gecko/browser/base/content/tabcandy/shared/jquery.select.js

48 lines
1.2 KiB
JavaScript
Raw Normal View History

function Selector(options){ this.init(options) }
Selector.prototype = {
init: function(options){
var self = this;
options.onSelect = function(a,b){ self.showMenu(a,b); };
options.onStart = function(){ self.hideMenu() };
+ Major reorg: moved all visualizations into "candies" folder, moved core js files into "core" folder, and js files shared by a couple of visualizations into "shared" folder + the top level index.html now automatically grabs all the different visualizations and lists them + Added a visualization switcher that can be dropped into any visualization; drop down in the upper left of the window + The Utils routines log(), trace() and error() now take in any number of parameters. If a parameter is an object, its first level is automatically expanded + Fixed lasso in the "original" visualization --HG-- rename : browser/base/content/tabcandy/jquery-ui.js => browser/base/content/tabcandy/app/jquery-ui.js rename : browser/base/content/tabcandy/jquery.js => browser/base/content/tabcandy/core/jquery.js rename : browser/base/content/tabcandy/app/jquery.lasso.js => browser/base/content/tabcandy/shared/jquery.lasso.js rename : content/ian1/index.html => content/candies/ian1/index.html rename : content/ian1/ui.js => content/candies/ian1/js/ui.js rename : content/line/index.html => content/candies/line/index.html rename : content/line/js/jquery.line.js => content/candies/line/js/jquery.line.js rename : content/line/js/jquery.select.js => content/candies/line/js/jquery.select.js rename : content/tab.html => content/candies/original/index.html rename : content/select/index.html => content/candies/select/index.html rename : content/stacks/index.html => content/candies/stacks/index.html rename : content/stacks/js/jquery.select.js => content/candies/stacks/js/jquery.select.js rename : content/stacks/js/ui.js => content/candies/stacks/js/ui.js
2010-03-05 15:14:10 -08:00
this.lasso = new Lasso(options);
},
hideMenu: function(){
if( this.menu ) this.menu.remove();
},
showMenu: function( selectedEls, pos ){
if( pos == null || selectedEls.length == 0 ) return;
var self = this;
this.menu = $("<div class='lasso-menu'>").appendTo("body");
this.menu.css({
position:"fixed",
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)} )
}
}
function group(els){
var startEl = $(els[0]);
startEl.css("z-index", 0);
for( var i=1; i<els.length; i++){
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);
}
}
$(function(){
var select = new Selector({
targets: ".tab",
container: "html",
});
});