-
Notifications
You must be signed in to change notification settings - Fork 234
/
Element.Shortcuts.html
164 lines (160 loc) · 4.01 KB
/
Element.Shortcuts.html
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
<style>
#foo-container {
top: 50px;
left: 450px;
position: absolute;
}
#foo {
width: 200px;
height: 200px;
border: 2px solid black;
padding: 10px;
}
.blackText {
color: #000;
}
.blueText {
color: #00f;
}
#logContaner {
position: absolute;
left: 450px;
top: 280px;
}
#hidden_foo {
display: none;
width: 200px;
height: 40px;
border: 2px solid black;
padding: 10px;
margin-top: 10px;
}
</style>
<div id="foo-container">
<div id="foo" class="blackText">
This is a bunch of text. This is a bunch of text. This is a bunch of text. This is a bunch of text. This is a bunch of text. This is a bunch of text. This is a bunch of text. This is a bunch of text. This is a bunch of text. This is a bunch of text. This is a bunch of text. This is a bunch of text. This is a bunch of text. This is a bunch of text. This is a bunch of text.
</div>
<div id="hidden_foo">I am hidden by CSS.</div>
</div>
<div id="logContaner" class="blueText"></div>
<script src="/depender/build?require=More/Element.Shortcuts,Core/Element.Event"></script>
<script>
var log = function(msg){
$('logContaner').adopt(new Element('p', {text: msg}));
};
var reset = function(element){
element.eliminate('element:_originalDisplay');
};
makeActions([
{
title: "Element.hide",
description: "Switches an element from display:block|inline|etc to display:none",
fn: function(){
$('foo').setStyle('display','block');
$('foo').hide();
}
},
{
title: "Element.show",
description: "Switches an element from display:none to display:block",
fn: function(){
$('foo').setStyle('display','none');
$('foo').show();
}
},
{
title: "Element.hide twice",
description: "Hides an element twice and then shows it after a pause",
fn: function(){
$('foo').show();
reset($('foo'));
$('foo').hide();
$('foo').hide();
(function(){
$('foo').show();
}).delay(250);
}
},
{
title: "Element.show: show an element hidden by css",
description: "Takes an element with a css class that has a display:none definition and shows it to display:block.",
fn: function(){
$('hidden_foo').show();
}
},
{
title: "Element.show(type)",
description: "Switches an element from display:none to display:inline. (It switches back after a second.)",
fn: function(){
$('foo').hide();
$('foo').show('inline');
(function(){
$('foo').setStyle('display', 'block');
}).delay(1000);
}
},
{
title: "Element.toggle",
description: "Toggles between display:none and block.",
fn: function(){
$('foo').toggle();
}
},
{
title: "Element.isDisplayed",
description: "Returns true if the element's display is not = none. (See log message displayed below after you click).",
fn: function(){
$('foo').hide();
if (!$('foo').isDisplayed()){
log('hide successful; foo is not visible');
} else {
log('either hide or isDisplayed failed');
$('foo').visTest = false;
}
$('foo').show();
$('foo').visTest = false;
if ($('foo').isDisplayed()){
log('show successful; foo is visible');
$('foo').visTest = true;
} else {
log('either show or isDisplayed failed');
$('foo').visTest = false;
}
}
},
{
title: "Element.isVisible",
description: "Returns true if the element is visible. (See log message displayed below after you click).",
fn: function(){
$('foo-container').hide();
if (!$('foo').isVisible()){
log('hide successful; foo is not visible');
} else {
log('either hide or isDisplayed failed');
}
$('foo-container').show();
if ($('foo').isVisible()){
log('show successful; foo is visible');
} else {
log('either show or isDisplayed failed');
}
}
},
{
title: 'Element.swapClass (blue)',
description: "Changes the text from black to blue.",
fn: function(){
$('foo').show();
$('foo').swapClass('blackText', 'blueText');
}
},
{
title: 'Element.swapClass (black)',
description: "Changes the text from blue to black.",
fn: function(){
$('foo').show();
$('foo').swapClass('blueText', 'blackText');
}
}
]);
</script>