MINOR: code formatting

This commit is contained in:
Will Rossiter 2011-12-17 16:06:56 +13:00
parent a04c1410e1
commit 01541487ca
3 changed files with 47 additions and 29 deletions

View File

@ -94,6 +94,7 @@
select: function() {
var parent = this.getMenuItem();
this.addClass('current').open();
// Remove "current" class from all siblings and their children
this.siblings().removeClass('current').close();
this.siblings().find('li').removeClass('current');
@ -132,6 +133,7 @@
if(this.is(':internal')) url = $('base').attr('href') + url;
var children = item.find('li');
if(children.length) {
children.first().find('a').click();
} else {

View File

@ -1,15 +1,17 @@
(function($) {
$.entwine('ss', function($){
/**
* Shows a previewable website state alongside its editable version in backend UI, typically a page.
* This allows CMS users to seamlessly switch between preview and edit mode in the same browser window.
* The preview panel is embedded in the layout of the backend UI, and loads its content via an iframe.
* Shows a previewable website state alongside its editable version in backend UI,
* typically a page. This allows CMS users to seamlessly switch between preview and
* edit mode in the same browser window. The preview panel is embedded in the layout
* of the backend UI, and loads its content via an iframe.
*
* The admin UI itself is collapsible, leaving most screen space to this panel.
* Relies on the server responses to indicate if a preview URL is available for the currently loaded
* admin interface. If no preview is available, the panel is "blocked" automatically.
*
* Relies on the server responses to indicate if a preview URL is available for the
* currently loaded admin interface. If no preview is available, the panel is "blocked"
* automatically.
*
* Internal links within the preview iframe trigger a refresh of the admin panel as well,
* while all external links are disabled (via JavaScript).
@ -78,7 +80,7 @@
this._super();
},
loadUrl: function(url) {
loadUrl: function(url) {
this.find('iframe').attr('src', url);
},
@ -96,12 +98,15 @@
if(contentEl.is('.' + blockedClasses.join(',.'))) return;
// Load this page in the admin interface if appropriate
var id = $(doc).find('meta[name=x-page-id]').attr('content'),
editLink = $(doc).find('meta[name=x-cms-edit-link]').attr('content'),
contentPanel = $('.cms-content');
var id = $(doc).find('meta[name=x-page-id]').attr('content');
var editLink = $(doc).find('meta[name=x-cms-edit-link]').attr('content');
var contentPanel = $('.cms-content');
if(id && contentPanel.find(':input[name=ID]').val() != id) {
// Ignore behaviour without history support (as we need ajax loading for the new form to load in the background)
if(window.History.enabled) $('.cms-container').loadPanel(editLink);
// Ignore behaviour without history support (as we need ajax loading
// for the new form to load in the background)
if(window.History.enabled)
$('.cms-container').loadPanel(editLink);
}
},
@ -221,6 +226,7 @@
this.find('.active a').addClass('ui-state-highlight');
}
});
$('.cms-preview .cms-preview-states a').entwine({
onclick: function(e) {
e.preventDefault();
@ -234,8 +240,8 @@
$('.cms-preview-toggle-link').entwine({
onclick: function(e) {
e.preventDefault();
$('.cms-preview').toggle();
$('.cms-preview').toggle();
}
});
});

View File

@ -2,14 +2,11 @@
* File: LeftAndMain.js
*/
(function($) {
$.metadata.setType('html5');
// setup jquery.entwine
$.entwine.warningLevel = $.entwine.WARN_LEVEL_BESTPRACTISE;
$.entwine('ss', function($){
// setup jquery.entwine
$.entwine.warningLevel = $.entwine.WARN_LEVEL_BESTPRACTISE;
$.entwine('ss', function($) {
/**
* Position the loading spinner animation below the ss logo
*/
@ -116,14 +113,20 @@
* - {Object} data Any additional data passed through to History.pushState()
*/
loadPanel: function(url, title, data) {
var data = data || {}, selector = data.selector || '.cms-content', contentEl = $(selector);
var data = data || {};
var selector = data.selector || '.cms-content'
var contentEl = $(selector);
// Check change tracking (can't use events as we need a way to cancel the current state change)
var trackedEls = contentEl.find(':data(changetracker)').add(contentEl.filter(':data(changetracker)'));
if(trackedEls.length) {
var abort = false;
trackedEls.each(function() {
if(!$(this).confirmUnsavedChanges()) abort = true;
});
if(abort) return;
}
@ -168,7 +171,10 @@
if(this.getCurrentXHR()) this.getCurrentXHR().abort();
var selector = state.data.selector || '.cms-content', contentEl = $(selector);
this.trigger('beforestatechange', {state: state, element: contentEl});
this.trigger('beforestatechange', {
state: state, element: contentEl
});
contentEl.addClass('loading');
@ -187,14 +193,17 @@
// Set loading state and store element state
newContentEl.addClass('loading');
var origStyle = contentEl.attr('style'),
layoutClasses = ['east', 'west', 'center', 'north', 'south'],
origLayoutClasses = $.grep(
contentEl.attr('class').split(' '),
function(val) {
return ($.inArray(val, layoutClasses) >= 0);
}
);
var origStyle = contentEl.attr('style');
var layoutClasses = ['east', 'west', 'center', 'north', 'south'];
var elemClasses = contentEl.attr('class');
var origLayoutClasses = $.grep(
elemClasses.split(' '),
function(val) {
return ($.inArray(val, layoutClasses) >= 0);
}
);
newContentEl
.removeClass(layoutClasses.join(' '))
.addClass(origLayoutClasses.join(' '))
@ -215,6 +224,7 @@
contentEl.removeClass('loading');
}
});
this.setCurrentXHR(xhr);
}
});