Giter Club home page Giter Club logo

Comments (4)

EitanBlumin avatar EitanBlumin commented on September 23, 2024
ALTER FUNCTION portal.GetNavigationRecursive(@ParentNavId INT)
RETURNS NVARCHAR(MAX)
AS
BEGIN
DECLARE
	@Json NVARCHAR(MAX)

;WITH Nav AS (SELECT TOP 100 PERCENT * FROM portal.Navigation ORDER BY NavOrder ASC)
SELECT @Json = ISNULL(@Json + N', ', N'[ ') + N' { "NavId": ' + CONVERT(nvarchar(max), NavId) + N',
"NavLabel": "' + portal.FormatValueForJson(NavLabel) + N'",
"NavOrder": ' + CONVERT(nvarchar(max), NavOrder) + N',
"NavUri": "' + ISNULL(portal.FormatValueForJson(NavUri), N'') + N'",
"NavGlyph": "' + portal.FormatValueForJson(NavGlyph) + N'",
"NavTooltip": "' + portal.FormatValueForJson(NavTooltip) + N'",
"ViewID": "' + portal.FormatValueForJson(CONVERT(nvarchar(max), ViewID)) + N'",
"ChildItems":' + ISNULL(portal.GetNavigationRecursive(ISNULL(NavId, -1)), N'[ ]') + N' }'
FROM Nav
WHERE NavParentId = @ParentNavId
OR (@ParentNavId IS NULL AND NavParentId IS NULL)

SET @Json = ISNULL(@Json, N'[ ') + N']'
RETURN @Json

END

from crude-asp.

EitanBlumin avatar EitanBlumin commented on September 23, 2024

Still need to think how to figure out which nav links should be active or not

from crude-asp.

EitanBlumin avatar EitanBlumin commented on September 23, 2024

Get path name:

var segments = window.location.pathname.split('/');
var toDelete = [];
for (var i = 0; i < segments.length; i++) {
    if (segments[i].length < 1) {
        toDelete.push(i);
    }
}
for (var i = 0; i < toDelete.length; i++) {
    segments.splice(i, 1);
}
var currFileName= segments[segments.length - 1];
console.log(currFileName);

Dynamically change menu item class:

$('.menu a').each(function() { //li a?
    if ($(this).attr('href') == currFileName){ $(this).addClass('active'); }
});

Find an element's parent:
https://api.jquery.com/parent/

Determine whether an element has a class:
https://api.jquery.com/hasClass/

Perhaps I could do it like this:

  1. Give all sidenav menu links (a) the same class (let's say, nav-link or whatever).
  2. Find current open page.
  3. Run jquery to find all sidenav links based on their class, and compare their href attribute against the current open page.
  4. If equals, run a recursive function which would add the "active" class to all parent (li) elements that don't have the "active" class yet. The recursive function stops when the parent element is not (li) or (ul), or when it already has the "active" class.

from crude-asp.

EitanBlumin avatar EitanBlumin commented on September 23, 2024

completed

from crude-asp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.