2 * Buttons helper for fancyBox
3 * version: 1.0.5 (Mon, 15 Oct 2012)
4 * @requires fancyBox v2.0 or later
7 * $(".fancybox").fancybox({
17 //Shortcut for fancyBox object
23 skipSingle : false, // disables if gallery contains single image
24 position : 'top', // 'top' or 'bottom'
25 tpl : '<div id="fancybox-buttons"><ul><li><a class="btnPrev" title="Previous" href="javascript:;"></a></li><li><a class="btnPlay" title="Start slideshow" href="javascript:;"></a></li><li><a class="btnNext" title="Next" href="javascript:;"></a></li><li><a class="btnToggle" title="Toggle size" href="javascript:;"></a></li><li><a class="btnClose" title="Close" href="javascript:jQuery.fancybox.close();"></a></li></ul></div>'
31 beforeLoad: function (opts, obj) {
32 //Remove self if gallery do not have at least two items
34 if (opts.skipSingle && obj.group.length < 2) {
35 obj.helpers.buttons = false;
41 //Increase top margin to give space for buttons
42 obj.margin[ opts.position === 'bottom' ? 2 : 0 ] += 30;
45 onPlayStart: function () {
47 this.buttons.play.attr('title', 'Pause slideshow').addClass('btnPlayOn');
51 onPlayEnd: function () {
53 this.buttons.play.attr('title', 'Start slideshow').removeClass('btnPlayOn');
57 afterShow: function (opts, obj) {
58 var buttons = this.buttons;
61 this.list = $(opts.tpl).addClass(opts.position).appendTo('body');
64 prev : this.list.find('.btnPrev').click( F.prev ),
65 next : this.list.find('.btnNext').click( F.next ),
66 play : this.list.find('.btnPlay').click( F.play ),
67 toggle : this.list.find('.btnToggle').click( F.toggle )
72 if (obj.index > 0 || obj.loop) {
73 buttons.prev.removeClass('btnDisabled');
75 buttons.prev.addClass('btnDisabled');
79 if (obj.loop || obj.index < obj.group.length - 1) {
80 buttons.next.removeClass('btnDisabled');
81 buttons.play.removeClass('btnDisabled');
84 buttons.next.addClass('btnDisabled');
85 buttons.play.addClass('btnDisabled');
88 this.buttons = buttons;
90 this.onUpdate(opts, obj);
93 onUpdate: function (opts, obj) {
100 toggle = this.buttons.toggle.removeClass('btnDisabled btnToggleOn');
104 toggle.addClass('btnToggleOn');
106 } else if (!obj.canExpand) {
107 toggle.addClass('btnDisabled');
111 beforeClose: function () {