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

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

Issue 10832196: [extensions] Don't let clicks on <a href="#"> links escape un-prevented. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . 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
« no previous file with comments | « chrome/browser/resources/ntp4/new_tab.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 * 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
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
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 }
OLDNEW
« no previous file with comments | « chrome/browser/resources/ntp4/new_tab.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698