Permalink
Browse files

Update formalize sources

  • Loading branch information...
1 parent 95fb496 commit 55e8290a4c50c46787f5b8da2bd395d9847c3db8 @iain committed Jan 25, 2012
@@ -1,24 +1,33 @@
/*
- Formalize - version 1.1
+ Formalize - version 1.2
Note: This file depends on the Dojo library.
*/
// Module pattern:
// http://yuiblog.com/blog/2007/06/12/module-pattern
var FORMALIZE = (function(window, document, undefined) {
+ // Internet Explorer detection.
+ function IE(version) {
+ var b = document.createElement('b');
+ b.innerHTML = '<!--[if IE ' + version + ']><br><![endif]-->';
+ return !!b.getElementsByTagName('br').length;
+ }
+
// Private constants.
var PLACEHOLDER_SUPPORTED = 'placeholder' in document.createElement('input');
var AUTOFOCUS_SUPPORTED = 'autofocus' in document.createElement('input');
- var IE6 = parseInt(dojo.isIE, 10) === 6;
- var IE7 = parseInt(dojo.isIE, 10) === 7;
+ var IE6 = IE(6);
+ var IE7 = IE(7);
// Expose innards of FORMALIZE.
return {
// FORMALIZE.go
go: function() {
- for (var i in FORMALIZE.init) {
- FORMALIZE.init[i]();
+ var i, j = FORMALIZE.init;
+
+ for (i in j) {
+ j.hasOwnProperty(i) && j[i]();
}
},
// FORMALIZE.init
@@ -102,6 +111,12 @@ var FORMALIZE = (function(window, document, undefined) {
FORMALIZE.misc.add_placeholder();
dojo.query('[placeholder]').forEach(function(el) {
+ // Placeholder obscured in older browsers,
+ // so there's no point adding to password.
+ if (el.type === 'password') {
+ return;
+ }
+
dojo.connect(el, 'onfocus', function() {
var text = el.getAttribute('placeholder');
@@ -147,6 +162,12 @@ var FORMALIZE = (function(window, document, undefined) {
}
dojo.query('[placeholder]').forEach(function(el) {
+ // Placeholder obscured in older browsers,
+ // so there's no point adding to password.
+ if (el.type === 'password') {
+ return;
+ }
+
var text = el.getAttribute('placeholder');
if (!el.value || el.value === text) {

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -1,24 +1,33 @@
/*
- Formalize - version 1.1
+ Formalize - version 1.2
Note: This file depends on the ExtJS 3.x library.
*/
// Module pattern:
// http://yuiblog.com/blog/2007/06/12/module-pattern
var FORMALIZE = (function(window, document, undefined) {
+ // Internet Explorer detection.
+ function IE(version) {
+ var b = document.createElement('b');
+ b.innerHTML = '<!--[if IE ' + version + ']><br><![endif]-->';
+ return !!b.getElementsByTagName('br').length;
+ }
+
// Private constants.
var PLACEHOLDER_SUPPORTED = 'placeholder' in document.createElement('input');
var AUTOFOCUS_SUPPORTED = 'autofocus' in document.createElement('input');
- var IE6 = Ext.isIE6;
- var IE7 = Ext.isIE7;
+ var IE6 = IE(6);
+ var IE7 = IE(7);
// Expose innards of FORMALIZE.
return {
// FORMALIZE.go
go: function() {
- for (var i in FORMALIZE.init) {
- FORMALIZE.init[i]();
+ var i, j = this.init;
+
+ for (i in j) {
+ j.hasOwnProperty(i) && j[i]();
}
},
// FORMALIZE.init
@@ -97,16 +106,15 @@ var FORMALIZE = (function(window, document, undefined) {
FORMALIZE.misc.add_placeholder();
Ext.each(Ext.query('[placeholder]'), function(el) {
+ // Placeholder obscured in older browsers,
+ // so there's no point adding to password.
+ if (el.type === 'password') {
+ return;
+ }
+
var text = el.getAttribute('placeholder');
var form = Ext.get(el).parent('form');
- function add_placeholder() {
- if (!el.value || el.value === text) {
- el.value = text;
- Ext.get(el).addClass('placeholder_text');
- }
- }
-
Ext.get(el).on('focus', function() {
if (el.value === text) {
el.value = '';
@@ -144,6 +152,12 @@ var FORMALIZE = (function(window, document, undefined) {
}
Ext.each(Ext.query('[placeholder]'), function(el) {
+ // Placeholder obscured in older browsers,
+ // so there's no point adding to password.
+ if (el.type === 'password') {
+ return;
+ }
+
var text = el.getAttribute('placeholder');
if (!el.value || el.value === text) {

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -1,24 +1,33 @@
/*
- Formalize - version 1.1
+ Formalize - version 1.2
Note: This file depends on the jQuery library.
*/
// Module pattern:
// http://yuiblog.com/blog/2007/06/12/module-pattern
var FORMALIZE = (function($, window, document, undefined) {
+ // Internet Explorer detection.
+ function IE(version) {
+ var b = document.createElement('b');
+ b.innerHTML = '<!--[if IE ' + version + ']><br><![endif]-->';
+ return !!b.getElementsByTagName('br').length;
+ }
+
// Private constants.
var PLACEHOLDER_SUPPORTED = 'placeholder' in document.createElement('input');
var AUTOFOCUS_SUPPORTED = 'autofocus' in document.createElement('input');
- var IE6 = !!($.browser.msie && parseInt($.browser.version, 10) === 6);
- var IE7 = !!($.browser.msie && parseInt($.browser.version, 10) === 7);
+ var IE6 = IE(6);
+ var IE7 = IE(7);
// Expose innards of FORMALIZE.
return {
// FORMALIZE.go
go: function() {
- for (var i in FORMALIZE.init) {
- FORMALIZE.init[i]();
+ var i, j = this.init;
+
+ for (i in j) {
+ j.hasOwnProperty(i) && j[i]();
}
},
// FORMALIZE.init
@@ -97,6 +106,12 @@ var FORMALIZE = (function($, window, document, undefined) {
FORMALIZE.misc.add_placeholder();
$(':input[placeholder]').each(function() {
+ // Placeholder obscured in older browsers,
+ // so there's no point adding to password.
+ if (this.type === 'password') {
+ return;
+ }
+
var el = $(this);
var text = el.attr('placeholder');
@@ -131,6 +146,12 @@ var FORMALIZE = (function($, window, document, undefined) {
}
$(':input[placeholder]').each(function() {
+ // Placeholder obscured in older browsers,
+ // so there's no point adding to password.
+ if (this.type === 'password') {
+ return;
+ }
+
var el = $(this);
var text = el.attr('placeholder');

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit 55e8290

Please sign in to comment.