client/js/renderer/nodebutton.js
author ymh <ymh.work@gmail.com>
Fri, 13 Mar 2015 10:56:19 +0100
changeset 396 b51c25ef4292
parent 293 fba23fde14ba
child 433 e457ec945e50
permissions -rw-r--r--
add timeout to buttons


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

    var Utils = requtils.getUtils();

    /* _NodeButton Begin */

    //var _NodeButton = Renderer._NodeButton = Utils.inherit(Renderer._BaseButton);
    var _NodeButton = Utils.inherit(BaseButton);

    _(_NodeButton.prototype).extend({
        setSectorSize: function() {
            var sectorInner = this.source_representation.circle_radius;
            if (sectorInner !== this.lastSectorInner) {
                if (this.sector) {
                    this.sector.destroy();
                }
                this.sector = this.renderer.drawSector(
                        this, 1 + sectorInner,
                        Utils._NODE_BUTTON_WIDTH + sectorInner,
                        this.startAngle,
                        this.endAngle,
                        1,
                        this.imageName,
                        this.renkan.translate(this.text)
                );
                this.lastSectorInner = sectorInner;
            }
        },
        unselect: function() {
            BaseButton.prototype.unselect.apply(this, Array.prototype.slice.call(arguments, 1));
            if(this.source_representation && this.source_representation.buttons_timeout) {
                clearTimeout(this.source_representation.buttons_timeout);
                this.source_representation.hideButtons();
            }
        },
        select: function() {
            if(this.source_representation && this.source_representation.buttons_timeout) {
                clearTimeout(this.source_representation.buttons_timeout);
            }
            this.sector.select();
        },
    });

    /* _NodeButton End */

    return _NodeButton;

});