# HG changeset patch # User ymh # Date 1356957451 -3600 # Node ID d0da34fda4b4a959d88233bab69a8c044cecdc7a # Parent 01fb9167ad752d34ea360301e9b3cc68b688292c# Parent 869410bab434d795e30405f50f176a3aee14faad Merge with 869410bab434d795e30405f50f176a3aee14faad diff -r 01fb9167ad75 -r d0da34fda4b4 client/css/renkan.css --- a/client/css/renkan.css Mon Dec 31 12:19:10 2012 +0100 +++ b/client/css/renkan.css Mon Dec 31 13:37:31 2012 +0100 @@ -71,7 +71,7 @@ } .Rk-PadTitle { - float: left; font-size: 14px; height: 16px; margin: 4px 5px; width: 130px; background: #666666; padding: 4px; border: 1px solid #333333; + float: left; font-size: 14px; height: 16px; margin: 4px 5px; width: 200px; background: #666666; padding: 4px; border: 1px solid #333333; border-radius: 3px; box-shadow: 0 1px 0 #505050; color: #ffffff; font-weight: bold; } @@ -146,6 +146,22 @@ .Rk-AddEdge-Button:hover { background-position: -68px -35px; } + +.Rk-Save-Button { + width: 34px; background-position: -102px 0; +} + +.Rk-Save-Button.disabled { + opacity: .5; cursor: default; +} + +.Rk-Save-Button:hover { + background-position: -102px -35px; +} + +.Rk-Save-Button.disabled:hover { + opacity: 1; background-position: -102px 0; +} /* Canvas */ .Rk-Canvas { @@ -260,24 +276,36 @@ /* Bin Search Field */ .Rk-Search-Form { - padding: 10px; height: 27px; + padding: 5px 10px; height: 27px; background: #666666; background: -moz-linear-gradient(top, #606060 20%, #909090 80%); background: -webkit-linear-gradient(top, #606060 20%, #909090 80%); } .Rk-Search-Input, .Rk-Search-Select { - float: left; border-width: 1px; border-color: #003050; + float: left; margin: 0; } .Rk-Search-Input { - border-top-left-radius: 5px; border-bottom-left-radius: 5px; border-style: solid; - font-size: 13px; width: 190px; background: #ffffff; height: 15px; padding: 5px; + border-top-left-radius: 5px; border-bottom-left-radius: 5px; border: 1px solid #003050; + font-size: 13px; background: #ffffff; height: 25px; padding: 0 5px; line-height: 25px; + -webkit-appearance: none; + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; + box-sizing: content-box; +} + +.Rk-Web-Search-Input { + width: 190px; +} + +.Rk-Bins-Search-Input { + width: 235px; } .Rk-Search-Select { display: inline-block; position: relative; width: 45px; - border-style: solid none; cursor: pointer; + border-width: 1px; border-color: #003050; border-style: solid none; cursor: pointer; height: 25px; background: #ffffff url(../img/more.png) 30px 10px no-repeat; } @@ -348,6 +376,11 @@ background-position: -18px 0; } +.Rk-Bin-Count { + float: right; background: #c000a0; color: #FFFFFF; text-shadow: 1px 1px 1px #000000; display: none; + border-radius: 4px; padding: 1px 3px; font-size: 10px; font-weight: bold; margin-top: 4px; +} + .Rk-Bin-Title-Icon { float: left; width: 25px; margin: 2px; } diff -r 01fb9167ad75 -r d0da34fda4b4 client/img/topbarbuttons.png Binary file client/img/topbarbuttons.png has changed diff -r 01fb9167ad75 -r d0da34fda4b4 client/js/i18n.js --- a/client/js/i18n.js Mon Dec 31 12:19:10 2012 +0100 +++ b/client/js/i18n.js Mon Dec 31 13:37:31 2012 +0100 @@ -11,6 +11,7 @@ full_screen: "Full Screen", add_node: "Add Node", add_edge: "Add Edge", + save_project: "Archive Project", created_by: "Created by:", zoom_in: "Zoom In", zoom_out: "Zoom Out", @@ -39,6 +40,7 @@ full_screen: "Mode plein écran", add_node: "Ajouter un nœud", add_edge: "Ajouter un lien", + save_project: "Archiver le projet", created_by: "Créé par :", zoom_in: "Agrandir l’échelle", zoom_out: "Rapetisser l’échelle", diff -r 01fb9167ad75 -r d0da34fda4b4 client/js/ldtjson-bin.js --- a/client/js/ldtjson-bin.js Mon Dec 31 12:19:10 2012 +0100 +++ b/client/js/ldtjson-bin.js Mon Dec 31 13:37:31 2012 +0100 @@ -4,12 +4,12 @@ Rkns.Ldt.ProjectBin.prototype.tagTemplate = Rkns._.template( '
  • ' - + '

    <%-title%>

  • ' + + '

    <%=htitle%>

    ' ); Rkns.Ldt.ProjectBin.prototype.annotationTemplate = Rkns._.template( '
  • ' - + '

    <%-title%>

    <%-description%>

    Start: <%=start%>, End: <%=end%>, Duration: <%=duration%>

  • ' + + '

    <%=htitle%>

    <%=hdescription%>

    Start: <%=start%>, End: <%=end%>, Duration: <%=duration%>

    ' ); Rkns.Ldt.ProjectBin.prototype._init = function(_renkan, _opts) { @@ -19,8 +19,15 @@ this.refresh(); } -Rkns.Ldt.ProjectBin.prototype.refresh = function() { - var _this = this; +Rkns.Ldt.ProjectBin.prototype.render = function(searchstr) { + if (searchstr) { + var rxbase = searchstr.replace(/(\W)/g,'\\$1'), + _rgxp = new RegExp('('+rxbase+')','gi'), + rxtest = new RegExp(rxbase,'i') + } + function highlight(_text) { + return searchstr ? _text.replace(_rgxp, "$1") : _text; + } function convertTC(_ms) { function pad(_n) { var _res = _n.toString(); @@ -40,46 +47,76 @@ _res += pad(_minutes) + ':' + pad(_seconds); return _res; } + + var _html = '
  • Tags

  • ', + _projtitle = this.data.meta["dc:title"], + _this = this, + count = 0; + _this.title_$.text('LDT Project: "' + _projtitle + '"'); + Rkns._(_this.data.tags).map(function(_tag) { + var _title = _tag.meta["dc:title"]; + if (searchstr && !rxtest.test(_title)) { + return; + } + count++; + _html += _this.tagTemplate({ + ldt_platform: _this.ldt_platform, + title: _title, + htitle: highlight(_title), + encodedtitle : encodeURIComponent(_title) + }) + }); + _html += '
  • Annotations

  • '; + Rkns._(_this.data.annotations).map(function(_annotation) { + var _description = _annotation.content.description, + _title = _annotation.content.title.replace(_description,""); + if (searchstr && !rxtest.test(_title) && !rxtest.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 ? "img/ldt-segment.png" : "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 + }); + }); + + this.main_$.html(_html); + if (searchstr && count) { + this.count_$.text(count).show(); + } else { + this.count_$.hide(); + } + if (searchstr && !count) { + this.$.hide(); + } else { + this.$.show(); + } + _renkan.resizeBins(); +} + +Rkns.Ldt.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) { - var _html = '
  • Tags

  • ', - _projtitle = _data.meta["dc:title"]; - _this.title_$.html('LDT Project: "' + _projtitle + '"'); - _html += Rkns._(_data.tags).map(function(_tag) { - var _title = _tag.meta["dc:title"] - return _this.tagTemplate({ - ldt_platform: _this.ldt_platform, - title: _title, - encodedtitle : encodeURIComponent(_title) - }) - }).join(""); - _html += '
  • Annotations

  • '; - _html += Rkns._(_data.annotations).map(function(_annotation) { - var _description = _annotation.content.description, - _title = _annotation.content.title.replace(_description,""), - _duration = _annotation.end - _annotation.begin, - _img = ( - (_annotation.content && _annotation.content.img && _annotation.content.img.src) - ? _annotation.content.img.src - : ( _duration ? "img/ldt-segment.png" : "img/ldt-point.png" ) - ); - return _this.annotationTemplate({ - ldt_platform: _this.ldt_platform, - title: _title, - description: _description, - start: convertTC(_annotation.begin), - end: convertTC(_annotation.end), - duration: convertTC(_duration), - mediaid: _annotation.media, - annotationid: _annotation.id, - image: _img - }); - }).join(""); - - _this.main_$.html(_html); - _renkan.resizeBins(); + _this.data = _data; + _this.render(); } }); } \ No newline at end of file diff -r 01fb9167ad75 -r d0da34fda4b4 client/js/main.js --- a/client/js/main.js Mon Dec 31 12:19:10 2012 +0100 +++ b/client/js/main.js Mon Dec 31 13:37:31 2012 +0100 @@ -56,6 +56,9 @@ _this.refresh(); return false; }); + this.count_$ = Rkns.$('
    ') + .addClass("Rk-Bin-Count") + .appendTo(this.$); this.title_$ = Rkns.$('

    ') .addClass("Rk-Bin-Title") .appendTo(this.$); @@ -110,12 +113,12 @@ _this.$.find(".Rk-Bin-Item.dragging").removeClass("dragging"); }); if (!_opts.search.length) { - this.$.find(".Rk-Search-Form").detach(); + this.$.find(".Rk-Web-Search-Form").detach(); } else { var _tmpl = Rkns._.template('
  • <%= title %>
  • '), _select = this.$.find(".Rk-Search-List"), - _input = this.$.find(".Rk-Search-Input") - _form = this.$.find(".Rk-Search-Form"); + _input = this.$.find(".Rk-Web-Search-Input") + _form = this.$.find(".Rk-Web-Search-Form"); Rkns._(_opts.search).each(function(_search, _key) { var _searchObj = new _search.type(_this, _search); _this.search_engines.push(_searchObj); @@ -186,13 +189,25 @@ Rkns.$(window).resize(function() { _this.resizeBins(); }); + + this.$.find(".Rk-Bins-Search-Input").on("change keyup paste input", function() { + var val = Rkns.$(this).val(); + Rkns._(_this.tabs).each(function(tab) { + tab.render(val); + }); + }); + this.$.find(".Rk-Bins-Search-Form").submit(function() { + return false + }); } Rkns.Renkan.prototype.template = Rkns._.template( '

    Hyper Plateau

    ' - + '
    ' + + '' + '
      ' - + '
      ' + + '' + + '
      ' + + '
      ' + '
        ' ); @@ -203,8 +218,8 @@ } Rkns.Renkan.prototype.resizeBins = function() { - var _d = + this.$.find(".Rk-Search-Form").outerHeight(); - this.$.find(".Rk-Bin-Title").each(function() { + var _d = + this.$.find(".Rk-Web-Search-Form").outerHeight() + this.$.find(".Rk-Bins-Search-Form").outerHeight(); + this.$.find(".Rk-Bin-Title:visible").each(function() { _d += Rkns.$(this).outerHeight(); }); this.$.find(".Rk-Bin-Main").css({ diff -r 01fb9167ad75 -r d0da34fda4b4 client/js/paper-renderer.js --- a/client/js/paper-renderer.js Mon Dec 31 12:19:10 2012 +0100 +++ b/client/js/paper-renderer.js Mon Dec 31 13:37:31 2012 +0100 @@ -939,9 +939,7 @@ this.renkan = _renkan; this.$ = Rkns.$(".Rk-Render"); this.representations = []; - this.$.html(this.template({ - l10n: _renkan.l10n - })) + this.$.html(this.template(_renkan)); this.canvas_$ = this.$.find(".Rk-Canvas"); this.editor_$ = this.$.find(".Rk-Editor"); this.notif_$ = this.$.find(".Rk-Notifications"); @@ -1058,9 +1056,17 @@ 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()}); + }) + this.renkan.project.get("users").each(function(_user) { _this.addUser(_user); - }) + }); this.renkan.project.on("add:users", function(_user) { _this.addUser(_user); @@ -1078,11 +1084,12 @@ } Rkns.Renderer.Scene.prototype.template = Rkns._.template( - '

        <%=l10n.untitled_project%>

        ' + '
        " placeholder="<%=l10n.untitled_project%>" />' + '
        <unknown user>
          ' + '
          <%=l10n.full_screen%>
          ' + '
          <%=l10n.add_node%>
          ' + '
          <%=l10n.add_edge%>
          ' + + '
          <%=l10n.save_project%>
          ' + '
          ' + '
          ' + '
          ' @@ -1132,7 +1139,7 @@ this.setScale(_scale); } if (nodes.length === 1) { - this.offset = paper.view.center.subtract(new paper.Point([nodes[0].get("position").x, nodes[0].get("position").y])); + this.offset = paper.view.center.subtract(new paper.Point([nodes.at(0).get("position").x, nodes.at(0).get("position").y])); this.setScale(1); } } diff -r 01fb9167ad75 -r d0da34fda4b4 client/js/renkan-publish.js --- a/client/js/renkan-publish.js Mon Dec 31 12:19:10 2012 +0100 +++ b/client/js/renkan-publish.js Mon Dec 31 13:37:31 2012 +0100 @@ -905,9 +905,10 @@ } Rkns.Renderer.Scene.prototype.autoScale = function() { - if (this.project.get("nodes").length) { - var _xx = this.project.get("nodes").map(function(_node) { return _node.get("position").x }), - _yy = this.project.get("nodes").map(function(_node) { return _node.get("position").y }), + var nodes = this.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), @@ -916,6 +917,11 @@ this.offset = paper.view.center.subtract(new paper.Point([(_maxx + _minx) / 2, (_maxy + _miny) / 2]).multiply(this.scale)); this.redraw(); } + if (nodes.length === 1) { + this.scale = 1; + this.offset = paper.view.center.subtract(new paper.Point([nodes.at(0).get("position").x, nodes.at(0).get("position").y])); + this.redraw(); + } } Rkns.Renderer.Scene.prototype.toPaperCoords = function(_point) { diff -r 01fb9167ad75 -r d0da34fda4b4 client/js/twitter-bin.js --- a/client/js/twitter-bin.js Mon Dec 31 12:19:10 2012 +0100 +++ b/client/js/twitter-bin.js Mon Dec 31 13:37:31 2012 +0100 @@ -44,81 +44,110 @@ this.refresh(); } +Rkns.Twitter.Bin.prototype.render = function(searchstr) { + var _rgxp = new RegExp('('+(searchstr || this.search).replace(/(\W)/g,'\\$1')+')','gi'); + if (searchstr) { + var rxtest = new RegExp(searchstr.replace(/(\W)/g,'\\$1'),'i'); + } + function highlight(_text) { + return _text.replace(_rgxp, "$1"); + } + var _html = "" + _this = this, + count = 0; + Rkns._(this.data.results).each(function(_result) { + if (searchstr && !rxtest.test(_result.text)) { + return; + } + count++; + var _entities = [], + _users = _result.text.match(/@[\w_]+/gm), + _lastpos = 0; + if (_users) { + for (var _i = 0; _i < _users.length; _i++) { + var _m = _users[_i], + _start = _lastpos + _result.text.substr(_lastpos).search(_m), + _lastpos = _start + _m.length; + _entities.push({ + "text" : _m, + "start" : _start, + "end" : _lastpos, + "link" :'', + }); + } + } + var _hashes = _result.text.match(/([^&]|^)#[^\s,.!?=#@&;()]+/gm), + _lastpos = 0; + if (_hashes) { + for (var _i = 0; _i < _hashes.length; _i++) { + var _m = _hashes[_i], + _h = ( _m[0] == '#' ? _m : _m.substr(1) ), + _start = _lastpos + _result.text.substr(_lastpos).search(_h), + _lastpos = _start + _h.length; + _entities.push({ + "text" : _h, + "start" : _start, + "end" : _lastpos, + "link" :'', + }); + } + } + + var _urls = _result.text.match(/(www\.|https?:\/\/)[\w./_\-]+/gim), + _lastpos = 0; + if (_urls) { + for (var _i = 0; _i < _urls.length; _i++) { + var _m = _urls[_i], + _start = _lastpos + _result.text.substr(_lastpos).search(_m), + _lastpos = _start + _m.length; + _entities.push({ + "text" : _m, + "start" : _start, + "end" : _lastpos, + "link" :'', + }); + } + } + _entities = Rkns._(_entities).sortBy(function(a) { return a.start }); + var _lastend = 0, + _text = Rkns._(_entities).map(function(_e) { + var _txt = highlight(_result.text.substring(_lastend, _e.start)) + _e.link + highlight(_e.text) + ''; + _lastend = _e.end; + return _txt; + }).join("") + highlight(_result.text.substring(_lastend)); + + _html += _this.tweetTemplate({ + tweet: _result, + date: new Date(_result.created_at.replace(/(\+|-)/,'UTC$1')).toLocaleString(), + text: _text + }); + }); + this.main_$.html(_html); + if (searchstr && count) { + this.count_$.text(count).show(); + } else { + this.count_$.hide(); + } + if (searchstr && !count) { + this.$.hide(); + } else { + this.$.show(); + } + _renkan.resizeBins(); +} + Rkns.Twitter.Bin.prototype.refresh = function() { var _this = this; Rkns.$.ajax({ - url: "http://search.twitter.com/search.json?q=" + encodeURIComponent(this.search), + url: "http://search.twitter.com/search.json", dataType: "jsonp", + data: { + q: this.search, + rpp: 100 + }, success: function(_data) { - var _rgxp = new RegExp('('+_this.search.replace(/(\W)/g,'\\$1')+')','gi'); - function highlight(_text) { - return _text.replace(_rgxp, "$1"); - } - var _html = Rkns._(_data.results).map(function(_result) { - var _entities = [], - _users = _result.text.match(/@[\w_]+/gm), - _lastpos = 0; - if (_users) { - for (var _i = 0; _i < _users.length; _i++) { - var _m = _users[_i], - _start = _lastpos + _result.text.substr(_lastpos).search(_m), - _lastpos = _start + _m.length; - _entities.push({ - "text" : _m, - "start" : _start, - "end" : _lastpos, - "link" :'', - }); - } - } - var _hashes = _result.text.match(/([^&]|^)#[^\s,.!?=#@&;()]+/gm), - _lastpos = 0; - if (_hashes) { - for (var _i = 0; _i < _hashes.length; _i++) { - var _m = _hashes[_i], - _h = ( _m[0] == '#' ? _m : _m.substr(1) ), - _start = _lastpos + _result.text.substr(_lastpos).search(_h), - _lastpos = _start + _h.length; - _entities.push({ - "text" : _h, - "start" : _start, - "end" : _lastpos, - "link" :'', - }); - } - } - - var _urls = _result.text.match(/(www\.|https?:\/\/)[\w./_\-]+/gim), - _lastpos = 0; - if (_urls) { - for (var _i = 0; _i < _urls.length; _i++) { - var _m = _urls[_i], - _start = _lastpos + _result.text.substr(_lastpos).search(_m), - _lastpos = _start + _m.length; - _entities.push({ - "text" : _m, - "start" : _start, - "end" : _lastpos, - "link" :'', - }); - } - } - _entities = Rkns._(_entities).sortBy(function(a) { return a.start }); - var _lastend = 0, - _text = Rkns._(_entities).map(function(_e) { - var _txt = highlight(_result.text.substring(_lastend, _e.start)) + _e.link + highlight(_e.text) + ''; - _lastend = _e.end; - return _txt; - }).join("") + highlight(_result.text.substring(_lastend)); - - return _this.tweetTemplate({ - tweet: _result, - date: new Date(_result.created_at.replace(/(\+|-)/,'UTC$1')).toLocaleString(), - text: _text - }); - }).join(""); - _this.main_$.html(_html); - _renkan.resizeBins(); + _this.data = _data; + _this.render(); } }); } diff -r 01fb9167ad75 -r d0da34fda4b4 client/js/wikipedia-bin.js --- a/client/js/wikipedia-bin.js Mon Dec 31 12:19:10 2012 +0100 +++ b/client/js/wikipedia-bin.js Mon Dec 31 13:37:31 2012 +0100 @@ -26,10 +26,10 @@ Rkns.Wikipedia.Bin = Rkns.Utils.inherit(Rkns._BaseBin); Rkns.Wikipedia.Bin.prototype.resultTemplate = Rkns._.template( - '
        • ' - + '
        • <%=highlightedtitle%>

          ' - + '

          <%=result.snippet%>

          ' + '
        • ' + + '
        • <%=htitle%>

          ' + + '

          <%=hdescription%>

          ' ); Rkns.Wikipedia.Bin.prototype._init = function(_renkan, _opts) { @@ -40,23 +40,54 @@ this.refresh(); } +Rkns.Wikipedia.Bin.prototype.render = function(searchstr) { + var _rgxp = new RegExp('('+(searchstr || this.search).replace(/(\W)/g,'\\$1')+')','gi'); + if (searchstr) { + var rxtest = new RegExp(searchstr.replace(/(\W)/g,'\\$1'),'i'); + } + function highlight(_text) { + return _text.replace(_rgxp, "$1"); + } + var _html = "", + _this = this; + 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.$('
          ').html(_result.snippet).text(); + if (searchstr && !rxtest.test(title) && !rxtest.test(description)) { + return; + } + count++; + _html += _this.resultTemplate({ + url: url, + title: title, + htitle: highlight(title), + description: description, + hdescription: highlight(description) + }); + }); + _this.main_$.html(_html); + if (searchstr && count) { + this.count_$.text(count).show(); + } else { + this.count_$.hide(); + } + if (searchstr && !count) { + this.$.hide(); + } else { + this.$.show(); + } + _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) { - var _rgxp = new RegExp('('+_this.search.replace(/(\W)/g,'\\$1')+')','gi'), - _html = Rkns._(_data.query.search).map(function(_result) { - return _this.resultTemplate({ - result: _result, - wpurl: "http://" + _this.lang + ".wikipedia.org/wiki/" + encodeURI(_result.title.replace(/ /g,"_")), - highlightedtitle: _result.title.replace(_rgxp, "$1"), - wpdesc: Rkns.$('
          ').html(_result.snippet).text() - }); - }).join(""); - _this.main_$.html(_html); - _renkan.resizeBins(); + _this.data = _data; + _this.render(); } }); } \ No newline at end of file