{"action":"opened","issue":{"url":"https://api.github.com/repos/CMUI/gearbox/issues/3","labels_url":"https://api.github.com/repos/CMUI/gearbox/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/CMUI/gearbox/issues/3/comments","events_url":"https://api.github.com/repos/CMUI/gearbox/issues/3/events","html_url":"https://github.com/CMUI/gearbox/issues/3","id":93739512,"number":3,"title":"API 文档 - `dom` 模块","user":{"login":"cssmagic","id":1231359,"avatar_url":"https://avatars.githubusercontent.com/u/1231359?v=3","gravatar_id":"","url":"https://api.github.com/users/cssmagic","html_url":"https://github.com/cssmagic","followers_url":"https://api.github.com/users/cssmagic/followers","following_url":"https://api.github.com/users/cssmagic/following{/other_user}","gists_url":"https://api.github.com/users/cssmagic/gists{/gist_id}","starred_url":"https://api.github.com/users/cssmagic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cssmagic/subscriptions","organizations_url":"https://api.github.com/users/cssmagic/orgs","repos_url":"https://api.github.com/users/cssmagic/repos","events_url":"https://api.github.com/users/cssmagic/events{/privacy}","received_events_url":"https://api.github.com/users/cssmagic/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-07-08T09:05:12Z","updated_at":"2015-07-08T09:05:12Z","closed_at":null,"body":"# API 文档 - `dom` 模块\r\n\r\n## JavaScript 变量<a name=\"js-var\"></a>\r\n\r\n为减少业务层对常用 DOM 元素的重复获取和包装，`dom` 模块预先缓存了这些元素的 Zepto 包装对象。在业务层可以直接使用。\r\n\r\n### `_.dom.$win`<a name=\"js-var-$win\"></a>\r\n\r\n`window` 对象的 Zepto 包装对象。\r\n\r\n#### 示例\r\n\r\n监听 `resize` 事件：\r\n\r\n```js\r\n_.dom.$win.on('resize', function (ev) {\r\n    //...\r\n})\r\n```\r\n\r\n### `_.dom.$doc`<a name=\"js-var-$doc\"></a>\r\n\r\n`document.documentElement` 对象（即 `<html>` 元素）的 Zepto 包装对象。\r\n\r\n### `_.dom.$body`<a name=\"js-var-$body\"></a>\r\n\r\n`document.body` 对象（即 `<body>` 元素）的 Zepto 包装对象。\r\n\r\n#### 注意事项\r\n\r\n为确保对 `document.body` 对象的正确获取，加载 GearBox 的脚本标签须放置在页面的 `<body>` 标签内。当然，根据前端性能的最佳实践，所有外链脚本也确实应该放置在页面的最底部：\r\n\r\n```html\r\n<html>\r\n<head>...</head>\r\n<body>\r\n    ...\r\n    <script src=\"...\"></script>\r\n</body>\r\n</html>\r\n```\r\n\r\n## JavaScript 接口<a name=\"js-api\"></a>\r\n\r\n### `_.dom.is$Element(obj)`<a name=\"js-api-is$Element\"></a>\r\n\r\n判断是否为 Zepto 包装对象（或 Zepto 集合）。\r\n\r\n如果外部环境没有加载 Zepto 但有 jQuery，则理论上此方法也可以判断 jQuery 包装对象（或 jQuery 集合）。\r\n\r\n#### 参数\r\n\r\n* `obj` -- 任意类型。需要判断的对象。\r\n\r\n#### 返回值\r\n\r\n布尔值。判断结果。\r\n\r\n#### 示例\r\n\r\n```js\r\n_.dom.is$Element(_.dom.$win)  // => true\r\n```\r\n"}}