package/ui/phpvirtualbox/js/utils.js
/**
 * Generate progress list element and append it
 * 
 * @param {Object} prequest - progress operation request object
 * @param {String} icon - URL of image to display on progress operation dialog (optional)
 * @param {String} title - title of progress operation dialog (optional)
 * @param {String} target - contextual target of progress operation
 * @param {Function} callback - function to run on progress completion
 * @see vboxconnector::progressGet()
 */
Generate progress list element and append it


Generate progress list element and append it
function vboxProgressCreateListElement(prequest,icon,title,target,callback) {
	var pid = prequest.progress;
	var div = $('<div />').attr({'id':'vboxProgress'+pid}).addClass('vboxProgressOpElement');
	var divOpTitle = $('<div />').addClass('vboxProgressOpTitle');
	if(icon) {
		$('<img />').attr({'src':'images/vbox/'+icon,'height':'16','width':'16'}).appendTo(divOpTitle);
	}
	if($('#vboxPane').data('vboxConfig').servers.length) {
		title = $('#vboxPane').data('vboxConfig').name + ': ' + title;		
	}
	$(divOpTitle).append(title + (target ? ' (' + target + ')' : '')).appendTo(div);
	$('<div />').addClass('vboxProgressBarContainer').append(
			$('<div />').attr({'id':'vboxProgressBar'+pid}).progressbar({ value: 1 })
	).appendTo(div);
	$('<div />').addClass('vboxProgressOpText').append(
			$('<span />').attr({'id':'vboxProgressText'+pid}).html('<img src="images/spinner.gif" height=12 width=12/>')
	).appendTo(div);
	$('<div />').addClass('vboxProgressOpCancel').append(
			$('<input />').attr({'id':'vboxProgressCancel'+pid,'type':'button'}).val(trans('Cancel','UIProgressDialog')).data({'pid':pid})
				.click(function(){
					this.disabled = 'disabled';
					vboxAjaxRequest('progressCancel',prequest);
				})
				.css({'margin':'0px'})
	).appendTo(div);
	$(div).data({'vboxCallback':callback})
	if($('#vboxProgressPlaceholder'+pid)[0]) {
		$('#vboxProgressPlaceholder'+pid).replaceWith(div);
	} else {
	    $('#vboxProgressOps').prepend(div);		
	}
}
function vboxProgressCreateListElement ( prequest , icon , title , target , callback ) { var pid = prequest . progress ; var div = $ ( '<div />' ) . attr ( { 'id' : 'vboxProgress' + pid } ) . addClass ( 'vboxProgressOpElement' ) ; var divOpTitle = $ ( '<div />' ) . addClass ( 'vboxProgressOpTitle' ) ; if ( icon ) { $ ( '<img />' ) . attr ( { 'src' : 'images/vbox/' + icon , 'height' : '16' , 'width' : '16' } ) . appendTo ( divOpTitle ) ; } if ( $ ( '#vboxPane' ) . data ( 'vboxConfig' ) . servers . length ) { title = $ ( '#vboxPane' ) . data ( 'vboxConfig' ) . name + ': ' + title ; } $ ( divOpTitle ) . append ( title + ( target ? ' (' + target + ')' : '' ) ) . appendTo ( div ) ; $ ( '<div />' ) . addClass ( 'vboxProgressBarContainer' ) . append ( $ ( '<div />' ) . attr ( { 'id' : 'vboxProgressBar' + pid } ) . progressbar ( { value : 1 } ) ) . appendTo ( div ) ; $ ( '<div />' ) . addClass ( 'vboxProgressOpText' ) . append ( $ ( '<span />' ) . attr ( { 'id' : 'vboxProgressText' + pid } ) . html ( '<img src="images/spinner.gif" height=12 width=12/>' ) ) . appendTo ( div ) ; $ ( '<div />' ) . addClass ( 'vboxProgressOpCancel' ) . append ( $ ( '<input />' ) . attr ( { 'id' : 'vboxProgressCancel' + pid , 'type' : 'button' } ) . val ( trans ( 'Cancel' , 'UIProgressDialog' ) ) . data ( { 'pid' : pid } ) . click ( function ( ) { this . disabled = 'disabled' ; vboxAjaxRequest ( 'progressCancel' , prequest ) ; } ) . css ( { 'margin' : '0px' } ) ) . appendTo ( div ) ; $ ( div ) . data ( { 'vboxCallback' : callback } ) if ( $ ( '#vboxProgressPlaceholder' + pid ) [ 0 ] ) { $ ( '#vboxProgressPlaceholder' + pid ) . replaceWith ( div ) ; } else { $ ( '#vboxProgressOps' ) . prepend ( div ) ; } }
Generate progress list element and append it
Generate progress list element and append it
// Shorthand
 // Title
 // Progress bar
 // Progress text
 // Cancel button
