| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Brian Grinstead All rights reserved. | 2 * Copyright (C) 2011 Brian Grinstead All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 358 show: function(element, color, format) | 358 show: function(element, color, format) |
| 359 { | 359 { |
| 360 if (this._popover.isShowing()) { | 360 if (this._popover.isShowing()) { |
| 361 if (this._anchorElement === element) | 361 if (this._anchorElement === element) |
| 362 return false; | 362 return false; |
| 363 | 363 |
| 364 // Reopen the picker for another anchor element. | 364 // Reopen the picker for another anchor element. |
| 365 this.hide(true); | 365 this.hide(true); |
| 366 } | 366 } |
| 367 | 367 |
| 368 delete this._isHidden; |
| 368 this._anchorElement = element; | 369 this._anchorElement = element; |
| 369 | 370 |
| 370 this._spectrum.setColor(color); | 371 this._spectrum.setColor(color); |
| 371 this._spectrum._originalFormat = format !== WebInspector.Color.Format.Or
iginal ? format : color.format(); | 372 this._spectrum._originalFormat = format !== WebInspector.Color.Format.Or
iginal ? format : color.format(); |
| 372 this.reposition(element); | 373 this.reposition(element); |
| 373 | 374 |
| 374 document.addEventListener("mousedown", this._hideProxy, false); | 375 document.addEventListener("mousedown", this._hideProxy, false); |
| 376 window.addEventListener("resize", this._hideProxy, false); |
| 375 if (WebInspector.experimentsSettings.colorPicker.isEnabled()) { | 377 if (WebInspector.experimentsSettings.colorPicker.isEnabled()) { |
| 376 WebInspector.targetManager.addModelListener(WebInspector.ResourceTre
eModel, WebInspector.ResourceTreeModel.EventTypes.ColorPicked, this._colorPicked
, this); | 378 WebInspector.targetManager.addModelListener(WebInspector.ResourceTre
eModel, WebInspector.ResourceTreeModel.EventTypes.ColorPicked, this._colorPicked
, this); |
| 377 PageAgent.setColorPickerEnabled(true); | 379 PageAgent.setColorPickerEnabled(true); |
| 378 } | 380 } |
| 379 return true; | 381 return true; |
| 380 }, | 382 }, |
| 381 | 383 |
| 382 reposition: function(element) | 384 reposition: function(element) |
| 383 { | 385 { |
| 384 if (!this._previousFocusElement) | 386 if (!this._previousFocusElement) |
| 385 this._previousFocusElement = WebInspector.currentFocusElement(); | 387 this._previousFocusElement = WebInspector.currentFocusElement(); |
| 386 this._popover.showView(this._spectrum, element); | 388 this._popover.showView(this._spectrum, element); |
| 387 WebInspector.setCurrentFocusElement(this._spectrum.element); | 389 WebInspector.setCurrentFocusElement(this._spectrum.element); |
| 388 }, | 390 }, |
| 389 | 391 |
| 390 /** | 392 /** |
| 391 * @param {boolean=} commitEdit | 393 * @param {boolean=} commitEdit |
| 392 */ | 394 */ |
| 393 hide: function(commitEdit) | 395 hide: function(commitEdit) |
| 394 { | 396 { |
| 395 if (!this._popover.isShowing()) | 397 if (this._isHidden) |
| 396 return; | 398 return; |
| 399 this._isHidden = true; |
| 397 this._popover.hide(); | 400 this._popover.hide(); |
| 398 | 401 |
| 399 document.removeEventListener("mousedown", this._hideProxy, false); | 402 document.removeEventListener("mousedown", this._hideProxy, false); |
| 403 window.removeEventListener("resize", this._hideProxy, false); |
| 400 | 404 |
| 401 if (WebInspector.experimentsSettings.colorPicker.isEnabled()) { | 405 if (WebInspector.experimentsSettings.colorPicker.isEnabled()) { |
| 402 PageAgent.setColorPickerEnabled(false); | 406 PageAgent.setColorPickerEnabled(false); |
| 403 WebInspector.targetManager.removeModelListener(WebInspector.Resource
TreeModel, WebInspector.ResourceTreeModel.EventTypes.ColorPicked, this._colorPic
ked, this); | 407 WebInspector.targetManager.removeModelListener(WebInspector.Resource
TreeModel, WebInspector.ResourceTreeModel.EventTypes.ColorPicked, this._colorPic
ked, this); |
| 404 } | 408 } |
| 405 | 409 |
| 406 this.dispatchEventToListeners(WebInspector.SpectrumPopupHelper.Events.Hi
dden, !!commitEdit); | 410 this.dispatchEventToListeners(WebInspector.SpectrumPopupHelper.Events.Hi
dden, !!commitEdit); |
| 407 | 411 |
| 408 WebInspector.setCurrentFocusElement(this._previousFocusElement); | 412 WebInspector.setCurrentFocusElement(this._previousFocusElement); |
| 409 delete this._previousFocusElement; | 413 delete this._previousFocusElement; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 | 459 |
| 456 WebInspector.ColorSwatch.prototype = { | 460 WebInspector.ColorSwatch.prototype = { |
| 457 /** | 461 /** |
| 458 * @param {string} colorString | 462 * @param {string} colorString |
| 459 */ | 463 */ |
| 460 setColorString: function(colorString) | 464 setColorString: function(colorString) |
| 461 { | 465 { |
| 462 this._swatchInnerElement.style.backgroundColor = colorString; | 466 this._swatchInnerElement.style.backgroundColor = colorString; |
| 463 } | 467 } |
| 464 } | 468 } |
| OLD | NEW |