Greasy Fork is available in English.

PopupX - Flickr Tweak (Only Tiny Design Tweak for Flickr + Autopager support)

browse image(embeded a link) by a Popup Image Viewer ( Original version by NIO, Tweaked Design version by decembre)

  1. // ==UserScript==
  2.  
  3. // @name PopupX - Flickr Tweak (Only Tiny Design Tweak for Flickr + Autopager support)
  4.  
  5. // @namespace http://userscripts.org/users/45256
  6.  
  7. // @description browse image(embeded a link) by a Popup Image Viewer ( Original version by NIO, Tweaked Design version by decembre)
  8.  
  9. // @include http://*.pixnet.net/album/*
  10.  
  11. // @include http://photo.pchome.com.tw/*
  12.  
  13. // @include http://www.wretch.cc/album/*
  14.  
  15. // @include http://www.wretch.cc/album/
  16.  
  17. // @include http://www.wretch.cc/blog/*
  18.  
  19. // @include http://picasaweb.google.com*
  20.  
  21. // @include http://album.blog.yam.com/*
  22.  
  23. // @include http://gnn.gamer.com.tw/*
  24.  
  25. // @include http://*nownews.com*/*
  26.  
  27. // @include http://2cat.twbbs.org/*
  28.  
  29. // @include http://komica*.dreamhosters.com/*
  30.  
  31. // @include http://blog.roodo.com/*
  32.  
  33. // @include http://iphonecake.com/*
  34.  
  35. // @include http://*.flickr.com/*
  36.  
  37. // @include http://*.engadget.com/*
  38.  
  39. // @include http://www.facebook.com/album.php*
  40.  
  41. // @include http://class.ruten.com.tw/*
  42.  
  43.  
  44.  
  45.  
  46.  
  47. // @version 0.0.1.20140630035010
  48. // ==/UserScript==
  49. /*
  50. ________________________________________________
  51. ________________________________________________
  52.  
  53. >>> Original Author : nio
  54. // @name PopupX
  55. // @namespace http://userscripts.org/users/45256
  56. // @description browse image(embeded a link) by a Popup Image Viewer
  57. Go here for more information....
  58.  
  59. >>> Thanks to Alesa Dam for her help!
  60. ________________________________________________
  61. ________________________________________________
  62.  
  63. is Tweaked version for Flickr:
  64. ________________________________________________
  65.  
  66. >> 2010-/08/18 : (Thanks to Alesa Dam ) : Press the shift (MAJ) while hovering a thumbnail, if I you want shows the preview . This way you can decide yourself when to see a bigger picture or not.
  67.  
  68. >> 2010-/08/16
  69. - Added support to Autopager ...by inserting at the end of the script :
  70. window.addEventListener('AutoPagerAfterInsert', function(){PopupImage.load(); }, false);
  71. Now no needs to click on the blue button (must find a way to convert it in a On/Off button...)
  72.  
  73. >> 2010/08/13
  74. - Idea of Alesa Dam : changed line 314 from this:"//img[@class='pc_img' or @class='setThumb' or @class='nextprev_thumb' ]"
  75. into this:"//img[(@class='pc_img' or @class='setThumb' or @class='nextprev_thumb') and not(contains(@src,'/cols/') or contains(@src,'_z.jpg'))]"
  76. to make it ignore collection mozaics (which contain '/cols/' in the src attribute) and 640px wide medium images (which contain '_z.jpg' int the src)
  77. >> 2010/08/12
  78. - just tweak Design by decembre (no new functions)
  79.  
  80.  
  81. */
  82.  
  83. //CHANGE LOG in the Original Version
  84.  
  85. // 2010/02/25 -
  86. // * support website: class.ruten.com.tw
  87. // * modify toolbox style
  88.  
  89. // 2009/07/23 -
  90.  
  91. // * support website: www.facebook.com/ profile.php & album.php
  92.  
  93. // * fixed toolbox style: set width
  94.  
  95. // 2009/06/14 -
  96.  
  97. // * fixed website pattern: Gamer GNN
  98.  
  99. // * some style changed.
  100.  
  101. // 2009/06/03 -
  102.  
  103. // * support website: *.engadget.com
  104.  
  105. // 2009/05/28 -
  106.  
  107. // * append a toolbox at top-left
  108.  
  109. // * add a option: shrink image
  110.  
  111. // 2009/05/27 -
  112.  
  113. // * fixed pattern for yam
  114.  
  115. // 2009/05/24 -
  116.  
  117. // * support website: iphonecake.com, *.flickr.com
  118.  
  119. // * add reload button.
  120.  
  121. // * compatible with google chrome (bookmarklet).
  122.  
  123.  
  124.  
  125.  
  126.  
  127. (function(){
  128.  
  129.  
  130.  
  131. var __fit = false;
  132.  
  133. var PopupImage =
  134.  
  135. {
  136.  
  137.  
  138. //樣式集
  139.  
  140. data :
  141.  
  142. [
  143.  
  144. //Pixnet相簿
  145.  
  146. [
  147.  
  148. /.*\.pixnet\.net\/album\//,
  149.  
  150. /\/thumb_/,
  151.  
  152. '/',
  153.  
  154. '//*[@id="contentBody"]//img[@class="thumb"]'
  155.  
  156. ],
  157.  
  158. //PCHome Photo
  159.  
  160. [
  161.  
  162. /photo\.pchome\.com\.tw/,
  163.  
  164. /s\./,
  165.  
  166. '.',
  167.  
  168. '//span[@class="PostponeImg Cover"]'
  169.  
  170. // '//span/img[1]'
  171.  
  172. ],
  173.  
  174.  
  175. //無名個人相簿
  176.  
  177. [
  178.  
  179. /www\.wretch\.cc\/album\/.+/,
  180.  
  181. /thumbs\/t/,
  182.  
  183. '',
  184.  
  185. '//*[@class="side"]/a/img[1]'
  186.  
  187. ],
  188.  
  189. //無名相簿首頁
  190.  
  191. [
  192.  
  193. /www\.wretch\.cc\/album\/$/,
  194.  
  195. /thumbs\/t/,
  196.  
  197. '',
  198.  
  199. '//*[@class="image_link"]/a/img[1]' //'.image_link >a>img:first-child'
  200.  
  201. ],
  202.  
  203. //無名blog頁面
  204.  
  205. [
  206.  
  207. /www\.wretch\.cc\/blog\/.+/,
  208.  
  209. /http:\/\/([\w\W]+cover\/)([\w\W]+)_\w+([\w\W]*)$/,
  210.  
  211. 'http://cover.wretch.cc/$2$3',
  212.  
  213. "//*[@class='boxMySpaceImg' or @class='bighead' or @id='whowrapper']//img[1]"
  214.  
  215. //'a.bighead>img:first-child, #whowrapper a img, #boxMySpace .boxMySpaceImg a img'
  216.  
  217. ],
  218.  
  219. //Picasaweb
  220.  
  221. [
  222.  
  223. /picasaweb\.google\.com(\.tw)?\/\w+/,
  224.  
  225. /\/(s\d{2,4})(\-\w+)?\//,
  226.  
  227. '/s640/',
  228.  
  229. "//a/img[1]" //'a>img:first-child'
  230.  
  231. ],
  232.  
  233. //Yam
  234.  
  235. [
  236.  
  237. /album\.blog\.yam\.com\/\w+/,
  238.  
  239. /\/album\/[\w]_/,
  240.  
  241. '/album/',
  242.  
  243. "//*[@class='photoimg' or @class='albumShow' or @id='sideBlock' or @id='albumList']//a/img" //'.photoimg a>img, .albumShow a>img, #sideBlock a>img, #albumList a>img';
  244.  
  245. ],
  246.  
  247. //Gamer GNN
  248.  
  249. [
  250.  
  251. /gnn\.gamer\.com\.tw\//,
  252.  
  253. /\/(M|S)\//,
  254.  
  255. '/B/',
  256.  
  257. "//img[@class='gnnPIC']" //"//a[starts-with(@href,'javascript:showpic(')]/img" //'a[href^="javascript:showpic("]>img'
  258.  
  259. ],
  260.  
  261. //NowNews
  262.  
  263. [
  264.  
  265. /www\.nownews\.com\//,
  266.  
  267. /s(\d+\.(jpg|JPG))/,
  268.  
  269. 'i$1',
  270.  
  271. "//a/img" //'a>img:first-child'
  272.  
  273. ],
  274.  
  275.  
  276. //2cat (no frameset)
  277.  
  278. [
  279.  
  280. /2cat\.twbbs\.org\//,
  281.  
  282. /thumb\/(\d+)s/,
  283.  
  284. 'src/$1',
  285.  
  286. "//div[@class='threadpost' or @class='reply']/a/img"
  287.  
  288. ],
  289.  
  290. //komica*.dreamhosters (no frameset)
  291.  
  292. [
  293.  
  294. /komica\d+\.dreamhosters\.com\//,
  295.  
  296. /thumb\/(\d+)s/,
  297.  
  298. 'src/$1',
  299.  
  300. "//*[contains(name(),'FORM') or contains(name(),'form') or contains(name(),'TABLE')]//a/img"
  301.  
  302. ],
  303.  
  304. //Roodo Blog
  305.  
  306. //sample: http://blog.roodo.com/ace_kaha/
  307.  
  308. [
  309.  
  310. /blog\.roodo\.com\//,
  311.  
  312. /(\w+)_s/,
  313.  
  314. '$1',
  315.  
  316. "//div[@class='pict']//img"
  317.  
  318. ],
  319.  
  320. //iphonecake.com
  321.  
  322. [
  323.  
  324. /iphonecake\.com/,
  325.  
  326. /(?:\-\w+)(\.jpg)/,
  327.  
  328. '$1',
  329.  
  330. "//img[@class='attachment-thumbnail']"
  331.  
  332. ],
  333.  
  334. //www.flickr.com
  335.  
  336. [
  337.  
  338. /flickr\.com/,
  339.  
  340. /_[a-z](\.jpg)$/,
  341.  
  342. '$1',
  343.  
  344. "//img[(@class='pc_img' or @class='setThumb' or @class='nextprev_thumb') and not(contains(@src,'/cols/') or contains(@src,'_z.jpg'))]"
  345.  
  346. ],
  347.  
  348. //mining.tw
  349.  
  350. // [
  351.  
  352. // /mining\.tw/,
  353.  
  354. // /http:\/\/([\w\W]+cover\/)([\w\W]+)_\w+([\w\W]*)$/,
  355.  
  356. // 'http://cover.wretch.cc/$2$3',
  357.  
  358. // "//div[@class='mPic']/a/img"
  359.  
  360. // ],
  361.  
  362. //http://chinese.engadget.com
  363.  
  364. [
  365.  
  366. /\w+\.engadget\.com/,
  367.  
  368. /_thumbnail/,
  369.  
  370. '',
  371.  
  372. "//*[@class='thumb' or @class='postgallery']//a/img"
  373.  
  374. ],
  375.  
  376. //facebook album
  377.  
  378. //facebook profile
  379.  
  380. [
  381.  
  382. /www\.facebook\.com\/(album|profile)\.php/,
  383.  
  384. /s([\d_]+)?\.jpg/,
  385.  
  386. 'n$1.jpg',
  387.  
  388. "//div[@id='photos_of_wrapper' or @id='album_container' or @id='tab_content']//a/img"
  389.  
  390. ],
  391. //ruten.com
  392.  
  393. [
  394.  
  395. /\.ruten\.com\.tw/,
  396.  
  397. /_\w\.jpg$/,
  398.  
  399. "_m.jpg",
  400.  
  401. "//div[@id='bestgoods_div']/parent::td//a/img | //*[@class='featured-first' or @class='all-products']//a/img"
  402.  
  403. ]
  404.  
  405. ],
  406.  
  407.  
  408.  
  409. //樣式組
  410.  
  411. //針對不同網站有個別的設定
  412.  
  413. PatternSet: function()
  414.  
  415. {
  416.  
  417. this.urlExpression = //;
  418.  
  419. this.patternBefore = //;
  420.  
  421. this.patternAfter = '';
  422.  
  423. this.imgSelector = '';
  424.  
  425.  
  426. // self 指物件本身
  427.  
  428. var self = this;
  429.  
  430.  
  431. //插入真實圖片元素
  432.  
  433. this.appendTrueImage =
  434.  
  435. function(srcImgNode, patternSet)
  436.  
  437. {
  438.  
  439.  
  440. patternSet = self;
  441.  
  442.  
  443. var imgSrc = srcImgNode.getAttribute('src');
  444.  
  445. //if (imgSrc == null)
  446.  
  447. //imgSrc = srcImgNode.src;
  448.  
  449. if (imgSrc == null || imgSrc == "")
  450.  
  451. {
  452.  
  453. if (location.href.match(/photo\.pchome/))
  454.  
  455. {
  456.  
  457. imgSrc = srcImgNode.getAttribute('id');
  458.  
  459. imgSrc = imgSrc.replace(/Img\[([\w\/\.\-]+)\]/, '$1');
  460.  
  461. }
  462.  
  463. else if (location.href.match(/www\.wretch\.cc\/blog\/.+/))
  464.  
  465. {
  466.  
  467. var re = /\/blog\/(\w+)/;
  468.  
  469. var after = 'http://cover.wretch.cc/$1.jpg';
  470.  
  471. var href = srcImgNode.parentNode.getAttribute('href');
  472.  
  473. imgSrc = href.replace(re, after).toLowerCase();
  474.  
  475. }
  476.  
  477. }
  478.  
  479. imgSrc = imgSrc.replace(patternSet.patternBefore, patternSet.patternAfter);
  480.  
  481. var imgNode = document.createElement('img');
  482.  
  483. imgNode.setAttribute('class', 'trueImg');
  484.  
  485. imgNode.setAttribute('src', imgSrc);
  486.  
  487. imgNode.style.display = 'none';
  488.  
  489.  
  490.  
  491. srcImgNode.parentNode.appendChild(imgNode);
  492.  
  493.  
  494.  
  495. srcImgNode.addEventListener('mouseover',
  496.  
  497. function(ev)
  498. // Alesa Dam change : only shows the preview if I press shift (MAJ) while hovering a thumbnail. This way y can decide yourself when to see a bigger picture or not.
  499. {
  500. if (!ev.shiftKey) {
  501. return;
  502. }
  503.  
  504. PopupImage.show();
  505.  
  506. var true_nodes = PopupImage.getElementsByClassName(ev.target.parentNode, 'trueImg');
  507.  
  508. if (true_nodes.length == 0)
  509.  
  510. true_nodes = PopupImage.getElementsByClassName(ev.target.parentNode.parentNode, 'trueImg');
  511.  
  512.  
  513. if (true_nodes.length > 0)
  514.  
  515. {
  516.  
  517. var srcNode = true_nodes[0];
  518.  
  519. var get_src = srcNode.getAttribute('src');
  520.  
  521. //顯示圖片
  522.  
  523. PopupImage.setViewerSrc(get_src);
  524.  
  525.  
  526.  
  527. //自動縮放
  528.  
  529. //if (PopupImage.isFitWindow)
  530.  
  531.  
  532.  
  533. if (__fit)
  534.  
  535. {
  536.  
  537. var sW = srcNode.width;
  538.  
  539. var sH = srcNode.height;
  540.  
  541. var iW = window.innerWidth;
  542.  
  543. var iH = window.innerHeight;
  544.  
  545.  
  546.  
  547. var dx = sW/iW;
  548.  
  549. var dy = sH/iH;
  550.  
  551.  
  552.  
  553. console.log('dx: '+dx+', dy:' + dy);
  554.  
  555. // alert('dx: '+dx+', dy:' + dy);
  556.  
  557. if (dx > 1 || dy > 1)
  558.  
  559. {
  560.  
  561. var fixed_ratio = 0.95;
  562.  
  563. var ratio = dx > dy ? dx : dy;
  564.  
  565. console.log('ratio: ' + ratio + ' after w,h: '+ (sW/ratio)*fixed_ratio + ',' + (sH/ratio)*fixed_ratio );
  566.  
  567. PopupImage.setWidth((sW/ratio)*fixed_ratio);
  568.  
  569. PopupImage.setHeight((sH/ratio)*fixed_ratio);
  570.  
  571. }
  572.  
  573. else
  574.  
  575. {
  576.  
  577. PopupImage.setWidth("");
  578.  
  579. PopupImage.setHeight("");
  580.  
  581. }
  582.  
  583. }
  584.  
  585. else
  586.  
  587. {
  588.  
  589. PopupImage.setWidth("");
  590.  
  591. PopupImage.setHeight("");
  592.  
  593. }
  594.  
  595.  
  596. }
  597.  
  598. },
  599.  
  600. false);
  601.  
  602.  
  603. srcImgNode.addEventListener('mouseout',
  604.  
  605. function(ev)
  606.  
  607. {
  608.  
  609. PopupImage.hide();
  610.  
  611. },
  612.  
  613. false);
  614.  
  615.  
  616.  
  617. srcImgNode.addEventListener('mousemove',
  618.  
  619. function(ev)
  620.  
  621. {
  622.  
  623. var viewportWidth = window.innerWidth;
  624.  
  625. var viewportHeight = window.innerHeight;
  626.  
  627. var x,y;
  628.  
  629. var paddingX= 100;
  630.  
  631. var paddingY = 100;
  632.  
  633. var imgWidth = PopupImage.getWidth();
  634.  
  635. var imgHeight = PopupImage.getHeight();
  636.  
  637.  
  638. if(ev.pageX >= viewportWidth/2)
  639.  
  640. {
  641.  
  642. x = ev.pageX - imgWidth - paddingX;
  643.  
  644. offsetX = (typeof(window.pageXOffset)=='undefined') ? ev.pageX - ev.clientX : window.pageXOffset;
  645.  
  646. x = (x >= offsetX) ? x: offsetX;
  647.  
  648. }
  649.  
  650. else
  651.  
  652. {
  653.  
  654. x = eval(ev.pageX + paddingX);
  655.  
  656. var dx = (ev.pageX + imgWidth + paddingX) - viewportWidth;
  657.  
  658. x = (dx > 0) ? x-dx : x;
  659.  
  660. }
  661.  
  662.  
  663. if (ev.clientY >= viewportHeight/2)
  664.  
  665. {
  666.  
  667. y = ev.pageY - imgHeight - paddingY;
  668.  
  669. offsetY = (typeof(window.pageYOffset)=='undefined') ? ev.pageY - ev.clientY : window.pageYOffset;
  670.  
  671. y = (y >= offsetY) ? y : offsetY;
  672.  
  673. }
  674.  
  675. else
  676.  
  677. {
  678.  
  679. y = eval(ev.pageY + paddingY);
  680.  
  681. dy = (viewportHeight -( ev.clientY + imgHeight) - paddingY);
  682.  
  683. y = (dy >= 0) ? y : y+dy-50;
  684.  
  685. }
  686.  
  687.  
  688.  
  689. PopupImage.setViewerPos(x, y);
  690.  
  691. },
  692.  
  693. false);
  694.  
  695.  
  696.  
  697. },
  698.  
  699.  
  700. //列舉元素
  701.  
  702. this.selectNodes =
  703.  
  704. function(xpathExpr)
  705.  
  706. {
  707.  
  708. var nodes = new Array();
  709.  
  710. var iters = document.evaluate(xpathExpr, document, null, XPathResult.ANY_TYPE, null);
  711.  
  712. var node;
  713.  
  714. while (node = iters.iterateNext())
  715.  
  716. {
  717.  
  718. nodes.push(node);
  719.  
  720. };
  721.  
  722. return nodes;
  723.  
  724. },
  725.  
  726.  
  727. //檢查網址
  728.  
  729. this.check = function()
  730.  
  731. {
  732.  
  733. if (location.href.match(self.urlExpression))
  734.  
  735. self.set();
  736.  
  737. },
  738.  
  739.  
  740. //建立所有物件及連結
  741.  
  742. this.set = function()
  743.  
  744. {
  745.  
  746. PopupImage.isGetProfile = true;
  747.  
  748. var nodes = this.selectNodes(this.imgSelector);
  749.  
  750. for(var i=0;i<nodes.length;i++)
  751.  
  752. {
  753.  
  754. //建立原始圖片元素
  755.  
  756. this.appendTrueImage(nodes[i], this);
  757.  
  758.  
  759.  
  760. }
  761.  
  762. }
  763.  
  764.  
  765. },
  766.  
  767.  
  768. //存放所有樣式組
  769.  
  770. patterns : null,
  771.  
  772.  
  773. //頁面不支援的訊息
  774.  
  775. NOT_SUPPORT_MSG : 'Not support this page !',
  776.  
  777.  
  778.  
  779. //載入樣式
  780.  
  781. loadPatterns :
  782.  
  783. function()
  784.  
  785. {
  786.  
  787. var d = this.data;
  788.  
  789. var aList = [];
  790.  
  791.  
  792. for (var i=0; i<d.length; i++)
  793.  
  794. {
  795.  
  796. var set = d[i];
  797.  
  798. var p = new this.PatternSet();
  799.  
  800. p.urlExpression = set[0];
  801.  
  802. p.patternBefore = set[1];
  803.  
  804. p.patternAfter = set[2];
  805.  
  806. p.imgSelector = set[3];
  807.  
  808.  
  809. aList.push(p);
  810.  
  811. }
  812.  
  813.  
  814. this.patterns = aList;
  815.  
  816. return d.length;
  817.  
  818. },
  819.  
  820.  
  821. //viewer flag
  822.  
  823. isViewerShow: false,
  824.  
  825.  
  826. //match profile
  827.  
  828. isGetProfile: false,
  829.  
  830.  
  831. //show not support alert
  832.  
  833. isAlert : true,
  834.  
  835.  
  836. //auto fit
  837.  
  838. isFitWindow: true,
  839.  
  840.  
  841. //viewer hide or show
  842.  
  843. hide: function()
  844.  
  845. {
  846.  
  847. var viewer = document.getElementById('pi_viewer');
  848.  
  849. if (viewer)
  850.  
  851. {
  852.  
  853. viewer.style.display = 'none';
  854.  
  855. viewer.style.zIndex = 0;
  856.  
  857. }
  858.  
  859. },
  860.  
  861.  
  862. show: function()
  863.  
  864. {
  865.  
  866. var viewer = document.getElementById('pi_viewer');
  867.  
  868. if (viewer)
  869.  
  870. {
  871.  
  872. viewer.style.display = 'block';
  873.  
  874. viewer.style.zIndex = 65535;
  875.  
  876. }
  877.  
  878. },
  879.  
  880.  
  881. //設定位置
  882.  
  883. setViewerPos: function(x,y)
  884.  
  885. {
  886.  
  887. var viewer = document.getElementById('pi_viewer');
  888.  
  889. if (viewer)
  890.  
  891. {
  892.  
  893. viewer.style.top = eval(y + 10) + 'px';
  894.  
  895. viewer.style.left = eval(x+ 10) + 'px';
  896.  
  897. }
  898.  
  899. },
  900.  
  901.  
  902.  
  903. //取得寬度
  904.  
  905. getWidth: function()
  906.  
  907. {
  908.  
  909. return document.getElementById('pi_viewer').offsetWidth;
  910.  
  911. },
  912.  
  913.  
  914.  
  915. //取得高度
  916.  
  917. getHeight: function()
  918.  
  919. {
  920.  
  921. return document.getElementById('pi_viewer').offsetHeight;
  922.  
  923. },
  924.  
  925.  
  926. setWidth: function(val)
  927.  
  928. {
  929.  
  930. var p = document.getElementById('pi_viewer');
  931.  
  932. if (val)
  933.  
  934. {
  935.  
  936. p.style.width = val + ' px';
  937.  
  938. p.width = val;
  939.  
  940. }
  941.  
  942. else //val = ''
  943.  
  944. {
  945.  
  946. p.style.removeProperty('width');
  947.  
  948. p.removeAttribute('width');
  949.  
  950. }
  951.  
  952. },
  953.  
  954.  
  955. setHeight: function()
  956.  
  957. {
  958.  
  959. var p = document.getElementById('pi_viewer');
  960.  
  961. if (val)
  962.  
  963. {
  964.  
  965. p.style.height = val + ' px';
  966.  
  967. p.height = val;
  968.  
  969. }
  970.  
  971. else //val = ''
  972.  
  973. {
  974.  
  975. p.style.removeProperty('height');
  976.  
  977. p.removeAttribute('height');
  978.  
  979. }
  980.  
  981. },
  982.  
  983.  
  984.  
  985. getElementsByClassName : function (parentElement,className){
  986.  
  987. var elems = parentElement.getElementsByTagName("*");
  988.  
  989. var result=[];
  990.  
  991. for (i=0; j=elems[i]; i++){
  992.  
  993. if ((" "+j.className+" ").indexOf(" "+className+" ")!=-1)
  994.  
  995. {
  996.  
  997. result.push(j);
  998.  
  999. }
  1000.  
  1001. }
  1002.  
  1003. return result;
  1004.  
  1005. },
  1006.  
  1007.  
  1008.  
  1009. //改變顯示路徑
  1010.  
  1011. setViewerSrc: function(src)
  1012.  
  1013. {
  1014.  
  1015. //alert(src);
  1016.  
  1017.  
  1018. var viewer = document.getElementById('pi_viewer');
  1019.  
  1020. if (viewer)
  1021.  
  1022. {
  1023.  
  1024. viewer.setAttribute('src', src);
  1025.  
  1026. }
  1027.  
  1028. },
  1029.  
  1030.  
  1031. //create PopupViewer Element
  1032.  
  1033. setViewer: function()
  1034.  
  1035. {
  1036.  
  1037. var viewerNode = document.getElementById('pi_viewer');
  1038.  
  1039. if (!viewerNode )
  1040.  
  1041. {
  1042.  
  1043. viewerNode = document.createElement('img');
  1044.  
  1045. viewerNode.setAttribute('id', 'pi_viewer');
  1046. ///decembre change : de dashed à solid 20px
  1047. viewerNode.setAttribute('style', 'background: white;display: none;z-index:99;top:0;left:0;color:black;position:absolute;border:#888 solid 20px');
  1048.  
  1049.  
  1050.  
  1051. document.body.appendChild(viewerNode);
  1052.  
  1053.  
  1054.  
  1055. viewerNode.addEventListener('mouseover', function() {PopupImage.show();}, false);
  1056.  
  1057. viewerNode.addEventListener('mouseout', function() {PopupImage.hide();}, false);
  1058.  
  1059. viewerNode.addEventListener('click', function(){PopupImage.hide();}, false);
  1060.  
  1061.  
  1062.  
  1063. }
  1064.  
  1065. },
  1066.  
  1067.  
  1068. //append a tool box
  1069.  
  1070. setToolTip: function()
  1071.  
  1072. {
  1073.  
  1074. if (document.getElementById('pi_tooltip') == null)
  1075.  
  1076. {
  1077.  
  1078. var toolBox = document.createElement('div');
  1079. /// decembre Change : width de 20px à 5px ; position fixed à ; top: de 300px à 500px, left à right , border de solid gray 1px à 0, padding de 2px à 0px, background : de #F2A531 (orange) à #FFFFFF (blanc)
  1080. toolBox.setAttribute('style', 'width:5px; position:fixed; top:350px;right:10px;border:0;padding:0px;background:#FFFFFF;opacity:0.5;font:8px verdana !important;');
  1081.  
  1082. toolBox.setAttribute('id', 'pi_tooltip');
  1083.  
  1084. document.body.appendChild(toolBox);
  1085.  
  1086. }
  1087.  
  1088. },
  1089.  
  1090.  
  1091. //append a reload button
  1092.  
  1093. setReloadButton: function()
  1094.  
  1095. {
  1096.  
  1097.  
  1098.  
  1099. if (document.getElementById('pi_reload') == null)
  1100.  
  1101. {
  1102.  
  1103. var reloadImg = document.createElement('img');
  1104.  
  1105. reloadImg.setAttribute('style', 'border:0;');
  1106. /// decembre change image reload par bouton bleu
  1107. reloadImg.src="data:;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABc0lEQVQ4je2Tz27TQByEv7XXSYgtIqWh4U9aop7gCThxgCOvwIG34EF4KlQJVQhUJLhUpCRumjiOY9fuZnd/HMqpROoZiZFGc5pvTqM+ffOtH5kMvlwy/pwxOitlP7c8MI6OqbFmw+Z6TupmTMlJsUGGoyCiQWP1zMv7gwPehUMOkxL9aEMwqWDRQLUF5yDw2LYhjzO+d+f+2K042VR8LYrgXP+qebW3x7glaB1AqBShAqUgjqAfC8976Gc9BoOI/nbF4XLC+GxCki78sRYI2CEFhAruacWgA09i4WGboBK6sub+MpZuWarOzvJt0M5UNwN3Au7Sf8A/AZDbFrwA4sEJ6K3HWI8X+btkPKyN8LMEDUxDrMso8pTFbKnyNFNX6uUH92b0lLdJT143in5uaK3MzZFqA8aB3WKpyfUFp9GEj5Jx0tTqtKrUVPHCBwzptB/LKNnnqBXLkYoYWkdiGrzZsL6ek7oLzln+ubOnQHOFxv4Gzp29cH1mY9IAAAAASUVORK5CYII=";
  1108. /// decembre Change :
  1109. // reloadImg.setAttribute('style', "position:fixed; top:20px;left:10px;border:0;cursor:pointer;");
  1110.  
  1111. reloadImg.setAttribute('style', "border:0;cursor:pointer;");
  1112.  
  1113. reloadImg.setAttribute('title', 'PopupX reload');
  1114.  
  1115. reloadImg.setAttribute('id', 'pi_reload');
  1116.  
  1117. reloadImg.addEventListener('click', function(){PopupImage.load(); }, false);
  1118.  
  1119. document.getElementById('pi_tooltip').appendChild(reloadImg);
  1120.  
  1121. }
  1122.  
  1123. },
  1124.  
  1125.  
  1126. //append a checkbox
  1127.  
  1128. setFitCheckbox: function()
  1129.  
  1130. {
  1131.  
  1132. if (document.getElementById('pi_fit') == null)
  1133.  
  1134. {
  1135.  
  1136. var fit = document.createElement('label');
  1137.  
  1138. fit.setAttribute('fit', '1');
  1139.  
  1140. fit.setAttribute('id', 'pi_fit');
  1141. ///decembre change : black à red
  1142. fit.setAttribute('style', 'color:red !important;cursor:pointer;');
  1143.  
  1144. fit.textContent = 'S: ' + (__fit ? "O" : "X");
  1145.  
  1146. fit.setAttribute('title', fit.textContent);
  1147.  
  1148. fit.addEventListener('click', function(){
  1149.  
  1150. __fit = fit.getAttribute('fit') == '1' ? true : false;
  1151.  
  1152. this.isFitWindow = __fit;
  1153.  
  1154.  
  1155.  
  1156. fit.setAttribute('fit', (!this.isFitWindow)*1+'');
  1157.  
  1158. fit.textContent = 'S: ' + (this.isFitWindow ? "O" : "X");
  1159.  
  1160. fit.setAttribute('title', fit.textContent);
  1161.  
  1162. }, false);
  1163.  
  1164.  
  1165. document.getElementById('pi_tooltip').appendChild(document.createElement('hr'));
  1166.  
  1167. document.getElementById('pi_tooltip').appendChild(fit);
  1168.  
  1169. }
  1170.  
  1171. },
  1172.  
  1173.  
  1174. //check browser
  1175.  
  1176. CheckBrowser: function()
  1177.  
  1178. {
  1179.  
  1180. if (navigator.userAgent)
  1181.  
  1182. {
  1183.  
  1184. if (typeof String.prototype.replace_regx == 'function')
  1185.  
  1186. //if Google Chrome
  1187.  
  1188. String.prototype.replace = String.prototype.replace_regx;
  1189.  
  1190. }
  1191.  
  1192. },
  1193.  
  1194.  
  1195.  
  1196. //init
  1197.  
  1198. init: function()
  1199.  
  1200. {
  1201.  
  1202. this.CheckBrowser();
  1203.  
  1204. this.setViewer();
  1205.  
  1206. this.setToolTip();
  1207.  
  1208. this.setReloadButton();
  1209.  
  1210. this.setFitCheckbox();
  1211.  
  1212.  
  1213. },
  1214.  
  1215.  
  1216. //load all
  1217.  
  1218. load : function()
  1219.  
  1220. {
  1221.  
  1222. this.init();
  1223.  
  1224.  
  1225. var count = this.loadPatterns();
  1226.  
  1227. for(var i=0;i<count;i++)
  1228.  
  1229. {
  1230.  
  1231. this.patterns[i].check();
  1232.  
  1233. }
  1234.  
  1235.  
  1236. if (!PopupImage.isGetProfile && PopupImage.isAlert)
  1237.  
  1238. {
  1239.  
  1240. alert(this.NOT_SUPPORT_MSG);
  1241.  
  1242. }
  1243.  
  1244. }
  1245.  
  1246.  
  1247.  
  1248. };
  1249.  
  1250.  
  1251.  
  1252. (function()
  1253.  
  1254. {
  1255. //decembre change : Added support to Autopager
  1256. PopupImage.isAlert = false;
  1257.  
  1258. PopupImage.load();
  1259.  
  1260. window.addEventListener('AutoPagerAfterInsert', function(){PopupImage.load(); }, false);
  1261.  
  1262. })();
  1263.  
  1264.  
  1265.  
  1266.  
  1267.  
  1268. })();
  1269.  
  1270.