-
Notifications
You must be signed in to change notification settings - Fork 0
/
jquery.select-dependency.min.js
5 lines (5 loc) · 1.22 KB
/
jquery.select-dependency.min.js
1
2
3
4
5
/* Copyright (c) 2016 Vincent Guyard ([email protected]) http://www.onaxis.cl
* Licensed under GPL (http://www.opensource.org/licenses/gpl-2.0.php)
* Use only for non-commercial usage.
*/
!function(a){jQuery.fn.SelectDependency=function(t){var e={onchange:function(){},all_value:"-1",show_all:!1};a.extend(e,t);return this.filter("[data-sd_group]").size()?this:(document.group_id=document.group_id?document.group_id+1:1,this.data("sd_group",document.group_id).attr("data-sd_group",document.group_id),this.each(function(){this.SelectDependencyBackup=a(this).clone(),a(this).on("change",function(){if(!a("body").hasClass("sd_lock")&&a(this).data("impact")){a("body").addClass("sd_lock");var t=a(this),o=a("[data-sd_group="+t.data("sd_group")+"]");if(o.each(function(){var t=a(this).val();a(this).html(this.SelectDependencyBackup.html()),a(this).val(t)}),e.show_all&&o.each(function(){var e=a(this).data("impact");if(e){var o=t.find("option:selected").data(e);o&&a(this).val(o)}}),e.show_all&&t.val()==e.all_value)return a("body").removeClass("sd_lock");o.find("option[data-"+t.data("impact")+"][data-"+t.data("impact")+"!="+t.val()+"]").remove(),a.proxy(e.onchange,this)(),a("body").removeClass("sd_lock")}})}).first().trigger("change"),this)}}(jQuery);