LT-275: Creating measure flow component common section

This commit is contained in:
Bruno Alves de Faria committed 2016-08-03 11:13:48 -03:00
1 parent 9a8eaff560
commit bbb7dad905
60 files changed
+391 -156

No files matched your search

+42
View File
@@ -0,0 +1,42 @@
import { OHIF } from 'meteor/ohif:core';
OHIF.blaze = {};
// Clone a template and return the clone
OHIF.blaze.cloneTemplate = (template, newName) => {
if (!template){
return;
}
const name = newName || template.viewName;
const clone = new Template(name, template.renderFunction);
clone.inheritsEventsFrom(template);
clone.inheritsHelpersFrom(template);
clone.inheritsHooksFrom(template);
return clone;
};
// Navigate upwards the component and get the parent with the given view name
OHIF.blaze.getParentView = (view, parentViewName) => {
let currentView = view;
while (currentView) {
if (currentView.name === parentViewName) {
break;
}
currentView = currentView.originalParentView || currentView.parentView;
}
return currentView;
};
// Search for the parent component of the given view
OHIF.blaze.getParentComponent = (view) => {
let currentView = view;
while (currentView) {
currentView = currentView.originalParentView || currentView.parentView;
if (currentView && currentView._component) {
return currentView._component;
}
}
};
+3
View File
@@ -0,0 +1,3 @@
import './blaze.js';
import './string.js';
import './user.js';
+33
View File
@@ -0,0 +1,33 @@
import { OHIF } from 'meteor/ohif:core';
import { _ } from 'meteor/underscore';
import { $ } from 'meteor/jquery';
OHIF.string = {};
// Search for some string inside any object or array
OHIF.string.search = (object, query, property=null, result=[]) => {
// Create the search pattern
const pattern = new RegExp($.trim(query).replace(/\s/gi, '|'), 'i');
_.each(object, item => {
// Stop here if item is empty
if (!item) {
return;
}
// Get the value to be compared
const value = _.isString(property) ? item[property] : item;
// Check if the value match the pattern
if (_.isString(value) && pattern.test(value)) {
// Add the current item to the result
result.push(item);
} else if (_.isObject(value)) {
// Search recursively the item if the current item is an object
OHIF.string.search(value, query, property, result);
}
});
// Return the found items
return result;
};
@@ -0,0 +1,151 @@
/*!
* transition-to-from-auto 0.5.2
* https://github.com/75lb/transition-to-from-auto
* Copyright 2015 Lloyd Brookes <75pound@gmail.com>
*/
/**
@module
@alias transition
*/
(function(window, document){
"use strict";
var getComputedStyle = window.getComputedStyle;
var isTransition = "data-ttfaInTransition";
var elements = [];
var data = [];
// Transition detecting
var transitionProp = false;
var transitionEnd = false;
var testStyle = document.createElement("a").style;
var testProp;
if(testStyle[testProp = "webkitTransition"] !== undefined) {
transitionProp = testProp;
transitionEnd = testProp + "End";
}
if(testStyle[testProp = "transition"] !== undefined) {
transitionProp = testProp;
transitionEnd = testProp + "end";
}
function process(options, data) {
var el = options.element;
var val = options.val;
var prop = options.prop;
var style = el.style;
var startVal;
var autoVal;
if(!transitionProp) {
return style[prop] = val;
}
if(el.hasAttribute(isTransition)) {
el.removeEventListener(transitionEnd, data.l);
} else {
style[transitionProp] = "none";
startVal = getComputedStyle(el)[prop];
style[prop] = "auto";
autoVal = getComputedStyle(el)[prop];
// Interrupt
if(startVal === val || val === "auto" && startVal === autoVal) {
return;
}
data.auto = autoVal;
el.setAttribute(isTransition, 1);
// Transition
style[prop] = startVal;
el.offsetWidth;
style[transitionProp] = options.style;
}
style[prop] = val === "auto" ? data.auto : val;
data.l = function (e) {
if(e.propertyName === prop) {
el.removeAttribute(isTransition);
el.removeEventListener(transitionEnd, data.l);
if(val === "auto") {
/* avoid transition flashes in Safari */
style[transitionProp] = "none";
style[prop] = val;
}
}
};
el.addEventListener(transitionEnd, data.l);
}
/**
@param options {Object}
@param options.element {string | element} - The DOM element or selector to transition
@param options.val {string} - The value you want to transition to
@param [options.prop] {string} - The CSS property to transition, defaults to `"height"`
@param [options.style] {string} - The desired value for the `transition` CSS property (e.g. `"height 1s"`). If specified, this value is added inline and will override your CSS. Leave this value blank if you already have it defined in your stylesheet.
@alias module:transition-to-from-auto
*/
function transition(options){
var element = options.element;
var datum;
var index;
if(typeof element === "string") {
element = document.querySelector(element);
}
element = options.element = element instanceof Node ? element : false;
options.prop = options.prop || "height";
options.style = options.style || "";
if(element) {
index = elements.indexOf(element);
if(~index) {
datum = data[index];
} else {
datum = {};
elements.push(element);
data.push(datum);
}
process(options, datum);
}
}
/**
The name of the vendor-specific transition CSS property
@type {string}
@example
el.style[transition.prop + 'Duration'] = '1s';
*/
transition.prop = transitionProp;
/**
* The name of the [transition end event](https://developer.mozilla.org/en-US/docs/Web/Events/transitionend) in the current browser (typically `"transitionend"` or `"webkitTransitionEnd"`)
* @type {string}
* @example
* el.addEventListener(transition.end, function(){
* // the transition ended..
* });
*/
transition.end = transitionEnd;
if (typeof module === "object" && module.exports){
module.exports = transition;
} else if (typeof define === "function" && define.amd){
define(function(){
return transition;
});
} else {
window.transition = transition;
}
})(window, document);
+32
View File
@@ -0,0 +1,32 @@
import { OHIF } from 'meteor/ohif:core';
OHIF.user = {};
// Throw error if there is no user logged in
OHIF.user.validate = () => {
if (!Meteor.userId()) {
throw new Meteor.Error('not-authorized');
}
};
// Get the persistent data by key
OHIF.user.getData = key => {
// Check if there is an user logged in
OHIF.user.validate();
// Get the user persistent data
const data = Meteor.user().profile.persistent;
if (data) {
return data[key];
}
};
// Store the persistent data by giving a key and a value to store
OHIF.user.setData = (key, value) => {
// Check if there is an user logged in
OHIF.user.validate();
// Call the update method on server-side
Meteor.call('userDataSet', key, value);
};