compass_formalize 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. data/.DS_Store +0 -0
  2. data/.gitignore +2 -0
  3. data/README.md +6 -0
  4. data/Rakefile +4 -0
  5. data/compass_formalize.gemspec +20 -0
  6. data/lib/compass_formalize.rb +2 -0
  7. data/stylesheets/_formalize.sass +271 -0
  8. data/templates/.DS_Store +0 -0
  9. data/templates/dojo/button.png +0 -0
  10. data/templates/dojo/dojo.formalize.js +174 -0
  11. data/templates/dojo/dojo.formalize.min.js +1 -0
  12. data/templates/dojo/manifest.rb +37 -0
  13. data/templates/dojo/select_arrow.gif +0 -0
  14. data/templates/extjs/.DS_Store +0 -0
  15. data/templates/extjs/button.png +0 -0
  16. data/templates/extjs/extjs.formalize.js +168 -0
  17. data/templates/extjs/extjs.formalize.min.js +1 -0
  18. data/templates/extjs/manifest.rb +37 -0
  19. data/templates/extjs/select_arrow.gif +0 -0
  20. data/templates/jquery/.DS_Store +0 -0
  21. data/templates/jquery/button.png +0 -0
  22. data/templates/jquery/jquery.formalize.js +158 -0
  23. data/templates/jquery/jquery.formalize.min.js +1 -0
  24. data/templates/jquery/manifest.rb +37 -0
  25. data/templates/jquery/select_arrow.gif +0 -0
  26. data/templates/mootools/.DS_Store +0 -0
  27. data/templates/mootools/button.png +0 -0
  28. data/templates/mootools/manifest.rb +37 -0
  29. data/templates/mootools/mootools.formalize.js +163 -0
  30. data/templates/mootools/mootools.formalize.min.js +1 -0
  31. data/templates/mootools/select_arrow.gif +0 -0
  32. data/templates/project/manifest.rb +18 -0
  33. data/templates/prototype/.DS_Store +0 -0
  34. data/templates/prototype/button.png +0 -0
  35. data/templates/prototype/manifest.rb +37 -0
  36. data/templates/prototype/prototype.formalize.js +171 -0
  37. data/templates/prototype/prototype.formalize.min.js +1 -0
  38. data/templates/prototype/select_arrow.gif +0 -0
  39. data/templates/yui/.DS_Store +0 -0
  40. data/templates/yui/button.png +0 -0
  41. data/templates/yui/manifest.rb +37 -0
  42. data/templates/yui/select_arrow.gif +0 -0
  43. data/templates/yui/yui.formalize.js +168 -0
  44. data/templates/yui/yui.formalize.min.js +1 -0
  45. metadata +130 -0
Binary file
Binary file
Binary file
@@ -0,0 +1,37 @@
1
+ # Make sure you list all the project template files here in the manifest.
2
+ discover :all
3
+
4
+ description "Teach your forms some manners."
5
+
6
+ help %Q{
7
+ Please see the Formalize website for documentation:
8
+
9
+ http://formalize.me/
10
+ }
11
+
12
+ welcome_message %Q{
13
+
14
+ Formalize assets have been copied to the proper asset folders
15
+ based on your Compass configuration.
16
+
17
+ Usage:
18
+
19
+ If you're using SCSS syntax, in your stylesheet:
20
+
21
+ @import "formalize";
22
+
23
+ or if you're using indented syntax
24
+
25
+ @import "formalize"
26
+
27
+ In your HTML markup, include the JavaScript implementation of
28
+ your choice:
29
+
30
+ // a jQuery example
31
+ <script src="/javascripts/jquery.formalize.js"></script>
32
+
33
+ Please see the Formalize website for documentation:
34
+
35
+ http://formalize.me/
36
+ }
37
+
@@ -0,0 +1,163 @@
1
+ //
2
+ // Note: This file depends on the MooTools library.
3
+ //
4
+
5
+ // Module pattern:
6
+ // http://yuiblog.com/blog/2007/06/12/module-pattern/
7
+ var FORMALIZE = (function(window, document, undefined) {
8
+ // Private constants.
9
+ var PLACEHOLDER_SUPPORTED = 'placeholder' in document.createElement('input');
10
+ var AUTOFOCUS_SUPPORTED = 'autofocus' in document.createElement('input');
11
+ var WEBKIT = 'webkitAppearance' in document.createElement('select').style;
12
+ var IE6 = Browser.ie6;
13
+ var IE7 = Browser.ie7;
14
+
15
+ // Expose innards of FORMALIZE.
16
+ return {
17
+ // FORMALIZE.go
18
+ go: function() {
19
+ for (var i in FORMALIZE.init) {
20
+ FORMALIZE.init[i]();
21
+ }
22
+ },
23
+ // FORMALIZE.init
24
+ init: {
25
+ // FORMALIZE.init.detect_webkit
26
+ detect_webkit: function() {
27
+ if (!WEBKIT) {
28
+ return;
29
+ }
30
+
31
+ // Tweaks for Safari + Chrome.
32
+ $$('html')[0].addClass('is_webkit');
33
+ },
34
+ // FORMALIZE.init.full_input_size
35
+ full_input_size: function() {
36
+ if (!IE7 || !$$('textarea, input.input_full').length) {
37
+ return;
38
+ }
39
+
40
+ // This fixes width: 100% on <textarea> and class="input_full".
41
+ // It ensures that form elements don't go wider than container.
42
+ $$('textarea, input.input_full').each(function(el) {
43
+ new Element('span.input_full_wrap').wraps(el);
44
+ });
45
+
46
+ },
47
+ // FORMALIZE.init.ie6_skin_inputs
48
+ ie6_skin_inputs: function() {
49
+ // Test for Internet Explorer 6.
50
+ if (!IE6 || !$$('input, select, textarea').length) {
51
+ // Exit if the browser is not IE6,
52
+ // or if no form elements exist.
53
+ return;
54
+ }
55
+
56
+ // For <input type="submit" />, etc.
57
+ var button_regex = /button|submit|reset/;
58
+
59
+ // For <input type="text" />, etc.
60
+ var type_regex = /date|datetime|datetime-local|email|month|number|password|range|search|tel|text|time|url|week/;
61
+
62
+ $$('input').each(function(el) {
63
+ // Is it a button?
64
+ if (el.getAttribute('type').match(button_regex)) {
65
+ el.addClass('ie6_button');
66
+
67
+ /* Is it disabled? */
68
+ if (el.disabled) {
69
+ el.addClass('ie6_button_disabled');
70
+ }
71
+ }
72
+ // Or is it a textual input?
73
+ else if (el.getAttribute('type').match(type_regex)) {
74
+ el.addClass('ie6_input');
75
+
76
+ /* Is it disabled? */
77
+ if (el.disabled) {
78
+ el.addClass('ie6_input_disabled');
79
+ }
80
+ }
81
+ });
82
+
83
+ $$('textarea, select').each(function(el) {
84
+ /* Is it disabled? */
85
+ if (el.disabled) {
86
+ el.addClass('ie6_input_disabled');
87
+ }
88
+ });
89
+ },
90
+ // FORMALIZE.init.autofocus
91
+ autofocus: function() {
92
+ if (AUTOFOCUS_SUPPORTED || !$$('[autofocus]').length) {
93
+ return;
94
+ }
95
+
96
+ $$('[autofocus]')[0].focus();
97
+ },
98
+ // FORMALIZE.init.placeholder
99
+ placeholder: function() {
100
+ if (PLACEHOLDER_SUPPORTED || !$$('[placeholder]').length) {
101
+ // Exit if placeholder is supported natively,
102
+ // or if page does not have any placeholder.
103
+ return;
104
+ }
105
+
106
+ FORMALIZE.misc.add_placeholder();
107
+
108
+ $$('[placeholder]').each(function(el) {
109
+ var text = el.get('placeholder');
110
+
111
+ el.addEvents({
112
+ focus: function() {
113
+ if (el.value === text) {
114
+ el.set('value', '').removeClass('placeholder_text');
115
+ }
116
+ },
117
+ blur: function() {
118
+ FORMALIZE.misc.add_placeholder();
119
+ }
120
+ });
121
+
122
+ // Prevent <form> from accidentally
123
+ // submitting the placeholder text.
124
+ el.getParent('form').addEvents({
125
+ 'submit': function() {
126
+ if (el.value === text) {
127
+ el.set('value', '').removeClass('placeholder_text');
128
+ }
129
+ },
130
+ 'reset': function() {
131
+ setTimeout(FORMALIZE.misc.add_placeholder, 50);
132
+ }
133
+ });
134
+ });
135
+ }
136
+ },
137
+ // FORMALIZE.misc
138
+ misc: {
139
+ // FORMALIZE.misc.add_placeholder
140
+ add_placeholder: function() {
141
+ if (PLACEHOLDER_SUPPORTED || !$$('[placeholder]').length) {
142
+ // Exit if placeholder is supported natively,
143
+ // or if page does not have any placeholder.
144
+ return;
145
+ }
146
+
147
+ $$('[placeholder]').each(function(el) {
148
+ var text = el.get('placeholder');
149
+
150
+ if (!el.value || el.value === text) {
151
+ el.set('value', text).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
+ $(document).addEvent('domready', function() {
162
+ FORMALIZE.go();
163
+ });
@@ -0,0 +1 @@
1
+ var FORMALIZE=(function(f,b,g){var e="placeholder" in b.createElement("input");var c="autofocus" in b.createElement("input");var d="webkitAppearance" in b.createElement("select").style;var a=Browser.ie6;var h=Browser.ie7;return{go:function(){for(var j in FORMALIZE.init){FORMALIZE.init[j]();}},init:{detect_webkit:function(){if(!d){return;}$$("html")[0].addClass("is_webkit");},full_input_size:function(){if(!h||!$$("textarea, input.input_full").length){return;}$$("textarea, input.input_full").each(function(i){new Element("span.input_full_wrap").wraps(i);});},ie6_skin_inputs:function(){if(!a||!$$("input, select, textarea").length){return;}var i=/button|submit|reset/;var j=/date|datetime|datetime-local|email|month|number|password|range|search|tel|text|time|url|week/;$$("input").each(function(k){if(k.getAttribute("type").match(i)){k.addClass("ie6_button");if(k.disabled){k.addClass("ie6_button_disabled");}}else{if(k.getAttribute("type").match(j)){k.addClass("ie6_input");if(k.disabled){k.addClass("ie6_input_disabled");}}}});$$("textarea, select").each(function(k){if(k.disabled){k.addClass("ie6_input_disabled");}});},autofocus:function(){if(c||!$$("[autofocus]").length){return;}$$("[autofocus]")[0].focus();},placeholder:function(){if(e||!$$("[placeholder]").length){return;}FORMALIZE.misc.add_placeholder();$$("[placeholder]").each(function(i){var j=i.get("placeholder");i.addEvents({focus:function(){if(i.value===j){i.set("value","").removeClass("placeholder_text");}},blur:function(){FORMALIZE.misc.add_placeholder();}});i.getParent("form").addEvents({submit:function(){if(i.value===j){i.set("value","").removeClass("placeholder_text");}},reset:function(){setTimeout(FORMALIZE.misc.add_placeholder,50);}});});}},misc:{add_placeholder:function(){if(e||!$$("[placeholder]").length){return;}$$("[placeholder]").each(function(i){var j=i.get("placeholder");if(!i.value||i.value===j){i.set("value",j).addClass("placeholder_text");}});}}};})(this,this.document);$(document).addEvent("domready",function(){FORMALIZE.go();});
Binary file
@@ -0,0 +1,18 @@
1
+ description "Teach your forms some manners."
2
+
3
+ help %Q{
4
+ To install, use the formalize pattern:
5
+
6
+ Ensure formalize is in your config.rb (this will be done for you automatically if you require it on project creation)
7
+
8
+ require 'compass_formalize'
9
+
10
+ Next run the formalize pattern and follow the instructions.
11
+
12
+ compass install formalize/formalize
13
+
14
+ Please see the Formalize website for documentation:
15
+
16
+ http://formalize.me/
17
+ }
18
+
Binary file
Binary file
@@ -0,0 +1,37 @@
1
+ # Make sure you list all the project template files here in the manifest.
2
+ discover :all
3
+
4
+ description "Teach your forms some manners."
5
+
6
+ help %Q{
7
+ Please see the Formalize website for documentation:
8
+
9
+ http://formalize.me/
10
+ }
11
+
12
+ welcome_message %Q{
13
+
14
+ Formalize assets have been copied to the proper asset folders
15
+ based on your Compass configuration.
16
+
17
+ Usage:
18
+
19
+ If you're using SCSS syntax, in your stylesheet:
20
+
21
+ @import "formalize";
22
+
23
+ or if you're using indented syntax
24
+
25
+ @import "formalize"
26
+
27
+ In your HTML markup, include the JavaScript implementation of
28
+ your choice:
29
+
30
+ // a jQuery example
31
+ <script src="/javascripts/jquery.formalize.js"></script>
32
+
33
+ Please see the Formalize website for documentation:
34
+
35
+ http://formalize.me/
36
+ }
37
+
@@ -0,0 +1,171 @@
1
+ //
2
+ // Note: This file depends on the Prototype library.
3
+ //
4
+
5
+ // Module pattern:
6
+ // http://yuiblog.com/blog/2007/06/12/module-pattern/
7
+ var FORMALIZE = (function(window, document, undefined) {
8
+ // Private constants.
9
+ var PLACEHOLDER_SUPPORTED = 'placeholder' in document.createElement('input');
10
+ var AUTOFOCUS_SUPPORTED = 'autofocus' in document.createElement('input');
11
+ var WEBKIT = 'webkitAppearance' in document.createElement('select').style;
12
+ var IE6 = IE(6);
13
+ var IE7 = IE(7);
14
+
15
+ // Internet Explorer detection.
16
+ function IE(version) {
17
+ var b = document.createElement('b');
18
+ b.innerHTML = '<!--[if IE ' + version + ']><br><![endif]-->';
19
+ return !!b.getElementsByTagName('br').length;
20
+ }
21
+
22
+ // Expose innards of FORMALIZE.
23
+ return {
24
+ // FORMALIZE.go
25
+ go: function() {
26
+ for (var i in FORMALIZE.init) {
27
+ FORMALIZE.init[i]();
28
+ }
29
+ },
30
+ // FORMALIZE.init
31
+ init: {
32
+ // FORMALIZE.init.detect_webkit
33
+ detect_webkit: function() {
34
+ if (!WEBKIT) {
35
+ return;
36
+ }
37
+
38
+ // Tweaks for Safari + Chrome.
39
+ $$('html')[0].addClassName('is_webkit');
40
+ },
41
+ // FORMALIZE.init.full_input_size
42
+ full_input_size: function() {
43
+ if (!IE7 || !$$('textarea, input.input_full').length) {
44
+ return;
45
+ }
46
+
47
+ // This fixes width: 100% on <textarea> and class="input_full".
48
+ // It ensures that form elements don't go wider than container.
49
+ $$('textarea, input.input_full').each(function(el) {
50
+ Element.wrap(el, 'span', {'class': 'input_full_wrap'});
51
+ });
52
+ },
53
+ // FORMALIZE.init.ie6_skin_inputs
54
+ ie6_skin_inputs: function() {
55
+ // Test for Internet Explorer 6.
56
+ if (!IE6 || !$$('input, select, textarea').length) {
57
+ // Exit if the browser is not IE6,
58
+ // or if no form elements exist.
59
+ return;
60
+ }
61
+
62
+ // For <input type="submit" />, etc.
63
+ var button_regex = /button|submit|reset/;
64
+
65
+ // For <input type="text" />, etc.
66
+ var type_regex = /date|datetime|datetime-local|email|month|number|password|range|search|tel|text|time|url|week/;
67
+
68
+ $$('input').each(function(el) {
69
+ // Is it a button?
70
+ if (el.getAttribute('type').match(button_regex)) {
71
+ el.addClassName('ie6_button');
72
+
73
+ /* Is it disabled? */
74
+ if (el.disabled) {
75
+ el.addClassName('ie6_button_disabled');
76
+ }
77
+ }
78
+ // Or is it a textual input?
79
+ else if (el.getAttribute('type').match(type_regex)) {
80
+ el.addClassName('ie6_input');
81
+
82
+ /* Is it disabled? */
83
+ if (el.disabled) {
84
+ el.addClassName('ie6_input_disabled');
85
+ }
86
+ }
87
+ });
88
+
89
+ $$('textarea, select').each(function(el) {
90
+ /* Is it disabled? */
91
+ if (el.disabled) {
92
+ el.addClassName('ie6_input_disabled');
93
+ }
94
+ });
95
+ },
96
+ // FORMALIZE.init.autofocus
97
+ autofocus: function() {
98
+ if (AUTOFOCUS_SUPPORTED || !$$('[autofocus]').length) {
99
+ return;
100
+ }
101
+
102
+ $$('[autofocus]')[0].focus();
103
+ },
104
+ // FORMALIZE.init.placeholder
105
+ placeholder: function() {
106
+ if (PLACEHOLDER_SUPPORTED || !$$('[placeholder]').length) {
107
+ // Exit if placeholder is supported natively,
108
+ // or if page does not have any placeholder.
109
+ return;
110
+ }
111
+
112
+ FORMALIZE.misc.add_placeholder();
113
+
114
+ $$('[placeholder]').each(function(el) {
115
+ var text = el.getAttribute('placeholder');
116
+ var form = el.up('form');
117
+
118
+ el.observe('focus', function() {
119
+ if (el.value === text) {
120
+ el.value = '';
121
+ el.removeClassName('placeholder_text');
122
+ }
123
+ });
124
+
125
+ el.observe('blur', function() {
126
+ FORMALIZE.misc.add_placeholder();
127
+ });
128
+
129
+ // Prevent <form> from accidentally
130
+ // submitting the placeholder text.
131
+ form.observe('submit', function() {
132
+ if (el.value === text) {
133
+ el.value = '';
134
+ el.removeClassName('placeholder_text');
135
+ }
136
+ });
137
+
138
+ form.observe('reset', function() {
139
+ setTimeout(FORMALIZE.misc.add_placeholder, 50);
140
+ });
141
+ });
142
+ }
143
+ },
144
+ // FORMALIZE.misc
145
+ misc: {
146
+ // FORMALIZE.misc.add_placeholder
147
+ add_placeholder: function() {
148
+ if (PLACEHOLDER_SUPPORTED || !$$('[placeholder]').length) {
149
+ // Exit if placeholder is supported natively,
150
+ // or if page does not have any placeholder.
151
+ return;
152
+ }
153
+
154
+ $$('[placeholder]').each(function(el) {
155
+ var text = el.getAttribute('placeholder');
156
+
157
+ if (!el.value || el.value === text) {
158
+ el.value = text;
159
+ el.addClassName('placeholder_text');
160
+ }
161
+ });
162
+ }
163
+ }
164
+ };
165
+ // Alias window, document.
166
+ })(this, this.document);
167
+
168
+ // Automatically calls all functions in FORMALIZE.init
169
+ $(document).observe('dom:loaded', function() {
170
+ FORMALIZE.go();
171
+ });