fl-builder-template-data-exporter.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. ( function( $ ) {
  2. /**
  3. * @class FLBuilderTemplateDataExporter
  4. * @since 1.8
  5. */
  6. FLBuilderTemplateDataExporter = {
  7. /**
  8. * @since 1.8
  9. * @method init
  10. */
  11. init: function()
  12. {
  13. $( 'input[name="fl-builder-template-data-exporter-all"]' ).on( 'click', FLBuilderTemplateDataExporter._allCheckboxClicked );
  14. $( '.fl-builder-template-data-checkbox' ).on( 'click', FLBuilderTemplateDataExporter._checkboxClicked );
  15. },
  16. /**
  17. * @since 1.8
  18. * @access private
  19. * @method _allCheckboxClicked
  20. */
  21. _allCheckboxClicked: function()
  22. {
  23. var checkbox = $( this ),
  24. parent = checkbox.parents( '.fl-builder-template-data-section ' ),
  25. checkboxes = parent.find( '.fl-builder-template-data-checkbox' );
  26. if ( checkbox.is( ':checked' ) ) {
  27. checkboxes.prop( 'checked', true );
  28. }
  29. else {
  30. checkboxes.prop( 'checked', false );
  31. }
  32. },
  33. /**
  34. * @since 1.8
  35. * @access private
  36. * @method _checkboxClicked
  37. */
  38. _checkboxClicked: function()
  39. {
  40. var allChecked = true,
  41. parent = $( this ).parents( '.fl-builder-template-data-section ' ),
  42. checkboxes = parent.find( '.fl-builder-template-data-checkbox' ),
  43. allCheckbox = parent.find( 'input[name="fl-builder-template-data-exporter-all"]' );
  44. checkboxes.each( function() {
  45. if ( ! $( this ).is( ':checked' ) ) {
  46. allChecked = false;
  47. }
  48. });
  49. allCheckbox.prop( 'checked', allChecked );
  50. }
  51. };
  52. $( FLBuilderTemplateDataExporter.init );
  53. } )( jQuery );