--- a/client/js/main.js Tue Aug 21 18:49:41 2012 +0200
+++ b/client/js/main.js Wed Aug 22 16:50:42 2012 +0200
@@ -48,6 +48,7 @@
this.main_$ = Rkns.$('<div>')
.addClass("Rk-Bin-Main")
.appendTo(this.$);
+ this.title_$.html(_opts.title || '(new bin)');
this.renkan.resizeBins();
}
}
@@ -76,10 +77,10 @@
this.renderer = new Rkns.Renderer.Scene(this);
this.tabs = [];
this.selected_bin_item = undefined;
- this.mousedown = false;
var _this = this;
this.$.mouseup(function() {
_this.selected_bin_item = undefined;
+ _this.$.find(".Rk-Bin-Item.dragging").removeClass("dragging");
});
if (!_opts.search.length) {
this.$.find(".Rk-Search-Form").detach();
@@ -112,6 +113,24 @@
});
}
+ Rkns._(_opts.bins).each(function(_bin) {
+ _this.tabs.push(new _bin.bin(_this, _bin));
+ })
+
+ /* The bins are not yet populated, but we want to bind dragging functions
+ * here, as it will be easier than in the bins. Therefore, we bind to Rk-Bins
+ * and look where the click was. */
+ function findItem(_event) {
+ var _t = Rkns.$(_event.target);
+ while (!_t.is(".Rk-Bins,.Rk-Bin-Item")) {
+ _t = _t.parent();
+ }
+ if (_t.is(".Rk-Bin-Item")) {
+ return _t
+ } else {
+ return null;
+ }
+ }
this.$.find(".Rk-Bins")
.click(function(_e) {
@@ -123,11 +142,9 @@
}
}
}).mousedown(function(_e) {
- var _t = Rkns.$(_e.target);
- while (!_t.is(".Rk-Bins,.Rk-Bin-Item")) {
- _t = _t.parent();
- }
- if (_t.is(".Rk-Bin-Item")) {
+ var _t = findItem(_e);
+ if (_t) {
+ _t.addClass("dragging");
_this.selected_bin_item = {
uri : $(_t).attr("data-uri"),
title : $(_t).attr("data-title"),
@@ -135,6 +152,18 @@
}
return false;
}
+ }).mouseover(function(_e) {
+ var _t = findItem(_e);
+ if (_t && $(_t).attr("data-uri")) {
+ var _models = _this.project.get("nodes").where({
+ uri: $(_t).attr("data-uri")
+ });
+ Rkns._(_models).each(function(_model) {
+ _this.renderer.highlightModel(_model);
+ });
+ }
+ }).mouseout(function() {
+ _this.renderer.unhighlightAll();
});
Rkns.$(window).resize(function() {
_this.resizeBins();
@@ -149,8 +178,10 @@
Rkns.Renkan.prototype.resizeBins = function() {
- var _titles = this.$.find(".Rk-Bin-Title"),
- _d = _titles.length * _titles.outerHeight() + this.$.find(".Rk-Search-Form").outerHeight();
+ var _d = + this.$.find(".Rk-Search-Form").outerHeight();
+ this.$.find(".Rk-Bin-Title").each(function() {
+ _d += Rkns.$(this).outerHeight();
+ });
this.$.find(".Rk-Bin-Main").css({
height: this.$.find(".Rk-Bins").height() - _d
});