mirror of https://github.com/ColorlibHQ/AdminLTE
fix(plugins): reworked jQueryInterface's for all plugins
parent
fe9461033d
commit
75deb497b3
|
@ -114,21 +114,25 @@ class CardRefresh {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Static
|
// Static
|
||||||
|
|
||||||
static _jQueryInterface(config) {
|
static _jQueryInterface(config) {
|
||||||
let data = $(this).data(DATA_KEY)
|
return this.each(function () {
|
||||||
const _options = $.extend({}, Default, $(this).data())
|
let data = $(this).data(DATA_KEY)
|
||||||
|
const _config = $.extend({}, Default, typeof config === 'object' ? config : $(this).data())
|
||||||
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
data = new CardRefresh($(this), _options)
|
data = new CardRefresh($(this), _config)
|
||||||
$(this).data(DATA_KEY, typeof config === 'string' ? data : config)
|
$(this).data(DATA_KEY, data)
|
||||||
}
|
data._init()
|
||||||
|
} else if (typeof config === 'string') {
|
||||||
|
if (typeof data[config] === 'undefined') {
|
||||||
|
throw new TypeError(`No method named "${config}"`)
|
||||||
|
}
|
||||||
|
|
||||||
if (typeof config === 'string' && /load/.test(config)) {
|
data[config]()
|
||||||
data[config]()
|
} else if (typeof config === 'undefined') {
|
||||||
} else {
|
data._init()
|
||||||
data._init($(this))
|
}
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -108,6 +108,7 @@ class CardWidget {
|
||||||
this._parent.css({
|
this._parent.css({
|
||||||
height: this._parent.height(),
|
height: this._parent.height(),
|
||||||
width: this._parent.width(),
|
width: this._parent.width(),
|
||||||
|
position: 'fixed',
|
||||||
transition: 'all .15s'
|
transition: 'all .15s'
|
||||||
}).delay(150).queue(function () {
|
}).delay(150).queue(function () {
|
||||||
const $element = $(this)
|
const $element = $(this)
|
||||||
|
@ -176,13 +177,12 @@ class CardWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Static
|
// Static
|
||||||
|
|
||||||
static _jQueryInterface(config) {
|
static _jQueryInterface(config) {
|
||||||
let data = $(this).data(DATA_KEY)
|
let data = $(this).data(DATA_KEY)
|
||||||
const _options = $.extend({}, Default, $(this).data())
|
const _config = $.extend({}, Default, $(this).data())
|
||||||
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
data = new CardWidget($(this), _options)
|
data = new CardWidget($(this), _config)
|
||||||
$(this).data(DATA_KEY, typeof config === 'string' ? data : config)
|
$(this).data(DATA_KEY, typeof config === 'string' ? data : config)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -286,22 +286,24 @@ class ControlSidebar {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Static
|
// Static
|
||||||
|
static _jQueryInterface(config) {
|
||||||
static _jQueryInterface(operation) {
|
|
||||||
return this.each(function () {
|
return this.each(function () {
|
||||||
let data = $(this).data(DATA_KEY)
|
let data = $(this).data(DATA_KEY)
|
||||||
const _options = $.extend({}, Default, $(this).data())
|
const _config = $.extend({}, Default, typeof config === 'object' ? config : $(this).data())
|
||||||
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
data = new ControlSidebar(this, _options)
|
data = new ControlSidebar($(this), _config)
|
||||||
$(this).data(DATA_KEY, data)
|
$(this).data(DATA_KEY, data)
|
||||||
}
|
data._init()
|
||||||
|
} else if (typeof config === 'string') {
|
||||||
|
if (typeof data[config] === 'undefined') {
|
||||||
|
throw new TypeError(`No method named "${config}"`)
|
||||||
|
}
|
||||||
|
|
||||||
if (data[operation] === 'undefined') {
|
data[config]()
|
||||||
throw new Error(`${operation} is not a function`)
|
} else if (typeof config === 'undefined') {
|
||||||
|
data._init()
|
||||||
}
|
}
|
||||||
|
|
||||||
data[operation]()
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,6 @@ class DirectChat {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Static
|
// Static
|
||||||
|
|
||||||
static _jQueryInterface(config) {
|
static _jQueryInterface(config) {
|
||||||
return this.each(function () {
|
return this.each(function () {
|
||||||
let data = $(this).data(DATA_KEY)
|
let data = $(this).data(DATA_KEY)
|
||||||
|
@ -48,9 +47,15 @@ class DirectChat {
|
||||||
if (!data) {
|
if (!data) {
|
||||||
data = new DirectChat($(this))
|
data = new DirectChat($(this))
|
||||||
$(this).data(DATA_KEY, data)
|
$(this).data(DATA_KEY, data)
|
||||||
}
|
} else if (typeof config === 'string') {
|
||||||
|
if (typeof data[config] === 'undefined') {
|
||||||
|
throw new TypeError(`No method named "${config}"`)
|
||||||
|
}
|
||||||
|
|
||||||
data[config]()
|
data[config]()
|
||||||
|
} else if (typeof config === 'undefined') {
|
||||||
|
data._init()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,18 +89,19 @@ class Dropdown {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Static
|
// Static
|
||||||
|
|
||||||
static _jQueryInterface(config) {
|
static _jQueryInterface(config) {
|
||||||
return this.each(function () {
|
return this.each(function () {
|
||||||
let data = $(this).data(DATA_KEY)
|
let data = $(this).data(DATA_KEY)
|
||||||
const _config = $.extend({}, Default, $(this).data())
|
const _config = $.extend({}, Default, typeof config === 'object' ? config : $(this).data())
|
||||||
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
data = new Dropdown($(this), _config)
|
data = new Dropdown($(this), _config)
|
||||||
$(this).data(DATA_KEY, data)
|
$(this).data(DATA_KEY, data)
|
||||||
}
|
} else if (typeof config === 'string') {
|
||||||
|
if (typeof data[config] === 'undefined') {
|
||||||
|
throw new TypeError(`No method named "${config}"`)
|
||||||
|
}
|
||||||
|
|
||||||
if (config === 'toggleSubmenu' || config === 'fixPosition') {
|
|
||||||
data[config]()
|
data[config]()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -30,14 +30,13 @@ const SELECTOR_ARIA_ATTR = 'aria-expanded'
|
||||||
* ====================================================
|
* ====================================================
|
||||||
*/
|
*/
|
||||||
class ExpandableTable {
|
class ExpandableTable {
|
||||||
constructor(element, options) {
|
constructor(element) {
|
||||||
this._options = options
|
|
||||||
this._element = element
|
this._element = element
|
||||||
}
|
}
|
||||||
|
|
||||||
// Public
|
// Public
|
||||||
|
|
||||||
init() {
|
_init() {
|
||||||
$(SELECTOR_DATA_TOGGLE).each((_, $header) => {
|
$(SELECTOR_DATA_TOGGLE).each((_, $header) => {
|
||||||
const $type = $($header).attr(SELECTOR_ARIA_ATTR)
|
const $type = $($header).attr(SELECTOR_ARIA_ATTR)
|
||||||
const $body = $($header).next(SELECTOR_EXPANDABLE_BODY).children().first().children()
|
const $body = $($header).next(SELECTOR_EXPANDABLE_BODY).children().first().children()
|
||||||
|
@ -80,8 +79,7 @@ class ExpandableTable {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Static
|
// Static
|
||||||
|
static _jQueryInterface(config) {
|
||||||
static _jQueryInterface(operation) {
|
|
||||||
return this.each(function () {
|
return this.each(function () {
|
||||||
let data = $(this).data(DATA_KEY)
|
let data = $(this).data(DATA_KEY)
|
||||||
|
|
||||||
|
@ -90,8 +88,8 @@ class ExpandableTable {
|
||||||
$(this).data(DATA_KEY, data)
|
$(this).data(DATA_KEY, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof operation === 'string' && /init|toggleRow/.test(operation)) {
|
if (typeof config === 'string' && /init|toggleRow/.test(config)) {
|
||||||
data[operation]()
|
data[config]()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -102,7 +100,7 @@ class ExpandableTable {
|
||||||
* ====================================================
|
* ====================================================
|
||||||
*/
|
*/
|
||||||
$(SELECTOR_TABLE).ready(function () {
|
$(SELECTOR_TABLE).ready(function () {
|
||||||
ExpandableTable._jQueryInterface.call($(this), 'init')
|
ExpandableTable._jQueryInterface.call($(this), '_init')
|
||||||
})
|
})
|
||||||
|
|
||||||
$(document).on('click', SELECTOR_DATA_TOGGLE, function () {
|
$(document).on('click', SELECTOR_DATA_TOGGLE, function () {
|
||||||
|
|
|
@ -34,7 +34,7 @@ const Default = {
|
||||||
class Fullscreen {
|
class Fullscreen {
|
||||||
constructor(_element, _options) {
|
constructor(_element, _options) {
|
||||||
this.element = _element
|
this.element = _element
|
||||||
this.options = $.extend({}, Default, _options)
|
this.options = _options
|
||||||
}
|
}
|
||||||
|
|
||||||
// Public
|
// Public
|
||||||
|
@ -82,24 +82,22 @@ class Fullscreen {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Static
|
// Static
|
||||||
|
|
||||||
static _jQueryInterface(config) {
|
static _jQueryInterface(config) {
|
||||||
let data = $(this).data(DATA_KEY)
|
return this.each(function () {
|
||||||
|
let data = $(this).data(DATA_KEY)
|
||||||
|
const _config = $.extend({}, Default, typeof config === 'object' ? config : $(this).data())
|
||||||
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
data = $(this).data()
|
data = new Fullscreen($(this), _config)
|
||||||
}
|
$(this).data(DATA_KEY, data)
|
||||||
|
} else if (typeof config === 'string') {
|
||||||
|
if (typeof data[config] === 'undefined') {
|
||||||
|
throw new TypeError(`No method named "${config}"`)
|
||||||
|
}
|
||||||
|
|
||||||
const _options = $.extend({}, Default, typeof config === 'object' ? config : data)
|
data[config]()
|
||||||
const plugin = new Fullscreen($(this), _options)
|
}
|
||||||
|
})
|
||||||
$(this).data(DATA_KEY, typeof config === 'object' ? config : data)
|
|
||||||
|
|
||||||
if (typeof config === 'string' && /toggle|toggleIcon|fullscreen|windowed/.test(config)) {
|
|
||||||
plugin[config]()
|
|
||||||
} else {
|
|
||||||
plugin.init()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
// noinspection EqualityComparisonWithCoercionJS
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------
|
* --------------------------------------------
|
||||||
* AdminLTE IFrame.js
|
* AdminLTE IFrame.js
|
||||||
|
@ -106,7 +108,11 @@ class IFrame {
|
||||||
if (autoOpen) {
|
if (autoOpen) {
|
||||||
if (this._config.loadingScreen) {
|
if (this._config.loadingScreen) {
|
||||||
const $loadingScreen = $(SELECTOR_TAB_LOADING)
|
const $loadingScreen = $(SELECTOR_TAB_LOADING)
|
||||||
$loadingScreen.fadeIn()
|
|
||||||
|
if (!$loadingScreen.is(':animated')) {
|
||||||
|
$loadingScreen.fadeIn()
|
||||||
|
}
|
||||||
|
|
||||||
$(`${tabId} iframe`).ready(() => {
|
$(`${tabId} iframe`).ready(() => {
|
||||||
if (typeof this._config.loadingScreen === 'number') {
|
if (typeof this._config.loadingScreen === 'number') {
|
||||||
this.switchTab(`#${navId}`)
|
this.switchTab(`#${navId}`)
|
||||||
|
@ -258,8 +264,6 @@ class IFrame {
|
||||||
|
|
||||||
if (usingDefTab) {
|
if (usingDefTab) {
|
||||||
const $el = $(`${SELECTOR_TAB_PANE}`).first()
|
const $el = $(`${SELECTOR_TAB_PANE}`).first()
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
console.log($el)
|
|
||||||
const uniqueName = $el.attr('id').replace('panel-', '')
|
const uniqueName = $el.attr('id').replace('panel-', '')
|
||||||
const navId = `#tab-${uniqueName}`
|
const navId = `#tab-${uniqueName}`
|
||||||
|
|
||||||
|
@ -316,7 +320,7 @@ class IFrame {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
let { target } = e
|
let { target } = e
|
||||||
|
|
||||||
if (target.nodeName == 'I') {
|
if (target.nodeName === 'I') {
|
||||||
target = e.target.offsetParent
|
target = e.target.offsetParent
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -411,8 +415,8 @@ class IFrame {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Static
|
// Static
|
||||||
|
// eslint-disable-next-line max-params
|
||||||
static _jQueryInterface(config) {
|
static _jQueryInterface(config, name, link, id, reload) {
|
||||||
if ($(SELECTOR_DATA_TOGGLE).length > 0) {
|
if ($(SELECTOR_DATA_TOGGLE).length > 0) {
|
||||||
let data = $(this).data(DATA_KEY)
|
let data = $(this).data(DATA_KEY)
|
||||||
|
|
||||||
|
@ -422,16 +426,14 @@ class IFrame {
|
||||||
|
|
||||||
const _options = $.extend({}, Default, typeof config === 'object' ? config : data)
|
const _options = $.extend({}, Default, typeof config === 'object' ? config : data)
|
||||||
localStorage.setItem('AdminLTE:IFrame:Options', JSON.stringify(_options))
|
localStorage.setItem('AdminLTE:IFrame:Options', JSON.stringify(_options))
|
||||||
|
|
||||||
const plugin = new IFrame($(this), _options)
|
const plugin = new IFrame($(this), _options)
|
||||||
|
window.iFrameInstance = plugin
|
||||||
$(this).data(DATA_KEY, typeof config === 'object' ? config : data)
|
$(this).data(DATA_KEY, typeof config === 'object' ? config : { link, name, id, reload, ...data })
|
||||||
|
|
||||||
if (typeof config === 'string' && /createTab|openTabSidebar|switchTab|removeActiveTab/.test(config)) {
|
if (typeof config === 'string' && /createTab|openTabSidebar|switchTab|removeActiveTab/.test(config)) {
|
||||||
plugin[config]()
|
plugin[config](name, link, id, reload)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
new IFrame($(this), JSON.parse(localStorage.getItem('AdminLTE:IFrame:Options')))._initFrameElement()
|
window.iFrameInstance = new IFrame($(this), JSON.parse(localStorage.getItem('AdminLTE:IFrame:Options')))._initFrameElement()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -210,21 +210,23 @@ class Layout {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Static
|
// Static
|
||||||
|
static _jQueryInterface(config) {
|
||||||
static _jQueryInterface(config = '') {
|
|
||||||
return this.each(function () {
|
return this.each(function () {
|
||||||
let data = $(this).data(DATA_KEY)
|
let data = $(this).data(DATA_KEY)
|
||||||
const _options = $.extend({}, Default, $(this).data())
|
const _config = $.extend({}, Default, typeof config === 'object' ? config : $(this).data())
|
||||||
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
data = new Layout($(this), _options)
|
data = new Layout($(this), _config)
|
||||||
$(this).data(DATA_KEY, data)
|
$(this).data(DATA_KEY, data)
|
||||||
}
|
|
||||||
|
|
||||||
if (config === 'init' || config === '') {
|
|
||||||
data._init()
|
data._init()
|
||||||
} else if (config === 'fixLayoutHeight' || config === 'fixLoginRegisterHeight') {
|
} else if (typeof config === 'string') {
|
||||||
|
if (typeof data[config] === 'undefined') {
|
||||||
|
throw new TypeError(`No method named "${config}"`)
|
||||||
|
}
|
||||||
|
|
||||||
data[config]()
|
data[config]()
|
||||||
|
} else if (typeof config === 'undefined') {
|
||||||
|
data._init()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ const Default = {
|
||||||
class NavbarSearch {
|
class NavbarSearch {
|
||||||
constructor(_element, _options) {
|
constructor(_element, _options) {
|
||||||
this._element = _element
|
this._element = _element
|
||||||
this._config = $.extend({}, Default, _options)
|
this._config = _options
|
||||||
}
|
}
|
||||||
|
|
||||||
// Public
|
// Public
|
||||||
|
@ -62,22 +62,21 @@ class NavbarSearch {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Static
|
// Static
|
||||||
|
static _jQueryInterface(config) {
|
||||||
static _jQueryInterface(options) {
|
|
||||||
return this.each(function () {
|
return this.each(function () {
|
||||||
let data = $(this).data(DATA_KEY)
|
let data = $(this).data(DATA_KEY)
|
||||||
const _options = $.extend({}, Default, $(this).data())
|
const _config = $.extend({}, Default, typeof config === 'object' ? config : $(this).data())
|
||||||
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
data = new NavbarSearch(this, _options)
|
data = new NavbarSearch($(this), _config)
|
||||||
$(this).data(DATA_KEY, data)
|
$(this).data(DATA_KEY, data)
|
||||||
}
|
} else if (typeof config === 'string') {
|
||||||
|
if (typeof data[config] === 'undefined') {
|
||||||
|
throw new TypeError(`No method named "${config}"`)
|
||||||
|
}
|
||||||
|
|
||||||
if (!/toggle|close|open/.test(options)) {
|
data[config]()
|
||||||
throw new Error(`Undefined method ${options}`)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
data[options]()
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ const Default = {
|
||||||
class PushMenu {
|
class PushMenu {
|
||||||
constructor(element, options) {
|
constructor(element, options) {
|
||||||
this._element = element
|
this._element = element
|
||||||
this._options = $.extend({}, Default, options)
|
this._options = options
|
||||||
|
|
||||||
if ($(SELECTOR_OVERLAY).length === 0) {
|
if ($(SELECTOR_OVERLAY).length === 0) {
|
||||||
this._addOverlay()
|
this._addOverlay()
|
||||||
|
@ -175,19 +175,23 @@ class PushMenu {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Static
|
// Static
|
||||||
|
static _jQueryInterface(config) {
|
||||||
static _jQueryInterface(operation) {
|
|
||||||
return this.each(function () {
|
return this.each(function () {
|
||||||
let data = $(this).data(DATA_KEY)
|
let data = $(this).data(DATA_KEY)
|
||||||
const _options = $.extend({}, Default, $(this).data())
|
const _config = $.extend({}, Default, typeof config === 'object' ? config : $(this).data())
|
||||||
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
data = new PushMenu(this, _options)
|
data = new PushMenu($(this), _config)
|
||||||
$(this).data(DATA_KEY, data)
|
$(this).data(DATA_KEY, data)
|
||||||
}
|
data._init()
|
||||||
|
} else if (typeof config === 'string') {
|
||||||
|
if (typeof data[config] === 'undefined') {
|
||||||
|
throw new TypeError(`No method named "${config}"`)
|
||||||
|
}
|
||||||
|
|
||||||
if (typeof operation === 'string' && /collapse|expand|toggle/.test(operation)) {
|
data[config]()
|
||||||
data[operation]()
|
} else if (typeof config === 'undefined') {
|
||||||
|
data._init()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ class SidebarSearch {
|
||||||
|
|
||||||
// Public
|
// Public
|
||||||
|
|
||||||
init() {
|
_init() {
|
||||||
if ($(SELECTOR_DATA_WIDGET).length === 0) {
|
if ($(SELECTOR_DATA_WIDGET).length === 0) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -207,24 +207,25 @@ class SidebarSearch {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Static
|
// Static
|
||||||
|
|
||||||
static _jQueryInterface(config) {
|
static _jQueryInterface(config) {
|
||||||
let data = $(this).data(DATA_KEY)
|
return this.each(function () {
|
||||||
|
let data = $(this).data(DATA_KEY)
|
||||||
|
const _config = $.extend({}, Default, typeof config === 'object' ? config : $(this).data())
|
||||||
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
data = $(this).data()
|
data = new SidebarSearch($(this), _config)
|
||||||
}
|
$(this).data(DATA_KEY, data)
|
||||||
|
data._init()
|
||||||
|
} else if (typeof config === 'string') {
|
||||||
|
if (typeof data[config] === 'undefined') {
|
||||||
|
throw new TypeError(`No method named "${config}"`)
|
||||||
|
}
|
||||||
|
|
||||||
const _options = $.extend({}, Default, typeof config === 'object' ? config : data)
|
data[config]()
|
||||||
const plugin = new SidebarSearch($(this), _options)
|
} else if (typeof config === 'undefined') {
|
||||||
|
data._init()
|
||||||
$(this).data(DATA_KEY, typeof config === 'object' ? config : data)
|
}
|
||||||
|
})
|
||||||
if (typeof config === 'string' && /init|toggle|close|open|search/.test(config)) {
|
|
||||||
plugin[config]()
|
|
||||||
} else {
|
|
||||||
plugin.init()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
// noinspection EqualityComparisonWithCoercionJS
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* --------------------------------------------
|
* --------------------------------------------
|
||||||
* AdminLTE Toasts.js
|
* AdminLTE Toasts.js
|
||||||
|
@ -140,19 +142,19 @@ class Toasts {
|
||||||
// Static
|
// Static
|
||||||
|
|
||||||
_getContainerId() {
|
_getContainerId() {
|
||||||
if (this._config.position == POSITION_TOP_RIGHT) {
|
if (this._config.position === POSITION_TOP_RIGHT) {
|
||||||
return SELECTOR_CONTAINER_TOP_RIGHT
|
return SELECTOR_CONTAINER_TOP_RIGHT
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._config.position == POSITION_TOP_LEFT) {
|
if (this._config.position === POSITION_TOP_LEFT) {
|
||||||
return SELECTOR_CONTAINER_TOP_LEFT
|
return SELECTOR_CONTAINER_TOP_LEFT
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._config.position == POSITION_BOTTOM_RIGHT) {
|
if (this._config.position === POSITION_BOTTOM_RIGHT) {
|
||||||
return SELECTOR_CONTAINER_BOTTOM_RIGHT
|
return SELECTOR_CONTAINER_BOTTOM_RIGHT
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._config.position == POSITION_BOTTOM_LEFT) {
|
if (this._config.position === POSITION_BOTTOM_LEFT) {
|
||||||
return SELECTOR_CONTAINER_BOTTOM_LEFT
|
return SELECTOR_CONTAINER_BOTTOM_LEFT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -181,7 +183,6 @@ class Toasts {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Static
|
// Static
|
||||||
|
|
||||||
static _jQueryInterface(option, config) {
|
static _jQueryInterface(option, config) {
|
||||||
return this.each(function () {
|
return this.each(function () {
|
||||||
const _options = $.extend({}, Default, config)
|
const _options = $.extend({}, Default, config)
|
||||||
|
|
|
@ -46,7 +46,7 @@ class TodoList {
|
||||||
toggle(item) {
|
toggle(item) {
|
||||||
item.parents('li').toggleClass(CLASS_NAME_TODO_LIST_DONE)
|
item.parents('li').toggleClass(CLASS_NAME_TODO_LIST_DONE)
|
||||||
if (!$(item).prop('checked')) {
|
if (!$(item).prop('checked')) {
|
||||||
this.unCheck($(item))
|
this.unCheck(item)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,11 +54,11 @@ class TodoList {
|
||||||
}
|
}
|
||||||
|
|
||||||
check(item) {
|
check(item) {
|
||||||
this._config.onCheck.call(item)
|
this._config.onCheck(item)
|
||||||
}
|
}
|
||||||
|
|
||||||
unCheck(item) {
|
unCheck(item) {
|
||||||
this._config.onUnCheck.call(item)
|
this._config.onUnCheck(item)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Private
|
// Private
|
||||||
|
@ -73,22 +73,23 @@ class TodoList {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Static
|
// Static
|
||||||
|
|
||||||
static _jQueryInterface(config) {
|
static _jQueryInterface(config) {
|
||||||
return this.each(function () {
|
return this.each(function () {
|
||||||
let data = $(this).data(DATA_KEY)
|
let data = $(this).data(DATA_KEY)
|
||||||
|
const _config = $.extend({}, Default, typeof config === 'object' ? config : $(this).data())
|
||||||
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
data = $(this).data()
|
data = new TodoList($(this), _config)
|
||||||
}
|
$(this).data(DATA_KEY, data)
|
||||||
|
data._init()
|
||||||
|
} else if (typeof config === 'string') {
|
||||||
|
if (typeof data[config] === 'undefined') {
|
||||||
|
throw new TypeError(`No method named "${config}"`)
|
||||||
|
}
|
||||||
|
|
||||||
const _options = $.extend({}, Default, typeof config === 'object' ? config : data)
|
data[config]()
|
||||||
const plugin = new TodoList($(this), _options)
|
} else if (typeof config === 'undefined') {
|
||||||
|
data._init()
|
||||||
$(this).data(DATA_KEY, typeof config === 'object' ? config : data)
|
|
||||||
|
|
||||||
if (config === 'init') {
|
|
||||||
plugin[config]()
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ class Treeview {
|
||||||
|
|
||||||
// Public
|
// Public
|
||||||
|
|
||||||
init() {
|
_init() {
|
||||||
$(`${SELECTOR_LI}${SELECTOR_OPEN} ${SELECTOR_TREEVIEW_MENU}${SELECTOR_OPEN}`).css('display', 'block')
|
$(`${SELECTOR_LI}${SELECTOR_OPEN} ${SELECTOR_TREEVIEW_MENU}${SELECTOR_OPEN}`).css('display', 'block')
|
||||||
this._setupListeners()
|
this._setupListeners()
|
||||||
}
|
}
|
||||||
|
@ -131,19 +131,23 @@ class Treeview {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Static
|
// Static
|
||||||
|
|
||||||
static _jQueryInterface(config) {
|
static _jQueryInterface(config) {
|
||||||
return this.each(function () {
|
return this.each(function () {
|
||||||
let data = $(this).data(DATA_KEY)
|
let data = $(this).data(DATA_KEY)
|
||||||
const _options = $.extend({}, Default, $(this).data())
|
const _config = $.extend({}, Default, typeof config === 'object' ? config : $(this).data())
|
||||||
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
data = new Treeview($(this), _options)
|
data = new Treeview($(this), _config)
|
||||||
$(this).data(DATA_KEY, data)
|
$(this).data(DATA_KEY, data)
|
||||||
}
|
data._init()
|
||||||
|
} else if (typeof config === 'string') {
|
||||||
|
if (typeof data[config] === 'undefined') {
|
||||||
|
throw new TypeError(`No method named "${config}"`)
|
||||||
|
}
|
||||||
|
|
||||||
if (config === 'init') {
|
|
||||||
data[config]()
|
data[config]()
|
||||||
|
} else if (typeof config === 'undefined') {
|
||||||
|
data._init()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue