')
+ .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;
+ 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-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");
+ 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();
+ });
+}
+
+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-Search-Form").outerHeight();
+ this.$.find(".Rk-Bin-Title").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