Changeset cebb45b in indico


Ignore:
Timestamp:
11/08/11 17:45:21 (19 months ago)
Author:
Pedro Ferreira <jose.pedro.ferreira@…>
Branches:
master, hello-world-walkthrough, ipv6, v0.98-series, v0.98.2, v0.98.3, v0.98b2, v0.99, 051b2622c51afb171a1dedb46a0df4fbb0cbd02e, 0da0c1403bae8e51d8229f460181c71b9e6dda72
Children:
306ce5
Parents:
b65b01
git-author:
Adrian Moennich <jerome.ernst.monnich@…> (11/08/11 17:43:56)
git-committer:
Pedro Ferreira <jose.pedro.ferreira@…> (11/08/11 17:45:21)
Message:

[IMP] Badges: use jQuery form plugin

Location:
indico/MaKaC/webinterface
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • indico/MaKaC/webinterface/rh/conferenceModif.py

    rb65b01 rcebb45b  
    75527552 
    75537553    def _process(self): 
     7554        from MaKaC.services.interface.rpc import json 
    75547555        if self._target.isClosed(): 
    7555             p = conferences.WPConferenceModificationClosed( self, self._target ) 
    7556             return p 
     7556            return json.encode_iframe({'status': 'error'}) 
    75577557        else: 
    75587558            if self._tempFilePath is not None: 
     
    75717571                        backgroundId = len(value) - 1 
    75727572 
    7573  
    7574                 return "".join(['<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">', 
    7575                                 '<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body>', 
    7576                                 '<span id="background_id">', 
    7577                                   str(backgroundId), 
    7578                                   '</span>', 
    7579                                   '<span id="background_url">', 
    7580                                   str(urlHandlers.UHConfModifBadgeGetBackground.getURL(self._conf, self.__templateId, backgroundId)), 
    7581                                   '</span>', 
    7582                                   '</body></html>' 
    7583                                   ]) 
     7573                return json.encode_iframe({ 
     7574                    'status': 'OK', 
     7575                    'id': backgroundId, 
     7576                    'url': str(urlHandlers.UHConfModifBadgeGetBackground.getURL(self._conf, self.__templateId, backgroundId)) 
     7577                }) 
    75847578 
    75857579class RHConfBadgeGetBackground(RHConfBadgeBase): 
  • indico/MaKaC/webinterface/tpls/ConfModifBadgeDesign.tpl

    rdad7bd rcebb45b  
    363363    } 
    364364 
    365     function sent() { 
    366         var iframeDocument = $('#uploadTarget')[0].contentDocument || $('#uploadTarget')[0].contentWindow; 
    367         if (iframeDocument.document) { 
    368             iframeDocument = iframeDocument.document; 
    369         } 
    370  
    371         try { 
    372             if (backgroundId != -1) { 
    373                 $('#background').remove(); 
    374             } 
    375             backgroundId = $('#background_id', iframeDocument).html(); 
    376             var backgroundURL = $('#background_url', iframeDocument).html(); 
    377             displayBackground(backgroundURL); 
    378         } 
    379         catch (err) { 
    380             $('#loadingIcon').hide(); 
    381         } 
    382     } 
    383  
    384365    function displayBackground(backgroundURL) { 
    385366        $('<img/>', { 
     
    421402        }).change(); 
    422403 
    423         // show a throbber when uploading a background 
    424         $('#bgForm').submit(function() { 
    425             $('#uploadTarget').one('load', sent); 
    426             $('#loadingIcon').show(); 
     404        $('#bgForm').ajaxForm({ 
     405            dataType: 'json', 
     406            iframe: true, 
     407            success: function(data) { 
     408                if(data.status != 'OK') { 
     409                    alert($T('An error occurred.')); 
     410                    $('#loadingIcon').hide(); 
     411                    return; 
     412                } 
     413                if (backgroundId != -1) { 
     414                    $('#background').remove(); 
     415                } 
     416                backgroundId = data.id; 
     417                displayBackground(data.url); 
     418            }, 
     419            beforeSubmit: function() { 
     420                $('#loadingIcon').show(); 
     421            } 
    427422        }); 
    428423 
     
    485480 
    486481 
    487 <iframe id="uploadTarget" name="uploadTarget" src="" style="width:0px;height:0px;border:0"></iframe> 
    488  
    489482<div style="width:100%"> 
    490483  <br/> 
     
    507500          <span class="titleCellFormat"> ${ _("Background")}<br><small>(${ _("picture file in jpeg, png or gif")})</small></span> 
    508501        </td> 
    509         <form id="bgForm" action="${ saveBackgroundURL }" method="POST" enctype="multipart/form-data" target="uploadTarget"> 
     502        <form id="bgForm" action="${ saveBackgroundURL }" method="POST" enctype="multipart/form-data"> 
    510503        <td height="20px" NOWRAP align="left" colspan="3"> 
    511504          <input name="file" size="58" type="file"> 
Note: See TracChangeset for help on using the changeset viewer.