compass_formalize 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +1 -0
  3. data/CHANGELOG.md +5 -4
  4. data/README.md +31 -0
  5. data/compass_formalize.gemspec +2 -2
  6. data/stylesheets/_formalize.sass +226 -170
  7. data/templates/{dojo → common}/button.png +0 -0
  8. data/templates/{dojo → common}/select_arrow.gif +0 -0
  9. data/templates/dojo/dojo.formalize.js +46 -19
  10. data/templates/dojo/dojo.formalize.min.js +1 -1
  11. data/templates/dojo/manifest.rb +5 -0
  12. data/templates/extjs/extjs.formalize.js +48 -25
  13. data/templates/extjs/extjs.formalize.min.js +1 -1
  14. data/templates/jquery-legacy/jquery.formalize.legacy.js +187 -0
  15. data/templates/jquery-legacy/jquery.formalize.legacy.min.js +1 -0
  16. data/templates/jquery-legacy/manifest.rb +42 -0
  17. data/templates/jquery/jquery.formalize.js +42 -20
  18. data/templates/jquery/jquery.formalize.min.js +1 -1
  19. data/templates/jquery/manifest.rb +6 -1
  20. data/templates/mootools/manifest.rb +5 -0
  21. data/templates/mootools/mootools.formalize.js +49 -20
  22. data/templates/mootools/mootools.formalize.min.js +1 -1
  23. data/templates/prototype/manifest.rb +5 -0
  24. data/templates/prototype/prototype.formalize.js +43 -23
  25. data/templates/prototype/prototype.formalize.min.js +1 -1
  26. data/templates/yui/manifest.rb +5 -0
  27. data/templates/yui/yui.formalize.js +57 -43
  28. data/templates/yui/yui.formalize.min.js +1 -1
  29. metadata +11 -40
  30. data/templates/extjs/button.png +0 -0
  31. data/templates/extjs/select_arrow.gif +0 -0
  32. data/templates/jquery/button.png +0 -0
  33. data/templates/jquery/select_arrow.gif +0 -0
  34. data/templates/mootools/button.png +0 -0
  35. data/templates/mootools/select_arrow.gif +0 -0
  36. data/templates/prototype/button.png +0 -0
  37. data/templates/prototype/select_arrow.gif +0 -0
  38. data/templates/yui/button.png +0 -0
  39. data/templates/yui/select_arrow.gif +0 -0
@@ -1,36 +1,42 @@
1
- //
2
- // Note: This file depends on the jQuery library.
3
- //
1
+ /*
2
+ Formalize - version 1.2
3
+
4
+ Note: This file depends on the jQuery library.
5
+ */
4
6
 
5
7
  // Module pattern:
6
- // http://yuiblog.com/blog/2007/06/12/module-pattern/
8
+ // http://yuiblog.com/blog/2007/06/12/module-pattern
7
9
  var FORMALIZE = (function($, window, document, undefined) {
10
+ // Internet Explorer detection.
11
+ function IE(version) {
12
+ var b = document.createElement('b');
13
+ b.innerHTML = '<!--[if IE ' + version + ']><br><![endif]-->';
14
+ return !!b.getElementsByTagName('br').length;
15
+ }
16
+
8
17
  // Private constants.
9
18
  var PLACEHOLDER_SUPPORTED = 'placeholder' in document.createElement('input');
10
19
  var AUTOFOCUS_SUPPORTED = 'autofocus' in document.createElement('input');
11
- var WEBKIT = 'webkitAppearance' in document.createElement('select').style;
12
- var IE6 = !!($.browser.msie && parseInt($.browser.version, 10) === 6);
13
- var IE7 = !!($.browser.msie && parseInt($.browser.version, 10) === 7);
20
+ var IE6 = IE(6);
21
+ var IE7 = IE(7);
14
22
 
15
23
  // Expose innards of FORMALIZE.
16
24
  return {
17
25
  // FORMALIZE.go
18
26
  go: function() {
19
- for (var i in FORMALIZE.init) {
20
- FORMALIZE.init[i]();
27
+ var i, j = this.init;
28
+
29
+ for (i in j) {
30
+ j.hasOwnProperty(i) && j[i]();
21
31
  }
22
32
  },
23
33
  // FORMALIZE.init
24
34
  init: {
25
- // FORMALIZE.init.detect_webkit
26
- detect_webkit: function() {
27
- if (!WEBKIT) {
28
- return;
29
- }
30
-
31
- // Tweaks for Safari + Chrome.
32
- // <html class="is_webkit">
33
- $(document.documentElement).addClass('is_webkit');
35
+ // FORMALIZE.init.disable_link_button
36
+ disable_link_button: function() {
37
+ $(document.documentElement).on('click', 'a.button_disabled', function() {
38
+ return false;
39
+ });
34
40
  },
35
41
  // FORMALIZE.init.full_input_size
36
42
  full_input_size: function() {
@@ -93,7 +99,11 @@ var FORMALIZE = (function($, window, document, undefined) {
93
99
  return;
94
100
  }
95
101
 
96
- $(':input[autofocus]:visible:first').focus();
102
+ var el = $('[autofocus]')[0];
103
+
104
+ if (!el.disabled) {
105
+ el.focus();
106
+ }
97
107
  },
98
108
  // FORMALIZE.init.placeholder
99
109
  placeholder: function() {
@@ -106,6 +116,12 @@ var FORMALIZE = (function($, window, document, undefined) {
106
116
  FORMALIZE.misc.add_placeholder();
107
117
 
108
118
  $(':input[placeholder]').each(function() {
119
+ // Placeholder obscured in older browsers,
120
+ // so there's no point adding to password.
121
+ if (this.type === 'password') {
122
+ return;
123
+ }
124
+
109
125
  var el = $(this);
110
126
  var text = el.attr('placeholder');
111
127
 
@@ -123,7 +139,7 @@ var FORMALIZE = (function($, window, document, undefined) {
123
139
  if (el.val() === text) {
124
140
  el.val('').removeClass('placeholder_text');
125
141
  }
126
- }).bind('reset', function() {
142
+ }).on('reset', function() {
127
143
  setTimeout(FORMALIZE.misc.add_placeholder, 50);
128
144
  });
129
145
  });
@@ -140,6 +156,12 @@ var FORMALIZE = (function($, window, document, undefined) {
140
156
  }
141
157
 
142
158
  $(':input[placeholder]').each(function() {
159
+ // Placeholder obscured in older browsers,
160
+ // so there's no point adding to password.
161
+ if (this.type === 'password') {
162
+ return;
163
+ }
164
+
143
165
  var el = $(this);
144
166
  var text = el.attr('placeholder');
145
167
 
@@ -1 +1 @@
1
- var FORMALIZE=function(a,b,c,d){var e="placeholder"in c.createElement("input"),f="autofocus"in c.createElement("input"),g="webkitAppearance"in c.createElement("select").style,h=!!a.browser.msie&&parseInt(a.browser.version,10)===6,i=!!a.browser.msie&&parseInt(a.browser.version,10)===7;return{go:function(){for(var a in FORMALIZE.init)FORMALIZE.init[a]()},init:{detect_webkit:function(){!g||a(c.documentElement).addClass("is_webkit")},full_input_size:function(){!!i&&!!a("textarea, input.input_full").length&&a("textarea, input.input_full").wrap('<span class="input_full_wrap"></span>')},ie6_skin_inputs:function(){if(!!h&&!!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()})
1
+ var FORMALIZE=function(e,t,n,r){function i(e){var t=n.createElement("b");return t.innerHTML="<!--[if IE "+e+"]><br><![endif]-->",!!t.getElementsByTagName("br").length}var s="placeholder"in n.createElement("input"),o="autofocus"in n.createElement("input"),u=i(6),a=i(7);return{go:function(){var e,t=this.init;for(e in t)t.hasOwnProperty(e)&&t[e]()},init:{disable_link_button:function(){e(n.documentElement).on("click","a.button_disabled",function(){return!1})},full_input_size:function(){if(!a||!e("textarea, input.input_full").length)return;e("textarea, input.input_full").wrap('<span class="input_full_wrap"></span>')},ie6_skin_inputs:function(){if(!u||!e("input, select, textarea").length)return;var t=/button|submit|reset/,n=/date|datetime|datetime-local|email|month|number|password|range|search|tel|text|time|url|week/;e("input").each(function(){var r=e(this);this.getAttribute("type").match(t)?(r.addClass("ie6_button"),this.disabled&&r.addClass("ie6_button_disabled")):this.getAttribute("type").match(n)&&(r.addClass("ie6_input"),this.disabled&&r.addClass("ie6_input_disabled"))}),e("textarea, select").each(function(){this.disabled&&e(this).addClass("ie6_input_disabled")})},autofocus:function(){if(o||!e(":input[autofocus]").length)return;var t=e("[autofocus]")[0];t.disabled||t.focus()},placeholder:function(){if(s||!e(":input[placeholder]").length)return;FORMALIZE.misc.add_placeholder(),e(":input[placeholder]").each(function(){if(this.type==="password")return;var t=e(this),n=t.attr("placeholder");t.focus(function(){t.val()===n&&t.val("").removeClass("placeholder_text")}).blur(function(){FORMALIZE.misc.add_placeholder()}),t.closest("form").submit(function(){t.val()===n&&t.val("").removeClass("placeholder_text")}).on("reset",function(){setTimeout(FORMALIZE.misc.add_placeholder,50)})})}},misc:{add_placeholder:function(){if(s||!e(":input[placeholder]").length)return;e(":input[placeholder]").each(function(){if(this.type==="password")return;var t=e(this),n=t.attr("placeholder");(!t.val()||t.val()===n)&&t.val(n).addClass("placeholder_text")})}}}}(jQuery,this,this.document);jQuery(document).ready(function(){FORMALIZE.go()})
@@ -1,5 +1,10 @@
1
1
  # Make sure you list all the project template files here in the manifest.
2
- discover :all
2
+
3
+ # Image Import
4
+ file '../common/button.png', :like => :image, :to => 'button.png'
5
+ file '../common/select_arrow.gif', :like => :image, :to => 'select_arrow.gif'
6
+
7
+ discover :all
3
8
 
4
9
  description "Teach your forms some manners."
5
10
 
@@ -1,4 +1,9 @@
1
1
  # Make sure you list all the project template files here in the manifest.
2
+
3
+ # Image Import
4
+ file '../common/button.png', :like => :image, :to => 'button.png'
5
+ file '../common/select_arrow.gif', :like => :image, :to => 'select_arrow.gif'
6
+
2
7
  discover :all
3
8
 
4
9
  description "Teach your forms some manners."
@@ -1,36 +1,47 @@
1
- //
2
- // Note: This file depends on the MooTools library.
3
- //
1
+ /*
2
+ Formalize - version 1.2
3
+
4
+ Note: This file depends on the MooTools library.
5
+ */
4
6
 
5
7
  // Module pattern:
6
- // http://yuiblog.com/blog/2007/06/12/module-pattern/
8
+ // http://yuiblog.com/blog/2007/06/12/module-pattern
7
9
  var FORMALIZE = (function(window, document, undefined) {
10
+ // Internet Explorer detection.
11
+ function IE(version) {
12
+ var b = document.createElement('b');
13
+ b.innerHTML = '<!--[if IE ' + version + ']><br><![endif]-->';
14
+ return !!b.getElementsByTagName('br').length;
15
+ }
16
+
8
17
  // Private constants.
9
18
  var PLACEHOLDER_SUPPORTED = 'placeholder' in document.createElement('input');
10
19
  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;
20
+ var IE6 = IE(6);
21
+ var IE7 = IE(7);
14
22
 
15
23
  // Expose innards of FORMALIZE.
16
24
  return {
17
25
  // FORMALIZE.go
18
26
  go: function() {
19
- for (var i in FORMALIZE.init) {
20
- FORMALIZE.init[i]();
27
+ var i, j = this.init;
28
+
29
+ for (i in j) {
30
+ j.hasOwnProperty(i) && j[i]();
21
31
  }
22
32
  },
23
33
  // FORMALIZE.init
24
34
  init: {
25
- // FORMALIZE.init.detect_webkit
26
- detect_webkit: function() {
27
- if (!WEBKIT) {
28
- return;
29
- }
30
-
31
- // Tweaks for Safari + Chrome.
32
- // <html class="is_webkit">
33
- $(document.documentElement).addClass('is_webkit');
35
+ // FORMALIZE.init.disable_link_button
36
+ disable_link_button: function() {
37
+ $(document.documentElement).addEvent('click', function(ev) {
38
+ var el = ev.target;
39
+ var is_disabled = el.tagName.toLowerCase() === 'a' && el.className.match('button_disabled');
40
+
41
+ if (is_disabled) {
42
+ ev.preventDefault();
43
+ }
44
+ });
34
45
  },
35
46
  // FORMALIZE.init.full_input_size
36
47
  full_input_size: function() {
@@ -94,7 +105,11 @@ var FORMALIZE = (function(window, document, undefined) {
94
105
  return;
95
106
  }
96
107
 
97
- $$('[autofocus]')[0].focus();
108
+ var el = $$('[autofocus]')[0];
109
+
110
+ if (!el.disabled) {
111
+ el.focus();
112
+ }
98
113
  },
99
114
  // FORMALIZE.init.placeholder
100
115
  placeholder: function() {
@@ -107,6 +122,12 @@ var FORMALIZE = (function(window, document, undefined) {
107
122
  FORMALIZE.misc.add_placeholder();
108
123
 
109
124
  $$('[placeholder]').each(function(el) {
125
+ // Placeholder obscured in older browsers,
126
+ // so there's no point adding to password.
127
+ if (el.type === 'password') {
128
+ return;
129
+ }
130
+
110
131
  var text = el.get('placeholder');
111
132
 
112
133
  el.addEvents({
@@ -122,7 +143,9 @@ var FORMALIZE = (function(window, document, undefined) {
122
143
 
123
144
  // Prevent <form> from accidentally
124
145
  // submitting the placeholder text.
125
- el.getParent('form').addEvents({
146
+ var form = el.getParent('form');
147
+
148
+ form && form.addEvents({
126
149
  'submit': function() {
127
150
  if (el.value === text) {
128
151
  el.set('value', '').removeClass('placeholder_text');
@@ -146,6 +169,12 @@ var FORMALIZE = (function(window, document, undefined) {
146
169
  }
147
170
 
148
171
  $$('[placeholder]').each(function(el) {
172
+ // Placeholder obscured in older browsers,
173
+ // so there's no point adding to password.
174
+ if (el.type === 'password') {
175
+ return;
176
+ }
177
+
149
178
  var text = el.get('placeholder');
150
179
 
151
180
  if (!el.value || el.value === text) {
@@ -1 +1 @@
1
- var FORMALIZE=function(a,b,c){var d="placeholder"in b.createElement("input"),e="autofocus"in b.createElement("input"),f="webkitAppearance"in b.createElement("select").style,g=Browser.ie6,h=Browser.ie7;return{go:function(){for(var a in FORMALIZE.init)FORMALIZE.init[a]()},init:{detect_webkit:function(){!f||$(b.documentElement).addClass("is_webkit")},full_input_size:function(){!!h&&!!$$("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(!!g&&!!$$("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()})
1
+ var FORMALIZE=function(e,t,n){function r(e){var n=t.createElement("b");return n.innerHTML="<!--[if IE "+e+"]><br><![endif]-->",!!n.getElementsByTagName("br").length}var i="placeholder"in t.createElement("input"),s="autofocus"in t.createElement("input"),o=r(6),u=r(7);return{go:function(){var e,t=this.init;for(e in t)t.hasOwnProperty(e)&&t[e]()},init:{disable_link_button:function(){$(t.documentElement).addEvent("click",function(e){var t=e.target,n=t.tagName.toLowerCase()==="a"&&t.className.match("button_disabled");n&&e.preventDefault()})},full_input_size:function(){if(!u||!$$("textarea, input.input_full").length)return;$$("textarea, input.input_full").each(function(e){(new Element("span.input_full_wrap")).wraps(e)})},ie6_skin_inputs:function(){if(!o||!$$("input, select, textarea").length)return;var e=/button|submit|reset/,t=/date|datetime|datetime-local|email|month|number|password|range|search|tel|text|time|url|week/;$$("input").each(function(n){n.getAttribute("type").match(e)?(n.addClass("ie6_button"),n.disabled&&n.addClass("ie6_button_disabled")):n.getAttribute("type").match(t)&&(n.addClass("ie6_input"),n.disabled&&n.addClass("ie6_input_disabled"))}),$$("textarea, select").each(function(e){e.disabled&&e.addClass("ie6_input_disabled")})},autofocus:function(){if(s||!$$("[autofocus]").length)return;var e=$$("[autofocus]")[0];e.disabled||e.focus()},placeholder:function(){if(i||!$$("[placeholder]").length)return;FORMALIZE.misc.add_placeholder(),$$("[placeholder]").each(function(e){if(e.type==="password")return;var t=e.get("placeholder");e.addEvents({focus:function(){e.value===t&&e.set("value","").removeClass("placeholder_text")},blur:function(){FORMALIZE.misc.add_placeholder()}});var n=e.getParent("form");n&&n.addEvents({submit:function(){e.value===t&&e.set("value","").removeClass("placeholder_text")},reset:function(){setTimeout(FORMALIZE.misc.add_placeholder,50)}})})}},misc:{add_placeholder:function(){if(i||!$$("[placeholder]").length)return;$$("[placeholder]").each(function(e){if(e.type==="password")return;var t=e.get("placeholder");(!e.value||e.value===t)&&e.set("value",t).addClass("placeholder_text")})}}}}(this,this.document);$(document).addEvent("domready",function(){FORMALIZE.go()})
@@ -1,4 +1,9 @@
1
1
  # Make sure you list all the project template files here in the manifest.
2
+
3
+ # Image Import
4
+ file '../common/button.png', :like => :image, :to => 'button.png'
5
+ file '../common/select_arrow.gif', :like => :image, :to => 'select_arrow.gif'
6
+
2
7
  discover :all
3
8
 
4
9
  description "Teach your forms some manners."
@@ -1,17 +1,12 @@
1
- //
2
- // Note: This file depends on the Prototype library.
3
- //
1
+ /*
2
+ Formalize - version 1.2
3
+
4
+ Note: This file depends on the Prototype library.
5
+ */
4
6
 
5
7
  // Module pattern:
6
- // http://yuiblog.com/blog/2007/06/12/module-pattern/
8
+ // http://yuiblog.com/blog/2007/06/12/module-pattern
7
9
  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
10
  // Internet Explorer detection.
16
11
  function IE(version) {
17
12
  var b = document.createElement('b');
@@ -19,25 +14,34 @@ var FORMALIZE = (function(window, document, undefined) {
19
14
  return !!b.getElementsByTagName('br').length;
20
15
  }
21
16
 
17
+ // Private constants.
18
+ var PLACEHOLDER_SUPPORTED = 'placeholder' in document.createElement('input');
19
+ var AUTOFOCUS_SUPPORTED = 'autofocus' in document.createElement('input');
20
+ var IE6 = IE(6);
21
+ var IE7 = IE(7);
22
+
22
23
  // Expose innards of FORMALIZE.
23
24
  return {
24
25
  // FORMALIZE.go
25
26
  go: function() {
26
- for (var i in FORMALIZE.init) {
27
- FORMALIZE.init[i]();
27
+ var i, j = this.init;
28
+
29
+ for (i in j) {
30
+ j.hasOwnProperty(i) && j[i]();
28
31
  }
29
32
  },
30
33
  // FORMALIZE.init
31
34
  init: {
32
- // FORMALIZE.init.detect_webkit
33
- detect_webkit: function() {
34
- if (!WEBKIT) {
35
- return;
36
- }
37
-
38
- // Tweaks for Safari + Chrome.
39
- // <html class="is_webkit">
40
- $(document.documentElement).addClassName('is_webkit');
35
+ // FORMALIZE.init.disable_link_button
36
+ disable_link_button: function() {
37
+ $(document.documentElement).observe('click', function(ev) {
38
+ var el = ev.target;
39
+ var is_disabled = el.tagName.toLowerCase() === 'a' && el.className.match('button_disabled');
40
+
41
+ if (is_disabled) {
42
+ ev.preventDefault();
43
+ }
44
+ });
41
45
  },
42
46
  // FORMALIZE.init.full_input_size
43
47
  full_input_size: function() {
@@ -100,7 +104,11 @@ var FORMALIZE = (function(window, document, undefined) {
100
104
  return;
101
105
  }
102
106
 
103
- $$('[autofocus]')[0].focus();
107
+ var el = $$('[autofocus]')[0];
108
+
109
+ if (!el.disabled) {
110
+ el.focus();
111
+ }
104
112
  },
105
113
  // FORMALIZE.init.placeholder
106
114
  placeholder: function() {
@@ -113,6 +121,12 @@ var FORMALIZE = (function(window, document, undefined) {
113
121
  FORMALIZE.misc.add_placeholder();
114
122
 
115
123
  $$('[placeholder]').each(function(el) {
124
+ // Placeholder obscured in older browsers,
125
+ // so there's no point adding to password.
126
+ if (el.type === 'password') {
127
+ return;
128
+ }
129
+
116
130
  var text = el.getAttribute('placeholder');
117
131
  var form = el.up('form');
118
132
 
@@ -153,6 +167,12 @@ var FORMALIZE = (function(window, document, undefined) {
153
167
  }
154
168
 
155
169
  $$('[placeholder]').each(function(el) {
170
+ // Placeholder obscured in older browsers,
171
+ // so there's no point adding to password.
172
+ if (el.type === 'password') {
173
+ return;
174
+ }
175
+
156
176
  var text = el.getAttribute('placeholder');
157
177
 
158
178
  if (!el.value || el.value === text) {
@@ -1 +1 @@
1
- var FORMALIZE=function(a,b,c){function i(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="webkitAppearance"in b.createElement("select").style,g=i(6),h=i(7);return{go:function(){for(var a in FORMALIZE.init)FORMALIZE.init[a]()},init:{detect_webkit:function(){!f||$(b.documentElement).addClassName("is_webkit")},full_input_size:function(){!!h&&!!$$("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(!!g&&!!$$("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()})
1
+ var FORMALIZE=function(e,t,n){function r(e){var n=t.createElement("b");return n.innerHTML="<!--[if IE "+e+"]><br><![endif]-->",!!n.getElementsByTagName("br").length}var i="placeholder"in t.createElement("input"),s="autofocus"in t.createElement("input"),o=r(6),u=r(7);return{go:function(){var e,t=this.init;for(e in t)t.hasOwnProperty(e)&&t[e]()},init:{disable_link_button:function(){$(t.documentElement).observe("click",function(e){var t=e.target,n=t.tagName.toLowerCase()==="a"&&t.className.match("button_disabled");n&&e.preventDefault()})},full_input_size:function(){if(!u||!$$("textarea, input.input_full").length)return;$$("textarea, input.input_full").each(function(e){Element.wrap(e,"span",{"class":"input_full_wrap"})})},ie6_skin_inputs:function(){if(!o||!$$("input, select, textarea").length)return;var e=/button|submit|reset/,t=/date|datetime|datetime-local|email|month|number|password|range|search|tel|text|time|url|week/;$$("input").each(function(n){n.getAttribute("type").match(e)?(n.addClassName("ie6_button"),n.disabled&&n.addClassName("ie6_button_disabled")):n.getAttribute("type").match(t)&&(n.addClassName("ie6_input"),n.disabled&&n.addClassName("ie6_input_disabled"))}),$$("textarea, select").each(function(e){e.disabled&&e.addClassName("ie6_input_disabled")})},autofocus:function(){if(s||!$$("[autofocus]").length)return;var e=$$("[autofocus]")[0];e.disabled||e.focus()},placeholder:function(){if(i||!$$("[placeholder]").length)return;FORMALIZE.misc.add_placeholder(),$$("[placeholder]").each(function(e){if(e.type==="password")return;var t=e.getAttribute("placeholder"),n=e.up("form");e.observe("focus",function(){e.value===t&&(e.value="",e.removeClassName("placeholder_text"))}),e.observe("blur",function(){FORMALIZE.misc.add_placeholder()}),n.observe("submit",function(){e.value===t&&(e.value="",e.removeClassName("placeholder_text"))}),n.observe("reset",function(){setTimeout(FORMALIZE.misc.add_placeholder,50)})})}},misc:{add_placeholder:function(){if(i||!$$("[placeholder]").length)return;$$("[placeholder]").each(function(e){if(e.type==="password")return;var t=e.getAttribute("placeholder");if(!e.value||e.value===t)e.value=t,e.addClassName("placeholder_text")})}}}}(this,this.document);$(document).observe("dom:loaded",function(){FORMALIZE.go()})
@@ -1,4 +1,9 @@
1
1
  # Make sure you list all the project template files here in the manifest.
2
+
3
+ # Image Import
4
+ file '../common/button.png', :like => :image, :to => 'button.png'
5
+ file '../common/select_arrow.gif', :like => :image, :to => 'select_arrow.gif'
6
+
2
7
  discover :all
3
8
 
4
9
  description "Teach your forms some manners."
@@ -1,38 +1,42 @@
1
- //
2
- // Note: This file depends on the YUI library.
3
- //
1
+ /*
2
+ Formalize - version 1.2
3
+
4
+ Note: This file depends on the YUI library.
5
+ */
6
+
7
+ YUI.add('formalize', function(Y) {
8
+ // Internet Explorer detection.
9
+ function IE(version) {
10
+ var b = document.createElement('b');
11
+ b.innerHTML = '<!--[if IE ' + version + ']><br><![endif]-->';
12
+ return !!b.getElementsByTagName('br').length;
13
+ }
4
14
 
5
- // Module pattern:
6
- // http://yuiblog.com/blog/2007/06/12/module-pattern/
7
- var FORMALIZE = (function(window, document, undefined) {
8
15
  // Private constants.
9
16
  var PLACEHOLDER_SUPPORTED = 'placeholder' in document.createElement('input');
10
17
  var AUTOFOCUS_SUPPORTED = 'autofocus' in document.createElement('input');
11
- var WEBKIT = 'webkitAppearance' in document.createElement('select').style;
12
- var IE6 = parseInt(Y.UA.ie, 10) === 6;
13
- var IE7 = parseInt(Y.UA.ie, 10) === 7;
18
+ var IE6 = IE(6);
19
+ var IE7 = IE(7);
14
20
 
15
- // Expose innards of FORMALIZE.
16
- return {
17
- // FORMALIZE.go
21
+ // Expose innards of Formalize.
22
+ Y.formalize = {
23
+ // Y.formalize.go
18
24
  go: function() {
19
- for (var i in FORMALIZE.init) {
20
- FORMALIZE.init[i]();
25
+ var i, j = this.init;
26
+
27
+ for (i in j) {
28
+ j.hasOwnProperty(i) && j[i]();
21
29
  }
22
30
  },
23
- // FORMALIZE.init
31
+ // Y.formalize.init
24
32
  init: {
25
- // FORMALIZE.init.detect_webkit
26
- detect_webkit: function() {
27
- if (!WEBKIT) {
28
- return;
29
- }
30
-
31
- // Tweaks for Safari + Chrome.
32
- // <html class="is_webkit">
33
- Y.one(document.documentElement).addClass('is_webkit');
33
+ // Y.formalize.init.disable_link_button
34
+ disable_link_button: function() {
35
+ Y.one(document.documentElement).delegate('click', function(ev) {
36
+ ev.preventDefault();
37
+ }, 'a.button_disabled');
34
38
  },
35
- // FORMALIZE.init.full_input_size
39
+ // Y.formalize.init.full_input_size
36
40
  full_input_size: function() {
37
41
  if (!IE7 || !Y.all('textarea, input.input_full')) {
38
42
  return;
@@ -45,7 +49,7 @@ var FORMALIZE = (function(window, document, undefined) {
45
49
  wrapper.append(el.replace(wrapper));
46
50
  });
47
51
  },
48
- // FORMALIZE.init.ie6_skin_inputs
52
+ // Y.formalize.init.ie6_skin_inputs
49
53
  ie6_skin_inputs: function() {
50
54
  // Test for Internet Explorer 6.
51
55
  if (!IE6 || !Y.all('input, select, textarea')) {
@@ -88,15 +92,19 @@ var FORMALIZE = (function(window, document, undefined) {
88
92
  }
89
93
  });
90
94
  },
91
- // FORMALIZE.init.autofocus
95
+ // Y.formalize.init.autofocus
92
96
  autofocus: function() {
93
97
  if (AUTOFOCUS_SUPPORTED || !Y.one('[autofocus]')) {
94
98
  return;
95
99
  }
96
100
 
97
- Y.one('[autofocus]').focus();
101
+ var el = Y.Node.getDOMNode(Y.one('[autofocus]'));
102
+
103
+ if (!el.disabled) {
104
+ el.focus();
105
+ }
98
106
  },
99
- // FORMALIZE.init.placeholder
107
+ // Y.formalize.init.placeholder
100
108
  placeholder: function() {
101
109
  if (PLACEHOLDER_SUPPORTED || !Y.one('[placeholder]')) {
102
110
  // Exit if placeholder is supported natively,
@@ -104,9 +112,15 @@ var FORMALIZE = (function(window, document, undefined) {
104
112
  return;
105
113
  }
106
114
 
107
- FORMALIZE.misc.add_placeholder();
115
+ Y.formalize.misc.add_placeholder();
108
116
 
109
117
  Y.all('[placeholder]').each(function(el) {
118
+ // Placeholder obscured in older browsers,
119
+ // so there's no point adding to password.
120
+ if (el.getAttribute('type') === 'password') {
121
+ return;
122
+ }
123
+
110
124
  var text = el.getAttribute('placeholder');
111
125
  var form = el.ancestor('form');
112
126
 
@@ -123,26 +137,26 @@ var FORMALIZE = (function(window, document, undefined) {
123
137
  });
124
138
 
125
139
  el.on('blur', function() {
126
- FORMALIZE.misc.add_placeholder();
140
+ Y.formalize.misc.add_placeholder();
127
141
  });
128
142
 
129
143
  // Prevent <form> from accidentally
130
144
  // submitting the placeholder text.
131
- form.on('submit', function() {
145
+ form && form.on('submit', function() {
132
146
  if (el.get('value') === text) {
133
147
  el.set('value', '').removeClass('placeholder_text');
134
148
  }
135
149
  });
136
150
 
137
- form.on('reset', function() {
138
- setTimeout(FORMALIZE.misc.add_placeholder, 50);
151
+ form && form.on('reset', function() {
152
+ setTimeout(Y.formalize.misc.add_placeholder, 50);
139
153
  });
140
154
  });
141
155
  }
142
156
  },
143
- // FORMALIZE.misc
157
+ // Y.formalize.misc
144
158
  misc: {
145
- // FORMALIZE.misc.add_placeholder
159
+ // Y.formalize.misc.add_placeholder
146
160
  add_placeholder: function() {
147
161
  if (PLACEHOLDER_SUPPORTED || !Y.one('[placeholder]')) {
148
162
  // Exit if placeholder is supported natively,
@@ -151,6 +165,12 @@ var FORMALIZE = (function(window, document, undefined) {
151
165
  }
152
166
 
153
167
  Y.all('[placeholder]').each(function(el) {
168
+ // Placeholder obscured in older browsers,
169
+ // so there's no point adding to password.
170
+ if (el.getAttribute('type') === 'password') {
171
+ return;
172
+ }
173
+
154
174
  var text = el.getAttribute('placeholder');
155
175
 
156
176
  if (!el.get('value') || el.get('value') === text) {
@@ -160,10 +180,4 @@ var FORMALIZE = (function(window, document, undefined) {
160
180
  }
161
181
  }
162
182
  };
163
- // Alias window, document.
164
- })(this, this.document);
165
-
166
- // Automatically calls all functions in FORMALIZE.init
167
- Y.on('domready', function() {
168
- FORMALIZE.go();
169
- });
183
+ }, '1.1', {requires: ['node', 'event']});