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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/common/UIString.js

Issue 2466123002: DevTools: reformat front-end code to match chromium style. (Closed)
Patch Set: all done Created 4 years, 1 month 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. 3 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
4 * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com). 4 * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com).
5 * Copyright (C) 2009 Joseph Pecoraro 5 * Copyright (C) 2009 Joseph Pecoraro
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 10 *
(...skipping 10 matching lines...) Expand all
21 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 23 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
24 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
27 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31
32 /** 31 /**
33 * @param {string} string 32 * @param {string} string
34 * @param {...*} vararg 33 * @param {...*} vararg
35 * @return {string} 34 * @return {string}
36 */ 35 */
37 WebInspector.UIString = function(string, vararg) 36 WebInspector.UIString = function(string, vararg) {
38 { 37 return String.vsprintf(WebInspector.localize(string), Array.prototype.slice.ca ll(arguments, 1));
39 return String.vsprintf(WebInspector.localize(string), Array.prototype.slice. call(arguments, 1));
40 }; 38 };
41 39
42 /** 40 /**
43 * @param {string} string 41 * @param {string} string
44 * @param {...*} vararg 42 * @param {...*} vararg
45 * @return {string} 43 * @return {string}
46 */ 44 */
47 WebInspector.UIString.capitalize = function(string, vararg) 45 WebInspector.UIString.capitalize = function(string, vararg) {
48 { 46 if (WebInspector._useLowerCaseMenuTitles === undefined)
49 if (WebInspector._useLowerCaseMenuTitles === undefined) 47 throw 'WebInspector.setLocalizationPlatform() has not been called';
50 throw "WebInspector.setLocalizationPlatform() has not been called";
51 48
52 var localized = WebInspector.localize(string); 49 var localized = WebInspector.localize(string);
53 var capitalized; 50 var capitalized;
54 if (WebInspector._useLowerCaseMenuTitles) 51 if (WebInspector._useLowerCaseMenuTitles)
55 capitalized = localized.replace(/\^(.)/g, "$1"); 52 capitalized = localized.replace(/\^(.)/g, '$1');
56 else 53 else
57 capitalized = localized.replace(/\^(.)/g, function(str, char) { return c har.toUpperCase(); }); 54 capitalized = localized.replace(/\^(.)/g, function(str, char) {
58 return String.vsprintf(capitalized, Array.prototype.slice.call(arguments, 1) ); 55 return char.toUpperCase();
56 });
57 return String.vsprintf(capitalized, Array.prototype.slice.call(arguments, 1));
59 }; 58 };
60 59
61 /** 60 /**
62 * @param {string} platform 61 * @param {string} platform
63 */ 62 */
64 WebInspector.setLocalizationPlatform = function(platform) 63 WebInspector.setLocalizationPlatform = function(platform) {
65 { 64 WebInspector._useLowerCaseMenuTitles = platform === 'windows';
66 WebInspector._useLowerCaseMenuTitles = platform === "windows";
67 }; 65 };
68 66
69 /** 67 /**
70 * @param {string} string 68 * @param {string} string
71 * @return {string} 69 * @return {string}
72 */ 70 */
73 WebInspector.localize = function(string) 71 WebInspector.localize = function(string) {
74 { 72 return string;
75 return string;
76 }; 73 };
77 74
78 /** 75 /**
79 * @constructor 76 * @unrestricted
80 * @param {string} format
81 */ 77 */
82 WebInspector.UIStringFormat = function(format) 78 WebInspector.UIStringFormat = class {
83 { 79 /**
80 * @param {string} format
81 */
82 constructor(format) {
84 /** @type {string} */ 83 /** @type {string} */
85 this._localizedFormat = WebInspector.localize(format); 84 this._localizedFormat = WebInspector.localize(format);
86 /** @type {!Array.<!Object>} */ 85 /** @type {!Array.<!Object>} */
87 this._tokenizedFormat = String.tokenizeFormatString(this._localizedFormat, S tring.standardFormatters); 86 this._tokenizedFormat = String.tokenizeFormatString(this._localizedFormat, S tring.standardFormatters);
87 }
88
89 /**
90 * @param {string} a
91 * @param {string} b
92 * @return {string}
93 */
94 static _append(a, b) {
95 return a + b;
96 }
97
98 /**
99 * @param {...*} vararg
100 * @return {string}
101 */
102 format(vararg) {
103 return String
104 .format(
105 this._localizedFormat, arguments, String.standardFormatters, '', Web Inspector.UIStringFormat._append,
106 this._tokenizedFormat)
107 .formattedResult;
108 }
88 }; 109 };
89 110
90 /**
91 * @param {string} a
92 * @param {string} b
93 * @return {string}
94 */
95 WebInspector.UIStringFormat._append = function(a, b)
96 {
97 return a + b;
98 };
99 111
100 WebInspector.UIStringFormat.prototype = {
101 /**
102 * @param {...*} vararg
103 * @return {string}
104 */
105 format: function(vararg)
106 {
107 return String.format(this._localizedFormat, arguments,
108 String.standardFormatters, "", WebInspector.UIStringFormat._append, this._tokenizedFormat).formattedResult;
109 }
110 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698