Advertisement
Guest User

Untitled

a guest
Feb 5th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. jBlocks.define('counter', {
  2. events: {
  3. 'click .js-inc': 'inc',
  4. 'click .js-dec': 'dec'
  5. },
  6.  
  7. methods: {
  8. oninit: function() {
  9. this._currentValue = Number(this.params.initialValue);
  10. },
  11. ondestroy: function() {
  12. this._currentValue = null;
  13. },
  14. /**
  15. * Increases the counter, emits changed event
  16. */
  17. inc: function() {
  18. this._currentValue++;
  19. this.emit('changed', this._currentValue);
  20. },
  21. /**
  22. * Decreases the counter, emits changed event
  23. */
  24. dec: function() {
  25. this._currentValue--;
  26. this.emit('changed', this._currentValue);
  27. },
  28. /**
  29. * Returns the current value
  30. * @return {Number}
  31. */
  32. getCurrentValue: function() {
  33. return this._currentValue;
  34. }
  35. }
  36. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement