From ffb2a60fb02af853f9279f197ea13cb0b5a59adc Mon Sep 17 00:00:00 2001 From: Mstislav Zhivodkov Date: Tue, 5 Jun 2018 12:48:51 +0700 Subject: [PATCH 1/5] Add notification for old browsers --- gulp/deps/deps.js | 13 ++- src/DGMuseum/skin/basic/img/DGMuseum.jpg | Bin 0 -> 2219 bytes .../skin/basic/img/DGMuseum_close.gif | Bin 0 -> 103 bytes src/DGMuseum/skin/basic/less/dg-museum.less | 72 +++++++++++++++ src/DGMuseum/src/DGMuseum.js | 83 ++++++++++++++++++ src/doc/en/manual/map.md | 6 ++ src/doc/ru/manual/map.md | 6 ++ 7 files changed, 178 insertions(+), 2 deletions(-) create mode 100644 src/DGMuseum/skin/basic/img/DGMuseum.jpg create mode 100644 src/DGMuseum/skin/basic/img/DGMuseum_close.gif create mode 100644 src/DGMuseum/skin/basic/less/dg-museum.less create mode 100644 src/DGMuseum/src/DGMuseum.js diff --git a/gulp/deps/deps.js b/gulp/deps/deps.js index 656135e47..5dce4d058 100644 --- a/gulp/deps/deps.js +++ b/gulp/deps/deps.js @@ -91,7 +91,7 @@ var deps = { 'DGCustomization/skin/{skin}/less/dg-customization.ie.less' ] }, - deps: ['DGCore', 'DGLocale', 'DGRoundControl', 'DGProjectDetector'] + deps: ['DGCore', 'DGLocale', 'DGRoundControl', 'DGProjectDetector', 'DGMuseum'] }, DGZoomControl: { @@ -357,8 +357,17 @@ var deps = { all: ['DGRulerControl/skin/{skin}/less/dg-control-round.less'] }, deps: ['DGRuler', 'DGRoundControl'] - } + }, + DGMuseum: { + desc: 'Museum module', + src: [ + 'DGMuseum/src/DGMuseum.js' + ], + less: { + all: ['DGMuseum/skin/{skin}/less/dg-museum.less'] + } + } }; if (typeof module !== 'undefined' && module.exports) { diff --git a/src/DGMuseum/skin/basic/img/DGMuseum.jpg b/src/DGMuseum/skin/basic/img/DGMuseum.jpg new file mode 100644 index 0000000000000000000000000000000000000000..2ca4ec1e0ca1f2de2947824e7ba492fa126843a1 GIT binary pat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>)_=EN8jO}8+Tjmutn=_woW+zV$HfPJOGZMno_YFFccsiD%> zZGtZA&65oCJ~#E?g|b31{_YD8ml%nmNgQXLIeKd)_Cj=6)A_ zp^7$$nTXFZFh0!@wWm`Ol^B65OCPUJWoUeq> zS>JY8CZk&Ajfh(-p6-rV<+1TpJu_DL1XW){+-QB&JaNpf3355XP)^k-c`57_k9Pl} zI(5TrYb#4@RAcfa?ExzZ)V3o6fa~s40yrWW5A3dFKGa&7GP=6uwcu)LD);>~%cdW? zwMLTIsqw)FEc7-lqZ3SR}({oUnrbgek zJoD3%Q@JoG)hI=)dgZb8Yn@byySdcpwM@KPz&T|#kMUNLNPFhqa((w-n+dtmUJnh4 zs)!$4>kh(Pf`)$$nZ_OQfY;pThDw^drM>txIs*>TExzvBt5PJ^mM_%XSk>@W zvUSjl#~?mU*e=5MeT>N?Czq|pN?r~NB4plCR`rfqb9o-UK00PsEQgGmI;^4NKaiT< zD?h#Qmp7q-GZ&g{>FyeR' + + '' + + '' + + '' + + ''; + + this._text = this._element.children[0]; + + this._closeButton = document.createElement('span'); + this._closeButton.className = 'dg-museum__close'; + this._element.appendChild(this._closeButton); + + this._renderTranslation(); + }, + + addHooks: function() { + this._map.getContainer().appendChild(this._element); + this._map.on('langchange', this._renderTranslation, this); + DG.DomEvent.on(this._closeButton, 'click', this._onCloseButtonClick, this); + }, + + removeHooks: function() { + this._map.getContainer().removeChild(this._element); + this._map.off('langchange', this._renderTranslation, this); + DG.DomEvent.off(this._closeButton, 'click', this._onCloseButtonClick, this); + }, + + _onCloseButtonClick: function(e) { + DG.DomEvent.stop(e); + this.disable(); + }, + + _renderTranslation: function() { + var lang = this._map.getLang(); + this._text.innerHTML = this.t('wearesorry'); + this._element.setAttribute('dir', lang === 'ar' ? 'rtl': 'ltr'); + } +}); + +DG.Map.addInitHook('addHandler', 'museum', DG.Map.Museum); diff --git a/src/doc/en/manual/map.md b/src/doc/en/manual/map.md index 604f81081..80614b1e3 100644 --- a/src/doc/en/manual/map.md +++ b/src/doc/en/manual/map.md @@ -195,6 +195,12 @@ Initialize the map on the "map" div with a given center and zoom: + + museum + Boolean + true + Whether the message about unsupported browser be displayed. + diff --git a/src/doc/ru/manual/map.md b/src/doc/ru/manual/map.md index ac145aa0f..722171ae2 100644 --- a/src/doc/ru/manual/map.md +++ b/src/doc/ru/manual/map.md @@ -198,6 +198,12 @@ масштабирования нет тайлов. + + museum + Boolean + true + Будет ли отображаться сообщение о том, что браузер не поддерживается. + From 1a2de619df1cc4d79758e5e2b708cd87c42305d2 Mon Sep 17 00:00:00 2001 From: Mstislav Zhivodkov Date: Fri, 8 Jun 2018 13:22:43 +0700 Subject: [PATCH 2/5] Add will word in map museum option --- src/doc/en/manual/map.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/en/manual/map.md b/src/doc/en/manual/map.md index 80614b1e3..fa761b07b 100644 --- a/src/doc/en/manual/map.md +++ b/src/doc/en/manual/map.md @@ -199,7 +199,7 @@ Initialize the map on the "map" div with a given center and zoom: museum Boolean true - Whether the message about unsupported browser be displayed. + Whether the message about unsupported browser will be displayed. From a96c91903a47c05c0bf93514e4665671568e0af7 Mon Sep 17 00:00:00 2001 From: Mstislav Zhivodkov Date: Thu, 14 Jun 2018 11:50:11 +0700 Subject: [PATCH 3/5] Increase museum z-index and use localstorage for disabling museum --- src/DGMuseum/skin/basic/less/dg-museum.less | 2 +- src/DGMuseum/src/DGMuseum.js | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/DGMuseum/skin/basic/less/dg-museum.less b/src/DGMuseum/skin/basic/less/dg-museum.less index 589e4e10f..b44d23fcc 100644 --- a/src/DGMuseum/skin/basic/less/dg-museum.less +++ b/src/DGMuseum/skin/basic/less/dg-museum.less @@ -3,7 +3,7 @@ top: 0; left: 0; right: 0; - z-index: 500; + z-index: 1500; padding: 4px 5px 8px; background: #333; color: #fff; diff --git a/src/DGMuseum/src/DGMuseum.js b/src/DGMuseum/src/DGMuseum.js index cd7f38e5f..24e4fa95e 100644 --- a/src/DGMuseum/src/DGMuseum.js +++ b/src/DGMuseum/src/DGMuseum.js @@ -5,8 +5,17 @@ var ie9 = (function() { return Boolean(all[0]); })(); +var wasPreviouslyDisabled = false; + +// Old Safari throws error when localStorage.getItem calls in private mode +try { + wasPreviouslyDisabled = localStorage.getItem('DGMuseum') === 'false'; +} catch (err) { + // do nothing +} + DG.Map.mergeOptions({ - museum: DG.Browser.ielt9 || ie9 || DG.Browser.opera12 || DG.Browser.safari51 + museum: !wasPreviouslyDisabled && (DG.Browser.ielt9 || ie9 || DG.Browser.opera12 || DG.Browser.safari51) }); DG.Map.Museum = DG.Handler.extend({ @@ -70,6 +79,14 @@ DG.Map.Museum = DG.Handler.extend({ _onCloseButtonClick: function(e) { DG.DomEvent.stop(e); + + // Old Safari throws error when localStorage.getItem calls in private mode + try { + localStorage.setItem('DGMuseum', 'false'); + } catch (err) { + // do nothing + } + this.disable(); }, From ea56046dd7d18f329b0ee1996548f030f7ba106b Mon Sep 17 00:00:00 2001 From: Mstislav Zhivodkov Date: Thu, 14 Jun 2018 13:32:39 +0700 Subject: [PATCH 4/5] Fix comment translation --- src/DGMuseum/src/DGMuseum.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/DGMuseum/src/DGMuseum.js b/src/DGMuseum/src/DGMuseum.js index 24e4fa95e..82ba99668 100644 --- a/src/DGMuseum/src/DGMuseum.js +++ b/src/DGMuseum/src/DGMuseum.js @@ -7,7 +7,7 @@ var ie9 = (function() { var wasPreviouslyDisabled = false; -// Old Safari throws error when localStorage.getItem calls in private mode +// Old Safari throws error when localStorage.getItem is called in private mode try { wasPreviouslyDisabled = localStorage.getItem('DGMuseum') === 'false'; } catch (err) { @@ -80,7 +80,7 @@ DG.Map.Museum = DG.Handler.extend({ _onCloseButtonClick: function(e) { DG.DomEvent.stop(e); - // Old Safari throws error when localStorage.getItem calls in private mode + // Old Safari throws error when localStorage.getItem is called in private mode try { localStorage.setItem('DGMuseum', 'false'); } catch (err) { From 5db92d7af0131b2e33bcbfbd980fde7bc74f9646 Mon Sep 17 00:00:00 2001 From: Mstislav Zhivodkov Date: Fri, 15 Jun 2018 15:29:43 +0700 Subject: [PATCH 5/5] Safari51 fix --- src/DGMuseum/src/DGMuseum.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/DGMuseum/src/DGMuseum.js b/src/DGMuseum/src/DGMuseum.js index 82ba99668..93f487ac4 100644 --- a/src/DGMuseum/src/DGMuseum.js +++ b/src/DGMuseum/src/DGMuseum.js @@ -5,6 +5,8 @@ var ie9 = (function() { return Boolean(all[0]); })(); +var safari51 = DG.Browser.safari && navigator.userAgent.indexOf('Version/5.1') !== -1; + var wasPreviouslyDisabled = false; // Old Safari throws error when localStorage.getItem is called in private mode @@ -15,7 +17,7 @@ try { } DG.Map.mergeOptions({ - museum: !wasPreviouslyDisabled && (DG.Browser.ielt9 || ie9 || DG.Browser.opera12 || DG.Browser.safari51) + museum: !wasPreviouslyDisabled && (DG.Browser.ielt9 || ie9 || DG.Browser.opera12 || safari51) }); DG.Map.Museum = DG.Handler.extend({