Changeset 377

Show
Ignore:
Timestamp:
04/29/08 20:59:23 (2 weeks ago)
Author:
t-bone
Message:
  • Wire up button disabling in the new UI; user feedback during synchronous API calls.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • extension/resurrect/content/resurrect-select-mirror.xul

    r376 r377  
    77<dialog id="resurrect-select-mirror" 
    88    xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 
     9    xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 
    910    title="&resurrect.title;" 
    1011    buttons="cancel" 
     
    2425    <label value='&resurrect.fromMirror;' /> 
    2526    <vbox id='resurrect' onclick='resurrect.clickedXul(event);'> 
    26     <button 
     27    <xul:button 
    2728        value='coralcdn' label=' &resurrect.coralcdn;' 
    2829        image='chrome://resurrect/skin/cacheicons/coralcdn.png' 
    2930    /> 
    30     <button 
     31    <xul:button 
    3132        value='google' label=' &resurrect.google;' 
    3233        image='chrome://resurrect/skin/cacheicons/google.png' 
    3334    /> 
    34     <button 
     35    <xul:button 
    3536        value='googletext' label=' &resurrect.google;&resurrect.textonly;' 
    3637        image='chrome://resurrect/skin/cacheicons/google.png' 
    3738    /> 
    38     <button 
     39    <xul:button 
    3940        value='yahoo' label=' &resurrect.yahoo;' 
    4041        image='chrome://resurrect/skin/cacheicons/yahoo.png' 
    4142    /> 
    42     <button 
     43    <xul:button 
    4344        value='archive' label=' &resurrect.archive;' 
    4445        image='chrome://resurrect/skin/cacheicons/archive.png' 
    4546    /> 
    46     <button 
     47    <xul:button 
    4748        value='msn' label=' &resurrect.msn;' 
    4849        image='chrome://resurrect/skin/cacheicons/msn.png' 
    4950    /> 
    50     <button 
     51    <xul:button 
    5152        value='gigablast' label=' &resurrect.gigablast;' 
    5253        image='chrome://resurrect/skin/cacheicons/gigablast.png' 
  • extension/resurrect/content/resurrect.js

    r375 r377  
    22 
    33    originalDoc:null, 
    4     disabled:false, 
    54 
    65// // // // // // // // // // // // // // // // // // // // // // // // // // // 
     
    3231 
    3332    attachClickEvent:function(event) { 
    34         resurrect.disabled=false; 
    35  
    3633        var contentDoc=event.target; 
     34        var contentWin=contentDoc.defaultView; 
     35 
    3736        if (contentDoc.documentURI.match(/^about:neterror/)) { 
    3837            contentDoc.getElementById('resurrect').addEventListener( 
    3938                'click', resurrect.clickedHtml, false 
    4039            ); 
     40        } 
     41    }, 
     42 
     43    disableButtons:function(doc) { 
     44        var bs=doc.getElementById('resurrect') 
     45            .getElementsByTagName('xul:button'); 
     46        for (var i=0, b=null; b=bs[i]; i++) { 
     47            b.setAttribute('disabled', 'true'); 
    4148        } 
    4249    }, 
     
    8693 
    8794    clickedHtml:function(event) { 
     95        if ('true'==event.target.getAttribute('disabled')) { 
     96            return; 
     97        } 
     98 
    8899        return resurrect.clickHandler( 
    89100            event, 
    90101            event.target.ownerDocument, 
    91             event.target.ownerDocument, 
    92102            event.target.ownerDocument.location.href 
    93103        ); 
     
    97107        return resurrect.clickHandler( 
    98108            event, 
    99             event.target.ownerDocument, 
    100109            window.arguments[0], 
    101110            window.arguments[1] 
     
    103112    }, 
    104113 
    105     clickHandler:function(event, ownerDoc, contentDoc, rawUrl) { 
    106         if (resurrect.disabled) return; 
    107         resurrect.disabled=true; 
     114    clickHandler:function(event, contentDoc, rawUrl) { 
     115        resurrect.disableButtons(event.target.ownerDocument); 
    108116 
    109117        // Run the actual code.  After timeout for UI repaint. 
    110118        setTimeout( 
    111119            resurrect.selectMirror, 1, 
    112             event.target.getAttribute('value'), ownerDoc, contentDoc, rawUrl 
     120            event.target.getAttribute('value'),  
     121            event.target.ownerDocument, 
     122            contentDoc, rawUrl 
    113123        ); 
    114124    }, 
     
    218228                setTimeout(window.close, 0); 
    219229            } 
    220         } else { 
    221             resurrect.disabled=false; 
    222230        } 
    223231    }