"Fancybox" Global jQuery plugin implementation with JSPM / System.js as module: -
i got 'fancybox' working module, can import import fancybox 'fancybox';
inside main app js file. cannot work 'helper' js files, extend functionality of main fancybox function.
jspm package.json in overrides section exports 'fancybox' function main 'source/jquery.fancybox.pack.js' file. should extended helper files.
{ "jspm": { "configfile": "config.js", "dependencies": { "fancybox": "bower:fancybox@^2.1.5", }, "overrides": { "bower:fancybox@2.1.5": { "main": "source/jquery.fancybox.pack.js", "format": "global", "files": [ "source/jquery.fancybox.pack.js", "source/helpers/jquery.fancybox-buttons.js", "source/helpers/jquery.fancybox-media.js", "source/helpers/jquery.fancybox-thumbs.js" ], "shim": { "source/jquery.fancybox.pack.js": { "deps": [ "jquery" ], "exports": "fancybox" }, "source/helpers/jquery.fancybox-buttons.js": { "deps": [ "jquery" ], "exports": "*" }, "source/helpers/jquery.fancybox-media.js": { "deps": [ "jquery" ], "exports": "*" }, "source/helpers/jquery.fancybox-thumbs.js": { "deps": [ "jquery" ], "exports": "*" } } } } } }
main app entery point main.js:
import jquery 'jquery'; import fancybox 'fancybox'; jquery(document).ready(function() { /* * simple image gallery. uses default settings */ if (typeof jquery('.fancybox').fancybox !== 'undefined') { // variable defined jquery('.fancybox').fancybox(); /* * different effects */ // change title type, overlay closing speed jquery(".fancybox-effects-a").fancybox({ helpers: { title : { type : 'outside' }, overlay : { speedout : 0 } } }); // ..... & other helpers , configurations. /* * thumbnail helper. disable animations, hide close button, arrows , slide next gallery item if clicked */ jquery('.fancybox-thumbs').fancybox({ preveffect : 'none', nexteffect : 'none', closebtn : false, arrows : false, nextclick : true, helpers : { thumbs : { width : 50, height : 50 } } }); } });
i'm not sure how combine helpers main function. thanks
- jspm override generator: http://jarreddebeer.github.io/jspm-package-override-generator/public/
- fancybox repo: https://github.com/fancyapps/fancybox & docs: http://fancyapps.com/fancybox/#docs
- jspm registry documentation: https://github.com/jspm/registry/wiki/configuring-packages-for-jspm & http://jspm.io/0.17-beta-guide/overrides.html
- system.js globals format https://github.com/systemjs/systemjs/blob/master/docs/module-formats.md#globals
i've installed latest beta version of jspm 0.17 ... followed documentation version, lot of trial , error, seems fulfill requirement. in package specific file filename@version.json jspm creates i've altered below code. , jspm install caused saved in package.json. after possible import package page, i.e. import 'fancybox; without exports.
{ "main": "source/helpers/jquery.fancybox-thumbs.js", "format": "global", "meta": { "source/jquery.fancybox.pack.js": { "deps": [ "./helpers/jquery.fancybox-thumbs.css!", "./helpers/jquery.fancybox-buttons.css!", "./jquery.fancybox.css!" ], "format": "global", "globals": { "jquery": "jquery" } }, "source/helpers/jquery.fancybox-buttons.js": { "format": "global", "globals": { "jquery": "jquery", "fancybox": "../jquery.fancybox.pack.js" } }, "source/helpers/jquery.fancybox-media.js": { "format": "global", "globals": { "fancybox": "./jquery.fancybox-buttons.js" } }, "source/helpers/jquery.fancybox-thumbs.js": { "format": "global", "globals": { "fancybox": "./jquery.fancybox-media.js" } } }, "map": {} }
Comments
Post a Comment