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/download.gaiamobile.org/js/pick.js
Normal file
5
assets/webapps/download.gaiamobile.org/js/pick.js
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
;'use strict';(function(exports){const CHUNK_SIZE=10;function DownloadPicker(){this.header=document.querySelector('#header');this.list=document.querySelector('#downloads ul');this.downloads=Object.create(null);navigator.mozSetMessageHandler('activity',this.handleActivity.bind(this));}
|
||||
DownloadPicker.prototype={handleActivity:function(activity){switch(activity.source.name){case'pick':this.activity=activity;this.attachActionHandlers();this.renderList();break;default:activity.postError('name not supported');}},renderList:function(){DownloadStore.getAll().onsuccess=(event)=>{var result=event.target.result;if(!Array.isArray(result)){result=[result];}
|
||||
var items=result.reverse();var total=document.body.dataset.downloads=items.length;this.renderFragment(items,0,total);};},renderFragment:function(items,from,total){var target=document.createDocumentFragment();var idx=from;for(;idx<from+CHUNK_SIZE&&idx<total;idx++){this.appendDownload(items[idx],target);}
|
||||
this.list.appendChild(target);(idx<total)&&setTimeout(()=>{this.renderFragment(items,idx,total);});},appendDownload:function(download,target){var id=download.id;if(this.downloads[id]){return;}
|
||||
this.downloads[id]=download;var item=document.createElement('li');item.dataset.id=id;var pFileName=document.createElement('p');pFileName.classList.add('fileName');pFileName.textContent=DownloadFormatter.getFileName(download);var pInfo=document.createElement('p');pInfo.classList.add('info');DownloadFormatter.getDate(download,(date)=>{DownloadFormatter.getTotalSize(download).then(totalSize=>{navigator.mozL10n.setAttributes(pInfo,'summary',{date:date,status:totalSize});});});item.appendChild(pFileName);item.appendChild(pInfo);target.appendChild(item);},attachActionHandlers:function(){this.header.addEventListener('action',()=>{this.activity.postError('cancelled');});this.list.addEventListener('click',(event)=>{var download=this.downloads[event.target.dataset.id];download&&this.pick(download);});},pick:function(download){LazyLoader.load(['shared/js/mime_mapper.js','shared/js/download/download_helper.js'],()=>{var req=DownloadHelper.info(download);req.onsuccess=(event)=>{this.activity.postResult(event.target.result);};req.onerror=(event)=>{DownloadHelper.handlerError(req.error,download);};});}};exports.downloadPicker=new DownloadPicker();}(window));
|
||||
Loading…
Reference in a new issue