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. |
| 111 * @param {function(Event):boolean=} opt_allowSelectStart Unless this function |
| 112 * is defined and returns true, the onselectionstart event will be |
| 113 * surpressed. |
| 114 * @param {function(Event):boolean=} opt_allowDragStart Unless this function |
| 115 * is defined and returns true, the ondragstart event will be surpressed. |
111 */ | 116 */ |
112 function disableTextSelectAndDrag() { | 117 function disableTextSelectAndDrag(opt_allowSelectStart, opt_allowDragStart) { |
113 // Disable text selection. | 118 // Disable text selection. |
114 document.onselectstart = function(e) { | 119 document.onselectstart = function(e) { |
115 e.preventDefault(); | 120 if (!(opt_allowSelectStart && opt_allowSelectStart.call(this, e))) |
116 } | 121 e.preventDefault(); |
| 122 }; |
117 | 123 |
118 // Disable dragging. | 124 // Disable dragging. |
119 document.ondragstart = function(e) { | 125 document.ondragstart = function(e) { |
120 e.preventDefault(); | 126 if (!(opt_allowDragStart && opt_allowDragStart.call(this, e))) |
121 } | 127 e.preventDefault(); |
| 128 }; |
122 } | 129 } |
123 | 130 |
124 /** | 131 /** |
125 * Check the directionality of the page. | 132 * Check the directionality of the page. |
126 * @return {boolean} True if Chrome is running an RTL UI. | 133 * @return {boolean} True if Chrome is running an RTL UI. |
127 */ | 134 */ |
128 function isRTL() { | 135 function isRTL() { |
129 return document.documentElement.dir == 'rtl'; | 136 return document.documentElement.dir == 'rtl'; |
130 } | 137 } |
131 | 138 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 * @param {string} value The value of the param. | 204 * @param {string} value The value of the param. |
198 * @return {string} The new URL. | 205 * @return {string} The new URL. |
199 */ | 206 */ |
200 function appendParam(url, key, value) { | 207 function appendParam(url, key, value) { |
201 var param = encodeURIComponent(key) + '=' + encodeURIComponent(value); | 208 var param = encodeURIComponent(key) + '=' + encodeURIComponent(value); |
202 | 209 |
203 if (url.indexOf('?') == -1) | 210 if (url.indexOf('?') == -1) |
204 return url + '?' + param; | 211 return url + '?' + param; |
205 return url + '&' + param; | 212 return url + '&' + param; |
206 } | 213 } |
OLD | NEW |