app/assets/javascripts/iqvoc/treeview.js in iqvoc-4.6.1 vs app/assets/javascripts/iqvoc/treeview.js in iqvoc-4.7.0

- old
+ new

@@ -27,10 +27,11 @@ load_on_demand: item.data('has-children'), locked: item.data('locked'), id: item.attr('id'), url: item.children('a').attr('href'), update_url: item.data('update-url'), + glance_url: item.data('glance-url'), published: item.data('published'), additionalText: item.children('span.additional_info') }; }); @@ -58,10 +59,14 @@ link.addClass('unpublished'); } else { link.addClass('published'); } + if (typeof link[0] !== 'undefined') { + var teaserLink = buildTeaserLink(node, link[0]); + } + if (dragabbleSupport) { // mark locked items if (typeof node.locked !== 'undefined' && node.locked) { // add icon only to the first element of the collection. // the second one could be a nodelist for parents nodes. @@ -78,11 +83,12 @@ if(node.moved) { $li.data('node-id', node.id); $li.data('old-parent-node-id', node.old_parent_id); $li.data('new-parent-node-id', node.target_node_id); $li.data('old-previous-sibling-id', node.old_previous_sibling_id); - $li.data('update-url', node.update_url); + $li.data('update-url', node.update_url), + $li.data('glance-url', node.glance_url); var saveButton = $('<button type="button" class="btn btn-primary btn-xs node-btn" data-tree-action="move"><i class="fa fa-save"></i> ' + saveLabel + '</button>'); var copyButton = $('<button type="button" class="btn btn-primary btn-xs node-btn" data-tree-action="copy"><i class="fa fa-copy"></i> ' + copyLabel + '</button>'); var undoButton = $('<button type="button" class="btn btn-primary btn-xs reset-node-btn"><i class="fa fa-undo"></i> ' + undoLabel + '</button>'); @@ -212,15 +218,43 @@ } $tree.tree('updateNode', node, {moved: false}); } function buildLink(url, label, additionalText) { - var link = $('<a>').attr('href', url).html(label); + var link = $('<a>').attr('href', url).addClass('tree-element-link').html(label); if (additionalText) { link = link.after(' ', additionalText); } return link; + } + + function buildTeaserLink(node, link) { + if (typeof node.glance_url === 'undefined') { + return; + } + + var teaserLink = $('<a/>') + + teaserLink.addClass('tree-element-teaser-link') + .attr('href', node.glance_url) + .append($('<i class="fa fa-search-plus"/>')) + + $(link).after(teaserLink); + + teaserLink.click(function(ev) { + ev.preventDefault(); + + var modal = $("#concept-teaser-modal"); + var target = $(this).attr("href"); + + $.get(target, function(data) { + modal.html(data); + modal.modal(); + }); + }); + + return teaserLink; } } return function(selector) {