Skip to content

Commit

Permalink
Fix #13. Trigger collapse/expand node by double click.
Browse files Browse the repository at this point in the history
  • Loading branch information
Joouis committed Nov 20, 2017
1 parent cad0678 commit 33726b8
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 13 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ You can find all these commands by [`Command Palette`](http://flight-manual.atom

## Icon alphabet meaning

- `U` : Unknown

##### HTML

- `<>` : Element
Expand All @@ -90,7 +88,11 @@ You can find all these commands by [`Command Palette`](http://flight-manual.atom
- `I` : Import
- `F` : Function
- `M` : Method
- `V`: Variable
- `V` : Variable

#### Others

- `U` : Unknown



Expand Down
22 changes: 13 additions & 9 deletions lib/structure-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ export default class StructureView {
toggle: true
});
},
onSelectTreeNode(evt) {
Util.selectTreeNode($(evt.target), this, {
toggle: false
});
}
},
watch: {
treeNodeId(val) {
Expand Down Expand Up @@ -274,15 +279,14 @@ export default class StructureView {
if (item.child) {
let childContent = self.treeGenerator(item.child);

if (childContent.length != 0)
{
entry = `<li node-id="${item.id}" class="list-nested-item expanded" title="${item.name}">
<div class="list-item symbol-mixed-block">
${iconTpl}
<span>${item.name}</span>
</div>
<ol class="list-tree">${childContent}</ol>
</li>`;
if (childContent.length != 0) {
entry = `<li node-id="${item.id}" class="list-nested-item expanded" title="${item.name}">
<div class="list-item symbol-mixed-block">
${iconTpl}
<span>${item.name}</span>
</div>
<ol class="list-tree">${childContent}</ol>
</li>`;
}
}

Expand Down
5 changes: 5 additions & 0 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,16 @@ export default {
if ($target.is('span')) $target = $target.parent();
if ($target.is('div')) $target = $target.parent();
if ($target.is('li')) {
// ".toggle" would be TRUE if it's double click
if (opts && opts.toggle) {
$target.hasClass('list-nested-item') && $target[$target.hasClass('collapsed') ? 'removeClass' : 'addClass']('collapsed');
}
let oldVal = vm.treeNodeId,
val = $target.attr('node-id');

// Same node
if (oldVal === val) return;

oldVal && $('div.structure-view>div.tree-panel>ol').find('li.selected').removeClass('selected');
$target.addClass('selected');
vm.treeNodeId = val;
Expand Down
4 changes: 4 additions & 0 deletions styles/structure-view.less
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
margin-right: 2px;
}

.full-menu {
user-select: none;
}

div.symbol-mixed-block {
display: flex;
align-items: center;
Expand Down
2 changes: 1 addition & 1 deletion templates/structure-view.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class='structure-view'>
<div class="no-file-hint" v-show="noTagHint"><pre>{{noTagHint}}</pre></div>
<div class="tree-panel" v-show="!noTagHint">
<ol class="full-menu list-tree has-collapsable-children" @click="onToggleTreeNode">
<ol class="full-menu list-tree has-collapsable-children" @click="onSelectTreeNode" @dblclick="onToggleTreeNode">
</ol>
</div>
<div class="mask">
Expand Down

0 comments on commit 33726b8

Please sign in to comment.