var globalNav;!function(){var t=$(window),e={header:"",panel:"",services:""},i="globalNavReady";globalNav={id:"",domain:"",ready:!1,header:"#header",render:function(t,i){this.opts=$.extend({},e,t),$(document).ready($.proxy(this.init,this,this.opts)),i&&this.init(this.opts,i)},init:function(e,s){if(!this.ready||s){this.addPredefinedContent();var n=$.Deferred(),o=this.id,a=this;return o&&sessionStorage.getItem(o)?(this.initializeHeader(sessionStorage.getItem(o)),this.ready=!0,t.trigger(i),n.resolve()):$.when(this._getHtml(e)).then(function(e){a._onSuccess(e),a.ready=!0,t.trigger(i)})}},addPredefinedContent:function(){this.$header=$(this.header)},initializeHeader:function(t){this.$header.html(t.html),t.classes&&this.$header.addClass(t.classes),$.fn.dropdown&&$(".dropdown",this.header).dropdown(),this.overlay&&this.overlay.init(),this.panel&&this.panel.init(this.opts.panel),this.services&&this.services.init(this.opts.services),this.search&&this.search.init(),this.notices&&this.notices.init(this.opts.notices)},_getHtml:function(t){return $.ajax({url:this.domain+"getHeaderContent",method:"POST",data:{data:JSON.stringify(t)},error:function(t){}})},_onSuccess:function(t){this.initializeHeader(t.response),this.id&&sessionStorage.setItem(this.id,t.response)}}}(),function(t,e){function i(t){this.opts=e.extend({},t),this.props=this.opts.props,this._init()}var s,n,o,a,l,h,d={fetch:{url:"",method:"",data:"",onSuccess:""},remove:{url:"",method:"",data:"",onSuccess:""},data:"",eventCounter:"",title:"Уведомления",titleTemplate:'

<%= title %>

',noticeTemplate:'
<% if (type == 1) {%> <%= typeLabel %> — <%= title %> <% } %> <% if (type == 2) {%> <%= title %> <% } %> <% if (type == 2) { %> <%= typeLabel %> <% } %> <% if (type == 1) { %> <% _.each(eventTypes, function(event){ %> <%= event.label %> <% }) %> <% } %>
× ',notFoundMessage:"Нет новых уведомлений",notFoundTemplate:'
<%= notFoundMessage %>
',onShow:""},r={0:"Horn",1:"Star",2:"Bag",3:"Sword",4:"Clients",5:"Box",6:"Gift"};globalNav.notices={eventsCount:0,newsCount:0,types:{1:"eventsCount",2:"newsCount"},notices:[],init:function(i){this.opts=e.extend({},d,i),this._addPanel(),this._addTitle(),this._addClose(),this._defineDOM(),this._addNotFoundMessage(),t.Preloader&&this._createPreloader(),this.opts.data?this._handleInitialData(this.opts.data):this.opts.fetch.url&&(this.preloader&&this.preloader.show(),e.when(this.getNotices()).then(function(t){var e=t.response;e&&this._handleInitialData(e)}.bind(this))),s.on("click",this._onClickNotices.bind(this)),a.on("click",this.hide.bind(this)),o.on("click",this.clearAll.bind(this,!0)),this.$panel.on("click",this._onClickPanel.bind(this)),h.on("globalNavOverlayHide",this._onHideOverlay.bind(this)),l.on("allNoticeHidden",this._onAllNoticesHidden.bind(this)),l.on("noticeHide",this._onNoticeHide.bind(this))},_handleInitialData:function(t){this.preloader&&this.preloader.hide(),this._render(t.items),this.eventsCount=t.events,this.newsCount=t.news,this._handleCounter(this.newsCount,this.eventsCount),this.handleNotFoundMessage(),this.opts.fetch.onSuccess&&this.opts.fetch.onSuccess(t)},_defineDOM:function(){s=e("#header-notice-toggle"),n=e(".header--notices--counter",s),o=e(".global-notices-header--clear",this.$panel),a=e(".nav-panel--close",this.$panel),h=e("html"),l=e(t);var i=this.opts.eventCounter;i&&(this.$eventCounter="string"==typeof i?e(this.opts.eventCounter):i)},_addClose:function(){this.$panel.append('×')},_addPanel:function(){this.$panel=e('