diff --git a/javascript/AssetAdmin.js b/javascript/AssetAdmin.js index 1f879155..8634e0e9 100755 --- a/javascript/AssetAdmin.js +++ b/javascript/AssetAdmin.js @@ -16,11 +16,10 @@ var _HANDLER_FORMS = { }; (function($) { - /** * Delete selected folders through "batch actions" tab. */ - $(function() { + $(document).ready(function() { $('#Form_BatchActionsForm').concrete('ss').register( // TODO Hardcoding of base URL 'admin/assets/batchactions/delete', @@ -36,32 +35,26 @@ var _HANDLER_FORMS = { ); }); - $('#Form_SyncForm').concrete('ss', function($) { - return { - onmatch: function() { - this.bind('submit', this._onsubmit); - this._super(); - }, - _onsubmit: function(e) { + $.concrete('ss', function($){ + $('#Form_SyncForm').concrete({ + onsubmit: function(e) { var button = jQuery(this).find(':submit:first'); button.addClass('loading'); $.get( jQuery(this).attr('action'), function() { button.removeClass('loading'); - // reload current var currNode = $('#sitetree')[0].firstSelected(); if(currNode) { var url = $(currNode).find('a').attr('href'); - $('#Form_EditForm').concrete('ss').loadForm(url); + $('#Form_EditForm').loadForm(url); } - } ); return false; } - }; + }); }); }(jQuery)); \ No newline at end of file diff --git a/javascript/CMSMain.EditForm.js b/javascript/CMSMain.EditForm.js index 8ec4d43c..11009ce4 100644 --- a/javascript/CMSMain.EditForm.js +++ b/javascript/CMSMain.EditForm.js @@ -1,43 +1,40 @@ (function($) { - /** - * Alert the user on change of page-type - this might have implications - * on the available form fields etc. - * @name ss.EditFormClassName - */ - $('#Form_EditForm :input[name=ClassName]').concrete('ss', function($){ - return/** @lends ss.EditFormClassName */{ + $.concrete('ss', function($){ + /** + * Alert the user on change of page-type - this might have implications + * on the available form fields etc. + * @name ss.EditFormClassName + */ + $('#Form_EditForm :input[name=ClassName]').concrete(/** @lends ss.EditFormClassName */{ onchange: function() { alert(ss.i18n._t('CMSMAIN.ALERTCLASSNAME')); } - }; - }); - - /** - * @class Input validation on the URLSegment field - * @name ss.EditForm.URLSegment - */ - $('#Form_EditForm input[name=URLSegment]').concrete('ss', function($){ - return/** @lends ss.EditForm.URLSegment */{ + }); + /** + * @class Input validation on the URLSegment field + * @name ss.EditForm.URLSegment + */ + $('#Form_EditForm input[name=URLSegment]').concrete(/** @lends ss.EditForm.URLSegment */{ FilterRegex: /[^A-Za-z0-9-]+/, - ValidationMessage: ss.i18n._t('CMSMAIN.URLSEGMENTVALIDATION'), - MaxLength: 50, - + onmatch : function() { var self = this; - + // intercept change event, do our own writing this.bind('change', function(e) { if(!self.validate()) { - jQuery.noticeAdd(self.ValidationMessage()); + jQuery.noticeAdd(self.getValidationMessage()); } self.val(self.suggestValue(e.target.value)); return false; }); + + this._super(); }, - + /** * Return a value matching the criteria. * @@ -46,38 +43,37 @@ */ suggestValue: function(val) { // TODO Do we want to enforce lowercasing in URLs? - return val.substr(0, this.MaxLength()).replace(this.FilterRegex(), '').toLowerCase(); + return val.substr(0, this.getMaxLength()).replace(this.getFilterRegex(), '').toLowerCase(); }, - + validate: function() { return ( - this.val().length > this.MaxLength() - || this.val().match(this.FilterRegex()) + this.val().length > this.getMaxLength() + || this.val().match(this.getFilterRegex()) ); } - }; - }); - - /** - * @class Input validation on the Title field - * @name ss.EditForm.Title - */ - $('#Form_EditForm input[name=Title]').concrete('ss', function($){ - return/** @lends ss.EditForm.Title */{ + }); + /** + * @class Input validation on the Title field + * @name ss.EditForm.Title + */ + $('#Form_EditForm input[name=Title]').concrete(/** @lends ss.EditForm.Title */{ onmatch : function() { var self = this; - + this.bind('change', function(e) { self.updateURLSegment(jQuery('#Form_EditForm input[name=URLSegment]')); // TODO We should really user-confirm these changes self.parents('form').find('input[name=MetaTitle], input[name=MenuTitle]').val(self.val()); }); + + this._super(); }, - + updateURLSegment: function(field) { if(!field || !field.length) return; - + // TODO language/logic coupling var isNew = this.val().indexOf("new") == 0; var suggestion = field.concrete('ss').suggestValue(this.val()); @@ -97,24 +93,22 @@ field.val(suggestion); } } - }; - }); + }); - /** - * @class ParentID field combination - mostly toggling between - * the two radiobuttons and setting the hidden "ParentID" field - * @name ss.EditForm.parentTypeSelector - */ - $('#Form_EditForm .parentTypeSelector').concrete('ss', function($){ - return/** @lends ss.EditForm.parentTypeSelector */{ + /** + * @class ParentID field combination - mostly toggling between + * the two radiobuttons and setting the hidden "ParentID" field + * @name ss.EditForm.parentTypeSelector + */ + $('#Form_EditForm .parentTypeSelector').concrete(/** @lends ss.EditForm.parentTypeSelector */{ onmatch : function() { var self = this; - this.find(':input[name=ParentType]').bind('click', function(e) {self._toggleSelection(e);}); - this._toggleSelection(); + + this._super(); }, - + _toggleSelection: function(e) { var selected = this.find(':input[name=ParentType]:checked').val(); // reset parent id if 'root' radiobutton is selected @@ -122,40 +116,38 @@ // toggle tree dropdown based on selection this.find('#ParentID').toggle(selected != 'root'); } - }; - }); + }); - /** - * @class Toggle display of group dropdown in "access" tab, - * based on selection of radiobuttons. - * @name ss.Form_EditForm.Access - */ - $('#Form_EditForm #CanViewType, #Form_EditForm #CanEditType').concrete('ss', function($){ - return/** @lends ss.Form_EditForm.Access */{ + /** + * @class Toggle display of group dropdown in "access" tab, + * based on selection of radiobuttons. + * @name ss.Form_EditForm.Access + */ + $('#Form_EditForm #CanViewType, #Form_EditForm #CanEditType').concrete(/** @lends ss.Form_EditForm.Access */{ onmatch: function() { // TODO Decouple var dropdown; if(this.attr('id') == 'CanViewType') dropdown = $('#ViewerGroups'); else if(this.attr('id') == 'CanEditType') dropdown = $('#EditorGroups'); - + this.find('.optionset :input').bind('change', function(e) { dropdown.toggle(e.target.value == 'OnlyTheseUsers'); }); - + // initial state var currentVal = this.find('input[name=' + this.attr('id') + ']:checked').val(); dropdown.toggle(currentVal == 'OnlyTheseUsers'); + + this._super(); } - }; - }); + }); - /** - * @class Email containing the link to the archived version of the page. - * Visible on readonly older versions of a specific page at the moment. - * @name ss.Form_EditForm_action_email - */ - $('#Form_EditForm .Actions #Form_EditForm_action_email').concrete('ss', function($){ - return/** @lends ss.Form_EditForm_action_email */{ + /** + * @class Email containing the link to the archived version of the page. + * Visible on readonly older versions of a specific page at the moment. + * @name ss.Form_EditForm_action_email + */ + $('#Form_EditForm .Actions #Form_EditForm_action_email').concrete(/** @lends ss.Form_EditForm_action_email */{ onclick: function(e) { window.open( 'mailto:?subject=' @@ -164,19 +156,17 @@ + $(':input[name=ArchiveEmailMessage]', this[0].form).val(), 'archiveemail' ); - + return false; } - }; - }); + }); - /** - * @class Open a printable representation of the form in a new window. - * Used for readonly older versions of a specific page. - * @name ss.Form_EditForm_action_print - */ - $('#Form_EditForm .Actions #Form_EditForm_action_print').concrete('ss', function($){ - return/** @lends ss.Form_EditForm_action_print */{ + /** + * @class Open a printable representation of the form in a new window. + * Used for readonly older versions of a specific page. + * @name ss.Form_EditForm_action_print + */ + $('#Form_EditForm .Actions #Form_EditForm_action_print').concrete(/** @lends ss.Form_EditForm_action_print */{ onclick: function(e) { var printURL = $(this[0].form).attr('action').replace(/\?.*$/,'') + '/printable/' @@ -184,22 +174,20 @@ if(printURL.substr(0,7) != 'http://') printURL = $('base').attr('href') + printURL; window.open(printURL, 'printable'); - + return false; } - }; - }); + }); - /** - * @class A "rollback" to a specific version needs user confirmation. - * @name ss.Form_EditForm_action_rollback - */ - $('#Form_EditForm .Actions #Form_EditForm_action_rollback').concrete('ss', function($){ - return/** @lends ss.Form_EditForm_action_rollback */{ + /** + * @class A "rollback" to a specific version needs user confirmation. + * @name ss.Form_EditForm_action_rollback + */ + $('#Form_EditForm .Actions #Form_EditForm_action_rollback').concrete(/** @lends ss.Form_EditForm_action_rollback */{ onclick: function(e) { // @todo i18n return confirm("Do you really want to copy the published content to the stage site?"); } - }; + }); }); }(jQuery)); \ No newline at end of file diff --git a/javascript/CMSMain.Translatable.js b/javascript/CMSMain.Translatable.js index cabe96cd..3fe3c8a9 100755 --- a/javascript/CMSMain.Translatable.js +++ b/javascript/CMSMain.Translatable.js @@ -1,20 +1,20 @@ (function($) { + $.concrete('ss', function($){ - /** - * @class Dropdown with languages above CMS tree, causing a redirect upon translation - * @name ss.CMSMain.LangSelector - */ - $('.CMSMain #Form_LangForm').concrete('ss', function($){ - return/** @lends ss.CMSMain.LangSelector */{ + /** + * @class Dropdown with languages above CMS tree, causing a redirect upon translation + * @name ss.CMSMain.LangSelector + */ + $('.CMSMain #Form_LangForm').concrete(/** @lends ss.CMSMain.LangSelector */{ onmatch: function() { var self = this; - + // monitor form loading for any locale changes $('#Form_EditForm').bind('loadnewpage', function(e) { var newLocale = $(this).find(':input[name=Locale]').val(); if(newLocale) self.val(newLocale); }); - + // whenever a new value is selected, reload the whole CMS in the new locale this.find(':input[name=Locale]').bind('change', function(e) { var url = document.location.href; @@ -24,29 +24,29 @@ document.location = url; return false; }); + + this._super(); } - }; - }); + }); - /** - * Loads /admin/createtranslation, which will create the new record, - * and redirect to an edit form. - * - * @class Dropdown in "Translation" tab in CMS forms, with button to - * trigger translating the currently loaded record. - * @name ss.CMSMain.createtranslation - * @requires jquery.metadata - */ - $('.CMSMain .createTranslation').concrete('ss', function($){ - return/** @lends ss.CMSMain.createtranslation */{ + /** + * Loads /admin/createtranslation, which will create the new record, + * and redirect to an edit form. + * + * @class Dropdown in "Translation" tab in CMS forms, with button to + * trigger translating the currently loaded record. + * @name ss.CMSMain.createtranslation + * @requires jquery.metadata + */ + $('.CMSMain .createTranslation').concrete(/** @lends ss.CMSMain.createtranslation */{ onmatch: function() { var self = this; - + this.find(':input[name=action_createtranslation]').bind('click', function(e) { var form = self.parents('form'); // redirect to new URL // TODO This should really be a POST request - + document.location.href = $('base').attr('href') + jQuery(self).metadata().url + '?ID=' + form.find(':input[name=ID]').val() + @@ -55,8 +55,9 @@ return false; }); + + this._super(); } - }; + }); }); - }(jQuery)); \ No newline at end of file diff --git a/javascript/CMSMain.js b/javascript/CMSMain.js index 3d23451a..7b9ece43 100644 --- a/javascript/CMSMain.js +++ b/javascript/CMSMain.js @@ -1,11 +1,11 @@ (function($) { + $.concrete('ss', function($){ - /** - * @class All forms in the right content panel should have closeable jQuery UI style titles. - * @name ss.contentPanel.form - */ - $('#contentPanel form').concrete('ss', function($){ - return/** @lends ss.contentPanel.form */{ + /** + * @class All forms in the right content panel should have closeable jQuery UI style titles. + * @name ss.contentPanel.form + */ + $('#contentPanel form').concrete(/** @lends ss.contentPanel.form */{ onmatch: function() { // Style as title bar this.find(':header:first').titlebar({ @@ -14,33 +14,27 @@ // The close button should close the east panel of the layout this.find(':header:first .ui-dialog-titlebar-close').bind('click', function(e) { $('body.CMSMain').concrete('ss').MainLayout().close('east'); - return false; }); + + this._super(); } - }; - }); + }); - /** - * @class Control the site tree filter. - * Toggles search form fields based on a dropdown selection, - * similar to "Smart Search" criteria in iTunes. - * @name ss.Form_SeachTreeForm - */ - $('#Form_SearchTreeForm').concrete('ss', function($) { - return/** @lends ss.Form_SeachTreeForm */{ - + /** + * @class Control the site tree filter. + * Toggles search form fields based on a dropdown selection, + * similar to "Smart Search" criteria in iTunes. + * @name ss.Form_SeachTreeForm + */ + $('#Form_SearchTreeForm').concrete(/** @lends ss.Form_SeachTreeForm */{ /** * @type DOMElement */ SelectEl: null, - + onmatch: function() { var self = this; - - // TODO Cant bind to onsubmit/onreset directly because of IE6 - this.bind('submit', function(e) {return self._submitForm(e);}); - this.bind('reset', function(e) {return self._resetForm(e);}); // only the first field should be visible by default this.find('.field').not(':first').hide(); @@ -52,39 +46,40 @@ ); this._setOptions(); - - }, + this._super(); + }, + _setOptions: function() { var self = this; - + // reset existing elements - self.SelectEl().find('option').remove(); - + self.getSelectEl().find('option').remove(); + // add default option // TODO i18n - jQuery('').appendTo(self.SelectEl()); - + jQuery('').appendTo(self.getSelectEl()); + // populate dropdown values from existing fields this.find('.field').each(function() { - $('