/**
 * Created by likuan on 9/12 0012.
 */
var TAG = function (nameval) {
    var el = nameval.el || '';
    var pt = nameval.pt || 0;
    var target = nameval.target || '';
    var _t = this;
    _t.opts = {};
    _t.init = function () {
        if (pt) {
            $(el).after($(el).clone(true)).remove();
            return riot.mount(el, _t.opts)[0]
        } else {
            return riot.mount(el, _t.opts)[0]
        }
    };
};

var mixin = {
    init: function() {
        this._ = this._p;
        this.p = this._p;
        this._format = this._f
    },
    _p: function (n) {
        var n=n||20,p = this;
            while (n > 0) {
                if (p.parent) {
                    p = p.parent;
                } else {
                    break;
                }
                n--;
            }
            return p;
    },
    _f: function (x) {
        if (x !== undefined) {
            if (x === '') {
                return true
            } else {
                if (x === '0') {
                    return false
                } else {
                    return x
                }
            }
        }
    },
    //赋值
    _s: function (o,z,y1,y2,y3,def) {
        this._f(o[y1])||this._f(o[y2])||this._f(o[y3])?this[z]=this._f(o[y1])||this._f(o[y2])||this._f(o[y3]):this[z]=def;
    }

};

riot.mixin('mixin', mixin);

function Store() {
    riot.observable(this);
    this.$emit = this.trigger;
    this.emit = this.trigger;
    this.$on = this.on;
};


// load显示与隐藏
var layer_index;
function load(_is, arg) {
    if (_is == undefined || _is == "show" || _is == 1 || _is == true) {
        $('html').spin(arg);
        layer_index = layer.load(3);
    } else {
        $('html').spin(false);
        layer.close(layer_index)
    }
}


//调试简写
function log(x) {
    console.log(x);
}