mirror of
https://github.com/xuthus83/pigallery2.git
synced 2024-11-03 21:04:03 +08:00
adding autocomplete icons
This commit is contained in:
parent
b96d083f4b
commit
eb46c53bbb
@ -4,7 +4,7 @@
|
||||
<div class="photo-name">{{gridPhoto.photo.name}}</div>
|
||||
|
||||
<div class="photo-position" *ngIf="gridPhoto.photo.metadata.positionData">
|
||||
<span class="glyphicon glyphicon-globe"></span>
|
||||
<span class="glyphicon glyphicon-map-marker"></span>
|
||||
<a *ngIf="gridPhoto.photo.metadata.positionData.city || gridPhoto.photo.metadata.positionData.state || gridPhoto.photo.metadata.positionData.country">
|
||||
{{gridPhoto.photo.metadata.positionData.city || gridPhoto.photo.metadata.positionData.state ||
|
||||
gridPhoto.photo.metadata.positionData.country}}
|
||||
|
@ -4,13 +4,19 @@
|
||||
<input type="text" class="form-control" placeholder="Search" (keyup)="onSearchChange($event)"
|
||||
(blur)="onFocusLost($event)" (focus)="onFocus($evnet)" [(ngModel)]="searchText" #name="ngForm"
|
||||
ngControl="search"
|
||||
name="srch-term" id="srch-term" autocomplete="off" >
|
||||
name="srch-term" id="srch-term" autocomplete="off">
|
||||
|
||||
<div class="autocomplete-list" *ngIf="autoCompleteItems.length > 0" >
|
||||
<div class="autocomplete-item" *ngFor="let item of autoCompleteItems" (mousedown)="search(item)">
|
||||
{{item.preText}}<strong>{{item.highLightText}}</strong>{{item.postText}}
|
||||
</div>
|
||||
<div class="autocomplete-list" *ngIf="autoCompleteItems.length > 0">
|
||||
<div class="autocomplete-item" *ngFor="let item of autoCompleteItems" (mousedown)="search(item)">
|
||||
<span [ngSwitch]="item.type">
|
||||
<span *ngSwitchWhen="0" class="glyphicon glyphicon-picture"></span>
|
||||
<span *ngSwitchWhen="1" class="glyphicon glyphicon-folder-open"></span>
|
||||
<span *ngSwitchWhen="2" class="glyphicon glyphicon-tag"></span>
|
||||
<span *ngSwitchWhen="3" class="glyphicon glyphicon-map-marker"></span>
|
||||
</span>
|
||||
{{item.preText}}<strong>{{item.highLightText}}</strong>{{item.postText}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="input-group-btn" style="display: block">
|
||||
<button class="btn btn-default dropdown-toggle" type="button" (click)="onSearch()"><i
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
import {Component} from "@angular/core";
|
||||
import {AutoCompleteService} from "./autocomplete.service";
|
||||
import {AutoCompleteItem} from "../../../../common/entities/AutoCompleteItem";
|
||||
import {AutoCompleteItem, AutoCompeleteTypes} from "../../../../common/entities/AutoCompleteItem";
|
||||
import {Message} from "../../../../common/entities/Message";
|
||||
import {GalleryService} from "../gallery.service";
|
||||
import {FORM_DIRECTIVES} from "@angular/common";
|
||||
@ -82,8 +82,8 @@ export class GallerySearchComponent {
|
||||
|
||||
private showSuggestions(suggestions:Array<AutoCompleteItem>, searchText:string) {
|
||||
this.emptyAutoComplete();
|
||||
suggestions.forEach((item)=> {
|
||||
let renderItem = new AutoCompleteRenderItem(item.text, searchText);
|
||||
suggestions.forEach((item:AutoCompleteItem)=> {
|
||||
let renderItem = new AutoCompleteRenderItem(item.text, searchText, item.type);
|
||||
this.autoCompleteItems.push(renderItem);
|
||||
});
|
||||
}
|
||||
@ -94,8 +94,9 @@ class AutoCompleteRenderItem {
|
||||
public preText:string = "";
|
||||
public highLightText:string = "";
|
||||
public postText:string = "";
|
||||
public type:AutoCompeleteTypes;
|
||||
|
||||
constructor(public text:string, searchText:string) {
|
||||
constructor(public text:string, searchText:string, type:AutoCompeleteTypes) {
|
||||
let preIndex = text.toLowerCase().indexOf(searchText.toLowerCase());
|
||||
if (preIndex > -1) {
|
||||
this.preText = text.substring(0, preIndex);
|
||||
@ -104,6 +105,7 @@ class AutoCompleteRenderItem {
|
||||
} else {
|
||||
this.postText = text;
|
||||
}
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user