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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
100 if (afterA == b) { | 100 if (afterA == b) { |
101 swapDomNodes(b, a); | 101 swapDomNodes(b, a); |
102 return; | 102 return; |
103 } | 103 } |
104 var aParent = a.parentNode; | 104 var aParent = a.parentNode; |
105 b.parentNode.replaceChild(a, b); | 105 b.parentNode.replaceChild(a, b); |
106 aParent.insertBefore(b, afterA); | 106 aParent.insertBefore(b, afterA); |
107 } | 107 } |
108 | 108 |
109 /** | 109 /** |
110 * Disables text selection and dragging. | 110 * Disables text selection and dragging, with optional whitelist callbacks. |
Dan Beam
2012/07/24 21:56:27
nit: no extra \n here in jsdoc
Harry McCleave
2012/07/24 22:54:06
Done.
| |
111 * | |
112 * @param {function(Event) : boolean} allowSelectStart if this function is | |
Dan Beam
2012/07/24 21:56:27
* @param {function(Event):boolean=} opt_allowSelec
Harry McCleave
2012/07/24 22:54:06
Done.
| |
113 * defined and returns true, will allow the SelectStart event to be processed | |
114 * @param {function(Event) : boolean} allowDragStart if this funcion is defined | |
Dan Beam
2012/07/24 21:56:27
* @param {function(Event):boolean=} opt_allowDragS
Harry McCleave
2012/07/24 22:54:06
Done.
| |
115 * and returns true, will allow the DragStart event to be processed | |
111 */ | 116 */ |
112 function disableTextSelectAndDrag() { | 117 function disableTextSelectAndDrag(allowSelectStart, allowDragStart) { |
113 // Disable text selection. | 118 // Disable text selection. |
114 document.onselectstart = function(e) { | 119 document.onselectstart = function(e) { |
115 e.preventDefault(); | 120 if (!(allowSelectStart && allowSelectStart(e))) { |
Dan Beam
2012/07/24 21:56:27
nit: no curlies, should probably actually modify t
Harry McCleave
2012/07/24 22:54:06
Done.
| |
121 e.preventDefault(); | |
122 } | |
116 } | 123 } |
Dan Beam
2012/07/24 21:56:27
};
Harry McCleave
2012/07/24 22:54:06
Done.
| |
117 | 124 |
118 // Disable dragging. | 125 // Disable dragging. |
119 document.ondragstart = function(e) { | 126 document.ondragstart = function(e) { |
120 e.preventDefault(); | 127 if (!(allowDragStart && allowDragStart(e))) { |
Dan Beam
2012/07/24 21:56:27
nit: no curlies, should probably actually modify t
Harry McCleave
2012/07/24 22:54:06
Done.
| |
128 e.preventDefault(); | |
129 } | |
121 } | 130 } |
Dan Beam
2012/07/24 21:56:27
};
Harry McCleave
2012/07/24 22:54:06
Done.
| |
122 } | 131 } |
123 | 132 |
124 /** | 133 /** |
125 * Check the directionality of the page. | 134 * Check the directionality of the page. |
126 * @return {boolean} True if Chrome is running an RTL UI. | 135 * @return {boolean} True if Chrome is running an RTL UI. |
127 */ | 136 */ |
128 function isRTL() { | 137 function isRTL() { |
129 return document.documentElement.dir == 'rtl'; | 138 return document.documentElement.dir == 'rtl'; |
130 } | 139 } |
131 | 140 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
197 * @param {string} value The value of the param. | 206 * @param {string} value The value of the param. |
198 * @return {string} The new URL. | 207 * @return {string} The new URL. |
199 */ | 208 */ |
200 function appendParam(url, key, value) { | 209 function appendParam(url, key, value) { |
201 var param = encodeURIComponent(key) + '=' + encodeURIComponent(value); | 210 var param = encodeURIComponent(key) + '=' + encodeURIComponent(value); |
202 | 211 |
203 if (url.indexOf('?') == -1) | 212 if (url.indexOf('?') == -1) |
204 return url + '?' + param; | 213 return url + '?' + param; |
205 return url + '&' + param; | 214 return url + '&' + param; |
206 } | 215 } |
OLD | NEW |