Skip to content

Commit 1c39750

Browse files
author
Sebastian Hammerl
committed
Added information and tests for bootstrap-like styles
1 parent fda86b1 commit 1c39750

File tree

6 files changed

+105
-7
lines changed

6 files changed

+105
-7
lines changed

README.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,26 @@ Add "ui.checkbox" to your modules list. Then you can use it like AngularJS input
3838
Additionally you can set the size:
3939

4040
```
41-
<checkbox ...></checkbox> (Normal size, corresponds to 'btn-xs')
42-
<checkbox large ...></checkbox> (Large, corresponds to 'btn-sm')
43-
<checkbox larger ...></checkbox> (Larger, corresponds to Button default size)
44-
<checkbox largest ...></checkbox> (Largest, corresponds to 'btn-lg')
41+
<checkbox ...></checkbox> (Normal size, corresponds to 'btn-xs')
42+
<checkbox large ...></checkbox> (Large, corresponds to 'btn-sm')
43+
<checkbox larger ...></checkbox> (Larger, corresponds to Button default size)
44+
<checkbox largest ...></checkbox> (Largest, corresponds to 'btn-lg')
4545
```
4646

4747
![Screenshot](/sizes.png?raw=true "Screenshot Sizes")
4848

49+
And also style the checkboxes Bootstrap like:
50+
51+
```
52+
<checkbox class="btn-primary"></checkbox> (Looks like primary button)
53+
<checkbox class="btn-success"></checkbox> (Looks like success button)
54+
<checkbox class="btn-info"></checkbox> (Looks like info button)
55+
<checkbox class="btn-warning"></checkbox> (Looks like warning button)
56+
<checkbox class="btn-danger"></checkbox> (Looks like danger button)
57+
```
58+
59+
![Screenshot](/styles.png?raw=true "Screenshot Styles")
60+
4961
See index.html for examples and how it works.
5062

5163
### Testing:

app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
angular.module("angular-bootstrap-checkbox-test", ["ui.checkbox"]).controller("index", function($scope) {
44
$scope.checkboxModel = [
5-
false, false, false,false, false, false, false, false, true
5+
false, false, false,false, false, false, false, false, true, false, true
66
];
77

88
$scope.changes = 0;

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-bootstrap-checkbox",
3-
"version": "0.2.1",
3+
"version": "0.3.0",
44
"authors": [
55
"Sebastian Hammerl, Getslash GmbH"
66
],

index.html

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,14 +276,81 @@
276276
</td>
277277
</tr>
278278

279+
<tr>
280+
<td>
281+
Different Styles (normal, primary, success, info, warning, danger)
282+
</td>
283+
<td></td>
284+
<td>
285+
default:<br><br><br>
286+
287+
primary:<br><br><br>
288+
289+
success:<br><br><br>
290+
291+
info:<br><br><br>
292+
293+
warning:<br><br><br>
294+
295+
danger:
296+
</td>
297+
<td>
298+
<checkbox id="checkbox9a" ng-model="checkboxModel[9]"></checkbox>
299+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
300+
<checkbox id="checkbox10a" ng-model="checkboxModel[10]"></checkbox><br><br><br>
301+
302+
<checkbox id="checkbox9b" class="btn-primary" ng-model="checkboxModel[9]"></checkbox>
303+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
304+
<checkbox id="checkbox10b" class="btn-primary" ng-model="checkboxModel[10]"></checkbox><br><br><br>
305+
306+
<checkbox id="checkbox9c" class="btn-success" ng-model="checkboxModel[9]"></checkbox>
307+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
308+
<checkbox id="checkbox10c" class="btn-success" ng-model="checkboxModel[10]"></checkbox><br><br><br>
309+
310+
<checkbox id="checkbox9d" class="btn-info" ng-model="checkboxModel[9]"></checkbox>
311+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
312+
<checkbox id="checkbox10d" class="btn-info" ng-model="checkboxModel[10]"></checkbox><br><br><br>
313+
314+
<checkbox id="checkbox9e" class="btn-warning" ng-model="checkboxModel[9]"></checkbox>
315+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
316+
<checkbox id="checkbox10e" class="btn-warning" ng-model="checkboxModel[10]"></checkbox><br><br><br>
317+
318+
<checkbox id="checkbox9f" class="btn-danger" ng-model="checkboxModel[9]"></checkbox>
319+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
320+
<checkbox id="checkbox10f" class="btn-danger" ng-model="checkboxModel[10]"></checkbox>
321+
</td>
322+
323+
<td style="width:300px;">
324+
325+
<pre>&lt;checkbox
326+
ng-model="checkboxModel[9]"
327+
&gt;&lt;/checkbox&gt
328+
&lt;checkbox class="btn-primary"
329+
ng-model="checkboxModel[9]"
330+
&gt;&lt;/checkbox&gt
331+
&lt;checkbox class="btn-success"
332+
ng-model="checkboxModel[9]"
333+
&gt;&lt;/checkbox&gt
334+
&lt;checkbox class="btn-info"
335+
ng-model="checkboxModel[9]"
336+
&gt;&lt;/checkbox&gt
337+
&lt;checkbox class="btn-warning"
338+
ng-model="checkboxModel[9]"
339+
&gt;&lt;/checkbox&gt
340+
&lt;checkbox class="btn-danger"
341+
ng-model="checkboxModel[9]"
342+
&gt;&lt;/checkbox&gt</pre>
343+
</td>
344+
</tr>
345+
279346
<tr>
280347
<td colspan="5">
281348
<b>app.js:</b>
282349
<pre>
283350
angular.module("angular-bootstrap-checkbox-test", ["ui.checkbox"])
284351
.controller("index", function($scope) {
285352
$scope.checkboxModel = [
286-
false, false, false,false, false, false, false, false, true
353+
false, false, false,false, false, false, false, false, true, false, true
287354
];
288355

289356
$scope.changes = 0;

styles.png

8.83 KB
Loading

test.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,4 +331,23 @@ describe("Checkbutton Tests", function() {
331331
expect(element("#checkbox8c").css("height")).toBe("34px");
332332
expect(element("#checkbox8d").css("height")).toBe("45px");
333333
});
334+
335+
it("Example Different Styles", function() {
336+
browser().navigateTo("index.html");
337+
338+
// Check if the checkbox has been replaced with template
339+
expect(element("#checkbox9a").attr("class")).toBe("btn btn-default ng-isolate-scope ng-valid btn-xs ng-dirty");
340+
expect(element("#checkbox9b").attr("class")).toBe("btn-primary btn btn-default ng-isolate-scope ng-valid btn-xs ng-dirty");
341+
expect(element("#checkbox9c").attr("class")).toBe("btn-success btn btn-default ng-isolate-scope ng-valid btn-xs ng-dirty");
342+
expect(element("#checkbox9d").attr("class")).toBe("btn-info btn btn-default ng-isolate-scope ng-valid btn-xs ng-dirty");
343+
expect(element("#checkbox9e").attr("class")).toBe("btn-warning btn btn-default ng-isolate-scope ng-valid btn-xs ng-dirty");
344+
expect(element("#checkbox9f").attr("class")).toBe("btn-danger btn btn-default ng-isolate-scope ng-valid btn-xs ng-dirty");
345+
346+
expect(element("#checkbox9a").css("background-color")).toBe("rgb(255, 255, 255)");
347+
expect(element("#checkbox9b").css("background-color")).toBe("rgb(66, 139, 202)");
348+
expect(element("#checkbox9c").css("background-color")).toBe("rgb(92, 184, 92)");
349+
expect(element("#checkbox9d").css("background-color")).toBe("rgb(91, 192, 222)");
350+
expect(element("#checkbox9e").css("background-color")).toBe("rgb(240, 173, 78)");
351+
expect(element("#checkbox9f").css("background-color")).toBe("rgb(217, 83, 79)");
352+
});
334353
});

0 commit comments

Comments
 (0)