差分
このページの2つのバージョン間の差分を表示します。
| 両方とも前のリビジョン前のリビジョン次のリビジョン | 前のリビジョン | ||
| study:javascript:jquery:plugin:monitor [2010/11/21 13:45] – banana | study:javascript:jquery:plugin:monitor [2016/05/20 06:21] (現在) – [demo page] banana | ||
|---|---|---|---|
| 行 1: | 行 1: | ||
| - | ====== jQuery plugin for monitoring | + | ====== jQuery plugin for monitoring |
| - | 前に、dojoでcustom eventを監視するクラスを作成してみたが、今回は同じソースをjQuery pluginで作成してみた。\\ | + | 前に、dojoで**[[study: |
| plugin化するにあたって、optionの設定ができることと、activeステートとidleステートの際のcallbackメソッドを\\ | plugin化するにあたって、optionの設定ができることと、activeステートとidleステートの際のcallbackメソッドを\\ | ||
| overrideできるようにすることを目標にした。 | overrideできるようにすることを目標にした。 | ||
| 行 23: | 行 23: | ||
| return monitor; | return monitor; | ||
| - | }, | + | } |
| }); | }); | ||
| 行 37: | 行 36: | ||
| defaults:{ | defaults:{ | ||
| timeout : 500, | timeout : 500, | ||
| - | events : [scroll], | + | events : [scroll] |
| - | + | ||
| }, | }, | ||
| setDefaults: | setDefaults: | ||
| 行 108: | 行 106: | ||
| $(" | $(" | ||
| debug(" | debug(" | ||
| - | } | + | }; |
| //override default onIdle method | //override default onIdle method | ||
| $.monitor.onIdle = function(){ | $.monitor.onIdle = function(){ | ||
| $(" | $(" | ||
| debug(" | debug(" | ||
| - | } | + | }; |
| - | $().ready(function(){ | + | $(function(){ |
| - | $(document).monitor({timeout: | + | $(document).monitor({timeout: |
| $(window).monitor({events: | $(window).monitor({events: | ||
| }); | }); | ||
| </ | </ | ||
| 基本的に | 基本的に | ||
| - | defalutメソッドであるonActiveメソッドとonIdleメソッドをoverrideしてから、monitorメソッドを呼び出す。 | + | defalutメソッドであるonActiveメソッドとonIdleメソッドをoverrideしてから、monitorメソッドを呼び出す。\\ |
| デモページでは、documentに対してtimeout5秒を指定してある。windowのりサイズイベントとスクロールイベントに対しては | デモページでは、documentに対してtimeout5秒を指定してある。windowのりサイズイベントとスクロールイベントに対しては | ||
| defaultの1秒がたったらIdleステートになる。 | defaultの1秒がたったらIdleステートになる。 | ||
| - | 以下にデモページのリンクをつけてある。\\ | + | デモは[[http:// |
| - | [[http:// | + | |
| + | < | ||
| + | <iframe width=" | ||
| + | </ | ||