client/js/main.js
changeset 433 e457ec945e50
parent 430 d3ae63bc18c6
child 444 19f0b7803aed
child 447 e246651b6626
equal deleted inserted replaced
432:24754fe4baaf 433:e457ec945e50
    98     Rkns.__renkans.push(this);
    98     Rkns.__renkans.push(this);
    99 
    99 
   100     this.options = _.defaults(_opts, Rkns.defaults, {templates: renkanJST});
   100     this.options = _.defaults(_opts, Rkns.defaults, {templates: renkanJST});
   101     this.template = renkanJST['templates/main.html'];
   101     this.template = renkanJST['templates/main.html'];
   102 
   102 
   103     _(this.options.property_files).each(function(f) {
   103     _.each(this.options.property_files,function(f) {
   104         Rkns.$.getJSON(f, function(data) {
   104         Rkns.$.getJSON(f, function(data) {
   105             _this.options.properties = _this.options.properties.concat(data);
   105             _this.options.properties = _this.options.properties.concat(data);
   106         });
   106         });
   107     });
   107     });
   108 
   108 
   116     		title: user_name
   116     		title: user_name
   117     	});
   117     	});
   118     	this.current_user = user_id;
   118     	this.current_user = user_id;
   119     	this.renderer.redrawUsers();
   119     	this.renderer.redrawUsers();
   120     };
   120     };
   121     
   121 
   122     if (typeof this.options.user_id !== "undefined") {
   122     if (typeof this.options.user_id !== "undefined") {
   123         this.current_user = this.options.user_id;
   123         this.current_user = this.options.user_id;
   124     }
   124     }
   125     this.$ = Rkns.$("#" + this.options.container);
   125     this.$ = Rkns.$("#" + this.options.container);
   126     this.$
   126     this.$
   152     } else {
   152     } else {
   153         var _tmpl = renkanJST['templates/search.html'],
   153         var _tmpl = renkanJST['templates/search.html'],
   154             _select = this.$.find(".Rk-Search-List"),
   154             _select = this.$.find(".Rk-Search-List"),
   155             _input = this.$.find(".Rk-Web-Search-Input"),
   155             _input = this.$.find(".Rk-Web-Search-Input"),
   156             _form = this.$.find(".Rk-Web-Search-Form");
   156             _form = this.$.find(".Rk-Web-Search-Form");
   157         _(this.options.search).each(function(_search, _key) {
   157         _.each(this.options.search, function(_search, _key) {
   158             if (Rkns[_search.type] && Rkns[_search.type].Search) {
   158             if (Rkns[_search.type] && Rkns[_search.type].Search) {
   159                 _this.search_engines.push(new Rkns[_search.type].Search(_this, _search));
   159                 _this.search_engines.push(new Rkns[_search.type].Search(_this, _search));
   160             }
   160             }
   161         });
   161         });
   162         _select.html(
   162         _select.html(
   186         this.$.find(".Rk-Search-Select").mouseleave(
   186         this.$.find(".Rk-Search-Select").mouseleave(
   187             function() { _select.hide(); }
   187             function() { _select.hide(); }
   188         );
   188         );
   189         this.setSearchEngine(0);
   189         this.setSearchEngine(0);
   190     }
   190     }
   191     _(this.options.bins).each(function(_bin) {
   191     _.each(this.options.bins, function(_bin) {
   192         if (Rkns[_bin.type] && Rkns[_bin.type].Bin) {
   192         if (Rkns[_bin.type] && Rkns[_bin.type].Bin) {
   193             _this.tabs.push(new Rkns[_bin.type].Bin(_this, _bin));
   193             _this.tabs.push(new Rkns[_bin.type].Bin(_this, _bin));
   194         }
   194         }
   195     });
   195     });
   196 
   196 
   211             var _t = Rkns.$(this);
   211             var _t = Rkns.$(this);
   212             if (_t && $(_t).attr("data-uri")) {
   212             if (_t && $(_t).attr("data-uri")) {
   213                 var _models = _this.project.get("nodes").where({
   213                 var _models = _this.project.get("nodes").where({
   214                     uri: $(_t).attr("data-uri")
   214                     uri: $(_t).attr("data-uri")
   215                 });
   215                 });
   216                 _(_models).each(function(_model) {
   216                 _.each(_models, function(_model) {
   217                     _this.renderer.highlightModel(_model);
   217                     _this.renderer.highlightModel(_model);
   218                 });
   218                 });
   219             }
   219             }
   220         }).mouseout(function() {
   220         }).mouseout(function() {
   221             _this.renderer.unhighlightAll();
   221             _this.renderer.unhighlightAll();
   275         var search = Rkns.Utils.regexpFromTextOrArray(val.length > 1 ? val: null);
   275         var search = Rkns.Utils.regexpFromTextOrArray(val.length > 1 ? val: null);
   276         if (search.source === lastsearch) {
   276         if (search.source === lastsearch) {
   277             return;
   277             return;
   278         }
   278         }
   279         lastsearch = search.source;
   279         lastsearch = search.source;
   280         _(_this.tabs).each(function(tab) {
   280         _.each(_this.tabs, function(tab) {
   281             tab.render(search);
   281             tab.render(search);
   282         });
   282         });
   283 
   283 
   284     });
   284     });
   285     this.$.find(".Rk-Bins-Search-Form").submit(function() {
   285     this.$.find(".Rk-Bins-Search-Form").submit(function() {
   375             if (typeof this._init === "function" && !this._initialized) {
   375             if (typeof this._init === "function" && !this._initialized) {
   376                 this._init.apply(this, Array.prototype.slice.call(arguments, 0));
   376                 this._init.apply(this, Array.prototype.slice.call(arguments, 0));
   377                 this._initialized = true;
   377                 this._initialized = true;
   378             }
   378             }
   379         };
   379         };
   380         _(_class.prototype).extend(_baseClass.prototype);
   380         _.extend(_class.prototype,_baseClass.prototype);
   381 
   381 
   382         return _class;
   382         return _class;
   383 
   383 
   384     },
   384     },
   385     regexpFromTextOrArray: (function() {
   385     regexpFromTextOrArray: (function() {
   396                 "{", "}", "(", ")", "[", "]", "【", "】", "、", "・", "‥", "。", "「", "」", "『", "』", "〜", ":", "!", "?", " ",
   396                 "{", "}", "(", ")", "[", "]", "【", "】", "、", "・", "‥", "。", "「", "」", "『", "』", "〜", ":", "!", "?", " ",
   397                 ",", " ", ";", "(", ")", ".", "*", "+", "\\", "?", "|", "{", "}", "[", "]", "^", "#", "/"
   397                 ",", " ", ";", "(", ")", ".", "*", "+", "\\", "?", "|", "{", "}", "[", "]", "^", "#", "/"
   398             ],
   398             ],
   399             remsrc = "[\\" + removeChars.join("\\") + "]",
   399             remsrc = "[\\" + removeChars.join("\\") + "]",
   400             remrx = new RegExp(remsrc, "gm"),
   400             remrx = new RegExp(remsrc, "gm"),
   401             charsrx = _(charsub).map(function(c) {
   401             charsrx = _.map(charsub, function(c) {
   402                 return new RegExp(c);
   402                 return new RegExp(c);
   403             });
   403             });
   404 
   404 
   405         function replaceText(_text) {
   405         function replaceText(_text) {
   406             var txt = _text.toLowerCase().replace(remrx,""), src = "";
   406             var txt = _text.toLowerCase().replace(remrx,""), src = "";
   412             for (var j = 0; j < txt.length; j++) {
   412             for (var j = 0; j < txt.length; j++) {
   413                 if (j) {
   413                 if (j) {
   414                     src += remsrc + "*";
   414                     src += remsrc + "*";
   415                 }
   415                 }
   416                 var l = txt[j];
   416                 var l = txt[j];
   417                 _(charsub).each(makeReplaceFunc(l));
   417                 _.each(charsub, makeReplaceFunc(l));
   418                 src += l;
   418                 src += l;
   419             }
   419             }
   420             return src;
   420             return src;
   421         }
   421         }
   422 
   422 
   424             switch (typeof inp) {
   424             switch (typeof inp) {
   425                 case "string":
   425                 case "string":
   426                     return replaceText(inp);
   426                     return replaceText(inp);
   427                 case "object":
   427                 case "object":
   428                     var src = '';
   428                     var src = '';
   429                     _(inp).each(function(v) {
   429                     _.each(inp, function(v) {
   430                         var res = getSource(v);
   430                         var res = getSource(v);
   431                         if (res) {
   431                         if (res) {
   432                             if (src) {
   432                             if (src) {
   433                                 src += '|';
   433                                 src += '|';
   434                             }
   434                             }