MCPcopy
hub / github.com/moxiecode/plupload / initialize

Function initialize

js/moxie.js:2942–3016  ·  view source on GitHub ↗
(items)

Source from the content-addressed store, hash-verified

2940 var comp = this, ruid;
2941
2942 function initialize(items) {
2943 var type, constructor;
2944
2945 // if we ran out of runtimes
2946 if (!items.length) {
2947 comp.trigger('RuntimeError', new x.RuntimeError(x.RuntimeError.NOT_INIT_ERR));
2948 runtime = null;
2949 return;
2950 }
2951
2952 type = items.shift().toLowerCase();
2953 constructor = Runtime.getConstructor(type);
2954 if (!constructor) {
2955 if (MXI_DEBUG && Env.debug.runtime) {
2956 Env.log("Constructor for '%s' runtime is not available.", type);
2957 }
2958 initialize(items);
2959 return;
2960 }
2961
2962 if (MXI_DEBUG && Env.debug.runtime) {
2963 Env.log("Trying runtime: %s", type);
2964 Env.log(options);
2965 }
2966
2967 // try initializing the runtime
2968 runtime = new constructor(options);
2969
2970 runtime.bind('Init', function() {
2971 // mark runtime as initialized
2972 runtime.initialized = true;
2973
2974 if (MXI_DEBUG && Env.debug.runtime) {
2975 Env.log("Runtime '%s' initialized", runtime.type);
2976 }
2977
2978 // jailbreak ...
2979 setTimeout(function() {
2980 runtime.clients++;
2981 comp.ruid = runtime.uid;
2982 // this will be triggered on component
2983 comp.trigger('RuntimeInit', runtime);
2984 }, 1);
2985 });
2986
2987 runtime.bind('Error', function() {
2988 if (MXI_DEBUG && Env.debug.runtime) {
2989 Env.log("Runtime '%s' failed to initialize", runtime.type);
2990 }
2991
2992 runtime.destroy(); // runtime cannot destroy itself from inside at a right moment, thus we do it here
2993 initialize(items);
2994 });
2995
2996 runtime.bind('Exception', function(e, err) {
2997 var message = err.name + "(#" + err.code + ")" + (err.message ? ", from: " + err.message : '');
2998
2999 if (MXI_DEBUG && Env.debug.runtime) {

Callers 1

moxie.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected