From 94e4cf02133fecc02886989d61af1ceb2291b995 Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Thu, 5 Jan 2012 09:29:06 +0000 Subject: [PATCH] jqueryDayField: do nothing if supported On iOS 5, for example, throws up a native date picker, so there's no reason to show the jquery-ui datepicker. This is not perfect, because the jquery-ui JavaScript and CSS are still loaded, and the JqueryDaySettings are not turned into attributes on the , but it's a start. --- yesod-form/Yesod/Form/Jquery.hs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/yesod-form/Yesod/Form/Jquery.hs b/yesod-form/Yesod/Form/Jquery.hs index fa6f6e5d..14c1f73c 100644 --- a/yesod-form/Yesod/Form/Jquery.hs +++ b/yesod-form/Yesod/Form/Jquery.hs @@ -86,13 +86,18 @@ jqueryDayField jds = Field addScript' urlJqueryUiJs addStylesheet' urlJqueryUiCss addJulius [JULIUS| -$(function(){$("##{theId}").datepicker({ - dateFormat:'yy-mm-dd', - changeMonth:#{jsBool $ jdsChangeMonth jds}, - changeYear:#{jsBool $ jdsChangeYear jds}, - numberOfMonths:#{mos $ jdsNumberOfMonths jds}, - yearRange:"#{jdsYearRange jds}" -})}); +$(function(){ + var i = $("##{theId}"); + if (i.attr("type") != "date") { + i.datepicker({ + dateFormat:'yy-mm-dd', + changeMonth:#{jsBool $ jdsChangeMonth jds}, + changeYear:#{jsBool $ jdsChangeYear jds}, + numberOfMonths:#{mos $ jdsNumberOfMonths jds}, + yearRange:"#{jdsYearRange jds}" + }); + } +}); |] } where