diff --git a/placeholders/Gruntfile.js b/placeholders/Gruntfile.js index cfc4de3..a5fdd67 100644 --- a/placeholders/Gruntfile.js +++ b/placeholders/Gruntfile.js @@ -19,7 +19,7 @@ module.exports = function(grunt) { return code } }, - url: 'https://raw.github.com/jamesallardice/Placeholders.js/v<%= pkg.version %>/lib/main.js', + url: 'https://raw.github.com/jamesallardice/Placeholders.js/<%= pkg.version %>/lib/main.js', name: 'placeholders.js' }, utils: { @@ -30,7 +30,7 @@ module.exports = function(grunt) { return code } }, - url: 'https://raw.github.com/jamesallardice/Placeholders.js/v<%= pkg.version %>/lib/utils.js', + url: 'https://raw.github.com/jamesallardice/Placeholders.js/<%= pkg.version %>/lib/utils.js', name: 'utils.js' } } diff --git a/placeholders/dist/placeholders-debug.js b/placeholders/dist/placeholders-debug.js index f1db812..4e75f78 100644 --- a/placeholders/dist/placeholders-debug.js +++ b/placeholders/dist/placeholders-debug.js @@ -1,4 +1,4 @@ -define("gallery/placeholders/3.0.0/placeholders-debug", [ "./utils-debug" ], function(require, exports, module) { +define("gallery/placeholders/3.0.1/placeholders-debug", [ "./utils-debug" ], function(require, exports, module) { require("./utils-debug"); (function(global) { "use strict"; @@ -23,6 +23,15 @@ define("gallery/placeholders/3.0.0/placeholders-debug", [ "./utils-debug" ], fun test = document.createElement("input"), head = document.getElementsByTagName("head")[0], root = document.documentElement, Placeholders = global.Placeholders, Utils = Placeholders.Utils, hideOnInput, liveUpdates, keydownVal, styleElem, styleRules, placeholder, timer, form, elem, len, i; // No-op (used in place of public methods when native support is detected) function noop() {} + // Avoid IE9 activeElement of death when an iframe is used. + // More info: + // http://bugs.jquery.com/ticket/13393 + // https://github.com/jquery/jquery/commit/85fc5878b3c6af73f42d61eedf73013e7faae408 + function safeActiveElement() { + try { + return document.activeElement; + } catch (err) {} + } // Hide the placeholder value on a single element. Returns true if the placeholder was hidden and false if it was not (because it wasn't visible in the first place) function hidePlaceholder(elem, keydownValue) { var type, maxLength, valueChanged = !!keydownValue && elem.value !== keydownValue, isPlaceholderValue = elem.value === elem.getAttribute(ATTR_CURRENT_VAL); @@ -141,7 +150,7 @@ define("gallery/placeholders/3.0.0/placeholders-debug", [ "./utils-debug" ], fun } function makeClickHandler(elem) { return function() { - if (elem === document.activeElement && elem.value === elem.getAttribute(ATTR_CURRENT_VAL) && elem.getAttribute(ATTR_ACTIVE) === "true") { + if (elem === safeActiveElement() && elem.value === elem.getAttribute(ATTR_CURRENT_VAL) && elem.getAttribute(ATTR_ACTIVE) === "true") { Utils.moveCaret(elem, 0); } }; @@ -177,7 +186,7 @@ define("gallery/placeholders/3.0.0/placeholders-debug", [ "./utils-debug" ], fun elem.setAttribute(ATTR_EVENTS_BOUND, "true"); elem.setAttribute(ATTR_CURRENT_VAL, placeholder); // If the element doesn't have a value and is not focussed, set it to the placeholder string - if (hideOnInput || elem !== document.activeElement) { + if (hideOnInput || elem !== safeActiveElement()) { showPlaceholder(elem); } } @@ -254,6 +263,9 @@ define("gallery/placeholders/3.0.0/placeholders-debug", [ "./utils-debug" ], fun } }, 100); } + Utils.addEventListener(global, "beforeunload", function() { + disablePlaceholders(); + }); // Expose public methods Placeholders.disable = Placeholders.nativeSupport ? noop : disablePlaceholders; Placeholders.enable = Placeholders.nativeSupport ? noop : enablePlaceholders; @@ -266,7 +278,7 @@ define("gallery/placeholders/3.0.0/placeholders-debug", [ "./utils-debug" ], fun } }); -define("gallery/placeholders/3.0.0/utils-debug", [], function(require, exports, module) { +define("gallery/placeholders/3.0.1/utils-debug", [], function(require, exports, module) { /* * The MIT License * diff --git a/placeholders/dist/placeholders.js b/placeholders/dist/placeholders.js index a2f9b92..7df98c9 100644 --- a/placeholders/dist/placeholders.js +++ b/placeholders/dist/placeholders.js @@ -1 +1 @@ -define("gallery/placeholders/3.0.0/placeholders",["./utils"],function(a,b,c){a("./utils"),function(a){"use strict";function b(){}function c(a,b){var c,d,e=!!b&&a.value!==b,f=a.value===a.getAttribute(G);return(e||f)&&"true"===a.getAttribute(H)?(a.removeAttribute(H),a.value=a.value.replace(a.getAttribute(G),""),a.className=a.className.replace(F,""),d=a.getAttribute(N),d&&(a.setAttribute("maxLength",d),a.removeAttribute(N)),c=a.getAttribute(I),c&&(a.type=c),!0):!1}function d(a){var b,c,d=a.getAttribute(G);return""===a.value&&d?(a.setAttribute(H,"true"),a.value=d,a.className+=" "+E,c=a.getAttribute(N),c||(a.setAttribute(N,a.maxLength),a.removeAttribute("maxLength")),b=a.getAttribute(I),b?a.type="text":"password"===a.type&&S.changeType(a,"text")&&a.setAttribute(I,"password"),!0):!1}function e(a,b){var c,d,e,f,g;if(a&&a.getAttribute(G))b(a);else for(c=a?a.getElementsByTagName("input"):o,d=a?a.getElementsByTagName("textarea"):p,g=0,f=c.length+d.length;f>g;g++)e=gA;A++)y=AA;A++)y=Ac;c++)if(a[c]===b)return!0;return!1}function d(a,b){var c;a.createTextRange?(c=a.createTextRange(),c.move("character",b),c.select()):a.selectionStart&&(a.focus(),a.setSelectionRange(b,b))}function e(a,b){try{return a.type=b,!0}catch(c){return!1}}a.Placeholders={Utils:{addEventListener:b,inArray:c,moveCaret:d,changeType:e}}}(this)}); +define("gallery/placeholders/3.0.1/placeholders",["./utils"],function(a,b,c){a("./utils"),function(a){"use strict";function b(){}function c(){try{return document.activeElement}catch(a){}}function d(a,b){var c,d,e=!!b&&a.value!==b,f=a.value===a.getAttribute(H);return(e||f)&&"true"===a.getAttribute(I)?(a.removeAttribute(I),a.value=a.value.replace(a.getAttribute(H),""),a.className=a.className.replace(G,""),d=a.getAttribute(O),d&&(a.setAttribute("maxLength",d),a.removeAttribute(O)),c=a.getAttribute(J),c&&(a.type=c),!0):!1}function e(a){var b,c,d=a.getAttribute(H);return""===a.value&&d?(a.setAttribute(I,"true"),a.value=d,a.className+=" "+F,c=a.getAttribute(O),c||(a.setAttribute(O,a.maxLength),a.removeAttribute("maxLength")),b=a.getAttribute(J),b?a.type="text":"password"===a.type&&T.changeType(a,"text")&&a.setAttribute(J,"password"),!0):!1}function f(a,b){var c,d,e,f,g;if(a&&a.getAttribute(H))b(a);else for(c=a?a.getElementsByTagName("input"):p,d=a?a.getElementsByTagName("textarea"):q,g=0,f=c.length+d.length;f>g;g++)e=gB;B++)z=BB;B++)z=Bc;c++)if(a[c]===b)return!0;return!1}function d(a,b){var c;a.createTextRange?(c=a.createTextRange(),c.move("character",b),c.select()):a.selectionStart&&(a.focus(),a.setSelectionRange(b,b))}function e(a,b){try{return a.type=b,!0}catch(c){return!1}}a.Placeholders={Utils:{addEventListener:b,inArray:c,moveCaret:d,changeType:e}}}(this)}); diff --git a/placeholders/package.json b/placeholders/package.json index b1f01a0..c516cd6 100644 --- a/placeholders/package.json +++ b/placeholders/package.json @@ -1,7 +1,7 @@ { "family": "gallery", "name": "placeholders", - "version": "3.0.0", + "version": "3.0.1", "author": "James Allardice ", "description": "A JavaScript polyfill for the HTML5 placeholder attribute", "homepage": "http://jamesallardice.github.io/Placeholders.js/",