Changeset 2042084
- Timestamp:
- 03/01/2019 11:54:21 AM (7 years ago)
- Location:
- sermon-manager-for-wordpress/trunk/assets/js/admin/settings
- Files:
-
- 2 edited
-
conditionals.js (modified) (1 diff)
-
conditionals.min.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
sermon-manager-for-wordpress/trunk/assets/js/admin/settings/conditionals.js
r2042078 r2042084 67 67 let selected_value = this.value; 68 68 69 69 70 // Hide or show the elements. 70 sm_hide_show_elements( target_value, selected_value, not, table_row );71 sm_hide_show_elements( target_value, conditional_element.closest( 'tr' ).hasClass( 'hidden' ) ? false : selected_value, not, table_row ); 71 72 } 72 73 ); 73 74 74 75 // Call the function first time. 75 sm_hide_show_elements( target_value, conditional_element. val(), not, table_row );76 sm_hide_show_elements( target_value, conditional_element.closest( 'tr' ).hasClass( 'hidden' ) ? false : conditional_element.val(), not, table_row ); 76 77 } 77 78 ); -
sermon-manager-for-wordpress/trunk/assets/js/admin/settings/conditionals.min.js
r2042078 r2042084 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"));let a=sm_get_query_params(document.location.search),c={action:"sm_settings_get_select_data",category:b,option_id:d.find("select").attr("id"),podcast_id:a.post};jQuery.ajax({method:"POST",url:ajaxurl,data:c}).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":if(e.find("option").each(function(){jQuery(this.remove())}),jQuery.each(a.options,function(a,b){d.find("select").append(jQuery("<option/>").val(a).text(b))}),a.selected?d.find("select").val(a.selected).change():d.find("select").prop("selectedIndex",0),0===Object.keys(a.options).length)return void d.addClass("hidden");}!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}}function sm_get_query_params(a){a=a.split("+").join(" ");for(var b,c={},d=/[?&]?([^=]+)=([^&]*)/g;b=d.exec(a);)c[decodeURIComponent(b[1])]=decodeURIComponent(b[2]);return c}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,!e.closest("tr").hasClass("hidden")&&a,g,d)}),sm_hide_show_elements(f,!e.closest("tr").hasClass("hidden")&&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"));let a=sm_get_query_params(document.location.search),c={action:"sm_settings_get_select_data",category:b,option_id:d.find("select").attr("id"),podcast_id:a.post};jQuery.ajax({method:"POST",url:ajaxurl,data:c}).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":if(e.find("option").each(function(){jQuery(this.remove())}),jQuery.each(a.options,function(a,b){d.find("select").append(jQuery("<option/>").val(a).text(b))}),a.selected?d.find("select").val(a.selected).change():d.find("select").prop("selectedIndex",0),0===Object.keys(a.options).length)return void d.addClass("hidden");}!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}}function sm_get_query_params(a){a=a.split("+").join(" ");for(var b,c={},d=/[?&]?([^=]+)=([^&]*)/g;b=d.exec(a);)c[decodeURIComponent(b[1])]=decodeURIComponent(b[2]);return c}
Note: See TracChangeset
for help on using the changeset viewer.