|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en" ng-app="demo"> |
| 3 | +<head> |
| 4 | + <meta charset="utf-8"> |
| 5 | + <title>AngularJS ui-select</title> |
| 6 | + |
| 7 | + <!-- |
| 8 | + IE8 support, see AngularJS Internet Explorer Compatibility http://docs.angularjs.org/guide/ie |
| 9 | + For Firefox 3.6, you will also need to include jQuery and ECMAScript 5 shim |
| 10 | + --> |
| 11 | + <!--[if lt IE 9]> |
| 12 | + <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.js"></script> |
| 13 | + <script src="http://cdnjs.cloudflare.com/ajax/libs/es5-shim/2.2.0/es5-shim.js"></script> |
| 14 | + <script> |
| 15 | + document.createElement('ui-select'); |
| 16 | + document.createElement('ui-select-match'); |
| 17 | + document.createElement('ui-select-choices'); |
| 18 | + </script> |
| 19 | + <![endif]--> |
| 20 | + |
| 21 | + <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.18/angular.js"></script> |
| 22 | + <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.18/angular-sanitize.js"></script> |
| 23 | + <link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.css"> |
| 24 | + |
| 25 | + <!-- ui-select files --> |
| 26 | + <script src="../dist/select.js"></script> |
| 27 | + <link rel="stylesheet" href="../dist/select.css"> |
| 28 | + |
| 29 | + <script src="demo.js"></script> |
| 30 | + |
| 31 | + <!-- Select2 theme --> |
| 32 | + <link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/select2/3.4.5/select2.css"> |
| 33 | + |
| 34 | + <!-- |
| 35 | + Selectize theme |
| 36 | + Less versions are available at https://github.com/brianreavis/selectize.js/tree/master/dist/less |
| 37 | + --> |
| 38 | + <link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.8.5/css/selectize.default.css"> |
| 39 | + <!-- <link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.8.5/css/selectize.bootstrap2.css"> --> |
| 40 | + <!-- <link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.8.5/css/selectize.bootstrap3.css"> --> |
| 41 | + |
| 42 | + <style> |
| 43 | + body { |
| 44 | + padding: 15px; |
| 45 | + } |
| 46 | + |
| 47 | + .select2 > .select2-choice.ui-select-match { |
| 48 | + /* Because of the inclusion of Bootstrap */ |
| 49 | + height: 29px; |
| 50 | + } |
| 51 | + |
| 52 | + .selectize-control > .selectize-dropdown { |
| 53 | + top: 36px; |
| 54 | + } |
| 55 | + |
| 56 | + /* Some additional styling to demonstrate that append-to-body helps achieve the proper z-index layering. */ |
| 57 | + .select-box { |
| 58 | + background: #fff; |
| 59 | + position: relative; |
| 60 | + z-index: 1; |
| 61 | + } |
| 62 | + .alert-info.positioned { |
| 63 | + margin-top: 1em; |
| 64 | + position: relative; |
| 65 | + z-index: 10000; // The select2 dropdown has a z-index of 9999 |
| 66 | + } |
| 67 | + </style> |
| 68 | +</head> |
| 69 | + |
| 70 | +<body ng-controller="DemoCtrl"> |
| 71 | + <script src="demo.js"></script> |
| 72 | + |
| 73 | + <button class="btn btn-default btn-xs" ng-click="enable()">Enable ui-select</button> |
| 74 | + <button class="btn btn-default btn-xs" ng-click="disable()">Disable ui-select</button> |
| 75 | + <button class="btn btn-default btn-xs" ng-click="appendToBodyDemo.startToggleTimer()" |
| 76 | + ng-disabled="appendToBodyDemo.remainingTime"> |
| 77 | + {{ appendToBodyDemo.remainingTime ? 'Toggling in ' + (appendToBodyDemo.remainingTime / 1000) + ' seconds' : 'Toggle ui-select presence' }} |
| 78 | + </button> |
| 79 | + <button class="btn btn-default btn-xs" ng-click="clear()">Clear ng-model</button> |
| 80 | + |
| 81 | + <div class="select-box" ng-show="appendToBodyDemo.present"> |
| 82 | + <h3>Bootstrap theme</h3> |
| 83 | + <p>Selected: {{address.selected.formatted_address}}</p> |
| 84 | + <ui-select ng-model="address.selected" |
| 85 | + theme="bootstrap" |
| 86 | + ng-disabled="disabled" |
| 87 | + reset-search-input="false" |
| 88 | + style="width: 300px;" |
| 89 | + title="Choose an address" |
| 90 | + append-to-body="true"> |
| 91 | + <ui-select-match placeholder="Enter an address...">{{$select.selected.formatted_address}}</ui-select-match> |
| 92 | + <ui-select-choices repeat="address in addresses track by $index" |
| 93 | + refresh="refreshAddresses($select.search)" |
| 94 | + refresh-delay="0"> |
| 95 | + <div ng-bind-html="address.formatted_address | highlight: $select.search"></div> |
| 96 | + </ui-select-choices> |
| 97 | + </ui-select> |
| 98 | + <p class="alert alert-info positioned">The select dropdown menu should be displayed above this element.</p> |
| 99 | + </div> |
| 100 | + |
| 101 | + <div class="select-box" ng-if="appendToBodyDemo.present"> |
| 102 | + <h3>Select2 theme</h3> |
| 103 | + <p>Selected: {{person.selected}}</p> |
| 104 | + <ui-select ng-model="person.selected" theme="select2" ng-disabled="disabled" style="min-width: 300px;" title="Choose a person" append-to-body="true"> |
| 105 | + <ui-select-match placeholder="Select a person in the list or search his name/age...">{{$select.selected.name}}</ui-select-match> |
| 106 | + <ui-select-choices repeat="person in people | propsFilter: {name: $select.search, age: $select.search}"> |
| 107 | + <div ng-bind-html="person.name | highlight: $select.search"></div> |
| 108 | + <small> |
| 109 | + email: {{person.email}} |
| 110 | + age: <span ng-bind-html="''+person.age | highlight: $select.search"></span> |
| 111 | + </small> |
| 112 | + </ui-select-choices> |
| 113 | + </ui-select> |
| 114 | + <p class="alert alert-info positioned">The select dropdown menu should be displayed above this element.</p> |
| 115 | + </div> |
| 116 | + |
| 117 | + <div class="select-box" ng-if="appendToBodyDemo.present"> |
| 118 | + <h3>Selectize theme</h3> |
| 119 | + <p>Selected: {{country.selected}}</p> |
| 120 | + <ui-select ng-model="country.selected" theme="selectize" ng-disabled="disabled" style="width: 300px;" title="Choose a country" append-to-body="true"> |
| 121 | + <ui-select-match placeholder="Select or search a country in the list...">{{$select.selected.name}}</ui-select-match> |
| 122 | + <ui-select-choices repeat="country in countries | filter: $select.search"> |
| 123 | + <span ng-bind-html="country.name | highlight: $select.search"></span> |
| 124 | + <small ng-bind-html="country.code | highlight: $select.search"></small> |
| 125 | + </ui-select-choices> |
| 126 | + </ui-select> |
| 127 | + <p class="alert alert-info positioned">The select dropdown menu should be displayed above this element.</p> |
| 128 | + </div> |
| 129 | +</body> |
| 130 | +</html> |
0 commit comments