brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [64/71] [abbrv] brooklyn-ui git commit: in yaml preview window, scroll to top after setting contents
Date Mon, 01 Feb 2016 17:53:03 GMT
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 <alex.heneveld@cloudsoftcorp.com>
Authored: Sat Jun 20 10:13:28 2015 -0700
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
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


Mime
View raw message