Lines Matching full:this

10  * you may not use this file except in compliance with the License.
31 this.$element = jQuery(element);
32 this.options = jQuery.extend({}, Typeahead.defaults, options);
33 this.matcher = this.options.matcher || this.matcher;
34 this.sorter = this.options.sorter || this.sorter;
35 this.select = this.options.select || this.select;
36 this.autoSelect = typeof this.options.autoSelect == 'boolean' ? this.options.autoSelect : true;
37 this.highlighter = this.options.highlighter || this.highlighter;
38 this.render = this.options.render || this.render;
39 this.updater = this.options.updater || this.updater;
40 this.displayText = this.options.displayText || this.displayText;
41 this.itemLink = this.options.itemLink || this.itemLink;
42 this.itemTitle = this.options.itemTitle || this.itemTitle;
43 this.followLinkOnSelect = this.options.followLinkOnSelect || this.followLinkOnSelect;
44 this.source = this.options.source;
45 this.delay = this.options.delay;
46this.theme = this.options.theme && this.options.themes && this.options.themes[this.options.theme] …
47 this.$menu = jQuery(this.options.menu || this.theme.menu);
48 this.$appendTo = this.options.appendTo ? jQuery(this.options.appendTo) : null;
49this.fitToElement = typeof this.options.fitToElement == 'boolean' ? this.options.fitToElement : fa…
50 this.shown = false;
51 this.listen();
52this.showHintOnFocus = typeof this.options.showHintOnFocus == 'boolean' || this.options.showHintOn…
53 this.afterSelect = this.options.afterSelect;
54 this.afterEmptySelect = this.options.afterEmptySelect;
55 this.addItem = false;
56 this.value = this.$element.val() || this.$element.text();
57 this.keyPressed = false;
58 this.focused = this.$element.is(':focus');
59 this.changeInputOnSelect = this.options.changeInputOnSelect || this.changeInputOnSelect;
60 this.changeInputOnMove = this.options.changeInputOnMove || this.changeInputOnMove;
61 this.openLinkInNewTab = this.options.openLinkInNewTab || this.openLinkInNewTab;
62 this.selectOnBlur = this.options.selectOnBlur || this.selectOnBlur;
63 this.showCategoryHeader = this.options.showCategoryHeader || this.showCategoryHeader;
72 // var val = this.$menu.find('.active').data('value');
73 this.$element.data('active', val);
74 if (this.autoSelect || val) {
75 var newVal = this.updater(val);
81 this.$element
82 .val(this.displayText(newVal) || newVal)
83 .text(this.displayText(newVal) || newVal)
85 this.afterSelect(newVal);
87 return this.hide();
91 var val = this.$menu.find('.active').data('value');
93 this.$element.data('active', val);
94 if (this.autoSelect || val) {
95 var newVal = this.updater(val);
102 if (this.changeInputOnSelect) {
103 this.$element
104 .val(this.displayText(newVal) || newVal)
105 .text(this.displayText(newVal) || newVal)
109 if (this.followLinkOnSelect && this.itemLink(val)) {
110 if (this.openLinkInNewTab) {
111 window.open(this.itemLink(val), '_blank');
113 document.location = this.itemLink(val);
115 this.afterSelect(newVal);
116 } else if (this.followLinkOnSelect && !this.itemLink(val)) {
117 this.afterEmptySelect(newVal);
119 this.afterSelect(newVal);
122 this.afterEmptySelect();
125 return this.hide();
133 this.source = source;
137 var pos = jQuery.extend({}, this.$element.position(), {
138 height: this.$element[0].offsetHeight
141 var scrollHeight = typeof this.options.scrollHeight == 'function' ?
142 this.options.scrollHeight.call() :
143 this.options.scrollHeight;
146 if (this.shown) {
147 element = this.$menu;
148 } else if (this.$appendTo) {
149 element = this.$menu.appendTo(this.$appendTo);
150 this.hasSameParent = this.$appendTo.is(this.$element.parent());
152 element = this.$menu.insertAfter(this.$element);
153 this.hasSameParent = true;
156 if (!this.hasSameParent) {
159 var offset = this.$element.offset();
174 if (this.options.fitToElement === true) {
175 element.css('width', this.$element.outerWidth() + 'px');
178 this.shown = true;
179 return this;
183 this.$menu.hide();
184 this.shown = false;
185 return this;
190 this.query = query;
192 this.query = this.$element.val();
195 if (this.query.length < this.options.minLength && !this.options.showHintOnFocus) {
196 return this.shown ? this.hide() : this;
204 if (jQuery.isFunction(this.source) && this.source.length === 3) {
205this.source(this.query, jQuery.proxy(this.process, this), jQuery.proxy(this.process, this));
206 } else if (jQuery.isFunction(this.source)) {
207 this.source(this.query, jQuery.proxy(this.process, this));
208 } else if (this.source) {
209 this.process(this.source);
211 }, this);
213 clearTimeout(this.lookupWorker);
214 this.lookupWorker = setTimeout(worker, this.delay);
218 var that = this;
224 items = this.sorter(items);
226 if (!items.length && !this.options.addItem) {
227 return this.shown ? this.hide() : this;
231 this.$element.data('active', items[0]);
233 this.$element.data('active', null);
236 if (this.options.items != 'all') {
237 items = items.slice(0, this.options.items);
241 if (this.options.addItem) {
242 items.push(this.options.addItem);
245 return this.render(items).show();
249 var it = this.displayText(item);
250 return ~it.toLowerCase().indexOf(this.query.toLowerCase());
260 var it = this.displayText(item);
261 if (!it.toLowerCase().indexOf(this.query.toLowerCase())) {
263 } else if (~it.indexOf(this.query)) {
274 var text = this.query;
312 var that = this;
313 var self = this;
326 this.showCategoryHeader = true;
327 if (this.showCategoryHeader) {
366 if (this.autoSelect && !activeFound) {
368 this.$element.data('active', items.first().data('value'));
370 this.$menu.html(items);
371 return this;
387 var active = this.$menu.find('.active').removeClass('active');
391 … next = jQuery(this.$menu.find(jQuery(this.options.item || this.theme.item).prop('tagName'))[0]);
400 var newVal = this.updater(next.data('value'));
401 if (this.changeInputOnMove) {
402 this.$element.val(this.displayText(newVal) || newVal);
407 var active = this.$menu.find('.active').removeClass('active');
411 … prev = this.$menu.find(jQuery(this.options.item || this.theme.item).prop('tagName')).last();
420 var newVal = this.updater(prev.data('value'));
421 if (this.changeInputOnMove) {
422 this.$element.val(this.displayText(newVal) || newVal);
427 this.$element
428 .on('focus.bootstrap3Typeahead', jQuery.proxy(this.focus, this))
429 .on('blur.bootstrap3Typeahead', jQuery.proxy(this.blur, this))
430 .on('keypress.bootstrap3Typeahead', jQuery.proxy(this.keypress, this))
431 ….on('propertychange.bootstrap3Typeahead input.bootstrap3Typeahead', jQuery.proxy(this.input, this))
432 .on('keyup.bootstrap3Typeahead', jQuery.proxy(this.keyup, this));
434 if (this.eventSupported('keydown')) {
435 this.$element.on('keydown.bootstrap3Typeahead', jQuery.proxy(this.keydown, this));
438 var itemTagName = jQuery(this.options.item || this.theme.item).prop('tagName');
440 this.$menu
441 .on('touchstart', itemTagName, jQuery.proxy(this.touchstart, this))
442 .on('touchend', itemTagName, jQuery.proxy(this.click, this))
443 .on('click', jQuery.proxy(this.click, this))
444 .on('mouseenter', itemTagName, jQuery.proxy(this.mouseenter, this))
445 .on('mouseleave', itemTagName, jQuery.proxy(this.mouseleave, this))
446 .on('mousedown', jQuery.proxy(this.mousedown, this));
448 this.$menu
449 .on('touchstart', itemTagName, jQuery.proxy(this.touchstart, this))
450 .on('touchend', itemTagName, jQuery.proxy(this.click, this));
452 this.$menu
453 .on('click', jQuery.proxy(this.click, this))
454 .on('mouseenter', itemTagName, jQuery.proxy(this.mouseenter, this))
455 .on('mouseleave', itemTagName, jQuery.proxy(this.mouseleave, this))
456 .on('mousedown', jQuery.proxy(this.mousedown, this));
461 this.$element.data('typeahead', null);
462 this.$element.data('active', null);
463 this.$element
470 if (this.eventSupported('keydown')) {
471 this.$element.unbind('keydown.bootstrap3-typeahead');
474 this.$menu.remove();
475 this.destroyed = true;
479 var isSupported = eventName in this.$element;
481 this.$element.setAttribute(eventName, 'return;');
482 isSupported = typeof this.$element[eventName] === 'function';
488 if (!this.shown) {
500 // with the shiftKey (this is actually the left parenthesis)
505 this.prev();
509 // with the shiftKey (this is actually the right parenthesis)
514 this.next();
529 this.keyPressed = true;
530 this.suppressKeyPressRepeat = ~jQuery.inArray(e.keyCode, [40, 38, 9, 13, 27]);
531 if (!this.shown && e.keyCode == 40) {
532 this.lookup();
534 this.move(e);
539 if (this.suppressKeyPressRepeat) {
542 this.move(e);
546 // This is a fixed for IE10/11 that fires the input event when a placehoder is changed
548 var currentValue = this.$element.val() || this.$element.text();
549 if (this.value !== currentValue) {
550 this.value = currentValue;
551 this.lookup();
556 if (this.destroyed) {
568 if (!this.shown || (this.showHintOnFocus && !this.keyPressed)) {
571 this.select();
574 if (!this.shown) {
577 this.select();
581 if (!this.shown) {
584 this.hide();
591 if (!this.focused) {
592 this.focused = true;
593 this.keyPressed = false;
594 if (this.options.showHintOnFocus && this.skipShowHintOnFocus !== true) {
595 if (this.options.showHintOnFocus === 'all') {
596 this.lookup('');
598 this.lookup();
602 if (this.skipShowHintOnFocus) {
603 this.skipShowHintOnFocus = false;
608 if (!this.mousedover && !this.mouseddown && this.shown) {
609 if (this.selectOnBlur) {
610 this.select();
612 this.hide();
613 this.focused = false;
614 this.keyPressed = false;
615 } else if (this.mouseddown) {
616 // This is for IE that blurs the input when user clicks on scroll.
618 this.skipShowHintOnFocus = true;
619 this.$element.focus();
620 this.mouseddown = false;
626 this.skipShowHintOnFocus = true;
627 this.select();
628 this.$element.focus();
629 this.hide();
633 this.mousedover = true;
634 this.$menu.find('.active').removeClass('active');
639 this.mousedover = false;
640 if (!this.focused && this.shown) {
641 this.hide();
649 this.mouseddown = true;
650 this.$menu.one('mouseup', function (e) {
651 // IE won't fire this, but FF and Chrome will so we reset our flag for them here
652 this.mouseddown = false;
653 }.bind(this));
658 this.$menu.find('.active').removeClass('active');
664 this.select();
665 this.$element.focus();
679 return this.data('active');
681 return this.each(function () {
682 var $this = jQuery(this);
683 var data = $this.data('typeahead');
686 $this.data('typeahead', (data = new Typeahead(this, options)));
741 return this;
749 var $this = jQuery(this);
750 if ($this.data('typeahead')) {
753 $this.typeahead($this.data());