Skip to content

Commit

Permalink
feat(jQuery): プラグインのサンプル実装を追加
Browse files Browse the repository at this point in the history
  • Loading branch information
azu committed Aug 29, 2015
1 parent 86a15df commit af01e9e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
20 changes: 14 additions & 6 deletions ja/jQuery/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
# jQueryのPlugin Pattern
# jQueryのPlugin

!CODEFILE "../../src/jQuery/jquery.js"
jQueryでは`$.fn`を拡張する事で、`$()`の返り値であるjQueryオブジェクトにメソッドを追加することが出来ます。

```js
var jQuery = require("jquery");
jQuery(document.body);
```
次の`greenify`プラグインでは、`$(document.body).greenify();`というメソッド呼び出しが可能になります。

!CODEFILE "../../src/jQuery/greenify.js"

実際に利用するためには、`jquery.js`を読み込んだ後に`greenify.js`を読み込ませる必要があります。

```html
<script src="jquery.js"></script>
<script src="greenify.js"></script>
```

## どういう仕組み?fea
2 changes: 1 addition & 1 deletion test/jQuery/greenify-test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// LICENSE : MIT
"use strict";
import jsdom from "jsdom";
import assert from "power-assert"
import assert from "power-assert";
import fs from "fs";
const testbed = fs.readFileSync(__dirname + "/fixtures/testbed.html", "utf-8");
const jquery = fs.readFileSync(__dirname + "/../../node_modules/jquery/dist/jquery.js", "utf-8");
Expand Down

0 comments on commit af01e9e

Please sign in to comment.