From 8752bd4966f130402493145ca45c52ef3016463c Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 22 Dec 2015 12:27:51 -0800 Subject: [PATCH] Disable live previews on mobile Summary: Fixes T1895. Now that we have on-demand prviews, we can use them on mobile. On mobile: - don't show live previews; - only save drafts every 10 seconds. Also, show fewer remarkup buttons on mobile to try to make sure the more important ones (preview, e.g.) fit. Test Plan: - Made window narrower and wider to trigger preview/no-preview behavior. - Used DarkConsole to verify request rate. Reviewers: chad Reviewed By: chad Maniphest Tasks: T1895 Differential Revision: https://secure.phabricator.com/D14856 --- resources/celerity/map.php | 26 +++++++++---------- .../control/PhabricatorRemarkupControl.php | 14 ++++++++++ webroot/rsrc/css/core/remarkup.css | 4 +++ .../transactions/behavior-comment-actions.js | 22 ++++++++++++++++ 4 files changed, 53 insertions(+), 13 deletions(-) diff --git a/resources/celerity/map.php b/resources/celerity/map.php index cc3db1adb6..42644ef072 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -7,7 +7,7 @@ */ return array( 'names' => array( - 'core.pkg.css' => '1a2d5480', + 'core.pkg.css' => '357b84b0', 'core.pkg.js' => 'cf262309', 'darkconsole.pkg.js' => 'e7393ebb', 'differential.pkg.css' => '2de124c9', @@ -104,7 +104,7 @@ return array( 'rsrc/css/application/tokens/tokens.css' => '3d0f239e', 'rsrc/css/application/uiexample/example.css' => '528b19de', 'rsrc/css/core/core.css' => 'a76cefc9', - 'rsrc/css/core/remarkup.css' => '72024fc6', + 'rsrc/css/core/remarkup.css' => '7afb543c', 'rsrc/css/core/syntax.css' => '9fd11da8', 'rsrc/css/core/z-index.css' => '57ddcaa2', 'rsrc/css/diviner/diviner-shared.css' => 'aa3656aa', @@ -427,7 +427,7 @@ return array( 'rsrc/js/application/repository/repository-crossreference.js' => 'e5339c43', 'rsrc/js/application/search/behavior-reorder-queries.js' => 'e9581f08', 'rsrc/js/application/slowvote/behavior-slowvote-embed.js' => '887ad43f', - 'rsrc/js/application/transactions/behavior-comment-actions.js' => 'bb0d2d0c', + 'rsrc/js/application/transactions/behavior-comment-actions.js' => 'd885b622', 'rsrc/js/application/transactions/behavior-reorder-configs.js' => 'd7a74243', 'rsrc/js/application/transactions/behavior-reorder-fields.js' => 'b59e1e96', 'rsrc/js/application/transactions/behavior-show-older-transactions.js' => 'dbbf48b6', @@ -572,7 +572,7 @@ return array( 'javelin-behavior-audit-preview' => 'd835b03a', 'javelin-behavior-bulk-job-reload' => 'edf8a145', 'javelin-behavior-choose-control' => 'dfaafb14', - 'javelin-behavior-comment-actions' => 'bb0d2d0c', + 'javelin-behavior-comment-actions' => 'd885b622', 'javelin-behavior-config-reorder-fields' => 'b6993408', 'javelin-behavior-conpherence-drag-and-drop-photo' => 'cf86d16a', 'javelin-behavior-conpherence-menu' => '1d45c74d', @@ -759,7 +759,7 @@ return array( 'phabricator-object-selector-css' => '85ee8ce6', 'phabricator-phtize' => 'd254d646', 'phabricator-prefab' => '666c80c5', - 'phabricator-remarkup-css' => '72024fc6', + 'phabricator-remarkup-css' => '7afb543c', 'phabricator-search-results-css' => '7dea472c', 'phabricator-shaped-request' => '7cbe244b', 'phabricator-side-menu-view-css' => 'bec2458e', @@ -1740,14 +1740,6 @@ return array( 'javelin-workflow', 'phabricator-draggable-list', ), - 'bb0d2d0c' => array( - 'javelin-behavior', - 'javelin-stratcom', - 'javelin-workflow', - 'javelin-dom', - 'phuix-form-control-view', - 'phuix-icon-view', - ), 'bd4c8dca' => array( 'javelin-install', 'javelin-util', @@ -1870,6 +1862,14 @@ return array( 'javelin-util', 'phabricator-shaped-request', ), + 'd885b622' => array( + 'javelin-behavior', + 'javelin-stratcom', + 'javelin-workflow', + 'javelin-dom', + 'phuix-form-control-view', + 'phuix-icon-view', + ), 'dbbf48b6' => array( 'javelin-behavior', 'javelin-stratcom', diff --git a/src/view/form/control/PhabricatorRemarkupControl.php b/src/view/form/control/PhabricatorRemarkupControl.php index c035becbbe..be989d8a5c 100644 --- a/src/view/form/control/PhabricatorRemarkupControl.php +++ b/src/view/form/control/PhabricatorRemarkupControl.php @@ -65,33 +65,43 @@ final class PhabricatorRemarkupControl extends AphrontFormTextAreaControl { $actions = array( 'fa-bold' => array( 'tip' => pht('Bold'), + 'nodevice' => true, ), 'fa-italic' => array( 'tip' => pht('Italics'), + 'nodevice' => true, ), 'fa-text-width' => array( 'tip' => pht('Monospaced'), + 'nodevice' => true, ), 'fa-link' => array( 'tip' => pht('Link'), + 'nodevice' => true, ), array( 'spacer' => true, + 'nodevice' => true, ), 'fa-list-ul' => array( 'tip' => pht('Bulleted List'), + 'nodevice' => true, ), 'fa-list-ol' => array( 'tip' => pht('Numbered List'), + 'nodevice' => true, ), 'fa-code' => array( 'tip' => pht('Code Block'), + 'nodevice' => true, ), 'fa-quote-right' => array( 'tip' => pht('Quote'), + 'nodevice' => true, ), 'fa-table' => array( 'tip' => pht('Table'), + 'nodevice' => true, ), 'fa-cloud-upload' => array( 'tip' => pht('Upload File'), @@ -155,6 +165,10 @@ final class PhabricatorRemarkupControl extends AphrontFormTextAreaControl { $classes[] = 'remarkup-assist-right'; } + if (idx($spec, 'nodevice')) { + $classes[] = 'remarkup-assist-nodevice'; + } + if (idx($spec, 'spacer')) { $classes[] = 'remarkup-assist-separator'; $buttons[] = phutil_tag( diff --git a/webroot/rsrc/css/core/remarkup.css b/webroot/rsrc/css/core/remarkup.css index b94a5ffc2c..98d6876e1d 100644 --- a/webroot/rsrc/css/core/remarkup.css +++ b/webroot/rsrc/css/core/remarkup.css @@ -556,3 +556,7 @@ var.remarkup-assist-textarea { .remarkup-assist-button.preview-active:hover .phui-icon-view { color: {$lightsky}; } + +.device .remarkup-assist-nodevice { + display: none; +} diff --git a/webroot/rsrc/js/application/transactions/behavior-comment-actions.js b/webroot/rsrc/js/application/transactions/behavior-comment-actions.js index c121111077..6cf0dd1740 100644 --- a/webroot/rsrc/js/application/transactions/behavior-comment-actions.js +++ b/webroot/rsrc/js/application/transactions/behavior-comment-actions.js @@ -115,6 +115,10 @@ JX.behavior('comment-actions', function(config) { } function onresponse(response) { + if (JX.Device.getDevice() != 'desktop') { + return; + } + var panel = JX.$(config.panelID); if (!response.xactions.length) { JX.DOM.hide(panel); @@ -152,7 +156,25 @@ JX.behavior('comment-actions', function(config) { JX.DOM.listen(form_node, 'shouldRefresh', null, always_trigger); request.start(); + + var ondevicechange = function() { + var panel = JX.$(config.panelID); + if (JX.Device.getDevice() == 'desktop') { + request.setRateLimit(500); + always_trigger(); + } else { + // On mobile, don't show live previews and only save drafts every + // 10 seconds. + request.setRateLimit(10000); + JX.DOM.hide(panel); + } + }; + + ondevicechange(); + + JX.Stratcom.listen('phabricator-device-change', null, ondevicechange); } restore_draft_actions(config.drafts || []); + });