Page MenuHomeIn-Portal Phabricator

in-portal
No OneTemporary

File Metadata

Created
Mon, Sep 22, 3:14 AM

in-portal

Index: trunk/core/admin_templates/js/uploader.js
===================================================================
--- trunk/core/admin_templates/js/uploader.js (nonexistent)
+++ trunk/core/admin_templates/js/uploader.js (revision 8174)
@@ -0,0 +1,432 @@
+function Uploader(id, params)
+{
+ this.id = id;
+ if (params.multiple.length == 0) params.multiple = 1;
+ this.params = params;
+ this.files_count = 0;
+ this.files = new Array();
+ this.deleted = new Array()
+
+ this.uploadURL = params.uploadURL;
+ this.deleteURL = params.deleteURL;
+}
+
+Uploader.prototype.Init = function()
+{
+ var holder = document.createElement('DIV');
+ document.body.appendChild(holder);
+
+ // moving out progress div to overcome loosing of flash object after setting opacity
+
+ this.div = document.getElementById(this.id+'_progress');
+ var clone = this.div.cloneNode(true);
+ this.div.parentNode.removeChild(this.div)
+ this.div = document.body.appendChild(clone);
+
+ this.filename = document.getElementById(this.id+'_progress_filename');
+ this.progress = document.getElementById(this.id+'_progress_progress');
+ this.elapsed = document.getElementById(this.id+'_progress_elapsed');
+ this.remaining = document.getElementById(this.id+'_progress_remaining');
+ this.percent = document.getElementById(this.id+'_percent');
+ this.done = document.getElementById(this.id+'_done');
+ this.total = 0;
+ this.uploaded = 0;
+
+ this.flash_id = UploadsManager.NextFlashId();
+ this.swf = new SWFObject('SWFUpload.swf', this.flash_id, "0", "0", "8", "#000000");
+ this.swf.setAttribute('style', '');
+ this.swf.addVariable("uploadScript", '');
+ this.swf.addVariable("maxFiles", escape(this.params.multiple));
+ this.swf.addVariable("allowedFilesize", escape(this.params.allowedFilesize));
+ this.swf.addVariable("allowedFiletypes", escape(this.params.allowedFiletypes));
+ this.swf.addVariable("allowedFiletypesDescription", escape(this.params.allowedFiletypesDescription));
+
+ this.swf.addVariable("uploadFileQueuedCallback", escape('UploadsManager.FileSelected'));
+ this.swf.addVariable("uploadFileStartCallback", escape('UploadsManager.UploadFileStart'));
+ this.swf.addVariable("uploadProgressCallback", escape('UploadsManager.UploadProgress'));
+ this.swf.addVariable("uploadFileCompleteCallback", escape('UploadsManager.UploadFileComplete'));
+ this.swf.addVariable("uploadFileCancelCallback", escape('UploadsManager.FileCancelled'));
+ this.swf.addVariable("uploadQueueCompleteCallback", escape('UploadsManager.UploadQueueComplete'));
+ this.swf.addVariable("uploadFileErrorCallback", escape('UploadsManager.UploadError'));
+ this.swf.addVariable("uploadCancelCallback", escape('uploadCancel'));
+ this.swf.addVariable("autoUpload", escape('false'));
+// this.swf.addVariable("flashLoadedCallback", 'flashLoadedCallback');
+
+ this.swf.addVariable("uploadScriptCallback", escape('UploadsManager.GetUploadScript'));
+ this.swf.addVariable("uploaderId", escape(this.id));
+ this.swf.write(holder);
+
+ this.flash = document.getElementById(this.flash_id);
+ /*if (this.flash != null) {
+ if(this.flash.PercentLoaded() == 100) {
+ alert('done movie: '+this.flash.PercentLoaded());
+ }
+ }
+ else {
+ alert('this.flash is null')
+ }*/
+ if (this.params.urls != '') {
+ var urls = this.params.urls.split('|');
+ var names = this.params.names.split('|');
+ var sizes = this.params.sizes.split('|');
+ for (var i in urls) {
+ var a_file = {
+ id : names[i],
+ name : names[i],
+ url : urls[i],
+ size: sizes[i],
+ uploaded : 1
+ }
+ this.files.push(a_file)
+ this.files_count++;
+ }
+ this.UpdateInfo();
+ }
+}
+
+Uploader.prototype.UpdateInfo = function()
+{
+ var o = '';
+ for (var f in this.files) {
+ this.files[f].name.match(/\.([^.]*)$/);
+ var ext = RegExp.$1;
+ var icon = ext.match(/^(ai|avi|bmp|cs|dll|doc|dot|exe|fla|gif|htm|html|jpg|js|mdb|mp3|pdf|ppt|rdp|swf|swt|txt|vsd|xls|xml|zip)$/) ? ext : 'default.icon';
+ o += '<img src="../cmseditor/editor/images/'+icon+'.gif" style="position: relative; top: 2px;">&nbsp;';
+ if (isset(this.files[f].uploaded)) {
+ o += '<a href="'+this.files[f].url+'" target="_new">'+this.files[f].name + '</a> ('+this.FormatSize(this.files[f].size)+')&nbsp;[<a href="javascript:UploadsManager.DeleteFile(\''+this.id+'\', \''+this.files[f].name+'\')">Delete</a>]<br/>';
+ }
+ else {
+ o += this.files[f].name + ' ('+this.FormatSize(this.files[f].size)+')&nbsp;[<a href="javascript:UploadsManager.CancelFile(\''+this.files[f].uploader_id+'\', \''+this.files[f].id+'\')">Delete</a>]<br/>';
+ }
+ }
+ document.getElementById(this.id+'_queueinfo').innerHTML = o;
+ this.PrepareFiles()
+}
+
+Uploader.prototype.RemoveFile = function(file)
+{
+ var n_files = new Array();
+ var count=0;
+ this.total=0;
+ for (var f in this.files) {
+ if (this.files[f].id != file.id && this.files[f].name != file.id ) {
+ n_files.push(this.files[f]);
+ if (!isset(this.files[f].uploaded)) {
+ this.total += file.size
+ }
+ count++;
+ }
+ }
+ this.files = n_files;
+ this.files_count = count;
+ this.UpdateInfo();
+}
+
+Uploader.prototype.GetUploadScript = function(file)
+{
+// document.getElementById(this.id+'[my_tmp]').value = file.id;
+ return this.uploadURL.replace('#ID#', file.id).replace('#FIELD#', this.params.field).replace('#SID#', this.params.flashsid);
+}
+
+Uploader.prototype.PrepareFiles = function()
+{
+ var ids = '';
+ var names = '';
+ for (var f in this.files) {
+ if (isset(this.files[f].uploaded) && !isset(this.files[f].temp)) continue;
+ ids += this.files[f].id + '|'
+ names += this.files[f].name + '|'
+ }
+ ids = ids.replace(/\|$/, '', ids);
+ names = names.replace(/\|$/, '', names);
+ document.getElementById(this.id+'[tmp_ids]').value = ids;
+ document.getElementById(this.id+'[tmp_names]').value = names;
+ document.getElementById(this.id+'[tmp_deleted]').value = this.deleted.join('|');
+}
+
+
+Uploader.prototype.HasQueue = function()
+{
+ for (var f in this.files) {
+ if (isset(this.files[f].uploaded)) continue;
+ return true;
+ }
+ return false;
+}
+
+
+Uploader.prototype.StartUpload = function()
+{
+ if (!this.HasQueue()) return;
+
+ Request.setOpacity(30, Form.Div);
+
+ if (!document.all) {
+ var $winW = window.innerWidth;
+ var $winH = window.innerHeight;
+ }
+ else {
+ var $winW = window.document.body.offsetWidth;
+ var $winH = window.document.body.offsetHeight;
+ }
+
+ var left = Math.round(($winW - 350)/2)+'px';
+ var top = Math.round(($winH - 110)/2)+'px';
+
+ this.div.style.top = top;
+ this.div.style.left = left;
+ this.div.style.display = 'block';
+ Request.setOpacity(100, this.div);
+
+ this.StartTime = this.GetMicroTime();
+ this.ProgressPercent = 0; // progress percent
+ this.ProgressTime = new Array();
+
+ this.uploaded = 0;
+ this.total = 0;
+ for (var f in this.files) {
+ if (isset(this.files[f].uploaded)) continue;
+ this.total += this.files[f].size;
+ }
+
+ document.getElementById(this.flash_id).upload();
+}
+
+Uploader.prototype.GetMicroTime = function() {
+ var $now = new Date();
+ return Math.round($now.getTime() / 1000); // because miliseconds are returned too
+}
+Uploader.prototype.GetEstimatedTime = function() {
+ return Math.ceil((100 - this.ProgressPercent) * this.ProgressTime / this.ProgressPercent);
+}
+
+Uploader.prototype.FormatTime = function ($seconds) {
+ $seconds = parseInt($seconds);
+
+ var $minutes = Math.floor($seconds / 60);
+ if ($minutes < 10) $minutes = '0' + $minutes;
+ $seconds = $seconds % 60;
+ if ($seconds < 10) $seconds = '0' + $seconds;
+
+ return $minutes + ':' + $seconds;
+}
+
+Uploader.prototype.FormatSize = function (bytes) {
+ var kb = Math.round(bytes / 1024);
+ if (kb < 1024) return kb+'Kb';
+ var mb = Math.round(kb / 1024 * 100)/100;
+ return mb+'Mb';
+}
+
+Uploader.prototype.UploadFileStart = function(file, position, queuelength)
+{
+ this.filename.innerHTML = file.name;
+}
+
+Uploader.prototype.UploadProgress = function(file, bytesLoaded)
+{
+ this.cur_file_uploaded = bytesLoaded;
+
+ var uploaded = this.uploaded+this.cur_file_uploaded;
+ this.ProgressTime = this.GetMicroTime() - this.StartTime;
+
+ var speed = 0;
+ if (this.ProgressTime > 0) {
+ speed = Math.round(uploaded/this.ProgressTime*100)/100;
+ }
+
+ this.progress.innerHTML = this.FormatSize(uploaded)+' / '+this.FormatSize(this.total) + ' ('+this.FormatSize(speed)+'/s)';
+ this.ProgressPercent = Math.round(uploaded/this.total*100);
+ this.done.style.width = this.ProgressPercent+'%';
+ this.percent.innerHTML = this.ProgressPercent+'%';
+
+ this.elapsed.innerHTML = this.FormatTime(this.ProgressTime );
+ this.remaining.innerHTML = this.FormatTime( this.GetEstimatedTime() );
+}
+
+Uploader.prototype.UploadFileComplete = function(file)
+{
+ this.uploaded += this.cur_file_uploaded;
+ for (var f in this.files) {
+ if (this.files[f].id == file.id) {
+ this.files[f].uploaded = 1;
+ this.files[f].temp = 1;
+ this.files[f].url = this.params.tmp_url.replace('#ID#', file.id).replace('#FILE#', file.name).replace('#FIELD#', this.params.field);
+ }
+ }
+ this.UpdateInfo();
+}
+
+
+// MANAGER
+
+
+function UploadsManager() {
+ // hooking to standard toolbar select button to peform auto-upload when Save is clicked
+ if (isset(a_toolbar)) {
+ if (a_toolbar.ButtonExists('select')) {
+ var old_onclick = a_toolbar.Buttons['select'].onClick;
+ a_toolbar.Buttons['select'].onClick = function() {
+ UploadsManager.UploadAll(function() {old_onclick()});
+ }
+ }
+ }
+ addLoadEvent(function() {UploadsManager.InitAll()});
+}
+
+UploadsManager = new UploadsManager();
+UploadsManager.Uploaders = new Object();
+UploadsManager.nextId = 0;
+
+
+UploadsManager.NextFlashId = function()
+{
+ this.nextId++;
+ return 'uploaderflash'+this.nextId;
+}
+
+UploadsManager.AddUploader = function(id, params )
+{
+ this.Uploaders[id] = new Uploader(id, params);
+}
+
+UploadsManager.InitAll = function()
+{
+ for (var i in this.Uploaders) {
+ this.Uploaders[i].Init();
+ }
+}
+
+UploadsManager.FileSelected = function(file)
+{
+ var upl = this.Uploaders[file.uploader_id]
+ if (upl.files_count >= upl.params.multiple) {
+ if (upl.params.multiple > 1) {
+ alert('too many files');
+ upl.flash.cancelFile(file.id);
+ }
+ else {
+ upl.files_count++;
+ upl.files.push(file);
+ upl.total += file.size;
+ if (upl.files[0].uploaded) {
+ UploadsManager.DeleteFile(file.uploader_id, upl.files[0].name);
+ }
+ else {
+ upl.flash.cancelFile(upl.files[0].id);
+ }
+ }
+ }
+ else {
+ upl.files_count++;
+ upl.files.push(file);
+ upl.total += file.size;
+ }
+ upl.UpdateInfo();
+}
+
+UploadsManager.FileCancelled = function(file)
+{
+ this.Uploaders[file.uploader_id].RemoveFile(file);
+}
+
+UploadsManager.GetUploadScript = function(file)
+{
+ return this.Uploaders[file.uploader_id].GetUploadScript(file);
+}
+
+UploadsManager.UploadError = function(errno, file, msg)
+{
+ alert('error '+errno)
+ alert('Error: '+msg+' on file '+file.name);
+}
+
+UploadsManager.DeleteFile = function(mov, fname)
+{
+ if (!confirm('Are you sure you want to delete this file?')) return;
+ Request.makeRequest(
+ this.Uploaders[mov].deleteURL.replace('#FILE#', fname),
+ false, '',
+ function(req, fname, upl) {
+ upl.RemoveFile({id:fname})
+ upl.deleted.push(fname);
+ upl.UpdateInfo();
+ },
+ function(req, fname, upl) {alert('Error while deleting file')},
+ fname, this.Uploaders[mov]
+ );
+}
+
+
+UploadsManager.Browse = function(id)
+{
+ this.Uploaders[id].flash.browse()
+}
+
+UploadsManager.StartUpload = function(id)
+{
+ this.uploadCancelled = false;
+ this.Uploaders[id].StartUpload();
+}
+
+UploadsManager.CancelFile = function(id, file_id)
+{
+ this.Uploaders[id].flash.cancelFile(file_id)
+}
+
+UploadsManager.UploadAll = function(onAllUploaded)
+{
+ if (!this.HasQueue()) {
+ onAllUploaded();
+ return;
+ }
+ this.uploadCancelled = false;
+ for (var i in this.Uploaders) {
+ this.Uploaders[i].StartUpload();
+ }
+ this.OnAllUploaded = onAllUploaded;
+}
+
+UploadsManager.UploadFileStart = function(file, position, queuelength)
+{
+ this.Uploaders[file.uploader_id].UploadFileStart(file, position, queuelength);
+}
+
+UploadsManager.UploadProgress = function(file, bytesLoaded)
+{
+ this.Uploaders[file.uploader_id].UploadProgress(file, bytesLoaded);
+}
+
+UploadsManager.UploadFileComplete = function(file)
+{
+ this.Uploaders[file.uploader_id].UploadFileComplete(file);
+}
+
+UploadsManager.HasQueue = function()
+{
+ var has_queue = false;
+ for (var i in this.Uploaders) {
+ var tmp = this.Uploaders[i].HasQueue()
+ has_queue = has_queue || tmp;
+ }
+ return has_queue;
+}
+
+UploadsManager.UploadQueueComplete = function(file)
+{
+ Request.setOpacity(100, Form.Div);
+ var all_done = true;
+ for (var i in this.Uploaders) {
+ this.Uploaders[i].div.style.display='none';
+ all_done == all_done && !this.Uploaders[i].HasQueue();
+ }
+ if (all_done && isset(this.OnAllUploaded) && !this.uploadCancelled) {
+ this.OnAllUploaded();
+ }
+}
+
+UploadsManager.CancelUpload = function(mov)
+{
+ document.getElementById(mov+'_swf').cancelQueue();
+ this.uploadCancelled = true;
+}
\ No newline at end of file
Property changes on: trunk/core/admin_templates/js/uploader.js
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.1
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: trunk/core/admin_templates/js/ajax.js
===================================================================
--- trunk/core/admin_templates/js/ajax.js (revision 8173)
+++ trunk/core/admin_templates/js/ajax.js (revision 8174)
@@ -1,324 +1,325 @@
function preg_print_pre(obj, reg)
{
if (!reg) reg = /.*/;
var p = ''
for (var prop in obj) {
if (prop.match(reg) ) {
p += prop + ': '+obj[prop] + '\n'
}
}
alert(p)
}
// Main AJAX classs
function Request() {}
Request.timeout = 15000; //5 seconds
Request.method = 'GET';
Request.headers = new Array();
Request.params = null;
Request.makeRequest = function(p_url, p_busyReq, p_progId, p_successCallBack, p_errorCallBack, p_pass, p_object) {
//p_url: the web service url
//p_busyReq: is a request for this object currently in progress?
//p_progId: element id where progress HTML should be shown
//p_successCallBack: callback function for successful response
//p_errorCallBack: callback function for erroneous response
//p_pass: string of params to pass to callback functions
//p_object: object of params to pass to callback functions
if (p_busyReq) return;
var req = Request.getRequest();
if (req != null) {
p_busyReq = true;
Request.showProgress(p_progId);
req.onreadystatechange = function() {
if (req.readyState == 4) {
p_busyReq = false;
window.clearTimeout(toId);
try {
if (req.status == 200) {
// preg_print_pre(req)
p_successCallBack(req, p_pass, p_object);
} else {
p_errorCallBack(req, p_pass, p_object);
}
Request.hideProgress(p_progId);
}
catch (e) {
// alert('AJAX error')
}
}
}
var $ajax_mark = (p_url.indexOf('?') ? '&' : '?') + 'ajax=yes';
req.open(Request.method, p_url + $ajax_mark, true);
if (Request.method == 'POST') {
Request.headers['Content-type'] = 'application/x-www-form-urlencoded';
Request.headers['referer'] = p_url;
}
else {
Request.headers['If-Modified-Since'] = 'Sat, 1 Jan 2000 00:00:00 GMT';
}
Request.sendHeaders(req);
if (Request.method == 'POST') {
req.send(Request.params);
Request.method = 'GET'; // restore method back to GET
}
else {
req.send(null);
}
var toId = window.setTimeout( function() {if (p_busyReq) req.abort();}, Request.timeout );
}
}
Request.sendHeaders = function($request) {
for (var $header_name in Request.headers) {
$request.setRequestHeader($header_name, Request.headers[$header_name]);
}
Request.headers = new Array(); // reset header afterwards
}
Request.getRequest = function() {
var xmlHttp;
try { xmlHttp = new ActiveXObject('MSXML2.XMLHTTP'); return xmlHttp; } catch (e) {}
try { xmlHttp = new ActiveXObject('Microsoft.XMLHTTP'); return xmlHttp; } catch (e) {}
try { xmlHttp = new XMLHttpRequest(); return xmlHttp; } catch(e) {}
return null;
}
Request.showProgress = function(p_id) {
if (p_id != '') {
Request.setOpacity(20, p_id);
if (!document.getElementById(p_id + '_progress')) {
document.body.appendChild(Request.getProgressObject(p_id));
}
else {
var $progress_div = document.getElementById(p_id + '_progress');
$progress_div.style.top = getRealTop(p_id) + 'px';
$progress_div.style.height = document.getElementById(p_id).clientHeight;
$progress_div.style.display = 'block';
}
// document.getElementById(p_id).innerHTML = Request.getProgressHtml();
}
}
Request.hideProgress = function(p_id) {
if (p_id != '') {
document.getElementById(p_id + '_progress').style.display = 'none';
Request.setOpacity(100, p_id);
}
}
Request.setOpacity = function (opacity, id) {
- var object = document.getElementById(id).style;
+ var elem = typeof(id)=='string' ? document.getElementById(id) : id;
+ var object = elem.style;
object.opacity = (opacity / 100);
object.MozOpacity = (opacity / 100);
object.KhtmlOpacity = (opacity / 100);
object.filter = "alpha(opacity=" + opacity + ")";
}
Request.getProgressHtml = function() {
return "<p class='progress'>" + Request.progressText + "<br /><img src='img/ajax_progress.gif' align='absmiddle' width='100' height='7' alt='" + Request.progressText + "'/></p>";
}
Request.getProgressObject = function($id) {
var $div = document.createElement('DIV');
var $parent_div = document.getElementById($id);
$div.id = $id + '_progress';
$div.style.width = $parent_div.clientWidth + 'px';
$div.style.height = '150px'; // default height if div is empty (first ajax request for div)
$div.style.left = getRealLeft($parent_div) + 'px';
$div.style.top = getRealTop($parent_div) + 'px';
$div.style.position = 'absolute';
/*$div.style.border = '1px solid green';
$div.style.backgroundColor = '#FF0000';*/
$div.innerHTML = '<table style="width: 100%; height: 100%;"><tr><td style="text-align: center;">'+Request.progressText+'<br /><img src="img/ajax_progress.gif" align="absmiddle" width="100" height="7" alt="'+escape(Request.progressText)+'" /></td></tr></table>';
return $div;
}
Request.getErrorHtml = function(p_req) {
//TODO: implement accepted way to handle request error
return '[status: ' + p_req.status + '; status_text: ' + p_req.statusText + '; responce_text: ' + p_req.responseText + ']';
}
Request.serializeForm = function(theform) {
if (typeof(theform) == 'string') {
theform = document.getElementById(theform);
}
var els = theform.elements;
var len = els.length;
var queryString = '';
Request.addField = function(name, value) {
if (queryString.length > 0) queryString += '&';
queryString += encodeURIComponent(name) + '=' + encodeURIComponent(value);
};
for (var i = 0; i<len; i++) {
var el = els[i];
if (el.disabled) continue;
switch(el.type) {
case 'text':
case 'password':
case 'hidden':
case 'textarea':
Request.addField(el.name, el.value);
break;
case 'select-one':
if (el.selectedIndex >= 0) {
Request.addField(el.name, el.options[el.selectedIndex].value);
}
break;
case 'select-multiple':
for (var j = 0; j < el.options.length; j++) {
if (!el.options[j].selected) continue;
Request.addField(el.name, el.options[j].value);
}
break;
case 'checkbox':
case 'radio':
if (!el.checked) continue;
Request.addField(el.name,el.value);
break;
}
}
return queryString;
};
// AJAX ProgressBar classs
function AjaxProgressBar($url) {
this.WindowTitle = this.GetWindow().document.title;
this.URL = $url;
this.BusyRequest = false;
this.LastResponceTime = this.GetMicroTime();
this.ProgressPercent = 0; // progress percent
this.ProgressTime = new Array();
this.Query();
}
AjaxProgressBar.prototype.GetWindow = function() {
return window.parent ? window.parent : window;
}
AjaxProgressBar.prototype.GetMicroTime = function() {
var $now = new Date();
return Math.round($now.getTime() / 1000); // because miliseconds are returned too
}
AjaxProgressBar.prototype.Query = function() {
// prompt('requestinng', this.URL);
Request.makeRequest(this.URL, this.BusyRequest, '', this.successCallback, this.errorCallback, '', this);
}
// return time needed for progress to finish
AjaxProgressBar.prototype.GetEstimatedTime = function() {
return Math.ceil((100 - this.ProgressPercent) * Math.sum(this.ProgressTime) / this.ProgressPercent);
}
AjaxProgressBar.prototype.successCallback = function($request, $params, $object) {
var $responce = $request.responseText;
var $match_redirect = new RegExp('^#redirect#(.*)').exec($responce);
if ($match_redirect != null) {
$object.showProgress(100);
// redirect to external template requested
window.location.href = $match_redirect[1];
return false;
}
if ($object.showProgress($responce)) {
$object.Query();
}
}
AjaxProgressBar.prototype.errorCallback = function($request, $params, $object) {
alert('AJAX Error; class: AjaxProgressBar; ' + Request.getErrorHtml($request));
}
AjaxProgressBar.prototype.FormatTime = function ($seconds) {
$seconds = parseInt($seconds);
var $minutes = Math.floor($seconds / 60);
if ($minutes < 10) $minutes = '0' + $minutes;
$seconds = $seconds % 60;
if ($seconds < 10) $seconds = '0' + $seconds;
return $minutes + ':' + $seconds;
}
AjaxProgressBar.prototype.showProgress = function ($percent) {
this.ProgressPercent = $percent;
var $now = this.GetMicroTime();
this.ProgressTime[this.ProgressTime.length] = $now - this.LastResponceTime;
this.LastResponceTime = $now;
var $display_progress = parseInt(this.ProgressPercent);
this.GetWindow().document.title = $display_progress + '% - ' + this.WindowTitle;
document.getElementById('progress_display[percents_completed]').innerHTML = $display_progress + '%';
document.getElementById('progress_display[elapsed_time]').innerHTML = this.FormatTime( Math.sum(this.ProgressTime) );
document.getElementById('progress_display[Estimated_time]').innerHTML = this.FormatTime( this.GetEstimatedTime() );
document.getElementById('progress_bar[done]').style.width = $display_progress + '%';
document.getElementById('progress_bar[left]').style.width = (100 - $display_progress) + '%';
return $percent < 100 ? true : false;
}
// AJAX PopupManager class
function AjaxPopupManager($url) {
this.URL = $url;
this.ResponceFunction = null;
this.PopupSizes = new Array();
}
AjaxPopupManager.prototype.GetSize = function ($template) {
if (this.ResponceFunction == null) {
alert ('Please define responce function first (type: '+typeof(this.ResponceFunction)+')');
}
if (!isset(this.PopupSizes[$template])) {
var $url = this.URL + '&type=GetPopupSize&template_name=' + $template;
// alert('from ajax: '+$url);
Request.makeRequest($url, this.BusyRequest, '', this.successCallback, this.errorCallback, ['GetSize', $template], this);
}
else {
// alert('from cache');
this.ResponceFunction(this.PopupSizes[$template]);
}
}
AjaxPopupManager.prototype.successCallback = function($request, $params, $object) {
var $responce = $request.responseText;
var $match_redirect = new RegExp('^#redirect#(.*)').exec($responce);
if ($match_redirect != null) {
// redirect to external template requested
window.location.href = $match_redirect[1];
return false;
}
switch ($params[0]) {
case 'GetSize':
// store responce to cache for future use
$object.PopupSizes[ $params[1] ] = $responce;
break;
}
$object.ResponceFunction($responce);
$object.ResponceFunction = null; // reset responce function
}
AjaxPopupManager.prototype.errorCallback = function($request, $params, $object) {
alert('AJAX Error; class: AjaxPopupManager; ' + Request.getErrorHtml($request));
}
\ No newline at end of file
Property changes on: trunk/core/admin_templates/js/ajax.js
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.3
\ No newline at end of property
+1.4
\ No newline at end of property
Index: trunk/core/admin_templates/js/swfobject.js
===================================================================
--- trunk/core/admin_templates/js/swfobject.js (nonexistent)
+++ trunk/core/admin_templates/js/swfobject.js (revision 8174)
@@ -0,0 +1,8 @@
+/**
+ * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
+ *
+ * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
+ * http://www.opensource.org/licenses/mit-license.php
+ *
+ */
+if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;
\ No newline at end of file
Property changes on: trunk/core/admin_templates/js/swfobject.js
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.1
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: trunk/core/admin_templates/js/forms.js
===================================================================
--- trunk/core/admin_templates/js/forms.js (revision 8173)
+++ trunk/core/admin_templates/js/forms.js (revision 8174)
@@ -1,134 +1,132 @@
var last_shown_error = false;
var errors = new Object();
var first_error = new Object();
var fields = new Object();
function show_form_error(prefix, field, sticky)
{
if (isset(errors[prefix]) && isset(errors[prefix][field])) {
span = document.getElementById('error_msg_'+prefix);
span.innerHTML = fields[prefix][field] + ' - ' + errors[prefix][field];
if (sticky) last_shown_error = field;
}
}
function hide_form_error(prefix)
{
span = document.getElementById('error_msg_'+prefix);
if (!span) return;
span.innerHTML = '<br/>';
if (typeof(last_shown_error) != 'undefined' && last_shown_error) {
show_form_error(prefix, last_shown_error);
}
}
function add_form_error(prefix, field, element, error_msg) {
if (error_msg != '') {
if (typeof(errors[prefix]) == 'undefined') {
errors[prefix] = new Object();
}
errors[prefix][field] = error_msg;
addEvent(document.getElementById(element), 'focus', function() {
show_form_error(prefix, field, true)
} );
addEvent(document.getElementById(element), 'blur', function() {last_shown_error = false} )
if (typeof(first_error[prefix]) == 'undefined' || first_error[prefix] == false) {
first_error[prefix] = [field, element];
}
}
}
function Form() {}
Form = new Form();
Form.Controls = new Array();
Form.Div = false;
Form.MinControlsHeight = 0;
Form.Coeffs = new Object();
Form.ScrollerW = 17;
Form.ScrollerH = 17;
Form.Wrap = true;
Form.Init = function(id)
{
this.Div = document.getElementById(id);
for (var i in this.Controls) {
dim = getDimensions(document.getElementById(this.Controls[i]));
this.MinControlsHeight += dim.innerHeight;
// alert('adding element '+this.Controls[i]+' height: '+dim.innerHeight+' total: '+this.MinControlsHeight)
}
document.body.style.height = '100%';
document.body.style.overflow = 'hidden';
document.body.scroll = 'no'
var a_div = document.createElement('DIV');
a_div.style.position = 'relative';
a_div.style.overflow = 'auto';
a_div.style.width = '100%';
a_div.style.height = '100%';
a_div.appendChild(el.parentNode.replaceChild(a_div, el))
this.Table = this.Div.getElementsByTagName('table')[0];
this.Table.style.height = 'auto';
this.MinHeight = this.Table.offsetHeight;
this.MinWidth = this.Table.offsetWidth;
addEvent(window, 'resize', function() {Form.Resize()})
this.Resize()
if (isset(first_error)) {
for (var i in first_error) {
if (first_error[i] != false) {
document.getElementById(first_error[i][1]).focus();
show_form_error(i, first_error[i][0], true);
// alert('focused on '+first_error[i][1])
}
}
}
}
Form.addControl = function(id, coeff) {
this.Controls.push(id);
this.Coeffs[id] = coeff ? coeff : 1; // for future use
}
Form.Resize = function()
{
var h = (document.all ? window.document.body.offsetHeight : window.innerHeight);
var pos = findPos(el);
var dim = getDimensions(this.Div);
h -= pos[1] + dim.padding[0] + dim.padding[2] + dim.borders[0] + dim.borders[2];
var w = (document.all ? window.document.body.offsetWidth : window.innerWidth);
w -= pos[0] + dim.padding[1] + dim.padding[3] + dim.borders[1] + dim.borders[3];
scroller_height = this.MinWidth >= w ? this.ScrollerH : 0;
scroller_width = this.MinHeight >= h - scroller_height ? this.ScrollerW : 0;
scroller_height = this.MinWidth >= w - scroller_width ? this.ScrollerH : 0;
// alert('resize: '+w+'x'+h)
this.Table.style.width = (w-scroller_width) + 'px';
this.Div.style.width = (w)+'px';
this.Div.style.height = (h)+'px';
var count = this.Controls.length;
// -count here is adjustment - 1px for each control
var split = h - count - this.MinHeight + this.MinControlsHeight;
if (split < this.MinControlsHeight) split = this.MinControlsHeight;
var new_height = Math.round(split / count) -2;
// alert('h is: '+h+' min height is '+this.MinHeight+' MinControlsHeight is '+this.MinControlsHeight+' -> '+split+' to split between '+count+' new height is '+new_height);
// print_pre(this.Controls)
for (var i in this.Controls) {
document.getElementById(this.Controls[i]).style.height = new_height + 'px';
}
-
-
}
Property changes on: trunk/core/admin_templates/js/forms.js
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.2
\ No newline at end of property
+1.3
\ No newline at end of property

Event Timeline