From 56b2c3af7de6b97aaa9a851450befbfca48572dc Mon Sep 17 00:00:00 2001 From: Henri Bergius Date: Wed, 2 Oct 2013 17:27:39 +0200 Subject: [PATCH] Rebuild --- build/dataflow.build.js | 2 +- build/dataflow.min.js | 8 ++++---- build/dataflow.min.js.map | 2 +- build/default/dataflow.min.css | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/build/dataflow.build.js b/build/dataflow.build.js index 8ccf0ce..129b7ee 100644 --- a/build/dataflow.build.js +++ b/build/dataflow.build.js @@ -1,4 +1,4 @@ -/*! dataflow.js - v0.0.7 - 2013-10-02 (5:53:08 PM GMT+0300) +/*! dataflow.js - v0.0.7 - 2013-10-02 (5:27:30 PM GMT+0200) * Copyright (c) 2013 Forrest Oliphant; Licensed MIT, GPL */ // Thanks bobnice http://stackoverflow.com/a/1583281/592125 diff --git a/build/dataflow.min.js b/build/dataflow.min.js index 969fe86..618495f 100644 --- a/build/dataflow.min.js +++ b/build/dataflow.min.js @@ -1,5 +1,5 @@ -/*! dataflow.js - v0.0.7 - 2013-10-02 (5:53:08 PM GMT+0300) +/*! dataflow.js - v0.0.7 - 2013-10-02 (5:27:30 PM GMT+0200) * Copyright (c) 2013 Forrest Oliphant; Licensed MIT, GPL */ -function CircularBuffer(e){this._array=Array(e),this.length=0}CircularBuffer.prototype.toString=function(){return"[object CircularBuffer("+this._array.length+") length "+this.length+"]"},CircularBuffer.prototype.get=function(e){return 0>e||this.length-this._array.length>e?void 0:this._array[e%this._array.length]},CircularBuffer.prototype.set=function(e,t){if(0>e||this.length-this._array.length>e)throw CircularBuffer.IndexError;for(;e>this.length;)this._array[this.length%this._array.length]=void 0,this.length++;this._array[e%this._array.length]=t,e==this.length&&this.length++},CircularBuffer.prototype.push=function(e){this._array[this.length%this._array.length]=e,this.length++},CircularBuffer.IndexError={},function(){var e=Backbone.Model.extend({$:function(e){return this.$el.find(e)},initialize:function(){this.el=document.createElement("div"),this.el.className="dataflow",this.$el=$(this.el),this.$el.data("dataflow",this);var e=Dataflow.prototype.module("card");if(this.shownCards=new e.Collection,this.shownCards.view=new e.CollectionView({collection:this.shownCards}),this.$el.append(this.shownCards.view.$el),this.debug=this.get("debug"),this.controls=this.get("controls"),this.controls!==!1&&(this.controls=!0),this.controls)for(var t in this.plugins)this.plugins[t].initialize&&this.plugins[t].initialize(this);this.inputs=this.get("inputs"),this.inputs!==!1&&(this.inputs=!0),this.editable=this.get("editable"),this.editable!==!1&&(this.editable=!0);var o=this.get("appendTo");o=o?o:"body","body"===o&&$("html, body").css({margin:"0px",padding:"0px",width:"100%",height:"100%"}),$(o).append(this.el),this.id||(this.id=$(o).attr("id")),this.loadState()},modules:{},module:function(e){return this.modules[e]?this.modules[e]:(this.modules[e]={},this.modules[e])},nodes:{},node:function(e){return this.nodes[e]?this.nodes[e]:(this.nodes[e]={description:""},this.nodes[e])},plugins:{},plugin:function(e){return this.plugins[e]?this.plugins[e]:(this.plugins[e]={},this.plugins[e])},addCard:function(e,t){t||this.hideCards(),this.shownCards.get(e)?this.shownCards.view.bringToTop(e):this.shownCards.add(e)},removeCard:function(e){this.shownCards.remove(e)},hideCards:function(){var e=this.shownCards.where({pinned:!1});this.shownCards.remove(e)},addPlugin:function(e){var t=this.plugins[e.id];if(t||(this.plugins[e.id]=t={}),t.info=e,t.enabled=!0,e.menu){var o=Dataflow.prototype.module("card"),i=new o.Model({dataflow:this,card:{el:e.menu},pinned:e.pinned?!0:!1});t.card=i,this.plugins.menu.addPlugin({id:e.id,icon:e.icon,label:e.label,showLabel:!1})}},showPlugin:function(e){this.plugins[e]&&this.plugins[e].card&&(this.addCard(this.plugins[e].card),"function"==typeof this.plugins[e].onShow&&this.plugins[e].onShow())},enablePlugin:function(e){var t=this.plugins[e];t&&this.addPlugin(t.info)},disablePlugin:function(e){this.plugins.menu.disablePlugin(e)},showContextBar:function(){this.contextBar.view.$el.show()},hideContextBar:function(){this.contextBar.view.$el.hide()},contexts:{},prepareContext:function(e){if(this.contexts[e])return this.contexts[e];var t=this.module("menucard");return this.contexts[e]=new t.Model({id:"context-"+e,dataflow:this,pinned:!0}),this.contexts[e].view=new t.View({model:this.contexts[e]}),this.contexts[e]},addContext:function(e){_.each(e.contexts,function(t){var o=this.prepareContext(t);o.menu.add(e)},this)},changeContext:function(e,t){var o=function(e,t){this.contexts[e]&&(this.contexts[e].set("label",t),this.shownCards.get("context-"+e)||this.shownCards.add(this.contexts[e]))}.bind(this),i=function(e){this.shownCards.get("context-"+e)&&this.shownCards.remove("context-"+e)}.bind(this);e.length>1?(o("nodes",e.length+" nodes"),i("node")):1===e.length?(o("node",e[0].get("label")),i("nodes")):(i("node"),i("nodes")),t.length>1?(o("edges",t.length+" edges"),i("edge")):1===t.length?(o("edge",t[0].id),i("edges")):(i("edge"),i("edges"))},loadGraph:function(e){this.graph&&(this.currentGraph.view&&this.currentGraph.view.remove(),this.graph.view&&this.graph.view.remove(),this.graph.remove());var t=this.module("graph");e.dataflow=this;var o=new t.Model(e);return o.view=new t.View({model:o}),this.$el.append(o.view.render().el),this.graph=this.currentGraph=o,o},showGraph:function(e){this.currentGraph.view.$el.detach(),this.$el.append(e.view.el),e.view.render(),this.currentGraph=e},debug:!1,log:function(e){this.trigger("log",e,arguments),this.debug&&console.log("Dataflow: ",arguments)},types:["all","canvas:2d","canvas:webgl","string","number","int","object","array"]});window.Dataflow=e,"object"==typeof exports&&(exports.Dataflow=e),Backbone.View.prototype.addEvents=function(e){this.delegateEvents(_.extend(_.clone(this.events),e))},Backbone.CollectionView=Backbone.Model.extend({prepend:!1,initialize:function(e){e.tagName&&(this.tagName=e.tagName),e.className&&(this.className=e.className),e.itemView&&(this.itemView=e.itemView),this.el=document.createElement(this.tagName),this.el.className=this.className,this.$el=$(this.el),this.parent=e.parent;var t=this.collection=this.get("collection");t.each(this.addItem,this),t.on("add",this.addItem,this),t.on("remove",this.removeItem,this)},addItem:function(e){e.view||(e.view=new this.itemView({model:e,parent:this.parent}),e.view.render()),this.prepend?this.$el.prepend(e.view.el):this.$el.append(e.view.el)},removeItem:function(e){e.view.remove()}})}(),function(e){var t=Backbone.Model.extend({});e.prototype.loadState=function(){var e="dataflow-"+(this.id?this.id:this.cid),o=JSON.parse(window.localStorage.getItem(e));o||(o={});var i=new t(o);this.set("state",i),i.on("change",function(t){window.localStorage.setItem(e,JSON.stringify(t.toJSON()))})}}(Dataflow),function(e){var t=e.prototype.module("graph"),o=e.prototype.module("node"),i=e.prototype.module("edge");t.Model=Backbone.Model.extend({defaults:{nodes:[],edges:[],panX:0,panY:0,zoom:1},initialize:function(){this.dataflow=this.get("dataflow");var e,t=this.nodes=new o.Collection;t.parentGraph=this,t.on("all",function(){this.trigger("change")},this),t.on("add",function(e){this.dataflow.trigger("node:add",this,e)},this),t.on("remove",function(e){e.remove(),this.dataflow.trigger("node:remove",this,e)},this);var n=this.get("nodes");for(e=0;n.length>e;e++){var a=n[e];a.parentGraph=this,a.type&&this.dataflow.nodes[a.type]?(a=new this.dataflow.nodes[a.type].Model(a),t.add(a)):this.dataflow.log("node "+a.id+" not added: node type ("+a.type+") not found",a)}var s=this.edges=new i.Collection;s.parentGraph=this,s.on("all",function(){this.trigger("change")},this),s.on("add",function(e){this.dataflow.trigger("edge:add",this,e)},this),s.on("remove",function(e){this.dataflow.trigger("edge:remove",this,e)},this);var r=this.get("edges");for(e=0;r.length>e;e++){var d=r[e];d.parentGraph=this,d.id=d.source.node+":"+d.source.port+"::"+d.target.node+":"+d.target.port;var l=t.get(d.source.node),h=t.get(d.target.node);l&&h&&l.outputs.get(d.source.port)&&h.inputs.get(d.target.port)?(d=new i.Model(d),s.add(d)):this.dataflow.log("edge "+d.id+" not added: node or port not found",d)}this.set({nodes:t,edges:s}),this.on("selectionChanged",this.selectionChanged,this),this.on("select:node",this.selectNode,this),this.on("select:edge",this.selectEdge,this),this.on("change",function(){this.dataflow.trigger("change",this)},this)},selectNode:function(e){this.dataflow.trigger("select:node",this,e)},selectEdge:function(e){this.dataflow.trigger("select:edge",this,e)},selectionChanged:function(){var e=this.nodes.where({selected:!0}),t=this.edges.where({selected:!0});this.dataflow.changeContext(e,t)},remove:function(){for(;this.nodes.length>0;)this.nodes.remove(this.nodes.at(this.nodes.length-1))},toJSON:function(){return{nodes:this.nodes,edges:this.edges}}})}(Dataflow),function(e){var t=e.prototype.module("node"),o=e.prototype.module("input"),i=e.prototype.module("output");t.Model=Backbone.Model.extend({defaults:function(){return{label:"",description:"",type:"test",x:200,y:100,state:{},selected:!1}},initialize:function(){this.parentGraph=this.get("parentGraph"),this.type=this.get("type"),""===this.get("label")&&this.set({label:this.get("type")});var e=this.inputs;this.inputs=new o.Collection,this.inputs.parentNode=this;for(var t=0;e.length>t;t++){var n=e[t],a=this.get("state");void 0!==n.value&&void 0===a[n.id]&&(a[n.id]=n.value),n.parentNode=this,n=new o.Model(n),this.inputs.add(n)}var s=this.outputs;for(this.outputs=new i.Collection,this.outputs.parentNode=this,t=0;s.length>t;t++){var r=s[t];r.parentNode=this,r=new i.Model(r),this.outputs.add(r)}this.on("change:selected",this.changeSelected,this)},changeSelected:function(){this.get("selected")&&this.parentGraph.trigger("select:node",this)},setState:function(e,t){var o=this.get("state");o[e]!==t&&(o[e]=t,this["input"+e]&&this["input"+e](t),this.trigger("change:state",e,t))},setBang:function(e){this["input"+e]&&this["input"+e](),this.trigger("bang",e)},send:function(e,t){var o=this;_.defer(function(){o.trigger("send:"+e,t)})},recieve:function(e,t){"function"==typeof this["input"+e]?this["input"+e](t):this["_"+e]=t},remove:function(){this.inputs.each(function(e){e.remove()}),this.outputs.each(function(e){e.remove()}),this.unload(),this.collection.remove(this),this.trigger("remove")},unload:function(){},toString:function(){return this.id+" ("+this.type+")"},toJSON:function(){return{id:this.get("id"),label:this.get("label"),type:this.get("type"),x:this.get("x"),y:this.get("y"),state:this.get("state")}},inputs:[],outputs:[]}),t.Collection=Backbone.Collection.extend({model:t.Model,comparator:function(e){return e.get("x")}})}(Dataflow),function(e){var t=e.prototype.module("input");t.Model=Backbone.Model.extend({defaults:{id:"input",description:"",label:"",type:"all"},initialize:function(){this.parentNode=this.get("parentNode"),""===this.get("label")&&this.set({label:this.id}),this.connected=[]},connect:function(e){this.connected.push(e),this.connected=_.uniq(this.connected),this.trigger("connected")},disconnect:function(e){this.connected=_.without(this.connected,e),0===this.connected.length&&this.trigger("disconnected")},remove:function(){for(;this.connected.length>0;)this.connected[0].remove()}}),t.Collection=Backbone.Collection.extend({model:t.Model})}(Dataflow),function(e){var t=e.prototype.module("input"),o=e.prototype.module("output");o.Model=t.Model.extend({defaults:{id:"output",label:"",type:"all",description:""}}),o.Collection=Backbone.Collection.extend({model:o.Model})}(Dataflow),function(e){var t=e.prototype.module("edge");t.Model=Backbone.Model.extend({defaults:{z:0,route:0,selected:!1,log:null},initialize:function(){var e,t,o,i=this.get("preview");if(this.parentGraph=this.get("parentGraph"),this.attributes.log=new CircularBuffer(50),i){e=this.get("parentGraph").nodes;var n=this.get("source"),a=this.get("target");n?(t=e.get(this.get("source").node),this.source=t.outputs.get(this.get("source").port)):a&&(o=e.get(this.get("target").node),this.target=o.inputs.get(this.get("target").port))}else{e=this.parentGraph.nodes;try{t=e.get(this.get("source").node),this.source=t.outputs.get(this.get("source").port),o=e.get(this.get("target").node),this.target=o.inputs.get(this.get("target").port)}catch(s){}this.source.connect(this),this.target.connect(this),t.on("send:"+this.source.id,this.send,this),this.bringToTop(),this.on("select",this.select,this)}},select:function(){this.parentGraph.trigger("select:edge",this)},send:function(e){this.target.parentNode.recieve(this.target.id,e)},isConnectedToPort:function(e){return this.source===e||this.target===e},isConnectedToNode:function(e){return this.source.parentNode===e||this.target.parentNode===e},toString:function(){return this.id?this.id:this.get("source").node+":"+this.get("source").port+"::"+this.get("target").node+":"+this.get("target").port},toJSON:function(){return{source:this.get("source"),target:this.get("target"),route:this.get("route")}},bringToTop:function(){var e=0;this.parentGraph.edges.each(function(t){if(t!==this){var o=t.get("z");o>e&&(e=o),t.view&&t.view.unhighlight()}},this),this.set("z",e+1)},remove:function(){this.source.disconnect(this),this.target.disconnect(this),this.collection&&this.collection.remove(this),this.source.parentNode.off("send:"+this.source.id,this.send,this),this.trigger("remove")}}),t.Collection=Backbone.Collection.extend({model:t.Model,comparator:function(e){return e.get("z")}})}(Dataflow),function(e){var t=e.prototype.module("graph");e.prototype.module("node");var o=e.prototype.module("edge"),i=.2,n=1.1;document.createElement("div").style.hasOwnProperty("zoom");var a='
';t.View=Backbone.View.extend({template:_.template(a),className:"dataflow-g",events:{"click .dataflow-graph":"deselect","dragstart .dataflow-graph-panzoom":"panStart","drag .dataflow-graph-panzoom":"pan","dragstop .dataflow-graph-panzoom":"panStop","click .dataflow-graph-gotoparent":"gotoParent",mousewheel:"mouseWheel"},initialize:function(){this.$el.html(this.template(this.model.toJSON()));var e=this.model.get("nodes"),t=this.model.get("edges");this.nodes=e.view={},this.model.nodes.each(this.addNode,this),this.model.nodes.on("add",this.addNode,this),this.model.nodes.on("remove",this.removeNode,this),this.edges=t.view={},this.model.edges.each(this.addEdge,this),this.model.edges.on("add",this.addEdge,this),this.model.edges.on("remove",this.removeEdge,this);var o=this.model.get("parentNode");o||this.$(".dataflow-graph-controls").hide(),this.$(".dataflow-graph-panzoom").draggable({helper:function(){var e=$("
");return this.model.dataflow.$el.append(e),e}.bind(this)}),this.$graphEl=this.$(".dataflow-graph"),this.graphEl=this.$(".dataflow-graph")[0],this.$graphEl.css({transform:"translate3d(0, 0, 0) scale3d(1, 1, 1) ",transformOrigin:"left top"}),this.bindInteraction()},panStartOffset:null,panStart:function(e,t){t&&(this.panStartOffset=t.offset)},pan:function(e,t){if(t){var o=this.model.get("zoom"),i=t.offset.left-this.panStartOffset.left,n=t.offset.top-this.panStartOffset.top;this.$(".dataflow-graph").css({transform:"translate3d("+i/o+"px, "+n/o+"px, 0)"})}},panStop:function(e,t){this.$(".dataflow-graph").css({transform:"translate3d(0, 0, 0)"});var o=this.model.get("zoom"),i=t.offset.left-this.panStartOffset.left,n=t.offset.top-this.panStartOffset.top;this.model.set({panX:this.model.get("panX")+i/o,panY:this.model.get("panY")+n/o})},tempPanX:0,tempPanY:0,setPanDebounce:_.debounce(function(){this.$(".dataflow-graph").css({transform:"translate3d(0, 0, 0)"}),this.model.set({panX:this.model.get("panX")+this.tempPanX,panY:this.model.get("panY")+this.tempPanY}),this.tempPanX=0,this.tempPanY=0},250),mouseWheel:function(e){e.preventDefault();var t=e.originalEvent;this.tempPanX+=t.wheelDeltaX/6,this.tempPanY+=t.wheelDeltaY/6,this.$(".dataflow-graph").css({transform:"translate3d("+this.tempPanX+"px, "+this.tempPanY+"px, 0)"}),this.setPanDebounce()},gotoParent:function(){var e=this.model.get("parentNode");e&&this.model.dataflow.showGraph(e.parentGraph)},bindInteraction:function(){this.bindZoom(),this.bindScroll()},bindZoom:function(){if(window.Hammer){var e,t,o,a,s,r,d,l,h,p,c=this;Hammer(this.$(".dataflow-graph-panzoom")[0]).on("transformstart",function(i){e=c.model.get("zoom"),t=i.gesture.center.pageX,o=i.gesture.center.pageY,a=t/e,s=o/e;var n=c.$el.offset();h=a-n.left,p=s-n.top,c.$graphEl.css({transformOrigin:a+"px "+s+"px"})}).on("transform",function(a){r=Math.max(i/e,Math.min(a.gesture.scale,n/e)),d=(a.gesture.center.pageX-t)/e,l=(a.gesture.center.pageY-o)/e,c.$graphEl.css({transform:"translate3d("+d+"px,"+l+"px, 0) "+"scale3d("+r+","+r+", 1) "})}).on("transformend",function(){c.$graphEl.css({transform:"translate3d(0, 0, 0) scale3d(1, 1, 1) "});var t=e*r;t=Math.max(i,Math.min(t,n)),c.model.set("zoom",t),h*=t,p*=t,c.model.set({panX:c.model.get("panX")+d,panY:c.model.get("panY")+l}),console.log(c.model.attributes)});var u=function(){var e=c.model.get("zoom"),t=c.zoomClass;c.zoomClass=.5>e?"zoom-tiny":.8>e?"zoom-small":1.3>e?"zoom-normal":"zoom-big",c.$graphEl.removeClass(t).addClass(c.zoomClass),c.graphEl.style.zoom=c.model.get("zoom")};this.model.on("change:zoom",u),1!==this.model.get("zoom")&&u()}},zoomClass:1,zoomIn:function(){var e=this.model.get("zoom"),t=.9*e;t=Math.max(i,t),t!==e&&this.model.set("zoom",t)},zoomOut:function(){var e=this.model.get("zoom"),t=1.1*e;t=Math.min(n,t),t!==e&&this.model.set("zoom",t)},zoomCenter:function(){var e=this.model.get("zoom"),t=1;t!==e&&this.model.set("zoom",1)},bindScroll:function(){},render:function(){var e=this;return _.defer(function(){e.rerenderEdges()},this),this},addNode:function(e){var t=this.model.dataflow.nodes[e.type];if(t&&t.View)e.view=new t.View({model:e,graph:this});else{var o=this.model.dataflow.node("base");e.view=new o.View({model:e,graph:this})}this.nodes[e.id]=e.view,e.view.render(),this.$(".dataflow-nodes").append(e.view.el)},removeNode:function(e){e.view.remove(),this.nodes[e.id]=null,delete this.nodes[e.id]},addEdge:function(e){e.view=new o.View({model:e}),this.edges[e.id]=e.view,e.view.render(),this.$(".dataflow-svg-edges")[0].appendChild(e.view.el)},removeEdge:function(e){e.view&&e.view.remove(),this.edges[e.id]=null,delete this.edges[e.id]},rerenderEdges:function(){_.each(this.edges,function(e){e.render()},this)},sizeSVG:function(){try{var e=this.$(".dataflow-svg-edges")[0],t=e.getBBox(),o=Math.max(Math.round(t.x+t.width+50),50),i=Math.max(Math.round(t.y+t.height+50),50);e.setAttribute("width",o),e.setAttribute("height",i)}catch(n){}},deselect:function(){this.model.nodes.invoke("set",{selected:!1}),this.model.edges.invoke("set",{selected:!1}),this.model.trigger("selectionChanged"),this.unfade(),this.model.dataflow.hideCards()},fade:function(){this.model.nodes.each(function(e){e.view&&(e.get("selected")||e.view.fade())}),this.fadeEdges()},fadeEdges:function(){this.model.edges.each(function(e){e.get("selected")||e.source.parentNode.get("selected")||e.target.parentNode.get("selected")?e.view.unfade():e.view.fade()})},unfade:function(){this.model.nodes.each(function(e){e.view&&e.view.unfade()}),this.model.edges.each(function(e){e.view&&e.view.unfade()})}})}(Dataflow),function(e){var t,o=e.prototype.module("node"),i=e.prototype.module("input"),n=e.prototype.module("output"),a='

<%- label %>

',s="";o.View=Backbone.View.extend({template:_.template(a),innerTemplate:_.template(s),className:"dataflow-node",events:function(){return{"click .dataflow-node-header":"select",dragstart:"dragStart",drag:"drag",dragstop:"dragStop"}},initialize:function(e){this.$el.html(this.template(this.model.toJSON())),this.graph=e.graph,this.$el.addClass(this.model.type),this.model.parentGraph.dataflow.editable||this.$(".dataflow-node-edit").hide(),this.inputs=this.model.inputs.view=new i.CollectionView({collection:this.model.inputs,parent:this}),this.outputs=this.model.outputs.view=new n.CollectionView({collection:this.model.outputs,parent:this}),this.$el.draggable({handle:"h1",helper:function(){return $("
")}}),this.$el.data("dataflow-node-view",this),this.$(".dataflow-node-inner").append(this.innerTemplate),this.listenTo(this.model.parentGraph,"change:panX change:panY",this.bumpPosition),this.listenTo(this.model,"change:selected",this.selectedChanged),this.listenTo(this.model,"change:label",this.changeLabel),this.listenTo(this.model,"remove",this.hideInspector),this.$inner=this.$(".dataflow-node-inner")},render:function(){return this.$el.css({left:this.model.get("x")+this.model.parentGraph.get("panX"),top:this.model.get("y")+this.model.parentGraph.get("panY")}),this.$(".dataflow-node-ins").html(this.inputs.el),this.$(".dataflow-node-outs").html(this.outputs.el),this.$(".dataflow-node-controls").hide(),this.$(".label-edit").hide(),this},_alsoDrag:[],_dragDelta:{},$dragHelpers:$('
'),dragStart:function(e,o){o&&(this.model.get("selected")||this.select(e,!0),e.stopPropagation(),t=this.model.parentGraph.get("zoom"),this.$dragHelpers.css({transform:"translate3d(0,0,0)"}),this.$el.parent().append(this.$dragHelpers),this._alsoDrag=this.model.collection.where({selected:!0}),_.each(this._alsoDrag,function(e){var t=e.view.$el,o=$('
').css({width:t.width(),height:t.height(),left:parseInt(t.css("left"),10),top:parseInt(t.css("top"),10)});this.$dragHelpers.append(o)},this))},changeLabel:function(){var e=this.model.get("label"),t=this.model.get("type");this.$(".dataflow-node-title").text(e).attr("title",e+": "+t)},drag:function(e,o){if(o){e.stopPropagation();var i=(o.position.left-o.originalPosition.left)/t,n=(o.position.top-o.originalPosition.top)/t;this.$dragHelpers.css({transform:"translate3d("+i+"px,"+n+"px,0)"})}},dragStop:function(e,o){if(o){e.stopPropagation(),this.model.parentGraph.get("panX"),this.model.parentGraph.get("panY");var i=(o.position.left-o.originalPosition.left)/t,n=(o.position.top-o.originalPosition.top)/t;this._alsoDrag.length&&(_.each(this._alsoDrag,function(e){e.view.moveToPosition(e.get("x")+i,e.get("y")+n)},this),this._alsoDrag=[]),this.$dragHelpers.empty(),this.$dragHelpers.remove()}},bumpPosition:function(){this.$el.css({left:this.model.get("x")+this.model.parentGraph.get("panX"),top:this.model.get("y")+this.model.parentGraph.get("panY")}),this.model.trigger("change:x change:y")},moveToPosition:function(e,t){this.model.set({x:e,y:t},{silent:!0}),this.bumpPosition()},removeModel:function(){this.model.remove()},bringToTop:function(){var e=0;this.model.collection.each(function(t){var o=parseInt(t.view.el.style.zIndex,10);o>e&&(e=o)},this),this.el.style.zIndex=e+1},select:function(e){e&&e.stopPropagation();var t=!1,o=this.model.get("selected");e&&(e.ctrlKey||e.metaKey)?(t=!0,o=!o,this.model.set("selected",o),o||this.fade()):(this.model.parentGraph.edges.invoke("set",{selected:!1}),this.model.parentGraph.nodes.invoke("set",{selected:!1}),this.model.parentGraph.view.fade(),o=!0,this.model.set("selected",!0)),this.bringToTop(),this.model.parentGraph.view.fadeEdges(),this.model.parentGraph.trigger("selectionChanged")},inspector:null,getInspector:function(){if(!this.inspector){var t=new o.InspectView({model:this.model}),i=e.prototype.module("card");this.inspector=new i.Model({dataflow:this.model.parentGraph.dataflow,card:t})}return this.inspector},showInspector:function(e){this.model.parentGraph.dataflow.addCard(this.getInspector(),e)},hideInspector:function(){this.model.parentGraph.dataflow.removeCard(this.getInspector())},fade:function(){this.$el.addClass("fade"),this.$el.removeClass("ui-selected")},unfade:function(){this.$el.removeClass("fade")},selectedChanged:function(){this.model.get("selected")?(this.highlight(),this.showInspector()):(this.unhighlight(),this.hideInspector())},highlight:function(){this.$el.removeClass("fade"),this.$el.addClass("ui-selected")},unhighlight:function(){this.$el.removeClass("ui-selected")}})}(Dataflow),function(e){var t=e.prototype.module("input"),o=e.prototype.module("edge"),i='',n=1;t.View=Backbone.View.extend({template:_.template(i),tagName:"li",className:"dataflow-port dataflow-in",events:{click:"getTopEdge",drop:"connectEdge","dragstart .dataflow-port-hole":"newEdgeStart","drag .dataflow-port-hole":"newEdgeDrag","dragstop .dataflow-port-hole":"newEdgeStop","dragstart .dataflow-port-plug":"changeEdgeStart","drag .dataflow-port-plug":"changeEdgeDrag","dragstop .dataflow-port-plug":"changeEdgeStop"},$input:null,initialize:function(e){this.$el.html(this.template(this.model.toJSON())),this.$el.addClass(this.model.get("type")),this.parent=e.parent;var t=this.parent.model,o=t.parentGraph;this.listenTo(t,"change:x change:y",function(){this._holePosition=null}.bind(this)),this.listenTo(o,"change:panX change:panY",function(){this._holePosition=null}.bind(this));var i=t.get("state");if(i&&i[this.model.id]&&this.$el.addClass("hasvalue"),this.model.parentNode.parentGraph.dataflow.editable){var n=this;if(this.$(".dataflow-port-plug").draggable({cursor:"pointer",helper:function(){var e=$('');return n.parent.graph.$el.append(e),e},disabled:!0,distance:10,delay:100}),this.$(".dataflow-port-hole").draggable({cursor:"pointer",helper:function(){var e=$('').data({port:n.model});return n.parent.graph.$el.append(e),e}}),this.$el.droppable({accept:".dataflow-port-plug.in, .dataflow-port-hole.out",activeClassType:"droppable-hover",refreshPositions:!0}),this.model.parentNode.parentGraph.dataflow.inputs){var a=this.model.get("type"),s=this.model.parentNode.get("state");if(e=this.model.get("options"),void 0!==e&&(_.isString(e)&&(e=e.split(" "),this.model.set("options",e)),_.isArray(e))){for(var r={},d=0;e.length>d;d++)r[e[d]]=e[d];e=r,this.model.set("options",e)}var l,h=this.renderInput(a,e);s&&void 0!==s[this.model.id]?l=s[this.model.id]:void 0!==this.model.get("value")&&(l=this.model.get("value")),this.setInputValue(h,a,l),this.model.parentNode.on("change:state",function(){var e=this.model.parentNode.get("state");return e&&void 0!==e[this.model.id]?(this.setInputValue(h,a,e[this.model.id]),this.$el.addClass("hasvalue"),void 0):(this.$el.removeClass("hasvalue"),void 0)}.bind(this));var p=$('