Skip to content

Commit

Permalink
Merge pull request #272 from kserin/master
Browse files Browse the repository at this point in the history
Fix #271 : add update method to 'phononized' dynamically created inputs
  • Loading branch information
qathom authored Nov 29, 2017
2 parents e37d303 + 75942c3 commit 71c3491
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 29 deletions.
34 changes: 25 additions & 9 deletions dist/js/components/forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* ========================================================================
* Licensed under MIT (http://phonon.quarkdev.com)
* ======================================================================== */
;(function (window) {
;(function (window, phonon) {

'use strict';

Expand All @@ -29,20 +29,24 @@
}
}

function update(input) {
addListener(input);

/*
* Do this once at start also, otherwise pre-populated inputs
* will have labels directly overlapping on top of the input value on page load.
*/
isInputFilled(input);
}

/*
* Attachs events once
*/
document.on('pagecreated', function(evt) {
var page = document.querySelector(evt.detail.page);
var inputs = page.querySelectorAll('input.with-label'), i = inputs.length - 1;
for (; i >= 0; i--) {
addListener(inputs[i]);

/*
* Do this once at start also, otherwise pre-populated inputs
* will have labels directly overlapping on top of the input value on page load.
*/
isInputFilled(inputs[i]);
update(inputs[i]);
}
});

Expand All @@ -57,4 +61,16 @@
}
});

}(typeof window !== 'undefined' ? window : this));
phonon.forms = {
update: update
};

window.phonon = phonon;

if(typeof exports === 'object') {
module.exports = phonon.popover;
} else if(typeof define === 'function' && define.amd) {
define(function() { return phonon.popover });
}

}(typeof window !== 'undefined' ? window : this, window.phonon || {}));
2 changes: 1 addition & 1 deletion dist/js/components/forms.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 25 additions & 9 deletions dist/js/phonon.js
Original file line number Diff line number Diff line change
Expand Up @@ -4084,7 +4084,7 @@ phonon.autocomplete = (function (Awesomplete) {
* ========================================================================
* Licensed under MIT (http://phonon.quarkdev.com)
* ======================================================================== */
;(function (window) {
;(function (window, phonon) {

'use strict';

Expand All @@ -4109,20 +4109,24 @@ phonon.autocomplete = (function (Awesomplete) {
}
}

function update(input) {
addListener(input);

/*
* Do this once at start also, otherwise pre-populated inputs
* will have labels directly overlapping on top of the input value on page load.
*/
isInputFilled(input);
}

/*
* Attachs events once
*/
document.on('pagecreated', function(evt) {
var page = document.querySelector(evt.detail.page);
var inputs = page.querySelectorAll('input.with-label'), i = inputs.length - 1;
for (; i >= 0; i--) {
addListener(inputs[i]);

/*
* Do this once at start also, otherwise pre-populated inputs
* will have labels directly overlapping on top of the input value on page load.
*/
isInputFilled(inputs[i]);
update(inputs[i]);
}
});

Expand All @@ -4137,7 +4141,19 @@ phonon.autocomplete = (function (Awesomplete) {
}
});

}(typeof window !== 'undefined' ? window : this));
phonon.forms = {
update: update
};

window.phonon = phonon;

if(typeof exports === 'object') {
module.exports = phonon.popover;
} else if(typeof define === 'function' && define.amd) {
define(function() { return phonon.popover });
}

}(typeof window !== 'undefined' ? window : this, window.phonon || {}));

/* ========================================================================
* Phonon: notifications.js v0.0.2
Expand Down
4 changes: 3 additions & 1 deletion dist/js/phonon.min.js

Large diffs are not rendered by default.

34 changes: 25 additions & 9 deletions src/js/ui/forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* ========================================================================
* Licensed under MIT (http://phonon.quarkdev.com)
* ======================================================================== */
;(function (window) {
;(function (window, phonon) {

'use strict';

Expand All @@ -29,20 +29,24 @@
}
}

function update(input) {
addListener(input);

/*
* Do this once at start also, otherwise pre-populated inputs
* will have labels directly overlapping on top of the input value on page load.
*/
isInputFilled(input);
}

/*
* Attachs events once
*/
document.on('pagecreated', function(evt) {
var page = document.querySelector(evt.detail.page);
var inputs = page.querySelectorAll('input.with-label'), i = inputs.length - 1;
for (; i >= 0; i--) {
addListener(inputs[i]);

/*
* Do this once at start also, otherwise pre-populated inputs
* will have labels directly overlapping on top of the input value on page load.
*/
isInputFilled(inputs[i]);
update(inputs[i]);
}
});

Expand All @@ -57,4 +61,16 @@
}
});

}(typeof window !== 'undefined' ? window : this));
phonon.forms = {
update: update
};

window.phonon = phonon;

if(typeof exports === 'object') {
module.exports = phonon.popover;
} else if(typeof define === 'function' && define.amd) {
define(function() { return phonon.popover });
}

}(typeof window !== 'undefined' ? window : this, window.phonon || {}));

0 comments on commit 71c3491

Please sign in to comment.