| OLD | NEW | 
|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 cr.define('ntp4', function() { | 5 cr.define('ntp4', function() { | 
| 6   'use strict'; | 6   'use strict'; | 
| 7 | 7 | 
| 8   var localStrings = new LocalStrings; | 8   var localStrings = new LocalStrings; | 
| 9 | 9 | 
| 10   /** | 10   /** | 
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 223 | 223 | 
| 224   BookmarksPage.prototype = { | 224   BookmarksPage.prototype = { | 
| 225     __proto__: TilePage.prototype, | 225     __proto__: TilePage.prototype, | 
| 226 | 226 | 
| 227     /** | 227     /** | 
| 228      * Initialize the bookmarks page object. | 228      * Initialize the bookmarks page object. | 
| 229      */ | 229      */ | 
| 230     initialize: function() { | 230     initialize: function() { | 
| 231       this.classList.add('bookmarks-page'); | 231       this.classList.add('bookmarks-page'); | 
| 232 | 232 | 
| 233       // insert the bookmark titles header which is unique to bookmark pages. | 233       // Insert the bookmark titles header which is unique to bookmark pages. | 
| 234       this.insertBefore($('bookmarks-title-wrapper'), this.firstChild); | 234       this.insertBefore($('bookmarks-title-wrapper'), this.firstChild); | 
| 235 | 235 | 
| 236       // insert a container for a link to a Bookmarks Manager page. | 236       // Insert the top & bottom links for the Bookmarks Manager page. | 
| 237       var link = document.createElement('a'); | 237       var pageContent = this.querySelector('.tile-page-content'); | 
| 238       link.className = 'bookmarks-manager-link'; | 238       var topWrapper = $('bookmarks-top-link-wrapper'); | 
| 239       link.textContent = localStrings.getString('bookmarksManagerLinkTitle'); | 239       pageContent.insertBefore(topWrapper, pageContent.firstChild); | 
| 240       var container = document.createElement('div'); | 240       topWrapper.hidden = false; | 
| 241       container.className = 'bookmarks-manager-link-container'; | 241       pageContent.appendChild($('bookmarks-bottom-link-wrapper')); | 
| 242       container.hidden = true; |  | 
| 243       container.appendChild(link); |  | 
| 244       this.querySelector('.tile-page-content').appendChild(container); |  | 
| 245     }, | 242     }, | 
| 246 | 243 | 
| 247     /** | 244     /** | 
| 248      * Build the bookmark titles bar (ie, navigation hiearchy). | 245      * Build the bookmark titles bar (ie, navigation hiearchy). | 
| 249      * @param {Array} items The parent hiearchy of the current folder. | 246      * @param {Array} items The parent hiearchy of the current folder. | 
| 250      * @private | 247      * @private | 
| 251      */ | 248      */ | 
| 252     updateBookmarkTitles_: function(items) { | 249     updateBookmarkTitles_: function(items) { | 
| 253       var wrapper = $('bookmarks-title-wrapper'); | 250       var wrapper = $('bookmarks-title-wrapper'); | 
| 254       var title = wrapper.querySelector('.section-title'); | 251       var title = wrapper.querySelector('.section-title'); | 
| (...skipping 16 matching lines...) Expand all  Loading... | 
| 271      * Build the bookmark tiles. | 268      * Build the bookmark tiles. | 
| 272      * @param {Array} items The contents of the current folder. | 269      * @param {Array} items The contents of the current folder. | 
| 273      * @private | 270      * @private | 
| 274      */ | 271      */ | 
| 275     updateBookmarkTiles_: function(items) { | 272     updateBookmarkTiles_: function(items) { | 
| 276       this.removeAllTiles(); | 273       this.removeAllTiles(); | 
| 277       var tile_count = Math.min(items.length, MAX_BOOKMARK_TILES); | 274       var tile_count = Math.min(items.length, MAX_BOOKMARK_TILES); | 
| 278       for (var i = 0; i < tile_count; i++) | 275       for (var i = 0; i < tile_count; i++) | 
| 279         this.appendTile(new Bookmark(items[i]), false); | 276         this.appendTile(new Bookmark(items[i]), false); | 
| 280 | 277 | 
| 281       var container = this.querySelector('.bookmarks-manager-link-container'); | 278       var link = $('bookmarks-top-link-wrapper').querySelector('a'); | 
|  | 279       link.href = 'chrome://bookmarks/#' + this.id; | 
|  | 280 | 
|  | 281       var wrapper = $('bookmarks-bottom-link-wrapper'); | 
| 282       if (items.length > MAX_BOOKMARK_TILES) { | 282       if (items.length > MAX_BOOKMARK_TILES) { | 
| 283         var link = container.querySelector('.bookmarks-manager-link'); | 283         var link = wrapper.querySelector('a'); | 
| 284         link.href = 'chrome://bookmarks/#' + this.id; | 284         link.href = 'chrome://bookmarks/#' + this.id; | 
| 285         container.hidden = false; | 285         wrapper.hidden = false; | 
| 286       } else { | 286       } else { | 
| 287         container.hidden = true; | 287         wrapper.hidden = true; | 
| 288       } | 288       } | 
| 289     }, | 289     }, | 
| 290 | 290 | 
| 291     /** | 291     /** | 
| 292      * Determine whether a bookmark ID matches a folder in the current | 292      * Determine whether a bookmark ID matches a folder in the current | 
| 293      * hierarchy. | 293      * hierarchy. | 
| 294      * @param {string} id The bookmark ID to search for. | 294      * @param {string} id The bookmark ID to search for. | 
| 295      * @private | 295      * @private | 
| 296      */ | 296      */ | 
| 297     isBookmarkInParentHierarchy_: function(id) { | 297     isBookmarkInParentHierarchy_: function(id) { | 
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 440      * Set the bookmark data that should be displayed, replacing any existing | 440      * Set the bookmark data that should be displayed, replacing any existing | 
| 441      * data. | 441      * data. | 
| 442      * @param {Object} data Data that shoudl be displayed. Contains arrays | 442      * @param {Object} data Data that shoudl be displayed. Contains arrays | 
| 443      *   'items' and 'navigationItems'. | 443      *   'items' and 'navigationItems'. | 
| 444      */ | 444      */ | 
| 445     set data(data) { | 445     set data(data) { | 
| 446       this.id = data.navigationItems[0].id; | 446       this.id = data.navigationItems[0].id; | 
| 447       this.updateBookmarkTiles_(data.items); | 447       this.updateBookmarkTiles_(data.items); | 
| 448       this.updateBookmarkTitles_(data.navigationItems); | 448       this.updateBookmarkTitles_(data.navigationItems); | 
| 449     }, | 449     }, | 
|  | 450 | 
|  | 451     /** @inheritDoc */ | 
|  | 452     get extraBottomPadding() { | 
|  | 453       return 40; | 
|  | 454     }, | 
| 450   }; | 455   }; | 
| 451 | 456 | 
| 452   /** | 457   /** | 
| 453    * Initializes and renders the bookmark chevron canvas.  This needs to be | 458    * Initializes and renders the bookmark chevron canvas.  This needs to be | 
| 454    * performed after the page has been loaded so that we have access to the | 459    * performed after the page has been loaded so that we have access to the | 
| 455    * style sheet values. | 460    * style sheet values. | 
| 456    */ | 461    */ | 
| 457   function initBookmarkChevron() { | 462   function initBookmarkChevron() { | 
| 458     var wrapperStyle = window.getComputedStyle($('bookmarks-title-wrapper')); | 463     var wrapperStyle = window.getComputedStyle($('bookmarks-title-wrapper')); | 
| 459     var width = 10; | 464     var width = 10; | 
| (...skipping 20 matching lines...) Expand all  Loading... | 
| 480       tile.stripeColor = color; | 485       tile.stripeColor = color; | 
| 481   }; | 486   }; | 
| 482 | 487 | 
| 483   return { | 488   return { | 
| 484     BookmarksPage: BookmarksPage, | 489     BookmarksPage: BookmarksPage, | 
| 485     initBookmarkChevron: initBookmarkChevron, | 490     initBookmarkChevron: initBookmarkChevron, | 
| 486   }; | 491   }; | 
| 487 }); | 492 }); | 
| 488 | 493 | 
| 489 window.addEventListener('load', ntp4.initBookmarkChevron); | 494 window.addEventListener('load', ntp4.initBookmarkChevron); | 
| OLD | NEW | 
|---|