diff --git a/.gitignore b/.gitignore index a088b6f..d8d7394 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules bower_components +demo/bower_components \ No newline at end of file diff --git a/demo/app.js b/demo/app.js new file mode 100644 index 0000000..7530204 --- /dev/null +++ b/demo/app.js @@ -0,0 +1,114 @@ + +var app = angular.module('angular-ui-select2-demo', ['ui.select2']); + +app.controller('MainCtrl', function ($scope, $element) { + + var states = [ + { text: 'Alaskan/Hawaiian Time Zone', children: [ + { id: 'AK', text: 'Alaska' }, + { id: 'HI', text: 'Hawaii' } + ]}, + { text: 'Pacific Time Zone', children: [ + { id: 'CA', text: 'California' }, + { id: 'NV', text: 'Nevada' }, + { id: 'OR', text: 'Oregon' }, + { id: 'WA', text: 'Washington' } + ]}, + { text: 'Mountain Time Zone', children: [ + { id: 'AZ', text: 'Arizona' }, + { id: 'CO', text: 'Colorado' }, + { id: 'ID', text: 'Idaho' }, + { id: 'MT', text: 'Montana' }, + { id: 'NE', text: 'Nebraska' }, + { id: 'NM', text: 'New Mexico' }, + { id: 'ND', text: 'North Dakota' }, + { id: 'UT', text: 'Utah' }, + { id: 'WY', text: 'Wyoming' } + ]}, + { text: 'Central Time Zone', children: [ + { id: 'AL', text: 'Alabama' }, + { id: 'AR', text: 'Arkansas' }, + { id: 'IL', text: 'Illinois' }, + { id: 'IA', text: 'Iowa' }, + { id: 'KS', text: 'Kansas' }, + { id: 'KY', text: 'Kentucky' }, + { id: 'LA', text: 'Louisiana' }, + { id: 'MN', text: 'Minnesota' }, + { id: 'MS', text: 'Mississippi' }, + { id: 'MO', text: 'Missouri' }, + { id: 'OK', text: 'Oklahoma' }, + { id: 'SD', text: 'South Dakota' }, + { id: 'TX', text: 'Texas' }, + { id: 'TN', text: 'Tennessee' }, + { id: 'WI', text: 'Wisconsin' } + ]}, + { text: 'Eastern Time Zone', children: [ + { id: 'CT', text: 'Connecticut' }, + { id: 'DE', text: 'Delaware' }, + { id: 'FL', text: 'Florida' }, + { id: 'GA', text: 'Georgia' }, + { id: 'IN', text: 'Indiana' }, + { id: 'ME', text: 'Maine' }, + { id: 'MD', text: 'Maryland' }, + { id: 'MA', text: 'Massachusetts' }, + { id: 'MI', text: 'Michigan' }, + { id: 'NH', text: 'New Hampshire' }, + { id: 'NJ', text: 'New Jersey' }, + { id: 'NY', text: 'New York' }, + { id: 'NC', text: 'North Carolina' }, + { id: 'OH', text: 'Ohio' }, + { id: 'PA', text: 'Pennsylvania' }, + { id: 'RI', text: 'Rhode Island' }, + { id: 'SC', text: 'South Carolina' }, + { id: 'VT', text: 'Vermont' }, + { id: 'VA', text: 'Virginia' }, + { id: 'WV', text: 'West Virginia' } + ]} + ]; + + function findState(id) { + for (var i=0; i=1.2.0", + "select2": "~3.4", + "jquery": ">=1.6.4", + "bootstrap": "~3.0.3", + "angular-ui-select2": "~0.0.5" + } +} diff --git a/demo/index.html b/demo/index.html new file mode 100644 index 0000000..dc01961 --- /dev/null +++ b/demo/index.html @@ -0,0 +1,225 @@ + + + + + + + + + + + + + + +
+ +
+

The Basics

+
+
+ + +
+
+

Value

+
{{ basicsValue }}
+
+
+
+ +
+

Multi-Value

+
+
+ + +
+
+

Value

+
{{ multiValue }}
+
+
+
+
+ + +
+
+

Config

+
{
+    multiple: true,
+    query: function (query) {
+      query.callback({ results: states });
+    },
+    initSelection: function(element, callback) {
+      var val = $(element).select2('val'),
+        results = [];
+      for (var i=0; i<val.length; i++) {
+        results.push(findState(val[i]));
+      }
+      callback(results);
+    }
+  }
+

Value

+
{{ multi2Value }}
+
+
+
+ +
+

Placeholders

+
+
+ + +
+
+

Value

+
{{ placeholdersValue }}
+
+
+
+
+ + +
+
+

Config

+
{{ placeholders }}
+

Value

+
{{ placeholdersMultiValue }}
+
+
+
+ +
+

Array Data

+
+
+ + +
+
+

Config

+
{{ array }}
+

Value

+
{{ arrayValue }}
+
+
+
+
+ + +
+
+

Config

+
{
+    query: function (query) {
+      query.callback({ results: states });
+    },
+    initSelection: function(element, callback) {
+      var val = $(element).select2('val');
+      return callback(findState(val));
+    }
+  }
+

Value

+
{{ arrayAsyncValue }}
+
+
+
+ +
+ +