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/ArrayConverter.jsm");
35 Cu.import(
"resource://app/jsmodules/sbCoverHelper.jsm");
36 Cu.import(
"resource://app/jsmodules/SBJobUtils.jsm");
37 Cu.import(
"resource://app/jsmodules/sbLibraryUtils.jsm");
38 Cu.import(
"resource://app/jsmodules/sbProperties.jsm");
39 Cu.import(
"resource://app/jsmodules/StringUtils.jsm");
40 Cu.import(
"resource://gre/modules/XPCOMUtils.jsm");
59 TrackEditor.state.addPropertyListener(this.property,
this);
66 return this._element.getAttribute(
"property");
74 return this._element.disabled;
78 this._element.disabled =
val;
81 onTrackEditorPropertyChange:
function TrackEditorWidgetBase_onTrackEditorPropertyChange() {
83 if (value != this._element.value) {
84 this._element.value =
value;
104 function TrackEditorLabel(
element) {
107 if (
element.hasAttribute(
"property-type") &&
108 element.getAttribute(
"property-type") ==
"label") {
110 var propMan = Cc[
"@songbirdnest.com/Songbird/Properties/PropertyManager;1"]
111 .getService(Ci.sbIPropertyManager);
112 var propInfo = propMan.getPropertyInfo(
element.getAttribute(
"property"));
113 element.setAttribute(
"value", propInfo.displayName);
121 TrackEditorLabel.prototype = {
136 function TrackEditorURILabel(
element) {
137 TrackEditorLabel.call(
this,
element);
139 this._button = document.createElement(
"button");
140 this._button.setAttribute(
"class",
"goto-url");
143 this._button.addEventListener(
"command",
144 function() {
self.onButtonCommand(); },
false);
146 element.parentNode.insertBefore(this._button,
element.nextSibling);
148 TrackEditorURILabel.prototype = {
149 __proto__: TrackEditorLabel.prototype,
150 _ioService: Cc[
"@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService),
152 onTrackEditorPropertyChange:
function TrackEditorWidgetBase_onTrackEditorPropertyChange() {
155 var formattedValue =
value;
158 var
ioService = Cc[
"@mozilla.org/network/io-service;1"]
159 .getService(Ci.nsIIOService);
161 if (uri.scheme ==
"file") {
162 formattedValue = uri.QueryInterface(Ci.nsIFileURL).file.path;
169 if (formattedValue != this._element.value) {
170 this._element.value = formattedValue;
173 if (value != this._button.value) {
174 this._button.value =
value;
178 onButtonCommand:
function()
180 this.loadOrRevealURI(this._button.value);
183 loadOrRevealURI:
function(uriLocation)
185 var uri = this._ioService.newURI(uriLocation,
null,
null);
186 if (uri.scheme ==
"file") {
190 this.promptAndLoadURI(uriLocation);
194 revealURI:
function(
uri) {
196 var f = uri.QueryInterface(Ci.nsIFileURL).file.QueryInterface(Ci.nsILocalFile);
204 let parent = f.parent.QueryInterface(Ci.nsILocalFile);
214 openExternal(parent);
219 promptAndLoadURI:
function(uriLocation) {
220 var properties =
TrackEditor.state.getEnabledProperties();
223 for (var
i = 0;
i < properties.length;
i++) {
224 if (
TrackEditor.state.isPropertyEdited(properties[
i])) {
230 if (items.length == 0 || edits == 0) {
240 var titleMessage =
SBString(
"trackeditor.closewarning.title");
241 var dialogMessage =
SBString(
"trackeditor.closewarning.message");
242 var prompts = Components.classes[
"@mozilla.org/embedcomp/prompt-service;1"]
243 .getService(Components.interfaces.nsIPromptService);
244 var
flags = prompts.BUTTON_TITLE_DONT_SAVE * prompts.BUTTON_POS_0 +
245 prompts.BUTTON_TITLE_CANCEL * prompts.BUTTON_POS_1 +
246 prompts.BUTTON_TITLE_OK * prompts.BUTTON_POS_2;
249 var button = prompts.confirmEx(
window, titleMessage, dialogMessage, flags,
261 Components.utils.reportError(e);
274 TrackEditorURILabel.call(
this,
element);
275 TrackEditor.state.addPropertyListener(SBProperties.originPageTitle,
this);
278 __proto__: TrackEditorURILabel.prototype,
280 onTrackEditorPropertyChange:
function (property) {
282 if (property == SBProperties.originPage || !property) {
283 this.onTrackEditorPagePropertyChange();
285 if (property == SBProperties.originPageTitle || !property) {
286 this.onTrackEditorPageTitlePropertyChange();
288 if (property == SBProperties.originPageImage || !property) {
289 this.onTrackEditorPageImagePropertyChange();
293 onTrackEditorPagePropertyChange:
function() {
294 var value =
TrackEditor.state.getPropertyValue(this.property);
296 var formattedValue =
value;
299 var ioService = Cc[
"@mozilla.org/network/io-service;1"]
300 .getService(Ci.nsIIOService);
301 var uri = ioService.newURI(value,
null,
null);
302 if (uri.scheme ==
"file") {
303 formattedValue = uri.QueryInterface(Ci.nsIFileURL).file.path;
310 if (value != this._button.value) {
311 this._button.value =
value;
315 onTrackEditorPageTitlePropertyChange:
function() {
316 var title =
TrackEditor.state.getPropertyValue(SBProperties.originPageTitle);
317 if (title != this._element.title) {
318 this._element.value = title;
322 onTrackEditorPageImagePropertyChange:
function() {
341 function TrackEditorInputWidget(
element) {
351 this._createCheckbox();
353 TrackEditorInputWidget.prototype = {
360 _createCheckbox:
function() {
361 var hbox = document.createElement(
"hbox");
362 this._element.parentNode.replaceChild(hbox, this._element);
363 var flex = this._element.getAttribute(
"flex");
364 this._checkbox = document.createElement(
"checkbox");
368 if (this._element.hasAttribute(
"tabindex")) {
369 var value = parseInt(this._element.getAttribute(
"tabindex")) - 1;
370 this._checkbox.setAttribute(
"tabindex", value);
372 this._checkbox.hidden =
true;
375 this._checkbox.addEventListener(
"command",
376 function() {
self.onCheckboxCommand(); },
false);
378 hbox.appendChild(this._checkbox);
380 hbox.setAttribute(
"flex", flex);
382 hbox.appendChild(this._element);
386 this._checkbox.disabled =
val;
387 this._element.disabled =
val;
391 return this._element.parentNode.hidden;
395 this._element.parentNode.hidden =
val;
398 onCheckboxCommand:
function() {
399 TrackEditor.state.setPropertyEnabled(this.property, this._checkbox.checked);
400 if (this._checkbox.checked) {
401 this._elementStack.focus();
405 onTrackEditorSelectionChange:
function() {
406 this._checkbox.hidden =
TrackEditor.state.selectedItems.length <= 1;
410 this._checkbox.disabled =
true;
411 this._element.setAttribute(
"readonly",
"true");
412 this._element.setAttribute(
"tooltiptext",
413 SBString(
"trackeditor.tooltip.readonly"));
415 this._checkbox.disabled =
false;
416 this._element.disabled =
false;
417 this._element.removeAttribute(
"readonly");
418 this._element.removeAttribute(
"tooltiptext");
422 onTrackEditorPropertyChange:
function TrackEditorInputWidget_onTrackEditorPropertyChange() {
425 this._checkbox.checked =
TrackEditor.state.isPropertyEnabled(this.property);
439 function TrackEditorTextbox(
element) {
441 TrackEditorInputWidget.call(
this,
element);
444 element.addEventListener(
"input",
445 function() {
self.onUserInput(); },
false);
447 var propMan = Cc[
"@songbirdnest.com/Songbird/Properties/PropertyManager;1"]
448 .getService(Ci.sbIPropertyManager);
449 var propInfo = propMan.getPropertyInfo(this.property);
450 if (propInfo instanceof Ci.sbINumberPropertyInfo ||
451 this._element.getAttribute(
"isnumeric") ==
"true") {
452 this._isNumeric =
true;
453 this._minValue = propInfo.minValue;
454 this._maxValue = propInfo.maxValue;
455 this._maxDigits =
new String(this._maxValue).length;
457 element.addEventListener(
"keypress",
458 function(evt) {
self.onKeypress(evt); },
false);
461 TrackEditorTextbox.prototype = {
462 __proto__: TrackEditorInputWidget.prototype,
478 var value =
self._element.value;
479 TrackEditor.state.setPropertyValue(
self.property, value);
482 if (!
TrackEditor.state.isPropertyEnabled(
self.property)) {
483 TrackEditor.state.setPropertyEnabled(
self.property,
true);
488 onKeypress:
function(evt) {
491 if (this._isNumeric) {
492 if (!evt.ctrlKey && !evt.metaKey && !evt.altKey && evt.charCode) {
493 if (evt.charCode < 48 || evt.charCode > 57) {
494 evt.preventDefault();
496 }
else if (this._element.value.length + 1 >
this._maxDigits &&
497 this._element.selectionStart ==
this._element.selectionEnd) {
498 evt.preventDefault();
504 onTrackEditorSelectionChange:
function TrackEditorTextbox_onTrackEditorSelectionChange() {
505 TrackEditorInputWidget.prototype.onTrackEditorSelectionChange.call(
this);
507 if (this._element.getAttribute(
"type") ==
"autocomplete") {
508 this._configureAutoComplete();
512 onTrackEditorPropertyChange:
function TrackEditorTextbox_onTrackEditorPropertyChange() {
513 TrackEditorInputWidget.prototype.onTrackEditorPropertyChange.call(
this);
515 var
property = this.property;
518 if (
TrackEditor.state.hasMultipleValuesForProperty(
this.property)) {
519 this._element.setAttribute(
"tooltiptext",
SBString(
"trackeditor.tooltip.multiple"));
521 else if (this._element.getAttribute(
"tooltiptext") ==
522 SBString(
"trackeditor.tooltip.multiple")) {
523 this._element.removeAttribute(
"tooltiptext");
527 if (
TrackEditor.state.isPropertyEdited(
this.property)) {
528 if (!this._element.hasAttribute(
"edited")) {
529 this._element.setAttribute(
"edited",
"true");
532 if (this._element.hasAttribute(
"edited")) {
533 this._element.removeAttribute(
"edited");
538 var value =
TrackEditor.state.getPropertyValue(property);
539 if (this._element.defaultValue != value) {
540 this._element.defaultValue =
value;
541 this._element.reset();
546 if (
TrackEditor.state.isPropertyInvalidated(
this.property)) {
547 if (!this._element.hasAttribute(
"invalid")) {
548 this._element.setAttribute(
"invalid",
"true");
549 this._element.setAttribute(
"tooltiptext",
SBString(
"trackeditor.tooltip.invalid"));
551 }
else if (this._element.hasAttribute(
"invalid")) {
552 this._element.removeAttribute(
"invalid");
553 this._element.removeAttribute(
"tooltiptext");
557 _configureAutoComplete:
function TrackEditorTextbox__configureAutoComplete() {
571 var library =
TrackEditor.mediaListView.mediaList.library;
574 var libraryGuid = library.guid;
582 if (this._element.getAttribute(
"autocompletesearch")
583 .indexOf(
"library-distinct-properties") >= 0) {
584 var defvals = this._element.getAttribute(
"defaultdistinctproperties");
585 var param = this.property;
588 if (this.property == SBProperties.genre) {
589 var
LSP = Cc[
"@songbirdnest.com/servicepane/library;1"]
590 .getService(Ci.sbILibraryServicePaneService);
592 LSP.getNodeContentTypeFromMediaListView(
TrackEditor.mediaListView);
596 param +=
";" + libraryGuid;
597 if (defvals && defvals !=
"") {
598 param +=
";" + defvals;
600 this._element.setAttribute(
"autocompletesearchparam", param);
605 this._element.inputField.tabIndex = this._element.tabIndex;
609 var marker = this._element
611 .getAnonymousElementByAttribute(this._element,
613 "historydropmarker");
614 if (
"showPopup" in marker) {
618 function showPopup() {
619 var textbox = document.getBindingParent(
this);
620 textbox.showHistoryPopup();
624 if (uneval(showPopup) == uneval(marker.showPopup)) {
626 marker.showPopup =
function showPopup_hacked() {
627 var textbox = document.getBindingParent(
this);
629 textbox.showHistoryPopup();
634 dump(
"trackEditor - autocomplete marker showPopup mismatch!\n");
655 function TrackEditorRating(
element) {
657 TrackEditorInputWidget.call(
this,
element);
660 element.addEventListener(
"input",
661 function() {
self.onUserInput(); },
false);
664 TrackEditorRating.prototype = {
665 __proto__: TrackEditorInputWidget.prototype,
668 var value = this._element.value;
669 TrackEditor.state.setPropertyValue(this.property, value);
672 if (!
TrackEditor.state.isPropertyEnabled(
this.property)) {
673 TrackEditor.state.setPropertyEnabled(this.property,
true);
677 onTrackEditorPropertyChange:
function TrackEditorRating_onTrackEditorPropertyChange() {
678 var
property = this.property;
681 if (
TrackEditor.state.isPropertyEdited(
this.property))
683 if (!this._element.hasAttribute(
"edited")) {
684 this._element.setAttribute(
"edited",
"true");
686 }
else if (this._element.hasAttribute(
"edited")) {
687 this._element.removeAttribute(
"edited");
690 TrackEditorInputWidget.prototype.onTrackEditorPropertyChange.call(
this);
693 this._checkbox.disabled =
false;
694 this._element.disabled =
false;
695 this._element.removeAttribute(
"readonly");
696 this._element.removeAttribute(
"tooltiptext");
sbDeviceFirmwareAutoCheckForUpdate prototype flags
function SBString(aKey, aDefault, aStringBundle)
this _dialogInput val(dateText)
aWindow setTimeout(function(){_this.restoreHistory(aWindow, aTabs, aTabData, aIdMap);}, 0)
_getSelectedPageStyle s i