Version Description
Download this release
Release Info
Developer | moskis |
Plugin | FancyBox for WordPress |
Version | 1.1 |
Comparing to | |
See all releases |
Version 1.1
- fancybox.php +71 -0
- img/fancy_closebox.png +0 -0
- img/fancy_ie_closebox.gif +0 -0
- img/fancy_left.gif +0 -0
- img/fancy_progress.png +0 -0
- img/fancy_right.gif +0 -0
- img/fancy_shadow_corners.png +0 -0
- img/fancy_shadow_horizontal.png +0 -0
- img/fancy_shadow_vertical.png +0 -0
- img/fancy_title_sprite.png +0 -0
- jquery.fancybox.js +384 -0
- readme.txt +72 -0
fancybox.php
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: FancyBox for WordPress
|
4 |
+
Plugin URI: http://blog.moskis.net/downloads/plugins/fancybox-for-wordpress/
|
5 |
+
Description: Integrates <a href="http://fancy.klade.lv/">FancyBox</a> by <a href="http://klade.lv/">Janis Skarnelis</a> into WordPress. All images on a page are treated as a gallery allowing to use Next and Previous buttons on the FancyBox frontend.
|
6 |
+
Version: 1.1
|
7 |
+
Author: Jose Pardilla (Th3 ProphetMan)
|
8 |
+
Author URI: http://blog.moskis.net/
|
9 |
+
*/
|
10 |
+
|
11 |
+
define( 'WPFANCYBOXHOME', get_option('siteurl') . '/wp-content/plugins/fancybox-for-wordpress/' ); // Get full url to plugin path
|
12 |
+
|
13 |
+
function wp_fancybox_do() {
|
14 |
+
|
15 |
+
// CSS is included here to reduce the number of server calls. ?>
|
16 |
+
<style type="text/css">
|
17 |
+
div#fancy_overlay{position:absolute;top:0;left:0;z-index:90;width:100%;background-color:#333;}
|
18 |
+
div#fancy_loading{position:absolute;height:40px;width:40px;cursor:pointer;display:none;overflow:hidden;background:transparent;z-index:100;}
|
19 |
+
div#fancy_loading div{position:absolute;top:0;left:0;width:40px;height:480px;background:transparent url(<?php echo WPFANCYBOXHOME; ?>img/fancy_progress.png) no-repeat;}
|
20 |
+
div#fancy_close{position:absolute;top:-12px;right:-12px;height:30px;width:30px;background:transparent url(<?php echo WPFANCYBOXHOME; ?>img/fancy_closebox.png);cursor:pointer;z-index:100;display:none;}
|
21 |
+
div#fancy_content{position:absolute;top:0;left:0;width:100%;height:100%;z-index:96;margin:0;padding:0;}
|
22 |
+
#fancy_frame{position:relative;width:100%;height:100%;display:none;}
|
23 |
+
img#fancy_img{position:absolute;top:0;left:0;width:100%;height:100%;border:0;z-index:92;margin:0;padding:0;}
|
24 |
+
div#fancy_title{position:absolute;bottom:-35px;left:0;width:100%;z-index:100;display:none;}
|
25 |
+
div#fancy_title table{margin:0 auto;}div#fancy_title div{color:#FFF;font:bold 12px Arial;padding-bottom:2px;}
|
26 |
+
td#fancy_title_left{height:32px;width:15px;background:transparent url(<?php echo WPFANCYBOXHOME; ?>img/fancy_title_sprite.png) no-repeat 0 -32px;}
|
27 |
+
td#fancy_title_main{height:32px;background:transparent url(<?php echo WPFANCYBOXHOME; ?>img/fancy_title_sprite.png) repeat-x;}
|
28 |
+
td#fancy_title_right{height:32px;width:15px;background:transparent url(<?php echo WPFANCYBOXHOME; ?>img/fancy_title_sprite.png) no-repeat 0 -64px;}
|
29 |
+
div#fancy_outer{position:absolute;top:0;left:0;z-index:90;overflow:hidden;background:transparent;display:none;margin:0;padding:18px 18px 58px;}
|
30 |
+
div#fancy_inner{position:relative;width:100%;height:100%;border:1px solid #444;background:#FFF;}
|
31 |
+
a#fancy_left,a#fancy_right{position:absolute;bottom:10px;height:100%;width:35%;cursor:pointer;background-image:url(data:image/gif;base64,AAAA);z-index:100;}
|
32 |
+
a#fancy_left{left:0;}a#fancy_right{right:0;}a#fancy_left:hover{background:transparent url(<?php echo WPFANCYBOXHOME; ?>img/fancy_left.gif) no-repeat 0 50%;}
|
33 |
+
a#fancy_right:hover{background:transparent url(<?php echo WPFANCYBOXHOME; ?>img/fancy_right.gif) no-repeat 100% 50%;}
|
34 |
+
#fancy_bigIframe,#fancy_freeIframe{position:absolute;top:0;left:0;width:100%;height:100%;z-index:10;}
|
35 |
+
div#fancy_bg{display:none;} div.fancy_bg{position:absolute;display:block;z-index:70;}
|
36 |
+
div.fancy_bg_n{top:-18px;width:100%;height:18px;background:transparent url(<?php echo WPFANCYBOXHOME; ?>img/fancy_shadow_horizontal.png) repeat-x;}
|
37 |
+
div.fancy_bg_ne{top:-18px;right:-13px;width:13px;height:18px;background:transparent url(<?php echo WPFANCYBOXHOME; ?>img/fancy_shadow_corners.png) no-repeat -13px 0;}
|
38 |
+
div.fancy_bg_e{right:-13px;height:100%;width:13px;background:transparent url(<?php echo WPFANCYBOXHOME; ?>img/fancy_shadow_vertical.png) repeat-y -13px 0;}
|
39 |
+
div.fancy_bg_se{bottom:-18px;right:-13px;width:13px;height:18px;background:transparent url(<?php echo WPFANCYBOXHOME; ?>img/fancy_shadow_corners.png) no-repeat -13px -18px;}
|
40 |
+
div.fancy_bg_s{bottom:-18px;width:100%;height:18px;background:transparent url(<?php echo WPFANCYBOXHOME; ?>img/fancy_shadow_horizontal.png) repeat-x 0 -18px;}
|
41 |
+
div.fancy_bg_sw{bottom:-18px;left:-13px;width:13px;height:18px;background:transparent url(<?php echo WPFANCYBOXHOME; ?>img/fancy_shadow_corners.png) no-repeat 0 -18px;}
|
42 |
+
div.fancy_bg_w{left:-13px;height:100%;width:13px;background:transparent url(<?php echo WPFANCYBOXHOME; ?>img/fancy_shadow_vertical.png) repeat-y;}
|
43 |
+
div.fancy_bg_nw{top:-18px;left:-13px;width:13px;height:18px;background:transparent url(<?php echo WPFANCYBOXHOME; ?>img/fancy_shadow_corners.png) no-repeat;}
|
44 |
+
* html div.fancy_bg_n,* html div.fancy_bg_ne,* html div.fancy_bg_e,* html div.fancy_bg_se,* html div.fancy_bg_s,* html div.fancy_bg_sw,* html div.fancy_bg_w,* html div.fancy_bg_nw{background:none;}
|
45 |
+
* html td#fancy_title_left,* html td#fancy_title_main,* html td#fancy_title_right{background:#000;}
|
46 |
+
* html div#fancy_close{background:url(<?php echo WPFANCYBOXHOME; ?>img/fancy_ie_closebox.gif);}
|
47 |
+
</style>
|
48 |
+
|
49 |
+
<script type="text/javascript">
|
50 |
+
jQuery.noConflict(); // Apply jQuery.noConflict()
|
51 |
+
jQuery(function(){
|
52 |
+
jQuery("a:has(img)[href$='.jpg']").attr({ rel: "fancybox" }); // These four lines add the rel="fancybox"
|
53 |
+
jQuery("a:has(img)[href$='.jpeg']").attr({ rel: "fancybox" }); // attribute to all links that contain
|
54 |
+
jQuery("a:has(img)[href$='.gif']").attr({ rel: "fancybox" }); // an image (i.e thumbnail) and link
|
55 |
+
jQuery("a:has(img)[href$='.png']").attr({ rel: "fancybox" }); // to a JPG, JPEG, PNG or GIF image.
|
56 |
+
jQuery("a[rel='fancybox']").fancybox(); //This applies fancybox to the links we have just edited.
|
57 |
+
});
|
58 |
+
</script>
|
59 |
+
|
60 |
+
<?php
|
61 |
+
|
62 |
+
}
|
63 |
+
|
64 |
+
function wp_fancybox_init() {
|
65 |
+
wp_enqueue_script('fancybox', WPFANCYBOXHOME . 'jquery.fancybox.js', array('jquery') ); // Load fancybox with jQuery
|
66 |
+
}
|
67 |
+
|
68 |
+
add_action('wp_print_scripts', 'wp_fancybox_init'); // Add the fancybox script to the WordPress head
|
69 |
+
add_action('wp_head', 'wp_fancybox_do'); // Add css and apply fancyboy the the page loads
|
70 |
+
|
71 |
+
?>
|
img/fancy_closebox.png
ADDED
Binary file
|
img/fancy_ie_closebox.gif
ADDED
Binary file
|
img/fancy_left.gif
ADDED
Binary file
|
img/fancy_progress.png
ADDED
Binary file
|
img/fancy_right.gif
ADDED
Binary file
|
img/fancy_shadow_corners.png
ADDED
Binary file
|
img/fancy_shadow_horizontal.png
ADDED
Binary file
|
img/fancy_shadow_vertical.png
ADDED
Binary file
|
img/fancy_title_sprite.png
ADDED
Binary file
|
jquery.fancybox.js
ADDED
@@ -0,0 +1,384 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*
|
2 |
+
* FancyBox - simple jQuery plugin for fancy image zooming
|
3 |
+
* Examples and documentation at: http://fancy.klade.lv/
|
4 |
+
* Version: 1.0.0 (29/04/2008)
|
5 |
+
* Copyright (c) 2008 Janis Skarnelis
|
6 |
+
* Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php
|
7 |
+
* Requires: jQuery v1.2.1 or later
|
8 |
+
*/
|
9 |
+
(function(jQuery) {
|
10 |
+
var opts = {},
|
11 |
+
imgPreloader = new Image, imgTypes = ['png', 'jpg', 'jpeg', 'gif'],
|
12 |
+
loadingTimer, loadingFrame = 1;
|
13 |
+
|
14 |
+
jQuery.fn.fancybox = function(settings) {
|
15 |
+
opts.settings = jQuery.extend({}, jQuery.fn.fancybox.defaults, settings);
|
16 |
+
|
17 |
+
jQuery.fn.fancybox.init();
|
18 |
+
|
19 |
+
return this.each(function() {
|
20 |
+
var $this = jQuery(this);
|
21 |
+
var o = jQuery.metadata ? jQuery.extend({}, opts.settings, jQuerythis.metadata()) : opts.settings;
|
22 |
+
|
23 |
+
$this.unbind('click').click(function() {
|
24 |
+
jQuery.fn.fancybox.start(this, o); return false;
|
25 |
+
});
|
26 |
+
});
|
27 |
+
};
|
28 |
+
|
29 |
+
jQuery.fn.fancybox.start = function(el, o) {
|
30 |
+
if (opts.animating) return false;
|
31 |
+
|
32 |
+
if (o.overlayShow) {
|
33 |
+
jQuery("#fancy_wrap").prepend('<div id="fancy_overlay"></div>');
|
34 |
+
jQuery("#fancy_overlay").css({'width': jQuery(window).width(), 'height': jQuery(document).height(), 'opacity': o.overlayOpacity});
|
35 |
+
|
36 |
+
if (jQuery.browser.msie) {
|
37 |
+
jQuery("#fancy_wrap").prepend('<iframe id="fancy_bigIframe" scrolling="no" frameborder="0"></iframe>');
|
38 |
+
jQuery("#fancy_bigIframe").css({'width': jQuery(window).width(), 'height': jQuery(document).height(), 'opacity': 0});
|
39 |
+
}
|
40 |
+
|
41 |
+
jQuery("#fancy_overlay").click(jQuery.fn.fancybox.close);
|
42 |
+
}
|
43 |
+
|
44 |
+
opts.itemArray = [];
|
45 |
+
opts.itemNum = 0;
|
46 |
+
|
47 |
+
if (jQuery.isFunction(o.itemLoadCallback)) {
|
48 |
+
o.itemLoadCallback.apply(this, [opts]);
|
49 |
+
|
50 |
+
var c = jQuery(el).children("img:first").length ? jQuery(el).children("img:first") : jQuery(el);
|
51 |
+
var tmp = {'width': c.width(), 'height': c.height(), 'pos': jQuery.fn.fancybox.getPosition(c)}
|
52 |
+
|
53 |
+
for (var i = 0; i < opts.itemArray.length; i++) {
|
54 |
+
opts.itemArray[i].o = jQuery.extend({}, o, opts.itemArray[i].o);
|
55 |
+
|
56 |
+
if (o.zoomSpeedIn > 0 || o.zoomSpeedOut > 0) {
|
57 |
+
opts.itemArray[i].orig = tmp;
|
58 |
+
}
|
59 |
+
}
|
60 |
+
|
61 |
+
} else {
|
62 |
+
if (!el.rel || el.rel == '') {
|
63 |
+
var item = {url: el.href, title: el.title, o: o};
|
64 |
+
|
65 |
+
if (o.zoomSpeedIn > 0 || o.zoomSpeedOut > 0) {
|
66 |
+
var c = jQuery(el).children("img:first").length ? jQuery(el).children("img:first") : jQuery(el);
|
67 |
+
item.orig = {'width': c.width(), 'height': c.height(), 'pos': jQuery.fn.fancybox.getPosition(c)}
|
68 |
+
}
|
69 |
+
|
70 |
+
opts.itemArray.push(item);
|
71 |
+
|
72 |
+
} else {
|
73 |
+
var arr = jQuery("a[@rel=" + el.rel + "]").get();
|
74 |
+
|
75 |
+
for (var i = 0; i < arr.length; i++) {
|
76 |
+
var tmp = jQuery.metadata ? jQuery.extend({}, o, jQuery(arr[i]).metadata()) : o;
|
77 |
+
var item = {url: arr[i].href, title: arr[i].title, o: tmp};
|
78 |
+
|
79 |
+
if (o.zoomSpeedIn > 0 || o.zoomSpeedOut > 0) {
|
80 |
+
var c = jQuery(arr[i]).children("img:first").length ? jQuery(arr[i]).children("img:first") : jQuery(el);
|
81 |
+
|
82 |
+
item.orig = {'width': c.width(), 'height': c.height(), 'pos': jQuery.fn.fancybox.getPosition(c)}
|
83 |
+
}
|
84 |
+
|
85 |
+
if (arr[i].href == el.href) opts.itemNum = i;
|
86 |
+
|
87 |
+
opts.itemArray.push(item);
|
88 |
+
}
|
89 |
+
}
|
90 |
+
}
|
91 |
+
|
92 |
+
jQuery.fn.fancybox.changeItem(opts.itemNum);
|
93 |
+
};
|
94 |
+
|
95 |
+
jQuery.fn.fancybox.changeItem = function(n) {
|
96 |
+
jQuery.fn.fancybox.showLoading();
|
97 |
+
|
98 |
+
opts.itemNum = n;
|
99 |
+
|
100 |
+
jQuery("#fancy_nav").empty();
|
101 |
+
jQuery("#fancy_outer").stop();
|
102 |
+
jQuery("#fancy_title").hide();
|
103 |
+
jQuery(document).unbind("keydown");
|
104 |
+
|
105 |
+
imgRegExp = imgTypes.join('|');
|
106 |
+
imgRegExp = new RegExp('\.' + imgRegExp + 'jQuery', 'i');
|
107 |
+
|
108 |
+
var url = opts.itemArray[n].url;
|
109 |
+
|
110 |
+
if (url.match(/#/)) {
|
111 |
+
var target = window.location.href.split('#')[0]; target = url.replace(target,'');
|
112 |
+
|
113 |
+
jQuery.fn.fancybox.showItem('<div id="fancy_div">' + jQuery(target).html() + '</div>');
|
114 |
+
|
115 |
+
jQuery("#fancy_loading").hide();
|
116 |
+
|
117 |
+
} else if (url.match(imgRegExp)) {
|
118 |
+
jQuery(imgPreloader).unbind('load').bind('load', function() {
|
119 |
+
jQuery("#fancy_loading").hide();
|
120 |
+
|
121 |
+
opts.itemArray[n].o.frameWidth = imgPreloader.width;
|
122 |
+
opts.itemArray[n].o.frameHeight = imgPreloader.height;
|
123 |
+
|
124 |
+
jQuery.fn.fancybox.showItem('<img id="fancy_img" title="Click to close" src="' + imgPreloader.src + '" />');
|
125 |
+
|
126 |
+
}).attr('src', url + '?rand=' + Math.floor(Math.random() * 999999999) );
|
127 |
+
|
128 |
+
} else {
|
129 |
+
jQuery.fn.fancybox.showItem('<iframe id="fancy_frame" onload="jQuery.fn.fancybox.showIframe()" name="fancy_iframe' + Math.round(Math.random()*1000) + '" frameborder="0" hspace="0" src="' + url + '"></iframe>');
|
130 |
+
}
|
131 |
+
};
|
132 |
+
|
133 |
+
jQuery.fn.fancybox.showIframe = function() {
|
134 |
+
jQuery("#fancy_loading").hide();
|
135 |
+
jQuery("#fancy_frame").show();
|
136 |
+
};
|
137 |
+
|
138 |
+
jQuery.fn.fancybox.showItem = function(val) {
|
139 |
+
jQuery.fn.fancybox.preloadNeighborImages();
|
140 |
+
|
141 |
+
var viewportPos = jQuery.fn.fancybox.getViewport();
|
142 |
+
var itemSize = jQuery.fn.fancybox.getMaxSize(viewportPos[0] - 50, viewportPos[1] - 100, opts.itemArray[opts.itemNum].o.frameWidth, opts.itemArray[opts.itemNum].o.frameHeight);
|
143 |
+
|
144 |
+
var itemLeft = viewportPos[2] + Math.round((viewportPos[0] - itemSize[0]) / 2) - 20;
|
145 |
+
var itemTop = viewportPos[3] + Math.round((viewportPos[1] - itemSize[1]) / 2) - 40;
|
146 |
+
|
147 |
+
var itemOpts = {
|
148 |
+
'left': itemLeft,
|
149 |
+
'top': itemTop,
|
150 |
+
'width': itemSize[0] + 'px',
|
151 |
+
'height': itemSize[1] + 'px'
|
152 |
+
}
|
153 |
+
|
154 |
+
if (opts.active) {
|
155 |
+
jQuery('#fancy_content').fadeOut("normal", function() {
|
156 |
+
jQuery("#fancy_content").empty();
|
157 |
+
|
158 |
+
jQuery("#fancy_outer").animate(itemOpts, "normal", function() {
|
159 |
+
jQuery("#fancy_content").append(jQuery(val)).fadeIn("normal");
|
160 |
+
jQuery.fn.fancybox.updateDetails();
|
161 |
+
});
|
162 |
+
});
|
163 |
+
|
164 |
+
} else {
|
165 |
+
opts.active = true;
|
166 |
+
|
167 |
+
jQuery("#fancy_content").empty();
|
168 |
+
|
169 |
+
if (jQuery("#fancy_content").is(":animated")) {
|
170 |
+
console.info('animated!');
|
171 |
+
}
|
172 |
+
|
173 |
+
if (opts.itemArray[opts.itemNum].o.zoomSpeedIn > 0) {
|
174 |
+
opts.animating = true;
|
175 |
+
itemOpts.opacity = "show";
|
176 |
+
|
177 |
+
jQuery("#fancy_outer").css({
|
178 |
+
'top': opts.itemArray[opts.itemNum].orig.pos.top - 18,
|
179 |
+
'left': opts.itemArray[opts.itemNum].orig.pos.left - 18,
|
180 |
+
'height': opts.itemArray[opts.itemNum].orig.height,
|
181 |
+
'width': opts.itemArray[opts.itemNum].orig.width
|
182 |
+
});
|
183 |
+
|
184 |
+
jQuery("#fancy_content").append(jQuery(val)).show();
|
185 |
+
|
186 |
+
jQuery("#fancy_outer").animate(itemOpts, opts.itemArray[opts.itemNum].o.zoomSpeedIn, function() {
|
187 |
+
opts.animating = false;
|
188 |
+
jQuery.fn.fancybox.updateDetails();
|
189 |
+
});
|
190 |
+
|
191 |
+
} else {
|
192 |
+
jQuery("#fancy_content").append(jQuery(val)).show();
|
193 |
+
jQuery("#fancy_outer").css(itemOpts).show();
|
194 |
+
jQuery.fn.fancybox.updateDetails();
|
195 |
+
}
|
196 |
+
}
|
197 |
+
};
|
198 |
+
|
199 |
+
jQuery.fn.fancybox.updateDetails = function() {
|
200 |
+
jQuery("#fancy_bg,#fancy_close").show();
|
201 |
+
|
202 |
+
if (opts.itemArray[opts.itemNum].title !== undefined && opts.itemArray[opts.itemNum].title !== '') {
|
203 |
+
jQuery('#fancy_title div').html(opts.itemArray[opts.itemNum].title);
|
204 |
+
jQuery('#fancy_title').show();
|
205 |
+
}
|
206 |
+
|
207 |
+
if (opts.itemArray[opts.itemNum].o.hideOnContentClick) {
|
208 |
+
jQuery("#fancy_content").click(jQuery.fn.fancybox.close);
|
209 |
+
} else {
|
210 |
+
jQuery("#fancy_content").unbind('click');
|
211 |
+
}
|
212 |
+
|
213 |
+
if (opts.itemNum != 0) {
|
214 |
+
jQuery("#fancy_nav").append('<a id="fancy_left" href="javascript:;"></a>');
|
215 |
+
|
216 |
+
jQuery('#fancy_left').click(function() {
|
217 |
+
jQuery.fn.fancybox.changeItem(opts.itemNum - 1); return false;
|
218 |
+
});
|
219 |
+
}
|
220 |
+
|
221 |
+
if (opts.itemNum != (opts.itemArray.length - 1)) {
|
222 |
+
jQuery("#fancy_nav").append('<a id="fancy_right" href="javascript:;"></a>');
|
223 |
+
|
224 |
+
jQuery('#fancy_right').click(function(){
|
225 |
+
jQuery.fn.fancybox.changeItem(opts.itemNum + 1); return false;
|
226 |
+
});
|
227 |
+
}
|
228 |
+
|
229 |
+
jQuery(document).keydown(function(event) {
|
230 |
+
if (event.keyCode == 27) {
|
231 |
+
jQuery.fn.fancybox.close();
|
232 |
+
|
233 |
+
} else if(event.keyCode == 37 && opts.itemNum != 0) {
|
234 |
+
jQuery.fn.fancybox.changeItem(opts.itemNum - 1);
|
235 |
+
|
236 |
+
} else if(event.keyCode == 39 && opts.itemNum != (opts.itemArray.length - 1)) {
|
237 |
+
jQuery.fn.fancybox.changeItem(opts.itemNum + 1);
|
238 |
+
}
|
239 |
+
});
|
240 |
+
};
|
241 |
+
|
242 |
+
jQuery.fn.fancybox.preloadNeighborImages = function() {
|
243 |
+
if ((opts.itemArray.length - 1) > opts.itemNum) {
|
244 |
+
preloadNextImage = new Image();
|
245 |
+
preloadNextImage.src = opts.itemArray[opts.itemNum + 1].url;
|
246 |
+
}
|
247 |
+
|
248 |
+
if (opts.itemNum > 0) {
|
249 |
+
preloadPrevImage = new Image();
|
250 |
+
preloadPrevImage.src = opts.itemArray[opts.itemNum - 1].url;
|
251 |
+
}
|
252 |
+
};
|
253 |
+
|
254 |
+
jQuery.fn.fancybox.close = function() {
|
255 |
+
if (opts.animating) return false;
|
256 |
+
|
257 |
+
jQuery(imgPreloader).unbind('load');
|
258 |
+
jQuery(document).unbind("keydown");
|
259 |
+
|
260 |
+
jQuery("#fancy_loading,#fancy_title,#fancy_close,#fancy_bg").hide();
|
261 |
+
|
262 |
+
jQuery("#fancy_nav").empty();
|
263 |
+
|
264 |
+
opts.active = false;
|
265 |
+
|
266 |
+
if (opts.itemArray[opts.itemNum].o.zoomSpeedOut > 0) {
|
267 |
+
var itemOpts = {
|
268 |
+
'top': opts.itemArray[opts.itemNum].orig.pos.top - 18,
|
269 |
+
'left': opts.itemArray[opts.itemNum].orig.pos.left - 18,
|
270 |
+
'height': opts.itemArray[opts.itemNum].orig.height,
|
271 |
+
'width': opts.itemArray[opts.itemNum].orig.width,
|
272 |
+
'opacity': 'hide'
|
273 |
+
};
|
274 |
+
|
275 |
+
opts.animating = true;
|
276 |
+
|
277 |
+
jQuery("#fancy_outer").animate(itemOpts, opts.itemArray[opts.itemNum].o.zoomSpeedOut, function() {
|
278 |
+
jQuery("#fancy_content").hide().empty();
|
279 |
+
jQuery("#fancy_overlay,#fancy_bigIframe").remove();
|
280 |
+
opts.animating = false;
|
281 |
+
});
|
282 |
+
|
283 |
+
} else {
|
284 |
+
jQuery("#fancy_outer").hide();
|
285 |
+
jQuery("#fancy_content").hide().empty();
|
286 |
+
jQuery("#fancy_overlay,#fancy_bigIframe").fadeOut("fast").remove();
|
287 |
+
}
|
288 |
+
};
|
289 |
+
|
290 |
+
jQuery.fn.fancybox.showLoading = function() {
|
291 |
+
clearInterval(loadingTimer);
|
292 |
+
|
293 |
+
var pos = jQuery.fn.fancybox.getViewport();
|
294 |
+
|
295 |
+
jQuery("#fancy_loading").css({'left': ((pos[0] - 40) / 2 + pos[2]), 'top': ((pos[1] - 40) / 2 + pos[3])}).show();
|
296 |
+
jQuery("#fancy_loading").bind('click', jQuery.fn.fancybox.close);
|
297 |
+
|
298 |
+
loadingTimer = setInterval(jQuery.fn.fancybox.animateLoading, 66);
|
299 |
+
};
|
300 |
+
|
301 |
+
jQuery.fn.fancybox.animateLoading = function(el, o) {
|
302 |
+
if (!jQuery("#fancy_loading").is(':visible')){
|
303 |
+
clearInterval(loadingTimer);
|
304 |
+
return;
|
305 |
+
}
|
306 |
+
|
307 |
+
jQuery("#fancy_loading > div").css('top', (loadingFrame * -40) + 'px');
|
308 |
+
|
309 |
+
loadingFrame = (loadingFrame + 1) % 12;
|
310 |
+
};
|
311 |
+
|
312 |
+
jQuery.fn.fancybox.init = function() {
|
313 |
+
if (!jQuery('#fancy_wrap').length) {
|
314 |
+
jQuery('<div id="fancy_wrap"><div id="fancy_loading"><div></div></div><div id="fancy_outer"><div id="fancy_inner"><div id="fancy_nav"></div><div id="fancy_close"></div><div id="fancy_content"></div><div id="fancy_title"></div></div></div></div>').appendTo("body");
|
315 |
+
jQuery('<div id="fancy_bg"><div class="fancy_bg fancy_bg_n"></div><div class="fancy_bg fancy_bg_ne"></div><div class="fancy_bg fancy_bg_e"></div><div class="fancy_bg fancy_bg_se"></div><div class="fancy_bg fancy_bg_s"></div><div class="fancy_bg fancy_bg_sw"></div><div class="fancy_bg fancy_bg_w"></div><div class="fancy_bg fancy_bg_nw"></div></div>').prependTo("#fancy_inner");
|
316 |
+
|
317 |
+
jQuery('<table cellspacing="0" cellpadding="0" border="0"><tr><td id="fancy_title_left"></td><td id="fancy_title_main"><div></div></td><td id="fancy_title_right"></td></tr></table>').appendTo('#fancy_title');
|
318 |
+
}
|
319 |
+
|
320 |
+
if (jQuery.browser.msie) {
|
321 |
+
jQuery("#fancy_inner").prepend('<iframe id="fancy_freeIframe" scrolling="no" frameborder="0"></iframe>');
|
322 |
+
}
|
323 |
+
|
324 |
+
if (jQuery.fn.pngFix) jQuery(document).pngFix();
|
325 |
+
|
326 |
+
jQuery("#fancy_close").click(jQuery.fn.fancybox.close);
|
327 |
+
};
|
328 |
+
|
329 |
+
jQuery.fn.fancybox.getPosition = function(el) {
|
330 |
+
var pos = el.offset();
|
331 |
+
|
332 |
+
pos.top += jQuery.fn.fancybox.num(el, 'paddingTop');
|
333 |
+
pos.top += jQuery.fn.fancybox.num(el, 'borderTopWidth');
|
334 |
+
|
335 |
+
pos.left += jQuery.fn.fancybox.num(el, 'paddingLeft');
|
336 |
+
pos.left += jQuery.fn.fancybox.num(el, 'borderLeftWidth');
|
337 |
+
|
338 |
+
return pos;
|
339 |
+
};
|
340 |
+
|
341 |
+
jQuery.fn.fancybox.num = function (el, prop) {
|
342 |
+
return parseInt(jQuery.curCSS(el.jquery?el[0]:el,prop,true))||0;
|
343 |
+
};
|
344 |
+
|
345 |
+
jQuery.fn.fancybox.getPageScroll = function() {
|
346 |
+
var xScroll, yScroll;
|
347 |
+
|
348 |
+
if (self.pageYOffset) {
|
349 |
+
yScroll = self.pageYOffset;
|
350 |
+
xScroll = self.pageXOffset;
|
351 |
+
} else if (document.documentElement && document.documentElement.scrollTop) {
|
352 |
+
yScroll = document.documentElement.scrollTop;
|
353 |
+
xScroll = document.documentElement.scrollLeft;
|
354 |
+
} else if (document.body) {
|
355 |
+
yScroll = document.body.scrollTop;
|
356 |
+
xScroll = document.body.scrollLeft;
|
357 |
+
}
|
358 |
+
|
359 |
+
return [xScroll, yScroll];
|
360 |
+
};
|
361 |
+
|
362 |
+
jQuery.fn.fancybox.getViewport = function() {
|
363 |
+
var scroll = jQuery.fn.fancybox.getPageScroll();
|
364 |
+
|
365 |
+
return [jQuery(window).width(), jQuery(window).height(), scroll[0], scroll[1]];
|
366 |
+
};
|
367 |
+
|
368 |
+
jQuery.fn.fancybox.getMaxSize = function(maxWidth, maxHeight, imageWidth, imageHeight) {
|
369 |
+
var r = Math.min(Math.min(maxWidth, imageWidth) / imageWidth, Math.min(maxHeight, imageHeight) / imageHeight);
|
370 |
+
|
371 |
+
return [Math.round(r * imageWidth), Math.round(r * imageHeight)];
|
372 |
+
};
|
373 |
+
|
374 |
+
jQuery.fn.fancybox.defaults = {
|
375 |
+
hideOnContentClick: true,
|
376 |
+
zoomSpeedIn: 500,
|
377 |
+
zoomSpeedOut: 500,
|
378 |
+
frameWidth: 600,
|
379 |
+
frameHeight: 400,
|
380 |
+
overlayShow: false,
|
381 |
+
overlayOpacity: 0.4,
|
382 |
+
itemLoadCallback: null
|
383 |
+
};
|
384 |
+
})(jQuery);
|
readme.txt
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== FancyBox for WordPress ===
|
2 |
+
Contributors: moskis
|
3 |
+
Donate link: https://www.asmallorange.com/extras/donate/?id=10218
|
4 |
+
Tags: fancybox, lightbox, jquery, image, gallery
|
5 |
+
Requires at least: 2.7
|
6 |
+
Tested up to: 2.7
|
7 |
+
Stable tag: 1.1
|
8 |
+
|
9 |
+
Seamlessly integrates FancyBox into your blog: Upload, activate, and you're done. No further configuration needed.
|
10 |
+
|
11 |
+
== Description ==
|
12 |
+
|
13 |
+
Seamlessly integrates [FancyBox](http://fancy.klade.lv/) into your blog: Upload, activate and you're done. No further configuration needed.
|
14 |
+
|
15 |
+
All images on the page will be considered part of a gallery, allowing you and your visitors to navigate through them with the [FancyBox](http://fancy.klade.lv/) interface.
|
16 |
+
|
17 |
+
The plugin will use jQuery to apply [FancyBox](http://fancy.klade.lv/) to ANY image links that open an image. This includes posts, the sidebar, etc.
|
18 |
+
|
19 |
+
The requirements are that the link is an image (for example a thumbnail), and that it links to a JPG, PNG or GIF file (that will be the bigger image).
|
20 |
+
|
21 |
+
[FancyBox](http://fancy.klade.lv/) will NOT be applied on text links, but i will implement a configuration page in the admin panel to optionally customize that and much more stuff in future versions.
|
22 |
+
|
23 |
+
Finally, i have only tested the plugin in WordPress 2.7, but it should work on recent previous versions. However, there's no reason why you shouldn't be already using WP2.7, is there? ;)
|
24 |
+
|
25 |
+
1.1 Fixes:
|
26 |
+
|
27 |
+
* Fixed FancyBox not being applied to .jpeg files
|
28 |
+
* Fixed "Click to close" overlay text
|
29 |
+
* Moved images to /img/ folder
|
30 |
+
|
31 |
+
|
32 |
+
== Installation ==
|
33 |
+
|
34 |
+
1. Upload the `fancybox-for-wordpress` folder to the `/wp-content/plugins/` directory
|
35 |
+
2. Activate the plugin through the 'Plugins' menu in WordPress
|
36 |
+
3. See [FancyBox](http://fancy.klade.lv/) magically applied to all your image links and galleries.
|
37 |
+
|
38 |
+
|
39 |
+
== Frequently Asked Questions ==
|
40 |
+
|
41 |
+
= About future releases =
|
42 |
+
|
43 |
+
Future releases will continue to work without having to make any configuration, but i will provide an options page to allow customization of the [FancyBox](http://fancy.klade.lv/) effect, and being able to change where it is used in your blog.
|
44 |
+
|
45 |
+
= No worky, what now? =
|
46 |
+
|
47 |
+
If the plugin is not working or you find any bug/bad behaviour/conflict deactivate it and email me at jose (at) moskis.net with a description of the problem, and i'll take a look at it.
|
48 |
+
|
49 |
+
If activating the plugin somehow brakes your panel (cant imagine that happening but just in case) delete the plugin from the plugins folder and go to your blog panel.
|
50 |
+
|
51 |
+
= Suggestions and feature requests? =
|
52 |
+
|
53 |
+
Don't hesitate to email me at jose (at) moskis.net with any thoughts about this plugin, feature requests, issues, doubts suggestions, anything goes. :)
|
54 |
+
|
55 |
+
= How does the plugin exactly work? =
|
56 |
+
|
57 |
+
First the plugin checks if your blog uses jQuery, if not it will load it from the WordPress files. Then it will load the FancyBox JavaScript, which is where all the magic happens. After this all the CSS code needed to beautify the plugin is added to the page. Finally, the JavaScript wait for your blog to finish loading and then it looks for all links where FancyBox can be applied, and adds it. And that's it. :)
|
58 |
+
|
59 |
+
= The plugin does not work with Mandingo theme =
|
60 |
+
|
61 |
+
To fix this edit the file /themes/mandigo/header.php and remove the line 231:
|
62 |
+
|
63 |
+
<code><script type="text/javascript" src="<?php echo $dirs['www']['js']; ?>jquery.js"></script></code>
|
64 |
+
|
65 |
+
After applying this fix everything seems to work perfectly.
|
66 |
+
|
67 |
+
|
68 |
+
== Demo ==
|
69 |
+
|
70 |
+
You can see the plugin working on [my blog](http://blog.moskis.net/downloads/plugins/fancybox-for-wordpress/) although there's nothing amazing to see, just a FancyBox simple implementation, that's the point ;)
|
71 |
+
|
72 |
+
You can take a look at the code if you're curious, though. Most of it is in the Head section of the page.
|