Renkan bin configuration now with class names instead of classes themselves
authorveltr
Thu, 14 Mar 2013 11:29:33 +0100
changeset 78 af9e716b01bc
parent 77 4f2511a70880
child 79 f33771f3c510
Renkan bin configuration now with class names instead of classes themselves
client/css/renkan.css
client/js/ldtjson-bin.js
client/js/list-bin.js
client/js/main.js
client/render-test.html
--- a/client/css/renkan.css	Thu Mar 14 00:29:09 2013 +0100
+++ b/client/css/renkan.css	Thu Mar 14 11:29:33 2013 +0100
@@ -422,7 +422,7 @@
     background: -moz-linear-gradient(top, #505050 20%, #1e1e1e 80%);
     background: -webkit-linear-gradient(top, #505050 20%, #1e1e1e 80%);
     border-bottom: 1px solid #666666; font-weight: bold;
-    font-size: 14px; padding: 5px 5px 5px 30px; cursor: pointer; color: #f0f0f0;
+    font-size: 14px; padding: 5px; cursor: pointer; color: #f0f0f0;
 }
 
 .Rk-Bin-Close {
@@ -564,7 +564,7 @@
     margin-left: 54px;
 }
 
-.Rk-ListBin-Image {
+.Rk-ResourceList-Image {
 	float: left; max-width: 100px; max-height: 75px; margin-right: 2px;
 }
 
--- a/client/js/ldtjson-bin.js	Thu Mar 14 00:29:09 2013 +0100
+++ b/client/js/ldtjson-bin.js	Thu Mar 14 11:29:33 2013 +0100
@@ -1,5 +1,15 @@
 Rkns.Ldt = {}
 
+Rkns.Ldt.Bin = function(_renkan, _opts) {
+	if (_opts.ldt_type) {
+		var resclass = Rkns.Ldt[_opts.ldt_type+"Bin"];
+		if (resclass) {
+			return new resclass(_renkan, _opts);
+		}
+	}
+	console.error("No such LDT Bin Type");
+}
+
 Rkns.Ldt.ProjectBin = Rkns.Utils.inherit(Rkns._BaseBin);
 
 Rkns.Ldt.ProjectBin.prototype.tagTemplate = Rkns._.template(
@@ -13,6 +23,7 @@
 );
 
 Rkns.Ldt.ProjectBin.prototype._init = function(_renkan, _opts) {
+	console.log("Initializing Project Bin");
     this.renkan = _renkan;
     this.proj_id = _opts.project_id;
     this.ldt_platform = _opts.ldt_platform || "http://ldt.iri.centrepompidou.fr/";
--- a/client/js/list-bin.js	Thu Mar 14 00:29:09 2013 +0100
+++ b/client/js/list-bin.js	Thu Mar 14 11:29:33 2013 +0100
@@ -1,14 +1,16 @@
-Rkns.ListBin = Rkns.Utils.inherit(Rkns._BaseBin);
+Rkns.ResourceList = {};
+
+Rkns.ResourceList.Bin = Rkns.Utils.inherit(Rkns._BaseBin);
 
-Rkns.ListBin.prototype.resultTemplate = Rkns._.template(
-    '<li class="Rk-Bin-Item Rk-ListBin-Item" draggable="true" data-uri="<%-url%>" '
+Rkns.ResourceList.Bin.prototype.resultTemplate = Rkns._.template(
+    '<li class="Rk-Bin-Item Rk-ResourceList-Item" draggable="true" data-uri="<%-url%>" '
     + 'data-title="<%-title%>" data-description="<%-description%>" data-image="<%-image%>">'
-    + '<% if (image) { %><img class="Rk-ListBin-Image" src="<%-image%>"><% } %></div><h4 class="Rk-ListBin-Title">'
+    + '<% if (image) { %><img class="Rk-ResourceList-Image" src="<%-image%>"><% } %></div><h4 class="Rk-ResourceList-Title">'
     + '<% if (url) { %><a href="<%-url%>" target="_blank"><% } %><%=htitle%><% if (url) { %></a><% } %></h4>'
-    + '<% if (description) { %><p class="Rk-ListBin-Description"><%=hdescription%></p><% } %><% if (image) { %><div style="clear: both;"></div><% } %></li>'
+    + '<% if (description) { %><p class="Rk-ResourceList-Description"><%=hdescription%></p><% } %><% if (image) { %><div style="clear: both;"></div><% } %></li>'
 );
 
-Rkns.ListBin.prototype._init = function(_renkan, _opts) {
+Rkns.ResourceList.Bin.prototype._init = function(_renkan, _opts) {
 	this.renkan = _renkan;
     this.title_$.html(_opts.title);
     if (_opts.list) {
@@ -17,7 +19,7 @@
     this.refresh();
 }
 
-Rkns.ListBin.prototype.render = function(searchstr) {
+Rkns.ResourceList.Bin.prototype.render = function(searchstr) {
     if (searchstr) {
     	var _rgxp = new RegExp('('+(searchstr).replace(/(\W)/g,'\\$1')+')','gi'),
     		rxtest = new RegExp(searchstr.replace(/(\W)/g,'\\$1'),'i');
@@ -85,7 +87,7 @@
     this.renkan.resizeBins();
 }
     
-Rkns.ListBin.prototype.refresh = function() {
+Rkns.ResourceList.Bin.prototype.refresh = function() {
     if (this.data) {
     	this.render();
     }
--- a/client/js/main.js	Thu Mar 14 00:29:09 2013 +0100
+++ b/client/js/main.js	Thu Mar 14 11:29:33 2013 +0100
@@ -164,9 +164,12 @@
             _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);
+        	console.log(_search, Rkns[_search.type]);
+        	if (Rkns[_search.type] && Rkns[_search.type].Search) {
+        		_this.search_engines.push(new Rkns[_search.type].Search(_this, _search));
+        	}
         });
+        console.log(_this.search_engines);
         _select.html(
             Rkns._(this.search_engines).map(function(_search, _key) {
                 return _tmpl({
@@ -197,7 +200,9 @@
         this.setSearchEngine(0);
     }
     Rkns._(_opts.bins).each(function(_bin) {
-        _this.tabs.push(new _bin.bin(_this, _bin));
+    	if (Rkns[_bin.type] && Rkns[_bin.type].Bin) {
+    		_this.tabs.push(new Rkns[_bin.type].Bin(_this, _bin));
+    	}
     });
     
     this.$.find(".Rk-Bins")
--- a/client/render-test.html	Thu Mar 14 00:29:09 2013 +0100
+++ b/client/render-test.html	Thu Mar 14 11:29:33 2013 +0100
@@ -28,7 +28,14 @@
                     url: "data/simple-persist.php",
                     bins: [
                     	{
-                    		bin: Rkns.ListBin,
+                            title: "Projet Lignes de Temps",
+                            type: "Ldt",
+                            ldt_type: "Project",
+                            project_id: "6af4019c-8283-11e2-9678-00145ea4a2be",
+                            ldt_platform: "http://ldt.iri.centrepompidou.fr/"
+                       },
+                    	{
+                    		type: "ResourceList",
                     		title: "Ressources",
                     		list: [
                     			{
@@ -36,30 +43,22 @@
                     				title: "Google",
                     				description: "Search engine",
                     				image: "http://www.google.fr/images/srpr/logo4w.png"
-                    			}, {
-                    				url: "http://www.twitter.com/"
-                    			}
+                    			},
+                    			"Polemic Tweet http://www.polemictweet.com",
+                    			"Twitter http://www.twitter.com/"
                     		]
                     	}
                     ],
                     search: [
                         {
-                            type: Rkns.Ldt.Search
+                            type: "Ldt"
                         },
                         {
-                            type: Rkns.Wikipedia.Search,
+                            type: "Wikipedia",
                             lang: "fr"
                         }, 
                         {
-                            type: Rkns.Wikipedia.Search,
-                            lang: "en"
-                        }, 
-                        {
-                            type: Rkns.Wikipedia.Search,
-                            lang: "ja"
-                        },
-                        {
-                            type: Rkns.Twitter.Search
+                            type: "Twitter"
                         }
                     ],
                     property_files: [ "data/properties.json" ],