/* jQuery Form Styler v1.5.5 | (c) Dimox | https://github.com/Dimox/jQueryFormStyler */ (function(c){c.fn.styler=function(D){var d=c.extend({wrapper:"form",idSuffix:"-styler",filePlaceholder:"\u0424\u0430\u0439\u043b \u043d\u0435 \u0432\u044b\u0431\u0440\u0430\u043d",fileBrowse:"\u041e\u0431\u0437\u043e\u0440...",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,singleSelectzIndex:"100",selectSmartPositioning:!0,onSelectOpened:function(){},onSelectClosed:function(){},onFormStyled:function(){}},D);return this.each(function(){function w(){var c="",n="",b="",v="";void 0!==a.attr("id")&&""!==a.attr("id")&&(c=' id="'+a.attr("id")+d.idSuffix+'"');void 0!==a.attr("title")&&""!==a.attr("title")&&(n=' title="'+a.attr("title")+'"');void 0!==a.attr("class")&&""!==a.attr("class")&&(b=" "+a.attr("class"));for(var r=a.data(),g=0;ga.parent("div.jq-checkbox").length){var d=function(){var d=new w,b=c("
');a.css({position:"absolute",zIndex:"-1",opacity:0,margin:0,padding:0}).after(b).prependTo(b);b.attr("unselectable","on").css({"-webkit-user-select":"none","-moz-user-select":"none","-ms-user-select":"none", "-o-user-select":"none","user-select":"none",display:"inline-block",position:"relative",overflow:"hidden"});a.is(":checked")&&b.addClass("checked");a.is(":disabled")&&b.addClass("disabled");b.on("click.styler",function(){b.is(".disabled")||(a.is(":checked")?(a.prop("checked",!1),b.removeClass("checked")):(a.prop("checked",!0),b.addClass("checked")),a.change());return!1});a.closest("label").add('label[for="'+a.attr("id")+'"]').click(function(a){b.click();a.preventDefault()});a.on("change.styler",function(){a.is(":checked")? b.addClass("checked"):b.removeClass("checked")}).on("keydown.styler",function(a){32==a.which&&b.click()}).on("focus.styler",function(){b.is(".disabled")||b.addClass("focused")}).on("blur.styler",function(){b.removeClass("focused")})};d();a.on("refresh",function(){a.off(".styler").parent().before(a).remove();d()})}});else if(a.is(":radio"))a.each(function(){if(1>a.parent("div.jq-radio").length){var h=function(){var n=new w,b=c("
'); a.css({position:"absolute",zIndex:"-1",opacity:0,margin:0,padding:0}).after(b).prependTo(b);b.attr("unselectable","on").css({"-webkit-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","-o-user-select":"none","user-select":"none",display:"inline-block",position:"relative"});a.is(":checked")&&b.addClass("checked");a.is(":disabled")&&b.addClass("disabled");b.on("click.styler",function(){b.is(".disabled")||(b.closest(d.wrapper).find('input[name="'+a.attr("name")+'"]').prop("checked", !1).parent().removeClass("checked"),a.prop("checked",!0).parent().addClass("checked"),a.change());return!1});a.closest("label").add('label[for="'+a.attr("id")+'"]').click(function(a){b.click();a.preventDefault()});a.on("change.styler",function(){a.parent().addClass("checked")}).on("focus.styler",function(){b.is(".disabled")||b.addClass("focused")}).on("blur.styler",function(){b.removeClass("focused")})};h();a.on("refresh",function(){a.off(".styler").parent().before(a).remove();h()})}});else if(a.is(":file"))a.css({position:"absolute", top:0,right:0,width:"100%",height:"100%",opacity:0,margin:0,padding:0}).each(function(){if(1>a.parent("div.jq-file").length){var h=function(){var n=new w,b=c("'),h=c('
'+d.filePlaceholder+"
").appendTo(b);c('
'+d.fileBrowse+"
").appendTo(b);a.after(b);b.append(a);a.is(":disabled")&&b.addClass("disabled");a.on("change.styler", function(){var c=a.val();if(a.is("[multiple]"))for(var c="",g=a[0].files,n=0;n a.parent("div.jqselect").length){var h=function(){function n(a){a.off("mousewheel DOMMouseScroll").on("mousewheel DOMMouseScroll",function(a){var b=null;"mousewheel"==a.type?b=-1*a.originalEvent.wheelDelta:"DOMMouseScroll"==a.type&&(b=40*a.originalEvent.detail);b&&(a.stopPropagation(),a.preventDefault(),c(this).scrollTop(b+c(this).scrollTop()))})}function b(){for(var a=0,c=g.length;a'+g.eq(a).html()+"";g.eq(a).parent().is("optgroup")&&(void 0!==g.eq(a).parent().attr("class")&&(k=" "+g.eq(a).parent().attr("class")),b="'+g.eq(a).html()+"",g.eq(a).is(":first-child")&& (b='
  • '+g.eq(a).parent().attr("label")+"
  • "+b));x+=b}}function h(){var s=new w,e=c("
    ');a.css({margin:0,padding:0}).after(e).prependTo(e); var s=c("div.jq-selectbox__select",e),p=c("div.jq-selectbox__select-text",e),t=g.filter(":selected");b();var l="";d.selectSearch&&(l='
    '+d.selectSearchNotFound+"
    ");var k=c('
    '+l+'
      '+x+"
    "); e.append(k);var m=c("ul",k),f=c("li",k),u=c("input",k),A=c("div.jq-selectbox__not-found",k).hide();f.lengthq&&(q=a.innerWidth(),B=a.width());a.css({display:"block"})});var l=e.clone().appendTo("body").width("auto"),r=l.width();l.remove();r==e.width()&&(p.width(B),q+=e.find("div.jq-selectbox__trigger").width());q>e.width()&&k.width(q);""===a.val()? (l=a.data("placeholder"),void 0===l&&(l=d.selectPlaceholder),p.text(l).addClass("placeholder")):p.text(t.text());""===g.first().text()&&""!==a.data("placeholder")&&f.first().hide();a.css({position:"absolute",left:0,top:0,width:"100%",height:"100%",opacity:0});var v=e.outerHeight(),y=u.outerHeight(),z=m.css("max-height"),l=f.filter(".selected");1>l.length&&f.first().addClass("selected sel");void 0===f.data("li-height")&&f.data("li-height",f.outerHeight());var C=k.css("top");"auto"==k.css("left")&& k.css({left:0});"auto"==k.css("top")&&k.css({top:v});k.hide();l.length&&(g.first().text()!=t.text()&&e.addClass("changed"),e.data("jqfs-class",l.data("jqfs-class")),e.addClass(l.data("jqfs-class")));if(a.is(":disabled"))return e.addClass("disabled"),!1;s.click(function(){c("div.jq-selectbox").filter(".opened").length&&d.onSelectClosed.call(c("div.jq-selectbox").filter(".opened"));a.focus();if(!navigator.userAgent.match(/(iPad|iPhone|iPod)/g)){var b=c(window),l=f.data("li-height"),p=e.offset().top, t=b.height()-v-(p-b.scrollTop()),h=d.selectVisibleOptions,s=5*l,q=l*h;0h&&(s=q);0===h&&(q="auto");var h=function(){k.height("auto").css({bottom:"auto",top:C});var a=function(){m.css("max-height",Math.floor((t-20-y)/l)*l)};a();m.css("max-height",q);"none"!=z&&m.css("max-height",z);ts+y+20?h():r():!1===d.selectSmartPositioning&&t>s+y+20&&h();c("div.jqselect").css({zIndex:d.singleSelectzIndex-1}).removeClass("opened");e.css({zIndex:d.singleSelectzIndex});k.is(":hidden")?(c("div.jq-selectbox__dropdown:visible").hide(),k.show(),e.addClass("opened focused"),d.onSelectOpened.call(e)):(k.hide(),e.removeClass("opened"),c("div.jq-selectbox").filter(".opened").length&&d.onSelectClosed.call(e));u.length&&(u.val("").keyup(), A.hide(),u.keyup(function(){var b=c(this).val();f.each(function(){c(this).html().match(RegExp(".*?"+b+".*?","i"))?c(this).show():c(this).hide()});""===g.first().text()&&""!==a.data("placeholder")&&f.first().hide();1>f.filter(":visible").length?A.show():A.hide()}));f.filter(".selected").length&&(0!==m.innerHeight()/l%2&&(l/=2),m.scrollTop(m.scrollTop()+f.filter(".selected").position().top-m.innerHeight()/2+l));n(m);return!1}});f.hover(function(){c(this).siblings().removeClass("selected")});f.filter(".selected").text(); f.filter(".selected").text();f.filter(":not(.disabled):not(.optgroup)").click(function(){a.focus();var b=c(this),f=b.text();if(!b.is(".selected")){var m=b.index(),m=m-b.prevAll(".optgroup").length;b.addClass("selected sel").siblings().removeClass("selected sel");g.prop("selected",!1).eq(m).prop("selected",!0);p.text(f);e.data("jqfs-class")&&e.removeClass(e.data("jqfs-class"));e.data("jqfs-class",b.data("jqfs-class"));e.addClass(b.data("jqfs-class"));a.change()}k.hide();e.removeClass("opened");d.onSelectClosed.call(e)}); k.mouseout(function(){c("li.sel",k).addClass("selected")});a.on("change.styler",function(){p.text(g.filter(":selected").text()).removeClass("placeholder");f.removeClass("selected sel").not(".optgroup").eq(a[0].selectedIndex).addClass("selected sel");g.first().text()!=f.filter(".selected").text()?e.addClass("changed"):e.removeClass("changed")}).on("focus.styler",function(){e.addClass("focused");c("div.jqselect").not(".focused").removeClass("opened")}).on("blur.styler",function(){e.removeClass("focused")}).on("keydown.styler keyup.styler", function(b){var c=f.data("li-height");p.text(g.filter(":selected").text());f.removeClass("selected sel").not(".optgroup").eq(a[0].selectedIndex).addClass("selected sel");38!=b.which&&37!=b.which&&33!=b.which&&36!=b.which||m.scrollTop(m.scrollTop()+f.filter(".selected").position().top);40!=b.which&&39!=b.which&&34!=b.which&&35!=b.which||m.scrollTop(m.scrollTop()+f.filter(".selected").position().top-m.innerHeight()+c);32==b.which&&b.preventDefault();13==b.which&&(b.preventDefault(),k.hide(),e.removeClass("opened"), d.onSelectClosed.call(e))});c(document).on("click",function(a){c(a.target).parents().hasClass("jq-selectbox")||"OPTION"==a.target.nodeName||(c("div.jq-selectbox").filter(".opened").length&&d.onSelectClosed.call(c("div.jq-selectbox").filter(".opened")),u.length&&u.val("").keyup(),k.hide().find("li.sel").addClass("selected"),e.removeClass("focused opened"))})}function r(){var d=new w,e=c("'); a.css({margin:0,padding:0}).after(e);b();e.append("
      "+x+"
    ");var p=c("ul",e).css({position:"relative","overflow-x":"hidden","-webkit-overflow-scrolling":"touch"}),h=c("li",e).attr("unselectable","on").css({"-webkit-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","-o-user-select":"none","user-select":"none","white-space":"nowrap"}),d=a.attr("size"),l=p.outerHeight(),k=h.outerHeight();void 0!==d&&0e.height()&&(p.css("overflowY", "scroll"),n(p),h.filter(".selected").length&&p.scrollTop(p.scrollTop()+h.filter(".selected").position().top));a.prependTo(e).css({position:"absolute",left:0,top:0,width:"100%",height:"100%",opacity:0});if(a.is(":disabled"))e.addClass("disabled"),g.each(function(){c(this).is(":selected")&&h.eq(c(this).index()).addClass("selected")});else if(h.filter(":not(.disabled):not(.optgroup)").click(function(b){a.focus();var f=c(this);b.ctrlKey||b.metaKey||f.addClass("selected");b.shiftKey||f.addClass("first"); b.ctrlKey||(b.metaKey||b.shiftKey)||f.siblings().removeClass("selected first");if(b.ctrlKey||b.metaKey)f.is(".selected")?f.removeClass("selected first"):f.addClass("selected first"),f.siblings().removeClass("first");if(b.shiftKey){var d=!1,e=!1;f.siblings().removeClass("selected").siblings(".first").addClass("selected");f.prevAll().each(function(){c(this).is(".first")&&(d=!0)});f.nextAll().each(function(){c(this).is(".first")&&(e=!0)});d&&f.prevAll().each(function(){if(c(this).is(".selected"))return!1; c(this).not(".disabled, .optgroup").addClass("selected")});e&&f.nextAll().each(function(){if(c(this).is(".selected"))return!1;c(this).not(".disabled, .optgroup").addClass("selected")});1==h.filter(".selected").length&&f.addClass("first")}g.prop("selected",!1);h.filter(".selected").each(function(){var a=c(this),b=a.index();a.is(".option")&&(b-=a.prevAll(".optgroup").length);g.eq(b).prop("selected",!0)});a.change()}),g.each(function(a){c(this).data("optionIndex",a)}),a.on("change.styler",function(){h.removeClass("selected"); var a=[];g.filter(":selected").each(function(){a.push(c(this).data("optionIndex"))});h.not(".optgroup").filter(function(b){return-1e.height())a.on("keydown.styler",function(a){38!=a.which&&37!=a.which&&33!=a.which||p.scrollTop(p.scrollTop()+h.filter(".selected").position().top-k);40!=a.which&&39!=a.which&&34!=a.which||p.scrollTop(p.scrollTop()+h.filter(".selected:last").position().top- p.innerHeight()+2*k)})}var g=c("option",a),x="";a.is("[multiple]")?r():h()};h();a.on("refresh",function(){a.off(".styler").parent().before(a).remove();h()})}});else if(a.is(":reset"))a.on("click",function(){setTimeout(function(){a.closest(d.wrapper).find("input, select").trigger("refresh")},1)})}).promise().done(function(){d.onFormStyled.call()})}})(jQuery);