Adding a close button on tabs

This commit is contained in:
Rodolphe Breard 2013-05-26 18:58:13 +02:00
parent 978c8b0b09
commit d8bf26c324
2 changed files with 26 additions and 5 deletions

View file

@ -31,15 +31,24 @@ Tab.prototype.filterName = function(name) {
};
Tab.prototype.initListElement = function() {
var inner = document.createElement("span");
var inner = document.createElement("span"), close = document.createElement("img");
close.src = "img/delcontact.png";
close.alt = "x";
close.title = "Close tab";
close.classList.add("close-tab");
inner.innerHTML = this.name;
this.el_lst = document.createElement("li");
this.el_lst.addEventListener("click", (function(elem) {
inner.addEventListener("click", (function(elem) {
return function() {
elem.show();
};
})(this), false);
close.addEventListener("click", (function(elem) {
return function() {
elem.close();
};
})(this), false);
this.el_lst.addEventListener("dblclick", (function(elem) {
return function() {
elem.close();
@ -47,6 +56,7 @@ Tab.prototype.initListElement = function() {
})(this), false);
this.el_lst.appendChild(inner);
this.el_lst.appendChild(close);
this.wr_lst.appendChild(this.el_lst);
};