scratch – Blame information for rev 125
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
125 | office | 1 | $('.example_typeahead > > input').tagsinput({ |
2 | typeahead: { |
||
3 | source: function(query) { |
||
4 | return $.getJSON('assets/citynames.json'); |
||
5 | } |
||
6 | } |
||
7 | }); |
||
8 | |||
9 | $('.example_objects_as_tags > > input').tagsinput({ |
||
10 | itemValue: 'value', |
||
11 | itemText: 'text', |
||
12 | typeahead: { |
||
13 | source: function(query) { |
||
14 | return $.getJSON('assets/cities.json'); |
||
15 | } |
||
16 | } |
||
17 | }); |
||
18 | $('.example_objects_as_tags > > input').tagsinput('add', { "value": 1 , "text": "Amsterdam" , "continent": "Europe" }); |
||
19 | $('.example_objects_as_tags > > input').tagsinput('add', { "value": 4 , "text": "Washington" , "continent": "America" }); |
||
20 | $('.example_objects_as_tags > > input').tagsinput('add', { "value": 7 , "text": "Sydney" , "continent": "Australia" }); |
||
21 | $('.example_objects_as_tags > > input').tagsinput('add', { "value": 10, "text": "Beijing" , "continent": "Asia" }); |
||
22 | $('.example_objects_as_tags > > input').tagsinput('add', { "value": 13, "text": "Cairo" , "continent": "Africa" }); |
||
23 | |||
24 | $('.example_tagclass > > input').tagsinput({ |
||
25 | tagClass: function(item) { |
||
26 | switch (item.continent) { |
||
27 | case 'Europe' : return 'label label-info'; |
||
28 | case 'America' : return 'label label-danger label-important'; |
||
29 | case 'Australia': return 'label label-success'; |
||
30 | case 'Africa' : return 'label'; |
||
31 | case 'Asia' : return 'label label-warning'; |
||
32 | } |
||
33 | }, |
||
34 | itemValue: 'value', |
||
35 | itemText: 'text', |
||
36 | typeahead: { |
||
37 | source: function(query) { |
||
38 | return $.getJSON('assets/cities.json'); |
||
39 | } |
||
40 | } |
||
41 | }); |
||
42 | $('.example_tagclass > > input').tagsinput('add', { "value": 1 , "text": "Amsterdam" , "continent": "Europe" }); |
||
43 | $('.example_tagclass > > input').tagsinput('add', { "value": 4 , "text": "Washington" , "continent": "America" }); |
||
44 | $('.example_tagclass > > input').tagsinput('add', { "value": 7 , "text": "Sydney" , "continent": "Australia" }); |
||
45 | $('.example_tagclass > > input').tagsinput('add', { "value": 10, "text": "Beijing" , "continent": "Asia" }); |
||
46 | $('.example_tagclass > > input').tagsinput('add', { "value": 13, "text": "Cairo" , "continent": "Africa" }); |
||
47 | |||
48 | angular.module('AngularExample', ['bootstrap-tagsinput']) |
||
49 | .controller('CityTagsInputController', |
||
50 | function CityTagsInputController($scope, $http) { |
||
51 | // Init with some cities |
||
52 | $scope.cities = [ |
||
53 | { "value": 1 , "text": "Amsterdam" , "continent": "Europe" }, |
||
54 | { "value": 4 , "text": "Washington" , "continent": "America" }, |
||
55 | { "value": 7 , "text": "Sydney" , "continent": "Australia" }, |
||
56 | { "value": 10, "text": "Beijing" , "continent": "Asia" }, |
||
57 | { "value": 13, "text": "Cairo" , "continent": "Africa" } |
||
58 | ]; |
||
59 | |||
60 | $scope.queryCities = function(query) { |
||
61 | return $http.get('assets/cities.json'); |
||
62 | }; |
||
63 | |||
64 | $scope.getTagClass = function(city) { |
||
65 | switch (city.continent) { |
||
66 | case 'Europe' : return 'label label-info'; |
||
67 | case 'America' : return 'label label-danger label-important'; |
||
68 | case 'Australia': return 'label label-success'; |
||
69 | case 'Africa' : return 'label'; |
||
70 | case 'Asia' : return 'label label-warning'; |
||
71 | } |
||
72 | }; |
||
73 | } |
||
74 | ); |