summaryrefslogtreecommitdiffstats
path: root/chrome/browser/resources/bookmark_manager/js/bmm.js
blob: 24c4ad0b0089e138536c3da4135c49cb1002ec95 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

cr.define('bmm', function() {
  function isFolder(bookmarkNode) {
    return !bookmarkNode.url;
  }

  function contains(parent, descendant) {
    if (descendant.parentId == parent.id)
      return true;
    // the bmm.treeLookup contains all folders
    var parentTreeItem = bmm.treeLookup[descendant.parentId];
    if (!parentTreeItem || !parentTreeItem.bookmarkNode)
      return false;
    return this.contains(parent, parentTreeItem.bookmarkNode);
  }

  return {
    isFolder: isFolder,
    contains: contains
  };
});