Namespace the Portal's copy of jQuery

Description

As we move toward morpheus and the inlined portal, we will be mixing tool markup with the background document. Some tools are stuck on old versions of jQuery and it hard to upgrade the jQuery in the tool. As an example, both the preferences tool and Lessons use Infusion - which includes a full copy of jQuery bundled in Infusion and infusion does not work with later copies of jQuery. And these tools do things like load jQuery, add plugins to jQuery, register handlers, and then make global scoped functions that access global variables like $ and jQuery.

Using jQuery.noConflict() it is possible to run two copies of jQuery at the same time as long as you keep things straight. One of the versions lives in $ and jQuery and the other version lives in a variable like "$old_jquery".

So either the tools or the portal need to access a jQuery through one of these other variables. While it might sound like a good idea to fix the tools, it is actually more reliable to teach the portal and portal scripts not to use $ or jQuery and instead use our own global variable to access jQuery in the portal.

The first part is to introduce a variable $PBJQ to be used within portal scripts to access the latest jQuery loaded by the portal with all the plugins that are loaded by the portal.

References:

https://forum.jquery.com/topic/multiple-versions-of-jquery-on-the-same-page
http://stackoverflow.com/questions/1566595/can-i-use-multiple-versions-of-jquery-on-the-same-page

Attachments

1
  • 05 Dec 2014, 09:32 PM

is related to

Activity

Show:

Charles R Severance June 24, 2015 at 11:42 PM

This is done.

Hudson CI Server December 6, 2014 at 5:07 AM

SUCCESS: Integrated in sakai-trunk-java-1.7 #554 (See http://builds.sakaiproject.org:8080/job/sakai-trunk-java-1.7/554/)
https://sakaiproject.atlassian.net/browse/SAK-28162#icft=SAK-28162

Namespace the morpheus scripts to use the global $PBJQ
instead of $ and jQuery

Mark - I may not have done this the most elegant way. If
there is some grunt magic that would do this better - feel free
to tweak the approach. (csev@umich.edu: rev 315939)
https://sakaiproject.atlassian.net/browse/SAK-28162#icft=SAK-28162

Refactor the portal code to place the portal's good copy of jQuery
1.9.1 in the variable $PBJQ (Peanut Butter and JQuery) and modify
portal scripts to access via $PDJQ instead of jQuery and $

We leave jQuery and $ as whatever the tool prefers so if they
define global functions and then use them - their assumptions
hold.

One small fix that got fixed whilst testing the namespace things
was to copy the portal.chat.video setup code from the neo portal to
the morpheus portal. (csev@umich.edu: rev 315938)

Charles R Severance December 5, 2014 at 9:32 PM

I attach a simepl HTML file that deonstrates the multiple simultaneous jQueries loaded in action.

Fixed

Details

Priority

Affects versions

Fix versions

Components

Assignee

Reporter

Created December 5, 2014 at 9:23 PM
Updated June 24, 2015 at 11:42 PM
Resolved June 24, 2015 at 11:42 PM