wrap.bind('mousewheel.fb', function(e, delta) {
					e.preventDefault();

					if (busy || delta === 0) {
						return;
					}

					if (delta > 0) {
						$.fancybox.prev();
					} else {
						$.fancybox.next();
					}
				});
		$(document).unbind('keydown.fb').bind('keydown.fb', function(e) {
			if (e.keyCode == 27 && currentOpts.enableEscapeButton) {
				e.preventDefault();
				$.fancybox.close();

			} else if (e.keyCode == 37) {
				e.preventDefault();
				$.fancybox.prev();

			} else if (e.keyCode == 39) {
				e.preventDefault();
				$.fancybox.next();
			}
		});
$.fancybox.resize = function() {
  if (overlay.is(':visible')) {
    overlay.css('height', $(document).height());
  }

  $.fancybox.center(true);
};
      $(document).bind('keydown.fb', function(e) {
        if (e.keyCode == 27 && currentOpts.enableEscapeButton) {
          e.preventDefault();
          $.fancybox.close();

        } else if ((e.keyCode == 37 || e.keyCode == 39) && currentOpts.enableKeyboardNav && e.target.tagName !== 'INPUT' && e.target.tagName !== 'TEXTAREA' && e.target.tagName !== 'SELECT') {
          e.preventDefault();
          $.fancybox[ e.keyCode == 37 ? 'prev' : 'next']();
        }
      });
      fancybox_init = function() {
          if ($("#fancybox-wrap").length) {
              return;
          }

          $.fancybox.update_base_elements();

          $('body').append(
              tmp			= $('<div id="fancybox-tmp" class="fncybox"></div>'),
              loading		= $('<div id="fancybox-loading" class="fncybox"><div></div></div>'),
              overlay		= $('<div id="fancybox-overlay" class="fncybox"></div>'),
              wrap		= $('<div id="fancybox-wrap" class="fncybox"></div>')
          );

		if (!$.support.opacity) {
			wrap.addClass('fancybox-ie');
			loading.addClass('fancybox-ie');
		}

		outer = $('<div id="fancybox-outer"></div>')
			.append('<div class="fancy-bg" id="fancy-bg-n"></div><div class="fancy-bg" id="fancy-bg-ne"></div><div class="fancy-bg" id="fancy-bg-e"></div><div class="fancy-bg" id="fancy-bg-se"></div><div class="fancy-bg" id="fancy-bg-s"></div><div class="fancy-bg" id="fancy-bg-sw"></div><div class="fancy-bg" id="fancy-bg-w"></div><div class="fancy-bg" id="fancy-bg-nw"></div>')
			.appendTo( wrap );

		outer.append(
			inner		= $('<div id="fancybox-inner" tabindex="-1"></div>'),
			close		= $('<a id="fancybox-close" href="#">Close</a>'),

			nav_left	= $('<a href="javascript:;" id="fancybox-left"><span class="fancy-ico" id="fancybox-left-ico"></span></a>'),
			nav_right	= $('<a href="javascript:;" id="fancybox-right"><span class="fancy-ico" id="fancybox-right-ico"></span></a>')
		);

		close.click($.fancybox.close);
		loading.click($.fancybox.cancel);

		nav_left.click(function(e) {
			e.preventDefault();
			$.fancybox.prev();
		});

		nav_right.click(function(e) {
			e.preventDefault();
			$.fancybox.next();
		});
          
          if(fancybox_test_props_all( 'boxShadow' )) {
              wrap.addClass('fancybox-box-shadow');
          }
          
		if (isIE6) {
			overlay.get(0).style.setExpression('height',	"document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px'");
			loading.get(0).style.setExpression('top',		"(-20 + (document.documentElement.clientHeight ? document.documentElement.clientHeight/2 : document.body.clientHeight/2 ) + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop )) + 'px'");

			outer.prepend('<iframe id="fancybox-hide-sel-frame" src="javascript:\'\';" scrolling="no" frameborder="0" ></iframe>');
		}
	};
  _finish = function () {
    if (!$.support.opacity) {
      content.get(0).style.removeAttribute('filter');
      wrap.get(0).style.removeAttribute('filter');
    }

    if (selectedOpts.autoDimensions) {
      content.css('height', 'auto');
    }

    wrap.css('height', 'auto');

    if (titleStr && titleStr.length) {
      title.show();
    }

    if (currentOpts.showCloseButton) {
      close.show();
    }

    _set_navigation();

    if (currentOpts.hideOnContentClick)  {
      content.bind('click', $.fancybox.close);
    }

    if (currentOpts.hideOnOverlayClick)  {
      overlay.bind('click', $.fancybox.close);
    }

    $(window).bind("resize.fb", $.fancybox.resize);

    if (currentOpts.centerOnScroll) {
      $(window).bind("scroll.fb", $.fancybox.center);
    }

    if (currentOpts.type == 'iframe') {
      $('<iframe id="fancybox-frame" name="fancybox-frame' + new Date().getTime() + '" frameborder="0" hspace="0" ' + ($.browser.msie ? 'allowtransparency="true""' : '') + ' scrolling="' + selectedOpts.scrolling + '" src="' + currentOpts.href + '"></iframe>').appendTo(content);
    }

    wrap.show();

    busy = false;

    $.fancybox.center();

    currentOpts.onComplete(currentArray, currentIndex, currentOpts);

    _preload_images();
  };
$.fancybox.resize = function() {
	var c, h;
	
	if (busy || wrap.is(':hidden')) {
		return;
	}

	busy = true;

	c = inner.wrapInner("<div style='overflow:auto'></div>").children();
	h = c.height();

	wrap.css({height:	h + (currentOpts.padding * 2) + titleh});
	inner.css({height:	h});

	c.replaceWith(c.children());

	$.fancybox.center();
};
Example #8
0
        $('#btnGistShare').click(function() {
          $.fancybox.close(true);

          var users = $('#sharedUsers').val();
          $('#sharedUsers').val('');

          service
            .setShared(self.model.get('id'), users)
            .done(function(data) {

              var splitStr = users.split(',');
              for (var i = 0; i < splitStr.length; i++) {
                // send a notification
                var text = '';
                if (self.model.attributes.description != undefined)
                  text = '(' + self.model.attributes.description + ')';

                var msg = global.user.name + ' just shared gist' + text;
                msg = msg + '</br>';
                global.socket.emit('sendalarmByLogin', splitStr[i], msg);
              }

              $('.starred-success').css('left', '140px');
              $('.starred-success').text('Shared Successfully').removeClass(
                'starred-success-hide starred-success-show').addClass(
                'starred-success-show');
              setTimeout(function() {
                $('.starred-success').removeClass(
                  'starred-success-hide starred-success-show').addClass(
                  'starred-success-hide');
                setTimeout(function() {
                  $('.starred-success').css('left', '-40px');
                }, 1000);
              }, 2000);


            });
        });
$.fancybox.prev = function() {
  return $.fancybox.pos( currentIndex - 1);
};
$.fancybox.next = function() {
  return $.fancybox.pos( currentIndex + 1);
};
  _start = function() {
    var obj = selectedArray[ selectedIndex ],
      href, 
      type, 
      title,
      str,
      emb,
      ret;

    _abort();

    selectedOpts = $.extend({}, $.fn.fancybox.defaults, (typeof $(obj).data('fancybox') == 'undefined' ? selectedOpts : $(obj).data('fancybox')));

    ret = selectedOpts.onStart(selectedArray, selectedIndex, selectedOpts);

    if (ret === false) {
      busy = false;
      return;
    } else if (typeof ret == 'object') {
      selectedOpts = $.extend(selectedOpts, ret);
    }

    title = selectedOpts.title || (obj.nodeName ? $(obj).attr('title') : obj.title) || '';

    if (obj.nodeName && !selectedOpts.orig) {
      selectedOpts.orig = $(obj).children("img:first").length ? $(obj).children("img:first") : $(obj);
    }

    if (title === '' && selectedOpts.orig && selectedOpts.titleFromAlt) {
      title = selectedOpts.orig.attr('alt');
    }

    href = selectedOpts.href || (obj.nodeName ? $(obj).attr('href') : obj.href) || null;

    if ((/^(?:javascript)/i).test(href) || href == '#') {
      href = null;
    }

    if (selectedOpts.type) {
      type = selectedOpts.type;

      if (!href) {
        href = selectedOpts.content;
      }

    } else if (selectedOpts.content) {
      type = 'html';

    } else if (href) {
      if (href.match(imgRegExp)) {
        type = 'image';

      } else if (href.match(swfRegExp)) {
        type = 'swf';

      } else if ($(obj).hasClass("iframe")) {
        type = 'iframe';

      } else if (href.indexOf("#") === 0) {
        type = 'inline';

      } else {
        type = 'ajax';
      }
    }

    if (!type) {
      _error();
      return;
    }

    if (type == 'inline') {
      obj  = href.substr(href.indexOf("#"));
      type = $(obj).length > 0 ? 'inline' : 'ajax';
    }

    selectedOpts.type = type;
    selectedOpts.href = href;
    selectedOpts.title = title;

    if (selectedOpts.autoDimensions) {
      if (selectedOpts.type == 'html' || selectedOpts.type == 'inline' || selectedOpts.type == 'ajax') {
        selectedOpts.width = 'auto';
        selectedOpts.height = 'auto';
      } else {
        selectedOpts.autoDimensions = false;  
      }
    }

    if (selectedOpts.modal) {
      selectedOpts.overlayShow = true;
      selectedOpts.hideOnOverlayClick = false;
      selectedOpts.hideOnContentClick = false;
      selectedOpts.enableEscapeButton = false;
      selectedOpts.showCloseButton = false;
    }

    selectedOpts.padding = parseInt(selectedOpts.padding, 10);
    selectedOpts.margin = parseInt(selectedOpts.margin, 10);

    tmp.css('padding', (selectedOpts.padding + selectedOpts.margin));

    $('.fancybox-inline-tmp').unbind('fancybox-cancel').bind('fancybox-change', function() {
      $(this).replaceWith(content.children());        
    });

    switch (type) {
      case 'html' :
        tmp.html( selectedOpts.content );
        _process_inline();
      break;

      case 'inline' :
        if ( $(obj).parent().is('#fancybox-content') === true) {
          busy = false;
          return;
        }

        $('<div class="fancybox-inline-tmp" />')
          .hide()
          .insertBefore( $(obj) )
          .bind('fancybox-cleanup', function() {
            $(this).replaceWith(content.children());
          }).bind('fancybox-cancel', function() {
            $(this).replaceWith(tmp.children());
          });

        $(obj).appendTo(tmp);

        _process_inline();
      break;

      case 'image':
        busy = false;

        $.fancybox.showActivity();

        imgPreloader = new Image();

        imgPreloader.onerror = function() {
          _error();
        };

        imgPreloader.onload = function() {
          busy = true;

          imgPreloader.onerror = imgPreloader.onload = null;

          _process_image();
        };

        imgPreloader.src = href;
      break;

      case 'swf':
        selectedOpts.scrolling = 'no';

        str = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + selectedOpts.width + '" height="' + selectedOpts.height + '"><param name="movie" value="' + href + '"></param>';
        emb = '';

        $.each(selectedOpts.swf, function(name, val) {
          str += '<param name="' + name + '" value="' + val + '"></param>';
          emb += ' ' + name + '="' + val + '"';
        });

        str += '<embed src="' + href + '" type="application/x-shockwave-flash" width="' + selectedOpts.width + '" height="' + selectedOpts.height + '"' + emb + '></embed></object>';

        tmp.html(str);

        _process_inline();
      break;

      case 'ajax':
        busy = false;

        $.fancybox.showActivity();

        selectedOpts.ajax.win = selectedOpts.ajax.success;

        ajaxLoader = $.ajax($.extend({}, selectedOpts.ajax, {
          url  : href,
          data : selectedOpts.ajax.data || {},
          error : function(XMLHttpRequest, textStatus, errorThrown) {
            if ( XMLHttpRequest.status > 0 ) {
              _error();
            }
          },
          success : function(data, textStatus, XMLHttpRequest) {
            var o = typeof XMLHttpRequest == 'object' ? XMLHttpRequest : ajaxLoader;
            if (o.status == 200) {
              if ( typeof selectedOpts.ajax.win == 'function' ) {
                ret = selectedOpts.ajax.win(href, data, textStatus, XMLHttpRequest);

                if (ret === false) {
                  loading.hide();
                  return;
                } else if (typeof ret == 'string' || typeof ret == 'object') {
                  data = ret;
                }
              }

              tmp.html( data );
              _process_inline();
            }
          }
        }));

      break;

      case 'iframe':
        _show();
      break;
    }
  };
$(document).ready(function() {
  $.fancybox.init();
});
 nav_left.click(function(e) {
   e.preventDefault();
   $.fancybox.prev();
 });
	fancybox_start = function() {
		fancybox_abort();

		var obj	= selectedArray[ selectedIndex ],
			href, 
			type, 
			title,
			str,
			emb,
			selector,
			data;

		selectedOpts = $.extend({}, $.fn.fancybox.defaults, (typeof $(obj).data('fancybox') == 'undefined' ? selectedOpts : $(obj).data('fancybox')));
		title = obj.title || $(obj).title || selectedOpts.title || '';
		
		if (obj.nodeName && !selectedOpts.orig) {
			selectedOpts.orig = $(obj).children("img:first").length ? $(obj).children("img:first") : $(obj);
		}

		if (title === '' && selectedOpts.orig) {
			title = selectedOpts.orig.attr('alt');
		}

		if (obj.nodeName && (/^(?:javascript|#)/i).test(obj.href)) {
			href = selectedOpts.href || null;
		} else {
			href = selectedOpts.href || obj.href || null;
		}

		if (selectedOpts.type) {
			type = selectedOpts.type;

			if (!href) {
				href = selectedOpts.content;
			}
			
		} else if (selectedOpts.content) {
			type	= 'html';

		} else if (href) {
			if (href.match(imgRegExp)) {
				type = 'image';

			} else if (href.match(swfRegExp)) {
				type = 'swf';

			} else if ($(obj).hasClass("iframe")) {
				type = 'iframe';

			} else if (href.match(/#/)) {
				obj = href.substr(href.indexOf("#"));

				type = $(obj).length > 0 ? 'inline' : 'ajax';
			} else {
				type = 'ajax';
			}
		} else {
			type = 'inline';
		}

		selectedOpts.type	= type;
		selectedOpts.href	= href;
		selectedOpts.title	= title;

		if (selectedOpts.autoDimensions && selectedOpts.type !== 'iframe' && selectedOpts.type !== 'swf') {
			selectedOpts.width		= 'auto';
			selectedOpts.height		= 'auto';
		}

		if (selectedOpts.modal) {
			selectedOpts.overlayShow		= true;
			selectedOpts.hideOnOverlayClick	= false;
			selectedOpts.hideOnContentClick	= false;
			selectedOpts.enableEscapeButton	= false;
			selectedOpts.showCloseButton	= false;
		}

		if ($.isFunction(selectedOpts.onStart)) {
			if (selectedOpts.onStart(selectedArray, selectedIndex, selectedOpts) === false) {
				busy = false;
				return;
			}
		}

		tmp.css('padding', (shadow + selectedOpts.padding + selectedOpts.margin));

		$('.fancybox-inline-tmp').unbind('fancybox-cancel').bind('fancybox-change', function() {
			$(this).replaceWith(inner.children());
		});

		switch (type) {
			case 'html' :
				tmp.html( selectedOpts.content );
				fancybox_process_inline();
			break;

			case 'inline' :
				$('<div class="fancybox-inline-tmp" />').hide().insertBefore( $(obj) ).bind('fancybox-cleanup', function() {
					$(this).replaceWith(inner.children());
				}).bind('fancybox-cancel', function() {
					$(this).replaceWith(tmp.children());
				});

				$(obj).appendTo(tmp);

				fancybox_process_inline();
			break;

			case 'image':
				busy = false;

				$.fancybox.showActivity();

				imgPreloader = new Image();

				imgPreloader.onerror = function() {
					fancybox_error();
				};

				imgPreloader.onload = function() {
					imgPreloader.onerror = null;
					imgPreloader.onload = null;
					fancybox_process_image();
				};

				imgPreloader.src = href;
	
			break;

			case 'swf':
				str = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + selectedOpts.width + '" height="' + selectedOpts.height + '"><param name="movie" value="' + href + '"></param>';
				emb = '';
				
				$.each(selectedOpts.swf, function(name, val) {
					str += '<param name="' + name + '" value="' + val + '"></param>';
					emb += ' ' + name + '="' + val + '"';
				});

				str += '<embed src="' + href + '" type="application/x-shockwave-flash" width="' + selectedOpts.width + '" height="' + selectedOpts.height + '"' + emb + '></embed></object>';

				tmp.html(str);

				fancybox_process_inline();
			break;

			case 'ajax':
				selector	= href.split('#', 2);
				data		= selectedOpts.ajax.data || {};

				if (selector.length > 1) {
					href = selector[0];

					if (typeof data == "string") {
						data += '&selector=' + selector[1];
					} else {
						data.selector = selector[1];
					}
				}

				busy = false;
				$.fancybox.showActivity();

				ajaxLoader = $.ajax($.extend(selectedOpts.ajax, {
					url		: href,
					data	: data,
					error	: fancybox_error,
					success : function(data, textStatus, XMLHttpRequest) {
						if (ajaxLoader.status == 200) {
							tmp.html( data );
							fancybox_process_inline();
						}
					}
				}));

			break;

			case 'iframe' :
				$('<iframe id="fancybox-frame" name="fancybox-frame' + new Date().getTime() + '" frameborder="0" hspace="0" scrolling="' + selectedOpts.scrolling + '" src="' + selectedOpts.href + '"></iframe>').appendTo(tmp);
				fancybox_show();
			break;
		}
	},
Example #15
0
 $( ".closeModal" ).click(function(){
   $.fancybox.close();
 } );
Example #16
0
 scope.$on( '$destroy', function () {
   $.fancybox.close();
 } );
 nav_right.click(function(e) {
   e.preventDefault();
   $.fancybox.next();
 });