bastion 1.0.2 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c36c849cc73e8e3c99e0736660a4cc34a955d120
4
- data.tar.gz: 6a71404931456f024ca9f15c704a14abab744171
3
+ metadata.gz: 52f906d47279b4f0208c48741f7b64b1fb137ffe
4
+ data.tar.gz: 0167998c6b06bbaf2feccccf30c0fdc771e87044
5
5
  SHA512:
6
- metadata.gz: 204ddad00ba3dfb01cf32dbee9856f4f7d8be98f18ee3b2dea58241aa9805e9e92e96976ab461c88d9b24c0440b6dc10dbfcad386f9e2eba2c25dd364d438474
7
- data.tar.gz: 31d4871ea9d01b82cfe2fec4d4650316ac9ce15def904090cc865ac7ef69a0be59f5a692f8c7e0f3fa89222f86328fba21e610871efd4b379872d3a596056898
6
+ metadata.gz: 6a5593efe6d9ae4e664e8bbc8e93c0b8b2be96fdc914d4eb0d06a621b4b8a66d0c4ee192cbe46d93b461843a8e017bf5e78cba08fb78e228d2f3d8c99567db30
7
+ data.tar.gz: 7f56299785fee09f780cdf78d72cf341868857fdac3a320a0d94252d3eaa44f0cbcec34ca75a799eb02e146e72e9ff7edb12df4a88a0b0bf85cb0dc61d609150
@@ -6,6 +6,7 @@ BASTION_MODULES = [
6
6
  'angular-blocks',
7
7
  'ngAnimate',
8
8
  'ngSanitize',
9
+ 'infinite-scroll',
9
10
  'templates',
10
11
  'ui.bootstrap',
11
12
  'ui.bootstrap.tpls',
@@ -6,6 +6,7 @@
6
6
  //= require "bastion/angular-ui-router/angular-ui-router"
7
7
  //= require "bastion/angular-uuid4/angular-uuid4.js"
8
8
  //= require "bastion/ngUpload/ng-upload"
9
+ //= require "bastion/ngInfiniteScroll/ng-infinite-scroll.js"
9
10
  //= require "bastion/angular-gettext/angular-gettext"
10
11
  //= require "bastion/angular-blocks/angular-blocks"
11
12
  //= require_tree "../../../../vendor/assets/javascripts/bastion/angular-bootstrap"
@@ -50,14 +50,13 @@
50
50
  </div>
51
51
  </div>
52
52
 
53
- <div class="nutupane" bst-table="detailsTable" nutupane-table>
53
+ <div class="nutupane nutupane-details-table" bst-table="detailsTable" nutupane-table>
54
54
  <div class="loading-mask loading-mask-collapsed" ng-show="detailsTable.refreshing">
55
55
  <i class="fa fa-spinner fa-spin"></i>
56
56
  <span ng-hide="$root.$state.current.collapsed">{{ "Loading..." | translate }}</span>
57
57
  </div>
58
58
 
59
- <div bst-container-scroll bst-infinite-scroll="detailsTable.nextPage()"
60
- data="detailsTable.rows" skip-initial-load="!detailsTable.initialLoad">
59
+ <div bst-container-scroll data="detailsTable.rows">
61
60
 
62
61
  <div class="nutupane-select-all" ng-show="detailsTable.selectAllResultsEnabled && detailsTable.allSelected() && !detailsTable.allResultsSelected">
63
62
  <span translate>All {{ detailsTable.rows.length }} items on this page are selected.</span>
@@ -73,7 +72,9 @@
73
72
  <span data-block="no-rows-message"></span>
74
73
  </p>
75
74
 
76
- <div ng-show="detailsTable.rows.length > 0" data-block="table"></div>
75
+ <div infinite-scroll="detailsTable.nextPage()" infinite-scroll-container="'.nutupane-details-table .container-scroll-wrapper'">
76
+ <div ng-show="detailsTable.rows.length > 0" data-block="table"></div>
77
+ </div>
77
78
  </div>
78
79
  </div>
79
80
 
@@ -61,8 +61,8 @@
61
61
  <span data-block="no-rows-message"></span>
62
62
  </p>
63
63
 
64
- <div ng-show="table.rows.length > 0" bst-container-scroll bst-infinite-scroll="table.nextPage()" data="table.rows">
65
- <div ui-view="table"></div>
64
+ <div ng-show="table.rows.length > 0" bst-container-scroll data="table.rows">
65
+ <div infinite-scroll="table.nextPage()" infinite-scroll-container="'.container-scroll-wrapper'" ui-view="table"></div>
66
66
  </div>
67
67
  </div>
68
68
 
data/bower.json CHANGED
@@ -16,6 +16,7 @@
16
16
  "angular-blocks": "~>0.1.8",
17
17
  "angular-i18n": "1.3.13",
18
18
  "underscore": "=1.5.2",
19
+ "ngInfiniteScroll": "1.2.0",
19
20
  "ngUpload": "~0.5.5",
20
21
  "bootstrap": "~3.1.1",
21
22
  "font-awesome": "4.2.0",
@@ -81,6 +82,9 @@
81
82
  "ngUpload": {
82
83
  "javascripts/bastion/ngUpload": "ng-upload.js"
83
84
  },
85
+ "ngInfiniteScroll": {
86
+ "javascripts/bastion/ngInfiniteScroll": "build/ng-infinite-scroll.js"
87
+ },
84
88
  "bootstrap": {
85
89
  "stylesheets/bastion/bootstrap/less": "less/*.less",
86
90
  "fonts/bastion/bootstrap": "dist/fonts/*"
data/grunt/karma.js CHANGED
@@ -28,6 +28,7 @@ module.exports = {
28
28
  basePath + 'vendor/assets/javascripts/bastion/angular-ui-router/angular-ui-router.js',
29
29
  basePath + 'vendor/assets/javascripts/bastion/angular-gettext/angular-gettext.js',
30
30
  basePath + 'vendor/assets/javascripts/bastion/ngUpload/ng-upload.js',
31
+ basePath + 'vendor/assets/javascripts/bastion/ngInfiniteScroll/ng-infinite-scroll.js',
31
32
  basePath + '.tmp/bower_components/angular-mocks/angular-mocks.js',
32
33
 
33
34
  basePath + 'app/assets/javascripts/bastion/bastion-bootstrap.js',
@@ -1,3 +1,3 @@
1
1
  module Bastion
2
- VERSION = "1.0.2"
2
+ VERSION = "2.0.0"
3
3
  end
@@ -0,0 +1,177 @@
1
+ /* ng-infinite-scroll - v1.2.0 - 2014-12-02 */
2
+ var mod;
3
+
4
+ mod = angular.module('infinite-scroll', []);
5
+
6
+ mod.value('THROTTLE_MILLISECONDS', null);
7
+
8
+ mod.directive('infiniteScroll', [
9
+ '$rootScope', '$window', '$interval', 'THROTTLE_MILLISECONDS', function($rootScope, $window, $interval, THROTTLE_MILLISECONDS) {
10
+ return {
11
+ scope: {
12
+ infiniteScroll: '&',
13
+ infiniteScrollContainer: '=',
14
+ infiniteScrollDistance: '=',
15
+ infiniteScrollDisabled: '=',
16
+ infiniteScrollUseDocumentBottom: '='
17
+ },
18
+ link: function(scope, elem, attrs) {
19
+ var changeContainer, checkWhenEnabled, container, handleInfiniteScrollContainer, handleInfiniteScrollDisabled, handleInfiniteScrollDistance, handleInfiniteScrollUseDocumentBottom, handler, height, immediateCheck, offsetTop, pageYOffset, scrollDistance, scrollEnabled, throttle, useDocumentBottom, windowElement;
20
+ windowElement = angular.element($window);
21
+ scrollDistance = null;
22
+ scrollEnabled = null;
23
+ checkWhenEnabled = null;
24
+ container = null;
25
+ immediateCheck = true;
26
+ useDocumentBottom = false;
27
+ height = function(elem) {
28
+ elem = elem[0] || elem;
29
+ if (isNaN(elem.offsetHeight)) {
30
+ return elem.document.documentElement.clientHeight;
31
+ } else {
32
+ return elem.offsetHeight;
33
+ }
34
+ };
35
+ offsetTop = function(elem) {
36
+ if (!elem[0].getBoundingClientRect || elem.css('none')) {
37
+ return;
38
+ }
39
+ return elem[0].getBoundingClientRect().top + pageYOffset(elem);
40
+ };
41
+ pageYOffset = function(elem) {
42
+ elem = elem[0] || elem;
43
+ if (isNaN(window.pageYOffset)) {
44
+ return elem.document.documentElement.scrollTop;
45
+ } else {
46
+ return elem.ownerDocument.defaultView.pageYOffset;
47
+ }
48
+ };
49
+ handler = function() {
50
+ var containerBottom, containerTopOffset, elementBottom, remaining, shouldScroll;
51
+ if (container === windowElement) {
52
+ containerBottom = height(container) + pageYOffset(container[0].document.documentElement);
53
+ elementBottom = offsetTop(elem) + height(elem);
54
+ } else {
55
+ containerBottom = height(container);
56
+ containerTopOffset = 0;
57
+ if (offsetTop(container) !== void 0) {
58
+ containerTopOffset = offsetTop(container);
59
+ }
60
+ elementBottom = offsetTop(elem) - containerTopOffset + height(elem);
61
+ }
62
+ if (useDocumentBottom) {
63
+ elementBottom = height((elem[0].ownerDocument || elem[0].document).documentElement);
64
+ }
65
+ remaining = elementBottom - containerBottom;
66
+ shouldScroll = remaining <= height(container) * scrollDistance + 1;
67
+ if (shouldScroll) {
68
+ checkWhenEnabled = true;
69
+ if (scrollEnabled) {
70
+ if (scope.$$phase || $rootScope.$$phase) {
71
+ return scope.infiniteScroll();
72
+ } else {
73
+ return scope.$apply(scope.infiniteScroll);
74
+ }
75
+ }
76
+ } else {
77
+ return checkWhenEnabled = false;
78
+ }
79
+ };
80
+ throttle = function(func, wait) {
81
+ var later, previous, timeout;
82
+ timeout = null;
83
+ previous = 0;
84
+ later = function() {
85
+ var context;
86
+ previous = new Date().getTime();
87
+ $interval.cancel(timeout);
88
+ timeout = null;
89
+ func.call();
90
+ return context = null;
91
+ };
92
+ return function() {
93
+ var now, remaining;
94
+ now = new Date().getTime();
95
+ remaining = wait - (now - previous);
96
+ if (remaining <= 0) {
97
+ clearTimeout(timeout);
98
+ $interval.cancel(timeout);
99
+ timeout = null;
100
+ previous = now;
101
+ return func.call();
102
+ } else {
103
+ if (!timeout) {
104
+ return timeout = $interval(later, remaining, 1);
105
+ }
106
+ }
107
+ };
108
+ };
109
+ if (THROTTLE_MILLISECONDS != null) {
110
+ handler = throttle(handler, THROTTLE_MILLISECONDS);
111
+ }
112
+ scope.$on('$destroy', function() {
113
+ return container.unbind('scroll', handler);
114
+ });
115
+ handleInfiniteScrollDistance = function(v) {
116
+ return scrollDistance = parseFloat(v) || 0;
117
+ };
118
+ scope.$watch('infiniteScrollDistance', handleInfiniteScrollDistance);
119
+ handleInfiniteScrollDistance(scope.infiniteScrollDistance);
120
+ handleInfiniteScrollDisabled = function(v) {
121
+ scrollEnabled = !v;
122
+ if (scrollEnabled && checkWhenEnabled) {
123
+ checkWhenEnabled = false;
124
+ return handler();
125
+ }
126
+ };
127
+ scope.$watch('infiniteScrollDisabled', handleInfiniteScrollDisabled);
128
+ handleInfiniteScrollDisabled(scope.infiniteScrollDisabled);
129
+ handleInfiniteScrollUseDocumentBottom = function(v) {
130
+ return useDocumentBottom = v;
131
+ };
132
+ scope.$watch('infiniteScrollUseDocumentBottom', handleInfiniteScrollUseDocumentBottom);
133
+ handleInfiniteScrollUseDocumentBottom(scope.infiniteScrollUseDocumentBottom);
134
+ changeContainer = function(newContainer) {
135
+ if (container != null) {
136
+ container.unbind('scroll', handler);
137
+ }
138
+ container = newContainer;
139
+ if (newContainer != null) {
140
+ return container.bind('scroll', handler);
141
+ }
142
+ };
143
+ changeContainer(windowElement);
144
+ handleInfiniteScrollContainer = function(newContainer) {
145
+ if ((newContainer == null) || newContainer.length === 0) {
146
+ return;
147
+ }
148
+ if (newContainer instanceof HTMLElement) {
149
+ newContainer = angular.element(newContainer);
150
+ } else if (typeof newContainer.append === 'function') {
151
+ newContainer = angular.element(newContainer[newContainer.length - 1]);
152
+ } else if (typeof newContainer === 'string') {
153
+ newContainer = angular.element(document.querySelector(newContainer));
154
+ }
155
+ if (newContainer != null) {
156
+ return changeContainer(newContainer);
157
+ } else {
158
+ throw new Exception("invalid infinite-scroll-container attribute.");
159
+ }
160
+ };
161
+ scope.$watch('infiniteScrollContainer', handleInfiniteScrollContainer);
162
+ handleInfiniteScrollContainer(scope.infiniteScrollContainer || []);
163
+ if (attrs.infiniteScrollParent != null) {
164
+ changeContainer(angular.element(elem.parent()));
165
+ }
166
+ if (attrs.infiniteScrollImmediateCheck != null) {
167
+ immediateCheck = scope.$eval(attrs.infiniteScrollImmediateCheck);
168
+ }
169
+ return $interval((function() {
170
+ if (immediateCheck) {
171
+ return handler();
172
+ }
173
+ }), 0, 1);
174
+ }
175
+ };
176
+ }
177
+ ]);
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bastion
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric D Helms
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-05-28 00:00:00.000000000 Z
12
+ date: 2015-06-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: angular-rails-templates
@@ -81,7 +81,6 @@ files:
81
81
  - app/assets/javascripts/bastion/components/bst-flyout.directive.js
82
82
  - app/assets/javascripts/bastion/components/bst-form-buttons.directive.js
83
83
  - app/assets/javascripts/bastion/components/bst-form-group.directive.js
84
- - app/assets/javascripts/bastion/components/bst-infinite-scroll.directive.js
85
84
  - app/assets/javascripts/bastion/components/bst-menu.directive.js
86
85
  - app/assets/javascripts/bastion/components/bst-modal.directive.js
87
86
  - app/assets/javascripts/bastion/components/bst-on-enter.directive.js
@@ -183,7 +182,6 @@ files:
183
182
  - test/components/bst-flyout.directive.test.js
184
183
  - test/components/bst-form-buttons.directive.test.js
185
184
  - test/components/bst-form-group.directive.test.js
186
- - test/components/bst-infinite-scroll.directive.test.js
187
185
  - test/components/bst-menu.directive.test.js
188
186
  - test/components/bst-modal.directive.test.js
189
187
  - test/components/bst-nutupane-table.directive.test.js
@@ -1020,6 +1018,7 @@ files:
1020
1018
  - vendor/assets/javascripts/bastion/angular/angular.js
1021
1019
  - vendor/assets/javascripts/bastion/es5-shim/es5-shim.js
1022
1020
  - vendor/assets/javascripts/bastion/json3/json3.js
1021
+ - vendor/assets/javascripts/bastion/ngInfiniteScroll/ng-infinite-scroll.js
1023
1022
  - vendor/assets/javascripts/bastion/ngUpload/ng-upload.js
1024
1023
  - vendor/assets/javascripts/bastion/underscore/underscore.js
1025
1024
  - vendor/assets/stylesheets/bastion/bootstrap/alerts.less
@@ -1156,7 +1155,6 @@ test_files:
1156
1155
  - test/menu/menu-expander.service.test.js
1157
1156
  - test/components/page-title.directive.test.js
1158
1157
  - test/components/bst-table.directive.test.js
1159
- - test/components/bst-infinite-scroll.directive.test.js
1160
1158
  - test/components/bst-container-scroll.directive.test.js
1161
1159
  - test/components/bst-modal.directive.test.js
1162
1160
  - test/components/bst-alert.directive.test.js
@@ -1,76 +0,0 @@
1
- /**
2
- * @ngdoc directive
3
- * @name Bastion.components.directive:bstInfiniteScroll
4
- *
5
- * @description
6
- * The infinite scroll directive should be applied to a wrapping div around another element
7
- * and provides automatic loading when a user scrolls to the bottom of the element.
8
- *
9
- * Note that the element using the bst-infinite-scroll directive should have it's overflow
10
- * set properly.
11
- *
12
- * @requires $window
13
- *
14
- * @example
15
- * <pre>
16
- * <div bst-infinite-scroll="loadMore()" style="height: 100px; overflow-y: auto;">
17
- * <p style="height: 1000px;">Hello</p>
18
- * </div>
19
- * </pre>
20
- */
21
- angular.module('Bastion.components').directive('bstInfiniteScroll', ['$window', function ($window) {
22
- return {
23
- scope: {
24
- data: '=',
25
- loadMoreFunction: '&bstInfiniteScroll',
26
- skipInitialLoad: '='
27
- },
28
- controller: function ($scope, $element) {
29
- var result, getScrollHeight, isPromise, loadUntilScroll,
30
- raw = $element[0];
31
-
32
- $element.bind('scroll', function () {
33
- var sliderPosition = raw.scrollTop + raw.offsetHeight;
34
- if (sliderPosition > 0 && sliderPosition >= raw.scrollHeight - 1) {
35
- $scope.loadMoreFunction();
36
- }
37
- });
38
-
39
- getScrollHeight = function () {
40
- var scrollHeight = 0;
41
- $element.children().each(function () {
42
- scrollHeight = scrollHeight + angular.element(this).get(0).scrollHeight;
43
- });
44
- return scrollHeight;
45
- };
46
-
47
- isPromise = function (promise) {
48
- return promise && promise.hasOwnProperty('then');
49
- };
50
-
51
- loadUntilScroll = function () {
52
- var loadResult;
53
-
54
- if (getScrollHeight() < $element.height()) {
55
- loadResult = $scope.loadMoreFunction();
56
- if (isPromise(loadResult)) {
57
- loadResult.then(function () {
58
- if (getScrollHeight() < $element.height()) {
59
- loadUntilScroll();
60
- }
61
- });
62
- }
63
- }
64
- };
65
-
66
- angular.element($window).bind('resize', loadUntilScroll);
67
-
68
- if (!$scope.skipInitialLoad && (angular.isUndefined($scope.data) || $scope.data.length === 0)) {
69
- result = $scope.loadMoreFunction();
70
- if (isPromise(result)) {
71
- result.then(loadUntilScroll);
72
- }
73
- }
74
- }
75
- };
76
- }]);
@@ -1,127 +0,0 @@
1
- describe('Directive: bstInfiniteScroll', function () {
2
- var $scope, $compile, $q, element;
3
-
4
- beforeEach(module('Bastion.components'));
5
-
6
- beforeEach(inject(function ($rootScope, _$compile_, _$q_){
7
- $scope = $rootScope;
8
- $compile = _$compile_;
9
- $q = _$q_;
10
-
11
- $scope.scrollHandler = {
12
- doIt: function() {
13
- var deferred = $q.defer();
14
- element.append('<p style="height: 10px;"></p>');
15
- deferred.resolve({});
16
- return deferred.promise;
17
- }
18
- };
19
- $scope.data = [];
20
- element = angular.element('<div data="data" bst-infinite-scroll="scrollHandler.doIt()" style="height: 100px; position: absolute; overflow-y: auto;"></div>');
21
- $('body').append(element);
22
- }));
23
-
24
- describe("loads more results if scrolling near the bottom", function() {
25
- beforeEach(function() {
26
- $compile(element)($scope);
27
- $scope.$digest();
28
- });
29
-
30
- it("calls the provided scroll function when scrolling near the bottom.", function() {
31
- spyOn($scope.scrollHandler, "doIt");
32
-
33
- // 95% of the height of the scroll area
34
- element.scrollTop(element[0].scrollHeight *.95);
35
- element.trigger('scroll');
36
-
37
- expect($scope.scrollHandler.doIt).toHaveBeenCalled();
38
- });
39
-
40
- it("does not calls the provided scroll function when not scrolling near the bottom.", function() {
41
- spyOn($scope.scrollHandler, "doIt");
42
-
43
- // 10% of the height of the scroll area
44
- element.scrollTop(element[0].scrollHeight *.10);
45
- element.trigger('scroll');
46
-
47
- expect($scope.scrollHandler.doIt).not.toHaveBeenCalled();
48
- });
49
- });
50
-
51
- describe("loads more results if there is not a scrollbar", function() {
52
- it("on initial load.", function() {
53
- spyOn($scope.scrollHandler, "doIt").andCallThrough();
54
- $compile(element)($scope);
55
- $scope.$digest();
56
- expect($scope.scrollHandler.doIt.callCount).toBe(10);
57
- });
58
- });
59
-
60
- describe("does not load more results if there is already a scrollbar", function() {
61
- beforeEach(function() {
62
- $compile(element)($scope);
63
- $scope.$digest();
64
- });
65
-
66
- it("on initial load.", function() {
67
- spyOn($scope.scrollHandler, "doIt").andCallThrough();
68
- $scope.$digest();
69
- expect($scope.scrollHandler.doIt.callCount).toBe(0);
70
- });
71
- });
72
-
73
- describe("loads more results based on the height of the elements", function() {
74
- beforeEach(function() {
75
- element.empty();
76
- element.append('<p style="height: 10px;"></p>');
77
- });
78
-
79
- it("loads more results if the scroll height is less than element height.", function() {
80
- spyOn($scope.scrollHandler, "doIt").andCallThrough();
81
- element.height("11px");
82
-
83
- $compile(element)($scope);
84
- $scope.$digest();
85
- $scope.$digest();
86
-
87
-
88
- expect($scope.scrollHandler.doIt.callCount).toBe(1);
89
- });
90
-
91
- it("does not load more results if the scroll height is equal to the element height.", function() {
92
- element.height("10px");
93
-
94
- $compile(element)($scope);
95
-
96
- spyOn($scope.scrollHandler, "doIt");
97
- $scope.$digest();
98
-
99
- expect($scope.scrollHandler.doIt.callCount).toBe(0);
100
- });
101
-
102
- it("does not load more results if the scroll height is greater than the element height.", function() {
103
- element.height("9px");
104
- element.append('<p style="height: 10px;"></p>');
105
- $compile(element)($scope);
106
-
107
- spyOn($scope.scrollHandler, "doIt");
108
- $scope.$digest();
109
-
110
- expect($scope.scrollHandler.doIt.callCount).toBe(0);
111
- });
112
-
113
- it("on resize", function() {
114
- element.height("11px");
115
- $compile(element)($scope);
116
- $scope.$digest();
117
- spyOn($scope.scrollHandler, "doIt").andCallThrough();
118
-
119
- element.height("21px");
120
- $(window).trigger('resize');
121
- $scope.$digest();
122
-
123
-
124
- expect($scope.scrollHandler.doIt.callCount).toBe(1);
125
- });
126
- });
127
- });