From 9331570ce4db0b87335cbf4d29a78483b7df4d17 Mon Sep 17 00:00:00 2001 From: Olle Haerstedt Date: Wed, 23 Mar 2016 16:28:27 +0100 Subject: [PATCH] Dev: Remove unused code related to file-upload pop-up --- scripts/modaldialog.js | 69 ++---------------------------------------- scripts/uploader.js | 21 ++----------- 2 files changed, 5 insertions(+), 85 deletions(-) diff --git a/scripts/modaldialog.js b/scripts/modaldialog.js index 3d464488919..b7c3b533b57 100644 --- a/scripts/modaldialog.js +++ b/scripts/modaldialog.js @@ -1,9 +1,12 @@ $(function() { openUploadModalDialog(); }); + function openUploadModalDialog(){ $('.upload').click(function(e) { + e.preventDefault(); + var $this = $(this); var show_title = getQueryVariable('show_title', this.href); var show_comment = getQueryVariable('show_comment', this.href); @@ -37,74 +40,8 @@ function openUploadModalDialog(){ } return pass; }); - - $('#uploader-div').dialog({ - title: uploadLang.title, - autoOpen: true, - width: dialogwidth, - height: 'auto', - open: function( event, ui ) { - $('#uploader-div').removeClass('hidden'); - setWidthUploader(); - }, - modal: true, - resizable: false, - autoResize: false, - draggable: true, - closeOnEscape: false, - dialogClass: "dialog-upload", - beforeClose: function() { - var pass; - if(document.getElementById('uploader').contentDocument) { - if(document.getElementById('uploader').contentDocument.defaultView) - { /*Firefox*/ - pass=document.getElementById('uploader').contentDocument.defaultView.saveAndExit(fieldname,show_title,show_comment,pos); - }else{ /*IE8*/ - pass=document.getElementById('uploader').contentWindow.saveAndExit(fieldname,show_title,show_comment,pos); - } - }else{ /*IE6*/ - pass=document.getElementById('uploader').contentWindow.saveAndExit(fieldname,show_title,show_comment,pos); - } - return pass; - }, - overlay: { - opacity: 0.85, - background: 'black' - }, - buttons: buttonsOpts, - close: function( ) { - checkconditions(); - }, - create: function() { - // Add Bootstrap class to button - $('.ui-dialog-buttonset button').addClass('btn btn-default'); - - // Remove borders - // TODO: Use this instead? http://plugins.krajee.com/file-input - $('.ui-widget-content').css('border', 'none'); - } - }); }); } -$(window).resize(function() { - setWidthUploader(); - if(typeof $("iframe#uploader")[0]!=="undefined" && jQuery.isFunction($("iframe#uploader")[0].contentWindow.fixParentHeigth)) - $("iframe#uploader")[0].contentWindow.fixParentHeigth(); -}); -/* Reset the position of the dialog (recenter) */ -function resetUploaderPosition(){ - //$( "#uploader" ).dialog( "option", "position", $( "#uploader" ).dialog( "option", "position" ) ); - -} -/* Set the with of upload madal and uploader frame according to windows width */ -function setWidthUploader(){ - //var maxwidth=Math.min($("body").innerWidth()-4, 974); - //if(maxwidth!=$( "#uploader" ).dialog( "option", "width" )){ - //$("#uploader").dialog( "option", "width", maxwidth).width(maxwidth-18) // Leave 20px for overflow - //} - $('#uploader').css('width', '100%'); - resetUploaderPosition(); -} function getQueryVariable(variable, url) { var vars = url.split("/"); diff --git a/scripts/uploader.js b/scripts/uploader.js index 887cecbb3d5..5c67707df84 100644 --- a/scripts/uploader.js +++ b/scripts/uploader.js @@ -1,18 +1,7 @@ $(document).ready(function(){ doFileUpload(); - fixParentHeigth(); }); -function fixParentHeigth() -{ - if(window != top) - { - frameheight=Math.max($('html').outerHeight()+30,150); - $(parent.jQuery.find('#uploader')).css("height",frameheight+"px"); - if(jQuery.isFunction(parent.resetUploaderPosition)) - parent.resetUploaderPosition(); - } -} function doFileUpload(){ var fieldname = $('#ia').val(); @@ -37,7 +26,7 @@ function doFileUpload(){ var previewblock = "
  • "; previewblock +="
    "; if (isValueInArray(image_extensions, json[i-1].ext.toLowerCase())) - previewblock += ""; + previewblock += ""; else previewblock += "
    "; previewblock += ""+decodeURIComponent(json[i-1].name)+""; @@ -69,7 +58,6 @@ function doFileUpload(){ // add file to the list $('#field'+fieldname+'_listfiles').append(previewblock); - fixParentHeigth(); } } @@ -98,7 +86,6 @@ function doFileUpload(){ if (filecount >= maxfiles) { $('#notice').html('

    '+uploadLang.errorNoMoreFiles+'

    '); - fixParentHeigth(); return false; } @@ -118,7 +105,6 @@ function doFileUpload(){ if (allowSubmit == false) { $('#notice').html('

    '+uploadLang.errorOnlyAllowed.replace('%s',$('#'+fieldname+'_allowed_filetypes').val())+'

    '); - fixParentHeigth(); return false; } @@ -165,7 +151,7 @@ function doFileUpload(){ previewblock +="
    "; if (isValueInArray(image_extensions, metadata.ext.toLowerCase())) - previewblock += ""; + previewblock += ""; else previewblock += "
    "; previewblock += ""+decodeURIComponent(metadata.name)+""; @@ -211,12 +197,10 @@ function doFileUpload(){ if (filecount >= maxfiles) $('#notice').html('

    '+uploadLang.errorTooMuch+'

    '); - fixParentHeigth(); } else { $('#notice').html('

    '+metadata.msg+'

    '); - fixParentHeigth(); } } @@ -334,7 +318,6 @@ function deletefile(fieldname, count) { $('#uploadstatus').html(uploadLang.errorNeedMore.replace('%s',(minfiles - filecount))); else $('#uploadstatus').html(uploadLang.errorMoreAllowed.replace('%s',(maxfiles - filecount))); - fixParentHeigth(); }); }