angular-strap-rails 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.DS_Store +0 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +45 -0
- data/Rakefile +1 -0
- data/angular-strap-rails.gemspec +15 -0
- data/lib/angular-strap-rails.rb +8 -0
- data/lib/angular-strap-rails/version.rb +5 -0
- data/vendor/.DS_Store +0 -0
- data/vendor/assets/.DS_Store +0 -0
- data/vendor/assets/javascripts/.DS_Store +0 -0
- data/vendor/assets/javascripts/angular-strap.coffee +0 -0
- data/vendor/assets/javascripts/angular-strap/.DS_Store +0 -0
- data/vendor/assets/javascripts/angular-strap/datepicker.coffee +11 -0
- data/vendor/assets/javascripts/angular-strap/modal.coffee +9 -0
- data/vendor/assets/javascripts/dist/angular-strap.js +3682 -0
- data/vendor/assets/javascripts/dist/angular-strap.tpl.js +100 -0
- data/vendor/assets/javascripts/dist/modules/affix.js +191 -0
- data/vendor/assets/javascripts/dist/modules/alert.js +114 -0
- data/vendor/assets/javascripts/dist/modules/alert.tpl.js +14 -0
- data/vendor/assets/javascripts/dist/modules/aside.js +96 -0
- data/vendor/assets/javascripts/dist/modules/aside.tpl.js +14 -0
- data/vendor/assets/javascripts/dist/modules/button.js +141 -0
- data/vendor/assets/javascripts/dist/modules/date-parser.js +150 -0
- data/vendor/assets/javascripts/dist/modules/datepicker.js +583 -0
- data/vendor/assets/javascripts/dist/modules/datepicker.tpl.js +14 -0
- data/vendor/assets/javascripts/dist/modules/debounce.js +60 -0
- data/vendor/assets/javascripts/dist/modules/dimensions.js +142 -0
- data/vendor/assets/javascripts/dist/modules/dropdown.js +124 -0
- data/vendor/assets/javascripts/dist/modules/dropdown.tpl.js +14 -0
- data/vendor/assets/javascripts/dist/modules/modal.js +282 -0
- data/vendor/assets/javascripts/dist/modules/modal.tpl.js +14 -0
- data/vendor/assets/javascripts/dist/modules/navbar.js +55 -0
- data/vendor/assets/javascripts/dist/modules/parse-options.js +51 -0
- data/vendor/assets/javascripts/dist/modules/popover.js +100 -0
- data/vendor/assets/javascripts/dist/modules/popover.tpl.js +14 -0
- data/vendor/assets/javascripts/dist/modules/raf.js +45 -0
- data/vendor/assets/javascripts/dist/modules/scrollspy.js +229 -0
- data/vendor/assets/javascripts/dist/modules/select.js +281 -0
- data/vendor/assets/javascripts/dist/modules/select.tpl.js +14 -0
- data/vendor/assets/javascripts/dist/modules/tab.js +69 -0
- data/vendor/assets/javascripts/dist/modules/tab.tpl.js +14 -0
- data/vendor/assets/javascripts/dist/modules/timepicker.js +430 -0
- data/vendor/assets/javascripts/dist/modules/timepicker.tpl.js +14 -0
- data/vendor/assets/javascripts/dist/modules/tooltip.js +405 -0
- data/vendor/assets/javascripts/dist/modules/tooltip.tpl.js +14 -0
- data/vendor/assets/javascripts/dist/modules/typeahead.js +225 -0
- data/vendor/assets/javascripts/dist/modules/typeahead.tpl.js +14 -0
- data/vendor/assets/stylesheets/angular-strap.css +564 -0
- metadata +94 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* angular-strap
|
|
3
|
+
* @version v2.0.1 - 2014-04-10
|
|
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
|
+
(function(window, document, undefined) {
|
|
9
|
+
'use strict';
|
|
10
|
+
|
|
11
|
+
// Source: alert.tpl.js
|
|
12
|
+
angular.module('mgcrea.ngStrap.alert').run([
|
|
13
|
+
'$templateCache',
|
|
14
|
+
function ($templateCache) {
|
|
15
|
+
$templateCache.put('alert/alert.tpl.html', '<div class="alert alert-dismissable" tabindex="-1" ng-class="[type ? \'alert-\' + type : null]"><button type="button" class="close" ng-click="$hide()">×</button> <strong ng-bind="title"></strong> <span ng-bind-html="content"></span></div>');
|
|
16
|
+
}
|
|
17
|
+
]);
|
|
18
|
+
|
|
19
|
+
// Source: aside.tpl.js
|
|
20
|
+
angular.module('mgcrea.ngStrap.aside').run([
|
|
21
|
+
'$templateCache',
|
|
22
|
+
function ($templateCache) {
|
|
23
|
+
$templateCache.put('aside/aside.tpl.html', '<div class="aside" tabindex="-1" role="dialog"><div class="aside-dialog"><div class="aside-content"><div class="aside-header" ng-show="title"><button type="button" class="close" ng-click="$hide()">×</button><h4 class="aside-title" ng-bind="title"></h4></div><div class="aside-body" ng-bind="content"></div><div class="aside-footer"><button type="button" class="btn btn-default" ng-click="$hide()">Close</button></div></div></div></div>');
|
|
24
|
+
}
|
|
25
|
+
]);
|
|
26
|
+
|
|
27
|
+
// Source: datepicker.tpl.js
|
|
28
|
+
angular.module('mgcrea.ngStrap.datepicker').run([
|
|
29
|
+
'$templateCache',
|
|
30
|
+
function ($templateCache) {
|
|
31
|
+
$templateCache.put('datepicker/datepicker.tpl.html', '<div class="dropdown-menu datepicker" ng-class="\'datepicker-mode-\' + $mode" style="max-width: 320px"><table style="table-layout: fixed; height: 100%; width: 100%"><thead><tr class="text-center"><th><button tabindex="-1" type="button" class="btn btn-default pull-left" ng-click="$selectPane(-1)"><i class="glyphicon glyphicon-chevron-left"></i></button></th><th colspan="{{ rows[0].length - 2 }}"><button tabindex="-1" type="button" class="btn btn-default btn-block text-strong" ng-click="$toggleMode()"><strong style="text-transform: capitalize" ng-bind="title"></strong></button></th><th><button tabindex="-1" type="button" class="btn btn-default pull-right" ng-click="$selectPane(+1)"><i class="glyphicon glyphicon-chevron-right"></i></button></th></tr><tr ng-show="labels" ng-bind-html="labels"></tr></thead><tbody><tr ng-repeat="(i, row) in rows" height="{{ 100 / rows.length }}%"><td class="text-center" ng-repeat="(j, el) in row"><button tabindex="-1" type="button" class="btn btn-default" style="width: 100%" ng-class="{\'btn-primary\': el.selected}" ng-click="$select(el.date)" ng-disabled="el.disabled"><span ng-class="{\'text-muted\': el.muted}" ng-bind="el.label"></span></button></td></tr></tbody></table></div>');
|
|
32
|
+
}
|
|
33
|
+
]);
|
|
34
|
+
|
|
35
|
+
// Source: dropdown.tpl.js
|
|
36
|
+
angular.module('mgcrea.ngStrap.dropdown').run([
|
|
37
|
+
'$templateCache',
|
|
38
|
+
function ($templateCache) {
|
|
39
|
+
$templateCache.put('dropdown/dropdown.tpl.html', '<ul tabindex="-1" class="dropdown-menu" role="menu"><li role="presentation" ng-class="{divider: item.divider}" ng-repeat="item in content"><a role="menuitem" tabindex="-1" ng-href="{{item.href}}" ng-if="!item.divider && item.href" ng-bind="item.text"></a> <a role="menuitem" tabindex="-1" href="javascript:void(0)" ng-if="!item.divider && item.click" ng-click="$eval(item.click);$hide()" ng-bind="item.text"></a></li></ul>');
|
|
40
|
+
}
|
|
41
|
+
]);
|
|
42
|
+
|
|
43
|
+
// Source: modal.tpl.js
|
|
44
|
+
angular.module('mgcrea.ngStrap.modal').run([
|
|
45
|
+
'$templateCache',
|
|
46
|
+
function ($templateCache) {
|
|
47
|
+
$templateCache.put('modal/modal.tpl.html', '<div class="modal" tabindex="-1" role="dialog"><div class="modal-dialog"><div class="modal-content"><div class="modal-header" ng-show="title"><button type="button" class="close" ng-click="$hide()">×</button><h4 class="modal-title" ng-bind="title"></h4></div><div class="modal-body" ng-bind="content"></div><div class="modal-footer"><button type="button" class="btn btn-default" ng-click="$hide()">Close</button></div></div></div></div>');
|
|
48
|
+
}
|
|
49
|
+
]);
|
|
50
|
+
|
|
51
|
+
// Source: popover.tpl.js
|
|
52
|
+
angular.module('mgcrea.ngStrap.popover').run([
|
|
53
|
+
'$templateCache',
|
|
54
|
+
function ($templateCache) {
|
|
55
|
+
$templateCache.put('popover/popover.tpl.html', '<div class="popover"><div class="arrow"></div><h3 class="popover-title" ng-bind="title" ng-show="title"></h3><div class="popover-content" ng-bind="content"></div></div>');
|
|
56
|
+
}
|
|
57
|
+
]);
|
|
58
|
+
|
|
59
|
+
// Source: select.tpl.js
|
|
60
|
+
angular.module('mgcrea.ngStrap.select').run([
|
|
61
|
+
'$templateCache',
|
|
62
|
+
function ($templateCache) {
|
|
63
|
+
$templateCache.put('select/select.tpl.html', '<ul tabindex="-1" class="select dropdown-menu" ng-show="$isVisible()" role="select"><li role="presentation" ng-repeat="match in $matches" ng-class="{active: $isActive($index)}"><a style="cursor: default" role="menuitem" tabindex="-1" ng-click="$select($index, $event)"><span ng-bind="match.label"></span> <i class="glyphicon glyphicon-ok pull-right" ng-if="$isMultiple && $isActive($index)"></i></a></li></ul>');
|
|
64
|
+
}
|
|
65
|
+
]);
|
|
66
|
+
|
|
67
|
+
// Source: tab.tpl.js
|
|
68
|
+
angular.module('mgcrea.ngStrap.tab').run([
|
|
69
|
+
'$templateCache',
|
|
70
|
+
function ($templateCache) {
|
|
71
|
+
$templateCache.put('tab/tab.tpl.html', '<ul class="nav nav-tabs"><li ng-repeat="pane in panes" ng-class="{active: $index == active}"><a data-toggle="tab" ng-click="setActive($index, $event)" data-index="{{$index}}">{{pane.title}}</a></li></ul><div class="tab-content"><div ng-repeat="pane in panes" class="tab-pane" ng-class="[$index == active ? \'active\' : \'\']" ng-include="pane.template || \'$pane\'"></div></div>');
|
|
72
|
+
}
|
|
73
|
+
]);
|
|
74
|
+
|
|
75
|
+
// Source: timepicker.tpl.js
|
|
76
|
+
angular.module('mgcrea.ngStrap.timepicker').run([
|
|
77
|
+
'$templateCache',
|
|
78
|
+
function ($templateCache) {
|
|
79
|
+
$templateCache.put('timepicker/timepicker.tpl.html', '<div class="dropdown-menu timepicker" style="min-width: 0px;width: auto"><table height="100%"><thead><tr class="text-center"><th><button tabindex="-1" type="button" class="btn btn-default pull-left" ng-click="$moveIndex(-1, 0)"><i class="glyphicon glyphicon-chevron-up"></i></button></th><th> </th><th><button tabindex="-1" type="button" class="btn btn-default pull-left" ng-click="$moveIndex(-1, 1)"><i class="glyphicon glyphicon-chevron-up"></i></button></th></tr></thead><tbody><tr ng-repeat="(i, row) in rows"><td class="text-center"><button tabindex="-1" style="width: 100%" type="button" class="btn btn-default" ng-class="{\'btn-primary\': row[0].selected}" ng-click="$select(row[0].date, 0)" ng-disabled="row[0].disabled"><span ng-class="{\'text-muted\': row[0].muted}" ng-bind="row[0].label"></span></button></td><td><span ng-bind="i == midIndex ? \':\' : \' \'"></span></td><td class="text-center"><button tabindex="-1" ng-if="row[1].date" style="width: 100%" type="button" class="btn btn-default" ng-class="{\'btn-primary\': row[1].selected}" ng-click="$select(row[1].date, 1)" ng-disabled="row[1].disabled"><span ng-class="{\'text-muted\': row[1].muted}" ng-bind="row[1].label"></span></button></td><td ng-if="showAM"> </td><td ng-if="showAM"><button tabindex="-1" ng-show="i == midIndex - !isAM * 1" style="width: 100%" type="button" ng-class="{\'btn-primary\': !!isAM}" class="btn btn-default" ng-click="$switchMeridian()" ng-disabled="el.disabled">AM</button> <button tabindex="-1" ng-show="i == midIndex + 1 - !isAM * 1" style="width: 100%" type="button" ng-class="{\'btn-primary\': !isAM}" class="btn btn-default" ng-click="$switchMeridian()" ng-disabled="el.disabled">PM</button></td></tr></tbody><tfoot><tr class="text-center"><th><button tabindex="-1" type="button" class="btn btn-default pull-left" ng-click="$moveIndex(1, 0)"><i class="glyphicon glyphicon-chevron-down"></i></button></th><th> </th><th><button tabindex="-1" type="button" class="btn btn-default pull-left" ng-click="$moveIndex(1, 1)"><i class="glyphicon glyphicon-chevron-down"></i></button></th></tr></tfoot></table></div>');
|
|
80
|
+
}
|
|
81
|
+
]);
|
|
82
|
+
|
|
83
|
+
// Source: tooltip.tpl.js
|
|
84
|
+
angular.module('mgcrea.ngStrap.tooltip').run([
|
|
85
|
+
'$templateCache',
|
|
86
|
+
function ($templateCache) {
|
|
87
|
+
$templateCache.put('tooltip/tooltip.tpl.html', '<div class="tooltip in" ng-show="title"><div class="tooltip-arrow"></div><div class="tooltip-inner" ng-bind="title"></div></div>');
|
|
88
|
+
}
|
|
89
|
+
]);
|
|
90
|
+
|
|
91
|
+
// Source: typeahead.tpl.js
|
|
92
|
+
angular.module('mgcrea.ngStrap.typeahead').run([
|
|
93
|
+
'$templateCache',
|
|
94
|
+
function ($templateCache) {
|
|
95
|
+
$templateCache.put('typeahead/typeahead.tpl.html', '<ul tabindex="-1" class="typeahead dropdown-menu" ng-show="$isVisible()" role="select"><li role="presentation" ng-repeat="match in $matches" ng-class="{active: $index == $activeIndex}"><a role="menuitem" tabindex="-1" ng-click="$select($index, $event)" ng-bind="match.label"></a></li></ul>');
|
|
96
|
+
}
|
|
97
|
+
]);
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
})(window, document);
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* angular-strap
|
|
3
|
+
* @version v2.0.1 - 2014-04-10
|
|
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', [
|
|
10
|
+
'mgcrea.ngStrap.helpers.dimensions',
|
|
11
|
+
'mgcrea.ngStrap.helpers.debounce'
|
|
12
|
+
]).provider('$affix', function () {
|
|
13
|
+
var defaults = this.defaults = { offsetTop: 'auto' };
|
|
14
|
+
this.$get = [
|
|
15
|
+
'$window',
|
|
16
|
+
'debounce',
|
|
17
|
+
'dimensions',
|
|
18
|
+
function ($window, debounce, dimensions) {
|
|
19
|
+
var bodyEl = angular.element($window.document.body);
|
|
20
|
+
var windowEl = angular.element($window);
|
|
21
|
+
function AffixFactory(element, config) {
|
|
22
|
+
var $affix = {};
|
|
23
|
+
// Common vars
|
|
24
|
+
var options = angular.extend({}, defaults, config);
|
|
25
|
+
var targetEl = options.target;
|
|
26
|
+
// Initial private vars
|
|
27
|
+
var reset = 'affix affix-top affix-bottom', initialAffixTop = 0, initialOffsetTop = 0, offsetTop = 0, offsetBottom = 0, affixed = null, unpin = null;
|
|
28
|
+
var parent = element.parent();
|
|
29
|
+
// Options: custom parent
|
|
30
|
+
if (options.offsetParent) {
|
|
31
|
+
if (options.offsetParent.match(/^\d+$/)) {
|
|
32
|
+
for (var i = 0; i < options.offsetParent * 1 - 1; i++) {
|
|
33
|
+
parent = parent.parent();
|
|
34
|
+
}
|
|
35
|
+
} else {
|
|
36
|
+
parent = angular.element(options.offsetParent);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
$affix.init = function () {
|
|
40
|
+
$affix.$parseOffsets();
|
|
41
|
+
initialOffsetTop = dimensions.offset(element[0]).top + initialAffixTop;
|
|
42
|
+
// Bind events
|
|
43
|
+
targetEl.on('scroll', $affix.checkPosition);
|
|
44
|
+
targetEl.on('click', $affix.checkPositionWithEventLoop);
|
|
45
|
+
windowEl.on('resize', $affix.$debouncedOnResize);
|
|
46
|
+
// Both of these checkPosition() calls are necessary for the case where
|
|
47
|
+
// the user hits refresh after scrolling to the bottom of the page.
|
|
48
|
+
$affix.checkPosition();
|
|
49
|
+
$affix.checkPositionWithEventLoop();
|
|
50
|
+
};
|
|
51
|
+
$affix.destroy = function () {
|
|
52
|
+
// Unbind events
|
|
53
|
+
targetEl.off('scroll', $affix.checkPosition);
|
|
54
|
+
targetEl.off('click', $affix.checkPositionWithEventLoop);
|
|
55
|
+
windowEl.off('resize', $affix.$debouncedOnResize);
|
|
56
|
+
};
|
|
57
|
+
$affix.checkPositionWithEventLoop = function () {
|
|
58
|
+
setTimeout($affix.checkPosition, 1);
|
|
59
|
+
};
|
|
60
|
+
$affix.checkPosition = function () {
|
|
61
|
+
// if (!this.$element.is(':visible')) return
|
|
62
|
+
var scrollTop = getScrollTop();
|
|
63
|
+
var position = dimensions.offset(element[0]);
|
|
64
|
+
var elementHeight = dimensions.height(element[0]);
|
|
65
|
+
// Get required affix class according to position
|
|
66
|
+
var affix = getRequiredAffixClass(unpin, position, elementHeight);
|
|
67
|
+
// Did affix status changed this last check?
|
|
68
|
+
if (affixed === affix)
|
|
69
|
+
return;
|
|
70
|
+
affixed = affix;
|
|
71
|
+
// Add proper affix class
|
|
72
|
+
element.removeClass(reset).addClass('affix' + (affix !== 'middle' ? '-' + affix : ''));
|
|
73
|
+
if (affix === 'top') {
|
|
74
|
+
unpin = null;
|
|
75
|
+
element.css('position', options.offsetParent ? '' : 'relative');
|
|
76
|
+
element.css('top', '');
|
|
77
|
+
} else if (affix === 'bottom') {
|
|
78
|
+
if (options.offsetUnpin) {
|
|
79
|
+
unpin = -(options.offsetUnpin * 1);
|
|
80
|
+
} else {
|
|
81
|
+
// Calculate unpin threshold when affixed to bottom.
|
|
82
|
+
// Hopefully the browser scrolls pixel by pixel.
|
|
83
|
+
unpin = position.top - scrollTop;
|
|
84
|
+
}
|
|
85
|
+
element.css('position', options.offsetParent ? '' : 'relative');
|
|
86
|
+
element.css('top', options.offsetParent ? '' : bodyEl[0].offsetHeight - offsetBottom - elementHeight - initialOffsetTop + 'px');
|
|
87
|
+
} else {
|
|
88
|
+
// affix === 'middle'
|
|
89
|
+
unpin = null;
|
|
90
|
+
element.css('position', 'fixed');
|
|
91
|
+
element.css('top', initialAffixTop + 'px');
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
$affix.$onResize = function () {
|
|
95
|
+
$affix.$parseOffsets();
|
|
96
|
+
$affix.checkPosition();
|
|
97
|
+
};
|
|
98
|
+
$affix.$debouncedOnResize = debounce($affix.$onResize, 50);
|
|
99
|
+
$affix.$parseOffsets = function () {
|
|
100
|
+
// Reset position to calculate correct offsetTop
|
|
101
|
+
element.css('position', options.offsetParent ? '' : 'relative');
|
|
102
|
+
if (options.offsetTop) {
|
|
103
|
+
if (options.offsetTop === 'auto') {
|
|
104
|
+
options.offsetTop = '+0';
|
|
105
|
+
}
|
|
106
|
+
if (options.offsetTop.match(/^[-+]\d+$/)) {
|
|
107
|
+
initialAffixTop = -options.offsetTop * 1;
|
|
108
|
+
if (options.offsetParent) {
|
|
109
|
+
offsetTop = dimensions.offset(parent[0]).top + options.offsetTop * 1;
|
|
110
|
+
} else {
|
|
111
|
+
offsetTop = dimensions.offset(element[0]).top - dimensions.css(element[0], 'marginTop', true) + options.offsetTop * 1;
|
|
112
|
+
}
|
|
113
|
+
} else {
|
|
114
|
+
offsetTop = options.offsetTop * 1;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (options.offsetBottom) {
|
|
118
|
+
if (options.offsetParent && options.offsetBottom.match(/^[-+]\d+$/)) {
|
|
119
|
+
// add 1 pixel due to rounding problems...
|
|
120
|
+
offsetBottom = getScrollHeight() - (dimensions.offset(parent[0]).top + dimensions.height(parent[0])) + options.offsetBottom * 1 + 1;
|
|
121
|
+
} else {
|
|
122
|
+
offsetBottom = options.offsetBottom * 1;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
// Private methods
|
|
127
|
+
function getRequiredAffixClass(unpin, position, elementHeight) {
|
|
128
|
+
var scrollTop = getScrollTop();
|
|
129
|
+
var scrollHeight = getScrollHeight();
|
|
130
|
+
if (scrollTop <= offsetTop) {
|
|
131
|
+
return 'top';
|
|
132
|
+
} else if (unpin !== null && scrollTop + unpin <= position.top) {
|
|
133
|
+
return 'middle';
|
|
134
|
+
} else if (offsetBottom !== null && position.top + elementHeight + initialAffixTop >= scrollHeight - offsetBottom) {
|
|
135
|
+
return 'bottom';
|
|
136
|
+
} else {
|
|
137
|
+
return 'middle';
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
function getScrollTop() {
|
|
141
|
+
return targetEl[0] === $window ? $window.pageYOffset : targetEl[0] === $window;
|
|
142
|
+
}
|
|
143
|
+
function getScrollHeight() {
|
|
144
|
+
return targetEl[0] === $window ? $window.document.body.scrollHeight : targetEl[0].scrollHeight;
|
|
145
|
+
}
|
|
146
|
+
$affix.init();
|
|
147
|
+
return $affix;
|
|
148
|
+
}
|
|
149
|
+
return AffixFactory;
|
|
150
|
+
}
|
|
151
|
+
];
|
|
152
|
+
}).directive('bsAffix', [
|
|
153
|
+
'$affix',
|
|
154
|
+
'$window',
|
|
155
|
+
function ($affix, $window) {
|
|
156
|
+
return {
|
|
157
|
+
restrict: 'EAC',
|
|
158
|
+
require: '^?bsAffixTarget',
|
|
159
|
+
link: function postLink(scope, element, attr, affixTarget) {
|
|
160
|
+
var options = {
|
|
161
|
+
scope: scope,
|
|
162
|
+
offsetTop: 'auto',
|
|
163
|
+
target: affixTarget ? affixTarget.$element : angular.element($window)
|
|
164
|
+
};
|
|
165
|
+
angular.forEach([
|
|
166
|
+
'offsetTop',
|
|
167
|
+
'offsetBottom',
|
|
168
|
+
'offsetParent',
|
|
169
|
+
'offsetUnpin'
|
|
170
|
+
], function (key) {
|
|
171
|
+
if (angular.isDefined(attr[key]))
|
|
172
|
+
options[key] = attr[key];
|
|
173
|
+
});
|
|
174
|
+
var affix = $affix(element, options);
|
|
175
|
+
scope.$on('$destroy', function () {
|
|
176
|
+
options = null;
|
|
177
|
+
affix = null;
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
]).directive('bsAffixTarget', function () {
|
|
183
|
+
return {
|
|
184
|
+
controller: [
|
|
185
|
+
'$element',
|
|
186
|
+
function ($element) {
|
|
187
|
+
this.$element = $element;
|
|
188
|
+
}
|
|
189
|
+
]
|
|
190
|
+
};
|
|
191
|
+
});
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* angular-strap
|
|
3
|
+
* @version v2.0.1 - 2014-04-10
|
|
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
|
+
// @BUG: following snippet won't compile correctly
|
|
10
|
+
// @TODO: submit issue to core
|
|
11
|
+
// '<span ng-if="title"><strong ng-bind="title"></strong> </span><span ng-bind-html="content"></span>' +
|
|
12
|
+
angular.module('mgcrea.ngStrap.alert', ['mgcrea.ngStrap.modal']).provider('$alert', function () {
|
|
13
|
+
var defaults = this.defaults = {
|
|
14
|
+
animation: 'am-fade',
|
|
15
|
+
prefixClass: 'alert',
|
|
16
|
+
placement: null,
|
|
17
|
+
template: 'alert/alert.tpl.html',
|
|
18
|
+
container: false,
|
|
19
|
+
element: null,
|
|
20
|
+
backdrop: false,
|
|
21
|
+
keyboard: true,
|
|
22
|
+
show: true,
|
|
23
|
+
duration: false,
|
|
24
|
+
type: false
|
|
25
|
+
};
|
|
26
|
+
this.$get = [
|
|
27
|
+
'$modal',
|
|
28
|
+
'$timeout',
|
|
29
|
+
function ($modal, $timeout) {
|
|
30
|
+
function AlertFactory(config) {
|
|
31
|
+
var $alert = {};
|
|
32
|
+
// Common vars
|
|
33
|
+
var options = angular.extend({}, defaults, config);
|
|
34
|
+
$alert = $modal(options);
|
|
35
|
+
// Support scope as string options [/*title, content, */type]
|
|
36
|
+
if (options.type) {
|
|
37
|
+
$alert.$scope.type = options.type;
|
|
38
|
+
}
|
|
39
|
+
// Support auto-close duration
|
|
40
|
+
var show = $alert.show;
|
|
41
|
+
if (options.duration) {
|
|
42
|
+
$alert.show = function () {
|
|
43
|
+
show();
|
|
44
|
+
$timeout(function () {
|
|
45
|
+
$alert.hide();
|
|
46
|
+
}, options.duration * 1000);
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
return $alert;
|
|
50
|
+
}
|
|
51
|
+
return AlertFactory;
|
|
52
|
+
}
|
|
53
|
+
];
|
|
54
|
+
}).directive('bsAlert', [
|
|
55
|
+
'$window',
|
|
56
|
+
'$location',
|
|
57
|
+
'$sce',
|
|
58
|
+
'$alert',
|
|
59
|
+
function ($window, $location, $sce, $alert) {
|
|
60
|
+
var requestAnimationFrame = $window.requestAnimationFrame || $window.setTimeout;
|
|
61
|
+
return {
|
|
62
|
+
restrict: 'EAC',
|
|
63
|
+
scope: true,
|
|
64
|
+
link: function postLink(scope, element, attr, transclusion) {
|
|
65
|
+
// Directive options
|
|
66
|
+
var options = {
|
|
67
|
+
scope: scope,
|
|
68
|
+
element: element,
|
|
69
|
+
show: false
|
|
70
|
+
};
|
|
71
|
+
angular.forEach([
|
|
72
|
+
'template',
|
|
73
|
+
'placement',
|
|
74
|
+
'keyboard',
|
|
75
|
+
'html',
|
|
76
|
+
'container',
|
|
77
|
+
'animation',
|
|
78
|
+
'duration'
|
|
79
|
+
], function (key) {
|
|
80
|
+
if (angular.isDefined(attr[key]))
|
|
81
|
+
options[key] = attr[key];
|
|
82
|
+
});
|
|
83
|
+
// Support scope as data-attrs
|
|
84
|
+
angular.forEach([
|
|
85
|
+
'title',
|
|
86
|
+
'content',
|
|
87
|
+
'type'
|
|
88
|
+
], function (key) {
|
|
89
|
+
attr[key] && attr.$observe(key, function (newValue, oldValue) {
|
|
90
|
+
scope[key] = $sce.trustAsHtml(newValue);
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
// Support scope as an object
|
|
94
|
+
attr.bsAlert && scope.$watch(attr.bsAlert, function (newValue, oldValue) {
|
|
95
|
+
if (angular.isObject(newValue)) {
|
|
96
|
+
angular.extend(scope, newValue);
|
|
97
|
+
} else {
|
|
98
|
+
scope.content = newValue;
|
|
99
|
+
}
|
|
100
|
+
}, true);
|
|
101
|
+
// Initialize alert
|
|
102
|
+
var alert = $alert(options);
|
|
103
|
+
// Trigger
|
|
104
|
+
element.on(attr.trigger || 'click', alert.toggle);
|
|
105
|
+
// Garbage collection
|
|
106
|
+
scope.$on('$destroy', function () {
|
|
107
|
+
alert.destroy();
|
|
108
|
+
options = null;
|
|
109
|
+
alert = null;
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
]);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* angular-strap
|
|
3
|
+
* @version v2.0.1 - 2014-04-10
|
|
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
|
+
$templateCache.put('alert/alert.tpl.html', '<div class="alert alert-dismissable" tabindex="-1" ng-class="[type ? \'alert-\' + type : null]"><button type="button" class="close" ng-click="$hide()">×</button> <strong ng-bind="title"></strong> <span ng-bind-html="content"></span></div>');
|
|
13
|
+
}
|
|
14
|
+
]);
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* angular-strap
|
|
3
|
+
* @version v2.0.1 - 2014-04-10
|
|
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.aside', ['mgcrea.ngStrap.modal']).provider('$aside', function () {
|
|
10
|
+
var defaults = this.defaults = {
|
|
11
|
+
animation: 'am-fade-and-slide-right',
|
|
12
|
+
prefixClass: 'aside',
|
|
13
|
+
placement: 'right',
|
|
14
|
+
template: 'aside/aside.tpl.html',
|
|
15
|
+
contentTemplate: false,
|
|
16
|
+
container: false,
|
|
17
|
+
element: null,
|
|
18
|
+
backdrop: true,
|
|
19
|
+
keyboard: true,
|
|
20
|
+
html: false,
|
|
21
|
+
show: true
|
|
22
|
+
};
|
|
23
|
+
this.$get = [
|
|
24
|
+
'$modal',
|
|
25
|
+
function ($modal) {
|
|
26
|
+
function AsideFactory(config) {
|
|
27
|
+
var $aside = {};
|
|
28
|
+
// Common vars
|
|
29
|
+
var options = angular.extend({}, defaults, config);
|
|
30
|
+
$aside = $modal(options);
|
|
31
|
+
return $aside;
|
|
32
|
+
}
|
|
33
|
+
return AsideFactory;
|
|
34
|
+
}
|
|
35
|
+
];
|
|
36
|
+
}).directive('bsAside', [
|
|
37
|
+
'$window',
|
|
38
|
+
'$location',
|
|
39
|
+
'$sce',
|
|
40
|
+
'$aside',
|
|
41
|
+
function ($window, $location, $sce, $aside) {
|
|
42
|
+
var requestAnimationFrame = $window.requestAnimationFrame || $window.setTimeout;
|
|
43
|
+
return {
|
|
44
|
+
restrict: 'EAC',
|
|
45
|
+
scope: true,
|
|
46
|
+
link: function postLink(scope, element, attr, transclusion) {
|
|
47
|
+
// Directive options
|
|
48
|
+
var options = {
|
|
49
|
+
scope: scope,
|
|
50
|
+
element: element,
|
|
51
|
+
show: false
|
|
52
|
+
};
|
|
53
|
+
angular.forEach([
|
|
54
|
+
'template',
|
|
55
|
+
'contentTemplate',
|
|
56
|
+
'placement',
|
|
57
|
+
'backdrop',
|
|
58
|
+
'keyboard',
|
|
59
|
+
'html',
|
|
60
|
+
'container',
|
|
61
|
+
'animation'
|
|
62
|
+
], function (key) {
|
|
63
|
+
if (angular.isDefined(attr[key]))
|
|
64
|
+
options[key] = attr[key];
|
|
65
|
+
});
|
|
66
|
+
// Support scope as data-attrs
|
|
67
|
+
angular.forEach([
|
|
68
|
+
'title',
|
|
69
|
+
'content'
|
|
70
|
+
], function (key) {
|
|
71
|
+
attr[key] && attr.$observe(key, function (newValue, oldValue) {
|
|
72
|
+
scope[key] = $sce.trustAsHtml(newValue);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
// Support scope as an object
|
|
76
|
+
attr.bsAside && scope.$watch(attr.bsAside, function (newValue, oldValue) {
|
|
77
|
+
if (angular.isObject(newValue)) {
|
|
78
|
+
angular.extend(scope, newValue);
|
|
79
|
+
} else {
|
|
80
|
+
scope.content = newValue;
|
|
81
|
+
}
|
|
82
|
+
}, true);
|
|
83
|
+
// Initialize aside
|
|
84
|
+
var aside = $aside(options);
|
|
85
|
+
// Trigger
|
|
86
|
+
element.on(attr.trigger || 'click', aside.toggle);
|
|
87
|
+
// Garbage collection
|
|
88
|
+
scope.$on('$destroy', function () {
|
|
89
|
+
aside.destroy();
|
|
90
|
+
options = null;
|
|
91
|
+
aside = null;
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
]);
|