Compare commits

...

3 Commits

Author SHA1 Message Date
Deon George
b3924ea239 Make resize delay configurable and default 1000 2020-03-12 09:13:55 +11:00
Deon George
6bc2787602 Improved sidebar open/close handling 2020-03-11 12:41:36 +11:00
Deon George
96a6830e61 Changed carbon method naming to be consistent with Carbon itself 2020-02-08 17:52:13 +11:00
2 changed files with 30 additions and 17 deletions

View File

@@ -14,6 +14,8 @@
}); });
$.AdminLTESidebarTweak = {}; $.AdminLTESidebarTweak = {};
$.AdminLTESidebarTweak.Open = true;
$.AdminLTESidebarTweak.ResizeDelay = 1000;
$.AdminLTESidebarTweak.options = { $.AdminLTESidebarTweak.options = {
EnableRemember: true, EnableRemember: true,
@@ -24,6 +26,29 @@
// Work out our timezone. // Work out our timezone.
const tz = Intl.DateTimeFormat().resolvedOptions().timeZone; const tz = Intl.DateTimeFormat().resolvedOptions().timeZone;
/**
* Open and close the sidebar
* @param state
* @param addclass
*/
function sidebaropenclose(state,addclass) {
// Dont do anything if the state hasnt changed.
if (state == $.AdminLTESidebarTweak.Open) {
return;
}
$.AdminLTESidebarTweak.Open = state;
if (addclass !== 'undefined')
$("body")
.addClass(state ? 'sidebar-open' : 'sidebar-collapse');
$(this).delay($.AdminLTESidebarTweak.ResizeDelay).queue(function() {
window.dispatchEvent(new Event('resize'));
$(this).dequeue();
});
}
$(function () { $(function () {
"use strict"; "use strict";
@@ -31,22 +56,15 @@
if($.AdminLTESidebarTweak.options.EnableRemember) { if($.AdminLTESidebarTweak.options.EnableRemember) {
document.cookie = "toggleState=closed;path=/"; document.cookie = "toggleState=closed;path=/";
$("body").delay(500).queue(function () { $("body").queue(sidebaropenclose(false));
window.dispatchEvent(new Event('resize'));
$(this).dequeue();
});
} }
}); });
// @todo this is not firing.
$("body").on("shown.lte.pushmenu", function(){ $("body").on("shown.lte.pushmenu", function(){
if($.AdminLTESidebarTweak.options.EnableRemember){ if($.AdminLTESidebarTweak.options.EnableRemember){
document.cookie = "toggleState=opened;path=/"; document.cookie = "toggleState=opened;path=/";
$("body").delay(500).queue(function () { $("body").queue(sidebaropenclose(true));
window.dispatchEvent(new Event('resize'));
$(this).dequeue();
});
} }
}); });
@@ -60,12 +78,7 @@
$(this).removeClass('hold-transition'); $(this).removeClass('hold-transition');
}); });
}else{ }else{
$("body") $("body").queue(sidebaropenclose(false,true));
.addClass('sidebar-collapse')
.delay(500).queue(function () {
window.dispatchEvent(new Event('resize'));
$(this).dequeue();
});
} }
} }
} }

View File

@@ -34,7 +34,7 @@ class Carbon extends CarbonBase
* *
* @return static * @return static
*/ */
public function firstOfHalf($dayOfWeek = null) public function startOfHalf($dayOfWeek = null)
{ {
return $this->setDate($this->year, $this->half * static::MONTHS_PER_HALF - 5, 1)->firstOfMonth($dayOfWeek); return $this->setDate($this->year, $this->half * static::MONTHS_PER_HALF - 5, 1)->firstOfMonth($dayOfWeek);
} }
@@ -49,7 +49,7 @@ class Carbon extends CarbonBase
* *
* @return static * @return static
*/ */
public function lastOfHalf($dayOfWeek = null) public function endOfHalf($dayOfWeek = null)
{ {
return $this->setDate($this->year, $this->half * static::MONTHS_PER_HALF, 1)->lastOfMonth($dayOfWeek); return $this->setDate($this->year, $this->half * static::MONTHS_PER_HALF, 1)->lastOfMonth($dayOfWeek);
} }