Skip to content

Commit

Permalink
simplify webview event handler
Browse files Browse the repository at this point in the history
  • Loading branch information
zilongshanren committed Jul 26, 2016
1 parent 269cf15 commit 2036a6e
Showing 1 changed file with 7 additions and 25 deletions.
32 changes: 7 additions & 25 deletions cocos2d/core/components/CCWebView.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,32 +86,14 @@ var WebView = cc.Class({
},

/**
* !#en The webview's event callback , it will be triggered when web page finished loading.
* !#zh WebView 的回调事件,当网页加载完成之后会回调此函数
* !#en The webview's event callback , it will be triggered when certain webview event occurs.
* !#zh WebView 的回调事件,当网页加载过程中,加载完成后或者加载出错时都会回调此函数
* @property {cc.Component.EventHandler[]} webviewLoadedEvents
*/
webviewLoadedEvents: {
webviewEvents: {
default: [],
type: cc.Component.EventHandler,
},
/**
* !#en The webview's event callback , it will be triggered when web page is loading.
* !#zh WebView 的回调事件,当网页加载时会回调此函数
* @property {cc.Component.EventHandler[]} webviewLoadingEvents
*/
webviewLoadingEvents: {
default: [],
type: cc.Component.EventHandler,
},
/**
* !#en The webview's event callback , it will be triggered when there are errors when loading.
* !#zh WebView 的回调事件,当网页加载出错时会回调此函数
* @property {cc.Component.EventHandler[]} webviewErrorEvents
*/
webviewErrorEvents: {
default: [],
type: cc.Component.EventHandler,
}
},

statics: {
Expand Down Expand Up @@ -156,16 +138,16 @@ var WebView = cc.Class({
},

_onWebViewLoaded: function () {
cc.Component.EventHandler.emitEvents(this.webviewLoadedEvents, this, EventType.LOADED);
cc.Component.EventHandler.emitEvents(this.webviewEvents, this, EventType.LOADED);
return true;
},

_onWebViewLoading: function () {
cc.Component.EventHandler.emitEvents(this.webviewLoadingEvents, this, EventType.LOADING);
return true;
cc.Component.EventHandler.emitEvents(this.webviewEvents, this, EventType.LOADING);
},

_onWebViewLoadError: function () {
cc.Component.EventHandler.emitEvents(this.webviewErrorEvents, this, EventType.ERROR);
cc.Component.EventHandler.emitEvents(this.webviewEvents, this, EventType.ERROR);
}

});
Expand Down

0 comments on commit 2036a6e

Please sign in to comment.