Skip to content

Commit b233e02

Browse files
change to md
1 parent b3a75da commit b233e02

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

README.md

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
A library for scope declaration like activerecord 3.
2+
3+
It can be used for declare scopes and behaviors that can be attached to dom object.
4+
5+
Some examples:
6+
7+
append style css to dom objects
8+
9+
```
10+
$.fn.declare.add({
11+
'set.color': function(color) {
12+
return this.css({
13+
'color': color
14+
});
15+
},
16+
'set.bgcolor': function(color) {
17+
return this.css({
18+
'background-color': color
19+
});
20+
}
21+
});
22+
23+
$("div.title").declare('set.color', 'yellow').declare('set.bgcolor', 'red');
24+
```
25+
26+
append events e style to table
27+
28+
```
29+
$.fn.declare.add({
30+
'row.alternate': function(opt) {
31+
this.find("tr.odd")
32+
.css("background-color",opt.odd_color)
33+
.end()
34+
.find("tr.even")
35+
.css("background-color",opt.even_color);
36+
}
37+
});
38+
39+
$.fn.declare.add({
40+
'row.hover':function(color_hover) {
41+
this.hover(
42+
function() {
43+
var that=$(this);
44+
that.data("old-bg",that.css("background-color"));
45+
that.css("background-color",color_hover);
46+
},
47+
function() {
48+
var that=$(this);
49+
that.css("background-color", that.data("old-bg"));
50+
}
51+
)
52+
}
53+
});
54+
55+
$("table")
56+
.declare('row.alternate',{
57+
odd_color:'#ff0000',
58+
even_color:'#00ff00'
59+
})
60+
.find("tr")
61+
.declare("row.hover","#0000ff");
62+
```

0 commit comments

Comments
 (0)