/** * moduleData = { id, x, y, width, height } * htmlWidget.init(moduleData); * htmlWidget.move(moduleData); * htmlWidget.dispose(id); * htmlWidget.hideAll(); * htmlWidget.showAll(); * htmlWidget.hide(id); * htmlWidget.show(id); * htmlWidget.resize(); */ var htmlWidget = { swf:null ,getObj:function(id){return ( (document.getElementById) ? document.getElementById(id) : ( (document.all) ? document.all[id] : ( (document.layers) ? document.layers[id] : null ) ));} ,config:{ divId:'htmlWidget_', divClass:'htmlWidgetDiv', dispose:'remove', initresize:false, resizeTimer:null, swf:'website_swf', container:'htmlContainer', timestamp:new Date().getTime() } ,objects:{} ,cache:{} ,disposed:{} ,init:function(moduleData) { if (!moduleData['file'] || moduleData.file == '') return; moduleData.htmlFile = moduleData.file.split('.xml')[0]+'.html'; this.disposed[moduleData.id] = false; if (this.config.initresize == false) { var f = window.onresize; window.onresize = function(){if (typeof f == 'function') f();htmlWidget.resize(false);}; this.config.initresize = true; } if (this.isObject(moduleData.id)) { this.show(moduleData.id); return; } this.setObject(moduleData.id, {params:moduleData}); if (this.cache[moduleData.id]) { this.cache[moduleData.id].moduleData = moduleData; this.fileResultHandler(this.cache[moduleData.id].data, moduleData.id); return; } var $t = this; var url = (flashvars['basePath'] ? flashvars.basePath : '') + moduleData.file; url += '?time=' + this.config.timestamp; $.get(url, function(data) { $t.cache[moduleData.id] = { data:data, moduleData:moduleData }; $t.fileResultHandler(data, moduleData.id); },"xml") .error(function(){ $t.error(moduleData, "HtmlWidget: Error while reading external file"); }); } ,copyObject:function(data) { var obj = {}; for(var i in data) { if (typeof data[i] == 'object') obj[i] = this.copyObject(data[i]); else obj[i] = data[i]; } return obj; } ,mergeObject:function(obj, data) { for(var i in data) { if (typeof data[i] == 'object') { obj[i] = this.mergeObject(( typeof obj[i] == 'object' ? obj[i] : {}),data[i]); } else obj[i] = data[i]; } return obj; } ,addObject:function(id, data) { var obj = this.copyObject(data); this.objects[id] = obj; } ,setObject:function(id, data) { var obj = this.getObject(id, {}); obj = (data != null ? this.mergeObject(obj, data) : null); this.objects[id] = obj; } ,getObjects:function() { return this.objects; } ,getObject:function(id, def) { if (!def) def = null return (typeof this.objects[id] != 'undefined' && this.objects[id] != null ? this.objects[id] : def); } ,isObject:function(id) { return (typeof this.objects[id] != 'undefined' && this.objects[id] != null); } ,fileResultHandler:function(data, id) { if (this.disposed[id]) { this.disposed[id] = false; return; } if ( typeof data == 'string') { var xml = new ActiveXObject('Microsoft.XMLDOM'); xml.async = false; xml.loadXML( xmlData); data = xml; } var obj = this.xml2obj(data); this.setObject(id, obj); this.add(id, true); } ,hide:function(id) { if ($('#' + this.config.divId + id).length > 0) $('#' + this.config.divId + id).hide(); } ,show:function(id) { if ($('#' + this.config.divId + id).length > 0) $('#' + this.config.divId + id).show(); else this.add(id); } ,setHtml:function(id) { if (!this.isObjects[id]) return; var obj = this.getObject(id); if (!frames[this.config.divId+'iframe_'+obj.params.id]) return ; var d = frames[this.config.divId+'iframe_'+obj.params.id].document; d.open(); d.write(obj.data); d.close(); } ,resize:function(isFlash) { if (typeof isFlash == 'undefined') isFlash = true; if (isFlash) { clearTimeout(this.config.resizeTimer); this.config.resizeTimer = setTimeout(function(){htmlWidget.resize(false);}, 10); return; } for(var i in this.objects) if (this.objects[i] != null) this.move(this.objects[i].params, false); } ,moveById:function(id, isFlash) { var params = this.getObject(id).params; params.id = id; this.move(params, isFlash); } ,move:function(data, isFlash) { if (!this.isObject(data.id)) return; this.setObject(data.id, {params:data}); if (typeof isFlash == 'undefined') isFlash = true; if (isFlash) { this.resize(true); return; } var style = { width: parseInt(data.width), height: parseInt(data.height), left: parseInt(data.x), top: parseInt(data.y) }; style.left+=$('#'+this.config.swf).offset().left; $('#' + this.config.divId + data.id) .width(style.width) .height(style.height) .css('left',style.left) .css('top',style.top) ; } ,add:function(id, recreate) { if (!this.isObject(id)) return; if (typeof recreate == 'undefined') recreate = true; var obj = this.getObject(id); if ($('#' + this.config.divId + obj.params.id).length < 1 || recreate == true) { var iframe = '' + ''; var div = '