<?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://blog.zhourunsheng.com/tag/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.zhourunsheng.com</link>
	<description>天空一朵雨做的云</description>
	<lastBuildDate>Sat, 08 May 2021 05:17:21 +0000</lastBuildDate>
	<language>zh-CN</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.1.41</generator>
	<item>
		<title>利用 jQuery Mobile 制作 wordpress 手机主题</title>
		<link>http://blog.zhourunsheng.com/2012/03/%e5%88%a9%e7%94%a8-jquery-mobile-%e5%88%b6%e4%bd%9c-wordpress-%e6%89%8b%e6%9c%ba%e4%b8%bb%e9%a2%98/</link>
		<comments>http://blog.zhourunsheng.com/2012/03/%e5%88%a9%e7%94%a8-jquery-mobile-%e5%88%b6%e4%bd%9c-wordpress-%e6%89%8b%e6%9c%ba%e4%b8%bb%e9%a2%98/#comments</comments>
		<pubDate>Tue, 06 Mar 2012 13:59:46 +0000</pubDate>
		<dc:creator><![CDATA[润物无声]]></dc:creator>
				<category><![CDATA[Web设计]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://blog.zhourunsheng.com/?p=1338</guid>
		<description><![CDATA[<p>jQuery Mobile 作为一款十分优秀的 Javascript 开发框架，可以用来方便的开发面向手持设备 [&#8230;]</p>
<p><a rel="nofollow" href="http://blog.zhourunsheng.com/2012/03/%e5%88%a9%e7%94%a8-jquery-mobile-%e5%88%b6%e4%bd%9c-wordpress-%e6%89%8b%e6%9c%ba%e4%b8%bb%e9%a2%98/">利用 jQuery Mobile 制作 wordpress 手机主题</a>，首发于<a rel="nofollow" href="http://blog.zhourunsheng.com">润物无声</a>。</p>
]]></description>
				<content:encoded><![CDATA[<p><a href="http://jquerymobile.com/">jQuery Mobile</a> 作为一款十分优秀的 Javascript 开发框架，可以用来方便的开发面向手持设备的网站和Web APP。</p>
<p>本文就带领大家使用 jQuery Mobile 来制作一款 wordpress 的手机主题。</p>
<p>示例代码演示效果如下</p>
<p><img src="http://blog.zhourunsheng.com/wp-content/uploads/2012/05/01.jpg" alt="jquery-mobile-wordpress-theme" width="386" height="500" /></p>
<p><span id="more-1338"></span></p>
<h3>主题制作步骤</h3>
<p><strong>1.</strong> 我们可以从头开始来制作一款主题，不过为了节省制作主题的时间，示例代码是通过客制化另外一款主题来实现的，首先需要下载一款 <a href="http://digwp.com/2010/02/blank-wordpress-theme/">BLANK-Theme</a> 的 wordpress 主题，该主题除了样式 style 没有定义以外，其他的功能都基本已经实现了，通过修改文件 <span style="background-color: #ff00ff;">style.css</span>，您可以修改该主题的名字，也可以客制化该主题的样式。</p>
<p><strong>2.</strong> 修改 Header 和 Footer</p>
<p>既然要制作手机主题，首先需要引用 jQuery 和 jQuery Mobile 开发库，您可以把这些开发库下载到自己的Server上，也可以利用JQuery的CDN Server，推荐利用CDN加速，这些库的加载速度会快很多，同时也可以为您的服务器节省流量。</p>
<p>修改 <span style="background-color: #ff00ff;">header.php</span> 文件， 在&lt;head&gt; 和&lt;/head&gt; 的标签中添加如下代码：</p>
<pre>&lt;link rel="stylesheet" href="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.css" /&gt;
&lt;script src="http://code.jquery.com/jquery-1.7.1.min.js"&gt;&lt;/script&gt;
&lt;script src="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.js"&gt;&lt;/script&gt;</pre>
<p>因为 jQuery Mobile 使用 HTML5, 我们需要修改 doctype。更新 Header 如下:</p>
<pre>&lt;!DOCTYPE html&gt;
&lt;html &lt;?php language_attributes(); ?&gt;&gt;
&lt;head&gt;</pre>
<p>接下来，替换从 &lt;body &lt;?php body_class(); ?&gt;&gt; 标签开始的全部内容如下：</p>
<pre>&lt;body &lt;?php body_class(); ?&gt;&gt;
&lt;div data-role="page" data-theme="b" id="jqm-home"&gt;
&lt;div data-role="header"&gt;
&lt;h1&gt;&lt;?php bloginfo('name'); ?&gt;&lt;/h1&gt;
&lt;/div&gt;

&lt;div data-role="content"&gt;</pre>
<p>然后开始修改 <span style="background-color: #ff00ff;">footer.php</span> 文件，替换为如下内容：</p>
<pre>&lt;/div&gt;&lt;!-- data role content--&gt;

&lt;div data-role="footer" class="ui-bar"&gt;
&lt;a href="#jqm-home" data-role="button" data-icon="arrow-u"&gt;Up&lt;/a&gt;&lt;/div&gt;
&lt;?php wp_footer(); ?&gt;
&lt;/div&gt;&lt;!-- data role content--&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<p><strong>3.</strong> 更新主页 homepage</p>
<p>设计手机主题的目标就是要求简洁，所以我们将用列表来展示最新发布的博文。</p>
<p>修改文件 <span style="background-color: #ff00ff;">index.php</span>中 loop 循环的内容如下：</p>
<pre>&lt;ul data-role="listview" data-inset="true" data-theme="c" data-dividertheme="b"&gt;
&lt;?php if (have_posts()) : while (have_posts()) : the_post(); ?&gt;
&lt;li&gt;&lt;a href="&lt;?php the_permalink() ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/li&gt;
&lt;?php endwhile;endif ?&gt;
&lt;/ul&gt;
&lt;?php include (TEMPLATEPATH . '/inc/nav.php' ); ?&gt;</pre>
<p>按照同样的方法修改 <span style="background-color: #ff00ff;">search.php</span> 和 <span style="background-color: #ff00ff;">archive.php</span>。</p>
<p><strong>4.</strong> 更新 Post 和 pages 文件</p>
<p>为了提高手持设备的用户体验，我们默认将评论列表窗口收缩，以节省屏幕空间，只有当用户需要查看评论的时候，才会点击展开，修改方法如下，更新文件 <span style="background-color: #ff00ff;">comments.php</span>：</p>
<pre>&lt;?php if ( have_comments() ) : ?&gt;

&lt;span style="color: #3068ff;"&gt;&lt;div data-role="collapsible" data-state="collapsed"&gt;&lt;/span&gt;

... ...

&lt;span style="color: #3068ff;"&gt;&lt;/div&gt;&lt;/span&gt;

&lt;?php else : // this is displayed if there are no comments so far ?&gt;</pre>
<p><strong>5.</strong> 更新搜索表单文件</p>
<p>更新 <span style="background-color: #ff00ff;">searchform.php</span> 文件，替换为如下内容：</p>
<pre>&lt;form action="&lt;?php bloginfo('siteurl'); ?&gt;" id="searchform" method="get"&gt;
&lt;div data-role="fieldcontain"&gt;
&lt;input type="search" name="s" id="search" value="" /&gt;
&lt;/div&gt;
&lt;/form&gt;</pre>
<p>为了将搜索 Bar 加入到主界面中，您需要修改 <span style="background-color: #ff00ff;">index.php</span> 文件，在 get_header() 函数之后加入如下代码：</p>
<pre>&lt;?php include('searchform.php'); ?&gt;</pre>
<p><strong>6.</strong> 样式修正</p>
<p>主页面中您可能会发现，搜索框的宽度没有文章列表的宽度长，看起来不太美观，解决的方法比较简单，修改 <span style="background-color: #ff00ff;">style.css</span> 文件，加入样式定义：</p>
<pre>.ui-input-search{
width:88% !important;
}</pre>
<p><strong>7.</strong> 去掉 sidebar</p>
<p>更新 <span style="background-color: #ff00ff;">sidebar.php</span> 文件，将输出都注释掉，方法如下：</p>
<pre>&lt;!-- sidebar的内容--&gt;</pre>
<h3>总结</h3>
<p>通过本文的整体流程，相信您已经学会了怎么样来制作一款 wordpress 手机主题了，接下来发挥您的想法，尽力去完善吧！</p>
<p>代码下载：</p>
<p>1. <a href="http://carey-blog-image.googlecode.com/files/BLANK-Theme-v1.zip">BLANK-Theme</a> 主题</p>
<p>2. 本文制作的 <a href="http://carey-blog-image.googlecode.com/files/BLANK-Theme%28by%20carey%29.zip">JQuery Mobile Theme</a></p>
<p>参考文章：</p>
<p>1. <a href="http://www.catswhocode.com/blog/how-to-create-a-mobile-wordpress-theme-with-jquery-mobile">how-to-create-a-mobile-wordpress-theme-with-jquery-mobile</a></p>
<p><a rel="nofollow" href="http://blog.zhourunsheng.com/2012/03/%e5%88%a9%e7%94%a8-jquery-mobile-%e5%88%b6%e4%bd%9c-wordpress-%e6%89%8b%e6%9c%ba%e4%b8%bb%e9%a2%98/">利用 jQuery Mobile 制作 wordpress 手机主题</a>，首发于<a rel="nofollow" href="http://blog.zhourunsheng.com">润物无声</a>。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.zhourunsheng.com/2012/03/%e5%88%a9%e7%94%a8-jquery-mobile-%e5%88%b6%e4%bd%9c-wordpress-%e6%89%8b%e6%9c%ba%e4%b8%bb%e9%a2%98/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>jQuery Mobile 教程</title>
		<link>http://blog.zhourunsheng.com/2011/07/jquery-mobile-%e6%95%99%e7%a8%8b/</link>
		<comments>http://blog.zhourunsheng.com/2011/07/jquery-mobile-%e6%95%99%e7%a8%8b/#comments</comments>
		<pubDate>Tue, 05 Jul 2011 06:49:21 +0000</pubDate>
		<dc:creator><![CDATA[润物无声]]></dc:creator>
				<category><![CDATA[Web设计]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://blog.zhourunsheng.com/?p=317</guid>
		<description><![CDATA[<p>1.  Creating a Website Using JQuery Mobile 在本教程中将告诉您如何利 [&#8230;]</p>
<p><a rel="nofollow" href="http://blog.zhourunsheng.com/2011/07/jquery-mobile-%e6%95%99%e7%a8%8b/">jQuery Mobile 教程</a>，首发于<a rel="nofollow" href="http://blog.zhourunsheng.com">润物无声</a>。</p>
]]></description>
				<content:encoded><![CDATA[<p><strong>1.  <a href="http://miamicoder.com/category/tutorials/jquery-mobile-tutorials/" target="_blank">Creating a Website Using JQuery Mobile</a></strong></p>
<p>在本教程中将告诉您如何利用jQuery Mobile建立一个网站。这个教程的第一部分为您解释该网站的特点并且完成网站的主页。</p>
<p><img class="alignnone size-full wp-image-319" title="Creating a Website Using JQuery Mobile" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/07/Creating-a-Website-Using-JQuery-Mobile.jpg" alt="Creating-a-Website-Using-JQuery-Mobile" width="500" height="303" /><br />
<span id="more-317"></span><br />
<strong>2. <a href="http://www.elated.com/articles/jquery-mobile-what-can-it-do-for-you/" target="_blank">jQuery Mobile: What Can It Do for You?</a></strong></p>
<p>这是一篇介绍jQuery Mobile主要特性和优点的详细教程，举例说明了如何利用这个新架构帮助你快速建立优质移动应用。</p>
<p><img class="alignnone size-full wp-image-320" title="jQuery Mobile What Can It Do for You" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/07/jQuery-Mobile-What-Can-It-Do-for-You.jpg" alt="jQuery-Mobile-What-Can-It-Do-for-You" width="500" height="254" /></p>
<p><strong>3. <a href="http://fuelyourcoding.com/getting-started-with-jquery-mobile-rails-3/" target="_blank">Getting Started with jQuery Mobile &amp; Rails 3</a></strong></p>
<p>本教程教我们如何利用Rails 3和jQuery Mobile创建CRUD应用。该应用程序将允许我们通过移动设备创建，读取，更新和删除博客帖子。</p>
<p><img class="alignnone size-full wp-image-321" title="Getting Started with jQuery Mobile &amp; Rails 3" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/07/Getting-Started-with-jQuery-Mobile-Rails-3.jpg" alt="Getting-Started-with-jQuery-Mobile-Rails-3" width="503" height="319" /></p>
<p><strong>4. <a href="http://devgrow.com/mobile-web-dev-using-jquery-mobile/" target="_blank">Creating a Simple App Using jQuery Mobile</a></strong></p>
<p>在这篇文章中，我们将看看如何利用框架，动态（AJAX）的页面加载，iOS的风格设计和页面过渡等创建一个简单的移动网站。</p>
<p><img class="alignnone size-full wp-image-322" title="Creating a Simple App Using jQuery Mobile" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/07/Creating-a-Simple-App-Using-jQuery-Mobile.jpg" alt="Creating-a-Simple-App-Using-jQuery-Mobile" width="500" height="242" /></p>
<p><strong>5. <a href="http://www.catswhocode.com/blog/how-to-create-a-mobile-wordpress-theme-with-jquery-mobile" target="_blank">How to create a mobile WordPress theme with jQuery Mobile</a></strong></p>
<p>本教程为您介绍如何创建一个移动优化WordPress主题。</p>
<p><img class="alignnone size-full wp-image-323" title="How to create a mobile WordPress theme with jQuery Mobile" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/07/How-to-create-a-mobile-WordPress-theme-with-jQuery-Mobile.jpg" alt="How-to-create-a-mobile-WordPress-theme-with-jQuery-Mobile" width="500" height="285" /></p>
<p><strong>6.<a href="http://www.mobiledevelopersolutions.com/home/start/twominutetutorials/tmt1part1" target="_blank">Two-Minute Tutorial  1</a> </strong></p>
<p>这个两分钟教程展示了如何使用AppLaud和PhoneGap Media API播放音频文件，并使用jQuery Mobile实现按钮和文本显示。它也显示了两种方法来访问音频文件：网址或本地上传。</p>
<p><img class="alignnone size-full wp-image-324" title="Two-Minute Tutorial" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/07/Two-Minute-Tutorial.jpg" alt="Two-Minute-Tutorial" width="500" height="303" /></p>
<p><strong>7. <a href="http://mobile.tutsplus.com/tutorials/mobile-web-apps/jquery-mobile-forms/" target="_blank">jQuery Mobile Framework – A Forms Tutorial</a> </strong></p>
<p>jQuery Mobile是一个相对较新的移动网络框架，2010年10月首次发布。该框架有许多有趣的功能来支持移动应用开发。在本教程中，我们将集中于 jQuery Mobile的一些基本要素：页面结构，形式和Ajax提交表单。本教程是基于jQuery Mobile 1.0 alpha版本。</p>
<p><img class="alignnone size-full wp-image-325" title="jQuery Mobile Framework – A Forms Tutorial" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/07/jQuery-Mobile-Framework-–-A-Forms-Tutorial.jpg" alt="jQuery-Mobile-Framework-–-A-Forms-Tutorial" width="500" height="286" /></p>
<p><strong>8. <a href="http://net.tutsplus.com/tutorials/javascript-ajax/how-to-build-an-rss-reader-with-jquery-mobile-2/" target="_blank">How to Build an RSS Reader with jQuery Mobile</a> </strong></p>
<p>本教程教我们如何使用PHP和jQuery Mobile建立一个简单的Tuts+ RSS阅读器。学习完这个教程，您可以轻而易举地在iPhone或Android手机上创建Tuts+ RSS阅读器。</p>
<p><img class="alignnone size-full wp-image-326" title="How to Build an RSS Reader with jQuery Mobile" src="http://blog.zhourunsheng.com/wp-content/uploads/2011/07/How-to-Build-an-RSS-Reader-with-jQuery-Mobile.jpg" alt="How-to-Build-an-RSS-Reader-with-jQuery-Mobile" width="500" height="275" /></p>
<p><a rel="nofollow" href="http://blog.zhourunsheng.com/2011/07/jquery-mobile-%e6%95%99%e7%a8%8b/">jQuery Mobile 教程</a>，首发于<a rel="nofollow" href="http://blog.zhourunsheng.com">润物无声</a>。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.zhourunsheng.com/2011/07/jquery-mobile-%e6%95%99%e7%a8%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
