/**
* @class Toolbar
* @author mpol
*
**/
function Toolbar(core) {
this.name = "Toolbar";
this.core = core;;
this.tools = new Array();
// properties
this.removeFollowingOnClick = true;
/**
* Initializes the object
* @param string String
*/
this.init = function() {
this.debug("Init")
}
this.initTools = function() {
$("#locationButtons").buttonset({
position: "absolute"
});
/* $("#home").button({
text: false,
position: "absolute",
icons: {
primary: "ui-icon-home"
}
});
$("#help").button({
text: false,
position: "absolute",
icons: {
primary: "ui-icon-help"
}
});
// hide help until help document has been written
$("#help").hide();
$("#newwin").button({
text: false,
position: "absolute",
icons: {
primary: "ui-icon-circle-close"
}
});
*/ }
this.disableTool = function(id) {
$('[id='+id+']').button({disabled: true});
}
this.addTool = function(id, toolName, callback) {
if (!this.tools[id]) {
this.tools[id] = toolName;
this.debug("Add Tool: "+id+" "+this.tools[id]);
$("#locationButtons").buttonset();
$("#locationButtons").append('');
$("#locationButtons").buttonset('refresh');
$('[id='+id+']').click(function() {
if (callback) {
callback();
}
if (this.removeFollowingOnClick) {
vdscore.toolbar.removeFollowingTools(id);
}
});
this.updateRender();
} else {
this.debug("TOOL ALREADY EXISTS");
}
}
this.removeFollowingTools = function(current) {
this.debug("removeFollowingTools "+current);
var c = false;
for (id in this.tools) {
this.debug("id: "+id+" c: "+c);
if (c) {
this.removeTool(id);
}
if (id == current) {
c = true;
}
}
}
this.removeTool = function(id) {
this.debug("Remove Tool: "+id);
$('input[id='+id+']').remove();
$('label[for='+id+']').remove();
//$("#locationButtons").empty();
$("#locationButtons").buttonset('refresh');
delete this.tools[id];
this.updateRender();
}
this.setSelectedById = function(id) {
this.debug("Set Selected: "+id);
$('input[id='+id+']').attr("checked", "checked");
$("#locationButtons").buttonset('refresh');
}
this.updateRender = function() {
//this.debug("Update Render");
$("#toolbar").height(27);
/* $("#home").position({
"my": "left",
"at": "left",
"of": $("#toolbar"),
"offset": "5 0"
});
*/ $("#location").position({
"my": "left",
"at": "left",
"of": $("#toolbar"),
"offset": "5 0"
});
$("#locationButtons").position({
"my": "left",
"at": "right",
"of": $("#location"),
"offset": "5 0"
});
/* $("#newwin").position({
"my": "right",
"at": "right",
"of": $("#toolbar"),
"offset": "-5 0"
});
$("#help").position({
"my": "right",
"at": "left",
"of": $("#newwin"),
"offset": "-5 0"
});
*/ }
/**
* Uses Core debug method
* @param string String
*/
this.debug = function(string) {
this.core.debug(this.name, string);
}
this.init();
}