View file wu-static/js2/wu_main.js

File size: 31.04Kb
//Уведомления
(function(e){var t=function(){return!1===e.support.boxModel&&e.support.objectAll&&e.support.leadingWhitespace}();e.jGrowl=function(t,i){0==e("#jGrowl").size()&&e('<div id="jGrowl"></div>').addClass(i&&i.position?i.position:e.jGrowl.defaults.position).appendTo("body"),e("#jGrowl").jGrowl(t,i)},e.fn.jGrowl=function(t,i){if(e.isFunction(this.each)){var o=arguments;return this.each(function(){void 0==e(this).data("jGrowl.instance")&&(e(this).data("jGrowl.instance",e.extend(new e.fn.jGrowl,{notifications:[],element:null,interval:null})),e(this).data("jGrowl.instance").startup(this)),e.isFunction(e(this).data("jGrowl.instance")[t])?e(this).data("jGrowl.instance")[t].apply(e(this).data("jGrowl.instance"),e.makeArray(o).slice(1)):e(this).data("jGrowl.instance").create(t,i)})}},e.extend(e.fn.jGrowl.prototype,{defaults:{pool:0,header:"",group:"",sticky:!1,position:"top-right",glue:"after",theme:"default",themeState:"highlight",corners:"10px",check:250,life:3e3,closeDuration:"normal",openDuration:"normal",easing:"swing",closer:!0,closeTemplate:"&times;",closerTemplate:"<div>close all</div>",log:function(){},beforeOpen:function(){},afterOpen:function(){},open:function(){},beforeClose:function(){},close:function(){},animateOpen:{opacity:"show"},animateClose:{opacity:"hide"}},notifications:[],element:null,interval:null,create:function(t,i){var i=e.extend({},this.defaults,i);i.speed!==void 0&&(i.openDuration=i.speed,i.closeDuration=i.speed),this.notifications.push({message:t,options:i}),i.log.apply(this.element,[this.element,t,i])},render:function(t){var i=this,o=t.message,n=t.options;n.themeState=""==n.themeState?"":"ui-state-"+n.themeState;var t=e("<div/>").addClass("jGrowl-notification "+n.themeState+" ui-corner-all"+(void 0!=n.group&&""!=n.group?" "+n.group:"")).append(e("<div/>").addClass("jGrowl-close").html(n.closeTemplate)).append(e("<div/>").addClass("jGrowl-header").html(n.header)).append(e("<div/>").addClass("jGrowl-message").html(o)).data("jGrowl",n).addClass(n.theme).children("div.jGrowl-close").bind("click.jGrowl",function(){e(this).parent().trigger("jGrowl.beforeClose")}).parent();e(t).bind("mouseover.jGrowl",function(){e("div.jGrowl-notification",i.element).data("jGrowl.pause",!0)}).bind("mouseout.jGrowl",function(){e("div.jGrowl-notification",i.element).data("jGrowl.pause",!1)}).bind("jGrowl.beforeOpen",function(){n.beforeOpen.apply(t,[t,o,n,i.element])!==!1&&e(this).trigger("jGrowl.open")}).bind("jGrowl.open",function(){n.open.apply(t,[t,o,n,i.element])!==!1&&("after"==n.glue?e("div.jGrowl-notification:last",i.element).after(t):e("div.jGrowl-notification:first",i.element).before(t),e(this).animate(n.animateOpen,n.openDuration,n.easing,function(){e.support.opacity===!1&&this.style.removeAttribute("filter"),null!==e(this).data("jGrowl")&&(e(this).data("jGrowl").created=new Date),e(this).trigger("jGrowl.afterOpen")}))}).bind("jGrowl.afterOpen",function(){n.afterOpen.apply(t,[t,o,n,i.element])}).bind("jGrowl.beforeClose",function(){n.beforeClose.apply(t,[t,o,n,i.element])!==!1&&e(this).trigger("jGrowl.close")}).bind("jGrowl.close",function(){e(this).data("jGrowl.pause",!0),e(this).animate(n.animateClose,n.closeDuration,n.easing,function(){e.isFunction(n.close)?n.close.apply(t,[t,o,n,i.element])!==!1&&e(this).remove():e(this).remove()})}).trigger("jGrowl.beforeOpen"),""!=n.corners&&void 0!=e.fn.corner&&e(t).corner(n.corners),e("div.jGrowl-notification:parent",i.element).size()>1&&0==e("div.jGrowl-closer",i.element).size()&&this.defaults.closer!==!1&&e(this.defaults.closerTemplate).addClass("jGrowl-closer "+this.defaults.themeState+" ui-corner-all").addClass(this.defaults.theme).appendTo(i.element).animate(this.defaults.animateOpen,this.defaults.speed,this.defaults.easing).bind("click.jGrowl",function(){e(this).siblings().trigger("jGrowl.beforeClose"),e.isFunction(i.defaults.closer)&&i.defaults.closer.apply(e(this).parent()[0],[e(this).parent()[0]])})},update:function(){e(this.element).find("div.jGrowl-notification:parent").each(function(){void 0!=e(this).data("jGrowl")&&void 0!==e(this).data("jGrowl").created&&e(this).data("jGrowl").created.getTime()+parseInt(e(this).data("jGrowl").life)<(new Date).getTime()&&e(this).data("jGrowl").sticky!==!0&&(void 0==e(this).data("jGrowl.pause")||e(this).data("jGrowl.pause")!==!0)&&e(this).trigger("jGrowl.beforeClose")}),this.notifications.length>0&&(0==this.defaults.pool||e(this.element).find("div.jGrowl-notification:parent").size()<this.defaults.pool)&&this.render(this.notifications.shift()),2>e(this.element).find("div.jGrowl-notification:parent").size()&&e(this.element).find("div.jGrowl-closer").animate(this.defaults.animateClose,this.defaults.speed,this.defaults.easing,function(){e(this).remove()})},startup:function(i){this.element=e(i).addClass("jGrowl").append('<div class="jGrowl-notification"></div>'),this.interval=setInterval(function(){e(i).data("jGrowl.instance").update()},parseInt(this.defaults.check)),t&&e(this.element).addClass("ie6")},shutdown:function(){e(this.element).removeClass("jGrowl").find("div.jGrowl-notification").trigger("jGrowl.close").parent().empty(),clearInterval(this.interval)},close:function(){e(this.element).find("div.jGrowl-notification").each(function(){e(this).trigger("jGrowl.beforeClose")})}}),e.jGrowl.defaults=e.fn.jGrowl.prototype.defaults})(jQuery);

function serr() { $.jGrowl('Ответ от сервера не получен', { theme: 'growl-error' }); }
function jerr() { $.jGrowl('Ошибка', { theme: 'growl-error' }); }

//Тэги
!function(t){var a=new Array,e=new Array;t.fn.doAutosize=function(a){var e=t(this).data("minwidth"),i=t(this).data("maxwidth"),n="",u=t(this),o=t("#"+t(this).data("tester_id"));if(n!==(n=u.val())){var d=n.replace(/&/g,"&amp;").replace(/\s/g," ").replace(/</g,"&lt;").replace(/>/g,"&gt;");o.html(d);var r=o.width(),s=r+a.comfortZone>=e?r+a.comfortZone:e,l=u.width(),p=l>s&&s>=e||s>e&&i>s;p&&u.width(s)}},t.fn.resetAutosize=function(a){var e=t(this).data("minwidth")||a.minInputWidth||t(this).width(),i=t(this).data("maxwidth")||a.maxInputWidth||t(this).closest(".tagsinput").width()-a.inputPadding,n=t(this),u=t("<tester/>").css({position:"absolute",top:-9999,left:-9999,width:"auto",fontSize:n.css("fontSize"),fontFamily:n.css("fontFamily"),fontWeight:n.css("fontWeight"),letterSpacing:n.css("letterSpacing"),whiteSpace:"nowrap"}),o=t(this).attr("id")+"_autosize_tester";!t("#"+o).length>0&&(u.attr("id",o),u.appendTo("body")),n.data("minwidth",e),n.data("maxwidth",i),n.data("tester_id",o),n.css("width",e)},t.fn.addTag=function(i,n){return n=jQuery.extend({focus:!1,callback:!0},n),this.each(function(){var u=t(this).attr("id"),o=t(this).val().split(a[u]);if(""==o[0]&&(o=new Array),i=jQuery.trim(i),n.unique){var d=t(this).tagExist(i);1==d&&t("#"+u+"_tag").addClass("not_valid")}else var d=!1;if(""!=i&&1!=d){if(t("<span>").addClass("tag").append(t("<span>").text(i).append(),t("<a>",{href:"#",title:"Removing tag",text:"x"}).click(function(){return t("#"+u).removeTag(escape(i))})).insertBefore("#"+u+"_addTag"),o.push(i),t("#"+u+"_tag").val(""),n.focus?t("#"+u+"_tag").focus():t("#"+u+"_tag").blur(),t.fn.tagsInput.updateTagsField(this,o),n.callback&&e[u]&&e[u].onAddTag){var r=e[u].onAddTag;r.call(this,i)}if(e[u]&&e[u].onChange){var s=o.length,r=e[u].onChange;r.call(this,t(this),o[s-1])}}}),!1},t.fn.removeTag=function(n){return n=unescape(n),this.each(function(){var u=t(this).attr("id"),o=t(this).val().split(a[u]);for(t("#"+u+"_tagsinput .tag").remove(),str="",i=0;i<o.length;i++)o[i]!=n&&(str=str+a[u]+o[i]);if(t.fn.tagsInput.importTags(this,str),e[u]&&e[u].onRemoveTag){var d=e[u].onRemoveTag;d.call(this,n)}}),!1},t.fn.tagExist=function(e){var i=t(this).attr("id"),n=t(this).val().split(a[i]);return jQuery.inArray(e,n)>=0},t.fn.importTags=function(a){id=t(this).attr("id"),t("#"+id+"_tagsinput .tag").remove(),t.fn.tagsInput.importTags(this,a)},t.fn.tagsInput=function(i){var n=jQuery.extend({interactive:!0,defaultText:"add a tag",minChars:0,width:"300px",height:"auto",autocomplete:{selectFirst:!1},hide:!0,delimiter:",",unique:!0,removeWithBackspace:!0,placeholderColor:"#666666",autosize:!0,comfortZone:20,inputPadding:12},i);return this.each(function(){n.hide&&t(this).hide();var i=t(this).attr("id");(!i||a[t(this).attr("id")])&&(i=t(this).attr("id","tags"+(new Date).getTime()).attr("id"));var u=jQuery.extend({pid:i,real_input:"#"+i,holder:"#"+i+"_tagsinput",input_wrapper:"#"+i+"_addTag",fake_input:"#"+i+"_tag"},n);a[i]=u.delimiter,(n.onAddTag||n.onRemoveTag||n.onChange)&&(e[i]=new Array,e[i].onAddTag=n.onAddTag,e[i].onRemoveTag=n.onRemoveTag,e[i].onChange=n.onChange);var o='<div id="'+i+'_tagsinput" class="tagsinput"><div id="'+i+'_addTag">';if(n.interactive&&(o=o+'<input id="'+i+'_tag" value="" data-default="'+n.defaultText+'" />'),o+='</div><div class="tags_clear"></div></div>',t(o).insertAfter(this),t(u.holder).css("width",n.width),t(u.holder).css("min-height",n.height),t(u.holder).css("height",n.height),""!=t(u.real_input).val()&&t.fn.tagsInput.importTags(t(u.real_input),t(u.real_input).val()),n.interactive){if(t(u.fake_input).val(t(u.fake_input).attr("data-default")),t(u.fake_input).css("color",n.placeholderColor),t(u.fake_input).resetAutosize(n),t(u.holder).bind("click",u,function(a){t(a.data.fake_input).focus()}),t(u.fake_input).bind("focus",u,function(a){t(a.data.fake_input).val()==t(a.data.fake_input).attr("data-default")&&t(a.data.fake_input).val(""),t(a.data.fake_input).css("color","#000000")}),void 0!=n.autocomplete_url){autocomplete_options={source:n.autocomplete_url};for(attrname in n.autocomplete)autocomplete_options[attrname]=n.autocomplete[attrname];void 0!==jQuery.Autocompleter?(t(u.fake_input).autocomplete(n.autocomplete_url,n.autocomplete),t(u.fake_input).bind("result",u,function(a,e,u){e&&t("#"+i).addTag(e[0]+"",{focus:!0,unique:n.unique})})):void 0!==jQuery.ui.autocomplete&&(t(u.fake_input).autocomplete(autocomplete_options),t(u.fake_input).bind("autocompleteselect",u,function(a,e){return t(a.data.real_input).addTag(e.item.value,{focus:!0,unique:n.unique}),!1}))}else t(u.fake_input).bind("blur",u,function(a){var e=t(this).attr("data-default");return""!=t(a.data.fake_input).val()&&t(a.data.fake_input).val()!=e?a.data.minChars<=t(a.data.fake_input).val().length&&(!a.data.maxChars||a.data.maxChars>=t(a.data.fake_input).val().length)&&t(a.data.real_input).addTag(t(a.data.fake_input).val(),{focus:!0,unique:n.unique}):(t(a.data.fake_input).val(t(a.data.fake_input).attr("data-default")),t(a.data.fake_input).css("color",n.placeholderColor)),!1});t(u.fake_input).bind("keypress",u,function(a){return a.which==a.data.delimiter.charCodeAt(0)||13==a.which?(a.preventDefault(),a.data.minChars<=t(a.data.fake_input).val().length&&(!a.data.maxChars||a.data.maxChars>=t(a.data.fake_input).val().length)&&t(a.data.real_input).addTag(t(a.data.fake_input).val(),{focus:!0,unique:n.unique}),t(a.data.fake_input).resetAutosize(n),!1):void(a.data.autosize&&t(a.data.fake_input).doAutosize(n))}),u.removeWithBackspace&&t(u.fake_input).bind("keydown",function(a){if(8==a.keyCode&&""==t(this).val()){a.preventDefault();var e=t(this).closest(".tagsinput").find(".tag:last").text(),i=t(this).attr("id").replace(/_tag$/,"");e=e.replace(/[\s]+x$/,""),t("#"+i).removeTag(escape(e)),t(this).trigger("focus")}}),t(u.fake_input).blur(),u.unique&&t(u.fake_input).keydown(function(a){(8==a.keyCode||String.fromCharCode(a.which).match(/\w+|[áéíóúÁÉÍÓÚñÑ,\/]+/))&&t(this).removeClass("not_valid")})}}),this},t.fn.tagsInput.updateTagsField=function(e,i){var n=t(e).attr("id");t(e).val(i.join(a[n]))},t.fn.tagsInput.importTags=function(n,u){t(n).val("");var o=t(n).attr("id"),d=u.split(a[o]);for(i=0;i<d.length;i++)t(n).addTag(d[i],{focus:!1,callback:!1});if(e[o]&&e[o].onChange){var r=e[o].onChange;r.call(n,n,d[i])}}}(jQuery);

//Автосайз
!function(a){var b,c={className:"autosizejs",append:"",callback:!1,resizeDelay:10,placeholder:!0},d='<textarea tabindex="-1" style="position:absolute; top:-999px; left:0; right:auto; bottom:auto; border:0; padding: 0; -moz-box-sizing:content-box; -webkit-box-sizing:content-box; box-sizing:content-box; word-wrap:break-word; height:0 !important; min-height:0 !important; overflow:hidden; transition:none; -webkit-transition:none; -moz-transition:none;"/>',e=["fontFamily","fontSize","fontWeight","fontStyle","letterSpacing","textTransform","wordSpacing","textIndent"],f=a(d).data("autosize",!0)[0];f.style.lineHeight="99px","99px"===a(f).css("lineHeight")&&e.push("lineHeight"),f.style.lineHeight="",a.fn.autosize=function(d){return this.length?(d=a.extend({},c,d||{}),f.parentNode!==document.body&&a(document.body).append(f),this.each(function(){function c(){var b,c=window.getComputedStyle?window.getComputedStyle(m,null):!1;c?(b=m.getBoundingClientRect().width,0===b&&(b=parseInt(c.width,10)),a.each(["paddingLeft","paddingRight","borderLeftWidth","borderRightWidth"],function(a,d){b-=parseInt(c[d],10)})):b=Math.max(n.width(),0),f.style.width=b+"px"}function g(){var g={};if(b=m,f.className=d.className,j=parseInt(n.css("maxHeight"),10),a.each(e,function(a,b){g[b]=n.css(b)}),a(f).css(g),c(),window.chrome){var h=m.style.width;m.style.width="0px";{m.offsetWidth}m.style.width=h}}function h(){var e,h;b!==m?g():c(),f.value=!m.value&&d.placeholder?(a(m).attr("placeholder")||"")+d.append:m.value+d.append,f.style.overflowY=m.style.overflowY,h=parseInt(m.style.height,10),f.scrollTop=0,f.scrollTop=9e4,e=f.scrollTop,j&&e>j?(m.style.overflowY="scroll",e=j):(m.style.overflowY="hidden",k>e&&(e=k)),e+=o,h!==e&&(m.style.height=e+"px",p&&d.callback.call(m,m))}function i(){clearTimeout(l),l=setTimeout(function(){var a=n.width();a!==r&&(r=a,h())},parseInt(d.resizeDelay,10))}var j,k,l,m=this,n=a(m),o=0,p=a.isFunction(d.callback),q={height:m.style.height,overflow:m.style.overflow,overflowY:m.style.overflowY,wordWrap:m.style.wordWrap,resize:m.style.resize},r=n.width();n.data("autosize")||(n.data("autosize",!0),("border-box"===n.css("box-sizing")||"border-box"===n.css("-moz-box-sizing")||"border-box"===n.css("-webkit-box-sizing"))&&(o=n.outerHeight()-n.height()),k=Math.max(parseInt(n.css("minHeight"),10)-o||0,n.height()),n.css({overflow:"hidden",overflowY:"hidden",wordWrap:"break-word",resize:"none"===n.css("resize")||"vertical"===n.css("resize")?"none":"horizontal"}),"onpropertychange"in m?"oninput"in m?n.on("input.autosize keyup.autosize",h):n.on("propertychange.autosize",function(){"value"===event.propertyName&&h()}):n.on("input.autosize",h),d.resizeDelay!==!1&&a(window).on("resize.autosize",i),n.on("autosize.resize",h),n.on("autosize.resizeIncludeStyle",function(){b=null,h()}),n.on("autosize.destroy",function(){b=null,clearTimeout(l),a(window).off("resize",i),n.off("autosize").off(".autosize").css(q).removeData("autosize")}),h())})):this}}(window.jQuery||window.$);

//UniForm
!function(e,t,n){"use strict";function s(e){var t=Array.prototype.slice.call(arguments,1);return e.prop?e.prop.apply(e,t):e.attr.apply(e,t)}function a(e,t,n){var s,a;for(s in n)n.hasOwnProperty(s)&&(a=s.replace(/ |$/g,t.eventNamespace),e.bind(a,n[s]))}function r(e,t,n){a(e,n,{focus:function(){t.addClass(n.focusClass)},blur:function(){t.removeClass(n.focusClass),t.removeClass(n.activeClass)},mouseenter:function(){t.addClass(n.hoverClass)},mouseleave:function(){t.removeClass(n.hoverClass),t.removeClass(n.activeClass)},"mousedown touchbegin":function(){e.is(":disabled")||t.addClass(n.activeClass)},"mouseup touchend":function(){t.removeClass(n.activeClass)}})}function i(e,t){e.removeClass(t.hoverClass+" "+t.focusClass+" "+t.activeClass)}function l(e,t,n){n?e.addClass(t):e.removeClass(t)}function u(e,t,n){var s="checked",a=t.is(":"+s);t.prop?t.prop(s,a):a?t.attr(s,s):t.removeAttr(s),l(e,n.checkedClass,a)}function o(e,t,n){l(e,n.disabledClass,t.is(":disabled"))}function c(e,t,n){switch(n){case"after":return e.after(t),e.next();case"before":return e.before(t),e.prev();case"wrap":return e.wrap(t),e.parent()}return null}function d(e,n,a){var r,i,l;return a||(a={}),a=t.extend({bind:{},divClass:null,divWrap:"wrap",spanClass:null,spanHtml:null,spanWrap:"wrap"},a),r=t("<div />"),i=t("<span />"),n.autoHide&&e.is(":hidden")&&"none"===e.css("display")&&r.hide(),a.divClass&&r.addClass(a.divClass),n.wrapperClass&&r.addClass(n.wrapperClass),a.spanClass&&i.addClass(a.spanClass),l=s(e,"id"),n.useID&&l&&s(r,"id",n.idPrefix+"-"+l),a.spanHtml&&i.html(a.spanHtml),r=c(e,r,a.divWrap),i=c(e,i,a.spanWrap),o(r,e,n),{div:r,span:i}}function f(e,n){var s;return n.wrapperClass?(s=t("<span />").addClass(n.wrapperClass),s=c(e,s,"wrap")):null}function p(){var n,s,a,r;return r="rgb(120,2,153)",s=t('<div style="width:0;height:0;color:'+r+'">'),t("body").append(s),a=s.get(0),n=e.getComputedStyle?e.getComputedStyle(a,"").color:(a.currentStyle||a.style||{}).color,s.remove(),n.replace(/ /g,"")!==r}function m(e){return e?t("<span />").text(e).html():""}function v(){return navigator.cpuClass&&!navigator.product}function h(){return void 0!==e.XMLHttpRequest?!0:!1}function C(e){var t;return e[0].multiple?!0:(t=s(e,"size"),!t||1>=t?!1:!0)}function b(){return!1}function y(e,t){var n="none";a(e,t,{"selectstart dragstart mousedown":b}),e.css({MozUserSelect:n,msUserSelect:n,webkitUserSelect:n,userSelect:n})}function w(e,t,n){var s=e.val();""===s?s=n.fileDefaultHtml:(s=s.split(/[\/\\]+/),s=s[s.length-1]),t.text(s)}function g(e,t,n){var s,a;for(s=[],e.each(function(){var e;for(e in t)Object.prototype.hasOwnProperty.call(t,e)&&(s.push({el:this,name:e,old:this.style[e]}),this.style[e]=t[e])}),n();s.length;)a=s.pop(),a.el.style[a.name]=a.old}function k(e,t){var n;n=e.parents(),n.push(e[0]),n=n.not(":visible"),g(n,{visibility:"hidden",display:"block",position:"absolute"},t)}function H(e,t){return function(){e.unwrap().unwrap().unbind(t.eventNamespace)}}var x=!0,A=!1,W=[{match:function(e){return e.is("a, button, :submit, :reset, input[type='button']")},apply:function(t,n){var l,u,c,f,p;return u=n.submitDefaultHtml,t.is(":reset")&&(u=n.resetDefaultHtml),f=t.is("a, button")?function(){return t.html()||u}:function(){return m(s(t,"value"))||u},c=d(t,n,{divClass:n.buttonClass,spanHtml:f()}),l=c.div,r(t,l,n),p=!1,a(l,n,{"click touchend":function(){var n,a,r,i;p||t.is(":disabled")||(p=!0,t[0].dispatchEvent?(n=document.createEvent("MouseEvents"),n.initEvent("click",!0,!0),a=t[0].dispatchEvent(n),t.is("a")&&a&&(r=s(t,"target"),i=s(t,"href"),r&&"_self"!==r?e.open(i,r):document.location.href=i)):t.click(),p=!1)}}),y(l,n),{remove:function(){return l.after(t),l.remove(),t.unbind(n.eventNamespace),t},update:function(){i(l,n),o(l,t,n),t.detach(),c.span.html(f()).append(t)}}}},{match:function(e){return e.is(":checkbox")},apply:function(e,t){var n,s,l;return n=d(e,t,{divClass:t.checkboxClass}),s=n.div,l=n.span,r(e,s,t),a(e,t,{"click touchend":function(){u(l,e,t)}}),u(l,e,t),{remove:H(e,t),update:function(){i(s,t),l.removeClass(t.checkedClass),u(l,e,t),o(s,e,t)}}}},{match:function(e){return e.is(":file")},apply:function(e,n){function l(){w(e,p,n)}var u,f,p,m;return u=d(e,n,{divClass:n.fileClass,spanClass:n.fileButtonClass,spanHtml:n.fileButtonHtml,spanWrap:"after"}),f=u.div,m=u.span,p=t("<span />").html(n.fileDefaultHtml),p.addClass(n.filenameClass),p=c(e,p,"after"),s(e,"size")||s(e,"size",f.width()/10),r(e,f,n),l(),v()?a(e,n,{click:function(){e.trigger("change"),setTimeout(l,0)}}):a(e,n,{change:l}),y(p,n),y(m,n),{remove:function(){return p.remove(),m.remove(),e.unwrap().unbind(n.eventNamespace)},update:function(){i(f,n),w(e,p,n),o(f,e,n)}}}},{match:function(e){if(e.is("input")){var t=(" "+s(e,"type")+" ").toLowerCase(),n=" color date datetime datetime-local email month number password search tel text time url week ";return n.indexOf(t)>=0}return!1},apply:function(e,t){var n,a;return n=s(e,"type"),e.addClass(t.inputClass),a=f(e,t),r(e,e,t),t.inputAddTypeAsClass&&e.addClass(n),{remove:function(){e.removeClass(t.inputClass),t.inputAddTypeAsClass&&e.removeClass(n),a&&e.unwrap()},update:b}}},{match:function(e){return e.is(":radio")},apply:function(e,n){var l,c,f;return l=d(e,n,{divClass:n.radioClass}),c=l.div,f=l.span,r(e,c,n),a(e,n,{"click touchend":function(){t.uniform.update(t(':radio[name="'+s(e,"name")+'"]'))}}),u(f,e,n),{remove:H(e,n),update:function(){i(c,n),u(f,e,n),o(c,e,n)}}}},{match:function(e){return e.is("select")&&!C(e)?!0:!1},apply:function(e,n){var s,l,u,c;return n.selectAutoWidth&&k(e,function(){c=e.width()}),s=d(e,n,{divClass:n.selectClass,spanHtml:(e.find(":selected:first")||e.find("option:first")).html(),spanWrap:"before"}),l=s.div,u=s.span,n.selectAutoWidth?k(e,function(){g(t([u[0],l[0]]),{display:"block"},function(){var e;e=u.outerWidth()-u.width(),l.width(c+e),u.width(c)})}):l.addClass("fixedWidth"),r(e,l,n),a(e,n,{change:function(){u.html(e.find(":selected").html()),l.removeClass(n.activeClass)},"click touchend":function(){var t=e.find(":selected").html();u.html()!==t&&e.trigger("change")},keyup:function(){u.html(e.find(":selected").html())}}),y(u,n),{remove:function(){return u.remove(),e.unwrap().unbind(n.eventNamespace),e},update:function(){n.selectAutoWidth?(t.uniform.restore(e),e.uniform(n)):(i(l,n),u.html(e.find(":selected").html()),o(l,e,n))}}}},{match:function(e){return e.is("select")&&C(e)?!0:!1},apply:function(e,t){var n;return e.addClass(t.selectMultiClass),n=f(e,t),r(e,e,t),{remove:function(){e.removeClass(t.selectMultiClass),n&&e.unwrap()},update:b}}},{match:function(e){return e.is("textarea")},apply:function(e,t){var n;return e.addClass(t.textareaClass),n=f(e,t),r(e,e,t),{remove:function(){e.removeClass(t.textareaClass),n&&e.unwrap()},update:b}}}];v()&&!h()&&(x=!1),t.uniform={defaults:{activeClass:"active",autoHide:!0,buttonClass:"button",checkboxClass:"checker",checkedClass:"checked",disabledClass:"disabled",eventNamespace:".uniform",fileButtonClass:"action",fileButtonHtml:"Choose File",fileClass:"uploader",fileDefaultHtml:"Файл не выбран",filenameClass:"filename",focusClass:"focus",hoverClass:"hover",idPrefix:"uniform",inputAddTypeAsClass:!0,inputClass:"uniform-input",radioClass:"radio",resetDefaultHtml:"Reset",resetSelector:!1,selectAutoWidth:!0,selectClass:"selector",selectMultiClass:"uniform-multiselect",submitDefaultHtml:"Submit",textareaClass:"uniform",useID:!0,wrapperClass:null},elements:[]},t.fn.uniform=function(n){var s=this;return n=t.extend({},t.uniform.defaults,n),A||(A=!0,p()&&(x=!1)),x?(n.resetSelector&&t(n.resetSelector).mouseup(function(){e.setTimeout(function(){t.uniform.update(s)},10)}),this.each(function(){var e,s,a,r=t(this);if(r.data("uniformed"))return t.uniform.update(r),void 0;for(e=0;e<W.length;e+=1)if(s=W[e],s.match(r,n))return a=s.apply(r,n),r.data("uniformed",a),t.uniform.elements.push(r.get(0)),void 0})):this},t.uniform.restore=t.fn.uniform.restore=function(e){e===n&&(e=t.uniform.elements),t(e).each(function(){var e,n,s=t(this);n=s.data("uniformed"),n&&(n.remove(),e=t.inArray(this,t.uniform.elements),e>=0&&t.uniform.elements.splice(e,1),s.removeData("uniformed"))})},t.uniform.update=t.fn.uniform.update=function(e){e===n&&(e=t.uniform.elements),t(e).each(function(){var e,n=t(this);e=n.data("uniformed"),e&&e.update(n,e.options)})}}(this,jQuery);

$(function() {
//Активация подсказок
$('.tip').tooltip();

//Активация dropdown
$('.dropdown, .btn-group').on('show.bs.dropdown', function(e){
$(this).find('.dropdown-menu').first().stop(true, true).fadeIn(100);
});
$('.dropdown, .btn-group').on('hide.bs.dropdown', function(e){
$(this).find('.dropdown-menu').first().stop(true, true).fadeOut(100);
});
$('.popup').click(function (e) {
e.stopPropagation();
});

// Навигация
$('.page-content').wrapInner('<div class="page-content-inner"></div>');
$(document).on('click', '.offcanvas', function () {
$('body').toggleClass('offcanvas-active');
});
$('.navigation').find('li.active').parents('li').addClass('active');
$('.navigation').find('li').not('.active').has('ul').children('ul').addClass('hidden-ul');
$('.navigation').find('li').has('ul').children('a').parent('li').addClass('has-ul');
$(document).on('click', '.sidebar-toggle', function (e) {
e.preventDefault();
$('body').toggleClass('sidebar-narrow');
if ($('body').hasClass('sidebar-narrow')) {
var ws = new Date();
ws.setDate(30 + ws.getDate());
document.cookie = "sidebar=0; path=/; domain=." + document.domain + "; expires=" + ws.toGMTString();
$('.navigation').children('li').children('ul').css('display', '');
$('.sidebar-content').hide().delay().queue(function(){
$(this).show().addClass('animated fadeIn').clearQueue();
});
} else {
var ws = new Date();
ws.setDate(30 + ws.getDate());
document.cookie = "sidebar=1; path=/; domain=." + document.domain + "; expires=" + ws.toGMTString();
$('.navigation').children('li').children('ul').css('display', 'none');
$('.navigation').children('li.active').children('ul').css('display', 'block');
$('.sidebar-content').hide().delay().queue(function(){
$(this).show().addClass('animated fadeIn').clearQueue();
});
}
if ($('body').hasClass('sidebar-narrow')) {
$('.navigation').children('li').children('ul').css('display', '');
$('.sidebar-content').hide().delay().queue(function(){
$(this).show().addClass('animated fadeIn').clearQueue();
});
} else {
$('.navigation').children('li').children('ul').css('display', 'none');
$('.navigation').children('li.active').children('ul').css('display', 'block');
$('.sidebar-content').hide().delay().queue(function(){
$(this).show().addClass('animated fadeIn').clearQueue();
});
}
});
$('.navigation').find('li').has('ul').children('a').on('click', function (e) {
e.preventDefault();
if ($('body').hasClass('sidebar-narrow')) {
$(this).parent('li > ul li').not('.disabled').toggleClass('active').children('ul').slideToggle(250);
$(this).parent('li > ul li').not('.disabled').siblings().removeClass('active').children('ul').slideUp(250);
}
else {
$(this).parent('li').not('.disabled').toggleClass('active').children('ul').slideToggle(250);
$(this).parent('li').not('.disabled').siblings().removeClass('active').children('ul').slideUp(250);
}
});
$('.navigation .disabled a, .navbar-nav > .disabled > a').click(function (e){
e.preventDefault();
});

// Автосайз
$('.elastic').autosize();

//Применение стилей
$(".styled, .multiselect-container input").uniform({ radioClass: 'choice', selectAutoWidth: false });

//Проверка вводимых символов
$('.func-verify').bind("change keyup paste input", function() {
var value = $(this).val();
var re = /[^-a-zA-Z0-9_\.]/g;
if (re.test(value)) {
value = value.replace(re, '');
$(this).val(value);
}
});

//Спойлер
$('[data-panel=collapse]').click(function(e){
e.preventDefault();
var $target = $(this).parent().parent().next('div');
if($target.is(':visible'))
{
$(this).children('i').removeClass('icon-arrow-up9');
$(this).children('i').addClass('icon-arrow-down9');
}
else
{
$(this).children('i').removeClass('icon-arrow-down9');
$(this).children('i').addClass('icon-arrow-up9');
}
$target.slideToggle(200);
});
$('[data-panel=close]').click(function(e){
e.preventDefault();
var $panelContent = $(this).parent().parent().parent();
$panelContent.slideUp(200).remove(200);
});

//Уведомления
$.jGrowl.defaults.closer = false;
$.jGrowl.defaults.easing = 'easeInOutCirc';

//Вход
$('#btnlogin').click(function(){
var login = $('#log_login').val();
var pass = $('#log_pass').val();
var data = {'login': login, 'pass': pass};
wu_response('/wu-engine/wu-actions/login.php', data, 'btnlogin', '1', function(wu_result) {
if(wu_result == 0){ notif_e('Неверный логин или пароль'); }
if(wu_result == 1){ location.reload(); }
if(wu_result == 2){ notif_e('Попробуйте войти позднее'); }
if(wu_result == 'wu-error'){ wu_err(); }
if(wu_result == 4){ notif_e('Не введён логин или пароль'); }
});
});

//Вверх
if($("#toTop").length > 0) {
$(window).scroll(function() {
});
$('.btnup').click(function() {
$('body,html').animate({scrollTop:0},500);
});
$(window).scroll(function() {
var top = $(document).scrollTop(),
pretop = $('#pretop').offset().top;
if (top >= pretop) { $('#toTop').addClass('fixedm'); $('#toTop').fadeIn(); } else { $('#toTop').removeClass('fixedm'); $('#toTop').fadeOut(); }
});
}

//Отмена перехода по ссылке
$(".nolink").on('click', function() {
return false;
});

//Закрытие модального окна
$(".modals_cl").on('click', function() {
var a_href = $(this).attr('href');
window.open(a_href, '_blank');
return false;
});

});

//Спойлер
$(document).on('click', '.spoiler-btn', function (e) {
e.preventDefault()
$(this).parent().children('.spoiler-body').toggle();
});

//Замена символов
function htmlspecialchars(text) {
var map = {
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#039;'
};
return text.replace(/[&<>"']/g, function(m) { return map[m]; });
}

//Системные уведомления
function notif_e(msg) { $.jGrowl(msg, { theme: 'growl-error' }); }
function notif_s(msg) { $.jGrowl(msg, { theme: 'growl-success' }); }
function wu_err() { $.jGrowl('Ошибка', { theme: 'growl-error' }); }

//Ajax запрос
function wu_response(wu_action, wu_data, wu_button, wu_type, cb){
if (!wu_action) { notif_e('Не задан action'); return false; }
if (!wu_data) { notif_e('Не переданы дата данные'); return false; }
if (cb && typeof(cb) === "function") {
if (wu_button.length > 0) { $('#'+wu_button).button('loading'); }
wu_data.token = token;
if (wu_type == 1) { wu_processData = true; wu_contentType = 'application/x-www-form-urlencoded; charset=UTF-8'; }
if (wu_type == 2) { wu_processData = false; wu_contentType = false; }
$.ajax({
type: 'POST',
url: wu_action,
data: wu_data,
cache: false,
processData: wu_processData,
contentType: wu_contentType,
success: function(wu_res){
if (wu_button.length > 0) { $('#'+wu_button).button('reset'); }
return cb(wu_res);
},
error: function(){
if (wu_button.length > 0) { $('#'+wu_button).button('reset'); }
notif_e('Ответ от сервера не получен');
return false;
}
});
} else { notif_e('Неверное использование функции'); return false; }
};

//Пользователи онлайн
$('#onlines').click(function(){
if ($("#onlinev").text().length == 0) { $("#onlinev").html('<li><center><i class="icon-spinner7 margloadt spin"></i></center></li>'); }
var data = {'wu': 'ok'};
wu_response('/wu-engine/wu-actions/load_online.php', data, '', '1', function(wu_result) {
$("#onlinev").text('');
$('#onlinev').show();
$('#onlinev').html(wu_result);
});
});

//Уведомления
$('#notifs').click(function(){
if ($("#notifv").text().length == 0) { $("#notifv").html('<li><center><i class="icon-spinner7 spin"></i></center></li>'); }
var data = {'wu': 'ok'};
wu_response('/wu-engine/wu-actions/load_notif.php', data, '', '1', function(wu_result) {
$("#notifc").hide();
$("#notifv").text('');
$('#notifv').show();
$('#notifv').html(wu_result);
});
});

//Очистка уведомлений
$('#notifd').click(function(){
var data = {'с': 'с'};
wu_response('/wu-engine/wu-actions/acc_notif_clear.php', data, 'notifd', '1', function(wu_result) {
if (wu_result == '1') {
$("#notifv").html('<li><center>Уведомлений нет</center></li>');
}
if (wu_result == 'wu-error') {
wu_err();
}
});
});

//Проверка суммы
function wu_sum_validate(element, decimals)
{
$(element).keypress(function(event)
{
num = $(this).val() ;
num = isNaN(num) || num === '' || num === null ? 0.00 : num ;
if ((event.which != 46 || $(this).val().indexOf('.') != -1) && (event.which < 48 || event.which > 57))
{
event.preventDefault();
}
if($(this).val() == parseFloat(num).toFixed(decimals))
{
event.preventDefault();
}
});
}