FIX pushToHistory

This commit is contained in:
Krivchikov Dmitry 2015-08-13 11:16:26 +03:00
parent 9435ebd29a
commit 1b9c8aa2df
2 changed files with 9 additions and 5 deletions

View File

@ -146,7 +146,7 @@ window.addEventListener('popstate', function(e)
setStatus(statusMovingInHistory); setStatus(statusMovingInHistory);
if (e.state.hasOwnProperty('pointId')) if (e.state.hasOwnProperty('pointId'))
{ {
showInfo(e.state.pointId); showInfo(e.state.pointId, false, true);
} else } else
if (e.state.hasOwnProperty('zoom')) if (e.state.hasOwnProperty('zoom'))
{ {

View File

@ -229,13 +229,14 @@ function initPoints(useBounds)
* @param {type} id * @param {type} id
* @returns {Boolean} * @returns {Boolean}
*/ */
function showInfo(id, mapClick) function showInfo(id, mapClick,doNotPushToHistory)
{ {
if (!(id in points)) { if (!(id in points)) {
return false; return false;
} }
mapClick = Boolean(mapClick !== undefined && mapClick === true); // true если это клик по маркеру на карте mapClick = Boolean(mapClick !== undefined && mapClick === true); // true если это клик по маркеру на карте
doNotPushToHistory = Boolean(doNotPushToHistory !== undefined && doNotPushToHistory === true); // true если НЕ добавляем в history
marker = points[id]; marker = points[id];
if (!(id in pointsSources)) if (!(id in pointsSources))
{ {
@ -248,11 +249,11 @@ function showInfo(id, mapClick)
} }
}); });
} else { } else {
drawInfoPopup(id, !mapClick); drawInfoPopup(id, !mapClick, doNotPushToHistory);
} }
} }
function drawInfoPopup(id, showPopup) { function drawInfoPopup(id, showPopup, doNotPushToHistory) {
data = pointsSources[id]; data = pointsSources[id];
if (typeof (data.images) == 'object') if (typeof (data.images) == 'object')
{ {
@ -307,7 +308,10 @@ function drawInfoPopup(id, showPopup) {
marker.openPopup(); marker.openPopup();
} }
if (!doNotPushToHistory) {
history.pushState({pointId: id}, document.title, "/?point=" + id); history.pushState({pointId: id}, document.title, "/?point=" + id);
}
document.title = marker.options.title; document.title = marker.options.title;
}); });