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

Commit

Permalink
feat(release): release initial v2.0.0-beta.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mgcrea committed Jan 7, 2014
1 parent d885dea commit da5e7fd
Show file tree
Hide file tree
Showing 29 changed files with 3,300 additions and 0 deletions.
1,540 changes: 1,540 additions & 0 deletions dist/angular-strap.js

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions dist/angular-strap.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/angular-strap.min.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

143 changes: 143 additions & 0 deletions dist/modules/affix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
/**
* angular-strap
* @version v2.0.0-beta.1 - 2014-01-07
* @link http://mgcrea.github.io/angular-strap
* @author Olivier Louvignes <olivier@mg-crea.com>
* @license MIT License, http://www.opensource.org/licenses/MIT
*/
'use strict';
angular.module('mgcrea.ngStrap.affix', ['mgcrea.ngStrap.jqlite.dimensions']).provider('$affix', function () {
var defaults = this.defaults = { offsetTop: 'auto' };
this.$get = [
'$window',
'dimensions',
function ($window, dimensions) {
var windowEl = angular.element($window);
var bodyEl = angular.element($window.document.body);
function AffixFactory(element, config) {
var $affix = {};
var options = angular.extend({}, defaults, config);
var reset = 'affix affix-top affix-bottom', initialAffixTop = 0, initialOffsetTop = 0, affixed = null, unpin = null;
var parent = element.parent();
if (options.offsetParent) {
if (options.offsetParent.match(/^\d+$/)) {
for (var i = 0; i < options.offsetParent * 1 - 1; i++) {
parent = parent.parent();
}
} else {
parent = angular.element(options.offsetParent);
}
}
var offsetTop = 0;
if (options.offsetTop) {
if (options.offsetTop === 'auto') {
options.offsetTop = '+0';
}
if (options.offsetTop.match(/^[-+]\d+$/)) {
initialAffixTop -= options.offsetTop * 1;
if (options.offsetParent) {
offsetTop = dimensions.offset(parent[0]).top + options.offsetTop * 1;
} else {
offsetTop = dimensions.offset(element[0]).top - dimensions.css(element[0], 'marginTop', true) + options.offsetTop * 1;
}
} else {
offsetTop = options.offsetTop * 1;
}
}
var offsetBottom = 0;
if (options.offsetBottom) {
if (options.offsetParent && options.offsetBottom.match(/^[-+]\d+$/)) {
offsetBottom = $window.document.body.scrollHeight - (dimensions.offset(parent[0]).top + dimensions.height(parent[0])) + options.offsetBottom * 1 + 1;
} else {
offsetBottom = options.offsetBottom * 1;
}
}
$affix.init = function () {
initialOffsetTop = dimensions.offset(element[0]).top + initialAffixTop;
windowEl.on('scroll', this.checkPosition);
windowEl.on('click', this.checkPositionWithEventLoop);
this.checkPosition();
this.checkPositionWithEventLoop();
};
$affix.destroy = function () {
windowEl.off('scroll', this.checkPosition);
windowEl.off('click', this.checkPositionWithEventLoop);
};
$affix.checkPositionWithEventLoop = function () {
setTimeout(this.checkPosition, 1);
};
$affix.checkPosition = function () {
var scrollTop = $window.pageYOffset;
var position = dimensions.offset(element[0]);
var elementHeight = dimensions.height(element[0]);
var affix = getRequiredAffixClass(unpin, position, elementHeight);
if (affixed === affix)
return;
affixed = affix;
element.removeClass(reset).addClass('affix' + (affix !== 'middle' ? '-' + affix : ''));
if (affix === 'top') {
unpin = null;
element.css('position', options.offsetParent ? '' : 'relative');
element.css('top', '');
} else if (affix === 'bottom') {
if (options.offsetUnpin) {
unpin = -(options.offsetUnpin * 1);
} else {
unpin = position.top - scrollTop;
}
element.css('position', options.offsetParent ? '' : 'relative');
element.css('top', options.offsetParent ? '' : bodyEl[0].offsetHeight - offsetBottom - elementHeight - initialOffsetTop + 'px');
} else {
unpin = null;
element.css('position', 'fixed');
element.css('top', initialAffixTop + 'px');
}
};
function getRequiredAffixClass(unpin, position, elementHeight) {
var scrollTop = $window.pageYOffset;
var scrollHeight = $window.document.body.scrollHeight;
if (scrollTop <= offsetTop) {
return 'top';
} else if (unpin !== null && scrollTop + unpin <= position.top) {
return 'middle';
} else if (offsetBottom !== null && position.top + elementHeight + initialAffixTop >= scrollHeight - offsetBottom) {
return 'bottom';
} else {
return 'middle';
}
}
$affix.init();
return $affix;
}
return AffixFactory;
}
];
}).directive('bsAffix', [
'$affix',
'dimensions',
function ($affix, dimensions) {
return {
restrict: 'EAC',
link: function postLink(scope, element, attr) {
var options = {
scope: scope,
offsetTop: 'auto'
};
angular.forEach([
'offsetTop',
'offsetBottom',
'offsetParent',
'offsetUnpin'
], function (key) {
if (angular.isDefined(attr[key]))
options[key] = attr[key];
});
var affix = $affix(element, options);
scope.$on('$destroy', function () {
options = null;
affix = null;
});
}
};
}
]);
9 changes: 9 additions & 0 deletions dist/modules/affix.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

109 changes: 109 additions & 0 deletions dist/modules/alert.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/**
* angular-strap
* @version v2.0.0-beta.1 - 2014-01-07
* @link http://mgcrea.github.io/angular-strap
* @author Olivier Louvignes <olivier@mg-crea.com>
* @license MIT License, http://www.opensource.org/licenses/MIT
*/
'use strict';
angular.module('mgcrea.ngStrap.alert', []).run([
'$templateCache',
function ($templateCache) {
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>';
$templateCache.put('$alert', template);
}
]).provider('$alert', function () {
var defaults = this.defaults = {
animation: 'animation-fade',
prefixClass: 'alert',
placement: null,
template: '$alert',
container: false,
element: null,
backdrop: false,
keyboard: true,
show: true,
duration: false
};
this.$get = [
'$modal',
'$timeout',
function ($modal, $timeout) {
function AlertFactory(config) {
var $alert = {};
var options = angular.extend({}, defaults, config);
$alert = $modal(options);
if (!options.scope) {
angular.forEach(['type'], function (key) {
if (options[key])
$alert.scope[key] = options[key];
});
}
var show = $alert.show;
if (options.duration) {
$alert.show = function () {
show();
$timeout(function () {
$alert.hide();
}, options.duration * 1000);
};
}
return $alert;
}
return AlertFactory;
}
];
}).directive('bsAlert', [
'$window',
'$location',
'$sce',
'$alert',
function ($window, $location, $sce, $alert) {
var requestAnimationFrame = $window.requestAnimationFrame || $window.setTimeout;
return {
restrict: 'EAC',
scope: true,
link: function postLink(scope, element, attr, transclusion) {
var options = {
scope: scope,
element: element,
show: false
};
angular.forEach([
'template',
'placement',
'keyboard',
'container',
'animation',
'duration'
], function (key) {
if (angular.isDefined(attr[key]))
options[key] = attr[key];
});
angular.forEach([
'title',
'content',
'type'
], function (key) {
attr[key] && attr.$observe(key, function (newValue, oldValue) {
scope[key] = newValue;
});
});
attr.bsAlert && scope.$watch(attr.bsAlert, function (newValue, oldValue) {
if (angular.isObject(newValue)) {
angular.extend(scope, newValue);
} else {
scope.content = newValue;
}
}, true);
var alert = $alert(options);
element.on(attr.trigger || 'click', alert.toggle);
scope.$on('$destroy', function () {
alert.destroy();
options = null;
alert = null;
});
}
};
}
]);
9 changes: 9 additions & 0 deletions dist/modules/alert.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit da5e7fd

Please sign in to comment.