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

This commit is contained in:
Ingo Schommer 2011-03-31 21:52:29 +13:00
parent fd0c38c175
commit dad6169f73
11 changed files with 48 additions and 43 deletions

View File

@ -757,6 +757,7 @@ class LeftAndMain extends Controller {
} }
$form = new Form($this, "EditForm", $fields, $actions); $form = new Form($this, "EditForm", $fields, $actions);
$form->addExtraClass('cms-edit-form');
$form->loadDataFrom($record); $form->loadDataFrom($record);
// Add a default or custom validator. // Add a default or custom validator.
@ -821,6 +822,8 @@ class LeftAndMain extends Controller {
new FieldSet() new FieldSet()
); );
$form->unsetValidator(); $form->unsetValidator();
$form->addExtraClass('cms-edit-form');
$form->addExtraClass('root-form');
return $form; return $form;
} }
@ -845,6 +848,7 @@ class LeftAndMain extends Controller {
) )
); );
$form->addExtraClass('actionparams'); $form->addExtraClass('actionparams');
$form->addExtraClass('add-form');
return $form; return $form;
} }

View File

@ -169,6 +169,7 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
$fields, $fields,
$actions $actions
); );
$form->addExtraClass('cms-edit-form');
return $form; return $form;
} }

View File

@ -4,16 +4,16 @@
(function($) { (function($) {
$.entwine('ss', function($){ $.entwine('ss', function($){
/** /**
* Class: #Form_AddForm * Class: .add-form
* *
* 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.
* *
* Requires: * Requires:
* ss.i18n * ss.i18n
* #Form_EditForm * .cms-edit-form
*/ */
$('#Form_AddForm').entwine({ $('.add-form').entwine({
/** /**
* Variable: Tree * Variable: Tree
* (DOMElement) * (DOMElement)
@ -91,7 +91,7 @@
data.push({name:button.attr('name'),value:button.val()}); data.push({name:button.attr('name'),value:button.val()});
// TODO Should be set by hiddenfield already // TODO Should be set by hiddenfield already
jQuery('#Form_EditForm').entwine('ss').loadForm( jQuery('.cms-edit-form').entwine('ss').loadForm(
this.attr('action'), this.attr('action'),
function() { function() {
// Tree updates are triggered by Form_EditForm load events // Tree updates are triggered by Form_EditForm load events

View File

@ -271,10 +271,10 @@
// // only if the current page was modified // // only if the current page was modified
// tree.jstree('select_node', selectedNode); // tree.jstree('select_node', selectedNode);
// } else if(data.deleted[selectedNodeId]) { // } else if(data.deleted[selectedNodeId]) {
// jQuery('#Form_EditForm').entwine('ss').removeForm(); // jQuery('.cms-edit-form').entwine('ss').removeForm();
// } // }
// } else { // } else {
// jQuery('#Form_EditForm').entwine('ss').removeForm(); // jQuery('.cms-edit-form').entwine('ss').removeForm();
// } // }
// close panel // close panel

View File

@ -5,7 +5,7 @@
$.entwine('ss', function($){ $.entwine('ss', function($){
/** /**
* Class: #Form_EditForm * Class: .cms-edit-form
* *
* Base edit form, provides ajaxified saving * Base edit form, provides ajaxified saving
* and reloading itself through the ajax return values. * and reloading itself through the ajax return values.
@ -19,7 +19,7 @@
* removeform - A form is about to be removed from the DOM * removeform - A form is about to be removed from the DOM
* load - Form is about to be loaded through ajax * load - Form is about to be loaded through ajax
*/ */
$('#Form_EditForm').entwine(/** @lends ss.Form_EditForm */{ $('.cms-edit-form').entwine(/** @lends ss.Form_EditForm */{
/** /**
* Variable: PlaceholderHtml * Variable: PlaceholderHtml
* (String_ HTML text to show when no form content is chosen. * (String_ HTML text to show when no form content is chosen.
@ -340,29 +340,29 @@
}); });
/** /**
* Class: #Form_EditForm .Actions :submit * Class: .cms-edit-form .Actions :submit
* *
* All buttons in the right CMS form go through here by default. * All buttons in the right CMS form go through here by default.
* We need this onclick overloading because we can't get to the * We need this onclick overloading because we can't get to the
* clicked button from a form.onsubmit event. * clicked button from a form.onsubmit event.
*/ */
$('#Form_EditForm .Actions :submit').entwine({ $('.cms-edit-form .Actions :submit').entwine({
/** /**
* Function: onclick * Function: onclick
*/ */
onclick: function(e) { onclick: function(e) {
jQuery('#Form_EditForm').entwine('ss').ajaxSubmit(this); jQuery('.cms-edit-form').entwine('ss').ajaxSubmit(this);
return false; return false;
} }
}); });
/** /**
* Class: #Form_EditForm textarea.htmleditor * Class: .cms-edit-form textarea.htmleditor
* *
* Add tinymce to HtmlEditorFields within the CMS. * Add tinymce to HtmlEditorFields within the CMS.
*/ */
$('#Form_EditForm textarea.htmleditor').entwine({ $('.cms-edit-form textarea.htmleditor').entwine({
/** /**
* Constructor: onmatch * Constructor: onmatch

View File

@ -124,7 +124,7 @@
}) })
// TODO Move to EditForm logic // TODO Move to EditForm logic
.bind('select_node.jstree', function(e, data) { .bind('select_node.jstree', function(e, data) {
var node = data.rslt.obj, loadedNodeID = $('#Form_EditForm :input[name=ID]').val() var node = data.rslt.obj, loadedNodeID = $('.edit-form :input[name=ID]').val()
// Don't allow checking disabled nodes // Don't allow checking disabled nodes
if($(node).hasClass('disabled')) return false; if($(node).hasClass('disabled')) return false;
@ -135,12 +135,12 @@
var url = $(node).find('a:first').attr('href'); var url = $(node).find('a:first').attr('href');
if(url && url != '#') { if(url && url != '#') {
var xmlhttp = $('#Form_EditForm').loadForm( var xmlhttp = $('.edit-form').loadForm(
url, url,
function(response) {} function(response) {}
); );
} else { } else {
$('#Form_EditForm').removeForm(); $('.edit-form').removeForm();
} }
}) })
.bind('move_node.jstree', function(e, data) { .bind('move_node.jstree', function(e, data) {
@ -159,7 +159,7 @@
}); });
}); });
$('#Form_EditForm').bind('loadnewpage', function(e, data) { $('.cms-edit-form').bind('loadnewpage', function(e, data) {
self._onLoadNewPage(e, data); self._onLoadNewPage(e, data);
}); });
}, },

View File

@ -62,7 +62,7 @@
$(this).find('.tab').not(':has(.tab)').css('overflow', 'auto'); $(this).find('.tab').not(':has(.tab)').css('overflow', 'auto');
// @todo Doesn't resize properly if the response doesn't contain a tabset (see above) // @todo Doesn't resize properly if the response doesn't contain a tabset (see above)
$('#Form_EditForm').bind('loadnewpage', function() { $('.cms-edit-form').bind('loadnewpage', function() {
// HACK Delay resizing to give jquery-ui tabs a change their dimensions // HACK Delay resizing to give jquery-ui tabs a change their dimensions
// through dynamically added css classes // through dynamically added css classes
var timerID = "timerLeftAndMainResize"; var timerID = "timerLeftAndMainResize";
@ -119,14 +119,14 @@
$('#contentPanel form', this).fitHeightToParent(); $('#contentPanel form', this).fitHeightToParent();
$('#contentPanel form fieldset', this).fitHeightToParent(); $('#contentPanel form fieldset', this).fitHeightToParent();
$('#contentPanel form fieldset .content', this).fitHeightToParent(); $('#contentPanel form fieldset .content', this).fitHeightToParent();
$('#Form_EditForm').fitHeightToParent(); $('.edit-form').fitHeightToParent();
$('#Form_EditForm fieldset', this).fitHeightToParent(); $('.edit-form fieldset', this).fitHeightToParent();
// Order of resizing is important: Outer to inner // Order of resizing is important: Outer to inner
// TODO Only supports two levels of tabs at the moment // TODO Only supports two levels of tabs at the moment
$('#Form_EditForm fieldset > .ss-tabset', this).fitHeightToParent(); $('.edit-form fieldset > .ss-tabset', this).fitHeightToParent();
$('#Form_EditForm fieldset > .ss-tabset > .tab', this).fitHeightToParent(); $('.edit-form fieldset > .ss-tabset > .tab', this).fitHeightToParent();
$('#Form_EditForm fieldset > .ss-tabset > .tab > .ss-tabset', this).fitHeightToParent(); $('.edit-form fieldset > .ss-tabset > .tab > .ss-tabset', this).fitHeightToParent();
$('#Form_EditForm fieldset > .ss-tabset > .tab > .ss-tabset > .tab', this).fitHeightToParent(); $('.edit-form fieldset > .ss-tabset > .tab > .ss-tabset > .tab', this).fitHeightToParent();
} }
}); });
@ -307,7 +307,7 @@
onmatch: function() { onmatch: function() {
this._super(); this._super();
$('#Form_EditForm').bind('loadnewpage delete', function(e) { $('.cms-edit-form').bind('loadnewpage delete', function(e) {
var updatedSwitchView = $('#AjaxSwitchView'); var updatedSwitchView = $('#AjaxSwitchView');
if(updatedSwitchView.length) { if(updatedSwitchView.length) {
$('#SwitchView').html(updatedSwitchView.html()); $('#SwitchView').html(updatedSwitchView.html());

View File

@ -88,24 +88,24 @@ AjaxMemberLookup = {
* Class: MemberTableField * Class: MemberTableField
*/ */
MemberTableField = Class.create(); MemberTableField = Class.create();
MemberTableField.applyTo('#Form_EditForm div.MemberTableField'); MemberTableField.applyTo('.cms-edit-form div.MemberTableField');
MemberTableField.prototype = { MemberTableField.prototype = {
initialize: function() { initialize: function() {
Behaviour.register({ Behaviour.register({
'#Form_EditForm div.MemberFilter input' : { '.cms-edit-form div.MemberFilter input' : {
onkeypress : this.prepareSearch.bind(this) onkeypress : this.prepareSearch.bind(this)
}, },
'#Form_EditForm div.MemberTableField table.data tr.addtogrouprow input' : { '.cms-edit-form div.MemberTableField table.data tr.addtogrouprow input' : {
onkeypress : this.prepareAddToGroup.bind(this) onkeypress : this.prepareAddToGroup.bind(this)
}, },
'#Form_EditForm div.MemberTableField table.data tr.addtogrouprow #Form_AddRecordForm_action_addtogroup' : { '.cms-edit-form div.MemberTableField table.data tr.addtogrouprow #Form_AddRecordForm_action_addtogroup' : {
onclick : this.prepareAddToGroup.bind(this) onclick : this.prepareAddToGroup.bind(this)
}, },
'#Form_EditForm div.MemberTableField table.data tr.addtogrouprow td.actions input' : { '.cms-edit-form div.MemberTableField table.data tr.addtogrouprow td.actions input' : {
initialise: function() { initialise: function() {
data = this.parentNode.parentNode.getElementsByTagName('input'); data = this.parentNode.parentNode.getElementsByTagName('input');
var i,item,error = []; var i,item,error = [];
@ -116,9 +116,9 @@ MemberTableField.prototype = {
onclick : this.addToGroup.bind(this) onclick : this.addToGroup.bind(this)
}, },
//'#Form_EditForm div.MemberTableField input' : AjaxMemberLookup, //'.cms-edit-form div.MemberTableField input' : AjaxMemberLookup,
'#Form_EditForm' : { '.cms-edit-form' : {
changeDetection_fieldsToIgnore : { changeDetection_fieldsToIgnore : {
'ctf[start]' : true, 'ctf[start]' : true,
'ctf[ID]' : true, 'ctf[ID]' : true,
@ -325,7 +325,7 @@ MemberFilterButton.prototype = {
// has to be external from initialize() because otherwise request will double on each reload - WTF // has to be external from initialize() because otherwise request will double on each reload - WTF
Behaviour.register({ Behaviour.register({
'#Form_EditForm div.MemberTableField table.data input.text' : AjaxMemberLookup '.cms-edit-form div.MemberTableField table.data input.text' : AjaxMemberLookup
}); });
/** /**

View File

@ -116,7 +116,7 @@
this.trigger('historyGoBack', {url:previousPage}); this.trigger('historyGoBack', {url:previousPage});
// load new location // load new location
$('#Form_EditForm').loadForm(previousPage); $('.cms-edit-form').loadForm(previousPage);
this.redraw(); this.redraw();
} }
@ -136,7 +136,7 @@
this.trigger('historyGoForward', {url:nextPage}); this.trigger('historyGoForward', {url:nextPage});
// load new location // load new location
$('#Form_EditForm').loadForm(nextPage); $('.cms-edit-form').loadForm(nextPage);
this.redraw(); this.redraw();
} }

View File

@ -71,7 +71,7 @@
var btn = $(this[0].clickedButton); var btn = $(this[0].clickedButton);
btn.addClass('loading'); btn.addClass('loading');
$('#Form_EditForm').loadForm( $('.cms-edit-form').loadForm(
this.attr('action'), this.attr('action'),
function() { function() {
btn.removeClass('loading'); btn.removeClass('loading');
@ -135,7 +135,7 @@
onclick: function(e) { onclick: function(e) {
var firstLink = this.find('a[href]'); var firstLink = this.find('a[href]');
if(!firstLink) return; if(!firstLink) return;
$('#Form_EditForm').loadForm(firstLink.attr('href')); $('.cms-edit-form').loadForm(firstLink.attr('href'));
return false; return false;
} }
}); });
@ -153,7 +153,7 @@
className = $('select option:selected', this).val(); className = $('select option:selected', this).val();
requestPath = this.attr('action').replace('ManagedModelsSelect', className + '/add'); requestPath = this.attr('action').replace('ManagedModelsSelect', className + '/add');
var $button = $(':submit', this); var $button = $(':submit', this);
$('#Form_EditForm').loadForm( $('.cms-edit-form').loadForm(
requestPath, requestPath,
function() { function() {
$button.removeClass('loading'); $button.removeClass('loading');
@ -166,11 +166,11 @@
}); });
/** /**
* Class: #Form_EditForm input[name=action_doDelete] * Class: .cms-edit-form input[name=action_doDelete]
* *
* RHS panel Delete button * RHS panel Delete button
*/ */
$('#Form_EditForm input[name=action_doDelete]').entwine({ $('.cms-edit-form input[name=action_doDelete]').entwine({
// Function: onclick // Function: onclick
onclick: function(e) { onclick: function(e) {
if(!confirm(ss.i18n._t('ModelAdmin.REALLYDELETE', 'Really delete?'))) { if(!confirm(ss.i18n._t('ModelAdmin.REALLYDELETE', 'Really delete?'))) {

View File

@ -53,9 +53,9 @@
$.entwine('ss', function($){ $.entwine('ss', function($){
/** /**
* Class: #Form_EditForm .Actions #Form_EditForm_action_addmember * Class: .cms-edit-form .Actions #Form_EditForm_action_addmember
*/ */
$('#Form_EditForm .Actions #Form_EditForm_action_addmember').entwine({ $('.cms-edit-form .Actions #Form_EditForm_action_addmember').entwine({
// Function: onclick // Function: onclick
onclick: function(e) { onclick: function(e) {
// CAUTION: Assumes that a MemberTableField-instance is present as an editing form // CAUTION: Assumes that a MemberTableField-instance is present as an editing form