client/js/renderer/basebutton.js
author ymh <ymh.work@gmail.com>
Fri, 13 Mar 2015 16:33:49 +0100
changeset 398 57f8d344fde9
parent 293 fba23fde14ba
child 433 e457ec945e50
permissions -rw-r--r--
Correct button shift on hover that appeared after paperjs v 0.9.15


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

    var Utils = requtils.getUtils();

    /* Rkns.Renderer._BaseButton Class */

    /* BaseButton is extended by contextual buttons that appear when hovering on nodes and edges */

    var _BaseButton = Utils.inherit(BaseRepresentation);

    _(_BaseButton.prototype).extend({
        moveTo: function(_pos) {
            this.sector.moveTo(_pos);
        },
        show: function() {
            this.sector.show();
        },
        hide: function() {
            this.sector.hide();
        },
        select: function() {
            this.sector.select();
        },
        unselect: function(_newTarget) {
            this.sector.unselect();
            if (!_newTarget || (_newTarget !== this.source_representation && _newTarget.source_representation !== this.source_representation)) {
                this.source_representation.unselect();
            }
        },
        destroy: function() {
            this.sector.destroy();
        }
    });

    return _BaseButton;

});