2011-05-20 01:38:36 +02:00
|
|
|
(function($) {
|
|
|
|
|
|
|
|
$.entwine('ss', function($){
|
2016-01-06 00:34:58 +01:00
|
|
|
|
2011-07-05 11:34:37 +02:00
|
|
|
/**
|
|
|
|
* The "content" area contains all of the section specific UI (excluding the menu).
|
|
|
|
* This area can be a form itself, as well as contain one or more forms.
|
2016-01-06 00:34:58 +01:00
|
|
|
* For example, a page edit form might fill the whole area,
|
2011-07-05 11:34:37 +02:00
|
|
|
* while a ModelAdmin layout shows a search form on the left, and edit form on the right.
|
|
|
|
*/
|
2011-07-05 14:34:31 +02:00
|
|
|
$('.cms-content').entwine({
|
2016-01-06 00:34:58 +01:00
|
|
|
|
2012-06-12 12:48:08 +02:00
|
|
|
onadd: function() {
|
2011-06-08 01:35:56 +02:00
|
|
|
var self = this;
|
2016-01-06 00:34:58 +01:00
|
|
|
|
2012-06-06 14:35:07 +02:00
|
|
|
// Force initialization of certain UI elements to avoid layout glitches
|
2012-04-17 17:40:37 +02:00
|
|
|
this.find('.cms-tabset').redrawTabs();
|
2011-06-08 01:35:56 +02:00
|
|
|
this._super();
|
2012-11-21 22:01:02 +01:00
|
|
|
|
2011-06-08 01:35:56 +02:00
|
|
|
},
|
2012-06-12 12:48:08 +02:00
|
|
|
|
2011-07-21 18:39:26 +02:00
|
|
|
redraw: function() {
|
2012-05-30 20:57:18 +02:00
|
|
|
if(window.debug) console.log('redraw', this.attr('class'), this.get(0));
|
2016-01-06 00:34:58 +01:00
|
|
|
|
2012-06-06 21:02:13 +02:00
|
|
|
// Force initialization of certain UI elements to avoid layout glitches
|
2012-04-17 17:40:37 +02:00
|
|
|
this.add(this.find('.cms-tabset')).redrawTabs();
|
2012-06-06 14:35:07 +02:00
|
|
|
this.find('.cms-content-header').redraw();
|
2012-06-06 21:02:13 +02:00
|
|
|
this.find('.cms-content-actions').redraw();
|
2011-05-20 01:38:36 +02:00
|
|
|
}
|
|
|
|
});
|
2012-02-15 17:40:27 +01:00
|
|
|
|
2012-05-11 05:31:12 +02:00
|
|
|
/**
|
|
|
|
* Load edit form for the selected node when its clicked.
|
|
|
|
*/
|
|
|
|
$('.cms-content .cms-tree').entwine({
|
2012-06-12 12:48:08 +02:00
|
|
|
onadd: function() {
|
2012-05-11 05:31:12 +02:00
|
|
|
var self = this;
|
2012-02-15 17:40:27 +01:00
|
|
|
|
2012-05-11 05:31:12 +02:00
|
|
|
this._super();
|
2012-02-15 17:40:27 +01:00
|
|
|
|
2012-05-11 05:31:12 +02:00
|
|
|
this.bind('select_node.jstree', function(e, data) {
|
|
|
|
var node = data.rslt.obj, loadedNodeID = self.find(':input[name=ID]').val(), origEvent = data.args[2], container = $('.cms-container');
|
2016-01-06 00:34:58 +01:00
|
|
|
|
2012-05-11 05:31:12 +02:00
|
|
|
// Don't trigger unless coming from a click event.
|
|
|
|
// Avoids problems with automated section switches from tree to detail view
|
|
|
|
// when JSTree auto-selects elements on first load.
|
|
|
|
if(!origEvent) {
|
|
|
|
return false;
|
|
|
|
}
|
2016-01-06 00:34:58 +01:00
|
|
|
|
2012-05-11 05:31:12 +02:00
|
|
|
// Don't allow checking disabled nodes
|
|
|
|
if($(node).hasClass('disabled')) return false;
|
|
|
|
|
|
|
|
// Don't allow reloading of currently selected node,
|
|
|
|
// mainly to avoid doing an ajax request on initial page load
|
|
|
|
if($(node).data('id') == loadedNodeID) return;
|
|
|
|
|
|
|
|
var url = $(node).find('a:first').attr('href');
|
|
|
|
if(url && url != '#') {
|
2013-10-14 15:33:40 +02:00
|
|
|
// strip possible querystrings from the url to avoid duplicateing document.location.search
|
|
|
|
url = url.split('?')[0];
|
2016-01-06 00:34:58 +01:00
|
|
|
|
2012-06-03 18:10:57 +02:00
|
|
|
// Deselect all nodes (will be reselected after load according to form state)
|
|
|
|
self.jstree('deselect_all');
|
|
|
|
self.jstree('uncheck_all');
|
2012-05-11 05:31:12 +02:00
|
|
|
|
|
|
|
// Ensure URL is absolute (important for IE)
|
|
|
|
if($.path.isExternal($(node).find('a:first'))) url = url = $.path.makeUrlAbsolute(url, $('base').attr('href'));
|
|
|
|
// Retain search parameters
|
|
|
|
if(document.location.search) url = $.path.addSearchParams(url, document.location.search.replace(/^\?/, ''));
|
|
|
|
// Load new page
|
2016-01-06 00:34:58 +01:00
|
|
|
container.loadPanel(url);
|
2012-05-11 05:31:12 +02:00
|
|
|
} else {
|
|
|
|
self.removeForm();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2012-06-06 14:35:07 +02:00
|
|
|
|
2012-06-06 21:02:13 +02:00
|
|
|
$('.cms-content .cms-content-fields').entwine({
|
2012-06-06 14:35:07 +02:00
|
|
|
redraw: function() {
|
|
|
|
if(window.debug) console.log('redraw', this.attr('class'), this.get(0));
|
2012-06-06 21:02:13 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2012-06-06 14:35:07 +02:00
|
|
|
$('.cms-content .cms-content-header, .cms-content .cms-content-actions').entwine({
|
|
|
|
redraw: function() {
|
|
|
|
if(window.debug) console.log('redraw', this.attr('class'), this.get(0));
|
|
|
|
|
|
|
|
// Fix dimensions to actual extents, in preparation for a relayout via jslayout.
|
2012-11-22 04:30:50 +01:00
|
|
|
this.height('auto');
|
2012-06-06 14:35:07 +02:00
|
|
|
this.height(this.innerHeight()-this.css('padding-top')-this.css('padding-bottom'));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-01-06 00:34:58 +01:00
|
|
|
|
2011-07-15 10:37:46 +02:00
|
|
|
});
|
2012-02-15 19:32:23 +01:00
|
|
|
|
2012-04-03 01:29:44 +02:00
|
|
|
})(jQuery);
|