22 * |
22 * |
23 * The fact that you are presently reading this means that you have had |
23 * The fact that you are presently reading this means that you have had |
24 * knowledge of the CeCILL-C license and that you accept its terms. |
24 * knowledge of the CeCILL-C license and that you accept its terms. |
25 */ |
25 */ |
26 |
26 |
27 /*! renkan - v00.12.22 - Copyright © IRI 2016 */ |
27 /*! renkan - v00.13 - Copyright © IRI 2017 */ |
28 |
28 |
29 this["renkanJST"] = this["renkanJST"] || {}; |
29 this["renkanJST"] = this["renkanJST"] || {}; |
30 |
30 |
31 this["renkanJST"]["templates/colorpicker.html"] = function(obj) { |
31 this["renkanJST"]["templates/colorpicker.html"] = function(obj) { |
32 obj || (obj = {}); |
32 obj || (obj = {}); |
155 __p += '\n <div class="Rk-Editor-p">\n '; |
155 __p += '\n <div class="Rk-Editor-p">\n '; |
156 if (options.show_edge_editor_style_color) { ; |
156 if (options.show_edge_editor_style_color) { ; |
157 __p += '\n <div id="Rk-Editor-p-color">\n <span class="Rk-Editor-Label">' + |
157 __p += '\n <div id="Rk-Editor-p-color">\n <span class="Rk-Editor-Label">' + |
158 __e(renkan.translate("Edge color:")) + |
158 __e(renkan.translate("Edge color:")) + |
159 '</span>\n <div class="Rk-Edit-ColorPicker-Wrapper">\n <span class="Rk-Edit-Color" style="background: <%-edge.color%>;">\n <span class="Rk-Edit-ColorTip"></span>\n </span>\n ' + |
159 '</span>\n <div class="Rk-Edit-ColorPicker-Wrapper">\n <span class="Rk-Edit-Color" style="background: <%-edge.color%>;">\n <span class="Rk-Edit-ColorTip"></span>\n </span>\n ' + |
160 ((__t = ( renkan.colorPicker )) == null ? '' : __t) + |
160 ((__t = ( renkan.colorPicker('Rk-Editor-ColorPicker-Edge') )) == null ? '' : __t) + |
161 '\n <span class="Rk-Edit-ColorPicker-Text">' + |
161 '\n <span class="Rk-Edit-ColorPicker-Text">' + |
162 __e( renkan.translate("Choose color") ) + |
162 __e( renkan.translate("Choose color") ) + |
163 '</span>\n </div>\n </div>\n '; |
163 '</span>\n </div>\n </div>\n '; |
164 } ; |
164 } ; |
165 __p += '\n '; |
165 __p += '\n '; |
526 __p += '\n <input class="Rk-Edit-Title" type="text" value="' + |
526 __p += '\n <input class="Rk-Edit-Title" type="text" value="' + |
527 __e(node.title) + |
527 __e(node.title) + |
528 '" />\n '; |
528 '" />\n '; |
529 } ; |
529 } ; |
530 __p += '\n</p>\n'; |
530 __p += '\n</p>\n'; |
|
531 if (options.show_node_title_style) { ; |
|
532 __p += '\n <div class="Rk-Editor-p-title-style Rk-Editor-p">\n <div class="Rk-Editor-p-title-color">\n <span class="Rk-Editor-Label">' + |
|
533 __e(renkan.translate("Title color:")) + |
|
534 '</span>\n <span class="Rk-Edit-Color" style="background: ' + |
|
535 __e(node.title_color) + |
|
536 ';">\n <span class="Rk-Edit-ColorTip"></span>\n </span>\n ' + |
|
537 ((__t = ( renkan.colorPicker('Rk-Editor-ColorPicker-Title') )) == null ? '' : __t) + |
|
538 '\n </div>\n <div class="Rk-Editor-p-title-size">\n <span class="Rk-Editor-Label">' + |
|
539 __e(renkan.translate("Title size:")) + |
|
540 '</span>\n <a href="#" class="Rk-Edit-Size-Btn" id="Rk-Edit-Title-Size-Down">-</a>\n <span class="Rk-Edit-Size-Disp" id="Rk-Edit-Title-Size-Value">' + |
|
541 __e(node.title_size.toFixed(1)) + |
|
542 '</span>\n <a href="#" class="Rk-Edit-Size-Btn" id="Rk-Edit-Title-Size-Up">+</a>\n </div>\n </div>\n'; |
|
543 } ; |
|
544 __p += ' '; |
531 if (options.show_node_editor_uri) { ; |
545 if (options.show_node_editor_uri) { ; |
532 __p += '\n <p>\n <label>' + |
546 __p += '\n <p>\n <label>' + |
533 __e(renkan.translate("URI:")) + |
547 __e(renkan.translate("URI:")) + |
534 '</label>\n <input class="Rk-Edit-URI" type="text" value="' + |
548 '</label>\n <input class="Rk-Edit-URI" type="text" value="' + |
535 __e(node.uri) + |
549 __e(node.uri) + |
588 __p += '\n <div id="Rk-Editor-p-color">\n <span class="Rk-Editor-Label">\n ' + |
602 __p += '\n <div id="Rk-Editor-p-color">\n <span class="Rk-Editor-Label">\n ' + |
589 __e(renkan.translate("Node color:")) + |
603 __e(renkan.translate("Node color:")) + |
590 '</span>\n <div class="Rk-Edit-ColorPicker-Wrapper">\n <span class="Rk-Edit-Color" style="background: ' + |
604 '</span>\n <div class="Rk-Edit-ColorPicker-Wrapper">\n <span class="Rk-Edit-Color" style="background: ' + |
591 __e(node.color) + |
605 __e(node.color) + |
592 ';">\n <span class="Rk-Edit-ColorTip"></span>\n </span>\n ' + |
606 ';">\n <span class="Rk-Edit-ColorTip"></span>\n </span>\n ' + |
593 ((__t = ( renkan.colorPicker )) == null ? '' : __t) + |
607 ((__t = ( renkan.colorPicker('Rk-Editor-ColorPicker-Node') )) == null ? '' : __t) + |
594 '\n <span class="Rk-Edit-ColorPicker-Text">' + |
608 '\n <span class="Rk-Edit-ColorPicker-Text">' + |
595 __e( renkan.translate("Choose color") ) + |
609 __e( renkan.translate("Choose color") ) + |
596 '</span>\n </div>\n </div>\n '; |
610 '</span>\n </div>\n </div>\n '; |
597 } ; |
611 } ; |
598 __p += '\n '; |
612 __p += '\n '; |
675 function print() { __p += __j.call(arguments, '') } |
689 function print() { __p += __j.call(arguments, '') } |
676 with (obj) { |
690 with (obj) { |
677 |
691 |
678 if (options.show_top_bar) { ; |
692 if (options.show_top_bar) { ; |
679 __p += '\n <div class="Rk-TopBar">\n <div class="loader"></div>\n '; |
693 __p += '\n <div class="Rk-TopBar">\n <div class="loader"></div>\n '; |
680 if (!options.editor_mode) { ; |
694 if (!options.editor_mode || !options.title_editable) { ; |
681 __p += '\n <h2 class="Rk-PadTitle">\n ' + |
695 __p += '\n <h2 class="Rk-PadTitle">\n ' + |
682 __e( project.get("title") || translate("Untitled project")) + |
696 __e( project.get("title") || translate("Untitled project")) + |
683 '\n </h2>\n '; |
697 '\n </h2>\n '; |
684 } else { ; |
698 } else { ; |
685 __p += '\n <input type="text" class="Rk-PadTitle" value="' + |
699 __p += '\n <input type="text" class="Rk-PadTitle" value="' + |
695 __p += '\n <div class="Rk-Edit-ColorPicker-Wrapper">\n <span class="Rk-CurrentUser-Color">\n '; |
709 __p += '\n <div class="Rk-Edit-ColorPicker-Wrapper">\n <span class="Rk-CurrentUser-Color">\n '; |
696 if (options.user_color_editable) { ; |
710 if (options.user_color_editable) { ; |
697 __p += '\n <span class="Rk-Edit-ColorTip"></span>\n '; |
711 __p += '\n <span class="Rk-Edit-ColorTip"></span>\n '; |
698 } ; |
712 } ; |
699 __p += '\n </span>\n '; |
713 __p += '\n </span>\n '; |
700 if (options.user_color_editable) { print(colorPicker) } ; |
714 if (options.user_color_editable) { print(colorPicker('Rk-Editor-ColorPicker-User')) } ; |
701 __p += '\n </div>\n '; |
715 __p += '\n </div>\n '; |
702 } ; |
716 } ; |
703 __p += '\n <span class="Rk-CurrentUser-Name"><unknown user></span>\n </div>\n <ul class="Rk-UserList"></ul>\n </div>\n '; |
717 __p += '\n <span class="Rk-CurrentUser-Name"><unknown user></span>\n </div>\n <ul class="Rk-UserList"></ul>\n </div>\n '; |
704 } ; |
718 } ; |
705 __p += '\n '; |
719 __p += '\n '; |
958 |
972 |
959 this.options = _.defaults(_opts, Rkns.defaults, { |
973 this.options = _.defaults(_opts, Rkns.defaults, { |
960 templates: _.defaults(_opts.templates, renkanJST) || renkanJST, |
974 templates: _.defaults(_opts.templates, renkanJST) || renkanJST, |
961 node_editor_templates: _.defaults(_opts.node_editor_templates, Rkns.defaults.node_editor_templates) |
975 node_editor_templates: _.defaults(_opts.node_editor_templates, Rkns.defaults.node_editor_templates) |
962 }); |
976 }); |
963 this.template = renkanJST['templates/main.html']; |
977 this.template = this.options.templates['templates/main.html']; |
964 |
978 |
965 var types_templates = {}; |
979 var types_templates = {}; |
966 _.each(this.options.node_editor_templates, function(value, key) { |
980 _.each(this.options.node_editor_templates, function(value, key) { |
967 types_templates[key] = _this.options.templates[value]; |
981 types_templates[key] = _this.options.templates[value]; |
968 delete _this.options.templates[value]; |
982 delete _this.options.templates[value]; |
1008 if (this.renderer) { |
1022 if (this.renderer) { |
1009 this.renderer.redrawUsers(); |
1023 this.renderer.redrawUsers(); |
1010 } |
1024 } |
1011 }); |
1025 }); |
1012 |
1026 |
1013 this.colorPicker = (function() { |
1027 this.colorPicker = function(pickerClass) { |
1014 var _tmpl = renkanJST['templates/colorpicker.html']; |
1028 var _tmpl = _this.options.templates['templates/colorpicker.html']; |
1015 return '<ul class="Rk-Edit-ColorPicker">' + Rkns.pickerColors.map(function(c) { |
1029 return '<ul class="Rk-Edit-ColorPicker '+pickerClass+'">' + Rkns.pickerColors.map(function(c) { |
1016 return _tmpl({ |
1030 return _tmpl({ |
1017 c: c |
1031 c: c |
1018 }); |
1032 }); |
1019 }).join("") + '</ul>'; |
1033 }).join("") + '</ul>'; |
1020 })(); |
1034 }; |
1021 |
1035 |
1022 if (this.options.show_editor) { |
1036 if (this.options.show_editor) { |
1023 this.renderer = new Rkns.Renderer.Scene(this); |
1037 this.renderer = new Rkns.Renderer.Scene(this); |
1024 } |
1038 } |
1025 |
1039 |
1026 if (!this.options.search.length) { |
1040 if (!this.options.search.length) { |
1027 this.$.find(".Rk-Web-Search-Form").detach(); |
1041 this.$.find(".Rk-Web-Search-Form").detach(); |
1028 } else { |
1042 } else { |
1029 var _tmpl = renkanJST['templates/search.html'], |
1043 var _tmpl = _this.options.templates['templates/search.html'], |
1030 _select = this.$.find(".Rk-Search-List"), |
1044 _select = this.$.find(".Rk-Search-List"), |
1031 _input = this.$.find(".Rk-Web-Search-Input"), |
1045 _input = this.$.find(".Rk-Web-Search-Input"), |
1032 _form = this.$.find(".Rk-Web-Search-Form"); |
1046 _form = this.$.find(".Rk-Web-Search-Form"); |
1033 _.each(this.options.search, function(_search, _key) { |
1047 _.each(this.options.search, function(_search, _key) { |
1034 if (Rkns[_search.type] && Rkns[_search.type].Search) { |
1048 if (Rkns[_search.type] && Rkns[_search.type].Search) { |
1407 shortenText: function(_text, _maxlength) { |
1421 shortenText: function(_text, _maxlength) { |
1408 return (_text.length > _maxlength ? (_text.substr(0, _maxlength) + '…') : _text); |
1422 return (_text.length > _maxlength ? (_text.substr(0, _maxlength) + '…') : _text); |
1409 }, |
1423 }, |
1410 /* Drawing an edit box with an arrow and positioning the edit box according to the position of the node/edge being edited |
1424 /* Drawing an edit box with an arrow and positioning the edit box according to the position of the node/edge being edited |
1411 * Called by Rkns.Renderer.NodeEditor and Rkns.Renderer.EdgeEditor */ |
1425 * Called by Rkns.Renderer.NodeEditor and Rkns.Renderer.EdgeEditor */ |
1412 drawEditBox: function(_options, _coords, _path, _xmargin, _selector) { |
1426 drawEditBox: function(_options, _coords, _path, _xmargin, _selector, _renkan) { |
1413 _selector.css({ |
1427 _selector.css({ |
1414 width: (_options.tooltip_width - 2 * _options.tooltip_padding) |
1428 width: (_options.tooltip_width - 2 * _options.tooltip_padding) |
1415 }); |
1429 }); |
1416 var _height = _selector.outerHeight() + 2 * _options.tooltip_padding, |
1430 |
|
1431 var rect = _selector[0].getBoundingClientRect(); |
|
1432 var container_rect = _renkan.$[0].getBoundingClientRect(); |
|
1433 |
|
1434 if(rect.bottom > (container_rect.bottom - 2 * _options.tooltip_padding - 10)) { |
|
1435 _selector.css({ |
|
1436 'overflow-x': 'hidden', |
|
1437 'overflow-y': 'scroll', |
|
1438 'max-height':(container_rect.bottom - 2 * _options.tooltip_padding - 5 - rect.top) + 'px' |
|
1439 }); |
|
1440 } |
|
1441 |
|
1442 var _height = _selector.outerHeight() + 2 * _options.tooltip_padding + 5, |
1417 _isLeft = (_coords.x < paper.view.center.x ? 1 : -1), |
1443 _isLeft = (_coords.x < paper.view.center.x ? 1 : -1), |
1418 _left = _coords.x + _isLeft * (_xmargin + _options.tooltip_arrow_length), |
1444 _left = _coords.x + _isLeft * (_xmargin + _options.tooltip_arrow_length), |
1419 _right = _coords.x + _isLeft * (_xmargin + _options.tooltip_arrow_length + _options.tooltip_width), |
1445 _right = _coords.x + _isLeft * (_xmargin + _options.tooltip_arrow_length + _options.tooltip_width), |
1420 _top = _coords.y - _height / 2; |
1446 _top = _coords.y - _height / 2; |
1421 if (_top + _height > (paper.view.size.height - _options.tooltip_margin)) { |
1447 if (_top + _height > (paper.view.size.height - _options.tooltip_margin)) { |
1432 _path.segments[2].point.y = _path.segments[3].point.y = _top; |
1458 _path.segments[2].point.y = _path.segments[3].point.y = _top; |
1433 _path.segments[4].point.y = _path.segments[5].point.y = _bottom; |
1459 _path.segments[4].point.y = _path.segments[5].point.y = _bottom; |
1434 _path.segments[1].point.y = _coords.y - _options.tooltip_arrow_width / 2; |
1460 _path.segments[1].point.y = _coords.y - _options.tooltip_arrow_width / 2; |
1435 _path.segments[6].point.y = _coords.y + _options.tooltip_arrow_width / 2; |
1461 _path.segments[6].point.y = _coords.y + _options.tooltip_arrow_width / 2; |
1436 _path.fillColor = new paper.Color(new paper.Gradient([_options.tooltip_top_color, _options.tooltip_bottom_color]), [0, _top], [0, _bottom]); |
1462 _path.fillColor = new paper.Color(new paper.Gradient([_options.tooltip_top_color, _options.tooltip_bottom_color]), [0, _top], [0, _bottom]); |
|
1463 |
1437 _selector.css({ |
1464 _selector.css({ |
1438 left: (_options.tooltip_padding + Math.min(_left, _right)), |
1465 left: (_options.tooltip_padding + Math.min(_left, _right)), |
1439 top: (_options.tooltip_padding + _top) |
1466 top: (_options.tooltip_padding + _top) |
1440 }); |
1467 }); |
|
1468 |
1441 return _path; |
1469 return _path; |
1442 }, |
1470 }, |
1443 // from http://stackoverflow.com/a/6444043 |
1471 // from http://stackoverflow.com/a/6444043 |
1444 increaseBrightness: function (hex, percent){ |
1472 increaseBrightness: function (hex, percent){ |
1445 // strip the leading # if it's there |
1473 // strip the leading # if it's there |
1959 size_bug_fix: false, |
1987 size_bug_fix: false, |
1960 /* Resize the canvas after load (fixes a bug on iPad and FF Mac) */ |
1988 /* Resize the canvas after load (fixes a bug on iPad and FF Mac) */ |
1961 force_resize: false, |
1989 force_resize: false, |
1962 allow_double_click: true, |
1990 allow_double_click: true, |
1963 /* Allows Double Click to create a node on an empty background */ |
1991 /* Allows Double Click to create a node on an empty background */ |
|
1992 double_click_open_url: true, |
|
1993 /* In read_only mode open node uri in new window with a double click */ |
|
1994 simple_click_open_url: false, |
|
1995 /* In read_only mode open node uri in new window with a simple click (do not disable the double click) */ |
1964 zoom_on_scroll: true, |
1996 zoom_on_scroll: true, |
1965 /* Allows to use the scrollwheel to zoom */ |
1997 /* Allows to use the scrollwheel to zoom */ |
1966 element_delete_delay: 0, |
1998 element_delete_delay: 0, |
1967 /* Delay between clicking on the bin on an element and really deleting it |
1999 /* Delay between clicking on the bin on an element and really deleting it |
1968 Set to 0 for delete confirm */ |
2000 Set to 0 for delete confirm */ |
1994 /* show the user list */ |
2026 /* show the user list */ |
1995 user_name_editable: true, |
2027 user_name_editable: true, |
1996 /* allow the edition of the user name */ |
2028 /* allow the edition of the user name */ |
1997 user_color_editable: true, |
2029 user_color_editable: true, |
1998 /* allow the edition of the user color */ |
2030 /* allow the edition of the user color */ |
|
2031 title_editable: true, |
|
2032 /* allow the edition of the renkan title */ |
1999 show_user_color: true, |
2033 show_user_color: true, |
2000 /* show user colors in the list */ |
2034 /* show user colors in the list */ |
2001 show_save_button: true, |
2035 show_save_button: true, |
2002 show_export_button: true, |
2036 show_export_button: true, |
2003 show_open_button: false, |
2037 show_open_button: false, |
2045 node_stroke_width: 2, |
2079 node_stroke_width: 2, |
2046 node_stroke_max_width: 12, |
2080 node_stroke_max_width: 12, |
2047 selected_node_stroke_width: 4, |
2081 selected_node_stroke_width: 4, |
2048 selected_node_stroke_max_width: 24, |
2082 selected_node_stroke_max_width: 24, |
2049 node_stroke_witdh_scale: 5, |
2083 node_stroke_witdh_scale: 5, |
|
2084 node_title_size_min: 0, |
|
2085 /* minimum relative size for node title (in graph) */ |
|
2086 node_title_size_max: 5, |
|
2087 /* maximum relative size for node title (in graph) */ |
|
2088 node_title_size_step: 0.1, |
|
2089 /* step for relative size for node title (in graph) */ |
2050 node_fill_color: "#ffffff", |
2090 node_fill_color: "#ffffff", |
|
2091 /* default color to fill node background */ |
2051 highlighted_node_fill_color: "#ffff00", |
2092 highlighted_node_fill_color: "#ffff00", |
|
2093 /* default color to fill highlighted node background */ |
|
2094 node_title_color: "#000000", |
|
2095 /* default title color */ |
2052 node_label_distance: 5, |
2096 node_label_distance: 5, |
2053 /* Vertical distance between node and label */ |
2097 /* Vertical distance between node and label */ |
2054 node_label_max_length: 60, |
2098 node_label_max_length: 60, |
2055 /* Maximum displayed text length */ |
2099 /* Maximum displayed text length */ |
2056 label_untitled_nodes: "(untitled)", |
2100 label_untitled_nodes: "(untitled)", |
2109 removePlugins : 'colorbutton,find,flash,font,forms,iframe,image,newpage,smiley,specialchar,stylescombo,templates', |
2153 removePlugins : 'colorbutton,find,flash,font,forms,iframe,image,newpage,smiley,specialchar,stylescombo,templates', |
2110 }, |
2154 }, |
2111 |
2155 |
2112 /* NODE EDITOR OPTIONS */ |
2156 /* NODE EDITOR OPTIONS */ |
2113 |
2157 |
|
2158 show_node_title_style: true, |
2114 show_node_editor_uri: true, |
2159 show_node_editor_uri: true, |
2115 show_node_editor_title: true, |
2160 show_node_editor_title: true, |
2116 show_node_editor_title_richtext: true, |
2161 show_node_editor_title_richtext: true, |
2117 show_node_editor_description: true, |
2162 show_node_editor_description: true, |
2118 show_node_editor_description_richtext: true, |
2163 show_node_editor_description_richtext: true, |
2119 show_node_editor_size: true, |
2164 show_node_editor_size: true, |
2120 show_node_editor_style: true, |
2165 show_node_editor_style: true, // show node title style editor |
2121 show_node_editor_style_color: true, |
2166 show_node_editor_style_color: true, |
2122 show_node_editor_style_dash: true, |
2167 show_node_editor_style_dash: true, |
2123 show_node_editor_style_thickness: true, |
2168 show_node_editor_style_thickness: true, |
2124 show_node_editor_image: true, |
2169 show_node_editor_image: true, |
2125 show_node_editor_creator: true, |
2170 show_node_editor_creator: true, |
2254 "Search in graph":"Rechercher dans carte", |
2299 "Search in graph":"Rechercher dans carte", |
2255 "Search in " : "Chercher dans ", |
2300 "Search in " : "Chercher dans ", |
2256 "Show hidden nodes": "Montrer les noeuds cachés", |
2301 "Show hidden nodes": "Montrer les noeuds cachés", |
2257 "Show neighbors": "Montrer les voisins", |
2302 "Show neighbors": "Montrer les voisins", |
2258 "Hide": "Cacher", |
2303 "Hide": "Cacher", |
2259 "Fullscreen not supported by your browser": "Le plein écran n'est pas supporté par votre navigateur" |
2304 "Fullscreen not supported by your browser": "Le plein écran n'est pas supporté par votre navigateur", |
|
2305 "Title size:": "Taille :", |
|
2306 "Title color:": "Couleur :", |
2260 } |
2307 } |
2261 }; |
2308 }; |
2262 |
2309 |
2263 /* Saves the Full JSON at each modification */ |
2310 /* Saves the Full JSON at each modification */ |
2264 |
2311 |
2431 console.error("No such LDT Bin Type"); |
2478 console.error("No such LDT Bin Type"); |
2432 }; |
2479 }; |
2433 |
2480 |
2434 var ProjectBin = Ldt.ProjectBin = Rkns.Utils.inherit(Rkns._BaseBin); |
2481 var ProjectBin = Ldt.ProjectBin = Rkns.Utils.inherit(Rkns._BaseBin); |
2435 |
2482 |
2436 ProjectBin.prototype.tagTemplate = renkanJST['templates/ldtjson-bin/tagtemplate.html']; |
|
2437 |
|
2438 ProjectBin.prototype.annotationTemplate = renkanJST['templates/ldtjson-bin/annotationtemplate.html']; |
|
2439 |
2483 |
2440 ProjectBin.prototype._init = function(_renkan, _opts) { |
2484 ProjectBin.prototype._init = function(_renkan, _opts) { |
2441 this.renkan = _renkan; |
2485 this.renkan = _renkan; |
|
2486 this.tagTemplate = _renkan.options.templates['templates/ldtjson-bin/tagtemplate.html']; |
|
2487 this.annotationTemplate = _renkan.options.templates['templates/ldtjson-bin/annotationtemplate.html']; |
2442 this.proj_id = _opts.project_id; |
2488 this.proj_id = _opts.project_id; |
2443 this.ldt_platform = _opts.ldt_platform || "http://ldt.iri.centrepompidou.fr/"; |
2489 this.ldt_platform = _opts.ldt_platform || "http://ldt.iri.centrepompidou.fr/"; |
2444 this.title_$.html(_opts.title); |
2490 this.title_$.html(_opts.title); |
2445 this.title_icon_$.addClass('Rk-Ldt-Title-Icon'); |
2491 this.title_icon_$.addClass('Rk-Ldt-Title-Icon'); |
2446 this.refresh(); |
2492 this.refresh(); |
2568 ); |
2614 ); |
2569 }; |
2615 }; |
2570 |
2616 |
2571 var ResultsBin = Ldt.ResultsBin = Rkns.Utils.inherit(Rkns._BaseBin); |
2617 var ResultsBin = Ldt.ResultsBin = Rkns.Utils.inherit(Rkns._BaseBin); |
2572 |
2618 |
2573 ResultsBin.prototype.segmentTemplate = renkanJST['templates/ldtjson-bin/segmenttemplate.html']; |
|
2574 |
2619 |
2575 ResultsBin.prototype._init = function(_renkan, _opts) { |
2620 ResultsBin.prototype._init = function(_renkan, _opts) { |
2576 this.renkan = _renkan; |
2621 this.renkan = _renkan; |
|
2622 this.segmentTemplate = _renkan.options.templates['templates/ldtjson-bin/segmenttemplate.html']; |
2577 this.ldt_platform = _opts.ldt_platform || "http://ldt.iri.centrepompidou.fr/"; |
2623 this.ldt_platform = _opts.ldt_platform || "http://ldt.iri.centrepompidou.fr/"; |
2578 this.max_results = _opts.max_results || 50; |
2624 this.max_results = _opts.max_results || 50; |
2579 this.search = _opts.search; |
2625 this.search = _opts.search; |
2580 this.title_$.html('Lignes de Temps: "' + _opts.search + '"'); |
2626 this.title_$.html('Lignes de Temps: "' + _opts.search + '"'); |
2581 this.title_icon_$.addClass('Rk-Ldt-Title-Icon'); |
2627 this.title_icon_$.addClass('Rk-Ldt-Title-Icon'); |
2681 |
2727 |
2682 Rkns.ResourceList = {}; |
2728 Rkns.ResourceList = {}; |
2683 |
2729 |
2684 Rkns.ResourceList.Bin = Rkns.Utils.inherit(Rkns._BaseBin); |
2730 Rkns.ResourceList.Bin = Rkns.Utils.inherit(Rkns._BaseBin); |
2685 |
2731 |
2686 Rkns.ResourceList.Bin.prototype.resultTemplate = renkanJST['templates/list-bin.html']; |
|
2687 |
|
2688 Rkns.ResourceList.Bin.prototype._init = function(_renkan, _opts) { |
2732 Rkns.ResourceList.Bin.prototype._init = function(_renkan, _opts) { |
2689 this.renkan = _renkan; |
2733 this.renkan = _renkan; |
|
2734 this.resultTemplate = _renkan.options.templates['templates/list-bin.html']; |
2690 this.title_$.html(_opts.title); |
2735 this.title_$.html(_opts.title); |
2691 if (_opts.list) { |
2736 if (_opts.list) { |
2692 this.data = _opts.list; |
2737 this.data = _opts.list; |
2693 } |
2738 } |
2694 this.refresh(); |
2739 this.refresh(); |
2797 ); |
2842 ); |
2798 }; |
2843 }; |
2799 |
2844 |
2800 Rkns.Wikipedia.Bin = Rkns.Utils.inherit(Rkns._BaseBin); |
2845 Rkns.Wikipedia.Bin = Rkns.Utils.inherit(Rkns._BaseBin); |
2801 |
2846 |
2802 Rkns.Wikipedia.Bin.prototype.resultTemplate = renkanJST['templates/wikipedia-bin/resulttemplate.html']; |
|
2803 |
|
2804 Rkns.Wikipedia.Bin.prototype._init = function(_renkan, _opts) { |
2847 Rkns.Wikipedia.Bin.prototype._init = function(_renkan, _opts) { |
2805 this.renkan = _renkan; |
2848 this.renkan = _renkan; |
2806 this.search = _opts.search; |
2849 this.search = _opts.search; |
|
2850 this.resultTemplate = _renkan.options.templates['templates/wikipedia-bin/resulttemplate.html']; |
2807 this.lang = _opts.lang || "en"; |
2851 this.lang = _opts.lang || "en"; |
2808 this.title_icon_$.addClass('Rk-Wikipedia-Title-Icon Rk-Wikipedia-Lang-' + this.lang); |
2852 this.title_icon_$.addClass('Rk-Wikipedia-Title-Icon Rk-Wikipedia-Lang-' + this.lang); |
2809 this.title_$.html(this.search).addClass("Rk-Wikipedia-Title"); |
2853 this.title_$.html(this.search).addClass("Rk-Wikipedia-Title"); |
2810 this.refresh(); |
2854 this.refresh(); |
2811 }; |
2855 }; |
3272 var clean_title = div.textContent || div.innerText || ""; |
3316 var clean_title = div.textContent || div.innerText || ""; |
3273 |
3317 |
3274 var _text = clean_title || this.renkan.translate(this.options.label_untitled_nodes) || ""; |
3318 var _text = clean_title || this.renkan.translate(this.options.label_untitled_nodes) || ""; |
3275 _text = Utils.shortenText(_text, this.options.node_label_max_length); |
3319 _text = Utils.shortenText(_text, this.options.node_label_max_length); |
3276 |
3320 |
|
3321 //_formatedText = _text; |
|
3322 |
|
3323 |
3277 if (typeof this.highlighted === "object") { |
3324 if (typeof this.highlighted === "object") { |
3278 this.title.html(this.highlighted.replace(_(_text).escape(),'<span class="Rk-Highlighted">$1</span>')); |
3325 _text = this.highlighted.replace(_(_text).escape(),'<span class="Rk-Highlighted">$1</span>'); |
3279 } else { |
3326 } |
3280 this.title.text(_text); |
3327 |
3281 } |
3328 //TODO: default text node color |
|
3329 var node_style = (this.model.get("style") || {'title_size': 1, 'title-color': '#00000' }); |
|
3330 var text_size = node_style.title_size || 1; |
|
3331 var text_color = node_style.title_color || this.options.node_title_color; |
|
3332 |
|
3333 var text_style = { |
|
3334 'line-height': "1em" |
|
3335 }; |
|
3336 |
|
3337 if(text_size !== 1) { |
|
3338 text_style['font-size'] = text_size.toFixed(1)+"em"; |
|
3339 } |
|
3340 //TODO: compare with default value |
|
3341 if(text_color !== "#000000") { |
|
3342 text_style.color = text_color; |
|
3343 } |
|
3344 |
|
3345 var text_node = $("<span>").css(text_style).html(_text); |
|
3346 |
|
3347 this.title.empty().append(text_node); |
3282 |
3348 |
3283 var _strokeWidth = this._getStrokeWidth(); |
3349 var _strokeWidth = this._getStrokeWidth(); |
3284 this.title.css({ |
3350 this.title.css({ |
3285 left: this.paper_coords.x, |
3351 left: this.paper_coords.x, |
3286 top: this.paper_coords.y + this.circle_radius * this.h_ratio + this.options.node_label_distance + 0.5*_strokeWidth, |
3352 top: this.paper_coords.y + this.circle_radius * this.h_ratio + this.options.node_label_distance + 0.5*_strokeWidth, |
4205 |
4271 |
4206 _(NodeEditor.prototype).extend({ |
4272 _(NodeEditor.prototype).extend({ |
4207 _init: function() { |
4273 _init: function() { |
4208 BaseEditor.prototype._init.apply(this); |
4274 BaseEditor.prototype._init.apply(this); |
4209 this.template = this.options.templates['templates/nodeeditor.html']; |
4275 this.template = this.options.templates['templates/nodeeditor.html']; |
4210 //this.templates['default']= this.options.templates['templates/nodeeditor.html']; |
|
4211 //fusionner avec this.options.node_editor_templates |
4276 //fusionner avec this.options.node_editor_templates |
4212 this.readOnlyTemplate = this.options.node_editor_templates; |
4277 this.readOnlyTemplate = this.options.node_editor_templates; |
4213 }, |
4278 }, |
4214 draw: function() { |
4279 draw: function() { |
4215 var _model = this.source_representation.model, |
4280 var _model = this.source_representation.model, |
4228 short_uri: Utils.shortenText((_model.get("uri") || "").replace(/^(https?:\/\/)?(www\.)?/,'').replace(/\/$/,''),40), |
4293 short_uri: Utils.shortenText((_model.get("uri") || "").replace(/^(https?:\/\/)?(www\.)?/,'').replace(/\/$/,''),40), |
4229 description: _model.get("description"), |
4294 description: _model.get("description"), |
4230 image: _model.get("image") || "", |
4295 image: _model.get("image") || "", |
4231 image_placeholder: _image_placeholder, |
4296 image_placeholder: _image_placeholder, |
4232 color: (_model.has("style") && _model.get("style").color) || _created_by.get("color"), |
4297 color: (_model.has("style") && _model.get("style").color) || _created_by.get("color"), |
|
4298 title_size: (_model.has("style") && _model.get("style").title_size) || 1, |
|
4299 title_color: (_model.has("style") && _model.get("style").title_color) || this.options.node_title_color, |
4233 thickness: (_model.has("style") && _model.get("style").thickness) || 1, |
4300 thickness: (_model.has("style") && _model.get("style").thickness) || 1, |
4234 dash: _model.has("style") && _model.get("style").dash ? "checked" : "", |
4301 dash: _model.has("style") && _model.get("style").dash ? "checked" : "", |
4235 clip_path: _model.get("clip_path") || false, |
4302 clip_path: _model.get("clip_path") || false, |
4236 created_by_color: _created_by.get("color"), |
4303 created_by_color: _created_by.get("color"), |
4237 created_by_title: _created_by.get("title"), |
4304 created_by_title: _created_by.get("title"), |
4480 this.editor_$.find("#Rk-Edit-Thickness-Up").click(function() { |
4547 this.editor_$.find("#Rk-Edit-Thickness-Up").click(function() { |
4481 shiftThickness(1); |
4548 shiftThickness(1); |
4482 return false; |
4549 return false; |
4483 }); |
4550 }); |
4484 |
4551 |
|
4552 var shiftTitleSize = function(n) { |
|
4553 var min = _this.options.node_title_size_min; |
|
4554 var max = _this.options.node_title_size_max; |
|
4555 if (_this.renderer.isEditable()) { |
|
4556 var _oldTitleSize = ((_model.has('style') && _model.get('style').title_size) || 1), |
|
4557 _newTitleSize = n + _oldTitleSize; |
|
4558 if(_newTitleSize < min ) { |
|
4559 _newTitleSize = min; |
|
4560 } |
|
4561 else if (_newTitleSize > max) { |
|
4562 _newTitleSize = max; |
|
4563 } |
|
4564 if (_newTitleSize !== _oldTitleSize) { |
|
4565 _this.editor_$.find("#Rk-Edit-Title-Size-Value").text(_newTitleSize.toFixed(1)); |
|
4566 _model.set("style", _.assign( ((_model.has("style") && _.clone(_model.get("style"))) || {}), {title_size: _newTitleSize})); |
|
4567 paper.view.draw(); |
|
4568 } |
|
4569 } |
|
4570 else { |
|
4571 closeEditor(); |
|
4572 } |
|
4573 }; |
|
4574 |
|
4575 |
|
4576 var _pickerTitle = _this.editor_$.find(".Rk-Editor-ColorPicker-Title"); |
|
4577 |
|
4578 this.editor_$.find(".Rk-Editor-p-title-color").hover( |
|
4579 function(_e) { |
|
4580 _e.preventDefault(); |
|
4581 _pickerTitle.show(); |
|
4582 }, |
|
4583 function(_e) { |
|
4584 _e.preventDefault(); |
|
4585 _pickerTitle.hide(); |
|
4586 } |
|
4587 ); |
|
4588 |
|
4589 _pickerTitle.find("li").hover( |
|
4590 function(_e) { |
|
4591 _e.preventDefault(); |
|
4592 _this.editor_$.find(".Rk-Editor-p-title-color .Rk-Edit-Color").css("background", $(this).attr("data-color")); |
|
4593 }, |
|
4594 function(_e) { |
|
4595 _e.preventDefault(); |
|
4596 var title_color = (_model.has("style") && _model.get("style").title_color) || _this.options.node_fill_color; |
|
4597 _this.editor_$.find(".Rk-Editor-p-title-color .Rk-Edit-Color").css("background", title_color); |
|
4598 } |
|
4599 ).click(function(_e) { |
|
4600 _e.preventDefault(); |
|
4601 if (_this.renderer.isEditable()) { |
|
4602 _model.set("style", _.assign( ((_model.has("style") && _.clone(_model.get("style"))) || {}), {title_color: $(this).attr("data-color")})); |
|
4603 _pickerTitle.hide(); |
|
4604 paper.view.draw(); |
|
4605 } else { |
|
4606 closeEditor(); |
|
4607 } |
|
4608 }); |
|
4609 |
|
4610 |
|
4611 this.editor_$.find("#Rk-Edit-Title-Size-Down").click(function() { |
|
4612 var step = _this.options.node_title_size_step; |
|
4613 shiftTitleSize(-step); |
|
4614 return false; |
|
4615 }); |
|
4616 this.editor_$.find("#Rk-Edit-Title-Size-Up").click(function() { |
|
4617 var step = _this.options.node_title_size_step; |
|
4618 shiftTitleSize(step); |
|
4619 return false; |
|
4620 }); |
|
4621 |
4485 this.editor_$.find(".Rk-Edit-Image-Del").click(function() { |
4622 this.editor_$.find(".Rk-Edit-Image-Del").click(function() { |
4486 _this.editor_$.find(".Rk-Edit-Image").val(''); |
4623 _this.editor_$.find(".Rk-Edit-Image").val(''); |
4487 onFieldChange(); |
4624 onFieldChange(); |
4488 return false; |
4625 return false; |
4489 }); |
4626 }); |
4501 }); |
4638 }); |
4502 }, |
4639 }, |
4503 redraw: function() { |
4640 redraw: function() { |
4504 if (this.options.popup_editor){ |
4641 if (this.options.popup_editor){ |
4505 var _coords = this.source_representation.paper_coords; |
4642 var _coords = this.source_representation.paper_coords; |
4506 Utils.drawEditBox(this.options, _coords, this.editor_block, this.source_representation.circle_radius * 0.75, this.editor_$); |
4643 Utils.drawEditBox(this.options, _coords, this.editor_block, this.source_representation.circle_radius * 0.75, this.editor_$, this.renderer.renkan); |
4507 } |
4644 } |
4508 this.editor_$.show(); |
4645 this.editor_$.show(); |
4509 paper.view.draw(); |
4646 paper.view.draw(); |
4510 }, |
4647 }, |
4511 destroy: function() { |
4648 destroy: function() { |
4701 } |
4838 } |
4702 }, |
4839 }, |
4703 redraw: function() { |
4840 redraw: function() { |
4704 if (this.options.popup_editor){ |
4841 if (this.options.popup_editor){ |
4705 var _coords = this.source_representation.paper_coords; |
4842 var _coords = this.source_representation.paper_coords; |
4706 Utils.drawEditBox(this.options, _coords, this.editor_block, 5, this.editor_$); |
4843 Utils.drawEditBox(this.options, _coords, this.editor_block, 5, this.editor_$, this.renderer.renkan); |
4707 } |
4844 } |
4708 this.editor_$.show(); |
4845 this.editor_$.show(); |
4709 paper.view.draw(); |
4846 paper.view.draw(); |
4710 } |
4847 } |
4711 }).value(); |
4848 }).value(); |
5355 } |
5492 } |
5356 }, |
5493 }, |
5357 touchend: function(_event) { |
5494 touchend: function(_event) { |
5358 _event.preventDefault(); |
5495 _event.preventDefault(); |
5359 _this.onMouseUp(_event.originalEvent.changedTouches[0], true); |
5496 _this.onMouseUp(_event.originalEvent.changedTouches[0], true); |
|
5497 }, |
|
5498 click: function(_event) { |
|
5499 _event.preventDefault(); |
|
5500 _this.onClick(_event); |
5360 }, |
5501 }, |
5361 dblclick: function(_event) { |
5502 dblclick: function(_event) { |
5362 _event.preventDefault(); |
5503 _event.preventDefault(); |
5363 if (_renkan.options.allow_double_click) { |
5504 if (_renkan.options.allow_double_click) { |
5364 _this.onDoubleClick(_event); |
5505 _this.onDoubleClick(_event); |
5632 }); |
5773 }); |
5633 } |
5774 } |
5634 |
5775 |
5635 if (_renkan.options.show_user_list && _renkan.options.user_color_editable) { |
5776 if (_renkan.options.show_user_list && _renkan.options.user_color_editable) { |
5636 var $cpwrapper = this.$.find(".Rk-Users .Rk-Edit-ColorPicker-Wrapper"), |
5777 var $cpwrapper = this.$.find(".Rk-Users .Rk-Edit-ColorPicker-Wrapper"), |
5637 $cplist = this.$.find(".Rk-Users .Rk-Edit-ColorPicker"); |
5778 $cplist = this.$.find(".Rk-Users .Rk-Editor-ColorPicker-User"); |
5638 |
5779 |
5639 $cpwrapper.hover( |
5780 $cpwrapper.hover( |
5640 function(_e) { |
5781 function(_e) { |
5641 if (_this.isEditable()) { |
5782 if (_this.isEditable()) { |
5642 _e.preventDefault(); |
5783 _e.preventDefault(); |
6198 this.view.setScale( this.view.scale * Math.SQRT1_2, this.view.offset.add(_delta.divide(Math.SQRT2))); |
6339 this.view.setScale( this.view.scale * Math.SQRT1_2, this.view.offset.add(_delta.divide(Math.SQRT2))); |
6199 } |
6340 } |
6200 this.totalScroll = 0; |
6341 this.totalScroll = 0; |
6201 } |
6342 } |
6202 }, |
6343 }, |
|
6344 onClick: function(_event) { |
|
6345 if (!this.isEditable()) { |
|
6346 var _off = this.canvas_$.offset(), |
|
6347 _point = new paper.Point([ |
|
6348 _event.pageX - _off.left, |
|
6349 _event.pageY - _off.top |
|
6350 ]); |
|
6351 var _hitResult = paper.project.hitTest(_point); |
|
6352 if(!this._open_uri_cb && |
|
6353 this.renkan.options.simple_click_open_url && |
|
6354 _hitResult && |
|
6355 typeof _hitResult.item.__representation !== "undefined" && |
|
6356 _hitResult.item.__representation.model.get('uri') && |
|
6357 !this._node_click_open_url |
|
6358 ) { |
|
6359 this._node_click_open_url = setTimeout(function() { |
|
6360 window.open(_hitResult.item.__representation.model.get('uri'), '_blank'); |
|
6361 this._node_click_open_url = null; |
|
6362 }.bind(this), 200); |
|
6363 } |
|
6364 } |
|
6365 }, |
6203 onDoubleClick: function(_event) { |
6366 onDoubleClick: function(_event) { |
6204 var _off = this.canvas_$.offset(), |
6367 var _off = this.canvas_$.offset(), |
6205 _point = new paper.Point([ |
6368 _point = new paper.Point([ |
6206 _event.pageX - _off.left, |
6369 _event.pageX - _off.left, |
6207 _event.pageY - _off.top |
6370 _event.pageY - _off.top |
6208 ]); |
6371 ]); |
6209 var _hitResult = paper.project.hitTest(_point); |
6372 var _hitResult = paper.project.hitTest(_point); |
6210 |
6373 |
6211 if (!this.isEditable()) { |
6374 if (!this.isEditable()) { |
6212 if (_hitResult && typeof _hitResult.item.__representation !== "undefined") { |
6375 if (this.renkan.options.double_click_open_url && |
6213 if (_hitResult.item.__representation.model.get('uri')){ |
6376 _hitResult && |
6214 window.open(_hitResult.item.__representation.model.get('uri'), '_blank'); |
6377 typeof _hitResult.item.__representation !== "undefined" && |
6215 } |
6378 _hitResult.item.__representation.model.get('uri') && |
|
6379 !this._node_click_open_url |
|
6380 ) { |
|
6381 window.open(_hitResult.item.__representation.model.get('uri'), '_blank'); |
6216 } |
6382 } |
6217 return; |
6383 return; |
6218 } |
6384 } |
6219 if (this.isEditable() && (!_hitResult || typeof _hitResult.item.__representation === "undefined")) { |
6385 if (this.isEditable() && (!_hitResult || typeof _hitResult.item.__representation === "undefined")) { |
6220 var _coords = this.toModelCoords(_point), |
6386 var _coords = this.toModelCoords(_point), |