Skip to content
Snippets Groups Projects
Commit 3742b5e2 authored by dj44vuri's avatar dj44vuri
Browse files

iCode Seminar

parents
Branches main
No related tags found
No related merge requests found
Showing
with 509 additions and 0 deletions
(function (root, factory) {
if (typeof define === "function" && define.amd) {
define([], function () {
return factory(root);
});
} else if (typeof exports === "object") {
module.exports = factory(root);
} else {
root.Tabby = factory(root);
}
})(
typeof global !== "undefined"
? global
: typeof window !== "undefined"
? window
: this,
function (window) {
"use strict";
//
// Variables
//
var defaults = {
idPrefix: "tabby-toggle_",
default: "[data-tabby-default]",
};
//
// Methods
//
/**
* Merge two or more objects together.
* @param {Object} objects The objects to merge together
* @returns {Object} Merged values of defaults and options
*/
var extend = function () {
var merged = {};
Array.prototype.forEach.call(arguments, function (obj) {
for (var key in obj) {
if (!obj.hasOwnProperty(key)) return;
merged[key] = obj[key];
}
});
return merged;
};
/**
* Emit a custom event
* @param {String} type The event type
* @param {Node} tab The tab to attach the event to
* @param {Node} details Details about the event
*/
var emitEvent = function (tab, details) {
// Create a new event
var event;
if (typeof window.CustomEvent === "function") {
event = new CustomEvent("tabby", {
bubbles: true,
cancelable: true,
detail: details,
});
} else {
event = document.createEvent("CustomEvent");
event.initCustomEvent("tabby", true, true, details);
}
// Dispatch the event
tab.dispatchEvent(event);
};
var focusHandler = function (event) {
toggle(event.target);
};
var getKeyboardFocusableElements = function (element) {
return [
...element.querySelectorAll(
'a[href], button, input, textarea, select, details,[tabindex]:not([tabindex="-1"])'
),
].filter(
(el) => !el.hasAttribute("disabled") && !el.getAttribute("aria-hidden")
);
};
/**
* Remove roles and attributes from a tab and its content
* @param {Node} tab The tab
* @param {Node} content The tab content
* @param {Object} settings User settings and options
*/
var destroyTab = function (tab, content, settings) {
// Remove the generated ID
if (tab.id.slice(0, settings.idPrefix.length) === settings.idPrefix) {
tab.id = "";
}
// remove event listener
tab.removeEventListener("focus", focusHandler, true);
// Remove roles
tab.removeAttribute("role");
tab.removeAttribute("aria-controls");
tab.removeAttribute("aria-selected");
tab.removeAttribute("tabindex");
tab.closest("li").removeAttribute("role");
content.removeAttribute("role");
content.removeAttribute("aria-labelledby");
content.removeAttribute("hidden");
};
/**
* Add the required roles and attributes to a tab and its content
* @param {Node} tab The tab
* @param {Node} content The tab content
* @param {Object} settings User settings and options
*/
var setupTab = function (tab, content, settings) {
// Give tab an ID if it doesn't already have one
if (!tab.id) {
tab.id = settings.idPrefix + content.id;
}
// Add roles
tab.setAttribute("role", "tab");
tab.setAttribute("aria-controls", content.id);
tab.closest("li").setAttribute("role", "presentation");
content.setAttribute("role", "tabpanel");
content.setAttribute("aria-labelledby", tab.id);
// Add selected state
if (tab.matches(settings.default)) {
tab.setAttribute("aria-selected", "true");
} else {
tab.setAttribute("aria-selected", "false");
content.setAttribute("hidden", "hidden");
}
// add focus event listender
tab.addEventListener("focus", focusHandler);
};
/**
* Hide a tab and its content
* @param {Node} newTab The new tab that's replacing it
*/
var hide = function (newTab) {
// Variables
var tabGroup = newTab.closest('[role="tablist"]');
if (!tabGroup) return {};
var tab = tabGroup.querySelector('[role="tab"][aria-selected="true"]');
if (!tab) return {};
var content = document.querySelector(tab.hash);
// Hide the tab
tab.setAttribute("aria-selected", "false");
// Hide the content
if (!content) return { previousTab: tab };
content.setAttribute("hidden", "hidden");
// Return the hidden tab and content
return {
previousTab: tab,
previousContent: content,
};
};
/**
* Show a tab and its content
* @param {Node} tab The tab
* @param {Node} content The tab content
*/
var show = function (tab, content) {
tab.setAttribute("aria-selected", "true");
content.removeAttribute("hidden");
tab.focus();
};
/**
* Toggle a new tab
* @param {Node} tab The tab to show
*/
var toggle = function (tab) {
// Make sure there's a tab to toggle and it's not already active
if (!tab || tab.getAttribute("aria-selected") == "true") return;
// Variables
var content = document.querySelector(tab.hash);
if (!content) return;
// Hide active tab and content
var details = hide(tab);
// Show new tab and content
show(tab, content);
// Add event details
details.tab = tab;
details.content = content;
// Emit a custom event
emitEvent(tab, details);
};
/**
* Get all of the tabs in a tablist
* @param {Node} tab A tab from the list
* @return {Object} The tabs and the index of the currently active one
*/
var getTabsMap = function (tab) {
var tabGroup = tab.closest('[role="tablist"]');
var tabs = tabGroup ? tabGroup.querySelectorAll('[role="tab"]') : null;
if (!tabs) return;
return {
tabs: tabs,
index: Array.prototype.indexOf.call(tabs, tab),
};
};
/**
* Switch the active tab based on keyboard activity
* @param {Node} tab The currently active tab
* @param {Key} key The key that was pressed
*/
var switchTabs = function (tab, key) {
// Get a map of tabs
var map = getTabsMap(tab);
if (!map) return;
var length = map.tabs.length - 1;
var index;
// Go to previous tab
if (["ArrowUp", "ArrowLeft", "Up", "Left"].indexOf(key) > -1) {
index = map.index < 1 ? length : map.index - 1;
}
// Go to next tab
else if (["ArrowDown", "ArrowRight", "Down", "Right"].indexOf(key) > -1) {
index = map.index === length ? 0 : map.index + 1;
}
// Go to home
else if (key === "Home") {
index = 0;
}
// Go to end
else if (key === "End") {
index = length;
}
// Toggle the tab
toggle(map.tabs[index]);
};
/**
* Create the Constructor object
*/
var Constructor = function (selector, options) {
//
// Variables
//
var publicAPIs = {};
var settings, tabWrapper;
//
// Methods
//
publicAPIs.destroy = function () {
// Get all tabs
var tabs = tabWrapper.querySelectorAll("a");
// Add roles to tabs
Array.prototype.forEach.call(tabs, function (tab) {
// Get the tab content
var content = document.querySelector(tab.hash);
if (!content) return;
// Setup the tab
destroyTab(tab, content, settings);
});
// Remove role from wrapper
tabWrapper.removeAttribute("role");
// Remove event listeners
document.documentElement.removeEventListener(
"click",
clickHandler,
true
);
tabWrapper.removeEventListener("keydown", keyHandler, true);
// Reset variables
settings = null;
tabWrapper = null;
};
/**
* Setup the DOM with the proper attributes
*/
publicAPIs.setup = function () {
// Variables
tabWrapper = document.querySelector(selector);
if (!tabWrapper) return;
var tabs = tabWrapper.querySelectorAll("a");
// Add role to wrapper
tabWrapper.setAttribute("role", "tablist");
// Add roles to tabs. provide dynanmic tab indexes if we are within reveal
var contentTabindexes =
window.document.body.classList.contains("reveal-viewport");
var nextTabindex = 1;
Array.prototype.forEach.call(tabs, function (tab) {
if (contentTabindexes) {
tab.setAttribute("tabindex", "" + nextTabindex++);
} else {
tab.setAttribute("tabindex", "0");
}
// Get the tab content
var content = document.querySelector(tab.hash);
if (!content) return;
// set tab indexes for content
if (contentTabindexes) {
getKeyboardFocusableElements(content).forEach(function (el) {
el.setAttribute("tabindex", "" + nextTabindex++);
});
}
// Setup the tab
setupTab(tab, content, settings);
});
};
/**
* Toggle a tab based on an ID
* @param {String|Node} id The tab to toggle
*/
publicAPIs.toggle = function (id) {
// Get the tab
var tab = id;
if (typeof id === "string") {
tab = document.querySelector(
selector + ' [role="tab"][href*="' + id + '"]'
);
}
// Toggle the tab
toggle(tab);
};
/**
* Handle click events
*/
var clickHandler = function (event) {
// Only run on toggles
var tab = event.target.closest(selector + ' [role="tab"]');
if (!tab) return;
// Prevent link behavior
event.preventDefault();
// Toggle the tab
toggle(tab);
};
/**
* Handle keydown events
*/
var keyHandler = function (event) {
// Only run if a tab is in focus
var tab = document.activeElement;
if (!tab.matches(selector + ' [role="tab"]')) return;
// Only run for specific keys
if (["Home", "End"].indexOf(event.key) < 0) return;
// Switch tabs
switchTabs(tab, event.key);
};
/**
* Initialize the instance
*/
var init = function () {
// Merge user options with defaults
settings = extend(defaults, options || {});
// Setup the DOM
publicAPIs.setup();
// Add event listeners
document.documentElement.addEventListener("click", clickHandler, true);
tabWrapper.addEventListener("keydown", keyHandler, true);
};
//
// Initialize and return the Public APIs
//
init();
return publicAPIs;
};
//
// Return the Constructor
//
return Constructor;
}
);
.tippy-box[data-animation=fade][data-state=hidden]{opacity:0}[data-tippy-root]{max-width:calc(100vw - 10px)}.tippy-box{position:relative;background-color:#333;color:#fff;border-radius:4px;font-size:14px;line-height:1.4;outline:0;transition-property:transform,visibility,opacity}.tippy-box[data-placement^=top]>.tippy-arrow{bottom:0}.tippy-box[data-placement^=top]>.tippy-arrow:before{bottom:-7px;left:0;border-width:8px 8px 0;border-top-color:initial;transform-origin:center top}.tippy-box[data-placement^=bottom]>.tippy-arrow{top:0}.tippy-box[data-placement^=bottom]>.tippy-arrow:before{top:-7px;left:0;border-width:0 8px 8px;border-bottom-color:initial;transform-origin:center bottom}.tippy-box[data-placement^=left]>.tippy-arrow{right:0}.tippy-box[data-placement^=left]>.tippy-arrow:before{border-width:8px 0 8px 8px;border-left-color:initial;right:-7px;transform-origin:center left}.tippy-box[data-placement^=right]>.tippy-arrow{left:0}.tippy-box[data-placement^=right]>.tippy-arrow:before{left:-7px;border-width:8px 8px 8px 0;border-right-color:initial;transform-origin:center right}.tippy-box[data-inertia][data-state=visible]{transition-timing-function:cubic-bezier(.54,1.5,.38,1.11)}.tippy-arrow{width:16px;height:16px;color:#333}.tippy-arrow:before{content:"";position:absolute;border-color:transparent;border-style:solid}.tippy-content{position:relative;padding:5px 9px;z-index:1}
\ No newline at end of file
This diff is collapsed.
/* http://meyerweb.com/eric/tools/css/reset/
v4.0 | 20180602
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
main, menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, main, menu, nav, section {
display: block;
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
SIL Open Font License (OFL)
http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=OFL
@font-face {
font-family: 'League Gothic';
src: url('./league-gothic.eot');
src: url('./league-gothic.eot?#iefix') format('embedded-opentype'),
url('./league-gothic.woff') format('woff'),
url('./league-gothic.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
File added
File added
File added
SIL Open Font License
Copyright 2010, 2012 Adobe Systems Incorporated (http://www.adobe.com/), with Reserved Font Name ‘Source’. All Rights Reserved. Source is a trademark of Adobe Systems Incorporated in the United States and/or other countries.
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL
—————————————————————————————-
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
—————————————————————————————-
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide development of collaborative font projects, to support the font creation efforts of academic and linguistic communities, and to provide a free and open framework in which fonts may be shared and improved in partnership with others.
The OFL allows the licensed fonts to be used, studied, modified and redistributed freely as long as they are not sold by themselves. The fonts, including any derivative works, can be bundled, embedded, redistributed and/or sold with any software provided that any reserved names are not used by derivative works. The fonts and derivatives, however, cannot be released under any other type of license. The requirement for fonts to remain under this license does not apply to any document created using the fonts or their derivatives.
DEFINITIONS
“Font Software” refers to the set of files released by the Copyright Holder(s) under this license and clearly marked as such. This may include source files, build scripts and documentation.
“Reserved Font Name” refers to any names specified as such after the copyright statement(s).
“Original Version” refers to the collection of Font Software components as distributed by the Copyright Holder(s).
“Modified Version” refers to any derivative made by adding to, deleting, or substituting—in part or in whole—any of the components of the Original Version, by changing formats or by porting the Font Software to a new environment.
“Author” refers to any designer, engineer, programmer, technical writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining a copy of the Font Software, to use, study, copy, merge, embed, modify, redistribute, and sell modified and unmodified copies of the Font Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components, in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled, redistributed and/or sold with any software, provided that each copy contains the above copyright notice and this license. These can be included either as stand-alone text files, human-readable headers or in the appropriate machine-readable metadata fields within text or binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font Name(s) unless explicit written permission is granted by the corresponding Copyright Holder. This restriction only applies to the primary font name as presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font Software shall not be used to promote, endorse or advertise any Modified Version, except to acknowledge the contribution(s) of the Copyright Holder(s) and the Author(s) or with their explicit written permission.
5) The Font Software, modified or unmodified, in part or in whole, must be distributed entirely under this license, and must not be distributed under any other license. The requirement for fonts to remain under this license does not apply to any document created using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.
\ No newline at end of file
File added
File added
File added
File added
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment