/* * jQuery Form Styler v2.0.2 * https://github.com/Dimox/jQueryFormStyler * * Copyright 2012-2017 Dimox (http://dimox.name/) * Released under the MIT license. * * Date: 2017.10.22 * */ (function(b){"function"===typeof define&&define.amd?define(["jquery"],b):"object"===typeof exports?module.exports=b($||require("jquery")):b(jQuery)})(function(b){function x(c,a){this.element=c;this.options=b.extend({},Q,a);var e=this.options.locale;void 0!==this.options.locales[e]&&b.extend(this.options,this.options.locales[e]);this.init()}function D(c){if(!b(c.target).parents().hasClass("jq-selectbox")&&"OPTION"!=c.target.nodeName&&b("div.jq-selectbox.opened").length){c=b("div.jq-selectbox.opened"); var a=b("div.jq-selectbox__search input",c),e=b("div.jq-selectbox__dropdown",c);c.find("select").data("_styler").options.onSelectClosed.call(c);a.length&&a.val("").keyup();e.hide().find("li.sel").addClass("selected");c.removeClass("focused opened dropup dropdown")}}var Q={idSuffix:"-styler",filePlaceholder:"\u0424\u0430\u0439\u043b \u043d\u0435 \u0432\u044b\u0431\u0440\u0430\u043d",fileBrowse:"\u041e\u0431\u0437\u043e\u0440...",fileNumber:"\u0412\u044b\u0431\u0440\u0430\u043d\u043e \u0444\u0430\u0439\u043b\u043e\u0432: %s", selectPlaceholder:"\u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435...",selectSearch:!1,selectSearchLimit:10,selectSearchNotFound:"\u0421\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u0439 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u043e",selectSearchPlaceholder:"\u041f\u043e\u0438\u0441\u043a...",selectVisibleOptions:0,selectSmartPositioning:!0,locale:"ru",locales:{en:{filePlaceholder:"No file selected",fileBrowse:"Browse...",fileNumber:"Selected files: %s",selectPlaceholder:"Select...", selectSearchNotFound:"No matches found",selectSearchPlaceholder:"Search..."}},onSelectOpened:function(){},onSelectClosed:function(){},onFormStyled:function(){}};x.prototype={init:function(){function c(){void 0!==a.attr("id")&&""!==a.attr("id")&&(this.id=a.attr("id")+e.idSuffix);this.title=a.attr("title");this.classes=a.attr("class");this.data=a.data()}var a=b(this.element),e=this.options,t=navigator.userAgent.match(/(iPad|iPhone|iPod)/i)&&!navigator.userAgent.match(/(Windows\sPhone)/i)?!0:!1,x=navigator.userAgent.match(/Android/i)&& !navigator.userAgent.match(/(Windows\sPhone)/i)?!0:!1;if(a.is(":checkbox")){var A=function(){var e=new c,d=b('
q&&(k=m);0===q&&(m="auto");var q=function(){n.height("auto").css({bottom:"auto", top:H});var a=function(){r.css("max-height",Math.floor((f-20-G)/c)*c)};a();r.css("max-height",m);"none"!=z&&r.css("max-height",z);fk+G+20?(q(),g.removeClass("dropup").addClass("dropdown")):(u(),g.removeClass("dropdown").addClass("dropup")): !1===w||0===w?f>k+G+20&&(q(),g.removeClass("dropup").addClass("dropdown")):(n.height("auto").css({bottom:"auto",top:H}),r.css("max-height",m),"none"!=z&&r.css("max-height",z));g.offset().left+n.outerWidth()>d.width()&&n.css({left:"auto",right:0});b("div.jqselect").css({zIndex:B-1}).removeClass("opened");g.css({zIndex:B});n.is(":hidden")?(b("div.jq-selectbox__dropdown:visible").hide(),n.show(),g.addClass("opened focused"),e.onSelectOpened.call(g)):(n.hide(),g.removeClass("opened dropup dropdown"), b("div.jq-selectbox").filter(".opened").length&&e.onSelectClosed.call(g));x.length&&(x.val("").keyup(),I.hide(),x.keyup(function(){var c=b(this).val();p.each(function(){b(this).html().match(new RegExp(".*?"+c+".*?","i"))?b(this).show():b(this).hide()});""===l.first().text()&&""!==a.data("placeholder")&&p.first().hide();1>p.filter(":visible").length?I.show():I.hide()}));p.filter(".selected").length&&(""===a.val()?r.scrollTop(0):(0!==r.innerHeight()/c%2&&(c/=2),r.scrollTop(r.scrollTop()+p.filter(".selected").position().top- r.innerHeight()/2+c)));v(r)}});p.hover(function(){b(this).siblings().removeClass("selected")});p.filter(".selected").text();p.filter(":not(.disabled):not(.optgroup)").click(function(){a.focus();var c=b(this),d=c.text();if(!c.is(".selected")){var q=c.index(),q=q-c.prevAll(".optgroup").length;c.addClass("selected sel").siblings().removeClass("selected sel");l.prop("selected",!1).eq(q).prop("selected",!0);u.text(d);g.data("jqfs-class")&&g.removeClass(g.data("jqfs-class"));g.data("jqfs-class",c.data("jqfs-class")); g.addClass(c.data("jqfs-class"));a.change()}n.hide();g.removeClass("opened dropup dropdown");e.onSelectClosed.call(g)});n.mouseout(function(){b("li.sel",n).addClass("selected")});a.on("change.styler",function(){u.text(l.filter(":selected").text()).removeClass("placeholder");p.removeClass("selected sel").not(".optgroup").eq(a[0].selectedIndex).addClass("selected sel");l.first().text()!=p.filter(".selected").text()?g.addClass("changed"):g.removeClass("changed")}).on("focus.styler",function(){g.addClass("focused"); b("div.jqselect").not(".focused").removeClass("opened dropup dropdown").find("div.jq-selectbox__dropdown").hide()}).on("blur.styler",function(){g.removeClass("focused")}).on("keydown.styler keyup.styler",function(b){var c=p.data("li-height");""===a.val()?u.text(y).addClass("placeholder"):u.text(l.filter(":selected").text());p.removeClass("selected sel").not(".optgroup").eq(a[0].selectedIndex).addClass("selected sel");if(38==b.which||37==b.which||33==b.which||36==b.which)""===a.val()?r.scrollTop(0): r.scrollTop(r.scrollTop()+p.filter(".selected").position().top);40!=b.which&&39!=b.which&&34!=b.which&&35!=b.which||r.scrollTop(r.scrollTop()+p.filter(".selected").position().top-r.innerHeight()+c);13==b.which&&(b.preventDefault(),n.hide(),g.removeClass("opened dropup dropdown"),e.onSelectClosed.call(g))}).on("keydown.styler",function(a){32==a.which&&(a.preventDefault(),O.click())});D.registered||(b(document).on("click",D),D.registered=!0)}function f(){var e=new c,h=b('').attr({id:e.id, title:e.title}).addClass(e.classes).data(e.data);a.after(h);d();h.append(" "+E+"
");var f=b("ul",h),m=b("li",h),e=a.attr("size"),k=f.outerHeight(),t=m.outerHeight();void 0!==e&&0h.height()&&(f.css("overflowY","scroll"),v(f),m.filter(".selected").length&&f.scrollTop(f.scrollTop()+m.filter(".selected").position().top));a.prependTo(h);if(a.is(":disabled"))h.addClass("disabled"),l.each(function(){b(this).is(":selected")&&m.eq(b(this).index()).addClass("selected")}); else if(m.filter(":not(.disabled):not(.optgroup)").click(function(c){a.focus();var d=b(this);c.ctrlKey||c.metaKey||d.addClass("selected");c.shiftKey||d.addClass("first");c.ctrlKey||c.metaKey||c.shiftKey||d.siblings().removeClass("selected first");if(c.ctrlKey||c.metaKey)d.is(".selected")?d.removeClass("selected first"):d.addClass("selected first"),d.siblings().removeClass("first");if(c.shiftKey){var e=!1,f=!1;d.siblings().removeClass("selected").siblings(".first").addClass("selected");d.prevAll().each(function(){b(this).is(".first")&& (e=!0)});d.nextAll().each(function(){b(this).is(".first")&&(f=!0)});e&&d.prevAll().each(function(){if(b(this).is(".selected"))return!1;b(this).not(".disabled, .optgroup").addClass("selected")});f&&d.nextAll().each(function(){if(b(this).is(".selected"))return!1;b(this).not(".disabled, .optgroup").addClass("selected")});1==m.filter(".selected").length&&d.addClass("first")}l.prop("selected",!1);m.filter(".selected").each(function(){var a=b(this),c=a.index();a.is(".option")&&(c-=a.prevAll(".optgroup").length); l.eq(c).prop("selected",!0)});a.change()}),l.each(function(a){b(this).data("optionIndex",a)}),a.on("change.styler",function(){m.removeClass("selected");var a=[];l.filter(":selected").each(function(){a.push(b(this).data("optionIndex"))});m.not(".optgroup").filter(function(c){return-1 h.height())a.on("keydown.styler",function(a){38!=a.which&&37!=a.which&& 33!=a.which||f.scrollTop(f.scrollTop()+m.filter(".selected").position().top-t);40!=a.which&&39!=a.which&&34!=a.which||f.scrollTop(f.scrollTop()+m.filter(".selected:last").position().top-f.innerHeight()+2*t)})}var l=b("option",a),E="";a.is("[multiple]")?x||t||f():k()};P();a.on("refresh",function(){a.off(".styler").parent().before(a).remove();P()})}else if(a.is(":reset"))a.on("click",function(){setTimeout(function(){a.closest("form").find("input, select").trigger("refresh")},1)})},destroy:function(){var c= b(this.element);c.is(":checkbox")||c.is(":radio")?(c.removeData("_styler").off(".styler refresh").removeAttr("style").parent().before(c).remove(),c.closest("label").add('label[for="'+c.attr("id")+'"]').off(".styler")):c.is('input[type="number"]')?c.removeData("_styler").off(".styler refresh").closest(".jq-number").before(c).remove():(c.is(":file")||c.is("select"))&&c.removeData("_styler").off(".styler refresh").removeAttr("style").parent().before(c).remove()}};b.fn.styler=function(c){var a=arguments; if(void 0===c||"object"===typeof c)return this.each(function(){b.data(this,"_styler")||b.data(this,"_styler",new x(this,c))}).promise().done(function(){var a=b(this[0]).data("_styler");a&&a.options.onFormStyled.call()}),this;if("string"===typeof c&&"_"!==c[0]&&"init"!==c){var e;this.each(function(){var t=b.data(this,"_styler");t instanceof x&&"function"===typeof t[c]&&(e=t[c].apply(t,Array.prototype.slice.call(a,1)))});return void 0!==e?e:this}};D.registered=!1});