@@ -37,8 +37,6 @@ $(function(){
37
37
this . $sidebar = $ ( '#sidebar' ) ;
38
38
this . $content = $ ( '#content' ) ;
39
39
this . $loaderWrap = $ ( '.loader-wrap' ) ;
40
- this . $navigationStateToggle = $ ( '#nav-state-toggle' ) ;
41
- this . $navigationCollapseToggle = $ ( '#nav-collapse-toggle' ) ;
42
40
this . settings = window . SingSettings ;
43
41
this . pageLoadCallbacks = { } ;
44
42
this . resizeCallbacks = [ ] ;
@@ -55,21 +53,6 @@ $(function(){
55
53
this . _initOnResizeCallbacks ( ) ;
56
54
this . _initOnScreenSizeCallbacks ( ) ;
57
55
58
- this . $sidebar . on ( 'mouseenter' , $ . proxy ( this . _sidebarMouseEnter , this ) ) ;
59
- this . $sidebar . on ( 'mouseleave' , $ . proxy ( this . _sidebarMouseLeave , this ) ) ;
60
- /**
61
- * open navigation in case collapsed sidebar clicked
62
- */
63
- //$(document).on('click', '.nav-collapsed #sidebar', $.proxy(this.expandNavigation, this));
64
- //we don't need this cool feature for big boys
65
- if ( Sing . isScreen ( 'xs' ) || Sing . isScreen ( 'sm' ) ) {
66
- ( 'ontouchstart' in window ) && this . $content
67
- . hammer ( )
68
- . bind ( 'swipeleft' , $ . proxy ( this . _contentSwipeLeft , this ) )
69
- . bind ( 'swiperight' , $ . proxy ( this . _contentSwipeRight , this ) ) ;
70
- }
71
-
72
- this . checkNavigationState ( ) ;
73
56
74
57
if ( this . pjaxEnabled ) {
75
58
/**
@@ -93,8 +76,6 @@ $(function(){
93
76
$ ( document ) . on ( 'pjax:end' , $ . proxy ( this . pageLoaded , this ) ) ;
94
77
}
95
78
96
- this . $navigationStateToggle . on ( 'click' , $ . proxy ( this . toggleNavigationState , this ) ) ;
97
- this . $navigationCollapseToggle . on ( 'click' , $ . proxy ( this . toggleNavigationCollapseState , this ) ) ;
98
79
99
80
/* reimplementing bs.collapse data-parent here as we don't want to use BS .panel*/
100
81
this . $sidebar . find ( '.collapse' ) . on ( 'show.bs.collapse' , function ( e ) {
@@ -175,104 +156,6 @@ $(function(){
175
156
this . pageResizeCallbacks = { } ;
176
157
} ;
177
158
178
- /**
179
- * Collapses navigation if nav-static local storage option is set to false
180
- */
181
- SingAppView . prototype . checkNavigationState = function ( ) {
182
- if ( this . isNavigationStatic ( ) ) {
183
- this . staticNavigationState ( ) ;
184
- if ( Sing . isScreen ( 'md' ) || Sing . isScreen ( 'sm' ) || Sing . isScreen ( 'xs' ) ) {
185
- this . collapseNavigation ( ) ;
186
- }
187
- } else {
188
- if ( Sing . isScreen ( 'lg' ) || Sing . isScreen ( 'xl' ) ) {
189
- var view = this ;
190
- setTimeout ( function ( ) {
191
- view . collapseNavigation ( ) ;
192
- } , this . navCollapseTimeout ) ;
193
- } else {
194
- this . collapseNavigation ( ) ;
195
- }
196
- }
197
- } ;
198
-
199
- SingAppView . prototype . collapseNavigation = function ( ) {
200
- //this method only makes sense for non-static navigation state
201
- if ( this . isNavigationStatic ( ) && ( Sing . isScreen ( 'lg' ) || Sing . isScreen ( 'xl' ) ) ) return ;
202
-
203
- // $('body').addClass('nav-collapsed');
204
- // this.$sidebar.find('.collapse.show').collapse('hide')
205
- // .siblings('[data-toggle=collapse]').addClass('collapsed');
206
-
207
- } ;
208
-
209
- SingAppView . prototype . expandNavigation = function ( ) {
210
- //this method only makes sense for non-static navigation state
211
- if ( this . isNavigationStatic ( ) && ( Sing . isScreen ( 'lg' ) || Sing . isScreen ( 'xl' ) ) ) return ;
212
-
213
- // $('body').removeClass('nav-collapsed');
214
- // this.$sidebar.find('.active .active').closest('.collapse').collapse('show')
215
- // .siblings('[data-toggle=collapse]').removeClass('collapsed');
216
- } ;
217
-
218
- SingAppView . prototype . _sidebarMouseEnter = function ( ) {
219
- if ( Sing . isScreen ( 'lg' ) || Sing . isScreen ( 'xl' ) ) {
220
- this . expandNavigation ( ) ;
221
- }
222
- } ;
223
-
224
- SingAppView . prototype . _sidebarMouseLeave = function ( ) {
225
- if ( Sing . isScreen ( 'lg' ) || Sing . isScreen ( 'xl' ) ) {
226
- this . collapseNavigation ( ) ;
227
- }
228
- } ;
229
-
230
- SingAppView . prototype . _collapseNavIfSmallScreen = function ( ) {
231
- if ( Sing . isScreen ( 'xs' ) || Sing . isScreen ( 'sm' ) || Sing . isScreen ( 'md' ) ) {
232
- this . collapseNavigation ( ) ;
233
- }
234
- } ;
235
-
236
- /**
237
- * Toggles between static and collapsing navigation states.
238
- * Collapsing - navigation automatically collapse when mouse leaves it and expand when enters.
239
- * Static - stays always open.
240
- */
241
-
242
- SingAppView . prototype . toggleNavigationState = function ( ) {
243
- if ( this . isNavigationStatic ( ) ) {
244
- this . collapsingNavigationState ( ) ;
245
- } else {
246
- this . staticNavigationState ( ) ;
247
- }
248
- $ ( window ) . trigger ( 'sing-app:content-resize' ) ;
249
- } ;
250
-
251
- /**
252
- * Turns on static navigation state.
253
- * Collapsing navigation state - navigation automatically collapse when mouse leaves it and expand when enters.
254
- * Static navigation state - navigation stays always open.
255
- */
256
- SingAppView . prototype . staticNavigationState = function ( ) {
257
- this . settings . set ( 'nav-static' , true ) . save ( ) ;
258
- $ ( 'body' ) . addClass ( 'nav-static' ) ;
259
- } ;
260
-
261
- /**
262
- * Turns on collapsing navigation state.
263
- * Collapsing navigation state - navigation automatically collapse when mouse leaves it and expand when enters.
264
- * Static navigation state - navigation stays always open.
265
- */
266
- SingAppView . prototype . collapsingNavigationState = function ( ) {
267
- this . settings . set ( 'nav-static' , false ) . save ( ) ;
268
- $ ( 'body' ) . removeClass ( 'nav-static' ) ;
269
- this . collapseNavigation ( ) ;
270
- } ;
271
-
272
- SingAppView . prototype . isNavigationStatic = function ( ) {
273
- return this . settings . get ( 'nav-static' ) === true ;
274
- } ;
275
-
276
159
/**
277
160
* Changes active navigation item depending on current page.
278
161
* Should be executed before page load
@@ -296,21 +179,6 @@ $(function(){
296
179
. parents ( 'li' ) . addClass ( 'active' ) ;
297
180
} ;
298
181
299
- /**
300
- * Checks whether screen is md or lg and closes navigation if opened
301
- * @private
302
- */
303
- SingAppView . prototype . _contentSwipeLeft = function ( ) {
304
- var self = this ;
305
- //this method only makes sense for small screens + ipad
306
- setTimeout ( function ( ) {
307
- if ( Sing . isScreen ( 'xl' ) ) return ;
308
-
309
- // if (!$('body').is('.nav-collapsed')){
310
- // self.collapseNavigation();
311
- // }
312
- } )
313
- } ;
314
182
315
183
/**
316
184
* Checks whether screen is md or lg and opens navigation if closed
@@ -525,12 +393,10 @@ $(function(){
525
393
526
394
window . SingApp = new SingAppView ( ) ;
527
395
528
- // SingApp.expandNavigation();
529
396
530
397
initAppPlugins ( ) ;
531
398
initAppFunctions ( ) ;
532
399
initAppFixes ( ) ;
533
- initDemoFunctions ( ) ;
534
400
} ) ;
535
401
536
402
/**
@@ -697,40 +563,3 @@ function initAppFixes(){
697
563
}
698
564
}
699
565
700
- /**
701
- * Demo-only functions. Does not affect the core Sing functionality.
702
- * Should be removed when used in real app.
703
- */
704
-
705
- function initDemoFunctions ( ) {
706
- ! function ( $ ) {
707
- $ ( '.theme-helper-toggler' ) . click ( ( ) => {
708
- $ ( '.theme-helper' ) . toggleClass ( 'theme-helper-opened' ) ;
709
- } ) ;
710
- $ ( '#load-notifications-btn' ) . on ( 'ajax-load:end' , function ( ) {
711
- setTimeout ( function ( ) {
712
- $ ( '#notifications-list' ) . find ( '.bg-attention' ) . removeClass ( 'bg-attention' ) ;
713
- } , 10000 )
714
- } ) ;
715
- $ ( '#notifications-toggle' ) . find ( 'input' ) . on ( 'ajax-load:end' , function ( ) {
716
- $ ( '#notifications-list' ) . find ( '[data-toggle=tooltip]' ) . tooltip ( ) ;
717
- } ) ;
718
-
719
-
720
- const mainSidebar = $ ( '#sidebar' ) ;
721
- const toggleSidebar = $ ( '#toggleSidebar' ) ;
722
-
723
- $ ( '.content-wrap' ) . on ( 'click' , ( e ) => {
724
- if ( $ ( '.toggle-sidebar' ) . hasClass ( 'open' ) ) {
725
- mainSidebar . removeClass ( 'sidebar-open' ) ;
726
- $ ( '.toggle-sidebar' ) . removeClass ( 'open' ) ;
727
- }
728
- } ) ;
729
-
730
- toggleSidebar . on ( 'click' , ( e ) => {
731
- mainSidebar . toggleClass ( 'sidebar-open' ) ;
732
- $ ( '.toggle-sidebar' ) . toggleClass ( 'open' ) ;
733
- } ) ;
734
-
735
- } ( jQuery ) ;
736
- }
0 commit comments