-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
382 lines (343 loc) · 9.42 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
<!DOCTYPE html>
<html ng-app="demo">
<head>
<title>Angular bootstrap row splitter</title>
<meta charset="utf-8" />
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/latest/css/bootstrap-theme.min.css">
<link href="sample/css/style.css" rel="stylesheet" />
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script src="sample/script/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.1/angular-route.min.js"></script>
<script src="src/bootstrap-row-splitter.js"></script>
<script src="sample/script.js"></script>
</head>
<body ng-controller="demoController">
<script type="text/ng-template" id="_home.html">
<h1>Getting Started</h1><hr>
<h3>Requirements</h3><hr>
<p>
I hope it will work 1.3.x and higher, Since I am using the basic directive.
</p>
<h3>
Files to download
</h3>
<hr>
<h4> <b> Add the files to your html</b></h4>
<p>
<code>
<script src="src/bootstrap-row-splitter.js"></script>
or
<script src="src/bootstrap-row-splitter.min.js"></script>
</code>
</p>
<p>
<b><h4>Add the module</h4></b>
</p>
<p>
<kbd>
angular.module('yourModule','jjBootstrapRowSplitter');
</kbd>
</p>
<h3>
Html code
</h3>
<pre><div class="splitted-item-wrapper"
bootstrap-row-splitter
shared-values="sharedValues"
options="arraySplit.options"
events="arraySplit.events"
template-url="{{ arraySplit.templateUrl '}}">
</div>
</pre>
<h3>Template code - Design based on your need - Refer id="_template.html" in sample</h3> <hr/>
<h4>
<b>splitItems</b> - This is the array which is splitted from your actual array.
</h4>
<pre> <code> <div class="row mrg5B" ng-repeat="subItems in splitItems"
ng-init="$parentIndex = $index"
ng-class="splitterParentClass[$parentIndex]">
<div ng-repeat="item in subItems" ng-class="splitItemsClasses[$parentIndex][$index]">
<div class="panel" ng-class="sharedValues.$parentScope.getPanelClass($index)">
<div class="panel-heading">
{{item.name'}}"
</div>
<div class="panel-body">
{{item.description}}
</div>
</div>
</div>
</div>
</code>
</pre>
<h3>Your code in controller</h3><hr/>
<pre>
// Here I have shared the controler scope for the directive.
$scope.sharedValues={$parentScope:$scope};
// Here I am calling to the controller to get the panel class
$scope.getPanelClass=getPanelClass;
// Array split object
$scope.arraySplit={
templateUrl:'_template.html', // Template that should be opened
options:{
// calculate on window resize - default value false
calculateOnResize: true,
// Mandatory - This is used to get the data in the directive
initializeValue: function () {
return angular.copy(data);
},
// No of columns for the first row - This is optional
firstSplitSizes: {
lg: 3
},
// No of columns for the rows
mediaSizes: {
xs: 1,
sm: 2,
md: 3,
lg: 4
},
// class name for the first row coulmns
firstSplitCustomClass:'firstSplitterClass',
// class name for the rows' columns
arraySplitCustomClass:'arraySplitterClass',
// class name for the rows
splitterParentClass:'row-divider'
},
events:{
}
}
$scope.splitItems=splitItems;
// Called from the directive template
function getPanelClass(index){
if((index%4)==0)
return 'panel-primary';
else if((index%4)==1)
return 'panel-success';
else if((index%4)==2)
return 'panel-info';
else if((index%4)==3)
return 'panel-danger';
}
// <b>To split the array whenever we need</b>
function splitItems(){
$scope.arraySplit.events.splitArray();
}
</pre>
<h3>
Configuration and options
</h3>
<hr/>
<dl class="dl-horizontal">
<dt>
bootstrap-row-splitter
</dt>
<dd>
Directive to be included in your html
</dd>
<dt>
shared-values
</dt>
<dd>
That is shared to the directive from the controller
</dd>
<dt>
options
</dt>
<dd>
Options for the directive
</dd>
<dt>
events
</dt>
<dd>
Events that is shared from the directive to the controller.
</dd>
<dt>
template-url
</dt>
<dd>
Template that should be passed to show the data using ng-repeat
</dd>
</dl>
<h3>
Options
</h3>
<hr/>
<dl >
<dt>
Options - This is a object with the following properties
</dt>
<dd>
<dl class="dl-horizontal">
<dt>
calculateOnResize
</dt>
<dd>
This is to recalculate the split array on window resize (Default is false)
</dd>
<dt>
initializeValue
</dt>
<dd>
<b>This is mandatory function for this directive</b>
This is the function used to initialize the value.
This is usually used to do manipulation before spliting the array.
</dd>
<dt>
firstSplitSizes
</dt>
<dd>
<b>This is the optional object. </b>
No of columns for the first row.
This should mentioned with the properties as {lg: 3, md:2,sm:3,xs:2} like that.
</dd>
<dt>
mediaSizes
</dt>
<dd>
<b>Mandatory object</b>
No of columns for the bootstrap rows.
This should mentioned with the properties as {lg: 3, md:2,sm:3,xs:2} like that.
If we missed to mention lg, then md size will be taken.
If we missed to mention md, then sm size will be taken.
If nothing has been mentioned, then size will be 1.
</dd>
<dt>
firstSplitCustomClass
</dt>
<dd>
Custom class for the first row coulmns.
</dd>
<dt>
arraySplitCustomClass
</dt>
<dd>Custom class for the row columns</dd>
<dt>
splitterParentClass
</dt>
<dd>custom class for the row</dd>
</dd>
</dl>
<h3>
Events
</h3>
<hr/>
<dl >
<dt>
<h4>Events - This is the <b>object</b> shared from directive to controller.</h4>
</dt>
<dd>
<dl class="dl-horizontal">
<dt>
splitArray
</dt>
<dd>
Sometimes the directive will be initialized before we get the data from the server.
To split the array manually, call the following function from the controller.
<code>splitArray()</code>
</dd>
<dt>
checkMedia
</dt>
<dd>
To check the media (Bootstrap media.). The following bootstrap media has been used.
<div>
lg: "(min-width: 1200px)"<br/>
md: "(min-width: 992px)"<br/>
sm: "(min-width: 768px)"<br/>
</div>
</dd>
</dd>
</dl>
</script>
<script type="text/ng-template" id="_bootstrapRows.html">
<h3 class="well">
Bootstrap rows using ng repeat.
Rows columns will be collapsed.
</h3>
<br/>
<div class="row" >
<div ng-repeat="item in item1" class="col-sm-3">
<div class="panel panel-primary">
<div class="panel-heading">
{{item.name}}
</div>
<div class="panel-body">
{{item.description}}
</div>
</div>
</div>
<div>
</script>
<script type="text/ng-template" id="_splittedBootstrapRows.html">
<h3 class="well">
After splitting the array, Bootstrap rows using ng repeat.
Equal size of rows for the different hight of the columns
</h3>
<br/>
<div class="splitted-item-wrapper "
bootstrap-row-splitter
shared-values="sharedValues"
options="arraySplit.options"
template-url="{{arraySplit.templateUrl}}"
events="arraySplit.events">
</div>
</script>
<script type="text/ng-template" id="_template.html">
<div class="row mrg5B" ng-repeat="subItems in splitItems"
ng-init="$parentIndex = $index"
ng-class="splitterParentClass[$parentIndex]">
<div ng-repeat="item in subItems" ng-class="splitItemsClasses[$parentIndex][$index]">
<div class="panel" ng-class="sharedValues.$parentScope.getPanelClass($index)">
<div class="panel-heading">
{{item.name}}
</div>
<div class="panel-body">
{{item.description}}
</div>
</div>
</div>
</div>
</script>
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Angular Bootstrap Row Splitter</a>
</div>
<ul class="nav navbar-nav">
<li><a href="https://github.com/jeevasusej/bootstrapRowSplitter" target="_blank">Git hub</a> </li>
<li><a href="#/">Home</a></li>
<li><a href="#/BoostrapRows">Bootstrap Row</a></li>
<li><a href="#/SplittedBoostrapRows">Angular Splitter</a></li>
</ul>
</div>
</nav>
<div class="container" style="margin-top:30px;">
<div class="page-header" style="padding-top:9px;">
<h1>Angular Bootstrap Row Splitter </h1>
<p>
<div>
Sometimes we need show the items in bootstrap row columns.
</div>
<div>
While implementing this using ng repeat, the column will be generated. But if the column hight is different, then the item won't be fit in the row. There will be a collapse
</div>
<div>
This directive will help the user to split the array of items based on medias (lg,md,sm,xs). So the items will be strict to the rows.
</div>
</p>
</div>
<section>
<div ng-view>
<div>
</section>
</body>
</html>