| @@ 3374-3422 (lines=49) @@ | ||
| 3371 | * A helper, internal data structure that acts as a map but also allows getting / removing |
|
| 3372 | * elements in the LIFO order |
|
| 3373 | */ |
|
| 3374 | .factory('$$stackedMap', function() { |
|
| 3375 | return { |
|
| 3376 | createNew: function() { |
|
| 3377 | var stack = []; |
|
| 3378 | ||
| 3379 | return { |
|
| 3380 | add: function(key, value) { |
|
| 3381 | stack.push({ |
|
| 3382 | key: key, |
|
| 3383 | value: value |
|
| 3384 | }); |
|
| 3385 | }, |
|
| 3386 | get: function(key) { |
|
| 3387 | for (var i = 0; i < stack.length; i++) { |
|
| 3388 | if (key === stack[i].key) { |
|
| 3389 | return stack[i]; |
|
| 3390 | } |
|
| 3391 | } |
|
| 3392 | }, |
|
| 3393 | keys: function() { |
|
| 3394 | var keys = []; |
|
| 3395 | for (var i = 0; i < stack.length; i++) { |
|
| 3396 | keys.push(stack[i].key); |
|
| 3397 | } |
|
| 3398 | return keys; |
|
| 3399 | }, |
|
| 3400 | top: function() { |
|
| 3401 | return stack[stack.length - 1]; |
|
| 3402 | }, |
|
| 3403 | remove: function(key) { |
|
| 3404 | var idx = -1; |
|
| 3405 | for (var i = 0; i < stack.length; i++) { |
|
| 3406 | if (key === stack[i].key) { |
|
| 3407 | idx = i; |
|
| 3408 | break; |
|
| 3409 | } |
|
| 3410 | } |
|
| 3411 | return stack.splice(idx, 1)[0]; |
|
| 3412 | }, |
|
| 3413 | removeTop: function() { |
|
| 3414 | return stack.splice(stack.length - 1, 1)[0]; |
|
| 3415 | }, |
|
| 3416 | length: function() { |
|
| 3417 | return stack.length; |
|
| 3418 | } |
|
| 3419 | }; |
|
| 3420 | } |
|
| 3421 | }; |
|
| 3422 | }); |
|
| 3423 | angular.module('ui.bootstrap.modal', ['ui.bootstrap.stackedMap', 'ui.bootstrap.position']) |
|
| 3424 | /** |
|
| 3425 | * A helper, internal data structure that stores all references attached to key |
|
| @@ 3373-3421 (lines=49) @@ | ||
| 3370 | * A helper, internal data structure that acts as a map but also allows getting / removing |
|
| 3371 | * elements in the LIFO order |
|
| 3372 | */ |
|
| 3373 | .factory('$$stackedMap', function() { |
|
| 3374 | return { |
|
| 3375 | createNew: function() { |
|
| 3376 | var stack = []; |
|
| 3377 | ||
| 3378 | return { |
|
| 3379 | add: function(key, value) { |
|
| 3380 | stack.push({ |
|
| 3381 | key: key, |
|
| 3382 | value: value |
|
| 3383 | }); |
|
| 3384 | }, |
|
| 3385 | get: function(key) { |
|
| 3386 | for (var i = 0; i < stack.length; i++) { |
|
| 3387 | if (key === stack[i].key) { |
|
| 3388 | return stack[i]; |
|
| 3389 | } |
|
| 3390 | } |
|
| 3391 | }, |
|
| 3392 | keys: function() { |
|
| 3393 | var keys = []; |
|
| 3394 | for (var i = 0; i < stack.length; i++) { |
|
| 3395 | keys.push(stack[i].key); |
|
| 3396 | } |
|
| 3397 | return keys; |
|
| 3398 | }, |
|
| 3399 | top: function() { |
|
| 3400 | return stack[stack.length - 1]; |
|
| 3401 | }, |
|
| 3402 | remove: function(key) { |
|
| 3403 | var idx = -1; |
|
| 3404 | for (var i = 0; i < stack.length; i++) { |
|
| 3405 | if (key === stack[i].key) { |
|
| 3406 | idx = i; |
|
| 3407 | break; |
|
| 3408 | } |
|
| 3409 | } |
|
| 3410 | return stack.splice(idx, 1)[0]; |
|
| 3411 | }, |
|
| 3412 | removeTop: function() { |
|
| 3413 | return stack.splice(stack.length - 1, 1)[0]; |
|
| 3414 | }, |
|
| 3415 | length: function() { |
|
| 3416 | return stack.length; |
|
| 3417 | } |
|
| 3418 | }; |
|
| 3419 | } |
|
| 3420 | }; |
|
| 3421 | }); |
|
| 3422 | angular.module('ui.bootstrap.modal', ['ui.bootstrap.stackedMap', 'ui.bootstrap.position']) |
|
| 3423 | /** |
|
| 3424 | * A helper, internal data structure that stores all references attached to key |
|