$(document).ready(function() { $('form').click(function() { if ($('.js-error').is(':visible')) { hideError(); } }); }); function numFormat(num) { return (num * 1).toLocaleString('ru-RU'); } function declOfNum(n, titles) { return titles[(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)]; } function loading(container, ostatus) { $(container).addClass('loading'); if (ostatus) { if (!$(ostatus).val()) var t = 'html'; else var t = 'val'; if (!$(ostatus).data('default-label')) $(ostatus).data('default-label', t == 'html' ? $(ostatus).html() : $(ostatus).val()); if (t == 'html') { $(ostatus).html('Секунду...'); } else { $(ostatus).val('Секунду...'); } } } function loaded(container, ostatus) { $(container).removeClass('loading'); if (ostatus && $(ostatus).data('default-label')) { if (!$(ostatus).val()) var t = 'html'; else var t = 'val'; if (t == 'html') { $(ostatus).html($(ostatus).data('default-label')); } else { $(ostatus).val($(ostatus).data('default-label')); } } } function showError(obj, error_text, no_scroll) { var error = $('.js-error'); error.html(error_text); error.css({ 'top': obj.offset().top - error.height() - 13, 'left': obj.offset().left }).show(); if (!no_scroll) { $('html, body').stop().animate({ scrollTop: obj.offset().top - error.height() - 20 }, 300); } } function hideError() { $('.js-error').hide(); } function formControl(form) { var error = false; hideError(); form.find('[data-control], [data-needed]').each(function() { var input = $(this); var val = input.val(); var error_text = ''; if (input.data('control') == 'email') { if (val && !(/^[a-zA-Z0-9\.\-\_]+@[a-zA-Z0-9\.\-\_]+\.[a-zA-Z0-9\.\-\_]+$/i).test(val)) { error = true; error_text = 'Пожалуйста, проверьте корректность e-mail'; } } if (input.data('control') == 'phone') { if (val && val.replace(/[^0-9]/g, '').length != 11) { error = true; error_text = 'Пожалуйста, проверьте корректность телефона'; } } if (input.data('control') == 'name') { if (val && val.length < 2) { error = true; error_text = 'Пожалуйста, введите ваши реальные данные'; } } if (input.data('control') == 'password') { if (val && val.length < 6) { error = true; error_text = 'Пароль должен содержать не менее 6 символов'; } } if (input.data('control') == 'url') { var url_pattern = new RegExp('^(https?:\\/\\/)?' + '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' + '((\\d{1,3}\\.){3}\\d{1,3}))' + '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' + '(\\?[;&a-z\\d%_.~+=-]*)?' + '(\\#[-a-z\\d_]*)?$', 'i'); if (val && !url_pattern.test(val)) { error = true; error_text = 'Пожалуйста, введите корректную ссылку'; } } if (!error && input.data('needed')) { if (input.prop('type') == 'checkbox') { if (!input.is(':checked')) error = true; } else if (input.prop('type') == 'radio') { var form = input.parents('form'); if (!form.find('input[name=' + input.attr('name') + ']:checked').length) error = true; } else { if (!val || !val.length) { error = true; } } if (error) { if (input.data('error')) error_text = input.data('error'); else error_text = 'Пожалуйста, заполните это поле'; } } if (error) { showError(input, error_text); return false; } }); if (error) return false; else return true; } !function(n){"function"==typeof define&&define.amd?define(["jquery"],n):"object"==typeof module&&module.exports?module.exports=function(e,t){return void 0===t&&(t="undefined"!=typeof window?require("jquery"):require("jquery")(e)),n(t),t}:n(jQuery)}(function(u){var e=function(){if(u&&u.fn&&u.fn.select2&&u.fn.select2.amd)var e=u.fn.select2.amd;var t,n,i,h,s,o,f,g,m,v,y,_,r,a,b;function w(e,t){return r.call(e,t)}function l(e,t){var n,i,r,s,o,a,l,c,u,d,p,h=t&&t.split("/"),f=y.map,g=f&&f["*"]||{};if(e){for(o=(e=e.split("/")).length-1,y.nodeIdCompat&&b.test(e[o])&&(e[o]=e[o].replace(b,"")),"."===e[0].charAt(0)&&h&&(e=h.slice(0,h.length-1).concat(e)),u=0;u":">",'"':""","'":"'","/":"/"};return"string"!=typeof e?e:String(e).replace(/[&<>"'\/\\]/g,function(e){return t[e]})},r.__cache={};var n=0;return r.GetUniqueElementId=function(e){var t=e.getAttribute("data-select2-id");return null!=t||(t=e.id?"select2-data-"+e.id:"select2-data-"+(++n).toString()+"-"+r.generateChars(4),e.setAttribute("data-select2-id",t)),t},r.StoreData=function(e,t,n){var i=r.GetUniqueElementId(e);r.__cache[i]||(r.__cache[i]={}),r.__cache[i][t]=n},r.GetData=function(e,t){var n=r.GetUniqueElementId(e);return t?r.__cache[n]&&null!=r.__cache[n][t]?r.__cache[n][t]:s(e).data(t):r.__cache[n]},r.RemoveData=function(e){var t=r.GetUniqueElementId(e);null!=r.__cache[t]&&delete r.__cache[t],e.removeAttribute("data-select2-id")},r.copyNonInternalCssClasses=function(e,t){var n=e.getAttribute("class").trim().split(/\s+/);n=n.filter(function(e){return 0===e.indexOf("select2-")});var i=t.getAttribute("class").trim().split(/\s+/);i=i.filter(function(e){return 0!==e.indexOf("select2-")});var r=n.concat(i);e.setAttribute("class",r.join(" "))},r}),e.define("select2/results",["jquery","./utils"],function(h,f){function i(e,t,n){this.$element=e,this.data=n,this.options=t,i.__super__.constructor.call(this)}return f.Extend(i,f.Observable),i.prototype.render=function(){var e=h('');return this.options.get("multiple")&&e.attr("aria-multiselectable","true"),this.$results=e},i.prototype.clear=function(){this.$results.empty()},i.prototype.displayMessage=function(e){var t=this.options.get("escapeMarkup");this.clear(),this.hideLoading();var n=h(''),i=this.options.get("translations").get(e.message);n.append(t(i(e.args))),n[0].className+=" select2-results__message",this.$results.append(n)},i.prototype.hideMessages=function(){this.$results.find(".select2-results__message").remove()},i.prototype.append=function(e){this.hideLoading();var t=[];if(null!=e.results&&0!==e.results.length){e.results=this.sort(e.results);for(var n=0;n",{class:"select2-results__options select2-results__options--nested"});p.append(l),o.append(a),o.append(p)}else this.template(e,t);return f.StoreData(t,"data",e),t},i.prototype.bind=function(t,e){var l=this,n=t.id+"-results";this.$results.attr("id",n),t.on("results:all",function(e){l.clear(),l.append(e.data),t.isOpen()&&(l.setClasses(),l.highlightFirstItem())}),t.on("results:append",function(e){l.append(e.data),t.isOpen()&&l.setClasses()}),t.on("query",function(e){l.hideMessages(),l.showLoading(e)}),t.on("select",function(){t.isOpen()&&(l.setClasses(),l.options.get("scrollAfterSelect")&&l.highlightFirstItem())}),t.on("unselect",function(){t.isOpen()&&(l.setClasses(),l.options.get("scrollAfterSelect")&&l.highlightFirstItem())}),t.on("open",function(){l.$results.attr("aria-expanded","true"),l.$results.attr("aria-hidden","false"),l.setClasses(),l.ensureHighlightVisible()}),t.on("close",function(){l.$results.attr("aria-expanded","false"),l.$results.attr("aria-hidden","true"),l.$results.removeAttr("aria-activedescendant")}),t.on("results:toggle",function(){var e=l.getHighlightedResults();0!==e.length&&e.trigger("mouseup")}),t.on("results:select",function(){var e=l.getHighlightedResults();if(0!==e.length){var t=f.GetData(e[0],"data");e.hasClass("select2-results__option--selected")?l.trigger("close",{}):l.trigger("select",{data:t})}}),t.on("results:previous",function(){var e=l.getHighlightedResults(),t=l.$results.find(".select2-results__option--selectable"),n=t.index(e);if(!(n<=0)){var i=n-1;0===e.length&&(i=0);var r=t.eq(i);r.trigger("mouseenter");var s=l.$results.offset().top,o=r.offset().top,a=l.$results.scrollTop()+(o-s);0===i?l.$results.scrollTop(0):o-s<0&&l.$results.scrollTop(a)}}),t.on("results:next",function(){var e=l.getHighlightedResults(),t=l.$results.find(".select2-results__option--selectable"),n=t.index(e)+1;if(!(n>=t.length)){var i=t.eq(n);i.trigger("mouseenter");var r=l.$results.offset().top+l.$results.outerHeight(!1),s=i.offset().top+i.outerHeight(!1),o=l.$results.scrollTop()+s-r;0===n?l.$results.scrollTop(0):rthis.$results.outerHeight()||s<0)&&this.$results.scrollTop(r)}},i.prototype.template=function(e,t){var n=this.options.get("templateResult"),i=this.options.get("escapeMarkup"),r=n(e,t);null==r?t.style.display="none":"string"==typeof r?t.innerHTML=i(r):h(t).append(r)},i}),e.define("select2/keys",[],function(){return{BACKSPACE:8,TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,ESC:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,DELETE:46}}),e.define("select2/selection/base",["jquery","../utils","../keys"],function(n,i,r){function s(e,t){this.$element=e,this.options=t,s.__super__.constructor.call(this)}return i.Extend(s,i.Observable),s.prototype.render=function(){var e=n('');return this._tabindex=0,null!=i.GetData(this.$element[0],"old-tabindex")?this._tabindex=i.GetData(this.$element[0],"old-tabindex"):null!=this.$element.attr("tabindex")&&(this._tabindex=this.$element.attr("tabindex")),e.attr("title",this.$element.attr("title")),e.attr("tabindex",this._tabindex),e.attr("aria-disabled","false"),this.$selection=e},s.prototype.bind=function(e,t){var n=this,i=e.id+"-results";this.container=e,this.$selection.on("focus",function(e){n.trigger("focus",e)}),this.$selection.on("blur",function(e){n._handleBlur(e)}),this.$selection.on("keydown",function(e){n.trigger("keypress",e),e.which===r.SPACE&&e.preventDefault()}),e.on("results:focus",function(e){n.$selection.attr("aria-activedescendant",e.data._resultId)}),e.on("selection:update",function(e){n.update(e.data)}),e.on("open",function(){n.$selection.attr("aria-expanded","true"),n.$selection.attr("aria-owns",i),n._attachCloseHandler(e)}),e.on("close",function(){n.$selection.attr("aria-expanded","false"),n.$selection.removeAttr("aria-activedescendant"),n.$selection.removeAttr("aria-owns"),n.$selection.trigger("focus"),n._detachCloseHandler(e)}),e.on("enable",function(){n.$selection.attr("tabindex",n._tabindex),n.$selection.attr("aria-disabled","false")}),e.on("disable",function(){n.$selection.attr("tabindex","-1"),n.$selection.attr("aria-disabled","true")})},s.prototype._handleBlur=function(e){var t=this;window.setTimeout(function(){document.activeElement==t.$selection[0]||n.contains(t.$selection[0],document.activeElement)||t.trigger("blur",e)},1)},s.prototype._attachCloseHandler=function(e){n(document.body).on("mousedown.select2."+e.id,function(e){var t=n(e.target).closest(".select2");n(".select2.select2-container--open").each(function(){this!=t[0]&&i.GetData(this,"element").select2("close")})})},s.prototype._detachCloseHandler=function(e){n(document.body).off("mousedown.select2."+e.id)},s.prototype.position=function(e,t){t.find(".selection").append(e)},s.prototype.destroy=function(){this._detachCloseHandler(this.container)},s.prototype.update=function(e){throw new Error("The `update` method must be defined in child classes.")},s.prototype.isEnabled=function(){return!this.isDisabled()},s.prototype.isDisabled=function(){return this.options.get("disabled")},s}),e.define("select2/selection/single",["jquery","./base","../utils","../keys"],function(e,t,n,i){function r(){r.__super__.constructor.apply(this,arguments)}return n.Extend(r,t),r.prototype.render=function(){var e=r.__super__.render.call(this);return e[0].classList.add("select2-selection--single"),e.html(''),e},r.prototype.bind=function(t,e){var n=this;r.__super__.bind.apply(this,arguments);var i=t.id+"-container";this.$selection.find(".select2-selection__rendered").attr("id",i).attr("role","textbox").attr("aria-readonly","true"),this.$selection.attr("aria-labelledby",i),this.$selection.on("mousedown",function(e){1===e.which&&n.trigger("toggle",{originalEvent:e})}),this.$selection.on("focus",function(e){}),this.$selection.on("blur",function(e){}),t.on("focus",function(e){t.isOpen()||n.$selection.trigger("focus")})},r.prototype.clear=function(){var e=this.$selection.find(".select2-selection__rendered");e.empty(),e.removeAttr("title")},r.prototype.display=function(e,t){var n=this.options.get("templateSelection");return this.options.get("escapeMarkup")(n(e,t))},r.prototype.selectionContainer=function(){return e("")},r.prototype.update=function(e){if(0!==e.length){var t=e[0],n=this.$selection.find(".select2-selection__rendered"),i=this.display(t,n);n.empty().append(i);var r=t.title||t.text;r?n.attr("title",r):n.removeAttr("title")}else this.clear()},r}),e.define("select2/selection/multiple",["jquery","./base","../utils"],function(r,e,d){function s(e,t){s.__super__.constructor.apply(this,arguments)}return d.Extend(s,e),s.prototype.render=function(){var e=s.__super__.render.call(this);return e[0].classList.add("select2-selection--multiple"),e.html('
    '),e},s.prototype.bind=function(e,t){var i=this;s.__super__.bind.apply(this,arguments);var n=e.id+"-container";this.$selection.find(".select2-selection__rendered").attr("id",n),this.$selection.on("click",function(e){i.trigger("toggle",{originalEvent:e})}),this.$selection.on("click",".select2-selection__choice__remove",function(e){if(!i.isDisabled()){var t=r(this).parent(),n=d.GetData(t[0],"data");i.trigger("unselect",{originalEvent:e,data:n})}}),this.$selection.on("keydown",".select2-selection__choice__remove",function(e){i.isDisabled()||e.stopPropagation()})},s.prototype.clear=function(){var e=this.$selection.find(".select2-selection__rendered");e.empty(),e.removeAttr("title")},s.prototype.display=function(e,t){var n=this.options.get("templateSelection");return this.options.get("escapeMarkup")(n(e,t))},s.prototype.selectionContainer=function(){return r('
  • ')},s.prototype.update=function(e){if(this.clear(),0!==e.length){for(var t=[],n=this.$selection.find(".select2-selection__rendered").attr("id")+"-choice-",i=0;i');r.attr("title",i()),r.attr("aria-label",i()),r.attr("aria-describedby",n),a.StoreData(r[0],"data",t),this.$selection.prepend(r)}},e}),e.define("select2/selection/search",["jquery","../utils","../keys"],function(i,l,c){function e(e,t,n){e.call(this,t,n)}return e.prototype.render=function(e){var t=i('');this.$searchContainer=t,this.$search=t.find("input"),this.$search.prop("autocomplete",this.options.get("autocomplete"));var n=e.call(this);return this._transferTabIndex(),n.append(this.$searchContainer),n},e.prototype.bind=function(e,t,n){var i=this,r=t.id+"-results",s=t.id+"-container";e.call(this,t,n),i.$search.attr("aria-describedby",s),t.on("open",function(){i.$search.attr("aria-controls",r),i.$search.trigger("focus")}),t.on("close",function(){i.$search.val(""),i.resizeSearch(),i.$search.removeAttr("aria-controls"),i.$search.removeAttr("aria-activedescendant"),i.$search.trigger("focus")}),t.on("enable",function(){i.$search.prop("disabled",!1),i._transferTabIndex()}),t.on("disable",function(){i.$search.prop("disabled",!0)}),t.on("focus",function(e){i.$search.trigger("focus")}),t.on("results:focus",function(e){e.data._resultId?i.$search.attr("aria-activedescendant",e.data._resultId):i.$search.removeAttr("aria-activedescendant")}),this.$selection.on("focusin",".select2-search--inline",function(e){i.trigger("focus",e)}),this.$selection.on("focusout",".select2-search--inline",function(e){i._handleBlur(e)}),this.$selection.on("keydown",".select2-search--inline",function(e){if(e.stopPropagation(),i.trigger("keypress",e),i._keyUpPrevented=e.isDefaultPrevented(),e.which===c.BACKSPACE&&""===i.$search.val()){var t=i.$selection.find(".select2-selection__choice").last();if(0this.maximumInputLength?this.trigger("results:message",{message:"inputTooLong",args:{maximum:this.maximumInputLength,input:t.term,params:t}}):e.call(this,t,n)},e}),e.define("select2/data/maximumSelectionLength",[],function(){function e(e,t,n){this.maximumSelectionLength=n.get("maximumSelectionLength"),e.call(this,t,n)}return e.prototype.bind=function(e,t,n){var i=this;e.call(this,t,n),t.on("select",function(){i._checkIfMaximumSelected()})},e.prototype.query=function(e,t,n){var i=this;this._checkIfMaximumSelected(function(){e.call(i,t,n)})},e.prototype._checkIfMaximumSelected=function(e,n){var i=this;this.current(function(e){var t=null!=e?e.length:0;0=i.maximumSelectionLength?i.trigger("results:message",{message:"maximumSelected",args:{maximum:i.maximumSelectionLength}}):n&&n()})},e}),e.define("select2/dropdown",["jquery","./utils"],function(t,e){function n(e,t){this.$element=e,this.options=t,n.__super__.constructor.call(this)}return e.Extend(n,e.Observable),n.prototype.render=function(){var e=t('');return e.attr("dir",this.options.get("dir")),this.$dropdown=e},n.prototype.bind=function(){},n.prototype.position=function(e,t){},n.prototype.destroy=function(){this.$dropdown.remove()},n}),e.define("select2/dropdown/search",["jquery"],function(s){function e(){}return e.prototype.render=function(e){var t=e.call(this),n=s('');return this.$searchContainer=n,this.$search=n.find("input"),this.$search.prop("autocomplete",this.options.get("autocomplete")),t.prepend(n),t},e.prototype.bind=function(e,t,n){var i=this,r=t.id+"-results";e.call(this,t,n),this.$search.on("keydown",function(e){i.trigger("keypress",e),i._keyUpPrevented=e.isDefaultPrevented()}),this.$search.on("input",function(e){s(this).off("keyup")}),this.$search.on("keyup input",function(e){i.handleSearch(e)}),t.on("open",function(){i.$search.attr("tabindex",0),i.$search.attr("aria-controls",r),i.$search.trigger("focus"),window.setTimeout(function(){i.$search.trigger("focus")},0)}),t.on("close",function(){i.$search.attr("tabindex",-1),i.$search.removeAttr("aria-controls"),i.$search.removeAttr("aria-activedescendant"),i.$search.val(""),i.$search.trigger("blur")}),t.on("focus",function(){t.isOpen()||i.$search.trigger("focus")}),t.on("results:all",function(e){null!=e.query.term&&""!==e.query.term||(i.showSearch(e)?i.$searchContainer[0].classList.remove("select2-search--hide"):i.$searchContainer[0].classList.add("select2-search--hide"))}),t.on("results:focus",function(e){e.data._resultId?i.$search.attr("aria-activedescendant",e.data._resultId):i.$search.removeAttr("aria-activedescendant")})},e.prototype.handleSearch=function(e){if(!this._keyUpPrevented){var t=this.$search.val();this.trigger("query",{term:t})}this._keyUpPrevented=!1},e.prototype.showSearch=function(e,t){return!0},e}),e.define("select2/dropdown/hidePlaceholder",[],function(){function e(e,t,n,i){this.placeholder=this.normalizePlaceholder(n.get("placeholder")),e.call(this,t,n,i)}return e.prototype.append=function(e,t){t.results=this.removePlaceholder(t.results),e.call(this,t)},e.prototype.normalizePlaceholder=function(e,t){return"string"==typeof t&&(t={id:"",text:t}),t},e.prototype.removePlaceholder=function(e,t){for(var n=t.slice(0),i=t.length-1;0<=i;i--){var r=t[i];this.placeholder.id===r.id&&n.splice(i,1)}return n},e}),e.define("select2/dropdown/infiniteScroll",["jquery"],function(n){function e(e,t,n,i){this.lastParams={},e.call(this,t,n,i),this.$loadingMore=this.createLoadingMore(),this.loading=!1}return e.prototype.append=function(e,t){this.$loadingMore.remove(),this.loading=!1,e.call(this,t),this.showLoadingMore(t)&&(this.$results.append(this.$loadingMore),this.loadMoreIfNeeded())},e.prototype.bind=function(e,t,n){var i=this;e.call(this,t,n),t.on("query",function(e){i.lastParams=e,i.loading=!0}),t.on("query:append",function(e){i.lastParams=e,i.loading=!0}),this.$results.on("scroll",this.loadMoreIfNeeded.bind(this))},e.prototype.loadMoreIfNeeded=function(){var e=n.contains(document.documentElement,this.$loadingMore[0]);if(!this.loading&&e){var t=this.$results.offset().top+this.$results.outerHeight(!1);this.$loadingMore.offset().top+this.$loadingMore.outerHeight(!1)<=t+50&&this.loadMore()}},e.prototype.loadMore=function(){this.loading=!0;var e=n.extend({},{page:1},this.lastParams);e.page++,this.trigger("query:append",e)},e.prototype.showLoadingMore=function(e,t){return t.pagination&&t.pagination.more},e.prototype.createLoadingMore=function(){var e=n('
  • '),t=this.options.get("translations").get("loadingMore");return e.html(t(this.lastParams)),e},e}),e.define("select2/dropdown/attachBody",["jquery","../utils"],function(f,a){function e(e,t,n){this.$dropdownParent=f(n.get("dropdownParent")||document.body),e.call(this,t,n)}return e.prototype.bind=function(e,t,n){var i=this;e.call(this,t,n),t.on("open",function(){i._showDropdown(),i._attachPositioningHandler(t),i._bindContainerResultHandlers(t)}),t.on("close",function(){i._hideDropdown(),i._detachPositioningHandler(t)}),this.$dropdownContainer.on("mousedown",function(e){e.stopPropagation()})},e.prototype.destroy=function(e){e.call(this),this.$dropdownContainer.remove()},e.prototype.position=function(e,t,n){t.attr("class",n.attr("class")),t[0].classList.remove("select2"),t[0].classList.add("select2-container--open"),t.css({position:"absolute",top:-999999}),this.$container=n},e.prototype.render=function(e){var t=f(""),n=e.call(this);return t.append(n),this.$dropdownContainer=t},e.prototype._hideDropdown=function(e){this.$dropdownContainer.detach()},e.prototype._bindContainerResultHandlers=function(e,t){if(!this._containerResultsHandlersBound){var n=this;t.on("results:all",function(){n._positionDropdown(),n._resizeDropdown()}),t.on("results:append",function(){n._positionDropdown(),n._resizeDropdown()}),t.on("results:message",function(){n._positionDropdown(),n._resizeDropdown()}),t.on("select",function(){n._positionDropdown(),n._resizeDropdown()}),t.on("unselect",function(){n._positionDropdown(),n._resizeDropdown()}),this._containerResultsHandlersBound=!0}},e.prototype._attachPositioningHandler=function(e,t){var n=this,i="scroll.select2."+t.id,r="resize.select2."+t.id,s="orientationchange.select2."+t.id,o=this.$container.parents().filter(a.hasScroll);o.each(function(){a.StoreData(this,"select2-scroll-position",{x:f(this).scrollLeft(),y:f(this).scrollTop()})}),o.on(i,function(e){var t=a.GetData(this,"select2-scroll-position");f(this).scrollTop(t.y)}),f(window).on(i+" "+r+" "+s,function(e){n._positionDropdown(),n._resizeDropdown()})},e.prototype._detachPositioningHandler=function(e,t){var n="scroll.select2."+t.id,i="resize.select2."+t.id,r="orientationchange.select2."+t.id;this.$container.parents().filter(a.hasScroll).off(n),f(window).off(n+" "+i+" "+r)},e.prototype._positionDropdown=function(){var e=f(window),t=this.$dropdown[0].classList.contains("select2-dropdown--above"),n=this.$dropdown[0].classList.contains("select2-dropdown--below"),i=null,r=this.$container.offset();r.bottom=r.top+this.$container.outerHeight(!1);var s={height:this.$container.outerHeight(!1)};s.top=r.top,s.bottom=r.top+s.height;var o=this.$dropdown.outerHeight(!1),a=e.scrollTop(),l=e.scrollTop()+e.height(),c=ar.bottom+o,d={left:r.left,top:s.bottom},p=this.$dropdownParent;"static"===p.css("position")&&(p=p.offsetParent());var h={top:0,left:0};(f.contains(document.body,p[0])||p[0].isConnected)&&(h=p.offset()),d.top-=h.top,d.left-=h.left,t||n||(i="below"),u||!c||t?!c&&u&&t&&(i="below"):i="above",("above"==i||t&&"below"!==i)&&(d.top=s.top-h.top-o),null!=i&&(this.$dropdown[0].classList.remove("select2-dropdown--below"),this.$dropdown[0].classList.remove("select2-dropdown--above"),this.$dropdown[0].classList.add("select2-dropdown--"+i),this.$container[0].classList.remove("select2-container--below"),this.$container[0].classList.remove("select2-container--above"),this.$container[0].classList.add("select2-container--"+i)),this.$dropdownContainer.css(d)},e.prototype._resizeDropdown=function(){var e={width:this.$container.outerWidth(!1)+"px"};this.options.get("dropdownAutoWidth")&&(e.minWidth=e.width,e.position="relative",e.width="auto"),this.$dropdown.css(e)},e.prototype._showDropdown=function(e){this.$dropdownContainer.appendTo(this.$dropdownParent),this._positionDropdown(),this._resizeDropdown()},e}),e.define("select2/dropdown/minimumResultsForSearch",[],function(){function e(e,t,n,i){this.minimumResultsForSearch=n.get("minimumResultsForSearch"),this.minimumResultsForSearch<0&&(this.minimumResultsForSearch=1/0),e.call(this,t,n,i)}return e.prototype.showSearch=function(e,t){return!(function e(t){for(var n=0,i=0;i');return e.attr("dir",this.options.get("dir")),this.$container=e,this.$container[0].classList.add("select2-container--"+this.options.get("theme")),u.StoreData(e[0],"element",this.$element),e},d}),e.define("jquery-mousewheel",["jquery"],function(e){return e}),e.define("jquery.select2",["jquery","jquery-mousewheel","./select2/core","./select2/defaults","./select2/utils"],function(r,e,s,t,o){if(null==r.fn.select2){var a=["open","close","destroy"];r.fn.select2=function(t){if("object"==typeof(t=t||{}))return this.each(function(){var e=r.extend(!0,{},t);new s(r(this),e)}),this;if("string"!=typeof t)throw new Error("Invalid arguments for Select2: "+t);var n,i=Array.prototype.slice.call(arguments,1);return this.each(function(){var e=o.GetData(this,"select2");null==e&&window.console&&console.error&&console.error("The select2('"+t+"') method was called on an element that is not using Select2."),n=e[t].apply(e,i)}),-10&&n%100<5||n%100>20?n%10>1?r:e:u}return{errorLoading:function(){return"Невозможно загрузить результаты"},inputTooLong:function(e){var r=e.input.length-e.maximum,u="Пожалуйста, введите на "+r+" символ";return u+=n(r,"","a","ов"),u+=" меньше"},inputTooShort:function(e){var r=e.minimum-e.input.length,u="Пожалуйста, введите ещё хотя бы "+r+" символ";return u+=n(r,"","a","ов")},loadingMore:function(){return"Загрузка данных…"},maximumSelected:function(e){var r="Вы можете выбрать не более "+e.maximum+" элемент";return r+=n(e.maximum,"","a","ов")},noResults:function(){return"Совпадений не найдено"},searching:function(){return"Поиск…"},removeAllItems:function(){return"Удалить все элементы"}}}),n.define,n.require}();$(document).ready(function() { $('.js-auth').submit(function() { var form = $(this); var submit = form.find('button[type=submit]'); if (!formControl(form)) return false; loading(form, submit); $.post('/auth/ajax.php', form.serialize(), function(ret) { loaded(form, submit); if (ret.success) { loading(form, submit); window.location.href = '/main/'; } else { if (ret.error == 1) { showError(form.find('input[name=email]'), 'Неправильный e-mail или пароль'); } } } ); return false; }); });$(document).ready(function() { $('.js-flashmob-task-show-detail').click(function() { var opener = $(this); var detail = opener.next('.js-flashmob-task-detail'); opener.hide(); detail.show(); return false; }); $('.js-flashmob-task-hide-detail').click(function() { var detail = $(this).parents('.js-flashmob-task-detail'); var opener = detail.prev('.js-flashmob-task-show-detail'); detail.hide(); opener.show(); return false; }); $('.js-flashmob-task-accept').click(function() { var form = $(this).parent(); var button = $(this); loading(form, button); $.post('/quest/ajax.php', { act: 'taskAccept', id: $(this).data('id') }, function(ret) { if (ret.success) { window.location.href = ret.url; } else { loaded(form, button); showError(button, 'Одновременно нельзя брать больше 3-ех заданий', true); } } ); return false; }); $('.js-flashmob-task-cancel').click(function() { var form = $(this).parent(); loading(form); $.post('/quest/ajax.php', { act: 'taskCancel', id: $(this).data('id') }, function(ret) { if (ret.success) { window.location.href = '/quest/'; } else { loaded(form); } } ); }); $('.js-flashmob-report').submit(function() { var form = $(this); var submit = form.find('button[type=submit]'); if (!formControl(form)) return false; loading(form, submit); $.post('/quest/ajax.php', form.serialize(), function(ret) { if (ret.success) { location.reload(); } else { loaded(form, submit); } } ); return false; }); $('.js-flashmob-check-report').click(function() { var form = $(this).parent(); var submit = $(this); loading(form, submit); $.post('/quest/ajax.php', { act: 'checkReport', check_id: $(this).data('check'), status: $(this).data('status'), }, function(ret) { if (ret.success) { location.reload(); } else { loaded(form, submit); } } ); return false; }); $('.js-flashmob-filter').click(function() { $('.js-flashmob-filter').removeClass('btn--standart').addClass('btn--white'); $(this).removeClass('btn--white').addClass('btn--standart'); if ($(this).data('filter') == 'all') { $('.js-flashmob-item').show(); } else { $('.js-flashmob-item').hide(); $('.js-flashmob-item-is-active').show(); } return false; }); if ($('.js-flashmob-filter-counter').length) { $('.js-flashmob-filter-counter').text($('.js-flashmob-item-is-active').length); } });$(document).ready(function() { $('.js-gender').submit(function() { var form = $(this); var submit = form.find('button[type=submit]'); if (!formControl(form)) return false; loading(form, submit); $.post('/gender/ajax.php', form.serialize(), function(ret) { loaded(form, submit); if (ret.success) { loading(form, submit); window.location.href = '/main/'; } } ); return false; }); });$(document).ready(function() { if ($('.js-location-city').length) { $('.js-location-city').select2({ language: 'ru', minimumInputLength: 1, placeholder: 'Выберите ваш город', ajax: { url: '/location/ajax.php', dataType: 'json', method: 'post', data: function (params) { var query = { act: 'getCities', q: params.term, } return query; }, delay: 200 }, }); $('.js-location-city').one('select2:open', function(e) { $('input.select2-search__field').prop('placeholder', 'Начните вводить название вашего города'); }); } if ($('.js-location-city-hint-set').length) { $('.js-location-city-hint-set').change(function() { $(this).parent().parent().parent().stop().hide(); $('.js-location-city').select2('open'); $('input.select2-search__field').val($(this).data('city')).keyup(); return false; }); } if ($('.js-location-city-hint-hide').length) { $('.js-location-city-hint-hide').change(function() { $(this).parent().parent().parent().stop().hide(); return false; }); } $('.js-location').submit(function() { var form = $(this); var submit = form.find('button[type=submit]'); if (!formControl(form)) return false; loading(form, submit); $.post('/location/ajax.php', form.serialize(), function(ret) { loaded(form, submit); if (ret.success) { loading(form, submit); window.location.href = '/main/'; } } ); return false; }); });$(document).ready(function() { if ($('.js-pagination').length) { $('.js-pagination').each(function() { var pagination = $(this); var prev = pagination.find('.js-pagination-prev'); var next = pagination.find('.js-pagination-next'); pagination.data('page', 1); pagination_checkPaginationVisible(pagination); prev.click(function() { var pagination = $(this).parents('.js-pagination'); pagination_getPage(pagination, pagination.data('page') - 1); return false; }); next.click(function() { var pagination = $(this).parents('.js-pagination'); pagination_getPage(pagination, pagination.data('page') + 1); return false; }); }); $('.js-pagination-search-me').click(function() { var pagination = $(this).parents('.js-pagination'); loading(pagination); $.post(pagination.data('ajax-path'), { act: pagination.data('ajax-act') + 'MyPage', search: $(this).data('search') }, function(ret) { if (ret.success) { pagination_getPage(pagination, ret.page); } else { loaded(pagination); } } ); return false; }); } }); function pagination_getPage(pagination, page) { var items = pagination.find('.js-pagination-items'); loading(pagination); $.post(pagination.data('ajax-path'), { act: pagination.data('ajax-act'), page: page }, function(ret) { loaded(pagination); if (ret.success) { items.html(ret.html); pagination.data('page', page); pagination_checkPaginationVisible(pagination); } } ); } function pagination_checkPaginationVisible(pagination) { var page = pagination.data('page'); var prev = pagination.find('.js-pagination-prev'); var next = pagination.find('.js-pagination-next'); var search_me = pagination.find('.js-pagination-search-me'); if (page == 1) { prev.addClass('pael-pagination__item_disabled'); } else { prev.removeClass('pael-pagination__item_disabled'); } if (page < pagination.data('pages')) { next.removeClass('pael-pagination__item_disabled'); } else { next.addClass('pael-pagination__item_disabled'); } if (!pagination.find('.js-pagination-item[data-id=' + search_me.data('search') + ']').length) { search_me.removeClass('pael-pagination__item_disabled'); } else { search_me.addClass('pael-pagination__item_disabled'); } }$(document).ready(function() { $('.js-popup-close').click(function() { $(this).parents('.popup').fadeOut(300); return false; }); });$(document).ready(function() { $('.js-profile').submit(function() { var form = $(this); var submit = form.find('button[type=submit]'); if (!formControl(form)) return false; if (form.find('input[name=password]').length) { if (form.find('input[name=password]').val().length || form.find('input[name=password_2]').val().length) { if (form.find('input[name=password]').val() != form.find('input[name=password_2]').val()) { showError(form.find('input[name=password]'), 'Пароли не совпадают'); return false; } } } loading(form, submit); $.post('/profile/ajax.php', form.serialize(), function(ret) { loaded(form, submit); if (ret.success) { loading(form, submit); window.location.href = '/profile/?saved'; } } ); return false; }); $('.js-profile-delete').click(function() { if (prompt("Внимание! Данное действие необратимо.\r\nВведите слово «удалить» без кавычек, чтобы подтвердить удаление.") == 'удалить') { var form = $(this); var submit = form; loading(form, submit); $.post('/profile/ajax.php', { act: 'delete' }, function(ret) { if (ret.success) { window.location.href = '/'; } else { loaded(form, submit); } } ); } return false; }); });$(document).ready(function() { $('.js-registration').submit(function() { var form = $(this); var submit = form.find('button[type=submit]'); if (!formControl(form)) return false; loading(form, submit); $.post('/registration/ajax.php', form.serialize(), function(ret) { loaded(form, submit); if (ret.success) { loading(form, submit); window.location.href = '/main/'; } else { if (ret.error == 1) { showError(form.find('input[name=email]'), 'Пользователь с заданным e-mail уже существует'); } } } ); return false; }); });$(document).ready(function() { $('.js-restore').submit(function() { var form = $(this); var submit = form.find('button[type=submit]'); if (!formControl(form)) return false; loading(form, submit); $.post('/restore/ajax.php', form.serialize(), function(ret) { loaded(form, submit); if (ret.success) { form.stop().slideUp(300); $('.js-restore-done').stop().slideDown(300); } else { if (ret.error == 1) { showError(form.find('input[name=email]'), 'Пользователь с указанным e-mail не найден'); } } } ); return false; }); });