fl-builder-user-templates-admin-list.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. ( function( $ ) {
  2. /**
  3. * Handles logic for the user templates admin list interface.
  4. *
  5. * @class FLBuilderUserTemplatesAdminList
  6. * @since 1.10
  7. */
  8. FLBuilderUserTemplatesAdminList = {
  9. /**
  10. * Initializes the user templates admin list interface.
  11. *
  12. * @since 1.10
  13. * @access private
  14. * @method _init
  15. */
  16. _init: function()
  17. {
  18. this._setupAddNewButton();
  19. this._setupSearch();
  20. this._fixCategories();
  21. },
  22. /**
  23. * Changes the Add New button URL to point to our
  24. * custom Add New page.
  25. *
  26. * @since 1.10
  27. * @access private
  28. * @method _setupSearch
  29. */
  30. _setupAddNewButton: function()
  31. {
  32. var url = FLBuilderConfig.addNewURL + '&fl-builder-template-type=' + FLBuilderConfig.userTemplateType;
  33. $( '.page-title-action' ).attr( 'href', url ).show();
  34. },
  35. /**
  36. * Adds a hidden input to the search for the user
  37. * template type.
  38. *
  39. * @since 1.10
  40. * @access private
  41. * @method _setupSearch
  42. */
  43. _setupSearch: function()
  44. {
  45. var type = FLBuilderConfig.userTemplateType,
  46. input = '<input type="hidden" name="fl-builder-template-type" value="' + type + '">'
  47. $( '.search-box' ).after( input );
  48. },
  49. _fixCategories: function() {
  50. $('.type-fl-builder-template').each( function( i,v ) {
  51. el = $(v).find('.taxonomy-fl-builder-template-category a');
  52. url = el.attr('href') + '&fl-builder-template-type=' + FLBuilderConfig.userTemplateType
  53. el.attr('href', url)
  54. })
  55. }
  56. };
  57. // Initialize
  58. $( function() { FLBuilderUserTemplatesAdminList._init(); } );
  59. } )( jQuery );