Skip to content

Commit 15933a1

Browse files
author
Wilhansen Li
committed
Use the aliased jQuery in the closure
Didn't notice it earlier. It shouldn't affect the behavior.
1 parent 426a03e commit 15933a1

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

jquery.toggle_select.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
var changed;
66
var options_width;
77

8-
jQuery.fn.toggle_select = function(options) {
8+
$.fn.toggle_select = function(options) {
99
// Extend out default options with those provided
10-
opts = jQuery.extend({}, jQuery.fn.toggle_select.defaults, options);
10+
opts = $.extend({}, $.fn.toggle_select.defaults, options);
1111
selects = this;
1212
options_width = parseInt(opts.width - opts.switch_width);
1313

1414
// Iterate over each matched element
1515
selects.each(function( ) {
16-
$this = jQuery(this);
16+
$this = $(this);
1717

1818
// Make sure the select has at least two options
1919
if ($this.children('option').length < 2)
@@ -41,18 +41,18 @@
4141
});
4242

4343
// Setup events
44-
jQuery(".toggle_switch .toggle_button").click(function() {
44+
$(".toggle_switch .toggle_button").click(function() {
4545
// Don't toggle on the same mouseup as a user drag
4646
if(!changed)
47-
toggle_switch(jQuery(this).parents(".toggle_switch"));
47+
toggle_switch($(this).parents(".toggle_switch"));
4848
});
49-
jQuery(".toggle_switch .toggle_button").mousedown(function() {
49+
$(".toggle_switch .toggle_button").mousedown(function() {
5050
// Reset changed on every mousedown
5151
changed = false;
5252
})
5353

5454
// Make center switch draggable
55-
jQuery(".toggle_switch .switch").draggable({ axis:'x', handle: jQuery(this).find('.toggle_button'),
55+
$(".toggle_switch .switch").draggable({ axis:'x', handle: $(this).find('.toggle_button'),
5656
start: function(e, ui) {
5757
// Called only when the mouse has started dragging, disable toggles
5858
changed = true;
@@ -69,15 +69,15 @@
6969
stop: function(e, ui) {
7070
// If the button is in the middle, move to one position or the other
7171
if (ui['position'].left > -options_width / 2)
72-
switch_on(jQuery(this).parent());
72+
switch_on($(this).parent());
7373
else
74-
switch_off(jQuery(this).parent());
74+
switch_off($(this).parent());
7575
}
7676
});
7777
};
7878

7979
// Set default options for the toggle
80-
jQuery.fn.toggle_select.defaults = {
80+
$.fn.toggle_select.defaults = {
8181
width : 80, // Width of entire toggle
8282
height : 27, // Height of entire toggle
8383
switch_width : 39, // Width of the switch between the two options
@@ -98,13 +98,13 @@
9898
toggle_switch.children(".switch").animate({left: -options_width}, opts.speed);
9999
var target = toggle_switch.children("select.toggle");
100100
target.val(toggle_switch.find(".switch .toggle_off").attr('value'));
101-
jQuery(target).change();
101+
$(target).change();
102102
}
103103
function switch_on(toggle_switch) {
104104
toggle_switch.children(".switch").animate({left: '0px'}, opts.speed);
105105
var target = toggle_switch.children("select.toggle");
106106
target.val(toggle_switch.find(".switch .toggle_on").attr('value'));
107-
jQuery(target).change();
107+
$(target).change();
108108
}
109109
function is_on(toggle_switch) {
110110
return toggle_switch.children(".switch").css('left') == '0px';

0 commit comments

Comments
 (0)