Merge pull request #5379 from open-sausages/pulls/4.0/fix-ie-routing

BUG Fix baseurl in IE missing leading /
This commit is contained in:
Ingo Schommer 2016-04-25 22:33:06 +12:00
commit c75a8d35e0
3 changed files with 2528 additions and 2522 deletions

View File

@ -1,1138 +1,1141 @@
(function (global, factory) { (function (global, factory) {
if (typeof define === "function" && define.amd) { if (typeof define === "function" && define.amd) {
define('ss.LeftAndMain', ['jQuery', 'lib/Router', 'lib/Config'], factory); define('ss.LeftAndMain', ['jQuery', 'lib/Router', 'lib/Config'], factory);
} else if (typeof exports !== "undefined") { } else if (typeof exports !== "undefined") {
factory(require('jQuery'), require('lib/Router'), require('lib/Config')); factory(require('jQuery'), require('lib/Router'), require('lib/Config'));
} else { } else {
var mod = { var mod = {
exports: {} exports: {}
}; };
factory(global.jQuery, global.Router, global.Config); factory(global.jQuery, global.Router, global.Config);
global.ssLeftAndMain = mod.exports; global.ssLeftAndMain = mod.exports;
} }
})(this, function (_jQuery, _Router, _Config) { })(this, function (_jQuery, _Router, _Config) {
'use strict'; 'use strict';
var _jQuery2 = _interopRequireDefault(_jQuery); var _jQuery2 = _interopRequireDefault(_jQuery);
var _Router2 = _interopRequireDefault(_Router); var _Router2 = _interopRequireDefault(_Router);
var _Config2 = _interopRequireDefault(_Config); var _Config2 = _interopRequireDefault(_Config);
function _interopRequireDefault(obj) { function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { return obj && obj.__esModule ? obj : {
default: obj default: obj
}; };
} }
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
return typeof obj; return typeof obj;
} : function (obj) { } : function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj;
}; };
var windowWidth, windowHeight; var windowWidth, windowHeight;
_jQuery2.default.noConflict(); _jQuery2.default.noConflict();
window.ss = window.ss || {}; window.ss = window.ss || {};
window.ss.router = _Router2.default; window.ss.router = _Router2.default;
window.ss.debounce = function (func, wait, immediate) { window.ss.debounce = function (func, wait, immediate) {
var timeout, context, args; var timeout, context, args;
var later = function later() { var later = function later() {
timeout = null; timeout = null;
if (!immediate) func.apply(context, args); if (!immediate) func.apply(context, args);
}; };
return function () { return function () {
var callNow = immediate && !timeout; var callNow = immediate && !timeout;
context = this; context = this;
args = arguments; args = arguments;
clearTimeout(timeout); clearTimeout(timeout);
timeout = setTimeout(later, wait); timeout = setTimeout(later, wait);
if (callNow) { if (callNow) {
func.apply(context, args); func.apply(context, args);
} }
}; };
}; };
function getUrlPath(url) { function getUrlPath(url) {
var anchor = document.createElement('a'); var anchor = document.createElement('a');
anchor.href = url; anchor.href = url;
return anchor.pathname; return anchor.pathname;
} }
(0, _jQuery2.default)(window).bind('resize.leftandmain', function (e) { (0, _jQuery2.default)(window).bind('resize.leftandmain', function (e) {
(0, _jQuery2.default)('.cms-container').trigger('windowresize'); (0, _jQuery2.default)('.cms-container').trigger('windowresize');
}); });
_jQuery2.default.entwine.warningLevel = _jQuery2.default.entwine.WARN_LEVEL_BESTPRACTISE; _jQuery2.default.entwine.warningLevel = _jQuery2.default.entwine.WARN_LEVEL_BESTPRACTISE;
_jQuery2.default.entwine('ss', function ($) { _jQuery2.default.entwine('ss', function ($) {
$(window).on("message", function (e) { $(window).on("message", function (e) {
var target, var target,
event = e.originalEvent, event = e.originalEvent,
data = _typeof(event.data) === 'object' ? event.data : JSON.parse(event.data); data = _typeof(event.data) === 'object' ? event.data : JSON.parse(event.data);
if ($.path.parseUrl(window.location.href).domain !== $.path.parseUrl(event.origin).domain) return; if ($.path.parseUrl(window.location.href).domain !== $.path.parseUrl(event.origin).domain) return;
target = typeof data.target === 'undefined' ? $(window) : $(data.target); target = typeof data.target === 'undefined' ? $(window) : $(data.target);
switch (data.type) { switch (data.type) {
case 'event': case 'event':
target.trigger(data.event, data.data); target.trigger(data.event, data.data);
break; break;
case 'callback': case 'callback':
target[data.callback].call(target, data.data); target[data.callback].call(target, data.data);
break; break;
} }
}); });
var positionLoadingSpinner = function positionLoadingSpinner() { var positionLoadingSpinner = function positionLoadingSpinner() {
var offset = 120; var offset = 120;
var spinner = $('.ss-loading-screen .loading-animation'); var spinner = $('.ss-loading-screen .loading-animation');
var top = ($(window).height() - spinner.height()) / 2; var top = ($(window).height() - spinner.height()) / 2;
spinner.css('top', top + offset); spinner.css('top', top + offset);
spinner.show(); spinner.show();
}; };
var applyChosen = function applyChosen(el) { var applyChosen = function applyChosen(el) {
if (el.is(':visible')) { if (el.is(':visible')) {
el.addClass('has-chosen').chosen({ el.addClass('has-chosen').chosen({
allow_single_deselect: true, allow_single_deselect: true,
disable_search_threshold: 20, disable_search_threshold: 20,
display_disabled_options: true display_disabled_options: true
}); });
} else { } else {
setTimeout(function () { setTimeout(function () {
el.show(); el.show();
applyChosen(el); applyChosen(el);
}, 500); }, 500);
} }
}; };
var isSameUrl = function isSameUrl(url1, url2) { var isSameUrl = function isSameUrl(url1, url2) {
var baseUrl = $('base').attr('href'); var baseUrl = $('base').attr('href');
url1 = $.path.isAbsoluteUrl(url1) ? url1 : $.path.makeUrlAbsolute(url1, baseUrl), url2 = $.path.isAbsoluteUrl(url2) ? url2 : $.path.makeUrlAbsolute(url2, baseUrl); url1 = $.path.isAbsoluteUrl(url1) ? url1 : $.path.makeUrlAbsolute(url1, baseUrl), url2 = $.path.isAbsoluteUrl(url2) ? url2 : $.path.makeUrlAbsolute(url2, baseUrl);
var url1parts = $.path.parseUrl(url1), var url1parts = $.path.parseUrl(url1),
url2parts = $.path.parseUrl(url2); url2parts = $.path.parseUrl(url2);
return url1parts.pathname.replace(/\/*$/, '') == url2parts.pathname.replace(/\/*$/, '') && url1parts.search == url2parts.search; return url1parts.pathname.replace(/\/*$/, '') == url2parts.pathname.replace(/\/*$/, '') && url1parts.search == url2parts.search;
}; };
var ajaxCompleteEvent = window.ss.debounce(function () { var ajaxCompleteEvent = window.ss.debounce(function () {
$(window).trigger('ajaxComplete'); $(window).trigger('ajaxComplete');
}, 1000, true); }, 1000, true);
$(window).bind('resize', positionLoadingSpinner).trigger('resize'); $(window).bind('resize', positionLoadingSpinner).trigger('resize');
$(document).ajaxComplete(function (e, xhr, settings) { $(document).ajaxComplete(function (e, xhr, settings) {
var origUrl, var origUrl,
url = xhr.getResponseHeader('X-ControllerURL'), url = xhr.getResponseHeader('X-ControllerURL'),
destUrl = settings.url, destUrl = settings.url,
msg = xhr.getResponseHeader('X-Status') !== null ? xhr.getResponseHeader('X-Status') : xhr.statusText, msg = xhr.getResponseHeader('X-Status') !== null ? xhr.getResponseHeader('X-Status') : xhr.statusText,
msgType = xhr.status < 200 || xhr.status > 399 ? 'bad' : 'good', msgType = xhr.status < 200 || xhr.status > 399 ? 'bad' : 'good',
ignoredMessages = ['OK']; ignoredMessages = ['OK'];
if (window.history.state) { if (window.history.state) {
origUrl = window.history.state.path; origUrl = window.history.state.path;
} else { } else {
origUrl = document.URL; origUrl = document.URL;
} }
if (url !== null && (!isSameUrl(origUrl, url) || !isSameUrl(destUrl, url))) { if (url !== null && (!isSameUrl(origUrl, url) || !isSameUrl(destUrl, url))) {
_Router2.default.show(url, { _Router2.default.show(url, {
id: new Date().getTime() + String(Math.random()).replace(/\D/g, ''), id: new Date().getTime() + String(Math.random()).replace(/\D/g, ''),
pjax: xhr.getResponseHeader('X-Pjax') ? xhr.getResponseHeader('X-Pjax') : settings.headers['X-Pjax'] pjax: xhr.getResponseHeader('X-Pjax') ? xhr.getResponseHeader('X-Pjax') : settings.headers['X-Pjax']
}); });
} }
if (xhr.getResponseHeader('X-Reauthenticate')) { if (xhr.getResponseHeader('X-Reauthenticate')) {
$('.cms-container').showLoginDialog(); $('.cms-container').showLoginDialog();
return; return;
} }
if (xhr.status !== 0 && msg && $.inArray(msg, ignoredMessages)) { if (xhr.status !== 0 && msg && $.inArray(msg, ignoredMessages)) {
statusMessage(decodeURIComponent(msg), msgType); statusMessage(decodeURIComponent(msg), msgType);
} }
ajaxCompleteEvent(this); ajaxCompleteEvent(this);
}); });
$('.cms-container').entwine({ $('.cms-container').entwine({
StateChangeXHR: null, StateChangeXHR: null,
FragmentXHR: {}, FragmentXHR: {},
StateChangeCount: 0, StateChangeCount: 0,
LayoutOptions: { LayoutOptions: {
minContentWidth: 940, minContentWidth: 940,
minPreviewWidth: 400, minPreviewWidth: 400,
mode: 'content' mode: 'content'
}, },
onadd: function onadd() { onadd: function onadd() {
var self = this, var self = this,
basePath = getUrlPath($('base')[0].href); basePath = getUrlPath($('base')[0].href);
basePath = basePath.replace(/\/$/, ''); basePath = basePath.replace(/\/$/, '');
_Router2.default.base(basePath); if (basePath.match(/^[^\/]/)) {
basePath = '/' + basePath;
_Config2.default.getTopLevelRoutes().forEach(function (route) { }
(0, _Router2.default)('/' + route + '(/*?)?', function (ctx, next) { _Router2.default.base(basePath);
if (document.readyState !== 'complete') {
return next(); _Config2.default.getTopLevelRoutes().forEach(function (route) {
} (0, _Router2.default)('/' + route + '(/*?)?', function (ctx, next) {
if (document.readyState !== 'complete') {
self.handleStateChange(null, ctx.state).done(next); return next();
}); }
});
self.handleStateChange(null, ctx.state).done(next);
_Router2.default.start(); });
});
if ($.browser.msie && parseInt($.browser.version, 10) < 8) {
$('.ss-loading-screen').append('<p class="ss-loading-incompat-warning"><span class="notice">' + 'Your browser is not compatible with the CMS interface. Please use Internet Explorer 8+, Google Chrome or Mozilla Firefox.' + '</span></p>').css('z-index', $('.ss-loading-screen').css('z-index') + 1); _Router2.default.start();
$('.loading-animation').remove();
if ($.browser.msie && parseInt($.browser.version, 10) < 8) {
this._super(); $('.ss-loading-screen').append('<p class="ss-loading-incompat-warning"><span class="notice">' + 'Your browser is not compatible with the CMS interface. Please use Internet Explorer 8+, Google Chrome or Mozilla Firefox.' + '</span></p>').css('z-index', $('.ss-loading-screen').css('z-index') + 1);
return; $('.loading-animation').remove();
}
this._super();
this.redraw(); return;
}
$('.ss-loading-screen').hide();
$('body').removeClass('loading'); this.redraw();
$(window).unbind('resize', positionLoadingSpinner);
this.restoreTabState(); $('.ss-loading-screen').hide();
this._super(); $('body').removeClass('loading');
}, $(window).unbind('resize', positionLoadingSpinner);
this.restoreTabState();
fromWindow: { this._super();
onstatechange: function onstatechange(event, historyState) { },
this.handleStateChange(event, historyState);
} fromWindow: {
}, onstatechange: function onstatechange(event, historyState) {
this.handleStateChange(event, historyState);
'onwindowresize': function onwindowresize() { }
this.redraw(); },
},
'onwindowresize': function onwindowresize() {
'from .cms-panel': { this.redraw();
ontoggle: function ontoggle() { },
this.redraw();
} 'from .cms-panel': {
}, ontoggle: function ontoggle() {
this.redraw();
'from .cms-container': { }
onaftersubmitform: function onaftersubmitform() { },
this.redraw();
} 'from .cms-container': {
}, onaftersubmitform: function onaftersubmitform() {
this.redraw();
'from .cms-menu-list li a': { }
onclick: function onclick(e) { },
var href = $(e.target).attr('href');
if (e.which > 1 || href == this._tabStateUrl()) return; 'from .cms-menu-list li a': {
this.splitViewMode(); onclick: function onclick(e) {
} var href = $(e.target).attr('href');
}, if (e.which > 1 || href == this._tabStateUrl()) return;
this.splitViewMode();
updateLayoutOptions: function updateLayoutOptions(newSpec) { }
var spec = this.getLayoutOptions(); },
var dirty = false; updateLayoutOptions: function updateLayoutOptions(newSpec) {
var spec = this.getLayoutOptions();
for (var k in newSpec) {
if (spec[k] !== newSpec[k]) { var dirty = false;
spec[k] = newSpec[k];
dirty = true; for (var k in newSpec) {
} if (spec[k] !== newSpec[k]) {
} spec[k] = newSpec[k];
dirty = true;
}
}
if (dirty) this.redraw();
},
if (dirty) this.redraw(); splitViewMode: function splitViewMode() {
}, this.updateLayoutOptions({
mode: 'split'
});
},
splitViewMode: function splitViewMode() { contentViewMode: function contentViewMode() {
this.updateLayoutOptions({ this.updateLayoutOptions({
mode: 'split' mode: 'content'
}); });
}, },
contentViewMode: function contentViewMode() { previewMode: function previewMode() {
this.updateLayoutOptions({ this.updateLayoutOptions({
mode: 'content' mode: 'preview'
}); });
}, },
previewMode: function previewMode() { RedrawSuppression: false,
this.updateLayoutOptions({
mode: 'preview'
});
},
RedrawSuppression: false, redraw: function redraw() {
if (this.getRedrawSuppression()) return;
if (window.debug) console.log('redraw', this.attr('class'), this.get(0));
redraw: function redraw() { this.data('jlayout', jLayout.threeColumnCompressor({
if (this.getRedrawSuppression()) return; menu: this.children('.cms-menu'),
content: this.children('.cms-content'),
preview: this.children('.cms-preview')
}, this.getLayoutOptions()));
if (window.debug) console.log('redraw', this.attr('class'), this.get(0)); this.layout();
this.data('jlayout', jLayout.threeColumnCompressor({ this.find('.cms-panel-layout').redraw();
menu: this.children('.cms-menu'), this.find('.cms-content-fields[data-layout-type]').redraw();
content: this.children('.cms-content'), this.find('.cms-edit-form[data-layout-type]').redraw();
preview: this.children('.cms-preview') this.find('.cms-preview').redraw();
}, this.getLayoutOptions())); this.find('.cms-content').redraw();
},
this.layout(); checkCanNavigate: function checkCanNavigate(selectors) {
var contentEls = this._findFragments(selectors || ['Content']),
trackedEls = contentEls.find(':data(changetracker)').add(contentEls.filter(':data(changetracker)')),
safe = true;
this.find('.cms-panel-layout').redraw(); if (!trackedEls.length) {
this.find('.cms-content-fields[data-layout-type]').redraw(); return true;
this.find('.cms-edit-form[data-layout-type]').redraw(); }
this.find('.cms-preview').redraw();
this.find('.cms-content').redraw();
},
checkCanNavigate: function checkCanNavigate(selectors) { trackedEls.each(function () {
var contentEls = this._findFragments(selectors || ['Content']), if (!$(this).confirmUnsavedChanges()) {
trackedEls = contentEls.find(':data(changetracker)').add(contentEls.filter(':data(changetracker)')), safe = false;
safe = true; }
});
if (!trackedEls.length) { return safe;
return true; },
}
trackedEls.each(function () { loadPanel: function loadPanel(url) {
if (!$(this).confirmUnsavedChanges()) { var title = arguments.length <= 1 || arguments[1] === undefined ? '' : arguments[1];
safe = false; var data = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
} var forceReload = arguments[3];
}); var forceReferer = arguments.length <= 4 || arguments[4] === undefined ? window.history.state.path : arguments[4];
return safe; if (!this.checkCanNavigate(data.pjax ? data.pjax.split(',') : ['Content'])) {
}, return;
}
loadPanel: function loadPanel(url) { this.saveTabState();
var title = arguments.length <= 1 || arguments[1] === undefined ? '' : arguments[1];
var data = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
var forceReload = arguments[3];
var forceReferer = arguments.length <= 4 || arguments[4] === undefined ? window.history.state.path : arguments[4];
if (!this.checkCanNavigate(data.pjax ? data.pjax.split(',') : ['Content'])) { data.__forceReferer = forceReferer;
return;
}
this.saveTabState(); if (forceReload) {
data.__forceReload = Math.random();
}
data.__forceReferer = forceReferer; _Router2.default.show(url, data);
},
if (forceReload) { reloadCurrentPanel: function reloadCurrentPanel() {
data.__forceReload = Math.random(); this.loadPanel(window.history.state.path, null, null, true);
} },
_Router2.default.show(url, data); submitForm: function submitForm(form, button, callback, ajaxOptions) {
}, var self = this;
reloadCurrentPanel: function reloadCurrentPanel() { if (!button) button = this.find('.Actions :submit[name=action_save]');
this.loadPanel(window.history.state.path, null, null, true);
},
submitForm: function submitForm(form, button, callback, ajaxOptions) { if (!button) button = this.find('.Actions :submit:first');
var self = this;
if (!button) button = this.find('.Actions :submit[name=action_save]'); form.trigger('beforesubmitform');
this.trigger('submitform', { form: form, button: button });
if (!button) button = this.find('.Actions :submit:first'); $(button).addClass('loading');
form.trigger('beforesubmitform'); var validationResult = form.validate();
this.trigger('submitform', { form: form, button: button }); if (typeof validationResult !== 'undefined' && !validationResult) {
statusMessage("Validation failed.", "bad");
$(button).addClass('loading'); $(button).removeClass('loading');
var validationResult = form.validate(); return false;
if (typeof validationResult !== 'undefined' && !validationResult) { }
statusMessage("Validation failed.", "bad");
$(button).removeClass('loading'); var formData = form.serializeArray();
return false; formData.push({ name: $(button).attr('name'), value: '1' });
}
var formData = form.serializeArray(); formData.push({ name: 'BackURL', value: window.history.state.path.replace(/\/$/, '') });
formData.push({ name: $(button).attr('name'), value: '1' }); this.saveTabState();
formData.push({ name: 'BackURL', value: window.history.state.path.replace(/\/$/, '') }); jQuery.ajax(jQuery.extend({
headers: { "X-Pjax": "CurrentForm,Breadcrumbs" },
url: form.attr('action'),
data: formData,
type: 'POST',
complete: function complete() {
$(button).removeClass('loading');
},
success: function success(data, status, xhr) {
form.removeClass('changed');
if (callback) callback(data, status, xhr);
this.saveTabState(); var newContentEls = self.handleAjaxResponse(data, status, xhr);
if (!newContentEls) return;
jQuery.ajax(jQuery.extend({ newContentEls.filter('form').trigger('aftersubmitform', { status: status, xhr: xhr, formData: formData });
headers: { "X-Pjax": "CurrentForm,Breadcrumbs" }, }
url: form.attr('action'), }, ajaxOptions));
data: formData,
type: 'POST',
complete: function complete() {
$(button).removeClass('loading');
},
success: function success(data, status, xhr) {
form.removeClass('changed');
if (callback) callback(data, status, xhr);
var newContentEls = self.handleAjaxResponse(data, status, xhr); return false;
if (!newContentEls) return; },
newContentEls.filter('form').trigger('aftersubmitform', { status: status, xhr: xhr, formData: formData }); LastState: null,
}
}, ajaxOptions));
return false; PauseState: false,
},
LastState: null, handleStateChange: function handleStateChange(event) {
var historyState = arguments.length <= 1 || arguments[1] === undefined ? window.history.state : arguments[1];
PauseState: false, if (this.getPauseState()) {
return;
}
handleStateChange: function handleStateChange(event) { if (this.getStateChangeXHR()) {
var historyState = arguments.length <= 1 || arguments[1] === undefined ? window.history.state : arguments[1]; this.getStateChangeXHR().abort();
}
if (this.getPauseState()) { var self = this,
return; fragments = historyState.pjax || 'Content',
} headers = {},
fragmentsArr = fragments.split(','),
contentEls = this._findFragments(fragmentsArr);
if (this.getStateChangeXHR()) { this.setStateChangeCount(this.getStateChangeCount() + 1);
this.getStateChangeXHR().abort();
}
var self = this, if (!this.checkCanNavigate()) {
fragments = historyState.pjax || 'Content', var lastState = this.getLastState();
headers = {},
fragmentsArr = fragments.split(','),
contentEls = this._findFragments(fragmentsArr);
this.setStateChangeCount(this.getStateChangeCount() + 1); this.setPauseState(true);
if (!this.checkCanNavigate()) { if (lastState !== null) {
var lastState = this.getLastState(); _Router2.default.show(lastState.url);
} else {
_Router2.default.back();
}
this.setPauseState(true); this.setPauseState(false);
if (lastState !== null) { return;
_Router2.default.show(lastState.url); }
} else {
_Router2.default.back();
}
this.setPauseState(false); this.setLastState(historyState);
return; if (contentEls.length < fragmentsArr.length) {
} fragments = 'Content', fragmentsArr = ['Content'];
contentEls = this._findFragments(fragmentsArr);
}
this.setLastState(historyState); this.trigger('beforestatechange', { state: historyState, element: contentEls });
if (contentEls.length < fragmentsArr.length) { headers['X-Pjax'] = fragments;
fragments = 'Content', fragmentsArr = ['Content'];
contentEls = this._findFragments(fragmentsArr);
}
this.trigger('beforestatechange', { state: historyState, element: contentEls }); if (typeof historyState.__forceReferer !== 'undefined') {
var url = historyState.__forceReferer;
headers['X-Pjax'] = fragments; try {
url = decodeURI(url);
} catch (e) {} finally {
headers['X-Backurl'] = encodeURI(url);
}
}
if (typeof historyState.__forceReferer !== 'undefined') { contentEls.addClass('loading');
var url = historyState.__forceReferer;
try { var promise = $.ajax({
url = decodeURI(url); headers: headers,
} catch (e) {} finally { url: historyState.path
headers['X-Backurl'] = encodeURI(url); }).done(function (data, status, xhr) {
} var els = self.handleAjaxResponse(data, status, xhr, historyState);
} self.trigger('afterstatechange', { data: data, status: status, xhr: xhr, element: els, state: historyState });
}).always(function () {
self.setStateChangeXHR(null);
contentEls.addClass('loading'); contentEls.removeClass('loading');
});
var promise = $.ajax({ this.setStateChangeXHR(promise);
headers: headers,
url: historyState.path
}).done(function (data, status, xhr) {
var els = self.handleAjaxResponse(data, status, xhr, historyState);
self.trigger('afterstatechange', { data: data, status: status, xhr: xhr, element: els, state: historyState });
}).always(function () {
self.setStateChangeXHR(null);
contentEls.removeClass('loading'); return promise;
}); },
loadFragment: function loadFragment(url, pjaxFragments) {
var self = this,
xhr,
headers = {},
baseUrl = $('base').attr('href'),
fragmentXHR = this.getFragmentXHR();
this.setStateChangeXHR(promise); if (typeof fragmentXHR[pjaxFragments] !== 'undefined' && fragmentXHR[pjaxFragments] !== null) {
fragmentXHR[pjaxFragments].abort();
fragmentXHR[pjaxFragments] = null;
}
return promise; url = $.path.isAbsoluteUrl(url) ? url : $.path.makeUrlAbsolute(url, baseUrl);
}, headers['X-Pjax'] = pjaxFragments;
loadFragment: function loadFragment(url, pjaxFragments) {
var self = this,
xhr,
headers = {},
baseUrl = $('base').attr('href'),
fragmentXHR = this.getFragmentXHR();
if (typeof fragmentXHR[pjaxFragments] !== 'undefined' && fragmentXHR[pjaxFragments] !== null) { xhr = $.ajax({
fragmentXHR[pjaxFragments].abort(); headers: headers,
fragmentXHR[pjaxFragments] = null; url: url,
} success: function success(data, status, xhr) {
var elements = self.handleAjaxResponse(data, status, xhr, null);
url = $.path.isAbsoluteUrl(url) ? url : $.path.makeUrlAbsolute(url, baseUrl);
headers['X-Pjax'] = pjaxFragments; self.trigger('afterloadfragment', { data: data, status: status, xhr: xhr, elements: elements });
},
xhr = $.ajax({ error: function error(xhr, status, _error) {
headers: headers, self.trigger('loadfragmenterror', { xhr: xhr, status: status, error: _error });
url: url, },
success: function success(data, status, xhr) { complete: function complete() {
var elements = self.handleAjaxResponse(data, status, xhr, null); var fragmentXHR = self.getFragmentXHR();
if (typeof fragmentXHR[pjaxFragments] !== 'undefined' && fragmentXHR[pjaxFragments] !== null) {
self.trigger('afterloadfragment', { data: data, status: status, xhr: xhr, elements: elements }); fragmentXHR[pjaxFragments] = null;
}, }
error: function error(xhr, status, _error) { }
self.trigger('loadfragmenterror', { xhr: xhr, status: status, error: _error }); });
},
complete: function complete() { fragmentXHR[pjaxFragments] = xhr;
var fragmentXHR = self.getFragmentXHR();
if (typeof fragmentXHR[pjaxFragments] !== 'undefined' && fragmentXHR[pjaxFragments] !== null) { return xhr;
fragmentXHR[pjaxFragments] = null; },
}
} handleAjaxResponse: function handleAjaxResponse(data, status, xhr, state) {
}); var self = this,
url,
fragmentXHR[pjaxFragments] = xhr; selectedTabs,
guessFragment,
return xhr; fragment,
}, $data;
handleAjaxResponse: function handleAjaxResponse(data, status, xhr, state) { if (xhr.getResponseHeader('X-Reload') && xhr.getResponseHeader('X-ControllerURL')) {
var self = this, var baseUrl = $('base').attr('href'),
url, rawURL = xhr.getResponseHeader('X-ControllerURL'),
selectedTabs, url = $.path.isAbsoluteUrl(rawURL) ? rawURL : $.path.makeUrlAbsolute(rawURL, baseUrl);
guessFragment,
fragment, document.location.href = url;
$data; return;
}
if (xhr.getResponseHeader('X-Reload') && xhr.getResponseHeader('X-ControllerURL')) {
var baseUrl = $('base').attr('href'), if (!data) return;
rawURL = xhr.getResponseHeader('X-ControllerURL'),
url = $.path.isAbsoluteUrl(rawURL) ? rawURL : $.path.makeUrlAbsolute(rawURL, baseUrl); var title = xhr.getResponseHeader('X-Title');
if (title) document.title = decodeURIComponent(title.replace(/\+/g, ' '));
document.location.href = url;
return; var newFragments = {},
} newContentEls;
if (!data) return; if (xhr.getResponseHeader('Content-Type').match(/^((text)|(application))\/json[ \t]*;?/i)) {
newFragments = data;
var title = xhr.getResponseHeader('X-Title'); } else {
if (title) document.title = decodeURIComponent(title.replace(/\+/g, ' ')); fragment = document.createDocumentFragment();
var newFragments = {}, jQuery.clean([data], document, fragment, []);
newContentEls; $data = $(jQuery.merge([], fragment.childNodes));
if (xhr.getResponseHeader('Content-Type').match(/^((text)|(application))\/json[ \t]*;?/i)) { guessFragment = 'Content';
newFragments = data; if ($data.is('form') && !$data.is('[data-pjax-fragment~=Content]')) guessFragment = 'CurrentForm';
} else {
fragment = document.createDocumentFragment(); newFragments[guessFragment] = $data;
}
jQuery.clean([data], document, fragment, []);
$data = $(jQuery.merge([], fragment.childNodes)); this.setRedrawSuppression(true);
try {
guessFragment = 'Content'; $.each(newFragments, function (newFragment, html) {
if ($data.is('form') && !$data.is('[data-pjax-fragment~=Content]')) guessFragment = 'CurrentForm'; var contentEl = $('[data-pjax-fragment]').filter(function () {
return $.inArray(newFragment, $(this).data('pjaxFragment').split(' ')) != -1;
newFragments[guessFragment] = $data; }),
} newContentEl = $(html);
this.setRedrawSuppression(true); if (newContentEls) newContentEls.add(newContentEl);else newContentEls = newContentEl;
try {
$.each(newFragments, function (newFragment, html) { if (newContentEl.find('.cms-container').length) {
var contentEl = $('[data-pjax-fragment]').filter(function () { throw 'Content loaded via ajax is not allowed to contain tags matching the ".cms-container" selector to avoid infinite loops';
return $.inArray(newFragment, $(this).data('pjaxFragment').split(' ')) != -1; }
}),
newContentEl = $(html); var origStyle = contentEl.attr('style');
var origParent = contentEl.parent();
if (newContentEls) newContentEls.add(newContentEl);else newContentEls = newContentEl; var origParentLayoutApplied = typeof origParent.data('jlayout') !== 'undefined';
var layoutClasses = ['east', 'west', 'center', 'north', 'south', 'column-hidden'];
if (newContentEl.find('.cms-container').length) { var elemClasses = contentEl.attr('class');
throw 'Content loaded via ajax is not allowed to contain tags matching the ".cms-container" selector to avoid infinite loops'; var origLayoutClasses = [];
} if (elemClasses) {
origLayoutClasses = $.grep(elemClasses.split(' '), function (val) {
var origStyle = contentEl.attr('style'); return $.inArray(val, layoutClasses) >= 0;
var origParent = contentEl.parent(); });
var origParentLayoutApplied = typeof origParent.data('jlayout') !== 'undefined'; }
var layoutClasses = ['east', 'west', 'center', 'north', 'south', 'column-hidden'];
var elemClasses = contentEl.attr('class'); newContentEl.removeClass(layoutClasses.join(' ')).addClass(origLayoutClasses.join(' '));
var origLayoutClasses = []; if (origStyle) newContentEl.attr('style', origStyle);
if (elemClasses) {
origLayoutClasses = $.grep(elemClasses.split(' '), function (val) { var styles = newContentEl.find('style').detach();
return $.inArray(val, layoutClasses) >= 0; if (styles.length) $(document).find('head').append(styles);
});
} contentEl.replaceWith(newContentEl);
newContentEl.removeClass(layoutClasses.join(' ')).addClass(origLayoutClasses.join(' ')); if (!origParent.is('.cms-container') && origParentLayoutApplied) {
if (origStyle) newContentEl.attr('style', origStyle); origParent.layout();
}
var styles = newContentEl.find('style').detach(); });
if (styles.length) $(document).find('head').append(styles);
var newForm = newContentEls.filter('form');
contentEl.replaceWith(newContentEl); if (newForm.hasClass('cms-tabset')) newForm.removeClass('cms-tabset').addClass('cms-tabset');
} finally {
if (!origParent.is('.cms-container') && origParentLayoutApplied) { this.setRedrawSuppression(false);
origParent.layout(); }
}
}); this.redraw();
this.restoreTabState(state && typeof state.tabState !== 'undefined' ? state.tabState : null);
var newForm = newContentEls.filter('form');
if (newForm.hasClass('cms-tabset')) newForm.removeClass('cms-tabset').addClass('cms-tabset'); return newContentEls;
} finally { },
this.setRedrawSuppression(false);
} _findFragments: function _findFragments(fragments) {
return $('[data-pjax-fragment]').filter(function () {
this.redraw(); var i,
this.restoreTabState(state && typeof state.tabState !== 'undefined' ? state.tabState : null); nodeFragments = $(this).data('pjaxFragment').split(' ');
for (i in fragments) {
return newContentEls; if ($.inArray(fragments[i], nodeFragments) != -1) return true;
}, }
return false;
_findFragments: function _findFragments(fragments) { });
return $('[data-pjax-fragment]').filter(function () { },
var i,
nodeFragments = $(this).data('pjaxFragment').split(' '); refresh: function refresh() {
for (i in fragments) { $(window).trigger('statechange');
if ($.inArray(fragments[i], nodeFragments) != -1) return true;
} $(this).redraw();
return false; },
});
}, saveTabState: function saveTabState() {
if (typeof window.sessionStorage == "undefined" || window.sessionStorage === null) return;
refresh: function refresh() {
$(window).trigger('statechange'); var selectedTabs = [],
url = this._tabStateUrl();
$(this).redraw(); this.find('.cms-tabset,.ss-tabset').each(function (i, el) {
}, var id = $(el).attr('id');
if (!id) return;
saveTabState: function saveTabState() { if (!$(el).data('tabs')) return;
if (typeof window.sessionStorage == "undefined" || window.sessionStorage === null) return; if ($(el).data('ignoreTabState') || $(el).getIgnoreTabState()) return;
var selectedTabs = [], selectedTabs.push({ id: id, selected: $(el).tabs('option', 'selected') });
url = this._tabStateUrl(); });
this.find('.cms-tabset,.ss-tabset').each(function (i, el) {
var id = $(el).attr('id'); if (selectedTabs) {
if (!id) return; var tabsUrl = 'tabs-' + url;
if (!$(el).data('tabs')) return; try {
if ($(el).data('ignoreTabState') || $(el).getIgnoreTabState()) return; window.sessionStorage.setItem(tabsUrl, JSON.stringify(selectedTabs));
} catch (err) {
selectedTabs.push({ id: id, selected: $(el).tabs('option', 'selected') }); if (err.code === DOMException.QUOTA_EXCEEDED_ERR && window.sessionStorage.length === 0) {
}); return;
} else {
if (selectedTabs) { throw err;
var tabsUrl = 'tabs-' + url; }
try { }
window.sessionStorage.setItem(tabsUrl, JSON.stringify(selectedTabs)); }
} catch (err) { },
if (err.code === DOMException.QUOTA_EXCEEDED_ERR && window.sessionStorage.length === 0) {
return; restoreTabState: function restoreTabState(overrideStates) {
} else { var self = this,
throw err; url = this._tabStateUrl(),
} hasSessionStorage = typeof window.sessionStorage !== "undefined" && window.sessionStorage,
} sessionData = hasSessionStorage ? window.sessionStorage.getItem('tabs-' + url) : null,
} sessionStates = sessionData ? JSON.parse(sessionData) : false;
},
this.find('.cms-tabset, .ss-tabset').each(function () {
restoreTabState: function restoreTabState(overrideStates) { var index,
var self = this, tabset = $(this),
url = this._tabStateUrl(), tabsetId = tabset.attr('id'),
hasSessionStorage = typeof window.sessionStorage !== "undefined" && window.sessionStorage, tab,
sessionData = hasSessionStorage ? window.sessionStorage.getItem('tabs-' + url) : null, forcedTab = tabset.find('.ss-tabs-force-active');
sessionStates = sessionData ? JSON.parse(sessionData) : false;
if (!tabset.data('tabs')) {
this.find('.cms-tabset, .ss-tabset').each(function () { return;
var index, }
tabset = $(this),
tabsetId = tabset.attr('id'), tabset.tabs('refresh');
tab,
forcedTab = tabset.find('.ss-tabs-force-active'); if (forcedTab.length) {
index = forcedTab.index();
if (!tabset.data('tabs')) { } else if (overrideStates && overrideStates[tabsetId]) {
return; tab = tabset.find(overrideStates[tabsetId].tabSelector);
} if (tab.length) {
index = tab.index();
tabset.tabs('refresh'); }
} else if (sessionStates) {
if (forcedTab.length) { $.each(sessionStates, function (i, sessionState) {
index = forcedTab.index(); if (tabset.is('#' + sessionState.id)) {
} else if (overrideStates && overrideStates[tabsetId]) { index = sessionState.selected;
tab = tabset.find(overrideStates[tabsetId].tabSelector); }
if (tab.length) { });
index = tab.index(); }
} if (index !== null) {
} else if (sessionStates) { tabset.tabs('option', 'active', index);
$.each(sessionStates, function (i, sessionState) { self.trigger('tabstaterestored');
if (tabset.is('#' + sessionState.id)) { }
index = sessionState.selected; });
} },
});
} clearTabState: function clearTabState(url) {
if (index !== null) { if (typeof window.sessionStorage == "undefined") return;
tabset.tabs('option', 'active', index);
self.trigger('tabstaterestored'); var s = window.sessionStorage;
} if (url) {
}); s.removeItem('tabs-' + url);
}, } else {
for (var i = 0; i < s.length; i++) {
clearTabState: function clearTabState(url) { if (s.key(i).match(/^tabs-/)) s.removeItem(s.key(i));
if (typeof window.sessionStorage == "undefined") return; }
}
var s = window.sessionStorage; },
if (url) {
s.removeItem('tabs-' + url); clearCurrentTabState: function clearCurrentTabState() {
} else { this.clearTabState(this._tabStateUrl());
for (var i = 0; i < s.length; i++) { },
if (s.key(i).match(/^tabs-/)) s.removeItem(s.key(i));
} _tabStateUrl: function _tabStateUrl() {
} return window.history.state.path.replace(/\?.*/, '').replace(/#.*/, '').replace($('base').attr('href'), '');
}, },
clearCurrentTabState: function clearCurrentTabState() { showLoginDialog: function showLoginDialog() {
this.clearTabState(this._tabStateUrl()); var tempid = $('body').data('member-tempid'),
}, dialog = $('.leftandmain-logindialog'),
url = 'CMSSecurity/login';
_tabStateUrl: function _tabStateUrl() {
return window.history.state.path.replace(/\?.*/, '').replace(/#.*/, '').replace($('base').attr('href'), ''); if (dialog.length) dialog.remove();
},
url = $.path.addSearchParams(url, {
showLoginDialog: function showLoginDialog() { 'tempid': tempid,
var tempid = $('body').data('member-tempid'), 'BackURL': window.location.href
dialog = $('.leftandmain-logindialog'), });
url = 'CMSSecurity/login';
dialog = $('<div class="leftandmain-logindialog"></div>');
if (dialog.length) dialog.remove(); dialog.attr('id', new Date().getTime());
dialog.data('url', url);
url = $.path.addSearchParams(url, { $('body').append(dialog);
'tempid': tempid, }
'BackURL': window.location.href });
});
$('.leftandmain-logindialog').entwine({
dialog = $('<div class="leftandmain-logindialog"></div>'); onmatch: function onmatch() {
dialog.attr('id', new Date().getTime()); this._super();
dialog.data('url', url);
$('body').append(dialog); this.ssdialog({
} iframeUrl: this.data('url'),
}); dialogClass: "leftandmain-logindialog-dialog",
autoOpen: true,
$('.leftandmain-logindialog').entwine({ minWidth: 500,
onmatch: function onmatch() { maxWidth: 500,
this._super(); minHeight: 370,
maxHeight: 400,
this.ssdialog({ closeOnEscape: false,
iframeUrl: this.data('url'), open: function open() {
dialogClass: "leftandmain-logindialog-dialog", $('.ui-widget-overlay').addClass('leftandmain-logindialog-overlay');
autoOpen: true, },
minWidth: 500, close: function close() {
maxWidth: 500, $('.ui-widget-overlay').removeClass('leftandmain-logindialog-overlay');
minHeight: 370, }
maxHeight: 400, });
closeOnEscape: false, },
open: function open() { onunmatch: function onunmatch() {
$('.ui-widget-overlay').addClass('leftandmain-logindialog-overlay'); this._super();
}, },
close: function close() { open: function open() {
$('.ui-widget-overlay').removeClass('leftandmain-logindialog-overlay'); this.ssdialog('open');
} },
}); close: function close() {
}, this.ssdialog('close');
onunmatch: function onunmatch() { },
this._super(); toggle: function toggle(bool) {
}, if (this.is(':visible')) this.close();else this.open();
open: function open() { },
this.ssdialog('open');
}, reauthenticate: function reauthenticate(data) {
close: function close() { if (typeof data.SecurityID !== 'undefined') {
this.ssdialog('close'); $(':input[name=SecurityID]').val(data.SecurityID);
}, }
toggle: function toggle(bool) {
if (this.is(':visible')) this.close();else this.open(); if (typeof data.TempID !== 'undefined') {
}, $('body').data('member-tempid', data.TempID);
}
reauthenticate: function reauthenticate(data) { this.close();
if (typeof data.SecurityID !== 'undefined') { }
$(':input[name=SecurityID]').val(data.SecurityID); });
}
$('form.loading,.cms-content.loading,.cms-content-fields.loading,.cms-content-view.loading').entwine({
if (typeof data.TempID !== 'undefined') { onmatch: function onmatch() {
$('body').data('member-tempid', data.TempID); this.append('<div class="cms-content-loading-overlay ui-widget-overlay-light"></div><div class="cms-content-loading-spinner"></div>');
} this._super();
this.close(); },
} onunmatch: function onunmatch() {
}); this.find('.cms-content-loading-overlay,.cms-content-loading-spinner').remove();
this._super();
$('form.loading,.cms-content.loading,.cms-content-fields.loading,.cms-content-view.loading').entwine({ }
onmatch: function onmatch() { });
this.append('<div class="cms-content-loading-overlay ui-widget-overlay-light"></div><div class="cms-content-loading-spinner"></div>');
this._super(); $('.cms input[type="submit"], .cms button, .cms input[type="reset"], .cms .ss-ui-button').entwine({
}, onadd: function onadd() {
onunmatch: function onunmatch() { this.addClass('ss-ui-button');
this.find('.cms-content-loading-overlay,.cms-content-loading-spinner').remove(); if (!this.data('button')) this.button();
this._super(); this._super();
} },
}); onremove: function onremove() {
if (this.data('button')) this.button('destroy');
$('.cms input[type="submit"], .cms button, .cms input[type="reset"], .cms .ss-ui-button').entwine({ this._super();
onadd: function onadd() { }
this.addClass('ss-ui-button'); });
if (!this.data('button')) this.button();
this._super(); $('.cms .cms-panel-link').entwine({
}, onclick: function onclick(e) {
onremove: function onremove() { if ($(this).hasClass('external-link')) {
if (this.data('button')) this.button('destroy'); e.stopPropagation();
this._super();
} return;
}); }
$('.cms .cms-panel-link').entwine({ var href = this.attr('href'),
onclick: function onclick(e) { url = href && !href.match(/^#/) ? href : this.data('href'),
if ($(this).hasClass('external-link')) { data = { pjax: this.data('pjaxTarget') };
e.stopPropagation();
$('.cms-container').loadPanel(url, null, data);
return; e.preventDefault();
} }
});
var href = this.attr('href'),
url = href && !href.match(/^#/) ? href : this.data('href'), $('.cms .ss-ui-button-ajax').entwine({
data = { pjax: this.data('pjaxTarget') }; onclick: function onclick(e) {
$(this).removeClass('ui-button-text-only');
$('.cms-container').loadPanel(url, null, data); $(this).addClass('ss-ui-button-loading ui-button-text-icons');
e.preventDefault();
} var loading = $(this).find(".ss-ui-loading-icon");
});
if (loading.length < 1) {
$('.cms .ss-ui-button-ajax').entwine({ loading = $("<span></span>").addClass('ss-ui-loading-icon ui-button-icon-primary ui-icon');
onclick: function onclick(e) {
$(this).removeClass('ui-button-text-only'); $(this).prepend(loading);
$(this).addClass('ss-ui-button-loading ui-button-text-icons'); }
var loading = $(this).find(".ss-ui-loading-icon"); loading.show();
if (loading.length < 1) { var href = this.attr('href'),
loading = $("<span></span>").addClass('ss-ui-loading-icon ui-button-icon-primary ui-icon'); url = href ? href : this.data('href');
$(this).prepend(loading); jQuery.ajax({
} url: url,
loading.show(); complete: function complete(xmlhttp, status) {
var msg = xmlhttp.getResponseHeader('X-Status') ? xmlhttp.getResponseHeader('X-Status') : xmlhttp.responseText;
var href = this.attr('href'),
url = href ? href : this.data('href'); try {
if (typeof msg != "undefined" && msg !== null) eval(msg);
jQuery.ajax({ } catch (e) {}
url: url,
loading.hide();
complete: function complete(xmlhttp, status) {
var msg = xmlhttp.getResponseHeader('X-Status') ? xmlhttp.getResponseHeader('X-Status') : xmlhttp.responseText; $(".cms-container").refresh();
try { $(this).removeClass('ss-ui-button-loading ui-button-text-icons');
if (typeof msg != "undefined" && msg !== null) eval(msg); $(this).addClass('ui-button-text-only');
} catch (e) {} },
dataType: 'html'
loading.hide(); });
e.preventDefault();
$(".cms-container").refresh(); }
});
$(this).removeClass('ss-ui-button-loading ui-button-text-icons');
$(this).addClass('ui-button-text-only'); $('.cms .ss-ui-dialog-link').entwine({
}, UUID: null,
dataType: 'html' onmatch: function onmatch() {
}); this._super();
e.preventDefault(); this.setUUID(new Date().getTime());
} },
}); onunmatch: function onunmatch() {
this._super();
$('.cms .ss-ui-dialog-link').entwine({ },
UUID: null, onclick: function onclick() {
onmatch: function onmatch() { this._super();
this._super();
this.setUUID(new Date().getTime()); var self = this,
}, id = 'ss-ui-dialog-' + this.getUUID();
onunmatch: function onunmatch() { var dialog = $('#' + id);
this._super(); if (!dialog.length) {
}, dialog = $('<div class="ss-ui-dialog" id="' + id + '" />');
onclick: function onclick() { $('body').append(dialog);
this._super(); }
var self = this, var extraClass = this.data('popupclass') ? this.data('popupclass') : '';
id = 'ss-ui-dialog-' + this.getUUID();
var dialog = $('#' + id); dialog.ssdialog({ iframeUrl: this.attr('href'), autoOpen: true, dialogExtraClass: extraClass });
if (!dialog.length) { return false;
dialog = $('<div class="ss-ui-dialog" id="' + id + '" />'); }
$('body').append(dialog); });
}
$('.cms-content .Actions').entwine({
var extraClass = this.data('popupclass') ? this.data('popupclass') : ''; onmatch: function onmatch() {
this.find('.ss-ui-button').click(function () {
dialog.ssdialog({ iframeUrl: this.attr('href'), autoOpen: true, dialogExtraClass: extraClass }); var form = this.form;
return false;
} if (form) {
}); form.clickedButton = this;
$('.cms-content .Actions').entwine({ setTimeout(function () {
onmatch: function onmatch() { form.clickedButton = null;
this.find('.ss-ui-button').click(function () { }, 10);
var form = this.form; }
});
if (form) {
form.clickedButton = this; this.redraw();
this._super();
setTimeout(function () { },
form.clickedButton = null; onunmatch: function onunmatch() {
}, 10); this._super();
} },
}); redraw: function redraw() {
if (window.debug) console.log('redraw', this.attr('class'), this.get(0));
this.redraw();
this._super(); this.contents().filter(function () {
}, return this.nodeType == 3 && !/\S/.test(this.nodeValue);
onunmatch: function onunmatch() { }).remove();
this._super();
}, this.find('.ss-ui-button').each(function () {
redraw: function redraw() { if (!$(this).data('button')) $(this).button();
if (window.debug) console.log('redraw', this.attr('class'), this.get(0)); });
this.contents().filter(function () { this.find('.ss-ui-buttonset').buttonset();
return this.nodeType == 3 && !/\S/.test(this.nodeValue); }
}).remove(); });
this.find('.ss-ui-button').each(function () { $('.cms .field.date input.text').entwine({
if (!$(this).data('button')) $(this).button(); onmatch: function onmatch() {
}); var holder = $(this).parents('.field.date:first'),
config = holder.data();
this.find('.ss-ui-buttonset').buttonset(); if (!config.showcalendar) {
} this._super();
}); return;
}
$('.cms .field.date input.text').entwine({
onmatch: function onmatch() { config.showOn = 'button';
var holder = $(this).parents('.field.date:first'), if (config.locale && $.datepicker.regional[config.locale]) {
config = holder.data(); config = $.extend(config, $.datepicker.regional[config.locale], {});
if (!config.showcalendar) { }
this._super();
return; $(this).datepicker(config);
}
config.showOn = 'button'; this._super();
if (config.locale && $.datepicker.regional[config.locale]) { },
config = $.extend(config, $.datepicker.regional[config.locale], {}); onunmatch: function onunmatch() {
} this._super();
}
$(this).datepicker(config); });
$('.cms .field.dropdown select, .cms .field select[multiple], .fieldholder-small select.dropdown').entwine({
this._super(); onmatch: function onmatch() {
}, if (this.is('.no-chosen')) {
onunmatch: function onunmatch() { this._super();
this._super(); return;
} }
});
if (!this.data('placeholder')) this.data('placeholder', ' ');
$('.cms .field.dropdown select, .cms .field select[multiple], .fieldholder-small select.dropdown').entwine({
onmatch: function onmatch() { this.removeClass('has-chosen').chosen("destroy");
if (this.is('.no-chosen')) { this.siblings('.chosen-container').remove();
this._super();
return; applyChosen(this);
}
this._super();
if (!this.data('placeholder')) this.data('placeholder', ' '); },
onunmatch: function onunmatch() {
this.removeClass('has-chosen').chosen("destroy"); this._super();
this.siblings('.chosen-container').remove(); }
});
applyChosen(this);
$(".cms-panel-layout").entwine({
this._super(); redraw: function redraw() {
}, if (window.debug) console.log('redraw', this.attr('class'), this.get(0));
onunmatch: function onunmatch() { }
this._super(); });
}
}); $('.cms .ss-gridfield').entwine({
showDetailView: function showDetailView(url) {
$(".cms-panel-layout").entwine({ var params = window.location.search.replace(/^\?/, '');
redraw: function redraw() { if (params) url = $.path.addSearchParams(url, params);
if (window.debug) console.log('redraw', this.attr('class'), this.get(0)); $('.cms-container').loadPanel(url);
} }
}); });
$('.cms .ss-gridfield').entwine({ $('.cms-search-form').entwine({
showDetailView: function showDetailView(url) { onsubmit: function onsubmit(e) {
var params = window.location.search.replace(/^\?/, ''); var nonEmptyInputs, url;
if (params) url = $.path.addSearchParams(url, params);
$('.cms-container').loadPanel(url); nonEmptyInputs = this.find(':input:not(:submit)').filter(function () {
} var vals = $.grep($(this).fieldValue(), function (val) {
}); return val;
});
$('.cms-search-form').entwine({ return vals.length;
onsubmit: function onsubmit(e) { });
var nonEmptyInputs, url;
url = this.attr('action');
nonEmptyInputs = this.find(':input:not(:submit)').filter(function () {
var vals = $.grep($(this).fieldValue(), function (val) { if (nonEmptyInputs.length) {
return val; url = $.path.addSearchParams(url, nonEmptyInputs.serialize().replace('+', '%20'));
}); }
return vals.length;
}); var container = this.closest('.cms-container');
container.find('.cms-edit-form').tabs('select', 0);
url = this.attr('action'); container.loadPanel(url, "", {}, true);
if (nonEmptyInputs.length) { return false;
url = $.path.addSearchParams(url, nonEmptyInputs.serialize().replace('+', '%20')); }
} });
var container = this.closest('.cms-container'); $(".cms-search-form button[type=reset], .cms-search-form input[type=reset]").entwine({
container.find('.cms-edit-form').tabs('select', 0); onclick: function onclick(e) {
container.loadPanel(url, "", {}, true); e.preventDefault();
return false; var form = $(this).parents('form');
}
}); form.clearForm();
form.find(".dropdown select").prop('selectedIndex', 0).trigger("chosen:updated");
$(".cms-search-form button[type=reset], .cms-search-form input[type=reset]").entwine({ form.submit();
onclick: function onclick(e) { }
e.preventDefault(); });
var form = $(this).parents('form'); window._panelDeferredCache = {};
$('.cms-panel-deferred').entwine({
form.clearForm(); onadd: function onadd() {
form.find(".dropdown select").prop('selectedIndex', 0).trigger("chosen:updated"); this._super();
form.submit(); this.redraw();
} },
}); onremove: function onremove() {
if (window.debug) console.log('saving', this.data('url'), this);
window._panelDeferredCache = {};
$('.cms-panel-deferred').entwine({ if (!this.data('deferredNoCache')) window._panelDeferredCache[this.data('url')] = this.html();
onadd: function onadd() { this._super();
this._super(); },
this.redraw(); redraw: function redraw() {
}, if (window.debug) console.log('redraw', this.attr('class'), this.get(0));
onremove: function onremove() {
if (window.debug) console.log('saving', this.data('url'), this); var self = this,
url = this.data('url');
if (!this.data('deferredNoCache')) window._panelDeferredCache[this.data('url')] = this.html(); if (!url) throw 'Elements of class .cms-panel-deferred need a "data-url" attribute';
this._super();
}, this._super();
redraw: function redraw() {
if (window.debug) console.log('redraw', this.attr('class'), this.get(0)); if (!this.children().length) {
if (!this.data('deferredNoCache') && typeof window._panelDeferredCache[url] !== 'undefined') {
var self = this, this.html(window._panelDeferredCache[url]);
url = this.data('url'); } else {
if (!url) throw 'Elements of class .cms-panel-deferred need a "data-url" attribute'; this.addClass('loading');
$.ajax({
this._super(); url: url,
complete: function complete() {
if (!this.children().length) { self.removeClass('loading');
if (!this.data('deferredNoCache') && typeof window._panelDeferredCache[url] !== 'undefined') { },
this.html(window._panelDeferredCache[url]); success: function success(data, status, xhr) {
} else { self.html(data);
this.addClass('loading'); }
$.ajax({ });
url: url, }
complete: function complete() { }
self.removeClass('loading'); }
}, });
success: function success(data, status, xhr) {
self.html(data); $('.cms-tabset').entwine({
} onadd: function onadd() {
}); this.redrawTabs();
} this._super();
} },
} onremove: function onremove() {
}); if (this.data('tabs')) this.tabs('destroy');
this._super();
$('.cms-tabset').entwine({ },
onadd: function onadd() { redrawTabs: function redrawTabs() {
this.redrawTabs(); this.rewriteHashlinks();
this._super();
}, var id = this.attr('id'),
onremove: function onremove() { activeTab = this.find('ul:first .ui-tabs-active');
if (this.data('tabs')) this.tabs('destroy');
this._super(); if (!this.data('uiTabs')) this.tabs({
}, active: activeTab.index() != -1 ? activeTab.index() : 0,
redrawTabs: function redrawTabs() { beforeLoad: function beforeLoad(e, ui) {
this.rewriteHashlinks(); return false;
},
var id = this.attr('id'), activate: function activate(e, ui) {
activeTab = this.find('ul:first .ui-tabs-active'); var actions = $(this).closest('form').find('.Actions');
if ($(ui.newTab).closest('li').hasClass('readonly')) {
if (!this.data('uiTabs')) this.tabs({ actions.fadeOut();
active: activeTab.index() != -1 ? activeTab.index() : 0, } else {
beforeLoad: function beforeLoad(e, ui) { actions.show();
return false; }
}, }
activate: function activate(e, ui) { });
var actions = $(this).closest('form').find('.Actions'); },
if ($(ui.newTab).closest('li').hasClass('readonly')) {
actions.fadeOut(); rewriteHashlinks: function rewriteHashlinks() {
} else { $(this).find('ul a').each(function () {
actions.show(); if (!$(this).attr('href')) return;
} var matches = $(this).attr('href').match(/#.*/);
} if (!matches) return;
}); $(this).attr('href', document.location.href.replace(/#.*/, '') + matches[0]);
}, });
}
rewriteHashlinks: function rewriteHashlinks() { });
$(this).find('ul a').each(function () {
if (!$(this).attr('href')) return; $('#filters-button').entwine({
var matches = $(this).attr('href').match(/#.*/); onmatch: function onmatch() {
if (!matches) return; this._super();
$(this).attr('href', document.location.href.replace(/#.*/, '') + matches[0]);
}); this.data('collapsed', true);
} this.data('animating', false);
}); },
onunmatch: function onunmatch() {
$('#filters-button').entwine({ this._super();
onmatch: function onmatch() { },
this._super(); showHide: function showHide() {
var self = this,
this.data('collapsed', true); $filters = $('.cms-content-filters').first(),
this.data('animating', false); collapsed = this.data('collapsed');
},
onunmatch: function onunmatch() { if (this.data('animating')) {
this._super(); return;
}, }
showHide: function showHide() {
var self = this, this.toggleClass('active');
$filters = $('.cms-content-filters').first(), this.data('animating', true);
collapsed = this.data('collapsed');
$filters[collapsed ? 'slideDown' : 'slideUp']({
if (this.data('animating')) { complete: function complete() {
return; self.data('collapsed', !collapsed);
} self.data('animating', false);
}
this.toggleClass('active'); });
this.data('animating', true); },
onclick: function onclick() {
$filters[collapsed ? 'slideDown' : 'slideUp']({ this.showHide();
complete: function complete() { }
self.data('collapsed', !collapsed); });
self.data('animating', false); });
}
}); var statusMessage = function statusMessage(text, type) {
}, text = jQuery('<div/>').text(text).html();
onclick: function onclick() { jQuery.noticeAdd({ text: text, type: type, stayTime: 5000, inEffect: { left: '0', opacity: 'show' } });
this.showHide(); };
}
}); var errorMessage = function errorMessage(text) {
}); jQuery.noticeAdd({ text: text, type: 'error', stayTime: 5000, inEffect: { left: '0', opacity: 'show' } });
};
var statusMessage = function statusMessage(text, type) {
text = jQuery('<div/>').text(text).html();
jQuery.noticeAdd({ text: text, type: type, stayTime: 5000, inEffect: { left: '0', opacity: 'show' } });
};
var errorMessage = function errorMessage(text) {
jQuery.noticeAdd({ text: text, type: 'error', stayTime: 5000, inEffect: { left: '0', opacity: 'show' } });
};
}); });

View File

@ -1,4 +1,4 @@
!function e(t,n,i){function s(o,r){if(!n[o]){if(!t[o]){var l="function"==typeof require&&require;if(!r&&l)return l(o,!0);if(a)return a(o,!0);var d=new Error("Cannot find module '"+o+"'");throw d.code="MODULE_NOT_FOUND",d}var c=n[o]={exports:{}};t[o][0].call(c.exports,function(e){var n=t[o][1][e];return s(n?n:e)},c,c.exports,e,t,n,i)}return n[o].exports}for(var a="function"==typeof require&&require,o=0;o<i.length;o++)s(i[o]);return s}({1:[function(e,t,n){"use strict";e("../legacy/LeftAndMain.Layout.js"),e("../legacy/LeftAndMain.js"),e("../legacy/LeftAndMain.ActionTabSet.js"),e("../legacy/LeftAndMain.Panel.js"),e("../legacy/LeftAndMain.Tree.js"),e("../legacy/LeftAndMain.Content.js"),e("../legacy/LeftAndMain.EditForm.js"),e("../legacy/LeftAndMain.Menu.js"),e("../legacy/LeftAndMain.Preview.js"),e("../legacy/LeftAndMain.BatchActions.js"),e("../legacy/LeftAndMain.FieldHelp.js"),e("../legacy/LeftAndMain.FieldDescriptionToggle.js"),e("../legacy/LeftAndMain.TreeDropdownField.js")},{"../legacy/LeftAndMain.ActionTabSet.js":2,"../legacy/LeftAndMain.BatchActions.js":3,"../legacy/LeftAndMain.Content.js":4,"../legacy/LeftAndMain.EditForm.js":5,"../legacy/LeftAndMain.FieldDescriptionToggle.js":6,"../legacy/LeftAndMain.FieldHelp.js":7,"../legacy/LeftAndMain.Layout.js":8,"../legacy/LeftAndMain.Menu.js":9,"../legacy/LeftAndMain.Panel.js":10,"../legacy/LeftAndMain.Preview.js":11,"../legacy/LeftAndMain.Tree.js":12,"../legacy/LeftAndMain.TreeDropdownField.js":13,"../legacy/LeftAndMain.js":14}],2:[function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}var s=e("jQuery"),a=i(s);a["default"].entwine("ss",function(e){e(".ss-tabset.ss-ui-action-tabset").entwine({IgnoreTabState:!0,onadd:function(){this._super(),this.tabs({collapsible:!0,active:!1})},onremove:function(){var t=e(".cms-container").find("iframe");t.each(function(t,n){try{e(n).contents().off("click.ss-ui-action-tabset")}catch(i){console.warn("Unable to access iframe, possible https mis-match")}}),e(document).off("click.ss-ui-action-tabset"),this._super()},ontabsbeforeactivate:function(e,t){this.riseUp(e,t)},onclick:function(e,t){this.attachCloseHandler(e,t)},attachCloseHandler:function(t,n){var i,s=this,a=e(".cms-container").find("iframe");i=function(t){var n,a;n=e(t.target).closest(".ss-ui-action-tabset .ui-tabs-panel"),e(t.target).closest(s).length||n.length||(s.tabs("option","active",!1),a=e(".cms-container").find("iframe"),a.each(function(t,n){e(n).contents().off("click.ss-ui-action-tabset",i)}),e(document).off("click.ss-ui-action-tabset",i))},e(document).on("click.ss-ui-action-tabset",i),a.length>0&&a.each(function(t,n){e(n).contents().on("click.ss-ui-action-tabset",i)})},riseUp:function(t,n){var i,s,a,o,r,l,d,c,u;return i=e(this).find(".ui-tabs-panel").outerHeight(),s=e(this).find(".ui-tabs-nav").outerHeight(),a=e(window).height()+e(document).scrollTop()-s,o=e(this).find(".ui-tabs-nav").offset().top,r=n.newPanel,l=n.newTab,o+i>=a&&o-i>0?(this.addClass("rise-up"),null!==l.position()&&(d=-r.outerHeight(),c=r.parents(".south"),c&&(u=l.offset().top-c.offset().top,d-=u),e(r).css("top",d+"px"))):(this.removeClass("rise-up"),null!==l.position()&&e(r).css("top","0px")),!1}}),e(".cms-content-actions .ss-tabset.ss-ui-action-tabset").entwine({ontabsbeforeactivate:function(t,n){this._super(t,n),e(n.newPanel).length>0&&e(n.newPanel).css("left",n.newTab.position().left+"px")}}),e(".cms-actions-row.ss-tabset.ss-ui-action-tabset").entwine({ontabsbeforeactivate:function(t,n){this._super(t,n),e(this).closest(".ss-ui-action-tabset").removeClass("tabset-open tabset-open-last")}}),e(".cms-content-fields .ss-tabset.ss-ui-action-tabset").entwine({ontabsbeforeactivate:function(t,n){this._super(t,n),e(n.newPanel).length>0&&(e(n.newTab).hasClass("last")?(e(n.newPanel).css({left:"auto",right:"0px"}),e(n.newPanel).parent().addClass("tabset-open-last")):(e(n.newPanel).css("left",n.newTab.position().left+"px"),e(n.newTab).hasClass("first")&&(e(n.newPanel).css("left","0px"),e(n.newPanel).parent().addClass("tabset-open"))))}}),e(".cms-tree-view-sidebar .cms-actions-row.ss-tabset.ss-ui-action-tabset").entwine({"from .ui-tabs-nav li":{onhover:function(t){e(t.target).parent().find("li .active").removeClass("active"),e(t.target).find("a").addClass("active")}},ontabsbeforeactivate:function(t,n){this._super(t,n),e(n.newPanel).css({left:"auto",right:"auto"}),e(n.newPanel).length>0&&e(n.newPanel).parent().addClass("tabset-open")}})})},{jQuery:"jQuery"}],3:[function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}var s=e("jQuery"),a=i(s),o=e("i18n"),r=i(o);a["default"].entwine("ss.tree",function(e){e("#Form_BatchActionsForm").entwine({Actions:[],getTree:function(){return e(".cms-tree")},fromTree:{oncheck_node:function(e,t){this.serializeFromTree()},onuncheck_node:function(e,t){this.serializeFromTree()}},registerDefault:function(){this.register("admin/pages/batchactions/publish",function(e){var t=confirm(r["default"].inject(r["default"]._t("CMSMAIN.BATCH_PUBLISH_PROMPT","You have {num} page(s) selected.\n\nDo you really want to publish?"),{num:e.length}));return t?e:!1}),this.register("admin/pages/batchactions/unpublish",function(e){var t=confirm(r["default"].inject(r["default"]._t("CMSMAIN.BATCH_UNPUBLISH_PROMPT","You have {num} page(s) selected.\n\nDo you really want to unpublish"),{num:e.length}));return t?e:!1}),this.register("admin/pages/batchactions/delete",function(e){var t=confirm(r["default"].inject(r["default"]._t("CMSMAIN.BATCH_DELETE_PROMPT","You have {num} page(s) selected.\n\nDo you really want to delete?"),{num:e.length}));return t?e:!1}),this.register("admin/pages/batchactions/archive",function(e){var t=confirm(r["default"].inject(r["default"]._t("CMSMAIN.BATCH_ARCHIVE_PROMPT","You have {num} page(s) selected.\n\nAre you sure you want to archive these pages?\n\nThese pages and all of their children pages will be unpublished and sent to the archive."),{num:e.length}));return t?e:!1}),this.register("admin/pages/batchactions/restore",function(e){var t=confirm(r["default"].inject(r["default"]._t("CMSMAIN.BATCH_RESTORE_PROMPT","You have {num} page(s) selected.\n\nDo you really want to restore to stage?\n\nChildren of archived pages will be restored to the root level, unless those pages are also being restored."),{num:e.length}));return t?e:!1}),this.register("admin/pages/batchactions/deletefromlive",function(e){var t=confirm(r["default"].inject(r["default"]._t("CMSMAIN.BATCH_DELETELIVE_PROMPT","You have {num} page(s) selected.\n\nDo you really want to delete these pages from live?"),{num:e.length}));return t?e:!1})},onadd:function(){this.registerDefault(),this._super()},register:function(e,t){this.trigger("register",{type:e,callback:t});var n=this.getActions();n[e]=t,this.setActions(n)},unregister:function(e){this.trigger("unregister",{type:e});var t=this.getActions();t[e]&&delete t[e],this.setActions(t)},refreshSelected:function(t){var n=this,i=this.getTree(),s=this.getIDs(),a=[],o=e(".cms-content-batchactions-button"),r=this.find(":input[name=Action]").val();null==t&&(t=i);for(var l in s)e(e(i).getNodeByID(l)).addClass("selected").attr("selected","selected");if(!r||-1==r||!o.hasClass("active"))return void e(t).find("li").each(function(){e(this).setEnabled(!0)});e(t).find("li").each(function(){a.push(e(this).data("id")),e(this).addClass("treeloading").setEnabled(!1)});var d=e.path.parseUrl(r),c=d.hrefNoSearch+"/applicablepages/";c=e.path.addSearchParams(c,d.search),c=e.path.addSearchParams(c,{csvIDs:a.join(",")}),jQuery.getJSON(c,function(i){jQuery(t).find("li").each(function(){e(this).removeClass("treeloading");var t=e(this).data("id");0==t||e.inArray(t,i)>=0?e(this).setEnabled(!0):(e(this).removeClass("selected").setEnabled(!1),e(this).prop("selected",!1))}),n.serializeFromTree()})},serializeFromTree:function(){var e=this.getTree(),t=e.getSelectedIDs();return this.setIDs(t),!0},setIDs:function(e){this.find(":input[name=csvIDs]").val(e?e.join(","):null)},getIDs:function(){var e=this.find(":input[name=csvIDs]").val();return e?e.split(","):[]},onsubmit:function(t){var n=this,i=this.getIDs(),s=this.getTree(),a=this.getActions();if(!i||!i.length)return alert(r["default"]._t("CMSMAIN.SELECTONEPAGE","Please select at least one page")),t.preventDefault(),!1;var o=this.find(":input[name=Action]").val();if(a[o]&&(i=this.getActions()[o].apply(this,[i])),!i||!i.length)return t.preventDefault(),!1;this.setIDs(i),s.find("li").removeClass("failed");var l=this.find(":submit:first");return l.addClass("loading"),jQuery.ajax({url:o,type:"POST",data:this.serializeArray(),complete:function(e,t){l.removeClass("loading"),s.jstree("refresh",-1),n.setIDs([]),n.find(":input[name=Action]").val("").change();var i=e.getResponseHeader("X-Status");i&&statusMessage(decodeURIComponent(i),"success"==t?"good":"bad")},success:function(t,n){var i,a;if(t.modified){var o=[];for(i in t.modified)a=s.getNodeByID(i),s.jstree("set_text",a,t.modified[i].TreeTitle),o.push(a);e(o).effect("highlight")}if(t.deleted)for(i in t.deleted)a=s.getNodeByID(i),a.length&&s.jstree("delete_node",a);if(t.error)for(i in t.error)a=s.getNodeByID(i),e(a).addClass("failed")},dataType:"json"}),t.preventDefault(),!1}}),e(".cms-content-batchactions-button").entwine({onmatch:function(){this._super(),this.updateTree()},onunmatch:function(){this._super()},onclick:function(e){this.updateTree()},updateTree:function(){var t=e(".cms-tree"),n=e("#Form_BatchActionsForm");this._super(),this.data("active")?(t.addClass("multiple"),t.removeClass("draggable"),n.serializeFromTree()):(t.removeClass("multiple"),t.addClass("draggable")),e("#Form_BatchActionsForm").refreshSelected()}}),e("#Form_BatchActionsForm select[name=Action]").entwine({onchange:function(t){var n=e(t.target.form),i=n.find(":submit"),s=e(t.target).val();s&&-1!=s?i.removeAttr("disabled").button("refresh"):i.attr("disabled","disabled").button("refresh"),e("#Form_BatchActionsForm").refreshSelected(),this.trigger("chosen:updated"),this._super(t)}})})},{i18n:"i18n",jQuery:"jQuery"}],4:[function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}var s=e("jQuery"),a=i(s);a["default"].entwine("ss",function(e){e(".cms-content").entwine({onadd:function(){this.find(".cms-tabset").redrawTabs(),this._super()},redraw:function(){window.debug&&console.log("redraw",this.attr("class"),this.get(0)),this.add(this.find(".cms-tabset")).redrawTabs(),this.find(".cms-content-header").redraw(),this.find(".cms-content-actions").redraw()}}),e(".cms-content .cms-tree").entwine({onadd:function(){var t=this;this._super(),this.bind("select_node.jstree",function(n,i){var s=i.rslt.obj,a=t.find(":input[name=ID]").val(),o=i.args[2],r=e(".cms-container");if(!o)return!1;if(e(s).hasClass("disabled"))return!1;if(e(s).data("id")!=a){var l=e(s).find("a:first").attr("href");l&&"#"!=l?(l=l.split("?")[0],t.jstree("deselect_all"),t.jstree("uncheck_all"),e.path.isExternal(e(s).find("a:first"))&&(l=l=e.path.makeUrlAbsolute(l,e("base").attr("href"))),document.location.search&&(l=e.path.addSearchParams(l,document.location.search.replace(/^\?/,""))),r.loadPanel(l)):t.removeForm()}})}}),e(".cms-content .cms-content-fields").entwine({redraw:function(){window.debug&&console.log("redraw",this.attr("class"),this.get(0))}}),e(".cms-content .cms-content-header, .cms-content .cms-content-actions").entwine({redraw:function(){window.debug&&console.log("redraw",this.attr("class"),this.get(0)),this.height("auto"),this.height(this.innerHeight()-this.css("padding-top")-this.css("padding-bottom"))}})})},{jQuery:"jQuery"}],5:[function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}var s=e("jQuery"),a=i(s),o=e("i18n"),r=i(o);window.onbeforeunload=function(e){var t=(0,a["default"])(".cms-edit-form");return t.trigger("beforesubmitform"),t.is(".changed")&&!t.is(".discardchanges")?r["default"]._t("LeftAndMain.CONFIRMUNSAVEDSHORT"):void 0},a["default"].entwine("ss",function(e){e(".cms-edit-form").entwine({PlaceholderHtml:"",ChangeTrackerOptions:{ignoreFieldSelector:".no-change-track, .ss-upload :input, .cms-navigator :input"},onadd:function(){this.attr("autocomplete","off"),this._setupChangeTracker();for(var t in{action:!0,method:!0,enctype:!0,name:!0}){var n=this.find(":input[name=_form_"+t+"]");n&&(this.attr(t,n.val()),n.remove())}if(this.hasClass("validationerror")){var i=this.find(".message.validation, .message.required").first().closest(".tab");e(".cms-container").clearCurrentTabState(),i.closest(".ss-tabset").tabs("option","active",i.index(".tab"))}this._super()},onremove:function(){this.changetracker("destroy"),this._super()},onmatch:function(){this._super()},onunmatch:function(){this._super()},redraw:function(){window.debug&&console.log("redraw",this.attr("class"),this.get(0)),this.add(this.find(".cms-tabset")).redrawTabs(),this.find(".cms-content-header").redraw()},_setupChangeTracker:function(){this.changetracker(this.getChangeTrackerOptions())},confirmUnsavedChanges:function(){if(this.trigger("beforesubmitform"),!this.is(".changed")||this.is(".discardchanges"))return!0;var e=confirm(r["default"]._t("LeftAndMain.CONFIRMUNSAVED"));return e&&this.addClass("discardchanges"),e},onsubmit:function(e,t){return"_blank"!=this.prop("target")?(t&&this.closest(".cms-container").submitForm(this,t),!1):void 0},validate:function(){var e=!0;return this.trigger("validate",{isValid:e}),e},"from .htmleditor":{oneditorinit:function(t){var n=this,i=e(t.target).closest(".field.htmleditor"),s=i.find("textarea.htmleditor").getEditor().getInstance();s.onClick.add(function(e){n.saveFieldFocus(i.attr("id"))})}},"from .cms-edit-form :input:not(:submit)":{onclick:function(t){this.saveFieldFocus(e(t.target).attr("id"))},onfocus:function(t){this.saveFieldFocus(e(t.target).attr("id"))}},"from .cms-edit-form .treedropdown *":{onfocusin:function(t){var n=e(t.target).closest(".field.treedropdown");this.saveFieldFocus(n.attr("id"))}},"from .cms-edit-form .dropdown .chosen-container a":{onfocusin:function(t){var n=e(t.target).closest(".field.dropdown");this.saveFieldFocus(n.attr("id"))}},"from .cms-container":{ontabstaterestored:function(e){this.restoreFieldFocus()}},saveFieldFocus:function(t){if("undefined"!=typeof window.sessionStorage&&null!==window.sessionStorage){var n=e(this).attr("id"),i=[];if(i.push({id:n,selected:t}),i)try{window.sessionStorage.setItem(n,JSON.stringify(i))}catch(s){if(s.code===DOMException.QUOTA_EXCEEDED_ERR&&0===window.sessionStorage.length)return;throw s}}},restoreFieldFocus:function(){if("undefined"!=typeof window.sessionStorage&&null!==window.sessionStorage){var t,n,i,s,a,o=this,r="undefined"!=typeof window.sessionStorage&&window.sessionStorage,l=r?window.sessionStorage.getItem(this.attr("id")):null,d=l?JSON.parse(l):!1,c=0!==this.find(".ss-tabset").length;if(r&&d.length>0){if(e.each(d,function(n,i){o.is("#"+i.id)&&(t=e("#"+i.selected))}),e(t).length<1)return void this.focusFirstInput();if(n=e(t).closest(".ss-tabset").find(".ui-tabs-nav .ui-tabs-active .ui-tabs-anchor").attr("id"),i="tab-"+e(t).closest(".ss-tabset .ui-tabs-panel").attr("id"),c&&i!==n)return;s=e(t).closest(".togglecomposite"),s.length>0&&s.accordion("activate",s.find(".ui-accordion-header")),a=e(t).position().top,e(t).is(":visible")||(t="#"+e(t).closest(".field").attr("id"),a=e(t).position().top),e(t).focus(),a>e(window).height()/2&&o.find(".cms-content-fields").scrollTop(a)}else this.focusFirstInput()}},focusFirstInput:function(){this.find(':input:not(:submit)[data-skip-autofocus!="true"]').filter(":visible:first").focus()}}),e(".cms-edit-form .Actions input.action[type=submit], .cms-edit-form .Actions button.action").entwine({onclick:function(e){return this.hasClass("gridfield-button-delete")&&!confirm(r["default"]._t("TABLEFIELD.DELETECONFIRMMESSAGE"))?(e.preventDefault(),!1):(this.is(":disabled")||this.parents("form").trigger("submit",[this]),e.preventDefault(),!1)}}),e(".cms-edit-form .Actions input.action[type=submit].ss-ui-action-cancel, .cms-edit-form .Actions button.action.ss-ui-action-cancel").entwine({onclick:function(e){window.history.length>1?window.history.back():this.parents("form").trigger("submit",[this]),e.preventDefault()}}),e(".cms-edit-form .ss-tabset").entwine({onmatch:function(){if(!this.hasClass("ss-ui-action-tabset")){var e=this.find("> ul:first");1==e.children("li").length&&e.hide().parent().addClass("ss-tabset-tabshidden")}this._super()},onunmatch:function(){this._super()}})})},{i18n:"i18n",jQuery:"jQuery"}],6:[function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}var s=e("jQuery"),a=i(s);a["default"].entwine("ss",function(e){e(".cms-description-toggle").entwine({onadd:function(){var e=!1,t=this.prop("id").substr(0,this.prop("id").indexOf("_Holder")),n=this.find(".cms-description-trigger"),i=this.find(".description");this.hasClass("description-toggle-enabled")||(0===n.length&&(n=this.find(".middleColumn").first().after('<label class="right" for="'+t+'"><a class="cms-description-trigger" href="javascript:void(0)"><span class="btn-icon-information"></span></a></label>').next()),this.addClass("description-toggle-enabled"),n.on("click",function(){i[e?"hide":"show"](),e=!e}),i.hide())}})})},{jQuery:"jQuery"}],7:[function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}var s=e("jQuery"),a=i(s);a["default"].entwine("ss",function(e){e(".cms .field.cms-description-tooltip").entwine({onmatch:function(){this._super();var e=this.find(".description");e.length&&(this.attr("title",e.text()).tooltip({content:e.html()}),e.remove())}}),e(".cms .field.cms-description-tooltip :input").entwine({onfocusin:function(e){this.closest(".field").tooltip("open")},onfocusout:function(e){this.closest(".field").tooltip("close")}})})},{jQuery:"jQuery"}],8:[function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}var s=e("jQuery"),a=i(s);a["default"].fn.layout.defaults.resize=!1,jLayout="undefined"==typeof jLayout?{}:jLayout,jLayout.threeColumnCompressor=function(e,t){function n(e){var t=e+"Size";return function(e){var n=s[t](),i=o[t](),a=r[t](),l=e.insets();return width=n.width+i.width+a.width,height=Math.max(n.height,i.height,a.height),{width:l.left+l.right+width,height:l.top+l.bottom+height}}}if("undefined"==typeof e.menu||"undefined"==typeof e.content||"undefined"==typeof e.preview)throw'Spec is invalid. Please provide "menu", "content" and "preview" elements.';if("undefined"==typeof t.minContentWidth||"undefined"==typeof t.minPreviewWidth||"undefined"==typeof t.mode)throw'Spec is invalid. Please provide "minContentWidth", "minPreviewWidth", "mode"';if("split"!==t.mode&&"content"!==t.mode&&"preview"!==t.mode)throw'Spec is invalid. "mode" should be either "split", "content" or "preview"';var i={options:t},s=a["default"].jLayoutWrap(e.menu),o=a["default"].jLayoutWrap(e.content),r=a["default"].jLayoutWrap(e.preview);return i.layout=function(n){var i=n.bounds(),a=n.insets(),l=a.top,d=i.height-a.bottom,c=a.left,u=i.width-a.right,h=e.menu.width(),f=0,p=0;"preview"===this.options.mode?(f=0,p=u-c-h):"content"===this.options.mode?(f=u-c-h,p=0):(f=(u-c-h)/2,p=u-c-(h+f),f<this.options.minContentWidth?(f=this.options.minContentWidth,p=u-c-(h+f)):p<this.options.minPreviewWidth&&(p=this.options.minPreviewWidth,f=u-c-(h+p)),(f<this.options.minContentWidth||p<this.options.minPreviewWidth)&&(f=u-c-h,p=0));var m={content:e.content.hasClass("column-hidden"),preview:e.preview.hasClass("column-hidden")},g={content:0===f,preview:0===p};return e.content.toggleClass("column-hidden",g.content),e.preview.toggleClass("column-hidden",g.preview),s.bounds({x:c,y:l,height:d-l,width:h}),s.doLayout(),c+=h,o.bounds({x:c,y:l,height:d-l,width:f}),g.content||o.doLayout(),c+=f,r.bounds({x:c,y:l,height:d-l,width:p}),g.preview||r.doLayout(),g.content!==m.content&&e.content.trigger("columnvisibilitychanged"),g.preview!==m.preview&&e.preview.trigger("columnvisibilitychanged"),f+p<t.minContentWidth+t.minPreviewWidth?e.preview.trigger("disable"):e.preview.trigger("enable"),n},i.preferred=n("preferred"),i.minimum=n("minimum"),i.maximum=n("maximum"),i}},{jQuery:"jQuery"}],9:[function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}var s=e("jQuery"),a=i(s);a["default"].entwine("ss",function(e){e(".cms-panel.cms-menu").entwine({togglePanel:function(t,n,i){e(".cms-menu-list").children("li").each(function(){t?e(this).children("ul").each(function(){e(this).removeClass("collapsed-flyout"),e(this).data("collapse")&&(e(this).removeData("collapse"),e(this).addClass("collapse"))}):e(this).children("ul").each(function(){e(this).addClass("collapsed-flyout"),e(this).hasClass("collapse"),e(this).removeClass("collapse"),e(this).data("collapse",!0)})}),this.toggleFlyoutState(t),this._super(t,n,i)},toggleFlyoutState:function(t){if(t)e(".collapsed").find("li").show(),e(".cms-menu-list").find(".child-flyout-indicator").hide();else{e(".collapsed-flyout").find("li").each(function(){e(this).hide()});var n=e(".cms-menu-list ul.collapsed-flyout").parent();0===n.children(".child-flyout-indicator").length&&n.append('<span class="child-flyout-indicator"></span>').fadeIn(),n.children(".child-flyout-indicator").fadeIn()}},siteTreePresent:function(){return e("#cms-content-tools-CMSMain").length>0},getPersistedStickyState:function(){var t,n;return void 0!==e.cookie&&(n=e.cookie("cms-menu-sticky"),void 0!==n&&null!==n&&(t="true"===n)),t},setPersistedStickyState:function(t){void 0!==e.cookie&&e.cookie("cms-menu-sticky",t,{path:"/",expires:31})},getEvaluatedCollapsedState:function(){var t,n=this.getPersistedCollapsedState(),i=e(".cms-menu").getPersistedStickyState(),s=this.siteTreePresent();return t=void 0===n?s:n!==s&&i?n:s},onadd:function(){var t=this;setTimeout(function(){t.togglePanel(!t.getEvaluatedCollapsedState(),!1,!1)},0),e(window).on("ajaxComplete",function(e){setTimeout(function(){t.togglePanel(!t.getEvaluatedCollapsedState(),!1,!1)},0)}),this._super()}}),e(".cms-menu-list").entwine({onmatch:function(){this.find("li.current").select(),this.updateItems(),this._super()},onunmatch:function(){this._super()},updateMenuFromResponse:function(e){var t=e.getResponseHeader("X-Controller");if(t){var n=this.find("li#Menu-"+t.replace(/\\/g,"-").replace(/[^a-zA-Z0-9\-_:.]+/,""));n.hasClass("current")||n.select()}this.updateItems()},"from .cms-container":{onafterstatechange:function(e,t){this.updateMenuFromResponse(t.xhr)},onaftersubmitform:function(e,t){this.updateMenuFromResponse(t.xhr)}},"from .cms-edit-form":{onrelodeditform:function(e,t){this.updateMenuFromResponse(t.xmlhttp)}},getContainingPanel:function(){return this.closest(".cms-panel")},fromContainingPanel:{ontoggle:function(t){this.toggleClass("collapsed",e(t.target).hasClass("collapsed")),e(".cms-container").trigger("windowresize"),this.hasClass("collapsed")&&this.find("li.children.opened").removeClass("opened"),this.hasClass("collapsed")||e(".toggle-children.opened").closest("li").addClass("opened")}},updateItems:function(){var t=this.find("#Menu-CMSMain");t[t.is(".current")?"show":"hide"]();var n=e(".cms-content input[name=ID]").val();n&&this.find("li").each(function(){e.isFunction(e(this).setRecordID)&&e(this).setRecordID(n)})}}),e(".cms-menu-list li").entwine({toggleFlyout:function(t){var n=e(this);if(n.children("ul").first().hasClass("collapsed-flyout"))if(t){if(!n.children("ul").first().children("li").first().hasClass("clone")){var i=n.clone();i.addClass("clone").css({}),i.children("ul").first().remove(),i.find("span").not(".text").remove(),i.find("a").first().unbind("click"),n.children("ul").prepend(i)}e(".collapsed-flyout").show(),n.addClass("opened"),n.children("ul").find("li").fadeIn("fast")}else i&&i.remove(),e(".collapsed-flyout").hide(),n.removeClass("opened"),n.find("toggle-children").removeClass("opened"),n.children("ul").find("li").hide()}}),e(".cms-menu-list li").hoverIntent(function(){e(this).toggleFlyout(!0)},function(){e(this).toggleFlyout(!1)}),e(".cms-menu-list .toggle").entwine({onclick:function(t){t.preventDefault(),e(this).toogleFlyout(!0)}}),e(".cms-menu-list li").entwine({onmatch:function(){this.find("ul").length&&this.find("a:first").append('<span class="toggle-children"><span class="toggle-children-icon"></span></span>'),this._super()},onunmatch:function(){this._super()},toggle:function(){this[this.hasClass("opened")?"close":"open"]()},open:function(){var e=this.getMenuItem();e&&e.open(),this.find("li.clone")&&this.find("li.clone").remove(),this.addClass("opened").find("ul").show(),this.find(".toggle-children").addClass("opened")},close:function(){this.removeClass("opened").find("ul").hide(),this.find(".toggle-children").removeClass("opened")},select:function(){var e=this.getMenuItem();if(this.addClass("current").open(),this.siblings().removeClass("current").close(),this.siblings().find("li").removeClass("current"),e){var t=e.siblings();e.addClass("current"),t.removeClass("current").close(),t.find("li").removeClass("current").close()}this.getMenu().updateItems(),this.trigger("select")}}),e(".cms-menu-list *").entwine({getMenu:function(){return this.parents(".cms-menu-list:first")}}),e(".cms-menu-list li *").entwine({getMenuItem:function(){return this.parents("li:first")}}),e(".cms-menu-list li a").entwine({onclick:function(t){var n=e.path.isExternal(this.attr("href"));if(!(t.which>1||n)&&"_blank"!=this.attr("target")){t.preventDefault();var i=this.getMenuItem(),s=this.attr("href");n||(s=e("base").attr("href")+s);var a=i.find("li");if(a.length)a.first().find("a").click();else if(!e(".cms-container").loadPanel(s))return!1;i.select()}}}),e(".cms-menu-list li .toggle-children").entwine({onclick:function(e){var t=this.closest("li");return t.toggle(),!1}}),e(".cms .profile-link").entwine({onclick:function(){return e(".cms-container").loadPanel(this.attr("href")),e(".cms-menu-list li").removeClass("current").close(),!1}}),e(".cms-menu .sticky-toggle").entwine({onadd:function(){var t=!!e(".cms-menu").getPersistedStickyState();this.toggleCSS(t),this.toggleIndicator(t),this._super()},toggleCSS:function(e){this[e?"addClass":"removeClass"]("active")},toggleIndicator:function(e){this.next(".sticky-status-indicator").text(e?"fixed":"auto")},onclick:function(){var e=this.closest(".cms-menu"),t=e.getPersistedCollapsedState(),n=e.getPersistedStickyState(),i=void 0===n?!this.hasClass("active"):!n;void 0===t?e.setPersistedCollapsedState(e.hasClass("collapsed")):void 0!==t&&i===!1&&e.clearPersistedCollapsedState(),e.setPersistedStickyState(i),this.toggleCSS(i),this.toggleIndicator(i),this._super()}})})},{jQuery:"jQuery"}],10:[function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}var s=e("jQuery"),a=i(s);a["default"].entwine("ss",function(e){e.entwine.warningLevel=e.entwine.WARN_LEVEL_BESTPRACTISE,e(".cms-panel").entwine({WidthExpanded:null,WidthCollapsed:null,canSetCookie:function(){return void 0!==e.cookie&&void 0!==this.attr("id")},getPersistedCollapsedState:function(){var t,n;return this.canSetCookie()&&(n=e.cookie("cms-panel-collapsed-"+this.attr("id")),void 0!==n&&null!==n&&(t="true"===n)),t},setPersistedCollapsedState:function(t){this.canSetCookie()&&e.cookie("cms-panel-collapsed-"+this.attr("id"),t,{path:"/",expires:31})},clearPersistedCollapsedState:function(){this.canSetCookie()&&e.cookie("cms-panel-collapsed-"+this.attr("id"),"",{path:"/",expires:-1})},getInitialCollapsedState:function(){var e=this.getPersistedCollapsedState();return void 0===e&&(e=this.hasClass("collapsed")),e},onadd:function(){var t,n;if(!this.find(".cms-panel-content").length)throw new Exception('Content panel for ".cms-panel" not found');this.find(".cms-panel-toggle").length||(n=e("<div class='cms-panel-toggle south'></div>").append('<a class="toggle-expand" href="#"><span>&raquo;</span></a>').append('<a class="toggle-collapse" href="#"><span>&laquo;</span></a>'),this.append(n)),this.setWidthExpanded(this.find(".cms-panel-content").innerWidth()),t=this.find(".cms-panel-content-collapsed"),this.setWidthCollapsed(t.length?t.innerWidth():this.find(".toggle-expand").innerWidth()),this.togglePanel(!this.getInitialCollapsedState(),!0,!1),this._super()},togglePanel:function(e,t,n){var i,s;t||(this.trigger("beforetoggle.sspanel",e),this.trigger(e?"beforeexpand":"beforecollapse")),this.toggleClass("collapsed",!e),i=e?this.getWidthExpanded():this.getWidthCollapsed(),this.width(i),s=this.find(".cms-panel-content-collapsed"),s.length&&(this.find(".cms-panel-content")[e?"show":"hide"](),this.find(".cms-panel-content-collapsed")[e?"hide":"show"]()),n!==!1&&this.setPersistedCollapsedState(!e),this.trigger("toggle",e),this.trigger(e?"expand":"collapse")},expandPanel:function(e){(e||this.hasClass("collapsed"))&&this.togglePanel(!0)},collapsePanel:function(e){!e&&this.hasClass("collapsed")||this.togglePanel(!1)}}),e(".cms-panel.collapsed .cms-panel-toggle").entwine({onclick:function(e){this.expandPanel(),e.preventDefault()}}),e(".cms-panel *").entwine({getPanel:function(){return this.parents(".cms-panel:first")}}),e(".cms-panel .toggle-expand").entwine({onclick:function(e){e.preventDefault(),e.stopPropagation(),this.getPanel().expandPanel(),this._super(e)}}),e(".cms-panel .toggle-collapse").entwine({onclick:function(e){e.preventDefault(),e.stopPropagation(),this.getPanel().collapsePanel(),this._super(e)}}),e(".cms-content-tools.collapsed").entwine({onclick:function(e){this.expandPanel(),this._super(e)}})})},{jQuery:"jQuery"}],11:[function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}var s=e("jQuery"),a=i(s),o=e("i18n"),r=i(o);a["default"].entwine("ss.preview",function(e){e(".cms-preview").entwine({AllowedStates:["StageLink","LiveLink","ArchiveLink"],CurrentStateName:null,CurrentSizeName:"auto",IsPreviewEnabled:!1,DefaultMode:"split",Sizes:{auto:{width:"100%",height:"100%"},mobile:{width:"335px",height:"568px"},mobileLandscape:{width:"583px",height:"320px"},tablet:{width:"783px",height:"1024px"},tabletLandscape:{width:"1039px",height:"768px"},desktop:{width:"1024px",height:"800px"}},changeState:function(t,n){var i=this,s=this._getNavigatorStates();return n!==!1&&e.each(s,function(e,n){i.saveState("state",t)}),this.setCurrentStateName(t),this._loadCurrentState(),this.redraw(),this},changeMode:function(t,n){var i=e(".cms-container");if("split"==t)i.entwine(".ss").splitViewMode(),this.setIsPreviewEnabled(!0),this._loadCurrentState();else if("content"==t)i.entwine(".ss").contentViewMode(),this.setIsPreviewEnabled(!1);else{if("preview"!=t)throw"Invalid mode: "+t;i.entwine(".ss").previewMode(),this.setIsPreviewEnabled(!0),this._loadCurrentState()}return n!==!1&&this.saveState("mode",t),this.redraw(),this},changeSize:function(e){var t=this.getSizes();return this.setCurrentSizeName(e),this.removeClass("auto desktop tablet mobile").addClass(e),this.find(".preview-device-outer").width(t[e].width).height(t[e].height),this.find(".preview-device-inner").width(t[e].width),this.saveState("size",e),this.redraw(),this},redraw:function(){window.debug&&console.log("redraw",this.attr("class"),this.get(0));var t=this.getCurrentStateName();t&&this.find(".cms-preview-states").changeVisibleState(t);var n=e(".cms-container").entwine(".ss").getLayoutOptions();n&&e(".preview-mode-selector").changeVisibleMode(n.mode);var i=this.getCurrentSizeName();return i&&this.find(".preview-size-selector").changeVisibleSize(this.getCurrentSizeName()),this},saveState:function(e,t){this._supportsLocalStorage()&&window.localStorage.setItem("cms-preview-state-"+e,t)},loadState:function(e){return this._supportsLocalStorage()?window.localStorage.getItem("cms-preview-state-"+e):void 0},disablePreview:function(){return this.setPendingURL(null),this._loadUrl("about:blank"),this._block(),this.changeMode("content",!1),this.setIsPreviewEnabled(!1),this},enablePreview:function(){return this.getIsPreviewEnabled()||(this.setIsPreviewEnabled(!0),e.browser.msie&&e.browser.version.slice(0,3)<=7?this.changeMode("content"):this.changeMode(this.getDefaultMode(),!1)),this},getOrAppendFontFixStyleElement:function(){var t=e("#FontFixStyleElement");return t.length||(t=e('<style type="text/css" id="FontFixStyleElement" disabled="disabled">:before,:after{content:none !important}</style>').appendTo("head")), !function e(t,n,i){function s(o,r){if(!n[o]){if(!t[o]){var l="function"==typeof require&&require;if(!r&&l)return l(o,!0);if(a)return a(o,!0);var d=new Error("Cannot find module '"+o+"'");throw d.code="MODULE_NOT_FOUND",d}var c=n[o]={exports:{}};t[o][0].call(c.exports,function(e){var n=t[o][1][e];return s(n?n:e)},c,c.exports,e,t,n,i)}return n[o].exports}for(var a="function"==typeof require&&require,o=0;o<i.length;o++)s(i[o]);return s}({1:[function(e,t,n){"use strict";e("../legacy/LeftAndMain.Layout.js"),e("../legacy/LeftAndMain.js"),e("../legacy/LeftAndMain.ActionTabSet.js"),e("../legacy/LeftAndMain.Panel.js"),e("../legacy/LeftAndMain.Tree.js"),e("../legacy/LeftAndMain.Content.js"),e("../legacy/LeftAndMain.EditForm.js"),e("../legacy/LeftAndMain.Menu.js"),e("../legacy/LeftAndMain.Preview.js"),e("../legacy/LeftAndMain.BatchActions.js"),e("../legacy/LeftAndMain.FieldHelp.js"),e("../legacy/LeftAndMain.FieldDescriptionToggle.js"),e("../legacy/LeftAndMain.TreeDropdownField.js")},{"../legacy/LeftAndMain.ActionTabSet.js":2,"../legacy/LeftAndMain.BatchActions.js":3,"../legacy/LeftAndMain.Content.js":4,"../legacy/LeftAndMain.EditForm.js":5,"../legacy/LeftAndMain.FieldDescriptionToggle.js":6,"../legacy/LeftAndMain.FieldHelp.js":7,"../legacy/LeftAndMain.Layout.js":8,"../legacy/LeftAndMain.Menu.js":9,"../legacy/LeftAndMain.Panel.js":10,"../legacy/LeftAndMain.Preview.js":11,"../legacy/LeftAndMain.Tree.js":12,"../legacy/LeftAndMain.TreeDropdownField.js":13,"../legacy/LeftAndMain.js":14}],2:[function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}var s=e("jQuery"),a=i(s);a["default"].entwine("ss",function(e){e(".ss-tabset.ss-ui-action-tabset").entwine({IgnoreTabState:!0,onadd:function(){this._super(),this.tabs({collapsible:!0,active:!1})},onremove:function(){var t=e(".cms-container").find("iframe");t.each(function(t,n){try{e(n).contents().off("click.ss-ui-action-tabset")}catch(i){console.warn("Unable to access iframe, possible https mis-match")}}),e(document).off("click.ss-ui-action-tabset"),this._super()},ontabsbeforeactivate:function(e,t){this.riseUp(e,t)},onclick:function(e,t){this.attachCloseHandler(e,t)},attachCloseHandler:function(t,n){var i,s=this,a=e(".cms-container").find("iframe");i=function(t){var n,a;n=e(t.target).closest(".ss-ui-action-tabset .ui-tabs-panel"),e(t.target).closest(s).length||n.length||(s.tabs("option","active",!1),a=e(".cms-container").find("iframe"),a.each(function(t,n){e(n).contents().off("click.ss-ui-action-tabset",i)}),e(document).off("click.ss-ui-action-tabset",i))},e(document).on("click.ss-ui-action-tabset",i),a.length>0&&a.each(function(t,n){e(n).contents().on("click.ss-ui-action-tabset",i)})},riseUp:function(t,n){var i,s,a,o,r,l,d,c,u;return i=e(this).find(".ui-tabs-panel").outerHeight(),s=e(this).find(".ui-tabs-nav").outerHeight(),a=e(window).height()+e(document).scrollTop()-s,o=e(this).find(".ui-tabs-nav").offset().top,r=n.newPanel,l=n.newTab,o+i>=a&&o-i>0?(this.addClass("rise-up"),null!==l.position()&&(d=-r.outerHeight(),c=r.parents(".south"),c&&(u=l.offset().top-c.offset().top,d-=u),e(r).css("top",d+"px"))):(this.removeClass("rise-up"),null!==l.position()&&e(r).css("top","0px")),!1}}),e(".cms-content-actions .ss-tabset.ss-ui-action-tabset").entwine({ontabsbeforeactivate:function(t,n){this._super(t,n),e(n.newPanel).length>0&&e(n.newPanel).css("left",n.newTab.position().left+"px")}}),e(".cms-actions-row.ss-tabset.ss-ui-action-tabset").entwine({ontabsbeforeactivate:function(t,n){this._super(t,n),e(this).closest(".ss-ui-action-tabset").removeClass("tabset-open tabset-open-last")}}),e(".cms-content-fields .ss-tabset.ss-ui-action-tabset").entwine({ontabsbeforeactivate:function(t,n){this._super(t,n),e(n.newPanel).length>0&&(e(n.newTab).hasClass("last")?(e(n.newPanel).css({left:"auto",right:"0px"}),e(n.newPanel).parent().addClass("tabset-open-last")):(e(n.newPanel).css("left",n.newTab.position().left+"px"),e(n.newTab).hasClass("first")&&(e(n.newPanel).css("left","0px"),e(n.newPanel).parent().addClass("tabset-open"))))}}),e(".cms-tree-view-sidebar .cms-actions-row.ss-tabset.ss-ui-action-tabset").entwine({"from .ui-tabs-nav li":{onhover:function(t){e(t.target).parent().find("li .active").removeClass("active"),e(t.target).find("a").addClass("active")}},ontabsbeforeactivate:function(t,n){this._super(t,n),e(n.newPanel).css({left:"auto",right:"auto"}),e(n.newPanel).length>0&&e(n.newPanel).parent().addClass("tabset-open")}})})},{jQuery:"jQuery"}],3:[function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}var s=e("jQuery"),a=i(s),o=e("i18n"),r=i(o);a["default"].entwine("ss.tree",function(e){e("#Form_BatchActionsForm").entwine({Actions:[],getTree:function(){return e(".cms-tree")},fromTree:{oncheck_node:function(e,t){this.serializeFromTree()},onuncheck_node:function(e,t){this.serializeFromTree()}},registerDefault:function(){this.register("admin/pages/batchactions/publish",function(e){var t=confirm(r["default"].inject(r["default"]._t("CMSMAIN.BATCH_PUBLISH_PROMPT","You have {num} page(s) selected.\n\nDo you really want to publish?"),{num:e.length}));return t?e:!1}),this.register("admin/pages/batchactions/unpublish",function(e){var t=confirm(r["default"].inject(r["default"]._t("CMSMAIN.BATCH_UNPUBLISH_PROMPT","You have {num} page(s) selected.\n\nDo you really want to unpublish"),{num:e.length}));return t?e:!1}),this.register("admin/pages/batchactions/delete",function(e){var t=confirm(r["default"].inject(r["default"]._t("CMSMAIN.BATCH_DELETE_PROMPT","You have {num} page(s) selected.\n\nDo you really want to delete?"),{num:e.length}));return t?e:!1}),this.register("admin/pages/batchactions/archive",function(e){var t=confirm(r["default"].inject(r["default"]._t("CMSMAIN.BATCH_ARCHIVE_PROMPT","You have {num} page(s) selected.\n\nAre you sure you want to archive these pages?\n\nThese pages and all of their children pages will be unpublished and sent to the archive."),{num:e.length}));return t?e:!1}),this.register("admin/pages/batchactions/restore",function(e){var t=confirm(r["default"].inject(r["default"]._t("CMSMAIN.BATCH_RESTORE_PROMPT","You have {num} page(s) selected.\n\nDo you really want to restore to stage?\n\nChildren of archived pages will be restored to the root level, unless those pages are also being restored."),{num:e.length}));return t?e:!1}),this.register("admin/pages/batchactions/deletefromlive",function(e){var t=confirm(r["default"].inject(r["default"]._t("CMSMAIN.BATCH_DELETELIVE_PROMPT","You have {num} page(s) selected.\n\nDo you really want to delete these pages from live?"),{num:e.length}));return t?e:!1})},onadd:function(){this.registerDefault(),this._super()},register:function(e,t){this.trigger("register",{type:e,callback:t});var n=this.getActions();n[e]=t,this.setActions(n)},unregister:function(e){this.trigger("unregister",{type:e});var t=this.getActions();t[e]&&delete t[e],this.setActions(t)},refreshSelected:function(t){var n=this,i=this.getTree(),s=this.getIDs(),a=[],o=e(".cms-content-batchactions-button"),r=this.find(":input[name=Action]").val();null==t&&(t=i);for(var l in s)e(e(i).getNodeByID(l)).addClass("selected").attr("selected","selected");if(!r||-1==r||!o.hasClass("active"))return void e(t).find("li").each(function(){e(this).setEnabled(!0)});e(t).find("li").each(function(){a.push(e(this).data("id")),e(this).addClass("treeloading").setEnabled(!1)});var d=e.path.parseUrl(r),c=d.hrefNoSearch+"/applicablepages/";c=e.path.addSearchParams(c,d.search),c=e.path.addSearchParams(c,{csvIDs:a.join(",")}),jQuery.getJSON(c,function(i){jQuery(t).find("li").each(function(){e(this).removeClass("treeloading");var t=e(this).data("id");0==t||e.inArray(t,i)>=0?e(this).setEnabled(!0):(e(this).removeClass("selected").setEnabled(!1),e(this).prop("selected",!1))}),n.serializeFromTree()})},serializeFromTree:function(){var e=this.getTree(),t=e.getSelectedIDs();return this.setIDs(t),!0},setIDs:function(e){this.find(":input[name=csvIDs]").val(e?e.join(","):null)},getIDs:function(){var e=this.find(":input[name=csvIDs]").val();return e?e.split(","):[]},onsubmit:function(t){var n=this,i=this.getIDs(),s=this.getTree(),a=this.getActions();if(!i||!i.length)return alert(r["default"]._t("CMSMAIN.SELECTONEPAGE","Please select at least one page")),t.preventDefault(),!1;var o=this.find(":input[name=Action]").val();if(a[o]&&(i=this.getActions()[o].apply(this,[i])),!i||!i.length)return t.preventDefault(),!1;this.setIDs(i),s.find("li").removeClass("failed");var l=this.find(":submit:first");return l.addClass("loading"),jQuery.ajax({url:o,type:"POST",data:this.serializeArray(),complete:function(e,t){l.removeClass("loading"),s.jstree("refresh",-1),n.setIDs([]),n.find(":input[name=Action]").val("").change();var i=e.getResponseHeader("X-Status");i&&statusMessage(decodeURIComponent(i),"success"==t?"good":"bad")},success:function(t,n){var i,a;if(t.modified){var o=[];for(i in t.modified)a=s.getNodeByID(i),s.jstree("set_text",a,t.modified[i].TreeTitle),o.push(a);e(o).effect("highlight")}if(t.deleted)for(i in t.deleted)a=s.getNodeByID(i),a.length&&s.jstree("delete_node",a);if(t.error)for(i in t.error)a=s.getNodeByID(i),e(a).addClass("failed")},dataType:"json"}),t.preventDefault(),!1}}),e(".cms-content-batchactions-button").entwine({onmatch:function(){this._super(),this.updateTree()},onunmatch:function(){this._super()},onclick:function(e){this.updateTree()},updateTree:function(){var t=e(".cms-tree"),n=e("#Form_BatchActionsForm");this._super(),this.data("active")?(t.addClass("multiple"),t.removeClass("draggable"),n.serializeFromTree()):(t.removeClass("multiple"),t.addClass("draggable")),e("#Form_BatchActionsForm").refreshSelected()}}),e("#Form_BatchActionsForm select[name=Action]").entwine({onchange:function(t){var n=e(t.target.form),i=n.find(":submit"),s=e(t.target).val();s&&-1!=s?i.removeAttr("disabled").button("refresh"):i.attr("disabled","disabled").button("refresh"),e("#Form_BatchActionsForm").refreshSelected(),this.trigger("chosen:updated"),this._super(t)}})})},{i18n:"i18n",jQuery:"jQuery"}],4:[function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}var s=e("jQuery"),a=i(s);a["default"].entwine("ss",function(e){e(".cms-content").entwine({onadd:function(){this.find(".cms-tabset").redrawTabs(),this._super()},redraw:function(){window.debug&&console.log("redraw",this.attr("class"),this.get(0)),this.add(this.find(".cms-tabset")).redrawTabs(),this.find(".cms-content-header").redraw(),this.find(".cms-content-actions").redraw()}}),e(".cms-content .cms-tree").entwine({onadd:function(){var t=this;this._super(),this.bind("select_node.jstree",function(n,i){var s=i.rslt.obj,a=t.find(":input[name=ID]").val(),o=i.args[2],r=e(".cms-container");if(!o)return!1;if(e(s).hasClass("disabled"))return!1;if(e(s).data("id")!=a){var l=e(s).find("a:first").attr("href");l&&"#"!=l?(l=l.split("?")[0],t.jstree("deselect_all"),t.jstree("uncheck_all"),e.path.isExternal(e(s).find("a:first"))&&(l=l=e.path.makeUrlAbsolute(l,e("base").attr("href"))),document.location.search&&(l=e.path.addSearchParams(l,document.location.search.replace(/^\?/,""))),r.loadPanel(l)):t.removeForm()}})}}),e(".cms-content .cms-content-fields").entwine({redraw:function(){window.debug&&console.log("redraw",this.attr("class"),this.get(0))}}),e(".cms-content .cms-content-header, .cms-content .cms-content-actions").entwine({redraw:function(){window.debug&&console.log("redraw",this.attr("class"),this.get(0)),this.height("auto"),this.height(this.innerHeight()-this.css("padding-top")-this.css("padding-bottom"))}})})},{jQuery:"jQuery"}],5:[function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}var s=e("jQuery"),a=i(s),o=e("i18n"),r=i(o);window.onbeforeunload=function(e){var t=(0,a["default"])(".cms-edit-form");return t.trigger("beforesubmitform"),t.is(".changed")&&!t.is(".discardchanges")?r["default"]._t("LeftAndMain.CONFIRMUNSAVEDSHORT"):void 0},a["default"].entwine("ss",function(e){e(".cms-edit-form").entwine({PlaceholderHtml:"",ChangeTrackerOptions:{ignoreFieldSelector:".no-change-track, .ss-upload :input, .cms-navigator :input"},onadd:function(){this.attr("autocomplete","off"),this._setupChangeTracker();for(var t in{action:!0,method:!0,enctype:!0,name:!0}){var n=this.find(":input[name=_form_"+t+"]");n&&(this.attr(t,n.val()),n.remove())}if(this.hasClass("validationerror")){var i=this.find(".message.validation, .message.required").first().closest(".tab");e(".cms-container").clearCurrentTabState(),i.closest(".ss-tabset").tabs("option","active",i.index(".tab"))}this._super()},onremove:function(){this.changetracker("destroy"),this._super()},onmatch:function(){this._super()},onunmatch:function(){this._super()},redraw:function(){window.debug&&console.log("redraw",this.attr("class"),this.get(0)),this.add(this.find(".cms-tabset")).redrawTabs(),this.find(".cms-content-header").redraw()},_setupChangeTracker:function(){this.changetracker(this.getChangeTrackerOptions())},confirmUnsavedChanges:function(){if(this.trigger("beforesubmitform"),!this.is(".changed")||this.is(".discardchanges"))return!0;var e=confirm(r["default"]._t("LeftAndMain.CONFIRMUNSAVED"));return e&&this.addClass("discardchanges"),e},onsubmit:function(e,t){return"_blank"!=this.prop("target")?(t&&this.closest(".cms-container").submitForm(this,t),!1):void 0},validate:function(){var e=!0;return this.trigger("validate",{isValid:e}),e},"from .htmleditor":{oneditorinit:function(t){var n=this,i=e(t.target).closest(".field.htmleditor"),s=i.find("textarea.htmleditor").getEditor().getInstance();s.onClick.add(function(e){n.saveFieldFocus(i.attr("id"))})}},"from .cms-edit-form :input:not(:submit)":{onclick:function(t){this.saveFieldFocus(e(t.target).attr("id"))},onfocus:function(t){this.saveFieldFocus(e(t.target).attr("id"))}},"from .cms-edit-form .treedropdown *":{onfocusin:function(t){var n=e(t.target).closest(".field.treedropdown");this.saveFieldFocus(n.attr("id"))}},"from .cms-edit-form .dropdown .chosen-container a":{onfocusin:function(t){var n=e(t.target).closest(".field.dropdown");this.saveFieldFocus(n.attr("id"))}},"from .cms-container":{ontabstaterestored:function(e){this.restoreFieldFocus()}},saveFieldFocus:function(t){if("undefined"!=typeof window.sessionStorage&&null!==window.sessionStorage){var n=e(this).attr("id"),i=[];if(i.push({id:n,selected:t}),i)try{window.sessionStorage.setItem(n,JSON.stringify(i))}catch(s){if(s.code===DOMException.QUOTA_EXCEEDED_ERR&&0===window.sessionStorage.length)return;throw s}}},restoreFieldFocus:function(){if("undefined"!=typeof window.sessionStorage&&null!==window.sessionStorage){var t,n,i,s,a,o=this,r="undefined"!=typeof window.sessionStorage&&window.sessionStorage,l=r?window.sessionStorage.getItem(this.attr("id")):null,d=l?JSON.parse(l):!1,c=0!==this.find(".ss-tabset").length;if(r&&d.length>0){if(e.each(d,function(n,i){o.is("#"+i.id)&&(t=e("#"+i.selected))}),e(t).length<1)return void this.focusFirstInput();if(n=e(t).closest(".ss-tabset").find(".ui-tabs-nav .ui-tabs-active .ui-tabs-anchor").attr("id"),i="tab-"+e(t).closest(".ss-tabset .ui-tabs-panel").attr("id"),c&&i!==n)return;s=e(t).closest(".togglecomposite"),s.length>0&&s.accordion("activate",s.find(".ui-accordion-header")),a=e(t).position().top,e(t).is(":visible")||(t="#"+e(t).closest(".field").attr("id"),a=e(t).position().top),e(t).focus(),a>e(window).height()/2&&o.find(".cms-content-fields").scrollTop(a)}else this.focusFirstInput()}},focusFirstInput:function(){this.find(':input:not(:submit)[data-skip-autofocus!="true"]').filter(":visible:first").focus()}}),e(".cms-edit-form .Actions input.action[type=submit], .cms-edit-form .Actions button.action").entwine({onclick:function(e){return this.hasClass("gridfield-button-delete")&&!confirm(r["default"]._t("TABLEFIELD.DELETECONFIRMMESSAGE"))?(e.preventDefault(),!1):(this.is(":disabled")||this.parents("form").trigger("submit",[this]),e.preventDefault(),!1)}}),e(".cms-edit-form .Actions input.action[type=submit].ss-ui-action-cancel, .cms-edit-form .Actions button.action.ss-ui-action-cancel").entwine({onclick:function(e){window.history.length>1?window.history.back():this.parents("form").trigger("submit",[this]),e.preventDefault()}}),e(".cms-edit-form .ss-tabset").entwine({onmatch:function(){if(!this.hasClass("ss-ui-action-tabset")){var e=this.find("> ul:first");1==e.children("li").length&&e.hide().parent().addClass("ss-tabset-tabshidden")}this._super()},onunmatch:function(){this._super()}})})},{i18n:"i18n",jQuery:"jQuery"}],6:[function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}var s=e("jQuery"),a=i(s);a["default"].entwine("ss",function(e){e(".cms-description-toggle").entwine({onadd:function(){var e=!1,t=this.prop("id").substr(0,this.prop("id").indexOf("_Holder")),n=this.find(".cms-description-trigger"),i=this.find(".description");this.hasClass("description-toggle-enabled")||(0===n.length&&(n=this.find(".middleColumn").first().after('<label class="right" for="'+t+'"><a class="cms-description-trigger" href="javascript:void(0)"><span class="btn-icon-information"></span></a></label>').next()),this.addClass("description-toggle-enabled"),n.on("click",function(){i[e?"hide":"show"](),e=!e}),i.hide())}})})},{jQuery:"jQuery"}],7:[function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}var s=e("jQuery"),a=i(s);a["default"].entwine("ss",function(e){e(".cms .field.cms-description-tooltip").entwine({onmatch:function(){this._super();var e=this.find(".description");e.length&&(this.attr("title",e.text()).tooltip({content:e.html()}),e.remove())}}),e(".cms .field.cms-description-tooltip :input").entwine({onfocusin:function(e){this.closest(".field").tooltip("open")},onfocusout:function(e){this.closest(".field").tooltip("close")}})})},{jQuery:"jQuery"}],8:[function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}var s=e("jQuery"),a=i(s);a["default"].fn.layout.defaults.resize=!1,jLayout="undefined"==typeof jLayout?{}:jLayout,jLayout.threeColumnCompressor=function(e,t){function n(e){var t=e+"Size";return function(e){var n=s[t](),i=o[t](),a=r[t](),l=e.insets();return width=n.width+i.width+a.width,height=Math.max(n.height,i.height,a.height),{width:l.left+l.right+width,height:l.top+l.bottom+height}}}if("undefined"==typeof e.menu||"undefined"==typeof e.content||"undefined"==typeof e.preview)throw'Spec is invalid. Please provide "menu", "content" and "preview" elements.';if("undefined"==typeof t.minContentWidth||"undefined"==typeof t.minPreviewWidth||"undefined"==typeof t.mode)throw'Spec is invalid. Please provide "minContentWidth", "minPreviewWidth", "mode"';if("split"!==t.mode&&"content"!==t.mode&&"preview"!==t.mode)throw'Spec is invalid. "mode" should be either "split", "content" or "preview"';var i={options:t},s=a["default"].jLayoutWrap(e.menu),o=a["default"].jLayoutWrap(e.content),r=a["default"].jLayoutWrap(e.preview);return i.layout=function(n){var i=n.bounds(),a=n.insets(),l=a.top,d=i.height-a.bottom,c=a.left,u=i.width-a.right,h=e.menu.width(),f=0,p=0;"preview"===this.options.mode?(f=0,p=u-c-h):"content"===this.options.mode?(f=u-c-h,p=0):(f=(u-c-h)/2,p=u-c-(h+f),f<this.options.minContentWidth?(f=this.options.minContentWidth,p=u-c-(h+f)):p<this.options.minPreviewWidth&&(p=this.options.minPreviewWidth,f=u-c-(h+p)),(f<this.options.minContentWidth||p<this.options.minPreviewWidth)&&(f=u-c-h,p=0));var m={content:e.content.hasClass("column-hidden"),preview:e.preview.hasClass("column-hidden")},g={content:0===f,preview:0===p};return e.content.toggleClass("column-hidden",g.content),e.preview.toggleClass("column-hidden",g.preview),s.bounds({x:c,y:l,height:d-l,width:h}),s.doLayout(),c+=h,o.bounds({x:c,y:l,height:d-l,width:f}),g.content||o.doLayout(),c+=f,r.bounds({x:c,y:l,height:d-l,width:p}),g.preview||r.doLayout(),g.content!==m.content&&e.content.trigger("columnvisibilitychanged"),g.preview!==m.preview&&e.preview.trigger("columnvisibilitychanged"),f+p<t.minContentWidth+t.minPreviewWidth?e.preview.trigger("disable"):e.preview.trigger("enable"),n},i.preferred=n("preferred"),i.minimum=n("minimum"),i.maximum=n("maximum"),i}},{jQuery:"jQuery"}],9:[function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}var s=e("jQuery"),a=i(s);a["default"].entwine("ss",function(e){e(".cms-panel.cms-menu").entwine({togglePanel:function(t,n,i){e(".cms-menu-list").children("li").each(function(){t?e(this).children("ul").each(function(){e(this).removeClass("collapsed-flyout"),e(this).data("collapse")&&(e(this).removeData("collapse"),e(this).addClass("collapse"))}):e(this).children("ul").each(function(){e(this).addClass("collapsed-flyout"),e(this).hasClass("collapse"),e(this).removeClass("collapse"),e(this).data("collapse",!0)})}),this.toggleFlyoutState(t),this._super(t,n,i)},toggleFlyoutState:function(t){if(t)e(".collapsed").find("li").show(),e(".cms-menu-list").find(".child-flyout-indicator").hide();else{e(".collapsed-flyout").find("li").each(function(){e(this).hide()});var n=e(".cms-menu-list ul.collapsed-flyout").parent();0===n.children(".child-flyout-indicator").length&&n.append('<span class="child-flyout-indicator"></span>').fadeIn(),n.children(".child-flyout-indicator").fadeIn()}},siteTreePresent:function(){return e("#cms-content-tools-CMSMain").length>0},getPersistedStickyState:function(){var t,n;return void 0!==e.cookie&&(n=e.cookie("cms-menu-sticky"),void 0!==n&&null!==n&&(t="true"===n)),t},setPersistedStickyState:function(t){void 0!==e.cookie&&e.cookie("cms-menu-sticky",t,{path:"/",expires:31})},getEvaluatedCollapsedState:function(){var t,n=this.getPersistedCollapsedState(),i=e(".cms-menu").getPersistedStickyState(),s=this.siteTreePresent();return t=void 0===n?s:n!==s&&i?n:s},onadd:function(){var t=this;setTimeout(function(){t.togglePanel(!t.getEvaluatedCollapsedState(),!1,!1)},0),e(window).on("ajaxComplete",function(e){setTimeout(function(){t.togglePanel(!t.getEvaluatedCollapsedState(),!1,!1)},0)}),this._super()}}),e(".cms-menu-list").entwine({onmatch:function(){this.find("li.current").select(),this.updateItems(),this._super()},onunmatch:function(){this._super()},updateMenuFromResponse:function(e){var t=e.getResponseHeader("X-Controller");if(t){var n=this.find("li#Menu-"+t.replace(/\\/g,"-").replace(/[^a-zA-Z0-9\-_:.]+/,""));n.hasClass("current")||n.select()}this.updateItems()},"from .cms-container":{onafterstatechange:function(e,t){this.updateMenuFromResponse(t.xhr)},onaftersubmitform:function(e,t){this.updateMenuFromResponse(t.xhr)}},"from .cms-edit-form":{onrelodeditform:function(e,t){this.updateMenuFromResponse(t.xmlhttp)}},getContainingPanel:function(){return this.closest(".cms-panel")},fromContainingPanel:{ontoggle:function(t){this.toggleClass("collapsed",e(t.target).hasClass("collapsed")),e(".cms-container").trigger("windowresize"),this.hasClass("collapsed")&&this.find("li.children.opened").removeClass("opened"),this.hasClass("collapsed")||e(".toggle-children.opened").closest("li").addClass("opened")}},updateItems:function(){var t=this.find("#Menu-CMSMain");t[t.is(".current")?"show":"hide"]();var n=e(".cms-content input[name=ID]").val();n&&this.find("li").each(function(){e.isFunction(e(this).setRecordID)&&e(this).setRecordID(n)})}}),e(".cms-menu-list li").entwine({toggleFlyout:function(t){var n=e(this);if(n.children("ul").first().hasClass("collapsed-flyout"))if(t){if(!n.children("ul").first().children("li").first().hasClass("clone")){var i=n.clone();i.addClass("clone").css({}),i.children("ul").first().remove(),i.find("span").not(".text").remove(),i.find("a").first().unbind("click"),n.children("ul").prepend(i)}e(".collapsed-flyout").show(),n.addClass("opened"),n.children("ul").find("li").fadeIn("fast")}else i&&i.remove(),e(".collapsed-flyout").hide(),n.removeClass("opened"),n.find("toggle-children").removeClass("opened"),n.children("ul").find("li").hide()}}),e(".cms-menu-list li").hoverIntent(function(){e(this).toggleFlyout(!0)},function(){e(this).toggleFlyout(!1)}),e(".cms-menu-list .toggle").entwine({onclick:function(t){t.preventDefault(),e(this).toogleFlyout(!0)}}),e(".cms-menu-list li").entwine({onmatch:function(){this.find("ul").length&&this.find("a:first").append('<span class="toggle-children"><span class="toggle-children-icon"></span></span>'),this._super()},onunmatch:function(){this._super()},toggle:function(){this[this.hasClass("opened")?"close":"open"]()},open:function(){var e=this.getMenuItem();e&&e.open(),this.find("li.clone")&&this.find("li.clone").remove(),this.addClass("opened").find("ul").show(),this.find(".toggle-children").addClass("opened")},close:function(){this.removeClass("opened").find("ul").hide(),this.find(".toggle-children").removeClass("opened")},select:function(){var e=this.getMenuItem();if(this.addClass("current").open(),this.siblings().removeClass("current").close(),this.siblings().find("li").removeClass("current"),e){var t=e.siblings();e.addClass("current"),t.removeClass("current").close(),t.find("li").removeClass("current").close()}this.getMenu().updateItems(),this.trigger("select")}}),e(".cms-menu-list *").entwine({getMenu:function(){return this.parents(".cms-menu-list:first")}}),e(".cms-menu-list li *").entwine({getMenuItem:function(){return this.parents("li:first")}}),e(".cms-menu-list li a").entwine({onclick:function(t){var n=e.path.isExternal(this.attr("href"));if(!(t.which>1||n)&&"_blank"!=this.attr("target")){t.preventDefault();var i=this.getMenuItem(),s=this.attr("href");n||(s=e("base").attr("href")+s);var a=i.find("li");if(a.length)a.first().find("a").click();else if(!e(".cms-container").loadPanel(s))return!1;i.select()}}}),e(".cms-menu-list li .toggle-children").entwine({onclick:function(e){var t=this.closest("li");return t.toggle(),!1}}),e(".cms .profile-link").entwine({onclick:function(){return e(".cms-container").loadPanel(this.attr("href")),e(".cms-menu-list li").removeClass("current").close(),!1}}),e(".cms-menu .sticky-toggle").entwine({onadd:function(){var t=!!e(".cms-menu").getPersistedStickyState();this.toggleCSS(t),this.toggleIndicator(t),this._super()},toggleCSS:function(e){this[e?"addClass":"removeClass"]("active")},toggleIndicator:function(e){this.next(".sticky-status-indicator").text(e?"fixed":"auto")},onclick:function(){var e=this.closest(".cms-menu"),t=e.getPersistedCollapsedState(),n=e.getPersistedStickyState(),i=void 0===n?!this.hasClass("active"):!n;void 0===t?e.setPersistedCollapsedState(e.hasClass("collapsed")):void 0!==t&&i===!1&&e.clearPersistedCollapsedState(),e.setPersistedStickyState(i),this.toggleCSS(i),this.toggleIndicator(i),this._super()}})})},{jQuery:"jQuery"}],10:[function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}var s=e("jQuery"),a=i(s);a["default"].entwine("ss",function(e){e.entwine.warningLevel=e.entwine.WARN_LEVEL_BESTPRACTISE,e(".cms-panel").entwine({WidthExpanded:null,WidthCollapsed:null,canSetCookie:function(){return void 0!==e.cookie&&void 0!==this.attr("id")},getPersistedCollapsedState:function(){var t,n;return this.canSetCookie()&&(n=e.cookie("cms-panel-collapsed-"+this.attr("id")),void 0!==n&&null!==n&&(t="true"===n)),t},setPersistedCollapsedState:function(t){this.canSetCookie()&&e.cookie("cms-panel-collapsed-"+this.attr("id"),t,{path:"/",expires:31})},clearPersistedCollapsedState:function(){this.canSetCookie()&&e.cookie("cms-panel-collapsed-"+this.attr("id"),"",{path:"/",expires:-1})},getInitialCollapsedState:function(){var e=this.getPersistedCollapsedState();return void 0===e&&(e=this.hasClass("collapsed")),e},onadd:function(){var t,n;if(!this.find(".cms-panel-content").length)throw new Exception('Content panel for ".cms-panel" not found');this.find(".cms-panel-toggle").length||(n=e("<div class='cms-panel-toggle south'></div>").append('<a class="toggle-expand" href="#"><span>&raquo;</span></a>').append('<a class="toggle-collapse" href="#"><span>&laquo;</span></a>'),this.append(n)),this.setWidthExpanded(this.find(".cms-panel-content").innerWidth()),t=this.find(".cms-panel-content-collapsed"),this.setWidthCollapsed(t.length?t.innerWidth():this.find(".toggle-expand").innerWidth()),this.togglePanel(!this.getInitialCollapsedState(),!0,!1),this._super()},togglePanel:function(e,t,n){var i,s;t||(this.trigger("beforetoggle.sspanel",e),this.trigger(e?"beforeexpand":"beforecollapse")),this.toggleClass("collapsed",!e),i=e?this.getWidthExpanded():this.getWidthCollapsed(),this.width(i),s=this.find(".cms-panel-content-collapsed"),s.length&&(this.find(".cms-panel-content")[e?"show":"hide"](),this.find(".cms-panel-content-collapsed")[e?"hide":"show"]()),n!==!1&&this.setPersistedCollapsedState(!e),this.trigger("toggle",e),this.trigger(e?"expand":"collapse")},expandPanel:function(e){(e||this.hasClass("collapsed"))&&this.togglePanel(!0)},collapsePanel:function(e){!e&&this.hasClass("collapsed")||this.togglePanel(!1)}}),e(".cms-panel.collapsed .cms-panel-toggle").entwine({onclick:function(e){this.expandPanel(),e.preventDefault()}}),e(".cms-panel *").entwine({getPanel:function(){return this.parents(".cms-panel:first")}}),e(".cms-panel .toggle-expand").entwine({onclick:function(e){e.preventDefault(),e.stopPropagation(),this.getPanel().expandPanel(),this._super(e)}}),e(".cms-panel .toggle-collapse").entwine({onclick:function(e){e.preventDefault(),e.stopPropagation(),this.getPanel().collapsePanel(),this._super(e)}}),e(".cms-content-tools.collapsed").entwine({onclick:function(e){this.expandPanel(),this._super(e)}})})},{jQuery:"jQuery"}],11:[function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}var s=e("jQuery"),a=i(s),o=e("i18n"),r=i(o);a["default"].entwine("ss.preview",function(e){e(".cms-preview").entwine({AllowedStates:["StageLink","LiveLink","ArchiveLink"],CurrentStateName:null,CurrentSizeName:"auto",IsPreviewEnabled:!1,DefaultMode:"split",Sizes:{auto:{width:"100%",height:"100%"},mobile:{width:"335px",height:"568px"},mobileLandscape:{width:"583px",height:"320px"},tablet:{width:"783px",height:"1024px"},tabletLandscape:{width:"1039px",height:"768px"},desktop:{width:"1024px",height:"800px"}},changeState:function(t,n){var i=this,s=this._getNavigatorStates();return n!==!1&&e.each(s,function(e,n){i.saveState("state",t)}),this.setCurrentStateName(t),this._loadCurrentState(),this.redraw(),this},changeMode:function(t,n){var i=e(".cms-container");if("split"==t)i.entwine(".ss").splitViewMode(),this.setIsPreviewEnabled(!0),this._loadCurrentState();else if("content"==t)i.entwine(".ss").contentViewMode(),this.setIsPreviewEnabled(!1);else{if("preview"!=t)throw"Invalid mode: "+t;i.entwine(".ss").previewMode(),this.setIsPreviewEnabled(!0),this._loadCurrentState()}return n!==!1&&this.saveState("mode",t),this.redraw(),this},changeSize:function(e){var t=this.getSizes();return this.setCurrentSizeName(e),this.removeClass("auto desktop tablet mobile").addClass(e),this.find(".preview-device-outer").width(t[e].width).height(t[e].height),this.find(".preview-device-inner").width(t[e].width),this.saveState("size",e),this.redraw(),this},redraw:function(){window.debug&&console.log("redraw",this.attr("class"),this.get(0));var t=this.getCurrentStateName();t&&this.find(".cms-preview-states").changeVisibleState(t);var n=e(".cms-container").entwine(".ss").getLayoutOptions();n&&e(".preview-mode-selector").changeVisibleMode(n.mode);var i=this.getCurrentSizeName();return i&&this.find(".preview-size-selector").changeVisibleSize(this.getCurrentSizeName()),this},saveState:function(e,t){this._supportsLocalStorage()&&window.localStorage.setItem("cms-preview-state-"+e,t)},loadState:function(e){return this._supportsLocalStorage()?window.localStorage.getItem("cms-preview-state-"+e):void 0},disablePreview:function(){return this.setPendingURL(null),this._loadUrl("about:blank"),this._block(),this.changeMode("content",!1),this.setIsPreviewEnabled(!1),this},enablePreview:function(){return this.getIsPreviewEnabled()||(this.setIsPreviewEnabled(!0),e.browser.msie&&e.browser.version.slice(0,3)<=7?this.changeMode("content"):this.changeMode(this.getDefaultMode(),!1)),this},getOrAppendFontFixStyleElement:function(){var t=e("#FontFixStyleElement");return t.length||(t=e('<style type="text/css" id="FontFixStyleElement" disabled="disabled">:before,:after{content:none !important}</style>').appendTo("head")),
t},onadd:function(){var t=this,n=(this.parent(),this.find("iframe"));n.addClass("center"),n.bind("load",function(){t._adjustIframeForPreview(),t._loadCurrentPage(),e(this).removeClass("loading")}),e.browser.msie&&8===parseInt(e.browser.version,10)&&n.bind("readystatechange",function(e){"interactive"==n[0].readyState&&(t.getOrAppendFontFixStyleElement().removeAttr("disabled"),setTimeout(function(){t.getOrAppendFontFixStyleElement().attr("disabled","disabled")},0))}),this.append('<div class="cms-preview-overlay ui-widget-overlay-light"></div>'),this.find(".cms-preview-overlay").hide(),this.disablePreview(),this._super()},_supportsLocalStorage:function(){var e,t,n=new Date;try{return(e=window.localStorage).setItem(n,n),t=e.getItem(n)==n,e.removeItem(n),t&&e}catch(i){console.warn("localStorge is not available due to current browser / system settings.")}},onenable:function(){var t=e(".preview-mode-selector");t.removeClass("split-disabled"),t.find(".disabled-tooltip").hide()},ondisable:function(){var t=e(".preview-mode-selector");t.addClass("split-disabled"),t.find(".disabled-tooltip").show()},_block:function(){return this.addClass("blocked"),this.find(".cms-preview-overlay").show(),this},_unblock:function(){return this.removeClass("blocked"),this.find(".cms-preview-overlay").hide(),this},_initialiseFromContent:function(){var t,n;return e(".cms-previewable").length?(t=this.loadState("mode"),n=this.loadState("size"),this._moveNavigator(),t&&"content"==t||(this.enablePreview(),this._loadCurrentState()),this.redraw(),t&&this.changeMode(t),n&&this.changeSize(n)):this.disablePreview(),this},"from .cms-container":{onafterstatechange:function(e,t){t.xhr.getResponseHeader("X-ControllerURL")||this._initialiseFromContent()}},PendingURL:null,oncolumnvisibilitychanged:function(){var e=this.getPendingURL();e&&!this.is(".column-hidden")&&(this.setPendingURL(null),this._loadUrl(e),this._unblock())},"from .cms-container .cms-edit-form":{onaftersubmitform:function(){this._initialiseFromContent()}},_loadUrl:function(e){return this.find("iframe").addClass("loading").attr("src",e),this},_getNavigatorStates:function(){var t=e.map(this.getAllowedStates(),function(t){var n=e(".cms-preview-states .state-name[data-name="+t+"]");return n.length?{name:t,url:n.attr("data-link"),active:n.is(":radio")?n.is(":checked"):n.is(":selected")}:null});return t},_loadCurrentState:function(){if(!this.getIsPreviewEnabled())return this;var t=this._getNavigatorStates(),n=this.getCurrentStateName(),i=null;t&&(i=e.grep(t,function(e,t){return n===e.name||!n&&e.active}));var s=null;return i[0]?s=i[0].url:t.length?(this.setCurrentStateName(t[0].name),s=t[0].url):this.setCurrentStateName(null),s+=(-1===s.indexOf("?")?"?":"&")+"CMSPreview=1",this.is(".column-hidden")?(this.setPendingURL(s),this._loadUrl("about:blank"),this._block()):(this.setPendingURL(null),s?(this._loadUrl(s),this._unblock()):this._block()),this},_moveNavigator:function(){var t=e(".cms-preview .cms-preview-controls"),n=e(".cms-edit-form .cms-navigator");n.length&&t.length?t.html(e(".cms-edit-form .cms-navigator").detach()):this._block()},_loadCurrentPage:function(){if(this.getIsPreviewEnabled()){var t;e(".cms-container");try{t=this.find("iframe")[0].contentDocument}catch(n){console.warn("Unable to access iframe, possible https mis-match")}if(t){var i=e(t).find("meta[name=x-page-id]").attr("content"),s=e(t).find("meta[name=x-cms-edit-link]").attr("content"),a=e(".cms-content");i&&a.find(":input[name=ID]").val()!=i&&e(".cms-container").entwine(".ss").loadPanel(s)}}},_adjustIframeForPreview:function(){var e,t=this.find("iframe")[0];if(t){try{e=t.contentDocument}catch(n){console.warn("Unable to access iframe, possible https mis-match")}if(e){for(var i=e.getElementsByTagName("A"),s=0;s<i.length;s++){var a=i[s].getAttribute("href");a&&a.match(/^http:\/\//)&&i[s].setAttribute("target","_blank")}var o=e.getElementById("SilverStripeNavigator");o&&(o.style.display="none");var r=e.getElementById("SilverStripeNavigatorMessage");r&&(r.style.display="none"),this.trigger("afterIframeAdjustedForPreview",[e])}}}}),e(".cms-edit-form").entwine({onadd:function(){this._super(),e(".cms-preview")._initialiseFromContent()}}),e(".cms-preview-states").entwine({changeVisibleState:function(e){this.find('input[data-name="'+e+'"]').prop("checked",!0)}}),e(".cms-preview-states .state-name").entwine({onclick:function(t){this.parent().find(".active").removeClass("active"),this.next("label").addClass("active");var n=e(this).attr("data-name");e(".cms-preview").changeState(n)}}),e(".preview-mode-selector").entwine({changeVisibleMode:function(e){this.find("select").val(e).trigger("chosen:updated")._addIcon()}}),e(".preview-mode-selector select").entwine({onchange:function(t){this._super(t),t.preventDefault();var n=e(this).val();e(".cms-preview").changeMode(n)}}),e(".cms-preview.column-hidden").entwine({onmatch:function(){e("#preview-mode-dropdown-in-content").show(),e(".cms-preview .result-selected").hasClass("font-icon-columns")&&statusMessage(r["default"]._t("LeftAndMain.DISABLESPLITVIEW","Screen too small to show site preview in split mode"),"error"),this._super()},onunmatch:function(){e("#preview-mode-dropdown-in-content").hide(),this._super()}}),e("#preview-mode-dropdown-in-content").entwine({onmatch:function(){e(".cms-preview").is(".column-hidden")?this.show():this.hide(),this._super()},onunmatch:function(){this._super()}}),e(".preview-size-selector").entwine({changeVisibleSize:function(e){this.find("select").val(e).trigger("chosen:updated")._addIcon()}}),e(".preview-size-selector select").entwine({onchange:function(t){t.preventDefault();var n=e(this).val();e(".cms-preview").changeSize(n)}}),e(".preview-selector select.preview-dropdown").entwine({"onchosen:ready":function(){this._super(),this._addIcon()},_addIcon:function(){var e=this.find(":selected"),t=e.attr("data-icon"),n=this.parent().find(".chosen-container a.chosen-single"),i=n.attr("data-icon");return"undefined"!=typeof i&&n.removeClass(i),n.addClass(t),n.attr("data-icon",t),this}}),e(".preview-mode-selector .chosen-drop li:last-child").entwine({onmatch:function(){e(".preview-mode-selector").hasClass("split-disabled")?this.parent().append('<div class="disabled-tooltip"></div>'):this.parent().append('<div class="disabled-tooltip" style="display: none;"></div>')}}),e(".preview-device-outer").entwine({onclick:function(){this.toggleClass("rotate")}})})},{i18n:"i18n",jQuery:"jQuery"}],12:[function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}var s=e("jQuery"),a=i(s);a["default"].entwine("ss.tree",function(e){e(".cms-tree").entwine({Hints:null,IsUpdatingTree:!1,IsLoaded:!1,onadd:function(){if(this._super(),!e.isNumeric(this.data("jstree_instance_id"))){var t=this.attr("data-hints");t&&this.setHints(e.parseJSON(t));var n=this;this.jstree(this.getTreeConfig()).bind("loaded.jstree",function(t,i){n.setIsLoaded(!0),i.inst._set_settings({html_data:{ajax:{url:n.data("urlTree"),data:function(t){var i=n.data("searchparams")||[];return i=e.grep(i,function(e,t){return"ID"!=e.name&&"value"!=e.name}),i.push({name:"ID",value:e(t).data("id")?e(t).data("id"):0}),i.push({name:"ajax",value:1}),i}}}}),n.updateFromEditForm(),n.css("visibility","visible"),i.inst.hide_checkboxes()}).bind("before.jstree",function(t,i){if("start_drag"==i.func&&(!n.hasClass("draggable")||n.hasClass("multiselect")))return t.stopImmediatePropagation(),!1;if(e.inArray(i.func,["check_node","uncheck_node"])){var s=e(i.args[0]).parents("li:first"),a=s.find("li:not(.disabled)");if(s.hasClass("disabled")&&0==a)return t.stopImmediatePropagation(),!1}}).bind("move_node.jstree",function(t,i){if(!n.getIsUpdatingTree()){var s=i.rslt.o,a=i.rslt.np,o=(i.inst._get_parent(s),e(a).data("id")||0),r=e(s).data("id"),l=e.map(e(s).siblings().andSelf(),function(t){return e(t).data("id")});e.ajax({url:n.data("urlSavetreenode"),type:"POST",data:{ID:r,ParentID:o,SiblingIDs:l},success:function(){e(".cms-edit-form :input[name=ID]").val()==r&&e(".cms-edit-form :input[name=ParentID]").val(o),n.updateNodesFromServer([r])},statusCode:{403:function(){e.jstree.rollback(i.rlbk)}}})}}).bind("select_node.jstree check_node.jstree uncheck_node.jstree",function(t,n){e(document).triggerHandler(t,n)})}},onremove:function(){this.jstree("destroy"),this._super()},"from .cms-container":{onafterstatechange:function(e){this.updateFromEditForm()}},"from .cms-container form":{onaftersubmitform:function(t){var n=e(".cms-edit-form :input[name=ID]").val();this.updateNodesFromServer([n])}},getTreeConfig:function(){var t=this;return{core:{initially_open:["record-0"],animation:0,html_titles:!0},html_data:{},ui:{select_limit:1,initially_select:[this.find(".current").attr("id")]},crrm:{move:{check_move:function(n){var i=e(n.o),s=e(n.np),a=n.ot.get_container()[0]==n.np[0],o=i.getClassname(),r=s.getClassname(),l=t.getHints(),d=[],c=r?r:"Root",u=l&&"undefined"!=typeof l[c]?l[c]:null;u&&i.attr("class").match(/VirtualPage-([^\s]*)/)&&(o=RegExp.$1),u&&(d="undefined"!=typeof u.disallowedChildren?u.disallowedChildren:[]);var h=!(0===i.data("id")||i.hasClass("status-archived")||a&&"inside"!=n.p||s.hasClass("nochildren")||d.length&&-1!=e.inArray(o,d));return h}}},dnd:{drop_target:!1,drag_target:!1},checkbox:{two_state:!0},themes:{theme:"apple",url:e("body").data("frameworkpath")+"/thirdparty/jstree/themes/apple/style.css"},plugins:["html_data","ui","dnd","crrm","themes","checkbox"]}},search:function(e,t){e?this.data("searchparams",e):this.removeData("searchparams"),this.jstree("refresh",-1,t)},getNodeByID:function(e){return this.find("*[data-id="+e+"]")},createNode:function(t,n,i){var s=this,a=void 0!==n.ParentID?s.getNodeByID(n.ParentID):!1,o=e(t),r={data:""};o.hasClass("jstree-open")?r.state="open":o.hasClass("jstree-closed")&&(r.state="closed"),this.jstree("create_node",a.length?a:-1,"last",r,function(e){for(var t=e.attr("class"),n=0;n<o[0].attributes.length;n++){var s=o[0].attributes[n];e.attr(s.name,s.value)}e.addClass(t).html(o.html()),i(e)})},updateNode:function(t,n,i){var s=e(n),a=t.attr("class"),o=i.NextID?this.getNodeByID(i.NextID):!1,r=i.PrevID?this.getNodeByID(i.PrevID):!1,l=i.ParentID?this.getNodeByID(i.ParentID):!1;e.each(["id","style","class","data-pagetype"],function(e,n){t.attr(n,s.attr(n))}),a=a.replace(/status-[^\s]*/,"");var d=t.children("ul").detach();t.addClass(a).html(s.html()).append(d),o&&o.length?this.jstree("move_node",t,o,"before"):r&&r.length?this.jstree("move_node",t,r,"after"):this.jstree("move_node",t,l.length?l:-1)},updateFromEditForm:function(){var t,n=e(".cms-edit-form :input[name=ID]").val();n?(t=this.getNodeByID(n),t.length?(this.jstree("deselect_all"),this.jstree("select_node",t)):this.updateNodesFromServer([n])):this.jstree("deselect_all")},updateNodesFromServer:function(t){if(!this.getIsUpdatingTree()&&this.getIsLoaded()){var n=this,i=!1;this.setIsUpdatingTree(!0),n.jstree("save_selected");var s=function(e){n.getNodeByID(e.data("id")).not(e).remove(),n.jstree("deselect_all"),n.jstree("select_node",e)};n.jstree("open_node",this.getNodeByID(0)),n.jstree("save_opened"),n.jstree("save_selected"),e.ajax({url:e.path.addSearchParams(this.data("urlUpdatetreenodes"),"ids="+t.join(",")),dataType:"json",success:function(t,a){e.each(t,function(e,t){var a=n.getNodeByID(e);return t?void(a.length?(n.updateNode(a,t.html,t),setTimeout(function(){s(a)},500)):(i=!0,t.ParentID&&!n.find("li[data-id="+t.ParentID+"]").length?n.jstree("load_node",-1,function(){newNode=n.find("li[data-id="+e+"]"),s(newNode)}):n.createNode(t.html,t,function(e){s(e)}))):void n.jstree("delete_node",a)}),i||(n.jstree("deselect_all"),n.jstree("reselect"),n.jstree("reopen"))},complete:function(){n.setIsUpdatingTree(!1)}})}}}),e(".cms-tree.multiple").entwine({onmatch:function(){this._super(),this.jstree("show_checkboxes")},onunmatch:function(){this._super(),this.jstree("uncheck_all"),this.jstree("hide_checkboxes")},getSelectedIDs:function(){return e(this).jstree("get_checked").not(".disabled").map(function(){return e(this).data("id")}).get()}}),e(".cms-tree li").entwine({setEnabled:function(e){this.toggleClass("disabled",!e)},getClassname:function(){var e=this.attr("class").match(/class-([^\s]*)/i);return e?e[1]:""},getID:function(){return this.data("id")}})})},{jQuery:"jQuery"}],13:[function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}var s=e("jQuery"),a=i(s);a["default"].entwine("ss",function(e){e(".TreeDropdownField").entwine({"from .cms-container form":{onaftersubmitform:function(e){this.find(".tree-holder").empty(),this._super()}}})})},{jQuery:"jQuery"}],14:[function(require,module,exports){"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function getUrlPath(e){var t=document.createElement("a");return t.href=e,t.pathname}var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},_jQuery=require("jQuery"),_jQuery2=_interopRequireDefault(_jQuery),_Router=require("lib/Router"),_Router2=_interopRequireDefault(_Router),_Config=require("lib/Config"),_Config2=_interopRequireDefault(_Config),windowWidth,windowHeight;_jQuery2["default"].noConflict(),window.ss=window.ss||{},window.ss.router=_Router2["default"],window.ss.debounce=function(e,t,n){var i,s,a,o=function(){i=null,n||e.apply(s,a)};return function(){var r=n&&!i;s=this,a=arguments,clearTimeout(i),i=setTimeout(o,t),r&&e.apply(s,a)}},(0,_jQuery2["default"])(window).bind("resize.leftandmain",function(e){(0,_jQuery2["default"])(".cms-container").trigger("windowresize")}),_jQuery2["default"].entwine.warningLevel=_jQuery2["default"].entwine.WARN_LEVEL_BESTPRACTISE,_jQuery2["default"].entwine("ss",function($){$(window).on("message",function(e){var t,n=e.originalEvent,i="object"===_typeof(n.data)?n.data:JSON.parse(n.data);if($.path.parseUrl(window.location.href).domain===$.path.parseUrl(n.origin).domain)switch(t=$("undefined"==typeof i.target?window:i.target),i.type){case"event":t.trigger(i.event,i.data);break;case"callback":t[i.callback].call(t,i.data)}});var positionLoadingSpinner=function(){var e=120,t=$(".ss-loading-screen .loading-animation"),n=($(window).height()-t.height())/2;t.css("top",n+e),t.show()},applyChosen=function e(t){t.is(":visible")?t.addClass("has-chosen").chosen({allow_single_deselect:!0,disable_search_threshold:20,display_disabled_options:!0}):setTimeout(function(){t.show(),e(t)},500)},isSameUrl=function(e,t){var n=$("base").attr("href");e=$.path.isAbsoluteUrl(e)?e:$.path.makeUrlAbsolute(e,n),t=$.path.isAbsoluteUrl(t)?t:$.path.makeUrlAbsolute(t,n);var i=$.path.parseUrl(e),s=$.path.parseUrl(t);return i.pathname.replace(/\/*$/,"")==s.pathname.replace(/\/*$/,"")&&i.search==s.search},ajaxCompleteEvent=window.ss.debounce(function(){$(window).trigger("ajaxComplete")},1e3,!0);$(window).bind("resize",positionLoadingSpinner).trigger("resize"),$(document).ajaxComplete(function(e,t,n){var i,s=t.getResponseHeader("X-ControllerURL"),a=n.url,o=null!==t.getResponseHeader("X-Status")?t.getResponseHeader("X-Status"):t.statusText,r=t.status<200||t.status>399?"bad":"good",l=["OK"];return i=window.history.state?window.history.state.path:document.URL,null===s||isSameUrl(i,s)&&isSameUrl(a,s)||_Router2["default"].show(s,{id:(new Date).getTime()+String(Math.random()).replace(/\D/g,""),pjax:t.getResponseHeader("X-Pjax")?t.getResponseHeader("X-Pjax"):n.headers["X-Pjax"]}),t.getResponseHeader("X-Reauthenticate")?void $(".cms-container").showLoginDialog():(0!==t.status&&o&&$.inArray(o,l)&&statusMessage(decodeURIComponent(o),r),void ajaxCompleteEvent(this))}),$(".cms-container").entwine({StateChangeXHR:null,FragmentXHR:{},StateChangeCount:0,LayoutOptions:{minContentWidth:940,minPreviewWidth:400,mode:"content"},onadd:function(){var e=this,t=getUrlPath($("base")[0].href);return t=t.replace(/\/$/,""),_Router2["default"].base(t),_Config2["default"].getTopLevelRoutes().forEach(function(t){(0,_Router2["default"])("/"+t+"(/*?)?",function(t,n){return"complete"!==document.readyState?n():void e.handleStateChange(null,t.state).done(n)})}),_Router2["default"].start(),$.browser.msie&&parseInt($.browser.version,10)<8?($(".ss-loading-screen").append('<p class="ss-loading-incompat-warning"><span class="notice">Your browser is not compatible with the CMS interface. Please use Internet Explorer 8+, Google Chrome or Mozilla Firefox.</span></p>').css("z-index",$(".ss-loading-screen").css("z-index")+1),$(".loading-animation").remove(),void this._super()):(this.redraw(),$(".ss-loading-screen").hide(),$("body").removeClass("loading"),$(window).unbind("resize",positionLoadingSpinner),this.restoreTabState(),void this._super())},fromWindow:{onstatechange:function(e,t){this.handleStateChange(e,t)}},onwindowresize:function(){this.redraw()},"from .cms-panel":{ontoggle:function(){this.redraw()}},"from .cms-container":{onaftersubmitform:function(){this.redraw()}},"from .cms-menu-list li a":{onclick:function(e){var t=$(e.target).attr("href");e.which>1||t==this._tabStateUrl()||this.splitViewMode()}},updateLayoutOptions:function(e){var t=this.getLayoutOptions(),n=!1;for(var i in e)t[i]!==e[i]&&(t[i]=e[i],n=!0);n&&this.redraw()},splitViewMode:function(){this.updateLayoutOptions({mode:"split"})},contentViewMode:function(){this.updateLayoutOptions({mode:"content"})},previewMode:function(){this.updateLayoutOptions({mode:"preview"})},RedrawSuppression:!1,redraw:function(){this.getRedrawSuppression()||(window.debug&&console.log("redraw",this.attr("class"),this.get(0)),this.data("jlayout",jLayout.threeColumnCompressor({menu:this.children(".cms-menu"),content:this.children(".cms-content"),preview:this.children(".cms-preview")},this.getLayoutOptions())),this.layout(),this.find(".cms-panel-layout").redraw(),this.find(".cms-content-fields[data-layout-type]").redraw(),this.find(".cms-edit-form[data-layout-type]").redraw(),this.find(".cms-preview").redraw(),this.find(".cms-content").redraw())},checkCanNavigate:function(e){var t=this._findFragments(e||["Content"]),n=t.find(":data(changetracker)").add(t.filter(":data(changetracker)")),i=!0;return n.length?(n.each(function(){$(this).confirmUnsavedChanges()||(i=!1)}),i):!0},loadPanel:function(e){var t=(arguments.length<=1||void 0===arguments[1]?"":arguments[1],arguments.length<=2||void 0===arguments[2]?{}:arguments[2]),n=arguments[3],i=arguments.length<=4||void 0===arguments[4]?window.history.state.path:arguments[4];this.checkCanNavigate(t.pjax?t.pjax.split(","):["Content"])&&(this.saveTabState(),t.__forceReferer=i,n&&(t.__forceReload=Math.random()),_Router2["default"].show(e,t))},reloadCurrentPanel:function(){this.loadPanel(window.history.state.path,null,null,!0)},submitForm:function(e,t,n,i){var s=this;t||(t=this.find(".Actions :submit[name=action_save]")),t||(t=this.find(".Actions :submit:first")),e.trigger("beforesubmitform"),this.trigger("submitform",{form:e,button:t}),$(t).addClass("loading");var a=e.validate();if("undefined"!=typeof a&&!a)return statusMessage("Validation failed.","bad"),$(t).removeClass("loading"),!1;var o=e.serializeArray();return o.push({name:$(t).attr("name"),value:"1"}),o.push({name:"BackURL",value:window.history.state.path.replace(/\/$/,"")}),this.saveTabState(),jQuery.ajax(jQuery.extend({headers:{"X-Pjax":"CurrentForm,Breadcrumbs"},url:e.attr("action"),data:o,type:"POST",complete:function(){$(t).removeClass("loading")},success:function(t,i,a){e.removeClass("changed"),n&&n(t,i,a);var r=s.handleAjaxResponse(t,i,a);r&&r.filter("form").trigger("aftersubmitform",{status:i,xhr:a,formData:o})}},i)),!1},LastState:null,PauseState:!1,handleStateChange:function(e){var t=arguments.length<=1||void 0===arguments[1]?window.history.state:arguments[1];if(!this.getPauseState()){this.getStateChangeXHR()&&this.getStateChangeXHR().abort();var n=this,i=t.pjax||"Content",s={},a=i.split(","),o=this._findFragments(a);if(this.setStateChangeCount(this.getStateChangeCount()+1),!this.checkCanNavigate()){var r=this.getLastState();return this.setPauseState(!0),null!==r?_Router2["default"].show(r.url):_Router2["default"].back(),void this.setPauseState(!1)}if(this.setLastState(t),o.length<a.length&&(i="Content",a=["Content"],o=this._findFragments(a)),this.trigger("beforestatechange",{state:t,element:o}),s["X-Pjax"]=i,"undefined"!=typeof t.__forceReferer){var l=t.__forceReferer;try{l=decodeURI(l)}catch(d){}finally{s["X-Backurl"]=encodeURI(l)}}o.addClass("loading");var c=$.ajax({headers:s,url:t.path}).done(function(e,i,s){var a=n.handleAjaxResponse(e,i,s,t);n.trigger("afterstatechange",{data:e,status:i,xhr:s,element:a,state:t})}).always(function(){n.setStateChangeXHR(null),o.removeClass("loading")});return this.setStateChangeXHR(c),c}},loadFragment:function(e,t){var n,i=this,s={},a=$("base").attr("href"),o=this.getFragmentXHR();return"undefined"!=typeof o[t]&&null!==o[t]&&(o[t].abort(),o[t]=null),e=$.path.isAbsoluteUrl(e)?e:$.path.makeUrlAbsolute(e,a),s["X-Pjax"]=t,n=$.ajax({headers:s,url:e,success:function(e,t,n){var s=i.handleAjaxResponse(e,t,n,null);i.trigger("afterloadfragment",{data:e,status:t,xhr:n,elements:s})},error:function(e,t,n){i.trigger("loadfragmenterror",{xhr:e,status:t,error:n})},complete:function(){var e=i.getFragmentXHR();"undefined"!=typeof e[t]&&null!==e[t]&&(e[t]=null)}}),o[t]=n,n},handleAjaxResponse:function(e,t,n,i){var s,a,o,r;if(n.getResponseHeader("X-Reload")&&n.getResponseHeader("X-ControllerURL")){var l=$("base").attr("href"),d=n.getResponseHeader("X-ControllerURL"),s=$.path.isAbsoluteUrl(d)?d:$.path.makeUrlAbsolute(d,l);return void(document.location.href=s)}if(e){var c=n.getResponseHeader("X-Title");c&&(document.title=decodeURIComponent(c.replace(/\+/g," ")));var u,h={};n.getResponseHeader("Content-Type").match(/^((text)|(application))\/json[ \t]*;?/i)?h=e:(o=document.createDocumentFragment(),jQuery.clean([e],document,o,[]),r=$(jQuery.merge([],o.childNodes)),a="Content",r.is("form")&&!r.is("[data-pjax-fragment~=Content]")&&(a="CurrentForm"),h[a]=r),this.setRedrawSuppression(!0);try{$.each(h,function(e,t){var n=$("[data-pjax-fragment]").filter(function(){return-1!=$.inArray(e,$(this).data("pjaxFragment").split(" "))}),i=$(t);if(u?u.add(i):u=i,i.find(".cms-container").length)throw'Content loaded via ajax is not allowed to contain tags matching the ".cms-container" selector to avoid infinite loops';var s=n.attr("style"),a=n.parent(),o="undefined"!=typeof a.data("jlayout"),r=["east","west","center","north","south","column-hidden"],l=n.attr("class"),d=[];l&&(d=$.grep(l.split(" "),function(e){return $.inArray(e,r)>=0})),i.removeClass(r.join(" ")).addClass(d.join(" ")),s&&i.attr("style",s);var c=i.find("style").detach();c.length&&$(document).find("head").append(c),n.replaceWith(i),!a.is(".cms-container")&&o&&a.layout()});var f=u.filter("form");f.hasClass("cms-tabset")&&f.removeClass("cms-tabset").addClass("cms-tabset")}finally{this.setRedrawSuppression(!1)}return this.redraw(),this.restoreTabState(i&&"undefined"!=typeof i.tabState?i.tabState:null),u}},_findFragments:function(e){return $("[data-pjax-fragment]").filter(function(){var t,n=$(this).data("pjaxFragment").split(" ");for(t in e)if(-1!=$.inArray(e[t],n))return!0;return!1})},refresh:function(){$(window).trigger("statechange"),$(this).redraw()},saveTabState:function(){if("undefined"!=typeof window.sessionStorage&&null!==window.sessionStorage){var e=[],t=this._tabStateUrl();if(this.find(".cms-tabset,.ss-tabset").each(function(t,n){var i=$(n).attr("id");i&&$(n).data("tabs")&&($(n).data("ignoreTabState")||$(n).getIgnoreTabState()||e.push({id:i,selected:$(n).tabs("option","selected")}))}),e){var n="tabs-"+t;try{window.sessionStorage.setItem(n,JSON.stringify(e))}catch(i){if(i.code===DOMException.QUOTA_EXCEEDED_ERR&&0===window.sessionStorage.length)return;throw i}}}},restoreTabState:function(e){var t=this,n=this._tabStateUrl(),i="undefined"!=typeof window.sessionStorage&&window.sessionStorage,s=i?window.sessionStorage.getItem("tabs-"+n):null,a=s?JSON.parse(s):!1;this.find(".cms-tabset, .ss-tabset").each(function(){var n,i,s=$(this),o=s.attr("id"),r=s.find(".ss-tabs-force-active");s.data("tabs")&&(s.tabs("refresh"),r.length?n=r.index():e&&e[o]?(i=s.find(e[o].tabSelector),i.length&&(n=i.index())):a&&$.each(a,function(e,t){s.is("#"+t.id)&&(n=t.selected)}),null!==n&&(s.tabs("option","active",n),t.trigger("tabstaterestored")))})},clearTabState:function(e){if("undefined"!=typeof window.sessionStorage){var t=window.sessionStorage;if(e)t.removeItem("tabs-"+e);else for(var n=0;n<t.length;n++)t.key(n).match(/^tabs-/)&&t.removeItem(t.key(n))}},clearCurrentTabState:function(){this.clearTabState(this._tabStateUrl())},_tabStateUrl:function(){return window.history.state.path.replace(/\?.*/,"").replace(/#.*/,"").replace($("base").attr("href"),"")},showLoginDialog:function(){var e=$("body").data("member-tempid"),t=$(".leftandmain-logindialog"),n="CMSSecurity/login";t.length&&t.remove(),n=$.path.addSearchParams(n,{tempid:e,BackURL:window.location.href}),t=$('<div class="leftandmain-logindialog"></div>'),t.attr("id",(new Date).getTime()),t.data("url",n),$("body").append(t)}}),$(".leftandmain-logindialog").entwine({onmatch:function(){this._super(),this.ssdialog({iframeUrl:this.data("url"),dialogClass:"leftandmain-logindialog-dialog",autoOpen:!0,minWidth:500,maxWidth:500,minHeight:370,maxHeight:400,closeOnEscape:!1,open:function(){$(".ui-widget-overlay").addClass("leftandmain-logindialog-overlay")},close:function(){$(".ui-widget-overlay").removeClass("leftandmain-logindialog-overlay")}})},onunmatch:function(){this._super()},open:function(){this.ssdialog("open")},close:function(){this.ssdialog("close")},toggle:function(e){this.is(":visible")?this.close():this.open()},reauthenticate:function(e){"undefined"!=typeof e.SecurityID&&$(":input[name=SecurityID]").val(e.SecurityID),"undefined"!=typeof e.TempID&&$("body").data("member-tempid",e.TempID),this.close()}}),$("form.loading,.cms-content.loading,.cms-content-fields.loading,.cms-content-view.loading").entwine({onmatch:function(){this.append('<div class="cms-content-loading-overlay ui-widget-overlay-light"></div><div class="cms-content-loading-spinner"></div>'),this._super()},onunmatch:function(){this.find(".cms-content-loading-overlay,.cms-content-loading-spinner").remove(),this._super()}}),$('.cms input[type="submit"], .cms button, .cms input[type="reset"], .cms .ss-ui-button').entwine({onadd:function(){this.addClass("ss-ui-button"),this.data("button")||this.button(),this._super()},onremove:function(){this.data("button")&&this.button("destroy"),this._super()}}),$(".cms .cms-panel-link").entwine({onclick:function(e){if($(this).hasClass("external-link"))return void e.stopPropagation();var t=this.attr("href"),n=t&&!t.match(/^#/)?t:this.data("href"),i={pjax:this.data("pjaxTarget")};$(".cms-container").loadPanel(n,null,i),e.preventDefault()}}),$(".cms .ss-ui-button-ajax").entwine({onclick:function onclick(e){$(this).removeClass("ui-button-text-only"),$(this).addClass("ss-ui-button-loading ui-button-text-icons");var loading=$(this).find(".ss-ui-loading-icon");loading.length<1&&(loading=$("<span></span>").addClass("ss-ui-loading-icon ui-button-icon-primary ui-icon"),$(this).prepend(loading)),loading.show();var href=this.attr("href"),url=href?href:this.data("href");jQuery.ajax({url:url,complete:function complete(xmlhttp,status){var msg=xmlhttp.getResponseHeader("X-Status")?xmlhttp.getResponseHeader("X-Status"):xmlhttp.responseText;try{"undefined"!=typeof msg&&null!==msg&&eval(msg)}catch(e){}loading.hide(),$(".cms-container").refresh(),$(this).removeClass("ss-ui-button-loading ui-button-text-icons"),$(this).addClass("ui-button-text-only")},dataType:"html"}),e.preventDefault()}}),$(".cms .ss-ui-dialog-link").entwine({UUID:null,onmatch:function(){this._super(),this.setUUID((new Date).getTime())},onunmatch:function(){this._super()},onclick:function(){this._super();var e="ss-ui-dialog-"+this.getUUID(),t=$("#"+e);t.length||(t=$('<div class="ss-ui-dialog" id="'+e+'" />'),$("body").append(t));var n=this.data("popupclass")?this.data("popupclass"):"";return t.ssdialog({iframeUrl:this.attr("href"),autoOpen:!0,dialogExtraClass:n}),!1}}),$(".cms-content .Actions").entwine({onmatch:function(){this.find(".ss-ui-button").click(function(){var e=this.form;e&&(e.clickedButton=this,setTimeout(function(){e.clickedButton=null},10))}),this.redraw(),this._super()},onunmatch:function(){this._super()},redraw:function(){window.debug&&console.log("redraw",this.attr("class"),this.get(0)),this.contents().filter(function(){return 3==this.nodeType&&!/\S/.test(this.nodeValue)}).remove(),this.find(".ss-ui-button").each(function(){$(this).data("button")||$(this).button()}),this.find(".ss-ui-buttonset").buttonset()}}),$(".cms .field.date input.text").entwine({onmatch:function(){var e=$(this).parents(".field.date:first"),t=e.data();return t.showcalendar?(t.showOn="button",t.locale&&$.datepicker.regional[t.locale]&&(t=$.extend(t,$.datepicker.regional[t.locale],{})),$(this).datepicker(t),void this._super()):void this._super()},onunmatch:function(){this._super()}}),$(".cms .field.dropdown select, .cms .field select[multiple], .fieldholder-small select.dropdown").entwine({onmatch:function(){return this.is(".no-chosen")?void this._super():(this.data("placeholder")||this.data("placeholder"," "),this.removeClass("has-chosen").chosen("destroy"),this.siblings(".chosen-container").remove(),applyChosen(this),void this._super())},onunmatch:function(){this._super()}}),$(".cms-panel-layout").entwine({redraw:function(){window.debug&&console.log("redraw",this.attr("class"),this.get(0))}}),$(".cms .ss-gridfield").entwine({showDetailView:function(e){var t=window.location.search.replace(/^\?/,"");t&&(e=$.path.addSearchParams(e,t)),$(".cms-container").loadPanel(e)}}),$(".cms-search-form").entwine({onsubmit:function(e){var t,n;t=this.find(":input:not(:submit)").filter(function(){var e=$.grep($(this).fieldValue(),function(e){return e});return e.length}),n=this.attr("action"),t.length&&(n=$.path.addSearchParams(n,t.serialize().replace("+","%20")));var i=this.closest(".cms-container");return i.find(".cms-edit-form").tabs("select",0),i.loadPanel(n,"",{},!0),!1}}),$(".cms-search-form button[type=reset], .cms-search-form input[type=reset]").entwine({onclick:function(e){e.preventDefault();var t=$(this).parents("form");t.clearForm(),t.find(".dropdown select").prop("selectedIndex",0).trigger("chosen:updated"),t.submit()}}),window._panelDeferredCache={},$(".cms-panel-deferred").entwine({onadd:function(){this._super(),this.redraw()},onremove:function(){window.debug&&console.log("saving",this.data("url"),this),this.data("deferredNoCache")||(window._panelDeferredCache[this.data("url")]=this.html()),this._super()},redraw:function(){window.debug&&console.log("redraw",this.attr("class"),this.get(0));var e=this,t=this.data("url");if(!t)throw'Elements of class .cms-panel-deferred need a "data-url" attribute';this._super(),this.children().length||(this.data("deferredNoCache")||"undefined"==typeof window._panelDeferredCache[t]?(this.addClass("loading"),$.ajax({url:t,complete:function(){e.removeClass("loading")},success:function(t,n,i){e.html(t)}})):this.html(window._panelDeferredCache[t]))}}),$(".cms-tabset").entwine({onadd:function(){this.redrawTabs(),this._super()},onremove:function(){this.data("tabs")&&this.tabs("destroy"),this._super()},redrawTabs:function(){this.rewriteHashlinks();var e=(this.attr("id"),this.find("ul:first .ui-tabs-active"));this.data("uiTabs")||this.tabs({active:-1!=e.index()?e.index():0,beforeLoad:function(e,t){return!1},activate:function(e,t){var n=$(this).closest("form").find(".Actions");$(t.newTab).closest("li").hasClass("readonly")?n.fadeOut():n.show()}})},rewriteHashlinks:function(){$(this).find("ul a").each(function(){if($(this).attr("href")){var e=$(this).attr("href").match(/#.*/);e&&$(this).attr("href",document.location.href.replace(/#.*/,"")+e[0])}})}}),$("#filters-button").entwine({onmatch:function(){this._super(),this.data("collapsed",!0),this.data("animating",!1); t},onadd:function(){var t=this,n=(this.parent(),this.find("iframe"));n.addClass("center"),n.bind("load",function(){t._adjustIframeForPreview(),t._loadCurrentPage(),e(this).removeClass("loading")}),e.browser.msie&&8===parseInt(e.browser.version,10)&&n.bind("readystatechange",function(e){"interactive"==n[0].readyState&&(t.getOrAppendFontFixStyleElement().removeAttr("disabled"),setTimeout(function(){t.getOrAppendFontFixStyleElement().attr("disabled","disabled")},0))}),this.append('<div class="cms-preview-overlay ui-widget-overlay-light"></div>'),this.find(".cms-preview-overlay").hide(),this.disablePreview(),this._super()},_supportsLocalStorage:function(){var e,t,n=new Date;try{return(e=window.localStorage).setItem(n,n),t=e.getItem(n)==n,e.removeItem(n),t&&e}catch(i){console.warn("localStorge is not available due to current browser / system settings.")}},onenable:function(){var t=e(".preview-mode-selector");t.removeClass("split-disabled"),t.find(".disabled-tooltip").hide()},ondisable:function(){var t=e(".preview-mode-selector");t.addClass("split-disabled"),t.find(".disabled-tooltip").show()},_block:function(){return this.addClass("blocked"),this.find(".cms-preview-overlay").show(),this},_unblock:function(){return this.removeClass("blocked"),this.find(".cms-preview-overlay").hide(),this},_initialiseFromContent:function(){var t,n;return e(".cms-previewable").length?(t=this.loadState("mode"),n=this.loadState("size"),this._moveNavigator(),t&&"content"==t||(this.enablePreview(),this._loadCurrentState()),this.redraw(),t&&this.changeMode(t),n&&this.changeSize(n)):this.disablePreview(),this},"from .cms-container":{onafterstatechange:function(e,t){t.xhr.getResponseHeader("X-ControllerURL")||this._initialiseFromContent()}},PendingURL:null,oncolumnvisibilitychanged:function(){var e=this.getPendingURL();e&&!this.is(".column-hidden")&&(this.setPendingURL(null),this._loadUrl(e),this._unblock())},"from .cms-container .cms-edit-form":{onaftersubmitform:function(){this._initialiseFromContent()}},_loadUrl:function(e){return this.find("iframe").addClass("loading").attr("src",e),this},_getNavigatorStates:function(){var t=e.map(this.getAllowedStates(),function(t){var n=e(".cms-preview-states .state-name[data-name="+t+"]");return n.length?{name:t,url:n.attr("data-link"),active:n.is(":radio")?n.is(":checked"):n.is(":selected")}:null});return t},_loadCurrentState:function(){if(!this.getIsPreviewEnabled())return this;var t=this._getNavigatorStates(),n=this.getCurrentStateName(),i=null;t&&(i=e.grep(t,function(e,t){return n===e.name||!n&&e.active}));var s=null;return i[0]?s=i[0].url:t.length?(this.setCurrentStateName(t[0].name),s=t[0].url):this.setCurrentStateName(null),s+=(-1===s.indexOf("?")?"?":"&")+"CMSPreview=1",this.is(".column-hidden")?(this.setPendingURL(s),this._loadUrl("about:blank"),this._block()):(this.setPendingURL(null),s?(this._loadUrl(s),this._unblock()):this._block()),this},_moveNavigator:function(){var t=e(".cms-preview .cms-preview-controls"),n=e(".cms-edit-form .cms-navigator");n.length&&t.length?t.html(e(".cms-edit-form .cms-navigator").detach()):this._block()},_loadCurrentPage:function(){if(this.getIsPreviewEnabled()){var t;e(".cms-container");try{t=this.find("iframe")[0].contentDocument}catch(n){console.warn("Unable to access iframe, possible https mis-match")}if(t){var i=e(t).find("meta[name=x-page-id]").attr("content"),s=e(t).find("meta[name=x-cms-edit-link]").attr("content"),a=e(".cms-content");i&&a.find(":input[name=ID]").val()!=i&&e(".cms-container").entwine(".ss").loadPanel(s)}}},_adjustIframeForPreview:function(){var e,t=this.find("iframe")[0];if(t){try{e=t.contentDocument}catch(n){console.warn("Unable to access iframe, possible https mis-match")}if(e){for(var i=e.getElementsByTagName("A"),s=0;s<i.length;s++){var a=i[s].getAttribute("href");a&&a.match(/^http:\/\//)&&i[s].setAttribute("target","_blank")}var o=e.getElementById("SilverStripeNavigator");o&&(o.style.display="none");var r=e.getElementById("SilverStripeNavigatorMessage");r&&(r.style.display="none"),this.trigger("afterIframeAdjustedForPreview",[e])}}}}),e(".cms-edit-form").entwine({onadd:function(){this._super(),e(".cms-preview")._initialiseFromContent()}}),e(".cms-preview-states").entwine({changeVisibleState:function(e){this.find('input[data-name="'+e+'"]').prop("checked",!0)}}),e(".cms-preview-states .state-name").entwine({onclick:function(t){this.parent().find(".active").removeClass("active"),this.next("label").addClass("active");var n=e(this).attr("data-name");e(".cms-preview").changeState(n)}}),e(".preview-mode-selector").entwine({changeVisibleMode:function(e){this.find("select").val(e).trigger("chosen:updated")._addIcon()}}),e(".preview-mode-selector select").entwine({onchange:function(t){this._super(t),t.preventDefault();var n=e(this).val();e(".cms-preview").changeMode(n)}}),e(".cms-preview.column-hidden").entwine({onmatch:function(){e("#preview-mode-dropdown-in-content").show(),e(".cms-preview .result-selected").hasClass("font-icon-columns")&&statusMessage(r["default"]._t("LeftAndMain.DISABLESPLITVIEW","Screen too small to show site preview in split mode"),"error"),this._super()},onunmatch:function(){e("#preview-mode-dropdown-in-content").hide(),this._super()}}),e("#preview-mode-dropdown-in-content").entwine({onmatch:function(){e(".cms-preview").is(".column-hidden")?this.show():this.hide(),this._super()},onunmatch:function(){this._super()}}),e(".preview-size-selector").entwine({changeVisibleSize:function(e){this.find("select").val(e).trigger("chosen:updated")._addIcon()}}),e(".preview-size-selector select").entwine({onchange:function(t){t.preventDefault();var n=e(this).val();e(".cms-preview").changeSize(n)}}),e(".preview-selector select.preview-dropdown").entwine({"onchosen:ready":function(){this._super(),this._addIcon()},_addIcon:function(){var e=this.find(":selected"),t=e.attr("data-icon"),n=this.parent().find(".chosen-container a.chosen-single"),i=n.attr("data-icon");return"undefined"!=typeof i&&n.removeClass(i),n.addClass(t),n.attr("data-icon",t),this}}),e(".preview-mode-selector .chosen-drop li:last-child").entwine({onmatch:function(){e(".preview-mode-selector").hasClass("split-disabled")?this.parent().append('<div class="disabled-tooltip"></div>'):this.parent().append('<div class="disabled-tooltip" style="display: none;"></div>')}}),e(".preview-device-outer").entwine({onclick:function(){this.toggleClass("rotate")}})})},{i18n:"i18n",jQuery:"jQuery"}],12:[function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}var s=e("jQuery"),a=i(s);a["default"].entwine("ss.tree",function(e){e(".cms-tree").entwine({Hints:null,IsUpdatingTree:!1,IsLoaded:!1,onadd:function(){if(this._super(),!e.isNumeric(this.data("jstree_instance_id"))){var t=this.attr("data-hints");t&&this.setHints(e.parseJSON(t));var n=this;this.jstree(this.getTreeConfig()).bind("loaded.jstree",function(t,i){n.setIsLoaded(!0),i.inst._set_settings({html_data:{ajax:{url:n.data("urlTree"),data:function(t){var i=n.data("searchparams")||[];return i=e.grep(i,function(e,t){return"ID"!=e.name&&"value"!=e.name}),i.push({name:"ID",value:e(t).data("id")?e(t).data("id"):0}),i.push({name:"ajax",value:1}),i}}}}),n.updateFromEditForm(),n.css("visibility","visible"),i.inst.hide_checkboxes()}).bind("before.jstree",function(t,i){if("start_drag"==i.func&&(!n.hasClass("draggable")||n.hasClass("multiselect")))return t.stopImmediatePropagation(),!1;if(e.inArray(i.func,["check_node","uncheck_node"])){var s=e(i.args[0]).parents("li:first"),a=s.find("li:not(.disabled)");if(s.hasClass("disabled")&&0==a)return t.stopImmediatePropagation(),!1}}).bind("move_node.jstree",function(t,i){if(!n.getIsUpdatingTree()){var s=i.rslt.o,a=i.rslt.np,o=(i.inst._get_parent(s),e(a).data("id")||0),r=e(s).data("id"),l=e.map(e(s).siblings().andSelf(),function(t){return e(t).data("id")});e.ajax({url:n.data("urlSavetreenode"),type:"POST",data:{ID:r,ParentID:o,SiblingIDs:l},success:function(){e(".cms-edit-form :input[name=ID]").val()==r&&e(".cms-edit-form :input[name=ParentID]").val(o),n.updateNodesFromServer([r])},statusCode:{403:function(){e.jstree.rollback(i.rlbk)}}})}}).bind("select_node.jstree check_node.jstree uncheck_node.jstree",function(t,n){e(document).triggerHandler(t,n)})}},onremove:function(){this.jstree("destroy"),this._super()},"from .cms-container":{onafterstatechange:function(e){this.updateFromEditForm()}},"from .cms-container form":{onaftersubmitform:function(t){var n=e(".cms-edit-form :input[name=ID]").val();this.updateNodesFromServer([n])}},getTreeConfig:function(){var t=this;return{core:{initially_open:["record-0"],animation:0,html_titles:!0},html_data:{},ui:{select_limit:1,initially_select:[this.find(".current").attr("id")]},crrm:{move:{check_move:function(n){var i=e(n.o),s=e(n.np),a=n.ot.get_container()[0]==n.np[0],o=i.getClassname(),r=s.getClassname(),l=t.getHints(),d=[],c=r?r:"Root",u=l&&"undefined"!=typeof l[c]?l[c]:null;u&&i.attr("class").match(/VirtualPage-([^\s]*)/)&&(o=RegExp.$1),u&&(d="undefined"!=typeof u.disallowedChildren?u.disallowedChildren:[]);var h=!(0===i.data("id")||i.hasClass("status-archived")||a&&"inside"!=n.p||s.hasClass("nochildren")||d.length&&-1!=e.inArray(o,d));return h}}},dnd:{drop_target:!1,drag_target:!1},checkbox:{two_state:!0},themes:{theme:"apple",url:e("body").data("frameworkpath")+"/thirdparty/jstree/themes/apple/style.css"},plugins:["html_data","ui","dnd","crrm","themes","checkbox"]}},search:function(e,t){e?this.data("searchparams",e):this.removeData("searchparams"),this.jstree("refresh",-1,t)},getNodeByID:function(e){return this.find("*[data-id="+e+"]")},createNode:function(t,n,i){var s=this,a=void 0!==n.ParentID?s.getNodeByID(n.ParentID):!1,o=e(t),r={data:""};o.hasClass("jstree-open")?r.state="open":o.hasClass("jstree-closed")&&(r.state="closed"),this.jstree("create_node",a.length?a:-1,"last",r,function(e){for(var t=e.attr("class"),n=0;n<o[0].attributes.length;n++){var s=o[0].attributes[n];e.attr(s.name,s.value)}e.addClass(t).html(o.html()),i(e)})},updateNode:function(t,n,i){var s=e(n),a=t.attr("class"),o=i.NextID?this.getNodeByID(i.NextID):!1,r=i.PrevID?this.getNodeByID(i.PrevID):!1,l=i.ParentID?this.getNodeByID(i.ParentID):!1;e.each(["id","style","class","data-pagetype"],function(e,n){t.attr(n,s.attr(n))}),a=a.replace(/status-[^\s]*/,"");var d=t.children("ul").detach();t.addClass(a).html(s.html()).append(d),o&&o.length?this.jstree("move_node",t,o,"before"):r&&r.length?this.jstree("move_node",t,r,"after"):this.jstree("move_node",t,l.length?l:-1)},updateFromEditForm:function(){var t,n=e(".cms-edit-form :input[name=ID]").val();n?(t=this.getNodeByID(n),t.length?(this.jstree("deselect_all"),this.jstree("select_node",t)):this.updateNodesFromServer([n])):this.jstree("deselect_all")},updateNodesFromServer:function(t){if(!this.getIsUpdatingTree()&&this.getIsLoaded()){var n=this,i=!1;this.setIsUpdatingTree(!0),n.jstree("save_selected");var s=function(e){n.getNodeByID(e.data("id")).not(e).remove(),n.jstree("deselect_all"),n.jstree("select_node",e)};n.jstree("open_node",this.getNodeByID(0)),n.jstree("save_opened"),n.jstree("save_selected"),e.ajax({url:e.path.addSearchParams(this.data("urlUpdatetreenodes"),"ids="+t.join(",")),dataType:"json",success:function(t,a){e.each(t,function(e,t){var a=n.getNodeByID(e);return t?void(a.length?(n.updateNode(a,t.html,t),setTimeout(function(){s(a)},500)):(i=!0,t.ParentID&&!n.find("li[data-id="+t.ParentID+"]").length?n.jstree("load_node",-1,function(){newNode=n.find("li[data-id="+e+"]"),s(newNode)}):n.createNode(t.html,t,function(e){s(e)}))):void n.jstree("delete_node",a)}),i||(n.jstree("deselect_all"),n.jstree("reselect"),n.jstree("reopen"))},complete:function(){n.setIsUpdatingTree(!1)}})}}}),e(".cms-tree.multiple").entwine({onmatch:function(){this._super(),this.jstree("show_checkboxes")},onunmatch:function(){this._super(),this.jstree("uncheck_all"),this.jstree("hide_checkboxes")},getSelectedIDs:function(){return e(this).jstree("get_checked").not(".disabled").map(function(){return e(this).data("id")}).get()}}),e(".cms-tree li").entwine({setEnabled:function(e){this.toggleClass("disabled",!e)},getClassname:function(){var e=this.attr("class").match(/class-([^\s]*)/i);return e?e[1]:""},getID:function(){return this.data("id")}})})},{jQuery:"jQuery"}],13:[function(e,t,n){"use strict";function i(e){return e&&e.__esModule?e:{"default":e}}var s=e("jQuery"),a=i(s);a["default"].entwine("ss",function(e){e(".TreeDropdownField").entwine({"from .cms-container form":{onaftersubmitform:function(e){this.find(".tree-holder").empty(),this._super()}}})})},{jQuery:"jQuery"}],14:[function(require,module,exports){"use strict";function _interopRequireDefault(e){return e&&e.__esModule?e:{"default":e}}function getUrlPath(e){var t=document.createElement("a");return t.href=e,t.pathname}var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},_jQuery=require("jQuery"),_jQuery2=_interopRequireDefault(_jQuery),_Router=require("lib/Router"),_Router2=_interopRequireDefault(_Router),_Config=require("lib/Config"),_Config2=_interopRequireDefault(_Config),windowWidth,windowHeight;_jQuery2["default"].noConflict(),window.ss=window.ss||{},window.ss.router=_Router2["default"],window.ss.debounce=function(e,t,n){var i,s,a,o=function(){i=null,n||e.apply(s,a)};return function(){var r=n&&!i;s=this,a=arguments,clearTimeout(i),i=setTimeout(o,t),r&&e.apply(s,a)}},(0,_jQuery2["default"])(window).bind("resize.leftandmain",function(e){(0,_jQuery2["default"])(".cms-container").trigger("windowresize")}),_jQuery2["default"].entwine.warningLevel=_jQuery2["default"].entwine.WARN_LEVEL_BESTPRACTISE,_jQuery2["default"].entwine("ss",function($){$(window).on("message",function(e){var t,n=e.originalEvent,i="object"===_typeof(n.data)?n.data:JSON.parse(n.data);if($.path.parseUrl(window.location.href).domain===$.path.parseUrl(n.origin).domain)switch(t=$("undefined"==typeof i.target?window:i.target),i.type){case"event":t.trigger(i.event,i.data);break;case"callback":t[i.callback].call(t,i.data)}});var positionLoadingSpinner=function(){var e=120,t=$(".ss-loading-screen .loading-animation"),n=($(window).height()-t.height())/2;t.css("top",n+e),t.show()},applyChosen=function e(t){t.is(":visible")?t.addClass("has-chosen").chosen({allow_single_deselect:!0,disable_search_threshold:20,display_disabled_options:!0}):setTimeout(function(){t.show(),e(t)},500)},isSameUrl=function(e,t){var n=$("base").attr("href");e=$.path.isAbsoluteUrl(e)?e:$.path.makeUrlAbsolute(e,n),t=$.path.isAbsoluteUrl(t)?t:$.path.makeUrlAbsolute(t,n);var i=$.path.parseUrl(e),s=$.path.parseUrl(t);return i.pathname.replace(/\/*$/,"")==s.pathname.replace(/\/*$/,"")&&i.search==s.search},ajaxCompleteEvent=window.ss.debounce(function(){$(window).trigger("ajaxComplete")},1e3,!0);$(window).bind("resize",positionLoadingSpinner).trigger("resize"),$(document).ajaxComplete(function(e,t,n){var i,s=t.getResponseHeader("X-ControllerURL"),a=n.url,o=null!==t.getResponseHeader("X-Status")?t.getResponseHeader("X-Status"):t.statusText,r=t.status<200||t.status>399?"bad":"good",l=["OK"];return i=window.history.state?window.history.state.path:document.URL,null===s||isSameUrl(i,s)&&isSameUrl(a,s)||_Router2["default"].show(s,{id:(new Date).getTime()+String(Math.random()).replace(/\D/g,""),pjax:t.getResponseHeader("X-Pjax")?t.getResponseHeader("X-Pjax"):n.headers["X-Pjax"]}),t.getResponseHeader("X-Reauthenticate")?void $(".cms-container").showLoginDialog():(0!==t.status&&o&&$.inArray(o,l)&&statusMessage(decodeURIComponent(o),r),void ajaxCompleteEvent(this))}),$(".cms-container").entwine({StateChangeXHR:null,FragmentXHR:{},StateChangeCount:0,LayoutOptions:{minContentWidth:940,minPreviewWidth:400,mode:"content"},onadd:function(){var e=this,t=getUrlPath($("base")[0].href);return t=t.replace(/\/$/,""),t.match(/^[^\/]/)&&(t="/"+t),_Router2["default"].base(t),_Config2["default"].getTopLevelRoutes().forEach(function(t){(0,_Router2["default"])("/"+t+"(/*?)?",function(t,n){return"complete"!==document.readyState?n():void e.handleStateChange(null,t.state).done(n)})}),_Router2["default"].start(),$.browser.msie&&parseInt($.browser.version,10)<8?($(".ss-loading-screen").append('<p class="ss-loading-incompat-warning"><span class="notice">Your browser is not compatible with the CMS interface. Please use Internet Explorer 8+, Google Chrome or Mozilla Firefox.</span></p>').css("z-index",$(".ss-loading-screen").css("z-index")+1),$(".loading-animation").remove(),void this._super()):(this.redraw(),$(".ss-loading-screen").hide(),$("body").removeClass("loading"),$(window).unbind("resize",positionLoadingSpinner),this.restoreTabState(),void this._super())},fromWindow:{onstatechange:function(e,t){this.handleStateChange(e,t)}},onwindowresize:function(){this.redraw()},"from .cms-panel":{ontoggle:function(){this.redraw()}},"from .cms-container":{onaftersubmitform:function(){this.redraw()}},"from .cms-menu-list li a":{onclick:function(e){var t=$(e.target).attr("href");e.which>1||t==this._tabStateUrl()||this.splitViewMode()}},updateLayoutOptions:function(e){var t=this.getLayoutOptions(),n=!1;for(var i in e)t[i]!==e[i]&&(t[i]=e[i],n=!0);n&&this.redraw()},splitViewMode:function(){this.updateLayoutOptions({mode:"split"})},contentViewMode:function(){this.updateLayoutOptions({mode:"content"})},previewMode:function(){this.updateLayoutOptions({mode:"preview"})},RedrawSuppression:!1,redraw:function(){this.getRedrawSuppression()||(window.debug&&console.log("redraw",this.attr("class"),this.get(0)),this.data("jlayout",jLayout.threeColumnCompressor({menu:this.children(".cms-menu"),content:this.children(".cms-content"),preview:this.children(".cms-preview")},this.getLayoutOptions())),this.layout(),this.find(".cms-panel-layout").redraw(),this.find(".cms-content-fields[data-layout-type]").redraw(),this.find(".cms-edit-form[data-layout-type]").redraw(),this.find(".cms-preview").redraw(),this.find(".cms-content").redraw())},checkCanNavigate:function(e){var t=this._findFragments(e||["Content"]),n=t.find(":data(changetracker)").add(t.filter(":data(changetracker)")),i=!0;return n.length?(n.each(function(){$(this).confirmUnsavedChanges()||(i=!1)}),i):!0},loadPanel:function(e){var t=(arguments.length<=1||void 0===arguments[1]?"":arguments[1],arguments.length<=2||void 0===arguments[2]?{}:arguments[2]),n=arguments[3],i=arguments.length<=4||void 0===arguments[4]?window.history.state.path:arguments[4];this.checkCanNavigate(t.pjax?t.pjax.split(","):["Content"])&&(this.saveTabState(),t.__forceReferer=i,n&&(t.__forceReload=Math.random()),_Router2["default"].show(e,t))},reloadCurrentPanel:function(){this.loadPanel(window.history.state.path,null,null,!0)},submitForm:function(e,t,n,i){var s=this;t||(t=this.find(".Actions :submit[name=action_save]")),t||(t=this.find(".Actions :submit:first")),e.trigger("beforesubmitform"),this.trigger("submitform",{form:e,button:t}),$(t).addClass("loading");var a=e.validate();if("undefined"!=typeof a&&!a)return statusMessage("Validation failed.","bad"),$(t).removeClass("loading"),!1;var o=e.serializeArray();return o.push({name:$(t).attr("name"),value:"1"}),o.push({name:"BackURL",value:window.history.state.path.replace(/\/$/,"")}),this.saveTabState(),jQuery.ajax(jQuery.extend({headers:{"X-Pjax":"CurrentForm,Breadcrumbs"},url:e.attr("action"),data:o,type:"POST",complete:function(){$(t).removeClass("loading")},success:function(t,i,a){e.removeClass("changed"),n&&n(t,i,a);var r=s.handleAjaxResponse(t,i,a);r&&r.filter("form").trigger("aftersubmitform",{status:i,xhr:a,formData:o})}},i)),!1},LastState:null,PauseState:!1,handleStateChange:function(e){var t=arguments.length<=1||void 0===arguments[1]?window.history.state:arguments[1];if(!this.getPauseState()){this.getStateChangeXHR()&&this.getStateChangeXHR().abort();var n=this,i=t.pjax||"Content",s={},a=i.split(","),o=this._findFragments(a);if(this.setStateChangeCount(this.getStateChangeCount()+1),!this.checkCanNavigate()){var r=this.getLastState();return this.setPauseState(!0),null!==r?_Router2["default"].show(r.url):_Router2["default"].back(),void this.setPauseState(!1)}if(this.setLastState(t),o.length<a.length&&(i="Content",a=["Content"],o=this._findFragments(a)),this.trigger("beforestatechange",{state:t,element:o}),s["X-Pjax"]=i,"undefined"!=typeof t.__forceReferer){var l=t.__forceReferer;try{l=decodeURI(l)}catch(d){}finally{s["X-Backurl"]=encodeURI(l)}}o.addClass("loading");var c=$.ajax({headers:s,url:t.path}).done(function(e,i,s){var a=n.handleAjaxResponse(e,i,s,t);n.trigger("afterstatechange",{data:e,status:i,xhr:s,element:a,state:t})}).always(function(){n.setStateChangeXHR(null),o.removeClass("loading")});return this.setStateChangeXHR(c),c}},loadFragment:function(e,t){var n,i=this,s={},a=$("base").attr("href"),o=this.getFragmentXHR();return"undefined"!=typeof o[t]&&null!==o[t]&&(o[t].abort(),o[t]=null),e=$.path.isAbsoluteUrl(e)?e:$.path.makeUrlAbsolute(e,a),s["X-Pjax"]=t,n=$.ajax({headers:s,url:e,success:function(e,t,n){var s=i.handleAjaxResponse(e,t,n,null);i.trigger("afterloadfragment",{data:e,status:t,xhr:n,elements:s})},error:function(e,t,n){i.trigger("loadfragmenterror",{xhr:e,status:t,error:n})},complete:function(){var e=i.getFragmentXHR();"undefined"!=typeof e[t]&&null!==e[t]&&(e[t]=null)}}),o[t]=n,n},handleAjaxResponse:function(e,t,n,i){var s,a,o,r;if(n.getResponseHeader("X-Reload")&&n.getResponseHeader("X-ControllerURL")){var l=$("base").attr("href"),d=n.getResponseHeader("X-ControllerURL"),s=$.path.isAbsoluteUrl(d)?d:$.path.makeUrlAbsolute(d,l);return void(document.location.href=s)}if(e){var c=n.getResponseHeader("X-Title");c&&(document.title=decodeURIComponent(c.replace(/\+/g," ")));var u,h={};n.getResponseHeader("Content-Type").match(/^((text)|(application))\/json[ \t]*;?/i)?h=e:(o=document.createDocumentFragment(),jQuery.clean([e],document,o,[]),r=$(jQuery.merge([],o.childNodes)),a="Content",r.is("form")&&!r.is("[data-pjax-fragment~=Content]")&&(a="CurrentForm"),h[a]=r),this.setRedrawSuppression(!0);try{$.each(h,function(e,t){var n=$("[data-pjax-fragment]").filter(function(){return-1!=$.inArray(e,$(this).data("pjaxFragment").split(" "))}),i=$(t);if(u?u.add(i):u=i,i.find(".cms-container").length)throw'Content loaded via ajax is not allowed to contain tags matching the ".cms-container" selector to avoid infinite loops';var s=n.attr("style"),a=n.parent(),o="undefined"!=typeof a.data("jlayout"),r=["east","west","center","north","south","column-hidden"],l=n.attr("class"),d=[];l&&(d=$.grep(l.split(" "),function(e){return $.inArray(e,r)>=0})),i.removeClass(r.join(" ")).addClass(d.join(" ")),s&&i.attr("style",s);var c=i.find("style").detach();c.length&&$(document).find("head").append(c),n.replaceWith(i),!a.is(".cms-container")&&o&&a.layout()});var f=u.filter("form");f.hasClass("cms-tabset")&&f.removeClass("cms-tabset").addClass("cms-tabset")}finally{this.setRedrawSuppression(!1)}return this.redraw(),this.restoreTabState(i&&"undefined"!=typeof i.tabState?i.tabState:null),u}},_findFragments:function(e){return $("[data-pjax-fragment]").filter(function(){var t,n=$(this).data("pjaxFragment").split(" ");for(t in e)if(-1!=$.inArray(e[t],n))return!0;return!1})},refresh:function(){$(window).trigger("statechange"),$(this).redraw()},saveTabState:function(){if("undefined"!=typeof window.sessionStorage&&null!==window.sessionStorage){var e=[],t=this._tabStateUrl();if(this.find(".cms-tabset,.ss-tabset").each(function(t,n){var i=$(n).attr("id");i&&$(n).data("tabs")&&($(n).data("ignoreTabState")||$(n).getIgnoreTabState()||e.push({id:i,selected:$(n).tabs("option","selected")}))}),e){var n="tabs-"+t;try{window.sessionStorage.setItem(n,JSON.stringify(e))}catch(i){if(i.code===DOMException.QUOTA_EXCEEDED_ERR&&0===window.sessionStorage.length)return;throw i}}}},restoreTabState:function(e){var t=this,n=this._tabStateUrl(),i="undefined"!=typeof window.sessionStorage&&window.sessionStorage,s=i?window.sessionStorage.getItem("tabs-"+n):null,a=s?JSON.parse(s):!1;this.find(".cms-tabset, .ss-tabset").each(function(){var n,i,s=$(this),o=s.attr("id"),r=s.find(".ss-tabs-force-active");s.data("tabs")&&(s.tabs("refresh"),r.length?n=r.index():e&&e[o]?(i=s.find(e[o].tabSelector),i.length&&(n=i.index())):a&&$.each(a,function(e,t){s.is("#"+t.id)&&(n=t.selected)}),null!==n&&(s.tabs("option","active",n),t.trigger("tabstaterestored")))})},clearTabState:function(e){if("undefined"!=typeof window.sessionStorage){var t=window.sessionStorage;if(e)t.removeItem("tabs-"+e);else for(var n=0;n<t.length;n++)t.key(n).match(/^tabs-/)&&t.removeItem(t.key(n))}},clearCurrentTabState:function(){this.clearTabState(this._tabStateUrl())},_tabStateUrl:function(){return window.history.state.path.replace(/\?.*/,"").replace(/#.*/,"").replace($("base").attr("href"),"")},showLoginDialog:function(){var e=$("body").data("member-tempid"),t=$(".leftandmain-logindialog"),n="CMSSecurity/login";t.length&&t.remove(),n=$.path.addSearchParams(n,{tempid:e,BackURL:window.location.href}),t=$('<div class="leftandmain-logindialog"></div>'),t.attr("id",(new Date).getTime()),t.data("url",n),$("body").append(t)}}),$(".leftandmain-logindialog").entwine({onmatch:function(){this._super(),this.ssdialog({iframeUrl:this.data("url"),dialogClass:"leftandmain-logindialog-dialog",autoOpen:!0,minWidth:500,maxWidth:500,minHeight:370,maxHeight:400,closeOnEscape:!1,open:function(){$(".ui-widget-overlay").addClass("leftandmain-logindialog-overlay")},close:function(){$(".ui-widget-overlay").removeClass("leftandmain-logindialog-overlay")}})},onunmatch:function(){this._super()},open:function(){this.ssdialog("open")},close:function(){this.ssdialog("close")},toggle:function(e){this.is(":visible")?this.close():this.open()},reauthenticate:function(e){"undefined"!=typeof e.SecurityID&&$(":input[name=SecurityID]").val(e.SecurityID),"undefined"!=typeof e.TempID&&$("body").data("member-tempid",e.TempID),this.close()}}),$("form.loading,.cms-content.loading,.cms-content-fields.loading,.cms-content-view.loading").entwine({onmatch:function(){this.append('<div class="cms-content-loading-overlay ui-widget-overlay-light"></div><div class="cms-content-loading-spinner"></div>'),this._super()},onunmatch:function(){this.find(".cms-content-loading-overlay,.cms-content-loading-spinner").remove(),this._super()}}),$('.cms input[type="submit"], .cms button, .cms input[type="reset"], .cms .ss-ui-button').entwine({onadd:function(){this.addClass("ss-ui-button"),this.data("button")||this.button(),this._super()},onremove:function(){this.data("button")&&this.button("destroy"),this._super()}}),$(".cms .cms-panel-link").entwine({onclick:function(e){if($(this).hasClass("external-link"))return void e.stopPropagation();var t=this.attr("href"),n=t&&!t.match(/^#/)?t:this.data("href"),i={pjax:this.data("pjaxTarget")};$(".cms-container").loadPanel(n,null,i),e.preventDefault()}}),$(".cms .ss-ui-button-ajax").entwine({onclick:function onclick(e){$(this).removeClass("ui-button-text-only"),$(this).addClass("ss-ui-button-loading ui-button-text-icons");var loading=$(this).find(".ss-ui-loading-icon");loading.length<1&&(loading=$("<span></span>").addClass("ss-ui-loading-icon ui-button-icon-primary ui-icon"),$(this).prepend(loading)),loading.show();var href=this.attr("href"),url=href?href:this.data("href");jQuery.ajax({url:url,complete:function complete(xmlhttp,status){var msg=xmlhttp.getResponseHeader("X-Status")?xmlhttp.getResponseHeader("X-Status"):xmlhttp.responseText;try{"undefined"!=typeof msg&&null!==msg&&eval(msg)}catch(e){}loading.hide(),$(".cms-container").refresh(),$(this).removeClass("ss-ui-button-loading ui-button-text-icons"),$(this).addClass("ui-button-text-only")},dataType:"html"}),e.preventDefault()}}),$(".cms .ss-ui-dialog-link").entwine({UUID:null,onmatch:function(){this._super(),this.setUUID((new Date).getTime())},onunmatch:function(){this._super()},onclick:function(){this._super();var e="ss-ui-dialog-"+this.getUUID(),t=$("#"+e);t.length||(t=$('<div class="ss-ui-dialog" id="'+e+'" />'),$("body").append(t));var n=this.data("popupclass")?this.data("popupclass"):"";return t.ssdialog({iframeUrl:this.attr("href"),autoOpen:!0,dialogExtraClass:n}),!1}}),$(".cms-content .Actions").entwine({onmatch:function(){this.find(".ss-ui-button").click(function(){var e=this.form;e&&(e.clickedButton=this,setTimeout(function(){e.clickedButton=null},10))}),this.redraw(),this._super()},onunmatch:function(){this._super()},redraw:function(){window.debug&&console.log("redraw",this.attr("class"),this.get(0)),this.contents().filter(function(){return 3==this.nodeType&&!/\S/.test(this.nodeValue)}).remove(),this.find(".ss-ui-button").each(function(){$(this).data("button")||$(this).button()}),this.find(".ss-ui-buttonset").buttonset()}}),$(".cms .field.date input.text").entwine({onmatch:function(){var e=$(this).parents(".field.date:first"),t=e.data();return t.showcalendar?(t.showOn="button",t.locale&&$.datepicker.regional[t.locale]&&(t=$.extend(t,$.datepicker.regional[t.locale],{})),$(this).datepicker(t),void this._super()):void this._super()},onunmatch:function(){this._super()}}),$(".cms .field.dropdown select, .cms .field select[multiple], .fieldholder-small select.dropdown").entwine({onmatch:function(){return this.is(".no-chosen")?void this._super():(this.data("placeholder")||this.data("placeholder"," "),this.removeClass("has-chosen").chosen("destroy"),this.siblings(".chosen-container").remove(),applyChosen(this),void this._super())},onunmatch:function(){this._super()}}),$(".cms-panel-layout").entwine({redraw:function(){window.debug&&console.log("redraw",this.attr("class"),this.get(0))}}),$(".cms .ss-gridfield").entwine({showDetailView:function(e){var t=window.location.search.replace(/^\?/,"");t&&(e=$.path.addSearchParams(e,t)),$(".cms-container").loadPanel(e)}}),$(".cms-search-form").entwine({onsubmit:function(e){var t,n;t=this.find(":input:not(:submit)").filter(function(){var e=$.grep($(this).fieldValue(),function(e){return e});return e.length}),n=this.attr("action"),t.length&&(n=$.path.addSearchParams(n,t.serialize().replace("+","%20")));var i=this.closest(".cms-container");return i.find(".cms-edit-form").tabs("select",0),i.loadPanel(n,"",{},!0),!1}}),$(".cms-search-form button[type=reset], .cms-search-form input[type=reset]").entwine({onclick:function(e){e.preventDefault();var t=$(this).parents("form");t.clearForm(),t.find(".dropdown select").prop("selectedIndex",0).trigger("chosen:updated"),t.submit()}}),window._panelDeferredCache={},$(".cms-panel-deferred").entwine({onadd:function(){this._super(),this.redraw()},onremove:function(){window.debug&&console.log("saving",this.data("url"),this),this.data("deferredNoCache")||(window._panelDeferredCache[this.data("url")]=this.html()),this._super()},redraw:function(){window.debug&&console.log("redraw",this.attr("class"),this.get(0));var e=this,t=this.data("url");if(!t)throw'Elements of class .cms-panel-deferred need a "data-url" attribute';this._super(),this.children().length||(this.data("deferredNoCache")||"undefined"==typeof window._panelDeferredCache[t]?(this.addClass("loading"),$.ajax({url:t,complete:function(){e.removeClass("loading")},success:function(t,n,i){e.html(t)}})):this.html(window._panelDeferredCache[t]))}}),$(".cms-tabset").entwine({onadd:function(){this.redrawTabs(),this._super()},onremove:function(){this.data("tabs")&&this.tabs("destroy"),this._super()},redrawTabs:function(){this.rewriteHashlinks();var e=(this.attr("id"),this.find("ul:first .ui-tabs-active"));this.data("uiTabs")||this.tabs({active:-1!=e.index()?e.index():0,beforeLoad:function(e,t){return!1},activate:function(e,t){var n=$(this).closest("form").find(".Actions");$(t.newTab).closest("li").hasClass("readonly")?n.fadeOut():n.show()}})},rewriteHashlinks:function(){$(this).find("ul a").each(function(){if($(this).attr("href")){var e=$(this).attr("href").match(/#.*/);e&&$(this).attr("href",document.location.href.replace(/#.*/,"")+e[0])}})}}),$("#filters-button").entwine({onmatch:function(){this._super(),this.data("collapsed",!0),
},onunmatch:function(){this._super()},showHide:function(){var e=this,t=$(".cms-content-filters").first(),n=this.data("collapsed");this.data("animating")||(this.toggleClass("active"),this.data("animating",!0),t[n?"slideDown":"slideUp"]({complete:function(){e.data("collapsed",!n),e.data("animating",!1)}}))},onclick:function(){this.showHide()}})});var statusMessage=function(e,t){e=jQuery("<div/>").text(e).html(),jQuery.noticeAdd({text:e,type:t,stayTime:5e3,inEffect:{left:"0",opacity:"show"}})},errorMessage=function(e){jQuery.noticeAdd({text:e,type:"error",stayTime:5e3,inEffect:{left:"0",opacity:"show"}})}},{jQuery:"jQuery","lib/Config":15,"lib/Router":"lib/Router"}],15:[function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var s=function(){function e(){i(this,e)}return e.getSection=function(e){return window.ss.config.sections[e]},e.getTopLevelRoutes=function(){var e=[];return Object.keys(window.ss.config.sections).forEach(function(t){var n=window.ss.config.sections[t].route,i=n.match(/^admin\/[^\/]+(\/?)$/);if(i){n=n.replace(/\/$/,"");var s=-1===e.indexOf(n);s&&e.push(n)}}),e},e}();n["default"]=s},{}]},{},[1]); this.data("animating",!1)},onunmatch:function(){this._super()},showHide:function(){var e=this,t=$(".cms-content-filters").first(),n=this.data("collapsed");this.data("animating")||(this.toggleClass("active"),this.data("animating",!0),t[n?"slideDown":"slideUp"]({complete:function(){e.data("collapsed",!n),e.data("animating",!1)}}))},onclick:function(){this.showHide()}})});var statusMessage=function(e,t){e=jQuery("<div/>").text(e).html(),jQuery.noticeAdd({text:e,type:t,stayTime:5e3,inEffect:{left:"0",opacity:"show"}})},errorMessage=function(e){jQuery.noticeAdd({text:e,type:"error",stayTime:5e3,inEffect:{left:"0",opacity:"show"}})}},{jQuery:"jQuery","lib/Config":15,"lib/Router":"lib/Router"}],15:[function(e,t,n){"use strict";function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var s=function(){function e(){i(this,e)}return e.getSection=function(e){return window.ss.config.sections[e]},e.getTopLevelRoutes=function(){var e=[];return Object.keys(window.ss.config.sections).forEach(function(t){var n=window.ss.config.sections[t].route,i=n.match(/^admin\/[^\/]+(\/?)$/);if(i){n=n.replace(/\/$/,"");var s=-1===e.indexOf(n);s&&e.push(n)}}),e},e}();n["default"]=s},{}]},{},[1]);
//# sourceMappingURL=bundle-legacy.js.map //# sourceMappingURL=bundle-legacy.js.map

View File

@ -21,26 +21,26 @@ window.ss.router = router;
* @desc Returns a function that will not be called until it hasn't been invoked for `wait` seconds. * @desc Returns a function that will not be called until it hasn't been invoked for `wait` seconds.
*/ */
window.ss.debounce = function (func, wait, immediate) { window.ss.debounce = function (func, wait, immediate) {
var timeout, context, args; var timeout, context, args;
var later = function() { var later = function() {
timeout = null; timeout = null;
if (!immediate) func.apply(context, args); if (!immediate) func.apply(context, args);
}; };
return function() { return function() {
var callNow = immediate && !timeout; var callNow = immediate && !timeout;
context = this; context = this;
args = arguments; args = arguments;
clearTimeout(timeout); clearTimeout(timeout);
timeout = setTimeout(later, wait); timeout = setTimeout(later, wait);
if (callNow) { if (callNow) {
func.apply(context, args); func.apply(context, args);
} }
}; };
}; };
/** /**
@ -50,14 +50,14 @@ window.ss.debounce = function (func, wait, immediate) {
* @return string * @return string
*/ */
function getUrlPath(url) { function getUrlPath(url) {
var anchor = document.createElement('a'); var anchor = document.createElement('a');
anchor.href = url; anchor.href = url;
return anchor.pathname return anchor.pathname
} }
$(window).bind('resize.leftandmain', function(e) { $(window).bind('resize.leftandmain', function(e) {
$('.cms-container').trigger('windowresize'); $('.cms-container').trigger('windowresize');
}); });
// setup jquery.entwine // setup jquery.entwine
@ -65,1437 +65,1440 @@ $.entwine.warningLevel = $.entwine.WARN_LEVEL_BESTPRACTISE;
$.entwine('ss', function($) { $.entwine('ss', function($) {
/* /*
* Handle messages sent via nested iframes * Handle messages sent via nested iframes
* Messages should be raised via postMessage with an object with the 'type' parameter given. * Messages should be raised via postMessage with an object with the 'type' parameter given.
* An optional 'target' and 'data' parameter can also be specified. If no target is specified * An optional 'target' and 'data' parameter can also be specified. If no target is specified
* events will be sent to the window instead. * events will be sent to the window instead.
* type should be one of: * type should be one of:
* - 'event' - Will trigger the given event (specified by 'event') on the target * - 'event' - Will trigger the given event (specified by 'event') on the target
* - 'callback' - Will call the given method (specified by 'callback') on the target * - 'callback' - Will call the given method (specified by 'callback') on the target
*/ */
$(window).on("message", function(e) { $(window).on("message", function(e) {
var target, var target,
event = e.originalEvent, event = e.originalEvent,
data = typeof event.data === 'object' ? event.data : JSON.parse(event.data); data = typeof event.data === 'object' ? event.data : JSON.parse(event.data);
// Reject messages outside of the same origin // Reject messages outside of the same origin
if($.path.parseUrl(window.location.href).domain !== $.path.parseUrl(event.origin).domain) return; if($.path.parseUrl(window.location.href).domain !== $.path.parseUrl(event.origin).domain) return;
// Get target of this action // Get target of this action
target = typeof(data.target) === 'undefined' target = typeof(data.target) === 'undefined'
? $(window) ? $(window)
: $(data.target); : $(data.target);
// Determine action // Determine action
switch(data.type) { switch(data.type) {
case 'event': case 'event':
target.trigger(data.event, data.data); target.trigger(data.event, data.data);
break; break;
case 'callback': case 'callback':
target[data.callback].call(target, data.data); target[data.callback].call(target, data.data);
break; break;
} }
}); });
/** /**
* Position the loading spinner animation below the ss logo * Position the loading spinner animation below the ss logo
*/ */
var positionLoadingSpinner = function() { var positionLoadingSpinner = function() {
var offset = 120; // offset from the ss logo var offset = 120; // offset from the ss logo
var spinner = $('.ss-loading-screen .loading-animation'); var spinner = $('.ss-loading-screen .loading-animation');
var top = ($(window).height() - spinner.height()) / 2; var top = ($(window).height() - spinner.height()) / 2;
spinner.css('top', top + offset); spinner.css('top', top + offset);
spinner.show(); spinner.show();
}; };
// apply an select element only when it is ready, ie. when it is rendered into a template // apply an select element only when it is ready, ie. when it is rendered into a template
// with css applied and got a width value. // with css applied and got a width value.
var applyChosen = function(el) { var applyChosen = function(el) {
if(el.is(':visible')) { if(el.is(':visible')) {
el.addClass('has-chosen').chosen({ el.addClass('has-chosen').chosen({
allow_single_deselect: true, allow_single_deselect: true,
disable_search_threshold: 20, disable_search_threshold: 20,
display_disabled_options: true display_disabled_options: true
}); });
} else { } else {
setTimeout(function() { setTimeout(function() {
// Make sure it's visible before applying the ui // Make sure it's visible before applying the ui
el.show(); el.show();
applyChosen(el); applyChosen(el);
}, 500); }, 500);
} }
}; };
/** /**
* Compare URLs, but normalize trailing slashes in * Compare URLs, but normalize trailing slashes in
* URL to work around routing weirdnesses in SS_HTTPRequest. * URL to work around routing weirdnesses in SS_HTTPRequest.
* Also normalizes relative URLs by prefixing them with the <base>. * Also normalizes relative URLs by prefixing them with the <base>.
*/ */
var isSameUrl = function(url1, url2) { var isSameUrl = function(url1, url2) {
var baseUrl = $('base').attr('href'); var baseUrl = $('base').attr('href');
url1 = $.path.isAbsoluteUrl(url1) ? url1 : $.path.makeUrlAbsolute(url1, baseUrl), url1 = $.path.isAbsoluteUrl(url1) ? url1 : $.path.makeUrlAbsolute(url1, baseUrl),
url2 = $.path.isAbsoluteUrl(url2) ? url2 : $.path.makeUrlAbsolute(url2, baseUrl); url2 = $.path.isAbsoluteUrl(url2) ? url2 : $.path.makeUrlAbsolute(url2, baseUrl);
var url1parts = $.path.parseUrl(url1), url2parts = $.path.parseUrl(url2); var url1parts = $.path.parseUrl(url1), url2parts = $.path.parseUrl(url2);
return ( return (
url1parts.pathname.replace(/\/*$/, '') == url2parts.pathname.replace(/\/*$/, '') && url1parts.pathname.replace(/\/*$/, '') == url2parts.pathname.replace(/\/*$/, '') &&
url1parts.search == url2parts.search url1parts.search == url2parts.search
); );
}; };
var ajaxCompleteEvent = window.ss.debounce(function () { var ajaxCompleteEvent = window.ss.debounce(function () {
$(window).trigger('ajaxComplete'); $(window).trigger('ajaxComplete');
}, 1000, true); }, 1000, true);
$(window).bind('resize', positionLoadingSpinner).trigger('resize'); $(window).bind('resize', positionLoadingSpinner).trigger('resize');
// global ajax handlers // global ajax handlers
$(document).ajaxComplete(function(e, xhr, settings) { $(document).ajaxComplete(function(e, xhr, settings) {
// Simulates a redirect on an ajax response. // Simulates a redirect on an ajax response.
var origUrl, var origUrl,
url = xhr.getResponseHeader('X-ControllerURL'), url = xhr.getResponseHeader('X-ControllerURL'),
destUrl = settings.url, destUrl = settings.url,
msg = xhr.getResponseHeader('X-Status') !== null ? xhr.getResponseHeader('X-Status') : xhr.statusText, // Handle custom status message headers msg = xhr.getResponseHeader('X-Status') !== null ? xhr.getResponseHeader('X-Status') : xhr.statusText, // Handle custom status message headers
msgType = (xhr.status < 200 || xhr.status > 399) ? 'bad' : 'good', msgType = (xhr.status < 200 || xhr.status > 399) ? 'bad' : 'good',
ignoredMessages = ['OK']; ignoredMessages = ['OK'];
if(window.history.state) { if(window.history.state) {
origUrl = window.history.state.path; origUrl = window.history.state.path;
} else { } else {
origUrl = document.URL; origUrl = document.URL;
} }
// Only redirect if controller url differs to the requested or current one // Only redirect if controller url differs to the requested or current one
if (url !== null && (!isSameUrl(origUrl, url) || !isSameUrl(destUrl, url))) { if (url !== null && (!isSameUrl(origUrl, url) || !isSameUrl(destUrl, url))) {
router.show(url, { router.show(url, {
id: (new Date()).getTime() + String(Math.random()).replace(/\D/g,''), // Ensure that redirections are followed through by history API by handing it a unique ID id: (new Date()).getTime() + String(Math.random()).replace(/\D/g,''), // Ensure that redirections are followed through by history API by handing it a unique ID
pjax: xhr.getResponseHeader('X-Pjax') ? xhr.getResponseHeader('X-Pjax') : settings.headers['X-Pjax'] pjax: xhr.getResponseHeader('X-Pjax') ? xhr.getResponseHeader('X-Pjax') : settings.headers['X-Pjax']
}); });
} }
// Enable reauthenticate dialog if requested // Enable reauthenticate dialog if requested
if (xhr.getResponseHeader('X-Reauthenticate')) { if (xhr.getResponseHeader('X-Reauthenticate')) {
$('.cms-container').showLoginDialog(); $('.cms-container').showLoginDialog();
return; return;
} }
// Show message (but ignore aborted requests) // Show message (but ignore aborted requests)
if (xhr.status !== 0 && msg && $.inArray(msg, ignoredMessages)) { if (xhr.status !== 0 && msg && $.inArray(msg, ignoredMessages)) {
// Decode into UTF-8, HTTP headers don't allow multibyte // Decode into UTF-8, HTTP headers don't allow multibyte
statusMessage(decodeURIComponent(msg), msgType); statusMessage(decodeURIComponent(msg), msgType);
} }
ajaxCompleteEvent(this); ajaxCompleteEvent(this);
}); });
/** /**
* Main LeftAndMain interface with some control panel and an edit form. * Main LeftAndMain interface with some control panel and an edit form.
* *
* Events: * Events:
* ajaxsubmit - ... * ajaxsubmit - ...
* validate - ... * validate - ...
* aftersubmitform - ... * aftersubmitform - ...
*/ */
$('.cms-container').entwine({ $('.cms-container').entwine({
/** /**
* Tracks current panel request. * Tracks current panel request.
*/ */
StateChangeXHR: null, StateChangeXHR: null,
/** /**
* Tracks current fragment-only parallel PJAX requests. * Tracks current fragment-only parallel PJAX requests.
*/ */
FragmentXHR: {}, FragmentXHR: {},
StateChangeCount: 0, StateChangeCount: 0,
/** /**
* Options for the threeColumnCompressor layout algorithm. * Options for the threeColumnCompressor layout algorithm.
* *
* See LeftAndMain.Layout.js for description of these options. * See LeftAndMain.Layout.js for description of these options.
*/ */
LayoutOptions: { LayoutOptions: {
minContentWidth: 940, minContentWidth: 940,
minPreviewWidth: 400, minPreviewWidth: 400,
mode: 'content' mode: 'content'
}, },
/** /**
* Constructor: onmatch * Constructor: onmatch
*/ */
onadd: function() { onadd: function() {
var self = this, var self = this,
basePath = getUrlPath($('base')[0].href); basePath = getUrlPath($('base')[0].href);
// Remove trailing / from base // Cleanup baseurl
basePath = basePath.replace(/\/$/, ''); basePath = basePath.replace(/\/$/, ''); // No trailing slash
router.base(basePath); if(basePath.match(/^[^\/]/)) {
basePath = '/' + basePath; // Mandatory leading slash
// Register all top level routes. }
Config.getTopLevelRoutes().forEach((route) => { router.base(basePath);
router(`/${route}(/*?)?`, (ctx, next) => {
// Register all top level routes.
// If the page isn't ready. Config.getTopLevelRoutes().forEach((route) => {
if (document.readyState !== 'complete') { router(`/${route}(/*?)?`, (ctx, next) => {
return next();
} // If the page isn't ready.
if (document.readyState !== 'complete') {
// Load the panel then call the next route. return next();
self.handleStateChange(null, ctx.state) }
.done(next);
}); // Load the panel then call the next route.
}); self.handleStateChange(null, ctx.state)
.done(next);
router.start(); });
});
// Browser detection
if($.browser.msie && parseInt($.browser.version, 10) < 8) { router.start();
$('.ss-loading-screen').append(
'<p class="ss-loading-incompat-warning"><span class="notice">' + // Browser detection
'Your browser is not compatible with the CMS interface. Please use Internet Explorer 8+, Google Chrome or Mozilla Firefox.' + if($.browser.msie && parseInt($.browser.version, 10) < 8) {
'</span></p>' $('.ss-loading-screen').append(
).css('z-index', $('.ss-loading-screen').css('z-index')+1); '<p class="ss-loading-incompat-warning"><span class="notice">' +
$('.loading-animation').remove(); 'Your browser is not compatible with the CMS interface. Please use Internet Explorer 8+, Google Chrome or Mozilla Firefox.' +
'</span></p>'
this._super(); ).css('z-index', $('.ss-loading-screen').css('z-index')+1);
return; $('.loading-animation').remove();
}
this._super();
// Initialize layouts return;
this.redraw(); }
// Remove loading screen // Initialize layouts
$('.ss-loading-screen').hide(); this.redraw();
$('body').removeClass('loading');
$(window).unbind('resize', positionLoadingSpinner); // Remove loading screen
this.restoreTabState(); $('.ss-loading-screen').hide();
this._super(); $('body').removeClass('loading');
}, $(window).unbind('resize', positionLoadingSpinner);
this.restoreTabState();
fromWindow: { this._super();
onstatechange: function(event, historyState){ },
this.handleStateChange(event, historyState);
} fromWindow: {
}, onstatechange: function(event, historyState){
this.handleStateChange(event, historyState);
'onwindowresize': function() { }
this.redraw(); },
},
'onwindowresize': function() {
'from .cms-panel': { this.redraw();
ontoggle: function(){ this.redraw(); } },
},
'from .cms-panel': {
'from .cms-container': { ontoggle: function(){ this.redraw(); }
onaftersubmitform: function(){ this.redraw(); } },
},
'from .cms-container': {
/** onaftersubmitform: function(){ this.redraw(); }
* Ensure the user can see the requested section - restore the default view. },
*/
'from .cms-menu-list li a': { /**
onclick: function(e) { * Ensure the user can see the requested section - restore the default view.
var href = $(e.target).attr('href'); */
if(e.which > 1 || href == this._tabStateUrl()) return; 'from .cms-menu-list li a': {
this.splitViewMode(); onclick: function(e) {
} var href = $(e.target).attr('href');
}, if(e.which > 1 || href == this._tabStateUrl()) return;
this.splitViewMode();
/** }
* Change the options of the threeColumnCompressor layout, and trigger layouting if needed. },
* You can provide any or all options. The remaining options will not be changed.
*/ /**
updateLayoutOptions: function(newSpec) { * Change the options of the threeColumnCompressor layout, and trigger layouting if needed.
var spec = this.getLayoutOptions(); * You can provide any or all options. The remaining options will not be changed.
*/
var dirty = false; updateLayoutOptions: function(newSpec) {
var spec = this.getLayoutOptions();
for (var k in newSpec) {
if (spec[k] !== newSpec[k]) { var dirty = false;
spec[k] = newSpec[k];
dirty = true; for (var k in newSpec) {
} if (spec[k] !== newSpec[k]) {
} spec[k] = newSpec[k];
dirty = true;
if (dirty) this.redraw(); }
}, }
/** if (dirty) this.redraw();
* Enable the split view - with content on the left and preview on the right. },
*/
splitViewMode: function() { /**
this.updateLayoutOptions({ * Enable the split view - with content on the left and preview on the right.
mode: 'split' */
}); splitViewMode: function() {
}, this.updateLayoutOptions({
mode: 'split'
/** });
* Content only. },
*/
contentViewMode: function() { /**
this.updateLayoutOptions({ * Content only.
mode: 'content' */
}); contentViewMode: function() {
}, this.updateLayoutOptions({
mode: 'content'
/** });
* Preview only. },
*/
previewMode: function() { /**
this.updateLayoutOptions({ * Preview only.
mode: 'preview' */
}); previewMode: function() {
}, this.updateLayoutOptions({
mode: 'preview'
RedrawSuppression: false, });
},
redraw: function() {
if (this.getRedrawSuppression()) return; RedrawSuppression: false,
if(window.debug) console.log('redraw', this.attr('class'), this.get(0)); redraw: function() {
if (this.getRedrawSuppression()) return;
// Reset the algorithm.
this.data('jlayout', jLayout.threeColumnCompressor( if(window.debug) console.log('redraw', this.attr('class'), this.get(0));
{
menu: this.children('.cms-menu'), // Reset the algorithm.
content: this.children('.cms-content'), this.data('jlayout', jLayout.threeColumnCompressor(
preview: this.children('.cms-preview') {
}, menu: this.children('.cms-menu'),
this.getLayoutOptions() content: this.children('.cms-content'),
)); preview: this.children('.cms-preview')
},
// Trigger layout algorithm once at the top. This also lays out children - we move from outside to this.getLayoutOptions()
// inside, resizing to fit the parent. ));
this.layout();
// Trigger layout algorithm once at the top. This also lays out children - we move from outside to
// Redraw on all the children that need it // inside, resizing to fit the parent.
this.find('.cms-panel-layout').redraw(); this.layout();
this.find('.cms-content-fields[data-layout-type]').redraw();
this.find('.cms-edit-form[data-layout-type]').redraw(); // Redraw on all the children that need it
this.find('.cms-preview').redraw(); this.find('.cms-panel-layout').redraw();
this.find('.cms-content').redraw(); this.find('.cms-content-fields[data-layout-type]').redraw();
}, this.find('.cms-edit-form[data-layout-type]').redraw();
this.find('.cms-preview').redraw();
/** this.find('.cms-content').redraw();
* Confirm whether the current user can navigate away from this page },
*
* @param {array} selectors Optional list of selectors /**
* @returns {boolean} True if the navigation can proceed * Confirm whether the current user can navigate away from this page
*/ *
checkCanNavigate: function(selectors) { * @param {array} selectors Optional list of selectors
// Check change tracking (can't use events as we need a way to cancel the current state change) * @returns {boolean} True if the navigation can proceed
var contentEls = this._findFragments(selectors || ['Content']), */
trackedEls = contentEls checkCanNavigate: function(selectors) {
.find(':data(changetracker)') // Check change tracking (can't use events as we need a way to cancel the current state change)
.add(contentEls.filter(':data(changetracker)')), var contentEls = this._findFragments(selectors || ['Content']),
safe = true; trackedEls = contentEls
.find(':data(changetracker)')
if(!trackedEls.length) { .add(contentEls.filter(':data(changetracker)')),
return true; safe = true;
}
if(!trackedEls.length) {
trackedEls.each(function() { return true;
// See LeftAndMain.EditForm.js }
if(!$(this).confirmUnsavedChanges()) {
safe = false; trackedEls.each(function() {
} // See LeftAndMain.EditForm.js
}); if(!$(this).confirmUnsavedChanges()) {
safe = false;
return safe; }
}, });
/** return safe;
* @param string url },
* @param string title - New window title.
* @param object data - Any additional data passed through to `window.history.state`. /**
* @param boolean forceReload - Forces the replacement of the current history state, even if the URL is the same, i.e. allows reloading. * @param string url
*/ * @param string title - New window title.
loadPanel: function (url, title = '', data = {}, forceReload, forceReferer = window.history.state.path) { * @param object data - Any additional data passed through to `window.history.state`.
// Check for unsaved changes * @param boolean forceReload - Forces the replacement of the current history state, even if the URL is the same, i.e. allows reloading.
if (!this.checkCanNavigate(data.pjax ? data.pjax.split(',') : ['Content'])) { */
return; loadPanel: function (url, title = '', data = {}, forceReload, forceReferer = window.history.state.path) {
} // Check for unsaved changes
if (!this.checkCanNavigate(data.pjax ? data.pjax.split(',') : ['Content'])) {
this.saveTabState(); return;
}
data.__forceReferer = forceReferer;
this.saveTabState();
if (forceReload) {
data.__forceReload = Math.random(); // Make sure the page reloads even if the URL is the same. data.__forceReferer = forceReferer;
}
if (forceReload) {
router.show(url, data); data.__forceReload = Math.random(); // Make sure the page reloads even if the URL is the same.
}, }
/** router.show(url, data);
* Nice wrapper for reloading current history state. },
*/
reloadCurrentPanel: function() { /**
this.loadPanel(window.history.state.path, null, null, true); * Nice wrapper for reloading current history state.
}, */
reloadCurrentPanel: function() {
/** this.loadPanel(window.history.state.path, null, null, true);
* Function: submitForm },
*
* Parameters: /**
* {DOMElement} form - The form to be submitted. Needs to be passed * Function: submitForm
* in to avoid entwine methods/context being removed through replacing the node itself. *
* {DOMElement} button - The pressed button (optional) * Parameters:
* {Function} callback - Called in complete() handler of jQuery.ajax() * {DOMElement} form - The form to be submitted. Needs to be passed
* {Object} ajaxOptions - Object literal to merge into $.ajax() call * in to avoid entwine methods/context being removed through replacing the node itself.
* * {DOMElement} button - The pressed button (optional)
* Returns: * {Function} callback - Called in complete() handler of jQuery.ajax()
* (boolean) * {Object} ajaxOptions - Object literal to merge into $.ajax() call
*/ *
submitForm: function(form, button, callback, ajaxOptions) { * Returns:
var self = this; * (boolean)
*/
// look for save button submitForm: function(form, button, callback, ajaxOptions) {
if(!button) button = this.find('.Actions :submit[name=action_save]'); var self = this;
// default to first button if none given - simulates browser behaviour
if(!button) button = this.find('.Actions :submit:first'); // look for save button
if(!button) button = this.find('.Actions :submit[name=action_save]');
form.trigger('beforesubmitform'); // default to first button if none given - simulates browser behaviour
this.trigger('submitform', {form: form, button: button}); if(!button) button = this.find('.Actions :submit:first');
// set button to "submitting" state form.trigger('beforesubmitform');
$(button).addClass('loading'); this.trigger('submitform', {form: form, button: button});
// validate if required // set button to "submitting" state
var validationResult = form.validate(); $(button).addClass('loading');
if(typeof validationResult!=='undefined' && !validationResult) {
// TODO Automatically switch to the tab/position of the first error // validate if required
statusMessage("Validation failed.", "bad"); var validationResult = form.validate();
if(typeof validationResult!=='undefined' && !validationResult) {
$(button).removeClass('loading'); // TODO Automatically switch to the tab/position of the first error
statusMessage("Validation failed.", "bad");
return false;
} $(button).removeClass('loading');
// get all data from the form return false;
var formData = form.serializeArray(); }
// add button action
formData.push({name: $(button).attr('name'), value:'1'}); // get all data from the form
// Artificial HTTP referer, IE doesn't submit them via ajax. var formData = form.serializeArray();
// Also rewrites anchors to their page counterparts, which is important // add button action
// as automatic browser ajax response redirects seem to discard the hash/fragment. formData.push({name: $(button).attr('name'), value:'1'});
// TODO Replaces trailing slashes added by History after locale (e.g. admin/?locale=en/) // Artificial HTTP referer, IE doesn't submit them via ajax.
formData.push({ name: 'BackURL', value: window.history.state.path.replace(/\/$/, '') }); // Also rewrites anchors to their page counterparts, which is important
// as automatic browser ajax response redirects seem to discard the hash/fragment.
// Save tab selections so we can restore them later // TODO Replaces trailing slashes added by History after locale (e.g. admin/?locale=en/)
this.saveTabState(); formData.push({ name: 'BackURL', value: window.history.state.path.replace(/\/$/, '') });
// Standard Pjax behaviour is to replace the submitted form with new content. // Save tab selections so we can restore them later
// The returned view isn't always decided upon when the request this.saveTabState();
// is fired, so the server might decide to change it based on its own logic,
// sending back different `X-Pjax` headers and content // Standard Pjax behaviour is to replace the submitted form with new content.
jQuery.ajax(jQuery.extend({ // The returned view isn't always decided upon when the request
headers: {"X-Pjax" : "CurrentForm,Breadcrumbs"}, // is fired, so the server might decide to change it based on its own logic,
url: form.attr('action'), // sending back different `X-Pjax` headers and content
data: formData, jQuery.ajax(jQuery.extend({
type: 'POST', headers: {"X-Pjax" : "CurrentForm,Breadcrumbs"},
complete: function() { url: form.attr('action'),
$(button).removeClass('loading'); data: formData,
}, type: 'POST',
success: function(data, status, xhr) { complete: function() {
form.removeClass('changed'); // TODO This should be using the plugin API $(button).removeClass('loading');
if(callback) callback(data, status, xhr); },
success: function(data, status, xhr) {
var newContentEls = self.handleAjaxResponse(data, status, xhr); form.removeClass('changed'); // TODO This should be using the plugin API
if(!newContentEls) return; if(callback) callback(data, status, xhr);
newContentEls.filter('form').trigger('aftersubmitform', {status: status, xhr: xhr, formData: formData}); var newContentEls = self.handleAjaxResponse(data, status, xhr);
} if(!newContentEls) return;
}, ajaxOptions));
newContentEls.filter('form').trigger('aftersubmitform', {status: status, xhr: xhr, formData: formData});
return false; }
}, }, ajaxOptions));
/** return false;
* Last html5 history state },
*/
LastState: null, /**
* Last html5 history state
/** */
* Flag to pause handleStateChange LastState: null,
*/
PauseState: false, /**
* Flag to pause handleStateChange
/** */
* Handles ajax loading of new panels through the window.history object. PauseState: false,
* To trigger loading, pass a new URL to router.show().
* Use loadPanel() as a router.show() wrapper as it provides some additional functionality /**
* like global changetracking and user aborts. * Handles ajax loading of new panels through the window.history object.
* * To trigger loading, pass a new URL to router.show().
* Due to the nature of history management, no callbacks are allowed. * Use loadPanel() as a router.show() wrapper as it provides some additional functionality
* Use the 'beforestatechange' and 'afterstatechange' events instead, * like global changetracking and user aborts.
* or overwrite the beforeLoad() and afterLoad() methods on the *
* DOM element you're loading the new content into. * Due to the nature of history management, no callbacks are allowed.
* Although you can pass data into router.show(url, data), it shouldn't contain * Use the 'beforestatechange' and 'afterstatechange' events instead,
* DOM elements or callback closures. * or overwrite the beforeLoad() and afterLoad() methods on the
* * DOM element you're loading the new content into.
* The passed URL should allow reconstructing important interface state * Although you can pass data into router.show(url, data), it shouldn't contain
* without additional parameters, in the following use cases: * DOM elements or callback closures.
* - Explicit loading through router.show() *
* - Implicit loading through browser navigation event triggered by the user (forward or back) * The passed URL should allow reconstructing important interface state
* - Full window refresh without ajax * without additional parameters, in the following use cases:
* For example, a ModelAdmin search event should contain the search terms * - Explicit loading through router.show()
* as URL parameters, and the result display should automatically appear * - Implicit loading through browser navigation event triggered by the user (forward or back)
* if the URL is loaded without ajax. * - Full window refresh without ajax
*/ * For example, a ModelAdmin search event should contain the search terms
handleStateChange: function (event, historyState = window.history.state) { * as URL parameters, and the result display should automatically appear
if (this.getPauseState()) { * if the URL is loaded without ajax.
return; */
} handleStateChange: function (event, historyState = window.history.state) {
if (this.getPauseState()) {
// Don't allow parallel loading to avoid edge cases return;
if (this.getStateChangeXHR()) { }
this.getStateChangeXHR().abort();
} // Don't allow parallel loading to avoid edge cases
if (this.getStateChangeXHR()) {
var self = this, this.getStateChangeXHR().abort();
fragments = historyState.pjax || 'Content', }
headers = {},
fragmentsArr = fragments.split(','), var self = this,
contentEls = this._findFragments(fragmentsArr); fragments = historyState.pjax || 'Content',
headers = {},
this.setStateChangeCount(this.getStateChangeCount() + 1); fragmentsArr = fragments.split(','),
contentEls = this._findFragments(fragmentsArr);
if (!this.checkCanNavigate()) {
var lastState = this.getLastState(); this.setStateChangeCount(this.getStateChangeCount() + 1);
// Suppress panel loading while resetting state if (!this.checkCanNavigate()) {
this.setPauseState(true); var lastState = this.getLastState();
// Restore best last state // Suppress panel loading while resetting state
if (lastState !== null) { this.setPauseState(true);
router.show(lastState.url);
} else { // Restore best last state
router.back(); if (lastState !== null) {
} router.show(lastState.url);
} else {
this.setPauseState(false); router.back();
}
// Abort loading of this panel
return; this.setPauseState(false);
}
// Abort loading of this panel
this.setLastState(historyState); return;
}
// If any of the requested Pjax fragments don't exist in the current view,
// fetch the "Content" view instead, which is the "outermost" fragment this.setLastState(historyState);
// that can be reloaded without reloading the whole window.
if (contentEls.length < fragmentsArr.length) { // If any of the requested Pjax fragments don't exist in the current view,
fragments = 'Content', fragmentsArr = ['Content']; // fetch the "Content" view instead, which is the "outermost" fragment
contentEls = this._findFragments(fragmentsArr); // that can be reloaded without reloading the whole window.
} if (contentEls.length < fragmentsArr.length) {
fragments = 'Content', fragmentsArr = ['Content'];
this.trigger('beforestatechange', { state: historyState, element: contentEls }); contentEls = this._findFragments(fragmentsArr);
}
// Set Pjax headers, which can declare a preference for the returned view.
// The actually returned view isn't always decided upon when the request this.trigger('beforestatechange', { state: historyState, element: contentEls });
// is fired, so the server might decide to change it based on its own logic.
headers['X-Pjax'] = fragments; // Set Pjax headers, which can declare a preference for the returned view.
// The actually returned view isn't always decided upon when the request
if (typeof historyState.__forceReferer !== 'undefined') { // is fired, so the server might decide to change it based on its own logic.
// Ensure query string is properly encoded if present headers['X-Pjax'] = fragments;
let url = historyState.__forceReferer;
if (typeof historyState.__forceReferer !== 'undefined') {
try { // Ensure query string is properly encoded if present
// Prevent double-encoding by attempting to decode let url = historyState.__forceReferer;
url = decodeURI(url);
} catch(e) { try {
// URL not encoded, or was encoded incorrectly, so do nothing // Prevent double-encoding by attempting to decode
} finally { url = decodeURI(url);
// Set our referer header to the encoded URL } catch(e) {
headers['X-Backurl'] = encodeURI(url); // URL not encoded, or was encoded incorrectly, so do nothing
} } finally {
} // Set our referer header to the encoded URL
headers['X-Backurl'] = encodeURI(url);
contentEls.addClass('loading'); }
}
let promise = $.ajax({
headers: headers, contentEls.addClass('loading');
url: historyState.path
}) let promise = $.ajax({
.done((data, status, xhr) => { headers: headers,
var els = self.handleAjaxResponse(data, status, xhr, historyState); url: historyState.path
self.trigger('afterstatechange', {data: data, status: status, xhr: xhr, element: els, state: historyState}); })
}) .done((data, status, xhr) => {
.always(() => { var els = self.handleAjaxResponse(data, status, xhr, historyState);
self.setStateChangeXHR(null); self.trigger('afterstatechange', {data: data, status: status, xhr: xhr, element: els, state: historyState});
// Remove loading indication from old content els (regardless of which are replaced) })
contentEls.removeClass('loading'); .always(() => {
}); self.setStateChangeXHR(null);
// Remove loading indication from old content els (regardless of which are replaced)
this.setStateChangeXHR(promise); contentEls.removeClass('loading');
});
return promise;
}, this.setStateChangeXHR(promise);
/** return promise;
* ALternative to loadPanel/submitForm. },
*
* Triggers a parallel-fetch of a PJAX fragment, which is a separate request to the /**
* state change requests. There could be any amount of these fetches going on in the background, * ALternative to loadPanel/submitForm.
* and they don't register as a HTML5 history states. *
* * Triggers a parallel-fetch of a PJAX fragment, which is a separate request to the
* This is meant for updating a PJAX areas that are not complete panel/form reloads. These you'd * state change requests. There could be any amount of these fetches going on in the background,
* normally do via submitForm or loadPanel which have a lot of automation built in. * and they don't register as a HTML5 history states.
* *
* On receiving successful response, the framework will update the element tagged with appropriate * This is meant for updating a PJAX areas that are not complete panel/form reloads. These you'd
* data-pjax-fragment attribute (e.g. data-pjax-fragment="<pjax-fragment-name>"). Make sure this element * normally do via submitForm or loadPanel which have a lot of automation built in.
* is available. *
* * On receiving successful response, the framework will update the element tagged with appropriate
* Example usage: * data-pjax-fragment attribute (e.g. data-pjax-fragment="<pjax-fragment-name>"). Make sure this element
* $('.cms-container').loadFragment('admin/foobar/', 'FragmentName'); * is available.
* *
* @param url string Relative or absolute url of the controller. * Example usage:
* @param pjaxFragments string PJAX fragment(s), comma separated. * $('.cms-container').loadFragment('admin/foobar/', 'FragmentName');
*/ *
loadFragment: function(url, pjaxFragments) { * @param url string Relative or absolute url of the controller.
* @param pjaxFragments string PJAX fragment(s), comma separated.
var self = this, */
xhr, loadFragment: function(url, pjaxFragments) {
headers = {},
baseUrl = $('base').attr('href'), var self = this,
fragmentXHR = this.getFragmentXHR(); xhr,
headers = {},
// Make sure only one XHR for a specific fragment is currently in progress. baseUrl = $('base').attr('href'),
if( fragmentXHR = this.getFragmentXHR();
typeof fragmentXHR[pjaxFragments]!=='undefined' &&
fragmentXHR[pjaxFragments]!==null // Make sure only one XHR for a specific fragment is currently in progress.
) { if(
fragmentXHR[pjaxFragments].abort(); typeof fragmentXHR[pjaxFragments]!=='undefined' &&
fragmentXHR[pjaxFragments] = null; fragmentXHR[pjaxFragments]!==null
} ) {
fragmentXHR[pjaxFragments].abort();
url = $.path.isAbsoluteUrl(url) ? url : $.path.makeUrlAbsolute(url, baseUrl); fragmentXHR[pjaxFragments] = null;
headers['X-Pjax'] = pjaxFragments; }
xhr = $.ajax({ url = $.path.isAbsoluteUrl(url) ? url : $.path.makeUrlAbsolute(url, baseUrl);
headers: headers, headers['X-Pjax'] = pjaxFragments;
url: url,
success: function(data, status, xhr) { xhr = $.ajax({
var elements = self.handleAjaxResponse(data, status, xhr, null); headers: headers,
url: url,
// We are fully done now, make it possible for others to hook in here. success: function(data, status, xhr) {
self.trigger('afterloadfragment', { data: data, status: status, xhr: xhr, elements: elements }); var elements = self.handleAjaxResponse(data, status, xhr, null);
},
error: function(xhr, status, error) { // We are fully done now, make it possible for others to hook in here.
self.trigger('loadfragmenterror', { xhr: xhr, status: status, error: error }); self.trigger('afterloadfragment', { data: data, status: status, xhr: xhr, elements: elements });
}, },
complete: function() { error: function(xhr, status, error) {
// Reset the current XHR in tracking object. self.trigger('loadfragmenterror', { xhr: xhr, status: status, error: error });
var fragmentXHR = self.getFragmentXHR(); },
if( complete: function() {
typeof fragmentXHR[pjaxFragments]!=='undefined' && // Reset the current XHR in tracking object.
fragmentXHR[pjaxFragments]!==null var fragmentXHR = self.getFragmentXHR();
) { if(
fragmentXHR[pjaxFragments] = null; typeof fragmentXHR[pjaxFragments]!=='undefined' &&
} fragmentXHR[pjaxFragments]!==null
} ) {
}); fragmentXHR[pjaxFragments] = null;
}
// Store the fragment request so we can abort later, should we get a duplicate request. }
fragmentXHR[pjaxFragments] = xhr; });
return xhr; // Store the fragment request so we can abort later, should we get a duplicate request.
}, fragmentXHR[pjaxFragments] = xhr;
/** return xhr;
* Handles ajax responses containing plain HTML, or mulitple },
* PJAX fragments wrapped in JSON (see PjaxResponseNegotiator PHP class).
* Can be hooked into an ajax 'success' callback. /**
* * Handles ajax responses containing plain HTML, or mulitple
* Parameters: * PJAX fragments wrapped in JSON (see PjaxResponseNegotiator PHP class).
* (Object) data * Can be hooked into an ajax 'success' callback.
* (String) status *
* (XMLHTTPRequest) xhr * Parameters:
* (Object) state The original history state which the request was initiated with * (Object) data
*/ * (String) status
handleAjaxResponse: function(data, status, xhr, state) { * (XMLHTTPRequest) xhr
var self = this, url, selectedTabs, guessFragment, fragment, $data; * (Object) state The original history state which the request was initiated with
*/
// Support a full reload handleAjaxResponse: function(data, status, xhr, state) {
if(xhr.getResponseHeader('X-Reload') && xhr.getResponseHeader('X-ControllerURL')) { var self = this, url, selectedTabs, guessFragment, fragment, $data;
var baseUrl = $('base').attr('href'),
rawURL = xhr.getResponseHeader('X-ControllerURL'), // Support a full reload
url = $.path.isAbsoluteUrl(rawURL) ? rawURL : $.path.makeUrlAbsolute(rawURL, baseUrl); if(xhr.getResponseHeader('X-Reload') && xhr.getResponseHeader('X-ControllerURL')) {
var baseUrl = $('base').attr('href'),
document.location.href = url; rawURL = xhr.getResponseHeader('X-ControllerURL'),
return; url = $.path.isAbsoluteUrl(rawURL) ? rawURL : $.path.makeUrlAbsolute(rawURL, baseUrl);
}
document.location.href = url;
// Pseudo-redirects via X-ControllerURL might return empty data, in which return;
// case we'll ignore the response }
if(!data) return;
// Pseudo-redirects via X-ControllerURL might return empty data, in which
// Update title // case we'll ignore the response
var title = xhr.getResponseHeader('X-Title'); if(!data) return;
if(title) document.title = decodeURIComponent(title.replace(/\+/g, ' '));
// Update title
var newFragments = {}, newContentEls; var title = xhr.getResponseHeader('X-Title');
// If content type is text/json (ignoring charset and other parameters) if(title) document.title = decodeURIComponent(title.replace(/\+/g, ' '));
if(xhr.getResponseHeader('Content-Type').match(/^((text)|(application))\/json[ \t]*;?/i)) {
newFragments = data; var newFragments = {}, newContentEls;
} else { // If content type is text/json (ignoring charset and other parameters)
if(xhr.getResponseHeader('Content-Type').match(/^((text)|(application))\/json[ \t]*;?/i)) {
// Fall back to replacing the content fragment if HTML is returned newFragments = data;
fragment = document.createDocumentFragment(); } else {
jQuery.clean( [ data ], document, fragment, [] ); // Fall back to replacing the content fragment if HTML is returned
$data = $(jQuery.merge( [], fragment.childNodes )); fragment = document.createDocumentFragment();
// Try and guess the fragment if none is provided jQuery.clean( [ data ], document, fragment, [] );
// TODO: data-pjax-fragment might actually give us the fragment. For now we just check most common case $data = $(jQuery.merge( [], fragment.childNodes ));
guessFragment = 'Content';
if ($data.is('form') && !$data.is('[data-pjax-fragment~=Content]')) guessFragment = 'CurrentForm'; // Try and guess the fragment if none is provided
// TODO: data-pjax-fragment might actually give us the fragment. For now we just check most common case
newFragments[guessFragment] = $data; guessFragment = 'Content';
} if ($data.is('form') && !$data.is('[data-pjax-fragment~=Content]')) guessFragment = 'CurrentForm';
this.setRedrawSuppression(true); newFragments[guessFragment] = $data;
try { }
// Replace each fragment individually
$.each(newFragments, function(newFragment, html) { this.setRedrawSuppression(true);
var contentEl = $('[data-pjax-fragment]').filter(function() { try {
return $.inArray(newFragment, $(this).data('pjaxFragment').split(' ')) != -1; // Replace each fragment individually
}), newContentEl = $(html); $.each(newFragments, function(newFragment, html) {
var contentEl = $('[data-pjax-fragment]').filter(function() {
// Add to result collection return $.inArray(newFragment, $(this).data('pjaxFragment').split(' ')) != -1;
if(newContentEls) newContentEls.add(newContentEl); }), newContentEl = $(html);
else newContentEls = newContentEl;
// Add to result collection
// Update panels if(newContentEls) newContentEls.add(newContentEl);
if(newContentEl.find('.cms-container').length) { else newContentEls = newContentEl;
throw 'Content loaded via ajax is not allowed to contain tags matching the ".cms-container" selector to avoid infinite loops';
} // Update panels
if(newContentEl.find('.cms-container').length) {
// Set loading state and store element state throw 'Content loaded via ajax is not allowed to contain tags matching the ".cms-container" selector to avoid infinite loops';
var origStyle = contentEl.attr('style'); }
var origParent = contentEl.parent();
var origParentLayoutApplied = (typeof origParent.data('jlayout')!=='undefined'); // Set loading state and store element state
var layoutClasses = ['east', 'west', 'center', 'north', 'south', 'column-hidden']; var origStyle = contentEl.attr('style');
var elemClasses = contentEl.attr('class'); var origParent = contentEl.parent();
var origLayoutClasses = []; var origParentLayoutApplied = (typeof origParent.data('jlayout')!=='undefined');
if(elemClasses) { var layoutClasses = ['east', 'west', 'center', 'north', 'south', 'column-hidden'];
origLayoutClasses = $.grep( var elemClasses = contentEl.attr('class');
elemClasses.split(' '), var origLayoutClasses = [];
function(val) { return ($.inArray(val, layoutClasses) >= 0);} if(elemClasses) {
); origLayoutClasses = $.grep(
} elemClasses.split(' '),
function(val) { return ($.inArray(val, layoutClasses) >= 0);}
newContentEl );
.removeClass(layoutClasses.join(' ')) }
.addClass(origLayoutClasses.join(' '));
if(origStyle) newContentEl.attr('style', origStyle); newContentEl
.removeClass(layoutClasses.join(' '))
// Allow injection of inline styles, as they're not allowed in the document body. .addClass(origLayoutClasses.join(' '));
// Not handling this through jQuery.ondemand to avoid parsing the DOM twice. if(origStyle) newContentEl.attr('style', origStyle);
var styles = newContentEl.find('style').detach();
if(styles.length) $(document).find('head').append(styles); // Allow injection of inline styles, as they're not allowed in the document body.
// Not handling this through jQuery.ondemand to avoid parsing the DOM twice.
// Replace panel completely (we need to override the "layout" attribute, so can't replace the child instead) var styles = newContentEl.find('style').detach();
contentEl.replaceWith(newContentEl); if(styles.length) $(document).find('head').append(styles);
// Force jlayout to rebuild internal hierarchy to point to the new elements. // Replace panel completely (we need to override the "layout" attribute, so can't replace the child instead)
// This is only necessary for elements that are at least 3 levels deep. 2nd level elements will contentEl.replaceWith(newContentEl);
// be taken care of when we lay out the top level element (.cms-container).
if (!origParent.is('.cms-container') && origParentLayoutApplied) { // Force jlayout to rebuild internal hierarchy to point to the new elements.
origParent.layout(); // This is only necessary for elements that are at least 3 levels deep. 2nd level elements will
} // be taken care of when we lay out the top level element (.cms-container).
}); if (!origParent.is('.cms-container') && origParentLayoutApplied) {
origParent.layout();
// Re-init tabs (in case the form tag itself is a tabset) }
var newForm = newContentEls.filter('form'); });
if(newForm.hasClass('cms-tabset')) newForm.removeClass('cms-tabset').addClass('cms-tabset');
} // Re-init tabs (in case the form tag itself is a tabset)
finally { var newForm = newContentEls.filter('form');
this.setRedrawSuppression(false); if(newForm.hasClass('cms-tabset')) newForm.removeClass('cms-tabset').addClass('cms-tabset');
} }
finally {
this.redraw(); this.setRedrawSuppression(false);
this.restoreTabState((state && typeof state.tabState !== 'undefined') ? state.tabState : null); }
return newContentEls; this.redraw();
}, this.restoreTabState((state && typeof state.tabState !== 'undefined') ? state.tabState : null);
/** return newContentEls;
* },
*
* Parameters: /**
* - fragments {Array} *
* Returns: jQuery collection *
*/ * Parameters:
_findFragments: function(fragments) { * - fragments {Array}
return $('[data-pjax-fragment]').filter(function() { * Returns: jQuery collection
// Allows for more than one fragment per node */
var i, nodeFragments = $(this).data('pjaxFragment').split(' '); _findFragments: function(fragments) {
for(i in fragments) { return $('[data-pjax-fragment]').filter(function() {
if($.inArray(fragments[i], nodeFragments) != -1) return true; // Allows for more than one fragment per node
} var i, nodeFragments = $(this).data('pjaxFragment').split(' ');
return false; for(i in fragments) {
}); if($.inArray(fragments[i], nodeFragments) != -1) return true;
}, }
return false;
/** });
* Function: refresh },
*
* Updates the container based on the current url /**
* * Function: refresh
* Returns: void *
*/ * Updates the container based on the current url
refresh: function() { *
$(window).trigger('statechange'); * Returns: void
*/
$(this).redraw(); refresh: function() {
}, $(window).trigger('statechange');
/** $(this).redraw();
* Save tab selections in order to reconstruct them later. },
* Requires HTML5 sessionStorage support.
*/ /**
saveTabState: function() { * Save tab selections in order to reconstruct them later.
if(typeof(window.sessionStorage)=="undefined" || window.sessionStorage === null) return; * Requires HTML5 sessionStorage support.
*/
var selectedTabs = [], url = this._tabStateUrl(); saveTabState: function() {
this.find('.cms-tabset,.ss-tabset').each(function(i, el) { if(typeof(window.sessionStorage)=="undefined" || window.sessionStorage === null) return;
var id = $(el).attr('id');
if(!id) return; // we need a unique reference var selectedTabs = [], url = this._tabStateUrl();
if(!$(el).data('tabs')) return; // don't act on uninit'ed controls this.find('.cms-tabset,.ss-tabset').each(function(i, el) {
var id = $(el).attr('id');
// Allow opt-out via data element or entwine property. if(!id) return; // we need a unique reference
if($(el).data('ignoreTabState') || $(el).getIgnoreTabState()) return; if(!$(el).data('tabs')) return; // don't act on uninit'ed controls
selectedTabs.push({id:id, selected:$(el).tabs('option', 'selected')}); // Allow opt-out via data element or entwine property.
}); if($(el).data('ignoreTabState') || $(el).getIgnoreTabState()) return;
if(selectedTabs) { selectedTabs.push({id:id, selected:$(el).tabs('option', 'selected')});
var tabsUrl = 'tabs-' + url; });
try {
window.sessionStorage.setItem(tabsUrl, JSON.stringify(selectedTabs)); if(selectedTabs) {
} catch(err) { var tabsUrl = 'tabs-' + url;
if (err.code === DOMException.QUOTA_EXCEEDED_ERR && window.sessionStorage.length === 0) { try {
// If this fails we ignore the error as the only issue is that it window.sessionStorage.setItem(tabsUrl, JSON.stringify(selectedTabs));
// does not remember the tab state. } catch(err) {
// This is a Safari bug which happens when private browsing is enabled. if (err.code === DOMException.QUOTA_EXCEEDED_ERR && window.sessionStorage.length === 0) {
return; // If this fails we ignore the error as the only issue is that it
} else { // does not remember the tab state.
throw err; // This is a Safari bug which happens when private browsing is enabled.
} return;
} } else {
} throw err;
}, }
}
/** }
* Re-select previously saved tabs. },
* Requires HTML5 sessionStorage support.
* /**
* Parameters: * Re-select previously saved tabs.
* (Object) Map of tab container selectors to tab selectors. * Requires HTML5 sessionStorage support.
* Used to mark a specific tab as active regardless of the previously saved options. *
*/ * Parameters:
restoreTabState: function(overrideStates) { * (Object) Map of tab container selectors to tab selectors.
var self = this, url = this._tabStateUrl(), * Used to mark a specific tab as active regardless of the previously saved options.
hasSessionStorage = (typeof(window.sessionStorage)!=="undefined" && window.sessionStorage), */
sessionData = hasSessionStorage ? window.sessionStorage.getItem('tabs-' + url) : null, restoreTabState: function(overrideStates) {
sessionStates = sessionData ? JSON.parse(sessionData) : false; var self = this, url = this._tabStateUrl(),
hasSessionStorage = (typeof(window.sessionStorage)!=="undefined" && window.sessionStorage),
this.find('.cms-tabset, .ss-tabset').each(function() { sessionData = hasSessionStorage ? window.sessionStorage.getItem('tabs-' + url) : null,
var index, tabset = $(this), tabsetId = tabset.attr('id'), tab, sessionStates = sessionData ? JSON.parse(sessionData) : false;
forcedTab = tabset.find('.ss-tabs-force-active');
this.find('.cms-tabset, .ss-tabset').each(function() {
if(!tabset.data('tabs')){ var index, tabset = $(this), tabsetId = tabset.attr('id'), tab,
return; // don't act on uninit'ed controls forcedTab = tabset.find('.ss-tabs-force-active');
}
if(!tabset.data('tabs')){
// The tabs may have changed, notify the widget that it should update its internal state. return; // don't act on uninit'ed controls
tabset.tabs('refresh'); }
// Make sure the intended tab is selected. // The tabs may have changed, notify the widget that it should update its internal state.
if(forcedTab.length) { tabset.tabs('refresh');
index = forcedTab.index();
} else if(overrideStates && overrideStates[tabsetId]) { // Make sure the intended tab is selected.
tab = tabset.find(overrideStates[tabsetId].tabSelector); if(forcedTab.length) {
if(tab.length){ index = forcedTab.index();
index = tab.index(); } else if(overrideStates && overrideStates[tabsetId]) {
} tab = tabset.find(overrideStates[tabsetId].tabSelector);
} else if(sessionStates) { if(tab.length){
$.each(sessionStates, function(i, sessionState) { index = tab.index();
if(tabset.is('#' + sessionState.id)){ }
index = sessionState.selected; } else if(sessionStates) {
} $.each(sessionStates, function(i, sessionState) {
}); if(tabset.is('#' + sessionState.id)){
} index = sessionState.selected;
if(index !== null){ }
tabset.tabs('option', 'active', index); });
self.trigger('tabstaterestored'); }
} if(index !== null){
}); tabset.tabs('option', 'active', index);
}, self.trigger('tabstaterestored');
}
/** });
* Remove any previously saved state. },
*
* Parameters: /**
* (String) url Optional (sanitized) URL to clear a specific state. * Remove any previously saved state.
*/ *
clearTabState: function(url) { * Parameters:
if(typeof(window.sessionStorage)=="undefined") return; * (String) url Optional (sanitized) URL to clear a specific state.
*/
var s = window.sessionStorage; clearTabState: function(url) {
if(url) { if(typeof(window.sessionStorage)=="undefined") return;
s.removeItem('tabs-' + url);
} else { var s = window.sessionStorage;
for(var i=0;i<s.length;i++) { if(url) {
if(s.key(i).match(/^tabs-/)) s.removeItem(s.key(i)); s.removeItem('tabs-' + url);
} } else {
} for(var i=0;i<s.length;i++) {
}, if(s.key(i).match(/^tabs-/)) s.removeItem(s.key(i));
}
/** }
* Remove tab state for the current URL. },
*/
clearCurrentTabState: function() { /**
this.clearTabState(this._tabStateUrl()); * Remove tab state for the current URL.
}, */
clearCurrentTabState: function() {
_tabStateUrl: function() { this.clearTabState(this._tabStateUrl());
return window.history.state.path },
.replace(/\?.*/, '')
.replace(/#.*/, '') _tabStateUrl: function() {
.replace($('base').attr('href'), ''); return window.history.state.path
}, .replace(/\?.*/, '')
.replace(/#.*/, '')
showLoginDialog: function() { .replace($('base').attr('href'), '');
var tempid = $('body').data('member-tempid'), },
dialog = $('.leftandmain-logindialog'),
url = 'CMSSecurity/login'; showLoginDialog: function() {
var tempid = $('body').data('member-tempid'),
// Force regeneration of any existing dialog dialog = $('.leftandmain-logindialog'),
if(dialog.length) dialog.remove(); url = 'CMSSecurity/login';
// Join url params // Force regeneration of any existing dialog
url = $.path.addSearchParams(url, { if(dialog.length) dialog.remove();
'tempid': tempid,
'BackURL': window.location.href // Join url params
}); url = $.path.addSearchParams(url, {
'tempid': tempid,
// Show a placeholder for instant feedback. Will be replaced with actual 'BackURL': window.location.href
// form dialog once its loaded. });
dialog = $('<div class="leftandmain-logindialog"></div>');
dialog.attr('id', new Date().getTime()); // Show a placeholder for instant feedback. Will be replaced with actual
dialog.data('url', url); // form dialog once its loaded.
$('body').append(dialog); dialog = $('<div class="leftandmain-logindialog"></div>');
} dialog.attr('id', new Date().getTime());
}); dialog.data('url', url);
$('body').append(dialog);
// Login dialog page }
$('.leftandmain-logindialog').entwine({ });
onmatch: function() {
this._super(); // Login dialog page
$('.leftandmain-logindialog').entwine({
// Create jQuery dialog onmatch: function() {
this.ssdialog({ this._super();
iframeUrl: this.data('url'),
dialogClass: "leftandmain-logindialog-dialog", // Create jQuery dialog
autoOpen: true, this.ssdialog({
minWidth: 500, iframeUrl: this.data('url'),
maxWidth: 500, dialogClass: "leftandmain-logindialog-dialog",
minHeight: 370, autoOpen: true,
maxHeight: 400, minWidth: 500,
closeOnEscape: false, maxWidth: 500,
open: function() { minHeight: 370,
$('.ui-widget-overlay').addClass('leftandmain-logindialog-overlay'); maxHeight: 400,
}, closeOnEscape: false,
close: function() { open: function() {
$('.ui-widget-overlay').removeClass('leftandmain-logindialog-overlay'); $('.ui-widget-overlay').addClass('leftandmain-logindialog-overlay');
} },
}); close: function() {
}, $('.ui-widget-overlay').removeClass('leftandmain-logindialog-overlay');
onunmatch: function() { }
this._super(); });
}, },
open: function() { onunmatch: function() {
this.ssdialog('open'); this._super();
}, },
close: function() { open: function() {
this.ssdialog('close'); this.ssdialog('open');
}, },
toggle: function(bool) { close: function() {
if(this.is(':visible')) this.close(); this.ssdialog('close');
else this.open(); },
}, toggle: function(bool) {
/** if(this.is(':visible')) this.close();
* Callback activated by CMSSecurity_success.ss else this.open();
*/ },
reauthenticate: function(data) { /**
// Replace all SecurityID fields with the given value * Callback activated by CMSSecurity_success.ss
if(typeof(data.SecurityID) !== 'undefined') { */
$(':input[name=SecurityID]').val(data.SecurityID); reauthenticate: function(data) {
} // Replace all SecurityID fields with the given value
// Update TempID for current user if(typeof(data.SecurityID) !== 'undefined') {
if(typeof(data.TempID) !== 'undefined') { $(':input[name=SecurityID]').val(data.SecurityID);
$('body').data('member-tempid', data.TempID); }
} // Update TempID for current user
this.close(); if(typeof(data.TempID) !== 'undefined') {
} $('body').data('member-tempid', data.TempID);
}); }
this.close();
/** }
* Add loading overlay to selected regions in the CMS automatically. });
* Not applied to all "*.loading" elements to avoid secondary regions
* like the breadcrumbs showing unnecessary loading status. /**
*/ * Add loading overlay to selected regions in the CMS automatically.
$('form.loading,.cms-content.loading,.cms-content-fields.loading,.cms-content-view.loading').entwine({ * Not applied to all "*.loading" elements to avoid secondary regions
onmatch: function() { * like the breadcrumbs showing unnecessary loading status.
this.append('<div class="cms-content-loading-overlay ui-widget-overlay-light"></div><div class="cms-content-loading-spinner"></div>'); */
this._super(); $('form.loading,.cms-content.loading,.cms-content-fields.loading,.cms-content-view.loading').entwine({
}, onmatch: function() {
onunmatch: function() { this.append('<div class="cms-content-loading-overlay ui-widget-overlay-light"></div><div class="cms-content-loading-spinner"></div>');
this.find('.cms-content-loading-overlay,.cms-content-loading-spinner').remove(); this._super();
this._super(); },
} onunmatch: function() {
}); this.find('.cms-content-loading-overlay,.cms-content-loading-spinner').remove();
this._super();
/** Make all buttons "hoverable" with jQuery theming. */ }
$('.cms input[type="submit"], .cms button, .cms input[type="reset"], .cms .ss-ui-button').entwine({ });
onadd: function() {
this.addClass('ss-ui-button'); /** Make all buttons "hoverable" with jQuery theming. */
if(!this.data('button')) this.button(); $('.cms input[type="submit"], .cms button, .cms input[type="reset"], .cms .ss-ui-button').entwine({
this._super(); onadd: function() {
}, this.addClass('ss-ui-button');
onremove: function() { if(!this.data('button')) this.button();
if(this.data('button')) this.button('destroy'); this._super();
this._super(); },
} onremove: function() {
}); if(this.data('button')) this.button('destroy');
this._super();
/** }
* Loads the link's 'href' attribute into a panel via ajax, });
* as opposed to triggering a full page reload.
* Little helper to avoid repetition, and make it easy to /**
* "opt in" to panel loading, while by default links still exhibit their default behaviour. * Loads the link's 'href' attribute into a panel via ajax,
* The PJAX target can be specified via a 'data-pjax-target' attribute. * as opposed to triggering a full page reload.
*/ * Little helper to avoid repetition, and make it easy to
$('.cms .cms-panel-link').entwine({ * "opt in" to panel loading, while by default links still exhibit their default behaviour.
onclick: function(e) { * The PJAX target can be specified via a 'data-pjax-target' attribute.
if($(this).hasClass('external-link')) { */
e.stopPropagation(); $('.cms .cms-panel-link').entwine({
onclick: function(e) {
return; if($(this).hasClass('external-link')) {
} e.stopPropagation();
var href = this.attr('href'), return;
url = (href && !href.match(/^#/)) ? href : this.data('href'), }
data = {pjax: this.data('pjaxTarget')};
var href = this.attr('href'),
$('.cms-container').loadPanel(url, null, data); url = (href && !href.match(/^#/)) ? href : this.data('href'),
e.preventDefault(); data = {pjax: this.data('pjaxTarget')};
}
}); $('.cms-container').loadPanel(url, null, data);
e.preventDefault();
/** }
* Does an ajax loads of the link's 'href' attribute via ajax and displays any FormResponse messages from the CMS. });
* Little helper to avoid repetition, and make it easy to trigger actions via a link,
* without reloading the page, changing the URL, or loading in any new panel content. /**
*/ * Does an ajax loads of the link's 'href' attribute via ajax and displays any FormResponse messages from the CMS.
$('.cms .ss-ui-button-ajax').entwine({ * Little helper to avoid repetition, and make it easy to trigger actions via a link,
onclick: function(e) { * without reloading the page, changing the URL, or loading in any new panel content.
$(this).removeClass('ui-button-text-only'); */
$(this).addClass('ss-ui-button-loading ui-button-text-icons'); $('.cms .ss-ui-button-ajax').entwine({
onclick: function(e) {
var loading = $(this).find(".ss-ui-loading-icon"); $(this).removeClass('ui-button-text-only');
$(this).addClass('ss-ui-button-loading ui-button-text-icons');
if(loading.length < 1) {
loading = $("<span></span>").addClass('ss-ui-loading-icon ui-button-icon-primary ui-icon'); var loading = $(this).find(".ss-ui-loading-icon");
$(this).prepend(loading); if(loading.length < 1) {
} loading = $("<span></span>").addClass('ss-ui-loading-icon ui-button-icon-primary ui-icon');
loading.show(); $(this).prepend(loading);
}
var href = this.attr('href'), url = href ? href : this.data('href');
loading.show();
jQuery.ajax({
url: url, var href = this.attr('href'), url = href ? href : this.data('href');
// Ensure that form view is loaded (rather than whole "Content" template)
complete: function(xmlhttp, status) { jQuery.ajax({
var msg = (xmlhttp.getResponseHeader('X-Status')) ? xmlhttp.getResponseHeader('X-Status') : xmlhttp.responseText; url: url,
// Ensure that form view is loaded (rather than whole "Content" template)
try { complete: function(xmlhttp, status) {
if (typeof msg != "undefined" && msg !== null) eval(msg); var msg = (xmlhttp.getResponseHeader('X-Status')) ? xmlhttp.getResponseHeader('X-Status') : xmlhttp.responseText;
}
catch(e) {} try {
if (typeof msg != "undefined" && msg !== null) eval(msg);
loading.hide(); }
catch(e) {}
$(".cms-container").refresh();
loading.hide();
$(this).removeClass('ss-ui-button-loading ui-button-text-icons');
$(this).addClass('ui-button-text-only'); $(".cms-container").refresh();
},
dataType: 'html' $(this).removeClass('ss-ui-button-loading ui-button-text-icons');
}); $(this).addClass('ui-button-text-only');
e.preventDefault(); },
} dataType: 'html'
}); });
e.preventDefault();
/** }
* Trigger dialogs with iframe based on the links href attribute (see ssui-core.js). });
*/
$('.cms .ss-ui-dialog-link').entwine({ /**
UUID: null, * Trigger dialogs with iframe based on the links href attribute (see ssui-core.js).
onmatch: function() { */
this._super(); $('.cms .ss-ui-dialog-link').entwine({
this.setUUID(new Date().getTime()); UUID: null,
}, onmatch: function() {
onunmatch: function() { this._super();
this._super(); this.setUUID(new Date().getTime());
}, },
onclick: function() { onunmatch: function() {
this._super(); this._super();
},
var self = this, id = 'ss-ui-dialog-' + this.getUUID(); onclick: function() {
var dialog = $('#' + id); this._super();
if(!dialog.length) {
dialog = $('<div class="ss-ui-dialog" id="' + id + '" />'); var self = this, id = 'ss-ui-dialog-' + this.getUUID();
$('body').append(dialog); var dialog = $('#' + id);
} if(!dialog.length) {
dialog = $('<div class="ss-ui-dialog" id="' + id + '" />');
var extraClass = this.data('popupclass')?this.data('popupclass'):''; $('body').append(dialog);
}
dialog.ssdialog({iframeUrl: this.attr('href'), autoOpen: true, dialogExtraClass: extraClass});
return false; var extraClass = this.data('popupclass')?this.data('popupclass'):'';
}
}); dialog.ssdialog({iframeUrl: this.attr('href'), autoOpen: true, dialogExtraClass: extraClass});
return false;
/** }
* Add styling to all contained buttons, and create buttonsets if required. });
*/
$('.cms-content .Actions').entwine({ /**
onmatch: function() { * Add styling to all contained buttons, and create buttonsets if required.
this.find('.ss-ui-button').click(function() { */
var form = this.form; $('.cms-content .Actions').entwine({
onmatch: function() {
// forms don't natively store the button they've been triggered with this.find('.ss-ui-button').click(function() {
if(form) { var form = this.form;
form.clickedButton = this;
// Reset the clicked button shortly after the onsubmit handlers // forms don't natively store the button they've been triggered with
// have fired on the form if(form) {
setTimeout(function() { form.clickedButton = this;
form.clickedButton = null; // Reset the clicked button shortly after the onsubmit handlers
}, 10); // have fired on the form
} setTimeout(function() {
}); form.clickedButton = null;
}, 10);
this.redraw(); }
this._super(); });
},
onunmatch: function() { this.redraw();
this._super(); this._super();
}, },
redraw: function() { onunmatch: function() {
if(window.debug) console.log('redraw', this.attr('class'), this.get(0)); this._super();
},
// Remove whitespace to avoid gaps with inline elements redraw: function() {
this.contents().filter(function() { if(window.debug) console.log('redraw', this.attr('class'), this.get(0));
return (this.nodeType == 3 && !/\S/.test(this.nodeValue));
}).remove(); // Remove whitespace to avoid gaps with inline elements
this.contents().filter(function() {
// Init buttons if required return (this.nodeType == 3 && !/\S/.test(this.nodeValue));
this.find('.ss-ui-button').each(function() { }).remove();
if(!$(this).data('button')) $(this).button();
}); // Init buttons if required
this.find('.ss-ui-button').each(function() {
// Mark up buttonsets if(!$(this).data('button')) $(this).button();
this.find('.ss-ui-buttonset').buttonset(); });
}
}); // Mark up buttonsets
this.find('.ss-ui-buttonset').buttonset();
/** }
* Duplicates functionality in DateField.js, but due to using entwine we can match });
* the DOM element on creation, rather than onclick - which allows us to decorate
* the field with a calendar icon /**
*/ * Duplicates functionality in DateField.js, but due to using entwine we can match
$('.cms .field.date input.text').entwine({ * the DOM element on creation, rather than onclick - which allows us to decorate
onmatch: function() { * the field with a calendar icon
var holder = $(this).parents('.field.date:first'), config = holder.data(); */
if(!config.showcalendar) { $('.cms .field.date input.text').entwine({
this._super(); onmatch: function() {
return; var holder = $(this).parents('.field.date:first'), config = holder.data();
} if(!config.showcalendar) {
this._super();
config.showOn = 'button'; return;
if(config.locale && $.datepicker.regional[config.locale]) { }
config = $.extend(config, $.datepicker.regional[config.locale], {});
} config.showOn = 'button';
if(config.locale && $.datepicker.regional[config.locale]) {
$(this).datepicker(config); config = $.extend(config, $.datepicker.regional[config.locale], {});
// // Unfortunately jQuery UI only allows configuration of icon images, not sprites }
// this.next('button').button('option', 'icons', {primary : 'ui-icon-calendar'});
$(this).datepicker(config);
this._super(); // // Unfortunately jQuery UI only allows configuration of icon images, not sprites
}, // this.next('button').button('option', 'icons', {primary : 'ui-icon-calendar'});
onunmatch: function() {
this._super(); this._super();
} },
}); onunmatch: function() {
this._super();
/** }
* Styled dropdown select fields via chosen. Allows things like search and optgroup });
* selection support. Rather than manually adding classes to selects we want
* styled, we style everything but the ones we tell it not to. /**
* * Styled dropdown select fields via chosen. Allows things like search and optgroup
* For the CMS we also need to tell the parent div that it has a select so * selection support. Rather than manually adding classes to selects we want
* we can fix the height cropping. * styled, we style everything but the ones we tell it not to.
*/ *
$('.cms .field.dropdown select, .cms .field select[multiple], .fieldholder-small select.dropdown').entwine({ * For the CMS we also need to tell the parent div that it has a select so
onmatch: function() { * we can fix the height cropping.
if(this.is('.no-chosen')) { */
this._super(); $('.cms .field.dropdown select, .cms .field select[multiple], .fieldholder-small select.dropdown').entwine({
return; onmatch: function() {
} if(this.is('.no-chosen')) {
this._super();
// Explicitly disable default placeholder if no custom one is defined return;
if(!this.data('placeholder')) this.data('placeholder', ' '); }
// We could've gotten stale classes and DOM elements from deferred cache. // Explicitly disable default placeholder if no custom one is defined
this.removeClass('has-chosen').chosen("destroy"); if(!this.data('placeholder')) this.data('placeholder', ' ');
this.siblings('.chosen-container').remove();
// We could've gotten stale classes and DOM elements from deferred cache.
// Apply Chosen this.removeClass('has-chosen').chosen("destroy");
applyChosen(this); this.siblings('.chosen-container').remove();
this._super(); // Apply Chosen
}, applyChosen(this);
onunmatch: function() {
this._super(); this._super();
} },
}); onunmatch: function() {
this._super();
$(".cms-panel-layout").entwine({ }
redraw: function() { });
if(window.debug) console.log('redraw', this.attr('class'), this.get(0));
} $(".cms-panel-layout").entwine({
}); redraw: function() {
if(window.debug) console.log('redraw', this.attr('class'), this.get(0));
/** }
* Overload the default GridField behaviour (open a new URL in the browser) });
* with the CMS-specific ajax loading.
*/ /**
$('.cms .ss-gridfield').entwine({ * Overload the default GridField behaviour (open a new URL in the browser)
showDetailView: function(url) { * with the CMS-specific ajax loading.
// Include any GET parameters from the current URL, as the view state might depend on it. */
// For example, a list prefiltered through external search criteria might be passed to GridField. $('.cms .ss-gridfield').entwine({
var params = window.location.search.replace(/^\?/, ''); showDetailView: function(url) {
if(params) url = $.path.addSearchParams(url, params); // Include any GET parameters from the current URL, as the view state might depend on it.
$('.cms-container').loadPanel(url); // For example, a list prefiltered through external search criteria might be passed to GridField.
} var params = window.location.search.replace(/^\?/, '');
}); if(params) url = $.path.addSearchParams(url, params);
$('.cms-container').loadPanel(url);
}
/** });
* Generic search form in the CMS, often hooked up to a GridField results display.
*/
$('.cms-search-form').entwine({ /**
onsubmit: function(e) { * Generic search form in the CMS, often hooked up to a GridField results display.
// Remove empty elements and make the URL prettier */
var nonEmptyInputs, $('.cms-search-form').entwine({
url; onsubmit: function(e) {
// Remove empty elements and make the URL prettier
nonEmptyInputs = this.find(':input:not(:submit)').filter(function() { var nonEmptyInputs,
// Use fieldValue() from jQuery.form plugin rather than jQuery.val(), url;
// as it handles checkbox values more consistently
var vals = $.grep($(this).fieldValue(), function(val) { return (val);}); nonEmptyInputs = this.find(':input:not(:submit)').filter(function() {
return (vals.length); // Use fieldValue() from jQuery.form plugin rather than jQuery.val(),
}); // as it handles checkbox values more consistently
var vals = $.grep($(this).fieldValue(), function(val) { return (val);});
url = this.attr('action'); return (vals.length);
});
if(nonEmptyInputs.length) {
url = $.path.addSearchParams( url = this.attr('action');
url,
// Undo jQuery's non-standard serialisation if(nonEmptyInputs.length) {
// See https://github.com/jquery/jquery/blob/1.7.2/src/ajax.js#L797 url = $.path.addSearchParams(
nonEmptyInputs.serialize().replace('+', '%20') url,
); // Undo jQuery's non-standard serialisation
} // See https://github.com/jquery/jquery/blob/1.7.2/src/ajax.js#L797
nonEmptyInputs.serialize().replace('+', '%20')
var container = this.closest('.cms-container'); );
container.find('.cms-edit-form').tabs('select',0); //always switch to the first tab (list view) when searching }
container.loadPanel(url, "", {}, true);
var container = this.closest('.cms-container');
return false; container.find('.cms-edit-form').tabs('select',0); //always switch to the first tab (list view) when searching
} container.loadPanel(url, "", {}, true);
});
return false;
/** }
* Reset button handler. IE8 does not bubble reset events to });
*/
$(".cms-search-form button[type=reset], .cms-search-form input[type=reset]").entwine({ /**
onclick: function(e) { * Reset button handler. IE8 does not bubble reset events to
e.preventDefault(); */
$(".cms-search-form button[type=reset], .cms-search-form input[type=reset]").entwine({
var form = $(this).parents('form'); onclick: function(e) {
e.preventDefault();
form.clearForm();
form.find(".dropdown select").prop('selectedIndex', 0).trigger("chosen:updated"); // Reset chosen.js var form = $(this).parents('form');
form.submit();
} form.clearForm();
}); form.find(".dropdown select").prop('selectedIndex', 0).trigger("chosen:updated"); // Reset chosen.js
form.submit();
/** }
* Allows to lazy load a panel, by leaving it empty });
* and declaring a URL to load its content via a 'url' HTML5 data attribute.
* The loaded HTML is cached, with cache key being the 'url' attribute. /**
* In order for this to work consistently, we assume that the responses are stateless. * Allows to lazy load a panel, by leaving it empty
* To avoid caching, add a 'deferred-no-cache' to the node. * and declaring a URL to load its content via a 'url' HTML5 data attribute.
*/ * The loaded HTML is cached, with cache key being the 'url' attribute.
window._panelDeferredCache = {}; * In order for this to work consistently, we assume that the responses are stateless.
$('.cms-panel-deferred').entwine({ * To avoid caching, add a 'deferred-no-cache' to the node.
onadd: function() { */
this._super(); window._panelDeferredCache = {};
this.redraw(); $('.cms-panel-deferred').entwine({
}, onadd: function() {
onremove: function() { this._super();
if(window.debug) console.log('saving', this.data('url'), this); this.redraw();
},
// Save the HTML state at the last possible moment. onremove: function() {
// Don't store the DOM to avoid memory leaks. if(window.debug) console.log('saving', this.data('url'), this);
if(!this.data('deferredNoCache')) window._panelDeferredCache[this.data('url')] = this.html();
this._super(); // Save the HTML state at the last possible moment.
}, // Don't store the DOM to avoid memory leaks.
redraw: function() { if(!this.data('deferredNoCache')) window._panelDeferredCache[this.data('url')] = this.html();
if(window.debug) console.log('redraw', this.attr('class'), this.get(0)); this._super();
},
var self = this, url = this.data('url'); redraw: function() {
if(!url) throw 'Elements of class .cms-panel-deferred need a "data-url" attribute'; if(window.debug) console.log('redraw', this.attr('class'), this.get(0));
this._super(); var self = this, url = this.data('url');
if(!url) throw 'Elements of class .cms-panel-deferred need a "data-url" attribute';
// If the node is empty, try to either load it from cache or via ajax.
if(!this.children().length) { this._super();
if(!this.data('deferredNoCache') && typeof window._panelDeferredCache[url] !== 'undefined') {
this.html(window._panelDeferredCache[url]); // If the node is empty, try to either load it from cache or via ajax.
} else { if(!this.children().length) {
this.addClass('loading'); if(!this.data('deferredNoCache') && typeof window._panelDeferredCache[url] !== 'undefined') {
$.ajax({ this.html(window._panelDeferredCache[url]);
url: url, } else {
complete: function() { this.addClass('loading');
self.removeClass('loading'); $.ajax({
}, url: url,
success: function(data, status, xhr) { complete: function() {
self.html(data); self.removeClass('loading');
} },
}); success: function(data, status, xhr) {
} self.html(data);
} }
} });
}); }
}
/** }
* Lightweight wrapper around jQuery UI tabs. });
* Ensures that anchor links are set properly,
* and any nested tabs are scrolled if they have /**
* their height explicitly set. This is important * Lightweight wrapper around jQuery UI tabs.
* for forms inside the CMS layout. * Ensures that anchor links are set properly,
*/ * and any nested tabs are scrolled if they have
$('.cms-tabset').entwine({ * their height explicitly set. This is important
onadd: function() { * for forms inside the CMS layout.
// Can't name redraw() as it clashes with other CMS entwine classes */
this.redrawTabs(); $('.cms-tabset').entwine({
this._super(); onadd: function() {
}, // Can't name redraw() as it clashes with other CMS entwine classes
onremove: function() { this.redrawTabs();
if (this.data('tabs')) this.tabs('destroy'); this._super();
this._super(); },
}, onremove: function() {
redrawTabs: function() { if (this.data('tabs')) this.tabs('destroy');
this.rewriteHashlinks(); this._super();
},
var id = this.attr('id'), activeTab = this.find('ul:first .ui-tabs-active'); redrawTabs: function() {
this.rewriteHashlinks();
if(!this.data('uiTabs')) this.tabs({
active: (activeTab.index() != -1) ? activeTab.index() : 0, var id = this.attr('id'), activeTab = this.find('ul:first .ui-tabs-active');
beforeLoad: function(e, ui) {
// Disable automatic ajax loading of tabs without matching DOM elements, if(!this.data('uiTabs')) this.tabs({
// determining if the current URL differs from the tab URL is too error prone. active: (activeTab.index() != -1) ? activeTab.index() : 0,
return false; beforeLoad: function(e, ui) {
}, // Disable automatic ajax loading of tabs without matching DOM elements,
activate: function(e, ui) { // determining if the current URL differs from the tab URL is too error prone.
// Usability: Hide actions for "readonly" tabs (which don't contain any editable fields) return false;
var actions = $(this).closest('form').find('.Actions'); },
if($(ui.newTab).closest('li').hasClass('readonly')) { activate: function(e, ui) {
actions.fadeOut(); // Usability: Hide actions for "readonly" tabs (which don't contain any editable fields)
} else { var actions = $(this).closest('form').find('.Actions');
actions.show(); if($(ui.newTab).closest('li').hasClass('readonly')) {
} actions.fadeOut();
} } else {
}); actions.show();
}, }
}
/** });
* Ensure hash links are prefixed with the current page URL, },
* otherwise jQuery interprets them as being external.
*/ /**
rewriteHashlinks: function() { * Ensure hash links are prefixed with the current page URL,
$(this).find('ul a').each(function() { * otherwise jQuery interprets them as being external.
if (!$(this).attr('href')) return; */
var matches = $(this).attr('href').match(/#.*/); rewriteHashlinks: function() {
if(!matches) return; $(this).find('ul a').each(function() {
$(this).attr('href', document.location.href.replace(/#.*/, '') + matches[0]); if (!$(this).attr('href')) return;
}); var matches = $(this).attr('href').match(/#.*/);
} if(!matches) return;
}); $(this).attr('href', document.location.href.replace(/#.*/, '') + matches[0]);
});
/** }
* CMS content filters });
*/
$('#filters-button').entwine({ /**
onmatch: function () { * CMS content filters
this._super(); */
$('#filters-button').entwine({
this.data('collapsed', true); // The current collapsed state of the element. onmatch: function () {
this.data('animating', false); // True if the element is currently animating. this._super();
},
onunmatch: function () { this.data('collapsed', true); // The current collapsed state of the element.
this._super(); this.data('animating', false); // True if the element is currently animating.
}, },
showHide: function () { onunmatch: function () {
var self = this, this._super();
$filters = $('.cms-content-filters').first(), },
collapsed = this.data('collapsed'); showHide: function () {
var self = this,
// Prevent the user from spamming the UI with animation requests. $filters = $('.cms-content-filters').first(),
if (this.data('animating')) { collapsed = this.data('collapsed');
return;
} // Prevent the user from spamming the UI with animation requests.
if (this.data('animating')) {
this.toggleClass('active'); return;
this.data('animating', true); }
// Slide the element down / up based on it's current collapsed state. this.toggleClass('active');
$filters[collapsed ? 'slideDown' : 'slideUp']({ this.data('animating', true);
complete: function () {
// Update the element's state. // Slide the element down / up based on it's current collapsed state.
self.data('collapsed', !collapsed); $filters[collapsed ? 'slideDown' : 'slideUp']({
self.data('animating', false); complete: function () {
} // Update the element's state.
}); self.data('collapsed', !collapsed);
}, self.data('animating', false);
onclick: function () { }
this.showHide(); });
} },
}); onclick: function () {
this.showHide();
}
});
}); });
var statusMessage = function(text, type) { var statusMessage = function(text, type) {
text = jQuery('<div/>').text(text).html(); // Escape HTML entities in text text = jQuery('<div/>').text(text).html(); // Escape HTML entities in text
jQuery.noticeAdd({text: text, type: type, stayTime: 5000, inEffect: {left: '0', opacity: 'show'}}); jQuery.noticeAdd({text: text, type: type, stayTime: 5000, inEffect: {left: '0', opacity: 'show'}});
}; };
var errorMessage = function(text) { var errorMessage = function(text) {
jQuery.noticeAdd({text: text, type: 'error', stayTime: 5000, inEffect: {left: '0', opacity: 'show'}}); jQuery.noticeAdd({text: text, type: 'error', stayTime: 5000, inEffect: {left: '0', opacity: 'show'}});
}; };