Skip to content

Commit eaead87

Browse files
committed
Merge pull request cocos2d#1032 from ShengxiangChen/issue2138_pluginx
fixed cocos2d#2138 PluginX HelloSocial Thanks
2 parents 5d9ab8c + 7b9bceb commit eaead87

28 files changed

+1317
-7
lines changed

cocos2d/CCLoader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
* @type Object
3131
*/
3232
cc.RESOURCE_TYPE = {
33-
"IMAGE": ["png", "jpg", "bmp","jpeg"],
33+
"IMAGE": ["png", "jpg", "bmp","jpeg","gif"],
3434
"SOUND": ["mp3", "ogg", "wav", "mp4", "m4a"],
3535
"XML": ["plist", "xml", "fnt", "tmx", "tsx"],
3636
"BINARY": ["ccbi"],

cocos2d/platform/jsloader.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,29 @@
199199
]);
200200
}
201201

202+
if (c.loadPluginx != null && c.loadPluginx == true) {
203+
engine = engine.concat([
204+
//protocols
205+
'../extensions/PluginX/protocols/Config.js',
206+
'../extensions/PluginX/protocols/PluginUtils.js',
207+
'../extensions/PluginX/protocols/PluginProtocol.js',
208+
'../extensions/PluginX/protocols/ProtocolSocial.js',
209+
//'../extensions/PluginX/protocols/ProtocolAds.js',
210+
//'../extensions/PluginX/protocols/ProtocolAnalytics.js',
211+
//'../extensions/PluginX/protocols/ProtocolIAP.js',
212+
'../extensions/PluginX/protocols/PluginFactory.js',
213+
'../extensions/PluginX/protocols/PluginManager.js',
214+
215+
//plugins
216+
'../extensions/PluginX/plugins/SocialWeibo.js',
217+
'../extensions/PluginX/plugins/SocialQQWeibo.js',
218+
'../extensions/PluginX/plugins/SocialQzone.js',
219+
'../extensions/PluginX/plugins/SocialTwitter.js',
220+
'../extensions/PluginX/plugins/SocialFacebook.js',
221+
//'../extensions/PluginX/plugins/AdsGoogle.js'
222+
]);
223+
}
224+
202225
if (!c.engineDir) {
203226
engine = [];
204227
}

cocos2d/platform/miniFramework.js

Lines changed: 55 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ cc.Browser = {};
6161
var browserTypes = cc.Browser.ua.match(/micromessenger|qqbrowser|mqqbrowser|ucbrowser|360browser|baidubrowser|maxthon|ie|opera|firefox/) || cc.Browser.ua.match(/chrome|safari/);
6262
if (browserTypes.length > 0) {
6363
var el = browserTypes[0];
64-
if(el == 'micromessenger'){
64+
if (el == 'micromessenger') {
6565
return 'wechat';
6666
}
6767
return el;
@@ -84,7 +84,7 @@ cc.Browser = {};
8484
// WebGL first
8585
cc.Browser.supportWebGL = !(window.WebGLRenderingContext == null);
8686
var tempCanvas = document.createElement("Canvas");
87-
var tempContext = cc.create3DContext(tempCanvas, {'stencil':true, 'preserveDrawingBuffer':true });
87+
var tempContext = cc.create3DContext(tempCanvas, {'stencil': true, 'preserveDrawingBuffer': true });
8888
cc.Browser.supportWebGL = !(tempContext == null)
8989
}
9090
if (cc._userRenderMode === 2 && !cc.Browser.supportWebGL) {
@@ -102,6 +102,55 @@ cc.Browser = {};
102102
return false;
103103
}
104104
})();
105+
106+
107+
cc.Browser.openURL = function (url) {
108+
if (this.isMobile) {
109+
var size = cc.Director.getInstance().getWinSize();
110+
var w = size.width + "px";
111+
var h = size.height + "px";
112+
113+
var div = cc.$new("div");
114+
div.style.backgroundColor = "#ffffff";
115+
div.style.width = w;
116+
div.style.height = h;
117+
div.style.zindex = 1000;
118+
div.style.position = 'absolute';
119+
div.style.top = 0 + 'px';
120+
div.style.left = 0 + 'px';
121+
div.id = "cocos2d-browser";
122+
123+
var iframe = cc.$new("iframe");
124+
iframe.src = url;
125+
iframe.style.width = w;
126+
iframe.style.height = h;
127+
iframe.setAttribute("frameborder", "no");
128+
iframe.setAttribute("scrolling", "no");
129+
div.appendChild(iframe);
130+
131+
iframe.onload = function () {
132+
var close = new Image();
133+
close.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACEAAAAhCAYAAABX5MJvAAAAGXRFWHRTb2Z0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Hxw/0eWxszIjyj8Jvy4N60FdVVX2Grnt4dkaowYJESAG3yaLR09Oz5uvrexwbGxuAR2erpKTkI6RqxW5DM6RnLT09PQQV5vDwsDYlJWUU+I4EIDMhEQLAA6q0DA4OrqMCg/c/qL6+XtXY2Kgn4sGJuavRaFbFYrFPeXn5FIj6ReFa64KnIpJOpaMK39vbM9XV1X13lF9kc3Nz+xMTEwZo89s03A4ycRE1N/RjF/WPKgyfDRU39Gu7w1qYyNYAtwDB1yhgGPDBfgzU4bMi7xoEjAI6iWZRdGMGH80Cr2goRlP5W8B7qwBHfw1YO6kEH4yC8EnJ5QKbnuDFh17nr4BPRP9P/BFgAHo7ZNgI9EbHAAAAAElFTkSuQmCC";
134+
div.appendChild(close);
135+
close.style.zindex = 1000;
136+
close.style.position = 'absolute';
137+
close.style.bottom = 10 + 'px';
138+
close.style.right = 10 + 'px';
139+
close.onclick = function () {
140+
div.remove();
141+
}
142+
};
143+
144+
var tag = document['ccConfig'].tag;
145+
var parent = document.getElementById(tag).parentNode;
146+
if (parent) {
147+
parent.appendChild(div);
148+
}
149+
}
150+
else {
151+
window.open(url);
152+
}
153+
}
105154
})();
106155

107156
cc.RenderDoesnotSupport = function () {
@@ -206,10 +255,10 @@ cc.$ = function (x) {
206255
return this;
207256
};
208257

209-
el.position = el.position || {x:0, y:0};
258+
el.position = el.position || {x: 0, y: 0};
210259
el.rotation = el.rotation || 0;
211-
el.scale = el.scale || {x:1, y:1};
212-
el.skew = el.skew || {x:0, y:0};
260+
el.scale = el.scale || {x: 1, y: 1};
261+
el.skew = el.skew || {x: 0, y: 0};
213262

214263
/**
215264
* move the element
@@ -322,5 +371,5 @@ cc.$.findpos = function (obj) {
322371
curleft += obj.offsetLeft;
323372
curtop += obj.offsetTop;
324373
} while (obj = obj.offsetParent);
325-
return {x:curleft, y:curtop};
374+
return {x: curleft, y: curtop};
326375
};
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
plugin.SocialFacebook = cc.Class.extend({
2+
3+
/**
4+
methods of protocol : InterfaceSocial
5+
*/
6+
init: function () {
7+
this._shareInfo = {
8+
'url': window.location.href
9+
};
10+
},
11+
configDeveloperInfo: function (cpInfo) {
12+
//invalid on html5
13+
},
14+
share: function (shareInfo) {
15+
var url = shareInfo["SharedURLPath"];
16+
if(url !== null){
17+
this._shareInfo.url = url;
18+
}
19+
20+
cc.Browser.openURL("http://www.facebook.com/sharer/sharer.php?u=" + url);
21+
},
22+
setDebugMode: function (debug) {
23+
//invalid on html5
24+
},
25+
getSDKVersion: function () {
26+
return "unkown";
27+
},
28+
getPluginVersion: function () {
29+
return plugin.Version;
30+
}
31+
});
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
plugin.SocialQQWeibo = cc.Class.extend({
2+
_shareInfo: null,
3+
4+
/**
5+
methods of protocol : InterfaceSocial
6+
*/
7+
init: function () {
8+
this._shareInfo = {
9+
'appkey': 12345678,
10+
'title': "Hello, Cocos2d-html5!",
11+
'url': window.location.href,
12+
'pic': null
13+
};
14+
},
15+
configDeveloperInfo: function (cpInfo) {
16+
this._shareInfo.appkey = cpInfo["QQWeiboAppKey"];
17+
},
18+
share: function (shareInfo) {
19+
this._shareInfo.title = shareInfo["SharedText"];
20+
this._shareInfo.pic = shareInfo["SharedImagePath"];
21+
22+
var urlstring = "", value;
23+
for (var key in this._shareInfo) {
24+
value = this._shareInfo[key];
25+
if (value !== null) {
26+
urlstring += encodeURI(key + "=" + value) + "&";
27+
}
28+
}
29+
urlstring = urlstring.substr(0, urlstring.length - 1);
30+
cc.Browser.openURL("http://share.v.t.qq.com/index.php?c=share&a=index&" + urlstring);
31+
32+
},
33+
setDebugMode: function (debug) {
34+
//invalid on html5
35+
},
36+
getSDKVersion: function () {
37+
return "unkown";
38+
},
39+
getPluginVersion: function () {
40+
return plugin.Version;
41+
}
42+
});
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
plugin.SocialQzone = cc.Class.extend({
2+
_shareInfo: null,
3+
4+
/**
5+
methods of protocol : InterfaceSocial
6+
*/
7+
init: function () {
8+
this._shareInfo = {
9+
'desc': "Hello, Cocos2d-html5!",
10+
'url': window.location.href,
11+
'pics': null,
12+
'showcount':1
13+
};
14+
},
15+
configDeveloperInfo: function (cpInfo) {
16+
//invalid on html5
17+
},
18+
share: function (shareInfo) {
19+
this._shareInfo.desc = shareInfo["SharedText"];
20+
this._shareInfo.pics = shareInfo["SharedImagePath"];
21+
var url = shareInfo["SharedURLPath"];
22+
if(url !== null){
23+
this._shareInfo.url = url;
24+
}
25+
26+
var urlstring = "", value;
27+
for (var key in this._shareInfo) {
28+
value = this._shareInfo[key];
29+
if (value) {
30+
urlstring += encodeURI(key + "=" + value) + "&";
31+
}
32+
}
33+
urlstring = urlstring.substr(0, urlstring.length - 1);
34+
cc.Browser.openURL("http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?"+urlstring);
35+
},
36+
setDebugMode: function (debug) {
37+
//invalid on html5
38+
},
39+
getSDKVersion: function () {
40+
return "unkown";
41+
},
42+
getPluginVersion: function () {
43+
return plugin.Version;
44+
}
45+
});
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
plugin.SocialTwitter = cc.Class.extend({
2+
_shareInfo: null,
3+
4+
/**
5+
methods of protocol : InterfaceSocial
6+
*/
7+
init: function () {
8+
this._shareInfo = {
9+
'appkey': 12345678,
10+
'title': "Hello, Cocos2d-html5!",
11+
'url': window.location.href,
12+
'pic': null
13+
};
14+
},
15+
configDeveloperInfo: function (cpInfo) {
16+
this._shareInfo.appkey = cpInfo["WeiboAppKey"];
17+
},
18+
share: function (shareInfo) {
19+
this._shareInfo.title = shareInfo["SharedText"];
20+
this._shareInfo.pic = shareInfo["SharedImagePath"];
21+
22+
23+
cc.Browser.openURL("http://twitter.com/intent/tweet?text=" + this._shareInfo.title + " " + this._shareInfo.url);
24+
},
25+
setDebugMode: function (debug) {
26+
//invalid on html5
27+
},
28+
getSDKVersion: function () {
29+
return "20130607";
30+
},
31+
getPluginVersion: function () {
32+
return plugin.Version;
33+
}
34+
});
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
plugin.SocialWeibo = cc.Class.extend({
2+
_shareInfo: null,
3+
4+
/**
5+
methods of protocol : InterfaceSocial
6+
*/
7+
init: function () {
8+
this._shareInfo = {
9+
'appkey': 12345678,
10+
'title': "Hello, Cocos2d-html5!",
11+
'url': window.location.href,
12+
'pic': null
13+
};
14+
},
15+
configDeveloperInfo: function (cpInfo) {
16+
this._shareInfo.appkey = cpInfo["WeiboAppKey"];
17+
},
18+
share: function (shareInfo) {
19+
this._shareInfo.title = shareInfo["SharedText"];
20+
this._shareInfo.pic = shareInfo["SharedImagePath"];
21+
22+
var urlstring = "?", value;
23+
for (var key in this._shareInfo) {
24+
value = this._shareInfo[key];
25+
if (value) {
26+
urlstring += encodeURI(key + "=" + value) + "&";
27+
}
28+
}
29+
urlstring = urlstring.substr(0, urlstring.length - 1);
30+
cc.Browser.openURL("http://v.t.sina.com.cn/share/share.php?" + urlstring);
31+
},
32+
setDebugMode: function (debug) {
33+
//invalid on html5
34+
},
35+
getSDKVersion: function () {
36+
return "2.0";
37+
},
38+
getPluginVersion: function () {
39+
return plugin.Version;
40+
}
41+
});

0 commit comments

Comments
 (0)