settings.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. (function($){
  2. FLBuilder.registerModuleHelper('accordion', {
  3. rules: {
  4. item_spacing: {
  5. required: true,
  6. number: true
  7. }
  8. },
  9. init: function()
  10. {
  11. var form = $( '.fl-builder-settings' ),
  12. labelSize = form.find( 'select[name=label_size]' ),
  13. itemSpacing = form.find( 'input[name=item_spacing]' );
  14. labelSize.on( 'change', this._previewLabelSize );
  15. itemSpacing.on( 'keyup', this._previewItemSpacing );
  16. },
  17. _previewLabelSize: function()
  18. {
  19. var size = $( '.fl-builder-settings select[name=label_size]' ).val(),
  20. wrap = FLBuilder.preview.elements.node.find( '.fl-accordion' );
  21. wrap.removeClass( 'fl-accordion-small' );
  22. wrap.removeClass( 'fl-accordion-medium' );
  23. wrap.removeClass( 'fl-accordion-large' );
  24. wrap.addClass( 'fl-accordion-' + size );
  25. },
  26. _previewItemSpacing: function()
  27. {
  28. var spacing = parseInt( $( '.fl-builder-settings input[name=item_spacing]' ).val(), 10 ),
  29. items = FLBuilder.preview.elements.node.find( '.fl-accordion-item' );
  30. items.attr( 'style', '' );
  31. if (isNaN( spacing ) || spacing === 0) {
  32. items.css( 'margin-bottom', '0px' );
  33. items.not( ':last-child' ).css( 'border-bottom', 'none' );
  34. } else {
  35. items.css( 'margin-bottom', spacing + 'px' );
  36. }
  37. }
  38. });
  39. })(jQuery);