108 if (!this.__strings) {
109 this.__strings = document.getElementById(
"stringBundle");
111 return this.__strings;
118 _loadInSidebar:
false,
128 _defaultInsertionPoint:
null,
137 _getAcceptLabel:
function BPP__getAcceptLabel() {
139 if (this._URIs.length)
140 return this._strings.getString(
"dialogAcceptLabelAddMulti");
143 return this._strings.getString(
"dialogAcceptLabelAddLivemark");
145 if (this._dummyItem || this._loadInSidebar)
146 return this._strings.getString(
"dialogAcceptLabelAddItem");
148 return this._strings.getString(
"dialogAcceptLabelSaveItem");
150 return this._strings.getString(
"dialogAcceptLabelEdit");
157 _getDialogTitle:
function BPP__getDialogTitle() {
160 return this._strings.getString(
"dialogTitleAddBookmark");
162 return this._strings.getString(
"dialogTitleAddLivemark");
166 if (this._URIs.length)
167 return this._strings.getString(
"dialogTitleAddMulti");
169 return this._strings.getString(
"dialogTitleAddFolder");
172 return this._strings.getFormattedString(
"dialogTitleEdit", [this._title]);
180 _determineItemInfo:
function BPP__determineItemInfo() {
181 var dialogInfo =
window.arguments[0];
183 this._hiddenRows = dialogInfo.hiddenRows ? dialogInfo.hiddenRows : [];
185 NS_ASSERT(
"type" in dialogInfo,
"missing type property for add action");
187 if (
"title" in dialogInfo)
188 this._title = dialogInfo.title;
190 if (
"defaultInsertionPoint" in dialogInfo) {
191 this._defaultInsertionPoint = dialogInfo.defaultInsertionPoint;
194 this._defaultInsertionPoint =
196 PlacesUtils.bookmarks.DEFAULT_INDEX,
197 Ci.nsITreeView.DROP_ON);
199 switch(dialogInfo.type) {
202 if (
"uri" in dialogInfo) {
204 "uri property should be a uri object");
205 this._uri = dialogInfo.uri;
206 if (typeof(this._title) !=
"string") {
207 this._title = this._getURITitleFromHistory(this._uri) ||
212 this._uri = PlacesUtils._uri(
"about:blank");
213 this._title = this._strings.getString(
"newBookmarkDefault");
214 this._dummyItem =
true;
217 if (
"loadBookmarkInSidebar" in dialogInfo)
218 this._loadInSidebar = dialogInfo.loadBookmarkInSidebar;
220 if (
"keyword" in dialogInfo) {
221 this._keyword = dialogInfo.keyword;
222 this._isAddKeywordDialog =
true;
223 if (
"postData" in dialogInfo)
224 this._postData = dialogInfo.postData;
225 if (
"charSet" in dialogInfo)
226 this._charSet = dialogInfo.charSet;
233 if (
"URIList" in dialogInfo) {
234 this._title = this._strings.getString(
"bookmarkAllTabsDefault");
235 this._URIs = dialogInfo.URIList;
238 this._title = this._strings.getString(
"newFolderDefault");
239 this._dummyItem =
true;
245 if (
"feedURI" in dialogInfo)
247 if (
"siteURI" in dialogInfo)
248 this._siteURI = dialogInfo.siteURI;
252 this._title = this._getURITitleFromHistory(this.
_feedURI) ||
256 this._title = this._strings.getString(
"newLivemarkDefault");
260 if (
"description" in dialogInfo)
261 this._description = dialogInfo.description;
265 this._itemId = dialogInfo.itemId;
266 this._title = PlacesUtils.bookmarks.getItemTitle(this._itemId);
268 this._hiddenRows.push(
"folderPicker");
269 this._readOnly = !!dialogInfo.readOnly;
271 switch (dialogInfo.type) {
275 this._uri = PlacesUtils.bookmarks.getBookmarkURI(this._itemId);
277 this._keyword = PlacesUtils.bookmarks
278 .getKeywordForBookmark(this._itemId);
280 this._loadInSidebar = PlacesUtils.annotations
281 .itemHasAnnotation(this._itemId,
286 if (PlacesUtils.itemIsLivemark(
this._itemId)) {
288 this.
_feedURI = PlacesUtils.livemarks.getFeedURI(this._itemId);
289 this._siteURI = PlacesUtils.livemarks.getSiteURI(this._itemId);
297 if (PlacesUtils.annotations
299 this._description = PlacesUtils.annotations
300 .getItemAnnotation(this._itemId,
317 _getURITitleFromHistory:
function BPP__getURITitleFromHistory(aURI) {
321 return PlacesUtils.history.getPageTitle(aURI);
328 onDialogLoad:
function BPP_onDialogLoad() {
329 this._determineItemInfo();
331 document.title = this._getDialogTitle();
332 var acceptButton = document.documentElement.getButton(
"accept");
333 acceptButton.label = this._getAcceptLabel();
337 switch (this._action) {
339 this._fillEditProperties();
340 acceptButton.disabled = this._readOnly;
343 this._fillAddProperties();
348 acceptButton.disabled = !this._inputIsValid();
357 if (!this._element(
"tagsRow").collapsed) {
358 this._element(
"tagsSelectorRow")
359 .addEventListener(
"DOMAttrModified",
this,
false);
361 if (!this._element(
"folderRow").collapsed) {
362 this._element(
"folderTreeRow")
363 .addEventListener(
"DOMAttrModified",
this,
false);
366 if (!this._readOnly) {
369 this._element(
"locationField")
370 .addEventListener(
"input",
this,
false);
371 if (this._isAddKeywordDialog) {
372 this._element(
"keywordField")
373 .addEventListener(
"input",
this,
false);
377 this._element(
"feedLocationField")
378 .addEventListener(
"input",
this,
false);
379 this._element(
"siteLocationField")
380 .addEventListener(
"input",
this,
false);
389 handleEvent:
function BPP_handleEvent(aEvent) {
390 var
target = aEvent.target;
391 switch (aEvent.type) {
393 if (target.id ==
"editBMPanel_locationField" ||
394 target.id ==
"editBMPanel_feedLocationField" ||
395 target.id ==
"editBMPanel_siteLocationField" ||
396 target.id ==
"editBMPanel_keywordField") {
398 document.documentElement
399 .getButton(
"accept").disabled = !this._inputIsValid();
403 case "DOMAttrModified":
406 if ((target.id ==
"editBMPanel_tagsSelectorRow" ||
407 target.id ==
"editBMPanel_folderTreeRow") &&
408 aEvent.attrName ==
"collapsed" &&
409 target == aEvent.originalTarget) {
411 var newHeight =
window.outerHeight;
413 newHeight -= this._elementsHeight[
id];
415 this._elementsHeight[
id] = target.boxObject.height;
416 newHeight += this._elementsHeight[
id];
425 _beginBatch:
function BPP__beginBatch() {
430 this._batching =
true;
433 _endBatch:
function BPP__endBatch() {
438 this._batching =
false;
441 _fillEditProperties:
function BPP__fillEditProperties() {
443 { hiddenRows: this._hiddenRows,
444 forceReadOnly: this._readOnly });
447 _fillAddProperties:
function BPP__fillAddProperties() {
448 this._createNewItem();
451 { hiddenRows: this._hiddenRows });
455 var locationField = this._element(
"locationField");
456 if (locationField.value ==
"about:blank")
457 locationField.value =
"";
462 if (aIID.equals(
Ci.nsIDOMEventListener) ||
463 aIID.equals(
Ci.nsISupports))
466 throw Cr.NS_NOINTERFACE;
469 _element:
function BPP__element(aID) {
470 return document.getElementById(
"editBMPanel_" + aID);
473 onDialogUnload:
function BPP_onDialogUnload() {
477 this._element(
"tagsSelectorRow")
478 .removeEventListener(
"DOMAttrModified",
this,
false);
479 this._element(
"folderTreeRow")
480 .removeEventListener(
"DOMAttrModified",
this,
false);
481 this._element(
"locationField")
482 .removeEventListener(
"input",
this,
false);
483 this._element(
"feedLocationField")
484 .removeEventListener(
"input",
this,
false);
485 this._element(
"siteLocationField")
486 .removeEventListener(
"input",
this,
false);
489 onDialogAccept:
function BPP_onDialogAccept() {
491 document.commandDispatcher.focusedElement.blur();
497 window.arguments[0].performed =
true;
500 onDialogCancel:
function BPP_onDialogCancel() {
508 window.arguments[0].performed =
false;
516 _inputIsValid:
function BPP__inputIsValid() {
518 !this._containsValidURI(
"locationField"))
520 if (this._isAddKeywordDialog && !this._element(
"keywordField").
value.length)
526 if (!this._containsValidURI(
"feedLocationField"))
528 if (!this._containsValidURI(
"siteLocationField") &&
529 (this._element(
"siteLocationField").
value.length > 0))
545 _containsValidURI:
function BPP__containsValidURI(aTextboxID) {
547 var
value = this._element(aTextboxID).value;
563 _getInsertionPointDetails:
function BPP__getInsertionPointDetails() {
564 var containerId = this._defaultInsertionPoint.itemId;
565 var indexInContainer = this._defaultInsertionPoint.index;
567 return [containerId, indexInContainer];
574 _getCreateNewBookmarkTransaction:
575 function BPP__getCreateNewBookmarkTransaction(aContainer, aIndex) {
576 var annotations = [];
577 var childTransactions = [];
579 if (this._description) {
580 childTransactions.push(
581 PlacesUIUtils.ptm.editItemDescription(-1,
this._description));
584 if (this._loadInSidebar) {
585 childTransactions.push(
586 PlacesUIUtils.ptm.setLoadInSidebar(-1,
this._loadInSidebar));
589 if (this._postData) {
590 childTransactions.push(
596 PlacesUtils.history.setCharsetForURI(this._uri, this._charSet);
600 this._title, this._keyword,
604 return PlacesUIUtils.ptm.aggregateTransactions(this._getDialogTitle(),
612 _getTransactionsForURIList:
function BPP__getTransactionsForURIList() {
613 var transactions = [];
614 for (var
i = 0;
i < this._URIs.length; ++
i) {
615 var
uri = this._URIs[
i];
616 var title = this._getURITitleFromHistory(uri);
617 transactions.push(
PlacesUIUtils.ptm.createItem(uri, -1, -1, title));
626 _getCreateNewFolderTransaction:
627 function BPP__getCreateNewFolderTransaction(aContainer, aIndex) {
628 var annotations = [];
629 var childItemsTransactions;
630 if (this._URIs.length)
631 childItemsTransactions = this._getTransactionsForURIList();
633 if (this._description)
634 annotations.push(this._getDescriptionAnnotation(this._description));
636 return PlacesUIUtils.ptm.createFolder(this._title, aContainer, aIndex,
637 annotations, childItemsTransactions);
644 _getCreateNewLivemarkTransaction:
645 function BPP__getCreateNewLivemarkTransaction(aContainer, aIndex) {
654 _createNewItem:
function BPP__getCreateItemTransaction() {
655 var [container, index] = this._getInsertionPointDetails();
658 switch (this._itemType) {
660 txn = this._getCreateNewFolderTransaction(container, index);
663 txn = this._getCreateNewLivemarkTransaction(container, index);
666 txn = this._getCreateNewBookmarkTransaction(container, index);
670 this._itemId = PlacesUtils.bookmarks.getIdForItemAt(container, index);
sbOSDControlService prototype QueryInterface
var BookmarkPropertiesPanel
function NS_ASSERT(cond, msg)
#define LOAD_IN_SIDEBAR_ANNO
function InsertionPoint(aItemId, aIndex, aOrientation, aIsTag, aDropNearItemId)
_getSelectedPageStyle s i