--- a/client/js/main.js Fri Jun 14 12:36:32 2013 +0200
+++ b/client/js/main.js Wed Jul 03 13:42:59 2013 +0200
@@ -25,13 +25,17 @@
/* Declaring the Renkan Namespace Rkns and Default values */
-if (typeof Rkns !== "object") {
- Rkns = {};
+(function(root) {
+
+"use strict";
+
+if (typeof root.Rkns !== "object") {
+ root.Rkns = {};
}
-Rkns.$ = jQuery;
-
-Rkns._ = _;
+var Rkns = root.Rkns;
+var $ = Rkns.$ = root.jQuery;
+var _ = Rkns._ = root._;
Rkns.VERSION = '0.2';
@@ -44,7 +48,9 @@
"#8f198f", "#a800a8", "#d826d8", "#ff00fe", "#e87ce8", "#ff65fe", "#f7d3f7", "#feccfe",
"#000000", "#242424", "#484848", "#6d6d6d", "#919191", "#b6b6b6", "#dadada", "#ffffff"];
-Rkns._BaseBin = function(_renkan, _opts) {
+Rkns.__renkans = [];
+
+var _BaseBin = Rkns._BaseBin = function(_renkan, _opts) {
if (typeof _renkan !== "undefined") {
this.renkan = _renkan;
this.renkan.$.find(".Rk-Bin-Main").hide();
@@ -105,16 +111,18 @@
}
};
-Rkns._BaseBin.prototype.destroy = function() {
+_BaseBin.prototype.destroy = function() {
this.$.detach();
this.renkan.resizeBins();
};
/* Point of entry */
-Rkns.Renkan = function(_opts) {
+var Renkan = Rkns.Renkan = function(_opts) {
var _this = this;
+ Rkns.__renkans.push(this);
+
this.options = _.defaults(_opts, Rkns.defaults);
Rkns._(this.options.property_files).each(function(f) {
@@ -135,15 +143,26 @@
.addClass("Rk-Main")
.html(this.template(this));
- if (this.options.show_editor) {
- this.renderer = new Rkns.Renderer.Scene(this);
- }
-
this.tabs = [];
this.search_engines = [];
this.current_user_list = new Rkns.Models.UsersList();
+ this.current_user_list.on("add remove", function() {
+ if (this.renderer) {
+ this.renderer.redrawUsers();
+ }
+ });
+
+ this.colorPicker = (function() {
+ var _tmpl = _.template('<li data-color="<%=c%>" style="background: <%=c%>"></li>');
+ return '<ul class="Rk-Edit-ColorPicker">' + Rkns.pickerColors.map(function(c) { return _tmpl({c:c})}).join("") + '</ul>'
+ })();
+
+ if (this.options.show_editor) {
+ this.renderer = new Rkns.Renderer.Scene(this);
+ }
+
if (!this.options.search.length) {
this.$.find(".Rk-Web-Search-Form").detach();
} else {
@@ -271,9 +290,10 @@
this.$.find(".Rk-Bins-Search-Form").submit(function() {
return false;
});
+
};
-Rkns.Renkan.prototype.template = Rkns._.template(
+Renkan.prototype.template = Rkns._.template(
'<% if (options.show_bins) { %><div class="Rk-Bins"><div class="Rk-Bins-Head"><h2 class="Rk-Bins-Title"><%- translate("Select contents:")%></h2>'
+ '<form class="Rk-Web-Search-Form Rk-Search-Form"><input class="Rk-Web-Search-Input Rk-Search-Input" type="search" placeholder="<%- translate("Search the Web") %>" />'
+ '<div class="Rk-Search-Select"><div class="Rk-Search-Current"></div><ul class="Rk-Search-List"></ul></div>'
@@ -284,7 +304,7 @@
+ '<% if (options.show_editor) { %><div class="Rk-Render Rk-Render-<% if (options.show_bins) { %>Panel<% } else { %>Full<% } %>"></div><% } %>'
);
-Rkns.Renkan.prototype.translate = function(_text) {
+Renkan.prototype.translate = function(_text) {
if (Rkns.i18n[this.options.language] && Rkns.i18n[this.options.language][_text]) {
return Rkns.i18n[this.options.language][_text];
}
@@ -294,16 +314,16 @@
return _text;
};
-Rkns.Renkan.prototype.onStatusChange = function() {
+Renkan.prototype.onStatusChange = function() {
this.renderer.onStatusChange();
};
-Rkns.Renkan.prototype.setSearchEngine = function(_key) {
+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() {
+Renkan.prototype.resizeBins = function() {
var _d = + this.$.find(".Rk-Bins-Head").outerHeight();
this.$.find(".Rk-Bin-Title:visible").each(function() {
_d += Rkns.$(this).outerHeight();
@@ -375,5 +395,6 @@
}
};
+})(window);
/* END main.js */