Ticket #2961: ajax_request_thing.2.diff

File ajax_request_thing.2.diff, 4.0 KB (added by Rob Smith, 17 years ago)
  • js/ajax_utils.js

     
     1/**
     2 * The routines to allow a small ajax request counter
     3 *
     4 * @url         $URL: http://svn.mythtv.org/svn/trunk/mythplugins/mythweb/js/utils.js $
     5 * @date        $Date: 2006-07-07 23:05:05 -0700 (Fri, 07 Jul 2006) $
     6 * @version     $Revision: 10427 $
     7 * @author      $Author: xris $
     8 * @license     LGPL
     9 *
     10/**/
     11
     12var pending_ajax_requests = 0;
     13
     14function ajax_add_request() {
     15    pending_ajax_requests +=1;
     16    get_element('ajax_num_requests').innerHTML = pending_ajax_requests;
     17    remove_class('ajax_working', 'hidden');
     18}
     19
     20function ajax_remove_request() {
     21    pending_ajax_requests -=1;
     22    get_element('ajax_num_requests').innerHTML = pending_ajax_requests;
     23    if (pending_ajax_requests == 0)
     24        add_class('ajax_working', 'hidden');
     25}
     26 No newline at end of file
  • modules/tv/tmpl/default/recorded.php

     
    121121        // Do the actual deletion
    122122            if (programs_shown == 1)
    123123                location.href = url;
    124             else
     124            else {
     125                ajax_add_request();
    125126                submit_url(url, http_success, http_failure, id, file);
     127            }
    126128        // Debug statements - uncomment to verify that the right file is being deleted
    127129            //alert('row number ' + id + ' belonged to section ' + section + ' which now has ' + rowcount[section] + ' elements');
    128130            //alert('just deleted an episode of "' + title + '" which now has ' + episode_count + ' episodes left');
     
    189191        $('diskfree').innerHTML = nice_filesize(<?php echo disk_size ?> - diskused);
    190192        // Eventually, we should perform the removal-from-the-list here instead
    191193        // of in confirm_delete()
     194        ajax_remove_request();
    192195    }
    193196
    194197    function http_failure(err, errstr, args) {
    195198        var file = args[0];
    196199        alert("Can't delete "+file.title+': '+file.subtitle+".\nHTTP Error:  " + errstr + ' (' + err + ')');
     200        ajax_remove_request();
    197201    }
    198202
    199203// -->
  • modules/_shared/tmpl/default/header.php

     
    3636    <script type="text/javascript" src="<?php echo root ?>js/visibility.js"></script>
    3737    <script type="text/javascript" src="<?php echo root ?>js/prototype.js"></script>
    3838    <script type="text/javascript" src="<?php echo root ?>js/ajax.js"></script>
     39    <script type="text/javascript" src="<?php echo root ?>js/ajax_utils.js"></script>
    3940
    4041    <link rel="stylesheet" type="text/css" href="<?php echo skin_url ?>/style.css" />
    4142    <link rel="stylesheet" type="text/css" href="<?php echo skin_url ?>/header.css" />
  • modules/_shared/tmpl/default/footer.php

     
    2121    }
    2222?>
    2323
     24<div id="ajax_working" class="hidden">
     25 <?php echo t('<span id="ajax_num_requests">0</span> requests pending.'); ?>
     26</div>
     27
    2428</body>
    2529</html>
  • skins/default/style.css

     
    202202    .clearfix {display: block;}
    203203    /* End hide from IE-mac */
    204204
     205    /* Ajax little popup request thing style */
     206    #ajax_working {
     207        position: fixed;
     208        background-color: green;
     209        bottom: 0px;
     210        left: 1em;
     211        padding: 1em;
     212        width: 10em;
     213        text-align: center;
     214    }
     215