Commit 312c4201 authored by webchick's avatar webchick

Issue #2516694 by eiriksm, nod_: JSDoc editor module

parent c1114291
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
"use strict"; "use strict";
/** /**
* Editor configuration namespace.
*
* @namespace * @namespace
*/ */
Drupal.editorConfiguration = { Drupal.editorConfiguration = {
...@@ -132,8 +134,10 @@ ...@@ -132,8 +134,10 @@
* "allowed tag property value" restrictions for this particular tag. * "allowed tag property value" restrictions for this particular tag.
* *
* @param {object} feature * @param {object} feature
* The feature in question.
* *
* @return {object} * @return {object}
* The universe generated.
* *
* @see findPropertyValueOnTag() * @see findPropertyValueOnTag()
* @see filterStatusAllowsFeature() * @see filterStatusAllowsFeature()
...@@ -187,8 +191,10 @@ ...@@ -187,8 +191,10 @@
* values are defined for all properties: attributes, classes and styles. * values are defined for all properties: attributes, classes and styles.
* *
* @param {object} section * @param {object} section
* The section to check.
* *
* @return {bool} * @return {bool}
* Returns true if the section has empty properties, false otherwise.
*/ */
function emptyProperties(section) { function emptyProperties(section) {
return section.attributes.length === 0 && section.classes.length === 0 && section.styles.length === 0; return section.attributes.length === 0 && section.classes.length === 0 && section.styles.length === 0;
...@@ -200,12 +206,18 @@ ...@@ -200,12 +206,18 @@
* tag. * tag.
* *
* @param {object} universe * @param {object} universe
* The universe to check.
* @param {string} tag * @param {string} tag
* The tag to look for.
* @param {string} property * @param {string} property
* The property to check.
* @param {Array} propertyValues * @param {Array} propertyValues
* Values of the property to check.
* @param {bool} allowing * @param {bool} allowing
* Whether to update the universe or not.
* *
* @return {bool} * @return {bool}
* Returns true if found, false otherwise.
*/ */
function findPropertyValuesOnTag(universe, tag, property, propertyValues, allowing) { function findPropertyValuesOnTag(universe, tag, property, propertyValues, allowing) {
// Detect the wildcard case. // Detect the wildcard case.
...@@ -226,11 +238,16 @@ ...@@ -226,11 +238,16 @@
* Calls findPropertyValuesOnAllTags for all tags in the universe. * Calls findPropertyValuesOnAllTags for all tags in the universe.
* *
* @param {object} universe * @param {object} universe
* The universe to check.
* @param {string} property * @param {string} property
* The property to check.
* @param {Array} propertyValues * @param {Array} propertyValues
* Values of the property to check.
* @param {bool} allowing * @param {bool} allowing
* Whether to update the universe or not.
* *
* @return {bool} * @return {bool}
* Returns true if found, false otherwise.
*/ */
function findPropertyValuesOnAllTags(universe, property, propertyValues, allowing) { function findPropertyValuesOnAllTags(universe, property, propertyValues, allowing) {
var atLeastOneFound = false; var atLeastOneFound = false;
...@@ -249,12 +266,18 @@ ...@@ -249,12 +266,18 @@
* value exists. Returns true if found, false otherwise. * value exists. Returns true if found, false otherwise.
* *
* @param {object} universe * @param {object} universe
* The universe to check.
* @param {string} tag * @param {string} tag
* The tag to look for.
* @param {string} property * @param {string} property
* The property to check.
* @param {string} propertyValue * @param {string} propertyValue
* The property value to check.
* @param {bool} allowing * @param {bool} allowing
* Whether to update the universe or not.
* *
* @return {bool} * @return {bool}
* Returns true if found, false otherwise.
*/ */
function findPropertyValueOnTag(universe, tag, property, propertyValue, allowing) { function findPropertyValueOnTag(universe, tag, property, propertyValue, allowing) {
// If the tag does not exist in the universe, then it definitely can't // If the tag does not exist in the universe, then it definitely can't
...@@ -303,9 +326,12 @@ ...@@ -303,9 +326,12 @@
* properties are marked as allowed. * properties are marked as allowed.
* *
* @param {object} universe * @param {object} universe
* The universe to delete from.
* @param {string} tag * @param {string} tag
* The tag to check.
* *
* @return {bool} * @return {bool}
* Whether something was deleted from the universe.
*/ */
function deleteFromUniverseIfAllowed(universe, tag) { function deleteFromUniverseIfAllowed(universe, tag) {
// Detect the wildcard case. // Detect the wildcard case.
...@@ -323,8 +349,10 @@ ...@@ -323,8 +349,10 @@
* Calls deleteFromUniverseIfAllowed for all tags in the universe. * Calls deleteFromUniverseIfAllowed for all tags in the universe.
* *
* @param {object} universe * @param {object} universe
* The universe to delete from.
* *
* @return {bool} * @return {bool}
* Whether something was deleted from the universe.
*/ */
function deleteAllTagsFromUniverseIfAllowed(universe) { function deleteAllTagsFromUniverseIfAllowed(universe) {
var atLeastOneDeleted = false; var atLeastOneDeleted = false;
...@@ -341,9 +369,12 @@ ...@@ -341,9 +369,12 @@
* that exists in the universe. * that exists in the universe.
* *
* @param {object} universe * @param {object} universe
* Universe to check.
* @param {object} filterStatus * @param {object} filterStatus
* Filter status to use for check.
* *
* @return {bool} * @return {bool}
* Whether any filter rule forbids something in the universe.
*/ */
function anyForbiddenFilterRuleMatches(universe, filterStatus) { function anyForbiddenFilterRuleMatches(universe, filterStatus) {
var properties = ['attributes', 'styles', 'classes']; var properties = ['attributes', 'styles', 'classes'];
...@@ -392,7 +423,9 @@ ...@@ -392,7 +423,9 @@
* deleted from the universe. * deleted from the universe.
* *
* @param {object} universe * @param {object} universe
* Universe to delete from.
* @param {object} filterStatus * @param {object} filterStatus
* The filter status in question.
*/ */
function markAllowedTagsAndPropertyValues(universe, filterStatus) { function markAllowedTagsAndPropertyValues(universe, filterStatus) {
var properties = ['attributes', 'styles', 'classes']; var properties = ['attributes', 'styles', 'classes'];
...@@ -445,9 +478,12 @@ ...@@ -445,9 +478,12 @@
* that. * that.
* *
* @param {object} filterStatus * @param {object} filterStatus
* The filter status in question.
* @param {object} feature * @param {object} feature
* The feature requested.
* *
* @return {bool} * @return {bool}
* Whether the current status of the filter allows specified feature.
* *
* @see generateUniverseFromFeatureRequirements() * @see generateUniverseFromFeatureRequirements()
*/ */
...@@ -768,7 +804,10 @@ ...@@ -768,7 +804,10 @@
* } * }
* } * }
* *
* @return {{ * @return {object}
* An object with the following structure:
* ```
* {
* tags: Array, * tags: Array,
* allow: null, * allow: null,
* restrictedTags: { * restrictedTags: {
...@@ -776,9 +815,10 @@ ...@@ -776,9 +815,10 @@
* allowed: {attributes: Array, styles: Array, classes: Array}, * allowed: {attributes: Array, styles: Array, classes: Array},
* forbidden: {attributes: Array, styles: Array, classes: Array} * forbidden: {attributes: Array, styles: Array, classes: Array}
* } * }
* }} * }
* ```
* *
* @see Drupal.FilterStatus * @see Drupal.FilterStatus
*/ */
Drupal.FilterHTMLRule = function () { Drupal.FilterHTMLRule = function () {
return { return {
...@@ -853,6 +893,9 @@ ...@@ -853,6 +893,9 @@
* Initializes {@link Drupal.filterConfiguration}. * Initializes {@link Drupal.filterConfiguration}.
* *
* @type {Drupal~behavior} * @type {Drupal~behavior}
*
* @prop {Drupal~behaviorAttach} attach
* Gets filter configuration from filter form input.
*/ */
Drupal.behaviors.initializeFilterConfiguration = { Drupal.behaviors.initializeFilterConfiguration = {
attach: function (context, settings) { attach: function (context, settings) {
......
...@@ -17,9 +17,13 @@ ...@@ -17,9 +17,13 @@
* interface. * interface.
* *
* @param {Drupal.Ajax} [ajax] * @param {Drupal.Ajax} [ajax]
* The Drupal.Ajax object.
* @param {object} response * @param {object} response
* The server response from the ajax request.
* @param {Array} response.values * @param {Array} response.values
* The values that were saved.
* @param {number} [status] * @param {number} [status]
* The status code from the ajax request.
* *
* @fires event:editor:dialogsave * @fires event:editor:dialogsave
*/ */
......
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
* @augments Drupal.quickedit.EditorView * @augments Drupal.quickedit.EditorView
* *
* @param {object} options * @param {object} options
* Options for the editor view.
*/ */
initialize: function (options) { initialize: function (options) {
Drupal.quickedit.EditorView.prototype.initialize.call(this, options); Drupal.quickedit.EditorView.prototype.initialize.call(this, options);
...@@ -70,6 +71,7 @@ ...@@ -70,6 +71,7 @@
* @inheritdoc * @inheritdoc
* *
* @return {jQuery} * @return {jQuery}
* The text element edited.
*/ */
getEditedElement: function () { getEditedElement: function () {
return this.$textElement; return this.$textElement;
...@@ -79,7 +81,9 @@ ...@@ -79,7 +81,9 @@
* @inheritdoc * @inheritdoc
* *
* @param {object} fieldModel * @param {object} fieldModel
* The field model.
* @param {string} state * @param {string} state
* The current state.
*/ */
stateChange: function (fieldModel, state) { stateChange: function (fieldModel, state) {
var editorModel = this.model; var editorModel = this.model;
...@@ -172,6 +176,7 @@ ...@@ -172,6 +176,7 @@
* @inheritdoc * @inheritdoc
* *
* @return {object} * @return {object}
* The sttings for the quick edit UI.
*/ */
getQuickEditUISettings: function () { getQuickEditUISettings: function () {
return {padding: true, unifiedToolbar: true, fullWidthToolbar: true, popup: false}; return {padding: true, unifiedToolbar: true, fullWidthToolbar: true, popup: false};
......
...@@ -59,6 +59,7 @@ ...@@ -59,6 +59,7 @@
* Handles changes in text format. * Handles changes in text format.
* *
* @param {jQuery.Event} event * @param {jQuery.Event} event
* The text format change event.
*/ */
function onTextFormatChange(event) { function onTextFormatChange(event) {
var $select = $(event.target); var $select = $(event.target);
...@@ -99,9 +100,10 @@ ...@@ -99,9 +100,10 @@
text: Drupal.t('Cancel'), text: Drupal.t('Cancel'),
class: 'button', class: 'button',
click: function () { click: function () {
// Restore the active format ID: cancel changing text format. We cannot // Restore the active format ID: cancel changing text format. We
// simply call event.preventDefault() because jQuery's change event is // cannot simply call event.preventDefault() because jQuery's
// only triggered after the change has already been accepted. // change event is only triggered after the change has already
// been accepted.
$select.val(activeFormatID); $select.val(activeFormatID);
confirmationDialog.close(); confirmationDialog.close();
} }
...@@ -138,6 +140,11 @@ ...@@ -138,6 +140,11 @@
* Enables editors on text_format elements. * Enables editors on text_format elements.
* *
* @type {Drupal~behavior} * @type {Drupal~behavior}
*
* @prop {Drupal~behaviorAttach} attach
* Attaches an editor to an input element.
* @prop {Drupal~behaviorDetach} detach
* Detaches an editor from an input element.
*/ */
Drupal.behaviors.editor = { Drupal.behaviors.editor = {
attach: function (context, settings) { attach: function (context, settings) {
...@@ -161,13 +168,13 @@ ...@@ -161,13 +168,13 @@
// Directly attach this text editor, if the text format is enabled. // Directly attach this text editor, if the text format is enabled.
if (settings.editor.formats[activeFormatID]) { if (settings.editor.formats[activeFormatID]) {
// XSS protection for the current text format/editor is performed on the // XSS protection for the current text format/editor is performed on
// server side, so we don't need to do anything special here. // the server side, so we don't need to do anything special here.
Drupal.editorAttach(field, settings.editor.formats[activeFormatID]); Drupal.editorAttach(field, settings.editor.formats[activeFormatID]);
} }
// When there is no text editor for this text format, still track changes, // When there is no text editor for this text format, still track
// because the user has the ability to switch to some text editor, other- // changes, because the user has the ability to switch to some text
// wise this code would not be executed. // editor, otherwise this code would not be executed.
$(field).on('change.editor keypress.editor', function () { $(field).on('change.editor keypress.editor', function () {
field.setAttribute('data-editor-value-is-changed', 'true'); field.setAttribute('data-editor-value-is-changed', 'true');
// Just knowing that the value was changed is enough, stop tracking. // Just knowing that the value was changed is enough, stop tracking.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment