<?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>权记 &#187; JQuery</title>
	<atom:link href="http://www.quanlei.com/tag/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.quanlei.com</link>
	<description>一个关于我们生活点滴的网站，一个记录我们酸甜苦辣的日志。</description>
	<lastBuildDate>Sun, 06 Jun 2010 01:10:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>[10/22 周主题] – 强悍的JQuery Validate 插件</title>
		<link>http://www.quanlei.com/2010/06/1022-week-subject-jquery-validate-plugin/</link>
		<comments>http://www.quanlei.com/2010/06/1022-week-subject-jquery-validate-plugin/#comments</comments>
		<pubDate>Sun, 06 Jun 2010 01:10:00 +0000</pubDate>
		<dc:creator>小权</dc:creator>
				<category><![CDATA[前端开发]]></category>
		<category><![CDATA[周主题]]></category>
		<category><![CDATA[技术]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Validate]]></category>
		<category><![CDATA[插件]]></category>
		<category><![CDATA[验证]]></category>

		<guid isPermaLink="false">http://www.quanlei.com/?p=1630</guid>
		<description><![CDATA[对于JQuery Validate，只有相见恨晚的感触，恐怕在表单验证领域这是目前我见过最好的插件了，可以很方便的使用，极大的提高表单验证的效率。 下面就介绍下简单的使用方法： 1、下载地址：http://bassistance.de/jquery-plugins/jquery-plugin-validation/，本文章发布时最新版是1.7。 2、在页面里面加载JQuery和JQuery Validate &#60;script type=&#34;text/javascript&#34; src=&#34;theme/default/js/jquery-1.4.2.min.js&#34;&#62;&#60;/script&#62; &#60;script type=&#34;text/javascript&#34; src=&#34;theme/default/js/jquery.validate.min.js&#34;&#62;&#60;/script&#62; 3、写一个表单提交页面，form id 为 login，两个提交域email和password。域提供相应的id。为了完善demo，我在里面也提供了一个注册的form，同时提供了自定义验证方法和ajax提交。 4、在页面或者单独写个js文件，输入如下代码： $().ready(function() { //身份证验证 jQuery.validator.addMethod(&#34;isIdCardNo&#34;, function(value, element) { return this.optional(element) &#124;&#124; isIdCardNo(value); }, &#34;请正确输入您的身份证号码&#34;); // 电话号码验证 jQuery.validator.addMethod(&#34;isPhone&#34;, function(value, element) { var tel = /^(\d{3,4}-?)?\d{7,9}$/g; return this.optional(element) &#124;&#124; (tel.test(value)); }, &#34;请正确填写您的电话号码&#34;); //昵称验证 jQuery.validator.addMethod(&#34;nickName&#34;, function(value, element) { return this.optional(element) &#124;&#124; /^[\u0391-\uFFE5\w]+$/.test(value); [...]]]></description>
			<content:encoded><![CDATA[<p>对于JQuery Validate，只有相见恨晚的感触，恐怕在表单验证领域这是目前我见过最好的插件了，可以很方便的使用，极大的提高表单验证的效率。</p>
<p>下面就介绍下简单的使用方法：</p>
<p>1、下载地址：<a href="http://bassistance.de/jquery-plugins/jquery-plugin-validation/">http://bassistance.de/jquery-plugins/jquery-plugin-validation/</a>，本文章发布时最新版是1.7。</p>
<p>2、在页面里面加载JQuery和JQuery Validate</p>
<pre class="brush: jscript;">
&lt;script type=&quot;text/javascript&quot; src=&quot;theme/default/js/jquery-1.4.2.min.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;theme/default/js/jquery.validate.min.js&quot;&gt;&lt;/script&gt;
</pre>
<p>3、写一个表单提交页面，form id 为 login，两个提交域email和password。域提供相应的id。为了完善demo，我在里面也提供了一个注册的form，同时提供了自定义验证方法和ajax提交。</p>
<p><span id="more-1630"></span></p>
<p>4、在页面或者单独写个js文件，输入如下代码：</p>
<pre class="brush: jscript;">
$().ready(function() {
    //身份证验证
    jQuery.validator.addMethod(&quot;isIdCardNo&quot;, function(value, element) {
        return this.optional(element) || isIdCardNo(value);
    }, &quot;请正确输入您的身份证号码&quot;);
    // 电话号码验证
    jQuery.validator.addMethod(&quot;isPhone&quot;, function(value, element) {
        var tel = /^(\d{3,4}-?)?\d{7,9}$/g;
        return this.optional(element) || (tel.test(value));
    }, &quot;请正确填写您的电话号码&quot;);
    //昵称验证
    jQuery.validator.addMethod(&quot;nickName&quot;, function(value, element) {
        return this.optional(element) || /^[\u0391-\uFFE5\w]+$/.test(value);
    }, &quot;昵称只能由中文，英文字母、数字和下划线组成&quot;);
    //手机验证
    jQuery.validator.addMethod(&quot;isMobile&quot;, function(value, element) {
        var length = value.length;
        var mobile = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/;
        return this.optional(element) || (length == 11 &amp;&amp; mobile.test(value));
    }, &quot;请正确填写您的手机号码&quot;);
    // 邮政编码验证
    jQuery.validator.addMethod(&quot;isZipCode&quot;, function(value, element) {
        var tel = /^[0-9]{6}$/;
        return this.optional(element) || (tel.test(value));
    }, &quot;请正确填写您的邮政编码&quot;);

    $(&quot;#login&quot;).validate({
        //        submitHandler: function() {
        //            $(&quot;#error_tip&quot;).hide();
        //            $.ajax({
        //                data:$(&quot;#login&quot;).serialize(),
        //                // The url you are going to submit to
        //                url: &quot;login.action&quot;,
        //                dataType: 'json',
        //                timeout: 10000,
        //                // Sends a message to the console if it failed for testing purposes.
        //                error: function() {
        //                    $(&quot;#error_tip&quot;).html(&quot;&lt;span&gt;服务器忙，请稍后重试。&lt;/span&gt;&quot;)
        //                },
        //                // If successful you can do something here. You can change elements, update text, or  simply alert the response to first test to see if it worked.
        //                success: function(response) {
        //                        $(&quot;#error_tip&quot;).html(&quot;&lt;span&gt;&quot;+ response.result +&quot;&lt;/span&gt;&quot;)
        //                        $(&quot;#error_tip&quot;).show();
        //                }
        //            });
        //        },
        rules: {
            email: {
                required: true,
                email: true
            },
            password: {
                required: true
            }
        },
        messages: {
            password: {
                required: &quot;请输入密码&quot;
            },
            email: {
                required:&quot;请输入邮件地址&quot;,
                email:&quot;请输入有效的邮件地址&quot;
            }
        }
    });

    $(&quot;#reg&quot;).validate({
        rules: {
            email: {
                required: true,
                email: true,
                remote:&quot;checkEmail.action&quot;
            },
            password: {
                required: true,
                minlength: 6,
                maxlength:12
            },
            confirm_password: {
                required: true,
                minlength: 6,
                equalTo: &quot;#password&quot;
            },
            answer:{
                required: true
            },
            agree: &quot;required&quot;
        },
        messages: {
            password: {
                required: &quot;请输入密码&quot;,
                minlength: &quot;密码长度在6-12个字符之间&quot;,
                maxlength: &quot;密码长度在6-12个字符之间&quot;
            },
            confirm_password: {
                required: &quot;请输入密码&quot;,
                minlength: &quot;密码长度在6-12个字符之间&quot;,
                equalTo: &quot;你输入的密码不一致&quot;
            },
            email: {
                required:&quot;请输入有效的邮件地址&quot;,
                email: &quot;请输入有效的邮件地址&quot;,
                remote: &quot;邮件地址已存在&quot;
            },
            answer:&quot;请输入安全问题答案&quot;,
            agree: &quot;请接受我们的条款&quot;
        }
    });
}
</pre>
<p>上面的代码基本上包含了大部分JQuery Validate的使用功能：</p>
<blockquote><p>1、基本验证</p>
<p>2、自定义验证 &#8211; 自定义验证跟其他官方的验证类似，加入rules即可，message上面已经定义，可以不加。</p>
<p>3、页面ajax提交。</p>
<p>4、ajax验证Emai帐户是否可用，需要注意的是remote仅支持返回true和false，也就是checkEmail.php只能返回true和false代表Email是否可用
</p></blockquote>
<p>更多Demo，请查看JQuery Validate的官方文档，很好理解：<br />
1、<a href="http://docs.jquery.com/Plugins/Validation">http://docs.jquery.com/Plugins/Validation</a><br />
2、<a href="http://jquery.bassistance.de/validate/demo/">http://jquery.bassistance.de/validate/demo/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.quanlei.com/2010/06/1022-week-subject-jquery-validate-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>为不同大小的浏览器视窗使用不同的样式表</title>
		<link>http://www.quanlei.com/2010/04/different-stylesheets-for-differently-sized-browser-windows/</link>
		<comments>http://www.quanlei.com/2010/04/different-stylesheets-for-differently-sized-browser-windows/#comments</comments>
		<pubDate>Sat, 24 Apr 2010 11:26:12 +0000</pubDate>
		<dc:creator>小权</dc:creator>
				<category><![CDATA[前端开发]]></category>
		<category><![CDATA[技术]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[浏览器]]></category>

		<guid isPermaLink="false">http://www.quanlei.com/?p=1473</guid>
		<description><![CDATA[同一个网站，访问它的浏览器可能会是不同的宽度，常见的有320px，480px，800px，1024px，1280px，1920px等，为不同大小的浏览器视窗提供不同的访问效果，提高用户的使用体验，同时网站本身也可以为不同受众提供不同的资源。 下面提供两种解决方案： 一、通过 W3C standard 来定义，例如： &#60;link rel=&#34;stylesheet&#34; media=&#34;screen and (min-device-width: 800px)&#34; href=&#34;800.css&#34; /&#62; 上面的代码表示：当访问网站的设备浏览器宽度大于等于800px时，将使用800.css这个样式。 又如： &#60;link rel='stylesheet' media='screen and (min-width: 701px) and (max-width: 900px)' href='css/medium.css' /&#62; 上面的代码表示：当访问网站的设备浏览器宽度在701px和900px之间时，将使用medium.css这个样式。 目前Mozilla， Opera和WebKit等浏览器的当前版本都支持这个标准，不幸的是IE浏览器并不支持此标准，包括IE8，以及IE9 Previous。 不要着急，方案二将解决此问题。 二、通过JQuery来动态调整页面样式 1、首先定义两个link，当然你也可以是一个，第二个是要更改的css &#60;link rel=&#34;stylesheet&#34; type=&#34;text/css&#34; href=&#34;main.css&#34; /&#62; &#60;link id=&#34;size-stylesheet&#34; rel=&#34;stylesheet&#34; type=&#34;text/css&#34; href=&#34;narrow.css&#34; /&#62; 2、下面的JavaScript代码将根据不同的浏览器大小，更改css unction adjustStyle(width) { width = parseInt(width); if (width &#60; [...]]]></description>
			<content:encoded><![CDATA[<p>同一个网站，访问它的浏览器可能会是不同的宽度，常见的有320px，480px，800px，1024px，1280px，1920px等，为不同大小的浏览器视窗提供不同的访问效果，提高用户的使用体验，同时网站本身也可以为不同受众提供不同的资源。</p>
<p><a href="http://www.quanlei.com/wp-content/uploads/2010/04/resolutiondeplayouts.jpg"><img class="aligncenter size-full wp-image-1474" title="resolutiondeplayouts" src="http://www.quanlei.com/wp-content/uploads/2010/04/resolutiondeplayouts.jpg" alt="" width="570" height="533" /></a></p>
<p>下面提供两种解决方案：</p>
<p>一、通过 <a href="http://www.w3.org/TR/css3-mediaqueries/">W3C standard</a> 来定义，例如：</p>
<pre class="brush: xml;">
&lt;link rel=&quot;stylesheet&quot; media=&quot;screen and (min-device-width: 800px)&quot; href=&quot;800.css&quot; /&gt;
</pre>
<p>上面的代码表示：当访问网站的设备浏览器宽度大于等于800px时，将使用800.css这个样式。</p>
<p>又如：</p>
<pre class="brush: xml;">
&lt;link rel='stylesheet' media='screen and (min-width: 701px) and (max-width: 900px)' href='css/medium.css' /&gt;
</pre>
<p>上面的代码表示：当访问网站的设备浏览器宽度在701px和900px之间时，将使用medium.css这个样式。</p>
<p>目前Mozilla， Opera和WebKit等浏览器的当前版本都支持这个标准，不幸的是IE浏览器并不支持此标准，包括IE8，以及IE9 Previous。</p>
<p>不要着急，方案二将解决此问题。</p>
<p><span id="more-1473"></span></p>
<p>二、通过JQuery来动态调整页面样式<br />
1、首先定义两个link，当然你也可以是一个，第二个是要更改的css</p>
<pre class="brush: xml;">
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;main.css&quot; /&gt;
&lt;link id=&quot;size-stylesheet&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;narrow.css&quot; /&gt;
</pre>
<p>2、下面的JavaScript代码将根据不同的浏览器大小，更改css</p>
<pre class="brush: jscript;">
unction adjustStyle(width) {
    width = parseInt(width);
    if (width &lt; 701) {
        $(&quot;#size-stylesheet&quot;).attr(&quot;href&quot;, &quot;css/narrow.css&quot;);
    } else if ((width &gt;= 701) &amp;&amp; (width &lt; 900)) {
        $(&quot;#size-stylesheet&quot;).attr(&quot;href&quot;, &quot;css/medium.css&quot;);
    } else {
       $(&quot;#size-stylesheet&quot;).attr(&quot;href&quot;, &quot;css/wide.css&quot;);
    }
}

$(function() {
    adjustStyle($(this).width());
    $(window).resize(function() {
        adjustStyle($(this).width());
    });
});
</pre>
<p>查看例子：</p>
<div class="demobtns"><a href="http://css-tricks.com/examples/ResolutionDependantLayout/example-one.php">例子1</a> <a href="http://css-tricks.com/examples/ResolutionDependantLayout/example-two.php">例子2</a> <a href="http://css-tricks.com/examples/ResolutionDependantLayout/example-three.php">例子3</a> <a href="http://css-tricks.com/examples/ResolutionDependantLayout.zip">下载所有例子</a></div>
<p>英文原址：http://css-tricks.com/resolution-specific-stylesheets/</p>
]]></content:encoded>
			<wfw:commentRss>http://www.quanlei.com/2010/04/different-stylesheets-for-differently-sized-browser-windows/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>老虎机式标签栏(Slot Machine Tabs)</title>
		<link>http://www.quanlei.com/2010/04/slot-machine-tabs/</link>
		<comments>http://www.quanlei.com/2010/04/slot-machine-tabs/#comments</comments>
		<pubDate>Thu, 22 Apr 2010 08:20:44 +0000</pubDate>
		<dc:creator>小权</dc:creator>
				<category><![CDATA[前端开发]]></category>
		<category><![CDATA[技术]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[tab]]></category>
		<category><![CDATA[标签]]></category>

		<guid isPermaLink="false">http://www.quanlei.com/?p=1383</guid>
		<description><![CDATA[玩过老虎机或者看过老虎机的朋友，对这个标签的运行轨迹将会相当熟悉了。 还是先看demo吧， Demo1 Demo2 大体看了下JS文件， 主要使用了JQuery的animate方法，让标签1，标签2，标签3被点击时，获取不同的随机速率。 原文地址：http://css-tricks.com/slot-machine-tabs/ 没有深入研究，仅仅记录下来，以备后用。]]></description>
			<content:encoded><![CDATA[<p>玩过老虎机或者看过老虎机的朋友，对这个标签的运行轨迹将会相当熟悉了。</p>
<p>还是先看demo吧，</p>
<div class="demobtns">
 <a href="http://fluxiom.com/features/ " target="_blank">Demo1</a> <a href="http://css-tricks.com/examples/SlotMachineTabs/" target="_blank">Demo2</a>
</div>
<p><a href="http://www.quanlei.com/wp-content/uploads/2010/04/slotmachinetabsexample.jpg"><img src="http://www.quanlei.com/wp-content/uploads/2010/04/slotmachinetabsexample.jpg" alt="" title="slotmachinetabsexample" width="570" height="266" class="aligncenter size-full wp-image-1387" /></a></p>
<p>大体看了下JS文件， 主要使用了JQuery的animate方法，让标签1，标签2，标签3被点击时，获取不同的随机速率。</p>
<p>原文地址：http://css-tricks.com/slot-machine-tabs/</p>
<p>没有深入研究，仅仅记录下来，以备后用。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.quanlei.com/2010/04/slot-machine-tabs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[10/08周主题] – JQuery分页导航条插件</title>
		<link>http://www.quanlei.com/2010/03/1008-week-subject-%e2%80%93-page-navigator/</link>
		<comments>http://www.quanlei.com/2010/03/1008-week-subject-%e2%80%93-page-navigator/#comments</comments>
		<pubDate>Tue, 09 Mar 2010 07:48:14 +0000</pubDate>
		<dc:creator>小权</dc:creator>
				<category><![CDATA[前端开发]]></category>
		<category><![CDATA[周主题]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[分页导航]]></category>
		<category><![CDATA[插件]]></category>

		<guid isPermaLink="false">http://www.quanlei.com/?p=1270</guid>
		<description><![CDATA[之前在写 [10/02周主题] – 仿Gmail头像上传剪辑 时说，还有个JQuery的分页组件分享给大家，这个组件是别人设计的，我只是在其基础上，进行一些改动，以符合自身项目的需求。 之前在做Web项目时，分页功能的处理是放在服务器端，客户端只是用来显示分页导航条内容。 虽然将服务器端的分页功能进行封装，页码显示代码也进行了整理，但是总归不是很方便，做分页功能还是要做不少工作。 后来去看一些将分页功能放在客户端处理的例子，最后发现了这个比较不错的JQuery组件（如果你有好的方案也欢迎分享啊），原文章在这里：http://lym6520.javaeye.com/blog/540580，我就不做过多介绍了。 通过这个组件做分页功能，服务器端几乎不做什么处理，只需要显示数据列表时把总数传给该组件即可。至于分页组件的样式你完全可以自己去定制。 下面分享下自己的一些优化工作： 1、Loading和错误提示 Loading和错误信息的显示在获取数据时控制，这里用到了Ajax的几个状态来判断，比如beforeSend，success以及error。 2、分页组件的翻页和获取数据是异步的，这样如果出现服务器问题，无法获取翻页后的信息，但是分页导航条已经做了翻页了。由于服务器出错是在Ajax里面捕获的，这样就只能做个hack，通过dom操作来让翻页返回去，最终的效果会是这样的：假如现在在第三页，要跳转到第四页，点 “4” 翻页了，然后发现翻页后无法获取数据，出现服务器问题了，接着就又返回第三页了，显示错误信息。]]></description>
			<content:encoded><![CDATA[<p>之前在写 <a title="Permanent Link to [10/02周主题] – 仿Gmail头像上传剪辑" rel="bookmark" href="../2010/01/1002-week-subject-gmail-icon-cutter/">[10/02周主题] – 仿Gmail头像上传剪辑</a> 时说，还有个JQuery的分页组件分享给大家，这个组件是别人设计的，我只是在其基础上，进行一些改动，以符合自身项目的需求。</p>
<p>之前在做Web项目时，分页功能的处理是放在服务器端，客户端只是用来显示分页导航条内容。 虽然将服务器端的分页功能进行封装，页码显示代码也进行了整理，但是总归不是很方便，做分页功能还是要做不少工作。</p>
<p>后来去看一些将分页功能放在客户端处理的例子，最后发现了这个比较不错的JQuery组件（如果你有好的方案也欢迎分享啊），原文章在这里：http://lym6520.javaeye.com/blog/540580，我就不做过多介绍了。</p>
<p>通过这个组件做分页功能，服务器端几乎不做什么处理，只需要显示数据列表时把总数传给该组件即可。至于分页组件的样式你完全可以自己去定制。</p>
<p>下面分享下自己的一些优化工作：</p>
<p>1、Loading和错误提示</p>
<p><a href="http://www.quanlei.com/wp-content/uploads/2010/03/page-loading.png"><img class="size-full wp-image-1272 alignnone" title="page-loading" src="http://www.quanlei.com/wp-content/uploads/2010/03/page-loading.png" alt="" width="485" height="53" /></a></p>
<p><a href="http://www.quanlei.com/wp-content/uploads/2010/03/page-error.png"><img class="size-full wp-image-1273 alignnone" title="page-error" src="http://www.quanlei.com/wp-content/uploads/2010/03/page-error.png" alt="" width="565" height="44" /></a></p>
<p>Loading和错误信息的显示在获取数据时控制，这里用到了Ajax的几个状态来判断，比如beforeSend，success以及error。</p>
<p>2、分页组件的翻页和获取数据是异步的，这样如果出现服务器问题，无法获取翻页后的信息，但是分页导航条已经做了翻页了。由于服务器出错是在Ajax里面捕获的，这样就只能做个hack，通过dom操作来让翻页返回去，最终的效果会是这样的：假如现在在第三页，要跳转到第四页，点 “4” 翻页了，然后发现翻页后无法获取数据，出现服务器问题了，接着就又返回第三页了，显示错误信息。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.quanlei.com/2010/03/1008-week-subject-%e2%80%93-page-navigator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[10/02周主题] – 仿Gmail头像上传剪辑</title>
		<link>http://www.quanlei.com/2010/01/1002-week-subject-gmail-icon-cutter/</link>
		<comments>http://www.quanlei.com/2010/01/1002-week-subject-gmail-icon-cutter/#comments</comments>
		<pubDate>Fri, 15 Jan 2010 10:20:10 +0000</pubDate>
		<dc:creator>小权</dc:creator>
				<category><![CDATA[前端开发]]></category>
		<category><![CDATA[周主题]]></category>
		<category><![CDATA[Gmail]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[上传]]></category>
		<category><![CDATA[剪辑]]></category>
		<category><![CDATA[剪辑，剪裁， JCrop]]></category>

		<guid isPermaLink="false">http://www.quanlei.com/?p=1180</guid>
		<description><![CDATA[本周关注比较多的是JQuery部分，优化了一个分页组件，实现了一个仿Gmail头像上传并剪辑的功能。 分页组件稍后有时间可以分享一下，今天分享下仿Gmail头像上传剪辑的功能。 本周主题：仿Gmail头像上传剪辑 这个功能是参考了Gmail的头像上传功能，并参照其流程实现的，因此叫仿Gmail头像上传剪辑，建议想用类似功能的朋友先看看Gmail的头像上传流程。 使用到的工具： 1、JQuery 2、Jquery.Form.JS (JQuery的一个form插件)，这里主要是在层里面用到它的ajaxSubmit功能。 3、JCrop（JQuery头像剪辑插件），之前有篇博文讲到。 场景，思路和做法： 1、比如更新用户信息时，要更新用户的头像，这里只是更新头像地址，而不是在更新用户信息页面时上传头像，头像上传和剪辑的处理交给其他组件完成，比如这个上传剪辑功能。 2、给一个链接，比如叫“上传照片”， 如下图： 点击该链接会弹出一个层， 如下图： 3、头像上传的事情在这个层内完成，先上传到系统的temp目录，因为这个图片最后是要删除的，JCrop 剪辑后的图片才是真正想要的。 4、将图片上传完后，进行同比例的显示缩放(注意我这里叫显示缩放，而不是真正的缩放，即仅在该层内等比例显示下即可，当然你也可以不显示缩放，结果是图片巨大个，显示不下或者出现滚动条)，显示在该页面，然后加载JCrop插件，进行图片剪辑处理（这里为了简单，没有放像Gmail那样的预览小图，需要的朋友可以参照JCrop加上），如下图： 5、点击“应用更改”时，将在服务器上进行原图片的剪辑工作，JCrop需要的是剪辑框的x,y,w,h四个参数，但是剪辑是在原图片上进行的，因此此处的x,y,w,h需要做映射，将缩略后的x,y,w,h映射到原图片的x,y,w,h上，新图片剪辑后保存到你的头像目录，最后别忘记删除temp文件夹下的图片。如下图效果： 总结： 此功能的实现上没有什么新颖的东西，主要是将几个插件的使用揉合在一块，然后形成一个用起来比较顺手的功能，实现过程可能稍感麻烦，但是最终的效果还是不错！]]></description>
			<content:encoded><![CDATA[<p>本周关注比较多的是JQuery部分，优化了一个分页组件，实现了一个仿Gmail头像上传并剪辑的功能。</p>
<p>分页组件稍后有时间可以分享一下，今天分享下仿Gmail头像上传剪辑的功能。</p>
<h1>本周主题：仿Gmail头像上传剪辑</h1>
<p>这个功能是参考了Gmail的头像上传功能，并参照其流程实现的，因此叫仿Gmail头像上传剪辑，建议想用类似功能的朋友先看看Gmail的头像上传流程。</p>
<h3>使用到的工具：</h3>
<p>1、JQuery</p>
<p>2、Jquery.Form.JS (JQuery的一个form插件)，这里主要是在层里面用到它的ajaxSubmit功能。</p>
<p>3、JCrop（JQuery头像剪辑插件），之前有篇博文讲到。</p>
<h3>场景，思路和做法：</h3>
<p>1、比如更新用户信息时，要更新用户的头像，这里只是更新头像地址，而不是在更新用户信息页面时上传头像，头像上传和剪辑的处理交给其他组件完成，比如这个上传剪辑功能。</p>
<p>2、给一个链接，比如叫“上传照片”， 如下图：</p>
<p><a href="http://www.quanlei.com/wp-content/uploads/2010/01/screenshot_007.png"><img class="aligncenter size-full wp-image-1190" title="screenshot_007" src="http://www.quanlei.com/wp-content/uploads/2010/01/screenshot_007.png" alt="" width="227" height="39" /></a></p>
<p>点击该链接会弹出一个层， 如下图：</p>
<p><a href="http://www.quanlei.com/wp-content/uploads/2010/01/screenshot_004.png"><img class="aligncenter size-full wp-image-1185" title="screenshot_004" src="http://www.quanlei.com/wp-content/uploads/2010/01/screenshot_004.png" alt="" width="452" height="454" /></a></p>
<p>3、头像上传的事情在这个层内完成，先上传到系统的temp目录，因为这个图片最后是要删除的，JCrop 剪辑后的图片才是真正想要的。</p>
<p>4、将图片上传完后，进行同比例的显示缩放(注意我这里叫显示缩放，而不是真正的缩放，即仅在该层内等比例显示下即可，当然你也可以不显示缩放，结果是图片巨大个，显示不下或者出现滚动条)，显示在该页面，然后加载JCrop插件，进行图片剪辑处理（这里为了简单，没有放像Gmail那样的预览小图，需要的朋友可以参照JCrop加上），如下图：</p>
<p><a href="http://www.quanlei.com/wp-content/uploads/2010/01/screenshot_005.png"><img class="aligncenter size-full wp-image-1186" title="screenshot_005" src="http://www.quanlei.com/wp-content/uploads/2010/01/screenshot_005.png" alt="" width="452" height="452" /></a></p>
<p>5、点击“应用更改”时，将在服务器上进行原图片的剪辑工作，JCrop需要的是剪辑框的x,y,w,h四个参数，但是剪辑是在原图片上进行的，因此此处的x,y,w,h需要做映射，将缩略后的x,y,w,h映射到原图片的x,y,w,h上，新图片剪辑后保存到你的头像目录，最后别忘记删除temp文件夹下的图片。如下图效果：</p>
<p><a href="http://www.quanlei.com/wp-content/uploads/2010/01/screenshot_006.png"><img class="aligncenter size-full wp-image-1188" title="screenshot_006" src="http://www.quanlei.com/wp-content/uploads/2010/01/screenshot_006.png" alt="" width="293" height="201" /></a></p>
<h3>总结：</h3>
<p>此功能的实现上没有什么新颖的东西，主要是将几个插件的使用揉合在一块，然后形成一个用起来比较顺手的功能，实现过程可能稍感麻烦，但是最终的效果还是不错！</p>
]]></content:encoded>
			<wfw:commentRss>http://www.quanlei.com/2010/01/1002-week-subject-gmail-icon-cutter/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>jQuery图像剪裁插件 &#8211; Jcrop</title>
		<link>http://www.quanlei.com/2010/01/jquery-plugh-jcrop/</link>
		<comments>http://www.quanlei.com/2010/01/jquery-plugh-jcrop/#comments</comments>
		<pubDate>Thu, 07 Jan 2010 01:40:00 +0000</pubDate>
		<dc:creator>小权</dc:creator>
				<category><![CDATA[前端开发]]></category>
		<category><![CDATA[技术]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[剪辑，剪裁， JCrop]]></category>

		<guid isPermaLink="false">http://www.quanlei.com/?p=1145</guid>
		<description><![CDATA[由于项目需要，需要进行图像剪裁，网上找到这个JQuery的插件，蛮好用的，记录一下。 强烈建议使用前，先去官网看看Demo：http://deepliquid.com/projects/Jcrop/demos.php 实现的流程大体如下： 通过JCrop获取剪辑框的位置x, y 和 剪辑框的大小 w , h。 将图片和剪辑框的四个参数传到服务器端，由服务器完成图片的剪辑工作。 保存剪辑好的图片。 具体使用方法，看官网的手册，简单易懂：http://deepliquid.com/content/Jcrop_Manual.html]]></description>
			<content:encoded><![CDATA[<p>由于项目需要，需要进行图像剪裁，网上找到这个JQuery的插件，蛮好用的，记录一下。</p>
<p style="text-align: center;"><img class="aligncenter" src="http://deepliquid.com/img/banner/jcrop.png" alt="" width="453" height="89" /></p>
<p style="text-align: left;">强烈建议使用前，先去官网看看Demo：<span style="color: #000000;"><a href="http://deepliquid.com/projects/Jcrop/demos.php">http://deepliquid.com/projects/Jcrop/demos.php</a></span></p>
<p style="text-align: left;"><span style="color: #000000;">实现的流程大体如下：</span></p>
<ol>
<li><span style="color: #000000;">通过JCrop获取剪辑框的位置x, y 和 剪辑框的大小 w , h。</span></li>
<li><span style="color: #000000;">将图片和剪辑框的四个参数传到服务器端，由服务器完成图片的剪辑工作。</span></li>
<li><span style="color: #000000;">保存剪辑好的图片。</span></li>
</ol>
<p>具体使用方法，看官网的手册，简单易懂：<a href="http://deepliquid.com/content/Jcrop_Manual.html">http://deepliquid.com/content/Jcrop_Manual.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.quanlei.com/2010/01/jquery-plugh-jcrop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[09/50周主题] – JQuery入门</title>
		<link>http://www.quanlei.com/2009/12/0950-week-subject-jquery/</link>
		<comments>http://www.quanlei.com/2009/12/0950-week-subject-jquery/#comments</comments>
		<pubDate>Wed, 16 Dec 2009 14:54:17 +0000</pubDate>
		<dc:creator>小权</dc:creator>
				<category><![CDATA[前端开发]]></category>
		<category><![CDATA[周主题]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[Dom]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[事件]]></category>
		<category><![CDATA[对象]]></category>
		<category><![CDATA[类]]></category>

		<guid isPermaLink="false">http://www.quanlei.com/?p=1073</guid>
		<description><![CDATA[周三赶鸭子上架的组织了一次JQuery入门培训，由于时间上的原因，自己没做Demo，拿官方现成的，主要是认识JQuery，了解JQuery核心函数，介绍一些常用的选择器，还有事件处理，以及Ajax的使用，这里简单分享下： 本周主题：JQuery 一、JQuery核心认识 $ 表示JQuery类，$(&#8230;) 构造一个JQuery类，这里的JQuery类是一个集合数组对象，而非Dom对象。 jQuery(expression,[context]) $(&#34;div &#62; p&#34;); $(&#34;input:radio&#34;, document.forms[0]); $(&#34;div&#34;, xml.responseXML); jQuery( html ) $(&#34;&#60;div&#62;Hello&#60;/div&#62;&#34;).appendTo(&#34;body&#34;); 主要用来加载html jQuery( elements ) $(document.body).css(&#34;background-color&#34;, &#34;black&#34;); $(myForm.elements).hide(); jQuery( callback ) $(function(){ alert('hello'); }); JQuey中执行方法是在页面加载结束后，官方解释是：A shorthand for $(document).ready(). 二、JQuery选择器 JQuery选择器是JQuery的一大亮点，快捷，高效的遍历整个HTML文档，常用的如下面几种： $(&#34;#id&#34;); $(&#34;div&#34;); $(&#34;.className&#34;); $(&#34;div,span,p.myClass&#34;) $(&#34;form input&#34;) $(&#34;form &#62; input&#34;) 强烈建议直接看官方文档：http://docs.jquery.com/Selectors 三、JQuery事件 $(&#34;p&#34;).bind(&#34;click&#34;, function(e){}); $(&#34;p&#34;).click(function() {}) trigger( event, data [...]]]></description>
			<content:encoded><![CDATA[<p><span style="color: #800000;"><span style="font-size: xx-large;">周</span></span>三赶鸭子上架的组织了一次JQuery入门培训，由于时间上的原因，自己没做Demo，拿官方现成的，主要是认识JQuery，了解JQuery核心函数，介绍一些常用的选择器，还有事件处理，以及Ajax的使用，这里简单分享下：</p>
<h2>本周主题：JQuery</h2>
<h3>一、JQuery核心认识</h3>
<blockquote><p>$ 表示JQuery类，$(&#8230;) 构造一个JQuery类，这里的JQuery类是一个集合数组对象，而非Dom对象。</p>
<h4>jQuery(expression,[context])</h4>
<blockquote><pre class="brush: xml;">
$(&quot;div &gt; p&quot;);
$(&quot;input:radio&quot;, document.forms[0]);
$(&quot;div&quot;, xml.responseXML);
</pre>
</blockquote>
<h4>jQuery( html )</h4>
<blockquote><pre class="brush: xml;">
$(&quot;&lt;div&gt;Hello&lt;/div&gt;&quot;).appendTo(&quot;body&quot;);
</pre>
<p>主要用来加载html</p></blockquote>
<h4>jQuery( elements )</h4>
<blockquote><pre class="brush: xml;">
$(document.body).css(&quot;background-color&quot;, &quot;black&quot;);
$(myForm.elements).hide();
</pre>
</blockquote>
<h4>jQuery( callback )</h4>
<blockquote><pre class="brush: xml;">
$(function(){
  alert('hello');
});
</pre>
<p>JQuey中执行方法是在页面加载结束后，官方解释是：A shorthand for $(document).ready().</p></blockquote>
</blockquote>
<h3>二、JQuery选择器</h3>
<blockquote><p>JQuery选择器是JQuery的一大亮点，快捷，高效的遍历整个HTML文档，常用的如下面几种：</p>
<pre class="brush: xml;">
$(&quot;#id&quot;);
$(&quot;div&quot;);
$(&quot;.className&quot;);
$(&quot;div,span,p.myClass&quot;)
$(&quot;form input&quot;)
$(&quot;form &gt; input&quot;)
</pre>
<p>强烈建议直接看官方文档：<a href="http://docs.jquery.com/Selectors ">http://docs.jquery.com/Selectors</a></p></blockquote>
<h3>三、JQuery事件</h3>
<blockquote><pre class="brush: xml;">
$(&quot;p&quot;).bind(&quot;click&quot;, function(e){});
$(&quot;p&quot;).click(function() {})
trigger( event, data ) //触发事件
triggerHandler( event, data ) //触发事件，但不触发浏览器的默认事件
$(&quot;p&quot;).live(&quot;click&quot;, function(){ //在p以及p的下面的子elements上都加上click事件
      $(this).after(&quot;&lt;p&gt;Another paragraph!&lt;/p&gt;&quot;);
});
</pre>
<p>更多，参见官方文档：<a href="http://docs.jquery.com/Events">http://docs.jquery.com/Events</a></p></blockquote>
<h3>四、JQuery Ajax</h3>
<blockquote><p>ajax这块感觉和其他框架没多少差别，用起来基本类似：<br />
1、$.post(&#8230;) 和 $.get(&#8230;)</p>
<blockquote><pre class="brush: jscript;">
$.post('save.cgi', {
    text: 'my string',
    number: 23
}, function() {
    alert('Your data has been saved.');
});
</pre>
</blockquote>
<p>2、$.ajax(&#8230;)</p>
<blockquote><pre class="brush: jscript;">
$.ajax({
    url: 'getdata.action',
    type: 'GET',
    dataType: 'html',
    Timeout: 1000,
    beforeSend: function(){
     // Handle the beforeSend event
   },
    success: function(html){
     // do something with html
   },
    complete: function(){
     // Handle the complete event
   },
    error: function(){
     alert('Error loading HTML document');
    },
});
</pre>
</blockquote>
</blockquote>
<h3>五、推荐阅读</h3>
<blockquote><p>
1、<a href="http://jquery.com/">http://jquery.com/</a><br />
2、<a href="http://jquery-api-zh-cn.googlecode.com/svn/trunk/index.html">jQuery 1.3 API 中文参考文档</a><br />
3、<a href="http://jqueryui.com/">http://jqueryui.com/</a><br />
4、<a href="http://jquery.org.cn/">http://jquery.org.cn/</a><br />
5、<a href="http://www.cnblogs.com/QLeelulu/archive/2008/04/21/1163021.html">有关Ajax的一个中文文章</a>
</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.quanlei.com/2009/12/0950-week-subject-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
