123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644 |
- Namespace.register("U.MT.UI.Picture");
- U.MT.UI.Picture = U.MT.UI.picture = function (arr, choosenum) {
- if (!!arr || typeof arr != 'array') {
- return;
- }
-
- U.MT.UI.Picture.ATTR = {
- "start": [],
- "now": [],
- "startX": 0
- }
-
- U.MT.UI.Picture.USERPICS = arr;
-
- U.MT.UI.Picture.create(choosenum);
- };
- U.MT.UI.Picture.MTW = document.documentElement.clientWidth
- U.MT.UI.Picture.MTH = document.documentElement.clientHeight
- U.MT.UI.Picture.currentnum = 0
- U.MT.UI.Picture.lastnum = 0
- U.MT.UI.Picture.rotatenum = 0
- U.MT.UI.Picture.scalenum = 1
- U.MT.UI.Picture.picmovedis = [0, 0]
- U.MT.UI.Picture.conpicbox = null
- U.MT.UI.Picture.header = null
- U.MT.UI.Picture.showstage = null
- U.MT.UI.Picture.showpicplace = null
- U.MT.UI.Picture.download = null
- U.MT.UI.Picture.pics = null
- U.MT.UI.Picture.picarr = null
- U.MT.UI.Picture.disx = 0
- U.MT.UI.Picture.disy = 0
- U.MT.UI.Picture.touchstartx = 0
- U.MT.UI.Picture.timer = null
- U.MT.UI.Picture.dbclicktimes = 0
- U.MT.UI.Picture.checkscale = true
- U.MT.UI.Picture.scalew = 0
- U.MT.UI.Picture.scaleh = 0
- U.MT.UI.Picture.touchmovedisx = 0
- U.MT.UI.Picture.touchmovedisy = 0
- U.MT.UI.Picture.start = 0
- U.MT.UI.Picture.now = 0
- U.MT.UI.Picture.startx = 0
- U.MT.UI.Picture.picUrl = ''
- U.MT.UI.Picture.TEMPLATE = [
- '<header class="U_MT_UI_Picture_header" id="U_MT_UI_Picture_header">' +
- ' <div class="U_MT_UI_Picture_header_a">' +
- ' <p>' +
- ' <i class="U_MT_UI_Picture_icon" id="U_MT_UI_Picture_back"></i>' +
- ' <span class="U_MT_UI_Picture_title">图片及视频</span>' +
- ' <span style="position: absolute;right: 1.25rem;" id="U_MT_UI_Picture_close" onclick="U.MT.UI.Picture.close()">关闭</span>' +
- ' </p>' +
- ' </div>' +
- ' </header>' +
- ' <section class="U_MT_UI_Picture_content" id="U_MT_UI_Picture_content">' +
- ' </section>',
- '<section class="U_MT_UI_Picture_show_stage" id="U_MT_UI_Picture_showStage">' +
- '<span style="position: absolute;left: 1rem; top: 1rem; color:#fff; z-index:1; border: 1px solid white;padding: 2px 4px;box-shadow: 0 0 5px #fff;" id="U_MT_UI_Picture_close" onclick="U.MT.UI.Picture.close()">关闭</span>' +
- '<span class="U_MT_UI_Picture_moreIcon" id="U_MT_UI_Picture_moreIcon"></span>' +
- '<div class="U_MT_UI_Picture_stage_bottom">' +
- '<span class="U_MT_UI_Picture_stage_turnRight" id="U_MT_UI_Picture_turnRight"></span>' +
- '<span class="U_MT_UI_Picture_stage_turnLeft" id="U_MT_UI_Picture_turnLeft"></span>' +
- '<a class="U_MT_UI_Picture_download" id="U_MT_UI_Picture_download"></a>' +
- '</div>' +
- '<div class="U_MT_UI_Picture_show_pic" id="U_MT_UI_Picture_showPic">' +
- '<div class="U_MT_UI_Picture_showPicPlace" id="U_MT_UI_Picture_showPicPlace">' +
- '</div>' +
- '</div>' +
- '</section>'
- ];
- U.MT.UI.Picture.create = function (choosenum) {
- if (U.MT.UI.Picture.conpicbox) {
- U.MT.UI.Picture.conpicbox.innerHTML = "";
- U.MT.UI.Picture.picUrl = '';
- U.MT.UI.Picture.addPic(U.MT.UI.Picture.USERPICS, choosenum);
- U.selectEl('#U_MT_UI_Picture_picBox')[0].style.display = 'block';
- return;
- }
- var _box = $$('div', { id: 'U_MT_UI_Picture_picBox', className: 'U_MT_UI_Picture_pic_box' }, document.body);
- _box.innerHTML = this.TEMPLATE[0] + this.TEMPLATE[1];
- var _showPic = U.selectEl('#U_MT_UI_Picture_showPic')[0];
- U.MT.UI.Picture.conpicbox = U.selectEl('#U_MT_UI_Picture_content')[0];
- U.MT.UI.Picture.header = U.selectEl('#U_MT_UI_Picture_header')[0];
- U.MT.UI.Picture.showstage = U.selectEl('#U_MT_UI_Picture_showStage')[0];
- U.MT.UI.Picture.showpicplace = U.selectEl('#U_MT_UI_Picture_showPicPlace')[0];
- U.MT.UI.Picture.download = U.selectEl('#U_MT_UI_Picture_download')[0];
- this.addPic(this.USERPICS, choosenum);
- U.MT.UI.Picture.loadbind();
- U.MT.UI.Picture.touchDrag(_showPic, U.MT.UI.Picture.showpicplace);
- }
- U.MT.UI.Picture.loadbind = function () {
-
- U.selectEl('#U_MT_UI_Picture_moreIcon')[0].addEventListener('click', U.UF.C.apply(this, function () {
- this.header.style.display = 'block';
- this.conpicbox.style.display = 'block';
- this.showstage.style.display = 'none';
- }), false);
-
- U.selectEl('#U_MT_UI_Picture_back')[0].addEventListener('click', U.UF.C.apply(this, function () {
- if (this.pics) {
- this.header.style.display = 'none';
- this.conpicbox.style.display = 'none';
- this.showstage.style.display = 'block';
- } else {
- U.alert('请先选择图片', 2000);
- }
- }), false);
-
- U.selectEl('#U_MT_UI_Picture_turnRight')[0].addEventListener('click', U.UF.C.apply(this, function () {
- this.rotatenum -= 90;
- this.transformControl(U.MT.UI.Picture.pics[this.currentnum], 'rotate(' + this.rotatenum + 'deg)');
- }), false);
-
- U.selectEl('#U_MT_UI_Picture_turnLeft')[0].addEventListener('click', U.UF.C.apply(this, function () {
- this.rotatenum += 90;
- this.transformControl(U.MT.UI.Picture.pics[this.currentnum], 'rotate(' + this.rotatenum + 'deg)');
- }), false);
- var _closes = U.selectEl('.U_MT_UI_Picture_close')
- }
- U.MT.UI.Picture.close = function () {
- if (_el = U.selectEl('#U_MT_UI_Picture_picBox')[0])
- _el.style.display = 'none';
- }
- U.MT.UI.Picture.addPic = function (arr, choosenum) {
- if (typeof arr[0] === 'string') {
- var _cbox = $$('div', { className: 'U_MT_UI_Picture_content_a' }, U.MT.UI.Picture.conpicbox),
- _s;
- for (var i = 0; i < arr.length; i++) {
- _s = $$('span', { className: 'U_MT_UI_Picture_divPic', style: { "background-image": "url(" + arr[i] + ")"} }, _cbox);
- U.MT.UI.Picture.picUrl += arr[i] + ((arr.length - 1 !== i) ? ',' : '');
- }
- if (arr.length === 1) {
- U.selectEl('#U_MT_UI_Picture_moreIcon')[0].style.display = 'none';
- }
- U.MT.UI.Picture.showPic(U.MT.UI.Picture.picUrl + ',' + (choosenum || 0));
- return;
- }
- for (var a in arr) {
- if (a === 'date') {
- $$('p', { style: { 'padding': '.8rem' }, innerText: arr[a] }, U.MT.UI.Picture.conpicbox);
- continue;
- }
- if (a === 'pic' && Array.isArray(arr[a])) {
- var _cbox = $$('div', { className: 'U_MT_UI_Picture_content_a' }, U.MT.UI.Picture.conpicbox);
- for (var i = 0; i < arr[a].length; i++) {
- var _s = $$('span', { className: 'U_MT_UI_Picture_divPic', style: { "background-image": "url(" + arr[a][i] + ")"} }, _cbox);
- _s.arr = arr[a] + "," + i;
- _s.onclick = function () {
- U.MT.UI.Picture.showPic(this.arr);
- }
- }
- continue;
- }
- if (typeof arr[a] == 'object')
- U.MT.UI.Picture.addPic(arr[a]);
- }
- }
- U.MT.UI.Picture.showPic = function (picSource) {
- U.MT.UI.Picture.picarr = picSource.split(',');
- U.MT.UI.Picture.currentnum = parseInt(U.MT.UI.Picture.picarr.pop());
- U.MT.UI.Picture.showpicplace.innerHTML = "";
- U.MT.UI.Picture.header.style.display = 'none';
- U.MT.UI.Picture.conpicbox.style.display = 'none';
- U.MT.UI.Picture.showstage.style.display = 'block';
- for (var i = 0; i < U.MT.UI.Picture.picarr.length; i++) {
- var _div = $$('div', { style: { display: "inline-block", width: U.MT.UI.Picture.MTW + 'px', height: '100%'} }, U.MT.UI.Picture.showpicplace);
- var _img = $$('img', { "onerror": U.MD.C.imgError, src: U.MT.UI.Picture.picarr[i], className: "U_MT_UI_Picture_showImage", style: { transition: 'transform .25s'} }, _div);
- }
- U.MT.UI.Picture.pics = U.selectEl('.U_MT_UI_Picture_showImage');
- U.MT.UI.Picture.pics[0].onload = U.UF.C.apply(this, function () {
- for (var i = 0; i < U.MT.UI.Picture.pics.length; i++) {
- U.MT.UI.Picture.pics[i].style.marginTop = (U.MT.UI.Picture.MTH - U.MT.UI.Picture.pics[i].clientHeight) / 2 + 'px';
- }
- this.showpicplace.style.width = this.picarr.length * 100 + '%';
- this.transformControl(this.showpicplace, 'translate(' + (-this.MTW * this.currentnum) + 'px)');
- this.downloadPic(U.MT.UI.Picture.download);
- });
- }
- U.MT.UI.Picture.touchDrag = function (dragEl, moveEl) {
- dragEl.addEventListener('touchstart', function (event) {
- U.MT.UI.Picture.touchStart(moveEl, event);
- });
- dragEl.addEventListener('touchmove', function (event) {
- U.MT.UI.Picture.touchMove(moveEl, event);
- });
- dragEl.addEventListener('touchend', function (event) {
- U.MT.UI.Picture.touchEnd(moveEl);
- });
- moveEl.addEventListener('transitionend', U.UF.C.apply(this, function () {
- if (this.currentnum != this.lastnum) {
- this.pics[this.lastnum].style.transform = '';
- this.pics[this.lastnum].style.webkitTransform = '';
- };
- }))
- }
- U.MT.UI.Picture.touchStart = function (moveEl, event) {
- var _mElTransform = moveEl.style.transform === "" ? 0 : parseInt(moveEl.style.transform.match(new RegExp(/[0-9-.]/ig)).join(''));
- event.preventDefault();
- if (event.touches.length == 1) {
- var _touch = event.targetTouches[0];
- U.MT.UI.Picture.disx = _touch.clientX - _mElTransform;
- U.MT.UI.Picture.disy = _touch.clientY;
- U.MT.UI.Picture.startx = _touch.clientX;
- U.MT.UI.Picture.touchstartx = _mElTransform;
- moveEl.style.transition = null;
- moveEl.style.webkitTransition = null;
- U.MT.UI.Picture.fingernum = 1;
- U.MT.UI.Picture.dbclicktimes++;
- U.MT.UI.Picture.timer = setTimeout(function () {
- clearTimeout(this.timer);
- this.dbclicktimes = 0;
- } .bind(this), 200);
- if (U.MT.UI.Picture.dbclicktimes === 2) {
- clearTimeout(U.MT.UI.Picture.timer);
- U.MT.UI.Picture.dbclicktimes = 0;
- if (U.MT.UI.Picture.checkscale) {
- var _multipleSize = parseInt(U.MT.UI.Picture.MTH / U.MT.UI.Picture.pics[U.MT.UI.Picture.currentnum].clientHeight * 100) / 100;
- U.MT.UI.Picture.scalenum = _multipleSize;
- U.MT.UI.Picture.scalew = U.MT.UI.Picture.pics[U.MT.UI.Picture.currentnum].clientWidth * _multipleSize;
- U.MT.UI.Picture.scaleh = U.MT.UI.Picture.pics[U.MT.UI.Picture.currentnum].clientHeight * _multipleSize;
- U.MT.UI.Picture.transformControl(U.MT.UI.Picture.pics[U.MT.UI.Picture.currentnum], 'scale(' + U.MT.UI.Picture.scalenum + ')');
- U.MT.UI.Picture.checkscale = false;
- } else {
- U.MT.UI.Picture.transformControl(U.MT.UI.Picture.pics[U.MT.UI.Picture.currentnum], 'translate(0,0)', 'scale');
- U.MT.UI.Picture.picmovedis[0] = 0;
- U.MT.UI.Picture.picmovedis[1] = 0;
- U.MT.UI.Picture.scalenum = 1;
- U.MT.UI.Picture.checkscale = true;
- }
- }
- } else if (event.touches.length === 2) {
- U.MT.UI.Picture.fingernum = 2;
- U.MT.UI.Picture.start = U.MT.UI.Picture.getDistance(event.touches[0], event.touches[1]);
- }
- }
- U.MT.UI.Picture.touchMove = function (moveEl, event) {
- var event = event || window.event, _touch = event.targetTouches[0];
- event.stopPropagation();
- if (U.MT.UI.Picture.fingernum === 2) {
- U.MT.UI.Picture.now = U.MT.UI.Picture.getDistance(event.touches[0], event.touches[1]);
- var _magnification = (U.MT.UI.Picture.now / U.MT.UI.Picture.start - 1);
- U.MT.UI.Picture.scalew = U.MT.UI.Picture.pics[U.MT.UI.Picture.currentnum].clientWidth * (_magnification + U.MT.UI.Picture.scalenum);
- U.MT.UI.Picture.scaleh = U.MT.UI.Picture.pics[U.MT.UI.Picture.currentnum].clientHeight * (_magnification + U.MT.UI.Picture.scalenum);
- U.MT.UI.Picture.pics[U.MT.UI.Picture.currentnum].style.transition = null;
- U.MT.UI.Picture.pics[U.MT.UI.Picture.currentnum].style.webkitTransition = null;
- U.MT.UI.Picture.transformControl(U.MT.UI.Picture.pics[U.MT.UI.Picture.currentnum], 'scale(' + (_magnification + U.MT.UI.Picture.scalenum) + ')');
- U.MT.UI.Picture.checkscale = false;
- } else if (U.MT.UI.Picture.fingernum === 1 && U.MT.UI.Picture.checkscale) {
- U.MT.UI.Picture.slide(moveEl, U.MT.UI.Picture.disx, U.MT.UI.Picture.startx, event);
- } else if (U.MT.UI.Picture.fingernum === 1 && !U.MT.UI.Picture.checkscale) {
- var _mElTransform = moveEl.style.transform === "" ? 0 : parseInt(moveEl.style.transform.match(new RegExp(/[0-9-.]/ig)).join(''));
- U.MT.UI.Picture.touchmovedisx = _touch.clientX - _mElTransform + U.MT.UI.Picture.picmovedis[0] - U.MT.UI.Picture.disx;
- U.MT.UI.Picture.touchmovedisy = _touch.clientY + U.MT.UI.Picture.picmovedis[1] - U.MT.UI.Picture.disy;
- if (
- (Math.abs(U.MT.UI.Picture.touchmovedisx) > Math.abs((U.MT.UI.Picture.MTW - U.MT.UI.Picture.scalew) / 2) + U.MT.UI.Picture.MTW / 3) ||
- (U.MT.UI.Picture.rotatenum % 180 != 0 && Math.abs(U.MT.UI.Picture.touchmovedisx) > (Math.abs(U.MT.UI.Picture.MTW - U.MT.UI.Picture.scaleh) / 2) + U.MT.UI.Picture.MTW / 3) ||
- Math.abs(U.MT.UI.Picture.touchmovedisy) > U.MT.UI.Picture.scaleh / 1.5
- ) {
- U.MT.UI.Picture.checkscale = true;
- U.MT.UI.Picture.disx = U.MT.UI.Picture.currentnum * U.MT.UI.Picture.MTW + _touch.clientX;
- U.MT.UI.Picture.pics[U.MT.UI.Picture.currentnum].style.transform = '';
- U.MT.UI.Picture.pics[U.MT.UI.Picture.currentnum].style.webkitTransform = '';
- U.MT.UI.Picture.pics[U.MT.UI.Picture.currentnum].style.transition = 'transform .25s';
- U.MT.UI.Picture.pics[U.MT.UI.Picture.currentnum].style.webkitTransition = 'transform .25s';
- U.MT.UI.Picture.rotatenum = 0;
- U.MT.UI.Picture.scalenum = 1;
- U.MT.UI.Picture.startx = _touch.clientX;
- } else {
- U.MT.UI.Picture.pics[U.MT.UI.Picture.currentnum].style.transition = null;
- U.MT.UI.Picture.pics[U.MT.UI.Picture.currentnum].style.webkitTransition = null;
- U.MT.UI.Picture.transformControl(U.MT.UI.Picture.pics[U.MT.UI.Picture.currentnum], 'translate(' + U.MT.UI.Picture.touchmovedisx + 'px,' + U.MT.UI.Picture.touchmovedisy + 'px)');
- }
- }
- }
- U.MT.UI.Picture.touchEnd = function (moveEl) {
- var _mElTransform = moveEl.style.transform === "" ? 0 : parseInt(moveEl.style.transform.match(new RegExp(/[0-9-.]/ig)).join('')),
- _diffX = U.MT.UI.Picture.touchstartx - _mElTransform,
- _magnification = (U.MT.UI.Picture.now / U.MT.UI.Picture.start - 1);
- U.MT.UI.Picture.touchMoveCheck(_diffX, moveEl);
- U.MT.UI.Picture.pics[U.MT.UI.Picture.currentnum].style.transition = 'transform .25s';
- U.MT.UI.Picture.pics[U.MT.UI.Picture.currentnum].style.webkitTransition = 'transform .25s';
- if (U.MT.UI.Picture.fingernum === 2) {
- U.MT.UI.Picture.scalenum += _magnification;
- if (U.MT.UI.Picture.scalenum < 0.8)
- U.MT.UI.Picture.scalenum = 0.8;
- else if (U.MT.UI.Picture.scalenum > 2.5)
- U.MT.UI.Picture.scalenum = 2.5;
- U.MT.UI.Picture.transformControl(U.MT.UI.Picture.pics[U.MT.UI.Picture.currentnum], 'scale(' + U.MT.UI.Picture.scalenum + ')');
- U.MT.UI.Picture.scalew = U.MT.UI.Picture.pics[U.MT.UI.Picture.currentnum].clientWidth * U.MT.UI.Picture.scalenum;
- U.MT.UI.Picture.scaleh = U.MT.UI.Picture.pics[U.MT.UI.Picture.currentnum].clientHeight * U.MT.UI.Picture.scalenum;
- }
- if (!U.MT.UI.Picture.checkscale) {
- U.MT.UI.Picture.picmovedis[0] = U.MT.UI.Picture.touchmovedisx;
- U.MT.UI.Picture.picmovedis[1] = U.MT.UI.Picture.touchmovedisy;
- U.MT.UI.Picture.dragImgBoundary(U.MT.UI.Picture.picmovedis, U.MT.UI.Picture.scalew, U.MT.UI.Picture.scaleh);
- } else {
- U.MT.UI.Picture.touchmovedisx = 0;
- U.MT.UI.Picture.touchmovedisy = 0;
- }
- }
- U.MT.UI.Picture.dragImgBoundary = function (picMoveDis, scaleW, scaleH) {
-
- var _outDisX = scaleW / 2 - U.MT.UI.Picture.MTW / 2, _outDisY = scaleH / 2 - U.MT.UI.Picture.MTH / 2;
- if (U.MT.UI.Picture.rotatenum % 180 == 0) {
- if (scaleW < U.MT.UI.Picture.MTW) {
- picMoveDis[0] = 0;
- } else {
- if (Math.abs(picMoveDis[0]) > Math.abs(_outDisX))
- picMoveDis[0] = picMoveDis[0] > 0 ? _outDisX : -_outDisX;
- }
- if (scaleH < U.MT.UI.Picture.MTH) {
- picMoveDis[1] = 0;
- } else {
- if (Math.abs(picMoveDis[1]) > Math.abs(_outDisY))
- picMoveDis[1] = picMoveDis[1] > 0 ? _outDisY : -_outDisY;
- }
- } else {
- if (scaleH < U.MT.UI.Picture.MTW) {
- picMoveDis[0] = 0;
- } else {
- if (Math.abs(picMoveDis[0]) > Math.abs(scaleH / 2 - U.MT.UI.Picture.MTW / 2))
- picMoveDis[0] = picMoveDis[0] > 0 ? scaleH / 2 - U.MT.UI.Picture.MTW / 2 : -(scaleH / 2 - U.MT.UI.Picture.MTW / 2);
- }
- if (scaleW < U.MT.UI.Picture.MTH) {
- picMoveDis[1] = 0;
- } else {
- if (Math.abs(picMoveDis[1]) > Math.abs(scaleW / 2 - U.MT.UI.Picture.MTH / 2))
- picMoveDis[1] = picMoveDis[1] > 0 ? scaleW / 2 - U.MT.UI.Picture.MTH / 2 : -(scaleW / 2 - U.MT.UI.Picture.MTH / 2);
- }
- }
- U.MT.UI.Picture.transformControl(U.MT.UI.Picture.pics[U.MT.UI.Picture.currentnum], 'translate(' + picMoveDis[0] + 'px,' + picMoveDis[1] + 'px)');
- }
- U.MT.UI.Picture.getDistance = function (p1, p2) {
- var x = p2.pageX - p1.pageX,
- y = p2.pageY - p1.pageY;
- return Math.sqrt((x * x) + (y * y));
- }
- U.MT.UI.Picture.slide = function (moveEl, disX, startX, event) {
- var event = event || window.event, _touch = event.targetTouches[0], _mElX = moveEl.style.transform === "" ? 0 : parseInt(moveEl.style.transform.match(new RegExp(/[0-9-.]/ig)).join(''));
- if (0 > _mElX)
- if (_mElX < -(moveEl.clientWidth - U.MT.UI.Picture.MTW)) {
- var _slowDownX = (startX - _touch.clientX) / 1.5 + (_touch.clientX - disX);
- U.MT.UI.Picture.transformControl(moveEl, 'translate(' + _slowDownX + 'px)');
- } else {
- U.MT.UI.Picture.transformControl(moveEl, 'translate(' + (_touch.clientX - disX) + 'px)');
- }
- else {
- U.MT.UI.Picture.transformControl(moveEl, 'translate(' + (_touch.clientX - disX) / 3 + 'px)');
- }
- event.stopImmediatePropagation();
- }
- U.MT.UI.Picture.touchMoveCheck = function (diffX, moveEl) {
- var _pageNum = Math.round(diffX / U.MT.UI.Picture.MTW);
- U.MT.UI.Picture.lastnum = U.MT.UI.Picture.currentnum;
- if (diffX >= 100 && _pageNum === 0) {
- U.MT.UI.Picture.currentnum++;
- U.MT.UI.Picture.rotatenum = 0;
- U.MT.UI.Picture.scalenum = 1;
- } else if (diffX <= -100 && _pageNum === 0) {
- U.MT.UI.Picture.currentnum--;
- U.MT.UI.Picture.rotatenum = 0;
- U.MT.UI.Picture.scalenum = 1;
- } else if (Math.abs(_pageNum) > 0) {
- U.MT.UI.Picture.rotatenum = 0;
- U.MT.UI.Picture.scalenum = 1;
- }
- U.MT.UI.Picture.currentnum = U.MT.UI.Picture.currentnum + _pageNum >= U.MT.UI.Picture.picarr.length - 1 ? U.MT.UI.Picture.picarr.length - 1 : U.MT.UI.Picture.currentnum + _pageNum;
- U.MT.UI.Picture.currentnum = U.MT.UI.Picture.currentnum <= 0 ? 0 : U.MT.UI.Picture.currentnum;
- moveEl.style.transition = 'transform .25s';
- moveEl.style.webkitTransition = 'transform .25s';
- U.MT.UI.Picture.transformControl(moveEl, 'translate(' + (-U.MT.UI.Picture.currentnum * U.MT.UI.Picture.MTW) + 'px)')
- U.MT.UI.Picture.downloadPic(U.MT.UI.Picture.download);
- }
- U.MT.UI.Picture.downloadPic = function (downLoadPic) {
-
- var imgSrc = U.MT.UI.Picture.pics[U.MT.UI.Picture.currentnum].getAttribute('src');
- if (U.MT.UI.Picture.browserIsIe()) {
- U.MT.UI.Picture.DownLoadReportIMG(imgSrc);
- } else {
-
- downLoadPic.setAttribute("href", imgSrc);
-
- downLoadPic.setAttribute('download', imgSrc.toLowerCase().split('/').splice(-1)[0]);
- downLoadPic.setAttribute('target', 'view_window')
- }
- }
- U.MT.UI.Picture.DownLoadReportIMG = function (imgPathURL) {
-
- if (!document.getElementById("IframeReportImg"))
- $$('iframe', { style: { display: 'none' }, id: "IframeReportImg", name: "IframeReportImg", onload: "DoSaveAsIMG()", width: 0, height: 0, src: 'about:blank' }, document.body);
- if (document.all.IframeReportImg.src != imgPathURL) {
-
- document.all.IframeReportImg.src = imgPathURL;
- } else {
-
- U.MT.UI.Picture.DoSaveAsIMG();
- }
- }
- U.MT.UI.Picture.DoSaveAsIMG = function () {
- if (document.all.IframeReportImg.src != "about:blank")
- window.frames["IframeReportImg"].document.execCommand("SaveAs");
- }
- U.MT.UI.Picture.browserIsIe = function () {
- if (!!window.ActiveXObject || "ActiveXObject" in window)
- return true;
- else
- return false;
- }
- U.MT.UI.Picture.transformControl = function (el, addAttr, delAttr) {
- var _attrArr = el.style.transform && el.style.transform.split(')'),
- _addAttr = addAttr || null,
- _delAttr = delAttr || null,
- addAttrStr = (el.style.transform && _addAttr) && ((c = el.style.transform.match(new RegExp(_addAttr.split('(')[0]))) && c[0]),
- str = '',
- _isinT;
- if (!_attrArr) {
- el.style.transform = _addAttr;
- el.style.webkitTransform = _addAttr;
- } else {
- _attrArr.pop();
- if (!addAttrStr && _addAttr)
- _attrArr.push(_addAttr);
- if (_addAttr && addAttrStr == 'translate')
- _attrArr.unshift(_addAttr);
- for (var _i = 0; _i < _attrArr.length; _i++) {
- _isinT = !str.match(new RegExp(_attrArr[_i].split('(')[0].trim()));
- if (_attrArr[_i].match(new RegExp(addAttrStr)) && _isinT) {
- str += _addAttr + ' ';
- } else if (!_attrArr[_i].match(new RegExp(_delAttr)) && _isinT) {
- if (_attrArr[_i].substr(_attrArr[_i].length - 1, 1) != ")") {
- str += _attrArr[_i] + ') ';
- } else {
- str += _attrArr[_i] + ' ';
- }
- }
- }
- el.style.transform = str;
- el.style.webkitTransform = str;
- }
- }
|