fl-builder-user-templates-admin-add.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. ( function( $ ) {
  2. /**
  3. * Handles logic for the user templates admin add new interface.
  4. *
  5. * @class FLBuilderUserTemplatesAdminAdd
  6. * @since 1.10
  7. */
  8. FLBuilderUserTemplatesAdminAdd = {
  9. /**
  10. * Initializes the user templates admin add new interface.
  11. *
  12. * @since 1.10
  13. * @access private
  14. * @method _init
  15. */
  16. _init: function()
  17. {
  18. this._bind();
  19. },
  20. /**
  21. * Binds events for the Add New form.
  22. *
  23. * @since 1.10
  24. * @access private
  25. * @method _bind
  26. */
  27. _bind: function()
  28. {
  29. $( 'select.fl-template-type' ).on( 'change', this._templateTypeChange );
  30. $( 'form.fl-new-template-form .dashicons-editor-help' ).tipTip();
  31. $( 'form.fl-new-template-form' ).validate();
  32. this._templateTypeChange();
  33. },
  34. /**
  35. * Callback for when the template type select changes.
  36. *
  37. * @since 1.10
  38. * @access private
  39. * @method _templateTypeChange
  40. */
  41. _templateTypeChange: function()
  42. {
  43. var val = $( 'select.fl-template-type' ).val(),
  44. module = $( '.fl-template-module-row' ),
  45. global = $( '.fl-template-global-row' ),
  46. add = $( '.fl-template-add' );
  47. module.toggle( 'module' == val );
  48. global.toggle( ( 'row' == val || 'module' == val ) );
  49. if ( '' == val ) {
  50. add.val( FLBuilderConfig.strings.addButton.add );
  51. }
  52. else {
  53. add.val( FLBuilderConfig.strings.addButton[ val ] );
  54. }
  55. }
  56. };
  57. // Initialize
  58. $( function() { FLBuilderUserTemplatesAdminAdd._init(); } );
  59. } )( jQuery );