Download:
child 6:d98a02185a99
parent 4:88f00d65652c
5:1c231df1a171
Anton Shestakov <engored@ya.ru>, Wed, 15 May 2013 18:12:07 +0900
Filter input wrap: ability to reliably set width: 100% without box-sizing.

2 файлов изменено, 12 вставок(+), 3 удалений(-) [+]
demo.html file | annotate | diff | comparison | revisions
jquery.lensy.js file | annotate | diff | comparison | revisions
--- a/demo.html Fri May 10 20:31:49 2013 +0900
+++ b/demo.html Wed May 15 18:12:07 2013 +0900
@@ -117,6 +117,9 @@
-moz-border-radius: 4px;
border-radius: 4px;
}
+ .lensy-filter-wrap {
+ padding-right: 6px;
+ }
.lensy-filter {
width: 100%;
}
--- a/jquery.lensy.js Fri May 10 20:31:49 2013 +0900
+++ b/jquery.lensy.js Wed May 15 18:12:07 2013 +0900
@@ -15,6 +15,10 @@
.attr('type', 'text')
.addClass(this.settings.filterClass);
+ this.$filterWrap = $('<div>')
+ .addClass(this.settings.filterWrapClass)
+ .append(this.$filter);
+
this.$container = $('<ul>')
.addClass(this.settings.containerClass);
@@ -28,7 +32,7 @@
this.$modal = $('<div>')
.addClass(this.settings.modalClass)
- .append(this.$filter)
+ .append(this.$filterWrap)
.append(this.$container)
.append(this.$closeButton)
.appendTo('body')
@@ -72,7 +76,8 @@
this.$container.find('[data-original-value]').each(function() {
var $item = $(this);
var value = $item.attr('data-original-value');
- if (self.settings.filterFn(self.$filter.val(), value, $item)) {
+ var text = $item.attr('data-original-text');
+ if (self.settings.filterFn(self.$filter.val(), value, text, $item)) {
$item.show();
} else {
$item.hide();
@@ -152,11 +157,12 @@
closeButtonClass: 'lensy-button',
modalClass: 'lensy-modal',
filterClass: 'lensy-filter',
+ filterWrapClass: 'lensy-filter-wrap',
widgetClass: 'lensy-widget',
itemClass: 'lensy-item',
itemActiveClass: 'active',
itemFn: function(value, text) { return $('<span>').text(text); },
widgetItemFn: undefined,
- filterFn: function(filterString, value) { return value.toLowerCase().indexOf(filterString.toLowerCase()) != -1; }
+ filterFn: function(filterString, value, text) { return text.toLowerCase().indexOf(filterString.toLowerCase()) != -1; }
};
})(jQuery);