Skip to content

Commit

Permalink
- update grunt to v1
Browse files Browse the repository at this point in the history
- add tast to build
- add code from commit  jamesallardice#99
  • Loading branch information
DragorWW committed Sep 27, 2016
1 parent 144ee9d commit 4647f8a
Show file tree
Hide file tree
Showing 10 changed files with 729 additions and 24 deletions.
8 changes: 5 additions & 3 deletions dist/placeholders.jquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -514,10 +514,12 @@
// If the element is part of a form, make sure the placeholder string is
// not submitted as a value.
var form = elem.form;
if ( form && typeof form === 'string' ) {
if ( form ) {

// Get the real form.
form = document.getElementById(form);
if ( typeof form === 'string' ) {
// Get the real form.
form = document.getElementById(form);
}

// Set a flag on the form so we know it's been handled (forms can contain
// multiple inputs).
Expand Down
175 changes: 174 additions & 1 deletion dist/placeholders.jquery.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,177 @@
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
!function(a){"use strict";function b(){}function c(){try{return document.activeElement}catch(a){}}function d(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return!0;return!1}function e(a,b,c){return a.addEventListener?a.addEventListener(b,c,!1):a.attachEvent?a.attachEvent("on"+b,c):void 0}function f(a,b){var c;a.createTextRange?(c=a.createTextRange(),c.move("character",b),c.select()):a.selectionStart&&(a.focus(),a.setSelectionRange(b,b))}function g(a,b){try{return a.type=b,!0}catch(c){return!1}}function h(a,b){if(a&&a.getAttribute(B))b(a);else for(var c,d=a?a.getElementsByTagName("input"):N,e=a?a.getElementsByTagName("textarea"):O,f=d?d.length:0,g=e?e.length:0,h=f+g,i=0;h>i;i++)c=f>i?d[i]:e[i-f],b(c)}function i(a){h(a,k)}function j(a){h(a,l)}function k(a,b){var c=!!b&&a.value!==b,d=a.value===a.getAttribute(B);if((c||d)&&"true"===a.getAttribute(C)){a.removeAttribute(C),a.value=a.value.replace(a.getAttribute(B),""),a.className=a.className.replace(A,"");var e=a.getAttribute(I);parseInt(e,10)>=0&&(a.setAttribute("maxLength",e),a.removeAttribute(I));var f=a.getAttribute(D);return f&&(a.type=f),!0}return!1}function l(a){var b=a.getAttribute(B);if(""===a.value&&b){a.setAttribute(C,"true"),a.value=b,a.className+=" "+z;var c=a.getAttribute(I);c||(a.setAttribute(I,a.maxLength),a.removeAttribute("maxLength"));var d=a.getAttribute(D);return d?a.type="text":"password"===a.type&&g(a,"text")&&a.setAttribute(D,"password"),!0}return!1}function m(a){return function(){P&&a.value===a.getAttribute(B)&&"true"===a.getAttribute(C)?f(a,0):k(a)}}function n(a){return function(){l(a)}}function o(a){return function(){i(a)}}function p(a){return function(b){return v=a.value,"true"===a.getAttribute(C)&&v===a.getAttribute(B)&&d(x,b.keyCode)?(b.preventDefault&&b.preventDefault(),!1):void 0}}function q(a){return function(){k(a,v),""===a.value&&(a.blur(),f(a,0))}}function r(a){return function(){a===c()&&a.value===a.getAttribute(B)&&"true"===a.getAttribute(C)&&f(a,0)}}function s(a){var b=a.form;b&&"string"==typeof b&&(b=document.getElementById(b),b.getAttribute(E)||(e(b,"submit",o(b)),b.setAttribute(E,"true"))),e(a,"focus",m(a)),e(a,"blur",n(a)),P&&(e(a,"keydown",p(a)),e(a,"keyup",q(a)),e(a,"click",r(a))),a.setAttribute(F,"true"),a.setAttribute(B,T),(P||a!==c())&&l(a)}var t=document.createElement("input"),u=void 0!==t.placeholder;if(a.Placeholders={nativeSupport:u,disable:u?b:i,enable:u?b:j},!u){var v,w=["text","search","url","tel","email","password","number","textarea"],x=[27,33,34,35,36,37,38,39,40,8,46],y="#ccc",z="placeholdersjs",A=new RegExp("(?:^|\\s)"+z+"(?!\\S)"),B="data-placeholder-value",C="data-placeholder-active",D="data-placeholder-type",E="data-placeholder-submit",F="data-placeholder-bound",G="data-placeholder-focus",H="data-placeholder-live",I="data-placeholder-maxlength",J=100,K=document.getElementsByTagName("head")[0],L=document.documentElement,M=a.Placeholders,N=document.getElementsByTagName("input"),O=document.getElementsByTagName("textarea"),P="false"===L.getAttribute(G),Q="false"!==L.getAttribute(H),R=document.createElement("style");R.type="text/css";var S=document.createTextNode("."+z+" {color:"+y+";}");R.styleSheet?R.styleSheet.cssText=S.nodeValue:R.appendChild(S),K.insertBefore(R,K.firstChild);for(var T,U,V=0,W=N.length+O.length;W>V;V++)U=V<N.length?N[V]:O[V-N.length],T=U.attributes.placeholder,T&&(T=T.nodeValue,T&&d(w,U.type)&&s(U));var X=setInterval(function(){for(var a=0,b=N.length+O.length;b>a;a++)U=a<N.length?N[a]:O[a-N.length],T=U.attributes.placeholder,T?(T=T.nodeValue,T&&d(w,U.type)&&(U.getAttribute(F)||s(U),(T!==U.getAttribute(B)||"password"===U.type&&!U.getAttribute(D))&&("password"===U.type&&!U.getAttribute(D)&&g(U,"text")&&U.setAttribute(D,"password"),U.value===U.getAttribute(B)&&(U.value=T),U.setAttribute(B,T)))):U.getAttribute(C)&&(k(U),U.removeAttribute(B));Q||clearInterval(X)},J);e(a,"beforeunload",function(){M.disable()})}}(this),function(a,b){"use strict";var c=a.fn.val,d=a.fn.prop;b.Placeholders.nativeSupport||(a.fn.val=function(a){var b=c.apply(this,arguments),d=this.eq(0).data("placeholder-value");return void 0===a&&this.eq(0).data("placeholder-active")&&b===d?"":b},a.fn.prop=function(a,b){return void 0===b&&this.eq(0).data("placeholder-active")&&"value"===a?"":d.apply(this,arguments)})}(jQuery,this);
!function(a){"use strict";
//
// Utility functions
//
// No-op (used in place of public methods when native support is detected).
function b(){}
// 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 c(){try{return document.activeElement}catch(a){}}
// Check whether an item is in an array. We don't use Array.prototype.indexOf
// so we don't clobber any existing polyfills. This is a really simple
// alternative.
function d(a,b){for(var c=0,d=a.length;c<d;c++)if(a[c]===b)return!0;return!1}
// Cross-browser DOM event binding
function e(a,b,c){return a.addEventListener?a.addEventListener(b,c,!1):a.attachEvent?a.attachEvent("on"+b,c):void 0}
// Move the caret to the index position specified. Assumes that the element
// has focus.
function f(a,b){var c;a.createTextRange?(c=a.createTextRange(),c.move("character",b),c.select()):a.selectionStart&&(a.focus(),a.setSelectionRange(b,b))}
// Attempt to change the type property of an input element.
function g(a,b){try{return a.type=b,!0}catch(a){
// You can't change input type in IE8 and below.
return!1}}function h(a,b){
// Check if the passed in node is an input/textarea (in which case it can't
// have any affected descendants).
if(a&&a.getAttribute(B))b(a);else for(var c,d=a?a.getElementsByTagName("input"):N,e=a?a.getElementsByTagName("textarea"):O,f=d?d.length:0,g=e?e.length:0,h=f+g,i=0;i<h;i++)c=i<f?d[i]:e[i-f],b(c)}
// Return all affected elements to their normal state (remove placeholder
// value if present).
function i(a){h(a,k)}
// Show the placeholder value on all appropriate elements.
function j(a){h(a,l)}
// 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 k(a,b){var c=!!b&&a.value!==b,d=a.value===a.getAttribute(B);if((c||d)&&"true"===a.getAttribute(C)){a.removeAttribute(C),a.value=a.value.replace(a.getAttribute(B),""),a.className=a.className.replace(A,"");
// Restore the maxlength value. Old FF returns -1 if attribute not set.
// See GH-56.
var e=a.getAttribute(I);parseInt(e,10)>=0&&(a.setAttribute("maxLength",e),a.removeAttribute(I));
// If the polyfill has changed the type of the element we need to change
// it back.
var f=a.getAttribute(D);return f&&(a.type=f),!0}return!1}
// Show the placeholder value on a single element. Returns true if the
// placeholder was shown and false if it was not (because it was already
// visible).
function l(a){var b=a.getAttribute(B);if(""===a.value&&b){a.setAttribute(C,"true"),a.value=b,a.className+=" "+z;
// Store and remove the maxlength value.
var c=a.getAttribute(I);c||(a.setAttribute(I,a.maxLength),a.removeAttribute("maxLength"));
// If the type of element needs to change, change it (e.g. password
// inputs).
var d=a.getAttribute(D);return d?a.type="text":"password"===a.type&&g(a,"text")&&a.setAttribute(D,"password"),!0}return!1}
// Returns a function that is used as a focus event handler.
function m(a){return function(){
// Only hide the placeholder value if the (default) hide-on-focus
// behaviour is enabled.
P&&a.value===a.getAttribute(B)&&"true"===a.getAttribute(C)?
// Move the caret to the start of the input (this mimics the behaviour
// of all browsers that do not hide the placeholder on focus).
f(a,0):
// Remove the placeholder.
k(a)}}
// Returns a function that is used as a blur event handler.
function n(a){return function(){l(a)}}
// Returns a function that is used as a submit event handler on form elements
// that have children affected by this polyfill.
function o(a){return function(){
// Turn off placeholders on all appropriate descendant elements.
i(a)}}
// Functions that are used as a event handlers when the hide-on-input
// behaviour has been activated - very basic implementation of the 'input'
// event.
function p(a){return function(b){
// Prevent the use of the arrow keys (try to keep the cursor before the
// placeholder).
if(v=a.value,"true"===a.getAttribute(C)&&v===a.getAttribute(B)&&d(x,b.keyCode))return b.preventDefault&&b.preventDefault(),!1}}function q(a){return function(){k(a,v),
// If the element is now empty we need to show the placeholder
""===a.value&&(a.blur(),f(a,0))}}function r(a){return function(){a===c()&&a.value===a.getAttribute(B)&&"true"===a.getAttribute(C)&&f(a,0)}}
// Bind event handlers to an element that we need to affect with the
// polyfill.
function s(a){
// If the element is part of a form, make sure the placeholder string is
// not submitted as a value.
var b=a.form;b&&("string"==typeof b&&(
// Get the real form.
b=document.getElementById(b)),
// Set a flag on the form so we know it's been handled (forms can contain
// multiple inputs).
b.getAttribute(E)||(e(b,"submit",o(b)),b.setAttribute(E,"true"))),
// Bind event handlers to the element so we can hide/show the placeholder
// as appropriate.
e(a,"focus",m(a)),e(a,"blur",n(a)),
// If the placeholder should hide on input rather than on focus we need
// additional event handlers
P&&(e(a,"keydown",p(a)),e(a,"keyup",q(a)),e(a,"click",r(a))),
// Remember that we've bound event handlers to this element.
a.setAttribute(F,"true"),a.setAttribute(B,T),
// If the element doesn't have a value and is not focussed, set it to the
// placeholder string.
(P||a!==c())&&l(a)}
//
// Test for support. We do this as early as possible to optimise for browsers
// that have native support for the attribute.
//
var t=document.createElement("input"),u=void 0!==t.placeholder;if(a.Placeholders={nativeSupport:u,disable:u?b:i,enable:u?b:j},!u){
//
// If we reach this point then the browser does not have native support for
// the attribute.
//
// The list of input element types that support the placeholder attribute.
var v,w=["text","search","url","tel","email","password","number","textarea"],x=[
// The following keys all cause the caret to jump to the end of the input
// value.
27,// Escape
33,// Page up
34,// Page down
35,// End
36,// Home
// Arrow keys allow you to move the caret manually, which should be
// prevented when the placeholder is visible.
37,// Left
38,// Up
39,// Right
40,// Down
// The following keys allow you to modify the placeholder text by removing
// characters, which should be prevented when the placeholder is visible.
8,// Backspace
46],y="#ccc",z="placeholdersjs",A=new RegExp("(?:^|\\s)"+z+"(?!\\S)"),B="data-placeholder-value",C="data-placeholder-active",D="data-placeholder-type",E="data-placeholder-submit",F="data-placeholder-bound",G="data-placeholder-focus",H="data-placeholder-live",I="data-placeholder-maxlength",J=100,K=document.getElementsByTagName("head")[0],L=document.documentElement,M=a.Placeholders,N=document.getElementsByTagName("input"),O=document.getElementsByTagName("textarea"),P="false"===L.getAttribute(G),Q="false"!==L.getAttribute(H),R=document.createElement("style");R.type="text/css";
// Create style rules as text node.
var S=document.createTextNode("."+z+" {color:"+y+";}");
// Append style rules to newly created stylesheet.
R.styleSheet?R.styleSheet.cssText=S.nodeValue:R.appendChild(S),
// Prepend new style element to the head (before any existing stylesheets,
// so user-defined rules take precedence).
K.insertBefore(R,K.firstChild);for(var T,U,V=0,W=N.length+O.length;V<W;V++)
// Find the next element. If we've already done all the inputs we move on
// to the textareas.
U=V<N.length?N[V]:O[V-N.length],
// Get the value of the placeholder attribute, if any. IE10 emulating IE7
// fails with getAttribute, hence the use of the attributes node.
T=U.attributes.placeholder,
// If the element has a placeholder attribute we need to modify it.
T&&(
// IE returns an empty object instead of undefined if the attribute is
// not present.
T=T.nodeValue,
// Only apply the polyfill if this element is of a type that supports
// placeholders and has a placeholder attribute with a non-empty value.
T&&d(w,U.type)&&s(U));
// If enabled, the polyfill will repeatedly check for changed/added elements
// and apply to those as well.
var X=setInterval(function(){for(var a=0,b=N.length+O.length;a<b;a++)U=a<N.length?N[a]:O[a-N.length],
// Only apply the polyfill if this element is of a type that supports
// placeholders, and has a placeholder attribute with a non-empty value.
T=U.attributes.placeholder,T?(T=T.nodeValue,T&&d(w,U.type)&&(
// If the element hasn't had event handlers bound to it then add
// them.
U.getAttribute(F)||s(U),
// If the placeholder value has changed or not been initialised yet
// we need to update the display.
(T!==U.getAttribute(B)||"password"===U.type&&!U.getAttribute(D))&&(
// Attempt to change the type of password inputs (fails in IE < 9).
"password"===U.type&&!U.getAttribute(D)&&g(U,"text")&&U.setAttribute(D,"password"),
// If the placeholder value has changed and the placeholder is
// currently on display we need to change it.
U.value===U.getAttribute(B)&&(U.value=T),
// Keep a reference to the current placeholder value in case it
// changes via another script.
U.setAttribute(B,T)))):U.getAttribute(C)&&(k(U),U.removeAttribute(B));
// If live updates are not enabled cancel the timer.
Q||clearInterval(X)},J);
// Disabling placeholders before unloading the page prevents flash of
// unstyled placeholders on load if the page was refreshed.
e(a,"beforeunload",function(){M.disable()})}}(this),function(a,b){"use strict";var c=a.fn.val,d=a.fn.prop;b.Placeholders.nativeSupport||(a.fn.val=function(a){var b=c.apply(this,arguments),d=this.eq(0).data("placeholder-value");return void 0===a&&this.eq(0).data("placeholder-active")&&b===d?"":b},a.fn.prop=function(a,b){return void 0===b&&this.eq(0).data("placeholder-active")&&"value"===a?"":d.apply(this,arguments)})}(jQuery,this);
8 changes: 5 additions & 3 deletions dist/placeholders.js
Original file line number Diff line number Diff line change
Expand Up @@ -514,10 +514,12 @@
// If the element is part of a form, make sure the placeholder string is
// not submitted as a value.
var form = elem.form;
if ( form && typeof form === 'string' ) {
if ( form ) {

// Get the real form.
form = document.getElementById(form);
if ( typeof form === 'string' ) {
// Get the real form.
form = document.getElementById(form);
}

// Set a flag on the form so we know it's been handled (forms can contain
// multiple inputs).
Expand Down
Loading

0 comments on commit 4647f8a

Please sign in to comment.