Commit 1778d6d1 authored by Alan McNatty's avatar Alan McNatty
Browse files

Merge branch 'master' of git://gitorious.org/mahara/mahara

parents 73689206 5ccbb142
......@@ -107,6 +107,10 @@ function pieform_element_filebrowser(Pieform $form, $element) {
$smarty->assign('agreementtext', get_string('uploadcopyrightdefaultcontent', 'install'));
}
}
else if (!isset($config['simpleupload'])) {
$config['simpleupload'] = 1;
}
if ($config['upload']) {
$maxuploadsize = display_size(get_max_upload_size(!$institution && !$group));
$smarty->assign('maxuploadsize', $maxuploadsize);
......
......@@ -70,6 +70,16 @@ function FileBrowser(idprefix, folderid, config, globalconfig) {
'value':0
}));
}
if (is_FF() && self.config.select && !$(self.id + '_uploadsubmit') && $(self.id + '_uploadsubmit_container')) {
var submitbutton = INPUT({
'class': 'submit',
'type': 'submit',
'name': self.id + '_uploadsubmit',
'value': get_string('upload')
});
appendChildNodes(self.id + '_uploadsubmit_container', submitbutton);
self.config.submitbutton = true;
}
self.upload_connectbuttons();
}
......@@ -85,7 +95,15 @@ function FileBrowser(idprefix, folderid, config, globalconfig) {
}
});
}
if (self.config.submitbutton && $(self.id + '_uploadsubmit')) {
connect(self.id + '_uploadsubmit', 'onclick', self.upload_submit);
}
else {
connect(self.id + '_userfile', 'onchange', self.upload_submit);
if ($(self.id + '_uploadsubmit')) {
removeElement(self.id + '_uploadsubmit');
}
}
}
this.upload_validate = function () {
......@@ -128,7 +146,9 @@ function FileBrowser(idprefix, folderid, config, globalconfig) {
'name':'userfile',
'size':40
}));
if (!$(self.id + '_uploadsubmit')) {
connect(self.id + '_userfile', 'onchange', self.upload_submit);
}
$(self.id + '_upload').value = 0;
return false;
}
......
......@@ -133,6 +133,7 @@ class PluginArtefactFile extends PluginArtefact {
'maxuploadsize',
'nametoolong',
'namefieldisrequired',
'upload',
'uploadingfiletofolder',
'youmustagreetothecopyrightnotice',
),
......
......@@ -38,6 +38,9 @@
<table id="{$prefix}_upload_container" class="fileupload{if $tabs && !$tabs.upload} hidden{/if}">
<tbody>
{if $config.upload}
{* config.uploadagreement: disable the file chooser unless the agreement is checked *}
{* config.simpleupload: the form only contains a file chooser *}
{* config.submitbutton: add submit button even if js is enabled & don't start uploading as soon as a file is chosen *}
<input type="hidden" name="{$prefix}_uploadnumber" id="{$prefix}_uploadnumber" value="1" />
<input type="hidden" name="MAX_FILE_SIZE" value="{$phpmaxfilesize}" />
<tr><td colspan=2 id="{$prefix}_upload_messages"></td></tr>
......@@ -49,24 +52,24 @@
{$agreementtext|clean_html|safe}
</td>
</tr>
{/if}
<tr class="uploadform">
<th><label>{str tag='File' section='artefact.file'}</label></th>
<th><label>{if $config.simpleupload}{str tag='uploadfile' section='artefact.file'}{else}{str tag='File' section='artefact.file'}{/if}</label></th>
<td>
<span id="{$prefix}_userfile_container"><input type="file" class="file" id="{$prefix}_userfile" name="userfile" size="40" /></span>
<span id="{$prefix}_userfile_maxuploadsize">({str tag=maxuploadsize section=artefact.file} {$maxuploadsize})</span>
<noscript><input type="submit" class="submit" name="{$prefix}_upload" id="{$prefix}_upload" value="{str tag=upload section=artefact.file}" /></noscript>
<script>setNodeAttribute('{$prefix}_userfile', 'disabled', true);</script>
{if $config.uploadagreement}<script>setNodeAttribute('{$prefix}_userfile', 'disabled', true);</script>{/if}
</td>
</tr>
{else}
<tr>
<th><label>{str tag='uploadfile' section='artefact.file'}</label></th>
<td>
<div id="{$prefix}_userfile_container"><input type="file" class="file" id="{$prefix}_userfile" name="userfile" size="40" /> ({str tag=maxuploadsize section=artefact.file} {$maxuploadsize})</div>
<tr class="uploadform">
<th></th>
<td id="{$prefix}_uploadsubmit_container">{* filebrowser.js may add a submit button in here even if config.submitbutton is off *}
{if $config.submitbutton}
<input type="submit" class="submit nojs-hidden-block" name="{$prefix}_uploadsubmit" id="{$prefix}_uploadsubmit" value="{str tag=upload section=artefact.file}" />
{/if}
<noscript><input type="submit" class="submit" name="{$prefix}_upload" id="{$prefix}_upload" value="{str tag=upload section=artefact.file}" /></noscript>
</td>
</tr>
{/if}
{/if}
{if $config.createfolder}
......
......@@ -740,3 +740,10 @@ function keypressKeyCode(e) {
}
return 0;
}
function is_FF() {
if ( /Firefox|Gecko|Iceweasel/.test(navigator.userAgent)) {
return true;
}
return false;
}
\ No newline at end of file
......@@ -44,7 +44,7 @@ $string['strfdaymonthyearshort'] = '%%d/%%m/%%Y';
$string['strftimew3cdatetime'] = '%%Y-%%m-%%dT%%T%%z';
$string['strftimew3cdate'] = '%%Y-%%m-%%d';
$string['thislanguage'] = 'English';
$string['locales'] = 'en_US.utf8,en_GB.utf8,en';
$string['locales'] = 'en_US.utf8,en_GB.utf8,en,english-us,english-uk,english';
?>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment