; !function (factory) { // amdģ�黯���� if (typeof define === "function" && define.amd) { define(["jquery"], factory); } else { factory(jquery); } }(function ($) { 'use strict'; var lzpreview = { version: '1.3.7', author: 'lzx', date: '2017-11-23' } $.extend({ islzarray: function (v) { return object.prototype.tostring.call(v) === '[object array]'; }, islzobject: function (v) { return object.prototype.tostring.call(v) === '[object object]'; }, islzstring: function (v) { return object.prototype.tostring.call(v) === '[object string]'; }, islzbool: function (v) { return object.prototype.tostring.call(v) === '[object boolean]'; }, islzfunction: function (v) { return object.prototype.tostring.call(v) === '[object function]'; }, ispc: function () { var useragentinfo = navigator.useragent, agents = new array("android", "iphone", "symbianos", "windows phone", "ipad", "ipod"), flag = true; for (var v = 0; v < agents.length; v++) { if (useragentinfo.indexof(agents[v]) > 0) { flag = false; break; } } return flag; } }); var previewevent = function (val, init) { this.$ele = $(val); this.param = this.$ele.data('lzpreview-param'); this.init = init; } previewevent.prototype = { constructor: previewevent, setevent: function (plugin) { var event = this; this.plugin = plugin; $.each(this.param.event, function (index, val) { event[val] && event[val](); }) }, // reseize resize: function () { var me = this; var $this = this.$ele; var self = $this[0].previewmethods; var $dom = $("#lz-atlas-preview"); $(window).resize(function () { self._calcsize(); me.plugin.slidertoolb.refresh(); }); }, // �رմ�ͼԤ�� close: function () { var $dom = $("#lz-atlas-preview"); var param = this.$ele.data('lzpreview-param'); $dom.find('.lz-colsebut').on('click', function () { param.openzoom = false; $dom.fadeout(150, function () { $dom.remove(); $('.lz-preview-meta').remove(); }); }); }, // �զ����ͷ corrow: function () { var $this = this.$ele; var self = $this[0].previewmethods; var $dom = $("#lz-atlas-preview"); var $corrows = $dom.find('.lz-thumbnail-box .lz-but'); var $corrow = $dom.find('.lz-atlas-box .lz-but'); var plugin = this.plugin; var param = this.$ele.data('lzpreview-param'); // ��ͼ�զ�����ƽ�ͷ $corrow.off('click').on('click', function () { var $this = $(this); var flag; if ($this.hasclass('lz-nextbut')) { plugin.slidertoolb.prev(); } if ($this.hasclass('lz-previousbut')) { plugin.slidertoolb.next(); } var initindex = self._currentpointer(); self._clslider(initindex); var index = initindex - 1; param.openzoom = false; self._zoombtn($(this), index); maxlen <= 10 && $corrows.eq(1).addclass('disabled'); maxlen == 1 && $corrow.eq(1).addclass('disabled'); }); // ����ͼ�զ�����ƽ�ͷ $corrows.off('click').on('click', function () { var $this = $(this); if ($this.hasclass('lz-nextbut')) { plugin.slidertools.prev(); } if ($this.hasclass('lz-previousbut')) { plugin.slidertools.next(); } maxlen <= 10 && $corrows.eq(1).addclass('disabled'); maxlen == 1 && $corrow.eq(1).addclass('disabled'); }); var maxlen = plugin.slidertoolb.$ele.find('li').length; // ͷβ��ͷ���ɵ��ч�� plugin.slidertoolb.on('switch', function (data) { if (plugin.slidertoolb.index() == 1) { $corrow.eq(0).addclass('disabled'); } else { $corrow.eq(0).removeclass('disabled'); } if (plugin.slidertoolb.index() == maxlen) { $corrow.eq(1).addclass('disabled'); } else { $corrow.eq(1).removeclass('disabled'); } }); plugin.slidertools.on('switch', function () { if (plugin.slidertools.index() == 1) { $corrows.eq(0).addclass('disabled'); } else { $corrows.eq(0).removeclass('disabled'); } !plugin.slidertools.islast() && $corrows.eq(1).removeclass('disabled'); }); plugin.slidertools.on('last', function () { $corrows.eq(1).addclass('disabled'); }); }, pointer: function () { var $this = this.$ele; var self = $this[0].previewmethods; var $dom = $("#lz-atlas-preview"); var plugin = this.plugin; var param = this.$ele.data('lzpreview-param'); plugin.slidertools.$ele.find('li').on('click', function () { param.openzoom = false; self._currentchange($(this)); }); }, // ����ͼƭ zoom: function () { var $this = this.$ele; var $dom = $("#lz-atlas-preview"); var self = $this[0].previewmethods; var plugin = this.plugin; var param = this.$ele.data('lzpreview-param'); $dom.find('.lz-see-change a').on('click', function () { param.openzoom = true; var index = plugin.slidertoolb.index() - 1; self._zoombtn($(this), index); }); }, // �������� wheel: function () { var $this = this.$ele; var flag = false; var param = this.$ele.data('lzpreview-param'); var $imgbox = $dom.find('.lz-atlas-box'); var $img = $dom.find('.lz-atlas-box .lz-inner-img a'); var index = -1; var self = $this[0].previewmethods; var plugin = this.plugin; $img.on('mouseenter', function () { index = $(this).closest('li').index(); flag = true; }).on('mouseleave', function () { flag = false; }); $imgbox.on('mousewheel.lzpreview dommousescroll.lzpreview', function (e) { e = e || window.event; if (flag && param.openzoom) { var $imgsizeadd = $dom.find('.lz-see-change-lg'); var $imgsizeminus = $dom.find('.lz-see-change-sm'); if (e.originalevent.wheeldelta) { e.originalevent.wheeldelta < 0 ? self._zoombtn($imgsizeadd, index) : self._zoombtn($imgsizeminus, index); } else if (e.originalevent.detail) { e.originalevent.detail > 0 ? self._zoombtn($imgsizeadd, index) : self._zoombtn($imgsizeminus, index); } } else if (flag && !param.openzoom) { var initindex; if (e.originalevent.wheeldelta) { if (e.originalevent.wheeldelta > 0) { plugin.slidertoolb.prev(); initindex = self._currentpointer(); self._clslider(initindex); } else { plugin.slidertoolb.next(); initindex = self._currentpointer(); self._clslider(initindex) }; } else if (e.originalevent.detail) { if (e.originalevent.detail < 0) { plugin.slidertoolb.prev(); initindex = self._currentpointer(); self._clslider(initindex); } else { plugin.slidertoolb.next(); initindex = self._currentpointer(); self._clslider(initindex) } } } return false }); }, // �ƶ�ͼƭ move: function () { var $this = this.$ele; var $dom = $("#lz-atlas-preview"); var $img = $dom.find('.lz-atlas-box img'); var param = this.$ele.data('lzpreview-param'); var self = $this[0].previewmethods; var plugin = this.plugin; $img.on('mousedown', function (e) { if (param.moveflag) { param.canmove = true; self._beginsite(e, $(this)); } else { param.canmove = false; } }).on('mousemove', function (e) { if (param.canmove) { var indexs = plugin.slidertoolb.index() - 1; var $currentimg = $img.eq(indexs); self._movesite(e); self._endsite(e); $currentimg.css({ left: self.ende[0] + self.imgleft, top: self.ende[1] + self.imgtop }); } }); $img.closest('a').on('click', function () { if (param.moveflag) { return false; } }); $('body').on('mouseup', function () { param.canmove = false; }); } } // ���� var previewplugin = function (val, init) { this.$ele = $(val); this.param = this.$ele.data('lzpreview-param'); this.init = init; } previewplugin.prototype = { constructor: previewplugin, _slider: function () { var $dom = $("#lz-atlas-preview"); this.slidertoolb = $dom.find('.lz-atlas-box .lz-tempwrap').lzslider({ cycle: false,//ѭ������ auto: false,//�զ����� arrowstyle: false,//ĭ�ϼ�ͷ��ʽ event: ['touch'],//ĭ���¼� speed: 0, num: 1 }); this.slidertools = $dom.find('.lz-thumbnail-box .lz-tempwrap').lzslider({ cycle: false,//ѭ������ auto: false,//�զ����� arrowstyle: false,//ĭ�ϼ�ͷ��ʽ event: ['touch'],//ĭ���¼� speed: 200, num: 1 }); } } // ������ var previewmethods = function (val) { this.$ele = $(val); this.param = this.$ele.data('lzpreview-param'); this.flag = true; } previewmethods.prototype = { constructor: previewmethods, // ����ͼƭ���� _setimglink: function () { var $dom = self.$dom = $('#lz-atlas-preview'); var $bigimg = $dom.find('.lz-atlas-box .lz-inner-img-box li'); var me = this; $bigimg.each(function (index, el) { $(el).children('a').attr({ 'href': me.param.imglink[index], 'target': me.param.imgtarget[index] }); }); }, // ������ʼ����ͼԤ�� _calcsize: function () { var $dom = self.$dom = $('#lz-atlas-preview'); var $bigimg = $dom.find('.lz-atlas-box .lz-inner-img-box li'); var me = this; $dom.show(); var windowwidth = $(window).width(); var itemheight = $bigimg.parent().height(); $bigimg.css({ width: windowwidth, height: itemheight + 'px' }); $dom.find('.lz-atlas-box .lz-but').css({ height: itemheight, lineheight: itemheight + 'px', top: '34px' }); !me.flag && $dom.hide(); me.flag = true; $dom.find('.lz-img-bd').css('visibility', 'visible'); }, _clicklist: function ($this, plugin) { var $dom = self.$dom = $('#lz-atlas-preview'), indexs = 0, _me = this, $corrows = $dom.find('.lz-thumbnail-box .lz-but'), $corrow = $dom.find('.lz-atlas-box .lz-but'), pagenum = _me.$ele.find('.xn-pager .w-page-cm.active').attr('jp-data'); if (!pagenum || pagenum === undefined) { $.islzfunction(_me.param.pagenum) && _me.param.pagenum() } //$this.index()�ڷ�ҳ�� ul�»�����һ��div ���ʸ�����ȡ�����ķ�ʽ ��ϊprevall indexs = _me.param.clickselect == '' ? $this.prevall('li').length : $this.closest(_me.param.itemselect).index(); (isnan(pagenum) || !pagenum) && (pagenum = 1); var listindex = _me.param.pagesize * (pagenum - 1) + indexs + 1; $dom = $("#lz-atlas-preview"); var maxlen = plugin.slidertoolb.$ele.find('li').length; this.plugin = plugin; plugin.slidertoolb.index(listindex); var currentindex = this._currentpointer(); this._clslider(currentindex); $dom.fadein(150); this._zoombtn($(this), indexs); if (plugin.slidertoolb.index() == 1) { $corrow.eq(0).addclass('disabled'); } if (plugin.slidertools.index() == 1) { $corrows.eq(0).addclass('disabled'); } plugin.slidertoolb.islast() && $corrow.eq(1).addclass('disabled'); plugin.slidertools.islast() && $corrows.eq(1).addclass('disabled'); maxlen <= 10 && $corrows.eq(1).addclass('disabled'); maxlen == 1 && $corrow.eq(1).addclass('disabled'); }, // �л����� _currentpointer: function () { var initindex = this.plugin.slidertoolb.index(); this.plugin.slidertools.$ele.find('li').removeclass('lz-action').eq(initindex - 1).addclass('lz-action'); return initindex }, _currentchange: function ($this) { var indexs = $this.index(); this.plugin.slidertools.$ele.find('li').removeclass('lz-action').eq(indexs).addclass('lz-action'); this.plugin.slidertoolb.index(indexs + 1); this._zoombtn($(this), indexs); }, // ����ͼ������� _clslider: function (initindex) { var indexs = this.plugin.slidertools.index(); if (initindex <= indexs + 2) { this.plugin.slidertools.index(initindex - 3);//ǰ���� } if (initindex >= indexs + 7) { this.plugin.slidertools.index(initindex - 6);//������ } }, _beginsite: function (event, $currentimg) { var me = this; var event = window.event || event; event.preventdefault ? event.preventdefault() : event.returnvalue = false; var scrollx = $(window).scrollleft(), scrolly = $(window).scrolltop(); var x = event.pagex || event.clientx + scrollx, y = event.pagey || event.clienty + scrolly; me.begine = [x, y]; me.imgtop = $currentimg.position().top; me.imgleft = $currentimg.position().left; }, // ��ȡ�ƶ�ʱ��λ�� _movesite: function (event) { var event = window.event || event; event.preventdefault ? event.preventdefault() : event.returnvalue = false; var scrollx = $(window).scrollleft(), scrolly = $(window).scrolltop(); var x = event.pagex || event.clientx + scrollx, y = event.pagey || event.clienty + scrolly; this.movee = [x, y]; }, // ��ȡ�ƶ����λ��ֵ _endsite: function () { var me = this; me.ende = [me.movee[0] - me.begine[0], me.movee[1] - me.begine[1]]; }, // ����ŵ���с��ť _zoombtn: function ($this, index) { var param = this.$ele.data('lzpreview-param'); var $dom = $("#lz-atlas-preview"); var $numdom = $dom.find('.lz-see-change-txt'); var $img = $dom.find('.lz-atlas-box img'); var num = +$numdom.text().replace('%', ''); var max = 500,//���ŵ���� min = 5;//��с��с���� var mleft = 0, mtop = 0, imgwid = 0, imghei = 0; var cssobj = { position: 'absolute', maxwidth: 'none', maxheight: 'none', left: '50%', top: '50%', zindex: 300 } var resetcssobj = { position: '', width: '', height: '', maxwidth: '', maxheight: '', left: '', top: '', zindex: '', marginleft: '', margintop: '' } var $currentimg = $img.eq(index); $this.hasclass('lz-see-change-sm') ? num -= 5 : $this.hasclass('lz-see-change-lg') ? num += 5 : num = 100; !param.getimgflag && (this.initwidth = $currentimg.width()); if (num >= min && num <= max) { $numdom.text(num + '%'); if (num == 100) { param.getimgflag = false; param.moveflag = false; $img.closest('a').css('cursor', 'pointer'); $currentimg.css(resetcssobj); } else { imgwid = ~~(this.initwidth * (num / 100)); imghei = ~~$currentimg.height(); $currentimg.css('width', imgwid); $currentimg.css(cssobj); mleft = -imgwid / 2; mtop = -imghei / 2; $currentimg.css({ marginleft: mleft, margintop: mtop }); param.getimgflag = true; if (num > 100) { param.moveflag = true; $img.closest('a').css('cursor', '') } else { param.moveflag = false; $img.closest('a').css('cursor', 'pointer') } } } }, // ���с�ڿɹ������ʱ���� _centerthumbnail: function () { var $thumbnail = $('#lz-atlas-preview .lz-thumbnail-box .lz-tempwrap .lz-inner-img-box'); var thumbnailwidth = $thumbnail.width(); if (thumbnailwidth < 670) { $thumbnail.parent().css('width', thumbnailwidth + 'px'); } }, // ��ʾ�����ؼ�ͷ _showswitch: function () { var param = this.param; if (!param.arrow) { $('#lz-atlas-preview').find('.lz-atlas-box .lz-img-but').hide(); $('#lz-atlas-preview').find('.lz-atlas-box .lz-img-bd .lz-tempwrap ul:first-child li a').css('maxwidth', '90%') } else { $('#lz-atlas-preview').find('.lz-atlas-box .lz-img-but').show(); $('#lz-atlas-preview').find('.lz-atlas-box .lz-img-bd .lz-tempwrap ul:first-child li a').css('maxwidth', '') } }, // ��ʾ����������ͼ _showthumbnail: function () { var param = this.param; if (!param.thumbnail || !$.ispc()) { $('#lz-atlas-preview').find('.lz-thumbnail-box').hide(); $('#lz-atlas-preview').find('.lz-atlas-box .lz-img-bd .lz-tempwrap ul:first-child').css('bottom', '34px'); $('#lz-atlas-preview').find('.lz-see-change').css('bottom', '38px') } else { $('#lz-atlas-preview').find('.lz-thumbnail-box').show(); $('#lz-atlas-preview').find('.lz-atlas-box .lz-img-bd .lz-tempwrap ul:first-child').css('bottom', '') $('#lz-atlas-preview').find('.lz-see-change').css('bottom', '') } } } var previewinit = function (val, a, b, c) { var me = this; me.$ele = $(val); }; previewinit.prototype = { constructor: previewinit, defaults: { itemselect: '.w-atlas-ul li', clickselect: '', imgurl: [], csslink: 'control/css/atlas-preview.css', imgalt: [], imglink: [], imgtarget: [], pagesize: 1, length: 0, moveflag: false, initwidth: 0, getimgflag: false, canmove: false, openzoom: false, arrow: true, thumbnail: true, event: ['resize', 'close', 'corrow', 'pointer', 'zoom', 'move', 'wheel'] }, // ��ʼ������ _initparam: function (a) { var param = this.defaults; if ($.islzobject(a)) { param = $.extend(true, {}, param, a); } param.imgurl = $.islzarray(param.imgurl) ? param.imgurl : ($.islzstring(param.imgurl) && param.imgurl != '') ? param.imgurl.split(' ') : [param.imgurl]; param.tag = $.islzarray(param.imgalt) ? param.imgalt : ($.islzstring(param.imgalt) && param.imgalt != '') + [param.imgalt]; param.length = param.imgurl.length; return param; }, //��ʼ������ _layout: function () { var me = this, $this = me.$ele, lzpreviewdom = '