Using WebViewer in WordPress

39 views
Skip to first unread message

Skip Gaede

unread,
May 30, 2014, 9:10:39 AM5/30/14
to pdfnet-w...@googlegroups.com
I have taken the index.html  provided with the WebViewer kit and can now use it in Wordpress (3.9.1), but to do it the right way, I need to use the WordPress versions of several JavaScript libraries:
  • jQuery (1.11.0)
  • jQuery_ui (1.10.4)
  • underscore (1.6.0)
  • backbone (1.1.2)
I have verified that using these versions works fine in the stand alone WebViewer. There are two sticking points though:
  1. http://codex.wordpress.org/Function_Reference/wp_enqueue_script#jQuery_noConflict_Wrappers  The jQuery in Wordpress uses a feature called noConflict wrappers. There are instruction on the web page on how to modify the user code to make it work with their library. Can someone point me to where to insert the fix in the WebViewer application?
  2. jQuery_ui in the WebViewer kit is bundled as a single minified file, whereas in WordPress all of the components are minified separately. Until the jQuery issue is resolved, I do not know that this is an issue. If I need to load the components individually, is there a list of what features in jQuery_ui are required?
Thanks!

Matt Parizeau

unread,
Jun 2, 2014, 1:33:04 PM6/2/14
to pdfnet-w...@googlegroups.com
I think you would just need to look at the html file you're using and see what WebViewer JavaScript files are being loaded and then inside those files you could wrap the code inside like they mention in your link:
(function($) {
    // Inside of this function, $() will work as an alias for jQuery()
    // and other libraries also using $ will not be accessible under this shortcut
})(jQuery);
Instead of above you may also just be able to add this after the jQuery script has been loaded and before other scripts are loaded:
window.$ = jQuery;

We don't have a list with everything we're using but the ones I know of are:
draggable, resizable, selectable, button, dialog, slider, tabs

There may be more so let me know if this turns out to be a problem

Matt Parizeau
Software Developer
PDFTron Systems Inc.
Reply all
Reply to author
Forward
0 new messages