app/scripts/ui-lib/uilib-loader.coffee

Library Loader

The actual library loader. It uses require to load the dependencies defined in the main file.

author: Julien Ramboz version: 1.0 requires: jQuery or Zepto DOM library

AMD loader

Try loading as AMD module or fall back to default loading

((plugin) -> if typeof define is "function" and define.amd define [

JS library (jQuery or Zepto)

"jslib" "core"

Plugins

"ellipsis"

Widgets

"overlay" "toggle" "tooltip" "collapse" "accordions" "tabs" "toolbar" "menubar" "menu" "tree" "dialog" "alert" "notification" "list" "carousel" "slideshow" "gallery" "filter" "sort" ], plugin else plugin @$ ) loader = ($, _) ->

Toggle the no-js/js class on the html element.

$("html").removeClass("no-js").addClass("js")

Add anchors for headings

headings = ">h1,>h2,>h3" $h = $(headings, $(".page-header, .page-header header")) $h = $h.add($(headings, $(".page-content header"))) $h = $h.add($(headings, $(".page-content, .page-content section"))) $h.each () -> $this = $ this label = $.trim($this.text()) unless this.id id = label.toLowerCase() .replace(/\(\)\[\]/,"") .replace(/\W/g,"-") .replace(/-+/g,"-") this.id = id unless $("[id=\"#{id}\"]").length $this.addClass("heading").append( $(document.createElement("a")).attr( href: "#" + this.id class: "heading-anchor" rel: "bookmark" ).html "<span class=\"visuallyhidden\">#{label}</span>" )

Mark icons as presentation-only content

$(".icon:empty").attr role: "presentation" hidden: "hidden"

Do not follow links of active navigation items

$(".nav").on "click", ".nav-item-active a.nav-link", (e) -> if $(e.target).closest(".nav-item").hasClass("nav-item-active") e.preventDefault()

Notify listeners the library has loaded

$(document).trigger "ui-loaded"

return the UI library

_