-
Notifications
You must be signed in to change notification settings - Fork 4
/
help.html
149 lines (147 loc) · 5 KB
/
help.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>YakShave Help</title>
<link rel="stylesheet" type="text/css" href="common/options.css" />
</head>
<body>
<h1>YakShave Help</h1>
<p>
Binding scripts are <code>eval()</code>'d when YakShave starts or
when the list of scripts is changed. At the top level, they should
call the functions
</p>
<ul>
<li><p><code>yak.functions.add()</code></p></li>
<li><p><code>yak.bindings.add()</code></p></li>
</ul>
<p>
A typical script looks like:
</p>
<pre>yak.bindings.add({
'key': {
onkeydown: function(event) { ... }
}
});</pre>
<p>
Bindings can use the functions
</p>
<ul>
<li><p><code>yak.xhr()</code></p></li>
<li><p><code>yak.tabs.*()</code></p></li>
</ul>
<p>
and use properties of the object
</p>
<ul>
<li><p><code>yak.variables</code></p></li>
</ul>
<p>
Try not to poke at other properties of <code>yak</code>, as I may
rearrange them on a whim.
</p>
<h2>Calling the <code>add()</code> functions</h2>
<p>
For <code>yak.functions.add()</code>, pass an object with the
property names you want to define and anonymous functions as their
values. For <code>yak.bindings.add()</code>, pass an object with
Emacs-like key description strings as the properties and objects
describing the bindings as their values.
See <a href="bindings/base.js">base.js</a> for examples.
</p>
<h2>Key Descriptions</h2>
<p class="warning">
As of version 1.0, only single keys (not sequences) are supported.
</p>
<p>
Keys are specified with an Emacs-style string. For a detailed
discussion of the real thing, see the EmacsWiki article on
<a href="http://www.emacswiki.org/emacs/KeySequence">key
sequences</a>. Our parser is somewhat more limited in scope and
<strike>more esoteric</strike> non-trivial key
sequences <strike>may</strike> probably will not
be expressible.
</p>
<p>
Handling of the Meta modifier varies between platforms, so don't
depend on it being a particular physical key.
</p>
<h2>Binding definitions</h2>
<p>
Binding objects have two kinds of properties:
</p>
<dl>
<dt>
<p><code>include</code> and <code>exclude</code></p>
</dt>
<dd>
<p>
Lists of which HTML elements the binding should fire on. By
default, <code>include</code> is <code>[HTMLElement]</code>,
which all elements are subclasses of. If you set it to something
else, the binding will match <em>only</em> those elements.
<code>yak.TextElements</code> is available for convenience.
</p>
</dd>
<dt>
<p>
<code>onkeydown</code>, <code>onkeyup</code>,
<code>onkeypress</code>
</p>
</dt>
<dd>
<p>
The function called when the binding fires, with the argument
<code>event</code>. Applied in the context
of <code>event.target</code>, so for accessing the contents of
e.g. a text element you can use <code>this.value</code>.
Normally, prevents any standard WebKit binding from firing,
but if you return <code>false</code> it will punt.
</p>
</dd>
</dl>
<h2>The standard library</h2>
<p>
<a href="bindings/base.js">base.js</a> adds a number of functions
that can be used as the <code>onkeypress</code> (etc.) of a
binding. The standard Emacs, info, and vi binding sets are almost
entirely made out of these functions. If you want to use a default
binding set but don't want a particular binding in it, you can
re-bind that key to <code>yak.functions.pass</code> (which simply
returns false).
</p>
<h2>Calling <code>xhr()</code></h2>
<p>
<code>xhr()</code> takes two arguments: an object representing the
request, and (optionally) a callback function. The request object
must have at least a <code>url</code> and the
HTTP <code>method</code> to use. <code>data</code> for a PUT or
POST request and an object representing <code>headers</code> are
optional.
</p>
<p>
The callback function should not take any arguments: In will be
applied in the XHR object's context, so to get e.g. the text of a
response use <code>this.responseText</code>. The callback will be
a closure over the event, so you can use <code>event.target</code>
to get the object that was previously <code>this</code>.
</p>
<h2>Calling the <code>yak.tabs</code> functions</h2>
<p><code>yak.tabs</code> currently has 4 functions:</p>
<ul>
<li><p><code>create()</code></p></li>
<li><p><code>update()</code></p></li>
<li><p><code>move()</code></p></li>
<li><p><code>remove()</code></p></li>
</ul>
<p>
They each take one argument, the respective kinds of properties
object described in
<a href="http://code.google.com/chrome/extensions/tabs.html">the
<code>chrome.tabs</code> documentation</a>. As of version 1.0,
only the current tab can be updated/moved/removed, so there is no
<code>tabId</code> argument.
</p>
</body>
</html>