1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133:
<?php
$plugin_is_filter = 800 | THEME_PLUGIN;
$plugin_description = gettext('Loads Colorbox JS and CSS scripts for selected theme page scripts.');
$plugin_notice = gettext('Note that this plugin does not attach Colorbox to any element. You need to do this on your theme yourself.');
$plugin_author = 'Stephen Billard (sbillard)';
$plugin_category = gettext('Media');
$option_interface = 'colorbox';
global $_zp_gallery, $_zp_gallery_page;
if (OFFSET_PATH) {
zp_register_filter('admin_head', 'colorbox::css');
} else {
zp_register_filter('theme_head', 'colorbox::css');
}
class colorbox {
function __construct() {
foreach (getThemeFiles(array('404.php', 'themeoptions.php', 'theme_description.php', 'slideshow.php', 'functions.php', 'password.php', 'sidebar.php', 'register.php', 'contact.php')) as $theme => $scripts) {
foreach ($scripts as $script) {
purgeOption('colorbox_' . $theme . '_' . stripSuffix($script));
}
}
setOptionDefault('colorbox_theme', 'example1');
}
function getOptionsSupported() {
global $_zp_gallery;
$themes = getPluginFiles('colorbox_js/themes/*.*');
$list = array('Custom (theme based)' => 'custom');
foreach ($themes as $theme) {
$theme = stripSuffix(basename($theme));
$list[ucfirst($theme)] = $theme;
}
$opts = array(gettext('Colorbox theme') => array(
'key' => 'colorbox_theme',
'type' => OPTION_TYPE_SELECTOR,
'order' => 0,
'selections' => $list,
'desc' => gettext("The Colorbox script comes with 5 example themes you can select here. If you select <em>custom (within theme)</em> you need to place a folder <em>colorbox_js</em> containing a <em>colorbox.css</em> file and a folder <em>images</em> within the current theme to override to use a custom Colorbox theme."))
);
return $opts;
}
function handleOption($option, $currentValue) {
}
static function css() {
global $_zp_gallery;
$inTheme = false;
if (OFFSET_PATH) {
$themepath = 'colorbox_js/themes/example4/colorbox.css';
} else {
$theme = getOption('colorbox_theme');
if (empty($theme)) {
$themepath = 'colorbox_js/themes/example4/colorbox.css';
} else {
if ($theme == 'custom') {
$themepath = zp_apply_filter('colorbox_themepath', 'colorbox_js/colorbox.css');
} else {
$themepath = 'colorbox_js/themes/' . $theme . '/colorbox.css';
}
$inTheme = $_zp_gallery->getCurrentTheme();
}
}
$css = getPlugin($themepath, $inTheme, true);
?>
<link rel="stylesheet" href="<?php echo $css; ?>" type="text/css" />
<script type="text/javascript" src="<?php echo FULLWEBPATH . "/" . ZENFOLDER . '/' . PLUGIN_FOLDER; ?>/colorbox_js/jquery.colorbox-min.js"></script>
<script>
var resizeTimer;
function resizeColorBoxImage() {
if (resizeTimer)
clearTimeout(resizeTimer);
resizeTimer = setTimeout(function () {
if (jQuery('#cboxOverlay').is(':visible')) {
jQuery.colorbox.resize({width: '90%'});
jQuery('#cboxLoadedContent img').css('max-width', '100%').css('height', 'auto');
}
}, 300)
}
function resizeColorBoxMap() {
if (resizeTimer)
clearTimeout(resizeTimer);
resizeTimer = setTimeout(function () {
var mapw = $(window).width() * 0.8;
var maph = $(window).height() * 0.7;
if (jQuery('#cboxOverlay').is(':visible')) {
$.colorbox.resize({innerWidth: mapw, innerHeight: maph});
$('#cboxLoadedContent iframe').contents().find('#map_canvas').css('width', '100%').css('height', maph - 20);
}
}, 500)
}
window.addEventListener("orientationchange", function () {
resizeColorBoxImage();
parent.resizeColorBoxMap()
}, false);
</script>
<?php
}
}
?>