Changeset 566

Show
Ignore:
Timestamp:
2007-08-21 23:23:13 (1 year ago)
Author:
MaierMan
Message:

#308 pt1: unify the tooltip and info window

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/chrome/content/dta/manager.js

    r565 r566  
    4646const MAX_BUFFER_SIZE = 5 * 1024 * 1024; 
    4747const MIN_BUFFER_SIZE = 1 * 1024 * 1024; 
    48 const SPEED_COUNT = 25; 
    4948 
    5049const REFRESH_FREQ = 1000; 
  • trunk/chrome/content/dta/manager/info.js

    r476 r566  
    2424        load: function DTA_load() { 
    2525                try { 
    26                         this.canvas = $("draw").getContext("2d"); 
    27  
    2826                        // d is an Array of Downloads 
    2927                        var downloads = window.arguments[0]; 
    3028                        if (downloads.length == 1) { 
    3129                                var d = downloads[0]; 
    32                                 $("infoURL").value = d.urlManager.usable; 
     30                                $("infoIcon").src = d.largeIcon; 
     31                                $("infoURL").value = d.urlManager.url; 
     32                                window.title = $("infoDest").value = d.destinationFile; 
     33                         
    3334                                $("sourcePage").value = d.referrer.spec; 
    3435                                $('renaming').value = d.mask; 
    3536                                $('directory').value = d.pathName; 
    3637                                $('hash').value = d.hash; 
    37                                 var caption = document.getAnonymousNodes($("logo"))[0]; 
    38                                 caption.style.backgroundImage = 'url(' + getIcon(d.fileName, 'isMetaLink' in d, 32) + ')'; 
    39                                 caption.style.paddingLeft = '37px'; 
    4038                                this.item = d; 
    41                                 Dialog.draw(); 
     39                                Tooltip.start(d); 
    4240                        } 
    4341                        else { 
    44                                  
    4542                                // more than just one download 
    46                                 $("infoURL").value = $("sourcePage").value = "---"; 
     43                                $('infoDest', 'infoURL', 'sourcePage').forEach( 
     44                                        function(e) { 
     45                                                e.value = "---"; 
     46                                        } 
     47                                ); 
    4748                                $("hash").setAttribute('readonly', 'true'); 
    4849                                $("hash").setAttribute('disabled', 'true'); 
     
    128129                        } 
    129130                } 
    130                  
    131                 // XXX: saveing destroys order, saving with putting new entries in the end, or as 2nd entry? 
    132                  
     131                Tooltip.stop(); 
    133132                return true; 
    134         }, 
    135         draw: function DTA_draw() { 
    136                 var d = this.item; 
    137                  
    138                 var c = d.firstChunk; 
    139                 var canvas = this.canvas; 
    140                  
    141                 canvas.clearRect(0,0,300,20); 
    142  
    143                 var prog = canvas.createLinearGradient(0,0,0,16); 
    144                 prog.addColorStop(0, 'rgba(96,165,1,255)'); 
    145                 prog.addColorStop(1, 'rgba(123,214,1,255)'); 
    146  
    147                 var compl = canvas.createLinearGradient(0,0,0,16); 
    148                 compl.addColorStop(0, 'rgba(13,141,15,255)'); 
    149                 compl.addColorStop(1, 'rgba(0,199,56,255)'); 
    150                  
    151                 var cancel = canvas.createLinearGradient(0,0,0,16); 
    152                 cancel.addColorStop(0, 'rgba(151,58,2,100)'); 
    153                 cancel.addColorStop(1, 'rgba(255,0,0,100)'); 
    154                  
    155                 var normal = canvas.createLinearGradient(0,0,0,16); 
    156                 normal.addColorStop(0, 'rgba(255,255,255,50)'); 
    157                 normal.addColorStop(1, '#ECE9D8'); 
    158                  
    159                 canvas.fillStyle = normal; 
    160                 canvas.fillRect(0,0,300,20); 
    161  
    162                 if (d.is(COMPLETE, FINISHING)) { 
    163                         canvas.fillStyle = compl; 
    164                         canvas.fillRect(0,0,300,20); 
    165                 } else if (d.is(CANCELED)) { 
    166                         canvas.fillStyle = cancel; 
    167                         canvas.fillRect(0,0,300,20); 
    168                 } else if (d.started && d.totalSize) { 
    169                         d.chunks.forEach( 
    170                                 function(c) { 
    171                                         this.canvas.fillStyle = prog; 
    172                                         this.canvas.fillRect( 
    173                                                 Math.ceil(c.start / d.totalSize * 300), 
    174                                                 0, 
    175                                                 Math.ceil(c.written / d.totalSize * 300), 
    176                                                 20 
    177                                         ); 
    178                                 }, 
    179                                 this 
    180                         ); 
    181                 } 
    182                 setTimeout('Dialog.draw();', 150); 
    183133        }, 
    184134        browseDir: function DTA_browseDir() { 
  • trunk/chrome/content/dta/manager/info.xul

    r472 r566  
    1111<?xml-stylesheet href="chrome://global/skin/" type="text/css"?> 
    1212<?xml-stylesheet href="chrome://dta/skin/common/style.css" type="text/css" ?> 
     13<?xml-stylesheet href="chrome://dta/skin/manager/info.css" type="text/css" ?> 
    1314 
    1415<!DOCTYPE dialog [ 
     
    1718        <!ENTITY % infoDTD SYSTEM "chrome://dta/locale/info.dtd"> 
    1819        %infoDTD; 
     20        <!ENTITY % managerDTD SYSTEM "chrome://dta/locale/manager.dtd"> 
     21        %managerDTD;     
    1922]> 
    2023 
     
    2528        id="dTaDownloadInfo"  
    2629        onload="Dialog.load();"  
    27         style="width:500px; margin: 0; padding: 0;" 
    2830        buttons="accept,cancel"  
    29         ondialogaccept="return Dialog.accept();"  
     31        ondialogaccept="return Dialog.accept();" 
     32        ondialogcancel="Tooltip.stop(); return true;" 
    3033        > 
    3134         
     
    3538        <script type="application/javascript;version=1.7" src="chrome://dta/content/common/internalFunctions.js"/> 
    3639        <script type="application/javascript;version=1.7" src="chrome://dta/content/dta/manager/info.js"/> 
     40        <script type="application/javascript;version=1.7" src="chrome://dta/content/dta/manager/tooltip.js"/> 
    3741         
    3842        <script src="chrome://global/content/nsDragAndDrop.js"/> 
     
    4751        </keyset> 
    4852         
    49         <dialogheader id="logo" title="&info.label;" /> 
    50  
    51         <grid style="padding:5px 10px;"> 
     53        <hbox> 
     54                <vbox> 
     55                        <spacer flex="1"/> 
     56                        <image id="infoIcon"/> 
     57                        <spacer flex="1"/> 
     58                </vbox> 
     59                <separator class="thin" /> 
     60                <grid id="infoGrid"> 
     61                        <columns><column/><column flex="1"/></columns> 
     62                        <rows> 
     63                                <label crop="left" id="infoDest" /> 
     64                                <row> 
     65                                        <label value="&infoURLTitle.value;" /> 
     66                                        <label crop="left" id="infoURL" /> 
     67                                </row> 
     68                                <row> 
     69                                        <label value="&infoSizeTitle.value;" /> 
     70                                        <label crop="left" id="infoSize" /> 
     71                                </row> 
     72                        </rows> 
     73                        <spacer flex="1"/> 
     74                </grid> 
     75        </hbox> 
     76        <separator class="thin" /> 
     77        <grid> 
    5278                <columns> 
    5379                        <column /> 
     
    5581                </columns> 
    5682                <rows> 
    57                         <row align="center"> 
    58                                 <label control="infoURL" id="infoURLTitle" value="&link.value;" /> 
    59                                 <textbox id="infoURL" readonly="true" /> 
    60                         </row> 
    6183                        <row align="center"> 
    6284                                <label control="sourcePage" id="sourcePageTitle" value="&referrer.value;" /> 
     
    83105                </rows> 
    84106        </grid> 
    85          
    86         <html:canvas id="draw" width="300" height="20" style="border:1px solid #555; margin:5px 10px;" ></html:canvas> 
     107        <separator class="thin" /> 
     108        <grid id="canvasGrid"> 
     109                <columns><column/><column flex="1"/><column/><column/></columns> 
     110                <rows> 
     111                        <stack> 
     112                                <html:canvas id="chunkCanvas" height="40px"></html:canvas> 
     113                                <label id="infoPercent"/> 
     114                        </stack> 
     115                        <row> 
     116                                <label value="&elapsedTitle.value;"/> 
     117                                <label id="timeElapsed"/> 
     118                                <label value="&remainingTitle.value;"/> 
     119                                <label id="timeRemaining"/> 
     120                        </row> 
     121                        <separator class="thin" /> 
     122                        <html:canvas id="speedCanvas" height="33"></html:canvas> 
     123                        <row> 
     124                                <label value="&currentSpeedTitle.value;"/> 
     125                                <label id="speedCurrent"/> 
     126                                <label value="&avgSpeedTitle.value;"/> 
     127                                <label id="speedAverage"/> 
     128                        </row> 
     129                </rows> 
     130        </grid> 
     131 
    87132</dialog> 
  • trunk/chrome/content/dta/manager/tooltip.js

    r480 r566  
    3838  
    3939const TOOLTIP_FREQ = 500; 
     40const SPEED_COUNT = 25; 
     41 
    4042var Tooltip = { 
    4143        _current: null, 
     
    195197                 
    196198                try { 
     199                        if (file.speeds.length) { 
     200                                var avg = 0; 
     201                                file.speeds.forEach( 
     202                                        function(s) { 
     203                                                avg += s; 
     204                                        } 
     205                                ) 
     206                                $('speedAverage').value = Utils.formatBytes(avg / file.speeds.length) + "/s"; 
     207                        } 
     208                        else { 
     209                                $('speedAverage').value = _('unknown'); 
     210                        } 
     211 
    197212                        $('infoSize').value = file.totalSize > 0 ? Utils.formatBytes(file.totalSize) : _('unknown'); 
    198213                        if (file.is(RUNNING)) { 
     
    200215                                $('timeRemaining').value = file.status; 
    201216                                $('speedCurrent').value = file.speed; 
    202                                 if (file.speeds.length) { 
    203                                         var avg = 0; 
    204                                         file.speeds.forEach( 
    205                                                 function(s) { 
    206                                                         avg += s; 
    207                                                 } 
    208                                         ) 
    209                                         $('speedAverage').value = Utils.formatBytes(avg / file.speeds.length) + "/s"; 
    210                                 } 
    211                                 else { 
    212                                         $('speedAverage').value = _('unknown'); 
    213                                 } 
    214217                        } 
    215218                        else { 
    216                                 $('timeElapsed', 'timeRemaining', 'speedCurrent', 'speedAverage').forEach( 
     219                                $('timeElapsed', 'timeRemaining', 'speedCurrent').forEach( 
    217220                                        function(e) { 
    218221                                                e.value = _('nal'); 
  • trunk/chrome/skin/manager/style.css

    r522 r566  
    109109} 
    110110#infoGrid label[crop] { 
    111         font-weight: normal !important
     111        font-weight: normal
    112112        max-width: 300px;        
    113113}