B2G/gecko/browser/components/places/content/bookmarkProperties.js
/**
   * Determines the initial data for the item edited or added by this dialog
   */
Determines the initial data for the item edited or added by this dialog
Determines the initial data for the item edited or added by this dialog
function BPP__determineItemInfo() {
    var dialogInfo = window.arguments[0];
    this._action = dialogInfo.action == "add" ? ACTION_ADD : ACTION_EDIT;
    this._hiddenRows = dialogInfo.hiddenRows ? dialogInfo.hiddenRows : [];
    if (this._action == ACTION_ADD) {
      NS_ASSERT("type" in dialogInfo, "missing type property for add action");
      if ("title" in dialogInfo)
        this._title = dialogInfo.title;
      if ("defaultInsertionPoint" in dialogInfo) {
        this._defaultInsertionPoint = dialogInfo.defaultInsertionPoint;
      }
      else
        this._defaultInsertionPoint =
          new InsertionPoint(PlacesUtils.bookmarksMenuFolderId,
                             PlacesUtils.bookmarks.DEFAULT_INDEX,
                             Ci.nsITreeView.DROP_ON);
      switch (dialogInfo.type) {
        case "bookmark":
          this._itemType = BOOKMARK_ITEM;
          if ("uri" in dialogInfo) {
            NS_ASSERT(dialogInfo.uri instanceof Ci.nsIURI,
                      "uri property should be a uri object");
            this._uri = dialogInfo.uri;
            if (typeof(this._title) != "string") {
              this._title = this._getURITitleFromHistory(this._uri) ||
                            this._uri.spec;
            }
          }
          else {
            this._uri = PlacesUtils._uri("about:blank");
            this._title = this._strings.getString("newBookmarkDefault");
            this._dummyItem = true;
          }
          if ("loadBookmarkInSidebar" in dialogInfo)
            this._loadInSidebar = dialogInfo.loadBookmarkInSidebar;
          if ("keyword" in dialogInfo) {
            this._keyword = dialogInfo.keyword;
            this._isAddKeywordDialog = true;
            if ("postData" in dialogInfo)
              this._postData = dialogInfo.postData;
            if ("charSet" in dialogInfo)
              this._charSet = dialogInfo.charSet;
          }
          break;
        case "folder":
          this._itemType = BOOKMARK_FOLDER;
          if (!this._title) {
            if ("URIList" in dialogInfo) {
              this._title = this._strings.getString("bookmarkAllTabsDefault");
              this._URIs = dialogInfo.URIList;
            }
            else
              this._title = this._strings.getString("newFolderDefault");
              this._dummyItem = true;
          }
          break;
        case "livemark":
          this._itemType = LIVEMARK_CONTAINER;
          if ("feedURI" in dialogInfo)
            this._feedURI = dialogInfo.feedURI;
          if ("siteURI" in dialogInfo)
            this._siteURI = dialogInfo.siteURI;
          if (!this._title) {
            if (this._feedURI) {
              this._title = this._getURITitleFromHistory(this._feedURI) ||
                            this._feedURI.spec;
            }
            else
              this._title = this._strings.getString("newLivemarkDefault");
          }
      }
      if ("description" in dialogInfo)
        this._description = dialogInfo.description;
    }
    else { 
      NS_ASSERT("itemId" in dialogInfo);
      this._itemId = dialogInfo.itemId;
      this._title = PlacesUtils.bookmarks.getItemTitle(this._itemId);
      this._readOnly = !!dialogInfo.readOnly;
      switch (dialogInfo.type) {
        case "bookmark":
          this._itemType = BOOKMARK_ITEM;
          this._uri = PlacesUtils.bookmarks.getBookmarkURI(this._itemId);
          this._keyword = PlacesUtils.bookmarks
                                     .getKeywordForBookmark(this._itemId);
          this._loadInSidebar = PlacesUtils.annotations
                                           .itemHasAnnotation(this._itemId,
                                                              PlacesUIUtils.LOAD_IN_SIDEBAR_ANNO);
          break;
        case "folder":
          this._itemType = BOOKMARK_FOLDER;
          PlacesUtils.livemarks.getLivemark(
            { id: this._itemId },
            (function (aStatus, aLivemark) {
              if (Components.isSuccessCode(aStatus)) {
                this._itemType = LIVEMARK_CONTAINER;
                this._feedURI = aLivemark.feedURI;
                this._siteURI = aLivemark.siteURI;
                this._fillEditProperties();
                let acceptButton = document.documentElement.getButton("accept");
                acceptButton.disabled = !this._inputIsValid();
                let newHeight = window.outerHeight +
                                this._element("descriptionField").boxObject.height;
                window.resizeTo(window.outerWidth, newHeight);
              }
            }).bind(this)
          );
          break;
      }
      if (PlacesUtils.annotations
                     .itemHasAnnotation(this._itemId, PlacesUIUtils.DESCRIPTION_ANNO)) {
        this._description = PlacesUtils.annotations
                                       .getItemAnnotation(this._itemId,
                                                          PlacesUIUtils.DESCRIPTION_ANNO);
      }
    }
  }
function BPP__determineItemInfo ( ) { var dialogInfo = window . arguments [ 0 ] ; this . _action = dialogInfo . action == "add" ? ACTION_ADD : ACTION_EDIT ; this . _hiddenRows = dialogInfo . hiddenRows ? dialogInfo . hiddenRows : [ ] ; if ( this . _action == ACTION_ADD ) { NS_ASSERT ( "type" in dialogInfo , "missing type property for add action" ) ; if ( "title" in dialogInfo ) this . _title = dialogInfo . title ; if ( "defaultInsertionPoint" in dialogInfo ) { this . _defaultInsertionPoint = dialogInfo . defaultInsertionPoint ; } else this . _defaultInsertionPoint = new InsertionPoint ( PlacesUtils . bookmarksMenuFolderId , PlacesUtils . bookmarks . DEFAULT_INDEX , Ci . nsITreeView . DROP_ON ) ; switch ( dialogInfo . type ) { case "bookmark" : this . _itemType = BOOKMARK_ITEM ; if ( "uri" in dialogInfo ) { NS_ASSERT ( dialogInfo . uri instanceof Ci . nsIURI , "uri property should be a uri object" ) ; this . _uri = dialogInfo . uri ; if ( typeof ( this . _title ) != "string" ) { this . _title = this . _getURITitleFromHistory ( this . _uri ) || this . _uri . spec ; } } else { this . _uri = PlacesUtils . _uri ( "about:blank" ) ; this . _title = this . _strings . getString ( "newBookmarkDefault" ) ; this . _dummyItem = true ; } if ( "loadBookmarkInSidebar" in dialogInfo ) this . _loadInSidebar = dialogInfo . loadBookmarkInSidebar ; if ( "keyword" in dialogInfo ) { this . _keyword = dialogInfo . keyword ; this . _isAddKeywordDialog = true ; if ( "postData" in dialogInfo ) this . _postData = dialogInfo . postData ; if ( "charSet" in dialogInfo ) this . _charSet = dialogInfo . charSet ; } break ; case "folder" : this . _itemType = BOOKMARK_FOLDER ; if ( ! this . _title ) { if ( "URIList" in dialogInfo ) { this . _title = this . _strings . getString ( "bookmarkAllTabsDefault" ) ; this . _URIs = dialogInfo . URIList ; } else this . _title = this . _strings . getString ( "newFolderDefault" ) ; this . _dummyItem = true ; } break ; case "livemark" : this . _itemType = LIVEMARK_CONTAINER ; if ( "feedURI" in dialogInfo ) this . _feedURI = dialogInfo . feedURI ; if ( "siteURI" in dialogInfo ) this . _siteURI = dialogInfo . siteURI ; if ( ! this . _title ) { if ( this . _feedURI ) { this . _title = this . _getURITitleFromHistory ( this . _feedURI ) || this . _feedURI . spec ; } else this . _title = this . _strings . getString ( "newLivemarkDefault" ) ; } } if ( "description" in dialogInfo ) this . _description = dialogInfo . description ; } else { NS_ASSERT ( "itemId" in dialogInfo ) ; this . _itemId = dialogInfo . itemId ; this . _title = PlacesUtils . bookmarks . getItemTitle ( this . _itemId ) ; this . _readOnly = ! ! dialogInfo . readOnly ; switch ( dialogInfo . type ) { case "bookmark" : this . _itemType = BOOKMARK_ITEM ; this . _uri = PlacesUtils . bookmarks . getBookmarkURI ( this . _itemId ) ; this . _keyword = PlacesUtils . bookmarks . getKeywordForBookmark ( this . _itemId ) ; this . _loadInSidebar = PlacesUtils . annotations . itemHasAnnotation ( this . _itemId , PlacesUIUtils . LOAD_IN_SIDEBAR_ANNO ) ; break ; case "folder" : this . _itemType = BOOKMARK_FOLDER ; PlacesUtils . livemarks . getLivemark ( { id : this . _itemId } , ( function ( aStatus , aLivemark ) { if ( Components . isSuccessCode ( aStatus ) ) { this . _itemType = LIVEMARK_CONTAINER ; this . _feedURI = aLivemark . feedURI ; this . _siteURI = aLivemark . siteURI ; this . _fillEditProperties ( ) ; let acceptButton = document . documentElement . getButton ( "accept" ) ; acceptButton . disabled = ! this . _inputIsValid ( ) ; let newHeight = window . outerHeight + this . _element ( "descriptionField" ) . boxObject . height ; window . resizeTo ( window . outerWidth , newHeight ) ; } } ) . bind ( this ) ) ; break ; } if ( PlacesUtils . annotations . itemHasAnnotation ( this . _itemId , PlacesUIUtils . DESCRIPTION_ANNO ) ) { this . _description = PlacesUtils . annotations . getItemAnnotation ( this . _itemId , PlacesUIUtils . DESCRIPTION_ANNO ) ; } } }
Determines the initial data for the item edited or added by this dialog
Determines the initial data for the item edited or added by this dialog
// edit // keyword // Load In Sidebar // Description