(function(factory){if(typeof define==="function"&&define.amd){define(["jquery"],factory)}else if(typeof exports==="object"){module.exports=factory($||require("jquery"))}else{factory(jQuery)}})(function($){"use strict";var pluginName="styler",defaults={idSuffix:"-styler",filePlaceholder:"Файл не выбран",fileBrowse:"Обзор...",fileNumber:"Выбрано файлов: %s",selectPlaceholder:"Выберите...",selectSearch:false,selectSearchLimit:10,selectSearchNotFound:"Совпадений не найдено",selectSearchPlaceholder:"Поиск...",selectVisibleOptions:0,selectSmartPositioning:false,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(){}};function Plugin(element,options){this.element=element;this.options=$.extend({},defaults,options);var locale=this.options.locale;if(this.options.locales[locale]!==undefined){$.extend(this.options,this.options.locales[locale])}this.init()}Plugin.prototype={init:function(){var el=$(this.element);var opt=this.options;var iOS=navigator.userAgent.match(/(iPad|iPhone|iPod)/i)&&!navigator.userAgent.match(/(Windows\sPhone)/i)?true:false;var Android=navigator.userAgent.match(/Android/i)&&!navigator.userAgent.match(/(Windows\sPhone)/i)?true:false;function Attributes(){if(el.attr("id")!==undefined&&el.attr("id")!==""){this.id=el.attr("id")+opt.idSuffix}this.title=el.attr("title");this.classes=el.attr("class");this.data=el.data()}if(el.is(":checkbox")){var checkboxOutput=function(){var att=new Attributes;var checkbox=$('

').attr({id:att.id,title:att.title}).addClass(att.classes).data(att.data);el.after(checkbox).prependTo(checkbox);if(el.is(":checked"))checkbox.addClass("checked");if(el.is(":disabled"))checkbox.addClass("disabled");checkbox.click(function(e){e.preventDefault();el.triggerHandler("click");if(!checkbox.is(".disabled")){if(el.is(":checked")){el.prop("checked",false);checkbox.removeClass("checked")}else{el.prop("checked",true);checkbox.addClass("checked")}el.focus().change()}});el.closest("label").add('label[for="'+el.attr("id")+'"]').on("click.styler",function(e){if(!$(e.target).is("a")&&!$(e.target).closest(checkbox).length){checkbox.triggerHandler("click");e.preventDefault()}});el.on("change.styler",function(){if(el.is(":checked"))checkbox.addClass("checked");else checkbox.removeClass("checked")}).on("keydown.styler",function(e){if(e.which==32)checkbox.click()}).on("focus.styler",function(){if(!checkbox.is(".disabled"))checkbox.addClass("focused")}).on("blur.styler",function(){checkbox.removeClass("focused")})};checkboxOutput();el.on("refresh",function(){el.closest("label").add('label[for="'+el.attr("id")+'"]').off(".styler");el.off(".styler").parent().before(el).remove();checkboxOutput()})}else if(el.is(":radio")){var radioOutput=function(){var att=new Attributes;var radio=$('
').attr({id:att.id,title:att.title}).addClass(att.classes).data(att.data);el.after(radio).prependTo(radio);if(el.is(":checked"))radio.addClass("checked");if(el.is(":disabled"))radio.addClass("disabled");$.fn.commonParents=function(){var cachedThis=this;return cachedThis.first().parents().filter(function(){return $(this).find(cachedThis).length===cachedThis.length})};$.fn.commonParent=function(){return $(this).commonParents().first()};radio.click(function(e){e.preventDefault();el.triggerHandler("click");if(!radio.is(".disabled")){var inputName=$('input[name="'+el.attr("name")+'"]');inputName.commonParent().find(inputName).prop("checked",false).parent().removeClass("checked");el.prop("checked",true).parent().addClass("checked");el.focus().change()}});el.closest("label").add('label[for="'+el.attr("id")+'"]').on("click.styler",function(e){if(!$(e.target).is("a")&&!$(e.target).closest(radio).length){radio.triggerHandler("click");e.preventDefault()}});el.on("change.styler",function(){el.parent().addClass("checked")}).on("focus.styler",function(){if(!radio.is(".disabled"))radio.addClass("focused")}).on("blur.styler",function(){radio.removeClass("focused")})};radioOutput();el.on("refresh",function(){el.closest("label").add('label[for="'+el.attr("id")+'"]').off(".styler");el.off(".styler").parent().before(el).remove();radioOutput()})}else if(el.is(":file")){var fileOutput=function(){var att=new Attributes;var placeholder=el.data("placeholder");if(placeholder===undefined)placeholder=opt.filePlaceholder;var browse=el.data("browse");if(browse===undefined||browse==="")browse=opt.fileBrowse;var file=$('
'+'
'+placeholder+"
"+'
'+browse+"
"+"
").attr({id:att.id,title:att.title}).addClass(att.classes).data(att.data);el.after(file).appendTo(file);if(el.is(":disabled"))file.addClass("disabled");var value=el.val();var name=$("div.jq-file__name",file);if(value)name.text(value.replace(/.+[\\\/]/,""));el.on("change.styler",function(){var value=el.val();if(el.is("[multiple]")){value="";var files=el[0].files.length;if(files>0){var number=el.data("number");if(number===undefined)number=opt.fileNumber;number=number.replace("%s",files);value=number}}name.text(value.replace(/.+[\\\/]/,""));if(value===""){name.text(placeholder);file.removeClass("changed")}else{file.addClass("changed")}}).on("focus.styler",function(){file.addClass("focused")}).on("blur.styler",function(){file.removeClass("focused")}).on("click.styler",function(){file.removeClass("focused")})};fileOutput();el.on("refresh",function(){el.off(".styler").parent().before(el).remove();fileOutput()})}else if(el.is('input[type="number"]')){var numberOutput=function(){var att=new Attributes;var number=$('
'+'
'+'
'+"
").attr({id:att.id,title:att.title}).addClass(att.classes).data(att.data);el.after(number).prependTo(number).wrap('
');if(el.is(":disabled"))number.addClass("disabled");var min,max,step,timeout=null,interval=null;if(el.attr("min")!==undefined)min=el.attr("min");if(el.attr("max")!==undefined)max=el.attr("max");if(el.attr("step")!==undefined&&$.isNumeric(el.attr("step")))step=Number(el.attr("step"));else step=Number(1);var changeValue=function(spin){var value=el.val(),newValue;if(!$.isNumeric(value)){value=0;el.val("0")}if(spin.is(".minus")){newValue=Number(value)-step}else if(spin.is(".plus")){newValue=Number(value)+step}var decimals=(step.toString().split(".")[1]||[]).length;if(decimals>0){var multiplier="1";while(multiplier.length=min&&newValue=min)el.val(newValue)}else if(!$.isNumeric(min)&&$.isNumeric(max)){if(newValue0?1:-1;scrollTop=selector.scrollTop();if(scrollTop>=scrollDiff&&wheelDelta0){e.stopPropagation();e.preventDefault()}})}var option=$("option",el);var list="";function makeList(){for(var i=0;i"+op.html()+"";if(op.parent().is("optgroup")){if(op.parent().attr("class")!==undefined)optgroupClass=" "+op.parent().attr("class");li="
  • "+op.html()+"
  • ";if(op.is(":first-child")){li='
  • '+op.parent().attr("label")+"
  • "+li}}list+=li}}function doSelect(){var att=new Attributes;var searchHTML="";var selectPlaceholder=el.data("placeholder");var selectSearch=el.data("search");var selectSearchLimit=el.data("search-limit");var selectSearchNotFound=el.data("search-not-found");var selectSearchPlaceholder=el.data("search-placeholder");var selectSmartPositioning=el.data("smart-positioning");if(selectPlaceholder===undefined)selectPlaceholder=opt.selectPlaceholder;if(selectSearch===undefined||selectSearch==="")selectSearch=opt.selectSearch;if(selectSearchLimit===undefined||selectSearchLimit==="")selectSearchLimit=opt.selectSearchLimit;if(selectSearchNotFound===undefined||selectSearchNotFound==="")selectSearchNotFound=opt.selectSearchNotFound;if(selectSearchPlaceholder===undefined)selectSearchPlaceholder=opt.selectSearchPlaceholder;if(selectSmartPositioning===undefined||selectSmartPositioning==="")selectSmartPositioning=opt.selectSmartPositioning;var selectbox=$('
    '+'
    '+'
    '+'
    '+'
    '+"
    "+"
    ").attr({id:att.id,title:att.title}).addClass(att.classes).data(att.data);el.after(selectbox).prependTo(selectbox);var selectzIndex=selectbox.css("z-index");selectzIndex=selectzIndex>0?selectzIndex:1;var divSelect=$("div.jq-selectbox__select",selectbox);var divText=$("div.jq-selectbox__select-text",selectbox);var optionSelected=option.filter(":selected");makeList();if(selectSearch)searchHTML=''+'
    '+selectSearchNotFound+"
    ";var dropdown=$('
    '+searchHTML+""+"
    ");selectbox.append(dropdown);var ul=$("ul",dropdown);var li=$("li",dropdown);var search=$("input",dropdown);var notFound=$("div.jq-selectbox__not-found",dropdown).hide();if(li.lengthliWidthInner){liWidthInner=l.innerWidth();liWidth=l.width()}});li.css({display:""});if(divText.is(".placeholder")&&divText.width()>liWidthInner){divText.width(divText.width())}else{var selClone=selectbox.clone().appendTo("body").width("auto");var selCloneWidth=selClone.outerWidth();selClone.remove();if(selCloneWidth==selectbox.outerWidth()){divText.width(liWidth)}}if(liWidthInner>selectbox.width())dropdown.width(liWidthInner);if(option.first().text()===""&&el.data("placeholder")!==""){li.first().hide()}var selectHeight=selectbox.outerHeight(true);var searchHeight=search.parent().outerHeight(true)||0;var isMaxHeight=ul.css("max-height");var liSelected=li.filter(".selected");if(liSelected.length0&&visibleminHeight+searchHeight+20){dropDown();selectbox.removeClass("dropup").addClass("dropdown")}else{dropUp();selectbox.removeClass("dropdown").addClass("dropup")}}else if(selectSmartPositioning===false||selectSmartPositioning===0){if(bottomOffset>minHeight+searchHeight+20){dropDown();selectbox.removeClass("dropup").addClass("dropdown")}}else{dropdown.height("auto").css({bottom:"auto",top:position});ul.css("max-height",newHeight);if(isMaxHeight!="none"){ul.css("max-height",isMaxHeight)}}if(selectbox.offset().left+dropdown.outerWidth()>win.width()){dropdown.css({left:"auto",right:0})}$("div.jqselect").css({zIndex:selectzIndex-1}).removeClass("opened");selectbox.css({zIndex:selectzIndex});if(dropdown.is(":hidden")){$("div.jq-selectbox__dropdown:visible").hide();dropdown.show();selectbox.addClass("opened focused");opt.onSelectOpened.call(selectbox)}else{dropdown.hide();selectbox.removeClass("opened dropup dropdown");if($("div.jq-selectbox").filter(".opened").length){opt.onSelectClosed.call(selectbox)}}if(search.length){search.val("").keyup();notFound.hide();search.keyup(function(){var query=$(this).val();li.each(function(){if(!$(this).html().match(new RegExp(".*?"+query+".*?","i"))){$(this).hide()}else{$(this).show()}});if(option.first().text()===""&&el.data("placeholder")!==""){li.first().hide()}if(li.filter(":visible").length').attr({id:att.id,title:att.title}).addClass(att.classes).data(att.data);el.after(selectbox);makeList();selectbox.append("");var ul=$("ul",selectbox);var li=$("li",selectbox);var size=el.attr("size");var ulHeight=ul.outerHeight();var liHeight=li.outerHeight();if(size!==undefined&&size>0){ul.css({height:liHeight*size})}else{ul.css({height:liHeight*4})}if(ulHeight>selectbox.height()){ul.css("overflowY","scroll");preventScrolling(ul);if(li.filter(".selected").length){ul.scrollTop(ul.scrollTop()+li.filter(".selected").position().top)}}el.prependTo(selectbox);if(el.is(":disabled")){selectbox.addClass("disabled");option.each(function(){if($(this).is(":selected"))li.eq($(this).index()).addClass("selected")})}else{li.filter(":not(.disabled):not(.optgroup)").click(function(e){el.focus();var clkd=$(this);if(!e.ctrlKey&&!e.metaKey)clkd.addClass("selected");if(!e.shiftKey)clkd.addClass("first");if(!e.ctrlKey&&!e.metaKey&&!e.shiftKey)clkd.siblings().removeClass("selected first");if(e.ctrlKey||e.metaKey){if(clkd.is(".selected"))clkd.removeClass("selected first");else clkd.addClass("selected first");clkd.siblings().removeClass("first")}if(e.shiftKey){var prev=false,next=false;clkd.siblings().removeClass("selected").siblings(".first").addClass("selected");clkd.prevAll().each(function(){if($(this).is(".first"))prev=true});clkd.nextAll().each(function(){if($(this).is(".first"))next=true});if(prev){clkd.prevAll().each(function(){if($(this).is(".selected"))return false;else $(this).not(".disabled, .optgroup").addClass("selected")})}if(next){clkd.nextAll().each(function(){if($(this).is(".selected"))return false;else $(this).not(".disabled, .optgroup").addClass("selected")})}if(li.filter(".selected").length==1)clkd.addClass("first")}option.prop("selected",false);li.filter(".selected").each(function(){var t=$(this);var index=t.index();if(t.is(".option"))index-=t.prevAll(".optgroup").length;option.eq(index).prop("selected",true)});el.change()});option.each(function(i){$(this).data("optionIndex",i)});el.on("change.styler",function(){li.removeClass("selected");var arrIndexes=[];option.filter(":selected").each(function(){arrIndexes.push($(this).data("optionIndex"))});li.not(".optgroup").filter(function(i){return $.inArray(i,arrIndexes)>-1}).addClass("selected")}).on("focus.styler",function(){selectbox.addClass("focused")}).on("blur.styler",function(){selectbox.removeClass("focused")});if(ulHeight>selectbox.height()){el.on("keydown.styler",function(e){if(e.which==38||e.which==37||e.which==33){ul.scrollTop(ul.scrollTop()+li.filter(".selected").position().top-liHeight)}if(e.which==40||e.which==39||e.which==34){ul.scrollTop(ul.scrollTop()+li.filter(".selected:last").position().top-ul.innerHeight()+liHeight*2)}})}}}if(el.is("[multiple]")){if(Android||iOS)return;doMultipleSelect()}else{doSelect()}};selectboxOutput();el.on("refresh",function(){el.off(".styler").parent().before(el).remove();selectboxOutput()})}else if(el.is(":reset")){el.on("click",function(){setTimeout(function(){el.closest("form").find("input, select").trigger("refresh")},1)})}},destroy:function(){var el=$(this.element);if(el.is(":checkbox")||el.is(":radio")){el.removeData("_"+pluginName).off(".styler refresh").removeAttr("style").parent().before(el).remove();el.closest("label").add('label[for="'+el.attr("id")+'"]').off(".styler")}else if(el.is('input[type="number"]')){el.removeData("_"+pluginName).off(".styler refresh").closest(".jq-number").before(el).remove()}else if(el.is(":file")||el.is("select")){el.removeData("_"+pluginName).off(".styler refresh").removeAttr("style").parent().before(el).remove()}}};$.fn[pluginName]=function(options){var args=arguments;if(options===undefined||typeof options==="object"){this.each(function(){if(!$.data(this,"_"+pluginName)){$.data(this,"_"+pluginName,new Plugin(this,options))}}).promise().done(function(){var opt=$(this[0]).data("_"+pluginName);if(opt)opt.options.onFormStyled.call()});return this}else if(typeof options==="string"&&options[0]!=="_"&&options!=="init"){var returns;this.each(function(){var instance=$.data(this,"_"+pluginName);if(instance instanceof Plugin&&typeof instance[options]==="function"){returns=instance[options].apply(instance,Array.prototype.slice.call(args,1))}});return returns!==undefined?returns:this}};function onDocumentClick(e){if(!$(e.target).parents().hasClass("jq-selectbox")&&e.target.nodeName!="OPTION"){if($("div.jq-selectbox.opened").length){var selectbox=$("div.jq-selectbox.opened"),search=$("div.jq-selectbox__search input",selectbox),dropdown=$("div.jq-selectbox__dropdown",selectbox),opt=selectbox.find("select").data("_"+pluginName).options;opt.onSelectClosed.call(selectbox);if(search.length)search.val("").keyup();dropdown.hide().find("li.sel").addClass("selected");selectbox.removeClass("focused opened dropup dropdown")}}}onDocumentClick.registered=false});
    Котята Мейн-кун — купить в Санкт-Петербурге | Объявление №146884 | ZVERO Сиба — купить в Москве | Объявление №45855 | ZVERO Щенки вельш корги пемброк — купить в Москве | Объявление №94826 | ZVERO Различные окрасы — купить в Москве | Объявление №153835 | ZVERO Акелла в дар — купить в Москве | Объявление №23562 | ZVERO