Skip to content

Commit

Permalink
feat: use IOS context menu
Browse files Browse the repository at this point in the history
  • Loading branch information
volishevko committed Oct 11, 2023
1 parent f570532 commit 27051e3
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 18 deletions.
2 changes: 1 addition & 1 deletion sources/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import "./utils/polyfills";
import constants from "./constants";
import state from "./models/state";
import auth from "./services/auth";
import util from "./utils/util";
import manageLocalStorageByAppVersion from "./services/localStorageManager";
import util from "./utils/util";
import MobileHeader from "./views/header/mobileHeader";
import MobileTop from "./views/mobileTop";
import OnlyHeaderTop from "./views/onlyHeaderTop";
Expand Down
2 changes: 1 addition & 1 deletion sources/services/ajaxActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ class AjaxActions {
}

async downloadImage(url, name) {
if (util.isiPhone()) {
if (util.isIOS()) {
const title = `Download image ${name}`;
const blob = await webix.ajax().response("blob").get(`${url}`);
util.shareFile(title, blob, name);
Expand Down
18 changes: 9 additions & 9 deletions sources/services/gallery/gallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,7 @@ class GalleryService {
const fullFileUrl = currentItem.files?.full?.url;
const fileName = currentItem.isic_id;
if (fullFileUrl) {
if (util.isiPhone()) {
if (util.isIOS()) {
ajax.downloadImage(fullFileUrl, fileName);
}
// TODO: alternative
Expand All @@ -1024,7 +1024,7 @@ class GalleryService {
const fullFileUrl = obj.fullFileUrl;
const fileName = obj.imageId;
if (fullFileUrl) {
if (util.isiPhone()) {
if (util.isIOS()) {
ajax.downloadImage(fullFileUrl, fileName);
}
// TODO: alternative
Expand Down Expand Up @@ -1524,14 +1524,14 @@ class GalleryService {
this._filterScrollView.resize();
}

clearFilterForm() {
const elements = this._filtersForm.getChildViews();
for (let i = 0; i < elements.length - 1; i++) {
let element = elements[i];
i--;
this._filtersForm.removeView(element);
}
clearFilterForm() {
const elements = this._filtersForm.getChildViews();
for (let i = 0; i < elements.length - 1; i++) {
let element = elements[i];
i--;
this._filtersForm.removeView(element);
}
}
}

export default GalleryService;
10 changes: 5 additions & 5 deletions sources/utils/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,12 +478,12 @@ function debounce(func, timeout = 300) {
};
}

function isiPhone() {
return /iPhone/i.test(navigator.userAgent)
function isIOS() {
return /iPad|iPhone|iPod/i.test(navigator.userAgent)
}

function isMobilePhone() {
return /Android|iPhone/i.test(navigator.userAgent)
return /Android|iPhone|iPad|iPod/i.test(navigator.userAgent)
}

/**
Expand All @@ -508,7 +508,7 @@ function shareUrl(title, url) {
}
}

async function shareFile(title, data, fileName) {
function shareFile(title, data, fileName) {
const file = new File([data], `${fileName}.jpeg`, {type: data.type});
navigator.share({
title: title,
Expand Down Expand Up @@ -558,7 +558,7 @@ export default {
getImageHeight,
setImageDimensions,
getOptionId,
isiPhone,
isIOS,
isMobilePhone,
shareUrl,
shareFile,
Expand Down
6 changes: 4 additions & 2 deletions sources/views/subviews/gallery/galleryMobile.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ export default class GalleryMobileView extends JetView {
hidden: true,
template(obj) {
const imageIconDimensions = util.getImageIconDimensions();
const downloadIcon = util.isiPhone()
const downloadIcon = util.isIOS()
? `<div class="gallery-images-button-elem tooltip-container tooltip-gallery-images" style="width: ${imageIconDimensions[0].width}px; height: ${imageIconDimensions[0].height}px;">
<span class="gallery-images-button download-icon tooltip-title">
<svg viewBox="0 0 26 26" class="gallery-icon-svg" style="width: ${imageIconDimensions[1].width}px; height: ${imageIconDimensions[1].height}px;">
Expand Down Expand Up @@ -685,7 +685,9 @@ export default class GalleryMobileView extends JetView {
this.windowResizeEvent = webix.event(window, "resize", resizeHandler);

const galleryDataview = this.getGalleryDataview();
this.contextMenu.attachTo(galleryDataview);
if (!util.isIOS()) {
this.contextMenu.attachTo(galleryDataview);
}
const imgWindowTemplateView = this.imageWindow.queryView({id: mobileImageWindow.getViewerId()})
.$view;
this.enlargeContextMenu.attachTo(imgWindowTemplateView);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ function _attachCollapseToFilter(filter, collapsed, dataForCreatingControl) {
? collapsibleFilter.rows[0].cols[0]
: collapsibleFilter.rows[0];
template.onClick = {
// eslint-disable-next-line func-names
"collapssible-filter": function () {
const currentMobile = util.isMobilePhone();
const children = currentMobile
Expand Down

0 comments on commit 27051e3

Please sign in to comment.