The charte instance implements a set of feature to handle the charte. You can get the app element and header, menu and footer elements. You can set the app name, menu and tabs. Listen to events to get informed of the interaction with the app elements.
- Source:
- charte/charte.js
Example
import chart from 'mcutils/charte.charte'
charte.setUnivers('carto');
// Add a fullscreen tool to the app fullscreen
charte.addTool('fullscreen', 'fi-visible', 'Plein écran', () => charte.fullscreen())
// Add a new tab
charte.addMenuTab('locate', 'fi-location ', 'Localisation', 'Onglet Carte');
charte.on('tab:show', (e) => {
console.log(e.id+ ' tab is open...');
})
Namespaces
Members
-
<static> setCarousel
-
Set a carrousel for an element
- Source:
- charte/charte.js
-
<static> setPiwik
-
Set piwik tracker
- Source:
- charte/charte.js
-
dispatchEvent
-
Dispatch a connect event
- Source:
- charte/charte.js
Methods
-
<static> accordionCheck(elt, b)
-
Check an accordion element
Parameters:
Name Type Description eltElement list or label element
bboolean - Source:
- charte/charte.js
-
<static> addExtraFooter(className, title, text, url [, external])
-
Add extra footer div
Parameters:
Name Type Argument Default Description classNamestring titlestring textstring urlstring externalboolean <optional>
false - Source:
- charte/charte.js
-
<static> addHelpLink(title, url [, external])
-
Add Help links
Parameters:
Name Type Argument Default Description titlestring urlstring externalboolean <optional>
false - Source:
- charte/charte.js
-
<static> addShortLink(title, url [, external])
-
Add Short links
Parameters:
Name Type Argument Default Description titlestring urlstring externalboolean <optional>
false - Source:
- charte/charte.js
-
<static> addUserMenuItem(content [, options])
-
Add user menu item
Parameters:
Name Type Argument Description contentstring | Element optionsObject <optional>
Properties
Name Type Argument Description classNamestring <optional>
- Source:
- charte/charte.js
Returns:
- Type
- Element
-
<static> addUserMenuSeparator( [options])
-
Add user menu separator
Parameters:
Name Type Argument Description optionsObject <optional>
Properties
Name Type Argument Description classNamestring <optional>
- Source:
- charte/charte.js
Returns:
- Type
- Element
-
<static> canLogout()
-
Check if the app can logout
- Source:
- charte/charte.js
Returns:
- Type
- boolean
-
<static> initAccordion(ul)
-
Initialize accordion
Parameters:
Name Type Description ulElement - Source:
- charte/charte.js
-
<static> initTabList(ul [, onchange])
-
Initialize tabs list
Parameters:
Name Type Argument Description ulElement tab element
onchangefunction <optional>
a function that takes the tab ID
- Source:
- charte/charte.js
-
<static> setTabList(ul, name)
-
Set tab list at name
Parameters:
Name Type Description ulElement namestring - Source:
- charte/charte.js
-
addFooterLink(options)
-
Add a menu button
Parameters:
Name Type Description optionsObject Properties
Name Type Description idstring titlestring smallstring text to display on small screen
hrefstring onclickfunction - Source:
- charte/charte.js
-
addMenuButton(id, icon, title)
-
Add a menu button
Parameters:
Name Type Description idstring iconstring an icon to display (set as classname)
titlestring button title
- Source:
- charte/charte.js
Returns:
the button element
- Type
- Element
-
addMenuList(options)
-
Add a menu list
Parameters:
Name Type Description optionsObject Properties
Name Type Description idstring titlestring listArray.<string> a list of submenu
onclickfunction - Source:
- charte/charte.js
Fires:
-
addMenuTab(id, icon, title, content)
-
Add a menu tab
Parameters:
Name Type Description idstring iconstring an icon to display (set as classname)
titlestring button title
contentElement | string an element or html to add in the tab
- Source:
- charte/charte.js
Returns:
the tab element
- Type
- Element
-
addTool(id, icon, title)
-
Add a new tool
Parameters:
Name Type Description idstring iconstring an icon to display (set as classname)
titlestring button title
- Source:
- charte/charte.js
Returns:
[onclick] callback function on click
- Type
- function
-
connect()
-
Dispatch a connect event
- Source:
- charte/charte.js
-
createAccordionElement(ul, options)
-
Create an accordion element
Parameters:
Name Type Description ulElement parent element with an accordion className
optionsobject Properties
Name Type Argument Default Description titlestring label title
expendedboolean <optional>
false isTitleboolean <optional>
false namestring <optional>
if defined use it to check/unchek all accordion with the same nameId
classNamestring <optional>
contentstring | Element <optional>
clickfunction <optional>
- Source:
- charte/charte.js
-
fullscreen()
-
Set the app fullscreen
- Source:
- charte/charte.js
Fires:
-
getAppElement()
-
Get app element (the map target or the page content element)
- Source:
- charte/charte.js
Returns:
- Type
- Element
-
getCurrentMenuTab()
-
Get the current menu tab (opened)
- Source:
- charte/charte.js
Returns:
- Type
- string
-
getFooterElement()
-
Get the app footer element
- Source:
- charte/charte.js
Returns:
- Type
- Element
-
getHeaderElement()
-
Get the app header element
- Source:
- charte/charte.js
Returns:
- Type
- Element
-
getMenuTabElement(id, icon, content)
-
Add a menu tab
Parameters:
Name Type Description idstring iconstring contentElement - Source:
- charte/charte.js
-
getSubFooterElement()
-
Get the app sub-footer element
- Source:
- charte/charte.js
Returns:
- Type
- Element
-
getToolbarElement()
-
Get menu tool bar element
- Source:
- charte/charte.js
Returns:
- Type
- Element
-
on(type, callback)
-
Add an event listener
Parameters:
Name Type Description typestring | Array.<string> the event name or an array of event name
callbackfunction - Source:
- charte/charte.js
Listens to Events:
-
setAppMenu(id, name)
-
Set the current app (check in menu + name)
Parameters:
Name Type Description idstring namestring - Source:
- charte/charte.js
-
setContact(options [, parent])
-
Add contact
Parameters:
Name Type Argument Description optionsObject Properties
Name Type Argument Description idstring titlestring smallstring text to display on small screen
hrefstring servicestring mapIDstring <optional>
userstring <optional>
userIDstring <optional>
emailstring <optional>
parentElement <optional>
Element to add the contact form (default footer)
- Source:
- charte/charte.js
-
setCopyright(date [, copy])
-
Set copyright date
Parameters:
Name Type Argument Default Description datenumber copystring <optional>
IGN - Source:
- charte/charte.js
-
setInputPlaceholder( [item])
-
Set the collapsible inputs placeholders. The placeholder will be extrated from the input and placed in a label to add a collapsible effect.
Parameters:
Name Type Argument Description itemElement <optional>
if none set all input with a input-placeholder class unset
- Source:
- charte/setInputPlaceholder.js
Example
<!-- add a collapsible placeholder --> <input typt="text" class="input-placeholder" placeholder="saisissez quelque chose" /> <!-- idem for a textarea --> <textarea class="input-placeholder" placeholder="saisissez quelque chose"></textarea> <!-- Process placeholders --> <script> import charte from 'mcutils/charte/macarte' // Gerer les placeholders charte.setInputPlaceholder(); </script>
-
setLogo(name [, title])
-
Set the app logo
Parameters:
Name Type Argument Description namestring application name
titlestring <optional>
link title, default 'Acceuil - ' + name
- Source:
- charte/charte.js
-
setMegaMenu(html)
-
Set the MegaMenu content (as returned by the MacarteAPI#getEditorial)
Parameters:
Name Type Description htmlstring MegaMenu content html string
- Source:
- charte/charte.js
-
setName(name [, title])
-
Set the app name
Parameters:
Name Type Argument Description namestring application name
titlestring <optional>
link title, default 'Acceuil - ' + name
- Source:
- charte/charte.js
-
setNewsletter(src, title)
-
Add newsletter
Parameters:
Name Type Description srcstring titlestring - Source:
- charte/charte.js
-
setUnivers(name)
-
Set the app univers
Parameters:
Name Type Description namestring - Source:
- charte/charte.js
-
setUser(user)
-
Set the user name in the bar and add a connected dataset to the body
Parameters:
Name Type Description userobject - Source:
- charte/charte.js
-
showTab( [id] [, b])
-
Show/hide a tab
Parameters:
Name Type Argument Description idstring <optional>
id of the tab to show / hide
bboolean <optional>
if none toggle the tab
- Source:
- charte/charte.js
-
un(type, callback)
-
Remove an event listener
Parameters:
Name Type Description typestring | Array.<string> callbackfunction - Source:
- charte/charte.js
Events
-
fullscreen
-
Fired when app is set/unset fullscreen
- Source:
- charte/charte.jsdoc
Listeners of This Event:
-
user
-
Fired when the user name is clicked / connected
- Source:
- charte/charte.jsdoc
Properties:
Name Type Description nameboolean click on the user name
headboolean click on the user head logo
Listeners of This Event:
-
header:list
-
Fired when header menu list is toggled
- Source:
- charte/charte.jsdoc
Properties:
Name Type Description idstring menu id
Listeners of This Event:
-
header:menu
-
Fired when header menu is toggled
- Source:
- charte/charte.jsdoc
Listeners of This Event:
-
header:title
-
Fired when header title (or logo) is clicked
- Source:
- charte/charte.jsdoc
-
menu:list
-
Fired when an item of the menu list is clicked
- Source:
- charte/charte.jsdoc
Properties:
Name Type Description idstring menu id
titlestring the menu title
Listeners of This Event:
-
tab:show
-
Fired when a tab is toggled
- Source:
- charte/charte.jsdoc
Properties:
Name Type Description idstring id of the tab shown or null if the tab hides
Listeners of This Event:
-
user:logout
-
Fired when the user logout (diconnect) is clicked
- Source:
- charte/charte.jsdoc
Listeners of This Event: