Last active
December 19, 2020 16:27
-
-
Save sotirisf/933ac84063e672cd5a19dae7630e8092 to your computer and use it in GitHub Desktop.
Hide unpublished variants 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} | |
}); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
//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" | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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