Browse Source

Aligned IconManager component to the new View API.

Aleksander Nowodzinski 9 years ago
parent
commit
e26a108fe8

+ 28 - 0
packages/ckeditor5-ui/src/iconmanager/iconmanager.js

@@ -0,0 +1,28 @@
+/**
+ * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+
+'use strict';
+
+import Controller from '../controller.js';
+
+/**
+ * Icon manager class.
+ *
+ * @memberOf ui.iconManager
+ * @extends ui.Controller
+ */
+export default class IconManager extends Controller {
+	/**
+	 * Creates a new instance of the IconManager class.
+	 *
+	 * @param {utils.Observable} model
+	 * @param {ui.View} [view] View instance.
+	 */
+	constructor( model, view ) {
+		super( model, view );
+
+		view.model.bind( 'sprite' ).to( model );
+	}
+}

+ 4 - 5
packages/ckeditor5-ui/src/iconmanagerview.js → packages/ckeditor5-ui/src/iconmanager/iconmanagerview.js

@@ -5,8 +5,8 @@
 
 'use strict';
 
-import View from './view.js';
-import Template from './template.js';
+import View from '../view.js';
+import Template from '../template.js';
 
 /**
  * Icon manager view using {@link ui.iconManager.IconManagerModel}.
@@ -14,10 +14,9 @@ import Template from './template.js';
  * @memberOf ui.iconManager
  * @extends ui.View
  */
-
 export default class IconManagerView extends View {
-	constructor( model, locale ) {
-		super( model, locale );
+	constructor( locale ) {
+		super( locale );
 
 		this.template = new Template( {
 			tag: 'svg',

+ 8 - 4
packages/ckeditor5-ui/tests/iconmanagerview.js

@@ -8,18 +8,22 @@
 'use strict';
 
 import testUtils from '/tests/ckeditor5/_utils/utils.js';
-import IconManagerView from '/ckeditor5/ui/iconmanagerview.js';
+import IconManager from '/ckeditor5/ui/iconmanager/iconmanager.js';
+import IconManagerView from '/ckeditor5/ui/iconmanager/iconmanagerview.js';
 import Model from '/ckeditor5/ui/model.js';
 
 testUtils.createSinonSandbox();
 
 describe( 'IconManagerView', () => {
-	let view;
+	let model, view;
 
 	beforeEach( () => {
-		view = new IconManagerView( new Model( {
+		view = new IconManagerView();
+		model = new Model( {
 			sprite: 'foo'
-		} ) );
+		} );
+
+		return new IconManager( model, view ).init();
 	} );
 
 	describe( 'constructor', () => {