client/js/renderer/nodelinkbutton.js
author ymh <ymh.work@gmail.com>
Thu, 05 Jan 2017 19:34:53 +0100
changeset 648 e388117572d8
parent 622 02e3c464223f
permissions -rw-r--r--
Improve display of editor tooltip. Add a vertical scroll if they too tall.


define(['jquery', 'underscore', 'requtils', 'renderer/nodebutton'], function ($, _, requtils, NodeButton) {
    'use strict';

    var Utils = requtils.getUtils();

    /* NodeLinkButton Begin */

    //var NodeLinkButton = Renderer.NodeLinkButton = Utils.inherit(Renderer._NodeButton);
    var NodeLinkButton = Utils.inherit(NodeButton);

    _(NodeLinkButton.prototype).extend({
        _init: function() {
            this.type = "Node-link-button";
            this.lastSectorInner = 0;
            this.startAngle = this.options.hide_nodes ? 135 : 90;
            this.endAngle = this.options.hide_nodes ? 190 : 180;
            this.imageName = "link";
            this.text = "Link to another node";
        },
        mousedown: function(_event, _isTouch) {
            if (this.renderer.isEditable()) {
                var _off = this.renderer.canvas_$.offset(),
                _point = new paper.Point([
                    _event.pageX - _off.left,
                    _event.pageY - _off.top
                ]);
                this.renderer.click_target = null;
                this.renderer.removeRepresentationsOfType("editor");
                this.renderer.addTempEdge(this.source_representation, _point, Utils.OriginEnum.EDGE_BUTTON_CIRCLE);
            }
        }
    }).value();

    /* NodeLinkButton End */

    return NodeLinkButton;

});