Added JavaScript zoom function for preview images. Fixes #19.
This commit is contained in:
50
script.js
Normal file
50
script.js
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* For Filelist Plugin
|
||||||
|
*
|
||||||
|
* @author joachimmueller
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* run on document load, setup everything we need
|
||||||
|
*/
|
||||||
|
jQuery(function () {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
// CONFIG
|
||||||
|
|
||||||
|
// these 2 variable determine popup's distance from the cursor
|
||||||
|
// you might want to adjust to get the right result
|
||||||
|
var xOffset = 10;
|
||||||
|
var yOffset = 30;
|
||||||
|
|
||||||
|
// END CONFIG
|
||||||
|
|
||||||
|
jQuery("img.filelist_preview").hover(function (e) {
|
||||||
|
this.t = this.title;
|
||||||
|
this.title = "";
|
||||||
|
|
||||||
|
var c;
|
||||||
|
if (this.t !== "") {
|
||||||
|
c = "<br/>" + this.t;
|
||||||
|
} else {
|
||||||
|
c = "";
|
||||||
|
}
|
||||||
|
jQuery("body").append("<p id='__filelist_preview'><img src='" + this.src + "' alt='Image preview' />" + c + "</p>");
|
||||||
|
jQuery("#__filelist_preview")
|
||||||
|
.css("top", (e.pageY - xOffset) + "px")
|
||||||
|
.css("left", (e.pageX + yOffset) + "px")
|
||||||
|
.css("max-width", "300px")
|
||||||
|
.css("max-height", "300px")
|
||||||
|
.css("position", "absolute")
|
||||||
|
.fadeIn("fast");
|
||||||
|
}, function () {
|
||||||
|
this.title = this.t;
|
||||||
|
jQuery("#__filelist_preview").remove();
|
||||||
|
});
|
||||||
|
jQuery("img.filelist_preview").mousemove(function (e) {
|
||||||
|
jQuery("#__filelist_preview")
|
||||||
|
.css("top", (e.pageY - xOffset) + "px")
|
||||||
|
.css("left", (e.pageX + yOffset) + "px")
|
||||||
|
.css("position", "absolute");
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -89,6 +89,7 @@ class syntax_plugin_filelist extends DokuWiki_Syntax_Plugin {
|
|||||||
'showsize' => 0,
|
'showsize' => 0,
|
||||||
'showdate' => 0,
|
'showdate' => 0,
|
||||||
'listsep' => '", "',
|
'listsep' => '", "',
|
||||||
|
'onhover' => 0,
|
||||||
);
|
);
|
||||||
foreach($flags as $flag) {
|
foreach($flags as $flag) {
|
||||||
list($name, $value) = explode('=', $flag);
|
list($name, $value) = explode('=', $flag);
|
||||||
@@ -517,7 +518,11 @@ class syntax_plugin_filelist extends DokuWiki_Syntax_Plugin {
|
|||||||
if ($previewsize == 0) {
|
if ($previewsize == 0) {
|
||||||
$previewsize = 32;
|
$previewsize = 32;
|
||||||
}
|
}
|
||||||
$renderer->doc .= '<img style=" max-height: '.$previewsize.'px; max-width: '.$previewsize.'px;" src="'.$imgLink.'">';
|
$imgclass = '';
|
||||||
|
if ($params['onhover']) {
|
||||||
|
$imgclass = 'class="filelist_preview"';
|
||||||
|
}
|
||||||
|
$renderer->doc .= '<img '.$imgclass.' style=" max-height: '.$previewsize.'px; max-width: '.$previewsize.'px;" src="'.$imgLink.'">';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user