Hi Ruben, On 12/04/2013 12:10 PM, Ruben M. wrote:
Hello XWiki team & users,
First of all thanks a lot for your great work.
I’ve set up XWiki as an intranet website (version 5.2.1). Currenty I’m trying to customize it with some javascript to make life easier for the users.
I experimented a bit with jQuery (as I have a bit of experience with it) and have successfully integrated it into a test page via the jQuery Helpers Extension (http://extensions.xwiki.org/xwiki/bin/view/Extension/jQuery+Helpers) Now I want to include a jQuery Plugin which extends the jQuery functions. I’d like to try out the live tiles in Windows 8 style from Drew Greenwell (http://www.drewgreenwell.com/projects/metrojs).
It’s no big deal to get the liveTiles working - On a local webserver without Xwiki. Here’s the problem: The functions from metrojs seem to collide with prototype.js. I experimented a bit with jQuerynoConflict(); , I tried to rename the functions inside metroJS.js, but nothing worked so far. Firebug says ‘$ele.attr is not a function’ inside the metrojs-Code in the console, which I believe is a problem with prototype.js. (See for the XWiki test page code at the end of the mail – I won’t post the whole MetroJS-Code here, it’s a little big).
My questions are: a) Is there a possibility to deactivate / rename / “defuse” prototype.js, or to listen for another shortcut than $ on this page (something like prototypeNoConflict();) ?
No, prototype is not really able to do this and much of XWiki and extension js depends on $ being bound to prototype.
b) Has anyone of you any experience with jQuery plugins (or even better, Metrojs!) in XWiki and maybe a hint?
I have experience with jquery, as of XWiki 5.2 you can access that using requirejs. require(['jquery'], function ($) { $('#xwikicontent').append('<p>hello world</p>') }); I recommend wrapping metrojs in a similar function to avoid conflicts while still giving it access to jquery as it requires.
c) Is there a possibility of producing some kind of “liveTiles” with prototype.js (which I’m not very experienced with)
prototype is (gingerly) moving toward retirement and the best support will always be found in the jQuery world. http://sstephenson.us/posts/you-are-not-your-code Thanks, Caleb
I know it’s more of a javascript-related question, so thanks a lot for reading this anyway.
Regards Ruben
#################
Here’s the current code of my test page (ADMIN is the test space):
{{velocity}} $xwiki.jsx.use("jQuery.jQuery", {'defer': false}) $xwiki.jsx.use("ADMIN.MetroJS") $xwiki.ssx.use("ADMIN.MetroCSS") {{/velocity}}
{{html}} Carousel Mode: Simple
<div class="red"> <div id="tile1" data-mode="carousel" data-start-now="true" class="live-tile" data-direction="horizontal" data-delay="3000"> <div> <http://www.drewgreenwell.com/images/sample/1tw.gif> </div> <div> <http://www.drewgreenwell.com/images/sample/2tw.gif> </div> <div class="accent emerald"><p class="metroExtraLarge">2 and a half</p></div> <div> <http://www.drewgreenwell.com/images/sample/3tw.gif> </div> <div> <http://www.drewgreenwell.com/images/sample/4tw.gif> </div> </div> </div>
{{/html}}
-- View this message in context: http://xwiki.475771.n2.nabble.com/jQuery-plugin-Conflict-with-prototype-js-t... Sent from the XWiki- Users mailing list archive at Nabble.com. _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users