23 * knowledge of the CeCILL-C license and that you accept its terms. |
23 * knowledge of the CeCILL-C license and that you accept its terms. |
24 */ |
24 */ |
25 |
25 |
26 /* Declaring the Renkan Namespace Rkns and Default values */ |
26 /* Declaring the Renkan Namespace Rkns and Default values */ |
27 |
27 |
28 if (typeof Rkns !== "object") { |
28 (function(root) { |
29 Rkns = {}; |
29 |
|
30 "use strict"; |
|
31 |
|
32 if (typeof root.Rkns !== "object") { |
|
33 root.Rkns = {}; |
30 } |
34 } |
31 |
35 |
32 Rkns.$ = jQuery; |
36 var Rkns = root.Rkns; |
33 |
37 var $ = Rkns.$ = root.jQuery; |
34 Rkns._ = _; |
38 var _ = Rkns._ = root._; |
35 |
39 |
36 Rkns.VERSION = '0.2'; |
40 Rkns.VERSION = '0.2'; |
37 |
41 |
38 Rkns.pickerColors = ["#8f1919", "#a80000", "#d82626", "#ff0000", "#e87c7c", "#ff6565", "#f7d3d3", "#fecccc", |
42 Rkns.pickerColors = ["#8f1919", "#a80000", "#d82626", "#ff0000", "#e87c7c", "#ff6565", "#f7d3d3", "#fecccc", |
39 "#8f5419", "#a85400", "#d87f26", "#ff7f00", "#e8b27c", "#ffb265", "#f7e5d3", "#fee5cc", |
43 "#8f5419", "#a85400", "#d87f26", "#ff7f00", "#e8b27c", "#ffb265", "#f7e5d3", "#fee5cc", |
42 "#198f8f", "#00a8a8", "#26d8d8", "#00feff", "#7ce8e8", "#65feff", "#d3f7f7", "#ccfefe", |
46 "#198f8f", "#00a8a8", "#26d8d8", "#00feff", "#7ce8e8", "#65feff", "#d3f7f7", "#ccfefe", |
43 "#19198f", "#0000a8", "#2626d8", "#0000ff", "#7c7ce8", "#6565ff", "#d3d3f7", "#ccccfe", |
47 "#19198f", "#0000a8", "#2626d8", "#0000ff", "#7c7ce8", "#6565ff", "#d3d3f7", "#ccccfe", |
44 "#8f198f", "#a800a8", "#d826d8", "#ff00fe", "#e87ce8", "#ff65fe", "#f7d3f7", "#feccfe", |
48 "#8f198f", "#a800a8", "#d826d8", "#ff00fe", "#e87ce8", "#ff65fe", "#f7d3f7", "#feccfe", |
45 "#000000", "#242424", "#484848", "#6d6d6d", "#919191", "#b6b6b6", "#dadada", "#ffffff"]; |
49 "#000000", "#242424", "#484848", "#6d6d6d", "#919191", "#b6b6b6", "#dadada", "#ffffff"]; |
46 |
50 |
47 Rkns._BaseBin = function(_renkan, _opts) { |
51 Rkns.__renkans = []; |
|
52 |
|
53 var _BaseBin = Rkns._BaseBin = function(_renkan, _opts) { |
48 if (typeof _renkan !== "undefined") { |
54 if (typeof _renkan !== "undefined") { |
49 this.renkan = _renkan; |
55 this.renkan = _renkan; |
50 this.renkan.$.find(".Rk-Bin-Main").hide(); |
56 this.renkan.$.find(".Rk-Bin-Main").hide(); |
51 this.$ = Rkns.$('<li>') |
57 this.$ = Rkns.$('<li>') |
52 .addClass("Rk-Bin") |
58 .addClass("Rk-Bin") |
103 },_opts.auto_refresh); |
109 },_opts.auto_refresh); |
104 } |
110 } |
105 } |
111 } |
106 }; |
112 }; |
107 |
113 |
108 Rkns._BaseBin.prototype.destroy = function() { |
114 _BaseBin.prototype.destroy = function() { |
109 this.$.detach(); |
115 this.$.detach(); |
110 this.renkan.resizeBins(); |
116 this.renkan.resizeBins(); |
111 }; |
117 }; |
112 |
118 |
113 /* Point of entry */ |
119 /* Point of entry */ |
114 |
120 |
115 Rkns.Renkan = function(_opts) { |
121 var Renkan = Rkns.Renkan = function(_opts) { |
116 var _this = this; |
122 var _this = this; |
|
123 |
|
124 Rkns.__renkans.push(this); |
117 |
125 |
118 this.options = _.defaults(_opts, Rkns.defaults); |
126 this.options = _.defaults(_opts, Rkns.defaults); |
119 |
127 |
120 Rkns._(this.options.property_files).each(function(f) { |
128 Rkns._(this.options.property_files).each(function(f) { |
121 Rkns.$.getJSON(f, function(data) { |
129 Rkns.$.getJSON(f, function(data) { |
133 this.$ = Rkns.$("#" + this.options.container); |
141 this.$ = Rkns.$("#" + this.options.container); |
134 this.$ |
142 this.$ |
135 .addClass("Rk-Main") |
143 .addClass("Rk-Main") |
136 .html(this.template(this)); |
144 .html(this.template(this)); |
137 |
145 |
|
146 this.tabs = []; |
|
147 this.search_engines = []; |
|
148 |
|
149 this.current_user_list = new Rkns.Models.UsersList(); |
|
150 |
|
151 this.current_user_list.on("add remove", function() { |
|
152 if (this.renderer) { |
|
153 this.renderer.redrawUsers(); |
|
154 } |
|
155 }); |
|
156 |
|
157 this.colorPicker = (function() { |
|
158 var _tmpl = _.template('<li data-color="<%=c%>" style="background: <%=c%>"></li>'); |
|
159 return '<ul class="Rk-Edit-ColorPicker">' + Rkns.pickerColors.map(function(c) { return _tmpl({c:c})}).join("") + '</ul>' |
|
160 })(); |
|
161 |
138 if (this.options.show_editor) { |
162 if (this.options.show_editor) { |
139 this.renderer = new Rkns.Renderer.Scene(this); |
163 this.renderer = new Rkns.Renderer.Scene(this); |
140 } |
164 } |
141 |
|
142 this.tabs = []; |
|
143 this.search_engines = []; |
|
144 |
|
145 this.current_user_list = new Rkns.Models.UsersList(); |
|
146 |
165 |
147 if (!this.options.search.length) { |
166 if (!this.options.search.length) { |
148 this.$.find(".Rk-Web-Search-Form").detach(); |
167 this.$.find(".Rk-Web-Search-Form").detach(); |
149 } else { |
168 } else { |
150 var _tmpl = Rkns._.template('<li class="<%= className %>" data-key="<%= key %>"><%= title %></li>'), |
169 var _tmpl = Rkns._.template('<li class="<%= className %>" data-key="<%= key %>"><%= title %></li>'), |
269 }); |
288 }); |
270 }); |
289 }); |
271 this.$.find(".Rk-Bins-Search-Form").submit(function() { |
290 this.$.find(".Rk-Bins-Search-Form").submit(function() { |
272 return false; |
291 return false; |
273 }); |
292 }); |
274 }; |
293 |
275 |
294 }; |
276 Rkns.Renkan.prototype.template = Rkns._.template( |
295 |
|
296 Renkan.prototype.template = Rkns._.template( |
277 '<% if (options.show_bins) { %><div class="Rk-Bins"><div class="Rk-Bins-Head"><h2 class="Rk-Bins-Title"><%- translate("Select contents:")%></h2>' |
297 '<% if (options.show_bins) { %><div class="Rk-Bins"><div class="Rk-Bins-Head"><h2 class="Rk-Bins-Title"><%- translate("Select contents:")%></h2>' |
278 + '<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") %>" />' |
298 + '<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") %>" />' |
279 + '<div class="Rk-Search-Select"><div class="Rk-Search-Current"></div><ul class="Rk-Search-List"></ul></div>' |
299 + '<div class="Rk-Search-Select"><div class="Rk-Search-Current"></div><ul class="Rk-Search-List"></ul></div>' |
280 + '<input type="submit" value="" class="Rk-Web-Search-Submit Rk-Search-Submit" title="<%- translate("Search the Web") %>" /></form>' |
300 + '<input type="submit" value="" class="Rk-Web-Search-Submit Rk-Search-Submit" title="<%- translate("Search the Web") %>" /></form>' |
281 + '<form class="Rk-Bins-Search-Form Rk-Search-Form"><input class="Rk-Bins-Search-Input Rk-Search-Input" type="search" placeholder="<%- translate("Search in Bins") %>" />' |
301 + '<form class="Rk-Bins-Search-Form Rk-Search-Form"><input class="Rk-Bins-Search-Input Rk-Search-Input" type="search" placeholder="<%- translate("Search in Bins") %>" />' |
282 + '<input type="submit" value="" class="Rk-Bins-Search-Submit Rk-Search-Submit" title="<%- translate("Search in Bins") %>" /></form></div>' |
302 + '<input type="submit" value="" class="Rk-Bins-Search-Submit Rk-Search-Submit" title="<%- translate("Search in Bins") %>" /></form></div>' |
283 + '<ul class="Rk-Bin-List"></ul></div><% } %>' |
303 + '<ul class="Rk-Bin-List"></ul></div><% } %>' |
284 + '<% if (options.show_editor) { %><div class="Rk-Render Rk-Render-<% if (options.show_bins) { %>Panel<% } else { %>Full<% } %>"></div><% } %>' |
304 + '<% if (options.show_editor) { %><div class="Rk-Render Rk-Render-<% if (options.show_bins) { %>Panel<% } else { %>Full<% } %>"></div><% } %>' |
285 ); |
305 ); |
286 |
306 |
287 Rkns.Renkan.prototype.translate = function(_text) { |
307 Renkan.prototype.translate = function(_text) { |
288 if (Rkns.i18n[this.options.language] && Rkns.i18n[this.options.language][_text]) { |
308 if (Rkns.i18n[this.options.language] && Rkns.i18n[this.options.language][_text]) { |
289 return Rkns.i18n[this.options.language][_text]; |
309 return Rkns.i18n[this.options.language][_text]; |
290 } |
310 } |
291 if (this.options.language.length > 2 && Rkns.i18n[this.options.language.substr(0,2)] && Rkns.i18n[this.options.language.substr(0,2)][_text]) { |
311 if (this.options.language.length > 2 && Rkns.i18n[this.options.language.substr(0,2)] && Rkns.i18n[this.options.language.substr(0,2)][_text]) { |
292 return Rkns.i18n[this.options.language.substr(0,2)][_text]; |
312 return Rkns.i18n[this.options.language.substr(0,2)][_text]; |
293 } |
313 } |
294 return _text; |
314 return _text; |
295 }; |
315 }; |
296 |
316 |
297 Rkns.Renkan.prototype.onStatusChange = function() { |
317 Renkan.prototype.onStatusChange = function() { |
298 this.renderer.onStatusChange(); |
318 this.renderer.onStatusChange(); |
299 }; |
319 }; |
300 |
320 |
301 Rkns.Renkan.prototype.setSearchEngine = function(_key) { |
321 Renkan.prototype.setSearchEngine = function(_key) { |
302 this.search_engine = this.search_engines[_key]; |
322 this.search_engine = this.search_engines[_key]; |
303 this.$.find(".Rk-Search-Current").attr("class","Rk-Search-Current " + this.search_engine.getBgClass()); |
323 this.$.find(".Rk-Search-Current").attr("class","Rk-Search-Current " + this.search_engine.getBgClass()); |
304 }; |
324 }; |
305 |
325 |
306 Rkns.Renkan.prototype.resizeBins = function() { |
326 Renkan.prototype.resizeBins = function() { |
307 var _d = + this.$.find(".Rk-Bins-Head").outerHeight(); |
327 var _d = + this.$.find(".Rk-Bins-Head").outerHeight(); |
308 this.$.find(".Rk-Bin-Title:visible").each(function() { |
328 this.$.find(".Rk-Bin-Title:visible").each(function() { |
309 _d += Rkns.$(this).outerHeight(); |
329 _d += Rkns.$(this).outerHeight(); |
310 }); |
330 }); |
311 this.$.find(".Rk-Bin-Main").css({ |
331 this.$.find(".Rk-Bin-Main").css({ |