github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

jquery / jquery-ui

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 710
    • 145
  • Source
  • Commits
  • Network (145)
  • Graphs
  • Tree: c665dcc

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 (19)
    • 1.9m2
    • 1.9m1
    • 1.8rc3
    • 1.8rc2
    • 1.8rc1
    • 1.8b1
    • 1.8a2
    • 1.8a1
    • 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…

The official jQuery user interface library. — Read more

  Cancel

http://jqueryui.com/

  Cancel
  • HTTP
  • Git Read-Only

This URL has Read+Write access

Merge branch 'widget-super' into devpreview
jzaefferer (author)
Sat Jun 19 08:38:37 -0700 2010
commit  c665dcc8bd8a5bdb26b6
tree    060a93bed1e3ddc25735
parent  92723de7f5a0f0c3ff7e parent  e9a2661dbf0dbf87d08b
M tests/unit/widget/widget.js 33 •••••
M ui/jquery.ui.accordion.js 2 ••
M ui/jquery.ui.autocomplete.js 4 ••••
M ui/jquery.ui.button.js 8 ••••
M ui/jquery.ui.progressbar.js 4 ••••
M ui/jquery.ui.slider.js 2 ••
M ui/jquery.ui.sortable.js 2 ••
M ui/jquery.ui.widget.js 13 ••••
Txt tests/unit/widget/widget.js
  • View file @ c665dcc
... ...
@@ -165,4 +165,37 @@ test(".widget() - overriden", function() {
165 165
   same(wrapper[0], $("<div></div>").testWidget().testWidget("widget")[0]);
166 166
 });
167 167
 
  168
+test("_super", function() {
  169
+  expect(2);
  170
+  $.widget("sup.parent", {
  171
+    log: function() {
  172
+      ok( this.called );
  173
+    }
  174
+  });
  175
+  $.widget("sup.child", $.sup.parent, {
  176
+    log: function() {
  177
+      this.called = true;
  178
+      ok( true );
  179
+      this._super("log");
  180
+    }
  181
+  });
  182
+  $("<div></div>").child().child("log");
  183
+});
  184
+
  185
+test("_superApply", function() {
  186
+  expect(2);
  187
+  $.widget("sup.parent", {
  188
+    log: function(a, b) {
  189
+      same( a, 1 );
  190
+      same( b, 2 );
  191
+    }
  192
+  });
  193
+  $.widget("sup.child", $.sup.parent, {
  194
+    log: function() {
  195
+      this._superApply("log", arguments);
  196
+    }
  197
+  });
  198
+  $("<div></div>").child().child("log", 1, 2);
  199
+});
  200
+
168 201
 })(jQuery);
Txt ui/jquery.ui.accordion.js
  • View file @ c665dcc
... ...
@@ -151,7 +151,7 @@ $.widget("ui.accordion", {
151 151
   },
152 152
   
153 153
   _setOption: function(key, value) {
154  
-    $.Widget.prototype._setOption.apply(this, arguments);
  154
+    this._superApply( "_setOption", arguments );
155 155
       
156 156
     if (key == "active") {
157 157
       this.activate(value);
Txt ui/jquery.ui.autocomplete.js
  • View file @ c665dcc
... ...
@@ -166,11 +166,11 @@ $.widget( "ui.autocomplete", {
166 166
       .removeAttr( "aria-autocomplete" )
167 167
       .removeAttr( "aria-haspopup" );
168 168
     this.menu.element.remove();
169  
-    $.Widget.prototype.destroy.call( this );
  169
+    this._super( "destroy" );
170 170
   },
171 171
 
172 172
   _setOption: function( key ) {
173  
-    $.Widget.prototype._setOption.apply( this, arguments );
  173
+    this._superApply( "_setOption", arguments );
174 174
     if ( key === "source" ) {
175 175
       this._initSource();
176 176
     }
Txt ui/jquery.ui.button.js
  • View file @ c665dcc
... ...
@@ -226,11 +226,11 @@ $.widget( "ui.button", {
226 226
       this.buttonElement.removeAttr( "title" );
227 227
     }
228 228
 
229  
-    $.Widget.prototype.destroy.call( this );
  229
+    this._super( "destroy" );
230 230
   },
231 231
 
232 232
   _setOption: function( key, value ) {
233  
-    $.Widget.prototype._setOption.apply( this, arguments );
  233
+    this._superApply( "_setOption", arguments );
234 234
     if ( key === "disabled" ) {
235 235
       if ( value ) {
236 236
         this.element.attr( "disabled", true );
... ...
@@ -324,7 +324,7 @@ $.widget( "ui.buttonset", {
324 324
       this.buttons.button( "option", key, value );
325 325
     }
326 326
 
327  
-    $.Widget.prototype._setOption.apply( this, arguments );
  327
+    this._superApply( "_setOption", arguments );
328 328
   },
329 329
   
330 330
   refresh: function() {
... ...
@@ -358,7 +358,7 @@ $.widget( "ui.buttonset", {
358 358
       .end()
359 359
       .button( "destroy" );
360 360
 
361  
-    $.Widget.prototype.destroy.call( this );
  361
+    this._super( "destroy" );
362 362
   }
363 363
 });
364 364
 
Txt ui/jquery.ui.progressbar.js
  • View file @ c665dcc
... ...
@@ -43,7 +43,7 @@ $.widget( "ui.progressbar", {
43 43
 
44 44
     this.valueDiv.remove();
45 45
 
46  
-    $.Widget.prototype.destroy.apply( this, arguments );
  46
+    this._superApply( "destroy", arguments );
47 47
   },
48 48
 
49 49
   value: function( newValue ) {
... ...
@@ -64,7 +64,7 @@ $.widget( "ui.progressbar", {
64 64
         break;
65 65
     }
66 66
 
67  
-    $.Widget.prototype._setOption.apply( this, arguments );
  67
+    this._superApply( "_setOption", arguments );
68 68
   },
69 69
 
70 70
   _value: function() {
Txt ui/jquery.ui.slider.js
  • View file @ c665dcc
... ...
@@ -511,7 +511,7 @@ $.widget( "ui.slider", $.ui.mouse, {
511 511
       valsLength = this.options.values.length;
512 512
     }
513 513
 
514  
-    $.Widget.prototype._setOption.apply( this, arguments );
  514
+    this._superApply( "_setOption", arguments );
515 515
 
516 516
     switch ( key ) {
517 517
       case "disabled":
Txt ui/jquery.ui.sortable.js
  • View file @ c665dcc
... ...
@@ -81,7 +81,7 @@ $.widget("ui.sortable", $.ui.mouse, {
81 81
         [ value ? "addClass" : "removeClass"]( "ui-sortable-disabled" );
82 82
     } else {
83 83
       // Don't call widget base _setOption for disable as it adds ui-state-disabled class
84  
-      $.Widget.prototype._setOption.apply(this, arguments);
  84
+      this._superApply( "_setOption", arguments );
85 85
     }
86 86
   },
87 87
 
Txt ui/jquery.ui.widget.js
  • View file @ c665dcc
... ...
@@ -62,7 +62,8 @@ $.widget = function( name, base, prototype ) {
62 62
     namespace: namespace,
63 63
     widgetName: name,
64 64
     widgetEventPrefix: $[ namespace ][ name ].prototype.widgetEventPrefix || name,
65  
-    widgetBaseClass: fullName
  65
+    widgetBaseClass: fullName,
  66
+    base: base.prototype
66 67
   }, prototype );
67 68
 
68 69
   $.widget.bridge( name, $[ namespace ][ name ] );
... ...
@@ -145,7 +146,15 @@ $.Widget.prototype = {
145 146
   },
146 147
   _create: function() {},
147 148
   _init: function() {},
148  
-
  149
+  
  150
+  _super: function( method ) {
  151
+    return this.base[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ) );
  152
+  },
  153
+  
  154
+  _superApply: function( method, args ) {
  155
+    return this.base[ method ].apply( this, args );
  156
+  },
  157
+  
149 158
   destroy: function() {
150 159
     this.element
151 160
       .unbind( "." + this.widgetName )

0 notes on commit c665dcc

Please log in to comment.
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server