--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/server/python/django/renkanmanager/static/renkanmanager/lib/renkan/js/renkan.js Wed Dec 17 16:32:46 2014 +0100
@@ -0,0 +1,4908 @@
+/*!
+ * _____ _
+ * | __ \ | |
+ * | |__) |___ _ __ | | ____ _ _ __
+ * | _ // _ \ '_ \| |/ / _` | '_ \
+ * | | \ \ __/ | | | < (_| | | | |
+ * |_| \_\___|_| |_|_|\_\__,_|_| |_|
+ *
+ * Copyright 2012-2013 Institut de recherche et d'innovation
+ * contributor(s) : Yves-Marie Haussonne, Raphael Velt, Samuel Huron
+ *
+ * contact@iri.centrepompidou.fr
+ * http://www.iri.centrepompidou.fr
+ *
+ * This software is a computer program whose purpose is to show and add annotations on a video .
+ * This software is governed by the CeCILL-C license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL-C
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL-C license and that you accept its terms.
+ */
+/*! renkan - v0.7.11 - Copyright © IRI 2014 */
+
+
+/* Declaring the Renkan Namespace Rkns and Default values */
+
+(function(root) {
+
+"use strict";
+
+if (typeof root.Rkns !== "object") {
+ root.Rkns = {};
+}
+
+var Rkns = root.Rkns;
+var $ = Rkns.$ = root.jQuery;
+var _ = Rkns._ = root._;
+
+Rkns.pickerColors = ["#8f1919", "#a80000", "#d82626", "#ff0000", "#e87c7c", "#ff6565", "#f7d3d3", "#fecccc",
+ "#8f5419", "#a85400", "#d87f26", "#ff7f00", "#e8b27c", "#ffb265", "#f7e5d3", "#fee5cc",
+ "#8f8f19", "#a8a800", "#d8d826", "#feff00", "#e8e87c", "#feff65", "#f7f7d3", "#fefecc",
+ "#198f19", "#00a800", "#26d826", "#00ff00", "#7ce87c", "#65ff65", "#d3f7d3", "#ccfecc",
+ "#198f8f", "#00a8a8", "#26d8d8", "#00feff", "#7ce8e8", "#65feff", "#d3f7f7", "#ccfefe",
+ "#19198f", "#0000a8", "#2626d8", "#0000ff", "#7c7ce8", "#6565ff", "#d3d3f7", "#ccccfe",
+ "#8f198f", "#a800a8", "#d826d8", "#ff00fe", "#e87ce8", "#ff65fe", "#f7d3f7", "#feccfe",
+ "#000000", "#242424", "#484848", "#6d6d6d", "#919191", "#b6b6b6", "#dadada", "#ffffff"];
+
+Rkns.__renkans = [];
+
+var _BaseBin = Rkns._BaseBin = function(_renkan, _opts) {
+ if (typeof _renkan !== "undefined") {
+ this.renkan = _renkan;
+ this.renkan.$.find(".Rk-Bin-Main").hide();
+ this.$ = Rkns.$('<li>')
+ .addClass("Rk-Bin")
+ .appendTo(_renkan.$.find(".Rk-Bin-List"));
+ this.title_icon_$ = Rkns.$('<span>')
+ .addClass("Rk-Bin-Title-Icon")
+ .appendTo(this.$);
+
+ var _this = this;
+
+ Rkns.$('<a>')
+ .attr({
+ href: "#",
+ title: _renkan.translate("Close bin")
+ })
+ .addClass("Rk-Bin-Close")
+ .html('×')
+ .appendTo(this.$)
+ .click(function() {
+ _this.destroy();
+ if (!_renkan.$.find(".Rk-Bin-Main:visible").length) {
+ _renkan.$.find(".Rk-Bin-Main:last").slideDown();
+ }
+ _renkan.resizeBins();
+ return false;
+ });
+ Rkns.$('<a>')
+ .attr({
+ href: "#",
+ title: _renkan.translate("Refresh bin")
+ })
+ .addClass("Rk-Bin-Refresh")
+ .appendTo(this.$)
+ .click(function() {
+ _this.refresh();
+ return false;
+ });
+ this.count_$ = Rkns.$('<div>')
+ .addClass("Rk-Bin-Count")
+ .appendTo(this.$);
+ this.title_$ = Rkns.$('<h2>')
+ .addClass("Rk-Bin-Title")
+ .appendTo(this.$);
+ this.main_$ = Rkns.$('<div>')
+ .addClass("Rk-Bin-Main")
+ .appendTo(this.$)
+ .html('<h4 class="Rk-Bin-Loading">' + _renkan.translate("Loading, please wait") + '</h4>');
+ this.title_$.html(_opts.title || '(new bin)');
+ this.renkan.resizeBins();
+
+ if (_opts.auto_refresh) {
+ window.setInterval(function() {
+ _this.refresh();
+ },_opts.auto_refresh);
+ }
+ }
+};
+
+_BaseBin.prototype.destroy = function() {
+ this.$.detach();
+ this.renkan.resizeBins();
+};
+
+/* Point of entry */
+
+var Renkan = Rkns.Renkan = function(_opts) {
+ var _this = this;
+
+ Rkns.__renkans.push(this);
+
+ this.options = _.defaults(_opts, Rkns.defaults);
+
+ _(this.options.property_files).each(function(f) {
+ Rkns.$.getJSON(f, function(data) {
+ _this.options.properties = _this.options.properties.concat(data);
+ });
+ });
+
+ this.read_only = this.options.read_only || !this.options.editor_mode;
+
+ this.project = new Rkns.Models.Project();
+
+ if (typeof this.options.user_id !== "undefined") {
+ this.current_user = this.options.user_id;
+ }
+ this.$ = Rkns.$("#" + this.options.container);
+ this.$
+ .addClass("Rk-Main")
+ .html(this.template(this));
+
+ this.tabs = [];
+ this.search_engines = [];
+
+ this.current_user_list = new Rkns.Models.UsersList();
+
+ this.current_user_list.on("add remove", function() {
+ if (this.renderer) {
+ this.renderer.redrawUsers();
+ }
+ });
+
+ this.colorPicker = (function() {
+ var _tmpl = _.template('<li data-color="<%=c%>" style="background: <%=c%>"></li>');
+ return '<ul class="Rk-Edit-ColorPicker">' + Rkns.pickerColors.map(function(c) { return _tmpl({c:c});}).join("") + '</ul>';
+ })();
+
+ if (this.options.show_editor) {
+ this.renderer = new Rkns.Renderer.Scene(this);
+ }
+
+ if (!this.options.search.length) {
+ this.$.find(".Rk-Web-Search-Form").detach();
+ } else {
+ var _tmpl = _.template('<li class="<%= className %>" data-key="<%= key %>"><%= title %></li>'),
+ _select = this.$.find(".Rk-Search-List"),
+ _input = this.$.find(".Rk-Web-Search-Input"),
+ _form = this.$.find(".Rk-Web-Search-Form");
+ _(this.options.search).each(function(_search, _key) {
+ if (Rkns[_search.type] && Rkns[_search.type].Search) {
+ _this.search_engines.push(new Rkns[_search.type].Search(_this, _search));
+ }
+ });
+ _select.html(
+ _(this.search_engines).map(function(_search, _key) {
+ return _tmpl({
+ key: _key,
+ title: _search.getSearchTitle(),
+ className: _search.getBgClass()
+ });
+ }).join("")
+ );
+ _select.find("li").click(function() {
+ var _el = Rkns.$(this);
+ _this.setSearchEngine(_el.attr("data-key"));
+ _form.submit();
+ });
+ _form.submit(function() {
+ if (_input.val()) {
+ var _search = _this.search_engine;
+ _search.search(_input.val());
+ }
+ return false;
+ });
+ this.$.find(".Rk-Search-Current").mouseenter(
+ function() { _select.slideDown(); }
+ );
+ this.$.find(".Rk-Search-Select").mouseleave(
+ function() { _select.hide(); }
+ );
+ this.setSearchEngine(0);
+ }
+ _(this.options.bins).each(function(_bin) {
+ if (Rkns[_bin.type] && Rkns[_bin.type].Bin) {
+ _this.tabs.push(new Rkns[_bin.type].Bin(_this, _bin));
+ }
+ });
+
+ var elementDropped = false;
+
+ this.$.find(".Rk-Bins")
+ .on("click",".Rk-Bin-Title,.Rk-Bin-Title-Icon", function() {
+ var _mainDiv = Rkns.$(this).siblings(".Rk-Bin-Main");
+ if (_mainDiv.is(":hidden")) {
+ _this.$.find(".Rk-Bin-Main").slideUp();
+ _mainDiv.slideDown();
+ }
+ });
+
+ if (this.options.show_editor) {
+
+ this.$.find(".Rk-Bins").on("mouseover", ".Rk-Bin-Item", function(_e) {
+ var _t = Rkns.$(this);
+ if (_t && $(_t).attr("data-uri")) {
+ var _models = _this.project.get("nodes").where({
+ uri: $(_t).attr("data-uri")
+ });
+ _(_models).each(function(_model) {
+ _this.renderer.highlightModel(_model);
+ });
+ }
+ }).mouseout(function() {
+ _this.renderer.unhighlightAll();
+ }).on("mousemove", ".Rk-Bin-Item", function(e) {
+ try {
+ this.dragDrop();
+ }
+ catch(err) {}
+ }).on("touchstart", ".Rk-Bin-Item", function(e) {
+ elementDropped = false;
+ }).on("touchmove", ".Rk-Bin-Item", function(e) {
+ e.preventDefault();
+ var touch = e.originalEvent.changedTouches[0],
+ off = _this.renderer.canvas_$.offset(),
+ w = _this.renderer.canvas_$.width(),
+ h = _this.renderer.canvas_$.height();
+ if (touch.pageX >= off.left && touch.pageX < (off.left + w) && touch.pageY >= off.top && touch.pageY < (off.top + h)) {
+ if (elementDropped) {
+ _this.renderer.onMouseMove(touch, true);
+ } else {
+ elementDropped = true;
+ var div = document.createElement('div');
+ div.appendChild(this.cloneNode(true));
+ _this.renderer.dropData({"text/html": div.innerHTML}, touch);
+ _this.renderer.onMouseDown(touch, true);
+ }
+ }
+ }).on("touchend", ".Rk-Bin-Item", function(e) {
+ if (elementDropped) {
+ _this.renderer.onMouseUp(e.originalEvent.changedTouches[0], true);
+ }
+ elementDropped = false;
+ }).on("dragstart", ".Rk-Bin-Item", function(e) {
+ var div = document.createElement('div');
+ div.appendChild(this.cloneNode(true));
+ try {
+ e.originalEvent.dataTransfer.setData("text/html",div.innerHTML);
+ }
+ catch(err) {
+ e.originalEvent.dataTransfer.setData("text",div.innerHTML);
+ }
+ });
+
+ }
+
+ Rkns.$(window).resize(function() {
+ _this.resizeBins();
+ });
+
+ var lastsearch = false, lastval = '';
+
+ this.$.find(".Rk-Bins-Search-Input").on("change keyup paste input", function() {
+ var val = Rkns.$(this).val();
+ if (val === lastval) {
+ return;
+ }
+ var search = Rkns.Utils.regexpFromTextOrArray(val.length > 1 ? val: null);
+ if (search.source === lastsearch) {
+ return;
+ }
+ lastsearch = search.source;
+ _(_this.tabs).each(function(tab) {
+ tab.render(search);
+ });
+
+ });
+ this.$.find(".Rk-Bins-Search-Form").submit(function() {
+ return false;
+ });
+
+};
+
+Renkan.prototype.template = _.template(
+ '<% if (options.show_bins) { %><div class="Rk-Bins"><div class="Rk-Bins-Head"><h2 class="Rk-Bins-Title"><%- translate("Select contents:")%></h2>' +
+ '<form class="Rk-Web-Search-Form Rk-Search-Form"><input class="Rk-Web-Search-Input Rk-Search-Input" type="search" placeholder="<%- translate("Search the Web") %>" />' +
+ '<div class="Rk-Search-Select"><div class="Rk-Search-Current"></div><ul class="Rk-Search-List"></ul></div>' +
+ '<input type="submit" value="" class="Rk-Web-Search-Submit Rk-Search-Submit" title="<%- translate("Search the Web") %>" /></form>' +
+ '<form class="Rk-Bins-Search-Form Rk-Search-Form"><input class="Rk-Bins-Search-Input Rk-Search-Input" type="search" placeholder="<%- translate("Search in Bins") %>" />' +
+ '<input type="submit" value="" class="Rk-Bins-Search-Submit Rk-Search-Submit" title="<%- translate("Search in Bins") %>" /></form></div>' +
+ '<ul class="Rk-Bin-List"></ul></div><% } %>' +
+ '<% if (options.show_editor) { %><div class="Rk-Render Rk-Render-<% if (options.show_bins) { %>Panel<% } else { %>Full<% } %>"></div><% } %>'
+);
+
+Renkan.prototype.translate = function(_text) {
+ if (Rkns.i18n[this.options.language] && Rkns.i18n[this.options.language][_text]) {
+ return Rkns.i18n[this.options.language][_text];
+ }
+ if (this.options.language.length > 2 && Rkns.i18n[this.options.language.substr(0,2)] && Rkns.i18n[this.options.language.substr(0,2)][_text]) {
+ return Rkns.i18n[this.options.language.substr(0,2)][_text];
+ }
+ return _text;
+};
+
+Renkan.prototype.onStatusChange = function() {
+ this.renderer.onStatusChange();
+};
+
+Renkan.prototype.setSearchEngine = function(_key) {
+ this.search_engine = this.search_engines[_key];
+ this.$.find(".Rk-Search-Current").attr("class","Rk-Search-Current " + this.search_engine.getBgClass());
+};
+
+Renkan.prototype.resizeBins = function() {
+ var _d = + this.$.find(".Rk-Bins-Head").outerHeight();
+ this.$.find(".Rk-Bin-Title:visible").each(function() {
+ _d += Rkns.$(this).outerHeight();
+ });
+ this.$.find(".Rk-Bin-Main").css({
+ height: this.$.find(".Rk-Bins").height() - _d
+ });
+};
+
+/* Utility functions */
+var getUUID4 = function() {
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
+ var r = Math.random()*16|0, v = c === 'x' ? r : (r&0x3|0x8);
+ return v.toString(16);
+ });
+};
+
+Rkns.Utils = {
+ getUUID4 : getUUID4,
+ getUID : (function() {
+ function pad(n){
+ return n<10 ? '0'+n : n;
+ }
+ var _d = new Date(),
+ ID_AUTO_INCREMENT = 0,
+ ID_BASE = _d.getUTCFullYear() + '-' +
+ pad(_d.getUTCMonth()+1) + '-' +
+ pad(_d.getUTCDate()) + '-' +
+ getUUID4();
+ return function(_base) {
+ var _n = (++ID_AUTO_INCREMENT).toString(16),
+ _uidbase = (typeof _base === "undefined" ? "" : _base + "-" );
+ while (_n.length < 4) { _n = '0' + _n; }
+ return _uidbase + ID_BASE + '-' + _n;
+ };
+ })(),
+ getFullURL : function(url) {
+
+ if(typeof(url) === 'undefined' || url == null ) {
+ return "";
+ }
+ if(/https?:\/\//.test(url)) {
+ return url;
+ }
+ var img = new Image();
+ img.src = url;
+ var res = img.src;
+ img.src = null;
+ return res;
+
+ },
+ inherit : function(_baseClass, _callbefore) {
+
+ var _class = function(_arg) {
+ if (typeof _callbefore === "function") {
+ _callbefore.apply(this, Array.prototype.slice.call(arguments, 0));
+ }
+ _baseClass.apply(this, Array.prototype.slice.call(arguments, 0));
+ if (typeof this._init === "function" && !this._initialized) {
+ this._init.apply(this, Array.prototype.slice.call(arguments, 0));
+ this._initialized = true;
+ }
+ };
+ _(_class.prototype).extend(_baseClass.prototype);
+
+ return _class;
+
+ },
+ regexpFromTextOrArray: (function() {
+ var charsub = [
+ '[aáàâä]',
+ '[cç]',
+ '[eéèêë]',
+ '[iíìîï]',
+ '[oóòôö]',
+ '[uùûü]'
+ ],
+ removeChars = [
+ String.fromCharCode(768), String.fromCharCode(769), String.fromCharCode(770), String.fromCharCode(771), String.fromCharCode(807),
+ "{", "}", "(", ")", "[", "]", "【", "】", "、", "・", "‥", "。", "「", "」", "『", "』", "〜", ":", "!", "?", " ",
+ ",", " ", ";", "(", ")", ".", "*", "+", "\\", "?", "|", "{", "}", "[", "]", "^", "#", "/"
+ ],
+ remsrc = "[\\" + removeChars.join("\\") + "]",
+ remrx = new RegExp(remsrc, "gm"),
+ charsrx = _(charsub).map(function(c) {
+ return new RegExp(c);
+ });
+
+ function replaceText(_text) {
+ var txt = _text.toLowerCase().replace(remrx,""), src = "";
+ function makeReplaceFunc(l) {
+ return function(k,v) {
+ l = l.replace(charsrx[k], v);
+ };
+ }
+ for (var j = 0; j < txt.length; j++) {
+ if (j) {
+ src += remsrc + "*";
+ }
+ var l = txt[j];
+ _(charsub).each(makeReplaceFunc(l));
+ src += l;
+ }
+ return src;
+ }
+
+ function getSource(inp) {
+ switch (typeof inp) {
+ case "string":
+ return replaceText(inp);
+ case "object":
+ var src = '';
+ _(inp).each(function(v) {
+ var res = getSource(v);
+ if (res) {
+ if (src) {
+ src += '|';
+ }
+ src += res;
+ }
+ });
+ return src;
+ }
+ return '';
+ }
+
+ return function(_textOrArray) {
+ var source = getSource(_textOrArray);
+ if (source) {
+ var testrx = new RegExp( source, "im"),
+ replacerx = new RegExp( '(' + source + ')', "igm");
+ return {
+ isempty: false,
+ source: source,
+ test: function(_t) { return testrx.test(_t); },
+ replace: function(_text, _replace) { return _text.replace(replacerx, _replace); }
+ };
+ } else {
+ return {
+ isempty: true,
+ source: '',
+ test: function() { return true; },
+ replace: function(_text) { return text; }
+ };
+ }
+ };
+ })(),
+ /* The minimum distance (in pixels) the mouse has to move to consider an element was dragged */
+ _MIN_DRAG_DISTANCE: 2,
+ /* Distance between the inner and outer radius of buttons that appear when hovering on a node */
+ _NODE_BUTTON_WIDTH: 40,
+
+ _EDGE_BUTTON_INNER: 2,
+ _EDGE_BUTTON_OUTER: 40,
+ /* Constants used to know if a specific action is to be performed when clicking on the canvas */
+ _CLICKMODE_ADDNODE: 1,
+ _CLICKMODE_STARTEDGE: 2,
+ _CLICKMODE_ENDEDGE: 3,
+ /* Node size step: Used to calculate the size change when clicking the +/- buttons */
+ _NODE_SIZE_STEP: Math.LN2/4,
+ _MIN_SCALE: 1/20,
+ _MAX_SCALE: 20,
+ _MOUSEMOVE_RATE: 80,
+ _DOUBLETAP_DELAY: 800,
+ /* Maximum distance in pixels (squared, to reduce calculations)
+ * between two taps when double-tapping on a touch terminal */
+ _DOUBLETAP_DISTANCE: 20*20,
+ /* A placeholder so a default colour is displayed when a node has a null value for its user property */
+ _USER_PLACEHOLDER: function(_renkan) {
+ return {
+ color: _renkan.options.default_user_color,
+ title: _renkan.translate("(unknown user)"),
+ get: function(attr) {
+ return this[attr] || false;
+ }
+ };
+ },
+ /* The code for the "Drag and Add Bookmarklet", slightly minified and with whitespaces removed, though
+ * it doesn't seem that it's still a requirement in newer browsers (i.e. the ones compatibles with canvas drawing)
+ */
+ _BOOKMARKLET_CODE: function(_renkan) {
+ return "(function(a,b,c,d,e,f,h,i,j,k,l,m,n,o,p,q,r){a=document;b=a.body;c=a.location.href;j='draggable';m='text/x-iri-';d=a.createElement('div');d.innerHTML='<p_style=\"position:fixed;top:0;right:0;font:bold_18px_sans-serif;color:#fff;background:#909;padding:10px;z-index:100000;\">" +
+ _renkan.translate("Drag items from this website, drop them in Renkan").replace(/ /g,"_") +
+ "</p>'.replace(/_/g,String.fromCharCode(32));b.appendChild(d);e=[{r:/https?:\\/\\/[^\\/]*twitter\\.com\\//,s:'.tweet',n:'twitter'},{r:/https?:\\/\\/[^\\/]*google\\.[^\\/]+\\//,s:'.g',n:'google'},{r:/https?:\\/\\/[^\\/]*lemonde\\.fr\\//,s:'[data-vr-contentbox]',n:'lemonde'}];f=false;e.forEach(function(g){if(g.r.test(c)){f=g;}});if(f){h=function(){Array.prototype.forEach.call(a.querySelectorAll(f.s),function(i){i[j]=true;k=i.style;k.borderWidth='2px';k.borderColor='#909';k.borderStyle='solid';k.backgroundColor='rgba(200,0,180,.1)';})};window.setInterval(h,500);h();};a.addEventListener('dragstart',function(k){l=k.dataTransfer;l.setData(m+'source-uri',c);l.setData(m+'source-title',a.title);n=k.target;if(f){o=n;while(!o.attributes[j]){o=o.parentNode;if(o==b){break;}}}if(f&&o.attributes[j]){p=o.cloneNode(true);l.setData(m+'specific-site',f.n)}else{q=a.getSelection();if(q.type==='Range'||!q.type){p=q.getRangeAt(0).cloneContents();}else{p=n.cloneNode();}}r=a.createElement('div');r.appendChild(p);l.setData('text/x-iri-selected-text',r.textContent.trim());l.setData('text/x-iri-selected-html',r.innerHTML);},false);})();";
+ },
+ /* Shortens text to the required length then adds ellipsis */
+ shortenText: function(_text, _maxlength) {
+ return (_text.length > _maxlength ? (_text.substr(0,_maxlength) + '…') : _text);
+ },
+ /* Drawing an edit box with an arrow and positioning the edit box according to the position of the node/edge being edited
+ * Called by Rkns.Renderer.NodeEditor and Rkns.Renderer.EdgeEditor */
+ drawEditBox: function(_options, _coords, _path, _xmargin, _selector) {
+ _selector.css({
+ width: ( _options.tooltip_width - 2* _options.tooltip_padding )
+ });
+ var _height = _selector.outerHeight() + 2* _options.tooltip_padding,
+ _isLeft = (_coords.x < paper.view.center.x ? 1 : -1),
+ _left = _coords.x + _isLeft * ( _xmargin + _options.tooltip_arrow_length ),
+ _right = _coords.x + _isLeft * ( _xmargin + _options.tooltip_arrow_length + _options.tooltip_width ),
+ _top = _coords.y - _height / 2;
+ if (_top + _height > (paper.view.size.height - _options.tooltip_margin)) {
+ _top = Math.max( paper.view.size.height - _options.tooltip_margin, _coords.y + _options.tooltip_arrow_width / 2 ) - _height;
+ }
+ if (_top < _options.tooltip_margin) {
+ _top = Math.min( _options.tooltip_margin, _coords.y - _options.tooltip_arrow_width / 2 );
+ }
+ var _bottom = _top + _height;
+ /* jshint laxbreak:true */
+ _path.segments[0].point
+ = _path.segments[7].point
+ = _coords.add([_isLeft * _xmargin, 0]);
+ _path.segments[1].point.x
+ = _path.segments[2].point.x
+ = _path.segments[5].point.x
+ = _path.segments[6].point.x
+ = _left;
+ _path.segments[3].point.x
+ = _path.segments[4].point.x
+ = _right;
+ _path.segments[2].point.y
+ = _path.segments[3].point.y
+ = _top;
+ _path.segments[4].point.y
+ = _path.segments[5].point.y
+ = _bottom;
+ _path.segments[1].point.y = _coords.y - _options.tooltip_arrow_width / 2;
+ _path.segments[6].point.y = _coords.y + _options.tooltip_arrow_width / 2;
+ _path.closed = true;
+ _path.fillColor = new paper.GradientColor(new paper.Gradient([_options.tooltip_top_color, _options.tooltip_bottom_color]), [0,_top], [0, _bottom]);
+ _selector.css({
+ left: (_options.tooltip_padding + Math.min(_left, _right)),
+ top: (_options.tooltip_padding + _top)
+ });
+ return _path;
+ }
+};
+})(window);
+
+/* END main.js */
+
+(function() {
+ "use strict";
+ var root = this;
+
+ var Backbone = root.Backbone;
+
+ var Models = root.Rkns.Models = {};
+
+
+ Models.getUID = function(obj) {
+ var guid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
+ var r = Math.random()*16|0, v = c === 'x' ? r : (r&0x3|0x8);
+ return v.toString(16);
+ });
+ if(typeof obj !== 'undefined') {
+ return obj.type + "-" + guid;
+ }
+ else {
+ return guid;
+ }
+ };
+
+
+ var RenkanModel = Backbone.RelationalModel.extend({
+ idAttribute : "_id",
+ constructor: function(options) {
+
+ if (typeof options !== "undefined") {
+ options._id = options._id || options.id || Models.getUID(this);
+ options.title = options.title || "";
+ options.description = options.description || "";
+ options.uri = options.uri || "";
+
+ if(typeof this.prepare === "function") {
+ options = this.prepare(options);
+ }
+ }
+ Backbone.RelationalModel.prototype.constructor.call(this, options);
+ },
+ validate: function() {
+ if(!this.type) {
+ return "object has no type";
+ }
+ },
+ addReference : function(_options, _propName, _list, _id, _default) {
+ var _element = _list.get(_id);
+ if (typeof _element === "undefined" && typeof _default !== "undefined") {
+ _options[_propName ] = _default;
+ }
+ else {
+ _options[_propName ] = _element;
+ }
+ }
+ });
+
+ // USER
+ var User = Models.User = RenkanModel.extend({
+ type: "user",
+ prepare: function(options) {
+ options.color = options.color || "#666666";
+ return options;
+ },
+ toJSON: function() {
+ return {
+ _id: this.get("_id"),
+ title: this.get("title"),
+ uri: this.get("uri"),
+ description: this.get("description"),
+ color: this.get("color")
+ };
+ }
+ });
+
+ // NODE
+ var Node = Models.Node = RenkanModel.extend({
+ type: "node",
+ relations: [{
+ type: Backbone.HasOne,
+ key: "created_by",
+ relatedModel: User
+ }],
+ prepare: function(options) {
+ var project = options.project;
+ this.addReference(options, "created_by", project.get("users"), options.created_by, project.current_user);
+ options.description = options.description || "";
+ return options;
+ },
+ toJSON: function() {
+ return {
+ _id: this.get("_id"),
+ title: this.get("title"),
+ uri: this.get("uri"),
+ description: this.get("description"),
+ position: this.get("position"),
+ image: this.get("image"),
+ color: this.get("color"),
+ created_by: this.get("created_by") ? this.get("created_by").get("_id") : null,
+ size: this.get("size"),
+ clip_path: this.get("clip_path"),
+ shape: this.get("shape")
+ };
+ }
+ });
+
+ // EDGE
+ var Edge = Models.Edge = RenkanModel.extend({
+ type: "edge",
+ relations: [
+ {
+ type: Backbone.HasOne,
+ key: "created_by",
+ relatedModel: User
+ },
+ {
+ type: Backbone.HasOne,
+ key: "from",
+ relatedModel: Node
+ },
+ {
+ type: Backbone.HasOne,
+ key: "to",
+ relatedModel: Node
+ }
+ ],
+ prepare: function(options) {
+ var project = options.project;
+ this.addReference(options, "created_by", project.get("users"), options.created_by, project.current_user);
+ this.addReference(options, "from", project.get("nodes"), options.from);
+ this.addReference(options, "to", project.get("nodes"), options.to);
+ return options;
+ },
+ toJSON: function() {
+ return {
+ _id: this.get("_id"),
+ title: this.get("title"),
+ uri: this.get("uri"),
+ description: this.get("description"),
+ from: this.get("from") ? this.get("from").get("_id") : null,
+ to: this.get("to") ? this.get("to").get("_id") : null,
+ color: this.get("color"),
+ created_by: this.get("created_by") ? this.get("created_by").get("_id") : null
+ };
+ }
+ });
+
+ // View
+ var View = Models.View = RenkanModel.extend({
+ type: "view",
+ relations: [
+ {
+ type: Backbone.HasOne,
+ key: "created_by",
+ relatedModel: User
+ }
+ ],
+ prepare: function(options) {
+ var project = options.project;
+ this.addReference(options, "created_by", project.get("users"), options.created_by, project.current_user);
+ options.description = options.description || "";
+ if(typeof options.offset !== "undefined") {
+ var offset = {};
+ if (Array.isArray(options.offset)) {
+ offset.x = options.offset[0];
+ offset.y = options.offset.length > 1 ? options.offset[1] : options.offset[0];
+ }
+ else if (options.offset.x != null) {
+ offset.x = options.offset.x;
+ offset.y = options.offset.y;
+ }
+ options.offset = offset;
+ }
+ return options;
+ },
+ toJSON: function() {
+ return {
+ _id: this.get("_id"),
+ zoom_level: this.get("zoom_level"),
+ offset: this.get("offset"),
+ title: this.get("title"),
+ description: this.get("description"),
+ created_by: this.get("created_by") ? this.get("created_by").get("_id") : null
+ // Don't need project id
+ };
+ }
+ });
+
+ // PROJECT
+ var Project = Models.Project = RenkanModel.extend({
+ type: "project",
+ relations: [
+ {
+ type: Backbone.HasMany,
+ key: "users",
+ relatedModel: User,
+ reverseRelation: {
+ key: 'project',
+ includeInJSON: '_id'
+ }
+ },
+ {
+ type: Backbone.HasMany,
+ key: "nodes",
+ relatedModel: Node,
+ reverseRelation: {
+ key: 'project',
+ includeInJSON: '_id'
+ }
+ },
+ {
+ type: Backbone.HasMany,
+ key: "edges",
+ relatedModel: Edge,
+ reverseRelation: {
+ key: 'project',
+ includeInJSON: '_id'
+ }
+ },
+ {
+ type: Backbone.HasMany,
+ key: "views",
+ relatedModel: View,
+ reverseRelation: {
+ key: 'project',
+ includeInJSON: '_id'
+ }
+ }
+ ],
+ addUser: function(_props, _options) {
+ _props.project = this;
+ var _user = User.findOrCreate(_props);
+ this.get("users").push(_user, _options);
+ return _user;
+ },
+ addNode: function(_props, _options) {
+ _props.project = this;
+ var _node = Node.findOrCreate(_props);
+ this.get("nodes").push(_node, _options);
+ return _node;
+ },
+ addEdge: function(_props, _options) {
+ _props.project = this;
+ var _edge = Edge.findOrCreate(_props);
+ this.get("edges").push(_edge, _options);
+ return _edge;
+ },
+ addView: function(_props, _options) {
+ _props.project = this;
+ // TODO: check if need to replace with create only
+ var _view = View.findOrCreate(_props);
+ // TODO: Should we remember only one view?
+ this.get("views").push(_view, _options);
+ return _view;
+ },
+ removeNode: function(_model) {
+ this.get("nodes").remove(_model);
+ },
+ removeEdge: function(_model) {
+ this.get("edges").remove(_model);
+ },
+ validate: function(options) {
+ var _project = this;
+ _([].concat(options.users, options.nodes, options.edges, options.views)).each(function(_item) {
+ if(_item) {
+ _item.project = _project;
+ }
+ });
+ },
+ // Add event handler to remove edges when a node is removed
+ initialize: function() {
+ var _this = this;
+ this.on("remove:nodes", function(_node) {
+ _this.get("edges").remove(
+ _this.get("edges").filter(function(_edge) {
+ return _edge.get("from") === _node || _edge.get("to") === _node;
+ })
+ );
+ });
+ }
+ });
+
+ var RosterUser = Models.RosterUser = Backbone.Model.extend({
+ type: "roster_user",
+ idAttribute : "_id",
+
+ constructor: function(options) {
+
+ if (typeof options !== "undefined") {
+ options._id = options._id || options.id || Models.getUID(this);
+ options.title = options.title || "(untitled " + this.type + ")";
+ options.description = options.description || "";
+ options.uri = options.uri || "";
+ options.project = options.project || null;
+ options.site_id = options.site_id || 0;
+
+ if(typeof this.prepare === "function") {
+ options = this.prepare(options);
+ }
+ }
+ Backbone.Model.prototype.constructor.call(this, options);
+ },
+
+ validate: function() {
+ if(!this.type) {
+ return "object has no type";
+ }
+ },
+
+ prepare: function(options) {
+ options.color = options.color || "#666666";
+ return options;
+ },
+
+ toJSON: function() {
+ return {
+ _id: this.get("_id"),
+ title: this.get("title"),
+ uri: this.get("uri"),
+ description: this.get("description"),
+ color: this.get("color"),
+ project: (this.get("project") != null)?this.get("project").get("id"):null,
+ site_id: this.get("site_id")
+ };
+ }
+ });
+
+ var UsersList = Models.UsersList = Backbone.Collection.extend({
+ model: RosterUser
+ });
+
+
+}).call(window);
+
+Rkns.defaults = {
+
+ language: (navigator.language || navigator.userLanguage || "en"),
+ /* GUI Language */
+ container: "renkan",
+ /* GUI Container DOM element ID */
+ search: [],
+ /* List of Search Engines */
+ bins: [],
+ /* List of Bins */
+ static_url: "",
+ /* URL for static resources */
+ show_bins: true,
+ /* Show bins in left column */
+ properties: [],
+ /* Semantic properties for edges */
+ show_editor: true,
+ /* Show the graph editor... Setting this to "false" only shows the bins part ! */
+ read_only: false,
+ /* Allows editing of renkan without changing the rest of the GUI. Can be switched on/off on the fly to block/enable editing */
+ editor_mode: true,
+ /* Switch for Publish/Edit GUI. If editor_mode is false, read_only will be true. */
+ manual_save: false,
+ /* In snapshot mode, clicking on the floppy will save a snapshot. Otherwise, it will show the connection status */
+ show_top_bar: true,
+ /* Show the top bar, (title, buttons, users) */
+ default_user_color: "#303030",
+ size_bug_fix: true,
+ /* Resize the canvas after load (fixes a bug on iPad and FF Mac) */
+ force_resize: false,
+ allow_double_click: true,
+ /* Allows Double Click to create a node on an empty background */
+ zoom_on_scroll: true,
+ /* Allows to use the scrollwheel to zoom */
+ element_delete_delay: 0,
+ /* Delay between clicking on the bin on an element and really deleting it
+ Set to 0 for delete confirm */
+ autoscale_padding: 50,
+ default_view: false,
+ /* Allows to load default view (zoom+offset) at start on read_only mode, instead of autoScale. default_view has to be an integer 0,1,2... */
+
+ /* TOP BAR BUTTONS */
+ show_search_field: true,
+ show_user_list: true,
+ user_name_editable: true,
+ user_color_editable: true,
+ show_save_button: true,
+ show_export_button: true,
+ show_open_button: false,
+ show_addnode_button: true,
+ show_addedge_button: true,
+ show_bookmarklet: true,
+ show_fullscreen_button: true,
+ home_button_url: false,
+ home_button_title: "Home",
+
+ /* MINI-MAP OPTIONS */
+
+ show_minimap: true,
+ /* Show a small map at the bottom right */
+ minimap_width: 160,
+ minimap_height: 120,
+ minimap_padding: 20,
+ minimap_background_color: "#ffffff",
+ minimap_border_color: "#cccccc",
+ minimap_highlight_color: "#ffff00",
+ minimap_highlight_weight: 5,
+
+ /* EDGE/NODE COMMON OPTIONS */
+
+ buttons_background: "#202020",
+ buttons_label_color: "#c000c0",
+ buttons_label_font_size: 9,
+
+ /* NODE DISPLAY OPTIONS */
+
+ show_node_circles: true,
+ /* Show circles for nodes */
+ clip_node_images: true,
+ /* Constraint node images to circles */
+ node_images_fill_mode: false,
+ /* Set to false for "letterboxing" (height/width of node adapted to show full image)
+ Set to true for "crop" (adapted to fill circle) */
+ node_size_base: 25,
+ node_stroke_width: 2,
+ selected_node_stroke_width: 4,
+ node_fill_color: "#ffffff",
+ highlighted_node_fill_color: "#ffff00",
+ node_label_distance: 5,
+ /* Vertical distance between node and label */
+ node_label_max_length: 60,
+ /* Maximum displayed text length */
+ label_untitled_nodes: "(untitled)",
+ /* Label to display on untitled nodes */
+ change_shapes: true,
+ /* Change shapes enabled */
+
+ /* EDGE DISPLAY OPTIONS */
+
+ edge_stroke_width: 2,
+ selected_edge_stroke_width: 4,
+ edge_label_distance: 0,
+ edge_label_max_length: 20,
+ edge_arrow_length: 18,
+ edge_arrow_width: 12,
+ edge_gap_in_bundles: 12,
+ label_untitled_edges: "",
+
+ /* CONTEXTUAL DISPLAY (TOOLTIP OR EDITOR) OPTIONS */
+
+ tooltip_width: 275,
+ tooltip_padding: 10,
+ tooltip_margin: 15,
+ tooltip_arrow_length : 20,
+ tooltip_arrow_width : 40,
+ tooltip_top_color: "#f0f0f0",
+ tooltip_bottom_color: "#d0d0d0",
+ tooltip_border_color: "#808080",
+ tooltip_border_width: 1,
+
+ /* NODE EDITOR OPTIONS */
+
+ show_node_editor_uri: true,
+ show_node_editor_description: true,
+ show_node_editor_size: true,
+ show_node_editor_color: true,
+ show_node_editor_image: true,
+ show_node_editor_creator: true,
+ uploaded_image_max_kb: 500,
+
+ /* NODE TOOLTIP OPTIONS */
+
+ show_node_tooltip_uri: true,
+ show_node_tooltip_description: true,
+ show_node_tooltip_color: true,
+ show_node_tooltip_image: true,
+ show_node_tooltip_creator: true,
+
+ /* EDGE EDITOR OPTIONS */
+
+ show_edge_editor_uri: true,
+ show_edge_editor_color: true,
+ show_edge_editor_direction: true,
+ show_edge_editor_nodes: true,
+ show_edge_editor_creator: true,
+
+ /* EDGE TOOLTIP OPTIONS */
+
+ show_edge_tooltip_uri: true,
+ show_edge_tooltip_color: true,
+ show_edge_tooltip_nodes: true,
+ show_edge_tooltip_creator: true
+
+ /* */
+
+};
+
+Rkns.i18n = {
+ fr: {
+ "Edit Node": "Édition d’un nœud",
+ "Edit Edge": "Édition d’un lien",
+ "Title:": "Titre :",
+ "URI:": "URI :",
+ "Description:": "Description :",
+ "From:": "De :",
+ "To:": "Vers :",
+ "Image": "Image",
+ "Image URL:": "URL d'Image",
+ "Choose Image File:": "Choisir un fichier image",
+ "Full Screen": "Mode plein écran",
+ "Add Node": "Ajouter un nœud",
+ "Add Edge": "Ajouter un lien",
+ "Save Project": "Enregistrer le projet",
+ "Open Project": "Ouvrir un projet",
+ "Auto-save enabled": "Enregistrement automatique activé",
+ "Connection lost": "Connexion perdue",
+ "Created by:": "Créé par :",
+ "Zoom In": "Agrandir l’échelle",
+ "Zoom Out": "Rapetisser l’échelle",
+ "Edit": "Éditer",
+ "Remove": "Supprimer",
+ "Cancel deletion": "Annuler la suppression",
+ "Link to another node": "Créer un lien",
+ "Enlarge": "Agrandir",
+ "Shrink": "Rétrécir",
+ "Click on the background canvas to add a node": "Cliquer sur le fond du graphe pour rajouter un nœud",
+ "Click on a first node to start the edge": "Cliquer sur un premier nœud pour commencer le lien",
+ "Click on a second node to complete the edge": "Cliquer sur un second nœud pour terminer le lien",
+ "Wikipedia": "Wikipédia",
+ "Wikipedia in ": "Wikipédia en ",
+ "French": "Français",
+ "English": "Anglais",
+ "Japanese": "Japonais",
+ "Untitled project": "Projet sans titre",
+ "Lignes de Temps": "Lignes de Temps",
+ "Loading, please wait": "Chargement en cours, merci de patienter",
+ "Edge color:": "Couleur :",
+ "Node color:": "Couleur :",
+ "Choose color": "Choisir une couleur",
+ "Change edge direction": "Changer le sens du lien",
+ "Do you really wish to remove node ": "Voulez-vous réellement supprimer le nœud ",
+ "Do you really wish to remove edge ": "Voulez-vous réellement supprimer le lien ",
+ "This file is not an image": "Ce fichier n'est pas une image",
+ "Image size must be under ": "L'image doit peser moins de ",
+ "Size:": "Taille :",
+ "KB": "ko",
+ "Choose from vocabulary:": "Choisir dans un vocabulaire :",
+ "SKOS Documentation properties": "SKOS: Propriétés documentaires",
+ "has note": "a pour note",
+ "has example": "a pour exemple",
+ "has definition": "a pour définition",
+ "SKOS Semantic relations": "SKOS: Relations sémantiques",
+ "has broader": "a pour concept plus large",
+ "has narrower": "a pour concept plus étroit",
+ "has related": "a pour concept apparenté",
+ "Dublin Core Metadata": "Métadonnées Dublin Core",
+ "has contributor": "a pour contributeur",
+ "covers": "couvre",
+ "created by": "créé par",
+ "has date": "a pour date",
+ "published by": "édité par",
+ "has source": "a pour source",
+ "has subject": "a pour sujet",
+ "Dragged resource": "Ressource glisée-déposée",
+ "Search the Web": "Rechercher en ligne",
+ "Search in Bins": "Rechercher dans les chutiers",
+ "Close bin": "Fermer le chutier",
+ "Refresh bin": "Rafraîchir le chutier",
+ "(untitled)": "(sans titre)",
+ "Select contents:": "Sélectionner des contenus :",
+ "Drag items from this website, drop them in Renkan": "Glissez des éléments de ce site web vers Renkan",
+ "Drag this button to your bookmark bar. When on a third-party website, click it to enable drag-and-drop from the website to Renkan.": "Glissez ce bouton vers votre barre de favoris. Ensuite, depuis un site tiers, cliquez dessus pour activer 'Drag-to-Add' puis glissez des éléments de ce site vers Renkan",
+ "Shapes available": "Formes disponibles",
+ "Circle": "Cercle",
+ "Square": "Carré",
+ "Diamond": "Losange",
+ "Hexagone": "Hexagone",
+ "Ellipse": "Ellipse",
+ "Star": "Étoile"
+ }
+};
+
+/* Saves the Full JSON at each modification */
+
+Rkns.jsonIO = function(_renkan, _opts) {
+ var _proj = _renkan.project;
+ if (typeof _opts.http_method === "undefined") {
+ _opts.http_method = 'PUT';
+ }
+ var _load = function() {
+ _renkan.renderer.redrawActive = false;
+ Rkns.$.getJSON(_opts.url, function(_data) {
+ _proj.set(_data, {validate: true});
+ _renkan.renderer.redrawActive = true;
+ _renkan.renderer.autoScale();
+ });
+ };
+ var _save = function() {
+ var _data = _proj.toJSON();
+ if (!_renkan.read_only) {
+ Rkns.$.ajax({
+ type: _opts.http_method,
+ url: _opts.url,
+ contentType: "application/json",
+ data: JSON.stringify(_data),
+ success: function(data, textStatus, jqXHR) {
+ }
+ });
+ }
+
+ };
+ var _thrSave = Rkns._.throttle(
+ function() {
+ setTimeout(_save, 100);
+ }, 1000);
+ _proj.on("add:nodes add:edges add:users add:views", function(_model) {
+ _model.on("change remove", function(_model) {
+ _thrSave();
+ });
+ _thrSave();
+ });
+ _proj.on("change", function() {
+ _thrSave();
+ });
+
+ _load();
+};
+
+/* Saves the Full JSON once */
+
+Rkns.jsonIOSaveOnClick = function(_renkan, _opts) {
+ var _proj = _renkan.project,
+ _saveWarn = false,
+ _onLeave = function() {
+ return "Project not saved";
+ };
+ if (typeof _opts.http_method === "undefined") {
+ _opts.http_method = 'POST';
+ }
+ var _load = function() {
+ var getdata = {},
+ rx = /id=([^&#?=]+)/,
+ matches = document.location.hash.match(rx);
+ if (matches) {
+ getdata.id = matches[1];
+ }
+ Rkns.$.ajax({
+ url: _opts.url,
+ data: getdata,
+ success: function(_data) {
+ _proj.set(_data, {validate: true});
+ _renkan.renderer.autoScale();
+ }
+ });
+ };
+ var _save = function() {
+ _proj.set("saved_at", new Date());
+ var _data = _proj.toJSON();
+ Rkns.$.ajax({
+ type: _opts.http_method,
+ url: _opts.url,
+ contentType: "application/json",
+ data: JSON.stringify(_data),
+ success: function(data, textStatus, jqXHR) {
+ $(window).off("beforeunload", _onLeave);
+ _saveWarn = false;
+ //document.location.hash = "#id=" + data.id;
+ //$(".Rk-Notifications").text("Saved as "+document.location.href).fadeIn().delay(2000).fadeOut();
+ }
+ });
+ };
+ var _checkLeave = function() {
+ var title = _proj.get("title");
+ if (title && _proj.get("nodes").length) {
+ $(".Rk-Save-Button").removeClass("disabled");
+ } else {
+ $(".Rk-Save-Button").addClass("disabled");
+ }
+ if (title) {
+ $(".Rk-PadTitle").css("border-color","#333333");
+ }
+ if (!_saveWarn) {
+ _saveWarn = true;
+ $(window).on("beforeunload", _onLeave);
+ }
+ };
+ _load();
+ _proj.on("add:nodes add:edges add:users change", function(_model) {
+ _model.on("change remove", function(_model) {
+ _checkLeave();
+ });
+ _checkLeave();
+ });
+ _renkan.renderer.save = function() {
+ if ($(".Rk-Save-Button").hasClass("disabled")) {
+ if (!_proj.get("title")) {
+ $(".Rk-PadTitle").css("border-color","#ff0000");
+ }
+ } else {
+ _save();
+ }
+ };
+};
+
+(function(Rkns) {
+"use strict";
+
+var _ = Rkns._;
+
+var Ldt = Rkns.Ldt = {};
+
+var Bin = Ldt.Bin = function(_renkan, _opts) {
+ if (_opts.ldt_type) {
+ var Resclass = Ldt[_opts.ldt_type+"Bin"];
+ if (Resclass) {
+ return new Resclass(_renkan, _opts);
+ }
+ }
+ console.error("No such LDT Bin Type");
+};
+
+var ProjectBin = Ldt.ProjectBin = Rkns.Utils.inherit(Rkns._BaseBin);
+
+ProjectBin.prototype.tagTemplate = _.template(
+ '<li class="Rk-Bin-Item" draggable="true" data-image="<%- Rkns.Utils.getFullURL(static_url+\'img/ldt-tag.png\') %>" data-uri="<%=ldt_platform%>ldtplatform/ldt/front/search/?search=<%=encodedtitle%>&field=all" data-title="<%-title%>" data-description="Tag \'<%-title%>\'">' +
+ '<img class="Rk-Ldt-Tag-Icon" src="<%-static_url%>img/ldt-tag.png" /><h4><%=htitle%></h4><div class="Rk-Clear"></div></li>'
+);
+
+ProjectBin.prototype.annotationTemplate = _.template(
+ '<li class="Rk-Bin-Item" draggable="true" data-image="<%- Rkns.Utils.getFullURL(image) %>" data-uri="<%=ldt_platform%>ldtplatform/ldt/front/player/<%=mediaid%>/#id=<%=annotationid%>" data-title="<%-title%>" data-description="<%-description%>">' +
+ '<img class="Rk-Ldt-Annotation-Icon" src="<%=image%>"/><h4><%=htitle%></h4><p><%=hdescription%></p><p>Start: <%=start%>, End: <%=end%>, Duration: <%=duration%></p><div class="Rk-Clear"></div></li>'
+);
+
+ProjectBin.prototype._init = function(_renkan, _opts) {
+ this.renkan = _renkan;
+ this.proj_id = _opts.project_id;
+ this.ldt_platform = _opts.ldt_platform || "http://ldt.iri.centrepompidou.fr/";
+ this.title_$.html(_opts.title);
+ this.title_icon_$.addClass('Rk-Ldt-Title-Icon');
+ this.refresh();
+};
+
+ProjectBin.prototype.render = function(searchbase) {
+ var search = searchbase || Rkns.Utils.regexpFromTextOrArray();
+ function highlight(_text) {
+ var _e = _(_text).escape();
+ return search.isempty ? _e : search.replace(_e, "<span class='searchmatch'>$1</span>");
+ }
+ function convertTC(_ms) {
+ function pad(_n) {
+ var _res = _n.toString();
+ while (_res.length < 2) {
+ _res = '0' + _res;
+ }
+ return _res;
+ }
+ var _totalSeconds = Math.abs(Math.floor(_ms/1000)),
+ _hours = Math.floor(_totalSeconds / 3600),
+ _minutes = (Math.floor(_totalSeconds / 60) % 60),
+ _seconds = _totalSeconds % 60,
+ _res = '';
+ if (_hours) {
+ _res += pad(_hours) + ':';
+ }
+ _res += pad(_minutes) + ':' + pad(_seconds);
+ return _res;
+ }
+
+ var _html = '<li><h3>Tags</h3></li>',
+ _projtitle = this.data.meta["dc:title"],
+ _this = this,
+ count = 0;
+ _this.title_$.text('LDT Project: "' + _projtitle + '"');
+ _(_this.data.tags).map(function(_tag) {
+ var _title = _tag.meta["dc:title"];
+ if (!search.isempty && !search.test(_title)) {
+ return;
+ }
+ count++;
+ _html += _this.tagTemplate({
+ ldt_platform: _this.ldt_platform,
+ title: _title,
+ htitle: highlight(_title),
+ encodedtitle : encodeURIComponent(_title),
+ static_url: _this.renkan.options.static_url
+ });
+ });
+ _html += '<li><h3>Annotations</h3></li>';
+ _(_this.data.annotations).map(function(_annotation) {
+ var _description = _annotation.content.description,
+ _title = _annotation.content.title.replace(_description,"");
+ if (!search.isempty && !search.test(_title) && !search.test(_description)) {
+ return;
+ }
+ count++;
+ var _duration = _annotation.end - _annotation.begin,
+ _img = (
+ (_annotation.content && _annotation.content.img && _annotation.content.img.src) ?
+ _annotation.content.img.src :
+ ( _duration ? _this.renkan.options.static_url+"img/ldt-segment.png" : _this.renkan.options.static_url+"img/ldt-point.png" )
+ );
+ _html += _this.annotationTemplate({
+ ldt_platform: _this.ldt_platform,
+ title: _title,
+ htitle: highlight(_title),
+ description: _description,
+ hdescription: highlight(_description),
+ start: convertTC(_annotation.begin),
+ end: convertTC(_annotation.end),
+ duration: convertTC(_duration),
+ mediaid: _annotation.media,
+ annotationid: _annotation.id,
+ image: _img,
+ static_url: _this.renkan.options.static_url
+ });
+ });
+
+ this.main_$.html(_html);
+ if (!search.isempty && count) {
+ this.count_$.text(count).show();
+ } else {
+ this.count_$.hide();
+ }
+ if (!search.isempty && !count) {
+ this.$.hide();
+ } else {
+ this.$.show();
+ }
+ this.renkan.resizeBins();
+};
+
+ProjectBin.prototype.refresh = function() {
+ var _this = this;
+ Rkns.$.ajax({
+ url: this.ldt_platform + 'ldtplatform/ldt/cljson/id/' + this.proj_id,
+ dataType: "jsonp",
+ success: function(_data) {
+ _this.data = _data;
+ _this.render();
+ }
+ });
+};
+
+var Search = Ldt.Search = function(_renkan, _opts) {
+ this.renkan = _renkan;
+ this.lang = _opts.lang || "en";
+};
+
+Search.prototype.getBgClass = function() {
+ return "Rk-Ldt-Icon";
+};
+
+Search.prototype.getSearchTitle = function() {
+ return this.renkan.translate("Lignes de Temps");
+};
+
+Search.prototype.search = function(_q) {
+ this.renkan.tabs.push(
+ new ResultsBin(this.renkan, {
+ search: _q
+ })
+ );
+};
+
+var ResultsBin = Ldt.ResultsBin = Rkns.Utils.inherit(Rkns._BaseBin);
+
+ResultsBin.prototype.segmentTemplate = _.template(
+ '<li class="Rk-Bin-Item" draggable="true" data-image="<%- Rkns.Utils.getFullURL(image) %>" data-uri="<%=ldt_platform%>ldtplatform/ldt/front/player/<%=mediaid%>/#id=<%=annotationid%>" data-title="<%-title%>" data-description="<%-description%>">' +
+ '<img class="Rk-Ldt-Annotation-Icon" src="<%=image%>"/><h4><%=htitle%></h4><p><%=hdescription%></p><p>Start: <%=start%>, End: <%=end%>, Duration: <%=duration%></p><div class="Rk-Clear"></div></li>'
+);
+
+ResultsBin.prototype._init = function(_renkan, _opts) {
+ this.renkan = _renkan;
+ this.ldt_platform = _opts.ldt_platform || "http://ldt.iri.centrepompidou.fr/";
+ this.max_results = _opts.max_results || 50;
+ this.search = _opts.search;
+ this.title_$.html('Lignes de Temps: "' + _opts.search + '"');
+ this.title_icon_$.addClass('Rk-Ldt-Title-Icon');
+ this.refresh();
+};
+
+ResultsBin.prototype.render = function(searchbase) {
+ if (!this.data) {
+ return;
+ }
+ var search = searchbase || Rkns.Utils.regexpFromTextOrArray();
+ var highlightrx = (search.isempty ? Rkns.Utils.regexpFromTextOrArray(this.search) : search);
+ function highlight(_text) {
+ return highlightrx.replace(_(_text).escape(), "<span class='searchmatch'>$1</span>");
+ }
+ function convertTC(_ms) {
+ function pad(_n) {
+ var _res = _n.toString();
+ while (_res.length < 2) {
+ _res = '0' + _res;
+ }
+ return _res;
+ }
+ var _totalSeconds = Math.abs(Math.floor(_ms/1000)),
+ _hours = Math.floor(_totalSeconds / 3600),
+ _minutes = (Math.floor(_totalSeconds / 60) % 60),
+ _seconds = _totalSeconds % 60,
+ _res = '';
+ if (_hours) {
+ _res += pad(_hours) + ':';
+ }
+ _res += pad(_minutes) + ':' + pad(_seconds);
+ return _res;
+ }
+
+ var _html = '',
+ _this = this,
+ count = 0;
+ _(this.data.objects).each(function(_segment) {
+ var _description = _segment.abstract,
+ _title = _segment.title;
+ if (!search.isempty && !search.test(_title) && !search.test(_description)) {
+ return;
+ }
+ count++;
+ var _duration = _segment.duration,
+ _begin = _segment.start_ts,
+ _end = + _segment.duration + _begin,
+ _img = (
+ _duration ?
+ _this.renkan.options.static_url + "img/ldt-segment.png" :
+ _this.renkan.options.static_url + "img/ldt-point.png"
+ );
+ _html += _this.segmentTemplate({
+ ldt_platform: _this.ldt_platform,
+ title: _title,
+ htitle: highlight(_title),
+ description: _description,
+ hdescription: highlight(_description),
+ start: convertTC(_begin),
+ end: convertTC(_end),
+ duration: convertTC(_duration),
+ mediaid: _segment.iri_id,
+ //projectid: _segment.project_id,
+ //cuttingid: _segment.cutting_id,
+ annotationid: _segment.element_id,
+ image: _img
+ });
+ });
+
+ this.main_$.html(_html);
+ if (!search.isempty && count) {
+ this.count_$.text(count).show();
+ } else {
+ this.count_$.hide();
+ }
+ if (!search.isempty && !count) {
+ this.$.hide();
+ } else {
+ this.$.show();
+ }
+ this.renkan.resizeBins();
+};
+
+ResultsBin.prototype.refresh = function() {
+ var _this = this;
+ Rkns.$.ajax({
+ url: this.ldt_platform + 'ldtplatform/api/ldt/1.0/segments/search/',
+ data: {
+ format: "jsonp",
+ q: this.search,
+ limit: this.max_results
+ },
+ dataType: "jsonp",
+ success: function(_data) {
+ _this.data = _data;
+ _this.render();
+ }
+ });
+};
+
+})(window.Rkns);
+
+Rkns.ResourceList = {};
+
+Rkns.ResourceList.Bin = Rkns.Utils.inherit(Rkns._BaseBin);
+
+Rkns.ResourceList.Bin.prototype.resultTemplate = Rkns._.template(
+ '<li class="Rk-Bin-Item Rk-ResourceList-Item" draggable="true" data-uri="<%-url%>" ' +
+ 'data-title="<%-title%>" data-description="<%-description%>" ' +
+ '<% if (image) { %>data-image="<%- Rkns.Utils.getFullURL(image) %>"<% } else { %>data-image=""<% } %> >' +
+ '<% if (image) { %><img class="Rk-ResourceList-Image" src="<%-image%>"/><% } %><h4 class="Rk-ResourceList-Title">' +
+ '<% if (url) { %><a href="<%-url%>" target="_blank"><% } %><%=htitle%><% if (url) { %></a><% } %></h4>' +
+ '<% if (description) { %><p class="Rk-ResourceList-Description"><%=hdescription%></p><% } %><% if (image) { %><div style="clear: both;"></div><% } %></li>'
+);
+
+Rkns.ResourceList.Bin.prototype._init = function(_renkan, _opts) {
+ this.renkan = _renkan;
+ this.title_$.html(_opts.title);
+ if (_opts.list) {
+ this.data = _opts.list;
+ }
+ this.refresh();
+};
+
+Rkns.ResourceList.Bin.prototype.render = function(searchbase) {
+ var search = searchbase || Rkns.Utils.regexpFromTextOrArray();
+ function highlight(_text) {
+ var _e = _(_text).escape();
+ return search.isempty ? _e : search.replace(_e, "<span class='searchmatch'>$1</span>");
+ }
+ var _html = "",
+ _this = this,
+ count = 0;
+ Rkns._(this.data).each(function(_item) {
+ var _element;
+ if (typeof _item === "string") {
+ if (/^(https?:\/\/|www)/.test(_item)) {
+ _element = { url: _item };
+ } else {
+ _element = { title: _item.replace(/[:,]?\s?(https?:\/\/|www)[\d\w\/.&?=#%-_]+\s?/,'').trim() };
+ var _match = _item.match(/(https?:\/\/|www)[\d\w\/.&?=#%-_]+/);
+ if (_match) {
+ _element.url = _match[0];
+ }
+ if (_element.title.length > 80) {
+ _element.description = _element.title;
+ _element.title = _element.title.replace(/^(.{30,60})\s.+$/,'$1…');
+ }
+ }
+ } else {
+ _element = _item;
+ }
+ var title = _element.title || (_element.url || "").replace(/^https?:\/\/(www\.)?/,'').replace(/^(.{40}).+$/,'$1…'),
+ url = _element.url || "",
+ description = _element.description || "",
+ image = _element.image || "";
+ if (url && !/^https?:\/\//.test(url)) {
+ url = 'http://' + url;
+ }
+ if (!search.isempty && !search.test(title) && !search.test(description)) {
+ return;
+ }
+ count++;
+ _html += _this.resultTemplate({
+ url: url,
+ title: title,
+ htitle: highlight(title),
+ image: image,
+ description: description,
+ hdescription: highlight(description),
+ static_url: _this.renkan.options.static_url
+ });
+ });
+ _this.main_$.html(_html);
+ if (!search.isempty && count) {
+ this.count_$.text(count).show();
+ } else {
+ this.count_$.hide();
+ }
+ if (!search.isempty && !count) {
+ this.$.hide();
+ } else {
+ this.$.show();
+ }
+ this.renkan.resizeBins();
+};
+
+Rkns.ResourceList.Bin.prototype.refresh = function() {
+ if (this.data) {
+ this.render();
+ }
+};
+
+Rkns.Wikipedia = {
+};
+
+Rkns.Wikipedia.Search = function(_renkan, _opts) {
+ this.renkan = _renkan;
+ this.lang = _opts.lang || "en";
+};
+
+Rkns.Wikipedia.Search.prototype.getBgClass = function() {
+ return "Rk-Wikipedia-Search-Icon Rk-Wikipedia-Lang-" + this.lang;
+};
+
+Rkns.Wikipedia.Search.prototype.getSearchTitle = function() {
+ var langs = {
+ "fr": "French",
+ "en": "English",
+ "ja": "Japanese"
+ };
+ if (langs[this.lang]) {
+ return this.renkan.translate("Wikipedia in ") + this.renkan.translate(langs[this.lang]);
+ } else {
+ return this.renkan.translate("Wikipedia") + " [" + this.lang + "]";
+ }
+};
+
+Rkns.Wikipedia.Search.prototype.search = function(_q) {
+ this.renkan.tabs.push(
+ new Rkns.Wikipedia.Bin(this.renkan, {
+ lang: this.lang,
+ search: _q
+ })
+ );
+};
+
+Rkns.Wikipedia.Bin = Rkns.Utils.inherit(Rkns._BaseBin);
+
+Rkns.Wikipedia.Bin.prototype.resultTemplate = Rkns._.template(
+ '<li class="Rk-Wikipedia-Result Rk-Bin-Item" draggable="true" data-uri="<%-url%>" ' +
+ 'data-title="Wikipedia: <%-title%>" data-description="<%-description%>" data-image="<%- Rkns.Utils.getFullURL( static_url + \'img/wikipedia.png\' ) %>">' +
+ '<img class="Rk-Wikipedia-Icon" src="<%-static_url%>img/wikipedia.png"></div><h4 class="Rk-Wikipedia-Title"><a href="<%-url%>" target="_blank"><%=htitle%></a></h4>' +
+ '<p class="Rk-Wikipedia-Snippet"><%=hdescription%></p></li>'
+);
+
+Rkns.Wikipedia.Bin.prototype._init = function(_renkan, _opts) {
+ this.renkan = _renkan;
+ this.search = _opts.search;
+ this.lang = _opts.lang || "en";
+ this.title_icon_$.addClass('Rk-Wikipedia-Title-Icon Rk-Wikipedia-Lang-' + this.lang);
+ this.title_$.html(this.search).addClass("Rk-Wikipedia-Title");
+ this.refresh();
+};
+
+Rkns.Wikipedia.Bin.prototype.render = function(searchbase) {
+ var search = searchbase || Rkns.Utils.regexpFromTextOrArray();
+ var highlightrx = (search.isempty ? Rkns.Utils.regexpFromTextOrArray(this.search) : search);
+ function highlight(_text) {
+ return highlightrx.replace(_(_text).escape(), "<span class='searchmatch'>$1</span>");
+ }
+ var _html = "",
+ _this = this,
+ count = 0;
+ Rkns._(this.data.query.search).each(function(_result) {
+ var title = _result.title,
+ url = "http://" + _this.lang + ".wikipedia.org/wiki/" + encodeURI(title.replace(/ /g,"_")),
+ description = Rkns.$('<div>').html(_result.snippet).text();
+ if (!search.isempty && !search.test(title) && !search.test(description)) {
+ return;
+ }
+ count++;
+ _html += _this.resultTemplate({
+ url: url,
+ title: title,
+ htitle: highlight(title),
+ description: description,
+ hdescription: highlight(description),
+ static_url: _this.renkan.options.static_url
+ });
+ });
+ _this.main_$.html(_html);
+ if (!search.isempty && count) {
+ this.count_$.text(count).show();
+ } else {
+ this.count_$.hide();
+ }
+ if (!search.isempty && !count) {
+ this.$.hide();
+ } else {
+ this.$.show();
+ }
+ this.renkan.resizeBins();
+};
+
+Rkns.Wikipedia.Bin.prototype.refresh = function() {
+ var _this = this;
+ Rkns.$.ajax({
+ url: "http://" + _this.lang + ".wikipedia.org/w/api.php?action=query&list=search&srsearch=" + encodeURIComponent(this.search) + "&format=json",
+ dataType: "jsonp",
+ success: function(_data) {
+ _this.data = _data;
+ _this.render();
+ }
+ });
+};
+
+
+define('renderer/baserepresentation',['jquery', 'underscore'], function ($, _) {
+
+
+ /* Rkns.Renderer._BaseRepresentation Class */
+
+ /* In Renkan, a "Representation" is a sort of ViewModel (in the MVVM paradigm) and bridges the gap between
+ * models (written with Backbone.js) and the view (written with Paper.js)
+ * Renkan's representations all inherit from Rkns.Renderer._BaseRepresentation '*/
+
+ var _BaseRepresentation = function(_renderer, _model) {
+ if (typeof _renderer !== "undefined") {
+ this.renderer = _renderer;
+ this.renkan = _renderer.renkan;
+ this.project = _renderer.renkan.project;
+ this.options = _renderer.renkan.options;
+ this.model = _model;
+ if (this.model) {
+ var _this = this;
+ this._changeBinding = function() {
+ _this.redraw();
+ };
+ this._removeBinding = function() {
+ _renderer.removeRepresentation(_this);
+ _(function() {
+ _renderer.redraw();
+ }).defer();
+ };
+ this._selectBinding = function() {
+ _this.select();
+ };
+ this._unselectBinding = function() {
+ _this.unselect();
+ };
+ this.model.on("change", this._changeBinding );
+ this.model.on("remove", this._removeBinding );
+ this.model.on("select", this._selectBinding );
+ this.model.on("unselect", this._unselectBinding );
+ }
+ }
+ };
+
+ /* Rkns.Renderer._BaseRepresentation Methods */
+
+ _(_BaseRepresentation.prototype).extend({
+ _super: function(_func) {
+ return _BaseRepresentation.prototype[_func].apply(this, Array.prototype.slice.call(arguments, 1));
+ },
+ redraw: function() {},
+ moveTo: function() {},
+ show: function() { return "chaud cacao"; },
+ hide: function() {},
+ select: function() {
+ if (this.model) {
+ this.model.trigger("selected");
+ }
+ },
+ unselect: function() {
+ if (this.model) {
+ this.model.trigger("unselected");
+ }
+ },
+ highlight: function() {},
+ unhighlight: function() {},
+ mousedown: function() {},
+ mouseup: function() {
+ if (this.model) {
+ this.model.trigger("clicked");
+ }
+ },
+ destroy: function() {
+ if (this.model) {
+ this.model.off("change", this._changeBinding );
+ this.model.off("remove", this._removeBinding );
+ this.model.off("select", this._selectBinding );
+ this.model.off("unselect", this._unselectBinding );
+ }
+ }
+ });
+
+ /* End of Rkns.Renderer._BaseRepresentation Class */
+
+ return _BaseRepresentation;
+
+});
+
+define('requtils',[], function ($, _) {
+
+ return {
+ getUtils: function(){
+ return window.Rkns.Utils;
+ },
+ getRenderer: function(){
+ return window.Rkns.Renderer;
+ }
+ };
+
+});
+
+
+define('renderer/basebutton',['jquery', 'underscore', 'requtils', 'renderer/baserepresentation'], function ($, _, requtils, BaseRepresentation) {
+
+
+ var Utils = requtils.getUtils();
+
+ /* Rkns.Renderer._BaseButton Class */
+
+ /* BaseButton is extended by contextual buttons that appear when hovering on nodes and edges */
+
+ var _BaseButton = Utils.inherit(BaseRepresentation);
+
+ _(_BaseButton.prototype).extend({
+ moveTo: function(_pos) {
+ this.sector.moveTo(_pos);
+ },
+ show: function() {
+ this.sector.show();
+ },
+ hide: function() {
+ this.sector.hide();
+ },
+ select: function() {
+ this.sector.select();
+ },
+ unselect: function(_newTarget) {
+ this.sector.unselect();
+ if (!_newTarget || (_newTarget !== this.source_representation && _newTarget.source_representation !== this.source_representation)) {
+ this.source_representation.unselect();
+ }
+ },
+ destroy: function() {
+ this.sector.destroy();
+ }
+ });
+
+ return _BaseButton;
+
+});
+
+
+define('renderer/shapebuilder',[], function () {
+
+
+ /* ShapeBuilder Begin */
+
+ var builders = {
+ "circle":{
+ getShape: function() {
+ return new paper.Path.Circle([0, 0], 1);
+ },
+ getImageShape: function(center, radius) {
+ return new paper.Path.Circle(center, radius);
+ }
+ },
+ "rectangle":{
+ getShape: function() {
+ return new paper.Path.Rectangle([-2, -2], [2, 2]);
+ },
+ getImageShape: function(center, radius) {
+ return new paper.Path.Rectangle([-radius, -radius], [radius*2, radius*2]);
+ }
+ },
+ "ellipse":{
+ getShape: function() {
+ return new paper.Path.Ellipse(new paper.Rectangle([-2, -1], [2, 1]));
+ },
+ getImageShape: function(center, radius) {
+ return new paper.Path.Ellipse(new paper.Rectangle([-radius, -radius/2], [radius*2, radius]));
+ }
+ },
+ "polygon":{
+ getShape: function() {
+ return new paper.Path.RegularPolygon([0, 0], 6, 1);
+ },
+ getImageShape: function(center, radius) {
+ return new paper.Path.RegularPolygon([0, 0], 6, radius);
+ }
+ },
+ "diamond":{
+ getShape: function() {
+ var d = new paper.Path.Rectangle([-2, -2], [2, 2]);
+ d.rotate(45);
+ return d;
+ },
+ getImageShape: function(center, radius) {
+ var d = new paper.Path.Rectangle([-radius, -radius], [radius*2, radius*2]);
+ d.rotate(45);
+ return d;
+ }
+ },
+ "star":{
+ getShape: function() {
+ return new paper.Path.Star([0, 0], 8, 1, 0.7);
+ },
+ getImageShape: function(center, radius) {
+ return new paper.Path.Star([0, 0], 8, radius*1, radius*0.7);
+ }
+ },
+ "svg": function(path){
+ return {
+ getShape: function() {
+ return new paper.Path(path);
+ },
+ getImageShape: function(center, radius) {
+ // No calcul for the moment
+ return new paper.Path();
+ }
+ };
+ }
+ };
+
+ var ShapeBuilder = function (shape){
+ if(typeof shape==="undefined"){
+ shape = "circle";
+ }
+ if(shape.substr(0,4)==="svg:"){
+ return builders.svg(shape.substr(4));
+ }
+ if(!(shape in builders)){
+ shape = "circle";
+ }
+ return builders[shape];
+ };
+
+ return ShapeBuilder;
+
+});
+
+define('renderer/noderepr',['jquery', 'underscore', 'requtils', 'renderer/baserepresentation', 'renderer/shapebuilder'], function ($, _, requtils, BaseRepresentation, ShapeBuilder) {
+
+
+ var Utils = requtils.getUtils();
+
+ /* Rkns.Renderer.Node Class */
+
+ /* The representation for the node : A circle, with an image inside and a text label underneath.
+ * The circle and the image are drawn on canvas and managed by Paper.js.
+ * The text label is an HTML node, managed by jQuery. */
+
+ //var NodeRepr = Renderer.Node = Utils.inherit(Renderer._BaseRepresentation);
+ var NodeRepr = Utils.inherit(BaseRepresentation);
+
+ _(NodeRepr.prototype).extend({
+ _init: function() {
+ this.renderer.node_layer.activate();
+ this.type = "Node";
+ this.buildShape();
+ if (this.options.show_node_circles) {
+ this.circle.strokeWidth = this.options.node_stroke_width;
+ this.h_ratio = 1;
+ } else {
+ this.h_ratio = 0;
+ }
+ this.title = $('<div class="Rk-Label">').appendTo(this.renderer.labels_$);
+
+ if (this.options.editor_mode) {
+ var Renderer = requtils.getRenderer();
+ this.normal_buttons = [
+ new Renderer.NodeEditButton(this.renderer, null),
+ new Renderer.NodeRemoveButton(this.renderer, null),
+ new Renderer.NodeLinkButton(this.renderer, null),
+ new Renderer.NodeEnlargeButton(this.renderer, null),
+ new Renderer.NodeShrinkButton(this.renderer, null)
+ ];
+ this.pending_delete_buttons = [
+ new Renderer.NodeRevertButton(this.renderer, null)
+ ];
+ this.all_buttons = this.normal_buttons.concat(this.pending_delete_buttons);
+
+ for (var i = 0; i < this.all_buttons.length; i++) {
+ this.all_buttons[i].source_representation = this;
+ }
+ this.active_buttons = [];
+ } else {
+ this.active_buttons = this.all_buttons = [];
+ }
+ this.last_circle_radius = 1;
+
+ if (this.renderer.minimap) {
+ this.renderer.minimap.node_layer.activate();
+ this.minimap_circle = new paper.Path.Circle([0, 0], 1);
+ this.minimap_circle.__representation = this.renderer.minimap.miniframe.__representation;
+ this.renderer.minimap.node_group.addChild(this.minimap_circle);
+ }
+ },
+ buildShape: function(){
+ if(typeof this.model.get("shape_changed")!=="undefined" && this.model.get("shape_changed")===true){
+ this.model.set("shape_changed", false);
+ delete this.img;
+ }
+ if(this.circle){
+ this.circle.remove();
+ delete this.circle;
+ }
+ // "circle" "rectangle" "ellipse" "polygon" "star" "diamond"
+ this.shapeBuilder = new ShapeBuilder(this.model.get("shape"));
+ this.circle = this.shapeBuilder.getShape();
+ this.circle.__representation = this;
+ this.last_circle_radius = 1;
+ },
+ redraw: function(_dontRedrawEdges) {
+ if(typeof this.model.get("shape_changed")!=="undefined" && this.model.get("shape_changed")===true){
+ this.buildShape();
+ }
+ var _model_coords = new paper.Point(this.model.get("position")),
+ _baseRadius = this.options.node_size_base * Math.exp((this.model.get("size") || 0) * Utils._NODE_SIZE_STEP);
+ if (!this.is_dragging || !this.paper_coords) {
+ this.paper_coords = this.renderer.toPaperCoords(_model_coords);
+ }
+ this.circle_radius = _baseRadius * this.renderer.scale;
+ if (this.last_circle_radius !== this.circle_radius) {
+ this.all_buttons.forEach(function(b) {
+ b.setSectorSize();
+ });
+ this.circle.scale(this.circle_radius / this.last_circle_radius);
+ if (this.node_image) {
+ this.node_image.scale(this.circle_radius / this.last_circle_radius);
+ }
+ }
+ this.circle.position = this.paper_coords;
+ if (this.node_image) {
+ this.node_image.position = this.paper_coords.subtract(this.image_delta.multiply(this.circle_radius));
+ }
+ this.last_circle_radius = this.circle_radius;
+
+ var old_act_btn = this.active_buttons;
+
+ var opacity = 1;
+ if (this.model.get("delete_scheduled")) {
+ opacity = 0.5;
+ this.active_buttons = this.pending_delete_buttons;
+ this.circle.dashArray = [2,2];
+ } else {
+ opacity = 1;
+ this.active_buttons = this.normal_buttons;
+ this.circle.dashArray = null;
+ }
+
+ if (this.selected && this.renderer.isEditable()) {
+ if (old_act_btn !== this.active_buttons) {
+ old_act_btn.forEach(function(b) {
+ b.hide();
+ });
+ }
+ this.active_buttons.forEach(function(b) {
+ b.show();
+ });
+ }
+
+ if (this.node_image) {
+ this.node_image.opacity = this.highlighted ? opacity * 0.5 : (opacity - 0.01);
+ }
+
+ this.circle.fillColor = this.highlighted ? this.options.highlighted_node_fill_color : this.options.node_fill_color;
+
+ this.circle.opacity = this.options.show_node_circles ? opacity : 0.01;
+
+ var _text = this.model.get("title") || this.renkan.translate(this.options.label_untitled_nodes) || "";
+ _text = Utils.shortenText(_text, this.options.node_label_max_length);
+
+ if (typeof this.highlighted === "object") {
+ this.title.html(this.highlighted.replace(_(_text).escape(),'<span class="Rk-Highlighted">$1</span>'));
+ } else {
+ this.title.text(_text);
+ }
+
+ this.title.css({
+ left: this.paper_coords.x,
+ top: this.paper_coords.y + this.circle_radius * this.h_ratio + this.options.node_label_distance,
+ opacity: opacity
+ });
+ var _color = this.model.get("color") || (this.model.get("created_by") || Utils._USER_PLACEHOLDER(this.renkan)).get("color");
+ this.circle.strokeColor = _color;
+ var _pc = this.paper_coords;
+ this.all_buttons.forEach(function(b) {
+ b.moveTo(_pc);
+ });
+ var lastImage = this.img;
+ this.img = this.model.get("image");
+ if (this.img && this.img !== lastImage) {
+ this.showImage();
+ }
+ if (this.node_image && !this.img) {
+ this.node_image.remove();
+ delete this.node_image;
+ }
+
+ if (this.renderer.minimap) {
+ this.minimap_circle.fillColor = _color;
+ var minipos = this.renderer.toMinimapCoords(_model_coords),
+ miniradius = this.renderer.minimap.scale * _baseRadius,
+ minisize = new paper.Size([miniradius, miniradius]);
+ this.minimap_circle.fitBounds(minipos.subtract(minisize), minisize.multiply(2));
+ }
+
+ if (!_dontRedrawEdges) {
+ var _this = this;
+ _.each(
+ this.project.get("edges").filter(
+ function (ed) {
+ return ((ed.get("to") === _this.model) || (ed.get("from") === _this.model));
+ }
+ ),
+ function(edge, index, list) {
+ var repr = _this.renderer.getRepresentationByModel(edge);
+ if (repr && typeof repr.from_representation !== "undefined" && typeof repr.from_representation.paper_coords !== "undefined" && typeof repr.to_representation !== "undefined" && typeof repr.to_representation.paper_coords !== "undefined") {
+ repr.redraw();
+ }
+ }
+ );
+ }
+
+ },
+ showImage: function() {
+ var _image = null;
+ if (typeof this.renderer.image_cache[this.img] === "undefined") {
+ _image = new Image();
+ this.renderer.image_cache[this.img] = _image;
+ _image.src = this.img;
+ } else {
+ _image = this.renderer.image_cache[this.img];
+ }
+ if (_image.width) {
+ if (this.node_image) {
+ this.node_image.remove();
+ }
+ this.renderer.node_layer.activate();
+ var width = _image.width,
+ height = _image.height,
+ clipPath = this.model.get("clip_path"),
+ hasClipPath = (typeof clipPath !== "undefined" && clipPath),
+ _clip = null,
+ baseRadius = null,
+ centerPoint = null;
+
+ if (hasClipPath) {
+ _clip = new paper.Path();
+ var instructions = clipPath.match(/[a-z][^a-z]+/gi) || [],
+ lastCoords = [0,0],
+ minX = Infinity,
+ minY = Infinity,
+ maxX = -Infinity,
+ maxY = -Infinity;
+
+ var transformCoords = function(tabc, relative) {
+ var newCoords = tabc.slice(1).map(function(v, k) {
+ var res = parseFloat(v),
+ isY = k % 2;
+ if (isY) {
+ res = ( res - 0.5 ) * height;
+ } else {
+ res = ( res - 0.5 ) * width;
+ }
+ if (relative) {
+ res += lastCoords[isY];
+ }
+ if (isY) {
+ minY = Math.min(minY, res);
+ maxY = Math.max(maxY, res);
+ } else {
+ minX = Math.min(minX, res);
+ maxX = Math.max(maxX, res);
+ }
+ return res;
+ });
+ lastCoords = newCoords.slice(-2);
+ return newCoords;
+ };
+
+ instructions.forEach(function(instr) {
+ var coords = instr.match(/([a-z]|[0-9.-]+)/ig) || [""];
+ switch(coords[0]) {
+ case "M":
+ _clip.moveTo(transformCoords(coords));
+ break;
+ case "m":
+ _clip.moveTo(transformCoords(coords, true));
+ break;
+ case "L":
+ _clip.lineTo(transformCoords(coords));
+ break;
+ case "l":
+ _clip.lineTo(transformCoords(coords, true));
+ break;
+ case "C":
+ _clip.cubicCurveTo(transformCoords(coords));
+ break;
+ case "c":
+ _clip.cubicCurveTo(transformCoords(coords, true));
+ break;
+ case "Q":
+ _clip.quadraticCurveTo(transformCoords(coords));
+ break;
+ case "q":
+ _clip.quadraticCurveTo(transformCoords(coords, true));
+ break;
+ }
+ });
+
+ baseRadius = Math[this.options.node_images_fill_mode ? "min" : "max"](maxX - minX, maxY - minY) / 2;
+ centerPoint = new paper.Point((maxX + minX) / 2, (maxY + minY) / 2);
+ if (!this.options.show_node_circles) {
+ this.h_ratio = (maxY - minY) / (2 * baseRadius);
+ }
+ } else {
+ baseRadius = Math[this.options.node_images_fill_mode ? "min" : "max"](width, height) / 2;
+ centerPoint = new paper.Point(0,0);
+ if (!this.options.show_node_circles) {
+ this.h_ratio = height / (2 * baseRadius);
+ }
+ }
+ var _raster = new paper.Raster(_image);
+ _raster.locked = true; // Disable mouse events on icon
+ if (hasClipPath) {
+ _raster = new paper.Group(_clip, _raster);
+ _raster.opacity = 0.99;
+ /* This is a workaround to allow clipping at group level
+ * If opacity was set to 1, paper.js would merge all clipping groups in one (known bug).
+ */
+ _raster.clipped = true;
+ _clip.__representation = this;
+ }
+ if (this.options.clip_node_images) {
+ var _circleClip = this.shapeBuilder.getImageShape(centerPoint, baseRadius);
+ _raster = new paper.Group(_circleClip, _raster);
+ _raster.opacity = 0.99;
+ _raster.clipped = true;
+ _circleClip.__representation = this;
+ }
+ this.image_delta = centerPoint.divide(baseRadius);
+ this.node_image = _raster;
+ this.node_image.__representation = _this;
+ this.node_image.scale(this.circle_radius / baseRadius);
+ this.node_image.position = this.paper_coords.subtract(this.image_delta.multiply(this.circle_radius));
+ this.redraw();
+ this.renderer.throttledPaperDraw();
+ } else {
+ var _this = this;
+ $(_image).on("load", function() {
+ _this.showImage();
+ });
+ }
+ },
+ paperShift: function(_delta) {
+ if (this.options.editor_mode) {
+ if (!this.renkan.read_only) {
+ this.is_dragging = true;
+ this.paper_coords = this.paper_coords.add(_delta);
+ this.redraw();
+ }
+ } else {
+ this.renderer.paperShift(_delta);
+ }
+ },
+ openEditor: function() {
+ this.renderer.removeRepresentationsOfType("editor");
+ var _editor = this.renderer.addRepresentation("NodeEditor",null);
+ _editor.source_representation = this;
+ _editor.draw();
+ },
+ select: function() {
+ this.selected = true;
+ this.circle.strokeWidth = this.options.selected_node_stroke_width;
+ if (this.renderer.isEditable()) {
+ this.active_buttons.forEach(function(b) {
+ b.show();
+ });
+ }
+ var _uri = this.model.get("uri");
+ if (_uri) {
+ $('.Rk-Bin-Item').each(function() {
+ var _el = $(this);
+ if (_el.attr("data-uri") === _uri) {
+ _el.addClass("selected");
+ }
+ });
+ }
+ if (!this.options.editor_mode) {
+ this.openEditor();
+ }
+
+ if (this.renderer.minimap) {
+ this.minimap_circle.strokeWidth = this.options.minimap_highlight_weight;
+ this.minimap_circle.strokeColor = this.options.minimap_highlight_color;
+ }
+ this._super("select");
+ },
+ unselect: function(_newTarget) {
+ if (!_newTarget || _newTarget.source_representation !== this) {
+ this.selected = false;
+ this.all_buttons.forEach(function(b) {
+ b.hide();
+ });
+ this.circle.strokeWidth = this.options.node_stroke_width;
+ $('.Rk-Bin-Item').removeClass("selected");
+ if (this.renderer.minimap) {
+ this.minimap_circle.strokeColor = undefined;
+ }
+ this._super("unselect");
+ }
+ },
+ highlight: function(textToReplace) {
+ var hlvalue = textToReplace || true;
+ if (this.highlighted === hlvalue) {
+ return;
+ }
+ this.highlighted = hlvalue;
+ this.redraw();
+ this.renderer.throttledPaperDraw();
+ },
+ unhighlight: function() {
+ if (!this.highlighted) {
+ return;
+ }
+ this.highlighted = false;
+ this.redraw();
+ this.renderer.throttledPaperDraw();
+ },
+ saveCoords: function() {
+ var _coords = this.renderer.toModelCoords(this.paper_coords),
+ _data = {
+ position: {
+ x: _coords.x,
+ y: _coords.y
+ }
+ };
+ if (this.renderer.isEditable()) {
+ this.model.set(_data);
+ }
+ },
+ mousedown: function(_event, _isTouch) {
+ if (_isTouch) {
+ this.renderer.unselectAll();
+ this.select();
+ }
+ },
+ mouseup: function(_event, _isTouch) {
+ if (this.renderer.is_dragging && this.renderer.isEditable()) {
+ this.saveCoords();
+ } else {
+ if (!_isTouch && !this.model.get("delete_scheduled")) {
+ this.openEditor();
+ }
+ this.model.trigger("clicked");
+ }
+ this.renderer.click_target = null;
+ this.renderer.is_dragging = false;
+ this.is_dragging = false;
+ },
+ destroy: function(_event) {
+ this._super("destroy");
+ this.all_buttons.forEach(function(b) {
+ b.destroy();
+ });
+ this.circle.remove();
+ this.title.remove();
+ if (this.renderer.minimap) {
+ this.minimap_circle.remove();
+ }
+ if (this.node_image) {
+ this.node_image.remove();
+ }
+ }
+ });
+
+ return NodeRepr;
+
+});
+
+
+define('renderer/edge',['jquery', 'underscore', 'requtils', 'renderer/baserepresentation'], function ($, _, requtils, BaseRepresentation) {
+
+
+ var Utils = requtils.getUtils();
+
+ /* Edge Class Begin */
+
+ //var Edge = Renderer.Edge = Utils.inherit(Renderer._BaseRepresentation);
+ var Edge = Utils.inherit(BaseRepresentation);
+
+ _(Edge.prototype).extend({
+ _init: function() {
+ this.renderer.edge_layer.activate();
+ this.type = "Edge";
+ this.from_representation = this.renderer.getRepresentationByModel(this.model.get("from"));
+ this.to_representation = this.renderer.getRepresentationByModel(this.model.get("to"));
+ this.bundle = this.renderer.addToBundles(this);
+ this.line = new paper.Path();
+ this.line.add([0,0],[0,0],[0,0]);
+ this.line.__representation = this;
+ this.line.strokeWidth = this.options.edge_stroke_width;
+ this.arrow = new paper.Path();
+ this.arrow.add(
+ [ 0, 0 ],
+ [ this.options.edge_arrow_length, this.options.edge_arrow_width / 2 ],
+ [ 0, this.options.edge_arrow_width ]
+ );
+ this.arrow.__representation = this;
+ this.text = $('<div class="Rk-Label Rk-Edge-Label">').appendTo(this.renderer.labels_$);
+ this.arrow_angle = 0;
+ if (this.options.editor_mode) {
+ var Renderer = requtils.getRenderer();
+ this.normal_buttons = [
+ new Renderer.EdgeEditButton(this.renderer, null),
+ new Renderer.EdgeRemoveButton(this.renderer, null)
+ ];
+ this.pending_delete_buttons = [
+ new Renderer.EdgeRevertButton(this.renderer, null)
+ ];
+ this.all_buttons = this.normal_buttons.concat(this.pending_delete_buttons);
+ for (var i = 0; i < this.all_buttons.length; i++) {
+ this.all_buttons[i].source_representation = this;
+ }
+ this.active_buttons = [];
+ } else {
+ this.active_buttons = this.all_buttons = [];
+ }
+
+ if (this.renderer.minimap) {
+ this.renderer.minimap.edge_layer.activate();
+ this.minimap_line = new paper.Path();
+ this.minimap_line.add([0,0],[0,0]);
+ this.minimap_line.__representation = this.renderer.minimap.miniframe.__representation;
+ this.minimap_line.strokeWidth = 1;
+ }
+ },
+ redraw: function() {
+ var from = this.model.get("from"),
+ to = this.model.get("to");
+ if (!from || !to) {
+ return;
+ }
+ this.from_representation = this.renderer.getRepresentationByModel(from);
+ this.to_representation = this.renderer.getRepresentationByModel(to);
+ if (typeof this.from_representation === "undefined" || typeof this.to_representation === "undefined") {
+ return;
+ }
+ var _p0a = this.from_representation.paper_coords,
+ _p1a = this.to_representation.paper_coords,
+ _v = _p1a.subtract(_p0a),
+ _r = _v.length,
+ _u = _v.divide(_r),
+ _ortho = new paper.Point([- _u.y, _u.x]),
+ _group_pos = this.bundle.getPosition(this),
+ _delta = _ortho.multiply( this.options.edge_gap_in_bundles * _group_pos ),
+ _p0b = _p0a.add(_delta), /* Adding a 4 px difference */
+ _p1b = _p1a.add(_delta), /* to differentiate bundled links */
+ _a = _v.angle,
+ _textdelta = _ortho.multiply(this.options.edge_label_distance),
+ _handle = _v.divide(3),
+ _color = this.model.get("color") || this.model.get("color") || (this.model.get("created_by") || Utils._USER_PLACEHOLDER(this.renkan)).get("color"),
+ opacity = 1;
+
+ if (this.model.get("delete_scheduled") || this.from_representation.model.get("delete_scheduled") || this.to_representation.model.get("delete_scheduled")) {
+ opacity = 0.5;
+ this.line.dashArray = [2, 2];
+ } else {
+ opacity = 1;
+ this.line.dashArray = null;
+ }
+
+ var old_act_btn = this.active_buttons;
+
+ this.active_buttons = this.model.get("delete_scheduled") ? this.pending_delete_buttons : this.normal_buttons;
+
+ if (this.selected && this.renderer.isEditable() && old_act_btn !== this.active_buttons) {
+ old_act_btn.forEach(function(b) {
+ b.hide();
+ });
+ this.active_buttons.forEach(function(b) {
+ b.show();
+ });
+ }
+
+ this.paper_coords = _p0b.add(_p1b).divide(2);
+ this.line.strokeColor = _color;
+ this.line.opacity = opacity;
+ this.line.segments[0].point = _p0a;
+ this.line.segments[1].point = this.paper_coords;
+ this.line.segments[1].handleIn = _handle.multiply(-1);
+ this.line.segments[1].handleOut = _handle;
+ this.line.segments[2].point = _p1a;
+ this.arrow.rotate(_a - this.arrow_angle);
+ this.arrow.fillColor = _color;
+ this.arrow.opacity = opacity;
+ this.arrow.position = this.paper_coords;
+ this.arrow_angle = _a;
+ if (_a > 90) {
+ _a -= 180;
+ _textdelta = _textdelta.multiply(-1);
+ }
+ if (_a < -90) {
+ _a += 180;
+ _textdelta = _textdelta.multiply(-1);
+ }
+ var _text = this.model.get("title") || this.renkan.translate(this.options.label_untitled_edges) || "";
+ _text = Utils.shortenText(_text, this.options.node_label_max_length);
+ this.text.text(_text);
+ var _textpos = this.paper_coords.add(_textdelta);
+ this.text.css({
+ left: _textpos.x,
+ top: _textpos.y,
+ transform: "rotate(" + _a + "deg)",
+ "-moz-transform": "rotate(" + _a + "deg)",
+ "-webkit-transform": "rotate(" + _a + "deg)",
+ opacity: opacity
+ });
+ this.text_angle = _a;
+
+ var _pc = this.paper_coords;
+ this.all_buttons.forEach(function(b) {
+ b.moveTo(_pc);
+ });
+
+ if (this.renderer.minimap) {
+ this.minimap_line.strokeColor = _color;
+ this.minimap_line.segments[0].point = this.renderer.toMinimapCoords(new paper.Point(this.from_representation.model.get("position")));
+ this.minimap_line.segments[1].point = this.renderer.toMinimapCoords(new paper.Point(this.to_representation.model.get("position")));
+ }
+ },
+ openEditor: function() {
+ this.renderer.removeRepresentationsOfType("editor");
+ var _editor = this.renderer.addRepresentation("EdgeEditor",null);
+ _editor.source_representation = this;
+ _editor.draw();
+ },
+ select: function() {
+ this.selected = true;
+ this.line.strokeWidth = this.options.selected_edge_stroke_width;
+ if (this.renderer.isEditable()) {
+ this.active_buttons.forEach(function(b) {
+ b.show();
+ });
+ }
+ if (!this.options.editor_mode) {
+ this.openEditor();
+ }
+ this._super("select");
+ },
+ unselect: function(_newTarget) {
+ if (!_newTarget || _newTarget.source_representation !== this) {
+ this.selected = false;
+ if (this.options.editor_mode) {
+ this.all_buttons.forEach(function(b) {
+ b.hide();
+ });
+ }
+ this.line.strokeWidth = this.options.edge_stroke_width;
+ this._super("unselect");
+ }
+ },
+ mousedown: function(_event, _isTouch) {
+ if (_isTouch) {
+ this.renderer.unselectAll();
+ this.select();
+ }
+ },
+ mouseup: function(_event, _isTouch) {
+ if (!this.renkan.read_only && this.renderer.is_dragging) {
+ this.from_representation.saveCoords();
+ this.to_representation.saveCoords();
+ this.from_representation.is_dragging = false;
+ this.to_representation.is_dragging = false;
+ } else {
+ if (!_isTouch) {
+ this.openEditor();
+ }
+ this.model.trigger("clicked");
+ }
+ this.renderer.click_target = null;
+ this.renderer.is_dragging = false;
+ },
+ paperShift: function(_delta) {
+ if (this.options.editor_mode) {
+ if (!this.options.read_only) {
+ this.from_representation.paperShift(_delta);
+ this.to_representation.paperShift(_delta);
+ }
+ } else {
+ this.renderer.paperShift(_delta);
+ }
+ },
+ destroy: function() {
+ this._super("destroy");
+ this.line.remove();
+ this.arrow.remove();
+ this.text.remove();
+ if (this.renderer.minimap) {
+ this.minimap_line.remove();
+ }
+ this.all_buttons.forEach(function(b) {
+ b.destroy();
+ });
+ var _this = this;
+ this.bundle.edges = _(this.bundle.edges).reject(function(_edge) {
+ return _this === _edge;
+ });
+ }
+ });
+
+ return Edge;
+
+});
+
+
+
+define('renderer/tempedge',['jquery', 'underscore', 'requtils', 'renderer/baserepresentation'], function ($, _, requtils, BaseRepresentation) {
+
+
+ var Utils = requtils.getUtils();
+
+ /* TempEdge Class Begin */
+
+ //var TempEdge = Renderer.TempEdge = Utils.inherit(Renderer._BaseRepresentation);
+ var TempEdge = Utils.inherit(BaseRepresentation);
+
+ _(TempEdge.prototype).extend({
+ _init: function() {
+ this.renderer.edge_layer.activate();
+ this.type = "Temp-edge";
+
+ var _color = (this.project.get("users").get(this.renkan.current_user) || Utils._USER_PLACEHOLDER(this.renkan)).get("color");
+ this.line = new paper.Path();
+ this.line.strokeColor = _color;
+ this.line.dashArray = [4, 2];
+ this.line.strokeWidth = this.options.selected_edge_stroke_width;
+ this.line.add([0,0],[0,0]);
+ this.line.__representation = this;
+ this.arrow = new paper.Path();
+ this.arrow.fillColor = _color;
+ this.arrow.add(
+ [ 0, 0 ],
+ [ this.options.edge_arrow_length, this.options.edge_arrow_width / 2 ],
+ [ 0, this.options.edge_arrow_width ]
+ );
+ this.arrow.__representation = this;
+ this.arrow_angle = 0;
+ },
+ redraw: function() {
+ var _p0 = this.from_representation.paper_coords,
+ _p1 = this.end_pos,
+ _a = _p1.subtract(_p0).angle,
+ _c = _p0.add(_p1).divide(2);
+ this.line.segments[0].point = _p0;
+ this.line.segments[1].point = _p1;
+ this.arrow.rotate(_a - this.arrow_angle);
+ this.arrow.position = _c;
+ this.arrow_angle = _a;
+ },
+ paperShift: function(_delta) {
+ if (!this.renderer.isEditable()) {
+ this.renderer.removeRepresentation(_this);
+ paper.view.draw();
+ return;
+ }
+ this.end_pos = this.end_pos.add(_delta);
+ var _hitResult = paper.project.hitTest(this.end_pos);
+ this.renderer.findTarget(_hitResult);
+ this.redraw();
+ },
+ mouseup: function(_event, _isTouch) {
+ var _hitResult = paper.project.hitTest(_event.point),
+ _model = this.from_representation.model,
+ _endDrag = true;
+ if (_hitResult && typeof _hitResult.item.__representation !== "undefined") {
+ var _target = _hitResult.item.__representation;
+ if (_target.type.substr(0,4) === "Node") {
+ var _destmodel = _target.model || _target.source_representation.model;
+ if (_model !== _destmodel) {
+ var _data = {
+ id: Utils.getUID('edge'),
+ created_by: this.renkan.current_user,
+ from: _model,
+ to: _destmodel
+ };
+ if (this.renderer.isEditable()) {
+ this.project.addEdge(_data);
+ }
+ }
+ }
+
+ if (_model === _target.model || (_target.source_representation && _target.source_representation.model === _model)) {
+ _endDrag = false;
+ this.renderer.is_dragging = true;
+ }
+ }
+ if (_endDrag) {
+ this.renderer.click_target = null;
+ this.renderer.is_dragging = false;
+ this.renderer.removeRepresentation(this);
+ paper.view.draw();
+ }
+ },
+ destroy: function() {
+ this.arrow.remove();
+ this.line.remove();
+ }
+ });
+
+ /* TempEdge Class End */
+
+ return TempEdge;
+
+});
+
+
+define('renderer/baseeditor',['jquery', 'underscore', 'requtils', 'renderer/baserepresentation'], function ($, _, requtils, BaseRepresentation) {
+
+
+ var Utils = requtils.getUtils();
+
+ /* _BaseEditor Begin */
+ //var _BaseEditor = Renderer._BaseEditor = Utils.inherit(Renderer._BaseRepresentation);
+ var _BaseEditor = Utils.inherit(BaseRepresentation);
+
+ _(_BaseEditor.prototype).extend({
+ _init: function() {
+ this.renderer.buttons_layer.activate();
+ this.type = "editor";
+ this.editor_block = new paper.Path();
+ var _pts = _(_.range(8)).map(function() {return [0,0];});
+ this.editor_block.add.apply(this.editor_block, _pts);
+ this.editor_block.strokeWidth = this.options.tooltip_border_width;
+ this.editor_block.strokeColor = this.options.tooltip_border_color;
+ this.editor_block.opacity = 0.8;
+ this.editor_$ = $('<div>')
+ .appendTo(this.renderer.editor_$)
+ .css({
+ position: "absolute",
+ opacity: 0.8
+ })
+ .hide();
+ },
+ destroy: function() {
+ this.editor_block.remove();
+ this.editor_$.remove();
+ }
+ });
+
+ /* _BaseEditor End */
+
+ return _BaseEditor;
+
+});
+
+
+define('renderer/nodeeditor',['jquery', 'underscore', 'requtils', 'renderer/baseeditor'], function ($, _, requtils, BaseEditor) {
+
+
+ var Utils = requtils.getUtils();
+
+ /* NodeEditor Begin */
+ //var NodeEditor = Renderer.NodeEditor = Utils.inherit(Renderer._BaseEditor);
+ var NodeEditor = Utils.inherit(BaseEditor);
+
+ _(NodeEditor.prototype).extend({
+ template: _.template(
+ '<h2><span class="Rk-CloseX">×</span><%-renkan.translate("Edit Node")%></span></h2>' +
+ '<p><label><%-renkan.translate("Title:")%></label><input class="Rk-Edit-Title" type="text" value="<%-node.title%>"/></p>' +
+ '<% if (options.show_node_editor_uri) { %><p><label><%-renkan.translate("URI:")%></label><input class="Rk-Edit-URI" type="text" value="<%-node.uri%>"/><a class="Rk-Edit-Goto" href="<%-node.uri%>" target="_blank"></a></p><% } %>' +
+ '<% if (options.show_node_editor_description) { %><p><label><%-renkan.translate("Description:")%></label><textarea class="Rk-Edit-Description"><%-node.description%></textarea></p><% } %>' +
+ '<% if (options.show_node_editor_size) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Size:")%></span><a href="#" class="Rk-Edit-Size-Down">-</a><span class="Rk-Edit-Size-Value"><%-node.size%></span><a href="#" class="Rk-Edit-Size-Up">+</a></p><% } %>' +
+ '<% if (options.show_node_editor_color) { %><div class="Rk-Editor-p"><span class="Rk-Editor-Label"><%-renkan.translate("Node color:")%></span><div class="Rk-Edit-ColorPicker-Wrapper"><span class="Rk-Edit-Color" style="background:<%-node.color%>;"><span class="Rk-Edit-ColorTip"></span></span>' +
+ '<%= renkan.colorPicker %><span class="Rk-Edit-ColorPicker-Text"><%- renkan.translate("Choose color") %></span></div></div><% } %>' +
+ '<% if (options.show_node_editor_image) { %><div class="Rk-Edit-ImgWrap"><div class="Rk-Edit-ImgPreview"><img src="<%-node.image || node.image_placeholder%>" />' +
+ '<% if (node.clip_path) { %><svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewbox="0 0 1 1" preserveAspectRatio="none"><path style="stroke-width: .02; stroke:red; fill-opacity:.3; fill:red;" d="<%- node.clip_path %>"/></svg><% }%>' +
+ '</div></div><p><label><%-renkan.translate("Image URL:")%></label><input class="Rk-Edit-Image" type="text" value="<%-node.image%>"/></p>' +
+ '<p><label><%-renkan.translate("Choose Image File:")%></label><input class="Rk-Edit-Image-File" type="file" accept="image/*"/></p><% } %>' +
+ '<% if (options.show_node_editor_creator && node.has_creator) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Created by:")%></span> <span class="Rk-UserColor" style="background:<%-node.created_by_color%>;"></span><%- shortenText(node.created_by_title, 25) %></p><% } %>' +
+ '<% if (options.change_shapes) { %><p><label><%-renkan.translate("Shapes available")%>:</label> <select class="Rk-Edit-Shape">' +
+ '<option class="Rk-Edit-Vocabulary-Property" value="circle"<% if (node.shape === "circle") { %> selected<% } %>><%- renkan.translate("Circle") %></option>' +
+ '<option class="Rk-Edit-Vocabulary-Property" value="rectangle"<% if (node.shape === "rectangle") { %> selected<% } %>><%- renkan.translate("Square") %></option>' +
+ '<option class="Rk-Edit-Vocabulary-Property" value="diamond"<% if (node.shape === "diamond") { %> selected<% } %>><%- renkan.translate("Diamond") %></option>' +
+ '<option class="Rk-Edit-Vocabulary-Property" value="polygon"<% if (node.shape === "polygon") { %> selected<% } %>><%- renkan.translate("Hexagone") %></option>' +
+ '<option class="Rk-Edit-Vocabulary-Property" value="ellipse"<% if (node.shape === "ellipse") { %> selected<% } %>><%- renkan.translate("Ellipse") %></option>' +
+ '<option class="Rk-Edit-Vocabulary-Property" value="star"<% if (node.shape === "star") { %> selected<% } %>><%- renkan.translate("Star") %></option>' +
+ '</select></p><% } %>'
+ ),
+ readOnlyTemplate: _.template(
+ '<h2><span class="Rk-CloseX">×</span><% if (options.show_node_tooltip_color) { %><span class="Rk-UserColor" style="background:<%-node.color%>;"></span><% } %>' +
+ '<span class="Rk-Display-Title"><% if (node.uri) { %><a href="<%-node.uri%>" target="_blank"><% } %><%-node.title%><% if (node.uri) { %></a><% } %></span></h2>' +
+ '<% if (node.uri && options.show_node_tooltip_uri) { %><p class="Rk-Display-URI"><a href="<%-node.uri%>" target="_blank"><%-node.short_uri%></a></p><% } %>' +
+ '<% if (options.show_node_tooltip_description) { %><p class="Rk-Display-Description"><%-node.description%></p><% } %>' +
+ '<% if (node.image && options.show_node_tooltip_image) { %><img class="Rk-Display-ImgPreview" src="<%-node.image%>" /><% } %>' +
+ '<% if (node.has_creator && options.show_node_tooltip_creator) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Created by:")%></span><span class="Rk-UserColor" style="background:<%-node.created_by_color%>;"></span><%- shortenText(node.created_by_title, 25) %></p><% } %>'
+ ),
+ draw: function() {
+ var _model = this.source_representation.model,
+ _created_by = _model.get("created_by") || Utils._USER_PLACEHOLDER(this.renkan),
+ _template = (this.renderer.isEditable() ? this.template : this.readOnlyTemplate ),
+ _image_placeholder = this.options.static_url + "img/image-placeholder.png",
+ _size = (_model.get("size") || 0);
+ this.editor_$
+ .html(_template({
+ node: {
+ has_creator: !!_model.get("created_by"),
+ title: _model.get("title"),
+ uri: _model.get("uri"),
+ short_uri: Utils.shortenText((_model.get("uri") || "").replace(/^(https?:\/\/)?(www\.)?/,'').replace(/\/$/,''),40),
+ description: _model.get("description"),
+ image: _model.get("image") || "",
+ image_placeholder: _image_placeholder,
+ color: _model.get("color") || _created_by.get("color"),
+ clip_path: _model.get("clip_path") || false,
+ created_by_color: _created_by.get("color"),
+ created_by_title: _created_by.get("title"),
+ size: (_size > 0 ? "+" : "") + _size,
+ shape: _model.get("shape") || "circle"
+ },
+ renkan: this.renkan,
+ options: this.options,
+ shortenText: Utils.shortenText
+ }));
+ this.redraw();
+ var _this = this,
+ closeEditor = function() {
+ _this.renderer.removeRepresentation(_this);
+ paper.view.draw();
+ };
+
+ this.editor_$.find(".Rk-CloseX").click(closeEditor);
+
+ this.editor_$.find(".Rk-Edit-Goto").click(function() {
+ if (!_model.get("uri")) {
+ return false;
+ }
+ });
+
+ if (this.renderer.isEditable()) {
+
+ var onFieldChange = _(function() {
+ _(function() {
+ if (_this.renderer.isEditable()) {
+ var _data = {
+ title: _this.editor_$.find(".Rk-Edit-Title").val()
+ };
+ if (_this.options.show_node_editor_uri) {
+ _data.uri = _this.editor_$.find(".Rk-Edit-URI").val();
+ _this.editor_$.find(".Rk-Edit-Goto").attr("href",_data.uri || "#");
+ }
+ if (_this.options.show_node_editor_image) {
+ _data.image = _this.editor_$.find(".Rk-Edit-Image").val();
+ _this.editor_$.find(".Rk-Edit-ImgPreview").attr("src", _data.image || _image_placeholder);
+ }
+ if (_this.options.show_node_editor_description) {
+ _data.description = _this.editor_$.find(".Rk-Edit-Description").val();
+ }
+ if (_this.options.change_shapes) {
+ if(_model.get("shape")!==_this.editor_$.find(".Rk-Edit-Shape").val()){
+ _data.shape = _this.editor_$.find(".Rk-Edit-Shape").val();
+ _data.shape_changed = true;
+ }
+ }
+ _model.set(_data);
+ _this.redraw();
+ // For an unknown reason, we have to set data twice when we change shape, otherwise the image disappears.
+ if(_data.shape_changed===true){
+ _model.set(_data);
+ }
+ } else {
+ closeEditor();
+ }
+ }).defer();
+ }).throttle(500);
+
+ this.editor_$.on("keyup", function(_e) {
+ if (_e.keyCode === 27) {
+ closeEditor();
+ }
+ });
+
+ this.editor_$.find("input, textarea, select").on("change keyup paste", onFieldChange);
+
+ this.editor_$.find(".Rk-Edit-Image-File").change(function() {
+ if (this.files.length) {
+ var f = this.files[0],
+ fr = new FileReader();
+ if (f.type.substr(0,5) !== "image") {
+ alert(_this.renkan.translate("This file is not an image"));
+ return;
+ }
+ if (f.size > (_this.options.uploaded_image_max_kb * 1024)) {
+ alert(_this.renkan.translate("Image size must be under ") + _this.options.uploaded_image_max_kb + _this.renkan.translate("KB"));
+ return;
+ }
+ fr.onload = function(e) {
+ _this.editor_$.find(".Rk-Edit-Image").val(e.target.result);
+ onFieldChange();
+ };
+ fr.readAsDataURL(f);
+ }
+ });
+ this.editor_$.find(".Rk-Edit-Title")[0].focus();
+
+ var _picker = _this.editor_$.find(".Rk-Edit-ColorPicker");
+
+ this.editor_$.find(".Rk-Edit-ColorPicker-Wrapper").hover(
+ function(_e) {
+ _e.preventDefault();
+ _picker.show();
+ },
+ function(_e) {
+ _e.preventDefault();
+ _picker.hide();
+ }
+ );
+
+ _picker.find("li").hover(
+ function(_e) {
+ _e.preventDefault();
+ _this.editor_$.find(".Rk-Edit-Color").css("background", $(this).attr("data-color"));
+ },
+ function(_e) {
+ _e.preventDefault();
+ _this.editor_$.find(".Rk-Edit-Color").css("background", _model.get("color") || (_model.get("created_by") || Utils._USER_PLACEHOLDER(_this.renkan)).get("color"));
+ }
+ ).click(function(_e) {
+ _e.preventDefault();
+ if (_this.renderer.isEditable()) {
+ _model.set("color", $(this).attr("data-color"));
+ _picker.hide();
+ paper.view.draw();
+ } else {
+ closeEditor();
+ }
+ });
+
+ var shiftSize = function(n) {
+ if (_this.renderer.isEditable()) {
+ var _newsize = n+(_model.get("size") || 0);
+ _this.editor_$.find(".Rk-Edit-Size-Value").text((_newsize > 0 ? "+" : "") + _newsize);
+ _model.set("size", _newsize);
+ paper.view.draw();
+ } else {
+ closeEditor();
+ }
+ };
+
+ this.editor_$.find(".Rk-Edit-Size-Down").click(function() {
+ shiftSize(-1);
+ return false;
+ });
+ this.editor_$.find(".Rk-Edit-Size-Up").click(function() {
+ shiftSize(1);
+ return false;
+ });
+ } else {
+ if (typeof this.source_representation.highlighted === "object") {
+ var titlehtml = this.source_representation.highlighted.replace(_(_model.get("title")).escape(),'<span class="Rk-Highlighted">$1</span>');
+ this.editor_$.find(".Rk-Display-Title" + (_model.get("uri") ? " a" : "")).html(titlehtml);
+ if (this.options.show_node_tooltip_description) {
+ this.editor_$.find(".Rk-Display-Description").html(this.source_representation.highlighted.replace(_(_model.get("description")).escape(),'<span class="Rk-Highlighted">$1</span>'));
+ }
+ }
+ }
+ this.editor_$.find("img").load(function() {
+ _this.redraw();
+ });
+ },
+ redraw: function() {
+ var _coords = this.source_representation.paper_coords;
+ Utils.drawEditBox(this.options, _coords, this.editor_block, this.source_representation.circle_radius * 0.75, this.editor_$);
+ this.editor_$.show();
+ paper.view.draw();
+ }
+ });
+
+ /* NodeEditor End */
+
+ return NodeEditor;
+
+});
+
+
+define('renderer/edgeeditor',['jquery', 'underscore', 'requtils', 'renderer/baseeditor'], function ($, _, requtils, BaseEditor) {
+
+
+ var Utils = requtils.getUtils();
+
+ /* EdgeEditor Begin */
+
+ //var EdgeEditor = Renderer.EdgeEditor = Utils.inherit(Renderer._BaseEditor);
+ var EdgeEditor = Utils.inherit(BaseEditor);
+
+ _(EdgeEditor.prototype).extend({
+ template: _.template(
+ '<h2><span class="Rk-CloseX">×</span><%-renkan.translate("Edit Edge")%></span></h2>' +
+ '<p><label><%-renkan.translate("Title:")%></label><input class="Rk-Edit-Title" type="text" value="<%-edge.title%>"/></p>' +
+ '<% if (options.show_edge_editor_uri) { %><p><label><%-renkan.translate("URI:")%></label><input class="Rk-Edit-URI" type="text" value="<%-edge.uri%>"/><a class="Rk-Edit-Goto" href="<%-edge.uri%>" target="_blank"></a></p>' +
+ '<% if (options.properties.length) { %><p><label><%-renkan.translate("Choose from vocabulary:")%></label><select class="Rk-Edit-Vocabulary">' +
+ '<% _(options.properties).each(function(ontology) { %><option class="Rk-Edit-Vocabulary-Class" value=""><%- renkan.translate(ontology.label) %></option>' +
+ '<% _(ontology.properties).each(function(property) { var uri = ontology["base-uri"] + property.uri; %><option class="Rk-Edit-Vocabulary-Property" value="<%- uri %>' +
+ '"<% if (uri === edge.uri) { %> selected<% } %>><%- renkan.translate(property.label) %></option>' +
+ '<% }) %><% }) %></select></p><% } } %>' +
+ '<% if (options.show_edge_editor_color) { %><div class="Rk-Editor-p"><span class="Rk-Editor-Label"><%-renkan.translate("Edge color:")%></span><div class="Rk-Edit-ColorPicker-Wrapper"><span class="Rk-Edit-Color" style="background:<%-edge.color%>;"><span class="Rk-Edit-ColorTip"></span></span>' +
+ '<%= renkan.colorPicker %><span class="Rk-Edit-ColorPicker-Text"><%- renkan.translate("Choose color") %></span></div></div><% } %>' +
+ '<% if (options.show_edge_editor_direction) { %><p><span class="Rk-Edit-Direction"><%- renkan.translate("Change edge direction") %></span></p><% } %>' +
+ '<% if (options.show_edge_editor_nodes) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("From:")%></span><span class="Rk-UserColor" style="background:<%-edge.from_color%>;"></span><%- shortenText(edge.from_title, 25) %></p>' +
+ '<p><span class="Rk-Editor-Label"><%-renkan.translate("To:")%></span><span class="Rk-UserColor" style="background:<%-edge.to_color%>;"></span><%- shortenText(edge.to_title, 25) %></p><% } %>' +
+ '<% if (options.show_edge_editor_creator && edge.has_creator) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Created by:")%></span><span class="Rk-UserColor" style="background:<%-edge.created_by_color%>;"></span><%- shortenText(edge.created_by_title, 25) %></p><% } %>'
+ ),
+ readOnlyTemplate: _.template(
+ '<h2><span class="Rk-CloseX">×</span><% if (options.show_edge_tooltip_color) { %><span class="Rk-UserColor" style="background:<%-edge.color%>;"></span><% } %>' +
+ '<span class="Rk-Display-Title"><% if (edge.uri) { %><a href="<%-edge.uri%>" target="_blank"><% } %><%-edge.title%><% if (edge.uri) { %></a><% } %></span></h2>' +
+ '<% if (options.show_edge_tooltip_uri && edge.uri) { %><p class="Rk-Display-URI"><a href="<%-edge.uri%>" target="_blank"><%-edge.short_uri%></a></p><% } %>' +
+ '<p><%-edge.description%></p>' +
+ '<% if (options.show_edge_tooltip_nodes) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("From:")%></span><span class="Rk-UserColor" style="background:<%-edge.from_color%>;"></span><%- shortenText(edge.from_title, 25) %></p>' +
+ '<p><span class="Rk-Editor-Label"><%-renkan.translate("To:")%></span><span class="Rk-UserColor" style="background:<%-edge.to_color%>;"></span><%- shortenText(edge.to_title, 25) %></p><% } %>' +
+ '<% if (options.show_edge_tooltip_creator && edge.has_creator) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Created by:")%></span><span class="Rk-UserColor" style="background:<%-edge.created_by_color%>;"></span><%- shortenText(edge.created_by_title, 25) %></p><% } %>'
+ ),
+ draw: function() {
+ var _model = this.source_representation.model,
+ _from_model = _model.get("from"),
+ _to_model = _model.get("to"),
+ _created_by = _model.get("created_by") || Utils._USER_PLACEHOLDER(this.renkan),
+ _template = (this.renderer.isEditable() ? this.template : this.readOnlyTemplate);
+ this.editor_$
+ .html(_template({
+ edge: {
+ has_creator: !!_model.get("created_by"),
+ title: _model.get("title"),
+ uri: _model.get("uri"),
+ short_uri: Utils.shortenText((_model.get("uri") || "").replace(/^(https?:\/\/)?(www\.)?/,'').replace(/\/$/,''),40),
+ description: _model.get("description"),
+ color: _model.get("color") || _created_by.get("color"),
+ from_title: _from_model.get("title"),
+ to_title: _to_model.get("title"),
+ from_color: _from_model.get("color") || (_from_model.get("created_by") || Utils._USER_PLACEHOLDER(this.renkan)).get("color"),
+ to_color: _to_model.get("color") || (_to_model.get("created_by") || Utils._USER_PLACEHOLDER(this.renkan)).get("color"),
+ created_by_color: _created_by.get("color"),
+ created_by_title: _created_by.get("title")
+ },
+ renkan: this.renkan,
+ shortenText: Utils.shortenText,
+ options: this.options
+ }));
+ this.redraw();
+ var _this = this,
+ closeEditor = function() {
+ _this.renderer.removeRepresentation(_this);
+ paper.view.draw();
+ };
+ this.editor_$.find(".Rk-CloseX").click(closeEditor);
+ this.editor_$.find(".Rk-Edit-Goto").click(function() {
+ if (!_model.get("uri")) {
+ return false;
+ }
+ });
+
+ if (this.renderer.isEditable()) {
+
+ var onFieldChange = _(function() {
+ _(function() {
+ if (_this.renderer.isEditable()) {
+ var _data = {
+ title: _this.editor_$.find(".Rk-Edit-Title").val()
+ };
+ if (_this.options.show_edge_editor_uri) {
+ _data.uri = _this.editor_$.find(".Rk-Edit-URI").val();
+ }
+ _this.editor_$.find(".Rk-Edit-Goto").attr("href",_data.uri || "#");
+ _model.set(_data);
+ paper.view.draw();
+ } else {
+ closeEditor();
+ }
+ }).defer();
+ }).throttle(500);
+
+ this.editor_$.on("keyup", function(_e) {
+ if (_e.keyCode === 27) {
+ closeEditor();
+ }
+ });
+
+ this.editor_$.find("input").on("keyup change paste", onFieldChange);
+
+ this.editor_$.find(".Rk-Edit-Vocabulary").change(function() {
+ var e = $(this),
+ v = e.val();
+ if (v) {
+ _this.editor_$.find(".Rk-Edit-Title").val(e.find(":selected").text());
+ _this.editor_$.find(".Rk-Edit-URI").val(v);
+ onFieldChange();
+ }
+ });
+ this.editor_$.find(".Rk-Edit-Direction").click(function() {
+ if (_this.renderer.isEditable()) {
+ _model.set({
+ from: _model.get("to"),
+ to: _model.get("from")
+ });
+ _this.draw();
+ } else {
+ closeEditor();
+ }
+ });
+
+ var _picker = _this.editor_$.find(".Rk-Edit-ColorPicker");
+
+ this.editor_$.find(".Rk-Edit-ColorPicker-Wrapper").hover(
+ function(_e) {
+ _e.preventDefault();
+ _picker.show();
+ },
+ function(_e) {
+ _e.preventDefault();
+ _picker.hide();
+ }
+ );
+
+ _picker.find("li").hover(
+ function(_e) {
+ _e.preventDefault();
+ _this.editor_$.find(".Rk-Edit-Color").css("background", $(this).attr("data-color"));
+ },
+ function(_e) {
+ _e.preventDefault();
+ _this.editor_$.find(".Rk-Edit-Color").css("background", _model.get("color") || (_model.get("created_by") || Utils._USER_PLACEHOLDER(_this.renkan)).get("color"));
+ }
+ ).click(function(_e) {
+ _e.preventDefault();
+ if (_this.renderer.isEditable()) {
+ _model.set("color", $(this).attr("data-color"));
+ _picker.hide();
+ paper.view.draw();
+ } else {
+ closeEditor();
+ }
+ });
+ }
+ },
+ redraw: function() {
+ var _coords = this.source_representation.paper_coords;
+ Utils.drawEditBox(this.options, _coords, this.editor_block, 5, this.editor_$);
+ this.editor_$.show();
+ paper.view.draw();
+ }
+ });
+
+ /* EdgeEditor End */
+
+ return EdgeEditor;
+
+});
+
+
+define('renderer/nodebutton',['jquery', 'underscore', 'requtils', 'renderer/basebutton'], function ($, _, requtils, BaseButton) {
+
+
+ var Utils = requtils.getUtils();
+
+ /* _NodeButton Begin */
+
+ //var _NodeButton = Renderer._NodeButton = Utils.inherit(Renderer._BaseButton);
+ var _NodeButton = Utils.inherit(BaseButton);
+
+ _(_NodeButton.prototype).extend({
+ setSectorSize: function() {
+ var sectorInner = this.source_representation.circle_radius;
+ if (sectorInner !== this.lastSectorInner) {
+ if (this.sector) {
+ this.sector.destroy();
+ }
+ this.sector = this.renderer.drawSector(
+ this, 1 + sectorInner,
+ Utils._NODE_BUTTON_WIDTH + sectorInner,
+ this.startAngle,
+ this.endAngle,
+ 1,
+ this.imageName,
+ this.renkan.translate(this.text)
+ );
+ this.lastSectorInner = sectorInner;
+ }
+ }
+ });
+
+ /* _NodeButton End */
+
+ return _NodeButton;
+
+});
+
+
+define('renderer/nodeeditbutton',['jquery', 'underscore', 'requtils', 'renderer/nodebutton'], function ($, _, requtils, NodeButton) {
+
+
+ var Utils = requtils.getUtils();
+
+ /* NodeEditButton Begin */
+
+ //var NodeEditButton = Renderer.NodeEditButton = Utils.inherit(Renderer._NodeButton);
+ var NodeEditButton = Utils.inherit(NodeButton);
+
+ _(NodeEditButton.prototype).extend({
+ _init: function() {
+ this.type = "Node-edit-button";
+ this.lastSectorInner = 0;
+ this.startAngle = -135;
+ this.endAngle = -45;
+ this.imageName = "edit";
+ this.text = "Edit";
+ },
+ mouseup: function() {
+ if (!this.renderer.is_dragging) {
+ this.source_representation.openEditor();
+ }
+ }
+ });
+
+ /* NodeEditButton End */
+
+ return NodeEditButton;
+
+});
+
+
+define('renderer/noderemovebutton',['jquery', 'underscore', 'requtils', 'renderer/nodebutton'], function ($, _, requtils, NodeButton) {
+
+
+ var Utils = requtils.getUtils();
+
+ /* NodeRemoveButton Begin */
+
+ //var NodeRemoveButton = Renderer.NodeRemoveButton = Utils.inherit(Renderer._NodeButton);
+ var NodeRemoveButton = Utils.inherit(NodeButton);
+
+ _(NodeRemoveButton.prototype).extend({
+ _init: function() {
+ this.type = "Node-remove-button";
+ this.lastSectorInner = 0;
+ this.startAngle = 0;
+ this.endAngle = 90;
+ this.imageName = "remove";
+ this.text = "Remove";
+ },
+ mouseup: function() {
+ this.renderer.click_target = null;
+ this.renderer.is_dragging = false;
+ this.renderer.removeRepresentationsOfType("editor");
+ if (this.renderer.isEditable()) {
+ if (this.options.element_delete_delay) {
+ var delid = Utils.getUID("delete");
+ this.renderer.delete_list.push({
+ id: delid,
+ time: new Date().valueOf() + this.options.element_delete_delay
+ });
+ this.source_representation.model.set("delete_scheduled", delid);
+ } else {
+ if (confirm(this.renkan.translate('Do you really wish to remove node ') + '"' + this.source_representation.model.get("title") + '"?')) {
+ this.project.removeNode(this.source_representation.model);
+ }
+ }
+ }
+ }
+ });
+
+ /* NodeRemoveButton End */
+
+ return NodeRemoveButton;
+
+});
+
+
+define('renderer/noderevertbutton',['jquery', 'underscore', 'requtils', 'renderer/nodebutton'], function ($, _, requtils, NodeButton) {
+
+
+ var Utils = requtils.getUtils();
+
+ /* NodeRevertButton Begin */
+
+ //var NodeRevertButton = Renderer.NodeRevertButton = Utils.inherit(Renderer._NodeButton);
+ var NodeRevertButton = Utils.inherit(NodeButton);
+
+ _(NodeRevertButton.prototype).extend({
+ _init: function() {
+ this.type = "Node-revert-button";
+ this.lastSectorInner = 0;
+ this.startAngle = -135;
+ this.endAngle = 135;
+ this.imageName = "revert";
+ this.text = "Cancel deletion";
+ },
+ mouseup: function() {
+ this.renderer.click_target = null;
+ this.renderer.is_dragging = false;
+ if (this.renderer.isEditable()) {
+ this.source_representation.model.unset("delete_scheduled");
+ }
+ }
+ });
+
+ /* NodeRevertButton End */
+
+ return NodeRevertButton;
+
+});
+
+
+define('renderer/nodelinkbutton',['jquery', 'underscore', 'requtils', 'renderer/nodebutton'], function ($, _, requtils, NodeButton) {
+
+
+ var Utils = requtils.getUtils();
+
+ /* NodeLinkButton Begin */
+
+ //var NodeLinkButton = Renderer.NodeLinkButton = Utils.inherit(Renderer._NodeButton);
+ var NodeLinkButton = Utils.inherit(NodeButton);
+
+ _(NodeLinkButton.prototype).extend({
+ _init: function() {
+ this.type = "Node-link-button";
+ this.lastSectorInner = 0;
+ this.startAngle = 90;
+ this.endAngle = 180;
+ this.imageName = "link";
+ this.text = "Link to another node";
+ },
+ mousedown: function(_event, _isTouch) {
+ if (this.renderer.isEditable()) {
+ var _off = this.renderer.canvas_$.offset(),
+ _point = new paper.Point([
+ _event.pageX - _off.left,
+ _event.pageY - _off.top
+ ]);
+ this.renderer.click_target = null;
+ this.renderer.removeRepresentationsOfType("editor");
+ this.renderer.addTempEdge(this.source_representation, _point);
+ }
+ }
+ });
+
+ /* NodeLinkButton End */
+
+ return NodeLinkButton;
+
+});
+
+
+
+define('renderer/nodeenlargebutton',['jquery', 'underscore', 'requtils', 'renderer/nodebutton'], function ($, _, requtils, NodeButton) {
+
+
+ var Utils = requtils.getUtils();
+
+ /* NodeEnlargeButton Begin */
+
+ //var NodeEnlargeButton = Renderer.NodeEnlargeButton = Utils.inherit(Renderer._NodeButton);
+ var NodeEnlargeButton = Utils.inherit(NodeButton);
+
+ _(NodeEnlargeButton.prototype).extend({
+ _init: function() {
+ this.type = "Node-enlarge-button";
+ this.lastSectorInner = 0;
+ this.startAngle = -45;
+ this.endAngle = 0;
+ this.imageName = "enlarge";
+ this.text = "Enlarge";
+ },
+ mouseup: function() {
+ var _newsize = 1 + (this.source_representation.model.get("size") || 0);
+ this.source_representation.model.set("size", _newsize);
+ this.source_representation.select();
+ this.select();
+ paper.view.draw();
+ }
+ });
+
+ /* NodeEnlargeButton End */
+
+ return NodeEnlargeButton;
+
+});
+
+
+define('renderer/nodeshrinkbutton',['jquery', 'underscore', 'requtils', 'renderer/nodebutton'], function ($, _, requtils, NodeButton) {
+
+
+ var Utils = requtils.getUtils();
+
+ /* NodeShrinkButton Begin */
+
+ //var NodeShrinkButton = Renderer.NodeShrinkButton = Utils.inherit(Renderer._NodeButton);
+ var NodeShrinkButton = Utils.inherit(NodeButton);
+
+ _(NodeShrinkButton.prototype).extend({
+ _init: function() {
+ this.type = "Node-shrink-button";
+ this.lastSectorInner = 0;
+ this.startAngle = -180;
+ this.endAngle = -135;
+ this.imageName = "shrink";
+ this.text = "Shrink";
+ },
+ mouseup: function() {
+ var _newsize = -1 + (this.source_representation.model.get("size") || 0);
+ this.source_representation.model.set("size", _newsize);
+ this.source_representation.select();
+ this.select();
+ paper.view.draw();
+ }
+ });
+
+ /* NodeShrinkButton End */
+
+ return NodeShrinkButton;
+
+});
+
+
+define('renderer/edgeeditbutton',['jquery', 'underscore', 'requtils', 'renderer/basebutton'], function ($, _, requtils, BaseButton) {
+
+
+ var Utils = requtils.getUtils();
+
+ /* EdgeEditButton Begin */
+
+ //var EdgeEditButton = Renderer.EdgeEditButton = Utils.inherit(Renderer._BaseButton);
+ var EdgeEditButton = Utils.inherit(BaseButton);
+
+ _(EdgeEditButton.prototype).extend({
+ _init: function() {
+ this.type = "Edge-edit-button";
+ this.sector = this.renderer.drawSector(this, Utils._EDGE_BUTTON_INNER, Utils._EDGE_BUTTON_OUTER, -270, -90, 1, "edit", this.renkan.translate("Edit"));
+ },
+ mouseup: function() {
+ if (!this.renderer.is_dragging) {
+ this.source_representation.openEditor();
+ }
+ }
+ });
+
+ /* EdgeEditButton End */
+
+ return EdgeEditButton;
+
+});
+
+
+define('renderer/edgeremovebutton',['jquery', 'underscore', 'requtils', 'renderer/basebutton'], function ($, _, requtils, BaseButton) {
+
+
+ var Utils = requtils.getUtils();
+
+ /* EdgeRemoveButton Begin */
+
+ //var EdgeRemoveButton = Renderer.EdgeRemoveButton = Utils.inherit(Renderer._BaseButton);
+ var EdgeRemoveButton = Utils.inherit(BaseButton);
+
+ _(EdgeRemoveButton.prototype).extend({
+ _init: function() {
+ this.type = "Edge-remove-button";
+ this.sector = this.renderer.drawSector(this, Utils._EDGE_BUTTON_INNER, Utils._EDGE_BUTTON_OUTER, -90, 90, 1, "remove", this.renkan.translate("Remove"));
+ },
+ mouseup: function() {
+ this.renderer.click_target = null;
+ this.renderer.is_dragging = false;
+ this.renderer.removeRepresentationsOfType("editor");
+ if (this.renderer.isEditable()) {
+ if (this.options.element_delete_delay) {
+ var delid = Utils.getUID("delete");
+ this.renderer.delete_list.push({
+ id: delid,
+ time: new Date().valueOf() + this.options.element_delete_delay
+ });
+ this.source_representation.model.set("delete_scheduled", delid);
+ } else {
+ if (confirm(this.renkan.translate('Do you really wish to remove edge ') + '"' + this.source_representation.model.get("title") + '"?')) {
+ this.project.removeEdge(this.source_representation.model);
+ }
+ }
+ }
+ }
+ });
+
+ /* EdgeRemoveButton End */
+
+ return EdgeRemoveButton;
+
+});
+
+
+define('renderer/edgerevertbutton',['jquery', 'underscore', 'requtils', 'renderer/basebutton'], function ($, _, requtils, BaseButton) {
+
+
+ var Utils = requtils.getUtils();
+
+ /* EdgeRevertButton Begin */
+
+ //var EdgeRevertButton = Renderer.EdgeRevertButton = Utils.inherit(Renderer._BaseButton);
+ var EdgeRevertButton = Utils.inherit(BaseButton);
+
+ _(EdgeRevertButton.prototype).extend({
+ _init: function() {
+ this.type = "Edge-revert-button";
+ this.sector = this.renderer.drawSector(this, Utils._EDGE_BUTTON_INNER, Utils._EDGE_BUTTON_OUTER, -135, 135, 1, "revert", this.renkan.translate("Cancel deletion"));
+ },
+ mouseup: function() {
+ this.renderer.click_target = null;
+ this.renderer.is_dragging = false;
+ if (this.renderer.isEditable()) {
+ this.source_representation.model.unset("delete_scheduled");
+ }
+ }
+ });
+
+ /* EdgeRevertButton End */
+
+ return EdgeRevertButton;
+
+});
+
+
+define('renderer/miniframe',['jquery', 'underscore', 'requtils', 'renderer/baserepresentation'], function ($, _, requtils, BaseRepresentation) {
+
+
+ var Utils = requtils.getUtils();
+
+ /* MiniFrame Begin */
+
+ //var MiniFrame = Renderer.MiniFrame = Utils.inherit(Renderer._BaseRepresentation);
+ var MiniFrame = Utils.inherit(BaseRepresentation);
+
+ _(MiniFrame.prototype).extend({
+ paperShift: function(_delta) {
+ this.renderer.offset = this.renderer.offset.subtract(_delta.divide(this.renderer.minimap.scale).multiply(this.renderer.scale));
+ this.renderer.redraw();
+ },
+ mouseup: function(_delta) {
+ this.renderer.click_target = null;
+ this.renderer.is_dragging = false;
+ }
+ });
+
+ /* MiniFrame End */
+
+ return MiniFrame;
+
+});
+
+
+define('renderer/scene',['jquery', 'underscore', 'filesaver', 'requtils', 'renderer/miniframe'], function ($, _, filesaver, requtils, MiniFrame) {
+
+
+ var Utils = requtils.getUtils();
+
+ /* Scene Begin */
+
+ var Scene = function(_renkan) {
+ this.renkan = _renkan;
+ this.$ = $(".Rk-Render");
+ this.representations = [];
+ this.$.html(this.template(_renkan));
+ this.onStatusChange();
+ this.canvas_$ = this.$.find(".Rk-Canvas");
+ this.labels_$ = this.$.find(".Rk-Labels");
+ this.editor_$ = this.$.find(".Rk-Editor");
+ this.notif_$ = this.$.find(".Rk-Notifications");
+ paper.setup(this.canvas_$[0]);
+ this.scale = 1;
+ this.initialScale = 1;
+ this.offset = paper.view.center;
+ this.totalScroll = 0;
+ this.mouse_down = false;
+ this.click_target = null;
+ this.selected_target = null;
+ this.edge_layer = new paper.Layer();
+ this.node_layer = new paper.Layer();
+ this.buttons_layer = new paper.Layer();
+ this.delete_list = [];
+ this.redrawActive = true;
+
+ if (_renkan.options.show_minimap) {
+ this.minimap = {
+ background_layer: new paper.Layer(),
+ edge_layer: new paper.Layer(),
+ node_layer: new paper.Layer(),
+ node_group: new paper.Group(),
+ size: new paper.Size( _renkan.options.minimap_width, _renkan.options.minimap_height )
+ };
+
+ this.minimap.background_layer.activate();
+ this.minimap.topleft = paper.view.bounds.bottomRight.subtract(this.minimap.size);
+ this.minimap.rectangle = new paper.Path.Rectangle(this.minimap.topleft.subtract([2,2]), this.minimap.size.add([4,4]));
+ this.minimap.rectangle.fillColor = _renkan.options.minimap_background_color;
+ this.minimap.rectangle.strokeColor = _renkan.options.minimap_border_color;
+ this.minimap.rectangle.strokeWidth = 4;
+ this.minimap.offset = new paper.Point(this.minimap.size.divide(2));
+ this.minimap.scale = 0.1;
+
+ this.minimap.node_layer.activate();
+ this.minimap.cliprectangle = new paper.Path.Rectangle(this.minimap.topleft, this.minimap.size);
+ this.minimap.node_group.addChild(this.minimap.cliprectangle);
+ this.minimap.node_group.clipped = true;
+ this.minimap.miniframe = new paper.Path.Rectangle(this.minimap.topleft, this.minimap.size);
+ this.minimap.node_group.addChild(this.minimap.miniframe);
+ this.minimap.miniframe.fillColor = '#c0c0ff';
+ this.minimap.miniframe.opacity = 0.3;
+ this.minimap.miniframe.strokeColor = '#000080';
+ this.minimap.miniframe.strokeWidth = 3;
+ this.minimap.miniframe.__representation = new MiniFrame(this, null);
+ }
+
+ this.throttledPaperDraw = _(function() {
+ paper.view.draw();
+ }).throttle(100);
+
+ this.bundles = [];
+ this.click_mode = false;
+
+ var _this = this,
+ _allowScroll = true,
+ _originalScale = 1,
+ _zooming = false,
+ _lastTapX = 0,
+ _lastTapY = 0;
+
+ this.image_cache = {};
+ this.icon_cache = {};
+
+ ['edit', 'remove', 'link', 'enlarge', 'shrink', 'revert' ].forEach(function(imgname) {
+ var img = new Image();
+ img.src = _renkan.options.static_url + 'img/' + imgname + '.png';
+ _this.icon_cache[imgname] = img;
+ });
+
+ var throttledMouseMove = _.throttle(function(_event, _isTouch) {
+ _this.onMouseMove(_event, _isTouch);
+ }, Utils._MOUSEMOVE_RATE);
+
+ this.canvas_$.on({
+ mousedown: function(_event) {
+ _event.preventDefault();
+ _this.onMouseDown(_event, false);
+ },
+ mousemove: function(_event) {
+ _event.preventDefault();
+ throttledMouseMove(_event, false);
+ },
+ mouseup: function(_event) {
+ _event.preventDefault();
+ _this.onMouseUp(_event, false);
+ },
+ mousewheel: function(_event, _delta) {
+ if(_renkan.options.zoom_on_scroll) {
+ _event.preventDefault();
+ if (_allowScroll) {
+ _this.onScroll(_event, _delta);
+ }
+ }
+ },
+ touchstart: function(_event) {
+ _event.preventDefault();
+ var _touches = _event.originalEvent.touches[0];
+ if (
+ _renkan.options.allow_double_click &&
+ new Date() - _lastTap < Utils._DOUBLETAP_DELAY &&
+ ( Math.pow(_lastTapX - _touches.pageX, 2) + Math.pow(_lastTapY - _touches.pageY, 2) < Utils._DOUBLETAP_DISTANCE )
+ ) {
+ _lastTap = 0;
+ _this.onDoubleClick(_touches);
+ } else {
+ _lastTap = new Date();
+ _lastTapX = _touches.pageX;
+ _lastTapY = _touches.pageY;
+ _originalScale = _this.scale;
+ _zooming = false;
+ _this.onMouseDown(_touches, true);
+ }
+ },
+ touchmove: function(_event) {
+ _event.preventDefault();
+ _lastTap = 0;
+ if (_event.originalEvent.touches.length === 1) {
+ _this.onMouseMove(_event.originalEvent.touches[0], true);
+ } else {
+ if (!_zooming) {
+ _this.onMouseUp(_event.originalEvent.touches[0], true);
+ _this.click_target = null;
+ _this.is_dragging = false;
+ _zooming = true;
+ }
+ if (_event.originalEvent.scale === "undefined") {
+ return;
+ }
+ var _newScale = _event.originalEvent.scale * _originalScale,
+ _scaleRatio = _newScale / _this.scale,
+ _newOffset = new paper.Point([
+ _this.canvas_$.width(),
+ _this.canvas_$.height()
+ ]).multiply( 0.5 * ( 1 - _scaleRatio ) ).add(_this.offset.multiply( _scaleRatio ));
+ _this.setScale(_newScale, _newOffset);
+ }
+ },
+ touchend: function(_event) {
+ _event.preventDefault();
+ _this.onMouseUp(_event.originalEvent.changedTouches[0], true);
+ },
+ dblclick: function(_event) {
+ _event.preventDefault();
+ if (_renkan.options.allow_double_click) {
+ _this.onDoubleClick(_event);
+ }
+ },
+ mouseleave: function(_event) {
+ _event.preventDefault();
+ _this.onMouseUp(_event, false);
+ _this.click_target = null;
+ _this.is_dragging = false;
+ },
+ dragover: function(_event) {
+ _event.preventDefault();
+ },
+ dragenter: function(_event) {
+ _event.preventDefault();
+ _allowScroll = false;
+ },
+ dragleave: function(_event) {
+ _event.preventDefault();
+ _allowScroll = true;
+ },
+ drop: function(_event) {
+ _event.preventDefault();
+ _allowScroll = true;
+ var res = {};
+ _(_event.originalEvent.dataTransfer.types).each(function(t) {
+ try {
+ res[t] = _event.originalEvent.dataTransfer.getData(t);
+ } catch(e) {}
+ });
+ var text = _event.originalEvent.dataTransfer.getData("Text");
+ if (typeof text === "string") {
+ switch(text[0]) {
+ case "{":
+ case "[":
+ try {
+ var data = JSON.parse(text);
+ _(res).extend(data);
+ }
+ catch(e) {
+ if (!res["text/plain"]) {
+ res["text/plain"] = text;
+ }
+ }
+ break;
+ case "<":
+ if (!res["text/html"]) {
+ res["text/html"] = text;
+ }
+ break;
+ default:
+ if (!res["text/plain"]) {
+ res["text/plain"] = text;
+ }
+ }
+ }
+ var url = _event.originalEvent.dataTransfer.getData("URL");
+ if (url && !res["text/uri-list"]) {
+ res["text/uri-list"] = url;
+ }
+ _this.dropData(res, _event.originalEvent);
+ }
+ });
+
+ var bindClick = function(selector, fname) {
+ _this.$.find(selector).click(function(evt) {
+ _this[fname](evt);
+ return false;
+ });
+ };
+
+ bindClick(".Rk-ZoomOut", "zoomOut");
+ bindClick(".Rk-ZoomIn", "zoomIn");
+ bindClick(".Rk-ZoomFit", "autoScale");
+ this.$.find(".Rk-ZoomSave").click( function() {
+ // Save scale and offset point
+ _this.renkan.project.addView( { zoom_level:_this.scale, offset:_this.offset } );
+ });
+ this.$.find(".Rk-ZoomSetSaved").click( function() {
+ var view = _this.renkan.project.get("views").last();
+ if(view){
+ _this.setScale(view.get("zoom_level"), new paper.Point(view.get("offset")));
+ }
+ });
+ if(this.renkan.read_only && !isNaN(parseInt(this.renkan.options.default_view))){
+ this.$.find(".Rk-ZoomSetSaved").show();
+ }
+ this.$.find(".Rk-CurrentUser").mouseenter(
+ function() { _this.$.find(".Rk-UserList").slideDown(); }
+ );
+ this.$.find(".Rk-Users").mouseleave(
+ function() { _this.$.find(".Rk-UserList").slideUp(); }
+ );
+ bindClick(".Rk-FullScreen-Button", "fullScreen");
+ bindClick(".Rk-AddNode-Button", "addNodeBtn");
+ bindClick(".Rk-AddEdge-Button", "addEdgeBtn");
+ bindClick(".Rk-Save-Button", "save");
+ bindClick(".Rk-Open-Button", "open");
+ bindClick(".Rk-Export-Button", "exportProject");
+ this.$.find(".Rk-Bookmarklet-Button")
+ /*jshint scripturl:true */
+ .attr("href","javascript:" + Utils._BOOKMARKLET_CODE(_renkan))
+ .click(function(){
+ _this.notif_$
+ .text(_renkan.translate("Drag this button to your bookmark bar. When on a third-party website, click it to enable drag-and-drop from the website to Renkan."))
+ .fadeIn()
+ .delay(5000)
+ .fadeOut();
+ return false;
+ });
+ this.$.find(".Rk-TopBar-Button").mouseover(function() {
+ $(this).find(".Rk-TopBar-Tooltip").show();
+ }).mouseout(function() {
+ $(this).find(".Rk-TopBar-Tooltip").hide();
+ });
+ bindClick(".Rk-Fold-Bins", "foldBins");
+
+ paper.view.onResize = function(_event) {
+ // Because of paper bug which does not calculate the good height (and width a fortiori)
+ // We have to update manually the canvas's height
+ paper.view._viewSize.height = _event.size.height = _this.canvas_$.parent().height();
+
+ if (_this.minimap) {
+ _this.minimap.topleft = paper.view.bounds.bottomRight.subtract(_this.minimap.size);
+ _this.minimap.rectangle.fitBounds(_this.minimap.topleft.subtract([2,2]), _this.minimap.size.add([4,4]));
+ _this.minimap.cliprectangle.fitBounds(_this.minimap.topleft, _this.minimap.size);
+ }
+ _this.redraw();
+ };
+
+ var _thRedraw = _.throttle(function() {
+ _this.redraw();
+ },50);
+
+ this.addRepresentations("Node", this.renkan.project.get("nodes"));
+ this.addRepresentations("Edge", this.renkan.project.get("edges"));
+ this.renkan.project.on("change:title", function() {
+ _this.$.find(".Rk-PadTitle").val(_renkan.project.get("title"));
+ });
+
+ this.$.find(".Rk-PadTitle").on("keyup input paste", function() {
+ _renkan.project.set({"title": $(this).val()});
+ });
+
+ var _thRedrawUsers = _.throttle(function() {
+ _this.redrawUsers();
+ }, 100);
+
+ _thRedrawUsers();
+
+ // register model events
+ this.renkan.project.on("add:users remove:users", _thRedrawUsers);
+
+ this.renkan.project.on("add:views remove:views", function(_node) {
+ if(_this.renkan.project.get('views').length > 0) {
+ _this.$.find(".Rk-ZoomSetSaved").show();
+ }
+ else {
+ _this.$.find(".Rk-ZoomSetSaved").hide();
+ }
+ });
+
+ this.renkan.project.on("add:nodes", function(_node) {
+ _this.addRepresentation("Node", _node);
+ _thRedraw();
+ });
+ this.renkan.project.on("add:edges", function(_edge) {
+ _this.addRepresentation("Edge", _edge);
+ _thRedraw();
+ });
+ this.renkan.project.on("change:title", function(_model, _title) {
+ var el = _this.$.find(".Rk-PadTitle");
+ if (el.is("input")) {
+ if (el.val() !== _title) {
+ el.val(_title);
+ }
+ } else {
+ el.text(_title);
+ }
+ });
+
+ if (_renkan.options.size_bug_fix) {
+ var _delay = (
+ typeof _renkan.options.size_bug_fix === "number" ?
+ _renkan.options.size_bug_fix
+ : 500
+ );
+ window.setTimeout(
+ function() {
+ _this.fixSize(true);
+ },
+ _delay
+ );
+ }
+
+ if (_renkan.options.force_resize) {
+ $(window).resize(function() {
+ _this.fixSize(false);
+ });
+ }
+
+ if (_renkan.options.show_user_list && _renkan.options.user_color_editable) {
+ var $cpwrapper = this.$.find(".Rk-Users .Rk-Edit-ColorPicker-Wrapper"),
+ $cplist = this.$.find(".Rk-Users .Rk-Edit-ColorPicker");
+
+ $cpwrapper.hover(
+ function(_e) {
+ if (_this.isEditable()) {
+ _e.preventDefault();
+ $cplist.show();
+ }
+ },
+ function(_e) {
+ _e.preventDefault();
+ $cplist.hide();
+ }
+ );
+
+ $cplist.find("li").mouseenter(
+ function(_e) {
+ if (_this.isEditable()) {
+ _e.preventDefault();
+ _this.$.find(".Rk-CurrentUser-Color").css("background", $(this).attr("data-color"));
+ }
+ }
+ );
+ }
+
+ if (_renkan.options.show_search_field) {
+
+ var lastval = '';
+
+ this.$.find(".Rk-GraphSearch-Field").on("keyup change paste input", function() {
+ var $this = $(this),
+ val = $this.val();
+ if (val === lastval) {
+ return;
+ }
+ lastval = val;
+ if (val.length < 2) {
+ _renkan.project.get("nodes").each(function(n) {
+ _this.getRepresentationByModel(n).unhighlight();
+ });
+ } else {
+ var rxs = Utils.regexpFromTextOrArray(val);
+ _renkan.project.get("nodes").each(function(n) {
+ if (rxs.test(n.get("title")) || rxs.test(n.get("description"))) {
+ _this.getRepresentationByModel(n).highlight(rxs);
+ } else {
+ _this.getRepresentationByModel(n).unhighlight();
+ }
+ });
+ }
+ });
+ }
+
+ this.redraw();
+
+ window.setInterval(function() {
+ var _now = new Date().valueOf();
+ _this.delete_list.forEach(function(d) {
+ if (_now >= d.time) {
+ var el = _renkan.project.get("nodes").findWhere({"delete_scheduled":d.id});
+ if (el) {
+ project.removeNode(el);
+ }
+ el = _renkan.project.get("edges").findWhere({"delete_scheduled":d.id});
+ if (el) {
+ project.removeEdge(el);
+ }
+ }
+ });
+ _this.delete_list = _this.delete_list.filter(function(d) {
+ return _renkan.project.get("nodes").findWhere({"delete_scheduled":d.id}) || _renkan.project.get("edges").findWhere({"delete_scheduled":d.id});
+ });
+ }, 500);
+
+ if (this.minimap) {
+ window.setInterval(function() {
+ _this.rescaleMinimap();
+ }, 2000);
+ }
+
+ };
+
+ _(Scene.prototype).extend({
+ template: _.template(
+ '<% if (options.show_top_bar) { %><div class="Rk-TopBar"><% if (!options.editor_mode) { %><h2 class="Rk-PadTitle"><%- project.get("title") || translate("Untitled project")%></h2>' +
+ '<% } else { %><input type="text" class="Rk-PadTitle" value="<%- project.get("title") || "" %>" placeholder="<%-translate("Untitled project")%>" /><% } %>' +
+ '<% if (options.show_user_list) { %><div class="Rk-Users"><div class="Rk-CurrentUser"><div class="Rk-Edit-ColorPicker-Wrapper"><span class="Rk-CurrentUser-Color"><% if (options.user_color_editable) { %><span class="Rk-Edit-ColorTip"></span><% } %></span>' +
+ '<% if (options.user_color_editable) { print(colorPicker) } %></div><span class="Rk-CurrentUser-Name"><unknown user></span></div><ul class="Rk-UserList"></ul></div><% } %>' +
+ '<% if (options.home_button_url) {%><div class="Rk-TopBar-Separator"></div><a class="Rk-TopBar-Button Rk-Home-Button" href="<%- options.home_button_url %>"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents">' +
+ '<%- translate(options.home_button_title) %></div></div></a><% } %>' +
+ '<% if (options.show_fullscreen_button) { %><div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-FullScreen-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents"><%-translate("Full Screen")%></div></div></div><% } %>' +
+ '<% if (options.editor_mode) { %>' +
+ '<% if (options.show_addnode_button) { %><div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-AddNode-Button"><div class="Rk-TopBar-Tooltip">' +
+ '<div class="Rk-TopBar-Tooltip-Contents"><%-translate("Add Node")%></div></div></div><% } %>' +
+ '<% if (options.show_addedge_button) { %><div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-AddEdge-Button"><div class="Rk-TopBar-Tooltip">' +
+ '<div class="Rk-TopBar-Tooltip-Contents"><%-translate("Add Edge")%></div></div></div><% } %>' +
+ '<% if (options.show_export_button) { %><div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-Export-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents"><%-translate("Download Project")%></div></div></div><% } %>' +
+ '<% if (options.show_save_button) { %><div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-Save-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents"> </div></div></div><% } %>' +
+ '<% if (options.show_open_button) { %><div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-Open-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents"><%-translate("Open Project")%></div></div></div><% } %>' +
+ '<% if (options.show_bookmarklet) { %><div class="Rk-TopBar-Separator"></div><a class="Rk-TopBar-Button Rk-Bookmarklet-Button" href="#"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents">' +
+ '<%-translate("Renkan \'Drag-to-Add\' bookmarklet")%></div></div></a><% } %>' +
+ '<% } else { %>' +
+ '<% if (options.show_export_button) { %><div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-Export-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents"><%-translate("Download Project")%></div></div></div><div class="Rk-TopBar-Separator"></div><% } %>' +
+ '<% };' +
+ 'if (options.show_search_field) { %>' +
+ '<form action="#" class="Rk-GraphSearch-Form"><input type="search" class="Rk-GraphSearch-Field" placeholder="<%- translate("Search in graph") %>" /></form><div class="Rk-TopBar-Separator"></div><% } %></div><% } %>' +
+ '<div class="Rk-Editing-Space<% if (!options.show_top_bar) { %> Rk-Editing-Space-Full<% } %>">' +
+ '<div class="Rk-Labels"></div><canvas class="Rk-Canvas" resize></canvas><div class="Rk-Notifications"></div><div class="Rk-Editor">' +
+ '<% if (options.show_bins) { %><div class="Rk-Fold-Bins">«</div><% } %>' +
+ '<div class="Rk-ZoomButtons"><div class="Rk-ZoomIn" title="<%-translate("Zoom In")%>"></div><div class="Rk-ZoomFit" title="<%-translate("Zoom Fit")%>"></div><div class="Rk-ZoomOut" title="<%-translate("Zoom Out")%>"></div>' +
+ '<% if (options.editor_mode) { %><div class="Rk-ZoomSave" title="<%-translate("Zoom Save")%>"></div><% } %>' +
+ '<% if (options.editor_mode || !isNaN(parseInt(options.default_view))) { %><div class="Rk-ZoomSetSaved" title="<%-translate("View saved zoom")%>"></div><% } %></div>' +
+ '</div></div>'
+ ),
+ fixSize: function(_autoscale) {
+ var w = this.$.width(),
+ h = this.$.height();
+ if (this.renkan.options.show_top_bar) {
+ h -= this.$.find(".Rk-TopBar").height();
+ }
+ this.canvas_$.attr({
+ width: w,
+ height: h
+ });
+
+ paper.view.viewSize = new paper.Size([w, h]);
+
+ if (_autoscale) {
+ // If _autoscale, we get the initial view (zoom+offset) set in the project datas.
+ if(this.renkan.read_only && !isNaN(parseInt(this.renkan.options.default_view))){
+ this.autoScale(this.renkan.project.get("views")[parseInt(this.renkan.options.default_view)]);
+ }
+ else{
+ this.autoScale();
+ }
+ }
+ },
+ drawSector: function(_repr, _inR, _outR, _startAngle, _endAngle, _padding, _imgname, _caption) {
+ var _options = this.renkan.options,
+ _startRads = _startAngle * Math.PI / 180,
+ _endRads = _endAngle * Math.PI / 180,
+ _img = this.icon_cache[_imgname],
+ _startdx = - Math.sin(_startRads),
+ _startdy = Math.cos(_startRads),
+ _startXIn = Math.cos(_startRads) * _inR + _padding * _startdx,
+ _startYIn = Math.sin(_startRads) * _inR + _padding * _startdy,
+ _startXOut = Math.cos(_startRads) * _outR + _padding * _startdx,
+ _startYOut = Math.sin(_startRads) * _outR + _padding * _startdy,
+ _enddx = - Math.sin(_endRads),
+ _enddy = Math.cos(_endRads),
+ _endXIn = Math.cos(_endRads) * _inR - _padding * _enddx,
+ _endYIn = Math.sin(_endRads) * _inR - _padding * _enddy,
+ _endXOut = Math.cos(_endRads) * _outR - _padding * _enddx,
+ _endYOut = Math.sin(_endRads) * _outR - _padding * _enddy,
+ _centerR = (_inR + _outR) / 2,
+ _centerRads = (_startRads + _endRads) / 2,
+ _centerX = Math.cos(_centerRads) * _centerR,
+ _centerY = Math.sin(_centerRads) * _centerR,
+ _centerXIn = Math.cos(_centerRads) * _inR,
+ _centerXOut = Math.cos(_centerRads) * _outR,
+ _centerYIn = Math.sin(_centerRads) * _inR,
+ _centerYOut = Math.sin(_centerRads) * _outR,
+ _textX = Math.cos(_centerRads) * (_outR + 3),
+ _textY = Math.sin(_centerRads) * (_outR + _options.buttons_label_font_size) + _options.buttons_label_font_size / 2;
+ this.buttons_layer.activate();
+ var _path = new paper.Path();
+ _path.add([_startXIn, _startYIn]);
+ _path.arcTo([_centerXIn, _centerYIn], [_endXIn, _endYIn]);
+ _path.lineTo([_endXOut, _endYOut]);
+ _path.arcTo([_centerXOut, _centerYOut], [_startXOut, _startYOut]);
+ _path.fillColor = _options.buttons_background;
+ _path.opacity = 0.5;
+ _path.closed = true;
+ _path.__representation = _repr;
+ var _text = new paper.PointText(_textX,_textY);
+ _text.characterStyle = {
+ fontSize: _options.buttons_label_font_size,
+ fillColor: _options.buttons_label_color
+ };
+ if (_textX > 2) {
+ _text.paragraphStyle.justification = 'left';
+ } else if (_textX < -2) {
+ _text.paragraphStyle.justification = 'right';
+ } else {
+ _text.paragraphStyle.justification = 'center';
+ }
+ _text.visible = false;
+ var _visible = false,
+ _restPos = new paper.Point(-200, -200),
+ _grp = new paper.Group([_path, _text]),
+ _delta = _grp.position,
+ _imgdelta = new paper.Point([_centerX, _centerY]),
+ _currentPos = new paper.Point(0,0);
+ _text.content = _caption;
+ _grp.visible = false;
+ _grp.position = _restPos;
+ var _res = {
+ show: function() {
+ _visible = true;
+ _grp.position = _currentPos.add(_delta);
+ _grp.visible = true;
+ },
+ moveTo: function(_point) {
+ _currentPos = _point;
+ if (_visible) {
+ _grp.position = _point.add(_delta);
+ }
+ },
+ hide: function() {
+ _visible = false;
+ _grp.visible = false;
+ _grp.position = _restPos;
+ },
+ select: function() {
+ _path.opacity = 0.8;
+ _text.visible = true;
+ },
+ unselect: function() {
+ _path.opacity = 0.5;
+ _text.visible = false;
+ },
+ destroy: function() {
+ _grp.remove();
+ }
+ };
+ var showImage = function() {
+ var _raster = new paper.Raster(_img);
+ _raster.position = _imgdelta.add(_grp.position).subtract(_delta);
+ _raster.locked = true; // Disable mouse events on icon
+ _grp.addChild(_raster);
+ };
+ if (_img.width) {
+ showImage();
+ } else {
+ $(_img).on("load",showImage);
+ }
+
+ return _res;
+ },
+ addToBundles: function(_edgeRepr) {
+ var _bundle = _(this.bundles).find(function(_bundle) {
+ return (
+ ( _bundle.from === _edgeRepr.from_representation && _bundle.to === _edgeRepr.to_representation ) ||
+ ( _bundle.from === _edgeRepr.to_representation && _bundle.to === _edgeRepr.from_representation )
+ );
+ });
+ if (typeof _bundle !== "undefined") {
+ _bundle.edges.push(_edgeRepr);
+ } else {
+ _bundle = {
+ from: _edgeRepr.from_representation,
+ to: _edgeRepr.to_representation,
+ edges: [ _edgeRepr ],
+ getPosition: function(_er) {
+ var _dir = (_er.from_representation === this.from) ? 1 : -1;
+ return _dir * ( _(this.edges).indexOf(_er) - (this.edges.length - 1) / 2 );
+ }
+ };
+ this.bundles.push(_bundle);
+ }
+ return _bundle;
+ },
+ isEditable: function() {
+ return (this.renkan.options.editor_mode && !this.renkan.read_only);
+ },
+ onStatusChange: function() {
+ var savebtn = this.$.find(".Rk-Save-Button"),
+ tip = savebtn.find(".Rk-TopBar-Tooltip-Contents");
+ if (this.renkan.read_only) {
+ savebtn.removeClass("disabled Rk-Save-Online").addClass("Rk-Save-ReadOnly");
+ tip.text(this.renkan.translate("Connection lost"));
+ } else {
+ if (this.renkan.options.manual_save) {
+ savebtn.removeClass("Rk-Save-ReadOnly Rk-Save-Online");
+ tip.text(this.renkan.translate("Save Project"));
+ } else {
+ savebtn.removeClass("disabled Rk-Save-ReadOnly").addClass("Rk-Save-Online");
+ tip.text(this.renkan.translate("Auto-save enabled"));
+ }
+ }
+ this.redrawUsers();
+ },
+ setScale: function(_newScale, _offset) {
+ if ((_newScale/this.initialScale) > Utils._MIN_SCALE && (_newScale/this.initialScale) < Utils._MAX_SCALE) {
+ this.scale = _newScale;
+ if (_offset) {
+ this.offset = _offset;
+ }
+ this.redraw();
+ }
+ },
+ autoScale: function(force_view) {
+ var nodes = this.renkan.project.get("nodes");
+ if (nodes.length > 1) {
+ var _xx = nodes.map(function(_node) { return _node.get("position").x; }),
+ _yy = nodes.map(function(_node) { return _node.get("position").y; }),
+ _minx = Math.min.apply(Math, _xx),
+ _miny = Math.min.apply(Math, _yy),
+ _maxx = Math.max.apply(Math, _xx),
+ _maxy = Math.max.apply(Math, _yy);
+ var _scale = Math.min( (paper.view.size.width - 2 * this.renkan.options.autoscale_padding) / (_maxx - _minx), (paper.view.size.height - 2 * this.renkan.options.autoscale_padding) / (_maxy - _miny));
+ this.initialScale = _scale;
+ // Override calculated scale if asked
+ if((typeof force_view !== "undefined") && parseFloat(force_view.zoom_level)>0 && parseFloat(force_view.offset.x)>0 && parseFloat(force_view.offset.y)>0){
+ this.setScale(parseFloat(force_view.zoom_level), new paper.Point(parseFloat(force_view.offset.x), parseFloat(force_view.offset.y)));
+ }
+ else{
+ this.setScale(_scale, paper.view.center.subtract(new paper.Point([(_maxx + _minx) / 2, (_maxy + _miny) / 2]).multiply(_scale)));
+ }
+ }
+ if (nodes.length === 1) {
+ this.setScale(1, paper.view.center.subtract(new paper.Point([nodes.at(0).get("position").x, nodes.at(0).get("position").y])));
+ }
+ },
+ redrawMiniframe: function() {
+ var topleft = this.toMinimapCoords(this.toModelCoords(new paper.Point([0,0]))),
+ bottomright = this.toMinimapCoords(this.toModelCoords(paper.view.bounds.bottomRight));
+ this.minimap.miniframe.fitBounds(topleft, bottomright);
+ },
+ rescaleMinimap: function() {
+ var nodes = this.renkan.project.get("nodes");
+ if (nodes.length > 1) {
+ var _xx = nodes.map(function(_node) { return _node.get("position").x; }),
+ _yy = nodes.map(function(_node) { return _node.get("position").y; }),
+ _minx = Math.min.apply(Math, _xx),
+ _miny = Math.min.apply(Math, _yy),
+ _maxx = Math.max.apply(Math, _xx),
+ _maxy = Math.max.apply(Math, _yy);
+ var _scale = Math.min(
+ this.scale * 0.8 * this.renkan.options.minimap_width / paper.view.bounds.width,
+ this.scale * 0.8 * this.renkan.options.minimap_height / paper.view.bounds.height,
+ ( this.renkan.options.minimap_width - 2 * this.renkan.options.minimap_padding ) / (_maxx - _minx),
+ ( this.renkan.options.minimap_height - 2 * this.renkan.options.minimap_padding ) / (_maxy - _miny)
+ );
+ this.minimap.offset = this.minimap.size.divide(2).subtract(new paper.Point([(_maxx + _minx) / 2, (_maxy + _miny) / 2]).multiply(_scale));
+ this.minimap.scale = _scale;
+ }
+ if (nodes.length === 1) {
+ this.minimap.scale = 0.1;
+ this.minimap.offset = this.minimap.size.divide(2).subtract(new paper.Point([nodes.at(0).get("position").x, nodes.at(0).get("position").y]).multiply(this.minimap.scale));
+ }
+ this.redraw();
+ },
+ toPaperCoords: function(_point) {
+ return _point.multiply(this.scale).add(this.offset);
+ },
+ toMinimapCoords: function(_point) {
+ return _point.multiply(this.minimap.scale).add(this.minimap.offset).add(this.minimap.topleft);
+ },
+ toModelCoords: function(_point) {
+ return _point.subtract(this.offset).divide(this.scale);
+ },
+ addRepresentation: function(_type, _model) {
+ var RendererType = requtils.getRenderer()[_type];
+ var _repr = new RendererType(this, _model);
+ this.representations.push(_repr);
+ return _repr;
+ },
+ addRepresentations: function(_type, _collection) {
+ var _this = this;
+ _collection.forEach(function(_model) {
+ _this.addRepresentation(_type, _model);
+ });
+ },
+ userTemplate: _.template(
+ '<li class="Rk-User"><span class="Rk-UserColor" style="background:<%=background%>;"></span><%=name%></li>'
+ ),
+ redrawUsers: function() {
+ if (!this.renkan.options.show_user_list) {
+ return;
+ }
+ var allUsers = [].concat((this.renkan.project.current_user_list || {}).models || [], (this.renkan.project.get("users") || {}).models || []),
+ ulistHtml = '',
+ $userpanel = this.$.find(".Rk-Users"),
+ $name = $userpanel.find(".Rk-CurrentUser-Name"),
+ $cpitems = $userpanel.find(".Rk-Edit-ColorPicker li"),
+ $colorsquare = $userpanel.find(".Rk-CurrentUser-Color"),
+ _this = this;
+ $name.off("click").text(this.renkan.translate("<unknown user>"));
+ $cpitems.off("mouseleave click");
+ allUsers.forEach(function(_user) {
+ if (_user.get("_id") === _this.renkan.current_user) {
+ $name.text(_user.get("title"));
+ $colorsquare.css("background", _user.get("color"));
+ if (_this.isEditable()) {
+
+ if (_this.renkan.options.user_name_editable) {
+ $name.click(function() {
+ var $this = $(this),
+ $input = $('<input>').val(_user.get("title")).blur(function() {
+ _user.set("title", $(this).val());
+ _this.redrawUsers();
+ _this.redraw();
+ });
+ $this.empty().html($input);
+ $input.select();
+ });
+ }
+
+ if (_this.renkan.options.user_color_editable) {
+ $cpitems.click(
+ function(_e) {
+ _e.preventDefault();
+ if (_this.isEditable()) {
+ _user.set("color", $(this).attr("data-color"));
+ }
+ $(this).parent().hide();
+ }
+ ).mouseleave(function() {
+ $colorsquare.css("background", _user.get("color"));
+ });
+ }
+ }
+
+ } else {
+ ulistHtml += _this.userTemplate({
+ name: _user.get("title"),
+ background: _user.get("color")
+ });
+ }
+ });
+ $userpanel.find(".Rk-UserList").html(ulistHtml);
+ },
+ removeRepresentation: function(_representation) {
+ _representation.destroy();
+ this.representations = _(this.representations).reject(
+ function(_repr) {
+ return _repr === _representation;
+ }
+ );
+ },
+ getRepresentationByModel: function(_model) {
+ if (!_model) {
+ return undefined;
+ }
+ return _(this.representations).find(function(_repr) {
+ return _repr.model === _model;
+ });
+ },
+ removeRepresentationsOfType: function(_type) {
+ var _representations = _(this.representations).filter(function(_repr) {
+ return _repr.type === _type;
+ }),
+ _this = this;
+ _(_representations).each(function(_repr) {
+ _this.removeRepresentation(_repr);
+ });
+ },
+ highlightModel: function(_model) {
+ var _repr = this.getRepresentationByModel(_model);
+ if (_repr) {
+ _repr.highlight();
+ }
+ },
+ unhighlightAll: function(_model) {
+ _(this.representations).each(function(_repr) {
+ _repr.unhighlight();
+ });
+ },
+ unselectAll: function(_model) {
+ _(this.representations).each(function(_repr) {
+ _repr.unselect();
+ });
+ },
+ redraw: function() {
+ if(! this.redrawActive ) {
+ return;
+ }
+ _(this.representations).each(function(_representation) {
+ _representation.redraw(true);
+ });
+ if (this.minimap) {
+ this.redrawMiniframe();
+ }
+ paper.view.draw();
+ },
+ addTempEdge: function(_from, _point) {
+ var _tmpEdge = this.addRepresentation("TempEdge",null);
+ _tmpEdge.end_pos = _point;
+ _tmpEdge.from_representation = _from;
+ _tmpEdge.redraw();
+ this.click_target = _tmpEdge;
+ },
+ findTarget: function(_hitResult) {
+ if (_hitResult && typeof _hitResult.item.__representation !== "undefined") {
+ var _newTarget = _hitResult.item.__representation;
+ if (this.selected_target !== _hitResult.item.__representation) {
+ if (this.selected_target) {
+ this.selected_target.unselect(_newTarget);
+ }
+ _newTarget.select(this.selected_target);
+ this.selected_target = _newTarget;
+ }
+ } else {
+ if (this.selected_target) {
+ this.selected_target.unselect();
+ }
+ this.selected_target = null;
+ }
+ },
+ paperShift: function(_delta) {
+ this.offset = this.offset.add(_delta);
+ this.redraw();
+ },
+ onMouseMove: function(_event) {
+ var _off = this.canvas_$.offset(),
+ _point = new paper.Point([
+ _event.pageX - _off.left,
+ _event.pageY - _off.top
+ ]),
+ _delta = _point.subtract(this.last_point);
+ this.last_point = _point;
+ if (!this.is_dragging && this.mouse_down && _delta.length > Utils._MIN_DRAG_DISTANCE) {
+ this.is_dragging = true;
+ }
+ var _hitResult = paper.project.hitTest(_point);
+ if (this.is_dragging) {
+ if (this.click_target && typeof this.click_target.paperShift === "function") {
+ this.click_target.paperShift(_delta);
+ } else {
+ this.paperShift(_delta);
+ }
+ } else {
+ this.findTarget(_hitResult);
+ }
+ paper.view.draw();
+ },
+ onMouseDown: function(_event, _isTouch) {
+ var _off = this.canvas_$.offset(),
+ _point = new paper.Point([
+ _event.pageX - _off.left,
+ _event.pageY - _off.top
+ ]);
+ this.last_point = _point;
+ this.mouse_down = true;
+ if (!this.click_target || this.click_target.type !== "Temp-edge") {
+ this.removeRepresentationsOfType("editor");
+ this.is_dragging = false;
+ var _hitResult = paper.project.hitTest(_point);
+ if (_hitResult && typeof _hitResult.item.__representation !== "undefined") {
+ this.click_target = _hitResult.item.__representation;
+ this.click_target.mousedown(_event, _isTouch);
+ } else {
+ this.click_target = null;
+ if (this.isEditable() && this.click_mode === Utils._CLICKMODE_ADDNODE) {
+ var _coords = this.toModelCoords(_point),
+ _data = {
+ id: Utils.getUID('node'),
+ created_by: this.renkan.current_user,
+ position: {
+ x: _coords.x,
+ y: _coords.y
+ }
+ };
+ _node = this.renkan.project.addNode(_data);
+ this.getRepresentationByModel(_node).openEditor();
+ }
+ }
+ }
+ if (this.click_mode) {
+ if (this.isEditable() && this.click_mode === Utils._CLICKMODE_STARTEDGE && this.click_target && this.click_target.type === "Node") {
+ this.removeRepresentationsOfType("editor");
+ this.addTempEdge(this.click_target, _point);
+ this.click_mode = Utils._CLICKMODE_ENDEDGE;
+ this.notif_$.fadeOut(function() {
+ $(this).html(this.renkan.translate("Click on a second node to complete the edge")).fadeIn();
+ });
+ } else {
+ this.notif_$.hide();
+ this.click_mode = false;
+ }
+ }
+ paper.view.draw();
+ },
+ onMouseUp: function(_event, _isTouch) {
+ this.mouse_down = false;
+ if (this.click_target) {
+ var _off = this.canvas_$.offset();
+ this.click_target.mouseup(
+ {
+ point: new paper.Point([
+ _event.pageX - _off.left,
+ _event.pageY - _off.top
+ ])
+ },
+ _isTouch
+ );
+ } else {
+ this.click_target = null;
+ this.is_dragging = false;
+ if (_isTouch) {
+ this.unselectAll();
+ }
+ }
+ paper.view.draw();
+ },
+ onScroll: function(_event, _scrolldelta) {
+ this.totalScroll += _scrolldelta;
+ if (Math.abs(this.totalScroll) >= 1) {
+ var _off = this.canvas_$.offset(),
+ _delta = new paper.Point([
+ _event.pageX - _off.left,
+ _event.pageY - _off.top
+ ]).subtract(this.offset).multiply( Math.SQRT2 - 1 );
+ if (this.totalScroll > 0) {
+ this.setScale( this.scale * Math.SQRT2, this.offset.subtract(_delta) );
+ } else {
+ this.setScale( this.scale * Math.SQRT1_2, this.offset.add(_delta.divide(Math.SQRT2)));
+ }
+ this.totalScroll = 0;
+ }
+ },
+ onDoubleClick: function(_event) {
+ if (!this.isEditable()) {
+ return;
+ }
+ var _off = this.canvas_$.offset(),
+ _point = new paper.Point([
+ _event.pageX - _off.left,
+ _event.pageY - _off.top
+ ]);
+ var _hitResult = paper.project.hitTest(_point);
+ if (this.isEditable() && (!_hitResult || typeof _hitResult.item.__representation === "undefined")) {
+ var _coords = this.toModelCoords(_point),
+ _data = {
+ id: Utils.getUID('node'),
+ created_by: this.renkan.current_user,
+ position: {
+ x: _coords.x,
+ y: _coords.y
+ }
+ },
+ _node = this.renkan.project.addNode(_data);
+ this.getRepresentationByModel(_node).openEditor();
+ }
+ paper.view.draw();
+ },
+ defaultDropHandler: function(_data) {
+ var newNode = {};
+ var snippet = "";
+ switch(_data["text/x-iri-specific-site"]) {
+ case "twitter":
+ snippet = $('<div>').html(_data["text/x-iri-selected-html"]);
+ var tweetdiv = snippet.find(".tweet");
+ newNode.title = this.renkan.translate("Tweet by ") + tweetdiv.attr("data-name");
+ newNode.uri = "http://twitter.com/" + tweetdiv.attr("data-screen-name") + "/status/" + tweetdiv.attr("data-tweet-id");
+ newNode.image = tweetdiv.find(".avatar").attr("src");
+ newNode.description = tweetdiv.find(".js-tweet-text:first").text();
+ break;
+ case "google":
+ snippet = $('<div>').html(_data["text/x-iri-selected-html"]);
+ newNode.title = snippet.find("h3:first").text().trim();
+ newNode.uri = snippet.find("h3 a").attr("href");
+ newNode.description = snippet.find(".st:first").text().trim();
+ break;
+ default:
+ if (_data["text/x-iri-source-uri"]) {
+ newNode.uri = _data["text/x-iri-source-uri"];
+ }
+ }
+ if (_data["text/plain"] || _data["text/x-iri-selected-text"]) {
+ newNode.description = (_data["text/plain"] || _data["text/x-iri-selected-text"]).replace(/[\s\n]+/gm,' ').trim();
+ }
+ if (_data["text/html"] || _data["text/x-iri-selected-html"]) {
+ snippet = $('<div>').html(_data["text/html"] || _data["text/x-iri-selected-html"]);
+ var _svgimgs = snippet.find("image");
+ if (_svgimgs.length) {
+ newNode.image = _svgimgs.attr("xlink:href");
+ }
+ var _svgpaths = snippet.find("path");
+ if (_svgpaths.length) {
+ newNode.clipPath = _svgpaths.attr("d");
+ }
+ var _imgs = snippet.find("img");
+ if (_imgs.length) {
+ newNode.image = _imgs[0].src;
+ }
+ var _as = snippet.find("a");
+ if (_as.length) {
+ newNode.uri = _as[0].href;
+ }
+ newNode.title = snippet.find("[title]").attr("title") || newNode.title;
+ newNode.description = snippet.text().replace(/[\s\n]+/gm,' ').trim();
+ }
+ if (_data["text/uri-list"]) {
+ newNode.uri = _data["text/uri-list"];
+ }
+ if (_data["text/x-moz-url"] && !newNode.title) {
+ newNode.title = (_data["text/x-moz-url"].split("\n")[1] || "").trim();
+ if (newNode.title === newNode.uri) {
+ newNode.title = false;
+ }
+ }
+ if (_data["text/x-iri-source-title"] && !newNode.title) {
+ newNode.title = _data["text/x-iri-source-title"];
+ }
+ if (_data["text/html"] || _data["text/x-iri-selected-html"]) {
+ snippet = $('<div>').html(_data["text/html"] || _data["text/x-iri-selected-html"]);
+ newNode.image = snippet.find("[data-image]").attr("data-image") || newNode.image;
+ newNode.uri = snippet.find("[data-uri]").attr("data-uri") || newNode.uri;
+ newNode.title = snippet.find("[data-title]").attr("data-title") || newNode.title;
+ newNode.description = snippet.find("[data-description]").attr("data-description") || newNode.description;
+ newNode.clipPath = snippet.find("[data-clip-path]").attr("data-clip-path") || newNode.clipPath;
+ }
+
+ if (!newNode.title) {
+ newNode.title = this.renkan.translate("Dragged resource");
+ }
+ var fields = ["title", "description", "uri", "image"];
+ for (var i = 0; i < fields.length; i++) {
+ var f = fields[i];
+ if (_data["text/x-iri-" + f] || _data[f]) {
+ newNode[f] = _data["text/x-iri-" + f] || _data[f];
+ }
+ if (newNode[f] === "none" || newNode[f] === "null") {
+ newNode[f] = undefined;
+ }
+ }
+
+ if(typeof this.renkan.options.drop_enhancer === "function"){
+ newNode = this.renkan.options.drop_enhancer(newNode, _data);
+ }
+
+ return newNode;
+
+ },
+ dropData: function(_data, _event) {
+ if (!this.isEditable()) {
+ return;
+ }
+ if (_data["text/json"] || _data["application/json"]) {
+ try {
+ var jsondata = JSON.parse(_data["text/json"] || _data["application/json"]);
+ _(_data).extend(jsondata);
+ }
+ catch(e) {}
+ }
+
+ var newNode = (typeof this.renkan.options.drop_handler === "undefined")?this.defaultDropHandler(_data):this.renkan.options.drop_handler(_data);
+
+ var _off = this.canvas_$.offset(),
+ _point = new paper.Point([
+ _event.pageX - _off.left,
+ _event.pageY - _off.top
+ ]),
+ _coords = this.toModelCoords(_point),
+ _nodedata = {
+ id: Utils.getUID('node'),
+ created_by: this.renkan.current_user,
+ uri: newNode.uri || "",
+ title: newNode.title || "",
+ description: newNode.description || "",
+ image: newNode.image || "",
+ color: newNode.color || undefined,
+ clip_path: newNode.clipPath || undefined,
+ position: {
+ x: _coords.x,
+ y: _coords.y
+ }
+ };
+ var _node = this.renkan.project.addNode(_nodedata),
+ _repr = this.getRepresentationByModel(_node);
+ if (_event.type === "drop") {
+ _repr.openEditor();
+ }
+ },
+ fullScreen: function() {
+ var _isFull = document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen,
+ _el = this.renkan.$[0],
+ _requestMethods = ["requestFullScreen","mozRequestFullScreen","webkitRequestFullScreen"],
+ _cancelMethods = ["cancelFullScreen","mozCancelFullScreen","webkitCancelFullScreen"],
+ i;
+ if (_isFull) {
+ for (i = 0; i < _cancelMethods.length; i++) {
+ if (typeof document[_cancelMethods[i]] === "function") {
+ document[_cancelMethods[i]]();
+ break;
+ }
+ }
+ } else {
+ for (i = 0; i < _requestMethods.length; i++) {
+ if (typeof _el[_requestMethods[i]] === "function") {
+ _el[_requestMethods[i]]();
+ break;
+ }
+ }
+ }
+ },
+ zoomOut: function() {
+ var _newScale = this.scale * Math.SQRT1_2,
+ _offset = new paper.Point([
+ this.canvas_$.width(),
+ this.canvas_$.height()
+ ]).multiply( 0.5 * ( 1 - Math.SQRT1_2 ) ).add(this.offset.multiply( Math.SQRT1_2 ));
+ this.setScale( _newScale, _offset );
+ },
+ zoomIn: function() {
+ var _newScale = this.scale * Math.SQRT2,
+ _offset = new paper.Point([
+ this.canvas_$.width(),
+ this.canvas_$.height()
+ ]).multiply( 0.5 * ( 1 - Math.SQRT2 ) ).add(this.offset.multiply( Math.SQRT2 ));
+ this.setScale( _newScale, _offset );
+ },
+ addNodeBtn: function() {
+ if (this.click_mode === Utils._CLICKMODE_ADDNODE) {
+ this.click_mode = false;
+ this.notif_$.hide();
+ } else {
+ this.click_mode = Utils._CLICKMODE_ADDNODE;
+ this.notif_$.text(this.renkan.translate("Click on the background canvas to add a node")).fadeIn();
+ }
+ return false;
+ },
+ addEdgeBtn: function() {
+ if (this.click_mode === Utils._CLICKMODE_STARTEDGE || this.click_mode === Utils._CLICKMODE_ENDEDGE) {
+ this.click_mode = false;
+ this.notif_$.hide();
+ } else {
+ this.click_mode = Utils._CLICKMODE_STARTEDGE;
+ this.notif_$.text(this.renkan.translate("Click on a first node to start the edge")).fadeIn();
+ }
+ return false;
+ },
+ exportProject: function() {
+ var projectJSON = this.renkan.project.toJSON(),
+ downloadLink = document.createElement("a"),
+ projectId = projectJSON.id,
+ fileNameToSaveAs = projectId + ".json";
+
+ // clean ids
+ delete projectJSON.id;
+ delete projectJSON._id;
+ delete projectJSON.space_id;
+
+ var objId;
+ var idsMap = {};
+
+ _.each(projectJSON.nodes, function(e,i,l) {
+ objId = e.id || e._id;
+ delete e._id;
+ delete e.id;
+ idsMap[objId] = e['@id'] = Utils.getUUID4();
+ });
+ _.each(projectJSON.edges, function(e,i,l) {
+ delete e._id;
+ delete e.id;
+ e.to = idsMap[e.to];
+ e.from = idsMap[e.from];
+ });
+ _.each(projectJSON.views, function(e,i,l) {
+ objId = e.id || e._id;
+ delete e._id;
+ delete e.id;
+ });
+ projectJSON.users = [];
+
+ var projectJSONStr = JSON.stringify(projectJSON, null, 2);
+ var blob = new Blob([projectJSONStr], {type: "application/json;charset=utf-8"});
+ filesaver(blob,fileNameToSaveAs);
+
+ },
+ foldBins: function() {
+ var foldBinsButton = this.$.find(".Rk-Fold-Bins"),
+ bins = this.renkan.$.find(".Rk-Bins");
+ var _this = this;
+ if (bins.offset().left < 0) {
+ bins.animate({left: 0},250);
+ this.$.animate({left: 300},250,function() {
+ var w = _this.$.width();
+ paper.view.viewSize = new paper.Size([w, _this.canvas_$.height()]);
+ });
+ foldBinsButton.html("«");
+ } else {
+ bins.animate({left: -300},250);
+ this.$.animate({left: 0},250,function() {
+ var w = _this.$.width();
+ paper.view.viewSize = new paper.Size([w, _this.canvas_$.height()]);
+ });
+ foldBinsButton.html("»");
+ }
+ },
+ save: function() { },
+ open: function() { }
+ });
+
+ /* Scene End */
+
+ return Scene;
+
+});
+
+
+//Load modules and use them
+if( typeof require.config === "function" ) {
+ require.config({
+ paths: {
+ 'jquery':'../lib/jquery.min',
+ 'underscore':'../lib/underscore-min',
+ 'filesaver' :'../lib/FileSaver',
+ 'requtils':'require-utils'
+ }
+ });
+}
+
+require(['renderer/baserepresentation',
+ 'renderer/basebutton',
+ 'renderer/noderepr',
+ 'renderer/edge',
+ 'renderer/tempedge',
+ 'renderer/baseeditor',
+ 'renderer/nodeeditor',
+ 'renderer/edgeeditor',
+ 'renderer/nodebutton',
+ 'renderer/nodeeditbutton',
+ 'renderer/noderemovebutton',
+ 'renderer/noderevertbutton',
+ 'renderer/nodelinkbutton',
+ 'renderer/nodeenlargebutton',
+ 'renderer/nodeshrinkbutton',
+ 'renderer/edgeeditbutton',
+ 'renderer/edgeremovebutton',
+ 'renderer/edgerevertbutton',
+ 'renderer/miniframe',
+ 'renderer/scene'
+ ], function(BaseRepresentation, BaseButton, NodeRepr, Edge, TempEdge, BaseEditor, NodeEditor, EdgeEditor, NodeButton, NodeEditButton, NodeRemoveButton, NodeRevertButton, NodeLinkButton, NodeEnlargeButton, NodeShrinkButton, EdgeEditButton, EdgeRemoveButton, EdgeRevertButton, MiniFrame, Scene){
+
+
+
+ var Rkns = window.Rkns;
+
+ if(typeof Rkns.Renderer === "undefined"){
+ Rkns.Renderer = {};
+ }
+ var Renderer = Rkns.Renderer;
+
+ Renderer._BaseRepresentation = BaseRepresentation;
+ Renderer._BaseButton = BaseButton;
+ Renderer.Node = NodeRepr;
+ Renderer.Edge = Edge;
+ Renderer.TempEdge = TempEdge;
+ Renderer._BaseEditor = BaseEditor;
+ Renderer.NodeEditor = NodeEditor;
+ Renderer.EdgeEditor = EdgeEditor;
+ Renderer._NodeButton = NodeButton;
+ Renderer.NodeEditButton = NodeEditButton;
+ Renderer.NodeRemoveButton = NodeRemoveButton;
+ Renderer.NodeRevertButton = NodeRevertButton;
+ Renderer.NodeLinkButton = NodeLinkButton;
+ Renderer.NodeEnlargeButton = NodeEnlargeButton;
+ Renderer.NodeShrinkButton = NodeShrinkButton;
+ Renderer.EdgeEditButton = EdgeEditButton;
+ Renderer.EdgeRemoveButton = EdgeRemoveButton;
+ Renderer.EdgeRevertButton = EdgeRevertButton;
+ Renderer.MiniFrame = MiniFrame;
+ Renderer.Scene = Scene;
+
+ startRenkan();
+});
+
+define("main-renderer", function(){});
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/server/python/django/renkanmanager/static/renkanmanager/lib/renkan/js/renkan.min.js Wed Dec 17 16:32:46 2014 +0100
@@ -0,0 +1,32 @@
+/*!
+ * _____ _
+ * | __ \ | |
+ * | |__) |___ _ __ | | ____ _ _ __
+ * | _ // _ \ '_ \| |/ / _` | '_ \
+ * | | \ \ __/ | | | < (_| | | | |
+ * |_| \_\___|_| |_|_|\_\__,_|_| |_|
+ *
+ * Copyright 2012-2013 Institut de recherche et d'innovation
+ * contributor(s) : Yves-Marie Haussonne, Raphael Velt, Samuel Huron
+ *
+ * contact@iri.centrepompidou.fr
+ * http://www.iri.centrepompidou.fr
+ *
+ * This software is a computer program whose purpose is to show and add annotations on a video .
+ * This software is governed by the CeCILL-C license under French law and
+ * abiding by the rules of distribution of free software. You can use,
+ * modify and/ or redistribute the software under the terms of the CeCILL-C
+ * license as circulated by CEA, CNRS and INRIA at the following URL
+ * "http://www.cecill.info".
+ *
+ * The fact that you are presently reading this means that you have had
+ * knowledge of the CeCILL-C license and that you accept its terms.
+ */
+/*! renkan - v0.7.11 - Copyright © IRI 2014 */
+
+
+!function(a){"use strict";"object"!=typeof a.Rkns&&(a.Rkns={});var b=a.Rkns,c=b.$=a.jQuery,d=b._=a._;b.pickerColors=["#8f1919","#a80000","#d82626","#ff0000","#e87c7c","#ff6565","#f7d3d3","#fecccc","#8f5419","#a85400","#d87f26","#ff7f00","#e8b27c","#ffb265","#f7e5d3","#fee5cc","#8f8f19","#a8a800","#d8d826","#feff00","#e8e87c","#feff65","#f7f7d3","#fefecc","#198f19","#00a800","#26d826","#00ff00","#7ce87c","#65ff65","#d3f7d3","#ccfecc","#198f8f","#00a8a8","#26d8d8","#00feff","#7ce8e8","#65feff","#d3f7f7","#ccfefe","#19198f","#0000a8","#2626d8","#0000ff","#7c7ce8","#6565ff","#d3d3f7","#ccccfe","#8f198f","#a800a8","#d826d8","#ff00fe","#e87ce8","#ff65fe","#f7d3f7","#feccfe","#000000","#242424","#484848","#6d6d6d","#919191","#b6b6b6","#dadada","#ffffff"],b.__renkans=[];var e=b._BaseBin=function(a,c){if("undefined"!=typeof a){this.renkan=a,this.renkan.$.find(".Rk-Bin-Main").hide(),this.$=b.$("<li>").addClass("Rk-Bin").appendTo(a.$.find(".Rk-Bin-List")),this.title_icon_$=b.$("<span>").addClass("Rk-Bin-Title-Icon").appendTo(this.$);var d=this;b.$("<a>").attr({href:"#",title:a.translate("Close bin")}).addClass("Rk-Bin-Close").html("×").appendTo(this.$).click(function(){return d.destroy(),a.$.find(".Rk-Bin-Main:visible").length||a.$.find(".Rk-Bin-Main:last").slideDown(),a.resizeBins(),!1}),b.$("<a>").attr({href:"#",title:a.translate("Refresh bin")}).addClass("Rk-Bin-Refresh").appendTo(this.$).click(function(){return d.refresh(),!1}),this.count_$=b.$("<div>").addClass("Rk-Bin-Count").appendTo(this.$),this.title_$=b.$("<h2>").addClass("Rk-Bin-Title").appendTo(this.$),this.main_$=b.$("<div>").addClass("Rk-Bin-Main").appendTo(this.$).html('<h4 class="Rk-Bin-Loading">'+a.translate("Loading, please wait")+"</h4>"),this.title_$.html(c.title||"(new bin)"),this.renkan.resizeBins(),c.auto_refresh&&window.setInterval(function(){d.refresh()},c.auto_refresh)}};e.prototype.destroy=function(){this.$.detach(),this.renkan.resizeBins()};var f=b.Renkan=function(a){var e=this;if(b.__renkans.push(this),this.options=d.defaults(a,b.defaults),d(this.options.property_files).each(function(a){b.$.getJSON(a,function(a){e.options.properties=e.options.properties.concat(a)})}),this.read_only=this.options.read_only||!this.options.editor_mode,this.project=new b.Models.Project,"undefined"!=typeof this.options.user_id&&(this.current_user=this.options.user_id),this.$=b.$("#"+this.options.container),this.$.addClass("Rk-Main").html(this.template(this)),this.tabs=[],this.search_engines=[],this.current_user_list=new b.Models.UsersList,this.current_user_list.on("add remove",function(){this.renderer&&this.renderer.redrawUsers()}),this.colorPicker=function(){var a=d.template('<li data-color="<%=c%>" style="background: <%=c%>"></li>');return'<ul class="Rk-Edit-ColorPicker">'+b.pickerColors.map(function(b){return a({c:b})}).join("")+"</ul>"}(),this.options.show_editor&&(this.renderer=new b.Renderer.Scene(this)),this.options.search.length){var f=d.template('<li class="<%= className %>" data-key="<%= key %>"><%= title %></li>'),g=this.$.find(".Rk-Search-List"),h=this.$.find(".Rk-Web-Search-Input"),i=this.$.find(".Rk-Web-Search-Form");d(this.options.search).each(function(a){b[a.type]&&b[a.type].Search&&e.search_engines.push(new b[a.type].Search(e,a))}),g.html(d(this.search_engines).map(function(a,b){return f({key:b,title:a.getSearchTitle(),className:a.getBgClass()})}).join("")),g.find("li").click(function(){var a=b.$(this);e.setSearchEngine(a.attr("data-key")),i.submit()}),i.submit(function(){if(h.val()){var a=e.search_engine;a.search(h.val())}return!1}),this.$.find(".Rk-Search-Current").mouseenter(function(){g.slideDown()}),this.$.find(".Rk-Search-Select").mouseleave(function(){g.hide()}),this.setSearchEngine(0)}else this.$.find(".Rk-Web-Search-Form").detach();d(this.options.bins).each(function(a){b[a.type]&&b[a.type].Bin&&e.tabs.push(new b[a.type].Bin(e,a))});var j=!1;this.$.find(".Rk-Bins").on("click",".Rk-Bin-Title,.Rk-Bin-Title-Icon",function(){var a=b.$(this).siblings(".Rk-Bin-Main");a.is(":hidden")&&(e.$.find(".Rk-Bin-Main").slideUp(),a.slideDown())}),this.options.show_editor&&this.$.find(".Rk-Bins").on("mouseover",".Rk-Bin-Item",function(){var a=b.$(this);if(a&&c(a).attr("data-uri")){var f=e.project.get("nodes").where({uri:c(a).attr("data-uri")});d(f).each(function(a){e.renderer.highlightModel(a)})}}).mouseout(function(){e.renderer.unhighlightAll()}).on("mousemove",".Rk-Bin-Item",function(){try{this.dragDrop()}catch(a){}}).on("touchstart",".Rk-Bin-Item",function(){j=!1}).on("touchmove",".Rk-Bin-Item",function(a){a.preventDefault();var b=a.originalEvent.changedTouches[0],c=e.renderer.canvas_$.offset(),d=e.renderer.canvas_$.width(),f=e.renderer.canvas_$.height();if(b.pageX>=c.left&&b.pageX<c.left+d&&b.pageY>=c.top&&b.pageY<c.top+f)if(j)e.renderer.onMouseMove(b,!0);else{j=!0;var g=document.createElement("div");g.appendChild(this.cloneNode(!0)),e.renderer.dropData({"text/html":g.innerHTML},b),e.renderer.onMouseDown(b,!0)}}).on("touchend",".Rk-Bin-Item",function(a){j&&e.renderer.onMouseUp(a.originalEvent.changedTouches[0],!0),j=!1}).on("dragstart",".Rk-Bin-Item",function(a){var b=document.createElement("div");b.appendChild(this.cloneNode(!0));try{a.originalEvent.dataTransfer.setData("text/html",b.innerHTML)}catch(c){a.originalEvent.dataTransfer.setData("text",b.innerHTML)}}),b.$(window).resize(function(){e.resizeBins()});var k=!1,l="";this.$.find(".Rk-Bins-Search-Input").on("change keyup paste input",function(){var a=b.$(this).val();if(a!==l){var c=b.Utils.regexpFromTextOrArray(a.length>1?a:null);c.source!==k&&(k=c.source,d(e.tabs).each(function(a){a.render(c)}))}}),this.$.find(".Rk-Bins-Search-Form").submit(function(){return!1})};f.prototype.template=d.template('<% if (options.show_bins) { %><div class="Rk-Bins"><div class="Rk-Bins-Head"><h2 class="Rk-Bins-Title"><%- translate("Select contents:")%></h2><form class="Rk-Web-Search-Form Rk-Search-Form"><input class="Rk-Web-Search-Input Rk-Search-Input" type="search" placeholder="<%- translate("Search the Web") %>" /><div class="Rk-Search-Select"><div class="Rk-Search-Current"></div><ul class="Rk-Search-List"></ul></div><input type="submit" value="" class="Rk-Web-Search-Submit Rk-Search-Submit" title="<%- translate("Search the Web") %>" /></form><form class="Rk-Bins-Search-Form Rk-Search-Form"><input class="Rk-Bins-Search-Input Rk-Search-Input" type="search" placeholder="<%- translate("Search in Bins") %>" /><input type="submit" value="" class="Rk-Bins-Search-Submit Rk-Search-Submit" title="<%- translate("Search in Bins") %>" /></form></div><ul class="Rk-Bin-List"></ul></div><% } %><% if (options.show_editor) { %><div class="Rk-Render Rk-Render-<% if (options.show_bins) { %>Panel<% } else { %>Full<% } %>"></div><% } %>'),f.prototype.translate=function(a){return b.i18n[this.options.language]&&b.i18n[this.options.language][a]?b.i18n[this.options.language][a]:this.options.language.length>2&&b.i18n[this.options.language.substr(0,2)]&&b.i18n[this.options.language.substr(0,2)][a]?b.i18n[this.options.language.substr(0,2)][a]:a},f.prototype.onStatusChange=function(){this.renderer.onStatusChange()},f.prototype.setSearchEngine=function(a){this.search_engine=this.search_engines[a],this.$.find(".Rk-Search-Current").attr("class","Rk-Search-Current "+this.search_engine.getBgClass())},f.prototype.resizeBins=function(){var a=+this.$.find(".Rk-Bins-Head").outerHeight();this.$.find(".Rk-Bin-Title:visible").each(function(){a+=b.$(this).outerHeight()}),this.$.find(".Rk-Bin-Main").css({height:this.$.find(".Rk-Bins").height()-a})};var g=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var b=16*Math.random()|0,c="x"===a?b:3&b|8;return c.toString(16)})};b.Utils={getUUID4:g,getUID:function(){function a(a){return 10>a?"0"+a:a}var b=new Date,c=0,d=b.getUTCFullYear()+"-"+a(b.getUTCMonth()+1)+"-"+a(b.getUTCDate())+"-"+g();return function(a){for(var b=(++c).toString(16),e="undefined"==typeof a?"":a+"-";b.length<4;)b="0"+b;return e+d+"-"+b}}(),getFullURL:function(a){if("undefined"==typeof a||null==a)return"";if(/https?:\/\//.test(a))return a;var b=new Image;b.src=a;var c=b.src;return b.src=null,c},inherit:function(a,b){var c=function(){"function"==typeof b&&b.apply(this,Array.prototype.slice.call(arguments,0)),a.apply(this,Array.prototype.slice.call(arguments,0)),"function"!=typeof this._init||this._initialized||(this._init.apply(this,Array.prototype.slice.call(arguments,0)),this._initialized=!0)};return d(c.prototype).extend(a.prototype),c},regexpFromTextOrArray:function(){function a(a){function b(a){return function(b,c){a=a.replace(h[b],c)}}for(var e=a.toLowerCase().replace(g,""),i="",j=0;j<e.length;j++){j&&(i+=f+"*");var k=e[j];d(c).each(b(k)),i+=k}return i}function b(c){switch(typeof c){case"string":return a(c);case"object":var e="";return d(c).each(function(a){var c=b(a);c&&(e&&(e+="|"),e+=c)}),e}return""}var c=["[aáàâä]","[cç]","[eéèêë]","[iíìîï]","[oóòôö]","[uùûü]"],e=[String.fromCharCode(768),String.fromCharCode(769),String.fromCharCode(770),String.fromCharCode(771),String.fromCharCode(807),"{","}","(",")","[","]","【","】","、","・","‥","。","「","」","『","』","〜",":","!","?"," ",","," ",";","(",")",".","*","+","\\","?","|","{","}","[","]","^","#","/"],f="[\\"+e.join("\\")+"]",g=new RegExp(f,"gm"),h=d(c).map(function(a){return new RegExp(a)});return function(a){var c=b(a);if(c){var d=new RegExp(c,"im"),e=new RegExp("("+c+")","igm");return{isempty:!1,source:c,test:function(a){return d.test(a)},replace:function(a,b){return a.replace(e,b)}}}return{isempty:!0,source:"",test:function(){return!0},replace:function(){return text}}}}(),_MIN_DRAG_DISTANCE:2,_NODE_BUTTON_WIDTH:40,_EDGE_BUTTON_INNER:2,_EDGE_BUTTON_OUTER:40,_CLICKMODE_ADDNODE:1,_CLICKMODE_STARTEDGE:2,_CLICKMODE_ENDEDGE:3,_NODE_SIZE_STEP:Math.LN2/4,_MIN_SCALE:.05,_MAX_SCALE:20,_MOUSEMOVE_RATE:80,_DOUBLETAP_DELAY:800,_DOUBLETAP_DISTANCE:400,_USER_PLACEHOLDER:function(a){return{color:a.options.default_user_color,title:a.translate("(unknown user)"),get:function(a){return this[a]||!1}}},_BOOKMARKLET_CODE:function(a){return"(function(a,b,c,d,e,f,h,i,j,k,l,m,n,o,p,q,r){a=document;b=a.body;c=a.location.href;j='draggable';m='text/x-iri-';d=a.createElement('div');d.innerHTML='<p_style=\"position:fixed;top:0;right:0;font:bold_18px_sans-serif;color:#fff;background:#909;padding:10px;z-index:100000;\">"+a.translate("Drag items from this website, drop them in Renkan").replace(/ /g,"_")+"</p>'.replace(/_/g,String.fromCharCode(32));b.appendChild(d);e=[{r:/https?:\\/\\/[^\\/]*twitter\\.com\\//,s:'.tweet',n:'twitter'},{r:/https?:\\/\\/[^\\/]*google\\.[^\\/]+\\//,s:'.g',n:'google'},{r:/https?:\\/\\/[^\\/]*lemonde\\.fr\\//,s:'[data-vr-contentbox]',n:'lemonde'}];f=false;e.forEach(function(g){if(g.r.test(c)){f=g;}});if(f){h=function(){Array.prototype.forEach.call(a.querySelectorAll(f.s),function(i){i[j]=true;k=i.style;k.borderWidth='2px';k.borderColor='#909';k.borderStyle='solid';k.backgroundColor='rgba(200,0,180,.1)';})};window.setInterval(h,500);h();};a.addEventListener('dragstart',function(k){l=k.dataTransfer;l.setData(m+'source-uri',c);l.setData(m+'source-title',a.title);n=k.target;if(f){o=n;while(!o.attributes[j]){o=o.parentNode;if(o==b){break;}}}if(f&&o.attributes[j]){p=o.cloneNode(true);l.setData(m+'specific-site',f.n)}else{q=a.getSelection();if(q.type==='Range'||!q.type){p=q.getRangeAt(0).cloneContents();}else{p=n.cloneNode();}}r=a.createElement('div');r.appendChild(p);l.setData('text/x-iri-selected-text',r.textContent.trim());l.setData('text/x-iri-selected-html',r.innerHTML);},false);})();"},shortenText:function(a,b){return a.length>b?a.substr(0,b)+"…":a},drawEditBox:function(a,b,c,d,e){e.css({width:a.tooltip_width-2*a.tooltip_padding});var f=e.outerHeight()+2*a.tooltip_padding,g=b.x<paper.view.center.x?1:-1,h=b.x+g*(d+a.tooltip_arrow_length),i=b.x+g*(d+a.tooltip_arrow_length+a.tooltip_width),j=b.y-f/2;j+f>paper.view.size.height-a.tooltip_margin&&(j=Math.max(paper.view.size.height-a.tooltip_margin,b.y+a.tooltip_arrow_width/2)-f),j<a.tooltip_margin&&(j=Math.min(a.tooltip_margin,b.y-a.tooltip_arrow_width/2));var k=j+f;return c.segments[0].point=c.segments[7].point=b.add([g*d,0]),c.segments[1].point.x=c.segments[2].point.x=c.segments[5].point.x=c.segments[6].point.x=h,c.segments[3].point.x=c.segments[4].point.x=i,c.segments[2].point.y=c.segments[3].point.y=j,c.segments[4].point.y=c.segments[5].point.y=k,c.segments[1].point.y=b.y-a.tooltip_arrow_width/2,c.segments[6].point.y=b.y+a.tooltip_arrow_width/2,c.closed=!0,c.fillColor=new paper.GradientColor(new paper.Gradient([a.tooltip_top_color,a.tooltip_bottom_color]),[0,j],[0,k]),e.css({left:a.tooltip_padding+Math.min(h,i),top:a.tooltip_padding+j}),c}}}(window),function(){"use strict";var a=this,b=a.Backbone,c=a.Rkns.Models={};c.getUID=function(a){var b="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var b=16*Math.random()|0,c="x"===a?b:3&b|8;return c.toString(16)});return"undefined"!=typeof a?a.type+"-"+b:b};{var d=b.RelationalModel.extend({idAttribute:"_id",constructor:function(a){"undefined"!=typeof a&&(a._id=a._id||a.id||c.getUID(this),a.title=a.title||"",a.description=a.description||"",a.uri=a.uri||"","function"==typeof this.prepare&&(a=this.prepare(a))),b.RelationalModel.prototype.constructor.call(this,a)},validate:function(){return this.type?void 0:"object has no type"},addReference:function(a,b,c,d,e){var f=c.get(d);a[b]="undefined"==typeof f&&"undefined"!=typeof e?e:f}}),e=c.User=d.extend({type:"user",prepare:function(a){return a.color=a.color||"#666666",a},toJSON:function(){return{_id:this.get("_id"),title:this.get("title"),uri:this.get("uri"),description:this.get("description"),color:this.get("color")}}}),f=c.Node=d.extend({type:"node",relations:[{type:b.HasOne,key:"created_by",relatedModel:e}],prepare:function(a){var b=a.project;return this.addReference(a,"created_by",b.get("users"),a.created_by,b.current_user),a.description=a.description||"",a},toJSON:function(){return{_id:this.get("_id"),title:this.get("title"),uri:this.get("uri"),description:this.get("description"),position:this.get("position"),image:this.get("image"),color:this.get("color"),created_by:this.get("created_by")?this.get("created_by").get("_id"):null,size:this.get("size"),clip_path:this.get("clip_path"),shape:this.get("shape")}}}),g=c.Edge=d.extend({type:"edge",relations:[{type:b.HasOne,key:"created_by",relatedModel:e},{type:b.HasOne,key:"from",relatedModel:f},{type:b.HasOne,key:"to",relatedModel:f}],prepare:function(a){var b=a.project;return this.addReference(a,"created_by",b.get("users"),a.created_by,b.current_user),this.addReference(a,"from",b.get("nodes"),a.from),this.addReference(a,"to",b.get("nodes"),a.to),a},toJSON:function(){return{_id:this.get("_id"),title:this.get("title"),uri:this.get("uri"),description:this.get("description"),from:this.get("from")?this.get("from").get("_id"):null,to:this.get("to")?this.get("to").get("_id"):null,color:this.get("color"),created_by:this.get("created_by")?this.get("created_by").get("_id"):null}}}),h=c.View=d.extend({type:"view",relations:[{type:b.HasOne,key:"created_by",relatedModel:e}],prepare:function(a){var b=a.project;if(this.addReference(a,"created_by",b.get("users"),a.created_by,b.current_user),a.description=a.description||"","undefined"!=typeof a.offset){var c={};Array.isArray(a.offset)?(c.x=a.offset[0],c.y=a.offset.length>1?a.offset[1]:a.offset[0]):null!=a.offset.x&&(c.x=a.offset.x,c.y=a.offset.y),a.offset=c}return a},toJSON:function(){return{_id:this.get("_id"),zoom_level:this.get("zoom_level"),offset:this.get("offset"),title:this.get("title"),description:this.get("description"),created_by:this.get("created_by")?this.get("created_by").get("_id"):null}}}),i=(c.Project=d.extend({type:"project",relations:[{type:b.HasMany,key:"users",relatedModel:e,reverseRelation:{key:"project",includeInJSON:"_id"}},{type:b.HasMany,key:"nodes",relatedModel:f,reverseRelation:{key:"project",includeInJSON:"_id"}},{type:b.HasMany,key:"edges",relatedModel:g,reverseRelation:{key:"project",includeInJSON:"_id"}},{type:b.HasMany,key:"views",relatedModel:h,reverseRelation:{key:"project",includeInJSON:"_id"}}],addUser:function(a,b){a.project=this;var c=e.findOrCreate(a);return this.get("users").push(c,b),c},addNode:function(a,b){a.project=this;var c=f.findOrCreate(a);return this.get("nodes").push(c,b),c},addEdge:function(a,b){a.project=this;var c=g.findOrCreate(a);return this.get("edges").push(c,b),c},addView:function(a,b){a.project=this;var c=h.findOrCreate(a);return this.get("views").push(c,b),c},removeNode:function(a){this.get("nodes").remove(a)},removeEdge:function(a){this.get("edges").remove(a)},validate:function(a){var b=this;_([].concat(a.users,a.nodes,a.edges,a.views)).each(function(a){a&&(a.project=b)})},initialize:function(){var a=this;this.on("remove:nodes",function(b){a.get("edges").remove(a.get("edges").filter(function(a){return a.get("from")===b||a.get("to")===b}))})}}),c.RosterUser=b.Model.extend({type:"roster_user",idAttribute:"_id",constructor:function(a){"undefined"!=typeof a&&(a._id=a._id||a.id||c.getUID(this),a.title=a.title||"(untitled "+this.type+")",a.description=a.description||"",a.uri=a.uri||"",a.project=a.project||null,a.site_id=a.site_id||0,"function"==typeof this.prepare&&(a=this.prepare(a))),b.Model.prototype.constructor.call(this,a)},validate:function(){return this.type?void 0:"object has no type"},prepare:function(a){return a.color=a.color||"#666666",a},toJSON:function(){return{_id:this.get("_id"),title:this.get("title"),uri:this.get("uri"),description:this.get("description"),color:this.get("color"),project:null!=this.get("project")?this.get("project").get("id"):null,site_id:this.get("site_id")}}}));c.UsersList=b.Collection.extend({model:i})}}.call(window),Rkns.defaults={language:navigator.language||navigator.userLanguage||"en",container:"renkan",search:[],bins:[],static_url:"",show_bins:!0,properties:[],show_editor:!0,read_only:!1,editor_mode:!0,manual_save:!1,show_top_bar:!0,default_user_color:"#303030",size_bug_fix:!0,force_resize:!1,allow_double_click:!0,zoom_on_scroll:!0,element_delete_delay:0,autoscale_padding:50,default_view:!1,show_search_field:!0,show_user_list:!0,user_name_editable:!0,user_color_editable:!0,show_save_button:!0,show_export_button:!0,show_open_button:!1,show_addnode_button:!0,show_addedge_button:!0,show_bookmarklet:!0,show_fullscreen_button:!0,home_button_url:!1,home_button_title:"Home",show_minimap:!0,minimap_width:160,minimap_height:120,minimap_padding:20,minimap_background_color:"#ffffff",minimap_border_color:"#cccccc",minimap_highlight_color:"#ffff00",minimap_highlight_weight:5,buttons_background:"#202020",buttons_label_color:"#c000c0",buttons_label_font_size:9,show_node_circles:!0,clip_node_images:!0,node_images_fill_mode:!1,node_size_base:25,node_stroke_width:2,selected_node_stroke_width:4,node_fill_color:"#ffffff",highlighted_node_fill_color:"#ffff00",node_label_distance:5,node_label_max_length:60,label_untitled_nodes:"(untitled)",change_shapes:!0,edge_stroke_width:2,selected_edge_stroke_width:4,edge_label_distance:0,edge_label_max_length:20,edge_arrow_length:18,edge_arrow_width:12,edge_gap_in_bundles:12,label_untitled_edges:"",tooltip_width:275,tooltip_padding:10,tooltip_margin:15,tooltip_arrow_length:20,tooltip_arrow_width:40,tooltip_top_color:"#f0f0f0",tooltip_bottom_color:"#d0d0d0",tooltip_border_color:"#808080",tooltip_border_width:1,show_node_editor_uri:!0,show_node_editor_description:!0,show_node_editor_size:!0,show_node_editor_color:!0,show_node_editor_image:!0,show_node_editor_creator:!0,uploaded_image_max_kb:500,show_node_tooltip_uri:!0,show_node_tooltip_description:!0,show_node_tooltip_color:!0,show_node_tooltip_image:!0,show_node_tooltip_creator:!0,show_edge_editor_uri:!0,show_edge_editor_color:!0,show_edge_editor_direction:!0,show_edge_editor_nodes:!0,show_edge_editor_creator:!0,show_edge_tooltip_uri:!0,show_edge_tooltip_color:!0,show_edge_tooltip_nodes:!0,show_edge_tooltip_creator:!0},Rkns.i18n={fr:{"Edit Node":"Édition d’un nœud","Edit Edge":"Édition d’un lien","Title:":"Titre :","URI:":"URI :","Description:":"Description :","From:":"De :","To:":"Vers :",Image:"Image","Image URL:":"URL d'Image","Choose Image File:":"Choisir un fichier image","Full Screen":"Mode plein écran","Add Node":"Ajouter un nœud","Add Edge":"Ajouter un lien","Save Project":"Enregistrer le projet","Open Project":"Ouvrir un projet","Auto-save enabled":"Enregistrement automatique activé","Connection lost":"Connexion perdue","Created by:":"Créé par :","Zoom In":"Agrandir l’échelle","Zoom Out":"Rapetisser l’échelle",Edit:"Éditer",Remove:"Supprimer","Cancel deletion":"Annuler la suppression","Link to another node":"Créer un lien",Enlarge:"Agrandir",Shrink:"Rétrécir","Click on the background canvas to add a node":"Cliquer sur le fond du graphe pour rajouter un nœud","Click on a first node to start the edge":"Cliquer sur un premier nœud pour commencer le lien","Click on a second node to complete the edge":"Cliquer sur un second nœud pour terminer le lien",Wikipedia:"Wikipédia","Wikipedia in ":"Wikipédia en ",French:"Français",English:"Anglais",Japanese:"Japonais","Untitled project":"Projet sans titre","Lignes de Temps":"Lignes de Temps","Loading, please wait":"Chargement en cours, merci de patienter","Edge color:":"Couleur :","Node color:":"Couleur :","Choose color":"Choisir une couleur","Change edge direction":"Changer le sens du lien","Do you really wish to remove node ":"Voulez-vous réellement supprimer le nœud ","Do you really wish to remove edge ":"Voulez-vous réellement supprimer le lien ","This file is not an image":"Ce fichier n'est pas une image","Image size must be under ":"L'image doit peser moins de ","Size:":"Taille :",KB:"ko","Choose from vocabulary:":"Choisir dans un vocabulaire :","SKOS Documentation properties":"SKOS: Propriétés documentaires","has note":"a pour note","has example":"a pour exemple","has definition":"a pour définition","SKOS Semantic relations":"SKOS: Relations sémantiques","has broader":"a pour concept plus large","has narrower":"a pour concept plus étroit","has related":"a pour concept apparenté","Dublin Core Metadata":"Métadonnées Dublin Core","has contributor":"a pour contributeur",covers:"couvre","created by":"créé par","has date":"a pour date","published by":"édité par","has source":"a pour source","has subject":"a pour sujet","Dragged resource":"Ressource glisée-déposée","Search the Web":"Rechercher en ligne","Search in Bins":"Rechercher dans les chutiers","Close bin":"Fermer le chutier","Refresh bin":"Rafraîchir le chutier","(untitled)":"(sans titre)","Select contents:":"Sélectionner des contenus :","Drag items from this website, drop them in Renkan":"Glissez des éléments de ce site web vers Renkan","Drag this button to your bookmark bar. When on a third-party website, click it to enable drag-and-drop from the website to Renkan.":"Glissez ce bouton vers votre barre de favoris. Ensuite, depuis un site tiers, cliquez dessus pour activer 'Drag-to-Add' puis glissez des éléments de ce site vers Renkan","Shapes available":"Formes disponibles",Circle:"Cercle",Square:"Carré",Diamond:"Losange",Hexagone:"Hexagone",Ellipse:"Ellipse",Star:"Étoile"}},Rkns.jsonIO=function(a,b){var c=a.project;"undefined"==typeof b.http_method&&(b.http_method="PUT");var d=function(){a.renderer.redrawActive=!1,Rkns.$.getJSON(b.url,function(b){c.set(b,{validate:!0}),a.renderer.redrawActive=!0,a.renderer.autoScale()})},e=function(){var d=c.toJSON();a.read_only||Rkns.$.ajax({type:b.http_method,url:b.url,contentType:"application/json",data:JSON.stringify(d),success:function(){}})},f=Rkns._.throttle(function(){setTimeout(e,100)},1e3);c.on("add:nodes add:edges add:users add:views",function(a){a.on("change remove",function(){f()}),f()}),c.on("change",function(){f()}),d()},Rkns.jsonIOSaveOnClick=function(a,b){var c=a.project,d=!1,e=function(){return"Project not saved"};"undefined"==typeof b.http_method&&(b.http_method="POST");var f=function(){var d={},e=/id=([^&#?=]+)/,f=document.location.hash.match(e);f&&(d.id=f[1]),Rkns.$.ajax({url:b.url,data:d,success:function(b){c.set(b,{validate:!0}),a.renderer.autoScale()}})},g=function(){c.set("saved_at",new Date);var a=c.toJSON();Rkns.$.ajax({type:b.http_method,url:b.url,contentType:"application/json",data:JSON.stringify(a),success:function(){$(window).off("beforeunload",e),d=!1}})},h=function(){var a=c.get("title");a&&c.get("nodes").length?$(".Rk-Save-Button").removeClass("disabled"):$(".Rk-Save-Button").addClass("disabled"),a&&$(".Rk-PadTitle").css("border-color","#333333"),d||(d=!0,$(window).on("beforeunload",e))};f(),c.on("add:nodes add:edges add:users change",function(a){a.on("change remove",function(){h()}),h()}),a.renderer.save=function(){$(".Rk-Save-Button").hasClass("disabled")?c.get("title")||$(".Rk-PadTitle").css("border-color","#ff0000"):g()}},function(a){"use strict";var b=a._,c=a.Ldt={},d=(c.Bin=function(a,b){if(b.ldt_type){var d=c[b.ldt_type+"Bin"];if(d)return new d(a,b)}console.error("No such LDT Bin Type")},c.ProjectBin=a.Utils.inherit(a._BaseBin));d.prototype.tagTemplate=b.template('<li class="Rk-Bin-Item" draggable="true" data-image="<%- Rkns.Utils.getFullURL(static_url+\'img/ldt-tag.png\') %>" data-uri="<%=ldt_platform%>ldtplatform/ldt/front/search/?search=<%=encodedtitle%>&field=all" data-title="<%-title%>" data-description="Tag \'<%-title%>\'"><img class="Rk-Ldt-Tag-Icon" src="<%-static_url%>img/ldt-tag.png" /><h4><%=htitle%></h4><div class="Rk-Clear"></div></li>'),d.prototype.annotationTemplate=b.template('<li class="Rk-Bin-Item" draggable="true" data-image="<%- Rkns.Utils.getFullURL(image) %>" data-uri="<%=ldt_platform%>ldtplatform/ldt/front/player/<%=mediaid%>/#id=<%=annotationid%>" data-title="<%-title%>" data-description="<%-description%>"><img class="Rk-Ldt-Annotation-Icon" src="<%=image%>"/><h4><%=htitle%></h4><p><%=hdescription%></p><p>Start: <%=start%>, End: <%=end%>, Duration: <%=duration%></p><div class="Rk-Clear"></div></li>'),d.prototype._init=function(a,b){this.renkan=a,this.proj_id=b.project_id,this.ldt_platform=b.ldt_platform||"http://ldt.iri.centrepompidou.fr/",this.title_$.html(b.title),this.title_icon_$.addClass("Rk-Ldt-Title-Icon"),this.refresh()},d.prototype.render=function(c){function d(a){var c=b(a).escape();return f.isempty?c:f.replace(c,"<span class='searchmatch'>$1</span>")}function e(a){function b(a){for(var b=a.toString();b.length<2;)b="0"+b;return b}var c=Math.abs(Math.floor(a/1e3)),d=Math.floor(c/3600),e=Math.floor(c/60)%60,f=c%60,g="";return d&&(g+=b(d)+":"),g+=b(e)+":"+b(f)}var f=c||a.Utils.regexpFromTextOrArray(),g="<li><h3>Tags</h3></li>",h=this.data.meta["dc:title"],i=this,j=0;i.title_$.text('LDT Project: "'+h+'"'),b(i.data.tags).map(function(a){var b=a.meta["dc:title"];(f.isempty||f.test(b))&&(j++,g+=i.tagTemplate({ldt_platform:i.ldt_platform,title:b,htitle:d(b),encodedtitle:encodeURIComponent(b),static_url:i.renkan.options.static_url}))}),g+="<li><h3>Annotations</h3></li>",b(i.data.annotations).map(function(a){var b=a.content.description,c=a.content.title.replace(b,"");if(f.isempty||f.test(c)||f.test(b)){j++;var h=a.end-a.begin,k=a.content&&a.content.img&&a.content.img.src?a.content.img.src:h?i.renkan.options.static_url+"img/ldt-segment.png":i.renkan.options.static_url+"img/ldt-point.png";g+=i.annotationTemplate({ldt_platform:i.ldt_platform,title:c,htitle:d(c),description:b,hdescription:d(b),start:e(a.begin),end:e(a.end),duration:e(h),mediaid:a.media,annotationid:a.id,image:k,static_url:i.renkan.options.static_url})}}),this.main_$.html(g),!f.isempty&&j?this.count_$.text(j).show():this.count_$.hide(),f.isempty||j?this.$.show():this.$.hide(),this.renkan.resizeBins()},d.prototype.refresh=function(){var b=this;a.$.ajax({url:this.ldt_platform+"ldtplatform/ldt/cljson/id/"+this.proj_id,dataType:"jsonp",success:function(a){b.data=a,b.render()}})};var e=c.Search=function(a,b){this.renkan=a,this.lang=b.lang||"en"};e.prototype.getBgClass=function(){return"Rk-Ldt-Icon"},e.prototype.getSearchTitle=function(){return this.renkan.translate("Lignes de Temps")},e.prototype.search=function(a){this.renkan.tabs.push(new f(this.renkan,{search:a}))};var f=c.ResultsBin=a.Utils.inherit(a._BaseBin);f.prototype.segmentTemplate=b.template('<li class="Rk-Bin-Item" draggable="true" data-image="<%- Rkns.Utils.getFullURL(image) %>" data-uri="<%=ldt_platform%>ldtplatform/ldt/front/player/<%=mediaid%>/#id=<%=annotationid%>" data-title="<%-title%>" data-description="<%-description%>"><img class="Rk-Ldt-Annotation-Icon" src="<%=image%>"/><h4><%=htitle%></h4><p><%=hdescription%></p><p>Start: <%=start%>, End: <%=end%>, Duration: <%=duration%></p><div class="Rk-Clear"></div></li>'),f.prototype._init=function(a,b){this.renkan=a,this.ldt_platform=b.ldt_platform||"http://ldt.iri.centrepompidou.fr/",this.max_results=b.max_results||50,this.search=b.search,this.title_$.html('Lignes de Temps: "'+b.search+'"'),this.title_icon_$.addClass("Rk-Ldt-Title-Icon"),this.refresh()},f.prototype.render=function(c){function d(a){return g.replace(b(a).escape(),"<span class='searchmatch'>$1</span>")}function e(a){function b(a){for(var b=a.toString();b.length<2;)b="0"+b;return b}var c=Math.abs(Math.floor(a/1e3)),d=Math.floor(c/3600),e=Math.floor(c/60)%60,f=c%60,g="";return d&&(g+=b(d)+":"),g+=b(e)+":"+b(f)}if(this.data){var f=c||a.Utils.regexpFromTextOrArray(),g=f.isempty?a.Utils.regexpFromTextOrArray(this.search):f,h="",i=this,j=0;b(this.data.objects).each(function(a){var b=a.abstract,c=a.title;if(f.isempty||f.test(c)||f.test(b)){j++;var g=a.duration,k=a.start_ts,l=+a.duration+k,m=g?i.renkan.options.static_url+"img/ldt-segment.png":i.renkan.options.static_url+"img/ldt-point.png";h+=i.segmentTemplate({ldt_platform:i.ldt_platform,title:c,htitle:d(c),description:b,hdescription:d(b),start:e(k),end:e(l),duration:e(g),mediaid:a.iri_id,annotationid:a.element_id,image:m})}}),this.main_$.html(h),!f.isempty&&j?this.count_$.text(j).show():this.count_$.hide(),f.isempty||j?this.$.show():this.$.hide(),this.renkan.resizeBins()}},f.prototype.refresh=function(){var b=this;a.$.ajax({url:this.ldt_platform+"ldtplatform/api/ldt/1.0/segments/search/",data:{format:"jsonp",q:this.search,limit:this.max_results},dataType:"jsonp",success:function(a){b.data=a,b.render()}})}}(window.Rkns),Rkns.ResourceList={},Rkns.ResourceList.Bin=Rkns.Utils.inherit(Rkns._BaseBin),Rkns.ResourceList.Bin.prototype.resultTemplate=Rkns._.template('<li class="Rk-Bin-Item Rk-ResourceList-Item" draggable="true" data-uri="<%-url%>" data-title="<%-title%>" data-description="<%-description%>" <% if (image) { %>data-image="<%- Rkns.Utils.getFullURL(image) %>"<% } else { %>data-image=""<% } %> ><% if (image) { %><img class="Rk-ResourceList-Image" src="<%-image%>"/><% } %><h4 class="Rk-ResourceList-Title"><% if (url) { %><a href="<%-url%>" target="_blank"><% } %><%=htitle%><% if (url) { %></a><% } %></h4><% if (description) { %><p class="Rk-ResourceList-Description"><%=hdescription%></p><% } %><% if (image) { %><div style="clear: both;"></div><% } %></li>'),Rkns.ResourceList.Bin.prototype._init=function(a,b){this.renkan=a,this.title_$.html(b.title),b.list&&(this.data=b.list),this.refresh()},Rkns.ResourceList.Bin.prototype.render=function(a){function b(a){var b=_(a).escape();return c.isempty?b:c.replace(b,"<span class='searchmatch'>$1</span>")}var c=a||Rkns.Utils.regexpFromTextOrArray(),d="",e=this,f=0;Rkns._(this.data).each(function(a){var g;if("string"==typeof a)if(/^(https?:\/\/|www)/.test(a))g={url:a};else{g={title:a.replace(/[:,]?\s?(https?:\/\/|www)[\d\w\/.&?=#%-_]+\s?/,"").trim()};var h=a.match(/(https?:\/\/|www)[\d\w\/.&?=#%-_]+/);h&&(g.url=h[0]),g.title.length>80&&(g.description=g.title,g.title=g.title.replace(/^(.{30,60})\s.+$/,"$1…"))}else g=a;var i=g.title||(g.url||"").replace(/^https?:\/\/(www\.)?/,"").replace(/^(.{40}).+$/,"$1…"),j=g.url||"",k=g.description||"",l=g.image||"";j&&!/^https?:\/\//.test(j)&&(j="http://"+j),(c.isempty||c.test(i)||c.test(k))&&(f++,d+=e.resultTemplate({url:j,title:i,htitle:b(i),image:l,description:k,hdescription:b(k),static_url:e.renkan.options.static_url}))
+}),e.main_$.html(d),!c.isempty&&f?this.count_$.text(f).show():this.count_$.hide(),c.isempty||f?this.$.show():this.$.hide(),this.renkan.resizeBins()},Rkns.ResourceList.Bin.prototype.refresh=function(){this.data&&this.render()},Rkns.Wikipedia={},Rkns.Wikipedia.Search=function(a,b){this.renkan=a,this.lang=b.lang||"en"},Rkns.Wikipedia.Search.prototype.getBgClass=function(){return"Rk-Wikipedia-Search-Icon Rk-Wikipedia-Lang-"+this.lang},Rkns.Wikipedia.Search.prototype.getSearchTitle=function(){var a={fr:"French",en:"English",ja:"Japanese"};return a[this.lang]?this.renkan.translate("Wikipedia in ")+this.renkan.translate(a[this.lang]):this.renkan.translate("Wikipedia")+" ["+this.lang+"]"},Rkns.Wikipedia.Search.prototype.search=function(a){this.renkan.tabs.push(new Rkns.Wikipedia.Bin(this.renkan,{lang:this.lang,search:a}))},Rkns.Wikipedia.Bin=Rkns.Utils.inherit(Rkns._BaseBin),Rkns.Wikipedia.Bin.prototype.resultTemplate=Rkns._.template('<li class="Rk-Wikipedia-Result Rk-Bin-Item" draggable="true" data-uri="<%-url%>" data-title="Wikipedia: <%-title%>" data-description="<%-description%>" data-image="<%- Rkns.Utils.getFullURL( static_url + \'img/wikipedia.png\' ) %>"><img class="Rk-Wikipedia-Icon" src="<%-static_url%>img/wikipedia.png"></div><h4 class="Rk-Wikipedia-Title"><a href="<%-url%>" target="_blank"><%=htitle%></a></h4><p class="Rk-Wikipedia-Snippet"><%=hdescription%></p></li>'),Rkns.Wikipedia.Bin.prototype._init=function(a,b){this.renkan=a,this.search=b.search,this.lang=b.lang||"en",this.title_icon_$.addClass("Rk-Wikipedia-Title-Icon Rk-Wikipedia-Lang-"+this.lang),this.title_$.html(this.search).addClass("Rk-Wikipedia-Title"),this.refresh()},Rkns.Wikipedia.Bin.prototype.render=function(a){function b(a){return d.replace(_(a).escape(),"<span class='searchmatch'>$1</span>")}var c=a||Rkns.Utils.regexpFromTextOrArray(),d=c.isempty?Rkns.Utils.regexpFromTextOrArray(this.search):c,e="",f=this,g=0;Rkns._(this.data.query.search).each(function(a){var d=a.title,h="http://"+f.lang+".wikipedia.org/wiki/"+encodeURI(d.replace(/ /g,"_")),i=Rkns.$("<div>").html(a.snippet).text();(c.isempty||c.test(d)||c.test(i))&&(g++,e+=f.resultTemplate({url:h,title:d,htitle:b(d),description:i,hdescription:b(i),static_url:f.renkan.options.static_url}))}),f.main_$.html(e),!c.isempty&&g?this.count_$.text(g).show():this.count_$.hide(),c.isempty||g?this.$.show():this.$.hide(),this.renkan.resizeBins()},Rkns.Wikipedia.Bin.prototype.refresh=function(){var a=this;Rkns.$.ajax({url:"http://"+a.lang+".wikipedia.org/w/api.php?action=query&list=search&srsearch="+encodeURIComponent(this.search)+"&format=json",dataType:"jsonp",success:function(b){a.data=b,a.render()}})},define("renderer/baserepresentation",["jquery","underscore"],function(a,b){var c=function(a,c){if("undefined"!=typeof a&&(this.renderer=a,this.renkan=a.renkan,this.project=a.renkan.project,this.options=a.renkan.options,this.model=c,this.model)){var d=this;this._changeBinding=function(){d.redraw()},this._removeBinding=function(){a.removeRepresentation(d),b(function(){a.redraw()}).defer()},this._selectBinding=function(){d.select()},this._unselectBinding=function(){d.unselect()},this.model.on("change",this._changeBinding),this.model.on("remove",this._removeBinding),this.model.on("select",this._selectBinding),this.model.on("unselect",this._unselectBinding)}};return b(c.prototype).extend({_super:function(a){return c.prototype[a].apply(this,Array.prototype.slice.call(arguments,1))},redraw:function(){},moveTo:function(){},show:function(){return"chaud cacao"},hide:function(){},select:function(){this.model&&this.model.trigger("selected")},unselect:function(){this.model&&this.model.trigger("unselected")},highlight:function(){},unhighlight:function(){},mousedown:function(){},mouseup:function(){this.model&&this.model.trigger("clicked")},destroy:function(){this.model&&(this.model.off("change",this._changeBinding),this.model.off("remove",this._removeBinding),this.model.off("select",this._selectBinding),this.model.off("unselect",this._unselectBinding))}}),c}),define("requtils",[],function(){return{getUtils:function(){return window.Rkns.Utils},getRenderer:function(){return window.Rkns.Renderer}}}),define("renderer/basebutton",["jquery","underscore","requtils","renderer/baserepresentation"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({moveTo:function(a){this.sector.moveTo(a)},show:function(){this.sector.show()},hide:function(){this.sector.hide()},select:function(){this.sector.select()},unselect:function(a){this.sector.unselect(),(!a||a!==this.source_representation&&a.source_representation!==this.source_representation)&&this.source_representation.unselect()},destroy:function(){this.sector.destroy()}}),f}),define("renderer/shapebuilder",[],function(){var a={circle:{getShape:function(){return new paper.Path.Circle([0,0],1)},getImageShape:function(a,b){return new paper.Path.Circle(a,b)}},rectangle:{getShape:function(){return new paper.Path.Rectangle([-2,-2],[2,2])},getImageShape:function(a,b){return new paper.Path.Rectangle([-b,-b],[2*b,2*b])}},ellipse:{getShape:function(){return new paper.Path.Ellipse(new paper.Rectangle([-2,-1],[2,1]))},getImageShape:function(a,b){return new paper.Path.Ellipse(new paper.Rectangle([-b,-b/2],[2*b,b]))}},polygon:{getShape:function(){return new paper.Path.RegularPolygon([0,0],6,1)},getImageShape:function(a,b){return new paper.Path.RegularPolygon([0,0],6,b)}},diamond:{getShape:function(){var a=new paper.Path.Rectangle([-2,-2],[2,2]);return a.rotate(45),a},getImageShape:function(a,b){var c=new paper.Path.Rectangle([-b,-b],[2*b,2*b]);return c.rotate(45),c}},star:{getShape:function(){return new paper.Path.Star([0,0],8,1,.7)},getImageShape:function(a,b){return new paper.Path.Star([0,0],8,1*b,.7*b)}},svg:function(a){return{getShape:function(){return new paper.Path(a)},getImageShape:function(){return new paper.Path}}}},b=function(b){return"undefined"==typeof b&&(b="circle"),"svg:"===b.substr(0,4)?a.svg(b.substr(4)):(b in a||(b="circle"),a[b])};return b}),define("renderer/noderepr",["jquery","underscore","requtils","renderer/baserepresentation","renderer/shapebuilder"],function(a,b,c,d,e){var f=c.getUtils(),g=f.inherit(d);return b(g.prototype).extend({_init:function(){if(this.renderer.node_layer.activate(),this.type="Node",this.buildShape(),this.options.show_node_circles?(this.circle.strokeWidth=this.options.node_stroke_width,this.h_ratio=1):this.h_ratio=0,this.title=a('<div class="Rk-Label">').appendTo(this.renderer.labels_$),this.options.editor_mode){var b=c.getRenderer();this.normal_buttons=[new b.NodeEditButton(this.renderer,null),new b.NodeRemoveButton(this.renderer,null),new b.NodeLinkButton(this.renderer,null),new b.NodeEnlargeButton(this.renderer,null),new b.NodeShrinkButton(this.renderer,null)],this.pending_delete_buttons=[new b.NodeRevertButton(this.renderer,null)],this.all_buttons=this.normal_buttons.concat(this.pending_delete_buttons);for(var d=0;d<this.all_buttons.length;d++)this.all_buttons[d].source_representation=this;this.active_buttons=[]}else this.active_buttons=this.all_buttons=[];this.last_circle_radius=1,this.renderer.minimap&&(this.renderer.minimap.node_layer.activate(),this.minimap_circle=new paper.Path.Circle([0,0],1),this.minimap_circle.__representation=this.renderer.minimap.miniframe.__representation,this.renderer.minimap.node_group.addChild(this.minimap_circle))},buildShape:function(){"undefined"!=typeof this.model.get("shape_changed")&&this.model.get("shape_changed")===!0&&(this.model.set("shape_changed",!1),delete this.img),this.circle&&(this.circle.remove(),delete this.circle),this.shapeBuilder=new e(this.model.get("shape")),this.circle=this.shapeBuilder.getShape(),this.circle.__representation=this,this.last_circle_radius=1},redraw:function(a){"undefined"!=typeof this.model.get("shape_changed")&&this.model.get("shape_changed")===!0&&this.buildShape();var c=new paper.Point(this.model.get("position")),d=this.options.node_size_base*Math.exp((this.model.get("size")||0)*f._NODE_SIZE_STEP);this.is_dragging&&this.paper_coords||(this.paper_coords=this.renderer.toPaperCoords(c)),this.circle_radius=d*this.renderer.scale,this.last_circle_radius!==this.circle_radius&&(this.all_buttons.forEach(function(a){a.setSectorSize()}),this.circle.scale(this.circle_radius/this.last_circle_radius),this.node_image&&this.node_image.scale(this.circle_radius/this.last_circle_radius)),this.circle.position=this.paper_coords,this.node_image&&(this.node_image.position=this.paper_coords.subtract(this.image_delta.multiply(this.circle_radius))),this.last_circle_radius=this.circle_radius;var e=this.active_buttons,g=1;this.model.get("delete_scheduled")?(g=.5,this.active_buttons=this.pending_delete_buttons,this.circle.dashArray=[2,2]):(g=1,this.active_buttons=this.normal_buttons,this.circle.dashArray=null),this.selected&&this.renderer.isEditable()&&(e!==this.active_buttons&&e.forEach(function(a){a.hide()}),this.active_buttons.forEach(function(a){a.show()})),this.node_image&&(this.node_image.opacity=this.highlighted?.5*g:g-.01),this.circle.fillColor=this.highlighted?this.options.highlighted_node_fill_color:this.options.node_fill_color,this.circle.opacity=this.options.show_node_circles?g:.01;var h=this.model.get("title")||this.renkan.translate(this.options.label_untitled_nodes)||"";h=f.shortenText(h,this.options.node_label_max_length),"object"==typeof this.highlighted?this.title.html(this.highlighted.replace(b(h).escape(),'<span class="Rk-Highlighted">$1</span>')):this.title.text(h),this.title.css({left:this.paper_coords.x,top:this.paper_coords.y+this.circle_radius*this.h_ratio+this.options.node_label_distance,opacity:g});var i=this.model.get("color")||(this.model.get("created_by")||f._USER_PLACEHOLDER(this.renkan)).get("color");this.circle.strokeColor=i;var j=this.paper_coords;this.all_buttons.forEach(function(a){a.moveTo(j)});var k=this.img;if(this.img=this.model.get("image"),this.img&&this.img!==k&&this.showImage(),this.node_image&&!this.img&&(this.node_image.remove(),delete this.node_image),this.renderer.minimap){this.minimap_circle.fillColor=i;var l=this.renderer.toMinimapCoords(c),m=this.renderer.minimap.scale*d,n=new paper.Size([m,m]);this.minimap_circle.fitBounds(l.subtract(n),n.multiply(2))}if(!a){var o=this;b.each(this.project.get("edges").filter(function(a){return a.get("to")===o.model||a.get("from")===o.model}),function(a){var b=o.renderer.getRepresentationByModel(a);b&&"undefined"!=typeof b.from_representation&&"undefined"!=typeof b.from_representation.paper_coords&&"undefined"!=typeof b.to_representation&&"undefined"!=typeof b.to_representation.paper_coords&&b.redraw()})}},showImage:function(){var b=null;if("undefined"==typeof this.renderer.image_cache[this.img]?(b=new Image,this.renderer.image_cache[this.img]=b,b.src=this.img):b=this.renderer.image_cache[this.img],b.width){this.node_image&&this.node_image.remove(),this.renderer.node_layer.activate();var c=b.width,d=b.height,e=this.model.get("clip_path"),f="undefined"!=typeof e&&e,g=null,h=null,i=null;if(f){g=new paper.Path;var j=e.match(/[a-z][^a-z]+/gi)||[],k=[0,0],l=1/0,m=1/0,n=-1/0,o=-1/0,p=function(a,b){var e=a.slice(1).map(function(a,e){var f=parseFloat(a),g=e%2;return f=g?(f-.5)*d:(f-.5)*c,b&&(f+=k[g]),g?(m=Math.min(m,f),o=Math.max(o,f)):(l=Math.min(l,f),n=Math.max(n,f)),f});return k=e.slice(-2),e};j.forEach(function(a){var b=a.match(/([a-z]|[0-9.-]+)/gi)||[""];switch(b[0]){case"M":g.moveTo(p(b));break;case"m":g.moveTo(p(b,!0));break;case"L":g.lineTo(p(b));break;case"l":g.lineTo(p(b,!0));break;case"C":g.cubicCurveTo(p(b));break;case"c":g.cubicCurveTo(p(b,!0));break;case"Q":g.quadraticCurveTo(p(b));break;case"q":g.quadraticCurveTo(p(b,!0))}}),h=Math[this.options.node_images_fill_mode?"min":"max"](n-l,o-m)/2,i=new paper.Point((n+l)/2,(o+m)/2),this.options.show_node_circles||(this.h_ratio=(o-m)/(2*h))}else h=Math[this.options.node_images_fill_mode?"min":"max"](c,d)/2,i=new paper.Point(0,0),this.options.show_node_circles||(this.h_ratio=d/(2*h));var q=new paper.Raster(b);if(q.locked=!0,f&&(q=new paper.Group(g,q),q.opacity=.99,q.clipped=!0,g.__representation=this),this.options.clip_node_images){var r=this.shapeBuilder.getImageShape(i,h);q=new paper.Group(r,q),q.opacity=.99,q.clipped=!0,r.__representation=this}this.image_delta=i.divide(h),this.node_image=q,this.node_image.__representation=s,this.node_image.scale(this.circle_radius/h),this.node_image.position=this.paper_coords.subtract(this.image_delta.multiply(this.circle_radius)),this.redraw(),this.renderer.throttledPaperDraw()}else{var s=this;a(b).on("load",function(){s.showImage()})}},paperShift:function(a){this.options.editor_mode?this.renkan.read_only||(this.is_dragging=!0,this.paper_coords=this.paper_coords.add(a),this.redraw()):this.renderer.paperShift(a)},openEditor:function(){this.renderer.removeRepresentationsOfType("editor");var a=this.renderer.addRepresentation("NodeEditor",null);a.source_representation=this,a.draw()},select:function(){this.selected=!0,this.circle.strokeWidth=this.options.selected_node_stroke_width,this.renderer.isEditable()&&this.active_buttons.forEach(function(a){a.show()});var b=this.model.get("uri");b&&a(".Rk-Bin-Item").each(function(){var c=a(this);c.attr("data-uri")===b&&c.addClass("selected")}),this.options.editor_mode||this.openEditor(),this.renderer.minimap&&(this.minimap_circle.strokeWidth=this.options.minimap_highlight_weight,this.minimap_circle.strokeColor=this.options.minimap_highlight_color),this._super("select")},unselect:function(b){b&&b.source_representation===this||(this.selected=!1,this.all_buttons.forEach(function(a){a.hide()}),this.circle.strokeWidth=this.options.node_stroke_width,a(".Rk-Bin-Item").removeClass("selected"),this.renderer.minimap&&(this.minimap_circle.strokeColor=void 0),this._super("unselect"))},highlight:function(a){var b=a||!0;this.highlighted!==b&&(this.highlighted=b,this.redraw(),this.renderer.throttledPaperDraw())},unhighlight:function(){this.highlighted&&(this.highlighted=!1,this.redraw(),this.renderer.throttledPaperDraw())},saveCoords:function(){var a=this.renderer.toModelCoords(this.paper_coords),b={position:{x:a.x,y:a.y}};this.renderer.isEditable()&&this.model.set(b)},mousedown:function(a,b){b&&(this.renderer.unselectAll(),this.select())},mouseup:function(a,b){this.renderer.is_dragging&&this.renderer.isEditable()?this.saveCoords():(b||this.model.get("delete_scheduled")||this.openEditor(),this.model.trigger("clicked")),this.renderer.click_target=null,this.renderer.is_dragging=!1,this.is_dragging=!1},destroy:function(){this._super("destroy"),this.all_buttons.forEach(function(a){a.destroy()}),this.circle.remove(),this.title.remove(),this.renderer.minimap&&this.minimap_circle.remove(),this.node_image&&this.node_image.remove()}}),g}),define("renderer/edge",["jquery","underscore","requtils","renderer/baserepresentation"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({_init:function(){if(this.renderer.edge_layer.activate(),this.type="Edge",this.from_representation=this.renderer.getRepresentationByModel(this.model.get("from")),this.to_representation=this.renderer.getRepresentationByModel(this.model.get("to")),this.bundle=this.renderer.addToBundles(this),this.line=new paper.Path,this.line.add([0,0],[0,0],[0,0]),this.line.__representation=this,this.line.strokeWidth=this.options.edge_stroke_width,this.arrow=new paper.Path,this.arrow.add([0,0],[this.options.edge_arrow_length,this.options.edge_arrow_width/2],[0,this.options.edge_arrow_width]),this.arrow.__representation=this,this.text=a('<div class="Rk-Label Rk-Edge-Label">').appendTo(this.renderer.labels_$),this.arrow_angle=0,this.options.editor_mode){var b=c.getRenderer();this.normal_buttons=[new b.EdgeEditButton(this.renderer,null),new b.EdgeRemoveButton(this.renderer,null)],this.pending_delete_buttons=[new b.EdgeRevertButton(this.renderer,null)],this.all_buttons=this.normal_buttons.concat(this.pending_delete_buttons);for(var d=0;d<this.all_buttons.length;d++)this.all_buttons[d].source_representation=this;this.active_buttons=[]}else this.active_buttons=this.all_buttons=[];this.renderer.minimap&&(this.renderer.minimap.edge_layer.activate(),this.minimap_line=new paper.Path,this.minimap_line.add([0,0],[0,0]),this.minimap_line.__representation=this.renderer.minimap.miniframe.__representation,this.minimap_line.strokeWidth=1)},redraw:function(){var a=this.model.get("from"),b=this.model.get("to");if(a&&b&&(this.from_representation=this.renderer.getRepresentationByModel(a),this.to_representation=this.renderer.getRepresentationByModel(b),"undefined"!=typeof this.from_representation&&"undefined"!=typeof this.to_representation)){var c=this.from_representation.paper_coords,d=this.to_representation.paper_coords,f=d.subtract(c),g=f.length,h=f.divide(g),i=new paper.Point([-h.y,h.x]),j=this.bundle.getPosition(this),k=i.multiply(this.options.edge_gap_in_bundles*j),l=c.add(k),m=d.add(k),n=f.angle,o=i.multiply(this.options.edge_label_distance),p=f.divide(3),q=this.model.get("color")||this.model.get("color")||(this.model.get("created_by")||e._USER_PLACEHOLDER(this.renkan)).get("color"),r=1;this.model.get("delete_scheduled")||this.from_representation.model.get("delete_scheduled")||this.to_representation.model.get("delete_scheduled")?(r=.5,this.line.dashArray=[2,2]):(r=1,this.line.dashArray=null);var s=this.active_buttons;this.active_buttons=this.model.get("delete_scheduled")?this.pending_delete_buttons:this.normal_buttons,this.selected&&this.renderer.isEditable()&&s!==this.active_buttons&&(s.forEach(function(a){a.hide()}),this.active_buttons.forEach(function(a){a.show()})),this.paper_coords=l.add(m).divide(2),this.line.strokeColor=q,this.line.opacity=r,this.line.segments[0].point=c,this.line.segments[1].point=this.paper_coords,this.line.segments[1].handleIn=p.multiply(-1),this.line.segments[1].handleOut=p,this.line.segments[2].point=d,this.arrow.rotate(n-this.arrow_angle),this.arrow.fillColor=q,this.arrow.opacity=r,this.arrow.position=this.paper_coords,this.arrow_angle=n,n>90&&(n-=180,o=o.multiply(-1)),-90>n&&(n+=180,o=o.multiply(-1));var t=this.model.get("title")||this.renkan.translate(this.options.label_untitled_edges)||"";t=e.shortenText(t,this.options.node_label_max_length),this.text.text(t);var u=this.paper_coords.add(o);this.text.css({left:u.x,top:u.y,transform:"rotate("+n+"deg)","-moz-transform":"rotate("+n+"deg)","-webkit-transform":"rotate("+n+"deg)",opacity:r}),this.text_angle=n;var v=this.paper_coords;this.all_buttons.forEach(function(a){a.moveTo(v)}),this.renderer.minimap&&(this.minimap_line.strokeColor=q,this.minimap_line.segments[0].point=this.renderer.toMinimapCoords(new paper.Point(this.from_representation.model.get("position"))),this.minimap_line.segments[1].point=this.renderer.toMinimapCoords(new paper.Point(this.to_representation.model.get("position"))))}},openEditor:function(){this.renderer.removeRepresentationsOfType("editor");var a=this.renderer.addRepresentation("EdgeEditor",null);a.source_representation=this,a.draw()},select:function(){this.selected=!0,this.line.strokeWidth=this.options.selected_edge_stroke_width,this.renderer.isEditable()&&this.active_buttons.forEach(function(a){a.show()}),this.options.editor_mode||this.openEditor(),this._super("select")},unselect:function(a){a&&a.source_representation===this||(this.selected=!1,this.options.editor_mode&&this.all_buttons.forEach(function(a){a.hide()}),this.line.strokeWidth=this.options.edge_stroke_width,this._super("unselect"))},mousedown:function(a,b){b&&(this.renderer.unselectAll(),this.select())},mouseup:function(a,b){!this.renkan.read_only&&this.renderer.is_dragging?(this.from_representation.saveCoords(),this.to_representation.saveCoords(),this.from_representation.is_dragging=!1,this.to_representation.is_dragging=!1):(b||this.openEditor(),this.model.trigger("clicked")),this.renderer.click_target=null,this.renderer.is_dragging=!1},paperShift:function(a){this.options.editor_mode?this.options.read_only||(this.from_representation.paperShift(a),this.to_representation.paperShift(a)):this.renderer.paperShift(a)},destroy:function(){this._super("destroy"),this.line.remove(),this.arrow.remove(),this.text.remove(),this.renderer.minimap&&this.minimap_line.remove(),this.all_buttons.forEach(function(a){a.destroy()});var a=this;this.bundle.edges=b(this.bundle.edges).reject(function(b){return a===b})}}),f}),define("renderer/tempedge",["jquery","underscore","requtils","renderer/baserepresentation"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({_init:function(){this.renderer.edge_layer.activate(),this.type="Temp-edge";var a=(this.project.get("users").get(this.renkan.current_user)||e._USER_PLACEHOLDER(this.renkan)).get("color");this.line=new paper.Path,this.line.strokeColor=a,this.line.dashArray=[4,2],this.line.strokeWidth=this.options.selected_edge_stroke_width,this.line.add([0,0],[0,0]),this.line.__representation=this,this.arrow=new paper.Path,this.arrow.fillColor=a,this.arrow.add([0,0],[this.options.edge_arrow_length,this.options.edge_arrow_width/2],[0,this.options.edge_arrow_width]),this.arrow.__representation=this,this.arrow_angle=0},redraw:function(){var a=this.from_representation.paper_coords,b=this.end_pos,c=b.subtract(a).angle,d=a.add(b).divide(2);this.line.segments[0].point=a,this.line.segments[1].point=b,this.arrow.rotate(c-this.arrow_angle),this.arrow.position=d,this.arrow_angle=c},paperShift:function(a){if(!this.renderer.isEditable())return this.renderer.removeRepresentation(_this),void paper.view.draw();this.end_pos=this.end_pos.add(a);var b=paper.project.hitTest(this.end_pos);this.renderer.findTarget(b),this.redraw()},mouseup:function(a){var b=paper.project.hitTest(a.point),c=this.from_representation.model,d=!0;if(b&&"undefined"!=typeof b.item.__representation){var f=b.item.__representation;if("Node"===f.type.substr(0,4)){var g=f.model||f.source_representation.model;if(c!==g){var h={id:e.getUID("edge"),created_by:this.renkan.current_user,from:c,to:g};this.renderer.isEditable()&&this.project.addEdge(h)}}(c===f.model||f.source_representation&&f.source_representation.model===c)&&(d=!1,this.renderer.is_dragging=!0)}d&&(this.renderer.click_target=null,this.renderer.is_dragging=!1,this.renderer.removeRepresentation(this),paper.view.draw())},destroy:function(){this.arrow.remove(),this.line.remove()}}),f}),define("renderer/baseeditor",["jquery","underscore","requtils","renderer/baserepresentation"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({_init:function(){this.renderer.buttons_layer.activate(),this.type="editor",this.editor_block=new paper.Path;var c=b(b.range(8)).map(function(){return[0,0]});this.editor_block.add.apply(this.editor_block,c),this.editor_block.strokeWidth=this.options.tooltip_border_width,this.editor_block.strokeColor=this.options.tooltip_border_color,this.editor_block.opacity=.8,this.editor_$=a("<div>").appendTo(this.renderer.editor_$).css({position:"absolute",opacity:.8}).hide()},destroy:function(){this.editor_block.remove(),this.editor_$.remove()}}),f}),define("renderer/nodeeditor",["jquery","underscore","requtils","renderer/baseeditor"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({template:b.template('<h2><span class="Rk-CloseX">×</span><%-renkan.translate("Edit Node")%></span></h2><p><label><%-renkan.translate("Title:")%></label><input class="Rk-Edit-Title" type="text" value="<%-node.title%>"/></p><% if (options.show_node_editor_uri) { %><p><label><%-renkan.translate("URI:")%></label><input class="Rk-Edit-URI" type="text" value="<%-node.uri%>"/><a class="Rk-Edit-Goto" href="<%-node.uri%>" target="_blank"></a></p><% } %><% if (options.show_node_editor_description) { %><p><label><%-renkan.translate("Description:")%></label><textarea class="Rk-Edit-Description"><%-node.description%></textarea></p><% } %><% if (options.show_node_editor_size) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Size:")%></span><a href="#" class="Rk-Edit-Size-Down">-</a><span class="Rk-Edit-Size-Value"><%-node.size%></span><a href="#" class="Rk-Edit-Size-Up">+</a></p><% } %><% if (options.show_node_editor_color) { %><div class="Rk-Editor-p"><span class="Rk-Editor-Label"><%-renkan.translate("Node color:")%></span><div class="Rk-Edit-ColorPicker-Wrapper"><span class="Rk-Edit-Color" style="background:<%-node.color%>;"><span class="Rk-Edit-ColorTip"></span></span><%= renkan.colorPicker %><span class="Rk-Edit-ColorPicker-Text"><%- renkan.translate("Choose color") %></span></div></div><% } %><% if (options.show_node_editor_image) { %><div class="Rk-Edit-ImgWrap"><div class="Rk-Edit-ImgPreview"><img src="<%-node.image || node.image_placeholder%>" /><% if (node.clip_path) { %><svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewbox="0 0 1 1" preserveAspectRatio="none"><path style="stroke-width: .02; stroke:red; fill-opacity:.3; fill:red;" d="<%- node.clip_path %>"/></svg><% }%></div></div><p><label><%-renkan.translate("Image URL:")%></label><input class="Rk-Edit-Image" type="text" value="<%-node.image%>"/></p><p><label><%-renkan.translate("Choose Image File:")%></label><input class="Rk-Edit-Image-File" type="file" accept="image/*"/></p><% } %><% if (options.show_node_editor_creator && node.has_creator) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Created by:")%></span> <span class="Rk-UserColor" style="background:<%-node.created_by_color%>;"></span><%- shortenText(node.created_by_title, 25) %></p><% } %><% if (options.change_shapes) { %><p><label><%-renkan.translate("Shapes available")%>:</label> <select class="Rk-Edit-Shape"><option class="Rk-Edit-Vocabulary-Property" value="circle"<% if (node.shape === "circle") { %> selected<% } %>><%- renkan.translate("Circle") %></option><option class="Rk-Edit-Vocabulary-Property" value="rectangle"<% if (node.shape === "rectangle") { %> selected<% } %>><%- renkan.translate("Square") %></option><option class="Rk-Edit-Vocabulary-Property" value="diamond"<% if (node.shape === "diamond") { %> selected<% } %>><%- renkan.translate("Diamond") %></option><option class="Rk-Edit-Vocabulary-Property" value="polygon"<% if (node.shape === "polygon") { %> selected<% } %>><%- renkan.translate("Hexagone") %></option><option class="Rk-Edit-Vocabulary-Property" value="ellipse"<% if (node.shape === "ellipse") { %> selected<% } %>><%- renkan.translate("Ellipse") %></option><option class="Rk-Edit-Vocabulary-Property" value="star"<% if (node.shape === "star") { %> selected<% } %>><%- renkan.translate("Star") %></option></select></p><% } %>'),readOnlyTemplate:b.template('<h2><span class="Rk-CloseX">×</span><% if (options.show_node_tooltip_color) { %><span class="Rk-UserColor" style="background:<%-node.color%>;"></span><% } %><span class="Rk-Display-Title"><% if (node.uri) { %><a href="<%-node.uri%>" target="_blank"><% } %><%-node.title%><% if (node.uri) { %></a><% } %></span></h2><% if (node.uri && options.show_node_tooltip_uri) { %><p class="Rk-Display-URI"><a href="<%-node.uri%>" target="_blank"><%-node.short_uri%></a></p><% } %><% if (options.show_node_tooltip_description) { %><p class="Rk-Display-Description"><%-node.description%></p><% } %><% if (node.image && options.show_node_tooltip_image) { %><img class="Rk-Display-ImgPreview" src="<%-node.image%>" /><% } %><% if (node.has_creator && options.show_node_tooltip_creator) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Created by:")%></span><span class="Rk-UserColor" style="background:<%-node.created_by_color%>;"></span><%- shortenText(node.created_by_title, 25) %></p><% } %>'),draw:function(){var c=this.source_representation.model,d=c.get("created_by")||e._USER_PLACEHOLDER(this.renkan),f=this.renderer.isEditable()?this.template:this.readOnlyTemplate,g=this.options.static_url+"img/image-placeholder.png",h=c.get("size")||0;this.editor_$.html(f({node:{has_creator:!!c.get("created_by"),title:c.get("title"),uri:c.get("uri"),short_uri:e.shortenText((c.get("uri")||"").replace(/^(https?:\/\/)?(www\.)?/,"").replace(/\/$/,""),40),description:c.get("description"),image:c.get("image")||"",image_placeholder:g,color:c.get("color")||d.get("color"),clip_path:c.get("clip_path")||!1,created_by_color:d.get("color"),created_by_title:d.get("title"),size:(h>0?"+":"")+h,shape:c.get("shape")||"circle"},renkan:this.renkan,options:this.options,shortenText:e.shortenText})),this.redraw();var i=this,j=function(){i.renderer.removeRepresentation(i),paper.view.draw()};if(this.editor_$.find(".Rk-CloseX").click(j),this.editor_$.find(".Rk-Edit-Goto").click(function(){return c.get("uri")?void 0:!1}),this.renderer.isEditable()){var k=b(function(){b(function(){if(i.renderer.isEditable()){var a={title:i.editor_$.find(".Rk-Edit-Title").val()};i.options.show_node_editor_uri&&(a.uri=i.editor_$.find(".Rk-Edit-URI").val(),i.editor_$.find(".Rk-Edit-Goto").attr("href",a.uri||"#")),i.options.show_node_editor_image&&(a.image=i.editor_$.find(".Rk-Edit-Image").val(),i.editor_$.find(".Rk-Edit-ImgPreview").attr("src",a.image||g)),i.options.show_node_editor_description&&(a.description=i.editor_$.find(".Rk-Edit-Description").val()),i.options.change_shapes&&c.get("shape")!==i.editor_$.find(".Rk-Edit-Shape").val()&&(a.shape=i.editor_$.find(".Rk-Edit-Shape").val(),a.shape_changed=!0),c.set(a),i.redraw(),a.shape_changed===!0&&c.set(a)}else j()}).defer()}).throttle(500);this.editor_$.on("keyup",function(a){27===a.keyCode&&j()}),this.editor_$.find("input, textarea, select").on("change keyup paste",k),this.editor_$.find(".Rk-Edit-Image-File").change(function(){if(this.files.length){var a=this.files[0],b=new FileReader;if("image"!==a.type.substr(0,5))return void alert(i.renkan.translate("This file is not an image"));if(a.size>1024*i.options.uploaded_image_max_kb)return void alert(i.renkan.translate("Image size must be under ")+i.options.uploaded_image_max_kb+i.renkan.translate("KB"));b.onload=function(a){i.editor_$.find(".Rk-Edit-Image").val(a.target.result),k()},b.readAsDataURL(a)}}),this.editor_$.find(".Rk-Edit-Title")[0].focus();var l=i.editor_$.find(".Rk-Edit-ColorPicker");this.editor_$.find(".Rk-Edit-ColorPicker-Wrapper").hover(function(a){a.preventDefault(),l.show()},function(a){a.preventDefault(),l.hide()}),l.find("li").hover(function(b){b.preventDefault(),i.editor_$.find(".Rk-Edit-Color").css("background",a(this).attr("data-color"))},function(a){a.preventDefault(),i.editor_$.find(".Rk-Edit-Color").css("background",c.get("color")||(c.get("created_by")||e._USER_PLACEHOLDER(i.renkan)).get("color"))}).click(function(b){b.preventDefault(),i.renderer.isEditable()?(c.set("color",a(this).attr("data-color")),l.hide(),paper.view.draw()):j()});var m=function(a){if(i.renderer.isEditable()){var b=a+(c.get("size")||0);i.editor_$.find(".Rk-Edit-Size-Value").text((b>0?"+":"")+b),c.set("size",b),paper.view.draw()}else j()};this.editor_$.find(".Rk-Edit-Size-Down").click(function(){return m(-1),!1}),this.editor_$.find(".Rk-Edit-Size-Up").click(function(){return m(1),!1})}else if("object"==typeof this.source_representation.highlighted){var n=this.source_representation.highlighted.replace(b(c.get("title")).escape(),'<span class="Rk-Highlighted">$1</span>');this.editor_$.find(".Rk-Display-Title"+(c.get("uri")?" a":"")).html(n),this.options.show_node_tooltip_description&&this.editor_$.find(".Rk-Display-Description").html(this.source_representation.highlighted.replace(b(c.get("description")).escape(),'<span class="Rk-Highlighted">$1</span>'))}this.editor_$.find("img").load(function(){i.redraw()})},redraw:function(){var a=this.source_representation.paper_coords;e.drawEditBox(this.options,a,this.editor_block,.75*this.source_representation.circle_radius,this.editor_$),this.editor_$.show(),paper.view.draw()}}),f}),define("renderer/edgeeditor",["jquery","underscore","requtils","renderer/baseeditor"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({template:b.template('<h2><span class="Rk-CloseX">×</span><%-renkan.translate("Edit Edge")%></span></h2><p><label><%-renkan.translate("Title:")%></label><input class="Rk-Edit-Title" type="text" value="<%-edge.title%>"/></p><% if (options.show_edge_editor_uri) { %><p><label><%-renkan.translate("URI:")%></label><input class="Rk-Edit-URI" type="text" value="<%-edge.uri%>"/><a class="Rk-Edit-Goto" href="<%-edge.uri%>" target="_blank"></a></p><% if (options.properties.length) { %><p><label><%-renkan.translate("Choose from vocabulary:")%></label><select class="Rk-Edit-Vocabulary"><% _(options.properties).each(function(ontology) { %><option class="Rk-Edit-Vocabulary-Class" value=""><%- renkan.translate(ontology.label) %></option><% _(ontology.properties).each(function(property) { var uri = ontology["base-uri"] + property.uri; %><option class="Rk-Edit-Vocabulary-Property" value="<%- uri %>"<% if (uri === edge.uri) { %> selected<% } %>><%- renkan.translate(property.label) %></option><% }) %><% }) %></select></p><% } } %><% if (options.show_edge_editor_color) { %><div class="Rk-Editor-p"><span class="Rk-Editor-Label"><%-renkan.translate("Edge color:")%></span><div class="Rk-Edit-ColorPicker-Wrapper"><span class="Rk-Edit-Color" style="background:<%-edge.color%>;"><span class="Rk-Edit-ColorTip"></span></span><%= renkan.colorPicker %><span class="Rk-Edit-ColorPicker-Text"><%- renkan.translate("Choose color") %></span></div></div><% } %><% if (options.show_edge_editor_direction) { %><p><span class="Rk-Edit-Direction"><%- renkan.translate("Change edge direction") %></span></p><% } %><% if (options.show_edge_editor_nodes) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("From:")%></span><span class="Rk-UserColor" style="background:<%-edge.from_color%>;"></span><%- shortenText(edge.from_title, 25) %></p><p><span class="Rk-Editor-Label"><%-renkan.translate("To:")%></span><span class="Rk-UserColor" style="background:<%-edge.to_color%>;"></span><%- shortenText(edge.to_title, 25) %></p><% } %><% if (options.show_edge_editor_creator && edge.has_creator) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Created by:")%></span><span class="Rk-UserColor" style="background:<%-edge.created_by_color%>;"></span><%- shortenText(edge.created_by_title, 25) %></p><% } %>'),readOnlyTemplate:b.template('<h2><span class="Rk-CloseX">×</span><% if (options.show_edge_tooltip_color) { %><span class="Rk-UserColor" style="background:<%-edge.color%>;"></span><% } %><span class="Rk-Display-Title"><% if (edge.uri) { %><a href="<%-edge.uri%>" target="_blank"><% } %><%-edge.title%><% if (edge.uri) { %></a><% } %></span></h2><% if (options.show_edge_tooltip_uri && edge.uri) { %><p class="Rk-Display-URI"><a href="<%-edge.uri%>" target="_blank"><%-edge.short_uri%></a></p><% } %><p><%-edge.description%></p><% if (options.show_edge_tooltip_nodes) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("From:")%></span><span class="Rk-UserColor" style="background:<%-edge.from_color%>;"></span><%- shortenText(edge.from_title, 25) %></p><p><span class="Rk-Editor-Label"><%-renkan.translate("To:")%></span><span class="Rk-UserColor" style="background:<%-edge.to_color%>;"></span><%- shortenText(edge.to_title, 25) %></p><% } %><% if (options.show_edge_tooltip_creator && edge.has_creator) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Created by:")%></span><span class="Rk-UserColor" style="background:<%-edge.created_by_color%>;"></span><%- shortenText(edge.created_by_title, 25) %></p><% } %>'),draw:function(){var c=this.source_representation.model,d=c.get("from"),f=c.get("to"),g=c.get("created_by")||e._USER_PLACEHOLDER(this.renkan),h=this.renderer.isEditable()?this.template:this.readOnlyTemplate;
+this.editor_$.html(h({edge:{has_creator:!!c.get("created_by"),title:c.get("title"),uri:c.get("uri"),short_uri:e.shortenText((c.get("uri")||"").replace(/^(https?:\/\/)?(www\.)?/,"").replace(/\/$/,""),40),description:c.get("description"),color:c.get("color")||g.get("color"),from_title:d.get("title"),to_title:f.get("title"),from_color:d.get("color")||(d.get("created_by")||e._USER_PLACEHOLDER(this.renkan)).get("color"),to_color:f.get("color")||(f.get("created_by")||e._USER_PLACEHOLDER(this.renkan)).get("color"),created_by_color:g.get("color"),created_by_title:g.get("title")},renkan:this.renkan,shortenText:e.shortenText,options:this.options})),this.redraw();var i=this,j=function(){i.renderer.removeRepresentation(i),paper.view.draw()};if(this.editor_$.find(".Rk-CloseX").click(j),this.editor_$.find(".Rk-Edit-Goto").click(function(){return c.get("uri")?void 0:!1}),this.renderer.isEditable()){var k=b(function(){b(function(){if(i.renderer.isEditable()){var a={title:i.editor_$.find(".Rk-Edit-Title").val()};i.options.show_edge_editor_uri&&(a.uri=i.editor_$.find(".Rk-Edit-URI").val()),i.editor_$.find(".Rk-Edit-Goto").attr("href",a.uri||"#"),c.set(a),paper.view.draw()}else j()}).defer()}).throttle(500);this.editor_$.on("keyup",function(a){27===a.keyCode&&j()}),this.editor_$.find("input").on("keyup change paste",k),this.editor_$.find(".Rk-Edit-Vocabulary").change(function(){var b=a(this),c=b.val();c&&(i.editor_$.find(".Rk-Edit-Title").val(b.find(":selected").text()),i.editor_$.find(".Rk-Edit-URI").val(c),k())}),this.editor_$.find(".Rk-Edit-Direction").click(function(){i.renderer.isEditable()?(c.set({from:c.get("to"),to:c.get("from")}),i.draw()):j()});var l=i.editor_$.find(".Rk-Edit-ColorPicker");this.editor_$.find(".Rk-Edit-ColorPicker-Wrapper").hover(function(a){a.preventDefault(),l.show()},function(a){a.preventDefault(),l.hide()}),l.find("li").hover(function(b){b.preventDefault(),i.editor_$.find(".Rk-Edit-Color").css("background",a(this).attr("data-color"))},function(a){a.preventDefault(),i.editor_$.find(".Rk-Edit-Color").css("background",c.get("color")||(c.get("created_by")||e._USER_PLACEHOLDER(i.renkan)).get("color"))}).click(function(b){b.preventDefault(),i.renderer.isEditable()?(c.set("color",a(this).attr("data-color")),l.hide(),paper.view.draw()):j()})}},redraw:function(){var a=this.source_representation.paper_coords;e.drawEditBox(this.options,a,this.editor_block,5,this.editor_$),this.editor_$.show(),paper.view.draw()}}),f}),define("renderer/nodebutton",["jquery","underscore","requtils","renderer/basebutton"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({setSectorSize:function(){var a=this.source_representation.circle_radius;a!==this.lastSectorInner&&(this.sector&&this.sector.destroy(),this.sector=this.renderer.drawSector(this,1+a,e._NODE_BUTTON_WIDTH+a,this.startAngle,this.endAngle,1,this.imageName,this.renkan.translate(this.text)),this.lastSectorInner=a)}}),f}),define("renderer/nodeeditbutton",["jquery","underscore","requtils","renderer/nodebutton"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({_init:function(){this.type="Node-edit-button",this.lastSectorInner=0,this.startAngle=-135,this.endAngle=-45,this.imageName="edit",this.text="Edit"},mouseup:function(){this.renderer.is_dragging||this.source_representation.openEditor()}}),f}),define("renderer/noderemovebutton",["jquery","underscore","requtils","renderer/nodebutton"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({_init:function(){this.type="Node-remove-button",this.lastSectorInner=0,this.startAngle=0,this.endAngle=90,this.imageName="remove",this.text="Remove"},mouseup:function(){if(this.renderer.click_target=null,this.renderer.is_dragging=!1,this.renderer.removeRepresentationsOfType("editor"),this.renderer.isEditable())if(this.options.element_delete_delay){var a=e.getUID("delete");this.renderer.delete_list.push({id:a,time:(new Date).valueOf()+this.options.element_delete_delay}),this.source_representation.model.set("delete_scheduled",a)}else confirm(this.renkan.translate("Do you really wish to remove node ")+'"'+this.source_representation.model.get("title")+'"?')&&this.project.removeNode(this.source_representation.model)}}),f}),define("renderer/noderevertbutton",["jquery","underscore","requtils","renderer/nodebutton"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({_init:function(){this.type="Node-revert-button",this.lastSectorInner=0,this.startAngle=-135,this.endAngle=135,this.imageName="revert",this.text="Cancel deletion"},mouseup:function(){this.renderer.click_target=null,this.renderer.is_dragging=!1,this.renderer.isEditable()&&this.source_representation.model.unset("delete_scheduled")}}),f}),define("renderer/nodelinkbutton",["jquery","underscore","requtils","renderer/nodebutton"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({_init:function(){this.type="Node-link-button",this.lastSectorInner=0,this.startAngle=90,this.endAngle=180,this.imageName="link",this.text="Link to another node"},mousedown:function(a){if(this.renderer.isEditable()){var b=this.renderer.canvas_$.offset(),c=new paper.Point([a.pageX-b.left,a.pageY-b.top]);this.renderer.click_target=null,this.renderer.removeRepresentationsOfType("editor"),this.renderer.addTempEdge(this.source_representation,c)}}}),f}),define("renderer/nodeenlargebutton",["jquery","underscore","requtils","renderer/nodebutton"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({_init:function(){this.type="Node-enlarge-button",this.lastSectorInner=0,this.startAngle=-45,this.endAngle=0,this.imageName="enlarge",this.text="Enlarge"},mouseup:function(){var a=1+(this.source_representation.model.get("size")||0);this.source_representation.model.set("size",a),this.source_representation.select(),this.select(),paper.view.draw()}}),f}),define("renderer/nodeshrinkbutton",["jquery","underscore","requtils","renderer/nodebutton"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({_init:function(){this.type="Node-shrink-button",this.lastSectorInner=0,this.startAngle=-180,this.endAngle=-135,this.imageName="shrink",this.text="Shrink"},mouseup:function(){var a=-1+(this.source_representation.model.get("size")||0);this.source_representation.model.set("size",a),this.source_representation.select(),this.select(),paper.view.draw()}}),f}),define("renderer/edgeeditbutton",["jquery","underscore","requtils","renderer/basebutton"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({_init:function(){this.type="Edge-edit-button",this.sector=this.renderer.drawSector(this,e._EDGE_BUTTON_INNER,e._EDGE_BUTTON_OUTER,-270,-90,1,"edit",this.renkan.translate("Edit"))},mouseup:function(){this.renderer.is_dragging||this.source_representation.openEditor()}}),f}),define("renderer/edgeremovebutton",["jquery","underscore","requtils","renderer/basebutton"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({_init:function(){this.type="Edge-remove-button",this.sector=this.renderer.drawSector(this,e._EDGE_BUTTON_INNER,e._EDGE_BUTTON_OUTER,-90,90,1,"remove",this.renkan.translate("Remove"))},mouseup:function(){if(this.renderer.click_target=null,this.renderer.is_dragging=!1,this.renderer.removeRepresentationsOfType("editor"),this.renderer.isEditable())if(this.options.element_delete_delay){var a=e.getUID("delete");this.renderer.delete_list.push({id:a,time:(new Date).valueOf()+this.options.element_delete_delay}),this.source_representation.model.set("delete_scheduled",a)}else confirm(this.renkan.translate("Do you really wish to remove edge ")+'"'+this.source_representation.model.get("title")+'"?')&&this.project.removeEdge(this.source_representation.model)}}),f}),define("renderer/edgerevertbutton",["jquery","underscore","requtils","renderer/basebutton"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({_init:function(){this.type="Edge-revert-button",this.sector=this.renderer.drawSector(this,e._EDGE_BUTTON_INNER,e._EDGE_BUTTON_OUTER,-135,135,1,"revert",this.renkan.translate("Cancel deletion"))},mouseup:function(){this.renderer.click_target=null,this.renderer.is_dragging=!1,this.renderer.isEditable()&&this.source_representation.model.unset("delete_scheduled")}}),f}),define("renderer/miniframe",["jquery","underscore","requtils","renderer/baserepresentation"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({paperShift:function(a){this.renderer.offset=this.renderer.offset.subtract(a.divide(this.renderer.minimap.scale).multiply(this.renderer.scale)),this.renderer.redraw()},mouseup:function(){this.renderer.click_target=null,this.renderer.is_dragging=!1}}),f}),define("renderer/scene",["jquery","underscore","filesaver","requtils","renderer/miniframe"],function(a,b,c,d,e){var f=d.getUtils(),g=function(c){this.renkan=c,this.$=a(".Rk-Render"),this.representations=[],this.$.html(this.template(c)),this.onStatusChange(),this.canvas_$=this.$.find(".Rk-Canvas"),this.labels_$=this.$.find(".Rk-Labels"),this.editor_$=this.$.find(".Rk-Editor"),this.notif_$=this.$.find(".Rk-Notifications"),paper.setup(this.canvas_$[0]),this.scale=1,this.initialScale=1,this.offset=paper.view.center,this.totalScroll=0,this.mouse_down=!1,this.click_target=null,this.selected_target=null,this.edge_layer=new paper.Layer,this.node_layer=new paper.Layer,this.buttons_layer=new paper.Layer,this.delete_list=[],this.redrawActive=!0,c.options.show_minimap&&(this.minimap={background_layer:new paper.Layer,edge_layer:new paper.Layer,node_layer:new paper.Layer,node_group:new paper.Group,size:new paper.Size(c.options.minimap_width,c.options.minimap_height)},this.minimap.background_layer.activate(),this.minimap.topleft=paper.view.bounds.bottomRight.subtract(this.minimap.size),this.minimap.rectangle=new paper.Path.Rectangle(this.minimap.topleft.subtract([2,2]),this.minimap.size.add([4,4])),this.minimap.rectangle.fillColor=c.options.minimap_background_color,this.minimap.rectangle.strokeColor=c.options.minimap_border_color,this.minimap.rectangle.strokeWidth=4,this.minimap.offset=new paper.Point(this.minimap.size.divide(2)),this.minimap.scale=.1,this.minimap.node_layer.activate(),this.minimap.cliprectangle=new paper.Path.Rectangle(this.minimap.topleft,this.minimap.size),this.minimap.node_group.addChild(this.minimap.cliprectangle),this.minimap.node_group.clipped=!0,this.minimap.miniframe=new paper.Path.Rectangle(this.minimap.topleft,this.minimap.size),this.minimap.node_group.addChild(this.minimap.miniframe),this.minimap.miniframe.fillColor="#c0c0ff",this.minimap.miniframe.opacity=.3,this.minimap.miniframe.strokeColor="#000080",this.minimap.miniframe.strokeWidth=3,this.minimap.miniframe.__representation=new e(this,null)),this.throttledPaperDraw=b(function(){paper.view.draw()}).throttle(100),this.bundles=[],this.click_mode=!1;var d=this,g=!0,h=1,i=!1,j=0,k=0;this.image_cache={},this.icon_cache={},["edit","remove","link","enlarge","shrink","revert"].forEach(function(a){var b=new Image;b.src=c.options.static_url+"img/"+a+".png",d.icon_cache[a]=b});var l=b.throttle(function(a,b){d.onMouseMove(a,b)},f._MOUSEMOVE_RATE);this.canvas_$.on({mousedown:function(a){a.preventDefault(),d.onMouseDown(a,!1)},mousemove:function(a){a.preventDefault(),l(a,!1)},mouseup:function(a){a.preventDefault(),d.onMouseUp(a,!1)},mousewheel:function(a,b){c.options.zoom_on_scroll&&(a.preventDefault(),g&&d.onScroll(a,b))},touchstart:function(a){a.preventDefault();var b=a.originalEvent.touches[0];c.options.allow_double_click&&new Date-_lastTap<f._DOUBLETAP_DELAY&&Math.pow(j-b.pageX,2)+Math.pow(k-b.pageY,2)<f._DOUBLETAP_DISTANCE?(_lastTap=0,d.onDoubleClick(b)):(_lastTap=new Date,j=b.pageX,k=b.pageY,h=d.scale,i=!1,d.onMouseDown(b,!0))},touchmove:function(a){if(a.preventDefault(),_lastTap=0,1===a.originalEvent.touches.length)d.onMouseMove(a.originalEvent.touches[0],!0);else{if(i||(d.onMouseUp(a.originalEvent.touches[0],!0),d.click_target=null,d.is_dragging=!1,i=!0),"undefined"===a.originalEvent.scale)return;var b=a.originalEvent.scale*h,c=b/d.scale,e=new paper.Point([d.canvas_$.width(),d.canvas_$.height()]).multiply(.5*(1-c)).add(d.offset.multiply(c));d.setScale(b,e)}},touchend:function(a){a.preventDefault(),d.onMouseUp(a.originalEvent.changedTouches[0],!0)},dblclick:function(a){a.preventDefault(),c.options.allow_double_click&&d.onDoubleClick(a)},mouseleave:function(a){a.preventDefault(),d.onMouseUp(a,!1),d.click_target=null,d.is_dragging=!1},dragover:function(a){a.preventDefault()},dragenter:function(a){a.preventDefault(),g=!1},dragleave:function(a){a.preventDefault(),g=!0},drop:function(a){a.preventDefault(),g=!0;var c={};b(a.originalEvent.dataTransfer.types).each(function(b){try{c[b]=a.originalEvent.dataTransfer.getData(b)}catch(d){}});var e=a.originalEvent.dataTransfer.getData("Text");if("string"==typeof e)switch(e[0]){case"{":case"[":try{var f=JSON.parse(e);b(c).extend(f)}catch(h){c["text/plain"]||(c["text/plain"]=e)}break;case"<":c["text/html"]||(c["text/html"]=e);break;default:c["text/plain"]||(c["text/plain"]=e)}var i=a.originalEvent.dataTransfer.getData("URL");i&&!c["text/uri-list"]&&(c["text/uri-list"]=i),d.dropData(c,a.originalEvent)}});var m=function(a,b){d.$.find(a).click(function(a){return d[b](a),!1})};m(".Rk-ZoomOut","zoomOut"),m(".Rk-ZoomIn","zoomIn"),m(".Rk-ZoomFit","autoScale"),this.$.find(".Rk-ZoomSave").click(function(){d.renkan.project.addView({zoom_level:d.scale,offset:d.offset})}),this.$.find(".Rk-ZoomSetSaved").click(function(){var a=d.renkan.project.get("views").last();a&&d.setScale(a.get("zoom_level"),new paper.Point(a.get("offset")))}),this.renkan.read_only&&!isNaN(parseInt(this.renkan.options.default_view))&&this.$.find(".Rk-ZoomSetSaved").show(),this.$.find(".Rk-CurrentUser").mouseenter(function(){d.$.find(".Rk-UserList").slideDown()}),this.$.find(".Rk-Users").mouseleave(function(){d.$.find(".Rk-UserList").slideUp()}),m(".Rk-FullScreen-Button","fullScreen"),m(".Rk-AddNode-Button","addNodeBtn"),m(".Rk-AddEdge-Button","addEdgeBtn"),m(".Rk-Save-Button","save"),m(".Rk-Open-Button","open"),m(".Rk-Export-Button","exportProject"),this.$.find(".Rk-Bookmarklet-Button").attr("href","javascript:"+f._BOOKMARKLET_CODE(c)).click(function(){return d.notif_$.text(c.translate("Drag this button to your bookmark bar. When on a third-party website, click it to enable drag-and-drop from the website to Renkan.")).fadeIn().delay(5e3).fadeOut(),!1}),this.$.find(".Rk-TopBar-Button").mouseover(function(){a(this).find(".Rk-TopBar-Tooltip").show()}).mouseout(function(){a(this).find(".Rk-TopBar-Tooltip").hide()}),m(".Rk-Fold-Bins","foldBins"),paper.view.onResize=function(a){paper.view._viewSize.height=a.size.height=d.canvas_$.parent().height(),d.minimap&&(d.minimap.topleft=paper.view.bounds.bottomRight.subtract(d.minimap.size),d.minimap.rectangle.fitBounds(d.minimap.topleft.subtract([2,2]),d.minimap.size.add([4,4])),d.minimap.cliprectangle.fitBounds(d.minimap.topleft,d.minimap.size)),d.redraw()};var n=b.throttle(function(){d.redraw()},50);this.addRepresentations("Node",this.renkan.project.get("nodes")),this.addRepresentations("Edge",this.renkan.project.get("edges")),this.renkan.project.on("change:title",function(){d.$.find(".Rk-PadTitle").val(c.project.get("title"))}),this.$.find(".Rk-PadTitle").on("keyup input paste",function(){c.project.set({title:a(this).val()})});var o=b.throttle(function(){d.redrawUsers()},100);if(o(),this.renkan.project.on("add:users remove:users",o),this.renkan.project.on("add:views remove:views",function(){d.renkan.project.get("views").length>0?d.$.find(".Rk-ZoomSetSaved").show():d.$.find(".Rk-ZoomSetSaved").hide()}),this.renkan.project.on("add:nodes",function(a){d.addRepresentation("Node",a),n()}),this.renkan.project.on("add:edges",function(a){d.addRepresentation("Edge",a),n()}),this.renkan.project.on("change:title",function(a,b){var c=d.$.find(".Rk-PadTitle");c.is("input")?c.val()!==b&&c.val(b):c.text(b)}),c.options.size_bug_fix){var p="number"==typeof c.options.size_bug_fix?c.options.size_bug_fix:500;window.setTimeout(function(){d.fixSize(!0)},p)}if(c.options.force_resize&&a(window).resize(function(){d.fixSize(!1)}),c.options.show_user_list&&c.options.user_color_editable){var q=this.$.find(".Rk-Users .Rk-Edit-ColorPicker-Wrapper"),r=this.$.find(".Rk-Users .Rk-Edit-ColorPicker");q.hover(function(a){d.isEditable()&&(a.preventDefault(),r.show())},function(a){a.preventDefault(),r.hide()}),r.find("li").mouseenter(function(b){d.isEditable()&&(b.preventDefault(),d.$.find(".Rk-CurrentUser-Color").css("background",a(this).attr("data-color")))})}if(c.options.show_search_field){var s="";this.$.find(".Rk-GraphSearch-Field").on("keyup change paste input",function(){var b=a(this),e=b.val();if(e!==s)if(s=e,e.length<2)c.project.get("nodes").each(function(a){d.getRepresentationByModel(a).unhighlight()});else{var g=f.regexpFromTextOrArray(e);c.project.get("nodes").each(function(a){g.test(a.get("title"))||g.test(a.get("description"))?d.getRepresentationByModel(a).highlight(g):d.getRepresentationByModel(a).unhighlight()})}})}this.redraw(),window.setInterval(function(){var a=(new Date).valueOf();d.delete_list.forEach(function(b){if(a>=b.time){var d=c.project.get("nodes").findWhere({delete_scheduled:b.id});d&&project.removeNode(d),d=c.project.get("edges").findWhere({delete_scheduled:b.id}),d&&project.removeEdge(d)}}),d.delete_list=d.delete_list.filter(function(a){return c.project.get("nodes").findWhere({delete_scheduled:a.id})||c.project.get("edges").findWhere({delete_scheduled:a.id})})},500),this.minimap&&window.setInterval(function(){d.rescaleMinimap()},2e3)};return b(g.prototype).extend({template:b.template('<% if (options.show_top_bar) { %><div class="Rk-TopBar"><% if (!options.editor_mode) { %><h2 class="Rk-PadTitle"><%- project.get("title") || translate("Untitled project")%></h2><% } else { %><input type="text" class="Rk-PadTitle" value="<%- project.get("title") || "" %>" placeholder="<%-translate("Untitled project")%>" /><% } %><% if (options.show_user_list) { %><div class="Rk-Users"><div class="Rk-CurrentUser"><div class="Rk-Edit-ColorPicker-Wrapper"><span class="Rk-CurrentUser-Color"><% if (options.user_color_editable) { %><span class="Rk-Edit-ColorTip"></span><% } %></span><% if (options.user_color_editable) { print(colorPicker) } %></div><span class="Rk-CurrentUser-Name"><unknown user></span></div><ul class="Rk-UserList"></ul></div><% } %><% if (options.home_button_url) {%><div class="Rk-TopBar-Separator"></div><a class="Rk-TopBar-Button Rk-Home-Button" href="<%- options.home_button_url %>"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents"><%- translate(options.home_button_title) %></div></div></a><% } %><% if (options.show_fullscreen_button) { %><div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-FullScreen-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents"><%-translate("Full Screen")%></div></div></div><% } %><% if (options.editor_mode) { %><% if (options.show_addnode_button) { %><div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-AddNode-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents"><%-translate("Add Node")%></div></div></div><% } %><% if (options.show_addedge_button) { %><div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-AddEdge-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents"><%-translate("Add Edge")%></div></div></div><% } %><% if (options.show_export_button) { %><div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-Export-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents"><%-translate("Download Project")%></div></div></div><% } %><% if (options.show_save_button) { %><div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-Save-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents"> </div></div></div><% } %><% if (options.show_open_button) { %><div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-Open-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents"><%-translate("Open Project")%></div></div></div><% } %><% if (options.show_bookmarklet) { %><div class="Rk-TopBar-Separator"></div><a class="Rk-TopBar-Button Rk-Bookmarklet-Button" href="#"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents"><%-translate("Renkan \'Drag-to-Add\' bookmarklet")%></div></div></a><% } %><% } else { %><% if (options.show_export_button) { %><div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-Export-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents"><%-translate("Download Project")%></div></div></div><div class="Rk-TopBar-Separator"></div><% } %><% };if (options.show_search_field) { %><form action="#" class="Rk-GraphSearch-Form"><input type="search" class="Rk-GraphSearch-Field" placeholder="<%- translate("Search in graph") %>" /></form><div class="Rk-TopBar-Separator"></div><% } %></div><% } %><div class="Rk-Editing-Space<% if (!options.show_top_bar) { %> Rk-Editing-Space-Full<% } %>"><div class="Rk-Labels"></div><canvas class="Rk-Canvas" resize></canvas><div class="Rk-Notifications"></div><div class="Rk-Editor"><% if (options.show_bins) { %><div class="Rk-Fold-Bins">«</div><% } %><div class="Rk-ZoomButtons"><div class="Rk-ZoomIn" title="<%-translate("Zoom In")%>"></div><div class="Rk-ZoomFit" title="<%-translate("Zoom Fit")%>"></div><div class="Rk-ZoomOut" title="<%-translate("Zoom Out")%>"></div><% if (options.editor_mode) { %><div class="Rk-ZoomSave" title="<%-translate("Zoom Save")%>"></div><% } %><% if (options.editor_mode || !isNaN(parseInt(options.default_view))) { %><div class="Rk-ZoomSetSaved" title="<%-translate("View saved zoom")%>"></div><% } %></div></div></div>'),fixSize:function(a){var b=this.$.width(),c=this.$.height();this.renkan.options.show_top_bar&&(c-=this.$.find(".Rk-TopBar").height()),this.canvas_$.attr({width:b,height:c}),paper.view.viewSize=new paper.Size([b,c]),a&&(this.renkan.read_only&&!isNaN(parseInt(this.renkan.options.default_view))?this.autoScale(this.renkan.project.get("views")[parseInt(this.renkan.options.default_view)]):this.autoScale())},drawSector:function(b,c,d,e,f,g,h,i){var j=this.renkan.options,k=e*Math.PI/180,l=f*Math.PI/180,m=this.icon_cache[h],n=-Math.sin(k),o=Math.cos(k),p=Math.cos(k)*c+g*n,q=Math.sin(k)*c+g*o,r=Math.cos(k)*d+g*n,s=Math.sin(k)*d+g*o,t=-Math.sin(l),u=Math.cos(l),v=Math.cos(l)*c-g*t,w=Math.sin(l)*c-g*u,x=Math.cos(l)*d-g*t,y=Math.sin(l)*d-g*u,z=(c+d)/2,A=(k+l)/2,B=Math.cos(A)*z,C=Math.sin(A)*z,D=Math.cos(A)*c,E=Math.cos(A)*d,F=Math.sin(A)*c,G=Math.sin(A)*d,H=Math.cos(A)*(d+3),I=Math.sin(A)*(d+j.buttons_label_font_size)+j.buttons_label_font_size/2;this.buttons_layer.activate();var J=new paper.Path;J.add([p,q]),J.arcTo([D,F],[v,w]),J.lineTo([x,y]),J.arcTo([E,G],[r,s]),J.fillColor=j.buttons_background,J.opacity=.5,J.closed=!0,J.__representation=b;var K=new paper.PointText(H,I);K.characterStyle={fontSize:j.buttons_label_font_size,fillColor:j.buttons_label_color},K.paragraphStyle.justification=H>2?"left":-2>H?"right":"center",K.visible=!1;var L=!1,M=new paper.Point(-200,-200),N=new paper.Group([J,K]),O=N.position,P=new paper.Point([B,C]),Q=new paper.Point(0,0);K.content=i,N.visible=!1,N.position=M;var R={show:function(){L=!0,N.position=Q.add(O),N.visible=!0},moveTo:function(a){Q=a,L&&(N.position=a.add(O))},hide:function(){L=!1,N.visible=!1,N.position=M},select:function(){J.opacity=.8,K.visible=!0},unselect:function(){J.opacity=.5,K.visible=!1},destroy:function(){N.remove()}},S=function(){var a=new paper.Raster(m);a.position=P.add(N.position).subtract(O),a.locked=!0,N.addChild(a)};return m.width?S():a(m).on("load",S),R},addToBundles:function(a){var c=b(this.bundles).find(function(b){return b.from===a.from_representation&&b.to===a.to_representation||b.from===a.to_representation&&b.to===a.from_representation});return"undefined"!=typeof c?c.edges.push(a):(c={from:a.from_representation,to:a.to_representation,edges:[a],getPosition:function(a){var c=a.from_representation===this.from?1:-1;return c*(b(this.edges).indexOf(a)-(this.edges.length-1)/2)}},this.bundles.push(c)),c},isEditable:function(){return this.renkan.options.editor_mode&&!this.renkan.read_only},onStatusChange:function(){var a=this.$.find(".Rk-Save-Button"),b=a.find(".Rk-TopBar-Tooltip-Contents");this.renkan.read_only?(a.removeClass("disabled Rk-Save-Online").addClass("Rk-Save-ReadOnly"),b.text(this.renkan.translate("Connection lost"))):this.renkan.options.manual_save?(a.removeClass("Rk-Save-ReadOnly Rk-Save-Online"),b.text(this.renkan.translate("Save Project"))):(a.removeClass("disabled Rk-Save-ReadOnly").addClass("Rk-Save-Online"),b.text(this.renkan.translate("Auto-save enabled"))),this.redrawUsers()},setScale:function(a,b){a/this.initialScale>f._MIN_SCALE&&a/this.initialScale<f._MAX_SCALE&&(this.scale=a,b&&(this.offset=b),this.redraw())},autoScale:function(a){var b=this.renkan.project.get("nodes");if(b.length>1){var c=b.map(function(a){return a.get("position").x}),d=b.map(function(a){return a.get("position").y}),e=Math.min.apply(Math,c),f=Math.min.apply(Math,d),g=Math.max.apply(Math,c),h=Math.max.apply(Math,d),i=Math.min((paper.view.size.width-2*this.renkan.options.autoscale_padding)/(g-e),(paper.view.size.height-2*this.renkan.options.autoscale_padding)/(h-f));this.initialScale=i,"undefined"!=typeof a&&parseFloat(a.zoom_level)>0&&parseFloat(a.offset.x)>0&&parseFloat(a.offset.y)>0?this.setScale(parseFloat(a.zoom_level),new paper.Point(parseFloat(a.offset.x),parseFloat(a.offset.y))):this.setScale(i,paper.view.center.subtract(new paper.Point([(g+e)/2,(h+f)/2]).multiply(i)))}1===b.length&&this.setScale(1,paper.view.center.subtract(new paper.Point([b.at(0).get("position").x,b.at(0).get("position").y])))},redrawMiniframe:function(){var a=this.toMinimapCoords(this.toModelCoords(new paper.Point([0,0]))),b=this.toMinimapCoords(this.toModelCoords(paper.view.bounds.bottomRight));this.minimap.miniframe.fitBounds(a,b)},rescaleMinimap:function(){var a=this.renkan.project.get("nodes");if(a.length>1){var b=a.map(function(a){return a.get("position").x}),c=a.map(function(a){return a.get("position").y}),d=Math.min.apply(Math,b),e=Math.min.apply(Math,c),f=Math.max.apply(Math,b),g=Math.max.apply(Math,c),h=Math.min(.8*this.scale*this.renkan.options.minimap_width/paper.view.bounds.width,.8*this.scale*this.renkan.options.minimap_height/paper.view.bounds.height,(this.renkan.options.minimap_width-2*this.renkan.options.minimap_padding)/(f-d),(this.renkan.options.minimap_height-2*this.renkan.options.minimap_padding)/(g-e));this.minimap.offset=this.minimap.size.divide(2).subtract(new paper.Point([(f+d)/2,(g+e)/2]).multiply(h)),this.minimap.scale=h}1===a.length&&(this.minimap.scale=.1,this.minimap.offset=this.minimap.size.divide(2).subtract(new paper.Point([a.at(0).get("position").x,a.at(0).get("position").y]).multiply(this.minimap.scale))),this.redraw()},toPaperCoords:function(a){return a.multiply(this.scale).add(this.offset)},toMinimapCoords:function(a){return a.multiply(this.minimap.scale).add(this.minimap.offset).add(this.minimap.topleft)},toModelCoords:function(a){return a.subtract(this.offset).divide(this.scale)},addRepresentation:function(a,b){var c=d.getRenderer()[a],e=new c(this,b);return this.representations.push(e),e},addRepresentations:function(a,b){var c=this;b.forEach(function(b){c.addRepresentation(a,b)})},userTemplate:b.template('<li class="Rk-User"><span class="Rk-UserColor" style="background:<%=background%>;"></span><%=name%></li>'),redrawUsers:function(){if(this.renkan.options.show_user_list){var b=[].concat((this.renkan.project.current_user_list||{}).models||[],(this.renkan.project.get("users")||{}).models||[]),c="",d=this.$.find(".Rk-Users"),e=d.find(".Rk-CurrentUser-Name"),f=d.find(".Rk-Edit-ColorPicker li"),g=d.find(".Rk-CurrentUser-Color"),h=this;e.off("click").text(this.renkan.translate("<unknown user>")),f.off("mouseleave click"),b.forEach(function(b){b.get("_id")===h.renkan.current_user?(e.text(b.get("title")),g.css("background",b.get("color")),h.isEditable()&&(h.renkan.options.user_name_editable&&e.click(function(){var c=a(this),d=a("<input>").val(b.get("title")).blur(function(){b.set("title",a(this).val()),h.redrawUsers(),h.redraw()});c.empty().html(d),d.select()}),h.renkan.options.user_color_editable&&f.click(function(c){c.preventDefault(),h.isEditable()&&b.set("color",a(this).attr("data-color")),a(this).parent().hide()}).mouseleave(function(){g.css("background",b.get("color"))}))):c+=h.userTemplate({name:b.get("title"),background:b.get("color")})}),d.find(".Rk-UserList").html(c)}},removeRepresentation:function(a){a.destroy(),this.representations=b(this.representations).reject(function(b){return b===a})},getRepresentationByModel:function(a){return a?b(this.representations).find(function(b){return b.model===a}):void 0},removeRepresentationsOfType:function(a){var c=b(this.representations).filter(function(b){return b.type===a}),d=this;b(c).each(function(a){d.removeRepresentation(a)})},highlightModel:function(a){var b=this.getRepresentationByModel(a);b&&b.highlight()},unhighlightAll:function(){b(this.representations).each(function(a){a.unhighlight()})},unselectAll:function(){b(this.representations).each(function(a){a.unselect()})},redraw:function(){this.redrawActive&&(b(this.representations).each(function(a){a.redraw(!0)}),this.minimap&&this.redrawMiniframe(),paper.view.draw())},addTempEdge:function(a,b){var c=this.addRepresentation("TempEdge",null);c.end_pos=b,c.from_representation=a,c.redraw(),this.click_target=c},findTarget:function(a){if(a&&"undefined"!=typeof a.item.__representation){var b=a.item.__representation;this.selected_target!==a.item.__representation&&(this.selected_target&&this.selected_target.unselect(b),b.select(this.selected_target),this.selected_target=b)}else this.selected_target&&this.selected_target.unselect(),this.selected_target=null},paperShift:function(a){this.offset=this.offset.add(a),this.redraw()},onMouseMove:function(a){var b=this.canvas_$.offset(),c=new paper.Point([a.pageX-b.left,a.pageY-b.top]),d=c.subtract(this.last_point);this.last_point=c,!this.is_dragging&&this.mouse_down&&d.length>f._MIN_DRAG_DISTANCE&&(this.is_dragging=!0);var e=paper.project.hitTest(c);this.is_dragging?this.click_target&&"function"==typeof this.click_target.paperShift?this.click_target.paperShift(d):this.paperShift(d):this.findTarget(e),paper.view.draw()},onMouseDown:function(b,c){var d=this.canvas_$.offset(),e=new paper.Point([b.pageX-d.left,b.pageY-d.top]);if(this.last_point=e,this.mouse_down=!0,!this.click_target||"Temp-edge"!==this.click_target.type){this.removeRepresentationsOfType("editor"),this.is_dragging=!1;var g=paper.project.hitTest(e);if(g&&"undefined"!=typeof g.item.__representation)this.click_target=g.item.__representation,this.click_target.mousedown(b,c);else if(this.click_target=null,this.isEditable()&&this.click_mode===f._CLICKMODE_ADDNODE){var h=this.toModelCoords(e),i={id:f.getUID("node"),created_by:this.renkan.current_user,position:{x:h.x,y:h.y}};_node=this.renkan.project.addNode(i),this.getRepresentationByModel(_node).openEditor()}}this.click_mode&&(this.isEditable()&&this.click_mode===f._CLICKMODE_STARTEDGE&&this.click_target&&"Node"===this.click_target.type?(this.removeRepresentationsOfType("editor"),this.addTempEdge(this.click_target,e),this.click_mode=f._CLICKMODE_ENDEDGE,this.notif_$.fadeOut(function(){a(this).html(this.renkan.translate("Click on a second node to complete the edge")).fadeIn()})):(this.notif_$.hide(),this.click_mode=!1)),paper.view.draw()},onMouseUp:function(a,b){if(this.mouse_down=!1,this.click_target){var c=this.canvas_$.offset();this.click_target.mouseup({point:new paper.Point([a.pageX-c.left,a.pageY-c.top])},b)}else this.click_target=null,this.is_dragging=!1,b&&this.unselectAll();
+paper.view.draw()},onScroll:function(a,b){if(this.totalScroll+=b,Math.abs(this.totalScroll)>=1){var c=this.canvas_$.offset(),d=new paper.Point([a.pageX-c.left,a.pageY-c.top]).subtract(this.offset).multiply(Math.SQRT2-1);this.totalScroll>0?this.setScale(this.scale*Math.SQRT2,this.offset.subtract(d)):this.setScale(this.scale*Math.SQRT1_2,this.offset.add(d.divide(Math.SQRT2))),this.totalScroll=0}},onDoubleClick:function(a){if(this.isEditable()){var b=this.canvas_$.offset(),c=new paper.Point([a.pageX-b.left,a.pageY-b.top]),d=paper.project.hitTest(c);if(this.isEditable()&&(!d||"undefined"==typeof d.item.__representation)){var e=this.toModelCoords(c),g={id:f.getUID("node"),created_by:this.renkan.current_user,position:{x:e.x,y:e.y}},h=this.renkan.project.addNode(g);this.getRepresentationByModel(h).openEditor()}paper.view.draw()}},defaultDropHandler:function(b){var c={},d="";switch(b["text/x-iri-specific-site"]){case"twitter":d=a("<div>").html(b["text/x-iri-selected-html"]);var e=d.find(".tweet");c.title=this.renkan.translate("Tweet by ")+e.attr("data-name"),c.uri="http://twitter.com/"+e.attr("data-screen-name")+"/status/"+e.attr("data-tweet-id"),c.image=e.find(".avatar").attr("src"),c.description=e.find(".js-tweet-text:first").text();break;case"google":d=a("<div>").html(b["text/x-iri-selected-html"]),c.title=d.find("h3:first").text().trim(),c.uri=d.find("h3 a").attr("href"),c.description=d.find(".st:first").text().trim();break;default:b["text/x-iri-source-uri"]&&(c.uri=b["text/x-iri-source-uri"])}if((b["text/plain"]||b["text/x-iri-selected-text"])&&(c.description=(b["text/plain"]||b["text/x-iri-selected-text"]).replace(/[\s\n]+/gm," ").trim()),b["text/html"]||b["text/x-iri-selected-html"]){d=a("<div>").html(b["text/html"]||b["text/x-iri-selected-html"]);var f=d.find("image");f.length&&(c.image=f.attr("xlink:href"));var g=d.find("path");g.length&&(c.clipPath=g.attr("d"));var h=d.find("img");h.length&&(c.image=h[0].src);var i=d.find("a");i.length&&(c.uri=i[0].href),c.title=d.find("[title]").attr("title")||c.title,c.description=d.text().replace(/[\s\n]+/gm," ").trim()}b["text/uri-list"]&&(c.uri=b["text/uri-list"]),b["text/x-moz-url"]&&!c.title&&(c.title=(b["text/x-moz-url"].split("\n")[1]||"").trim(),c.title===c.uri&&(c.title=!1)),b["text/x-iri-source-title"]&&!c.title&&(c.title=b["text/x-iri-source-title"]),(b["text/html"]||b["text/x-iri-selected-html"])&&(d=a("<div>").html(b["text/html"]||b["text/x-iri-selected-html"]),c.image=d.find("[data-image]").attr("data-image")||c.image,c.uri=d.find("[data-uri]").attr("data-uri")||c.uri,c.title=d.find("[data-title]").attr("data-title")||c.title,c.description=d.find("[data-description]").attr("data-description")||c.description,c.clipPath=d.find("[data-clip-path]").attr("data-clip-path")||c.clipPath),c.title||(c.title=this.renkan.translate("Dragged resource"));for(var j=["title","description","uri","image"],k=0;k<j.length;k++){var l=j[k];(b["text/x-iri-"+l]||b[l])&&(c[l]=b["text/x-iri-"+l]||b[l]),("none"===c[l]||"null"===c[l])&&(c[l]=void 0)}return"function"==typeof this.renkan.options.drop_enhancer&&(c=this.renkan.options.drop_enhancer(c,b)),c},dropData:function(a,c){if(this.isEditable()){if(a["text/json"]||a["application/json"])try{var d=JSON.parse(a["text/json"]||a["application/json"]);b(a).extend(d)}catch(e){}var g="undefined"==typeof this.renkan.options.drop_handler?this.defaultDropHandler(a):this.renkan.options.drop_handler(a),h=this.canvas_$.offset(),i=new paper.Point([c.pageX-h.left,c.pageY-h.top]),j=this.toModelCoords(i),k={id:f.getUID("node"),created_by:this.renkan.current_user,uri:g.uri||"",title:g.title||"",description:g.description||"",image:g.image||"",color:g.color||void 0,clip_path:g.clipPath||void 0,position:{x:j.x,y:j.y}},l=this.renkan.project.addNode(k),m=this.getRepresentationByModel(l);"drop"===c.type&&m.openEditor()}},fullScreen:function(){var a,b=document.fullScreen||document.mozFullScreen||document.webkitIsFullScreen,c=this.renkan.$[0],d=["requestFullScreen","mozRequestFullScreen","webkitRequestFullScreen"],e=["cancelFullScreen","mozCancelFullScreen","webkitCancelFullScreen"];if(b){for(a=0;a<e.length;a++)if("function"==typeof document[e[a]]){document[e[a]]();break}}else for(a=0;a<d.length;a++)if("function"==typeof c[d[a]]){c[d[a]]();break}},zoomOut:function(){var a=this.scale*Math.SQRT1_2,b=new paper.Point([this.canvas_$.width(),this.canvas_$.height()]).multiply(.5*(1-Math.SQRT1_2)).add(this.offset.multiply(Math.SQRT1_2));this.setScale(a,b)},zoomIn:function(){var a=this.scale*Math.SQRT2,b=new paper.Point([this.canvas_$.width(),this.canvas_$.height()]).multiply(.5*(1-Math.SQRT2)).add(this.offset.multiply(Math.SQRT2));this.setScale(a,b)},addNodeBtn:function(){return this.click_mode===f._CLICKMODE_ADDNODE?(this.click_mode=!1,this.notif_$.hide()):(this.click_mode=f._CLICKMODE_ADDNODE,this.notif_$.text(this.renkan.translate("Click on the background canvas to add a node")).fadeIn()),!1},addEdgeBtn:function(){return this.click_mode===f._CLICKMODE_STARTEDGE||this.click_mode===f._CLICKMODE_ENDEDGE?(this.click_mode=!1,this.notif_$.hide()):(this.click_mode=f._CLICKMODE_STARTEDGE,this.notif_$.text(this.renkan.translate("Click on a first node to start the edge")).fadeIn()),!1},exportProject:function(){var a=this.renkan.project.toJSON(),d=(document.createElement("a"),a.id),e=d+".json";delete a.id,delete a._id,delete a.space_id;var g,h={};b.each(a.nodes,function(a){g=a.id||a._id,delete a._id,delete a.id,h[g]=a["@id"]=f.getUUID4()}),b.each(a.edges,function(a){delete a._id,delete a.id,a.to=h[a.to],a.from=h[a.from]}),b.each(a.views,function(a){g=a.id||a._id,delete a._id,delete a.id}),a.users=[];var i=JSON.stringify(a,null,2),j=new Blob([i],{type:"application/json;charset=utf-8"});c(j,e)},foldBins:function(){var a=this.$.find(".Rk-Fold-Bins"),b=this.renkan.$.find(".Rk-Bins"),c=this;b.offset().left<0?(b.animate({left:0},250),this.$.animate({left:300},250,function(){var a=c.$.width();paper.view.viewSize=new paper.Size([a,c.canvas_$.height()])}),a.html("«")):(b.animate({left:-300},250),this.$.animate({left:0},250,function(){var a=c.$.width();paper.view.viewSize=new paper.Size([a,c.canvas_$.height()])}),a.html("»"))},save:function(){},open:function(){}}),g}),"function"==typeof require.config&&require.config({paths:{jquery:"../lib/jquery.min",underscore:"../lib/underscore-min",filesaver:"../lib/FileSaver",requtils:"require-utils"}}),require(["renderer/baserepresentation","renderer/basebutton","renderer/noderepr","renderer/edge","renderer/tempedge","renderer/baseeditor","renderer/nodeeditor","renderer/edgeeditor","renderer/nodebutton","renderer/nodeeditbutton","renderer/noderemovebutton","renderer/noderevertbutton","renderer/nodelinkbutton","renderer/nodeenlargebutton","renderer/nodeshrinkbutton","renderer/edgeeditbutton","renderer/edgeremovebutton","renderer/edgerevertbutton","renderer/miniframe","renderer/scene"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t){var u=window.Rkns;"undefined"==typeof u.Renderer&&(u.Renderer={});var v=u.Renderer;v._BaseRepresentation=a,v._BaseButton=b,v.Node=c,v.Edge=d,v.TempEdge=e,v._BaseEditor=f,v.NodeEditor=g,v.EdgeEditor=h,v._NodeButton=i,v.NodeEditButton=j,v.NodeRemoveButton=k,v.NodeRevertButton=l,v.NodeLinkButton=m,v.NodeEnlargeButton=n,v.NodeShrinkButton=o,v.EdgeEditButton=p,v.EdgeRemoveButton=q,v.EdgeRevertButton=r,v.MiniFrame=s,v.Scene=t,startRenkan()}),define("main-renderer",function(){});
+//# sourceMappingURL=renkan.min.map
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/server/python/django/renkanmanager/static/renkanmanager/lib/renkan/js/renkan.min.map Wed Dec 17 16:32:46 2014 +0100
@@ -0,0 +1,1 @@
+{"version":3,"file":"renkan.min.js","sources":["../../js/main.js","../../js/models.js","../../js/defaults.js","../../js/i18n.js","../../js/full-json.js","../../js/save-once.js","../../js/ldtjson-bin.js","../../js/list-bin.js","../../js/wikipedia-bin.js","paper-renderer.js"],"names":["root","Rkns","$","jQuery","_","pickerColors","__renkans","_BaseBin","_renkan","_opts","this","renkan","find","hide","addClass","appendTo","title_icon_$","_this","attr","href","title","translate","html","click","destroy","length","slideDown","resizeBins","refresh","count_$","title_$","main_$","auto_refresh","window","setInterval","prototype","detach","Renkan","push","options","defaults","property_files","each","f","getJSON","data","properties","concat","read_only","editor_mode","project","Models","Project","user_id","current_user","container","template","tabs","search_engines","current_user_list","UsersList","on","renderer","redrawUsers","colorPicker","_tmpl","map","c","join","show_editor","Renderer","Scene","search","_select","_input","_form","_search","type","Search","_key","key","getSearchTitle","className","getBgClass","_el","setSearchEngine","submit","val","search_engine","mouseenter","mouseleave","bins","_bin","Bin","elementDropped","_mainDiv","siblings","is","slideUp","_t","_models","get","where","uri","_model","highlightModel","mouseout","unhighlightAll","dragDrop","err","e","preventDefault","touch","originalEvent","changedTouches","off","canvas_$","offset","w","width","h","height","pageX","left","pageY","top","onMouseMove","div","document","createElement","appendChild","cloneNode","dropData","text/html","innerHTML","onMouseDown","onMouseUp","dataTransfer","setData","resize","lastsearch","lastval","Utils","regexpFromTextOrArray","source","tab","render","_text","i18n","language","substr","onStatusChange","_d","outerHeight","css","getUUID4","replace","r","Math","random","v","toString","getUID","pad","n","Date","ID_AUTO_INCREMENT","ID_BASE","getUTCFullYear","getUTCMonth","getUTCDate","_base","_n","_uidbase","getFullURL","url","test","img","Image","src","res","inherit","_baseClass","_callbefore","_class","apply","Array","slice","call","arguments","_init","_initialized","extend","replaceText","makeReplaceFunc","l","k","charsrx","txt","toLowerCase","remrx","j","remsrc","charsub","getSource","inp","removeChars","String","fromCharCode","RegExp","_textOrArray","testrx","replacerx","isempty","_replace","text","_MIN_DRAG_DISTANCE","_NODE_BUTTON_WIDTH","_EDGE_BUTTON_INNER","_EDGE_BUTTON_OUTER","_CLICKMODE_ADDNODE","_CLICKMODE_STARTEDGE","_CLICKMODE_ENDEDGE","_NODE_SIZE_STEP","LN2","_MIN_SCALE","_MAX_SCALE","_MOUSEMOVE_RATE","_DOUBLETAP_DELAY","_DOUBLETAP_DISTANCE","_USER_PLACEHOLDER","color","default_user_color","_BOOKMARKLET_CODE","shortenText","_maxlength","drawEditBox","_options","_coords","_path","_xmargin","_selector","tooltip_width","tooltip_padding","_height","_isLeft","x","paper","view","center","_left","tooltip_arrow_length","_right","_top","y","size","tooltip_margin","max","tooltip_arrow_width","min","_bottom","segments","point","add","closed","fillColor","GradientColor","Gradient","tooltip_top_color","tooltip_bottom_color","Backbone","obj","guid","RenkanModel","RelationalModel","idAttribute","constructor","_id","id","description","prepare","validate","addReference","_propName","_list","_default","_element","User","toJSON","Node","relations","HasOne","relatedModel","created_by","position","image","clip_path","shape","Edge","from","to","View","isArray","zoom_level","RosterUser","HasMany","reverseRelation","includeInJSON","addUser","_props","_user","findOrCreate","addNode","_node","addEdge","_edge","addView","_view","removeNode","remove","removeEdge","_project","users","nodes","edges","views","_item","initialize","filter","Model","site_id","Collection","model","navigator","userLanguage","static_url","show_bins","manual_save","show_top_bar","size_bug_fix","force_resize","allow_double_click","zoom_on_scroll","element_delete_delay","autoscale_padding","default_view","show_search_field","show_user_list","user_name_editable","user_color_editable","show_save_button","show_export_button","show_open_button","show_addnode_button","show_addedge_button","show_bookmarklet","show_fullscreen_button","home_button_url","home_button_title","show_minimap","minimap_width","minimap_height","minimap_padding","minimap_background_color","minimap_border_color","minimap_highlight_color","minimap_highlight_weight","buttons_background","buttons_label_color","buttons_label_font_size","show_node_circles","clip_node_images","node_images_fill_mode","node_size_base","node_stroke_width","selected_node_stroke_width","node_fill_color","highlighted_node_fill_color","node_label_distance","node_label_max_length","label_untitled_nodes","change_shapes","edge_stroke_width","selected_edge_stroke_width","edge_label_distance","edge_label_max_length","edge_arrow_length","edge_arrow_width","edge_gap_in_bundles","label_untitled_edges","tooltip_border_color","tooltip_border_width","show_node_editor_uri","show_node_editor_description","show_node_editor_size","show_node_editor_color","show_node_editor_image","show_node_editor_creator","uploaded_image_max_kb","show_node_tooltip_uri","show_node_tooltip_description","show_node_tooltip_color","show_node_tooltip_image","show_node_tooltip_creator","show_edge_editor_uri","show_edge_editor_color","show_edge_editor_direction","show_edge_editor_nodes","show_edge_editor_creator","show_edge_tooltip_uri","show_edge_tooltip_color","show_edge_tooltip_nodes","show_edge_tooltip_creator","fr","Edit Node","Edit Edge","Title:","URI:","Description:","From:","To:","Image URL:","Choose Image File:","Full Screen","Add Node","Add Edge","Save Project","Open Project","Auto-save enabled","Connection lost","Created by:","Zoom In","Zoom Out","Edit","Remove","Cancel deletion","Link to another node","Enlarge","Shrink","Click on the background canvas to add a node","Click on a first node to start the edge","Click on a second node to complete the edge","Wikipedia","Wikipedia in ","French","English","Japanese","Untitled project","Lignes de Temps","Loading, please wait","Edge color:","Node color:","Choose color","Change edge direction","Do you really wish to remove node ","Do you really wish to remove edge ","This file is not an image","Image size must be under ","Size:","KB","Choose from vocabulary:","SKOS Documentation properties","has note","has example","has definition","SKOS Semantic relations","has broader","has narrower","has related","Dublin Core Metadata","has contributor","covers","created by","has date","published by","has source","has subject","Dragged resource","Search the Web","Search in Bins","Close bin","Refresh bin","(untitled)","Select contents:","Drag items from this website, drop them in Renkan","Drag this button to your bookmark bar. When on a third-party website, click it to enable drag-and-drop from the website to Renkan.","Shapes available","Circle","Square","Diamond","Hexagone","Ellipse","Star","jsonIO","_proj","http_method","_load","redrawActive","_data","set","autoScale","_save","ajax","contentType","JSON","stringify","success","_thrSave","throttle","setTimeout","jsonIOSaveOnClick","_saveWarn","_onLeave","getdata","rx","matches","location","hash","match","_checkLeave","removeClass","save","hasClass","Ldt","ProjectBin","ldt_type","Resclass","console","error","tagTemplate","annotationTemplate","proj_id","project_id","ldt_platform","searchbase","highlight","_e","escape","convertTC","_ms","_res","_totalSeconds","abs","floor","_hours","_minutes","_seconds","_html","_projtitle","meta","count","tags","_tag","_title","htitle","encodedtitle","encodeURIComponent","annotations","_annotation","_description","content","_duration","end","begin","_img","hdescription","start","duration","mediaid","media","annotationid","show","dataType","lang","_q","ResultsBin","segmentTemplate","max_results","highlightrx","objects","_segment","abstract","_begin","start_ts","_end","iri_id","element_id","format","q","limit","ResourceList","resultTemplate","list","trim","_match","langs","en","ja","query","_result","encodeURI","snippet","define","_BaseRepresentation","_renderer","_changeBinding","redraw","_removeBinding","removeRepresentation","defer","_selectBinding","select","_unselectBinding","unselect","_super","_func","moveTo","trigger","unhighlight","mousedown","mouseup","getUtils","getRenderer","requtils","BaseRepresentation","_BaseButton","_pos","sector","_newTarget","source_representation","builders","circle","getShape","Path","getImageShape","radius","rectangle","Rectangle","ellipse","polygon","RegularPolygon","diamond","d","rotate","star","svg","path","ShapeBuilder","NodeRepr","node_layer","activate","buildShape","strokeWidth","h_ratio","labels_$","normal_buttons","NodeEditButton","NodeRemoveButton","NodeLinkButton","NodeEnlargeButton","NodeShrinkButton","pending_delete_buttons","NodeRevertButton","all_buttons","i","active_buttons","last_circle_radius","minimap","minimap_circle","__representation","miniframe","node_group","addChild","shapeBuilder","_dontRedrawEdges","_model_coords","Point","_baseRadius","exp","is_dragging","paper_coords","toPaperCoords","circle_radius","scale","forEach","b","setSectorSize","node_image","subtract","image_delta","multiply","old_act_btn","opacity","dashArray","selected","isEditable","highlighted","_color","strokeColor","_pc","lastImage","showImage","minipos","toMinimapCoords","miniradius","minisize","Size","fitBounds","ed","edge","repr","getRepresentationByModel","from_representation","to_representation","_image","image_cache","clipPath","hasClipPath","_clip","baseRadius","centerPoint","instructions","lastCoords","minX","Infinity","minY","maxX","maxY","transformCoords","tabc","relative","newCoords","parseFloat","isY","instr","coords","lineTo","cubicCurveTo","quadraticCurveTo","_raster","Raster","locked","Group","clipped","_circleClip","divide","throttledPaperDraw","paperShift","_delta","openEditor","removeRepresentationsOfType","_editor","addRepresentation","draw","_uri","undefined","textToReplace","hlvalue","saveCoords","toModelCoords","_event","_isTouch","unselectAll","click_target","edge_layer","bundle","addToBundles","line","arrow","arrow_angle","EdgeEditButton","EdgeRemoveButton","EdgeRevertButton","minimap_line","_p0a","_p1a","_v","_r","_u","_ortho","_group_pos","getPosition","_p0b","_p1b","_a","angle","_textdelta","_handle","handleIn","handleOut","_textpos","transform","-moz-transform","-webkit-transform","text_angle","reject","TempEdge","_p0","_p1","end_pos","_c","_hitResult","hitTest","findTarget","_endDrag","item","_target","_destmodel","_BaseEditor","buttons_layer","editor_block","_pts","range","editor_$","BaseEditor","NodeEditor","readOnlyTemplate","_created_by","_template","_image_placeholder","_size","node","has_creator","short_uri","image_placeholder","created_by_color","created_by_title","closeEditor","onFieldChange","shape_changed","keyCode","change","files","FileReader","alert","onload","target","result","readAsDataURL","focus","_picker","hover","shiftSize","_newsize","titlehtml","load","EdgeEditor","_from_model","_to_model","from_title","to_title","from_color","to_color","BaseButton","_NodeButton","sectorInner","lastSectorInner","drawSector","startAngle","endAngle","imageName","NodeButton","delid","delete_list","time","valueOf","confirm","unset","_off","_point","addTempEdge","MiniFrame","filesaver","representations","notif_$","setup","initialScale","totalScroll","mouse_down","selected_target","Layer","background_layer","topleft","bounds","bottomRight","cliprectangle","bundles","click_mode","_allowScroll","_originalScale","_zooming","_lastTapX","_lastTapY","icon_cache","imgname","throttledMouseMove","mousemove","mousewheel","onScroll","touchstart","_touches","touches","_lastTap","pow","onDoubleClick","touchmove","_newScale","_scaleRatio","_newOffset","setScale","touchend","dblclick","dragover","dragenter","dragleave","drop","types","t","getData","parse","bindClick","selector","fname","evt","last","isNaN","parseInt","fadeIn","delay","fadeOut","mouseover","onResize","_viewSize","parent","_thRedraw","addRepresentations","_thRedrawUsers","el","_delay","fixSize","$cpwrapper","$cplist","$this","rxs","_now","findWhere","delete_scheduled","rescaleMinimap","_autoscale","viewSize","_repr","_inR","_outR","_startAngle","_endAngle","_padding","_imgname","_caption","_startRads","PI","_endRads","_startdx","sin","_startdy","cos","_startXIn","_startYIn","_startXOut","_startYOut","_enddx","_enddy","_endXIn","_endYIn","_endXOut","_endYOut","_centerR","_centerRads","_centerX","_centerY","_centerXIn","_centerXOut","_centerYIn","_centerYOut","_textX","_textY","arcTo","PointText","characterStyle","fontSize","paragraphStyle","justification","visible","_visible","_restPos","_grp","_imgdelta","_currentPos","_edgeRepr","_bundle","_er","_dir","indexOf","savebtn","tip","_offset","force_view","_xx","_yy","_minx","_miny","_maxx","_maxy","_scale","at","redrawMiniframe","bottomright","_type","RendererType","_collection","userTemplate","allUsers","models","ulistHtml","$userpanel","$name","$cpitems","$colorsquare","$input","blur","empty","name","background","_representation","_representations","_from","_tmpEdge","last_point","_scrolldelta","SQRT2","SQRT1_2","defaultDropHandler","newNode","tweetdiv","_svgimgs","_svgpaths","_imgs","_as","split","fields","drop_enhancer","jsondata","drop_handler","_nodedata","fullScreen","_isFull","mozFullScreen","webkitIsFullScreen","_requestMethods","_cancelMethods","zoomOut","zoomIn","addNodeBtn","addEdgeBtn","exportProject","projectJSON","projectId","fileNameToSaveAs","space_id","objId","idsMap","projectJSONStr","blob","Blob","foldBins","foldBinsButton","animate","open","require","config","paths","jquery","underscore","startRenkan"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;CAGA,SAAUA,GAEV,YAEyB,iBAAdA,GAAKC,OACZD,EAAKC,QAGT,IAAIA,GAAOD,EAAKC,KACZC,EAAID,EAAKC,EAAIF,EAAKG,OAClBC,EAAIH,EAAKG,EAAIJ,EAAKI,CAEtBH,GAAKI,cAAgB,UAAW,UAAW,UAAW,UAAW,UAAW,UAAW,UAAW,UAC9F,UAAW,UAAW,UAAW,UAAW,UAAW,UAAW,UAAW,UAC7E,UAAW,UAAW,UAAW,UAAW,UAAW,UAAW,UAAW,UAC7E,UAAW,UAAW,UAAW,UAAW,UAAW,UAAW,UAAW,UAC7E,UAAW,UAAW,UAAW,UAAW,UAAW,UAAW,UAAW,UAC7E,UAAW,UAAW,UAAW,UAAW,UAAW,UAAW,UAAW,UAC7E,UAAW,UAAW,UAAW,UAAW,UAAW,UAAW,UAAW,UAC7E,UAAW,UAAW,UAAW,UAAW,UAAW,UAAW,UAAW,WAEjFJ,EAAKK,YAEL,IAAIC,GAAWN,EAAKM,SAAW,SAASC,EAASC,GAC7C,GAAuB,mBAAZD,GAAyB,CAChCE,KAAKC,OAASH,EACdE,KAAKC,OAAOT,EAAEU,KAAK,gBAAgBC,OACnCH,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7B7kB,EAAS8kB,iBAAmBA,EAC5B9kB,EAAS4rB,eAAiBA,EAC1B5rB,EAAS6rB,iBAAmBA,EAC5B7rB,EAAS8rB,iBAAmBA,EAC5B9rB,EAASiyB,UAAYA,EACrBjyB,EAASC,MAAQA,EAEjBm/B,gBAGJhe,OAAO,gBAAiB","sourcesContent":["\n/* Declaring the Renkan Namespace Rkns and Default values */\n\n(function(root) {\n\n\"use strict\";\n\nif (typeof root.Rkns !== \"object\") {\n root.Rkns = {};\n}\n\nvar Rkns = root.Rkns;\nvar $ = Rkns.$ = root.jQuery;\nvar _ = Rkns._ = root._;\n\nRkns.pickerColors = [\"#8f1919\", \"#a80000\", \"#d82626\", \"#ff0000\", \"#e87c7c\", \"#ff6565\", \"#f7d3d3\", \"#fecccc\",\n \"#8f5419\", \"#a85400\", \"#d87f26\", \"#ff7f00\", \"#e8b27c\", \"#ffb265\", \"#f7e5d3\", \"#fee5cc\",\n \"#8f8f19\", \"#a8a800\", \"#d8d826\", \"#feff00\", \"#e8e87c\", \"#feff65\", \"#f7f7d3\", \"#fefecc\",\n \"#198f19\", \"#00a800\", \"#26d826\", \"#00ff00\", \"#7ce87c\", \"#65ff65\", \"#d3f7d3\", \"#ccfecc\",\n \"#198f8f\", \"#00a8a8\", \"#26d8d8\", \"#00feff\", \"#7ce8e8\", \"#65feff\", \"#d3f7f7\", \"#ccfefe\",\n \"#19198f\", \"#0000a8\", \"#2626d8\", \"#0000ff\", \"#7c7ce8\", \"#6565ff\", \"#d3d3f7\", \"#ccccfe\",\n \"#8f198f\", \"#a800a8\", \"#d826d8\", \"#ff00fe\", \"#e87ce8\", \"#ff65fe\", \"#f7d3f7\", \"#feccfe\",\n \"#000000\", \"#242424\", \"#484848\", \"#6d6d6d\", \"#919191\", \"#b6b6b6\", \"#dadada\", \"#ffffff\"];\n\nRkns.__renkans = [];\n\nvar _BaseBin = Rkns._BaseBin = function(_renkan, _opts) {\n if (typeof _renkan !== \"undefined\") {\n this.renkan = _renkan;\n this.renkan.$.find(\".Rk-Bin-Main\").hide();\n this.$ = Rkns.$('<li>')\n .addClass(\"Rk-Bin\")\n .appendTo(_renkan.$.find(\".Rk-Bin-List\"));\n this.title_icon_$ = Rkns.$('<span>')\n .addClass(\"Rk-Bin-Title-Icon\")\n .appendTo(this.$);\n\n var _this = this;\n\n Rkns.$('<a>')\n .attr({\n href: \"#\",\n title: _renkan.translate(\"Close bin\")\n })\n .addClass(\"Rk-Bin-Close\")\n .html('×')\n .appendTo(this.$)\n .click(function() {\n _this.destroy();\n if (!_renkan.$.find(\".Rk-Bin-Main:visible\").length) {\n _renkan.$.find(\".Rk-Bin-Main:last\").slideDown();\n }\n _renkan.resizeBins();\n return false;\n });\n Rkns.$('<a>')\n .attr({\n href: \"#\",\n title: _renkan.translate(\"Refresh bin\")\n })\n .addClass(\"Rk-Bin-Refresh\")\n .appendTo(this.$)\n .click(function() {\n _this.refresh();\n return false;\n });\n this.count_$ = Rkns.$('<div>')\n .addClass(\"Rk-Bin-Count\")\n .appendTo(this.$);\n this.title_$ = Rkns.$('<h2>')\n .addClass(\"Rk-Bin-Title\")\n .appendTo(this.$);\n this.main_$ = Rkns.$('<div>')\n .addClass(\"Rk-Bin-Main\")\n .appendTo(this.$)\n .html('<h4 class=\"Rk-Bin-Loading\">' + _renkan.translate(\"Loading, please wait\") + '</h4>');\n this.title_$.html(_opts.title || '(new bin)');\n this.renkan.resizeBins();\n\n if (_opts.auto_refresh) {\n window.setInterval(function() {\n _this.refresh();\n },_opts.auto_refresh);\n }\n }\n};\n\n_BaseBin.prototype.destroy = function() {\n this.$.detach();\n this.renkan.resizeBins();\n};\n\n/* Point of entry */\n\nvar Renkan = Rkns.Renkan = function(_opts) {\n var _this = this;\n\n Rkns.__renkans.push(this);\n\n this.options = _.defaults(_opts, Rkns.defaults);\n\n _(this.options.property_files).each(function(f) {\n Rkns.$.getJSON(f, function(data) {\n _this.options.properties = _this.options.properties.concat(data);\n });\n });\n\n this.read_only = this.options.read_only || !this.options.editor_mode;\n\n this.project = new Rkns.Models.Project();\n\n if (typeof this.options.user_id !== \"undefined\") {\n this.current_user = this.options.user_id;\n }\n this.$ = Rkns.$(\"#\" + this.options.container);\n this.$\n .addClass(\"Rk-Main\")\n .html(this.template(this));\n\n this.tabs = [];\n this.search_engines = [];\n\n this.current_user_list = new Rkns.Models.UsersList();\n\n this.current_user_list.on(\"add remove\", function() {\n if (this.renderer) {\n this.renderer.redrawUsers();\n }\n });\n\n this.colorPicker = (function() {\n var _tmpl = _.template('<li data-color=\"<%=c%>\" style=\"background: <%=c%>\"></li>');\n return '<ul class=\"Rk-Edit-ColorPicker\">' + Rkns.pickerColors.map(function(c) { return _tmpl({c:c});}).join(\"\") + '</ul>';\n })();\n\n if (this.options.show_editor) {\n this.renderer = new Rkns.Renderer.Scene(this);\n }\n\n if (!this.options.search.length) {\n this.$.find(\".Rk-Web-Search-Form\").detach();\n } else {\n var _tmpl = _.template('<li class=\"<%= className %>\" data-key=\"<%= key %>\"><%= title %></li>'),\n _select = this.$.find(\".Rk-Search-List\"),\n _input = this.$.find(\".Rk-Web-Search-Input\"),\n _form = this.$.find(\".Rk-Web-Search-Form\");\n _(this.options.search).each(function(_search, _key) {\n if (Rkns[_search.type] && Rkns[_search.type].Search) {\n _this.search_engines.push(new Rkns[_search.type].Search(_this, _search));\n }\n });\n _select.html(\n _(this.search_engines).map(function(_search, _key) {\n return _tmpl({\n key: _key,\n title: _search.getSearchTitle(),\n className: _search.getBgClass()\n });\n }).join(\"\")\n );\n _select.find(\"li\").click(function() {\n var _el = Rkns.$(this);\n _this.setSearchEngine(_el.attr(\"data-key\"));\n _form.submit();\n });\n _form.submit(function() {\n if (_input.val()) {\n var _search = _this.search_engine;\n _search.search(_input.val());\n }\n return false;\n });\n this.$.find(\".Rk-Search-Current\").mouseenter(\n function() { _select.slideDown(); }\n );\n this.$.find(\".Rk-Search-Select\").mouseleave(\n function() { _select.hide(); }\n );\n this.setSearchEngine(0);\n }\n _(this.options.bins).each(function(_bin) {\n if (Rkns[_bin.type] && Rkns[_bin.type].Bin) {\n _this.tabs.push(new Rkns[_bin.type].Bin(_this, _bin));\n }\n });\n\n var elementDropped = false;\n\n this.$.find(\".Rk-Bins\")\n .on(\"click\",\".Rk-Bin-Title,.Rk-Bin-Title-Icon\", function() {\n var _mainDiv = Rkns.$(this).siblings(\".Rk-Bin-Main\");\n if (_mainDiv.is(\":hidden\")) {\n _this.$.find(\".Rk-Bin-Main\").slideUp();\n _mainDiv.slideDown();\n }\n });\n\n if (this.options.show_editor) {\n\n this.$.find(\".Rk-Bins\").on(\"mouseover\", \".Rk-Bin-Item\", function(_e) {\n var _t = Rkns.$(this);\n if (_t && $(_t).attr(\"data-uri\")) {\n var _models = _this.project.get(\"nodes\").where({\n uri: $(_t).attr(\"data-uri\")\n });\n _(_models).each(function(_model) {\n _this.renderer.highlightModel(_model);\n });\n }\n }).mouseout(function() {\n _this.renderer.unhighlightAll();\n }).on(\"mousemove\", \".Rk-Bin-Item\", function(e) {\n try {\n this.dragDrop();\n }\n catch(err) {}\n }).on(\"touchstart\", \".Rk-Bin-Item\", function(e) {\n elementDropped = false;\n }).on(\"touchmove\", \".Rk-Bin-Item\", function(e) {\n e.preventDefault();\n var touch = e.originalEvent.changedTouches[0],\n off = _this.renderer.canvas_$.offset(),\n w = _this.renderer.canvas_$.width(),\n h = _this.renderer.canvas_$.height();\n if (touch.pageX >= off.left && touch.pageX < (off.left + w) && touch.pageY >= off.top && touch.pageY < (off.top + h)) {\n if (elementDropped) {\n _this.renderer.onMouseMove(touch, true);\n } else {\n elementDropped = true;\n var div = document.createElement('div');\n div.appendChild(this.cloneNode(true));\n _this.renderer.dropData({\"text/html\": div.innerHTML}, touch);\n _this.renderer.onMouseDown(touch, true);\n }\n }\n }).on(\"touchend\", \".Rk-Bin-Item\", function(e) {\n if (elementDropped) {\n _this.renderer.onMouseUp(e.originalEvent.changedTouches[0], true);\n }\n elementDropped = false;\n }).on(\"dragstart\", \".Rk-Bin-Item\", function(e) {\n var div = document.createElement('div');\n div.appendChild(this.cloneNode(true));\n try {\n e.originalEvent.dataTransfer.setData(\"text/html\",div.innerHTML);\n }\n catch(err) {\n e.originalEvent.dataTransfer.setData(\"text\",div.innerHTML);\n }\n });\n\n }\n\n Rkns.$(window).resize(function() {\n _this.resizeBins();\n });\n\n var lastsearch = false, lastval = '';\n\n this.$.find(\".Rk-Bins-Search-Input\").on(\"change keyup paste input\", function() {\n var val = Rkns.$(this).val();\n if (val === lastval) {\n return;\n }\n var search = Rkns.Utils.regexpFromTextOrArray(val.length > 1 ? val: null);\n if (search.source === lastsearch) {\n return;\n }\n lastsearch = search.source;\n _(_this.tabs).each(function(tab) {\n tab.render(search);\n });\n\n });\n this.$.find(\".Rk-Bins-Search-Form\").submit(function() {\n return false;\n });\n\n};\n\nRenkan.prototype.template = _.template(\n '<% if (options.show_bins) { %><div class=\"Rk-Bins\"><div class=\"Rk-Bins-Head\"><h2 class=\"Rk-Bins-Title\"><%- translate(\"Select contents:\")%></h2>' +\n '<form class=\"Rk-Web-Search-Form Rk-Search-Form\"><input class=\"Rk-Web-Search-Input Rk-Search-Input\" type=\"search\" placeholder=\"<%- translate(\"Search the Web\") %>\" />' +\n '<div class=\"Rk-Search-Select\"><div class=\"Rk-Search-Current\"></div><ul class=\"Rk-Search-List\"></ul></div>' +\n '<input type=\"submit\" value=\"\" class=\"Rk-Web-Search-Submit Rk-Search-Submit\" title=\"<%- translate(\"Search the Web\") %>\" /></form>' +\n '<form class=\"Rk-Bins-Search-Form Rk-Search-Form\"><input class=\"Rk-Bins-Search-Input Rk-Search-Input\" type=\"search\" placeholder=\"<%- translate(\"Search in Bins\") %>\" />' +\n '<input type=\"submit\" value=\"\" class=\"Rk-Bins-Search-Submit Rk-Search-Submit\" title=\"<%- translate(\"Search in Bins\") %>\" /></form></div>' +\n '<ul class=\"Rk-Bin-List\"></ul></div><% } %>' +\n '<% if (options.show_editor) { %><div class=\"Rk-Render Rk-Render-<% if (options.show_bins) { %>Panel<% } else { %>Full<% } %>\"></div><% } %>'\n);\n\nRenkan.prototype.translate = function(_text) {\n if (Rkns.i18n[this.options.language] && Rkns.i18n[this.options.language][_text]) {\n return Rkns.i18n[this.options.language][_text];\n }\n if (this.options.language.length > 2 && Rkns.i18n[this.options.language.substr(0,2)] && Rkns.i18n[this.options.language.substr(0,2)][_text]) {\n return Rkns.i18n[this.options.language.substr(0,2)][_text];\n }\n return _text;\n};\n\nRenkan.prototype.onStatusChange = function() {\n this.renderer.onStatusChange();\n};\n\nRenkan.prototype.setSearchEngine = function(_key) {\n this.search_engine = this.search_engines[_key];\n this.$.find(\".Rk-Search-Current\").attr(\"class\",\"Rk-Search-Current \" + this.search_engine.getBgClass());\n};\n\nRenkan.prototype.resizeBins = function() {\n var _d = + this.$.find(\".Rk-Bins-Head\").outerHeight();\n this.$.find(\".Rk-Bin-Title:visible\").each(function() {\n _d += Rkns.$(this).outerHeight();\n });\n this.$.find(\".Rk-Bin-Main\").css({\n height: this.$.find(\".Rk-Bins\").height() - _d\n });\n};\n\n/* Utility functions */\nvar getUUID4 = function() {\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {\n var r = Math.random()*16|0, v = c === 'x' ? r : (r&0x3|0x8);\n return v.toString(16);\n });\n};\n\nRkns.Utils = {\n getUUID4 : getUUID4,\n getUID : (function() {\n function pad(n){\n return n<10 ? '0'+n : n;\n }\n var _d = new Date(),\n ID_AUTO_INCREMENT = 0,\n ID_BASE = _d.getUTCFullYear() + '-' +\n pad(_d.getUTCMonth()+1) + '-' +\n pad(_d.getUTCDate()) + '-' +\n getUUID4();\n return function(_base) {\n var _n = (++ID_AUTO_INCREMENT).toString(16),\n _uidbase = (typeof _base === \"undefined\" ? \"\" : _base + \"-\" );\n while (_n.length < 4) { _n = '0' + _n; }\n return _uidbase + ID_BASE + '-' + _n;\n };\n })(),\n getFullURL : function(url) {\n\n if(typeof(url) === 'undefined' || url == null ) {\n return \"\";\n }\n if(/https?:\\/\\//.test(url)) {\n return url;\n }\n var img = new Image();\n img.src = url;\n var res = img.src;\n img.src = null;\n return res;\n\n },\n inherit : function(_baseClass, _callbefore) {\n\n var _class = function(_arg) {\n if (typeof _callbefore === \"function\") {\n _callbefore.apply(this, Array.prototype.slice.call(arguments, 0));\n }\n _baseClass.apply(this, Array.prototype.slice.call(arguments, 0));\n if (typeof this._init === \"function\" && !this._initialized) {\n this._init.apply(this, Array.prototype.slice.call(arguments, 0));\n this._initialized = true;\n }\n };\n _(_class.prototype).extend(_baseClass.prototype);\n\n return _class;\n\n },\n regexpFromTextOrArray: (function() {\n var charsub = [\n '[aáàâä]',\n '[cç]',\n '[eéèêë]',\n '[iíìîï]',\n '[oóòôö]',\n '[uùûü]'\n ],\n removeChars = [\n String.fromCharCode(768), String.fromCharCode(769), String.fromCharCode(770), String.fromCharCode(771), String.fromCharCode(807),\n \"{\", \"}\", \"(\", \")\", \"[\", \"]\", \"【\", \"】\", \"、\", \"・\", \"‥\", \"。\", \"「\", \"」\", \"『\", \"』\", \"〜\", \":\", \"!\", \"?\", \" \",\n \",\", \" \", \";\", \"(\", \")\", \".\", \"*\", \"+\", \"\\\\\", \"?\", \"|\", \"{\", \"}\", \"[\", \"]\", \"^\", \"#\", \"/\"\n ],\n remsrc = \"[\\\\\" + removeChars.join(\"\\\\\") + \"]\",\n remrx = new RegExp(remsrc, \"gm\"),\n charsrx = _(charsub).map(function(c) {\n return new RegExp(c);\n });\n\n function replaceText(_text) {\n var txt = _text.toLowerCase().replace(remrx,\"\"), src = \"\";\n function makeReplaceFunc(l) {\n return function(k,v) {\n l = l.replace(charsrx[k], v);\n };\n }\n for (var j = 0; j < txt.length; j++) {\n if (j) {\n src += remsrc + \"*\";\n }\n var l = txt[j];\n _(charsub).each(makeReplaceFunc(l));\n src += l;\n }\n return src;\n }\n\n function getSource(inp) {\n switch (typeof inp) {\n case \"string\":\n return replaceText(inp);\n case \"object\":\n var src = '';\n _(inp).each(function(v) {\n var res = getSource(v);\n if (res) {\n if (src) {\n src += '|';\n }\n src += res;\n }\n });\n return src;\n }\n return '';\n }\n\n return function(_textOrArray) {\n var source = getSource(_textOrArray);\n if (source) {\n var testrx = new RegExp( source, \"im\"),\n replacerx = new RegExp( '(' + source + ')', \"igm\");\n return {\n isempty: false,\n source: source,\n test: function(_t) { return testrx.test(_t); },\n replace: function(_text, _replace) { return _text.replace(replacerx, _replace); }\n };\n } else {\n return {\n isempty: true,\n source: '',\n test: function() { return true; },\n replace: function(_text) { return text; }\n };\n }\n };\n })(),\n /* The minimum distance (in pixels) the mouse has to move to consider an element was dragged */\n _MIN_DRAG_DISTANCE: 2,\n /* Distance between the inner and outer radius of buttons that appear when hovering on a node */\n _NODE_BUTTON_WIDTH: 40,\n\n _EDGE_BUTTON_INNER: 2,\n _EDGE_BUTTON_OUTER: 40,\n /* Constants used to know if a specific action is to be performed when clicking on the canvas */\n _CLICKMODE_ADDNODE: 1,\n _CLICKMODE_STARTEDGE: 2,\n _CLICKMODE_ENDEDGE: 3,\n /* Node size step: Used to calculate the size change when clicking the +/- buttons */\n _NODE_SIZE_STEP: Math.LN2/4,\n _MIN_SCALE: 1/20,\n _MAX_SCALE: 20,\n _MOUSEMOVE_RATE: 80,\n _DOUBLETAP_DELAY: 800,\n /* Maximum distance in pixels (squared, to reduce calculations)\n * between two taps when double-tapping on a touch terminal */\n _DOUBLETAP_DISTANCE: 20*20,\n /* A placeholder so a default colour is displayed when a node has a null value for its user property */\n _USER_PLACEHOLDER: function(_renkan) {\n return {\n color: _renkan.options.default_user_color,\n title: _renkan.translate(\"(unknown user)\"),\n get: function(attr) {\n return this[attr] || false;\n }\n };\n },\n /* The code for the \"Drag and Add Bookmarklet\", slightly minified and with whitespaces removed, though\n * it doesn't seem that it's still a requirement in newer browsers (i.e. the ones compatibles with canvas drawing)\n */\n _BOOKMARKLET_CODE: function(_renkan) {\n return \"(function(a,b,c,d,e,f,h,i,j,k,l,m,n,o,p,q,r){a=document;b=a.body;c=a.location.href;j='draggable';m='text/x-iri-';d=a.createElement('div');d.innerHTML='<p_style=\\\"position:fixed;top:0;right:0;font:bold_18px_sans-serif;color:#fff;background:#909;padding:10px;z-index:100000;\\\">\" +\n _renkan.translate(\"Drag items from this website, drop them in Renkan\").replace(/ /g,\"_\") +\n \"</p>'.replace(/_/g,String.fromCharCode(32));b.appendChild(d);e=[{r:/https?:\\\\/\\\\/[^\\\\/]*twitter\\\\.com\\\\//,s:'.tweet',n:'twitter'},{r:/https?:\\\\/\\\\/[^\\\\/]*google\\\\.[^\\\\/]+\\\\//,s:'.g',n:'google'},{r:/https?:\\\\/\\\\/[^\\\\/]*lemonde\\\\.fr\\\\//,s:'[data-vr-contentbox]',n:'lemonde'}];f=false;e.forEach(function(g){if(g.r.test(c)){f=g;}});if(f){h=function(){Array.prototype.forEach.call(a.querySelectorAll(f.s),function(i){i[j]=true;k=i.style;k.borderWidth='2px';k.borderColor='#909';k.borderStyle='solid';k.backgroundColor='rgba(200,0,180,.1)';})};window.setInterval(h,500);h();};a.addEventListener('dragstart',function(k){l=k.dataTransfer;l.setData(m+'source-uri',c);l.setData(m+'source-title',a.title);n=k.target;if(f){o=n;while(!o.attributes[j]){o=o.parentNode;if(o==b){break;}}}if(f&&o.attributes[j]){p=o.cloneNode(true);l.setData(m+'specific-site',f.n)}else{q=a.getSelection();if(q.type==='Range'||!q.type){p=q.getRangeAt(0).cloneContents();}else{p=n.cloneNode();}}r=a.createElement('div');r.appendChild(p);l.setData('text/x-iri-selected-text',r.textContent.trim());l.setData('text/x-iri-selected-html',r.innerHTML);},false);})();\";\n },\n /* Shortens text to the required length then adds ellipsis */\n shortenText: function(_text, _maxlength) {\n return (_text.length > _maxlength ? (_text.substr(0,_maxlength) + '…') : _text);\n },\n /* Drawing an edit box with an arrow and positioning the edit box according to the position of the node/edge being edited\n * Called by Rkns.Renderer.NodeEditor and Rkns.Renderer.EdgeEditor */\n drawEditBox: function(_options, _coords, _path, _xmargin, _selector) {\n _selector.css({\n width: ( _options.tooltip_width - 2* _options.tooltip_padding )\n });\n var _height = _selector.outerHeight() + 2* _options.tooltip_padding,\n _isLeft = (_coords.x < paper.view.center.x ? 1 : -1),\n _left = _coords.x + _isLeft * ( _xmargin + _options.tooltip_arrow_length ),\n _right = _coords.x + _isLeft * ( _xmargin + _options.tooltip_arrow_length + _options.tooltip_width ),\n _top = _coords.y - _height / 2;\n if (_top + _height > (paper.view.size.height - _options.tooltip_margin)) {\n _top = Math.max( paper.view.size.height - _options.tooltip_margin, _coords.y + _options.tooltip_arrow_width / 2 ) - _height;\n }\n if (_top < _options.tooltip_margin) {\n _top = Math.min( _options.tooltip_margin, _coords.y - _options.tooltip_arrow_width / 2 );\n }\n var _bottom = _top + _height;\n /* jshint laxbreak:true */\n _path.segments[0].point\n = _path.segments[7].point\n = _coords.add([_isLeft * _xmargin, 0]);\n _path.segments[1].point.x\n = _path.segments[2].point.x\n = _path.segments[5].point.x\n = _path.segments[6].point.x\n = _left;\n _path.segments[3].point.x\n = _path.segments[4].point.x\n = _right;\n _path.segments[2].point.y\n = _path.segments[3].point.y\n = _top;\n _path.segments[4].point.y\n = _path.segments[5].point.y\n = _bottom;\n _path.segments[1].point.y = _coords.y - _options.tooltip_arrow_width / 2;\n _path.segments[6].point.y = _coords.y + _options.tooltip_arrow_width / 2;\n _path.closed = true;\n _path.fillColor = new paper.GradientColor(new paper.Gradient([_options.tooltip_top_color, _options.tooltip_bottom_color]), [0,_top], [0, _bottom]);\n _selector.css({\n left: (_options.tooltip_padding + Math.min(_left, _right)),\n top: (_options.tooltip_padding + _top)\n });\n return _path;\n }\n};\n})(window);\n\n/* END main.js */\n","(function() {\n \"use strict\";\n var root = this;\n\n var Backbone = root.Backbone;\n\n var Models = root.Rkns.Models = {};\n\n\n Models.getUID = function(obj) {\n var guid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {\n var r = Math.random()*16|0, v = c === 'x' ? r : (r&0x3|0x8);\n return v.toString(16);\n });\n if(typeof obj !== 'undefined') {\n return obj.type + \"-\" + guid;\n }\n else {\n return guid;\n }\n };\n\n\n var RenkanModel = Backbone.RelationalModel.extend({\n idAttribute : \"_id\",\n constructor: function(options) {\n\n if (typeof options !== \"undefined\") {\n options._id = options._id || options.id || Models.getUID(this);\n options.title = options.title || \"\";\n options.description = options.description || \"\";\n options.uri = options.uri || \"\";\n\n if(typeof this.prepare === \"function\") {\n options = this.prepare(options);\n }\n }\n Backbone.RelationalModel.prototype.constructor.call(this, options);\n },\n validate: function() {\n if(!this.type) {\n return \"object has no type\";\n }\n },\n addReference : function(_options, _propName, _list, _id, _default) {\n var _element = _list.get(_id);\n if (typeof _element === \"undefined\" && typeof _default !== \"undefined\") {\n _options[_propName ] = _default;\n }\n else {\n _options[_propName ] = _element;\n }\n }\n });\n\n // USER\n var User = Models.User = RenkanModel.extend({\n type: \"user\",\n prepare: function(options) {\n options.color = options.color || \"#666666\";\n return options;\n },\n toJSON: function() {\n return {\n _id: this.get(\"_id\"),\n title: this.get(\"title\"),\n uri: this.get(\"uri\"),\n description: this.get(\"description\"),\n color: this.get(\"color\")\n };\n }\n });\n\n // NODE\n var Node = Models.Node = RenkanModel.extend({\n type: \"node\",\n relations: [{\n type: Backbone.HasOne,\n key: \"created_by\",\n relatedModel: User\n }],\n prepare: function(options) {\n var project = options.project;\n this.addReference(options, \"created_by\", project.get(\"users\"), options.created_by, project.current_user);\n options.description = options.description || \"\";\n return options;\n },\n toJSON: function() {\n return {\n _id: this.get(\"_id\"),\n title: this.get(\"title\"),\n uri: this.get(\"uri\"),\n description: this.get(\"description\"),\n position: this.get(\"position\"),\n image: this.get(\"image\"),\n color: this.get(\"color\"),\n created_by: this.get(\"created_by\") ? this.get(\"created_by\").get(\"_id\") : null,\n size: this.get(\"size\"),\n clip_path: this.get(\"clip_path\"),\n shape: this.get(\"shape\")\n };\n }\n });\n\n // EDGE\n var Edge = Models.Edge = RenkanModel.extend({\n type: \"edge\",\n relations: [\n {\n type: Backbone.HasOne,\n key: \"created_by\",\n relatedModel: User\n },\n {\n type: Backbone.HasOne,\n key: \"from\",\n relatedModel: Node\n },\n {\n type: Backbone.HasOne,\n key: \"to\",\n relatedModel: Node\n }\n ],\n prepare: function(options) {\n var project = options.project;\n this.addReference(options, \"created_by\", project.get(\"users\"), options.created_by, project.current_user);\n this.addReference(options, \"from\", project.get(\"nodes\"), options.from);\n this.addReference(options, \"to\", project.get(\"nodes\"), options.to);\n return options;\n },\n toJSON: function() {\n return {\n _id: this.get(\"_id\"),\n title: this.get(\"title\"),\n uri: this.get(\"uri\"),\n description: this.get(\"description\"),\n from: this.get(\"from\") ? this.get(\"from\").get(\"_id\") : null,\n to: this.get(\"to\") ? this.get(\"to\").get(\"_id\") : null,\n color: this.get(\"color\"),\n created_by: this.get(\"created_by\") ? this.get(\"created_by\").get(\"_id\") : null\n };\n }\n });\n\n // View\n var View = Models.View = RenkanModel.extend({\n type: \"view\",\n relations: [\n {\n type: Backbone.HasOne,\n key: \"created_by\",\n relatedModel: User\n }\n ],\n prepare: function(options) {\n var project = options.project;\n this.addReference(options, \"created_by\", project.get(\"users\"), options.created_by, project.current_user);\n options.description = options.description || \"\";\n if(typeof options.offset !== \"undefined\") {\n var offset = {};\n if (Array.isArray(options.offset)) {\n offset.x = options.offset[0];\n offset.y = options.offset.length > 1 ? options.offset[1] : options.offset[0];\n }\n else if (options.offset.x != null) {\n offset.x = options.offset.x;\n offset.y = options.offset.y;\n }\n options.offset = offset;\n }\n return options;\n },\n toJSON: function() {\n return {\n _id: this.get(\"_id\"),\n zoom_level: this.get(\"zoom_level\"),\n offset: this.get(\"offset\"),\n title: this.get(\"title\"),\n description: this.get(\"description\"),\n created_by: this.get(\"created_by\") ? this.get(\"created_by\").get(\"_id\") : null\n // Don't need project id\n };\n }\n });\n\n // PROJECT\n var Project = Models.Project = RenkanModel.extend({\n type: \"project\",\n relations: [\n {\n type: Backbone.HasMany,\n key: \"users\",\n relatedModel: User,\n reverseRelation: {\n key: 'project',\n includeInJSON: '_id'\n }\n },\n {\n type: Backbone.HasMany,\n key: \"nodes\",\n relatedModel: Node,\n reverseRelation: {\n key: 'project',\n includeInJSON: '_id'\n }\n },\n {\n type: Backbone.HasMany,\n key: \"edges\",\n relatedModel: Edge,\n reverseRelation: {\n key: 'project',\n includeInJSON: '_id'\n }\n },\n {\n type: Backbone.HasMany,\n key: \"views\",\n relatedModel: View,\n reverseRelation: {\n key: 'project',\n includeInJSON: '_id'\n }\n }\n ],\n addUser: function(_props, _options) {\n _props.project = this;\n var _user = User.findOrCreate(_props);\n this.get(\"users\").push(_user, _options);\n return _user;\n },\n addNode: function(_props, _options) {\n _props.project = this;\n var _node = Node.findOrCreate(_props);\n this.get(\"nodes\").push(_node, _options);\n return _node;\n },\n addEdge: function(_props, _options) {\n _props.project = this;\n var _edge = Edge.findOrCreate(_props);\n this.get(\"edges\").push(_edge, _options);\n return _edge;\n },\n addView: function(_props, _options) {\n _props.project = this;\n // TODO: check if need to replace with create only\n var _view = View.findOrCreate(_props);\n // TODO: Should we remember only one view?\n this.get(\"views\").push(_view, _options);\n return _view;\n },\n removeNode: function(_model) {\n this.get(\"nodes\").remove(_model);\n },\n removeEdge: function(_model) {\n this.get(\"edges\").remove(_model);\n },\n validate: function(options) {\n var _project = this;\n _([].concat(options.users, options.nodes, options.edges, options.views)).each(function(_item) {\n if(_item) {\n _item.project = _project;\n }\n });\n },\n // Add event handler to remove edges when a node is removed\n initialize: function() {\n var _this = this;\n this.on(\"remove:nodes\", function(_node) {\n _this.get(\"edges\").remove(\n _this.get(\"edges\").filter(function(_edge) {\n return _edge.get(\"from\") === _node || _edge.get(\"to\") === _node;\n })\n );\n });\n }\n });\n\n var RosterUser = Models.RosterUser = Backbone.Model.extend({\n type: \"roster_user\",\n idAttribute : \"_id\",\n\n constructor: function(options) {\n\n if (typeof options !== \"undefined\") {\n options._id = options._id || options.id || Models.getUID(this);\n options.title = options.title || \"(untitled \" + this.type + \")\";\n options.description = options.description || \"\";\n options.uri = options.uri || \"\";\n options.project = options.project || null;\n options.site_id = options.site_id || 0;\n\n if(typeof this.prepare === \"function\") {\n options = this.prepare(options);\n }\n }\n Backbone.Model.prototype.constructor.call(this, options);\n },\n\n validate: function() {\n if(!this.type) {\n return \"object has no type\";\n }\n },\n\n prepare: function(options) {\n options.color = options.color || \"#666666\";\n return options;\n },\n\n toJSON: function() {\n return {\n _id: this.get(\"_id\"),\n title: this.get(\"title\"),\n uri: this.get(\"uri\"),\n description: this.get(\"description\"),\n color: this.get(\"color\"),\n project: (this.get(\"project\") != null)?this.get(\"project\").get(\"id\"):null,\n site_id: this.get(\"site_id\")\n };\n }\n });\n\n var UsersList = Models.UsersList = Backbone.Collection.extend({\n model: RosterUser\n });\n\n\n}).call(window);\n","Rkns.defaults = {\n\n language: (navigator.language || navigator.userLanguage || \"en\"),\n /* GUI Language */\n container: \"renkan\",\n /* GUI Container DOM element ID */\n search: [],\n /* List of Search Engines */\n bins: [],\n /* List of Bins */\n static_url: \"\",\n /* URL for static resources */\n show_bins: true,\n /* Show bins in left column */\n properties: [],\n /* Semantic properties for edges */\n show_editor: true,\n /* Show the graph editor... Setting this to \"false\" only shows the bins part ! */\n read_only: false,\n /* Allows editing of renkan without changing the rest of the GUI. Can be switched on/off on the fly to block/enable editing */\n editor_mode: true,\n /* Switch for Publish/Edit GUI. If editor_mode is false, read_only will be true. */\n manual_save: false,\n /* In snapshot mode, clicking on the floppy will save a snapshot. Otherwise, it will show the connection status */\n show_top_bar: true,\n /* Show the top bar, (title, buttons, users) */\n default_user_color: \"#303030\",\n size_bug_fix: true,\n /* Resize the canvas after load (fixes a bug on iPad and FF Mac) */\n force_resize: false,\n allow_double_click: true,\n /* Allows Double Click to create a node on an empty background */\n zoom_on_scroll: true,\n /* Allows to use the scrollwheel to zoom */\n element_delete_delay: 0,\n /* Delay between clicking on the bin on an element and really deleting it\n Set to 0 for delete confirm */\n autoscale_padding: 50,\n default_view: false,\n\t/* Allows to load default view (zoom+offset) at start on read_only mode, instead of autoScale. default_view has to be an integer 0,1,2... */\n\n /* TOP BAR BUTTONS */\n show_search_field: true,\n show_user_list: true,\n user_name_editable: true,\n user_color_editable: true,\n show_save_button: true,\n show_export_button: true,\n show_open_button: false,\n show_addnode_button: true,\n show_addedge_button: true,\n show_bookmarklet: true,\n show_fullscreen_button: true,\n home_button_url: false,\n home_button_title: \"Home\",\n\n /* MINI-MAP OPTIONS */\n\n show_minimap: true,\n /* Show a small map at the bottom right */\n minimap_width: 160,\n minimap_height: 120,\n minimap_padding: 20,\n minimap_background_color: \"#ffffff\",\n minimap_border_color: \"#cccccc\",\n minimap_highlight_color: \"#ffff00\",\n minimap_highlight_weight: 5,\n\n /* EDGE/NODE COMMON OPTIONS */\n\n buttons_background: \"#202020\",\n buttons_label_color: \"#c000c0\",\n buttons_label_font_size: 9,\n\n /* NODE DISPLAY OPTIONS */\n\n show_node_circles: true,\n /* Show circles for nodes */\n clip_node_images: true,\n /* Constraint node images to circles */\n node_images_fill_mode: false,\n /* Set to false for \"letterboxing\" (height/width of node adapted to show full image)\n Set to true for \"crop\" (adapted to fill circle) */\n node_size_base: 25,\n node_stroke_width: 2,\n selected_node_stroke_width: 4,\n node_fill_color: \"#ffffff\",\n highlighted_node_fill_color: \"#ffff00\",\n node_label_distance: 5,\n /* Vertical distance between node and label */\n node_label_max_length: 60,\n /* Maximum displayed text length */\n label_untitled_nodes: \"(untitled)\",\n /* Label to display on untitled nodes */\n change_shapes: true,\n /* Change shapes enabled */\n\n /* EDGE DISPLAY OPTIONS */\n\n edge_stroke_width: 2,\n selected_edge_stroke_width: 4,\n edge_label_distance: 0,\n edge_label_max_length: 20,\n edge_arrow_length: 18,\n edge_arrow_width: 12,\n edge_gap_in_bundles: 12,\n label_untitled_edges: \"\",\n\n /* CONTEXTUAL DISPLAY (TOOLTIP OR EDITOR) OPTIONS */\n\n tooltip_width: 275,\n tooltip_padding: 10,\n tooltip_margin: 15,\n tooltip_arrow_length : 20,\n tooltip_arrow_width : 40,\n tooltip_top_color: \"#f0f0f0\",\n tooltip_bottom_color: \"#d0d0d0\",\n tooltip_border_color: \"#808080\",\n tooltip_border_width: 1,\n\n /* NODE EDITOR OPTIONS */\n\n show_node_editor_uri: true,\n show_node_editor_description: true,\n show_node_editor_size: true,\n show_node_editor_color: true,\n show_node_editor_image: true,\n show_node_editor_creator: true,\n uploaded_image_max_kb: 500,\n\n /* NODE TOOLTIP OPTIONS */\n\n show_node_tooltip_uri: true,\n show_node_tooltip_description: true,\n show_node_tooltip_color: true,\n show_node_tooltip_image: true,\n show_node_tooltip_creator: true,\n\n /* EDGE EDITOR OPTIONS */\n\n show_edge_editor_uri: true,\n show_edge_editor_color: true,\n show_edge_editor_direction: true,\n show_edge_editor_nodes: true,\n show_edge_editor_creator: true,\n\n /* EDGE TOOLTIP OPTIONS */\n\n show_edge_tooltip_uri: true,\n show_edge_tooltip_color: true,\n show_edge_tooltip_nodes: true,\n show_edge_tooltip_creator: true\n\n /* */\n\n};\n","Rkns.i18n = {\n fr: {\n \"Edit Node\": \"Édition d’un nœud\",\n \"Edit Edge\": \"Édition d’un lien\",\n \"Title:\": \"Titre :\",\n \"URI:\": \"URI :\",\n \"Description:\": \"Description :\",\n \"From:\": \"De :\",\n \"To:\": \"Vers :\",\n \"Image\": \"Image\",\n \"Image URL:\": \"URL d'Image\",\n \"Choose Image File:\": \"Choisir un fichier image\",\n \"Full Screen\": \"Mode plein écran\",\n \"Add Node\": \"Ajouter un nœud\",\n \"Add Edge\": \"Ajouter un lien\",\n \"Save Project\": \"Enregistrer le projet\",\n \"Open Project\": \"Ouvrir un projet\",\n \"Auto-save enabled\": \"Enregistrement automatique activé\",\n \"Connection lost\": \"Connexion perdue\",\n \"Created by:\": \"Créé par :\",\n \"Zoom In\": \"Agrandir l’échelle\",\n \"Zoom Out\": \"Rapetisser l’échelle\",\n \"Edit\": \"Éditer\",\n \"Remove\": \"Supprimer\",\n \"Cancel deletion\": \"Annuler la suppression\",\n \"Link to another node\": \"Créer un lien\",\n \"Enlarge\": \"Agrandir\",\n \"Shrink\": \"Rétrécir\",\n \"Click on the background canvas to add a node\": \"Cliquer sur le fond du graphe pour rajouter un nœud\",\n \"Click on a first node to start the edge\": \"Cliquer sur un premier nœud pour commencer le lien\",\n \"Click on a second node to complete the edge\": \"Cliquer sur un second nœud pour terminer le lien\",\n \"Wikipedia\": \"Wikipédia\",\n \"Wikipedia in \": \"Wikipédia en \",\n \"French\": \"Français\",\n \"English\": \"Anglais\",\n \"Japanese\": \"Japonais\",\n \"Untitled project\": \"Projet sans titre\",\n \"Lignes de Temps\": \"Lignes de Temps\",\n \"Loading, please wait\": \"Chargement en cours, merci de patienter\",\n \"Edge color:\": \"Couleur :\",\n \"Node color:\": \"Couleur :\",\n \"Choose color\": \"Choisir une couleur\",\n \"Change edge direction\": \"Changer le sens du lien\",\n \"Do you really wish to remove node \": \"Voulez-vous réellement supprimer le nœud \",\n \"Do you really wish to remove edge \": \"Voulez-vous réellement supprimer le lien \",\n \"This file is not an image\": \"Ce fichier n'est pas une image\",\n \"Image size must be under \": \"L'image doit peser moins de \",\n \"Size:\": \"Taille :\",\n \"KB\": \"ko\",\n \"Choose from vocabulary:\": \"Choisir dans un vocabulaire :\",\n \"SKOS Documentation properties\": \"SKOS: Propriétés documentaires\",\n \"has note\": \"a pour note\",\n \"has example\": \"a pour exemple\",\n \"has definition\": \"a pour définition\",\n \"SKOS Semantic relations\": \"SKOS: Relations sémantiques\",\n \"has broader\": \"a pour concept plus large\",\n \"has narrower\": \"a pour concept plus étroit\",\n \"has related\": \"a pour concept apparenté\",\n \"Dublin Core Metadata\": \"Métadonnées Dublin Core\",\n \"has contributor\": \"a pour contributeur\",\n \"covers\": \"couvre\",\n \"created by\": \"créé par\",\n \"has date\": \"a pour date\",\n \"published by\": \"édité par\",\n \"has source\": \"a pour source\",\n \"has subject\": \"a pour sujet\",\n \"Dragged resource\": \"Ressource glisée-déposée\",\n \"Search the Web\": \"Rechercher en ligne\",\n \"Search in Bins\": \"Rechercher dans les chutiers\",\n \"Close bin\": \"Fermer le chutier\",\n \"Refresh bin\": \"Rafraîchir le chutier\",\n \"(untitled)\": \"(sans titre)\",\n \"Select contents:\": \"Sélectionner des contenus :\",\n \"Drag items from this website, drop them in Renkan\": \"Glissez des éléments de ce site web vers Renkan\",\n \"Drag this button to your bookmark bar. When on a third-party website, click it to enable drag-and-drop from the website to Renkan.\": \"Glissez ce bouton vers votre barre de favoris. Ensuite, depuis un site tiers, cliquez dessus pour activer 'Drag-to-Add' puis glissez des éléments de ce site vers Renkan\",\n \"Shapes available\": \"Formes disponibles\",\n \"Circle\": \"Cercle\",\n \"Square\": \"Carré\",\n \"Diamond\": \"Losange\",\n \"Hexagone\": \"Hexagone\",\n \"Ellipse\": \"Ellipse\",\n \"Star\": \"Étoile\"\n }\n};\n","/* Saves the Full JSON at each modification */\n\nRkns.jsonIO = function(_renkan, _opts) {\n var _proj = _renkan.project;\n if (typeof _opts.http_method === \"undefined\") {\n _opts.http_method = 'PUT';\n }\n var _load = function() {\n _renkan.renderer.redrawActive = false;\n Rkns.$.getJSON(_opts.url, function(_data) {\n _proj.set(_data, {validate: true});\n _renkan.renderer.redrawActive = true;\n _renkan.renderer.autoScale();\n });\n };\n var _save = function() {\n var _data = _proj.toJSON();\n if (!_renkan.read_only) {\n Rkns.$.ajax({\n type: _opts.http_method,\n url: _opts.url,\n contentType: \"application/json\",\n data: JSON.stringify(_data),\n success: function(data, textStatus, jqXHR) {\n }\n });\n }\n\n };\n var _thrSave = Rkns._.throttle(\n function() {\n setTimeout(_save, 100);\n }, 1000);\n _proj.on(\"add:nodes add:edges add:users add:views\", function(_model) {\n _model.on(\"change remove\", function(_model) {\n _thrSave();\n });\n _thrSave();\n });\n _proj.on(\"change\", function() {\n _thrSave();\n });\n\n _load();\n};\n","/* Saves the Full JSON once */\n\nRkns.jsonIOSaveOnClick = function(_renkan, _opts) {\n var _proj = _renkan.project,\n _saveWarn = false,\n _onLeave = function() {\n return \"Project not saved\";\n };\n if (typeof _opts.http_method === \"undefined\") {\n _opts.http_method = 'POST';\n }\n var _load = function() {\n var getdata = {},\n rx = /id=([^&#?=]+)/,\n matches = document.location.hash.match(rx);\n if (matches) {\n getdata.id = matches[1];\n }\n Rkns.$.ajax({\n url: _opts.url,\n data: getdata,\n success: function(_data) {\n _proj.set(_data, {validate: true});\n \t_renkan.renderer.autoScale();\n }\n });\n };\n var _save = function() {\n _proj.set(\"saved_at\", new Date());\n var _data = _proj.toJSON();\n Rkns.$.ajax({\n type: _opts.http_method,\n url: _opts.url,\n contentType: \"application/json\",\n data: JSON.stringify(_data),\n success: function(data, textStatus, jqXHR) {\n $(window).off(\"beforeunload\", _onLeave);\n _saveWarn = false;\n //document.location.hash = \"#id=\" + data.id;\n //$(\".Rk-Notifications\").text(\"Saved as \"+document.location.href).fadeIn().delay(2000).fadeOut();\n }\n });\n };\n var _checkLeave = function() {\n var title = _proj.get(\"title\");\n if (title && _proj.get(\"nodes\").length) {\n $(\".Rk-Save-Button\").removeClass(\"disabled\");\n } else {\n $(\".Rk-Save-Button\").addClass(\"disabled\");\n }\n if (title) {\n $(\".Rk-PadTitle\").css(\"border-color\",\"#333333\");\n }\n if (!_saveWarn) {\n _saveWarn = true;\n $(window).on(\"beforeunload\", _onLeave);\n }\n };\n _load();\n _proj.on(\"add:nodes add:edges add:users change\", function(_model) {\n _model.on(\"change remove\", function(_model) {\n _checkLeave();\n });\n _checkLeave();\n });\n _renkan.renderer.save = function() {\n if ($(\".Rk-Save-Button\").hasClass(\"disabled\")) {\n if (!_proj.get(\"title\")) {\n $(\".Rk-PadTitle\").css(\"border-color\",\"#ff0000\");\n }\n } else {\n _save();\n }\n };\n};\n","(function(Rkns) {\n\"use strict\";\n\nvar _ = Rkns._;\n\nvar Ldt = Rkns.Ldt = {};\n\nvar Bin = Ldt.Bin = function(_renkan, _opts) {\n if (_opts.ldt_type) {\n var Resclass = Ldt[_opts.ldt_type+\"Bin\"];\n if (Resclass) {\n return new Resclass(_renkan, _opts);\n }\n }\n console.error(\"No such LDT Bin Type\");\n};\n\nvar ProjectBin = Ldt.ProjectBin = Rkns.Utils.inherit(Rkns._BaseBin);\n\nProjectBin.prototype.tagTemplate = _.template(\n '<li class=\"Rk-Bin-Item\" draggable=\"true\" data-image=\"<%- Rkns.Utils.getFullURL(static_url+\\'img/ldt-tag.png\\') %>\" data-uri=\"<%=ldt_platform%>ldtplatform/ldt/front/search/?search=<%=encodedtitle%>&field=all\" data-title=\"<%-title%>\" data-description=\"Tag \\'<%-title%>\\'\">' +\n '<img class=\"Rk-Ldt-Tag-Icon\" src=\"<%-static_url%>img/ldt-tag.png\" /><h4><%=htitle%></h4><div class=\"Rk-Clear\"></div></li>'\n);\n\nProjectBin.prototype.annotationTemplate = _.template(\n '<li class=\"Rk-Bin-Item\" draggable=\"true\" data-image=\"<%- Rkns.Utils.getFullURL(image) %>\" data-uri=\"<%=ldt_platform%>ldtplatform/ldt/front/player/<%=mediaid%>/#id=<%=annotationid%>\" data-title=\"<%-title%>\" data-description=\"<%-description%>\">' +\n '<img class=\"Rk-Ldt-Annotation-Icon\" src=\"<%=image%>\"/><h4><%=htitle%></h4><p><%=hdescription%></p><p>Start: <%=start%>, End: <%=end%>, Duration: <%=duration%></p><div class=\"Rk-Clear\"></div></li>'\n);\n\nProjectBin.prototype._init = function(_renkan, _opts) {\n this.renkan = _renkan;\n this.proj_id = _opts.project_id;\n this.ldt_platform = _opts.ldt_platform || \"http://ldt.iri.centrepompidou.fr/\";\n this.title_$.html(_opts.title);\n this.title_icon_$.addClass('Rk-Ldt-Title-Icon');\n this.refresh();\n};\n\nProjectBin.prototype.render = function(searchbase) {\n var search = searchbase || Rkns.Utils.regexpFromTextOrArray();\n function highlight(_text) {\n var _e = _(_text).escape();\n return search.isempty ? _e : search.replace(_e, \"<span class='searchmatch'>$1</span>\");\n }\n function convertTC(_ms) {\n function pad(_n) {\n var _res = _n.toString();\n while (_res.length < 2) {\n _res = '0' + _res;\n }\n return _res;\n }\n var _totalSeconds = Math.abs(Math.floor(_ms/1000)),\n _hours = Math.floor(_totalSeconds / 3600),\n _minutes = (Math.floor(_totalSeconds / 60) % 60),\n _seconds = _totalSeconds % 60,\n _res = '';\n if (_hours) {\n _res += pad(_hours) + ':';\n }\n _res += pad(_minutes) + ':' + pad(_seconds);\n return _res;\n }\n\n var _html = '<li><h3>Tags</h3></li>',\n _projtitle = this.data.meta[\"dc:title\"],\n _this = this,\n count = 0;\n _this.title_$.text('LDT Project: \"' + _projtitle + '\"');\n _(_this.data.tags).map(function(_tag) {\n var _title = _tag.meta[\"dc:title\"];\n if (!search.isempty && !search.test(_title)) {\n return;\n }\n count++;\n _html += _this.tagTemplate({\n ldt_platform: _this.ldt_platform,\n title: _title,\n htitle: highlight(_title),\n encodedtitle : encodeURIComponent(_title),\n static_url: _this.renkan.options.static_url\n });\n });\n _html += '<li><h3>Annotations</h3></li>';\n _(_this.data.annotations).map(function(_annotation) {\n var _description = _annotation.content.description,\n _title = _annotation.content.title.replace(_description,\"\");\n if (!search.isempty && !search.test(_title) && !search.test(_description)) {\n return;\n }\n count++;\n var _duration = _annotation.end - _annotation.begin,\n _img = (\n (_annotation.content && _annotation.content.img && _annotation.content.img.src) ?\n _annotation.content.img.src :\n ( _duration ? _this.renkan.options.static_url+\"img/ldt-segment.png\" : _this.renkan.options.static_url+\"img/ldt-point.png\" )\n );\n _html += _this.annotationTemplate({\n ldt_platform: _this.ldt_platform,\n title: _title,\n htitle: highlight(_title),\n description: _description,\n hdescription: highlight(_description),\n start: convertTC(_annotation.begin),\n end: convertTC(_annotation.end),\n duration: convertTC(_duration),\n mediaid: _annotation.media,\n annotationid: _annotation.id,\n image: _img,\n static_url: _this.renkan.options.static_url\n });\n });\n\n this.main_$.html(_html);\n if (!search.isempty && count) {\n this.count_$.text(count).show();\n } else {\n this.count_$.hide();\n }\n if (!search.isempty && !count) {\n this.$.hide();\n } else {\n this.$.show();\n }\n this.renkan.resizeBins();\n};\n\nProjectBin.prototype.refresh = function() {\n var _this = this;\n Rkns.$.ajax({\n url: this.ldt_platform + 'ldtplatform/ldt/cljson/id/' + this.proj_id,\n dataType: \"jsonp\",\n success: function(_data) {\n _this.data = _data;\n _this.render();\n }\n });\n};\n\nvar Search = Ldt.Search = function(_renkan, _opts) {\n this.renkan = _renkan;\n this.lang = _opts.lang || \"en\";\n};\n\nSearch.prototype.getBgClass = function() {\n return \"Rk-Ldt-Icon\";\n};\n\nSearch.prototype.getSearchTitle = function() {\n return this.renkan.translate(\"Lignes de Temps\");\n};\n\nSearch.prototype.search = function(_q) {\n this.renkan.tabs.push(\n new ResultsBin(this.renkan, {\n search: _q\n })\n );\n};\n\nvar ResultsBin = Ldt.ResultsBin = Rkns.Utils.inherit(Rkns._BaseBin);\n\nResultsBin.prototype.segmentTemplate = _.template(\n '<li class=\"Rk-Bin-Item\" draggable=\"true\" data-image=\"<%- Rkns.Utils.getFullURL(image) %>\" data-uri=\"<%=ldt_platform%>ldtplatform/ldt/front/player/<%=mediaid%>/#id=<%=annotationid%>\" data-title=\"<%-title%>\" data-description=\"<%-description%>\">' +\n '<img class=\"Rk-Ldt-Annotation-Icon\" src=\"<%=image%>\"/><h4><%=htitle%></h4><p><%=hdescription%></p><p>Start: <%=start%>, End: <%=end%>, Duration: <%=duration%></p><div class=\"Rk-Clear\"></div></li>'\n);\n\nResultsBin.prototype._init = function(_renkan, _opts) {\n this.renkan = _renkan;\n this.ldt_platform = _opts.ldt_platform || \"http://ldt.iri.centrepompidou.fr/\";\n this.max_results = _opts.max_results || 50;\n this.search = _opts.search;\n this.title_$.html('Lignes de Temps: \"' + _opts.search + '\"');\n this.title_icon_$.addClass('Rk-Ldt-Title-Icon');\n this.refresh();\n};\n\nResultsBin.prototype.render = function(searchbase) {\n if (!this.data) {\n return;\n }\n var search = searchbase || Rkns.Utils.regexpFromTextOrArray();\n var highlightrx = (search.isempty ? Rkns.Utils.regexpFromTextOrArray(this.search) : search);\n function highlight(_text) {\n return highlightrx.replace(_(_text).escape(), \"<span class='searchmatch'>$1</span>\");\n }\n function convertTC(_ms) {\n function pad(_n) {\n var _res = _n.toString();\n while (_res.length < 2) {\n _res = '0' + _res;\n }\n return _res;\n }\n var _totalSeconds = Math.abs(Math.floor(_ms/1000)),\n _hours = Math.floor(_totalSeconds / 3600),\n _minutes = (Math.floor(_totalSeconds / 60) % 60),\n _seconds = _totalSeconds % 60,\n _res = '';\n if (_hours) {\n _res += pad(_hours) + ':';\n }\n _res += pad(_minutes) + ':' + pad(_seconds);\n return _res;\n }\n\n var _html = '',\n _this = this,\n count = 0;\n _(this.data.objects).each(function(_segment) {\n var _description = _segment.abstract,\n _title = _segment.title;\n if (!search.isempty && !search.test(_title) && !search.test(_description)) {\n return;\n }\n count++;\n var _duration = _segment.duration,\n _begin = _segment.start_ts,\n _end = + _segment.duration + _begin,\n _img = (\n _duration ?\n _this.renkan.options.static_url + \"img/ldt-segment.png\" :\n _this.renkan.options.static_url + \"img/ldt-point.png\"\n );\n _html += _this.segmentTemplate({\n ldt_platform: _this.ldt_platform,\n title: _title,\n htitle: highlight(_title),\n description: _description,\n hdescription: highlight(_description),\n start: convertTC(_begin),\n end: convertTC(_end),\n duration: convertTC(_duration),\n mediaid: _segment.iri_id,\n //projectid: _segment.project_id,\n //cuttingid: _segment.cutting_id,\n annotationid: _segment.element_id,\n image: _img\n });\n });\n\n this.main_$.html(_html);\n if (!search.isempty && count) {\n this.count_$.text(count).show();\n } else {\n this.count_$.hide();\n }\n if (!search.isempty && !count) {\n this.$.hide();\n } else {\n this.$.show();\n }\n this.renkan.resizeBins();\n};\n\nResultsBin.prototype.refresh = function() {\n var _this = this;\n Rkns.$.ajax({\n url: this.ldt_platform + 'ldtplatform/api/ldt/1.0/segments/search/',\n data: {\n format: \"jsonp\",\n q: this.search,\n limit: this.max_results\n },\n dataType: \"jsonp\",\n success: function(_data) {\n _this.data = _data;\n _this.render();\n }\n });\n};\n\n})(window.Rkns);\n","Rkns.ResourceList = {};\n\nRkns.ResourceList.Bin = Rkns.Utils.inherit(Rkns._BaseBin);\n\nRkns.ResourceList.Bin.prototype.resultTemplate = Rkns._.template(\n '<li class=\"Rk-Bin-Item Rk-ResourceList-Item\" draggable=\"true\" data-uri=\"<%-url%>\" ' +\n 'data-title=\"<%-title%>\" data-description=\"<%-description%>\" ' +\n '<% if (image) { %>data-image=\"<%- Rkns.Utils.getFullURL(image) %>\"<% } else { %>data-image=\"\"<% } %> >' +\n '<% if (image) { %><img class=\"Rk-ResourceList-Image\" src=\"<%-image%>\"/><% } %><h4 class=\"Rk-ResourceList-Title\">' +\n '<% if (url) { %><a href=\"<%-url%>\" target=\"_blank\"><% } %><%=htitle%><% if (url) { %></a><% } %></h4>' +\n '<% if (description) { %><p class=\"Rk-ResourceList-Description\"><%=hdescription%></p><% } %><% if (image) { %><div style=\"clear: both;\"></div><% } %></li>'\n);\n\nRkns.ResourceList.Bin.prototype._init = function(_renkan, _opts) {\n this.renkan = _renkan;\n this.title_$.html(_opts.title);\n if (_opts.list) {\n this.data = _opts.list;\n }\n this.refresh();\n};\n\nRkns.ResourceList.Bin.prototype.render = function(searchbase) {\n var search = searchbase || Rkns.Utils.regexpFromTextOrArray();\n function highlight(_text) {\n var _e = _(_text).escape();\n return search.isempty ? _e : search.replace(_e, \"<span class='searchmatch'>$1</span>\");\n }\n var _html = \"\",\n _this = this,\n count = 0;\n Rkns._(this.data).each(function(_item) {\n var _element;\n if (typeof _item === \"string\") {\n if (/^(https?:\\/\\/|www)/.test(_item)) {\n _element = { url: _item };\n } else {\n _element = { title: _item.replace(/[:,]?\\s?(https?:\\/\\/|www)[\\d\\w\\/.&?=#%-_]+\\s?/,'').trim() };\n var _match = _item.match(/(https?:\\/\\/|www)[\\d\\w\\/.&?=#%-_]+/);\n if (_match) {\n _element.url = _match[0];\n }\n if (_element.title.length > 80) {\n _element.description = _element.title;\n _element.title = _element.title.replace(/^(.{30,60})\\s.+$/,'$1…');\n }\n }\n } else {\n _element = _item;\n }\n var title = _element.title || (_element.url || \"\").replace(/^https?:\\/\\/(www\\.)?/,'').replace(/^(.{40}).+$/,'$1…'),\n url = _element.url || \"\",\n description = _element.description || \"\",\n image = _element.image || \"\";\n if (url && !/^https?:\\/\\//.test(url)) {\n url = 'http://' + url;\n }\n if (!search.isempty && !search.test(title) && !search.test(description)) {\n return;\n }\n count++;\n _html += _this.resultTemplate({\n url: url,\n title: title,\n htitle: highlight(title),\n image: image,\n description: description,\n hdescription: highlight(description),\n static_url: _this.renkan.options.static_url\n });\n });\n _this.main_$.html(_html);\n if (!search.isempty && count) {\n this.count_$.text(count).show();\n } else {\n this.count_$.hide();\n }\n if (!search.isempty && !count) {\n this.$.hide();\n } else {\n this.$.show();\n }\n this.renkan.resizeBins();\n};\n\nRkns.ResourceList.Bin.prototype.refresh = function() {\n if (this.data) {\n this.render();\n }\n};\n","Rkns.Wikipedia = {\n};\n\nRkns.Wikipedia.Search = function(_renkan, _opts) {\n this.renkan = _renkan;\n this.lang = _opts.lang || \"en\";\n};\n\nRkns.Wikipedia.Search.prototype.getBgClass = function() {\n return \"Rk-Wikipedia-Search-Icon Rk-Wikipedia-Lang-\" + this.lang;\n};\n\nRkns.Wikipedia.Search.prototype.getSearchTitle = function() {\n var langs = {\n \"fr\": \"French\",\n \"en\": \"English\",\n \"ja\": \"Japanese\"\n };\n if (langs[this.lang]) {\n return this.renkan.translate(\"Wikipedia in \") + this.renkan.translate(langs[this.lang]);\n } else {\n return this.renkan.translate(\"Wikipedia\") + \" [\" + this.lang + \"]\";\n }\n};\n\nRkns.Wikipedia.Search.prototype.search = function(_q) {\n this.renkan.tabs.push(\n new Rkns.Wikipedia.Bin(this.renkan, {\n lang: this.lang,\n search: _q\n })\n );\n};\n\nRkns.Wikipedia.Bin = Rkns.Utils.inherit(Rkns._BaseBin);\n\nRkns.Wikipedia.Bin.prototype.resultTemplate = Rkns._.template(\n '<li class=\"Rk-Wikipedia-Result Rk-Bin-Item\" draggable=\"true\" data-uri=\"<%-url%>\" ' +\n 'data-title=\"Wikipedia: <%-title%>\" data-description=\"<%-description%>\" data-image=\"<%- Rkns.Utils.getFullURL( static_url + \\'img/wikipedia.png\\' ) %>\">' +\n '<img class=\"Rk-Wikipedia-Icon\" src=\"<%-static_url%>img/wikipedia.png\"></div><h4 class=\"Rk-Wikipedia-Title\"><a href=\"<%-url%>\" target=\"_blank\"><%=htitle%></a></h4>' +\n '<p class=\"Rk-Wikipedia-Snippet\"><%=hdescription%></p></li>'\n);\n\nRkns.Wikipedia.Bin.prototype._init = function(_renkan, _opts) {\n this.renkan = _renkan;\n this.search = _opts.search;\n this.lang = _opts.lang || \"en\";\n this.title_icon_$.addClass('Rk-Wikipedia-Title-Icon Rk-Wikipedia-Lang-' + this.lang);\n this.title_$.html(this.search).addClass(\"Rk-Wikipedia-Title\");\n this.refresh();\n};\n\nRkns.Wikipedia.Bin.prototype.render = function(searchbase) {\n var search = searchbase || Rkns.Utils.regexpFromTextOrArray();\n var highlightrx = (search.isempty ? Rkns.Utils.regexpFromTextOrArray(this.search) : search);\n function highlight(_text) {\n return highlightrx.replace(_(_text).escape(), \"<span class='searchmatch'>$1</span>\");\n }\n var _html = \"\",\n _this = this,\n count = 0;\n Rkns._(this.data.query.search).each(function(_result) {\n var title = _result.title,\n url = \"http://\" + _this.lang + \".wikipedia.org/wiki/\" + encodeURI(title.replace(/ /g,\"_\")),\n description = Rkns.$('<div>').html(_result.snippet).text();\n if (!search.isempty && !search.test(title) && !search.test(description)) {\n return;\n }\n count++;\n _html += _this.resultTemplate({\n url: url,\n title: title,\n htitle: highlight(title),\n description: description,\n hdescription: highlight(description),\n static_url: _this.renkan.options.static_url\n });\n });\n _this.main_$.html(_html);\n if (!search.isempty && count) {\n this.count_$.text(count).show();\n } else {\n this.count_$.hide();\n }\n if (!search.isempty && !count) {\n this.$.hide();\n } else {\n this.$.show();\n }\n this.renkan.resizeBins();\n};\n\nRkns.Wikipedia.Bin.prototype.refresh = function() {\n var _this = this;\n Rkns.$.ajax({\n url: \"http://\" + _this.lang + \".wikipedia.org/w/api.php?action=query&list=search&srsearch=\" + encodeURIComponent(this.search) + \"&format=json\",\n dataType: \"jsonp\",\n success: function(_data) {\n _this.data = _data;\n _this.render();\n }\n });\n};\n","\ndefine('renderer/baserepresentation',['jquery', 'underscore'], function ($, _) {\n \n\n /* Rkns.Renderer._BaseRepresentation Class */\n\n /* In Renkan, a \"Representation\" is a sort of ViewModel (in the MVVM paradigm) and bridges the gap between\n * models (written with Backbone.js) and the view (written with Paper.js)\n * Renkan's representations all inherit from Rkns.Renderer._BaseRepresentation '*/\n\n var _BaseRepresentation = function(_renderer, _model) {\n if (typeof _renderer !== \"undefined\") {\n this.renderer = _renderer;\n this.renkan = _renderer.renkan;\n this.project = _renderer.renkan.project;\n this.options = _renderer.renkan.options;\n this.model = _model;\n if (this.model) {\n var _this = this;\n this._changeBinding = function() {\n _this.redraw();\n };\n this._removeBinding = function() {\n _renderer.removeRepresentation(_this);\n _(function() {\n _renderer.redraw();\n }).defer();\n };\n this._selectBinding = function() {\n _this.select();\n };\n this._unselectBinding = function() {\n _this.unselect();\n };\n this.model.on(\"change\", this._changeBinding );\n this.model.on(\"remove\", this._removeBinding );\n this.model.on(\"select\", this._selectBinding );\n this.model.on(\"unselect\", this._unselectBinding );\n }\n }\n };\n\n /* Rkns.Renderer._BaseRepresentation Methods */\n\n _(_BaseRepresentation.prototype).extend({\n _super: function(_func) {\n return _BaseRepresentation.prototype[_func].apply(this, Array.prototype.slice.call(arguments, 1));\n },\n redraw: function() {},\n moveTo: function() {},\n show: function() { return \"chaud cacao\"; },\n hide: function() {},\n select: function() {\n if (this.model) {\n this.model.trigger(\"selected\");\n }\n },\n unselect: function() {\n if (this.model) {\n this.model.trigger(\"unselected\");\n }\n },\n highlight: function() {},\n unhighlight: function() {},\n mousedown: function() {},\n mouseup: function() {\n if (this.model) {\n this.model.trigger(\"clicked\");\n }\n },\n destroy: function() {\n if (this.model) {\n this.model.off(\"change\", this._changeBinding );\n this.model.off(\"remove\", this._removeBinding );\n this.model.off(\"select\", this._selectBinding );\n this.model.off(\"unselect\", this._unselectBinding );\n }\n }\n });\n\n /* End of Rkns.Renderer._BaseRepresentation Class */\n\n return _BaseRepresentation;\n\n});\n\ndefine('requtils',[], function ($, _) {\n \n return {\n getUtils: function(){\n return window.Rkns.Utils;\n },\n getRenderer: function(){\n return window.Rkns.Renderer;\n }\n };\n\n});\n\n\ndefine('renderer/basebutton',['jquery', 'underscore', 'requtils', 'renderer/baserepresentation'], function ($, _, requtils, BaseRepresentation) {\n \n\n var Utils = requtils.getUtils();\n\n /* Rkns.Renderer._BaseButton Class */\n\n /* BaseButton is extended by contextual buttons that appear when hovering on nodes and edges */\n\n var _BaseButton = Utils.inherit(BaseRepresentation);\n\n _(_BaseButton.prototype).extend({\n moveTo: function(_pos) {\n this.sector.moveTo(_pos);\n },\n show: function() {\n this.sector.show();\n },\n hide: function() {\n this.sector.hide();\n },\n select: function() {\n this.sector.select();\n },\n unselect: function(_newTarget) {\n this.sector.unselect();\n if (!_newTarget || (_newTarget !== this.source_representation && _newTarget.source_representation !== this.source_representation)) {\n this.source_representation.unselect();\n }\n },\n destroy: function() {\n this.sector.destroy();\n }\n });\n\n return _BaseButton;\n\n});\n\n\ndefine('renderer/shapebuilder',[], function () {\n \n\n /* ShapeBuilder Begin */\n\n var builders = {\n \"circle\":{\n getShape: function() {\n return new paper.Path.Circle([0, 0], 1);\n },\n getImageShape: function(center, radius) {\n return new paper.Path.Circle(center, radius);\n }\n },\n \"rectangle\":{\n getShape: function() {\n return new paper.Path.Rectangle([-2, -2], [2, 2]);\n },\n getImageShape: function(center, radius) {\n return new paper.Path.Rectangle([-radius, -radius], [radius*2, radius*2]);\n }\n },\n \"ellipse\":{\n getShape: function() {\n return new paper.Path.Ellipse(new paper.Rectangle([-2, -1], [2, 1]));\n },\n getImageShape: function(center, radius) {\n return new paper.Path.Ellipse(new paper.Rectangle([-radius, -radius/2], [radius*2, radius]));\n }\n },\n \"polygon\":{\n getShape: function() {\n return new paper.Path.RegularPolygon([0, 0], 6, 1);\n },\n getImageShape: function(center, radius) {\n return new paper.Path.RegularPolygon([0, 0], 6, radius);\n }\n },\n \"diamond\":{\n getShape: function() {\n var d = new paper.Path.Rectangle([-2, -2], [2, 2]);\n d.rotate(45);\n return d;\n },\n getImageShape: function(center, radius) {\n var d = new paper.Path.Rectangle([-radius, -radius], [radius*2, radius*2]);\n d.rotate(45);\n return d;\n }\n },\n \"star\":{\n getShape: function() {\n return new paper.Path.Star([0, 0], 8, 1, 0.7);\n },\n getImageShape: function(center, radius) {\n return new paper.Path.Star([0, 0], 8, radius*1, radius*0.7);\n }\n },\n \"svg\": function(path){\n return {\n getShape: function() {\n return new paper.Path(path);\n },\n getImageShape: function(center, radius) {\n // No calcul for the moment \n return new paper.Path();\n }\n };\n }\n };\n \n var ShapeBuilder = function (shape){\n if(typeof shape===\"undefined\"){\n shape = \"circle\";\n }\n if(shape.substr(0,4)===\"svg:\"){\n return builders.svg(shape.substr(4));\n }\n if(!(shape in builders)){\n shape = \"circle\";\n }\n return builders[shape];\n };\n \n return ShapeBuilder;\n\n});\n\ndefine('renderer/noderepr',['jquery', 'underscore', 'requtils', 'renderer/baserepresentation', 'renderer/shapebuilder'], function ($, _, requtils, BaseRepresentation, ShapeBuilder) {\n \n\n var Utils = requtils.getUtils();\n\n /* Rkns.Renderer.Node Class */\n\n /* The representation for the node : A circle, with an image inside and a text label underneath.\n * The circle and the image are drawn on canvas and managed by Paper.js.\n * The text label is an HTML node, managed by jQuery. */\n\n //var NodeRepr = Renderer.Node = Utils.inherit(Renderer._BaseRepresentation);\n var NodeRepr = Utils.inherit(BaseRepresentation);\n\n _(NodeRepr.prototype).extend({\n _init: function() {\n this.renderer.node_layer.activate();\n this.type = \"Node\";\n this.buildShape();\n if (this.options.show_node_circles) {\n this.circle.strokeWidth = this.options.node_stroke_width;\n this.h_ratio = 1;\n } else {\n this.h_ratio = 0;\n }\n this.title = $('<div class=\"Rk-Label\">').appendTo(this.renderer.labels_$);\n \n if (this.options.editor_mode) {\n var Renderer = requtils.getRenderer();\n this.normal_buttons = [\n new Renderer.NodeEditButton(this.renderer, null),\n new Renderer.NodeRemoveButton(this.renderer, null),\n new Renderer.NodeLinkButton(this.renderer, null),\n new Renderer.NodeEnlargeButton(this.renderer, null),\n new Renderer.NodeShrinkButton(this.renderer, null)\n ];\n this.pending_delete_buttons = [\n new Renderer.NodeRevertButton(this.renderer, null)\n ];\n this.all_buttons = this.normal_buttons.concat(this.pending_delete_buttons);\n \n for (var i = 0; i < this.all_buttons.length; i++) {\n this.all_buttons[i].source_representation = this;\n }\n this.active_buttons = [];\n } else {\n this.active_buttons = this.all_buttons = [];\n }\n this.last_circle_radius = 1;\n\n if (this.renderer.minimap) {\n this.renderer.minimap.node_layer.activate();\n this.minimap_circle = new paper.Path.Circle([0, 0], 1);\n this.minimap_circle.__representation = this.renderer.minimap.miniframe.__representation;\n this.renderer.minimap.node_group.addChild(this.minimap_circle);\n }\n },\n buildShape: function(){\n if(typeof this.model.get(\"shape_changed\")!==\"undefined\" && this.model.get(\"shape_changed\")===true){\n this.model.set(\"shape_changed\", false);\n delete this.img;\n }\n if(this.circle){\n this.circle.remove();\n delete this.circle;\n }\n // \"circle\" \"rectangle\" \"ellipse\" \"polygon\" \"star\" \"diamond\"\n this.shapeBuilder = new ShapeBuilder(this.model.get(\"shape\"));\n this.circle = this.shapeBuilder.getShape();\n this.circle.__representation = this;\n this.last_circle_radius = 1;\n },\n redraw: function(_dontRedrawEdges) {\n if(typeof this.model.get(\"shape_changed\")!==\"undefined\" && this.model.get(\"shape_changed\")===true){\n this.buildShape();\n }\n var _model_coords = new paper.Point(this.model.get(\"position\")),\n _baseRadius = this.options.node_size_base * Math.exp((this.model.get(\"size\") || 0) * Utils._NODE_SIZE_STEP);\n if (!this.is_dragging || !this.paper_coords) {\n this.paper_coords = this.renderer.toPaperCoords(_model_coords);\n }\n this.circle_radius = _baseRadius * this.renderer.scale;\n if (this.last_circle_radius !== this.circle_radius) {\n this.all_buttons.forEach(function(b) {\n b.setSectorSize();\n });\n this.circle.scale(this.circle_radius / this.last_circle_radius);\n if (this.node_image) {\n this.node_image.scale(this.circle_radius / this.last_circle_radius);\n }\n }\n this.circle.position = this.paper_coords;\n if (this.node_image) {\n this.node_image.position = this.paper_coords.subtract(this.image_delta.multiply(this.circle_radius));\n }\n this.last_circle_radius = this.circle_radius;\n\n var old_act_btn = this.active_buttons;\n\n var opacity = 1;\n if (this.model.get(\"delete_scheduled\")) {\n opacity = 0.5;\n this.active_buttons = this.pending_delete_buttons;\n this.circle.dashArray = [2,2];\n } else {\n opacity = 1;\n this.active_buttons = this.normal_buttons;\n this.circle.dashArray = null;\n }\n\n if (this.selected && this.renderer.isEditable()) {\n if (old_act_btn !== this.active_buttons) {\n old_act_btn.forEach(function(b) {\n b.hide();\n });\n }\n this.active_buttons.forEach(function(b) {\n b.show();\n });\n }\n\n if (this.node_image) {\n this.node_image.opacity = this.highlighted ? opacity * 0.5 : (opacity - 0.01);\n }\n\n this.circle.fillColor = this.highlighted ? this.options.highlighted_node_fill_color : this.options.node_fill_color;\n\n this.circle.opacity = this.options.show_node_circles ? opacity : 0.01;\n\n var _text = this.model.get(\"title\") || this.renkan.translate(this.options.label_untitled_nodes) || \"\";\n _text = Utils.shortenText(_text, this.options.node_label_max_length);\n\n if (typeof this.highlighted === \"object\") {\n this.title.html(this.highlighted.replace(_(_text).escape(),'<span class=\"Rk-Highlighted\">$1</span>'));\n } else {\n this.title.text(_text);\n }\n\n this.title.css({\n left: this.paper_coords.x,\n top: this.paper_coords.y + this.circle_radius * this.h_ratio + this.options.node_label_distance,\n opacity: opacity\n });\n var _color = this.model.get(\"color\") || (this.model.get(\"created_by\") || Utils._USER_PLACEHOLDER(this.renkan)).get(\"color\");\n this.circle.strokeColor = _color;\n var _pc = this.paper_coords;\n this.all_buttons.forEach(function(b) {\n b.moveTo(_pc);\n });\n var lastImage = this.img;\n this.img = this.model.get(\"image\");\n if (this.img && this.img !== lastImage) {\n this.showImage();\n }\n if (this.node_image && !this.img) {\n this.node_image.remove();\n delete this.node_image;\n }\n\n if (this.renderer.minimap) {\n this.minimap_circle.fillColor = _color;\n var minipos = this.renderer.toMinimapCoords(_model_coords),\n miniradius = this.renderer.minimap.scale * _baseRadius,\n minisize = new paper.Size([miniradius, miniradius]);\n this.minimap_circle.fitBounds(minipos.subtract(minisize), minisize.multiply(2));\n }\n\n if (!_dontRedrawEdges) {\n var _this = this;\n _.each(\n this.project.get(\"edges\").filter(\n function (ed) {\n return ((ed.get(\"to\") === _this.model) || (ed.get(\"from\") === _this.model));\n }\n ),\n function(edge, index, list) {\n var repr = _this.renderer.getRepresentationByModel(edge);\n if (repr && typeof repr.from_representation !== \"undefined\" && typeof repr.from_representation.paper_coords !== \"undefined\" && typeof repr.to_representation !== \"undefined\" && typeof repr.to_representation.paper_coords !== \"undefined\") {\n repr.redraw();\n }\n }\n );\n }\n\n },\n showImage: function() {\n var _image = null;\n if (typeof this.renderer.image_cache[this.img] === \"undefined\") {\n _image = new Image();\n this.renderer.image_cache[this.img] = _image;\n _image.src = this.img;\n } else {\n _image = this.renderer.image_cache[this.img];\n }\n if (_image.width) {\n if (this.node_image) {\n this.node_image.remove();\n }\n this.renderer.node_layer.activate();\n var width = _image.width,\n height = _image.height,\n clipPath = this.model.get(\"clip_path\"),\n hasClipPath = (typeof clipPath !== \"undefined\" && clipPath),\n _clip = null,\n baseRadius = null,\n centerPoint = null;\n \n if (hasClipPath) {\n _clip = new paper.Path();\n var instructions = clipPath.match(/[a-z][^a-z]+/gi) || [],\n lastCoords = [0,0],\n minX = Infinity,\n minY = Infinity,\n maxX = -Infinity,\n maxY = -Infinity;\n\n var transformCoords = function(tabc, relative) {\n var newCoords = tabc.slice(1).map(function(v, k) {\n var res = parseFloat(v),\n isY = k % 2;\n if (isY) {\n res = ( res - 0.5 ) * height;\n } else {\n res = ( res - 0.5 ) * width;\n }\n if (relative) {\n res += lastCoords[isY];\n }\n if (isY) {\n minY = Math.min(minY, res);\n maxY = Math.max(maxY, res);\n } else {\n minX = Math.min(minX, res);\n maxX = Math.max(maxX, res);\n }\n return res;\n });\n lastCoords = newCoords.slice(-2);\n return newCoords;\n };\n\n instructions.forEach(function(instr) {\n var coords = instr.match(/([a-z]|[0-9.-]+)/ig) || [\"\"];\n switch(coords[0]) {\n case \"M\":\n _clip.moveTo(transformCoords(coords));\n break;\n case \"m\":\n _clip.moveTo(transformCoords(coords, true));\n break;\n case \"L\":\n _clip.lineTo(transformCoords(coords));\n break;\n case \"l\":\n _clip.lineTo(transformCoords(coords, true));\n break;\n case \"C\":\n _clip.cubicCurveTo(transformCoords(coords));\n break;\n case \"c\":\n _clip.cubicCurveTo(transformCoords(coords, true));\n break;\n case \"Q\":\n _clip.quadraticCurveTo(transformCoords(coords));\n break;\n case \"q\":\n _clip.quadraticCurveTo(transformCoords(coords, true));\n break;\n }\n });\n\n baseRadius = Math[this.options.node_images_fill_mode ? \"min\" : \"max\"](maxX - minX, maxY - minY) / 2;\n centerPoint = new paper.Point((maxX + minX) / 2, (maxY + minY) / 2);\n if (!this.options.show_node_circles) {\n this.h_ratio = (maxY - minY) / (2 * baseRadius);\n }\n } else {\n baseRadius = Math[this.options.node_images_fill_mode ? \"min\" : \"max\"](width, height) / 2;\n centerPoint = new paper.Point(0,0);\n if (!this.options.show_node_circles) {\n this.h_ratio = height / (2 * baseRadius);\n }\n }\n var _raster = new paper.Raster(_image);\n _raster.locked = true; // Disable mouse events on icon\n if (hasClipPath) {\n _raster = new paper.Group(_clip, _raster);\n _raster.opacity = 0.99;\n /* This is a workaround to allow clipping at group level\n * If opacity was set to 1, paper.js would merge all clipping groups in one (known bug).\n */\n _raster.clipped = true;\n _clip.__representation = this;\n }\n if (this.options.clip_node_images) {\n var _circleClip = this.shapeBuilder.getImageShape(centerPoint, baseRadius);\n _raster = new paper.Group(_circleClip, _raster);\n _raster.opacity = 0.99;\n _raster.clipped = true;\n _circleClip.__representation = this;\n }\n this.image_delta = centerPoint.divide(baseRadius);\n this.node_image = _raster;\n this.node_image.__representation = _this;\n this.node_image.scale(this.circle_radius / baseRadius);\n this.node_image.position = this.paper_coords.subtract(this.image_delta.multiply(this.circle_radius));\n this.redraw();\n this.renderer.throttledPaperDraw();\n } else {\n var _this = this;\n $(_image).on(\"load\", function() {\n _this.showImage();\n });\n }\n },\n paperShift: function(_delta) {\n if (this.options.editor_mode) {\n if (!this.renkan.read_only) {\n this.is_dragging = true;\n this.paper_coords = this.paper_coords.add(_delta);\n this.redraw();\n }\n } else {\n this.renderer.paperShift(_delta);\n }\n },\n openEditor: function() {\n this.renderer.removeRepresentationsOfType(\"editor\");\n var _editor = this.renderer.addRepresentation(\"NodeEditor\",null);\n _editor.source_representation = this;\n _editor.draw();\n },\n select: function() {\n this.selected = true;\n this.circle.strokeWidth = this.options.selected_node_stroke_width;\n if (this.renderer.isEditable()) {\n this.active_buttons.forEach(function(b) {\n b.show();\n });\n }\n var _uri = this.model.get(\"uri\");\n if (_uri) {\n $('.Rk-Bin-Item').each(function() {\n var _el = $(this);\n if (_el.attr(\"data-uri\") === _uri) {\n _el.addClass(\"selected\");\n }\n });\n }\n if (!this.options.editor_mode) {\n this.openEditor();\n }\n\n if (this.renderer.minimap) {\n this.minimap_circle.strokeWidth = this.options.minimap_highlight_weight;\n this.minimap_circle.strokeColor = this.options.minimap_highlight_color;\n }\n this._super(\"select\");\n },\n unselect: function(_newTarget) {\n if (!_newTarget || _newTarget.source_representation !== this) {\n this.selected = false;\n this.all_buttons.forEach(function(b) {\n b.hide();\n });\n this.circle.strokeWidth = this.options.node_stroke_width;\n $('.Rk-Bin-Item').removeClass(\"selected\");\n if (this.renderer.minimap) {\n this.minimap_circle.strokeColor = undefined;\n }\n this._super(\"unselect\");\n }\n },\n highlight: function(textToReplace) {\n var hlvalue = textToReplace || true;\n if (this.highlighted === hlvalue) {\n return;\n }\n this.highlighted = hlvalue;\n this.redraw();\n this.renderer.throttledPaperDraw();\n },\n unhighlight: function() {\n if (!this.highlighted) {\n return;\n }\n this.highlighted = false;\n this.redraw();\n this.renderer.throttledPaperDraw();\n },\n saveCoords: function() {\n var _coords = this.renderer.toModelCoords(this.paper_coords),\n _data = {\n position: {\n x: _coords.x,\n y: _coords.y\n }\n };\n if (this.renderer.isEditable()) {\n this.model.set(_data);\n }\n },\n mousedown: function(_event, _isTouch) {\n if (_isTouch) {\n this.renderer.unselectAll();\n this.select();\n }\n },\n mouseup: function(_event, _isTouch) {\n if (this.renderer.is_dragging && this.renderer.isEditable()) {\n this.saveCoords();\n } else {\n if (!_isTouch && !this.model.get(\"delete_scheduled\")) {\n this.openEditor();\n }\n this.model.trigger(\"clicked\");\n }\n this.renderer.click_target = null;\n this.renderer.is_dragging = false;\n this.is_dragging = false;\n },\n destroy: function(_event) {\n this._super(\"destroy\");\n this.all_buttons.forEach(function(b) {\n b.destroy();\n });\n this.circle.remove();\n this.title.remove();\n if (this.renderer.minimap) {\n this.minimap_circle.remove();\n }\n if (this.node_image) {\n this.node_image.remove();\n }\n }\n });\n\n return NodeRepr;\n\n});\n\n\ndefine('renderer/edge',['jquery', 'underscore', 'requtils', 'renderer/baserepresentation'], function ($, _, requtils, BaseRepresentation) {\n \n\n var Utils = requtils.getUtils();\n\n /* Edge Class Begin */\n\n //var Edge = Renderer.Edge = Utils.inherit(Renderer._BaseRepresentation);\n var Edge = Utils.inherit(BaseRepresentation);\n\n _(Edge.prototype).extend({\n _init: function() {\n this.renderer.edge_layer.activate();\n this.type = \"Edge\";\n this.from_representation = this.renderer.getRepresentationByModel(this.model.get(\"from\"));\n this.to_representation = this.renderer.getRepresentationByModel(this.model.get(\"to\"));\n this.bundle = this.renderer.addToBundles(this);\n this.line = new paper.Path();\n this.line.add([0,0],[0,0],[0,0]);\n this.line.__representation = this;\n this.line.strokeWidth = this.options.edge_stroke_width;\n this.arrow = new paper.Path();\n this.arrow.add(\n [ 0, 0 ],\n [ this.options.edge_arrow_length, this.options.edge_arrow_width / 2 ],\n [ 0, this.options.edge_arrow_width ]\n );\n this.arrow.__representation = this;\n this.text = $('<div class=\"Rk-Label Rk-Edge-Label\">').appendTo(this.renderer.labels_$);\n this.arrow_angle = 0;\n if (this.options.editor_mode) {\n var Renderer = requtils.getRenderer();\n this.normal_buttons = [\n new Renderer.EdgeEditButton(this.renderer, null),\n new Renderer.EdgeRemoveButton(this.renderer, null)\n ];\n this.pending_delete_buttons = [\n new Renderer.EdgeRevertButton(this.renderer, null)\n ];\n this.all_buttons = this.normal_buttons.concat(this.pending_delete_buttons);\n for (var i = 0; i < this.all_buttons.length; i++) {\n this.all_buttons[i].source_representation = this;\n }\n this.active_buttons = [];\n } else {\n this.active_buttons = this.all_buttons = [];\n }\n\n if (this.renderer.minimap) {\n this.renderer.minimap.edge_layer.activate();\n this.minimap_line = new paper.Path();\n this.minimap_line.add([0,0],[0,0]);\n this.minimap_line.__representation = this.renderer.minimap.miniframe.__representation;\n this.minimap_line.strokeWidth = 1;\n }\n },\n redraw: function() {\n var from = this.model.get(\"from\"),\n to = this.model.get(\"to\");\n if (!from || !to) {\n return;\n }\n this.from_representation = this.renderer.getRepresentationByModel(from);\n this.to_representation = this.renderer.getRepresentationByModel(to);\n if (typeof this.from_representation === \"undefined\" || typeof this.to_representation === \"undefined\") {\n return;\n }\n var _p0a = this.from_representation.paper_coords,\n _p1a = this.to_representation.paper_coords,\n _v = _p1a.subtract(_p0a),\n _r = _v.length,\n _u = _v.divide(_r),\n _ortho = new paper.Point([- _u.y, _u.x]),\n _group_pos = this.bundle.getPosition(this),\n _delta = _ortho.multiply( this.options.edge_gap_in_bundles * _group_pos ),\n _p0b = _p0a.add(_delta), /* Adding a 4 px difference */\n _p1b = _p1a.add(_delta), /* to differentiate bundled links */\n _a = _v.angle,\n _textdelta = _ortho.multiply(this.options.edge_label_distance),\n _handle = _v.divide(3),\n _color = this.model.get(\"color\") || this.model.get(\"color\") || (this.model.get(\"created_by\") || Utils._USER_PLACEHOLDER(this.renkan)).get(\"color\"),\n opacity = 1;\n\n if (this.model.get(\"delete_scheduled\") || this.from_representation.model.get(\"delete_scheduled\") || this.to_representation.model.get(\"delete_scheduled\")) {\n opacity = 0.5;\n this.line.dashArray = [2, 2];\n } else {\n opacity = 1;\n this.line.dashArray = null;\n }\n\n var old_act_btn = this.active_buttons;\n\n this.active_buttons = this.model.get(\"delete_scheduled\") ? this.pending_delete_buttons : this.normal_buttons;\n\n if (this.selected && this.renderer.isEditable() && old_act_btn !== this.active_buttons) {\n old_act_btn.forEach(function(b) {\n b.hide();\n });\n this.active_buttons.forEach(function(b) {\n b.show();\n });\n }\n\n this.paper_coords = _p0b.add(_p1b).divide(2);\n this.line.strokeColor = _color;\n this.line.opacity = opacity;\n this.line.segments[0].point = _p0a;\n this.line.segments[1].point = this.paper_coords;\n this.line.segments[1].handleIn = _handle.multiply(-1);\n this.line.segments[1].handleOut = _handle;\n this.line.segments[2].point = _p1a;\n this.arrow.rotate(_a - this.arrow_angle);\n this.arrow.fillColor = _color;\n this.arrow.opacity = opacity;\n this.arrow.position = this.paper_coords;\n this.arrow_angle = _a;\n if (_a > 90) {\n _a -= 180;\n _textdelta = _textdelta.multiply(-1);\n }\n if (_a < -90) {\n _a += 180;\n _textdelta = _textdelta.multiply(-1);\n }\n var _text = this.model.get(\"title\") || this.renkan.translate(this.options.label_untitled_edges) || \"\";\n _text = Utils.shortenText(_text, this.options.node_label_max_length);\n this.text.text(_text);\n var _textpos = this.paper_coords.add(_textdelta);\n this.text.css({\n left: _textpos.x,\n top: _textpos.y,\n transform: \"rotate(\" + _a + \"deg)\",\n \"-moz-transform\": \"rotate(\" + _a + \"deg)\",\n \"-webkit-transform\": \"rotate(\" + _a + \"deg)\",\n opacity: opacity\n });\n this.text_angle = _a;\n\n var _pc = this.paper_coords;\n this.all_buttons.forEach(function(b) {\n b.moveTo(_pc);\n });\n\n if (this.renderer.minimap) {\n this.minimap_line.strokeColor = _color;\n this.minimap_line.segments[0].point = this.renderer.toMinimapCoords(new paper.Point(this.from_representation.model.get(\"position\")));\n this.minimap_line.segments[1].point = this.renderer.toMinimapCoords(new paper.Point(this.to_representation.model.get(\"position\")));\n }\n },\n openEditor: function() {\n this.renderer.removeRepresentationsOfType(\"editor\");\n var _editor = this.renderer.addRepresentation(\"EdgeEditor\",null);\n _editor.source_representation = this;\n _editor.draw();\n },\n select: function() {\n this.selected = true;\n this.line.strokeWidth = this.options.selected_edge_stroke_width;\n if (this.renderer.isEditable()) {\n this.active_buttons.forEach(function(b) {\n b.show();\n });\n }\n if (!this.options.editor_mode) {\n this.openEditor();\n }\n this._super(\"select\");\n },\n unselect: function(_newTarget) {\n if (!_newTarget || _newTarget.source_representation !== this) {\n this.selected = false;\n if (this.options.editor_mode) {\n this.all_buttons.forEach(function(b) {\n b.hide();\n });\n }\n this.line.strokeWidth = this.options.edge_stroke_width;\n this._super(\"unselect\");\n }\n },\n mousedown: function(_event, _isTouch) {\n if (_isTouch) {\n this.renderer.unselectAll();\n this.select();\n }\n },\n mouseup: function(_event, _isTouch) {\n if (!this.renkan.read_only && this.renderer.is_dragging) {\n this.from_representation.saveCoords();\n this.to_representation.saveCoords();\n this.from_representation.is_dragging = false;\n this.to_representation.is_dragging = false;\n } else {\n if (!_isTouch) {\n this.openEditor();\n }\n this.model.trigger(\"clicked\");\n }\n this.renderer.click_target = null;\n this.renderer.is_dragging = false;\n },\n paperShift: function(_delta) {\n if (this.options.editor_mode) {\n if (!this.options.read_only) {\n this.from_representation.paperShift(_delta);\n this.to_representation.paperShift(_delta);\n }\n } else {\n this.renderer.paperShift(_delta);\n }\n },\n destroy: function() {\n this._super(\"destroy\");\n this.line.remove();\n this.arrow.remove();\n this.text.remove();\n if (this.renderer.minimap) {\n this.minimap_line.remove();\n }\n this.all_buttons.forEach(function(b) {\n b.destroy();\n });\n var _this = this;\n this.bundle.edges = _(this.bundle.edges).reject(function(_edge) {\n return _this === _edge;\n });\n }\n });\n\n return Edge;\n\n});\n\n\n\ndefine('renderer/tempedge',['jquery', 'underscore', 'requtils', 'renderer/baserepresentation'], function ($, _, requtils, BaseRepresentation) {\n \n\n var Utils = requtils.getUtils();\n\n /* TempEdge Class Begin */\n\n //var TempEdge = Renderer.TempEdge = Utils.inherit(Renderer._BaseRepresentation);\n var TempEdge = Utils.inherit(BaseRepresentation);\n\n _(TempEdge.prototype).extend({\n _init: function() {\n this.renderer.edge_layer.activate();\n this.type = \"Temp-edge\";\n\n var _color = (this.project.get(\"users\").get(this.renkan.current_user) || Utils._USER_PLACEHOLDER(this.renkan)).get(\"color\");\n this.line = new paper.Path();\n this.line.strokeColor = _color;\n this.line.dashArray = [4, 2];\n this.line.strokeWidth = this.options.selected_edge_stroke_width;\n this.line.add([0,0],[0,0]);\n this.line.__representation = this;\n this.arrow = new paper.Path();\n this.arrow.fillColor = _color;\n this.arrow.add(\n [ 0, 0 ],\n [ this.options.edge_arrow_length, this.options.edge_arrow_width / 2 ],\n [ 0, this.options.edge_arrow_width ]\n );\n this.arrow.__representation = this;\n this.arrow_angle = 0;\n },\n redraw: function() {\n var _p0 = this.from_representation.paper_coords,\n _p1 = this.end_pos,\n _a = _p1.subtract(_p0).angle,\n _c = _p0.add(_p1).divide(2);\n this.line.segments[0].point = _p0;\n this.line.segments[1].point = _p1;\n this.arrow.rotate(_a - this.arrow_angle);\n this.arrow.position = _c;\n this.arrow_angle = _a;\n },\n paperShift: function(_delta) {\n if (!this.renderer.isEditable()) {\n this.renderer.removeRepresentation(_this);\n paper.view.draw();\n return;\n }\n this.end_pos = this.end_pos.add(_delta);\n var _hitResult = paper.project.hitTest(this.end_pos);\n this.renderer.findTarget(_hitResult);\n this.redraw();\n },\n mouseup: function(_event, _isTouch) {\n var _hitResult = paper.project.hitTest(_event.point),\n _model = this.from_representation.model,\n _endDrag = true;\n if (_hitResult && typeof _hitResult.item.__representation !== \"undefined\") {\n var _target = _hitResult.item.__representation;\n if (_target.type.substr(0,4) === \"Node\") {\n var _destmodel = _target.model || _target.source_representation.model;\n if (_model !== _destmodel) {\n var _data = {\n id: Utils.getUID('edge'),\n created_by: this.renkan.current_user,\n from: _model,\n to: _destmodel\n };\n if (this.renderer.isEditable()) {\n this.project.addEdge(_data);\n }\n }\n }\n\n if (_model === _target.model || (_target.source_representation && _target.source_representation.model === _model)) {\n _endDrag = false;\n this.renderer.is_dragging = true;\n }\n }\n if (_endDrag) {\n this.renderer.click_target = null;\n this.renderer.is_dragging = false;\n this.renderer.removeRepresentation(this);\n paper.view.draw();\n }\n },\n destroy: function() {\n this.arrow.remove();\n this.line.remove();\n }\n });\n\n /* TempEdge Class End */\n\n return TempEdge;\n\n});\n\n\ndefine('renderer/baseeditor',['jquery', 'underscore', 'requtils', 'renderer/baserepresentation'], function ($, _, requtils, BaseRepresentation) {\n \n\n var Utils = requtils.getUtils();\n\n /* _BaseEditor Begin */\n //var _BaseEditor = Renderer._BaseEditor = Utils.inherit(Renderer._BaseRepresentation);\n var _BaseEditor = Utils.inherit(BaseRepresentation);\n\n _(_BaseEditor.prototype).extend({\n _init: function() {\n this.renderer.buttons_layer.activate();\n this.type = \"editor\";\n this.editor_block = new paper.Path();\n var _pts = _(_.range(8)).map(function() {return [0,0];});\n this.editor_block.add.apply(this.editor_block, _pts);\n this.editor_block.strokeWidth = this.options.tooltip_border_width;\n this.editor_block.strokeColor = this.options.tooltip_border_color;\n this.editor_block.opacity = 0.8;\n this.editor_$ = $('<div>')\n .appendTo(this.renderer.editor_$)\n .css({\n position: \"absolute\",\n opacity: 0.8\n })\n .hide();\n },\n destroy: function() {\n this.editor_block.remove();\n this.editor_$.remove();\n }\n });\n\n /* _BaseEditor End */\n\n return _BaseEditor;\n\n});\n\n\ndefine('renderer/nodeeditor',['jquery', 'underscore', 'requtils', 'renderer/baseeditor'], function ($, _, requtils, BaseEditor) {\n \n\n var Utils = requtils.getUtils();\n\n /* NodeEditor Begin */\n //var NodeEditor = Renderer.NodeEditor = Utils.inherit(Renderer._BaseEditor);\n var NodeEditor = Utils.inherit(BaseEditor);\n\n _(NodeEditor.prototype).extend({\n template: _.template(\n '<h2><span class=\"Rk-CloseX\">×</span><%-renkan.translate(\"Edit Node\")%></span></h2>' +\n '<p><label><%-renkan.translate(\"Title:\")%></label><input class=\"Rk-Edit-Title\" type=\"text\" value=\"<%-node.title%>\"/></p>' +\n '<% if (options.show_node_editor_uri) { %><p><label><%-renkan.translate(\"URI:\")%></label><input class=\"Rk-Edit-URI\" type=\"text\" value=\"<%-node.uri%>\"/><a class=\"Rk-Edit-Goto\" href=\"<%-node.uri%>\" target=\"_blank\"></a></p><% } %>' +\n '<% if (options.show_node_editor_description) { %><p><label><%-renkan.translate(\"Description:\")%></label><textarea class=\"Rk-Edit-Description\"><%-node.description%></textarea></p><% } %>' +\n '<% if (options.show_node_editor_size) { %><p><span class=\"Rk-Editor-Label\"><%-renkan.translate(\"Size:\")%></span><a href=\"#\" class=\"Rk-Edit-Size-Down\">-</a><span class=\"Rk-Edit-Size-Value\"><%-node.size%></span><a href=\"#\" class=\"Rk-Edit-Size-Up\">+</a></p><% } %>' +\n '<% if (options.show_node_editor_color) { %><div class=\"Rk-Editor-p\"><span class=\"Rk-Editor-Label\"><%-renkan.translate(\"Node color:\")%></span><div class=\"Rk-Edit-ColorPicker-Wrapper\"><span class=\"Rk-Edit-Color\" style=\"background:<%-node.color%>;\"><span class=\"Rk-Edit-ColorTip\"></span></span>' +\n '<%= renkan.colorPicker %><span class=\"Rk-Edit-ColorPicker-Text\"><%- renkan.translate(\"Choose color\") %></span></div></div><% } %>' +\n '<% if (options.show_node_editor_image) { %><div class=\"Rk-Edit-ImgWrap\"><div class=\"Rk-Edit-ImgPreview\"><img src=\"<%-node.image || node.image_placeholder%>\" />' +\n '<% if (node.clip_path) { %><svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" viewbox=\"0 0 1 1\" preserveAspectRatio=\"none\"><path style=\"stroke-width: .02; stroke:red; fill-opacity:.3; fill:red;\" d=\"<%- node.clip_path %>\"/></svg><% }%>' +\n '</div></div><p><label><%-renkan.translate(\"Image URL:\")%></label><input class=\"Rk-Edit-Image\" type=\"text\" value=\"<%-node.image%>\"/></p>' +\n '<p><label><%-renkan.translate(\"Choose Image File:\")%></label><input class=\"Rk-Edit-Image-File\" type=\"file\" accept=\"image/*\"/></p><% } %>' +\n '<% if (options.show_node_editor_creator && node.has_creator) { %><p><span class=\"Rk-Editor-Label\"><%-renkan.translate(\"Created by:\")%></span> <span class=\"Rk-UserColor\" style=\"background:<%-node.created_by_color%>;\"></span><%- shortenText(node.created_by_title, 25) %></p><% } %>' +\n '<% if (options.change_shapes) { %><p><label><%-renkan.translate(\"Shapes available\")%>:</label> <select class=\"Rk-Edit-Shape\">' +\n '<option class=\"Rk-Edit-Vocabulary-Property\" value=\"circle\"<% if (node.shape === \"circle\") { %> selected<% } %>><%- renkan.translate(\"Circle\") %></option>' +\n '<option class=\"Rk-Edit-Vocabulary-Property\" value=\"rectangle\"<% if (node.shape === \"rectangle\") { %> selected<% } %>><%- renkan.translate(\"Square\") %></option>' +\n '<option class=\"Rk-Edit-Vocabulary-Property\" value=\"diamond\"<% if (node.shape === \"diamond\") { %> selected<% } %>><%- renkan.translate(\"Diamond\") %></option>' +\n '<option class=\"Rk-Edit-Vocabulary-Property\" value=\"polygon\"<% if (node.shape === \"polygon\") { %> selected<% } %>><%- renkan.translate(\"Hexagone\") %></option>' +\n '<option class=\"Rk-Edit-Vocabulary-Property\" value=\"ellipse\"<% if (node.shape === \"ellipse\") { %> selected<% } %>><%- renkan.translate(\"Ellipse\") %></option>' +\n '<option class=\"Rk-Edit-Vocabulary-Property\" value=\"star\"<% if (node.shape === \"star\") { %> selected<% } %>><%- renkan.translate(\"Star\") %></option>' +\n '</select></p><% } %>'\n ),\n readOnlyTemplate: _.template(\n '<h2><span class=\"Rk-CloseX\">×</span><% if (options.show_node_tooltip_color) { %><span class=\"Rk-UserColor\" style=\"background:<%-node.color%>;\"></span><% } %>' +\n '<span class=\"Rk-Display-Title\"><% if (node.uri) { %><a href=\"<%-node.uri%>\" target=\"_blank\"><% } %><%-node.title%><% if (node.uri) { %></a><% } %></span></h2>' +\n '<% if (node.uri && options.show_node_tooltip_uri) { %><p class=\"Rk-Display-URI\"><a href=\"<%-node.uri%>\" target=\"_blank\"><%-node.short_uri%></a></p><% } %>' +\n '<% if (options.show_node_tooltip_description) { %><p class=\"Rk-Display-Description\"><%-node.description%></p><% } %>' +\n '<% if (node.image && options.show_node_tooltip_image) { %><img class=\"Rk-Display-ImgPreview\" src=\"<%-node.image%>\" /><% } %>' +\n '<% if (node.has_creator && options.show_node_tooltip_creator) { %><p><span class=\"Rk-Editor-Label\"><%-renkan.translate(\"Created by:\")%></span><span class=\"Rk-UserColor\" style=\"background:<%-node.created_by_color%>;\"></span><%- shortenText(node.created_by_title, 25) %></p><% } %>'\n ),\n draw: function() {\n var _model = this.source_representation.model,\n _created_by = _model.get(\"created_by\") || Utils._USER_PLACEHOLDER(this.renkan),\n _template = (this.renderer.isEditable() ? this.template : this.readOnlyTemplate ),\n _image_placeholder = this.options.static_url + \"img/image-placeholder.png\",\n _size = (_model.get(\"size\") || 0);\n this.editor_$\n .html(_template({\n node: {\n has_creator: !!_model.get(\"created_by\"),\n title: _model.get(\"title\"),\n uri: _model.get(\"uri\"),\n short_uri: Utils.shortenText((_model.get(\"uri\") || \"\").replace(/^(https?:\\/\\/)?(www\\.)?/,'').replace(/\\/$/,''),40),\n description: _model.get(\"description\"),\n image: _model.get(\"image\") || \"\",\n image_placeholder: _image_placeholder,\n color: _model.get(\"color\") || _created_by.get(\"color\"),\n clip_path: _model.get(\"clip_path\") || false,\n created_by_color: _created_by.get(\"color\"),\n created_by_title: _created_by.get(\"title\"),\n size: (_size > 0 ? \"+\" : \"\") + _size,\n shape: _model.get(\"shape\") || \"circle\"\n },\n renkan: this.renkan,\n options: this.options,\n shortenText: Utils.shortenText\n }));\n this.redraw();\n var _this = this,\n closeEditor = function() {\n _this.renderer.removeRepresentation(_this);\n paper.view.draw();\n };\n\n this.editor_$.find(\".Rk-CloseX\").click(closeEditor);\n\n this.editor_$.find(\".Rk-Edit-Goto\").click(function() {\n if (!_model.get(\"uri\")) {\n return false;\n }\n });\n\n if (this.renderer.isEditable()) {\n\n var onFieldChange = _(function() {\n _(function() {\n if (_this.renderer.isEditable()) {\n var _data = {\n title: _this.editor_$.find(\".Rk-Edit-Title\").val()\n };\n if (_this.options.show_node_editor_uri) {\n _data.uri = _this.editor_$.find(\".Rk-Edit-URI\").val();\n _this.editor_$.find(\".Rk-Edit-Goto\").attr(\"href\",_data.uri || \"#\");\n }\n if (_this.options.show_node_editor_image) {\n _data.image = _this.editor_$.find(\".Rk-Edit-Image\").val();\n _this.editor_$.find(\".Rk-Edit-ImgPreview\").attr(\"src\", _data.image || _image_placeholder);\n }\n if (_this.options.show_node_editor_description) {\n _data.description = _this.editor_$.find(\".Rk-Edit-Description\").val();\n }\n if (_this.options.change_shapes) {\n if(_model.get(\"shape\")!==_this.editor_$.find(\".Rk-Edit-Shape\").val()){\n _data.shape = _this.editor_$.find(\".Rk-Edit-Shape\").val();\n _data.shape_changed = true;\n }\n }\n _model.set(_data);\n _this.redraw();\n // For an unknown reason, we have to set data twice when we change shape, otherwise the image disappears.\n if(_data.shape_changed===true){\n _model.set(_data);\n }\n } else {\n closeEditor();\n }\n }).defer();\n }).throttle(500);\n \n this.editor_$.on(\"keyup\", function(_e) {\n if (_e.keyCode === 27) {\n closeEditor();\n }\n });\n\n this.editor_$.find(\"input, textarea, select\").on(\"change keyup paste\", onFieldChange);\n\n this.editor_$.find(\".Rk-Edit-Image-File\").change(function() {\n if (this.files.length) {\n var f = this.files[0],\n fr = new FileReader();\n if (f.type.substr(0,5) !== \"image\") {\n alert(_this.renkan.translate(\"This file is not an image\"));\n return;\n }\n if (f.size > (_this.options.uploaded_image_max_kb * 1024)) {\n alert(_this.renkan.translate(\"Image size must be under \") + _this.options.uploaded_image_max_kb + _this.renkan.translate(\"KB\"));\n return;\n }\n fr.onload = function(e) {\n _this.editor_$.find(\".Rk-Edit-Image\").val(e.target.result);\n onFieldChange();\n };\n fr.readAsDataURL(f);\n }\n });\n this.editor_$.find(\".Rk-Edit-Title\")[0].focus();\n\n var _picker = _this.editor_$.find(\".Rk-Edit-ColorPicker\");\n\n this.editor_$.find(\".Rk-Edit-ColorPicker-Wrapper\").hover(\n function(_e) {\n _e.preventDefault();\n _picker.show();\n },\n function(_e) {\n _e.preventDefault();\n _picker.hide();\n }\n );\n\n _picker.find(\"li\").hover(\n function(_e) {\n _e.preventDefault();\n _this.editor_$.find(\".Rk-Edit-Color\").css(\"background\", $(this).attr(\"data-color\"));\n },\n function(_e) {\n _e.preventDefault();\n _this.editor_$.find(\".Rk-Edit-Color\").css(\"background\", _model.get(\"color\") || (_model.get(\"created_by\") || Utils._USER_PLACEHOLDER(_this.renkan)).get(\"color\"));\n }\n ).click(function(_e) {\n _e.preventDefault();\n if (_this.renderer.isEditable()) {\n _model.set(\"color\", $(this).attr(\"data-color\"));\n _picker.hide();\n paper.view.draw();\n } else {\n closeEditor();\n }\n });\n\n var shiftSize = function(n) {\n if (_this.renderer.isEditable()) {\n var _newsize = n+(_model.get(\"size\") || 0);\n _this.editor_$.find(\".Rk-Edit-Size-Value\").text((_newsize > 0 ? \"+\" : \"\") + _newsize);\n _model.set(\"size\", _newsize);\n paper.view.draw();\n } else {\n closeEditor();\n }\n };\n\n this.editor_$.find(\".Rk-Edit-Size-Down\").click(function() {\n shiftSize(-1);\n return false;\n });\n this.editor_$.find(\".Rk-Edit-Size-Up\").click(function() {\n shiftSize(1);\n return false;\n });\n } else {\n if (typeof this.source_representation.highlighted === \"object\") {\n var titlehtml = this.source_representation.highlighted.replace(_(_model.get(\"title\")).escape(),'<span class=\"Rk-Highlighted\">$1</span>');\n this.editor_$.find(\".Rk-Display-Title\" + (_model.get(\"uri\") ? \" a\" : \"\")).html(titlehtml);\n if (this.options.show_node_tooltip_description) {\n this.editor_$.find(\".Rk-Display-Description\").html(this.source_representation.highlighted.replace(_(_model.get(\"description\")).escape(),'<span class=\"Rk-Highlighted\">$1</span>'));\n }\n }\n }\n this.editor_$.find(\"img\").load(function() {\n _this.redraw();\n });\n },\n redraw: function() {\n var _coords = this.source_representation.paper_coords;\n Utils.drawEditBox(this.options, _coords, this.editor_block, this.source_representation.circle_radius * 0.75, this.editor_$);\n this.editor_$.show();\n paper.view.draw();\n }\n });\n\n /* NodeEditor End */\n\n return NodeEditor;\n\n});\n\n\ndefine('renderer/edgeeditor',['jquery', 'underscore', 'requtils', 'renderer/baseeditor'], function ($, _, requtils, BaseEditor) {\n \n\n var Utils = requtils.getUtils();\n\n /* EdgeEditor Begin */\n\n //var EdgeEditor = Renderer.EdgeEditor = Utils.inherit(Renderer._BaseEditor);\n var EdgeEditor = Utils.inherit(BaseEditor);\n\n _(EdgeEditor.prototype).extend({\n template: _.template(\n '<h2><span class=\"Rk-CloseX\">×</span><%-renkan.translate(\"Edit Edge\")%></span></h2>' +\n '<p><label><%-renkan.translate(\"Title:\")%></label><input class=\"Rk-Edit-Title\" type=\"text\" value=\"<%-edge.title%>\"/></p>' +\n '<% if (options.show_edge_editor_uri) { %><p><label><%-renkan.translate(\"URI:\")%></label><input class=\"Rk-Edit-URI\" type=\"text\" value=\"<%-edge.uri%>\"/><a class=\"Rk-Edit-Goto\" href=\"<%-edge.uri%>\" target=\"_blank\"></a></p>' +\n '<% if (options.properties.length) { %><p><label><%-renkan.translate(\"Choose from vocabulary:\")%></label><select class=\"Rk-Edit-Vocabulary\">' +\n '<% _(options.properties).each(function(ontology) { %><option class=\"Rk-Edit-Vocabulary-Class\" value=\"\"><%- renkan.translate(ontology.label) %></option>' +\n '<% _(ontology.properties).each(function(property) { var uri = ontology[\"base-uri\"] + property.uri; %><option class=\"Rk-Edit-Vocabulary-Property\" value=\"<%- uri %>' +\n '\"<% if (uri === edge.uri) { %> selected<% } %>><%- renkan.translate(property.label) %></option>' +\n '<% }) %><% }) %></select></p><% } } %>' +\n '<% if (options.show_edge_editor_color) { %><div class=\"Rk-Editor-p\"><span class=\"Rk-Editor-Label\"><%-renkan.translate(\"Edge color:\")%></span><div class=\"Rk-Edit-ColorPicker-Wrapper\"><span class=\"Rk-Edit-Color\" style=\"background:<%-edge.color%>;\"><span class=\"Rk-Edit-ColorTip\"></span></span>' +\n '<%= renkan.colorPicker %><span class=\"Rk-Edit-ColorPicker-Text\"><%- renkan.translate(\"Choose color\") %></span></div></div><% } %>' +\n '<% if (options.show_edge_editor_direction) { %><p><span class=\"Rk-Edit-Direction\"><%- renkan.translate(\"Change edge direction\") %></span></p><% } %>' +\n '<% if (options.show_edge_editor_nodes) { %><p><span class=\"Rk-Editor-Label\"><%-renkan.translate(\"From:\")%></span><span class=\"Rk-UserColor\" style=\"background:<%-edge.from_color%>;\"></span><%- shortenText(edge.from_title, 25) %></p>' +\n '<p><span class=\"Rk-Editor-Label\"><%-renkan.translate(\"To:\")%></span><span class=\"Rk-UserColor\" style=\"background:<%-edge.to_color%>;\"></span><%- shortenText(edge.to_title, 25) %></p><% } %>' +\n '<% if (options.show_edge_editor_creator && edge.has_creator) { %><p><span class=\"Rk-Editor-Label\"><%-renkan.translate(\"Created by:\")%></span><span class=\"Rk-UserColor\" style=\"background:<%-edge.created_by_color%>;\"></span><%- shortenText(edge.created_by_title, 25) %></p><% } %>'\n ),\n readOnlyTemplate: _.template(\n '<h2><span class=\"Rk-CloseX\">×</span><% if (options.show_edge_tooltip_color) { %><span class=\"Rk-UserColor\" style=\"background:<%-edge.color%>;\"></span><% } %>' +\n '<span class=\"Rk-Display-Title\"><% if (edge.uri) { %><a href=\"<%-edge.uri%>\" target=\"_blank\"><% } %><%-edge.title%><% if (edge.uri) { %></a><% } %></span></h2>' +\n '<% if (options.show_edge_tooltip_uri && edge.uri) { %><p class=\"Rk-Display-URI\"><a href=\"<%-edge.uri%>\" target=\"_blank\"><%-edge.short_uri%></a></p><% } %>' +\n '<p><%-edge.description%></p>' +\n '<% if (options.show_edge_tooltip_nodes) { %><p><span class=\"Rk-Editor-Label\"><%-renkan.translate(\"From:\")%></span><span class=\"Rk-UserColor\" style=\"background:<%-edge.from_color%>;\"></span><%- shortenText(edge.from_title, 25) %></p>' +\n '<p><span class=\"Rk-Editor-Label\"><%-renkan.translate(\"To:\")%></span><span class=\"Rk-UserColor\" style=\"background:<%-edge.to_color%>;\"></span><%- shortenText(edge.to_title, 25) %></p><% } %>' +\n '<% if (options.show_edge_tooltip_creator && edge.has_creator) { %><p><span class=\"Rk-Editor-Label\"><%-renkan.translate(\"Created by:\")%></span><span class=\"Rk-UserColor\" style=\"background:<%-edge.created_by_color%>;\"></span><%- shortenText(edge.created_by_title, 25) %></p><% } %>'\n ),\n draw: function() {\n var _model = this.source_representation.model,\n _from_model = _model.get(\"from\"),\n _to_model = _model.get(\"to\"),\n _created_by = _model.get(\"created_by\") || Utils._USER_PLACEHOLDER(this.renkan),\n _template = (this.renderer.isEditable() ? this.template : this.readOnlyTemplate);\n this.editor_$\n .html(_template({\n edge: {\n has_creator: !!_model.get(\"created_by\"),\n title: _model.get(\"title\"),\n uri: _model.get(\"uri\"),\n short_uri: Utils.shortenText((_model.get(\"uri\") || \"\").replace(/^(https?:\\/\\/)?(www\\.)?/,'').replace(/\\/$/,''),40),\n description: _model.get(\"description\"),\n color: _model.get(\"color\") || _created_by.get(\"color\"),\n from_title: _from_model.get(\"title\"),\n to_title: _to_model.get(\"title\"),\n from_color: _from_model.get(\"color\") || (_from_model.get(\"created_by\") || Utils._USER_PLACEHOLDER(this.renkan)).get(\"color\"),\n to_color: _to_model.get(\"color\") || (_to_model.get(\"created_by\") || Utils._USER_PLACEHOLDER(this.renkan)).get(\"color\"),\n created_by_color: _created_by.get(\"color\"),\n created_by_title: _created_by.get(\"title\")\n },\n renkan: this.renkan,\n shortenText: Utils.shortenText,\n options: this.options\n }));\n this.redraw();\n var _this = this,\n closeEditor = function() {\n _this.renderer.removeRepresentation(_this);\n paper.view.draw();\n };\n this.editor_$.find(\".Rk-CloseX\").click(closeEditor);\n this.editor_$.find(\".Rk-Edit-Goto\").click(function() {\n if (!_model.get(\"uri\")) {\n return false;\n }\n });\n\n if (this.renderer.isEditable()) {\n\n var onFieldChange = _(function() {\n _(function() {\n if (_this.renderer.isEditable()) {\n var _data = {\n title: _this.editor_$.find(\".Rk-Edit-Title\").val()\n };\n if (_this.options.show_edge_editor_uri) {\n _data.uri = _this.editor_$.find(\".Rk-Edit-URI\").val();\n }\n _this.editor_$.find(\".Rk-Edit-Goto\").attr(\"href\",_data.uri || \"#\");\n _model.set(_data);\n paper.view.draw();\n } else {\n closeEditor();\n }\n }).defer();\n }).throttle(500);\n\n this.editor_$.on(\"keyup\", function(_e) {\n if (_e.keyCode === 27) {\n closeEditor();\n }\n });\n\n this.editor_$.find(\"input\").on(\"keyup change paste\", onFieldChange);\n\n this.editor_$.find(\".Rk-Edit-Vocabulary\").change(function() {\n var e = $(this),\n v = e.val();\n if (v) {\n _this.editor_$.find(\".Rk-Edit-Title\").val(e.find(\":selected\").text());\n _this.editor_$.find(\".Rk-Edit-URI\").val(v);\n onFieldChange();\n }\n });\n this.editor_$.find(\".Rk-Edit-Direction\").click(function() {\n if (_this.renderer.isEditable()) {\n _model.set({\n from: _model.get(\"to\"),\n to: _model.get(\"from\")\n });\n _this.draw();\n } else {\n closeEditor();\n }\n });\n\n var _picker = _this.editor_$.find(\".Rk-Edit-ColorPicker\");\n\n this.editor_$.find(\".Rk-Edit-ColorPicker-Wrapper\").hover(\n function(_e) {\n _e.preventDefault();\n _picker.show();\n },\n function(_e) {\n _e.preventDefault();\n _picker.hide();\n }\n );\n\n _picker.find(\"li\").hover(\n function(_e) {\n _e.preventDefault();\n _this.editor_$.find(\".Rk-Edit-Color\").css(\"background\", $(this).attr(\"data-color\"));\n },\n function(_e) {\n _e.preventDefault();\n _this.editor_$.find(\".Rk-Edit-Color\").css(\"background\", _model.get(\"color\") || (_model.get(\"created_by\") || Utils._USER_PLACEHOLDER(_this.renkan)).get(\"color\"));\n }\n ).click(function(_e) {\n _e.preventDefault();\n if (_this.renderer.isEditable()) {\n _model.set(\"color\", $(this).attr(\"data-color\"));\n _picker.hide();\n paper.view.draw();\n } else {\n closeEditor();\n }\n });\n }\n },\n redraw: function() {\n var _coords = this.source_representation.paper_coords;\n Utils.drawEditBox(this.options, _coords, this.editor_block, 5, this.editor_$);\n this.editor_$.show();\n paper.view.draw();\n }\n });\n\n /* EdgeEditor End */\n\n return EdgeEditor;\n\n});\n\n\ndefine('renderer/nodebutton',['jquery', 'underscore', 'requtils', 'renderer/basebutton'], function ($, _, requtils, BaseButton) {\n \n \n var Utils = requtils.getUtils();\n\n /* _NodeButton Begin */\n\n //var _NodeButton = Renderer._NodeButton = Utils.inherit(Renderer._BaseButton);\n var _NodeButton = Utils.inherit(BaseButton);\n\n _(_NodeButton.prototype).extend({\n setSectorSize: function() {\n var sectorInner = this.source_representation.circle_radius;\n if (sectorInner !== this.lastSectorInner) {\n if (this.sector) {\n this.sector.destroy();\n }\n this.sector = this.renderer.drawSector(\n this, 1 + sectorInner,\n Utils._NODE_BUTTON_WIDTH + sectorInner,\n this.startAngle,\n this.endAngle,\n 1,\n this.imageName,\n this.renkan.translate(this.text)\n );\n this.lastSectorInner = sectorInner;\n }\n }\n });\n\n /* _NodeButton End */\n\n return _NodeButton;\n\n});\n\n\ndefine('renderer/nodeeditbutton',['jquery', 'underscore', 'requtils', 'renderer/nodebutton'], function ($, _, requtils, NodeButton) {\n \n\n var Utils = requtils.getUtils();\n\n /* NodeEditButton Begin */\n\n //var NodeEditButton = Renderer.NodeEditButton = Utils.inherit(Renderer._NodeButton);\n var NodeEditButton = Utils.inherit(NodeButton);\n\n _(NodeEditButton.prototype).extend({\n _init: function() {\n this.type = \"Node-edit-button\";\n this.lastSectorInner = 0;\n this.startAngle = -135;\n this.endAngle = -45;\n this.imageName = \"edit\";\n this.text = \"Edit\";\n },\n mouseup: function() {\n if (!this.renderer.is_dragging) {\n this.source_representation.openEditor();\n }\n }\n });\n\n /* NodeEditButton End */\n\n return NodeEditButton;\n\n});\n\n\ndefine('renderer/noderemovebutton',['jquery', 'underscore', 'requtils', 'renderer/nodebutton'], function ($, _, requtils, NodeButton) {\n \n \n var Utils = requtils.getUtils();\n\n /* NodeRemoveButton Begin */\n\n //var NodeRemoveButton = Renderer.NodeRemoveButton = Utils.inherit(Renderer._NodeButton);\n var NodeRemoveButton = Utils.inherit(NodeButton);\n\n _(NodeRemoveButton.prototype).extend({\n _init: function() {\n this.type = \"Node-remove-button\";\n this.lastSectorInner = 0;\n this.startAngle = 0;\n this.endAngle = 90;\n this.imageName = \"remove\";\n this.text = \"Remove\";\n },\n mouseup: function() {\n this.renderer.click_target = null;\n this.renderer.is_dragging = false;\n this.renderer.removeRepresentationsOfType(\"editor\");\n if (this.renderer.isEditable()) {\n if (this.options.element_delete_delay) {\n var delid = Utils.getUID(\"delete\");\n this.renderer.delete_list.push({\n id: delid,\n time: new Date().valueOf() + this.options.element_delete_delay\n });\n this.source_representation.model.set(\"delete_scheduled\", delid);\n } else {\n if (confirm(this.renkan.translate('Do you really wish to remove node ') + '\"' + this.source_representation.model.get(\"title\") + '\"?')) {\n this.project.removeNode(this.source_representation.model);\n }\n }\n }\n }\n });\n\n /* NodeRemoveButton End */\n\n return NodeRemoveButton;\n\n});\n\n\ndefine('renderer/noderevertbutton',['jquery', 'underscore', 'requtils', 'renderer/nodebutton'], function ($, _, requtils, NodeButton) {\n \n\n var Utils = requtils.getUtils();\n\n /* NodeRevertButton Begin */\n\n //var NodeRevertButton = Renderer.NodeRevertButton = Utils.inherit(Renderer._NodeButton);\n var NodeRevertButton = Utils.inherit(NodeButton);\n\n _(NodeRevertButton.prototype).extend({\n _init: function() {\n this.type = \"Node-revert-button\";\n this.lastSectorInner = 0;\n this.startAngle = -135;\n this.endAngle = 135;\n this.imageName = \"revert\";\n this.text = \"Cancel deletion\";\n },\n mouseup: function() {\n this.renderer.click_target = null;\n this.renderer.is_dragging = false;\n if (this.renderer.isEditable()) {\n this.source_representation.model.unset(\"delete_scheduled\");\n }\n }\n });\n\n /* NodeRevertButton End */\n\n return NodeRevertButton;\n\n});\n\n\ndefine('renderer/nodelinkbutton',['jquery', 'underscore', 'requtils', 'renderer/nodebutton'], function ($, _, requtils, NodeButton) {\n \n\n var Utils = requtils.getUtils();\n\n /* NodeLinkButton Begin */\n\n //var NodeLinkButton = Renderer.NodeLinkButton = Utils.inherit(Renderer._NodeButton);\n var NodeLinkButton = Utils.inherit(NodeButton);\n\n _(NodeLinkButton.prototype).extend({\n _init: function() {\n this.type = \"Node-link-button\";\n this.lastSectorInner = 0;\n this.startAngle = 90;\n this.endAngle = 180;\n this.imageName = \"link\";\n this.text = \"Link to another node\";\n },\n mousedown: function(_event, _isTouch) {\n if (this.renderer.isEditable()) {\n var _off = this.renderer.canvas_$.offset(),\n _point = new paper.Point([\n _event.pageX - _off.left,\n _event.pageY - _off.top\n ]);\n this.renderer.click_target = null;\n this.renderer.removeRepresentationsOfType(\"editor\");\n this.renderer.addTempEdge(this.source_representation, _point);\n }\n }\n });\n\n /* NodeLinkButton End */\n\n return NodeLinkButton;\n\n});\n\n\n\ndefine('renderer/nodeenlargebutton',['jquery', 'underscore', 'requtils', 'renderer/nodebutton'], function ($, _, requtils, NodeButton) {\n \n \n var Utils = requtils.getUtils();\n\n /* NodeEnlargeButton Begin */\n\n //var NodeEnlargeButton = Renderer.NodeEnlargeButton = Utils.inherit(Renderer._NodeButton);\n var NodeEnlargeButton = Utils.inherit(NodeButton);\n\n _(NodeEnlargeButton.prototype).extend({\n _init: function() {\n this.type = \"Node-enlarge-button\";\n this.lastSectorInner = 0;\n this.startAngle = -45;\n this.endAngle = 0;\n this.imageName = \"enlarge\";\n this.text = \"Enlarge\";\n },\n mouseup: function() {\n var _newsize = 1 + (this.source_representation.model.get(\"size\") || 0);\n this.source_representation.model.set(\"size\", _newsize);\n this.source_representation.select();\n this.select();\n paper.view.draw();\n }\n });\n\n /* NodeEnlargeButton End */\n\n return NodeEnlargeButton;\n\n});\n\n\ndefine('renderer/nodeshrinkbutton',['jquery', 'underscore', 'requtils', 'renderer/nodebutton'], function ($, _, requtils, NodeButton) {\n \n\n var Utils = requtils.getUtils();\n\n /* NodeShrinkButton Begin */\n\n //var NodeShrinkButton = Renderer.NodeShrinkButton = Utils.inherit(Renderer._NodeButton);\n var NodeShrinkButton = Utils.inherit(NodeButton);\n\n _(NodeShrinkButton.prototype).extend({\n _init: function() {\n this.type = \"Node-shrink-button\";\n this.lastSectorInner = 0;\n this.startAngle = -180;\n this.endAngle = -135;\n this.imageName = \"shrink\";\n this.text = \"Shrink\";\n },\n mouseup: function() {\n var _newsize = -1 + (this.source_representation.model.get(\"size\") || 0);\n this.source_representation.model.set(\"size\", _newsize);\n this.source_representation.select();\n this.select();\n paper.view.draw();\n }\n });\n\n /* NodeShrinkButton End */\n\n return NodeShrinkButton;\n\n});\n\n\ndefine('renderer/edgeeditbutton',['jquery', 'underscore', 'requtils', 'renderer/basebutton'], function ($, _, requtils, BaseButton) {\n \n\n var Utils = requtils.getUtils();\n\n /* EdgeEditButton Begin */\n\n //var EdgeEditButton = Renderer.EdgeEditButton = Utils.inherit(Renderer._BaseButton);\n var EdgeEditButton = Utils.inherit(BaseButton);\n\n _(EdgeEditButton.prototype).extend({\n _init: function() {\n this.type = \"Edge-edit-button\";\n this.sector = this.renderer.drawSector(this, Utils._EDGE_BUTTON_INNER, Utils._EDGE_BUTTON_OUTER, -270, -90, 1, \"edit\", this.renkan.translate(\"Edit\"));\n },\n mouseup: function() {\n if (!this.renderer.is_dragging) {\n this.source_representation.openEditor();\n }\n }\n });\n\n /* EdgeEditButton End */\n\n return EdgeEditButton;\n\n});\n\n\ndefine('renderer/edgeremovebutton',['jquery', 'underscore', 'requtils', 'renderer/basebutton'], function ($, _, requtils, BaseButton) {\n \n\n var Utils = requtils.getUtils();\n\n /* EdgeRemoveButton Begin */\n\n //var EdgeRemoveButton = Renderer.EdgeRemoveButton = Utils.inherit(Renderer._BaseButton);\n var EdgeRemoveButton = Utils.inherit(BaseButton);\n\n _(EdgeRemoveButton.prototype).extend({\n _init: function() {\n this.type = \"Edge-remove-button\";\n this.sector = this.renderer.drawSector(this, Utils._EDGE_BUTTON_INNER, Utils._EDGE_BUTTON_OUTER, -90, 90, 1, \"remove\", this.renkan.translate(\"Remove\"));\n },\n mouseup: function() {\n this.renderer.click_target = null;\n this.renderer.is_dragging = false;\n this.renderer.removeRepresentationsOfType(\"editor\");\n if (this.renderer.isEditable()) {\n if (this.options.element_delete_delay) {\n var delid = Utils.getUID(\"delete\");\n this.renderer.delete_list.push({\n id: delid,\n time: new Date().valueOf() + this.options.element_delete_delay\n });\n this.source_representation.model.set(\"delete_scheduled\", delid);\n } else {\n if (confirm(this.renkan.translate('Do you really wish to remove edge ') + '\"' + this.source_representation.model.get(\"title\") + '\"?')) {\n this.project.removeEdge(this.source_representation.model);\n }\n }\n }\n }\n });\n\n /* EdgeRemoveButton End */\n\n return EdgeRemoveButton;\n\n});\n\n\ndefine('renderer/edgerevertbutton',['jquery', 'underscore', 'requtils', 'renderer/basebutton'], function ($, _, requtils, BaseButton) {\n \n\n var Utils = requtils.getUtils();\n\n /* EdgeRevertButton Begin */\n\n //var EdgeRevertButton = Renderer.EdgeRevertButton = Utils.inherit(Renderer._BaseButton);\n var EdgeRevertButton = Utils.inherit(BaseButton);\n\n _(EdgeRevertButton.prototype).extend({\n _init: function() {\n this.type = \"Edge-revert-button\";\n this.sector = this.renderer.drawSector(this, Utils._EDGE_BUTTON_INNER, Utils._EDGE_BUTTON_OUTER, -135, 135, 1, \"revert\", this.renkan.translate(\"Cancel deletion\"));\n },\n mouseup: function() {\n this.renderer.click_target = null;\n this.renderer.is_dragging = false;\n if (this.renderer.isEditable()) {\n this.source_representation.model.unset(\"delete_scheduled\");\n }\n }\n });\n\n /* EdgeRevertButton End */\n\n return EdgeRevertButton;\n\n});\n\n\ndefine('renderer/miniframe',['jquery', 'underscore', 'requtils', 'renderer/baserepresentation'], function ($, _, requtils, BaseRepresentation) {\n \n\n var Utils = requtils.getUtils();\n\n /* MiniFrame Begin */\n\n //var MiniFrame = Renderer.MiniFrame = Utils.inherit(Renderer._BaseRepresentation);\n var MiniFrame = Utils.inherit(BaseRepresentation);\n\n _(MiniFrame.prototype).extend({\n paperShift: function(_delta) {\n this.renderer.offset = this.renderer.offset.subtract(_delta.divide(this.renderer.minimap.scale).multiply(this.renderer.scale));\n this.renderer.redraw();\n },\n mouseup: function(_delta) {\n this.renderer.click_target = null;\n this.renderer.is_dragging = false;\n }\n });\n\n /* MiniFrame End */\n\n return MiniFrame;\n\n});\n\n\ndefine('renderer/scene',['jquery', 'underscore', 'filesaver', 'requtils', 'renderer/miniframe'], function ($, _, filesaver, requtils, MiniFrame) {\n \n\n var Utils = requtils.getUtils();\n\n /* Scene Begin */\n\n var Scene = function(_renkan) {\n this.renkan = _renkan;\n this.$ = $(\".Rk-Render\");\n this.representations = [];\n this.$.html(this.template(_renkan));\n this.onStatusChange();\n this.canvas_$ = this.$.find(\".Rk-Canvas\");\n this.labels_$ = this.$.find(\".Rk-Labels\");\n this.editor_$ = this.$.find(\".Rk-Editor\");\n this.notif_$ = this.$.find(\".Rk-Notifications\");\n paper.setup(this.canvas_$[0]);\n this.scale = 1;\n this.initialScale = 1;\n this.offset = paper.view.center;\n this.totalScroll = 0;\n this.mouse_down = false;\n this.click_target = null;\n this.selected_target = null;\n this.edge_layer = new paper.Layer();\n this.node_layer = new paper.Layer();\n this.buttons_layer = new paper.Layer();\n this.delete_list = [];\n this.redrawActive = true;\n\n if (_renkan.options.show_minimap) {\n this.minimap = {\n background_layer: new paper.Layer(),\n edge_layer: new paper.Layer(),\n node_layer: new paper.Layer(),\n node_group: new paper.Group(),\n size: new paper.Size( _renkan.options.minimap_width, _renkan.options.minimap_height )\n };\n\n this.minimap.background_layer.activate();\n this.minimap.topleft = paper.view.bounds.bottomRight.subtract(this.minimap.size);\n this.minimap.rectangle = new paper.Path.Rectangle(this.minimap.topleft.subtract([2,2]), this.minimap.size.add([4,4]));\n this.minimap.rectangle.fillColor = _renkan.options.minimap_background_color;\n this.minimap.rectangle.strokeColor = _renkan.options.minimap_border_color;\n this.minimap.rectangle.strokeWidth = 4;\n this.minimap.offset = new paper.Point(this.minimap.size.divide(2));\n this.minimap.scale = 0.1;\n\n this.minimap.node_layer.activate();\n this.minimap.cliprectangle = new paper.Path.Rectangle(this.minimap.topleft, this.minimap.size);\n this.minimap.node_group.addChild(this.minimap.cliprectangle);\n this.minimap.node_group.clipped = true;\n this.minimap.miniframe = new paper.Path.Rectangle(this.minimap.topleft, this.minimap.size);\n this.minimap.node_group.addChild(this.minimap.miniframe);\n this.minimap.miniframe.fillColor = '#c0c0ff';\n this.minimap.miniframe.opacity = 0.3;\n this.minimap.miniframe.strokeColor = '#000080';\n this.minimap.miniframe.strokeWidth = 3;\n this.minimap.miniframe.__representation = new MiniFrame(this, null);\n }\n\n this.throttledPaperDraw = _(function() {\n paper.view.draw();\n }).throttle(100);\n\n this.bundles = [];\n this.click_mode = false;\n\n var _this = this,\n _allowScroll = true,\n _originalScale = 1,\n _zooming = false,\n _lastTapX = 0,\n _lastTapY = 0;\n\n this.image_cache = {};\n this.icon_cache = {};\n\n ['edit', 'remove', 'link', 'enlarge', 'shrink', 'revert' ].forEach(function(imgname) {\n var img = new Image();\n img.src = _renkan.options.static_url + 'img/' + imgname + '.png';\n _this.icon_cache[imgname] = img;\n });\n\n var throttledMouseMove = _.throttle(function(_event, _isTouch) {\n _this.onMouseMove(_event, _isTouch);\n }, Utils._MOUSEMOVE_RATE);\n\n this.canvas_$.on({\n mousedown: function(_event) {\n _event.preventDefault();\n _this.onMouseDown(_event, false);\n },\n mousemove: function(_event) {\n _event.preventDefault();\n throttledMouseMove(_event, false);\n },\n mouseup: function(_event) {\n _event.preventDefault();\n _this.onMouseUp(_event, false);\n },\n mousewheel: function(_event, _delta) {\n if(_renkan.options.zoom_on_scroll) {\n _event.preventDefault();\n if (_allowScroll) {\n _this.onScroll(_event, _delta);\n }\n }\n },\n touchstart: function(_event) {\n _event.preventDefault();\n var _touches = _event.originalEvent.touches[0];\n if (\n _renkan.options.allow_double_click &&\n new Date() - _lastTap < Utils._DOUBLETAP_DELAY &&\n ( Math.pow(_lastTapX - _touches.pageX, 2) + Math.pow(_lastTapY - _touches.pageY, 2) < Utils._DOUBLETAP_DISTANCE )\n ) {\n _lastTap = 0;\n _this.onDoubleClick(_touches);\n } else {\n _lastTap = new Date();\n _lastTapX = _touches.pageX;\n _lastTapY = _touches.pageY;\n _originalScale = _this.scale;\n _zooming = false;\n _this.onMouseDown(_touches, true);\n }\n },\n touchmove: function(_event) {\n _event.preventDefault();\n _lastTap = 0;\n if (_event.originalEvent.touches.length === 1) {\n _this.onMouseMove(_event.originalEvent.touches[0], true);\n } else {\n if (!_zooming) {\n _this.onMouseUp(_event.originalEvent.touches[0], true);\n _this.click_target = null;\n _this.is_dragging = false;\n _zooming = true;\n }\n if (_event.originalEvent.scale === \"undefined\") {\n return;\n }\n var _newScale = _event.originalEvent.scale * _originalScale,\n _scaleRatio = _newScale / _this.scale,\n _newOffset = new paper.Point([\n _this.canvas_$.width(),\n _this.canvas_$.height()\n ]).multiply( 0.5 * ( 1 - _scaleRatio ) ).add(_this.offset.multiply( _scaleRatio ));\n _this.setScale(_newScale, _newOffset);\n }\n },\n touchend: function(_event) {\n _event.preventDefault();\n _this.onMouseUp(_event.originalEvent.changedTouches[0], true);\n },\n dblclick: function(_event) {\n _event.preventDefault();\n if (_renkan.options.allow_double_click) {\n _this.onDoubleClick(_event);\n }\n },\n mouseleave: function(_event) {\n _event.preventDefault();\n _this.onMouseUp(_event, false);\n _this.click_target = null;\n _this.is_dragging = false;\n },\n dragover: function(_event) {\n _event.preventDefault();\n },\n dragenter: function(_event) {\n _event.preventDefault();\n _allowScroll = false;\n },\n dragleave: function(_event) {\n _event.preventDefault();\n _allowScroll = true;\n },\n drop: function(_event) {\n _event.preventDefault();\n _allowScroll = true;\n var res = {};\n _(_event.originalEvent.dataTransfer.types).each(function(t) {\n try {\n res[t] = _event.originalEvent.dataTransfer.getData(t);\n } catch(e) {}\n });\n var text = _event.originalEvent.dataTransfer.getData(\"Text\");\n if (typeof text === \"string\") {\n switch(text[0]) {\n case \"{\":\n case \"[\":\n try {\n var data = JSON.parse(text);\n _(res).extend(data);\n }\n catch(e) {\n if (!res[\"text/plain\"]) {\n res[\"text/plain\"] = text;\n }\n }\n break;\n case \"<\":\n if (!res[\"text/html\"]) {\n res[\"text/html\"] = text;\n }\n break;\n default:\n if (!res[\"text/plain\"]) {\n res[\"text/plain\"] = text;\n }\n }\n }\n var url = _event.originalEvent.dataTransfer.getData(\"URL\");\n if (url && !res[\"text/uri-list\"]) {\n res[\"text/uri-list\"] = url;\n }\n _this.dropData(res, _event.originalEvent);\n }\n });\n\n var bindClick = function(selector, fname) {\n _this.$.find(selector).click(function(evt) {\n _this[fname](evt);\n return false;\n });\n };\n\n bindClick(\".Rk-ZoomOut\", \"zoomOut\");\n bindClick(\".Rk-ZoomIn\", \"zoomIn\");\n bindClick(\".Rk-ZoomFit\", \"autoScale\");\n this.$.find(\".Rk-ZoomSave\").click( function() {\n // Save scale and offset point\n _this.renkan.project.addView( { zoom_level:_this.scale, offset:_this.offset } );\n });\n this.$.find(\".Rk-ZoomSetSaved\").click( function() {\n var view = _this.renkan.project.get(\"views\").last();\n if(view){\n _this.setScale(view.get(\"zoom_level\"), new paper.Point(view.get(\"offset\")));\n }\n });\n if(this.renkan.read_only && !isNaN(parseInt(this.renkan.options.default_view))){\n this.$.find(\".Rk-ZoomSetSaved\").show();\n }\n this.$.find(\".Rk-CurrentUser\").mouseenter(\n function() { _this.$.find(\".Rk-UserList\").slideDown(); }\n );\n this.$.find(\".Rk-Users\").mouseleave(\n function() { _this.$.find(\".Rk-UserList\").slideUp(); }\n );\n bindClick(\".Rk-FullScreen-Button\", \"fullScreen\");\n bindClick(\".Rk-AddNode-Button\", \"addNodeBtn\");\n bindClick(\".Rk-AddEdge-Button\", \"addEdgeBtn\");\n bindClick(\".Rk-Save-Button\", \"save\");\n bindClick(\".Rk-Open-Button\", \"open\");\n bindClick(\".Rk-Export-Button\", \"exportProject\");\n this.$.find(\".Rk-Bookmarklet-Button\")\n /*jshint scripturl:true */\n .attr(\"href\",\"javascript:\" + Utils._BOOKMARKLET_CODE(_renkan))\n .click(function(){\n _this.notif_$\n .text(_renkan.translate(\"Drag this button to your bookmark bar. When on a third-party website, click it to enable drag-and-drop from the website to Renkan.\"))\n .fadeIn()\n .delay(5000)\n .fadeOut();\n return false;\n });\n this.$.find(\".Rk-TopBar-Button\").mouseover(function() {\n $(this).find(\".Rk-TopBar-Tooltip\").show();\n }).mouseout(function() {\n $(this).find(\".Rk-TopBar-Tooltip\").hide();\n });\n bindClick(\".Rk-Fold-Bins\", \"foldBins\");\n\n paper.view.onResize = function(_event) {\n // Because of paper bug which does not calculate the good height (and width a fortiori)\n // We have to update manually the canvas's height\n paper.view._viewSize.height = _event.size.height = _this.canvas_$.parent().height();\n\n if (_this.minimap) {\n _this.minimap.topleft = paper.view.bounds.bottomRight.subtract(_this.minimap.size);\n _this.minimap.rectangle.fitBounds(_this.minimap.topleft.subtract([2,2]), _this.minimap.size.add([4,4]));\n _this.minimap.cliprectangle.fitBounds(_this.minimap.topleft, _this.minimap.size);\n }\n _this.redraw();\n };\n\n var _thRedraw = _.throttle(function() {\n _this.redraw();\n },50);\n\n this.addRepresentations(\"Node\", this.renkan.project.get(\"nodes\"));\n this.addRepresentations(\"Edge\", this.renkan.project.get(\"edges\"));\n this.renkan.project.on(\"change:title\", function() {\n _this.$.find(\".Rk-PadTitle\").val(_renkan.project.get(\"title\"));\n });\n\n this.$.find(\".Rk-PadTitle\").on(\"keyup input paste\", function() {\n _renkan.project.set({\"title\": $(this).val()});\n });\n\n var _thRedrawUsers = _.throttle(function() {\n _this.redrawUsers();\n }, 100);\n\n _thRedrawUsers();\n\n // register model events\n this.renkan.project.on(\"add:users remove:users\", _thRedrawUsers);\n\n this.renkan.project.on(\"add:views remove:views\", function(_node) {\n if(_this.renkan.project.get('views').length > 0) {\n _this.$.find(\".Rk-ZoomSetSaved\").show();\n }\n else {\n _this.$.find(\".Rk-ZoomSetSaved\").hide();\n }\n });\n\n this.renkan.project.on(\"add:nodes\", function(_node) {\n _this.addRepresentation(\"Node\", _node);\n _thRedraw();\n });\n this.renkan.project.on(\"add:edges\", function(_edge) {\n _this.addRepresentation(\"Edge\", _edge);\n _thRedraw();\n });\n this.renkan.project.on(\"change:title\", function(_model, _title) {\n var el = _this.$.find(\".Rk-PadTitle\");\n if (el.is(\"input\")) {\n if (el.val() !== _title) {\n el.val(_title);\n }\n } else {\n el.text(_title);\n }\n });\n\n if (_renkan.options.size_bug_fix) {\n var _delay = (\n typeof _renkan.options.size_bug_fix === \"number\" ?\n _renkan.options.size_bug_fix\n : 500\n );\n window.setTimeout(\n function() {\n _this.fixSize(true);\n },\n _delay\n );\n }\n\n if (_renkan.options.force_resize) {\n $(window).resize(function() {\n _this.fixSize(false);\n });\n }\n\n if (_renkan.options.show_user_list && _renkan.options.user_color_editable) {\n var $cpwrapper = this.$.find(\".Rk-Users .Rk-Edit-ColorPicker-Wrapper\"),\n $cplist = this.$.find(\".Rk-Users .Rk-Edit-ColorPicker\");\n\n $cpwrapper.hover(\n function(_e) {\n if (_this.isEditable()) {\n _e.preventDefault();\n $cplist.show();\n }\n },\n function(_e) {\n _e.preventDefault();\n $cplist.hide();\n }\n );\n\n $cplist.find(\"li\").mouseenter(\n function(_e) {\n if (_this.isEditable()) {\n _e.preventDefault();\n _this.$.find(\".Rk-CurrentUser-Color\").css(\"background\", $(this).attr(\"data-color\"));\n }\n }\n );\n }\n\n if (_renkan.options.show_search_field) {\n\n var lastval = '';\n\n this.$.find(\".Rk-GraphSearch-Field\").on(\"keyup change paste input\", function() {\n var $this = $(this),\n val = $this.val();\n if (val === lastval) {\n return;\n }\n lastval = val;\n if (val.length < 2) {\n _renkan.project.get(\"nodes\").each(function(n) {\n _this.getRepresentationByModel(n).unhighlight();\n });\n } else {\n var rxs = Utils.regexpFromTextOrArray(val);\n _renkan.project.get(\"nodes\").each(function(n) {\n if (rxs.test(n.get(\"title\")) || rxs.test(n.get(\"description\"))) {\n _this.getRepresentationByModel(n).highlight(rxs);\n } else {\n _this.getRepresentationByModel(n).unhighlight();\n }\n });\n }\n });\n }\n\n this.redraw();\n\n window.setInterval(function() {\n var _now = new Date().valueOf();\n _this.delete_list.forEach(function(d) {\n if (_now >= d.time) {\n var el = _renkan.project.get(\"nodes\").findWhere({\"delete_scheduled\":d.id});\n if (el) {\n project.removeNode(el);\n }\n el = _renkan.project.get(\"edges\").findWhere({\"delete_scheduled\":d.id});\n if (el) {\n project.removeEdge(el);\n }\n }\n });\n _this.delete_list = _this.delete_list.filter(function(d) {\n return _renkan.project.get(\"nodes\").findWhere({\"delete_scheduled\":d.id}) || _renkan.project.get(\"edges\").findWhere({\"delete_scheduled\":d.id});\n });\n }, 500);\n\n if (this.minimap) {\n window.setInterval(function() {\n _this.rescaleMinimap();\n }, 2000);\n }\n\n };\n\n _(Scene.prototype).extend({\n template: _.template(\n '<% if (options.show_top_bar) { %><div class=\"Rk-TopBar\"><% if (!options.editor_mode) { %><h2 class=\"Rk-PadTitle\"><%- project.get(\"title\") || translate(\"Untitled project\")%></h2>' +\n '<% } else { %><input type=\"text\" class=\"Rk-PadTitle\" value=\"<%- project.get(\"title\") || \"\" %>\" placeholder=\"<%-translate(\"Untitled project\")%>\" /><% } %>' +\n '<% if (options.show_user_list) { %><div class=\"Rk-Users\"><div class=\"Rk-CurrentUser\"><div class=\"Rk-Edit-ColorPicker-Wrapper\"><span class=\"Rk-CurrentUser-Color\"><% if (options.user_color_editable) { %><span class=\"Rk-Edit-ColorTip\"></span><% } %></span>' +\n '<% if (options.user_color_editable) { print(colorPicker) } %></div><span class=\"Rk-CurrentUser-Name\"><unknown user></span></div><ul class=\"Rk-UserList\"></ul></div><% } %>' +\n '<% if (options.home_button_url) {%><div class=\"Rk-TopBar-Separator\"></div><a class=\"Rk-TopBar-Button Rk-Home-Button\" href=\"<%- options.home_button_url %>\"><div class=\"Rk-TopBar-Tooltip\"><div class=\"Rk-TopBar-Tooltip-Contents\">' +\n '<%- translate(options.home_button_title) %></div></div></a><% } %>' +\n '<% if (options.show_fullscreen_button) { %><div class=\"Rk-TopBar-Separator\"></div><div class=\"Rk-TopBar-Button Rk-FullScreen-Button\"><div class=\"Rk-TopBar-Tooltip\"><div class=\"Rk-TopBar-Tooltip-Contents\"><%-translate(\"Full Screen\")%></div></div></div><% } %>' +\n '<% if (options.editor_mode) { %>' +\n '<% if (options.show_addnode_button) { %><div class=\"Rk-TopBar-Separator\"></div><div class=\"Rk-TopBar-Button Rk-AddNode-Button\"><div class=\"Rk-TopBar-Tooltip\">' +\n '<div class=\"Rk-TopBar-Tooltip-Contents\"><%-translate(\"Add Node\")%></div></div></div><% } %>' +\n '<% if (options.show_addedge_button) { %><div class=\"Rk-TopBar-Separator\"></div><div class=\"Rk-TopBar-Button Rk-AddEdge-Button\"><div class=\"Rk-TopBar-Tooltip\">' +\n '<div class=\"Rk-TopBar-Tooltip-Contents\"><%-translate(\"Add Edge\")%></div></div></div><% } %>' +\n '<% if (options.show_export_button) { %><div class=\"Rk-TopBar-Separator\"></div><div class=\"Rk-TopBar-Button Rk-Export-Button\"><div class=\"Rk-TopBar-Tooltip\"><div class=\"Rk-TopBar-Tooltip-Contents\"><%-translate(\"Download Project\")%></div></div></div><% } %>' +\n '<% if (options.show_save_button) { %><div class=\"Rk-TopBar-Separator\"></div><div class=\"Rk-TopBar-Button Rk-Save-Button\"><div class=\"Rk-TopBar-Tooltip\"><div class=\"Rk-TopBar-Tooltip-Contents\"> </div></div></div><% } %>' +\n '<% if (options.show_open_button) { %><div class=\"Rk-TopBar-Separator\"></div><div class=\"Rk-TopBar-Button Rk-Open-Button\"><div class=\"Rk-TopBar-Tooltip\"><div class=\"Rk-TopBar-Tooltip-Contents\"><%-translate(\"Open Project\")%></div></div></div><% } %>' +\n '<% if (options.show_bookmarklet) { %><div class=\"Rk-TopBar-Separator\"></div><a class=\"Rk-TopBar-Button Rk-Bookmarklet-Button\" href=\"#\"><div class=\"Rk-TopBar-Tooltip\"><div class=\"Rk-TopBar-Tooltip-Contents\">' +\n '<%-translate(\"Renkan \\'Drag-to-Add\\' bookmarklet\")%></div></div></a><% } %>' +\n '<% } else { %>' +\n '<% if (options.show_export_button) { %><div class=\"Rk-TopBar-Separator\"></div><div class=\"Rk-TopBar-Button Rk-Export-Button\"><div class=\"Rk-TopBar-Tooltip\"><div class=\"Rk-TopBar-Tooltip-Contents\"><%-translate(\"Download Project\")%></div></div></div><div class=\"Rk-TopBar-Separator\"></div><% } %>' +\n '<% };' +\n 'if (options.show_search_field) { %>' +\n '<form action=\"#\" class=\"Rk-GraphSearch-Form\"><input type=\"search\" class=\"Rk-GraphSearch-Field\" placeholder=\"<%- translate(\"Search in graph\") %>\" /></form><div class=\"Rk-TopBar-Separator\"></div><% } %></div><% } %>' +\n '<div class=\"Rk-Editing-Space<% if (!options.show_top_bar) { %> Rk-Editing-Space-Full<% } %>\">' +\n '<div class=\"Rk-Labels\"></div><canvas class=\"Rk-Canvas\" resize></canvas><div class=\"Rk-Notifications\"></div><div class=\"Rk-Editor\">' +\n '<% if (options.show_bins) { %><div class=\"Rk-Fold-Bins\">«</div><% } %>' +\n '<div class=\"Rk-ZoomButtons\"><div class=\"Rk-ZoomIn\" title=\"<%-translate(\"Zoom In\")%>\"></div><div class=\"Rk-ZoomFit\" title=\"<%-translate(\"Zoom Fit\")%>\"></div><div class=\"Rk-ZoomOut\" title=\"<%-translate(\"Zoom Out\")%>\"></div>' +\n '<% if (options.editor_mode) { %><div class=\"Rk-ZoomSave\" title=\"<%-translate(\"Zoom Save\")%>\"></div><% } %>' +\n '<% if (options.editor_mode || !isNaN(parseInt(options.default_view))) { %><div class=\"Rk-ZoomSetSaved\" title=\"<%-translate(\"View saved zoom\")%>\"></div><% } %></div>' +\n '</div></div>'\n ),\n fixSize: function(_autoscale) {\n var w = this.$.width(),\n h = this.$.height();\n if (this.renkan.options.show_top_bar) {\n h -= this.$.find(\".Rk-TopBar\").height();\n }\n this.canvas_$.attr({\n width: w,\n height: h\n });\n\n paper.view.viewSize = new paper.Size([w, h]);\n\n if (_autoscale) {\n // If _autoscale, we get the initial view (zoom+offset) set in the project datas.\n if(this.renkan.read_only && !isNaN(parseInt(this.renkan.options.default_view))){\n this.autoScale(this.renkan.project.get(\"views\")[parseInt(this.renkan.options.default_view)]);\n }\n else{\n this.autoScale();\n }\n }\n },\n drawSector: function(_repr, _inR, _outR, _startAngle, _endAngle, _padding, _imgname, _caption) {\n var _options = this.renkan.options,\n _startRads = _startAngle * Math.PI / 180,\n _endRads = _endAngle * Math.PI / 180,\n _img = this.icon_cache[_imgname],\n _startdx = - Math.sin(_startRads),\n _startdy = Math.cos(_startRads),\n _startXIn = Math.cos(_startRads) * _inR + _padding * _startdx,\n _startYIn = Math.sin(_startRads) * _inR + _padding * _startdy,\n _startXOut = Math.cos(_startRads) * _outR + _padding * _startdx,\n _startYOut = Math.sin(_startRads) * _outR + _padding * _startdy,\n _enddx = - Math.sin(_endRads),\n _enddy = Math.cos(_endRads),\n _endXIn = Math.cos(_endRads) * _inR - _padding * _enddx,\n _endYIn = Math.sin(_endRads) * _inR - _padding * _enddy,\n _endXOut = Math.cos(_endRads) * _outR - _padding * _enddx,\n _endYOut = Math.sin(_endRads) * _outR - _padding * _enddy,\n _centerR = (_inR + _outR) / 2,\n _centerRads = (_startRads + _endRads) / 2,\n _centerX = Math.cos(_centerRads) * _centerR,\n _centerY = Math.sin(_centerRads) * _centerR,\n _centerXIn = Math.cos(_centerRads) * _inR,\n _centerXOut = Math.cos(_centerRads) * _outR,\n _centerYIn = Math.sin(_centerRads) * _inR,\n _centerYOut = Math.sin(_centerRads) * _outR,\n _textX = Math.cos(_centerRads) * (_outR + 3),\n _textY = Math.sin(_centerRads) * (_outR + _options.buttons_label_font_size) + _options.buttons_label_font_size / 2;\n this.buttons_layer.activate();\n var _path = new paper.Path();\n _path.add([_startXIn, _startYIn]);\n _path.arcTo([_centerXIn, _centerYIn], [_endXIn, _endYIn]);\n _path.lineTo([_endXOut, _endYOut]);\n _path.arcTo([_centerXOut, _centerYOut], [_startXOut, _startYOut]);\n _path.fillColor = _options.buttons_background;\n _path.opacity = 0.5;\n _path.closed = true;\n _path.__representation = _repr;\n var _text = new paper.PointText(_textX,_textY);\n _text.characterStyle = {\n fontSize: _options.buttons_label_font_size,\n fillColor: _options.buttons_label_color\n };\n if (_textX > 2) {\n _text.paragraphStyle.justification = 'left';\n } else if (_textX < -2) {\n _text.paragraphStyle.justification = 'right';\n } else {\n _text.paragraphStyle.justification = 'center';\n }\n _text.visible = false;\n var _visible = false,\n _restPos = new paper.Point(-200, -200),\n _grp = new paper.Group([_path, _text]),\n _delta = _grp.position,\n _imgdelta = new paper.Point([_centerX, _centerY]),\n _currentPos = new paper.Point(0,0);\n _text.content = _caption;\n _grp.visible = false;\n _grp.position = _restPos;\n var _res = {\n show: function() {\n _visible = true;\n _grp.position = _currentPos.add(_delta);\n _grp.visible = true;\n },\n moveTo: function(_point) {\n _currentPos = _point;\n if (_visible) {\n _grp.position = _point.add(_delta);\n }\n },\n hide: function() {\n _visible = false;\n _grp.visible = false;\n _grp.position = _restPos;\n },\n select: function() {\n _path.opacity = 0.8;\n _text.visible = true;\n },\n unselect: function() {\n _path.opacity = 0.5;\n _text.visible = false;\n },\n destroy: function() {\n _grp.remove();\n }\n };\n var showImage = function() {\n var _raster = new paper.Raster(_img);\n _raster.position = _imgdelta.add(_grp.position).subtract(_delta);\n _raster.locked = true; // Disable mouse events on icon\n _grp.addChild(_raster);\n };\n if (_img.width) {\n showImage();\n } else {\n $(_img).on(\"load\",showImage);\n }\n\n return _res;\n },\n addToBundles: function(_edgeRepr) {\n var _bundle = _(this.bundles).find(function(_bundle) {\n return (\n ( _bundle.from === _edgeRepr.from_representation && _bundle.to === _edgeRepr.to_representation ) ||\n ( _bundle.from === _edgeRepr.to_representation && _bundle.to === _edgeRepr.from_representation )\n );\n });\n if (typeof _bundle !== \"undefined\") {\n _bundle.edges.push(_edgeRepr);\n } else {\n _bundle = {\n from: _edgeRepr.from_representation,\n to: _edgeRepr.to_representation,\n edges: [ _edgeRepr ],\n getPosition: function(_er) {\n var _dir = (_er.from_representation === this.from) ? 1 : -1;\n return _dir * ( _(this.edges).indexOf(_er) - (this.edges.length - 1) / 2 );\n }\n };\n this.bundles.push(_bundle);\n }\n return _bundle;\n },\n isEditable: function() {\n return (this.renkan.options.editor_mode && !this.renkan.read_only);\n },\n onStatusChange: function() {\n var savebtn = this.$.find(\".Rk-Save-Button\"),\n tip = savebtn.find(\".Rk-TopBar-Tooltip-Contents\");\n if (this.renkan.read_only) {\n savebtn.removeClass(\"disabled Rk-Save-Online\").addClass(\"Rk-Save-ReadOnly\");\n tip.text(this.renkan.translate(\"Connection lost\"));\n } else {\n if (this.renkan.options.manual_save) {\n savebtn.removeClass(\"Rk-Save-ReadOnly Rk-Save-Online\");\n tip.text(this.renkan.translate(\"Save Project\"));\n } else {\n savebtn.removeClass(\"disabled Rk-Save-ReadOnly\").addClass(\"Rk-Save-Online\");\n tip.text(this.renkan.translate(\"Auto-save enabled\"));\n }\n }\n this.redrawUsers();\n },\n setScale: function(_newScale, _offset) {\n if ((_newScale/this.initialScale) > Utils._MIN_SCALE && (_newScale/this.initialScale) < Utils._MAX_SCALE) {\n this.scale = _newScale;\n if (_offset) {\n this.offset = _offset;\n }\n this.redraw();\n }\n },\n autoScale: function(force_view) {\n var nodes = this.renkan.project.get(\"nodes\");\n if (nodes.length > 1) {\n var _xx = nodes.map(function(_node) { return _node.get(\"position\").x; }),\n _yy = nodes.map(function(_node) { return _node.get(\"position\").y; }),\n _minx = Math.min.apply(Math, _xx),\n _miny = Math.min.apply(Math, _yy),\n _maxx = Math.max.apply(Math, _xx),\n _maxy = Math.max.apply(Math, _yy);\n var _scale = Math.min( (paper.view.size.width - 2 * this.renkan.options.autoscale_padding) / (_maxx - _minx), (paper.view.size.height - 2 * this.renkan.options.autoscale_padding) / (_maxy - _miny));\n this.initialScale = _scale;\n // Override calculated scale if asked\n if((typeof force_view !== \"undefined\") && parseFloat(force_view.zoom_level)>0 && parseFloat(force_view.offset.x)>0 && parseFloat(force_view.offset.y)>0){\n this.setScale(parseFloat(force_view.zoom_level), new paper.Point(parseFloat(force_view.offset.x), parseFloat(force_view.offset.y)));\n }\n else{\n this.setScale(_scale, paper.view.center.subtract(new paper.Point([(_maxx + _minx) / 2, (_maxy + _miny) / 2]).multiply(_scale)));\n }\n }\n if (nodes.length === 1) {\n this.setScale(1, paper.view.center.subtract(new paper.Point([nodes.at(0).get(\"position\").x, nodes.at(0).get(\"position\").y])));\n }\n },\n redrawMiniframe: function() {\n var topleft = this.toMinimapCoords(this.toModelCoords(new paper.Point([0,0]))),\n bottomright = this.toMinimapCoords(this.toModelCoords(paper.view.bounds.bottomRight));\n this.minimap.miniframe.fitBounds(topleft, bottomright);\n },\n rescaleMinimap: function() {\n var nodes = this.renkan.project.get(\"nodes\");\n if (nodes.length > 1) {\n var _xx = nodes.map(function(_node) { return _node.get(\"position\").x; }),\n _yy = nodes.map(function(_node) { return _node.get(\"position\").y; }),\n _minx = Math.min.apply(Math, _xx),\n _miny = Math.min.apply(Math, _yy),\n _maxx = Math.max.apply(Math, _xx),\n _maxy = Math.max.apply(Math, _yy);\n var _scale = Math.min(\n this.scale * 0.8 * this.renkan.options.minimap_width / paper.view.bounds.width,\n this.scale * 0.8 * this.renkan.options.minimap_height / paper.view.bounds.height,\n ( this.renkan.options.minimap_width - 2 * this.renkan.options.minimap_padding ) / (_maxx - _minx),\n ( this.renkan.options.minimap_height - 2 * this.renkan.options.minimap_padding ) / (_maxy - _miny)\n );\n this.minimap.offset = this.minimap.size.divide(2).subtract(new paper.Point([(_maxx + _minx) / 2, (_maxy + _miny) / 2]).multiply(_scale));\n this.minimap.scale = _scale;\n }\n if (nodes.length === 1) {\n this.minimap.scale = 0.1;\n this.minimap.offset = this.minimap.size.divide(2).subtract(new paper.Point([nodes.at(0).get(\"position\").x, nodes.at(0).get(\"position\").y]).multiply(this.minimap.scale));\n }\n this.redraw();\n },\n toPaperCoords: function(_point) {\n return _point.multiply(this.scale).add(this.offset);\n },\n toMinimapCoords: function(_point) {\n return _point.multiply(this.minimap.scale).add(this.minimap.offset).add(this.minimap.topleft);\n },\n toModelCoords: function(_point) {\n return _point.subtract(this.offset).divide(this.scale);\n },\n addRepresentation: function(_type, _model) {\n var RendererType = requtils.getRenderer()[_type];\n var _repr = new RendererType(this, _model);\n this.representations.push(_repr);\n return _repr;\n },\n addRepresentations: function(_type, _collection) {\n var _this = this;\n _collection.forEach(function(_model) {\n _this.addRepresentation(_type, _model);\n });\n },\n userTemplate: _.template(\n '<li class=\"Rk-User\"><span class=\"Rk-UserColor\" style=\"background:<%=background%>;\"></span><%=name%></li>'\n ),\n redrawUsers: function() {\n if (!this.renkan.options.show_user_list) {\n return;\n }\n var allUsers = [].concat((this.renkan.project.current_user_list || {}).models || [], (this.renkan.project.get(\"users\") || {}).models || []),\n ulistHtml = '',\n $userpanel = this.$.find(\".Rk-Users\"),\n $name = $userpanel.find(\".Rk-CurrentUser-Name\"),\n $cpitems = $userpanel.find(\".Rk-Edit-ColorPicker li\"),\n $colorsquare = $userpanel.find(\".Rk-CurrentUser-Color\"),\n _this = this;\n $name.off(\"click\").text(this.renkan.translate(\"<unknown user>\"));\n $cpitems.off(\"mouseleave click\");\n allUsers.forEach(function(_user) {\n if (_user.get(\"_id\") === _this.renkan.current_user) {\n $name.text(_user.get(\"title\"));\n $colorsquare.css(\"background\", _user.get(\"color\"));\n if (_this.isEditable()) {\n\n if (_this.renkan.options.user_name_editable) {\n $name.click(function() {\n var $this = $(this),\n $input = $('<input>').val(_user.get(\"title\")).blur(function() {\n _user.set(\"title\", $(this).val());\n _this.redrawUsers();\n _this.redraw();\n });\n $this.empty().html($input);\n $input.select();\n });\n }\n\n if (_this.renkan.options.user_color_editable) {\n $cpitems.click(\n function(_e) {\n _e.preventDefault();\n if (_this.isEditable()) {\n _user.set(\"color\", $(this).attr(\"data-color\"));\n }\n $(this).parent().hide();\n }\n ).mouseleave(function() {\n $colorsquare.css(\"background\", _user.get(\"color\"));\n });\n }\n }\n\n } else {\n ulistHtml += _this.userTemplate({\n name: _user.get(\"title\"),\n background: _user.get(\"color\")\n });\n }\n });\n $userpanel.find(\".Rk-UserList\").html(ulistHtml);\n },\n removeRepresentation: function(_representation) {\n _representation.destroy();\n this.representations = _(this.representations).reject(\n function(_repr) {\n return _repr === _representation;\n }\n );\n },\n getRepresentationByModel: function(_model) {\n if (!_model) {\n return undefined;\n }\n return _(this.representations).find(function(_repr) {\n return _repr.model === _model;\n });\n },\n removeRepresentationsOfType: function(_type) {\n var _representations = _(this.representations).filter(function(_repr) {\n return _repr.type === _type;\n }),\n _this = this;\n _(_representations).each(function(_repr) {\n _this.removeRepresentation(_repr);\n });\n },\n highlightModel: function(_model) {\n var _repr = this.getRepresentationByModel(_model);\n if (_repr) {\n _repr.highlight();\n }\n },\n unhighlightAll: function(_model) {\n _(this.representations).each(function(_repr) {\n _repr.unhighlight();\n });\n },\n unselectAll: function(_model) {\n _(this.representations).each(function(_repr) {\n _repr.unselect();\n });\n },\n redraw: function() {\n if(! this.redrawActive ) {\n return;\n }\n _(this.representations).each(function(_representation) {\n _representation.redraw(true);\n });\n if (this.minimap) {\n this.redrawMiniframe();\n }\n paper.view.draw();\n },\n addTempEdge: function(_from, _point) {\n var _tmpEdge = this.addRepresentation(\"TempEdge\",null);\n _tmpEdge.end_pos = _point;\n _tmpEdge.from_representation = _from;\n _tmpEdge.redraw();\n this.click_target = _tmpEdge;\n },\n findTarget: function(_hitResult) {\n if (_hitResult && typeof _hitResult.item.__representation !== \"undefined\") {\n var _newTarget = _hitResult.item.__representation;\n if (this.selected_target !== _hitResult.item.__representation) {\n if (this.selected_target) {\n this.selected_target.unselect(_newTarget);\n }\n _newTarget.select(this.selected_target);\n this.selected_target = _newTarget;\n }\n } else {\n if (this.selected_target) {\n this.selected_target.unselect();\n }\n this.selected_target = null;\n }\n },\n paperShift: function(_delta) {\n this.offset = this.offset.add(_delta);\n this.redraw();\n },\n onMouseMove: function(_event) {\n var _off = this.canvas_$.offset(),\n _point = new paper.Point([\n _event.pageX - _off.left,\n _event.pageY - _off.top\n ]),\n _delta = _point.subtract(this.last_point);\n this.last_point = _point;\n if (!this.is_dragging && this.mouse_down && _delta.length > Utils._MIN_DRAG_DISTANCE) {\n this.is_dragging = true;\n }\n var _hitResult = paper.project.hitTest(_point);\n if (this.is_dragging) {\n if (this.click_target && typeof this.click_target.paperShift === \"function\") {\n this.click_target.paperShift(_delta);\n } else {\n this.paperShift(_delta);\n }\n } else {\n this.findTarget(_hitResult);\n }\n paper.view.draw();\n },\n onMouseDown: function(_event, _isTouch) {\n var _off = this.canvas_$.offset(),\n _point = new paper.Point([\n _event.pageX - _off.left,\n _event.pageY - _off.top\n ]);\n this.last_point = _point;\n this.mouse_down = true;\n if (!this.click_target || this.click_target.type !== \"Temp-edge\") {\n this.removeRepresentationsOfType(\"editor\");\n this.is_dragging = false;\n var _hitResult = paper.project.hitTest(_point);\n if (_hitResult && typeof _hitResult.item.__representation !== \"undefined\") {\n this.click_target = _hitResult.item.__representation;\n this.click_target.mousedown(_event, _isTouch);\n } else {\n this.click_target = null;\n if (this.isEditable() && this.click_mode === Utils._CLICKMODE_ADDNODE) {\n var _coords = this.toModelCoords(_point),\n _data = {\n id: Utils.getUID('node'),\n created_by: this.renkan.current_user,\n position: {\n x: _coords.x,\n y: _coords.y\n }\n };\n _node = this.renkan.project.addNode(_data);\n this.getRepresentationByModel(_node).openEditor();\n }\n }\n }\n if (this.click_mode) {\n if (this.isEditable() && this.click_mode === Utils._CLICKMODE_STARTEDGE && this.click_target && this.click_target.type === \"Node\") {\n this.removeRepresentationsOfType(\"editor\");\n this.addTempEdge(this.click_target, _point);\n this.click_mode = Utils._CLICKMODE_ENDEDGE;\n this.notif_$.fadeOut(function() {\n $(this).html(this.renkan.translate(\"Click on a second node to complete the edge\")).fadeIn();\n });\n } else {\n this.notif_$.hide();\n this.click_mode = false;\n }\n }\n paper.view.draw();\n },\n onMouseUp: function(_event, _isTouch) {\n this.mouse_down = false;\n if (this.click_target) {\n var _off = this.canvas_$.offset();\n this.click_target.mouseup(\n {\n point: new paper.Point([\n _event.pageX - _off.left,\n _event.pageY - _off.top\n ])\n },\n _isTouch\n );\n } else {\n this.click_target = null;\n this.is_dragging = false;\n if (_isTouch) {\n this.unselectAll();\n }\n }\n paper.view.draw();\n },\n onScroll: function(_event, _scrolldelta) {\n this.totalScroll += _scrolldelta;\n if (Math.abs(this.totalScroll) >= 1) {\n var _off = this.canvas_$.offset(),\n _delta = new paper.Point([\n _event.pageX - _off.left,\n _event.pageY - _off.top\n ]).subtract(this.offset).multiply( Math.SQRT2 - 1 );\n if (this.totalScroll > 0) {\n this.setScale( this.scale * Math.SQRT2, this.offset.subtract(_delta) );\n } else {\n this.setScale( this.scale * Math.SQRT1_2, this.offset.add(_delta.divide(Math.SQRT2)));\n }\n this.totalScroll = 0;\n }\n },\n onDoubleClick: function(_event) {\n if (!this.isEditable()) {\n return;\n }\n var _off = this.canvas_$.offset(),\n _point = new paper.Point([\n _event.pageX - _off.left,\n _event.pageY - _off.top\n ]);\n var _hitResult = paper.project.hitTest(_point);\n if (this.isEditable() && (!_hitResult || typeof _hitResult.item.__representation === \"undefined\")) {\n var _coords = this.toModelCoords(_point),\n _data = {\n id: Utils.getUID('node'),\n created_by: this.renkan.current_user,\n position: {\n x: _coords.x,\n y: _coords.y\n }\n },\n _node = this.renkan.project.addNode(_data);\n this.getRepresentationByModel(_node).openEditor();\n }\n paper.view.draw();\n },\n defaultDropHandler: function(_data) {\n var newNode = {};\n var snippet = \"\";\n switch(_data[\"text/x-iri-specific-site\"]) {\n case \"twitter\":\n snippet = $('<div>').html(_data[\"text/x-iri-selected-html\"]);\n var tweetdiv = snippet.find(\".tweet\");\n newNode.title = this.renkan.translate(\"Tweet by \") + tweetdiv.attr(\"data-name\");\n newNode.uri = \"http://twitter.com/\" + tweetdiv.attr(\"data-screen-name\") + \"/status/\" + tweetdiv.attr(\"data-tweet-id\");\n newNode.image = tweetdiv.find(\".avatar\").attr(\"src\");\n newNode.description = tweetdiv.find(\".js-tweet-text:first\").text();\n break;\n case \"google\":\n snippet = $('<div>').html(_data[\"text/x-iri-selected-html\"]);\n newNode.title = snippet.find(\"h3:first\").text().trim();\n newNode.uri = snippet.find(\"h3 a\").attr(\"href\");\n newNode.description = snippet.find(\".st:first\").text().trim();\n break;\n default:\n if (_data[\"text/x-iri-source-uri\"]) {\n newNode.uri = _data[\"text/x-iri-source-uri\"];\n }\n }\n if (_data[\"text/plain\"] || _data[\"text/x-iri-selected-text\"]) {\n newNode.description = (_data[\"text/plain\"] || _data[\"text/x-iri-selected-text\"]).replace(/[\\s\\n]+/gm,' ').trim();\n }\n if (_data[\"text/html\"] || _data[\"text/x-iri-selected-html\"]) {\n snippet = $('<div>').html(_data[\"text/html\"] || _data[\"text/x-iri-selected-html\"]);\n var _svgimgs = snippet.find(\"image\");\n if (_svgimgs.length) {\n newNode.image = _svgimgs.attr(\"xlink:href\");\n }\n var _svgpaths = snippet.find(\"path\");\n if (_svgpaths.length) {\n newNode.clipPath = _svgpaths.attr(\"d\");\n }\n var _imgs = snippet.find(\"img\");\n if (_imgs.length) {\n newNode.image = _imgs[0].src;\n }\n var _as = snippet.find(\"a\");\n if (_as.length) {\n newNode.uri = _as[0].href;\n }\n newNode.title = snippet.find(\"[title]\").attr(\"title\") || newNode.title;\n newNode.description = snippet.text().replace(/[\\s\\n]+/gm,' ').trim();\n }\n if (_data[\"text/uri-list\"]) {\n newNode.uri = _data[\"text/uri-list\"];\n }\n if (_data[\"text/x-moz-url\"] && !newNode.title) {\n newNode.title = (_data[\"text/x-moz-url\"].split(\"\\n\")[1] || \"\").trim();\n if (newNode.title === newNode.uri) {\n newNode.title = false;\n }\n }\n if (_data[\"text/x-iri-source-title\"] && !newNode.title) {\n newNode.title = _data[\"text/x-iri-source-title\"];\n }\n if (_data[\"text/html\"] || _data[\"text/x-iri-selected-html\"]) {\n snippet = $('<div>').html(_data[\"text/html\"] || _data[\"text/x-iri-selected-html\"]);\n newNode.image = snippet.find(\"[data-image]\").attr(\"data-image\") || newNode.image;\n newNode.uri = snippet.find(\"[data-uri]\").attr(\"data-uri\") || newNode.uri;\n newNode.title = snippet.find(\"[data-title]\").attr(\"data-title\") || newNode.title;\n newNode.description = snippet.find(\"[data-description]\").attr(\"data-description\") || newNode.description;\n newNode.clipPath = snippet.find(\"[data-clip-path]\").attr(\"data-clip-path\") || newNode.clipPath;\n }\n\n if (!newNode.title) {\n newNode.title = this.renkan.translate(\"Dragged resource\");\n }\n var fields = [\"title\", \"description\", \"uri\", \"image\"];\n for (var i = 0; i < fields.length; i++) {\n var f = fields[i];\n if (_data[\"text/x-iri-\" + f] || _data[f]) {\n newNode[f] = _data[\"text/x-iri-\" + f] || _data[f];\n }\n if (newNode[f] === \"none\" || newNode[f] === \"null\") {\n newNode[f] = undefined;\n }\n }\n\n if(typeof this.renkan.options.drop_enhancer === \"function\"){\n newNode = this.renkan.options.drop_enhancer(newNode, _data);\n }\n\n return newNode;\n\n },\n dropData: function(_data, _event) {\n if (!this.isEditable()) {\n return;\n }\n if (_data[\"text/json\"] || _data[\"application/json\"]) {\n try {\n var jsondata = JSON.parse(_data[\"text/json\"] || _data[\"application/json\"]);\n _(_data).extend(jsondata);\n }\n catch(e) {}\n }\n\n var newNode = (typeof this.renkan.options.drop_handler === \"undefined\")?this.defaultDropHandler(_data):this.renkan.options.drop_handler(_data);\n\n var _off = this.canvas_$.offset(),\n _point = new paper.Point([\n _event.pageX - _off.left,\n _event.pageY - _off.top\n ]),\n _coords = this.toModelCoords(_point),\n _nodedata = {\n id: Utils.getUID('node'),\n created_by: this.renkan.current_user,\n uri: newNode.uri || \"\",\n title: newNode.title || \"\",\n description: newNode.description || \"\",\n image: newNode.image || \"\",\n color: newNode.color || undefined,\n clip_path: newNode.clipPath || undefined,\n position: {\n x: _coords.x,\n y: _coords.y\n }\n };\n var _node = this.renkan.project.addNode(_nodedata),\n _repr = this.getRepresentationByModel(_node);\n if (_event.type === \"drop\") {\n _repr.openEditor();\n }\n },\n fullScreen: function() {\n var _isFull = document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen,\n _el = this.renkan.$[0],\n _requestMethods = [\"requestFullScreen\",\"mozRequestFullScreen\",\"webkitRequestFullScreen\"],\n _cancelMethods = [\"cancelFullScreen\",\"mozCancelFullScreen\",\"webkitCancelFullScreen\"],\n i;\n if (_isFull) {\n for (i = 0; i < _cancelMethods.length; i++) {\n if (typeof document[_cancelMethods[i]] === \"function\") {\n document[_cancelMethods[i]]();\n break;\n }\n }\n } else {\n for (i = 0; i < _requestMethods.length; i++) {\n if (typeof _el[_requestMethods[i]] === \"function\") {\n _el[_requestMethods[i]]();\n break;\n }\n }\n }\n },\n zoomOut: function() {\n var _newScale = this.scale * Math.SQRT1_2,\n _offset = new paper.Point([\n this.canvas_$.width(),\n this.canvas_$.height()\n ]).multiply( 0.5 * ( 1 - Math.SQRT1_2 ) ).add(this.offset.multiply( Math.SQRT1_2 ));\n this.setScale( _newScale, _offset );\n },\n zoomIn: function() {\n var _newScale = this.scale * Math.SQRT2,\n _offset = new paper.Point([\n this.canvas_$.width(),\n this.canvas_$.height()\n ]).multiply( 0.5 * ( 1 - Math.SQRT2 ) ).add(this.offset.multiply( Math.SQRT2 ));\n this.setScale( _newScale, _offset );\n },\n addNodeBtn: function() {\n if (this.click_mode === Utils._CLICKMODE_ADDNODE) {\n this.click_mode = false;\n this.notif_$.hide();\n } else {\n this.click_mode = Utils._CLICKMODE_ADDNODE;\n this.notif_$.text(this.renkan.translate(\"Click on the background canvas to add a node\")).fadeIn();\n }\n return false;\n },\n addEdgeBtn: function() {\n if (this.click_mode === Utils._CLICKMODE_STARTEDGE || this.click_mode === Utils._CLICKMODE_ENDEDGE) {\n this.click_mode = false;\n this.notif_$.hide();\n } else {\n this.click_mode = Utils._CLICKMODE_STARTEDGE;\n this.notif_$.text(this.renkan.translate(\"Click on a first node to start the edge\")).fadeIn();\n }\n return false;\n },\n exportProject: function() {\n var projectJSON = this.renkan.project.toJSON(),\n downloadLink = document.createElement(\"a\"),\n projectId = projectJSON.id,\n fileNameToSaveAs = projectId + \".json\";\n\n // clean ids\n delete projectJSON.id;\n delete projectJSON._id;\n delete projectJSON.space_id;\n\n var objId;\n var idsMap = {};\n\n _.each(projectJSON.nodes, function(e,i,l) {\n objId = e.id || e._id;\n delete e._id;\n delete e.id;\n idsMap[objId] = e['@id'] = Utils.getUUID4();\n });\n _.each(projectJSON.edges, function(e,i,l) {\n delete e._id;\n delete e.id;\n e.to = idsMap[e.to];\n e.from = idsMap[e.from];\n });\n _.each(projectJSON.views, function(e,i,l) {\n objId = e.id || e._id;\n delete e._id;\n delete e.id;\n });\n projectJSON.users = [];\n\n var projectJSONStr = JSON.stringify(projectJSON, null, 2);\n var blob = new Blob([projectJSONStr], {type: \"application/json;charset=utf-8\"});\n filesaver(blob,fileNameToSaveAs);\n\n },\n foldBins: function() {\n var foldBinsButton = this.$.find(\".Rk-Fold-Bins\"),\n bins = this.renkan.$.find(\".Rk-Bins\");\n var _this = this;\n if (bins.offset().left < 0) {\n bins.animate({left: 0},250);\n this.$.animate({left: 300},250,function() {\n var w = _this.$.width();\n paper.view.viewSize = new paper.Size([w, _this.canvas_$.height()]);\n });\n foldBinsButton.html(\"«\");\n } else {\n bins.animate({left: -300},250);\n this.$.animate({left: 0},250,function() {\n var w = _this.$.width();\n paper.view.viewSize = new paper.Size([w, _this.canvas_$.height()]);\n });\n foldBinsButton.html(\"»\");\n }\n },\n save: function() { },\n open: function() { }\n });\n\n /* Scene End */\n\n return Scene;\n\n});\n\n\n//Load modules and use them\nif( typeof require.config === \"function\" ) {\n require.config({\n paths: {\n 'jquery':'../lib/jquery.min',\n 'underscore':'../lib/underscore-min',\n 'filesaver' :'../lib/FileSaver',\n 'requtils':'require-utils'\n }\n });\n}\n\nrequire(['renderer/baserepresentation',\n 'renderer/basebutton',\n 'renderer/noderepr',\n 'renderer/edge',\n 'renderer/tempedge',\n 'renderer/baseeditor',\n 'renderer/nodeeditor',\n 'renderer/edgeeditor',\n 'renderer/nodebutton',\n 'renderer/nodeeditbutton',\n 'renderer/noderemovebutton',\n 'renderer/noderevertbutton',\n 'renderer/nodelinkbutton',\n 'renderer/nodeenlargebutton',\n 'renderer/nodeshrinkbutton',\n 'renderer/edgeeditbutton',\n 'renderer/edgeremovebutton',\n 'renderer/edgerevertbutton',\n 'renderer/miniframe',\n 'renderer/scene'\n ], function(BaseRepresentation, BaseButton, NodeRepr, Edge, TempEdge, BaseEditor, NodeEditor, EdgeEditor, NodeButton, NodeEditButton, NodeRemoveButton, NodeRevertButton, NodeLinkButton, NodeEnlargeButton, NodeShrinkButton, EdgeEditButton, EdgeRemoveButton, EdgeRevertButton, MiniFrame, Scene){\n\n \n\n var Rkns = window.Rkns;\n\n if(typeof Rkns.Renderer === \"undefined\"){\n Rkns.Renderer = {};\n }\n var Renderer = Rkns.Renderer;\n\n Renderer._BaseRepresentation = BaseRepresentation;\n Renderer._BaseButton = BaseButton;\n Renderer.Node = NodeRepr;\n Renderer.Edge = Edge;\n Renderer.TempEdge = TempEdge;\n Renderer._BaseEditor = BaseEditor;\n Renderer.NodeEditor = NodeEditor;\n Renderer.EdgeEditor = EdgeEditor;\n Renderer._NodeButton = NodeButton;\n Renderer.NodeEditButton = NodeEditButton;\n Renderer.NodeRemoveButton = NodeRemoveButton;\n Renderer.NodeRevertButton = NodeRevertButton;\n Renderer.NodeLinkButton = NodeLinkButton;\n Renderer.NodeEnlargeButton = NodeEnlargeButton;\n Renderer.NodeShrinkButton = NodeShrinkButton;\n Renderer.EdgeEditButton = EdgeEditButton;\n Renderer.EdgeRemoveButton = EdgeRemoveButton;\n Renderer.EdgeRevertButton = EdgeRevertButton;\n Renderer.MiniFrame = MiniFrame;\n Renderer.Scene = Scene;\n \n startRenkan();\n});\n\ndefine(\"main-renderer\", function(){});\n\n"]}
\ No newline at end of file
--- a/server/python/django/renkanmanager/static/renkanmanager/lib/renkan/renkan.js Wed Dec 17 16:31:10 2014 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,4908 +0,0 @@
-/*!
- * _____ _
- * | __ \ | |
- * | |__) |___ _ __ | | ____ _ _ __
- * | _ // _ \ '_ \| |/ / _` | '_ \
- * | | \ \ __/ | | | < (_| | | | |
- * |_| \_\___|_| |_|_|\_\__,_|_| |_|
- *
- * Copyright 2012-2013 Institut de recherche et d'innovation
- * contributor(s) : Yves-Marie Haussonne, Raphael Velt, Samuel Huron
- *
- * contact@iri.centrepompidou.fr
- * http://www.iri.centrepompidou.fr
- *
- * This software is a computer program whose purpose is to show and add annotations on a video .
- * This software is governed by the CeCILL-C license under French law and
- * abiding by the rules of distribution of free software. You can use,
- * modify and/ or redistribute the software under the terms of the CeCILL-C
- * license as circulated by CEA, CNRS and INRIA at the following URL
- * "http://www.cecill.info".
- *
- * The fact that you are presently reading this means that you have had
- * knowledge of the CeCILL-C license and that you accept its terms.
- */
-/*! renkan - v0.7.11 - Copyright © IRI 2014 */
-
-
-/* Declaring the Renkan Namespace Rkns and Default values */
-
-(function(root) {
-
-"use strict";
-
-if (typeof root.Rkns !== "object") {
- root.Rkns = {};
-}
-
-var Rkns = root.Rkns;
-var $ = Rkns.$ = root.jQuery;
-var _ = Rkns._ = root._;
-
-Rkns.pickerColors = ["#8f1919", "#a80000", "#d82626", "#ff0000", "#e87c7c", "#ff6565", "#f7d3d3", "#fecccc",
- "#8f5419", "#a85400", "#d87f26", "#ff7f00", "#e8b27c", "#ffb265", "#f7e5d3", "#fee5cc",
- "#8f8f19", "#a8a800", "#d8d826", "#feff00", "#e8e87c", "#feff65", "#f7f7d3", "#fefecc",
- "#198f19", "#00a800", "#26d826", "#00ff00", "#7ce87c", "#65ff65", "#d3f7d3", "#ccfecc",
- "#198f8f", "#00a8a8", "#26d8d8", "#00feff", "#7ce8e8", "#65feff", "#d3f7f7", "#ccfefe",
- "#19198f", "#0000a8", "#2626d8", "#0000ff", "#7c7ce8", "#6565ff", "#d3d3f7", "#ccccfe",
- "#8f198f", "#a800a8", "#d826d8", "#ff00fe", "#e87ce8", "#ff65fe", "#f7d3f7", "#feccfe",
- "#000000", "#242424", "#484848", "#6d6d6d", "#919191", "#b6b6b6", "#dadada", "#ffffff"];
-
-Rkns.__renkans = [];
-
-var _BaseBin = Rkns._BaseBin = function(_renkan, _opts) {
- if (typeof _renkan !== "undefined") {
- this.renkan = _renkan;
- this.renkan.$.find(".Rk-Bin-Main").hide();
- this.$ = Rkns.$('<li>')
- .addClass("Rk-Bin")
- .appendTo(_renkan.$.find(".Rk-Bin-List"));
- this.title_icon_$ = Rkns.$('<span>')
- .addClass("Rk-Bin-Title-Icon")
- .appendTo(this.$);
-
- var _this = this;
-
- Rkns.$('<a>')
- .attr({
- href: "#",
- title: _renkan.translate("Close bin")
- })
- .addClass("Rk-Bin-Close")
- .html('×')
- .appendTo(this.$)
- .click(function() {
- _this.destroy();
- if (!_renkan.$.find(".Rk-Bin-Main:visible").length) {
- _renkan.$.find(".Rk-Bin-Main:last").slideDown();
- }
- _renkan.resizeBins();
- return false;
- });
- Rkns.$('<a>')
- .attr({
- href: "#",
- title: _renkan.translate("Refresh bin")
- })
- .addClass("Rk-Bin-Refresh")
- .appendTo(this.$)
- .click(function() {
- _this.refresh();
- return false;
- });
- this.count_$ = Rkns.$('<div>')
- .addClass("Rk-Bin-Count")
- .appendTo(this.$);
- this.title_$ = Rkns.$('<h2>')
- .addClass("Rk-Bin-Title")
- .appendTo(this.$);
- this.main_$ = Rkns.$('<div>')
- .addClass("Rk-Bin-Main")
- .appendTo(this.$)
- .html('<h4 class="Rk-Bin-Loading">' + _renkan.translate("Loading, please wait") + '</h4>');
- this.title_$.html(_opts.title || '(new bin)');
- this.renkan.resizeBins();
-
- if (_opts.auto_refresh) {
- window.setInterval(function() {
- _this.refresh();
- },_opts.auto_refresh);
- }
- }
-};
-
-_BaseBin.prototype.destroy = function() {
- this.$.detach();
- this.renkan.resizeBins();
-};
-
-/* Point of entry */
-
-var Renkan = Rkns.Renkan = function(_opts) {
- var _this = this;
-
- Rkns.__renkans.push(this);
-
- this.options = _.defaults(_opts, Rkns.defaults);
-
- _(this.options.property_files).each(function(f) {
- Rkns.$.getJSON(f, function(data) {
- _this.options.properties = _this.options.properties.concat(data);
- });
- });
-
- this.read_only = this.options.read_only || !this.options.editor_mode;
-
- this.project = new Rkns.Models.Project();
-
- if (typeof this.options.user_id !== "undefined") {
- this.current_user = this.options.user_id;
- }
- this.$ = Rkns.$("#" + this.options.container);
- this.$
- .addClass("Rk-Main")
- .html(this.template(this));
-
- this.tabs = [];
- this.search_engines = [];
-
- this.current_user_list = new Rkns.Models.UsersList();
-
- this.current_user_list.on("add remove", function() {
- if (this.renderer) {
- this.renderer.redrawUsers();
- }
- });
-
- this.colorPicker = (function() {
- var _tmpl = _.template('<li data-color="<%=c%>" style="background: <%=c%>"></li>');
- return '<ul class="Rk-Edit-ColorPicker">' + Rkns.pickerColors.map(function(c) { return _tmpl({c:c});}).join("") + '</ul>';
- })();
-
- if (this.options.show_editor) {
- this.renderer = new Rkns.Renderer.Scene(this);
- }
-
- if (!this.options.search.length) {
- this.$.find(".Rk-Web-Search-Form").detach();
- } else {
- var _tmpl = _.template('<li class="<%= className %>" data-key="<%= key %>"><%= title %></li>'),
- _select = this.$.find(".Rk-Search-List"),
- _input = this.$.find(".Rk-Web-Search-Input"),
- _form = this.$.find(".Rk-Web-Search-Form");
- _(this.options.search).each(function(_search, _key) {
- if (Rkns[_search.type] && Rkns[_search.type].Search) {
- _this.search_engines.push(new Rkns[_search.type].Search(_this, _search));
- }
- });
- _select.html(
- _(this.search_engines).map(function(_search, _key) {
- return _tmpl({
- key: _key,
- title: _search.getSearchTitle(),
- className: _search.getBgClass()
- });
- }).join("")
- );
- _select.find("li").click(function() {
- var _el = Rkns.$(this);
- _this.setSearchEngine(_el.attr("data-key"));
- _form.submit();
- });
- _form.submit(function() {
- if (_input.val()) {
- var _search = _this.search_engine;
- _search.search(_input.val());
- }
- return false;
- });
- this.$.find(".Rk-Search-Current").mouseenter(
- function() { _select.slideDown(); }
- );
- this.$.find(".Rk-Search-Select").mouseleave(
- function() { _select.hide(); }
- );
- this.setSearchEngine(0);
- }
- _(this.options.bins).each(function(_bin) {
- if (Rkns[_bin.type] && Rkns[_bin.type].Bin) {
- _this.tabs.push(new Rkns[_bin.type].Bin(_this, _bin));
- }
- });
-
- var elementDropped = false;
-
- this.$.find(".Rk-Bins")
- .on("click",".Rk-Bin-Title,.Rk-Bin-Title-Icon", function() {
- var _mainDiv = Rkns.$(this).siblings(".Rk-Bin-Main");
- if (_mainDiv.is(":hidden")) {
- _this.$.find(".Rk-Bin-Main").slideUp();
- _mainDiv.slideDown();
- }
- });
-
- if (this.options.show_editor) {
-
- this.$.find(".Rk-Bins").on("mouseover", ".Rk-Bin-Item", function(_e) {
- var _t = Rkns.$(this);
- if (_t && $(_t).attr("data-uri")) {
- var _models = _this.project.get("nodes").where({
- uri: $(_t).attr("data-uri")
- });
- _(_models).each(function(_model) {
- _this.renderer.highlightModel(_model);
- });
- }
- }).mouseout(function() {
- _this.renderer.unhighlightAll();
- }).on("mousemove", ".Rk-Bin-Item", function(e) {
- try {
- this.dragDrop();
- }
- catch(err) {}
- }).on("touchstart", ".Rk-Bin-Item", function(e) {
- elementDropped = false;
- }).on("touchmove", ".Rk-Bin-Item", function(e) {
- e.preventDefault();
- var touch = e.originalEvent.changedTouches[0],
- off = _this.renderer.canvas_$.offset(),
- w = _this.renderer.canvas_$.width(),
- h = _this.renderer.canvas_$.height();
- if (touch.pageX >= off.left && touch.pageX < (off.left + w) && touch.pageY >= off.top && touch.pageY < (off.top + h)) {
- if (elementDropped) {
- _this.renderer.onMouseMove(touch, true);
- } else {
- elementDropped = true;
- var div = document.createElement('div');
- div.appendChild(this.cloneNode(true));
- _this.renderer.dropData({"text/html": div.innerHTML}, touch);
- _this.renderer.onMouseDown(touch, true);
- }
- }
- }).on("touchend", ".Rk-Bin-Item", function(e) {
- if (elementDropped) {
- _this.renderer.onMouseUp(e.originalEvent.changedTouches[0], true);
- }
- elementDropped = false;
- }).on("dragstart", ".Rk-Bin-Item", function(e) {
- var div = document.createElement('div');
- div.appendChild(this.cloneNode(true));
- try {
- e.originalEvent.dataTransfer.setData("text/html",div.innerHTML);
- }
- catch(err) {
- e.originalEvent.dataTransfer.setData("text",div.innerHTML);
- }
- });
-
- }
-
- Rkns.$(window).resize(function() {
- _this.resizeBins();
- });
-
- var lastsearch = false, lastval = '';
-
- this.$.find(".Rk-Bins-Search-Input").on("change keyup paste input", function() {
- var val = Rkns.$(this).val();
- if (val === lastval) {
- return;
- }
- var search = Rkns.Utils.regexpFromTextOrArray(val.length > 1 ? val: null);
- if (search.source === lastsearch) {
- return;
- }
- lastsearch = search.source;
- _(_this.tabs).each(function(tab) {
- tab.render(search);
- });
-
- });
- this.$.find(".Rk-Bins-Search-Form").submit(function() {
- return false;
- });
-
-};
-
-Renkan.prototype.template = _.template(
- '<% if (options.show_bins) { %><div class="Rk-Bins"><div class="Rk-Bins-Head"><h2 class="Rk-Bins-Title"><%- translate("Select contents:")%></h2>' +
- '<form class="Rk-Web-Search-Form Rk-Search-Form"><input class="Rk-Web-Search-Input Rk-Search-Input" type="search" placeholder="<%- translate("Search the Web") %>" />' +
- '<div class="Rk-Search-Select"><div class="Rk-Search-Current"></div><ul class="Rk-Search-List"></ul></div>' +
- '<input type="submit" value="" class="Rk-Web-Search-Submit Rk-Search-Submit" title="<%- translate("Search the Web") %>" /></form>' +
- '<form class="Rk-Bins-Search-Form Rk-Search-Form"><input class="Rk-Bins-Search-Input Rk-Search-Input" type="search" placeholder="<%- translate("Search in Bins") %>" />' +
- '<input type="submit" value="" class="Rk-Bins-Search-Submit Rk-Search-Submit" title="<%- translate("Search in Bins") %>" /></form></div>' +
- '<ul class="Rk-Bin-List"></ul></div><% } %>' +
- '<% if (options.show_editor) { %><div class="Rk-Render Rk-Render-<% if (options.show_bins) { %>Panel<% } else { %>Full<% } %>"></div><% } %>'
-);
-
-Renkan.prototype.translate = function(_text) {
- if (Rkns.i18n[this.options.language] && Rkns.i18n[this.options.language][_text]) {
- return Rkns.i18n[this.options.language][_text];
- }
- if (this.options.language.length > 2 && Rkns.i18n[this.options.language.substr(0,2)] && Rkns.i18n[this.options.language.substr(0,2)][_text]) {
- return Rkns.i18n[this.options.language.substr(0,2)][_text];
- }
- return _text;
-};
-
-Renkan.prototype.onStatusChange = function() {
- this.renderer.onStatusChange();
-};
-
-Renkan.prototype.setSearchEngine = function(_key) {
- this.search_engine = this.search_engines[_key];
- this.$.find(".Rk-Search-Current").attr("class","Rk-Search-Current " + this.search_engine.getBgClass());
-};
-
-Renkan.prototype.resizeBins = function() {
- var _d = + this.$.find(".Rk-Bins-Head").outerHeight();
- this.$.find(".Rk-Bin-Title:visible").each(function() {
- _d += Rkns.$(this).outerHeight();
- });
- this.$.find(".Rk-Bin-Main").css({
- height: this.$.find(".Rk-Bins").height() - _d
- });
-};
-
-/* Utility functions */
-var getUUID4 = function() {
- return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
- var r = Math.random()*16|0, v = c === 'x' ? r : (r&0x3|0x8);
- return v.toString(16);
- });
-};
-
-Rkns.Utils = {
- getUUID4 : getUUID4,
- getUID : (function() {
- function pad(n){
- return n<10 ? '0'+n : n;
- }
- var _d = new Date(),
- ID_AUTO_INCREMENT = 0,
- ID_BASE = _d.getUTCFullYear() + '-' +
- pad(_d.getUTCMonth()+1) + '-' +
- pad(_d.getUTCDate()) + '-' +
- getUUID4();
- return function(_base) {
- var _n = (++ID_AUTO_INCREMENT).toString(16),
- _uidbase = (typeof _base === "undefined" ? "" : _base + "-" );
- while (_n.length < 4) { _n = '0' + _n; }
- return _uidbase + ID_BASE + '-' + _n;
- };
- })(),
- getFullURL : function(url) {
-
- if(typeof(url) === 'undefined' || url == null ) {
- return "";
- }
- if(/https?:\/\//.test(url)) {
- return url;
- }
- var img = new Image();
- img.src = url;
- var res = img.src;
- img.src = null;
- return res;
-
- },
- inherit : function(_baseClass, _callbefore) {
-
- var _class = function(_arg) {
- if (typeof _callbefore === "function") {
- _callbefore.apply(this, Array.prototype.slice.call(arguments, 0));
- }
- _baseClass.apply(this, Array.prototype.slice.call(arguments, 0));
- if (typeof this._init === "function" && !this._initialized) {
- this._init.apply(this, Array.prototype.slice.call(arguments, 0));
- this._initialized = true;
- }
- };
- _(_class.prototype).extend(_baseClass.prototype);
-
- return _class;
-
- },
- regexpFromTextOrArray: (function() {
- var charsub = [
- '[aáàâä]',
- '[cç]',
- '[eéèêë]',
- '[iíìîï]',
- '[oóòôö]',
- '[uùûü]'
- ],
- removeChars = [
- String.fromCharCode(768), String.fromCharCode(769), String.fromCharCode(770), String.fromCharCode(771), String.fromCharCode(807),
- "{", "}", "(", ")", "[", "]", "【", "】", "、", "・", "‥", "。", "「", "」", "『", "』", "〜", ":", "!", "?", " ",
- ",", " ", ";", "(", ")", ".", "*", "+", "\\", "?", "|", "{", "}", "[", "]", "^", "#", "/"
- ],
- remsrc = "[\\" + removeChars.join("\\") + "]",
- remrx = new RegExp(remsrc, "gm"),
- charsrx = _(charsub).map(function(c) {
- return new RegExp(c);
- });
-
- function replaceText(_text) {
- var txt = _text.toLowerCase().replace(remrx,""), src = "";
- function makeReplaceFunc(l) {
- return function(k,v) {
- l = l.replace(charsrx[k], v);
- };
- }
- for (var j = 0; j < txt.length; j++) {
- if (j) {
- src += remsrc + "*";
- }
- var l = txt[j];
- _(charsub).each(makeReplaceFunc(l));
- src += l;
- }
- return src;
- }
-
- function getSource(inp) {
- switch (typeof inp) {
- case "string":
- return replaceText(inp);
- case "object":
- var src = '';
- _(inp).each(function(v) {
- var res = getSource(v);
- if (res) {
- if (src) {
- src += '|';
- }
- src += res;
- }
- });
- return src;
- }
- return '';
- }
-
- return function(_textOrArray) {
- var source = getSource(_textOrArray);
- if (source) {
- var testrx = new RegExp( source, "im"),
- replacerx = new RegExp( '(' + source + ')', "igm");
- return {
- isempty: false,
- source: source,
- test: function(_t) { return testrx.test(_t); },
- replace: function(_text, _replace) { return _text.replace(replacerx, _replace); }
- };
- } else {
- return {
- isempty: true,
- source: '',
- test: function() { return true; },
- replace: function(_text) { return text; }
- };
- }
- };
- })(),
- /* The minimum distance (in pixels) the mouse has to move to consider an element was dragged */
- _MIN_DRAG_DISTANCE: 2,
- /* Distance between the inner and outer radius of buttons that appear when hovering on a node */
- _NODE_BUTTON_WIDTH: 40,
-
- _EDGE_BUTTON_INNER: 2,
- _EDGE_BUTTON_OUTER: 40,
- /* Constants used to know if a specific action is to be performed when clicking on the canvas */
- _CLICKMODE_ADDNODE: 1,
- _CLICKMODE_STARTEDGE: 2,
- _CLICKMODE_ENDEDGE: 3,
- /* Node size step: Used to calculate the size change when clicking the +/- buttons */
- _NODE_SIZE_STEP: Math.LN2/4,
- _MIN_SCALE: 1/20,
- _MAX_SCALE: 20,
- _MOUSEMOVE_RATE: 80,
- _DOUBLETAP_DELAY: 800,
- /* Maximum distance in pixels (squared, to reduce calculations)
- * between two taps when double-tapping on a touch terminal */
- _DOUBLETAP_DISTANCE: 20*20,
- /* A placeholder so a default colour is displayed when a node has a null value for its user property */
- _USER_PLACEHOLDER: function(_renkan) {
- return {
- color: _renkan.options.default_user_color,
- title: _renkan.translate("(unknown user)"),
- get: function(attr) {
- return this[attr] || false;
- }
- };
- },
- /* The code for the "Drag and Add Bookmarklet", slightly minified and with whitespaces removed, though
- * it doesn't seem that it's still a requirement in newer browsers (i.e. the ones compatibles with canvas drawing)
- */
- _BOOKMARKLET_CODE: function(_renkan) {
- return "(function(a,b,c,d,e,f,h,i,j,k,l,m,n,o,p,q,r){a=document;b=a.body;c=a.location.href;j='draggable';m='text/x-iri-';d=a.createElement('div');d.innerHTML='<p_style=\"position:fixed;top:0;right:0;font:bold_18px_sans-serif;color:#fff;background:#909;padding:10px;z-index:100000;\">" +
- _renkan.translate("Drag items from this website, drop them in Renkan").replace(/ /g,"_") +
- "</p>'.replace(/_/g,String.fromCharCode(32));b.appendChild(d);e=[{r:/https?:\\/\\/[^\\/]*twitter\\.com\\//,s:'.tweet',n:'twitter'},{r:/https?:\\/\\/[^\\/]*google\\.[^\\/]+\\//,s:'.g',n:'google'},{r:/https?:\\/\\/[^\\/]*lemonde\\.fr\\//,s:'[data-vr-contentbox]',n:'lemonde'}];f=false;e.forEach(function(g){if(g.r.test(c)){f=g;}});if(f){h=function(){Array.prototype.forEach.call(a.querySelectorAll(f.s),function(i){i[j]=true;k=i.style;k.borderWidth='2px';k.borderColor='#909';k.borderStyle='solid';k.backgroundColor='rgba(200,0,180,.1)';})};window.setInterval(h,500);h();};a.addEventListener('dragstart',function(k){l=k.dataTransfer;l.setData(m+'source-uri',c);l.setData(m+'source-title',a.title);n=k.target;if(f){o=n;while(!o.attributes[j]){o=o.parentNode;if(o==b){break;}}}if(f&&o.attributes[j]){p=o.cloneNode(true);l.setData(m+'specific-site',f.n)}else{q=a.getSelection();if(q.type==='Range'||!q.type){p=q.getRangeAt(0).cloneContents();}else{p=n.cloneNode();}}r=a.createElement('div');r.appendChild(p);l.setData('text/x-iri-selected-text',r.textContent.trim());l.setData('text/x-iri-selected-html',r.innerHTML);},false);})();";
- },
- /* Shortens text to the required length then adds ellipsis */
- shortenText: function(_text, _maxlength) {
- return (_text.length > _maxlength ? (_text.substr(0,_maxlength) + '…') : _text);
- },
- /* Drawing an edit box with an arrow and positioning the edit box according to the position of the node/edge being edited
- * Called by Rkns.Renderer.NodeEditor and Rkns.Renderer.EdgeEditor */
- drawEditBox: function(_options, _coords, _path, _xmargin, _selector) {
- _selector.css({
- width: ( _options.tooltip_width - 2* _options.tooltip_padding )
- });
- var _height = _selector.outerHeight() + 2* _options.tooltip_padding,
- _isLeft = (_coords.x < paper.view.center.x ? 1 : -1),
- _left = _coords.x + _isLeft * ( _xmargin + _options.tooltip_arrow_length ),
- _right = _coords.x + _isLeft * ( _xmargin + _options.tooltip_arrow_length + _options.tooltip_width ),
- _top = _coords.y - _height / 2;
- if (_top + _height > (paper.view.size.height - _options.tooltip_margin)) {
- _top = Math.max( paper.view.size.height - _options.tooltip_margin, _coords.y + _options.tooltip_arrow_width / 2 ) - _height;
- }
- if (_top < _options.tooltip_margin) {
- _top = Math.min( _options.tooltip_margin, _coords.y - _options.tooltip_arrow_width / 2 );
- }
- var _bottom = _top + _height;
- /* jshint laxbreak:true */
- _path.segments[0].point
- = _path.segments[7].point
- = _coords.add([_isLeft * _xmargin, 0]);
- _path.segments[1].point.x
- = _path.segments[2].point.x
- = _path.segments[5].point.x
- = _path.segments[6].point.x
- = _left;
- _path.segments[3].point.x
- = _path.segments[4].point.x
- = _right;
- _path.segments[2].point.y
- = _path.segments[3].point.y
- = _top;
- _path.segments[4].point.y
- = _path.segments[5].point.y
- = _bottom;
- _path.segments[1].point.y = _coords.y - _options.tooltip_arrow_width / 2;
- _path.segments[6].point.y = _coords.y + _options.tooltip_arrow_width / 2;
- _path.closed = true;
- _path.fillColor = new paper.GradientColor(new paper.Gradient([_options.tooltip_top_color, _options.tooltip_bottom_color]), [0,_top], [0, _bottom]);
- _selector.css({
- left: (_options.tooltip_padding + Math.min(_left, _right)),
- top: (_options.tooltip_padding + _top)
- });
- return _path;
- }
-};
-})(window);
-
-/* END main.js */
-
-(function() {
- "use strict";
- var root = this;
-
- var Backbone = root.Backbone;
-
- var Models = root.Rkns.Models = {};
-
-
- Models.getUID = function(obj) {
- var guid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
- var r = Math.random()*16|0, v = c === 'x' ? r : (r&0x3|0x8);
- return v.toString(16);
- });
- if(typeof obj !== 'undefined') {
- return obj.type + "-" + guid;
- }
- else {
- return guid;
- }
- };
-
-
- var RenkanModel = Backbone.RelationalModel.extend({
- idAttribute : "_id",
- constructor: function(options) {
-
- if (typeof options !== "undefined") {
- options._id = options._id || options.id || Models.getUID(this);
- options.title = options.title || "";
- options.description = options.description || "";
- options.uri = options.uri || "";
-
- if(typeof this.prepare === "function") {
- options = this.prepare(options);
- }
- }
- Backbone.RelationalModel.prototype.constructor.call(this, options);
- },
- validate: function() {
- if(!this.type) {
- return "object has no type";
- }
- },
- addReference : function(_options, _propName, _list, _id, _default) {
- var _element = _list.get(_id);
- if (typeof _element === "undefined" && typeof _default !== "undefined") {
- _options[_propName ] = _default;
- }
- else {
- _options[_propName ] = _element;
- }
- }
- });
-
- // USER
- var User = Models.User = RenkanModel.extend({
- type: "user",
- prepare: function(options) {
- options.color = options.color || "#666666";
- return options;
- },
- toJSON: function() {
- return {
- _id: this.get("_id"),
- title: this.get("title"),
- uri: this.get("uri"),
- description: this.get("description"),
- color: this.get("color")
- };
- }
- });
-
- // NODE
- var Node = Models.Node = RenkanModel.extend({
- type: "node",
- relations: [{
- type: Backbone.HasOne,
- key: "created_by",
- relatedModel: User
- }],
- prepare: function(options) {
- var project = options.project;
- this.addReference(options, "created_by", project.get("users"), options.created_by, project.current_user);
- options.description = options.description || "";
- return options;
- },
- toJSON: function() {
- return {
- _id: this.get("_id"),
- title: this.get("title"),
- uri: this.get("uri"),
- description: this.get("description"),
- position: this.get("position"),
- image: this.get("image"),
- color: this.get("color"),
- created_by: this.get("created_by") ? this.get("created_by").get("_id") : null,
- size: this.get("size"),
- clip_path: this.get("clip_path"),
- shape: this.get("shape")
- };
- }
- });
-
- // EDGE
- var Edge = Models.Edge = RenkanModel.extend({
- type: "edge",
- relations: [
- {
- type: Backbone.HasOne,
- key: "created_by",
- relatedModel: User
- },
- {
- type: Backbone.HasOne,
- key: "from",
- relatedModel: Node
- },
- {
- type: Backbone.HasOne,
- key: "to",
- relatedModel: Node
- }
- ],
- prepare: function(options) {
- var project = options.project;
- this.addReference(options, "created_by", project.get("users"), options.created_by, project.current_user);
- this.addReference(options, "from", project.get("nodes"), options.from);
- this.addReference(options, "to", project.get("nodes"), options.to);
- return options;
- },
- toJSON: function() {
- return {
- _id: this.get("_id"),
- title: this.get("title"),
- uri: this.get("uri"),
- description: this.get("description"),
- from: this.get("from") ? this.get("from").get("_id") : null,
- to: this.get("to") ? this.get("to").get("_id") : null,
- color: this.get("color"),
- created_by: this.get("created_by") ? this.get("created_by").get("_id") : null
- };
- }
- });
-
- // View
- var View = Models.View = RenkanModel.extend({
- type: "view",
- relations: [
- {
- type: Backbone.HasOne,
- key: "created_by",
- relatedModel: User
- }
- ],
- prepare: function(options) {
- var project = options.project;
- this.addReference(options, "created_by", project.get("users"), options.created_by, project.current_user);
- options.description = options.description || "";
- if(typeof options.offset !== "undefined") {
- var offset = {};
- if (Array.isArray(options.offset)) {
- offset.x = options.offset[0];
- offset.y = options.offset.length > 1 ? options.offset[1] : options.offset[0];
- }
- else if (options.offset.x != null) {
- offset.x = options.offset.x;
- offset.y = options.offset.y;
- }
- options.offset = offset;
- }
- return options;
- },
- toJSON: function() {
- return {
- _id: this.get("_id"),
- zoom_level: this.get("zoom_level"),
- offset: this.get("offset"),
- title: this.get("title"),
- description: this.get("description"),
- created_by: this.get("created_by") ? this.get("created_by").get("_id") : null
- // Don't need project id
- };
- }
- });
-
- // PROJECT
- var Project = Models.Project = RenkanModel.extend({
- type: "project",
- relations: [
- {
- type: Backbone.HasMany,
- key: "users",
- relatedModel: User,
- reverseRelation: {
- key: 'project',
- includeInJSON: '_id'
- }
- },
- {
- type: Backbone.HasMany,
- key: "nodes",
- relatedModel: Node,
- reverseRelation: {
- key: 'project',
- includeInJSON: '_id'
- }
- },
- {
- type: Backbone.HasMany,
- key: "edges",
- relatedModel: Edge,
- reverseRelation: {
- key: 'project',
- includeInJSON: '_id'
- }
- },
- {
- type: Backbone.HasMany,
- key: "views",
- relatedModel: View,
- reverseRelation: {
- key: 'project',
- includeInJSON: '_id'
- }
- }
- ],
- addUser: function(_props, _options) {
- _props.project = this;
- var _user = User.findOrCreate(_props);
- this.get("users").push(_user, _options);
- return _user;
- },
- addNode: function(_props, _options) {
- _props.project = this;
- var _node = Node.findOrCreate(_props);
- this.get("nodes").push(_node, _options);
- return _node;
- },
- addEdge: function(_props, _options) {
- _props.project = this;
- var _edge = Edge.findOrCreate(_props);
- this.get("edges").push(_edge, _options);
- return _edge;
- },
- addView: function(_props, _options) {
- _props.project = this;
- // TODO: check if need to replace with create only
- var _view = View.findOrCreate(_props);
- // TODO: Should we remember only one view?
- this.get("views").push(_view, _options);
- return _view;
- },
- removeNode: function(_model) {
- this.get("nodes").remove(_model);
- },
- removeEdge: function(_model) {
- this.get("edges").remove(_model);
- },
- validate: function(options) {
- var _project = this;
- _([].concat(options.users, options.nodes, options.edges, options.views)).each(function(_item) {
- if(_item) {
- _item.project = _project;
- }
- });
- },
- // Add event handler to remove edges when a node is removed
- initialize: function() {
- var _this = this;
- this.on("remove:nodes", function(_node) {
- _this.get("edges").remove(
- _this.get("edges").filter(function(_edge) {
- return _edge.get("from") === _node || _edge.get("to") === _node;
- })
- );
- });
- }
- });
-
- var RosterUser = Models.RosterUser = Backbone.Model.extend({
- type: "roster_user",
- idAttribute : "_id",
-
- constructor: function(options) {
-
- if (typeof options !== "undefined") {
- options._id = options._id || options.id || Models.getUID(this);
- options.title = options.title || "(untitled " + this.type + ")";
- options.description = options.description || "";
- options.uri = options.uri || "";
- options.project = options.project || null;
- options.site_id = options.site_id || 0;
-
- if(typeof this.prepare === "function") {
- options = this.prepare(options);
- }
- }
- Backbone.Model.prototype.constructor.call(this, options);
- },
-
- validate: function() {
- if(!this.type) {
- return "object has no type";
- }
- },
-
- prepare: function(options) {
- options.color = options.color || "#666666";
- return options;
- },
-
- toJSON: function() {
- return {
- _id: this.get("_id"),
- title: this.get("title"),
- uri: this.get("uri"),
- description: this.get("description"),
- color: this.get("color"),
- project: (this.get("project") != null)?this.get("project").get("id"):null,
- site_id: this.get("site_id")
- };
- }
- });
-
- var UsersList = Models.UsersList = Backbone.Collection.extend({
- model: RosterUser
- });
-
-
-}).call(window);
-
-Rkns.defaults = {
-
- language: (navigator.language || navigator.userLanguage || "en"),
- /* GUI Language */
- container: "renkan",
- /* GUI Container DOM element ID */
- search: [],
- /* List of Search Engines */
- bins: [],
- /* List of Bins */
- static_url: "",
- /* URL for static resources */
- show_bins: true,
- /* Show bins in left column */
- properties: [],
- /* Semantic properties for edges */
- show_editor: true,
- /* Show the graph editor... Setting this to "false" only shows the bins part ! */
- read_only: false,
- /* Allows editing of renkan without changing the rest of the GUI. Can be switched on/off on the fly to block/enable editing */
- editor_mode: true,
- /* Switch for Publish/Edit GUI. If editor_mode is false, read_only will be true. */
- manual_save: false,
- /* In snapshot mode, clicking on the floppy will save a snapshot. Otherwise, it will show the connection status */
- show_top_bar: true,
- /* Show the top bar, (title, buttons, users) */
- default_user_color: "#303030",
- size_bug_fix: true,
- /* Resize the canvas after load (fixes a bug on iPad and FF Mac) */
- force_resize: false,
- allow_double_click: true,
- /* Allows Double Click to create a node on an empty background */
- zoom_on_scroll: true,
- /* Allows to use the scrollwheel to zoom */
- element_delete_delay: 0,
- /* Delay between clicking on the bin on an element and really deleting it
- Set to 0 for delete confirm */
- autoscale_padding: 50,
- default_view: false,
- /* Allows to load default view (zoom+offset) at start on read_only mode, instead of autoScale. default_view has to be an integer 0,1,2... */
-
- /* TOP BAR BUTTONS */
- show_search_field: true,
- show_user_list: true,
- user_name_editable: true,
- user_color_editable: true,
- show_save_button: true,
- show_export_button: true,
- show_open_button: false,
- show_addnode_button: true,
- show_addedge_button: true,
- show_bookmarklet: true,
- show_fullscreen_button: true,
- home_button_url: false,
- home_button_title: "Home",
-
- /* MINI-MAP OPTIONS */
-
- show_minimap: true,
- /* Show a small map at the bottom right */
- minimap_width: 160,
- minimap_height: 120,
- minimap_padding: 20,
- minimap_background_color: "#ffffff",
- minimap_border_color: "#cccccc",
- minimap_highlight_color: "#ffff00",
- minimap_highlight_weight: 5,
-
- /* EDGE/NODE COMMON OPTIONS */
-
- buttons_background: "#202020",
- buttons_label_color: "#c000c0",
- buttons_label_font_size: 9,
-
- /* NODE DISPLAY OPTIONS */
-
- show_node_circles: true,
- /* Show circles for nodes */
- clip_node_images: true,
- /* Constraint node images to circles */
- node_images_fill_mode: false,
- /* Set to false for "letterboxing" (height/width of node adapted to show full image)
- Set to true for "crop" (adapted to fill circle) */
- node_size_base: 25,
- node_stroke_width: 2,
- selected_node_stroke_width: 4,
- node_fill_color: "#ffffff",
- highlighted_node_fill_color: "#ffff00",
- node_label_distance: 5,
- /* Vertical distance between node and label */
- node_label_max_length: 60,
- /* Maximum displayed text length */
- label_untitled_nodes: "(untitled)",
- /* Label to display on untitled nodes */
- change_shapes: true,
- /* Change shapes enabled */
-
- /* EDGE DISPLAY OPTIONS */
-
- edge_stroke_width: 2,
- selected_edge_stroke_width: 4,
- edge_label_distance: 0,
- edge_label_max_length: 20,
- edge_arrow_length: 18,
- edge_arrow_width: 12,
- edge_gap_in_bundles: 12,
- label_untitled_edges: "",
-
- /* CONTEXTUAL DISPLAY (TOOLTIP OR EDITOR) OPTIONS */
-
- tooltip_width: 275,
- tooltip_padding: 10,
- tooltip_margin: 15,
- tooltip_arrow_length : 20,
- tooltip_arrow_width : 40,
- tooltip_top_color: "#f0f0f0",
- tooltip_bottom_color: "#d0d0d0",
- tooltip_border_color: "#808080",
- tooltip_border_width: 1,
-
- /* NODE EDITOR OPTIONS */
-
- show_node_editor_uri: true,
- show_node_editor_description: true,
- show_node_editor_size: true,
- show_node_editor_color: true,
- show_node_editor_image: true,
- show_node_editor_creator: true,
- uploaded_image_max_kb: 500,
-
- /* NODE TOOLTIP OPTIONS */
-
- show_node_tooltip_uri: true,
- show_node_tooltip_description: true,
- show_node_tooltip_color: true,
- show_node_tooltip_image: true,
- show_node_tooltip_creator: true,
-
- /* EDGE EDITOR OPTIONS */
-
- show_edge_editor_uri: true,
- show_edge_editor_color: true,
- show_edge_editor_direction: true,
- show_edge_editor_nodes: true,
- show_edge_editor_creator: true,
-
- /* EDGE TOOLTIP OPTIONS */
-
- show_edge_tooltip_uri: true,
- show_edge_tooltip_color: true,
- show_edge_tooltip_nodes: true,
- show_edge_tooltip_creator: true
-
- /* */
-
-};
-
-Rkns.i18n = {
- fr: {
- "Edit Node": "Édition d’un nœud",
- "Edit Edge": "Édition d’un lien",
- "Title:": "Titre :",
- "URI:": "URI :",
- "Description:": "Description :",
- "From:": "De :",
- "To:": "Vers :",
- "Image": "Image",
- "Image URL:": "URL d'Image",
- "Choose Image File:": "Choisir un fichier image",
- "Full Screen": "Mode plein écran",
- "Add Node": "Ajouter un nœud",
- "Add Edge": "Ajouter un lien",
- "Save Project": "Enregistrer le projet",
- "Open Project": "Ouvrir un projet",
- "Auto-save enabled": "Enregistrement automatique activé",
- "Connection lost": "Connexion perdue",
- "Created by:": "Créé par :",
- "Zoom In": "Agrandir l’échelle",
- "Zoom Out": "Rapetisser l’échelle",
- "Edit": "Éditer",
- "Remove": "Supprimer",
- "Cancel deletion": "Annuler la suppression",
- "Link to another node": "Créer un lien",
- "Enlarge": "Agrandir",
- "Shrink": "Rétrécir",
- "Click on the background canvas to add a node": "Cliquer sur le fond du graphe pour rajouter un nœud",
- "Click on a first node to start the edge": "Cliquer sur un premier nœud pour commencer le lien",
- "Click on a second node to complete the edge": "Cliquer sur un second nœud pour terminer le lien",
- "Wikipedia": "Wikipédia",
- "Wikipedia in ": "Wikipédia en ",
- "French": "Français",
- "English": "Anglais",
- "Japanese": "Japonais",
- "Untitled project": "Projet sans titre",
- "Lignes de Temps": "Lignes de Temps",
- "Loading, please wait": "Chargement en cours, merci de patienter",
- "Edge color:": "Couleur :",
- "Node color:": "Couleur :",
- "Choose color": "Choisir une couleur",
- "Change edge direction": "Changer le sens du lien",
- "Do you really wish to remove node ": "Voulez-vous réellement supprimer le nœud ",
- "Do you really wish to remove edge ": "Voulez-vous réellement supprimer le lien ",
- "This file is not an image": "Ce fichier n'est pas une image",
- "Image size must be under ": "L'image doit peser moins de ",
- "Size:": "Taille :",
- "KB": "ko",
- "Choose from vocabulary:": "Choisir dans un vocabulaire :",
- "SKOS Documentation properties": "SKOS: Propriétés documentaires",
- "has note": "a pour note",
- "has example": "a pour exemple",
- "has definition": "a pour définition",
- "SKOS Semantic relations": "SKOS: Relations sémantiques",
- "has broader": "a pour concept plus large",
- "has narrower": "a pour concept plus étroit",
- "has related": "a pour concept apparenté",
- "Dublin Core Metadata": "Métadonnées Dublin Core",
- "has contributor": "a pour contributeur",
- "covers": "couvre",
- "created by": "créé par",
- "has date": "a pour date",
- "published by": "édité par",
- "has source": "a pour source",
- "has subject": "a pour sujet",
- "Dragged resource": "Ressource glisée-déposée",
- "Search the Web": "Rechercher en ligne",
- "Search in Bins": "Rechercher dans les chutiers",
- "Close bin": "Fermer le chutier",
- "Refresh bin": "Rafraîchir le chutier",
- "(untitled)": "(sans titre)",
- "Select contents:": "Sélectionner des contenus :",
- "Drag items from this website, drop them in Renkan": "Glissez des éléments de ce site web vers Renkan",
- "Drag this button to your bookmark bar. When on a third-party website, click it to enable drag-and-drop from the website to Renkan.": "Glissez ce bouton vers votre barre de favoris. Ensuite, depuis un site tiers, cliquez dessus pour activer 'Drag-to-Add' puis glissez des éléments de ce site vers Renkan",
- "Shapes available": "Formes disponibles",
- "Circle": "Cercle",
- "Square": "Carré",
- "Diamond": "Losange",
- "Hexagone": "Hexagone",
- "Ellipse": "Ellipse",
- "Star": "Étoile"
- }
-};
-
-/* Saves the Full JSON at each modification */
-
-Rkns.jsonIO = function(_renkan, _opts) {
- var _proj = _renkan.project;
- if (typeof _opts.http_method === "undefined") {
- _opts.http_method = 'PUT';
- }
- var _load = function() {
- _renkan.renderer.redrawActive = false;
- Rkns.$.getJSON(_opts.url, function(_data) {
- _proj.set(_data, {validate: true});
- _renkan.renderer.redrawActive = true;
- _renkan.renderer.autoScale();
- });
- };
- var _save = function() {
- var _data = _proj.toJSON();
- if (!_renkan.read_only) {
- Rkns.$.ajax({
- type: _opts.http_method,
- url: _opts.url,
- contentType: "application/json",
- data: JSON.stringify(_data),
- success: function(data, textStatus, jqXHR) {
- }
- });
- }
-
- };
- var _thrSave = Rkns._.throttle(
- function() {
- setTimeout(_save, 100);
- }, 1000);
- _proj.on("add:nodes add:edges add:users add:views", function(_model) {
- _model.on("change remove", function(_model) {
- _thrSave();
- });
- _thrSave();
- });
- _proj.on("change", function() {
- _thrSave();
- });
-
- _load();
-};
-
-/* Saves the Full JSON once */
-
-Rkns.jsonIOSaveOnClick = function(_renkan, _opts) {
- var _proj = _renkan.project,
- _saveWarn = false,
- _onLeave = function() {
- return "Project not saved";
- };
- if (typeof _opts.http_method === "undefined") {
- _opts.http_method = 'POST';
- }
- var _load = function() {
- var getdata = {},
- rx = /id=([^&#?=]+)/,
- matches = document.location.hash.match(rx);
- if (matches) {
- getdata.id = matches[1];
- }
- Rkns.$.ajax({
- url: _opts.url,
- data: getdata,
- success: function(_data) {
- _proj.set(_data, {validate: true});
- _renkan.renderer.autoScale();
- }
- });
- };
- var _save = function() {
- _proj.set("saved_at", new Date());
- var _data = _proj.toJSON();
- Rkns.$.ajax({
- type: _opts.http_method,
- url: _opts.url,
- contentType: "application/json",
- data: JSON.stringify(_data),
- success: function(data, textStatus, jqXHR) {
- $(window).off("beforeunload", _onLeave);
- _saveWarn = false;
- //document.location.hash = "#id=" + data.id;
- //$(".Rk-Notifications").text("Saved as "+document.location.href).fadeIn().delay(2000).fadeOut();
- }
- });
- };
- var _checkLeave = function() {
- var title = _proj.get("title");
- if (title && _proj.get("nodes").length) {
- $(".Rk-Save-Button").removeClass("disabled");
- } else {
- $(".Rk-Save-Button").addClass("disabled");
- }
- if (title) {
- $(".Rk-PadTitle").css("border-color","#333333");
- }
- if (!_saveWarn) {
- _saveWarn = true;
- $(window).on("beforeunload", _onLeave);
- }
- };
- _load();
- _proj.on("add:nodes add:edges add:users change", function(_model) {
- _model.on("change remove", function(_model) {
- _checkLeave();
- });
- _checkLeave();
- });
- _renkan.renderer.save = function() {
- if ($(".Rk-Save-Button").hasClass("disabled")) {
- if (!_proj.get("title")) {
- $(".Rk-PadTitle").css("border-color","#ff0000");
- }
- } else {
- _save();
- }
- };
-};
-
-(function(Rkns) {
-"use strict";
-
-var _ = Rkns._;
-
-var Ldt = Rkns.Ldt = {};
-
-var Bin = Ldt.Bin = function(_renkan, _opts) {
- if (_opts.ldt_type) {
- var Resclass = Ldt[_opts.ldt_type+"Bin"];
- if (Resclass) {
- return new Resclass(_renkan, _opts);
- }
- }
- console.error("No such LDT Bin Type");
-};
-
-var ProjectBin = Ldt.ProjectBin = Rkns.Utils.inherit(Rkns._BaseBin);
-
-ProjectBin.prototype.tagTemplate = _.template(
- '<li class="Rk-Bin-Item" draggable="true" data-image="<%- Rkns.Utils.getFullURL(static_url+\'img/ldt-tag.png\') %>" data-uri="<%=ldt_platform%>ldtplatform/ldt/front/search/?search=<%=encodedtitle%>&field=all" data-title="<%-title%>" data-description="Tag \'<%-title%>\'">' +
- '<img class="Rk-Ldt-Tag-Icon" src="<%-static_url%>img/ldt-tag.png" /><h4><%=htitle%></h4><div class="Rk-Clear"></div></li>'
-);
-
-ProjectBin.prototype.annotationTemplate = _.template(
- '<li class="Rk-Bin-Item" draggable="true" data-image="<%- Rkns.Utils.getFullURL(image) %>" data-uri="<%=ldt_platform%>ldtplatform/ldt/front/player/<%=mediaid%>/#id=<%=annotationid%>" data-title="<%-title%>" data-description="<%-description%>">' +
- '<img class="Rk-Ldt-Annotation-Icon" src="<%=image%>"/><h4><%=htitle%></h4><p><%=hdescription%></p><p>Start: <%=start%>, End: <%=end%>, Duration: <%=duration%></p><div class="Rk-Clear"></div></li>'
-);
-
-ProjectBin.prototype._init = function(_renkan, _opts) {
- this.renkan = _renkan;
- this.proj_id = _opts.project_id;
- this.ldt_platform = _opts.ldt_platform || "http://ldt.iri.centrepompidou.fr/";
- this.title_$.html(_opts.title);
- this.title_icon_$.addClass('Rk-Ldt-Title-Icon');
- this.refresh();
-};
-
-ProjectBin.prototype.render = function(searchbase) {
- var search = searchbase || Rkns.Utils.regexpFromTextOrArray();
- function highlight(_text) {
- var _e = _(_text).escape();
- return search.isempty ? _e : search.replace(_e, "<span class='searchmatch'>$1</span>");
- }
- function convertTC(_ms) {
- function pad(_n) {
- var _res = _n.toString();
- while (_res.length < 2) {
- _res = '0' + _res;
- }
- return _res;
- }
- var _totalSeconds = Math.abs(Math.floor(_ms/1000)),
- _hours = Math.floor(_totalSeconds / 3600),
- _minutes = (Math.floor(_totalSeconds / 60) % 60),
- _seconds = _totalSeconds % 60,
- _res = '';
- if (_hours) {
- _res += pad(_hours) + ':';
- }
- _res += pad(_minutes) + ':' + pad(_seconds);
- return _res;
- }
-
- var _html = '<li><h3>Tags</h3></li>',
- _projtitle = this.data.meta["dc:title"],
- _this = this,
- count = 0;
- _this.title_$.text('LDT Project: "' + _projtitle + '"');
- _(_this.data.tags).map(function(_tag) {
- var _title = _tag.meta["dc:title"];
- if (!search.isempty && !search.test(_title)) {
- return;
- }
- count++;
- _html += _this.tagTemplate({
- ldt_platform: _this.ldt_platform,
- title: _title,
- htitle: highlight(_title),
- encodedtitle : encodeURIComponent(_title),
- static_url: _this.renkan.options.static_url
- });
- });
- _html += '<li><h3>Annotations</h3></li>';
- _(_this.data.annotations).map(function(_annotation) {
- var _description = _annotation.content.description,
- _title = _annotation.content.title.replace(_description,"");
- if (!search.isempty && !search.test(_title) && !search.test(_description)) {
- return;
- }
- count++;
- var _duration = _annotation.end - _annotation.begin,
- _img = (
- (_annotation.content && _annotation.content.img && _annotation.content.img.src) ?
- _annotation.content.img.src :
- ( _duration ? _this.renkan.options.static_url+"img/ldt-segment.png" : _this.renkan.options.static_url+"img/ldt-point.png" )
- );
- _html += _this.annotationTemplate({
- ldt_platform: _this.ldt_platform,
- title: _title,
- htitle: highlight(_title),
- description: _description,
- hdescription: highlight(_description),
- start: convertTC(_annotation.begin),
- end: convertTC(_annotation.end),
- duration: convertTC(_duration),
- mediaid: _annotation.media,
- annotationid: _annotation.id,
- image: _img,
- static_url: _this.renkan.options.static_url
- });
- });
-
- this.main_$.html(_html);
- if (!search.isempty && count) {
- this.count_$.text(count).show();
- } else {
- this.count_$.hide();
- }
- if (!search.isempty && !count) {
- this.$.hide();
- } else {
- this.$.show();
- }
- this.renkan.resizeBins();
-};
-
-ProjectBin.prototype.refresh = function() {
- var _this = this;
- Rkns.$.ajax({
- url: this.ldt_platform + 'ldtplatform/ldt/cljson/id/' + this.proj_id,
- dataType: "jsonp",
- success: function(_data) {
- _this.data = _data;
- _this.render();
- }
- });
-};
-
-var Search = Ldt.Search = function(_renkan, _opts) {
- this.renkan = _renkan;
- this.lang = _opts.lang || "en";
-};
-
-Search.prototype.getBgClass = function() {
- return "Rk-Ldt-Icon";
-};
-
-Search.prototype.getSearchTitle = function() {
- return this.renkan.translate("Lignes de Temps");
-};
-
-Search.prototype.search = function(_q) {
- this.renkan.tabs.push(
- new ResultsBin(this.renkan, {
- search: _q
- })
- );
-};
-
-var ResultsBin = Ldt.ResultsBin = Rkns.Utils.inherit(Rkns._BaseBin);
-
-ResultsBin.prototype.segmentTemplate = _.template(
- '<li class="Rk-Bin-Item" draggable="true" data-image="<%- Rkns.Utils.getFullURL(image) %>" data-uri="<%=ldt_platform%>ldtplatform/ldt/front/player/<%=mediaid%>/#id=<%=annotationid%>" data-title="<%-title%>" data-description="<%-description%>">' +
- '<img class="Rk-Ldt-Annotation-Icon" src="<%=image%>"/><h4><%=htitle%></h4><p><%=hdescription%></p><p>Start: <%=start%>, End: <%=end%>, Duration: <%=duration%></p><div class="Rk-Clear"></div></li>'
-);
-
-ResultsBin.prototype._init = function(_renkan, _opts) {
- this.renkan = _renkan;
- this.ldt_platform = _opts.ldt_platform || "http://ldt.iri.centrepompidou.fr/";
- this.max_results = _opts.max_results || 50;
- this.search = _opts.search;
- this.title_$.html('Lignes de Temps: "' + _opts.search + '"');
- this.title_icon_$.addClass('Rk-Ldt-Title-Icon');
- this.refresh();
-};
-
-ResultsBin.prototype.render = function(searchbase) {
- if (!this.data) {
- return;
- }
- var search = searchbase || Rkns.Utils.regexpFromTextOrArray();
- var highlightrx = (search.isempty ? Rkns.Utils.regexpFromTextOrArray(this.search) : search);
- function highlight(_text) {
- return highlightrx.replace(_(_text).escape(), "<span class='searchmatch'>$1</span>");
- }
- function convertTC(_ms) {
- function pad(_n) {
- var _res = _n.toString();
- while (_res.length < 2) {
- _res = '0' + _res;
- }
- return _res;
- }
- var _totalSeconds = Math.abs(Math.floor(_ms/1000)),
- _hours = Math.floor(_totalSeconds / 3600),
- _minutes = (Math.floor(_totalSeconds / 60) % 60),
- _seconds = _totalSeconds % 60,
- _res = '';
- if (_hours) {
- _res += pad(_hours) + ':';
- }
- _res += pad(_minutes) + ':' + pad(_seconds);
- return _res;
- }
-
- var _html = '',
- _this = this,
- count = 0;
- _(this.data.objects).each(function(_segment) {
- var _description = _segment.abstract,
- _title = _segment.title;
- if (!search.isempty && !search.test(_title) && !search.test(_description)) {
- return;
- }
- count++;
- var _duration = _segment.duration,
- _begin = _segment.start_ts,
- _end = + _segment.duration + _begin,
- _img = (
- _duration ?
- _this.renkan.options.static_url + "img/ldt-segment.png" :
- _this.renkan.options.static_url + "img/ldt-point.png"
- );
- _html += _this.segmentTemplate({
- ldt_platform: _this.ldt_platform,
- title: _title,
- htitle: highlight(_title),
- description: _description,
- hdescription: highlight(_description),
- start: convertTC(_begin),
- end: convertTC(_end),
- duration: convertTC(_duration),
- mediaid: _segment.iri_id,
- //projectid: _segment.project_id,
- //cuttingid: _segment.cutting_id,
- annotationid: _segment.element_id,
- image: _img
- });
- });
-
- this.main_$.html(_html);
- if (!search.isempty && count) {
- this.count_$.text(count).show();
- } else {
- this.count_$.hide();
- }
- if (!search.isempty && !count) {
- this.$.hide();
- } else {
- this.$.show();
- }
- this.renkan.resizeBins();
-};
-
-ResultsBin.prototype.refresh = function() {
- var _this = this;
- Rkns.$.ajax({
- url: this.ldt_platform + 'ldtplatform/api/ldt/1.0/segments/search/',
- data: {
- format: "jsonp",
- q: this.search,
- limit: this.max_results
- },
- dataType: "jsonp",
- success: function(_data) {
- _this.data = _data;
- _this.render();
- }
- });
-};
-
-})(window.Rkns);
-
-Rkns.ResourceList = {};
-
-Rkns.ResourceList.Bin = Rkns.Utils.inherit(Rkns._BaseBin);
-
-Rkns.ResourceList.Bin.prototype.resultTemplate = Rkns._.template(
- '<li class="Rk-Bin-Item Rk-ResourceList-Item" draggable="true" data-uri="<%-url%>" ' +
- 'data-title="<%-title%>" data-description="<%-description%>" ' +
- '<% if (image) { %>data-image="<%- Rkns.Utils.getFullURL(image) %>"<% } else { %>data-image=""<% } %> >' +
- '<% if (image) { %><img class="Rk-ResourceList-Image" src="<%-image%>"/><% } %><h4 class="Rk-ResourceList-Title">' +
- '<% if (url) { %><a href="<%-url%>" target="_blank"><% } %><%=htitle%><% if (url) { %></a><% } %></h4>' +
- '<% if (description) { %><p class="Rk-ResourceList-Description"><%=hdescription%></p><% } %><% if (image) { %><div style="clear: both;"></div><% } %></li>'
-);
-
-Rkns.ResourceList.Bin.prototype._init = function(_renkan, _opts) {
- this.renkan = _renkan;
- this.title_$.html(_opts.title);
- if (_opts.list) {
- this.data = _opts.list;
- }
- this.refresh();
-};
-
-Rkns.ResourceList.Bin.prototype.render = function(searchbase) {
- var search = searchbase || Rkns.Utils.regexpFromTextOrArray();
- function highlight(_text) {
- var _e = _(_text).escape();
- return search.isempty ? _e : search.replace(_e, "<span class='searchmatch'>$1</span>");
- }
- var _html = "",
- _this = this,
- count = 0;
- Rkns._(this.data).each(function(_item) {
- var _element;
- if (typeof _item === "string") {
- if (/^(https?:\/\/|www)/.test(_item)) {
- _element = { url: _item };
- } else {
- _element = { title: _item.replace(/[:,]?\s?(https?:\/\/|www)[\d\w\/.&?=#%-_]+\s?/,'').trim() };
- var _match = _item.match(/(https?:\/\/|www)[\d\w\/.&?=#%-_]+/);
- if (_match) {
- _element.url = _match[0];
- }
- if (_element.title.length > 80) {
- _element.description = _element.title;
- _element.title = _element.title.replace(/^(.{30,60})\s.+$/,'$1…');
- }
- }
- } else {
- _element = _item;
- }
- var title = _element.title || (_element.url || "").replace(/^https?:\/\/(www\.)?/,'').replace(/^(.{40}).+$/,'$1…'),
- url = _element.url || "",
- description = _element.description || "",
- image = _element.image || "";
- if (url && !/^https?:\/\//.test(url)) {
- url = 'http://' + url;
- }
- if (!search.isempty && !search.test(title) && !search.test(description)) {
- return;
- }
- count++;
- _html += _this.resultTemplate({
- url: url,
- title: title,
- htitle: highlight(title),
- image: image,
- description: description,
- hdescription: highlight(description),
- static_url: _this.renkan.options.static_url
- });
- });
- _this.main_$.html(_html);
- if (!search.isempty && count) {
- this.count_$.text(count).show();
- } else {
- this.count_$.hide();
- }
- if (!search.isempty && !count) {
- this.$.hide();
- } else {
- this.$.show();
- }
- this.renkan.resizeBins();
-};
-
-Rkns.ResourceList.Bin.prototype.refresh = function() {
- if (this.data) {
- this.render();
- }
-};
-
-Rkns.Wikipedia = {
-};
-
-Rkns.Wikipedia.Search = function(_renkan, _opts) {
- this.renkan = _renkan;
- this.lang = _opts.lang || "en";
-};
-
-Rkns.Wikipedia.Search.prototype.getBgClass = function() {
- return "Rk-Wikipedia-Search-Icon Rk-Wikipedia-Lang-" + this.lang;
-};
-
-Rkns.Wikipedia.Search.prototype.getSearchTitle = function() {
- var langs = {
- "fr": "French",
- "en": "English",
- "ja": "Japanese"
- };
- if (langs[this.lang]) {
- return this.renkan.translate("Wikipedia in ") + this.renkan.translate(langs[this.lang]);
- } else {
- return this.renkan.translate("Wikipedia") + " [" + this.lang + "]";
- }
-};
-
-Rkns.Wikipedia.Search.prototype.search = function(_q) {
- this.renkan.tabs.push(
- new Rkns.Wikipedia.Bin(this.renkan, {
- lang: this.lang,
- search: _q
- })
- );
-};
-
-Rkns.Wikipedia.Bin = Rkns.Utils.inherit(Rkns._BaseBin);
-
-Rkns.Wikipedia.Bin.prototype.resultTemplate = Rkns._.template(
- '<li class="Rk-Wikipedia-Result Rk-Bin-Item" draggable="true" data-uri="<%-url%>" ' +
- 'data-title="Wikipedia: <%-title%>" data-description="<%-description%>" data-image="<%- Rkns.Utils.getFullURL( static_url + \'img/wikipedia.png\' ) %>">' +
- '<img class="Rk-Wikipedia-Icon" src="<%-static_url%>img/wikipedia.png"></div><h4 class="Rk-Wikipedia-Title"><a href="<%-url%>" target="_blank"><%=htitle%></a></h4>' +
- '<p class="Rk-Wikipedia-Snippet"><%=hdescription%></p></li>'
-);
-
-Rkns.Wikipedia.Bin.prototype._init = function(_renkan, _opts) {
- this.renkan = _renkan;
- this.search = _opts.search;
- this.lang = _opts.lang || "en";
- this.title_icon_$.addClass('Rk-Wikipedia-Title-Icon Rk-Wikipedia-Lang-' + this.lang);
- this.title_$.html(this.search).addClass("Rk-Wikipedia-Title");
- this.refresh();
-};
-
-Rkns.Wikipedia.Bin.prototype.render = function(searchbase) {
- var search = searchbase || Rkns.Utils.regexpFromTextOrArray();
- var highlightrx = (search.isempty ? Rkns.Utils.regexpFromTextOrArray(this.search) : search);
- function highlight(_text) {
- return highlightrx.replace(_(_text).escape(), "<span class='searchmatch'>$1</span>");
- }
- var _html = "",
- _this = this,
- count = 0;
- Rkns._(this.data.query.search).each(function(_result) {
- var title = _result.title,
- url = "http://" + _this.lang + ".wikipedia.org/wiki/" + encodeURI(title.replace(/ /g,"_")),
- description = Rkns.$('<div>').html(_result.snippet).text();
- if (!search.isempty && !search.test(title) && !search.test(description)) {
- return;
- }
- count++;
- _html += _this.resultTemplate({
- url: url,
- title: title,
- htitle: highlight(title),
- description: description,
- hdescription: highlight(description),
- static_url: _this.renkan.options.static_url
- });
- });
- _this.main_$.html(_html);
- if (!search.isempty && count) {
- this.count_$.text(count).show();
- } else {
- this.count_$.hide();
- }
- if (!search.isempty && !count) {
- this.$.hide();
- } else {
- this.$.show();
- }
- this.renkan.resizeBins();
-};
-
-Rkns.Wikipedia.Bin.prototype.refresh = function() {
- var _this = this;
- Rkns.$.ajax({
- url: "http://" + _this.lang + ".wikipedia.org/w/api.php?action=query&list=search&srsearch=" + encodeURIComponent(this.search) + "&format=json",
- dataType: "jsonp",
- success: function(_data) {
- _this.data = _data;
- _this.render();
- }
- });
-};
-
-
-define('renderer/baserepresentation',['jquery', 'underscore'], function ($, _) {
-
-
- /* Rkns.Renderer._BaseRepresentation Class */
-
- /* In Renkan, a "Representation" is a sort of ViewModel (in the MVVM paradigm) and bridges the gap between
- * models (written with Backbone.js) and the view (written with Paper.js)
- * Renkan's representations all inherit from Rkns.Renderer._BaseRepresentation '*/
-
- var _BaseRepresentation = function(_renderer, _model) {
- if (typeof _renderer !== "undefined") {
- this.renderer = _renderer;
- this.renkan = _renderer.renkan;
- this.project = _renderer.renkan.project;
- this.options = _renderer.renkan.options;
- this.model = _model;
- if (this.model) {
- var _this = this;
- this._changeBinding = function() {
- _this.redraw();
- };
- this._removeBinding = function() {
- _renderer.removeRepresentation(_this);
- _(function() {
- _renderer.redraw();
- }).defer();
- };
- this._selectBinding = function() {
- _this.select();
- };
- this._unselectBinding = function() {
- _this.unselect();
- };
- this.model.on("change", this._changeBinding );
- this.model.on("remove", this._removeBinding );
- this.model.on("select", this._selectBinding );
- this.model.on("unselect", this._unselectBinding );
- }
- }
- };
-
- /* Rkns.Renderer._BaseRepresentation Methods */
-
- _(_BaseRepresentation.prototype).extend({
- _super: function(_func) {
- return _BaseRepresentation.prototype[_func].apply(this, Array.prototype.slice.call(arguments, 1));
- },
- redraw: function() {},
- moveTo: function() {},
- show: function() { return "chaud cacao"; },
- hide: function() {},
- select: function() {
- if (this.model) {
- this.model.trigger("selected");
- }
- },
- unselect: function() {
- if (this.model) {
- this.model.trigger("unselected");
- }
- },
- highlight: function() {},
- unhighlight: function() {},
- mousedown: function() {},
- mouseup: function() {
- if (this.model) {
- this.model.trigger("clicked");
- }
- },
- destroy: function() {
- if (this.model) {
- this.model.off("change", this._changeBinding );
- this.model.off("remove", this._removeBinding );
- this.model.off("select", this._selectBinding );
- this.model.off("unselect", this._unselectBinding );
- }
- }
- });
-
- /* End of Rkns.Renderer._BaseRepresentation Class */
-
- return _BaseRepresentation;
-
-});
-
-define('requtils',[], function ($, _) {
-
- return {
- getUtils: function(){
- return window.Rkns.Utils;
- },
- getRenderer: function(){
- return window.Rkns.Renderer;
- }
- };
-
-});
-
-
-define('renderer/basebutton',['jquery', 'underscore', 'requtils', 'renderer/baserepresentation'], function ($, _, requtils, BaseRepresentation) {
-
-
- var Utils = requtils.getUtils();
-
- /* Rkns.Renderer._BaseButton Class */
-
- /* BaseButton is extended by contextual buttons that appear when hovering on nodes and edges */
-
- var _BaseButton = Utils.inherit(BaseRepresentation);
-
- _(_BaseButton.prototype).extend({
- moveTo: function(_pos) {
- this.sector.moveTo(_pos);
- },
- show: function() {
- this.sector.show();
- },
- hide: function() {
- this.sector.hide();
- },
- select: function() {
- this.sector.select();
- },
- unselect: function(_newTarget) {
- this.sector.unselect();
- if (!_newTarget || (_newTarget !== this.source_representation && _newTarget.source_representation !== this.source_representation)) {
- this.source_representation.unselect();
- }
- },
- destroy: function() {
- this.sector.destroy();
- }
- });
-
- return _BaseButton;
-
-});
-
-
-define('renderer/shapebuilder',[], function () {
-
-
- /* ShapeBuilder Begin */
-
- var builders = {
- "circle":{
- getShape: function() {
- return new paper.Path.Circle([0, 0], 1);
- },
- getImageShape: function(center, radius) {
- return new paper.Path.Circle(center, radius);
- }
- },
- "rectangle":{
- getShape: function() {
- return new paper.Path.Rectangle([-2, -2], [2, 2]);
- },
- getImageShape: function(center, radius) {
- return new paper.Path.Rectangle([-radius, -radius], [radius*2, radius*2]);
- }
- },
- "ellipse":{
- getShape: function() {
- return new paper.Path.Ellipse(new paper.Rectangle([-2, -1], [2, 1]));
- },
- getImageShape: function(center, radius) {
- return new paper.Path.Ellipse(new paper.Rectangle([-radius, -radius/2], [radius*2, radius]));
- }
- },
- "polygon":{
- getShape: function() {
- return new paper.Path.RegularPolygon([0, 0], 6, 1);
- },
- getImageShape: function(center, radius) {
- return new paper.Path.RegularPolygon([0, 0], 6, radius);
- }
- },
- "diamond":{
- getShape: function() {
- var d = new paper.Path.Rectangle([-2, -2], [2, 2]);
- d.rotate(45);
- return d;
- },
- getImageShape: function(center, radius) {
- var d = new paper.Path.Rectangle([-radius, -radius], [radius*2, radius*2]);
- d.rotate(45);
- return d;
- }
- },
- "star":{
- getShape: function() {
- return new paper.Path.Star([0, 0], 8, 1, 0.7);
- },
- getImageShape: function(center, radius) {
- return new paper.Path.Star([0, 0], 8, radius*1, radius*0.7);
- }
- },
- "svg": function(path){
- return {
- getShape: function() {
- return new paper.Path(path);
- },
- getImageShape: function(center, radius) {
- // No calcul for the moment
- return new paper.Path();
- }
- };
- }
- };
-
- var ShapeBuilder = function (shape){
- if(typeof shape==="undefined"){
- shape = "circle";
- }
- if(shape.substr(0,4)==="svg:"){
- return builders.svg(shape.substr(4));
- }
- if(!(shape in builders)){
- shape = "circle";
- }
- return builders[shape];
- };
-
- return ShapeBuilder;
-
-});
-
-define('renderer/noderepr',['jquery', 'underscore', 'requtils', 'renderer/baserepresentation', 'renderer/shapebuilder'], function ($, _, requtils, BaseRepresentation, ShapeBuilder) {
-
-
- var Utils = requtils.getUtils();
-
- /* Rkns.Renderer.Node Class */
-
- /* The representation for the node : A circle, with an image inside and a text label underneath.
- * The circle and the image are drawn on canvas and managed by Paper.js.
- * The text label is an HTML node, managed by jQuery. */
-
- //var NodeRepr = Renderer.Node = Utils.inherit(Renderer._BaseRepresentation);
- var NodeRepr = Utils.inherit(BaseRepresentation);
-
- _(NodeRepr.prototype).extend({
- _init: function() {
- this.renderer.node_layer.activate();
- this.type = "Node";
- this.buildShape();
- if (this.options.show_node_circles) {
- this.circle.strokeWidth = this.options.node_stroke_width;
- this.h_ratio = 1;
- } else {
- this.h_ratio = 0;
- }
- this.title = $('<div class="Rk-Label">').appendTo(this.renderer.labels_$);
-
- if (this.options.editor_mode) {
- var Renderer = requtils.getRenderer();
- this.normal_buttons = [
- new Renderer.NodeEditButton(this.renderer, null),
- new Renderer.NodeRemoveButton(this.renderer, null),
- new Renderer.NodeLinkButton(this.renderer, null),
- new Renderer.NodeEnlargeButton(this.renderer, null),
- new Renderer.NodeShrinkButton(this.renderer, null)
- ];
- this.pending_delete_buttons = [
- new Renderer.NodeRevertButton(this.renderer, null)
- ];
- this.all_buttons = this.normal_buttons.concat(this.pending_delete_buttons);
-
- for (var i = 0; i < this.all_buttons.length; i++) {
- this.all_buttons[i].source_representation = this;
- }
- this.active_buttons = [];
- } else {
- this.active_buttons = this.all_buttons = [];
- }
- this.last_circle_radius = 1;
-
- if (this.renderer.minimap) {
- this.renderer.minimap.node_layer.activate();
- this.minimap_circle = new paper.Path.Circle([0, 0], 1);
- this.minimap_circle.__representation = this.renderer.minimap.miniframe.__representation;
- this.renderer.minimap.node_group.addChild(this.minimap_circle);
- }
- },
- buildShape: function(){
- if(typeof this.model.get("shape_changed")!=="undefined" && this.model.get("shape_changed")===true){
- this.model.set("shape_changed", false);
- delete this.img;
- }
- if(this.circle){
- this.circle.remove();
- delete this.circle;
- }
- // "circle" "rectangle" "ellipse" "polygon" "star" "diamond"
- this.shapeBuilder = new ShapeBuilder(this.model.get("shape"));
- this.circle = this.shapeBuilder.getShape();
- this.circle.__representation = this;
- this.last_circle_radius = 1;
- },
- redraw: function(_dontRedrawEdges) {
- if(typeof this.model.get("shape_changed")!=="undefined" && this.model.get("shape_changed")===true){
- this.buildShape();
- }
- var _model_coords = new paper.Point(this.model.get("position")),
- _baseRadius = this.options.node_size_base * Math.exp((this.model.get("size") || 0) * Utils._NODE_SIZE_STEP);
- if (!this.is_dragging || !this.paper_coords) {
- this.paper_coords = this.renderer.toPaperCoords(_model_coords);
- }
- this.circle_radius = _baseRadius * this.renderer.scale;
- if (this.last_circle_radius !== this.circle_radius) {
- this.all_buttons.forEach(function(b) {
- b.setSectorSize();
- });
- this.circle.scale(this.circle_radius / this.last_circle_radius);
- if (this.node_image) {
- this.node_image.scale(this.circle_radius / this.last_circle_radius);
- }
- }
- this.circle.position = this.paper_coords;
- if (this.node_image) {
- this.node_image.position = this.paper_coords.subtract(this.image_delta.multiply(this.circle_radius));
- }
- this.last_circle_radius = this.circle_radius;
-
- var old_act_btn = this.active_buttons;
-
- var opacity = 1;
- if (this.model.get("delete_scheduled")) {
- opacity = 0.5;
- this.active_buttons = this.pending_delete_buttons;
- this.circle.dashArray = [2,2];
- } else {
- opacity = 1;
- this.active_buttons = this.normal_buttons;
- this.circle.dashArray = null;
- }
-
- if (this.selected && this.renderer.isEditable()) {
- if (old_act_btn !== this.active_buttons) {
- old_act_btn.forEach(function(b) {
- b.hide();
- });
- }
- this.active_buttons.forEach(function(b) {
- b.show();
- });
- }
-
- if (this.node_image) {
- this.node_image.opacity = this.highlighted ? opacity * 0.5 : (opacity - 0.01);
- }
-
- this.circle.fillColor = this.highlighted ? this.options.highlighted_node_fill_color : this.options.node_fill_color;
-
- this.circle.opacity = this.options.show_node_circles ? opacity : 0.01;
-
- var _text = this.model.get("title") || this.renkan.translate(this.options.label_untitled_nodes) || "";
- _text = Utils.shortenText(_text, this.options.node_label_max_length);
-
- if (typeof this.highlighted === "object") {
- this.title.html(this.highlighted.replace(_(_text).escape(),'<span class="Rk-Highlighted">$1</span>'));
- } else {
- this.title.text(_text);
- }
-
- this.title.css({
- left: this.paper_coords.x,
- top: this.paper_coords.y + this.circle_radius * this.h_ratio + this.options.node_label_distance,
- opacity: opacity
- });
- var _color = this.model.get("color") || (this.model.get("created_by") || Utils._USER_PLACEHOLDER(this.renkan)).get("color");
- this.circle.strokeColor = _color;
- var _pc = this.paper_coords;
- this.all_buttons.forEach(function(b) {
- b.moveTo(_pc);
- });
- var lastImage = this.img;
- this.img = this.model.get("image");
- if (this.img && this.img !== lastImage) {
- this.showImage();
- }
- if (this.node_image && !this.img) {
- this.node_image.remove();
- delete this.node_image;
- }
-
- if (this.renderer.minimap) {
- this.minimap_circle.fillColor = _color;
- var minipos = this.renderer.toMinimapCoords(_model_coords),
- miniradius = this.renderer.minimap.scale * _baseRadius,
- minisize = new paper.Size([miniradius, miniradius]);
- this.minimap_circle.fitBounds(minipos.subtract(minisize), minisize.multiply(2));
- }
-
- if (!_dontRedrawEdges) {
- var _this = this;
- _.each(
- this.project.get("edges").filter(
- function (ed) {
- return ((ed.get("to") === _this.model) || (ed.get("from") === _this.model));
- }
- ),
- function(edge, index, list) {
- var repr = _this.renderer.getRepresentationByModel(edge);
- if (repr && typeof repr.from_representation !== "undefined" && typeof repr.from_representation.paper_coords !== "undefined" && typeof repr.to_representation !== "undefined" && typeof repr.to_representation.paper_coords !== "undefined") {
- repr.redraw();
- }
- }
- );
- }
-
- },
- showImage: function() {
- var _image = null;
- if (typeof this.renderer.image_cache[this.img] === "undefined") {
- _image = new Image();
- this.renderer.image_cache[this.img] = _image;
- _image.src = this.img;
- } else {
- _image = this.renderer.image_cache[this.img];
- }
- if (_image.width) {
- if (this.node_image) {
- this.node_image.remove();
- }
- this.renderer.node_layer.activate();
- var width = _image.width,
- height = _image.height,
- clipPath = this.model.get("clip_path"),
- hasClipPath = (typeof clipPath !== "undefined" && clipPath),
- _clip = null,
- baseRadius = null,
- centerPoint = null;
-
- if (hasClipPath) {
- _clip = new paper.Path();
- var instructions = clipPath.match(/[a-z][^a-z]+/gi) || [],
- lastCoords = [0,0],
- minX = Infinity,
- minY = Infinity,
- maxX = -Infinity,
- maxY = -Infinity;
-
- var transformCoords = function(tabc, relative) {
- var newCoords = tabc.slice(1).map(function(v, k) {
- var res = parseFloat(v),
- isY = k % 2;
- if (isY) {
- res = ( res - 0.5 ) * height;
- } else {
- res = ( res - 0.5 ) * width;
- }
- if (relative) {
- res += lastCoords[isY];
- }
- if (isY) {
- minY = Math.min(minY, res);
- maxY = Math.max(maxY, res);
- } else {
- minX = Math.min(minX, res);
- maxX = Math.max(maxX, res);
- }
- return res;
- });
- lastCoords = newCoords.slice(-2);
- return newCoords;
- };
-
- instructions.forEach(function(instr) {
- var coords = instr.match(/([a-z]|[0-9.-]+)/ig) || [""];
- switch(coords[0]) {
- case "M":
- _clip.moveTo(transformCoords(coords));
- break;
- case "m":
- _clip.moveTo(transformCoords(coords, true));
- break;
- case "L":
- _clip.lineTo(transformCoords(coords));
- break;
- case "l":
- _clip.lineTo(transformCoords(coords, true));
- break;
- case "C":
- _clip.cubicCurveTo(transformCoords(coords));
- break;
- case "c":
- _clip.cubicCurveTo(transformCoords(coords, true));
- break;
- case "Q":
- _clip.quadraticCurveTo(transformCoords(coords));
- break;
- case "q":
- _clip.quadraticCurveTo(transformCoords(coords, true));
- break;
- }
- });
-
- baseRadius = Math[this.options.node_images_fill_mode ? "min" : "max"](maxX - minX, maxY - minY) / 2;
- centerPoint = new paper.Point((maxX + minX) / 2, (maxY + minY) / 2);
- if (!this.options.show_node_circles) {
- this.h_ratio = (maxY - minY) / (2 * baseRadius);
- }
- } else {
- baseRadius = Math[this.options.node_images_fill_mode ? "min" : "max"](width, height) / 2;
- centerPoint = new paper.Point(0,0);
- if (!this.options.show_node_circles) {
- this.h_ratio = height / (2 * baseRadius);
- }
- }
- var _raster = new paper.Raster(_image);
- _raster.locked = true; // Disable mouse events on icon
- if (hasClipPath) {
- _raster = new paper.Group(_clip, _raster);
- _raster.opacity = 0.99;
- /* This is a workaround to allow clipping at group level
- * If opacity was set to 1, paper.js would merge all clipping groups in one (known bug).
- */
- _raster.clipped = true;
- _clip.__representation = this;
- }
- if (this.options.clip_node_images) {
- var _circleClip = this.shapeBuilder.getImageShape(centerPoint, baseRadius);
- _raster = new paper.Group(_circleClip, _raster);
- _raster.opacity = 0.99;
- _raster.clipped = true;
- _circleClip.__representation = this;
- }
- this.image_delta = centerPoint.divide(baseRadius);
- this.node_image = _raster;
- this.node_image.__representation = _this;
- this.node_image.scale(this.circle_radius / baseRadius);
- this.node_image.position = this.paper_coords.subtract(this.image_delta.multiply(this.circle_radius));
- this.redraw();
- this.renderer.throttledPaperDraw();
- } else {
- var _this = this;
- $(_image).on("load", function() {
- _this.showImage();
- });
- }
- },
- paperShift: function(_delta) {
- if (this.options.editor_mode) {
- if (!this.renkan.read_only) {
- this.is_dragging = true;
- this.paper_coords = this.paper_coords.add(_delta);
- this.redraw();
- }
- } else {
- this.renderer.paperShift(_delta);
- }
- },
- openEditor: function() {
- this.renderer.removeRepresentationsOfType("editor");
- var _editor = this.renderer.addRepresentation("NodeEditor",null);
- _editor.source_representation = this;
- _editor.draw();
- },
- select: function() {
- this.selected = true;
- this.circle.strokeWidth = this.options.selected_node_stroke_width;
- if (this.renderer.isEditable()) {
- this.active_buttons.forEach(function(b) {
- b.show();
- });
- }
- var _uri = this.model.get("uri");
- if (_uri) {
- $('.Rk-Bin-Item').each(function() {
- var _el = $(this);
- if (_el.attr("data-uri") === _uri) {
- _el.addClass("selected");
- }
- });
- }
- if (!this.options.editor_mode) {
- this.openEditor();
- }
-
- if (this.renderer.minimap) {
- this.minimap_circle.strokeWidth = this.options.minimap_highlight_weight;
- this.minimap_circle.strokeColor = this.options.minimap_highlight_color;
- }
- this._super("select");
- },
- unselect: function(_newTarget) {
- if (!_newTarget || _newTarget.source_representation !== this) {
- this.selected = false;
- this.all_buttons.forEach(function(b) {
- b.hide();
- });
- this.circle.strokeWidth = this.options.node_stroke_width;
- $('.Rk-Bin-Item').removeClass("selected");
- if (this.renderer.minimap) {
- this.minimap_circle.strokeColor = undefined;
- }
- this._super("unselect");
- }
- },
- highlight: function(textToReplace) {
- var hlvalue = textToReplace || true;
- if (this.highlighted === hlvalue) {
- return;
- }
- this.highlighted = hlvalue;
- this.redraw();
- this.renderer.throttledPaperDraw();
- },
- unhighlight: function() {
- if (!this.highlighted) {
- return;
- }
- this.highlighted = false;
- this.redraw();
- this.renderer.throttledPaperDraw();
- },
- saveCoords: function() {
- var _coords = this.renderer.toModelCoords(this.paper_coords),
- _data = {
- position: {
- x: _coords.x,
- y: _coords.y
- }
- };
- if (this.renderer.isEditable()) {
- this.model.set(_data);
- }
- },
- mousedown: function(_event, _isTouch) {
- if (_isTouch) {
- this.renderer.unselectAll();
- this.select();
- }
- },
- mouseup: function(_event, _isTouch) {
- if (this.renderer.is_dragging && this.renderer.isEditable()) {
- this.saveCoords();
- } else {
- if (!_isTouch && !this.model.get("delete_scheduled")) {
- this.openEditor();
- }
- this.model.trigger("clicked");
- }
- this.renderer.click_target = null;
- this.renderer.is_dragging = false;
- this.is_dragging = false;
- },
- destroy: function(_event) {
- this._super("destroy");
- this.all_buttons.forEach(function(b) {
- b.destroy();
- });
- this.circle.remove();
- this.title.remove();
- if (this.renderer.minimap) {
- this.minimap_circle.remove();
- }
- if (this.node_image) {
- this.node_image.remove();
- }
- }
- });
-
- return NodeRepr;
-
-});
-
-
-define('renderer/edge',['jquery', 'underscore', 'requtils', 'renderer/baserepresentation'], function ($, _, requtils, BaseRepresentation) {
-
-
- var Utils = requtils.getUtils();
-
- /* Edge Class Begin */
-
- //var Edge = Renderer.Edge = Utils.inherit(Renderer._BaseRepresentation);
- var Edge = Utils.inherit(BaseRepresentation);
-
- _(Edge.prototype).extend({
- _init: function() {
- this.renderer.edge_layer.activate();
- this.type = "Edge";
- this.from_representation = this.renderer.getRepresentationByModel(this.model.get("from"));
- this.to_representation = this.renderer.getRepresentationByModel(this.model.get("to"));
- this.bundle = this.renderer.addToBundles(this);
- this.line = new paper.Path();
- this.line.add([0,0],[0,0],[0,0]);
- this.line.__representation = this;
- this.line.strokeWidth = this.options.edge_stroke_width;
- this.arrow = new paper.Path();
- this.arrow.add(
- [ 0, 0 ],
- [ this.options.edge_arrow_length, this.options.edge_arrow_width / 2 ],
- [ 0, this.options.edge_arrow_width ]
- );
- this.arrow.__representation = this;
- this.text = $('<div class="Rk-Label Rk-Edge-Label">').appendTo(this.renderer.labels_$);
- this.arrow_angle = 0;
- if (this.options.editor_mode) {
- var Renderer = requtils.getRenderer();
- this.normal_buttons = [
- new Renderer.EdgeEditButton(this.renderer, null),
- new Renderer.EdgeRemoveButton(this.renderer, null)
- ];
- this.pending_delete_buttons = [
- new Renderer.EdgeRevertButton(this.renderer, null)
- ];
- this.all_buttons = this.normal_buttons.concat(this.pending_delete_buttons);
- for (var i = 0; i < this.all_buttons.length; i++) {
- this.all_buttons[i].source_representation = this;
- }
- this.active_buttons = [];
- } else {
- this.active_buttons = this.all_buttons = [];
- }
-
- if (this.renderer.minimap) {
- this.renderer.minimap.edge_layer.activate();
- this.minimap_line = new paper.Path();
- this.minimap_line.add([0,0],[0,0]);
- this.minimap_line.__representation = this.renderer.minimap.miniframe.__representation;
- this.minimap_line.strokeWidth = 1;
- }
- },
- redraw: function() {
- var from = this.model.get("from"),
- to = this.model.get("to");
- if (!from || !to) {
- return;
- }
- this.from_representation = this.renderer.getRepresentationByModel(from);
- this.to_representation = this.renderer.getRepresentationByModel(to);
- if (typeof this.from_representation === "undefined" || typeof this.to_representation === "undefined") {
- return;
- }
- var _p0a = this.from_representation.paper_coords,
- _p1a = this.to_representation.paper_coords,
- _v = _p1a.subtract(_p0a),
- _r = _v.length,
- _u = _v.divide(_r),
- _ortho = new paper.Point([- _u.y, _u.x]),
- _group_pos = this.bundle.getPosition(this),
- _delta = _ortho.multiply( this.options.edge_gap_in_bundles * _group_pos ),
- _p0b = _p0a.add(_delta), /* Adding a 4 px difference */
- _p1b = _p1a.add(_delta), /* to differentiate bundled links */
- _a = _v.angle,
- _textdelta = _ortho.multiply(this.options.edge_label_distance),
- _handle = _v.divide(3),
- _color = this.model.get("color") || this.model.get("color") || (this.model.get("created_by") || Utils._USER_PLACEHOLDER(this.renkan)).get("color"),
- opacity = 1;
-
- if (this.model.get("delete_scheduled") || this.from_representation.model.get("delete_scheduled") || this.to_representation.model.get("delete_scheduled")) {
- opacity = 0.5;
- this.line.dashArray = [2, 2];
- } else {
- opacity = 1;
- this.line.dashArray = null;
- }
-
- var old_act_btn = this.active_buttons;
-
- this.active_buttons = this.model.get("delete_scheduled") ? this.pending_delete_buttons : this.normal_buttons;
-
- if (this.selected && this.renderer.isEditable() && old_act_btn !== this.active_buttons) {
- old_act_btn.forEach(function(b) {
- b.hide();
- });
- this.active_buttons.forEach(function(b) {
- b.show();
- });
- }
-
- this.paper_coords = _p0b.add(_p1b).divide(2);
- this.line.strokeColor = _color;
- this.line.opacity = opacity;
- this.line.segments[0].point = _p0a;
- this.line.segments[1].point = this.paper_coords;
- this.line.segments[1].handleIn = _handle.multiply(-1);
- this.line.segments[1].handleOut = _handle;
- this.line.segments[2].point = _p1a;
- this.arrow.rotate(_a - this.arrow_angle);
- this.arrow.fillColor = _color;
- this.arrow.opacity = opacity;
- this.arrow.position = this.paper_coords;
- this.arrow_angle = _a;
- if (_a > 90) {
- _a -= 180;
- _textdelta = _textdelta.multiply(-1);
- }
- if (_a < -90) {
- _a += 180;
- _textdelta = _textdelta.multiply(-1);
- }
- var _text = this.model.get("title") || this.renkan.translate(this.options.label_untitled_edges) || "";
- _text = Utils.shortenText(_text, this.options.node_label_max_length);
- this.text.text(_text);
- var _textpos = this.paper_coords.add(_textdelta);
- this.text.css({
- left: _textpos.x,
- top: _textpos.y,
- transform: "rotate(" + _a + "deg)",
- "-moz-transform": "rotate(" + _a + "deg)",
- "-webkit-transform": "rotate(" + _a + "deg)",
- opacity: opacity
- });
- this.text_angle = _a;
-
- var _pc = this.paper_coords;
- this.all_buttons.forEach(function(b) {
- b.moveTo(_pc);
- });
-
- if (this.renderer.minimap) {
- this.minimap_line.strokeColor = _color;
- this.minimap_line.segments[0].point = this.renderer.toMinimapCoords(new paper.Point(this.from_representation.model.get("position")));
- this.minimap_line.segments[1].point = this.renderer.toMinimapCoords(new paper.Point(this.to_representation.model.get("position")));
- }
- },
- openEditor: function() {
- this.renderer.removeRepresentationsOfType("editor");
- var _editor = this.renderer.addRepresentation("EdgeEditor",null);
- _editor.source_representation = this;
- _editor.draw();
- },
- select: function() {
- this.selected = true;
- this.line.strokeWidth = this.options.selected_edge_stroke_width;
- if (this.renderer.isEditable()) {
- this.active_buttons.forEach(function(b) {
- b.show();
- });
- }
- if (!this.options.editor_mode) {
- this.openEditor();
- }
- this._super("select");
- },
- unselect: function(_newTarget) {
- if (!_newTarget || _newTarget.source_representation !== this) {
- this.selected = false;
- if (this.options.editor_mode) {
- this.all_buttons.forEach(function(b) {
- b.hide();
- });
- }
- this.line.strokeWidth = this.options.edge_stroke_width;
- this._super("unselect");
- }
- },
- mousedown: function(_event, _isTouch) {
- if (_isTouch) {
- this.renderer.unselectAll();
- this.select();
- }
- },
- mouseup: function(_event, _isTouch) {
- if (!this.renkan.read_only && this.renderer.is_dragging) {
- this.from_representation.saveCoords();
- this.to_representation.saveCoords();
- this.from_representation.is_dragging = false;
- this.to_representation.is_dragging = false;
- } else {
- if (!_isTouch) {
- this.openEditor();
- }
- this.model.trigger("clicked");
- }
- this.renderer.click_target = null;
- this.renderer.is_dragging = false;
- },
- paperShift: function(_delta) {
- if (this.options.editor_mode) {
- if (!this.options.read_only) {
- this.from_representation.paperShift(_delta);
- this.to_representation.paperShift(_delta);
- }
- } else {
- this.renderer.paperShift(_delta);
- }
- },
- destroy: function() {
- this._super("destroy");
- this.line.remove();
- this.arrow.remove();
- this.text.remove();
- if (this.renderer.minimap) {
- this.minimap_line.remove();
- }
- this.all_buttons.forEach(function(b) {
- b.destroy();
- });
- var _this = this;
- this.bundle.edges = _(this.bundle.edges).reject(function(_edge) {
- return _this === _edge;
- });
- }
- });
-
- return Edge;
-
-});
-
-
-
-define('renderer/tempedge',['jquery', 'underscore', 'requtils', 'renderer/baserepresentation'], function ($, _, requtils, BaseRepresentation) {
-
-
- var Utils = requtils.getUtils();
-
- /* TempEdge Class Begin */
-
- //var TempEdge = Renderer.TempEdge = Utils.inherit(Renderer._BaseRepresentation);
- var TempEdge = Utils.inherit(BaseRepresentation);
-
- _(TempEdge.prototype).extend({
- _init: function() {
- this.renderer.edge_layer.activate();
- this.type = "Temp-edge";
-
- var _color = (this.project.get("users").get(this.renkan.current_user) || Utils._USER_PLACEHOLDER(this.renkan)).get("color");
- this.line = new paper.Path();
- this.line.strokeColor = _color;
- this.line.dashArray = [4, 2];
- this.line.strokeWidth = this.options.selected_edge_stroke_width;
- this.line.add([0,0],[0,0]);
- this.line.__representation = this;
- this.arrow = new paper.Path();
- this.arrow.fillColor = _color;
- this.arrow.add(
- [ 0, 0 ],
- [ this.options.edge_arrow_length, this.options.edge_arrow_width / 2 ],
- [ 0, this.options.edge_arrow_width ]
- );
- this.arrow.__representation = this;
- this.arrow_angle = 0;
- },
- redraw: function() {
- var _p0 = this.from_representation.paper_coords,
- _p1 = this.end_pos,
- _a = _p1.subtract(_p0).angle,
- _c = _p0.add(_p1).divide(2);
- this.line.segments[0].point = _p0;
- this.line.segments[1].point = _p1;
- this.arrow.rotate(_a - this.arrow_angle);
- this.arrow.position = _c;
- this.arrow_angle = _a;
- },
- paperShift: function(_delta) {
- if (!this.renderer.isEditable()) {
- this.renderer.removeRepresentation(_this);
- paper.view.draw();
- return;
- }
- this.end_pos = this.end_pos.add(_delta);
- var _hitResult = paper.project.hitTest(this.end_pos);
- this.renderer.findTarget(_hitResult);
- this.redraw();
- },
- mouseup: function(_event, _isTouch) {
- var _hitResult = paper.project.hitTest(_event.point),
- _model = this.from_representation.model,
- _endDrag = true;
- if (_hitResult && typeof _hitResult.item.__representation !== "undefined") {
- var _target = _hitResult.item.__representation;
- if (_target.type.substr(0,4) === "Node") {
- var _destmodel = _target.model || _target.source_representation.model;
- if (_model !== _destmodel) {
- var _data = {
- id: Utils.getUID('edge'),
- created_by: this.renkan.current_user,
- from: _model,
- to: _destmodel
- };
- if (this.renderer.isEditable()) {
- this.project.addEdge(_data);
- }
- }
- }
-
- if (_model === _target.model || (_target.source_representation && _target.source_representation.model === _model)) {
- _endDrag = false;
- this.renderer.is_dragging = true;
- }
- }
- if (_endDrag) {
- this.renderer.click_target = null;
- this.renderer.is_dragging = false;
- this.renderer.removeRepresentation(this);
- paper.view.draw();
- }
- },
- destroy: function() {
- this.arrow.remove();
- this.line.remove();
- }
- });
-
- /* TempEdge Class End */
-
- return TempEdge;
-
-});
-
-
-define('renderer/baseeditor',['jquery', 'underscore', 'requtils', 'renderer/baserepresentation'], function ($, _, requtils, BaseRepresentation) {
-
-
- var Utils = requtils.getUtils();
-
- /* _BaseEditor Begin */
- //var _BaseEditor = Renderer._BaseEditor = Utils.inherit(Renderer._BaseRepresentation);
- var _BaseEditor = Utils.inherit(BaseRepresentation);
-
- _(_BaseEditor.prototype).extend({
- _init: function() {
- this.renderer.buttons_layer.activate();
- this.type = "editor";
- this.editor_block = new paper.Path();
- var _pts = _(_.range(8)).map(function() {return [0,0];});
- this.editor_block.add.apply(this.editor_block, _pts);
- this.editor_block.strokeWidth = this.options.tooltip_border_width;
- this.editor_block.strokeColor = this.options.tooltip_border_color;
- this.editor_block.opacity = 0.8;
- this.editor_$ = $('<div>')
- .appendTo(this.renderer.editor_$)
- .css({
- position: "absolute",
- opacity: 0.8
- })
- .hide();
- },
- destroy: function() {
- this.editor_block.remove();
- this.editor_$.remove();
- }
- });
-
- /* _BaseEditor End */
-
- return _BaseEditor;
-
-});
-
-
-define('renderer/nodeeditor',['jquery', 'underscore', 'requtils', 'renderer/baseeditor'], function ($, _, requtils, BaseEditor) {
-
-
- var Utils = requtils.getUtils();
-
- /* NodeEditor Begin */
- //var NodeEditor = Renderer.NodeEditor = Utils.inherit(Renderer._BaseEditor);
- var NodeEditor = Utils.inherit(BaseEditor);
-
- _(NodeEditor.prototype).extend({
- template: _.template(
- '<h2><span class="Rk-CloseX">×</span><%-renkan.translate("Edit Node")%></span></h2>' +
- '<p><label><%-renkan.translate("Title:")%></label><input class="Rk-Edit-Title" type="text" value="<%-node.title%>"/></p>' +
- '<% if (options.show_node_editor_uri) { %><p><label><%-renkan.translate("URI:")%></label><input class="Rk-Edit-URI" type="text" value="<%-node.uri%>"/><a class="Rk-Edit-Goto" href="<%-node.uri%>" target="_blank"></a></p><% } %>' +
- '<% if (options.show_node_editor_description) { %><p><label><%-renkan.translate("Description:")%></label><textarea class="Rk-Edit-Description"><%-node.description%></textarea></p><% } %>' +
- '<% if (options.show_node_editor_size) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Size:")%></span><a href="#" class="Rk-Edit-Size-Down">-</a><span class="Rk-Edit-Size-Value"><%-node.size%></span><a href="#" class="Rk-Edit-Size-Up">+</a></p><% } %>' +
- '<% if (options.show_node_editor_color) { %><div class="Rk-Editor-p"><span class="Rk-Editor-Label"><%-renkan.translate("Node color:")%></span><div class="Rk-Edit-ColorPicker-Wrapper"><span class="Rk-Edit-Color" style="background:<%-node.color%>;"><span class="Rk-Edit-ColorTip"></span></span>' +
- '<%= renkan.colorPicker %><span class="Rk-Edit-ColorPicker-Text"><%- renkan.translate("Choose color") %></span></div></div><% } %>' +
- '<% if (options.show_node_editor_image) { %><div class="Rk-Edit-ImgWrap"><div class="Rk-Edit-ImgPreview"><img src="<%-node.image || node.image_placeholder%>" />' +
- '<% if (node.clip_path) { %><svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewbox="0 0 1 1" preserveAspectRatio="none"><path style="stroke-width: .02; stroke:red; fill-opacity:.3; fill:red;" d="<%- node.clip_path %>"/></svg><% }%>' +
- '</div></div><p><label><%-renkan.translate("Image URL:")%></label><input class="Rk-Edit-Image" type="text" value="<%-node.image%>"/></p>' +
- '<p><label><%-renkan.translate("Choose Image File:")%></label><input class="Rk-Edit-Image-File" type="file" accept="image/*"/></p><% } %>' +
- '<% if (options.show_node_editor_creator && node.has_creator) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Created by:")%></span> <span class="Rk-UserColor" style="background:<%-node.created_by_color%>;"></span><%- shortenText(node.created_by_title, 25) %></p><% } %>' +
- '<% if (options.change_shapes) { %><p><label><%-renkan.translate("Shapes available")%>:</label> <select class="Rk-Edit-Shape">' +
- '<option class="Rk-Edit-Vocabulary-Property" value="circle"<% if (node.shape === "circle") { %> selected<% } %>><%- renkan.translate("Circle") %></option>' +
- '<option class="Rk-Edit-Vocabulary-Property" value="rectangle"<% if (node.shape === "rectangle") { %> selected<% } %>><%- renkan.translate("Square") %></option>' +
- '<option class="Rk-Edit-Vocabulary-Property" value="diamond"<% if (node.shape === "diamond") { %> selected<% } %>><%- renkan.translate("Diamond") %></option>' +
- '<option class="Rk-Edit-Vocabulary-Property" value="polygon"<% if (node.shape === "polygon") { %> selected<% } %>><%- renkan.translate("Hexagone") %></option>' +
- '<option class="Rk-Edit-Vocabulary-Property" value="ellipse"<% if (node.shape === "ellipse") { %> selected<% } %>><%- renkan.translate("Ellipse") %></option>' +
- '<option class="Rk-Edit-Vocabulary-Property" value="star"<% if (node.shape === "star") { %> selected<% } %>><%- renkan.translate("Star") %></option>' +
- '</select></p><% } %>'
- ),
- readOnlyTemplate: _.template(
- '<h2><span class="Rk-CloseX">×</span><% if (options.show_node_tooltip_color) { %><span class="Rk-UserColor" style="background:<%-node.color%>;"></span><% } %>' +
- '<span class="Rk-Display-Title"><% if (node.uri) { %><a href="<%-node.uri%>" target="_blank"><% } %><%-node.title%><% if (node.uri) { %></a><% } %></span></h2>' +
- '<% if (node.uri && options.show_node_tooltip_uri) { %><p class="Rk-Display-URI"><a href="<%-node.uri%>" target="_blank"><%-node.short_uri%></a></p><% } %>' +
- '<% if (options.show_node_tooltip_description) { %><p class="Rk-Display-Description"><%-node.description%></p><% } %>' +
- '<% if (node.image && options.show_node_tooltip_image) { %><img class="Rk-Display-ImgPreview" src="<%-node.image%>" /><% } %>' +
- '<% if (node.has_creator && options.show_node_tooltip_creator) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Created by:")%></span><span class="Rk-UserColor" style="background:<%-node.created_by_color%>;"></span><%- shortenText(node.created_by_title, 25) %></p><% } %>'
- ),
- draw: function() {
- var _model = this.source_representation.model,
- _created_by = _model.get("created_by") || Utils._USER_PLACEHOLDER(this.renkan),
- _template = (this.renderer.isEditable() ? this.template : this.readOnlyTemplate ),
- _image_placeholder = this.options.static_url + "img/image-placeholder.png",
- _size = (_model.get("size") || 0);
- this.editor_$
- .html(_template({
- node: {
- has_creator: !!_model.get("created_by"),
- title: _model.get("title"),
- uri: _model.get("uri"),
- short_uri: Utils.shortenText((_model.get("uri") || "").replace(/^(https?:\/\/)?(www\.)?/,'').replace(/\/$/,''),40),
- description: _model.get("description"),
- image: _model.get("image") || "",
- image_placeholder: _image_placeholder,
- color: _model.get("color") || _created_by.get("color"),
- clip_path: _model.get("clip_path") || false,
- created_by_color: _created_by.get("color"),
- created_by_title: _created_by.get("title"),
- size: (_size > 0 ? "+" : "") + _size,
- shape: _model.get("shape") || "circle"
- },
- renkan: this.renkan,
- options: this.options,
- shortenText: Utils.shortenText
- }));
- this.redraw();
- var _this = this,
- closeEditor = function() {
- _this.renderer.removeRepresentation(_this);
- paper.view.draw();
- };
-
- this.editor_$.find(".Rk-CloseX").click(closeEditor);
-
- this.editor_$.find(".Rk-Edit-Goto").click(function() {
- if (!_model.get("uri")) {
- return false;
- }
- });
-
- if (this.renderer.isEditable()) {
-
- var onFieldChange = _(function() {
- _(function() {
- if (_this.renderer.isEditable()) {
- var _data = {
- title: _this.editor_$.find(".Rk-Edit-Title").val()
- };
- if (_this.options.show_node_editor_uri) {
- _data.uri = _this.editor_$.find(".Rk-Edit-URI").val();
- _this.editor_$.find(".Rk-Edit-Goto").attr("href",_data.uri || "#");
- }
- if (_this.options.show_node_editor_image) {
- _data.image = _this.editor_$.find(".Rk-Edit-Image").val();
- _this.editor_$.find(".Rk-Edit-ImgPreview").attr("src", _data.image || _image_placeholder);
- }
- if (_this.options.show_node_editor_description) {
- _data.description = _this.editor_$.find(".Rk-Edit-Description").val();
- }
- if (_this.options.change_shapes) {
- if(_model.get("shape")!==_this.editor_$.find(".Rk-Edit-Shape").val()){
- _data.shape = _this.editor_$.find(".Rk-Edit-Shape").val();
- _data.shape_changed = true;
- }
- }
- _model.set(_data);
- _this.redraw();
- // For an unknown reason, we have to set data twice when we change shape, otherwise the image disappears.
- if(_data.shape_changed===true){
- _model.set(_data);
- }
- } else {
- closeEditor();
- }
- }).defer();
- }).throttle(500);
-
- this.editor_$.on("keyup", function(_e) {
- if (_e.keyCode === 27) {
- closeEditor();
- }
- });
-
- this.editor_$.find("input, textarea, select").on("change keyup paste", onFieldChange);
-
- this.editor_$.find(".Rk-Edit-Image-File").change(function() {
- if (this.files.length) {
- var f = this.files[0],
- fr = new FileReader();
- if (f.type.substr(0,5) !== "image") {
- alert(_this.renkan.translate("This file is not an image"));
- return;
- }
- if (f.size > (_this.options.uploaded_image_max_kb * 1024)) {
- alert(_this.renkan.translate("Image size must be under ") + _this.options.uploaded_image_max_kb + _this.renkan.translate("KB"));
- return;
- }
- fr.onload = function(e) {
- _this.editor_$.find(".Rk-Edit-Image").val(e.target.result);
- onFieldChange();
- };
- fr.readAsDataURL(f);
- }
- });
- this.editor_$.find(".Rk-Edit-Title")[0].focus();
-
- var _picker = _this.editor_$.find(".Rk-Edit-ColorPicker");
-
- this.editor_$.find(".Rk-Edit-ColorPicker-Wrapper").hover(
- function(_e) {
- _e.preventDefault();
- _picker.show();
- },
- function(_e) {
- _e.preventDefault();
- _picker.hide();
- }
- );
-
- _picker.find("li").hover(
- function(_e) {
- _e.preventDefault();
- _this.editor_$.find(".Rk-Edit-Color").css("background", $(this).attr("data-color"));
- },
- function(_e) {
- _e.preventDefault();
- _this.editor_$.find(".Rk-Edit-Color").css("background", _model.get("color") || (_model.get("created_by") || Utils._USER_PLACEHOLDER(_this.renkan)).get("color"));
- }
- ).click(function(_e) {
- _e.preventDefault();
- if (_this.renderer.isEditable()) {
- _model.set("color", $(this).attr("data-color"));
- _picker.hide();
- paper.view.draw();
- } else {
- closeEditor();
- }
- });
-
- var shiftSize = function(n) {
- if (_this.renderer.isEditable()) {
- var _newsize = n+(_model.get("size") || 0);
- _this.editor_$.find(".Rk-Edit-Size-Value").text((_newsize > 0 ? "+" : "") + _newsize);
- _model.set("size", _newsize);
- paper.view.draw();
- } else {
- closeEditor();
- }
- };
-
- this.editor_$.find(".Rk-Edit-Size-Down").click(function() {
- shiftSize(-1);
- return false;
- });
- this.editor_$.find(".Rk-Edit-Size-Up").click(function() {
- shiftSize(1);
- return false;
- });
- } else {
- if (typeof this.source_representation.highlighted === "object") {
- var titlehtml = this.source_representation.highlighted.replace(_(_model.get("title")).escape(),'<span class="Rk-Highlighted">$1</span>');
- this.editor_$.find(".Rk-Display-Title" + (_model.get("uri") ? " a" : "")).html(titlehtml);
- if (this.options.show_node_tooltip_description) {
- this.editor_$.find(".Rk-Display-Description").html(this.source_representation.highlighted.replace(_(_model.get("description")).escape(),'<span class="Rk-Highlighted">$1</span>'));
- }
- }
- }
- this.editor_$.find("img").load(function() {
- _this.redraw();
- });
- },
- redraw: function() {
- var _coords = this.source_representation.paper_coords;
- Utils.drawEditBox(this.options, _coords, this.editor_block, this.source_representation.circle_radius * 0.75, this.editor_$);
- this.editor_$.show();
- paper.view.draw();
- }
- });
-
- /* NodeEditor End */
-
- return NodeEditor;
-
-});
-
-
-define('renderer/edgeeditor',['jquery', 'underscore', 'requtils', 'renderer/baseeditor'], function ($, _, requtils, BaseEditor) {
-
-
- var Utils = requtils.getUtils();
-
- /* EdgeEditor Begin */
-
- //var EdgeEditor = Renderer.EdgeEditor = Utils.inherit(Renderer._BaseEditor);
- var EdgeEditor = Utils.inherit(BaseEditor);
-
- _(EdgeEditor.prototype).extend({
- template: _.template(
- '<h2><span class="Rk-CloseX">×</span><%-renkan.translate("Edit Edge")%></span></h2>' +
- '<p><label><%-renkan.translate("Title:")%></label><input class="Rk-Edit-Title" type="text" value="<%-edge.title%>"/></p>' +
- '<% if (options.show_edge_editor_uri) { %><p><label><%-renkan.translate("URI:")%></label><input class="Rk-Edit-URI" type="text" value="<%-edge.uri%>"/><a class="Rk-Edit-Goto" href="<%-edge.uri%>" target="_blank"></a></p>' +
- '<% if (options.properties.length) { %><p><label><%-renkan.translate("Choose from vocabulary:")%></label><select class="Rk-Edit-Vocabulary">' +
- '<% _(options.properties).each(function(ontology) { %><option class="Rk-Edit-Vocabulary-Class" value=""><%- renkan.translate(ontology.label) %></option>' +
- '<% _(ontology.properties).each(function(property) { var uri = ontology["base-uri"] + property.uri; %><option class="Rk-Edit-Vocabulary-Property" value="<%- uri %>' +
- '"<% if (uri === edge.uri) { %> selected<% } %>><%- renkan.translate(property.label) %></option>' +
- '<% }) %><% }) %></select></p><% } } %>' +
- '<% if (options.show_edge_editor_color) { %><div class="Rk-Editor-p"><span class="Rk-Editor-Label"><%-renkan.translate("Edge color:")%></span><div class="Rk-Edit-ColorPicker-Wrapper"><span class="Rk-Edit-Color" style="background:<%-edge.color%>;"><span class="Rk-Edit-ColorTip"></span></span>' +
- '<%= renkan.colorPicker %><span class="Rk-Edit-ColorPicker-Text"><%- renkan.translate("Choose color") %></span></div></div><% } %>' +
- '<% if (options.show_edge_editor_direction) { %><p><span class="Rk-Edit-Direction"><%- renkan.translate("Change edge direction") %></span></p><% } %>' +
- '<% if (options.show_edge_editor_nodes) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("From:")%></span><span class="Rk-UserColor" style="background:<%-edge.from_color%>;"></span><%- shortenText(edge.from_title, 25) %></p>' +
- '<p><span class="Rk-Editor-Label"><%-renkan.translate("To:")%></span><span class="Rk-UserColor" style="background:<%-edge.to_color%>;"></span><%- shortenText(edge.to_title, 25) %></p><% } %>' +
- '<% if (options.show_edge_editor_creator && edge.has_creator) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Created by:")%></span><span class="Rk-UserColor" style="background:<%-edge.created_by_color%>;"></span><%- shortenText(edge.created_by_title, 25) %></p><% } %>'
- ),
- readOnlyTemplate: _.template(
- '<h2><span class="Rk-CloseX">×</span><% if (options.show_edge_tooltip_color) { %><span class="Rk-UserColor" style="background:<%-edge.color%>;"></span><% } %>' +
- '<span class="Rk-Display-Title"><% if (edge.uri) { %><a href="<%-edge.uri%>" target="_blank"><% } %><%-edge.title%><% if (edge.uri) { %></a><% } %></span></h2>' +
- '<% if (options.show_edge_tooltip_uri && edge.uri) { %><p class="Rk-Display-URI"><a href="<%-edge.uri%>" target="_blank"><%-edge.short_uri%></a></p><% } %>' +
- '<p><%-edge.description%></p>' +
- '<% if (options.show_edge_tooltip_nodes) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("From:")%></span><span class="Rk-UserColor" style="background:<%-edge.from_color%>;"></span><%- shortenText(edge.from_title, 25) %></p>' +
- '<p><span class="Rk-Editor-Label"><%-renkan.translate("To:")%></span><span class="Rk-UserColor" style="background:<%-edge.to_color%>;"></span><%- shortenText(edge.to_title, 25) %></p><% } %>' +
- '<% if (options.show_edge_tooltip_creator && edge.has_creator) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Created by:")%></span><span class="Rk-UserColor" style="background:<%-edge.created_by_color%>;"></span><%- shortenText(edge.created_by_title, 25) %></p><% } %>'
- ),
- draw: function() {
- var _model = this.source_representation.model,
- _from_model = _model.get("from"),
- _to_model = _model.get("to"),
- _created_by = _model.get("created_by") || Utils._USER_PLACEHOLDER(this.renkan),
- _template = (this.renderer.isEditable() ? this.template : this.readOnlyTemplate);
- this.editor_$
- .html(_template({
- edge: {
- has_creator: !!_model.get("created_by"),
- title: _model.get("title"),
- uri: _model.get("uri"),
- short_uri: Utils.shortenText((_model.get("uri") || "").replace(/^(https?:\/\/)?(www\.)?/,'').replace(/\/$/,''),40),
- description: _model.get("description"),
- color: _model.get("color") || _created_by.get("color"),
- from_title: _from_model.get("title"),
- to_title: _to_model.get("title"),
- from_color: _from_model.get("color") || (_from_model.get("created_by") || Utils._USER_PLACEHOLDER(this.renkan)).get("color"),
- to_color: _to_model.get("color") || (_to_model.get("created_by") || Utils._USER_PLACEHOLDER(this.renkan)).get("color"),
- created_by_color: _created_by.get("color"),
- created_by_title: _created_by.get("title")
- },
- renkan: this.renkan,
- shortenText: Utils.shortenText,
- options: this.options
- }));
- this.redraw();
- var _this = this,
- closeEditor = function() {
- _this.renderer.removeRepresentation(_this);
- paper.view.draw();
- };
- this.editor_$.find(".Rk-CloseX").click(closeEditor);
- this.editor_$.find(".Rk-Edit-Goto").click(function() {
- if (!_model.get("uri")) {
- return false;
- }
- });
-
- if (this.renderer.isEditable()) {
-
- var onFieldChange = _(function() {
- _(function() {
- if (_this.renderer.isEditable()) {
- var _data = {
- title: _this.editor_$.find(".Rk-Edit-Title").val()
- };
- if (_this.options.show_edge_editor_uri) {
- _data.uri = _this.editor_$.find(".Rk-Edit-URI").val();
- }
- _this.editor_$.find(".Rk-Edit-Goto").attr("href",_data.uri || "#");
- _model.set(_data);
- paper.view.draw();
- } else {
- closeEditor();
- }
- }).defer();
- }).throttle(500);
-
- this.editor_$.on("keyup", function(_e) {
- if (_e.keyCode === 27) {
- closeEditor();
- }
- });
-
- this.editor_$.find("input").on("keyup change paste", onFieldChange);
-
- this.editor_$.find(".Rk-Edit-Vocabulary").change(function() {
- var e = $(this),
- v = e.val();
- if (v) {
- _this.editor_$.find(".Rk-Edit-Title").val(e.find(":selected").text());
- _this.editor_$.find(".Rk-Edit-URI").val(v);
- onFieldChange();
- }
- });
- this.editor_$.find(".Rk-Edit-Direction").click(function() {
- if (_this.renderer.isEditable()) {
- _model.set({
- from: _model.get("to"),
- to: _model.get("from")
- });
- _this.draw();
- } else {
- closeEditor();
- }
- });
-
- var _picker = _this.editor_$.find(".Rk-Edit-ColorPicker");
-
- this.editor_$.find(".Rk-Edit-ColorPicker-Wrapper").hover(
- function(_e) {
- _e.preventDefault();
- _picker.show();
- },
- function(_e) {
- _e.preventDefault();
- _picker.hide();
- }
- );
-
- _picker.find("li").hover(
- function(_e) {
- _e.preventDefault();
- _this.editor_$.find(".Rk-Edit-Color").css("background", $(this).attr("data-color"));
- },
- function(_e) {
- _e.preventDefault();
- _this.editor_$.find(".Rk-Edit-Color").css("background", _model.get("color") || (_model.get("created_by") || Utils._USER_PLACEHOLDER(_this.renkan)).get("color"));
- }
- ).click(function(_e) {
- _e.preventDefault();
- if (_this.renderer.isEditable()) {
- _model.set("color", $(this).attr("data-color"));
- _picker.hide();
- paper.view.draw();
- } else {
- closeEditor();
- }
- });
- }
- },
- redraw: function() {
- var _coords = this.source_representation.paper_coords;
- Utils.drawEditBox(this.options, _coords, this.editor_block, 5, this.editor_$);
- this.editor_$.show();
- paper.view.draw();
- }
- });
-
- /* EdgeEditor End */
-
- return EdgeEditor;
-
-});
-
-
-define('renderer/nodebutton',['jquery', 'underscore', 'requtils', 'renderer/basebutton'], function ($, _, requtils, BaseButton) {
-
-
- var Utils = requtils.getUtils();
-
- /* _NodeButton Begin */
-
- //var _NodeButton = Renderer._NodeButton = Utils.inherit(Renderer._BaseButton);
- var _NodeButton = Utils.inherit(BaseButton);
-
- _(_NodeButton.prototype).extend({
- setSectorSize: function() {
- var sectorInner = this.source_representation.circle_radius;
- if (sectorInner !== this.lastSectorInner) {
- if (this.sector) {
- this.sector.destroy();
- }
- this.sector = this.renderer.drawSector(
- this, 1 + sectorInner,
- Utils._NODE_BUTTON_WIDTH + sectorInner,
- this.startAngle,
- this.endAngle,
- 1,
- this.imageName,
- this.renkan.translate(this.text)
- );
- this.lastSectorInner = sectorInner;
- }
- }
- });
-
- /* _NodeButton End */
-
- return _NodeButton;
-
-});
-
-
-define('renderer/nodeeditbutton',['jquery', 'underscore', 'requtils', 'renderer/nodebutton'], function ($, _, requtils, NodeButton) {
-
-
- var Utils = requtils.getUtils();
-
- /* NodeEditButton Begin */
-
- //var NodeEditButton = Renderer.NodeEditButton = Utils.inherit(Renderer._NodeButton);
- var NodeEditButton = Utils.inherit(NodeButton);
-
- _(NodeEditButton.prototype).extend({
- _init: function() {
- this.type = "Node-edit-button";
- this.lastSectorInner = 0;
- this.startAngle = -135;
- this.endAngle = -45;
- this.imageName = "edit";
- this.text = "Edit";
- },
- mouseup: function() {
- if (!this.renderer.is_dragging) {
- this.source_representation.openEditor();
- }
- }
- });
-
- /* NodeEditButton End */
-
- return NodeEditButton;
-
-});
-
-
-define('renderer/noderemovebutton',['jquery', 'underscore', 'requtils', 'renderer/nodebutton'], function ($, _, requtils, NodeButton) {
-
-
- var Utils = requtils.getUtils();
-
- /* NodeRemoveButton Begin */
-
- //var NodeRemoveButton = Renderer.NodeRemoveButton = Utils.inherit(Renderer._NodeButton);
- var NodeRemoveButton = Utils.inherit(NodeButton);
-
- _(NodeRemoveButton.prototype).extend({
- _init: function() {
- this.type = "Node-remove-button";
- this.lastSectorInner = 0;
- this.startAngle = 0;
- this.endAngle = 90;
- this.imageName = "remove";
- this.text = "Remove";
- },
- mouseup: function() {
- this.renderer.click_target = null;
- this.renderer.is_dragging = false;
- this.renderer.removeRepresentationsOfType("editor");
- if (this.renderer.isEditable()) {
- if (this.options.element_delete_delay) {
- var delid = Utils.getUID("delete");
- this.renderer.delete_list.push({
- id: delid,
- time: new Date().valueOf() + this.options.element_delete_delay
- });
- this.source_representation.model.set("delete_scheduled", delid);
- } else {
- if (confirm(this.renkan.translate('Do you really wish to remove node ') + '"' + this.source_representation.model.get("title") + '"?')) {
- this.project.removeNode(this.source_representation.model);
- }
- }
- }
- }
- });
-
- /* NodeRemoveButton End */
-
- return NodeRemoveButton;
-
-});
-
-
-define('renderer/noderevertbutton',['jquery', 'underscore', 'requtils', 'renderer/nodebutton'], function ($, _, requtils, NodeButton) {
-
-
- var Utils = requtils.getUtils();
-
- /* NodeRevertButton Begin */
-
- //var NodeRevertButton = Renderer.NodeRevertButton = Utils.inherit(Renderer._NodeButton);
- var NodeRevertButton = Utils.inherit(NodeButton);
-
- _(NodeRevertButton.prototype).extend({
- _init: function() {
- this.type = "Node-revert-button";
- this.lastSectorInner = 0;
- this.startAngle = -135;
- this.endAngle = 135;
- this.imageName = "revert";
- this.text = "Cancel deletion";
- },
- mouseup: function() {
- this.renderer.click_target = null;
- this.renderer.is_dragging = false;
- if (this.renderer.isEditable()) {
- this.source_representation.model.unset("delete_scheduled");
- }
- }
- });
-
- /* NodeRevertButton End */
-
- return NodeRevertButton;
-
-});
-
-
-define('renderer/nodelinkbutton',['jquery', 'underscore', 'requtils', 'renderer/nodebutton'], function ($, _, requtils, NodeButton) {
-
-
- var Utils = requtils.getUtils();
-
- /* NodeLinkButton Begin */
-
- //var NodeLinkButton = Renderer.NodeLinkButton = Utils.inherit(Renderer._NodeButton);
- var NodeLinkButton = Utils.inherit(NodeButton);
-
- _(NodeLinkButton.prototype).extend({
- _init: function() {
- this.type = "Node-link-button";
- this.lastSectorInner = 0;
- this.startAngle = 90;
- this.endAngle = 180;
- this.imageName = "link";
- this.text = "Link to another node";
- },
- mousedown: function(_event, _isTouch) {
- if (this.renderer.isEditable()) {
- var _off = this.renderer.canvas_$.offset(),
- _point = new paper.Point([
- _event.pageX - _off.left,
- _event.pageY - _off.top
- ]);
- this.renderer.click_target = null;
- this.renderer.removeRepresentationsOfType("editor");
- this.renderer.addTempEdge(this.source_representation, _point);
- }
- }
- });
-
- /* NodeLinkButton End */
-
- return NodeLinkButton;
-
-});
-
-
-
-define('renderer/nodeenlargebutton',['jquery', 'underscore', 'requtils', 'renderer/nodebutton'], function ($, _, requtils, NodeButton) {
-
-
- var Utils = requtils.getUtils();
-
- /* NodeEnlargeButton Begin */
-
- //var NodeEnlargeButton = Renderer.NodeEnlargeButton = Utils.inherit(Renderer._NodeButton);
- var NodeEnlargeButton = Utils.inherit(NodeButton);
-
- _(NodeEnlargeButton.prototype).extend({
- _init: function() {
- this.type = "Node-enlarge-button";
- this.lastSectorInner = 0;
- this.startAngle = -45;
- this.endAngle = 0;
- this.imageName = "enlarge";
- this.text = "Enlarge";
- },
- mouseup: function() {
- var _newsize = 1 + (this.source_representation.model.get("size") || 0);
- this.source_representation.model.set("size", _newsize);
- this.source_representation.select();
- this.select();
- paper.view.draw();
- }
- });
-
- /* NodeEnlargeButton End */
-
- return NodeEnlargeButton;
-
-});
-
-
-define('renderer/nodeshrinkbutton',['jquery', 'underscore', 'requtils', 'renderer/nodebutton'], function ($, _, requtils, NodeButton) {
-
-
- var Utils = requtils.getUtils();
-
- /* NodeShrinkButton Begin */
-
- //var NodeShrinkButton = Renderer.NodeShrinkButton = Utils.inherit(Renderer._NodeButton);
- var NodeShrinkButton = Utils.inherit(NodeButton);
-
- _(NodeShrinkButton.prototype).extend({
- _init: function() {
- this.type = "Node-shrink-button";
- this.lastSectorInner = 0;
- this.startAngle = -180;
- this.endAngle = -135;
- this.imageName = "shrink";
- this.text = "Shrink";
- },
- mouseup: function() {
- var _newsize = -1 + (this.source_representation.model.get("size") || 0);
- this.source_representation.model.set("size", _newsize);
- this.source_representation.select();
- this.select();
- paper.view.draw();
- }
- });
-
- /* NodeShrinkButton End */
-
- return NodeShrinkButton;
-
-});
-
-
-define('renderer/edgeeditbutton',['jquery', 'underscore', 'requtils', 'renderer/basebutton'], function ($, _, requtils, BaseButton) {
-
-
- var Utils = requtils.getUtils();
-
- /* EdgeEditButton Begin */
-
- //var EdgeEditButton = Renderer.EdgeEditButton = Utils.inherit(Renderer._BaseButton);
- var EdgeEditButton = Utils.inherit(BaseButton);
-
- _(EdgeEditButton.prototype).extend({
- _init: function() {
- this.type = "Edge-edit-button";
- this.sector = this.renderer.drawSector(this, Utils._EDGE_BUTTON_INNER, Utils._EDGE_BUTTON_OUTER, -270, -90, 1, "edit", this.renkan.translate("Edit"));
- },
- mouseup: function() {
- if (!this.renderer.is_dragging) {
- this.source_representation.openEditor();
- }
- }
- });
-
- /* EdgeEditButton End */
-
- return EdgeEditButton;
-
-});
-
-
-define('renderer/edgeremovebutton',['jquery', 'underscore', 'requtils', 'renderer/basebutton'], function ($, _, requtils, BaseButton) {
-
-
- var Utils = requtils.getUtils();
-
- /* EdgeRemoveButton Begin */
-
- //var EdgeRemoveButton = Renderer.EdgeRemoveButton = Utils.inherit(Renderer._BaseButton);
- var EdgeRemoveButton = Utils.inherit(BaseButton);
-
- _(EdgeRemoveButton.prototype).extend({
- _init: function() {
- this.type = "Edge-remove-button";
- this.sector = this.renderer.drawSector(this, Utils._EDGE_BUTTON_INNER, Utils._EDGE_BUTTON_OUTER, -90, 90, 1, "remove", this.renkan.translate("Remove"));
- },
- mouseup: function() {
- this.renderer.click_target = null;
- this.renderer.is_dragging = false;
- this.renderer.removeRepresentationsOfType("editor");
- if (this.renderer.isEditable()) {
- if (this.options.element_delete_delay) {
- var delid = Utils.getUID("delete");
- this.renderer.delete_list.push({
- id: delid,
- time: new Date().valueOf() + this.options.element_delete_delay
- });
- this.source_representation.model.set("delete_scheduled", delid);
- } else {
- if (confirm(this.renkan.translate('Do you really wish to remove edge ') + '"' + this.source_representation.model.get("title") + '"?')) {
- this.project.removeEdge(this.source_representation.model);
- }
- }
- }
- }
- });
-
- /* EdgeRemoveButton End */
-
- return EdgeRemoveButton;
-
-});
-
-
-define('renderer/edgerevertbutton',['jquery', 'underscore', 'requtils', 'renderer/basebutton'], function ($, _, requtils, BaseButton) {
-
-
- var Utils = requtils.getUtils();
-
- /* EdgeRevertButton Begin */
-
- //var EdgeRevertButton = Renderer.EdgeRevertButton = Utils.inherit(Renderer._BaseButton);
- var EdgeRevertButton = Utils.inherit(BaseButton);
-
- _(EdgeRevertButton.prototype).extend({
- _init: function() {
- this.type = "Edge-revert-button";
- this.sector = this.renderer.drawSector(this, Utils._EDGE_BUTTON_INNER, Utils._EDGE_BUTTON_OUTER, -135, 135, 1, "revert", this.renkan.translate("Cancel deletion"));
- },
- mouseup: function() {
- this.renderer.click_target = null;
- this.renderer.is_dragging = false;
- if (this.renderer.isEditable()) {
- this.source_representation.model.unset("delete_scheduled");
- }
- }
- });
-
- /* EdgeRevertButton End */
-
- return EdgeRevertButton;
-
-});
-
-
-define('renderer/miniframe',['jquery', 'underscore', 'requtils', 'renderer/baserepresentation'], function ($, _, requtils, BaseRepresentation) {
-
-
- var Utils = requtils.getUtils();
-
- /* MiniFrame Begin */
-
- //var MiniFrame = Renderer.MiniFrame = Utils.inherit(Renderer._BaseRepresentation);
- var MiniFrame = Utils.inherit(BaseRepresentation);
-
- _(MiniFrame.prototype).extend({
- paperShift: function(_delta) {
- this.renderer.offset = this.renderer.offset.subtract(_delta.divide(this.renderer.minimap.scale).multiply(this.renderer.scale));
- this.renderer.redraw();
- },
- mouseup: function(_delta) {
- this.renderer.click_target = null;
- this.renderer.is_dragging = false;
- }
- });
-
- /* MiniFrame End */
-
- return MiniFrame;
-
-});
-
-
-define('renderer/scene',['jquery', 'underscore', 'filesaver', 'requtils', 'renderer/miniframe'], function ($, _, filesaver, requtils, MiniFrame) {
-
-
- var Utils = requtils.getUtils();
-
- /* Scene Begin */
-
- var Scene = function(_renkan) {
- this.renkan = _renkan;
- this.$ = $(".Rk-Render");
- this.representations = [];
- this.$.html(this.template(_renkan));
- this.onStatusChange();
- this.canvas_$ = this.$.find(".Rk-Canvas");
- this.labels_$ = this.$.find(".Rk-Labels");
- this.editor_$ = this.$.find(".Rk-Editor");
- this.notif_$ = this.$.find(".Rk-Notifications");
- paper.setup(this.canvas_$[0]);
- this.scale = 1;
- this.initialScale = 1;
- this.offset = paper.view.center;
- this.totalScroll = 0;
- this.mouse_down = false;
- this.click_target = null;
- this.selected_target = null;
- this.edge_layer = new paper.Layer();
- this.node_layer = new paper.Layer();
- this.buttons_layer = new paper.Layer();
- this.delete_list = [];
- this.redrawActive = true;
-
- if (_renkan.options.show_minimap) {
- this.minimap = {
- background_layer: new paper.Layer(),
- edge_layer: new paper.Layer(),
- node_layer: new paper.Layer(),
- node_group: new paper.Group(),
- size: new paper.Size( _renkan.options.minimap_width, _renkan.options.minimap_height )
- };
-
- this.minimap.background_layer.activate();
- this.minimap.topleft = paper.view.bounds.bottomRight.subtract(this.minimap.size);
- this.minimap.rectangle = new paper.Path.Rectangle(this.minimap.topleft.subtract([2,2]), this.minimap.size.add([4,4]));
- this.minimap.rectangle.fillColor = _renkan.options.minimap_background_color;
- this.minimap.rectangle.strokeColor = _renkan.options.minimap_border_color;
- this.minimap.rectangle.strokeWidth = 4;
- this.minimap.offset = new paper.Point(this.minimap.size.divide(2));
- this.minimap.scale = 0.1;
-
- this.minimap.node_layer.activate();
- this.minimap.cliprectangle = new paper.Path.Rectangle(this.minimap.topleft, this.minimap.size);
- this.minimap.node_group.addChild(this.minimap.cliprectangle);
- this.minimap.node_group.clipped = true;
- this.minimap.miniframe = new paper.Path.Rectangle(this.minimap.topleft, this.minimap.size);
- this.minimap.node_group.addChild(this.minimap.miniframe);
- this.minimap.miniframe.fillColor = '#c0c0ff';
- this.minimap.miniframe.opacity = 0.3;
- this.minimap.miniframe.strokeColor = '#000080';
- this.minimap.miniframe.strokeWidth = 3;
- this.minimap.miniframe.__representation = new MiniFrame(this, null);
- }
-
- this.throttledPaperDraw = _(function() {
- paper.view.draw();
- }).throttle(100);
-
- this.bundles = [];
- this.click_mode = false;
-
- var _this = this,
- _allowScroll = true,
- _originalScale = 1,
- _zooming = false,
- _lastTapX = 0,
- _lastTapY = 0;
-
- this.image_cache = {};
- this.icon_cache = {};
-
- ['edit', 'remove', 'link', 'enlarge', 'shrink', 'revert' ].forEach(function(imgname) {
- var img = new Image();
- img.src = _renkan.options.static_url + 'img/' + imgname + '.png';
- _this.icon_cache[imgname] = img;
- });
-
- var throttledMouseMove = _.throttle(function(_event, _isTouch) {
- _this.onMouseMove(_event, _isTouch);
- }, Utils._MOUSEMOVE_RATE);
-
- this.canvas_$.on({
- mousedown: function(_event) {
- _event.preventDefault();
- _this.onMouseDown(_event, false);
- },
- mousemove: function(_event) {
- _event.preventDefault();
- throttledMouseMove(_event, false);
- },
- mouseup: function(_event) {
- _event.preventDefault();
- _this.onMouseUp(_event, false);
- },
- mousewheel: function(_event, _delta) {
- if(_renkan.options.zoom_on_scroll) {
- _event.preventDefault();
- if (_allowScroll) {
- _this.onScroll(_event, _delta);
- }
- }
- },
- touchstart: function(_event) {
- _event.preventDefault();
- var _touches = _event.originalEvent.touches[0];
- if (
- _renkan.options.allow_double_click &&
- new Date() - _lastTap < Utils._DOUBLETAP_DELAY &&
- ( Math.pow(_lastTapX - _touches.pageX, 2) + Math.pow(_lastTapY - _touches.pageY, 2) < Utils._DOUBLETAP_DISTANCE )
- ) {
- _lastTap = 0;
- _this.onDoubleClick(_touches);
- } else {
- _lastTap = new Date();
- _lastTapX = _touches.pageX;
- _lastTapY = _touches.pageY;
- _originalScale = _this.scale;
- _zooming = false;
- _this.onMouseDown(_touches, true);
- }
- },
- touchmove: function(_event) {
- _event.preventDefault();
- _lastTap = 0;
- if (_event.originalEvent.touches.length === 1) {
- _this.onMouseMove(_event.originalEvent.touches[0], true);
- } else {
- if (!_zooming) {
- _this.onMouseUp(_event.originalEvent.touches[0], true);
- _this.click_target = null;
- _this.is_dragging = false;
- _zooming = true;
- }
- if (_event.originalEvent.scale === "undefined") {
- return;
- }
- var _newScale = _event.originalEvent.scale * _originalScale,
- _scaleRatio = _newScale / _this.scale,
- _newOffset = new paper.Point([
- _this.canvas_$.width(),
- _this.canvas_$.height()
- ]).multiply( 0.5 * ( 1 - _scaleRatio ) ).add(_this.offset.multiply( _scaleRatio ));
- _this.setScale(_newScale, _newOffset);
- }
- },
- touchend: function(_event) {
- _event.preventDefault();
- _this.onMouseUp(_event.originalEvent.changedTouches[0], true);
- },
- dblclick: function(_event) {
- _event.preventDefault();
- if (_renkan.options.allow_double_click) {
- _this.onDoubleClick(_event);
- }
- },
- mouseleave: function(_event) {
- _event.preventDefault();
- _this.onMouseUp(_event, false);
- _this.click_target = null;
- _this.is_dragging = false;
- },
- dragover: function(_event) {
- _event.preventDefault();
- },
- dragenter: function(_event) {
- _event.preventDefault();
- _allowScroll = false;
- },
- dragleave: function(_event) {
- _event.preventDefault();
- _allowScroll = true;
- },
- drop: function(_event) {
- _event.preventDefault();
- _allowScroll = true;
- var res = {};
- _(_event.originalEvent.dataTransfer.types).each(function(t) {
- try {
- res[t] = _event.originalEvent.dataTransfer.getData(t);
- } catch(e) {}
- });
- var text = _event.originalEvent.dataTransfer.getData("Text");
- if (typeof text === "string") {
- switch(text[0]) {
- case "{":
- case "[":
- try {
- var data = JSON.parse(text);
- _(res).extend(data);
- }
- catch(e) {
- if (!res["text/plain"]) {
- res["text/plain"] = text;
- }
- }
- break;
- case "<":
- if (!res["text/html"]) {
- res["text/html"] = text;
- }
- break;
- default:
- if (!res["text/plain"]) {
- res["text/plain"] = text;
- }
- }
- }
- var url = _event.originalEvent.dataTransfer.getData("URL");
- if (url && !res["text/uri-list"]) {
- res["text/uri-list"] = url;
- }
- _this.dropData(res, _event.originalEvent);
- }
- });
-
- var bindClick = function(selector, fname) {
- _this.$.find(selector).click(function(evt) {
- _this[fname](evt);
- return false;
- });
- };
-
- bindClick(".Rk-ZoomOut", "zoomOut");
- bindClick(".Rk-ZoomIn", "zoomIn");
- bindClick(".Rk-ZoomFit", "autoScale");
- this.$.find(".Rk-ZoomSave").click( function() {
- // Save scale and offset point
- _this.renkan.project.addView( { zoom_level:_this.scale, offset:_this.offset } );
- });
- this.$.find(".Rk-ZoomSetSaved").click( function() {
- var view = _this.renkan.project.get("views").last();
- if(view){
- _this.setScale(view.get("zoom_level"), new paper.Point(view.get("offset")));
- }
- });
- if(this.renkan.read_only && !isNaN(parseInt(this.renkan.options.default_view))){
- this.$.find(".Rk-ZoomSetSaved").show();
- }
- this.$.find(".Rk-CurrentUser").mouseenter(
- function() { _this.$.find(".Rk-UserList").slideDown(); }
- );
- this.$.find(".Rk-Users").mouseleave(
- function() { _this.$.find(".Rk-UserList").slideUp(); }
- );
- bindClick(".Rk-FullScreen-Button", "fullScreen");
- bindClick(".Rk-AddNode-Button", "addNodeBtn");
- bindClick(".Rk-AddEdge-Button", "addEdgeBtn");
- bindClick(".Rk-Save-Button", "save");
- bindClick(".Rk-Open-Button", "open");
- bindClick(".Rk-Export-Button", "exportProject");
- this.$.find(".Rk-Bookmarklet-Button")
- /*jshint scripturl:true */
- .attr("href","javascript:" + Utils._BOOKMARKLET_CODE(_renkan))
- .click(function(){
- _this.notif_$
- .text(_renkan.translate("Drag this button to your bookmark bar. When on a third-party website, click it to enable drag-and-drop from the website to Renkan."))
- .fadeIn()
- .delay(5000)
- .fadeOut();
- return false;
- });
- this.$.find(".Rk-TopBar-Button").mouseover(function() {
- $(this).find(".Rk-TopBar-Tooltip").show();
- }).mouseout(function() {
- $(this).find(".Rk-TopBar-Tooltip").hide();
- });
- bindClick(".Rk-Fold-Bins", "foldBins");
-
- paper.view.onResize = function(_event) {
- // Because of paper bug which does not calculate the good height (and width a fortiori)
- // We have to update manually the canvas's height
- paper.view._viewSize.height = _event.size.height = _this.canvas_$.parent().height();
-
- if (_this.minimap) {
- _this.minimap.topleft = paper.view.bounds.bottomRight.subtract(_this.minimap.size);
- _this.minimap.rectangle.fitBounds(_this.minimap.topleft.subtract([2,2]), _this.minimap.size.add([4,4]));
- _this.minimap.cliprectangle.fitBounds(_this.minimap.topleft, _this.minimap.size);
- }
- _this.redraw();
- };
-
- var _thRedraw = _.throttle(function() {
- _this.redraw();
- },50);
-
- this.addRepresentations("Node", this.renkan.project.get("nodes"));
- this.addRepresentations("Edge", this.renkan.project.get("edges"));
- this.renkan.project.on("change:title", function() {
- _this.$.find(".Rk-PadTitle").val(_renkan.project.get("title"));
- });
-
- this.$.find(".Rk-PadTitle").on("keyup input paste", function() {
- _renkan.project.set({"title": $(this).val()});
- });
-
- var _thRedrawUsers = _.throttle(function() {
- _this.redrawUsers();
- }, 100);
-
- _thRedrawUsers();
-
- // register model events
- this.renkan.project.on("add:users remove:users", _thRedrawUsers);
-
- this.renkan.project.on("add:views remove:views", function(_node) {
- if(_this.renkan.project.get('views').length > 0) {
- _this.$.find(".Rk-ZoomSetSaved").show();
- }
- else {
- _this.$.find(".Rk-ZoomSetSaved").hide();
- }
- });
-
- this.renkan.project.on("add:nodes", function(_node) {
- _this.addRepresentation("Node", _node);
- _thRedraw();
- });
- this.renkan.project.on("add:edges", function(_edge) {
- _this.addRepresentation("Edge", _edge);
- _thRedraw();
- });
- this.renkan.project.on("change:title", function(_model, _title) {
- var el = _this.$.find(".Rk-PadTitle");
- if (el.is("input")) {
- if (el.val() !== _title) {
- el.val(_title);
- }
- } else {
- el.text(_title);
- }
- });
-
- if (_renkan.options.size_bug_fix) {
- var _delay = (
- typeof _renkan.options.size_bug_fix === "number" ?
- _renkan.options.size_bug_fix
- : 500
- );
- window.setTimeout(
- function() {
- _this.fixSize(true);
- },
- _delay
- );
- }
-
- if (_renkan.options.force_resize) {
- $(window).resize(function() {
- _this.fixSize(false);
- });
- }
-
- if (_renkan.options.show_user_list && _renkan.options.user_color_editable) {
- var $cpwrapper = this.$.find(".Rk-Users .Rk-Edit-ColorPicker-Wrapper"),
- $cplist = this.$.find(".Rk-Users .Rk-Edit-ColorPicker");
-
- $cpwrapper.hover(
- function(_e) {
- if (_this.isEditable()) {
- _e.preventDefault();
- $cplist.show();
- }
- },
- function(_e) {
- _e.preventDefault();
- $cplist.hide();
- }
- );
-
- $cplist.find("li").mouseenter(
- function(_e) {
- if (_this.isEditable()) {
- _e.preventDefault();
- _this.$.find(".Rk-CurrentUser-Color").css("background", $(this).attr("data-color"));
- }
- }
- );
- }
-
- if (_renkan.options.show_search_field) {
-
- var lastval = '';
-
- this.$.find(".Rk-GraphSearch-Field").on("keyup change paste input", function() {
- var $this = $(this),
- val = $this.val();
- if (val === lastval) {
- return;
- }
- lastval = val;
- if (val.length < 2) {
- _renkan.project.get("nodes").each(function(n) {
- _this.getRepresentationByModel(n).unhighlight();
- });
- } else {
- var rxs = Utils.regexpFromTextOrArray(val);
- _renkan.project.get("nodes").each(function(n) {
- if (rxs.test(n.get("title")) || rxs.test(n.get("description"))) {
- _this.getRepresentationByModel(n).highlight(rxs);
- } else {
- _this.getRepresentationByModel(n).unhighlight();
- }
- });
- }
- });
- }
-
- this.redraw();
-
- window.setInterval(function() {
- var _now = new Date().valueOf();
- _this.delete_list.forEach(function(d) {
- if (_now >= d.time) {
- var el = _renkan.project.get("nodes").findWhere({"delete_scheduled":d.id});
- if (el) {
- project.removeNode(el);
- }
- el = _renkan.project.get("edges").findWhere({"delete_scheduled":d.id});
- if (el) {
- project.removeEdge(el);
- }
- }
- });
- _this.delete_list = _this.delete_list.filter(function(d) {
- return _renkan.project.get("nodes").findWhere({"delete_scheduled":d.id}) || _renkan.project.get("edges").findWhere({"delete_scheduled":d.id});
- });
- }, 500);
-
- if (this.minimap) {
- window.setInterval(function() {
- _this.rescaleMinimap();
- }, 2000);
- }
-
- };
-
- _(Scene.prototype).extend({
- template: _.template(
- '<% if (options.show_top_bar) { %><div class="Rk-TopBar"><% if (!options.editor_mode) { %><h2 class="Rk-PadTitle"><%- project.get("title") || translate("Untitled project")%></h2>' +
- '<% } else { %><input type="text" class="Rk-PadTitle" value="<%- project.get("title") || "" %>" placeholder="<%-translate("Untitled project")%>" /><% } %>' +
- '<% if (options.show_user_list) { %><div class="Rk-Users"><div class="Rk-CurrentUser"><div class="Rk-Edit-ColorPicker-Wrapper"><span class="Rk-CurrentUser-Color"><% if (options.user_color_editable) { %><span class="Rk-Edit-ColorTip"></span><% } %></span>' +
- '<% if (options.user_color_editable) { print(colorPicker) } %></div><span class="Rk-CurrentUser-Name"><unknown user></span></div><ul class="Rk-UserList"></ul></div><% } %>' +
- '<% if (options.home_button_url) {%><div class="Rk-TopBar-Separator"></div><a class="Rk-TopBar-Button Rk-Home-Button" href="<%- options.home_button_url %>"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents">' +
- '<%- translate(options.home_button_title) %></div></div></a><% } %>' +
- '<% if (options.show_fullscreen_button) { %><div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-FullScreen-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents"><%-translate("Full Screen")%></div></div></div><% } %>' +
- '<% if (options.editor_mode) { %>' +
- '<% if (options.show_addnode_button) { %><div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-AddNode-Button"><div class="Rk-TopBar-Tooltip">' +
- '<div class="Rk-TopBar-Tooltip-Contents"><%-translate("Add Node")%></div></div></div><% } %>' +
- '<% if (options.show_addedge_button) { %><div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-AddEdge-Button"><div class="Rk-TopBar-Tooltip">' +
- '<div class="Rk-TopBar-Tooltip-Contents"><%-translate("Add Edge")%></div></div></div><% } %>' +
- '<% if (options.show_export_button) { %><div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-Export-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents"><%-translate("Download Project")%></div></div></div><% } %>' +
- '<% if (options.show_save_button) { %><div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-Save-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents"> </div></div></div><% } %>' +
- '<% if (options.show_open_button) { %><div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-Open-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents"><%-translate("Open Project")%></div></div></div><% } %>' +
- '<% if (options.show_bookmarklet) { %><div class="Rk-TopBar-Separator"></div><a class="Rk-TopBar-Button Rk-Bookmarklet-Button" href="#"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents">' +
- '<%-translate("Renkan \'Drag-to-Add\' bookmarklet")%></div></div></a><% } %>' +
- '<% } else { %>' +
- '<% if (options.show_export_button) { %><div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-Export-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents"><%-translate("Download Project")%></div></div></div><div class="Rk-TopBar-Separator"></div><% } %>' +
- '<% };' +
- 'if (options.show_search_field) { %>' +
- '<form action="#" class="Rk-GraphSearch-Form"><input type="search" class="Rk-GraphSearch-Field" placeholder="<%- translate("Search in graph") %>" /></form><div class="Rk-TopBar-Separator"></div><% } %></div><% } %>' +
- '<div class="Rk-Editing-Space<% if (!options.show_top_bar) { %> Rk-Editing-Space-Full<% } %>">' +
- '<div class="Rk-Labels"></div><canvas class="Rk-Canvas" resize></canvas><div class="Rk-Notifications"></div><div class="Rk-Editor">' +
- '<% if (options.show_bins) { %><div class="Rk-Fold-Bins">«</div><% } %>' +
- '<div class="Rk-ZoomButtons"><div class="Rk-ZoomIn" title="<%-translate("Zoom In")%>"></div><div class="Rk-ZoomFit" title="<%-translate("Zoom Fit")%>"></div><div class="Rk-ZoomOut" title="<%-translate("Zoom Out")%>"></div>' +
- '<% if (options.editor_mode) { %><div class="Rk-ZoomSave" title="<%-translate("Zoom Save")%>"></div><% } %>' +
- '<% if (options.editor_mode || !isNaN(parseInt(options.default_view))) { %><div class="Rk-ZoomSetSaved" title="<%-translate("View saved zoom")%>"></div><% } %></div>' +
- '</div></div>'
- ),
- fixSize: function(_autoscale) {
- var w = this.$.width(),
- h = this.$.height();
- if (this.renkan.options.show_top_bar) {
- h -= this.$.find(".Rk-TopBar").height();
- }
- this.canvas_$.attr({
- width: w,
- height: h
- });
-
- paper.view.viewSize = new paper.Size([w, h]);
-
- if (_autoscale) {
- // If _autoscale, we get the initial view (zoom+offset) set in the project datas.
- if(this.renkan.read_only && !isNaN(parseInt(this.renkan.options.default_view))){
- this.autoScale(this.renkan.project.get("views")[parseInt(this.renkan.options.default_view)]);
- }
- else{
- this.autoScale();
- }
- }
- },
- drawSector: function(_repr, _inR, _outR, _startAngle, _endAngle, _padding, _imgname, _caption) {
- var _options = this.renkan.options,
- _startRads = _startAngle * Math.PI / 180,
- _endRads = _endAngle * Math.PI / 180,
- _img = this.icon_cache[_imgname],
- _startdx = - Math.sin(_startRads),
- _startdy = Math.cos(_startRads),
- _startXIn = Math.cos(_startRads) * _inR + _padding * _startdx,
- _startYIn = Math.sin(_startRads) * _inR + _padding * _startdy,
- _startXOut = Math.cos(_startRads) * _outR + _padding * _startdx,
- _startYOut = Math.sin(_startRads) * _outR + _padding * _startdy,
- _enddx = - Math.sin(_endRads),
- _enddy = Math.cos(_endRads),
- _endXIn = Math.cos(_endRads) * _inR - _padding * _enddx,
- _endYIn = Math.sin(_endRads) * _inR - _padding * _enddy,
- _endXOut = Math.cos(_endRads) * _outR - _padding * _enddx,
- _endYOut = Math.sin(_endRads) * _outR - _padding * _enddy,
- _centerR = (_inR + _outR) / 2,
- _centerRads = (_startRads + _endRads) / 2,
- _centerX = Math.cos(_centerRads) * _centerR,
- _centerY = Math.sin(_centerRads) * _centerR,
- _centerXIn = Math.cos(_centerRads) * _inR,
- _centerXOut = Math.cos(_centerRads) * _outR,
- _centerYIn = Math.sin(_centerRads) * _inR,
- _centerYOut = Math.sin(_centerRads) * _outR,
- _textX = Math.cos(_centerRads) * (_outR + 3),
- _textY = Math.sin(_centerRads) * (_outR + _options.buttons_label_font_size) + _options.buttons_label_font_size / 2;
- this.buttons_layer.activate();
- var _path = new paper.Path();
- _path.add([_startXIn, _startYIn]);
- _path.arcTo([_centerXIn, _centerYIn], [_endXIn, _endYIn]);
- _path.lineTo([_endXOut, _endYOut]);
- _path.arcTo([_centerXOut, _centerYOut], [_startXOut, _startYOut]);
- _path.fillColor = _options.buttons_background;
- _path.opacity = 0.5;
- _path.closed = true;
- _path.__representation = _repr;
- var _text = new paper.PointText(_textX,_textY);
- _text.characterStyle = {
- fontSize: _options.buttons_label_font_size,
- fillColor: _options.buttons_label_color
- };
- if (_textX > 2) {
- _text.paragraphStyle.justification = 'left';
- } else if (_textX < -2) {
- _text.paragraphStyle.justification = 'right';
- } else {
- _text.paragraphStyle.justification = 'center';
- }
- _text.visible = false;
- var _visible = false,
- _restPos = new paper.Point(-200, -200),
- _grp = new paper.Group([_path, _text]),
- _delta = _grp.position,
- _imgdelta = new paper.Point([_centerX, _centerY]),
- _currentPos = new paper.Point(0,0);
- _text.content = _caption;
- _grp.visible = false;
- _grp.position = _restPos;
- var _res = {
- show: function() {
- _visible = true;
- _grp.position = _currentPos.add(_delta);
- _grp.visible = true;
- },
- moveTo: function(_point) {
- _currentPos = _point;
- if (_visible) {
- _grp.position = _point.add(_delta);
- }
- },
- hide: function() {
- _visible = false;
- _grp.visible = false;
- _grp.position = _restPos;
- },
- select: function() {
- _path.opacity = 0.8;
- _text.visible = true;
- },
- unselect: function() {
- _path.opacity = 0.5;
- _text.visible = false;
- },
- destroy: function() {
- _grp.remove();
- }
- };
- var showImage = function() {
- var _raster = new paper.Raster(_img);
- _raster.position = _imgdelta.add(_grp.position).subtract(_delta);
- _raster.locked = true; // Disable mouse events on icon
- _grp.addChild(_raster);
- };
- if (_img.width) {
- showImage();
- } else {
- $(_img).on("load",showImage);
- }
-
- return _res;
- },
- addToBundles: function(_edgeRepr) {
- var _bundle = _(this.bundles).find(function(_bundle) {
- return (
- ( _bundle.from === _edgeRepr.from_representation && _bundle.to === _edgeRepr.to_representation ) ||
- ( _bundle.from === _edgeRepr.to_representation && _bundle.to === _edgeRepr.from_representation )
- );
- });
- if (typeof _bundle !== "undefined") {
- _bundle.edges.push(_edgeRepr);
- } else {
- _bundle = {
- from: _edgeRepr.from_representation,
- to: _edgeRepr.to_representation,
- edges: [ _edgeRepr ],
- getPosition: function(_er) {
- var _dir = (_er.from_representation === this.from) ? 1 : -1;
- return _dir * ( _(this.edges).indexOf(_er) - (this.edges.length - 1) / 2 );
- }
- };
- this.bundles.push(_bundle);
- }
- return _bundle;
- },
- isEditable: function() {
- return (this.renkan.options.editor_mode && !this.renkan.read_only);
- },
- onStatusChange: function() {
- var savebtn = this.$.find(".Rk-Save-Button"),
- tip = savebtn.find(".Rk-TopBar-Tooltip-Contents");
- if (this.renkan.read_only) {
- savebtn.removeClass("disabled Rk-Save-Online").addClass("Rk-Save-ReadOnly");
- tip.text(this.renkan.translate("Connection lost"));
- } else {
- if (this.renkan.options.manual_save) {
- savebtn.removeClass("Rk-Save-ReadOnly Rk-Save-Online");
- tip.text(this.renkan.translate("Save Project"));
- } else {
- savebtn.removeClass("disabled Rk-Save-ReadOnly").addClass("Rk-Save-Online");
- tip.text(this.renkan.translate("Auto-save enabled"));
- }
- }
- this.redrawUsers();
- },
- setScale: function(_newScale, _offset) {
- if ((_newScale/this.initialScale) > Utils._MIN_SCALE && (_newScale/this.initialScale) < Utils._MAX_SCALE) {
- this.scale = _newScale;
- if (_offset) {
- this.offset = _offset;
- }
- this.redraw();
- }
- },
- autoScale: function(force_view) {
- var nodes = this.renkan.project.get("nodes");
- if (nodes.length > 1) {
- var _xx = nodes.map(function(_node) { return _node.get("position").x; }),
- _yy = nodes.map(function(_node) { return _node.get("position").y; }),
- _minx = Math.min.apply(Math, _xx),
- _miny = Math.min.apply(Math, _yy),
- _maxx = Math.max.apply(Math, _xx),
- _maxy = Math.max.apply(Math, _yy);
- var _scale = Math.min( (paper.view.size.width - 2 * this.renkan.options.autoscale_padding) / (_maxx - _minx), (paper.view.size.height - 2 * this.renkan.options.autoscale_padding) / (_maxy - _miny));
- this.initialScale = _scale;
- // Override calculated scale if asked
- if((typeof force_view !== "undefined") && parseFloat(force_view.zoom_level)>0 && parseFloat(force_view.offset.x)>0 && parseFloat(force_view.offset.y)>0){
- this.setScale(parseFloat(force_view.zoom_level), new paper.Point(parseFloat(force_view.offset.x), parseFloat(force_view.offset.y)));
- }
- else{
- this.setScale(_scale, paper.view.center.subtract(new paper.Point([(_maxx + _minx) / 2, (_maxy + _miny) / 2]).multiply(_scale)));
- }
- }
- if (nodes.length === 1) {
- this.setScale(1, paper.view.center.subtract(new paper.Point([nodes.at(0).get("position").x, nodes.at(0).get("position").y])));
- }
- },
- redrawMiniframe: function() {
- var topleft = this.toMinimapCoords(this.toModelCoords(new paper.Point([0,0]))),
- bottomright = this.toMinimapCoords(this.toModelCoords(paper.view.bounds.bottomRight));
- this.minimap.miniframe.fitBounds(topleft, bottomright);
- },
- rescaleMinimap: function() {
- var nodes = this.renkan.project.get("nodes");
- if (nodes.length > 1) {
- var _xx = nodes.map(function(_node) { return _node.get("position").x; }),
- _yy = nodes.map(function(_node) { return _node.get("position").y; }),
- _minx = Math.min.apply(Math, _xx),
- _miny = Math.min.apply(Math, _yy),
- _maxx = Math.max.apply(Math, _xx),
- _maxy = Math.max.apply(Math, _yy);
- var _scale = Math.min(
- this.scale * 0.8 * this.renkan.options.minimap_width / paper.view.bounds.width,
- this.scale * 0.8 * this.renkan.options.minimap_height / paper.view.bounds.height,
- ( this.renkan.options.minimap_width - 2 * this.renkan.options.minimap_padding ) / (_maxx - _minx),
- ( this.renkan.options.minimap_height - 2 * this.renkan.options.minimap_padding ) / (_maxy - _miny)
- );
- this.minimap.offset = this.minimap.size.divide(2).subtract(new paper.Point([(_maxx + _minx) / 2, (_maxy + _miny) / 2]).multiply(_scale));
- this.minimap.scale = _scale;
- }
- if (nodes.length === 1) {
- this.minimap.scale = 0.1;
- this.minimap.offset = this.minimap.size.divide(2).subtract(new paper.Point([nodes.at(0).get("position").x, nodes.at(0).get("position").y]).multiply(this.minimap.scale));
- }
- this.redraw();
- },
- toPaperCoords: function(_point) {
- return _point.multiply(this.scale).add(this.offset);
- },
- toMinimapCoords: function(_point) {
- return _point.multiply(this.minimap.scale).add(this.minimap.offset).add(this.minimap.topleft);
- },
- toModelCoords: function(_point) {
- return _point.subtract(this.offset).divide(this.scale);
- },
- addRepresentation: function(_type, _model) {
- var RendererType = requtils.getRenderer()[_type];
- var _repr = new RendererType(this, _model);
- this.representations.push(_repr);
- return _repr;
- },
- addRepresentations: function(_type, _collection) {
- var _this = this;
- _collection.forEach(function(_model) {
- _this.addRepresentation(_type, _model);
- });
- },
- userTemplate: _.template(
- '<li class="Rk-User"><span class="Rk-UserColor" style="background:<%=background%>;"></span><%=name%></li>'
- ),
- redrawUsers: function() {
- if (!this.renkan.options.show_user_list) {
- return;
- }
- var allUsers = [].concat((this.renkan.project.current_user_list || {}).models || [], (this.renkan.project.get("users") || {}).models || []),
- ulistHtml = '',
- $userpanel = this.$.find(".Rk-Users"),
- $name = $userpanel.find(".Rk-CurrentUser-Name"),
- $cpitems = $userpanel.find(".Rk-Edit-ColorPicker li"),
- $colorsquare = $userpanel.find(".Rk-CurrentUser-Color"),
- _this = this;
- $name.off("click").text(this.renkan.translate("<unknown user>"));
- $cpitems.off("mouseleave click");
- allUsers.forEach(function(_user) {
- if (_user.get("_id") === _this.renkan.current_user) {
- $name.text(_user.get("title"));
- $colorsquare.css("background", _user.get("color"));
- if (_this.isEditable()) {
-
- if (_this.renkan.options.user_name_editable) {
- $name.click(function() {
- var $this = $(this),
- $input = $('<input>').val(_user.get("title")).blur(function() {
- _user.set("title", $(this).val());
- _this.redrawUsers();
- _this.redraw();
- });
- $this.empty().html($input);
- $input.select();
- });
- }
-
- if (_this.renkan.options.user_color_editable) {
- $cpitems.click(
- function(_e) {
- _e.preventDefault();
- if (_this.isEditable()) {
- _user.set("color", $(this).attr("data-color"));
- }
- $(this).parent().hide();
- }
- ).mouseleave(function() {
- $colorsquare.css("background", _user.get("color"));
- });
- }
- }
-
- } else {
- ulistHtml += _this.userTemplate({
- name: _user.get("title"),
- background: _user.get("color")
- });
- }
- });
- $userpanel.find(".Rk-UserList").html(ulistHtml);
- },
- removeRepresentation: function(_representation) {
- _representation.destroy();
- this.representations = _(this.representations).reject(
- function(_repr) {
- return _repr === _representation;
- }
- );
- },
- getRepresentationByModel: function(_model) {
- if (!_model) {
- return undefined;
- }
- return _(this.representations).find(function(_repr) {
- return _repr.model === _model;
- });
- },
- removeRepresentationsOfType: function(_type) {
- var _representations = _(this.representations).filter(function(_repr) {
- return _repr.type === _type;
- }),
- _this = this;
- _(_representations).each(function(_repr) {
- _this.removeRepresentation(_repr);
- });
- },
- highlightModel: function(_model) {
- var _repr = this.getRepresentationByModel(_model);
- if (_repr) {
- _repr.highlight();
- }
- },
- unhighlightAll: function(_model) {
- _(this.representations).each(function(_repr) {
- _repr.unhighlight();
- });
- },
- unselectAll: function(_model) {
- _(this.representations).each(function(_repr) {
- _repr.unselect();
- });
- },
- redraw: function() {
- if(! this.redrawActive ) {
- return;
- }
- _(this.representations).each(function(_representation) {
- _representation.redraw(true);
- });
- if (this.minimap) {
- this.redrawMiniframe();
- }
- paper.view.draw();
- },
- addTempEdge: function(_from, _point) {
- var _tmpEdge = this.addRepresentation("TempEdge",null);
- _tmpEdge.end_pos = _point;
- _tmpEdge.from_representation = _from;
- _tmpEdge.redraw();
- this.click_target = _tmpEdge;
- },
- findTarget: function(_hitResult) {
- if (_hitResult && typeof _hitResult.item.__representation !== "undefined") {
- var _newTarget = _hitResult.item.__representation;
- if (this.selected_target !== _hitResult.item.__representation) {
- if (this.selected_target) {
- this.selected_target.unselect(_newTarget);
- }
- _newTarget.select(this.selected_target);
- this.selected_target = _newTarget;
- }
- } else {
- if (this.selected_target) {
- this.selected_target.unselect();
- }
- this.selected_target = null;
- }
- },
- paperShift: function(_delta) {
- this.offset = this.offset.add(_delta);
- this.redraw();
- },
- onMouseMove: function(_event) {
- var _off = this.canvas_$.offset(),
- _point = new paper.Point([
- _event.pageX - _off.left,
- _event.pageY - _off.top
- ]),
- _delta = _point.subtract(this.last_point);
- this.last_point = _point;
- if (!this.is_dragging && this.mouse_down && _delta.length > Utils._MIN_DRAG_DISTANCE) {
- this.is_dragging = true;
- }
- var _hitResult = paper.project.hitTest(_point);
- if (this.is_dragging) {
- if (this.click_target && typeof this.click_target.paperShift === "function") {
- this.click_target.paperShift(_delta);
- } else {
- this.paperShift(_delta);
- }
- } else {
- this.findTarget(_hitResult);
- }
- paper.view.draw();
- },
- onMouseDown: function(_event, _isTouch) {
- var _off = this.canvas_$.offset(),
- _point = new paper.Point([
- _event.pageX - _off.left,
- _event.pageY - _off.top
- ]);
- this.last_point = _point;
- this.mouse_down = true;
- if (!this.click_target || this.click_target.type !== "Temp-edge") {
- this.removeRepresentationsOfType("editor");
- this.is_dragging = false;
- var _hitResult = paper.project.hitTest(_point);
- if (_hitResult && typeof _hitResult.item.__representation !== "undefined") {
- this.click_target = _hitResult.item.__representation;
- this.click_target.mousedown(_event, _isTouch);
- } else {
- this.click_target = null;
- if (this.isEditable() && this.click_mode === Utils._CLICKMODE_ADDNODE) {
- var _coords = this.toModelCoords(_point),
- _data = {
- id: Utils.getUID('node'),
- created_by: this.renkan.current_user,
- position: {
- x: _coords.x,
- y: _coords.y
- }
- };
- _node = this.renkan.project.addNode(_data);
- this.getRepresentationByModel(_node).openEditor();
- }
- }
- }
- if (this.click_mode) {
- if (this.isEditable() && this.click_mode === Utils._CLICKMODE_STARTEDGE && this.click_target && this.click_target.type === "Node") {
- this.removeRepresentationsOfType("editor");
- this.addTempEdge(this.click_target, _point);
- this.click_mode = Utils._CLICKMODE_ENDEDGE;
- this.notif_$.fadeOut(function() {
- $(this).html(this.renkan.translate("Click on a second node to complete the edge")).fadeIn();
- });
- } else {
- this.notif_$.hide();
- this.click_mode = false;
- }
- }
- paper.view.draw();
- },
- onMouseUp: function(_event, _isTouch) {
- this.mouse_down = false;
- if (this.click_target) {
- var _off = this.canvas_$.offset();
- this.click_target.mouseup(
- {
- point: new paper.Point([
- _event.pageX - _off.left,
- _event.pageY - _off.top
- ])
- },
- _isTouch
- );
- } else {
- this.click_target = null;
- this.is_dragging = false;
- if (_isTouch) {
- this.unselectAll();
- }
- }
- paper.view.draw();
- },
- onScroll: function(_event, _scrolldelta) {
- this.totalScroll += _scrolldelta;
- if (Math.abs(this.totalScroll) >= 1) {
- var _off = this.canvas_$.offset(),
- _delta = new paper.Point([
- _event.pageX - _off.left,
- _event.pageY - _off.top
- ]).subtract(this.offset).multiply( Math.SQRT2 - 1 );
- if (this.totalScroll > 0) {
- this.setScale( this.scale * Math.SQRT2, this.offset.subtract(_delta) );
- } else {
- this.setScale( this.scale * Math.SQRT1_2, this.offset.add(_delta.divide(Math.SQRT2)));
- }
- this.totalScroll = 0;
- }
- },
- onDoubleClick: function(_event) {
- if (!this.isEditable()) {
- return;
- }
- var _off = this.canvas_$.offset(),
- _point = new paper.Point([
- _event.pageX - _off.left,
- _event.pageY - _off.top
- ]);
- var _hitResult = paper.project.hitTest(_point);
- if (this.isEditable() && (!_hitResult || typeof _hitResult.item.__representation === "undefined")) {
- var _coords = this.toModelCoords(_point),
- _data = {
- id: Utils.getUID('node'),
- created_by: this.renkan.current_user,
- position: {
- x: _coords.x,
- y: _coords.y
- }
- },
- _node = this.renkan.project.addNode(_data);
- this.getRepresentationByModel(_node).openEditor();
- }
- paper.view.draw();
- },
- defaultDropHandler: function(_data) {
- var newNode = {};
- var snippet = "";
- switch(_data["text/x-iri-specific-site"]) {
- case "twitter":
- snippet = $('<div>').html(_data["text/x-iri-selected-html"]);
- var tweetdiv = snippet.find(".tweet");
- newNode.title = this.renkan.translate("Tweet by ") + tweetdiv.attr("data-name");
- newNode.uri = "http://twitter.com/" + tweetdiv.attr("data-screen-name") + "/status/" + tweetdiv.attr("data-tweet-id");
- newNode.image = tweetdiv.find(".avatar").attr("src");
- newNode.description = tweetdiv.find(".js-tweet-text:first").text();
- break;
- case "google":
- snippet = $('<div>').html(_data["text/x-iri-selected-html"]);
- newNode.title = snippet.find("h3:first").text().trim();
- newNode.uri = snippet.find("h3 a").attr("href");
- newNode.description = snippet.find(".st:first").text().trim();
- break;
- default:
- if (_data["text/x-iri-source-uri"]) {
- newNode.uri = _data["text/x-iri-source-uri"];
- }
- }
- if (_data["text/plain"] || _data["text/x-iri-selected-text"]) {
- newNode.description = (_data["text/plain"] || _data["text/x-iri-selected-text"]).replace(/[\s\n]+/gm,' ').trim();
- }
- if (_data["text/html"] || _data["text/x-iri-selected-html"]) {
- snippet = $('<div>').html(_data["text/html"] || _data["text/x-iri-selected-html"]);
- var _svgimgs = snippet.find("image");
- if (_svgimgs.length) {
- newNode.image = _svgimgs.attr("xlink:href");
- }
- var _svgpaths = snippet.find("path");
- if (_svgpaths.length) {
- newNode.clipPath = _svgpaths.attr("d");
- }
- var _imgs = snippet.find("img");
- if (_imgs.length) {
- newNode.image = _imgs[0].src;
- }
- var _as = snippet.find("a");
- if (_as.length) {
- newNode.uri = _as[0].href;
- }
- newNode.title = snippet.find("[title]").attr("title") || newNode.title;
- newNode.description = snippet.text().replace(/[\s\n]+/gm,' ').trim();
- }
- if (_data["text/uri-list"]) {
- newNode.uri = _data["text/uri-list"];
- }
- if (_data["text/x-moz-url"] && !newNode.title) {
- newNode.title = (_data["text/x-moz-url"].split("\n")[1] || "").trim();
- if (newNode.title === newNode.uri) {
- newNode.title = false;
- }
- }
- if (_data["text/x-iri-source-title"] && !newNode.title) {
- newNode.title = _data["text/x-iri-source-title"];
- }
- if (_data["text/html"] || _data["text/x-iri-selected-html"]) {
- snippet = $('<div>').html(_data["text/html"] || _data["text/x-iri-selected-html"]);
- newNode.image = snippet.find("[data-image]").attr("data-image") || newNode.image;
- newNode.uri = snippet.find("[data-uri]").attr("data-uri") || newNode.uri;
- newNode.title = snippet.find("[data-title]").attr("data-title") || newNode.title;
- newNode.description = snippet.find("[data-description]").attr("data-description") || newNode.description;
- newNode.clipPath = snippet.find("[data-clip-path]").attr("data-clip-path") || newNode.clipPath;
- }
-
- if (!newNode.title) {
- newNode.title = this.renkan.translate("Dragged resource");
- }
- var fields = ["title", "description", "uri", "image"];
- for (var i = 0; i < fields.length; i++) {
- var f = fields[i];
- if (_data["text/x-iri-" + f] || _data[f]) {
- newNode[f] = _data["text/x-iri-" + f] || _data[f];
- }
- if (newNode[f] === "none" || newNode[f] === "null") {
- newNode[f] = undefined;
- }
- }
-
- if(typeof this.renkan.options.drop_enhancer === "function"){
- newNode = this.renkan.options.drop_enhancer(newNode, _data);
- }
-
- return newNode;
-
- },
- dropData: function(_data, _event) {
- if (!this.isEditable()) {
- return;
- }
- if (_data["text/json"] || _data["application/json"]) {
- try {
- var jsondata = JSON.parse(_data["text/json"] || _data["application/json"]);
- _(_data).extend(jsondata);
- }
- catch(e) {}
- }
-
- var newNode = (typeof this.renkan.options.drop_handler === "undefined")?this.defaultDropHandler(_data):this.renkan.options.drop_handler(_data);
-
- var _off = this.canvas_$.offset(),
- _point = new paper.Point([
- _event.pageX - _off.left,
- _event.pageY - _off.top
- ]),
- _coords = this.toModelCoords(_point),
- _nodedata = {
- id: Utils.getUID('node'),
- created_by: this.renkan.current_user,
- uri: newNode.uri || "",
- title: newNode.title || "",
- description: newNode.description || "",
- image: newNode.image || "",
- color: newNode.color || undefined,
- clip_path: newNode.clipPath || undefined,
- position: {
- x: _coords.x,
- y: _coords.y
- }
- };
- var _node = this.renkan.project.addNode(_nodedata),
- _repr = this.getRepresentationByModel(_node);
- if (_event.type === "drop") {
- _repr.openEditor();
- }
- },
- fullScreen: function() {
- var _isFull = document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen,
- _el = this.renkan.$[0],
- _requestMethods = ["requestFullScreen","mozRequestFullScreen","webkitRequestFullScreen"],
- _cancelMethods = ["cancelFullScreen","mozCancelFullScreen","webkitCancelFullScreen"],
- i;
- if (_isFull) {
- for (i = 0; i < _cancelMethods.length; i++) {
- if (typeof document[_cancelMethods[i]] === "function") {
- document[_cancelMethods[i]]();
- break;
- }
- }
- } else {
- for (i = 0; i < _requestMethods.length; i++) {
- if (typeof _el[_requestMethods[i]] === "function") {
- _el[_requestMethods[i]]();
- break;
- }
- }
- }
- },
- zoomOut: function() {
- var _newScale = this.scale * Math.SQRT1_2,
- _offset = new paper.Point([
- this.canvas_$.width(),
- this.canvas_$.height()
- ]).multiply( 0.5 * ( 1 - Math.SQRT1_2 ) ).add(this.offset.multiply( Math.SQRT1_2 ));
- this.setScale( _newScale, _offset );
- },
- zoomIn: function() {
- var _newScale = this.scale * Math.SQRT2,
- _offset = new paper.Point([
- this.canvas_$.width(),
- this.canvas_$.height()
- ]).multiply( 0.5 * ( 1 - Math.SQRT2 ) ).add(this.offset.multiply( Math.SQRT2 ));
- this.setScale( _newScale, _offset );
- },
- addNodeBtn: function() {
- if (this.click_mode === Utils._CLICKMODE_ADDNODE) {
- this.click_mode = false;
- this.notif_$.hide();
- } else {
- this.click_mode = Utils._CLICKMODE_ADDNODE;
- this.notif_$.text(this.renkan.translate("Click on the background canvas to add a node")).fadeIn();
- }
- return false;
- },
- addEdgeBtn: function() {
- if (this.click_mode === Utils._CLICKMODE_STARTEDGE || this.click_mode === Utils._CLICKMODE_ENDEDGE) {
- this.click_mode = false;
- this.notif_$.hide();
- } else {
- this.click_mode = Utils._CLICKMODE_STARTEDGE;
- this.notif_$.text(this.renkan.translate("Click on a first node to start the edge")).fadeIn();
- }
- return false;
- },
- exportProject: function() {
- var projectJSON = this.renkan.project.toJSON(),
- downloadLink = document.createElement("a"),
- projectId = projectJSON.id,
- fileNameToSaveAs = projectId + ".json";
-
- // clean ids
- delete projectJSON.id;
- delete projectJSON._id;
- delete projectJSON.space_id;
-
- var objId;
- var idsMap = {};
-
- _.each(projectJSON.nodes, function(e,i,l) {
- objId = e.id || e._id;
- delete e._id;
- delete e.id;
- idsMap[objId] = e['@id'] = Utils.getUUID4();
- });
- _.each(projectJSON.edges, function(e,i,l) {
- delete e._id;
- delete e.id;
- e.to = idsMap[e.to];
- e.from = idsMap[e.from];
- });
- _.each(projectJSON.views, function(e,i,l) {
- objId = e.id || e._id;
- delete e._id;
- delete e.id;
- });
- projectJSON.users = [];
-
- var projectJSONStr = JSON.stringify(projectJSON, null, 2);
- var blob = new Blob([projectJSONStr], {type: "application/json;charset=utf-8"});
- filesaver(blob,fileNameToSaveAs);
-
- },
- foldBins: function() {
- var foldBinsButton = this.$.find(".Rk-Fold-Bins"),
- bins = this.renkan.$.find(".Rk-Bins");
- var _this = this;
- if (bins.offset().left < 0) {
- bins.animate({left: 0},250);
- this.$.animate({left: 300},250,function() {
- var w = _this.$.width();
- paper.view.viewSize = new paper.Size([w, _this.canvas_$.height()]);
- });
- foldBinsButton.html("«");
- } else {
- bins.animate({left: -300},250);
- this.$.animate({left: 0},250,function() {
- var w = _this.$.width();
- paper.view.viewSize = new paper.Size([w, _this.canvas_$.height()]);
- });
- foldBinsButton.html("»");
- }
- },
- save: function() { },
- open: function() { }
- });
-
- /* Scene End */
-
- return Scene;
-
-});
-
-
-//Load modules and use them
-if( typeof require.config === "function" ) {
- require.config({
- paths: {
- 'jquery':'../lib/jquery.min',
- 'underscore':'../lib/underscore-min',
- 'filesaver' :'../lib/FileSaver',
- 'requtils':'require-utils'
- }
- });
-}
-
-require(['renderer/baserepresentation',
- 'renderer/basebutton',
- 'renderer/noderepr',
- 'renderer/edge',
- 'renderer/tempedge',
- 'renderer/baseeditor',
- 'renderer/nodeeditor',
- 'renderer/edgeeditor',
- 'renderer/nodebutton',
- 'renderer/nodeeditbutton',
- 'renderer/noderemovebutton',
- 'renderer/noderevertbutton',
- 'renderer/nodelinkbutton',
- 'renderer/nodeenlargebutton',
- 'renderer/nodeshrinkbutton',
- 'renderer/edgeeditbutton',
- 'renderer/edgeremovebutton',
- 'renderer/edgerevertbutton',
- 'renderer/miniframe',
- 'renderer/scene'
- ], function(BaseRepresentation, BaseButton, NodeRepr, Edge, TempEdge, BaseEditor, NodeEditor, EdgeEditor, NodeButton, NodeEditButton, NodeRemoveButton, NodeRevertButton, NodeLinkButton, NodeEnlargeButton, NodeShrinkButton, EdgeEditButton, EdgeRemoveButton, EdgeRevertButton, MiniFrame, Scene){
-
-
-
- var Rkns = window.Rkns;
-
- if(typeof Rkns.Renderer === "undefined"){
- Rkns.Renderer = {};
- }
- var Renderer = Rkns.Renderer;
-
- Renderer._BaseRepresentation = BaseRepresentation;
- Renderer._BaseButton = BaseButton;
- Renderer.Node = NodeRepr;
- Renderer.Edge = Edge;
- Renderer.TempEdge = TempEdge;
- Renderer._BaseEditor = BaseEditor;
- Renderer.NodeEditor = NodeEditor;
- Renderer.EdgeEditor = EdgeEditor;
- Renderer._NodeButton = NodeButton;
- Renderer.NodeEditButton = NodeEditButton;
- Renderer.NodeRemoveButton = NodeRemoveButton;
- Renderer.NodeRevertButton = NodeRevertButton;
- Renderer.NodeLinkButton = NodeLinkButton;
- Renderer.NodeEnlargeButton = NodeEnlargeButton;
- Renderer.NodeShrinkButton = NodeShrinkButton;
- Renderer.EdgeEditButton = EdgeEditButton;
- Renderer.EdgeRemoveButton = EdgeRemoveButton;
- Renderer.EdgeRevertButton = EdgeRevertButton;
- Renderer.MiniFrame = MiniFrame;
- Renderer.Scene = Scene;
-
- startRenkan();
-});
-
-define("main-renderer", function(){});
-
--- a/server/python/django/renkanmanager/static/renkanmanager/lib/renkan/renkan.min.js Wed Dec 17 16:31:10 2014 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-/*!
- * _____ _
- * | __ \ | |
- * | |__) |___ _ __ | | ____ _ _ __
- * | _ // _ \ '_ \| |/ / _` | '_ \
- * | | \ \ __/ | | | < (_| | | | |
- * |_| \_\___|_| |_|_|\_\__,_|_| |_|
- *
- * Copyright 2012-2013 Institut de recherche et d'innovation
- * contributor(s) : Yves-Marie Haussonne, Raphael Velt, Samuel Huron
- *
- * contact@iri.centrepompidou.fr
- * http://www.iri.centrepompidou.fr
- *
- * This software is a computer program whose purpose is to show and add annotations on a video .
- * This software is governed by the CeCILL-C license under French law and
- * abiding by the rules of distribution of free software. You can use,
- * modify and/ or redistribute the software under the terms of the CeCILL-C
- * license as circulated by CEA, CNRS and INRIA at the following URL
- * "http://www.cecill.info".
- *
- * The fact that you are presently reading this means that you have had
- * knowledge of the CeCILL-C license and that you accept its terms.
- */
-/*! renkan - v0.7.11 - Copyright © IRI 2014 */
-
-
-!function(a){"use strict";"object"!=typeof a.Rkns&&(a.Rkns={});var b=a.Rkns,c=b.$=a.jQuery,d=b._=a._;b.pickerColors=["#8f1919","#a80000","#d82626","#ff0000","#e87c7c","#ff6565","#f7d3d3","#fecccc","#8f5419","#a85400","#d87f26","#ff7f00","#e8b27c","#ffb265","#f7e5d3","#fee5cc","#8f8f19","#a8a800","#d8d826","#feff00","#e8e87c","#feff65","#f7f7d3","#fefecc","#198f19","#00a800","#26d826","#00ff00","#7ce87c","#65ff65","#d3f7d3","#ccfecc","#198f8f","#00a8a8","#26d8d8","#00feff","#7ce8e8","#65feff","#d3f7f7","#ccfefe","#19198f","#0000a8","#2626d8","#0000ff","#7c7ce8","#6565ff","#d3d3f7","#ccccfe","#8f198f","#a800a8","#d826d8","#ff00fe","#e87ce8","#ff65fe","#f7d3f7","#feccfe","#000000","#242424","#484848","#6d6d6d","#919191","#b6b6b6","#dadada","#ffffff"],b.__renkans=[];var e=b._BaseBin=function(a,c){if("undefined"!=typeof a){this.renkan=a,this.renkan.$.find(".Rk-Bin-Main").hide(),this.$=b.$("<li>").addClass("Rk-Bin").appendTo(a.$.find(".Rk-Bin-List")),this.title_icon_$=b.$("<span>").addClass("Rk-Bin-Title-Icon").appendTo(this.$);var d=this;b.$("<a>").attr({href:"#",title:a.translate("Close bin")}).addClass("Rk-Bin-Close").html("×").appendTo(this.$).click(function(){return d.destroy(),a.$.find(".Rk-Bin-Main:visible").length||a.$.find(".Rk-Bin-Main:last").slideDown(),a.resizeBins(),!1}),b.$("<a>").attr({href:"#",title:a.translate("Refresh bin")}).addClass("Rk-Bin-Refresh").appendTo(this.$).click(function(){return d.refresh(),!1}),this.count_$=b.$("<div>").addClass("Rk-Bin-Count").appendTo(this.$),this.title_$=b.$("<h2>").addClass("Rk-Bin-Title").appendTo(this.$),this.main_$=b.$("<div>").addClass("Rk-Bin-Main").appendTo(this.$).html('<h4 class="Rk-Bin-Loading">'+a.translate("Loading, please wait")+"</h4>"),this.title_$.html(c.title||"(new bin)"),this.renkan.resizeBins(),c.auto_refresh&&window.setInterval(function(){d.refresh()},c.auto_refresh)}};e.prototype.destroy=function(){this.$.detach(),this.renkan.resizeBins()};var f=b.Renkan=function(a){var e=this;if(b.__renkans.push(this),this.options=d.defaults(a,b.defaults),d(this.options.property_files).each(function(a){b.$.getJSON(a,function(a){e.options.properties=e.options.properties.concat(a)})}),this.read_only=this.options.read_only||!this.options.editor_mode,this.project=new b.Models.Project,"undefined"!=typeof this.options.user_id&&(this.current_user=this.options.user_id),this.$=b.$("#"+this.options.container),this.$.addClass("Rk-Main").html(this.template(this)),this.tabs=[],this.search_engines=[],this.current_user_list=new b.Models.UsersList,this.current_user_list.on("add remove",function(){this.renderer&&this.renderer.redrawUsers()}),this.colorPicker=function(){var a=d.template('<li data-color="<%=c%>" style="background: <%=c%>"></li>');return'<ul class="Rk-Edit-ColorPicker">'+b.pickerColors.map(function(b){return a({c:b})}).join("")+"</ul>"}(),this.options.show_editor&&(this.renderer=new b.Renderer.Scene(this)),this.options.search.length){var f=d.template('<li class="<%= className %>" data-key="<%= key %>"><%= title %></li>'),g=this.$.find(".Rk-Search-List"),h=this.$.find(".Rk-Web-Search-Input"),i=this.$.find(".Rk-Web-Search-Form");d(this.options.search).each(function(a){b[a.type]&&b[a.type].Search&&e.search_engines.push(new b[a.type].Search(e,a))}),g.html(d(this.search_engines).map(function(a,b){return f({key:b,title:a.getSearchTitle(),className:a.getBgClass()})}).join("")),g.find("li").click(function(){var a=b.$(this);e.setSearchEngine(a.attr("data-key")),i.submit()}),i.submit(function(){if(h.val()){var a=e.search_engine;a.search(h.val())}return!1}),this.$.find(".Rk-Search-Current").mouseenter(function(){g.slideDown()}),this.$.find(".Rk-Search-Select").mouseleave(function(){g.hide()}),this.setSearchEngine(0)}else this.$.find(".Rk-Web-Search-Form").detach();d(this.options.bins).each(function(a){b[a.type]&&b[a.type].Bin&&e.tabs.push(new b[a.type].Bin(e,a))});var j=!1;this.$.find(".Rk-Bins").on("click",".Rk-Bin-Title,.Rk-Bin-Title-Icon",function(){var a=b.$(this).siblings(".Rk-Bin-Main");a.is(":hidden")&&(e.$.find(".Rk-Bin-Main").slideUp(),a.slideDown())}),this.options.show_editor&&this.$.find(".Rk-Bins").on("mouseover",".Rk-Bin-Item",function(){var a=b.$(this);if(a&&c(a).attr("data-uri")){var f=e.project.get("nodes").where({uri:c(a).attr("data-uri")});d(f).each(function(a){e.renderer.highlightModel(a)})}}).mouseout(function(){e.renderer.unhighlightAll()}).on("mousemove",".Rk-Bin-Item",function(){try{this.dragDrop()}catch(a){}}).on("touchstart",".Rk-Bin-Item",function(){j=!1}).on("touchmove",".Rk-Bin-Item",function(a){a.preventDefault();var b=a.originalEvent.changedTouches[0],c=e.renderer.canvas_$.offset(),d=e.renderer.canvas_$.width(),f=e.renderer.canvas_$.height();if(b.pageX>=c.left&&b.pageX<c.left+d&&b.pageY>=c.top&&b.pageY<c.top+f)if(j)e.renderer.onMouseMove(b,!0);else{j=!0;var g=document.createElement("div");g.appendChild(this.cloneNode(!0)),e.renderer.dropData({"text/html":g.innerHTML},b),e.renderer.onMouseDown(b,!0)}}).on("touchend",".Rk-Bin-Item",function(a){j&&e.renderer.onMouseUp(a.originalEvent.changedTouches[0],!0),j=!1}).on("dragstart",".Rk-Bin-Item",function(a){var b=document.createElement("div");b.appendChild(this.cloneNode(!0));try{a.originalEvent.dataTransfer.setData("text/html",b.innerHTML)}catch(c){a.originalEvent.dataTransfer.setData("text",b.innerHTML)}}),b.$(window).resize(function(){e.resizeBins()});var k=!1,l="";this.$.find(".Rk-Bins-Search-Input").on("change keyup paste input",function(){var a=b.$(this).val();if(a!==l){var c=b.Utils.regexpFromTextOrArray(a.length>1?a:null);c.source!==k&&(k=c.source,d(e.tabs).each(function(a){a.render(c)}))}}),this.$.find(".Rk-Bins-Search-Form").submit(function(){return!1})};f.prototype.template=d.template('<% if (options.show_bins) { %><div class="Rk-Bins"><div class="Rk-Bins-Head"><h2 class="Rk-Bins-Title"><%- translate("Select contents:")%></h2><form class="Rk-Web-Search-Form Rk-Search-Form"><input class="Rk-Web-Search-Input Rk-Search-Input" type="search" placeholder="<%- translate("Search the Web") %>" /><div class="Rk-Search-Select"><div class="Rk-Search-Current"></div><ul class="Rk-Search-List"></ul></div><input type="submit" value="" class="Rk-Web-Search-Submit Rk-Search-Submit" title="<%- translate("Search the Web") %>" /></form><form class="Rk-Bins-Search-Form Rk-Search-Form"><input class="Rk-Bins-Search-Input Rk-Search-Input" type="search" placeholder="<%- translate("Search in Bins") %>" /><input type="submit" value="" class="Rk-Bins-Search-Submit Rk-Search-Submit" title="<%- translate("Search in Bins") %>" /></form></div><ul class="Rk-Bin-List"></ul></div><% } %><% if (options.show_editor) { %><div class="Rk-Render Rk-Render-<% if (options.show_bins) { %>Panel<% } else { %>Full<% } %>"></div><% } %>'),f.prototype.translate=function(a){return b.i18n[this.options.language]&&b.i18n[this.options.language][a]?b.i18n[this.options.language][a]:this.options.language.length>2&&b.i18n[this.options.language.substr(0,2)]&&b.i18n[this.options.language.substr(0,2)][a]?b.i18n[this.options.language.substr(0,2)][a]:a},f.prototype.onStatusChange=function(){this.renderer.onStatusChange()},f.prototype.setSearchEngine=function(a){this.search_engine=this.search_engines[a],this.$.find(".Rk-Search-Current").attr("class","Rk-Search-Current "+this.search_engine.getBgClass())},f.prototype.resizeBins=function(){var a=+this.$.find(".Rk-Bins-Head").outerHeight();this.$.find(".Rk-Bin-Title:visible").each(function(){a+=b.$(this).outerHeight()}),this.$.find(".Rk-Bin-Main").css({height:this.$.find(".Rk-Bins").height()-a})};var g=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var b=16*Math.random()|0,c="x"===a?b:3&b|8;return c.toString(16)})};b.Utils={getUUID4:g,getUID:function(){function a(a){return 10>a?"0"+a:a}var b=new Date,c=0,d=b.getUTCFullYear()+"-"+a(b.getUTCMonth()+1)+"-"+a(b.getUTCDate())+"-"+g();return function(a){for(var b=(++c).toString(16),e="undefined"==typeof a?"":a+"-";b.length<4;)b="0"+b;return e+d+"-"+b}}(),getFullURL:function(a){if("undefined"==typeof a||null==a)return"";if(/https?:\/\//.test(a))return a;var b=new Image;b.src=a;var c=b.src;return b.src=null,c},inherit:function(a,b){var c=function(){"function"==typeof b&&b.apply(this,Array.prototype.slice.call(arguments,0)),a.apply(this,Array.prototype.slice.call(arguments,0)),"function"!=typeof this._init||this._initialized||(this._init.apply(this,Array.prototype.slice.call(arguments,0)),this._initialized=!0)};return d(c.prototype).extend(a.prototype),c},regexpFromTextOrArray:function(){function a(a){function b(a){return function(b,c){a=a.replace(h[b],c)}}for(var e=a.toLowerCase().replace(g,""),i="",j=0;j<e.length;j++){j&&(i+=f+"*");var k=e[j];d(c).each(b(k)),i+=k}return i}function b(c){switch(typeof c){case"string":return a(c);case"object":var e="";return d(c).each(function(a){var c=b(a);c&&(e&&(e+="|"),e+=c)}),e}return""}var c=["[aáàâä]","[cç]","[eéèêë]","[iíìîï]","[oóòôö]","[uùûü]"],e=[String.fromCharCode(768),String.fromCharCode(769),String.fromCharCode(770),String.fromCharCode(771),String.fromCharCode(807),"{","}","(",")","[","]","【","】","、","・","‥","。","「","」","『","』","〜",":","!","?"," ",","," ",";","(",")",".","*","+","\\","?","|","{","}","[","]","^","#","/"],f="[\\"+e.join("\\")+"]",g=new RegExp(f,"gm"),h=d(c).map(function(a){return new RegExp(a)});return function(a){var c=b(a);if(c){var d=new RegExp(c,"im"),e=new RegExp("("+c+")","igm");return{isempty:!1,source:c,test:function(a){return d.test(a)},replace:function(a,b){return a.replace(e,b)}}}return{isempty:!0,source:"",test:function(){return!0},replace:function(){return text}}}}(),_MIN_DRAG_DISTANCE:2,_NODE_BUTTON_WIDTH:40,_EDGE_BUTTON_INNER:2,_EDGE_BUTTON_OUTER:40,_CLICKMODE_ADDNODE:1,_CLICKMODE_STARTEDGE:2,_CLICKMODE_ENDEDGE:3,_NODE_SIZE_STEP:Math.LN2/4,_MIN_SCALE:.05,_MAX_SCALE:20,_MOUSEMOVE_RATE:80,_DOUBLETAP_DELAY:800,_DOUBLETAP_DISTANCE:400,_USER_PLACEHOLDER:function(a){return{color:a.options.default_user_color,title:a.translate("(unknown user)"),get:function(a){return this[a]||!1}}},_BOOKMARKLET_CODE:function(a){return"(function(a,b,c,d,e,f,h,i,j,k,l,m,n,o,p,q,r){a=document;b=a.body;c=a.location.href;j='draggable';m='text/x-iri-';d=a.createElement('div');d.innerHTML='<p_style=\"position:fixed;top:0;right:0;font:bold_18px_sans-serif;color:#fff;background:#909;padding:10px;z-index:100000;\">"+a.translate("Drag items from this website, drop them in Renkan").replace(/ /g,"_")+"</p>'.replace(/_/g,String.fromCharCode(32));b.appendChild(d);e=[{r:/https?:\\/\\/[^\\/]*twitter\\.com\\//,s:'.tweet',n:'twitter'},{r:/https?:\\/\\/[^\\/]*google\\.[^\\/]+\\//,s:'.g',n:'google'},{r:/https?:\\/\\/[^\\/]*lemonde\\.fr\\//,s:'[data-vr-contentbox]',n:'lemonde'}];f=false;e.forEach(function(g){if(g.r.test(c)){f=g;}});if(f){h=function(){Array.prototype.forEach.call(a.querySelectorAll(f.s),function(i){i[j]=true;k=i.style;k.borderWidth='2px';k.borderColor='#909';k.borderStyle='solid';k.backgroundColor='rgba(200,0,180,.1)';})};window.setInterval(h,500);h();};a.addEventListener('dragstart',function(k){l=k.dataTransfer;l.setData(m+'source-uri',c);l.setData(m+'source-title',a.title);n=k.target;if(f){o=n;while(!o.attributes[j]){o=o.parentNode;if(o==b){break;}}}if(f&&o.attributes[j]){p=o.cloneNode(true);l.setData(m+'specific-site',f.n)}else{q=a.getSelection();if(q.type==='Range'||!q.type){p=q.getRangeAt(0).cloneContents();}else{p=n.cloneNode();}}r=a.createElement('div');r.appendChild(p);l.setData('text/x-iri-selected-text',r.textContent.trim());l.setData('text/x-iri-selected-html',r.innerHTML);},false);})();"},shortenText:function(a,b){return a.length>b?a.substr(0,b)+"…":a},drawEditBox:function(a,b,c,d,e){e.css({width:a.tooltip_width-2*a.tooltip_padding});var f=e.outerHeight()+2*a.tooltip_padding,g=b.x<paper.view.center.x?1:-1,h=b.x+g*(d+a.tooltip_arrow_length),i=b.x+g*(d+a.tooltip_arrow_length+a.tooltip_width),j=b.y-f/2;j+f>paper.view.size.height-a.tooltip_margin&&(j=Math.max(paper.view.size.height-a.tooltip_margin,b.y+a.tooltip_arrow_width/2)-f),j<a.tooltip_margin&&(j=Math.min(a.tooltip_margin,b.y-a.tooltip_arrow_width/2));var k=j+f;return c.segments[0].point=c.segments[7].point=b.add([g*d,0]),c.segments[1].point.x=c.segments[2].point.x=c.segments[5].point.x=c.segments[6].point.x=h,c.segments[3].point.x=c.segments[4].point.x=i,c.segments[2].point.y=c.segments[3].point.y=j,c.segments[4].point.y=c.segments[5].point.y=k,c.segments[1].point.y=b.y-a.tooltip_arrow_width/2,c.segments[6].point.y=b.y+a.tooltip_arrow_width/2,c.closed=!0,c.fillColor=new paper.GradientColor(new paper.Gradient([a.tooltip_top_color,a.tooltip_bottom_color]),[0,j],[0,k]),e.css({left:a.tooltip_padding+Math.min(h,i),top:a.tooltip_padding+j}),c}}}(window),function(){"use strict";var a=this,b=a.Backbone,c=a.Rkns.Models={};c.getUID=function(a){var b="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var b=16*Math.random()|0,c="x"===a?b:3&b|8;return c.toString(16)});return"undefined"!=typeof a?a.type+"-"+b:b};{var d=b.RelationalModel.extend({idAttribute:"_id",constructor:function(a){"undefined"!=typeof a&&(a._id=a._id||a.id||c.getUID(this),a.title=a.title||"",a.description=a.description||"",a.uri=a.uri||"","function"==typeof this.prepare&&(a=this.prepare(a))),b.RelationalModel.prototype.constructor.call(this,a)},validate:function(){return this.type?void 0:"object has no type"},addReference:function(a,b,c,d,e){var f=c.get(d);a[b]="undefined"==typeof f&&"undefined"!=typeof e?e:f}}),e=c.User=d.extend({type:"user",prepare:function(a){return a.color=a.color||"#666666",a},toJSON:function(){return{_id:this.get("_id"),title:this.get("title"),uri:this.get("uri"),description:this.get("description"),color:this.get("color")}}}),f=c.Node=d.extend({type:"node",relations:[{type:b.HasOne,key:"created_by",relatedModel:e}],prepare:function(a){var b=a.project;return this.addReference(a,"created_by",b.get("users"),a.created_by,b.current_user),a.description=a.description||"",a},toJSON:function(){return{_id:this.get("_id"),title:this.get("title"),uri:this.get("uri"),description:this.get("description"),position:this.get("position"),image:this.get("image"),color:this.get("color"),created_by:this.get("created_by")?this.get("created_by").get("_id"):null,size:this.get("size"),clip_path:this.get("clip_path"),shape:this.get("shape")}}}),g=c.Edge=d.extend({type:"edge",relations:[{type:b.HasOne,key:"created_by",relatedModel:e},{type:b.HasOne,key:"from",relatedModel:f},{type:b.HasOne,key:"to",relatedModel:f}],prepare:function(a){var b=a.project;return this.addReference(a,"created_by",b.get("users"),a.created_by,b.current_user),this.addReference(a,"from",b.get("nodes"),a.from),this.addReference(a,"to",b.get("nodes"),a.to),a},toJSON:function(){return{_id:this.get("_id"),title:this.get("title"),uri:this.get("uri"),description:this.get("description"),from:this.get("from")?this.get("from").get("_id"):null,to:this.get("to")?this.get("to").get("_id"):null,color:this.get("color"),created_by:this.get("created_by")?this.get("created_by").get("_id"):null}}}),h=c.View=d.extend({type:"view",relations:[{type:b.HasOne,key:"created_by",relatedModel:e}],prepare:function(a){var b=a.project;if(this.addReference(a,"created_by",b.get("users"),a.created_by,b.current_user),a.description=a.description||"","undefined"!=typeof a.offset){var c={};Array.isArray(a.offset)?(c.x=a.offset[0],c.y=a.offset.length>1?a.offset[1]:a.offset[0]):null!=a.offset.x&&(c.x=a.offset.x,c.y=a.offset.y),a.offset=c}return a},toJSON:function(){return{_id:this.get("_id"),zoom_level:this.get("zoom_level"),offset:this.get("offset"),title:this.get("title"),description:this.get("description"),created_by:this.get("created_by")?this.get("created_by").get("_id"):null}}}),i=(c.Project=d.extend({type:"project",relations:[{type:b.HasMany,key:"users",relatedModel:e,reverseRelation:{key:"project",includeInJSON:"_id"}},{type:b.HasMany,key:"nodes",relatedModel:f,reverseRelation:{key:"project",includeInJSON:"_id"}},{type:b.HasMany,key:"edges",relatedModel:g,reverseRelation:{key:"project",includeInJSON:"_id"}},{type:b.HasMany,key:"views",relatedModel:h,reverseRelation:{key:"project",includeInJSON:"_id"}}],addUser:function(a,b){a.project=this;var c=e.findOrCreate(a);return this.get("users").push(c,b),c},addNode:function(a,b){a.project=this;var c=f.findOrCreate(a);return this.get("nodes").push(c,b),c},addEdge:function(a,b){a.project=this;var c=g.findOrCreate(a);return this.get("edges").push(c,b),c},addView:function(a,b){a.project=this;var c=h.findOrCreate(a);return this.get("views").push(c,b),c},removeNode:function(a){this.get("nodes").remove(a)},removeEdge:function(a){this.get("edges").remove(a)},validate:function(a){var b=this;_([].concat(a.users,a.nodes,a.edges,a.views)).each(function(a){a&&(a.project=b)})},initialize:function(){var a=this;this.on("remove:nodes",function(b){a.get("edges").remove(a.get("edges").filter(function(a){return a.get("from")===b||a.get("to")===b}))})}}),c.RosterUser=b.Model.extend({type:"roster_user",idAttribute:"_id",constructor:function(a){"undefined"!=typeof a&&(a._id=a._id||a.id||c.getUID(this),a.title=a.title||"(untitled "+this.type+")",a.description=a.description||"",a.uri=a.uri||"",a.project=a.project||null,a.site_id=a.site_id||0,"function"==typeof this.prepare&&(a=this.prepare(a))),b.Model.prototype.constructor.call(this,a)},validate:function(){return this.type?void 0:"object has no type"},prepare:function(a){return a.color=a.color||"#666666",a},toJSON:function(){return{_id:this.get("_id"),title:this.get("title"),uri:this.get("uri"),description:this.get("description"),color:this.get("color"),project:null!=this.get("project")?this.get("project").get("id"):null,site_id:this.get("site_id")}}}));c.UsersList=b.Collection.extend({model:i})}}.call(window),Rkns.defaults={language:navigator.language||navigator.userLanguage||"en",container:"renkan",search:[],bins:[],static_url:"",show_bins:!0,properties:[],show_editor:!0,read_only:!1,editor_mode:!0,manual_save:!1,show_top_bar:!0,default_user_color:"#303030",size_bug_fix:!0,force_resize:!1,allow_double_click:!0,zoom_on_scroll:!0,element_delete_delay:0,autoscale_padding:50,default_view:!1,show_search_field:!0,show_user_list:!0,user_name_editable:!0,user_color_editable:!0,show_save_button:!0,show_export_button:!0,show_open_button:!1,show_addnode_button:!0,show_addedge_button:!0,show_bookmarklet:!0,show_fullscreen_button:!0,home_button_url:!1,home_button_title:"Home",show_minimap:!0,minimap_width:160,minimap_height:120,minimap_padding:20,minimap_background_color:"#ffffff",minimap_border_color:"#cccccc",minimap_highlight_color:"#ffff00",minimap_highlight_weight:5,buttons_background:"#202020",buttons_label_color:"#c000c0",buttons_label_font_size:9,show_node_circles:!0,clip_node_images:!0,node_images_fill_mode:!1,node_size_base:25,node_stroke_width:2,selected_node_stroke_width:4,node_fill_color:"#ffffff",highlighted_node_fill_color:"#ffff00",node_label_distance:5,node_label_max_length:60,label_untitled_nodes:"(untitled)",change_shapes:!0,edge_stroke_width:2,selected_edge_stroke_width:4,edge_label_distance:0,edge_label_max_length:20,edge_arrow_length:18,edge_arrow_width:12,edge_gap_in_bundles:12,label_untitled_edges:"",tooltip_width:275,tooltip_padding:10,tooltip_margin:15,tooltip_arrow_length:20,tooltip_arrow_width:40,tooltip_top_color:"#f0f0f0",tooltip_bottom_color:"#d0d0d0",tooltip_border_color:"#808080",tooltip_border_width:1,show_node_editor_uri:!0,show_node_editor_description:!0,show_node_editor_size:!0,show_node_editor_color:!0,show_node_editor_image:!0,show_node_editor_creator:!0,uploaded_image_max_kb:500,show_node_tooltip_uri:!0,show_node_tooltip_description:!0,show_node_tooltip_color:!0,show_node_tooltip_image:!0,show_node_tooltip_creator:!0,show_edge_editor_uri:!0,show_edge_editor_color:!0,show_edge_editor_direction:!0,show_edge_editor_nodes:!0,show_edge_editor_creator:!0,show_edge_tooltip_uri:!0,show_edge_tooltip_color:!0,show_edge_tooltip_nodes:!0,show_edge_tooltip_creator:!0},Rkns.i18n={fr:{"Edit Node":"Édition d’un nœud","Edit Edge":"Édition d’un lien","Title:":"Titre :","URI:":"URI :","Description:":"Description :","From:":"De :","To:":"Vers :",Image:"Image","Image URL:":"URL d'Image","Choose Image File:":"Choisir un fichier image","Full Screen":"Mode plein écran","Add Node":"Ajouter un nœud","Add Edge":"Ajouter un lien","Save Project":"Enregistrer le projet","Open Project":"Ouvrir un projet","Auto-save enabled":"Enregistrement automatique activé","Connection lost":"Connexion perdue","Created by:":"Créé par :","Zoom In":"Agrandir l’échelle","Zoom Out":"Rapetisser l’échelle",Edit:"Éditer",Remove:"Supprimer","Cancel deletion":"Annuler la suppression","Link to another node":"Créer un lien",Enlarge:"Agrandir",Shrink:"Rétrécir","Click on the background canvas to add a node":"Cliquer sur le fond du graphe pour rajouter un nœud","Click on a first node to start the edge":"Cliquer sur un premier nœud pour commencer le lien","Click on a second node to complete the edge":"Cliquer sur un second nœud pour terminer le lien",Wikipedia:"Wikipédia","Wikipedia in ":"Wikipédia en ",French:"Français",English:"Anglais",Japanese:"Japonais","Untitled project":"Projet sans titre","Lignes de Temps":"Lignes de Temps","Loading, please wait":"Chargement en cours, merci de patienter","Edge color:":"Couleur :","Node color:":"Couleur :","Choose color":"Choisir une couleur","Change edge direction":"Changer le sens du lien","Do you really wish to remove node ":"Voulez-vous réellement supprimer le nœud ","Do you really wish to remove edge ":"Voulez-vous réellement supprimer le lien ","This file is not an image":"Ce fichier n'est pas une image","Image size must be under ":"L'image doit peser moins de ","Size:":"Taille :",KB:"ko","Choose from vocabulary:":"Choisir dans un vocabulaire :","SKOS Documentation properties":"SKOS: Propriétés documentaires","has note":"a pour note","has example":"a pour exemple","has definition":"a pour définition","SKOS Semantic relations":"SKOS: Relations sémantiques","has broader":"a pour concept plus large","has narrower":"a pour concept plus étroit","has related":"a pour concept apparenté","Dublin Core Metadata":"Métadonnées Dublin Core","has contributor":"a pour contributeur",covers:"couvre","created by":"créé par","has date":"a pour date","published by":"édité par","has source":"a pour source","has subject":"a pour sujet","Dragged resource":"Ressource glisée-déposée","Search the Web":"Rechercher en ligne","Search in Bins":"Rechercher dans les chutiers","Close bin":"Fermer le chutier","Refresh bin":"Rafraîchir le chutier","(untitled)":"(sans titre)","Select contents:":"Sélectionner des contenus :","Drag items from this website, drop them in Renkan":"Glissez des éléments de ce site web vers Renkan","Drag this button to your bookmark bar. When on a third-party website, click it to enable drag-and-drop from the website to Renkan.":"Glissez ce bouton vers votre barre de favoris. Ensuite, depuis un site tiers, cliquez dessus pour activer 'Drag-to-Add' puis glissez des éléments de ce site vers Renkan","Shapes available":"Formes disponibles",Circle:"Cercle",Square:"Carré",Diamond:"Losange",Hexagone:"Hexagone",Ellipse:"Ellipse",Star:"Étoile"}},Rkns.jsonIO=function(a,b){var c=a.project;"undefined"==typeof b.http_method&&(b.http_method="PUT");var d=function(){a.renderer.redrawActive=!1,Rkns.$.getJSON(b.url,function(b){c.set(b,{validate:!0}),a.renderer.redrawActive=!0,a.renderer.autoScale()})},e=function(){var d=c.toJSON();a.read_only||Rkns.$.ajax({type:b.http_method,url:b.url,contentType:"application/json",data:JSON.stringify(d),success:function(){}})},f=Rkns._.throttle(function(){setTimeout(e,100)},1e3);c.on("add:nodes add:edges add:users add:views",function(a){a.on("change remove",function(){f()}),f()}),c.on("change",function(){f()}),d()},Rkns.jsonIOSaveOnClick=function(a,b){var c=a.project,d=!1,e=function(){return"Project not saved"};"undefined"==typeof b.http_method&&(b.http_method="POST");var f=function(){var d={},e=/id=([^&#?=]+)/,f=document.location.hash.match(e);f&&(d.id=f[1]),Rkns.$.ajax({url:b.url,data:d,success:function(b){c.set(b,{validate:!0}),a.renderer.autoScale()}})},g=function(){c.set("saved_at",new Date);var a=c.toJSON();Rkns.$.ajax({type:b.http_method,url:b.url,contentType:"application/json",data:JSON.stringify(a),success:function(){$(window).off("beforeunload",e),d=!1}})},h=function(){var a=c.get("title");a&&c.get("nodes").length?$(".Rk-Save-Button").removeClass("disabled"):$(".Rk-Save-Button").addClass("disabled"),a&&$(".Rk-PadTitle").css("border-color","#333333"),d||(d=!0,$(window).on("beforeunload",e))};f(),c.on("add:nodes add:edges add:users change",function(a){a.on("change remove",function(){h()}),h()}),a.renderer.save=function(){$(".Rk-Save-Button").hasClass("disabled")?c.get("title")||$(".Rk-PadTitle").css("border-color","#ff0000"):g()}},function(a){"use strict";var b=a._,c=a.Ldt={},d=(c.Bin=function(a,b){if(b.ldt_type){var d=c[b.ldt_type+"Bin"];if(d)return new d(a,b)}console.error("No such LDT Bin Type")},c.ProjectBin=a.Utils.inherit(a._BaseBin));d.prototype.tagTemplate=b.template('<li class="Rk-Bin-Item" draggable="true" data-image="<%- Rkns.Utils.getFullURL(static_url+\'img/ldt-tag.png\') %>" data-uri="<%=ldt_platform%>ldtplatform/ldt/front/search/?search=<%=encodedtitle%>&field=all" data-title="<%-title%>" data-description="Tag \'<%-title%>\'"><img class="Rk-Ldt-Tag-Icon" src="<%-static_url%>img/ldt-tag.png" /><h4><%=htitle%></h4><div class="Rk-Clear"></div></li>'),d.prototype.annotationTemplate=b.template('<li class="Rk-Bin-Item" draggable="true" data-image="<%- Rkns.Utils.getFullURL(image) %>" data-uri="<%=ldt_platform%>ldtplatform/ldt/front/player/<%=mediaid%>/#id=<%=annotationid%>" data-title="<%-title%>" data-description="<%-description%>"><img class="Rk-Ldt-Annotation-Icon" src="<%=image%>"/><h4><%=htitle%></h4><p><%=hdescription%></p><p>Start: <%=start%>, End: <%=end%>, Duration: <%=duration%></p><div class="Rk-Clear"></div></li>'),d.prototype._init=function(a,b){this.renkan=a,this.proj_id=b.project_id,this.ldt_platform=b.ldt_platform||"http://ldt.iri.centrepompidou.fr/",this.title_$.html(b.title),this.title_icon_$.addClass("Rk-Ldt-Title-Icon"),this.refresh()},d.prototype.render=function(c){function d(a){var c=b(a).escape();return f.isempty?c:f.replace(c,"<span class='searchmatch'>$1</span>")}function e(a){function b(a){for(var b=a.toString();b.length<2;)b="0"+b;return b}var c=Math.abs(Math.floor(a/1e3)),d=Math.floor(c/3600),e=Math.floor(c/60)%60,f=c%60,g="";return d&&(g+=b(d)+":"),g+=b(e)+":"+b(f)}var f=c||a.Utils.regexpFromTextOrArray(),g="<li><h3>Tags</h3></li>",h=this.data.meta["dc:title"],i=this,j=0;i.title_$.text('LDT Project: "'+h+'"'),b(i.data.tags).map(function(a){var b=a.meta["dc:title"];(f.isempty||f.test(b))&&(j++,g+=i.tagTemplate({ldt_platform:i.ldt_platform,title:b,htitle:d(b),encodedtitle:encodeURIComponent(b),static_url:i.renkan.options.static_url}))}),g+="<li><h3>Annotations</h3></li>",b(i.data.annotations).map(function(a){var b=a.content.description,c=a.content.title.replace(b,"");if(f.isempty||f.test(c)||f.test(b)){j++;var h=a.end-a.begin,k=a.content&&a.content.img&&a.content.img.src?a.content.img.src:h?i.renkan.options.static_url+"img/ldt-segment.png":i.renkan.options.static_url+"img/ldt-point.png";g+=i.annotationTemplate({ldt_platform:i.ldt_platform,title:c,htitle:d(c),description:b,hdescription:d(b),start:e(a.begin),end:e(a.end),duration:e(h),mediaid:a.media,annotationid:a.id,image:k,static_url:i.renkan.options.static_url})}}),this.main_$.html(g),!f.isempty&&j?this.count_$.text(j).show():this.count_$.hide(),f.isempty||j?this.$.show():this.$.hide(),this.renkan.resizeBins()},d.prototype.refresh=function(){var b=this;a.$.ajax({url:this.ldt_platform+"ldtplatform/ldt/cljson/id/"+this.proj_id,dataType:"jsonp",success:function(a){b.data=a,b.render()}})};var e=c.Search=function(a,b){this.renkan=a,this.lang=b.lang||"en"};e.prototype.getBgClass=function(){return"Rk-Ldt-Icon"},e.prototype.getSearchTitle=function(){return this.renkan.translate("Lignes de Temps")},e.prototype.search=function(a){this.renkan.tabs.push(new f(this.renkan,{search:a}))};var f=c.ResultsBin=a.Utils.inherit(a._BaseBin);f.prototype.segmentTemplate=b.template('<li class="Rk-Bin-Item" draggable="true" data-image="<%- Rkns.Utils.getFullURL(image) %>" data-uri="<%=ldt_platform%>ldtplatform/ldt/front/player/<%=mediaid%>/#id=<%=annotationid%>" data-title="<%-title%>" data-description="<%-description%>"><img class="Rk-Ldt-Annotation-Icon" src="<%=image%>"/><h4><%=htitle%></h4><p><%=hdescription%></p><p>Start: <%=start%>, End: <%=end%>, Duration: <%=duration%></p><div class="Rk-Clear"></div></li>'),f.prototype._init=function(a,b){this.renkan=a,this.ldt_platform=b.ldt_platform||"http://ldt.iri.centrepompidou.fr/",this.max_results=b.max_results||50,this.search=b.search,this.title_$.html('Lignes de Temps: "'+b.search+'"'),this.title_icon_$.addClass("Rk-Ldt-Title-Icon"),this.refresh()},f.prototype.render=function(c){function d(a){return g.replace(b(a).escape(),"<span class='searchmatch'>$1</span>")}function e(a){function b(a){for(var b=a.toString();b.length<2;)b="0"+b;return b}var c=Math.abs(Math.floor(a/1e3)),d=Math.floor(c/3600),e=Math.floor(c/60)%60,f=c%60,g="";return d&&(g+=b(d)+":"),g+=b(e)+":"+b(f)}if(this.data){var f=c||a.Utils.regexpFromTextOrArray(),g=f.isempty?a.Utils.regexpFromTextOrArray(this.search):f,h="",i=this,j=0;b(this.data.objects).each(function(a){var b=a.abstract,c=a.title;if(f.isempty||f.test(c)||f.test(b)){j++;var g=a.duration,k=a.start_ts,l=+a.duration+k,m=g?i.renkan.options.static_url+"img/ldt-segment.png":i.renkan.options.static_url+"img/ldt-point.png";h+=i.segmentTemplate({ldt_platform:i.ldt_platform,title:c,htitle:d(c),description:b,hdescription:d(b),start:e(k),end:e(l),duration:e(g),mediaid:a.iri_id,annotationid:a.element_id,image:m})}}),this.main_$.html(h),!f.isempty&&j?this.count_$.text(j).show():this.count_$.hide(),f.isempty||j?this.$.show():this.$.hide(),this.renkan.resizeBins()}},f.prototype.refresh=function(){var b=this;a.$.ajax({url:this.ldt_platform+"ldtplatform/api/ldt/1.0/segments/search/",data:{format:"jsonp",q:this.search,limit:this.max_results},dataType:"jsonp",success:function(a){b.data=a,b.render()}})}}(window.Rkns),Rkns.ResourceList={},Rkns.ResourceList.Bin=Rkns.Utils.inherit(Rkns._BaseBin),Rkns.ResourceList.Bin.prototype.resultTemplate=Rkns._.template('<li class="Rk-Bin-Item Rk-ResourceList-Item" draggable="true" data-uri="<%-url%>" data-title="<%-title%>" data-description="<%-description%>" <% if (image) { %>data-image="<%- Rkns.Utils.getFullURL(image) %>"<% } else { %>data-image=""<% } %> ><% if (image) { %><img class="Rk-ResourceList-Image" src="<%-image%>"/><% } %><h4 class="Rk-ResourceList-Title"><% if (url) { %><a href="<%-url%>" target="_blank"><% } %><%=htitle%><% if (url) { %></a><% } %></h4><% if (description) { %><p class="Rk-ResourceList-Description"><%=hdescription%></p><% } %><% if (image) { %><div style="clear: both;"></div><% } %></li>'),Rkns.ResourceList.Bin.prototype._init=function(a,b){this.renkan=a,this.title_$.html(b.title),b.list&&(this.data=b.list),this.refresh()},Rkns.ResourceList.Bin.prototype.render=function(a){function b(a){var b=_(a).escape();return c.isempty?b:c.replace(b,"<span class='searchmatch'>$1</span>")}var c=a||Rkns.Utils.regexpFromTextOrArray(),d="",e=this,f=0;Rkns._(this.data).each(function(a){var g;if("string"==typeof a)if(/^(https?:\/\/|www)/.test(a))g={url:a};else{g={title:a.replace(/[:,]?\s?(https?:\/\/|www)[\d\w\/.&?=#%-_]+\s?/,"").trim()};var h=a.match(/(https?:\/\/|www)[\d\w\/.&?=#%-_]+/);h&&(g.url=h[0]),g.title.length>80&&(g.description=g.title,g.title=g.title.replace(/^(.{30,60})\s.+$/,"$1…"))}else g=a;var i=g.title||(g.url||"").replace(/^https?:\/\/(www\.)?/,"").replace(/^(.{40}).+$/,"$1…"),j=g.url||"",k=g.description||"",l=g.image||"";j&&!/^https?:\/\//.test(j)&&(j="http://"+j),(c.isempty||c.test(i)||c.test(k))&&(f++,d+=e.resultTemplate({url:j,title:i,htitle:b(i),image:l,description:k,hdescription:b(k),static_url:e.renkan.options.static_url}))
-}),e.main_$.html(d),!c.isempty&&f?this.count_$.text(f).show():this.count_$.hide(),c.isempty||f?this.$.show():this.$.hide(),this.renkan.resizeBins()},Rkns.ResourceList.Bin.prototype.refresh=function(){this.data&&this.render()},Rkns.Wikipedia={},Rkns.Wikipedia.Search=function(a,b){this.renkan=a,this.lang=b.lang||"en"},Rkns.Wikipedia.Search.prototype.getBgClass=function(){return"Rk-Wikipedia-Search-Icon Rk-Wikipedia-Lang-"+this.lang},Rkns.Wikipedia.Search.prototype.getSearchTitle=function(){var a={fr:"French",en:"English",ja:"Japanese"};return a[this.lang]?this.renkan.translate("Wikipedia in ")+this.renkan.translate(a[this.lang]):this.renkan.translate("Wikipedia")+" ["+this.lang+"]"},Rkns.Wikipedia.Search.prototype.search=function(a){this.renkan.tabs.push(new Rkns.Wikipedia.Bin(this.renkan,{lang:this.lang,search:a}))},Rkns.Wikipedia.Bin=Rkns.Utils.inherit(Rkns._BaseBin),Rkns.Wikipedia.Bin.prototype.resultTemplate=Rkns._.template('<li class="Rk-Wikipedia-Result Rk-Bin-Item" draggable="true" data-uri="<%-url%>" data-title="Wikipedia: <%-title%>" data-description="<%-description%>" data-image="<%- Rkns.Utils.getFullURL( static_url + \'img/wikipedia.png\' ) %>"><img class="Rk-Wikipedia-Icon" src="<%-static_url%>img/wikipedia.png"></div><h4 class="Rk-Wikipedia-Title"><a href="<%-url%>" target="_blank"><%=htitle%></a></h4><p class="Rk-Wikipedia-Snippet"><%=hdescription%></p></li>'),Rkns.Wikipedia.Bin.prototype._init=function(a,b){this.renkan=a,this.search=b.search,this.lang=b.lang||"en",this.title_icon_$.addClass("Rk-Wikipedia-Title-Icon Rk-Wikipedia-Lang-"+this.lang),this.title_$.html(this.search).addClass("Rk-Wikipedia-Title"),this.refresh()},Rkns.Wikipedia.Bin.prototype.render=function(a){function b(a){return d.replace(_(a).escape(),"<span class='searchmatch'>$1</span>")}var c=a||Rkns.Utils.regexpFromTextOrArray(),d=c.isempty?Rkns.Utils.regexpFromTextOrArray(this.search):c,e="",f=this,g=0;Rkns._(this.data.query.search).each(function(a){var d=a.title,h="http://"+f.lang+".wikipedia.org/wiki/"+encodeURI(d.replace(/ /g,"_")),i=Rkns.$("<div>").html(a.snippet).text();(c.isempty||c.test(d)||c.test(i))&&(g++,e+=f.resultTemplate({url:h,title:d,htitle:b(d),description:i,hdescription:b(i),static_url:f.renkan.options.static_url}))}),f.main_$.html(e),!c.isempty&&g?this.count_$.text(g).show():this.count_$.hide(),c.isempty||g?this.$.show():this.$.hide(),this.renkan.resizeBins()},Rkns.Wikipedia.Bin.prototype.refresh=function(){var a=this;Rkns.$.ajax({url:"http://"+a.lang+".wikipedia.org/w/api.php?action=query&list=search&srsearch="+encodeURIComponent(this.search)+"&format=json",dataType:"jsonp",success:function(b){a.data=b,a.render()}})},define("renderer/baserepresentation",["jquery","underscore"],function(a,b){var c=function(a,c){if("undefined"!=typeof a&&(this.renderer=a,this.renkan=a.renkan,this.project=a.renkan.project,this.options=a.renkan.options,this.model=c,this.model)){var d=this;this._changeBinding=function(){d.redraw()},this._removeBinding=function(){a.removeRepresentation(d),b(function(){a.redraw()}).defer()},this._selectBinding=function(){d.select()},this._unselectBinding=function(){d.unselect()},this.model.on("change",this._changeBinding),this.model.on("remove",this._removeBinding),this.model.on("select",this._selectBinding),this.model.on("unselect",this._unselectBinding)}};return b(c.prototype).extend({_super:function(a){return c.prototype[a].apply(this,Array.prototype.slice.call(arguments,1))},redraw:function(){},moveTo:function(){},show:function(){return"chaud cacao"},hide:function(){},select:function(){this.model&&this.model.trigger("selected")},unselect:function(){this.model&&this.model.trigger("unselected")},highlight:function(){},unhighlight:function(){},mousedown:function(){},mouseup:function(){this.model&&this.model.trigger("clicked")},destroy:function(){this.model&&(this.model.off("change",this._changeBinding),this.model.off("remove",this._removeBinding),this.model.off("select",this._selectBinding),this.model.off("unselect",this._unselectBinding))}}),c}),define("requtils",[],function(){return{getUtils:function(){return window.Rkns.Utils},getRenderer:function(){return window.Rkns.Renderer}}}),define("renderer/basebutton",["jquery","underscore","requtils","renderer/baserepresentation"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({moveTo:function(a){this.sector.moveTo(a)},show:function(){this.sector.show()},hide:function(){this.sector.hide()},select:function(){this.sector.select()},unselect:function(a){this.sector.unselect(),(!a||a!==this.source_representation&&a.source_representation!==this.source_representation)&&this.source_representation.unselect()},destroy:function(){this.sector.destroy()}}),f}),define("renderer/shapebuilder",[],function(){var a={circle:{getShape:function(){return new paper.Path.Circle([0,0],1)},getImageShape:function(a,b){return new paper.Path.Circle(a,b)}},rectangle:{getShape:function(){return new paper.Path.Rectangle([-2,-2],[2,2])},getImageShape:function(a,b){return new paper.Path.Rectangle([-b,-b],[2*b,2*b])}},ellipse:{getShape:function(){return new paper.Path.Ellipse(new paper.Rectangle([-2,-1],[2,1]))},getImageShape:function(a,b){return new paper.Path.Ellipse(new paper.Rectangle([-b,-b/2],[2*b,b]))}},polygon:{getShape:function(){return new paper.Path.RegularPolygon([0,0],6,1)},getImageShape:function(a,b){return new paper.Path.RegularPolygon([0,0],6,b)}},diamond:{getShape:function(){var a=new paper.Path.Rectangle([-2,-2],[2,2]);return a.rotate(45),a},getImageShape:function(a,b){var c=new paper.Path.Rectangle([-b,-b],[2*b,2*b]);return c.rotate(45),c}},star:{getShape:function(){return new paper.Path.Star([0,0],8,1,.7)},getImageShape:function(a,b){return new paper.Path.Star([0,0],8,1*b,.7*b)}},svg:function(a){return{getShape:function(){return new paper.Path(a)},getImageShape:function(){return new paper.Path}}}},b=function(b){return"undefined"==typeof b&&(b="circle"),"svg:"===b.substr(0,4)?a.svg(b.substr(4)):(b in a||(b="circle"),a[b])};return b}),define("renderer/noderepr",["jquery","underscore","requtils","renderer/baserepresentation","renderer/shapebuilder"],function(a,b,c,d,e){var f=c.getUtils(),g=f.inherit(d);return b(g.prototype).extend({_init:function(){if(this.renderer.node_layer.activate(),this.type="Node",this.buildShape(),this.options.show_node_circles?(this.circle.strokeWidth=this.options.node_stroke_width,this.h_ratio=1):this.h_ratio=0,this.title=a('<div class="Rk-Label">').appendTo(this.renderer.labels_$),this.options.editor_mode){var b=c.getRenderer();this.normal_buttons=[new b.NodeEditButton(this.renderer,null),new b.NodeRemoveButton(this.renderer,null),new b.NodeLinkButton(this.renderer,null),new b.NodeEnlargeButton(this.renderer,null),new b.NodeShrinkButton(this.renderer,null)],this.pending_delete_buttons=[new b.NodeRevertButton(this.renderer,null)],this.all_buttons=this.normal_buttons.concat(this.pending_delete_buttons);for(var d=0;d<this.all_buttons.length;d++)this.all_buttons[d].source_representation=this;this.active_buttons=[]}else this.active_buttons=this.all_buttons=[];this.last_circle_radius=1,this.renderer.minimap&&(this.renderer.minimap.node_layer.activate(),this.minimap_circle=new paper.Path.Circle([0,0],1),this.minimap_circle.__representation=this.renderer.minimap.miniframe.__representation,this.renderer.minimap.node_group.addChild(this.minimap_circle))},buildShape:function(){"undefined"!=typeof this.model.get("shape_changed")&&this.model.get("shape_changed")===!0&&(this.model.set("shape_changed",!1),delete this.img),this.circle&&(this.circle.remove(),delete this.circle),this.shapeBuilder=new e(this.model.get("shape")),this.circle=this.shapeBuilder.getShape(),this.circle.__representation=this,this.last_circle_radius=1},redraw:function(a){"undefined"!=typeof this.model.get("shape_changed")&&this.model.get("shape_changed")===!0&&this.buildShape();var c=new paper.Point(this.model.get("position")),d=this.options.node_size_base*Math.exp((this.model.get("size")||0)*f._NODE_SIZE_STEP);this.is_dragging&&this.paper_coords||(this.paper_coords=this.renderer.toPaperCoords(c)),this.circle_radius=d*this.renderer.scale,this.last_circle_radius!==this.circle_radius&&(this.all_buttons.forEach(function(a){a.setSectorSize()}),this.circle.scale(this.circle_radius/this.last_circle_radius),this.node_image&&this.node_image.scale(this.circle_radius/this.last_circle_radius)),this.circle.position=this.paper_coords,this.node_image&&(this.node_image.position=this.paper_coords.subtract(this.image_delta.multiply(this.circle_radius))),this.last_circle_radius=this.circle_radius;var e=this.active_buttons,g=1;this.model.get("delete_scheduled")?(g=.5,this.active_buttons=this.pending_delete_buttons,this.circle.dashArray=[2,2]):(g=1,this.active_buttons=this.normal_buttons,this.circle.dashArray=null),this.selected&&this.renderer.isEditable()&&(e!==this.active_buttons&&e.forEach(function(a){a.hide()}),this.active_buttons.forEach(function(a){a.show()})),this.node_image&&(this.node_image.opacity=this.highlighted?.5*g:g-.01),this.circle.fillColor=this.highlighted?this.options.highlighted_node_fill_color:this.options.node_fill_color,this.circle.opacity=this.options.show_node_circles?g:.01;var h=this.model.get("title")||this.renkan.translate(this.options.label_untitled_nodes)||"";h=f.shortenText(h,this.options.node_label_max_length),"object"==typeof this.highlighted?this.title.html(this.highlighted.replace(b(h).escape(),'<span class="Rk-Highlighted">$1</span>')):this.title.text(h),this.title.css({left:this.paper_coords.x,top:this.paper_coords.y+this.circle_radius*this.h_ratio+this.options.node_label_distance,opacity:g});var i=this.model.get("color")||(this.model.get("created_by")||f._USER_PLACEHOLDER(this.renkan)).get("color");this.circle.strokeColor=i;var j=this.paper_coords;this.all_buttons.forEach(function(a){a.moveTo(j)});var k=this.img;if(this.img=this.model.get("image"),this.img&&this.img!==k&&this.showImage(),this.node_image&&!this.img&&(this.node_image.remove(),delete this.node_image),this.renderer.minimap){this.minimap_circle.fillColor=i;var l=this.renderer.toMinimapCoords(c),m=this.renderer.minimap.scale*d,n=new paper.Size([m,m]);this.minimap_circle.fitBounds(l.subtract(n),n.multiply(2))}if(!a){var o=this;b.each(this.project.get("edges").filter(function(a){return a.get("to")===o.model||a.get("from")===o.model}),function(a){var b=o.renderer.getRepresentationByModel(a);b&&"undefined"!=typeof b.from_representation&&"undefined"!=typeof b.from_representation.paper_coords&&"undefined"!=typeof b.to_representation&&"undefined"!=typeof b.to_representation.paper_coords&&b.redraw()})}},showImage:function(){var b=null;if("undefined"==typeof this.renderer.image_cache[this.img]?(b=new Image,this.renderer.image_cache[this.img]=b,b.src=this.img):b=this.renderer.image_cache[this.img],b.width){this.node_image&&this.node_image.remove(),this.renderer.node_layer.activate();var c=b.width,d=b.height,e=this.model.get("clip_path"),f="undefined"!=typeof e&&e,g=null,h=null,i=null;if(f){g=new paper.Path;var j=e.match(/[a-z][^a-z]+/gi)||[],k=[0,0],l=1/0,m=1/0,n=-1/0,o=-1/0,p=function(a,b){var e=a.slice(1).map(function(a,e){var f=parseFloat(a),g=e%2;return f=g?(f-.5)*d:(f-.5)*c,b&&(f+=k[g]),g?(m=Math.min(m,f),o=Math.max(o,f)):(l=Math.min(l,f),n=Math.max(n,f)),f});return k=e.slice(-2),e};j.forEach(function(a){var b=a.match(/([a-z]|[0-9.-]+)/gi)||[""];switch(b[0]){case"M":g.moveTo(p(b));break;case"m":g.moveTo(p(b,!0));break;case"L":g.lineTo(p(b));break;case"l":g.lineTo(p(b,!0));break;case"C":g.cubicCurveTo(p(b));break;case"c":g.cubicCurveTo(p(b,!0));break;case"Q":g.quadraticCurveTo(p(b));break;case"q":g.quadraticCurveTo(p(b,!0))}}),h=Math[this.options.node_images_fill_mode?"min":"max"](n-l,o-m)/2,i=new paper.Point((n+l)/2,(o+m)/2),this.options.show_node_circles||(this.h_ratio=(o-m)/(2*h))}else h=Math[this.options.node_images_fill_mode?"min":"max"](c,d)/2,i=new paper.Point(0,0),this.options.show_node_circles||(this.h_ratio=d/(2*h));var q=new paper.Raster(b);if(q.locked=!0,f&&(q=new paper.Group(g,q),q.opacity=.99,q.clipped=!0,g.__representation=this),this.options.clip_node_images){var r=this.shapeBuilder.getImageShape(i,h);q=new paper.Group(r,q),q.opacity=.99,q.clipped=!0,r.__representation=this}this.image_delta=i.divide(h),this.node_image=q,this.node_image.__representation=s,this.node_image.scale(this.circle_radius/h),this.node_image.position=this.paper_coords.subtract(this.image_delta.multiply(this.circle_radius)),this.redraw(),this.renderer.throttledPaperDraw()}else{var s=this;a(b).on("load",function(){s.showImage()})}},paperShift:function(a){this.options.editor_mode?this.renkan.read_only||(this.is_dragging=!0,this.paper_coords=this.paper_coords.add(a),this.redraw()):this.renderer.paperShift(a)},openEditor:function(){this.renderer.removeRepresentationsOfType("editor");var a=this.renderer.addRepresentation("NodeEditor",null);a.source_representation=this,a.draw()},select:function(){this.selected=!0,this.circle.strokeWidth=this.options.selected_node_stroke_width,this.renderer.isEditable()&&this.active_buttons.forEach(function(a){a.show()});var b=this.model.get("uri");b&&a(".Rk-Bin-Item").each(function(){var c=a(this);c.attr("data-uri")===b&&c.addClass("selected")}),this.options.editor_mode||this.openEditor(),this.renderer.minimap&&(this.minimap_circle.strokeWidth=this.options.minimap_highlight_weight,this.minimap_circle.strokeColor=this.options.minimap_highlight_color),this._super("select")},unselect:function(b){b&&b.source_representation===this||(this.selected=!1,this.all_buttons.forEach(function(a){a.hide()}),this.circle.strokeWidth=this.options.node_stroke_width,a(".Rk-Bin-Item").removeClass("selected"),this.renderer.minimap&&(this.minimap_circle.strokeColor=void 0),this._super("unselect"))},highlight:function(a){var b=a||!0;this.highlighted!==b&&(this.highlighted=b,this.redraw(),this.renderer.throttledPaperDraw())},unhighlight:function(){this.highlighted&&(this.highlighted=!1,this.redraw(),this.renderer.throttledPaperDraw())},saveCoords:function(){var a=this.renderer.toModelCoords(this.paper_coords),b={position:{x:a.x,y:a.y}};this.renderer.isEditable()&&this.model.set(b)},mousedown:function(a,b){b&&(this.renderer.unselectAll(),this.select())},mouseup:function(a,b){this.renderer.is_dragging&&this.renderer.isEditable()?this.saveCoords():(b||this.model.get("delete_scheduled")||this.openEditor(),this.model.trigger("clicked")),this.renderer.click_target=null,this.renderer.is_dragging=!1,this.is_dragging=!1},destroy:function(){this._super("destroy"),this.all_buttons.forEach(function(a){a.destroy()}),this.circle.remove(),this.title.remove(),this.renderer.minimap&&this.minimap_circle.remove(),this.node_image&&this.node_image.remove()}}),g}),define("renderer/edge",["jquery","underscore","requtils","renderer/baserepresentation"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({_init:function(){if(this.renderer.edge_layer.activate(),this.type="Edge",this.from_representation=this.renderer.getRepresentationByModel(this.model.get("from")),this.to_representation=this.renderer.getRepresentationByModel(this.model.get("to")),this.bundle=this.renderer.addToBundles(this),this.line=new paper.Path,this.line.add([0,0],[0,0],[0,0]),this.line.__representation=this,this.line.strokeWidth=this.options.edge_stroke_width,this.arrow=new paper.Path,this.arrow.add([0,0],[this.options.edge_arrow_length,this.options.edge_arrow_width/2],[0,this.options.edge_arrow_width]),this.arrow.__representation=this,this.text=a('<div class="Rk-Label Rk-Edge-Label">').appendTo(this.renderer.labels_$),this.arrow_angle=0,this.options.editor_mode){var b=c.getRenderer();this.normal_buttons=[new b.EdgeEditButton(this.renderer,null),new b.EdgeRemoveButton(this.renderer,null)],this.pending_delete_buttons=[new b.EdgeRevertButton(this.renderer,null)],this.all_buttons=this.normal_buttons.concat(this.pending_delete_buttons);for(var d=0;d<this.all_buttons.length;d++)this.all_buttons[d].source_representation=this;this.active_buttons=[]}else this.active_buttons=this.all_buttons=[];this.renderer.minimap&&(this.renderer.minimap.edge_layer.activate(),this.minimap_line=new paper.Path,this.minimap_line.add([0,0],[0,0]),this.minimap_line.__representation=this.renderer.minimap.miniframe.__representation,this.minimap_line.strokeWidth=1)},redraw:function(){var a=this.model.get("from"),b=this.model.get("to");if(a&&b&&(this.from_representation=this.renderer.getRepresentationByModel(a),this.to_representation=this.renderer.getRepresentationByModel(b),"undefined"!=typeof this.from_representation&&"undefined"!=typeof this.to_representation)){var c=this.from_representation.paper_coords,d=this.to_representation.paper_coords,f=d.subtract(c),g=f.length,h=f.divide(g),i=new paper.Point([-h.y,h.x]),j=this.bundle.getPosition(this),k=i.multiply(this.options.edge_gap_in_bundles*j),l=c.add(k),m=d.add(k),n=f.angle,o=i.multiply(this.options.edge_label_distance),p=f.divide(3),q=this.model.get("color")||this.model.get("color")||(this.model.get("created_by")||e._USER_PLACEHOLDER(this.renkan)).get("color"),r=1;this.model.get("delete_scheduled")||this.from_representation.model.get("delete_scheduled")||this.to_representation.model.get("delete_scheduled")?(r=.5,this.line.dashArray=[2,2]):(r=1,this.line.dashArray=null);var s=this.active_buttons;this.active_buttons=this.model.get("delete_scheduled")?this.pending_delete_buttons:this.normal_buttons,this.selected&&this.renderer.isEditable()&&s!==this.active_buttons&&(s.forEach(function(a){a.hide()}),this.active_buttons.forEach(function(a){a.show()})),this.paper_coords=l.add(m).divide(2),this.line.strokeColor=q,this.line.opacity=r,this.line.segments[0].point=c,this.line.segments[1].point=this.paper_coords,this.line.segments[1].handleIn=p.multiply(-1),this.line.segments[1].handleOut=p,this.line.segments[2].point=d,this.arrow.rotate(n-this.arrow_angle),this.arrow.fillColor=q,this.arrow.opacity=r,this.arrow.position=this.paper_coords,this.arrow_angle=n,n>90&&(n-=180,o=o.multiply(-1)),-90>n&&(n+=180,o=o.multiply(-1));var t=this.model.get("title")||this.renkan.translate(this.options.label_untitled_edges)||"";t=e.shortenText(t,this.options.node_label_max_length),this.text.text(t);var u=this.paper_coords.add(o);this.text.css({left:u.x,top:u.y,transform:"rotate("+n+"deg)","-moz-transform":"rotate("+n+"deg)","-webkit-transform":"rotate("+n+"deg)",opacity:r}),this.text_angle=n;var v=this.paper_coords;this.all_buttons.forEach(function(a){a.moveTo(v)}),this.renderer.minimap&&(this.minimap_line.strokeColor=q,this.minimap_line.segments[0].point=this.renderer.toMinimapCoords(new paper.Point(this.from_representation.model.get("position"))),this.minimap_line.segments[1].point=this.renderer.toMinimapCoords(new paper.Point(this.to_representation.model.get("position"))))}},openEditor:function(){this.renderer.removeRepresentationsOfType("editor");var a=this.renderer.addRepresentation("EdgeEditor",null);a.source_representation=this,a.draw()},select:function(){this.selected=!0,this.line.strokeWidth=this.options.selected_edge_stroke_width,this.renderer.isEditable()&&this.active_buttons.forEach(function(a){a.show()}),this.options.editor_mode||this.openEditor(),this._super("select")},unselect:function(a){a&&a.source_representation===this||(this.selected=!1,this.options.editor_mode&&this.all_buttons.forEach(function(a){a.hide()}),this.line.strokeWidth=this.options.edge_stroke_width,this._super("unselect"))},mousedown:function(a,b){b&&(this.renderer.unselectAll(),this.select())},mouseup:function(a,b){!this.renkan.read_only&&this.renderer.is_dragging?(this.from_representation.saveCoords(),this.to_representation.saveCoords(),this.from_representation.is_dragging=!1,this.to_representation.is_dragging=!1):(b||this.openEditor(),this.model.trigger("clicked")),this.renderer.click_target=null,this.renderer.is_dragging=!1},paperShift:function(a){this.options.editor_mode?this.options.read_only||(this.from_representation.paperShift(a),this.to_representation.paperShift(a)):this.renderer.paperShift(a)},destroy:function(){this._super("destroy"),this.line.remove(),this.arrow.remove(),this.text.remove(),this.renderer.minimap&&this.minimap_line.remove(),this.all_buttons.forEach(function(a){a.destroy()});var a=this;this.bundle.edges=b(this.bundle.edges).reject(function(b){return a===b})}}),f}),define("renderer/tempedge",["jquery","underscore","requtils","renderer/baserepresentation"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({_init:function(){this.renderer.edge_layer.activate(),this.type="Temp-edge";var a=(this.project.get("users").get(this.renkan.current_user)||e._USER_PLACEHOLDER(this.renkan)).get("color");this.line=new paper.Path,this.line.strokeColor=a,this.line.dashArray=[4,2],this.line.strokeWidth=this.options.selected_edge_stroke_width,this.line.add([0,0],[0,0]),this.line.__representation=this,this.arrow=new paper.Path,this.arrow.fillColor=a,this.arrow.add([0,0],[this.options.edge_arrow_length,this.options.edge_arrow_width/2],[0,this.options.edge_arrow_width]),this.arrow.__representation=this,this.arrow_angle=0},redraw:function(){var a=this.from_representation.paper_coords,b=this.end_pos,c=b.subtract(a).angle,d=a.add(b).divide(2);this.line.segments[0].point=a,this.line.segments[1].point=b,this.arrow.rotate(c-this.arrow_angle),this.arrow.position=d,this.arrow_angle=c},paperShift:function(a){if(!this.renderer.isEditable())return this.renderer.removeRepresentation(_this),void paper.view.draw();this.end_pos=this.end_pos.add(a);var b=paper.project.hitTest(this.end_pos);this.renderer.findTarget(b),this.redraw()},mouseup:function(a){var b=paper.project.hitTest(a.point),c=this.from_representation.model,d=!0;if(b&&"undefined"!=typeof b.item.__representation){var f=b.item.__representation;if("Node"===f.type.substr(0,4)){var g=f.model||f.source_representation.model;if(c!==g){var h={id:e.getUID("edge"),created_by:this.renkan.current_user,from:c,to:g};this.renderer.isEditable()&&this.project.addEdge(h)}}(c===f.model||f.source_representation&&f.source_representation.model===c)&&(d=!1,this.renderer.is_dragging=!0)}d&&(this.renderer.click_target=null,this.renderer.is_dragging=!1,this.renderer.removeRepresentation(this),paper.view.draw())},destroy:function(){this.arrow.remove(),this.line.remove()}}),f}),define("renderer/baseeditor",["jquery","underscore","requtils","renderer/baserepresentation"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({_init:function(){this.renderer.buttons_layer.activate(),this.type="editor",this.editor_block=new paper.Path;var c=b(b.range(8)).map(function(){return[0,0]});this.editor_block.add.apply(this.editor_block,c),this.editor_block.strokeWidth=this.options.tooltip_border_width,this.editor_block.strokeColor=this.options.tooltip_border_color,this.editor_block.opacity=.8,this.editor_$=a("<div>").appendTo(this.renderer.editor_$).css({position:"absolute",opacity:.8}).hide()},destroy:function(){this.editor_block.remove(),this.editor_$.remove()}}),f}),define("renderer/nodeeditor",["jquery","underscore","requtils","renderer/baseeditor"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({template:b.template('<h2><span class="Rk-CloseX">×</span><%-renkan.translate("Edit Node")%></span></h2><p><label><%-renkan.translate("Title:")%></label><input class="Rk-Edit-Title" type="text" value="<%-node.title%>"/></p><% if (options.show_node_editor_uri) { %><p><label><%-renkan.translate("URI:")%></label><input class="Rk-Edit-URI" type="text" value="<%-node.uri%>"/><a class="Rk-Edit-Goto" href="<%-node.uri%>" target="_blank"></a></p><% } %><% if (options.show_node_editor_description) { %><p><label><%-renkan.translate("Description:")%></label><textarea class="Rk-Edit-Description"><%-node.description%></textarea></p><% } %><% if (options.show_node_editor_size) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Size:")%></span><a href="#" class="Rk-Edit-Size-Down">-</a><span class="Rk-Edit-Size-Value"><%-node.size%></span><a href="#" class="Rk-Edit-Size-Up">+</a></p><% } %><% if (options.show_node_editor_color) { %><div class="Rk-Editor-p"><span class="Rk-Editor-Label"><%-renkan.translate("Node color:")%></span><div class="Rk-Edit-ColorPicker-Wrapper"><span class="Rk-Edit-Color" style="background:<%-node.color%>;"><span class="Rk-Edit-ColorTip"></span></span><%= renkan.colorPicker %><span class="Rk-Edit-ColorPicker-Text"><%- renkan.translate("Choose color") %></span></div></div><% } %><% if (options.show_node_editor_image) { %><div class="Rk-Edit-ImgWrap"><div class="Rk-Edit-ImgPreview"><img src="<%-node.image || node.image_placeholder%>" /><% if (node.clip_path) { %><svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewbox="0 0 1 1" preserveAspectRatio="none"><path style="stroke-width: .02; stroke:red; fill-opacity:.3; fill:red;" d="<%- node.clip_path %>"/></svg><% }%></div></div><p><label><%-renkan.translate("Image URL:")%></label><input class="Rk-Edit-Image" type="text" value="<%-node.image%>"/></p><p><label><%-renkan.translate("Choose Image File:")%></label><input class="Rk-Edit-Image-File" type="file" accept="image/*"/></p><% } %><% if (options.show_node_editor_creator && node.has_creator) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Created by:")%></span> <span class="Rk-UserColor" style="background:<%-node.created_by_color%>;"></span><%- shortenText(node.created_by_title, 25) %></p><% } %><% if (options.change_shapes) { %><p><label><%-renkan.translate("Shapes available")%>:</label> <select class="Rk-Edit-Shape"><option class="Rk-Edit-Vocabulary-Property" value="circle"<% if (node.shape === "circle") { %> selected<% } %>><%- renkan.translate("Circle") %></option><option class="Rk-Edit-Vocabulary-Property" value="rectangle"<% if (node.shape === "rectangle") { %> selected<% } %>><%- renkan.translate("Square") %></option><option class="Rk-Edit-Vocabulary-Property" value="diamond"<% if (node.shape === "diamond") { %> selected<% } %>><%- renkan.translate("Diamond") %></option><option class="Rk-Edit-Vocabulary-Property" value="polygon"<% if (node.shape === "polygon") { %> selected<% } %>><%- renkan.translate("Hexagone") %></option><option class="Rk-Edit-Vocabulary-Property" value="ellipse"<% if (node.shape === "ellipse") { %> selected<% } %>><%- renkan.translate("Ellipse") %></option><option class="Rk-Edit-Vocabulary-Property" value="star"<% if (node.shape === "star") { %> selected<% } %>><%- renkan.translate("Star") %></option></select></p><% } %>'),readOnlyTemplate:b.template('<h2><span class="Rk-CloseX">×</span><% if (options.show_node_tooltip_color) { %><span class="Rk-UserColor" style="background:<%-node.color%>;"></span><% } %><span class="Rk-Display-Title"><% if (node.uri) { %><a href="<%-node.uri%>" target="_blank"><% } %><%-node.title%><% if (node.uri) { %></a><% } %></span></h2><% if (node.uri && options.show_node_tooltip_uri) { %><p class="Rk-Display-URI"><a href="<%-node.uri%>" target="_blank"><%-node.short_uri%></a></p><% } %><% if (options.show_node_tooltip_description) { %><p class="Rk-Display-Description"><%-node.description%></p><% } %><% if (node.image && options.show_node_tooltip_image) { %><img class="Rk-Display-ImgPreview" src="<%-node.image%>" /><% } %><% if (node.has_creator && options.show_node_tooltip_creator) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Created by:")%></span><span class="Rk-UserColor" style="background:<%-node.created_by_color%>;"></span><%- shortenText(node.created_by_title, 25) %></p><% } %>'),draw:function(){var c=this.source_representation.model,d=c.get("created_by")||e._USER_PLACEHOLDER(this.renkan),f=this.renderer.isEditable()?this.template:this.readOnlyTemplate,g=this.options.static_url+"img/image-placeholder.png",h=c.get("size")||0;this.editor_$.html(f({node:{has_creator:!!c.get("created_by"),title:c.get("title"),uri:c.get("uri"),short_uri:e.shortenText((c.get("uri")||"").replace(/^(https?:\/\/)?(www\.)?/,"").replace(/\/$/,""),40),description:c.get("description"),image:c.get("image")||"",image_placeholder:g,color:c.get("color")||d.get("color"),clip_path:c.get("clip_path")||!1,created_by_color:d.get("color"),created_by_title:d.get("title"),size:(h>0?"+":"")+h,shape:c.get("shape")||"circle"},renkan:this.renkan,options:this.options,shortenText:e.shortenText})),this.redraw();var i=this,j=function(){i.renderer.removeRepresentation(i),paper.view.draw()};if(this.editor_$.find(".Rk-CloseX").click(j),this.editor_$.find(".Rk-Edit-Goto").click(function(){return c.get("uri")?void 0:!1}),this.renderer.isEditable()){var k=b(function(){b(function(){if(i.renderer.isEditable()){var a={title:i.editor_$.find(".Rk-Edit-Title").val()};i.options.show_node_editor_uri&&(a.uri=i.editor_$.find(".Rk-Edit-URI").val(),i.editor_$.find(".Rk-Edit-Goto").attr("href",a.uri||"#")),i.options.show_node_editor_image&&(a.image=i.editor_$.find(".Rk-Edit-Image").val(),i.editor_$.find(".Rk-Edit-ImgPreview").attr("src",a.image||g)),i.options.show_node_editor_description&&(a.description=i.editor_$.find(".Rk-Edit-Description").val()),i.options.change_shapes&&c.get("shape")!==i.editor_$.find(".Rk-Edit-Shape").val()&&(a.shape=i.editor_$.find(".Rk-Edit-Shape").val(),a.shape_changed=!0),c.set(a),i.redraw(),a.shape_changed===!0&&c.set(a)}else j()}).defer()}).throttle(500);this.editor_$.on("keyup",function(a){27===a.keyCode&&j()}),this.editor_$.find("input, textarea, select").on("change keyup paste",k),this.editor_$.find(".Rk-Edit-Image-File").change(function(){if(this.files.length){var a=this.files[0],b=new FileReader;if("image"!==a.type.substr(0,5))return void alert(i.renkan.translate("This file is not an image"));if(a.size>1024*i.options.uploaded_image_max_kb)return void alert(i.renkan.translate("Image size must be under ")+i.options.uploaded_image_max_kb+i.renkan.translate("KB"));b.onload=function(a){i.editor_$.find(".Rk-Edit-Image").val(a.target.result),k()},b.readAsDataURL(a)}}),this.editor_$.find(".Rk-Edit-Title")[0].focus();var l=i.editor_$.find(".Rk-Edit-ColorPicker");this.editor_$.find(".Rk-Edit-ColorPicker-Wrapper").hover(function(a){a.preventDefault(),l.show()},function(a){a.preventDefault(),l.hide()}),l.find("li").hover(function(b){b.preventDefault(),i.editor_$.find(".Rk-Edit-Color").css("background",a(this).attr("data-color"))},function(a){a.preventDefault(),i.editor_$.find(".Rk-Edit-Color").css("background",c.get("color")||(c.get("created_by")||e._USER_PLACEHOLDER(i.renkan)).get("color"))}).click(function(b){b.preventDefault(),i.renderer.isEditable()?(c.set("color",a(this).attr("data-color")),l.hide(),paper.view.draw()):j()});var m=function(a){if(i.renderer.isEditable()){var b=a+(c.get("size")||0);i.editor_$.find(".Rk-Edit-Size-Value").text((b>0?"+":"")+b),c.set("size",b),paper.view.draw()}else j()};this.editor_$.find(".Rk-Edit-Size-Down").click(function(){return m(-1),!1}),this.editor_$.find(".Rk-Edit-Size-Up").click(function(){return m(1),!1})}else if("object"==typeof this.source_representation.highlighted){var n=this.source_representation.highlighted.replace(b(c.get("title")).escape(),'<span class="Rk-Highlighted">$1</span>');this.editor_$.find(".Rk-Display-Title"+(c.get("uri")?" a":"")).html(n),this.options.show_node_tooltip_description&&this.editor_$.find(".Rk-Display-Description").html(this.source_representation.highlighted.replace(b(c.get("description")).escape(),'<span class="Rk-Highlighted">$1</span>'))}this.editor_$.find("img").load(function(){i.redraw()})},redraw:function(){var a=this.source_representation.paper_coords;e.drawEditBox(this.options,a,this.editor_block,.75*this.source_representation.circle_radius,this.editor_$),this.editor_$.show(),paper.view.draw()}}),f}),define("renderer/edgeeditor",["jquery","underscore","requtils","renderer/baseeditor"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({template:b.template('<h2><span class="Rk-CloseX">×</span><%-renkan.translate("Edit Edge")%></span></h2><p><label><%-renkan.translate("Title:")%></label><input class="Rk-Edit-Title" type="text" value="<%-edge.title%>"/></p><% if (options.show_edge_editor_uri) { %><p><label><%-renkan.translate("URI:")%></label><input class="Rk-Edit-URI" type="text" value="<%-edge.uri%>"/><a class="Rk-Edit-Goto" href="<%-edge.uri%>" target="_blank"></a></p><% if (options.properties.length) { %><p><label><%-renkan.translate("Choose from vocabulary:")%></label><select class="Rk-Edit-Vocabulary"><% _(options.properties).each(function(ontology) { %><option class="Rk-Edit-Vocabulary-Class" value=""><%- renkan.translate(ontology.label) %></option><% _(ontology.properties).each(function(property) { var uri = ontology["base-uri"] + property.uri; %><option class="Rk-Edit-Vocabulary-Property" value="<%- uri %>"<% if (uri === edge.uri) { %> selected<% } %>><%- renkan.translate(property.label) %></option><% }) %><% }) %></select></p><% } } %><% if (options.show_edge_editor_color) { %><div class="Rk-Editor-p"><span class="Rk-Editor-Label"><%-renkan.translate("Edge color:")%></span><div class="Rk-Edit-ColorPicker-Wrapper"><span class="Rk-Edit-Color" style="background:<%-edge.color%>;"><span class="Rk-Edit-ColorTip"></span></span><%= renkan.colorPicker %><span class="Rk-Edit-ColorPicker-Text"><%- renkan.translate("Choose color") %></span></div></div><% } %><% if (options.show_edge_editor_direction) { %><p><span class="Rk-Edit-Direction"><%- renkan.translate("Change edge direction") %></span></p><% } %><% if (options.show_edge_editor_nodes) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("From:")%></span><span class="Rk-UserColor" style="background:<%-edge.from_color%>;"></span><%- shortenText(edge.from_title, 25) %></p><p><span class="Rk-Editor-Label"><%-renkan.translate("To:")%></span><span class="Rk-UserColor" style="background:<%-edge.to_color%>;"></span><%- shortenText(edge.to_title, 25) %></p><% } %><% if (options.show_edge_editor_creator && edge.has_creator) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Created by:")%></span><span class="Rk-UserColor" style="background:<%-edge.created_by_color%>;"></span><%- shortenText(edge.created_by_title, 25) %></p><% } %>'),readOnlyTemplate:b.template('<h2><span class="Rk-CloseX">×</span><% if (options.show_edge_tooltip_color) { %><span class="Rk-UserColor" style="background:<%-edge.color%>;"></span><% } %><span class="Rk-Display-Title"><% if (edge.uri) { %><a href="<%-edge.uri%>" target="_blank"><% } %><%-edge.title%><% if (edge.uri) { %></a><% } %></span></h2><% if (options.show_edge_tooltip_uri && edge.uri) { %><p class="Rk-Display-URI"><a href="<%-edge.uri%>" target="_blank"><%-edge.short_uri%></a></p><% } %><p><%-edge.description%></p><% if (options.show_edge_tooltip_nodes) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("From:")%></span><span class="Rk-UserColor" style="background:<%-edge.from_color%>;"></span><%- shortenText(edge.from_title, 25) %></p><p><span class="Rk-Editor-Label"><%-renkan.translate("To:")%></span><span class="Rk-UserColor" style="background:<%-edge.to_color%>;"></span><%- shortenText(edge.to_title, 25) %></p><% } %><% if (options.show_edge_tooltip_creator && edge.has_creator) { %><p><span class="Rk-Editor-Label"><%-renkan.translate("Created by:")%></span><span class="Rk-UserColor" style="background:<%-edge.created_by_color%>;"></span><%- shortenText(edge.created_by_title, 25) %></p><% } %>'),draw:function(){var c=this.source_representation.model,d=c.get("from"),f=c.get("to"),g=c.get("created_by")||e._USER_PLACEHOLDER(this.renkan),h=this.renderer.isEditable()?this.template:this.readOnlyTemplate;
-this.editor_$.html(h({edge:{has_creator:!!c.get("created_by"),title:c.get("title"),uri:c.get("uri"),short_uri:e.shortenText((c.get("uri")||"").replace(/^(https?:\/\/)?(www\.)?/,"").replace(/\/$/,""),40),description:c.get("description"),color:c.get("color")||g.get("color"),from_title:d.get("title"),to_title:f.get("title"),from_color:d.get("color")||(d.get("created_by")||e._USER_PLACEHOLDER(this.renkan)).get("color"),to_color:f.get("color")||(f.get("created_by")||e._USER_PLACEHOLDER(this.renkan)).get("color"),created_by_color:g.get("color"),created_by_title:g.get("title")},renkan:this.renkan,shortenText:e.shortenText,options:this.options})),this.redraw();var i=this,j=function(){i.renderer.removeRepresentation(i),paper.view.draw()};if(this.editor_$.find(".Rk-CloseX").click(j),this.editor_$.find(".Rk-Edit-Goto").click(function(){return c.get("uri")?void 0:!1}),this.renderer.isEditable()){var k=b(function(){b(function(){if(i.renderer.isEditable()){var a={title:i.editor_$.find(".Rk-Edit-Title").val()};i.options.show_edge_editor_uri&&(a.uri=i.editor_$.find(".Rk-Edit-URI").val()),i.editor_$.find(".Rk-Edit-Goto").attr("href",a.uri||"#"),c.set(a),paper.view.draw()}else j()}).defer()}).throttle(500);this.editor_$.on("keyup",function(a){27===a.keyCode&&j()}),this.editor_$.find("input").on("keyup change paste",k),this.editor_$.find(".Rk-Edit-Vocabulary").change(function(){var b=a(this),c=b.val();c&&(i.editor_$.find(".Rk-Edit-Title").val(b.find(":selected").text()),i.editor_$.find(".Rk-Edit-URI").val(c),k())}),this.editor_$.find(".Rk-Edit-Direction").click(function(){i.renderer.isEditable()?(c.set({from:c.get("to"),to:c.get("from")}),i.draw()):j()});var l=i.editor_$.find(".Rk-Edit-ColorPicker");this.editor_$.find(".Rk-Edit-ColorPicker-Wrapper").hover(function(a){a.preventDefault(),l.show()},function(a){a.preventDefault(),l.hide()}),l.find("li").hover(function(b){b.preventDefault(),i.editor_$.find(".Rk-Edit-Color").css("background",a(this).attr("data-color"))},function(a){a.preventDefault(),i.editor_$.find(".Rk-Edit-Color").css("background",c.get("color")||(c.get("created_by")||e._USER_PLACEHOLDER(i.renkan)).get("color"))}).click(function(b){b.preventDefault(),i.renderer.isEditable()?(c.set("color",a(this).attr("data-color")),l.hide(),paper.view.draw()):j()})}},redraw:function(){var a=this.source_representation.paper_coords;e.drawEditBox(this.options,a,this.editor_block,5,this.editor_$),this.editor_$.show(),paper.view.draw()}}),f}),define("renderer/nodebutton",["jquery","underscore","requtils","renderer/basebutton"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({setSectorSize:function(){var a=this.source_representation.circle_radius;a!==this.lastSectorInner&&(this.sector&&this.sector.destroy(),this.sector=this.renderer.drawSector(this,1+a,e._NODE_BUTTON_WIDTH+a,this.startAngle,this.endAngle,1,this.imageName,this.renkan.translate(this.text)),this.lastSectorInner=a)}}),f}),define("renderer/nodeeditbutton",["jquery","underscore","requtils","renderer/nodebutton"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({_init:function(){this.type="Node-edit-button",this.lastSectorInner=0,this.startAngle=-135,this.endAngle=-45,this.imageName="edit",this.text="Edit"},mouseup:function(){this.renderer.is_dragging||this.source_representation.openEditor()}}),f}),define("renderer/noderemovebutton",["jquery","underscore","requtils","renderer/nodebutton"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({_init:function(){this.type="Node-remove-button",this.lastSectorInner=0,this.startAngle=0,this.endAngle=90,this.imageName="remove",this.text="Remove"},mouseup:function(){if(this.renderer.click_target=null,this.renderer.is_dragging=!1,this.renderer.removeRepresentationsOfType("editor"),this.renderer.isEditable())if(this.options.element_delete_delay){var a=e.getUID("delete");this.renderer.delete_list.push({id:a,time:(new Date).valueOf()+this.options.element_delete_delay}),this.source_representation.model.set("delete_scheduled",a)}else confirm(this.renkan.translate("Do you really wish to remove node ")+'"'+this.source_representation.model.get("title")+'"?')&&this.project.removeNode(this.source_representation.model)}}),f}),define("renderer/noderevertbutton",["jquery","underscore","requtils","renderer/nodebutton"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({_init:function(){this.type="Node-revert-button",this.lastSectorInner=0,this.startAngle=-135,this.endAngle=135,this.imageName="revert",this.text="Cancel deletion"},mouseup:function(){this.renderer.click_target=null,this.renderer.is_dragging=!1,this.renderer.isEditable()&&this.source_representation.model.unset("delete_scheduled")}}),f}),define("renderer/nodelinkbutton",["jquery","underscore","requtils","renderer/nodebutton"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({_init:function(){this.type="Node-link-button",this.lastSectorInner=0,this.startAngle=90,this.endAngle=180,this.imageName="link",this.text="Link to another node"},mousedown:function(a){if(this.renderer.isEditable()){var b=this.renderer.canvas_$.offset(),c=new paper.Point([a.pageX-b.left,a.pageY-b.top]);this.renderer.click_target=null,this.renderer.removeRepresentationsOfType("editor"),this.renderer.addTempEdge(this.source_representation,c)}}}),f}),define("renderer/nodeenlargebutton",["jquery","underscore","requtils","renderer/nodebutton"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({_init:function(){this.type="Node-enlarge-button",this.lastSectorInner=0,this.startAngle=-45,this.endAngle=0,this.imageName="enlarge",this.text="Enlarge"},mouseup:function(){var a=1+(this.source_representation.model.get("size")||0);this.source_representation.model.set("size",a),this.source_representation.select(),this.select(),paper.view.draw()}}),f}),define("renderer/nodeshrinkbutton",["jquery","underscore","requtils","renderer/nodebutton"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({_init:function(){this.type="Node-shrink-button",this.lastSectorInner=0,this.startAngle=-180,this.endAngle=-135,this.imageName="shrink",this.text="Shrink"},mouseup:function(){var a=-1+(this.source_representation.model.get("size")||0);this.source_representation.model.set("size",a),this.source_representation.select(),this.select(),paper.view.draw()}}),f}),define("renderer/edgeeditbutton",["jquery","underscore","requtils","renderer/basebutton"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({_init:function(){this.type="Edge-edit-button",this.sector=this.renderer.drawSector(this,e._EDGE_BUTTON_INNER,e._EDGE_BUTTON_OUTER,-270,-90,1,"edit",this.renkan.translate("Edit"))},mouseup:function(){this.renderer.is_dragging||this.source_representation.openEditor()}}),f}),define("renderer/edgeremovebutton",["jquery","underscore","requtils","renderer/basebutton"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({_init:function(){this.type="Edge-remove-button",this.sector=this.renderer.drawSector(this,e._EDGE_BUTTON_INNER,e._EDGE_BUTTON_OUTER,-90,90,1,"remove",this.renkan.translate("Remove"))},mouseup:function(){if(this.renderer.click_target=null,this.renderer.is_dragging=!1,this.renderer.removeRepresentationsOfType("editor"),this.renderer.isEditable())if(this.options.element_delete_delay){var a=e.getUID("delete");this.renderer.delete_list.push({id:a,time:(new Date).valueOf()+this.options.element_delete_delay}),this.source_representation.model.set("delete_scheduled",a)}else confirm(this.renkan.translate("Do you really wish to remove edge ")+'"'+this.source_representation.model.get("title")+'"?')&&this.project.removeEdge(this.source_representation.model)}}),f}),define("renderer/edgerevertbutton",["jquery","underscore","requtils","renderer/basebutton"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({_init:function(){this.type="Edge-revert-button",this.sector=this.renderer.drawSector(this,e._EDGE_BUTTON_INNER,e._EDGE_BUTTON_OUTER,-135,135,1,"revert",this.renkan.translate("Cancel deletion"))},mouseup:function(){this.renderer.click_target=null,this.renderer.is_dragging=!1,this.renderer.isEditable()&&this.source_representation.model.unset("delete_scheduled")}}),f}),define("renderer/miniframe",["jquery","underscore","requtils","renderer/baserepresentation"],function(a,b,c,d){var e=c.getUtils(),f=e.inherit(d);return b(f.prototype).extend({paperShift:function(a){this.renderer.offset=this.renderer.offset.subtract(a.divide(this.renderer.minimap.scale).multiply(this.renderer.scale)),this.renderer.redraw()},mouseup:function(){this.renderer.click_target=null,this.renderer.is_dragging=!1}}),f}),define("renderer/scene",["jquery","underscore","filesaver","requtils","renderer/miniframe"],function(a,b,c,d,e){var f=d.getUtils(),g=function(c){this.renkan=c,this.$=a(".Rk-Render"),this.representations=[],this.$.html(this.template(c)),this.onStatusChange(),this.canvas_$=this.$.find(".Rk-Canvas"),this.labels_$=this.$.find(".Rk-Labels"),this.editor_$=this.$.find(".Rk-Editor"),this.notif_$=this.$.find(".Rk-Notifications"),paper.setup(this.canvas_$[0]),this.scale=1,this.initialScale=1,this.offset=paper.view.center,this.totalScroll=0,this.mouse_down=!1,this.click_target=null,this.selected_target=null,this.edge_layer=new paper.Layer,this.node_layer=new paper.Layer,this.buttons_layer=new paper.Layer,this.delete_list=[],this.redrawActive=!0,c.options.show_minimap&&(this.minimap={background_layer:new paper.Layer,edge_layer:new paper.Layer,node_layer:new paper.Layer,node_group:new paper.Group,size:new paper.Size(c.options.minimap_width,c.options.minimap_height)},this.minimap.background_layer.activate(),this.minimap.topleft=paper.view.bounds.bottomRight.subtract(this.minimap.size),this.minimap.rectangle=new paper.Path.Rectangle(this.minimap.topleft.subtract([2,2]),this.minimap.size.add([4,4])),this.minimap.rectangle.fillColor=c.options.minimap_background_color,this.minimap.rectangle.strokeColor=c.options.minimap_border_color,this.minimap.rectangle.strokeWidth=4,this.minimap.offset=new paper.Point(this.minimap.size.divide(2)),this.minimap.scale=.1,this.minimap.node_layer.activate(),this.minimap.cliprectangle=new paper.Path.Rectangle(this.minimap.topleft,this.minimap.size),this.minimap.node_group.addChild(this.minimap.cliprectangle),this.minimap.node_group.clipped=!0,this.minimap.miniframe=new paper.Path.Rectangle(this.minimap.topleft,this.minimap.size),this.minimap.node_group.addChild(this.minimap.miniframe),this.minimap.miniframe.fillColor="#c0c0ff",this.minimap.miniframe.opacity=.3,this.minimap.miniframe.strokeColor="#000080",this.minimap.miniframe.strokeWidth=3,this.minimap.miniframe.__representation=new e(this,null)),this.throttledPaperDraw=b(function(){paper.view.draw()}).throttle(100),this.bundles=[],this.click_mode=!1;var d=this,g=!0,h=1,i=!1,j=0,k=0;this.image_cache={},this.icon_cache={},["edit","remove","link","enlarge","shrink","revert"].forEach(function(a){var b=new Image;b.src=c.options.static_url+"img/"+a+".png",d.icon_cache[a]=b});var l=b.throttle(function(a,b){d.onMouseMove(a,b)},f._MOUSEMOVE_RATE);this.canvas_$.on({mousedown:function(a){a.preventDefault(),d.onMouseDown(a,!1)},mousemove:function(a){a.preventDefault(),l(a,!1)},mouseup:function(a){a.preventDefault(),d.onMouseUp(a,!1)},mousewheel:function(a,b){c.options.zoom_on_scroll&&(a.preventDefault(),g&&d.onScroll(a,b))},touchstart:function(a){a.preventDefault();var b=a.originalEvent.touches[0];c.options.allow_double_click&&new Date-_lastTap<f._DOUBLETAP_DELAY&&Math.pow(j-b.pageX,2)+Math.pow(k-b.pageY,2)<f._DOUBLETAP_DISTANCE?(_lastTap=0,d.onDoubleClick(b)):(_lastTap=new Date,j=b.pageX,k=b.pageY,h=d.scale,i=!1,d.onMouseDown(b,!0))},touchmove:function(a){if(a.preventDefault(),_lastTap=0,1===a.originalEvent.touches.length)d.onMouseMove(a.originalEvent.touches[0],!0);else{if(i||(d.onMouseUp(a.originalEvent.touches[0],!0),d.click_target=null,d.is_dragging=!1,i=!0),"undefined"===a.originalEvent.scale)return;var b=a.originalEvent.scale*h,c=b/d.scale,e=new paper.Point([d.canvas_$.width(),d.canvas_$.height()]).multiply(.5*(1-c)).add(d.offset.multiply(c));d.setScale(b,e)}},touchend:function(a){a.preventDefault(),d.onMouseUp(a.originalEvent.changedTouches[0],!0)},dblclick:function(a){a.preventDefault(),c.options.allow_double_click&&d.onDoubleClick(a)},mouseleave:function(a){a.preventDefault(),d.onMouseUp(a,!1),d.click_target=null,d.is_dragging=!1},dragover:function(a){a.preventDefault()},dragenter:function(a){a.preventDefault(),g=!1},dragleave:function(a){a.preventDefault(),g=!0},drop:function(a){a.preventDefault(),g=!0;var c={};b(a.originalEvent.dataTransfer.types).each(function(b){try{c[b]=a.originalEvent.dataTransfer.getData(b)}catch(d){}});var e=a.originalEvent.dataTransfer.getData("Text");if("string"==typeof e)switch(e[0]){case"{":case"[":try{var f=JSON.parse(e);b(c).extend(f)}catch(h){c["text/plain"]||(c["text/plain"]=e)}break;case"<":c["text/html"]||(c["text/html"]=e);break;default:c["text/plain"]||(c["text/plain"]=e)}var i=a.originalEvent.dataTransfer.getData("URL");i&&!c["text/uri-list"]&&(c["text/uri-list"]=i),d.dropData(c,a.originalEvent)}});var m=function(a,b){d.$.find(a).click(function(a){return d[b](a),!1})};m(".Rk-ZoomOut","zoomOut"),m(".Rk-ZoomIn","zoomIn"),m(".Rk-ZoomFit","autoScale"),this.$.find(".Rk-ZoomSave").click(function(){d.renkan.project.addView({zoom_level:d.scale,offset:d.offset})}),this.$.find(".Rk-ZoomSetSaved").click(function(){var a=d.renkan.project.get("views").last();a&&d.setScale(a.get("zoom_level"),new paper.Point(a.get("offset")))}),this.renkan.read_only&&!isNaN(parseInt(this.renkan.options.default_view))&&this.$.find(".Rk-ZoomSetSaved").show(),this.$.find(".Rk-CurrentUser").mouseenter(function(){d.$.find(".Rk-UserList").slideDown()}),this.$.find(".Rk-Users").mouseleave(function(){d.$.find(".Rk-UserList").slideUp()}),m(".Rk-FullScreen-Button","fullScreen"),m(".Rk-AddNode-Button","addNodeBtn"),m(".Rk-AddEdge-Button","addEdgeBtn"),m(".Rk-Save-Button","save"),m(".Rk-Open-Button","open"),m(".Rk-Export-Button","exportProject"),this.$.find(".Rk-Bookmarklet-Button").attr("href","javascript:"+f._BOOKMARKLET_CODE(c)).click(function(){return d.notif_$.text(c.translate("Drag this button to your bookmark bar. When on a third-party website, click it to enable drag-and-drop from the website to Renkan.")).fadeIn().delay(5e3).fadeOut(),!1}),this.$.find(".Rk-TopBar-Button").mouseover(function(){a(this).find(".Rk-TopBar-Tooltip").show()}).mouseout(function(){a(this).find(".Rk-TopBar-Tooltip").hide()}),m(".Rk-Fold-Bins","foldBins"),paper.view.onResize=function(a){paper.view._viewSize.height=a.size.height=d.canvas_$.parent().height(),d.minimap&&(d.minimap.topleft=paper.view.bounds.bottomRight.subtract(d.minimap.size),d.minimap.rectangle.fitBounds(d.minimap.topleft.subtract([2,2]),d.minimap.size.add([4,4])),d.minimap.cliprectangle.fitBounds(d.minimap.topleft,d.minimap.size)),d.redraw()};var n=b.throttle(function(){d.redraw()},50);this.addRepresentations("Node",this.renkan.project.get("nodes")),this.addRepresentations("Edge",this.renkan.project.get("edges")),this.renkan.project.on("change:title",function(){d.$.find(".Rk-PadTitle").val(c.project.get("title"))}),this.$.find(".Rk-PadTitle").on("keyup input paste",function(){c.project.set({title:a(this).val()})});var o=b.throttle(function(){d.redrawUsers()},100);if(o(),this.renkan.project.on("add:users remove:users",o),this.renkan.project.on("add:views remove:views",function(){d.renkan.project.get("views").length>0?d.$.find(".Rk-ZoomSetSaved").show():d.$.find(".Rk-ZoomSetSaved").hide()}),this.renkan.project.on("add:nodes",function(a){d.addRepresentation("Node",a),n()}),this.renkan.project.on("add:edges",function(a){d.addRepresentation("Edge",a),n()}),this.renkan.project.on("change:title",function(a,b){var c=d.$.find(".Rk-PadTitle");c.is("input")?c.val()!==b&&c.val(b):c.text(b)}),c.options.size_bug_fix){var p="number"==typeof c.options.size_bug_fix?c.options.size_bug_fix:500;window.setTimeout(function(){d.fixSize(!0)},p)}if(c.options.force_resize&&a(window).resize(function(){d.fixSize(!1)}),c.options.show_user_list&&c.options.user_color_editable){var q=this.$.find(".Rk-Users .Rk-Edit-ColorPicker-Wrapper"),r=this.$.find(".Rk-Users .Rk-Edit-ColorPicker");q.hover(function(a){d.isEditable()&&(a.preventDefault(),r.show())},function(a){a.preventDefault(),r.hide()}),r.find("li").mouseenter(function(b){d.isEditable()&&(b.preventDefault(),d.$.find(".Rk-CurrentUser-Color").css("background",a(this).attr("data-color")))})}if(c.options.show_search_field){var s="";this.$.find(".Rk-GraphSearch-Field").on("keyup change paste input",function(){var b=a(this),e=b.val();if(e!==s)if(s=e,e.length<2)c.project.get("nodes").each(function(a){d.getRepresentationByModel(a).unhighlight()});else{var g=f.regexpFromTextOrArray(e);c.project.get("nodes").each(function(a){g.test(a.get("title"))||g.test(a.get("description"))?d.getRepresentationByModel(a).highlight(g):d.getRepresentationByModel(a).unhighlight()})}})}this.redraw(),window.setInterval(function(){var a=(new Date).valueOf();d.delete_list.forEach(function(b){if(a>=b.time){var d=c.project.get("nodes").findWhere({delete_scheduled:b.id});d&&project.removeNode(d),d=c.project.get("edges").findWhere({delete_scheduled:b.id}),d&&project.removeEdge(d)}}),d.delete_list=d.delete_list.filter(function(a){return c.project.get("nodes").findWhere({delete_scheduled:a.id})||c.project.get("edges").findWhere({delete_scheduled:a.id})})},500),this.minimap&&window.setInterval(function(){d.rescaleMinimap()},2e3)};return b(g.prototype).extend({template:b.template('<% if (options.show_top_bar) { %><div class="Rk-TopBar"><% if (!options.editor_mode) { %><h2 class="Rk-PadTitle"><%- project.get("title") || translate("Untitled project")%></h2><% } else { %><input type="text" class="Rk-PadTitle" value="<%- project.get("title") || "" %>" placeholder="<%-translate("Untitled project")%>" /><% } %><% if (options.show_user_list) { %><div class="Rk-Users"><div class="Rk-CurrentUser"><div class="Rk-Edit-ColorPicker-Wrapper"><span class="Rk-CurrentUser-Color"><% if (options.user_color_editable) { %><span class="Rk-Edit-ColorTip"></span><% } %></span><% if (options.user_color_editable) { print(colorPicker) } %></div><span class="Rk-CurrentUser-Name"><unknown user></span></div><ul class="Rk-UserList"></ul></div><% } %><% if (options.home_button_url) {%><div class="Rk-TopBar-Separator"></div><a class="Rk-TopBar-Button Rk-Home-Button" href="<%- options.home_button_url %>"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents"><%- translate(options.home_button_title) %></div></div></a><% } %><% if (options.show_fullscreen_button) { %><div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-FullScreen-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents"><%-translate("Full Screen")%></div></div></div><% } %><% if (options.editor_mode) { %><% if (options.show_addnode_button) { %><div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-AddNode-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents"><%-translate("Add Node")%></div></div></div><% } %><% if (options.show_addedge_button) { %><div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-AddEdge-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents"><%-translate("Add Edge")%></div></div></div><% } %><% if (options.show_export_button) { %><div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-Export-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents"><%-translate("Download Project")%></div></div></div><% } %><% if (options.show_save_button) { %><div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-Save-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents"> </div></div></div><% } %><% if (options.show_open_button) { %><div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-Open-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents"><%-translate("Open Project")%></div></div></div><% } %><% if (options.show_bookmarklet) { %><div class="Rk-TopBar-Separator"></div><a class="Rk-TopBar-Button Rk-Bookmarklet-Button" href="#"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents"><%-translate("Renkan \'Drag-to-Add\' bookmarklet")%></div></div></a><% } %><% } else { %><% if (options.show_export_button) { %><div class="Rk-TopBar-Separator"></div><div class="Rk-TopBar-Button Rk-Export-Button"><div class="Rk-TopBar-Tooltip"><div class="Rk-TopBar-Tooltip-Contents"><%-translate("Download Project")%></div></div></div><div class="Rk-TopBar-Separator"></div><% } %><% };if (options.show_search_field) { %><form action="#" class="Rk-GraphSearch-Form"><input type="search" class="Rk-GraphSearch-Field" placeholder="<%- translate("Search in graph") %>" /></form><div class="Rk-TopBar-Separator"></div><% } %></div><% } %><div class="Rk-Editing-Space<% if (!options.show_top_bar) { %> Rk-Editing-Space-Full<% } %>"><div class="Rk-Labels"></div><canvas class="Rk-Canvas" resize></canvas><div class="Rk-Notifications"></div><div class="Rk-Editor"><% if (options.show_bins) { %><div class="Rk-Fold-Bins">«</div><% } %><div class="Rk-ZoomButtons"><div class="Rk-ZoomIn" title="<%-translate("Zoom In")%>"></div><div class="Rk-ZoomFit" title="<%-translate("Zoom Fit")%>"></div><div class="Rk-ZoomOut" title="<%-translate("Zoom Out")%>"></div><% if (options.editor_mode) { %><div class="Rk-ZoomSave" title="<%-translate("Zoom Save")%>"></div><% } %><% if (options.editor_mode || !isNaN(parseInt(options.default_view))) { %><div class="Rk-ZoomSetSaved" title="<%-translate("View saved zoom")%>"></div><% } %></div></div></div>'),fixSize:function(a){var b=this.$.width(),c=this.$.height();this.renkan.options.show_top_bar&&(c-=this.$.find(".Rk-TopBar").height()),this.canvas_$.attr({width:b,height:c}),paper.view.viewSize=new paper.Size([b,c]),a&&(this.renkan.read_only&&!isNaN(parseInt(this.renkan.options.default_view))?this.autoScale(this.renkan.project.get("views")[parseInt(this.renkan.options.default_view)]):this.autoScale())},drawSector:function(b,c,d,e,f,g,h,i){var j=this.renkan.options,k=e*Math.PI/180,l=f*Math.PI/180,m=this.icon_cache[h],n=-Math.sin(k),o=Math.cos(k),p=Math.cos(k)*c+g*n,q=Math.sin(k)*c+g*o,r=Math.cos(k)*d+g*n,s=Math.sin(k)*d+g*o,t=-Math.sin(l),u=Math.cos(l),v=Math.cos(l)*c-g*t,w=Math.sin(l)*c-g*u,x=Math.cos(l)*d-g*t,y=Math.sin(l)*d-g*u,z=(c+d)/2,A=(k+l)/2,B=Math.cos(A)*z,C=Math.sin(A)*z,D=Math.cos(A)*c,E=Math.cos(A)*d,F=Math.sin(A)*c,G=Math.sin(A)*d,H=Math.cos(A)*(d+3),I=Math.sin(A)*(d+j.buttons_label_font_size)+j.buttons_label_font_size/2;this.buttons_layer.activate();var J=new paper.Path;J.add([p,q]),J.arcTo([D,F],[v,w]),J.lineTo([x,y]),J.arcTo([E,G],[r,s]),J.fillColor=j.buttons_background,J.opacity=.5,J.closed=!0,J.__representation=b;var K=new paper.PointText(H,I);K.characterStyle={fontSize:j.buttons_label_font_size,fillColor:j.buttons_label_color},K.paragraphStyle.justification=H>2?"left":-2>H?"right":"center",K.visible=!1;var L=!1,M=new paper.Point(-200,-200),N=new paper.Group([J,K]),O=N.position,P=new paper.Point([B,C]),Q=new paper.Point(0,0);K.content=i,N.visible=!1,N.position=M;var R={show:function(){L=!0,N.position=Q.add(O),N.visible=!0},moveTo:function(a){Q=a,L&&(N.position=a.add(O))},hide:function(){L=!1,N.visible=!1,N.position=M},select:function(){J.opacity=.8,K.visible=!0},unselect:function(){J.opacity=.5,K.visible=!1},destroy:function(){N.remove()}},S=function(){var a=new paper.Raster(m);a.position=P.add(N.position).subtract(O),a.locked=!0,N.addChild(a)};return m.width?S():a(m).on("load",S),R},addToBundles:function(a){var c=b(this.bundles).find(function(b){return b.from===a.from_representation&&b.to===a.to_representation||b.from===a.to_representation&&b.to===a.from_representation});return"undefined"!=typeof c?c.edges.push(a):(c={from:a.from_representation,to:a.to_representation,edges:[a],getPosition:function(a){var c=a.from_representation===this.from?1:-1;return c*(b(this.edges).indexOf(a)-(this.edges.length-1)/2)}},this.bundles.push(c)),c},isEditable:function(){return this.renkan.options.editor_mode&&!this.renkan.read_only},onStatusChange:function(){var a=this.$.find(".Rk-Save-Button"),b=a.find(".Rk-TopBar-Tooltip-Contents");this.renkan.read_only?(a.removeClass("disabled Rk-Save-Online").addClass("Rk-Save-ReadOnly"),b.text(this.renkan.translate("Connection lost"))):this.renkan.options.manual_save?(a.removeClass("Rk-Save-ReadOnly Rk-Save-Online"),b.text(this.renkan.translate("Save Project"))):(a.removeClass("disabled Rk-Save-ReadOnly").addClass("Rk-Save-Online"),b.text(this.renkan.translate("Auto-save enabled"))),this.redrawUsers()},setScale:function(a,b){a/this.initialScale>f._MIN_SCALE&&a/this.initialScale<f._MAX_SCALE&&(this.scale=a,b&&(this.offset=b),this.redraw())},autoScale:function(a){var b=this.renkan.project.get("nodes");if(b.length>1){var c=b.map(function(a){return a.get("position").x}),d=b.map(function(a){return a.get("position").y}),e=Math.min.apply(Math,c),f=Math.min.apply(Math,d),g=Math.max.apply(Math,c),h=Math.max.apply(Math,d),i=Math.min((paper.view.size.width-2*this.renkan.options.autoscale_padding)/(g-e),(paper.view.size.height-2*this.renkan.options.autoscale_padding)/(h-f));this.initialScale=i,"undefined"!=typeof a&&parseFloat(a.zoom_level)>0&&parseFloat(a.offset.x)>0&&parseFloat(a.offset.y)>0?this.setScale(parseFloat(a.zoom_level),new paper.Point(parseFloat(a.offset.x),parseFloat(a.offset.y))):this.setScale(i,paper.view.center.subtract(new paper.Point([(g+e)/2,(h+f)/2]).multiply(i)))}1===b.length&&this.setScale(1,paper.view.center.subtract(new paper.Point([b.at(0).get("position").x,b.at(0).get("position").y])))},redrawMiniframe:function(){var a=this.toMinimapCoords(this.toModelCoords(new paper.Point([0,0]))),b=this.toMinimapCoords(this.toModelCoords(paper.view.bounds.bottomRight));this.minimap.miniframe.fitBounds(a,b)},rescaleMinimap:function(){var a=this.renkan.project.get("nodes");if(a.length>1){var b=a.map(function(a){return a.get("position").x}),c=a.map(function(a){return a.get("position").y}),d=Math.min.apply(Math,b),e=Math.min.apply(Math,c),f=Math.max.apply(Math,b),g=Math.max.apply(Math,c),h=Math.min(.8*this.scale*this.renkan.options.minimap_width/paper.view.bounds.width,.8*this.scale*this.renkan.options.minimap_height/paper.view.bounds.height,(this.renkan.options.minimap_width-2*this.renkan.options.minimap_padding)/(f-d),(this.renkan.options.minimap_height-2*this.renkan.options.minimap_padding)/(g-e));this.minimap.offset=this.minimap.size.divide(2).subtract(new paper.Point([(f+d)/2,(g+e)/2]).multiply(h)),this.minimap.scale=h}1===a.length&&(this.minimap.scale=.1,this.minimap.offset=this.minimap.size.divide(2).subtract(new paper.Point([a.at(0).get("position").x,a.at(0).get("position").y]).multiply(this.minimap.scale))),this.redraw()},toPaperCoords:function(a){return a.multiply(this.scale).add(this.offset)},toMinimapCoords:function(a){return a.multiply(this.minimap.scale).add(this.minimap.offset).add(this.minimap.topleft)},toModelCoords:function(a){return a.subtract(this.offset).divide(this.scale)},addRepresentation:function(a,b){var c=d.getRenderer()[a],e=new c(this,b);return this.representations.push(e),e},addRepresentations:function(a,b){var c=this;b.forEach(function(b){c.addRepresentation(a,b)})},userTemplate:b.template('<li class="Rk-User"><span class="Rk-UserColor" style="background:<%=background%>;"></span><%=name%></li>'),redrawUsers:function(){if(this.renkan.options.show_user_list){var b=[].concat((this.renkan.project.current_user_list||{}).models||[],(this.renkan.project.get("users")||{}).models||[]),c="",d=this.$.find(".Rk-Users"),e=d.find(".Rk-CurrentUser-Name"),f=d.find(".Rk-Edit-ColorPicker li"),g=d.find(".Rk-CurrentUser-Color"),h=this;e.off("click").text(this.renkan.translate("<unknown user>")),f.off("mouseleave click"),b.forEach(function(b){b.get("_id")===h.renkan.current_user?(e.text(b.get("title")),g.css("background",b.get("color")),h.isEditable()&&(h.renkan.options.user_name_editable&&e.click(function(){var c=a(this),d=a("<input>").val(b.get("title")).blur(function(){b.set("title",a(this).val()),h.redrawUsers(),h.redraw()});c.empty().html(d),d.select()}),h.renkan.options.user_color_editable&&f.click(function(c){c.preventDefault(),h.isEditable()&&b.set("color",a(this).attr("data-color")),a(this).parent().hide()}).mouseleave(function(){g.css("background",b.get("color"))}))):c+=h.userTemplate({name:b.get("title"),background:b.get("color")})}),d.find(".Rk-UserList").html(c)}},removeRepresentation:function(a){a.destroy(),this.representations=b(this.representations).reject(function(b){return b===a})},getRepresentationByModel:function(a){return a?b(this.representations).find(function(b){return b.model===a}):void 0},removeRepresentationsOfType:function(a){var c=b(this.representations).filter(function(b){return b.type===a}),d=this;b(c).each(function(a){d.removeRepresentation(a)})},highlightModel:function(a){var b=this.getRepresentationByModel(a);b&&b.highlight()},unhighlightAll:function(){b(this.representations).each(function(a){a.unhighlight()})},unselectAll:function(){b(this.representations).each(function(a){a.unselect()})},redraw:function(){this.redrawActive&&(b(this.representations).each(function(a){a.redraw(!0)}),this.minimap&&this.redrawMiniframe(),paper.view.draw())},addTempEdge:function(a,b){var c=this.addRepresentation("TempEdge",null);c.end_pos=b,c.from_representation=a,c.redraw(),this.click_target=c},findTarget:function(a){if(a&&"undefined"!=typeof a.item.__representation){var b=a.item.__representation;this.selected_target!==a.item.__representation&&(this.selected_target&&this.selected_target.unselect(b),b.select(this.selected_target),this.selected_target=b)}else this.selected_target&&this.selected_target.unselect(),this.selected_target=null},paperShift:function(a){this.offset=this.offset.add(a),this.redraw()},onMouseMove:function(a){var b=this.canvas_$.offset(),c=new paper.Point([a.pageX-b.left,a.pageY-b.top]),d=c.subtract(this.last_point);this.last_point=c,!this.is_dragging&&this.mouse_down&&d.length>f._MIN_DRAG_DISTANCE&&(this.is_dragging=!0);var e=paper.project.hitTest(c);this.is_dragging?this.click_target&&"function"==typeof this.click_target.paperShift?this.click_target.paperShift(d):this.paperShift(d):this.findTarget(e),paper.view.draw()},onMouseDown:function(b,c){var d=this.canvas_$.offset(),e=new paper.Point([b.pageX-d.left,b.pageY-d.top]);if(this.last_point=e,this.mouse_down=!0,!this.click_target||"Temp-edge"!==this.click_target.type){this.removeRepresentationsOfType("editor"),this.is_dragging=!1;var g=paper.project.hitTest(e);if(g&&"undefined"!=typeof g.item.__representation)this.click_target=g.item.__representation,this.click_target.mousedown(b,c);else if(this.click_target=null,this.isEditable()&&this.click_mode===f._CLICKMODE_ADDNODE){var h=this.toModelCoords(e),i={id:f.getUID("node"),created_by:this.renkan.current_user,position:{x:h.x,y:h.y}};_node=this.renkan.project.addNode(i),this.getRepresentationByModel(_node).openEditor()}}this.click_mode&&(this.isEditable()&&this.click_mode===f._CLICKMODE_STARTEDGE&&this.click_target&&"Node"===this.click_target.type?(this.removeRepresentationsOfType("editor"),this.addTempEdge(this.click_target,e),this.click_mode=f._CLICKMODE_ENDEDGE,this.notif_$.fadeOut(function(){a(this).html(this.renkan.translate("Click on a second node to complete the edge")).fadeIn()})):(this.notif_$.hide(),this.click_mode=!1)),paper.view.draw()},onMouseUp:function(a,b){if(this.mouse_down=!1,this.click_target){var c=this.canvas_$.offset();this.click_target.mouseup({point:new paper.Point([a.pageX-c.left,a.pageY-c.top])},b)}else this.click_target=null,this.is_dragging=!1,b&&this.unselectAll();
-paper.view.draw()},onScroll:function(a,b){if(this.totalScroll+=b,Math.abs(this.totalScroll)>=1){var c=this.canvas_$.offset(),d=new paper.Point([a.pageX-c.left,a.pageY-c.top]).subtract(this.offset).multiply(Math.SQRT2-1);this.totalScroll>0?this.setScale(this.scale*Math.SQRT2,this.offset.subtract(d)):this.setScale(this.scale*Math.SQRT1_2,this.offset.add(d.divide(Math.SQRT2))),this.totalScroll=0}},onDoubleClick:function(a){if(this.isEditable()){var b=this.canvas_$.offset(),c=new paper.Point([a.pageX-b.left,a.pageY-b.top]),d=paper.project.hitTest(c);if(this.isEditable()&&(!d||"undefined"==typeof d.item.__representation)){var e=this.toModelCoords(c),g={id:f.getUID("node"),created_by:this.renkan.current_user,position:{x:e.x,y:e.y}},h=this.renkan.project.addNode(g);this.getRepresentationByModel(h).openEditor()}paper.view.draw()}},defaultDropHandler:function(b){var c={},d="";switch(b["text/x-iri-specific-site"]){case"twitter":d=a("<div>").html(b["text/x-iri-selected-html"]);var e=d.find(".tweet");c.title=this.renkan.translate("Tweet by ")+e.attr("data-name"),c.uri="http://twitter.com/"+e.attr("data-screen-name")+"/status/"+e.attr("data-tweet-id"),c.image=e.find(".avatar").attr("src"),c.description=e.find(".js-tweet-text:first").text();break;case"google":d=a("<div>").html(b["text/x-iri-selected-html"]),c.title=d.find("h3:first").text().trim(),c.uri=d.find("h3 a").attr("href"),c.description=d.find(".st:first").text().trim();break;default:b["text/x-iri-source-uri"]&&(c.uri=b["text/x-iri-source-uri"])}if((b["text/plain"]||b["text/x-iri-selected-text"])&&(c.description=(b["text/plain"]||b["text/x-iri-selected-text"]).replace(/[\s\n]+/gm," ").trim()),b["text/html"]||b["text/x-iri-selected-html"]){d=a("<div>").html(b["text/html"]||b["text/x-iri-selected-html"]);var f=d.find("image");f.length&&(c.image=f.attr("xlink:href"));var g=d.find("path");g.length&&(c.clipPath=g.attr("d"));var h=d.find("img");h.length&&(c.image=h[0].src);var i=d.find("a");i.length&&(c.uri=i[0].href),c.title=d.find("[title]").attr("title")||c.title,c.description=d.text().replace(/[\s\n]+/gm," ").trim()}b["text/uri-list"]&&(c.uri=b["text/uri-list"]),b["text/x-moz-url"]&&!c.title&&(c.title=(b["text/x-moz-url"].split("\n")[1]||"").trim(),c.title===c.uri&&(c.title=!1)),b["text/x-iri-source-title"]&&!c.title&&(c.title=b["text/x-iri-source-title"]),(b["text/html"]||b["text/x-iri-selected-html"])&&(d=a("<div>").html(b["text/html"]||b["text/x-iri-selected-html"]),c.image=d.find("[data-image]").attr("data-image")||c.image,c.uri=d.find("[data-uri]").attr("data-uri")||c.uri,c.title=d.find("[data-title]").attr("data-title")||c.title,c.description=d.find("[data-description]").attr("data-description")||c.description,c.clipPath=d.find("[data-clip-path]").attr("data-clip-path")||c.clipPath),c.title||(c.title=this.renkan.translate("Dragged resource"));for(var j=["title","description","uri","image"],k=0;k<j.length;k++){var l=j[k];(b["text/x-iri-"+l]||b[l])&&(c[l]=b["text/x-iri-"+l]||b[l]),("none"===c[l]||"null"===c[l])&&(c[l]=void 0)}return"function"==typeof this.renkan.options.drop_enhancer&&(c=this.renkan.options.drop_enhancer(c,b)),c},dropData:function(a,c){if(this.isEditable()){if(a["text/json"]||a["application/json"])try{var d=JSON.parse(a["text/json"]||a["application/json"]);b(a).extend(d)}catch(e){}var g="undefined"==typeof this.renkan.options.drop_handler?this.defaultDropHandler(a):this.renkan.options.drop_handler(a),h=this.canvas_$.offset(),i=new paper.Point([c.pageX-h.left,c.pageY-h.top]),j=this.toModelCoords(i),k={id:f.getUID("node"),created_by:this.renkan.current_user,uri:g.uri||"",title:g.title||"",description:g.description||"",image:g.image||"",color:g.color||void 0,clip_path:g.clipPath||void 0,position:{x:j.x,y:j.y}},l=this.renkan.project.addNode(k),m=this.getRepresentationByModel(l);"drop"===c.type&&m.openEditor()}},fullScreen:function(){var a,b=document.fullScreen||document.mozFullScreen||document.webkitIsFullScreen,c=this.renkan.$[0],d=["requestFullScreen","mozRequestFullScreen","webkitRequestFullScreen"],e=["cancelFullScreen","mozCancelFullScreen","webkitCancelFullScreen"];if(b){for(a=0;a<e.length;a++)if("function"==typeof document[e[a]]){document[e[a]]();break}}else for(a=0;a<d.length;a++)if("function"==typeof c[d[a]]){c[d[a]]();break}},zoomOut:function(){var a=this.scale*Math.SQRT1_2,b=new paper.Point([this.canvas_$.width(),this.canvas_$.height()]).multiply(.5*(1-Math.SQRT1_2)).add(this.offset.multiply(Math.SQRT1_2));this.setScale(a,b)},zoomIn:function(){var a=this.scale*Math.SQRT2,b=new paper.Point([this.canvas_$.width(),this.canvas_$.height()]).multiply(.5*(1-Math.SQRT2)).add(this.offset.multiply(Math.SQRT2));this.setScale(a,b)},addNodeBtn:function(){return this.click_mode===f._CLICKMODE_ADDNODE?(this.click_mode=!1,this.notif_$.hide()):(this.click_mode=f._CLICKMODE_ADDNODE,this.notif_$.text(this.renkan.translate("Click on the background canvas to add a node")).fadeIn()),!1},addEdgeBtn:function(){return this.click_mode===f._CLICKMODE_STARTEDGE||this.click_mode===f._CLICKMODE_ENDEDGE?(this.click_mode=!1,this.notif_$.hide()):(this.click_mode=f._CLICKMODE_STARTEDGE,this.notif_$.text(this.renkan.translate("Click on a first node to start the edge")).fadeIn()),!1},exportProject:function(){var a=this.renkan.project.toJSON(),d=(document.createElement("a"),a.id),e=d+".json";delete a.id,delete a._id,delete a.space_id;var g,h={};b.each(a.nodes,function(a){g=a.id||a._id,delete a._id,delete a.id,h[g]=a["@id"]=f.getUUID4()}),b.each(a.edges,function(a){delete a._id,delete a.id,a.to=h[a.to],a.from=h[a.from]}),b.each(a.views,function(a){g=a.id||a._id,delete a._id,delete a.id}),a.users=[];var i=JSON.stringify(a,null,2),j=new Blob([i],{type:"application/json;charset=utf-8"});c(j,e)},foldBins:function(){var a=this.$.find(".Rk-Fold-Bins"),b=this.renkan.$.find(".Rk-Bins"),c=this;b.offset().left<0?(b.animate({left:0},250),this.$.animate({left:300},250,function(){var a=c.$.width();paper.view.viewSize=new paper.Size([a,c.canvas_$.height()])}),a.html("«")):(b.animate({left:-300},250),this.$.animate({left:0},250,function(){var a=c.$.width();paper.view.viewSize=new paper.Size([a,c.canvas_$.height()])}),a.html("»"))},save:function(){},open:function(){}}),g}),"function"==typeof require.config&&require.config({paths:{jquery:"../lib/jquery.min",underscore:"../lib/underscore-min",filesaver:"../lib/FileSaver",requtils:"require-utils"}}),require(["renderer/baserepresentation","renderer/basebutton","renderer/noderepr","renderer/edge","renderer/tempedge","renderer/baseeditor","renderer/nodeeditor","renderer/edgeeditor","renderer/nodebutton","renderer/nodeeditbutton","renderer/noderemovebutton","renderer/noderevertbutton","renderer/nodelinkbutton","renderer/nodeenlargebutton","renderer/nodeshrinkbutton","renderer/edgeeditbutton","renderer/edgeremovebutton","renderer/edgerevertbutton","renderer/miniframe","renderer/scene"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t){var u=window.Rkns;"undefined"==typeof u.Renderer&&(u.Renderer={});var v=u.Renderer;v._BaseRepresentation=a,v._BaseButton=b,v.Node=c,v.Edge=d,v.TempEdge=e,v._BaseEditor=f,v.NodeEditor=g,v.EdgeEditor=h,v._NodeButton=i,v.NodeEditButton=j,v.NodeRemoveButton=k,v.NodeRevertButton=l,v.NodeLinkButton=m,v.NodeEnlargeButton=n,v.NodeShrinkButton=o,v.EdgeEditButton=p,v.EdgeRemoveButton=q,v.EdgeRevertButton=r,v.MiniFrame=s,v.Scene=t,startRenkan()}),define("main-renderer",function(){});
-//# sourceMappingURL=renkan.min.map
\ No newline at end of file
--- a/server/python/django/renkanmanager/static/renkanmanager/lib/renkan/renkan.min.map Wed Dec 17 16:31:10 2014 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-{"version":3,"file":"renkan.min.js","sources":["../../js/main.js","../../js/models.js","../../js/defaults.js","../../js/i18n.js","../../js/full-json.js","../../js/save-once.js","../../js/ldtjson-bin.js","../../js/list-bin.js","../../js/wikipedia-bin.js","paper-renderer.js"],"names":["root","Rkns","$","jQuery","_","pickerColors","__renkans","_BaseBin","_renkan","_opts","this","renkan","find","hide","addClass","appendTo","title_icon_$","_this","attr","href","title","translate","html","click","destroy","length","slideDown","resizeBins","refresh","count_$","title_$","main_$","auto_refresh","window","setInterval","prototype","detach","Renkan","push","options","defaults","property_files","each","f","getJSON","data","properties","concat","read_only","editor_mode","project","Models","Project","user_id","current_user","container","template","tabs","search_engines","current_user_list","UsersList","on","renderer","redrawUsers","colorPicker","_tmpl","map","c","join","show_editor","Renderer","Scene","search","_select","_input","_form","_search","type","Search","_key","key","getSearchTitle","className","getBgClass","_el","setSearchEngine","submit","val","search_engine","mouseenter","mouseleave","bins","_bin","Bin","elementDropped","_mainDiv","siblings","is","slideUp","_t","_models","get","where","uri","_model","highlightModel","mouseout","unhighlightAll","dragDrop","err","e","preventDefault","touch","originalEvent","changedTouches","off","canvas_$","offset","w","width","h","height","pageX","left","pageY","top","onMouseMove","div","document","createElement","appendChild","cloneNode","dropData","text/html","innerHTML","onMouseDown","onMouseUp","dataTransfer","setData","resize","lastsearch","lastval","Utils","regexpFromTextOrArray","source","tab","render","_text","i18n","language","substr","onStatusChange","_d","outerHeight","css","getUUID4","replace","r","Math","random","v","toString","getUID","pad","n","Date","ID_AUTO_INCREMENT","ID_BASE","getUTCFullYear","getUTCMonth","getUTCDate","_base","_n","_uidbase","getFullURL","url","test","img","Image","src","res","inherit","_baseClass","_callbefore","_class","apply","Array","slice","call","arguments","_init","_initialized","extend","replaceText","makeReplaceFunc","l","k","charsrx","txt","toLowerCase","remrx","j","remsrc","charsub","getSource","inp","removeChars","String","fromCharCode","RegExp","_textOrArray","testrx","replacerx","isempty","_replace","text","_MIN_DRAG_DISTANCE","_NODE_BUTTON_WIDTH","_EDGE_BUTTON_INNER","_EDGE_BUTTON_OUTER","_CLICKMODE_ADDNODE","_CLICKMODE_STARTEDGE","_CLICKMODE_ENDEDGE","_NODE_SIZE_STEP","LN2","_MIN_SCALE","_MAX_SCALE","_MOUSEMOVE_RATE","_DOUBLETAP_DELAY","_DOUBLETAP_DISTANCE","_USER_PLACEHOLDER","color","default_user_color","_BOOKMARKLET_CODE","shortenText","_maxlength","drawEditBox","_options","_coords","_path","_xmargin","_selector","tooltip_width","tooltip_padding","_height","_isLeft","x","paper","view","center","_left","tooltip_arrow_length","_right","_top","y","size","tooltip_margin","max","tooltip_arrow_width","min","_bottom","segments","point","add","closed","fillColor","GradientColor","Gradient","tooltip_top_color","tooltip_bottom_color","Backbone","obj","guid","RenkanModel","RelationalModel","idAttribute","constructor","_id","id","description","prepare","validate","addReference","_propName","_list","_default","_element","User","toJSON","Node","relations","HasOne","relatedModel","created_by","position","image","clip_path","shape","Edge","from","to","View","isArray","zoom_level","RosterUser","HasMany","reverseRelation","includeInJSON","addUser","_props","_user","findOrCreate","addNode","_node","addEdge","_edge","addView","_view","removeNode","remove","removeEdge","_project","users","nodes","edges","views","_item","initialize","filter","Model","site_id","Collection","model","navigator","userLanguage","static_url","show_bins","manual_save","show_top_bar","size_bug_fix","force_resize","allow_double_click","zoom_on_scroll","element_delete_delay","autoscale_padding","default_view","show_search_field","show_user_list","user_name_editable","user_color_editable","show_save_button","show_export_button","show_open_button","show_addnode_button","show_addedge_button","show_bookmarklet","show_fullscreen_button","home_button_url","home_button_title","show_minimap","minimap_width","minimap_height","minimap_padding","minimap_background_color","minimap_border_color","minimap_highlight_color","minimap_highlight_weight","buttons_background","buttons_label_color","buttons_label_font_size","show_node_circles","clip_node_images","node_images_fill_mode","node_size_base","node_stroke_width","selected_node_stroke_width","node_fill_color","highlighted_node_fill_color","node_label_distance","node_label_max_length","label_untitled_nodes","change_shapes","edge_stroke_width","selected_edge_stroke_width","edge_label_distance","edge_label_max_length","edge_arrow_length","edge_arrow_width","edge_gap_in_bundles","label_untitled_edges","tooltip_border_color","tooltip_border_width","show_node_editor_uri","show_node_editor_description","show_node_editor_size","show_node_editor_color","show_node_editor_image","show_node_editor_creator","uploaded_image_max_kb","show_node_tooltip_uri","show_node_tooltip_description","show_node_tooltip_color","show_node_tooltip_image","show_node_tooltip_creator","show_edge_editor_uri","show_edge_editor_color","show_edge_editor_direction","show_edge_editor_nodes","show_edge_editor_creator","show_edge_tooltip_uri","show_edge_tooltip_color","show_edge_tooltip_nodes","show_edge_tooltip_creator","fr","Edit Node","Edit Edge","Title:","URI:","Description:","From:","To:","Image URL:","Choose Image File:","Full Screen","Add Node","Add Edge","Save Project","Open Project","Auto-save enabled","Connection lost","Created by:","Zoom In","Zoom Out","Edit","Remove","Cancel deletion","Link to another node","Enlarge","Shrink","Click on the background canvas to add a node","Click on a first node to start the edge","Click on a second node to complete the edge","Wikipedia","Wikipedia in ","French","English","Japanese","Untitled project","Lignes de Temps","Loading, please wait","Edge color:","Node color:","Choose color","Change edge direction","Do you really wish to remove node ","Do you really wish to remove edge ","This file is not an image","Image size must be under ","Size:","KB","Choose from vocabulary:","SKOS Documentation properties","has note","has example","has definition","SKOS Semantic relations","has broader","has narrower","has related","Dublin Core Metadata","has contributor","covers","created by","has date","published by","has source","has subject","Dragged resource","Search the Web","Search in Bins","Close bin","Refresh bin","(untitled)","Select contents:","Drag items from this website, drop them in Renkan","Drag this button to your bookmark bar. When on a third-party website, click it to enable drag-and-drop from the website to Renkan.","Shapes available","Circle","Square","Diamond","Hexagone","Ellipse","Star","jsonIO","_proj","http_method","_load","redrawActive","_data","set","autoScale","_save","ajax","contentType","JSON","stringify","success","_thrSave","throttle","setTimeout","jsonIOSaveOnClick","_saveWarn","_onLeave","getdata","rx","matches","location","hash","match","_checkLeave","removeClass","save","hasClass","Ldt","ProjectBin","ldt_type","Resclass","console","error","tagTemplate","annotationTemplate","proj_id","project_id","ldt_platform","searchbase","highlight","_e","escape","convertTC","_ms","_res","_totalSeconds","abs","floor","_hours","_minutes","_seconds","_html","_projtitle","meta","count","tags","_tag","_title","htitle","encodedtitle","encodeURIComponent","annotations","_annotation","_description","content","_duration","end","begin","_img","hdescription","start","duration","mediaid","media","annotationid","show","dataType","lang","_q","ResultsBin","segmentTemplate","max_results","highlightrx","objects","_segment","abstract","_begin","start_ts","_end","iri_id","element_id","format","q","limit","ResourceList","resultTemplate","list","trim","_match","langs","en","ja","query","_result","encodeURI","snippet","define","_BaseRepresentation","_renderer","_changeBinding","redraw","_removeBinding","removeRepresentation","defer","_selectBinding","select","_unselectBinding","unselect","_super","_func","moveTo","trigger","unhighlight","mousedown","mouseup","getUtils","getRenderer","requtils","BaseRepresentation","_BaseButton","_pos","sector","_newTarget","source_representation","builders","circle","getShape","Path","getImageShape","radius","rectangle","Rectangle","ellipse","polygon","RegularPolygon","diamond","d","rotate","star","svg","path","ShapeBuilder","NodeRepr","node_layer","activate","buildShape","strokeWidth","h_ratio","labels_$","normal_buttons","NodeEditButton","NodeRemoveButton","NodeLinkButton","NodeEnlargeButton","NodeShrinkButton","pending_delete_buttons","NodeRevertButton","all_buttons","i","active_buttons","last_circle_radius","minimap","minimap_circle","__representation","miniframe","node_group","addChild","shapeBuilder","_dontRedrawEdges","_model_coords","Point","_baseRadius","exp","is_dragging","paper_coords","toPaperCoords","circle_radius","scale","forEach","b","setSectorSize","node_image","subtract","image_delta","multiply","old_act_btn","opacity","dashArray","selected","isEditable","highlighted","_color","strokeColor","_pc","lastImage","showImage","minipos","toMinimapCoords","miniradius","minisize","Size","fitBounds","ed","edge","repr","getRepresentationByModel","from_representation","to_representation","_image","image_cache","clipPath","hasClipPath","_clip","baseRadius","centerPoint","instructions","lastCoords","minX","Infinity","minY","maxX","maxY","transformCoords","tabc","relative","newCoords","parseFloat","isY","instr","coords","lineTo","cubicCurveTo","quadraticCurveTo","_raster","Raster","locked","Group","clipped","_circleClip","divide","throttledPaperDraw","paperShift","_delta","openEditor","removeRepresentationsOfType","_editor","addRepresentation","draw","_uri","undefined","textToReplace","hlvalue","saveCoords","toModelCoords","_event","_isTouch","unselectAll","click_target","edge_layer","bundle","addToBundles","line","arrow","arrow_angle","EdgeEditButton","EdgeRemoveButton","EdgeRevertButton","minimap_line","_p0a","_p1a","_v","_r","_u","_ortho","_group_pos","getPosition","_p0b","_p1b","_a","angle","_textdelta","_handle","handleIn","handleOut","_textpos","transform","-moz-transform","-webkit-transform","text_angle","reject","TempEdge","_p0","_p1","end_pos","_c","_hitResult","hitTest","findTarget","_endDrag","item","_target","_destmodel","_BaseEditor","buttons_layer","editor_block","_pts","range","editor_$","BaseEditor","NodeEditor","readOnlyTemplate","_created_by","_template","_image_placeholder","_size","node","has_creator","short_uri","image_placeholder","created_by_color","created_by_title","closeEditor","onFieldChange","shape_changed","keyCode","change","files","FileReader","alert","onload","target","result","readAsDataURL","focus","_picker","hover","shiftSize","_newsize","titlehtml","load","EdgeEditor","_from_model","_to_model","from_title","to_title","from_color","to_color","BaseButton","_NodeButton","sectorInner","lastSectorInner","drawSector","startAngle","endAngle","imageName","NodeButton","delid","delete_list","time","valueOf","confirm","unset","_off","_point","addTempEdge","MiniFrame","filesaver","representations","notif_$","setup","initialScale","totalScroll","mouse_down","selected_target","Layer","background_layer","topleft","bounds","bottomRight","cliprectangle","bundles","click_mode","_allowScroll","_originalScale","_zooming","_lastTapX","_lastTapY","icon_cache","imgname","throttledMouseMove","mousemove","mousewheel","onScroll","touchstart","_touches","touches","_lastTap","pow","onDoubleClick","touchmove","_newScale","_scaleRatio","_newOffset","setScale","touchend","dblclick","dragover","dragenter","dragleave","drop","types","t","getData","parse","bindClick","selector","fname","evt","last","isNaN","parseInt","fadeIn","delay","fadeOut","mouseover","onResize","_viewSize","parent","_thRedraw","addRepresentations","_thRedrawUsers","el","_delay","fixSize","$cpwrapper","$cplist","$this","rxs","_now","findWhere","delete_scheduled","rescaleMinimap","_autoscale","viewSize","_repr","_inR","_outR","_startAngle","_endAngle","_padding","_imgname","_caption","_startRads","PI","_endRads","_startdx","sin","_startdy","cos","_startXIn","_startYIn","_startXOut","_startYOut","_enddx","_enddy","_endXIn","_endYIn","_endXOut","_endYOut","_centerR","_centerRads","_centerX","_centerY","_centerXIn","_centerXOut","_centerYIn","_centerYOut","_textX","_textY","arcTo","PointText","characterStyle","fontSize","paragraphStyle","justification","visible","_visible","_restPos","_grp","_imgdelta","_currentPos","_edgeRepr","_bundle","_er","_dir","indexOf","savebtn","tip","_offset","force_view","_xx","_yy","_minx","_miny","_maxx","_maxy","_scale","at","redrawMiniframe","bottomright","_type","RendererType","_collection","userTemplate","allUsers","models","ulistHtml","$userpanel","$name","$cpitems","$colorsquare","$input","blur","empty","name","background","_representation","_representations","_from","_tmpEdge","last_point","_scrolldelta","SQRT2","SQRT1_2","defaultDropHandler","newNode","tweetdiv","_svgimgs","_svgpaths","_imgs","_as","split","fields","drop_enhancer","jsondata","drop_handler","_nodedata","fullScreen","_isFull","mozFullScreen","webkitIsFullScreen","_requestMethods","_cancelMethods","zoomOut","zoomIn","addNodeBtn","addEdgeBtn","exportProject","projectJSON","projectId","fileNameToSaveAs","space_id","objId","idsMap","projectJSONStr","blob","Blob","foldBins","foldBinsButton","animate","open","require","config","paths","jquery","underscore","startRenkan"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;CAGA,SAAUA,GAEV,YAEyB,iBAAdA,GAAKC,OACZD,EAAKC,QAGT,IAAIA,GAAOD,EAAKC,KACZC,EAAID,EAAKC,EAAIF,EAAKG,OAClBC,EAAIH,EAAKG,EAAIJ,EAAKI,CAEtBH,GAAKI,cAAgB,UAAW,UAAW,UAAW,UAAW,UAAW,UAAW,UAAW,UAC9F,UAAW,UAAW,UAAW,UAAW,UAAW,UAAW,UAAW,UAC7E,UAAW,UAAW,UAAW,UAAW,UAAW,UAAW,UAAW,UAC7E,UAAW,UAAW,UAAW,UAAW,UAAW,UAAW,UAAW,UAC7E,UAAW,UAAW,UAAW,UAAW,UAAW,UAAW,UAAW,UAC7E,UAAW,UAAW,UAAW,UAAW,UAAW,UAAW,UAAW,UAC7E,UAAW,UAAW,UAAW,UAAW,UAAW,UAAW,UAAW,UAC7E,UAAW,UAAW,UAAW,UAAW,UAAW,UAAW,UAAW,WAEjFJ,EAAKK,YAEL,IAAIC,GAAWN,EAAKM,SAAW,SAASC,EAASC,GAC7C,GAAuB,mBAAZD,GAAyB,CAChCE,KAAKC,OAASH,EACdE,KAAKC,OAAOT,EAAEU,KAAK,gBAAgBC,OACnCH,KAAKR,EAAID,EAAKC,EAAE,QACXY,SAAS,UACTC,SAASP,EAAQN,EAAEU,KAAK,iBAC7BF,KAAKM,aAAef,EAAKC,EAAE,UACtBY,SAAS,qBACTC,SAASL,KAAKR,EAEnB,IAAIe,GAAQP,IAEZT,G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m/B,gBAGJhe,OAAO,gBAAiB","sourcesContent":["\n/* Declaring the Renkan Namespace Rkns and Default values */\n\n(function(root) {\n\n\"use strict\";\n\nif (typeof root.Rkns !== \"object\") {\n root.Rkns = {};\n}\n\nvar Rkns = root.Rkns;\nvar $ = Rkns.$ = root.jQuery;\nvar _ = Rkns._ = root._;\n\nRkns.pickerColors = [\"#8f1919\", \"#a80000\", \"#d82626\", \"#ff0000\", \"#e87c7c\", \"#ff6565\", \"#f7d3d3\", \"#fecccc\",\n \"#8f5419\", \"#a85400\", \"#d87f26\", \"#ff7f00\", \"#e8b27c\", \"#ffb265\", \"#f7e5d3\", \"#fee5cc\",\n \"#8f8f19\", \"#a8a800\", \"#d8d826\", \"#feff00\", \"#e8e87c\", \"#feff65\", \"#f7f7d3\", \"#fefecc\",\n \"#198f19\", \"#00a800\", \"#26d826\", \"#00ff00\", \"#7ce87c\", \"#65ff65\", \"#d3f7d3\", \"#ccfecc\",\n \"#198f8f\", \"#00a8a8\", \"#26d8d8\", \"#00feff\", \"#7ce8e8\", \"#65feff\", \"#d3f7f7\", \"#ccfefe\",\n \"#19198f\", \"#0000a8\", \"#2626d8\", \"#0000ff\", \"#7c7ce8\", \"#6565ff\", \"#d3d3f7\", \"#ccccfe\",\n \"#8f198f\", \"#a800a8\", \"#d826d8\", \"#ff00fe\", \"#e87ce8\", \"#ff65fe\", \"#f7d3f7\", \"#feccfe\",\n \"#000000\", \"#242424\", \"#484848\", \"#6d6d6d\", \"#919191\", \"#b6b6b6\", \"#dadada\", \"#ffffff\"];\n\nRkns.__renkans = [];\n\nvar _BaseBin = Rkns._BaseBin = function(_renkan, _opts) {\n if (typeof _renkan !== \"undefined\") {\n this.renkan = _renkan;\n this.renkan.$.find(\".Rk-Bin-Main\").hide();\n this.$ = Rkns.$('<li>')\n .addClass(\"Rk-Bin\")\n .appendTo(_renkan.$.find(\".Rk-Bin-List\"));\n this.title_icon_$ = Rkns.$('<span>')\n .addClass(\"Rk-Bin-Title-Icon\")\n .appendTo(this.$);\n\n var _this = this;\n\n Rkns.$('<a>')\n .attr({\n href: \"#\",\n title: _renkan.translate(\"Close bin\")\n })\n .addClass(\"Rk-Bin-Close\")\n .html('×')\n .appendTo(this.$)\n .click(function() {\n _this.destroy();\n if (!_renkan.$.find(\".Rk-Bin-Main:visible\").length) {\n _renkan.$.find(\".Rk-Bin-Main:last\").slideDown();\n }\n _renkan.resizeBins();\n return false;\n });\n Rkns.$('<a>')\n .attr({\n href: \"#\",\n title: _renkan.translate(\"Refresh bin\")\n })\n .addClass(\"Rk-Bin-Refresh\")\n .appendTo(this.$)\n .click(function() {\n _this.refresh();\n return false;\n });\n this.count_$ = Rkns.$('<div>')\n .addClass(\"Rk-Bin-Count\")\n .appendTo(this.$);\n this.title_$ = Rkns.$('<h2>')\n .addClass(\"Rk-Bin-Title\")\n .appendTo(this.$);\n this.main_$ = Rkns.$('<div>')\n .addClass(\"Rk-Bin-Main\")\n .appendTo(this.$)\n .html('<h4 class=\"Rk-Bin-Loading\">' + _renkan.translate(\"Loading, please wait\") + '</h4>');\n this.title_$.html(_opts.title || '(new bin)');\n this.renkan.resizeBins();\n\n if (_opts.auto_refresh) {\n window.setInterval(function() {\n _this.refresh();\n },_opts.auto_refresh);\n }\n }\n};\n\n_BaseBin.prototype.destroy = function() {\n this.$.detach();\n this.renkan.resizeBins();\n};\n\n/* Point of entry */\n\nvar Renkan = Rkns.Renkan = function(_opts) {\n var _this = this;\n\n Rkns.__renkans.push(this);\n\n this.options = _.defaults(_opts, Rkns.defaults);\n\n _(this.options.property_files).each(function(f) {\n Rkns.$.getJSON(f, function(data) {\n _this.options.properties = _this.options.properties.concat(data);\n });\n });\n\n this.read_only = this.options.read_only || !this.options.editor_mode;\n\n this.project = new Rkns.Models.Project();\n\n if (typeof this.options.user_id !== \"undefined\") {\n this.current_user = this.options.user_id;\n }\n this.$ = Rkns.$(\"#\" + this.options.container);\n this.$\n .addClass(\"Rk-Main\")\n .html(this.template(this));\n\n this.tabs = [];\n this.search_engines = [];\n\n this.current_user_list = new Rkns.Models.UsersList();\n\n this.current_user_list.on(\"add remove\", function() {\n if (this.renderer) {\n this.renderer.redrawUsers();\n }\n });\n\n this.colorPicker = (function() {\n var _tmpl = _.template('<li data-color=\"<%=c%>\" style=\"background: <%=c%>\"></li>');\n return '<ul class=\"Rk-Edit-ColorPicker\">' + Rkns.pickerColors.map(function(c) { return _tmpl({c:c});}).join(\"\") + '</ul>';\n })();\n\n if (this.options.show_editor) {\n this.renderer = new Rkns.Renderer.Scene(this);\n }\n\n if (!this.options.search.length) {\n this.$.find(\".Rk-Web-Search-Form\").detach();\n } else {\n var _tmpl = _.template('<li class=\"<%= className %>\" data-key=\"<%= key %>\"><%= title %></li>'),\n _select = this.$.find(\".Rk-Search-List\"),\n _input = this.$.find(\".Rk-Web-Search-Input\"),\n _form = this.$.find(\".Rk-Web-Search-Form\");\n _(this.options.search).each(function(_search, _key) {\n if (Rkns[_search.type] && Rkns[_search.type].Search) {\n _this.search_engines.push(new Rkns[_search.type].Search(_this, _search));\n }\n });\n _select.html(\n _(this.search_engines).map(function(_search, _key) {\n return _tmpl({\n key: _key,\n title: _search.getSearchTitle(),\n className: _search.getBgClass()\n });\n }).join(\"\")\n );\n _select.find(\"li\").click(function() {\n var _el = Rkns.$(this);\n _this.setSearchEngine(_el.attr(\"data-key\"));\n _form.submit();\n });\n _form.submit(function() {\n if (_input.val()) {\n var _search = _this.search_engine;\n _search.search(_input.val());\n }\n return false;\n });\n this.$.find(\".Rk-Search-Current\").mouseenter(\n function() { _select.slideDown(); }\n );\n this.$.find(\".Rk-Search-Select\").mouseleave(\n function() { _select.hide(); }\n );\n this.setSearchEngine(0);\n }\n _(this.options.bins).each(function(_bin) {\n if (Rkns[_bin.type] && Rkns[_bin.type].Bin) {\n _this.tabs.push(new Rkns[_bin.type].Bin(_this, _bin));\n }\n });\n\n var elementDropped = false;\n\n this.$.find(\".Rk-Bins\")\n .on(\"click\",\".Rk-Bin-Title,.Rk-Bin-Title-Icon\", function() {\n var _mainDiv = Rkns.$(this).siblings(\".Rk-Bin-Main\");\n if (_mainDiv.is(\":hidden\")) {\n _this.$.find(\".Rk-Bin-Main\").slideUp();\n _mainDiv.slideDown();\n }\n });\n\n if (this.options.show_editor) {\n\n this.$.find(\".Rk-Bins\").on(\"mouseover\", \".Rk-Bin-Item\", function(_e) {\n var _t = Rkns.$(this);\n if (_t && $(_t).attr(\"data-uri\")) {\n var _models = _this.project.get(\"nodes\").where({\n uri: $(_t).attr(\"data-uri\")\n });\n _(_models).each(function(_model) {\n _this.renderer.highlightModel(_model);\n });\n }\n }).mouseout(function() {\n _this.renderer.unhighlightAll();\n }).on(\"mousemove\", \".Rk-Bin-Item\", function(e) {\n try {\n this.dragDrop();\n }\n catch(err) {}\n }).on(\"touchstart\", \".Rk-Bin-Item\", function(e) {\n elementDropped = false;\n }).on(\"touchmove\", \".Rk-Bin-Item\", function(e) {\n e.preventDefault();\n var touch = e.originalEvent.changedTouches[0],\n off = _this.renderer.canvas_$.offset(),\n w = _this.renderer.canvas_$.width(),\n h = _this.renderer.canvas_$.height();\n if (touch.pageX >= off.left && touch.pageX < (off.left + w) && touch.pageY >= off.top && touch.pageY < (off.top + h)) {\n if (elementDropped) {\n _this.renderer.onMouseMove(touch, true);\n } else {\n elementDropped = true;\n var div = document.createElement('div');\n div.appendChild(this.cloneNode(true));\n _this.renderer.dropData({\"text/html\": div.innerHTML}, touch);\n _this.renderer.onMouseDown(touch, true);\n }\n }\n }).on(\"touchend\", \".Rk-Bin-Item\", function(e) {\n if (elementDropped) {\n _this.renderer.onMouseUp(e.originalEvent.changedTouches[0], true);\n }\n elementDropped = false;\n }).on(\"dragstart\", \".Rk-Bin-Item\", function(e) {\n var div = document.createElement('div');\n div.appendChild(this.cloneNode(true));\n try {\n e.originalEvent.dataTransfer.setData(\"text/html\",div.innerHTML);\n }\n catch(err) {\n e.originalEvent.dataTransfer.setData(\"text\",div.innerHTML);\n }\n });\n\n }\n\n Rkns.$(window).resize(function() {\n _this.resizeBins();\n });\n\n var lastsearch = false, lastval = '';\n\n this.$.find(\".Rk-Bins-Search-Input\").on(\"change keyup paste input\", function() {\n var val = Rkns.$(this).val();\n if (val === lastval) {\n return;\n }\n var search = Rkns.Utils.regexpFromTextOrArray(val.length > 1 ? val: null);\n if (search.source === lastsearch) {\n return;\n }\n lastsearch = search.source;\n _(_this.tabs).each(function(tab) {\n tab.render(search);\n });\n\n });\n this.$.find(\".Rk-Bins-Search-Form\").submit(function() {\n return false;\n });\n\n};\n\nRenkan.prototype.template = _.template(\n '<% if (options.show_bins) { %><div class=\"Rk-Bins\"><div class=\"Rk-Bins-Head\"><h2 class=\"Rk-Bins-Title\"><%- translate(\"Select contents:\")%></h2>' +\n '<form class=\"Rk-Web-Search-Form Rk-Search-Form\"><input class=\"Rk-Web-Search-Input Rk-Search-Input\" type=\"search\" placeholder=\"<%- translate(\"Search the Web\") %>\" />' +\n '<div class=\"Rk-Search-Select\"><div class=\"Rk-Search-Current\"></div><ul class=\"Rk-Search-List\"></ul></div>' +\n '<input type=\"submit\" value=\"\" class=\"Rk-Web-Search-Submit Rk-Search-Submit\" title=\"<%- translate(\"Search the Web\") %>\" /></form>' +\n '<form class=\"Rk-Bins-Search-Form Rk-Search-Form\"><input class=\"Rk-Bins-Search-Input Rk-Search-Input\" type=\"search\" placeholder=\"<%- translate(\"Search in Bins\") %>\" />' +\n '<input type=\"submit\" value=\"\" class=\"Rk-Bins-Search-Submit Rk-Search-Submit\" title=\"<%- translate(\"Search in Bins\") %>\" /></form></div>' +\n '<ul class=\"Rk-Bin-List\"></ul></div><% } %>' +\n '<% if (options.show_editor) { %><div class=\"Rk-Render Rk-Render-<% if (options.show_bins) { %>Panel<% } else { %>Full<% } %>\"></div><% } %>'\n);\n\nRenkan.prototype.translate = function(_text) {\n if (Rkns.i18n[this.options.language] && Rkns.i18n[this.options.language][_text]) {\n return Rkns.i18n[this.options.language][_text];\n }\n if (this.options.language.length > 2 && Rkns.i18n[this.options.language.substr(0,2)] && Rkns.i18n[this.options.language.substr(0,2)][_text]) {\n return Rkns.i18n[this.options.language.substr(0,2)][_text];\n }\n return _text;\n};\n\nRenkan.prototype.onStatusChange = function() {\n this.renderer.onStatusChange();\n};\n\nRenkan.prototype.setSearchEngine = function(_key) {\n this.search_engine = this.search_engines[_key];\n this.$.find(\".Rk-Search-Current\").attr(\"class\",\"Rk-Search-Current \" + this.search_engine.getBgClass());\n};\n\nRenkan.prototype.resizeBins = function() {\n var _d = + this.$.find(\".Rk-Bins-Head\").outerHeight();\n this.$.find(\".Rk-Bin-Title:visible\").each(function() {\n _d += Rkns.$(this).outerHeight();\n });\n this.$.find(\".Rk-Bin-Main\").css({\n height: this.$.find(\".Rk-Bins\").height() - _d\n });\n};\n\n/* Utility functions */\nvar getUUID4 = function() {\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {\n var r = Math.random()*16|0, v = c === 'x' ? r : (r&0x3|0x8);\n return v.toString(16);\n });\n};\n\nRkns.Utils = {\n getUUID4 : getUUID4,\n getUID : (function() {\n function pad(n){\n return n<10 ? '0'+n : n;\n }\n var _d = new Date(),\n ID_AUTO_INCREMENT = 0,\n ID_BASE = _d.getUTCFullYear() + '-' +\n pad(_d.getUTCMonth()+1) + '-' +\n pad(_d.getUTCDate()) + '-' +\n getUUID4();\n return function(_base) {\n var _n = (++ID_AUTO_INCREMENT).toString(16),\n _uidbase = (typeof _base === \"undefined\" ? \"\" : _base + \"-\" );\n while (_n.length < 4) { _n = '0' + _n; }\n return _uidbase + ID_BASE + '-' + _n;\n };\n })(),\n getFullURL : function(url) {\n\n if(typeof(url) === 'undefined' || url == null ) {\n return \"\";\n }\n if(/https?:\\/\\//.test(url)) {\n return url;\n }\n var img = new Image();\n img.src = url;\n var res = img.src;\n img.src = null;\n return res;\n\n },\n inherit : function(_baseClass, _callbefore) {\n\n var _class = function(_arg) {\n if (typeof _callbefore === \"function\") {\n _callbefore.apply(this, Array.prototype.slice.call(arguments, 0));\n }\n _baseClass.apply(this, Array.prototype.slice.call(arguments, 0));\n if (typeof this._init === \"function\" && !this._initialized) {\n this._init.apply(this, Array.prototype.slice.call(arguments, 0));\n this._initialized = true;\n }\n };\n _(_class.prototype).extend(_baseClass.prototype);\n\n return _class;\n\n },\n regexpFromTextOrArray: (function() {\n var charsub = [\n '[aáàâä]',\n '[cç]',\n '[eéèêë]',\n '[iíìîï]',\n '[oóòôö]',\n '[uùûü]'\n ],\n removeChars = [\n String.fromCharCode(768), String.fromCharCode(769), String.fromCharCode(770), String.fromCharCode(771), String.fromCharCode(807),\n \"{\", \"}\", \"(\", \")\", \"[\", \"]\", \"【\", \"】\", \"、\", \"・\", \"‥\", \"。\", \"「\", \"」\", \"『\", \"』\", \"〜\", \":\", \"!\", \"?\", \" \",\n \",\", \" \", \";\", \"(\", \")\", \".\", \"*\", \"+\", \"\\\\\", \"?\", \"|\", \"{\", \"}\", \"[\", \"]\", \"^\", \"#\", \"/\"\n ],\n remsrc = \"[\\\\\" + removeChars.join(\"\\\\\") + \"]\",\n remrx = new RegExp(remsrc, \"gm\"),\n charsrx = _(charsub).map(function(c) {\n return new RegExp(c);\n });\n\n function replaceText(_text) {\n var txt = _text.toLowerCase().replace(remrx,\"\"), src = \"\";\n function makeReplaceFunc(l) {\n return function(k,v) {\n l = l.replace(charsrx[k], v);\n };\n }\n for (var j = 0; j < txt.length; j++) {\n if (j) {\n src += remsrc + \"*\";\n }\n var l = txt[j];\n _(charsub).each(makeReplaceFunc(l));\n src += l;\n }\n return src;\n }\n\n function getSource(inp) {\n switch (typeof inp) {\n case \"string\":\n return replaceText(inp);\n case \"object\":\n var src = '';\n _(inp).each(function(v) {\n var res = getSource(v);\n if (res) {\n if (src) {\n src += '|';\n }\n src += res;\n }\n });\n return src;\n }\n return '';\n }\n\n return function(_textOrArray) {\n var source = getSource(_textOrArray);\n if (source) {\n var testrx = new RegExp( source, \"im\"),\n replacerx = new RegExp( '(' + source + ')', \"igm\");\n return {\n isempty: false,\n source: source,\n test: function(_t) { return testrx.test(_t); },\n replace: function(_text, _replace) { return _text.replace(replacerx, _replace); }\n };\n } else {\n return {\n isempty: true,\n source: '',\n test: function() { return true; },\n replace: function(_text) { return text; }\n };\n }\n };\n })(),\n /* The minimum distance (in pixels) the mouse has to move to consider an element was dragged */\n _MIN_DRAG_DISTANCE: 2,\n /* Distance between the inner and outer radius of buttons that appear when hovering on a node */\n _NODE_BUTTON_WIDTH: 40,\n\n _EDGE_BUTTON_INNER: 2,\n _EDGE_BUTTON_OUTER: 40,\n /* Constants used to know if a specific action is to be performed when clicking on the canvas */\n _CLICKMODE_ADDNODE: 1,\n _CLICKMODE_STARTEDGE: 2,\n _CLICKMODE_ENDEDGE: 3,\n /* Node size step: Used to calculate the size change when clicking the +/- buttons */\n _NODE_SIZE_STEP: Math.LN2/4,\n _MIN_SCALE: 1/20,\n _MAX_SCALE: 20,\n _MOUSEMOVE_RATE: 80,\n _DOUBLETAP_DELAY: 800,\n /* Maximum distance in pixels (squared, to reduce calculations)\n * between two taps when double-tapping on a touch terminal */\n _DOUBLETAP_DISTANCE: 20*20,\n /* A placeholder so a default colour is displayed when a node has a null value for its user property */\n _USER_PLACEHOLDER: function(_renkan) {\n return {\n color: _renkan.options.default_user_color,\n title: _renkan.translate(\"(unknown user)\"),\n get: function(attr) {\n return this[attr] || false;\n }\n };\n },\n /* The code for the \"Drag and Add Bookmarklet\", slightly minified and with whitespaces removed, though\n * it doesn't seem that it's still a requirement in newer browsers (i.e. the ones compatibles with canvas drawing)\n */\n _BOOKMARKLET_CODE: function(_renkan) {\n return \"(function(a,b,c,d,e,f,h,i,j,k,l,m,n,o,p,q,r){a=document;b=a.body;c=a.location.href;j='draggable';m='text/x-iri-';d=a.createElement('div');d.innerHTML='<p_style=\\\"position:fixed;top:0;right:0;font:bold_18px_sans-serif;color:#fff;background:#909;padding:10px;z-index:100000;\\\">\" +\n _renkan.translate(\"Drag items from this website, drop them in Renkan\").replace(/ /g,\"_\") +\n \"</p>'.replace(/_/g,String.fromCharCode(32));b.appendChild(d);e=[{r:/https?:\\\\/\\\\/[^\\\\/]*twitter\\\\.com\\\\//,s:'.tweet',n:'twitter'},{r:/https?:\\\\/\\\\/[^\\\\/]*google\\\\.[^\\\\/]+\\\\//,s:'.g',n:'google'},{r:/https?:\\\\/\\\\/[^\\\\/]*lemonde\\\\.fr\\\\//,s:'[data-vr-contentbox]',n:'lemonde'}];f=false;e.forEach(function(g){if(g.r.test(c)){f=g;}});if(f){h=function(){Array.prototype.forEach.call(a.querySelectorAll(f.s),function(i){i[j]=true;k=i.style;k.borderWidth='2px';k.borderColor='#909';k.borderStyle='solid';k.backgroundColor='rgba(200,0,180,.1)';})};window.setInterval(h,500);h();};a.addEventListener('dragstart',function(k){l=k.dataTransfer;l.setData(m+'source-uri',c);l.setData(m+'source-title',a.title);n=k.target;if(f){o=n;while(!o.attributes[j]){o=o.parentNode;if(o==b){break;}}}if(f&&o.attributes[j]){p=o.cloneNode(true);l.setData(m+'specific-site',f.n)}else{q=a.getSelection();if(q.type==='Range'||!q.type){p=q.getRangeAt(0).cloneContents();}else{p=n.cloneNode();}}r=a.createElement('div');r.appendChild(p);l.setData('text/x-iri-selected-text',r.textContent.trim());l.setData('text/x-iri-selected-html',r.innerHTML);},false);})();\";\n },\n /* Shortens text to the required length then adds ellipsis */\n shortenText: function(_text, _maxlength) {\n return (_text.length > _maxlength ? (_text.substr(0,_maxlength) + '…') : _text);\n },\n /* Drawing an edit box with an arrow and positioning the edit box according to the position of the node/edge being edited\n * Called by Rkns.Renderer.NodeEditor and Rkns.Renderer.EdgeEditor */\n drawEditBox: function(_options, _coords, _path, _xmargin, _selector) {\n _selector.css({\n width: ( _options.tooltip_width - 2* _options.tooltip_padding )\n });\n var _height = _selector.outerHeight() + 2* _options.tooltip_padding,\n _isLeft = (_coords.x < paper.view.center.x ? 1 : -1),\n _left = _coords.x + _isLeft * ( _xmargin + _options.tooltip_arrow_length ),\n _right = _coords.x + _isLeft * ( _xmargin + _options.tooltip_arrow_length + _options.tooltip_width ),\n _top = _coords.y - _height / 2;\n if (_top + _height > (paper.view.size.height - _options.tooltip_margin)) {\n _top = Math.max( paper.view.size.height - _options.tooltip_margin, _coords.y + _options.tooltip_arrow_width / 2 ) - _height;\n }\n if (_top < _options.tooltip_margin) {\n _top = Math.min( _options.tooltip_margin, _coords.y - _options.tooltip_arrow_width / 2 );\n }\n var _bottom = _top + _height;\n /* jshint laxbreak:true */\n _path.segments[0].point\n = _path.segments[7].point\n = _coords.add([_isLeft * _xmargin, 0]);\n _path.segments[1].point.x\n = _path.segments[2].point.x\n = _path.segments[5].point.x\n = _path.segments[6].point.x\n = _left;\n _path.segments[3].point.x\n = _path.segments[4].point.x\n = _right;\n _path.segments[2].point.y\n = _path.segments[3].point.y\n = _top;\n _path.segments[4].point.y\n = _path.segments[5].point.y\n = _bottom;\n _path.segments[1].point.y = _coords.y - _options.tooltip_arrow_width / 2;\n _path.segments[6].point.y = _coords.y + _options.tooltip_arrow_width / 2;\n _path.closed = true;\n _path.fillColor = new paper.GradientColor(new paper.Gradient([_options.tooltip_top_color, _options.tooltip_bottom_color]), [0,_top], [0, _bottom]);\n _selector.css({\n left: (_options.tooltip_padding + Math.min(_left, _right)),\n top: (_options.tooltip_padding + _top)\n });\n return _path;\n }\n};\n})(window);\n\n/* END main.js */\n","(function() {\n \"use strict\";\n var root = this;\n\n var Backbone = root.Backbone;\n\n var Models = root.Rkns.Models = {};\n\n\n Models.getUID = function(obj) {\n var guid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {\n var r = Math.random()*16|0, v = c === 'x' ? r : (r&0x3|0x8);\n return v.toString(16);\n });\n if(typeof obj !== 'undefined') {\n return obj.type + \"-\" + guid;\n }\n else {\n return guid;\n }\n };\n\n\n var RenkanModel = Backbone.RelationalModel.extend({\n idAttribute : \"_id\",\n constructor: function(options) {\n\n if (typeof options !== \"undefined\") {\n options._id = options._id || options.id || Models.getUID(this);\n options.title = options.title || \"\";\n options.description = options.description || \"\";\n options.uri = options.uri || \"\";\n\n if(typeof this.prepare === \"function\") {\n options = this.prepare(options);\n }\n }\n Backbone.RelationalModel.prototype.constructor.call(this, options);\n },\n validate: function() {\n if(!this.type) {\n return \"object has no type\";\n }\n },\n addReference : function(_options, _propName, _list, _id, _default) {\n var _element = _list.get(_id);\n if (typeof _element === \"undefined\" && typeof _default !== \"undefined\") {\n _options[_propName ] = _default;\n }\n else {\n _options[_propName ] = _element;\n }\n }\n });\n\n // USER\n var User = Models.User = RenkanModel.extend({\n type: \"user\",\n prepare: function(options) {\n options.color = options.color || \"#666666\";\n return options;\n },\n toJSON: function() {\n return {\n _id: this.get(\"_id\"),\n title: this.get(\"title\"),\n uri: this.get(\"uri\"),\n description: this.get(\"description\"),\n color: this.get(\"color\")\n };\n }\n });\n\n // NODE\n var Node = Models.Node = RenkanModel.extend({\n type: \"node\",\n relations: [{\n type: Backbone.HasOne,\n key: \"created_by\",\n relatedModel: User\n }],\n prepare: function(options) {\n var project = options.project;\n this.addReference(options, \"created_by\", project.get(\"users\"), options.created_by, project.current_user);\n options.description = options.description || \"\";\n return options;\n },\n toJSON: function() {\n return {\n _id: this.get(\"_id\"),\n title: this.get(\"title\"),\n uri: this.get(\"uri\"),\n description: this.get(\"description\"),\n position: this.get(\"position\"),\n image: this.get(\"image\"),\n color: this.get(\"color\"),\n created_by: this.get(\"created_by\") ? this.get(\"created_by\").get(\"_id\") : null,\n size: this.get(\"size\"),\n clip_path: this.get(\"clip_path\"),\n shape: this.get(\"shape\")\n };\n }\n });\n\n // EDGE\n var Edge = Models.Edge = RenkanModel.extend({\n type: \"edge\",\n relations: [\n {\n type: Backbone.HasOne,\n key: \"created_by\",\n relatedModel: User\n },\n {\n type: Backbone.HasOne,\n key: \"from\",\n relatedModel: Node\n },\n {\n type: Backbone.HasOne,\n key: \"to\",\n relatedModel: Node\n }\n ],\n prepare: function(options) {\n var project = options.project;\n this.addReference(options, \"created_by\", project.get(\"users\"), options.created_by, project.current_user);\n this.addReference(options, \"from\", project.get(\"nodes\"), options.from);\n this.addReference(options, \"to\", project.get(\"nodes\"), options.to);\n return options;\n },\n toJSON: function() {\n return {\n _id: this.get(\"_id\"),\n title: this.get(\"title\"),\n uri: this.get(\"uri\"),\n description: this.get(\"description\"),\n from: this.get(\"from\") ? this.get(\"from\").get(\"_id\") : null,\n to: this.get(\"to\") ? this.get(\"to\").get(\"_id\") : null,\n color: this.get(\"color\"),\n created_by: this.get(\"created_by\") ? this.get(\"created_by\").get(\"_id\") : null\n };\n }\n });\n\n // View\n var View = Models.View = RenkanModel.extend({\n type: \"view\",\n relations: [\n {\n type: Backbone.HasOne,\n key: \"created_by\",\n relatedModel: User\n }\n ],\n prepare: function(options) {\n var project = options.project;\n this.addReference(options, \"created_by\", project.get(\"users\"), options.created_by, project.current_user);\n options.description = options.description || \"\";\n if(typeof options.offset !== \"undefined\") {\n var offset = {};\n if (Array.isArray(options.offset)) {\n offset.x = options.offset[0];\n offset.y = options.offset.length > 1 ? options.offset[1] : options.offset[0];\n }\n else if (options.offset.x != null) {\n offset.x = options.offset.x;\n offset.y = options.offset.y;\n }\n options.offset = offset;\n }\n return options;\n },\n toJSON: function() {\n return {\n _id: this.get(\"_id\"),\n zoom_level: this.get(\"zoom_level\"),\n offset: this.get(\"offset\"),\n title: this.get(\"title\"),\n description: this.get(\"description\"),\n created_by: this.get(\"created_by\") ? this.get(\"created_by\").get(\"_id\") : null\n // Don't need project id\n };\n }\n });\n\n // PROJECT\n var Project = Models.Project = RenkanModel.extend({\n type: \"project\",\n relations: [\n {\n type: Backbone.HasMany,\n key: \"users\",\n relatedModel: User,\n reverseRelation: {\n key: 'project',\n includeInJSON: '_id'\n }\n },\n {\n type: Backbone.HasMany,\n key: \"nodes\",\n relatedModel: Node,\n reverseRelation: {\n key: 'project',\n includeInJSON: '_id'\n }\n },\n {\n type: Backbone.HasMany,\n key: \"edges\",\n relatedModel: Edge,\n reverseRelation: {\n key: 'project',\n includeInJSON: '_id'\n }\n },\n {\n type: Backbone.HasMany,\n key: \"views\",\n relatedModel: View,\n reverseRelation: {\n key: 'project',\n includeInJSON: '_id'\n }\n }\n ],\n addUser: function(_props, _options) {\n _props.project = this;\n var _user = User.findOrCreate(_props);\n this.get(\"users\").push(_user, _options);\n return _user;\n },\n addNode: function(_props, _options) {\n _props.project = this;\n var _node = Node.findOrCreate(_props);\n this.get(\"nodes\").push(_node, _options);\n return _node;\n },\n addEdge: function(_props, _options) {\n _props.project = this;\n var _edge = Edge.findOrCreate(_props);\n this.get(\"edges\").push(_edge, _options);\n return _edge;\n },\n addView: function(_props, _options) {\n _props.project = this;\n // TODO: check if need to replace with create only\n var _view = View.findOrCreate(_props);\n // TODO: Should we remember only one view?\n this.get(\"views\").push(_view, _options);\n return _view;\n },\n removeNode: function(_model) {\n this.get(\"nodes\").remove(_model);\n },\n removeEdge: function(_model) {\n this.get(\"edges\").remove(_model);\n },\n validate: function(options) {\n var _project = this;\n _([].concat(options.users, options.nodes, options.edges, options.views)).each(function(_item) {\n if(_item) {\n _item.project = _project;\n }\n });\n },\n // Add event handler to remove edges when a node is removed\n initialize: function() {\n var _this = this;\n this.on(\"remove:nodes\", function(_node) {\n _this.get(\"edges\").remove(\n _this.get(\"edges\").filter(function(_edge) {\n return _edge.get(\"from\") === _node || _edge.get(\"to\") === _node;\n })\n );\n });\n }\n });\n\n var RosterUser = Models.RosterUser = Backbone.Model.extend({\n type: \"roster_user\",\n idAttribute : \"_id\",\n\n constructor: function(options) {\n\n if (typeof options !== \"undefined\") {\n options._id = options._id || options.id || Models.getUID(this);\n options.title = options.title || \"(untitled \" + this.type + \")\";\n options.description = options.description || \"\";\n options.uri = options.uri || \"\";\n options.project = options.project || null;\n options.site_id = options.site_id || 0;\n\n if(typeof this.prepare === \"function\") {\n options = this.prepare(options);\n }\n }\n Backbone.Model.prototype.constructor.call(this, options);\n },\n\n validate: function() {\n if(!this.type) {\n return \"object has no type\";\n }\n },\n\n prepare: function(options) {\n options.color = options.color || \"#666666\";\n return options;\n },\n\n toJSON: function() {\n return {\n _id: this.get(\"_id\"),\n title: this.get(\"title\"),\n uri: this.get(\"uri\"),\n description: this.get(\"description\"),\n color: this.get(\"color\"),\n project: (this.get(\"project\") != null)?this.get(\"project\").get(\"id\"):null,\n site_id: this.get(\"site_id\")\n };\n }\n });\n\n var UsersList = Models.UsersList = Backbone.Collection.extend({\n model: RosterUser\n });\n\n\n}).call(window);\n","Rkns.defaults = {\n\n language: (navigator.language || navigator.userLanguage || \"en\"),\n /* GUI Language */\n container: \"renkan\",\n /* GUI Container DOM element ID */\n search: [],\n /* List of Search Engines */\n bins: [],\n /* List of Bins */\n static_url: \"\",\n /* URL for static resources */\n show_bins: true,\n /* Show bins in left column */\n properties: [],\n /* Semantic properties for edges */\n show_editor: true,\n /* Show the graph editor... Setting this to \"false\" only shows the bins part ! */\n read_only: false,\n /* Allows editing of renkan without changing the rest of the GUI. Can be switched on/off on the fly to block/enable editing */\n editor_mode: true,\n /* Switch for Publish/Edit GUI. If editor_mode is false, read_only will be true. */\n manual_save: false,\n /* In snapshot mode, clicking on the floppy will save a snapshot. Otherwise, it will show the connection status */\n show_top_bar: true,\n /* Show the top bar, (title, buttons, users) */\n default_user_color: \"#303030\",\n size_bug_fix: true,\n /* Resize the canvas after load (fixes a bug on iPad and FF Mac) */\n force_resize: false,\n allow_double_click: true,\n /* Allows Double Click to create a node on an empty background */\n zoom_on_scroll: true,\n /* Allows to use the scrollwheel to zoom */\n element_delete_delay: 0,\n /* Delay between clicking on the bin on an element and really deleting it\n Set to 0 for delete confirm */\n autoscale_padding: 50,\n default_view: false,\n\t/* Allows to load default view (zoom+offset) at start on read_only mode, instead of autoScale. default_view has to be an integer 0,1,2... */\n\n /* TOP BAR BUTTONS */\n show_search_field: true,\n show_user_list: true,\n user_name_editable: true,\n user_color_editable: true,\n show_save_button: true,\n show_export_button: true,\n show_open_button: false,\n show_addnode_button: true,\n show_addedge_button: true,\n show_bookmarklet: true,\n show_fullscreen_button: true,\n home_button_url: false,\n home_button_title: \"Home\",\n\n /* MINI-MAP OPTIONS */\n\n show_minimap: true,\n /* Show a small map at the bottom right */\n minimap_width: 160,\n minimap_height: 120,\n minimap_padding: 20,\n minimap_background_color: \"#ffffff\",\n minimap_border_color: \"#cccccc\",\n minimap_highlight_color: \"#ffff00\",\n minimap_highlight_weight: 5,\n\n /* EDGE/NODE COMMON OPTIONS */\n\n buttons_background: \"#202020\",\n buttons_label_color: \"#c000c0\",\n buttons_label_font_size: 9,\n\n /* NODE DISPLAY OPTIONS */\n\n show_node_circles: true,\n /* Show circles for nodes */\n clip_node_images: true,\n /* Constraint node images to circles */\n node_images_fill_mode: false,\n /* Set to false for \"letterboxing\" (height/width of node adapted to show full image)\n Set to true for \"crop\" (adapted to fill circle) */\n node_size_base: 25,\n node_stroke_width: 2,\n selected_node_stroke_width: 4,\n node_fill_color: \"#ffffff\",\n highlighted_node_fill_color: \"#ffff00\",\n node_label_distance: 5,\n /* Vertical distance between node and label */\n node_label_max_length: 60,\n /* Maximum displayed text length */\n label_untitled_nodes: \"(untitled)\",\n /* Label to display on untitled nodes */\n change_shapes: true,\n /* Change shapes enabled */\n\n /* EDGE DISPLAY OPTIONS */\n\n edge_stroke_width: 2,\n selected_edge_stroke_width: 4,\n edge_label_distance: 0,\n edge_label_max_length: 20,\n edge_arrow_length: 18,\n edge_arrow_width: 12,\n edge_gap_in_bundles: 12,\n label_untitled_edges: \"\",\n\n /* CONTEXTUAL DISPLAY (TOOLTIP OR EDITOR) OPTIONS */\n\n tooltip_width: 275,\n tooltip_padding: 10,\n tooltip_margin: 15,\n tooltip_arrow_length : 20,\n tooltip_arrow_width : 40,\n tooltip_top_color: \"#f0f0f0\",\n tooltip_bottom_color: \"#d0d0d0\",\n tooltip_border_color: \"#808080\",\n tooltip_border_width: 1,\n\n /* NODE EDITOR OPTIONS */\n\n show_node_editor_uri: true,\n show_node_editor_description: true,\n show_node_editor_size: true,\n show_node_editor_color: true,\n show_node_editor_image: true,\n show_node_editor_creator: true,\n uploaded_image_max_kb: 500,\n\n /* NODE TOOLTIP OPTIONS */\n\n show_node_tooltip_uri: true,\n show_node_tooltip_description: true,\n show_node_tooltip_color: true,\n show_node_tooltip_image: true,\n show_node_tooltip_creator: true,\n\n /* EDGE EDITOR OPTIONS */\n\n show_edge_editor_uri: true,\n show_edge_editor_color: true,\n show_edge_editor_direction: true,\n show_edge_editor_nodes: true,\n show_edge_editor_creator: true,\n\n /* EDGE TOOLTIP OPTIONS */\n\n show_edge_tooltip_uri: true,\n show_edge_tooltip_color: true,\n show_edge_tooltip_nodes: true,\n show_edge_tooltip_creator: true\n\n /* */\n\n};\n","Rkns.i18n = {\n fr: {\n \"Edit Node\": \"Édition d’un nœud\",\n \"Edit Edge\": \"Édition d’un lien\",\n \"Title:\": \"Titre :\",\n \"URI:\": \"URI :\",\n \"Description:\": \"Description :\",\n \"From:\": \"De :\",\n \"To:\": \"Vers :\",\n \"Image\": \"Image\",\n \"Image URL:\": \"URL d'Image\",\n \"Choose Image File:\": \"Choisir un fichier image\",\n \"Full Screen\": \"Mode plein écran\",\n \"Add Node\": \"Ajouter un nœud\",\n \"Add Edge\": \"Ajouter un lien\",\n \"Save Project\": \"Enregistrer le projet\",\n \"Open Project\": \"Ouvrir un projet\",\n \"Auto-save enabled\": \"Enregistrement automatique activé\",\n \"Connection lost\": \"Connexion perdue\",\n \"Created by:\": \"Créé par :\",\n \"Zoom In\": \"Agrandir l’échelle\",\n \"Zoom Out\": \"Rapetisser l’échelle\",\n \"Edit\": \"Éditer\",\n \"Remove\": \"Supprimer\",\n \"Cancel deletion\": \"Annuler la suppression\",\n \"Link to another node\": \"Créer un lien\",\n \"Enlarge\": \"Agrandir\",\n \"Shrink\": \"Rétrécir\",\n \"Click on the background canvas to add a node\": \"Cliquer sur le fond du graphe pour rajouter un nœud\",\n \"Click on a first node to start the edge\": \"Cliquer sur un premier nœud pour commencer le lien\",\n \"Click on a second node to complete the edge\": \"Cliquer sur un second nœud pour terminer le lien\",\n \"Wikipedia\": \"Wikipédia\",\n \"Wikipedia in \": \"Wikipédia en \",\n \"French\": \"Français\",\n \"English\": \"Anglais\",\n \"Japanese\": \"Japonais\",\n \"Untitled project\": \"Projet sans titre\",\n \"Lignes de Temps\": \"Lignes de Temps\",\n \"Loading, please wait\": \"Chargement en cours, merci de patienter\",\n \"Edge color:\": \"Couleur :\",\n \"Node color:\": \"Couleur :\",\n \"Choose color\": \"Choisir une couleur\",\n \"Change edge direction\": \"Changer le sens du lien\",\n \"Do you really wish to remove node \": \"Voulez-vous réellement supprimer le nœud \",\n \"Do you really wish to remove edge \": \"Voulez-vous réellement supprimer le lien \",\n \"This file is not an image\": \"Ce fichier n'est pas une image\",\n \"Image size must be under \": \"L'image doit peser moins de \",\n \"Size:\": \"Taille :\",\n \"KB\": \"ko\",\n \"Choose from vocabulary:\": \"Choisir dans un vocabulaire :\",\n \"SKOS Documentation properties\": \"SKOS: Propriétés documentaires\",\n \"has note\": \"a pour note\",\n \"has example\": \"a pour exemple\",\n \"has definition\": \"a pour définition\",\n \"SKOS Semantic relations\": \"SKOS: Relations sémantiques\",\n \"has broader\": \"a pour concept plus large\",\n \"has narrower\": \"a pour concept plus étroit\",\n \"has related\": \"a pour concept apparenté\",\n \"Dublin Core Metadata\": \"Métadonnées Dublin Core\",\n \"has contributor\": \"a pour contributeur\",\n \"covers\": \"couvre\",\n \"created by\": \"créé par\",\n \"has date\": \"a pour date\",\n \"published by\": \"édité par\",\n \"has source\": \"a pour source\",\n \"has subject\": \"a pour sujet\",\n \"Dragged resource\": \"Ressource glisée-déposée\",\n \"Search the Web\": \"Rechercher en ligne\",\n \"Search in Bins\": \"Rechercher dans les chutiers\",\n \"Close bin\": \"Fermer le chutier\",\n \"Refresh bin\": \"Rafraîchir le chutier\",\n \"(untitled)\": \"(sans titre)\",\n \"Select contents:\": \"Sélectionner des contenus :\",\n \"Drag items from this website, drop them in Renkan\": \"Glissez des éléments de ce site web vers Renkan\",\n \"Drag this button to your bookmark bar. When on a third-party website, click it to enable drag-and-drop from the website to Renkan.\": \"Glissez ce bouton vers votre barre de favoris. Ensuite, depuis un site tiers, cliquez dessus pour activer 'Drag-to-Add' puis glissez des éléments de ce site vers Renkan\",\n \"Shapes available\": \"Formes disponibles\",\n \"Circle\": \"Cercle\",\n \"Square\": \"Carré\",\n \"Diamond\": \"Losange\",\n \"Hexagone\": \"Hexagone\",\n \"Ellipse\": \"Ellipse\",\n \"Star\": \"Étoile\"\n }\n};\n","/* Saves the Full JSON at each modification */\n\nRkns.jsonIO = function(_renkan, _opts) {\n var _proj = _renkan.project;\n if (typeof _opts.http_method === \"undefined\") {\n _opts.http_method = 'PUT';\n }\n var _load = function() {\n _renkan.renderer.redrawActive = false;\n Rkns.$.getJSON(_opts.url, function(_data) {\n _proj.set(_data, {validate: true});\n _renkan.renderer.redrawActive = true;\n _renkan.renderer.autoScale();\n });\n };\n var _save = function() {\n var _data = _proj.toJSON();\n if (!_renkan.read_only) {\n Rkns.$.ajax({\n type: _opts.http_method,\n url: _opts.url,\n contentType: \"application/json\",\n data: JSON.stringify(_data),\n success: function(data, textStatus, jqXHR) {\n }\n });\n }\n\n };\n var _thrSave = Rkns._.throttle(\n function() {\n setTimeout(_save, 100);\n }, 1000);\n _proj.on(\"add:nodes add:edges add:users add:views\", function(_model) {\n _model.on(\"change remove\", function(_model) {\n _thrSave();\n });\n _thrSave();\n });\n _proj.on(\"change\", function() {\n _thrSave();\n });\n\n _load();\n};\n","/* Saves the Full JSON once */\n\nRkns.jsonIOSaveOnClick = function(_renkan, _opts) {\n var _proj = _renkan.project,\n _saveWarn = false,\n _onLeave = function() {\n return \"Project not saved\";\n };\n if (typeof _opts.http_method === \"undefined\") {\n _opts.http_method = 'POST';\n }\n var _load = function() {\n var getdata = {},\n rx = /id=([^&#?=]+)/,\n matches = document.location.hash.match(rx);\n if (matches) {\n getdata.id = matches[1];\n }\n Rkns.$.ajax({\n url: _opts.url,\n data: getdata,\n success: function(_data) {\n _proj.set(_data, {validate: true});\n \t_renkan.renderer.autoScale();\n }\n });\n };\n var _save = function() {\n _proj.set(\"saved_at\", new Date());\n var _data = _proj.toJSON();\n Rkns.$.ajax({\n type: _opts.http_method,\n url: _opts.url,\n contentType: \"application/json\",\n data: JSON.stringify(_data),\n success: function(data, textStatus, jqXHR) {\n $(window).off(\"beforeunload\", _onLeave);\n _saveWarn = false;\n //document.location.hash = \"#id=\" + data.id;\n //$(\".Rk-Notifications\").text(\"Saved as \"+document.location.href).fadeIn().delay(2000).fadeOut();\n }\n });\n };\n var _checkLeave = function() {\n var title = _proj.get(\"title\");\n if (title && _proj.get(\"nodes\").length) {\n $(\".Rk-Save-Button\").removeClass(\"disabled\");\n } else {\n $(\".Rk-Save-Button\").addClass(\"disabled\");\n }\n if (title) {\n $(\".Rk-PadTitle\").css(\"border-color\",\"#333333\");\n }\n if (!_saveWarn) {\n _saveWarn = true;\n $(window).on(\"beforeunload\", _onLeave);\n }\n };\n _load();\n _proj.on(\"add:nodes add:edges add:users change\", function(_model) {\n _model.on(\"change remove\", function(_model) {\n _checkLeave();\n });\n _checkLeave();\n });\n _renkan.renderer.save = function() {\n if ($(\".Rk-Save-Button\").hasClass(\"disabled\")) {\n if (!_proj.get(\"title\")) {\n $(\".Rk-PadTitle\").css(\"border-color\",\"#ff0000\");\n }\n } else {\n _save();\n }\n };\n};\n","(function(Rkns) {\n\"use strict\";\n\nvar _ = Rkns._;\n\nvar Ldt = Rkns.Ldt = {};\n\nvar Bin = Ldt.Bin = function(_renkan, _opts) {\n if (_opts.ldt_type) {\n var Resclass = Ldt[_opts.ldt_type+\"Bin\"];\n if (Resclass) {\n return new Resclass(_renkan, _opts);\n }\n }\n console.error(\"No such LDT Bin Type\");\n};\n\nvar ProjectBin = Ldt.ProjectBin = Rkns.Utils.inherit(Rkns._BaseBin);\n\nProjectBin.prototype.tagTemplate = _.template(\n '<li class=\"Rk-Bin-Item\" draggable=\"true\" data-image=\"<%- Rkns.Utils.getFullURL(static_url+\\'img/ldt-tag.png\\') %>\" data-uri=\"<%=ldt_platform%>ldtplatform/ldt/front/search/?search=<%=encodedtitle%>&field=all\" data-title=\"<%-title%>\" data-description=\"Tag \\'<%-title%>\\'\">' +\n '<img class=\"Rk-Ldt-Tag-Icon\" src=\"<%-static_url%>img/ldt-tag.png\" /><h4><%=htitle%></h4><div class=\"Rk-Clear\"></div></li>'\n);\n\nProjectBin.prototype.annotationTemplate = _.template(\n '<li class=\"Rk-Bin-Item\" draggable=\"true\" data-image=\"<%- Rkns.Utils.getFullURL(image) %>\" data-uri=\"<%=ldt_platform%>ldtplatform/ldt/front/player/<%=mediaid%>/#id=<%=annotationid%>\" data-title=\"<%-title%>\" data-description=\"<%-description%>\">' +\n '<img class=\"Rk-Ldt-Annotation-Icon\" src=\"<%=image%>\"/><h4><%=htitle%></h4><p><%=hdescription%></p><p>Start: <%=start%>, End: <%=end%>, Duration: <%=duration%></p><div class=\"Rk-Clear\"></div></li>'\n);\n\nProjectBin.prototype._init = function(_renkan, _opts) {\n this.renkan = _renkan;\n this.proj_id = _opts.project_id;\n this.ldt_platform = _opts.ldt_platform || \"http://ldt.iri.centrepompidou.fr/\";\n this.title_$.html(_opts.title);\n this.title_icon_$.addClass('Rk-Ldt-Title-Icon');\n this.refresh();\n};\n\nProjectBin.prototype.render = function(searchbase) {\n var search = searchbase || Rkns.Utils.regexpFromTextOrArray();\n function highlight(_text) {\n var _e = _(_text).escape();\n return search.isempty ? _e : search.replace(_e, \"<span class='searchmatch'>$1</span>\");\n }\n function convertTC(_ms) {\n function pad(_n) {\n var _res = _n.toString();\n while (_res.length < 2) {\n _res = '0' + _res;\n }\n return _res;\n }\n var _totalSeconds = Math.abs(Math.floor(_ms/1000)),\n _hours = Math.floor(_totalSeconds / 3600),\n _minutes = (Math.floor(_totalSeconds / 60) % 60),\n _seconds = _totalSeconds % 60,\n _res = '';\n if (_hours) {\n _res += pad(_hours) + ':';\n }\n _res += pad(_minutes) + ':' + pad(_seconds);\n return _res;\n }\n\n var _html = '<li><h3>Tags</h3></li>',\n _projtitle = this.data.meta[\"dc:title\"],\n _this = this,\n count = 0;\n _this.title_$.text('LDT Project: \"' + _projtitle + '\"');\n _(_this.data.tags).map(function(_tag) {\n var _title = _tag.meta[\"dc:title\"];\n if (!search.isempty && !search.test(_title)) {\n return;\n }\n count++;\n _html += _this.tagTemplate({\n ldt_platform: _this.ldt_platform,\n title: _title,\n htitle: highlight(_title),\n encodedtitle : encodeURIComponent(_title),\n static_url: _this.renkan.options.static_url\n });\n });\n _html += '<li><h3>Annotations</h3></li>';\n _(_this.data.annotations).map(function(_annotation) {\n var _description = _annotation.content.description,\n _title = _annotation.content.title.replace(_description,\"\");\n if (!search.isempty && !search.test(_title) && !search.test(_description)) {\n return;\n }\n count++;\n var _duration = _annotation.end - _annotation.begin,\n _img = (\n (_annotation.content && _annotation.content.img && _annotation.content.img.src) ?\n _annotation.content.img.src :\n ( _duration ? _this.renkan.options.static_url+\"img/ldt-segment.png\" : _this.renkan.options.static_url+\"img/ldt-point.png\" )\n );\n _html += _this.annotationTemplate({\n ldt_platform: _this.ldt_platform,\n title: _title,\n htitle: highlight(_title),\n description: _description,\n hdescription: highlight(_description),\n start: convertTC(_annotation.begin),\n end: convertTC(_annotation.end),\n duration: convertTC(_duration),\n mediaid: _annotation.media,\n annotationid: _annotation.id,\n image: _img,\n static_url: _this.renkan.options.static_url\n });\n });\n\n this.main_$.html(_html);\n if (!search.isempty && count) {\n this.count_$.text(count).show();\n } else {\n this.count_$.hide();\n }\n if (!search.isempty && !count) {\n this.$.hide();\n } else {\n this.$.show();\n }\n this.renkan.resizeBins();\n};\n\nProjectBin.prototype.refresh = function() {\n var _this = this;\n Rkns.$.ajax({\n url: this.ldt_platform + 'ldtplatform/ldt/cljson/id/' + this.proj_id,\n dataType: \"jsonp\",\n success: function(_data) {\n _this.data = _data;\n _this.render();\n }\n });\n};\n\nvar Search = Ldt.Search = function(_renkan, _opts) {\n this.renkan = _renkan;\n this.lang = _opts.lang || \"en\";\n};\n\nSearch.prototype.getBgClass = function() {\n return \"Rk-Ldt-Icon\";\n};\n\nSearch.prototype.getSearchTitle = function() {\n return this.renkan.translate(\"Lignes de Temps\");\n};\n\nSearch.prototype.search = function(_q) {\n this.renkan.tabs.push(\n new ResultsBin(this.renkan, {\n search: _q\n })\n );\n};\n\nvar ResultsBin = Ldt.ResultsBin = Rkns.Utils.inherit(Rkns._BaseBin);\n\nResultsBin.prototype.segmentTemplate = _.template(\n '<li class=\"Rk-Bin-Item\" draggable=\"true\" data-image=\"<%- Rkns.Utils.getFullURL(image) %>\" data-uri=\"<%=ldt_platform%>ldtplatform/ldt/front/player/<%=mediaid%>/#id=<%=annotationid%>\" data-title=\"<%-title%>\" data-description=\"<%-description%>\">' +\n '<img class=\"Rk-Ldt-Annotation-Icon\" src=\"<%=image%>\"/><h4><%=htitle%></h4><p><%=hdescription%></p><p>Start: <%=start%>, End: <%=end%>, Duration: <%=duration%></p><div class=\"Rk-Clear\"></div></li>'\n);\n\nResultsBin.prototype._init = function(_renkan, _opts) {\n this.renkan = _renkan;\n this.ldt_platform = _opts.ldt_platform || \"http://ldt.iri.centrepompidou.fr/\";\n this.max_results = _opts.max_results || 50;\n this.search = _opts.search;\n this.title_$.html('Lignes de Temps: \"' + _opts.search + '\"');\n this.title_icon_$.addClass('Rk-Ldt-Title-Icon');\n this.refresh();\n};\n\nResultsBin.prototype.render = function(searchbase) {\n if (!this.data) {\n return;\n }\n var search = searchbase || Rkns.Utils.regexpFromTextOrArray();\n var highlightrx = (search.isempty ? Rkns.Utils.regexpFromTextOrArray(this.search) : search);\n function highlight(_text) {\n return highlightrx.replace(_(_text).escape(), \"<span class='searchmatch'>$1</span>\");\n }\n function convertTC(_ms) {\n function pad(_n) {\n var _res = _n.toString();\n while (_res.length < 2) {\n _res = '0' + _res;\n }\n return _res;\n }\n var _totalSeconds = Math.abs(Math.floor(_ms/1000)),\n _hours = Math.floor(_totalSeconds / 3600),\n _minutes = (Math.floor(_totalSeconds / 60) % 60),\n _seconds = _totalSeconds % 60,\n _res = '';\n if (_hours) {\n _res += pad(_hours) + ':';\n }\n _res += pad(_minutes) + ':' + pad(_seconds);\n return _res;\n }\n\n var _html = '',\n _this = this,\n count = 0;\n _(this.data.objects).each(function(_segment) {\n var _description = _segment.abstract,\n _title = _segment.title;\n if (!search.isempty && !search.test(_title) && !search.test(_description)) {\n return;\n }\n count++;\n var _duration = _segment.duration,\n _begin = _segment.start_ts,\n _end = + _segment.duration + _begin,\n _img = (\n _duration ?\n _this.renkan.options.static_url + \"img/ldt-segment.png\" :\n _this.renkan.options.static_url + \"img/ldt-point.png\"\n );\n _html += _this.segmentTemplate({\n ldt_platform: _this.ldt_platform,\n title: _title,\n htitle: highlight(_title),\n description: _description,\n hdescription: highlight(_description),\n start: convertTC(_begin),\n end: convertTC(_end),\n duration: convertTC(_duration),\n mediaid: _segment.iri_id,\n //projectid: _segment.project_id,\n //cuttingid: _segment.cutting_id,\n annotationid: _segment.element_id,\n image: _img\n });\n });\n\n this.main_$.html(_html);\n if (!search.isempty && count) {\n this.count_$.text(count).show();\n } else {\n this.count_$.hide();\n }\n if (!search.isempty && !count) {\n this.$.hide();\n } else {\n this.$.show();\n }\n this.renkan.resizeBins();\n};\n\nResultsBin.prototype.refresh = function() {\n var _this = this;\n Rkns.$.ajax({\n url: this.ldt_platform + 'ldtplatform/api/ldt/1.0/segments/search/',\n data: {\n format: \"jsonp\",\n q: this.search,\n limit: this.max_results\n },\n dataType: \"jsonp\",\n success: function(_data) {\n _this.data = _data;\n _this.render();\n }\n });\n};\n\n})(window.Rkns);\n","Rkns.ResourceList = {};\n\nRkns.ResourceList.Bin = Rkns.Utils.inherit(Rkns._BaseBin);\n\nRkns.ResourceList.Bin.prototype.resultTemplate = Rkns._.template(\n '<li class=\"Rk-Bin-Item Rk-ResourceList-Item\" draggable=\"true\" data-uri=\"<%-url%>\" ' +\n 'data-title=\"<%-title%>\" data-description=\"<%-description%>\" ' +\n '<% if (image) { %>data-image=\"<%- Rkns.Utils.getFullURL(image) %>\"<% } else { %>data-image=\"\"<% } %> >' +\n '<% if (image) { %><img class=\"Rk-ResourceList-Image\" src=\"<%-image%>\"/><% } %><h4 class=\"Rk-ResourceList-Title\">' +\n '<% if (url) { %><a href=\"<%-url%>\" target=\"_blank\"><% } %><%=htitle%><% if (url) { %></a><% } %></h4>' +\n '<% if (description) { %><p class=\"Rk-ResourceList-Description\"><%=hdescription%></p><% } %><% if (image) { %><div style=\"clear: both;\"></div><% } %></li>'\n);\n\nRkns.ResourceList.Bin.prototype._init = function(_renkan, _opts) {\n this.renkan = _renkan;\n this.title_$.html(_opts.title);\n if (_opts.list) {\n this.data = _opts.list;\n }\n this.refresh();\n};\n\nRkns.ResourceList.Bin.prototype.render = function(searchbase) {\n var search = searchbase || Rkns.Utils.regexpFromTextOrArray();\n function highlight(_text) {\n var _e = _(_text).escape();\n return search.isempty ? _e : search.replace(_e, \"<span class='searchmatch'>$1</span>\");\n }\n var _html = \"\",\n _this = this,\n count = 0;\n Rkns._(this.data).each(function(_item) {\n var _element;\n if (typeof _item === \"string\") {\n if (/^(https?:\\/\\/|www)/.test(_item)) {\n _element = { url: _item };\n } else {\n _element = { title: _item.replace(/[:,]?\\s?(https?:\\/\\/|www)[\\d\\w\\/.&?=#%-_]+\\s?/,'').trim() };\n var _match = _item.match(/(https?:\\/\\/|www)[\\d\\w\\/.&?=#%-_]+/);\n if (_match) {\n _element.url = _match[0];\n }\n if (_element.title.length > 80) {\n _element.description = _element.title;\n _element.title = _element.title.replace(/^(.{30,60})\\s.+$/,'$1…');\n }\n }\n } else {\n _element = _item;\n }\n var title = _element.title || (_element.url || \"\").replace(/^https?:\\/\\/(www\\.)?/,'').replace(/^(.{40}).+$/,'$1…'),\n url = _element.url || \"\",\n description = _element.description || \"\",\n image = _element.image || \"\";\n if (url && !/^https?:\\/\\//.test(url)) {\n url = 'http://' + url;\n }\n if (!search.isempty && !search.test(title) && !search.test(description)) {\n return;\n }\n count++;\n _html += _this.resultTemplate({\n url: url,\n title: title,\n htitle: highlight(title),\n image: image,\n description: description,\n hdescription: highlight(description),\n static_url: _this.renkan.options.static_url\n });\n });\n _this.main_$.html(_html);\n if (!search.isempty && count) {\n this.count_$.text(count).show();\n } else {\n this.count_$.hide();\n }\n if (!search.isempty && !count) {\n this.$.hide();\n } else {\n this.$.show();\n }\n this.renkan.resizeBins();\n};\n\nRkns.ResourceList.Bin.prototype.refresh = function() {\n if (this.data) {\n this.render();\n }\n};\n","Rkns.Wikipedia = {\n};\n\nRkns.Wikipedia.Search = function(_renkan, _opts) {\n this.renkan = _renkan;\n this.lang = _opts.lang || \"en\";\n};\n\nRkns.Wikipedia.Search.prototype.getBgClass = function() {\n return \"Rk-Wikipedia-Search-Icon Rk-Wikipedia-Lang-\" + this.lang;\n};\n\nRkns.Wikipedia.Search.prototype.getSearchTitle = function() {\n var langs = {\n \"fr\": \"French\",\n \"en\": \"English\",\n \"ja\": \"Japanese\"\n };\n if (langs[this.lang]) {\n return this.renkan.translate(\"Wikipedia in \") + this.renkan.translate(langs[this.lang]);\n } else {\n return this.renkan.translate(\"Wikipedia\") + \" [\" + this.lang + \"]\";\n }\n};\n\nRkns.Wikipedia.Search.prototype.search = function(_q) {\n this.renkan.tabs.push(\n new Rkns.Wikipedia.Bin(this.renkan, {\n lang: this.lang,\n search: _q\n })\n );\n};\n\nRkns.Wikipedia.Bin = Rkns.Utils.inherit(Rkns._BaseBin);\n\nRkns.Wikipedia.Bin.prototype.resultTemplate = Rkns._.template(\n '<li class=\"Rk-Wikipedia-Result Rk-Bin-Item\" draggable=\"true\" data-uri=\"<%-url%>\" ' +\n 'data-title=\"Wikipedia: <%-title%>\" data-description=\"<%-description%>\" data-image=\"<%- Rkns.Utils.getFullURL( static_url + \\'img/wikipedia.png\\' ) %>\">' +\n '<img class=\"Rk-Wikipedia-Icon\" src=\"<%-static_url%>img/wikipedia.png\"></div><h4 class=\"Rk-Wikipedia-Title\"><a href=\"<%-url%>\" target=\"_blank\"><%=htitle%></a></h4>' +\n '<p class=\"Rk-Wikipedia-Snippet\"><%=hdescription%></p></li>'\n);\n\nRkns.Wikipedia.Bin.prototype._init = function(_renkan, _opts) {\n this.renkan = _renkan;\n this.search = _opts.search;\n this.lang = _opts.lang || \"en\";\n this.title_icon_$.addClass('Rk-Wikipedia-Title-Icon Rk-Wikipedia-Lang-' + this.lang);\n this.title_$.html(this.search).addClass(\"Rk-Wikipedia-Title\");\n this.refresh();\n};\n\nRkns.Wikipedia.Bin.prototype.render = function(searchbase) {\n var search = searchbase || Rkns.Utils.regexpFromTextOrArray();\n var highlightrx = (search.isempty ? Rkns.Utils.regexpFromTextOrArray(this.search) : search);\n function highlight(_text) {\n return highlightrx.replace(_(_text).escape(), \"<span class='searchmatch'>$1</span>\");\n }\n var _html = \"\",\n _this = this,\n count = 0;\n Rkns._(this.data.query.search).each(function(_result) {\n var title = _result.title,\n url = \"http://\" + _this.lang + \".wikipedia.org/wiki/\" + encodeURI(title.replace(/ /g,\"_\")),\n description = Rkns.$('<div>').html(_result.snippet).text();\n if (!search.isempty && !search.test(title) && !search.test(description)) {\n return;\n }\n count++;\n _html += _this.resultTemplate({\n url: url,\n title: title,\n htitle: highlight(title),\n description: description,\n hdescription: highlight(description),\n static_url: _this.renkan.options.static_url\n });\n });\n _this.main_$.html(_html);\n if (!search.isempty && count) {\n this.count_$.text(count).show();\n } else {\n this.count_$.hide();\n }\n if (!search.isempty && !count) {\n this.$.hide();\n } else {\n this.$.show();\n }\n this.renkan.resizeBins();\n};\n\nRkns.Wikipedia.Bin.prototype.refresh = function() {\n var _this = this;\n Rkns.$.ajax({\n url: \"http://\" + _this.lang + \".wikipedia.org/w/api.php?action=query&list=search&srsearch=\" + encodeURIComponent(this.search) + \"&format=json\",\n dataType: \"jsonp\",\n success: function(_data) {\n _this.data = _data;\n _this.render();\n }\n });\n};\n","\ndefine('renderer/baserepresentation',['jquery', 'underscore'], function ($, _) {\n \n\n /* Rkns.Renderer._BaseRepresentation Class */\n\n /* In Renkan, a \"Representation\" is a sort of ViewModel (in the MVVM paradigm) and bridges the gap between\n * models (written with Backbone.js) and the view (written with Paper.js)\n * Renkan's representations all inherit from Rkns.Renderer._BaseRepresentation '*/\n\n var _BaseRepresentation = function(_renderer, _model) {\n if (typeof _renderer !== \"undefined\") {\n this.renderer = _renderer;\n this.renkan = _renderer.renkan;\n this.project = _renderer.renkan.project;\n this.options = _renderer.renkan.options;\n this.model = _model;\n if (this.model) {\n var _this = this;\n this._changeBinding = function() {\n _this.redraw();\n };\n this._removeBinding = function() {\n _renderer.removeRepresentation(_this);\n _(function() {\n _renderer.redraw();\n }).defer();\n };\n this._selectBinding = function() {\n _this.select();\n };\n this._unselectBinding = function() {\n _this.unselect();\n };\n this.model.on(\"change\", this._changeBinding );\n this.model.on(\"remove\", this._removeBinding );\n this.model.on(\"select\", this._selectBinding );\n this.model.on(\"unselect\", this._unselectBinding );\n }\n }\n };\n\n /* Rkns.Renderer._BaseRepresentation Methods */\n\n _(_BaseRepresentation.prototype).extend({\n _super: function(_func) {\n return _BaseRepresentation.prototype[_func].apply(this, Array.prototype.slice.call(arguments, 1));\n },\n redraw: function() {},\n moveTo: function() {},\n show: function() { return \"chaud cacao\"; },\n hide: function() {},\n select: function() {\n if (this.model) {\n this.model.trigger(\"selected\");\n }\n },\n unselect: function() {\n if (this.model) {\n this.model.trigger(\"unselected\");\n }\n },\n highlight: function() {},\n unhighlight: function() {},\n mousedown: function() {},\n mouseup: function() {\n if (this.model) {\n this.model.trigger(\"clicked\");\n }\n },\n destroy: function() {\n if (this.model) {\n this.model.off(\"change\", this._changeBinding );\n this.model.off(\"remove\", this._removeBinding );\n this.model.off(\"select\", this._selectBinding );\n this.model.off(\"unselect\", this._unselectBinding );\n }\n }\n });\n\n /* End of Rkns.Renderer._BaseRepresentation Class */\n\n return _BaseRepresentation;\n\n});\n\ndefine('requtils',[], function ($, _) {\n \n return {\n getUtils: function(){\n return window.Rkns.Utils;\n },\n getRenderer: function(){\n return window.Rkns.Renderer;\n }\n };\n\n});\n\n\ndefine('renderer/basebutton',['jquery', 'underscore', 'requtils', 'renderer/baserepresentation'], function ($, _, requtils, BaseRepresentation) {\n \n\n var Utils = requtils.getUtils();\n\n /* Rkns.Renderer._BaseButton Class */\n\n /* BaseButton is extended by contextual buttons that appear when hovering on nodes and edges */\n\n var _BaseButton = Utils.inherit(BaseRepresentation);\n\n _(_BaseButton.prototype).extend({\n moveTo: function(_pos) {\n this.sector.moveTo(_pos);\n },\n show: function() {\n this.sector.show();\n },\n hide: function() {\n this.sector.hide();\n },\n select: function() {\n this.sector.select();\n },\n unselect: function(_newTarget) {\n this.sector.unselect();\n if (!_newTarget || (_newTarget !== this.source_representation && _newTarget.source_representation !== this.source_representation)) {\n this.source_representation.unselect();\n }\n },\n destroy: function() {\n this.sector.destroy();\n }\n });\n\n return _BaseButton;\n\n});\n\n\ndefine('renderer/shapebuilder',[], function () {\n \n\n /* ShapeBuilder Begin */\n\n var builders = {\n \"circle\":{\n getShape: function() {\n return new paper.Path.Circle([0, 0], 1);\n },\n getImageShape: function(center, radius) {\n return new paper.Path.Circle(center, radius);\n }\n },\n \"rectangle\":{\n getShape: function() {\n return new paper.Path.Rectangle([-2, -2], [2, 2]);\n },\n getImageShape: function(center, radius) {\n return new paper.Path.Rectangle([-radius, -radius], [radius*2, radius*2]);\n }\n },\n \"ellipse\":{\n getShape: function() {\n return new paper.Path.Ellipse(new paper.Rectangle([-2, -1], [2, 1]));\n },\n getImageShape: function(center, radius) {\n return new paper.Path.Ellipse(new paper.Rectangle([-radius, -radius/2], [radius*2, radius]));\n }\n },\n \"polygon\":{\n getShape: function() {\n return new paper.Path.RegularPolygon([0, 0], 6, 1);\n },\n getImageShape: function(center, radius) {\n return new paper.Path.RegularPolygon([0, 0], 6, radius);\n }\n },\n \"diamond\":{\n getShape: function() {\n var d = new paper.Path.Rectangle([-2, -2], [2, 2]);\n d.rotate(45);\n return d;\n },\n getImageShape: function(center, radius) {\n var d = new paper.Path.Rectangle([-radius, -radius], [radius*2, radius*2]);\n d.rotate(45);\n return d;\n }\n },\n \"star\":{\n getShape: function() {\n return new paper.Path.Star([0, 0], 8, 1, 0.7);\n },\n getImageShape: function(center, radius) {\n return new paper.Path.Star([0, 0], 8, radius*1, radius*0.7);\n }\n },\n \"svg\": function(path){\n return {\n getShape: function() {\n return new paper.Path(path);\n },\n getImageShape: function(center, radius) {\n // No calcul for the moment \n return new paper.Path();\n }\n };\n }\n };\n \n var ShapeBuilder = function (shape){\n if(typeof shape===\"undefined\"){\n shape = \"circle\";\n }\n if(shape.substr(0,4)===\"svg:\"){\n return builders.svg(shape.substr(4));\n }\n if(!(shape in builders)){\n shape = \"circle\";\n }\n return builders[shape];\n };\n \n return ShapeBuilder;\n\n});\n\ndefine('renderer/noderepr',['jquery', 'underscore', 'requtils', 'renderer/baserepresentation', 'renderer/shapebuilder'], function ($, _, requtils, BaseRepresentation, ShapeBuilder) {\n \n\n var Utils = requtils.getUtils();\n\n /* Rkns.Renderer.Node Class */\n\n /* The representation for the node : A circle, with an image inside and a text label underneath.\n * The circle and the image are drawn on canvas and managed by Paper.js.\n * The text label is an HTML node, managed by jQuery. */\n\n //var NodeRepr = Renderer.Node = Utils.inherit(Renderer._BaseRepresentation);\n var NodeRepr = Utils.inherit(BaseRepresentation);\n\n _(NodeRepr.prototype).extend({\n _init: function() {\n this.renderer.node_layer.activate();\n this.type = \"Node\";\n this.buildShape();\n if (this.options.show_node_circles) {\n this.circle.strokeWidth = this.options.node_stroke_width;\n this.h_ratio = 1;\n } else {\n this.h_ratio = 0;\n }\n this.title = $('<div class=\"Rk-Label\">').appendTo(this.renderer.labels_$);\n \n if (this.options.editor_mode) {\n var Renderer = requtils.getRenderer();\n this.normal_buttons = [\n new Renderer.NodeEditButton(this.renderer, null),\n new Renderer.NodeRemoveButton(this.renderer, null),\n new Renderer.NodeLinkButton(this.renderer, null),\n new Renderer.NodeEnlargeButton(this.renderer, null),\n new Renderer.NodeShrinkButton(this.renderer, null)\n ];\n this.pending_delete_buttons = [\n new Renderer.NodeRevertButton(this.renderer, null)\n ];\n this.all_buttons = this.normal_buttons.concat(this.pending_delete_buttons);\n \n for (var i = 0; i < this.all_buttons.length; i++) {\n this.all_buttons[i].source_representation = this;\n }\n this.active_buttons = [];\n } else {\n this.active_buttons = this.all_buttons = [];\n }\n this.last_circle_radius = 1;\n\n if (this.renderer.minimap) {\n this.renderer.minimap.node_layer.activate();\n this.minimap_circle = new paper.Path.Circle([0, 0], 1);\n this.minimap_circle.__representation = this.renderer.minimap.miniframe.__representation;\n this.renderer.minimap.node_group.addChild(this.minimap_circle);\n }\n },\n buildShape: function(){\n if(typeof this.model.get(\"shape_changed\")!==\"undefined\" && this.model.get(\"shape_changed\")===true){\n this.model.set(\"shape_changed\", false);\n delete this.img;\n }\n if(this.circle){\n this.circle.remove();\n delete this.circle;\n }\n // \"circle\" \"rectangle\" \"ellipse\" \"polygon\" \"star\" \"diamond\"\n this.shapeBuilder = new ShapeBuilder(this.model.get(\"shape\"));\n this.circle = this.shapeBuilder.getShape();\n this.circle.__representation = this;\n this.last_circle_radius = 1;\n },\n redraw: function(_dontRedrawEdges) {\n if(typeof this.model.get(\"shape_changed\")!==\"undefined\" && this.model.get(\"shape_changed\")===true){\n this.buildShape();\n }\n var _model_coords = new paper.Point(this.model.get(\"position\")),\n _baseRadius = this.options.node_size_base * Math.exp((this.model.get(\"size\") || 0) * Utils._NODE_SIZE_STEP);\n if (!this.is_dragging || !this.paper_coords) {\n this.paper_coords = this.renderer.toPaperCoords(_model_coords);\n }\n this.circle_radius = _baseRadius * this.renderer.scale;\n if (this.last_circle_radius !== this.circle_radius) {\n this.all_buttons.forEach(function(b) {\n b.setSectorSize();\n });\n this.circle.scale(this.circle_radius / this.last_circle_radius);\n if (this.node_image) {\n this.node_image.scale(this.circle_radius / this.last_circle_radius);\n }\n }\n this.circle.position = this.paper_coords;\n if (this.node_image) {\n this.node_image.position = this.paper_coords.subtract(this.image_delta.multiply(this.circle_radius));\n }\n this.last_circle_radius = this.circle_radius;\n\n var old_act_btn = this.active_buttons;\n\n var opacity = 1;\n if (this.model.get(\"delete_scheduled\")) {\n opacity = 0.5;\n this.active_buttons = this.pending_delete_buttons;\n this.circle.dashArray = [2,2];\n } else {\n opacity = 1;\n this.active_buttons = this.normal_buttons;\n this.circle.dashArray = null;\n }\n\n if (this.selected && this.renderer.isEditable()) {\n if (old_act_btn !== this.active_buttons) {\n old_act_btn.forEach(function(b) {\n b.hide();\n });\n }\n this.active_buttons.forEach(function(b) {\n b.show();\n });\n }\n\n if (this.node_image) {\n this.node_image.opacity = this.highlighted ? opacity * 0.5 : (opacity - 0.01);\n }\n\n this.circle.fillColor = this.highlighted ? this.options.highlighted_node_fill_color : this.options.node_fill_color;\n\n this.circle.opacity = this.options.show_node_circles ? opacity : 0.01;\n\n var _text = this.model.get(\"title\") || this.renkan.translate(this.options.label_untitled_nodes) || \"\";\n _text = Utils.shortenText(_text, this.options.node_label_max_length);\n\n if (typeof this.highlighted === \"object\") {\n this.title.html(this.highlighted.replace(_(_text).escape(),'<span class=\"Rk-Highlighted\">$1</span>'));\n } else {\n this.title.text(_text);\n }\n\n this.title.css({\n left: this.paper_coords.x,\n top: this.paper_coords.y + this.circle_radius * this.h_ratio + this.options.node_label_distance,\n opacity: opacity\n });\n var _color = this.model.get(\"color\") || (this.model.get(\"created_by\") || Utils._USER_PLACEHOLDER(this.renkan)).get(\"color\");\n this.circle.strokeColor = _color;\n var _pc = this.paper_coords;\n this.all_buttons.forEach(function(b) {\n b.moveTo(_pc);\n });\n var lastImage = this.img;\n this.img = this.model.get(\"image\");\n if (this.img && this.img !== lastImage) {\n this.showImage();\n }\n if (this.node_image && !this.img) {\n this.node_image.remove();\n delete this.node_image;\n }\n\n if (this.renderer.minimap) {\n this.minimap_circle.fillColor = _color;\n var minipos = this.renderer.toMinimapCoords(_model_coords),\n miniradius = this.renderer.minimap.scale * _baseRadius,\n minisize = new paper.Size([miniradius, miniradius]);\n this.minimap_circle.fitBounds(minipos.subtract(minisize), minisize.multiply(2));\n }\n\n if (!_dontRedrawEdges) {\n var _this = this;\n _.each(\n this.project.get(\"edges\").filter(\n function (ed) {\n return ((ed.get(\"to\") === _this.model) || (ed.get(\"from\") === _this.model));\n }\n ),\n function(edge, index, list) {\n var repr = _this.renderer.getRepresentationByModel(edge);\n if (repr && typeof repr.from_representation !== \"undefined\" && typeof repr.from_representation.paper_coords !== \"undefined\" && typeof repr.to_representation !== \"undefined\" && typeof repr.to_representation.paper_coords !== \"undefined\") {\n repr.redraw();\n }\n }\n );\n }\n\n },\n showImage: function() {\n var _image = null;\n if (typeof this.renderer.image_cache[this.img] === \"undefined\") {\n _image = new Image();\n this.renderer.image_cache[this.img] = _image;\n _image.src = this.img;\n } else {\n _image = this.renderer.image_cache[this.img];\n }\n if (_image.width) {\n if (this.node_image) {\n this.node_image.remove();\n }\n this.renderer.node_layer.activate();\n var width = _image.width,\n height = _image.height,\n clipPath = this.model.get(\"clip_path\"),\n hasClipPath = (typeof clipPath !== \"undefined\" && clipPath),\n _clip = null,\n baseRadius = null,\n centerPoint = null;\n \n if (hasClipPath) {\n _clip = new paper.Path();\n var instructions = clipPath.match(/[a-z][^a-z]+/gi) || [],\n lastCoords = [0,0],\n minX = Infinity,\n minY = Infinity,\n maxX = -Infinity,\n maxY = -Infinity;\n\n var transformCoords = function(tabc, relative) {\n var newCoords = tabc.slice(1).map(function(v, k) {\n var res = parseFloat(v),\n isY = k % 2;\n if (isY) {\n res = ( res - 0.5 ) * height;\n } else {\n res = ( res - 0.5 ) * width;\n }\n if (relative) {\n res += lastCoords[isY];\n }\n if (isY) {\n minY = Math.min(minY, res);\n maxY = Math.max(maxY, res);\n } else {\n minX = Math.min(minX, res);\n maxX = Math.max(maxX, res);\n }\n return res;\n });\n lastCoords = newCoords.slice(-2);\n return newCoords;\n };\n\n instructions.forEach(function(instr) {\n var coords = instr.match(/([a-z]|[0-9.-]+)/ig) || [\"\"];\n switch(coords[0]) {\n case \"M\":\n _clip.moveTo(transformCoords(coords));\n break;\n case \"m\":\n _clip.moveTo(transformCoords(coords, true));\n break;\n case \"L\":\n _clip.lineTo(transformCoords(coords));\n break;\n case \"l\":\n _clip.lineTo(transformCoords(coords, true));\n break;\n case \"C\":\n _clip.cubicCurveTo(transformCoords(coords));\n break;\n case \"c\":\n _clip.cubicCurveTo(transformCoords(coords, true));\n break;\n case \"Q\":\n _clip.quadraticCurveTo(transformCoords(coords));\n break;\n case \"q\":\n _clip.quadraticCurveTo(transformCoords(coords, true));\n break;\n }\n });\n\n baseRadius = Math[this.options.node_images_fill_mode ? \"min\" : \"max\"](maxX - minX, maxY - minY) / 2;\n centerPoint = new paper.Point((maxX + minX) / 2, (maxY + minY) / 2);\n if (!this.options.show_node_circles) {\n this.h_ratio = (maxY - minY) / (2 * baseRadius);\n }\n } else {\n baseRadius = Math[this.options.node_images_fill_mode ? \"min\" : \"max\"](width, height) / 2;\n centerPoint = new paper.Point(0,0);\n if (!this.options.show_node_circles) {\n this.h_ratio = height / (2 * baseRadius);\n }\n }\n var _raster = new paper.Raster(_image);\n _raster.locked = true; // Disable mouse events on icon\n if (hasClipPath) {\n _raster = new paper.Group(_clip, _raster);\n _raster.opacity = 0.99;\n /* This is a workaround to allow clipping at group level\n * If opacity was set to 1, paper.js would merge all clipping groups in one (known bug).\n */\n _raster.clipped = true;\n _clip.__representation = this;\n }\n if (this.options.clip_node_images) {\n var _circleClip = this.shapeBuilder.getImageShape(centerPoint, baseRadius);\n _raster = new paper.Group(_circleClip, _raster);\n _raster.opacity = 0.99;\n _raster.clipped = true;\n _circleClip.__representation = this;\n }\n this.image_delta = centerPoint.divide(baseRadius);\n this.node_image = _raster;\n this.node_image.__representation = _this;\n this.node_image.scale(this.circle_radius / baseRadius);\n this.node_image.position = this.paper_coords.subtract(this.image_delta.multiply(this.circle_radius));\n this.redraw();\n this.renderer.throttledPaperDraw();\n } else {\n var _this = this;\n $(_image).on(\"load\", function() {\n _this.showImage();\n });\n }\n },\n paperShift: function(_delta) {\n if (this.options.editor_mode) {\n if (!this.renkan.read_only) {\n this.is_dragging = true;\n this.paper_coords = this.paper_coords.add(_delta);\n this.redraw();\n }\n } else {\n this.renderer.paperShift(_delta);\n }\n },\n openEditor: function() {\n this.renderer.removeRepresentationsOfType(\"editor\");\n var _editor = this.renderer.addRepresentation(\"NodeEditor\",null);\n _editor.source_representation = this;\n _editor.draw();\n },\n select: function() {\n this.selected = true;\n this.circle.strokeWidth = this.options.selected_node_stroke_width;\n if (this.renderer.isEditable()) {\n this.active_buttons.forEach(function(b) {\n b.show();\n });\n }\n var _uri = this.model.get(\"uri\");\n if (_uri) {\n $('.Rk-Bin-Item').each(function() {\n var _el = $(this);\n if (_el.attr(\"data-uri\") === _uri) {\n _el.addClass(\"selected\");\n }\n });\n }\n if (!this.options.editor_mode) {\n this.openEditor();\n }\n\n if (this.renderer.minimap) {\n this.minimap_circle.strokeWidth = this.options.minimap_highlight_weight;\n this.minimap_circle.strokeColor = this.options.minimap_highlight_color;\n }\n this._super(\"select\");\n },\n unselect: function(_newTarget) {\n if (!_newTarget || _newTarget.source_representation !== this) {\n this.selected = false;\n this.all_buttons.forEach(function(b) {\n b.hide();\n });\n this.circle.strokeWidth = this.options.node_stroke_width;\n $('.Rk-Bin-Item').removeClass(\"selected\");\n if (this.renderer.minimap) {\n this.minimap_circle.strokeColor = undefined;\n }\n this._super(\"unselect\");\n }\n },\n highlight: function(textToReplace) {\n var hlvalue = textToReplace || true;\n if (this.highlighted === hlvalue) {\n return;\n }\n this.highlighted = hlvalue;\n this.redraw();\n this.renderer.throttledPaperDraw();\n },\n unhighlight: function() {\n if (!this.highlighted) {\n return;\n }\n this.highlighted = false;\n this.redraw();\n this.renderer.throttledPaperDraw();\n },\n saveCoords: function() {\n var _coords = this.renderer.toModelCoords(this.paper_coords),\n _data = {\n position: {\n x: _coords.x,\n y: _coords.y\n }\n };\n if (this.renderer.isEditable()) {\n this.model.set(_data);\n }\n },\n mousedown: function(_event, _isTouch) {\n if (_isTouch) {\n this.renderer.unselectAll();\n this.select();\n }\n },\n mouseup: function(_event, _isTouch) {\n if (this.renderer.is_dragging && this.renderer.isEditable()) {\n this.saveCoords();\n } else {\n if (!_isTouch && !this.model.get(\"delete_scheduled\")) {\n this.openEditor();\n }\n this.model.trigger(\"clicked\");\n }\n this.renderer.click_target = null;\n this.renderer.is_dragging = false;\n this.is_dragging = false;\n },\n destroy: function(_event) {\n this._super(\"destroy\");\n this.all_buttons.forEach(function(b) {\n b.destroy();\n });\n this.circle.remove();\n this.title.remove();\n if (this.renderer.minimap) {\n this.minimap_circle.remove();\n }\n if (this.node_image) {\n this.node_image.remove();\n }\n }\n });\n\n return NodeRepr;\n\n});\n\n\ndefine('renderer/edge',['jquery', 'underscore', 'requtils', 'renderer/baserepresentation'], function ($, _, requtils, BaseRepresentation) {\n \n\n var Utils = requtils.getUtils();\n\n /* Edge Class Begin */\n\n //var Edge = Renderer.Edge = Utils.inherit(Renderer._BaseRepresentation);\n var Edge = Utils.inherit(BaseRepresentation);\n\n _(Edge.prototype).extend({\n _init: function() {\n this.renderer.edge_layer.activate();\n this.type = \"Edge\";\n this.from_representation = this.renderer.getRepresentationByModel(this.model.get(\"from\"));\n this.to_representation = this.renderer.getRepresentationByModel(this.model.get(\"to\"));\n this.bundle = this.renderer.addToBundles(this);\n this.line = new paper.Path();\n this.line.add([0,0],[0,0],[0,0]);\n this.line.__representation = this;\n this.line.strokeWidth = this.options.edge_stroke_width;\n this.arrow = new paper.Path();\n this.arrow.add(\n [ 0, 0 ],\n [ this.options.edge_arrow_length, this.options.edge_arrow_width / 2 ],\n [ 0, this.options.edge_arrow_width ]\n );\n this.arrow.__representation = this;\n this.text = $('<div class=\"Rk-Label Rk-Edge-Label\">').appendTo(this.renderer.labels_$);\n this.arrow_angle = 0;\n if (this.options.editor_mode) {\n var Renderer = requtils.getRenderer();\n this.normal_buttons = [\n new Renderer.EdgeEditButton(this.renderer, null),\n new Renderer.EdgeRemoveButton(this.renderer, null)\n ];\n this.pending_delete_buttons = [\n new Renderer.EdgeRevertButton(this.renderer, null)\n ];\n this.all_buttons = this.normal_buttons.concat(this.pending_delete_buttons);\n for (var i = 0; i < this.all_buttons.length; i++) {\n this.all_buttons[i].source_representation = this;\n }\n this.active_buttons = [];\n } else {\n this.active_buttons = this.all_buttons = [];\n }\n\n if (this.renderer.minimap) {\n this.renderer.minimap.edge_layer.activate();\n this.minimap_line = new paper.Path();\n this.minimap_line.add([0,0],[0,0]);\n this.minimap_line.__representation = this.renderer.minimap.miniframe.__representation;\n this.minimap_line.strokeWidth = 1;\n }\n },\n redraw: function() {\n var from = this.model.get(\"from\"),\n to = this.model.get(\"to\");\n if (!from || !to) {\n return;\n }\n this.from_representation = this.renderer.getRepresentationByModel(from);\n this.to_representation = this.renderer.getRepresentationByModel(to);\n if (typeof this.from_representation === \"undefined\" || typeof this.to_representation === \"undefined\") {\n return;\n }\n var _p0a = this.from_representation.paper_coords,\n _p1a = this.to_representation.paper_coords,\n _v = _p1a.subtract(_p0a),\n _r = _v.length,\n _u = _v.divide(_r),\n _ortho = new paper.Point([- _u.y, _u.x]),\n _group_pos = this.bundle.getPosition(this),\n _delta = _ortho.multiply( this.options.edge_gap_in_bundles * _group_pos ),\n _p0b = _p0a.add(_delta), /* Adding a 4 px difference */\n _p1b = _p1a.add(_delta), /* to differentiate bundled links */\n _a = _v.angle,\n _textdelta = _ortho.multiply(this.options.edge_label_distance),\n _handle = _v.divide(3),\n _color = this.model.get(\"color\") || this.model.get(\"color\") || (this.model.get(\"created_by\") || Utils._USER_PLACEHOLDER(this.renkan)).get(\"color\"),\n opacity = 1;\n\n if (this.model.get(\"delete_scheduled\") || this.from_representation.model.get(\"delete_scheduled\") || this.to_representation.model.get(\"delete_scheduled\")) {\n opacity = 0.5;\n this.line.dashArray = [2, 2];\n } else {\n opacity = 1;\n this.line.dashArray = null;\n }\n\n var old_act_btn = this.active_buttons;\n\n this.active_buttons = this.model.get(\"delete_scheduled\") ? this.pending_delete_buttons : this.normal_buttons;\n\n if (this.selected && this.renderer.isEditable() && old_act_btn !== this.active_buttons) {\n old_act_btn.forEach(function(b) {\n b.hide();\n });\n this.active_buttons.forEach(function(b) {\n b.show();\n });\n }\n\n this.paper_coords = _p0b.add(_p1b).divide(2);\n this.line.strokeColor = _color;\n this.line.opacity = opacity;\n this.line.segments[0].point = _p0a;\n this.line.segments[1].point = this.paper_coords;\n this.line.segments[1].handleIn = _handle.multiply(-1);\n this.line.segments[1].handleOut = _handle;\n this.line.segments[2].point = _p1a;\n this.arrow.rotate(_a - this.arrow_angle);\n this.arrow.fillColor = _color;\n this.arrow.opacity = opacity;\n this.arrow.position = this.paper_coords;\n this.arrow_angle = _a;\n if (_a > 90) {\n _a -= 180;\n _textdelta = _textdelta.multiply(-1);\n }\n if (_a < -90) {\n _a += 180;\n _textdelta = _textdelta.multiply(-1);\n }\n var _text = this.model.get(\"title\") || this.renkan.translate(this.options.label_untitled_edges) || \"\";\n _text = Utils.shortenText(_text, this.options.node_label_max_length);\n this.text.text(_text);\n var _textpos = this.paper_coords.add(_textdelta);\n this.text.css({\n left: _textpos.x,\n top: _textpos.y,\n transform: \"rotate(\" + _a + \"deg)\",\n \"-moz-transform\": \"rotate(\" + _a + \"deg)\",\n \"-webkit-transform\": \"rotate(\" + _a + \"deg)\",\n opacity: opacity\n });\n this.text_angle = _a;\n\n var _pc = this.paper_coords;\n this.all_buttons.forEach(function(b) {\n b.moveTo(_pc);\n });\n\n if (this.renderer.minimap) {\n this.minimap_line.strokeColor = _color;\n this.minimap_line.segments[0].point = this.renderer.toMinimapCoords(new paper.Point(this.from_representation.model.get(\"position\")));\n this.minimap_line.segments[1].point = this.renderer.toMinimapCoords(new paper.Point(this.to_representation.model.get(\"position\")));\n }\n },\n openEditor: function() {\n this.renderer.removeRepresentationsOfType(\"editor\");\n var _editor = this.renderer.addRepresentation(\"EdgeEditor\",null);\n _editor.source_representation = this;\n _editor.draw();\n },\n select: function() {\n this.selected = true;\n this.line.strokeWidth = this.options.selected_edge_stroke_width;\n if (this.renderer.isEditable()) {\n this.active_buttons.forEach(function(b) {\n b.show();\n });\n }\n if (!this.options.editor_mode) {\n this.openEditor();\n }\n this._super(\"select\");\n },\n unselect: function(_newTarget) {\n if (!_newTarget || _newTarget.source_representation !== this) {\n this.selected = false;\n if (this.options.editor_mode) {\n this.all_buttons.forEach(function(b) {\n b.hide();\n });\n }\n this.line.strokeWidth = this.options.edge_stroke_width;\n this._super(\"unselect\");\n }\n },\n mousedown: function(_event, _isTouch) {\n if (_isTouch) {\n this.renderer.unselectAll();\n this.select();\n }\n },\n mouseup: function(_event, _isTouch) {\n if (!this.renkan.read_only && this.renderer.is_dragging) {\n this.from_representation.saveCoords();\n this.to_representation.saveCoords();\n this.from_representation.is_dragging = false;\n this.to_representation.is_dragging = false;\n } else {\n if (!_isTouch) {\n this.openEditor();\n }\n this.model.trigger(\"clicked\");\n }\n this.renderer.click_target = null;\n this.renderer.is_dragging = false;\n },\n paperShift: function(_delta) {\n if (this.options.editor_mode) {\n if (!this.options.read_only) {\n this.from_representation.paperShift(_delta);\n this.to_representation.paperShift(_delta);\n }\n } else {\n this.renderer.paperShift(_delta);\n }\n },\n destroy: function() {\n this._super(\"destroy\");\n this.line.remove();\n this.arrow.remove();\n this.text.remove();\n if (this.renderer.minimap) {\n this.minimap_line.remove();\n }\n this.all_buttons.forEach(function(b) {\n b.destroy();\n });\n var _this = this;\n this.bundle.edges = _(this.bundle.edges).reject(function(_edge) {\n return _this === _edge;\n });\n }\n });\n\n return Edge;\n\n});\n\n\n\ndefine('renderer/tempedge',['jquery', 'underscore', 'requtils', 'renderer/baserepresentation'], function ($, _, requtils, BaseRepresentation) {\n \n\n var Utils = requtils.getUtils();\n\n /* TempEdge Class Begin */\n\n //var TempEdge = Renderer.TempEdge = Utils.inherit(Renderer._BaseRepresentation);\n var TempEdge = Utils.inherit(BaseRepresentation);\n\n _(TempEdge.prototype).extend({\n _init: function() {\n this.renderer.edge_layer.activate();\n this.type = \"Temp-edge\";\n\n var _color = (this.project.get(\"users\").get(this.renkan.current_user) || Utils._USER_PLACEHOLDER(this.renkan)).get(\"color\");\n this.line = new paper.Path();\n this.line.strokeColor = _color;\n this.line.dashArray = [4, 2];\n this.line.strokeWidth = this.options.selected_edge_stroke_width;\n this.line.add([0,0],[0,0]);\n this.line.__representation = this;\n this.arrow = new paper.Path();\n this.arrow.fillColor = _color;\n this.arrow.add(\n [ 0, 0 ],\n [ this.options.edge_arrow_length, this.options.edge_arrow_width / 2 ],\n [ 0, this.options.edge_arrow_width ]\n );\n this.arrow.__representation = this;\n this.arrow_angle = 0;\n },\n redraw: function() {\n var _p0 = this.from_representation.paper_coords,\n _p1 = this.end_pos,\n _a = _p1.subtract(_p0).angle,\n _c = _p0.add(_p1).divide(2);\n this.line.segments[0].point = _p0;\n this.line.segments[1].point = _p1;\n this.arrow.rotate(_a - this.arrow_angle);\n this.arrow.position = _c;\n this.arrow_angle = _a;\n },\n paperShift: function(_delta) {\n if (!this.renderer.isEditable()) {\n this.renderer.removeRepresentation(_this);\n paper.view.draw();\n return;\n }\n this.end_pos = this.end_pos.add(_delta);\n var _hitResult = paper.project.hitTest(this.end_pos);\n this.renderer.findTarget(_hitResult);\n this.redraw();\n },\n mouseup: function(_event, _isTouch) {\n var _hitResult = paper.project.hitTest(_event.point),\n _model = this.from_representation.model,\n _endDrag = true;\n if (_hitResult && typeof _hitResult.item.__representation !== \"undefined\") {\n var _target = _hitResult.item.__representation;\n if (_target.type.substr(0,4) === \"Node\") {\n var _destmodel = _target.model || _target.source_representation.model;\n if (_model !== _destmodel) {\n var _data = {\n id: Utils.getUID('edge'),\n created_by: this.renkan.current_user,\n from: _model,\n to: _destmodel\n };\n if (this.renderer.isEditable()) {\n this.project.addEdge(_data);\n }\n }\n }\n\n if (_model === _target.model || (_target.source_representation && _target.source_representation.model === _model)) {\n _endDrag = false;\n this.renderer.is_dragging = true;\n }\n }\n if (_endDrag) {\n this.renderer.click_target = null;\n this.renderer.is_dragging = false;\n this.renderer.removeRepresentation(this);\n paper.view.draw();\n }\n },\n destroy: function() {\n this.arrow.remove();\n this.line.remove();\n }\n });\n\n /* TempEdge Class End */\n\n return TempEdge;\n\n});\n\n\ndefine('renderer/baseeditor',['jquery', 'underscore', 'requtils', 'renderer/baserepresentation'], function ($, _, requtils, BaseRepresentation) {\n \n\n var Utils = requtils.getUtils();\n\n /* _BaseEditor Begin */\n //var _BaseEditor = Renderer._BaseEditor = Utils.inherit(Renderer._BaseRepresentation);\n var _BaseEditor = Utils.inherit(BaseRepresentation);\n\n _(_BaseEditor.prototype).extend({\n _init: function() {\n this.renderer.buttons_layer.activate();\n this.type = \"editor\";\n this.editor_block = new paper.Path();\n var _pts = _(_.range(8)).map(function() {return [0,0];});\n this.editor_block.add.apply(this.editor_block, _pts);\n this.editor_block.strokeWidth = this.options.tooltip_border_width;\n this.editor_block.strokeColor = this.options.tooltip_border_color;\n this.editor_block.opacity = 0.8;\n this.editor_$ = $('<div>')\n .appendTo(this.renderer.editor_$)\n .css({\n position: \"absolute\",\n opacity: 0.8\n })\n .hide();\n },\n destroy: function() {\n this.editor_block.remove();\n this.editor_$.remove();\n }\n });\n\n /* _BaseEditor End */\n\n return _BaseEditor;\n\n});\n\n\ndefine('renderer/nodeeditor',['jquery', 'underscore', 'requtils', 'renderer/baseeditor'], function ($, _, requtils, BaseEditor) {\n \n\n var Utils = requtils.getUtils();\n\n /* NodeEditor Begin */\n //var NodeEditor = Renderer.NodeEditor = Utils.inherit(Renderer._BaseEditor);\n var NodeEditor = Utils.inherit(BaseEditor);\n\n _(NodeEditor.prototype).extend({\n template: _.template(\n '<h2><span class=\"Rk-CloseX\">×</span><%-renkan.translate(\"Edit Node\")%></span></h2>' +\n '<p><label><%-renkan.translate(\"Title:\")%></label><input class=\"Rk-Edit-Title\" type=\"text\" value=\"<%-node.title%>\"/></p>' +\n '<% if (options.show_node_editor_uri) { %><p><label><%-renkan.translate(\"URI:\")%></label><input class=\"Rk-Edit-URI\" type=\"text\" value=\"<%-node.uri%>\"/><a class=\"Rk-Edit-Goto\" href=\"<%-node.uri%>\" target=\"_blank\"></a></p><% } %>' +\n '<% if (options.show_node_editor_description) { %><p><label><%-renkan.translate(\"Description:\")%></label><textarea class=\"Rk-Edit-Description\"><%-node.description%></textarea></p><% } %>' +\n '<% if (options.show_node_editor_size) { %><p><span class=\"Rk-Editor-Label\"><%-renkan.translate(\"Size:\")%></span><a href=\"#\" class=\"Rk-Edit-Size-Down\">-</a><span class=\"Rk-Edit-Size-Value\"><%-node.size%></span><a href=\"#\" class=\"Rk-Edit-Size-Up\">+</a></p><% } %>' +\n '<% if (options.show_node_editor_color) { %><div class=\"Rk-Editor-p\"><span class=\"Rk-Editor-Label\"><%-renkan.translate(\"Node color:\")%></span><div class=\"Rk-Edit-ColorPicker-Wrapper\"><span class=\"Rk-Edit-Color\" style=\"background:<%-node.color%>;\"><span class=\"Rk-Edit-ColorTip\"></span></span>' +\n '<%= renkan.colorPicker %><span class=\"Rk-Edit-ColorPicker-Text\"><%- renkan.translate(\"Choose color\") %></span></div></div><% } %>' +\n '<% if (options.show_node_editor_image) { %><div class=\"Rk-Edit-ImgWrap\"><div class=\"Rk-Edit-ImgPreview\"><img src=\"<%-node.image || node.image_placeholder%>\" />' +\n '<% if (node.clip_path) { %><svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" viewbox=\"0 0 1 1\" preserveAspectRatio=\"none\"><path style=\"stroke-width: .02; stroke:red; fill-opacity:.3; fill:red;\" d=\"<%- node.clip_path %>\"/></svg><% }%>' +\n '</div></div><p><label><%-renkan.translate(\"Image URL:\")%></label><input class=\"Rk-Edit-Image\" type=\"text\" value=\"<%-node.image%>\"/></p>' +\n '<p><label><%-renkan.translate(\"Choose Image File:\")%></label><input class=\"Rk-Edit-Image-File\" type=\"file\" accept=\"image/*\"/></p><% } %>' +\n '<% if (options.show_node_editor_creator && node.has_creator) { %><p><span class=\"Rk-Editor-Label\"><%-renkan.translate(\"Created by:\")%></span> <span class=\"Rk-UserColor\" style=\"background:<%-node.created_by_color%>;\"></span><%- shortenText(node.created_by_title, 25) %></p><% } %>' +\n '<% if (options.change_shapes) { %><p><label><%-renkan.translate(\"Shapes available\")%>:</label> <select class=\"Rk-Edit-Shape\">' +\n '<option class=\"Rk-Edit-Vocabulary-Property\" value=\"circle\"<% if (node.shape === \"circle\") { %> selected<% } %>><%- renkan.translate(\"Circle\") %></option>' +\n '<option class=\"Rk-Edit-Vocabulary-Property\" value=\"rectangle\"<% if (node.shape === \"rectangle\") { %> selected<% } %>><%- renkan.translate(\"Square\") %></option>' +\n '<option class=\"Rk-Edit-Vocabulary-Property\" value=\"diamond\"<% if (node.shape === \"diamond\") { %> selected<% } %>><%- renkan.translate(\"Diamond\") %></option>' +\n '<option class=\"Rk-Edit-Vocabulary-Property\" value=\"polygon\"<% if (node.shape === \"polygon\") { %> selected<% } %>><%- renkan.translate(\"Hexagone\") %></option>' +\n '<option class=\"Rk-Edit-Vocabulary-Property\" value=\"ellipse\"<% if (node.shape === \"ellipse\") { %> selected<% } %>><%- renkan.translate(\"Ellipse\") %></option>' +\n '<option class=\"Rk-Edit-Vocabulary-Property\" value=\"star\"<% if (node.shape === \"star\") { %> selected<% } %>><%- renkan.translate(\"Star\") %></option>' +\n '</select></p><% } %>'\n ),\n readOnlyTemplate: _.template(\n '<h2><span class=\"Rk-CloseX\">×</span><% if (options.show_node_tooltip_color) { %><span class=\"Rk-UserColor\" style=\"background:<%-node.color%>;\"></span><% } %>' +\n '<span class=\"Rk-Display-Title\"><% if (node.uri) { %><a href=\"<%-node.uri%>\" target=\"_blank\"><% } %><%-node.title%><% if (node.uri) { %></a><% } %></span></h2>' +\n '<% if (node.uri && options.show_node_tooltip_uri) { %><p class=\"Rk-Display-URI\"><a href=\"<%-node.uri%>\" target=\"_blank\"><%-node.short_uri%></a></p><% } %>' +\n '<% if (options.show_node_tooltip_description) { %><p class=\"Rk-Display-Description\"><%-node.description%></p><% } %>' +\n '<% if (node.image && options.show_node_tooltip_image) { %><img class=\"Rk-Display-ImgPreview\" src=\"<%-node.image%>\" /><% } %>' +\n '<% if (node.has_creator && options.show_node_tooltip_creator) { %><p><span class=\"Rk-Editor-Label\"><%-renkan.translate(\"Created by:\")%></span><span class=\"Rk-UserColor\" style=\"background:<%-node.created_by_color%>;\"></span><%- shortenText(node.created_by_title, 25) %></p><% } %>'\n ),\n draw: function() {\n var _model = this.source_representation.model,\n _created_by = _model.get(\"created_by\") || Utils._USER_PLACEHOLDER(this.renkan),\n _template = (this.renderer.isEditable() ? this.template : this.readOnlyTemplate ),\n _image_placeholder = this.options.static_url + \"img/image-placeholder.png\",\n _size = (_model.get(\"size\") || 0);\n this.editor_$\n .html(_template({\n node: {\n has_creator: !!_model.get(\"created_by\"),\n title: _model.get(\"title\"),\n uri: _model.get(\"uri\"),\n short_uri: Utils.shortenText((_model.get(\"uri\") || \"\").replace(/^(https?:\\/\\/)?(www\\.)?/,'').replace(/\\/$/,''),40),\n description: _model.get(\"description\"),\n image: _model.get(\"image\") || \"\",\n image_placeholder: _image_placeholder,\n color: _model.get(\"color\") || _created_by.get(\"color\"),\n clip_path: _model.get(\"clip_path\") || false,\n created_by_color: _created_by.get(\"color\"),\n created_by_title: _created_by.get(\"title\"),\n size: (_size > 0 ? \"+\" : \"\") + _size,\n shape: _model.get(\"shape\") || \"circle\"\n },\n renkan: this.renkan,\n options: this.options,\n shortenText: Utils.shortenText\n }));\n this.redraw();\n var _this = this,\n closeEditor = function() {\n _this.renderer.removeRepresentation(_this);\n paper.view.draw();\n };\n\n this.editor_$.find(\".Rk-CloseX\").click(closeEditor);\n\n this.editor_$.find(\".Rk-Edit-Goto\").click(function() {\n if (!_model.get(\"uri\")) {\n return false;\n }\n });\n\n if (this.renderer.isEditable()) {\n\n var onFieldChange = _(function() {\n _(function() {\n if (_this.renderer.isEditable()) {\n var _data = {\n title: _this.editor_$.find(\".Rk-Edit-Title\").val()\n };\n if (_this.options.show_node_editor_uri) {\n _data.uri = _this.editor_$.find(\".Rk-Edit-URI\").val();\n _this.editor_$.find(\".Rk-Edit-Goto\").attr(\"href\",_data.uri || \"#\");\n }\n if (_this.options.show_node_editor_image) {\n _data.image = _this.editor_$.find(\".Rk-Edit-Image\").val();\n _this.editor_$.find(\".Rk-Edit-ImgPreview\").attr(\"src\", _data.image || _image_placeholder);\n }\n if (_this.options.show_node_editor_description) {\n _data.description = _this.editor_$.find(\".Rk-Edit-Description\").val();\n }\n if (_this.options.change_shapes) {\n if(_model.get(\"shape\")!==_this.editor_$.find(\".Rk-Edit-Shape\").val()){\n _data.shape = _this.editor_$.find(\".Rk-Edit-Shape\").val();\n _data.shape_changed = true;\n }\n }\n _model.set(_data);\n _this.redraw();\n // For an unknown reason, we have to set data twice when we change shape, otherwise the image disappears.\n if(_data.shape_changed===true){\n _model.set(_data);\n }\n } else {\n closeEditor();\n }\n }).defer();\n }).throttle(500);\n \n this.editor_$.on(\"keyup\", function(_e) {\n if (_e.keyCode === 27) {\n closeEditor();\n }\n });\n\n this.editor_$.find(\"input, textarea, select\").on(\"change keyup paste\", onFieldChange);\n\n this.editor_$.find(\".Rk-Edit-Image-File\").change(function() {\n if (this.files.length) {\n var f = this.files[0],\n fr = new FileReader();\n if (f.type.substr(0,5) !== \"image\") {\n alert(_this.renkan.translate(\"This file is not an image\"));\n return;\n }\n if (f.size > (_this.options.uploaded_image_max_kb * 1024)) {\n alert(_this.renkan.translate(\"Image size must be under \") + _this.options.uploaded_image_max_kb + _this.renkan.translate(\"KB\"));\n return;\n }\n fr.onload = function(e) {\n _this.editor_$.find(\".Rk-Edit-Image\").val(e.target.result);\n onFieldChange();\n };\n fr.readAsDataURL(f);\n }\n });\n this.editor_$.find(\".Rk-Edit-Title\")[0].focus();\n\n var _picker = _this.editor_$.find(\".Rk-Edit-ColorPicker\");\n\n this.editor_$.find(\".Rk-Edit-ColorPicker-Wrapper\").hover(\n function(_e) {\n _e.preventDefault();\n _picker.show();\n },\n function(_e) {\n _e.preventDefault();\n _picker.hide();\n }\n );\n\n _picker.find(\"li\").hover(\n function(_e) {\n _e.preventDefault();\n _this.editor_$.find(\".Rk-Edit-Color\").css(\"background\", $(this).attr(\"data-color\"));\n },\n function(_e) {\n _e.preventDefault();\n _this.editor_$.find(\".Rk-Edit-Color\").css(\"background\", _model.get(\"color\") || (_model.get(\"created_by\") || Utils._USER_PLACEHOLDER(_this.renkan)).get(\"color\"));\n }\n ).click(function(_e) {\n _e.preventDefault();\n if (_this.renderer.isEditable()) {\n _model.set(\"color\", $(this).attr(\"data-color\"));\n _picker.hide();\n paper.view.draw();\n } else {\n closeEditor();\n }\n });\n\n var shiftSize = function(n) {\n if (_this.renderer.isEditable()) {\n var _newsize = n+(_model.get(\"size\") || 0);\n _this.editor_$.find(\".Rk-Edit-Size-Value\").text((_newsize > 0 ? \"+\" : \"\") + _newsize);\n _model.set(\"size\", _newsize);\n paper.view.draw();\n } else {\n closeEditor();\n }\n };\n\n this.editor_$.find(\".Rk-Edit-Size-Down\").click(function() {\n shiftSize(-1);\n return false;\n });\n this.editor_$.find(\".Rk-Edit-Size-Up\").click(function() {\n shiftSize(1);\n return false;\n });\n } else {\n if (typeof this.source_representation.highlighted === \"object\") {\n var titlehtml = this.source_representation.highlighted.replace(_(_model.get(\"title\")).escape(),'<span class=\"Rk-Highlighted\">$1</span>');\n this.editor_$.find(\".Rk-Display-Title\" + (_model.get(\"uri\") ? \" a\" : \"\")).html(titlehtml);\n if (this.options.show_node_tooltip_description) {\n this.editor_$.find(\".Rk-Display-Description\").html(this.source_representation.highlighted.replace(_(_model.get(\"description\")).escape(),'<span class=\"Rk-Highlighted\">$1</span>'));\n }\n }\n }\n this.editor_$.find(\"img\").load(function() {\n _this.redraw();\n });\n },\n redraw: function() {\n var _coords = this.source_representation.paper_coords;\n Utils.drawEditBox(this.options, _coords, this.editor_block, this.source_representation.circle_radius * 0.75, this.editor_$);\n this.editor_$.show();\n paper.view.draw();\n }\n });\n\n /* NodeEditor End */\n\n return NodeEditor;\n\n});\n\n\ndefine('renderer/edgeeditor',['jquery', 'underscore', 'requtils', 'renderer/baseeditor'], function ($, _, requtils, BaseEditor) {\n \n\n var Utils = requtils.getUtils();\n\n /* EdgeEditor Begin */\n\n //var EdgeEditor = Renderer.EdgeEditor = Utils.inherit(Renderer._BaseEditor);\n var EdgeEditor = Utils.inherit(BaseEditor);\n\n _(EdgeEditor.prototype).extend({\n template: _.template(\n '<h2><span class=\"Rk-CloseX\">×</span><%-renkan.translate(\"Edit Edge\")%></span></h2>' +\n '<p><label><%-renkan.translate(\"Title:\")%></label><input class=\"Rk-Edit-Title\" type=\"text\" value=\"<%-edge.title%>\"/></p>' +\n '<% if (options.show_edge_editor_uri) { %><p><label><%-renkan.translate(\"URI:\")%></label><input class=\"Rk-Edit-URI\" type=\"text\" value=\"<%-edge.uri%>\"/><a class=\"Rk-Edit-Goto\" href=\"<%-edge.uri%>\" target=\"_blank\"></a></p>' +\n '<% if (options.properties.length) { %><p><label><%-renkan.translate(\"Choose from vocabulary:\")%></label><select class=\"Rk-Edit-Vocabulary\">' +\n '<% _(options.properties).each(function(ontology) { %><option class=\"Rk-Edit-Vocabulary-Class\" value=\"\"><%- renkan.translate(ontology.label) %></option>' +\n '<% _(ontology.properties).each(function(property) { var uri = ontology[\"base-uri\"] + property.uri; %><option class=\"Rk-Edit-Vocabulary-Property\" value=\"<%- uri %>' +\n '\"<% if (uri === edge.uri) { %> selected<% } %>><%- renkan.translate(property.label) %></option>' +\n '<% }) %><% }) %></select></p><% } } %>' +\n '<% if (options.show_edge_editor_color) { %><div class=\"Rk-Editor-p\"><span class=\"Rk-Editor-Label\"><%-renkan.translate(\"Edge color:\")%></span><div class=\"Rk-Edit-ColorPicker-Wrapper\"><span class=\"Rk-Edit-Color\" style=\"background:<%-edge.color%>;\"><span class=\"Rk-Edit-ColorTip\"></span></span>' +\n '<%= renkan.colorPicker %><span class=\"Rk-Edit-ColorPicker-Text\"><%- renkan.translate(\"Choose color\") %></span></div></div><% } %>' +\n '<% if (options.show_edge_editor_direction) { %><p><span class=\"Rk-Edit-Direction\"><%- renkan.translate(\"Change edge direction\") %></span></p><% } %>' +\n '<% if (options.show_edge_editor_nodes) { %><p><span class=\"Rk-Editor-Label\"><%-renkan.translate(\"From:\")%></span><span class=\"Rk-UserColor\" style=\"background:<%-edge.from_color%>;\"></span><%- shortenText(edge.from_title, 25) %></p>' +\n '<p><span class=\"Rk-Editor-Label\"><%-renkan.translate(\"To:\")%></span><span class=\"Rk-UserColor\" style=\"background:<%-edge.to_color%>;\"></span><%- shortenText(edge.to_title, 25) %></p><% } %>' +\n '<% if (options.show_edge_editor_creator && edge.has_creator) { %><p><span class=\"Rk-Editor-Label\"><%-renkan.translate(\"Created by:\")%></span><span class=\"Rk-UserColor\" style=\"background:<%-edge.created_by_color%>;\"></span><%- shortenText(edge.created_by_title, 25) %></p><% } %>'\n ),\n readOnlyTemplate: _.template(\n '<h2><span class=\"Rk-CloseX\">×</span><% if (options.show_edge_tooltip_color) { %><span class=\"Rk-UserColor\" style=\"background:<%-edge.color%>;\"></span><% } %>' +\n '<span class=\"Rk-Display-Title\"><% if (edge.uri) { %><a href=\"<%-edge.uri%>\" target=\"_blank\"><% } %><%-edge.title%><% if (edge.uri) { %></a><% } %></span></h2>' +\n '<% if (options.show_edge_tooltip_uri && edge.uri) { %><p class=\"Rk-Display-URI\"><a href=\"<%-edge.uri%>\" target=\"_blank\"><%-edge.short_uri%></a></p><% } %>' +\n '<p><%-edge.description%></p>' +\n '<% if (options.show_edge_tooltip_nodes) { %><p><span class=\"Rk-Editor-Label\"><%-renkan.translate(\"From:\")%></span><span class=\"Rk-UserColor\" style=\"background:<%-edge.from_color%>;\"></span><%- shortenText(edge.from_title, 25) %></p>' +\n '<p><span class=\"Rk-Editor-Label\"><%-renkan.translate(\"To:\")%></span><span class=\"Rk-UserColor\" style=\"background:<%-edge.to_color%>;\"></span><%- shortenText(edge.to_title, 25) %></p><% } %>' +\n '<% if (options.show_edge_tooltip_creator && edge.has_creator) { %><p><span class=\"Rk-Editor-Label\"><%-renkan.translate(\"Created by:\")%></span><span class=\"Rk-UserColor\" style=\"background:<%-edge.created_by_color%>;\"></span><%- shortenText(edge.created_by_title, 25) %></p><% } %>'\n ),\n draw: function() {\n var _model = this.source_representation.model,\n _from_model = _model.get(\"from\"),\n _to_model = _model.get(\"to\"),\n _created_by = _model.get(\"created_by\") || Utils._USER_PLACEHOLDER(this.renkan),\n _template = (this.renderer.isEditable() ? this.template : this.readOnlyTemplate);\n this.editor_$\n .html(_template({\n edge: {\n has_creator: !!_model.get(\"created_by\"),\n title: _model.get(\"title\"),\n uri: _model.get(\"uri\"),\n short_uri: Utils.shortenText((_model.get(\"uri\") || \"\").replace(/^(https?:\\/\\/)?(www\\.)?/,'').replace(/\\/$/,''),40),\n description: _model.get(\"description\"),\n color: _model.get(\"color\") || _created_by.get(\"color\"),\n from_title: _from_model.get(\"title\"),\n to_title: _to_model.get(\"title\"),\n from_color: _from_model.get(\"color\") || (_from_model.get(\"created_by\") || Utils._USER_PLACEHOLDER(this.renkan)).get(\"color\"),\n to_color: _to_model.get(\"color\") || (_to_model.get(\"created_by\") || Utils._USER_PLACEHOLDER(this.renkan)).get(\"color\"),\n created_by_color: _created_by.get(\"color\"),\n created_by_title: _created_by.get(\"title\")\n },\n renkan: this.renkan,\n shortenText: Utils.shortenText,\n options: this.options\n }));\n this.redraw();\n var _this = this,\n closeEditor = function() {\n _this.renderer.removeRepresentation(_this);\n paper.view.draw();\n };\n this.editor_$.find(\".Rk-CloseX\").click(closeEditor);\n this.editor_$.find(\".Rk-Edit-Goto\").click(function() {\n if (!_model.get(\"uri\")) {\n return false;\n }\n });\n\n if (this.renderer.isEditable()) {\n\n var onFieldChange = _(function() {\n _(function() {\n if (_this.renderer.isEditable()) {\n var _data = {\n title: _this.editor_$.find(\".Rk-Edit-Title\").val()\n };\n if (_this.options.show_edge_editor_uri) {\n _data.uri = _this.editor_$.find(\".Rk-Edit-URI\").val();\n }\n _this.editor_$.find(\".Rk-Edit-Goto\").attr(\"href\",_data.uri || \"#\");\n _model.set(_data);\n paper.view.draw();\n } else {\n closeEditor();\n }\n }).defer();\n }).throttle(500);\n\n this.editor_$.on(\"keyup\", function(_e) {\n if (_e.keyCode === 27) {\n closeEditor();\n }\n });\n\n this.editor_$.find(\"input\").on(\"keyup change paste\", onFieldChange);\n\n this.editor_$.find(\".Rk-Edit-Vocabulary\").change(function() {\n var e = $(this),\n v = e.val();\n if (v) {\n _this.editor_$.find(\".Rk-Edit-Title\").val(e.find(\":selected\").text());\n _this.editor_$.find(\".Rk-Edit-URI\").val(v);\n onFieldChange();\n }\n });\n this.editor_$.find(\".Rk-Edit-Direction\").click(function() {\n if (_this.renderer.isEditable()) {\n _model.set({\n from: _model.get(\"to\"),\n to: _model.get(\"from\")\n });\n _this.draw();\n } else {\n closeEditor();\n }\n });\n\n var _picker = _this.editor_$.find(\".Rk-Edit-ColorPicker\");\n\n this.editor_$.find(\".Rk-Edit-ColorPicker-Wrapper\").hover(\n function(_e) {\n _e.preventDefault();\n _picker.show();\n },\n function(_e) {\n _e.preventDefault();\n _picker.hide();\n }\n );\n\n _picker.find(\"li\").hover(\n function(_e) {\n _e.preventDefault();\n _this.editor_$.find(\".Rk-Edit-Color\").css(\"background\", $(this).attr(\"data-color\"));\n },\n function(_e) {\n _e.preventDefault();\n _this.editor_$.find(\".Rk-Edit-Color\").css(\"background\", _model.get(\"color\") || (_model.get(\"created_by\") || Utils._USER_PLACEHOLDER(_this.renkan)).get(\"color\"));\n }\n ).click(function(_e) {\n _e.preventDefault();\n if (_this.renderer.isEditable()) {\n _model.set(\"color\", $(this).attr(\"data-color\"));\n _picker.hide();\n paper.view.draw();\n } else {\n closeEditor();\n }\n });\n }\n },\n redraw: function() {\n var _coords = this.source_representation.paper_coords;\n Utils.drawEditBox(this.options, _coords, this.editor_block, 5, this.editor_$);\n this.editor_$.show();\n paper.view.draw();\n }\n });\n\n /* EdgeEditor End */\n\n return EdgeEditor;\n\n});\n\n\ndefine('renderer/nodebutton',['jquery', 'underscore', 'requtils', 'renderer/basebutton'], function ($, _, requtils, BaseButton) {\n \n \n var Utils = requtils.getUtils();\n\n /* _NodeButton Begin */\n\n //var _NodeButton = Renderer._NodeButton = Utils.inherit(Renderer._BaseButton);\n var _NodeButton = Utils.inherit(BaseButton);\n\n _(_NodeButton.prototype).extend({\n setSectorSize: function() {\n var sectorInner = this.source_representation.circle_radius;\n if (sectorInner !== this.lastSectorInner) {\n if (this.sector) {\n this.sector.destroy();\n }\n this.sector = this.renderer.drawSector(\n this, 1 + sectorInner,\n Utils._NODE_BUTTON_WIDTH + sectorInner,\n this.startAngle,\n this.endAngle,\n 1,\n this.imageName,\n this.renkan.translate(this.text)\n );\n this.lastSectorInner = sectorInner;\n }\n }\n });\n\n /* _NodeButton End */\n\n return _NodeButton;\n\n});\n\n\ndefine('renderer/nodeeditbutton',['jquery', 'underscore', 'requtils', 'renderer/nodebutton'], function ($, _, requtils, NodeButton) {\n \n\n var Utils = requtils.getUtils();\n\n /* NodeEditButton Begin */\n\n //var NodeEditButton = Renderer.NodeEditButton = Utils.inherit(Renderer._NodeButton);\n var NodeEditButton = Utils.inherit(NodeButton);\n\n _(NodeEditButton.prototype).extend({\n _init: function() {\n this.type = \"Node-edit-button\";\n this.lastSectorInner = 0;\n this.startAngle = -135;\n this.endAngle = -45;\n this.imageName = \"edit\";\n this.text = \"Edit\";\n },\n mouseup: function() {\n if (!this.renderer.is_dragging) {\n this.source_representation.openEditor();\n }\n }\n });\n\n /* NodeEditButton End */\n\n return NodeEditButton;\n\n});\n\n\ndefine('renderer/noderemovebutton',['jquery', 'underscore', 'requtils', 'renderer/nodebutton'], function ($, _, requtils, NodeButton) {\n \n \n var Utils = requtils.getUtils();\n\n /* NodeRemoveButton Begin */\n\n //var NodeRemoveButton = Renderer.NodeRemoveButton = Utils.inherit(Renderer._NodeButton);\n var NodeRemoveButton = Utils.inherit(NodeButton);\n\n _(NodeRemoveButton.prototype).extend({\n _init: function() {\n this.type = \"Node-remove-button\";\n this.lastSectorInner = 0;\n this.startAngle = 0;\n this.endAngle = 90;\n this.imageName = \"remove\";\n this.text = \"Remove\";\n },\n mouseup: function() {\n this.renderer.click_target = null;\n this.renderer.is_dragging = false;\n this.renderer.removeRepresentationsOfType(\"editor\");\n if (this.renderer.isEditable()) {\n if (this.options.element_delete_delay) {\n var delid = Utils.getUID(\"delete\");\n this.renderer.delete_list.push({\n id: delid,\n time: new Date().valueOf() + this.options.element_delete_delay\n });\n this.source_representation.model.set(\"delete_scheduled\", delid);\n } else {\n if (confirm(this.renkan.translate('Do you really wish to remove node ') + '\"' + this.source_representation.model.get(\"title\") + '\"?')) {\n this.project.removeNode(this.source_representation.model);\n }\n }\n }\n }\n });\n\n /* NodeRemoveButton End */\n\n return NodeRemoveButton;\n\n});\n\n\ndefine('renderer/noderevertbutton',['jquery', 'underscore', 'requtils', 'renderer/nodebutton'], function ($, _, requtils, NodeButton) {\n \n\n var Utils = requtils.getUtils();\n\n /* NodeRevertButton Begin */\n\n //var NodeRevertButton = Renderer.NodeRevertButton = Utils.inherit(Renderer._NodeButton);\n var NodeRevertButton = Utils.inherit(NodeButton);\n\n _(NodeRevertButton.prototype).extend({\n _init: function() {\n this.type = \"Node-revert-button\";\n this.lastSectorInner = 0;\n this.startAngle = -135;\n this.endAngle = 135;\n this.imageName = \"revert\";\n this.text = \"Cancel deletion\";\n },\n mouseup: function() {\n this.renderer.click_target = null;\n this.renderer.is_dragging = false;\n if (this.renderer.isEditable()) {\n this.source_representation.model.unset(\"delete_scheduled\");\n }\n }\n });\n\n /* NodeRevertButton End */\n\n return NodeRevertButton;\n\n});\n\n\ndefine('renderer/nodelinkbutton',['jquery', 'underscore', 'requtils', 'renderer/nodebutton'], function ($, _, requtils, NodeButton) {\n \n\n var Utils = requtils.getUtils();\n\n /* NodeLinkButton Begin */\n\n //var NodeLinkButton = Renderer.NodeLinkButton = Utils.inherit(Renderer._NodeButton);\n var NodeLinkButton = Utils.inherit(NodeButton);\n\n _(NodeLinkButton.prototype).extend({\n _init: function() {\n this.type = \"Node-link-button\";\n this.lastSectorInner = 0;\n this.startAngle = 90;\n this.endAngle = 180;\n this.imageName = \"link\";\n this.text = \"Link to another node\";\n },\n mousedown: function(_event, _isTouch) {\n if (this.renderer.isEditable()) {\n var _off = this.renderer.canvas_$.offset(),\n _point = new paper.Point([\n _event.pageX - _off.left,\n _event.pageY - _off.top\n ]);\n this.renderer.click_target = null;\n this.renderer.removeRepresentationsOfType(\"editor\");\n this.renderer.addTempEdge(this.source_representation, _point);\n }\n }\n });\n\n /* NodeLinkButton End */\n\n return NodeLinkButton;\n\n});\n\n\n\ndefine('renderer/nodeenlargebutton',['jquery', 'underscore', 'requtils', 'renderer/nodebutton'], function ($, _, requtils, NodeButton) {\n \n \n var Utils = requtils.getUtils();\n\n /* NodeEnlargeButton Begin */\n\n //var NodeEnlargeButton = Renderer.NodeEnlargeButton = Utils.inherit(Renderer._NodeButton);\n var NodeEnlargeButton = Utils.inherit(NodeButton);\n\n _(NodeEnlargeButton.prototype).extend({\n _init: function() {\n this.type = \"Node-enlarge-button\";\n this.lastSectorInner = 0;\n this.startAngle = -45;\n this.endAngle = 0;\n this.imageName = \"enlarge\";\n this.text = \"Enlarge\";\n },\n mouseup: function() {\n var _newsize = 1 + (this.source_representation.model.get(\"size\") || 0);\n this.source_representation.model.set(\"size\", _newsize);\n this.source_representation.select();\n this.select();\n paper.view.draw();\n }\n });\n\n /* NodeEnlargeButton End */\n\n return NodeEnlargeButton;\n\n});\n\n\ndefine('renderer/nodeshrinkbutton',['jquery', 'underscore', 'requtils', 'renderer/nodebutton'], function ($, _, requtils, NodeButton) {\n \n\n var Utils = requtils.getUtils();\n\n /* NodeShrinkButton Begin */\n\n //var NodeShrinkButton = Renderer.NodeShrinkButton = Utils.inherit(Renderer._NodeButton);\n var NodeShrinkButton = Utils.inherit(NodeButton);\n\n _(NodeShrinkButton.prototype).extend({\n _init: function() {\n this.type = \"Node-shrink-button\";\n this.lastSectorInner = 0;\n this.startAngle = -180;\n this.endAngle = -135;\n this.imageName = \"shrink\";\n this.text = \"Shrink\";\n },\n mouseup: function() {\n var _newsize = -1 + (this.source_representation.model.get(\"size\") || 0);\n this.source_representation.model.set(\"size\", _newsize);\n this.source_representation.select();\n this.select();\n paper.view.draw();\n }\n });\n\n /* NodeShrinkButton End */\n\n return NodeShrinkButton;\n\n});\n\n\ndefine('renderer/edgeeditbutton',['jquery', 'underscore', 'requtils', 'renderer/basebutton'], function ($, _, requtils, BaseButton) {\n \n\n var Utils = requtils.getUtils();\n\n /* EdgeEditButton Begin */\n\n //var EdgeEditButton = Renderer.EdgeEditButton = Utils.inherit(Renderer._BaseButton);\n var EdgeEditButton = Utils.inherit(BaseButton);\n\n _(EdgeEditButton.prototype).extend({\n _init: function() {\n this.type = \"Edge-edit-button\";\n this.sector = this.renderer.drawSector(this, Utils._EDGE_BUTTON_INNER, Utils._EDGE_BUTTON_OUTER, -270, -90, 1, \"edit\", this.renkan.translate(\"Edit\"));\n },\n mouseup: function() {\n if (!this.renderer.is_dragging) {\n this.source_representation.openEditor();\n }\n }\n });\n\n /* EdgeEditButton End */\n\n return EdgeEditButton;\n\n});\n\n\ndefine('renderer/edgeremovebutton',['jquery', 'underscore', 'requtils', 'renderer/basebutton'], function ($, _, requtils, BaseButton) {\n \n\n var Utils = requtils.getUtils();\n\n /* EdgeRemoveButton Begin */\n\n //var EdgeRemoveButton = Renderer.EdgeRemoveButton = Utils.inherit(Renderer._BaseButton);\n var EdgeRemoveButton = Utils.inherit(BaseButton);\n\n _(EdgeRemoveButton.prototype).extend({\n _init: function() {\n this.type = \"Edge-remove-button\";\n this.sector = this.renderer.drawSector(this, Utils._EDGE_BUTTON_INNER, Utils._EDGE_BUTTON_OUTER, -90, 90, 1, \"remove\", this.renkan.translate(\"Remove\"));\n },\n mouseup: function() {\n this.renderer.click_target = null;\n this.renderer.is_dragging = false;\n this.renderer.removeRepresentationsOfType(\"editor\");\n if (this.renderer.isEditable()) {\n if (this.options.element_delete_delay) {\n var delid = Utils.getUID(\"delete\");\n this.renderer.delete_list.push({\n id: delid,\n time: new Date().valueOf() + this.options.element_delete_delay\n });\n this.source_representation.model.set(\"delete_scheduled\", delid);\n } else {\n if (confirm(this.renkan.translate('Do you really wish to remove edge ') + '\"' + this.source_representation.model.get(\"title\") + '\"?')) {\n this.project.removeEdge(this.source_representation.model);\n }\n }\n }\n }\n });\n\n /* EdgeRemoveButton End */\n\n return EdgeRemoveButton;\n\n});\n\n\ndefine('renderer/edgerevertbutton',['jquery', 'underscore', 'requtils', 'renderer/basebutton'], function ($, _, requtils, BaseButton) {\n \n\n var Utils = requtils.getUtils();\n\n /* EdgeRevertButton Begin */\n\n //var EdgeRevertButton = Renderer.EdgeRevertButton = Utils.inherit(Renderer._BaseButton);\n var EdgeRevertButton = Utils.inherit(BaseButton);\n\n _(EdgeRevertButton.prototype).extend({\n _init: function() {\n this.type = \"Edge-revert-button\";\n this.sector = this.renderer.drawSector(this, Utils._EDGE_BUTTON_INNER, Utils._EDGE_BUTTON_OUTER, -135, 135, 1, \"revert\", this.renkan.translate(\"Cancel deletion\"));\n },\n mouseup: function() {\n this.renderer.click_target = null;\n this.renderer.is_dragging = false;\n if (this.renderer.isEditable()) {\n this.source_representation.model.unset(\"delete_scheduled\");\n }\n }\n });\n\n /* EdgeRevertButton End */\n\n return EdgeRevertButton;\n\n});\n\n\ndefine('renderer/miniframe',['jquery', 'underscore', 'requtils', 'renderer/baserepresentation'], function ($, _, requtils, BaseRepresentation) {\n \n\n var Utils = requtils.getUtils();\n\n /* MiniFrame Begin */\n\n //var MiniFrame = Renderer.MiniFrame = Utils.inherit(Renderer._BaseRepresentation);\n var MiniFrame = Utils.inherit(BaseRepresentation);\n\n _(MiniFrame.prototype).extend({\n paperShift: function(_delta) {\n this.renderer.offset = this.renderer.offset.subtract(_delta.divide(this.renderer.minimap.scale).multiply(this.renderer.scale));\n this.renderer.redraw();\n },\n mouseup: function(_delta) {\n this.renderer.click_target = null;\n this.renderer.is_dragging = false;\n }\n });\n\n /* MiniFrame End */\n\n return MiniFrame;\n\n});\n\n\ndefine('renderer/scene',['jquery', 'underscore', 'filesaver', 'requtils', 'renderer/miniframe'], function ($, _, filesaver, requtils, MiniFrame) {\n \n\n var Utils = requtils.getUtils();\n\n /* Scene Begin */\n\n var Scene = function(_renkan) {\n this.renkan = _renkan;\n this.$ = $(\".Rk-Render\");\n this.representations = [];\n this.$.html(this.template(_renkan));\n this.onStatusChange();\n this.canvas_$ = this.$.find(\".Rk-Canvas\");\n this.labels_$ = this.$.find(\".Rk-Labels\");\n this.editor_$ = this.$.find(\".Rk-Editor\");\n this.notif_$ = this.$.find(\".Rk-Notifications\");\n paper.setup(this.canvas_$[0]);\n this.scale = 1;\n this.initialScale = 1;\n this.offset = paper.view.center;\n this.totalScroll = 0;\n this.mouse_down = false;\n this.click_target = null;\n this.selected_target = null;\n this.edge_layer = new paper.Layer();\n this.node_layer = new paper.Layer();\n this.buttons_layer = new paper.Layer();\n this.delete_list = [];\n this.redrawActive = true;\n\n if (_renkan.options.show_minimap) {\n this.minimap = {\n background_layer: new paper.Layer(),\n edge_layer: new paper.Layer(),\n node_layer: new paper.Layer(),\n node_group: new paper.Group(),\n size: new paper.Size( _renkan.options.minimap_width, _renkan.options.minimap_height )\n };\n\n this.minimap.background_layer.activate();\n this.minimap.topleft = paper.view.bounds.bottomRight.subtract(this.minimap.size);\n this.minimap.rectangle = new paper.Path.Rectangle(this.minimap.topleft.subtract([2,2]), this.minimap.size.add([4,4]));\n this.minimap.rectangle.fillColor = _renkan.options.minimap_background_color;\n this.minimap.rectangle.strokeColor = _renkan.options.minimap_border_color;\n this.minimap.rectangle.strokeWidth = 4;\n this.minimap.offset = new paper.Point(this.minimap.size.divide(2));\n this.minimap.scale = 0.1;\n\n this.minimap.node_layer.activate();\n this.minimap.cliprectangle = new paper.Path.Rectangle(this.minimap.topleft, this.minimap.size);\n this.minimap.node_group.addChild(this.minimap.cliprectangle);\n this.minimap.node_group.clipped = true;\n this.minimap.miniframe = new paper.Path.Rectangle(this.minimap.topleft, this.minimap.size);\n this.minimap.node_group.addChild(this.minimap.miniframe);\n this.minimap.miniframe.fillColor = '#c0c0ff';\n this.minimap.miniframe.opacity = 0.3;\n this.minimap.miniframe.strokeColor = '#000080';\n this.minimap.miniframe.strokeWidth = 3;\n this.minimap.miniframe.__representation = new MiniFrame(this, null);\n }\n\n this.throttledPaperDraw = _(function() {\n paper.view.draw();\n }).throttle(100);\n\n this.bundles = [];\n this.click_mode = false;\n\n var _this = this,\n _allowScroll = true,\n _originalScale = 1,\n _zooming = false,\n _lastTapX = 0,\n _lastTapY = 0;\n\n this.image_cache = {};\n this.icon_cache = {};\n\n ['edit', 'remove', 'link', 'enlarge', 'shrink', 'revert' ].forEach(function(imgname) {\n var img = new Image();\n img.src = _renkan.options.static_url + 'img/' + imgname + '.png';\n _this.icon_cache[imgname] = img;\n });\n\n var throttledMouseMove = _.throttle(function(_event, _isTouch) {\n _this.onMouseMove(_event, _isTouch);\n }, Utils._MOUSEMOVE_RATE);\n\n this.canvas_$.on({\n mousedown: function(_event) {\n _event.preventDefault();\n _this.onMouseDown(_event, false);\n },\n mousemove: function(_event) {\n _event.preventDefault();\n throttledMouseMove(_event, false);\n },\n mouseup: function(_event) {\n _event.preventDefault();\n _this.onMouseUp(_event, false);\n },\n mousewheel: function(_event, _delta) {\n if(_renkan.options.zoom_on_scroll) {\n _event.preventDefault();\n if (_allowScroll) {\n _this.onScroll(_event, _delta);\n }\n }\n },\n touchstart: function(_event) {\n _event.preventDefault();\n var _touches = _event.originalEvent.touches[0];\n if (\n _renkan.options.allow_double_click &&\n new Date() - _lastTap < Utils._DOUBLETAP_DELAY &&\n ( Math.pow(_lastTapX - _touches.pageX, 2) + Math.pow(_lastTapY - _touches.pageY, 2) < Utils._DOUBLETAP_DISTANCE )\n ) {\n _lastTap = 0;\n _this.onDoubleClick(_touches);\n } else {\n _lastTap = new Date();\n _lastTapX = _touches.pageX;\n _lastTapY = _touches.pageY;\n _originalScale = _this.scale;\n _zooming = false;\n _this.onMouseDown(_touches, true);\n }\n },\n touchmove: function(_event) {\n _event.preventDefault();\n _lastTap = 0;\n if (_event.originalEvent.touches.length === 1) {\n _this.onMouseMove(_event.originalEvent.touches[0], true);\n } else {\n if (!_zooming) {\n _this.onMouseUp(_event.originalEvent.touches[0], true);\n _this.click_target = null;\n _this.is_dragging = false;\n _zooming = true;\n }\n if (_event.originalEvent.scale === \"undefined\") {\n return;\n }\n var _newScale = _event.originalEvent.scale * _originalScale,\n _scaleRatio = _newScale / _this.scale,\n _newOffset = new paper.Point([\n _this.canvas_$.width(),\n _this.canvas_$.height()\n ]).multiply( 0.5 * ( 1 - _scaleRatio ) ).add(_this.offset.multiply( _scaleRatio ));\n _this.setScale(_newScale, _newOffset);\n }\n },\n touchend: function(_event) {\n _event.preventDefault();\n _this.onMouseUp(_event.originalEvent.changedTouches[0], true);\n },\n dblclick: function(_event) {\n _event.preventDefault();\n if (_renkan.options.allow_double_click) {\n _this.onDoubleClick(_event);\n }\n },\n mouseleave: function(_event) {\n _event.preventDefault();\n _this.onMouseUp(_event, false);\n _this.click_target = null;\n _this.is_dragging = false;\n },\n dragover: function(_event) {\n _event.preventDefault();\n },\n dragenter: function(_event) {\n _event.preventDefault();\n _allowScroll = false;\n },\n dragleave: function(_event) {\n _event.preventDefault();\n _allowScroll = true;\n },\n drop: function(_event) {\n _event.preventDefault();\n _allowScroll = true;\n var res = {};\n _(_event.originalEvent.dataTransfer.types).each(function(t) {\n try {\n res[t] = _event.originalEvent.dataTransfer.getData(t);\n } catch(e) {}\n });\n var text = _event.originalEvent.dataTransfer.getData(\"Text\");\n if (typeof text === \"string\") {\n switch(text[0]) {\n case \"{\":\n case \"[\":\n try {\n var data = JSON.parse(text);\n _(res).extend(data);\n }\n catch(e) {\n if (!res[\"text/plain\"]) {\n res[\"text/plain\"] = text;\n }\n }\n break;\n case \"<\":\n if (!res[\"text/html\"]) {\n res[\"text/html\"] = text;\n }\n break;\n default:\n if (!res[\"text/plain\"]) {\n res[\"text/plain\"] = text;\n }\n }\n }\n var url = _event.originalEvent.dataTransfer.getData(\"URL\");\n if (url && !res[\"text/uri-list\"]) {\n res[\"text/uri-list\"] = url;\n }\n _this.dropData(res, _event.originalEvent);\n }\n });\n\n var bindClick = function(selector, fname) {\n _this.$.find(selector).click(function(evt) {\n _this[fname](evt);\n return false;\n });\n };\n\n bindClick(\".Rk-ZoomOut\", \"zoomOut\");\n bindClick(\".Rk-ZoomIn\", \"zoomIn\");\n bindClick(\".Rk-ZoomFit\", \"autoScale\");\n this.$.find(\".Rk-ZoomSave\").click( function() {\n // Save scale and offset point\n _this.renkan.project.addView( { zoom_level:_this.scale, offset:_this.offset } );\n });\n this.$.find(\".Rk-ZoomSetSaved\").click( function() {\n var view = _this.renkan.project.get(\"views\").last();\n if(view){\n _this.setScale(view.get(\"zoom_level\"), new paper.Point(view.get(\"offset\")));\n }\n });\n if(this.renkan.read_only && !isNaN(parseInt(this.renkan.options.default_view))){\n this.$.find(\".Rk-ZoomSetSaved\").show();\n }\n this.$.find(\".Rk-CurrentUser\").mouseenter(\n function() { _this.$.find(\".Rk-UserList\").slideDown(); }\n );\n this.$.find(\".Rk-Users\").mouseleave(\n function() { _this.$.find(\".Rk-UserList\").slideUp(); }\n );\n bindClick(\".Rk-FullScreen-Button\", \"fullScreen\");\n bindClick(\".Rk-AddNode-Button\", \"addNodeBtn\");\n bindClick(\".Rk-AddEdge-Button\", \"addEdgeBtn\");\n bindClick(\".Rk-Save-Button\", \"save\");\n bindClick(\".Rk-Open-Button\", \"open\");\n bindClick(\".Rk-Export-Button\", \"exportProject\");\n this.$.find(\".Rk-Bookmarklet-Button\")\n /*jshint scripturl:true */\n .attr(\"href\",\"javascript:\" + Utils._BOOKMARKLET_CODE(_renkan))\n .click(function(){\n _this.notif_$\n .text(_renkan.translate(\"Drag this button to your bookmark bar. When on a third-party website, click it to enable drag-and-drop from the website to Renkan.\"))\n .fadeIn()\n .delay(5000)\n .fadeOut();\n return false;\n });\n this.$.find(\".Rk-TopBar-Button\").mouseover(function() {\n $(this).find(\".Rk-TopBar-Tooltip\").show();\n }).mouseout(function() {\n $(this).find(\".Rk-TopBar-Tooltip\").hide();\n });\n bindClick(\".Rk-Fold-Bins\", \"foldBins\");\n\n paper.view.onResize = function(_event) {\n // Because of paper bug which does not calculate the good height (and width a fortiori)\n // We have to update manually the canvas's height\n paper.view._viewSize.height = _event.size.height = _this.canvas_$.parent().height();\n\n if (_this.minimap) {\n _this.minimap.topleft = paper.view.bounds.bottomRight.subtract(_this.minimap.size);\n _this.minimap.rectangle.fitBounds(_this.minimap.topleft.subtract([2,2]), _this.minimap.size.add([4,4]));\n _this.minimap.cliprectangle.fitBounds(_this.minimap.topleft, _this.minimap.size);\n }\n _this.redraw();\n };\n\n var _thRedraw = _.throttle(function() {\n _this.redraw();\n },50);\n\n this.addRepresentations(\"Node\", this.renkan.project.get(\"nodes\"));\n this.addRepresentations(\"Edge\", this.renkan.project.get(\"edges\"));\n this.renkan.project.on(\"change:title\", function() {\n _this.$.find(\".Rk-PadTitle\").val(_renkan.project.get(\"title\"));\n });\n\n this.$.find(\".Rk-PadTitle\").on(\"keyup input paste\", function() {\n _renkan.project.set({\"title\": $(this).val()});\n });\n\n var _thRedrawUsers = _.throttle(function() {\n _this.redrawUsers();\n }, 100);\n\n _thRedrawUsers();\n\n // register model events\n this.renkan.project.on(\"add:users remove:users\", _thRedrawUsers);\n\n this.renkan.project.on(\"add:views remove:views\", function(_node) {\n if(_this.renkan.project.get('views').length > 0) {\n _this.$.find(\".Rk-ZoomSetSaved\").show();\n }\n else {\n _this.$.find(\".Rk-ZoomSetSaved\").hide();\n }\n });\n\n this.renkan.project.on(\"add:nodes\", function(_node) {\n _this.addRepresentation(\"Node\", _node);\n _thRedraw();\n });\n this.renkan.project.on(\"add:edges\", function(_edge) {\n _this.addRepresentation(\"Edge\", _edge);\n _thRedraw();\n });\n this.renkan.project.on(\"change:title\", function(_model, _title) {\n var el = _this.$.find(\".Rk-PadTitle\");\n if (el.is(\"input\")) {\n if (el.val() !== _title) {\n el.val(_title);\n }\n } else {\n el.text(_title);\n }\n });\n\n if (_renkan.options.size_bug_fix) {\n var _delay = (\n typeof _renkan.options.size_bug_fix === \"number\" ?\n _renkan.options.size_bug_fix\n : 500\n );\n window.setTimeout(\n function() {\n _this.fixSize(true);\n },\n _delay\n );\n }\n\n if (_renkan.options.force_resize) {\n $(window).resize(function() {\n _this.fixSize(false);\n });\n }\n\n if (_renkan.options.show_user_list && _renkan.options.user_color_editable) {\n var $cpwrapper = this.$.find(\".Rk-Users .Rk-Edit-ColorPicker-Wrapper\"),\n $cplist = this.$.find(\".Rk-Users .Rk-Edit-ColorPicker\");\n\n $cpwrapper.hover(\n function(_e) {\n if (_this.isEditable()) {\n _e.preventDefault();\n $cplist.show();\n }\n },\n function(_e) {\n _e.preventDefault();\n $cplist.hide();\n }\n );\n\n $cplist.find(\"li\").mouseenter(\n function(_e) {\n if (_this.isEditable()) {\n _e.preventDefault();\n _this.$.find(\".Rk-CurrentUser-Color\").css(\"background\", $(this).attr(\"data-color\"));\n }\n }\n );\n }\n\n if (_renkan.options.show_search_field) {\n\n var lastval = '';\n\n this.$.find(\".Rk-GraphSearch-Field\").on(\"keyup change paste input\", function() {\n var $this = $(this),\n val = $this.val();\n if (val === lastval) {\n return;\n }\n lastval = val;\n if (val.length < 2) {\n _renkan.project.get(\"nodes\").each(function(n) {\n _this.getRepresentationByModel(n).unhighlight();\n });\n } else {\n var rxs = Utils.regexpFromTextOrArray(val);\n _renkan.project.get(\"nodes\").each(function(n) {\n if (rxs.test(n.get(\"title\")) || rxs.test(n.get(\"description\"))) {\n _this.getRepresentationByModel(n).highlight(rxs);\n } else {\n _this.getRepresentationByModel(n).unhighlight();\n }\n });\n }\n });\n }\n\n this.redraw();\n\n window.setInterval(function() {\n var _now = new Date().valueOf();\n _this.delete_list.forEach(function(d) {\n if (_now >= d.time) {\n var el = _renkan.project.get(\"nodes\").findWhere({\"delete_scheduled\":d.id});\n if (el) {\n project.removeNode(el);\n }\n el = _renkan.project.get(\"edges\").findWhere({\"delete_scheduled\":d.id});\n if (el) {\n project.removeEdge(el);\n }\n }\n });\n _this.delete_list = _this.delete_list.filter(function(d) {\n return _renkan.project.get(\"nodes\").findWhere({\"delete_scheduled\":d.id}) || _renkan.project.get(\"edges\").findWhere({\"delete_scheduled\":d.id});\n });\n }, 500);\n\n if (this.minimap) {\n window.setInterval(function() {\n _this.rescaleMinimap();\n }, 2000);\n }\n\n };\n\n _(Scene.prototype).extend({\n template: _.template(\n '<% if (options.show_top_bar) { %><div class=\"Rk-TopBar\"><% if (!options.editor_mode) { %><h2 class=\"Rk-PadTitle\"><%- project.get(\"title\") || translate(\"Untitled project\")%></h2>' +\n '<% } else { %><input type=\"text\" class=\"Rk-PadTitle\" value=\"<%- project.get(\"title\") || \"\" %>\" placeholder=\"<%-translate(\"Untitled project\")%>\" /><% } %>' +\n '<% if (options.show_user_list) { %><div class=\"Rk-Users\"><div class=\"Rk-CurrentUser\"><div class=\"Rk-Edit-ColorPicker-Wrapper\"><span class=\"Rk-CurrentUser-Color\"><% if (options.user_color_editable) { %><span class=\"Rk-Edit-ColorTip\"></span><% } %></span>' +\n '<% if (options.user_color_editable) { print(colorPicker) } %></div><span class=\"Rk-CurrentUser-Name\"><unknown user></span></div><ul class=\"Rk-UserList\"></ul></div><% } %>' +\n '<% if (options.home_button_url) {%><div class=\"Rk-TopBar-Separator\"></div><a class=\"Rk-TopBar-Button Rk-Home-Button\" href=\"<%- options.home_button_url %>\"><div class=\"Rk-TopBar-Tooltip\"><div class=\"Rk-TopBar-Tooltip-Contents\">' +\n '<%- translate(options.home_button_title) %></div></div></a><% } %>' +\n '<% if (options.show_fullscreen_button) { %><div class=\"Rk-TopBar-Separator\"></div><div class=\"Rk-TopBar-Button Rk-FullScreen-Button\"><div class=\"Rk-TopBar-Tooltip\"><div class=\"Rk-TopBar-Tooltip-Contents\"><%-translate(\"Full Screen\")%></div></div></div><% } %>' +\n '<% if (options.editor_mode) { %>' +\n '<% if (options.show_addnode_button) { %><div class=\"Rk-TopBar-Separator\"></div><div class=\"Rk-TopBar-Button Rk-AddNode-Button\"><div class=\"Rk-TopBar-Tooltip\">' +\n '<div class=\"Rk-TopBar-Tooltip-Contents\"><%-translate(\"Add Node\")%></div></div></div><% } %>' +\n '<% if (options.show_addedge_button) { %><div class=\"Rk-TopBar-Separator\"></div><div class=\"Rk-TopBar-Button Rk-AddEdge-Button\"><div class=\"Rk-TopBar-Tooltip\">' +\n '<div class=\"Rk-TopBar-Tooltip-Contents\"><%-translate(\"Add Edge\")%></div></div></div><% } %>' +\n '<% if (options.show_export_button) { %><div class=\"Rk-TopBar-Separator\"></div><div class=\"Rk-TopBar-Button Rk-Export-Button\"><div class=\"Rk-TopBar-Tooltip\"><div class=\"Rk-TopBar-Tooltip-Contents\"><%-translate(\"Download Project\")%></div></div></div><% } %>' +\n '<% if (options.show_save_button) { %><div class=\"Rk-TopBar-Separator\"></div><div class=\"Rk-TopBar-Button Rk-Save-Button\"><div class=\"Rk-TopBar-Tooltip\"><div class=\"Rk-TopBar-Tooltip-Contents\"> </div></div></div><% } %>' +\n '<% if (options.show_open_button) { %><div class=\"Rk-TopBar-Separator\"></div><div class=\"Rk-TopBar-Button Rk-Open-Button\"><div class=\"Rk-TopBar-Tooltip\"><div class=\"Rk-TopBar-Tooltip-Contents\"><%-translate(\"Open Project\")%></div></div></div><% } %>' +\n '<% if (options.show_bookmarklet) { %><div class=\"Rk-TopBar-Separator\"></div><a class=\"Rk-TopBar-Button Rk-Bookmarklet-Button\" href=\"#\"><div class=\"Rk-TopBar-Tooltip\"><div class=\"Rk-TopBar-Tooltip-Contents\">' +\n '<%-translate(\"Renkan \\'Drag-to-Add\\' bookmarklet\")%></div></div></a><% } %>' +\n '<% } else { %>' +\n '<% if (options.show_export_button) { %><div class=\"Rk-TopBar-Separator\"></div><div class=\"Rk-TopBar-Button Rk-Export-Button\"><div class=\"Rk-TopBar-Tooltip\"><div class=\"Rk-TopBar-Tooltip-Contents\"><%-translate(\"Download Project\")%></div></div></div><div class=\"Rk-TopBar-Separator\"></div><% } %>' +\n '<% };' +\n 'if (options.show_search_field) { %>' +\n '<form action=\"#\" class=\"Rk-GraphSearch-Form\"><input type=\"search\" class=\"Rk-GraphSearch-Field\" placeholder=\"<%- translate(\"Search in graph\") %>\" /></form><div class=\"Rk-TopBar-Separator\"></div><% } %></div><% } %>' +\n '<div class=\"Rk-Editing-Space<% if (!options.show_top_bar) { %> Rk-Editing-Space-Full<% } %>\">' +\n '<div class=\"Rk-Labels\"></div><canvas class=\"Rk-Canvas\" resize></canvas><div class=\"Rk-Notifications\"></div><div class=\"Rk-Editor\">' +\n '<% if (options.show_bins) { %><div class=\"Rk-Fold-Bins\">«</div><% } %>' +\n '<div class=\"Rk-ZoomButtons\"><div class=\"Rk-ZoomIn\" title=\"<%-translate(\"Zoom In\")%>\"></div><div class=\"Rk-ZoomFit\" title=\"<%-translate(\"Zoom Fit\")%>\"></div><div class=\"Rk-ZoomOut\" title=\"<%-translate(\"Zoom Out\")%>\"></div>' +\n '<% if (options.editor_mode) { %><div class=\"Rk-ZoomSave\" title=\"<%-translate(\"Zoom Save\")%>\"></div><% } %>' +\n '<% if (options.editor_mode || !isNaN(parseInt(options.default_view))) { %><div class=\"Rk-ZoomSetSaved\" title=\"<%-translate(\"View saved zoom\")%>\"></div><% } %></div>' +\n '</div></div>'\n ),\n fixSize: function(_autoscale) {\n var w = this.$.width(),\n h = this.$.height();\n if (this.renkan.options.show_top_bar) {\n h -= this.$.find(\".Rk-TopBar\").height();\n }\n this.canvas_$.attr({\n width: w,\n height: h\n });\n\n paper.view.viewSize = new paper.Size([w, h]);\n\n if (_autoscale) {\n // If _autoscale, we get the initial view (zoom+offset) set in the project datas.\n if(this.renkan.read_only && !isNaN(parseInt(this.renkan.options.default_view))){\n this.autoScale(this.renkan.project.get(\"views\")[parseInt(this.renkan.options.default_view)]);\n }\n else{\n this.autoScale();\n }\n }\n },\n drawSector: function(_repr, _inR, _outR, _startAngle, _endAngle, _padding, _imgname, _caption) {\n var _options = this.renkan.options,\n _startRads = _startAngle * Math.PI / 180,\n _endRads = _endAngle * Math.PI / 180,\n _img = this.icon_cache[_imgname],\n _startdx = - Math.sin(_startRads),\n _startdy = Math.cos(_startRads),\n _startXIn = Math.cos(_startRads) * _inR + _padding * _startdx,\n _startYIn = Math.sin(_startRads) * _inR + _padding * _startdy,\n _startXOut = Math.cos(_startRads) * _outR + _padding * _startdx,\n _startYOut = Math.sin(_startRads) * _outR + _padding * _startdy,\n _enddx = - Math.sin(_endRads),\n _enddy = Math.cos(_endRads),\n _endXIn = Math.cos(_endRads) * _inR - _padding * _enddx,\n _endYIn = Math.sin(_endRads) * _inR - _padding * _enddy,\n _endXOut = Math.cos(_endRads) * _outR - _padding * _enddx,\n _endYOut = Math.sin(_endRads) * _outR - _padding * _enddy,\n _centerR = (_inR + _outR) / 2,\n _centerRads = (_startRads + _endRads) / 2,\n _centerX = Math.cos(_centerRads) * _centerR,\n _centerY = Math.sin(_centerRads) * _centerR,\n _centerXIn = Math.cos(_centerRads) * _inR,\n _centerXOut = Math.cos(_centerRads) * _outR,\n _centerYIn = Math.sin(_centerRads) * _inR,\n _centerYOut = Math.sin(_centerRads) * _outR,\n _textX = Math.cos(_centerRads) * (_outR + 3),\n _textY = Math.sin(_centerRads) * (_outR + _options.buttons_label_font_size) + _options.buttons_label_font_size / 2;\n this.buttons_layer.activate();\n var _path = new paper.Path();\n _path.add([_startXIn, _startYIn]);\n _path.arcTo([_centerXIn, _centerYIn], [_endXIn, _endYIn]);\n _path.lineTo([_endXOut, _endYOut]);\n _path.arcTo([_centerXOut, _centerYOut], [_startXOut, _startYOut]);\n _path.fillColor = _options.buttons_background;\n _path.opacity = 0.5;\n _path.closed = true;\n _path.__representation = _repr;\n var _text = new paper.PointText(_textX,_textY);\n _text.characterStyle = {\n fontSize: _options.buttons_label_font_size,\n fillColor: _options.buttons_label_color\n };\n if (_textX > 2) {\n _text.paragraphStyle.justification = 'left';\n } else if (_textX < -2) {\n _text.paragraphStyle.justification = 'right';\n } else {\n _text.paragraphStyle.justification = 'center';\n }\n _text.visible = false;\n var _visible = false,\n _restPos = new paper.Point(-200, -200),\n _grp = new paper.Group([_path, _text]),\n _delta = _grp.position,\n _imgdelta = new paper.Point([_centerX, _centerY]),\n _currentPos = new paper.Point(0,0);\n _text.content = _caption;\n _grp.visible = false;\n _grp.position = _restPos;\n var _res = {\n show: function() {\n _visible = true;\n _grp.position = _currentPos.add(_delta);\n _grp.visible = true;\n },\n moveTo: function(_point) {\n _currentPos = _point;\n if (_visible) {\n _grp.position = _point.add(_delta);\n }\n },\n hide: function() {\n _visible = false;\n _grp.visible = false;\n _grp.position = _restPos;\n },\n select: function() {\n _path.opacity = 0.8;\n _text.visible = true;\n },\n unselect: function() {\n _path.opacity = 0.5;\n _text.visible = false;\n },\n destroy: function() {\n _grp.remove();\n }\n };\n var showImage = function() {\n var _raster = new paper.Raster(_img);\n _raster.position = _imgdelta.add(_grp.position).subtract(_delta);\n _raster.locked = true; // Disable mouse events on icon\n _grp.addChild(_raster);\n };\n if (_img.width) {\n showImage();\n } else {\n $(_img).on(\"load\",showImage);\n }\n\n return _res;\n },\n addToBundles: function(_edgeRepr) {\n var _bundle = _(this.bundles).find(function(_bundle) {\n return (\n ( _bundle.from === _edgeRepr.from_representation && _bundle.to === _edgeRepr.to_representation ) ||\n ( _bundle.from === _edgeRepr.to_representation && _bundle.to === _edgeRepr.from_representation )\n );\n });\n if (typeof _bundle !== \"undefined\") {\n _bundle.edges.push(_edgeRepr);\n } else {\n _bundle = {\n from: _edgeRepr.from_representation,\n to: _edgeRepr.to_representation,\n edges: [ _edgeRepr ],\n getPosition: function(_er) {\n var _dir = (_er.from_representation === this.from) ? 1 : -1;\n return _dir * ( _(this.edges).indexOf(_er) - (this.edges.length - 1) / 2 );\n }\n };\n this.bundles.push(_bundle);\n }\n return _bundle;\n },\n isEditable: function() {\n return (this.renkan.options.editor_mode && !this.renkan.read_only);\n },\n onStatusChange: function() {\n var savebtn = this.$.find(\".Rk-Save-Button\"),\n tip = savebtn.find(\".Rk-TopBar-Tooltip-Contents\");\n if (this.renkan.read_only) {\n savebtn.removeClass(\"disabled Rk-Save-Online\").addClass(\"Rk-Save-ReadOnly\");\n tip.text(this.renkan.translate(\"Connection lost\"));\n } else {\n if (this.renkan.options.manual_save) {\n savebtn.removeClass(\"Rk-Save-ReadOnly Rk-Save-Online\");\n tip.text(this.renkan.translate(\"Save Project\"));\n } else {\n savebtn.removeClass(\"disabled Rk-Save-ReadOnly\").addClass(\"Rk-Save-Online\");\n tip.text(this.renkan.translate(\"Auto-save enabled\"));\n }\n }\n this.redrawUsers();\n },\n setScale: function(_newScale, _offset) {\n if ((_newScale/this.initialScale) > Utils._MIN_SCALE && (_newScale/this.initialScale) < Utils._MAX_SCALE) {\n this.scale = _newScale;\n if (_offset) {\n this.offset = _offset;\n }\n this.redraw();\n }\n },\n autoScale: function(force_view) {\n var nodes = this.renkan.project.get(\"nodes\");\n if (nodes.length > 1) {\n var _xx = nodes.map(function(_node) { return _node.get(\"position\").x; }),\n _yy = nodes.map(function(_node) { return _node.get(\"position\").y; }),\n _minx = Math.min.apply(Math, _xx),\n _miny = Math.min.apply(Math, _yy),\n _maxx = Math.max.apply(Math, _xx),\n _maxy = Math.max.apply(Math, _yy);\n var _scale = Math.min( (paper.view.size.width - 2 * this.renkan.options.autoscale_padding) / (_maxx - _minx), (paper.view.size.height - 2 * this.renkan.options.autoscale_padding) / (_maxy - _miny));\n this.initialScale = _scale;\n // Override calculated scale if asked\n if((typeof force_view !== \"undefined\") && parseFloat(force_view.zoom_level)>0 && parseFloat(force_view.offset.x)>0 && parseFloat(force_view.offset.y)>0){\n this.setScale(parseFloat(force_view.zoom_level), new paper.Point(parseFloat(force_view.offset.x), parseFloat(force_view.offset.y)));\n }\n else{\n this.setScale(_scale, paper.view.center.subtract(new paper.Point([(_maxx + _minx) / 2, (_maxy + _miny) / 2]).multiply(_scale)));\n }\n }\n if (nodes.length === 1) {\n this.setScale(1, paper.view.center.subtract(new paper.Point([nodes.at(0).get(\"position\").x, nodes.at(0).get(\"position\").y])));\n }\n },\n redrawMiniframe: function() {\n var topleft = this.toMinimapCoords(this.toModelCoords(new paper.Point([0,0]))),\n bottomright = this.toMinimapCoords(this.toModelCoords(paper.view.bounds.bottomRight));\n this.minimap.miniframe.fitBounds(topleft, bottomright);\n },\n rescaleMinimap: function() {\n var nodes = this.renkan.project.get(\"nodes\");\n if (nodes.length > 1) {\n var _xx = nodes.map(function(_node) { return _node.get(\"position\").x; }),\n _yy = nodes.map(function(_node) { return _node.get(\"position\").y; }),\n _minx = Math.min.apply(Math, _xx),\n _miny = Math.min.apply(Math, _yy),\n _maxx = Math.max.apply(Math, _xx),\n _maxy = Math.max.apply(Math, _yy);\n var _scale = Math.min(\n this.scale * 0.8 * this.renkan.options.minimap_width / paper.view.bounds.width,\n this.scale * 0.8 * this.renkan.options.minimap_height / paper.view.bounds.height,\n ( this.renkan.options.minimap_width - 2 * this.renkan.options.minimap_padding ) / (_maxx - _minx),\n ( this.renkan.options.minimap_height - 2 * this.renkan.options.minimap_padding ) / (_maxy - _miny)\n );\n this.minimap.offset = this.minimap.size.divide(2).subtract(new paper.Point([(_maxx + _minx) / 2, (_maxy + _miny) / 2]).multiply(_scale));\n this.minimap.scale = _scale;\n }\n if (nodes.length === 1) {\n this.minimap.scale = 0.1;\n this.minimap.offset = this.minimap.size.divide(2).subtract(new paper.Point([nodes.at(0).get(\"position\").x, nodes.at(0).get(\"position\").y]).multiply(this.minimap.scale));\n }\n this.redraw();\n },\n toPaperCoords: function(_point) {\n return _point.multiply(this.scale).add(this.offset);\n },\n toMinimapCoords: function(_point) {\n return _point.multiply(this.minimap.scale).add(this.minimap.offset).add(this.minimap.topleft);\n },\n toModelCoords: function(_point) {\n return _point.subtract(this.offset).divide(this.scale);\n },\n addRepresentation: function(_type, _model) {\n var RendererType = requtils.getRenderer()[_type];\n var _repr = new RendererType(this, _model);\n this.representations.push(_repr);\n return _repr;\n },\n addRepresentations: function(_type, _collection) {\n var _this = this;\n _collection.forEach(function(_model) {\n _this.addRepresentation(_type, _model);\n });\n },\n userTemplate: _.template(\n '<li class=\"Rk-User\"><span class=\"Rk-UserColor\" style=\"background:<%=background%>;\"></span><%=name%></li>'\n ),\n redrawUsers: function() {\n if (!this.renkan.options.show_user_list) {\n return;\n }\n var allUsers = [].concat((this.renkan.project.current_user_list || {}).models || [], (this.renkan.project.get(\"users\") || {}).models || []),\n ulistHtml = '',\n $userpanel = this.$.find(\".Rk-Users\"),\n $name = $userpanel.find(\".Rk-CurrentUser-Name\"),\n $cpitems = $userpanel.find(\".Rk-Edit-ColorPicker li\"),\n $colorsquare = $userpanel.find(\".Rk-CurrentUser-Color\"),\n _this = this;\n $name.off(\"click\").text(this.renkan.translate(\"<unknown user>\"));\n $cpitems.off(\"mouseleave click\");\n allUsers.forEach(function(_user) {\n if (_user.get(\"_id\") === _this.renkan.current_user) {\n $name.text(_user.get(\"title\"));\n $colorsquare.css(\"background\", _user.get(\"color\"));\n if (_this.isEditable()) {\n\n if (_this.renkan.options.user_name_editable) {\n $name.click(function() {\n var $this = $(this),\n $input = $('<input>').val(_user.get(\"title\")).blur(function() {\n _user.set(\"title\", $(this).val());\n _this.redrawUsers();\n _this.redraw();\n });\n $this.empty().html($input);\n $input.select();\n });\n }\n\n if (_this.renkan.options.user_color_editable) {\n $cpitems.click(\n function(_e) {\n _e.preventDefault();\n if (_this.isEditable()) {\n _user.set(\"color\", $(this).attr(\"data-color\"));\n }\n $(this).parent().hide();\n }\n ).mouseleave(function() {\n $colorsquare.css(\"background\", _user.get(\"color\"));\n });\n }\n }\n\n } else {\n ulistHtml += _this.userTemplate({\n name: _user.get(\"title\"),\n background: _user.get(\"color\")\n });\n }\n });\n $userpanel.find(\".Rk-UserList\").html(ulistHtml);\n },\n removeRepresentation: function(_representation) {\n _representation.destroy();\n this.representations = _(this.representations).reject(\n function(_repr) {\n return _repr === _representation;\n }\n );\n },\n getRepresentationByModel: function(_model) {\n if (!_model) {\n return undefined;\n }\n return _(this.representations).find(function(_repr) {\n return _repr.model === _model;\n });\n },\n removeRepresentationsOfType: function(_type) {\n var _representations = _(this.representations).filter(function(_repr) {\n return _repr.type === _type;\n }),\n _this = this;\n _(_representations).each(function(_repr) {\n _this.removeRepresentation(_repr);\n });\n },\n highlightModel: function(_model) {\n var _repr = this.getRepresentationByModel(_model);\n if (_repr) {\n _repr.highlight();\n }\n },\n unhighlightAll: function(_model) {\n _(this.representations).each(function(_repr) {\n _repr.unhighlight();\n });\n },\n unselectAll: function(_model) {\n _(this.representations).each(function(_repr) {\n _repr.unselect();\n });\n },\n redraw: function() {\n if(! this.redrawActive ) {\n return;\n }\n _(this.representations).each(function(_representation) {\n _representation.redraw(true);\n });\n if (this.minimap) {\n this.redrawMiniframe();\n }\n paper.view.draw();\n },\n addTempEdge: function(_from, _point) {\n var _tmpEdge = this.addRepresentation(\"TempEdge\",null);\n _tmpEdge.end_pos = _point;\n _tmpEdge.from_representation = _from;\n _tmpEdge.redraw();\n this.click_target = _tmpEdge;\n },\n findTarget: function(_hitResult) {\n if (_hitResult && typeof _hitResult.item.__representation !== \"undefined\") {\n var _newTarget = _hitResult.item.__representation;\n if (this.selected_target !== _hitResult.item.__representation) {\n if (this.selected_target) {\n this.selected_target.unselect(_newTarget);\n }\n _newTarget.select(this.selected_target);\n this.selected_target = _newTarget;\n }\n } else {\n if (this.selected_target) {\n this.selected_target.unselect();\n }\n this.selected_target = null;\n }\n },\n paperShift: function(_delta) {\n this.offset = this.offset.add(_delta);\n this.redraw();\n },\n onMouseMove: function(_event) {\n var _off = this.canvas_$.offset(),\n _point = new paper.Point([\n _event.pageX - _off.left,\n _event.pageY - _off.top\n ]),\n _delta = _point.subtract(this.last_point);\n this.last_point = _point;\n if (!this.is_dragging && this.mouse_down && _delta.length > Utils._MIN_DRAG_DISTANCE) {\n this.is_dragging = true;\n }\n var _hitResult = paper.project.hitTest(_point);\n if (this.is_dragging) {\n if (this.click_target && typeof this.click_target.paperShift === \"function\") {\n this.click_target.paperShift(_delta);\n } else {\n this.paperShift(_delta);\n }\n } else {\n this.findTarget(_hitResult);\n }\n paper.view.draw();\n },\n onMouseDown: function(_event, _isTouch) {\n var _off = this.canvas_$.offset(),\n _point = new paper.Point([\n _event.pageX - _off.left,\n _event.pageY - _off.top\n ]);\n this.last_point = _point;\n this.mouse_down = true;\n if (!this.click_target || this.click_target.type !== \"Temp-edge\") {\n this.removeRepresentationsOfType(\"editor\");\n this.is_dragging = false;\n var _hitResult = paper.project.hitTest(_point);\n if (_hitResult && typeof _hitResult.item.__representation !== \"undefined\") {\n this.click_target = _hitResult.item.__representation;\n this.click_target.mousedown(_event, _isTouch);\n } else {\n this.click_target = null;\n if (this.isEditable() && this.click_mode === Utils._CLICKMODE_ADDNODE) {\n var _coords = this.toModelCoords(_point),\n _data = {\n id: Utils.getUID('node'),\n created_by: this.renkan.current_user,\n position: {\n x: _coords.x,\n y: _coords.y\n }\n };\n _node = this.renkan.project.addNode(_data);\n this.getRepresentationByModel(_node).openEditor();\n }\n }\n }\n if (this.click_mode) {\n if (this.isEditable() && this.click_mode === Utils._CLICKMODE_STARTEDGE && this.click_target && this.click_target.type === \"Node\") {\n this.removeRepresentationsOfType(\"editor\");\n this.addTempEdge(this.click_target, _point);\n this.click_mode = Utils._CLICKMODE_ENDEDGE;\n this.notif_$.fadeOut(function() {\n $(this).html(this.renkan.translate(\"Click on a second node to complete the edge\")).fadeIn();\n });\n } else {\n this.notif_$.hide();\n this.click_mode = false;\n }\n }\n paper.view.draw();\n },\n onMouseUp: function(_event, _isTouch) {\n this.mouse_down = false;\n if (this.click_target) {\n var _off = this.canvas_$.offset();\n this.click_target.mouseup(\n {\n point: new paper.Point([\n _event.pageX - _off.left,\n _event.pageY - _off.top\n ])\n },\n _isTouch\n );\n } else {\n this.click_target = null;\n this.is_dragging = false;\n if (_isTouch) {\n this.unselectAll();\n }\n }\n paper.view.draw();\n },\n onScroll: function(_event, _scrolldelta) {\n this.totalScroll += _scrolldelta;\n if (Math.abs(this.totalScroll) >= 1) {\n var _off = this.canvas_$.offset(),\n _delta = new paper.Point([\n _event.pageX - _off.left,\n _event.pageY - _off.top\n ]).subtract(this.offset).multiply( Math.SQRT2 - 1 );\n if (this.totalScroll > 0) {\n this.setScale( this.scale * Math.SQRT2, this.offset.subtract(_delta) );\n } else {\n this.setScale( this.scale * Math.SQRT1_2, this.offset.add(_delta.divide(Math.SQRT2)));\n }\n this.totalScroll = 0;\n }\n },\n onDoubleClick: function(_event) {\n if (!this.isEditable()) {\n return;\n }\n var _off = this.canvas_$.offset(),\n _point = new paper.Point([\n _event.pageX - _off.left,\n _event.pageY - _off.top\n ]);\n var _hitResult = paper.project.hitTest(_point);\n if (this.isEditable() && (!_hitResult || typeof _hitResult.item.__representation === \"undefined\")) {\n var _coords = this.toModelCoords(_point),\n _data = {\n id: Utils.getUID('node'),\n created_by: this.renkan.current_user,\n position: {\n x: _coords.x,\n y: _coords.y\n }\n },\n _node = this.renkan.project.addNode(_data);\n this.getRepresentationByModel(_node).openEditor();\n }\n paper.view.draw();\n },\n defaultDropHandler: function(_data) {\n var newNode = {};\n var snippet = \"\";\n switch(_data[\"text/x-iri-specific-site\"]) {\n case \"twitter\":\n snippet = $('<div>').html(_data[\"text/x-iri-selected-html\"]);\n var tweetdiv = snippet.find(\".tweet\");\n newNode.title = this.renkan.translate(\"Tweet by \") + tweetdiv.attr(\"data-name\");\n newNode.uri = \"http://twitter.com/\" + tweetdiv.attr(\"data-screen-name\") + \"/status/\" + tweetdiv.attr(\"data-tweet-id\");\n newNode.image = tweetdiv.find(\".avatar\").attr(\"src\");\n newNode.description = tweetdiv.find(\".js-tweet-text:first\").text();\n break;\n case \"google\":\n snippet = $('<div>').html(_data[\"text/x-iri-selected-html\"]);\n newNode.title = snippet.find(\"h3:first\").text().trim();\n newNode.uri = snippet.find(\"h3 a\").attr(\"href\");\n newNode.description = snippet.find(\".st:first\").text().trim();\n break;\n default:\n if (_data[\"text/x-iri-source-uri\"]) {\n newNode.uri = _data[\"text/x-iri-source-uri\"];\n }\n }\n if (_data[\"text/plain\"] || _data[\"text/x-iri-selected-text\"]) {\n newNode.description = (_data[\"text/plain\"] || _data[\"text/x-iri-selected-text\"]).replace(/[\\s\\n]+/gm,' ').trim();\n }\n if (_data[\"text/html\"] || _data[\"text/x-iri-selected-html\"]) {\n snippet = $('<div>').html(_data[\"text/html\"] || _data[\"text/x-iri-selected-html\"]);\n var _svgimgs = snippet.find(\"image\");\n if (_svgimgs.length) {\n newNode.image = _svgimgs.attr(\"xlink:href\");\n }\n var _svgpaths = snippet.find(\"path\");\n if (_svgpaths.length) {\n newNode.clipPath = _svgpaths.attr(\"d\");\n }\n var _imgs = snippet.find(\"img\");\n if (_imgs.length) {\n newNode.image = _imgs[0].src;\n }\n var _as = snippet.find(\"a\");\n if (_as.length) {\n newNode.uri = _as[0].href;\n }\n newNode.title = snippet.find(\"[title]\").attr(\"title\") || newNode.title;\n newNode.description = snippet.text().replace(/[\\s\\n]+/gm,' ').trim();\n }\n if (_data[\"text/uri-list\"]) {\n newNode.uri = _data[\"text/uri-list\"];\n }\n if (_data[\"text/x-moz-url\"] && !newNode.title) {\n newNode.title = (_data[\"text/x-moz-url\"].split(\"\\n\")[1] || \"\").trim();\n if (newNode.title === newNode.uri) {\n newNode.title = false;\n }\n }\n if (_data[\"text/x-iri-source-title\"] && !newNode.title) {\n newNode.title = _data[\"text/x-iri-source-title\"];\n }\n if (_data[\"text/html\"] || _data[\"text/x-iri-selected-html\"]) {\n snippet = $('<div>').html(_data[\"text/html\"] || _data[\"text/x-iri-selected-html\"]);\n newNode.image = snippet.find(\"[data-image]\").attr(\"data-image\") || newNode.image;\n newNode.uri = snippet.find(\"[data-uri]\").attr(\"data-uri\") || newNode.uri;\n newNode.title = snippet.find(\"[data-title]\").attr(\"data-title\") || newNode.title;\n newNode.description = snippet.find(\"[data-description]\").attr(\"data-description\") || newNode.description;\n newNode.clipPath = snippet.find(\"[data-clip-path]\").attr(\"data-clip-path\") || newNode.clipPath;\n }\n\n if (!newNode.title) {\n newNode.title = this.renkan.translate(\"Dragged resource\");\n }\n var fields = [\"title\", \"description\", \"uri\", \"image\"];\n for (var i = 0; i < fields.length; i++) {\n var f = fields[i];\n if (_data[\"text/x-iri-\" + f] || _data[f]) {\n newNode[f] = _data[\"text/x-iri-\" + f] || _data[f];\n }\n if (newNode[f] === \"none\" || newNode[f] === \"null\") {\n newNode[f] = undefined;\n }\n }\n\n if(typeof this.renkan.options.drop_enhancer === \"function\"){\n newNode = this.renkan.options.drop_enhancer(newNode, _data);\n }\n\n return newNode;\n\n },\n dropData: function(_data, _event) {\n if (!this.isEditable()) {\n return;\n }\n if (_data[\"text/json\"] || _data[\"application/json\"]) {\n try {\n var jsondata = JSON.parse(_data[\"text/json\"] || _data[\"application/json\"]);\n _(_data).extend(jsondata);\n }\n catch(e) {}\n }\n\n var newNode = (typeof this.renkan.options.drop_handler === \"undefined\")?this.defaultDropHandler(_data):this.renkan.options.drop_handler(_data);\n\n var _off = this.canvas_$.offset(),\n _point = new paper.Point([\n _event.pageX - _off.left,\n _event.pageY - _off.top\n ]),\n _coords = this.toModelCoords(_point),\n _nodedata = {\n id: Utils.getUID('node'),\n created_by: this.renkan.current_user,\n uri: newNode.uri || \"\",\n title: newNode.title || \"\",\n description: newNode.description || \"\",\n image: newNode.image || \"\",\n color: newNode.color || undefined,\n clip_path: newNode.clipPath || undefined,\n position: {\n x: _coords.x,\n y: _coords.y\n }\n };\n var _node = this.renkan.project.addNode(_nodedata),\n _repr = this.getRepresentationByModel(_node);\n if (_event.type === \"drop\") {\n _repr.openEditor();\n }\n },\n fullScreen: function() {\n var _isFull = document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen,\n _el = this.renkan.$[0],\n _requestMethods = [\"requestFullScreen\",\"mozRequestFullScreen\",\"webkitRequestFullScreen\"],\n _cancelMethods = [\"cancelFullScreen\",\"mozCancelFullScreen\",\"webkitCancelFullScreen\"],\n i;\n if (_isFull) {\n for (i = 0; i < _cancelMethods.length; i++) {\n if (typeof document[_cancelMethods[i]] === \"function\") {\n document[_cancelMethods[i]]();\n break;\n }\n }\n } else {\n for (i = 0; i < _requestMethods.length; i++) {\n if (typeof _el[_requestMethods[i]] === \"function\") {\n _el[_requestMethods[i]]();\n break;\n }\n }\n }\n },\n zoomOut: function() {\n var _newScale = this.scale * Math.SQRT1_2,\n _offset = new paper.Point([\n this.canvas_$.width(),\n this.canvas_$.height()\n ]).multiply( 0.5 * ( 1 - Math.SQRT1_2 ) ).add(this.offset.multiply( Math.SQRT1_2 ));\n this.setScale( _newScale, _offset );\n },\n zoomIn: function() {\n var _newScale = this.scale * Math.SQRT2,\n _offset = new paper.Point([\n this.canvas_$.width(),\n this.canvas_$.height()\n ]).multiply( 0.5 * ( 1 - Math.SQRT2 ) ).add(this.offset.multiply( Math.SQRT2 ));\n this.setScale( _newScale, _offset );\n },\n addNodeBtn: function() {\n if (this.click_mode === Utils._CLICKMODE_ADDNODE) {\n this.click_mode = false;\n this.notif_$.hide();\n } else {\n this.click_mode = Utils._CLICKMODE_ADDNODE;\n this.notif_$.text(this.renkan.translate(\"Click on the background canvas to add a node\")).fadeIn();\n }\n return false;\n },\n addEdgeBtn: function() {\n if (this.click_mode === Utils._CLICKMODE_STARTEDGE || this.click_mode === Utils._CLICKMODE_ENDEDGE) {\n this.click_mode = false;\n this.notif_$.hide();\n } else {\n this.click_mode = Utils._CLICKMODE_STARTEDGE;\n this.notif_$.text(this.renkan.translate(\"Click on a first node to start the edge\")).fadeIn();\n }\n return false;\n },\n exportProject: function() {\n var projectJSON = this.renkan.project.toJSON(),\n downloadLink = document.createElement(\"a\"),\n projectId = projectJSON.id,\n fileNameToSaveAs = projectId + \".json\";\n\n // clean ids\n delete projectJSON.id;\n delete projectJSON._id;\n delete projectJSON.space_id;\n\n var objId;\n var idsMap = {};\n\n _.each(projectJSON.nodes, function(e,i,l) {\n objId = e.id || e._id;\n delete e._id;\n delete e.id;\n idsMap[objId] = e['@id'] = Utils.getUUID4();\n });\n _.each(projectJSON.edges, function(e,i,l) {\n delete e._id;\n delete e.id;\n e.to = idsMap[e.to];\n e.from = idsMap[e.from];\n });\n _.each(projectJSON.views, function(e,i,l) {\n objId = e.id || e._id;\n delete e._id;\n delete e.id;\n });\n projectJSON.users = [];\n\n var projectJSONStr = JSON.stringify(projectJSON, null, 2);\n var blob = new Blob([projectJSONStr], {type: \"application/json;charset=utf-8\"});\n filesaver(blob,fileNameToSaveAs);\n\n },\n foldBins: function() {\n var foldBinsButton = this.$.find(\".Rk-Fold-Bins\"),\n bins = this.renkan.$.find(\".Rk-Bins\");\n var _this = this;\n if (bins.offset().left < 0) {\n bins.animate({left: 0},250);\n this.$.animate({left: 300},250,function() {\n var w = _this.$.width();\n paper.view.viewSize = new paper.Size([w, _this.canvas_$.height()]);\n });\n foldBinsButton.html(\"«\");\n } else {\n bins.animate({left: -300},250);\n this.$.animate({left: 0},250,function() {\n var w = _this.$.width();\n paper.view.viewSize = new paper.Size([w, _this.canvas_$.height()]);\n });\n foldBinsButton.html(\"»\");\n }\n },\n save: function() { },\n open: function() { }\n });\n\n /* Scene End */\n\n return Scene;\n\n});\n\n\n//Load modules and use them\nif( typeof require.config === \"function\" ) {\n require.config({\n paths: {\n 'jquery':'../lib/jquery.min',\n 'underscore':'../lib/underscore-min',\n 'filesaver' :'../lib/FileSaver',\n 'requtils':'require-utils'\n }\n });\n}\n\nrequire(['renderer/baserepresentation',\n 'renderer/basebutton',\n 'renderer/noderepr',\n 'renderer/edge',\n 'renderer/tempedge',\n 'renderer/baseeditor',\n 'renderer/nodeeditor',\n 'renderer/edgeeditor',\n 'renderer/nodebutton',\n 'renderer/nodeeditbutton',\n 'renderer/noderemovebutton',\n 'renderer/noderevertbutton',\n 'renderer/nodelinkbutton',\n 'renderer/nodeenlargebutton',\n 'renderer/nodeshrinkbutton',\n 'renderer/edgeeditbutton',\n 'renderer/edgeremovebutton',\n 'renderer/edgerevertbutton',\n 'renderer/miniframe',\n 'renderer/scene'\n ], function(BaseRepresentation, BaseButton, NodeRepr, Edge, TempEdge, BaseEditor, NodeEditor, EdgeEditor, NodeButton, NodeEditButton, NodeRemoveButton, NodeRevertButton, NodeLinkButton, NodeEnlargeButton, NodeShrinkButton, EdgeEditButton, EdgeRemoveButton, EdgeRevertButton, MiniFrame, Scene){\n\n \n\n var Rkns = window.Rkns;\n\n if(typeof Rkns.Renderer === \"undefined\"){\n Rkns.Renderer = {};\n }\n var Renderer = Rkns.Renderer;\n\n Renderer._BaseRepresentation = BaseRepresentation;\n Renderer._BaseButton = BaseButton;\n Renderer.Node = NodeRepr;\n Renderer.Edge = Edge;\n Renderer.TempEdge = TempEdge;\n Renderer._BaseEditor = BaseEditor;\n Renderer.NodeEditor = NodeEditor;\n Renderer.EdgeEditor = EdgeEditor;\n Renderer._NodeButton = NodeButton;\n Renderer.NodeEditButton = NodeEditButton;\n Renderer.NodeRemoveButton = NodeRemoveButton;\n Renderer.NodeRevertButton = NodeRevertButton;\n Renderer.NodeLinkButton = NodeLinkButton;\n Renderer.NodeEnlargeButton = NodeEnlargeButton;\n Renderer.NodeShrinkButton = NodeShrinkButton;\n Renderer.EdgeEditButton = EdgeEditButton;\n Renderer.EdgeRemoveButton = EdgeRemoveButton;\n Renderer.EdgeRevertButton = EdgeRevertButton;\n Renderer.MiniFrame = MiniFrame;\n Renderer.Scene = Scene;\n \n startRenkan();\n});\n\ndefine(\"main-renderer\", function(){});\n\n"]}
\ No newline at end of file