mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-03-12 00:45:34 +00:00
move js for btn-file into php function
the new function printFileChooserJs() must be called in the js method on every page where a file upload button is used
This commit is contained in:
parent
d519990d5e
commit
cefb89a8c2
|
@ -329,24 +329,6 @@ $(document).ready( function() {
|
||||||
});
|
});
|
||||||
}); /* }}} */
|
}); /* }}} */
|
||||||
|
|
||||||
$(document).on('change', '.btn-file :file', function() {
|
|
||||||
var input = $(this),
|
|
||||||
numFiles = input.get(0).files ? input.get(0).files.length : 1,
|
|
||||||
label = input.val().replace(/\\/g, '/').replace(/.*\//, '');
|
|
||||||
input.trigger('fileselect', [numFiles, label]);
|
|
||||||
});
|
|
||||||
|
|
||||||
$(document).on('fileselect', '.upload-file .btn-file :file', function(event, numFiles, label) {
|
|
||||||
var input = $(this).parents('.input-append').find(':text'),
|
|
||||||
log = numFiles > 1 ? numFiles + ' files selected' : label;
|
|
||||||
|
|
||||||
if( input.length ) {
|
|
||||||
input.val(log);
|
|
||||||
} else {
|
|
||||||
if( log ) alert(log);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$('div.ajax').each(function(index) { /* {{{ */
|
$('div.ajax').each(function(index) { /* {{{ */
|
||||||
var element = $(this);
|
var element = $(this);
|
||||||
var url = '';
|
var url = '';
|
||||||
|
|
|
@ -996,7 +996,31 @@ background-image: linear-gradient(to bottom, #882222, #111111);;
|
||||||
}
|
}
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
function getFileChooser($varname='userfile', $multiple=false, $accept='') { /* {{{ */
|
function printFileChooserJs() { /* {{{ */
|
||||||
|
?>
|
||||||
|
$(document).ready(function() {
|
||||||
|
$(document).on('change', '.btn-file :file', function() {
|
||||||
|
var input = $(this),
|
||||||
|
numFiles = input.get(0).files ? input.get(0).files.length : 1,
|
||||||
|
label = input.val().replace(/\\/g, '/').replace(/.*\//, '');
|
||||||
|
input.trigger('fileselect', [numFiles, label]);
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on('fileselect', '.upload-file .btn-file :file', function(event, numFiles, label) {
|
||||||
|
var input = $(this).parents('.input-append').find(':text'),
|
||||||
|
log = numFiles > 1 ? numFiles + ' files selected' : label;
|
||||||
|
|
||||||
|
if( input.length ) {
|
||||||
|
input.val(log);
|
||||||
|
} else {
|
||||||
|
// if( log ) alert(log);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
<?php
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
|
function getFileChooserHtml($varname='userfile', $multiple=false, $accept='') { /* {{{ */
|
||||||
$id = preg_replace('/[^A-Za-z]/', '', $varname);
|
$id = preg_replace('/[^A-Za-z]/', '', $varname);
|
||||||
$html = '
|
$html = '
|
||||||
<div id="'.$id.'-upload-files">
|
<div id="'.$id.'-upload-files">
|
||||||
|
@ -1014,7 +1038,7 @@ background-image: linear-gradient(to bottom, #882222, #111111);;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
function printFileChooser($varname='userfile', $multiple=false, $accept='') { /* {{{ */
|
function printFileChooser($varname='userfile', $multiple=false, $accept='') { /* {{{ */
|
||||||
echo self::getFileChooser($varname, $multiple, $accept);
|
echo self::getFileChooserHtml($varname, $multiple, $accept);
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
function printDateChooser($defDate = '', $varName) { /* {{{ */
|
function printDateChooser($defDate = '', $varName) { /* {{{ */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user