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
5
assets/webapps/wallpaper.gaiamobile.org/js/pick.js
Normal file
5
assets/webapps/wallpaper.gaiamobile.org/js/pick.js
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
;'use strict';var Wallpaper={thumbnailScale:3/8,wallpapersUrl:'/resources/list.json',init:function wallpaper_init(){var self=this;if(navigator.mozSetMessageHandler){navigator.mozSetMessageHandler('activity',function handler(request){var activityName=request.source.name;if(activityName!=='pick'){return;}
|
||||
self.startPick(request);});}
|
||||
this.header=document.getElementById('header');this.wallpapers=document.getElementById('wallpapers');this.generateWallpaperList();},generateWallpaperList:function wallpaper_generateWallpaperList(cb){var self=this;var sampleSize=Downsample.sizeNoMoreThan(this.thumbnailScale);LazyLoader.getJSON(this.wallpapersUrl).then(function(json){self.wallpapers.innerHTML='';json.forEach(function(wallpaper){var fileName='resources/'+wallpaper;var imgNode=document.createElement('img');imgNode.alt='';imgNode.classList.add('wallpaper');imgNode.dataset.filename=fileName;imgNode.src=fileName+sampleSize;self.wallpapers.appendChild(imgNode);});if(cb){cb();}});},startPick:function wallpaper_startPick(request){this.pickActivity=request;this.wallpapers.addEventListener('click',this.pickWallpaper.bind(this));this.header.addEventListener('action',this.cancelPick.bind(this));},pickWallpaper:function wallpaper_pickWallpaper(e){var src=e.target.dataset.filename;if(src===''){return;}
|
||||
if(!this.pickActivity){return;}
|
||||
var img=new Image();img.src=src;var self=this;img.onload=function(){var canvas=document.createElement('canvas');var context=canvas.getContext('2d');canvas.width=img.width;canvas.height=img.height;context.drawImage(img,0,0);canvas.toBlob(function(blob){self.pickActivity.postResult({type:'image/jpeg',blob:blob,name:src},'image/jpeg');self.endPick();},'image/jpeg');};},cancelPick:function wallpaper_cancelPick(){this.pickActivity.postError('cancelled');this.endPick();},endPick:function wallpaper_endPick(){this.pickActivity=null;this.header.removeEventListener('action',this.cancelPick);this.wallpapers.removeEventListener('click',this.pickWallpaper);}};window.addEventListener('load',function pick(){window.removeEventListener('load',pick);Wallpaper.init();});
|
||||
Loading…
Reference in a new issue