diff --git a/src/sunstone/public/js/plugins/images-tab.js b/src/sunstone/public/js/plugins/images-tab.js index f8ea5c77a1..d09bfe3be9 100644 --- a/src/sunstone/public/js/plugins/images-tab.js +++ b/src/sunstone/public/js/plugins/images-tab.js @@ -866,26 +866,20 @@ function enable_all_datastores() } // Prepare the image creation dialog -function setupCreateImageDialog(){ +function setupCreateImageDialog(dialog){ dialogs_context.append('
'); $create_image_dialog = $('#create_image_dialog',dialogs_context); var dialog = $create_image_dialog; dialog.html(create_image_tmpl); - setupTips($create_image_dialog); - - var height = Math.floor($(window).height()*0.8); //set height to a percentage of the window - - //Prepare jquery dialog - //dialog.dialog({ - // autoOpen: false, - // modal:true, - // width: 520, - // height: height - //}); dialog.addClass("reveal-modal large max-height"); + initialize_create_image_dialog(dialog); +} + +function initialize_create_image_dialog(dialog) { + setupTips(dialog); $('.advanced',dialog).hide(); $('#advanced_image_create',dialog).click(function(){ @@ -893,32 +887,24 @@ function setupCreateImageDialog(){ return false; }); - //$('#img_tabs',dialog).tabs(); - //$('button',dialog).button(); - //$('#datablock_img',dialog).attr('disabled','disabled'); - - $('select#img_type',dialog).change(function(){ var value = $(this).val(); - var context = $create_image_dialog; + var context = dialog; switch (value){ case "DATABLOCK": $('#datablock_img',context).removeAttr("disabled"); - //$('#empty_datablock', context).show(); break; default: $('#datablock_img',context).attr('disabled','disabled'); - //$('#empty_datablock', context).hide(); $('#path_img',context).click(); } }); - $('#img_path,#img_fstype,#img_size,#file-uploader',dialog).closest('.row').hide(); $("input[name='src_path']", dialog).change(function(){ - var context = $create_image_dialog; + var context = dialog; var value = $(this).val(); switch (value){ case "path": @@ -942,8 +928,8 @@ function setupCreateImageDialog(){ $('#add_custom_var_image_button', dialog).click( function(){ - var name = $('#custom_var_image_name',$create_image_dialog).val(); - var value = $('#custom_var_image_value',$create_image_dialog).val(); + var name = $('#custom_var_image_name',dialog).val(); + var value = $('#custom_var_image_value',dialog).val(); if (!name.length || !value.length) { notifyError(tr("Custom attribute name and value must be filled in")); return false; @@ -951,14 +937,14 @@ function setupCreateImageDialog(){ option= ''; - $('select#custom_var_image_box',$create_image_dialog).append(option); + $('select#custom_var_image_box',dialog).append(option); return false; } ); $('#remove_custom_var_image_button', dialog).click( function(){ - $('select#custom_var_image_box :selected',$create_image_dialog).remove(); + $('select#custom_var_image_box :selected',dialog).remove(); return false; } ); @@ -966,9 +952,7 @@ function setupCreateImageDialog(){ $('#upload-progress',dialog).css({ border: "1px solid #AAAAAA", position: "relative", -// bottom: "29px", width: "258px", -// left: "133px", height: "15px", display: "inline-block" }); @@ -978,7 +962,7 @@ function setupCreateImageDialog(){ // Upload is handled by FileUploader vendor plugin var uploader = new qq.FileUploaderBasic({ - button: $('#file-uploader',$create_image_dialog)[0], + button: $('#file-uploader',dialog)[0], action: 'upload', multiple: false, params: {}, @@ -987,35 +971,11 @@ function setupCreateImageDialog(){ //notifyMessage(message); }, onSubmit: function(id, fileName){ - //set url params - //since the body is the upload, we need the pass - //the image info here uploader.setParams({ img : JSON.stringify(img_obj), file: fileName }); - //we pop up an upload progress dialog - //var pos_top = $(window).height() - 120; - //var pos_left = 220; - //var pb_dialog = $('