Skip to content

Commit

Permalink
ENHANCEMENT Moved cms/javascript documentation from JSDoc to NaturalD…
Browse files Browse the repository at this point in the history
…ocs format

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@104369 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information
chillu committed May 8, 2010
1 parent 24fb77a commit ecbee33
Show file tree
Hide file tree
Showing 24 changed files with 733 additions and 159 deletions.
20 changes: 19 additions & 1 deletion javascript/AssetAdmin.DragDrop.js
@@ -1,6 +1,12 @@
/**
* File: AssetAdmin.DragDrop.js
*/
(function($) { (function($) {
$.entwine('ss', function($){ $.entwine('ss', function($){


/**
* Class: .AssetTableField.dragdrop
*/
$('.AssetTableField.dragdrop').entwine({ $('.AssetTableField.dragdrop').entwine({
onmatch: function() { onmatch: function() {
var self = this; var self = this;
Expand All @@ -15,6 +21,8 @@
this._super(); this._super();
}, },
/** /**
* Function: drop
*
* Take selected files and move them to a folder target in the tree. * Take selected files and move them to a folder target in the tree.
*/ */
drop: function(e, ui) { drop: function(e, ui) {
Expand All @@ -30,11 +38,15 @@
) )
} }
}, },

/** /**
* Function: getSelected
*
* Get the IDs of all selected files in the table. * Get the IDs of all selected files in the table.
* Used for drag'n'drop. * Used for drag'n'drop.
* *
* @return Array * Returns:
* Array
*/ */
getSelected: function() { getSelected: function() {
return this.find(':input[name=Files\[\]]:checked').map(function() { return this.find(':input[name=Files\[\]]:checked').map(function() {
Expand All @@ -44,6 +56,7 @@
}); });


$('.AssetTableField .dragfile').entwine({ $('.AssetTableField .dragfile').entwine({
// Constructor: onmatch
onmatch: function() { onmatch: function() {
var self = this; var self = this;
var container = this.parents('.AssetTableField'); var container = this.parents('.AssetTableField');
Expand All @@ -64,6 +77,11 @@
this._super(); this._super();
}, },
/** /**
* Function: onmousedown
*
* Parameters:
* (Event) e
*
* Automatically select the checkbox in the same table row * Automatically select the checkbox in the same table row
* to signify that this element is moved, and hint that * to signify that this element is moved, and hint that
* all checkboxed elements will be moved along with it. * all checkboxed elements will be moved along with it.
Expand Down
15 changes: 15 additions & 0 deletions javascript/AssetAdmin.js
@@ -1,3 +1,7 @@
/**
* File: AssetAdmin.js
*/

/** /**
* Configuration for the left hand tree * Configuration for the left hand tree
*/ */
Expand Down Expand Up @@ -36,7 +40,18 @@ var _HANDLER_FORMS = {
}); });


$.entwine('ss', function($){ $.entwine('ss', function($){

/**
* Class: #Form_SyncForm
*/
$('#Form_SyncForm').entwine({ $('#Form_SyncForm').entwine({

/**
* Function: onsubmit
*
* Parameters:
* (Event) e
*/
onsubmit: function(e) { onsubmit: function(e) {
var button = jQuery(this).find(':submit:first'); var button = jQuery(this).find(':submit:first');
button.addClass('loading'); button.addClass('loading');
Expand Down
26 changes: 26 additions & 0 deletions javascript/AssetTableField.js
@@ -1,7 +1,14 @@
/**
* File: AssetTableField.js
*/
(function($) { (function($) {
$.entwine('ss', function($){ $.entwine('ss', function($){


/**
* Class: .AssetTableField
*/
$('.AssetTableField').entwine({ $('.AssetTableField').entwine({
// Constructor: onmatch
onmatch: function() { onmatch: function() {
var self = this; var self = this;


Expand Down Expand Up @@ -30,6 +37,12 @@
this._super(); this._super();
}, },


/**
* Function: refresh
*
* Parameters:
* (Function) callback
*/
refresh: function(callback) { refresh: function(callback) {
var self = this; var self = this;
this.load( this.load(
Expand All @@ -44,9 +57,12 @@
}); });


/** /**
* Class: .AssetTableField :checkbox
*
* Checkboxes used to batch delete files * Checkboxes used to batch delete files
*/ */
$('.AssetTableField :checkbox').entwine({ $('.AssetTableField :checkbox').entwine({
// Function: onchange
onchange: function() { onchange: function() {
var container = this.parents('.AssetTableField'); var container = this.parents('.AssetTableField');
var input = container.find('input#deletemarked'); var input = container.find('input#deletemarked');
Expand All @@ -59,14 +75,24 @@
}) })


/** /**
* Class: .AssetTableField input#deletemarked
*
* Batch delete files marked by checkboxes in the table. * Batch delete files marked by checkboxes in the table.
* Refreshes the form field afterwards via ajax. * Refreshes the form field afterwards via ajax.
*/ */
$('.AssetTableField input#deletemarked').entwine({ $('.AssetTableField input#deletemarked').entwine({
// Constructor: onmatch
onmatch: function() { onmatch: function() {
this.attr('disabled', 'disabled'); this.attr('disabled', 'disabled');
this._super(); this._super();
}, },

/**
* Function: onclick
*
* Parameters:
* (Event) e
*/
onclick: function(e) { onclick: function(e) {
if(!confirm(ss.i18n._t('AssetTableField.REALLYDELETE'))) return false; if(!confirm(ss.i18n._t('AssetTableField.REALLYDELETE'))) return false;


Expand Down
122 changes: 96 additions & 26 deletions javascript/CMSMain.EditForm.js
@@ -1,25 +1,44 @@
(function($) { (function($) {
$.entwine('ss', 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. * 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() { onchange: function() {
alert(ss.i18n._t('CMSMAIN.ALERTCLASSNAME')); alert(ss.i18n._t('CMSMAIN.ALERTCLASSNAME'));
} }
}); });


/** /**
* @class Input validation on the URLSegment field * Class: #Form_EditForm input[name=URLSegment]
* @name ss.EditForm.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-]+/, FilterRegex: /[^A-Za-z0-9-]+/,

/**
* Property: ValidationMessage
* String
*/
ValidationMessage: ss.i18n._t('CMSMAIN.URLSEGMENTVALIDATION'), ValidationMessage: ss.i18n._t('CMSMAIN.URLSEGMENTVALIDATION'),

/**
* Property: MaxLength
* Int
*/
MaxLength: 50, MaxLength: 50,


/**
* Constructor: onmatch
*/
onmatch : function() { onmatch : function() {
var self = this; var self = this;


Expand All @@ -36,16 +55,27 @@
}, },


/** /**
* Function: suggestValue
*
* Return a value matching the criteria. * Return a value matching the criteria.
* *
* @param {String} val * Parameters:
* @return val * (String) val
*
* Returns:
* String
*/ */
suggestValue: function(val) { suggestValue: function(val) {
// TODO Do we want to enforce lowercasing in URLs? // TODO Do we want to enforce lowercasing in URLs?
return val.substr(0, this.getMaxLength()).replace(this.getFilterRegex(), '').toLowerCase(); return val.substr(0, this.getMaxLength()).replace(this.getFilterRegex(), '').toLowerCase();
}, },


/**
* Function: validate
*
* Returns:
* Boolean
*/
validate: function() { validate: function() {
return ( return (
this.val().length > this.getMaxLength() this.val().length > this.getMaxLength()
Expand All @@ -55,10 +85,12 @@
}); });


/** /**
* @class Input validation on the Title field * Class: #Form_EditForm input[name=Title]
* @name ss.EditForm.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() { onmatch : function() {
var self = this; var self = this;


Expand All @@ -71,6 +103,12 @@
this._super(); this._super();
}, },


/**
* Function: updateURLSegment
*
* Parameters:
* (DOMElement) field
*/
updateURLSegment: function(field) { updateURLSegment: function(field) {
if(!field || !field.length) return; if(!field || !field.length) return;


Expand All @@ -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 * 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() { onmatch : function() {
var self = this; var self = this;
this.find(':input[name=ParentType]').bind('click', function(e) {self._toggleSelection(e);}); this.find(':input[name=ParentType]').bind('click', function(e) {self._toggleSelection(e);});
Expand All @@ -109,6 +149,12 @@
this._super(); this._super();
}, },


/**
* Function: _toggleSelection
*
* Parameters:
* (Event) e
*/
_toggleSelection: function(e) { _toggleSelection: function(e) {
var selected = this.find(':input[name=ParentType]:checked').val(); var selected = this.find(':input[name=ParentType]:checked').val();
// reset parent id if 'root' radiobutton is selected // reset parent id if 'root' radiobutton is selected
Expand All @@ -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. * 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() { onmatch: function() {
// TODO Decouple // TODO Decouple
var dropdown; var dropdown;
Expand All @@ -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. * 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) { onclick: function(e) {
window.open( window.open(
'mailto:?subject=' 'mailto:?subject='
Expand All @@ -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. * 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) { onclick: function(e) {
var printURL = $(this[0].form).attr('action').replace(/\?.*$/,'') var printURL = $(this[0].form).attr('action').replace(/\?.*$/,'')
+ '/printable/' + '/printable/'
Expand All @@ -180,10 +242,18 @@
}); });


/** /**
* @class A "rollback" to a specific version needs user confirmation. * Class: #Form_EditForm .Actions #Form_EditForm_action_rollback
* @name ss.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) { onclick: function(e) {
// @todo i18n // @todo i18n
var form = this.parents('form:first'), version = form.find(':input[name=Version]').val(), message = ''; var form = this.parents('form:first'), version = form.find(':input[name=Version]').val(), message = '';
Expand Down

0 comments on commit ecbee33

Please sign in to comment.