Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Simplify demo code * Remove unused files
- Loading branch information
1 parent
29ac79a
commit 47614ca
Showing
7 changed files
with
19 additions
and
247 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,13 @@ | ||
function Demo(config){ | ||
this.config = config; | ||
this.config.development = config.development || false; | ||
|
||
this.paymentForm = $('#' + config.formID); | ||
this.inputs = $('input[type=text], input[type=email], input[type=tel]'); | ||
this.button = this.paymentForm.find('.button'); | ||
|
||
this.states = { | ||
'show' : 'active', | ||
'wait' : 'loading' | ||
}; | ||
this.focusClass = "has-focus"; | ||
this.valueClass = "has-value"; | ||
|
||
this.initialize(); | ||
} | ||
|
||
|
||
Demo.prototype.initialize = function(){ | ||
var self = this; | ||
|
||
this.events(); | ||
this.inputs.each(function(index, element){ | ||
self.labelHander($(element)); | ||
}); | ||
this.notify('error'); | ||
}; | ||
|
||
|
||
Demo.prototype.events = function(){ | ||
var self = this; | ||
|
||
this.inputs.on('focus', function(){ | ||
$(this).closest('label').addClass(self.focusClass); | ||
self.labelHander($(this)); | ||
}).on('keydown', function(){ | ||
self.labelHander($(this)); | ||
}).on('blur', function(){ | ||
$(this).closest('label').removeClass(self.focusClass); | ||
self.labelHander($(this)); | ||
}); | ||
}; | ||
|
||
|
||
Demo.prototype.labelHander = function(element){ | ||
var self = this; | ||
var input = element; | ||
var label = input.closest('label'); | ||
|
||
window.setTimeout(function(){ | ||
var hasValue = (input.val().length > 0) ? true : false ; | ||
|
||
if (hasValue) { | ||
label.addClass(self.valueClass); | ||
} else { | ||
label.removeClass(self.valueClass); | ||
} | ||
}, 10); | ||
}; | ||
|
||
|
||
Demo.prototype.notify = function(status){ | ||
var self = this; | ||
var notice = $('.notice-' + status ); | ||
var delay = (this.config.development === true) ? 4000 : 2000; | ||
|
||
notice.show() | ||
|
||
window.setTimeout(function(){ | ||
notice.addClass('show'); | ||
self.button.removeClass(self.states.wait); | ||
|
||
window.setTimeout(function(){ | ||
notice.removeClass('show'); | ||
window.setTimeout(function(){ | ||
notice.hide(); | ||
}, 310); | ||
}, delay); | ||
}, 10); | ||
}; | ||
'use strict'; | ||
|
||
(function () { | ||
var amount = document.querySelector('#amount'); | ||
var amountLabel = document.querySelector('label[for="amount"]'); | ||
|
||
amount.addEventListener('focus', function () { | ||
amountLabel.className = 'has-focus'; | ||
}, false); | ||
amount.addEventListener('blur', function () { | ||
amountLabel.className = ''; | ||
}, false); | ||
})(); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters