(function($) { /** * @class Base edit form, provides ajaxified saving * and reloading itself through the ajax return values. * Takes care of resizing tabsets within the layout container. * @name ss.Form_EditForm */ $('#Form_EditForm').concrete('ss',function($){ return/** @lends ss.Form_EditForm */{ /** * @type String HTML text to show when the form has been deleted. */ RemoveHtml: null, /** * Suppress submission unless it is handled through ajaxSubmit() */ onsubmit: function(e) { return false; }, /** * @param {DOMElement} button The pressed button (optional) */ ajaxSubmit: function(button) { // default to first button if none given - simulates browser behaviour if(!button) button = this.find(':submit:first'); var self = this; this.trigger('ajaxsubmit', {button: button}); // set button to "submitting" state $(button).addClass('loading'); // @todo TinyMCE coupling if(typeof tinyMCE != 'undefined') tinyMCE.triggerSave(); // validate if required if(!this.validate()) { // TODO Automatically switch to the tab/position of the first error statusMessage("Validation failed.", "bad"); $(button).removeClass('loading'); return false; } // get all data from the form var data = this.serializeArray(); // add button action data.push({name: $(button).attr('name'), value:'1'}); $.post( this.attr('action'), data, function(response) { $(button).removeClass('loading'); self._loadResponse(response); }, // @todo Currently all responses are assumed to be evaluated 'script' ); return false; }, /** * Hook in (optional) validation routines. * Currently clientside validation is not supported out of the box in the CMS. * * @todo Placeholder implementation * * @return {boolean} */ validate: function() { var isValid = true; this.trigger('validate', {isValid: isValid}); return isValid; }, /** * @param String url * @param Function callback (Optional) */ load: function(url, callback) { var self = this; $.get( url, function(response) { self._loadResponse(response); if(callback) callback.apply(self, [response]); }, // @todo Currently all responses are assumed to be evaluated 'script' ); }, /** * Remove everying inside the