MCPcopy
hub / github.com/impress/impress.js / addNavigationControls

Function addNavigationControls

js/impress.js:3923–3970  ·  view source on GitHub ↗
( event )

Source from the content-addressed store, hash-verified

3921 };
3922
3923 var addNavigationControls = function( event ) {
3924 api = event.detail.api;
3925 var gc = api.lib.gc;
3926 root = event.target;
3927 steps = root.querySelectorAll( '.step' );
3928
3929 var prevHtml = '<button id="impress-navigation-ui-prev" title="Previous" ' +
3930 'class="impress-navigation-ui">&lt;</button>';
3931 var selectHtml = '<select id="impress-navigation-ui-select" title="Go to" ' +
3932 'class="impress-navigation-ui">' + '\n' +
3933 selectOptionsHtml() +
3934 '</select>';
3935 var nextHtml = '<button id="impress-navigation-ui-next" title="Next" ' +
3936 'class="impress-navigation-ui">&gt;</button>';
3937
3938 prev = makeDomElement( prevHtml );
3939 prev.addEventListener( 'click',
3940 function() {
3941 api.prev();
3942 } );
3943 select = makeDomElement( selectHtml );
3944 select.addEventListener( 'change',
3945 function( event ) {
3946 api.goto( event.target.value );
3947 } );
3948 gc.addEventListener( root, 'impress:steprefresh', function( event ) {
3949
3950 // As impress.js core now allows to dynamically edit the steps, including adding,
3951 // removing, and reordering steps, we need to requery and redraw the select list on
3952 // every stepenter event.
3953 steps = root.querySelectorAll( '.step' );
3954 select.innerHTML = '\n' + selectOptionsHtml();
3955
3956 // Make sure the list always shows the step we're actually on, even if it wasn't
3957 // selected from the list
3958 select.value = event.target.id;
3959 } );
3960 next = makeDomElement( nextHtml );
3961 next.addEventListener( 'click',
3962 function() {
3963 api.next();
3964 } );
3965
3966 triggerEvent( toolbar, 'impress:toolbar:appendChild', { group: 0, element: prev } );
3967 triggerEvent( toolbar, 'impress:toolbar:appendChild', { group: 0, element: select } );
3968 triggerEvent( toolbar, 'impress:toolbar:appendChild', { group: 0, element: next } );
3969
3970 };
3971
3972 // API for not listing given step in the select widget.
3973 // For example, if you set class="skip" on some element, you may not want it to show up in the

Callers 1

impress.jsFile · 0.70

Calls 3

selectOptionsHtmlFunction · 0.70
makeDomElementFunction · 0.70
triggerEventFunction · 0.70

Tested by

no test coverage detected