Author: fil@rezo.net
Date: Thu Aug 3 22:58:33 2006
New Revision: 4388
Log:
thickbox gere maintenant une galerie entiere et fonctionne dans l'espace prive (a condition d'avoir la derniere modif de spip)
Modified:
_plugins_/thickbox/head.php
_plugins_/thickbox/thickbox.css
_plugins_/thickbox/thickbox.js
Modified: _plugins_/thickbox/head.php
--- _plugins_/thickbox/head.php (original)
+++ _plugins_/thickbox/head.php Thu Aug 3 22:58:33 2006
@@ -10,18 +10,9 @@
<script type="text/javascript"><!--
TB_chemin_animation = "'.url_absolue(find_in_path('circle_animation.gif')).'";
// --></script>
-<script src="'.find_in_path('thickbox.js').'" type="text/javascript"></script>
+<script src="'.url_absolue(find_in_path('thickbox.js')).'" type="text/javascript"></script>
';
-//jquery.js passe en plugin separe
-//$flux .= '<script src="'.find_in_path('jquery.js').'" type="text/javascript"></script>';
-
-/*
-$flux .= '<script type="text/javascript" src="'
- .generer_url_public('lightbox_js').'"></script>';
- $flux .= "<link rel='stylesheet' href='"
- .generer_url_public('lightbox_css')."' type='text/css' media='all' />\n";
-*/
return $flux;
}
Modified: _plugins_/thickbox/thickbox.css
--- _plugins_/thickbox/thickbox.css (original)
+++ _plugins_/thickbox/thickbox.css Thu Aug 3 22:58:33 2006
@@ -7,7 +7,7 @@
/* ---------->>> CSS Hacks <<<---------------------------------------------------------------*/
-#TB_window {font-size: 1.2em}
+#TB_window { /*font-size: 1.2em */ }
#contentPad{
margin:20px;
@@ -37,7 +37,7 @@
z-index: 102;
color:#000000;
display:none;
- border: 4px solid #525252;
+ border: 2px solid #525252;
}
#TB_window img {
Modified: _plugins_/thickbox/thickbox.js
--- _plugins_/thickbox/thickbox.js (original)
+++ _plugins_/thickbox/thickbox.js Thu Aug 3 22:58:33 2006
@@ -3,56 +3,74 @@
* By Cody Lindley (http://www.codylindley.com)
* Under an Attribution, Share Alike License
* Thickbox is built on top of the very light weight jquery library.
+ *
+ * Modified for SPIP <www.spip.net> by Fil <fil@rezo.net>
+ *
*/
-//on page load call TB_init
-$(document).ready(TB_init);
-
-
-//add thickbox to href elements that have a class of .thickbox
-TB_Image = function() {
+function TB_Image() {
var t = this.title || this.name || '<small>'+this.href+'</small>';
- TB_show(t,this.href);
- this.blur();
+ TB_on();
+ TB_show(t,this.href,'image');
return false;
-};
+}
function TB_init(){
+ // add the thickbox to all links of class=thickbox
+ $("a.thickbox").click(TB_Image);
+
+ // and to all links of type image/jpeg (or gif|png)
+ // here we also deal with the prev/next thing
+ $("a[@type]")
+ .each(
+ function(i) {
+ if (
+ this.type.match(/^image[\/](jpeg|gif|png)$/i)
+ ) {
+ this.onclick = TB_Image;
+
+ // on stocke le lien dans un tableau
+ imageArray.push ([
+ this.href,
+ this.title || this.name
+ ]);
+
+ }
+ }
+ );
+
+ // and to all links to images (maybe too slow?)
+/*
$("a[@href]").each(
function(i) {
if (
- this.type
- ? this.type.match(/image[\/](jpeg|gif|png)/i)
- : (this.href
- ? this.href.match(/^[^?]+\.(jpeg|jpg|gif|png)$/i)
- : false
- ) || this.className == 'thickbox'
+ this.href.match(/^[^?]+\.(jpeg|jpg|gif|png)$/i)
) {
this.onclick = TB_Image;
}
}
);
+*/
}
+function TB_on() {
-
-function TB_show(caption, url) {//function called when the user clicks on a thickbox link
- try {
-
- $("body").append("<iframe id='TB_HideSelect'></iframe><div id='TB_overlay'></div><div id='TB_window'></div>");
- $("#TB_overlay").click(TB_remove);
+ $("body").append("<div id='TB_overlay'></div><div id='TB_window'></div>");
+ $("#TB_overlay").click(TB_next);
$(window).scroll(TB_position);
-
- $("#TB_HideSelect").css({display:"block"});
TB_overlaySize();
- $("body").append("<div id='TB_load'><img src='"+TB_chemin_animation+"' /></div>");
+ $("body").append("<div id='TB_load' style='display:none;'><img src='"+TB_chemin_animation+"' /></div>");
TB_load_position();
+}
+
+function TB_show(caption, url, type) {//function called when the user clicks on a thickbox link
+ try {
var urlString = /\.jpg|\.jpeg|\.png|\.gif|\.html|\.htm|\.php|\.cfm|\.asp|\.aspx|\.jsp|\.jst|\.rb|\.txt/g;
var urlType = url.toLowerCase().match(urlString);
- if(urlType == '.jpg' || urlType == '.jpeg' || urlType == '.png' || urlType == '.gif'){//code to show images
+ if (type=='image' || urlType == '.jpg' || urlType == '.jpeg' || urlType == '.png' || urlType == '.gif'){//code to show images
imgPreloader = new Image();
imgPreloader.onload = function(){
@@ -89,7 +107,7 @@
$("#TB_closeWindowButton").click(TB_remove);
TB_position();
$("#TB_load").remove();
- $("#TB_ImageOff").click(TB_remove);
+ $("#TB_ImageOff").click(TB_next);
$("#TB_window").slideDown();
}
@@ -133,11 +151,31 @@
//helper functions below
function TB_remove() {
- $("#TB_window").fadeOut("fast",function(){$('#TB_window,#TB_overlay,#TB_HideSelect').remove();});
+ $("#TB_window").fadeOut("fast",function(){$('#TB_window,#TB_overlay').remove();});
$("#TB_load").remove();
return false;
}
+function TB_next() {
+ var current = $("#TB_Image").get(0).src;
+ for (var i=0; i<imageArray.length; i++) {
+ if (imageArray[i][0] == current) {
+ var next = i+1;
+ }
+ }
+
+ if (next<imageArray.length) {
+ $("#TB_window").html('');
+ TB_show(imageArray[next][1] || imageArray[next][0],
+ imageArray[next][0], 'image');
+ }
+ else {
+ TB_remove();
+ }
+
+ return false;
+}
+
function TB_position() {
var pagesize = getPageSize();
var arrayPageScroll = getPageScrollTop();
@@ -205,3 +243,11 @@
arrayPageSize = new Array(w,h)
return arrayPageSize;
}
+
+
+/* init */
+// $(document).load(TB_init) si on veut que ca marche dans l'espace prive
+// (a cause des document_write() qu'il y a en pagaille...)
+// $(document).ready(TB_init);
+var imageArray = [];
+$(document).load(TB_init);