durgaprassad7 / simplemodal

Automatically exported from code.google.com/p/simplemodal
0 stars 0 forks source link

position not used when called from different frame #20

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Version of SimpleModal?
 * SimpleModal 1.3-b1 - jQuery Plugin

Version of jQuery?
 * jQuery JavaScript Library v1.3.1

Browser/OS you are experiencing the problem with?
Firefox / WinXP, unsure if others

When calling modal from a different frame the position option can be
ignored because the constructor method will not be equal to the one of
executing frame. 

Offending line of code; setPosition() #485
if (this.opts.position && this.opts.position.constructor == Array) {

Potential fixes:
 - use JQuery 1.3 $.isArray()
 - use this.opts.position.length && this.opts.position[0]

Original issue reported on code.google.com by cavi...@gmail.com on 11 Jun 2009 at 7:43

GoogleCodeExporter commented 8 years ago
Thanks for the report. Do you happen to have a simple test case of the issue?

Original comment by emartin24 on 11 Jun 2009 at 8:58

GoogleCodeExporter commented 8 years ago
Sorry, rude of me not to include steps to recreate. 

It is a little weird, aka still dealing with design mistakes from the 90's.

There are two frames one is a library with JavaScript the other with content. 
The
content frame calls a function in the library frame to create a pop-up. The 
library
frame uses the content's frame "window" object to get its jQuery and 
simplemodal then
calls creates the pop-up. The crux is that the library frame creates the array 
for
"position" option. It is then passed into a function under the content frame's 
scope.
Therefor the constructor function for the "position" option and the Array 
constructor
in simplemodal are different.

Like I said weird and honestly stupid, but its slow and difficult work to change
legacy stuff.

Attached is a zip with the needed frameset and html files to show the issue. A 
copy
of simplemodal 1.3b1 and "my" simplemodal with changes that fix the issue.

Hope that helps!

Original comment by cavi...@gmail.com on 11 Jun 2009 at 10:27

Attachments:

GoogleCodeExporter commented 8 years ago
Sorry it took me so long to get around to this. I changed the line in question 
to:

if (this.opts.position && Object.prototype.toString.call(this.opts.position) ===
"[object Array]") {

That seems to fix the problem (borrowed the code from jQuery's isArray 
function).

Look for the fix to show up in the next release (1.3.1).

Thanks for the report and example code!

Original comment by emartin24 on 20 Aug 2009 at 6:23