diff --git a/bower.json b/bower.json index 7b3b0f9..9912d19 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "better-dateinput-polyfill", - "version": "1.5.1", + "version": "1.5.2", "main": [ "dist/better-dateinput-polyfill.js" ], diff --git a/dist/better-dateinput-polyfill.js b/dist/better-dateinput-polyfill.js index 2b78811..1ba8a38 100644 --- a/dist/better-dateinput-polyfill.js +++ b/dist/better-dateinput-polyfill.js @@ -1,11 +1,11 @@ /** * better-dateinput-polyfill: input[type=date] polyfill for better-dom - * @version 1.5.1 Thu, 22 Jan 2015 21:00:52 GMT + * @version 1.5.2 Thu, 26 Feb 2015 14:03:58 GMT * @link https://github.com/chemerisuk/better-dateinput-polyfill * @copyright 2014 Maksim Chemerisuk * @license MIT */ -(function(DOM, BASE_CLASS, VK_SPACE, VK_TAB, VK_ENTER, VK_ESCAPE, VK_BACKSPACE, VK_DELETE, DateUtils) { +(function(DOM, BASE_CLASS, VK_SPACE, VK_TAB, VK_ENTER, VK_ESCAPE, VK_BACKSPACE, VK_DELETE, DateUtils, testDateInput) { "use strict"; var __ = DOM.__, @@ -16,11 +16,8 @@ readDateRange = function(el) {return ["min", "max"].map(function(x) {return new Date(el.get(x) || "")})}, pad = function(num, maxlen) {return ((maxlen === 2 ? "0" : "00") + num).slice(-maxlen)}; - // Feature detect browsers that already support date inputs - var hasNativeSupport = DOM.create("input[type=date]")[0].type === "date"; - // need to skip mobile/tablet browsers - DOM.extend("input[type=date]", !( window.orientation || hasNativeSupport ), { + DOM.extend("input[type=date]", testDateInput, { constructor: function() {var this$0 = this; var calendar = PICKER_TEMPLATE.clone(true), label = LABEL_TEMPLATE.clone(true), @@ -331,6 +328,20 @@ var millisBetween = d.getTime() - beginOfYear; return Math.floor(1 + millisBetween / 86400000); } +}, function(el) { + var nativeValue = el.get("_native"), + deviceType = "orientation" in window ? "mobile" : "desktop"; + + if (!nativeValue || nativeValue === deviceType) { + // by default test if the type property is "date" + // to determine if the device supports native control + return el[0].type !== "date"; + } else { + // remove native control + el.set("type", "text"); + // force applying the polyfill + return true; + } })); DOM.importStyles("@media screen", ".btr-dateinput-value{position:absolute;display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;border-style:none solid;border-color:transparent;pointer-events:none}.btr-dateinput-calendar{position:absolute;visibility:hidden;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;color:#FFF;border-bottom:1px solid #CCC;overflow:hidden;border-radius:3px;-webkit-box-shadow:0 .25em .5em rgba(0,0,0,.2);box-shadow:0 .25em .5em rgba(0,0,0,.2);font-family:Helvetica Neue,Helvetica,Arial,sans-serif;text-align:center;opacity:1;-webkit-transform:scale(1,1) translate3d(0,0,0);transform:scale(1,1) translate3d(0,0,0);-webkit-transform-origin:50% 0;-ms-transform-origin:50% 0;transform-origin:50% 0;-webkit-transition:.1s ease-out;transition:.1s ease-out;width:15em;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.btr-dateinput-calendar[aria-hidden=true]{opacity:0;-webkit-transform:scale(.75,.75) translate3d(0,0,0);transform:scale(.75,.75) translate3d(0,0,0)}.btr-dateinput-calendar-header{position:relative;margin:0;height:2.5em;line-height:2.5em;font-weight:700;white-space:nowrap;background:#2da4d6;text-shadow:0 1px 0 #555;border-bottom:1px solid #207fb1}.btr-dateinput-calendar-header>a{width:2.5em;height:2.5em;position:absolute;left:0;top:0;color:inherit}.btr-dateinput-calendar-header>a:before{content:'\\25C4'}.btr-dateinput-calendar-header>a::before{font-size:.85em}.btr-dateinput-calendar-header>a+a{left:auto;right:0}.btr-dateinput-calendar-header>a+a:before{content:'\\25BA'}.btr-dateinput-calendar-days{width:100%;table-layout:fixed;border-spacing:0;border-collapse:collapse;color:#555;background:#FFF;border-radius:3px;border:1px solid #CCC;border-bottom:0}.btr-dateinput-calendar-days>thead{border-top:1px solid #EEE;border-bottom:1px solid #CCC;font-size:.75em;background:#DDD;font-weight:700;text-shadow:0 1px 0 #f3f3f3}.btr-dateinput-calendar-body{-webkit-transform:translateX(0);-ms-transform:translateX(0);transform:translateX(0);-webkit-transition:-webkit-transform .1s linear;transition:transform .1s linear}.btr-dateinput-calendar-body[aria-hidden=true]{-webkit-transform:translateX(-100%);-ms-transform:translateX(-100%);transform:translateX(-100%)}.btr-dateinput-calendar-body+.btr-dateinput-calendar-body{position:absolute;bottom:0}.btr-dateinput-calendar-body+.btr-dateinput-calendar-body[aria-hidden=true]{-webkit-transform:translateX(100%);-ms-transform:translateX(100%);transform:translateX(100%)}.btr-dateinput-calendar-days td,.btr-dateinput-calendar-days th{width:2em;height:2em;line-height:2;padding:0;text-align:center}.btr-dateinput-calendar-past,.btr-dateinput-calendar-future{color:#DDD}.btr-dateinput-calendar-out{color:#CCC;text-shadow:0 1px 0 #FFF}.btr-dateinput-calendar-today{color:#FFF;background-color:#2da4d6;text-shadow:0 1px 0 #555;font-weight:700}.btr-dateinput-calendar-out,.btr-dateinput-calendar-days td:hover{background-color:#f3f3f3;background-color:rgba(0,0,0,.05)}.btr-dateinput-calendar-header>a:hover,td.btr-dateinput-calendar-today:hover{background-color:#207fb1;text-decoration:none}.btr-dateinput-value+input::-moz-placeholder{color:initial}"); diff --git a/package.json b/package.json index 7ecb583..f348183 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "better-dateinput-polyfill", "description": "input[type=date] polyfill for better-dom", - "version": "1.5.1", + "version": "1.5.2", "author": "Maksim Chemerisuk", "license": "MIT", "homepage": "https://github.com/chemerisuk/better-dateinput-polyfill",