+ Added a "close" feature to the group menu in the stacks candy

+ Added a tab() feature to window.Tabs, to get a tab object from one of the tab's elements
+ Stacks now pile up directly on top of each other in the stacks candy (rather than being offset a little)
+ Added Utils.isRightClick() for weeding out right clicks in mousedown
+ The Lasso now only starts for left clicks, not both left or right
This commit is contained in:
Ian Gilman 2010-03-09 14:21:08 -08:00
parent 81242b5bf1
commit 1b1a4d59d1
6 changed files with 82 additions and 12 deletions

Binary file not shown.

View File

@ -357,6 +357,10 @@ function Tabs() {
// make a new one?
return browserWindow.addTab(url);
},
tab: function tab(value) {
// assuming value is a DOM element for the time being
return $(value).find("canvas").data("link").tab;
},
toString: function toString() {
return "[Tabs]";
}

View File

@ -138,7 +138,17 @@ var Utils = {
this.trace('this is a trace');
this.log(1, null, {'foo': 'hello', 'bar': 2}, 'whatever');
this.log('ending logging test');
}
},
// ___ Event
isRightClick: function(event) {
if(event.which)
return (event.which == 3);
else if(event.button)
return (event.button == 2);
return false;
}
};
window.Utils = Utils;

View File

@ -38,7 +38,8 @@ Lasso.prototype = {
var self = this;
$(this._container)
.mousedown( function(e){
if( $(e.target).is(self._selector)
if(Utils.isRightClick(e)
|| $(e.target).is(self._selector)
|| $(e.target).parent(self._selector).length > 0
|| !self._acceptMouseDown(e))
return;

View File

@ -104,7 +104,7 @@
.lasso-menu {
background-color: white;
width: 100px;
height: 100px;
height: 200px;
border: 1px solid #DDD;
-moz-box-shadow: 2px 2px 4px rgba(0,0,0,.5);
line-height: 100px;
@ -128,6 +128,7 @@
<script type="text/javascript;version=1.8">
</script>
<script type="text/javascript;version=1.8" src="../../js/optional/stacktrace.js"></script>
<script type="text/javascript;version=1.8" src="../../js/core/jquery.js"></script>
<script type="text/javascript;version=1.8" src="../../js/optional/jquery-ui.js"></script>
@ -149,5 +150,10 @@
</script>
<!-- END Switch Control -->
<script type="text/javascript;version=1.8">
/* Utils.log(1, Tabs); */
/* window.setTimeout(function() { alert('foo'); }, 2000); */
</script>
</body>
</html>

View File

@ -9,15 +9,39 @@ Selector.prototype = {
this.lasso = new Lasso(options);
},
hideMenu: function(){
if( this.menu ) this.menu.remove();
startFadeOutTimer: function() {
var self = this;
this.timeout = setTimeout(function() {
self.timeout = null;
self.hideMenu();
}, 2000);
},
cancelFadeOutTimer: function() {
if(this.timeout) {
clearTimeout(this.timeout);
this.timeout = null;
}
},
hideMenu: function() {
var self = this;
if(this.menu) {
this.menu.fadeOut(2000, function() {
self.menu.remove();
self.menu = null;
});
}
this.cancelFadeOutTimer();
},
showMenu: function( selectedEls, pos ){
if( pos == null || selectedEls.length == 0 ) return;
var self = this;
self.updateSelection(selectedEls);
this.updateSelection(selectedEls);
this.cancelFadeOutTimer();
this.menu = $("<div class='lasso-menu'>").appendTo("body");
this.menu.css({
@ -25,11 +49,28 @@ Selector.prototype = {
zIndex: 9999,
top:pos.y-this.menu.height()/2,
left:pos.x-this.menu.width()/2
})
.text("Group")
.mouseout( function(){self.hideMenu()} )
.mousedown( function(){group(selectedEls)} )
},
});
this.menu.mouseover(function() {
self.cancelFadeOutTimer();
});
this.menu.mouseout(function() {
self.startFadeOutTimer();
});
$('<div>Group</div>')
.appendTo(this.menu)
.mousedown(function() {
group(selectedEls);
});
$('<div>Close</div>')
.appendTo(this.menu)
.mousedown(function() {
close(selectedEls);
});
},
updateSelection: function(els) {
for( var i=0; i<els.length; i++){
@ -54,7 +95,15 @@ function group(els){
var el = els[i];
var pos = startEl.position();
$(el).css("z-index", i*10);
$(el).animate({top: pos.top+i*15, left: pos.left+i*15, position: "absolute"}, 250);
$(el).animate({top: pos.top, left: pos.left, position: "absolute"}, 250);
}
}
function close(els){
for( var i=0; i<els.length; i++){
var el = els[i];
var tab = Tabs.tab(el);
tab.close();
}
}