Skip to content

Commit

Permalink
Fixed #350
Browse files Browse the repository at this point in the history
  • Loading branch information
leongersen committed Sep 24, 2014
1 parent eb0f1d0 commit 5f5571a
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 41 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ Bower users can install all compiled and minified files easily using `bower inst

Changelog
---------
###7.0.4 ~ 7.0.6
###7.0.8
+ Fixed an issue in the way the `$.fn.val` method is overridden. (#350)

###7.0.4 ~ 7.0.7
+ Bower support.

###7.0.3:
Expand Down
31 changes: 20 additions & 11 deletions distribute/jquery.nouislider.all.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! noUiSlider - 7.0.6 - 2014-09-11 20:29:06 */
/*! noUiSlider - 7.0.8 - 2014-09-24 14:32:09 */

(function(){

Expand Down Expand Up @@ -2019,35 +2019,44 @@ function closure ( target, options, originalOptions ){
// the slider value handling. No? Use the standard method.
// Note how $.fn.val expects 'this' to be an instance of $. For convenience,
// the above 'value' function does too.
$.fn.val = function ( ) {
$.fn.val = function ( arg ) {

// this === instanceof $

function valMethod( a ){
return a.hasClass(Classes[0]) ? value : $val;
}

var args = arguments,
first = $(this[0]);

if ( !arguments.length ) {
// If no value is passed, this is 'get'.
if ( arg === undefined ) {
var first = $(this[0]);
return valMethod(first).call(first);
}

// Return the set so it remains chainable
return this.each(function(){
valMethod($(this)).apply($(this), args);
var isFunction = $.isFunction(arg);

// Return the set so it remains chainable. Make sure not to break
// jQuery's .val(function( index, value ){}) signature.
return this.each(function( i ){

var val = arg, $t = $(this);

if ( isFunction ) {
val = arg.call(this, i, $t.val());
}

valMethod($t).call($t, val);
});
};

// Extend jQuery/Zepto with the noUiSlider method.
$.fn.noUiSlider = function ( options, rebuildFlag ) {

switch ( options ) {
case 'step': return this[0].getCurrentStep();
case 'options': return this[0].getOriginalOptions();
}

return ( rebuildFlag ? rebuild : initialize ).call(this, options);
};

Expand Down
4 changes: 2 additions & 2 deletions distribute/jquery.nouislider.all.min.js

Large diffs are not rendered by default.

31 changes: 20 additions & 11 deletions distribute/jquery.nouislider.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! noUiSlider - 7.0.6 - 2014-09-11 20:29:06 */
/*! noUiSlider - 7.0.8 - 2014-09-24 14:32:09 */

/*jslint browser: true */
/*jslint white: true */
Expand Down Expand Up @@ -1371,35 +1371,44 @@ function closure ( target, options, originalOptions ){
// the slider value handling. No? Use the standard method.
// Note how $.fn.val expects 'this' to be an instance of $. For convenience,
// the above 'value' function does too.
$.fn.val = function ( ) {
$.fn.val = function ( arg ) {

// this === instanceof $

function valMethod( a ){
return a.hasClass(Classes[0]) ? value : $val;
}

var args = arguments,
first = $(this[0]);

if ( !arguments.length ) {
// If no value is passed, this is 'get'.
if ( arg === undefined ) {
var first = $(this[0]);
return valMethod(first).call(first);
}

// Return the set so it remains chainable
return this.each(function(){
valMethod($(this)).apply($(this), args);
var isFunction = $.isFunction(arg);

// Return the set so it remains chainable. Make sure not to break
// jQuery's .val(function( index, value ){}) signature.
return this.each(function( i ){

var val = arg, $t = $(this);

if ( isFunction ) {
val = arg.call(this, i, $t.val());
}

valMethod($t).call($t, val);
});
};

// Extend jQuery/Zepto with the noUiSlider method.
$.fn.noUiSlider = function ( options, rebuildFlag ) {

switch ( options ) {
case 'step': return this[0].getCurrentStep();
case 'options': return this[0].getOriginalOptions();
}

return ( rebuildFlag ? rebuild : initialize ).call(this, options);
};

Expand Down
2 changes: 1 addition & 1 deletion distribute/jquery.nouislider.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions distribute/jquery.nouislider.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion distribute/jquery.nouislider.pips.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion nouislider.jquery.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"url": "http://www.wtfpl.net/"
}
],
"version": "7.0.6",
"version": "7.0.8",
"author": {
"name": "Léon Gersen",
"url": "https://twitter.com/LeonGersen"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "noUiSlider",
"version": "7.0.6",
"version": "7.0.8",
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-compress": "^0.11.0",
Expand Down
29 changes: 19 additions & 10 deletions src/js/interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,34 +57,43 @@
// the slider value handling. No? Use the standard method.
// Note how $.fn.val expects 'this' to be an instance of $. For convenience,
// the above 'value' function does too.
$.fn.val = function ( ) {
$.fn.val = function ( arg ) {

// this === instanceof $

function valMethod( a ){
return a.hasClass(Classes[0]) ? value : $val;
}

var args = arguments,
first = $(this[0]);

if ( !arguments.length ) {
// If no value is passed, this is 'get'.
if ( arg === undefined ) {
var first = $(this[0]);
return valMethod(first).call(first);
}

// Return the set so it remains chainable
return this.each(function(){
valMethod($(this)).apply($(this), args);
var isFunction = $.isFunction(arg);

// Return the set so it remains chainable. Make sure not to break
// jQuery's .val(function( index, value ){}) signature.
return this.each(function( i ){

var val = arg, $t = $(this);

if ( isFunction ) {
val = arg.call(this, i, $t.val());
}

valMethod($t).call($t, val);
});
};

// Extend jQuery/Zepto with the noUiSlider method.
$.fn.noUiSlider = function ( options, rebuildFlag ) {

switch ( options ) {
case 'step': return this[0].getCurrentStep();
case 'options': return this[0].getOriginalOptions();
}

return ( rebuildFlag ? rebuild : initialize ).call(this, options);
};
5 changes: 5 additions & 0 deletions tests/general_val.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,9 @@
ok(one[0] === one.val(10)[0]);
ok(two[0] === two.val(20)[0]);

var expectedValues = ['10', '20', '50'];

Q.find("input").val(function(index, value){
equal(value, expectedValues[index]);
});
});

0 comments on commit 5f5571a

Please sign in to comment.