Animal
11-20-2006, 08:03 AM
Another small suggestion.
Instead of absolutely positioning the close button, could this be changed as in the code below to be floated on the right?
This would then enable other buttons to be added and removed at will into a Dialog's "tools" area. If this change could be made, it would be easier to subclass BasicDialog to create more functional Window elements.
Not a huge change. Just a couple of extra elements needed. A div wrapper for the header text to float it left, and a wrapper for the buttons to form a "tools" element which is floated right:
In the constructor, just after declaring "dh" as shorthand for the DomHelper:
var dh = YAHOO.ext.DomHelper;
this.titleEl = document.createElement("div");
this.titleEl.className = "ydlg-title";
if(!this.header){
this.header = dh.append(this.el.dom, {tag: 'div', cls:'ydlg-hd'}, true);
}
else {
while(this.header.dom.firstChild)
this.titleEl.appendChild(this.header.dom.firstChild);
}
// wrap any title elements in a float:left div, opposite to the tools element.
this.header.dom.appendChild(this.titleEl);
That wraps any textual elements in existing markup into a div.
Then, creating the tools element and adding the close button:
// Add a float:right tool element for header buttons
this.tools = dh.append(this.header.dom, {tag:'div', cls:'ydlg-tools'}, true);
// Add specified header buttons into tools element
if(this.closable !== false){
this.el.addClass('ydlg-closable');
this.close = dh.append(this.tools.dom, {tag: 'div', cls:'ydlg-hd-button ydlg-close'}, true);
this.close.mon('click', function(){
this.hide();
}, this, true);
}
The style rules in basic-dialog.css:
.ydlg .ydlg-title {
float:left;
color:#fff
}
.ydlg .ydlg-hd-tools {
float:right;
}
.ydlg .ydlg-hd-button {
float:right;
height:15px;
width:15px;
margin:0px;
padding:0px;
line-height:1px;
font-size:1px;
background-repeat:no-repeat;
cursor:pointer;
visibility:inherit;
}
.ydlg .ydlg-close {
background-image:url(../images/basic-dialog/close.gif);
}
Instead of absolutely positioning the close button, could this be changed as in the code below to be floated on the right?
This would then enable other buttons to be added and removed at will into a Dialog's "tools" area. If this change could be made, it would be easier to subclass BasicDialog to create more functional Window elements.
Not a huge change. Just a couple of extra elements needed. A div wrapper for the header text to float it left, and a wrapper for the buttons to form a "tools" element which is floated right:
In the constructor, just after declaring "dh" as shorthand for the DomHelper:
var dh = YAHOO.ext.DomHelper;
this.titleEl = document.createElement("div");
this.titleEl.className = "ydlg-title";
if(!this.header){
this.header = dh.append(this.el.dom, {tag: 'div', cls:'ydlg-hd'}, true);
}
else {
while(this.header.dom.firstChild)
this.titleEl.appendChild(this.header.dom.firstChild);
}
// wrap any title elements in a float:left div, opposite to the tools element.
this.header.dom.appendChild(this.titleEl);
That wraps any textual elements in existing markup into a div.
Then, creating the tools element and adding the close button:
// Add a float:right tool element for header buttons
this.tools = dh.append(this.header.dom, {tag:'div', cls:'ydlg-tools'}, true);
// Add specified header buttons into tools element
if(this.closable !== false){
this.el.addClass('ydlg-closable');
this.close = dh.append(this.tools.dom, {tag: 'div', cls:'ydlg-hd-button ydlg-close'}, true);
this.close.mon('click', function(){
this.hide();
}, this, true);
}
The style rules in basic-dialog.css:
.ydlg .ydlg-title {
float:left;
color:#fff
}
.ydlg .ydlg-hd-tools {
float:right;
}
.ydlg .ydlg-hd-button {
float:right;
height:15px;
width:15px;
margin:0px;
padding:0px;
line-height:1px;
font-size:1px;
background-repeat:no-repeat;
cursor:pointer;
visibility:inherit;
}
.ydlg .ydlg-close {
background-image:url(../images/basic-dialog/close.gif);
}