settings.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. (function($){
  2. FLBuilder.registerModuleHelper( 'vamtam-heading', {
  3. rules: {
  4. heading: {
  5. required: true
  6. }
  7. },
  8. init: function() {
  9. var form = $( '.fl-builder-settings' );
  10. // Init validation events.
  11. this._fontSizeChanged();
  12. this._mobileFontSizeChanged();
  13. // Validation events.
  14. form.find( 'select[name=font_size]' ).on( 'change', this._fontSizeChanged );
  15. form.find( 'select[name=r_font_size]' ).on( 'change', this._mobileFontSizeChanged );
  16. },
  17. _fontSizeChanged: function() {
  18. var form = $( '.fl-builder-settings' ),
  19. fontSize = form.find( 'select[name=font_size]' ).val(),
  20. customSize = form.find( 'input[name=custom_font_size]' );
  21. this._changeFontSize( fontSize, customSize );
  22. },
  23. _mobileFontSizeChanged: function() {
  24. var form = $( '.fl-builder-settings' ),
  25. fontSize = form.find( 'select[name=r_font_size]' ).val(),
  26. customSize = form.find( 'input[name=r_custom_font_size]' );
  27. this._changeFontSize( fontSize, customSize );
  28. },
  29. _changeFontSize: function( fontSize, customSize ) {
  30. customSize.rules( 'remove' );
  31. if ( fontSize === 'custom' ) {
  32. customSize.rules( 'add', {
  33. number: true,
  34. required: true
  35. } );
  36. }
  37. }
  38. });
  39. })(jQuery);