/** * MUI Angular Select Component * @module angular/select */ import angular from 'angular'; import * as formlib from '../js/lib/forms'; import * as util from '../js/lib/util'; import * as jqLite from '../js/lib/jqLite'; const moduleName = 'mui.select'; angular.module(moduleName, []) .directive('muiSelect', ['$timeout', function($timeout) { return { restrict: 'AE', require: ['ngModel'], scope: { label: '@', name: '@', ngDisabled: '=', ngModel: '=' }, replace: true, transclude: true, template: '
' + '' + '' + '
' + '
{{option.label}}
' + '
' + '
', link: function(scope, element, attrs, controller, transcludeFn) { var wrapperEl = element, menuEl = element.find('div'), selectEl = element.find('select'), isUndef = angular.isUndefined, cacheIndex; // disable MUI js selectEl[0]._muiSelect = true; // init scope scope.options = []; scope.isOpen = false; scope.useDefault = ('ontouchstart' in document.documentElement) ? true : false; scope.origTabIndex = selectEl[0].tabIndex; scope.menuIndex = 0; scope.q = ''; scope.qTimeout = null; // handle `use-default` attribute if (!isUndef(attrs.useDefault)) scope.useDefault = true; // use tabIndex to make wrapper or inner focusable if (scope.useDefault === false) { wrapperEl.prop('tabIndex', '0'); selectEl.prop('tabIndex', '-1'); } else { wrapperEl.prop('tabIndex', '-1'); selectEl.prop('tabIndex', '0'); } // extract