Skip to content
This repository was archived by the owner on Dec 1, 2023. It is now read-only.

Commit da5e7fd

Browse files
committed
feat(release): release initial v2.0.0-beta.1
1 parent d885dea commit da5e7fd

29 files changed

+3300
-0
lines changed

dist/angular-strap.js

+1,540
Large diffs are not rendered by default.

dist/angular-strap.min.js

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/angular-strap.min.map

+1
Original file line numberDiff line numberDiff line change

dist/modules/affix.js

+143
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
/**
2+
* angular-strap
3+
* @version v2.0.0-beta.1 - 2014-01-07
4+
* @link http://mgcrea.github.io/angular-strap
5+
* @author Olivier Louvignes <olivier@mg-crea.com>
6+
* @license MIT License, http://www.opensource.org/licenses/MIT
7+
*/
8+
'use strict';
9+
angular.module('mgcrea.ngStrap.affix', ['mgcrea.ngStrap.jqlite.dimensions']).provider('$affix', function () {
10+
var defaults = this.defaults = { offsetTop: 'auto' };
11+
this.$get = [
12+
'$window',
13+
'dimensions',
14+
function ($window, dimensions) {
15+
var windowEl = angular.element($window);
16+
var bodyEl = angular.element($window.document.body);
17+
function AffixFactory(element, config) {
18+
var $affix = {};
19+
var options = angular.extend({}, defaults, config);
20+
var reset = 'affix affix-top affix-bottom', initialAffixTop = 0, initialOffsetTop = 0, affixed = null, unpin = null;
21+
var parent = element.parent();
22+
if (options.offsetParent) {
23+
if (options.offsetParent.match(/^\d+$/)) {
24+
for (var i = 0; i < options.offsetParent * 1 - 1; i++) {
25+
parent = parent.parent();
26+
}
27+
} else {
28+
parent = angular.element(options.offsetParent);
29+
}
30+
}
31+
var offsetTop = 0;
32+
if (options.offsetTop) {
33+
if (options.offsetTop === 'auto') {
34+
options.offsetTop = '+0';
35+
}
36+
if (options.offsetTop.match(/^[-+]\d+$/)) {
37+
initialAffixTop -= options.offsetTop * 1;
38+
if (options.offsetParent) {
39+
offsetTop = dimensions.offset(parent[0]).top + options.offsetTop * 1;
40+
} else {
41+
offsetTop = dimensions.offset(element[0]).top - dimensions.css(element[0], 'marginTop', true) + options.offsetTop * 1;
42+
}
43+
} else {
44+
offsetTop = options.offsetTop * 1;
45+
}
46+
}
47+
var offsetBottom = 0;
48+
if (options.offsetBottom) {
49+
if (options.offsetParent && options.offsetBottom.match(/^[-+]\d+$/)) {
50+
offsetBottom = $window.document.body.scrollHeight - (dimensions.offset(parent[0]).top + dimensions.height(parent[0])) + options.offsetBottom * 1 + 1;
51+
} else {
52+
offsetBottom = options.offsetBottom * 1;
53+
}
54+
}
55+
$affix.init = function () {
56+
initialOffsetTop = dimensions.offset(element[0]).top + initialAffixTop;
57+
windowEl.on('scroll', this.checkPosition);
58+
windowEl.on('click', this.checkPositionWithEventLoop);
59+
this.checkPosition();
60+
this.checkPositionWithEventLoop();
61+
};
62+
$affix.destroy = function () {
63+
windowEl.off('scroll', this.checkPosition);
64+
windowEl.off('click', this.checkPositionWithEventLoop);
65+
};
66+
$affix.checkPositionWithEventLoop = function () {
67+
setTimeout(this.checkPosition, 1);
68+
};
69+
$affix.checkPosition = function () {
70+
var scrollTop = $window.pageYOffset;
71+
var position = dimensions.offset(element[0]);
72+
var elementHeight = dimensions.height(element[0]);
73+
var affix = getRequiredAffixClass(unpin, position, elementHeight);
74+
if (affixed === affix)
75+
return;
76+
affixed = affix;
77+
element.removeClass(reset).addClass('affix' + (affix !== 'middle' ? '-' + affix : ''));
78+
if (affix === 'top') {
79+
unpin = null;
80+
element.css('position', options.offsetParent ? '' : 'relative');
81+
element.css('top', '');
82+
} else if (affix === 'bottom') {
83+
if (options.offsetUnpin) {
84+
unpin = -(options.offsetUnpin * 1);
85+
} else {
86+
unpin = position.top - scrollTop;
87+
}
88+
element.css('position', options.offsetParent ? '' : 'relative');
89+
element.css('top', options.offsetParent ? '' : bodyEl[0].offsetHeight - offsetBottom - elementHeight - initialOffsetTop + 'px');
90+
} else {
91+
unpin = null;
92+
element.css('position', 'fixed');
93+
element.css('top', initialAffixTop + 'px');
94+
}
95+
};
96+
function getRequiredAffixClass(unpin, position, elementHeight) {
97+
var scrollTop = $window.pageYOffset;
98+
var scrollHeight = $window.document.body.scrollHeight;
99+
if (scrollTop <= offsetTop) {
100+
return 'top';
101+
} else if (unpin !== null && scrollTop + unpin <= position.top) {
102+
return 'middle';
103+
} else if (offsetBottom !== null && position.top + elementHeight + initialAffixTop >= scrollHeight - offsetBottom) {
104+
return 'bottom';
105+
} else {
106+
return 'middle';
107+
}
108+
}
109+
$affix.init();
110+
return $affix;
111+
}
112+
return AffixFactory;
113+
}
114+
];
115+
}).directive('bsAffix', [
116+
'$affix',
117+
'dimensions',
118+
function ($affix, dimensions) {
119+
return {
120+
restrict: 'EAC',
121+
link: function postLink(scope, element, attr) {
122+
var options = {
123+
scope: scope,
124+
offsetTop: 'auto'
125+
};
126+
angular.forEach([
127+
'offsetTop',
128+
'offsetBottom',
129+
'offsetParent',
130+
'offsetUnpin'
131+
], function (key) {
132+
if (angular.isDefined(attr[key]))
133+
options[key] = attr[key];
134+
});
135+
var affix = $affix(element, options);
136+
scope.$on('$destroy', function () {
137+
options = null;
138+
affix = null;
139+
});
140+
}
141+
};
142+
}
143+
]);

dist/modules/affix.min.js

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/modules/alert.js

+109
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
/**
2+
* angular-strap
3+
* @version v2.0.0-beta.1 - 2014-01-07
4+
* @link http://mgcrea.github.io/angular-strap
5+
* @author Olivier Louvignes <olivier@mg-crea.com>
6+
* @license MIT License, http://www.opensource.org/licenses/MIT
7+
*/
8+
'use strict';
9+
angular.module('mgcrea.ngStrap.alert', []).run([
10+
'$templateCache',
11+
function ($templateCache) {
12+
var template = '' + '<div class="alert" tabindex="-1" ng-class="[type ? \'alert-\' + type : null]">' + '<button type="button" class="close" ng-click="$hide()">&times;</button>' + '<strong ng-bind="title"></strong>&nbsp;<span ng-bind-html="content"></span>' + '</div>';
13+
$templateCache.put('$alert', template);
14+
}
15+
]).provider('$alert', function () {
16+
var defaults = this.defaults = {
17+
animation: 'animation-fade',
18+
prefixClass: 'alert',
19+
placement: null,
20+
template: '$alert',
21+
container: false,
22+
element: null,
23+
backdrop: false,
24+
keyboard: true,
25+
show: true,
26+
duration: false
27+
};
28+
this.$get = [
29+
'$modal',
30+
'$timeout',
31+
function ($modal, $timeout) {
32+
function AlertFactory(config) {
33+
var $alert = {};
34+
var options = angular.extend({}, defaults, config);
35+
$alert = $modal(options);
36+
if (!options.scope) {
37+
angular.forEach(['type'], function (key) {
38+
if (options[key])
39+
$alert.scope[key] = options[key];
40+
});
41+
}
42+
var show = $alert.show;
43+
if (options.duration) {
44+
$alert.show = function () {
45+
show();
46+
$timeout(function () {
47+
$alert.hide();
48+
}, options.duration * 1000);
49+
};
50+
}
51+
return $alert;
52+
}
53+
return AlertFactory;
54+
}
55+
];
56+
}).directive('bsAlert', [
57+
'$window',
58+
'$location',
59+
'$sce',
60+
'$alert',
61+
function ($window, $location, $sce, $alert) {
62+
var requestAnimationFrame = $window.requestAnimationFrame || $window.setTimeout;
63+
return {
64+
restrict: 'EAC',
65+
scope: true,
66+
link: function postLink(scope, element, attr, transclusion) {
67+
var options = {
68+
scope: scope,
69+
element: element,
70+
show: false
71+
};
72+
angular.forEach([
73+
'template',
74+
'placement',
75+
'keyboard',
76+
'container',
77+
'animation',
78+
'duration'
79+
], function (key) {
80+
if (angular.isDefined(attr[key]))
81+
options[key] = attr[key];
82+
});
83+
angular.forEach([
84+
'title',
85+
'content',
86+
'type'
87+
], function (key) {
88+
attr[key] && attr.$observe(key, function (newValue, oldValue) {
89+
scope[key] = newValue;
90+
});
91+
});
92+
attr.bsAlert && scope.$watch(attr.bsAlert, function (newValue, oldValue) {
93+
if (angular.isObject(newValue)) {
94+
angular.extend(scope, newValue);
95+
} else {
96+
scope.content = newValue;
97+
}
98+
}, true);
99+
var alert = $alert(options);
100+
element.on(attr.trigger || 'click', alert.toggle);
101+
scope.$on('$destroy', function () {
102+
alert.destroy();
103+
options = null;
104+
alert = null;
105+
});
106+
}
107+
};
108+
}
109+
]);

dist/modules/alert.min.js

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)