--- a/client/js/main.js Tue Mar 26 16:14:19 2013 +0100
+++ b/client/js/main.js Tue Mar 26 19:12:05 2013 +0100
@@ -98,53 +98,25 @@
Rkns.Renkan = function(_opts) {
var _this = this;
- if (typeof _opts.language !== "string" || typeof Rkns.i18n[_opts.language] == "undefined") {
- _opts.language = (navigator.language || navigator.userLanguage || "en");
- }
- if (typeof _opts.container !== "string") {
- _opts.container = "renkan";
- }
- 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.properties !== "object") {
- _opts.properties = [];
- }
- if (typeof _opts.property_files === "object") {
- Rkns._(_opts.property_files).each(function(f) {
- Rkns.$.getJSON(f, function(data) {
- _this.properties = _this.properties.concat(data);
- });
- });
- }
- if (typeof _opts.clip_images === "undefined") {
- _opts.clip_images = true;
- }
+ this.options = _.defaults(_opts, Rkns.defaults);
+
+ Rkns._(this.options.property_files).each(function(f) {
+ Rkns.$.getJSON(f, function(data) {
+ _this.options.properties = _this.options.properties.concat(data);
+ });
+ });
+
+ this.read_only = this.options.read_only || !this.options.editor_mode;
+
this.project = new Rkns.Models.Project();
- this.language = _opts.language;
- this.static_url = _opts.static_url;
- this.show_bins = _opts.show_bins;
- this.properties = _opts.properties;
- this.clip_images = _opts.clip_images;
- this.read_only = _opts.read_only || false;
- this.snapshot_mode = _opts.snapshot_mode || false;
this.translate = function(_text) {
- return (Rkns.i18n[_opts.language] || Rkns.i18n[_opts.language.substr(0,2)] || {})[_text] || _text;
+ return (Rkns.i18n[_this.options.language] || Rkns.i18n[_this.options.language.substr(0,2)] || {})[_text] || _text;
}
- if (typeof _opts.user_id !== "undefined") {
- this.current_user = _opts.user_id;
+ if (typeof this.options.user_id !== "undefined") {
+ this.current_user = this.options.user_id;
}
- this.$ = Rkns.$("#" + _opts.container);
+ this.$ = Rkns.$("#" + this.options.container);
this.$
.addClass("Rk-Main")
.html(this.template(this));
@@ -154,14 +126,14 @@
this.current_user_list = new Rkns.Models.UsersList();
- if (!_opts.search.length) {
+ if (!this.options.search.length) {
this.$.find(".Rk-Web-Search-Form").detach();
} else {
var _tmpl = Rkns._.template('<li class="<%= className %>" data-key="<%= key %>"><%= title %></li>'),
_select = this.$.find(".Rk-Search-List"),
_input = this.$.find(".Rk-Web-Search-Input")
_form = this.$.find(".Rk-Web-Search-Form");
- Rkns._(_opts.search).each(function(_search, _key) {
+ Rkns._(this.options.search).each(function(_search, _key) {
if (Rkns[_search.type] && Rkns[_search.type].Search) {
_this.search_engines.push(new Rkns[_search.type].Search(_this, _search));
}
@@ -195,7 +167,7 @@
);
this.setSearchEngine(0);
}
- Rkns._(_opts.bins).each(function(_bin) {
+ Rkns._(this.options.bins).each(function(_bin) {
if (Rkns[_bin.type] && Rkns[_bin.type].Bin) {
_this.tabs.push(new Rkns[_bin.type].Bin(_this, _bin));
}
@@ -251,13 +223,13 @@
}
Rkns.Renkan.prototype.template = Rkns._.template(
- '<% if (show_bins) { %><div class="Rk-Bins"><div class="Rk-Bins-Head"><h2 class="Rk-Bins-Title"><%- translate("Select contents:")%></h2>'
+ '<% 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>'
+ '<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="<%- translate("Search in Bins") %>" />'
+ '<input type="submit" value="" class="Rk-Bins-Search-Submit Rk-Search-Submit" /></form></div>'
- + '<ul class="Rk-Bin-List"></ul></div><% } %><div class="Rk-Render Rk-Render-<% if (show_bins) { %>Panel<% } else { %>Full<% } %>"></div>'
+ + '<ul class="Rk-Bin-List"></ul></div><% } %><div class="Rk-Render Rk-Render-<% if (options.show_bins) { %>Panel<% } else { %>Full<% } %>"></div>'
);
Rkns.Renkan.prototype.onStatusChange = function() {