Skip to content

Commit e739fe6

Browse files
committed
added: new examples
1 parent bbafcf1 commit e739fe6

11 files changed

Lines changed: 125 additions & 0 deletions

File tree

changes.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,19 @@ IN DEVELOPMENT ======= ???
88
- added: framework.assert(name, callback)
99
- added: framework.assert(name, url, callback, method, data, headers, xhr)
1010
- added: framework.injectComponent(name, url)
11+
- added: framework.path.components([filename])
1112

13+
- updated: framework.usage([detailed])
1214
- updated: BINARY
1315

1416
- fixed: // char in views and templates
1517
- fixed: assertion testing
1618

1719
improvements: views (in release mode)
1820

21+
- EXAMPLE (NEW): https://github.com/petersirka/total.js/tree/master/examples/components
22+
- EXAMPLE (NEW): https://github.com/petersirka/total.js/tree/master/examples/minimal
23+
1924
======= 1.0.2 (HOTFIX)
2025

2126
- fixed: mail message (problem with diacritics in OUTLOOK)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
var module_name = '';
2+
3+
exports.install = function(framework, name, directory) {
4+
module_name = name;
5+
};
6+
7+
exports.render = function(model) {
8+
var self = this;
9+
return self.view('.' + self.path.components(module_name + '/template'), model, true);
10+
};
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<div>Name:</div>
2+
<div>@{text('name')}</div>
3+
<br />
4+
<div>Email:</div>
5+
<div>@{text('email')}</div>
6+
<br />
7+
<div>Message:</div>
8+
<div>@{textarea('message')}</div>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
var configuration = { class: 'grid' };
2+
3+
exports.install = function(framework) {
4+
// @#auto-vendor-prefix#@ = framework automatically adds prefixes
5+
framework.fs.create.css('grid', '@#auto-vendor-prefix#@\n.grid{width:100%;border:1px solid #E0E0E0;border-right:0;border-bottom:0;font:normal 11px Arial;color:gray}.grid td{border:1px solid #E0E0E0;border-left:0;border-top:0;padding:5px 8px}', true);
6+
};
7+
8+
exports.configure = function(obj) {
9+
utils.extend(configuration, obj);
10+
};
11+
12+
exports.render = function(data) {
13+
14+
// this === controller
15+
var self = this;
16+
17+
// I created grid.css in exports.install
18+
// This function adds grid.css into HTML @{head}
19+
self.head('grid.css');
20+
21+
var builder = '<table width="100%" cellspacing="0" cellpadding="0" border="0" class="' + configuration.class + '">';
22+
var length = data.length;
23+
24+
for (var i = 0; i < length; i++)
25+
builder += '<tr><td>' + data[i] + '</td></tr>';
26+
27+
return builder + '</table>';
28+
};
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
exports.install = function(framework) {
2+
framework.route('/', view_homepage);
3+
framework.route('/custom/', plain_custom);
4+
};
5+
6+
function view_homepage() {
7+
var self = this;
8+
self.view('homepage');
9+
}
10+
11+
function plain_custom() {
12+
var self = this;
13+
self.plain(self.component('grid', [1, 2, 3, 4, 5]));
14+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
framework.component('grid').configure({ class: 'grid' });

examples/components/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
var framework = require('total.js');
2+
var http = require('http');
3+
4+
var port = 8004;
5+
var debug = true;
6+
7+
framework.run(http, debug, port);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
body { padding: 20px; }
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
@{meta}
5+
<meta charset="utf-8" />
6+
<meta http-equiv="X-UA-Compatible" content="IE=10" />
7+
<meta name="format-detection" content="telephone=no"/>
8+
<meta name="viewport" content="width=1024, user-scalable=yes" />
9+
<meta name="robots" content="all,follow" />
10+
@{head}
11+
@{css('default.css')}
12+
</head>
13+
<body>
14+
15+
<div>@{body}</div>
16+
17+
</body>
18+
</html>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@{meta('Component example')}
2+
3+
<div>
4+
<h1>Component example</h1>
5+
<br />
6+
<h2>Grid</h2>
7+
@{component('grid', [1, 2, 3, 4, 5])}
8+
<br />
9+
<h2>Contact form</h2>
10+
@{component('contactform', { Email: '@' })}
11+
</div>

0 commit comments

Comments
 (0)