浏览代码

Bound LabeledInputView's class to #isReadOnly attribute.

Aleksander Nowodzinski 8 年之前
父节点
当前提交
aa106f0867

+ 7 - 1
packages/ckeditor5-ui/src/labeledinput/labeledinputview.js

@@ -68,9 +68,15 @@ export default class LabeledInputView extends View {
 		 */
 		this.inputView = this._createInputView( InputView, id );
 
+		const bind = this.bindTemplate;
+
 		this.template = new Template( {
 			tag: 'div',
-
+			attributes: {
+				class: [
+					bind.if( 'isReadOnly', 'ck-disabled' )
+				]
+			},
 			children: [
 				this.labelView,
 				this.inputView

+ 12 - 0
packages/ckeditor5-ui/tests/labeledinput/labeledinputview.js

@@ -44,6 +44,18 @@ describe( 'LabeledInputView', () => {
 		it( 'should have input view', () => {
 			expect( view.template.children.get( 1 ) ).to.equal( view.inputView );
 		} );
+
+		describe( 'DOM bindings', () => {
+			describe( 'class', () => {
+				it( 'should react on view#isReadOnly', () => {
+					view.isReadOnly = false;
+					expect( view.element.classList.contains( 'ck-disabled' ) ).to.be.false;
+
+					view.isReadOnly = true;
+					expect( view.element.classList.contains( 'ck-disabled' ) ).to.be.true;
+				} );
+			} );
+		} );
 	} );
 
 	describe( 'binding', () => {