Professional Documents
Culture Documents
Writing A Google Closure Editor Plugin
Writing A Google Closure Editor Plugin
. .
@yinhm Google Closure Plugin 1/27
.
Before we start
.
. .
@yinhm Google Closure Plugin 2/27
.
goog.require('goog.dom');
function sayHi() {
var newHeader = goog.dom.createDom('h1',
{'style': 'background-color:#EEE'},
'Hello world!');
goog.dom.appendChild(document.body, newHeader);
}
. .
@yinhm Google Closure Plugin 3/27
.
<html>
<head>
<script src="closure-library/closure/goog/base.js">
</script>
<script src="hello.js"></script>
</head>
<body onload="sayHi()">
</body>
</html>
. .
@yinhm Google Closure Plugin 4/27
.
. .
@yinhm Google Closure Plugin 5/27
.
Modules
.
. .
@yinhm Google Closure Plugin 6/27
.
object-oriented programming
.
. .
@yinhm Google Closure Plugin 7/27
.
Example of a Class
.
example.Animal = function(first_name) {
this.name_ = name;
};
example.Animal.prototype.first_name = '';
example.Animal.prototype.getName = function() {
return this.name_;
};
. .
@yinhm Google Closure Plugin 8/27
.
Static methods
.
. .
@yinhm Google Closure Plugin 9/27
.
Inheritance
.
goog.privode('example.Bird');
goog.require('example.Animal');
example.Bird = function() {
// call to the superclass’s constructor function
goog.base(this, 'bird');
};
goog.inherits(example.Bird, example.Animal); // prototyp
example.Bird.prototype.fly = function() {
return true;
};
. .
@yinhm Google Closure Plugin 10/27
.
Inheritance of ui.Dialog
.
. .
@yinhm Google Closure Plugin 11/27
.
goog.Disposable
.
• dispose
• disposeInternal
. .
@yinhm Google Closure Plugin 12/27
.
goog.events.EventTarget
.
• addEventListener
• removeEventListener
• dispatchEvent
. .
@yinhm Google Closure Plugin 13/27
.
goog.ui.Component
.
A UI Component Example
.
An Introduction to Components
. .
@yinhm Google Closure Plugin 15/27
.
. .
@yinhm Google Closure Plugin 16/27
.
design
. .
@yinhm Google Closure Plugin 17/27
.
. .
@yinhm Google Closure Plugin 18/27
.
init editor
.
. .
@yinhm Google Closure Plugin 19/27
.
register plugin
.
. .
@yinhm Google Closure Plugin 20/27
.
Interacting
.
. .
@yinhm Google Closure Plugin 21/27
.
goog.editor.Plugin
.
. .
@yinhm Google Closure Plugin 22/27
.
Implemen: ImageDialogPlugin
.
. .
@yinhm Google Closure Plugin 23/27
.
Implement: ImageDialog
.
. .
@yinhm Google Closure Plugin 24/27
.
Implement: detail
.
. .
@yinhm Google Closure Plugin 25/27
.
References
.
. .
@yinhm Google Closure Plugin 26/27
.
About
.
Created in LaTEX using the beamer class, TeX Live and Emacs.
by @yinhm
http://yinhm.appspot.com
. .
@yinhm Google Closure Plugin 27/27