/docs/html/styleguide/common-conventions.html
HTML | 216 lines | 177 code | 20 blank | 19 comment | 0 complexity | 308d5e213bbbfd5f45aef8931b35a8a0 MD5 | raw file
- <!doctype html>
- <html>
- <head>
- <meta charset="utf-8"/>
- <title>通用约定 — KISSY Docs valpha documentation</title>
- <link rel="stylesheet" href="../static/reset.css"/>
- <link rel="stylesheet" href="../static/kissy.css"/>
- <link rel="stylesheet" href="../static/pygments.css"/>
- <link rel="shortcut icon" href="../static/favicon.ico"/>
- <link href='http://fonts.googleapis.com/css?family=Philosopher' rel='stylesheet' type='text/css'>
- <script>
- var DOCUMENTATION_OPTIONS = {
- URL_ROOT: '../',
- VERSION: 'alpha',
- COLLAPSE_INDEX: false,
- FILE_SUFFIX: '.html',
- HAS_SOURCE: true
- };
- if(window.location.href.indexOf("localhost/kissy_git/")!=-1){
- document.write('<script src="http://localhost/kissy_git/kissy/build/kissy.js"'+'><'+'/script>');
- } else{
- document.write('<script src="http://yiminghe.github.com/kissy/build/kissy.js"'+'>'+'<'+'/script>');
- }
- </script>
- <script type="text/javascript" src="../static/jquery.js"></script>
- <script type="text/javascript" src="../static/underscore.js"></script>
- <script type="text/javascript" src="../static/doctools.js"></script>
- </head>
- <body><div id="header">
- <h1 class="logo"><a alt="KISSY" href="http://docs.kissyui.com"><img src="../static/logo.png"/></a></h1>
- <p class="desc">小巧灵活、简洁实用、愉悦编码、快乐开发</p>
- <ul class="navigation">
- <li><a href="../../html/quickstart/index.html">快速上手</a></li>
- <li><a href="../../html/api/index.html">API</a></li>
- <li><a href="../../html/demo/index.html">DEMO</a></li>
- <li><a href="http://blog.kissyui.com/">博客</a></li>
- <!--<li><a href="mailto:all@kissyui.com">论坛</a></li>-->
- <li><a href="http://www.github.com/kissyteam">源码</a></li>
- </ul>
- <div id="searchbox" style="display: none" class="searchbox">
- <form class="search" action="../search.html" method="get">
- <input type="text" name="q" size="28" class="ipt"/>
- <input type="submit" value="Go" class="btn"/>
- <input type="hidden" name="check_keywords" value="yes" />
- <input type="hidden" name="area" value="default" />
- </form>
- </div>
- <script type="text/javascript">$('#searchbox').show(0);</script>
- </div>
- <div id="content">
-
- <div class="layout grid-s6m0">
- <div class="col-main">
- <div class="main-wrap">
- <div class='related'>
- <h3>Navigation</h3>
-
- <ul>
- <li class="right" style="margin-right: 10px">
- <a href="../genindex.html" title="General Index"
- accesskey="I">index</a></li>
- <li class="right" >
- <a href="../py-modindex.html" title="Python Module Index"
- >modules</a> | </li>
- <li class="right" >
- <a href="css-coding-style.html" title="CSS 编码规范"
- accesskey="N">next</a> | </li>
- <li class="right" >
- <a href="index.html" title="最佳编码实践"
- accesskey="P">previous</a> | </li>
- <li><a href="../index.html">KISSY Docs</a> » </li>
- <li><a href="index.html" accesskey="U">最佳编码实践</a> » </li>
- </ul>
- </div>
-
- <div class="section" id="styleguide-commonconventions">
- <span id="id1"></span><h1>通用约定<a class="headerlink" href="#styleguide-commonconventions" title="Permalink to this headline">¶</a></h1>
- <div class="section" id="id2">
- <h2>文件与目录命名约定<a class="headerlink" href="#id2" title="Permalink to this headline">¶</a></h2>
- <ol class="arabic simple">
- <li>一律小写, 必须是英文单词或产品名称的拼音, 多个单词用连字符(-)连接. 只能出现英文字母、数字和连字符, 严禁出现中文.</li>
- <li>出现版本号时, 需要用字母 v 做为前缀, 小版本号用点号(.)隔开, 比如 global-v8.js 或 detail-v2.2.js .</li>
- <li>该命名规范适用于 html, css, js, swf, php, xml, png, gif, jpg, ico 等前端维护的所有文件类型和相关目录.</li>
- <li>js 和 css 压缩文件, 统一以 -min 结尾, 比如源码文件为 kissy.js, 压缩后为 kissy-min.js .</li>
- </ol>
- </div>
- <div class="section" id="id3">
- <h2>文件编码约定<a class="headerlink" href="#id3" title="Permalink to this headline">¶</a></h2>
- <blockquote>
- <div><p>由于历史原因, 前端开发涉及的所有文本文件请统一 <strong>采用 GB2312, GBK 或 GB18030 编码</strong> .</p>
- <p>注意:后台采用 UTF-8 的新项目, 或自主开发的项目, 推荐使用 UTF-8 编码.</p>
- </div></blockquote>
- </div>
- <div class="section" id="id-class">
- <h2>id 和 class 命名约定<a class="headerlink" href="#id-class" title="Permalink to this headline">¶</a></h2>
- <ol class="arabic simple">
- <li>id 和 class 的命名总规则为: <strong>内容优先,表现为辅</strong>. 首先根据内容来命名, 比如 main-nav. 如果根据内容找不到合适的命名, 可以再结合表现来定, 比如 skin-blue, present-tab, col-main.</li>
- <li>id 和 class 名称一律小写, 多个单词用连字符连接, 比如 recommend-presents.</li>
- <li>id 和 class 名称中只能出现小写的 26 个英文字母、数字和连字符(-), 任何其它字符都严禁出现.</li>
- <li>id 和 class <strong>尽量用英文单词命名</strong> . 确实找不到合适的单词时, 可以考虑使用产品的中文拼音, 比如 wangwang, dating. 对于中国以及淘宝特色词汇, 也可以使用拼音, 比如 xiaobao, daigou. 除了产品名称和特色词汇, 其它任何情况下都严禁使用拼音.</li>
- <li>在不影响语义的情况下, id 和 class 名称中可以适当采用英文单词缩写, 比如 col, nav, hd, bd, ft 等, 但切忌自造缩写.</li>
- <li>id 和 class 名称中的第一个词必须是单词全拼或语义非常清晰的单词缩写, 比如 present, col.</li>
- <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>
- <li>在自动化测试脚本中当作 hook 用的 class, 命名规则为 T_UpperCamelCase, 其中字母 T 代表 Test.</li>
- </ol>
- </div>
- </div>
- <div>
- <label>
- 评论:
- <select id='openComment'>
- <option value='1'>打开</option>
- <option value='0'>关闭</option>
- </select>
- </label>
- <script>
- if(!window.localStorage){
- KISSY.one("#openComment").attr("disabled",true);
- }else{
- KISSY.one("#openComment").val(window.localStorage.getItem("kissy-commment")||"1");
- KISSY.one("#openComment").on("change",function(){
- window.localStorage.setItem("kissy-commment",KISSY.one("#openComment").val());
- window.location.reload();
- });
- }
- </script>
- </div>
- <div id="disqus_thread"></div>
- <script>
- if((window.location.hostname.indexOf("kissyui.com")!=-1 )&& window.localStorage.getItem("kissy-commment")!="0"){
- /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
- var disqus_shortname = 'kissy-docs'; // required: replace example with your forum shortname
- // The following are highly recommended additional parameters. Remove the slashes in front to use.
- //var disqus_identifier = '/anim';
- //var disqus_url = window.location;
- /* * * DON'T EDIT BELOW THIS LINE * * */
- (function() {
- var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
- dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
- (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
- })();
- }
- </script>
- <noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
- <a href="http://disqus.com" class="dsq-brlink">blog comments powered by <span class="logo-disqus">Disqus</span></a>
- <!--<div id="google-search-box">
- <div id="cse" style="width: 100%;">Loading</div>
- <script>
- if(window.location.hostname.indexOf("kissyui.com")!=-1){
- document.write('<script src="http://www.google.com/jsapi" type="text/javascript"><'+'/script>');
- }
- </script>
- <script>
- if(window.location.hostname.indexOf("kissyui.com")!=-1){
- google.load('search', '1', {language : 'zh-CN', style : google.loader.themes.MINIMALIST});
- google.setOnLoadCallback(function() {
- var customSearchControl = new google.search.CustomSearchControl('012347804910294994683:n4uzb24gqdm');
- customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
- customSearchControl.draw('cse');
- }, true);
- }
- </script>
- </div>-->
- </div>
- </div>
- <div class="col-sub">
- <div class="s-box">
- <div class="s-box-bd">
- <ul class="current">
- <li class="toctree-l1"><a class="reference internal" href="../quickstart/index.html">快速上手</a></li>
- <li class="toctree-l1"><a class="reference internal" href="../api/index.html">API文档</a></li>
- <li class="toctree-l1"><a class="reference internal" href="../demo/index.html">All Demos</a></li>
- <li class="toctree-l1"><a class="reference internal" href="../relatedproj/index.html">子项目集</a></li>
- <li class="toctree-l1 current"><a class="reference internal" href="index.html">最佳编码实践</a><ul class="current">
- <li class="toctree-l2 current"><a class="current reference internal" href="">通用约定</a><ul>
- <li class="toctree-l3"><a class="reference internal" href="#id2">文件与目录命名约定</a></li>
- <li class="toctree-l3"><a class="reference internal" href="#id3">文件编码约定</a></li>
- <li class="toctree-l3"><a class="reference internal" href="#id-class">id 和 class 命名约定</a></li>
- </ul>
- </li>
- <li class="toctree-l2"><a class="reference internal" href="css-coding-style.html">CSS 编码规范</a></li>
- <li class="toctree-l2"><a class="reference internal" href="html-coding-style.html">HTML 编码规范</a></li>
- <li class="toctree-l2"><a class="reference internal" href="js-lang-rules.html">JavaScript 语言规范</a></li>
- <li class="toctree-l2"><a class="reference internal" href="js-style-rules.html">JavaScript 编码风格</a></li>
- </ul>
- </li>
- <li class="toctree-l1"><a class="reference internal" href="../tools/index.html">前端常用工具</a></li>
- <li class="toctree-l1"><a class="reference internal" href="../workflow/index.html">组件开发指南</a></li>
- </ul>
- </div>
- </div>
- </div>
- </div>
- </div>
- <div id="footer">
- © Copyright 2010~2011, KISSY Team. Created using <a href="http://sphinx.pocoo.org/">Sphinx</a>
- </div>
- </body>
- </html>