github github
  • Home
  • Pricing and Signup
  • Training
  • Gist
  • Blog
  • Login

jquery / jquery-ui

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
    • 1,171
    • 294
  • Source
  • Commits
  • Network (294)
  • Graphs
  • Tree: f00c031

click here to add a description

click here to add a homepage

  • Switch Branches (8)
    • bind
    • devpreview
    • formcontrols
    • master
    • menu
    • panel
    • tooltip
    • widget-super
  • Switch Tags (22)
    • 1.9m2
    • 1.9m1
    • 1.8rc3
    • 1.8rc2
    • 1.8rc1
    • 1.8b1
    • 1.8a2
    • 1.8a1
    • 1.8.5
    • 1.8.4
    • 1.8.3
    • 1.8.2
    • 1.8.1
    • 1.8
    • 1.7
    • 1.6rc6
    • 1.6rc5
    • 1.6rc3
    • 1.6rc2
    • 1.6
    • 1.5.2
    • 1.5.1
  • Comments
  • Contributors
Sending Request…
Downloads

The official jQuery user interface library. — Read more

  Cancel

http://jqueryui.com/

  Cancel
  • HTTP
  • Git Read-Only

This URL has Read+Write access

Progressbar: cleanup.
scottgonzalez (author)
Thu Jul 29 02:38:24 -0700 2010
commit  f00c03139bf83e573b60
tree    4eca10b09d8e6a040a5e
parent  ee1f5b54de149e10444b

Showing 2 changed files with 26 additions and 25 deletions.

M tests/unit/progressbar/progressbar_options.js 14 •••••
M ui/jquery.ui.progressbar.js 37 ••••
Txt tests/unit/progressbar/progressbar_options.js
  • View file @ f00c031
... ...
@@ -17,4 +17,18 @@ test("{ value : 5 }", function() {
17 17
   same( 5, $("#progressbar").progressbar("value") );
18 18
 });
19 19
 
  20
+test("{ value : -5 }", function() {
  21
+  $("#progressbar").progressbar({
  22
+    value: -5
  23
+  });
  24
+  same( 0, $("#progressbar").progressbar("value") );
  25
+});
  26
+
  27
+test("{ value : 105 }", function() {
  28
+  $("#progressbar").progressbar({
  29
+    value: 105
  30
+  });
  31
+  same( 100, $("#progressbar").progressbar("value") );
  32
+});
  33
+
20 34
 })(jQuery);
Txt ui/jquery.ui.progressbar.js
  • View file @ f00c031
... ...
@@ -17,13 +17,17 @@ $.widget( "ui.progressbar", {
17 17
   options: {
18 18
     value: 0
19 19
   },
  20
+
  21
+  min: 0,
  22
+  max: 100,
  23
+
20 24
   _create: function() {
21 25
     this.element
22 26
       .addClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
23 27
       .attr({
24 28
         role: "progressbar",
25  
-        "aria-valuemin": this._valueMin(),
26  
-        "aria-valuemax": this._valueMax(),
  29
+        "aria-valuemin": this.min,
  30
+        "aria-valuemax": this.max,
27 31
         "aria-valuenow": this._value()
28 32
       });
29 33
 
... ...
@@ -56,12 +60,10 @@ $.widget( "ui.progressbar", {
56 60
   },
57 61
 
58 62
   _setOption: function( key, value ) {
59  
-    switch ( key ) {
60  
-      case "value":
61  
-        this.options.value = value;
62  
-        this._refreshValue();
63  
-        this._trigger( "change" );
64  
-        break;
  63
+    if ( key === "value" ) {
  64
+      this.options.value = value;
  65
+      this._refreshValue();
  66
+      this._trigger( "change" );
65 67
     }
66 68
 
67 69
     $.Widget.prototype._setOption.apply( this, arguments );
... ...
@@ -73,28 +75,13 @@ $.widget( "ui.progressbar", {
73 75
     if ( typeof val !== "number" ) {
74 76
       val = 0;
75 77
     }
76  
-    if ( val < this._valueMin() ) {
77  
-      val = this._valueMin();
78  
-    }
79  
-    if ( val > this._valueMax() ) {
80  
-      val = this._valueMax();
81  
-    }
82  
-
83  
-    return val;
84  
-  },
85  
-
86  
-  _valueMin: function() {
87  
-    return 0;
88  
-  },
89  
-
90  
-  _valueMax: function() {
91  
-    return 100;
  78
+    return Math.min( this.max, Math.max( this.min, val ) );
92 79
   },
93 80
 
94 81
   _refreshValue: function() {
95 82
     var value = this.value();
96 83
     this.valueDiv
97  
-      [ value === this._valueMax() ? "addClass" : "removeClass"]( "ui-corner-right" )
  84
+      .toggleClass( "ui-corner-right", value === this.max )
98 85
       .width( value + "%" );
99 86
     this.element.attr( "aria-valuenow", value );
100 87
   }

0 notes on commit f00c031

Please log in to comment.
Dedicated Server Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
  • Blog
  • Support
  • Training
  • Job Board
  • Shop
  • Contact
  • API
  • Status
  • © 2010 GitHub Inc. All rights reserved.
  • Terms of Service
  • Privacy
  • Security
  • English
  • Deutsch
  • Français
  • 日本語
  • Português (BR)
  • Русский
  • 中文
  • See all available languages

Your current locale selection: English. Choose another?

  • English
  • Afrikaans
  • Català
  • Čeština
  • Deutsch
  • Español
  • Français
  • Hrvatski
  • Indonesia
  • Italiano
  • 日本語
  • Nederlands
  • Norsk
  • Polski
  • Português (BR)
  • Русский
  • Српски
  • Svenska
  • 中文

Keyboard Shortcuts

Site wide shortcuts

s
Focus site search
?
Bring up this help dialog

Commit list

j
Move selected down
k
Move selected up
t
Open tree
p
Open parent
c or o or enter
Open commit

Pull request list

j
Move selected down
k
Move selected up
o or enter
Open issue

Issues

j
Move selected down
k
Move selected up
x
Toggle select target
o or enter
Open issue
I
Mark selected as read
U
Mark selected as unread
e
Close selected
y
Remove selected from view
c
Create issue
l
Create label
i
Back to inbox
u
Back to issues
/
Focus issues search

Network Graph

← or h
Scroll left
→ or l
Scroll right
↑ or k
Scroll up
↓ or j
Scroll down
t
Toggle visibility of head labels
shift ← or shift h
Scroll all the way left
shift → or shift l
Scroll all the way right
shift ↑ or shift k
Scroll all the way up
shift ↓ or shift j
Scroll all the way down