ENHANCEMENT Moved cms/javascript documentation from JSDoc to NaturalDocs format

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@104369 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2010-05-08 02:45:05 +00:00
parent 24fb77ab73
commit ecbee33385
24 changed files with 733 additions and 159 deletions

View File

@ -1,6 +1,12 @@
/**
* File: AssetAdmin.DragDrop.js
*/
(function($) {
$.entwine('ss', function($){
/**
* Class: .AssetTableField.dragdrop
*/
$('.AssetTableField.dragdrop').entwine({
onmatch: function() {
var self = this;
@ -15,6 +21,8 @@
this._super();
},
/**
* Function: drop
*
* Take selected files and move them to a folder target in the tree.
*/
drop: function(e, ui) {
@ -30,11 +38,15 @@
)
}
},
/**
* Function: getSelected
*
* Get the IDs of all selected files in the table.
* Used for drag'n'drop.
*
* @return Array
* Returns:
* Array
*/
getSelected: function() {
return this.find(':input[name=Files\[\]]:checked').map(function() {
@ -44,6 +56,7 @@
});
$('.AssetTableField .dragfile').entwine({
// Constructor: onmatch
onmatch: function() {
var self = this;
var container = this.parents('.AssetTableField');
@ -64,6 +77,11 @@
this._super();
},
/**
* Function: onmousedown
*
* Parameters:
* (Event) e
*
* Automatically select the checkbox in the same table row
* to signify that this element is moved, and hint that
* all checkboxed elements will be moved along with it.

View File

@ -1,3 +1,7 @@
/**
* File: AssetAdmin.js
*/
/**
* Configuration for the left hand tree
*/
@ -36,7 +40,18 @@ var _HANDLER_FORMS = {
});
$.entwine('ss', function($){
/**
* Class: #Form_SyncForm
*/
$('#Form_SyncForm').entwine({
/**
* Function: onsubmit
*
* Parameters:
* (Event) e
*/
onsubmit: function(e) {
var button = jQuery(this).find(':submit:first');
button.addClass('loading');

View File

@ -1,7 +1,14 @@
/**
* File: AssetTableField.js
*/
(function($) {
$.entwine('ss', function($){
/**
* Class: .AssetTableField
*/
$('.AssetTableField').entwine({
// Constructor: onmatch
onmatch: function() {
var self = this;
@ -30,6 +37,12 @@
this._super();
},
/**
* Function: refresh
*
* Parameters:
* (Function) callback
*/
refresh: function(callback) {
var self = this;
this.load(
@ -44,9 +57,12 @@
});
/**
* Class: .AssetTableField :checkbox
*
* Checkboxes used to batch delete files
*/
$('.AssetTableField :checkbox').entwine({
// Function: onchange
onchange: function() {
var container = this.parents('.AssetTableField');
var input = container.find('input#deletemarked');
@ -59,14 +75,24 @@
})
/**
* Class: .AssetTableField input#deletemarked
*
* Batch delete files marked by checkboxes in the table.
* Refreshes the form field afterwards via ajax.
*/
$('.AssetTableField input#deletemarked').entwine({
// Constructor: onmatch
onmatch: function() {
this.attr('disabled', 'disabled');
this._super();
},
/**
* Function: onclick
*
* Parameters:
* (Event) e
*/
onclick: function(e) {
if(!confirm(ss.i18n._t('AssetTableField.REALLYDELETE'))) return false;

View File

@ -1,25 +1,44 @@
(function($) {
$.entwine('ss', function($){
/**
* Alert the user on change of page-type - this might have implications
* Class: #Form_EditForm :input[name=ClassName]
* 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]').entwine(/** @lends ss.EditFormClassName */{
$('#Form_EditForm :input[name=ClassName]').entwine({
// Function: onchange
onchange: function() {
alert(ss.i18n._t('CMSMAIN.ALERTCLASSNAME'));
}
});
/**
* @class Input validation on the URLSegment field
* @name ss.EditForm.URLSegment
* Class: #Form_EditForm input[name=URLSegment]
*
* Input validation on the URLSegment field
*/
$('#Form_EditForm input[name=URLSegment]').entwine(/** @lends ss.EditForm.URLSegment */{
$('#Form_EditForm input[name=URLSegment]').entwine({
/**
* Property: FilterRegex
* Regex
*/
FilterRegex: /[^A-Za-z0-9-]+/,
/**
* Property: ValidationMessage
* String
*/
ValidationMessage: ss.i18n._t('CMSMAIN.URLSEGMENTVALIDATION'),
/**
* Property: MaxLength
* Int
*/
MaxLength: 50,
/**
* Constructor: onmatch
*/
onmatch : function() {
var self = this;
@ -36,16 +55,27 @@
},
/**
* Function: suggestValue
*
* Return a value matching the criteria.
*
* @param {String} val
* @return val
* Parameters:
* (String) val
*
* Returns:
* String
*/
suggestValue: function(val) {
// TODO Do we want to enforce lowercasing in URLs?
return val.substr(0, this.getMaxLength()).replace(this.getFilterRegex(), '').toLowerCase();
},
/**
* Function: validate
*
* Returns:
* Boolean
*/
validate: function() {
return (
this.val().length > this.getMaxLength()
@ -55,10 +85,12 @@
});
/**
* @class Input validation on the Title field
* @name ss.EditForm.Title
* Class: #Form_EditForm input[name=Title]
*
* Input validation on the Title field
*/
$('#Form_EditForm input[name=Title]').entwine(/** @lends ss.EditForm.Title */{
$('#Form_EditForm input[name=Title]').entwine({
// Constructor: onmatch
onmatch : function() {
var self = this;
@ -71,6 +103,12 @@
this._super();
},
/**
* Function: updateURLSegment
*
* Parameters:
* (DOMElement) field
*/
updateURLSegment: function(field) {
if(!field || !field.length) return;
@ -96,11 +134,13 @@
});
/**
* @class ParentID field combination - mostly toggling between
* Class: #Form_EditForm .parentTypeSelector
*
* ParentID field combination - mostly toggling between
* the two radiobuttons and setting the hidden "ParentID" field
* @name ss.EditForm.parentTypeSelector
*/
$('#Form_EditForm .parentTypeSelector').entwine(/** @lends ss.EditForm.parentTypeSelector */{
$('#Form_EditForm .parentTypeSelector').entwine({
// Constructor: onmatch
onmatch : function() {
var self = this;
this.find(':input[name=ParentType]').bind('click', function(e) {self._toggleSelection(e);});
@ -109,6 +149,12 @@
this._super();
},
/**
* Function: _toggleSelection
*
* Parameters:
* (Event) e
*/
_toggleSelection: function(e) {
var selected = this.find(':input[name=ParentType]:checked').val();
// reset parent id if 'root' radiobutton is selected
@ -119,11 +165,13 @@
});
/**
* @class Toggle display of group dropdown in "access" tab,
* Class: #Form_EditForm #CanViewType, #Form_EditForm #CanEditType
*
* Toggle display of group dropdown in "access" tab,
* based on selection of radiobuttons.
* @name ss.Form_EditForm.Access
*/
$('#Form_EditForm #CanViewType, #Form_EditForm #CanEditType').entwine(/** @lends ss.Form_EditForm.Access */{
$('#Form_EditForm #CanViewType, #Form_EditForm #CanEditType').entwine({
// Constructor: onmatch
onmatch: function() {
// TODO Decouple
var dropdown;
@ -143,11 +191,18 @@
});
/**
* @class Email containing the link to the archived version of the page.
* Class: #Form_EditForm .Actions #Form_EditForm_action_email
*
* 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').entwine(/** @lends ss.Form_EditForm_action_email */{
$('#Form_EditForm .Actions #Form_EditForm_action_email').entwine({
/**
* Function: onclick
*
* Parameters:
* (Event) e
*/
onclick: function(e) {
window.open(
'mailto:?subject='
@ -162,11 +217,18 @@
});
/**
* @class Open a printable representation of the form in a new window.
* Class: #Form_EditForm .Actions #Form_EditForm_action_print
*
* 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').entwine(/** @lends ss.Form_EditForm_action_print */{
$('#Form_EditForm .Actions #Form_EditForm_action_print').entwine({
/**
* Function: onclick
*
* Parameters:
* (Event) e
*/
onclick: function(e) {
var printURL = $(this[0].form).attr('action').replace(/\?.*$/,'')
+ '/printable/'
@ -180,10 +242,18 @@
});
/**
* @class A "rollback" to a specific version needs user confirmation.
* @name ss.Form_EditForm_action_rollback
* Class: #Form_EditForm .Actions #Form_EditForm_action_rollback
*
* A "rollback" to a specific version needs user confirmation.
*/
$('#Form_EditForm .Actions #Form_EditForm_action_rollback').entwine(/** @lends ss.Form_EditForm_action_rollback */{
$('#Form_EditForm .Actions #Form_EditForm_action_rollback').entwine({
/**
* Function: onclick
*
* Parameters:
* (Event) e
*/
onclick: function(e) {
// @todo i18n
var form = this.parents('form:first'), version = form.find(':input[name=Version]').val(), message = '';

View File

@ -1,11 +1,18 @@
/**
* File: CMSMain.Translatable.js
*/
(function($) {
$.entwine('ss', function($){
/**
* @class Dropdown with languages above CMS tree, causing a redirect upon translation
* @name ss.CMSMain.LangSelector
* Class: .CMSMain #Form_LangForm
*
* Dropdown with languages above CMS tree, causing a redirect upon translation
*/
$('.CMSMain #Form_LangForm').entwine(/** @lends ss.CMSMain.LangSelector */{
$('.CMSMain #Form_LangForm').entwine({
/**
* Constructor: onmatch
*/
onmatch: function() {
var self = this;
@ -30,15 +37,22 @@
});
/**
* Class: .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
* Dropdown in "Translation" tab in CMS forms, with button to
* trigger translating the currently loaded record.
* @name ss.CMSMain.createtranslation
* @requires jquery.metadata
*
* Requires:
* jquery.metadata
*/
$('.CMSMain .createTranslation').entwine(/** @lends ss.CMSMain.createtranslation */{
$('.CMSMain .createTranslation').entwine({
/**
* Constructor: onmatch
*/
onmatch: function() {
var self = this;

View File

@ -1,12 +1,12 @@
/**
* File: CMSMain.Tree.js
*/
if(typeof SiteTreeHandlers == 'undefined') SiteTreeHandlers = {};
SiteTreeHandlers.parentChanged_url = 'admin/ajaxupdateparent';
SiteTreeHandlers.orderChanged_url = 'admin/ajaxupdatesort';
SiteTreeHandlers.loadPage_url = 'admin/getitem';
SiteTreeHandlers.loadTree_url = 'admin/getsubtree';
/**
* Tree context menu
*/
TreeContextMenu = {
'Edit this page' : function(treeNode) {
treeNode.selectTreeNode();

View File

@ -1,11 +1,16 @@
/**
* File: CMSMain.js
*/
(function($) {
$.entwine('ss', function($){
/**
* @class All forms in the right content panel should have closeable jQuery UI style titles.
* @name ss.contentPanel.form
* Class: #contentPanel form
*
* All forms in the right content panel should have closeable jQuery UI style titles.
*/
$('#contentPanel form').entwine(/** @lends ss.contentPanel.form */{
$('#contentPanel form').entwine({
// Constructor: onmatch
onmatch: function() {
// Style as title bar
this.find(':header:first').titlebar({
@ -22,17 +27,22 @@
});
/**
* @class Control the site tree filter.
* Class: #Form_SearchTreeForm
*
* 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').entwine(/** @lends ss.Form_SeachTreeForm */{
$('#Form_SearchTreeForm').entwine({
/**
* @type DOMElement
* Variable: SelectEl
* {DOMElement}
*/
SelectEl: null,
/**
* Constructor: onmatch
*/
onmatch: function() {
var self = this;
@ -57,6 +67,9 @@
this._super();
},
/**
* Function: _setOptions
*/
_setOptions: function() {
var self = this;
@ -80,6 +93,8 @@
},
/**
* Function: onsubmit
*
* Filter tree based on selected criteria.
*/
onsubmit: function(e) {
@ -109,6 +124,12 @@
return false;
},
/**
* Function: onreset
*
* Parameters:
* (Event) e
*/
onreset: function(e) {
this.find('.field :input').clearFields();
this.find('.field').not('.show-default').hide();
@ -127,6 +148,12 @@
return false;
},
/**
* Function: _addField
*
* Parameters:
* (Event) e
*/
_addField: function(e) {
var $select = $(e.target);
// show formfield matching the option
@ -141,6 +168,9 @@
return false;
},
/**
* Function: _reloadSitetree
*/
_reloadSitetree: function() {
var self = this;
@ -160,13 +190,17 @@
});
/**
* @class Simple form with a page type dropdown
* Class: Form_SideReportsForm
*
* Simple form with a page type dropdown
* which creates a new page through #Form_EditForm and adds a new tree node.
* @name ss.reports_holder
*/
$('#Form_SideReportsForm').entwine(/** @lends ss.reports_holder */{
ReportContainer: null,
/**
* Constructor: onmatch
*/
onmatch: function() {
var self = this;
@ -185,6 +219,12 @@
this._super();
},
/**
* Function: onsubmit
*
* Parameters:
* (Event) e
*/
onsubmit: function(e) {
var self = this;
@ -213,9 +253,15 @@
});
/**
* Class: #SideReportsHolder form
*
* All forms loaded via ajax from the Form_SideReports dropdown.
*/
$("#SideReportsHolder form").entwine({
/**
* Function: onsubmit
*/
onsubmit: function() {
var self = this;
@ -244,6 +290,10 @@
* Register the onclick handler that loads the page into EditForm
*/
$("#SideReportsHolder form ul a").entwine({
/**
* Function: onclick
*/
onclick: function(e) {
if (e.button!=2) {
var $link = $(this);
@ -261,11 +311,11 @@
});
/**
* @class Simple form showing versions of a specific page.
* @name ss.Form_VersionsForm
* @requires ss.i18n
* Class: #Form_VersionsForm
*
* Simple form showing versions of a specific page.
*/
$('#Form_VersionsForm').entwine(/** @lends ss.Form_VersionsForm */{
$('#Form_VersionsForm').entwine({
onmatch: function() {
var self = this;
@ -341,8 +391,11 @@
},
/**
* @param {boolean} loadEditForm Determines if responses should show in current panel,
* or in the edit form (in the case of 'compare versions').
* Function: _submit
*
* Parameters:
* (bool) loadEditForm - Determines if responses should show in current panel,
* or in the edit form (in the case of 'compare versions').
*/
_submit: function(loadEditForm) {
var self = this;

View File

@ -1,5 +1,16 @@
/**
* File: CommentTableField.js
*/
/**
* Class: CommentTableField
*/
CommentTableField = Class.create();
CommentTableField.prototype = {
/**
* Constructor: initialize
*/
initialize: function() {
var rules = {};
@ -35,6 +46,9 @@ CommentTableField.prototype = {
Behaviour.register(rules);
},
/**
* Function: removeRowAfterAjax
*/
removeRowAfterAjax: function(e) {
var img = Event.element(e);
var link = Event.findElement(e,"a");
@ -55,7 +69,14 @@ CommentTableField.prototype = {
Event.stop(e);
},
// prevent submission of wrong form-button (CommentFilterButton)
/**
* Function: prepareSearch
*
* prevent submission of wrong form-button (CommentFilterButton)
*
* Parameters:
* (Event) e
*/
prepareSearch: function(e) {
// IE6 doesnt send an event-object with onkeypress
var event = (e) ? e : window.event;
@ -72,9 +93,16 @@ CommentTableField.prototype = {
CommentTableField.applyTo('div.CommentTableField');
/**
* Class: CommentFilterButton
*/
CommentFilterButton = Class.create();
CommentFilterButton.applyTo('#CommentFilterButton');
CommentFilterButton.prototype = {
/**
* Constructor: initialize
*/
initialize: function() {
this.inputFields = new Array();
@ -99,10 +127,22 @@ CommentFilterButton.prototype = {
}
},
/**
* Function: isChanged
*
* Returns:
* (boolean)
*/
isChanged: function() {
return false;
},
/**
* Function: onclick
*
* Parameters:
* (Event) e
*/
onclick: function(e) {
try {
var form = Event.findElement(e,"form");

View File

@ -1,28 +1,40 @@
/**
* File: LeftAndMain.AddForm.js
*/
(function($) {
$.entwine('ss', function($){
/**
* @class Simple form with a page type dropdown
* Class: #Form_AddForm
*
* Simple form with a page type dropdown
* which creates a new page through #Form_EditForm and adds a new tree node.
* @name ss.Form_AddForm
* @requires ss.i18n
* @requires ss.Form_EditForm
*
* Requires:
* ss.i18n
* #Form_EditForm
*/
$('#Form_AddForm').entwine(/** @lends ss.Form_AddForm */{
$('#Form_AddForm').entwine({
/**
* @type DOMElement
* Variable: Tree
* (DOMElement)
*/
Tree: null,
/**
* @type Array Map of <option> values to an object of "title" and "value"
* Variable: OrigOptions
* (Array) Map of <option> values to an object of "title" and "value"
*/
OrigOptions: null,
/**
* @type Array Internal counter to create unique page identifiers prior to ajax saving
* Variable: NewPages
* (Array) Internal counter to create unique page identifiers prior to ajax saving
*/
NewPages: [],
/**
* Constructor: onmatch
*/
onmatch: function() {
var self = this, typeDropdown = this.find(':input[name=PageType]');
@ -47,6 +59,12 @@
this._super();
},
/**
* Function: onsubmit
*
* Parameters:
* (Event) e
*/
onsubmit: function(e) {
var newPages = this.getNewPages();
var tree = this.getTree();
@ -86,6 +104,12 @@
return false;
},
/**
* Function: refresh
*
* Parameters:
* (DOMElement) selectedNode
*/
refresh: function(selectedNode) {
// Note: Uses siteTreeHints global
var tree = this.getTree(),

View File

@ -1,31 +1,40 @@
/**
* File: LeftAndMain.BatchActions.js
*/
(function($) {
$.entwine('ss', function($){
/**
* @class Batch actions which take a bunch of selected pages,
* Class: #Form_BatchActionsForm
*
* Batch actions which take a bunch of selected pages,
* usually from the CMS tree implementation, and perform serverside
* callbacks on the whole set. We make the tree selectable when the jQuery.UI tab
* enclosing this form is opened.
* @name ss.Form_BatchActionsForm
*
* Events:
* - register: Called before an action is added.
* - unregister: Called before an action is removed.
* register - Called before an action is added.
* unregister - Called before an action is removed.
*/
$('#Form_BatchActionsForm').entwine(/** @lends ss.Form_BatchActionsForm */{
$('#Form_BatchActionsForm').entwine({
/**
* @type {DOMElement}
* Variable: Tree
* (DOMElement)
*/
Tree: null,
/**
* @type {Array} Stores all actions that can be performed on the collected IDs as
* Variable: Actions
* (Array) Stores all actions that can be performed on the collected IDs as
* function closures. This might trigger filtering of the selected IDs,
* a confirmation message, etc.
*/
Actions: [],
/**
* Constructor: onmatch
*/
onmatch: function() {
var self = this;
@ -52,8 +61,12 @@
},
/**
* @param {String} type
* @param {Function} callback
* Function: register
*
* Parameters:
*
* (String) type - ...
* (Function) callback - ...
*/
register: function(type, callback) {
this.trigger('register', {type: type, callback: callback});
@ -63,9 +76,13 @@
},
/**
* Function: unregister
*
* Remove an existing action.
*
* @param {String} type
* Parameters:
*
* {String} type
*/
unregister: function(type) {
this.trigger('unregister', {type: type});
@ -76,19 +93,27 @@
},
/**
* Function: _isActive
*
* Determines if we should allow and track tree selections.
*
* @todo Too much coupling with tabset
* @return boolean
* Todo:
* Too much coupling with tabset
*
* Returns:
* (boolean)
*/
_isActive: function() {
return $('#TreeActions-batchactions').is(':visible');
},
/**
* Function: refreshSelected
*
* Ajax callbacks determine which pages is selectable in a certain batch action.
*
* @param {Object} rootNode
* Parameters:
* {Object} rootNode
*/
refreshSelected : function(rootNode) {
var self = this, st = this.getTree(), ids = this.getIDs(), allIds = [];
@ -133,6 +158,12 @@
});
},
/**
* Function: serializeFromTree
*
* Returns:
* (boolean)
*/
serializeFromTree: function() {
var tree = this.getTree(), ids = [];
@ -156,19 +187,31 @@
},
/**
* @param {Array} ids
* Function: setIDS
*
* Parameters:
* {Array} ids
*/
setIDs: function(ids) {
this.find(':input[name=csvIDs]').val(ids.join(','));
},
/**
* @return {Array}
* Function: getIDS
*
* Returns:
* {Array}
*/
getIDs: function() {
return this.find(':input[name=csvIDs]').val().split(',');
},
/**
* Function: onsubmit
*
* Parameters:
* (Event) e
*/
onsubmit: function(e) {
var ids = this.getIDs();
var tree = this.getTree();
@ -259,7 +302,10 @@
},
/**
* @todo This is simulating MultiselectTree functionality, and shouldn't be necessary.
* Function: _multiselectTransform
*
* Todo:
* This is simulating MultiselectTree functionality, and shouldn't be necessary.
*/
_multiselectTransform : function() {
// make tree selectable
@ -280,8 +326,12 @@
},
/**
* Function: _treeSelectionChanged
*
* Only triggers if the field is considered 'active'.
* @todo Most of this is basically simulating broken behaviour of the MultiselectTree mixin,
*
* Todo:
* Most of this is basically simulating broken behaviour of the MultiselectTree mixin,
* and should be removed.
*/
_treeSelectionChanged: function(node) {
@ -310,7 +360,17 @@
});
});
/**
* Class: #Form_BatchActionsForm :select[name=Action]
*/
$('#Form_BatchActionsForm :select[name=Action]').entwine({
/**
* Function: onchange
*
* Parameters:
* (Event) e
*/
onchange: function(e) {
$(e.target.form).entwine('ss').refreshSelected();
}

View File

@ -1,31 +1,41 @@
/**
* File: LeftAndMain.EditForm.js
*/
(function($) {
$.entwine('ss', function($){
/**
* @class Base edit form, provides ajaxified saving
* Class: #Form_EditForm
*
* 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
* @require jquery.changetracker
*
* <h3>Events</h3>
* - ajaxsubmit: Form is about to be submitted through ajax
* - validate: Contains validation result
* - removeform: A form is about to be removed from the DOM
* - load: Form is about to be loaded through ajax
* Events:
* ajaxsubmit - Form is about to be submitted through ajax
* validate - Contains validation result
* removeform - A form is about to be removed from the DOM
* load - Form is about to be loaded through ajax
*/
$('#Form_EditForm').entwine(/** @lends ss.Form_EditForm */{
/**
* @type String HTML text to show when no form content is chosen.
* Will show inside the <form> tag.
* Variable: PlaceholderHtml
* (String_ HTML text to show when no form content is chosen.
* Will show inside the <form> tag.
*/
PlaceholderHtml: '',
/**
* @type Object
* Variable: ChangeTrackerOptions
* (Object)
*/
ChangeTrackerOptions: {},
/**
* Constructor: onmatch
*/
onmatch: function() {
var self = this;
@ -37,6 +47,9 @@
this._super();
},
/**
* Function: _setupChangeTracker
*/
_setupChangeTracker: function() {
// Don't bind any events here, as we dont replace the
// full <form> tag by any ajax updates they won't automatically reapply
@ -44,11 +57,16 @@
},
/**
* Function: _checkChangeTracker
*
* Checks the jquery.changetracker plugin status for this form.
* Usually bound to window.onbeforeunload.
*
* @param {boolean} isUnloadEvent
* @return Either a string with a confirmation message, or the result of a confirm() dialog,
* Parameters:
* {boolean} isUnloadEvent - ..
*
* Returns:
* (String) Either a string with a confirmation message, or the result of a confirm() dialog,
* based on the isUnloadEvent parameter.
*/
_checkChangeTracker: function(isUnloadEvent) {
@ -70,9 +88,9 @@
},
/**
* Suppress submission unless it is handled through ajaxSubmit().
* Function: onsubmit
*
* @param {Event} e
* Suppress submission unless it is handled through ajaxSubmit().
*/
onsubmit: function(e) {
this.ajaxSubmit();
@ -81,10 +99,16 @@
},
/**
* @param {DOMElement} button The pressed button (optional)
* @param {Function} callback Called in complete() handler of jQuery.ajax()
* @param {Object} ajaxOptions Object literal to merge into $.ajax() call
* @param {boolean} loadResponse Render response through _loadResponse() (Default: true)
* Function: ajaxSubmit
*
* Parameters:
* {DOMElement} button - The pressed button (optional)
* {Function} callback - Called in complete() handler of jQuery.ajax()
* {Object} ajaxOptions - Object literal to merge into $.ajax() call
* {boolean} loadResponse - Render response through _loadResponse() (Default: true)
*
* Returns:
* (boolean)
*/
ajaxSubmit: function(button, callback, ajaxOptions, loadResponse) {
var self = this;
@ -140,12 +164,16 @@
},
/**
* Function: validate
*
* Hook in (optional) validation routines.
* Currently clientside validation is not supported out of the box in the CMS.
*
* @todo Placeholder implementation
* Todo:
* Placeholder implementation
*
* @return {boolean}
* Returns:
* {boolean}
*/
validate: function() {
var isValid = true;
@ -155,9 +183,15 @@
},
/**
* @param {String} url
* @param {Function} callback (Optional) Called after the form content as been loaded
* @param {ajaxOptions} Object literal merged into the jQuery.ajax() call (Optional)
* Function: loadForm
*
* Parameters:
* (String) url - ..
* (Function) callback - (Optional) Called after the form content as been loaded
* (Object) ajaxOptions - Object literal merged into the jQuery.ajax() call (Optional)
*
* Returns:
* (XMLHTTPRequest)
*/
loadForm: function(url, callback, ajaxOptions) {
var self = this;
@ -189,11 +223,14 @@
},
/**
* Function: removeForm
*
* Remove everying inside the <form> tag
* with a custom HTML fragment. Useful e.g. for deleting a page in the CMS.
* Checks for unsaved changes before removing the form
*
* @param {String} placeholderHtml Short note why the form has been removed, displayed in <p> tags.
* Parameters:
* {String} placeholderHtml - Short note why the form has been removed, displayed in <p> tags.
* Falls back to the default RemoveText() option (Optional)
*/
removeForm: function(placeholderHtml) {
@ -207,6 +244,8 @@
},
/**
* Function: cleanup
*
* Remove all the currently active TinyMCE editors.
* Note: Everything that calls this externally has an inappropriate coupling to TinyMCE.
*/
@ -221,12 +260,15 @@
},
/**
* @param {String} data Either HTML for straight insertion, or eval'ed JavaScript.
* Function: _loadResponse
*
* Parameters:
* {String} data - Either HTML for straight insertion, or eval'ed JavaScript.
* If passed as HTML, it is assumed that everying inside the <form> tag is replaced,
* but the old <form> tag itself stays intact.
* @param {String} status
* @param {XMLHTTPRequest} xmlhttp
* @param {Array} origData The original submitted data, useful to do comparisons of changed
* {String} status
* {XMLHTTPRequest} xmlhttp - ..
* {Array} origData - The original submitted data, useful to do comparisons of changed
* values in new form output, e.g. to detect a URLSegment being changed on the serverside.
* Array in jQuery serializeArray() notation.
*/
@ -287,12 +329,17 @@
});
/**
* @class All buttons in the right CMS form go through here by default.
* Class: #Form_EditForm .Actions :submit
*
* All buttons in the right CMS form go through here by default.
* We need this onclick overloading because we can't get to the
* clicked button from a form.onsubmit event.
* @name ss.Form_EditForm.Actions.submit
*/
$('#Form_EditForm .Actions :submit').entwine(/** @lends ss.Form_EditForm.Actions.submit */{
$('#Form_EditForm .Actions :submit').entwine({
/**
* Function: onclick
*/
onclick: function(e) {
jQuery('#Form_EditForm').entwine('ss').ajaxSubmit(this);
return false;
@ -300,10 +347,15 @@
});
/**
* @class Add tinymce to HtmlEditorFields within the CMS.
* @name ss.Form_EditForm.textarea.htmleditor
* Class: #Form_EditForm textarea.htmleditor
*
* Add tinymce to HtmlEditorFields within the CMS.
*/
$('#Form_EditForm textarea.htmleditor').entwine(/** @lends ss.Form_EditForm.Actions.submit */{
$('#Form_EditForm textarea.htmleditor').entwine({
/**
* Constructor: onmatch
*/
onmatch : function() {
tinyMCE.execCommand("mceAddControl", true, this.attr('id'));
this.isChanged = function() {

View File

@ -1,3 +1,7 @@
/**
* File: LeftAndMain.Tree.js
*/
/**
* LeftAndMain_left.js
* Code for supporting the left-hand panel of all the 2-pane admin windows
@ -34,6 +38,8 @@ var _HANDLER_FORMS = {
var TreeContextMenu = null;
/**
* Class: TreeAPI
*
* Extra methods for the tree when used in the LHS of the CMS
*/
TreeAPI = Class.create();

View File

@ -1,6 +1,10 @@
/**
* @type jquery.layout Global variable so layout state management
* can pick it up.
* File: LeftAndMain.js
*/
/**
* Variable: ss_MainLayout
* jquery.layout Global variable so layout state management can pick it up.
*/
var ss_MainLayout;
@ -18,29 +22,32 @@ var ss_MainLayout;
}
});
/**
* Available Custom Events:
* <ul>
* <li>ajaxsubmit</li>
* <li>validate</li>
* <li>loadnewpage</li>
/**
* Class: .LeftAndMain
*
* @class Main LeftAndMain interface with some control
* panel and an edit form.
* @name ss.LeftAndMain
* Main LeftAndMain interface with some control panel and an edit form.
*
* Events:
* ajaxsubmit - ...
* validate - ...
* loadnewpage - ...
*/
$('.LeftAndMain').entwine(/** @lends ss.EditMemberProfile */{
$('.LeftAndMain').entwine({
/**
* Reference to jQuery.layout element
* @type Object
* Variable: MainLayout
* (Object) Reference to jQuery.layout element
*/
MainLayout: null,
/**
* @type Number Interval in which /Security/ping will be checked for a valid login session.
* Variable: PingIntervalSeconds
* (Number) Interval in which /Security/ping will be checked for a valid login session.
*/
PingIntervalSeconds: 5*60,
/**
* Constructor: onmatch
*/
onmatch: function() {
var self = this;
@ -85,6 +92,8 @@ var ss_MainLayout;
},
/**
* Function: _setupLayout
*
* Initialize jQuery layout manager with the following panes:
* - east: Tree, Page Version History, Site Reports
* - center: Form
@ -150,6 +159,8 @@ var ss_MainLayout;
},
/**
* Function: _setupPinging
*
* This function is called by prototype when it receives notification that the user was logged out.
* It uses /Security/ping for this purpose, which should return '1' if a valid user session exists.
* It redirects back to the login form if the URL is either unreachable, or returns '0'.
@ -177,9 +188,13 @@ var ss_MainLayout;
},
/**
* Function: _resizeChildren
*
* Resize elements in center panel
* to fit the boundary box provided by the layout manager.
* TODO Replace with automated less ugly parent/sibling traversal
*
* Todo:
* Replace with automated less ugly parent/sibling traversal
*/
_resizeChildren: function() {
$("#treepanes", this).accordion("resize");
@ -199,13 +214,17 @@ var ss_MainLayout;
});
/**
* @class Make all buttons "hoverable" with jQuery theming.
* Class: .LeftAndMain :submit, .LeftAndMain button, .LeftAndMain :reset
*
* Make all buttons "hoverable" with jQuery theming.
* Also sets the clicked button on a form submission, making it available through
* a new 'clickedButton' property on the form DOM element.
*
* @name ss.LeftAndMain.Buttons
*/
$('.LeftAndMain :submit, .LeftAndMain button, .LeftAndMain :reset').entwine(/** @lends ss.LeftAndMain.Buttons */{
$('.LeftAndMain :submit, .LeftAndMain button, .LeftAndMain :reset').entwine({
/**
* Constructor: onmatch
*/
onmatch: function() {
this.addClass(
'ui-state-default ' +
@ -239,11 +258,14 @@ var ss_MainLayout;
});
/**
* @class Container for tree actions like "create", "search", etc.
* @name ss.TreeActions
* Class: #TreeActions
*
* Container for tree actions like "create", "search", etc.
*/
$('#TreeActions').entwine(/** @lends ss.TreeActions */{
$('#TreeActions').entwine({
/**
* Constructor: onmatch
*
* Setup "create", "search", "batch actions" layers above tree.
* All tab contents are closed by default.
*/
@ -257,11 +279,15 @@ var ss_MainLayout;
});
/**
* @class Link for editing the profile for a logged-in member
* through a modal dialog.
* @name ss.EditMemberProfile
* Class: a#EditMemberProfile
*
* Link for editing the profile for a logged-in member through a modal dialog.
*/
$('a#EditMemberProfile').entwine(/** @lends ss.EditMemberProfile */{
$('a#EditMemberProfile').entwine({
/**
* Constructor: onmatch
*/
onmatch: function() {
var self = this;
@ -297,6 +323,9 @@ var ss_MainLayout;
$('#ss-ui-dialog-iframe').bind('load', function(e) {self._resize();});
},
/**
* Function: _openPopup
*/
_openPopup: function(e) {
$('#ss-ui-dialog-iframe').attr('src', this.attr('href'));
@ -305,6 +334,9 @@ var ss_MainLayout;
return false;
},
/**
* Function: _resize
*/
_resize: function() {
var iframe = $('#ss-ui-dialog-iframe');
var container = $('#ss-ui-dialog');
@ -323,6 +355,9 @@ var ss_MainLayout;
this._saveState();
},
/**
* Function: _saveState
*/
_saveState: function() {
var container = $('#ss-ui-dialog');
@ -345,18 +380,25 @@ var ss_MainLayout;
});
/**
* @class Links for viewing the currently loaded page
* Class: #switchView a
*
* Links for viewing the currently loaded page
* in different modes: 'live', 'stage' or 'archived'.
* Automatically updates on loading a new page.
* @name ss.switchViewLinks
* @requires jquery.metadata
*
* Requires:
* jquery.metadata
*/
$('#switchView a').entwine(/** @lends ss.switchViewLinks */{
$('#switchView a').entwine({
/**
* @type DOMElement
* Variable: Form
* (DOMElement)
*/
Form: null,
/**
* Constructor: onmatch
*/
onmatch: function() {
var self = this;
this.setForm($('#Form_EditForm'));
@ -368,6 +410,8 @@ var ss_MainLayout;
},
/**
* Function: refresh
*
* Parse new links based on the underlying form URLSegment,
* preserving the ?stage URL parameters if necessary.
*/
@ -388,6 +432,9 @@ var ss_MainLayout;
this.toggle((urlSegment));
},
/**
* Function: onclick
*/
onclick: function(e) {
// Open in popup
window.open($(e.target).attr('href'));

View File

@ -1,5 +1,11 @@
/**
* File: MemberImportForm.js
*/
(function($) {
$.entwine('ss', function($){
/**
* Class: .import-form .advanced
*/
$('.import-form .advanced').entwine({
onmatch: function() {
this._super();
@ -8,7 +14,14 @@
}
});
/**
* Class: .import-form a.toggle-advanced
*/
$('.import-form a.toggle-advanced').entwine({
/**
* Function: onclick
*/
onclick: function(e) {
this.parents('form:eq(0)').find('.advanced').toggle();
return false;

View File

@ -1,6 +1,11 @@
/**
* File: MemberTableField.js
*/
(function($) {
$.entwine('ss', function($){
/**
* Class: #Permissions .checkbox[value=ADMIN]
*
* Automatically check and disable all checkboxes if ADMIN permissions are selected.
* As they're disabled, any changes won't be submitted (which is intended behaviour),
* checking all boxes is purely presentational.
@ -11,9 +16,15 @@
this._super();
},
/**
* Function: onclick
*/
onclick: function(e) {
this.toggleCheckboxes();
},
/**
* Function: toggleCheckboxes
*/
toggleCheckboxes: function() {
var self = this, checkboxes = this.parents('.field:eq(0)').find('.checkbox').not(this);
@ -48,6 +59,8 @@ if(typeof(ComplexTableField) != 'undefined') {
}
/**
* Class: AjaxMemberLookup
*
* Auto-lookup on ajax fields
*/
AjaxMemberLookup = {
@ -79,6 +92,9 @@ AjaxMemberLookup = {
}
}
/**
* Class: MemberTableField
*/
MemberTableField = Class.create();
MemberTableField.applyTo('#Form_EditForm div.MemberTableField');
MemberTableField.prototype = {
@ -247,6 +263,9 @@ MemberTableField.prototype = {
*/
}
/**
* Class: MemberFilterButton
*/
MemberFilterButton = Class.create();
MemberFilterButton.applyTo('#MemberFilterButton');
MemberFilterButton.prototype = {

View File

@ -1,3 +1,10 @@
/**
* File: MemberTableField_popup.js
*/
/**
* Class: MemberTableFieldPopupForm
*/
MemberTableFieldPopupForm = Class.extend("ComplexTableFieldPopupForm");
MemberTableFieldPopupForm.prototype = {
initialize: function() {

View File

@ -1,6 +1,11 @@
/**
* File: ModelAdmin.History.js
*/
(function($) {
$.entwine('ss', function($){
/**
* Class: .ModelAdmin
*
* A simple ajax browser history implementation tailored towards
* navigating through search results and different forms loaded into
* the ModelAdmin right panels. The logic listens to search and form loading
@ -15,13 +20,20 @@
* - historyGoFoward
* - historyGoBack
*
* @todo Switch tab state when re-displaying search forms
* @todo Reload search parameters into forms
*
* @name ss.ModelAdmin
* Todo:
* Switch tab state when re-displaying search forms
* Reload search parameters into forms
*/
$('.ModelAdmin').entwine(/** @lends ss.ModelAdmin */ {
$('.ModelAdmin').entwine({
/**
* Variable: History
*/
History: [],
/**
* Variable: Future
*/
Future: [],
onmatch: function() {
@ -48,11 +60,21 @@
});
},
/**
* Function: redraw
*/
redraw: function() {
this.find('.historyNav .forward').toggle(Boolean(this.getFuture().length > 0));
this.find('.historyNav .back').toggle(Boolean(this.getHistory().length > 1));
},
/**
* Function: startHistory
*
* Parameters:
* (String) url - ...
* (Object) data - ...
*/
startHistory: function(url, data) {
this.trigger('historyStart', {url: url, data: data});
@ -79,6 +101,9 @@
this.redraw();
},
/**
* Function: goBack
*/
goBack: function() {
if(this.getHistory() && this.getHistory().length) {
if(this.getFuture() == null) this.setFuture([]);
@ -97,6 +122,9 @@
}
},
/**
* Function: goForward
*/
goForward: function() {
if(this.getFuture() && this.getFuture().length) {
if(this.getFuture() == null) this.setFuture([]);
@ -116,6 +144,8 @@
});
/**
* Class: #SearchForm_holder form
*
* A search action will cause the history to be reset.
*/
$('#SearchForm_holder form').entwine({
@ -133,6 +163,8 @@
});
/**
* Class: form[name=Form_ResultsForm] tbody td a
*
* We have to apply this to the result table buttons instead of the
* more generic form loading.
*/

View File

@ -1,3 +1,7 @@
/**
* File: ModelAdmin.js
*/
/**
* Javascript handlers for generic model admin.
*
@ -16,6 +20,8 @@
//////////////////////////////////////////////////////////////////
/**
* Class: #ModelClassSelector select
*
* If a dropdown is used to choose between the classes, it is handled by this code
*/
$('#ModelClassSelector select').entwine({
@ -27,6 +33,8 @@
},
/**
* Function: onchange
*
* Set up an onchange function to show the applicable form and hide all others
*/
onchange: function(e) {
@ -37,7 +45,10 @@
});
}
});
/**
* Class: #SearchForm_holder form
*
* Submits a search filter query and attaches event handlers
* to the response table, excluding the import form because
* file ($_FILES) submission doesn't work using AJAX
@ -45,6 +56,10 @@
* Note: This is used for Form_CreateForm and all Form_SearchForm_* variations
*/
$('#SearchForm_holder form').entwine({
/**
* Function: onsubmit
*/
onsubmit: function(e) {
// Import forms are processed without ajax
if(this.is('#Form_ImportForm')) return true;
@ -67,9 +82,15 @@
});
/**
* Class: a.form_frontend_function.toggle_result_assembly
*
* Column selection in search form
*/
$('a.form_frontend_function.toggle_result_assembly').entwine({
/**
* Function: onclick
*/
onclick: function(e) {
var toggleElement = $(this).next();
toggleElement.toggle();
@ -77,7 +98,13 @@
}
});
/**
* Class: a.form_frontend_function.tick_all_result_assembly
*/
$('a.form_frontend_function.tick_all_result_assembly').entwine({
/**
* Function: onclick
*/
onclick: function(e) {
var resultAssembly = $(this).prevAll('div#ResultAssembly').find('ul li input');
resultAssembly.attr('checked', 'checked');
@ -94,9 +121,14 @@
});
/**
* Class: .resultsTable tbody td
*
* Table record handler for search result record
*/
$('.resultsTable tbody td').entwine({
/**
* Function: onclick
*/
onclick: function(e) {
var firstLink = this.find('a[href]');
if(!firstLink) return;
@ -106,9 +138,14 @@
});
/**
* Class: #Form_ManagedModelsSelect
*
* Add object button
*/
$('#Form_ManagedModelsSelect').entwine({
/**
* Function: onsubmit
*/
onsubmit: function(e) {
className = $('select option:selected', this).val();
requestPath = this.attr('action').replace('ManagedModelsSelect', className + '/add');
@ -126,9 +163,12 @@
});
/**
* Class: #Form_EditForm input[name=action_doDelete]
*
* RHS panel Delete button
*/
$('#Form_EditForm input[name=action_doDelete]').entwine({
// Function: onclick
onclick: function(e) {
if(!confirm(ss.i18n._t('ModelAdmin.REALLYDELETE', 'Really delete?'))) {
this.removeClass('loading');
@ -138,6 +178,8 @@
});
/**
* Class: .importSpec
*
* Toggle import specifications
*/
$('.importSpec').entwine({

View File

@ -1,9 +1,13 @@
/**
* Ajax to support the comment posting system
* File: PageCommentInterface.js
*/
/**
* Class: PageCommentInterface
*
* Ajax to support the comment posting system
*/
PageCommentInterface = Class.create();
PageCommentInterface.prototype = {
initialize: function() {
Behaviour.register({

View File

@ -1,10 +1,14 @@
/**
* File: ReportAdmin.Tree.js
*/
(function($) {
$.entwine('ss', function($){
/**
* @class Tree panel.
* @name ss.sitetree
* Class: #sitetree
*
* Tree panel.
*/
$('#sitetree').entwine(/** @lends ss.sitetree */{
$('#sitetree').entwine({
onmatch: function() {
// make sure current ID of loaded form is actually selected in tree
var id = $('#Form_EditForm :input[name=ID]').val();

View File

@ -1,4 +1,6 @@
/**
* File: SecurityAdmin.Tree.js
*
* Configuration for the left hand tree
*/
if(typeof SiteTreeHandlers == 'undefined') SiteTreeHandlers = {};

View File

@ -1,3 +1,6 @@
/**
* File: SecurityAdmin.js
*/
(function($) {
var refreshAfterImport = function(e) {
@ -49,7 +52,11 @@
});
$.entwine('ss', function($){
/**
* Class: #Form_EditForm .Actions #Form_EditForm_action_addmember
*/
$('#Form_EditForm .Actions #Form_EditForm_action_addmember').entwine({
// Function: onclick
onclick: function(e) {
// CAUTION: Assumes that a MemberTableField-instance is present as an editing form
var t = $('#Form_EditForm_Members');

View File

@ -1,3 +1,10 @@
/**
* File: ThumbnailStripField.js
*/
/**
* Class: ThumbnailStripField
*/
ThumbnailStripField = Class.create();
// We do this instead of div.thumbnailstrip for efficiency. It means that ThumbnailStripField can only be used in the
// CMS toolbar

View File

@ -1,5 +1,11 @@
WidgetAreaEditorClass = Class.create();
/**
* File: WidgetAreaEditor.js
*/
/**
* Class: WidgetAreaEditorClass
*/
WidgetAreaEditorClass = Class.create();
WidgetAreaEditorClass.prototype = {
initialize: function() {
this.name = this.getAttribute('name');
@ -207,8 +213,10 @@ WidgetAreaEditorClass.prototype = {
}
}
/**
* Class: UsedWidget
*/
UsedWidget = Class.create();
UsedWidget.prototype = {
initialize: function() {
// Call deleteWidget when delete button is pushed
@ -239,6 +247,9 @@ UsedWidget.prototype = {
}
}
/**
* Class: AvailableWidgetHeader
*/
AvailableWidgetHeader = Class.create();
AvailableWidgetHeader.prototype = {
onclick: function(event) {
@ -248,15 +259,16 @@ AvailableWidgetHeader.prototype = {
$('WidgetAreaEditor-'+widgetArea).addWidget(className, widgetArea);
}
}
AvailableWidgetHeader.applyTo('div.availableWidgets .Widget h3');
/**
* Class: WidgetTreeDropdownField
*/
WidgetTreeDropdownField = Class.extend('TreeDropdownField');
WidgetTreeDropdownField.prototype = {
getName: function() {
return 'Widget_TDF_Endpoint';
}
}
WidgetTreeDropdownField.applyTo('div.usedWidgets .TreeDropdownField');
WidgetAreaEditorClass.applyTo('.WidgetAreaEditor');