Merge pull request #661 from Alfresco/dev-denys-657

#657 Enforce single-click navigation for mobile browsers
This commit is contained in:
Mario Romano 2016-09-01 09:37:24 -04:00 committed by GitHub
commit 1b0f107d77
2 changed files with 16 additions and 31 deletions

View File

@ -492,35 +492,11 @@ describe('DocumentList', () => {
expect(documentList.displayFolderContent).not.toHaveBeenCalled(); expect(documentList.displayFolderContent).not.toHaveBeenCalled();
}); });
// TODO: move to data adapter it('should enforce single-click on mobile browser', () => {
/* spyOn(documentList, 'isMobile').and.returnValue(true);
it('should sort by dates up to ms', () => { documentList.navigationMode = DocumentList.DOUBLE_CLICK_NAVIGATION;
let file1 = new FileNode(); documentList.ngOnInit();
file1.entry['dateProp'] = new Date(2016, 6, 30, 13, 14, 1); expect(documentList.isMobile).toHaveBeenCalled();
expect(documentList.navigationMode).toBe(DocumentList.SINGLE_CLICK_NAVIGATION);
let file2 = new FileNode();
file2.entry['dateProp'] = new Date(2016, 6, 30, 13, 14, 2);
let page = new PageNode([file1, file2]);
// desc
documentList.sort(page, new ColumnSortingModel({
key: 'dateProp',
direction: 'desc'
}));
expect(page.list.entries[0]).toBe(file2);
expect(page.list.entries[1]).toBe(file1);
// asc
documentList.sort(page, new ColumnSortingModel({
key: 'dateProp',
direction: 'asc'
}));
expect(page.list.entries[0]).toBe(file1);
expect(page.list.entries[1]).toBe(file2);
}); });
*/
}); });

View File

@ -77,7 +77,7 @@ export class DocumentList implements OnInit, AfterViewInit, AfterViewChecked, Af
navigate: boolean = true; navigate: boolean = true;
@Input() @Input()
navigationMode: string = 'dblclick'; // click|dblclick navigationMode: string = DocumentList.DOUBLE_CLICK_NAVIGATION; // click|dblclick
@Input() @Input()
thumbnails: boolean = false; thumbnails: boolean = false;
@ -184,6 +184,11 @@ export class DocumentList implements OnInit, AfterViewInit, AfterViewChecked, Af
this.data.thumbnails = this.thumbnails; this.data.thumbnails = this.thumbnails;
this.data.maxItems = this.pageSize; this.data.maxItems = this.pageSize;
this.contextActionHandler.subscribe(val => this.contextActionCallback(val)); this.contextActionHandler.subscribe(val => this.contextActionCallback(val));
// Automatically enforce single-click navigation for mobile browsers
if (this.isMobile()) {
this.navigationMode = DocumentList.SINGLE_CLICK_NAVIGATION;
}
} }
ngAfterContentInit() { ngAfterContentInit() {
@ -206,6 +211,10 @@ export class DocumentList implements OnInit, AfterViewInit, AfterViewChecked, Af
if (componentHandler) { if (componentHandler) {
componentHandler.upgradeAllRegistered(); componentHandler.upgradeAllRegistered();
} }
}
isMobile(): boolean {
return !!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
} }