wp/wp-admin/js/widgets/custom-html-widgets.js
changeset 9 177826044cd9
parent 7 cf61fcea0001
child 16 a86126ab1dd4
--- a/wp/wp-admin/js/widgets/custom-html-widgets.js	Mon Oct 14 18:06:33 2019 +0200
+++ b/wp/wp-admin/js/widgets/custom-html-widgets.js	Mon Oct 14 18:28:13 2019 +0200
@@ -1,6 +1,15 @@
+/**
+ * @output wp-admin/js/widgets/custom-html-widgets.js
+ */
+
 /* global wp */
 /* eslint consistent-this: [ "error", "control" ] */
 /* eslint no-magic-numbers: ["error", { "ignore": [0,1,-1] }] */
+
+/**
+ * @namespace wp.customHtmlWidget
+ * @memberOf wp
+ */
 wp.customHtmlWidgets = ( function( $ ) {
 	'use strict';
 
@@ -15,14 +24,7 @@
 		}
 	};
 
-	/**
-	 * Text widget control.
-	 *
-	 * @class CustomHtmlWidgetControl
-	 * @constructor
-	 * @abstract
-	 */
-	component.CustomHtmlWidgetControl = Backbone.View.extend({
+	component.CustomHtmlWidgetControl = Backbone.View.extend(/** @lends wp.customHtmlWidgets.CustomHtmlWidgetControl.prototype */{
 
 		/**
 		 * View events.
@@ -32,11 +34,16 @@
 		events: {},
 
 		/**
-		 * Initialize.
+		 * Text widget control.
+		 *
+		 * @constructs wp.customHtmlWidgets.CustomHtmlWidgetControl
+		 * @augments Backbone.View
+		 * @abstract
 		 *
 		 * @param {Object} options - Options.
 		 * @param {jQuery} options.el - Control field container element.
 		 * @param {jQuery} options.syncContainer - Container element where fields are synced for the server.
+		 *
 		 * @returns {void}
 		 */
 		initialize: function initialize( options ) {
@@ -105,10 +112,10 @@
 			 * to prevent the editor's contents from getting sanitized as soon as a user removes focus from
 			 * the editor. This is particularly important for users who cannot unfiltered_html.
 			 */
-			control.contentUpdateBypassed = control.fields.content.is( document.activeElement ) || control.editor && control.editor.codemirror.state.focused || 0 !== control.currentErrorAnnotations;
+			control.contentUpdateBypassed = control.fields.content.is( document.activeElement ) || control.editor && control.editor.codemirror.state.focused || 0 !== control.currentErrorAnnotations.length;
 			if ( ! control.contentUpdateBypassed ) {
 				syncInput = control.syncContainer.find( '.sync-input.content' );
-				control.fields.content.val( syncInput.val() ).trigger( 'change' );
+				control.fields.content.val( syncInput.val() );
 			}
 		},
 
@@ -171,6 +178,8 @@
 				/**
 				 * Handle tabbing to the field before the editor.
 				 *
+				 * @ignore
+				 *
 				 * @returns {void}
 				 */
 				onTabPrevious: function onTabPrevious() {
@@ -180,6 +189,8 @@
 				/**
 				 * Handle tabbing to the field after the editor.
 				 *
+				 * @ignore
+				 *
 				 * @returns {void}
 				 */
 				onTabNext: function onTabNext() {
@@ -190,6 +201,8 @@
 				/**
 				 * Disable save button and store linting errors for use in updateFields.
 				 *
+				 * @ignore
+				 *
 				 * @param {Array} errorAnnotations - Error notifications.
 				 * @returns {void}
 				 */
@@ -200,6 +213,8 @@
 				/**
 				 * Update error notice.
 				 *
+				 * @ignore
+				 *
 				 * @param {Array} errorAnnotations - Error annotations.
 				 * @returns {void}
 				 */
@@ -259,6 +274,8 @@
 	/**
 	 * Mapping of widget ID to instances of CustomHtmlWidgetControl subclasses.
 	 *
+	 * @alias wp.customHtmlWidgets.widgetControls
+	 *
 	 * @type {Object.<string, wp.textWidgets.CustomHtmlWidgetControl>}
 	 */
 	component.widgetControls = {};
@@ -266,8 +283,11 @@
 	/**
 	 * Handle widget being added or initialized for the first time at the widget-added event.
 	 *
+	 * @alias wp.customHtmlWidgets.handleWidgetAdded
+	 *
 	 * @param {jQuery.Event} event - Event.
 	 * @param {jQuery}       widgetContainer - Widget container element.
+	 *
 	 * @returns {void}
 	 */
 	component.handleWidgetAdded = function handleWidgetAdded( event, widgetContainer ) {
@@ -325,6 +345,8 @@
 	/**
 	 * Setup widget in accessibility mode.
 	 *
+	 * @alias wp.customHtmlWidgets.setupAccessibleMode
+	 *
 	 * @returns {void}
 	 */
 	component.setupAccessibleMode = function setupAccessibleMode() {
@@ -358,6 +380,8 @@
 	 * the widgets admin screen and also via the 'widget-synced' event when making
 	 * a change to a widget in the customizer.
 	 *
+	 * @alias wp.customHtmlWidgets.handleWidgetUpdated
+	 *
 	 * @param {jQuery.Event} event - Event.
 	 * @param {jQuery}       widgetContainer - Widget container element.
 	 * @returns {void}
@@ -387,7 +411,10 @@
 	 * When WordPress enqueues this script, it should have an inline script
 	 * attached which calls wp.textWidgets.init().
 	 *
+	 * @alias wp.customHtmlWidgets.init
+	 *
 	 * @param {object} settings - Options for code editor, exported from PHP.
+	 *
 	 * @returns {void}
 	 */
 	component.init = function init( settings ) {