Skip to content

Instantly share code, notes, and snippets.

@jonathanread
Last active August 29, 2015 14:02
Show Gist options
  • Save jonathanread/a2e5c631b24b8c02cf9d to your computer and use it in GitHub Desktop.
Save jonathanread/a2e5c631b24b8c02cf9d to your computer and use it in GitHub Desktop.
<%@ Control Language="C#" %>
<%@ Import Namespace="Telerik.Sitefinity.Web.UI.NavigationControls.Extensions.LightNavigationControlTemplate" %>
<%@ Import Namespace="Telerik.Sitefinity.Web.UI.NavigationControls" %>
<%@ Register Assembly="Telerik.Sitefinity" TagPrefix="navigation" Namespace="Telerik.Sitefinity.Web.UI.NavigationControls" %>
<%@ Register Assembly="Telerik.Sitefinity" TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI" %>
<sf:ResourceLinks id="resLinks" runat="server" UseEmbeddedThemes="true" Theme="Basic">
<sf:ResourceFile Name="Telerik.Sitefinity.Resources.Themes.Basic.Styles.nav.widget.css" Static="true" />
<sf:ResourceFile Name="Telerik.Sitefinity.Resources.Scripts.Kendo.styles.kendo_common_min.css" Static="true" />
</sf:ResourceLinks>
<navigation:SitefinitySiteMapDataSource runat="server" ID="dataSource" />
<div class="sfNavWrp sfNavHorizontalDropDownWrp <%= this.GetCssClass() %>">
<%-- responsive design section - renders templates for the responsive design--%>
<navigation:NavTransformationTemplate runat="server" TransformationName="ToToggleMenu" TemplateName="ToggleMenu" />
<navigation:NavTransformationTemplate runat="server" TransformationName="ToDropDown" TemplateName="Dropdown" />
<%--end of the responsive design section --%>
a
<ul runat="server" id="navigationUl" class="sfNavHorizontalDropDown sfNavList">
<navigation:NavigationContainer runat="server" DataSourceID="dataSource">
<Templates>
<navigation:NavigationTemplate>
<Template>
<li>
<a runat="server" data-url='<%# (bool)Eval("HasChildNodes") ? Eval("Url") : "" %>' href='<%# (bool)Eval("HasChildNodes") ? "javascript:void(0)" : Eval("Url") %>' %>' target='<%# NavigationUtilities.GetLinkTarget(Container.DataItem)%>'><%# Eval("Title") %></a>
<ul runat="server" id="childNodesContainer"></ul>
</li>
</Template>
<SelectedTemplate>
<li>
<a runat="server" data-url='<%# (bool)Eval("HasChildNodes") ? Eval("Url") : "" %>' href='<%# (bool)Eval("HasChildNodes") ? "javascript:void(0)" : Eval("Url") %>' class="sfSel" target='<%# NavigationUtilities.GetLinkTarget(Container.DataItem)%>'><%# Eval("Title") %></a>
<ul runat="server" id="childNodesContainer"></ul>
</li>
</SelectedTemplate>
</navigation:NavigationTemplate>
</Templates>
</navigation:NavigationContainer>
</ul>
</div>
<script type="text/javascript">
(function ($) {
var kendoMenu = $('.sfNavHorizontalDropDown').not('.k-menu').kendoMenu({
animation: false,
openOnClick: isMobile()
}).data('kendoMenu');
})(jQuery);
</script>
function isMobile() {
if (window.matchMedia("not all, not all, only screen and (-webkit-min-device-pixel-ratio: 2), not all, only screen and (max-width: 320px) and (min-width: 240px), only screen and (max-width: 480px) and (min-width: 320px), only screen and (max-width: 960px) and (min-width: 480px)").matches) {
$(".sfNavHorizontalDropDown").ready(function () {
var menu = $(".sfNavHorizontalDropDown").data("kendoMenu");
menu.bind("close", function (e) {
$(e.item).children("a").attr("href", "javascript:void(0)");
});
menu.bind("open", function (e) {
var a = $(e.item).children("a");
if (a.data("url") !== "") {
a.attr("href", a.data("url").replace("~", ""));
}
});
});
return true;
}
else {
$(".sfNavHorizontalDropDown > li").each(function () {
var a = $(this).children("a");
if (a.data("url") != "") {
a.attr("href", a.data("url").replace("~", ""));
}
});
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment