share-extras / media-viewers

Enhanced document previews for a range of different document and media types, plus a dashlet allowing any content item to be displayed on a site dashboard.
Apache License 2.0
29 stars 23 forks source link

spinner.js is not loaded in latest 4.2.d build #5

Closed wabson closed 10 years ago

wabson commented 11 years ago

Rendering of the viewer currently fails on 4.2.d and an error is logged to the console indicating that the Spinner function (constructor) does not exist.

The spinner source is being loaded correctly, but for some reason the function is not created in the window scope and is not defined during initialisation of the viewer or indeed afterwards (e.g. if tested from the Web Console).

Observed on Chrome 26.

deas commented 11 years ago

I guess dojo in 4.2.d breaks it.

/*                                                                                                                                                
  if (typeof define == 'function' && define.amd)                                                                                                  
    define(function() { return Spinner })                                                                                                         
  else                                                                                                                                            
*/
    window.Spinner = Spinner

in ./META-INF/extras/components/preview/spin.js from version 2.5.1 helped me getting around the problem.

jpotts commented 10 years ago

I confirm that the problem exists on 4.2.d Community Edition and deas' fix solves the problem.

wabson commented 10 years ago

I'm not sure I understand what the fix is here. Are you suggesting we should fork the code in spin.js to add the above snippet? If so then where?

loftux commented 10 years ago

This can be fixed by adding the latest version of spin.js (1.3.2) from https://raw.github.com/fgnass/spin.js/gh-pages/spin.js
Then comment row 13

/* AMD module */
   //else if (typeof define == 'function' && define.amd) define(factory)

As can be noted the code detects the dojo framework and assumes it should be loaded from that framework. Commenting that line and it works again.