<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>PageTalks &#187; thickbox</title>
	<atom:link href="http://pagetalks.com/tag/thickbox/feed" rel="self" type="application/rss+xml" />
	<link>http://pagetalks.com</link>
	<description>Pure Web Development &#38; Design Ideas</description>
	<lastBuildDate>Thu, 19 Jan 2012 12:06:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Let Thickbox conquers Flash</title>
		<link>http://pagetalks.com/2008/08/29/let-thickbox-conquers-flash.html</link>
		<comments>http://pagetalks.com/2008/08/29/let-thickbox-conquers-flash.html#comments</comments>
		<pubDate>Fri, 29 Aug 2008 09:08:37 +0000</pubDate>
		<dc:creator>Robin</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[thickbox]]></category>

		<guid isPermaLink="false">http://pagetalks.com/?p=61</guid>
		<description><![CDATA[大家都知道我们无所不能的Thickbox竟然不能支持Flash的载入。虽然将SWF文件当作iFrame内容直接用Anchor引用，可以在 IE下正常显示flash内容，可惜在FF下无用。在Thickbox还没有做出更新的时候，我们... ]]></description>
			<content:encoded><![CDATA[<p>大家都知道我们无所不能的Thickbox竟然不能支持Flash的载入。虽然将SWF文件当作iFrame内容直接用Anchor引用，可以在 IE下正常显示flash内容，可惜在FF下无用。在Thickbox还没有做出更新的时候，我们该怎么在Thickbox里面显示Flash呢？曾经有 人提出过改版的Thickbox， 可以他没有继续更新。</p>
<p>今天突发奇想，干脆写个PHP页面，然后当iFrame引用吧！</p>
<p>我这里示范一下用Thickbox打开FLV播放器并播放指定文件的例子吧。（其实这个ELFVision里已经得到了使用）<br />
这里使用的<a href="http://www.jeroenwijering.com/">JW FLV</a>播放器支持N多的参数和外部脚本，我们只订制了它播放文件、长度、宽度和自动播放，这四个非常基本的参数。如下是默认状态下的播放器代码：</p>
<pre>&lt;embed src="http://www.jeroenwijering.com/embed/player.swf" allowscriptaccess="always" allowfullscreen="true" flashvars="width=320&amp;height=250&amp;file=/upload/player.flv" width="320" height="250"&gt;&lt;/embed&gt; </pre>
<p><span id="more-61"></span><br />
接下来我们自己编写一个videoPlay.php页面来作为iFrame的内容，并在使用中向videoPlay.php传递参数。（小弟在写这 篇文章的时候特地花了几十分钟学PHP，对，就是几十分钟）在ELFVision中的videoPlay.php页面代码如下：</p>
<pre>
&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"&gt;
&lt;HTML&gt;
&lt;HEAD&gt;
&lt;TITLE&gt; Video Player - ELFVision &lt;/TITLE&gt;
&lt;META NAME="Generator" CONTENT="EditPlus"&gt;
&lt;META NAME="Author" CONTENT="Robin"&gt;
&lt;META NAME="Keywords" CONTENT="Video Playing"&gt;
&lt;META NAME="Description" CONTENT="Playing"&gt;
&lt;style&gt;
* {
padding: 0;
margin: 0;
}
body {
overflow: hidden;
}
&lt;/style&gt;
&lt;/HEAD&gt;
&lt;BODY&gt;
&lt;?php
$x=$_GET[’x'];
$y=$_GET[’y'];
$link=$_GET[’link’];
$autoplay=$_GET[’autop’];
echo ‘&lt;embed src="http://www.elfvision.com/blog/wp-content/mediaplayer.swf" ‘;
echo ‘width="’.$x.’ "height="’.$y.’" ‘;
echo ‘allowscriptaccess="always" ‘;
echo ‘allowfullscreen="true" ‘;
echo ‘ flashvars="height=’.$y.’&amp;width=’.$x.’&amp;file=’.$link.’&amp;screencolor=0xFFFFFF&amp;autostart=’.$autoplay.’" /&gt;’;
?&gt;
&lt;/BODY&gt;
&lt;/HTML&gt;
</pre>
<p>基本都是静态代码嘛……呵呵……</p>
<p>在正文中，可以像这样调用：</p>
<pre>&lt;a href="http://www.elfvision.com/movie/videoPlay.php?x=350&amp;y=204&amp;link=http://www.elfvision.com/movie/vitas_opera2.flv&amp;autop=true&amp;keepThis=true&amp;TB_iframe=true&amp;width=320&amp;height=194" class="thickbox"&gt;查看该视频&lt;/a&gt;</pre>
<p>其中排开实现thickbox所传递的参数外，x代表宽度，y代表高度，link代表FLV文件的绝对地址，autop代表是否自动播放。之所以这样命名，是为了防止和thickbox的参数冲突。这样，Thickbox就成功调用了！</p>
<p>另外一个很奇怪的事情就是，调用WP内置的Thickbox来显示Flash，其窗口宽度和高度会无缘地增加30px和10px。目前为止笔者还不 知道原因，所以我在传递thickbox的width和height的时候分别用真实值减去了30和10，暂且算是解决方案吧。知道真相的同学记得告诉我 哦！</p>
]]></content:encoded>
			<wfw:commentRss>http://pagetalks.com/2008/08/29/let-thickbox-conquers-flash.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Disable Image Resizing in Thickbox</title>
		<link>http://pagetalks.com/2008/08/29/disable-image-resizing-in-thickbox.html</link>
		<comments>http://pagetalks.com/2008/08/29/disable-image-resizing-in-thickbox.html#comments</comments>
		<pubDate>Fri, 29 Aug 2008 09:00:22 +0000</pubDate>
		<dc:creator>Robin</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[resize]]></category>
		<category><![CDATA[thickbox]]></category>

		<guid isPermaLink="false">http://pagetalks.com/?p=56</guid>
		<description><![CDATA[Thickbox对图片的处理相当相当智能，其中就包括图片的缩放，也就是当图片实际大小超过窗口大小的时候，脚本会自动把图片缩放到适当大小显 示，让图片不至于溢出。但这个带来一个比较麻... ]]></description>
			<content:encoded><![CDATA[<div lang="zh">Thickbox对图片的处理相当相当智能，其中就包括图片的缩放，也就是当图片实际大小超过窗口大小的时候，脚本会自动把图片缩放到适当大小显 示，让图片不至于溢出。但这个带来一个比较麻烦的事情，由于是通过简单改变IMG标签的width和height属性达到的缩放会使图片产生许多粗糙边缘 以及细节的丢失。于是大家开始寻找废掉这个“智能”的方法……汗~</p>
<h3>源头在哪里？</h3>
<p>打开thickbox.js，大家不难发现，图片Resize的代码就是如下这段：</p>
<pre>var pagesize = tb_getPageSize();
var x = pagesize[0] - 150;
var y = pagesize[1] - 150;
var imageWidth = imgPreloader.width;
var imageHeight = imgPreloader.height;
if (imageWidth &gt; x) {
imageHeight = imageHeight * (x / imageWidth);
imageWidth = x;
if (imageHeight &gt; y) {
imageWidth = imageWidth * (y / imageHeight);
imageHeight = y;
}
} else if (imageHeight &gt; y) {
imageWidth = imageWidth * (y / imageHeight);
imageHeight = y;
if (imageWidth &gt; x) {
imageHeight = imageHeight * (x / imageWidth);
imageWidth = x;
}
}</pre>
<p>很显然在这里就可以直接废掉它的机制，将以上代码替换为：</p>
<pre>var imageWidth = imgPreloader.width;
var imageHeight = imgPreloader.height;</pre>
<p>这样图片始终将以原始大小输出，如果浏览器没有特殊的自动缩放功能，那么图片将最终处于100%状态。
</p></div>
<div lang="en">Thickbox is quite intelligent on handling the images, e.g, it aotomatically resizes the images if it&#8217;s too large for the thickbox containers. Unfortunately , this is often not the intent of our own&#8230;</p>
<h3>Where is the root?</h3>
<p>Simply open thickbox.js, it&#8217;s easy to find the resizing is driven by the code below: </p>
<pre>var pagesize = tb_getPageSize();
var x = pagesize[0] - 150;
var y = pagesize[1] - 150;
var imageWidth = imgPreloader.width;
var imageHeight = imgPreloader.height;
if (imageWidth &gt; x) {
imageHeight = imageHeight * (x / imageWidth);
imageWidth = x;
if (imageHeight &gt; y) {
imageWidth = imageWidth * (y / imageHeight);
imageHeight = y;
}
} else if (imageHeight &gt; y) {
imageWidth = imageWidth * (y / imageHeight);
imageHeight = y;
if (imageWidth &gt; x) {
imageHeight = imageHeight * (x / imageWidth);
imageWidth = x;
}
}</pre>
<p>If you just want to disble it for good, don&#8217;t hesitate to replace the code above with these: </p>
<pre>var imageWidth = imgPreloader.width;
var imageHeight = imgPreloader.height;</pre>
<p>Finnaly thickbox displays the image in original size. Cheers!
</p></div>
<p><span id="more-56"></span></p>
<div lang="zh">
<h3>问题解决了？</h3>
<p>别高兴的太早！毕竟人家写Resize的代码是有用处的——因为Thickbox的窗口即使溢出，其主窗口也不会产生滚动条。也就是说，就算图片超过了屏幕，用户也不能通过滚动条浏览到图片全貌。这不是得不偿失么？！慢慢来……慢慢来……<br />
解决思路可以是如下的：<br />
1、如果图片能够在当前窗口100%显示且不会造成益处，系统就没有必要Resize<br />
2、图片太大无法在当前窗口以100%大小显示，需要Resize的时候，我们提供额外的全尺寸图片链接。<br />
这是目前最直接也是最有效的方法了……</p>
<p>我们首先还是需要找到之前的那段关于Resize的代码，将其替换为如下：</p>
<pre>var pagesize = tb_getPageSize();
var resized = false;
var x = pagesize[0] - 150;
var y = pagesize[1] - 150;
var imageWidth = imgPreloader.width;
var imageHeight = imgPreloader.height;
if (imageWidth &gt; x) {
resized = true;
imageHeight = imageHeight * (x / imageWidth);
imageWidth = x;
if (imageHeight &gt; y) {
imageWidth = imageWidth * (y / imageHeight);
imageHeight = y;
}
} else if (imageHeight &gt; y) {
resized = true;
imageWidth = imageWidth * (y / imageHeight);
imageHeight = y;
if (imageWidth &gt; x) {
imageHeight = imageHeight * (x / imageWidth);
imageWidth = x;
}
}</pre>
<p>其实无非是加入了一个名称为resized的布尔值变量，作为是否Resized判断。</p>
<p>紧接着我们要加入源文件链接，找到如下代码：</p>
<pre>$("#TB_window").append("&lt;a href='' id='TB_ImageOff' title='Close'&gt;&lt;img id='TB_Image' src='"+url+"' width='"+imageWidth+"' height='"+imageHeight+"' alt='"+caption+"'/&gt;&lt;/a&gt;" + "&lt;div id='TB_caption'&gt;"+caption+"&lt;div id='TB_secondLine'&gt;" + TB_imageCount + TB_PrevHTML + TB_NextHTML + "&lt;/div&gt;&lt;/div&gt;&lt;div id='TB_closeWindow'&gt;&lt;a href='#' id='TB_closeWindowButton' title='Close'&gt;close&lt;/a&gt; or Esc Key&lt;/div&gt;");</pre>
<p>稍微分析一下，你会发现这是thickbox窗口生成显示图片的代码。替换成如下：</p>
<pre>if(!resized){
$("#TB_window").append("&lt;a href='' id='TB_ImageOff' title='Close'&gt;&lt;img id='TB_Image' src='"+url+"' width='"+imageWidth+"' height='"+imageHeight+"' alt='"+caption+"'/&gt;&lt;/a&gt;" + "&lt;div id='TB_caption'&gt;"+caption+"&lt;div id='TB_secondLine'&gt;" + TB_imageCount + TB_PrevHTML + TB_NextHTML + "&lt;/div&gt;&lt;/div&gt;&lt;div id='TB_closeWindow'&gt;&lt;a href='#' id='TB_closeWindowButton' title='Close'&gt;close&lt;/a&gt; or Esc Key&lt;/div&gt;");
} else {
$("#TB_window").append("&lt;a href='' id='TB_ImageOff' title='Close'&gt;&lt;img id='TB_Image' src='"+url+"' width='"+imageWidth+"' height='"+imageHeight+"' alt='"+caption+"'/&gt;&lt;/a&gt;" + "&lt;div id='TB_caption'&gt;"+caption+" &lt;span style='color: rgb(255, 0, 0); font-weight: bold;'&gt;&lt;a href='"+url+"' target='_blank'&gt;CLICK FOR ORIGINAL SIZE&lt;/a&gt;&lt;/span&gt;"+"&lt;div id='TB_secondLine'&gt;" + TB_imageCount + TB_PrevHTML + TB_NextHTML + "&lt;/div&gt;&lt;/div&gt;&lt;div id='TB_closeWindow'&gt;&lt;a href='#' id='TB_closeWindowButton' title='Close'&gt;close&lt;/a&gt; or Esc Key&lt;/div&gt;");
}</pre>
<p>也就是如果之前resized变量为true，系统就会生成带有源文件链接的Thickbox窗口。至于链接样式，大家可以自己发挥……</p>
<p>事情就是这样，大家过上了幸福的生活……Orz~Thickbox的作者从此认识到自己Resize机制是多么不智能……
</p></div>
<div lang="en">
<h3>Problem Solved?</h3>
<p>It seems it works all right. What if the image is large enough to overflow the thickbox? You know that&#8217;s why the sophisticated developer type these code in their project to enable resizing. Let&#8217;s think better:<br />
1.If the image is fine with the thickbox, thus it won&#8217;t overflow. Well, resizing is not needed.<br />
2.If the image is large, let the script resize the image. Besides, we insert a link to the original file.<br />
Sounds like a plan?<br />
Let&#8217;s find the resizing code again, and replace it with the code below:</p>
<pre>var pagesize = tb_getPageSize();
var resized = false;
var x = pagesize[0] - 150;
var y = pagesize[1] - 150;
var imageWidth = imgPreloader.width;
var imageHeight = imgPreloader.height;
if (imageWidth &gt; x) {
resized = true;
imageHeight = imageHeight * (x / imageWidth);
imageWidth = x;
if (imageHeight &gt; y) {
imageWidth = imageWidth * (y / imageHeight);
imageHeight = y;
}
} else if (imageHeight &gt; y) {
resized = true;
imageWidth = imageWidth * (y / imageHeight);
imageHeight = y;
if (imageWidth &gt; x) {
imageHeight = imageHeight * (x / imageWidth);
imageWidth = x;
}
}</pre>
<p>In fact, I only create a boolean varible &#8220;resized&#8221; to flag if resized.<br />
Then we come back the thickbox.js, locate the code below:</p>
<pre>$("#TB_window").append("&lt;a href='' id='TB_ImageOff' title='Close'&gt;&lt;img id='TB_Image' src='"+url+"' width='"+imageWidth+"' height='"+imageHeight+"' alt='"+caption+"'/&gt;&lt;/a&gt;" + "&lt;div id='TB_caption'&gt;"+caption+"&lt;div id='TB_secondLine'&gt;" + TB_imageCount + TB_PrevHTML + TB_NextHTML + "&lt;/div&gt;&lt;/div&gt;&lt;div id='TB_closeWindow'&gt;&lt;a href='#' id='TB_closeWindowButton' title='Close'&gt;close&lt;/a&gt; or Esc Key&lt;/div&gt;");</pre>
<p>The code will control and create the elements in thickbox, you can modify as you wish. Here is mine: </p>
<pre>if(!resized){
$("#TB_window").append("&lt;a href='' id='TB_ImageOff' title='Close'&gt;&lt;img id='TB_Image' src='"+url+"' width='"+imageWidth+"' height='"+imageHeight+"' alt='"+caption+"'/&gt;&lt;/a&gt;" + "&lt;div id='TB_caption'&gt;"+caption+"&lt;div id='TB_secondLine'&gt;" + TB_imageCount + TB_PrevHTML + TB_NextHTML + "&lt;/div&gt;&lt;/div&gt;&lt;div id='TB_closeWindow'&gt;&lt;a href='#' id='TB_closeWindowButton' title='Close'&gt;close&lt;/a&gt; or Esc Key&lt;/div&gt;");
} else {
$("#TB_window").append("&lt;a href='' id='TB_ImageOff' title='Close'&gt;&lt;img id='TB_Image' src='"+url+"' width='"+imageWidth+"' height='"+imageHeight+"' alt='"+caption+"'/&gt;&lt;/a&gt;" + "&lt;div id='TB_caption'&gt;"+caption+" &lt;span style='color: rgb(255, 0, 0); font-weight: bold;'&gt;&lt;a href='"+url+"' target='_blank'&gt;CLICK FOR ORIGINAL SIZE&lt;/a&gt;&lt;/span&gt;"+"&lt;div id='TB_secondLine'&gt;" + TB_imageCount + TB_PrevHTML + TB_NextHTML + "&lt;/div&gt;&lt;/div&gt;&lt;div id='TB_closeWindow'&gt;&lt;a href='#' id='TB_closeWindowButton' title='Close'&gt;close&lt;/a&gt; or Esc Key&lt;/div&gt;");
}</pre>
<p>Obviously clear that if &#8220;resized&#8221; is true, it will insert a link where you assign in the previous code. Otherwise, peace&#8230;&#8230;</p>
<p>Well, the story ends&#8230;&#8230;You can try your plan. This is only a demostration how we can better or custom the thickbox.
</p></div>
]]></content:encoded>
			<wfw:commentRss>http://pagetalks.com/2008/08/29/disable-image-resizing-in-thickbox.html/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Thickbox and its customization</title>
		<link>http://pagetalks.com/2008/08/29/thickbox-and-its-customization.html</link>
		<comments>http://pagetalks.com/2008/08/29/thickbox-and-its-customization.html#comments</comments>
		<pubDate>Fri, 29 Aug 2008 08:56:24 +0000</pubDate>
		<dc:creator>Robin</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[thickbox]]></category>
		<category><![CDATA[ui]]></category>

		<guid isPermaLink="false">http://pagetalks.com/?p=52</guid>
		<description><![CDATA[Thickbox是基于jQuery的一套成熟的交互UI，能让设计师方便的实现Lightbox特效，以及更多你想不到的功能。 既然jQuery是一个轻量级的脚本库，作为设计师出生的使用者会感到它的使用是相对容易的... ]]></description>
			<content:encoded><![CDATA[<p><a href="http://jquery.com/demo/thickbox/">Thickbox</a>是基于<a href="http://jquery.com/">jQuery</a>的一套成熟的交互UI，能让设计师方便的实现Lightbox特效，以及更多你想不到的功能。<br />
既然jQuery是一个轻量级的脚本库，作为设计师出生的使用者会感到它的使用是相对容易的。运用Thickbox实现Lightbox效果是目前流行的几种实现方法中最灵活、最轻便的一种。除了轻便之外，它所支持的浏览器也相当的广泛：Windows IE 6.0, Windows IE 7+, Windows FF 2.0.0.6+, Windows Opera 9.0+, Macintosh Safari 2.0.4+, Macintosh FF 2.0.0.6+, Macintosh Opera 9.10+。</p>
<h3>安装Thickbox</h3>
<p>登陆官方网站获得最新版本的<a href="http://jquery.com/">jQuery</a>和<a href="http://jquery.com/demo/thickbox/">Thickbox</a>的文件，<br />
Thickbox需要jQuery的脚本库，那么首先应该载入jQuery，再载入Thickbox了。<br />
在META标签内加入如下语句：</p>
<pre>&lt;script type="text/javascript" src="path-to-file/jquery.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="path-to-file/thickbox.js"&gt;&lt;/script&gt;</pre>
<p><span id="more-52"></span><br />
这里需要注意的是jQuery的脚本文件必须先于thickbox的脚本文件，同时注意修改文件的路径。<br />
紧接着需要加入Thickbox的CSS文件：</p>
<pre>&lt;link rel="stylesheet" href="path-to-file/thickbox.css" type="text/css" media="screen" /&gt;</pre>
<p>当然载入CSS的方法多种多样，这只是一个示范。</p>
<h3>使用Thickbox</h3>
<p>关于Thickbox的具体使用，可以参考官方网站的示例：<a href="http://jquery.com/demo/thickbox/#examples">http://jquery.com/demo/thickbox/#examples</a>也可以参考legal翻译的文档。由于原来的链接无法访问，这里只给出原文的存档：<br />
<a href="http://pagetalks.com/talks/wp-content/uploads/2008/03/thickbox/thickbox.html">http://pagetalks.com/talks/wp-content/uploads/2008/03/thickbox/thickbox.html</a></p>
<h3>定制Thickbox</h3>
<p>对于大多数实际使用中，原来的CSS文档设置的样式都无法让人满意（看看连Microsoft的官方网站上的Lightbox都那么炫）。在这里给出Thickbox中CSS档的分析：</p>
<ul>
<li>#TB_overlay：覆盖原文当背景层ID</li>
<li> .TB_overlayBG：背景层的背景元素，也就是背景的实体Class</li>
<li> #TB_window：Thickbox内容窗口的主体ID</li>
<li>#TB_caption：Thickbox内容窗口左下角的标题和导航所在DIV的ID</li>
<li>#TB_closeWindow：右上角“Close”链接所在的元素（不知道是DIV还是Span）的ID</li>
<li>#TB_closeAjaxWindow：Ajax载入窗口中的“Close”链接所在元素（不知道是DIV还是Span）的ID</li>
<li> #TB_ajaxWindowTitle：左上角标题所在元素的ID</li>
<li> #TB_title：Thickbox内容窗口顶端元素（包含标题和“Close”链接的容器）的ID</li>
<li>#TB_ajaxContent：内容容器ID</li>
<li> #TB_load：载入进度条的ID</li>
<li>#TB_iframeContent：iFrame元素ID</li>
</ul>
<p>最近在用Thickbox做ELFVision首页上的作品陈列室“Works”，可以到<a href="http://www.elfvision.com">ELFVision</a>的首页，点击Works链接看看美化过的Thickbox。不过这个是半成品，还有一些想法要通过jQuery的编程实现，慢慢来吧。</p>
]]></content:encoded>
			<wfw:commentRss>http://pagetalks.com/2008/08/29/thickbox-and-its-customization.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
