Skip to content

Commit

Permalink
Added Firefox support for onforminput. Even though it is has been
Browse files Browse the repository at this point in the history
depricated from the HTML5 spec, it is still useful.

Change-Id: Ia303136caa2c564095e8b923b62e19bf7143c303
  • Loading branch information
zoltan-dulac committed May 9, 2011
1 parent af6fff5 commit 5d95a9f
Showing 1 changed file with 32 additions and 6 deletions.
38 changes: 32 additions & 6 deletions shared/js/html5Widgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ var html5Widgets = new function(){
return;
}



isDebug = CSSHelpers.isMemberOfClass(document.body, 'html5Widgets-debug')

// dummy link setup
Expand All @@ -64,6 +66,8 @@ var html5Widgets = new function(){

}



function supports_input_placeholder() {
var i = document.createElement('input');
return 'placeholder' in i;
Expand Down Expand Up @@ -95,7 +99,7 @@ var html5Widgets = new function(){
var outputElements = document.getElementsByTagName('output');
for (var i=0; i<outputElements.length; i++) {
var outputEl = outputElements[i];
if (outputEl.value != undefined) {
if (outputEl.value != undefined && outputEl.onforminput != undefined) {

// this browser supports the output tag .. bail
supportsNatively["output"] = true;
Expand Down Expand Up @@ -403,9 +407,9 @@ var html5Widgets = new function(){

Calendar.setup(
{
eventName :"focus",
eventName :"click",
showsTime : type.indexOf('time') >= 0,
//cache : true,
cache : true,
inputField : me.node.id, // ID of the input field
ifFormat : formatString, // the date format
button : me.node.id // ID of the button
Expand All @@ -414,7 +418,10 @@ var html5Widgets = new function(){



EventHelpers.addEvent(me.node, 'click', openCalendar);


EventHelpers.addEvent(me.node, 'click', forceCalToTop);
EventHelpers.addEvent(me.node, 'focus', focusEvent)
EventHelpers.addEvent(me.node, 'keypress', openCalendar);
EventHelpers.addEvent(me.node, 'blur', closeCalendar);

Expand Down Expand Up @@ -491,9 +498,22 @@ var html5Widgets = new function(){
}
}

function forceCalToTop(e) {
var cal = window.calendar;

cal.element.style.zIndex = 100;
}

function focusEvent(e) {
var el = EventHelpers.getEventTarget(e);
EventHelpers.fireEvent(el, 'click')
}

function openCalendar(e) {

var cal = window.calendar;
cal.element.style.zIndex = 0;

cal.element.style.zIndex = 100;
if (cal.open != undefined) {
cal.open();
}
Expand Down Expand Up @@ -620,7 +640,10 @@ var html5Widgets = new function(){
setPlaceholderText(true);
EventHelpers.addEvent(me.node, 'blur', blurEvent);
EventHelpers.addEvent(me.node, 'focus', focusEvent);
EventHelpers.addEvent(me.node.form, 'submit', removePlaceholderText);

if (me.node.form) {
EventHelpers.addEvent(me.node.form, 'submit', removePlaceholderText);
}

if (window.$wf2) {
if ($wf2.callBeforeValidation != undefined) {
Expand Down Expand Up @@ -844,6 +867,8 @@ var html5Widgets = new function(){
}
return null;
}


}

var StringHelpers = new function () {
Expand Down Expand Up @@ -1056,3 +1081,4 @@ var html5Widgets = new function(){


EventHelpers.addPageLoadEvent('html5Widgets.init');

0 comments on commit 5d95a9f

Please sign in to comment.