-
Notifications
You must be signed in to change notification settings - Fork 368
Expand file tree
/
Copy pathtie.html
More file actions
114 lines (105 loc) · 2.74 KB
/
tie.html
File metadata and controls
114 lines (105 loc) · 2.74 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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>tie</title>
<style type='text/css'>
body {font-family: verdana}
.error {border: solid 1px red;}
.error_text { color: red; font-size: 10px;}
td {padding: 3px;}
#sliderWrapper {
border: solid 1px gray;
width: 300px;
height: 30px;
}
.mxui_slider {
width: 30px;
height: 30px;
background-color: green;
}
.rating .selected {
font-size: 20px;
font-weight: bold;
color: red;
}
</style>
</head>
<body>
<div id='sliderWrapper'><div id='age1'></div></div>
<div id='rating'></div>
<input type='text' id='age2' />
<textarea id='age3'></textarea>
<select id='age4'>
<option value='1'>1</option>
<option value='2'>2</option>
<option value='3'>3</option>
<option value='4'>4</option>
<option value='5'>5</option>
<option value='6'>6</option>
<option value='7'>7</option>
<option value='8'>8</option>
<option value='9'>9</option>
<option value='10'>10</option>
</select>
<script type='text/javascript'
src='../../steal/steal.js'>
steal('jquery/model','jquery/tie','mxui/slider').then(function(){
$.Model.extend("Person",{
init : function(){
this.validateFormatOf(["email"], /\w+\@\w+\.(com|net)/, "not a valid email")
this.validate("birthday",function(){
if(this.birthday > new Date){
return "your birthday needs to be in the past"
}
})
}
},{
setAge : function(age, success, error){
age = +(age);
if(isNaN(age) || !isFinite(age) || age < 1 || age > 10){
error()
}else{
$.ajax({
url: "/update/age",
data: {
age: age
},
success: success,
error: error
})
}
}
});
$.Controller.extend("Rating",{
init : function(){
var html = [];
for(var i =0; i < 15; i++){
html.push("<a href='javascript://'>"+(i+1)+".</a>")
}
this.element.html(html.join(" "))
},
val : function(num){
var selected = this.element.find(".selected");
if(num){
selected.removeClass("selected");
this.element.find("a").eq(num-1)
.addClass("selected")
}else{
return selected.text();
}
},
"a click" : function(el){
this.element.find(".selected").removeClass('selected');
el.addClass('selected');
this.element.trigger("change",el.text())
}
})
person = new Person({age: 1});
$("#age1").mxui_slider({interval: 1, min: 1, max: 10});
$("#rating").rating();
$("#age1, #age2, #age3, #age4, #rating").tie(person,"age")
})
</script>
</body>
</html>