diff --git a/src/modal/modal.js b/src/modal/modal.js index bd284c0a02..85d159dafd 100644 --- a/src/modal/modal.js +++ b/src/modal/modal.js @@ -1,59 +1,4 @@ -angular.module('ui.bootstrap.modal', []) - -/** - * A helper, internal data structure that acts as a map but also allows getting / removing - * elements in the LIFO order - */ - .factory('$$stackedMap', function() { - return { - createNew: function() { - var stack = []; - - return { - add: function(key, value) { - stack.push({ - key: key, - value: value - }); - }, - get: function(key) { - for (var i = 0; i < stack.length; i++) { - if (key == stack[i].key) { - return stack[i]; - } - } - }, - keys: function() { - var keys = []; - for (var i = 0; i < stack.length; i++) { - keys.push(stack[i].key); - } - return keys; - }, - top: function() { - return stack[stack.length - 1]; - }, - remove: function(key) { - var idx = -1; - for (var i = 0; i < stack.length; i++) { - if (key == stack[i].key) { - idx = i; - break; - } - } - return stack.splice(idx, 1)[0]; - }, - removeTop: function() { - return stack.splice(stack.length - 1, 1)[0]; - }, - length: function() { - return stack.length; - } - }; - } - }; - }) - +angular.module('ui.bootstrap.modal', ['ui.bootstrap.stackedMap']) /** * A helper, internal data structure that stores all references attached to key */ diff --git a/src/stackedMap/stackedMap.js b/src/stackedMap/stackedMap.js new file mode 100644 index 0000000000..bd97fb60db --- /dev/null +++ b/src/stackedMap/stackedMap.js @@ -0,0 +1,54 @@ +angular.module('ui.bootstrap.stackedMap', []) +/** + * A helper, internal data structure that acts as a map but also allows getting / removing + * elements in the LIFO order + */ + .factory('$$stackedMap', function() { + return { + createNew: function() { + var stack = []; + + return { + add: function(key, value) { + stack.push({ + key: key, + value: value + }); + }, + get: function(key) { + for (var i = 0; i < stack.length; i++) { + if (key == stack[i].key) { + return stack[i]; + } + } + }, + keys: function() { + var keys = []; + for (var i = 0; i < stack.length; i++) { + keys.push(stack[i].key); + } + return keys; + }, + top: function() { + return stack[stack.length - 1]; + }, + remove: function(key) { + var idx = -1; + for (var i = 0; i < stack.length; i++) { + if (key == stack[i].key) { + idx = i; + break; + } + } + return stack.splice(idx, 1)[0]; + }, + removeTop: function() { + return stack.splice(stack.length - 1, 1)[0]; + }, + length: function() { + return stack.length; + } + }; + } + }; + }); \ No newline at end of file diff --git a/src/modal/test/stackedMap.spec.js b/src/stackedMap/test/stackedMap.spec.js similarity index 99% rename from src/modal/test/stackedMap.spec.js rename to src/stackedMap/test/stackedMap.spec.js index 2e422eedf2..62ad5d698e 100644 --- a/src/modal/test/stackedMap.spec.js +++ b/src/stackedMap/test/stackedMap.spec.js @@ -49,4 +49,4 @@ describe('stacked map', function() { it('should ignore removal of non-existing elements', function() { expect(stackedMap.remove('non-existing')).toBeUndefined(); }); -}); \ No newline at end of file +}); diff --git a/src/tooltip/test/tooltip.spec.js b/src/tooltip/test/tooltip.spec.js index a5e23d7f12..a86bd2017c 100644 --- a/src/tooltip/test/tooltip.spec.js +++ b/src/tooltip/test/tooltip.spec.js @@ -3,7 +3,8 @@ describe('tooltip', function() { elmBody, scope, elmScope, - tooltipScope; + tooltipScope, + $document; // load the tooltip code beforeEach(module('ui.bootstrap.tooltip')); @@ -11,11 +12,12 @@ describe('tooltip', function() { // load the template beforeEach(module('template/tooltip/tooltip-popup.html')); - beforeEach(inject(function($rootScope, $compile) { + beforeEach(inject(function($rootScope, $compile, _$document_) { elmBody = angular.element( '