OLD | NEW |
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 * The global object. | 6 * The global object. |
7 * @type {!Object} | 7 * @type {!Object} |
8 * @const | 8 * @const |
9 */ | 9 */ |
10 var global = this; | 10 var global = this; |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 }; | 122 }; |
123 | 123 |
124 // Disable dragging. | 124 // Disable dragging. |
125 document.ondragstart = function(e) { | 125 document.ondragstart = function(e) { |
126 if (!(opt_allowDragStart && opt_allowDragStart.call(this, e))) | 126 if (!(opt_allowDragStart && opt_allowDragStart.call(this, e))) |
127 e.preventDefault(); | 127 e.preventDefault(); |
128 }; | 128 }; |
129 } | 129 } |
130 | 130 |
131 /** | 131 /** |
| 132 * Call this to stop clicks on <a href="#"> links from scrolling to the top of |
| 133 * the page (and possibly showing a # in the link). |
| 134 */ |
| 135 function preventDefaultOnPoundLinkClicks() { |
| 136 document.addEventListener('click', function(e) { |
| 137 if (e.target.nodeName == 'A' && e.target.getAttribute('href') == '#') |
| 138 e.preventDefault(); |
| 139 }); |
| 140 } |
| 141 |
| 142 /** |
132 * Check the directionality of the page. | 143 * Check the directionality of the page. |
133 * @return {boolean} True if Chrome is running an RTL UI. | 144 * @return {boolean} True if Chrome is running an RTL UI. |
134 */ | 145 */ |
135 function isRTL() { | 146 function isRTL() { |
136 return document.documentElement.dir == 'rtl'; | 147 return document.documentElement.dir == 'rtl'; |
137 } | 148 } |
138 | 149 |
139 /** | 150 /** |
140 * Simple common assertion API | 151 * Simple common assertion API |
141 * @param {*} condition The condition to test. Note that this may be used to | 152 * @param {*} condition The condition to test. Note that this may be used to |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 * @param {string} value The value of the param. | 215 * @param {string} value The value of the param. |
205 * @return {string} The new URL. | 216 * @return {string} The new URL. |
206 */ | 217 */ |
207 function appendParam(url, key, value) { | 218 function appendParam(url, key, value) { |
208 var param = encodeURIComponent(key) + '=' + encodeURIComponent(value); | 219 var param = encodeURIComponent(key) + '=' + encodeURIComponent(value); |
209 | 220 |
210 if (url.indexOf('?') == -1) | 221 if (url.indexOf('?') == -1) |
211 return url + '?' + param; | 222 return url + '?' + param; |
212 return url + '&' + param; | 223 return url + '&' + param; |
213 } | 224 } |
OLD | NEW |