/**
 * Created with JetBrains WebStorm.
 * User: dfwang
 * Date: 14-6-16
 * Time: 下午5:25
 * To change this template use File | Settings | File Templates.
 */
define(function (require, exports) {
    var _a_$talign = function() {
        this.__property = null;
        this.__that =null;
    }
    _a_$talign.left = function(_this){
        _this.dom.textAlign = 'left';
        _this.canvas.renderAll();
    }
    _a_$talign.center=function(_this){
        _this.dom.textAlign = 'center';
        _this.canvas.renderAll();
    }
    _a_$talign.right=function(_this){
        _this.dom.textAlign = 'right';
        _this.canvas.renderAll();
    }
//文字大小
    _a_$talign.size=function(_this){
        _this.dom.fontSize= 12;
        _this.canvas.renderAll();
    }
//字体
    _a_$talign.family=function(_this){
        _this.dom.fontFamily= '黑体';
        _this.canvas.renderAll();
    }
//字体着色
    _a_$talign.color=function(_this){
        _this.dom.textBackgroundColor = '#ff0000';
        _this.canvas.renderAll();
    }
    /**
     * 创建属性列表
     */
    _a_$talign.prototype.showProperty=function(){
        this.hideProperty();
        var _that = this;
        this.__property ='<div id="text_style_font" class="text-style-align"><ul>' +
            '<li><a href="javascript:void(0)"></a></li>' +
            '<li><a href="javascript:void(0)"></a></li>' +
            '<li><a href="javascript:void(0)"></a></li>' +
            '<li><a href="javascript:void(0)"></a></li>' +
            '<li><a href="javascript:void(0)"></a></li>' +
            '</ul></div>';
        $('#propertyArea').html(this.__property);
        _a_$talign.setActive(_that.dom);
        //添加事件
        $('#text_style_font li:nth-of-type(1)>a').on('click',function(e){
            _a_$talign.size(_that);
            _a_$talign.active(e.target);
        });
        $('#text_style_font li:nth-of-type(2)>a').on('click',function(e){
            _a_$talign.color(_that);
            _a_$talign.active(e.target);
        })
        $('#text_style_font li:nth-of-type(3)>a').on('click',function(e){
            _a_$talign.center(_that);
            _a_$talign.active(e.target);
        })
        $('#text_style_font li:nth-of-type(4)>a').on('click',function(e){
            _a_$talign.left(_that);
            _a_$talign.active(e.target);
        })
        $('#text_style_font li:nth-of-type(5)>a').on('click',function(e){
            _a_$talign.right(_that);
            _a_$talign.active(e.target);
        })
        PAGECURRENT.c.activeObject = _that;
    }
    _a_$talign.setActive = function(_tar){

    }
    /**
     * 设置已选样式
     * @param e
     */
    _a_$talign.active = function(e)
    {
        var _as = $(e).closest('ul').find('li');
        for(var i=0;i<_as.length;i++)
        {
            $(_as[i]).find('a').removeClass('text-style-a-hover');
        }
        $(e).addClass('text-style-a-hover');
    }
    /**
     * 清除dom
     */
    _a_$talign.prototype.hideProperty=function(){
        $('#propertyArea').html('');
    }
    _a_$talign.prototype.precut = function(){

    }
    /**
     * 返回当前的属性dom
     * @returns {*}   dom
     */
    _a_$talign.prototype.getProperty = function(){
        return this.__property;
    }
    exports.instance = _a_$talign;
})
