@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Help PROFESSIONAL SOFTWARE ENGINEERS copy text to their clipboard

Summary: Ref T12780. I'd like 18,000 GitHub stars now please thank you

Test Plan: this feature is awful

Reviewers: chad

Reviewed By: chad

Subscribers: cspeckmim

Maniphest Tasks: T12780

Differential Revision: https://secure.phabricator.com/D18053

+105 -11
+10 -3
resources/celerity/map.php
··· 9 9 'names' => array( 10 10 'conpherence.pkg.css' => 'ff161f2d', 11 11 'conpherence.pkg.js' => 'b5b51108', 12 - 'core.pkg.css' => 'c56695d0', 12 + 'core.pkg.css' => '0c6e11ed', 13 13 'core.pkg.js' => '1475bd91', 14 14 'darkconsole.pkg.js' => '1f9a31bc', 15 15 'differential.pkg.css' => 'a2755617', ··· 114 114 'rsrc/css/application/slowvote/slowvote.css' => 'a94b7230', 115 115 'rsrc/css/application/tokens/tokens.css' => '3d0f239e', 116 116 'rsrc/css/application/uiexample/example.css' => '528b19de', 117 - 'rsrc/css/core/core.css' => '9f4cb463', 117 + 'rsrc/css/core/core.css' => '23beb330', 118 118 'rsrc/css/core/remarkup.css' => 'd1a5e11e', 119 119 'rsrc/css/core/syntax.css' => 'cae95e89', 120 120 'rsrc/css/core/z-index.css' => '9d8f7c4b', ··· 474 474 'rsrc/js/core/behavior-autofocus.js' => '7319e029', 475 475 'rsrc/js/core/behavior-badge-view.js' => '8ff5e24c', 476 476 'rsrc/js/core/behavior-choose-control.js' => '327a00d1', 477 + 'rsrc/js/core/behavior-copy.js' => 'b0b8f86d', 477 478 'rsrc/js/core/behavior-detect-timezone.js' => '4c193c96', 478 479 'rsrc/js/core/behavior-device.js' => 'bb1dd507', 479 480 'rsrc/js/core/behavior-drag-and-drop-textarea.js' => '484a6e22', ··· 644 645 'javelin-behavior-passphrase-credential-control' => '3cb0b2fc', 645 646 'javelin-behavior-phabricator-active-nav' => 'e379b58e', 646 647 'javelin-behavior-phabricator-autofocus' => '7319e029', 648 + 'javelin-behavior-phabricator-clipboard-copy' => 'b0b8f86d', 647 649 'javelin-behavior-phabricator-file-tree' => '88236f00', 648 650 'javelin-behavior-phabricator-gesture' => '3ab51e2c', 649 651 'javelin-behavior-phabricator-gesture-example' => '558829c2', ··· 763 765 'phabricator-busy' => '59a7976a', 764 766 'phabricator-chatlog-css' => 'd295b020', 765 767 'phabricator-content-source-view-css' => '4b8b05d4', 766 - 'phabricator-core-css' => '9f4cb463', 768 + 'phabricator-core-css' => '23beb330', 767 769 'phabricator-countdown-css' => '16c52f5c', 768 770 'phabricator-darklog' => 'c8e1ffe3', 769 771 'phabricator-darkmessage' => 'c48cccdd', ··· 1737 1739 'javelin-stratcom', 1738 1740 'javelin-dom', 1739 1741 'phuix-dropdown-menu', 1742 + ), 1743 + 'b0b8f86d' => array( 1744 + 'javelin-behavior', 1745 + 'javelin-dom', 1746 + 'javelin-stratcom', 1740 1747 ), 1741 1748 'b23b49e6' => array( 1742 1749 'javelin-behavior',
+39 -8
src/applications/uiexample/examples/PHUIButtonExample.php
··· 106 106 107 107 $column = array(); 108 108 $icons = array( 109 - 'Comment' => 'fa-comment', 110 - 'Give Token' => 'fa-trophy', 111 - 'Reverse Time' => 'fa-clock-o', 112 - 'Implode Earth' => 'fa-exclamation-triangle red', 109 + array( 110 + 'text' => pht('Comment'), 111 + 'icon' => 'fa-comment', 112 + ), 113 + array( 114 + 'text' => pht('Give Token'), 115 + 'icon' => 'fa-trophy', 116 + ), 117 + array( 118 + 'text' => pht('Reverse Time'), 119 + 'icon' => 'fa-clock-o', 120 + ), 121 + array( 122 + 'text' => pht('Implode Earth'), 123 + 'icon' => 'fa-exclamation-triangle', 124 + ), 125 + array( 126 + 'text' => pht('Copy "Quack" to Clipboard'), 127 + 'icon' => 'fa-clipboard', 128 + 'copy' => pht('Quack'), 129 + ), 113 130 ); 114 - foreach ($icons as $text => $icon) { 115 - $column[] = id(new PHUIButtonView()) 131 + foreach ($icons as $text => $spec) { 132 + $button = id(new PHUIButtonView()) 116 133 ->setTag('a') 117 134 ->setColor(PHUIButtonView::GREY) 118 - ->setIcon($icon) 119 - ->setText($text) 135 + ->setIcon(idx($spec, 'icon')) 136 + ->setText(idx($spec, 'text')) 120 137 ->addClass(PHUI::MARGIN_SMALL_RIGHT); 138 + 139 + $copy = idx($spec, 'copy'); 140 + if ($copy !== null) { 141 + Javelin::initBehavior('phabricator-clipboard-copy'); 142 + 143 + $button->addClass('clipboard-copy'); 144 + $button->addSigil('clipboard-copy'); 145 + $button->setMetadata( 146 + array( 147 + 'text' => $copy, 148 + )); 149 + } 150 + 151 + $column[] = $button; 121 152 } 122 153 123 154 $layout3 = id(new AphrontMultiColumnView())
+13
webroot/rsrc/css/core/core.css
··· 173 173 height: 2px; 174 174 background: {$sky}; 175 175 } 176 + 177 + .clipboard-copy { 178 + visibility: hidden; 179 + } 180 + 181 + .supports-clipboard .clipboard-copy { 182 + visibility: visible; 183 + } 184 + 185 + .clipboard-buffer { 186 + position: absolute; 187 + left: -9999px; 188 + }
+43
webroot/rsrc/js/core/behavior-copy.js
··· 1 + /** 2 + * @provides javelin-behavior-phabricator-clipboard-copy 3 + * @requires javelin-behavior 4 + * javelin-dom 5 + * javelin-stratcom 6 + * @javelin 7 + */ 8 + 9 + JX.behavior('phabricator-clipboard-copy', function() { 10 + 11 + if (!document.queryCommandSupported) { 12 + return; 13 + } 14 + 15 + if (!document.queryCommandSupported('copy')) { 16 + return; 17 + } 18 + 19 + JX.DOM.alterClass(document.body, 'supports-clipboard', true); 20 + 21 + JX.Stratcom.listen('click', 'clipboard-copy', function(e) { 22 + e.kill(); 23 + 24 + var data = e.getNodeData('clipboard-copy'); 25 + var attr = { 26 + value: data.text || '', 27 + className: 'clipboard-buffer' 28 + }; 29 + 30 + var node = JX.$N('textarea', attr); 31 + document.body.appendChild(node); 32 + 33 + try { 34 + node.select(); 35 + document.execCommand('copy'); 36 + } catch (ignored) { 37 + // Ignore any errors we hit. 38 + } 39 + 40 + JX.DOM.remove(node); 41 + }); 42 + 43 + });