1 line
17 KiB
JavaScript
1 line
17 KiB
JavaScript
if("undefined"==typeof jQuery)throw new Error("AdminLTE requires jQuery");!function($){"use strict";var DataKey="lte.boxrefresh",Default={source:"",params:{},trigger:".refresh-btn",content:".box-body",loadInContent:!0,responseType:"",overlayTemplate:'<div class="overlay"><div class="fa fa-refresh fa-spin"></div></div>',onLoadStart:function(){},onLoadDone:function(response){return response}},Selector={data:'[data-widget="box-refresh"]'},BoxRefresh=function(element,options){if(this.element=element,this.options=options,this.$overlay=$(options.overlay),""===options.source)throw new Error("Source url was not defined. Please specify a url in your BoxRefresh source option.");this._setUpListeners(),this.load()};function Plugin(option){return this.each(function(){var $this=$(this),data=$this.data(DataKey);if(!data){var options=$.extend({},Default,$this.data(),"object"==typeof option&&option);$this.data(DataKey,data=new BoxRefresh($this,options))}if("string"==typeof data){if(void 0===data[option])throw new Error("No method named "+option);data[option]()}})}BoxRefresh.prototype.load=function(){this._addOverlay(),this.options.onLoadStart.call($(this)),$.get(this.options.source,this.options.params,function(response){this.options.loadInContent&&$(this.options.content).html(response),this.options.onLoadDone.call($(this),response),this._removeOverlay()}.bind(this),""!==this.options.responseType&&this.options.responseType)},BoxRefresh.prototype._setUpListeners=function(){$(this.element).on("click",Selector.trigger,function(event){event&&event.preventDefault(),this.load()}.bind(this))},BoxRefresh.prototype._addOverlay=function(){$(this.element).append(this.$overlay)},BoxRefresh.prototype._removeOverlay=function(){$(this.element).remove(this.$overlay)};var old=$.fn.boxRefresh;$.fn.boxRefresh=Plugin,$.fn.boxRefresh.Constructor=BoxRefresh,$.fn.boxRefresh.noConflict=function(){return $.fn.boxRefresh=old,this},$(window).on("load",function(){$(Selector.data).each(function(){Plugin.call($(this))})})}(jQuery),function($){"use strict";var DataKey="lte.boxwidget",Default={animationSpeed:500,collapseTrigger:'[data-widget="collapse"]',removeTrigger:'[data-widget="remove"]',collapseIcon:"fa-minus",expandIcon:"fa-plus",removeIcon:"fa-times"},Selector_data=".box",Selector_collapsed=".collapsed-box",Selector_header=".box-header",Selector_body=".box-body",Selector_footer=".box-footer",Selector_tools=".box-tools",ClassName_collapsed="collapsed-box",Event_collapsed="collapsed.boxwidget",Event_expanded="expanded.boxwidget",Event_removed="removed.boxwidget",BoxWidget=function(element,options){this.element=element,this.options=options,this._setUpListeners()};function Plugin(option){return this.each(function(){var $this=$(this),data=$this.data(DataKey);if(!data){var options=$.extend({},Default,$this.data(),"object"==typeof option&&option);$this.data(DataKey,data=new BoxWidget($this,options))}if("string"==typeof option){if(void 0===data[option])throw new Error("No method named "+option);data[option]()}})}BoxWidget.prototype.toggle=function(){var isOpen;!$(this.element).is(Selector_collapsed)?this.collapse():this.expand()},BoxWidget.prototype.expand=function(){var expandedEvent=$.Event(Event_expanded),collapseIcon=this.options.collapseIcon,expandIcon=this.options.expandIcon;$(this.element).removeClass(ClassName_collapsed),$(this.element).children(Selector_header+", "+Selector_body+", "+Selector_footer).children(Selector_tools).find("."+expandIcon).removeClass(expandIcon).addClass(collapseIcon),$(this.element).children(Selector_body+", "+Selector_footer).slideDown(this.options.animationSpeed,function(){$(this.element).trigger(expandedEvent)}.bind(this))},BoxWidget.prototype.collapse=function(){var collapsedEvent=$.Event(Event_collapsed),collapseIcon=this.options.collapseIcon,expandIcon=this.options.expandIcon;$(this.element).children(Selector_header+", "+Selector_body+", "+Selector_footer).children(Selector_tools).find("."+collapseIcon).removeClass(collapseIcon).addClass(expandIcon),$(this.element).children(Selector_body+", "+Selector_footer).slideUp(this.options.animationSpeed,function(){$(this.element).addClass(ClassName_collapsed),$(this.element).trigger(collapsedEvent)}.bind(this))},BoxWidget.prototype.remove=function(){var removedEvent=$.Event(Event_removed);$(this.element).slideUp(this.options.animationSpeed,function(){$(this.element).trigger(removedEvent),$(this.element).remove()}.bind(this))},BoxWidget.prototype._setUpListeners=function(){var that=this;$(this.element).on("click",this.options.collapseTrigger,function(event){return event&&event.preventDefault(),that.toggle($(this)),!1}),$(this.element).on("click",this.options.removeTrigger,function(event){return event&&event.preventDefault(),that.remove($(this)),!1})};var old=$.fn.boxWidget;$.fn.boxWidget=Plugin,$.fn.boxWidget.Constructor=BoxWidget,$.fn.boxWidget.noConflict=function(){return $.fn.boxWidget=old,this},$(window).on("load",function(){$(Selector_data).each(function(){Plugin.call($(this))})})}(jQuery),function($){"use strict";var DataKey="lte.controlsidebar",Default={slide:!0},Selector_sidebar=".control-sidebar",Selector_data='[data-toggle="control-sidebar"]',Selector_open=".control-sidebar-open",Selector_bg=".control-sidebar-bg",Selector_wrapper=".wrapper",Selector_content=".content-wrapper",Selector_boxed=".layout-boxed",ClassName_open="control-sidebar-open",ClassName_fixed="fixed",Event_collapsed="collapsed.controlsidebar",Event_expanded="expanded.controlsidebar",ControlSidebar=function(element,options){this.element=element,this.options=options,this.hasBindedResize=!1,this.init()};function Plugin(option){return this.each(function(){var $this=$(this),data=$this.data(DataKey);if(!data){var options=$.extend({},Default,$this.data(),"object"==typeof option&&option);$this.data(DataKey,data=new ControlSidebar($this,options))}"string"==typeof option&&data.toggle()})}ControlSidebar.prototype.init=function(){$(this.element).is(Selector_data)||$(this).on("click",this.toggle),this.fix(),$(window).resize(function(){this.fix()}.bind(this))},ControlSidebar.prototype.toggle=function(event){event&&event.preventDefault(),this.fix(),$(Selector_sidebar).is(Selector_open)||$("body").is(Selector_open)?this.collapse():this.expand()},ControlSidebar.prototype.expand=function(){this.options.slide?$(Selector_sidebar).addClass(ClassName_open):$("body").addClass(ClassName_open),$(this.element).trigger($.Event(Event_expanded))},ControlSidebar.prototype.collapse=function(){$("body, "+Selector_sidebar).removeClass(ClassName_open),$(this.element).trigger($.Event(Event_collapsed))},ControlSidebar.prototype.fix=function(){$("body").is(Selector_boxed)&&this._fixForBoxed($(Selector_bg))},ControlSidebar.prototype._fixForBoxed=function(bg){bg.css({position:"absolute",height:$(Selector_wrapper).height()})};var old=$.fn.controlSidebar;$.fn.controlSidebar=Plugin,$.fn.controlSidebar.Constructor=ControlSidebar,$.fn.controlSidebar.noConflict=function(){return $.fn.controlSidebar=old,this},$(document).on("click",Selector_data,function(event){event&&event.preventDefault(),Plugin.call($(this),"toggle")})}(jQuery),function($){"use strict";var DataKey="lte.directchat",Selector_data='[data-widget="chat-pane-toggle"]',Selector_box=".direct-chat",ClassName_open="direct-chat-contacts-open",DirectChat=function(element){this.element=element};function Plugin(option){return this.each(function(){var $this=$(this),data=$this.data(DataKey);data||$this.data(DataKey,data=new DirectChat($this)),"string"==typeof option&&data.toggle($this)})}DirectChat.prototype.toggle=function($trigger){$trigger.parents(Selector_box).first().toggleClass(ClassName_open)};var old=$.fn.directChat;$.fn.directChat=Plugin,$.fn.directChat.Constructor=DirectChat,$.fn.directChat.noConflict=function(){return $.fn.directChat=old,this},$(document).on("click",Selector_data,function(event){event&&event.preventDefault(),Plugin.call($(this),"toggle")})}(jQuery),function($){"use strict";var DataKey="lte.layout",Default={slimscroll:!0,resetHeight:!0},Selector_wrapper=".wrapper",Selector_contentWrapper=".content-wrapper",Selector_layoutBoxed=".layout-boxed",Selector_mainFooter=".main-footer",Selector_mainHeader=".main-header",Selector_sidebar=".sidebar",Selector_controlSidebar=".control-sidebar",Selector_fixed=".fixed",Selector_sidebarMenu=".sidebar-menu",Selector_logo=".main-header .logo",ClassName_fixed="fixed",ClassName_holdTransition="hold-transition",Layout=function(options){this.options=options,this.bindedResize=!1,this.activate()};function Plugin(option){return this.each(function(){var $this=$(this),data=$this.data(DataKey);if(!data){var options=$.extend({},Default,$this.data(),"object"==typeof option&&option);$this.data(DataKey,data=new Layout(options))}if("string"==typeof option){if(void 0===data[option])throw new Error("No method named "+option);data[option]()}})}Layout.prototype.activate=function(){this.fix(),this.fixSidebar(),$("body").removeClass(ClassName_holdTransition),this.options.resetHeight&&$("body, html, "+Selector_wrapper).css({height:"auto","min-height":"100%"}),this.bindedResize||($(window).resize(function(){this.fix(),this.fixSidebar(),$(Selector_logo+", "+Selector_sidebar).one("webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend",function(){this.fix(),this.fixSidebar()}.bind(this))}.bind(this)),this.bindedResize=!0),$(Selector_sidebarMenu).on("expanded.tree",function(){this.fix(),this.fixSidebar()}.bind(this)),$(Selector_sidebarMenu).on("collapsed.tree",function(){this.fix(),this.fixSidebar()}.bind(this))},Layout.prototype.fix=function(){$(Selector_layoutBoxed+" > "+Selector_wrapper).css("overflow","hidden");var footerHeight=$(Selector_mainFooter).outerHeight()||0,headerHeight,neg=($(Selector_mainHeader).outerHeight()||0)+footerHeight,windowHeight=$(window).height(),sidebarHeight=$(Selector_sidebar).height()||0;if($("body").hasClass(ClassName_fixed))$(Selector_contentWrapper).css("min-height",windowHeight-footerHeight);else{var postSetHeight;windowHeight>=sidebarHeight?($(Selector_contentWrapper).css("min-height",windowHeight-neg),postSetHeight=windowHeight-neg):($(Selector_contentWrapper).css("min-height",sidebarHeight),postSetHeight=sidebarHeight);var $controlSidebar=$(Selector_controlSidebar);void 0!==$controlSidebar&&$controlSidebar.height()>postSetHeight&&$(Selector_contentWrapper).css("min-height",$controlSidebar.height())}},Layout.prototype.fixSidebar=function(){$("body").hasClass(ClassName_fixed)?this.options.slimscroll&&void 0!==$.fn.slimScroll&&$(Selector_sidebar).slimScroll({height:$(window).height()-$(Selector_mainHeader).height()+"px"}):void 0!==$.fn.slimScroll&&$(Selector_sidebar).slimScroll({destroy:!0}).height("auto")};var old=$.fn.layout;$.fn.layout=Plugin,$.fn.layout.Constuctor=Layout,$.fn.layout.noConflict=function(){return $.fn.layout=old,this},$(window).on("load",function(){Plugin.call($("body"))})}(jQuery),function($){"use strict";var DataKey="lte.pushmenu",Default={collapseScreenSize:767,expandOnHover:!1,expandTransitionDelay:200},Selector_collapsed=".sidebar-collapse",Selector_open=".sidebar-open",Selector_mainSidebar=".main-sidebar",Selector_contentWrapper=".content-wrapper",Selector_searchInput=".sidebar-form .form-control",Selector_button='[data-toggle="push-menu"]',Selector_mini=".sidebar-mini",Selector_expanded=".sidebar-expanded-on-hover",Selector_layoutFixed=".fixed",ClassName_collapsed="sidebar-collapse",ClassName_open="sidebar-open",ClassName_mini="sidebar-mini",ClassName_expanded="sidebar-expanded-on-hover",ClassName_expandFeature="sidebar-mini-expand-feature",ClassName_layoutFixed="fixed",Event_expanded="expanded.pushMenu",Event_collapsed="collapsed.pushMenu",PushMenu=function(options){this.options=options,this.init()};function Plugin(option){return this.each(function(){var $this=$(this),data=$this.data(DataKey);if(!data){var options=$.extend({},Default,$this.data(),"object"==typeof option&&option);$this.data(DataKey,data=new PushMenu(options))}"toggle"===option&&data.toggle()})}PushMenu.prototype.init=function(){(this.options.expandOnHover||$("body").is(Selector_mini+Selector_layoutFixed))&&(this.expandOnHover(),$("body").addClass(ClassName_expandFeature)),$(Selector_contentWrapper).click(function(){$(window).width()<=this.options.collapseScreenSize&&$("body").hasClass(ClassName_open)&&this.close()}.bind(this)),$(Selector_searchInput).click(function(e){e.stopPropagation()})},PushMenu.prototype.toggle=function(){var windowWidth=$(window).width(),isOpen=!$("body").hasClass(ClassName_collapsed);windowWidth<=this.options.collapseScreenSize&&(isOpen=$("body").hasClass(ClassName_open)),isOpen?this.close():this.open()},PushMenu.prototype.open=function(){var windowWidth;$(window).width()>this.options.collapseScreenSize?$("body").removeClass(ClassName_collapsed).trigger($.Event(Event_expanded)):$("body").addClass(ClassName_open).trigger($.Event(Event_expanded))},PushMenu.prototype.close=function(){var windowWidth;$(window).width()>this.options.collapseScreenSize?$("body").addClass(ClassName_collapsed).trigger($.Event(Event_collapsed)):$("body").removeClass(ClassName_open+" "+ClassName_collapsed).trigger($.Event(Event_collapsed))},PushMenu.prototype.expandOnHover=function(){$(Selector_mainSidebar).hover(function(){$("body").is(Selector_mini+Selector_collapsed)&&$(window).width()>this.options.collapseScreenSize&&this.expand()}.bind(this),function(){$("body").is(Selector_expanded)&&this.collapse()}.bind(this))},PushMenu.prototype.expand=function(){setTimeout(function(){$("body").removeClass(ClassName_collapsed).addClass(ClassName_expanded)},this.options.expandTransitionDelay)},PushMenu.prototype.collapse=function(){setTimeout(function(){$("body").removeClass(ClassName_expanded).addClass(ClassName_collapsed)},this.options.expandTransitionDelay)};var old=$.fn.pushMenu;$.fn.pushMenu=Plugin,$.fn.pushMenu.Constructor=PushMenu,$.fn.pushMenu.noConflict=function(){return $.fn.pushMenu=old,this},$(document).on("click",Selector_button,function(e){e.preventDefault(),Plugin.call($(this),"toggle")}),$(window).on("load",function(){Plugin.call($(Selector_button))})}(jQuery),function($){"use strict";var DataKey="lte.todolist",Default={onCheck:function(item){return item},onUnCheck:function(item){return item}},Selector={data:'[data-widget="todo-list"]'},ClassName_done="done",TodoList=function(element,options){this.element=element,this.options=options,this._setUpListeners()};function Plugin(option){return this.each(function(){var $this=$(this),data=$this.data(DataKey);if(!data){var options=$.extend({},Default,$this.data(),"object"==typeof option&&option);$this.data(DataKey,data=new TodoList($this,options))}if("string"==typeof data){if(void 0===data[option])throw new Error("No method named "+option);data[option]()}})}TodoList.prototype.toggle=function(item){item.parents(Selector.li).first().toggleClass(ClassName_done),item.prop("checked")?this.check(item):this.unCheck(item)},TodoList.prototype.check=function(item){this.options.onCheck.call(item)},TodoList.prototype.unCheck=function(item){this.options.onUnCheck.call(item)},TodoList.prototype._setUpListeners=function(){var that=this;$(this.element).on("change ifChanged","input:checkbox",function(){that.toggle($(this))})};var old=$.fn.todoList;$.fn.todoList=Plugin,$.fn.todoList.Constructor=TodoList,$.fn.todoList.noConflict=function(){return $.fn.todoList=old,this},$(window).on("load",function(){$(Selector.data).each(function(){Plugin.call($(this))})})}(jQuery),function($){"use strict";var DataKey="lte.tree",Default={animationSpeed:500,accordion:!0,followLink:!1,trigger:".treeview a"},Selector_tree=".tree",Selector_treeview=".treeview",Selector_treeviewMenu=".treeview-menu",Selector_open=".menu-open, .active",Selector_li="li",Selector_data='[data-widget="tree"]',Selector_active=".active",ClassName_open="menu-open",ClassName_tree="tree",Event_collapsed="collapsed.tree",Event_expanded="expanded.tree",Tree=function(element,options){this.element=element,this.options=options,$(this.element).addClass(ClassName_tree),$(Selector_treeview+Selector_active,this.element).addClass(ClassName_open),this._setUpListeners()};function Plugin(option){return this.each(function(){var $this=$(this),data;if(!$this.data(DataKey)){var options=$.extend({},Default,$this.data(),"object"==typeof option&&option);$this.data(DataKey,new Tree($this,options))}})}Tree.prototype.toggle=function(link,event){var treeviewMenu=link.next(Selector_treeviewMenu),parentLi=link.parent(),isOpen=parentLi.hasClass(ClassName_open);parentLi.is(Selector_treeview)&&(this.options.followLink&&"#"!==link.attr("href")||event.preventDefault(),isOpen?this.collapse(treeviewMenu,parentLi):this.expand(treeviewMenu,parentLi))},Tree.prototype.expand=function(tree,parent){var expandedEvent=$.Event(Event_expanded);if(this.options.accordion){var openMenuLi=parent.siblings(Selector_open),openTree=openMenuLi.children(Selector_treeviewMenu);this.collapse(openTree,openMenuLi)}parent.addClass(ClassName_open),tree.slideDown(this.options.animationSpeed,function(){$(this.element).trigger(expandedEvent)}.bind(this))},Tree.prototype.collapse=function(tree,parentLi){var collapsedEvent=$.Event(Event_collapsed);parentLi.removeClass(ClassName_open),tree.slideUp(this.options.animationSpeed,function(){$(this.element).trigger(collapsedEvent)}.bind(this))},Tree.prototype._setUpListeners=function(){var that=this;$(this.element).on("click",this.options.trigger,function(event){that.toggle($(this),event)})};var old=$.fn.tree;$.fn.tree=Plugin,$.fn.tree.Constructor=Tree,$.fn.tree.noConflict=function(){return $.fn.tree=old,this},$(window).on("load",function(){$(Selector_data).each(function(){Plugin.call($(this))})})}(jQuery); |