Daniel@0: /* global ChordVis */ Daniel@0: 'use strict'; Daniel@0: Daniel@0: App.module('TooltipModule', function (TooltipModule, App, Backbone, Marionette, $, _) { Daniel@0: var renderFunctions = {}; Daniel@0: Daniel@0: var OBJECT_TYPE_CHORD_SEQUENCE = 1; Daniel@0: Daniel@0: TooltipModule.addInitializer(function() { Daniel@0: Daniel@0: Daniel@0: TooltipModule.TooltipView = Backbone.View.extend({ Daniel@0: Daniel@0: initialize: function(options) { Daniel@0: var _this = this; Daniel@0: Daniel@0: _this.$tooltip = $("
").addClass("tooltip").appendTo("body"); Daniel@0: }, Daniel@0: Daniel@0: update: function(mouseEvent, title, target) { Daniel@0: var _this = this; Daniel@0: // removing the tooltip Daniel@0: if (!mouseEvent || mouseEvent.type == "mouseout" || mouseEvent.type == "mouseup" || !title) { Daniel@0: _this.previousTarget = null; Daniel@0: _this.$tooltip.addClass("tooltip_animation_slow-opacity"); Daniel@0: _this.$tooltip.removeClass("tooltip_state_visible"); Daniel@0: } else { Daniel@0: if (target != _this.previousTarget) { Daniel@0: _this.$tooltip.removeClass("tooltip_animation_slow-opacity"); Daniel@0: _this.$tooltip.addClass("tooltip_state_visible"); Daniel@0: Daniel@0: _this.$tooltip.html(title); Daniel@0: } Daniel@0: Daniel@0: _this.$tooltip.position({ Daniel@0: of: mouseEvent, Daniel@0: my: "left+20 topt+20", Daniel@0: collision: "flip flip" Daniel@0: }); Daniel@0: }; Daniel@0: } Daniel@0: // update: function(mouseEvent, object) { Daniel@0: // var _this = this; Daniel@0: // var objectType = null; Daniel@0: // if (object && object.sequenceAsObject && object.sequenceAsObject && object.sequenceAsObject.frequency && object.sequenceAsObject.chordsInOrder) { Daniel@0: // objectType = OBJECT_TYPE_CHORD_SEQUENCE; Daniel@0: // } Daniel@0: // if (!mouseEvent || mouseEvent.type == "mouseout" || !objectType) { Daniel@0: // _this.previousObject = null; Daniel@0: // _this.$tooltip.addClass("tooltip_animation_slow-opacity"); Daniel@0: // _this.$tooltip.removeClass("tooltip_state_visible"); Daniel@0: // } else { Daniel@0: // if (object != _this.previousObject) { Daniel@0: // _this.$tooltip.removeClass("tooltip_animation_slow-opacity"); Daniel@0: // _this.$tooltip.addClass("tooltip_state_visible"); Daniel@0: // // Chord sequence Daniel@0: // if (objectType == OBJECT_TYPE_CHORD_SEQUENCE) { Daniel@0: // _this.previousObject = object; Daniel@0: // Daniel@0: // var chordIds = _.pluck(object.sequenceAsObject.chordsInOrder, "id"); Daniel@0: // var chordTitles = []; Daniel@0: // for (var i = 0; i < chordIds.length; i++) { Daniel@0: // chordTitles.push(_this.bankOfChords.get(chordIds[i]).getNormalisedId()); Daniel@0: // } Daniel@0: // var frequency = object.sequenceAsObject.frequency; Daniel@0: // _this.$tooltip.html(_.str.sprintf("%s