[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 /** 2 * @provides javelin-behavior-global-drag-and-drop 3 * @requires javelin-behavior 4 * javelin-dom 5 * javelin-uri 6 * javelin-mask 7 * phabricator-drag-and-drop-file-upload 8 */ 9 10 JX.behavior('global-drag-and-drop', function(config) { 11 if (!JX.PhabricatorDragAndDropFileUpload.isSupported()) { 12 return; 13 } 14 15 var pending = 0; 16 var files = []; 17 var errors = false; 18 19 if (config.ifSupported) { 20 JX.$(config.ifSupported).style.display = ''; 21 } 22 23 var drop = new JX.PhabricatorDragAndDropFileUpload(document.documentElement) 24 .setURI(config.uploadURI) 25 .setViewPolicy(config.viewPolicy); 26 27 drop.listen('didBeginDrag', function() { 28 JX.Mask.show(); 29 JX.DOM.show(JX.$(config.instructions)); 30 }); 31 32 drop.listen('didEndDrag', function() { 33 JX.Mask.hide(); 34 JX.DOM.hide(JX.$(config.instructions)); 35 }); 36 37 drop.listen('willUpload', function() { 38 pending++; 39 }); 40 41 drop.listen('didUpload', function(f) { 42 files.push(f); 43 44 pending--; 45 if (pending === 0 && !errors) { 46 // If whatever the user dropped in has finished uploading, send them to 47 // their uploads. 48 var uri; 49 uri = JX.$U(config.browseURI); 50 var ids = []; 51 for (var ii = 0; ii < files.length; ii++) { 52 ids.push(files[ii].getID()); 53 } 54 uri.setQueryParam('h', ids.join(',')); 55 56 files = []; 57 58 uri.go(); 59 } 60 }); 61 62 drop.listen('didError', function() { 63 pending--; 64 errors = true; 65 }); 66 67 drop.start(); 68 });
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |