We''re building a JavaScript framework for a web application and would like to use prototype for easier DOM access and ajax. The problem is, we want to be as little intrusive as possible. So you just include our core js file on your html page and you''re done. Our framework just adds some special functionality to the website and should not interfere with the application. The problem is if a customer uses an old version of prototype, we have a conflict of the functions like $. We would like to keep the current application untouched but still use the latest prototype version. So what I was thinking of is to have prototype as a part of our framework in its own namespace. So we could use something like: myFramework.$("id").show(); First of all would this be possible at all? If yes, what has to be done to achieve this? If not, is there a schematic view of which functionality depends on which other? As we certainly don''t need all prototype parts, we could just copy the ones we need and put them in our framework to achieve the above result (if the license alows this at all) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Hiya, You might try ProtoSafe (code.google.com/p/protosafe) OR for demos (protolific.net). The SVN repo is the most recent (has some documentation updates). ProtoSafe encapsulates/modifies Prototype and all included files. Increases compatibility with 3rd party scripts by keeping Prototype out of the global namespace, as much as possible, and by subclassing the Array object to avoid for-in loop pollution. You can create a single standalone js file and include it in your pages. Everything is highly documented. Small file footprint (3kb gzipped or smaller in standalone). Has custom Packer 3 that is compatible with Prototype 1.6+ This may be what you are looking for. Soon I will be releasing a server side solution for compressing and auto ProtoSafe modifying files. JDD --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Because everythign is encapsulated there is no need to namespace Prototype methods. You simply use Prototype as normal, Prototype''s $() will not conflict with other $() functions outside of its closure. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Hi JD On Mar 19, 5:06 pm, jdalton <John.David.Dal...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Because everythign is encapsulated there is no need to namespace > Prototype methods. > You simply use Prototype as normal, Prototype''s $() will not conflict > with other $() functions outside of its closure.It does look like what I need, but I still don''t understand how this works. For me the file after the modification looks exactly the same as before. So no wrapper function as Mislav propoeses. Did I miss something there? I just had the prototype.js as the input file... --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Hi JD Thanks, that looks like what I need. Do I understand this right, I have to place everything that want''s to use prototype functions within this empty wrapper function? What exactly are the code parts on top of the standalone script good for (ProtoSafe Class and functions)? Thomas (I realized that most users use their real name instead of a nickname, so I changed it) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Hiya Thomas, I may need to clean up the readme file. Would you please email me your initial impressions of what you thought it was instructing you to do? My email is either posted here or in the readme. I am really wanting user feedback. So far over a hundred downloads and zero comments :/. Basic usage: (Requires all files to be pre-modified with the ./tools/ modify.html) <script type="text/javascript" src="protosafe.js? load=yourScript,yourOtherScript,andSoOn"></script> Inside your directory you would have prototype.js, protosafe.js, yourScript.js, yourOtherScript.js, and andSoOn.js OR Standalone usage: (It''s a regular javascript file, name it whatever you want) <script type="text/javascript" src="standalone.js"></script> You use the ./tools/modify.html file to compile all scripts into 1 file (this is preferred for production use). The readme file explains a step by step of how to do this. The ProtoSafe object is the bootstrap that loads Prototype + other included files. In the standalone mode ProtoSafe is stripped down to a minimum with only the parts used to remove MooTools extensions and the $Array object. -JDD --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Will do, but one more remark regarding this from my side. With your ProtoSafe class you again could cause problems if, in the very unlikely case, some other framework also uses this method to wrap prototype.js into an anonymous function. With what option do I have to pre modify other scripts: AJAX Loader ? When should I use the Dean Edwards Packer 3.0 options? Thomas On Mar 20, 4:18 pm, jdalton <John.David.Dal...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hiya Thomas, > > I may need to clean up the readme file. Would you please email me your > initial impressions of what you thought it was instructing you to do? > My email is either posted here or in the readme. I am really wanting > user feedback. So far over a hundred downloads and zero comments :/. > > Basic usage: (Requires all files to be pre-modified with the ./tools/ > modify.html) > <script type="text/javascript" src="protosafe.js? > load=yourScript,yourOtherScript,andSoOn"></script> > > Inside your directory you would have prototype.js, protosafe.js, > yourScript.js, yourOtherScript.js, and andSoOn.js > > OR > > Standalone usage: (It''s a regular javascript file, name it whatever > you want) > <script type="text/javascript" src="standalone.js"></script> > > You use the ./tools/modify.html file to compile all scripts into 1 > file (this is preferred for production use). > The readme file explains a step by step of how to do this. > > The ProtoSafe object is the bootstrap that loads Prototype + other > included files. In the standalone mode ProtoSafe is stripped down to a > minimum with only the parts used to remove MooTools extensions and the > $Array object. > > -JDD--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---