LT-275: Creating measure flow component animations

This commit is contained in:
Bruno Alves de Faria committed 2016-07-29 09:03:35 -03:00
1 parent 7fdfbf1c1a
commit 9a8eaff560
7 files changed
+404 -73

No files matched your search

@@ -2,7 +2,6 @@ import { OHIF } from 'meteor/ohif:core';
import { Template } from 'meteor/templating';
import { ReactiveVar } from 'meteor/reactive-var';
import { _ } from 'meteor/underscore';
import { $ } from 'meteor/jquery';
/*
* input: controls a tree selection component
@@ -13,6 +12,8 @@ OHIF.mixins.selectTree = new OHIF.Mixin({
onCreated() {
const instance = Template.instance();
const component = instance.component;
const rootComponent = instance.data.root || component;
const rootInstance = rootComponent.templateInstance;
// Create the component's value storage property
instance.data.currentNode = new ReactiveVar(null);
@@ -41,49 +42,6 @@ OHIF.mixins.selectTree = new OHIF.Mixin({
// Change the current node
instance.data.currentNode.set(node);
};
},
events: {
'change .select-tree:first>.tree-options>label>input'(event, instance) {
const component = instance.component;
const $target = $(event.target);
const eventComponent = $target.data('component');
// Change the active item
const rootComponent = instance.data.root || component;
rootComponent.templateInstance.$('label').removeClass('active');
$target.closest('label.tree-leaf').addClass('active');
// Change the component's value
component.value(eventComponent.value());
},
'click .select-tree:first>.tree-options>.tree-breadcrumb>.tree-back'(event, instance) {
// Prevent the default element action
event.preventDefault();
// Reset the checked inputs to unchecked state
const rootComponent = instance.data.root || instance.component;
rootComponent.templateInstance.$('input').removeAttr('checked');
// Get the index of the breadcrumb's clicked option
const index = $(event.currentTarget).attr('data-index') | 0;
// Set the current instance
let currentInstance = instance.component.parent.templateInstance;
// Iterate over all parents until gets into the clicked node
for (let i = 1; i <= index; i++) {
// Unset the selected node
currentInstance.data.currentNode.set(null);
// Check if it's not the root node
if (i < index) {
// Change the current instance
currentInstance = currentInstance.component.parent.templateInstance;
}
}
}
}
}
});