/* js-mindmap Copyright (c) 2008/09/10 Kenneth Kufluk http://kenneth.kufluk.com/ MIT (X11) license Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ (function($){ var TIMEOUT = 4; // movement timeout in seconds var CENTRE_FORCE = 3; // strength of attraction to the centre by the active node // Define all Node related functions. function Node(obj, name, parent, opts){ this.obj = obj; this.options = obj.options; this.name = name; this.href = opts.href; if (opts.url) this.url = opts.url; this.el = $(''+this.name+''); this.el.addClass('node'); $('body').prepend(this.el); if (!parent) { obj.activeNode = this; $(this.el).addClass('active'); $(this.el).addClass('root'); } else { var lineno = obj.lines.length; obj.lines[lineno] = new Line(obj, this, parent); } this.parent = parent; this.children = new Array(); if (this.parent) this.parent.children.push(this); this.moving = false; this.moveTimer = 0; this.obj.movementStopped = false; this.visible = true; this.hasLayout = true; this.x = 1; this.y = 1; this.dx = 0; this.dy = 0; this.hasPosition = false; this.content = []; // array of content elements to display onclick; this.el.css('position','absolute'); var thisnode = this; this.el.draggable({ drag:function() { obj.root.animateToStatic(); } }); this.el.click(function(){ /* if (obj.activeNode==thisnode) { if (thisnode.url) location.href=thisnode.url; else location.href=this.href; return false; } */ if (obj.activeNode) { obj.activeNode.el.removeClass('active'); /* // remove the activeNodes children // except, obviously, the node in question (doh!) var kids = obj.activeNode.children; var selfIsKid = false; for (var i=0;i