svnno****@sourc*****
svnno****@sourc*****
2010年 7月 28日 (水) 07:58:29 JST
Revision: 867 http://sourceforge.jp/projects/p2-php/svn/view?view=rev&revision=867 Author: rsk Date: 2010-07-28 07:58:29 +0900 (Wed, 28 Jul 2010) Log Message: ----------- expack: - FitImageããªãã¡ã¯ã¿ãªã³ã°ã - iOSç¨ã¬ã¹ãããã¢ããããªãã¡ã¯ã¿ãªã³ã°ã Modified Paths: -------------- p2ex/trunk/ic2_fitimage.php p2ex/trunk/js/fitimage.js p2ex/trunk/js/ic2_getinfo.js p2ex/trunk/js/respopup_iphone.js -------------- next part -------------- Modified: p2ex/trunk/ic2_fitimage.php =================================================================== --- p2ex/trunk/ic2_fitimage.php 2010-06-20 01:28:52 UTC (rev 866) +++ p2ex/trunk/ic2_fitimage.php 2010-07-27 22:58:29 UTC (rev 867) @@ -18,9 +18,6 @@ // {{{ æõEoÍpÏÝè $url = $_GET['url']; -$x = ''; -$y = ''; - $info_key_type = 'url'; $info_key_value = $url; @@ -36,25 +33,32 @@ $url = rawurldecode($m[1]); if ($icdb->get($url)) { $url = $thumbnailer->srcPath($icdb->size, $icdb->md5, $icdb->mime); - $x = $icdb->width; - $y = $icdb->height; + $x = (int)$icdb->width; + $y = (int)$icdb->height; + } else { + $x = 0; + $y = 0; } $info_key_type = 'id'; $info_key_value = $icdb->id; +} else { + // OàÁÄLbV ³ê½æð\¦·éÌÅA±±ÉÍȢ͸ + $x = 0; + $y = 0; } $info_key_value = htmlspecialchars($info_key_value, ENT_QUOTES); $alt = htmlspecialchars(basename($url)); -$afi_js = ''; +$autofit = ''; if ($x && $y) { if ($_conf['expack.ic2.fitimage'] == 1) { - $afi_js = "fi.fitTo('contract');"; + $autofit = 'contract'; } elseif ($_conf['expack.ic2.fitimage'] == 2) { - $afi_js = "fi.fitTo('width');"; + $autofit = 'width'; } elseif ($_conf['expack.ic2.fitimage'] == 3) { - $afi_js = "fi.fitTo('height');"; + $autofit = 'height'; } } @@ -78,61 +82,8 @@ <script type="text/javascript" src="js/json2.js?{$_conf['p2_version_id']}"></script> <script type="text/javascript" src="js/ic2_getinfo.js?{$_conf['p2_version_id']}"></script> <script type="text/javascript" src="js/fitimage.js?{$_conf['p2_version_id']}"></script> - <script type="text/javascript"> - //<![CDATA[ - var fi, fiTimer = null; - - function fiSetup() - { - window.focus(); - - function \$(id) { return document.getElementById(id); } - - var img = \$('picture'); - - fi = new FitImage(img, {$x}, {$y}); - {$afi_js} - - img.onclick = function(evt) - { - if (fiTimer) { - clearTimeout(fiTimer); - } - fiTimer = setTimeout('fiShowHide(); fiTimer = null;', 250); - }; - - img.ondblclick = function(evt) - { - if (fiTimer) { - clearTimeout(fiTimer); - fiTimer = null; - } - if (fi.currentMode == 'auto') { - fi.fitTo(fi.defaultMode); - } else { - fi.fitTo(fi.currentMode); - } - }; - - //\$('fi_fit_xy').onclick = function(evt){ fi.fitTo('full'); }; - \$('fi_fit_x').onclick = function(evt){ fi.fitTo('width'); }; - \$('fi_fit_y').onclick = function(evt){ fi.fitTo('height'); }; - - fiGetImageInfo('{$info_key_type}', '{$info_key_value}'); - - if (\$('fi_id').value != '') { - var stars = \$('fi_stars').getElementsByTagName('img'); - for (var i = 0; i < stars.length; i++) { - stars[i].onclick = (function(n){ - return function(){ fiUpdateRank(n); }; - })(i - 1); - } - } - } - //]]> - </script> </head> -<body onload="fiSetup()"> +<body onload="fiSetup({$x},{$y},'{$autofit}','{$info_key_type}','{$info_key_value}')"> <div id="btn"> <input type="hidden" id="fi_id" value=""> <!-- <input type="text" id="fi_memo" size="50" value=""><br> --> Modified: p2ex/trunk/js/fitimage.js =================================================================== --- p2ex/trunk/js/fitimage.js 2010-06-20 01:28:52 UTC (rev 866) +++ p2ex/trunk/js/fitimage.js 2010-07-27 22:58:29 UTC (rev 867) @@ -2,12 +2,17 @@ * ImageCache2::FitImage */ +// {{{ GLOBALS + +var fiTimer = null; + +// }}} // {{{ FitImage IuWFNg /* * RXgN^ * - * @param String id æÌidܽÍDOMvf + * @param String id æÌidܽÍDOMvf * @param Number width æÌ * @param Number height æ̳ */ @@ -130,6 +135,10 @@ /* * f[^x[X©çæîñðæ¾·é + * + * @param String type + * @param String value + * @return void */ function fiGetImageInfo(type, value) { @@ -271,8 +280,79 @@ } // }}} +// {{{ fiSetup() /* + * FitImageðZbgAbv·é + * + * @param Number width + * @param Number height + * @param String autofit + * @param String infoKeyType + * @param String infoKeyValue + * @return void + */ +function fiSetup(width, height, autofit, infoKeyType, infoKeyValue) +{ + var $, fi, img; + + if (typeof(width) !== 'number' || width < 1 || + typeof(height) !== 'number' || height < 1) { + alert('FitImageÌZbgAbv¸s: æTCYªs³Å·'); + return; + } + + window.focus(); + + $ = function(id){ + return document.getElementById(id); + }; + + img = $('picture'); + + fi = new FitImage(img, width, height); + if (autofit && autofit !== '') { + fi.fitTo(autofit); + } + + img.onclick = function(evt){ + if (fiTimer) { + clearTimeout(fiTimer); + } + fiTimer = setTimeout('fiShowHide(); fiTimer = null;', 250); + }; + + img.ondblclick = function(evt){ + if (fiTimer) { + clearTimeout(fiTimer); + fiTimer = null; + } + if (fi.currentMode == 'auto') { + fi.fitTo(fi.defaultMode); + } else { + fi.fitTo(fi.currentMode); + } + }; + + //$('fi_fit_xy').onclick = function(evt){ fi.fitTo('full'); }; + $('fi_fit_x').onclick = function(evt){ fi.fitTo('width'); }; + $('fi_fit_y').onclick = function(evt){ fi.fitTo('height'); }; + + fiGetImageInfo(infoKeyType, infoKeyValue); + + if ($('fi_id').value != '') { + var stars = $('fi_stars').getElementsByTagName('img'); + for (var i = 0; i < stars.length; i++) { + stars[i].onclick = (function(n){ + return function(){ fiUpdateRank(n); }; + })(i - 1); + } + } +} + +// }}} + +/* * Local Variables: * mode: javascript * coding: cp932 Modified: p2ex/trunk/js/ic2_getinfo.js =================================================================== --- p2ex/trunk/js/ic2_getinfo.js 2010-06-20 01:28:52 UTC (rev 866) +++ p2ex/trunk/js/ic2_getinfo.js 2010-07-27 22:58:29 UTC (rev 867) @@ -37,7 +37,12 @@ return null; } - return (typeof res === 'object' && typeof res.id === 'number') ? res : null; + if (res) { + if (typeof res.id === 'number') { + return res; + } + } + return null; } // }}} Modified: p2ex/trunk/js/respopup_iphone.js =================================================================== --- p2ex/trunk/js/respopup_iphone.js 2010-06-20 01:28:52 UTC (rev 866) +++ p2ex/trunk/js/respopup_iphone.js 2010-07-27 22:58:29 UTC (rev 867) @@ -32,7 +32,7 @@ }; // }}} -// {{{ getActivator() +// {{{ ipoputil.getActivator() /** * IuWFNgðÅOÊÉÚ®·éÖðÔ· @@ -48,7 +48,7 @@ }; // }}} -// {{{ getDeactivator() +// {{{ ipoputil.getDeactivator() /** * DOMc[©çIuWFNgðæèÖðÔ· @@ -66,7 +66,7 @@ }; // }}} -// {{{ iResPopUp() +// {{{ ipoputil.popup() /** * iPhonepX|bvAbv @@ -76,7 +76,7 @@ * @return {Boolean} * @todo use asynchronous request */ -var iResPopUp = function(url, evt) { +ipoputil.popup = function(url, evt) { var yOffset = Math.max(10, iutil.getPageY(evt) - 20); if (_IRESPOPG.hash[url]) { @@ -156,7 +156,31 @@ }; // }}} +// {{{ iResPopUp() +/** + * iPhonepX|bvAbv + * + * @param {String} url + * @param {Event} evt + * @return {Boolean} + * @todo use asynchronous request + * @see iutil.popup + */ +var iResPopUp = function(url, evt) { + if (typeof url !== 'string' && typeof url.href === 'string') { + url = url.href; + } + evt = evt || window.event; + if (false === ipoputil.popup(url, evt)) { + iutil.stopEvent(evt); + return false; + } + return true; +}; + +// }}} + /* * Local Variables: * mode: javascript