browser/components/places/content/moveBookmarks.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 var gMoveBookmarksDialog = {
     7   _nodes: null,
     9   _foldersTree: null,
    10   get foldersTree() {
    11     if (!this._foldersTree)
    12       this._foldersTree = document.getElementById("foldersTree");
    14     return this._foldersTree;
    15   },
    17   init: function() {
    18     this._nodes = window.arguments[0];
    20     this.foldersTree.place =
    21       "place:excludeItems=1&excludeQueries=1&excludeReadOnlyFolders=1&folder=" +
    22       PlacesUIUtils.allBookmarksFolderId;
    23   },
    25   onOK: function MBD_onOK(aEvent) {
    26     let selectedNode = this.foldersTree.selectedNode;
    27     let selectedFolderId = PlacesUtils.getConcreteItemId(selectedNode);
    29     if (!PlacesUIUtils.useAsyncTransactions) {
    30       let transactions = [];
    31       for (var i=0; i < this._nodes.length; i++) {
    32         // Nothing to do if the node is already under the selected folder
    33         if (this._nodes[i].parent.itemId == selectedFolderId)
    34           continue;
    36         let txn = new PlacesMoveItemTransaction(this._nodes[i].itemId,
    37                                                 selectedFolderId,
    38                                                 PlacesUtils.bookmarks.DEFAULT_INDEX);
    39         transactions.push(txn);
    40       }
    41       if (transactions.length != 0) {
    42         let txn = new PlacesAggregatedTransaction("Move Items", transactions);
    43         PlacesUtils.transactionManager.doTransaction(txn);
    44       }
    45       return;
    46     }
    48     PlacesTransactions.transact(function* () {
    49       let newParentGUID = yield PlacesUtils.promiseItemGUID(selectedFolderId);
    50       for (let node of this._nodes) {
    51         // Nothing to do if the node is already under the selected folder.
    52         if (node.parent.itemId == selectedFolderId)
    53           continue;
    54         yield PlacesTransactions.MoveItem({ GUID: node.bookmarkGuid
    55                                           , newParentGUID: newParentGUID });
    56       }
    57     }.bind(this)).then(null, Components.utils.reportError);
    58   },
    60   newFolder: function MBD_newFolder() {
    61     // The command is disabled when the tree is not focused
    62     this.foldersTree.focus();
    63     goDoCommand("placesCmd_new:folder");
    64   }
    65 };

mercurial