Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Side by Side Diff: chrome/browser/resources/file_manager/js/util.js

Issue 10834354: Refactor the Photo Editor to enable new feature work (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase, .grd fix Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 /** 5 /**
6 * Namespace for utility functions. 6 * Namespace for utility functions.
7 */ 7 */
8 var util = {}; 8 var util = {};
9 9
10 /** 10 /**
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 /** 562 /**
563 * Makes filesystem: URL from the path. 563 * Makes filesystem: URL from the path.
564 * @param {string} path File or directory path. 564 * @param {string} path File or directory path.
565 * @return {string} URL. 565 * @return {string} URL.
566 */ 566 */
567 util.makeFilesystemUrl = function(path) { 567 util.makeFilesystemUrl = function(path) {
568 return 'filesystem:' + chrome.extension.getURL('external' + path); 568 return 'filesystem:' + chrome.extension.getURL('external' + path);
569 }; 569 };
570 570
571 /** 571 /**
572 * @return {string} Id of the current Chrome extension.
573 */
574 util.getExtensionId = function() {
575 return chrome.extension.getURL('').split('/')[2];
576 };
577
578 /**
572 * Traverses a tree up to a certain depth. 579 * Traverses a tree up to a certain depth.
573 * @param {FileEntry} root Root entry. 580 * @param {FileEntry} root Root entry.
574 * @param {function(Array.<Entry>)} callback The callback is called at the very 581 * @param {function(Array.<Entry>)} callback The callback is called at the very
575 * end with a list of entries found. 582 * end with a list of entries found.
576 * @param {number?} max_depth Maximum depth. Pass zero to traverse everything. 583 * @param {number?} max_depth Maximum depth. Pass zero to traverse everything.
577 */ 584 */
578 util.traverseTree = function(root, callback, max_depth) { 585 util.traverseTree = function(root, callback, max_depth) {
579 if (root.isFile) { 586 if (root.isFile) {
580 callback([root]); 587 callback([root]);
581 return; 588 return;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 * Equivilant to loadTimeData.getStringF(id, ...). 638 * Equivilant to loadTimeData.getStringF(id, ...).
632 * 639 *
633 * @param {string} id The id of the string to return. 640 * @param {string} id The id of the string to return.
634 * @param {...string} var_args The values to replace into the string. 641 * @param {...string} var_args The values to replace into the string.
635 * @return {string} The translated string with replaced values. 642 * @return {string} The translated string with replaced values.
636 */ 643 */
637 function strf(id, var_args) { 644 function strf(id, var_args) {
638 return loadTimeData.getStringF.apply(loadTimeData, arguments); 645 return loadTimeData.getStringF.apply(loadTimeData, arguments);
639 } 646 }
640 647
648 /**
649 * A shortcut function to create a child element with given tag and class.
650 *
651 * @param {HTMLElement} parent Parent element.
652 * @param {string} opt_className Class name.
653 * @param {string} opt_tag Element tag, DIV is omitted.
654 * @return {Element} Newly created element.
655 */
656 function createChild(parent, opt_className, opt_tag) {
657 var child = parent.ownerDocument.createElement(opt_tag || 'div');
658 if (opt_className)
659 child.className = opt_className;
660 parent.appendChild(child);
661 return child;
662 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698