Skip to content

Commit 7c280d1

Browse files
author
Angelo Dini
committed
Merge pull request django-cms#2065 from FinalAngel/feature/fixes
Visual Debug Information
2 parents 7ff02b2 + 55675e3 commit 7c280d1

File tree

12 files changed

+125
-66
lines changed

12 files changed

+125
-66
lines changed

cms/static/cms/css/plugins/cms.toolbar.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cms/static/cms/css/plugins/cms.toolbar.sideframe.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
343 Bytes
Loading
-252 Bytes
Loading

cms/static/cms/js/plugins/cms.placeholders.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ $(document).ready(function () {
136136
'cursor': 'move',
137137
'opacity': 0.4,
138138
'zIndex': 999999,
139+
'delay': 150,
139140
// nestedSortable
140141
'listType': 'div.cms_draggables',
141142
'doNotClear': true,
@@ -350,7 +351,8 @@ $(document).ready(function () {
350351
'add_plugin': '',
351352
'edit_plugin': '',
352353
'move_plugin': '',
353-
'copy_plugin': ''
354+
'copy_plugin': '',
355+
'cut_plugin': ''
354356
}
355357
},
356358

@@ -557,7 +559,7 @@ $(document).ready(function () {
557559
$('.cms_btn-publish').addClass('cms_btn-publish-active').parent().show();
558560
},
559561

560-
copyPlugin: function () {
562+
copyPlugin: function (cut) {
561563
var that = this;
562564
var data = {
563565
'source_placeholder_id': this.options.placeholder_id,
@@ -568,9 +570,12 @@ $(document).ready(function () {
568570
'csrfmiddlewaretoken': this.csrf
569571
};
570572

573+
// determine if we are using copy or cut
574+
var url = (cut) ? this.options.urls.cut_plugin : this.options.urls.copy_plugin;
575+
571576
$.ajax({
572577
'type': 'POST',
573-
'url': this.options.urls.copy_plugin,
578+
'url': url,
574579
'data': data,
575580
'success': function () {
576581
// refresh browser after success
@@ -749,7 +754,7 @@ $(document).ready(function () {
749754
},
750755

751756
_delegate: function (el) {
752-
return CMS.API.Toolbar.delegate(el);
757+
return CMS.API.Toolbar._delegate(el);
753758
}
754759

755760
});

cms/static/cms/js/plugins/cms.toolbar.js

Lines changed: 86 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,8 @@ $(document).ready(function () {
3131
'css_modal': 'cms/css/plugins/cms.toolbar.modal.css',
3232
'css_sideframe': 'cms/css/plugins/cms.toolbar.sideframe.css'
3333
},
34-
'lang': {
35-
'confirm': 'Yes',
36-
'cancel': 'Cancel'
37-
},
3834
'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
4036
'toolbar': 'expanded', // expanded or collapsed
4137
'mode': 'edit', // live, draft, edit or layout
4238
'states': [],
@@ -53,7 +49,6 @@ $(document).ready(function () {
5349
this.container = $(container);
5450
this.options = $.extend(true, {}, this.options, options);
5551
this.settings = this.getSettings() || this.setSettings(this.options.settings);
56-
5752
// class variables
5853
this.toolbar = this.container.find('.cms_toolbar');
5954
this.toolbar.hide();
@@ -111,11 +106,14 @@ $(document).ready(function () {
111106

112107
// add toolbar ready class to body
113108
$('body').addClass('cms_toolbar-ready');
109+
110+
// check if debug is true
111+
if(this.options.debug) this._debug();
114112
},
115113

116114
_load: function () {
117115
// reset some settings if not authenticated
118-
if(!this.options.authenticated) this.reset();
116+
if(!this.options.authenticated) this._reset();
119117
// check if we should show the sideframe
120118
if(this.settings.sideframe.url) {
121119
this.openSideframe(this.settings.sideframe.url, false);
@@ -128,7 +126,7 @@ $(document).ready(function () {
128126
// attach event to the trigger handler
129127
this.toolbarTrigger.bind('click', function (e) {
130128
e.preventDefault();
131-
that.toggleToolbar(200);
129+
that.toggleToolbar();
132130
});
133131

134132
// attach event to the navigation elements
@@ -137,15 +135,15 @@ $(document).ready(function () {
137135
// attach delegate event
138136
item.find('li ul a').bind('click', function (e) {
139137
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));
141139
});
142140
// remove events from first level
143141
item.find('> li > a').bind('click', function (e) {
144142
e.preventDefault();
145143
if($(this).attr('href') !== ''
146144
&& $(this).attr('href') !== '#'
147145
&& !$(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));
149147
});
150148

151149
// handle states
@@ -275,13 +273,17 @@ $(document).ready(function () {
275273
},
276274

277275
// 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);
280281
},
281282

282283
setSettings: function (settings) {
283284
// cancel if local storage is not available
284285
if(!window.localStorage) return false;
286+
285287
// set settings
286288
settings = $.extend(true, {}, this.settings, settings);
287289
// save inside local storage
@@ -301,47 +303,15 @@ $(document).ready(function () {
301303
resetSettings: function () {
302304
// cancel if local storage is not available
303305
if(!window.localStorage) return false;
306+
304307
// 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+
307311
// enforce reload to apply changes
308312
CMS.API.Helpers.reloadBrowser();
309313
},
310314

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-
345315
openSideframe: function (url, animate) {
346316
// prepare iframe
347317
var that = this;
@@ -366,6 +336,9 @@ $(document).ready(function () {
366336
that.enforceReload = false;
367337
}
368338

339+
// add debug infos
340+
if(that.options.debug) iframe.contents().find('body').addClass('cms_debug');
341+
369342
// save url in settings
370343
that.settings.sideframe.url = iframe.get(0).contentWindow.location.href;
371344
that.setSettings();
@@ -429,6 +402,9 @@ $(document).ready(function () {
429402
// set top to 0 if toolbar is collapsed
430403
if(this.settings.toolbar === 'collapsed') top = 0;
431404

405+
// do we need to add debug styles?
406+
if(this.options.debug) top = top + 5;
407+
432408
// set correct position and show
433409
this.messages.css('top', -height).show();
434410

@@ -538,7 +514,7 @@ $(document).ready(function () {
538514
'type': 'POST',
539515
'url': url,
540516
'data': (post) ? JSON.parse(post) : {},
541-
'success': function (data) {
517+
'success': function () {
542518
CMS.API.Helpers.reloadBrowser();
543519
},
544520
'error': function (jqXHR) {
@@ -574,6 +550,10 @@ $(document).ready(function () {
574550
if(bound - pos <= 0) $(window).scrollTop(pos - offset);
575551
},
576552

553+
showError: function (msg) {
554+
this.openMessage(msg, 'center', this.options.messageDelay, true);
555+
},
556+
577557
// private methods
578558
_showToolbar: function (speed, init) {
579559
this.toolbarTrigger.addClass('cms_toolbar-trigger-expanded');
@@ -678,6 +658,40 @@ $(document).ready(function () {
678658
}, duration);
679659
},
680660

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+
681695
_showSideframe: function (width, animate) {
682696
// add class
683697
this.sideframe.find('.cms_sideframe-hide').removeClass('cms_sideframe-hidden');
@@ -832,7 +846,7 @@ $(document).ready(function () {
832846

833847
this.modal.css({
834848
'left': this.toolbar.find('.cms_toolbar-left').outerWidth(true) + 50,
835-
'top': 1,
849+
'top': (this.options.debug) ? 6 : 1,
836850
'margin': 0
837851
});
838852

@@ -850,6 +864,7 @@ $(document).ready(function () {
850864
},
851865

852866
_maximizeModal: function () {
867+
var debug = (this.options.debug) ? 5 : 0;
853868
var container = this.modal.find('.cms_modal-body');
854869
var trigger = this.modal.find('.cms_modal-maximize');
855870
var btnCk = this.modal.find('iframe').contents().find('.cke_button__maximize');
@@ -875,14 +890,14 @@ $(document).ready(function () {
875890
// reset
876891
this.modal.css({
877892
'left': 0,
878-
'top': 0,
893+
'top': debug,
879894
'margin': 0
880895
});
881896
// bind resize event
882897
$(window).bind('resize.cms.modal', function () {
883898
container.css({
884899
'width': $(window).width(),
885-
'height': $(window).height() - 60
900+
'height': $(window).height() - 60 - debug
886901
});
887902
});
888903
$(window).trigger('resize.cms.modal');
@@ -1141,8 +1156,25 @@ $(document).ready(function () {
11411156
this.modal.find('.cms_modal-title').text(el.text());
11421157
},
11431158

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+
});
11461178
}
11471179

11481180
});

cms/static/cms/sass/plugins/cms.toolbar.scss

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,18 @@
2323
//######################################################################################################################
2424
// #TOOLBAR#
2525

26-
#cms_toolbar { position:absolute; left:0; top:0; z-index:9999999; width:100%; }
26+
// debug mode
27+
.cms_toolbar-debug {
28+
.cms_toolbar { top:5px !important; }
29+
.cms_toolbar-trigger { top:5px !important; }
30+
31+
.cms_debug-bar { position:fixed; left:0; top:0; z-index:99999999; width:100%; height:4px;
32+
border-bottom:1px solid #ddd; background:#fdffc8 url('../../img/toolbar/sprite_toolbar.png') repeat-x left -444px; }
33+
}
34+
.cms_toolbar-debug #container { padding-top:35px !important; }
35+
36+
// toolbar
37+
#cms_toolbar { position:absolute; left:0; top:5px; z-index:9999999; width:100%; }
2738
#cms_toolbar {
2839
.cms_toolbar { display:none; position:fixed; left:0; top:0; z-index:999999; width:100%; min-width:320px; height:30px;
2940
border-bottom:1px solid $color-grey !important; background:$color-grey-5;

cms/static/cms/sass/plugins/cms.toolbar.sideframe.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
// #SIDEFRAME#
1212
#header { display:none; }
1313
#container { padding-top:30px; }
14+
.cms_debug #container { padding-top:35px; }
15+
1416
#container .breadcrumbs { display:block; background:$color-grey !important; }
1517
#content { padding-top:10px; }
1618

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
{% load i18n %}
2-
<div class="cms_toolbar-item cms_toolbar-item-logo"><a href="/">{% trans "django CMS" %}</a></div>
2+
<div class="cms_toolbar-item cms_toolbar-item-logo"><a href="/" title="{{ cms_version }}">{% trans "django CMS" %}</a></div>

cms/templates/cms/toolbar/plugin.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
'edit_plugin': '{% url "admin:cms_page_edit_plugin" instance.pk %}',
2222
'move_plugin': '{% url "admin:cms_page_move_plugin" %}',
2323
'copy_plugin': '{% url "admin:cms_page_copy_plugins" %}',
24+
{% comment %}'cut_plugin': '{% url "admin:cms_page_cut_plugins" %}',{% endcomment %}
2425
'stack_plugin': ''
2526
}
2627
});

0 commit comments

Comments
 (0)