MINOR Using '.cms-edit-form' instead of '#Form_EditForm' selector

This commit is contained in:
Ingo Schommer 2011-03-31 21:51:59 +13:00
parent 7b655d6199
commit 4fe07e9b71
10 changed files with 59 additions and 27 deletions

View File

@ -285,7 +285,7 @@ JS
// echo <<<HTML // echo <<<HTML
// <script type="text/javascript"> // <script type="text/javascript">
// var url = parent.document.getElementById('sitetree').getTreeNodeByIdx( "{$folder->ID}" ).getElementsByTagName('a')[0].href; // var url = parent.document.getElementById('sitetree').getTreeNodeByIdx( "{$folder->ID}" ).getElementsByTagName('a')[0].href;
// parent.jQuery('#Form_EditForm').entwine('ss').loadForm(url); // parent.jQuery('.cms-edit-form').entwine('ss').loadForm(url);
// parent.statusMessage("{$statusMessage}","{$status}"); // parent.statusMessage("{$statusMessage}","{$status}");
// </script> // </script>
// HTML; // HTML;

View File

@ -462,6 +462,11 @@ JS;
$form = new Form($this, "EditForm", $fields, $actions, $validator); $form = new Form($this, "EditForm", $fields, $actions, $validator);
$form->loadDataFrom($record); $form->loadDataFrom($record);
$form->disableDefaultAction(); $form->disableDefaultAction();
$form->addExtraClass('cms-edit-form');
$form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
// TODO Can't merge $FormAttributes in template at the moment
$form->addExtraClass('cms-content center ss-tabset');
if($form->Fields()->hasTabset()) $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
if(!$record->canEdit() || $record->IsDeletedFromStage) { if(!$record->canEdit() || $record->IsDeletedFromStage) {
$readonlyFields = $form->Fields()->makeReadonly(); $readonlyFields = $form->Fields()->makeReadonly();
@ -488,8 +493,14 @@ JS;
$fields = $siteConfig->getCMSFields(); $fields = $siteConfig->getCMSFields();
$form = new Form($this, 'RootForm', $fields, $siteConfig->getCMSActions()); $form = new Form($this, 'RootForm', $fields, $siteConfig->getCMSActions());
$form->addExtraClass('root-form');
$form->addExtraClass('cms-edit-form');
// TODO Can't merge $FormAttributes in template at the moment
$form->addExtraClass('cms-content center ss-tabset');
if($form->Fields()->hasTabset()) $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
$form->setHTMLID('Form_EditForm'); $form->setHTMLID('Form_EditForm');
$form->loadDataFrom($siteConfig); $form->loadDataFrom($siteConfig);
$form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
$this->extend('updateEditForm', $form); $this->extend('updateEditForm', $form);

13
config.rb Normal file
View File

@ -0,0 +1,13 @@
# Require any additional compass plugins here.
require 'compass-colors'
project_type = :stand_alone
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "css"
sass_dir = "sass"
images_dir = "images"
javascripts_dir = "javascript"
output_style = :compact
# To enable relative paths to assets via compass helper functions. Uncomment:
# relative_assets = true

View File

@ -47,7 +47,7 @@
var currNode = $('#sitetree')[0].firstSelected(); var currNode = $('#sitetree')[0].firstSelected();
if(currNode) { if(currNode) {
var url = $(currNode).find('a').attr('href'); var url = $(currNode).find('a').attr('href');
$('#Form_EditForm').loadForm(url); $('.cms-edit-form').loadForm(url);
} }
$('#sitetree')[0].setCustomURL('admin/assets/getsubtree'); $('#sitetree')[0].setCustomURL('admin/assets/getsubtree');
$('#sitetree')[0].reload({onSuccess: function() { $('#sitetree')[0].reload({onSuccess: function() {

View File

@ -4,11 +4,11 @@
(function($) { (function($) {
$.entwine('ss', function($){ $.entwine('ss', function($){
/** /**
* Class: #Form_EditForm :input[name=ClassName] * Class: .cms-edit-form :input[name=ClassName]
* Alert the user on change of page-type. This might have implications * Alert the user on change of page-type. This might have implications
* on the available form fields etc. * on the available form fields etc.
*/ */
$('#Form_EditForm :input[name=ClassName]').entwine({ $('.cms-edit-form :input[name=ClassName]').entwine({
// Function: onchange // Function: onchange
onchange: function() { onchange: function() {
alert(ss.i18n._t('CMSMAIN.ALERTCLASSNAME')); alert(ss.i18n._t('CMSMAIN.ALERTCLASSNAME'));
@ -16,11 +16,11 @@
}); });
/** /**
* Class: #Form_EditForm input[name=URLSegment] * Class: .cms-edit-form input[name=URLSegment]
* *
* Input validation on the URLSegment field * Input validation on the URLSegment field
*/ */
$('#Form_EditForm input[name=URLSegment]').entwine({ $('.cms-edit-form input[name=URLSegment]').entwine({
/** /**
* Property: FilterRegex * Property: FilterRegex
* Regex * Regex
@ -88,17 +88,17 @@
}); });
/** /**
* Class: #Form_EditForm input[name=Title] * Class: .cms-edit-form input[name=Title]
* *
* Input validation on the Title field * Input validation on the Title field
*/ */
$('#Form_EditForm input[name=Title]').entwine({ $('.cms-edit-form input[name=Title]').entwine({
// Constructor: onmatch // Constructor: onmatch
onmatch : function() { onmatch : function() {
var self = this; var self = this;
this.bind('change', function(e) { this.bind('change', function(e) {
self.updateURLSegment(jQuery('#Form_EditForm input[name=URLSegment]')); self.updateURLSegment(jQuery('.cms-edit-form input[name=URLSegment]'));
// TODO We should really user-confirm these changes // TODO We should really user-confirm these changes
self.parents('form').find('input[name=MetaTitle], input[name=MenuTitle]').val(self.val()); self.parents('form').find('input[name=MetaTitle], input[name=MenuTitle]').val(self.val());
}); });
@ -137,12 +137,12 @@
}); });
/** /**
* Class: #Form_EditForm .parentTypeSelector * Class: .cms-edit-form .parentTypeSelector
* *
* ParentID field combination - mostly toggling between * ParentID field combination - mostly toggling between
* the two radiobuttons and setting the hidden "ParentID" field * the two radiobuttons and setting the hidden "ParentID" field
*/ */
$('#Form_EditForm .parentTypeSelector').entwine({ $('.cms-edit-form .parentTypeSelector').entwine({
// Constructor: onmatch // Constructor: onmatch
onmatch : function() { onmatch : function() {
var self = this; var self = this;
@ -168,12 +168,12 @@
}); });
/** /**
* Class: #Form_EditForm #CanViewType, #Form_EditForm #CanEditType * Class: .cms-edit-form #CanViewType, .cms-edit-form #CanEditType
* *
* Toggle display of group dropdown in "access" tab, * Toggle display of group dropdown in "access" tab,
* based on selection of radiobuttons. * based on selection of radiobuttons.
*/ */
$('#Form_EditForm #CanViewType, #Form_EditForm #CanEditType').entwine({ $('.cms-edit-form #CanViewType, .cms-edit-form #CanEditType').entwine({
// Constructor: onmatch // Constructor: onmatch
onmatch: function() { onmatch: function() {
// TODO Decouple // TODO Decouple
@ -194,12 +194,12 @@
}); });
/** /**
* Class: #Form_EditForm .Actions #Form_EditForm_action_email * Class: .cms-edit-form .Actions #Form_EditForm_action_email
* *
* Email containing the link to the archived version of the page. * Email containing the link to the archived version of the page.
* Visible on readonly older versions of a specific page at the moment. * Visible on readonly older versions of a specific page at the moment.
*/ */
$('#Form_EditForm .Actions #Form_EditForm_action_email').entwine({ $('.cms-edit-form .Actions #Form_EditForm_action_email').entwine({
/** /**
* Function: onclick * Function: onclick
* *
@ -220,12 +220,12 @@
}); });
/** /**
* Class: #Form_EditForm .Actions #Form_EditForm_action_print * Class: .cms-edit-form .Actions #Form_EditForm_action_print
* *
* Open a printable representation of the form in a new window. * Open a printable representation of the form in a new window.
* Used for readonly older versions of a specific page. * Used for readonly older versions of a specific page.
*/ */
$('#Form_EditForm .Actions #Form_EditForm_action_print').entwine({ $('.cms-edit-form .Actions #Form_EditForm_action_print').entwine({
/** /**
* Function: onclick * Function: onclick
* *
@ -245,11 +245,11 @@
}); });
/** /**
* Class: #Form_EditForm .Actions #Form_EditForm_action_rollback * Class: .cms-edit-form .Actions #Form_EditForm_action_rollback
* *
* A "rollback" to a specific version needs user confirmation. * A "rollback" to a specific version needs user confirmation.
*/ */
$('#Form_EditForm .Actions #Form_EditForm_action_rollback').entwine({ $('.cms-edit-form .Actions #Form_EditForm_action_rollback').entwine({
/** /**
* Function: onclick * Function: onclick

View File

@ -169,7 +169,7 @@
* Class: Form_SideReportsForm * Class: Form_SideReportsForm
* *
* Simple form with a page type dropdown * Simple form with a page type dropdown
* which creates a new page through #Form_EditForm and adds a new tree node. * which creates a new page through .cms-edit-form and adds a new tree node.
*/ */
$('#Form_SideReportsForm').entwine(/** @lends ss.reports_holder */{ $('#Form_SideReportsForm').entwine(/** @lends ss.reports_holder */{
ReportContainer: null, ReportContainer: null,
@ -275,7 +275,7 @@
if (e.button!=2) { if (e.button!=2) {
var $link = $(this); var $link = $(this);
$link.addClass('loading'); $link.addClass('loading');
jQuery('#Form_EditForm').entwine('ss').loadForm( jQuery('.cms-edit-form').entwine('ss').loadForm(
$(this).attr('href'), $(this).attr('href'),
function(e) { function(e) {
$link.removeClass('loading'); $link.removeClass('loading');
@ -337,7 +337,7 @@
var link = $(this).siblings('.versionlink').find('a').attr('href'); var link = $(this).siblings('.versionlink').find('a').attr('href');
td.addClass('loading'); td.addClass('loading');
jQuery('#Form_EditForm').entwine('ss').loadForm( jQuery('.cms-edit-form').entwine('ss').loadForm(
link, link,
function(e) { function(e) {
td.removeClass('loading'); td.removeClass('loading');
@ -388,7 +388,7 @@
data.push({name:$button.attr('name'), value: $button.val()}); data.push({name:$button.attr('name'), value: $button.val()});
if(loadEditForm) { if(loadEditForm) {
jQuery('#Form_EditForm').entwine('ss').loadForm( jQuery('.cms-edit-form').entwine('ss').loadForm(
this.attr('action'), this.attr('action'),
function(e) { function(e) {
$button.removeClass('loading'); $button.removeClass('loading');

View File

@ -0,0 +1,8 @@
(function($) {
// Load tree links directly rather than through ajax into .cms-edit-form.
$('.cms-tree').bind('select_node.jstree', function(e, data) {
var node = data.rslt.obj, url = $(node).find('a:first').attr('href');
if(url && url != '#') document.location.href = url;
return false;
});
}(jQuery));

View File

@ -25,11 +25,11 @@ CommentTableField.prototype = {
rules['#'+this.id+' table.data a.hamlink'] = { rules['#'+this.id+' table.data a.hamlink'] = {
onclick: this.removeRowAfterAjax.bind(this) onclick: this.removeRowAfterAjax.bind(this)
}; };
rules['#Form_EditForm div.CommentFilter input'] = { rules['.edit-form div.CommentFilter input'] = {
onkeypress : this.prepareSearch.bind(this) onkeypress : this.prepareSearch.bind(this)
}; };
rules['#Form_EditForm'] = { rules['.edit-form'] = {
changeDetection_fieldsToIgnore : { changeDetection_fieldsToIgnore : {
'ctf[start]' : true, 'ctf[start]' : true,
'ctf[ID]' : true, 'ctf[ID]' : true,

View File

@ -11,7 +11,7 @@
$('#sitetree').entwine({ $('#sitetree').entwine({
onmatch: function() { onmatch: function() {
// make sure current ID of loaded form is actually selected in tree // make sure current ID of loaded form is actually selected in tree
var id = $('#Form_EditForm :input[name=ID]').val(); var id = $('.cms-edit-form :input[name=ID]').val();
if (id) this[0].setCurrentByIdx(id); if (id) this[0].setCurrentByIdx(id);
this._super(); this._super();

View File

@ -55,7 +55,7 @@ WidgetAreaEditorClass.prototype = {
// Ensure correct sort values are written when page is saved // Ensure correct sort values are written when page is saved
// TODO Adjust to new event listeners // TODO Adjust to new event listeners
jQuery('#Form_EditForm').bind('ajaxsubmit', this.beforeSave.bind(this)); jQuery('.cms-edit-form').bind('ajaxsubmit', this.beforeSave.bind(this));
}, },
rewriteWidgetAreaAttributes: function() { rewriteWidgetAreaAttributes: function() {