Skip to content

Commit

Permalink
ENHANCEMENT Moving placeholder HTML for CMS EditForm out of the <form…
Browse files Browse the repository at this point in the history
…> 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
  • Loading branch information
chillu committed Nov 21, 2009
1 parent 471afa4 commit c48c775
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
2 changes: 1 addition & 1 deletion code/LeftAndMain.php
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ function getSiteTreeFor($className, $rootID = null, $childrenMethod = null, $fil
// 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();
Expand Down
13 changes: 9 additions & 4 deletions javascript/LeftAndMain.EditForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <form> tag.
*/
RemoveText: 'Removed',
PlaceholderHtml: '',

/**
* @type Object
Expand All @@ -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();
},

Expand Down
6 changes: 4 additions & 2 deletions javascript/LeftAndMain_left.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
14 changes: 8 additions & 6 deletions templates/Includes/CMSMain_right.ss
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<div class='ss-cmsForm-welcomeMessage'>
<h1>$ApplicationName</h1>
<p>
<% _t('WELCOMETO','Welcome to') %> $ApplicationName!
<% _t('CHOOSEPAGE','Please choose a page from the left.') %>
</p>
</div>
<% if EditForm %>
$EditForm
<% else %>
<form id="Form_EditForm" action="admin?executeForm=EditForm" method="post" enctype="multipart/form-data">
<h1>$ApplicationName</h1>
<p>
<% _t('WELCOMETO','Welcome to') %> $ApplicationName!
<% _t('CHOOSEPAGE','Please choose a page from the left.') %>
</p>
<form id="Form_EditForm" action="admin/EditForm" method="post" enctype="multipart/form-data">
</form>
<% end_if %>

Expand Down

0 comments on commit c48c775

Please sign in to comment.