playlistPage.js
Go to the documentation of this file.
1 /*
2  *=BEGIN SONGBIRD GPL
3  *
4  * This file is part of the Songbird web player.
5  *
6  * Copyright(c) 2005-2009 POTI, Inc.
7  * http://www.songbirdnest.com
8  *
9  * This file may be licensed under the terms of of the
10  * GNU General Public License Version 2 (the ``GPL'').
11  *
12  * Software distributed under the License is distributed
13  * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
14  * express or implied. See the GPL for the specific language
15  * governing rights and limitations.
16  *
17  * You should have received a copy of the GPL along with this
18  * program. If not, go to http://www.gnu.org/licenses/gpl.html
19  * or write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21  *
22  *=END SONGBIRD GPL
23  */
24 
25 
26 if (typeof(Cc) == "undefined")
27  window.Cc = Components.classes;
28 if (typeof(Ci) == "undefined")
29  window.Ci = Components.interfaces;
30 if (typeof(Cu) == "undefined")
31  window.Cu = Components.utils;
32 if (typeof(Cr) == "undefined")
33  window.Cr = Components.results;
34 
35 
36 Cu.import("resource://app/jsmodules/sbProperties.jsm");
37 Cu.import("resource://app/jsmodules/sbLibraryUtils.jsm");
38 Cu.import("resource://app/jsmodules/kPlaylistCommands.jsm");
39 
52 window.mediaPage = {
53 
54  // The sbIMediaListView that this page is to display
55  _mediaListView: null,
56 
57  // The sb-playlist XBL binding
58  _playlist: null,
59 
60 
64  get mediaListView() {
65  return this._mediaListView;
66  },
67 
68 
74  set mediaListView(value) {
75 
76  if (!this._mediaListView) {
77  this._mediaListView = value;
78  } else {
79  throw new Error("mediaListView may only be set once. Please reload the page");
80  }
81  },
82 
83 
87  get isOnlyView() false,
88 
89 
95  onLoad: function(e) {
96  if (!this._mediaListView) {
97  Components.utils.reportError("playlistPage.xul did not receive " +
98  "a mediaListView before the onload event!");
99  return;
100  }
101 
102  var servicePaneNode =
103  Cc["@songbirdnest.com/servicepane/library;1"]
104  .getService(Ci.sbILibraryServicePaneService)
105  .getNodeFromMediaListView(this._mediaListView);
106  if (servicePaneNode) {
107  document.title = servicePaneNode.displayName;
108  }
109  else {
110  // failed to find the node, stick with the media list name
111  document.title = this._mediaListView.mediaList.name;
112  }
113 
114  this._playlist = document.getElementById("playlist");
115 
116  // Clear the playlist filters. This is a filter-free view.
117  this._clearFilterLists();
118 
119  // Get playlist commands (context menu, keyboard shortcuts, toolbar)
120  // Note: playlist commands currently depend on the playlist widget.
121  var mgr =
122  Components.classes["@songbirdnest.com/Songbird/PlaylistCommandsManager;1"]
123  .createInstance(Components.interfaces.sbIPlaylistCommandsManager);
124  var cmds = mgr.request(kPlaylistCommands.MEDIAITEM_DEFAULT);
125 
126  // Set up the playlist widget
127  this._playlist.bind(this._mediaListView, cmds);
128  },
129 
130 
134  onUnload: function(e) {
135  if (this._playlist) {
136  this._playlist.destroy();
137  this._playlist = null;
138  }
139  },
140 
141 
146  highlightItem: function(aIndex) {
147  this._playlist.highlightItem(aIndex);
148  },
149 
150 
154  canDrop: function(aEvent, aSession) {
155  return this._playlist._canDrop(aEvent);
156  },
157 
158 
162  onDrop: function(aEvent, aSession) {
163  return this._playlist.
164  _dropOnTree(-1,
165  Ci.sbIMediaListViewTreeViewObserver.DROP_AFTER,
166  aSession);
167  },
168 
169 
170 
175  _parseQueryString: function() {
176  var queryString = (location.search || "?").substr(1).split("&");
177  var queryObject = {};
178  var key, value;
179  for each (var pair in queryString) {
180  [key, value] = pair.split("=");
181  queryObject[key] = unescape(value);
182  }
183  return queryObject;
184  },
185 
186 
190  _clearFilterLists: function() {
191  // Don't use filters for this version. We'll clear them out.
192  var filters = this._mediaListView.cascadeFilterSet;
193 
194  for (var i = filters.length - 1; i > 0; i--) {
195  filters.remove(i);
196  }
197  if (filters.length == 0 || !filters.isSearch(0)) {
198  if (filters.length == 1) {
199  filters.remove(0);
200  }
201  filters.appendSearch(["*"], 1);
202  }
203  }
204 
205 } // End window.mediaPage
206 
207 
const Cu
const Cc
let window
Lastfm onLoad
Definition: mini.js:36
this _document false
Definition: FeedWriter.js:1085
return null
Definition: FeedWriter.js:1143
countRef value
Definition: FeedWriter.js:1423
const Cr
const Ci
function onUnload()
onUnload - called when the cover preview window unloads.
Definition: coverPreview.js:36
_getSelectedPageStyle s i