2011-04-28 12:36:28 +02:00
|
|
|
(function($) {
|
2015-09-07 00:49:37 +02:00
|
|
|
|
2012-11-29 05:41:48 +01:00
|
|
|
$.entwine('ss.preview', function($){
|
2011-05-15 05:43:21 +02:00
|
|
|
|
2011-07-15 10:35:41 +02:00
|
|
|
/**
|
2012-12-03 22:16:58 +01:00
|
|
|
* Shows a previewable website state alongside its editable version in backend UI.
|
2011-12-17 04:06:56 +01:00
|
|
|
*
|
2016-01-06 00:34:58 +01:00
|
|
|
* Relies on the server responses to indicate if a preview is available for the
|
2012-12-03 22:16:58 +01:00
|
|
|
* currently loaded admin interface - signified by class ".cms-previewable" being present.
|
|
|
|
*
|
2016-01-06 00:34:58 +01:00
|
|
|
* The preview options at the bottom are constructured by grabbing a SilverStripeNavigator
|
2012-12-03 22:16:58 +01:00
|
|
|
* structure also provided by the backend.
|
2011-07-15 10:35:41 +02:00
|
|
|
*/
|
2011-07-05 14:34:31 +02:00
|
|
|
$('.cms-preview').entwine({
|
2012-11-29 05:41:48 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* List of SilverStripeNavigator states (SilverStripeNavigatorItem classes) to search for.
|
|
|
|
* The order is significant - if the state is not available, preview will start searching the list
|
|
|
|
* from the beginning.
|
|
|
|
*/
|
2013-01-25 11:33:48 +01:00
|
|
|
AllowedStates: ['StageLink', 'LiveLink','ArchiveLink'],
|
2012-11-29 05:41:48 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* API
|
|
|
|
* Name of the current preview state - one of the "AllowedStates".
|
|
|
|
*/
|
|
|
|
CurrentStateName: null,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* API
|
|
|
|
* Current size selection.
|
|
|
|
*/
|
|
|
|
CurrentSizeName: 'auto',
|
|
|
|
|
2012-12-03 22:16:58 +01:00
|
|
|
/**
|
|
|
|
* Flags whether the preview is available on this CMS section.
|
|
|
|
*/
|
|
|
|
IsPreviewEnabled: false,
|
|
|
|
|
2013-01-15 16:36:53 +01:00
|
|
|
/**
|
|
|
|
* Mode in which the preview will be enabled.
|
|
|
|
*/
|
|
|
|
DefaultMode: 'split',
|
|
|
|
|
|
|
|
Sizes: {
|
2013-02-04 13:42:28 +01:00
|
|
|
auto: {
|
|
|
|
width: '100%',
|
|
|
|
height: '100%'
|
|
|
|
},
|
2013-01-15 16:36:53 +01:00
|
|
|
mobile: {
|
2016-01-06 00:34:58 +01:00
|
|
|
width: '335px', // add 15px for approx desktop scrollbar
|
|
|
|
height: '568px'
|
2013-01-15 16:36:53 +01:00
|
|
|
},
|
|
|
|
mobileLandscape: {
|
|
|
|
width: '583px', // add 15px for approx desktop scrollbar
|
|
|
|
height: '320px'
|
|
|
|
},
|
|
|
|
tablet: {
|
|
|
|
width: '783px', // add 15px for approx desktop scrollbar
|
|
|
|
height: '1024px'
|
|
|
|
},
|
|
|
|
tabletLandscape: {
|
|
|
|
width: '1039px', // add 15px for approx desktop scrollbar
|
|
|
|
height: '768px'
|
|
|
|
},
|
|
|
|
desktop: {
|
|
|
|
width: '1024px',
|
|
|
|
height: '800px'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2012-11-29 05:41:48 +01:00
|
|
|
/**
|
|
|
|
* API
|
|
|
|
* Switch the preview to different state.
|
|
|
|
* stateName can be one of the "AllowedStates".
|
2013-02-01 00:21:50 +01:00
|
|
|
*
|
|
|
|
* @param {String}
|
|
|
|
* @param {Boolean} Set to FALSE to avoid persisting the state
|
2012-11-29 05:41:48 +01:00
|
|
|
*/
|
2016-01-06 00:34:58 +01:00
|
|
|
changeState: function(stateName, save) {
|
2013-02-01 00:21:50 +01:00
|
|
|
var self = this, states = this._getNavigatorStates();
|
|
|
|
if(save !== false) {
|
|
|
|
$.each(states, function(index, state) {
|
|
|
|
self.saveState('state', stateName);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2012-11-29 05:41:48 +01:00
|
|
|
this.setCurrentStateName(stateName);
|
2012-12-03 22:16:58 +01:00
|
|
|
this._loadCurrentState();
|
2012-11-29 05:41:48 +01:00
|
|
|
this.redraw();
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* API
|
|
|
|
* Change the preview mode.
|
|
|
|
* modeName can be: split, content, preview.
|
|
|
|
*/
|
2016-01-06 00:34:58 +01:00
|
|
|
changeMode: function(modeName, save) {
|
2012-11-29 05:41:48 +01:00
|
|
|
var container = $('.cms-container');
|
|
|
|
|
2013-02-05 10:23:48 +01:00
|
|
|
if (modeName == 'split') {
|
2012-11-29 05:41:48 +01:00
|
|
|
container.entwine('.ss').splitViewMode();
|
2013-02-05 10:23:48 +01:00
|
|
|
this.setIsPreviewEnabled(true);
|
|
|
|
this._loadCurrentState();
|
|
|
|
} else if (modeName == 'content') {
|
2012-11-29 05:41:48 +01:00
|
|
|
container.entwine('.ss').contentViewMode();
|
2013-02-05 10:23:48 +01:00
|
|
|
this.setIsPreviewEnabled(false);
|
2013-06-13 01:31:57 +02:00
|
|
|
// Do not load content as the preview is not visible.
|
2013-02-05 10:23:48 +01:00
|
|
|
} else if (modeName == 'preview') {
|
2012-11-29 05:41:48 +01:00
|
|
|
container.entwine('.ss').previewMode();
|
2013-02-05 10:23:48 +01:00
|
|
|
this.setIsPreviewEnabled(true);
|
2013-06-13 01:31:57 +02:00
|
|
|
this._loadCurrentState();
|
2013-02-05 10:23:48 +01:00
|
|
|
} else {
|
|
|
|
throw 'Invalid mode: ' + modeName;
|
2012-11-29 05:41:48 +01:00
|
|
|
}
|
|
|
|
|
2013-02-01 00:21:50 +01:00
|
|
|
if(save !== false) this.saveState('mode', modeName);
|
|
|
|
|
2012-11-29 05:41:48 +01:00
|
|
|
this.redraw();
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* API
|
|
|
|
* Change the preview size.
|
|
|
|
* sizeName can be: auto, desktop, tablet, mobile.
|
|
|
|
*/
|
|
|
|
changeSize: function(sizeName) {
|
2013-01-15 16:36:53 +01:00
|
|
|
var sizes = this.getSizes();
|
2012-11-29 05:41:48 +01:00
|
|
|
|
2013-01-15 16:36:53 +01:00
|
|
|
this.setCurrentSizeName(sizeName);
|
|
|
|
this.removeClass('auto desktop tablet mobile').addClass(sizeName);
|
|
|
|
this.find('.preview-device-outer')
|
|
|
|
.width(sizes[sizeName].width)
|
|
|
|
.height(sizes[sizeName].height);
|
|
|
|
this.find('.preview-device-inner')
|
|
|
|
.width(sizes[sizeName].width);
|
2012-11-29 05:41:48 +01:00
|
|
|
|
2013-02-01 00:21:50 +01:00
|
|
|
this.saveState('size', sizeName);
|
|
|
|
|
2012-11-29 05:41:48 +01:00
|
|
|
this.redraw();
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* API
|
|
|
|
* Update the visual appearance to match the internal preview state.
|
|
|
|
*/
|
2016-01-06 00:34:58 +01:00
|
|
|
redraw: function() {
|
2012-12-03 03:17:16 +01:00
|
|
|
|
2012-11-29 05:41:48 +01:00
|
|
|
if(window.debug) console.log('redraw', this.attr('class'), this.get(0));
|
|
|
|
|
|
|
|
// Update preview state selector.
|
|
|
|
var currentStateName = this.getCurrentStateName();
|
|
|
|
if (currentStateName) {
|
|
|
|
this.find('.cms-preview-states').changeVisibleState(currentStateName);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update preview mode selectors.
|
|
|
|
var layoutOptions = $('.cms-container').entwine('.ss').getLayoutOptions();
|
|
|
|
if (layoutOptions) {
|
|
|
|
// There are two mode selectors that we need to keep in sync. Redraw both.
|
|
|
|
$('.preview-mode-selector').changeVisibleMode(layoutOptions.mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update preview size selector.
|
|
|
|
var currentSizeName = this.getCurrentSizeName();
|
|
|
|
if (currentSizeName) {
|
|
|
|
this.find('.preview-size-selector').changeVisibleSize(this.getCurrentSizeName());
|
|
|
|
}
|
2012-12-03 22:16:58 +01:00
|
|
|
|
|
|
|
return this;
|
2012-11-29 05:41:48 +01:00
|
|
|
},
|
|
|
|
|
2013-02-01 00:21:50 +01:00
|
|
|
/**
|
|
|
|
* Store the preview options for this page.
|
|
|
|
*/
|
|
|
|
saveState : function(name, value) {
|
2015-02-19 22:43:20 +01:00
|
|
|
if(this._supportsLocalStorage()) window.localStorage.setItem('cms-preview-state-' + name, value);
|
2013-02-01 00:21:50 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Load previously stored preferences
|
|
|
|
*/
|
|
|
|
loadState : function(name) {
|
2015-02-19 22:43:20 +01:00
|
|
|
if(this._supportsLocalStorage()) return window.localStorage.getItem('cms-preview-state-' + name);
|
2016-01-06 00:34:58 +01:00
|
|
|
},
|
2013-02-01 00:21:50 +01:00
|
|
|
|
2012-12-03 22:16:58 +01:00
|
|
|
/**
|
|
|
|
* Disable the area - it will not appear in the GUI.
|
|
|
|
* Caveat: the preview will be automatically enabled when ".cms-previewable" class is detected.
|
|
|
|
*/
|
|
|
|
disablePreview: function() {
|
2013-08-15 04:28:47 +02:00
|
|
|
this.setPendingURL(null);
|
2012-12-03 22:16:58 +01:00
|
|
|
this._loadUrl('about:blank');
|
|
|
|
this._block();
|
2013-02-01 00:21:50 +01:00
|
|
|
this.changeMode('content', false);
|
2012-12-03 22:16:58 +01:00
|
|
|
this.setIsPreviewEnabled(false);
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enable the area and start updating to reflect the content editing.
|
|
|
|
*/
|
|
|
|
enablePreview: function() {
|
2012-12-04 04:50:35 +01:00
|
|
|
if (!this.getIsPreviewEnabled()) {
|
|
|
|
this.setIsPreviewEnabled(true);
|
2012-12-04 06:10:20 +01:00
|
|
|
|
|
|
|
// Initialise mode.
|
|
|
|
if ($.browser.msie && $.browser.version.slice(0,3)<=7) {
|
|
|
|
// We do not support the split mode in IE < 8.
|
|
|
|
this.changeMode('content');
|
|
|
|
} else {
|
2013-02-01 00:21:50 +01:00
|
|
|
this.changeMode(this.getDefaultMode(), false);
|
2012-12-04 06:10:20 +01:00
|
|
|
}
|
2012-12-04 04:50:35 +01:00
|
|
|
}
|
2012-12-03 22:16:58 +01:00
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2013-08-22 04:30:00 +02:00
|
|
|
/**
|
|
|
|
* Return a style element we can use in IE8 to fix fonts (see readystatechange binding in onadd below)
|
|
|
|
*/
|
|
|
|
getOrAppendFontFixStyleElement: function() {
|
|
|
|
var style = $('#FontFixStyleElement');
|
|
|
|
if (!style.length) {
|
|
|
|
style = $(
|
|
|
|
'<style type="text/css" id="FontFixStyleElement" disabled="disabled">'+
|
|
|
|
':before,:after{content:none !important}'+
|
|
|
|
'</style>'
|
|
|
|
).appendTo('head');
|
|
|
|
}
|
|
|
|
|
|
|
|
return style;
|
|
|
|
},
|
|
|
|
|
2012-12-03 22:16:58 +01:00
|
|
|
/**
|
|
|
|
* Initialise the preview element.
|
|
|
|
*/
|
2012-06-14 23:44:22 +02:00
|
|
|
onadd: function() {
|
2013-08-22 04:30:00 +02:00
|
|
|
var self = this, layoutContainer = this.parent(), iframe = this.find('iframe');
|
2012-12-03 22:16:58 +01:00
|
|
|
|
2011-04-28 12:36:28 +02:00
|
|
|
// Create layout and controls
|
2013-08-22 04:30:00 +02:00
|
|
|
iframe.addClass('center');
|
|
|
|
iframe.bind('load', function() {
|
2012-12-03 22:16:58 +01:00
|
|
|
self._adjustIframeForPreview();
|
2011-12-19 15:06:04 +01:00
|
|
|
|
|
|
|
// Load edit view for new page, but only if the preview is activated at the moment.
|
|
|
|
// This avoids e.g. force-redirections of the edit view on RedirectorPage instances.
|
2012-11-29 05:41:48 +01:00
|
|
|
self._loadCurrentPage();
|
2016-01-06 00:34:58 +01:00
|
|
|
|
2012-12-10 17:47:31 +01:00
|
|
|
$(this).removeClass('loading');
|
2011-05-15 05:43:21 +02:00
|
|
|
});
|
2013-08-22 04:30:00 +02:00
|
|
|
|
|
|
|
// If there's any webfonts in the preview, IE8 will start glitching. This fixes that.
|
|
|
|
if ($.browser.msie && 8 === parseInt($.browser.version, 10)) {
|
|
|
|
iframe.bind('readystatechange', function(e) {
|
|
|
|
if(iframe[0].readyState == 'interactive') {
|
|
|
|
self.getOrAppendFontFixStyleElement().removeAttr('disabled');
|
|
|
|
setTimeout(function(){ self.getOrAppendFontFixStyleElement().attr('disabled', 'disabled'); }, 0);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2011-07-15 10:35:41 +02:00
|
|
|
// Preview might not be available in all admin interfaces - block/disable when necessary
|
2011-09-29 06:09:36 +02:00
|
|
|
this.append('<div class="cms-preview-overlay ui-widget-overlay-light"></div>');
|
2016-01-06 00:34:58 +01:00
|
|
|
this.find('.cms-preview-overlay').hide();
|
2011-12-12 21:30:16 +01:00
|
|
|
|
2012-12-03 22:16:58 +01:00
|
|
|
this.disablePreview();
|
2012-11-22 02:14:11 +01:00
|
|
|
|
2011-04-28 12:36:28 +02:00
|
|
|
this._super();
|
|
|
|
},
|
2016-01-06 00:34:58 +01:00
|
|
|
|
2015-02-19 22:43:20 +01:00
|
|
|
/**
|
|
|
|
* Detect and use localStorage if available. In IE11 windows 8.1 call to window.localStorage was throwing out an access denied error in some cases which was causing the preview window not to display correctly in the CMS admin area.
|
|
|
|
*/
|
|
|
|
_supportsLocalStorage: function() {
|
|
|
|
var uid = new Date;
|
|
|
|
var storage;
|
|
|
|
var result;
|
|
|
|
try {
|
|
|
|
(storage = window.localStorage).setItem(uid, uid);
|
|
|
|
result = storage.getItem(uid) == uid;
|
|
|
|
storage.removeItem(uid);
|
|
|
|
return result && storage;
|
|
|
|
} catch (exception) {
|
|
|
|
console.warn('localStorge is not available due to current browser / system settings.');
|
|
|
|
}
|
|
|
|
},
|
2012-11-22 02:14:11 +01:00
|
|
|
|
2015-09-07 00:49:37 +02:00
|
|
|
onenable: function () {
|
|
|
|
var $viewModeSelector = $('.preview-mode-selector');
|
|
|
|
|
|
|
|
$viewModeSelector.removeClass('split-disabled');
|
|
|
|
$viewModeSelector.find('.disabled-tooltip').hide();
|
|
|
|
},
|
|
|
|
|
|
|
|
ondisable: function () {
|
|
|
|
var $viewModeSelector = $('.preview-mode-selector');
|
|
|
|
|
|
|
|
$viewModeSelector.addClass('split-disabled');
|
|
|
|
$viewModeSelector.find('.disabled-tooltip').show();
|
|
|
|
},
|
|
|
|
|
2012-11-29 05:41:48 +01:00
|
|
|
/**
|
2012-12-03 22:16:58 +01:00
|
|
|
* Set the preview to unavailable - could be still visible. This is purely visual.
|
|
|
|
*/
|
|
|
|
_block: function() {
|
|
|
|
this.addClass('blocked');
|
2013-01-30 11:32:55 +01:00
|
|
|
this.find('.cms-preview-overlay').show();
|
2012-12-03 22:16:58 +01:00
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the preview to available (remove the overlay);
|
|
|
|
*/
|
|
|
|
_unblock: function() {
|
|
|
|
this.removeClass('blocked');
|
2013-01-30 11:32:55 +01:00
|
|
|
this.find('.cms-preview-overlay').hide();
|
2012-12-03 22:16:58 +01:00
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2012-12-04 06:10:20 +01:00
|
|
|
* Update the preview according to browser and CMS section capabilities.
|
2012-12-03 22:16:58 +01:00
|
|
|
*/
|
|
|
|
_initialiseFromContent: function() {
|
2013-02-05 10:23:48 +01:00
|
|
|
var mode, size;
|
|
|
|
|
2012-12-03 22:16:58 +01:00
|
|
|
if (!$('.cms-previewable').length) {
|
|
|
|
this.disablePreview();
|
|
|
|
} else {
|
2013-02-05 10:23:48 +01:00
|
|
|
mode = this.loadState('mode');
|
|
|
|
size = this.loadState('size');
|
|
|
|
|
2012-12-03 22:16:58 +01:00
|
|
|
this._moveNavigator();
|
2013-02-05 10:23:48 +01:00
|
|
|
if(!mode || mode != 'content') {
|
|
|
|
this.enablePreview();
|
|
|
|
this._loadCurrentState();
|
|
|
|
}
|
2012-12-04 04:50:35 +01:00
|
|
|
this.redraw();
|
2013-02-01 00:21:50 +01:00
|
|
|
|
|
|
|
// now check the cookie to see if we have any preview settings that have been
|
|
|
|
// retained for this page from the last visit
|
|
|
|
if(mode) this.changeMode(mode);
|
|
|
|
if(size) this.changeSize(size);
|
2012-12-03 22:16:58 +01:00
|
|
|
}
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update preview whenever any panels are reloaded.
|
|
|
|
*/
|
|
|
|
'from .cms-container': {
|
2014-12-05 02:02:50 +01:00
|
|
|
onafterstatechange: function(e, data) {
|
|
|
|
// Don't update preview if we're dealing with a custom redirect
|
|
|
|
if(data.xhr.getResponseHeader('X-ControllerURL')) return;
|
|
|
|
|
2012-12-03 22:16:58 +01:00
|
|
|
this._initialiseFromContent();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2013-08-15 04:28:47 +02:00
|
|
|
/** @var string A URL that should be displayed in this preview panel once it becomes visible */
|
|
|
|
PendingURL: null,
|
|
|
|
|
|
|
|
oncolumnvisibilitychanged: function() {
|
|
|
|
var url = this.getPendingURL();
|
|
|
|
if (url && !this.is('.column-hidden')) {
|
|
|
|
this.setPendingURL(null);
|
|
|
|
this._loadUrl(url);
|
|
|
|
this._unblock();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2012-12-03 22:16:58 +01:00
|
|
|
/**
|
|
|
|
* Update preview whenever a form is submitted.
|
|
|
|
* This is an alternative to the LeftAndmMain::loadPanel functionality which we already
|
|
|
|
* cover in the onafterstatechange handler.
|
|
|
|
*/
|
|
|
|
'from .cms-container .cms-edit-form': {
|
|
|
|
onaftersubmitform: function(){
|
|
|
|
this._initialiseFromContent();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2013-02-05 10:23:48 +01:00
|
|
|
* Change the URL of the preview iframe (if its not already displayed).
|
2012-11-29 05:41:48 +01:00
|
|
|
*/
|
|
|
|
_loadUrl: function(url) {
|
2013-02-08 00:04:18 +01:00
|
|
|
this.find('iframe').addClass('loading').attr('src', url);
|
2012-12-03 22:16:58 +01:00
|
|
|
return this;
|
2011-04-28 12:36:28 +02:00
|
|
|
},
|
2011-07-21 20:14:33 +02:00
|
|
|
|
2012-11-29 05:41:48 +01:00
|
|
|
/**
|
|
|
|
* Fetch available states from the current SilverStripeNavigator (SilverStripeNavigatorItems).
|
|
|
|
* Navigator is supplied by the backend and contains all state options for the current object.
|
|
|
|
*/
|
|
|
|
_getNavigatorStates: function() {
|
|
|
|
// Walk through available states and get the URLs.
|
|
|
|
var urlMap = $.map(this.getAllowedStates(), function(name) {
|
2012-12-03 03:17:16 +01:00
|
|
|
var stateLink = $('.cms-preview-states .state-name[data-name=' + name + ']');
|
2013-01-25 11:33:48 +01:00
|
|
|
if(stateLink.length) {
|
|
|
|
return {
|
2016-01-06 00:34:58 +01:00
|
|
|
name: name,
|
2013-01-25 11:33:48 +01:00
|
|
|
url: stateLink.attr('data-link'),
|
|
|
|
active: stateLink.is(':radio') ? stateLink.is(':checked') : stateLink.is(':selected')
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
2012-11-29 05:41:48 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
return urlMap;
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
2012-12-03 22:16:58 +01:00
|
|
|
* Load current state into the preview (e.g. StageLink or LiveLink).
|
|
|
|
* We try to reuse the state we have been previously in. Otherwise we fall back
|
|
|
|
* to the first state available on the "AllowedStates" list.
|
|
|
|
*
|
|
|
|
* @returns New state name.
|
2012-11-29 05:41:48 +01:00
|
|
|
*/
|
2012-12-03 22:16:58 +01:00
|
|
|
_loadCurrentState: function() {
|
|
|
|
if (!this.getIsPreviewEnabled()) return this;
|
|
|
|
|
2012-11-29 05:41:48 +01:00
|
|
|
var states = this._getNavigatorStates();
|
|
|
|
var currentStateName = this.getCurrentStateName();
|
|
|
|
var currentState = null;
|
|
|
|
|
|
|
|
// Find current state within currently available states.
|
|
|
|
if (states) {
|
|
|
|
currentState = $.grep(states, function(state, index) {
|
2013-01-25 11:33:48 +01:00
|
|
|
return (
|
|
|
|
currentStateName === state.name ||
|
|
|
|
(!currentStateName && state.active)
|
|
|
|
);
|
2012-11-29 05:41:48 +01:00
|
|
|
});
|
|
|
|
}
|
2012-11-22 02:14:11 +01:00
|
|
|
|
2013-08-15 04:28:47 +02:00
|
|
|
var url = null;
|
|
|
|
|
2012-11-29 05:41:48 +01:00
|
|
|
if (currentState[0]) {
|
2012-12-03 22:16:58 +01:00
|
|
|
// State is available on the newly loaded content. Get it.
|
2013-08-15 04:28:47 +02:00
|
|
|
url = currentState[0].url;
|
2012-11-29 05:41:48 +01:00
|
|
|
} else if (states.length) {
|
2012-12-03 22:16:58 +01:00
|
|
|
// Fall back to the first available content state.
|
2012-11-29 05:41:48 +01:00
|
|
|
this.setCurrentStateName(states[0].name);
|
2013-08-15 04:28:47 +02:00
|
|
|
url = states[0].url;
|
2012-06-12 12:48:08 +02:00
|
|
|
} else {
|
2012-12-03 22:16:58 +01:00
|
|
|
// No state available at all.
|
|
|
|
this.setCurrentStateName(null);
|
2013-08-15 04:28:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// If this preview panel isn't visible at the moment, delay loading the URL until it (maybe) is later
|
|
|
|
if (this.is('.column-hidden')) {
|
|
|
|
this.setPendingURL(url);
|
|
|
|
this._loadUrl('about:blank');
|
2012-11-29 05:41:48 +01:00
|
|
|
this._block();
|
2012-06-12 12:48:08 +02:00
|
|
|
}
|
2013-08-15 04:28:47 +02:00
|
|
|
else {
|
|
|
|
this.setPendingURL(null);
|
|
|
|
|
|
|
|
if (url) {
|
|
|
|
this._loadUrl(url);
|
|
|
|
this._unblock();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this._block();
|
|
|
|
}
|
|
|
|
}
|
2012-06-12 12:48:08 +02:00
|
|
|
|
2012-12-03 22:16:58 +01:00
|
|
|
return this;
|
2012-11-22 02:14:11 +01:00
|
|
|
},
|
|
|
|
|
2012-11-27 06:03:43 +01:00
|
|
|
/**
|
2012-12-03 22:16:58 +01:00
|
|
|
* Move the navigator from the content to the preview bar.
|
2012-11-27 06:03:43 +01:00
|
|
|
*/
|
2012-12-03 22:16:58 +01:00
|
|
|
_moveNavigator: function() {
|
|
|
|
var previewEl = $('.cms-preview .cms-preview-controls');
|
|
|
|
var navigatorEl = $('.cms-edit-form .cms-navigator');
|
2012-06-12 12:48:08 +02:00
|
|
|
|
2012-12-03 22:16:58 +01:00
|
|
|
if (navigatorEl.length && previewEl.length) {
|
|
|
|
// Navigator is available - install the navigator.
|
|
|
|
previewEl.html($('.cms-edit-form .cms-navigator').detach());
|
|
|
|
} else {
|
|
|
|
// Navigator not available.
|
|
|
|
this._block();
|
2012-11-27 06:03:43 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2011-07-21 20:14:33 +02:00
|
|
|
/**
|
|
|
|
* Loads the matching edit form for a page viewed in the preview iframe,
|
|
|
|
* based on metadata sent along with this document.
|
|
|
|
*/
|
2012-11-29 05:41:48 +01:00
|
|
|
_loadCurrentPage: function() {
|
2012-12-03 22:16:58 +01:00
|
|
|
if (!this.getIsPreviewEnabled()) return;
|
2011-05-15 05:43:21 +02:00
|
|
|
|
2012-12-03 22:16:58 +01:00
|
|
|
var doc = this.find('iframe')[0].contentDocument,
|
|
|
|
containerEl = $('.cms-container');
|
2011-05-15 05:43:21 +02:00
|
|
|
|
|
|
|
// Load this page in the admin interface if appropriate
|
2016-01-06 00:34:58 +01:00
|
|
|
var id = $(doc).find('meta[name=x-page-id]').attr('content');
|
2011-12-17 04:06:56 +01:00
|
|
|
var editLink = $(doc).find('meta[name=x-cms-edit-link]').attr('content');
|
|
|
|
var contentPanel = $('.cms-content');
|
2016-01-06 00:34:58 +01:00
|
|
|
|
2011-06-09 03:49:52 +02:00
|
|
|
if(id && contentPanel.find(':input[name=ID]').val() != id) {
|
2016-01-06 00:34:58 +01:00
|
|
|
// Ignore behaviour without history support (as we need ajax loading
|
2011-12-17 04:06:56 +01:00
|
|
|
// for the new form to load in the background)
|
2016-01-06 00:34:58 +01:00
|
|
|
if(window.History.enabled)
|
2012-11-29 05:41:48 +01:00
|
|
|
$('.cms-container').entwine('.ss').loadPanel(editLink);
|
2011-06-09 03:49:52 +02:00
|
|
|
}
|
2011-05-15 05:43:21 +02:00
|
|
|
},
|
2012-01-03 14:42:26 +01:00
|
|
|
|
|
|
|
/**
|
2012-12-03 22:16:58 +01:00
|
|
|
* Prepare the iframe content for preview.
|
2012-01-03 14:42:26 +01:00
|
|
|
*/
|
2012-12-03 22:16:58 +01:00
|
|
|
_adjustIframeForPreview: function() {
|
2012-11-22 02:14:11 +01:00
|
|
|
var iframe = this.find('iframe')[0];
|
|
|
|
if(iframe){
|
|
|
|
var doc = iframe.contentDocument;
|
|
|
|
}else{
|
|
|
|
return;
|
|
|
|
}
|
2016-01-06 00:34:58 +01:00
|
|
|
|
2012-04-10 21:08:31 +02:00
|
|
|
if(!doc) return;
|
2011-04-28 12:36:28 +02:00
|
|
|
|
2012-12-03 22:16:58 +01:00
|
|
|
// Open external links in new window to avoid "escaping" the internal page context in the preview
|
|
|
|
// iframe, which is important to stay in for the CMS logic.
|
2011-04-28 12:36:28 +02:00
|
|
|
var links = doc.getElementsByTagName('A');
|
|
|
|
for (var i = 0; i < links.length; i++) {
|
|
|
|
var href = links[i].getAttribute('href');
|
2011-07-15 10:35:41 +02:00
|
|
|
if(!href) continue;
|
2016-01-06 00:34:58 +01:00
|
|
|
|
2012-08-27 14:40:11 +02:00
|
|
|
if (href.match(/^http:\/\//)) links[i].setAttribute('target', '_blank');
|
2011-04-28 12:36:28 +02:00
|
|
|
}
|
2012-08-27 14:40:11 +02:00
|
|
|
|
2012-11-29 05:41:48 +01:00
|
|
|
// Hide the navigator from the preview iframe and use only the CMS one.
|
2012-08-27 14:40:11 +02:00
|
|
|
var navi = doc.getElementById('SilverStripeNavigator');
|
|
|
|
if(navi) navi.style.display = 'none';
|
|
|
|
var naviMsg = doc.getElementById('SilverStripeNavigatorMessage');
|
|
|
|
if(naviMsg) naviMsg.style.display = 'none';
|
2013-05-26 02:50:55 +02:00
|
|
|
|
|
|
|
// Trigger extensions.
|
|
|
|
this.trigger('afterIframeAdjustedForPreview', [ doc ]);
|
2012-11-29 05:41:48 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$('.cms-edit-form').entwine({
|
2014-07-14 01:15:38 +02:00
|
|
|
onadd: function() {
|
|
|
|
this._super();
|
2012-12-03 22:16:58 +01:00
|
|
|
$('.cms-preview')._initialiseFromContent();
|
2011-04-28 12:36:28 +02:00
|
|
|
}
|
|
|
|
});
|
2016-01-06 00:34:58 +01:00
|
|
|
|
2012-11-29 05:41:48 +01:00
|
|
|
/**
|
|
|
|
* "Preview state" functions.
|
|
|
|
* -------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
$('.cms-preview-states').entwine({
|
|
|
|
/**
|
2012-12-03 22:16:58 +01:00
|
|
|
* Change the appearance of the state selector.
|
2012-11-29 05:41:48 +01:00
|
|
|
*/
|
|
|
|
changeVisibleState: function(state) {
|
2012-12-04 04:50:35 +01:00
|
|
|
this.find('input[data-name="'+state+'"]').prop('checked', true);
|
2011-05-02 01:43:51 +02:00
|
|
|
}
|
2012-11-29 05:41:48 +01:00
|
|
|
});
|
2012-11-26 05:26:06 +01:00
|
|
|
|
2012-12-03 03:17:16 +01:00
|
|
|
$('.cms-preview-states .state-name').entwine({
|
2012-11-29 05:41:48 +01:00
|
|
|
/**
|
|
|
|
* Reacts to the user changing the state of the preview.
|
|
|
|
*/
|
2016-01-06 00:34:58 +01:00
|
|
|
onclick: function(e) {
|
2012-12-04 06:10:20 +01:00
|
|
|
//Add and remove classes to make switch work ok in old IE
|
|
|
|
this.parent().find('.active').removeClass('active');
|
|
|
|
this.next('label').addClass('active');
|
|
|
|
|
2012-12-03 03:17:16 +01:00
|
|
|
var targetStateName = $(this).attr('data-name');
|
2012-11-29 05:41:48 +01:00
|
|
|
// Reload preview with the selected state.
|
2016-01-06 00:34:58 +01:00
|
|
|
$('.cms-preview').changeState(targetStateName);
|
2012-11-29 05:41:48 +01:00
|
|
|
}
|
2016-01-06 00:34:58 +01:00
|
|
|
});
|
|
|
|
|
2012-11-29 05:41:48 +01:00
|
|
|
/**
|
|
|
|
* "Preview mode" functions
|
|
|
|
* -------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
$('.preview-mode-selector').entwine({
|
|
|
|
/**
|
2012-12-03 22:16:58 +01:00
|
|
|
* Change the appearance of the mode selector.
|
2012-11-29 05:41:48 +01:00
|
|
|
*/
|
|
|
|
changeVisibleMode: function(mode) {
|
|
|
|
this.find('select')
|
|
|
|
.val(mode)
|
2012-11-27 06:03:43 +01:00
|
|
|
.trigger('liszt:updated')
|
2012-11-29 05:41:48 +01:00
|
|
|
._addIcon();
|
2011-05-15 05:43:21 +02:00
|
|
|
}
|
2015-09-07 00:49:37 +02:00
|
|
|
});
|
2012-05-04 01:29:50 +02:00
|
|
|
|
2012-11-29 05:41:48 +01:00
|
|
|
$('.preview-mode-selector select').entwine({
|
|
|
|
/**
|
|
|
|
* Reacts to the user changing the preview mode.
|
|
|
|
*/
|
2016-01-06 00:34:58 +01:00
|
|
|
onchange: function(e) {
|
2012-12-16 03:53:22 +01:00
|
|
|
this._super(e);
|
2012-11-27 06:03:43 +01:00
|
|
|
e.preventDefault();
|
|
|
|
|
2012-11-29 05:41:48 +01:00
|
|
|
var targetStateName = $(this).val();
|
|
|
|
$('.cms-preview').changeMode(targetStateName);
|
2012-11-27 06:03:43 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-01-06 00:34:58 +01:00
|
|
|
|
2012-12-04 06:10:20 +01:00
|
|
|
$('.preview-mode-selector .chzn-results li').entwine({
|
|
|
|
/**
|
2016-01-06 00:34:58 +01:00
|
|
|
* IE8 doesn't support programatic access to onchange event
|
2012-12-04 06:10:20 +01:00
|
|
|
* so react on click
|
|
|
|
*/
|
2015-09-07 00:49:37 +02:00
|
|
|
onclick:function(e){
|
2012-12-04 06:10:20 +01:00
|
|
|
if ($.browser.msie) {
|
2016-01-06 00:34:58 +01:00
|
|
|
e.preventDefault();
|
2012-12-04 06:10:20 +01:00
|
|
|
var index = this.index();
|
2016-01-06 00:34:58 +01:00
|
|
|
var targetStateName = this.closest('.preview-mode-selector').find('select option:eq('+index+')').val();
|
|
|
|
|
2012-12-04 06:10:20 +01:00
|
|
|
//var targetStateName = $(this).val();
|
|
|
|
$('.cms-preview').changeMode(targetStateName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2016-01-06 00:34:58 +01:00
|
|
|
|
2012-11-27 06:03:43 +01:00
|
|
|
/**
|
2012-11-29 05:41:48 +01:00
|
|
|
* Adjust the visibility of the preview-mode selector in the CMS part (hidden if preview is visible).
|
2012-11-27 06:03:43 +01:00
|
|
|
*/
|
|
|
|
$('.cms-preview.column-hidden').entwine({
|
|
|
|
onmatch: function() {
|
|
|
|
$('#preview-mode-dropdown-in-content').show();
|
2015-09-07 00:49:37 +02:00
|
|
|
// Alert the user as to why the preview is hidden
|
|
|
|
if ($('.cms-preview .result-selected').hasClass('font-icon-columns')) {
|
|
|
|
statusMessage(ss.i18n._t(
|
|
|
|
'LeftAndMain.DISABLESPLITVIEW',
|
|
|
|
"Screen too small to show site preview in split mode"),
|
|
|
|
"error");
|
|
|
|
}
|
2012-11-27 06:03:43 +01:00
|
|
|
this._super();
|
|
|
|
},
|
2015-09-07 00:49:37 +02:00
|
|
|
|
2012-11-27 06:03:43 +01:00
|
|
|
onunmatch: function() {
|
|
|
|
$('#preview-mode-dropdown-in-content').hide();
|
|
|
|
this._super();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
2012-11-29 05:41:48 +01:00
|
|
|
* Initialise the preview-mode selector in the CMS part (could be hidden if preview is visible).
|
2012-11-27 06:03:43 +01:00
|
|
|
*/
|
|
|
|
$('#preview-mode-dropdown-in-content').entwine({
|
|
|
|
onmatch: function() {
|
|
|
|
if ($('.cms-preview').is('.column-hidden')) {
|
|
|
|
this.show();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.hide();
|
|
|
|
}
|
|
|
|
this._super();
|
|
|
|
},
|
|
|
|
onunmatch: function() {
|
|
|
|
this._super();
|
|
|
|
}
|
|
|
|
});
|
2012-05-04 01:29:50 +02:00
|
|
|
|
2012-11-29 05:41:48 +01:00
|
|
|
/**
|
|
|
|
* "Preview size" functions
|
|
|
|
* -------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
$('.preview-size-selector').entwine({
|
|
|
|
/**
|
2012-12-03 22:16:58 +01:00
|
|
|
* Change the appearance of the size selector.
|
2012-11-29 05:41:48 +01:00
|
|
|
*/
|
2016-01-06 00:34:58 +01:00
|
|
|
changeVisibleSize: function(size) {
|
2012-11-29 05:41:48 +01:00
|
|
|
this.find('select')
|
|
|
|
.val(size)
|
|
|
|
.trigger('liszt:updated')
|
|
|
|
._addIcon();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$('.preview-size-selector select').entwine({
|
|
|
|
/**
|
|
|
|
* Trigger change in the preview size.
|
|
|
|
*/
|
|
|
|
onchange: function(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
var targetSizeName = $(this).val();
|
|
|
|
$('.cms-preview').changeSize(targetSizeName);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-01-06 00:34:58 +01:00
|
|
|
|
2012-11-29 05:41:48 +01:00
|
|
|
/**
|
2012-12-03 22:16:58 +01:00
|
|
|
* "Chosen" plumbing.
|
2012-11-29 05:41:48 +01:00
|
|
|
* -------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
2012-11-22 04:30:50 +01:00
|
|
|
/*
|
2016-01-06 00:34:58 +01:00
|
|
|
* Add a class to the chzn select trigger based on the currently
|
2012-11-22 04:30:50 +01:00
|
|
|
* selected option. Update as this changes
|
|
|
|
*/
|
2012-11-27 06:03:43 +01:00
|
|
|
$('.preview-selector select.preview-dropdown').entwine({
|
|
|
|
'onliszt:showing_dropdown': function() {
|
2012-11-29 05:41:48 +01:00
|
|
|
this.siblings().find('.chzn-drop').addClass('open')._alignRight();
|
2012-11-27 06:03:43 +01:00
|
|
|
},
|
2012-12-16 03:53:22 +01:00
|
|
|
|
2012-11-27 06:03:43 +01:00
|
|
|
'onliszt:hiding_dropdown': function() {
|
2012-11-29 05:41:48 +01:00
|
|
|
this.siblings().find('.chzn-drop').removeClass('open')._removeRightAlign();
|
2012-12-16 03:53:22 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Trigger additional initial icon update when the control is fully loaded.
|
|
|
|
* Solves an IE8 timing issue.
|
|
|
|
*/
|
|
|
|
'onliszt:ready': function() {
|
|
|
|
this._super();
|
|
|
|
this._addIcon();
|
|
|
|
},
|
|
|
|
|
2012-11-29 05:41:48 +01:00
|
|
|
_addIcon: function(){
|
2016-01-06 00:34:58 +01:00
|
|
|
var selected = this.find(':selected');
|
|
|
|
var iconClass = selected.attr('data-icon');
|
|
|
|
|
2012-11-22 04:30:50 +01:00
|
|
|
var target = this.parent().find('.chzn-container a.chzn-single');
|
|
|
|
var oldIcon = target.attr('data-icon');
|
2012-12-16 03:53:22 +01:00
|
|
|
if(typeof oldIcon !== 'undefined'){
|
2012-11-22 04:30:50 +01:00
|
|
|
target.removeClass(oldIcon);
|
|
|
|
}
|
|
|
|
target.addClass(iconClass);
|
2016-01-06 00:34:58 +01:00
|
|
|
target.attr('data-icon', iconClass);
|
2012-11-22 02:14:11 +01:00
|
|
|
|
2012-12-16 03:53:22 +01:00
|
|
|
return this;
|
2012-11-22 04:30:50 +01:00
|
|
|
}
|
|
|
|
});
|
2012-11-22 02:14:11 +01:00
|
|
|
|
2012-11-27 06:03:43 +01:00
|
|
|
$('.preview-selector .chzn-drop').entwine({
|
2012-11-29 05:41:48 +01:00
|
|
|
_alignRight: function(){
|
2012-11-27 06:03:43 +01:00
|
|
|
var that = this;
|
|
|
|
$(this).hide();
|
2016-01-06 00:34:58 +01:00
|
|
|
/* Delay so styles applied after chosen applies css
|
2012-11-27 06:03:43 +01:00
|
|
|
(the line after we find out the dropdown is open)
|
|
|
|
*/
|
2016-01-06 00:34:58 +01:00
|
|
|
setTimeout(function(){
|
2012-11-27 06:03:43 +01:00
|
|
|
$(that).css({left:'auto', right:0});
|
2016-01-06 00:34:58 +01:00
|
|
|
$(that).show();
|
|
|
|
}, 100);
|
2012-11-27 06:03:43 +01:00
|
|
|
},
|
2012-11-29 05:41:48 +01:00
|
|
|
_removeRightAlign:function(){
|
2012-11-27 06:03:43 +01:00
|
|
|
$(this).css({right:'auto'});
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2016-01-06 00:34:58 +01:00
|
|
|
/*
|
|
|
|
* Means of having extra styled data in chzn 'preview-selector' selects
|
|
|
|
* When chzn ul is ready, grab data-description from original select.
|
2012-11-22 04:30:50 +01:00
|
|
|
* If it exists, append to option and add description class to list item
|
|
|
|
*/
|
2012-11-27 06:03:43 +01:00
|
|
|
/*
|
|
|
|
|
2016-01-06 00:34:58 +01:00
|
|
|
Currently buggy (adds dexcription, then re-renders). This may need to
|
|
|
|
be done inside chosen. Chosen recommends to do this stuff in the css,
|
|
|
|
but that option is inaccessible and untranslatable
|
2012-11-27 06:03:43 +01:00
|
|
|
(https://github.com/harvesthq/chosen/issues/399)
|
|
|
|
|
2012-11-22 04:30:50 +01:00
|
|
|
$('.preview-selector .chzn-drop ul').entwine({
|
|
|
|
onmatch: function() {
|
2012-11-27 06:03:43 +01:00
|
|
|
this.extraData();
|
|
|
|
this._super();
|
2012-11-22 04:30:50 +01:00
|
|
|
},
|
2012-11-27 06:03:43 +01:00
|
|
|
onunmatch: function() {
|
|
|
|
this._super();
|
|
|
|
},
|
|
|
|
extraData: function(){
|
2012-11-22 04:30:50 +01:00
|
|
|
var that = this;
|
2016-01-06 00:34:58 +01:00
|
|
|
var options = this.closest('.preview-selector').find('select option');
|
|
|
|
|
2012-11-22 04:30:50 +01:00
|
|
|
$.each(options, function(index, option){
|
2012-11-27 06:03:43 +01:00
|
|
|
var target = $(that).find("li:eq(" + index + ")");
|
|
|
|
var description = $(option).attr('data-description');
|
|
|
|
if(description != undefined && !$(target).hasClass('description')){
|
2012-11-22 04:30:50 +01:00
|
|
|
$(target).append('<span>' + description + '</span>');
|
2016-01-06 00:34:58 +01:00
|
|
|
$(target).addClass('description');
|
2012-11-22 04:30:50 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2012-11-27 06:03:43 +01:00
|
|
|
}); */
|
|
|
|
|
2015-09-07 00:49:37 +02:00
|
|
|
$('.preview-mode-selector .chzn-drop li:last-child').entwine({
|
|
|
|
onmatch: function () {
|
|
|
|
if ($('.preview-mode-selector').hasClass('split-disabled')) {
|
|
|
|
this.parent().append('<div class="disabled-tooltip"></div>');
|
|
|
|
} else {
|
|
|
|
this.parent().append('<div class="disabled-tooltip" style="display: none;"></div>');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2012-11-29 05:41:48 +01:00
|
|
|
/**
|
|
|
|
* Recalculate the preview space to allow for horizontal scrollbar and the preview actions panel
|
|
|
|
*/
|
|
|
|
$('.preview-scroll').entwine({
|
2012-08-28 18:31:15 +02:00
|
|
|
/**
|
2012-11-29 05:41:48 +01:00
|
|
|
* Height of the preview actions panel
|
2012-08-28 18:31:15 +02:00
|
|
|
*/
|
2012-11-29 05:41:48 +01:00
|
|
|
ToolbarSize: 53,
|
2012-08-28 18:31:15 +02:00
|
|
|
|
2012-11-29 05:41:48 +01:00
|
|
|
_redraw: function() {
|
|
|
|
var toolbarSize = this.getToolbarSize();
|
2012-11-22 04:30:50 +01:00
|
|
|
|
|
|
|
if(window.debug) console.log('redraw', this.attr('class'), this.get(0));
|
|
|
|
var previewHeight = (this.height() - toolbarSize);
|
|
|
|
this.height(previewHeight);
|
2016-01-06 00:34:58 +01:00
|
|
|
},
|
2012-11-29 05:41:48 +01:00
|
|
|
|
2012-11-22 04:30:50 +01:00
|
|
|
onmatch: function() {
|
2012-11-29 05:41:48 +01:00
|
|
|
this._redraw();
|
2012-11-27 06:03:43 +01:00
|
|
|
this._super();
|
|
|
|
},
|
2012-11-29 05:41:48 +01:00
|
|
|
|
2012-11-27 06:03:43 +01:00
|
|
|
onunmatch: function() {
|
|
|
|
this._super();
|
2012-11-22 04:30:50 +01:00
|
|
|
}
|
2012-11-29 05:41:48 +01:00
|
|
|
// TODO: Need to recalculate on resize of browser
|
2012-11-22 04:30:50 +01:00
|
|
|
|
|
|
|
});
|
|
|
|
|
2012-12-06 03:22:45 +01:00
|
|
|
/**
|
|
|
|
* Rotate preview to landscape
|
|
|
|
*/
|
2015-09-07 00:49:37 +02:00
|
|
|
$('.preview-device-outer').entwine({
|
|
|
|
onclick: function () {
|
|
|
|
this.toggleClass('rotate');
|
2012-12-06 03:22:45 +01:00
|
|
|
}
|
|
|
|
});
|
2011-04-28 12:36:28 +02:00
|
|
|
});
|
2012-11-22 04:30:50 +01:00
|
|
|
}(jQuery));
|