From 3bfc9c80405a739881f3f3a02a943b8cff447536 Mon Sep 17 00:00:00 2001 From: Daniel Bendel Date: Mon, 6 Jun 2016 10:15:38 +0200 Subject: [PATCH] feat(md-select): add disabled property and functionality, closes #190 --- src/select/select.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/select/select.js b/src/select/select.js index 07a585df..f85fa8ce 100644 --- a/src/select/select.js +++ b/src/select/select.js @@ -1,4 +1,4 @@ -import { customAttribute } from 'aurelia-templating'; +import { bindable, customAttribute } from 'aurelia-templating'; import { BindingEngine } from 'aurelia-binding'; import { inject } from 'aurelia-dependency-injection'; import { TaskQueue } from 'aurelia-task-queue'; @@ -8,6 +8,7 @@ import { fireEvent } from '../common/events'; @inject(Element, LogManager, BindingEngine, TaskQueue) @customAttribute('md-select') export class MdSelect { + @bindable() disabled = false; _suspendUpdate = false; subscriptions = []; @@ -43,6 +44,22 @@ export class MdSelect { }); } + disabledChanged(newValue) { + let $wrapper = $(this.element).parent('.select-wrapper'); + if ($wrapper.length > 0) { + if (newValue) { + $('.caret', $wrapper).addClass('disabled'); + $('input.select-dropdown', $wrapper).attr('disabled', 'disabled'); + $wrapper.attr('disabled', 'disabled'); + } else { + $('.caret', $wrapper).removeClass('disabled'); + $('input.select-dropdown', $wrapper).attr('disabled', null); + $wrapper.attr('disabled', null); + $('.select-dropdown', $wrapper).dropdown({'hover': false, 'closeOnClick': false}); + } + } + } + notifyBindingEngine() { this.log.debug('selectedOptions changed', arguments); }