Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- jBlocks.define('counter', {
- events: {
- 'click .js-inc': 'inc',
- 'click .js-dec': 'dec'
- },
- methods: {
- oninit: function() {
- this._currentValue = Number(this.params.initialValue);
- },
- ondestroy: function() {
- this._currentValue = null;
- },
- /**
- * Increases the counter, emits changed event
- */
- inc: function() {
- this._currentValue++;
- this.emit('changed', this._currentValue);
- },
- /**
- * Decreases the counter, emits changed event
- */
- dec: function() {
- this._currentValue--;
- this.emit('changed', this._currentValue);
- },
- /**
- * Returns the current value
- * @return {Number}
- */
- getCurrentValue: function() {
- return this._currentValue;
- }
- }
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement