/* * jquery picplay plugin * @name jquery-piceyes-1.0.js * @author xiaoyan - frbao * @version 1.0 * @date jan 14, 2016 * @category jquery plugin * @github https://github.com/xiaoyan0552/jquery.piceyes */ (function($){ $.fn.piceyes = function(){ var $obj = this; var num,zg = $obj.length - 1; var win_w = $(window).width(); var win_h = $(window).height(); var eyehtml = '
' // +'' +'
' +'
' +'' // +'' // +'' +'
' +'
' // +'
'; $('body').append(eyehtml); $obj.click(function() { $(".picshade").css("height", win_h); var n = $(this).find("img").attr('src'); $(".pictures_eyes img").attr("src", n); num = $obj.index(this); popwin($('.pictures_eyes')); }); $(".pictures_eyes_close,.picshade,.pictures_eyes").click(function() { $(".picshade,.pictures_eyes,.pictures_eyes_close,.pictures_eyes_indicators").fadeout(); $('body').css({'overflow':'auto'}); }); $('.pictures_eyes img').click(function(e){ stoppropagation(e); }); $(".next").click(function(e){ if(num < zg){ num++; }else{ num = 0; } var xx = $obj.eq(num).find('img').attr("src"); $(".pictures_eyes img").attr("src", xx); stoppropagation(e); popwin($('.pictures_eyes')); }); $(".prev").click(function(e){ if(num > 0){ num--; }else{ num = zg; } var xx = $obj.eq(num).find('img').attr("src"); $(".pictures_eyes img").attr("src", xx); stoppropagation(e); popwin($('.pictures_eyes')); }); function popwin(obj){ $('body').css({'overflow':'visible'}); var pwidth = obj.width(); var pheight = obj.height(); obj.css({left:(win_w - pwidth)/2,top:(win_h - pheight)/2}).show(); $('.picshade,.pictures_eyes_close').fadein(); indicatorslist(); } function updateplace(obj){ var pwidth = obj.width(); var pheight = obj.height(); obj.css({left:(win_w - pwidth)/2,top:(win_h - pheight)/2}); } function indicatorslist(){ var indhtml = ''; $obj.each(function(){ var img = $(this).find('img').attr('src'); indhtml +=''; }); $('.pictures_eyes_indicators').html(indhtml).fadein(); $('.pictures_eyes_indicators a').eq(num).addclass('current').siblings().removeclass('current'); $('.pictures_eyes_indicators a').click(function(){ $(this).addclass('current').siblings().removeclass('current'); var xx = $(this).find('img').attr("src"); $(".pictures_eyes img").attr("src", xx); updateplace($('.pictures_eyes')); }); } function stoppropagation(e) { e = e || window.event; if(e.stoppropagation) { e.stoppropagation(); } else { e.cancelbubble = true; } } } })(jquery);