groups

Link to this snippet:


Download to Code Collector

language: JavaScript
licence: Other

JavaScript Defaults

options: send to code collectorview all jerry nummi's snippets
function iPhone() {
  return (navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i));
}

(function($) {
  $.fn.actAsMailTo = function(options) {
    var opts = $.extend({}, $.fn.actAsMailTo.defaults, options);
    return this.each(function() {
      var link    = $(this);
      var newText = link.text().replace(opts.meowMeow, '@').replace(opts.dot, '.');
      link.text(newText).attr('href', 'mailto:' + newText);
    });
  };

  $.fn.actAsMailTo.defaults = {
    // <space>[at]<space>
    // <space>[dot]<space>
    meowMeow: ' [at] ', dot: ' [dot] '
  };
})(jQuery);

(function($) {
  $.fn.actAsSlideshow = function(options) {
    var opts = $.extend({}, $.fn.actAsSlideshow.defaults, options);
    return this.each(function() {
      var container = $(this);
      container.find('img:gt(0)').hide();
      setInterval(function(){
        container.find(':first-child').fadeOut()
                 .next('img').fadeIn(350)
                 .end().appendTo(container);
      }, opts.speed);
    });
  };

  $.fn.actAsSlideshow.defaults = { speed: 3500 };
})(jQuery);

(function($) {
  $.fn.newWindow = function() {
    return this.each(function() {
      $(this).click(function() {
        var newWindow = window.open($(this).attr('href'), '_blank');
        if(newWindow) { if(newWindow.focus) { newWindow.focus(); return false; } }
        newWindow = null;
      });
    });
  };
})(jQuery);

$(function() {
  $('a[rel=email]').actAsMailTo();
  $('a[rel=external]').newWindow();
  $('#photo').actAsSlideshow();
});