Changeset 2034194
- Timestamp:
- 02/19/2019 01:46:47 PM (7 years ago)
- Location:
- sermon-manager-for-wordpress/trunk/assets/js/admin/settings
- Files:
-
- 2 edited
-
conditionals.js (modified) (3 diffs)
-
conditionals.min.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
sermon-manager-for-wordpress/trunk/assets/js/admin/settings/conditionals.js
r2034188 r2034194 121 121 // If we should get options via Ajax. 122 122 if ( is_ajax ) { 123 sm_reset_option_value( element, ! table_row.hasClass( 'hidden' ) ); 124 123 125 let data = { 124 126 'action': 'sm_settings_get_select_data', … … 135 137 ).always( 136 138 function () { 137 // Reset element value. 138 switch ( element.prop( 'tagName' ) ) { 139 case 'SELECT': 140 element.find( 'option' ).each( 141 function () { 142 jQuery( this.remove() ); 143 } 144 ); 145 if ( ! table_row.hasClass( 'hidden' ) ) { 146 element.append( jQuery( '<option/>' ).val( '' ).text( 'Loading...' ) ); 147 } 148 break; 149 } 139 sm_reset_option_value( element, ! table_row.hasClass( 'hidden' ) ); 150 140 } 151 141 ).done( … … 200 190 } 201 191 192 /** 193 * Clears the current option value. 194 * 195 * @type {object} The option element. 196 * @type {boolean} If we should show that it's loading. 197 */ 198 function sm_reset_option_value( element, write_loading ) { 199 switch ( element.prop( 'tagName' ) ) { 200 case 'SELECT': 201 element.find( 'option' ).each( 202 function () { 203 jQuery( this.remove() ); 204 } 205 ); 206 } 207 if ( write_loading ) { 208 element.append( jQuery( '<option/>' ).val( '' ).text( 'Loading...' ) ); 209 } 210 } 202 211 203 212 /** -
sermon-manager-for-wordpress/trunk/assets/js/admin/settings/conditionals.min.js
r2034188 r2034194 1 "undefined"!=typeof sm_conditionals&&jQuery(function(){jQuery.each(sm_conditionals,function(a,b){let c=jQuery("#"+a),d=c.closest("tr");jQuery.each(b,function(a,b){let c=b.id,e=jQuery("#"+c),f=sm_isset(b.value)?b.value:b["!value"],g=sm_isset(b["!value"]);e.on("change",function(){let a=this.value;sm_hide_show_elements(f,a,g,d)}),sm_hide_show_elements(f,e.val(),g,d)})})});function sm_hide_show_elements(a,b,c,d){let e=d.find("select"),f=a!==b,g=!!e.data("ajax")&&e.data("ajax");if(f=c?!f:f,g||(f?d.addClass("hidden"):d.removeClass("hidden")),g){ jQuery.ajax({method:"POST",url:ajaxurl,data:{action:"sm_settings_get_select_data",id:b}}).always(function(){switch(e.prop("tagName")){case"SELECT":e.find("option").each(function(){jQuery(this.remove())}),d.hasClass("hidden")||e.append(jQuery("<option/>").val("").text("Loading..."));}}).done(function(a){if("false"===a)a=!1;else try{a=JSON.parse(a)}catch(b){a=!1}if("object"==typeof a)switch(d.removeClass("hidden"),e.prop("tagName")){case"SELECT":e.find("option").each(function(){jQuery(this.remove())}),jQuery.each(a,function(a,b){d.find("select").append(jQuery("<option/>").val(a).text(b))});}!1===a&&d.addClass("hidden")}).fail(function(){switch(e.prop("tabName")){case"SELECT":e.append(jQuery("<option/>").val("").text("Error."));}})}}function sm_isset(a){try{return"undefined"!=typeof a}catch(a){return!1}}1 "undefined"!=typeof sm_conditionals&&jQuery(function(){jQuery.each(sm_conditionals,function(a,b){let c=jQuery("#"+a),d=c.closest("tr");jQuery.each(b,function(a,b){let c=b.id,e=jQuery("#"+c),f=sm_isset(b.value)?b.value:b["!value"],g=sm_isset(b["!value"]);e.on("change",function(){let a=this.value;sm_hide_show_elements(f,a,g,d)}),sm_hide_show_elements(f,e.val(),g,d)})})});function sm_hide_show_elements(a,b,c,d){let e=d.find("select"),f=a!==b,g=!!e.data("ajax")&&e.data("ajax");if(f=c?!f:f,g||(f?d.addClass("hidden"):d.removeClass("hidden")),g){sm_reset_option_value(e,!d.hasClass("hidden"));jQuery.ajax({method:"POST",url:ajaxurl,data:{action:"sm_settings_get_select_data",id:b}}).always(function(){sm_reset_option_value(e,!d.hasClass("hidden"))}).done(function(a){if("false"===a)a=!1;else try{a=JSON.parse(a)}catch(b){a=!1}if("object"==typeof a)switch(d.removeClass("hidden"),e.prop("tagName")){case"SELECT":e.find("option").each(function(){jQuery(this.remove())}),jQuery.each(a,function(a,b){d.find("select").append(jQuery("<option/>").val(a).text(b))});}!1===a&&d.addClass("hidden")}).fail(function(){switch(e.prop("tabName")){case"SELECT":e.append(jQuery("<option/>").val("").text("Error."));}})}}function sm_reset_option_value(a,b){switch(a.prop("tagName")){case"SELECT":a.find("option").each(function(){jQuery(this.remove())});}b&&a.append(jQuery("<option/>").val("").text("Loading..."))}function sm_isset(a){try{return"undefined"!=typeof a}catch(a){return!1}}
Note: See TracChangeset
for help on using the changeset viewer.