diff options
| author | Alon Levy <alon@pobox.com> | 2015-02-25 00:22:53 +0200 |
|---|---|---|
| committer | Alon Levy <alon@pobox.com> | 2015-02-25 00:22:53 +0200 |
| commit | 64324f317b6fbd9a1b636b0b21e123155f8153d4 (patch) | |
| tree | e9796eb67a99133b49d2151a0034b180c364f0ad | |
| parent | 717200a13ce38ad113620a092f786e9b1ea6ee85 (diff) | |
client: selection tools: add link nodes in fan
| -rw-r--r-- | res/client/css/partials/input-bar.scss | 4 | ||||
| -rw-r--r-- | res/client/css/style.css | 17 | ||||
| -rw-r--r-- | res/templates/index.html | 3 | ||||
| -rw-r--r-- | src/client/model/graph.js | 17 | ||||
| -rw-r--r-- | src/client/textanalysis.js | 3 | ||||
| -rw-r--r-- | src/client/view/selection.js | 41 |
6 files changed, 65 insertions, 20 deletions
diff --git a/res/client/css/partials/input-bar.scss b/res/client/css/partials/input-bar.scss index 7200d807..8c9784d8 100644 --- a/res/client/css/partials/input-bar.scss +++ b/res/client/css/partials/input-bar.scss @@ -39,9 +39,9 @@ } } -#merge-tool { +#selection-tools { position: absolute; - top: 160px; + top: 180px; left: 24px; } diff --git a/res/client/css/style.css b/res/client/css/style.css index d3385366..b09d2b3f 100644 --- a/res/client/css/style.css +++ b/res/client/css/style.css @@ -49,9 +49,6 @@ a:hover { a:active { color: #919095; } -button { - border: none; } - input { background-color: white; color: #363636; @@ -229,9 +226,9 @@ body.debug .debug-ui-right { #input-container__graph-input:focus { width: 80%; } -#merge-tool { +#selection-tools { position: absolute; - top: 160px; + top: 180px; left: 24px; } #textanalyser.ui-autocomplete-input { @@ -375,7 +372,7 @@ body.debug .debug-ui-right { border-top: 6px solid #363636; } .info.type-project { - border-top: 6px solid #40C200; } + border-top: 6px solid #40c200; } .info .info-card-attr { display: block; @@ -526,8 +523,8 @@ body.debug .debug-ui-right { width: 100%; min-height: 48px; text-align: center; - background-color: #D3F2F8; - color: #1D6E7F; + background-color: #d3f2f8; + color: #1d6e7f; border-top: 1px solid #8eb6bf; border-bottom: 1px solid #8eb6bf; } @@ -784,7 +781,7 @@ p { fill: #8b3ab0; } .circle.project { - fill: #40C200; } + fill: #40c200; } .circle.third-internship-proposal { fill: #33c2e0; } @@ -1089,5 +1086,3 @@ p { svg text::selection { background: none; } - -/*# sourceMappingURL=style.css.map */ diff --git a/res/templates/index.html b/res/templates/index.html index 67acaeff..c3d703e1 100644 --- a/res/templates/index.html +++ b/res/templates/index.html @@ -71,7 +71,8 @@ var rz_config = { // set as a global variable <button id="btn_add"></button> <div id="input-suggestion" class="suggestion" style="display: none"></div> </div> - <div class='merge-tool' id='merge-tool'> + <div class='selection-tools' id='selection-tools'> + <button id="btn_link_fan" style="display: none">link nodes in fan</button> <button id="btn_merge" style="display: none">merge nodes</button> </div> </div> diff --git a/src/client/model/graph.js b/src/client/model/graph.js index c7e255ec..4feb8a52 100644 --- a/src/client/model/graph.js +++ b/src/client/model/graph.js @@ -542,6 +542,21 @@ function Graph(spec) { this.commit_and_tx_diff__topo(topo_diff); } + /** + * links the first node in the list to the rest of the list. + */ + var nodes__link_fan = function(node_ids) { + util.assert(node_ids.length > 1); // strictly speaking we can also treat 1 as correct usage + var src_id = node_ids[0], + src_node = find_node__by_id(src_id), + added_links = node_ids.slice(1).map(function (tgt_id) { + return model_core.create_link__set_random_id(src_node, find_node__by_id(tgt_id), + {name: 'link'}); + }); + commit_and_tx_diff__topo(model_diff.new_topo_diff({link_set_add: added_links})); + }; + this.nodes__link_fan = nodes__link_fan; + var nodes__merge = function(node_ids) { util.assert(node_ids.length > 1); // strictly speaking we can also treat 1 as correct usage var merged = _.rest(node_ids); @@ -570,7 +585,7 @@ function Graph(spec) { link_set_add: added_links, node_id_set_rm: merged}); commit_and_tx_diff__topo(topo_diff); - } + }; this.nodes__merge = nodes__merge; var _remove_link_set = function(link_id_set) { diff --git a/src/client/textanalysis.js b/src/client/textanalysis.js index 5371c472..02f24211 100644 --- a/src/client/textanalysis.js +++ b/src/client/textanalysis.js @@ -503,6 +503,9 @@ var textAnalyser = function (spec) { ret.drop_conjugator_links = true; // leaving since we might change behavior again + // textanalysis.ui uses this. should make this more explicit + ret.thirds = thirds; + ret.applyToGraph = function(spec) { var edit_graph = spec.edit_graph, backend_commit = spec.backend_commit, diff --git a/src/client/view/selection.js b/src/client/view/selection.js index d91bafbd..8f05f12d 100644 --- a/src/client/view/selection.js +++ b/src/client/view/selection.js @@ -1,6 +1,28 @@ define(['rz_core', 'Bacon', 'jquery', 'underscore'], function(rz_core, Bacon, $, _) { +function list_from_list_like(list_like) +{ + var list = [], + i; + + for (i = 0 ; i < list_like.length ; ++i) { + list.push(list_like[i]); + } + return list; +} + +function list_call(list, field) +{ + list.forEach(function (item) { + item[field].apply(item, list_from_list_like(arguments).slice(2)); + }); +} + +function root_nodes_ids() { + return _.pluck(root_nodes, 'id'); +} + function Selection() { } @@ -173,16 +195,25 @@ var update = function(nodes, append) var setup_merge_button = function(main_graph) { var merge_root_selection = function() { - main_graph.nodes__merge(_.pluck(root_nodes, 'id')); - } - var merge_btn = $('#btn_merge'); + main_graph.nodes__merge(root_nodes_ids()); + }, + link_fan_root_selection = function() { + main_graph.nodes__link_fan(root_nodes_ids()); + }, + merge_btn = $('#btn_merge'), + link_fan_btn = $('#btn_link_fan'), + buttons = [merge_btn, link_fan_btn]; + merge_btn.asEventStream('click').onValue(merge_root_selection); + link_fan_btn.asEventStream('click').onValue(link_fan_root_selection); + selectionChangedBus.map(function (selection) { return selection.root_nodes.length > 1; }) .onValue(function (visible) { if (visible) { - merge_btn.show(); + list_call(buttons, 'show'); } else { - merge_btn.hide(); + list_call(buttons, 'hide'); + buttons.forEach(function (btn) { btn.hide(); }); } }); } |
