Ticket #1061 (closed feature: fixed)

Opened 6 years ago

Last modified 6 years ago

callback for close button on popup

Reported by: elemoine Owned by: 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 Download (3.3 KB) - added by elemoine 6 years ago.
closeCallback.patch Download (2.9 KB) - added by euzuro 6 years ago.
just a suggestion for making the patch a little simpler
patch-1061-A2.diff Download (7.2 KB) - added by elemoine 6 years ago.
new patch with an example and tests
closeCallback.2.patch Download (7.0 KB) - added by euzuro 6 years ago.
slightly modified version of eric's latest patch

Change History

Changed 6 years ago by elemoine

Changed 6 years ago by euzuro

just a suggestion for making the patch a little simpler

  Changed 6 years ago by elemoine

  • keywords review added
  • 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.

Changed 6 years ago by elemoine

new patch with an example and tests

Changed 6 years ago by euzuro

slightly modified version of eric's latest patch

follow-up: ↓ 4   Changed 6 years ago 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.

  Changed 6 years ago 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   Changed 6 years ago 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

  Changed 6 years ago by euzuro

  • keywords commit added; review removed

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

  Changed 6 years ago by elemoine

  • keywords commit removed
  • status changed from new to closed
  • resolution set to fixed

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

Note: See TracTickets for help on using tickets.