diff -r fac7354c55d2 -r 110f99eb417e client/js/main.js --- 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('