sumatra-rails 0.0.4.1 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile.lock +4 -5
- data/lib/sumatra/rails/version.rb +1 -1
- data/vendor/assets/javascripts/sumatra.js.coffee +122 -1
- metadata +19 -30
- checksums.yaml +0 -15
- data/vendor/assets/javascripts/sumatra/.env.example +0 -1
- data/vendor/assets/javascripts/sumatra/.gitignore +0 -2
- data/vendor/assets/javascripts/sumatra/Cakefile +0 -27
- data/vendor/assets/javascripts/sumatra/LICENSE.md +0 -20
- data/vendor/assets/javascripts/sumatra/README.md +0 -183
- data/vendor/assets/javascripts/sumatra/component.json +0 -30
- data/vendor/assets/javascripts/sumatra/docs/docco.css +0 -500
- data/vendor/assets/javascripts/sumatra/docs/index.html +0 -177
- data/vendor/assets/javascripts/sumatra/docs/index.md +0 -0
- data/vendor/assets/javascripts/sumatra/docs/plugin.js.html +0 -207
- data/vendor/assets/javascripts/sumatra/docs/public/fonts/aller-bold.eot +0 -0
- data/vendor/assets/javascripts/sumatra/docs/public/fonts/aller-bold.ttf +0 -0
- data/vendor/assets/javascripts/sumatra/docs/public/fonts/aller-bold.woff +0 -0
- data/vendor/assets/javascripts/sumatra/docs/public/fonts/aller-light.eot +0 -0
- data/vendor/assets/javascripts/sumatra/docs/public/fonts/aller-light.ttf +0 -0
- data/vendor/assets/javascripts/sumatra/docs/public/fonts/aller-light.woff +0 -0
- data/vendor/assets/javascripts/sumatra/docs/public/fonts/fleurons.eot +0 -0
- data/vendor/assets/javascripts/sumatra/docs/public/fonts/fleurons.ttf +0 -0
- data/vendor/assets/javascripts/sumatra/docs/public/fonts/fleurons.woff +0 -0
- data/vendor/assets/javascripts/sumatra/docs/public/fonts/novecento-bold.eot +0 -0
- data/vendor/assets/javascripts/sumatra/docs/public/fonts/novecento-bold.ttf +0 -0
- data/vendor/assets/javascripts/sumatra/docs/public/fonts/novecento-bold.woff +0 -0
- data/vendor/assets/javascripts/sumatra/docs/public/images/gray.png +0 -0
- data/vendor/assets/javascripts/sumatra/docs/public/stylesheets/normalize.css +0 -375
- data/vendor/assets/javascripts/sumatra/docs/runtime.js.html +0 -111
@@ -1,500 +0,0 @@
|
|
1
|
-
/*--------------------- Typography ----------------------------*/
|
2
|
-
|
3
|
-
@font-face {
|
4
|
-
font-family: 'aller-light';
|
5
|
-
src: url('public/fonts/aller-light.eot');
|
6
|
-
src: url('public/fonts/aller-light.eot?#iefix') format('embedded-opentype'),
|
7
|
-
url('public/fonts/aller-light.woff') format('woff'),
|
8
|
-
url('public/fonts/aller-light.ttf') format('truetype');
|
9
|
-
font-weight: normal;
|
10
|
-
font-style: normal;
|
11
|
-
}
|
12
|
-
|
13
|
-
@font-face {
|
14
|
-
font-family: 'aller-bold';
|
15
|
-
src: url('public/fonts/aller-bold.eot');
|
16
|
-
src: url('public/fonts/aller-bold.eot?#iefix') format('embedded-opentype'),
|
17
|
-
url('public/fonts/aller-bold.woff') format('woff'),
|
18
|
-
url('public/fonts/aller-bold.ttf') format('truetype');
|
19
|
-
font-weight: normal;
|
20
|
-
font-style: normal;
|
21
|
-
}
|
22
|
-
|
23
|
-
@font-face {
|
24
|
-
font-family: 'novecento-bold';
|
25
|
-
src: url('public/fonts/novecento-bold.eot');
|
26
|
-
src: url('public/fonts/novecento-bold.eot?#iefix') format('embedded-opentype'),
|
27
|
-
url('public/fonts/novecento-bold.woff') format('woff'),
|
28
|
-
url('public/fonts/novecento-bold.ttf') format('truetype');
|
29
|
-
font-weight: normal;
|
30
|
-
font-style: normal;
|
31
|
-
}
|
32
|
-
|
33
|
-
/*--------------------- Layout ----------------------------*/
|
34
|
-
html { height: 100%; }
|
35
|
-
body {
|
36
|
-
font-family: "aller-light";
|
37
|
-
font-size: 14px;
|
38
|
-
line-height: 18px;
|
39
|
-
color: #30404f;
|
40
|
-
margin: 0; padding: 0;
|
41
|
-
height:100%;
|
42
|
-
}
|
43
|
-
#container { min-height: 100%; }
|
44
|
-
|
45
|
-
a {
|
46
|
-
color: #000;
|
47
|
-
}
|
48
|
-
|
49
|
-
b, strong {
|
50
|
-
font-weight: normal;
|
51
|
-
font-family: "aller-bold";
|
52
|
-
}
|
53
|
-
|
54
|
-
p, ul, ol {
|
55
|
-
margin: 15px 0 0px;
|
56
|
-
}
|
57
|
-
|
58
|
-
h1, h2, h3, h4, h5, h6 {
|
59
|
-
color: #112233;
|
60
|
-
line-height: 1em;
|
61
|
-
font-weight: normal;
|
62
|
-
font-family: "novecento-bold";
|
63
|
-
text-transform: uppercase;
|
64
|
-
margin: 30px 0 15px 0;
|
65
|
-
}
|
66
|
-
|
67
|
-
h1 {
|
68
|
-
margin-top: 40px;
|
69
|
-
}
|
70
|
-
|
71
|
-
hr {
|
72
|
-
border: 0;
|
73
|
-
background: 1px solid #ddd;
|
74
|
-
height: 1px;
|
75
|
-
margin: 20px 0;
|
76
|
-
}
|
77
|
-
|
78
|
-
pre, tt, code {
|
79
|
-
font-size: 12px; line-height: 16px;
|
80
|
-
font-family: Menlo, Monaco, Consolas, "Lucida Console", monospace;
|
81
|
-
margin: 0; padding: 0;
|
82
|
-
}
|
83
|
-
.annotation pre {
|
84
|
-
display: block;
|
85
|
-
margin: 0;
|
86
|
-
padding: 7px 10px;
|
87
|
-
background: #fcfcfc;
|
88
|
-
-moz-box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
|
89
|
-
-webkit-box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
|
90
|
-
box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
|
91
|
-
overflow-x: auto;
|
92
|
-
}
|
93
|
-
.annotation pre code {
|
94
|
-
border: 0;
|
95
|
-
padding: 0;
|
96
|
-
background: transparent;
|
97
|
-
}
|
98
|
-
|
99
|
-
|
100
|
-
blockquote {
|
101
|
-
border-left: 5px solid #ccc;
|
102
|
-
margin: 0;
|
103
|
-
padding: 1px 0 1px 1em;
|
104
|
-
}
|
105
|
-
.sections blockquote p {
|
106
|
-
font-family: Menlo, Consolas, Monaco, monospace;
|
107
|
-
font-size: 12px; line-height: 16px;
|
108
|
-
color: #999;
|
109
|
-
margin: 10px 0 0;
|
110
|
-
white-space: pre-wrap;
|
111
|
-
}
|
112
|
-
|
113
|
-
ul.sections {
|
114
|
-
list-style: none;
|
115
|
-
padding:0 0 5px 0;;
|
116
|
-
margin:0;
|
117
|
-
}
|
118
|
-
|
119
|
-
/*
|
120
|
-
Force border-box so that % widths fit the parent
|
121
|
-
container without overlap because of margin/padding.
|
122
|
-
|
123
|
-
More Info : http://www.quirksmode.org/css/box.html
|
124
|
-
*/
|
125
|
-
ul.sections > li > div {
|
126
|
-
-moz-box-sizing: border-box; /* firefox */
|
127
|
-
-ms-box-sizing: border-box; /* ie */
|
128
|
-
-webkit-box-sizing: border-box; /* webkit */
|
129
|
-
-khtml-box-sizing: border-box; /* konqueror */
|
130
|
-
box-sizing: border-box; /* css3 */
|
131
|
-
}
|
132
|
-
|
133
|
-
|
134
|
-
/*---------------------- Jump Page -----------------------------*/
|
135
|
-
#jump_to, #jump_page {
|
136
|
-
margin: 0;
|
137
|
-
background: white;
|
138
|
-
-webkit-box-shadow: 0 0 25px #777; -moz-box-shadow: 0 0 25px #777;
|
139
|
-
-webkit-border-bottom-left-radius: 5px; -moz-border-radius-bottomleft: 5px;
|
140
|
-
font: 16px Arial;
|
141
|
-
cursor: pointer;
|
142
|
-
text-align: right;
|
143
|
-
list-style: none;
|
144
|
-
}
|
145
|
-
|
146
|
-
#jump_to a {
|
147
|
-
text-decoration: none;
|
148
|
-
}
|
149
|
-
|
150
|
-
#jump_to a.large {
|
151
|
-
display: none;
|
152
|
-
}
|
153
|
-
#jump_to a.small {
|
154
|
-
font-size: 22px;
|
155
|
-
font-weight: bold;
|
156
|
-
color: #676767;
|
157
|
-
}
|
158
|
-
|
159
|
-
#jump_to, #jump_wrapper {
|
160
|
-
position: fixed;
|
161
|
-
right: 0; top: 0;
|
162
|
-
padding: 10px 15px;
|
163
|
-
margin:0;
|
164
|
-
}
|
165
|
-
|
166
|
-
#jump_wrapper {
|
167
|
-
display: none;
|
168
|
-
padding:0;
|
169
|
-
}
|
170
|
-
|
171
|
-
#jump_to:hover #jump_wrapper {
|
172
|
-
display: block;
|
173
|
-
}
|
174
|
-
|
175
|
-
#jump_page {
|
176
|
-
padding: 5px 0 3px;
|
177
|
-
margin: 0 0 25px 25px;
|
178
|
-
}
|
179
|
-
|
180
|
-
#jump_page .source {
|
181
|
-
display: block;
|
182
|
-
padding: 15px;
|
183
|
-
text-decoration: none;
|
184
|
-
border-top: 1px solid #eee;
|
185
|
-
}
|
186
|
-
|
187
|
-
#jump_page .source:hover {
|
188
|
-
background: #f5f5ff;
|
189
|
-
}
|
190
|
-
|
191
|
-
#jump_page .source:first-child {
|
192
|
-
}
|
193
|
-
|
194
|
-
/*---------------------- Low resolutions (> 320px) ---------------------*/
|
195
|
-
@media only screen and (min-width: 320px) {
|
196
|
-
.pilwrap { display: none; }
|
197
|
-
|
198
|
-
ul.sections > li > div {
|
199
|
-
display: block;
|
200
|
-
padding:5px 10px 0 10px;
|
201
|
-
}
|
202
|
-
|
203
|
-
ul.sections > li > div.annotation ul, ul.sections > li > div.annotation ol {
|
204
|
-
padding-left: 30px;
|
205
|
-
}
|
206
|
-
|
207
|
-
ul.sections > li > div.content {
|
208
|
-
background: #f5f5ff;
|
209
|
-
overflow-x:auto;
|
210
|
-
-webkit-box-shadow: inset 0 0 5px #e5e5ee;
|
211
|
-
box-shadow: inset 0 0 5px #e5e5ee;
|
212
|
-
border: 1px solid #dedede;
|
213
|
-
margin:5px 10px 5px 10px;
|
214
|
-
padding-bottom: 5px;
|
215
|
-
}
|
216
|
-
|
217
|
-
ul.sections > li > div.annotation pre {
|
218
|
-
margin: 7px 0 7px;
|
219
|
-
padding-left: 15px;
|
220
|
-
}
|
221
|
-
|
222
|
-
ul.sections > li > div.annotation p tt, .annotation code {
|
223
|
-
background: #f8f8ff;
|
224
|
-
border: 1px solid #dedede;
|
225
|
-
font-size: 12px;
|
226
|
-
padding: 0 0.2em;
|
227
|
-
}
|
228
|
-
}
|
229
|
-
|
230
|
-
/*---------------------- (> 481px) ---------------------*/
|
231
|
-
@media only screen and (min-width: 481px) {
|
232
|
-
#container {
|
233
|
-
position: relative;
|
234
|
-
}
|
235
|
-
body {
|
236
|
-
background-color: #F5F5FF;
|
237
|
-
font-size: 15px;
|
238
|
-
line-height: 21px;
|
239
|
-
}
|
240
|
-
pre, tt, code {
|
241
|
-
line-height: 18px;
|
242
|
-
}
|
243
|
-
p, ul, ol {
|
244
|
-
margin: 0 0 15px;
|
245
|
-
}
|
246
|
-
|
247
|
-
|
248
|
-
#jump_to {
|
249
|
-
padding: 5px 10px;
|
250
|
-
}
|
251
|
-
#jump_wrapper {
|
252
|
-
padding: 0;
|
253
|
-
}
|
254
|
-
#jump_to, #jump_page {
|
255
|
-
font: 10px Arial;
|
256
|
-
text-transform: uppercase;
|
257
|
-
}
|
258
|
-
#jump_page .source {
|
259
|
-
padding: 5px 10px;
|
260
|
-
}
|
261
|
-
#jump_to a.large {
|
262
|
-
display: inline-block;
|
263
|
-
}
|
264
|
-
#jump_to a.small {
|
265
|
-
display: none;
|
266
|
-
}
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
#background {
|
271
|
-
position: absolute;
|
272
|
-
top: 0; bottom: 0;
|
273
|
-
width: 350px;
|
274
|
-
background: #fff;
|
275
|
-
border-right: 1px solid #e5e5ee;
|
276
|
-
z-index: -1;
|
277
|
-
}
|
278
|
-
|
279
|
-
ul.sections > li > div.annotation ul, ul.sections > li > div.annotation ol {
|
280
|
-
padding-left: 40px;
|
281
|
-
}
|
282
|
-
|
283
|
-
ul.sections > li {
|
284
|
-
white-space: nowrap;
|
285
|
-
}
|
286
|
-
|
287
|
-
ul.sections > li > div {
|
288
|
-
display: inline-block;
|
289
|
-
}
|
290
|
-
|
291
|
-
ul.sections > li > div.annotation {
|
292
|
-
max-width: 350px;
|
293
|
-
min-width: 350px;
|
294
|
-
min-height: 5px;
|
295
|
-
padding: 13px;
|
296
|
-
overflow-x: hidden;
|
297
|
-
white-space: normal;
|
298
|
-
vertical-align: top;
|
299
|
-
text-align: left;
|
300
|
-
}
|
301
|
-
ul.sections > li > div.annotation pre {
|
302
|
-
margin: 15px 0 15px;
|
303
|
-
padding-left: 15px;
|
304
|
-
}
|
305
|
-
|
306
|
-
ul.sections > li > div.content {
|
307
|
-
padding: 13px;
|
308
|
-
vertical-align: top;
|
309
|
-
background: #f5f5ff;
|
310
|
-
border: none;
|
311
|
-
-webkit-box-shadow: none;
|
312
|
-
box-shadow: none;
|
313
|
-
}
|
314
|
-
|
315
|
-
.pilwrap {
|
316
|
-
position: relative;
|
317
|
-
display: inline;
|
318
|
-
}
|
319
|
-
|
320
|
-
.pilcrow {
|
321
|
-
font: 12px Arial;
|
322
|
-
text-decoration: none;
|
323
|
-
color: #454545;
|
324
|
-
position: absolute;
|
325
|
-
top: 3px; left: -20px;
|
326
|
-
padding: 1px 2px;
|
327
|
-
opacity: 0;
|
328
|
-
-webkit-transition: opacity 0.2s linear;
|
329
|
-
}
|
330
|
-
.for-h1 .pilcrow {
|
331
|
-
top: 47px;
|
332
|
-
}
|
333
|
-
.for-h2 .pilcrow, .for-h3 .pilcrow, .for-h4 .pilcrow {
|
334
|
-
top: 35px;
|
335
|
-
}
|
336
|
-
|
337
|
-
ul.sections > li > div.annotation:hover .pilcrow {
|
338
|
-
opacity: 1;
|
339
|
-
}
|
340
|
-
}
|
341
|
-
|
342
|
-
/*---------------------- (> 1025px) ---------------------*/
|
343
|
-
@media only screen and (min-width: 1025px) {
|
344
|
-
|
345
|
-
body {
|
346
|
-
font-size: 16px;
|
347
|
-
line-height: 24px;
|
348
|
-
}
|
349
|
-
|
350
|
-
#background {
|
351
|
-
width: 525px;
|
352
|
-
}
|
353
|
-
ul.sections > li > div.annotation {
|
354
|
-
max-width: 525px;
|
355
|
-
min-width: 525px;
|
356
|
-
padding: 10px 25px 1px 50px;
|
357
|
-
}
|
358
|
-
ul.sections > li > div.content {
|
359
|
-
padding: 9px 15px 16px 25px;
|
360
|
-
}
|
361
|
-
}
|
362
|
-
|
363
|
-
/*---------------------- Syntax Highlighting -----------------------------*/
|
364
|
-
|
365
|
-
td.linenos { background-color: #f0f0f0; padding-right: 10px; }
|
366
|
-
span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; }
|
367
|
-
/*
|
368
|
-
|
369
|
-
github.com style (c) Vasily Polovnyov <vast@whiteants.net>
|
370
|
-
|
371
|
-
*/
|
372
|
-
|
373
|
-
pre code {
|
374
|
-
display: block; padding: 0.5em;
|
375
|
-
color: #000;
|
376
|
-
background: #f8f8ff
|
377
|
-
}
|
378
|
-
|
379
|
-
pre .comment,
|
380
|
-
pre .template_comment,
|
381
|
-
pre .diff .header,
|
382
|
-
pre .javadoc {
|
383
|
-
color: #408080;
|
384
|
-
font-style: italic
|
385
|
-
}
|
386
|
-
|
387
|
-
pre .keyword,
|
388
|
-
pre .assignment,
|
389
|
-
pre .literal,
|
390
|
-
pre .css .rule .keyword,
|
391
|
-
pre .winutils,
|
392
|
-
pre .javascript .title,
|
393
|
-
pre .lisp .title,
|
394
|
-
pre .subst {
|
395
|
-
color: #954121;
|
396
|
-
/*font-weight: bold*/
|
397
|
-
}
|
398
|
-
|
399
|
-
pre .number,
|
400
|
-
pre .hexcolor {
|
401
|
-
color: #40a070
|
402
|
-
}
|
403
|
-
|
404
|
-
pre .string,
|
405
|
-
pre .tag .value,
|
406
|
-
pre .phpdoc,
|
407
|
-
pre .tex .formula {
|
408
|
-
color: #219161;
|
409
|
-
}
|
410
|
-
|
411
|
-
pre .title,
|
412
|
-
pre .id {
|
413
|
-
color: #19469D;
|
414
|
-
}
|
415
|
-
pre .params {
|
416
|
-
color: #00F;
|
417
|
-
}
|
418
|
-
|
419
|
-
pre .javascript .title,
|
420
|
-
pre .lisp .title,
|
421
|
-
pre .subst {
|
422
|
-
font-weight: normal
|
423
|
-
}
|
424
|
-
|
425
|
-
pre .class .title,
|
426
|
-
pre .haskell .label,
|
427
|
-
pre .tex .command {
|
428
|
-
color: #458;
|
429
|
-
font-weight: bold
|
430
|
-
}
|
431
|
-
|
432
|
-
pre .tag,
|
433
|
-
pre .tag .title,
|
434
|
-
pre .rules .property,
|
435
|
-
pre .django .tag .keyword {
|
436
|
-
color: #000080;
|
437
|
-
font-weight: normal
|
438
|
-
}
|
439
|
-
|
440
|
-
pre .attribute,
|
441
|
-
pre .variable,
|
442
|
-
pre .instancevar,
|
443
|
-
pre .lisp .body {
|
444
|
-
color: #008080
|
445
|
-
}
|
446
|
-
|
447
|
-
pre .regexp {
|
448
|
-
color: #B68
|
449
|
-
}
|
450
|
-
|
451
|
-
pre .class {
|
452
|
-
color: #458;
|
453
|
-
font-weight: bold
|
454
|
-
}
|
455
|
-
|
456
|
-
pre .symbol,
|
457
|
-
pre .ruby .symbol .string,
|
458
|
-
pre .ruby .symbol .keyword,
|
459
|
-
pre .ruby .symbol .keymethods,
|
460
|
-
pre .lisp .keyword,
|
461
|
-
pre .tex .special,
|
462
|
-
pre .input_number {
|
463
|
-
color: #990073
|
464
|
-
}
|
465
|
-
|
466
|
-
pre .builtin,
|
467
|
-
pre .constructor,
|
468
|
-
pre .built_in,
|
469
|
-
pre .lisp .title {
|
470
|
-
color: #0086b3
|
471
|
-
}
|
472
|
-
|
473
|
-
pre .preprocessor,
|
474
|
-
pre .pi,
|
475
|
-
pre .doctype,
|
476
|
-
pre .shebang,
|
477
|
-
pre .cdata {
|
478
|
-
color: #999;
|
479
|
-
font-weight: bold
|
480
|
-
}
|
481
|
-
|
482
|
-
pre .deletion {
|
483
|
-
background: #fdd
|
484
|
-
}
|
485
|
-
|
486
|
-
pre .addition {
|
487
|
-
background: #dfd
|
488
|
-
}
|
489
|
-
|
490
|
-
pre .diff .change {
|
491
|
-
background: #0086b3
|
492
|
-
}
|
493
|
-
|
494
|
-
pre .chunk {
|
495
|
-
color: #aaa
|
496
|
-
}
|
497
|
-
|
498
|
-
pre .tex .formula {
|
499
|
-
opacity: 0.5;
|
500
|
-
}
|
@@ -1,177 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
|
3
|
-
<html>
|
4
|
-
<head>
|
5
|
-
<title>Sumatra</title>
|
6
|
-
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
7
|
-
<meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
|
8
|
-
<link rel="stylesheet" media="all" href="docco.css" />
|
9
|
-
</head>
|
10
|
-
<body>
|
11
|
-
<div id="container">
|
12
|
-
<div id="background"></div>
|
13
|
-
|
14
|
-
<ul class="sections">
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
<li id="section-1">
|
19
|
-
<div class="annotation">
|
20
|
-
|
21
|
-
<div class="pilwrap for-h1">
|
22
|
-
<a class="pilcrow" href="#section-1">¶</a>
|
23
|
-
</div>
|
24
|
-
<h1>Sumatra</h1>
|
25
|
-
<p>Sumatra is a CoffeeScript framework for writing jQuery plugins harder,
|
26
|
-
better, faster, stronger.</p>
|
27
|
-
<p>You should use Sumatra if you...</p>
|
28
|
-
<ul>
|
29
|
-
<li>Encapsulate complex jQuery plugins in a service object and call an
|
30
|
-
instance of that service object for each DOM element the plugin
|
31
|
-
selector is passed</li>
|
32
|
-
<li>Enjoy test-driven development, clear code, and convention over
|
33
|
-
configuration</li>
|
34
|
-
<li>Believe unicorns are real</li>
|
35
|
-
</ul>
|
36
|
-
<h2>Why?</h2>
|
37
|
-
<p>A lot of jQuery plugins are written to encapsulate a simple bit of
|
38
|
-
functionality used throughout the application. But jQuery's syntax was
|
39
|
-
designed to improve the way people write JavaScript. CoffeeScript has a
|
40
|
-
similar goal, but approaches it from a different angle, it compiles its
|
41
|
-
syntax into JavaScript but does so in a safe, syntactically correct and
|
42
|
-
(mostly) readable way. This framework unites the two, and finally allows
|
43
|
-
jQuery developers to build plugins in CoffeeScript without making their
|
44
|
-
code look, well, downright ugly!</p>
|
45
|
-
<h2>The Goods</h2>
|
46
|
-
<p>
|
47
|
-
You came here for docs, right?
|
48
|
-
|
49
|
-
<ul>
|
50
|
-
<li><a href="plugin.js.html">SumatraPlugin</a></li>
|
51
|
-
<li><a href="runtime.js.html">sumatra()</a></li>
|
52
|
-
</ul>
|
53
|
-
</p>
|
54
|
-
<h2>Installation</h2>
|
55
|
-
<h3>Requirements</h3>
|
56
|
-
<ul>
|
57
|
-
<li>jQuery</li>
|
58
|
-
<li>CoffeeScript if you want to develop it..</li>
|
59
|
-
</ul>
|
60
|
-
<p>We recommend Bower for installing Sumatra as a component:</p>
|
61
|
-
<pre><code class="lang-bash">$ bower install sumatra</code></pre>
|
62
|
-
<p>However, you can also install Sumatra manually by just including the
|
63
|
-
<code>pkg/sumatra.js</code> file in your javascripts directory.</p>
|
64
|
-
<h2>Usage</h2>
|
65
|
-
<p>Sumatra values convention over configuration, and its usage revolves
|
66
|
-
around an established pattern that hopefully others will find useful.</p>
|
67
|
-
<h3>Defining a Basic Plugin</h3>
|
68
|
-
<p>After loading Sumatra, you can build jQuery plugins that are both clear
|
69
|
-
and superbly terse:</p>
|
70
|
-
<pre><code class="lang-coffeescript">sumatra 'clickMe', ->
|
71
|
-
class ClickMe extends SumatraPlugin
|
72
|
-
action: 'click'
|
73
|
-
perform: (event) =>
|
74
|
-
element_id = @element.attr('id') || '<div>'
|
75
|
-
alert "You just clicked #{element_id}!"</code></pre>
|
76
|
-
<p>All this plugin does is show an <code>alert()</code> when the element is clicked.
|
77
|
-
You can define a single action with <code>action:</code> and then define the
|
78
|
-
<code>perform()</code> event handler that binds to whatever action you've set
|
79
|
-
on the element.</p>
|
80
|
-
<p>To bind an element to this event, just call it like any normal
|
81
|
-
jQuery plugin:</p>
|
82
|
-
<pre><code class="lang-coffeescript">$('#my_element').clickMe();</code></pre>
|
83
|
-
<h3>Parameters</h3>
|
84
|
-
<p>You can also make plugins that pass in options. All Sumatra plugins
|
85
|
-
take an <code>options</code> hash as their only argument, regardless of whether
|
86
|
-
the service object uses them or not.</p>
|
87
|
-
<pre><code class="lang-coffeescript">sumatra 'ajaxSubmit', ->
|
88
|
-
class AjaxSubmit extends SumatraPlugin
|
89
|
-
action: 'submit'
|
90
|
-
mergeOptions: ->
|
91
|
-
@defaults = @_getFormDefaults()
|
92
|
-
_.extend(@options, @defaults)
|
93
|
-
|
94
|
-
perform: (event) =>
|
95
|
-
event.preventDefault()
|
96
|
-
event.stopPropagation()
|
97
|
-
$.ajax @options
|
98
|
-
|
99
|
-
_getFormDefaults: ->
|
100
|
-
{
|
101
|
-
url: @element.attr('action')
|
102
|
-
type: @element.attr('method')
|
103
|
-
error: (message, status, xhr) ->
|
104
|
-
console.log status, message, xhr
|
105
|
-
alert "#{status}: #{message}"
|
106
|
-
}</code></pre>
|
107
|
-
<p>This is an example of <a href="http://jquery.malsup.com/form">ajaxSubmit from the jQuery.form plugin</a>,
|
108
|
-
implemented using Sumatra. It would especially be useful when rendering
|
109
|
-
an inline response with JSON, using something such as Handlebars to
|
110
|
-
compile the JSON data into a logic-less client-side template...</p>
|
111
|
-
<pre><code class="lang-coffeescript">$('form').ajaxSubmit \
|
112
|
-
dataType: 'json'
|
113
|
-
success: (context) =>
|
114
|
-
template = Handlebars.compile $('#response_template')
|
115
|
-
response = template(context)
|
116
|
-
@element.html response</code></pre>
|
117
|
-
<h3>Basic Properties</h3>
|
118
|
-
<p>As a by-product of the jQuery instantation process, each <code>SumatraPlugin</code>
|
119
|
-
comes with the following three properties, for free:</p>
|
120
|
-
<ul>
|
121
|
-
<li><strong>element:</strong> References a single jQuery DOM Object, which can perform
|
122
|
-
basic functionality on the page. It is obtained from the collection of
|
123
|
-
objects which matched the plugin's selector upon instantiation.</li>
|
124
|
-
<li><strong>index:</strong> The index of the jQuery DOM Object in the collection of
|
125
|
-
objects which matched the plugin's selector upon instantiation.</li>
|
126
|
-
<li><strong>options:</strong> A Hash-notated Object obtained as the only argument in
|
127
|
-
the jQuery plugin when instantiated. This object is then merged with
|
128
|
-
the <code>defaults</code> hash, which are default params in the plugin's
|
129
|
-
definition, before initialization occurs.</li>
|
130
|
-
</ul>
|
131
|
-
<h3>Workflow</h3>
|
132
|
-
<p>Each SumatraPlugin has a "workflow" that is expressed as a series of
|
133
|
-
methods, all run in the <code>constructor</code> of the object. The constructor
|
134
|
-
is responsible for setup of the object's basic properties. This method
|
135
|
-
should never be overridden, instead, each step of the instantiation
|
136
|
-
process can be controlled by overriding one of the following methods:</p>
|
137
|
-
<ul>
|
138
|
-
<li><strong>mergeOptions:</strong> Merge the options with the defaults hash. You can
|
139
|
-
override this to use attributes from <code>@element</code> as defaults instead.</li>
|
140
|
-
<li><strong>initialize:</strong> The main override of the constructor method, this is
|
141
|
-
where one would actually "construct" the objects they are going to be
|
142
|
-
using in this plugin instance, bind events, and call helper methods.</li>
|
143
|
-
<li><strong>bindEvents:</strong> This is where the <code>action:</code> event should be bound in
|
144
|
-
some way. In many cases, this is overridden to bind other events as
|
145
|
-
well as the <code>action:</code>, or binding the event as a <code>$(document).on</code>.</li>
|
146
|
-
<li><strong>perform:</strong> The event handler of the plugin, this is normally called
|
147
|
-
when the <code>action:</code> event is fired, but it must be defined if it is
|
148
|
-
called or it will throw an error.</li>
|
149
|
-
</ul>
|
150
|
-
<p>You can define more methods, but these are the only public methods that
|
151
|
-
should be overridden. Any method beginning with <code>_</code> is considered
|
152
|
-
"private" and should not be overridden. Please carry this convention
|
153
|
-
to your own code as well.</p>
|
154
|
-
<h2>Development</h2>
|
155
|
-
<p>You can build this code into JavaScript by running the following
|
156
|
-
command at the root dir:</p>
|
157
|
-
<pre><code class="lang-bash">$ npm install && cake build</code></pre>
|
158
|
-
<h3>Contributions</h3>
|
159
|
-
<p>Contributions will be accepted via Git/GitHub pull requests, as long as
|
160
|
-
you write tests that prove your contributions work. We use Jasmine to
|
161
|
-
write tests in CoffeeScript (you know, for the actual framework?) and
|
162
|
-
RSpec to write tests for the Rails helpers.</p>
|
163
|
-
<h3>Releases</h3>
|
164
|
-
<p>All releases will be made in both CoffeeScript and JavaScript, and
|
165
|
-
available simultaneously on the Bower and RubyGems package managers.
|
166
|
-
We use Bower to manage the standalone JavaScript code which has no
|
167
|
-
dependency on Sprockets, Rails, or anything Ruby.</p>
|
168
|
-
<p>This code is released under the <a href="https://github.com/tubbo/sumatra/blob/master/LICENSE.md">MIT License</a>.</p>
|
169
|
-
|
170
|
-
</div>
|
171
|
-
|
172
|
-
</li>
|
173
|
-
|
174
|
-
</ul>
|
175
|
-
</div>
|
176
|
-
</body>
|
177
|
-
</html>
|
File without changes
|