Files
@ 654a62c4f366
Branch filter:
Location: hot67beta/media/system/js/swf.js
654a62c4f366
7.4 KiB
text/javascript
menubar 11 to 30 and revert
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 | /*
Script: Swiff.Base.js
Contains <Swiff>, <Swiff.getVersion>, <Swiff.remote>
Author:
Valerio Proietti, <http://mad4milk.net>
enhanced by Harald Kirschner <http://digitarald.de>
Credits:
Flash detection 'borrowed' from SWFObject.
License:
MIT-style license.
*/
/*
Function: Swiff
creates a flash object with supplied parameters.
Arguments:
source - the swf path.
properties - an object with key/value pairs. all options are optional. see below.
where - the $(element) to inject the flash object.
Properties:
width - int, the width of the flash object. defaults to 0.
height - int, the height of the flash object. defaults to 0.
id - string, the id of the flash object. defaults to 'Swiff-Object-num_of_object_inserted'.
wmode - string, transparent or opaque.
bgcolor - string, hex value for the movie background color.
vars - an object of variables (functions, anything) you want to pass to your flash movie
Returns:
the object element, to be injected somewhere.
Important: the $ function on the OBJECT element wont extend it, will just target the movie by its id/reference. So its not possible to use the <Element> methods on it.
This is why it has to be injected using $('myFlashContainer').adopt(myObj) instead of $(myObj).injectInside('myFlashContainer');
Example:
(start code)
var obj = new Swiff('myMovie.swf', {
width: 500,
height: 400,
id: 'myBeautifulMovie',
wmode: 'opaque',
bgcolor: '#ff3300',
vars: {
onLoad: myOnloadFunc,
myVariable: myJsVar,
myVariableString: 'hello'
}
});
$('myElement').adopt(obj);
(end)
*/
var Swiff = function(source, props){
if (!Swiff.fixed) Swiff.fix();
var instance = Swiff.nextInstance();
Swiff.vars[instance] = {};
props = $merge({
width: 1,
height: 1,
id: instance,
wmode: 'transparent',
bgcolor: '#ffffff',
allowScriptAccess: 'sameDomain',
callBacks: {'onLoad': Class.empty},
params: false
}, props || {});
var append = [];
for (var p in props.callBacks){
Swiff.vars[instance][p] = props.callBacks[p];
append.push(p + '=Swiff.vars.' + instance + '.' + p);
}
if (props.params) append.push(Object.toQueryString(props.params));
var swf = source + '?' + append.join('&');
return new Element('div').setHTML(
'<object width="', props.width, '" height="', props.height, '" id="', props.id, '" type="application/x-shockwave-flash" data="', swf, '">'
,'<param name="allowScriptAccess" value="', props.allowScriptAccess, '" />'
,'<param name="movie" value="', swf, '" />'
,'<param name="bgcolor" value="', props.bgcolor, '" />'
,'<param name="scale" value="noscale" />'
,'<param name="salign" value="lt" />'
,'<param name="wmode" value="', props.wmode, '" />'
,'</object>').firstChild;
};
Swiff.extend = $extend;
Swiff.extend({
count: 0,
callBacks: {},
vars: {},
nextInstance: function(){
return 'Swiff' + Swiff.count++;
},
//from swfObject, fixes bugs in ie+fp9
fix: function(){
Swiff.fixed = true;
window.addEvent('beforeunload', function(){
__flash_unloadHandler = __flash_savedUnloadHandler = Class.empty;
});
if (!window.ie) return;
window.addEvent('unload', function(){
$each(document.getElementsByTagName("object"), function(swf){
swf.style.display = 'none';
for (var p in swf){
if (typeof swf[p] == 'function') swf[p] = Class.empty;
}
});
});
},
/*
Function: Swiff.getVersion
gets the major version of the flash player installed.
Returns:
a number representing the flash version installed, or 0 if no player is installed.
*/
getVersion: function(){
if (!Swiff.pluginVersion) {
var x;
if(navigator.plugins && navigator.mimeTypes.length){
x = navigator.plugins["Shockwave Flash"];
if(x && x.description) x = x.description;
} else if (window.ie){
try {
x = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
x = x.GetVariable("$version");
} catch(e){}
}
Swiff.pluginVersion = ($type(x) == 'string') ? parseInt(x.match(/\d+/)[0]) : 0;
}
return Swiff.pluginVersion;
},
/*
Function: Swiff.remote
Calls an ActionScript function from javascript. Requires ExternalInterface.
Returns:
Whatever the ActionScript Returns
*/
remote: function(obj, fn){
var rs = obj.CallFunction("<invoke name=\"" + fn + "\" returntype=\"javascript\">" + __flash__argumentsToXML(arguments, 2) + "</invoke>");
return eval(rs);
}
});
/*
Script: Swiff.Uploader.js
Contains <Swiff.Uploader>
Author:
Valerio Proietti, <http://mad4milk.net>,
Harald Kirschner, <http://digitarald.de>
License:
MIT-style license.
*/
/*
Class: Swiff.Uploader
creates an uploader instance. Requires an existing Swiff.Uploader.swf instance.
Arguments:
callBacks - an object, containing key/value pairs, representing the possible callbacks. See below.
onLoaded - Callback when the swf is initialized
options - types, multiple, queued, swf, url, container
callBacks:
onOpen - a function to fire when the user opens a file.
onProgress - a function to fire when the file is uploading. passes the name, the current uploaded size and the full size.
onSelect - a function to fire when the user selects a file.
onComplete - a function to fire when the file finishes uploading
onError - a function to fire when there is an error.
onCancel - a function to fire when the user cancels the file uploading.
*/
Swiff.Uploader = new Class({
options: {
types: false,
multiple: true,
queued: true,
swf: null,
url: null,
container: null
},
callBacks: {
onOpen: Class.empty,
onProgress: Class.empty,
onSelect: Class.empty,
onComplete: Class.empty,
onError: Class.empty,
onCancel: Class.empty
},
initialize: function(callBacks, onLoaded, options){
if (Swiff.getVersion() < 8) return false;
this.setOptions(options);
this.onLoaded = onLoaded;
var calls = $extend($merge(this.callBacks), callBacks || {});
for (p in calls) calls[p] = calls[p].bind(this);
this.instance = Swiff.nextInstance();
Swiff.callBacks[this.instance] = calls;
this.object = Swiff.Uploader.register(this.loaded.bind(this), this.options.swf, this.options.container);
return this;
},
loaded: function(){
Swiff.remote(this.object, 'create', this.instance, this.options.types, this.options.multiple, this.options.queued, this.options.url);
this.onLoaded.delay(10);
},
browse: function(){
Swiff.remote(this.object, 'browse', this.instance);
},
send: function(url){
Swiff.remote(this.object, 'upload', this.instance, url);
},
remove: function(name, size){
Swiff.remote(this.object, 'remove', this.instance, name, size);
},
fileIndex: function(name, size){
return Swiff.remote(this.object, 'fileIndex', this.instance, name, size);
},
fileList: function(){
return Swiff.remote(this.object, 'filelist', this.instance);
}
});
Swiff.Uploader.implement(new Options);
Swiff.Uploader.extend = $extend;
Swiff.Uploader.extend({
swf: 'Swiff.Uploader.swf',
callBacks: [],
register: function(callBack, url, container){
if (!Swiff.Uploader.object || !Swiff.Uploader.loaded) {
Swiff.Uploader.callBacks.push(callBack);
if (!Swiff.Uploader.object) {
Swiff.Uploader.object = new Swiff(url || Swiff.Uploader.swf, {callBacks: {'onLoad': Swiff.Uploader.onLoad}});
(container || document.body).appendChild(Swiff.Uploader.object);
}
}
else callBack.delay(10);
return Swiff.Uploader.object;
},
onLoad: function(){
Swiff.Uploader.loaded = true;
Swiff.Uploader.callBacks.each(function(fn){
fn.delay(10);
});
Swiff.Uploader.callBacks.length = 0;
}
});
|