brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rich...@apache.org
Subject [03/16] incubator-brooklyn git commit: tidy jsgui for sensors+config
Date Tue, 23 Jun 2015 12:26:19 GMT
tidy jsgui for sensors+config

* word "copied" properly removed after delay
* use nice tooltip styling
* suppress tooltip if no useful info (ad hoc sensor/config)


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/ba30c69a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/ba30c69a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/ba30c69a

Branch: refs/heads/master
Commit: ba30c69a244b449c55fbeaa32fcda23e947c5512
Parents: 3650dfa
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Fri Jun 19 20:22:30 2015 -0700
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Sun Jun 21 12:22:11 2015 -0700

----------------------------------------------------------------------
 .../main/webapp/assets/js/view/entity-config.js | 33 +++++++++-----------
 .../webapp/assets/js/view/entity-sensors.js     | 33 +++++++++-----------
 .../webapp/assets/tpl/apps/config-name.html     | 12 ++++++-
 .../webapp/assets/tpl/apps/sensor-name.html     | 12 ++++++-
 4 files changed, 52 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ba30c69a/usage/jsgui/src/main/webapp/assets/js/view/entity-config.js
----------------------------------------------------------------------
diff --git a/usage/jsgui/src/main/webapp/assets/js/view/entity-config.js b/usage/jsgui/src/main/webapp/assets/js/view/entity-config.js
index 924339d..befd9f2 100644
--- a/usage/jsgui/src/main/webapp/assets/js/view/entity-config.js
+++ b/usage/jsgui/src/main/webapp/assets/js/view/entity-config.js
@@ -176,30 +176,24 @@ define([
             
             this.zeroClipboard = new ZeroClipboard();
             this.zeroClipboard.on( "dataRequested" , function(client) {
-                var text = $(this).attr('copy-value');
-                if (!text) text = $(this).closest('.floatGroup').find('.value').html();
                 try {
-//                    log("Copying text '"+text+"' to clipboard");
+                    // the zeroClipboard instance is a singleton so check our scope first
+                    if (!$(this).closest("#config-table").length) return;
+                    var text = $(this).attr('copy-value');
+                    if (!text) text = $(this).closest('.floatGroup').find('.value').html();
+                    
+//                    log("Copying config text '"+text+"' to clipboard");
                     client.setText(text);
                     
-                    var $widget = $(this);
-                    var oldHtml = $widget.html();
-                    var fnRestore = _.once(function() { $widget.html(oldHtml); });
-                    // show the word copied for feedback;
+                    // show the word "copied" for feedback;
                     // NB this occurs on mousedown, due to how flash plugin works
                     // (same style of feedback and interaction as github)
                     // the other "clicks" are now triggered by *mouseup*
+                    var $widget = $(this);
+                    var oldHtml = $widget.html();
                     $widget.html('<b>Copied!</b>');
-                    setTimeout(fnRestore, 3000);
-                    
-                    // these listeners stay registered until page is reloaded
-                    // but they do nothing after first run, due to use of _.once
-                    // however the timeout is good enough, and actually desired
-                    // because on corner case of mousedown-moveaway-mouseup,
-                    // we want to keep the feedback; so they work, but are disabled for now.
-                    // (remove once we are happy with this behaviour, since Feb 2014)
-//                    that.zeroClipboard.on( "mouseout", fnRestore);
-//                    that.zeroClipboard.on( "mouseup", fnRestore);
+                    // use a timeout to restore because mouseouts can leave corner cases
(see history)
+                    setTimeout(function() { $widget.html(oldHtml); }, 600);
                 } catch (e) {
                     log("Zeroclipboard failure; falling back to prompt mechanism");
                     log(e);
@@ -229,7 +223,10 @@ define([
         floatMenuActive: false,
         lastFloatMenuRowId: null,
         lastFloatFocusInTextForEventUnmangling: null,
-        updateFloatMenus: function() { this.zeroClipboard.clip( $('.valueCopy') ); },
+        updateFloatMenus: function() {
+            $('#config-table *[rel="tooltip"]').tooltip();
+            this.zeroClipboard.clip( $('.valueCopy') );
+        },
         showFloatLeft: function(event) {
             this.noteFloatMenuFocusChange(true, event, "show-left");
             this.showFloatLeftOf($(event.currentTarget));

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ba30c69a/usage/jsgui/src/main/webapp/assets/js/view/entity-sensors.js
----------------------------------------------------------------------
diff --git a/usage/jsgui/src/main/webapp/assets/js/view/entity-sensors.js b/usage/jsgui/src/main/webapp/assets/js/view/entity-sensors.js
index cf84508..7fbf90e 100644
--- a/usage/jsgui/src/main/webapp/assets/js/view/entity-sensors.js
+++ b/usage/jsgui/src/main/webapp/assets/js/view/entity-sensors.js
@@ -184,30 +184,24 @@ define([
             
             this.zeroClipboard = new ZeroClipboard();
             this.zeroClipboard.on( "dataRequested" , function(client) {
-                var text = $(this).attr('copy-value');
-                if (!text) text = $(this).closest('.floatGroup').find('.value').html();
                 try {
-//                    log("Copying text '"+text+"' to clipboard");
+                    // the zeroClipboard instance is a singleton so check our scope first
+                    if (!$(this).closest("#sensors-table").length) return;
+                    var text = $(this).attr('copy-value');
+                    if (!text) text = $(this).closest('.floatGroup').find('.value').html();
+                    
+//                    log("Copying sensors text '"+text+"' to clipboard");
                     client.setText(text);
                     
-                    var $widget = $(this);
-                    var oldHtml = $widget.html();
-                    var fnRestore = _.once(function() { $widget.html(oldHtml); });
-                    // show the word copied for feedback;
+                    // show the word "copied" for feedback;
                     // NB this occurs on mousedown, due to how flash plugin works
                     // (same style of feedback and interaction as github)
                     // the other "clicks" are now triggered by *mouseup*
+                    var $widget = $(this);
+                    var oldHtml = $widget.html();
                     $widget.html('<b>Copied!</b>');
-                    setTimeout(fnRestore, 3000);
-                    
-                    // these listeners stay registered until page is reloaded
-                    // but they do nothing after first run, due to use of _.once
-                    // however the timeout is good enough, and actually desired
-                    // because on corner case of mousedown-moveaway-mouseup,
-                    // we want to keep the feedback; so they work, but are disabled for now.
-                    // (remove once we are happy with this behaviour, since Feb 2014)
-//                    that.zeroClipboard.on( "mouseout", fnRestore);
-//                    that.zeroClipboard.on( "mouseup", fnRestore);
+                    // use a timeout to restore because mouseouts can leave corner cases
(see history)
+                    setTimeout(function() { $widget.html(oldHtml); }, 600);
                 } catch (e) {
                     log("Zeroclipboard failure; falling back to prompt mechanism");
                     log(e);
@@ -248,7 +242,10 @@ define([
         floatMenuActive: false,
         lastFloatMenuRowId: null,
         lastFloatFocusInTextForEventUnmangling: null,
-        updateFloatMenus: function() { this.zeroClipboard.clip( $('.valueCopy') ); },
+        updateFloatMenus: function() {
+            $('#sensors-table *[rel="tooltip"]').tooltip();
+            this.zeroClipboard.clip( $('.valueCopy') );
+        },
         showFloatLeft: function(event) {
             this.noteFloatMenuFocusChange(true, event, "show-left");
             this.showFloatLeftOf($(event.currentTarget));

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ba30c69a/usage/jsgui/src/main/webapp/assets/tpl/apps/config-name.html
----------------------------------------------------------------------
diff --git a/usage/jsgui/src/main/webapp/assets/tpl/apps/config-name.html b/usage/jsgui/src/main/webapp/assets/tpl/apps/config-name.html
index cc183b9..1170415 100644
--- a/usage/jsgui/src/main/webapp/assets/tpl/apps/config-name.html
+++ b/usage/jsgui/src/main/webapp/assets/tpl/apps/config-name.html
@@ -18,7 +18,17 @@ specific language governing permissions and limitations
 under the License.
 -->
 
+<% if (description || type) { %>
 <span class="config-name" rel="tooltip" data-placement="left"
-    title="<% if (description) { %><b><%- description %></b><br/><%
} %>(<%- type %>)">
+    title="<% 
+         if (description) { %><b><%- description %></b><br/><%
} 
+         if (type) { %>(<% 
+           if (type.startsWith("java.lang.") || type.startsWith("util.")) type = type.substring(10);
+         %><%- type %>)<% } %>">
     <%- name %>
 </span>
+<% } else { %>
+<span class="config-name">
+    <%- name %>
+</span>
+<% } %>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ba30c69a/usage/jsgui/src/main/webapp/assets/tpl/apps/sensor-name.html
----------------------------------------------------------------------
diff --git a/usage/jsgui/src/main/webapp/assets/tpl/apps/sensor-name.html b/usage/jsgui/src/main/webapp/assets/tpl/apps/sensor-name.html
index 6a5577b..222ba1f 100644
--- a/usage/jsgui/src/main/webapp/assets/tpl/apps/sensor-name.html
+++ b/usage/jsgui/src/main/webapp/assets/tpl/apps/sensor-name.html
@@ -18,7 +18,17 @@ specific language governing permissions and limitations
 under the License.
 -->
 
+<% if (description || type) { %>
 <span class="sensor-name" rel="tooltip" data-placement="left"
-    title="<% if (description) { %><b><%- description %></b><br/><%
} %>(<%- type %>)">
+    title="<% 
+         if (description) { %><b><%- description %></b><br/><%
} 
+         if (type) { %>(<% 
+           if (type.startsWith("java.lang.") || type.startsWith("util.")) type = type.substring(10);
+         %><%- type %>)<% } %>">
     <%- name %>
 </span>
+<% } else { %>
+<span class="sensor-name">
+    <%- name %>
+</span>
+<% } %>


Mime
View raw message