From 763538e1360ea03ff4da714c390fb6b94e33e7af Mon Sep 17 00:00:00 2001 From: Seth Call Date: Thu, 13 Feb 2014 17:51:51 +0000 Subject: [PATCH] * VRFS-1095 fixing copy-to-clipboard for share dialog in native client. --- ruby/.simplecov | 24 ++++++++++++++++ web/app/assets/javascripts/fakeJamClient.js | 8 ++++++ web/app/assets/javascripts/shareDialog.js | 31 +++++++++++++-------- web/app/assets/javascripts/utils.js | 15 ++++++++++ 4 files changed, 66 insertions(+), 12 deletions(-) diff --git a/ruby/.simplecov b/ruby/.simplecov index 001eb3ab5..20d05200f 100644 --- a/ruby/.simplecov +++ b/ruby/.simplecov @@ -5,3 +5,27 @@ SimpleCov.start do add_filter "/tmp/" add_filter "/vendor/" end + + #SimpleCov.coverage_dir 'coverage/' + all_files = Dir['**/*.rb'] + base_result = {} + all_files.each do |file| + absolute = File::expand_path(file) + lines = File.readlines(absolute, :encoding => 'UTF-8') + base_result[absolute] = lines.map do |l| + l.strip! + l.empty? || l =~ /^end$/ || l[0] == '#' ? nil : 0 + end + end + + SimpleCov.at_exit do + coverage_result = Coverage.result + covered_files = coverage_result.keys + covered_files.each do |covered_file| + base_result.delete(covered_file) + end + merged = SimpleCov::Result.new(coverage_result).original_result.merge_resultset(base_result) + result = SimpleCov::Result.new(merged) + result.format! + end + diff --git a/web/app/assets/javascripts/fakeJamClient.js b/web/app/assets/javascripts/fakeJamClient.js index bc2d0baf6..bb53dc900 100644 --- a/web/app/assets/javascripts/fakeJamClient.js +++ b/web/app/assets/javascripts/fakeJamClient.js @@ -570,6 +570,8 @@ } function CloseRecording() {} function OnDownloadAvailable() {} + function SaveToClipboard(text) {} + function IsNativeClient() { return false; } function SessionLiveBroadcastStart(host, port, mount, sourceUser, sourcePass, preferredClientId, bitrate) { @@ -711,6 +713,12 @@ this.CloseRecording = CloseRecording; this.OnDownloadAvailable = OnDownloadAvailable; + // Clipboard + this.SaveToClipboard = SaveToClipboard; + + // Capabilities + this.IsNativeClient = IsNativeClient; + // Broadcasting this.SessionLiveBroadcastStart = SessionLiveBroadcastStart; this.SessionLiveBroadcastStop = SessionLiveBroadcastStop; diff --git a/web/app/assets/javascripts/shareDialog.js b/web/app/assets/javascripts/shareDialog.js index a8a26d4e0..af80eca98 100644 --- a/web/app/assets/javascripts/shareDialog.js +++ b/web/app/assets/javascripts/shareDialog.js @@ -338,14 +338,6 @@ return false; }) - /* - $("#btn-share-copy").zclip({ - path: 'zeroclipboard.swf', - copy: function() { - // console.log("copied " + $(".link-contents").text()); - return "TEXT"; - } - });*/ } function showDialog() { @@ -463,13 +455,28 @@ } function afterShow() { - $("#btn-share-copy").clipboard({ + if(context.JK.hasFlash()) { + $("#btn-share-copy").clipboard({ path: '/assets/jquery.clipboard.swf', copy: function() { - // Return text in closest element (useful when you have multiple boxes that can be copied) - return $(".link-contents").text(); + // Return text in closest element (useful when you have multiple boxes that can be copied) + return $(".link-contents").text(); } - }); + }); + } + else { + if(context.jamClient) { + // uses bridge call to ultimately access QClipboard + $("#btn-share-copy").unbind('click').click(function() { + context.jamClient.SaveToClipboard($(".link-contents").text()); + return false; + }) + } + else { + console.log("no copy-to-clipboard capabilities") + } + + } } function afterHide() { diff --git a/web/app/assets/javascripts/utils.js b/web/app/assets/javascripts/utils.js index 8db5501d2..9497825ce 100644 --- a/web/app/assets/javascripts/utils.js +++ b/web/app/assets/javascripts/utils.js @@ -479,6 +479,21 @@ } $item.easyDropDown({nativeTouch: !gon.isNativeClient && gon.global.env != "test"}); }) + } + + context.JK.hasFlash = function() { + var hasFlash = false; + + if(!context.jamClient || !context.jamClient.IsNativeClient()) { + try { + var fo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash'); + if(fo) hasFlash = true; + }catch(e){ + if(navigator.mimeTypes ["application/x-shockwave-flash"] != undefined) hasFlash = true; + } + } + + return hasFlash; }