Code coverage report for src/select/bootstrap-select.directive.js

Statements: 100% (21 / 21)      Branches: 50% (2 / 4)      Functions: 100% (6 / 6)      Lines: 100% (21 / 21)      Ignored: none     

All files » src/select/ » bootstrap-select.directive.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 481     3             3   3 12 12       3 3     3   3 3 3     3 3 3 3   3     3 3     3   3        
angular.module('patternfly.select').directive('pfBootstrapSelect', function () {
  'use strict';
 
  return {
    restrict: 'A',
    require: '?ngModel',
    scope: {
      selectPickerOptions: '=pfBootstrapSelect'
    },
    link: function (scope, element, attrs, ngModel) {
      var optionCollectionList, optionCollectionExpr, optionCollection, $render = ngModel.$render;
 
      var selectpickerRefresh = function (argument) {
        scope.$applyAsync(function () {
          element.selectpicker('refresh');
        });
      };
 
      var selectpickerDestroy = function () {
        element.selectpicker('destroy');
      };
 
      element.selectpicker(scope.selectPickerOptions);
 
      ngModel.$render = function () {
        $render.apply(this, arguments);
        selectpickerRefresh();
      };
 
      Eif (attrs.ngOptions) {
        optionCollectionList = attrs.ngOptions.split('in ');
        optionCollectionExpr = optionCollectionList[optionCollectionList.length - 1].split(/track by|\|/);
        optionCollection = optionCollectionExpr[0];
 
        scope.$parent.$watchCollection(optionCollection, selectpickerRefresh);
      }
 
      Eif (attrs.ngModel) {
        scope.$parent.$watch(attrs.ngModel, selectpickerRefresh);
      }
 
      attrs.$observe('disabled', selectpickerRefresh);
 
      scope.$on('$destroy', selectpickerDestroy);
    }
  };
});