OpenLayers OpenLayers

Ticket #1061 (closed feature: fixed)

Opened 1 year ago

Last modified 1 year ago

callback for close button on popup

Reported by: elemoine Assigned to: elemoine
Priority: minor Milestone: 2.6 Release
Component: Popup Version: SVN
Keywords: Cc:
State:

Description

I've been working on a project where I need a callback on popup close.

Tests to come...

Attachments

patch-close-popup-A1.diff (3.3 kB) - added by elemoine on 10/04/07 12:20:40.
closeCallback.patch (2.9 kB) - added by euzuro on 10/04/07 12:31:06.
just a suggestion for making the patch a little simpler
patch-1061-A2.diff (7.2 kB) - added by elemoine on 10/05/07 16:35:32.
new patch with an example and tests
closeCallback.2.patch (7.0 kB) - added by euzuro on 10/08/07 22:21:13.
slightly modified version of eric's latest patch

Change History

10/04/07 12:20:40 changed by elemoine

  • attachment patch-close-popup-A1.diff added.

10/04/07 12:31:06 changed by euzuro

  • attachment closeCallback.patch added.

just a suggestion for making the patch a little simpler

10/05/07 16:34:38 changed by elemoine

  • keywords set to review.
  • version changed from 2.5 RC4 to SVN.
  • milestone set to 2.6 Release.

Thanks euzuro for the patch. I cooked up a new patch based on euzuro's with an example and tests included. Tests pass on FF, except BaseTypes/test_Element.html and Control/test_PanZoom.html which actually also fail without my patch! Did not run test on IE.

10/05/07 16:35:32 changed by elemoine

  • attachment patch-1061-A2.diff added.

new patch with an example and tests

10/08/07 22:21:13 changed by euzuro

  • attachment closeCallback.2.patch added.

slightly modified version of eric's latest patch

(follow-up: ↓ 4 ) 10/08/07 22:28:22 changed by euzuro

your new patch is great, eric. the only thing i'd want to change is the overriding of the OpenLayers.Function.bindAsEventListener. I see that you're doing that so that you can test if the observer is the same. The only problem is that maybe overriding 'bindAsEventListener()' will cause problems in other tests in other parts of the code.

Generally, we try to avoid overriding basic functionality in the tests, but when we do, we always make sure to re-assign the value at the end. So in this case we'd do something like this:

var tempBind = OpenLayers.Function.bindAsEventListener;
OpenLayers.Function.bindAsEventListener = function(func, obj) { return func };

and then at the end of the test function:

OpenLayers.Function.bindAsEventListener = tempBind;

In this case, however, I dont think that it's strictly necessary to override the function. I believe we acheive the same test by simply *calling* the observer, and then in the observer function's code adding a t.ok(true). If it doesn't get called, we won't have the right number of tests passing. This is a technique I have used in the past.

Additionally, I removed the map creation/ addpopup call as all we really need to do is take the 2nd child of the popup's groupDiv. This makes the tests' overhead a little less... and since they're getting pretty damn slow these days, I think we should keep an eye out for ways to make them run faster.

Let me know what you think of the patch. Like anything, it's only a suggestion on my part.

10/08/07 22:48:04 changed by euzuro

note that my patch passes all tests in ff and ie6... (and for the record, so did eric's... the ones that were failing in ff must have been a timing thing or something)

(in reply to: ↑ 2 ) 10/09/07 01:59:13 changed by elemoine

Replying to euzuro:

your new patch is great, eric. the only thing i'd want to change is the overriding of the OpenLayers.Function.bindAsEventListener. I see that you're doing that so that you can test if the observer is the same. The only problem is that maybe overriding 'bindAsEventListener()' will cause problems in other tests in other parts of the code. Generally, we try to avoid overriding basic functionality in the tests, but when we do, we always make sure to re-assign the value at the end. So in this case we'd do something like this:

var tempBind = OpenLayers.Function.bindAsEventListener;
OpenLayers.Function.bindAsEventListener = function(func, obj) { return func };

and then at the end of the test function:

OpenLayers.Function.bindAsEventListener = tempBind;

Good catch Erik, I indeed forgot to do that.

In this case, however, I dont think that it's strictly necessary to override the function. I believe we acheive the same test by simply *calling* the observer, and then in the observer function's code adding a t.ok(true). If it doesn't get called, we won't have the right number of tests passing. This is a technique I have used in the past. Additionally, I removed the map creation/ addpopup call as all we really need to do is take the 2nd child of the popup's groupDiv. This makes the tests' overhead a little less... and since they're getting pretty damn slow these days, I think we should keep an eye out for ways to make them run faster. Let me know what you think of the patch. Like anything, it's only a suggestion on my part.

I think your patch is great. I agree with all the changes your're proposing.

We can plan to commit this for 2.6.

-- Eric

10/09/07 10:48:56 changed by euzuro

  • keywords changed from review to commit.

ok we are both in agreement with this final patch, and all tests are passing. please commit!

10/10/07 15:03:21 changed by elemoine

  • keywords deleted.
  • status changed from new to closed.
  • resolution set to fixed.

(In [4916]) callback for close button on popup (closes #1061)