Floatbox and Drupal aggregated JS

Page: 1

Author Post
Member
Registered: Feb 2011
Posts: 3
I am using Floatbox on a Drupal site.
The Floatbox files floatbox.js and floatbox.css are loaded via a module i build to load extra CSS and JS files.
Drupal has the ability to aggregate all JS files that have to be loaded for a page in one file. It occurred to me that Floatbox stops working when floatbox.js is aggregated in that one file. Keeping it out of aggregation, so loading is separate, makes every thing work fine. Any idea why floatbox.js cannot be aggregated?

Greetings
Luch
Administrator
Registered: Aug 2008
Posts: 3382
Floatbox looks for the floatbox.js include line to determine where to find its supporting files such as modules, graphics and language files. When floatbox.js is aggregated into something else (or renamed) it can't find an include line to parse for the install path.

For exactly this type of scenario, there is an editable customPaths section right at the top of floatbox.js. Unless you have scattered the floatbox folders around to different locations, the only customPath setting you will need to set in there is installBase. Set this to the absolute path of the floatbox folder: e.g., /includes/floatbox/, or whatever it is on your site.
Member
Registered: Feb 2011
Posts: 3
Hello Byron,

Thanks for pointing out customPaths section. I have set installBase to sites/all/libraries/floatbox and everything is working fine!
So you see i used a relative path instead of the absolute path you advised.
The path is relative to Drupal's base path. With this setting i can easily move files from development site, on my local machine, to production site hosted by my provider.

Luch
Administrator
Registered: Aug 2008
Posts: 3382
Be careful with that relative path. While it may work from one folder, pages served from a different folder level within the site will likely fail.
Member
Registered: Feb 2011
Posts: 3
Byron, thanks for warning me. Relative path works in about 97% of the pages. I changed it to an absolute path ( /sites/all/libraries/floatbox ) and checked again.
Now its 100%. :D
Member
Registered: Aug 2012
Posts: 5
Hi Byron,

where is the custompaths in the new floatbox? I can't find it. how can I include the custome path for my drupal module?

Thanks
Administrator
Registered: Aug 2008
Posts: 3382
I took custom path information out of the docs because I really don't want to encourage scattering the floatbox folder contents out to various other folders. It's too easy to run into problems doing that - which is a headache both for the Floatbox user and for me when things don't work and the support requests come in.

But if you must do it, you can define custom paths in an fbPageOptions definition that MUST be placed on the page before (above) the include line for floatbox.js.
<script type="text/javascript">
fbPageOptions = {
modulesPath : &#039;/path/to/modules/&#039;,
languagesPath : &#039;/path/to/languages/folder/&#039;,
graphicsPath : &#039;/path/to/graphics/&#039;
}
</script>

IMPORTANT: The paths must terminate with a '/' character.

The options.js file must always reside in the same folder as floatbox.js and its name is hard-coded and can't be changed. You can however merge floatbox.js and options.js into one file by appending options.js to floatbox.js.

Note that if you change the relative path relationship between floatbox.css and the graphics folder, you will need to modify all the url paths in floatbox.css appropriately.

I would like to emphasis that I discourage breaking apart the floatbox folder.
Member
Registered: Aug 2012
Posts: 5
I will try your suggestion for adding the custom paths in the fbPageOptions and let you know how it goes.

Thanks for your prompt reply.
« Last edit by akbar on Wed Aug 22, 2012 2:23 pm. »
Member
Registered: Aug 2012
Posts: 5
is there a better way to include this? because in drupal I have floatbox js to load dynamically.

MUST be placed on the page before (above) the include line for floatbox.js
« Last edit by akbar on Wed Aug 22, 2012 2:33 pm. »
Administrator
Registered: Aug 2008
Posts: 3382
For custom paths to take effect, the fbPageOptions definition needs to be defined and present before floatbox.js loads and runs. If floatbox.js is being loaded dynamically then this should be easy to accomplish because dynamic implies delayed.

It will save us both grief if you just leave the floatbox folder intact and load it normally. For all the time being burnt trying to alter Floatbox's folder hierarchy and load sequence, you will save at best a few undetectable milliseconds in load time. Note that Floatbox is already modular and does dynamic delayed loading of most of its own code.

Google's PageSpeed service gives the Floatbox demo page 97 out of 100 and this is a very large page loading Floatbox in the standard fashion. I could tweak that score up 1 or 2 points by combing decoration images used on that page into a single sprite. I'm pointing this out to suggest that the time we're spending trying to customize your deployment is going to deliver no detectable benefits, which is why I discourage it and have left this customizing information out of the documentation.
Member
Registered: Aug 2012
Posts: 5
got it working :) now another question I purchased the license while ago and now I am moving our courses (I work for a university) to a new cms and want to purchase another license for that site. if for example the site is
https://courses.university.edu/course 1
https://courses.university.edu/course 2

and so on I just need to purchase license for the https://courses.university.edu/ right?

Thanks
Administrator
Registered: Aug 2008
Posts: 3382
I think so. Licensing is per web site, so if all the courses comprise a single integrated web site then just the one license is required. If they are independent web sites (generally indicated by separate content, audience, home pages and navigation) then they would each require their own registration. You're in the best position to determine whether you are deploying a single site or multiple sites. If it is multiples, be sure to take advantage of the reduced cost of registration multi-paks.
Member
Registered: Aug 2012
Posts: 5
okay thanks! it is a single site. basically all goes through the site I already purchased the license but will purchase another license since there are two seperate addresses.
« Last edit by akbar on Wed Aug 22, 2012 4:34 pm. »

Page: 1