AdminLTE/dist/js/adminlte.js

1131 lines
28 KiB
JavaScript
Raw Normal View History

2017-02-25 19:39:54 +00:00
/*! AdminLTE app.js
* ================
* Main JS application file for AdminLTE v2. This file
* should be included in all pages. It controls some layout
* options and implements exclusive AdminLTE plugins.
*
* @Author Almsaeed Studio
* @Support <https://www.almsaeedstudio.com>
* @Email <abdullah@almsaeedstudio.com>
2018-07-15 18:48:11 +00:00
* @version 2.4.8
2017-02-25 19:39:54 +00:00
* @repository git://github.com/almasaeed2010/AdminLTE.git
* @license MIT <http://opensource.org/licenses/MIT>
*/
// Make sure jQuery has been loaded
if (typeof jQuery === 'undefined') {
throw new Error('AdminLTE requires jQuery')
}
2017-07-08 17:45:57 +00:00
/* BoxRefresh()
* =========
* Adds AJAX content control to a box.
2017-02-25 19:39:54 +00:00
*
2017-07-08 17:45:57 +00:00
* @Usage: $('#my-box').boxRefresh(options)
* or add [data-widget="box-refresh"] to the box element
* Pass any option as data-option="value"
2017-02-25 19:39:54 +00:00
*/
+function ($) {
2017-10-26 20:53:11 +00:00
'use strict';
2017-02-25 19:39:54 +00:00
2017-10-26 20:53:11 +00:00
var DataKey = 'lte.boxrefresh';
2017-02-25 19:39:54 +00:00
var Default = {
2017-07-08 17:45:57 +00:00
source : '',
params : {},
trigger : '.refresh-btn',
content : '.box-body',
loadInContent : true,
responseType : '',
overlayTemplate: '<div class="overlay"><div class="fa fa-refresh fa-spin"></div></div>',
onLoadStart : function () {
},
onLoadDone : function (response) {
2017-10-26 20:53:11 +00:00
return response;
2017-07-08 17:45:57 +00:00
}
2017-10-26 20:53:11 +00:00
};
2017-02-25 19:39:54 +00:00
var Selector = {
2017-07-08 17:45:57 +00:00
data: '[data-widget="box-refresh"]'
2017-10-26 20:53:11 +00:00
};
2017-02-25 19:39:54 +00:00
2017-07-08 17:45:57 +00:00
// BoxRefresh Class Definition
// =========================
var BoxRefresh = function (element, options) {
2017-10-26 20:53:11 +00:00
this.element = element;
this.options = options;
this.$overlay = $(options.overlay);
2017-02-25 19:39:54 +00:00
2017-07-08 17:45:57 +00:00
if (options.source === '') {
2017-10-26 20:53:11 +00:00
throw new Error('Source url was not defined. Please specify a url in your BoxRefresh source option.');
2017-02-25 19:39:54 +00:00
}
2017-10-26 20:53:11 +00:00
this._setUpListeners();
this.load();
};
2017-06-25 13:33:22 +00:00
2017-07-08 17:45:57 +00:00
BoxRefresh.prototype.load = function () {
2017-10-26 20:53:11 +00:00
this._addOverlay();
this.options.onLoadStart.call($(this));
2017-06-25 13:33:22 +00:00
2017-07-08 17:45:57 +00:00
$.get(this.options.source, this.options.params, function (response) {
if (this.options.loadInContent) {
2017-10-26 20:53:11 +00:00
$(this.options.content).html(response);
2017-07-08 17:45:57 +00:00
}
2017-10-26 20:53:11 +00:00
this.options.onLoadDone.call($(this), response);
this._removeOverlay();
}.bind(this), this.options.responseType !== '' && this.options.responseType);
};
2017-02-25 19:39:54 +00:00
2017-07-08 17:45:57 +00:00
// Private
2017-02-25 19:39:54 +00:00
2017-07-08 17:45:57 +00:00
BoxRefresh.prototype._setUpListeners = function () {
$(this.element).on('click', Selector.trigger, function (event) {
2017-10-26 20:53:11 +00:00
if (event) event.preventDefault();
this.load();
}.bind(this));
};
2017-02-25 19:39:54 +00:00
2017-07-08 17:45:57 +00:00
BoxRefresh.prototype._addOverlay = function () {
2017-10-26 20:53:11 +00:00
$(this.element).append(this.$overlay);
};
2017-02-25 19:39:54 +00:00
2017-07-08 17:45:57 +00:00
BoxRefresh.prototype._removeOverlay = function () {
2017-10-26 20:53:11 +00:00
$(this.element).remove(this.$overlay);
};
2017-02-25 19:39:54 +00:00
// Plugin Definition
// =================
function Plugin(option) {
return this.each(function () {
2017-10-26 20:53:11 +00:00
var $this = $(this);
var data = $this.data(DataKey);
2017-02-25 19:39:54 +00:00
if (!data) {
2017-10-26 20:53:11 +00:00
var options = $.extend({}, Default, $this.data(), typeof option == 'object' && option);
$this.data(DataKey, (data = new BoxRefresh($this, options)));
2017-02-25 19:39:54 +00:00
}
2017-07-08 17:45:57 +00:00
if (typeof data == 'string') {
if (typeof data[option] == 'undefined') {
2017-10-26 20:53:11 +00:00
throw new Error('No method named ' + option);
2017-02-25 19:39:54 +00:00
}
2017-10-26 20:53:11 +00:00
data[option]();
2017-02-25 19:39:54 +00:00
}
2017-10-26 20:53:11 +00:00
});
2017-02-25 19:39:54 +00:00
}
2017-10-26 20:53:11 +00:00
var old = $.fn.boxRefresh;
2017-02-25 19:39:54 +00:00
2017-10-26 20:53:11 +00:00
$.fn.boxRefresh = Plugin;
$.fn.boxRefresh.Constructor = BoxRefresh;
2017-02-25 19:39:54 +00:00
2017-07-08 17:45:57 +00:00
// No Conflict Mode
2017-02-25 19:39:54 +00:00
// ================
2017-07-08 17:45:57 +00:00
$.fn.boxRefresh.noConflict = function () {
2017-10-26 20:53:11 +00:00
$.fn.boxRefresh = old;
return this;
};
2017-02-25 19:39:54 +00:00
2017-07-08 17:45:57 +00:00
// BoxRefresh Data API
// =================
2017-02-25 19:39:54 +00:00
$(window).on('load', function () {
2017-07-08 17:45:57 +00:00
$(Selector.data).each(function () {
2017-10-26 20:53:11 +00:00
Plugin.call($(this));
});
});
2017-07-08 17:45:57 +00:00
2017-10-26 20:53:11 +00:00
}(jQuery);
2017-02-25 19:39:54 +00:00
2017-07-08 17:45:57 +00:00
/* BoxWidget()
* ======
* Adds box widget functions to boxes.
2017-02-25 19:39:54 +00:00
*
2017-07-08 17:45:57 +00:00
* @Usage: $('.my-box').boxWidget(options)
* This plugin auto activates on any element using the `.box` class
* Pass any option as data-option="value"
2017-02-25 19:39:54 +00:00
*/
+function ($) {
2017-10-26 20:53:11 +00:00
'use strict';
2017-02-25 19:39:54 +00:00
2017-10-26 20:53:11 +00:00
var DataKey = 'lte.boxwidget';
2017-02-25 19:39:54 +00:00
var Default = {
2017-07-08 17:45:57 +00:00
animationSpeed : 500,
collapseTrigger: '[data-widget="collapse"]',
removeTrigger : '[data-widget="remove"]',
collapseIcon : 'fa-minus',
expandIcon : 'fa-plus',
removeIcon : 'fa-times'
2017-10-26 20:53:11 +00:00
};
2017-02-25 19:39:54 +00:00
var Selector = {
2017-07-08 17:45:57 +00:00
data : '.box',
collapsed: '.collapsed-box',
2017-10-26 20:53:11 +00:00
header : '.box-header',
2017-07-08 17:45:57 +00:00
body : '.box-body',
footer : '.box-footer',
tools : '.box-tools'
2017-10-26 20:53:11 +00:00
};
2017-02-25 19:39:54 +00:00
var ClassName = {
2017-07-08 17:45:57 +00:00
collapsed: 'collapsed-box'
2017-10-26 20:53:11 +00:00
};
2017-02-25 19:39:54 +00:00
var Event = {
2017-07-08 17:45:57 +00:00
collapsed: 'collapsed.boxwidget',
expanded : 'expanded.boxwidget',
removed : 'removed.boxwidget'
2017-10-26 20:53:11 +00:00
};
2017-02-25 19:39:54 +00:00
2017-07-08 17:45:57 +00:00
// BoxWidget Class Definition
// =====================
var BoxWidget = function (element, options) {
2017-10-26 20:53:11 +00:00
this.element = element;
this.options = options;
2017-02-25 19:39:54 +00:00
2017-10-26 20:53:11 +00:00
this._setUpListeners();
};
2017-02-25 19:39:54 +00:00
2017-07-08 17:45:57 +00:00
BoxWidget.prototype.toggle = function () {
2017-10-26 20:53:11 +00:00
var isOpen = !$(this.element).is(Selector.collapsed);
2017-02-25 19:39:54 +00:00
2017-07-08 17:45:57 +00:00
if (isOpen) {
2017-10-26 20:53:11 +00:00
this.collapse();
2017-02-25 19:39:54 +00:00
} else {
2017-10-26 20:53:11 +00:00
this.expand();
2017-02-25 19:39:54 +00:00
}
2017-10-26 20:53:11 +00:00
};
2017-02-25 19:39:54 +00:00
2017-07-08 17:45:57 +00:00
BoxWidget.prototype.expand = function () {
2017-10-26 20:53:11 +00:00
var expandedEvent = $.Event(Event.expanded);
var collapseIcon = this.options.collapseIcon;
var expandIcon = this.options.expandIcon;
2017-02-25 19:39:54 +00:00
2017-10-26 20:53:11 +00:00
$(this.element).removeClass(ClassName.collapsed);
2017-02-25 19:39:54 +00:00
2017-07-08 17:45:57 +00:00
$(this.element)
2017-10-26 20:53:11 +00:00
.children(Selector.header + ', ' + Selector.body + ', ' + Selector.footer)
.children(Selector.tools)
2017-07-08 17:45:57 +00:00
.find('.' + expandIcon)
.removeClass(expandIcon)
2017-10-26 20:53:11 +00:00
.addClass(collapseIcon);
2017-02-25 19:39:54 +00:00
2017-10-26 20:53:11 +00:00
$(this.element).children(Selector.body + ', ' + Selector.footer)
2017-07-08 17:45:57 +00:00
.slideDown(this.options.animationSpeed, function () {
2017-10-26 20:53:11 +00:00
$(this.element).trigger(expandedEvent);
}.bind(this));
};
2017-02-25 19:39:54 +00:00
2017-07-08 17:45:57 +00:00
BoxWidget.prototype.collapse = function () {
2017-10-26 20:53:11 +00:00
var collapsedEvent = $.Event(Event.collapsed);
var collapseIcon = this.options.collapseIcon;
var expandIcon = this.options.expandIcon;
2017-02-25 19:39:54 +00:00
2017-07-08 17:45:57 +00:00
$(this.element)
2017-10-26 20:53:11 +00:00
.children(Selector.header + ', ' + Selector.body + ', ' + Selector.footer)
.children(Selector.tools)
2017-07-08 17:45:57 +00:00
.find('.' + collapseIcon)
.removeClass(collapseIcon)
2017-10-26 20:53:11 +00:00
.addClass(expandIcon);
2017-02-25 19:39:54 +00:00
2017-10-26 20:53:11 +00:00
$(this.element).children(Selector.body + ', ' + Selector.footer)
2017-07-08 17:45:57 +00:00
.slideUp(this.options.animationSpeed, function () {
2017-10-26 20:53:11 +00:00
$(this.element).addClass(ClassName.collapsed);
$(this.element).trigger(collapsedEvent);
}.bind(this));
};
2017-02-25 19:39:54 +00:00
2017-07-08 17:45:57 +00:00
BoxWidget.prototype.remove = function () {
2017-10-26 20:53:11 +00:00
var removedEvent = $.Event(Event.removed);
2017-02-25 19:39:54 +00:00
2017-07-08 17:45:57 +00:00
$(this.element).slideUp(this.options.animationSpeed, function () {
2017-10-26 20:53:11 +00:00
$(this.element).trigger(removedEvent);
$(this.element).remove();
}.bind(this));
};
2017-02-25 19:39:54 +00:00
// Private
2017-07-08 17:45:57 +00:00
BoxWidget.prototype._setUpListeners = function () {
2017-10-26 20:53:11 +00:00
var that = this;
2017-02-25 19:39:54 +00:00
2017-07-08 17:45:57 +00:00
$(this.element).on('click', this.options.collapseTrigger, function (event) {
2017-10-26 20:53:11 +00:00
if (event) event.preventDefault();
that.toggle($(this));
return false;
});
2017-07-08 17:45:57 +00:00
$(this.element).on('click', this.options.removeTrigger, function (event) {
2017-10-26 20:53:11 +00:00
if (event) event.preventDefault();
that.remove($(this));
return false;
});
};
2017-02-25 19:39:54 +00:00
// Plugin Definition
// =================
function Plugin(option) {
return this.each(function () {
2017-10-26 20:53:11 +00:00
var $this = $(this);
var data = $this.data(DataKey);
2017-02-25 19:39:54 +00:00
if (!data) {
2017-10-26 20:53:11 +00:00
var options = $.extend({}, Default, $this.data(), typeof option == 'object' && option);
$this.data(DataKey, (data = new BoxWidget($this, options)));
2017-07-08 17:45:57 +00:00
}
if (typeof option == 'string') {
if (typeof data[option] == 'undefined') {
2017-10-26 20:53:11 +00:00
throw new Error('No method named ' + option);
2017-07-08 17:45:57 +00:00
}
2017-10-26 20:53:11 +00:00
data[option]();
2017-02-25 19:39:54 +00:00
}
2017-10-26 20:53:11 +00:00
});
2017-02-25 19:39:54 +00:00
}
2017-10-26 20:53:11 +00:00
var old = $.fn.boxWidget;
2017-02-25 19:39:54 +00:00
2017-10-26 20:53:11 +00:00
$.fn.boxWidget = Plugin;
$.fn.boxWidget.Constructor = BoxWidget;
2017-02-25 19:39:54 +00:00
// No Conflict Mode
// ================
2017-07-08 17:45:57 +00:00
$.fn.boxWidget.noConflict = function () {
2017-10-26 20:53:11 +00:00
$.fn.boxWidget = old;
return this;
};
2017-02-25 19:39:54 +00:00
2017-07-08 17:45:57 +00:00
// BoxWidget Data API
// ==================
2017-02-25 19:39:54 +00:00
$(window).on('load', function () {
$(Selector.data).each(function () {
2017-10-26 20:53:11 +00:00
Plugin.call($(this));
});
});
}(jQuery);
2017-02-25 19:39:54 +00:00
/* ControlSidebar()
* ===============
* Toggles the state of the control sidebar
*
* @Usage: $('#control-sidebar-trigger').controlSidebar(options)
* or add [data-toggle="control-sidebar"] to the trigger
* Pass any option as data-option="value"
*/
+function ($) {
2017-10-26 20:53:11 +00:00
'use strict';
2017-02-25 19:39:54 +00:00
2017-10-26 20:53:11 +00:00
var DataKey = 'lte.controlsidebar';
2017-02-25 19:39:54 +00:00
var Default = {
slide: true
2017-10-26 20:53:11 +00:00
};
2017-02-25 19:39:54 +00:00
var Selector = {
sidebar: '.control-sidebar',
data : '[data-toggle="control-sidebar"]',
open : '.control-sidebar-open',
bg : '.control-sidebar-bg',
wrapper: '.wrapper',
content: '.content-wrapper',
boxed : '.layout-boxed'
2017-10-26 20:53:11 +00:00
};
2017-02-25 19:39:54 +00:00
var ClassName = {
open : 'control-sidebar-open',
fixed: 'fixed'
2017-10-26 20:53:11 +00:00
};
2017-02-25 19:39:54 +00:00
var Event = {
collapsed: 'collapsed.controlsidebar',
expanded : 'expanded.controlsidebar'
2017-10-26 20:53:11 +00:00
};
2017-02-25 19:39:54 +00:00
// ControlSidebar Class Definition
// ===============================
var ControlSidebar = function (element, options) {
2017-10-26 20:53:11 +00:00
this.element = element;
this.options = options;
this.hasBindedResize = false;
2017-02-25 19:39:54 +00:00
2017-10-26 20:53:11 +00:00
this.init();
};
2017-02-25 19:39:54 +00:00
ControlSidebar.prototype.init = function () {
// Add click listener if the element hasn't been
// initialized using the data API
if (!$(this.element).is(Selector.data)) {
2017-10-26 20:53:11 +00:00
$(this).on('click', this.toggle);
2017-02-25 19:39:54 +00:00
}
2017-10-26 20:53:11 +00:00
this.fix();
2017-02-25 19:39:54 +00:00
$(window).resize(function () {
2017-10-26 20:53:11 +00:00
this.fix();
}.bind(this));
};
2017-02-25 19:39:54 +00:00
ControlSidebar.prototype.toggle = function (event) {
2017-10-26 20:53:11 +00:00
if (event) event.preventDefault();
2017-02-25 19:39:54 +00:00
2017-10-26 20:53:11 +00:00
this.fix();
2017-02-25 19:39:54 +00:00
if (!$(Selector.sidebar).is(Selector.open) && !$('body').is(Selector.open)) {
2017-10-26 20:53:11 +00:00
this.expand();
2017-02-25 19:39:54 +00:00
} else {
2017-10-26 20:53:11 +00:00
this.collapse();
2017-02-25 19:39:54 +00:00
}
2017-10-26 20:53:11 +00:00
};
2017-02-25 19:39:54 +00:00
ControlSidebar.prototype.expand = function () {
if (!this.options.slide) {
2017-10-26 20:53:11 +00:00
$('body').addClass(ClassName.open);
2017-02-25 19:39:54 +00:00
} else {
2017-10-26 20:53:11 +00:00
$(Selector.sidebar).addClass(ClassName.open);
2017-02-25 19:39:54 +00:00
}
2017-10-26 20:53:11 +00:00
$(this.element).trigger($.Event(Event.expanded));
};
2017-02-25 19:39:54 +00:00
ControlSidebar.prototype.collapse = function () {
2017-10-26 20:53:11 +00:00
$('body, ' + Selector.sidebar).removeClass(ClassName.open);
$(this.element).trigger($.Event(Event.collapsed));
};
2017-02-25 19:39:54 +00:00
ControlSidebar.prototype.fix = function () {
if ($('body').is(Selector.boxed)) {
2017-10-26 20:53:11 +00:00
this._fixForBoxed($(Selector.bg));
2017-02-25 19:39:54 +00:00
}
2017-10-26 20:53:11 +00:00
};
2017-02-25 19:39:54 +00:00
// Private
ControlSidebar.prototype._fixForBoxed = function (bg) {
bg.css({
position: 'absolute',
height : $(Selector.wrapper).height()
2017-10-26 20:53:11 +00:00
});
};
2017-02-25 19:39:54 +00:00
// Plugin Definition
// =================
function Plugin(option) {
return this.each(function () {
2017-10-26 20:53:11 +00:00
var $this = $(this);
var data = $this.data(DataKey);
2017-02-25 19:39:54 +00:00
if (!data) {
2017-10-26 20:53:11 +00:00
var options = $.extend({}, Default, $this.data(), typeof option == 'object' && option);
$this.data(DataKey, (data = new ControlSidebar($this, options)));
2017-02-25 19:39:54 +00:00
}
2017-10-26 20:53:11 +00:00
if (typeof option == 'string') data.toggle();
});
2017-02-25 19:39:54 +00:00
}
2017-10-26 20:53:11 +00:00
var old = $.fn.controlSidebar;
2017-02-25 19:39:54 +00:00
2017-10-26 20:53:11 +00:00
$.fn.controlSidebar = Plugin;
$.fn.controlSidebar.Constructor = ControlSidebar;
2017-02-25 19:39:54 +00:00
// No Conflict Mode
// ================
$.fn.controlSidebar.noConflict = function () {
2017-10-26 20:53:11 +00:00
$.fn.controlSidebar = old;
return this;
};
2017-02-25 19:39:54 +00:00
// ControlSidebar Data API
// =======================
$(document).on('click', Selector.data, function (event) {
2017-10-26 20:53:11 +00:00
if (event) event.preventDefault();
Plugin.call($(this), 'toggle');
});
2017-02-25 19:39:54 +00:00
2017-10-26 20:53:11 +00:00
}(jQuery);
2017-02-25 19:39:54 +00:00
2017-07-08 17:45:57 +00:00
/* DirectChat()
* ===============
* Toggles the state of the control sidebar
2017-02-25 19:39:54 +00:00
*
2017-07-08 17:45:57 +00:00
* @Usage: $('#my-chat-box').directChat()
* or add [data-widget="direct-chat"] to the trigger
2017-02-25 19:39:54 +00:00
*/
+function ($) {
2017-10-26 20:53:11 +00:00
'use strict';
2017-02-25 19:39:54 +00:00
2017-10-26 20:53:11 +00:00
var DataKey = 'lte.directchat';
2017-02-25 19:39:54 +00:00
2017-07-08 17:45:57 +00:00
var Selector = {
data: '[data-widget="chat-pane-toggle"]',
box : '.direct-chat'
2017-10-26 20:53:11 +00:00
};
2017-02-25 19:39:54 +00:00
2017-07-08 17:45:57 +00:00
var ClassName = {
open: 'direct-chat-contacts-open'
2017-10-26 20:53:11 +00:00
};
2017-07-08 17:45:57 +00:00
// DirectChat Class Definition
// ===========================
var DirectChat = function (element) {
2017-10-26 20:53:11 +00:00
this.element = element;
};
2017-07-08 17:45:57 +00:00
DirectChat.prototype.toggle = function ($trigger) {
2017-10-26 20:53:11 +00:00
$trigger.parents(Selector.box).first().toggleClass(ClassName.open);
};
2017-07-08 17:45:57 +00:00
// Plugin Definition
// =================
function Plugin(option) {
return this.each(function () {
2017-10-26 20:53:11 +00:00
var $this = $(this);
var data = $this.data(DataKey);
2017-07-08 17:45:57 +00:00
if (!data) {
2017-10-26 20:53:11 +00:00
$this.data(DataKey, (data = new DirectChat($this)));
2017-07-08 17:45:57 +00:00
}
2017-10-26 20:53:11 +00:00
if (typeof option == 'string') data.toggle($this);
});
2017-07-08 17:45:57 +00:00
}
2017-10-26 20:53:11 +00:00
var old = $.fn.directChat;
2017-07-08 17:45:57 +00:00
2017-10-26 20:53:11 +00:00
$.fn.directChat = Plugin;
$.fn.directChat.Constructor = DirectChat;
2017-07-08 17:45:57 +00:00
// No Conflict Mode
// ================
$.fn.directChat.noConflict = function () {
2017-10-26 20:53:11 +00:00
$.fn.directChat = old;
return this;
};
2017-07-08 17:45:57 +00:00
// DirectChat Data API
// ===================
$(document).on('click', Selector.data, function (event) {
2017-10-26 20:53:11 +00:00
if (event) event.preventDefault();
Plugin.call($(this), 'toggle');
});
2017-07-08 17:45:57 +00:00
2017-10-26 20:53:11 +00:00
}(jQuery);
2017-07-08 17:45:57 +00:00
/* Layout()
* ========
* Implements AdminLTE layout.
* Fixes the layout height in case min-height fails.
*
* @usage activated automatically upon window load.
* Configure any options by passing data-option="value"
* to the body tag.
*/
+function ($) {
2017-10-26 20:53:11 +00:00
'use strict';
2017-07-08 17:45:57 +00:00
2017-10-26 20:53:11 +00:00
var DataKey = 'lte.layout';
2017-07-08 17:45:57 +00:00
var Default = {
slimscroll : true,
resetHeight: true
2017-10-26 20:53:11 +00:00
};
2017-07-08 17:45:57 +00:00
var Selector = {
wrapper : '.wrapper',
contentWrapper: '.content-wrapper',
layoutBoxed : '.layout-boxed',
mainFooter : '.main-footer',
mainHeader : '.main-header',
sidebar : '.sidebar',
controlSidebar: '.control-sidebar',
fixed : '.fixed',
sidebarMenu : '.sidebar-menu',
logo : '.main-header .logo'
2017-10-26 20:53:11 +00:00
};
2017-02-25 19:39:54 +00:00
var ClassName = {
2017-07-08 17:45:57 +00:00
fixed : 'fixed',
holdTransition: 'hold-transition'
2017-10-26 20:53:11 +00:00
};
2017-02-25 19:39:54 +00:00
2017-07-08 17:45:57 +00:00
var Layout = function (options) {
2017-10-26 20:53:11 +00:00
this.options = options;
this.bindedResize = false;
this.activate();
};
2017-02-25 19:39:54 +00:00
2017-07-08 17:45:57 +00:00
Layout.prototype.activate = function () {
2017-10-26 20:53:11 +00:00
this.fix();
this.fixSidebar();
2017-02-25 19:39:54 +00:00
2017-10-26 20:53:11 +00:00
$('body').removeClass(ClassName.holdTransition);
2017-07-08 17:45:57 +00:00
if (this.options.resetHeight) {
$('body, html, ' + Selector.wrapper).css({
'height' : 'auto',
'min-height': '100%'
2017-10-26 20:53:11 +00:00
});
2017-07-08 17:45:57 +00:00
}
if (!this.bindedResize) {
$(window).resize(function () {
2017-10-26 20:53:11 +00:00
this.fix();
this.fixSidebar();
2017-07-08 17:45:57 +00:00
$(Selector.logo + ', ' + Selector.sidebar).one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function () {
2017-10-26 20:53:11 +00:00
this.fix();
this.fixSidebar();
}.bind(this));
}.bind(this));
2017-07-08 17:45:57 +00:00
2017-10-26 20:53:11 +00:00
this.bindedResize = true;
2017-07-08 17:45:57 +00:00
}
$(Selector.sidebarMenu).on('expanded.tree', function () {
2017-10-26 20:53:11 +00:00
this.fix();
this.fixSidebar();
}.bind(this));
2017-07-08 17:45:57 +00:00
$(Selector.sidebarMenu).on('collapsed.tree', function () {
2017-10-26 20:53:11 +00:00
this.fix();
this.fixSidebar();
}.bind(this));
};
2017-02-25 19:39:54 +00:00
2017-07-08 17:45:57 +00:00
Layout.prototype.fix = function () {
// Remove overflow from .wrapper if layout-boxed exists
2017-10-26 20:53:11 +00:00
$(Selector.layoutBoxed + ' > ' + Selector.wrapper).css('overflow', 'hidden');
2017-02-25 19:39:54 +00:00
2017-07-08 17:45:57 +00:00
// Get window height and the wrapper height
2018-07-14 21:40:00 +00:00
var footerHeight = $(Selector.mainFooter).outerHeight() || 0;
var headerHeight = $(Selector.mainHeader).outerHeight() || 0;
var neg = headerHeight + footerHeight;
2017-10-26 20:53:11 +00:00
var windowHeight = $(window).height();
var sidebarHeight = $(Selector.sidebar).height() || 0;
2017-07-08 17:45:57 +00:00
// Set the min-height of the content and sidebar based on
// the height of the document.
if ($('body').hasClass(ClassName.fixed)) {
2017-10-26 20:53:11 +00:00
$(Selector.contentWrapper).css('min-height', windowHeight - footerHeight);
2017-02-25 19:39:54 +00:00
} else {
2017-10-26 20:53:11 +00:00
var postSetHeight;
2017-07-08 17:45:57 +00:00
if (windowHeight >= sidebarHeight + headerHeight) {
2017-10-26 20:53:11 +00:00
$(Selector.contentWrapper).css('min-height', windowHeight - neg);
postSetHeight = windowHeight - neg;
2017-07-08 17:45:57 +00:00
} else {
2017-10-26 20:53:11 +00:00
$(Selector.contentWrapper).css('min-height', sidebarHeight);
postSetHeight = sidebarHeight;
2017-07-08 17:45:57 +00:00
}
// Fix for the control sidebar height
2017-10-26 20:53:11 +00:00
var $controlSidebar = $(Selector.controlSidebar);
2017-07-08 17:45:57 +00:00
if (typeof $controlSidebar !== 'undefined') {
if ($controlSidebar.height() > postSetHeight)
2017-10-26 20:53:11 +00:00
$(Selector.contentWrapper).css('min-height', $controlSidebar.height());
2017-07-08 17:45:57 +00:00
}
2017-02-25 19:39:54 +00:00
}
2017-10-26 20:53:11 +00:00
};
2017-02-25 19:39:54 +00:00
2017-07-08 17:45:57 +00:00
Layout.prototype.fixSidebar = function () {
// Make sure the body tag has the .fixed class
if (!$('body').hasClass(ClassName.fixed)) {
if (typeof $.fn.slimScroll !== 'undefined') {
2017-10-26 20:53:11 +00:00
$(Selector.sidebar).slimScroll({ destroy: true }).height('auto');
2017-07-08 17:45:57 +00:00
}
2017-10-26 20:53:11 +00:00
return;
2017-07-08 17:45:57 +00:00
}
2017-02-25 19:39:54 +00:00
2017-07-08 17:45:57 +00:00
// Enable slimscroll for fixed layout
if (this.options.slimscroll) {
if (typeof $.fn.slimScroll !== 'undefined') {
// Destroy if it exists
// $(Selector.sidebar).slimScroll({ destroy: true }).height('auto')
2017-02-25 19:39:54 +00:00
2017-07-08 17:45:57 +00:00
// Add slimscroll
$(Selector.sidebar).slimScroll({
2017-10-26 20:53:11 +00:00
height: ($(window).height() - $(Selector.mainHeader).height()) + 'px'
});
2017-07-08 17:45:57 +00:00
}
}
2017-10-26 20:53:11 +00:00
};
2017-02-25 19:39:54 +00:00
2017-07-08 17:45:57 +00:00
// Plugin Definition
// =================
function Plugin(option) {
return this.each(function () {
2017-10-26 20:53:11 +00:00
var $this = $(this);
var data = $this.data(DataKey);
2017-07-08 17:45:57 +00:00
if (!data) {
2017-10-26 20:53:11 +00:00
var options = $.extend({}, Default, $this.data(), typeof option === 'object' && option);
$this.data(DataKey, (data = new Layout(options)));
2017-07-08 17:45:57 +00:00
}
if (typeof option === 'string') {
if (typeof data[option] === 'undefined') {
2017-10-26 20:53:11 +00:00
throw new Error('No method named ' + option);
2017-07-08 17:45:57 +00:00
}
2017-10-26 20:53:11 +00:00
data[option]();
2017-07-08 17:45:57 +00:00
}
2017-10-26 20:53:11 +00:00
});
2017-07-08 17:45:57 +00:00
}
2017-10-26 20:53:11 +00:00
var old = $.fn.layout;
2017-07-08 17:45:57 +00:00
2017-10-26 20:53:11 +00:00
$.fn.layout = Plugin;
$.fn.layout.Constuctor = Layout;
2017-07-08 17:45:57 +00:00
// No conflict mode
// ================
$.fn.layout.noConflict = function () {
2017-10-26 20:53:11 +00:00
$.fn.layout = old;
return this;
};
2017-07-08 17:45:57 +00:00
// Layout DATA-API
// ===============
$(window).on('load', function () {
2017-10-26 20:53:11 +00:00
Plugin.call($('body'));
});
}(jQuery);
2017-07-08 17:45:57 +00:00
/* PushMenu()
* ==========
* Adds the push menu functionality to the sidebar.
*
* @usage: $('.btn').pushMenu(options)
* or add [data-toggle="push-menu"] to any button
* Pass any option as data-option="value"
*/
+function ($) {
2017-10-26 20:53:11 +00:00
'use strict';
2017-07-08 17:45:57 +00:00
2017-10-26 20:53:11 +00:00
var DataKey = 'lte.pushmenu';
2017-07-08 17:45:57 +00:00
var Default = {
collapseScreenSize : 767,
expandOnHover : false,
expandTransitionDelay: 200
2017-10-26 20:53:11 +00:00
};
2017-07-08 17:45:57 +00:00
var Selector = {
collapsed : '.sidebar-collapse',
open : '.sidebar-open',
mainSidebar : '.main-sidebar',
contentWrapper: '.content-wrapper',
searchInput : '.sidebar-form .form-control',
button : '[data-toggle="push-menu"]',
mini : '.sidebar-mini',
expanded : '.sidebar-expanded-on-hover',
layoutFixed : '.fixed'
2017-10-26 20:53:11 +00:00
};
2017-07-08 17:45:57 +00:00
var ClassName = {
collapsed : 'sidebar-collapse',
open : 'sidebar-open',
mini : 'sidebar-mini',
expanded : 'sidebar-expanded-on-hover',
expandFeature: 'sidebar-mini-expand-feature',
layoutFixed : 'fixed'
2017-10-26 20:53:11 +00:00
};
2017-07-08 17:45:57 +00:00
var Event = {
expanded : 'expanded.pushMenu',
collapsed: 'collapsed.pushMenu'
2017-10-26 20:53:11 +00:00
};
2017-07-08 17:45:57 +00:00
// PushMenu Class Definition
// =========================
var PushMenu = function (options) {
2017-10-26 20:53:11 +00:00
this.options = options;
this.init();
};
2017-07-08 17:45:57 +00:00
PushMenu.prototype.init = function () {
if (this.options.expandOnHover
|| ($('body').is(Selector.mini + Selector.layoutFixed))) {
2017-10-26 20:53:11 +00:00
this.expandOnHover();
$('body').addClass(ClassName.expandFeature);
2017-07-08 17:45:57 +00:00
}
$(Selector.contentWrapper).click(function () {
// Enable hide menu when clicking on the content-wrapper on small screens
if ($(window).width() <= this.options.collapseScreenSize && $('body').hasClass(ClassName.open)) {
2017-10-26 20:53:11 +00:00
this.close();
2017-07-08 17:45:57 +00:00
}
2017-10-26 20:53:11 +00:00
}.bind(this));
2017-07-08 17:45:57 +00:00
// __Fix for android devices
$(Selector.searchInput).click(function (e) {
2017-10-26 20:53:11 +00:00
e.stopPropagation();
});
};
2017-02-25 19:39:54 +00:00
2017-07-08 17:45:57 +00:00
PushMenu.prototype.toggle = function () {
2017-10-26 20:53:11 +00:00
var windowWidth = $(window).width();
var isOpen = !$('body').hasClass(ClassName.collapsed);
2017-02-25 19:39:54 +00:00
2017-07-08 17:45:57 +00:00
if (windowWidth <= this.options.collapseScreenSize) {
2017-10-26 20:53:11 +00:00
isOpen = $('body').hasClass(ClassName.open);
2017-07-08 17:45:57 +00:00
}
2017-02-25 19:39:54 +00:00
2017-07-08 17:45:57 +00:00
if (!isOpen) {
2017-10-26 20:53:11 +00:00
this.open();
2017-07-08 17:45:57 +00:00
} else {
2017-10-26 20:53:11 +00:00
this.close();
2017-07-08 17:45:57 +00:00
}
2017-10-26 20:53:11 +00:00
};
2017-02-25 19:39:54 +00:00
2017-07-08 17:45:57 +00:00
PushMenu.prototype.open = function () {
2017-10-26 20:53:11 +00:00
var windowWidth = $(window).width();
2017-02-25 19:39:54 +00:00
2017-07-08 17:45:57 +00:00
if (windowWidth > this.options.collapseScreenSize) {
$('body').removeClass(ClassName.collapsed)
2017-10-26 20:53:11 +00:00
.trigger($.Event(Event.expanded));
2017-07-08 17:45:57 +00:00
}
else {
$('body').addClass(ClassName.open)
2017-10-26 20:53:11 +00:00
.trigger($.Event(Event.expanded));
2017-07-08 17:45:57 +00:00
}
2017-10-26 20:53:11 +00:00
};
2017-02-25 19:39:54 +00:00
2017-07-08 17:45:57 +00:00
PushMenu.prototype.close = function () {
2017-10-26 20:53:11 +00:00
var windowWidth = $(window).width();
2017-07-08 17:45:57 +00:00
if (windowWidth > this.options.collapseScreenSize) {
$('body').addClass(ClassName.collapsed)
2017-10-26 20:53:11 +00:00
.trigger($.Event(Event.collapsed));
2017-07-08 17:45:57 +00:00
} else {
$('body').removeClass(ClassName.open + ' ' + ClassName.collapsed)
2017-10-26 20:53:11 +00:00
.trigger($.Event(Event.collapsed));
2017-07-08 17:45:57 +00:00
}
2017-10-26 20:53:11 +00:00
};
2017-02-25 19:39:54 +00:00
2017-07-08 17:45:57 +00:00
PushMenu.prototype.expandOnHover = function () {
$(Selector.mainSidebar).hover(function () {
if ($('body').is(Selector.mini + Selector.collapsed)
&& $(window).width() > this.options.collapseScreenSize) {
2017-10-26 20:53:11 +00:00
this.expand();
2017-07-08 17:45:57 +00:00
}
}.bind(this), function () {
if ($('body').is(Selector.expanded)) {
2017-10-26 20:53:11 +00:00
this.collapse();
2017-07-08 17:45:57 +00:00
}
2017-10-26 20:53:11 +00:00
}.bind(this));
};
2017-02-25 19:39:54 +00:00
2017-07-08 17:45:57 +00:00
PushMenu.prototype.expand = function () {
setTimeout(function () {
$('body').removeClass(ClassName.collapsed)
2017-10-26 20:53:11 +00:00
.addClass(ClassName.expanded);
}, this.options.expandTransitionDelay);
};
2017-02-25 19:39:54 +00:00
2017-07-08 17:45:57 +00:00
PushMenu.prototype.collapse = function () {
setTimeout(function () {
$('body').removeClass(ClassName.expanded)
2017-10-26 20:53:11 +00:00
.addClass(ClassName.collapsed);
}, this.options.expandTransitionDelay);
};
2017-02-25 19:39:54 +00:00
2017-07-08 17:45:57 +00:00
// PushMenu Plugin Definition
// ==========================
2017-02-25 19:39:54 +00:00
function Plugin(option) {
return this.each(function () {
2017-10-26 20:53:11 +00:00
var $this = $(this);
var data = $this.data(DataKey);
2017-02-25 19:39:54 +00:00
if (!data) {
2017-10-26 20:53:11 +00:00
var options = $.extend({}, Default, $this.data(), typeof option == 'object' && option);
$this.data(DataKey, (data = new PushMenu(options)));
2017-02-25 19:39:54 +00:00
}
2017-10-26 20:53:11 +00:00
if (option === 'toggle') data.toggle();
});
2017-02-25 19:39:54 +00:00
}
2017-10-26 20:53:11 +00:00
var old = $.fn.pushMenu;
2017-02-25 19:39:54 +00:00
2017-10-26 20:53:11 +00:00
$.fn.pushMenu = Plugin;
$.fn.pushMenu.Constructor = PushMenu;
2017-02-25 19:39:54 +00:00
// No Conflict Mode
// ================
2017-07-08 17:45:57 +00:00
$.fn.pushMenu.noConflict = function () {
2017-10-26 20:53:11 +00:00
$.fn.pushMenu = old;
return this;
};
2017-02-25 19:39:54 +00:00
2017-07-08 17:45:57 +00:00
// Data API
// ========
$(document).on('click', Selector.button, function (e) {
2017-10-26 20:53:11 +00:00
e.preventDefault();
Plugin.call($(this), 'toggle');
});
2017-02-25 19:39:54 +00:00
$(window).on('load', function () {
2017-10-26 20:53:11 +00:00
Plugin.call($(Selector.button));
});
}(jQuery);
2017-02-25 19:39:54 +00:00
/* TodoList()
* =========
* Converts a list into a todoList.
*
* @Usage: $('.my-list').todoList(options)
* or add [data-widget="todo-list"] to the ul element
* Pass any option as data-option="value"
*/
+function ($) {
2017-10-26 20:53:11 +00:00
'use strict';
2017-02-25 19:39:54 +00:00
2017-10-26 20:53:11 +00:00
var DataKey = 'lte.todolist';
2017-02-25 19:39:54 +00:00
var Default = {
2017-07-08 17:45:57 +00:00
onCheck : function (item) {
2017-10-26 20:53:11 +00:00
return item;
2017-02-25 19:39:54 +00:00
},
2017-07-08 17:45:57 +00:00
onUnCheck: function (item) {
2017-10-26 20:53:11 +00:00
return item;
2017-02-25 19:39:54 +00:00
}
2017-10-26 20:53:11 +00:00
};
2017-02-25 19:39:54 +00:00
var Selector = {
data: '[data-widget="todo-list"]'
2017-10-26 20:53:11 +00:00
};
2017-02-25 19:39:54 +00:00
var ClassName = {
done: 'done'
2017-10-26 20:53:11 +00:00
};
2017-02-25 19:39:54 +00:00
// TodoList Class Definition
// =========================
var TodoList = function (element, options) {
2017-10-26 20:53:11 +00:00
this.element = element;
this.options = options;
2017-02-25 19:39:54 +00:00
2017-10-26 20:53:11 +00:00
this._setUpListeners();
};
2017-02-25 19:39:54 +00:00
TodoList.prototype.toggle = function (item) {
2017-10-26 20:53:11 +00:00
item.parents(Selector.li).first().toggleClass(ClassName.done);
2017-02-25 19:39:54 +00:00
if (!item.prop('checked')) {
2017-10-26 20:53:11 +00:00
this.unCheck(item);
return;
2017-02-25 19:39:54 +00:00
}
2017-10-26 20:53:11 +00:00
this.check(item);
};
2017-02-25 19:39:54 +00:00
TodoList.prototype.check = function (item) {
2017-10-26 20:53:11 +00:00
this.options.onCheck.call(item);
};
2017-02-25 19:39:54 +00:00
TodoList.prototype.unCheck = function (item) {
2017-10-26 20:53:11 +00:00
this.options.onUnCheck.call(item);
};
2017-02-25 19:39:54 +00:00
// Private
TodoList.prototype._setUpListeners = function () {
2017-10-26 20:53:11 +00:00
var that = this;
2017-02-25 19:39:54 +00:00
$(this.element).on('change ifChanged', 'input:checkbox', function () {
2017-10-26 20:53:11 +00:00
that.toggle($(this));
});
};
2017-02-25 19:39:54 +00:00
// Plugin Definition
// =================
function Plugin(option) {
return this.each(function () {
2017-10-26 20:53:11 +00:00
var $this = $(this);
var data = $this.data(DataKey);
2017-02-25 19:39:54 +00:00
if (!data) {
2017-10-26 20:53:11 +00:00
var options = $.extend({}, Default, $this.data(), typeof option == 'object' && option);
$this.data(DataKey, (data = new TodoList($this, options)));
2017-02-25 19:39:54 +00:00
}
if (typeof data == 'string') {
if (typeof data[option] == 'undefined') {
2017-10-26 20:53:11 +00:00
throw new Error('No method named ' + option);
2017-02-25 19:39:54 +00:00
}
2017-10-26 20:53:11 +00:00
data[option]();
2017-02-25 19:39:54 +00:00
}
2017-10-26 20:53:11 +00:00
});
2017-02-25 19:39:54 +00:00
}
2017-10-26 20:53:11 +00:00
var old = $.fn.todoList;
2017-02-25 19:39:54 +00:00
2017-10-26 20:53:11 +00:00
$.fn.todoList = Plugin;
$.fn.todoList.Constructor = TodoList;
2017-02-25 19:39:54 +00:00
// No Conflict Mode
// ================
$.fn.todoList.noConflict = function () {
2017-10-26 20:53:11 +00:00
$.fn.todoList = old;
return this;
};
2017-02-25 19:39:54 +00:00
// TodoList Data API
// =================
$(window).on('load', function () {
$(Selector.data).each(function () {
2017-10-26 20:53:11 +00:00
Plugin.call($(this));
});
});
2017-02-25 19:39:54 +00:00
2017-10-26 20:53:11 +00:00
}(jQuery);
2017-03-04 17:13:04 +00:00
2017-07-08 17:45:57 +00:00
/* Tree()
* ======
* Converts a nested list into a multilevel
* tree view menu.
2017-03-04 17:13:04 +00:00
*
2017-07-08 17:45:57 +00:00
* @Usage: $('.my-menu').tree(options)
* or add [data-widget="tree"] to the ul element
* Pass any option as data-option="value"
2017-03-04 17:13:04 +00:00
*/
+function ($) {
2017-10-26 20:53:11 +00:00
'use strict';
2017-03-04 17:13:04 +00:00
2017-10-26 20:53:11 +00:00
var DataKey = 'lte.tree';
2017-07-08 17:45:57 +00:00
var Default = {
animationSpeed: 500,
accordion : true,
followLink : false,
trigger : '.treeview a'
2017-10-26 20:53:11 +00:00
};
2017-03-04 17:13:04 +00:00
var Selector = {
2017-07-08 17:45:57 +00:00
tree : '.tree',
treeview : '.treeview',
treeviewMenu: '.treeview-menu',
open : '.menu-open, .active',
li : 'li',
data : '[data-widget="tree"]',
active : '.active'
2017-10-26 20:53:11 +00:00
};
2017-03-04 17:13:04 +00:00
var ClassName = {
2017-07-08 17:45:57 +00:00
open: 'menu-open',
tree: 'tree'
2017-10-26 20:53:11 +00:00
};
2017-03-04 17:13:04 +00:00
2017-07-08 17:45:57 +00:00
var Event = {
collapsed: 'collapsed.tree',
expanded : 'expanded.tree'
2017-10-26 20:53:11 +00:00
};
2017-07-08 17:45:57 +00:00
// Tree Class Definition
// =====================
var Tree = function (element, options) {
2017-10-26 20:53:11 +00:00
this.element = element;
this.options = options;
2017-07-08 17:45:57 +00:00
2017-10-26 20:53:11 +00:00
$(this.element).addClass(ClassName.tree);
2017-07-08 17:45:57 +00:00
2017-10-26 20:53:11 +00:00
$(Selector.treeview + Selector.active, this.element).addClass(ClassName.open);
2017-07-08 17:45:57 +00:00
2017-10-26 20:53:11 +00:00
this._setUpListeners();
};
2017-03-04 17:13:04 +00:00
2017-07-08 17:45:57 +00:00
Tree.prototype.toggle = function (link, event) {
2017-10-26 20:53:11 +00:00
var treeviewMenu = link.next(Selector.treeviewMenu);
var parentLi = link.parent();
var isOpen = parentLi.hasClass(ClassName.open);
2017-07-08 17:45:57 +00:00
if (!parentLi.is(Selector.treeview)) {
2017-10-26 20:53:11 +00:00
return;
2017-07-08 17:45:57 +00:00
}
if (!this.options.followLink || link.attr('href') === '#') {
2017-10-26 20:53:11 +00:00
event.preventDefault();
2017-07-08 17:45:57 +00:00
}
if (isOpen) {
2017-10-26 20:53:11 +00:00
this.collapse(treeviewMenu, parentLi);
2017-07-08 17:45:57 +00:00
} else {
2017-10-26 20:53:11 +00:00
this.expand(treeviewMenu, parentLi);
2017-07-08 17:45:57 +00:00
}
2017-10-26 20:53:11 +00:00
};
2017-07-08 17:45:57 +00:00
Tree.prototype.expand = function (tree, parent) {
2017-10-26 20:53:11 +00:00
var expandedEvent = $.Event(Event.expanded);
2017-07-08 17:45:57 +00:00
if (this.options.accordion) {
2017-10-26 20:53:11 +00:00
var openMenuLi = parent.siblings(Selector.open);
var openTree = openMenuLi.children(Selector.treeviewMenu);
this.collapse(openTree, openMenuLi);
2017-07-08 17:45:57 +00:00
}
2017-10-26 20:53:11 +00:00
parent.addClass(ClassName.open);
2017-07-08 17:45:57 +00:00
tree.slideDown(this.options.animationSpeed, function () {
2017-10-26 20:53:11 +00:00
$(this.element).trigger(expandedEvent);
}.bind(this));
};
2017-07-08 17:45:57 +00:00
Tree.prototype.collapse = function (tree, parentLi) {
2017-10-26 20:53:11 +00:00
var collapsedEvent = $.Event(Event.collapsed);
2017-07-08 17:45:57 +00:00
//tree.find(Selector.open).removeClass(ClassName.open);
2017-10-26 20:53:11 +00:00
parentLi.removeClass(ClassName.open);
2017-07-08 17:45:57 +00:00
tree.slideUp(this.options.animationSpeed, function () {
//tree.find(Selector.open + ' > ' + Selector.treeview).slideUp();
2017-10-26 20:53:11 +00:00
$(this.element).trigger(collapsedEvent);
}.bind(this));
};
2017-07-08 17:45:57 +00:00
// Private
2017-07-08 17:45:57 +00:00
Tree.prototype._setUpListeners = function () {
2017-10-26 20:53:11 +00:00
var that = this;
2017-07-08 17:45:57 +00:00
$(this.element).on('click', this.options.trigger, function (event) {
2017-10-26 20:53:11 +00:00
that.toggle($(this), event);
});
};
2017-03-04 17:13:04 +00:00
// Plugin Definition
// =================
function Plugin(option) {
return this.each(function () {
2017-10-26 20:53:11 +00:00
var $this = $(this);
var data = $this.data(DataKey);
2017-03-04 17:13:04 +00:00
if (!data) {
2017-10-26 20:53:11 +00:00
var options = $.extend({}, Default, $this.data(), typeof option == 'object' && option);
$this.data(DataKey, new Tree($this, options));
2017-03-04 17:13:04 +00:00
}
2017-10-26 20:53:11 +00:00
});
2017-03-04 17:13:04 +00:00
}
2017-10-26 20:53:11 +00:00
var old = $.fn.tree;
2017-03-04 17:13:04 +00:00
2017-10-26 20:53:11 +00:00
$.fn.tree = Plugin;
$.fn.tree.Constructor = Tree;
2017-03-04 17:13:04 +00:00
// No Conflict Mode
// ================
2017-07-08 17:45:57 +00:00
$.fn.tree.noConflict = function () {
2017-10-26 20:53:11 +00:00
$.fn.tree = old;
return this;
};
2017-03-04 17:13:04 +00:00
2017-07-08 17:45:57 +00:00
// Tree Data API
// =============
$(window).on('load', function () {
$(Selector.data).each(function () {
2017-10-26 20:53:11 +00:00
Plugin.call($(this));
});
});
2017-03-04 17:13:04 +00:00
2017-10-26 20:53:11 +00:00
}(jQuery);