[SPIP] +spip v3.0.17
[lhc/web/clavette_www.git] / www / plugins-dist / mediabox / javascript / spip.mediabox.js
1 // Inside the function "this" will be "document" when called by ready()
2 // and "the ajaxed element" when called because of onAjaxLoad
3 var mediaboxInit = function() {
4 //console.log(box_settings);
5 var options = {
6 transition:box_settings.trans,
7 speed:box_settings.speed,
8 maxWidth:box_settings.maxW,
9 maxHeight:box_settings.maxH,
10 minWidth:box_settings.minW,
11 minHeight:box_settings.minH,
12 opacity:box_settings.opa,
13 slideshowSpeed:box_settings.ssSpeed,
14 slideshowStart:box_settings.str_ssStart,
15 slideshowStop:box_settings.str_ssStop,
16 current:box_settings.str_cur,
17 previous:box_settings.str_prev,
18 next:box_settings.str_next,
19 close:box_settings.str_close,
20 splash_url:box_settings.splash_url
21 };
22
23 // passer le portfolio de la dist en mode galerie
24 if (box_settings.sel_g){
25 jQuery(box_settings.sel_g, this).not('.hasbox,#colorbox')
26 .attr("onclick","") // se debarrasser du onclick de SPIP
27 .colorbox(jQuery.extend({}, options, {rel:'galerieauto',slideshow:true,slideshowAuto:false}))
28 .addClass("hasbox");
29 }
30
31 if (box_settings.tt_img) {
32 // selectionner tous les liens vers des images
33 jQuery("a[type=\'image/jpeg\'],a[type=\'image/png\'],a[type=\'image/gif\']",this).not('.hasbox')
34 .attr("onclick","") // se debarrasser du onclick de SPIP
35 .colorbox(options) // activer la box
36 .addClass("hasbox") // noter qu\'on l\'a vue
37 ;
38 }
39
40 // charger la box sur autre chose
41 if (box_settings.sel_c){
42 jQuery(box_settings.sel_c).not('.hasbox')
43 .colorbox(jQuery.extend({}, options, {slideshow:true,slideshowAuto:false}))
44 .addClass("hasbox") // noter qu\'on l\'a vue
45 ;
46 }
47 };
48
49 /* initialiser maintenant si box_settings est deja la
50 * nb en cas de defer sur le chargement du scipt javascript principal
51 */
52 if (typeof(box_settings)!='undefined')
53 (function($){ if(typeof onAjaxLoad == "function") onAjaxLoad(mediaboxInit); $(mediaboxInit); })(jQuery);
54
55 ;(function ($) {
56 /*
57 * overlayClose: (Boolean:false) Allow click on overlay to close the dialog?
58 * iframe: (Boolean:false) Open box in iframe
59 * minHeight: (Number:200) The minimum height for the container
60 * minWidth: (Number:200) The minimum width for the container
61 * maxHeight: (Number:null) The maximum height for the container. If not specified, the window height is used.
62 * maxWidth: (Number:null) The maximum width for the container. If not specified, the window width is used.
63 * autoResize: (Boolean:false) Resize container on window resize? Use with caution - this may have undesirable side-effects.
64 * onOpen: (Function:null) The callback function used in place of SimpleModal's open
65 * onShow: (Function:null) The callback function used after the modal dialog has opened
66 * onClose: (Function:null) The callback function used in place of SimpleModal's close
67 */
68 $.fn.mediabox = function (options) {
69 var cbox_options = {
70 overlayClose: true,
71 iframe: false,
72 maxWidth:box_settings.maxW,
73 maxHeight:box_settings.maxH,
74 minWidth:box_settings.minW,
75 minHeight:box_settings.minH,
76 opacity:box_settings.opa,
77 slideshowStart:box_settings.str_ssStart,
78 slideshowStop:box_settings.str_ssStop,
79 current:box_settings.str_cur,
80 previous:box_settings.str_prev,
81 next:box_settings.str_next,
82 close:box_settings.str_close,
83 onOpen: (options && options.onOpen) || null,
84 onComplete: (options && options.onShow) || null,
85 onClosed: (options && options.onClose) || null
86 };
87
88 return this.colorbox($.extend(cbox_options,options));
89 };
90 $.mediaboxClose = function () {$.fn.colorbox.close();};
91
92 // API modalbox
93 $.modalbox = function (href, options) {$.fn.mediabox($.extend({href:href,inline:href.match(/^#/),overlayClose:true},options));};
94 $.modalboxload = function (url, options) { $.modalbox(url,options); };
95 $.modalboxclose = $.mediaboxClose;
96
97 })(jQuery);