diff -r f67047a16084 -r fba23fde14ba client/js/main.js
--- a/client/js/main.js Fri May 16 12:37:51 2014 +0200
+++ b/client/js/main.js Fri May 16 14:09:57 2014 +0200
@@ -34,9 +34,9 @@
this.title_icon_$ = Rkns.$('')
.addClass("Rk-Bin-Title-Icon")
.appendTo(this.$);
-
+
var _this = this;
-
+
Rkns.$('')
.attr({
href: "#",
@@ -76,7 +76,7 @@
.html('' + _renkan.translate("Loading, please wait") + '
');
this.title_$.html(_opts.title || '(new bin)');
this.renkan.resizeBins();
-
+
if (_opts.auto_refresh) {
window.setInterval(function() {
_this.refresh();
@@ -94,21 +94,21 @@
var Renkan = Rkns.Renkan = function(_opts) {
var _this = this;
-
+
Rkns.__renkans.push(this);
-
+
this.options = _.defaults(_opts, Rkns.defaults);
-
+
_(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();
-
+
if (typeof this.options.user_id !== "undefined") {
this.current_user = this.options.user_id;
}
@@ -116,27 +116,27 @@
this.$
.addClass("Rk-Main")
.html(this.template(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('');
- return '' + Rkns.pickerColors.map(function(c) { return _tmpl({c:c})}).join("") + '
'
+ return '' + Rkns.pickerColors.map(function(c) { return _tmpl({c:c});}).join("") + '
';
})();
-
+
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 {
@@ -183,9 +183,9 @@
_this.tabs.push(new Rkns[_bin.type].Bin(_this, _bin));
}
});
-
+
var elementDropped = false;
-
+
this.$.find(".Rk-Bins")
.on("click",".Rk-Bin-Title,.Rk-Bin-Title-Icon", function() {
var _mainDiv = Rkns.$(this).siblings(".Rk-Bin-Main");
@@ -194,9 +194,9 @@
_mainDiv.slideDown();
}
});
-
+
if (this.options.show_editor) {
-
+
this.$.find(".Rk-Bins").on("mouseover", ".Rk-Bin-Item", function(_e) {
var _t = Rkns.$(this);
if (_t && $(_t).attr("data-uri")) {
@@ -248,15 +248,15 @@
e.originalEvent.dataTransfer.setData("text",div.innerHTML);
}
});
-
+
}
-
+
Rkns.$(window).resize(function() {
_this.resizeBins();
});
-
+
var lastsearch = false, lastval = '';
-
+
this.$.find(".Rk-Bins-Search-Input").on("change keyup paste input", function() {
var val = Rkns.$(this).val();
if (val === lastval) {
@@ -270,23 +270,23 @@
_(_this.tabs).each(function(tab) {
tab.render(search);
});
-
+
});
this.$.find(".Rk-Bins-Search-Form").submit(function() {
return false;
});
-
+
};
Renkan.prototype.template = _.template(
- '<% if (options.show_bins) { %><%- translate("Select contents:")%>
'
- + '
'
- + '
'
- + '
<% } %>'
- + '<% if (options.show_editor) { %><% } %>'
+ '<% if (options.show_bins) { %><%- translate("Select contents:")%>
' +
+ '
' +
+ '
' +
+ '
<% } %>' +
+ '<% if (options.show_editor) { %><% } %>'
);
Renkan.prototype.translate = function(_text) {
@@ -327,26 +327,26 @@
}
function fillrand() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
- var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
+ var r = Math.random()*16|0, v = c === 'x' ? r : (r&0x3|0x8);
return v.toString(16);
});
}
var _d = new Date(),
ID_AUTO_INCREMENT = 0,
- ID_BASE = _d.getUTCFullYear() + '-'
- + pad(_d.getUTCMonth()+1) + '-'
- + pad(_d.getUTCDate()) + '-'
- + fillrand();
+ ID_BASE = _d.getUTCFullYear() + '-' +
+ pad(_d.getUTCMonth()+1) + '-' +
+ pad(_d.getUTCDate()) + '-' +
+ fillrand();
return function(_base) {
var _n = (++ID_AUTO_INCREMENT).toString(16),
- _base = (typeof _base === "undefined" ? "" : _base + "-" );
+ _uidbase = (typeof _base === "undefined" ? "" : _base + "-" );
while (_n.length < 4) { _n = '0' + _n; }
- return _base + ID_BASE + '-' + _n;
- }
+ return _uidbase + ID_BASE + '-' + _n;
+ };
})(),
getFullURL : function(url) {
-
- if(typeof(url) == 'undefined' || url == null ) {
+
+ if(typeof(url) === 'undefined' || url == null ) {
return "";
}
if(/https?:\/\//.test(url)) {
@@ -357,24 +357,24 @@
var res = img.src;
img.src = null;
return res;
-
+
},
inherit : function(_baseClass, _callbefore) {
-
+
var _class = function(_arg) {
if (typeof _callbefore === "function") {
_callbefore.apply(this, Array.prototype.slice.call(arguments, 0));
}
_baseClass.apply(this, Array.prototype.slice.call(arguments, 0));
- if (typeof this._init == "function" && !this._initialized) {
+ if (typeof this._init === "function" && !this._initialized) {
this._init.apply(this, Array.prototype.slice.call(arguments, 0));
this._initialized = true;
}
};
_(_class.prototype).extend(_baseClass.prototype);
-
+
return _class;
-
+
},
regexpFromTextOrArray: (function() {
var charsub = [
@@ -395,22 +395,25 @@
charsrx = _(charsub).map(function(c) {
return new RegExp(c);
});
-
+
function replaceText(_text) {
var txt = _text.toLowerCase().replace(remrx,""), src = "";
+ function makeReplaceFunc(l) {
+ return function(k,v) {
+ l = l.replace(charsrx[k], v);
+ };
+ }
for (var j = 0; j < txt.length; j++) {
if (j) {
src += remsrc + "*";
}
var l = txt[j];
- _(charsub).each(function(v, k) {
- l = l.replace(charsrx[k], v);
- });
+ _(charsub).each(makeReplaceFunc(l));
src += l;
}
return src;
}
-
+
function getSource(inp) {
switch (typeof inp) {
case "string":
@@ -430,27 +433,27 @@
}
return '';
}
-
+
return function(_textOrArray) {
var source = getSource(_textOrArray);
if (source) {
var testrx = new RegExp( source, "im"),
- replacerx = new RegExp( '(' + source + ')', "igm")
+ replacerx = new RegExp( '(' + source + ')', "igm");
return {
isempty: false,
source: source,
- test: function(_t) { return testrx.test(_t) },
+ test: function(_t) { return testrx.test(_t); },
replace: function(_text, _replace) { return _text.replace(replacerx, _replace); }
- }
+ };
} else {
return {
isempty: true,
source: '',
- test: function() { return true },
- replace: function(_text) { return text }
- }
+ test: function() { return true; },
+ replace: function(_text) { return text; }
+ };
}
- }
+ };
})(),
/* The minimum distance (in pixels) the mouse has to move to consider an element was dragged */
_MIN_DRAG_DISTANCE: 2,
@@ -486,9 +489,9 @@
* it doesn't seem that it's still a requirement in newer browsers (i.e. the ones compatibles with canvas drawing)
*/
_BOOKMARKLET_CODE: function(_renkan) {
- return "(function(a,b,c,d,e,f,h,i,j,k,l,m,n,o,p,q,r){a=document;b=a.body;c=a.location.href;j='draggable';m='text/x-iri-';d=a.createElement('div');d.innerHTML='"
- + _renkan.translate("Drag items from this website, drop them in Renkan").replace(/ /g,"_")
- + "
'.replace(/_/g,String.fromCharCode(32));b.appendChild(d);e=[{r:/https?:\\/\\/[^\\/]*twitter\\.com\\//,s:'.tweet',n:'twitter'},{r:/https?:\\/\\/[^\\/]*google\\.[^\\/]+\\//,s:'.g',n:'google'},{r:/https?:\\/\\/[^\\/]*lemonde\\.fr\\//,s:'[data-vr-contentbox]',n:'lemonde'}];f=false;e.forEach(function(g){if(g.r.test(c)){f=g;}});if(f){h=function(){Array.prototype.forEach.call(a.querySelectorAll(f.s),function(i){i[j]=true;k=i.style;k.borderWidth='2px';k.borderColor='#909';k.borderStyle='solid';k.backgroundColor='rgba(200,0,180,.1)';})};window.setInterval(h,500);h();};a.addEventListener('dragstart',function(k){l=k.dataTransfer;l.setData(m+'source-uri',c);l.setData(m+'source-title',a.title);n=k.target;if(f){o=n;while(!o.attributes[j]){o=o.parentNode;if(o==b){break;}}}if(f&&o.attributes[j]){p=o.cloneNode(true);l.setData(m+'specific-site',f.n)}else{q=a.getSelection();if(q.type==='Range'||!q.type){p=q.getRangeAt(0).cloneContents();}else{p=n.cloneNode();}}r=a.createElement('div');r.appendChild(p);l.setData('text/x-iri-selected-text',r.textContent.trim());l.setData('text/x-iri-selected-html',r.innerHTML);},false);})();";
+ return "(function(a,b,c,d,e,f,h,i,j,k,l,m,n,o,p,q,r){a=document;b=a.body;c=a.location.href;j='draggable';m='text/x-iri-';d=a.createElement('div');d.innerHTML='" +
+ _renkan.translate("Drag items from this website, drop them in Renkan").replace(/ /g,"_") +
+ "'.replace(/_/g,String.fromCharCode(32));b.appendChild(d);e=[{r:/https?:\\/\\/[^\\/]*twitter\\.com\\//,s:'.tweet',n:'twitter'},{r:/https?:\\/\\/[^\\/]*google\\.[^\\/]+\\//,s:'.g',n:'google'},{r:/https?:\\/\\/[^\\/]*lemonde\\.fr\\//,s:'[data-vr-contentbox]',n:'lemonde'}];f=false;e.forEach(function(g){if(g.r.test(c)){f=g;}});if(f){h=function(){Array.prototype.forEach.call(a.querySelectorAll(f.s),function(i){i[j]=true;k=i.style;k.borderWidth='2px';k.borderColor='#909';k.borderStyle='solid';k.backgroundColor='rgba(200,0,180,.1)';})};window.setInterval(h,500);h();};a.addEventListener('dragstart',function(k){l=k.dataTransfer;l.setData(m+'source-uri',c);l.setData(m+'source-title',a.title);n=k.target;if(f){o=n;while(!o.attributes[j]){o=o.parentNode;if(o==b){break;}}}if(f&&o.attributes[j]){p=o.cloneNode(true);l.setData(m+'specific-site',f.n)}else{q=a.getSelection();if(q.type==='Range'||!q.type){p=q.getRangeAt(0).cloneContents();}else{p=n.cloneNode();}}r=a.createElement('div');r.appendChild(p);l.setData('text/x-iri-selected-text',r.textContent.trim());l.setData('text/x-iri-selected-html',r.innerHTML);},false);})();";
},
/* Shortens text to the required length then adds ellipsis */
shortenText: function(_text, _maxlength) {
@@ -512,23 +515,24 @@
_top = Math.min( _options.tooltip_margin, _coords.y - _options.tooltip_arrow_width / 2 );
}
var _bottom = _top + _height;
+ /* jshint laxbreak:true */
_path.segments[0].point
- = _path.segments[7].point
- = _coords.add([_isLeft * _xmargin, 0]);
+ = _path.segments[7].point
+ = _coords.add([_isLeft * _xmargin, 0]);
_path.segments[1].point.x
- = _path.segments[2].point.x
- = _path.segments[5].point.x
- = _path.segments[6].point.x
- = _left;
+ = _path.segments[2].point.x
+ = _path.segments[5].point.x
+ = _path.segments[6].point.x
+ = _left;
_path.segments[3].point.x
- = _path.segments[4].point.x
- = _right;
+ = _path.segments[4].point.x
+ = _right;
_path.segments[2].point.y
- = _path.segments[3].point.y
- = _top;
+ = _path.segments[3].point.y
+ = _top;
_path.segments[4].point.y
- = _path.segments[5].point.y
- = _bottom;
+ = _path.segments[5].point.y
+ = _bottom;
_path.segments[1].point.y = _coords.y - _options.tooltip_arrow_width / 2;
_path.segments[6].point.y = _coords.y + _options.tooltip_arrow_width / 2;
_path.closed = true;