PageRenderTime 70ms CodeModel.GetById 32ms RepoModel.GetById 0ms app.codeStats 0ms

/docs/html/styleguide/common-conventions.html

https://github.com/YuhangGe/kissyteam.github.com
HTML | 216 lines | 177 code | 20 blank | 19 comment | 0 complexity | 308d5e213bbbfd5f45aef8931b35a8a0 MD5 | raw file
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8"/>
  5. <title>通用约定 &mdash; KISSY Docs valpha documentation</title>
  6. <link rel="stylesheet" href="../static/reset.css"/>
  7. <link rel="stylesheet" href="../static/kissy.css"/>
  8. <link rel="stylesheet" href="../static/pygments.css"/>
  9. <link rel="shortcut icon" href="../static/favicon.ico"/>
  10. <link href='http://fonts.googleapis.com/css?family=Philosopher' rel='stylesheet' type='text/css'>
  11. <script>
  12. var DOCUMENTATION_OPTIONS = {
  13. URL_ROOT: '../',
  14. VERSION: 'alpha',
  15. COLLAPSE_INDEX: false,
  16. FILE_SUFFIX: '.html',
  17. HAS_SOURCE: true
  18. };
  19. if(window.location.href.indexOf("localhost/kissy_git/")!=-1){
  20. document.write('<script src="http://localhost/kissy_git/kissy/build/kissy.js"'+'><'+'/script>');
  21. } else{
  22. document.write('<script src="http://yiminghe.github.com/kissy/build/kissy.js"'+'>'+'<'+'/script>');
  23. }
  24. </script>
  25. <script type="text/javascript" src="../static/jquery.js"></script>
  26. <script type="text/javascript" src="../static/underscore.js"></script>
  27. <script type="text/javascript" src="../static/doctools.js"></script>
  28. </head>
  29. <body><div id="header">
  30. <h1 class="logo"><a alt="KISSY" href="http://docs.kissyui.com"><img src="../static/logo.png"/></a></h1>
  31. <p class="desc">小巧灵活简洁实用愉悦编码快乐开发</p>
  32. <ul class="navigation">
  33. <li><a href="../../html/quickstart/index.html">快速上手</a></li>
  34. <li><a href="../../html/api/index.html">API</a></li>
  35. <li><a href="../../html/demo/index.html">DEMO</a></li>
  36. <li><a href="http://blog.kissyui.com/">博客</a></li>
  37. <!--<li><a href="mailto:all@kissyui.com">论坛</a></li>-->
  38. <li><a href="http://www.github.com/kissyteam">源码</a></li>
  39. </ul>
  40. <div id="searchbox" style="display: none" class="searchbox">
  41. <form class="search" action="../search.html" method="get">
  42. <input type="text" name="q" size="28" class="ipt"/>
  43. <input type="submit" value="Go" class="btn"/>
  44. <input type="hidden" name="check_keywords" value="yes" />
  45. <input type="hidden" name="area" value="default" />
  46. </form>
  47. </div>
  48. <script type="text/javascript">$('#searchbox').show(0);</script>
  49. </div>
  50. <div id="content">
  51. <div class="layout grid-s6m0">
  52. <div class="col-main">
  53. <div class="main-wrap">
  54. <div class='related'>
  55. <h3>Navigation</h3>
  56. <ul>
  57. <li class="right" style="margin-right: 10px">
  58. <a href="../genindex.html" title="General Index"
  59. accesskey="I">index</a></li>
  60. <li class="right" >
  61. <a href="../py-modindex.html" title="Python Module Index"
  62. >modules</a> | </li>
  63. <li class="right" >
  64. <a href="css-coding-style.html" title="CSS 编码规范"
  65. accesskey="N">next</a> | </li>
  66. <li class="right" >
  67. <a href="index.html" title="最佳编码实践"
  68. accesskey="P">previous</a> | </li>
  69. <li><a href="../index.html">KISSY Docs</a> &#187; </li>
  70. <li><a href="index.html" accesskey="U">最佳编码实践</a> &#187; </li>
  71. </ul>
  72. </div>
  73. <div class="section" id="styleguide-commonconventions">
  74. <span id="id1"></span><h1>通用约定<a class="headerlink" href="#styleguide-commonconventions" title="Permalink to this headline"></a></h1>
  75. <div class="section" id="id2">
  76. <h2>文件与目录命名约定<a class="headerlink" href="#id2" title="Permalink to this headline"></a></h2>
  77. <ol class="arabic simple">
  78. <li>一律小写, 必须是英文单词或产品名称的拼音, 多个单词用连字符(-)连接. 只能出现英文字母数字和连字符, 严禁出现中文.</li>
  79. <li>出现版本号时, 需要用字母 v 做为前缀, 小版本号用点号(.)隔开, 比如 global-v8.js detail-v2.2.js .</li>
  80. <li>该命名规范适用于 html, css, js, swf, php, xml, png, gif, jpg, ico 等前端维护的所有文件类型和相关目录.</li>
  81. <li>js css 压缩文件, 统一以 -min 结尾, 比如源码文件为 kissy.js, 压缩后为 kissy-min.js .</li>
  82. </ol>
  83. </div>
  84. <div class="section" id="id3">
  85. <h2>文件编码约定<a class="headerlink" href="#id3" title="Permalink to this headline"></a></h2>
  86. <blockquote>
  87. <div><p>由于历史原因, 前端开发涉及的所有文本文件请统一 <strong>采用 GB2312, GBK GB18030 编码</strong> .</p>
  88. <p>注意后台采用 UTF-8 的新项目, 或自主开发的项目, 推荐使用 UTF-8 编码.</p>
  89. </div></blockquote>
  90. </div>
  91. <div class="section" id="id-class">
  92. <h2>id class 命名约定<a class="headerlink" href="#id-class" title="Permalink to this headline"></a></h2>
  93. <ol class="arabic simple">
  94. <li>id class 的命名总规则为 <strong>内容优先,表现为辅</strong>. 首先根据内容来命名, 比如 main-nav. 如果根据内容找不到合适的命名, 可以再结合表现来定, 比如 skin-blue, present-tab, col-main.</li>
  95. <li>id class 名称一律小写, 多个单词用连字符连接, 比如 recommend-presents.</li>
  96. <li>id class 名称中只能出现小写的 26 个英文字母数字和连字符(-), 任何其它字符都严禁出现.</li>
  97. <li>id class <strong>尽量用英文单词命名</strong> . 确实找不到合适的单词时, 可以考虑使用产品的中文拼音, 比如 wangwang, dating. 对于中国以及淘宝特色词汇, 也可以使用拼音, 比如 xiaobao, daigou. 除了产品名称和特色词汇, 其它任何情况下都严禁使用拼音.</li>
  98. <li>在不影响语义的情况下, id class 名称中可以适当采用英文单词缩写, 比如 col, nav, hd, bd, ft , 但切忌自造缩写.</li>
  99. <li>id class 名称中的第一个词必须是单词全拼或语义非常清晰的单词缩写, 比如 present, col.</li>
  100. <li>仅在 JavaScript 代码中当作 hook 用的 id class, 命名规则为 <tt class="docutils literal"><span class="pre">J_UpperCamelCase``(请注意,</span> <span class="pre">``J_</span></tt> 后的首字母也大写), 其中字母 J 代表 JavaScript, 也是钩子(hook)的象形. 注意如果在 JavaScript CSS 中都需要用到, 则不用遵守本约定.</li>
  101. <li>在自动化测试脚本中当作 hook 用的 class, 命名规则为 T_UpperCamelCase, 其中字母 T 代表 Test.</li>
  102. </ol>
  103. </div>
  104. </div>
  105. <div>
  106. <label>
  107. 评论
  108. <select id='openComment'>
  109. <option value='1'>打开</option>
  110. <option value='0'>关闭</option>
  111. </select>
  112. </label>
  113. <script>
  114. if(!window.localStorage){
  115. KISSY.one("#openComment").attr("disabled",true);
  116. }else{
  117. KISSY.one("#openComment").val(window.localStorage.getItem("kissy-commment")||"1");
  118. KISSY.one("#openComment").on("change",function(){
  119. window.localStorage.setItem("kissy-commment",KISSY.one("#openComment").val());
  120. window.location.reload();
  121. });
  122. }
  123. </script>
  124. </div>
  125. <div id="disqus_thread"></div>
  126. <script>
  127. if((window.location.hostname.indexOf("kissyui.com")!=-1 )&& window.localStorage.getItem("kissy-commment")!="0"){
  128. /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
  129. var disqus_shortname = 'kissy-docs'; // required: replace example with your forum shortname
  130. // The following are highly recommended additional parameters. Remove the slashes in front to use.
  131. //var disqus_identifier = '/anim';
  132. //var disqus_url = window.location;
  133. /* * * DON'T EDIT BELOW THIS LINE * * */
  134. (function() {
  135. var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
  136. dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
  137. (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
  138. })();
  139. }
  140. </script>
  141. <noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
  142. <a href="http://disqus.com" class="dsq-brlink">blog comments powered by <span class="logo-disqus">Disqus</span></a>
  143. <!--<div id="google-search-box">
  144. <div id="cse" style="width: 100%;">Loading</div>
  145. <script>
  146. if(window.location.hostname.indexOf("kissyui.com")!=-1){
  147. document.write('<script src="http://www.google.com/jsapi" type="text/javascript"><'+'/script>');
  148. }
  149. </script>
  150. <script>
  151. if(window.location.hostname.indexOf("kissyui.com")!=-1){
  152. google.load('search', '1', {language : 'zh-CN', style : google.loader.themes.MINIMALIST});
  153. google.setOnLoadCallback(function() {
  154. var customSearchControl = new google.search.CustomSearchControl('012347804910294994683:n4uzb24gqdm');
  155. customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
  156. customSearchControl.draw('cse');
  157. }, true);
  158. }
  159. </script>
  160. </div>-->
  161. </div>
  162. </div>
  163. <div class="col-sub">
  164. <div class="s-box">
  165. <div class="s-box-bd">
  166. <ul class="current">
  167. <li class="toctree-l1"><a class="reference internal" href="../quickstart/index.html">快速上手</a></li>
  168. <li class="toctree-l1"><a class="reference internal" href="../api/index.html">API文档</a></li>
  169. <li class="toctree-l1"><a class="reference internal" href="../demo/index.html">All Demos</a></li>
  170. <li class="toctree-l1"><a class="reference internal" href="../relatedproj/index.html">子项目集</a></li>
  171. <li class="toctree-l1 current"><a class="reference internal" href="index.html">最佳编码实践</a><ul class="current">
  172. <li class="toctree-l2 current"><a class="current reference internal" href="">通用约定</a><ul>
  173. <li class="toctree-l3"><a class="reference internal" href="#id2">文件与目录命名约定</a></li>
  174. <li class="toctree-l3"><a class="reference internal" href="#id3">文件编码约定</a></li>
  175. <li class="toctree-l3"><a class="reference internal" href="#id-class">id class 命名约定</a></li>
  176. </ul>
  177. </li>
  178. <li class="toctree-l2"><a class="reference internal" href="css-coding-style.html">CSS 编码规范</a></li>
  179. <li class="toctree-l2"><a class="reference internal" href="html-coding-style.html">HTML 编码规范</a></li>
  180. <li class="toctree-l2"><a class="reference internal" href="js-lang-rules.html">JavaScript 语言规范</a></li>
  181. <li class="toctree-l2"><a class="reference internal" href="js-style-rules.html">JavaScript 编码风格</a></li>
  182. </ul>
  183. </li>
  184. <li class="toctree-l1"><a class="reference internal" href="../tools/index.html">前端常用工具</a></li>
  185. <li class="toctree-l1"><a class="reference internal" href="../workflow/index.html">组件开发指南</a></li>
  186. </ul>
  187. </div>
  188. </div>
  189. </div>
  190. </div>
  191. </div>
  192. <div id="footer">
  193. &copy; Copyright 2010~2011, KISSY Team. Created using <a href="http://sphinx.pocoo.org/">Sphinx</a>
  194. </div>
  195. </body>
  196. </html>