Changeset View
Changeset View
Standalone View
Standalone View
webroot/rsrc/js/application/diff/DiffChangesetList.js
| Show First 20 Lines • Show All 192 Lines • ▼ Show 20 Lines | wake: function() { | ||||
| label = pht( | label = pht( | ||||
| 'Jump to previous inline comment, including collapsed comments.'); | 'Jump to previous inline comment, including collapsed comments.'); | ||||
| this._installJumpKey('P', label, -1, 'comment', true); | this._installJumpKey('P', label, -1, 'comment', true); | ||||
| var formation = this.getFormationView(); | var formation = this.getFormationView(); | ||||
| if (formation) { | if (formation) { | ||||
| var filetree = formation.getColumn(0); | var filetree = formation.getColumn(0); | ||||
| var toggletree = JX.bind(filetree, filetree.toggleVisibility); | var toggletree = JX.bind(filetree, filetree.toggleVisibility); | ||||
| label = pht('Hide or show the paths panel.'); | |||||
| this._installKey('f', 'diff-vis', label, toggletree); | this._installKey('f', 'diff-vis', label, toggletree); | ||||
| } | } | ||||
| if (!standalone) { | if (!standalone) { | ||||
| label = pht('Hide or show the current file.'); | label = pht('Hide or show the current file.'); | ||||
| this._installKey('h', 'diff-vis', label, this._onkeytogglefile); | this._installKey('h', 'diff-vis', label, this._onkeytogglefile); | ||||
| } | } | ||||
| Show All 12 Lines | wake: function() { | ||||
| this._installKey('w', 'inline', label, this._onkeydone); | this._installKey('w', 'inline', label, this._onkeydone); | ||||
| label = pht('Collapse or expand inline comment.'); | label = pht('Collapse or expand inline comment.'); | ||||
| this._installKey('q', 'diff-vis', label, this._onkeycollapse); | this._installKey('q', 'diff-vis', label, this._onkeycollapse); | ||||
| label = pht('Hide or show all inline comments.'); | label = pht('Hide or show all inline comments.'); | ||||
| this._installKey('A', 'diff-vis', label, this._onkeyhideall); | this._installKey('A', 'diff-vis', label, this._onkeyhideall); | ||||
| label = pht('Show path in repository.'); | |||||
| this._installKey('d', 'diff-nav', label, this._onkeyshowpath); | |||||
| label = pht('Show directory in repository.'); | |||||
| this._installKey('D', 'diff-nav', label, this._onkeyshowdirectory); | |||||
| label = pht('Open file in external editor.'); | label = pht('Open file in external editor.'); | ||||
| this._installKey('\\', 'diff-nav', label, this._onkeyopeneditor); | this._installKey('\\', 'diff-nav', label, this._onkeyopeneditor); | ||||
| }, | }, | ||||
| isAsleep: function() { | isAsleep: function() { | ||||
| return this._asleep; | return this._asleep; | ||||
| }, | }, | ||||
| newChangesetForNode: function(node) { | newChangesetForNode: function(node) { | ||||
| var changeset = JX.DiffChangeset.getForNode(node); | var changeset = JX.DiffChangeset.getForNode(node); | ||||
| ▲ Show 20 Lines • Show All 211 Lines • ▼ Show 20 Lines | _onkeydone: function() { | ||||
| } | } | ||||
| } | } | ||||
| var pht = this.getTranslations(); | var pht = this.getTranslations(); | ||||
| this._warnUser(pht('You must select a comment to mark done.')); | this._warnUser(pht('You must select a comment to mark done.')); | ||||
| }, | }, | ||||
| _onkeytogglefile: function() { | _onkeytogglefile: function() { | ||||
| var cursor = this._cursorItem; | var pht = this.getTranslations(); | ||||
| var changeset = this._getChangesetForKeyCommand(); | |||||
| if (cursor) { | if (!changeset) { | ||||
| if (cursor.type == 'file') { | this._warnUser(pht('You must select a file to hide or show.')); | ||||
| cursor.changeset.toggleVisibility(); | |||||
| return; | return; | ||||
| } | } | ||||
| } | |||||
| var pht = this.getTranslations(); | changeset.toggleVisibility(); | ||||
| this._warnUser(pht('You must select a file to hide or show.')); | |||||
| }, | }, | ||||
| _onkeyopeneditor: function() { | _getChangesetForKeyCommand: function() { | ||||
| var pht = this.getTranslations(); | |||||
| var cursor = this._cursorItem; | var cursor = this._cursorItem; | ||||
| var changeset; | var changeset; | ||||
| if (cursor) { | if (cursor) { | ||||
| changeset = cursor.changeset; | changeset = cursor.changeset; | ||||
| } | } | ||||
| if (!changeset) { | if (!changeset) { | ||||
| changeset = this._getVisibleChangeset(); | changeset = this._getVisibleChangeset(); | ||||
| } | } | ||||
| return changeset; | |||||
| }, | |||||
| _onkeyopeneditor: function() { | |||||
| var pht = this.getTranslations(); | |||||
| var changeset = this._getChangesetForKeyCommand(); | |||||
| if (!changeset) { | if (!changeset) { | ||||
| this._warnUser(pht('You must select a file to edit.')); | this._warnUser(pht('You must select a file to edit.')); | ||||
| return; | return; | ||||
| } | } | ||||
| var editor_uri = changeset.getEditorURI(); | var editor_uri = changeset.getEditorURI(); | ||||
| if (editor_uri === null) { | if (editor_uri === null) { | ||||
| this._warnUser(pht('No external editor is configured.')); | this._warnUser(pht('No external editor is configured.')); | ||||
| return; | return; | ||||
| } | } | ||||
| JX.$U(editor_uri).go(); | JX.$U(editor_uri).go(); | ||||
| }, | }, | ||||
| _onkeyshowpath: function() { | |||||
| this._onrepositorykey(false); | |||||
| }, | |||||
| _onkeyshowdirectory: function() { | |||||
| this._onrepositorykey(true); | |||||
| }, | |||||
| _onrepositorykey: function(is_directory) { | |||||
| var pht = this.getTranslations(); | |||||
| var changeset = this._getChangesetForKeyCommand(); | |||||
| if (!changeset) { | |||||
| this._warnUser(pht('You must select a file to open.')); | |||||
| return; | |||||
| } | |||||
| var show_uri; | |||||
| if (is_directory) { | |||||
| show_uri = changeset.getShowDirectoryURI(); | |||||
| } else { | |||||
| show_uri = changeset.getShowPathURI(); | |||||
| } | |||||
| if (show_uri === null) { | |||||
| return; | |||||
| } | |||||
| window.open(show_uri); | |||||
| }, | |||||
| _onkeycollapse: function() { | _onkeycollapse: function() { | ||||
| var cursor = this._cursorItem; | var cursor = this._cursorItem; | ||||
| if (cursor) { | if (cursor) { | ||||
| if (cursor.type == 'comment') { | if (cursor.type == 'comment') { | ||||
| var inline = cursor.target; | var inline = cursor.target; | ||||
| if (inline.canCollapse()) { | if (inline.canCollapse()) { | ||||
| this.setFocus(null); | this.setFocus(null); | ||||
| ▲ Show 20 Lines • Show All 148 Lines • ▼ Show 20 Lines | selectChangeset: function(changeset, scroll) { | ||||
| var item = items[ii]; | var item = items[ii]; | ||||
| if (changeset === item.target) { | if (changeset === item.target) { | ||||
| cursor = ii; | cursor = ii; | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| if (cursor !== null) { | if (cursor !== null) { | ||||
| this._setSelectionState(items[cursor], true); | this._setSelectionState(items[cursor], scroll); | ||||
| } | } | ||||
| return this; | return this; | ||||
| }, | }, | ||||
| _setSelectionState: function(item, scroll) { | _setSelectionState: function(item, scroll) { | ||||
| this._cursorItem = item; | this._cursorItem = item; | ||||
| this._redrawSelection(scroll); | this._redrawSelection(scroll); | ||||
| ▲ Show 20 Lines • Show All 106 Lines • ▼ Show 20 Lines | _onmenu: function(e) { | ||||
| var node = JX.DOM.findAbove( | var node = JX.DOM.findAbove( | ||||
| button, | button, | ||||
| 'div', | 'div', | ||||
| 'differential-changeset'); | 'differential-changeset'); | ||||
| var changeset_list = this; | var changeset_list = this; | ||||
| var changeset = this.getChangesetForNode(node); | var changeset = this.getChangesetForNode(node); | ||||
| var menu = new JX.PHUIXDropdownMenu(button); | var menu = new JX.PHUIXDropdownMenu(button) | ||||
| .setWidth(240); | |||||
| var list = new JX.PHUIXActionListView(); | var list = new JX.PHUIXActionListView(); | ||||
| var add_link = function(icon, name, href, local) { | var add_link = function(icon, name, href, local) { | ||||
| if (!href) { | |||||
| return; | |||||
| } | |||||
| var link = new JX.PHUIXActionView() | var link = new JX.PHUIXActionView() | ||||
| .setIcon(icon) | .setIcon(icon) | ||||
| .setName(name) | .setName(name) | ||||
| .setHref(href) | |||||
| .setHandler(function(e) { | .setHandler(function(e) { | ||||
| if (local) { | if (local) { | ||||
| window.location.assign(href); | window.location.assign(href); | ||||
| } else { | } else { | ||||
| window.open(href); | window.open(href); | ||||
| } | } | ||||
| menu.close(); | menu.close(); | ||||
| e.prevent(); | e.prevent(); | ||||
| }); | }); | ||||
| if (href) { | |||||
| link.setHref(href); | |||||
| } else { | |||||
| link | |||||
| .setDisabled(true) | |||||
| .setUnresponsive(true); | |||||
| } | |||||
| list.addItem(link); | list.addItem(link); | ||||
| return link; | return link; | ||||
| }; | }; | ||||
| var reveal_item = new JX.PHUIXActionView() | |||||
| .setIcon('fa-eye'); | |||||
| list.addItem(reveal_item); | |||||
| var visible_item = new JX.PHUIXActionView() | var visible_item = new JX.PHUIXActionView() | ||||
| .setKeyCommand('h') | |||||
| .setHandler(function(e) { | .setHandler(function(e) { | ||||
| e.prevent(); | e.prevent(); | ||||
| menu.close(); | menu.close(); | ||||
| changeset.select(false); | |||||
| changeset.toggleVisibility(); | changeset.toggleVisibility(); | ||||
| }); | }); | ||||
| list.addItem(visible_item); | list.addItem(visible_item); | ||||
| add_link('fa-file-text', pht('Browse in Diffusion'), data.diffusionURI); | var reveal_item = new JX.PHUIXActionView() | ||||
| add_link('fa-file-o', pht('View Standalone'), data.standaloneURI); | .setIcon('fa-eye'); | ||||
| list.addItem(reveal_item); | |||||
| list.addItem( | |||||
| new JX.PHUIXActionView() | |||||
| .setDivider(true)); | |||||
| var up_item = new JX.PHUIXActionView() | var up_item = new JX.PHUIXActionView() | ||||
| .setHandler(function(e) { | .setHandler(function(e) { | ||||
| if (changeset.isLoaded()) { | if (changeset.isLoaded()) { | ||||
| // Don't let the user swap display modes if a comment is being | // Don't let the user swap display modes if a comment is being | ||||
| // edited, since they might lose their work. See PHI180. | // edited, since they might lose their work. See PHI180. | ||||
| var inlines = changeset.getInlines(); | var inlines = changeset.getInlines(); | ||||
| ▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | _onmenu: function(e) { | ||||
| e.prevent(); | e.prevent(); | ||||
| menu.close(); | menu.close(); | ||||
| }); | }); | ||||
| list.addItem(highlight_item); | list.addItem(highlight_item); | ||||
| var engine_item = new JX.PHUIXActionView() | var engine_item = new JX.PHUIXActionView() | ||||
| .setIcon('fa-file-image-o') | .setIcon('fa-file-image-o') | ||||
| .setName(pht('View As...')) | .setName(pht('View As Document Type...')) | ||||
| .setHandler(function(e) { | .setHandler(function(e) { | ||||
| var params = { | var params = { | ||||
| engine: changeset.getDocumentEngine(), | engine: changeset.getDocumentEngine(), | ||||
| }; | }; | ||||
| new JX.Workflow('/services/viewas/', params) | new JX.Workflow('/services/viewas/', params) | ||||
| .setHandler(function(r) { | .setHandler(function(r) { | ||||
| changeset.reload({engine: r.engine}); | changeset.reload({engine: r.engine}); | ||||
| }) | }) | ||||
| .start(); | .start(); | ||||
| e.prevent(); | e.prevent(); | ||||
| menu.close(); | menu.close(); | ||||
| }); | }); | ||||
| list.addItem(engine_item); | list.addItem(engine_item); | ||||
| list.addItem( | |||||
| new JX.PHUIXActionView() | |||||
| .setDivider(true)); | |||||
| add_link('fa-external-link', pht('View Standalone'), data.standaloneURI); | |||||
| add_link('fa-arrow-left', pht('Show Raw File (Left)'), data.leftURI); | add_link('fa-arrow-left', pht('Show Raw File (Left)'), data.leftURI); | ||||
| add_link('fa-arrow-right', pht('Show Raw File (Right)'), data.rightURI); | add_link('fa-arrow-right', pht('Show Raw File (Right)'), data.rightURI); | ||||
| add_link( | |||||
| 'fa-folder-open-o', | |||||
| pht('Show Directory in Repository'), | |||||
| changeset.getShowDirectoryURI()) | |||||
| .setKeyCommand('D'); | |||||
| add_link( | |||||
| 'fa-file-text-o', | |||||
| pht('Show Path in Repository'), | |||||
| changeset.getShowPathURI()) | |||||
| .setKeyCommand('d'); | |||||
| var editor_uri = changeset.getEditorURI(); | var editor_uri = changeset.getEditorURI(); | ||||
| if (editor_uri !== null) { | if (editor_uri !== null) { | ||||
| add_link('fa-pencil', pht('Open in Editor'), editor_uri, true); | add_link('fa-i-cursor', pht('Open in Editor'), editor_uri, true) | ||||
| .setKeyCommand('\\'); | |||||
| } else { | } else { | ||||
| var configure_uri = changeset.getEditorConfigureURI(); | var configure_uri = changeset.getEditorConfigureURI(); | ||||
| if (configure_uri !== null) { | if (configure_uri !== null) { | ||||
| add_link('fa-wrench', pht('Configure Editor'), configure_uri); | add_link('fa-wrench', pht('Configure Editor'), configure_uri); | ||||
| } | } | ||||
| } | } | ||||
| menu.setContent(list.getNode()); | menu.setContent(list.getNode()); | ||||
| menu.listen('open', function() { | menu.listen('open', function() { | ||||
| // When the user opens the menu, check if there are any "Show More" | // When the user opens the menu, check if there are any "Show More" | ||||
| // links in the changeset body. If there aren't, disable the "Show | // links in the changeset body. If there aren't, disable the "Show | ||||
| // Entire File" menu item since it won't change anything. | // Entire File" menu item since it won't change anything. | ||||
| var nodes = JX.DOM.scry(JX.$(data.containerID), 'a', 'show-more'); | var nodes = JX.DOM.scry(JX.$(data.containerID), 'a', 'show-more'); | ||||
| if (nodes.length) { | if (nodes.length) { | ||||
| reveal_item | reveal_item | ||||
| .setDisabled(false) | .setDisabled(false) | ||||
| .setName(pht('Show All Context')) | .setName(pht('Show All Context')) | ||||
| .setIcon('fa-file-o') | .setIcon('fa-arrows-v') | ||||
| .setHandler(function(e) { | .setHandler(function(e) { | ||||
| changeset.loadAllContext(); | changeset.loadAllContext(); | ||||
| e.prevent(); | e.prevent(); | ||||
| menu.close(); | menu.close(); | ||||
| }); | }); | ||||
| } else { | } else { | ||||
| reveal_item | reveal_item | ||||
| .setDisabled(true) | .setDisabled(true) | ||||
| .setUnresponsive(true) | |||||
| .setIcon('fa-file') | .setIcon('fa-file') | ||||
| .setName(pht('All Context Shown')) | .setName(pht('All Context Shown')) | ||||
| .setHandler(function(e) { e.prevent(); }); | .setHref(null); | ||||
| } | } | ||||
| encoding_item.setDisabled(!changeset.isLoaded()); | encoding_item.setDisabled(!changeset.isLoaded()); | ||||
| highlight_item.setDisabled(!changeset.isLoaded()); | highlight_item.setDisabled(!changeset.isLoaded()); | ||||
| engine_item.setDisabled(!changeset.isLoaded()); | engine_item.setDisabled(!changeset.isLoaded()); | ||||
| if (changeset.isLoaded()) { | if (changeset.isLoaded()) { | ||||
| if (changeset.getRendererKey() == '2up') { | if (changeset.getRendererKey() == '2up') { | ||||
| up_item | up_item | ||||
| .setIcon('fa-list-alt') | .setIcon('fa-list-alt') | ||||
| .setName(pht('View Unified')); | .setName(pht('View Unified Diff')); | ||||
| } else { | } else { | ||||
| up_item | up_item | ||||
| .setIcon('fa-files-o') | .setIcon('fa-columns') | ||||
| .setName(pht('View Side-by-Side')); | .setName(pht('View Side-by-Side Diff')); | ||||
| } | } | ||||
| } else { | } else { | ||||
| up_item | up_item | ||||
| .setIcon('fa-refresh') | .setIcon('fa-refresh') | ||||
| .setName(pht('Load Changes')); | .setName(pht('Load Changes')); | ||||
| } | } | ||||
| visible_item | visible_item | ||||
| ▲ Show 20 Lines • Show All 1,073 Lines • Show Last 20 Lines | |||||