Skip to content

Commit 02e379e

Browse files
committed
better hash handling
1 parent 09d38d8 commit 02e379e

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

puckweb/wwwroot/Areas/puck/assets/js/puck.handlers.js

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -991,15 +991,29 @@ $(window).load(function () {
991991
//cleft.parent().append(
992992
// $("<div/>").html("<i style=\"font-size:18px;\" class=\"fas fa-arrows-alt-h\"/>").addClass("colsResizer").css({ position: "absolute", left: (cleft.width()-0+13) + "px", top: "10px" })
993993
//);
994+
var afterVariants = function (data) {
995+
languages = data;
996+
for (var i = 0; i < languages.length; i++) {
997+
languageSortDictionary[languages[i].Key] = i + 1;
998+
}
999+
var hash = getQueryString("hash");
1000+
if (languages.length == 0) {
1001+
onAfterDom(function () {
1002+
msg(0, "take a moment to setup puck. at the very least, choose your languages!");
1003+
});
1004+
location.hash = "settings?path=/puck/settings/languages";
1005+
} else if (!hash&&!location.hash) {
1006+
location.hash = "#content";
1007+
}
1008+
};
9941009

9951010
var hash = getQueryString("hash");
9961011
//console.log("hashQs",hash);
9971012

998-
if (!hash) {
999-
if (!location.hash)
1000-
location.hash = "#content";
1001-
return;
1002-
}
1013+
getVariants(afterVariants);
1014+
1015+
if (!hash) return;
1016+
10031017
setTimeout(function () {
10041018
location.hash = hash;
10051019
if (hash[0] != "#")
@@ -1050,18 +1064,7 @@ getUserRoles(function (d) {
10501064
if (!userRoles.contains("_republish")) $(".republish_entire_site").hide();
10511065
});
10521066
});
1053-
getVariants(function (data) {
1054-
languages = data;
1055-
for (var i = 0; i < languages.length; i++) {
1056-
languageSortDictionary[languages[i].Key] = i + 1;
1057-
}
1058-
if (languages.length == 0) {
1059-
onAfterDom(function () {
1060-
msg(0, "take a moment to setup puck. at the very least, choose your languages!");
1061-
});
1062-
location.hash = "settings?path=/puck/settings/languages";
1063-
}
1064-
});
1067+
10651068
var isArray = function (arg) {
10661069
return Object.prototype.toString.call(arg) === '[object Array]';
10671070
};

0 commit comments

Comments
 (0)