From d3bf7e42844e94d8247abb24c7a8cd5b7d207fe0 Mon Sep 17 00:00:00 2001 From: Adam Young Date: Jun 20 2011 19:36:30 +0000 Subject: editable entity_select jsl fixes https://fedorahosted.org/freeipa/ticket/1043 remove redundant call to focus. --- diff --git a/install/ui/host.js b/install/ui/host.js index fe35e0f..bd14917 100644 --- a/install/ui/host.js +++ b/install/ui/host.js @@ -87,7 +87,19 @@ IPA.entity_factories.host = function () { }). standard_association_facets(). adder_dialog({ - fields: ['fqdn', {factory:IPA.force_host_add_checkbox_widget}] + width:500, + fields:[ + { + factory:IPA.entity_select_widget, + name: 'fqdn', + field_name:'idnsname', + entity: 'dnszone', + label: IPA.messages.objects.service.host, + editable: true, + undo: false + }, + {factory:IPA.force_host_add_checkbox_widget} + ] }). build(); }; diff --git a/install/ui/widget.js b/install/ui/widget.js index 9f013a0..528ee8b 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) { $('