viewthread_album.htm 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. <!--{template common/header}-->
  2. <style type="text/css">
  3. .postalbum { background-color:#343434; display:none; height:100%; overflow:hidden; padding:0 0 1px 0; position:absolute; top:0; width:100%; z-index:80; }
  4. .postalbum_h { height:44px; left:0; line-height:44px; position:absolute; top:0px; width:100%; z-index:90; opacity:0.7; background:black; }
  5. .postalbum_h a:link, a:visited, a:hover { color:white; }
  6. .postalbum_h_back { position:absolute; left:10px; top:0px; height:25px; width:30px; z-index:90; color:white; }
  7. .postalbum_h_picnum { position:absolute; right:10px; top:0px; height:25px; width:105px; z-index:90; color:white; }
  8. .postalbum_c { height:100%; position:relative; z-index:-1; display:-webkit-box; display:-moz-box; display:-o-box; display:box; -webkit-transition:all 350ms linear; -moz-transition:all 350ms linear; -o-transition:all 350ms linear; transition:all 350ms linear; }
  9. .postalbum_u { border-radius:3px 3px 3px 3px; text-align:center; }
  10. .postalbum_i { margin-bottom:-3px; max-width:100%; vertical-align:middle; visibility:hidden; }
  11. </style>
  12. <!--{eval $curaidkey = 0;}-->
  13. <!--{eval $count = count($imglist['aid']);}-->
  14. <!--{if $_GET['aid']}-->
  15. <!--{loop $imglist['aid'] $k $aid}-->
  16. <!--{if $_GET['aid'] == $aid}-->
  17. <!--{eval $curaidkey = $k;break;}-->
  18. <!--{/if}-->
  19. <!--{/loop}-->
  20. <!--{/if}-->
  21. <div class="postalbum">
  22. <div class="postalbum_h">
  23. <a href="forum.php?mod=viewthread&tid=$_G[tid]&page=$_G[page]" class="postalbum_h_back">{lang return}</a>
  24. <span class="postalbum_h_picnum">{lang numheader} <span id="curpic"><!--{eval echo $curaidkey + 1}--></span> {lang unitpaper} / {lang numtotal} $count {lang unitpaper}</span>
  25. </div>
  26. <ul class="postalbum_c">
  27. <!--{loop $imglist[url] $key $imgurl}-->
  28. <li class="postalbum_u" id="u_$key">
  29. <!--{eval $imgurl = getforumimg($imglist[aid][$key], 0, 2000, 550, 'fixnone');}-->
  30. <img class="postalbum_i" load="0" id="img_$key" <!--{if $curaidkey == $key}-->src="$imgurl"<!--{/if}--> zsrc="$imgurl" orig="$imglist[url][$key]"/>
  31. </li>
  32. <!--{/loop}-->
  33. </ul>
  34. </div>
  35. <script type="text/javascript">
  36. (function() {
  37. var support3d = ("WebKitCSSMatrix" in window && "m11" in new WebKitCSSMatrix());
  38. var curkey = $curaidkey;
  39. var count = $count;
  40. var imglist = new Array();
  41. imglist['url'] = [<!--{echo dimplode($imglist[url]);}-->];
  42. var width = window.innerWidth;
  43. var height = document.documentElement.clientHeight;
  44. $('.postalbum').css({'display':'block', 'height':height + 'px'});
  45. $('.postalbum_u').css({'height':height + 'px', 'width':width + 'px'});
  46. $('.postalbum_i').css({'max-height':'100%', 'visibility':'visible'});
  47. if(support3d) {
  48. $('.postalbum_c').css({'line-height':height + 'px', 'width':width * count + 'px'});
  49. slidmoving('-' + curkey * width);
  50. } else {
  51. $('.postalbum_c').css({'display':'block', 'height':height * count + 'px'});
  52. $('.postalbum_c').css({'top': '-' + curkey * height + 'px'});
  53. }
  54. var position = {};
  55. var status = true;
  56. var posalbum_touch_interval = 0;
  57. var postalbum_timeoutid = null;
  58. touchaction = function(postalbum, postalbum_u, fun) {
  59. postalbum.on('touchstart', postalbum_u, function(e) {
  60. e = mygetnativeevent(e);
  61. position.x1 = e.touches[0].pageX;
  62. position.y1 = e.touches[0].pageY;
  63. position.hori = true;
  64. status = true;
  65. }).on('touchmove', postalbum_u, function(e) {
  66. status = false;
  67. e = mygetnativeevent(e);
  68. position.x2 = e.touches[0].pageX;
  69. position.y2 = e.touches[0].pageY;
  70. position.distx = position.x2 - position.x1;
  71. position.disty = position.y2 - position.y2;
  72. if(Math.abs(position.distx) < 2 * Math.abs(position.disty)) {
  73. position.hori = false;
  74. } else {
  75. e.preventDefault();
  76. }
  77. }).on('touchend', postalbum_u, function(e) {
  78. e = mygetnativeevent(e);
  79. if(position.x2 && Math.abs(position.distx) > 30 && position.hori && !status) {
  80. var swipedire = position.distx > 0 ? 'right' : 'left';
  81. fun.call(this, swipedire, e);
  82. } else if(status) {
  83. postalbum_touch_interval = new Date().getTime();
  84. if(!postalbum_timeoutid) {
  85. postalbum_timeoutid = setTimeout(function() {
  86. var interval = new Date().getTime() - postalbum_touch_interval;
  87. if(interval >= 250) {
  88. fun.call(this, 'tap', e);
  89. }
  90. postalbum_touch_interval = 0;
  91. postalbum_timeoutid = null;
  92. }, 250);
  93. }
  94. }
  95. });
  96. };
  97. var curkeyimg = $('#img_' + curkey);
  98. curkeyimg.css({'-webkit-transition':'all 200ms', '-moz-transition':'all 200ms', '-o-transition':'all 200ms', 'transition':'all 200ms'});
  99. imgchange(curkeyimg, 1, 0, 0);
  100. setTimeout(function() {
  101. fiximgmove(curkeyimg);
  102. }, 350);
  103. var imgscale = 1;
  104. var oldscalex = 0;
  105. var oldscaley = 0;
  106. var newscalex = 0;
  107. var newscaley = 0;
  108. var imgmovestatus = false;
  109. var touch_interval = 0;
  110. var timeoutid = null;
  111. var imgtouchpos = {};
  112. $('.postalbum_u').on('touchstart', '.postalbum_i', function(e) {
  113. if(!imgmovestatus) {
  114. return;
  115. }
  116. e = mygetnativeevent(e);
  117. imgtouchpos.x1 = e.touches[0].pageX;
  118. imgtouchpos.y1 = e.touches[0].pageY;
  119. }).on('touchmove', '.postalbum_i', function(e) {
  120. if(!imgmovestatus) {
  121. return;
  122. }
  123. e = mygetnativeevent(e);
  124. imgtouchpos.x2 = e.touches[0].pageX;
  125. imgtouchpos.y2 = e.touches[0].pageY;
  126. imgtouchpos.distx = imgtouchpos.x2 - imgtouchpos.x1;
  127. imgtouchpos.disty = imgtouchpos.y2 - imgtouchpos.y1;
  128. newscalex = imgtouchpos.distx / imgscale + oldscalex;
  129. newscaley = imgtouchpos.disty / imgscale + oldscaley;
  130. imgchange($('#img_' + curkey), imgscale, newscalex, newscaley);
  131. }).on('touchend', '.postalbum_i', function(e) {
  132. touch_interval = new Date().getTime();
  133. if(!timeoutid) {
  134. timeoutid = setTimeout(function() {
  135. var interval = new Date().getTime() - touch_interval;
  136. var obj = $('#img_' + curkey);
  137. if(interval < 250) {
  138. imgscale = imgscale == 1 ? 2 : 1;
  139. imgmovestatus = (imgscale == 1) ? false : true;
  140. if(imgmovestatus) {
  141. obj.attr('src', obj.attr('orig'));
  142. }
  143. imgchange(obj, imgscale, newscalex, newscaley);
  144. setTimeout(function() {
  145. fiximgmove(obj);
  146. }, 250);
  147. } else {
  148. if(imgmovestatus) {
  149. oldscalex = newscalex;
  150. oldscaley = newscaley;
  151. fiximgmove(obj);
  152. }
  153. }
  154. touch_interval = 0;
  155. timeoutid = null;
  156. }, 250);
  157. }
  158. });
  159. function imgchange(img, scale, x, y) {
  160. if(!img[0]) {
  161. return;
  162. }
  163. scale = scale || 1;
  164. x = x || 0;
  165. y = y || 0;
  166. img.css('-webkit-transform', 'scale(' + scale + ')');
  167. img.css('-moz-transform', 'scale(' + scale + ')');
  168. img.css('-o-transform', 'scale(' + scale + ')');
  169. img.css('transform', 'scale(' + scale + ')');
  170. var pimg = img.parent();
  171. var translatetxt = (support3d ? "translate3d": "translate") + "(" + x * scale + "px, " + y * scale + "px" + (support3d ? ", 0px)": ")");
  172. pimg.css('-webkit-transform', translatetxt);
  173. pimg.css('-moz-transform', translatetxt);
  174. pimg.css('-o-transform', translatetxt);
  175. pimg.css('transform', translatetxt);
  176. }
  177. function fiximgmove(imgobj) {
  178. var offset = imgobj.offset();
  179. var movex = imgobj.width() * imgscale - width;
  180. var movey = imgobj.height() * imgscale - height;
  181. if(movey > 0) {
  182. var yoffset = offset.top - $('.postalbum').offset().top;
  183. if(yoffset > 0) {
  184. oldscaley = oldscaley - yoffset / imgscale;
  185. } else {
  186. if(yoffset + imgobj.height() * imgscale - height < 0) {
  187. oldscaley = oldscaley - (yoffset + imgobj.height() * imgscale - height) / imgscale;
  188. }
  189. }
  190. } else {
  191. oldscaley = 0;
  192. }
  193. if(movex > 0) {
  194. if(offset.left > 0) {
  195. oldscalex = oldscalex - offset.left / imgscale;
  196. } else {
  197. if(offset.left + imgobj.width() * imgscale - width < 0) {
  198. oldscalex = oldscalex - (offset.left + imgobj.width() * imgscale - width) / imgscale;
  199. }
  200. }
  201. } else {
  202. oldscalex = 0;
  203. }
  204. if(imgscale < 1) {
  205. imgscale = 1;
  206. }
  207. newscalex = oldscalex;
  208. newscaley = oldscaley;
  209. imgchange(imgobj, imgscale, oldscalex, oldscaley);
  210. }
  211. var headerstatus = true;
  212. touchaction($('.postalbum'), '.postalbum_u', function(swipedire, touchevent) {
  213. if(imgmovestatus) {
  214. return;
  215. }
  216. switch(swipedire) {
  217. case 'left':
  218. if(curkey >= count - 1) {
  219. popup.open('{lang lastpic}', 'alert');
  220. } else {
  221. for(var i=0; i<3; i++) {
  222. if(!$('#img_' + (curkey + i)).attr('src')) {
  223. $('#img_' + (curkey + i)).attr('src', $('#img_'+(curkey + i)).attr('zsrc'));
  224. }
  225. }
  226. curkey++;
  227. if(support3d) {
  228. slidmoving('-' + curkey * width);
  229. } else {
  230. $('.postalbum_c').css({'top': '-' + curkey * height + 'px'});
  231. }
  232. $('#curpic').text(curkey + 1);
  233. }
  234. break;
  235. case 'right':
  236. if(curkey <= 0) {
  237. popup.open('{lang firstpic}', 'alert');
  238. } else {
  239. for(var i=-3; i<0; i++) {
  240. if(!$('#img_' + (curkey + i)).attr('src')) {
  241. $('#img_' + (curkey + i)).attr('src', $('#img_'+(curkey + i)).attr('zsrc'));
  242. }
  243. }
  244. curkey--;
  245. if(support3d) {
  246. slidmoving('-' + curkey * width);
  247. } else {
  248. $('.postalbum_c').css({'top': '-' + curkey * height + 'px'});
  249. }
  250. $('#curpic').text(curkey + 1);
  251. }
  252. break;
  253. case 'tap':
  254. var obj = $('.postalbum_h');
  255. var top = headerstatus ? 0 : 44;
  256. adjust = function() {
  257. setTimeout(function() {
  258. if(top == 0 && headerstatus == false) {
  259. headerstatus = true;
  260. } else if(top == 44 && headerstatus == true) {
  261. headerstatus = false;
  262. } else if(headerstatus == false) {
  263. top--;
  264. obj.css('top', '-' + top + 'px');
  265. adjust();
  266. } else {
  267. top++;
  268. obj.css('top', '-' + top + 'px');
  269. adjust();
  270. }
  271. }, 10);
  272. }
  273. adjust();
  274. break;
  275. }
  276. });
  277. function slidmoving(distx) {
  278. $('.postalbum_c').css('-webkit-transform', 'translate3d('+ distx + 'px, 0, 0)');
  279. $('.postalbum_c').css('-moz-transform', 'translate3d('+ distx + 'px, 0, 0)');
  280. $('.postalbum_c').css('-o-transform', 'translate3d('+ distx + 'px, 0, 0)');
  281. $('.postalbum_c').css('transform', 'translate3d('+ distx + 'px, 0, 0)');
  282. return true;
  283. }
  284. })();
  285. </script>
  286. <!--{template common/footer}-->