Skip to content

Commit

Permalink
Merge pull request #2220 from REJack/v3-dev
Browse files Browse the repository at this point in the history
further changes for v3.0.0-rc.1
  • Loading branch information
REJack committed Sep 1, 2019
2 parents 4cb6c94 + baea4e4 commit 0bf308e
Show file tree
Hide file tree
Showing 809 changed files with 135,865 additions and 173,495 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ node_modules/
bower_components/

// Docs
Gemfile.lock
docs/_site
.jekyll-cache/
.jekyll-metadata
Expand Down
4 changes: 3 additions & 1 deletion build/js/AdminLTE.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -15,5 +16,6 @@ export {
DirectChat,
TodoList,
CardWidget,
CardRefresh
CardRefresh,
Dropdown
}
8 changes: 4 additions & 4 deletions build/js/CardWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)

Expand All @@ -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({
Expand All @@ -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;' +
Expand Down
152 changes: 144 additions & 8 deletions build/js/ControlSidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}

/**
Expand All @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
112 changes: 112 additions & 0 deletions build/js/Dropdown.js
Original file line number Diff line number Diff line change
@@ -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
9 changes: 0 additions & 9 deletions build/js/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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) {
Expand Down
Loading

0 comments on commit 0bf308e

Please sign in to comment.