; (function ($, window, document) { var defaults, pluginName, ProductSelect; pluginName = "ProductSelect"; defaults = { url: "/Level2/Leve2Order/GetZXL2Product", required: true, hasAll: false, Bigproduct_obj: "#BigPuc", Product_obj: "#Puc", GetModule: function () { } }; ProductSelect = (function () { function ProductSelect(element, options) { this.element = element; this.opts = $.extend(true, {}, defaults, options); this.init(); } return ProductSelect; })(); ProductSelect.prototype.init = function () { var Product_json = [], _this = this, $BigPuc = $(this.opts.Bigproduct_obj), $Product = $(this.opts.Product_obj); if (typeof this.opts.url === "string") { $.getJSON(this.opts.url, function (json) { Product_json = json; $.data(_this, "ProductJson", Product_json); _this.BigProductBind(Product_json); }); $BigPuc.bind("change", function () { _this.ProductBind(); }); $Product.bind("change", function () { _this.ModuleBind(); }); } }; ProductSelect.prototype.BigProductBind = function (json) { var select_html = "", _this = this, $prov = $(this.opts.Bigproduct_obj); if (this.opts.hasAll) { select_html = "" } $.each(json.Productlist, function (i, n) { select_html += ""; }); $prov.append(select_html); return this.ProductBind(); }; ProductSelect.prototype.ProductBind = function () { var $BigProduct, $Product, select_html, _this, Productdata; _this = this; $BigProduct = $(this.opts.Bigproduct_obj); $Product = $(this.opts.Product_obj); $Product.empty(); select_html = ""; this.data = $.data(this); if (this.opts.hasAll) { select_html = "" } if (this.data.ProductJson.Productlist[$BigProduct.get(0).selectedIndex]) { Productdata = typeof (this.data.ProductJson.Productlist[$BigProduct.get(0).selectedIndex].softProduct) === "undefined" ? "undefined" : this.data.ProductJson.Productlist[$BigProduct.get(0).selectedIndex].softProduct; $.data(_this, "ModuleJson", Productdata); if (Productdata !== "undefined") { $.each(Productdata, function (i, n) { select_html += ""; }); $Product.append(select_html); return this.ModuleBind(); } } }; ProductSelect.prototype.ModuleBind = function () { var $BigProduct, $Product, _this, Productdata, Moduledata; _this = this; $BigProduct = $(this.opts.Bigproduct_obj); $Product = $(this.opts.Product_obj); this.data = $.data(this); if (this.data.ModuleJson != "undefined" && this.data.ModuleJson[$Product.get(0).selectedIndex]) { Moduledata = typeof (this.data.ModuleJson[$Product.get(0).selectedIndex].softModule) === "undefined" ? "undefined" : this.data.ModuleJson[$Product.get(0).selectedIndex].softModule; _this.opts.GetModule(Moduledata); } } $.fn[pluginName] = function (options) { return this.each(function () { if (!$.data(this, pluginName)) { $.data(this, pluginName, new ProductSelect(this, options)); } }); } })(jQuery, window, document);