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