client/js/renderer/basebutton.js
author cavaliet
Mon, 05 May 2014 17:43:37 +0200
changeset 284 fa8035885814
child 293 fba23fde14ba
permissions -rw-r--r--
build renderer with require js

"use strict";

define(['jquery', 'underscore', 'requtils', 'renderer/baserepresentation'], function ($, _, requtils, BaseRepresentation) {
    
    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;

});