(function($){$.widget("lws.lws_vertical_nav",{options:{},_create:function(){this.groups=this.element.find(".groups-grid");this._createStructure();this.vertNav.on("mouseout",".vertnav-item",this._bind(this._outItem,this));this.vertNav.on("mouseover",".vertnav-item",this._bind(this._overItem,this));this.vertNav.on("click",".vertnav-item",this._bind(this._scrollToGroup,this));this.vertNav.on("click",".vertnav-prec",this._bind(this._scrollToPrec,this));this.vertNav.on("click",".vertnav-suiv",this._bind(this._scrollToSuiv,this));$(document).on("scroll",this._bind(this._handleScroll,this))},_bind:function(fn,me){return function(){return fn.apply(me,arguments)}},_createStructure:function(){this.vertNav=$("<div>",{class:"lws-vertical-nav"}).appendTo(this.groups);this.prec=$("<div>",{class:"vertnav-prec lws-icon-nav-up"}).appendTo(this.vertNav);var me=this;this.initialPos=false;this.groups.find(".group-item").each(function(){if(!me.initialPos)me.initialPos=Math.floor($(this).position().top);icon=$(this).find(".group-icon").data("lws-icon");text=$(this).find(".group-title").html();$("<div>",{class:"vertnav-item","data-id":$(this).attr("id")}).append($("<div>",{class:"vertnav-icon "+icon})).append($("<div>",{class:"vertnav-label",html:text})).appendTo(me.vertNav)});this.suiv=$("<div>",{class:"vertnav-suiv lws-icon-nav-down"}).appendTo(this.vertNav);this._handleScroll()},_outItem:function(){this.vertNav.find(".vertnav-item").removeClass("rang1").removeClass("rang2")},_overItem:function(event){var origin=event.currentTarget;prev1=$(origin).prev();if(prev1.hasClass("vertnav-item")){prev1.addClass("rang1");prev2=$(prev1).prev();if(prev2.hasClass("vertnav-item")){prev2.addClass("rang2")}}next1=$(origin).next();if(next1.hasClass("vertnav-item")){next1.addClass("rang1");next2=$(next1).next();if(next2.hasClass("vertnav-item")){next2.addClass("rang2")}}},_handleScroll:function(){var scroll=$(document).scrollTop();var me=this;$(".vertnav-item").each(function(){var id=$(this).data("id");var group=$("#"+id).get(0);var initial=group.offsetTop-me.initialPos;var end=initial+$(group).innerHeight();if(initial<=scroll&&scroll<end){$(this).addClass("current")}else{$(this).removeClass("current")}})},_scrollToGroup:function(event){var id=$(event.currentTarget).data("id");$("html, body").stop().animate({scrollTop:$("#"+id).get(0).offsetTop-this.initialPos+10},1e3,"swing")},_scrollToPrec:function(event){var origin=$(".vertnav-item.current").first().prev();if(origin.hasClass("vertnav-item")){var id=$(origin).data("id");$("html, body").stop().animate({scrollTop:$("#"+id).get(0).offsetTop-this.initialPos+10},1e3,"swing")}},_scrollToSuiv:function(event){var origin=$(".vertnav-item.current").last().next();if(origin.hasClass("vertnav-item")){var id=$(origin).data("id");$("html, body").stop().animate({scrollTop:$("#"+id).get(0).offsetTop-this.initialPos+10},1e3,"swing")}}})})(jQuery);jQuery(function($){$(".lws-admin-page").lws_vertical_nav()});
