NOTFORMERE: BUGFIX: fixed layout issue when tinymce event handler was not removed before the load request. BUGFIX: removed back button display when no history existed

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.3@96959 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Will Rossiter 2010-01-14 21:45:32 +00:00 committed by Sam Minnee
parent a10b7018dd
commit 284f5ee453
2 changed files with 44 additions and 22 deletions

View File

@ -123,6 +123,10 @@ body.ModelAdmin #right .ajaxActions {
bottom: 35px !important; bottom: 35px !important;
} }
body.ModelAdmin #Form_EditForm_action_goBack {
display: none; /* Hide the back button by default. Shown when addHistory is Triggered */
}
.tab h3 { .tab h3 {
margin-top: 10px; margin-top: 10px;
font-size: 1.2em; font-size: 1.2em;

View File

@ -10,6 +10,7 @@
*/ */
(function($) { (function($) {
$(document).ready(function() { $(document).ready(function() {
/** /**
* Add class ajaxActions class to the parent of Add button of AddForm * Add class ajaxActions class to the parent of Add button of AddForm
* so it float to the right * so it float to the right
@ -81,6 +82,10 @@ $(document).ready(function() {
$('#SearchForm_holder .tab form:not(#Form_ImportForm)').submit(function () { $('#SearchForm_holder .tab form:not(#Form_ImportForm)').submit(function () {
var $form = $(this); var $form = $(this);
$('#right form textarea').each(function(){
tinyMCE.execCommand('mceRemoveControl', false, $(this).attr('id'));
});
$('#ModelAdminPanel').fn('startHistory', $(this).attr('action'), $(this).formToArray()); $('#ModelAdminPanel').fn('startHistory', $(this).attr('action'), $(this).formToArray());
$('#ModelAdminPanel').load($(this).attr('action'), $(this).formToArray(), standardStatusHandler(function(result) { $('#ModelAdminPanel').load($(this).attr('action'), $(this).formToArray(), standardStatusHandler(function(result) {
if(!this.future || !this.future.length) { if(!this.future || !this.future.length) {
@ -92,7 +97,7 @@ $(document).ready(function() {
$('#form_actions_right').remove(); $('#form_actions_right').remove();
Behaviour.apply(); Behaviour.apply();
console.log(window.onresize);
if(window.onresize) window.onresize(); if(window.onresize) window.onresize();
// Remove the loading indicators from the buttons // Remove the loading indicators from the buttons
$('input[type=submit]', $form).removeClass('loading'); $('input[type=submit]', $form).removeClass('loading');
@ -149,16 +154,6 @@ $(document).ready(function() {
$('#ModelAdminPanel').fn('loadForm', el.attr('href')); $('#ModelAdminPanel').fn('loadForm', el.attr('href'));
return false; return false;
}); });
/* this isn't being used currently; the real hover code is part of TableListField
.hover(
function(){
$(this).addClass('over').siblings().addClass('over')
},
function(){
$(this).removeClass('over').siblings().removeClass('over')
}
);
*/
////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////
// RHS detail form // RHS detail form
@ -183,22 +178,28 @@ $(document).ready(function() {
/** /**
* RHS panel Save button * RHS panel Save button
*/ */
$('#right #form_actions_right input[name=action_doSave]').livequery('click', function(){
$('#right #form_actions_right input[name=action_doSave], #right #form_actions_right input[name=action_doCreate]').livequery('click', function(){
var form = $('#right form'); var form = $('#right form');
var formAction = form.attr('action') + '?' + $(this).fieldSerialize(); var formAction = form.attr('action') + '?' + $(this).fieldSerialize();
$('#right form textarea').each(function(){
tinyMCE.execCommand('mceRemoveControl', false, $(this).attr('id'));
});
// Post the data to save // Post the data to save
$.post(formAction, form.formToArray(), function(result){ $.post(formAction, form.formToArray(), function(result){
$('#right #ModelAdminPanel').html(result); $('#right #ModelAdminPanel').html(result);
statusMessage(ss.i18n._t('ModelAdmin.SAVED')); statusMessage(ss.i18n._t('ModelAdmin.SAVED'));
// TODO/SAM: It seems a bit of a hack to have to list all the little updaters here. // refresh and reapply the JS to trigger textmate
// Is livequery a solution? Behaviour.apply();
Behaviour.apply(); // refreshes ComplexTableField
if(window.onresize) window.onresize(); if(window.onresize) window.onresize();
}, 'html'); }, 'html');
return false; return false;
}); });
@ -212,6 +213,10 @@ $(document).ready(function() {
return false; return false;
} }
$('#right form textarea').each(function(){
tinyMCE.execCommand('mceRemoveControl', false, $(this).attr('id'));
});
var form = $('#right form'); var form = $('#right form');
var formAction = form.attr('action') + '?' + $(this).fieldSerialize(); var formAction = form.attr('action') + '?' + $(this).fieldSerialize();
@ -275,12 +280,16 @@ $(document).ready(function() {
loadForm: function(url, successCallback) { loadForm: function(url, successCallback) {
$('#right #ModelAdminPanel').load(url, standardStatusHandler(function(result) { $('#right #ModelAdminPanel').load(url, standardStatusHandler(function(result) {
if(typeof(successCallback) == 'function') successCallback.apply(); if(typeof(successCallback) == 'function') successCallback.apply();
if(!this.future || !this.future.length) {
$('#Form_EditForm_action_goForward, #Form_ResultsForm_action_goForward').hide(); var forward = $('#Form_EditForm_action_goForward, #Form_ResultsForm_action_goForward');
} var back = $('#Form_EditForm_action_goBack, #Form_ResultsForm_action_goBack');
if(!this.history || this.history.length <= 1) {
$('#Form_EditForm_action_goBack, #Form_ResultsForm_action_goBack').hide(); if(!this.future || !this.future.length) forward.hide();
} else forward.show();
if(!this.history || this.history.length <= 1) back.hide();
else back.show();
Behaviour.apply(); // refreshes ComplexTableField Behaviour.apply(); // refreshes ComplexTableField
if(window.onresize) window.onresize(); if(window.onresize) window.onresize();
@ -311,6 +320,10 @@ $(document).ready(function() {
}, },
goBack: function() { goBack: function() {
$('#right form textarea').each(function(){
tinyMCE.execCommand('mceRemoveControl', false, $(this).attr('id'));
});
if(this.history && this.history.length) { if(this.history && this.history.length) {
if(this.future == null) this.future = []; if(this.future == null) this.future = [];
@ -320,9 +333,14 @@ $(document).ready(function() {
this.future.push(currentPage); this.future.push(currentPage);
$(this).fn('loadForm', previousPage); $(this).fn('loadForm', previousPage);
} }
}, },
goForward: function() { goForward: function() {
$('#right form textarea').each(function(){
tinyMCE.execCommand('mceRemoveControl', false, $(this).attr('id'));
});
if(this.future && this.future.length) { if(this.future && this.future.length) {
if(this.future == null) this.future = []; if(this.future == null) this.future = [];