mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 16:12:40 +08:00
@@ -516,7 +516,7 @@ _ccsg.EditBox.KeyboardReturnType = KeyboardReturnType;
|
||||
scaleX /= dpr;
|
||||
scaleY /= dpr;
|
||||
|
||||
var container = cc.container;
|
||||
var container = cc.game.container;
|
||||
var a = t.a * scaleX, b = t.b, c = t.c, d = t.d * scaleY;
|
||||
|
||||
var offsetX = container && container.style.paddingLeft && parseInt(container.style.paddingLeft);
|
||||
@@ -543,8 +543,17 @@ _ccsg.EditBox.KeyboardReturnType = KeyboardReturnType;
|
||||
var editBox = this._edTxt;
|
||||
if (node.visible) {
|
||||
editBox.style.visibility = 'visible';
|
||||
cc.game.container.appendChild(editBox);
|
||||
} else {
|
||||
editBox.style.visibility = 'hidden';
|
||||
var hasChild = false;
|
||||
if('contains' in cc.game.container) {
|
||||
hasChild = cc.game.container.contains(editBox);
|
||||
}else {
|
||||
hasChild = cc.game.container.compareDocumentPosition(editBox) % 16;
|
||||
}
|
||||
if(hasChild)
|
||||
cc.game.container.removeChild(editBox);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -986,20 +995,20 @@ _ccsg.EditBox.KeyboardReturnType = KeyboardReturnType;
|
||||
};
|
||||
|
||||
proto._addDomInputControl = function () {
|
||||
cc.container.appendChild(this._edTxt);
|
||||
cc.game.container.appendChild(this._edTxt);
|
||||
};
|
||||
|
||||
proto._removeDomInputControl = function () {
|
||||
var editBox = this._edTxt;
|
||||
if(editBox){
|
||||
var hasChild = false;
|
||||
if('contains' in cc.container) {
|
||||
hasChild = cc.container.contains(editBox);
|
||||
if('contains' in cc.game.container) {
|
||||
hasChild = cc.game.container.contains(editBox);
|
||||
}else {
|
||||
hasChild = cc.container.compareDocumentPosition(editBox) % 16;
|
||||
hasChild = cc.game.container.compareDocumentPosition(editBox) % 16;
|
||||
}
|
||||
if(hasChild)
|
||||
cc.container.removeChild(editBox);
|
||||
cc.game.container.removeChild(editBox);
|
||||
}
|
||||
this._edTxt = null;
|
||||
};
|
||||
|
||||
@@ -270,7 +270,7 @@ _ccsg.VideoPlayer.EventType = {
|
||||
scaleX /= dpr;
|
||||
scaleY /= dpr;
|
||||
|
||||
var container = cc.container;
|
||||
var container = cc.game.container;
|
||||
var a = t.a * scaleX, b = t.b, c = t.c, d = t.d * scaleY;
|
||||
|
||||
var offsetX = container && container.style.paddingLeft && parseInt(container.style.paddingLeft);
|
||||
@@ -383,9 +383,20 @@ _ccsg.VideoPlayer.EventType = {
|
||||
var video = this._video;
|
||||
if (node.visible) {
|
||||
video.style.visibility = 'visible';
|
||||
cc.game.container.appendChild(video);
|
||||
} else {
|
||||
video.style.visibility = 'hidden';
|
||||
video.pause();
|
||||
if(video){
|
||||
var hasChild = false;
|
||||
if('contains' in cc.game.container) {
|
||||
hasChild = cc.game.container.contains(video);
|
||||
}else {
|
||||
hasChild = cc.game.container.compareDocumentPosition(video) % 16;
|
||||
}
|
||||
if(hasChild)
|
||||
cc.game.container.removeChild(video);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -397,20 +408,20 @@ _ccsg.VideoPlayer.EventType = {
|
||||
video.className = "cocosVideo";
|
||||
video.setAttribute('preload', true);
|
||||
this._video = video;
|
||||
cc.container.appendChild(video);
|
||||
cc.game.container.appendChild(video);
|
||||
};
|
||||
|
||||
proto.removeDom = function () {
|
||||
var video = this._video;
|
||||
if(video){
|
||||
var hasChild = false;
|
||||
if('contains' in cc.container) {
|
||||
hasChild = cc.container.contains(video);
|
||||
if('contains' in cc.game.container) {
|
||||
hasChild = cc.game.container.contains(video);
|
||||
}else {
|
||||
hasChild = cc.container.compareDocumentPosition(video) % 16;
|
||||
hasChild = cc.game.container.compareDocumentPosition(video) % 16;
|
||||
}
|
||||
if(hasChild)
|
||||
cc.container.removeChild(video);
|
||||
cc.game.container.removeChild(video);
|
||||
}
|
||||
this._video = null;
|
||||
this._url = "";
|
||||
|
||||
@@ -188,6 +188,11 @@ _ccsg.WebView = _ccsg.Node.extend(/** @lends _ccsg.WebView# */{
|
||||
this._renderCmd.removeDom();
|
||||
this.stopAllActions();
|
||||
this.unscheduleAllCallbacks();
|
||||
},
|
||||
|
||||
setVisible: function ( visible ) {
|
||||
_ccsg.Node.prototype.setVisible.call(this, visible);
|
||||
this._renderCmd.updateVisibility();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -233,6 +238,7 @@ _ccsg.WebView.EventType = {
|
||||
_ccsg.WebView.RenderCmd = function(node){
|
||||
RenderCmd.call(this, node);
|
||||
|
||||
this._parent = null;
|
||||
this._div = null;
|
||||
this._iframe = null;
|
||||
this._listener = null;
|
||||
@@ -290,7 +296,7 @@ _ccsg.WebView.EventType = {
|
||||
scaleX /= dpr;
|
||||
scaleY /= dpr;
|
||||
|
||||
var container = cc.container;
|
||||
var container = cc.game.container;
|
||||
var a = t.a * scaleX, b = t.b, c = t.c, d = t.d * scaleY;
|
||||
|
||||
var offsetX = container && container.style.paddingLeft && parseInt(container.style.paddingLeft);
|
||||
@@ -318,6 +324,7 @@ _ccsg.WebView.EventType = {
|
||||
var self = this;
|
||||
var cb = function(){
|
||||
self._loaded = true;
|
||||
self.updateVisibility();
|
||||
iframe.removeEventListener("load", cb);
|
||||
};
|
||||
iframe.addEventListener("load", cb);
|
||||
@@ -351,7 +358,7 @@ _ccsg.WebView.EventType = {
|
||||
this._div.style.width = contentSize.width + "px";
|
||||
this._div.style.overflow = "scroll";
|
||||
this._div.style.border = "none";
|
||||
cc.container.appendChild(this._div);
|
||||
cc.game.container.appendChild(this._div);
|
||||
};
|
||||
|
||||
proto.createNativeControl = function () {
|
||||
@@ -364,15 +371,37 @@ _ccsg.WebView.EventType = {
|
||||
var div = this._div;
|
||||
if(div){
|
||||
var hasChild = false;
|
||||
if('contains' in cc.container) {
|
||||
hasChild = cc.container.contains(div);
|
||||
if('contains' in cc.game.container) {
|
||||
hasChild = cc.game.container.contains(div);
|
||||
}else {
|
||||
hasChild = cc.container.compareDocumentPosition(div) % 16;
|
||||
hasChild = cc.game.container.compareDocumentPosition(div) % 16;
|
||||
}
|
||||
if(hasChild)
|
||||
cc.container.removeChild(div);
|
||||
cc.game.container.removeChild(div);
|
||||
}
|
||||
this._div = null;
|
||||
};
|
||||
|
||||
proto.updateVisibility = function () {
|
||||
var node = this._node;
|
||||
if (!this._div) return;
|
||||
var div = this._div;
|
||||
if (node.visible) {
|
||||
div.style.visibility = 'visible';
|
||||
cc.game.container.appendChild(div);
|
||||
} else {
|
||||
div.style.visibility = 'hidden';
|
||||
if(div){
|
||||
var hasChild = false;
|
||||
if('contains' in cc.game.container) {
|
||||
hasChild = cc.game.container.contains(div);
|
||||
}else {
|
||||
hasChild = cc.game.container.compareDocumentPosition(div) % 16;
|
||||
}
|
||||
if(hasChild)
|
||||
cc.game.container.removeChild(div);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
})(_ccsg.WebView._polyfill);
|
||||
|
||||
Reference in New Issue
Block a user