From 1b90b3b65ea214a3a09922f6b9c1de304e5257da Mon Sep 17 00:00:00 2001 From: Petr Vobornik Date: Fri, 29 Mar 2013 15:27:58 +0100 Subject: Add phase on exact position https://fedorahosted.org/freeipa/ticket/3235 --- install/ui/src/libs/jquery.ordered-map.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'install/ui/src/libs') diff --git a/install/ui/src/libs/jquery.ordered-map.js b/install/ui/src/libs/jquery.ordered-map.js index 33737b564..77d17c56a 100755 --- a/install/ui/src/libs/jquery.ordered-map.js +++ b/install/ui/src/libs/jquery.ordered-map.js @@ -35,15 +35,25 @@ jQuery.ordered_map = jQuery.fn.ordered_map = function(map) { return that.map[key]; }; - that.put = function(key, value) { + that.put = function(key, value, position) { + + var undefined; var i = that.get_key_index(key); if (i >= 0) { that.values[i] = value; } else { - that.keys.push(key); - that.values.push(value); - that.length = that.keys.length; + if (typeof position !== 'number') { + that.keys.push(key); + that.values.push(value); + that.length = that.keys.length; + } else { + if (position < 0) position = 0; + else if (position > that.length) position = that.length; + that.keys.splice(position, 0, key); + that.values.splice(position, 0, value); + that.length = that.keys.length; + } } that.map[key] = value; -- cgit