address.js
4 years ago
admin-settings.js
4 years ago
count.js
4 years ago
file_upload.js
4 years ago
image.js
4 years ago
infinite_table.js
4 years ago
opening-hours.js
4 years ago
ordering.js
4 years ago
scheduler.js
4 years ago
spectrum.js
4 years ago
admin-settings.js
104 lines
| 1 | jQuery(document).ready(function() { |
| 2 | |
| 3 | if ( ! jQuery.isFunction( jQuery.fn.spectrum ) ) { return; } |
| 4 | |
| 5 | jQuery('.sap-spectrum').spectrum({ |
| 6 | showInput: true, |
| 7 | showInitial: true, |
| 8 | preferredFormat: "hex", |
| 9 | allowEmpty: true |
| 10 | }); |
| 11 | |
| 12 | jQuery('.sap-spectrum').css('display', 'inline'); |
| 13 | |
| 14 | jQuery('.sap-spectrum').on('change', function() { |
| 15 | if (jQuery(this).val() != "") { |
| 16 | jQuery(this).css('background', jQuery(this).val()); |
| 17 | var rgb = EWD_SAP_hexToRgb(jQuery(this).val()); |
| 18 | var Brightness = (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000; |
| 19 | if (Brightness < 100) {jQuery(this).css('color', '#ffffff');} |
| 20 | else {jQuery(this).css('color', '#000000');} |
| 21 | } |
| 22 | else { |
| 23 | jQuery(this).css('background', 'none'); |
| 24 | } |
| 25 | }); |
| 26 | |
| 27 | jQuery('.sap-spectrum').each(function() { |
| 28 | if (jQuery(this).val() != "") { |
| 29 | jQuery(this).css('background', jQuery(this).val()); |
| 30 | var rgb = EWD_SAP_hexToRgb(jQuery(this).val()); |
| 31 | var Brightness = (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000; |
| 32 | if (Brightness < 100) {jQuery(this).css('color', '#ffffff');} |
| 33 | else {jQuery(this).css('color', '#000000');} |
| 34 | } |
| 35 | }); |
| 36 | |
| 37 | jQuery( 'fieldset[data-conditional_on]' ).each( function() { |
| 38 | |
| 39 | var option = jQuery( this ); |
| 40 | var option_name = jQuery( 'input[name="option_page"]' ).val() + '[' + option.data( 'conditional_on' ) + ']'; |
| 41 | console.log( option_name ); |
| 42 | jQuery( '[name="' + option_name + '"], [name="' + option_name + '[]"]' ).on( 'change', function() { |
| 43 | |
| 44 | var option_value = jQuery( this ).attr( 'type' ) != 'checkbox' ? jQuery( this ).val() : |
| 45 | ( ( option.data( 'conditional_on_value' ) == 1 || option.data( 'conditional_on_value' ) == '' ) ? jQuery( this ).is( ':checked' ) : |
| 46 | ( jQuery( this ).is( ':checked' ) ? option.data( 'conditional_on_value' ) : false ) ); |
| 47 | console.log( option_name ); console.log( option_value ); console.log( option.data( 'conditional_on_value' ) ); |
| 48 | if ( option_value == option.data( 'conditional_on_value' ) ) { |
| 49 | |
| 50 | option.parent().parent().removeClass( 'sap-hidden' ); |
| 51 | } |
| 52 | else { |
| 53 | |
| 54 | option.parent().parent().addClass( 'sap-hidden' ); |
| 55 | } |
| 56 | }); |
| 57 | }); |
| 58 | }); |
| 59 | |
| 60 | function EWD_SAP_hexToRgb(hex) { |
| 61 | var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); |
| 62 | return result ? { |
| 63 | r: parseInt(result[1], 16), |
| 64 | g: parseInt(result[2], 16), |
| 65 | b: parseInt(result[3], 16) |
| 66 | } : null; |
| 67 | } |
| 68 | |
| 69 | //OPTIONS PAGE YES/NO TOGGLE SWITCHES |
| 70 | jQuery(document).ready(function($){ |
| 71 | $('.sap-admin-option-toggle').on('change', function() { |
| 72 | var Input_Name = $(this).data('inputname'); |
| 73 | if ($(this).is(':checked')) { |
| 74 | $('input[name="' + Input_Name + '"][value="1"]').prop('checked', true).trigger('change'); |
| 75 | $('input[name="' + Input_Name + '"][value=""]').prop('checked', false); |
| 76 | } |
| 77 | else { |
| 78 | $('input[name="' + Input_Name + '"][value="1"]').prop('checked', false).trigger('change'); |
| 79 | $('input[name="' + Input_Name + '"][value=""]').prop('checked', true); |
| 80 | } |
| 81 | }); |
| 82 | }); |
| 83 | |
| 84 | /*LOCK BOXES*/ |
| 85 | jQuery( document ).ready( function() { |
| 86 | |
| 87 | function resizeLockdownBoxes() { |
| 88 | jQuery('.sap-premium-options-table-overlay').each(function(){ |
| 89 | |
| 90 | var eachProTableOverlay = jQuery( this ); |
| 91 | var associatedTable = eachProTableOverlay.next(); |
| 92 | associatedTable.css('min-height', '260px'); |
| 93 | var tablePosition = associatedTable.position(); |
| 94 | |
| 95 | eachProTableOverlay.css( 'width', associatedTable.outerWidth(true) + 'px' ); |
| 96 | eachProTableOverlay.css( 'height', associatedTable.outerHeight() + 'px' ); |
| 97 | eachProTableOverlay.css( 'left', tablePosition.left + 'px' ); |
| 98 | eachProTableOverlay.css( 'top', tablePosition.top + 'px' ); |
| 99 | }); |
| 100 | } |
| 101 | |
| 102 | setTimeout( resizeLockdownBoxes, 750 ); |
| 103 | jQuery( window ).on( 'resize', resizeLockdownBoxes ); |
| 104 | }); |