/*
 * 特别声明：本技术材料受《中华人民共和国著作权法》、《计算机软件保护条例》等法律、法规、行政
 * 规章以及有关国际条约的保护，赞同科技享有知识产权、保留一切权利并视其为技术秘密。未经本公司书
 * 面许可，任何人不得擅自（包括但不限于：以非法的方式复制、传播、展示、镜像、上载、下载）使用，
 * 不得向第三方泄露、透露、披露。否则，本公司将依法追究侵权者的法律责任。特此声明！
 *
 * Special Declaration: These technical material reserved as the technical secrets by AGREE 
 * TECHNOLOGY have been protected by the "Copyright Law" "ordinances on Protection of Computer 
 * Software" and other relevant administrative regulations and international treaties. Without 
 * the written permission of the Company, no person may use (including but not limited to the 
 * illegal copy, distribute, display, image, upload, and download) and disclose the above 
 * technical documents to any third party. Otherwise, any infringer shall afford the legal 
 * liability to the company.
 */
/**
 * Created by liushuai on 2015/1/29.
 */
define(function () {
    return {
        dispatchEvent: function (msgType, attrs) {
            var evtObj = {
                msgType: msgType,
                attributes: attrs
            }
            var msg = JSON.stringify(evtObj);
            // TODO
            // if (eventdispatch !== undefined) {
            //     return eventdispatch.dispatch(msg);
            // } else {
            if(window.cefQuery){
                return window.cefQuery({
                               request: msg,
                               onSuccess: function(response) {
                               //TODO
//                                 foo.innerHTML = "Response from Java: " + response;
                               },
                               onFailure: function(error_code, error_message) {
                               //TODO
//                                 foo.innerHTML = "[ERROR]" + error_code + "\n" + error_message;
                               }
                             });
            }else{
                console.error("not found event dispatch!");
            }
            // }
        }, DISPOSED: 12,

        MOUSE_UP: 0x24,

        MOUSE_DOWN: 0x25,

        CLICK: 0x26,

        MODIFY: 0x27,

        /**
         * onChange事件，一般是由Select、RadioButton等组件产生
         */
        ON_CHANGE: 0x28,

        BROWSER_EVENT: 0x29,

        ON_FOCUS: 0x2A,

        KEY_UP: 0x2B,

        KEY_DONW: 0x2C,

        SELECTION: 0x2D,

        TOUCH_MOVE: 0x2E,

        /**
         * LOOK_OVER事件，由自定义组件CustomQueue产生
         */
        LOOK_OVER: 0x2F,

        MSG_TYPE: {
            INIT: 0x06,
            WIDGET: 0x16,
            GPS: 0x18,
            FINISH: 0x26,
            ERROR: 0x36,
            ACTIVE_ELEMENT: 0x37,
            DISPLAY_FILTER: 0x38,
            DISPLAY: 0x3A
        }
    };
})