Commit 9c16305b authored by webchick's avatar webchick

Issue #2212283 by nod_: Auto-format JS files.

parent 7f555205
...@@ -107,7 +107,8 @@ ...@@ -107,7 +107,8 @@
// xmlhttp.responseText is going to throw an exception. So we'll catch it. // xmlhttp.responseText is going to throw an exception. So we'll catch it.
try { try {
responseText = "\n" + Drupal.t("ResponseText: !responseText", {'!responseText': $.trim(xmlhttp.responseText) }); responseText = "\n" + Drupal.t("ResponseText: !responseText", {'!responseText': $.trim(xmlhttp.responseText) });
} catch (e) {} }
catch (e) {}
// Make the responseText more readable by stripping HTML tags and newlines. // Make the responseText more readable by stripping HTML tags and newlines.
responseText = responseText.replace(/<("[^"]*"|'[^']*'|[^'">])*>/gi, ""); responseText = responseText.replace(/<("[^"]*"|'[^']*'|[^'">])*>/gi, "");
......
...@@ -162,10 +162,10 @@ ...@@ -162,10 +162,10 @@
* *
* @return {Object} * @return {Object}
*/ */
function renderItem (ul, item) { function renderItem(ul, item) {
return $("<li>") return $("<li>")
.append( $("<a>").html(item.label)) .append($("<a>").html(item.label))
.appendTo( ul ); .appendTo(ul);
} }
/** /**
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
Drupal.dialog = function (element, options) { Drupal.dialog = function (element, options) {
function openDialog (settings) { function openDialog(settings) {
settings = $.extend({}, drupalSettings.dialog, options, settings); settings = $.extend({}, drupalSettings.dialog, options, settings);
// Trigger a global event to allow scripts to bind events to the dialog. // Trigger a global event to allow scripts to bind events to the dialog.
$(window).trigger('dialog:beforecreate', [dialog, $element, settings]); $(window).trigger('dialog:beforecreate', [dialog, $element, settings]);
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
$(window).trigger('dialog:aftercreate', [dialog, $element, settings]); $(window).trigger('dialog:aftercreate', [dialog, $element, settings]);
} }
function closeDialog (value) { function closeDialog(value) {
$(window).trigger('dialog:beforeclose', [dialog, $element]); $(window).trigger('dialog:beforeclose', [dialog, $element]);
$element.dialog('close'); $element.dialog('close');
dialog.returnValue = value; dialog.returnValue = value;
......
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
'dialog:aftercreate': function (event, dialog, $element, settings) { 'dialog:aftercreate': function (event, dialog, $element, settings) {
var autoResize = debounce(resetSize, 20); var autoResize = debounce(resetSize, 20);
var eventData = { settings: settings, $element: $element }; var eventData = { settings: settings, $element: $element };
if (settings.autoResize === true || settings.autoResize === 'true') { if (settings.autoResize === true || settings.autoResize === 'true') {
$element $element
.dialog('option', { resizable: false, draggable: false }) .dialog('option', { resizable: false, draggable: false })
.dialog('widget').css('position', 'fixed'); .dialog('widget').css('position', 'fixed');
......
...@@ -144,7 +144,6 @@ ...@@ -144,7 +144,6 @@
} }
}); });
$.extend(Drupal.theme, { $.extend(Drupal.theme, {
/** /**
* A toggle is an interactive element often bound to a click handler. * A toggle is an interactive element often bound to a click handler.
......
...@@ -37,6 +37,7 @@ if (window.jQuery) { ...@@ -37,6 +37,7 @@ if (window.jQuery) {
} }
this.message = messageList.join(' ; '); this.message = messageList.join(' ; ');
} }
DrupalBehaviorError.prototype = new Error(); DrupalBehaviorError.prototype = new Error();
/** /**
......
...@@ -116,7 +116,6 @@ ...@@ -116,7 +116,6 @@
} }
}; };
/** /**
* Sends a 'formUpdated' event each time a form element is modified. * Sends a 'formUpdated' event each time a form element is modified.
*/ */
...@@ -149,7 +148,6 @@ ...@@ -149,7 +148,6 @@
var contextIsForm = $context.is('form'); var contextIsForm = $context.is('form');
var $forms = (contextIsForm ? $context : $context.find('form')).once('form-updated'); var $forms = (contextIsForm ? $context : $context.find('form')).once('form-updated');
if ($forms.length) { if ($forms.length) {
// Initialize form behaviors, use $.makeArray to be able to use native // Initialize form behaviors, use $.makeArray to be able to use native
// forEach array method and have the callback parameters in the right order. // forEach array method and have the callback parameters in the right order.
......
...@@ -109,5 +109,4 @@ ...@@ -109,5 +109,4 @@
} }
}); });
})(jQuery); })(jQuery);
...@@ -428,7 +428,6 @@ ...@@ -428,7 +428,6 @@
} }
}; };
/** /**
* A state object is used for describing the state and performing aliasing. * A state object is used for describing the state and performing aliasing.
*/ */
...@@ -552,23 +551,28 @@ ...@@ -552,23 +551,28 @@
} }
}); });
/** /**
* These are helper functions implementing addition "operators" and don't * These are helper functions implementing addition "operators" and don't
* implement any logic that is particular to states. * implement any logic that is particular to states.
*/ */
// Bitwise AND with a third undefined state. /**
* Bitwise AND with a third undefined state.
*/
function ternary(a, b) { function ternary(a, b) {
return typeof a === 'undefined' ? b : (typeof b === 'undefined' ? a : a && b); return typeof a === 'undefined' ? b : (typeof b === 'undefined' ? a : a && b);
} }
// Inverts a (if it's not undefined) when invertState is true. /**
* Inverts a (if it's not undefined) when invertState is true.
*/
function invert(a, invertState) { function invert(a, invertState) {
return (invertState && typeof a !== 'undefined') ? !a : a; return (invertState && typeof a !== 'undefined') ? !a : a;
} }
// Compares two values while ignoring undefined values. /**
* Compares two values while ignoring undefined values.
*/
function compare(a, b) { function compare(a, b) {
return (a === b) ? (typeof a === 'undefined' ? a : true) : (typeof a === 'undefined' || typeof b === 'undefined'); return (a === b) ? (typeof a === 'undefined' ? a : true) : (typeof a === 'undefined' || typeof b === 'undefined');
} }
......
...@@ -280,7 +280,6 @@ ...@@ -280,7 +280,6 @@
} }
}); });
// Mark this behavior as processed on the first pass and return if it is // Mark this behavior as processed on the first pass and return if it is
// already processed. // already processed.
if (Drupal.tabbingManager) { if (Drupal.tabbingManager) {
...@@ -288,5 +287,4 @@ ...@@ -288,5 +287,4 @@
} }
Drupal.tabbingManager = new TabbingManager(); Drupal.tabbingManager = new TabbingManager();
}(jQuery, Drupal)); }(jQuery, Drupal));
...@@ -994,6 +994,7 @@ ...@@ -994,6 +994,7 @@
var currentRow = $(this.element, this.table).next('tr.draggable'); var currentRow = $(this.element, this.table).next('tr.draggable');
var rows = []; var rows = [];
var child = 0; var child = 0;
function rowIndentation(el, indentNum) { function rowIndentation(el, indentNum) {
var self = $(el); var self = $(el);
if (child === 1 && (indentNum === parentIndentation)) { if (child === 1 && (indentNum === parentIndentation)) {
...@@ -1006,6 +1007,7 @@ ...@@ -1006,6 +1007,7 @@
self.addClass('tree-child-horizontal'); self.addClass('tree-child-horizontal');
} }
} }
while (currentRow.length) { while (currentRow.length) {
// A greater indentation indicates this is a child. // A greater indentation indicates this is a child.
if (currentRow.find('.indentation').length > parentIndentation) { if (currentRow.find('.indentation').length > parentIndentation) {
......
...@@ -532,7 +532,7 @@ ...@@ -532,7 +532,7 @@
* A jQuery DOM fragment that represents the new button group. It has * A jQuery DOM fragment that represents the new button group. It has
* not been added to the DOM yet. * not been added to the DOM yet.
*/ */
function insertNewGroup (success, $group) { function insertNewGroup(success, $group) {
if (success) { if (success) {
$group.appendTo($(event.currentTarget).closest('.ckeditor-row').children('.ckeditor-toolbar-groups')); $group.appendTo($(event.currentTarget).closest('.ckeditor-row').children('.ckeditor-toolbar-groups'));
// Focus on the new group. // Focus on the new group.
...@@ -1171,7 +1171,7 @@ ...@@ -1171,7 +1171,7 @@
* A callback to invoke after the button group naming modal dialog has been * A callback to invoke after the button group naming modal dialog has been
* closed. * closed.
*/ */
function registerButtonMove (view, $button, callback) { function registerButtonMove(view, $button, callback) {
var $group = $button.closest('.ckeditor-toolbar-group'); var $group = $button.closest('.ckeditor-toolbar-group');
// If dropped in a placeholder button group, the user must name it. // If dropped in a placeholder button group, the user must name it.
...@@ -1201,7 +1201,7 @@ ...@@ -1201,7 +1201,7 @@
* @param jQuery $group * @param jQuery $group
* A jQuery set that contains an li element that wraps a group of buttons. * A jQuery set that contains an li element that wraps a group of buttons.
*/ */
function registerGroupMove (view, $group) { function registerGroupMove(view, $group) {
// Remove placeholder classes if necessary. // Remove placeholder classes if necessary.
var $row = $group.closest('.ckeditor-row'); var $row = $group.closest('.ckeditor-row');
if ($row.hasClass('placeholder')) { if ($row.hasClass('placeholder')) {
...@@ -1229,7 +1229,7 @@ ...@@ -1229,7 +1229,7 @@
* A callback to invoke after the button group naming modal dialog has been * A callback to invoke after the button group naming modal dialog has been
* closed. * closed.
*/ */
function openGroupNameDialog (view, $group, callback) { function openGroupNameDialog(view, $group, callback) {
callback = callback || function () {}; callback = callback || function () {};
/** /**
...@@ -1241,7 +1241,7 @@ ...@@ -1241,7 +1241,7 @@
* @return Boolean * @return Boolean
* Returns true when an error exists, otherwise returns false. * Returns true when an error exists, otherwise returns false.
*/ */
function validateForm (form) { function validateForm(form) {
if (form.elements[0].value.length === 0) { if (form.elements[0].value.length === 0) {
var $form = $(form); var $form = $(form);
if (!$form.hasClass('errors')) { if (!$form.hasClass('errors')) {
...@@ -1266,12 +1266,12 @@ ...@@ -1266,12 +1266,12 @@
* The form DOM element that contains the input with the new button group * The form DOM element that contains the input with the new button group
* title string. * title string.
*/ */
function closeDialog (action, form) { function closeDialog(action, form) {
/** /**
* Closes the dialog when the user cancels or supplies valid data. * Closes the dialog when the user cancels or supplies valid data.
*/ */
function shutdown () { function shutdown() {
dialog.close(action); dialog.close(action);
// The processing marker can be deleted since the dialog has been closed. // The processing marker can be deleted since the dialog has been closed.
...@@ -1286,7 +1286,7 @@ ...@@ -1286,7 +1286,7 @@
* @param String name * @param String name
* The new name of the CKEditor button group. * The new name of the CKEditor button group.
*/ */
function namePlaceholderGroup ($group, name) { function namePlaceholderGroup($group, name) {
// If it's currently still a placeholder, then that means we're creating // If it's currently still a placeholder, then that means we're creating
// a new group, and we must do some extra work. // a new group, and we must do some extra work.
if ($group.hasClass('placeholder')) { if ($group.hasClass('placeholder')) {
......
...@@ -30,12 +30,13 @@ ...@@ -30,12 +30,13 @@
var stylesSet = that._generateStylesSetSetting(styles); var stylesSet = that._generateStylesSetSetting(styles);
if (!_.isEqual(previousStylesSet, stylesSet)) { if (!_.isEqual(previousStylesSet, stylesSet)) {
previousStylesSet = stylesSet; previousStylesSet = stylesSet;
$ckeditorActiveToolbar.trigger('CKEditorPluginSettingsChanged', [{ stylesSet: stylesSet }]); $ckeditorActiveToolbar.trigger('CKEditorPluginSettingsChanged', [
{ stylesSet: stylesSet }
]);
} }
}); });
}, },
/** /**
* Builds the "stylesSet" configuration part of the CKEditor JS settings. * Builds the "stylesSet" configuration part of the CKEditor JS settings.
* *
......
...@@ -80,7 +80,7 @@ ...@@ -80,7 +80,7 @@
widgetDefinition._dataToDialogValues = function (data) { widgetDefinition._dataToDialogValues = function (data) {
var dialogValues = {}; var dialogValues = {};
var map = widgetDefinition._mapDataToDialog; var map = widgetDefinition._mapDataToDialog;
Object.keys(widgetDefinition._mapDataToDialog).forEach(function(key) { Object.keys(widgetDefinition._mapDataToDialog).forEach(function (key) {
dialogValues[map[key]] = data[key]; dialogValues[map[key]] = data[key];
}); });
return dialogValues; return dialogValues;
...@@ -90,7 +90,7 @@ ...@@ -90,7 +90,7 @@
widgetDefinition._dialogValuesToData = function (dialogReturnValues) { widgetDefinition._dialogValuesToData = function (dialogReturnValues) {
var data = {}; var data = {};
var map = widgetDefinition._mapDataToDialog; var map = widgetDefinition._mapDataToDialog;
Object.keys(widgetDefinition._mapDataToDialog).forEach(function(key) { Object.keys(widgetDefinition._mapDataToDialog).forEach(function (key) {
if (dialogReturnValues.hasOwnProperty(map[key])) { if (dialogReturnValues.hasOwnProperty(map[key])) {
data[key] = dialogReturnValues[map[key]]; data[key] = dialogReturnValues[map[key]];
} }
...@@ -177,7 +177,7 @@ ...@@ -177,7 +177,7 @@
editor.addCommand('editdrupalimage', { editor.addCommand('editdrupalimage', {
allowedContent: 'img[alt,!src,width,height,!data-editor-file-uuid]', allowedContent: 'img[alt,!src,width,height,!data-editor-file-uuid]',
requiredContent: 'img[alt,src,width,height,data-editor-file-uuid]', requiredContent: 'img[alt,src,width,height,data-editor-file-uuid]',
modes: { wysiwyg : 1 }, modes: { wysiwyg: 1 },
canUndo: true, canUndo: true,
exec: function (editor, data) { exec: function (editor, data) {
var dialogSettings = { var dialogSettings = {
...@@ -234,7 +234,7 @@ ...@@ -234,7 +234,7 @@
}); });
function isImageWidget (editor, element) { function isImageWidget(editor, element) {
var widget = editor.widgets.getByElement(element.getChild(0), true); var widget = editor.widgets.getByElement(element.getChild(0), true);
return widget && widget.name === 'image'; return widget && widget.name === 'image';
} }
......
...@@ -58,10 +58,10 @@ ...@@ -58,10 +58,10 @@
// attributes. // attributes.
widgetDefinition.downcast = function (element) { widgetDefinition.downcast = function (element) {
// Find an image element in the one being downcasted (can be itself). // Find an image element in the one being downcasted (can be itself).
var img = findElementByName(element, 'img'), var img = findElementByName(element, 'img');
caption = this.editables.caption, var caption = this.editables.caption;
captionHtml = caption && caption.getData(), var captionHtml = caption && caption.getData();
attrs = img.attributes; var attrs = img.attributes;
// If image contains a non-empty caption, serialize caption to the // If image contains a non-empty caption, serialize caption to the
// data-caption attribute. // data-caption attribute.
...@@ -91,8 +91,8 @@ ...@@ -91,8 +91,8 @@
return; return;
} }
var attrs = element.attributes, var attrs = element.attributes;
retElement = element; var retElement = element;
// We won't need the attributes during editing: we'll use widget.data // We won't need the attributes during editing: we'll use widget.data
// to store them (except the caption, which is stored in the DOM). // to store them (except the caption, which is stored in the DOM).
...@@ -107,9 +107,9 @@ ...@@ -107,9 +107,9 @@
// Captioned image will be transformed to <figure>, so we don't want // Captioned image will be transformed to <figure>, so we don't want
// the <p> anymore. // the <p> anymore.
if (element.parent.name === 'p' && caption) { if (element.parent.name === 'p' && caption) {
var index = element.getIndex(), var index = element.getIndex();
splitBefore = index > 0, var splitBefore = index > 0;
splitAfter = index + 1 < element.parent.children.length; var splitAfter = index + 1 < element.parent.children.length;
if (splitBefore) { if (splitBefore) {
element.parent.split(index); element.parent.split(index);
...@@ -203,7 +203,7 @@ ...@@ -203,7 +203,7 @@
* @param String name * @param String name
* @return CKEDITOR.htmlParser.element * @return CKEDITOR.htmlParser.element
*/ */
function findElementByName (element, name) { function findElementByName(element, name) {
if (element.name === name) { if (element.name === name) {
return element; return element;
} }
......
...@@ -192,7 +192,6 @@ ...@@ -192,7 +192,6 @@
} }
}); });
/** /**
* Get the surrounding link element of current selection. * Get the surrounding link element of current selection.
* *
......
...@@ -113,6 +113,7 @@ ...@@ -113,6 +113,7 @@
} }
} }
} }
if (drupalSettings.comment && drupalSettings.comment.newCommentsLinks) { if (drupalSettings.comment && drupalSettings.comment.newCommentsLinks) {
render(drupalSettings.comment.newCommentsLinks.node[fieldName]); render(drupalSettings.comment.newCommentsLinks.node[fieldName]);
} }
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
* @param string html * @param string html
* The server-side rendered HTML for this contextual link. * The server-side rendered HTML for this contextual link.
*/ */
function initContextual ($contextual, html) { function initContextual($contextual, html) {
var $region = $contextual.closest('.contextual-region'); var $region = $contextual.closest('.contextual-region');
var contextual = Drupal.contextual; var contextual = Drupal.contextual;
...@@ -101,7 +101,7 @@ ...@@ -101,7 +101,7 @@
* A contextual links placeholder DOM element, containing the actual * A contextual links placeholder DOM element, containing the actual
* contextual links as rendered by the server. * contextual links as rendered by the server.
*/ */
function adjustIfNestedAndOverlapping ($contextual) { function adjustIfNestedAndOverlapping($contextual) {
var $contextuals = $contextual var $contextuals = $contextual
// @todo confirm that .closest() is not sufficient // @todo confirm that .closest() is not sufficient
.parents('.contextual-region').eq(-1) .parents('.contextual-region').eq(-1)
...@@ -156,7 +156,7 @@ ...@@ -156,7 +156,7 @@
}); });
// Update all contextual links placeholders whose HTML is cached. // Update all contextual links placeholders whose HTML is cached.
var uncachedIDs = _.filter(ids, function initIfCached (contextualID) { var uncachedIDs = _.filter(ids, function initIfCached(contextualID) {
var html = storage.getItem('Drupal.contextual.' + contextualID); var html = storage.getItem('Drupal.contextual.' + contextualID);
if (html !== null) { if (html !== null) {
// Initialize after the current executation cycle, to make the AJAX // Initialize after the current executation cycle, to make the AJAX
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
tabbingContext: null tabbingContext: null
}, },
/** /**
* {@inheritdoc} * {@inheritdoc}
* *
......
...@@ -259,7 +259,7 @@ ...@@ -259,7 +259,7 @@
* A callback to be called (with no parameters) after the field's value has * A callback to be called (with no parameters) after the field's value has
* been XSS filtered. * been XSS filtered.
*/ */
function filterXssWhenSwitching (field, format, originalFormatID, callback) { function filterXssWhenSwitching(field, format, originalFormatID, callback) {
// A text editor that already is XSS-safe needs no additional measures. // A text editor that already is XSS-safe needs no additional measures.
if (format.editor.isXssSafe) { if (format.editor.isXssSafe) {
callback(field, format); callback(field, format);
......
...@@ -166,7 +166,6 @@ ...@@ -166,7 +166,6 @@
} }
}; };
/** /**
* Row handlers for the 'Manage display' screen. * Row handlers for the 'Manage display' screen.
*/ */
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
var $context = $(context); var $context = $(context);
var elements; var elements;
function initFileValidation (selector) { function initFileValidation(selector) {
$context.find(selector) $context.find(selector)
.once('fileValidate') .once('fileValidate')
.on('change.fileValidate', { extensions: elements[selector] }, Drupal.file.validateExtension); .on('change.fileValidate', { extensions: elements[selector] }, Drupal.file.validateExtension);
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
var $context = $(context); var $context = $(context);
var elements; var elements;
function removeFileValidation (selector) { function removeFileValidation(selector) {
$context.find(selector) $context.find(selector)
.removeOnce('fileValidate') .removeOnce('fileValidate')
.off('change.fileValidate', Drupal.file.validateExtension); .off('change.fileValidate', Drupal.file.validateExtension);
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
.find('table, .tabledrag-toggle-weight') .find('table, .tabledrag-toggle-weight')
.toggle($checkbox.prop('checked')); .toggle($checkbox.prop('checked'));
} }
// Bind hide/show and rearrange customization checkboxes. // Bind hide/show and rearrange customization checkboxes.
$configForm.once('negotiation-language-admin-bind').on('change', inputSelector, function (event) { $configForm.once('negotiation-language-admin-bind').on('change', inputSelector, function (event) {
toggleTable(event.target); toggleTable(event.target);
......
...@@ -70,9 +70,9 @@ ...@@ -70,9 +70,9 @@
// Render form container. // Render form container.
var $formContainer = this.$formContainer = $(Drupal.theme('quickeditFormContainer', { var $formContainer = this.$formContainer = $(Drupal.theme('quickeditFormContainer', {
id: id, id: id,
loadingMsg: Drupal.t('Loading…') loadingMsg: Drupal.t('Loading…')
} }
)); ));
$formContainer $formContainer
.find('.quickedit-form') .find('.quickedit-form')
......
...@@ -563,6 +563,7 @@ ...@@ -563,6 +563,7 @@
function hasOtherRegion(contextualLink) { function hasOtherRegion(contextualLink) {
return contextualLink.region !== entityElement; return contextualLink.region !== entityElement;
} }
contextualLinksQueue = _.filter(contextualLinksQueue, hasOtherRegion); contextualLinksQueue = _.filter(contextualLinksQueue, hasOtherRegion);
}); });
...@@ -576,6 +577,7 @@ ...@@ -576,6 +577,7 @@
function hasOtherFieldElement(field) { function hasOtherFieldElement(field) {
return field.el !== fieldElement; return field.el !== fieldElement;
} }
fieldsMetadataQueue = _.filter(fieldsMetadataQueue, hasOtherFieldElement); fieldsMetadataQueue = _.filter(fieldsMetadataQueue, hasOtherFieldElement);
fieldsAvailableQueue = _.filter(fieldsAvailableQueue, hasOtherFieldElement); fieldsAvailableQueue = _.filter(fieldsAvailableQueue, hasOtherFieldElement);
}); });
......
...@@ -325,7 +325,7 @@ ...@@ -325,7 +325,7 @@
var that = this; var that = this;
var discardDialog; var discardDialog;
function closeDiscardDialog (action) { function closeDiscardDialog(action) {
discardDialog.close(action); discardDialog.close(action);
// The active modal has been removed. // The active modal has been removed.
that.model.set('activeModal', null); that.model.set('activeModal', null);
......