joint.all.js
function() {

	this._magnets = [];

	var $link = this.$('.link');
	var magnetElements = this.options.cellView.$('[magnet="true"]');

	if (this.options.magnetFilter) {

	    if (_.isFunction(this.options.magnetFilter)) {

		// We want function to be called with a magnet element as the first parameter. Not an index
		// as jQuery.filter would do it.
		magnetElements = _.filter(magnetElements, this.options.magnetFilter);

	    } else {

		// Every other case runs jQuery.filter method
		magnetElements = magnetElements.filter(this.options.magnetFilter);
	    }
	}

	if ($link.length && magnetElements.length) {

	    var linkWidth = $link.width();
	    var linkHeight = $link.height();

	    _.each(magnetElements, function(magnetElement) {

		var magnetClientRect = magnetElement.getBoundingClientRect();

		var $haloElement = $link.clone()
		    .addClass('halo-magnet')
		    .css({
			width: Math.min(magnetClientRect.width, linkWidth),
			height: Math.min(magnetClientRect.height, linkHeight),
			'background-size': 'contain'
		    })
		    .data('selector', this.options.cellView.getSelector(magnetElement))
		    .appendTo(this.$el);

		this._magnets.push({ $halo: $haloElement, el: magnetElement });

	    }, this);
	}

	// disable linking & forking from the element itself if is it not a magnet
	if (this.options.cellView.$el.attr('magnet') == 'false') {
	    $link.hide();
	    this.$('.fork').hide();
	}
    }
function() {

	this._magnets = [];

	var $link = this.$('.link');
	var magnetElements = this.options.cellView.$('[magnet="true"]');

	if (this.options.magnetFilter) {

	    if (_.isFunction(this.options.magnetFilter)) {

		// We want function to be called with a magnet element as the first parameter. Not an index
		// as jQuery.filter would do it.
		magnetElements = _.filter(magnetElements, this.options.magnetFilter);

	    } else {

		// Every other case runs jQuery.filter method
		magnetElements = magnetElements.filter(this.options.magnetFilter);
	    }
	}

	if ($link.length && magnetElements.length) {

	    var linkWidth = $link.width();
	    var linkHeight = $link.height();

	    _.each(magnetElements, function(magnetElement) {

		var magnetClientRect = magnetElement.getBoundingClientRect();

		var $haloElement = $link.clone()
		    .addClass('halo-magnet')
		    .css({
			width: Math.min(magnetClientRect.width, linkWidth),
			height: Math.min(magnetClientRect.height, linkHeight),
			'background-size': 'contain'
		    })
		    .data('selector', this.options.cellView.getSelector(magnetElement))
		    .appendTo(this.$el);

		this._magnets.push({ $halo: $haloElement, el: magnetElement });

	    }, this);
	}

	// disable linking & forking from the element itself if is it not a magnet
	if (this.options.cellView.$el.attr('magnet') == 'false') {
	    $link.hide();
	    this.$('.fork').hide();
	}
    }
Magnet functions