jQuery: The Write Less, Do More JavaScript Library

Changeset 5553

Show
Ignore:
Timestamp:
05/11/08 19:56:04 (3 months ago)
Author:
braeker
Message:

Fluent progressbar text

Location:
branches/ui-1.6/ui
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • branches/ui-1.6/ui/tests/progressbar.html

    r5250 r5553  
    1818<script type="text/javascript" src="../ui.progressbar.js"></script> 
    1919 
    20 <script type="text/javascript" src="../../fx/fx.js"></script> 
    21 <script type="text/javascript" src="../../fx/fx.bounce.js"></script> 
    22 <script type="text/javascript" src="../../fx/fx.scale.js"></script> 
    23  
    24 <link rel="stylesheet" href="../../themes/flora/flora.all.css" type="text/css" media="screen" title="Flora (Default)" /> 
    2520<style type="text/css" media="all"> 
    2621 
     
    2924    background: #fff; 
    3025    font-family: Arial; 
    31     font-size: 12px; 
    3226} 
    3327 
     
    4337} 
    4438 
     39/* ProgressBar */ 
     40 
    4541.ui-progressbar { 
    46     padding: 1px; 
    47     width: 200px; line-height: 19px; 
     42    width: 400px; height: 20px; 
    4843    border: 1px #ccc solid; 
    4944    background:#E0E8F3 url(images/bg.gif) repeat-x scroll 0%; 
     
    5146} 
    5247 
    53  
    54 .ui-hidden { 
    55     left:-10000px; 
    56     position:absolute; 
    57     top:-10000px; 
    58     visibility:hidden; 
    59 } 
    60  
    6148.ui-progressbar-wrap { 
    62     position:relative; 
    63     height: 20px; 
    64 } 
    65  
    66 .ui-progressbar-text { 
    67     color:#fff; 
    68     font-size:11px; 
    69     font-weight:bold; 
    70     left:0pt; 
    71     overflow:hidden; 
    72     padding:0px 5px; 
    73     text-align:left; 
    74     position: absolute; 
    75 } 
    76  
    77 .ui-progressbar-text.right-align { 
    78     text-align: right; 
    79     padding: 0 5px 0 0; 
    80 } 
    81  
    82 .ui-progressbar-text-back { 
    83     /*background:#E0E8F3 url(images/bg.gif) repeat-x scroll 0%;*/ 
    84     color:#000; 
     49    position: relative; 
     50    height: auto; 
     51    width: auto; 
     52    line-height: 18px; 
     53    _line-height: 16px; 
    8554} 
    8655 
     
    9059    border-right:1px solid #7FA9E4; 
    9160    border-top:1px solid #D1E4FD; 
    92     height:18px; 
    93     width:0pt; 
    9461    position: absolute; 
     62} 
     63 
     64.ui-progressbar-text { 
     65    color:#fff; 
     66    overflow: hidden; 
     67    white-space: nowrap; 
     68    font-size: 11px; 
     69    font-weight: bold; 
     70    padding-left: 5px; 
     71} 
     72 
     73.ui-progressbar-text-back { 
     74    color:#000; 
     75    padding-top: 1px; 
     76    padding-bottom: 1px; 
     77    padding-right: 1px; 
    9578} 
    9679 
     
    10285 
    10386/* custom */ 
     87.ui-progressbar-text.right-align { 
     88    text-align: right; 
     89    padding: 0 5px 0 0; 
     90} 
    10491.ui-progressbar-inner-custom { 
    10592    background: url(images/custom-bar.gif) repeat-x scroll left center; 
     
    10895    border-top:1px solid #BEBEBE; 
    10996    height:15px; 
     97} 
     98 
     99.ui-hidden { 
     100    left:-10000px; 
     101    position:absolute; 
     102    top:-10000px; 
     103    visibility:hidden; 
    110104} 
    111105 
     
    172166        $('#p1').progressbar({ 
    173167             
    174             text: 'Waiting...', 
     168            text: 'jQuery ProgressBar waiting...', 
    175169             
    176170            //addClass: 'ui-progressbar-inner-custom teste', 
     
    184178      duration: 2000, 
    185179             
    186       stepping: 5, 
     180      stepping: 3, 
    187181             
    188182            progress: function(range, ui) { 
  • branches/ui-1.6/ui/ui.progressbar.js

    r5250 r5553  
    5252        var text = o.text ? o.text : (o.range ? '0%' : ''), elw = el.css('width'), elh = el.css('height'); 
    5353         
    54         //el.css({overflow: 'hidden'}); 
    55      
    5654        this.wrapper = $("<div class='ui-progressbar-wrap'></div>"); 
    5755         
     
    6058        }); 
    6159         
    62         this.textel = $("<div class='ui-progressbar-text'></div>").css({ 
     60        this.textel = $("<div class='ui-progressbar-text'></div>").html(text).css({ 
    6361            width: '0px', overflow: 'hidden' 
    64         }) 
    65         .append( 
    66             $('<div>').html(text) 
    67         ); 
    68          
    69         this.textBg = $("<div class='ui-progressbar-text ui-progressbar-text-back'></div>") 
    70         .append( 
    71             $('<div>').html(text).css({ width: elw }) 
    72         ); 
     62        }); 
     63         
     64        this.textBg = $("<div class='ui-progressbar-text ui-progressbar-text-back'></div>").html(text).css({ 
     65                width: elw 
     66        }); 
    7367         
    7468        this.wrapper.append(this.bar.append(this.textel), this.textBg).appendTo(el); 
     
    126120            var frames = Math.ceil(100/o.stepping) || 0, ms = o.duration/frames || 0, 
    127121             
    128             render = function(step, t) { return function() { 
    129                     clearInterval(t); 
    130                     self.progress(o.stepping * step); 
    131                     // on end 
    132                     if (step >= frames) { 
    133                         self.stop(); 
    134  
    135                         if (self.waitThread || o.wait == 'loop') { 
    136                             self._step = 0; 
    137                             self.start(); 
    138                         } 
     122            render = function(step, t) { 
     123                //clearInterval(t); 
     124                 
     125                console.log(step) 
     126                 
     127                self.progress(o.stepping * step); 
     128                // on end 
     129                if (step >= frames) { 
     130                    self.stop(); 
     131 
     132                    if (self.waitThread || o.wait == 'loop') { 
     133                        self._step = 0; 
     134                        self.start(); 
    139135                    } 
    140                 }; 
     136                } 
    141137            }; 
    142             var from = this._step; 
    143              
    144             for(var step = from; step <= frames; step++) { 
     138            var from = this._step, _step = (this._step - (from - 1)); 
     139             
     140            console.log(_step) 
     141             
     142            /*for(var step = from; step <= frames; step++) { 
    145143                var interval = (step - (from - 1)) * ms; 
    146144                this.threads[step] = setTimeout(render(step, this.threads[step]), interval); 
    147             } 
     145            }*/ 
     146             
     147            this.threads[0] = setInterval(function() { 
     148                render(_step++); 
     149            }, ms); 
    148150             
    149151            this.propagate('start');