1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 16:52:41 +01:00

Decrease fragility of conpherence-pontificate behavior

Summary:
Currently, this behavior binds a ton of IDs. This makes the behavior fragile: if it is invoked on a page without all the right elements, some `JX.$()` tends to explode.

Instead, don't assume anything is present on the page. This allows the behavior to be invoked on other pages (like the "New Conpherence" page) or pages without some elements (like some future thread-only mobile view) without creating JS errors.

Test Plan:
Added comments, added comments with files. Viewed "New conphenrece" page.

NOTE: Control+Enter is currently broken, but this diff didn't change that behavior.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D5468
This commit is contained in:
epriestley 2013-03-31 14:41:13 -07:00
parent e9fe1f4beb
commit ef30820cf4
5 changed files with 103 additions and 204 deletions

View file

@ -448,62 +448,6 @@ celerity_register_resource_map(array(
'disk' => '/rsrc/image/menu_texture.png',
'type' => 'png',
),
'/rsrc/image/people/harding.png' =>
array(
'hash' => '818b035ace2c480aa8df7b7f11cef58b',
'uri' => '/res/818b035a/rsrc/image/people/harding.png',
'disk' => '/rsrc/image/people/harding.png',
'type' => 'png',
),
'/rsrc/image/people/jefferson.png' =>
array(
'hash' => '55fe807ff02f9320e595fb59442e2038',
'uri' => '/res/55fe807f/rsrc/image/people/jefferson.png',
'disk' => '/rsrc/image/people/jefferson.png',
'type' => 'png',
),
'/rsrc/image/people/lincoln.png' =>
array(
'hash' => '2363337947ab52fd5fda79e4a004e930',
'uri' => '/res/23633379/rsrc/image/people/lincoln.png',
'disk' => '/rsrc/image/people/lincoln.png',
'type' => 'png',
),
'/rsrc/image/people/mckinley.png' =>
array(
'hash' => '0b7b05dd47c49a0874670e5e8200bba8',
'uri' => '/res/0b7b05dd/rsrc/image/people/mckinley.png',
'disk' => '/rsrc/image/people/mckinley.png',
'type' => 'png',
),
'/rsrc/image/people/taft.png' =>
array(
'hash' => 'f3e47d45b59b0b009fd536dabae9a151',
'uri' => '/res/f3e47d45/rsrc/image/people/taft.png',
'disk' => '/rsrc/image/people/taft.png',
'type' => 'png',
),
'/rsrc/image/people/washington.png' =>
array(
'hash' => '01412761cab769f7993d69eba986d949',
'uri' => '/res/01412761/rsrc/image/people/washington.png',
'disk' => '/rsrc/image/people/washington.png',
'type' => 'png',
),
'/rsrc/image/phrequent_active.png' =>
array(
'hash' => '716cddc08630eaa33934b2008723cac0',
'uri' => '/res/716cddc0/rsrc/image/phrequent_active.png',
'disk' => '/rsrc/image/phrequent_active.png',
'type' => 'png',
),
'/rsrc/image/phrequent_inactive.png' =>
array(
'hash' => 'f9099683873c01c5de1dc6650bd668fe',
'uri' => '/res/f9099683/rsrc/image/phrequent_inactive.png',
'disk' => '/rsrc/image/phrequent_inactive.png',
'type' => 'png',
),
'/rsrc/image/search.png' =>
array(
'hash' => 'ff7da044e6f923b8f569dec11f97e5e5',
@ -651,13 +595,6 @@ celerity_register_resource_map(array(
'disk' => '/rsrc/image/texture/grip.png',
'type' => 'png',
),
'/rsrc/image/texture/panel-header-gradient.png' =>
array(
'hash' => 'ad9204dd3ef5b12b645d80677d8ccead',
'uri' => '/res/ad9204dd/rsrc/image/texture/panel-header-gradient.png',
'disk' => '/rsrc/image/texture/panel-header-gradient.png',
'type' => 'png',
),
'/rsrc/image/texture/pholio-background.gif' =>
array(
'hash' => 'cf4561af116edf393dc583e5119fb412',
@ -1203,7 +1140,7 @@ celerity_register_resource_map(array(
),
'javelin-behavior-aphront-form-disable-on-submit' =>
array(
'uri' => '/res/f5a60aec/rsrc/js/application/core/behavior-form.js',
'uri' => '/res/b5052cd0/rsrc/js/application/core/behavior-form.js',
'type' => 'js',
'requires' =>
array(
@ -1269,7 +1206,7 @@ celerity_register_resource_map(array(
),
'javelin-behavior-conpherence-pontificate' =>
array(
'uri' => '/res/abc4d947/rsrc/js/application/conpherence/behavior-pontificate.js',
'uri' => '/res/e5a0ce39/rsrc/js/application/conpherence/behavior-pontificate.js',
'type' => 'js',
'requires' =>
array(
@ -1277,6 +1214,7 @@ celerity_register_resource_map(array(
1 => 'javelin-dom',
2 => 'javelin-util',
3 => 'javelin-workflow',
4 => 'javelin-stratcom',
),
'disk' => '/rsrc/js/application/conpherence/behavior-pontificate.js',
),
@ -2878,7 +2816,7 @@ celerity_register_resource_map(array(
),
'phabricator-drag-and-drop-file-upload' =>
array(
'uri' => '/res/1daa63d1/rsrc/js/application/core/DragAndDropFileUpload.js',
'uri' => '/res/ce71f19a/rsrc/js/application/core/DragAndDropFileUpload.js',
'type' => 'js',
'requires' =>
array(
@ -3441,24 +3379,6 @@ celerity_register_resource_map(array(
),
'disk' => '/rsrc/js/application/uiexample/ReactorSendPropertiesExample.js',
),
'phabricator-workboard-view-css' =>
array(
'uri' => '/res/b70667c6/rsrc/css/layout/phabricator-workboard-view.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/layout/phabricator-workboard-view.css',
),
'phabricator-workpanel-view-css' =>
array(
'uri' => '/res/d2eea288/rsrc/css/layout/phabricator-workpanel-view.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/layout/phabricator-workpanel-view.css',
),
'phabricator-zindex-css' =>
array(
'uri' => '/res/fcbf82ad/rsrc/css/core/z-index.css',
@ -3495,15 +3415,6 @@ celerity_register_resource_map(array(
),
'disk' => '/rsrc/css/application/pholio/pholio-inline-comments.css',
),
'phrequent-css' =>
array(
'uri' => '/res/9d6f3eb7/rsrc/css/application/phrequent/phrequent.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/application/phrequent/phrequent.css',
),
'phriction-document-css' =>
array(
'uri' => '/res/e71e4a67/rsrc/css/application/phriction/phriction-document-css.css',
@ -3675,15 +3586,6 @@ celerity_register_resource_map(array(
),
'disk' => '/rsrc/css/application/config/setup-issue.css',
),
'spacing-css' =>
array(
'uri' => '/res/59e4c9b1/rsrc/css/core/spacing.css',
'type' => 'css',
'requires' =>
array(
),
'disk' => '/rsrc/css/core/spacing.css',
),
'sprite-apps-css' =>
array(
'uri' => '/res/c53973fc/rsrc/css/sprite-apps.css',
@ -3849,7 +3751,7 @@ celerity_register_resource_map(array(
'uri' => '/res/pkg/4fc2a8f9/core.pkg.css',
'type' => 'css',
),
'def4c982' =>
'95ceba95' =>
array(
'name' => 'core.pkg.js',
'symbols' =>
@ -3890,7 +3792,7 @@ celerity_register_resource_map(array(
33 => 'javelin-behavior-global-drag-and-drop',
34 => 'javelin-behavior-phabricator-reveal-content',
),
'uri' => '/res/pkg/def4c982/core.pkg.js',
'uri' => '/res/pkg/95ceba95/core.pkg.js',
'type' => 'js',
),
'dca4a03d' =>
@ -3926,7 +3828,7 @@ celerity_register_resource_map(array(
'uri' => '/res/pkg/8aaacd1b/differential.pkg.css',
'type' => 'css',
),
'67ea27d0' =>
'322728f3' =>
array(
'name' => 'differential.pkg.js',
'symbols' =>
@ -3952,7 +3854,7 @@ celerity_register_resource_map(array(
18 => 'javelin-behavior-differential-toggle-files',
19 => 'javelin-behavior-differential-user-select',
),
'uri' => '/res/pkg/67ea27d0/differential.pkg.js',
'uri' => '/res/pkg/322728f3/differential.pkg.js',
'type' => 'js',
),
'c8ce2d88' =>
@ -4049,7 +3951,7 @@ celerity_register_resource_map(array(
'aphront-typeahead-control-css' => '4fc2a8f9',
'differential-changeset-view-css' => '8aaacd1b',
'differential-core-view-css' => '8aaacd1b',
'differential-inline-comment-editor' => '67ea27d0',
'differential-inline-comment-editor' => '322728f3',
'differential-local-commits-view-css' => '8aaacd1b',
'differential-results-table-css' => '8aaacd1b',
'differential-revision-add-comment-css' => '8aaacd1b',
@ -4062,58 +3964,58 @@ celerity_register_resource_map(array(
'diffusion-icons-css' => 'c8ce2d88',
'global-drag-and-drop-css' => '4fc2a8f9',
'inline-comment-summary-css' => '8aaacd1b',
'javelin-aphlict' => 'def4c982',
'javelin-aphlict' => '95ceba95',
'javelin-behavior' => 'fe22443b',
'javelin-behavior-aphlict-dropdown' => 'def4c982',
'javelin-behavior-aphlict-listen' => 'def4c982',
'javelin-behavior-aphront-basic-tokenizer' => 'def4c982',
'javelin-behavior-aphront-drag-and-drop' => '67ea27d0',
'javelin-behavior-aphront-drag-and-drop-textarea' => '67ea27d0',
'javelin-behavior-aphront-form-disable-on-submit' => 'def4c982',
'javelin-behavior-aphlict-dropdown' => '95ceba95',
'javelin-behavior-aphlict-listen' => '95ceba95',
'javelin-behavior-aphront-basic-tokenizer' => '95ceba95',
'javelin-behavior-aphront-drag-and-drop' => '322728f3',
'javelin-behavior-aphront-drag-and-drop-textarea' => '322728f3',
'javelin-behavior-aphront-form-disable-on-submit' => '95ceba95',
'javelin-behavior-audit-preview' => 'f96657b8',
'javelin-behavior-dark-console' => 'dca4a03d',
'javelin-behavior-device' => 'def4c982',
'javelin-behavior-differential-accept-with-errors' => '67ea27d0',
'javelin-behavior-differential-add-reviewers-and-ccs' => '67ea27d0',
'javelin-behavior-differential-comment-jump' => '67ea27d0',
'javelin-behavior-differential-diff-radios' => '67ea27d0',
'javelin-behavior-differential-dropdown-menus' => '67ea27d0',
'javelin-behavior-differential-edit-inline-comments' => '67ea27d0',
'javelin-behavior-differential-feedback-preview' => '67ea27d0',
'javelin-behavior-differential-keyboard-navigation' => '67ea27d0',
'javelin-behavior-differential-populate' => '67ea27d0',
'javelin-behavior-differential-show-more' => '67ea27d0',
'javelin-behavior-differential-toggle-files' => '67ea27d0',
'javelin-behavior-differential-user-select' => '67ea27d0',
'javelin-behavior-device' => '95ceba95',
'javelin-behavior-differential-accept-with-errors' => '322728f3',
'javelin-behavior-differential-add-reviewers-and-ccs' => '322728f3',
'javelin-behavior-differential-comment-jump' => '322728f3',
'javelin-behavior-differential-diff-radios' => '322728f3',
'javelin-behavior-differential-dropdown-menus' => '322728f3',
'javelin-behavior-differential-edit-inline-comments' => '322728f3',
'javelin-behavior-differential-feedback-preview' => '322728f3',
'javelin-behavior-differential-keyboard-navigation' => '322728f3',
'javelin-behavior-differential-populate' => '322728f3',
'javelin-behavior-differential-show-more' => '322728f3',
'javelin-behavior-differential-toggle-files' => '322728f3',
'javelin-behavior-differential-user-select' => '322728f3',
'javelin-behavior-diffusion-commit-graph' => 'f96657b8',
'javelin-behavior-diffusion-pull-lastmodified' => 'f96657b8',
'javelin-behavior-error-log' => 'dca4a03d',
'javelin-behavior-global-drag-and-drop' => 'def4c982',
'javelin-behavior-history-install' => 'def4c982',
'javelin-behavior-konami' => 'def4c982',
'javelin-behavior-lightbox-attachments' => 'def4c982',
'javelin-behavior-load-blame' => '67ea27d0',
'javelin-behavior-global-drag-and-drop' => '95ceba95',
'javelin-behavior-history-install' => '95ceba95',
'javelin-behavior-konami' => '95ceba95',
'javelin-behavior-lightbox-attachments' => '95ceba95',
'javelin-behavior-load-blame' => '322728f3',
'javelin-behavior-maniphest-batch-selector' => 'f85eb6d8',
'javelin-behavior-maniphest-subpriority-editor' => 'f85eb6d8',
'javelin-behavior-maniphest-transaction-controls' => 'f85eb6d8',
'javelin-behavior-maniphest-transaction-expand' => 'f85eb6d8',
'javelin-behavior-maniphest-transaction-preview' => 'f85eb6d8',
'javelin-behavior-phabricator-active-nav' => 'def4c982',
'javelin-behavior-phabricator-autofocus' => 'def4c982',
'javelin-behavior-phabricator-gesture' => 'def4c982',
'javelin-behavior-phabricator-keyboard-shortcuts' => 'def4c982',
'javelin-behavior-phabricator-nav' => 'def4c982',
'javelin-behavior-phabricator-object-selector' => '67ea27d0',
'javelin-behavior-phabricator-oncopy' => 'def4c982',
'javelin-behavior-phabricator-remarkup-assist' => 'def4c982',
'javelin-behavior-phabricator-reveal-content' => 'def4c982',
'javelin-behavior-phabricator-search-typeahead' => 'def4c982',
'javelin-behavior-phabricator-tooltips' => 'def4c982',
'javelin-behavior-phabricator-watch-anchor' => 'def4c982',
'javelin-behavior-refresh-csrf' => 'def4c982',
'javelin-behavior-repository-crossreference' => '67ea27d0',
'javelin-behavior-toggle-class' => 'def4c982',
'javelin-behavior-workflow' => 'def4c982',
'javelin-behavior-phabricator-active-nav' => '95ceba95',
'javelin-behavior-phabricator-autofocus' => '95ceba95',
'javelin-behavior-phabricator-gesture' => '95ceba95',
'javelin-behavior-phabricator-keyboard-shortcuts' => '95ceba95',
'javelin-behavior-phabricator-nav' => '95ceba95',
'javelin-behavior-phabricator-object-selector' => '322728f3',
'javelin-behavior-phabricator-oncopy' => '95ceba95',
'javelin-behavior-phabricator-remarkup-assist' => '95ceba95',
'javelin-behavior-phabricator-reveal-content' => '95ceba95',
'javelin-behavior-phabricator-search-typeahead' => '95ceba95',
'javelin-behavior-phabricator-tooltips' => '95ceba95',
'javelin-behavior-phabricator-watch-anchor' => '95ceba95',
'javelin-behavior-refresh-csrf' => '95ceba95',
'javelin-behavior-repository-crossreference' => '322728f3',
'javelin-behavior-toggle-class' => '95ceba95',
'javelin-behavior-workflow' => '95ceba95',
'javelin-dom' => 'fe22443b',
'javelin-event' => 'fe22443b',
'javelin-install' => 'fe22443b',
@ -4135,39 +4037,39 @@ celerity_register_resource_map(array(
'lightbox-attachment-css' => '4fc2a8f9',
'maniphest-task-summary-css' => '6b1fccc6',
'maniphest-transaction-detail-css' => '6b1fccc6',
'phabricator-busy' => 'def4c982',
'phabricator-busy' => '95ceba95',
'phabricator-content-source-view-css' => '8aaacd1b',
'phabricator-core-buttons-css' => '4fc2a8f9',
'phabricator-core-css' => '4fc2a8f9',
'phabricator-crumbs-view-css' => '4fc2a8f9',
'phabricator-directory-css' => '4fc2a8f9',
'phabricator-drag-and-drop-file-upload' => '67ea27d0',
'phabricator-dropdown-menu' => 'def4c982',
'phabricator-file-upload' => 'def4c982',
'phabricator-drag-and-drop-file-upload' => '322728f3',
'phabricator-dropdown-menu' => '95ceba95',
'phabricator-file-upload' => '95ceba95',
'phabricator-filetree-view-css' => '4fc2a8f9',
'phabricator-flag-css' => '4fc2a8f9',
'phabricator-form-view-css' => '4fc2a8f9',
'phabricator-header-view-css' => '4fc2a8f9',
'phabricator-jump-nav' => '4fc2a8f9',
'phabricator-keyboard-shortcut' => 'def4c982',
'phabricator-keyboard-shortcut-manager' => 'def4c982',
'phabricator-keyboard-shortcut' => '95ceba95',
'phabricator-keyboard-shortcut-manager' => '95ceba95',
'phabricator-main-menu-view' => '4fc2a8f9',
'phabricator-menu-item' => 'def4c982',
'phabricator-menu-item' => '95ceba95',
'phabricator-nav-view-css' => '4fc2a8f9',
'phabricator-notification' => 'def4c982',
'phabricator-notification' => '95ceba95',
'phabricator-notification-css' => '4fc2a8f9',
'phabricator-notification-menu-css' => '4fc2a8f9',
'phabricator-object-item-list-view-css' => '4fc2a8f9',
'phabricator-object-selector-css' => '8aaacd1b',
'phabricator-paste-file-upload' => 'def4c982',
'phabricator-prefab' => 'def4c982',
'phabricator-paste-file-upload' => '95ceba95',
'phabricator-prefab' => '95ceba95',
'phabricator-project-tag-css' => '6b1fccc6',
'phabricator-remarkup-css' => '4fc2a8f9',
'phabricator-shaped-request' => '67ea27d0',
'phabricator-shaped-request' => '322728f3',
'phabricator-side-menu-view-css' => '4fc2a8f9',
'phabricator-standard-page-view' => '4fc2a8f9',
'phabricator-textareautils' => 'def4c982',
'phabricator-tooltip' => 'def4c982',
'phabricator-textareautils' => '95ceba95',
'phabricator-tooltip' => '95ceba95',
'phabricator-transaction-view-css' => '4fc2a8f9',
'phabricator-zindex-css' => '4fc2a8f9',
'sprite-apps-large-css' => '4fc2a8f9',

View file

@ -329,6 +329,7 @@ abstract class ConpherenceController extends PhabricatorController {
'selected_conpherence_id' => $this->getSelectedConpherencePHID(),
'fancy_ajax' => (bool) $this->getSelectedConpherencePHID()
));
if ($more_than_menu) {
Javelin::initBehavior('conpherence-drag-and-drop-photo',
array(
@ -337,14 +338,8 @@ abstract class ConpherenceController extends PhabricatorController {
'upload_uri' => '/file/dropupload/',
'activated_class' => 'conpherence-header-upload-photo',
));
Javelin::initBehavior('conpherence-pontificate',
array(
'messages' => 'conpherence-messages',
'header' => 'conpherence-header-pane',
'menu_pane' => 'conpherence-menu',
'form_pane' => 'conpherence-form',
'file_widget' => 'widgets-files',
));
}
Javelin::initBehavior('conpherence-pontificate');
}
}

View file

@ -64,17 +64,19 @@ final class ConpherenceListController extends
private function renderEmptyMainPane() {
$this->initJavelinBehaviors(true);
return phutil_tag(
return javelin_tag(
'div',
array(
'id' => 'conpherence-main-pane'
'id' => 'conpherence-main-pane',
'sigil' => 'conpherence-layout'
),
array(
phutil_tag(
javelin_tag(
'div',
array(
'class' => 'conpherence-header-pane',
'id' => 'conpherence-header-pane',
'sigil' => 'conpherence-header',
),
''),
phutil_tag(
@ -91,11 +93,12 @@ final class ConpherenceListController extends
'id' => 'conpherence-message-pane'
),
array(
phutil_tag(
javelin_tag(
'div',
array(
'class' => 'conpherence-messages',
'id' => 'conpherence-messages'
'id' => 'conpherence-messages',
'sigil' => 'conpherence-messages',
),
''),
phutil_tag(

View file

@ -175,11 +175,12 @@ final class ConpherenceWidgetController extends
'style' => 'display: none;'
),
$this->renderPeopleWidgetPaneContent()).
phutil_tag(
javelin_tag(
'div',
array(
'class' => 'widgets-body',
'id' => 'widgets-files',
'sigil' => 'conpherence-widget-files',
),
id(new ConpherenceFileWidgetView())
->setUser($this->getRequest()->getUser())

View file

@ -4,53 +4,51 @@
* javelin-dom
* javelin-util
* javelin-workflow
* javelin-stratcom
*/
JX.behavior('conpherence-pontificate', function(config) {
var root = JX.$(config.form_pane);
var onsubmit = function(e) {
e.kill();
var form = JX.DOM.find(root, 'form');
var form = e.getNode('tag:form');
var root = e.getNode('conpherence-layout');
var messages = JX.DOM.find(root, 'div', 'conpherence-messages');
var header = JX.DOM.find(root, 'div', 'conpherence-header');
var files = null;
try {
files = JX.DOM.find(root, 'div', 'conpherence-widget-files');
} catch (ex) {
// Ignore, this view may not have a Files widget.
}
JX.Workflow.newFromForm(form)
.setHandler(JX.bind(this, function(r) {
// add the new transactions, probably just our post but who knows
var messages = JX.$(config.messages);
JX.DOM.appendContent(messages, JX.$H(r.transactions));
messages.scrollTop = messages.scrollHeight;
JX.DOM.setContent(header, JX.$H(r.header));
// update the menu entry as well
JX.DOM.replace(
JX.$(r.conpherence_phid + '-nav-item'),
JX.$H(r.nav_item)
);
try {
JX.DOM.replace(
JX.$(r.conpherence_phid + '-nav-item'),
JX.$H(r.nav_item));
} catch (ex) {
// Ignore; this view may not have a menu.
}
// update the header
JX.DOM.setContent(
JX.$(config.header),
JX.$H(r.header)
);
if (files) {
JX.DOM.setContent(files, JX.$H(r.file_widget));
}
// update the file widget
JX.DOM.setContent(
JX.$(config.file_widget),
JX.$H(r.file_widget)
);
// clear the textarea
var textarea = JX.DOM.find(form, 'textarea');
textarea.value = '';
}))
.start();
};
JX.DOM.listen(
root,
['click'],
'conpherence-pontificate',
onsubmit
);
JX.Stratcom.listen('click', 'conpherence-pontificate', onsubmit);
});