Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Selection

About

Edit section
  • Status: 開発中
  • Instantiation: jetpack.future.import('selection')
  • Last Update: v0.6
  • Summary: selectionは基本的なユーザインタラクションです。Jetpackはユーザによるselectionを探すための標準メソッドを提供しています。 Jetpackのselectionの実装を使用することで、selection イベントの設定、取得をすることが可能となります。

selectionの設定と取得


Edit section

jetpack.selection の現在のバージョンは .text .htmlのフォーマットを含みます。

selectionの取得

var textOfSel = jetpack.selection.text;
var htmlOfSel = jetpack.selection.html;

selectionの設定

jetpack.selection.text = 'Hello';
jetpack.selection.html = '<b>Hello</b>';

onSelection

Edit section

onSelection メソッドを使用することでselectionが行われたときに、イベント関数を実行することができます。

Selectionイベントの追加:

jetpack.selection.onSelection( fn );

Argumants
fn: selectionが行われるときに実行される関数。関数は引数を受け取りません。 引数の代わりに jetpack.selection.* を使用してください。

Selection イベントの除去:

jetpack.selection.onSelection.unbind( fn );

Arguments
fn: 開放したい関数のリファレンス。A reference to a specific function you would like to unbind.

詳細な例:

jetpack.selection.onSelection(function(){
  var html = jetpack.selection.html;
  jetpack.selection.html = ">>>" + html + "<<<";
});

 

ドキュメントのタグと貢献者

 このページの貢献者: teoli, arita_san
 最終更新者: teoli,