Skip to content
Permalink
Browse files

Merge pull request #2220 from REJack/v3-dev

further changes for v3.0.0-rc.1
  • Loading branch information...
REJack committed Sep 1, 2019
2 parents 4cb6c94 + baea4e4 commit 0bf308ebd69b1b08d7cb8402f4c43075dd5e7a1f
Showing 809 changed files with 135,865 additions and 173,495 deletions.
@@ -20,6 +20,7 @@ node_modules/
bower_components/

// Docs
Gemfile.lock
docs/_site
.jekyll-cache/
.jekyll-metadata
@@ -6,6 +6,7 @@ import DirectChat from './DirectChat'
import TodoList from './TodoList'
import CardWidget from './CardWidget'
import CardRefresh from './CardRefresh'
import Dropdown from './Dropdown'

export {
ControlSidebar,
@@ -15,5 +16,6 @@ export {
DirectChat,
TodoList,
CardWidget,
CardRefresh
CardRefresh,
Dropdown
}
@@ -70,7 +70,7 @@ const CardWidget = (($) => {
.slideUp(this._settings.animationSpeed, () => {
this._parent.addClass(ClassName.COLLAPSED)
})
this._element.children(this._settings.collapseTrigger + ' .' + this._settings.collapseIcon)
this._parent.find(this._settings.collapseTrigger + ' .' + this._settings.collapseIcon)
.addClass(this._settings.expandIcon)
.removeClass(this._settings.collapseIcon)

@@ -85,7 +85,7 @@ const CardWidget = (($) => {
this._parent.removeClass(ClassName.COLLAPSED)
})

this._element.children(this._settings.collapseTrigger + ' .' + this._settings.expandIcon)
this._parent.find(this._settings.collapseTrigger + ' .' + this._settings.expandIcon)
.addClass(this._settings.collapseIcon)
.removeClass(this._settings.expandIcon)

@@ -112,7 +112,7 @@ const CardWidget = (($) => {
}

maximize() {
this._element.children(this._settings.maximizeTrigger + ' .' + this._settings.maximizeIcon)
this._parent.find(this._settings.maximizeTrigger + ' .' + this._settings.maximizeIcon)
.addClass(this._settings.minimizeIcon)
.removeClass(this._settings.maximizeIcon)
this._parent.css({
@@ -134,7 +134,7 @@ const CardWidget = (($) => {
}

minimize() {
this._element.children(this._settings.maximizeTrigger + ' .' + this._settings.minimizeIcon)
this._parent.find(this._settings.maximizeTrigger + ' .' + this._settings.minimizeIcon)
.addClass(this._settings.maximizeIcon)
.removeClass(this._settings.minimizeIcon)
this._parent.css('cssText', 'height:' + this._parent[0].style.height + ' !important;' +
@@ -19,23 +19,39 @@ const ControlSidebar = (($) => {

const Event = {
COLLAPSED: `collapsed${EVENT_KEY}`,
EXPANDED: `expanded${EVENT_KEY}`
EXPANDED: `expanded${EVENT_KEY}`,
}

const Selector = {
CONTROL_SIDEBAR: '.control-sidebar',
DATA_TOGGLE : '[data-widget="control-sidebar"]',
MAIN_HEADER : '.main-header'
CONTROL_SIDEBAR_CONTENT: '.control-sidebar-content',
DATA_TOGGLE: '[data-widget="control-sidebar"]',
CONTENT: '.content-wrapper',
HEADER: '.main-header',
FOOTER: '.main-footer',
}

const ClassName = {
CONTROL_SIDEBAR_ANIMATE: 'control-sidebar-animate',
CONTROL_SIDEBAR_OPEN: 'control-sidebar-open',
CONTROL_SIDEBAR_SLIDE: 'control-sidebar-slide-open'
CONTROL_SIDEBAR_SLIDE: 'control-sidebar-slide-open',
LAYOUT_FIXED: 'layout-fixed',
NAVBAR_FIXED: 'layout-navbar-fixed',
NAVBAR_SM_FIXED: 'layout-sm-navbar-fixed',
NAVBAR_MD_FIXED: 'layout-md-navbar-fixed',
NAVBAR_LG_FIXED: 'layout-lg-navbar-fixed',
NAVBAR_XL_FIXED: 'layout-xl-navbar-fixed',
FOOTER_FIXED: 'layout-footer-fixed',
FOOTER_SM_FIXED: 'layout-sm-footer-fixed',
FOOTER_MD_FIXED: 'layout-md-footer-fixed',
FOOTER_LG_FIXED: 'layout-lg-footer-fixed',
FOOTER_XL_FIXED: 'layout-xl-footer-fixed',
}

const Default = {
controlsidebarSlide: true
controlsidebarSlide: true,
scrollbarTheme : 'os-theme-light',
scrollbarAutoHide: 'l',
}

/**
@@ -46,7 +62,9 @@ const ControlSidebar = (($) => {
class ControlSidebar {
constructor(element, config) {
this._element = element
this._config = this._getConfig(config)
this._config = config

this._init()
}

// Public
@@ -101,10 +119,128 @@ const ControlSidebar = (($) => {

// Private

_getConfig(config) {
return $.extend({}, Default, config)
_init() {
this._fixHeight()
this._fixScrollHeight()

$(window).resize(() => {
this._fixHeight()
this._fixScrollHeight()
})

$(window).scroll(() => {
if ($('body').hasClass(ClassName.CONTROL_SIDEBAR_OPEN) || $('body').hasClass(ClassName.CONTROL_SIDEBAR_SLIDE)) {
this._fixScrollHeight()
}
})
}

_fixScrollHeight() {
const heights = {
scroll: $(document).height(),
window: $(window).height(),
header: $(Selector.HEADER).outerHeight(),
footer: $(Selector.FOOTER).outerHeight(),
}
const positions = {
bottom: Math.abs((heights.window + $(window).scrollTop()) - heights.scroll),
top: $(window).scrollTop(),
}

let navbarFixed = false;
let footerFixed = false;

if ($('body').hasClass(ClassName.LAYOUT_FIXED)) {
if (
$('body').hasClass(ClassName.NAVBAR_FIXED)
|| $('body').hasClass(ClassName.NAVBAR_SM_FIXED)
|| $('body').hasClass(ClassName.NAVBAR_MD_FIXED)
|| $('body').hasClass(ClassName.NAVBAR_LG_FIXED)
|| $('body').hasClass(ClassName.NAVBAR_XL_FIXED)
) {
if ($(Selector.HEADER).css("position") === "fixed") {
navbarFixed = true;
}
}
if (
$('body').hasClass(ClassName.FOOTER_FIXED)
|| $('body').hasClass(ClassName.FOOTER_SM_FIXED)
|| $('body').hasClass(ClassName.FOOTER_MD_FIXED)
|| $('body').hasClass(ClassName.FOOTER_LG_FIXED)
|| $('body').hasClass(ClassName.FOOTER_XL_FIXED)
) {
if ($(Selector.FOOTER).css("position") === "fixed") {
footerFixed = true;
}
}

if (positions.top === 0 && positions.bottom === 0) {
$(Selector.CONTROL_SIDEBAR).css('bottom', heights.footer);
$(Selector.CONTROL_SIDEBAR).css('top', heights.header);
$(Selector.CONTROL_SIDEBAR + ', ' + Selector.CONTROL_SIDEBAR + ' ' + Selector.CONTROL_SIDEBAR_CONTENT).css('height', heights.window - (heights.header + heights.footer))
} else if (positions.bottom <= heights.footer) {
if (footerFixed === false) {
$(Selector.CONTROL_SIDEBAR).css('bottom', heights.footer - positions.bottom);
$(Selector.CONTROL_SIDEBAR + ', ' + Selector.CONTROL_SIDEBAR + ' ' + Selector.CONTROL_SIDEBAR_CONTENT).css('height', heights.window - (heights.footer - positions.bottom))
} else {
$(Selector.CONTROL_SIDEBAR).css('bottom', heights.footer);
}
} else if (positions.top <= heights.header) {
if (navbarFixed === false) {
$(Selector.CONTROL_SIDEBAR).css('top', heights.header - positions.top);
$(Selector.CONTROL_SIDEBAR + ', ' + Selector.CONTROL_SIDEBAR + ' ' + Selector.CONTROL_SIDEBAR_CONTENT).css('height', heights.window - (heights.header - positions.top))
} else {
$(Selector.CONTROL_SIDEBAR).css('top', heights.header);
}
} else {
if (navbarFixed === false) {
$(Selector.CONTROL_SIDEBAR).css('top', 0);
$(Selector.CONTROL_SIDEBAR + ', ' + Selector.CONTROL_SIDEBAR + ' ' + Selector.CONTROL_SIDEBAR_CONTENT).css('height', heights.window)
} else {
$(Selector.CONTROL_SIDEBAR).css('top', heights.header);
}
}
}
}

_fixHeight() {
const heights = {
window: $(window).height(),
header: $(Selector.HEADER).outerHeight(),
footer: $(Selector.FOOTER).outerHeight(),
}

if ($('body').hasClass(ClassName.LAYOUT_FIXED)) {
let sidebarHeight = heights.window - heights.header;

if (
$('body').hasClass(ClassName.FOOTER_FIXED)
|| $('body').hasClass(ClassName.FOOTER_SM_FIXED)
|| $('body').hasClass(ClassName.FOOTER_MD_FIXED)
|| $('body').hasClass(ClassName.FOOTER_LG_FIXED)
|| $('body').hasClass(ClassName.FOOTER_XL_FIXED)
) {
if ($(Selector.FOOTER).css("position") === "fixed") {
sidebarHeight = heights.window - heights.header - heights.footer;
}
}

$(Selector.CONTROL_SIDEBAR + ' ' + Selector.CONTROL_SIDEBAR_CONTENT).css('height', sidebarHeight)

if (typeof $.fn.overlayScrollbars !== 'undefined') {
$(Selector.CONTROL_SIDEBAR + ' ' + Selector.CONTROL_SIDEBAR_CONTENT).overlayScrollbars({
className : this._config.scrollbarTheme,
sizeAutoCapable : true,
scrollbars : {
autoHide: this._config.scrollbarAutoHide,
clickScrolling : true
}
})
}
}
}


// Static

static _jQueryInterface(operation) {
@@ -0,0 +1,112 @@
/**
* --------------------------------------------
* AdminLTE Dropdown.js
* License MIT
* --------------------------------------------
*/

const Dropdown = (($) => {
/**
* Constants
* ====================================================
*/

const NAME = 'Dropdown'
const DATA_KEY = 'lte.dropdown'
const EVENT_KEY = `.${DATA_KEY}`
const JQUERY_NO_CONFLICT = $.fn[NAME]

const Selector = {
DROPDOWN_MENU: 'ul.dropdown-menu',
DROPDOWN_TOGGLE: '[data-toggle="dropdown"]',
}

const ClassName = {
DROPDOWN_HOVER: '.dropdown-hover'
}

const Default = {
}


/**
* Class Definition
* ====================================================
*/

class Dropdown {
constructor(element, config) {
this._config = config
this._element = element
}

// Public

toggleSubmenu() {
this._element.siblings().show().toggleClass("show");

if (! this._element.next().hasClass('show')) {
this._element.parents('.dropdown-menu').first().find('.show').removeClass("show").hide();
}

this._element.parents('li.nav-item.dropdown.show').on('hidden.bs.dropdown', function(e) {
$('.dropdown-submenu .show').removeClass("show").hide();
});

}

// Static

static _jQueryInterface(config) {
return this.each(function () {
let data = $(this).data(DATA_KEY)
const _config = $.extend({}, Default, $(this).data())

if (!data) {
data = new Dropdown($(this), _config)
$(this).data(DATA_KEY, data)
}

if (config === 'toggleSubmenu') {
data[config]()
}
})
}
}

/**
* Data API
* ====================================================
*/

$(Selector.DROPDOWN_MENU + ' ' + Selector.DROPDOWN_TOGGLE).on("click", function(event) {
event.preventDefault();
event.stopPropagation();

Dropdown._jQueryInterface.call($(this), 'toggleSubmenu')
});

// $(Selector.SIDEBAR + ' a').on('focusin', () => {
// $(Selector.MAIN_SIDEBAR).addClass(ClassName.SIDEBAR_FOCUSED);
// })

// $(Selector.SIDEBAR + ' a').on('focusout', () => {
// $(Selector.MAIN_SIDEBAR).removeClass(ClassName.SIDEBAR_FOCUSED);
// })

/**
* jQuery API
* ====================================================
*/

$.fn[NAME] = Dropdown._jQueryInterface
$.fn[NAME].Constructor = Dropdown
$.fn[NAME].noConflict = function () {
$.fn[NAME] = JQUERY_NO_CONFLICT
return Dropdown._jQueryInterface
}

return Dropdown
})(jQuery)

export default Dropdown
@@ -77,7 +77,6 @@ const Layout = (($) => {
if ($('body').hasClass(ClassName.LAYOUT_FIXED)) {
$(Selector.CONTENT).css('min-height', max - heights.header - heights.footer)
// $(Selector.SIDEBAR).css('min-height', max - heights.header)
$(Selector.CONTROL_SIDEBAR + ' .control-sidebar-content').css('height', max - heights.header)

if (typeof $.fn.overlayScrollbars !== 'undefined') {
$(Selector.SIDEBAR).overlayScrollbars({
@@ -88,14 +87,6 @@ const Layout = (($) => {
clickScrolling : true
}
})
$(Selector.CONTROL_SIDEBAR + ' .control-sidebar-content').overlayScrollbars({
className : this._config.scrollbarTheme,
sizeAutoCapable : true,
scrollbars : {
autoHide: this._config.scrollbarAutoHide,
clickScrolling : true
}
})
}
} else {
if (heights.window > heights.sidebar) {

0 comments on commit 0bf308e

Please sign in to comment.
You can’t perform that action at this time.