@@ -91,6 +91,7 @@ Formular = SpatialMap.Class ({
9191 groupedLayers : [ ] ,
9292
9393 _listeners : [ ] ,
94+ maxUploadFileSize : 100 ,
9495
9596 initialize : function ( options ) {
9697 SpatialMap . Util . extend ( this , options ) ;
@@ -1390,11 +1391,12 @@ Formular = SpatialMap.Class ({
13901391 jQuery ( '#' + id ) . datepicker ( options ) ;
13911392
13921393 } else if ( type == 'file' ) {
1394+ this . maxUploadFileSize = typeof node . attr ( 'maxfilesize' ) === 'undefined' ? 100 : parseInt ( node . attr ( 'maxfilesize' ) ) ;
13931395 if ( this . bootstrap === true ) {
1394- contentcontainer . append ( '<div id="' + id + '_row" class="form-group' + ( className ? ' ' + className : '' ) + '"><label for="' + id + '">' + node . attr ( 'displayname' ) + ( req ? ' <span class="required">*</span>' :'' ) + '</label><input type="hidden" id="' + id + '" value="' + ( value || '' ) + '"/><input type="hidden" id="' + id + '_org" value="' + ( value || '' ) + '"/><div class="fileupload' + ( req ? ' required-enabled' :'' ) + '"><form id="form_' + id + '" method="POST" target="uploadframe_' + id + '" enctype="multipart/form-data" action="/jsp/modules/formular/upload.jsp"><input ' + ( postparam . disabled ? 'disabled' :'' ) + ' type="file" name="file_' + id + '" id="file_' + id + '" /><span class="filupload-delete" title="Fjern vedhæftet fil"></span><input type="hidden" name="callbackhandler" value="parent.formular.fileupload"/><input type="hidden" name="id" value="' + id + '"/><input type="hidden" name="sessionid" value="' + this . sessionid + '"/><input type="hidden" name="formular" value="' + this . name + '"/></form><iframe name="uploadframe_' + id + '" id="uploadframe_' + id + '" frameborder="0" style="display:none;"></iframe></div></div>' ) ;
1396+ contentcontainer . append ( '<div id="' + id + '_row" class="form-group' + ( className ? ' ' + className : '' ) + '"><label for="' + id + '">' + node . attr ( 'displayname' ) + ( req ? ' <span class="required">*</span>' :'' ) + '</label><input type="hidden" id="' + id + '" value="' + ( value || '' ) + '"/><input type="hidden" id="' + id + '_org" value="' + ( value || '' ) + '"/><div class="fileupload' + ( req ? ' required-enabled' :'' ) + '"><form id="form_' + id + '" method="POST" target="uploadframe_' + id + '" enctype="multipart/form-data" action="/jsp/modules/formular/upload.jsp"><input ' + ( postparam . disabled ? 'disabled' :'' ) + ' type="file" name="file_' + id + '" id="file_' + id + '" /><span class="filupload-delete" title="Fjern vedhæftet fil"></span><input type="hidden" name="callbackhandler" value="parent.formular.fileupload"/><input type="hidden" name="id" value="' + id + '"/><input type="hidden" name="sessionid" value="' + this . sessionid + '"/><input type="hidden" name="formular" value="' + this . name + '"/> <input type="hidden" name="maxfilesize" value="' + this . maxUploadFileSize + '"/> </form><iframe name="uploadframe_' + id + '" id="uploadframe_' + id + '" frameborder="0" style="display:none;"></iframe></div></div>' ) ;
13951397 contentcontainer . find ( '#' + id + '_row .filupload-delete' ) . click ( SpatialMap . Function . bind ( this . deleteFileUpload , this , id ) ) . hide ( ) ;
13961398 } else {
1397- contentcontainer . append ( '<tr id="' + id + '_row"><td><input type="hidden" id="' + id + '" value="' + ( value || '' ) + '"/><input type="hidden" id="' + id + '_org" value="' + ( value || '' ) + '"/><div class="labeldiv' + ( className ? ' ' + className : '' ) + '" id="' + id + '_displayname">' + node . attr ( 'displayname' ) + '</div></td><td><div class="valuediv"><form id="form_' + id + '" method="POST" target="uploadframe_' + id + '" enctype="multipart/form-data" action="/jsp/modules/formular/upload.jsp"><input type="file" name="file_' + id + '" id="file_' + id + '" /><input type="hidden" name="callbackhandler" value="parent.formular.fileupload"/><input type="hidden" name="id" value="' + id + '"/><input type="hidden" name="sessionid" value="' + this . sessionid + '"/><input type="hidden" name="formular" value="' + this . name + '"/></form><iframe name="uploadframe_' + id + '" id="uploadframe_' + id + '" frameborder="0" style="display:none;"></iframe></div></td></tr>' ) ;
1399+ contentcontainer . append ( '<tr id="' + id + '_row"><td><input type="hidden" id="' + id + '" value="' + ( value || '' ) + '"/><input type="hidden" id="' + id + '_org" value="' + ( value || '' ) + '"/><div class="labeldiv' + ( className ? ' ' + className : '' ) + '" id="' + id + '_displayname">' + node . attr ( 'displayname' ) + '</div></td><td><div class="valuediv"><form id="form_' + id + '" method="POST" target="uploadframe_' + id + '" enctype="multipart/form-data" action="/jsp/modules/formular/upload.jsp"><input type="file" name="file_' + id + '" id="file_' + id + '" /><input type="hidden" name="callbackhandler" value="parent.formular.fileupload"/><input type="hidden" name="id" value="' + id + '"/><input type="hidden" name="sessionid" value="' + this . sessionid + '"/><input type="hidden" name="formular" value="' + this . name + '"/> <input type="hidden" name="maxfilesize" value="' + this . maxUploadFileSize + '"/> </form><iframe name="uploadframe_'+ id + '" id="uploadframe_' + id + '" frameborder="0" style="display:none;"></iframe></div></td></tr>' ) ;
13981400 }
13991401 jQuery ( '#file_' + id ) . change ( SpatialMap . Function . bind ( function ( id ) {
14001402 this . startFileUpload ( id ) ;
@@ -3601,11 +3603,27 @@ Formular = SpatialMap.Class ({
36013603 jQuery ( '#' + id + '_row .filupload-delete' ) . hide ( ) ;
36023604 } ,
36033605
3604- fileupload : function ( filename , id , orgfilename ) {
3606+ removeInvalidFileNotice : function ( id ) {
3607+ jQuery ( '#' + id + '_invalidfile' ) . remove ( ) ;
3608+ } ,
3609+
3610+ fileupload : function ( filename , id , orgfilename , filesize ) {
36053611 this . endFileUpload ( ) ;
3606- jQuery ( '#' + id ) . val ( filename ) ;
3607- jQuery ( '#' + id + '_org' ) . val ( orgfilename ) ;
3608- jQuery ( '#' + id + '_row .filupload-delete' ) . show ( ) ;
3612+ this . removeInvalidFileNotice ( id ) ;
3613+ if ( typeof filesize !== 'undefined' && ( parseInt ( filesize ) <= this . maxUploadFileSize ) ) {
3614+ jQuery ( '#' + id ) . val ( filename ) ;
3615+ jQuery ( '#' + id + '_org' ) . val ( orgfilename ) ;
3616+ jQuery ( '#' + id + '_row .filupload-delete' ) . show ( ) ;
3617+ } else {
3618+ this . deleteFileUpload ( id ) ;
3619+ var inputRow = jQuery ( '#' + id + '_row' ) ;
3620+ var destinationTd = inputRow . children ( ) [ 1 ] ;
3621+ jQuery ( '<div/>' , {
3622+ id : id + '_invalidfile' ,
3623+ text : 'Filen overskride den maksimale størrelse!'
3624+ } ) . appendTo ( destinationTd )
3625+
3626+ }
36093627 } ,
36103628
36113629 start : function ( options ) {
@@ -3848,8 +3866,15 @@ Formular = SpatialMap.Class ({
38483866 }
38493867 }
38503868 }
3851- }
3869+ } ,
38523870
3871+ paramHasValue : function ( param ) {
3872+ var curParam = this . currentParams [ param ] ;
3873+ if ( typeof curParam !== 'undefined' && curParam != null && curParam . length > 0 ) {
3874+ return true ;
3875+ }
3876+ return false ;
3877+ }
38533878} ) ;
38543879
38553880
0 commit comments