-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
484 lines (412 loc) · 15.4 KB
/
index.html
File metadata and controls
484 lines (412 loc) · 15.4 KB
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
<!DOCTYPE html>
<html>
<head>
<title>Mog - Markup Object Generator</title>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="assets/css/styles.css">
</head>
<body>
<div class="box">
<h1 class="wrapper">Using Mog</h1>
</div>
<div class="box">
<div class="wrapper cf">
<h2>Setup</h2>
<code class="code-block">
<pre>
<script>
var Demo = Mog.extend({
initialize: function () {
this.sync();
}
});
var demo = new Demo("demo");
</script>
</pre>
</code>
<div class="half">
<p>
Mog does a lot of things for you while providing a powerful, event-driven
platform to expand upon.
</p>
<p>
To get started with Mog all we have to do is pass <code>Mog.extend()</code> an
object containing an <code>initialize</code> function. This simply gives Mog some
code to run when you use the <code>new</code> keyword.
</p>
<p>
When we pass the string <code>"demo"</code> to <code>new Demo()</code> and call
<code>sync()</code> in our <code>initialize</code> function, Mog looks through
your HTML and generates a model.
</p>
<p>
You'll see how Mog takes <code>"demo"</code> and uses it to generate an object.
</p>
</div>
</div>
</div>
<div class="box">
<div class="wrapper cf">
<h2>Moving one value</h2>
<div class="half">
<p>
Mog moves input values into HTML.
</p>
</div>
<div class="half clear">
<h3>Input</h3>
<input type="text" data-mog-input="demo[name]" value="Bob">
</div>
<div class="half">
<h3>Output</h3>
<span data-mog-output="demo[name]">Bob</span>
</div>
<div class="half clear">
<h3>HTML</h3>
<code class="code-block">
<input type="text" data-mog-input="demo[name]" value="Bob">
<br>
<em>…</em>
<br>
<span data-mog-output="demo[name]">Bob</span>
</code>
</div>
<div class="half">
<p>
The <code>data-mog-input</code> attribute tells Mog that this HTML element
generates a property value. The first part of the value, <code>demo</code>,
tells Mog to listen to this element when we call <code>sync()</code>.
The second piece, <code>[name]</code>, tells Mog which property the HTML
element is associated with. In this case, Bob.
</p>
<p>
The <code>data-mog-output</code> behaves basically the same way, but tells Mog
to place values into the element instead of retrieve values from it.
</p>
</div>
</div>
</div>
<div class="box">
<div class="wrapper cf">
<h2>Moving many values</h2>
<div class="half">
<p>
Mog moves many input values into many HTML elements. Any Mog input has this
ability.
</p>
</div>
<div class="half clear">
<h3>Input</h3>
<input type="text" data-mog-input="demo[name-x]" value="Dave">
<br>
<input type="text" data-mog-input="demo[name-x]" value="Dave">
<br>
<input type="text" data-mog-input="demo[name-x]" value="Dave">
</div>
<div class="half">
<h3>Output</h3>
<strong data-mog-output="demo[name-x]">Dave</strong>
<br>
<em data-mog-output="demo[name-x]">Dave</em>
</div>
<div class="half clear">
<h3>HTML</h3>
<code class="code-block">
<input type="text" data-mog-input="demo[name-x]" value="Dave">
<input type="text" data-mog-input="demo[name-x]" value="Dave">
<input type="text" data-mog-input="demo[name-x]" value="Dave">
<br>
<em>…</em>
<br>
<strong data-mog-output="demo[name-x]">Dave</strong>
<br>
<em data-mog-output="demo[name-x]">Dave</em>
</code>
</div>
</div>
</div>
<div class="box">
<div class="wrapper cf">
<h2>Moving textarea values</h2>
<div class="half">
<p>
Mog moves textarea values into HTML.
</p>
</div>
<div class="half clear">
<h3>Input</h3>
<textarea data-mog-input="demo[about]">A little about me.</textarea>
</div>
<div class="half">
<h3>Output</h3>
<p data-mog-output="demo[about]">
A little about me.
</p>
</div>
<div class="half clear">
<h3>HTML</h3>
<code class="code-block">
<textarea data-mog-input="demo[about]">A little about me.</textarea>
<br>
<em>…</em>
<br>
<p data-mog-output="demo[about]">
<br>
A little about me.
<br>
</p>
</code>
</div>
</div>
</div>
<div class="box">
<div class="wrapper cf">
<h2>Moving select value</h2>
<div class="half">
<p>
Mog can move the value of a select.
</p>
</div>
<div class="half clear">
<h3>Input</h3>
<select data-mog-input="demo[food]">
<option value="None">None</option>
<option value="Burger">Burger</option>
<option value="Salad">Salad</option>
<option value="Pizza">Pizza</option>
</select>
</div>
<div class="half">
<h3>Output</h3>
<span data-mog-output="demo[food]">None</span>
</div>
<div class="half clear">
<h3>HTML</h3>
<code class="code-block">
<pre>
<select data-mog-input="demo[food]">
<option value="None">None</option>
<option value="Burger">Burger</option>
<option value="Salad">Salad</option>
<option value="Pizza">Pizza</option>
</select>
<em>…</em>
<span data-mog-output="demo[food]">None</span>
</pre>
</code>
</div>
</div>
</div>
<div class="box">
<div class="wrapper cf">
<h2>Moving multiple select values</h2>
<div class="half">
<p>
Mog can move the values of a multiple select.
</p>
</div>
<div class="half clear">
<h3>Input</h3>
<select multiple data-mog-input="demo[food-x]">
<option value="Soda">Soda</option>
<option selected value="Water">Water</option>
<option selected value="Tea">Tea</option>
<option value="Coffee">Coffee</option>
</select>
</div>
<div class="half">
<h3>Output</h3>
<span data-mog-output="demo[food-x]">Tea, Water</span>
</div>
<div class="half clear">
<h3>HTML</h3>
<code class="code-block">
<pre>
<select multiple data-mog-input="demo[food]">
<option value="Soda">Soda</option>
<option value="Water">Water</option>
<option value="Tea">Tea</option>
<option value="Coffee">Coffee</option>
</select>
<em>…</em>
<span data-mog-output="demo[food]">None</span>
</pre>
</code>
</div>
</div>
</div>
<div class="box">
<div class="wrapper cf">
<h2>Moving checkbox values</h2>
<div class="half">
<p>
Mog can move the value of a checkbox.
</p>
</div>
<div class="half clear">
<h3>Input</h3>
<input data-mog-input="demo[like-it]" type="checkbox" value="Like it"> Like it
<br>
<input data-mog-input="demo[love-it]" type="checkbox" checked value="Love it"> Love it
</div>
<div class="half">
<h3>Output</h3>
<span data-mog-output="demo[like-it]"></span>
<br>
<span data-mog-output="demo[love-it]">Love it</span>
</div>
<div class="half clear">
<h3>HTML</h3>
<code class="code-block">
<pre>
<nput data-mog-input="demo[like-it]" type="checkbox" value="Like it"> Like it
<input data-mog-input="demo[love-it]" type="checkbox" checked value="Love it"> Love it
<em>…</em>
<span data-mog-output="demo[like-it]"></span>
<span data-mog-output="demo[love-it]">Love it</span>
</pre>
</code>
</div>
</div>
</div>
<div class="box">
<div class="wrapper cf">
<h2>Moving radio values</h2>
<div class="half">
<p>
Mog can move the value of a radio button group.
</p>
</div>
<div class="half clear">
<h3>Input</h3>
Computers?
<br>
<input data-mog-input="demo[computers]" type="radio" name="computers" value="Yes"> Yes
<br>
<input data-mog-input="demo[computers]" type="radio" name="computers" checked value="No"> No
</div>
<div class="half">
<h3>Output</h3>
<span data-mog-output="demo[computers]">No</span>
</div>
<div class="half clear">
<h3>HTML</h3>
<code class="code-block">
<pre>
<input data-mog-input="demo[computers]" type="radio" name="computers" value="Yes"> Yes
<input data-mog-input="demo[computers]" type="radio" name="computers" checked value="No"> No
<em>…</em>
<span data-mog-output="demo[computers]">No</span>
</pre>
</code>
</div>
</div>
</div>
<div class="box">
<div class="wrapper cf">
<h2>Let's get more complex</h2>
<div class="half">
<p>
Since Mog emits events like a fat kid loves cake, we easily create more
interactions.
</p>
</div>
<div class="half clear">
<h3>Input</h3>
<p>
When are you available?
</p>
<p>
<input data-mog-input="demo[days-weekends]" type="checkbox" value="Weekends"> Weekends
<input data-mog-input="demo[days-weekdays]" type="checkbox" value="Weekdays"> Weekdays
</p>
<p>
<input data-mog-input="demo[days-sunday]" type="checkbox" value="Sunday"> Su
<input data-mog-input="demo[days-monday]" type="checkbox" value="Monday"> Mo
<input data-mog-input="demo[days-tuesday]" type="checkbox" value="Tuesday"> Tu
<input data-mog-input="demo[days-wednesday]" type="checkbox" value="Wednesday"> We
<input data-mog-input="demo[days-thursday]" type="checkbox" value="Thursday"> Th
<input data-mog-input="demo[days-friday]" type="checkbox" value="Friday"> Fr
<input data-mog-input="demo[days-saturday]" type="checkbox" value="Saturday"> Sa
</p>
</div>
<div class="half">
<h3>Output</h3>
<span data-mog-output="demo[computers]">No</span>
</div>
<div class="half clear">
<h3>HTML</h3>
<code class="code-block">
<pre>
<input data-mog-input="demo[computers]" type="radio" name="computers" value="Yes"> Yes
<input data-mog-input="demo[computers]" type="radio" name="computers" checked value="No"> No
<em>…</em>
<span data-mog-output="demo[computers]">No</span>
</pre>
</code>
</div>
</div>
</div>
<script type="text/javascript" src="mog.js"></script>
<script>
var Demo = Mog.extend({
// starting to flesh out what a collection might be here
// an object with a string value, collection.test
// an object with a boolean vlaue, collection.checked
setWeekends: function (value) {
var setTo = ( value === "Weekends" || value === true ) ? true : false;
this.set({
"days-saturday": setTo,
"days-sunday": setTo
}, true );
},
setWeekdays: function (value) {
var setTo = ( value === "Weekdays" || value === true ) ? true : false;
this.set({
"days-monday": setTo,
"days-tuesday": setTo,
"days-wednesday": setTo,
"days-thursday": setTo,
"days-friday": setTo
}, true);
},
setWeekday: function () {
if ( this.get("days-monday") && this.get("days-tuesday") && this.get("days-wednesday") && this.get("days-thursday") && this.get("days-friday") ) {
this.set({
"days-weekdays": true
}, true );
} else {
this.set({
"days-weekdays": false
}, true );
}
},
setWeekend: function () {
if ( this.get("days-sunday") && this.get("days-saturday") ) {
this.set({
"days-weekends": true
}, true );
} else {
this.set({
"days-weekends": false
}, true );
}
},
initialize: function () {
this.on( "set.days-weekends", this.setWeekends.bind(this) )
.on( "set.days-weekdays", this.setWeekdays.bind(this) )
.on( "set.days-monday, set.days-tuesday, set.days-wednesday, set.days-thursday, set.days-friday", this.setWeekday.bind(this) )
.on( "set.days-sunday, set.days-saturday", this.setWeekend.bind(this) );
this.sync();
}
});
var demo = new Demo("demo");
</script>
</body>
</html>