Skip to content

Instantly share code, notes, and snippets.

@sotirisf
Last active December 19, 2020 16:27
Show Gist options
  • Save sotirisf/933ac84063e672cd5a19dae7630e8092 to your computer and use it in GitHub Desktop.
Save sotirisf/933ac84063e672cd5a19dae7630e8092 to your computer and use it in GitHub Desktop.
Hide unpublished variants 2
var enableHideNodes = "";
$.ajax({
url: "/umbraco/api/TreeVariantSettings/HideUnpublishedVariantsFromTree",
success: function (data) {
enableHideNodes = data;
}
, async: false
});
if (enableHideNodes === "true") {
$(document).arrive("li.umb-tree-item.not-published-add", function () {
var name = $(this).find("a").text();
if (name.startsWith("(") && name.endsWith(")")) {
$(this).hide();
}
});
$(document).arrive("li.umb-tree-item.not-published", function () {
var name = $(this).find("a").text();
if (name.startsWith("(") && name.endsWith(")")) {
$(this).hide();
}
});
}
{
//array of files we want to inject into the application on app_start
"javascript": [
"~/App_Plugins/HideNodesFromTree/arrive.js",
"~/App_Plugins/HideNodesFromTree/hider.js",
"~/App_Plugins/HideNodesFromTree/toggle.js"
]
}
function HideShowTreeNodes()
{
$("li.umb-tree-item.not-published").each(function () {
tgl($(this));
});
$(document).arrive("li.umb-tree-item.not-published-add", function () {
tgl($(this));
});
};
function tgl(t) {
var name = t.find("a").text();
if (name.startsWith("(") && name.endsWith(")")) {
t.toggle();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment