Multiple versions of prototype.js

9 messages Options
Embed this post
Permalink
gingerbbm

Multiple versions of prototype.js

Reply Threaded More More options
Print post
Permalink

Dear all

I've been integrating MapGuide Fusion into a web app that was originally
using a different mapping engine, but I've hit a snag. The app was built
using various features of prototype.js. Fusion also borrows from this
library, and I'm getting conflicts, specifically when I try a
string.evalJSON() call.

Before I get into the nitty gritty, has anyone else tried to use two
different versions of prototype.js alongside each other, and if so, how did
you achieve it?

Thanks
Stuart
--
View this message in context: http://n2.nabble.com/Multiple-versions-of-prototype.js-tp1494625p1494625.html
Sent from the Fusion Users mailing list archive at Nabble.com.

_______________________________________________
fusion-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fusion-users
Paul Spencer-2

Re: Multiple versions of prototype.js

Reply Threaded More More options
Print post
Permalink
Stuart

it is not possible to use two different versions of prototype at the  
same time, nor will it be possible for you to use the new version  
based on MooTools with a version of prototype.  This is an artefact of  
how Prototype and MooTools are built (something I didn't appreciate  
until recently myself).

Your realistic choices are:

1) load your Fusion application into your web page using an iframe or  
frame, thereby separating the two versions of prototype

2) replace the version of prototype used in Fusion (via the Jx  
library) with your version and deal with any issues this creates in  
Fusion/Jx

3) update your code to use the newer version of Prototype that comes  
with Fusion

Only the first option will protect you from upgrading to MapGuide 2.1/
Fusion 2.0 (the version that will include MooTools).  Even if you  
modify Fusion to use your version of prototype now, you will  
eventually have to migrate your code to MooTools if you plan on  
upgrading to MGOS 2.1 or a future MGE version.

Sorry for the pain this is likely going to cause you.  Had I realized  
the implications of choosing MooTools, things might have gone  
differently early on.  However, it is too late at this point to go  
back on that decision in the near future.

Cheers

Paul

On 13-Nov-08, at 11:47 AM, gingerbbm wrote:

>
> Dear all
>
> I've been integrating MapGuide Fusion into a web app that was  
> originally
> using a different mapping engine, but I've hit a snag. The app was  
> built
> using various features of prototype.js. Fusion also borrows from this
> library, and I'm getting conflicts, specifically when I try a
> string.evalJSON() call.
>
> Before I get into the nitty gritty, has anyone else tried to use two
> different versions of prototype.js alongside each other, and if so,  
> how did
> you achieve it?
>
> Thanks
> Stuart
> --
> View this message in context: http://n2.nabble.com/Multiple-versions-of-prototype.js-tp1494625p1494625.html
> Sent from the Fusion Users mailing list archive at Nabble.com.
>
> _______________________________________________
> fusion-users mailing list
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/fusion-users


__________________________________________

    Paul Spencer
    Chief Technology Officer
    DM Solutions Group Inc
    http://research.dmsolutions.ca/

_______________________________________________
fusion-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fusion-users
gingerbbm

Re: Multiple versions of prototype.js

Reply Threaded More More options
Print post
Permalink

Thanks for your reply, Paul.

The solution I arrived at - and I'm not really very happy about it - was to
do a search n' replace on the string "Prototype" in the MapGuide Fusion code
(so that it's now "OPrototype"). It appears to solve my issues.

Of course this is not sustainable but it means I can use the latest version
of Prototype (and Scriptaculous) in the rest of my site without worrying -
or resorting to nasty frames - at least until it's time to upgrade.

Questions:
1. Why does Fusion not use the full version of Prototype?
2. Will Fusion 2.0 use the full (and latest) version of Prototype?
3. Does Mootools rely on a full version of Prototype (or does it use a
subset a la Fusion 1.x)?

Cheers
Stuart
--
View this message in context: http://n2.nabble.com/Multiple-versions-of-prototype.js-tp1494625p1497776.html
Sent from the Fusion Users mailing list archive at Nabble.com.

_______________________________________________
fusion-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fusion-users
Paul Spencer-2

Re: Multiple versions of prototype.js

Reply Threaded More More options
Print post
Permalink
Hi Stuart,

Fusion does use a full version of Prototype and Scriptaculous but I  
believe it is an older version as we haven't updated in a while.

Fusion 2.0 will use MooTools which is an alternate (and unfortunately  
mutually exclusive) javascript framework.  MooTools is similar to  
Prototype (the MooTools developers were originally part of the  
Prototype community) but different in some subtle ways.

It looks to me like you should be able to take a full build of  
Prototype and Scriptaculous, concatenate them together and replace the  
first 5799 lines of jx_combined.js ... then its just a matter of  
figuring out if this breaks anything and patching Fusion and/or Jx  
stuff.

Or you could just remove those lines from jx_combined.js load your own  
Prototype/Scriptaculous first.  And if you are using jx_compressed.js,  
that is just a copy of jx_combined.js that has been minified using  
jsmin (or any other minifier).

Cheers

Paul


On 14-Nov-08, at 4:45 AM, gingerbbm wrote:

>
> Thanks for your reply, Paul.
>
> The solution I arrived at - and I'm not really very happy about it -  
> was to
> do a search n' replace on the string "Prototype" in the MapGuide  
> Fusion code
> (so that it's now "OPrototype"). It appears to solve my issues.
>
> Of course this is not sustainable but it means I can use the latest  
> version
> of Prototype (and Scriptaculous) in the rest of my site without  
> worrying -
> or resorting to nasty frames - at least until it's time to upgrade.
>
> Questions:
> 1. Why does Fusion not use the full version of Prototype?
> 2. Will Fusion 2.0 use the full (and latest) version of Prototype?
> 3. Does Mootools rely on a full version of Prototype (or does it use a
> subset a la Fusion 1.x)?
>
> Cheers
> Stuart
> --
> View this message in context: http://n2.nabble.com/Multiple-versions-of-prototype.js-tp1494625p1497776.html
> Sent from the Fusion Users mailing list archive at Nabble.com.
>
> _______________________________________________
> fusion-users mailing list
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/fusion-users


__________________________________________

    Paul Spencer
    Chief Technology Officer
    DM Solutions Group Inc
    http://research.dmsolutions.ca/

_______________________________________________
fusion-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fusion-users
gingerbbm

Re: Multiple versions of prototype.js

Reply Threaded More More options
Print post
Permalink


Paul Spencer-2 wrote:
>
> Or you could just remove those lines from jx_combined.js load your own
> Prototype/Scriptaculous first.
>


I quite like the sound of that.

The thing is, when I implemented my search/replace solution to rename the
Prototype object, I used a brute force approach which impacted the following
files:

http://n2.nabble.com/file/n1498158/fusion_files_containing_prototype.png 

Is jx_combined.js really all I'd need to change?


--
View this message in context: http://n2.nabble.com/Multiple-versions-of-prototype.js-tp1494625p1498158.html
Sent from the Fusion Users mailing list archive at Nabble.com.

_______________________________________________
fusion-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fusion-users
Paul Spencer-2

Re: Multiple versions of prototype.js

Reply Threaded More More options
Print post
Permalink
The scriptaculous stuff is directly embedded in jx_combined.js, so you  
don't need to change that.

Selenium is a testing framework that is not used at runtime (or  
actually ever ;)).  Ignore it.

OpenLayers safely incorporates portions of the Prototype code, it used  
to be based on Prototype but they eventually pulled it out and just  
kept portions of the code.  You *should* be able to leave OpenLayers  
as-is and it should not collide with your new Prototype.

Cheers

Paul

On 14-Nov-08, at 7:00 AM, gingerbbm wrote:

>
>
> Paul Spencer-2 wrote:
>>
>> Or you could just remove those lines from jx_combined.js load your  
>> own
>> Prototype/Scriptaculous first.
>>
>
>
> I quite like the sound of that.
>
> The thing is, when I implemented my search/replace solution to  
> rename the
> Prototype object, I used a brute force approach which impacted the  
> following
> files:
>
> http://n2.nabble.com/file/n1498158/fusion_files_containing_prototype.png
>
> Is jx_combined.js really all I'd need to change?
>
>
> --
> View this message in context: http://n2.nabble.com/Multiple-versions-of-prototype.js-tp1494625p1498158.html
> Sent from the Fusion Users mailing list archive at Nabble.com.
>
> _______________________________________________
> fusion-users mailing list
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/fusion-users


__________________________________________

    Paul Spencer
    Chief Technology Officer
    DM Solutions Group Inc
    http://research.dmsolutions.ca/

_______________________________________________
fusion-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fusion-users
gingerbbm

Re: Multiple versions of prototype.js

Reply Threaded More More options
Print post
Permalink

Alas, it's not working.

The Event.stop() calls are failing on "event.preventDefault()" and thefore
"Fusion.Event.FUSION_INITIALIZED" is never triggered. The message in Firebug
is:

    TypeError: event.preventDefault is not a function

I'm struggling to understand what's happening through the call stack so if
you have any ideas please let me know, otherwise I'll revert to my previous
solution.

Thanks
Stuart
--
View this message in context: http://n2.nabble.com/Multiple-versions-of-prototype.js-tp1494625p1498962.html
Sent from the Fusion Users mailing list archive at Nabble.com.

_______________________________________________
fusion-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fusion-users
Paul Spencer-2

Re: Multiple versions of prototype.js

Reply Threaded More More options
Print post
Permalink
Try replacing Event.stop(e) in the fusion code with  
OpenLayers.Event.stop(e);

On 14-Nov-08, at 10:33 AM, gingerbbm wrote:

>
> Alas, it's not working.
>
> The Event.stop() calls are failing on "event.preventDefault()" and  
> thefore
> "Fusion.Event.FUSION_INITIALIZED" is never triggered. The message in  
> Firebug
> is:
>
>    TypeError: event.preventDefault is not a function
>
> I'm struggling to understand what's happening through the call stack  
> so if
> you have any ideas please let me know, otherwise I'll revert to my  
> previous
> solution.
>
> Thanks
> Stuart
> --
> View this message in context: http://n2.nabble.com/Multiple-versions-of-prototype.js-tp1494625p1498962.html
> Sent from the Fusion Users mailing list archive at Nabble.com.
>
> _______________________________________________
> fusion-users mailing list
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/fusion-users


__________________________________________

    Paul Spencer
    Chief Technology Officer
    DM Solutions Group Inc
    http://research.dmsolutions.ca/

_______________________________________________
fusion-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fusion-users
gingerbbm

Re: Multiple versions of prototype.js

Reply Threaded More More options
Print post
Permalink

Thanks for the suggestion but it looks like that will impact various widget
code files, and it seems the lesser of two evils to change the Prototype
references rather than changing Event.stop().

Thanks
Stuart
--
View this message in context: http://n2.nabble.com/Multiple-versions-of-prototype.js-tp1494625p1508728.html
Sent from the Fusion Users mailing list archive at Nabble.com.

_______________________________________________
fusion-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fusion-users