Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
31
gaia/dev_apps/uitest/js/API/shareimage.js
Executable file
31
gaia/dev_apps/uitest/js/API/shareimage.js
Executable file
|
|
@ -0,0 +1,31 @@
|
|||
var shareImage = document.querySelector("#share-image"),
|
||||
imgToShare = document.querySelector("#image-to-share");
|
||||
if (shareImage && imgToShare) {
|
||||
shareImage.onclick = function () {
|
||||
if(imgToShare.naturalWidth > 0) {
|
||||
// Create dummy canvas
|
||||
var blobCanvas = document.createElement("canvas");
|
||||
blobCanvas.width = imgToShare.width;
|
||||
blobCanvas.height = imgToShare.height;
|
||||
|
||||
// Get context and draw image
|
||||
var blobCanvasContext = blobCanvas.getContext("2d");
|
||||
blobCanvasContext.drawImage(imgToShare, 0, 0);
|
||||
|
||||
// Export to blob and share through a Web Activitiy
|
||||
blobCanvas.toBlob(function (blob) {
|
||||
var sharingImage = new MozActivity({
|
||||
name: "share",
|
||||
data: {
|
||||
type: "image/*",
|
||||
number: 1,
|
||||
blobs: [blob]
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
else {
|
||||
alert("Image failed to load, can't be shared");
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue