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

View File

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

View File

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