40 autoCloseOnClick:
true,
41 onCloseCallback:
null,
43 onClickCallback:
null,
64 showText:
function(aText,
74 else if (!
aWidth) { width_val =
'300'; width_attr =
'width'; }
75 else { width_val =
aWidth; width_attr =
'width'; }
77 this.showContent(
'chrome://songbird/content/bindings/balloon.xml#balloon-text',
82 [
'value', width_attr],
106 showContent:
function(aBindingURL,
112 aBindingAttributeValue) {
114 if (!aAnchorElement) aAnchorElement = document.documentElement;
115 this.bindingUrl = aBindingURL;
116 this.bindingAttribute = aBindingAttribute;
117 this.bindingAttributeValue = aBindingAttributeValue;
118 this.titleImageClass = aTitleImageClass;
119 this.titleValue = aTitle;
120 this.anchorElement = aAnchorElement;
121 this.originalDocument = document;
122 this.originalWindow =
window;
123 this.checkboxLabel = aCheckboxLabel;
133 case "Darwin": raisedflag =
"";
break;
134 default: raisedflag =
",alwaysRaised";
break;
137 this.tipWindow =
window.openDialog(
"chrome://songbird/content/xul/balloonTip.xul",
"_blank",
"chrome,modal=no,titlebar=no,resizable=no"+raisedflag,
this);
138 this.initTimeStamp =
new Date().getTime();
139 if (this.autoCloseTimeout)
setTimeout(
function(obj) { obj.onAutoCloseTimeout(); }, this.autoCloseTimeout * 1000,
this );
143 bindingAttribute:
null,
144 bindingAttributeValue:
null,
145 titleImageClass:
null,
148 checkboxElement:
null,
152 originalDocument:
null,
153 originalWindow:
null,
162 autoCloseTimeoutElapsed:
function() {
163 var
now =
new Date().getTime();
164 var diff = (now - this.initTimeStamp)/1000;
165 return diff > this.autoCloseTimeout;
168 onAutoCloseTimeout:
function() {
169 if (this.focused)
return;
173 onTipBlur:
function() {
174 this.focused =
false;
175 if (!this.autoCloseTimeout)
return;
176 if (this.autoCloseTimeoutElapsed()) this.closeTip();
179 onTipFocus:
function() {
183 onTipClick:
function(clickEvent) {
184 if (this.onClickCallback) this.onClickCallback(
this, clickEvent);
185 if (this.autoCloseOnClick) this.closeTip();
189 closeTip:
function() {
190 if (!this.tipWindow)
return;
192 if (this.onCloseCallback) this.onCloseCallback(
this, this.checkboxElement);
194 this.tipWindow.document.removeEventListener(
"focus", this.onfocus,
true);
195 this.tipWindow.document.removeEventListener(
"blur", this.onblur,
true);
196 this.tipWindow.document.removeEventListener(
"click", this.onclick,
true);
197 var wnd = this.tipWindow;
198 this.tipWindow =
null;
203 onCreateTip:
function(aWindow) {
209 Components.classes[
"@songbirdnest.com/Songbird/WindowCloak;1"]
210 .getService(Components.interfaces.sbIWindowCloak);
211 windowCloak.cloak(aWindow);
215 intersectRect:
function(aRectA, aRectB, aIntersection) {
216 aIntersection.x = Math.max(aRectA.x, aRectB.x);
217 aIntersection.y = Math.max(aRectA.y, aRectB.y);
218 aIntersection.w = Math.min(aRectA.x + aRectA.w, aRectB.x + aRectB.w) - aIntersection.x;
219 aIntersection.h = Math.min(aRectA.y + aRectA.h, aRectB.y + aRectB.h) - aIntersection.y;
221 if (!(aIntersection.x < aIntersection.x + aIntersection.w && aIntersection.y < aIntersection.y + aIntersection.h)) {
222 aIntersection.x = aIntersection.y = aIntersection.w = aIntersection.height = 0;
229 getXULWindowFromWindow:
function(
win) {
232 var requestor =
win.QueryInterface(Components.interfaces.nsIInterfaceRequestor);
233 var nav = requestor.getInterface(Components.interfaces.nsIWebNavigation);
234 var dsti = nav.QueryInterface(Components.interfaces.nsIDocShellTreeItem);
235 var
owner = dsti.treeOwner;
236 requestor = owner.QueryInterface(Components.interfaces.nsIInterfaceRequestor);
237 rv = requestor.getInterface(Components.interfaces.nsIXULWindow);
247 computePositionAndOrientation:
function() {
250 if (!this.tipWindow)
return;
252 if (!this.gotmetrics) {
254 if (this.tipWindow.document.documentElement.boxObject.width == 0 ||
255 this.tipWindow.document.documentElement.boxObject.height == 0) {
256 setTimeout(
function(obj) { obj.computePositionAndOrientation(); }, 0,
this);
261 if (this.onInitCallback) this.onInitCallback(
this, this.checkboxElement);
264 this._tipX = this.tipWindow.document.documentElement.boxObject.screenX;
265 this._tipY = this.tipWindow.document.documentElement.boxObject.screenY;
266 this._tipWidth = this.tipWindow.document.documentElement.boxObject.width;
267 this._tipHeight = this.tipWindow.document.documentElement.boxObject.height;
271 handleEvent:
function(
event ) { this._that.onTipBlur(); }
272 }; this.onblur._that =
this;
273 this.tipWindow.document.addEventListener(
"blur", this.onblur,
true);
277 handleEvent:
function(
event ) { this._that.onTipFocus(); }
278 }; this.onfocus._that =
this;
279 this.tipWindow.document.addEventListener(
"focus", this.onfocus,
true);
283 handleEvent:
function(
event ) { this._that.onTipClick(); }
284 }; this.onclick._that =
this;
285 this.tipWindow.document.addEventListener(
"click", this.onclick,
true);
291 var xulwindow = this.getXULWindowFromWindow(this.tipWindow);
292 if (xulwindow) xulwindow.zLevel = Components.interfaces.nsIXULWindow.highestZ;
296 this._anchor_nw = this.tipWindow.document.getElementById(
"anchor-nw");
297 this._anchor_ne = this.tipWindow.document.getElementById(
"anchor-ne");
298 this._anchor_sw = this.tipWindow.document.getElementById(
"anchor-sw");
299 this._anchor_se = this.tipWindow.document.getElementById(
"anchor-se");
300 this._frame_n = this.tipWindow.document.getElementById(
"frame-n");
301 this._frame_s = this.tipWindow.document.getElementById(
"frame-s");
304 this._offset_nw = this._anchor_nw.boxObject.screenX - this._tipX;
305 this._offset_ne = (this._tipX + this._tipWidth) - (this._anchor_ne.boxObject.screenX +
this._anchor_ne.boxObject.width);
306 this._offset_sw = this._anchor_sw.boxObject.screenX - this._tipX;
307 this._offset_se = (this._tipX + this._tipWidth) - (this._anchor_se.boxObject.screenX +
this._anchor_se.boxObject.width);
308 this._margin_n = this._frame_n.boxObject.screenY - this._tipY;
309 this._margin_s = (this._tipY + this._tipHeight) - (this._frame_s.boxObject.screenY +
this._frame_s.boxObject.height);
313 this.gotmetrics =
true;
334 var basewindows = [this.originalWindow, (this.tipWindow == this.originalWindow) ?
null : this.tipWindow];
336 for (var j in basewindows) {
337 if (!basewindows[j])
continue;
340 var screen = basewindows[j].QueryInterface(Components.interfaces.nsIDOMWindowInternal).screen;
341 if (!screen)
continue;
345 w: screen.availWidth,
346 h: screen.availHeight
363 for (var
i = 0;
i <= 3;
i++) {
369 px = this.anchorElement.boxObject.screenX + (this.anchorElement.boxObject.width / 4);
370 py = this.anchorElement.boxObject.screenY + this.anchorElement.boxObject.height;
373 px = this.anchorElement.boxObject.screenX + (this.anchorElement.boxObject.width / 4)*3;
374 py = this.anchorElement.boxObject.screenY + this.anchorElement.boxObject.height;
377 px = this.anchorElement.boxObject.screenX + (this.anchorElement.boxObject.width / 4);
378 py = this.anchorElement.boxObject.screenY;
381 px = this.anchorElement.boxObject.screenX + (this.anchorElement.boxObject.width / 4)*3;
382 py = this.anchorElement.boxObject.screenY;
387 px = this.anchorElement.boxObject.screenX + (this.anchorElement.boxObject.width / 2);
388 py = this.anchorElement.boxObject.screenY + (this.anchorElement.boxObject.height / 2);
393 case ORIENT_NW: px -= this._offset_nw;
break;
394 case ORIENT_NE: px += this._offset_ne;
break;
395 case ORIENT_SW: px -= this._offset_sw;
break;
396 case ORIENT_SE: px += this._offset_se;
break;
400 var wx, wy, wh = this._tipHeight,
ww = this._tipWidth;
405 wh -= this._margin_s;
408 wx = px - this._tipWidth;
410 wh -= this._margin_s;
414 wy = py - this._tipHeight + this._margin_n;
415 wh -= this._margin_n;
418 wx = px - this._tipWidth;
419 wy = py - this._tipHeight + this._margin_n;
420 wh -= this._margin_n;
432 var insideRect = { x: 0,
y: 0, w: 0, h: 0};
433 this.intersectRect(tipRect, screenRect, insideRect);
434 var insideArea = insideRect.w * insideRect.h;
437 if (best.insideArea == -1 || insideArea > best.insideArea) {
438 best.orientation =
i;
439 best.insideArea = insideArea;
452 switch (best.orientation) {
454 this._anchor_nw.hidden =
false;
455 this._anchor_ne.hidden =
true;
456 this._anchor_sw.hidden =
true;
457 this._anchor_se.hidden =
true;
460 this._anchor_nw.hidden =
true;
461 this._anchor_ne.hidden =
false;
462 this._anchor_sw.hidden =
true;
463 this._anchor_se.hidden =
true;
466 this._anchor_nw.hidden =
true;
467 this._anchor_ne.hidden =
true;
468 this._anchor_sw.hidden =
false;
469 this._anchor_se.hidden =
true;
472 this._anchor_nw.hidden =
true;
473 this._anchor_ne.hidden =
true;
474 this._anchor_sw.hidden =
true;
475 this._anchor_se.hidden =
false;
479 if (this.lastW != best.w ||
480 this.lastH != best.h) {
483 this.tipWindow.resizeTo(best.w, best.h);
489 if (this.lastX != best.x ||
490 this.lastY != best.y) {
496 this.tipWindow.moveTo(best.x, best.y);
502 if (!this.doneUncloak) {
505 Components.classes[
"@songbirdnest.com/Songbird/WindowCloak;1"]
506 .getService(Components.interfaces.sbIWindowCloak);
507 windowCloak.uncloak(this.tipWindow);
508 this.doneUncloak =
true;
512 setTimeout(
function(obj) { obj.computePositionAndOrientation(); }, 100,
this);
514 Components.utils.reportError(e);
function getPlatformString()
Get the name of the platform we are running on.
aWindow setTimeout(function(){_this.restoreHistory(aWindow, aTabs, aTabData, aIdMap);}, 0)
BogusChannel prototype owner
this _dialogInput this _pos[1] px
_getSelectedPageStyle s i