このブログは、旧・はてなダイアリー「檜山正幸のキマイラ飼育記 メモ編」(http://d.hatena.ne.jp/m-hiyama-memo/)のデータを移行・保存したものであり、今後(2019年1月以降)更新の予定はありません。

今後の更新は、新しいブログ http://m-hiyama-memo.hatenablog.com/ で行います。

Closure Libraryのメモはgoogタグ

トップレベルの名前空間がgoogだからな。

JSONのカラーリング表示ができる。new goog.format.JsonPrettyPrinter(new goog.format.JsonPrettyPrinter.HtmlDelimiters());

CSSプロパティは:

  • .goog-jsonprettyprinter-propertyname
  • .goog-jsonprettyprinter-propertyvalue-string
  • .goog-jsonprettyprinter-propertyvalue-number
  • .goog-jsonprettyprinter-propertyvalue-boolean
  • .goog-jsonprettyprinter-propertyvalue-null

となるから、お好みの色やフォントで。



無色のコンテナ(goog.ui.Container)とコントロール(goog.ui.Control)でもけっこうなことができる。

コントロール(goog.ui.Control)からのACTIONイベント(goog.ui.Component.EventTypeにあるはず)を捕まえればいい。
イベントにコントロールのID(HTMLのIDとは無関係)が入っているので、それをコマンド名(トリガー文字列)と解釈して、対応するハンドラー関数を実行する。とか。


簡単なダイアログなら:

var prompt = new goog.ui.Prompt('Information Required'/*title*/, 'What is your favorite color?'/*message*/, promptHandler/*callback*/);

もう少しダイアログらしいのは

<button onclick="showDialog(dialog2);">
    Open Dialog (w/ Iframe mask)
</button>
var dialog2 = new goog.ui.Dialog(null, true);
    dialog2.setContent('Some windowed elements leak through standard divs so ' +
        'we add an iframe to mask the nasties.');
    dialog2.setTitle('I have an Iframe mask :)');

    dialog2.setButtonSet(goog.ui.Dialog.ButtonSet.YES_NO_CANCEL);

    goog.events.listen(dialog2, goog.ui.Dialog.EventType.SELECT, 
                       function(e) {
                        alert('You chose: ' + e.key);
                      });


var currDialog;
function showDialog(dialog) {
     currDialog = dialog;
     dialog.setVisible(true);
}