| OLD | NEW |
| 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 */ | 87 */ |
| 88 UI.DragHandler = class { | 88 UI.DragHandler = class { |
| 89 constructor() { | 89 constructor() { |
| 90 this._elementDragMove = this._elementDragMove.bind(this); | 90 this._elementDragMove = this._elementDragMove.bind(this); |
| 91 this._elementDragEnd = this._elementDragEnd.bind(this); | 91 this._elementDragEnd = this._elementDragEnd.bind(this); |
| 92 this._mouseOutWhileDragging = this._mouseOutWhileDragging.bind(this); | 92 this._mouseOutWhileDragging = this._mouseOutWhileDragging.bind(this); |
| 93 } | 93 } |
| 94 | 94 |
| 95 _createGlassPane() { | 95 _createGlassPane() { |
| 96 this._glassPaneInUse = true; | 96 this._glassPaneInUse = true; |
| 97 if (!UI.DragHandler._glassPaneUsageCount++) | 97 if (!UI.DragHandler._glassPaneUsageCount++) { |
| 98 UI.DragHandler._glassPane = new UI.GlassPane(UI.DragHandler._documentForMo
useOut); | 98 UI.DragHandler._glassPane = new UI.GlassPane( |
| 99 UI.DragHandler._documentForMouseOut, false /* dimmed */, true /* block
PointerEvents */, event => {}); |
| 100 UI.DragHandler._glassPane.show(); |
| 101 } |
| 99 } | 102 } |
| 100 | 103 |
| 101 _disposeGlassPane() { | 104 _disposeGlassPane() { |
| 102 if (!this._glassPaneInUse) | 105 if (!this._glassPaneInUse) |
| 103 return; | 106 return; |
| 104 this._glassPaneInUse = false; | 107 this._glassPaneInUse = false; |
| 105 if (--UI.DragHandler._glassPaneUsageCount) | 108 if (--UI.DragHandler._glassPaneUsageCount) |
| 106 return; | 109 return; |
| 107 UI.DragHandler._glassPane.dispose(); | 110 UI.DragHandler._glassPane.hide(); |
| 108 delete UI.DragHandler._glassPane; | 111 delete UI.DragHandler._glassPane; |
| 109 delete UI.DragHandler._documentForMouseOut; | 112 delete UI.DragHandler._documentForMouseOut; |
| 110 } | 113 } |
| 111 | 114 |
| 112 /** | 115 /** |
| 113 * @param {!Element} targetElement | 116 * @param {!Element} targetElement |
| 114 * @param {?function(!MouseEvent):boolean} elementDragStart | 117 * @param {?function(!MouseEvent):boolean} elementDragStart |
| 115 * @param {function(!MouseEvent)} elementDrag | 118 * @param {function(!MouseEvent)} elementDrag |
| 116 * @param {?function(!MouseEvent)} elementDragEnd | 119 * @param {?function(!MouseEvent)} elementDragEnd |
| 117 * @param {string} cursor | 120 * @param {string} cursor |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 lastX += velocityX * duration; | 295 lastX += velocityX * duration; |
| 293 lastY += velocityY * duration; | 296 lastY += velocityY * duration; |
| 294 var k = Math.pow(1 / (1 + friction), duration / 1000); | 297 var k = Math.pow(1 / (1 + friction), duration / 1000); |
| 295 velocityX *= k; | 298 velocityX *= k; |
| 296 velocityY *= k; | 299 velocityY *= k; |
| 297 elementDrag(lastX, lastY); | 300 elementDrag(lastX, lastY); |
| 298 } | 301 } |
| 299 }; | 302 }; |
| 300 | 303 |
| 301 /** | 304 /** |
| 302 * @unrestricted | |
| 303 */ | |
| 304 UI.GlassPane = class { | |
| 305 /** | |
| 306 * @param {!Document} document | |
| 307 * @param {boolean=} dimmed | |
| 308 */ | |
| 309 constructor(document, dimmed) { | |
| 310 this.element = createElement('div'); | |
| 311 var background = dimmed ? 'rgba(255, 255, 255, 0.5)' : 'transparent'; | |
| 312 this._zIndex = UI._glassPane ? UI._glassPane._zIndex + 1000 : | |
| 313 3000; // Deliberately starts with 3000 to hi
de other z-indexed elements below. | |
| 314 this.element.style.cssText = 'position:absolute;top:0;bottom:0;left:0;right:
0;background-color:' + background + | |
| 315 ';z-index:' + this._zIndex + ';overflow:hidden;'; | |
| 316 document.body.appendChild(this.element); | |
| 317 UI._glassPane = this; | |
| 318 // TODO(dgozman): disallow focus outside of glass pane? | |
| 319 } | |
| 320 | |
| 321 dispose() { | |
| 322 delete UI._glassPane; | |
| 323 this.element.remove(); | |
| 324 } | |
| 325 }; | |
| 326 | |
| 327 /** @type {!UI.GlassPane|undefined} */ | |
| 328 UI._glassPane; | |
| 329 | |
| 330 /** | |
| 331 * @param {?Node=} node | 305 * @param {?Node=} node |
| 332 * @return {boolean} | 306 * @return {boolean} |
| 333 */ | 307 */ |
| 334 UI.isBeingEdited = function(node) { | 308 UI.isBeingEdited = function(node) { |
| 335 if (!node || node.nodeType !== Node.ELEMENT_NODE) | 309 if (!node || node.nodeType !== Node.ELEMENT_NODE) |
| 336 return false; | 310 return false; |
| 337 var element = /** {!Element} */ (node); | 311 var element = /** {!Element} */ (node); |
| 338 if (element.classList.contains('text-prompt') || element.nodeName === 'INPUT'
|| element.nodeName === 'TEXTAREA') | 312 if (element.classList.contains('text-prompt') || element.nodeName === 'INPUT'
|| element.nodeName === 'TEXTAREA') |
| 339 return true; | 313 return true; |
| 340 | 314 |
| (...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1210 document.defaultView.addEventListener('blur', UI._windowBlurred.bind(UI, docum
ent), false); | 1184 document.defaultView.addEventListener('blur', UI._windowBlurred.bind(UI, docum
ent), false); |
| 1211 document.addEventListener('focus', UI._focusChanged.bind(UI), true); | 1185 document.addEventListener('focus', UI._focusChanged.bind(UI), true); |
| 1212 | 1186 |
| 1213 if (!UI.themeSupport) | 1187 if (!UI.themeSupport) |
| 1214 UI.themeSupport = new UI.ThemeSupport(themeSetting); | 1188 UI.themeSupport = new UI.ThemeSupport(themeSetting); |
| 1215 UI.themeSupport.applyTheme(document); | 1189 UI.themeSupport.applyTheme(document); |
| 1216 | 1190 |
| 1217 var body = /** @type {!Element} */ (document.body); | 1191 var body = /** @type {!Element} */ (document.body); |
| 1218 UI.appendStyle(body, 'ui/inspectorStyle.css'); | 1192 UI.appendStyle(body, 'ui/inspectorStyle.css'); |
| 1219 UI.appendStyle(body, 'ui/popover.css'); | 1193 UI.appendStyle(body, 'ui/popover.css'); |
| 1194 UI.GlassPane.setContainer(/** @type {!Element} */ (document.body)); |
| 1220 }; | 1195 }; |
| 1221 | 1196 |
| 1222 /** | 1197 /** |
| 1223 * @param {string} name | 1198 * @param {string} name |
| 1224 * @return {string} | 1199 * @return {string} |
| 1225 */ | 1200 */ |
| 1226 UI.beautifyFunctionName = function(name) { | 1201 UI.beautifyFunctionName = function(name) { |
| 1227 return name || Common.UIString('(anonymous)'); | 1202 return name || Common.UIString('(anonymous)'); |
| 1228 }; | 1203 }; |
| 1229 | 1204 |
| (...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2077 */ | 2052 */ |
| 2078 constructor(message, okCallback, cancelCallback) { | 2053 constructor(message, okCallback, cancelCallback) { |
| 2079 super(true); | 2054 super(true); |
| 2080 this.registerRequiredCSS('ui/confirmDialog.css'); | 2055 this.registerRequiredCSS('ui/confirmDialog.css'); |
| 2081 this.contentElement.createChild('div', 'message').createChild('span').textCo
ntent = message; | 2056 this.contentElement.createChild('div', 'message').createChild('span').textCo
ntent = message; |
| 2082 var buttonsBar = this.contentElement.createChild('div', 'button'); | 2057 var buttonsBar = this.contentElement.createChild('div', 'button'); |
| 2083 buttonsBar.appendChild(UI.createTextButton(Common.UIString('Ok'), okCallback
)); | 2058 buttonsBar.appendChild(UI.createTextButton(Common.UIString('Ok'), okCallback
)); |
| 2084 buttonsBar.appendChild(UI.createTextButton(Common.UIString('Cancel'), cancel
Callback)); | 2059 buttonsBar.appendChild(UI.createTextButton(Common.UIString('Cancel'), cancel
Callback)); |
| 2085 } | 2060 } |
| 2086 }; | 2061 }; |
| OLD | NEW |