/**
 * [OElove] (C)2010-2099 oelove.com biz
 * Email: service@phpcoo.com ,phpcoo@qq.com
 * This is NOT a freeware, use is subject to license terms
 * $ Last update 2020/03/30 by CL $
*/
var _inst_oehome_dialog = null;
$(function(){
    
    function OEHomeDialog () {
        this._home_dialog = null;
        this.slide_time = 200;
        
        this.clickDialog();
    }
    
    OEHomeDialog.prototype = {
        
        //点击
        clickDialog:function() {
            var _this = this;
            
            //弹出
            $(document).on("click", "[f='but_open_dialog']", function() {
                var $dialog = $(this).attr("data-dialog");
                var $type = $(this).attr("data-type"); //类型 right,bottom,zoom
                if (typeof($type) == 'undefined') {
                    $type = 'right';
                }
                _this.openDialog($dialog, $type);
            });
            
            //关闭
            $(document).on("click", "[f='close_dialog']", function(){
                var $url = $(this).attr("data-url");
                if (typeof($url) == 'undefined') {
                    $url = '';
                }
                if ($url != '') {
                    _this._home_dialog.hide(function() {
                        setTimeout(function(){
                            window.location.href = $url;
                        }, 50);
                    });
                }
                else {
                    _this.closeDialog();
                }
            });
            
            
        },
        openDialog:function($dialog, $type) {
            var _this = this;
            var $animated = 'slideRightIn';
            if ($type == 'bottom') {
                $animated = 'slideBottomIn';
            }
            else if ($type == 'zoom') {
                $animated = 'zoomIn';
            }
            
            _this._home_dialog = OEUI.Dialog({
                el: '#'+$dialog+'_dialog',
                animated: $animated,
                time:_this.slide_time
            }); 

        },
        closeDialog:function() {
            var _this = this;
            if (_this._home_dialog) {
                _this._home_dialog.hide();
            }
        }
        
    }
    
    _inst_oehome_dialog = new OEHomeDialog();
    
});