typus 3.1.0.rc14 → 3.1.0.rc15
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitmodules +3 -0
- data/README.md +10 -14
- data/Rakefile +7 -5
- data/app/assets/javascripts/typus.js +1 -0
- data/app/assets/javascripts/typus/jquery.application.js +0 -2
- data/app/assets/stylesheets/typus.css +13 -1
- data/app/assets/stylesheets/typus/account.css +53 -0
- data/app/assets/stylesheets/typus/actions.css +11 -0
- data/app/assets/stylesheets/typus/content.css +92 -0
- data/app/assets/stylesheets/typus/defaults.css +31 -0
- data/app/assets/stylesheets/typus/errors.css +33 -0
- data/app/assets/stylesheets/typus/footer.css +8 -0
- data/app/assets/stylesheets/typus/forms.css +52 -0
- data/app/assets/stylesheets/typus/hacks.css +20 -0
- data/app/assets/stylesheets/typus/header.css +55 -0
- data/app/assets/stylesheets/typus/layout.css +4 -0
- data/app/assets/stylesheets/typus/pagination.css +34 -8
- data/app/assets/stylesheets/typus/sidebar.css +23 -0
- data/app/assets/stylesheets/typus/tables.css +47 -0
- data/app/helpers/admin/base_helper.rb +1 -1
- data/app/helpers/admin/resources/data_types/belongs_to_helper.rb +1 -0
- data/app/helpers/admin/resources/data_types/tree_helper.rb +1 -0
- data/app/helpers/admin/resources/display_helper.rb +1 -1
- data/app/helpers/admin/resources/form_helper.rb +1 -0
- data/app/helpers/admin/resources_helper.rb +3 -5
- data/app/views/admin/account/forgot_password.html.erb +7 -1
- data/app/views/admin/base/user_guide.html.erb +61 -57
- data/app/views/admin/dashboard/show.html.erb +6 -16
- data/app/views/admin/dashboard/widgets/_applications.html.erb +31 -0
- data/app/views/admin/dashboard/widgets/_models.html.erb +23 -0
- data/app/views/admin/dashboard/widgets/_models_extended.html.erb +25 -0
- data/app/views/admin/dashboard/widgets/_resources.html.erb +23 -0
- data/app/views/admin/resources/_actions.html.erb +23 -0
- data/app/views/admin/resources/edit.html.erb +26 -20
- data/app/views/admin/resources/edit/_actions.html.erb +7 -0
- data/app/views/admin/resources/edit/_rencently_edited.html.erb +8 -0
- data/app/views/admin/resources/index.html.erb +42 -32
- data/app/views/admin/resources/new.html.erb +16 -8
- data/app/views/admin/resources/show.html.erb +22 -14
- data/app/views/admin/session/new.html.erb +9 -1
- data/app/views/admin/templates/_belongs_to.html.erb +1 -1
- data/app/views/admin/templates/_belongs_to_with_autocomplete.html.erb +1 -1
- data/app/views/admin/templates/_boolean.html.erb +1 -1
- data/app/views/admin/templates/_date.html.erb +1 -1
- data/app/views/admin/templates/_datetime.html.erb +1 -1
- data/app/views/admin/templates/_dragonfly.html.erb +1 -1
- data/app/views/admin/templates/_paperclip.html.erb +1 -1
- data/app/views/admin/templates/_password.html.erb +1 -1
- data/app/views/admin/templates/_selector.html.erb +1 -1
- data/app/views/admin/templates/_string.html.erb +1 -1
- data/app/views/admin/templates/_string_with_preview.html.erb +1 -1
- data/app/views/admin/templates/_text.html.erb +1 -1
- data/app/views/admin/templates/_text_with_ckeditor.html.erb +16 -2
- data/app/views/admin/templates/_text_with_ckeditor_and_assets.html.erb +16 -2
- data/app/views/admin/templates/_time.html.erb +1 -1
- data/app/views/admin/templates/_tree.html.erb +1 -1
- data/app/views/helpers/admin/resources/_sidebar.html.erb +36 -12
- data/app/views/helpers/admin/resources/_table.html.erb +5 -3
- data/app/views/layouts/admin/base.html.erb +16 -29
- data/app/views/layouts/admin/headless.html.erb +1 -1
- data/app/views/layouts/admin/session.html.erb +6 -0
- data/lib/support/fake_user.rb +2 -8
- data/lib/typus.rb +6 -2
- data/lib/typus/authentication/devise.rb +19 -0
- data/lib/typus/controller/headless.rb +1 -1
- data/lib/typus/orm/active_record/admin_user_v1.rb +15 -1
- data/lib/typus/orm/active_record/admin_user_v2.rb +16 -2
- data/lib/typus/orm/active_record/user/class_methods.rb +2 -3
- data/lib/typus/orm/active_record/user/instance_methods.rb +5 -2
- data/lib/typus/orm/active_record/user/instance_methods_more.rb +19 -0
- data/lib/typus/version.rb +1 -1
- data/vendor/assets/adapt/css/1200.css +357 -0
- data/vendor/assets/adapt/css/1200.min.css +1 -0
- data/vendor/assets/adapt/css/1560.css +357 -0
- data/vendor/assets/adapt/css/1560.min.css +1 -0
- data/vendor/assets/adapt/css/720.css +357 -0
- data/vendor/assets/adapt/css/720.min.css +1 -0
- data/vendor/assets/adapt/css/960.css +357 -0
- data/vendor/assets/adapt/css/960.min.css +1 -0
- data/vendor/assets/adapt/css/fluid.css +345 -0
- data/vendor/assets/adapt/css/fluid.min.css +1 -0
- data/vendor/assets/adapt/css/master.css +120 -0
- data/vendor/assets/adapt/css/mobile.css +20 -0
- data/vendor/assets/adapt/css/mobile.min.css +1 -0
- data/vendor/assets/adapt/css/reset.css +202 -0
- data/vendor/assets/adapt/css/text.css +81 -0
- data/vendor/assets/adapt/images/h1.png +0 -0
- data/vendor/assets/adapt/js/adapt.js +135 -0
- data/vendor/assets/adapt/js/adapt.min.js +1 -0
- data/vendor/assets/formalize/.gitignore +1 -0
- data/vendor/assets/formalize/css/_formalize.sass +332 -0
- data/vendor/assets/formalize/css/demo.css +47 -0
- data/vendor/assets/formalize/css/formalize.css +395 -0
- data/vendor/assets/formalize/css/reset.css +202 -0
- data/vendor/assets/formalize/css/text.css +81 -0
- data/vendor/assets/formalize/images/button.png +0 -0
- data/vendor/assets/formalize/images/select_arrow.gif +0 -0
- data/vendor/assets/formalize/js/dojo.formalize.js +166 -0
- data/vendor/assets/formalize/js/dojo.formalize.min.js +1 -0
- data/vendor/assets/formalize/js/extjs.formalize.js +163 -0
- data/vendor/assets/formalize/js/extjs.formalize.min.js +1 -0
- data/vendor/assets/formalize/js/jquery.formalize.js +150 -0
- data/vendor/assets/formalize/js/jquery.formalize.min.js +1 -0
- data/vendor/assets/formalize/js/mootools.formalize.js +155 -0
- data/vendor/assets/formalize/js/mootools.formalize.min.js +1 -0
- data/vendor/assets/formalize/js/prototype.formalize.js +163 -0
- data/vendor/assets/formalize/js/prototype.formalize.min.js +1 -0
- data/vendor/assets/formalize/js/yui.formalize.js +152 -0
- data/vendor/assets/formalize/js/yui.formalize.min.js +1 -0
- metadata +79 -47
- data/app/assets/stylesheets/typus/screen.css +0 -340
- data/app/helpers/admin/dashboard_helper.rb +0 -8
- data/app/views/admin/dashboard/_applications.html.erb +0 -21
- data/config/locales/typus.ca.models.yml +0 -17
- data/config/locales/typus.ca.yml +0 -80
- data/config/locales/typus.de.models.yml +0 -17
- data/config/locales/typus.de.yml +0 -79
- data/config/locales/typus.el.models.yml +0 -17
- data/config/locales/typus.el.yml +0 -81
- data/config/locales/typus.es.models.yml +0 -18
- data/config/locales/typus.es.yml +0 -81
- data/config/locales/typus.fr.models.yml +0 -18
- data/config/locales/typus.fr.yml +0 -85
- data/config/locales/typus.hu.models.yml +0 -17
- data/config/locales/typus.hu.yml +0 -79
- data/config/locales/typus.it.models.yml +0 -18
- data/config/locales/typus.it.yml +0 -88
- data/config/locales/typus.locale.models.yml.template +0 -17
- data/config/locales/typus.locale.yml.template +0 -80
- data/config/locales/typus.pt-BR.models.yml +0 -17
- data/config/locales/typus.pt-BR.yml +0 -79
- data/config/locales/typus.pt-PT.models.yml +0 -17
- data/config/locales/typus.pt-PT.yml +0 -83
- data/config/locales/typus.ru.models.yml +0 -17
- data/config/locales/typus.ru.yml +0 -79
- data/config/locales/typus.zh-CN.models.yml +0 -17
- data/config/locales/typus.zh-CN.yml +0 -78
@@ -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(dojo.isIE,10)===6,g=parseInt(dojo.isIE,10)===7;return{go:function(){for(var a in FORMALIZE.init)FORMALIZE.init[a]()},init:{full_input_size:function(){!!g&&!!dojo.query("textarea, input.input_full").length&&dojo.query("textarea, input.input_full").forEach(function(a){var c=a.cloneNode(!1),d=b.createElement("span");d.className="input_full_wrap",d.appendChild(c),a.parentNode.replaceChild(d,a)})},ie6_skin_inputs:function(){if(!!f&&!!dojo.query("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/;dojo.query("input").forEach(function(c){c.getAttribute("type").match(a)?(dojo.addClass(c,"ie6_button"),c.disabled&&dojo.addClass(c,"ie6_button_disabled")):c.getAttribute("type").match(b)&&(dojo.addClass(c,"ie6_input"),c.disabled&&dojo.addClass(c,"ie6_input_disabled"))}),dojo.query("textarea, select").forEach(function(a){a.disabled&&dojo.addClass(a,"ie6_input_disabled")})}},autofocus:function(){!e&&!!dojo.query("[autofocus]").length&&dojo.query("[autofocus]")[0].focus()},placeholder:function(){!d&&!!dojo.query("[placeholder]").length&&(FORMALIZE.misc.add_placeholder(),dojo.query("[placeholder]").forEach(function(a){dojo.connect(a,"onfocus",function(){var b=a.getAttribute("placeholder");a.value===b&&(a.value="",dojo.removeClass(a,"placeholder_text"))}),dojo.connect(a,"onblur",function(){FORMALIZE.misc.add_placeholder()})}),dojo.query("form").forEach(function(a){dojo.connect(a,"onsubmit",function(){dojo.query("[placeholder]",a).forEach(function(a){var b=a.getAttribute("placeholder");a.value===b&&(a.value="",dojo.removeClass(a,"placeholder_text"))})}),dojo.connect(a,"onreset",function(){setTimeout(FORMALIZE.misc.add_placeholder,50)})}))}},misc:{add_placeholder:function(){!d&&!!dojo.query("[placeholder]").length&&dojo.query("[placeholder]").forEach(function(a){var b=a.getAttribute("placeholder");if(!a.value||a.value===b)a.value=b,dojo.addClass(a,"placeholder_text")})}}}}(this,this.document);dojo.addOnLoad(function(){FORMALIZE.go()})
|
@@ -0,0 +1,163 @@
|
|
1
|
+
/*
|
2
|
+
Formalize - version 1.1
|
3
|
+
|
4
|
+
Note: This file depends on the ExtJS 3.x 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 = Ext.isIE6;
|
14
|
+
var IE7 = Ext.isIE7;
|
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 || !Ext.query('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
|
+
Ext.each(Ext.query('textarea, input.input_full'), function(el) {
|
35
|
+
Ext.get(el).wrap('<span class="input_full_wrap"></span>');
|
36
|
+
});
|
37
|
+
},
|
38
|
+
// FORMALIZE.init.ie6_skin_inputs
|
39
|
+
ie6_skin_inputs: function() {
|
40
|
+
// Test for Internet Explorer 6.
|
41
|
+
if (!IE6 || !Ext.query('input, select, textarea')) {
|
42
|
+
// Exit if the browser is not IE6,
|
43
|
+
// or if no form elements exist.
|
44
|
+
return;
|
45
|
+
}
|
46
|
+
|
47
|
+
// For <input type="submit" />, etc.
|
48
|
+
var button_regex = /button|submit|reset/;
|
49
|
+
|
50
|
+
// For <input type="text" />, etc.
|
51
|
+
var type_regex = /date|datetime|datetime-local|email|month|number|password|range|search|tel|text|time|url|week/;
|
52
|
+
|
53
|
+
Ext.each(Ext.query('input'), function(el) {
|
54
|
+
// Is it a button?
|
55
|
+
if (el.getAttribute('type').match(button_regex)) {
|
56
|
+
Ext.get(el).addClass('ie6_button');
|
57
|
+
|
58
|
+
/* Is it disabled? */
|
59
|
+
if (el.disabled) {
|
60
|
+
Ext.get(el).addClass('ie6_button_disabled');
|
61
|
+
}
|
62
|
+
}
|
63
|
+
// Or is it a textual input?
|
64
|
+
else if (el.getAttribute('type').match(type_regex)) {
|
65
|
+
Ext.get(el).addClass('ie6_input');
|
66
|
+
|
67
|
+
/* Is it disabled? */
|
68
|
+
if (el.disabled) {
|
69
|
+
Ext.get(el).addClass('ie6_input_disabled');
|
70
|
+
}
|
71
|
+
}
|
72
|
+
});
|
73
|
+
|
74
|
+
Ext.each(Ext.query('textarea, select'), function(el) {
|
75
|
+
/* Is it disabled? */
|
76
|
+
if (el.disabled) {
|
77
|
+
Ext.get(el).addClass('ie6_input_disabled');
|
78
|
+
}
|
79
|
+
});
|
80
|
+
},
|
81
|
+
// FORMALIZE.init.autofocus
|
82
|
+
autofocus: function() {
|
83
|
+
if (AUTOFOCUS_SUPPORTED || !Ext.query('[autofocus]')) {
|
84
|
+
return;
|
85
|
+
}
|
86
|
+
|
87
|
+
Ext.query('[autofocus]')[0].focus();
|
88
|
+
},
|
89
|
+
// FORMALIZE.init.placeholder
|
90
|
+
placeholder: function() {
|
91
|
+
if (PLACEHOLDER_SUPPORTED || !Ext.query('[placeholder]')) {
|
92
|
+
// Exit if placeholder is supported natively,
|
93
|
+
// or if page does not have any placeholder.
|
94
|
+
return;
|
95
|
+
}
|
96
|
+
|
97
|
+
FORMALIZE.misc.add_placeholder();
|
98
|
+
|
99
|
+
Ext.each(Ext.query('[placeholder]'), function(el) {
|
100
|
+
var text = el.getAttribute('placeholder');
|
101
|
+
var form = Ext.get(el).parent('form');
|
102
|
+
|
103
|
+
function add_placeholder() {
|
104
|
+
if (!el.value || el.value === text) {
|
105
|
+
el.value = text;
|
106
|
+
Ext.get(el).addClass('placeholder_text');
|
107
|
+
}
|
108
|
+
}
|
109
|
+
|
110
|
+
Ext.get(el).on('focus', function() {
|
111
|
+
if (el.value === text) {
|
112
|
+
el.value = '';
|
113
|
+
Ext.get(el).removeClass('placeholder_text');
|
114
|
+
}
|
115
|
+
});
|
116
|
+
|
117
|
+
Ext.get(el).on('blur', function() {
|
118
|
+
FORMALIZE.misc.add_placeholder();
|
119
|
+
});
|
120
|
+
|
121
|
+
// Prevent <form> from accidentally
|
122
|
+
// submitting the placeholder text.
|
123
|
+
form.on('submit', function() {
|
124
|
+
if (el.value === text) {
|
125
|
+
el.value = '';
|
126
|
+
Ext.get(el).removeClass('placeholder_text');
|
127
|
+
}
|
128
|
+
});
|
129
|
+
|
130
|
+
form.on('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 || !Ext.query('[placeholder]')) {
|
141
|
+
// Exit if placeholder is supported natively,
|
142
|
+
// or if page does not have any placeholder.
|
143
|
+
return;
|
144
|
+
}
|
145
|
+
|
146
|
+
Ext.each(Ext.query('[placeholder]'), function(el) {
|
147
|
+
var text = el.getAttribute('placeholder');
|
148
|
+
|
149
|
+
if (!el.value || el.value === text) {
|
150
|
+
el.value = text;
|
151
|
+
Ext.get(el).addClass('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
|
+
Ext.onReady(function() {
|
162
|
+
FORMALIZE.go();
|
163
|
+
});
|
@@ -0,0 +1 @@
|
|
1
|
+
var FORMALIZE=function(a,b,c){var d="placeholder"in b.createElement("input"),e="autofocus"in b.createElement("input"),f=Ext.isIE6,g=Ext.isIE7;return{go:function(){for(var a in FORMALIZE.init)FORMALIZE.init[a]()},init:{full_input_size:function(){!!g&&!!Ext.query("textarea, input.input_full")&&Ext.each(Ext.query("textarea, input.input_full"),function(a){Ext.get(a).wrap('<span class="input_full_wrap"></span>')})},ie6_skin_inputs:function(){if(!!f&&!!Ext.query("input, select, textarea")){var a=/button|submit|reset/,b=/date|datetime|datetime-local|email|month|number|password|range|search|tel|text|time|url|week/;Ext.each(Ext.query("input"),function(c){c.getAttribute("type").match(a)?(Ext.get(c).addClass("ie6_button"),c.disabled&&Ext.get(c).addClass("ie6_button_disabled")):c.getAttribute("type").match(b)&&(Ext.get(c).addClass("ie6_input"),c.disabled&&Ext.get(c).addClass("ie6_input_disabled"))}),Ext.each(Ext.query("textarea, select"),function(a){a.disabled&&Ext.get(a).addClass("ie6_input_disabled")})}},autofocus:function(){!e&&!!Ext.query("[autofocus]")&&Ext.query("[autofocus]")[0].focus()},placeholder:function(){!d&&!!Ext.query("[placeholder]")&&(FORMALIZE.misc.add_placeholder(),Ext.each(Ext.query("[placeholder]"),function(a){function d(){if(!a.value||a.value===b)a.value=b,Ext.get(a).addClass("placeholder_text")}var b=a.getAttribute("placeholder"),c=Ext.get(a).parent("form");Ext.get(a).on("focus",function(){a.value===b&&(a.value="",Ext.get(a).removeClass("placeholder_text"))}),Ext.get(a).on("blur",function(){FORMALIZE.misc.add_placeholder()}),c.on("submit",function(){a.value===b&&(a.value="",Ext.get(a).removeClass("placeholder_text"))}),c.on("reset",function(){setTimeout(FORMALIZE.misc.add_placeholder,50)})}))}},misc:{add_placeholder:function(){!d&&!!Ext.query("[placeholder]")&&Ext.each(Ext.query("[placeholder]"),function(a){var b=a.getAttribute("placeholder");if(!a.value||a.value===b)a.value=b,Ext.get(a).addClass("placeholder_text")})}}}}(this,this.document);Ext.onReady(function(){FORMALIZE.go()})
|
@@ -0,0 +1,150 @@
|
|
1
|
+
/*
|
2
|
+
Formalize - version 1.1
|
3
|
+
|
4
|
+
Note: This file depends on the jQuery 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.msie && parseInt($.browser.version, 10) === 6);
|
14
|
+
var IE7 = !!($.browser.msie && parseInt($.browser.version, 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 || !$('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').wrap('<span class="input_full_wrap"></span>');
|
35
|
+
},
|
36
|
+
// FORMALIZE.init.ie6_skin_inputs
|
37
|
+
ie6_skin_inputs: function() {
|
38
|
+
// Test for Internet Explorer 6.
|
39
|
+
if (!IE6 || !$('input, select, textarea').length) {
|
40
|
+
// Exit if the browser is not IE6,
|
41
|
+
// or if no form elements exist.
|
42
|
+
return;
|
43
|
+
}
|
44
|
+
|
45
|
+
// For <input type="submit" />, etc.
|
46
|
+
var button_regex = /button|submit|reset/;
|
47
|
+
|
48
|
+
// For <input type="text" />, etc.
|
49
|
+
var type_regex = /date|datetime|datetime-local|email|month|number|password|range|search|tel|text|time|url|week/;
|
50
|
+
|
51
|
+
$('input').each(function() {
|
52
|
+
var el = $(this);
|
53
|
+
|
54
|
+
// Is it a button?
|
55
|
+
if (this.getAttribute('type').match(button_regex)) {
|
56
|
+
el.addClass('ie6_button');
|
57
|
+
|
58
|
+
/* Is it disabled? */
|
59
|
+
if (this.disabled) {
|
60
|
+
el.addClass('ie6_button_disabled');
|
61
|
+
}
|
62
|
+
}
|
63
|
+
// Or is it a textual input?
|
64
|
+
else if (this.getAttribute('type').match(type_regex)) {
|
65
|
+
el.addClass('ie6_input');
|
66
|
+
|
67
|
+
/* Is it disabled? */
|
68
|
+
if (this.disabled) {
|
69
|
+
el.addClass('ie6_input_disabled');
|
70
|
+
}
|
71
|
+
}
|
72
|
+
});
|
73
|
+
|
74
|
+
$('textarea, select').each(function() {
|
75
|
+
/* Is it disabled? */
|
76
|
+
if (this.disabled) {
|
77
|
+
$(this).addClass('ie6_input_disabled');
|
78
|
+
}
|
79
|
+
});
|
80
|
+
},
|
81
|
+
// FORMALIZE.init.autofocus
|
82
|
+
autofocus: function() {
|
83
|
+
if (AUTOFOCUS_SUPPORTED || !$(':input[autofocus]').length) {
|
84
|
+
return;
|
85
|
+
}
|
86
|
+
|
87
|
+
$(':input[autofocus]:visible:first').focus();
|
88
|
+
},
|
89
|
+
// FORMALIZE.init.placeholder
|
90
|
+
placeholder: function() {
|
91
|
+
if (PLACEHOLDER_SUPPORTED || !$(':input[placeholder]').length) {
|
92
|
+
// Exit if placeholder is supported natively,
|
93
|
+
// or if page does not have any placeholder.
|
94
|
+
return;
|
95
|
+
}
|
96
|
+
|
97
|
+
FORMALIZE.misc.add_placeholder();
|
98
|
+
|
99
|
+
$(':input[placeholder]').each(function() {
|
100
|
+
var el = $(this);
|
101
|
+
var text = el.attr('placeholder');
|
102
|
+
|
103
|
+
el.focus(function() {
|
104
|
+
if (el.val() === text) {
|
105
|
+
el.val('').removeClass('placeholder_text');
|
106
|
+
}
|
107
|
+
}).blur(function() {
|
108
|
+
FORMALIZE.misc.add_placeholder();
|
109
|
+
});
|
110
|
+
|
111
|
+
// Prevent <form> from accidentally
|
112
|
+
// submitting the placeholder text.
|
113
|
+
el.closest('form').submit(function() {
|
114
|
+
if (el.val() === text) {
|
115
|
+
el.val('').removeClass('placeholder_text');
|
116
|
+
}
|
117
|
+
}).bind('reset', function() {
|
118
|
+
setTimeout(FORMALIZE.misc.add_placeholder, 50);
|
119
|
+
});
|
120
|
+
});
|
121
|
+
}
|
122
|
+
},
|
123
|
+
// FORMALIZE.misc
|
124
|
+
misc: {
|
125
|
+
// FORMALIZE.misc.add_placeholder
|
126
|
+
add_placeholder: function() {
|
127
|
+
if (PLACEHOLDER_SUPPORTED || !$(':input[placeholder]').length) {
|
128
|
+
// Exit if placeholder is supported natively,
|
129
|
+
// or if page does not have any placeholder.
|
130
|
+
return;
|
131
|
+
}
|
132
|
+
|
133
|
+
$(':input[placeholder]').each(function() {
|
134
|
+
var el = $(this);
|
135
|
+
var text = el.attr('placeholder');
|
136
|
+
|
137
|
+
if (!el.val() || el.val() === text) {
|
138
|
+
el.val(text).addClass('placeholder_text');
|
139
|
+
}
|
140
|
+
});
|
141
|
+
}
|
142
|
+
}
|
143
|
+
};
|
144
|
+
// Alias jQuery, window, document.
|
145
|
+
})(jQuery, this, this.document);
|
146
|
+
|
147
|
+
// Automatically calls all functions in FORMALIZE.init
|
148
|
+
jQuery(document).ready(function() {
|
149
|
+
FORMALIZE.go();
|
150
|
+
});
|
@@ -0,0 +1 @@
|
|
1
|
+
var FORMALIZE=function(a,b,c,d){var e="placeholder"in c.createElement("input"),f="autofocus"in c.createElement("input"),g=!!a.browser.msie&&parseInt(a.browser.version,10)===6,h=!!a.browser.msie&&parseInt(a.browser.version,10)===7;return{go:function(){for(var a in FORMALIZE.init)FORMALIZE.init[a]()},init:{full_input_size:function(){!!h&&!!a("textarea, input.input_full").length&&a("textarea, input.input_full").wrap('<span class="input_full_wrap"></span>')},ie6_skin_inputs:function(){if(!!g&&!!a("input, select, textarea").length){var b=/button|submit|reset/,c=/date|datetime|datetime-local|email|month|number|password|range|search|tel|text|time|url|week/;a("input").each(function(){var d=a(this);this.getAttribute("type").match(b)?(d.addClass("ie6_button"),this.disabled&&d.addClass("ie6_button_disabled")):this.getAttribute("type").match(c)&&(d.addClass("ie6_input"),this.disabled&&d.addClass("ie6_input_disabled"))}),a("textarea, select").each(function(){this.disabled&&a(this).addClass("ie6_input_disabled")})}},autofocus:function(){!f&&!!a(":input[autofocus]").length&&a(":input[autofocus]:visible:first").focus()},placeholder:function(){!e&&!!a(":input[placeholder]").length&&(FORMALIZE.misc.add_placeholder(),a(":input[placeholder]").each(function(){var b=a(this),c=b.attr("placeholder");b.focus(function(){b.val()===c&&b.val("").removeClass("placeholder_text")}).blur(function(){FORMALIZE.misc.add_placeholder()}),b.closest("form").submit(function(){b.val()===c&&b.val("").removeClass("placeholder_text")}).bind("reset",function(){setTimeout(FORMALIZE.misc.add_placeholder,50)})}))}},misc:{add_placeholder:function(){!e&&!!a(":input[placeholder]").length&&a(":input[placeholder]").each(function(){var b=a(this),c=b.attr("placeholder");(!b.val()||b.val()===c)&&b.val(c).addClass("placeholder_text")})}}}}(jQuery,this,this.document);jQuery(document).ready(function(){FORMALIZE.go()})
|
@@ -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
|
+
});
|