Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
Conflicts:
	dist/css/foundation-select.min.css
  • Loading branch information
Samuel Moncarey committed Jan 9, 2018
2 parents 9c4cd70 + 17030bf commit a546d77
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 16 deletions.
11 changes: 8 additions & 3 deletions dist/css/foundation-select.css
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@
cursor: pointer;
border-radius: 0; }
.select-wrapper .select-container input[aria-expanded="true"] {
border-radius: 0 0 0 0; }
border-radius: 0 0 0 0;
border: 1px solid #8a8a8a;
-webkit-box-shadow: 0 0 5px #cacaca;
box-shadow: 0 0 5px #cacaca;
outline: none; }
.select-wrapper .select-container .select-dropdown, .select-wrapper .select-container .multiple-select {
background-color: #fefefe;
border: 1px solid #cacaca;
Expand Down Expand Up @@ -151,7 +155,8 @@
right: 0;
color: #8a8a8a;
padding: 0.5rem;
line-height: 1.5;
line-height: 1.4375rem;
width: 2.5rem;
text-align: center;
cursor: pointer; }
cursor: pointer;
vertical-align: bottom; }
21 changes: 19 additions & 2 deletions dist/js/foundation.select.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
'id': $ddId,
'class': 'select-dropdown',
'data-dropdown': '',
'data-v-offset': 0,
'data-v-offset': this.options.dropdownOffset,
'data-h-offset': 0,
'data-close-on-click': true
});
Expand All @@ -128,6 +128,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons

this.$options = {};
this.$autoSelect = [];
this._setPlaceholderOption();
this.$select.find('option').each(this._setOption.bind(this));

this.$element.attr('placeholder', this.options.placeholder);
Expand All @@ -142,6 +143,17 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
});
}
}
}, {
key: '_setPlaceholderOption',
value: function _setPlaceholderOption() {
var hasEmptyOption = void 0;
this.$select.find('option').each(function (index, option) {
if ($(option).val() == '') hasEmptyOption = true;
});
if (!hasEmptyOption && this.options.placeholder != '') {
this.$select.prepend($('<option value="">' + this.options.placeholder + '</option>'));
}
}
}, {
key: '_setOption',
value: function _setOption(index, option) {
Expand Down Expand Up @@ -267,6 +279,10 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
});
});

this.$dropdown.on('show.zf.dropdown', function () {
_this.$element.focus();
});

$.each(this.$options, function (index, option) {
var $target = $(option).find('a');
$target.on('click', _this.select.bind(_this));
Expand Down Expand Up @@ -328,7 +344,8 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
iconClass: 'fa-caret-down',
placeholder: '',
value: '',
mousewheel: true
mousewheel: true,
dropdownOffset: 0
};
}
}]);
Expand Down
2 changes: 1 addition & 1 deletion dist/js/foundation.select.min.js

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

16 changes: 15 additions & 1 deletion src/js/foundation.select.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
'id': $ddId,
'class': 'select-dropdown',
'data-dropdown': '',
'data-v-offset': 0,
'data-v-offset': this.options.dropdownOffset,
'data-h-offset': 0,
'data-close-on-click': true
});
Expand All @@ -118,6 +118,7 @@

this.$options = {};
this.$autoSelect = [];
this._setPlaceholderOption();
this.$select.find('option').each(this._setOption.bind(this));

this.$element.attr('placeholder', this.options.placeholder);
Expand All @@ -133,6 +134,16 @@
}
}

_setPlaceholderOption() {
let hasEmptyOption;
this.$select.find('option').each((index, option) => {
if ($(option).val() == '') hasEmptyOption = true
});
if (!hasEmptyOption && this.options.placeholder != '') {
this.$select.prepend($(`<option value="">${this.options.placeholder}</option>`));
}
}

_setOption(index, option) {
let value = $(option).val(), text = $(option).text();
if (value == '') {
Expand Down Expand Up @@ -252,6 +263,8 @@
});
});

this.$dropdown.on('show.zf.dropdown', () => { _this.$element.focus(); });

$.each(this.$options, (index, option) => {
let $target = $(option).find('a');
$target.on('click', _this.select.bind(_this));
Expand Down Expand Up @@ -313,6 +326,7 @@
placeholder: '',
value: '',
mousewheel: true,
dropdownOffset: 0
};
}
}
Expand Down
Loading

0 comments on commit a546d77

Please sign in to comment.