silverstripe-framework/admin/client/dist/js/LeftAndMain.Content.js

97 lines
2.7 KiB
JavaScript
Raw Normal View History

(function (global, factory) {
2016-07-13 04:43:07 +02:00
if (typeof define === "function" && define.amd) {
define('ss.LeftAndMain.Content', ['jQuery'], factory);
} else if (typeof exports !== "undefined") {
factory(require('jQuery'));
} else {
var mod = {
exports: {}
};
factory(global.jQuery);
global.ssLeftAndMainContent = mod.exports;
}
})(this, function (_jQuery) {
2016-07-13 04:43:07 +02:00
'use strict';
2016-07-13 04:43:07 +02:00
var _jQuery2 = _interopRequireDefault(_jQuery);
2016-07-13 04:43:07 +02:00
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
2016-07-13 04:43:07 +02:00
_jQuery2.default.entwine('ss', function ($) {
$('.cms-content').entwine({
2016-07-13 04:43:07 +02:00
onadd: function onadd() {
var self = this;
2016-07-13 04:43:07 +02:00
this.find('.cms-tabset').redrawTabs();
this._super();
},
2016-07-13 04:43:07 +02:00
redraw: function redraw() {
if (window.debug) console.log('redraw', this.attr('class'), this.get(0));
2016-07-13 04:43:07 +02:00
this.add(this.find('.cms-tabset')).redrawTabs();
this.find('.cms-content-header').redraw();
this.find('.cms-content-actions').redraw();
}
});
2016-07-13 04:43:07 +02:00
$('.cms-content .cms-tree').entwine({
onadd: function onadd() {
var self = this;
2016-07-13 04:43:07 +02:00
this._super();
2016-07-13 04:43:07 +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-07-13 04:43:07 +02:00
if (!origEvent) {
return false;
}
2016-07-13 04:43:07 +02:00
if ($(node).hasClass('disabled')) return false;
2016-07-13 04:43:07 +02:00
if ($(node).data('id') == loadedNodeID) return;
2016-07-13 04:43:07 +02:00
var url = $(node).find('a:first').attr('href');
if (url && url != '#') {
url = url.split('?')[0];
2016-07-13 04:43:07 +02:00
self.jstree('deselect_all');
self.jstree('uncheck_all');
2016-07-13 04:43:07 +02:00
if ($.path.isExternal($(node).find('a:first'))) url = url = $.path.makeUrlAbsolute(url, $('base').attr('href'));
2016-07-13 04:43:07 +02:00
if (document.location.search) url = $.path.addSearchParams(url, document.location.search.replace(/^\?/, ''));
2016-07-13 04:43:07 +02:00
container.loadPanel(url);
} else {
self.removeForm();
}
});
}
});
2016-07-13 04:43:07 +02:00
$('.cms-content .cms-content-fields').entwine({
redraw: function redraw() {
if (window.debug) console.log('redraw', this.attr('class'), this.get(0));
}
});
2016-07-13 04:43:07 +02:00
$('.cms-content .cms-content-header, .cms-content .cms-content-actions').entwine({
redraw: function redraw() {
if (window.debug) console.log('redraw', this.attr('class'), this.get(0));
2016-07-13 04:43:07 +02:00
this.height('auto');
this.height(this.innerHeight() - this.css('padding-top') - this.css('padding-bottom'));
}
});
});
});