Fix GH-103: Create SWF regardless of platform
Port LLK/scratchr2#4168 for ScratchX. Original description from that change: > This fixes #4112 by creating the swf regardless of OS and browser. > Calling `embedSWF` would first check for the existence of the plugin > before creating, causing browsers that don’t allow the flash plugin by > default to not be able to show their “allow” message. This tries to > create the swf no matter what, allowing browsers to detect flash > themselves. > > Logic is as follows: > 1. check if `userAgent` returns a mobile/tablet OS. Display error > message if so > 2. check if on windows and using ie – check for an express install if > so (like in `embedSWF`) > 3. load the swf in all other cases, let browsers handle it. > > Test Cases: > - Test how project pages load in Android and iOS devices, on tablets > and on phones, and on multiple desktop OS's for correct loading > behavior. This resolves LLK/scratchx#103
This commit is contained in:
parent
bc523ddb37
commit
e2455a0609
3 changed files with 32 additions and 4 deletions
|
@ -109,14 +109,35 @@ var params = {
|
|||
};
|
||||
|
||||
$.each(flashVars, function (prop, val) {
|
||||
if ($.isPlainObject(val))
|
||||
flashVars[prop] = encodeURIComponent(JSON.stringify(val));
|
||||
if ($.isPlainObject(val)) {
|
||||
val = encodeURIComponent(JSON.stringify(val));
|
||||
}
|
||||
if (typeof params.flashvars !== 'undefined') {
|
||||
params.flashvars += '&' + prop + '=' + val;
|
||||
} else {
|
||||
params.flashvars = prop + '=' + val;
|
||||
}
|
||||
});
|
||||
|
||||
swfobject.switchOffAutoHideShow();
|
||||
|
||||
swfobject.embedSWF('Scratch.swf', 'scratch', '100%', '100%', '11.7.0', 'libs/expressInstall.swf',
|
||||
flashVars, params, null, handleEmbedStatus);
|
||||
var swfAttributes = {
|
||||
data: 'Scratch.swf',
|
||||
width: '100%',
|
||||
height: '100%'
|
||||
};
|
||||
|
||||
swfobject.addDomLoadEvent(function() {
|
||||
// check if mobile/tablet browser user bowser
|
||||
if(bowser.mobile || bowser.tablet) {
|
||||
// if on mobile, show error screen
|
||||
handleEmbedStatus({success: false});
|
||||
} else {
|
||||
// if not on ie, let browser try to handle flash loading
|
||||
var swf = swfobject.createSWF(swfAttributes, params, "scratch");
|
||||
handleEmbedStatus({success: true, ref: swf});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/* File uploads */
|
||||
|
|
Reference in a new issue