25 if (typeof(
Ci) ==
"undefined")
26 var
Ci = Components.interfaces;
27 if (typeof(
Cc) ==
"undefined")
28 var
Cc = Components.classes;
29 if (typeof(
Cr) ==
"undefined")
30 var
Cr = Components.results;
31 if (typeof(
Cu) ==
"undefined")
32 var
Cu = Components.utils;
34 Cu.import(
"resource://app/jsmodules/sbLibraryUtils.jsm");
35 Cu.import(
"resource://app/jsmodules/ArrayConverter.jsm");
54 dump(
"\nMiniplayer." +
arguments.callee.name +
"\n");
61 this._setMinMaxCallback();
64 var nextLayout = this._getNextLayout();
65 var button = document.getElementById(
"miniplayer_feathers_button");
68 SBString(
"feathers.switchfeathers",
"Switch Feathers"));
69 button.setAttribute(
"tooltiptext", switchToString);
72 var windowElement = document.getElementsByTagName(
"window")[0];
73 windowElement.setAttribute(
"hasTitlebar",this._hasTitlebar());
75 initializeDocumentPlatformAttribute();
78 this._miniPlayerMinWidth = parseInt(getComputedStyle(
79 document.documentElement,
"").minWidth);
80 this._miniPlayerMinHeight = parseInt(getComputedStyle(
81 document.documentElement,
"").minHeight);
84 this._initialized =
false;
85 var resizer = document.getElementById(
"miniplayer_resizer_right");
86 resizer.addEventListener(
"mousemove", gMiniplayer.resizeHandler,
false);
90 resizeHandler:
function miniPlayer_resizeHandler(e) {
91 var windowElement = document.getElementsByTagName(
"window")[0],
92 width = windowElement.boxObject.width;
100 if (!this._initialized) {
101 this._initialized =
true;
103 gMiniplayer._miniPlayerMinHeight);
106 if (e.type ==
"mousemove") {
107 if (!gMiniplayer._mouseDown || (gMiniplayer._mouseDown ==
false) ||
108 e.clientX < gMiniplayer._miniPlayerMinWidth)
110 if (e.clientX < gMiniplayer._miniPlayerMinWidth)
111 window.resizeTo(gMiniplayer._miniPlayerMinWidth,
112 gMiniplayer._miniPlayerMinHeight);
117 }
else if (gMiniplayer._cancelResize && gMiniplayer._cancelResize ==
true) {
118 gMiniplayer._cancelResize =
false;
123 if (
width < gMiniplayer._miniPlayerMinWidth) {
125 window.resizeTo(gMiniplayer._miniPlayerMinWidth,
126 gMiniplayer._miniPlayerMinHeight);
130 var ratings = document.getElementById(
"faceplate-tool");
131 var faceplate = document.getElementById(
"faceplate");
132 var autoscroll = document.getElementById(
"sb-faceplate-autoscroll-box");
135 if (
width < 500 && ratings.style.visibility !=
"collapse") {
136 ratings.style.visibility =
"collapse";
137 }
else if (
width >= 500 && ratings.style.visibility !=
"visible") {
138 ratings.style.visibility =
"visible";
142 if (
width < 315 && autoscroll.style.visibility !=
"collapse") {
143 autoscroll.style.visibility =
"collapse";
144 }
else if (
width >= 315 && autoscroll.style.visibility !=
"visible") {
145 autoscroll.style.visibility =
"visible";
149 if (
width < 308 && faceplate.style.visibility !=
"collapse") {
150 faceplate.style.visibility =
"collapse";
151 }
else if (
width >= 308 && faceplate.style.visibility !=
"visible") {
152 faceplate.style.visibility =
"visible";
155 var resizerBoundaryPassed = (e.type ==
"mousemove" && e.clientX > 308);
156 if (
width < 308 && !resizerBoundaryPassed) {
158 window.resizeTo(gMiniplayer._miniPlayerMinWidth,
159 gMiniplayer._miniPlayerMinHeight);
162 gMiniplayer._cancelResize =
true;
163 if (
width < gMiniplayer._miniPlayerMinWidth && resizerBoundaryPassed) {
165 window.resizeTo(gMiniplayer._miniPlayerMinWidth,
166 gMiniplayer._miniPlayerMinHeight);
178 var resizer = document.getElementById(
"miniplayer_resizer_right");
179 resizer.removeEventListener(
"mousemove", gMiniplayer.resizeHandler,
false);
181 dump(
"\nMiniplayer." +
arguments.callee.name +
"\n");
183 this._resetMinMaxCallback();
190 onKeypress:
function onKeypress( evt )
192 dump(
"\nMiniplayer." +
arguments.callee.name +
"\n");
194 dump(
"\nChecking for quit key\n");
201 switch ( evt.keyCode )
204 gMM.sequencer.previous();
207 gMM.sequencer.next();
211 if (
gMM.status.state == sbIMediacoreStatus.STATUS_PLAYING ||
212 gMM.status.state == sbIMediacoreStatus.STATUS_BUFFERING )
213 gMM.playbackControl.pause();
214 else if(
gMM.primaryCore)
215 gMM.playbackControl.play();
219 var app = Components.classes[
"@songbirdnest.com/Songbird/ApplicationController;1"]
220 .getService(Components.interfaces.sbIApplicationController);
224 switch ( evt.charCode )
227 if (
gMM.status.state == sbIMediacoreStatus.STATUS_PLAYING ||
228 gMM.status.state == sbIMediacoreStatus.STATUS_BUFFERING )
229 gMM.playbackControl.pause();
231 gMM.playbackControl.play();
241 onDblClick:
function onDblClick( evt )
243 dump(
"\nMiniplayer." +
arguments.callee.name +
"\n");
244 if (evt.target.localName ==
'sb-draggable') {
245 this.revertFeathers();
253 revertFeathers:
function revertFeathers()
257 var feathersMgr = Cc[
'@songbirdnest.com/songbird/feathersmanager;1']
258 .getService(Ci.sbIFeathersManager);
259 var skinName = feathersMgr.currentSkinName;
260 var layoutURL = feathersMgr.currentLayoutURL;
261 var nextLayout = this._getNextLayout();
265 if (nextLayout.url != layoutURL) {
266 feathersMgr.switchFeathers(nextLayout.url, skinName);
269 dump(
"revertFeathers(): Unable to switch to the " +
270 "next layout for the current skin.\n\n" +
271 " Error: " + e.toString() +
"\n");
275 _getNextLayout:
function getNextLayout()
277 var feathersMgr = Cc[
'@songbirdnest.com/songbird/feathersmanager;1']
278 .getService(Ci.sbIFeathersManager);
279 var skinName = feathersMgr.currentSkinName;
280 var layoutURL = feathersMgr.currentLayoutURL;
284 var
enum = feathersMgr.getLayoutsForSkin(skinName);
287 var nextLayout =
enum.getNext();
289 switchLayout = nextLayout;
290 if (nextLayout.QueryInterface(Ci.sbILayoutDescription).url == layoutURL
291 &&
enum.hasMoreElements())
293 switchlayout =
enum.getNext().QueryInterface(Ci.sbILayoutDescription);
312 GetMinWidth:
function()
314 var minWidth = getComputedStyle(document.documentElement,
"").minWidth;
315 return (minWidth ==
"none") ? -1 : parseInt(minWidth);
318 GetMinHeight:
function()
320 var minHeight = getComputedStyle(document.documentElement,
"").minHeight;
321 return (minHeight ==
"none") ? -1 : parseInt(minHeight);
324 GetMaxWidth:
function()
326 var maxWidth = getComputedStyle(document.documentElement,
"").maxWidth;
327 return (maxWidth ==
"none") ? -1 : parseInt(maxWidth);
330 GetMaxHeight:
function()
332 var maxHeight = getComputedStyle(document.documentElement,
"").maxHeight;
333 return (maxHeight ==
"none") ? -1 : parseInt(maxHeight);
336 OnWindowClose:
function()
343 if (!aIID.equals(Components.interfaces.sbIWindowMinMaxCallback) &&
344 !aIID.equals(Components.interfaces.nsISupportsWeakReference) &&
345 !aIID.equals(Components.interfaces.nsISupports))
347 throw Components.results.NS_ERROR_NO_INTERFACE;
365 _setMinMaxCallback:
function _setMinMaxCallback()
371 if (platform ==
"Windows_NT") {
372 var windowMinMax = Components.classes[
"@songbirdnest.com/Songbird/WindowMinMax;1"];
373 var
service = windowMinMax.getService(Components.interfaces.sbIWindowMinMax);
375 service.setCallback(document, this._minMaxHandler);
377 }
else if (platform ==
"Darwin") {
379 Cc[
"@songbirdnest.com/integration/native-window-manager;1"]
380 .getService(Ci.sbINativeWindowManager);
381 if (nativeWinMgr.supportsMinimumWindowSize) {
382 var minWidth = this._minMaxHandler.GetMinWidth();
383 var minHeight = this._minMaxHandler.GetMinHeight();
384 dump(
"min: " + minWidth +
" x " + minHeight +
"\n");
385 var cstyle =
window.getComputedStyle(document.documentElement,
'');
386 dump (
"document min: " + cstyle.minWidth +
"\n");
387 nativeWinMgr.setMinimumWindowSize(
window, minWidth, minHeight);
393 dump(
"Error. songbird_hack.js:setMinMaxCallback() \n " + err +
"\n");
398 _resetMinMaxCallback:
function _resetMinMaxCallback()
404 if (platform ==
"Windows_NT") {
405 var windowMinMax = Components.classes[
"@songbirdnest.com/Songbird/WindowMinMax;1"];
406 var service = windowMinMax.getService(Components.interfaces.sbIWindowMinMax);
407 service.resetCallback(document);
414 dump(
"Error. songbird_hack.js: SBUnitialize() \n" + err +
"\n");
424 _getPlatform:
function _getPlatform() {
428 Components.classes[
"@mozilla.org/system-info;1"]
429 .getService(Components.interfaces.nsIPropertyBag2);
430 platform = sysInfo.getProperty(
"name");
433 dump(
"System-info not available, trying the user agent string.\n");
434 var user_agent = navigator.userAgent;
435 if (user_agent.indexOf(
"Mac OS X") != -1)
445 _hasTitlebar:
function _hasTitlebar() {
448 window.QueryInterface(Components.interfaces.nsIInterfaceRequestor);
449 var webnav =
window.getInterface(Components.interfaces.nsIWebNavigation);
450 var treeItem = webnav.QueryInterface(Components.interfaces.nsIDocShellTreeItem);
451 var treeOwner = treeItem.treeOwner;
452 var requestor = treeOwner.QueryInterface(Components.interfaces.nsIInterfaceRequestor);
453 var windowChrome = requestor.getInterface(Components.interfaces.nsIWebBrowserChrome);
456 return windowChrome.chromeFlags & windowChrome.CHROME_TITLEBAR;
function SBFormattedString(aKey, aParams, aDefault, aStringBundle)
function getPlatformString()
Get the name of the platform we are running on.
sbOSDControlService prototype QueryInterface
function SBString(aKey, aDefault, aStringBundle)
aWindow setTimeout(function(){_this.restoreHistory(aWindow, aTabs, aTabData, aIdMap);}, 0)
return!aWindow arguments!aWindow arguments[0]
SimpleArrayEnumerator prototype hasMoreElements
function onUnload()
onUnload - called when the cover preview window unloads.