client/js/main.js
changeset 62 f9019462465a
parent 56 a9b9e6c7be63
child 64 3a5a9421687b
--- a/client/js/main.js	Thu Feb 14 12:25:58 2013 +0100
+++ b/client/js/main.js	Thu Feb 14 17:39:52 2013 +0100
@@ -95,12 +95,22 @@
     if (typeof _opts.search !== "object" || !_opts.search) {
         _opts.search = [];
     }
+    if (typeof _opts.bins !== "object" || !_opts.bins) {
+        _opts.bins = [];
+    }
     if (typeof _opts.static_url !== "string") {
         _opts.static_url = "";
     }
+    if (typeof _opts.show_bins !== "boolean") {
+        _opts.show_bins = !!_opts.search.length || !!_opts.bins.length;
+    }
+    if (typeof _opts.read_only !== "boolean") {
+        _opts.read_only = false;
+    }
     this.project = new Rkns.Models.Project();
     this.language = _opts.language;
     this.static_url = _opts.static_url;
+    this.read_only = _opts.read_only;
     this.l10n = Rkns.i18n[_opts.language];
     if (typeof _opts.user_id !== "undefined") {
         this.current_user = _opts.user_id;
@@ -108,7 +118,7 @@
     this.$ = Rkns.$("#" + _opts.container);
     this.$
         .addClass("Rk-Main")
-        .html(this.template());
+        .html(this.template(_opts));
     this.renderer = new Rkns.Renderer.Scene(this);
     this.tabs = [];
     this.search_engines = [];
@@ -173,6 +183,9 @@
                 _mainDiv.slideDown();
             }
         }).on("mousedown", ".Rk-Bin-Item", function() {
+            if (_this.read_only) {
+                return false;
+            }
             var _t = Rkns.$(this);
             _t.addClass("dragging");
             _this.selected_bin_item = {
@@ -211,13 +224,13 @@
 }
 
 Rkns.Renkan.prototype.template = Rkns._.template(
-    '<div class="Rk-Title"><h1>Hyper Plateau</h1></div><div class="Rk-Bins">'
+    '<% if (show_bins) { %><div class="Rk-Title"><h1>Hyper Plateau</h1></div><div class="Rk-Bins">'
     + '<form class="Rk-Web-Search-Form Rk-Search-Form"><input class="Rk-Web-Search-Input Rk-Search-Input" type="search" placeholder="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" /></form>'
     + '<form class="Rk-Bins-Search-Form Rk-Search-Form"><input class="Rk-Bins-Search-Input Rk-Search-Input" type="search" placeholder="Search in Bins" />'
     + '<input type="submit" value="" class="Rk-Bins-Search-Submit Rk-Search-Submit" /></form>'
-    + '<ul class="Rk-Bin-List"></ul></div><div class="Rk-Render Rk-Render-Panel"></div>'
+    + '<ul class="Rk-Bin-List"></ul></div><% } %><div class="Rk-Render Rk-Render-<% if (show_bins) { %>Panel<% } else { %>Full<% } %>"></div>'
 );