Return-Path: X-Original-To: apmail-brooklyn-commits-archive@minotaur.apache.org Delivered-To: apmail-brooklyn-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 94EED1852C for ; Mon, 1 Feb 2016 17:52:02 +0000 (UTC) Received: (qmail 84515 invoked by uid 500); 1 Feb 2016 17:52:02 -0000 Delivered-To: apmail-brooklyn-commits-archive@brooklyn.apache.org Received: (qmail 84417 invoked by uid 500); 1 Feb 2016 17:52:02 -0000 Mailing-List: contact commits-help@brooklyn.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@brooklyn.apache.org Delivered-To: mailing list commits@brooklyn.apache.org Received: (qmail 82923 invoked by uid 99); 1 Feb 2016 17:52:01 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Feb 2016 17:52:01 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 5230DE07F7; Mon, 1 Feb 2016 17:52:01 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: heneveld@apache.org To: commits@brooklyn.apache.org Date: Mon, 01 Feb 2016 17:53:03 -0000 Message-Id: In-Reply-To: <2f2fa8dbcb034fa3a39d73addfe1e183@git.apache.org> References: <2f2fa8dbcb034fa3a39d73addfe1e183@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [64/71] [abbrv] brooklyn-ui git commit: in yaml preview window, scroll to top after setting contents in yaml preview window, scroll to top after setting contents Project: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/repo Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/commit/8930be28 Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/tree/8930be28 Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/diff/8930be28 Branch: refs/heads/0.7.0-incubating Commit: 8930be2890af11ac3dbc4c3303f7b398708673cd Parents: 0c825e8 Author: Alex Heneveld Authored: Sat Jun 20 10:13:28 2015 -0700 Committer: Alex Heneveld Committed: Sun Jun 21 12:22:11 2015 -0700 ---------------------------------------------------------------------- .../webapp/assets/js/util/brooklyn-utils.js | 26 ++++++++++++++++++++ .../assets/js/view/application-add-wizard.js | 4 +-- 2 files changed, 28 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/8930be28/usage/jsgui/src/main/webapp/assets/js/util/brooklyn-utils.js ---------------------------------------------------------------------- diff --git a/usage/jsgui/src/main/webapp/assets/js/util/brooklyn-utils.js b/usage/jsgui/src/main/webapp/assets/js/util/brooklyn-utils.js index 318a734..5f3915c 100644 --- a/usage/jsgui/src/main/webapp/assets/js/util/brooklyn-utils.js +++ b/usage/jsgui/src/main/webapp/assets/js/util/brooklyn-utils.js @@ -188,6 +188,32 @@ define([ }); } + Util.setSelectionRange = function (input, selectionStart, selectionEnd) { + if (input.setSelectionRange) { + input.focus(); + input.setSelectionRange(selectionStart, selectionEnd); + } + else if (input.createTextRange) { + var range = input.createTextRange(); + range.collapse(true); + range.moveEnd('character', selectionEnd); + range.moveStart('character', selectionStart); + range.select(); + } + }; + + Util.setCaretToPos = function (input, pos) { + Util.setSelectionRange(input, pos, pos); + }; + + $.fn.setCaretToStart = function() { + this.each(function(index, elem) { + Util.setCaretToPos(elem, 0); + $(elem).scrollTop(0); + }); + return this; + }; + $("#logout-link").on("click", function (e) { e.preventDefault(); Util.logout() http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/8930be28/usage/jsgui/src/main/webapp/assets/js/view/application-add-wizard.js ---------------------------------------------------------------------- diff --git a/usage/jsgui/src/main/webapp/assets/js/view/application-add-wizard.js b/usage/jsgui/src/main/webapp/assets/js/view/application-add-wizard.js index e9427dd..09fd1c4 100644 --- a/usage/jsgui/src/main/webapp/assets/js/view/application-add-wizard.js +++ b/usage/jsgui/src/main/webapp/assets/js/view/application-add-wizard.js @@ -280,7 +280,7 @@ define([ if (yaml) { // it's a yaml catalog template which includes a location, show the yaml tab $("ul#app-add-wizard-create-tab").find("a[href='#yamlTab']").tab('show'); - $("#yaml_code").focus(); + $("#yaml_code").setCaretToStart(); } else { // it's a java catalog template or yaml template without a location, go to wizard this.currentStep += 1; @@ -302,7 +302,7 @@ define([ that.model.spec.pruneLocations(); $("textarea#yaml_code").val(JsYaml.safeDump(oldSpecToCamp(that.model.spec.toJSON()))); $("ul#app-add-wizard-create-tab").find("a[href='#yamlTab']").tab('show'); - $("#yaml_code").focus(); + $("#yaml_code").setCaretToStart(); }); } else { // call to validate should showFailure