-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
executable file
·122 lines (115 loc) · 3.11 KB
/
index.html
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<!DOCTYPE html>
<html>
<head>
<title>ng-drop-btn Demo</title>
<link href="bootstrap.css" rel="stylesheet" type="text/css" />
<!--link href="css/app.css" rel="stylesheet" type="text/css" /-->
<link href="ng-tree-btn.css" rel="stylesheet" type="text/css" />
<script src="../js/jquery-1.8.2.min.js"></script>
<!--script src="http://code.jquery.com/jquery.min.js"></script-->
<script src="../js/bootstrap.js"></script>
<script src="angular.js"></script>
<script src="ng-tree-btn.js"></script>
<meta charset=utf-8 />
<style type="text/css">
.demo { padding: 20px; }
</style>
</head>
<body>
<script type="text/javascript">
angular.module('demoApp', ['pbComponents']);
var myCtrl = function ($scope) {
$scope.rooms = {
"items": [
{"id":"1","name": "Room 1"},
{"id":"2","name": "Room 2", "checked":true},
{"id":"3","name": "Room 3", "checked":true},
{"id":"4","name": "Room 4"}
]
};
$scope.guests = {
items: [
{
"name": "Room 1",
"items": [
{"id":"g11","name": "Guest 11"},
{"id":"g12","name": "Guest 12", "checked": true }
]
},
{
"name": "Room 2",
"items": [
{"id":"g21","name": "Guest 21"},
{"id":"g22","name": "Guest 22"}
]
}
]
};
function findRoomById(id) {
var i, options = $scope.rooms.items;
for (i in options) {
if (options[i].id == id) {
return options[i];
}
}
return null;
}
$scope.populateDropdown = function (res) {
var id, room, s = "";
for (id in res) {
if (res[id]){
room = findRoomById(id);
if (room != null) {
s += room.name + ", ";
}
}
}
if (s.length > 19) {
$scope.label = s.substring(0,17)+"...";
} else if (s.length > 2) {
$scope.label = s.substring(0, s.length - 2);
}
}
$scope.processRes = function (res) {
var prop;
if (typeof(res) === "string") {
alert(res);
} else {
var s = "";
for(prop in res){
s += prop + ":" + res[prop] + ",";
}
alert(s);
}
};
$scope.btns = [
{
"label":"Drop Button",
"chk":true,
"items": $scope.rooms
},
{
"label":"Drop Button 2",
"chk":true,
"items": $scope.guests
}
];
$scope.isOn = function (btn) {
return btn.chk;
};
}
</script>
<div ng-app="demoApp" ng-controller="myCtrl">
<div class="btn-toolbar" ng-app="demoApp" ng-controller="myCtrl">
<div ng-repeat="btn in btns" class="pull-left demo">
<div class="btn-group">
<div ng-tree-btn="btn.items" label="{{btn.label}}" is-enabled="isOn(btn)"
btncls="btn-mini w140 btn-success" callback="processRes(res)"></div>
</div>
<input type="checkbox" ng-model="btn.chk"> Enabled: {{btn.chk}}
</div>
</div>
<!--input type="checkbox" ng-model="btn.chk"> Enable {{btn.chk}} -->
</div>
</body>
</html>