Skip to content

Commit

Permalink
Re: #146 - The change event is now triggered when using the defaultTe…
Browse files Browse the repository at this point in the history
…xt option
  • Loading branch information
gfranko committed Apr 20, 2013
1 parent 3387e0a commit a30aee4
Show file tree
Hide file tree
Showing 10 changed files with 87 additions and 23 deletions.
56 changes: 56 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
module.exports = function(grunt) {

grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
jshint: {
files: ['Gruntfile.js', 'src/javascripts/jquery.selectBoxIt.js'],
options: {
globals: {
jQuery: true,
console: false,
module: true,
document: true
},
sub: true
}
},
concat: {
dist: {
src: ['src/javascripts/jquery.selectBoxIt.core.js', 'src/javascripts/jquery.selectBoxIt.ariaAccessibility.js', 'src/javascripts/jquery.selectBoxIt.copyAttributes.js', 'src/javascripts/jquery.selectBoxIt.destroy.js', 'src/javascripts/jquery.selectBoxIt.disable.js', 'src/javascripts/jquery.selectBoxIt.dynamicPositioning.js', 'src/javascripts/jquery.selectBoxIt.enable.js', 'src/javascripts/jquery.selectBoxIt.keyboardNavigation.js', 'src/javascripts/jquery.selectBoxIt.keyboardSearch.js', 'src/javascripts/jquery.selectBoxIt.mobile.js', 'src/javascripts/jquery.selectBoxIt.selectOption.js', 'src/javascripts/jquery.selectBoxIt.setOption.js', 'src/javascripts/jquery.selectBoxIt.setOptions.js', 'src/javascripts/jquery.selectBoxIt.wait.js', 'src/javascripts/jquery.selectBoxIt.endClosure.js'],
dest: 'src/javascripts/jquery.selectBoxIt.js'
}
},
uglify: {
my_target: {
files: {
'src/javascripts/jquery.selectBoxIt.min.js': ['src/javascripts/jquery.selectBoxIt.js']
}
},
options: {
banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %> \n' +
'<%= pkg.homepage ? "* " + pkg.homepage : "" %>\n' +
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %>*/\n'
}
},
jasmine: {
customRunner: {
src: 'src/javascripts/jquery.selectBoxIt.js',
options: {
specs: 'test/spec/selectBoxItSpec.js',
helpers: ['libs/jquery/jquery.js', 'libs/jqueryUI/jquery-ui.js', 'libs/jasmine/jasmine-jquery.js']
}
}
}
});

grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-jasmine');
grunt.registerTask('test', ['concat', 'jshint', 'jasmine']);
grunt.registerTask('build', ['uglify']);
grunt.registerTask('default', ['test', 'build']);

};
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@
"url": "http://www.gregfranko.com/jQuery.selectBoxIt.js//blob/master/LICENSE-MIT"
}
],
"dependencies": {
"grunt": "0.3.17",
"grunt-jasmine-task": "0.2.3",
"temporary": "0.0.5"
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-concat": "~0.2.0",
"grunt-contrib-uglify": "~0.2.0",
"grunt-contrib-jshint": "~0.3.0",
"grunt-contrib-jasmine": "~0.4.2"
},
"scripts": {
"test": "grunt travis --verbose"
Expand Down
13 changes: 8 additions & 5 deletions src/javascripts/jquery.selectBoxIt.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,12 @@

});

self.list.css({

"min-width": self.dropdown.width()

});

}

// Dynamically adds the `max-width` and `line-height` CSS styles of the dropdown list text element
Expand Down Expand Up @@ -1396,10 +1402,7 @@
// If the default text option is set and the current drop down option is not disabled
if ((defaultText && self.options["html"] ? self.dropdownText.html() === defaultText: self.dropdownText.text() === defaultText) && self.selectBox.val() === elem.attr("data-val")) {

// Updates the dropdown list value
self._setText(self.dropdownText, currentText);

self.dropdownText.trigger("internal-change");
self.triggerEvent("change");

}

Expand Down Expand Up @@ -1648,7 +1651,7 @@

var self = this,
// Finds the currently option index
currentIndex = self.options["showFirstOption"] ? self.currentFocus : ((self.currentFocus - 1) >= 0 ? self.currentFocus: 0 );
currentIndex = self.options["showFirstOption"] ? self.currentFocus : ((self.currentFocus - 1) >= 0 ? self.currentFocus: 0);

// Triggers the custom option-click event on the original select box and passes the select box option
self.selectBox.trigger(eventName, { "elem": self.selectBox.eq(currentIndex), "dropdown-elem": self.listItems.eq(self.currentFocus) });
Expand Down
13 changes: 8 additions & 5 deletions src/javascripts/jquery.selectBoxIt.js
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,12 @@

});

self.list.css({

"min-width": self.dropdown.width()

});

}

// Dynamically adds the `max-width` and `line-height` CSS styles of the dropdown list text element
Expand Down Expand Up @@ -1396,10 +1402,7 @@
// If the default text option is set and the current drop down option is not disabled
if ((defaultText && self.options["html"] ? self.dropdownText.html() === defaultText: self.dropdownText.text() === defaultText) && self.selectBox.val() === elem.attr("data-val")) {

// Updates the dropdown list value
self._setText(self.dropdownText, currentText);

self.dropdownText.trigger("internal-change");
self.triggerEvent("change");

}

Expand Down Expand Up @@ -1648,7 +1651,7 @@

var self = this,
// Finds the currently option index
currentIndex = self.options["showFirstOption"] ? self.currentFocus : ((self.currentFocus - 1) >= 0 ? self.currentFocus: 0 );
currentIndex = self.options["showFirstOption"] ? self.currentFocus : ((self.currentFocus - 1) >= 0 ? self.currentFocus: 0);

// Triggers the custom option-click event on the original select box and passes the select box option
self.selectBox.trigger(eventName, { "elem": self.selectBox.eq(currentIndex), "dropdown-elem": self.listItems.eq(self.currentFocus) });
Expand Down
6 changes: 3 additions & 3 deletions src/javascripts/jquery.selectBoxIt.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/stylesheets/jquery.selectBoxIt.css
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
cursor: not-allowed;
cursor: default;
}

/* Button Text */
Expand All @@ -81,8 +81,8 @@
.selectboxit-container .selectboxit-options {
-moz-box-sizing: border-box;
box-sizing: border-box;
min-width: 100%; /* Minimum Width of the dropdown list box options */
*width: 100%;
min-width: 220px; /* Minimum Width of the dropdown list box options */
*width: 220px;
margin: 0;
padding: 0;
list-style: none;
Expand Down
6 changes: 3 additions & 3 deletions test/SpecRunner.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
<link rel="stylesheet" type="text/css" href="../src/stylesheets/SelectBoxIt/jQuery.selectBoxIt.css" />
<link rel="stylesheet" type="text/css" href="../libs/jasmine/jasmine.css">
<script type="text/javascript" src="../libs/jasmine/jasmine.js"></script>
<script type="text/javascript" src="../libs/jquery/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="../libs/jasmine/jasmine-jquery-1.3.1.js"></script>
<script type="text/javascript" src="../libs/jquery/jquery.js"></script>
<script type="text/javascript" src="../libs/jasmine/jasmine-jquery.js"></script>
<script type="text/javascript" src="../libs/jasmine/jasmine-html.js"></script>

<!-- include source files here... -->
<script type="text/javascript" src="../libs/jqueryUI/jquery-ui-1.9.1.custom.min.js"></script>
<script type="text/javascript" src="../libs/jqueryUI/jquery-ui.js"></script>
<script src="../src/javascripts/jquery.selectBoxIt.min.js"></script>

<!-- include spec files here... -->
Expand Down

0 comments on commit a30aee4

Please sign in to comment.