formalize-rails 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README.md +24 -0
- data/Rakefile +1 -0
- data/formalize-rails.gemspec +22 -0
- data/lib/formalize/rails/engine.rb +6 -0
- data/lib/formalize/rails/version.rb +5 -0
- data/lib/formalize/rails.rb +7 -0
- data/lib/formalize-rails.rb +1 -0
- data/vendor/assets/images/button.png +0 -0
- data/vendor/assets/images/select_arrow.gif +0 -0
- data/vendor/assets/javascripts/dojo.formalize.js +166 -0
- data/vendor/assets/javascripts/dojo.formalize.min.js +1 -0
- data/vendor/assets/javascripts/extjs.formalize.js +163 -0
- data/vendor/assets/javascripts/extjs.formalize.min.js +1 -0
- data/vendor/assets/javascripts/jquery.formalize.js +150 -0
- data/vendor/assets/javascripts/jquery.formalize.min.js +1 -0
- data/vendor/assets/javascripts/mootools.formalize.js +155 -0
- data/vendor/assets/javascripts/mootools.formalize.min.js +1 -0
- data/vendor/assets/javascripts/prototype.formalize.js +163 -0
- data/vendor/assets/javascripts/prototype.formalize.min.js +1 -0
- data/vendor/assets/javascripts/yui.formalize.js +160 -0
- data/vendor/assets/javascripts/yui.formalize.min.js +1 -0
- data/vendor/assets/stylesheets/formalize.css +356 -0
- metadata +83 -0
@@ -0,0 +1,155 @@
|
|
1
|
+
/*
|
2
|
+
Formalize - version 1.1
|
3
|
+
|
4
|
+
Note: This file depends on the MooTools library.
|
5
|
+
*/
|
6
|
+
|
7
|
+
// Module pattern:
|
8
|
+
// http://yuiblog.com/blog/2007/06/12/module-pattern
|
9
|
+
var FORMALIZE = (function(window, document, undefined) {
|
10
|
+
// Private constants.
|
11
|
+
var PLACEHOLDER_SUPPORTED = 'placeholder' in document.createElement('input');
|
12
|
+
var AUTOFOCUS_SUPPORTED = 'autofocus' in document.createElement('input');
|
13
|
+
var IE6 = Browser.ie6;
|
14
|
+
var IE7 = Browser.ie7;
|
15
|
+
|
16
|
+
// Expose innards of FORMALIZE.
|
17
|
+
return {
|
18
|
+
// FORMALIZE.go
|
19
|
+
go: function() {
|
20
|
+
for (var i in FORMALIZE.init) {
|
21
|
+
FORMALIZE.init[i]();
|
22
|
+
}
|
23
|
+
},
|
24
|
+
// FORMALIZE.init
|
25
|
+
init: {
|
26
|
+
// FORMALIZE.init.full_input_size
|
27
|
+
full_input_size: function() {
|
28
|
+
if (!IE7 || !$$('textarea, input.input_full').length) {
|
29
|
+
return;
|
30
|
+
}
|
31
|
+
|
32
|
+
// This fixes width: 100% on <textarea> and class="input_full".
|
33
|
+
// It ensures that form elements don't go wider than container.
|
34
|
+
$$('textarea, input.input_full').each(function(el) {
|
35
|
+
new Element('span.input_full_wrap').wraps(el);
|
36
|
+
});
|
37
|
+
|
38
|
+
},
|
39
|
+
// FORMALIZE.init.ie6_skin_inputs
|
40
|
+
ie6_skin_inputs: function() {
|
41
|
+
// Test for Internet Explorer 6.
|
42
|
+
if (!IE6 || !$$('input, select, textarea').length) {
|
43
|
+
// Exit if the browser is not IE6,
|
44
|
+
// or if no form elements exist.
|
45
|
+
return;
|
46
|
+
}
|
47
|
+
|
48
|
+
// For <input type="submit" />, etc.
|
49
|
+
var button_regex = /button|submit|reset/;
|
50
|
+
|
51
|
+
// For <input type="text" />, etc.
|
52
|
+
var type_regex = /date|datetime|datetime-local|email|month|number|password|range|search|tel|text|time|url|week/;
|
53
|
+
|
54
|
+
$$('input').each(function(el) {
|
55
|
+
// Is it a button?
|
56
|
+
if (el.getAttribute('type').match(button_regex)) {
|
57
|
+
el.addClass('ie6_button');
|
58
|
+
|
59
|
+
/* Is it disabled? */
|
60
|
+
if (el.disabled) {
|
61
|
+
el.addClass('ie6_button_disabled');
|
62
|
+
}
|
63
|
+
}
|
64
|
+
// Or is it a textual input?
|
65
|
+
else if (el.getAttribute('type').match(type_regex)) {
|
66
|
+
el.addClass('ie6_input');
|
67
|
+
|
68
|
+
/* Is it disabled? */
|
69
|
+
if (el.disabled) {
|
70
|
+
el.addClass('ie6_input_disabled');
|
71
|
+
}
|
72
|
+
}
|
73
|
+
});
|
74
|
+
|
75
|
+
$$('textarea, select').each(function(el) {
|
76
|
+
/* Is it disabled? */
|
77
|
+
if (el.disabled) {
|
78
|
+
el.addClass('ie6_input_disabled');
|
79
|
+
}
|
80
|
+
});
|
81
|
+
},
|
82
|
+
// FORMALIZE.init.autofocus
|
83
|
+
autofocus: function() {
|
84
|
+
if (AUTOFOCUS_SUPPORTED || !$$('[autofocus]').length) {
|
85
|
+
return;
|
86
|
+
}
|
87
|
+
|
88
|
+
$$('[autofocus]')[0].focus();
|
89
|
+
},
|
90
|
+
// FORMALIZE.init.placeholder
|
91
|
+
placeholder: function() {
|
92
|
+
if (PLACEHOLDER_SUPPORTED || !$$('[placeholder]').length) {
|
93
|
+
// Exit if placeholder is supported natively,
|
94
|
+
// or if page does not have any placeholder.
|
95
|
+
return;
|
96
|
+
}
|
97
|
+
|
98
|
+
FORMALIZE.misc.add_placeholder();
|
99
|
+
|
100
|
+
$$('[placeholder]').each(function(el) {
|
101
|
+
var text = el.get('placeholder');
|
102
|
+
|
103
|
+
el.addEvents({
|
104
|
+
focus: function() {
|
105
|
+
if (el.value === text) {
|
106
|
+
el.set('value', '').removeClass('placeholder_text');
|
107
|
+
}
|
108
|
+
},
|
109
|
+
blur: function() {
|
110
|
+
FORMALIZE.misc.add_placeholder();
|
111
|
+
}
|
112
|
+
});
|
113
|
+
|
114
|
+
// Prevent <form> from accidentally
|
115
|
+
// submitting the placeholder text.
|
116
|
+
el.getParent('form').addEvents({
|
117
|
+
'submit': function() {
|
118
|
+
if (el.value === text) {
|
119
|
+
el.set('value', '').removeClass('placeholder_text');
|
120
|
+
}
|
121
|
+
},
|
122
|
+
'reset': function() {
|
123
|
+
setTimeout(FORMALIZE.misc.add_placeholder, 50);
|
124
|
+
}
|
125
|
+
});
|
126
|
+
});
|
127
|
+
}
|
128
|
+
},
|
129
|
+
// FORMALIZE.misc
|
130
|
+
misc: {
|
131
|
+
// FORMALIZE.misc.add_placeholder
|
132
|
+
add_placeholder: function() {
|
133
|
+
if (PLACEHOLDER_SUPPORTED || !$$('[placeholder]').length) {
|
134
|
+
// Exit if placeholder is supported natively,
|
135
|
+
// or if page does not have any placeholder.
|
136
|
+
return;
|
137
|
+
}
|
138
|
+
|
139
|
+
$$('[placeholder]').each(function(el) {
|
140
|
+
var text = el.get('placeholder');
|
141
|
+
|
142
|
+
if (!el.value || el.value === text) {
|
143
|
+
el.set('value', text).addClass('placeholder_text');
|
144
|
+
}
|
145
|
+
});
|
146
|
+
}
|
147
|
+
}
|
148
|
+
};
|
149
|
+
// Alias window, document.
|
150
|
+
})(this, this.document);
|
151
|
+
|
152
|
+
// Automatically calls all functions in FORMALIZE.init
|
153
|
+
$(document).addEvent('domready', function() {
|
154
|
+
FORMALIZE.go();
|
155
|
+
});
|
@@ -0,0 +1 @@
|
|
1
|
+
var FORMALIZE=function(a,b,c){var d="placeholder"in b.createElement("input"),e="autofocus"in b.createElement("input"),f=Browser.ie6,g=Browser.ie7;return{go:function(){for(var a in FORMALIZE.init)FORMALIZE.init[a]()},init:{full_input_size:function(){!!g&&!!$$("textarea, input.input_full").length&&$$("textarea, input.input_full").each(function(a){(new Element("span.input_full_wrap")).wraps(a)})},ie6_skin_inputs:function(){if(!!f&&!!$$("input, select, textarea").length){var a=/button|submit|reset/,b=/date|datetime|datetime-local|email|month|number|password|range|search|tel|text|time|url|week/;$$("input").each(function(c){c.getAttribute("type").match(a)?(c.addClass("ie6_button"),c.disabled&&c.addClass("ie6_button_disabled")):c.getAttribute("type").match(b)&&(c.addClass("ie6_input"),c.disabled&&c.addClass("ie6_input_disabled"))}),$$("textarea, select").each(function(a){a.disabled&&a.addClass("ie6_input_disabled")})}},autofocus:function(){!e&&!!$$("[autofocus]").length&&$$("[autofocus]")[0].focus()},placeholder:function(){!d&&!!$$("[placeholder]").length&&(FORMALIZE.misc.add_placeholder(),$$("[placeholder]").each(function(a){var b=a.get("placeholder");a.addEvents({focus:function(){a.value===b&&a.set("value","").removeClass("placeholder_text")},blur:function(){FORMALIZE.misc.add_placeholder()}}),a.getParent("form").addEvents({submit:function(){a.value===b&&a.set("value","").removeClass("placeholder_text")},reset:function(){setTimeout(FORMALIZE.misc.add_placeholder,50)}})}))}},misc:{add_placeholder:function(){!d&&!!$$("[placeholder]").length&&$$("[placeholder]").each(function(a){var b=a.get("placeholder");(!a.value||a.value===b)&&a.set("value",b).addClass("placeholder_text")})}}}}(this,this.document);$(document).addEvent("domready",function(){FORMALIZE.go()})
|
@@ -0,0 +1,163 @@
|
|
1
|
+
/*
|
2
|
+
Formalize - version 1.1
|
3
|
+
|
4
|
+
Note: This file depends on the Prototype library.
|
5
|
+
*/
|
6
|
+
|
7
|
+
// Module pattern:
|
8
|
+
// http://yuiblog.com/blog/2007/06/12/module-pattern
|
9
|
+
var FORMALIZE = (function(window, document, undefined) {
|
10
|
+
// Private constants.
|
11
|
+
var PLACEHOLDER_SUPPORTED = 'placeholder' in document.createElement('input');
|
12
|
+
var AUTOFOCUS_SUPPORTED = 'autofocus' in document.createElement('input');
|
13
|
+
var IE6 = IE(6);
|
14
|
+
var IE7 = IE(7);
|
15
|
+
|
16
|
+
// Internet Explorer detection.
|
17
|
+
function IE(version) {
|
18
|
+
var b = document.createElement('b');
|
19
|
+
b.innerHTML = '<!--[if IE ' + version + ']><br><![endif]-->';
|
20
|
+
return !!b.getElementsByTagName('br').length;
|
21
|
+
}
|
22
|
+
|
23
|
+
// Expose innards of FORMALIZE.
|
24
|
+
return {
|
25
|
+
// FORMALIZE.go
|
26
|
+
go: function() {
|
27
|
+
for (var i in FORMALIZE.init) {
|
28
|
+
FORMALIZE.init[i]();
|
29
|
+
}
|
30
|
+
},
|
31
|
+
// FORMALIZE.init
|
32
|
+
init: {
|
33
|
+
// FORMALIZE.init.full_input_size
|
34
|
+
full_input_size: function() {
|
35
|
+
if (!IE7 || !$$('textarea, input.input_full').length) {
|
36
|
+
return;
|
37
|
+
}
|
38
|
+
|
39
|
+
// This fixes width: 100% on <textarea> and class="input_full".
|
40
|
+
// It ensures that form elements don't go wider than container.
|
41
|
+
$$('textarea, input.input_full').each(function(el) {
|
42
|
+
Element.wrap(el, 'span', {'class': 'input_full_wrap'});
|
43
|
+
});
|
44
|
+
},
|
45
|
+
// FORMALIZE.init.ie6_skin_inputs
|
46
|
+
ie6_skin_inputs: function() {
|
47
|
+
// Test for Internet Explorer 6.
|
48
|
+
if (!IE6 || !$$('input, select, textarea').length) {
|
49
|
+
// Exit if the browser is not IE6,
|
50
|
+
// or if no form elements exist.
|
51
|
+
return;
|
52
|
+
}
|
53
|
+
|
54
|
+
// For <input type="submit" />, etc.
|
55
|
+
var button_regex = /button|submit|reset/;
|
56
|
+
|
57
|
+
// For <input type="text" />, etc.
|
58
|
+
var type_regex = /date|datetime|datetime-local|email|month|number|password|range|search|tel|text|time|url|week/;
|
59
|
+
|
60
|
+
$$('input').each(function(el) {
|
61
|
+
// Is it a button?
|
62
|
+
if (el.getAttribute('type').match(button_regex)) {
|
63
|
+
el.addClassName('ie6_button');
|
64
|
+
|
65
|
+
/* Is it disabled? */
|
66
|
+
if (el.disabled) {
|
67
|
+
el.addClassName('ie6_button_disabled');
|
68
|
+
}
|
69
|
+
}
|
70
|
+
// Or is it a textual input?
|
71
|
+
else if (el.getAttribute('type').match(type_regex)) {
|
72
|
+
el.addClassName('ie6_input');
|
73
|
+
|
74
|
+
/* Is it disabled? */
|
75
|
+
if (el.disabled) {
|
76
|
+
el.addClassName('ie6_input_disabled');
|
77
|
+
}
|
78
|
+
}
|
79
|
+
});
|
80
|
+
|
81
|
+
$$('textarea, select').each(function(el) {
|
82
|
+
/* Is it disabled? */
|
83
|
+
if (el.disabled) {
|
84
|
+
el.addClassName('ie6_input_disabled');
|
85
|
+
}
|
86
|
+
});
|
87
|
+
},
|
88
|
+
// FORMALIZE.init.autofocus
|
89
|
+
autofocus: function() {
|
90
|
+
if (AUTOFOCUS_SUPPORTED || !$$('[autofocus]').length) {
|
91
|
+
return;
|
92
|
+
}
|
93
|
+
|
94
|
+
$$('[autofocus]')[0].focus();
|
95
|
+
},
|
96
|
+
// FORMALIZE.init.placeholder
|
97
|
+
placeholder: function() {
|
98
|
+
if (PLACEHOLDER_SUPPORTED || !$$('[placeholder]').length) {
|
99
|
+
// Exit if placeholder is supported natively,
|
100
|
+
// or if page does not have any placeholder.
|
101
|
+
return;
|
102
|
+
}
|
103
|
+
|
104
|
+
FORMALIZE.misc.add_placeholder();
|
105
|
+
|
106
|
+
$$('[placeholder]').each(function(el) {
|
107
|
+
var text = el.getAttribute('placeholder');
|
108
|
+
var form = el.up('form');
|
109
|
+
|
110
|
+
el.observe('focus', function() {
|
111
|
+
if (el.value === text) {
|
112
|
+
el.value = '';
|
113
|
+
el.removeClassName('placeholder_text');
|
114
|
+
}
|
115
|
+
});
|
116
|
+
|
117
|
+
el.observe('blur', function() {
|
118
|
+
FORMALIZE.misc.add_placeholder();
|
119
|
+
});
|
120
|
+
|
121
|
+
// Prevent <form> from accidentally
|
122
|
+
// submitting the placeholder text.
|
123
|
+
form.observe('submit', function() {
|
124
|
+
if (el.value === text) {
|
125
|
+
el.value = '';
|
126
|
+
el.removeClassName('placeholder_text');
|
127
|
+
}
|
128
|
+
});
|
129
|
+
|
130
|
+
form.observe('reset', function() {
|
131
|
+
setTimeout(FORMALIZE.misc.add_placeholder, 50);
|
132
|
+
});
|
133
|
+
});
|
134
|
+
}
|
135
|
+
},
|
136
|
+
// FORMALIZE.misc
|
137
|
+
misc: {
|
138
|
+
// FORMALIZE.misc.add_placeholder
|
139
|
+
add_placeholder: function() {
|
140
|
+
if (PLACEHOLDER_SUPPORTED || !$$('[placeholder]').length) {
|
141
|
+
// Exit if placeholder is supported natively,
|
142
|
+
// or if page does not have any placeholder.
|
143
|
+
return;
|
144
|
+
}
|
145
|
+
|
146
|
+
$$('[placeholder]').each(function(el) {
|
147
|
+
var text = el.getAttribute('placeholder');
|
148
|
+
|
149
|
+
if (!el.value || el.value === text) {
|
150
|
+
el.value = text;
|
151
|
+
el.addClassName('placeholder_text');
|
152
|
+
}
|
153
|
+
});
|
154
|
+
}
|
155
|
+
}
|
156
|
+
};
|
157
|
+
// Alias window, document.
|
158
|
+
})(this, this.document);
|
159
|
+
|
160
|
+
// Automatically calls all functions in FORMALIZE.init
|
161
|
+
$(document).observe('dom:loaded', function() {
|
162
|
+
FORMALIZE.go();
|
163
|
+
});
|
@@ -0,0 +1 @@
|
|
1
|
+
var FORMALIZE=function(a,b,c){function h(a){var c=b.createElement("b");c.innerHTML="<!--[if IE "+a+"]><br><![endif]-->";return!!c.getElementsByTagName("br").length}var d="placeholder"in b.createElement("input"),e="autofocus"in b.createElement("input"),f=h(6),g=h(7);return{go:function(){for(var a in FORMALIZE.init)FORMALIZE.init[a]()},init:{full_input_size:function(){!!g&&!!$$("textarea, input.input_full").length&&$$("textarea, input.input_full").each(function(a){Element.wrap(a,"span",{"class":"input_full_wrap"})})},ie6_skin_inputs:function(){if(!!f&&!!$$("input, select, textarea").length){var a=/button|submit|reset/,b=/date|datetime|datetime-local|email|month|number|password|range|search|tel|text|time|url|week/;$$("input").each(function(c){c.getAttribute("type").match(a)?(c.addClassName("ie6_button"),c.disabled&&c.addClassName("ie6_button_disabled")):c.getAttribute("type").match(b)&&(c.addClassName("ie6_input"),c.disabled&&c.addClassName("ie6_input_disabled"))}),$$("textarea, select").each(function(a){a.disabled&&a.addClassName("ie6_input_disabled")})}},autofocus:function(){!e&&!!$$("[autofocus]").length&&$$("[autofocus]")[0].focus()},placeholder:function(){!d&&!!$$("[placeholder]").length&&(FORMALIZE.misc.add_placeholder(),$$("[placeholder]").each(function(a){var b=a.getAttribute("placeholder"),c=a.up("form");a.observe("focus",function(){a.value===b&&(a.value="",a.removeClassName("placeholder_text"))}),a.observe("blur",function(){FORMALIZE.misc.add_placeholder()}),c.observe("submit",function(){a.value===b&&(a.value="",a.removeClassName("placeholder_text"))}),c.observe("reset",function(){setTimeout(FORMALIZE.misc.add_placeholder,50)})}))}},misc:{add_placeholder:function(){!d&&!!$$("[placeholder]").length&&$$("[placeholder]").each(function(a){var b=a.getAttribute("placeholder");if(!a.value||a.value===b)a.value=b,a.addClassName("placeholder_text")})}}}}(this,this.document);$(document).observe("dom:loaded",function(){FORMALIZE.go()})
|
@@ -0,0 +1,160 @@
|
|
1
|
+
/*
|
2
|
+
Formalize - version 1.1
|
3
|
+
|
4
|
+
Note: This file depends on the YUI library.
|
5
|
+
*/
|
6
|
+
|
7
|
+
// Module pattern:
|
8
|
+
// http://yuiblog.com/blog/2007/06/12/module-pattern
|
9
|
+
var FORMALIZE = (function(window, document, undefined) {
|
10
|
+
// Private constants.
|
11
|
+
var PLACEHOLDER_SUPPORTED = 'placeholder' in document.createElement('input');
|
12
|
+
var AUTOFOCUS_SUPPORTED = 'autofocus' in document.createElement('input');
|
13
|
+
var IE6 = parseInt(Y.UA.ie, 10) === 6;
|
14
|
+
var IE7 = parseInt(Y.UA.ie, 10) === 7;
|
15
|
+
|
16
|
+
// Expose innards of FORMALIZE.
|
17
|
+
return {
|
18
|
+
// FORMALIZE.go
|
19
|
+
go: function() {
|
20
|
+
for (var i in FORMALIZE.init) {
|
21
|
+
FORMALIZE.init[i]();
|
22
|
+
}
|
23
|
+
},
|
24
|
+
// FORMALIZE.init
|
25
|
+
init: {
|
26
|
+
// FORMALIZE.init.full_input_size
|
27
|
+
full_input_size: function() {
|
28
|
+
if (!IE7 || !Y.all('textarea, input.input_full')) {
|
29
|
+
return;
|
30
|
+
}
|
31
|
+
|
32
|
+
// This fixes width: 100% on <textarea> and class="input_full".
|
33
|
+
// It ensures that form elements don't go wider than container.
|
34
|
+
Y.all('textarea, input.input_full').each(function(el) {
|
35
|
+
var wrapper = Y.Node.create('<span class="input_full_wrap"></span>');
|
36
|
+
wrapper.append(el.replace(wrapper));
|
37
|
+
});
|
38
|
+
},
|
39
|
+
// FORMALIZE.init.ie6_skin_inputs
|
40
|
+
ie6_skin_inputs: function() {
|
41
|
+
// Test for Internet Explorer 6.
|
42
|
+
if (!IE6 || !Y.all('input, select, textarea')) {
|
43
|
+
// Exit if the browser is not IE6,
|
44
|
+
// or if no form elements exist.
|
45
|
+
return;
|
46
|
+
}
|
47
|
+
|
48
|
+
// For <input type="submit" />, etc.
|
49
|
+
var button_regex = /button|submit|reset/;
|
50
|
+
|
51
|
+
// For <input type="text" />, etc.
|
52
|
+
var type_regex = /date|datetime|datetime-local|email|month|number|password|range|search|tel|text|time|url|week/;
|
53
|
+
|
54
|
+
Y.all('input').each(function(el) {
|
55
|
+
// Is it a button?
|
56
|
+
if (el.getAttribute('type').match(button_regex)) {
|
57
|
+
el.addClass('ie6_button');
|
58
|
+
|
59
|
+
/* Is it disabled? */
|
60
|
+
if (el.disabled) {
|
61
|
+
el.addClass('ie6_button_disabled');
|
62
|
+
}
|
63
|
+
}
|
64
|
+
// Or is it a textual input?
|
65
|
+
else if (el.getAttribute('type').match(type_regex)) {
|
66
|
+
el.addClass('ie6_input');
|
67
|
+
|
68
|
+
/* Is it disabled? */
|
69
|
+
if (el.disabled) {
|
70
|
+
el.addClass('ie6_input_disabled');
|
71
|
+
}
|
72
|
+
}
|
73
|
+
});
|
74
|
+
|
75
|
+
Y.all('textarea, select').each(function(el) {
|
76
|
+
/* Is it disabled? */
|
77
|
+
if (el.disabled) {
|
78
|
+
el.addClass('ie6_input_disabled');
|
79
|
+
}
|
80
|
+
});
|
81
|
+
},
|
82
|
+
// FORMALIZE.init.autofocus
|
83
|
+
autofocus: function() {
|
84
|
+
if (AUTOFOCUS_SUPPORTED || !Y.one('[autofocus]')) {
|
85
|
+
return;
|
86
|
+
}
|
87
|
+
|
88
|
+
Y.one('[autofocus]').focus();
|
89
|
+
},
|
90
|
+
// FORMALIZE.init.placeholder
|
91
|
+
placeholder: function() {
|
92
|
+
if (PLACEHOLDER_SUPPORTED || !Y.one('[placeholder]')) {
|
93
|
+
// Exit if placeholder is supported natively,
|
94
|
+
// or if page does not have any placeholder.
|
95
|
+
return;
|
96
|
+
}
|
97
|
+
|
98
|
+
FORMALIZE.misc.add_placeholder();
|
99
|
+
|
100
|
+
Y.all('[placeholder]').each(function(el) {
|
101
|
+
var text = el.getAttribute('placeholder');
|
102
|
+
var form = el.ancestor('form');
|
103
|
+
|
104
|
+
function add_placeholder() {
|
105
|
+
if (!el.get('value') || el.get('value') === text) {
|
106
|
+
el.set('value', text).addClass('placeholder_text');
|
107
|
+
}
|
108
|
+
}
|
109
|
+
|
110
|
+
el.on('focus', function() {
|
111
|
+
if (el.get('value') === text) {
|
112
|
+
el.set('value', '').removeClass('placeholder_text');
|
113
|
+
}
|
114
|
+
});
|
115
|
+
|
116
|
+
el.on('blur', function() {
|
117
|
+
FORMALIZE.misc.add_placeholder();
|
118
|
+
});
|
119
|
+
|
120
|
+
// Prevent <form> from accidentally
|
121
|
+
// submitting the placeholder text.
|
122
|
+
form.on('submit', function() {
|
123
|
+
if (el.get('value') === text) {
|
124
|
+
el.set('value', '').removeClass('placeholder_text');
|
125
|
+
}
|
126
|
+
});
|
127
|
+
|
128
|
+
form.on('reset', function() {
|
129
|
+
setTimeout(FORMALIZE.misc.add_placeholder, 50);
|
130
|
+
});
|
131
|
+
});
|
132
|
+
}
|
133
|
+
},
|
134
|
+
// FORMALIZE.misc
|
135
|
+
misc: {
|
136
|
+
// FORMALIZE.misc.add_placeholder
|
137
|
+
add_placeholder: function() {
|
138
|
+
if (PLACEHOLDER_SUPPORTED || !Y.one('[placeholder]')) {
|
139
|
+
// Exit if placeholder is supported natively,
|
140
|
+
// or if page does not have any placeholder.
|
141
|
+
return;
|
142
|
+
}
|
143
|
+
|
144
|
+
Y.all('[placeholder]').each(function(el) {
|
145
|
+
var text = el.getAttribute('placeholder');
|
146
|
+
|
147
|
+
if (!el.get('value') || el.get('value') === text) {
|
148
|
+
el.set('value', text).addClass('placeholder_text');
|
149
|
+
}
|
150
|
+
});
|
151
|
+
}
|
152
|
+
}
|
153
|
+
};
|
154
|
+
// Alias window, document.
|
155
|
+
})(this, this.document);
|
156
|
+
|
157
|
+
// Automatically calls all functions in FORMALIZE.init
|
158
|
+
Y.on('domready', function() {
|
159
|
+
FORMALIZE.go();
|
160
|
+
});
|
@@ -0,0 +1 @@
|
|
1
|
+
var FORMALIZE=function(a,b,c){var d="placeholder"in b.createElement("input"),e="autofocus"in b.createElement("input"),f=parseInt(Y.UA.ie,10)===6,g=parseInt(Y.UA.ie,10)===7;return{go:function(){for(var a in FORMALIZE.init)FORMALIZE.init[a]()},init:{full_input_size:function(){!!g&&!!Y.all("textarea, input.input_full")&&Y.all("textarea, input.input_full").each(function(a){var b=Y.Node.create('<span class="input_full_wrap"></span>');b.append(a.replace(b))})},ie6_skin_inputs:function(){if(!!f&&!!Y.all("input, select, textarea")){var a=/button|submit|reset/,b=/date|datetime|datetime-local|email|month|number|password|range|search|tel|text|time|url|week/;Y.all("input").each(function(c){c.getAttribute("type").match(a)?(c.addClass("ie6_button"),c.disabled&&c.addClass("ie6_button_disabled")):c.getAttribute("type").match(b)&&(c.addClass("ie6_input"),c.disabled&&c.addClass("ie6_input_disabled"))}),Y.all("textarea, select").each(function(a){a.disabled&&a.addClass("ie6_input_disabled")})}},autofocus:function(){!e&&!!Y.one("[autofocus]")&&Y.one("[autofocus]").focus()},placeholder:function(){!d&&!!Y.one("[placeholder]")&&(FORMALIZE.misc.add_placeholder(),Y.all("[placeholder]").each(function(a){function d(){(!a.get("value")||a.get("value")===b)&&a.set("value",b).addClass("placeholder_text")}var b=a.getAttribute("placeholder"),c=a.ancestor("form");a.on("focus",function(){a.get("value")===b&&a.set("value","").removeClass("placeholder_text")}),a.on("blur",function(){FORMALIZE.misc.add_placeholder()}),c.on("submit",function(){a.get("value")===b&&a.set("value","").removeClass("placeholder_text")}),c.on("reset",function(){setTimeout(FORMALIZE.misc.add_placeholder,50)})}))}},misc:{add_placeholder:function(){!d&&!!Y.one("[placeholder]")&&Y.all("[placeholder]").each(function(a){var b=a.getAttribute("placeholder");(!a.get("value")||a.get("value")===b)&&a.set("value",b).addClass("placeholder_text")})}}}}(this,this.document);Y.on("domready",function(){FORMALIZE.go()})
|