Commits

Anton Shestakov committed 1c231df

Filter input wrap: ability to reliably set width: 100% without box-sizing.

Comments (0)

Files changed (2)

            -moz-border-radius: 4px;
                 border-radius: 4px;
       }
+      .lensy-filter-wrap {
+        padding-right: 6px;
+      }
       .lensy-filter {
         width: 100%;
       }
                 .attr('type', 'text')
                 .addClass(this.settings.filterClass);
             
+            this.$filterWrap = $('<div>')
+                .addClass(this.settings.filterWrapClass)
+                .append(this.$filter);
+
             this.$container = $('<ul>')
                 .addClass(this.settings.containerClass);
             
             
             this.$modal = $('<div>')
                 .addClass(this.settings.modalClass)
-                .append(this.$filter)
+                .append(this.$filterWrap)
                 .append(this.$container)
                 .append(this.$closeButton)
                 .appendTo('body')
             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();
         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);