Skip to content

Commit

Permalink
Merge pull request #43 from SengitU/master
Browse files Browse the repository at this point in the history
Resolved a bug related to display-type text
  • Loading branch information
bcinarli authored Nov 8, 2016
2 parents 253167a + 0d043ba commit a9a21d0
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 41 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "uxrocket.select",
"version": "3.5.7",
"version": "3.5.8",
"homepage": "https://github.com/uxrocket/uxrocket.select",
"authors": [
"Bilal Çınarlı <[email protected]>"
Expand Down
43 changes: 27 additions & 16 deletions dist/uxrocket.select.js
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@
Select.prototype.unbindUI = function() {
this.emitEvent('destroy');
this.$selection.off('.' + rocketName);
this.$selection.parent().off('.' + rocketName);
this.$el.off('.' + rocketName);
};

Expand Down Expand Up @@ -584,23 +585,29 @@
if(!this.$drop) {
this.prepareDrop();
} else {
this.$drop.find('[data-value="' + value + '"]').parent().removeClass(selected)
this.$drop.find('[data-value="' + value + '"]').parent().removeClass(selected);
}

this.$el.find('[value="' + value + '"]').removeAttr('selected');
option.removeClass(selected);
this.$selection.find('[data-value="' + value + '"]').remove();
this.$el.val($.grep(this.$el.val(), function(val) {
return val !== value;
}));

if(this.multiple && this.options.displayType !== 'tags' && this.$el.val() !== null) {
this.$selection
.find('.' + selectionText)
.html(this.options.multipleInfoMessage + ' ' + this.$el.val().length + '/' + this.optionData.length);
if(this.$el.val()) {
this.$el.val($.grep(this.$el.val(), function(val) {
return val !== value;
}));
}

if(this.multiple && this.options.displayType === 'tags' && this.$el.val().length < 1) {
if(this.multiple && this.options.displayType !== 'tags') {
var $selection = this.$selection.find('.' + selectionText);
if(this.$el.val()) {
$selection.html(this.options.multipleInfoMessage + ' ' + this.$el.val().length + '/' + this.optionData.length);
}
else {
$selection.html(this.options.multipleInfoMessage + ' ' + 0 + '/' + this.optionData.length);
}
}

if(this.multiple && this.options.displayType === 'tags' && (this.$el.val() === null || this.$el.val().length < 1)) {
this.$selection.find('.' + selectionText).text(this.multiplePlaceholder);
}

Expand Down Expand Up @@ -826,16 +833,16 @@
minWidth: this.$selection.outerWidth()
};
var optionList = $('.uxr-select-list');
var dropHeight = this.$drop.height();
var dropHeight = this.$drop.height() > 280 ? 280 : this.$drop.height(); // Max-height with search field
var totalVisibleHeight = document.documentElement.clientHeight;
var topSpace = (this.$el.offset().top - $(window).scrollTop()) > 250 ? 250 : this.$el.offset().top - $(window).scrollTop();
var bottomSpace = ((totalVisibleHeight - topSpace) - this.$selection.height()) > 250 ? 250 :(totalVisibleHeight - topSpace) - this.$selection.height();
var topSpace = this.$el.offset().top - $(window).scrollTop();
var bottomSpace = (totalVisibleHeight - topSpace) - this.$selection.height();
var setPosition = {
top: function(){
optionList.css( { maxHeight: topSpace } );
optionList.css( { maxHeight: topSpace > 250 ? 250 : topSpace} ); // Max-height for options
},
bottom: function(){
optionList.css( { maxHeight: bottomSpace } );
optionList.css( { maxHeight: bottomSpace > 250 ? 250 : bottomSpace } );
}
};
if( bottomSpace >= dropHeight ){
Expand Down Expand Up @@ -1001,6 +1008,10 @@
focusedInstances.current = null;
}

if(focusedInstances.current && focusedInstances.current.el === this.$el[0]) {
focusedInstances.current = null;
}

this.unbindUI();
this.undecorateUI();

Expand Down Expand Up @@ -1159,7 +1170,7 @@
});

// version
ux.version = '3.5.7';
ux.version = '3.5.8';

// default settings
ux.settings = defaults;
Expand Down
4 changes: 2 additions & 2 deletions dist/uxrocket.select.min.css

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

6 changes: 3 additions & 3 deletions dist/uxrocket.select.min.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3480,7 +3480,6 @@
console.log('Selected Text: ' + $el.text());
}
}

var $s = $('#sample-01').data('uxrSelect');
</script>
</body>
Expand Down
43 changes: 27 additions & 16 deletions lib/uxrocket.select.js
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@
Select.prototype.unbindUI = function() {
this.emitEvent('destroy');
this.$selection.off('.' + rocketName);
this.$selection.parent().off('.' + rocketName);
this.$el.off('.' + rocketName);
};

Expand Down Expand Up @@ -584,23 +585,29 @@
if(!this.$drop) {
this.prepareDrop();
} else {
this.$drop.find('[data-value="' + value + '"]').parent().removeClass(selected)
this.$drop.find('[data-value="' + value + '"]').parent().removeClass(selected);
}

this.$el.find('[value="' + value + '"]').removeAttr('selected');
option.removeClass(selected);
this.$selection.find('[data-value="' + value + '"]').remove();
this.$el.val($.grep(this.$el.val(), function(val) {
return val !== value;
}));

if(this.multiple && this.options.displayType !== 'tags' && this.$el.val() !== null) {
this.$selection
.find('.' + selectionText)
.html(this.options.multipleInfoMessage + ' ' + this.$el.val().length + '/' + this.optionData.length);
if(this.$el.val()) {
this.$el.val($.grep(this.$el.val(), function(val) {
return val !== value;
}));
}

if(this.multiple && this.options.displayType === 'tags' && this.$el.val().length < 1) {
if(this.multiple && this.options.displayType !== 'tags') {
var $selection = this.$selection.find('.' + selectionText);
if(this.$el.val()) {
$selection.html(this.options.multipleInfoMessage + ' ' + this.$el.val().length + '/' + this.optionData.length);
}
else {
$selection.html(this.options.multipleInfoMessage + ' ' + 0 + '/' + this.optionData.length);
}
}

if(this.multiple && this.options.displayType === 'tags' && (this.$el.val() === null || this.$el.val().length < 1)) {
this.$selection.find('.' + selectionText).text(this.multiplePlaceholder);
}

Expand Down Expand Up @@ -826,16 +833,16 @@
minWidth: this.$selection.outerWidth()
};
var optionList = $('.uxr-select-list');
var dropHeight = this.$drop.height();
var dropHeight = this.$drop.height() > 280 ? 280 : this.$drop.height(); // Max-height with search field
var totalVisibleHeight = document.documentElement.clientHeight;
var topSpace = (this.$el.offset().top - $(window).scrollTop()) > 250 ? 250 : this.$el.offset().top - $(window).scrollTop();
var bottomSpace = ((totalVisibleHeight - topSpace) - this.$selection.height()) > 250 ? 250 :(totalVisibleHeight - topSpace) - this.$selection.height();
var topSpace = this.$el.offset().top - $(window).scrollTop();
var bottomSpace = (totalVisibleHeight - topSpace) - this.$selection.height();
var setPosition = {
top: function(){
optionList.css( { maxHeight: topSpace } );
optionList.css( { maxHeight: topSpace > 250 ? 250 : topSpace} ); // Max-height for options
},
bottom: function(){
optionList.css( { maxHeight: bottomSpace } );
optionList.css( { maxHeight: bottomSpace > 250 ? 250 : bottomSpace } );
}
};
if( bottomSpace >= dropHeight ){
Expand Down Expand Up @@ -1001,6 +1008,10 @@
focusedInstances.current = null;
}

if(focusedInstances.current && focusedInstances.current.el === this.$el[0]) {
focusedInstances.current = null;
}

this.unbindUI();
this.undecorateUI();

Expand Down Expand Up @@ -1159,7 +1170,7 @@
});

// version
ux.version = '3.5.7';
ux.version = '3.5.8';

// default settings
ux.settings = defaults;
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": "uxrocket.select",
"version": "3.5.7",
"version": "3.5.8",
"description": "jQuery based Select box replacement function",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion uxrocket.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Select",
"registry": "uxrocket.select",
"version": "3.5.7",
"version": "3.5.8",
"paths": {
"lib": "lib/",
"dist": "dist/",
Expand Down
5 changes: 5 additions & 0 deletions version.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## Versiyon 3.5.8
- FIX: Display-type text durumunda seçim sayısının sıfır olmaması problemi giderildi.
- FIX: Drop pozisyonunun hesaplanmasındaki bir yanlışlık düzeltildi.
- FIX: Component remove edildikten sonra da çalışan bir event düzeltildi.

## Versiyon 3.5.7
- FIX: Display-type text olması durumunda pre-selected verilerin tag şeklinde gözükmesi problemi giderildi.
- FIX: Display-type tag olması durumunda pre-selected verilerin çalışması düzenlendi.
Expand Down

0 comments on commit a9a21d0

Please sign in to comment.