|
@@ -81,34 +81,43 @@ CKEDITOR.define( [
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * Initializes the view.
|
|
|
|
|
- */
|
|
|
|
|
- init() {
|
|
|
|
|
- this._initRegions();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * Initializes {@link #regions} of this view by passing a DOM element
|
|
|
|
|
- * generated from {@link #_regionsSelectors} into {@link Region#init}.
|
|
|
|
|
|
|
+ * Element of this view. The element is rendered on first reference
|
|
|
|
|
+ * using {@link #template} definition and {@link #_template} object.
|
|
|
*
|
|
*
|
|
|
- * @protected
|
|
|
|
|
|
|
+ * @property el
|
|
|
*/
|
|
*/
|
|
|
- _initRegions() {
|
|
|
|
|
- let region, regionEl, regionSelector;
|
|
|
|
|
|
|
+ get el() {
|
|
|
|
|
+ if ( this._el ) {
|
|
|
|
|
+ return this._el;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- for ( region of this.regions ) {
|
|
|
|
|
- regionSelector = this._regionsSelectors[ region.name ];
|
|
|
|
|
|
|
+ if ( !this.template ) {
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Attempting to access an element of a view, which has no `template`
|
|
|
|
|
+ * property.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @error ui-view-notemplate
|
|
|
|
|
+ */
|
|
|
|
|
+ throw new CKEditorError( 'ui-view-notemplate' );
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- if ( typeof regionSelector == 'string' ) {
|
|
|
|
|
- regionEl = this.el.querySelector( regionSelector );
|
|
|
|
|
- } else if ( typeof regionSelector == 'function' ) {
|
|
|
|
|
- regionEl = regionSelector( this.el );
|
|
|
|
|
- } else {
|
|
|
|
|
- regionEl = null;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // Prepare pre–defined listeners.
|
|
|
|
|
+ this._prepareElementListeners( this.template );
|
|
|
|
|
|
|
|
- region.init( regionEl );
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ this._template = new Template( this.template );
|
|
|
|
|
+
|
|
|
|
|
+ return ( this._el = this._template.render() );
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ set el( el ) {
|
|
|
|
|
+ this._el = el;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Initializes the view.
|
|
|
|
|
+ */
|
|
|
|
|
+ init() {
|
|
|
|
|
+ this._initRegions();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -292,39 +301,6 @@ CKEDITOR.define( [
|
|
|
this._regionsSelectors[ regionName ] = regionSelector;
|
|
this._regionsSelectors[ regionName ] = regionSelector;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * Element of this view. The element is rendered on first reference
|
|
|
|
|
- * using {@link #template} definition and {@link #_template} object.
|
|
|
|
|
- *
|
|
|
|
|
- * @property el
|
|
|
|
|
- */
|
|
|
|
|
- get el() {
|
|
|
|
|
- if ( this._el ) {
|
|
|
|
|
- return this._el;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if ( !this.template ) {
|
|
|
|
|
- /**
|
|
|
|
|
- * Attempting to access an element of a view, which has no `template`
|
|
|
|
|
- * property.
|
|
|
|
|
- *
|
|
|
|
|
- * @error ui-view-notemplate
|
|
|
|
|
- */
|
|
|
|
|
- throw new CKEditorError( 'ui-view-notemplate' );
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // Prepare pre–defined listeners.
|
|
|
|
|
- this._prepareElementListeners( this.template );
|
|
|
|
|
-
|
|
|
|
|
- this._template = new Template( this.template );
|
|
|
|
|
-
|
|
|
|
|
- return ( this._el = this._template.render() );
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- set el( el ) {
|
|
|
|
|
- this._el = el;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* Binds an `attribute` of View's model so the DOM of the View is updated when the `attribute`
|
|
* Binds an `attribute` of View's model so the DOM of the View is updated when the `attribute`
|
|
|
* changes. It returns a function which, once called in the context of a DOM element,
|
|
* changes. It returns a function which, once called in the context of a DOM element,
|
|
@@ -395,6 +371,30 @@ CKEDITOR.define( [
|
|
|
this.model = this.regions = this.template = this._regionsSelectors = this._el = this._template = null;
|
|
this.model = this.regions = this.template = this._regionsSelectors = this._el = this._template = null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Initializes {@link #regions} of this view by passing a DOM element
|
|
|
|
|
+ * generated from {@link #_regionsSelectors} into {@link Region#init}.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @protected
|
|
|
|
|
+ */
|
|
|
|
|
+ _initRegions() {
|
|
|
|
|
+ let region, regionEl, regionSelector;
|
|
|
|
|
+
|
|
|
|
|
+ for ( region of this.regions ) {
|
|
|
|
|
+ regionSelector = this._regionsSelectors[ region.name ];
|
|
|
|
|
+
|
|
|
|
|
+ if ( typeof regionSelector == 'string' ) {
|
|
|
|
|
+ regionEl = this.el.querySelector( regionSelector );
|
|
|
|
|
+ } else if ( typeof regionSelector == 'function' ) {
|
|
|
|
|
+ regionEl = regionSelector( this.el );
|
|
|
|
|
+ } else {
|
|
|
|
|
+ regionEl = null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ region.init( regionEl );
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* For a given event name or callback, returns a function which,
|
|
* For a given event name or callback, returns a function which,
|
|
|
* once executed in a context of an element, attaches native DOM listener
|
|
* once executed in a context of an element, attaches native DOM listener
|