From d3bf7e42844e94d8247abb24c7a8cd5b7d207fe0 Mon Sep 17 00:00:00 2001 From: Adam Young Date: Sat, 18 Jun 2011 23:22:48 -0400 Subject: editable entity_select jsl fixes https://fedorahosted.org/freeipa/ticket/1043 remove redundant call to focus. --- install/ui/widget.js | 51 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) (limited to 'install/ui/widget.js') diff --git a/install/ui/widget.js b/install/ui/widget.js index 9f013a0a..528ee8b1 100644 --- a/install/ui/widget.js +++ b/install/ui/widget.js @@ -324,6 +324,20 @@ IPA.widget = function(spec) { return that; }; +/*uses a browser specific technique to select a range.*/ +IPA.select_range = function(input,start, end) { + input.focus(); + if (input[0].setSelectionRange) { + input[0].setSelectionRange(start, end); + } else if (input[0].createTextRange) { + var range = input[0].createTextRange(); + range.collapse(true); + range.moveEnd('character', end); + range.moveStart('character', start); + range.select(); + } +}; + IPA.text_widget = function(spec) { @@ -334,6 +348,10 @@ IPA.text_widget = function(spec) { that.size = spec.size || 30; that.type = spec.type || 'text'; + that.select_range = function(start, end){ + IPA.select_range(that.input, start, end); + }; + that.create = function(container) { $('