@@ -31,12 +31,8 @@ $(document).ready(function () {
31
31
'css_modal' : 'cms/css/plugins/cms.toolbar.modal.css' ,
32
32
'css_sideframe' : 'cms/css/plugins/cms.toolbar.sideframe.css'
33
33
} ,
34
- 'lang' : {
35
- 'confirm' : 'Yes' ,
36
- 'cancel' : 'Cancel'
37
- } ,
38
34
'settings' : {
39
- 'version' : '3.0.beta1 ' , // this is required to flush storage on new releases
35
+ 'version' : '3.0.0 ' , // this is required to flush storage on new releases
40
36
'toolbar' : 'expanded' , // expanded or collapsed
41
37
'mode' : 'edit' , // live, draft, edit or layout
42
38
'states' : [ ] ,
@@ -53,7 +49,6 @@ $(document).ready(function () {
53
49
this . container = $ ( container ) ;
54
50
this . options = $ . extend ( true , { } , this . options , options ) ;
55
51
this . settings = this . getSettings ( ) || this . setSettings ( this . options . settings ) ;
56
-
57
52
// class variables
58
53
this . toolbar = this . container . find ( '.cms_toolbar' ) ;
59
54
this . toolbar . hide ( ) ;
@@ -111,11 +106,14 @@ $(document).ready(function () {
111
106
112
107
// add toolbar ready class to body
113
108
$ ( 'body' ) . addClass ( 'cms_toolbar-ready' ) ;
109
+
110
+ // check if debug is true
111
+ if ( this . options . debug ) this . _debug ( ) ;
114
112
} ,
115
113
116
114
_load : function ( ) {
117
115
// reset some settings if not authenticated
118
- if ( ! this . options . authenticated ) this . reset ( ) ;
116
+ if ( ! this . options . authenticated ) this . _reset ( ) ;
119
117
// check if we should show the sideframe
120
118
if ( this . settings . sideframe . url ) {
121
119
this . openSideframe ( this . settings . sideframe . url , false ) ;
@@ -128,7 +126,7 @@ $(document).ready(function () {
128
126
// attach event to the trigger handler
129
127
this . toolbarTrigger . bind ( 'click' , function ( e ) {
130
128
e . preventDefault ( ) ;
131
- that . toggleToolbar ( 200 ) ;
129
+ that . toggleToolbar ( ) ;
132
130
} ) ;
133
131
134
132
// attach event to the navigation elements
@@ -137,15 +135,15 @@ $(document).ready(function () {
137
135
// attach delegate event
138
136
item . find ( 'li ul a' ) . bind ( 'click' , function ( e ) {
139
137
e . preventDefault ( ) ;
140
- if ( ! $ ( this ) . parent ( ) . hasClass ( 'cms_toolbar-item-navigation-disabled' ) ) that . delegate ( $ ( this ) ) ;
138
+ if ( ! $ ( this ) . parent ( ) . hasClass ( 'cms_toolbar-item-navigation-disabled' ) ) that . _delegate ( $ ( this ) ) ;
141
139
} ) ;
142
140
// remove events from first level
143
141
item . find ( '> li > a' ) . bind ( 'click' , function ( e ) {
144
142
e . preventDefault ( ) ;
145
143
if ( $ ( this ) . attr ( 'href' ) !== ''
146
144
&& $ ( this ) . attr ( 'href' ) !== '#'
147
145
&& ! $ ( this ) . parent ( ) . hasClass ( 'cms_toolbar-item-navigation-disabled' )
148
- && ! $ ( this ) . parent ( ) . hasClass ( 'cms_toolbar-item-navigation-disabled' ) ) that . delegate ( $ ( this ) ) ;
146
+ && ! $ ( this ) . parent ( ) . hasClass ( 'cms_toolbar-item-navigation-disabled' ) ) that . _delegate ( $ ( this ) ) ;
149
147
} ) ;
150
148
151
149
// handle states
@@ -275,13 +273,17 @@ $(document).ready(function () {
275
273
} ,
276
274
277
275
// public methods
278
- toggleToolbar : function ( speed ) {
279
- ( this . settings . toolbar === 'collapsed' ) ? this . _showToolbar ( speed ) : this . _hideToolbar ( speed ) ;
276
+ toggleToolbar : function ( show ) {
277
+ // overwrite state when provided
278
+ if ( show ) this . settings . toolbar = 'collapsed' ;
279
+ // toggle bar
280
+ ( this . settings . toolbar === 'collapsed' ) ? this . _showToolbar ( 200 ) : this . _hideToolbar ( 200 ) ;
280
281
} ,
281
282
282
283
setSettings : function ( settings ) {
283
284
// cancel if local storage is not available
284
285
if ( ! window . localStorage ) return false ;
286
+
285
287
// set settings
286
288
settings = $ . extend ( true , { } , this . settings , settings ) ;
287
289
// save inside local storage
@@ -301,47 +303,15 @@ $(document).ready(function () {
301
303
resetSettings : function ( ) {
302
304
// cancel if local storage is not available
303
305
if ( ! window . localStorage ) return false ;
306
+
304
307
// reset settings
305
- localStorage . removeItem ( 'cms_cookie' ) ;
306
- this . setSettings ( this . options . settings ) ;
308
+ window . localStorage . removeItem ( 'cms_cookie' ) ;
309
+ this . settings = this . setSettings ( this . options . settings ) ;
310
+
307
311
// enforce reload to apply changes
308
312
CMS . API . Helpers . reloadBrowser ( ) ;
309
313
} ,
310
314
311
- delegate : function ( el ) {
312
- // save local vars
313
- var target = el . attr ( 'data-rel' ) ;
314
-
315
- // reset states
316
- this . reset ( ) ;
317
-
318
- switch ( target ) {
319
- case 'modal' :
320
- this . openModal ( el . attr ( 'href' ) , el . attr ( 'data-name' ) ) ;
321
- break ;
322
- case 'message' :
323
- this . openMessage ( el . attr ( 'data-text' ) ) ;
324
- break ;
325
- case 'sideframe' :
326
- this . openSideframe ( el . attr ( 'href' ) , true ) ;
327
- break ;
328
- case 'ajax' :
329
- this . openAjax ( el . attr ( 'href' ) , el . attr ( 'data-post' ) , el . attr ( 'data-text' ) ) ;
330
- break ;
331
- default :
332
- window . location . href = el . attr ( 'href' ) ;
333
- }
334
- } ,
335
-
336
- reset : function ( ) {
337
- // reset sideframe settings
338
- this . settings . sideframe = {
339
- 'url' : null ,
340
- 'hidden' : false ,
341
- 'maximized' : this . settings . sideframe . maximized // we need to keep the default value
342
- } ;
343
- } ,
344
-
345
315
openSideframe : function ( url , animate ) {
346
316
// prepare iframe
347
317
var that = this ;
@@ -366,6 +336,9 @@ $(document).ready(function () {
366
336
that . enforceReload = false ;
367
337
}
368
338
339
+ // add debug infos
340
+ if ( that . options . debug ) iframe . contents ( ) . find ( 'body' ) . addClass ( 'cms_debug' ) ;
341
+
369
342
// save url in settings
370
343
that . settings . sideframe . url = iframe . get ( 0 ) . contentWindow . location . href ;
371
344
that . setSettings ( ) ;
@@ -429,6 +402,9 @@ $(document).ready(function () {
429
402
// set top to 0 if toolbar is collapsed
430
403
if ( this . settings . toolbar === 'collapsed' ) top = 0 ;
431
404
405
+ // do we need to add debug styles?
406
+ if ( this . options . debug ) top = top + 5 ;
407
+
432
408
// set correct position and show
433
409
this . messages . css ( 'top' , - height ) . show ( ) ;
434
410
@@ -538,7 +514,7 @@ $(document).ready(function () {
538
514
'type' : 'POST' ,
539
515
'url' : url ,
540
516
'data' : ( post ) ? JSON . parse ( post ) : { } ,
541
- 'success' : function ( data ) {
517
+ 'success' : function ( ) {
542
518
CMS . API . Helpers . reloadBrowser ( ) ;
543
519
} ,
544
520
'error' : function ( jqXHR ) {
@@ -574,6 +550,10 @@ $(document).ready(function () {
574
550
if ( bound - pos <= 0 ) $ ( window ) . scrollTop ( pos - offset ) ;
575
551
} ,
576
552
553
+ showError : function ( msg ) {
554
+ this . openMessage ( msg , 'center' , this . options . messageDelay , true ) ;
555
+ } ,
556
+
577
557
// private methods
578
558
_showToolbar : function ( speed , init ) {
579
559
this . toolbarTrigger . addClass ( 'cms_toolbar-trigger-expanded' ) ;
@@ -678,6 +658,40 @@ $(document).ready(function () {
678
658
} , duration ) ;
679
659
} ,
680
660
661
+ _delegate : function ( el ) {
662
+ // save local vars
663
+ var target = el . attr ( 'data-rel' ) ;
664
+
665
+ // reset states
666
+ this . _reset ( ) ;
667
+
668
+ switch ( target ) {
669
+ case 'modal' :
670
+ this . openModal ( el . attr ( 'href' ) , el . attr ( 'data-name' ) ) ;
671
+ break ;
672
+ case 'message' :
673
+ this . openMessage ( el . attr ( 'data-text' ) ) ;
674
+ break ;
675
+ case 'sideframe' :
676
+ this . openSideframe ( el . attr ( 'href' ) , true ) ;
677
+ break ;
678
+ case 'ajax' :
679
+ this . openAjax ( el . attr ( 'href' ) , el . attr ( 'data-post' ) , el . attr ( 'data-text' ) ) ;
680
+ break ;
681
+ default :
682
+ window . location . href = el . attr ( 'href' ) ;
683
+ }
684
+ } ,
685
+
686
+ _reset : function ( ) {
687
+ // reset sideframe settings
688
+ this . settings . sideframe = {
689
+ 'url' : null ,
690
+ 'hidden' : false ,
691
+ 'maximized' : this . settings . sideframe . maximized // we need to keep the default value
692
+ } ;
693
+ } ,
694
+
681
695
_showSideframe : function ( width , animate ) {
682
696
// add class
683
697
this . sideframe . find ( '.cms_sideframe-hide' ) . removeClass ( 'cms_sideframe-hidden' ) ;
@@ -832,7 +846,7 @@ $(document).ready(function () {
832
846
833
847
this . modal . css ( {
834
848
'left' : this . toolbar . find ( '.cms_toolbar-left' ) . outerWidth ( true ) + 50 ,
835
- 'top' : 1 ,
849
+ 'top' : ( this . options . debug ) ? 6 : 1 ,
836
850
'margin' : 0
837
851
} ) ;
838
852
@@ -850,6 +864,7 @@ $(document).ready(function () {
850
864
} ,
851
865
852
866
_maximizeModal : function ( ) {
867
+ var debug = ( this . options . debug ) ? 5 : 0 ;
853
868
var container = this . modal . find ( '.cms_modal-body' ) ;
854
869
var trigger = this . modal . find ( '.cms_modal-maximize' ) ;
855
870
var btnCk = this . modal . find ( 'iframe' ) . contents ( ) . find ( '.cke_button__maximize' ) ;
@@ -875,14 +890,14 @@ $(document).ready(function () {
875
890
// reset
876
891
this . modal . css ( {
877
892
'left' : 0 ,
878
- 'top' : 0 ,
893
+ 'top' : debug ,
879
894
'margin' : 0
880
895
} ) ;
881
896
// bind resize event
882
897
$ ( window ) . bind ( 'resize.cms.modal' , function ( ) {
883
898
container . css ( {
884
899
'width' : $ ( window ) . width ( ) ,
885
- 'height' : $ ( window ) . height ( ) - 60
900
+ 'height' : $ ( window ) . height ( ) - 60 - debug
886
901
} ) ;
887
902
} ) ;
888
903
$ ( window ) . trigger ( 'resize.cms.modal' ) ;
@@ -1141,8 +1156,25 @@ $(document).ready(function () {
1141
1156
this . modal . find ( '.cms_modal-title' ) . text ( el . text ( ) ) ;
1142
1157
} ,
1143
1158
1144
- showError : function ( msg ) {
1145
- this . openMessage ( msg , 'center' , this . options . messageDelay , true ) ;
1159
+ _debug : function ( ) {
1160
+ var that = this ;
1161
+ var timeout = 1000 ;
1162
+ var timer = function ( ) { } ;
1163
+
1164
+ // add top margin
1165
+ $ ( 'html' ) . css ( 'margin-top' , 5 ) ;
1166
+
1167
+ // bind message event
1168
+ var debug = this . container . find ( '.cms_debug-bar' ) ;
1169
+ debug . bind ( 'mouseenter mouseleave' , function ( e ) {
1170
+ clearTimeout ( timer ) ;
1171
+
1172
+ if ( e . type === 'mouseenter' ) {
1173
+ timer = setTimeout ( function ( ) {
1174
+ that . openMessage ( that . options . lang . debug ) ;
1175
+ } , timeout ) ;
1176
+ }
1177
+ } ) ;
1146
1178
}
1147
1179
1148
1180
} ) ;
0 commit comments