brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [1/2] brooklyn-ui git commit: use local version of zeroclipboard movie
Date Sun, 21 Feb 2016 18:46:40 GMT
Repository: brooklyn-ui
Updated Branches:
  refs/heads/master 22ddab78f -> a4111a762


use local version of zeroclipboard movie

fixes issues in some recent browser (eg latest chrome on latest os x)
where the flash "movie" won't load unless it is local.
the error it gives is a generic "uncaught exception" in
ZeroClipboard activate -> flashState.bridge.setSize.
curiously it still works fine in some browsers (firefox) and
older chrome was also fine but I'm guessing
security modes are being tightened in browsers.

none of the other recommended settings for fixing this seem to work:
* trustedDomains
* trustedOrigin
* allowScriptAccess
* and even the flash config in the browser

it's just a small movie however so should be low impact (smaller than most of our images).
put in img path to simplify access.

also, zeroclipboard is updated from 1.3.1 to 1.3.5 (latest stable 1.x branch).
(2.x branch looks like it might be a bigger api change although some fixes in this area are
reported.)

this does not include the ZeroClipboard.swf binary but it will download it as is
normal practise for binary dependencies.  slightly unusually this uses maven to download it
explicitly.


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

Branch: refs/heads/master
Commit: 9b34c8c75883d9891229eff7bc6a5c0ca5b0974c
Parents: 68fb226
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Wed Feb 10 08:56:33 2016 +0000
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Thu Feb 18 16:14:08 2016 +0000

----------------------------------------------------------------------
 pom.xml                                         | 98 ++++++++++++++------
 .../webapp/assets/img/zeroclipboard/.gitignore  |  1 +
 .../webapp/assets/img/zeroclipboard/README.md   | 41 ++++++++
 src/main/webapp/assets/js/libs/ZeroClipboard.js | 67 ++++++++-----
 src/main/webapp/assets/js/view/entity-config.js |  2 +-
 .../webapp/assets/js/view/entity-sensors.js     |  2 +-
 6 files changed, 158 insertions(+), 53 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/9b34c8c7/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 3c5acf0..39f9e8c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -220,34 +220,49 @@
                 </plugin>
                 <!--This plugin's configuration is used to store Eclipse m2e settings
only. It has no influence on the Maven build itself.-->
                 <plugin>
-                	<groupId>org.eclipse.m2e</groupId>
-                	<artifactId>lifecycle-mapping</artifactId>
-                	<version>1.0.0</version>
-                	<configuration>
-                		<lifecycleMappingMetadata>
-                			<pluginExecutions>
-                				<pluginExecution>
-                					<pluginExecutionFilter>
-                						<groupId>
-                							com.github.skwakman.nodejs-maven-plugin
-                						</groupId>
-                						<artifactId>
-                							nodejs-maven-plugin
-                						</artifactId>
-                						<versionRange>
-                							[1.0.3,)
-                						</versionRange>
-                						<goals>
-                							<goal>extract</goal>
-                						</goals>
-                					</pluginExecutionFilter>
-                					<action>
-                						<ignore></ignore>
-                					</action>
-                				</pluginExecution>
-                			</pluginExecutions>
-                		</lifecycleMappingMetadata>
-                	</configuration>
+                  <groupId>org.eclipse.m2e</groupId>
+                  <artifactId>lifecycle-mapping</artifactId>
+                  <version>1.0.0</version>
+                  <configuration>
+                    <lifecycleMappingMetadata>
+                      <pluginExecutions>
+                        <pluginExecution>
+                          <pluginExecutionFilter>
+                            <groupId>
+                              com.github.skwakman.nodejs-maven-plugin
+                            </groupId>
+                            <artifactId>
+                              nodejs-maven-plugin
+                            </artifactId>
+                            <versionRange>
+                              [1.0.3,)
+                            </versionRange>
+                            <goals>
+                              <goal>extract</goal>
+                            </goals>
+                          </pluginExecutionFilter>
+                          <action>
+                            <ignore></ignore>
+                          </action>
+                        </pluginExecution>
+                        <pluginExecution>
+                          <pluginExecutionFilter>
+                            <groupId>org.codehaus.mojo</groupId>
+                            <artifactId>
+                              wagon-maven-plugin
+                            </artifactId>
+                            <versionRange>[1.0,)</versionRange>
+                            <goals>
+                              <goal>download-single</goal>
+                            </goals>
+                          </pluginExecutionFilter>
+                          <action>
+                            <ignore></ignore>
+                          </action>
+                        </pluginExecution>
+                      </pluginExecutions>
+                    </lifecycleMappingMetadata>
+                  </configuration>
                 </plugin>
             </plugins>
         </pluginManagement>
@@ -434,6 +449,33 @@
                 </plugins>
             </build>
         </profile>
+        <profile>
+            <!-- see README in the directory referenced below -->
+            <id>download-zeroclipboard</id>
+            <activation>
+                <file><missing>src/main/webapp/assets/img/zeroclipboard/ZeroClipboard.swf</missing></file>
+            </activation>
+            <build><plugins><plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>wagon-maven-plugin</artifactId>
+                <version>1.0</version>
+                <executions>
+                    <execution>
+                        <id>download-zeroclipboard</id>
+                        <phase>generate-sources</phase>
+                        <goals>
+                            <goal>download-single</goal>
+                        </goals>
+                        <configuration>
+                            <url>http://cdnjs.cloudflare.com</url>
+                            <fromFile>/ajax/libs/zeroclipboard/1.3.5/ZeroClipboard.swf</fromFile>
+                            <toDir>src/main/webapp/assets/img/zeroclipboard/</toDir>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin></plugins></build>
+        </profile>
+
     </profiles>
 
 </project>

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/9b34c8c7/src/main/webapp/assets/img/zeroclipboard/.gitignore
----------------------------------------------------------------------
diff --git a/src/main/webapp/assets/img/zeroclipboard/.gitignore b/src/main/webapp/assets/img/zeroclipboard/.gitignore
new file mode 100644
index 0000000..b780f9f
--- /dev/null
+++ b/src/main/webapp/assets/img/zeroclipboard/.gitignore
@@ -0,0 +1 @@
+ZeroClipboard.swf

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/9b34c8c7/src/main/webapp/assets/img/zeroclipboard/README.md
----------------------------------------------------------------------
diff --git a/src/main/webapp/assets/img/zeroclipboard/README.md b/src/main/webapp/assets/img/zeroclipboard/README.md
new file mode 100644
index 0000000..8407841
--- /dev/null
+++ b/src/main/webapp/assets/img/zeroclipboard/README.md
@@ -0,0 +1,41 @@
+
+For the clipboard to work, the ZeroClipboard.swf artifact (v1.3.5) needs to be 
+downloaded and installed in this directory. Maven will do this automatically for
+you on first run and thereafter use the downloaded version.
+
+If you do not wish to have it, simply create an empty file with that name in this dir.
+
+You can download it manually from:
+
+    http://cdnjs.cloudflare.com/ajax/libs/zeroclipboard/1.3.5/ZeroClipboard.swf
+
+It can be built from source using a free toolchain as described at 
+
+    https://github.com/zeroclipboard/zeroclipboard/blob/master/CONTRIBUTING.md .
+
+It is not checked in because binary artifacts should not be included in source releases
+due to Apache policies. This project is not currently set up to use bower/npm which would
+do the same thing, so instead we follow this process. See also ZeroClipboard.js.
+
+ZeroClipboard is used under the MIT license.
+
+This description file is part of the Apache Brooklyn project.
+
+----
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/9b34c8c7/src/main/webapp/assets/js/libs/ZeroClipboard.js
----------------------------------------------------------------------
diff --git a/src/main/webapp/assets/js/libs/ZeroClipboard.js b/src/main/webapp/assets/js/libs/ZeroClipboard.js
index bcdabf5..a28dd56 100644
--- a/src/main/webapp/assets/js/libs/ZeroClipboard.js
+++ b/src/main/webapp/assets/js/libs/ZeroClipboard.js
@@ -4,14 +4,14 @@
 * Copyright (c) 2014 Jon Rohan, James M. Greene
 * Licensed MIT
 * http://zeroclipboard.org/
-* v1.3.1
+* v1.3.5
 *
 * BROOKLYN NOTE: The accompanying SWF artifact can also be built from source using a free
toolchain
 * as described at https://github.com/zeroclipboard/zeroclipboard/blob/master/CONTRIBUTING.md
.
 * (It has been included in the Apache project as a binary artifact because building it is
tedious.
 * Also- it is small!) This paragraph is the only change to this source file.
 */
-(function() {
+(function(window) {
   "use strict";
   var currentElement;
   var flashState = {
@@ -449,6 +449,12 @@
     }
     return obj;
   };
+  var _safeActiveElement = function() {
+    try {
+      return document.activeElement;
+    } catch (err) {}
+    return null;
+  };
   var _detectFlashSupport = function() {
     var hasFlash = false;
     if (typeof flashState.disabled === "boolean") {
@@ -505,22 +511,28 @@
   ZeroClipboard.prototype.setText = function(newText) {
     if (newText && newText !== "") {
       _clipData["text/plain"] = newText;
-      if (flashState.ready === true && flashState.bridge) {
+      if (flashState.ready === true && flashState.bridge && typeof flashState.bridge.setText
=== "function") {
         flashState.bridge.setText(newText);
-      } else {}
+      } else {
+        flashState.ready = false;
+      }
     }
     return this;
   };
   ZeroClipboard.prototype.setSize = function(width, height) {
-    if (flashState.ready === true && flashState.bridge) {
+    if (flashState.ready === true && flashState.bridge && typeof flashState.bridge.setSize
=== "function") {
       flashState.bridge.setSize(width, height);
-    } else {}
+    } else {
+      flashState.ready = false;
+    }
     return this;
   };
   var _setHandCursor = function(enabled) {
-    if (flashState.ready === true && flashState.bridge) {
+    if (flashState.ready === true && flashState.bridge && typeof flashState.bridge.setHandCursor
=== "function") {
       flashState.bridge.setHandCursor(enabled);
-    } else {}
+    } else {
+      flashState.ready = false;
+    }
   };
   ZeroClipboard.prototype.destroy = function() {
     this.unclip();
@@ -537,7 +549,7 @@
     }
     return clients;
   };
-  ZeroClipboard.version = "1.3.1";
+  ZeroClipboard.version = "1.3.5";
   var _globalConfig = {
     swfPath: _swfPath,
     trustedDomains: window.location.host ? [ window.location.host ] : [],
@@ -669,8 +681,10 @@
         htmlBridge.style.height = pos.height + "px";
         htmlBridge.style.zIndex = pos.zIndex + 1;
       }
-      if (flashState.ready === true && flashState.bridge) {
+      if (flashState.ready === true && flashState.bridge && typeof flashState.bridge.setSize
=== "function") {
         flashState.bridge.setSize(pos.width, pos.height);
+      } else {
+        flashState.ready = false;
       }
     }
     return this;
@@ -867,7 +881,7 @@
     if (typeof eventName === "string" && eventName) {
       var cleanEventName = eventName.toLowerCase().replace(/^on/, "");
       if (cleanEventName) {
-        var clients = currentElement ? _getAllClientsClippedToElement(currentElement) : _getAllClients();
+        var clients = currentElement && _globalConfig.autoActivate === true ? _getAllClientsClippedToElement(currentElement)
: _getAllClients();
         for (var i = 0, len = clients.length; i < len; i++) {
           _receiveEvent.call(clients[i], cleanEventName, args);
         }
@@ -978,16 +992,18 @@
       break;
 
      case "datarequested":
-      var targetId = element.getAttribute("data-clipboard-target"), targetEl = !targetId
? null : document.getElementById(targetId);
-      if (targetEl) {
-        var textContent = targetEl.value || targetEl.textContent || targetEl.innerText;
-        if (textContent) {
-          this.setText(textContent);
-        }
-      } else {
-        var defaultText = element.getAttribute("data-clipboard-text");
-        if (defaultText) {
-          this.setText(defaultText);
+      if (element) {
+        var targetId = element.getAttribute("data-clipboard-target"), targetEl = !targetId
? null : document.getElementById(targetId);
+        if (targetEl) {
+          var textContent = targetEl.value || targetEl.textContent || targetEl.innerText;
+          if (textContent) {
+            this.setText(textContent);
+          }
+        } else {
+          var defaultText = element.getAttribute("data-clipboard-text");
+          if (defaultText) {
+            this.setText(defaultText);
+          }
         }
       }
       performCallbackAsync = false;
@@ -995,6 +1011,9 @@
 
      case "complete":
       _deleteOwnProperties(_clipData);
+      if (element && element !== _safeActiveElement() && element.focus) {
+        element.focus();
+      }
       break;
     }
     var context = element;
@@ -1006,10 +1025,12 @@
       _amdModuleId = module && module.id || null;
       return ZeroClipboard;
     });
-  } else if (typeof module === "object" && module && typeof module.exports
=== "object" && module.exports) {
+  } else if (typeof module === "object" && module && typeof module.exports
=== "object" && module.exports && typeof window.require === "function") {
     _cjsModuleId = module.id || null;
     module.exports = ZeroClipboard;
   } else {
     window.ZeroClipboard = ZeroClipboard;
   }
-})();
+})(function() {
+  return this;
+}());

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/9b34c8c7/src/main/webapp/assets/js/view/entity-config.js
----------------------------------------------------------------------
diff --git a/src/main/webapp/assets/js/view/entity-config.js b/src/main/webapp/assets/js/view/entity-config.js
index f517bcb..a115bb3 100644
--- a/src/main/webapp/assets/js/view/entity-config.js
+++ b/src/main/webapp/assets/js/view/entity-config.js
@@ -28,7 +28,7 @@ define([
 ], function (_, $, Backbone, Util, ZeroClipboard, ViewUtils, ConfigSummary, ConfigHtml, ConfigNameHtml)
{
 
     // TODO consider extracting all such usages to a shared ZeroClipboard wrapper?
-    ZeroClipboard.config({ moviePath: '//cdnjs.cloudflare.com/ajax/libs/zeroclipboard/1.3.1/ZeroClipboard.swf'
});
+    ZeroClipboard.config({ moviePath: '/assets/img/zeroclipboard/ZeroClipboard.swf' });
 
     var configHtml = _.template(ConfigHtml),
         configNameHtml = _.template(ConfigNameHtml);

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/9b34c8c7/src/main/webapp/assets/js/view/entity-sensors.js
----------------------------------------------------------------------
diff --git a/src/main/webapp/assets/js/view/entity-sensors.js b/src/main/webapp/assets/js/view/entity-sensors.js
index 282c622..9e91331 100644
--- a/src/main/webapp/assets/js/view/entity-sensors.js
+++ b/src/main/webapp/assets/js/view/entity-sensors.js
@@ -28,7 +28,7 @@ define([
 ], function (_, $, Backbone, Util, ZeroClipboard, ViewUtils, SensorSummary, SensorsHtml,
SensorNameHtml) {
 
     // TODO consider extracting all such usages to a shared ZeroClipboard wrapper?
-    ZeroClipboard.config({ moviePath: '//cdnjs.cloudflare.com/ajax/libs/zeroclipboard/1.3.1/ZeroClipboard.swf'
});
+    ZeroClipboard.config({ moviePath: '/assets/img/zeroclipboard/ZeroClipboard.swf' });
     
     var sensorHtml = _.template(SensorsHtml),
         sensorNameHtml = _.template(SensorNameHtml);


Mime
View raw message