Last active
August 14, 2023 10:25
-
-
Save leekelleher/7285d00188906dfb4b29a39183540556 to your computer and use it in GitHub Desktop.
Umbraco (v8-10) AngularJS hacking the top navigation
This file contains hidden or 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
angular.module("umbraco").run([ | |
"$compile", | |
"appState", | |
"eventsService", | |
function ($compile, appState, eventsService) { | |
eventsService.on("app.ready", function (e, args) { | |
// console.log("app.ready", e, args); | |
var scope = e.targetScope.$new(); | |
scope.open = open; | |
var html = ` | |
<li class="umb-app-header__action"> | |
<button type="button" class="umb-app-header__button btn-reset" title="Smile" ng-click="open()" hotkey="ctrl+shift+q"> | |
<span class="umb-app-header__action-icon umb-icon"> | |
<span class="umb-icon__inner"> | |
<umb-icon icon="icon-smiley"></umb-icon> | |
</span> | |
</span> | |
</button> | |
</li>`; | |
var dom = $compile(html)(scope); | |
angular.element(".umb-app-header__actions > li:nth-child(1)").after(dom); | |
}); | |
function open() { | |
var showDrawer = appState.getDrawerState("showDrawer"); | |
appState.setDrawerState("view", "/App_Plugins/Custom/backoffice/drawer/drawer.html"); | |
appState.setDrawerState("showDrawer", !showDrawer); | |
}; | |
} | |
]); |
This file contains hidden or 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
angular.module("umbraco").run([ | |
"assetsService", | |
"eventsService", | |
function (assetsService, eventsService) { | |
eventsService.on("app.ready", function (evt, data) { | |
var assets = [ | |
"https://cdn.jsdelivr.net/npm/@umbraco-ui/uui@latest/dist/uui.min.js", | |
"https://cdn.jsdelivr.net/npm/@umbraco-ui/uui-css@latest/dist/uui-css.css" | |
]; | |
assetsService.load(assets).then(function () { | |
console.log("The assets have been loaded."); | |
}); | |
}); | |
} | |
]); |
This file contains hidden or 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
angular.module("umbraco").run([ | |
"eventsService", | |
function (eventsService) { | |
eventsService.on("app.ready", function (e, args) { | |
var html = ` | |
<li class="umb-app-header__action"> | |
<span class="umb-app-header__button"> | |
<span class="umb-app-header__action-icon umb-icon"> | |
<span class="umb-icon__inner">🟢</span> | |
</span> | |
</span> | |
</li>`; | |
var dom = angular.element(html); | |
angular.element(".umb-app-header__actions > li:nth-last-child(1)").after(dom); | |
window.addEventListener("online", () => angular.element(".umb-icon__inner", dom).html("🟢")); | |
window.addEventListener("offline", () => angular.element(".umb-icon__inner", dom).html("🔴")); | |
}); | |
} | |
]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment