28 var
Cc = Components.classes;
29 var
Ci = Components.interfaces;
30 var
Cu = Components.utils;
31 var
Cr = Components.results;
33 Cu.import(
"resource://app/jsmodules/sbProperties.jsm");
34 Cu.import(
"resource://app/jsmodules/sbLibraryUtils.jsm");
35 Cu.import(
"resource://app/jsmodules/kPlaylistCommands.jsm");
36 Cu.import(
"resource://app/jsmodules/SBDataRemoteUtils.jsm");
65 return this._mediaListView;
74 set mediaListView(
value) {
76 if (!this._mediaListView) {
77 this._mediaListView =
value;
79 throw new Error(
"mediaListView may only be set once. Please reload the page");
87 get isOnlyView()
false,
96 if (!this._mediaListView) {
97 Components.utils.reportError(
"playlistPage.xul did not receive " +
98 "a mediaListView before the onload event!");
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;
111 document.title = this._mediaListView.mediaList.name;
114 this._playlist = document.getElementById(
"playlist");
117 this._updateFilterLists();
118 this._generateFilters();
123 Components.classes[
"@songbirdnest.com/Songbird/PlaylistCommandsManager;1"]
124 .createInstance(Components.interfaces.sbIPlaylistCommandsManager);
125 var cmds = mgr.request(kPlaylistCommands.MEDIAITEM_DEFAULT);
128 this._playlist.bind(this._mediaListView, cmds);
134 if (!prefs.has(
"songbird.splitter.sb-playlist-splitter.before.height") &&
135 !prefs.has(
"songbird.splitter.sb-playlist-splitter.after.height"))
137 var splitter = document.getElementById(
"sb-playlist-splitter");
139 var page = document.getElementById(
"sb-playlist-media-page");
140 var pageHeight = page.boxObject.height;
143 const FILTER_COVER_AREA = 0.30;
144 var splitFactor = parseInt(pageHeight * FILTER_COVER_AREA);
147 var filterTree = document.getElementById(
"sb-filterlist-tree");
148 var rowLineHeight = parseInt(getComputedStyle(filterTree,
"").lineHeight);
149 if (splitFactor % rowLineHeight != 0) {
150 splitFactor = rowLineHeight * (Math.round(splitFactor / rowLineHeight));
154 splitter.setBeforeHeight(splitFactor);
155 splitter.setAfterHeight(pageHeight - splitFactor);
165 for (var s = 0; s < this._splitters.length; s++) {
166 this._splitters[s].removeEventListener(
"mousemove", this._onFilterSplitterMove,
true);
167 this._splitters[s].removeEventListener(
"mousedown", this._onFilterSplitterDown,
true);
168 this._splitters[s].removeEventListener(
"mouseup", this._onFilterSplitterUp,
true);
171 if (this._playlist) {
172 this._playlist.destroy();
173 this._playlist =
null;
182 highlightItem:
function(aIndex) {
183 this._playlist.highlightItem(aIndex);
189 canDrop:
function(aEvent, aSession) {
190 return this._playlist._canDrop(aEvent);
196 onDrop:
function(aEvent, aSession) {
197 return this._playlist.
199 Ci.sbIMediaListViewTreeViewObserver.DROP_AFTER,
207 _parseQueryString:
function() {
208 var queryString = (location.search ||
"?").substr(1).split(
"&");
209 var queryObject = {};
211 for each (var pair
in queryString) {
221 _updateFilterLists:
function() {
226 var queryString = this._parseQueryString();
228 var filters = this._mediaListView.cascadeFilterSet;
232 if (filters.length <= 1) {
235 if ( filterSet.length > 0 ) {
236 filterSet = filterSet.split(
";");
243 var defaultFilterSet = [
245 SBProperties.artistName,
246 SBProperties.albumName
248 for (var
i = filterSet.length;
i < defaultFilterSet.length;
i++) {
249 filterSet.push(defaultFilterSet[
i]);
252 for each (var
filter in filterSet) {
253 filters.appendFilter(filter);
261 _generateFilters:
function() {
263 var psplitter = document.getElementById(
"sb-playlist-splitter");
264 psplitter.setAttribute(
"hidden",
"true");
267 var parent = document.getElementById(
"sb-playlist-filters");
268 while (parent.firstChild) {
269 parent.removeChild(parent.firstChild);
273 var cfs = this.mediaListView.cascadeFilterSet;
274 var length = cfs.length;
277 for (var
i = 0;
i < length;
i++) {
279 if (cfs.isSearch(
i)) {
284 var
XUL_NS =
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
285 var filterlist = document.createElementNS(XUL_NS,
"sb-filterlist");
286 filterlist.setAttribute(
"enableColumnDrag",
"false");
287 filterlist.setAttribute(
"flex",
"1");
289 if (this.mediaListView instanceof
Ci.sbIFilterableMediaListView) {
290 let constraint = this.mediaListView.filterConstraint;
292 for (let
group in ArrayConverter.JSEnum(constraint.groups)) {
293 if (!(
group instanceof
Ci.sbILibraryConstraintGroup )) {
296 if (!
group.hasProperty(SBProperties.contentType)) {
300 ArrayConverter.JSArray(
group.getValues(SBProperties.contentType));
301 if (types.length == 1) {
302 filterlist.setAttribute(
"filter-category-value", types[0]);
309 parent.appendChild(filterlist);
311 filterlist.bind(this.mediaListView,
i);
312 filters.push(filterlist);
314 if (
i < length - 1) {
315 var splitter = document.createElement(
"sb-smart-splitter");
316 splitter.setAttribute(
"id",
"filter_splitter" );
317 splitter.setAttribute(
"stateid",
"filter_splitter_" + cfs.getProperty(
i) + this.mediaListView.mediaList.guid );
318 splitter.setAttribute(
"state",
"open");
319 splitter.setAttribute(
"resizebefore",
"closest");
320 splitter.setAttribute(
"resizeafter",
"closest");
321 splitter.setAttribute(
"collapse",
"never");
323 var grippy = document.createElement(
"grippy" );
324 splitter.appendChild(grippy);
326 this._splitters.push(splitter);
335 for (var s=0;s<this._splitters.length;s++) {
336 var splitter = this._splitters[s];
337 parent.insertBefore(splitter, filters[s+1]);
341 if (!parent.firstChild) {
342 parent.setAttribute(
"hidden",
"true");
345 psplitter.removeAttribute(
"hidden");
function SBDataGetStringValue(aKey)
Get the value of the data in string format.
function onUnload()
onUnload - called when the cover preview window unloads.
_getSelectedPageStyle s i
Array filter(tab.attributes, function(aAttr){return(_this.xulAttributes.indexOf(aAttr.name) >-1);}).forEach(tab.removeAttribute