Last active
August 29, 2015 14:15
-
-
Save rarous/27005ace67d9e0b745f0 to your computer and use it in GitHub Desktop.
Fix for IE10- when working with HTML in JointJS elements http://jointjs.com/tutorial/html-elements
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
initialize: function() { | |
_.bindAll(this, 'updateBox'); | |
joint.dia.ElementView.prototype.initialize.apply(this, arguments); | |
this.$box = $(_.template(this.template)()); | |
// FIX: `pointer-events: none` like behavior for IE 10 and older | |
// Prevent "blank:pointerclick" event | |
this.$box.data('view', this); | |
// Propagate events on HTML element to SVG | |
this.$box.on('dblclick', _.bind(function() { this.$el.dblclick(); }, this)); | |
this.$box.on('click', _.bind(function() { this.$el.click(); }, this)); | |
this.$box.on('mousedown', _.bind(function() { this.$el.mousedown(); }, this)); | |
this.$box.on('mouseup', _.bind(function() { this.$el.mouseup(); }, this)); | |
this.$box.on('mouseover', _.bind(function() { this.$el.mouseover(); }, this)); | |
this.$box.on('mouseout', _.bind(function() { this.$el.mouseout(); }, this)); | |
// Prevent paper from handling pointerdown. | |
this.$box.find('input,select').on('mousedown click', function(evt) { evt.stopPropagation(); }); | |
// This is an example of reacting on the input change and storing the input data in the cell model. | |
this.$box.find('input').on('change', _.bind(function(evt) { | |
this.model.set('input', $(evt.target).val()); | |
}, this)); | |
this.$box.find('select').on('change', _.bind(function(evt) { | |
this.model.set('select', $(evt.target).val()); | |
}, this)); | |
this.$box.find('select').val(this.model.get('select')); | |
this.$box.find('.delete').on('click', _.bind(this.model.remove, this.model)); | |
// Update the box position whenever the underlying model changes. | |
this.model.on('change', this.updateBox, this); | |
// Remove the box when the model gets removed from the graph. | |
this.model.on('remove', this.removeBox, this); | |
this.updateBox(); | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment