Repository navigation
Expand file tree
/
Copy pathtest.html
More file actions
143 lines (124 loc) · 3.97 KB
/
Copy pathtest.html
File metadata and controls
143 lines (124 loc) · 3.97 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
<!doctype html>
<html>
<head>
</head>
<body data-ng-app="test">
<div data-hyper=".translations as t">
<div data-hyper-translate="t.simple"></div>
<div data-hyper-translate="t.param <- .username"></div>
<div data-ng-scope data-ng-init="foo = {smart_count: 0}">
<input data-ng-model="foo.smart_count" type="number" />
<span data-hyper-translate="t.cars <- foo.smart_count"></span>
</div>
<div data-ng-scope data-ng-init="goal = {smart_count: 0}">
<input data-ng-model="goal.smart_count" type="number" />
<span data-hyper-translate="t.goals <- goal.smart_count"></span>
</div>
<div data-ng-scope data-ng-init="templateValue = 'templated'">
<input data-ng-model="templateValue" />
<span data-hyper-translate="t.{{templateValue}}"></span>
</div>
<div data-ng-scope data-ng-init="name = 'Mike'">
<input data-ng-model="name" />
<span data-hyper-translate="t.param <- name as username"></span>
</div>
<div data-ng-scope data-ng-init="val = {time: '2014-11-14'}">
<input data-ng-model="val.time" type="date" />
<span data-hyper-translate="t.relative <- val.time"></span>
</div>
<div data-autoincrement data-ng-init="user = {name: 'Robert'}">
<input data-ng-model="user.name" />
<span data-hyper-translate="t.relative <- user.name, val.time"></span>
</div>
<input type=submit data-hyper-translate="value -> t.create" />
<div data-hyper-translate="t.param <- .username">
<span name="username">
<a href="#" data-ng-bind="username"></a>
</span>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.20/angular.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.20/angular-mocks.js"></script>
<script src="./build/build.js"></script>
<script>
BROWSER_ENV = 'development';
require('ng-hyper');
var app = angular.module('test', ['ng-hyper', 'ng-hyper-translate']);
app.provider({
'$httpBackend': angular.mock.$HttpBackendProvider,
'hyperHttpRoot': function () {
return {$get: function(){return '/api'}}
}
});
app.directive('autoincrement', function() {
return {
scope: true,
link: function($scope, el, attr) {
$scope.val = {time: Date.now()};
}
}
});
var t = {
simple: 'Simple Translation',
param: 'Hello, %{username}',
templated: 'This is a templated value',
cars: [
'%{smart_count} car',
'%{smart_count} cars'
],
goals: {
_format: 'ordinal',
one: '%{smart_count}st goal',
two: '%{smart_count}nd goal',
few: '%{smart_count}rd goal',
other: '%{smart_count}th goal'
},
create: 'Create',
relative: {
_format: 'relative',
future: 'in %{time} %{name} will post',
past: '%{name} posted %{time} ago',
s: {
one: 'a second',
other: '%{time} seconds'
},
m: {
one: 'a minute',
other: '%{time} minutes'
},
h: {
one: 'a hour',
other: '%{time} hours'
},
d: {
one: 'a day',
other: '%{time} days'
},
M: {
one: 'a month',
other: '%{time} months'
},
y: {
one: 'a year',
other: '%{time} years'
}
}
};
var root = {
href: '/api',
username: 'Joe',
translations: t
};
app.run([
'$httpBackend',
function(http) {
http.whenGET('/api').respond(root);
setTimeout(function(){
http.flush();
}, 100);
}
]);
//app.bootstrap(document, ['test']);
</script>
</body>
</html>