Skip to content

Commit

Permalink
Dev: Fixed again #07261: Internet Explorer: short free text not acces…
Browse files Browse the repository at this point in the history
…sible after file upload

Dev: Add condirm dialog at close
Dev: beforeClose test if minfiles is OK, then no need to do it in button
Dev: remove iframe before new one : then only one function ...
Dev: use showpopups option for javascript confirm
  • Loading branch information
Shnoulle committed Mar 22, 2013
1 parent a533ae8 commit 97ff9d0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 84 deletions.
22 changes: 11 additions & 11 deletions application/controllers/UploaderController.php
Expand Up @@ -245,18 +245,8 @@ function run($actionID)
var fieldname = "'.$param['fieldname'].'";
var questgrppreview = '.$param['preview'].';
</script>';
$meta .='<script type="text/javascript" src="'.Yii::app()->getConfig("generalscripts").'/ajaxupload.js"></script>
<script type="text/javascript" src="'.Yii::app()->getConfig("generalscripts").'/uploader.js"></script>
<link type="text/css" href="'.Yii::app()->getConfig("publicstyleurl").'uploader.css" rel="stylesheet" />';

$clang = Yii::app()->lang;

$header = getHeader($meta);

echo $header;

echo "<script type='text/javascript'>
var translt = {
translt = {
titleFld: '" . $clang->gT('Title','js') . "',
commentFld: '" . $clang->gT('Comment','js') . "',
errorNoMoreFiles: '" . $clang->gT('Sorry, no more files can be uploaded!','js') . "',
Expand All @@ -269,7 +259,17 @@ function run($actionID)
errorTooMuch: '" . $clang->gT('The maximum number of files has been uploaded. You may return back to survey.','js') . "',
errorNeedMoreConfirm: '" . $clang->gT("You need to upload %s more files for this question.\nAre you sure you want to exit?",'js') . "'
};
showpopups=".Yii::app()->getConfig("showpopups").";
</script>\n";
$meta .='<script type="text/javascript" src="'.Yii::app()->getConfig("generalscripts").'/ajaxupload.js"></script>
<script type="text/javascript" src="'.Yii::app()->getConfig("generalscripts").'/uploader.js"></script>
<link type="text/css" href="'.Yii::app()->getConfig("publicstyleurl").'uploader.css" rel="stylesheet" />';

$clang = Yii::app()->lang;

$header = getHeader($meta);

echo $header;

$fn = $param['fieldname'];
$qid = $param['qid'];
Expand Down
78 changes: 7 additions & 71 deletions scripts/modaldialog.js
Expand Up @@ -15,74 +15,13 @@ $(document).ready(function() {
var fieldname = getQueryVariable('fieldname', this.href);
var buttonsOpts = {};
buttonsOpts[translt.returnTxt] = function() {
// Fix for the IE bug 04965
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);
}
if (pass) {
$('iframe#uploader').remove();
$(this).dialog('destroy').remove();
checkconditions();
}
$(this).dialog("close");
};

var horizontalPadding = 30;
var verticalPadding = 20;
$('#uploader').dialog('destroy'); // destroy the old modal dialog

if ($('#uploader').length > 0)
{

$('iframe#uploader', parent.document).dialog({
title: translt.title,
autoOpen: true,
width: 984,
height: 440,
modal: true,
resizable: true,
autoResize: true,
draggable: true,
closeOnEscape: false,
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);
}
if (pass) {
$('iframe#uploader').remove();
$(this).dialog('destroy').remove();
checkconditions();
}
return true;

},
overlay: {
opacity: 0.85,
background: 'black'
},
buttons: buttonsOpts
}).width(984 - horizontalPadding).height(440 - verticalPadding);
}
else
{
$('<iframe id=\"uploader\" name=\"uploader\" class=\"externalSite\" src=\"' + this.href + '\" />').dialog({
$('#uploader').dialog('destroy').remove(); // destroy the old modal dialog
$('<iframe id=\"uploader\" name=\"uploader\" class=\"externalSite\" src=\"' + this.href + '\" />').dialog({
title: translt.title,
autoOpen: true,
width: 984,
Expand All @@ -104,20 +43,17 @@ $(document).ready(function() {
}else{ /*IE6*/
pass=document.getElementById('uploader').contentWindow.saveAndExit(fieldname,show_title,show_comment,pos);
}
if (pass) {
$('iframe#uploader').remove();
$(this).dialog('destroy');
checkconditions();
}
return pass;
},
overlay: {
opacity: 0.85,
background: 'black'
},
buttons: buttonsOpts
buttons: buttonsOpts,
close: function( ) {
checkconditions();
}
}).width(984 - horizontalPadding).height(440 - verticalPadding);
}
});
});

Expand Down
5 changes: 3 additions & 2 deletions scripts/uploader.js
Expand Up @@ -228,9 +228,10 @@ function passJSON(fieldname, show_title, show_comment, pos) {
function saveAndExit(fieldname, show_title, show_comment, pos) {
var filecount = parseInt($('#'+fieldname+'_filecount').val());
var minfiles = parseInt($('#'+fieldname+'_minfiles').val());
if (minfiles != 0 && filecount < minfiles)

if (minfiles != 0 && filecount < minfiles && showpopups)
{
var confirmans = confirm(translt.errorNeedMore.replace('%s', (minfiles - filecount)))
var confirmans = confirm(translt.errorNeedMoreConfirm.replace('%s', (minfiles - filecount)))
if (confirmans)
{
passJSON(fieldname, show_title, show_comment, pos);
Expand Down

0 comments on commit 97ff9d0

Please sign in to comment.