searchpicker
Advanced tools
Comparing version 1.0.11 to 1.0.12
@@ -15,2 +15,3 @@ import { EventObject } from "./EventObject"; | ||
private searchTmrId; | ||
private isMobile; | ||
constructor(container: any, options: ISearchPickerOptions); | ||
@@ -36,1 +37,2 @@ getChoices(): IPickerItem[]; | ||
} | ||
export declare function isMobile(): boolean; |
@@ -25,2 +25,3 @@ "use strict"; | ||
_this.searchTmrId = null; | ||
_this.isMobile = isMobile(); | ||
_this.options = _this.extendOptions(new DefaultSearchPickerOptions_1.DefaultSearchPickerOptions(), options); | ||
@@ -61,3 +62,3 @@ _this.setupHtml(); | ||
this.applyTemplate(); | ||
this.choices = new SearchPickerChoices_1.SearchPickerChoices(this.choicesElm, this.options); | ||
this.choices = new SearchPickerChoices_1.SearchPickerChoices(this.choicesElm, this.options, this.isMobile); | ||
this.results = new SearchPickerResults_1.SearchPickerResults(this.choicesElm, this.options); | ||
@@ -163,2 +164,12 @@ }; | ||
exports.SearchPicker = SearchPicker; | ||
function isMobile() { | ||
return !!(navigator.userAgent.match(/Android/i) | ||
|| navigator.userAgent.match(/webOS/i) | ||
|| navigator.userAgent.match(/iPhone/i) | ||
|| navigator.userAgent.match(/iPad/i) | ||
|| navigator.userAgent.match(/iPod/i) | ||
|| navigator.userAgent.match(/BlackBerry/i) | ||
|| navigator.userAgent.match(/Windows Phone/i)); | ||
} | ||
exports.isMobile = isMobile; | ||
//# sourceMappingURL=SearchPicker.js.map |
@@ -20,4 +20,5 @@ import { EventObject } from "./EventObject"; | ||
private shouldUpdateAutoComplete; | ||
private isMobile; | ||
private inputForbidden; | ||
constructor(container: any, options: ISearchPickerOptions); | ||
constructor(container: any, options: ISearchPickerOptions, isMobile?: boolean); | ||
addChoice(item: IPickerItem): void; | ||
@@ -55,2 +56,3 @@ removeChoice(item: IPickerItem): void; | ||
private getChoicesRange(choice1, choice2); | ||
private checkEmptiness(); | ||
} |
@@ -15,5 +15,6 @@ "use strict"; | ||
var Utils_1 = require("./Utils"); | ||
var EMPTY_PICKER_CSS_CLASS = "__empty"; | ||
var SearchPickerChoices = (function (_super) { | ||
__extends(SearchPickerChoices, _super); | ||
function SearchPickerChoices(container, options) { | ||
function SearchPickerChoices(container, options, isMobile) { | ||
var _this = _super.call(this) || this; | ||
@@ -26,2 +27,3 @@ _this.container = container; | ||
_this.pendingBackstroke = []; | ||
_this.isMobile = isMobile; | ||
_this.sizerElm = document.getElementById('__srchpicker-sizer'); | ||
@@ -40,2 +42,3 @@ if (_this.sizerElm) { | ||
this.scaleSearchField(); | ||
this.checkEmptiness(); | ||
}; | ||
@@ -49,2 +52,3 @@ SearchPickerChoices.prototype.removeChoice = function (item) { | ||
this.$notifyEvent('choiceRemoved', item); | ||
this.checkEmptiness(); | ||
return; | ||
@@ -83,3 +87,3 @@ } | ||
SearchPickerChoices.prototype.setAutocompleteText = function (text) { | ||
if (!this.shouldUpdateAutoComplete) { | ||
if (!this.shouldUpdateAutoComplete || this.isMobile) { | ||
return; | ||
@@ -254,2 +258,3 @@ } | ||
} | ||
this.checkEmptiness(); | ||
}; | ||
@@ -393,2 +398,3 @@ SearchPickerChoices.prototype.onKeyDown = function (evt) { | ||
SearchPickerChoices.prototype.applyTemplate = function () { | ||
Utils_1.Utility.addClass(this.container, EMPTY_PICKER_CSS_CLASS); | ||
this.inputJsElmWrap = document.createElement('li'); | ||
@@ -482,2 +488,10 @@ this.inputJsElmWrap.className = 'search-field'; | ||
}; | ||
SearchPickerChoices.prototype.checkEmptiness = function () { | ||
if (this.inputElm.value == "" && this.selected.length == 0) { | ||
Utils_1.Utility.addClass(this.container, EMPTY_PICKER_CSS_CLASS); | ||
} | ||
else { | ||
Utils_1.Utility.removeClass(this.container, EMPTY_PICKER_CSS_CLASS); | ||
} | ||
}; | ||
return SearchPickerChoices; | ||
@@ -484,0 +498,0 @@ }(EventObject_1.EventObject)); |
{ | ||
"name": "searchpicker", | ||
"version": "1.0.11", | ||
"version": "1.0.12", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "./lib/Index.js", |
@@ -19,5 +19,9 @@ import {EventObject} from "./EventObject"; | ||
private isMobile:boolean; | ||
constructor(private container: any | ||
, options: ISearchPickerOptions) { | ||
super(); | ||
this.isMobile = isMobile(); | ||
this.options = this.extendOptions(new DefaultSearchPickerOptions(), options); | ||
@@ -66,3 +70,3 @@ this.setupHtml(); | ||
this.applyTemplate(); | ||
this.choices = new SearchPickerChoices(this.choicesElm, this.options); | ||
this.choices = new SearchPickerChoices(this.choicesElm, this.options, this.isMobile); | ||
this.results = new SearchPickerResults(this.choicesElm, this.options); | ||
@@ -181,2 +185,14 @@ } | ||
} | ||
export function isMobile() { | ||
return !!(navigator.userAgent.match(/Android/i) | ||
|| navigator.userAgent.match(/webOS/i) | ||
|| navigator.userAgent.match(/iPhone/i) | ||
|| navigator.userAgent.match(/iPad/i) | ||
|| navigator.userAgent.match(/iPod/i) | ||
|| navigator.userAgent.match(/BlackBerry/i) | ||
|| navigator.userAgent.match(/Windows Phone/i)) | ||
} |
@@ -6,2 +6,5 @@ import {EventObject} from "./EventObject"; | ||
const EMPTY_PICKER_CSS_CLASS = "__empty"; | ||
export class SearchPickerChoices extends EventObject { | ||
@@ -25,7 +28,11 @@ | ||
private isMobile:boolean; | ||
private inputForbidden: boolean; | ||
constructor(private container: any | ||
, private options: ISearchPickerOptions) { | ||
, private options: ISearchPickerOptions, isMobile?:boolean) { | ||
super(); | ||
this.isMobile = isMobile; | ||
this.sizerElm = <HTMLDivElement>document.getElementById('__srchpicker-sizer'); | ||
@@ -44,2 +51,3 @@ if (this.sizerElm) { | ||
this.scaleSearchField(); | ||
this.checkEmptiness(); | ||
} | ||
@@ -54,2 +62,3 @@ | ||
this.$notifyEvent('choiceRemoved', item); | ||
this.checkEmptiness(); | ||
return; | ||
@@ -92,3 +101,3 @@ } | ||
setAutocompleteText(text: string) { | ||
if (!this.shouldUpdateAutoComplete) { | ||
if (!this.shouldUpdateAutoComplete || this.isMobile) { | ||
return; | ||
@@ -276,2 +285,3 @@ } | ||
if (this.canSelectMoreChoices()) { | ||
@@ -282,2 +292,4 @@ this.clearBackstroke(); | ||
} | ||
this.checkEmptiness(); | ||
} | ||
@@ -430,2 +442,4 @@ | ||
private applyTemplate(): void { | ||
Utility.addClass(this.container, EMPTY_PICKER_CSS_CLASS); | ||
this.inputJsElmWrap = document.createElement('li'); | ||
@@ -537,2 +551,10 @@ this.inputJsElmWrap.className = 'search-field'; | ||
private checkEmptiness(){ | ||
if(this.inputElm.value =="" && this.selected.length == 0){ | ||
Utility.addClass(this.container, EMPTY_PICKER_CSS_CLASS); | ||
} else { | ||
Utility.removeClass(this.container, EMPTY_PICKER_CSS_CLASS); | ||
} | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
220912
3117