Skip to content

Commit

Permalink
migration on marionette v2
Browse files Browse the repository at this point in the history
  • Loading branch information
Valery Bugakov committed Nov 6, 2015
1 parent bdc493f commit 983e888
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
4 changes: 2 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "marionette-tooltip",
"version": "v0.1.0",
"version": "v0.2.0",
"homepage": "https://github.com/valerymercury/marionette-tooltip",
"authors": [
"Joe Fitter <[email protected]>"
Expand Down Expand Up @@ -28,6 +28,6 @@
"dependencies": {
"backbone": ">=0.9.0",
"jquery": ">=1.9.0",
"marionette": ">=1.8.8"
"marionette": ">=2.0.0"
}
}
24 changes: 10 additions & 14 deletions src/marionette-tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ Backbone.Tooltip = Backbone.Marionette.ItemView.extend({
throw new Error('Tooltip needs a target element');
}

if (this.options.text === undefined || this.options.text === '') {
throw new Error('Sorry, no tooltip text was provided.');
}

// Feedback and Timout are incompatible options
if (this.options.feedback && this.options.timeout) {
throw new Error('Sorry, cannot timeout tooltip while awaiting feedback');
Expand Down Expand Up @@ -87,7 +83,7 @@ Backbone.Tooltip = Backbone.Marionette.ItemView.extend({
if (currentTooltip.options.interrupt) {
return;
}
currentTooltip.destroy();
currentTooltip.destroyTooltip();
}

/*
Expand Down Expand Up @@ -171,7 +167,7 @@ Backbone.Tooltip = Backbone.Marionette.ItemView.extend({
}
} else {
// remove tootlip;
tooltip.destroy();
tooltip.destroyTooltip();
}
}
});
Expand Down Expand Up @@ -332,7 +328,7 @@ Backbone.Tooltip = Backbone.Marionette.ItemView.extend({
}
},
addDefaultExitListeners: function() {
//save references so events can be removed from window on destroy
//save references so events can be removed from window on destroyTooltip
this.clickHandler = _.bind(this.clicked, this);
this.keypressHandler = _.bind(this.keypressed, this);
$(window).on('click', this.clickHandler);
Expand Down Expand Up @@ -457,14 +453,14 @@ Backbone.Tooltip = Backbone.Marionette.ItemView.extend({
exit: function(evt, silent) {
/*
* wait until animation complete before
* calling destroy();
* calling destroyTooltip();
*/

this.silent = silent || false;
this.animate(false, this.destroy);
this.animate(false, this.destroyTooltip);
},

destroy: function() {
destroyTooltip: function() {
// Remove tooltip reference from $el data
this.options.$el.data('activeTooltip', null);
// Unbind window listeners relating to this tooltip
Expand All @@ -480,8 +476,8 @@ Backbone.Tooltip = Backbone.Marionette.ItemView.extend({
if (this.options.exit) {
this.options.$el.off(this.options.exit, this.exitHandler);
}
if (this.options.onClose) {
this.onClose();
if (this.options.onDestroy) {
this.onDestroy();
}

/*
Expand All @@ -491,9 +487,9 @@ Backbone.Tooltip = Backbone.Marionette.ItemView.extend({
this.unbind();
},

onClose: function() {
onDestroy: function() {
if (!this.silent) {
this.options.onClose();
this.options.onDestroy();
}
},

Expand Down

0 comments on commit 983e888

Please sign in to comment.