Skip to content

Commit

Permalink
Dev: Remove unused code related to file-upload pop-up
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt committed Mar 23, 2016
1 parent 448c1e0 commit 9331570
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 85 deletions.
69 changes: 3 additions & 66 deletions 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);
Expand Down Expand Up @@ -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("/");
Expand Down
21 changes: 2 additions & 19 deletions 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();

Expand All @@ -37,7 +26,7 @@ function doFileUpload(){
var previewblock = "<li id='"+fieldname+"_li_"+i+"' class='previewblock file-element'>";
previewblock +="<div class='file-preview'>";
if (isValueInArray(image_extensions, json[i-1].ext.toLowerCase()))
previewblock += "<img src='"+uploadurl+"/filegetcontents/"+json[i-1].filename+"' onload='fixParentHeigth()' class='uploaded' />";
previewblock += "<img src='"+uploadurl+"/filegetcontents/"+json[i-1].filename+"' class='uploaded' />";
else
previewblock += "<div class='upload-placeholder' />";
previewblock += "<span class='file-name'>"+decodeURIComponent(json[i-1].name)+"</span>";
Expand Down Expand Up @@ -69,7 +58,6 @@ function doFileUpload(){

// add file to the list
$('#field'+fieldname+'_listfiles').append(previewblock);
fixParentHeigth();
}
}

Expand Down Expand Up @@ -98,7 +86,6 @@ function doFileUpload(){
if (filecount >= maxfiles)
{
$('#notice').html('<p class="alert alert-danger fa fa-exclamation-circle">'+uploadLang.errorNoMoreFiles+'</p>');
fixParentHeigth();
return false;
}

Expand All @@ -118,7 +105,6 @@ function doFileUpload(){
if (allowSubmit == false)
{
$('#notice').html('<p class="alert alert-danger fa fa-exclamation-circle">'+uploadLang.errorOnlyAllowed.replace('%s',$('#'+fieldname+'_allowed_filetypes').val())+'</p>');
fixParentHeigth();
return false;
}

Expand Down Expand Up @@ -165,7 +151,7 @@ function doFileUpload(){

previewblock +="<div class='file-preview'>";
if (isValueInArray(image_extensions, metadata.ext.toLowerCase()))
previewblock += "<img src='"+uploadurl+"/filegetcontents/"+decodeURIComponent(metadata.filename)+"' onload='fixParentHeigth()' class='uploaded' />";
previewblock += "<img src='"+uploadurl+"/filegetcontents/"+decodeURIComponent(metadata.filename)+"' class='uploaded' />";
else
previewblock += "<div class='upload-placeholder' />";
previewblock += "<span class='file-name'>"+decodeURIComponent(metadata.name)+"<span>";
Expand Down Expand Up @@ -211,12 +197,10 @@ function doFileUpload(){

if (filecount >= maxfiles)
$('#notice').html('<p class="alert alert-success fa fa-check">'+uploadLang.errorTooMuch+'</p>');
fixParentHeigth();
}
else
{
$('#notice').html('<p class="alert alert-danger fa fa-exclamation-circle">'+metadata.msg+'</p>');
fixParentHeigth();
}

}
Expand Down Expand Up @@ -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();
});
}

Expand Down

0 comments on commit 9331570

Please sign in to comment.