diff -r 01f66ed90e32 -r 87569ad0ff53 server/src/main/webapp/static/js/main.js --- a/server/src/main/webapp/static/js/main.js Wed Feb 13 13:41:19 2013 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,278 +0,0 @@ -/* - * Copyright 2012 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. -*/ - -/* Declaring the Renkan Namespace Rkns and Default values */ - -if (typeof Rkns !== "object") { - Rkns = {} -} - -Rkns.$ = jQuery; - -Rkns._ = _; - -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._BaseBin = function(_renkan, _opts) { - if (typeof _renkan !== "undefined") { - this.renkan = _renkan; - this.renkan.$.find(".Rk-Bin-Main").hide(); - this.$ = Rkns.$('
  • ') - .addClass("Rk-Bin") - .appendTo(_renkan.$.find(".Rk-Bin-List")); - this.title_icon_$ = Rkns.$('') - .addClass("Rk-Bin-Title-Icon") - .appendTo(this.$); - - var _this = this; - - Rkns.$('') - .attr("href","#") - .addClass("Rk-Bin-Close") - .html('×') - .appendTo(this.$) - .click(function() { - _this.destroy(); - return false; - }); - Rkns.$('') - .attr("href","#") - .addClass("Rk-Bin-Refresh") - .appendTo(this.$) - .click(function() { - _this.refresh(); - return false; - }); - this.count_$ = Rkns.$('
    ') - .addClass("Rk-Bin-Count") - .appendTo(this.$); - this.title_$ = Rkns.$('

    ') - .addClass("Rk-Bin-Title") - .appendTo(this.$); - this.main_$ = Rkns.$('
    ') - .addClass("Rk-Bin-Main") - .appendTo(this.$); - this.title_$.html(_opts.title || '(new bin)'); - this.renkan.resizeBins(); - - if (_opts.auto_refresh) { - window.setInterval(function() { - _this.refresh(); - },_opts.auto_refresh) - } - } -} - -Rkns._BaseBin.prototype.destroy = function() { - this.$.detach(); - this.renkan.resizeBins(); -} - -/* Point of entry */ - -Rkns.Renkan = function(_opts) { - if (typeof _opts.language !== "string" || typeof Rkns.i18n[_opts.language] == "undefined") { - _opts.language = "en"; - } - if (typeof _opts.container !== "string") { - _opts.container = "renkan"; - } - if (typeof _opts.search !== "object" || !_opts.search) { - _opts.search = []; - } - if (typeof _opts.static_url !== "string") { - _opts.static_url = ""; - } - this.project = new Rkns.Models.Project(); - this.language = _opts.language; - this.static_url = _opts.static_url; - this.l10n = Rkns.i18n[_opts.language]; - if (typeof _opts.user_id !== "undefined") { - this.current_user = _opts.user_id; - } - this.$ = Rkns.$("#" + _opts.container); - this.$ - .addClass("Rk-Main") - .html(this.template()); - this.renderer = new Rkns.Renderer.Scene(this); - this.tabs = []; - this.search_engines = []; - this.selected_bin_item = undefined; - - this.current_user_list = new Rkns.Models.UsersList(); - - var _this = this; - this.$.mouseup(function() { - _this.selected_bin_item = undefined; - _this.$.find(".Rk-Bin-Item.dragging").removeClass("dragging"); - }); - if (!_opts.search.length) { - this.$.find(".Rk-Web-Search-Form").detach(); - } else { - var _tmpl = Rkns._.template('
  • <%= title %>
  • '), - _select = this.$.find(".Rk-Search-List"), - _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); - }); - _select.html( - Rkns._(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.slideUp(); } - ); - this.setSearchEngine(0); - } - Rkns._(_opts.bins).each(function(_bin) { - _this.tabs.push(new _bin.bin(_this, _bin)); - }); - - 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(); - } - }).on("mousedown", ".Rk-Bin-Item", function() { - var _t = Rkns.$(this); - _t.addClass("dragging"); - _this.selected_bin_item = { - uri : $(_t).attr("data-uri"), - title : $(_t).attr("data-title"), - description : $(_t).attr("data-description"), - image: $(_t).attr("data-image") - } - return false; - }).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") - }); - Rkns._(_models).each(function(_model) { - _this.renderer.highlightModel(_model); - }); - } - }).mouseout(function() { - _this.renderer.unhighlightAll(); - }); - 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

    ' - + '
    ' - + '
      ' - + '
      ' - + '
      ' - + '
      ' - + '
        ' -); - - -Rkns.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()); -} - -Rkns.Renkan.prototype.resizeBins = 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({ - height: this.$.find(".Rk-Bins").height() - _d - }); -} - -/* Utility functions */ - -Rkns.Utils = { - _ID_AUTO_INCREMENT : 0, - _ID_BASE : (function(_d) { - function pad(n){return n<10 ? '0'+n : n} - function fillrand(n) { - var _res = '' - for (var i=0; i