From c48c7755bb736d065a04cdceaac6706fb686e8e6 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Sat, 21 Nov 2009 03:14:22 +0000 Subject: [PATCH] ENHANCEMENT Moving placeholder HTML for CMS EditForm out of the
tag, and picking it up for later usage in the EditForm javascript git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@92691 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- code/LeftAndMain.php | 2 +- javascript/LeftAndMain.EditForm.js | 13 +++++++++---- javascript/LeftAndMain_left.js | 6 ++++-- templates/Includes/CMSMain_right.ss | 14 ++++++++------ 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/code/LeftAndMain.php b/code/LeftAndMain.php index c5aeaebd..001f5a6d 100644 --- a/code/LeftAndMain.php +++ b/code/LeftAndMain.php @@ -511,7 +511,7 @@ class LeftAndMain extends Controller { // Wrap the root if needs be. if(!$rootID) { - $rootLink = $this->Link() . '0'; + $rootLink = '#'; // This lets us override the tree title with an extension if($this->hasMethod('getCMSTreeTitle')) $treeTitle = $this->getCMSTreeTitle(); diff --git a/javascript/LeftAndMain.EditForm.js b/javascript/LeftAndMain.EditForm.js index 3c77885e..fe0d4a5c 100644 --- a/javascript/LeftAndMain.EditForm.js +++ b/javascript/LeftAndMain.EditForm.js @@ -17,10 +17,10 @@ return/** @lends ss.Form_EditForm */{ /** - * @type String HTML text to show when the form has been deleted. - * @todo i18n + * @type String HTML text to show when no form content is chosen. + * Will show inside the tag. */ - RemoveText: 'Removed', + PlaceholderHtml: '', /** * @type Object @@ -31,10 +31,15 @@ var self = this; this._setupChangeTracker(); - + // Can't bind this through jQuery window.onbeforeunload = function(e) {return self._checkChangeTracker(false);}; + // set default placeholder if form has no children + this.setPlaceholderHtml(jQuery('.ss-cmsForm-welcomeMessage').html()); + jQuery('.ss-cmsForm-welcomeMessage').remove(); + if(!self.find('*').length) self.removeForm(); + $._super(); }, diff --git a/javascript/LeftAndMain_left.js b/javascript/LeftAndMain_left.js index acaa8274..f816ceb1 100755 --- a/javascript/LeftAndMain_left.js +++ b/javascript/LeftAndMain_left.js @@ -199,17 +199,19 @@ TreeAPI.prototype = { TreeNodeAPI = Class.create(); TreeNodeAPI.prototype = { selectTreeNode : function() { - if(this.getElementsByTagName('a')[0].href) { + var url = jQuery(this).find('a').attr('href'); + if(url && url != '#') { _AJAX_LOADING = true; if($('sitetree').notify('SelectionChanged', this)) { this.getPageFromServer(); } + } else { + jQuery('#Form_EditForm').concrete('ss').removeForm(); } }, getPageFromServer : function() { var self = this; - var xmlhttp = jQuery('#Form_EditForm').concrete('ss').load( jQuery(this).find('a').attr('href'), function(response) { diff --git a/templates/Includes/CMSMain_right.ss b/templates/Includes/CMSMain_right.ss index 1f0a92ac..d7e64445 100755 --- a/templates/Includes/CMSMain_right.ss +++ b/templates/Includes/CMSMain_right.ss @@ -1,12 +1,14 @@ +
+

$ApplicationName

+

+ <% _t('WELCOMETO','Welcome to') %> $ApplicationName! + <% _t('CHOOSEPAGE','Please choose a page from the left.') %> +

+
<% if EditForm %> $EditForm <% else %> - -

$ApplicationName

-

- <% _t('WELCOMETO','Welcome to') %> $ApplicationName! - <% _t('CHOOSEPAGE','Please choose a page from the left.') %> -

+
<% end_if %>