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

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

Issue 144783002: Simplify directory initialization in Files app. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleaned up. Created 6 years, 10 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 'use strict'; 5 'use strict';
6 6
7 /** 7 /**
8 * Namespace for utility functions. 8 * Namespace for utility functions.
9 */ 9 */
10 var util = {}; 10 var util = {};
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 */ 665 */
666 util.createChild = function(parent, opt_className, opt_tag) { 666 util.createChild = function(parent, opt_className, opt_tag) {
667 var child = parent.ownerDocument.createElement(opt_tag || 'div'); 667 var child = parent.ownerDocument.createElement(opt_tag || 'div');
668 if (opt_className) 668 if (opt_className)
669 child.className = opt_className; 669 child.className = opt_className;
670 parent.appendChild(child); 670 parent.appendChild(child);
671 return child; 671 return child;
672 }; 672 };
673 673
674 /** 674 /**
675 * Update the app state. 675 * Updates the app state.
676 * TODO(mtomasz): Migrate to URLs.
676 * 677 *
677 * @param {string} path Path to be put in the address bar after the hash. 678 * @param {string} currentDirectoryPath Currently opened path. If null the path
678 * If null the hash is left unchanged. 679 * is left unchanged.
679 * @param {string|Object=} opt_param Search parameter. Used directly if string, 680 * @param {string} selectionPath Currently selected path. If null the path is
680 * stringified if object. If omitted the search query is left unchanged. 681 * left unchanged.
682 * @param {string|Object=} opt_param Additional parameters, to be stored. If
683 * null, then left unchanged.
681 */ 684 */
682 util.updateAppState = function(path, opt_param) { 685 util.updateAppState = function(currentDirectoryPath, selectionPath, opt_param) {
683 window.appState = window.appState || {}; 686 window.appState = window.appState || {};
684 if (typeof opt_param == 'string') 687 if (opt_param !== undefined && opt_param !== null)
685 window.appState.params = {};
686 else if (typeof opt_param == 'object')
687 window.appState.params = opt_param; 688 window.appState.params = opt_param;
688 if (path) 689 if (currentDirectoryPath !== null)
689 window.appState.defaultPath = path; 690 window.appState.currentDirectoryPath = currentDirectoryPath;
691 if (selectionPath !== null)
692 window.appState.selectionPath = selectionPath;
690 util.saveAppState(); 693 util.saveAppState();
691 return;
692 }; 694 };
693 695
694 /** 696 /**
695 * Return a translated string. 697 * Returns a translated string.
696 * 698 *
697 * Wrapper function to make dealing with translated strings more concise. 699 * Wrapper function to make dealing with translated strings more concise.
698 * Equivalent to loadTimeData.getString(id). 700 * Equivalent to loadTimeData.getString(id).
699 * 701 *
700 * @param {string} id The id of the string to return. 702 * @param {string} id The id of the string to return.
701 * @return {string} The translated string. 703 * @return {string} The translated string.
702 */ 704 */
703 function str(id) { 705 function str(id) {
704 return loadTimeData.getString(id); 706 return loadTimeData.getString(id);
705 } 707 }
706 708
707 /** 709 /**
708 * Return a translated string with arguments replaced. 710 * Returns a translated string with arguments replaced.
709 * 711 *
710 * Wrapper function to make dealing with translated strings more concise. 712 * Wrapper function to make dealing with translated strings more concise.
711 * Equivalent to loadTimeData.getStringF(id, ...). 713 * Equivalent to loadTimeData.getStringF(id, ...).
712 * 714 *
713 * @param {string} id The id of the string to return. 715 * @param {string} id The id of the string to return.
714 * @param {...string} var_args The values to replace into the string. 716 * @param {...string} var_args The values to replace into the string.
715 * @return {string} The translated string with replaced values. 717 * @return {string} The translated string with replaced values.
716 */ 718 */
717 function strf(id, var_args) { 719 function strf(id, var_args) {
718 return loadTimeData.getStringF.apply(loadTimeData, arguments); 720 return loadTimeData.getStringF.apply(loadTimeData, arguments);
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
1261 * @enum {string} 1263 * @enum {string}
1262 * @const 1264 * @const
1263 */ 1265 */
1264 util.VolumeType = Object.freeze({ 1266 util.VolumeType = Object.freeze({
1265 DRIVE: 'drive', 1267 DRIVE: 'drive',
1266 DOWNLOADS: 'downloads', 1268 DOWNLOADS: 'downloads',
1267 REMOVABLE: 'removable', 1269 REMOVABLE: 'removable',
1268 ARCHIVE: 'archive', 1270 ARCHIVE: 'archive',
1269 CLOUD_DEVICE: 'cloud_device' 1271 CLOUD_DEVICE: 'cloud_device'
1270 }); 1272 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698