[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 /** 2 * @provides javelin-behavior-dashboard-move-panels 3 * @requires javelin-behavior 4 * javelin-dom 5 * javelin-util 6 * javelin-stratcom 7 * javelin-workflow 8 * phabricator-draggable-list 9 */ 10 11 JX.behavior('dashboard-move-panels', function(config) { 12 13 var itemSigil = 'dashboard-panel'; 14 15 function finditems(col) { 16 return JX.DOM.scry(col, 'div', itemSigil); 17 } 18 19 function markcolempty(col, toggle) { 20 JX.DOM.alterClass(col, 'dashboard-column-empty', toggle); 21 } 22 23 function onupdate(col) { 24 markcolempty(col, !this.findItems().length); 25 } 26 27 function onresponse(response, item, list) { 28 list.unlock(); 29 JX.DOM.alterClass(item, 'drag-sending', false); 30 } 31 32 function ondrop(list, item, after) { 33 list.lock(); 34 JX.DOM.alterClass(item, 'drag-sending', true); 35 36 var item_phid = JX.Stratcom.getData(item).objectPHID; 37 var data = { 38 objectPHID: item_phid, 39 columnID: JX.Stratcom.getData(list.getRootNode()).columnID 40 }; 41 42 var after_phid = null; 43 var items = finditems(list.getRootNode()); 44 if (after) { 45 after_phid = JX.Stratcom.getData(after).objectPHID; 46 data.afterPHID = after_phid; 47 } 48 var ii; 49 var ii_item; 50 var ii_item_phid; 51 var ii_prev_item_phid = null; 52 var before_phid = null; 53 for (ii = 0; ii < items.length; ii++) { 54 ii_item = items[ii]; 55 ii_item_phid = JX.Stratcom.getData(ii_item).objectPHID; 56 if (ii_item_phid == item_phid) { 57 // skip the item we just dropped 58 continue; 59 } 60 // note this handles when there is no after phid - we are at the top of 61 // the list - quite nicely 62 if (ii_prev_item_phid == after_phid) { 63 before_phid = ii_item_phid; 64 break; 65 } 66 ii_prev_item_phid = ii_item_phid; 67 } 68 if (before_phid) { 69 data.beforePHID = before_phid; 70 } 71 72 var workflow = new JX.Workflow(config.moveURI, data) 73 .setHandler(function(response) { 74 onresponse(response, item, list); 75 }); 76 77 workflow.start(); 78 } 79 80 var lists = []; 81 var ii; 82 var cols = JX.DOM.scry(JX.$(config.dashboardID), 'div', 'dashboard-column'); 83 var col = null; 84 85 for (ii = 0; ii < cols.length; ii++) { 86 col = cols[ii]; 87 var list = new JX.DraggableList(itemSigil, col) 88 .setFindItemsHandler(JX.bind(null, finditems, col)); 89 90 list.listen('didSend', JX.bind(list, onupdate, col)); 91 list.listen('didReceive', JX.bind(list, onupdate, col)); 92 93 list.listen('didDrop', JX.bind(null, ondrop, list)); 94 95 lists.push(list); 96 markcolempty(col, finditems(col).length === 0); 97 } 98 99 for (ii = 0; ii < lists.length; ii++) { 100 lists[ii].setGroup(lists); 101 } 102 103 });
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 |