码迷,mamicode.com
首页 > 其他好文 > 详细

命名空间

时间:2014-09-17 20:24:22      阅读:207      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   color   io   ar   for   div   sp   

var UNISA = UNISA || {};

UNISA.slideshow = (function (doc, $, undefined) {

  var cycleHomepage = function () {
    var paused = false;
    $(‘#hero-banner‘).each(function () {
      var $this = $(this),
            opts = {
              pager: ‘#banner-nav‘,
              fx: ‘fade‘,
              speed: 1500,
              timeout: 5000,
              //pauseOnPagerHover: true,
              pause: 1
            };

      //if we have a media centre, than we need to add some buttons.
      if ($this.is(‘.media_centre‘)) {
        opts.prev = $this.find(‘.prev‘);
        opts.next = $this.find(‘.next‘);
        opts.fx = ‘scrollHorz‘;
        // For fade effect change
        opts.speed = 800,
            opts.timeout = 6000,
            opts.pause = 1
      }

      $this.find(‘#slider‘).cycle(opts);
      
      //ie focus fix, opacity on hover/focus
      $(‘#banner-nav a, #pausePlay‘).on("mouseenter focus", (function () {
        $(this).toggleClass(‘ie7focus‘, true);
        $(‘#banner-nav a, #pausePlay‘).toggleClass(‘hiviz‘, true);
      })).on("blur mouseleave", (function () {
        $(this).toggleClass(‘ie7focus‘, false);
        $(‘#banner-nav a, #pausePlay‘).toggleClass(‘hiviz‘, false);
      }));

      // Pause/play buttons
      $(‘#pausePlay‘).toggle(function () {
        $(‘#slider‘).cycle(‘pause‘);
        $(‘#pausePlay span‘).html(‘Play slideshow‘);
        $(this).toggleClass(‘paused‘, true).attr(‘title‘, ‘Slideshow paused. Click to play‘);
        paused = true;
      },
              function () {
                $(‘#slider‘).cycle(‘resume‘, true);
                $(‘#pausePlay span‘).html(‘Pause slideshow‘);
                paused = false;
                $(this).toggleClass(‘paused‘, false).attr(‘title‘, ‘Click to pause slideshow‘);
              }
              )
    });
    // If user tabs to slide, pause slideshow
            $(‘#slider li a‘).focus(function () {
              $(‘#pausePlay span‘).html(‘Play slideshow‘);
      $(‘#slider‘).cycle(‘pause‘);
    }).blur(function () {
      if (!paused) {
        $(‘#slider‘).cycle(‘resume‘, true);
        $(‘#pausePlay span‘).html(‘Pause slideshow‘);
      }
    });

  },

  cycleInline = function () {
    var paused = false;
    $(‘.inline-banner > ul‘).cycle({
      pager: ‘#banner-nav .paging‘,
      fx: ‘scrollHorz‘,
      speed: 800,
      timeout: 6000,
      pause: 1,
      next: ‘#banner-nav .next-slide‘,
      prev: ‘#banner-nav .prev-slide‘
    });

    // Pause/play buttons
    $(‘.inline-banner #pausePlay‘).toggle(function () {
      $(‘.inline-banner #pausePlay span‘).html(‘Play slideshow‘);
      $(this).toggleClass(‘paused‘, true).attr(‘title‘, ‘Slideshow paused. Click to play‘);
      $(‘.inline-banner > ul‘).cycle(‘pause‘);
      paused = true;
    },
              function () {
                $(‘.inline-banner #pausePlay span‘).html(‘Pause slideshow‘);
                $(‘.inline-banner > ul‘).cycle(‘resume‘, true);
                $(this).toggleClass(‘paused‘, false).attr(‘title‘, ‘Click to pause slideshow‘);
                paused = false;
              }
              );

    // Reset opacity on focus, ie focus fix
    $(‘.inline-banner #banner-nav a‘).focus(function () {
      $(this).toggleClass("ie7focus", true);
      $(‘.inline-banner #banner-nav a‘).toggleClass("hiviz", true);
    }).blur(function () {
      $(this).toggleClass("ie7focus", false);
      $(‘.inline-banner #banner-nav a‘).toggleClass("hiviz", false);
    });

    // If user tabs to slide, pause slideshow
    $(‘.inline-banner > ul a‘).focus(function () {
      $(‘.inline-banner > ul‘).cycle(‘pause‘);
      $(‘.inline-banner #pausePlay span‘).html(‘Play slideshow‘);
    }).blur(function () {
      if (!paused) {
        $(‘.inline-banner > ul‘).cycle(‘resume‘, true);
        $(‘.inline-banner #pausePlay span‘).html(‘Pause slideshow‘);
      }
    });
  }

  return {

    init: function () {
      cycleHomepage();
      cycleInline();
    }

  };

})(document, jQuery);

var jQuery_1_7_1 = jQuery.noConflict();

jQuery_1_7_1(document).ready(function () {
     UNISA.slideshow.init();
}); 

 

命名空间

标签:des   style   blog   color   io   ar   for   div   sp   

原文地址:http://www.cnblogs.com/oceanden/p/3977872.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!