OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html i18n-values="dir:textdirection"> | 2 <html i18n-values="dir:textdirection"> |
3 <!-- | 3 <!-- |
4 | 4 |
5 Copyright (c) 2010 The Chromium Authors. All rights reserved. | 5 Copyright (c) 2010 The Chromium Authors. All rights reserved. |
6 Use of this source code is governed by a BSD-style license that can be | 6 Use of this source code is governed by a BSD-style license that can be |
7 found in the LICENSE file. | 7 found in the LICENSE file. |
8 | 8 |
9 | 9 |
10 This is work in progress: | 10 This is work in progress: |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 // We listen to hashchange so that we can update the currently shown folder when | 213 // We listen to hashchange so that we can update the currently shown folder when |
214 // the user goes back and forward in the history. | 214 // the user goes back and forward in the history. |
215 window.onhashchange = function(e) { | 215 window.onhashchange = function(e) { |
216 var id = window.location.hash.slice(1); | 216 var id = window.location.hash.slice(1); |
217 | 217 |
218 var valid = false; | 218 var valid = false; |
219 | 219 |
220 // In case we got a search hash update the text input and the bmm.treeLookup | 220 // In case we got a search hash update the text input and the bmm.treeLookup |
221 // to use the new id. | 221 // to use the new id. |
222 if (/^q=/.test(id)) { | 222 if (/^q=/.test(id)) { |
223 delete bmm.treeLookup[searchTreeItem.bookmarkId]; | 223 setSearch(id.slice(2)); |
224 $('term').value = id.slice(2); | |
225 searchTreeItem.bookmarkId = id; | |
226 bmm.treeLookup[id] = searchTreeItem; | |
227 valid = true; | 224 valid = true; |
228 } else if (id == 'recent') { | 225 } else if (id == 'recent') { |
229 valid = true; | 226 valid = true; |
230 } | 227 } |
231 | 228 |
232 if (valid) { | 229 if (valid) { |
233 updateParentId(id); | 230 updateParentId(id); |
234 } else { | 231 } else { |
235 // We need to verify that this is a correct ID. | 232 // We need to verify that this is a correct ID. |
236 chrome.bookmarks.get(id, function(items) { | 233 chrome.bookmarks.get(id, function(items) { |
(...skipping 19 matching lines...) Expand all Loading... |
256 // folder part. | 253 // folder part. |
257 list.addEventListener('urlClicked', function(e) { | 254 list.addEventListener('urlClicked', function(e) { |
258 openUrls([e.url], e.kind); | 255 openUrls([e.url], e.kind); |
259 }); | 256 }); |
260 | 257 |
261 /** | 258 /** |
262 * Navigates to the search results for the search text. | 259 * Navigates to the search results for the search text. |
263 * @para {string} searchText The text to search for. | 260 * @para {string} searchText The text to search for. |
264 */ | 261 */ |
265 function setSearch(searchText) { | 262 function setSearch(searchText) { |
266 navigateTo('q=' + searchText); | 263 delete bmm.treeLookup[searchTreeItem.bookmarkId]; |
| 264 searchTreeItem.bookmarkId = 'q=' + searchText; |
| 265 bmm.treeLookup[searchTreeItem.bookmarkId] = searchTreeItem; |
| 266 tree.selectedItem = searchTreeItem; |
267 } | 267 } |
268 | 268 |
269 /** | 269 /** |
270 * Clears the search. | 270 * Clears the search. |
271 */ | 271 */ |
272 function resetSearch() { | 272 function resetSearch() { |
273 $('term').value = ''; | 273 $('term').value = ''; |
274 setSearch(''); | 274 setSearch(''); |
275 $('term').focus(); | 275 $('term').focus(); |
276 } | 276 } |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 tree.add(recentTreeItem); | 383 tree.add(recentTreeItem); |
384 tree.add(searchTreeItem); | 384 tree.add(searchTreeItem); |
385 | 385 |
386 // Now we can select a tree item. | 386 // Now we can select a tree item. |
387 var hash = window.location.hash.slice(1); | 387 var hash = window.location.hash.slice(1); |
388 if (!hash) { | 388 if (!hash) { |
389 // If we do not have a hash select first item in the tree. | 389 // If we do not have a hash select first item in the tree. |
390 hash = tree.items[0].bookmarkId; | 390 hash = tree.items[0].bookmarkId; |
391 } | 391 } |
392 | 392 |
393 if (/^q=/.test(hash)) | 393 if (/^q=/.test(hash)) { |
394 $('term').value = hash.slice(2); | 394 var searchTerm = hash.slice(2); |
395 navigateTo(hash); | 395 $('term').value = searchTerm; |
| 396 setSearch(searchTerm); |
| 397 } else { |
| 398 navigateTo(hash); |
| 399 } |
396 }); | 400 }); |
397 | 401 |
398 tree.buildTree(); | 402 tree.buildTree(); |
399 addBookmarkModelListeners(); | 403 addBookmarkModelListeners(); |
400 | 404 |
401 var dnd = { | 405 var dnd = { |
402 DND_EFFECT_COPY: 'copy', | 406 DND_EFFECT_COPY: 'copy', |
403 DND_EFFECT_MOVE: cr.isMac ? 'move' : 'copy', // http://crbug.com/14654 | 407 DND_EFFECT_MOVE: cr.isMac ? 'move' : 'copy', // http://crbug.com/14654 |
404 | 408 |
405 dragData: null, | 409 dragData: null, |
(...skipping 1164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1570 localStrings.templateData = data; | 1574 localStrings.templateData = data; |
1571 i18nTemplate.process(document, data); | 1575 i18nTemplate.process(document, data); |
1572 }); | 1576 }); |
1573 | 1577 |
1574 </script> | 1578 </script> |
1575 | 1579 |
1576 <div id="drop-overlay"></div> | 1580 <div id="drop-overlay"></div> |
1577 | 1581 |
1578 </body> | 1582 </body> |
1579 </html> | 1583 </html> |
OLD | NEW |