init
This commit is contained in:
parent
06f61d8ce8
commit
f301cb744d
2271 changed files with 103162 additions and 0 deletions
22
02-ui/05-widgets/02-widgets-structure/05-voter-proto/solution/voter.js
Executable file
22
02-ui/05-widgets/02-widgets-structure/05-voter-proto/solution/voter.js
Executable file
|
@ -0,0 +1,22 @@
|
|||
|
||||
function Voter(options) {
|
||||
var elem = this._elem = options.elem;
|
||||
this._voteElem = elem.find('.vote');
|
||||
|
||||
elem.on('mousedown selectstart', false);
|
||||
|
||||
elem.on('click', '.down', this._onDownClick.bind(this));
|
||||
elem.on('click', '.up', this._onUpClick.bind(this));
|
||||
}
|
||||
|
||||
Voter.prototype._onDownClick = function() {
|
||||
this._voteElem.html( +this._voteElem.html() - 1 );
|
||||
};
|
||||
|
||||
Voter.prototype._onUpClick = function() {
|
||||
this._voteElem.html( +this._voteElem.html() + 1 );
|
||||
};
|
||||
|
||||
Voter.prototype.setVote = function(vote) {
|
||||
this._voteElem.html(vote);
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue