2021-11-02 14:05:32 +01:00
"use strict" ;
/ * !
2021-12-29 17:04:45 +01:00
=== === === === === === === === === === === === === === === === === === ===
* Black Dashboard Pro - v1 . 1.1
=== === === === === === === === === === === === === === === === === === ===
2021-11-02 14:05:32 +01:00
2021-12-29 17:04:45 +01:00
* Product Page : https : //themes.getbootstrap.com/product/black-dashboard-pro-premium-bootstrap-4-admin/
* Copyright 2019 Creative Tim ( https : //www.creative-tim.com)
* Coded by Creative Tim
2021-11-02 14:05:32 +01:00
2021-12-29 17:04:45 +01:00
=== === === === === === === === === === === === === === === === === === ===
2021-11-02 14:05:32 +01:00
2021-12-29 17:04:45 +01:00
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software .
2021-11-02 14:05:32 +01:00
2021-12-29 17:04:45 +01:00
* /
2021-11-02 14:05:32 +01:00
var transparent = true ;
var transparentDemo = true ;
var fixedTop = false ;
var navbar _initialized = false ;
var backgroundOrange = false ;
var sidebar _mini _active = false ;
var toggle _initialized = false ;
var $html = $ ( 'html' ) ;
var $body = $ ( 'body' ) ;
var $navbar _minimize _fixed = $ ( '.navbar-minimize-fixed' ) ;
var $collapse = $ ( '.collapse' ) ;
var $navbar = $ ( '.navbar' ) ;
var $tagsinput = $ ( '.tagsinput' ) ;
var $selectpicker = $ ( '.selectpicker' ) ;
var $navbar _color = $ ( '.navbar[color-on-scroll]' ) ;
var $full _screen _map = $ ( '.full-screen-map' ) ;
var $datetimepicker = $ ( '.datetimepicker' ) ;
var $datepicker = $ ( '.datepicker' ) ;
var $timepicker = $ ( '.timepicker' ) ;
var seq = 0 ,
2021-12-29 17:04:45 +01:00
delays = 80 ,
durations = 500 ;
2021-11-02 14:05:32 +01:00
var seq2 = 0 ,
2021-12-29 17:04:45 +01:00
delays2 = 80 ,
durations2 = 500 ;
2021-11-02 14:05:32 +01:00
// Returns a function, that, as long as it continues to be invoked, will not
// be triggered. The function will be called after it stops being called for
// N milliseconds. If `immediate` is passed, trigger the function on the
// leading edge, instead of the trailing.
function debounce ( func , wait , immediate ) {
2021-12-29 17:04:45 +01:00
var timeout ;
return function ( ) {
var context = this ,
args = arguments ;
clearTimeout ( timeout ) ;
timeout = setTimeout ( function ( ) {
timeout = null ;
if ( ! immediate ) func . apply ( context , args ) ;
} , wait ) ;
if ( immediate && ! timeout ) func . apply ( context , args ) ;
} ;
2021-11-02 14:05:32 +01:00
} ;
( function ( ) {
2021-12-29 17:04:45 +01:00
var isWindows = navigator . platform . indexOf ( 'Win' ) > - 1 ? true : false ;
if ( isWindows ) {
// if we are on windows OS we activate the perfectScrollbar function
if ( $ ( '.main-panel' ) . length != 0 ) {
var ps = new PerfectScrollbar ( '.main-panel' , {
wheelSpeed : 2 ,
wheelPropagation : true ,
minScrollbarLength : 20 ,
suppressScrollX : true
} ) ;
}
if ( $ ( '.sidebar .sidebar-wrapper' ) . length != 0 ) {
var ps1 = new PerfectScrollbar ( '.sidebar .sidebar-wrapper' ) ;
$ ( '.table-responsive' ) . each ( function ( ) {
var ps2 = new PerfectScrollbar ( $ ( this ) [ 0 ] ) ;
} ) ;
}
$html . addClass ( 'perfect-scrollbar-on' ) ;
} else {
$html . addClass ( 'perfect-scrollbar-off' ) ;
}
2021-11-02 14:05:32 +01:00
} ) ( ) ;
$ ( document ) . ready ( function ( ) {
2021-12-29 17:04:45 +01:00
var scroll _start = 0 ;
var startchange = $ ( '.row' ) ;
var offset = startchange . offset ( ) ;
var scrollElement = navigator . platform . indexOf ( 'Win' ) > - 1 ? $ ( ".ps" ) : $ ( window ) ;
scrollElement . scroll ( function ( ) {
scroll _start = $ ( this ) . scrollTop ( ) ;
if ( scroll _start > 50 ) {
$navbar _minimize _fixed . css ( 'opacity' , '1' ) ;
} else {
$navbar _minimize _fixed . css ( 'opacity' , '0' ) ;
}
} ) ;
// hide the siblings opened collapse
$collapse . on ( 'show.bs.collapse' , function ( ) {
$ ( this ) . parent ( ) . siblings ( ) . children ( '.collapse' ) . each ( function ( ) {
$ ( this ) . collapse ( 'hide' ) ;
} ) ;
} ) ;
// Activate the Tooltips
$ ( '[data-toggle="tooltip"], [rel="tooltip"]' ) . tooltip ( ) ;
// Activate Popovers and set color for popovers
$ ( '[data-toggle="popover"]' ) . each ( function ( ) {
color _class = $ ( this ) . data ( 'color' ) ;
$ ( this ) . popover ( {
template : '<div class="popover popover-' + color _class + '" role="tooltip"><div class="arrow"></div><h3 class="popover-header"></h3><div class="popover-body"></div></div>'
} ) ;
} ) ;
var tagClass = $tagsinput . data ( 'color' ) ;
if ( $tagsinput . length != 0 ) {
$tagsinput . tagsinput ( ) ;
}
$ ( '.bootstrap-tagsinput' ) . find ( '.tag' ) . addClass ( 'badge-' + tagClass ) ;
// Activate bootstrap-select
if ( $selectpicker . length != 0 ) {
$selectpicker . selectpicker ( {
iconBase : "tim-icons" ,
tickIcon : "icon-check-2"
} ) ;
}
//when you click the modal search button the navbar will not be collapsed
$ ( "#search-button" ) . click ( function ( ) {
$ ( this ) . closest ( '.navbar-collapse' ) . removeClass ( 'show' ) ;
$navbar . addClass ( 'navbar-transparent' ) . removeClass ( 'bg-white' ) ;
2022-02-10 21:49:39 +01:00
// $('#inlineFormInputGroup').focus();
2021-12-29 17:04:45 +01:00
} ) ;
blackDashboard . initMinimizeSidebar ( ) ;
var scroll _distance = $navbar _color . attr ( 'color-on-scroll' ) || 500 ;
// Check if we have the class "navbar-color-on-scroll" then add the function to remove the class "navbar-transparent" so it will transform to a plain color.
if ( $navbar _color . length != 0 ) {
blackDashboard . checkScrollForTransparentNavbar ( ) ;
$ ( window ) . on ( 'scroll' , blackDashboard . checkScrollForTransparentNavbar )
}
if ( $full _screen _map . length == 0 && $ ( '.bd-docs' ) . length == 0 ) {
// On click navbar-collapse the menu will be white not transparent
$ ( '.navbar-toggler' ) . click ( function ( ) {
$collapse . on ( 'show.bs.collapse' , function ( ) {
$ ( this ) . closest ( '.navbar' ) . removeClass ( 'navbar-transparent' ) . addClass ( 'bg-white' ) ;
} ) . on ( 'hide.bs.collapse' , function ( ) {
$ ( this ) . closest ( '.navbar' ) . addClass ( 'navbar-transparent' ) . removeClass ( 'bg-white' ) ;
} ) ;
$navbar . css ( 'transition' , '' ) ;
} ) ;
}
$navbar . css ( {
'top' : '0' ,
'transition' : 'all .5s linear'
} ) ;
$ ( '.form-control' ) . on ( "focus" , function ( ) {
$ ( this ) . parent ( '.input-group' ) . addClass ( "input-group-focus" ) ;
} ) . on ( "blur" , function ( ) {
$ ( this ) . parent ( ".input-group" ) . removeClass ( "input-group-focus" ) ;
} ) ;
// Activate bootstrapSwitch
$ ( '.bootstrap-switch' ) . each ( function ( ) {
var data _on _label = $ ( this ) . data ( 'on-label' ) || '' ;
var data _off _label = $ ( this ) . data ( 'off-label' ) || '' ;
$ ( this ) . bootstrapSwitch ( {
onText : data _on _label ,
offText : data _off _label
} ) ;
} ) ;
2021-11-02 14:05:32 +01:00
} ) ;
$ ( document ) . on ( 'click' , '.navbar-toggle' , function ( ) {
2021-12-29 17:04:45 +01:00
var $toggle = $ ( this ) ;
if ( blackDashboard . misc . navbar _menu _visible == 1 ) {
$html . removeClass ( 'nav-open' ) ;
blackDashboard . misc . navbar _menu _visible = 0 ;
setTimeout ( function ( ) {
$toggle . removeClass ( 'toggled' ) ;
$ ( '.bodyClick' ) . remove ( ) ;
} , 550 ) ;
} else {
setTimeout ( function ( ) {
$toggle . addClass ( 'toggled' ) ;
} , 580 ) ;
var div = '<div class="bodyClick"></div>' ;
$ ( div ) . appendTo ( 'body' ) . click ( function ( ) {
$html . removeClass ( 'nav-open' ) ;
blackDashboard . misc . navbar _menu _visible = 0 ;
setTimeout ( function ( ) {
$toggle . removeClass ( 'toggled' ) ;
$ ( '.bodyClick' ) . remove ( ) ;
} , 550 ) ;
} ) ;
$html . addClass ( 'nav-open' ) ;
blackDashboard . misc . navbar _menu _visible = 1 ;
}
2021-11-02 14:05:32 +01:00
} ) ;
$ ( window ) . resize ( function ( ) {
2021-12-29 17:04:45 +01:00
// reset the seq for charts drawing animations
seq = seq2 = 0 ;
if ( $full _screen _map . length == 0 && $ ( '.bd-docs' ) . length == 0 ) {
var isExpanded = $navbar . find ( '[data-toggle="collapse"]' ) . attr ( "aria-expanded" ) ;
if ( $navbar . hasClass ( 'bg-white' ) && $ ( window ) . width ( ) > 991 ) {
$navbar . removeClass ( 'bg-white' ) . addClass ( 'navbar-transparent' ) ;
} else if ( $navbar . hasClass ( 'navbar-transparent' ) && $ ( window ) . width ( ) < 991 && isExpanded != "false" ) {
$navbar . addClass ( 'bg-white' ) . removeClass ( 'navbar-transparent' ) ;
}
}
2021-11-02 14:05:32 +01:00
} ) ;
var blackDashboard = {
2021-12-29 17:04:45 +01:00
misc : {
navbar _menu _visible : 0
} ,
checkScrollForTransparentNavbar : debounce ( function ( ) {
if ( $ ( document ) . scrollTop ( ) > scroll _distance ) {
if ( transparent ) {
transparent = false ;
$navbar _color . removeClass ( 'navbar-transparent' ) ;
}
} else {
if ( ! transparent ) {
transparent = true ;
$navbar _color . addClass ( 'navbar-transparent' ) ;
}
}
} , 17 ) ,
// Activate DateTimePicker
initDateTimePicker : function ( ) {
if ( $datetimepicker . length != 0 ) {
$datetimepicker . datetimepicker ( {
2022-01-26 12:53:14 +01:00
format : 'YYYY-MM-DD H:mm' ,
2021-12-29 17:04:45 +01:00
icons : {
time : "tim-icons icon-watch-time" ,
date : "tim-icons icon-calendar-60" ,
up : "fa fa-chevron-up" ,
down : "fa fa-chevron-down" ,
previous : 'tim-icons icon-minimal-left' ,
next : 'tim-icons icon-minimal-right' ,
today : 'fa fa-screenshot' ,
clear : 'fa fa-trash' ,
close : 'fa fa-remove'
}
} ) ;
}
if ( $datepicker . length != 0 ) {
$datepicker . datetimepicker ( {
2021-12-29 22:26:40 +01:00
format : 'YYYY-MM-DD' ,
2021-12-29 17:04:45 +01:00
icons : {
time : "tim-icons icon-watch-time" ,
date : "tim-icons icon-calendar-60" ,
up : "fa fa-chevron-up" ,
down : "fa fa-chevron-down" ,
previous : 'tim-icons icon-minimal-left' ,
next : 'tim-icons icon-minimal-right' ,
today : 'fa fa-screenshot' ,
clear : 'fa fa-trash' ,
close : 'fa fa-remove'
}
} ) ;
}
if ( $timepicker . length != 0 ) {
$timepicker . datetimepicker ( {
2021-12-29 22:26:40 +01:00
format : 'H:mm' , // use this format if you want the 24hours timepicker
// format: 'h:mm A', //use this format if you want the 12hours timpiecker with AM/PM toggle
2021-12-29 17:04:45 +01:00
icons : {
time : "tim-icons icon-watch-time" ,
date : "tim-icons icon-calendar-60" ,
up : "fa fa-chevron-up" ,
down : "fa fa-chevron-down" ,
previous : 'tim-icons icon-minimal-left' ,
next : 'tim-icons icon-minimal-right' ,
today : 'fa fa-screenshot' ,
clear : 'fa fa-trash' ,
close : 'fa fa-remove'
}
} ) ;
}
} ,
initMinimizeSidebar : function ( ) {
if ( $ ( '.sidebar-mini' ) . length != 0 ) {
sidebar _mini _active = true ;
}
$ ( '.minimize-sidebar' ) . click ( function ( ) {
if ( sidebar _mini _active == true ) {
$body . removeClass ( 'sidebar-mini' ) ;
sidebar _mini _active = false ;
blackDashboard . showSidebarMessage ( 'Sidebar mini deactivated...' ) ;
} else {
$body . addClass ( 'sidebar-mini' ) ;
sidebar _mini _active = true ;
blackDashboard . showSidebarMessage ( 'Sidebar mini activated...' ) ;
}
// we simulate the window Resize so the charts will get updated in realtime.
var simulateWindowResize = setInterval ( function ( ) {
window . dispatchEvent ( new Event ( 'resize' ) ) ;
} , 180 ) ;
// we stop the simulation of Window Resize after the animations are completed
setTimeout ( function ( ) {
clearInterval ( simulateWindowResize ) ;
} , 1000 ) ;
} ) ;
} ,
startAnimationForLineChart : function ( chart ) {
chart . on ( 'draw' , function ( data ) {
if ( data . type === 'line' || data . type === 'area' ) {
data . element . animate ( {
d : {
begin : 600 ,
dur : 700 ,
from : data . path . clone ( ) . scale ( 1 , 0 ) . translate ( 0 , data . chartRect . height ( ) ) . stringify ( ) ,
to : data . path . clone ( ) . stringify ( ) ,
easing : Chartist . Svg . Easing . easeOutQuint
}
} ) ;
} else if ( data . type === 'point' ) {
seq ++ ;
data . element . animate ( {
opacity : {
begin : seq * delays ,
dur : durations ,
from : 0 ,
to : 1 ,
easing : 'ease'
}
} ) ;
}
} ) ;
seq = 0 ;
} ,
startAnimationForBarChart : function ( chart ) {
chart . on ( 'draw' , function ( data ) {
if ( data . type === 'bar' ) {
seq2 ++ ;
data . element . animate ( {
opacity : {
begin : seq2 * delays2 ,
dur : durations2 ,
from : 0 ,
to : 1 ,
easing : 'ease'
}
} ) ;
}
} ) ;
seq2 = 0 ;
} ,
showSidebarMessage : function ( message ) {
try {
$ . notify ( {
icon : "tim-icons icon-bell-55" ,
message : message
} , {
type : 'primary' ,
timer : 4000 ,
placement : {
from : 'top' ,
align : 'right'
}
} ) ;
} catch ( e ) {
console . log ( 'Notify library is missing, please make sure you have the notifications library added.' ) ;
}
}
2021-11-02 14:05:32 +01:00
} ;
function hexToRGB ( hex , alpha ) {
2021-12-29 17:04:45 +01:00
var r = parseInt ( hex . slice ( 1 , 3 ) , 16 ) ,
g = parseInt ( hex . slice ( 3 , 5 ) , 16 ) ,
b = parseInt ( hex . slice ( 5 , 7 ) , 16 ) ;
if ( alpha ) {
return "rgba(" + r + ", " + g + ", " + b + ", " + alpha + ")" ;
} else {
return "rgb(" + r + ", " + g + ", " + b + ")" ;
}
}