Update to support save mode to url and parse mode from url
This commit is contained in:
parent
3840308ab6
commit
f1c9874ed0
1 changed files with 18 additions and 5 deletions
|
@ -195,10 +195,16 @@ var supportExtraTags = [
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
var modeType = {
|
var modeType = {
|
||||||
edit: {},
|
edit: {
|
||||||
view: {},
|
name: "edit"
|
||||||
both: {}
|
},
|
||||||
}
|
view: {
|
||||||
|
name: "view"
|
||||||
|
},
|
||||||
|
both: {
|
||||||
|
name: "both"
|
||||||
|
}
|
||||||
|
};
|
||||||
var statusType = {
|
var statusType = {
|
||||||
connected: {
|
connected: {
|
||||||
msg: "CONNECTED",
|
msg: "CONNECTED",
|
||||||
|
@ -215,7 +221,7 @@ var statusType = {
|
||||||
label: "label-danger",
|
label: "label-danger",
|
||||||
fa: "fa-plug"
|
fa: "fa-plug"
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
var defaultMode = modeType.view;
|
var defaultMode = modeType.view;
|
||||||
|
|
||||||
//global vars
|
//global vars
|
||||||
|
@ -1133,6 +1139,8 @@ function changeMode(type) {
|
||||||
ui.area.view.show();
|
ui.area.view.show();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
// save mode to url
|
||||||
|
if (history.replaceState && loaded) history.replaceState(null, "", serverurl + '/' + noteid + '?' + currentMode.name);
|
||||||
if (currentMode == modeType.view) {
|
if (currentMode == modeType.view) {
|
||||||
editor.getInputField().blur();
|
editor.getInputField().blur();
|
||||||
}
|
}
|
||||||
|
@ -2416,6 +2424,11 @@ socket.on('refresh', function (data) {
|
||||||
else
|
else
|
||||||
currentMode = modeType.both;
|
currentMode = modeType.both;
|
||||||
}
|
}
|
||||||
|
// parse mode from url
|
||||||
|
if (window.location.search.length > 0) {
|
||||||
|
var urlMode = modeType[window.location.search.substr(1)];
|
||||||
|
if (urlMode) currentMode = urlMode;
|
||||||
|
}
|
||||||
changeMode(currentMode);
|
changeMode(currentMode);
|
||||||
if (nocontent && !visibleXS) {
|
if (nocontent && !visibleXS) {
|
||||||
editor.focus();
|
editor.focus();
|
||||||
|
|
Loading…
Reference in a new issue