Skip to content

Commit f1c0368

Browse files
authored
V1.0.0
v1.0.0
1 parent 68db5d1 commit f1c0368

5 files changed

Lines changed: 62 additions & 30 deletions

File tree

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ FancyBox JavaScript library for presenting images in a fancy way, no more openin
99
- MyBB support thread: https://community.mybb.com/thread-219143.html or feel free to create a ticket on GitHub
1010

1111
## Authors and credits:
12-
- Wildcard - for help with coding and fixing bugs in MyBB FanxyBox
13-
- effone - for a lot of useful tips
12+
- Wildcard - for a great help with coding and fixing bugs in MyBB FanxyBox
13+
- effone - for a lot of useful tips and fixes
14+
- iAndrew - for a working sample code for external image URLs support in FancyBox
1415
- lukasamd - for an original idea and MyBB integration
1516
- SvePu - for code improvements - added ability to view all images in a post
1617
- Jānis Skarnelis - as a developer of awesome FancyBox library
1718

18-
## Developed with love by MyBB Group
19-
[![MyBB Group](https://github.com/mybbgroup/MyBB_Fancybox/blob/master/mybbgrouplogo.png?raw=true "MyBB Group")](https://mybb.com "MyBB Group")
19+
## Developed with love by MyBB Group - https://mybb.group
20+
[![MyBB Group](https://github.com/mybbgroup/MyBB_Fancybox/blob/master/mybbgrouplogo.png?raw=true "MyBB Group")](https://mybb.group "MyBB Group")

inc/plugins/mybbfancybox.php

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* MyBB FancyBox - plugin for MyBB 1.8.x forum software
55
*
66
* @package MyBB Plugin
7-
* @author MyBB Group - Eldenroot & Wildcard - <eldenroot@gmail.com>
7+
* @author MyBB Group - Eldenroot & Wildcard & effone - <eldenroot@gmail.com>
88
* @copyright 2019 MyBB Group <http://mybb.group>
99
* @link <https://github.com/mybbgroup/MyBB_Fancybox>
1010
* @license GPL-3.0
@@ -55,11 +55,11 @@ function mybbfancybox_info()
5555

5656
return array(
5757
"name" => $lang->mybbfancybox,
58-
"description" => $lang->mybbfancybox_description,
58+
"description" => $lang->mybbfancybox_description . '<a href=\'https://www.paypal.com/cgi-bin/webscr?cmd=_donations&amount=0&business=eldenroot%40gmail.com&item_name=MyBB+Plugin+Development&no_note=1&no_shipping=1&currency_code=USD\' target=\'_blank\'><img style=\'float: right; margin-top: 5px;\' src=\'https://www.paypalobjects.com/webstatic/en_US/btn/btn_donate_pp_142x27.png\' border=\'0\' alt=\'PayPal Donate\' /></a>',
5959
"website" => "https://github.com/mybbgroup/MyBB_Fancybox",
60-
"author" => "MyBB Group (Eldenroot & Wildcard)",
60+
"author" => "MyBB Group (Eldenroot & Wildcard & effone)",
6161
"authorsite" => "https://github.com/mybbgroup/MyBB_Fancybox",
62-
"version" => "0.9.0dev",
62+
"version" => "1.0.0",
6363
"codename" => "mybbfancybox",
6464
"compatibility" => "18*"
6565
);
@@ -168,7 +168,7 @@ function mybbfancybox_install()
168168
$db->insert_query('settings', $mybbfancybox_setting);
169169

170170
$mybbfancybox_setting = array(
171-
'name' => 'mybbfancybox_include_images_from_urls_into_gallery', // issue GitHub #49
171+
'name' => 'mybbfancybox_include_images_from_urls_into_gallery',
172172
'title' => $lang->mybbfancybox_include_images_from_urls_into_gallery_title,
173173
'description' => $lang->mybbfancybox_include_images_from_urls_into_gallery_description,
174174
'optionscode' => 'yesno',
@@ -178,46 +178,46 @@ function mybbfancybox_install()
178178
);
179179
$db->insert_query('settings', $mybbfancybox_setting);
180180

181-
// FancyBox basic settings - lines #37-48 in mybbfancybox.js in /jscripts folder
181+
// FancyBox basic settings
182182
$mybbfancybox_setting = array(
183183
'name' => 'mybbfancybox_protect_images',
184184
'title' => $lang->mybbfancybox_protect_images_title,
185185
'description' => $lang->mybbfancybox_protect_images_description,
186-
'optionscode' => 'yesno', // false or true value
186+
'optionscode' => 'yesno',
187187
'value' => '0',
188188
'disporder' => '4',
189189
'gid' => $gid
190190
);
191191
$db->insert_query('settings', $mybbfancybox_setting);
192192

193193
$mybbfancybox_setting = array(
194-
'name' => 'mybbfancybox_watermark', // displayed only the previous setting (protect images) is enabled
194+
'name' => 'mybbfancybox_watermark',
195195
'title' => $lang->mybbfancybox_watermark_title,
196196
'description' => $lang->mybbfancybox_watermark_description,
197-
'optionscode' => 'yesno', // CSS class watermark or leave blank to disable (protect images must be enable to use that!)
197+
'optionscode' => 'yesno',
198198
'value' => '0',
199199
'disporder' => '5',
200200
'gid' => $gid
201201
);
202202
$db->insert_query('settings', $mybbfancybox_setting);
203203

204204
$mybbfancybox_setting = array(
205-
'name' => 'mybbfancybox_watermark_low_resolution_images', // displayed only the previous setting (watermark) is enabled
205+
'name' => 'mybbfancybox_watermark_low_resolution_images',
206206
'title' => $lang->mybbfancybox_watermark_low_resolution_images_title,
207207
'description' => $lang->mybbfancybox_watermark_low_resolution_images_description,
208-
'optionscode' => 'yesno', // Exclude low resolution images from adding watermark
208+
'optionscode' => 'yesno',
209209
'value' => '0',
210210
'disporder' => '6',
211211
'gid' => $gid
212212
);
213213
$db->insert_query('settings', $mybbfancybox_setting);
214214

215215
$mybbfancybox_setting = array(
216-
'name' => 'mybbfancybox_watermark_resolutions', // displayed only if the previous setting (watermark exclude...) is set to YES
216+
'name' => 'mybbfancybox_watermark_resolutions',
217217
'title' => $lang->mybbfancybox_watermark_resolutions_title,
218218
'description' => $lang->mybbfancybox_watermark_resolutions_description,
219219
'optionscode' => 'text',
220-
'value' => '300|300', // Instead of using hard-coded values would be better to add a custom box max width X height px
220+
'value' => '300|300',
221221
'disporder' => '7',
222222
'gid' => $gid
223223
);
@@ -227,7 +227,7 @@ function mybbfancybox_install()
227227
'name' => 'mybbfancybox_loop',
228228
'title' => $lang->mybbfancybox_loop_title,
229229
'description' => $lang->mybbfancybox_loop_description,
230-
'optionscode' => 'yesno', // false or true value
230+
'optionscode' => 'yesno',
231231
'value' => '1',
232232
'disporder' => '8',
233233
'gid' => $gid
@@ -238,7 +238,7 @@ function mybbfancybox_install()
238238
'name' => 'mybbfancybox_infobar',
239239
'title' => $lang->mybbfancybox_infobar_title,
240240
'description' => $lang->mybbfancybox_infobar_description,
241-
'optionscode' => 'yesno', // false or true value
241+
'optionscode' => 'yesno',
242242
'value' => '1',
243243
'disporder' => '9',
244244
'gid' => $gid
@@ -249,7 +249,7 @@ function mybbfancybox_install()
249249
'name' => 'mybbfancybox_arrows',
250250
'title' => $lang->mybbfancybox_arrows_title,
251251
'description' => $lang->mybbfancybox_arrows_description,
252-
'optionscode' => 'yesno', // false or true value
252+
'optionscode' => 'yesno',
253253
'value' => '1',
254254
'disporder' => '10',
255255
'gid' => $gid
@@ -260,7 +260,7 @@ function mybbfancybox_install()
260260
'name' => 'mybbfancybox_thumbs',
261261
'title' => $lang->mybbfancybox_thumbs_title,
262262
'description' => $lang->mybbfancybox_thumbs_description,
263-
'optionscode' => 'yesno', // false or true value
263+
'optionscode' => 'yesno',
264264
'value' => '0',
265265
'disporder' => '11',
266266
'gid' => $gid
@@ -271,7 +271,7 @@ function mybbfancybox_install()
271271
'name' => 'mybbfancybox_minimize',
272272
'title' => $lang->mybbfancybox_minimize_title,
273273
'description' => $lang->mybbfancybox_minimize_description,
274-
'optionscode' => 'yesno', // enable or disable feature; CSS is already added into mybbfancybox.css; we need just to load an extra JS + delete commented minimize button in config file (GitHub issue #32)
274+
'optionscode' => 'yesno',
275275
'value' => '1',
276276
'disporder' => '12',
277277
'gid' => $gid
@@ -292,7 +292,7 @@ function mybbfancybox_install()
292292
293293
EOF;
294294

295-
// Settings for buttons - lines #50-58 in mybbfancybox.js in /jscripts folder
295+
// Settings for buttons
296296
$mybbfancybox_setting = array(
297297
'name' => 'mybbfancybox_buttons',
298298
'title' => $lang->mybbfancybox_buttons_title,
@@ -394,6 +394,14 @@ function mybbfancybox_showthread_start()
394394
// Apply required changes in postbit_attachments_images_image template (replace all content)
395395
$templates->cache['postbit_attachments_images_image'] = '<a target="_blank" data-fancybox="data-{$attachment[\'pid\']}" data-type="image"><img src="attachment.php?aid={$attachment[\'aid\']}" class="attachment" alt="" title="{$lang->postbit_attachment_filename} {$attachment[\'filename\']}&#13{$lang->postbit_attachment_size} {$attachment[\'filesize\']}&#13{$lang->mybbfancybox_uploaded} {$attachdate}&#13{$lang->mybbfancybox_views} {$attachment[\'downloads\']}{$lang->mybbfancybox_views_symbol_after}" /></a>&nbsp;&nbsp;&nbsp;';
396396

397+
$buttonArray = (array) unserialize($mybb->settings['mybbfancybox_buttons']);
398+
399+
// Minimize button - load JS code only when enabled in ACP
400+
$minimize = '';
401+
402+
if ($mybb->settings['mybbfancybox_minimize'] == 1) {
403+
array_splice($buttonArray, count($buttonArray)-1, 0, 'minimize');
404+
}
397405
foreach (array(
398406
'mybbfancybox_protect_images' => 'protect',
399407
'mybbfancybox_loop' => 'loop',
@@ -441,8 +449,6 @@ function mybbfancybox_showthread_start()
441449
}
442450
}
443451

444-
$buttonArray = (array) unserialize($mybb->settings['mybbfancybox_buttons']);
445-
446452
if (!empty($buttonArray) &&
447453
count($buttonArray) > 0) {
448454
$buttons = "'".implode("','", $buttonArray)."'";
@@ -478,6 +484,10 @@ function mybbfancybox_showthread_start()
478484
infobar: {$infobar},
479485
arrows: {$arrows},
480486
thumbs: {$thumbs},{$buttons}{$afterLoadScript}
487+
btnTpl: {
488+
minimize:
489+
'<button data-fancybox-minimize class="fancybox-button fancybox-button--minimise" title="{{MINIMIZE}}"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 445 445"><g fill="#010002"><path d="M440.3 4.7a15.9 15.9 0 0 0-22.5 0L286 136.5V47.7a16 16 0 0 0-31.7 0V175l1.2 6 3.3 5 .1.2h.2l5 3.4 6 1.2h127.2a16 16 0 0 0 0-31.8h-88.8L440.3 27.2a16 16 0 0 0 0-22.5zM180.9 255.5l-6-1.2H47.6a16 16 0 0 0 0 31.8h88.7L4.7 417.8A15.9 15.9 0 1 0 27 440.3L159 308.5v88.8a16 16 0 0 0 31.8 0V270.2l-1.2-6a16 16 0 0 0-8.6-8.7z"/></g></svg><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 381.4 381.4"><path d="M380.1 9.8c-1.6-3.9-4.7-7-8.5-8.6L365.5 0h-159a16 16 0 0 0 0 31.8h120.6L31.8 327V206.6a15.9 15.9 0 0 0-31.8 0v159l1.2 6 3.3 5 .1.1.2.1 5 3.4 6 1.2h159a16 16 0 0 0 0-31.8H54.3L349.6 54.3v120.5a16 16 0 0 0 31.8 0v-159l-1.3-6z" fill="#010002"/></svg></button>'
490+
}
481491
});
482492
// -->
483493
</script>
@@ -592,4 +602,3 @@ function mybbfancybox_print_peekers($peekers)
592602

593603
return $peekers;
594604
}
595-

inc/plugins/mybbfancybox/mybbfancybox.css

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,20 @@
2626

2727
/** FancyBox - minimize feature **/
2828
.minimized {
29-
height: 44px;
29+
height: 44px !important;
3030
}
3131

3232
.minimized .fancybox-stage,
3333
.minimized .fancybox-navigation {
3434
display: none;
3535
}
3636

37+
.minimized .fancybox-caption__body {
38+
margin-bottom: -13px;
39+
font-size: 13px;
40+
opacity: 0.95;
41+
}
42+
3743
.fancybox-button--minimise svg {
3844
padding: 2px;
3945
}
@@ -49,4 +55,4 @@
4955

5056
.minimized .fancybox-button--minimise svg:nth-child(2) {
5157
display: block;
52-
}
58+
}

jscripts/mybbfancybox.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ var MyBBFancyBox = (function($, m) {
2525
},
2626
options = {
2727
slideClass: '',
28+
closeExisting: true,
2829
loop: true,
2930
protect: false,
3031
keyboard: true,
@@ -35,13 +36,13 @@ var MyBBFancyBox = (function($, m) {
3536
hideOnClose: true,
3637
},
3738
buttons: [
38-
'minimize', // this is needed for the new feature - display only when setting in ACP is enabled
3939
'slideShow',
4040
'fullScreen',
4141
'thumbs',
4242
'share',
4343
'download',
4444
'zoom',
45+
'minimize',
4546
'close',
4647
],
4748
};
@@ -52,6 +53,20 @@ var MyBBFancyBox = (function($, m) {
5253
* @return void
5354
*/
5455
function init() {
56+
57+
if (options.buttons && options.buttons.indexOf("minimize") !== -1) {
58+
var yState = $('body').css('overflow-y');
59+
// Add click event for minimize button
60+
$(document).on('click', '[data-fancybox-minimize]', function() {
61+
var fb = $.fancybox.getInstance();
62+
63+
if (fb) {
64+
fb.$refs.container.toggleClass('minimized');
65+
$('body').css('overflow-y', (fb.$refs.container.hasClass('minimized')) ? yState : 'hidden');
66+
}
67+
});
68+
}
69+
5570
$('.post_body img').each(function() {
5671
var currentImage = $(this);
5772
var pid = currentImage.parents('.post_body.scaleimages').attr('id');
@@ -65,6 +80,7 @@ var MyBBFancyBox = (function($, m) {
6580
$.fancybox.defaults.i18n.en = lang;
6681

6782
// FancyBox default settings
83+
6884
$('[data-fancybox]').fancybox(options);
6985
}
7086

@@ -79,7 +95,7 @@ var MyBBFancyBox = (function($, m) {
7995
}
8096

8197
m.setup = setup;
82-
98+
8399
$(init);
84100
return m;
85101
})(jQuery, MyBBFancyBox || {});

mybbgrouplogo.png

3.52 KB
Loading

0 commit comments

Comments
 (0)