Skip to content

Commit cc9057c

Browse files
committed
update dist
1 parent 4c705ce commit cc9057c

File tree

2 files changed

+21
-23
lines changed

2 files changed

+21
-23
lines changed

dist/angular-bootstrap-toggle.js

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
(function () {
22
'use strict';
33

4-
angular.module('ui.toggle',[])
4+
angular.module('ui.toggle', [])
55

66
.value('$toggleSuppressError', false)
77

@@ -41,19 +41,7 @@
4141
* Default: ''
4242
* Description: Appends the value to the class attribute of the toggle. This can be used to apply custom styles. Refer to Custom Styles for reference.
4343
*/
44-
style: '',
45-
/**
46-
* Type: integer
47-
* Default: null
48-
* Description: Sets the width of the toggle. if set to null, width will be calculated.
49-
*/
50-
width: null,
51-
/**
52-
* Type: integer
53-
* Default: null
54-
* Description: Sets the height of the toggle. if set to null, height will be calculated.
55-
*/
56-
height: null
44+
style: ''
5745
})
5846

5947
.controller('ToggleController',
@@ -63,8 +51,10 @@
6351
ngModelCtrl = {$setViewValue: angular.noop};
6452

6553
// Configuration attributes
66-
angular.forEach(['on', 'off', 'size', 'onstyle', 'offstyle', 'style', 'width', 'height'], function (key, index) {
54+
angular.forEach(['on', 'off', 'size', 'onstyle', 'offstyle', 'style'], function (key, index) {
55+
//$log.info(key + ':' + $attrs[key]);
6756
self[key] = angular.isDefined($attrs[key]) ? (index < 6 ? $interpolate($attrs[key])($scope.$parent) : $scope.$parent.$eval($attrs[key])) : toggleConfig[key];
57+
//$log.info(key + ':' + self[key]);
6858
});
6959

7060
this.init = function (ngModelCtrl_) {
@@ -81,16 +71,24 @@
8171
var labels = self.element.find('label');
8272
angular.element(labels[0]).html(self.on);
8373
angular.element(labels[1]).html(self.off);
84-
8574
var spans = self.element.find('span');
75+
var wrapperComputedWidth = self.width || Math.max(labels[0].offsetWidth, labels[1].offsetWidth) + (spans[0].offsetWidth / 2);
76+
var wrapperComputedHeight = self.height || Math.max(labels[0].offsetHeight, labels[1].offsetHeight);
8677

87-
var width = self.width || Math.max(labels[0].offsetWidth, labels[1].offsetWidth) + (spans[0].offsetWidth / 2);
88-
var height = self.height || Math.max(labels[0].offsetHeight, labels[1].offsetHeight);
78+
var divs = self.element.find('div');
79+
var wrapperWidth = divs[0].offsetWidth;
80+
var wrapperHeight = divs[1].offsetHeight;
8981

90-
$scope.wrapperStyle = {width: width, height: height};
82+
$scope.wrapperStyle = {};
83+
if (wrapperWidth < wrapperComputedWidth) {
84+
$scope.wrapperStyle.width = wrapperComputedWidth + 'px';
85+
}
9186

92-
$scope.onClass = [self.size, 'toggle-on'];
93-
$scope.offClass = [self.size, 'toggle-off'];
87+
if (wrapperHeight < wrapperComputedHeight && self.size != 'btn-xs' && self.size != 'btn-sm') {
88+
$scope.wrapperStyle.height = wrapperComputedHeight + 'px';
89+
}
90+
$scope.onClass = [self.onstyle, self.size, 'toggle-on'];
91+
$scope.offClass = [self.offstyle, self.size, 'toggle-off'];
9492
$scope.handleClass = [self.size, 'toggle-handle'];
9593
};
9694

@@ -127,7 +125,7 @@
127125
return {
128126
restrict: 'E',
129127
transclude: true,
130-
template: '<div class="toggle btn" ng-class="wrapperClass" ng-style="::wrapperStyle" ng-click="onSwitch()"><div class="toggle-group"><label class="btn btn-primary" ng-class="::onClass"></label><label class="btn btn-default active" ng-class="::offClass"></label><span class="btn btn-default" ng-class="::handleClass"></span></div></div>',
128+
template: '<div class="toggle btn" ng-class="wrapperClass" ng-style="::wrapperStyle" ng-click="onSwitch()"><div class="toggle-group"><label class="btn" ng-class="::onClass"></label><label class="btn active" ng-class="::offClass"></label><span class="btn btn-default" ng-class="::handleClass"></span></div></div>',
131129
scope: {
132130
bindModel: '=ngModel'
133131
},

dist/angular-bootstrap-toggle.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)