diff --git a/system/application/views/arbors/html5_RDFa/wrapper.php b/system/application/views/arbors/html5_RDFa/wrapper.php index 500d9e12c..8b61d4e54 100755 --- a/system/application/views/arbors/html5_RDFa/wrapper.php +++ b/system/application/views/arbors/html5_RDFa/wrapper.php @@ -57,7 +57,7 @@ function print_rdf($rdf, $tabs=0, $ns=array(), $hide=array(), $aria=false, $forc if (in_array($p, $hide)) continue; foreach ($values as $value) { if (isURL($value['value']) && !in_array(toNS($p,$ns), $force_literal)) { - $str = ''."\n"; + $str = ''."\n"; } else { $str = ''.$value['value'].''."\n"; } @@ -203,19 +203,19 @@ function print_rdf($rdf, $tabs=0, $ns=array(), $hide=array(), $aria=false, $forc title?>subtitle)&&!empty($book->subtitle))?': '.$book->subtitle.'':''?> -slug)) echo ' '."\n"; ?> - +slug)) echo ' '."\n"; ?> + contributors as $contrib): if (empty($contrib->list_in_index)) continue; - echo ' '."\n"; + echo ' '."\n"; endforeach; ?> -'."\n" : '')?> +'."\n" : '')?> editions)): for ($j = count($book->editions)-1; $j >= 0; $j--): - echo ' '."\n"; + echo ' '."\n"; endfor; endif; ?> @@ -223,7 +223,7 @@ function print_rdf($rdf, $tabs=0, $ns=array(), $hide=array(), $aria=false, $forc versions); $j++): @@ -231,13 +231,13 @@ function print_rdf($rdf, $tabs=0, $ns=array(), $hide=array(), $aria=false, $forc if ($book->versions[$j]->content_id == @$page->content_id) continue; ?>

- - + + pages->rdf($page, $base_uri), 3, $ns); ?> users->rdf($page->user, $base_uri), 3, $ns); ?> - + versions->rdf($page->versions[$page->version_index], $base_uri), 2, $ns, array('sioc:content')); ?> @@ -298,14 +298,14 @@ function print_rdf($rdf, $tabs=0, $ns=array(), $hide=array(), $aria=false, $forc ?> li>a:hover,.nav>li>a:focus{outline:dotted 1px #000}.carousel-indicators li,.carousel-indicators li.active{height:18px;width:18px;border-width:2px;position:relative;box-shadow:0px 0px 0px 1px #808080}.carousel-indicators.active li{background-color:rgba(100,149,253,0.6)}.carousel-indicators.active li.active{background-color:white}.carousel-tablist-highlight{display:block;position:absolute;outline:2px solid transparent;background-color:transparent;box-shadow:0px 0px 0px 1px transparent}.carousel-tablist-highlight.focus{outline:2px solid #6495ED;background-color:rgba(0,0,0,0.4)}a.carousel-control:focus{outline:2px solid #6495ED;background-image:linear-gradient(to right, transparent 0px, rgba(0,0,0,0.5) 100%);box-shadow:0px 0px 0px 1px #000000}.carousel-pause-button{position:absolute;top:-30em;left:-300em;display:block}.carousel-pause-button.focus{top:0.5em;left:0.5em}.carousel.contrast .carousel-caption{background-color:rgba(0,0,0,0.5);z-index:10}.alert-success{color:#2d4821}.alert-info{color:#214c62}.alert-warning{color:#6c4a00;background-color:#f9f1c6}.alert-danger{color:#d2322d}.alert-danger:hover{color:#a82824} +.btn:focus{outline:dotted 2px #000}div.active:focus{outline:dotted 1px #000}a:focus{outline:dotted 1px #000}.close:hover,.close:focus{outline:dotted 1px #000}.nav>li>a:hover,.nav>li>a:focus{outline:dotted 1px #000}.carousel-indicators li,.carousel-indicators li.active{height:18px;width:18px;border-width:2px;position:relative;box-shadow:0px 0px 0px 1px #808080}.carousel-indicators.active li{background-color:rgba(100,149,253,0.6)}.carousel-indicators.active li.active{background-color:white}.carousel-tablist-highlight{display:block;position:absolute;outline:2px solid transparent;background-color:transparent;box-shadow:0px 0px 0px 1px transparent}.carousel-tablist-highlight.focus{outline:2px solid #6495ED;background-color:rgba(0,0,0,0.4)}a.carousel-control:focus{outline:2px solid #6495ED;background-image:linear-gradient(to right, transparent 0px, rgba(0,0,0,0.5) 100%);box-shadow:0px 0px 0px 1px #000000}.carousel-pause-button{position:absolute;top:-30em;left:-300em;display:block}.carousel-pause-button.focus{top:0.5em;left:0.5em}.carousel:hover .carousel-caption,.carousel.contrast .carousel-caption{background-color:rgba(0,0,0,0.5);z-index:10}.alert-success{color:#2d4821}.alert-info{color:#214c62}.alert-warning{color:#6c4a00;background-color:#f9f1c6}.alert-danger{color:#d2322d}.alert-danger:hover{color:#a82824} diff --git a/system/application/views/melons/cantaloupe/css/common.css b/system/application/views/melons/cantaloupe/css/common.css index 9f877d1c2..7c087eb8c 100755 --- a/system/application/views/melons/cantaloupe/css/common.css +++ b/system/application/views/melons/cantaloupe/css/common.css @@ -1175,6 +1175,10 @@ label { button, .btn, input, optgroup, select, textarea { font-family: Lato, Arial, sans-serif; } +.search .form-horizontal .form-group { + margin-right: 0; + margin-left: 0; +} .btn-primary { background-color: #026697; border-color: #026697; } diff --git a/system/application/views/melons/cantaloupe/css/header.css b/system/application/views/melons/cantaloupe/css/header.css index 0f83e9570..abfd677e7 100644 --- a/system/application/views/melons/cantaloupe/css/header.css +++ b/system/application/views/melons/cantaloupe/css/header.css @@ -395,6 +395,9 @@ span.navbar-text.navbar-left.pull-left.title_wrapper.visible-xs{ margin-bottom: 1rem; font-weight: bold; } +.navbar ul.dropdown-menu>li:last-child, .navbar ul.dropdown-menu .body>ol>li:last-child, .navbar ul.dropdown-menu li.static:last-child, .navbar ul.dropdown-menu .relationships li:last-child { + margin-bottom: 0; +} .navbar ul.dropdown-menu .relationships>ul>li{ margin-bottom: 4.4rem; } @@ -527,6 +530,7 @@ span.navbar-text.navbar-left.pull-left.title_wrapper.visible-xs{ padding-left: 3.5rem; margin-left: 3rem; right: 2.2rem; + outline-color: #fff; } .tocMenu .expandedPage .relationships ol>li>a{ margin-right: 3.5rem; @@ -606,12 +610,15 @@ span.navbar-text.navbar-left.pull-left.title_wrapper.visible-xs{ color: #fff; text-decoration: none; } +.navbar ul.dropdown-menu li>a:focus-visible, #mobileMainMenuSubmenus li>a:focus-visible{ + outline-color: #fff; +} .navbar li.mainMenu ul.dropdown-menu>li:hover, .navbar li.mainMenu ul.dropdown-menu>li:focus{ background-color: transparent; } .navbar li.mainMenu>.mainMenuDropdown>#mainMenuInside>li.static{ - padding: 0 3rem; + padding: 1.5rem 3rem 0 3rem; } .navbar li.mainMenu>.mainMenuDropdown>#mainMenuInside>li.top{ margin-bottom: 1rem; @@ -638,7 +645,7 @@ span.navbar-text.navbar-left.pull-left.title_wrapper.visible-xs{ .navbar li.mainMenu>.mainMenuDropdown>#mainMenuInside>li>ol>li.is_parent>a.expand, .tocMenu .expandedPage .relationships ol>li.is_parent>a.expand{ background-color: #4c4c4c; } -.navbar li.mainMenu>.mainMenuDropdown>#mainMenuInside>li>ol>li>a.expand:hover, .tocMenu .expandedPage .relationships ol>li>a.expand:hover, +.navbar li.mainMenu>.mainMenuDropdown>#mainMenuInside>li>ol>li>a.expand:hover, .navbar li.mainMenu>.mainMenuDropdown>#mainMenuInside>li>ol>li>a.expand:focus, .tocMenu .expandedPage .relationships ol>li>a.expand:hover, .tocMenu .expandedPage .relationships ol>li>a.expand:focus{ background-color: #006793; } @@ -651,7 +658,7 @@ span.navbar-text.navbar-left.pull-left.title_wrapper.visible-xs{ .navbar ul.dropdown-menu li{ max-width: 38rem; } -.navbar ul.dropdown-menu li.vis_link{ +#vis_menu li{ max-width: inherit; } .navbar .dropdown-menu li:hover, .navbar .dropdown-menu li:active{ @@ -960,6 +967,7 @@ i.loader{ } #ScalarHeaderMenu{ + position: relative; -webkit-transition: -webkit-transform .5s; -moz-transition: -moz-transform .5s; transition: transform .5s; @@ -1144,3 +1152,19 @@ i.loader{ width: 100%; } } +#skip { + position:absolute; + left:0; + top:-100px; + text-transform: none; + background-color: black; + padding: 5px 10px; + z-index: 100; + transition: top .25s; + text-decoration: none; +} + +#skip:focus { + left: 0; + top: 0; +} \ No newline at end of file diff --git a/system/application/views/melons/cantaloupe/css/vis.css b/system/application/views/melons/cantaloupe/css/vis.css index 81ab144fb..f9046754f 100755 --- a/system/application/views/melons/cantaloupe/css/vis.css +++ b/system/application/views/melons/cantaloupe/css/vis.css @@ -16,6 +16,7 @@ div.jqcloud > span:hover {} .visList {width:100%;} .visList .header > td {border-top:solid 1px #aaaaaa; border-bottom:solid 1px #aaaaaa; white-space:nowrap; padding:6px 4px 6px 4px; font-size:13px;} -.visListRow > td {border-bottom:solid 1px #aaaaaa; padding:8px 4px 8px 4px; font-size:13px; line-height:125%;} +.visListRow > td {border-bottom:solid 1px #aaaaaa; padding:8px 4px 8px 4px; font-size:13px; line-height:125%; vertical-align:top;} .visListRow:hover {background-color:#d9edf7; cursor:pointer;} -.visListRow.selected {background-color:#c7e6f6 !important;} \ No newline at end of file +.visListRow.selected {background-color:#c7e6f6 !important;} +.visList .thumb { width:76px; max-width:76px; } \ No newline at end of file diff --git a/system/application/views/melons/cantaloupe/js/bootstrap-accessibility.min.js b/system/application/views/melons/cantaloupe/js/bootstrap-accessibility.min.js old mode 100755 new mode 100644 index 6460911fe..f67aac63c --- a/system/application/views/melons/cantaloupe/js/bootstrap-accessibility.min.js +++ b/system/application/views/melons/cantaloupe/js/bootstrap-accessibility.min.js @@ -1,4 +1,4 @@ -/*! bootstrap-accessibility-plugin - v1.0.5 - 2016-07-19 +/*! bootstrap-accessibility-plugin - v1.0.6 - 2020-05-07 * https://github.com/paypal/bootstrap-accessibility-plugin -* Copyright (c) 2016 PayPal Accessibility Team; Licensed BSD */ -!function($){"use strict";var uniqueId=function(prefix){return(prefix||"ui-id")+"-"+Math.floor(1e3*Math.random()+1)},focusable=function(element,isTabIndexNotNaN){var map,mapName,img,nodeName=element.nodeName.toLowerCase();return"area"===nodeName?(map=element.parentNode,mapName=map.name,element.href&&mapName&&"map"===map.nodeName.toLowerCase()?(img=$("img[usemap='#"+mapName+"']")[0],!!img&&visible(img)):!1):(/input|select|textarea|button|object/.test(nodeName)?!element.disabled:"a"===nodeName?element.href||isTabIndexNotNaN:isTabIndexNotNaN)&&visible(element)},visible=function(element){return $.expr.filters.visible(element)&&!$(element).parents().addBack().filter(function(){return"hidden"===$.css(this,"visibility")}).length};$.extend($.expr[":"],{data:$.expr.createPseudo?$.expr.createPseudo(function(dataName){return function(elem){return!!$.data(elem,dataName)}}):function(elem,i,match){return!!$.data(elem,match[3])},focusable:function(element){return focusable(element,!isNaN($.attr(element,"tabindex")))},tabbable:function(element){var tabIndex=$.attr(element,"tabindex"),isTabIndexNaN=isNaN(tabIndex);return(isTabIndexNaN||tabIndex>=0)&&focusable(element,!isTabIndexNaN)}}),$(".modal-dialog").attr({role:"document"});var modalhide=$.fn.modal.Constructor.prototype.hide;$.fn.modal.Constructor.prototype.hide=function(){modalhide.apply(this,arguments),$(document).off("keydown.bs.modal")};var modalfocus=$.fn.modal.Constructor.prototype.enforceFocus;$.fn.modal.Constructor.prototype.enforceFocus=function(){var $content=this.$element.find(".modal-content"),focEls=$content.find(":tabbable"),$lastEl=$(focEls[focEls.length-1]),$firstEl=$(focEls[0]);$lastEl.on("keydown.bs.modal",$.proxy(function(ev){9!==ev.keyCode||ev.shiftKey|ev.ctrlKey|ev.metaKey|ev.altKey||(ev.preventDefault(),$firstEl.focus())},this)),$firstEl.on("keydown.bs.modal",$.proxy(function(ev){9===ev.keyCode&&ev.shiftKey&&(ev.preventDefault(),$lastEl.focus())},this)),modalfocus.apply(this,arguments)};var $par,firstItem,toggle="[data-toggle=dropdown]",focusDelay=200,menus=$(toggle).parent().find("ul").attr("role","menu"),lis=menus.find("li").attr("role","presentation");lis.find("a").attr({role:"menuitem",tabIndex:"-1"}),$(toggle).attr({"aria-haspopup":"true","aria-expanded":"false"}),$(toggle).parent().on("shown.bs.dropdown",function(e){$par=$(this);var $toggle=$par.find(toggle);$toggle.attr("aria-expanded","true"),$toggle.on("keydown.bs.dropdown",$.proxy(function(ev){setTimeout(function(){firstItem=$(".dropdown-menu [role=menuitem]:visible",$par)[0];try{firstItem.focus()}catch(ex){}},focusDelay)},this))}).on("hidden.bs.dropdown",function(e){$par=$(this);var $toggle=$par.find(toggle);$toggle.attr("aria-expanded","false")}),$(document).on("focusout.dropdown.data-api",".dropdown-menu",function(e){var $this=$(this),that=this;$this.parent().hasClass("open")&&setTimeout(function(){$.contains(that,document.activeElement)||$this.parent().find("[data-toggle=dropdown]").dropdown("toggle")},150)}).on("keydown.bs.dropdown.data-api",toggle+", [role=menu]",$.fn.dropdown.Constructor.prototype.keydown);var $tablist=$(".nav-tabs, .nav-pills"),$lis=$tablist.children("li"),$tabs=$tablist.find('[data-toggle="tab"], [data-toggle="pill"]');$tabs&&($tablist.attr("role","tablist"),$lis.attr("role","presentation"),$tabs.attr("role","tab")),$tabs.each(function(index){var tabpanel=$($(this).attr("href")),tab=$(this),tabid=tab.attr("id")||uniqueId("ui-tab");tab.attr("id",tabid),tab.parent().hasClass("active")?(tab.attr({tabIndex:"0","aria-selected":"true","aria-controls":tab.attr("href").substr(1)}),tabpanel.attr({role:"tabpanel",tabIndex:"0","aria-hidden":"false","aria-labelledby":tabid})):(tab.attr({tabIndex:"-1","aria-selected":"false","aria-controls":tab.attr("href").substr(1)}),tabpanel.attr({role:"tabpanel",tabIndex:"-1","aria-hidden":"true","aria-labelledby":tabid}))}),$.fn.tab.Constructor.prototype.keydown=function(e){var $items,index,$this=$(this),$ul=$this.closest("ul[role=tablist] "),k=e.which||e.keyCode;if($this=$(this),/(37|38|39|40)/.test(k)){$items=$ul.find("[role=tab]:visible"),index=$items.index($items.filter(":focus")),(38==k||37==k)&&index--,(39==k||40==k)&&index++,0>index&&(index=$items.length-1),index==$items.length&&(index=0);var nextTab=$items.eq(index);"tab"===nextTab.attr("role")&&nextTab.tab("show").focus(),e.preventDefault(),e.stopPropagation()}},$(document).on("keydown.tab.data-api",'[data-toggle="tab"], [data-toggle="pill"]',$.fn.tab.Constructor.prototype.keydown);var tabactivate=$.fn.tab.Constructor.prototype.activate;$.fn.tab.Constructor.prototype.activate=function(element,container,callback){var $active=container.find("> .active");$active.find("[data-toggle=tab], [data-toggle=pill]").attr({tabIndex:"-1","aria-selected":!1}),$active.filter(".tab-pane").attr({"aria-hidden":!0,tabIndex:"-1"}),tabactivate.apply(this,arguments),element.addClass("active"),element.find("[data-toggle=tab], [data-toggle=pill]").attr({tabIndex:"0","aria-selected":!0}),element.filter(".tab-pane").attr({"aria-hidden":!1,tabIndex:"0"})};var $colltabs=$('[data-toggle="collapse"]');$colltabs.each(function(index){var colltab=$(this),collpanel=$(colltab.attr("data-target")?colltab.attr("data-target"):colltab.attr("href")),parent=colltab.attr("data-parent"),collparent=parent&&$(parent),collid=colltab.attr("id")||uniqueId("ui-collapse");colltab.attr("id",collid),collparent&&(colltab.attr({role:"tab","aria-selected":"false","aria-expanded":"false"}),$(collparent).find("div:not(.collapse,.panel-body), h4").attr("role","presentation"),collparent.attr({role:"tablist","aria-multiselectable":"true"}),collpanel.hasClass("in")?(colltab.attr({"aria-controls":collpanel.attr("id"),"aria-selected":"true","aria-expanded":"true",tabindex:"0"}),collpanel.attr({role:"tabpanel",tabindex:"0","aria-labelledby":collid,"aria-hidden":"false"})):(colltab.attr({"aria-controls":collpanel.attr("id"),tabindex:"-1"}),collpanel.attr({role:"tabpanel",tabindex:"-1","aria-labelledby":collid,"aria-hidden":"true"})))});var collToggle=$.fn.collapse.Constructor.prototype.toggle;$.fn.collapse.Constructor.prototype.toggle=function(){var href,prevTab=this.$parent&&this.$parent.find('[aria-expanded="true"]');if(prevTab){var curTab,prevPanel=prevTab.attr("data-target")||(href=prevTab.attr("href"))&&href.replace(/.*(?=#[^\s]+$)/,""),$prevPanel=$(prevPanel),$curPanel=this.$element;this.$parent;this.$parent&&(curTab=this.$parent.find('[data-toggle=collapse][href="#'+this.$element.attr("id")+'"]')),collToggle.apply(this,arguments),$.support.transition&&this.$element.one($.support.transition.end,function(){prevTab.attr({"aria-selected":"false","aria-expanded":"false",tabIndex:"-1"}),$prevPanel.attr({"aria-hidden":"true",tabIndex:"-1"}),curTab.attr({"aria-selected":"true","aria-expanded":"true",tabIndex:"0"}),$curPanel.hasClass("in")?$curPanel.attr({"aria-hidden":"false",tabIndex:"0"}):(curTab.attr({"aria-selected":"false","aria-expanded":"false"}),$curPanel.attr({"aria-hidden":"true",tabIndex:"-1"}))})}else collToggle.apply(this,arguments)},$.fn.collapse.Constructor.prototype.keydown=function(e){var $items,index,$this=$(this),$tablist=$this.closest("div[role=tablist] "),k=e.which||e.keyCode;$this=$(this),/(32|37|38|39|40)/.test(k)&&(32==k&&$this.trigger('click'),$items=$tablist.find("[role=tab]"),index=$items.index($items.filter(":focus")),(38==k||37==k)&&index--,(39==k||40==k)&&index++,0>index&&(index=$items.length-1),index==$items.length&&(index=0),$items.eq(index).focus(),e.preventDefault(),e.stopPropagation())},$(document).on("keydown.collapse.data-api",'[data-toggle="collapse"]',$.fn.collapse.Constructor.prototype.keydown),$(".carousel").each(function(index){function setTablistHighlightBox(){var $tab,offset,height,width,highlightBox={};highlightBox.top=0,highlightBox.left=32e3,highlightBox.height=0,highlightBox.width=0;for(var i=0;i<$tabs.length;i++){$tab=$tabs[i],offset=$($tab).offset(),height=$($tab).height(),width=$($tab).width(),highlightBox.topoffset.left&&(highlightBox.left=Math.round(offset.left));var w=offset.left-highlightBox.left+Math.round(width);highlightBox.widthA carousel is a rotating set of images, rotation stops on keyboard focus on carousel tab controls or hovering the mouse pointer over images. Use the tabs or the previous and next buttons to change the displayed slide.

'),$this.prepend('

Carousel content with '+$tabpanels.length+" slides.

")),i=0;i<$tabs.length;i++){$tab=$tabs[i],$tab.setAttribute("role","tab"),$tab.setAttribute("id","tab-"+index+"-"+i),$tab.setAttribute("aria-controls","tabpanel-"+index+"-"+i);var tpId="#tabpanel-"+index+"-"+i,caption=$this.find(tpId).find("h1").text();("string"!=typeof caption||0===caption.length)&&(caption=$this.find(tpId).text()),("string"!=typeof caption||0===caption.length)&&(caption=$this.find(tpId).find("h3").text()),("string"!=typeof caption||0===caption.length)&&(caption=$this.find(tpId).find("h4").text()),("string"!=typeof caption||0===caption.length)&&(caption=$this.find(tpId).find("h5").text()),("string"!=typeof caption||0===caption.length)&&(caption=$this.find(tpId).find("h6").text()),("string"!=typeof caption||0===caption.length)&&(caption="no title");var tabName=document.createElement("span");tabName.setAttribute("class","sr-only"),tabName.innerHTML="Slide "+(i+1),caption&&(tabName.innerHTML+=": "+caption),$tab.appendChild(tabName)}$tablistHighlight=document.createElement("div"),$tablistHighlight.className="carousel-tablist-highlight",document.body.appendChild($tablistHighlight),$complementaryLandmark=document.createElement("aside"),$complementaryLandmark.setAttribute("class","carousel-aside-pause"),$complementaryLandmark.setAttribute("aria-label","carousel pause/play control"),$this.prepend($complementaryLandmark),$pauseCarousel=document.createElement("button"),$pauseCarousel.className="carousel-pause-button",$pauseCarousel.innerHTML="Pause Carousel",$pauseCarousel.setAttribute("title","Pause/Play carousel button can be used by screen reader users to stop carousel animations"),$($complementaryLandmark).append($pauseCarousel),$($pauseCarousel).on('click', function(){$is_paused?($pauseCarousel.innerHTML="Pause Carousel",$this.carousel("cycle"),$is_paused=!1):($pauseCarousel.innerHTML="Play Carousel",$this.carousel("pause"),$is_paused=!0)}),$($pauseCarousel).focus(function(){$(this).addClass("focus")}),$($pauseCarousel).blur(function(){$(this).removeClass("focus")}),setTablistHighlightBox(),$(window).on('resize', function(){setTablistHighlightBox()}),$prev.attr("aria-label","Previous Slide"),$prev.on('keydown', function(e){var k=e.which||e.keyCode;/(13|32)/.test(k)&&(e.preventDefault(),e.stopPropagation(),$prev.trigger("click"))}),$prev.focus(function(){$(this).parents(".carousel").addClass("contrast")}),$prev.blur(function(){$(this).parents(".carousel").removeClass("contrast")}),$next.attr("aria-label","Next Slide"),$next.on('keydown', function(e){var k=e.which||e.keyCode;/(13|32)/.test(k)&&(e.preventDefault(),e.stopPropagation(),$next.trigger("click"))}),$next.focus(function(){$(this).parents(".carousel").addClass("contrast")}),$next.blur(function(){$(this).parents(".carousel").removeClass("contrast")}),$(".carousel-inner a").focus(function(){$(this).parents(".carousel").addClass("contrast")}),$(".carousel-inner a").blur(function(){$(this).parents(".carousel").removeClass("contrast")}),$tabs.each(function(){var item=$(this);item.hasClass("active")?item.attr({"aria-selected":"true",tabindex:"0"}):item.attr({"aria-selected":"false",tabindex:"-1"})})});var slideCarousel=$.fn.carousel.Constructor.prototype.slide;$.fn.carousel.Constructor.prototype.slide=function(type,next){var $id,$element=this.$element,$active=$element.find("[role=tabpanel].active"),$next=next||$active[type](),$tab_count=$element.find("[role=tabpanel]").size(),$prev_side=$element.find('[data-slide="prev"]'),$next_side=$element.find('[data-slide="next"]'),$index=0,$prev_index=$tab_count-1,$next_index=1;$next&&$next.attr("id")&&($id=$next.attr("id"),$index=$id.lastIndexOf("-"),$index>=0&&($index=parseInt($id.substring($index+1),10)),$prev_index=$index-1,1>$prev_index&&($prev_index=$tab_count-1),$next_index=$index+1,$next_index>=$tab_count&&($next_index=0)),$prev_side.attr("aria-label","Show slide "+($prev_index+1)+" of "+$tab_count),$next_side.attr("aria-label","Show slide "+($next_index+1)+" of "+$tab_count),slideCarousel.apply(this,arguments),$active.one("bsTransitionEnd",function(){var $tab;$tab=$element.find('li[aria-controls="'+$active.attr("id")+'"]'),$tab&&$tab.attr({"aria-selected":!1,tabIndex:"-1"}),$tab=$element.find('li[aria-controls="'+$next.attr("id")+'"]'),$tab&&$tab.attr({"aria-selected":!0,tabIndex:"0"})})};var $this;$.fn.carousel.Constructor.prototype.keydown=function(e){function selectTab(index){index>=$tabs.length||0>index||($carousel.carousel(index),setTimeout(function(){$tabs[index].focus()},150))}$this=$this||$(this),this instanceof Node&&($this=$(this));var index,$carousel=$(e.target).closest(".carousel"),$tabs=$carousel.find("[role=tab]"),k=e.which||e.keyCode;/(37|38|39|40)/.test(k)&&(index=$tabs.index($tabs.filter(".active")),(37==k||38==k)&&(index--,selectTab(index)),(39==k||40==k)&&(index++,selectTab(index)),e.preventDefault(),e.stopPropagation())},$(document).on("keydown.carousel.data-api","li[role=tab]",$.fn.carousel.Constructor.prototype.keydown)}(jQuery); +* Copyright (c) 2020 PayPal Accessibility Team; Licensed BSD */ +!function($){"use strict";var uniqueId=function(prefix){return(prefix||"ui-id")+"-"+Math.floor(1e3*Math.random()+1)},focusable=function(element,isTabIndexNotNaN){var map,mapName,img,nodeName=element.nodeName.toLowerCase();return"area"===nodeName?(map=element.parentNode,mapName=map.name,element.href&&mapName&&"map"===map.nodeName.toLowerCase()?(img=$("img[usemap='#"+mapName+"']")[0],!!img&&visible(img)):!1):(/input|select|textarea|button|object/.test(nodeName)?!element.disabled:"a"===nodeName?element.href||isTabIndexNotNaN:isTabIndexNotNaN)&&visible(element)},visible=function(element){return $.expr.filters.visible(element)&&!$(element).parents().addBack().filter(function(){return"hidden"===$.css(this,"visibility")}).length};$.extend($.expr[":"],{data:$.expr.createPseudo?$.expr.createPseudo(function(dataName){return function(elem){return!!$.data(elem,dataName)}}):function(elem,i,match){return!!$.data(elem,match[3])},focusable:function(element){return focusable(element,!isNaN($.attr(element,"tabindex")))},tabbable:function(element){var tabIndex=$.attr(element,"tabindex"),isTabIndexNaN=isNaN(tabIndex);return(isTabIndexNaN||tabIndex>=0)&&focusable(element,!isTabIndexNaN)}}),$(".modal-dialog").attr({role:"document"});var modalhide=$.fn.modal.Constructor.prototype.hide;$.fn.modal.Constructor.prototype.hide=function(){modalhide.apply(this,arguments),$(document).off("keydown.bs.modal")};var modalfocus=$.fn.modal.Constructor.prototype.enforceFocus;$.fn.modal.Constructor.prototype.enforceFocus=function(){var $content=this.$element.find(".modal-content"),focEls=$content.find(":tabbable"),$lastEl=$(focEls[focEls.length-1]),$firstEl=$(focEls[0]);$lastEl.on("keydown.bs.modal",$.proxy(function(ev){9!==ev.keyCode||ev.shiftKey|ev.ctrlKey|ev.metaKey|ev.altKey||(ev.preventDefault(),$firstEl.focus())},this)),$firstEl.on("keydown.bs.modal",$.proxy(function(ev){9===ev.keyCode&&ev.shiftKey&&(ev.preventDefault(),$lastEl.focus())},this)),modalfocus.apply(this,arguments)};var $par,firstItem,toggle="[data-toggle=dropdown]",focusDelay=200,menus=$(toggle).parent().find("ul").attr("role","menu"),lis=menus.find("li").attr("role","presentation");lis.find("a").attr({role:"menuitem",tabIndex:"-1"}),$(toggle).attr({"aria-haspopup":"true","aria-expanded":"false"}),$(toggle).parent().on("shown.bs.dropdown",function(e){$par=$(this);var $toggle=$par.find(toggle);$toggle.attr("aria-expanded","true"),$toggle.on("keydown.bs.dropdown",$.proxy(function(ev){setTimeout(function(){firstItem=$(".dropdown-menu [role=menuitem]:visible",$par)[0];try{firstItem.focus()}catch(ex){}},focusDelay)},this))}).on("hidden.bs.dropdown",function(e){$par=$(this);var $toggle=$par.find(toggle);$toggle.attr("aria-expanded","false")}),$(document).on("focusout.dropdown.data-api",".dropdown-menu",function(e){var $this=$(this),that=this;$this.parent().hasClass("open")&&setTimeout(function(){$.contains(that,document.activeElement)||$this.parent().find("[data-toggle=dropdown]").dropdown("toggle")},150)}).on("keydown.bs.dropdown.data-api",toggle+", [role=menu]",$.fn.dropdown.Constructor.prototype.keydown);var $tablist=$(".nav-tabs, .nav-pills"),$lis=$tablist.children("li"),$tabs=$tablist.find('[data-toggle="tab"], [data-toggle="pill"]');$tabs&&($tablist.attr("role","tablist"),$lis.attr("role","presentation"),$tabs.attr("role","tab")),$tabs.each(function(index){var tabpanel=$($(this).attr("href")),tab=$(this),tabid=tab.attr("id")||uniqueId("ui-tab");tab.attr("id",tabid),tab.parent().hasClass("active")?(tab.attr({tabIndex:"0","aria-selected":"true","aria-controls":tab.attr("href").substr(1)}),tabpanel.attr({role:"tabpanel",tabIndex:"0","aria-hidden":"false","aria-labelledby":tabid})):(tab.attr({tabIndex:"-1","aria-selected":"false","aria-controls":tab.attr("href").substr(1)}),tabpanel.attr({role:"tabpanel",tabIndex:"-1","aria-hidden":"true","aria-labelledby":tabid}))}),$.fn.tab.Constructor.prototype.keydown=function(e){var $items,index,$this=$(this),$ul=$this.closest("ul[role=tablist] "),k=e.which||e.keyCode;if($this=$(this),/(37|38|39|40)/.test(k)){$items=$ul.find("[role=tab]:visible"),index=$items.index($items.filter(":focus")),(38==k||37==k)&&index--,(39==k||40==k)&&index++,0>index&&(index=$items.length-1),index==$items.length&&(index=0);var nextTab=$items.eq(index);"tab"===nextTab.attr("role")&&nextTab.tab("show").focus(),e.preventDefault(),e.stopPropagation()}},$(document).on("keydown.tab.data-api",'[data-toggle="tab"], [data-toggle="pill"]',$.fn.tab.Constructor.prototype.keydown);var tabactivate=$.fn.tab.Constructor.prototype.activate;$.fn.tab.Constructor.prototype.activate=function(element,container,callback){var $active=container.find("> .active");$active.find("[data-toggle=tab], [data-toggle=pill]").attr({tabIndex:"-1","aria-selected":!1}),$active.filter(".tab-pane").attr({"aria-hidden":!0,tabIndex:"-1"}),tabactivate.apply(this,arguments),element.addClass("active"),element.find("[data-toggle=tab], [data-toggle=pill]").attr({tabIndex:"0","aria-selected":!0}),element.filter(".tab-pane").attr({"aria-hidden":!1,tabIndex:"0"})};var $colltabs=$('[data-toggle="collapse"]');$colltabs.each(function(index){var colltab=$(this),collpanel=$(colltab.attr("data-target")?colltab.attr("data-target"):colltab.attr("href")),parent=colltab.attr("data-parent"),collparent=parent&&$(parent),collid=colltab.attr("id")||uniqueId("ui-collapse"),parentpanel=collpanel.parent(),parentfirstchild=collparent?collparent.find(".panel.panel-default:first-child"):null,hasopenpanel=collparent?collparent.find(".panel-collapse.in").length>0:!1;colltab.attr("id",collid),collparent&&(colltab.attr({"aria-controls":collpanel.attr("id"),role:"tab","aria-selected":"false","aria-expanded":"false"}),$(collparent).find("div:not(.collapse,.panel-body), h4").attr("role","presentation"),collparent.attr({role:"tablist","aria-multiselectable":"true"}),collpanel.attr({role:"tabpanel","aria-labelledby":collid}),!hasopenpanel&&parentpanel.is(parentfirstchild)?(colltab.attr({tabindex:"0"}),collpanel.attr({tabindex:"-1"})):collpanel.hasClass("in")?(colltab.attr({"aria-selected":"true","aria-expanded":"true",tabindex:"0"}),collpanel.attr({tabindex:"0","aria-hidden":"false"})):(colltab.attr({tabindex:"-1"}),collpanel.attr({tabindex:"-1","aria-hidden":"true"})))});var collToggle=$.fn.collapse.Constructor.prototype.toggle;$.fn.collapse.Constructor.prototype.toggle=function(){var href,prevTab=this.$parent&&this.$parent.find('[aria-expanded="true"]');if(prevTab){var curTab,prevPanel=prevTab.attr("data-target")||(href=prevTab.attr("href"))&&href.replace(/.*(?=#[^\s]+$)/,""),$prevPanel=$(prevPanel),$curPanel=this.$element;this.$parent;this.$parent&&(curTab=this.$parent.find('[data-toggle=collapse][href="#'+this.$element.attr("id")+'"]')),collToggle.apply(this,arguments),$.support.transition&&this.$element.one($.support.transition.end,function(){prevTab.attr({"aria-selected":"false","aria-expanded":"false",tabIndex:"-1"}),$prevPanel.attr({"aria-hidden":"true",tabIndex:"-1"}),curTab.attr({"aria-selected":"true","aria-expanded":"true",tabIndex:"0"}),$curPanel.hasClass("in")?$curPanel.attr({"aria-hidden":"false",tabIndex:"0"}):(curTab.attr({"aria-selected":"false","aria-expanded":"false"}),$curPanel.attr({"aria-hidden":"true",tabIndex:"-1"}))})}else collToggle.apply(this,arguments)},$.fn.collapse.Constructor.prototype.keydown=function(e){var $items,index,$this=$(this),$tablist=$this.closest("div[role=tablist] "),k=e.which||e.keyCode;$this=$(this),/(32|37|38|39|40)/.test(k)&&(32==k&&$this.click(),$items=$tablist.find("[role=tab]"),index=$items.index($items.filter(":focus")),(38==k||37==k)&&index--,(39==k||40==k)&&index++,0>index&&(index=$items.length-1),index==$items.length&&(index=0),$items.eq(index).focus(),e.preventDefault(),e.stopPropagation())},$(document).on("keydown.collapse.data-api",'[data-toggle="collapse"]',$.fn.collapse.Constructor.prototype.keydown),$(".carousel").each(function(index){function setTablistHighlightBox(){var $tab,offset,height,width,highlightBox={};highlightBox.top=0,highlightBox.left=32e3,highlightBox.height=0,highlightBox.width=0;for(var i=0;i<$tabs.length;i++){$tab=$tabs[i],offset=$($tab).offset(),height=$($tab).height(),width=$($tab).width(),highlightBox.topoffset.left&&(highlightBox.left=Math.round(offset.left));var w=offset.left-highlightBox.left+Math.round(width);highlightBox.widthA carousel is a rotating set of images, rotation stops on keyboard focus on carousel tab controls or hovering the mouse pointer over images. Use the tabs or the previous and next buttons to change the displayed slide.

'),$this.prepend('

Carousel content with '+$tabpanels.length+" slides.

")),i=0;i<$tabs.length;i++){$tab=$tabs[i],$tab.setAttribute("role","tab"),$tab.setAttribute("id","tab-"+index+"-"+i),$tab.setAttribute("aria-controls","tabpanel-"+index+"-"+i);var tpId="#tabpanel-"+index+"-"+i,caption=$this.find(tpId).find("h1").text();("string"!=typeof caption||0===caption.length)&&(caption=$this.find(tpId).text()),("string"!=typeof caption||0===caption.length)&&(caption=$this.find(tpId).find("h3").text()),("string"!=typeof caption||0===caption.length)&&(caption=$this.find(tpId).find("h4").text()),("string"!=typeof caption||0===caption.length)&&(caption=$this.find(tpId).find("h5").text()),("string"!=typeof caption||0===caption.length)&&(caption=$this.find(tpId).find("h6").text()),("string"!=typeof caption||0===caption.length)&&(caption="no title");var tabName=document.createElement("span");tabName.setAttribute("class","sr-only"),tabName.innerHTML="Slide "+(i+1),caption&&(tabName.innerHTML+=": "+caption),$tab.appendChild(tabName)}$tablistHighlight=document.createElement("div"),$tablistHighlight.className="carousel-tablist-highlight",document.body.appendChild($tablistHighlight),$complementaryLandmark=document.createElement("aside"),$complementaryLandmark.setAttribute("class","carousel-aside-pause"),$complementaryLandmark.setAttribute("aria-label","carousel pause/play control"),$this.prepend($complementaryLandmark),$pauseCarousel=document.createElement("button"),$pauseCarousel.className="carousel-pause-button",$pauseCarousel.innerHTML="Pause Carousel",$pauseCarousel.setAttribute("title","Pause/Play carousel button can be used by screen reader users to stop carousel animations"),$($complementaryLandmark).append($pauseCarousel),$($pauseCarousel).click(function(){$is_paused?($pauseCarousel.innerHTML="Pause Carousel",$this.carousel("cycle"),$is_paused=!1):($pauseCarousel.innerHTML="Play Carousel",$this.carousel("pause"),$is_paused=!0)}),$($pauseCarousel).focus(function(){$(this).addClass("focus")}),$($pauseCarousel).blur(function(){$(this).removeClass("focus")}),setTablistHighlightBox(),$(window).resize(function(){setTablistHighlightBox()}),$prev.attr("aria-label","Previous Slide"),$prev.keydown(function(e){var k=e.which||e.keyCode;/(13|32)/.test(k)&&(e.preventDefault(),e.stopPropagation(),$prev.trigger("click"))}),$prev.focus(function(){$(this).parents(".carousel").addClass("contrast")}),$prev.blur(function(){$(this).parents(".carousel").removeClass("contrast")}),$next.attr("aria-label","Next Slide"),$next.keydown(function(e){var k=e.which||e.keyCode;/(13|32)/.test(k)&&(e.preventDefault(),e.stopPropagation(),$next.trigger("click"))}),$next.focus(function(){$(this).parents(".carousel").addClass("contrast")}),$next.blur(function(){$(this).parents(".carousel").removeClass("contrast")}),$(".carousel-inner a").focus(function(){$(this).parents(".carousel").addClass("contrast")}),$(".carousel-inner a").blur(function(){$(this).parents(".carousel").removeClass("contrast")}),$tabs.each(function(){var item=$(this);item.hasClass("active")?item.attr({"aria-selected":"true",tabindex:"0"}):item.attr({"aria-selected":"false",tabindex:"-1"})})});var slideCarousel=$.fn.carousel.Constructor.prototype.slide;$.fn.carousel.Constructor.prototype.slide=function(type,next){var $id,$element=this.$element,$active=$element.find("[role=tabpanel].active"),$next=next||$active[type](),$tab_count=$element.find("[role=tabpanel]").length,$prev_side=$element.find('[data-slide="prev"]'),$next_side=$element.find('[data-slide="next"]'),$index=0,$prev_index=$tab_count-1,$next_index=1;$next&&$next.attr("id")&&($id=$next.attr("id"),$index=$id.lastIndexOf("-"),$index>=0&&($index=parseInt($id.substring($index+1),10)),$prev_index=$index-1,1>$prev_index&&($prev_index=$tab_count-1),$next_index=$index+1,$next_index>=$tab_count&&($next_index=0)),$prev_side.attr("aria-label","Show slide "+($prev_index+1)+" of "+$tab_count),$next_side.attr("aria-label","Show slide "+($next_index+1)+" of "+$tab_count),slideCarousel.apply(this,arguments),$active.one("bsTransitionEnd",function(){var $tab;$tab=$element.find('li[aria-controls="'+$active.attr("id")+'"]'),$tab&&$tab.attr({"aria-selected":!1,tabIndex:"-1"}),$tab=$element.find('li[aria-controls="'+$next.attr("id")+'"]'),$tab&&$tab.attr({"aria-selected":!0,tabIndex:"0"})})};var $this;$.fn.carousel.Constructor.prototype.keydown=function(e){function selectTab(index){index>=$tabs.length||0>index||($carousel.carousel(index),setTimeout(function(){$tabs[index].focus()},150))}$this=$this||$(this),this instanceof Node&&($this=$(this));var index,$carousel=$(e.target).closest(".carousel"),$tabs=$carousel.find("[role=tab]"),k=e.which||e.keyCode;/(37|38|39|40)/.test(k)&&(index=$tabs.index($tabs.filter(".active")),(37==k||38==k)&&(index--,selectTab(index)),(39==k||40==k)&&(index++,selectTab(index)),e.preventDefault(),e.stopPropagation())},$(document).on("keydown.carousel.data-api","li[role=tab]",$.fn.carousel.Constructor.prototype.keydown)}(jQuery); \ No newline at end of file diff --git a/system/application/views/melons/cantaloupe/js/scalarheader.jquery.js b/system/application/views/melons/cantaloupe/js/scalarheader.jquery.js old mode 100755 new mode 100644 index db496f1f1..4a892676e --- a/system/application/views/melons/cantaloupe/js/scalarheader.jquery.js +++ b/system/application/views/melons/cantaloupe/js/scalarheader.jquery.js @@ -1,9 +1,3 @@ -//getComputedStyle Polyfill - needed for IE<=8 -"getComputedStyle"in this||(this.getComputedStyle=function(){function g(a,b,c,e){var d=b[c];b=parseFloat(d);d=d.split(/\d/)[0];e=null!=e?e:/%|em/.test(d)&&a.parentElement?g(a.parentElement,a.parentElement.currentStyle,"fontSize",null):16;a="fontSize"==c?e:/width/i.test(c)?a.clientWidth:a.clientHeight;return"em"==d?b*e:"in"==d?96*b:"pt"==d?96*b/72:"%"==d?b/100*a:b}function h(a,b){var c="border"==b?"Width":"",e=b+"Top"+c,d=b+"Right"+c,f=b+"Bottom"+c,c=b+"Left"+c;a[b]=(a[e]==a[d]==a[f]==a[c]?[a[e]]: -a[e]==a[f]&&a[c]==a[d]?[a[e],a[d]]:a[c]==a[d]?[a[e],a[d],a[f]]:[a[e],a[d],a[f],a[c]]).join(" ")}function k(a){var b=a.currentStyle,c=g(a,b,"fontSize",null);for(property in b)/width|height|margin.|padding.|border.+W/.test(property)&&"auto"!==this[property]?this[property]=g(a,b,property,c)+"px":"styleFloat"===property?this["float"]=b[property]:this[property]=b[property];h(this,"margin");h(this,"padding");h(this,"border");this.fontSize=c+"px";return this}k.prototype={constructor:k,getPropertyPriority:function(){}, -getPropertyValue:function(a){return this[a]||""},item:function(){},removeProperty:function(){},setProperty:function(){},getPropertyCSSValue:function(){}};return function(a){return new k(a)}}(this)); - - /** * Scalar * Copyright 2013 The Alliance for Networking Visual Culture. @@ -22,2075 +16,2108 @@ getPropertyValue:function(a){return this[a]||""},item:function(){},removePropert * or implied. See the License for the specific language governing * permissions and limitations under the License. */ - (function($){ - $.scalarheader = function(el, options){ - // To avoid scope issues, use 'base' instead of 'this' - // to reference this class from internal events and functions. - var base = this; - - // Access to jQuery and DOM versions of element - base.$el = $(el); - base.el = el; - base.usingMobileView = false; - base.parentNodes = []; - base.checkedParents = []; - base.visitedPages = []; - base.oldScrollTop = 0; - base.dataType = 'normal'; - base.usingHypothesis = $('link#hypothesis').attr('href') === 'true'; - base.editorialWorkflowEnabled = $('link#editorial_workflow').attr('href') === 'true'; - base.remToPx = parseFloat(getComputedStyle(document.documentElement).fontSize); - base.editorialStates = { - "none": { id: "none", name: null }, - "draft": { id: "draft", name: "Draft" }, - "edit": { id: "edit", name: "Edit" }, - "editreview": { id: "editreview", name: "Edit Review" }, - "clean": { id: "clean", name: "Clean" }, - "ready": { id: "ready", name: "Ready" }, - "published": { id: "published", name: "Published" }, - } - base.editorialBarData = { - "author": { - "draft": { - "text": "This $contentType is in the $editorialState state and has $openQueryCount open queries.
Continue working until you're ready to submit it for editing.", - "previousEditorialState": null, - "nextEditorialState": "edit", - "actions": ["Edit $contentType","Dashboard"] +(function($){ + $.scalarheader = function(el, options){ + var base = this + base.$el = $(el) + base.el = el + + base.usingMobileView = false; + // TODO: fill in the rest of these items + base.$el.data("scalarheader", base); + + base.init = function() { + base.options = $.extend({},$.scalarheader.defaultOptions, options); + base.currentNode = scalarapi.model.getCurrentPageNode(); + base.parentNodes = []; + base.checkedParents = []; + base.visitedPages = []; + base.index_url = scalarapi.model.parent_uri.slice(0, -1); + base.index_url = base.index_url.substr(0, base.index_url.lastIndexOf('/'))+'/'; + base.remToPx = parseFloat(getComputedStyle(document.documentElement).fontSize); + //We might not have the current page loaded, but we can still get the slug; strip the book URL and the GET params from the current URL + base.current_slug = window.location.href.split("?")[0].split("#")[0].replace(scalarapi.model.parent_uri,''); + + base.menuData = { + main: { + menu: { + class: 'mainMenu', + label: 'Table of Contents', + description: 'Main navigation for the project', + contentsClass: 'mainMenuDropdown', + contents: ''+ + '' + }, + items: [], + }, + wayfinding: { + menu: { + id: 'navMenu', + label: 'Wayfinding', + description: 'Various ways to explore Scalar', + icon: 'wayfindingIcon', + }, + items: [ + { + id: 'recent_menu', + text: 'Recent', + icon: 'recentIcon', + placeholder: '
  • ', + submenu: [] + }, + { + id: 'lenses_menu', + text: 'Lenses', + icon: 'lensIcon', + submenu: [] + }, + { + id: 'vis_menu', + text: 'Visualizations', + icon: 'visIcon', + submenu: [ + { + text: 'Current', + icon: 'currentIcon', + class: 'vis_link', + data: { vistype: 'viscurrent' }, }, - "edit": { - "text": "This $contentType is in the $editorialState state and has $openQueryCount open queries.
    Once an editor moves it into $nextEditorialState, you can respond to any changes or queries.", - "previousEditorialState": "draft", - "nextEditorialState": "editreview", - "actions": ["Dashboard"] + { + text: 'Contents', + icon: 'tocIcon', + class: 'vis_link', + data: { vistype: 'vistoc' }, }, - "editreview": { - "text": "This $contentType is in the $editorialState state and has $openQueryCount open queries.
    Edit this page to review and respond to editor changes and queries, moving it to the $nextEditorialState state once all issues have been addressed. Use the Editorial Path to view all changes at once.", - "previousEditorialState": "edit", - "nextEditorialState": "clean", - "actions": ["Edit $contentType","Editorial Path"] + { + text: 'Connections', + icon: 'connectionsIcon', + class: 'vis_link', + data: { vistype: 'visconnections' }, }, - "clean": { - "text": "This $contentType is in the $editorialState state and has $openQueryCount open queries.
    An editor will review and either move it back to the $previousEditorialState state for further changes, or into the $nextEditorialState state for publication.", - "previousEditorialState": "editreview", - "nextEditorialState": "ready", - "actions": ["Dashboard"] + { + text: 'Grid', + icon: 'gridIcon', + class: 'vis_link', + data: { vistype: 'visindex' }, }, - "ready": { - "text": "This $contentType is in the $editorialState state and has $openQueryCount open queries.
    An editor will move it to the $nextEditorialState state when it’s time to make it public.", - "previousEditorialState": "clean", - "nextEditorialState": "published", - "actions": ["Dashboard"] + { + text: 'Map', + icon: 'mapIcon', + class: 'vis_link', + data: { vistype: 'vismap' }, }, - "published": null, - "pastVersion": { - "text": "Version $versionNum of this $contentType was in the $editorialState state.
    Go to the latest version to see its current state.", - "previousEditorialState": null, - "nextEditorialState": null, - "actions": ["Latest version"] - } - }, - "editor": { - "draft": { - "text": "This $contentType is in the $editorialState state and has $openQueryCount open queries.
    Please wait for the author to submit it for editing.", - "previousEditorialState": null, - "nextEditorialState": "edit", - "actions": ["Dashboard"] + { + text: 'Radial', + icon: 'radialIcon', + class: 'vis_link', + data: { vistype: 'visradial' }, }, - "edit": { - "text": "This $contentType is in the $editorialState state and has $openQueryCount open queries.
    You can review it, make changes, and add queries for the author.", - "previousEditorialState": "draft", - "nextEditorialState": "editreview", - "actions": ["Edit $contentType","Dashboard"] + { + text: 'Path', + icon: 'pathIcon', + class: 'vis_link', + data: { vistype: 'vispath' }, }, - "editreview": { - "text": "This $contentType is in the $editorialState state and has $openQueryCount open queries.
    Once an author moves it to the $nextEditorialState state, you can do your final review on it.", - "previousEditorialState": "edit", - "nextEditorialState": "clean", - "actions": ["Dashboard"] + { + text: 'Media', + icon: 'mediaIcon', + class: 'vis_link', + data: { vistype: 'vismedia' }, }, - "clean": { - "text": "This $contentType is in the $editorialState state and has $openQueryCount open queries.
    Do your final review on the content and move it back to the $previousEditorialState state if it requires further changes, or to the $nextEditorialState state for publication.", - "previousEditorialState": "editreview", - "nextEditorialState": "ready", - "actions": ["Edit $contentType","Dashboard"] + { + text: 'Tag', + icon: 'tagIcon', + class: 'vis_link', + data: { vistype: 'vistag' }, }, - "ready": { - "text": "This $contentType is in the $editorialState state and has $openQueryCount open queries.
    Move it to the $nextEditorialState state to make it publicly available.", - "previousEditorialState": "clean", - "nextEditorialState": "published", - "actions": ["Dashboard"] + { + text: 'Word Cloud', + icon: 'wordCloudIcon', + class: 'vis_link', + data: { vistype: 'viswordcloud' }, }, - "published": null, - "pastVersion": { - "text": "Version $versionNum of this $contentType was in the $editorialState state.
    Go to the latest version to see its current state.", - "previousEditorialState": null, - "nextEditorialState": null, - "actions": ["Latest version"] - } + ], + }, + { + id: 'scalar_menu', + text: 'Scalar', + icon: 'scalarIcon', + submenu: [ + { + text: 'About Scalar', + url: 'https://scalar.usc.edu/', + target: '_scalar', + }, + { + text: 'User’s Guide', + url: 'https://scalar.usc.edu/works/guide2', + target: '_scalar', + }, + { + text: 'More Scalar Projects', + url: base.applyCurrentQueryVarsToURL(base.index_url), + target: '_scalar', + }, + ], + }, + ] + }, + search: { + menu: { + id: 'ScalarHeaderSearch', + label: 'Search', + }, + items: [ + { + text: 'Advanced search' } + ] + }, + import: { + menu: { + id: 'ScalarHeaderAnnotate', + class: 'hidden-xs', + label: 'Import', + description: 'Media import options', + icon: 'importIcon', + contentsId: 'ScalarHeaderMenuImportList' + }, + items: [ + { + text: 'Affiliated archives', + submenu: [ + { + text: 'Critical Commons', + url: base.applyCurrentQueryVarsToURL(scalarapi.model.urlPrefix + 'import/critical_commons'), + }, + { + text: 'Internet Archive', + url: base.applyCurrentQueryVarsToURL(scalarapi.model.urlPrefix + 'import/internet_archive'), + }, + { + text: 'Shoah Foundation VHA Online', + url: base.applyCurrentQueryVarsToURL(scalarapi.model.urlPrefix + 'import/shoah_foundation_vha_online'), + }, + { + text: 'Shoah Foundation VHA (partner site)', + url: base.applyCurrentQueryVarsToURL(scalarapi.model.urlPrefix + 'import/shoah_foundation_vha'), + }, + ], + }, + { + text: 'Other archives', + submenu: [ + { + text: 'Omeka sites', + url: base.applyCurrentQueryVarsToURL(scalarapi.model.urlPrefix + 'import/omeka'), + }, + { + text: 'Omeka S sites', + url: base.applyCurrentQueryVarsToURL(scalarapi.model.urlPrefix + 'import/omeka_s'), + }, + { + text: 'YouTube', + url: base.applyCurrentQueryVarsToURL(scalarapi.model.urlPrefix + 'import/youtube'), + }, + { + text: 'Harvard Art Museums', + url: base.applyCurrentQueryVarsToURL(scalarapi.model.urlPrefix + 'import/harvard_art_museums'), + include: $('link#harvard_art_museums_key').attr('href') + }, + ], + }, + { + text: 'Files and URLs', + submenu: [ + { + text: 'Upload media files', + url: base.applyCurrentQueryVarsToURL(scalarapi.model.urlPrefix + 'upload'), + }, + { + text: 'Link to media files', + url: base.applyCurrentQueryVarsToURL(scalarapi.model.urlPrefix + 'new.edit?type=media&'), + }, + ], + }, + ], + }, + account: { + menu: { + id: 'userMenu', + class: 'hidden-xs', + label: 'Account', + description: 'User account options', + icon: 'userIcon', + contentsId: 'ScalarHeaderMenuUserList' + }, + items: [ + ] + }, + } + + base.controlData = { + search: { + id: 'ScalarHeaderMenuSearch', + icon: 'searchIcon', + label: 'Search', + description: 'Open search field', + }, + help: { + id: 'ScalarHeaderHelp', + icon: 'helpIcon', + label: 'Help', + description: 'Display help information' + }, + addPage: { + id: 'ScalarHeaderNew', + icon: 'newIcon', + url: base.applyCurrentQueryVarsToURL(scalarapi.model.urlPrefix + 'new.edit'), + label: 'New page', + description: 'Create a new page', + }, + editContent: { + id: 'ScalarHeaderEdit', + icon: 'editIcon', + url: scalarapi.stripEdition(base.applyCurrentQueryVarsToURL(scalarapi.model.urlPrefix + base.current_slug + '.edit')), + label: 'New page', + description: 'Create a new page', + include: scalarapi.model.getUser().canEditThisUrl(window.location.href) + }, + annotateMedia: { + id: 'ScalarHeaderAnnotate', + icon: 'annotateIcon', + url: base.applyCurrentQueryVarsToURL(scalarapi.model.urlPrefix + scalarapi.basepath(window.location.href) + '.annotation_editor'), + label: 'Annotate media', + description: 'Annotate the current media', + include: scalarapi.model.getUser().canEditThisUrl(window.location.href) + }, + delete: { + id: 'ScalarHeaderDelete', + icon: 'deleteIcon', + label: 'Delete', + description: 'Make this content private', + include: scalarapi.model.getUser().canDeleteThisUrl(window.location.href) + }, + editorialPath: { + id: 'ScalarHeaderEditorialPath', + icon: 'editorialPathIcon', + url: base.applyCurrentQueryVarsToURL(scalarapi.model.urlPrefix + 'editorialpath'), + label: 'Editorial path', + description: 'Access a catalog of items for editorial review', + }, + dashboard: { + id: 'ScalarHeaderOptions', + icon: 'optionsIcon', + url: system_uri + '/dashboard?book_id=' + scalarapi.model.bookId + '&zone=style#tabs-style', + label: 'Dashboard', + description: 'Open the Dashboard', } - base.editorialState = base.editorialStates['none']; - if (base.editorialWorkflowEnabled) { - if($('header span.metadata[property="scalar:editorialState"]').length > 0){ - base.editorialState = base.editorialStates[$('header span.metadata[property="scalar:editorialState"]').text()]; - }else{ - base.editorialState = base.editorialStates["draft"]; + } + + base.visualizationData = { + visconnections: { + "visualization": { + "type": "force-directed", + "options": {} + }, + "components": [ + { + "content-selector": { + "type": "items-by-type", + "content-type": "all-content" + }, + "modifiers": [{ + "type": "filter", + "subtype": "relationship", + "content-types": [ + "all-types" + ], + "relationship": "any-relationship" + }] } - } - // Add a reverse reference to the DOM object - base.$el.data("scalarheader", base); - - base.init = function(){ - base.dataType = scalarapi.getFileExtension(window.location.href); - if(['edit','versions','history','meta','annotation_editor','manage_lenses'].indexOf(base.dataType)===-1){ - base.dataType = 'normal'; + ], + "sorts": [] + }, + vistoc: { + "visualization": { + "type": "tree", + "options": {} + }, + "components": [ + { + "content-selector": { + "type": "items-by-type", + "content-type": "table-of-contents" + }, + "modifiers": [{ + "type": "filter", + "subtype": "relationship", + "content-types": [ + "all-types" + ], + "relationship": "child" + }] + }, + { + "content-selector": { + "type": "items-by-type", + "content-type": "all-content" + }, + "modifiers": [] } - //Replace undefined options with defaults... - base.options = $.extend({},$.scalarheader.defaultOptions, options); - //Are we logged in? Check the RDF metadata. - base.logged_in = $('link#logged_in').length > 0 && $('link#logged_in').attr('href')!=''; - - base.currentNode = scalarapi.model.getCurrentPageNode(); - - base.userId = 'unknown'; - if(base.logged_in){ - //While we are logged in, check what our user level is, and set the appropriate bools - base.is_author = $('link#user_level').length > 0 && $('link#user_level').attr('href')=='scalar:Author'; - base.is_commentator = $('link#user_level').length > 0 && $('link#user_level').attr('href')=='scalar:Commentator'; - base.is_reviewer = $('link#user_level').length > 0 && $('link#user_level').attr('href')=='scalar:Reviewer'; - base.is_editor = $('link#user_level').length > 0 && $('link#user_level').attr('href')=='scalar:Editor'; - base.is_reader = $('link#user_level').length > 0 && $('link#user_level').attr('href')=='scalar:Reader'; - let temp = $('link#logged_in').attr('href').split('/'); - base.userId = parseInt(temp[temp.length - 1]); - - if(base.is_author || base.is_commentator || base.is_reviewer || base.is_editor){ - base.$el.addClass('edit_enabled'); + ], + "sorts": [] + }, + vis: { + "visualization": { + "type": "grid", + "options": {} + }, + "components": [ + { + "content-selector": { + "type": "items-by-type", + "content-type": "all-content" + }, + "modifiers": [ + { + "type": "filter", + "subtype": "relationship", + "content-types": [ + "all-types" + ], + "relationship": "any-relationship" } + ] } - base.isEditorialPathPage = $('.editorialpath-page>#editorialPath').length > 0; - base.okToAdd = (base.is_author || base.is_commentator); - base.okToDelete = (base.is_author || base.is_commentator) && (base.editorialState != base.editorialStates['edit']) && (base.editorialState != base.editorialStates['clean']) && (base.editorialState != base.editorialStates['published']); - base.okToCopyEdit = (((base.is_author || base.is_commentator) && (base.editorialState != base.editorialStates['edit']) && (base.editorialState != base.editorialStates['clean']) && (base.editorialState != base.editorialStates['ready'])) || (base.is_editor && ((base.editorialState != base.editorialStates['draft']) && (base.editorialState != base.editorialStates['editreview']) && (base.editorialState != base.editorialStates['ready'])))); - - //We should also grab the book ID from the RDF stuff - base.bookId = parseInt($('link#book_id').attr('href')); - - base.parent = $('link#parent').attr('href'); - - //We need some wrapper classes for Bootstrap, so we'll add those here. There are also some helper classes as well. - base.$el.addClass('text-uppercase heading_font navbar navbar-inverse navbar-fixed-top').attr('id','scalarheader'); - - if(base.usingHypothesis){ - base.$el.addClass('hypothesis_active'); - } - - //Store the home URL so that we can use these later without making extra queries on the DOM - var home_url = base.$el.find('#book-title').attr("href"); - - //Book URL and Home URL (the latter can simply be the Book URL, since it will redirect to /index) - var book_url = home_url = $('link#parent').attr('href'); - - var index_url = book_url.slice(0,-1); - index_url = index_url.substr(0, index_url.lastIndexOf('/'))+'/'; - - //We might not have the current page loaded, but we can still get the slug; strip the book URL and the GET params from the current URL - base.current_slug = window.location.href.split("?")[0].split("#")[0].replace(book_url,''); - - //Pop the title link DOM element off for a minute - we'll use this again later on. - var title_link = base.$el.find('#book-title').addClass('navbar-link').detach().attr('id','').addClass('book-title'); - //Handle the internal structure of the navbar now. - var navbar_html = '
    '+ - ''+ - ''+ - '
    '; - base.mobileTOCMenu = $('').appendTo('body'); - base.mobileTOCMenu.find('.close_menu, header>a').on('click', function(e){ - $('#mobileMainMenuSubmenus').removeClass('active'); - $('.mainMenuDropdown, #ScalarHeaderMenu').css({ - 'transform' : 'translateX(0px)', - '-webkit-transform' : 'translateX(0px)', - '-moz-transform' : 'translateX(0px)', - 'position': '' - }); - setTimeout(function(){ - $('#mobileMainMenuSubmenus').find('.expandedPage').remove(); - },500); - e.preventDefault(); - e.stopPropagation(); - return false; - }); - base.$el.on('hide.bs.collapse',function(){ - if($('#mobileMainMenuSubmenus').hasClass('active')){ - $('#mobileMainMenuSubmenus').removeClass('active'); - $('.mainMenuDropdown, #ScalarHeaderMenu').css({ - 'transform' : 'translateX(0px)', - '-webkit-transform' : 'translateX(0px)', - '-moz-transform' : 'translateX(0px)', - 'position': '' - }); - setTimeout(function(){ - $('#mobileMainMenuSubmenus').find('.expandedPage').remove(); - },500); - e.preventDefault(); - e.stopPropagation(); - return false; + ], + "sorts": [] + }, + visindex: { + "visualization": { + "type": "grid", + "options": {} + }, + "components": [ + { + "content-selector": { + "type": "items-by-type", + "content-type": "all-content" + }, + "modifiers": [ + { + "type": "filter", + "subtype": "relationship", + "content-types": [ + "all-types" + ], + "relationship": "any-relationship" } - }).on('mouseover', function(e){ - $(this).removeClass('short'); - $('body').removeClass('shortHeader').trigger('headerSizeChanged'); - }); - - //Convert our navbar html into a jquery element - var navbar = $(navbar_html); - - // Any custom menu items? - if ('undefined' != typeof(customScalarHeaderMenuLeftItems) && Array.isArray(customScalarHeaderMenuLeftItems)) { - for (var c = 0; c < customScalarHeaderMenuLeftItems.length; c++) { - customnavbaritem = $('
  • '+customScalarHeaderMenuLeftItems[c]+'
  • '); - navbar.find('#ScalarHeaderMenuLeft').append(customnavbaritem); - } - } - - // remove import options with missing keys - if (!$('link#harvard_art_museums_key').attr('href')) { - navbar.find('#import-harvard').remove(); - } - - // Any Airtables? - var $airtables = $('link#airtable'); - if ($airtables.length) { - for (var j = 0; j < $airtables.length; j++) { - navbar.find('#ScalarHeaderMenuImportList').find('ul.other-archives').append('
  • Airtable: '+$airtables.eq(j).attr('href')+'
  • '); - } + ] } - - //We don't always want all of the edit buttons for alternate data - //type requests (ex: meta or versions) - remove these as necessary - - var remove_edit_icons = []; - if(['edit','versions','history','annotation_editor','manage_lenses'].indexOf(base.dataType)!==-1){ - remove_edit_icons.push('#ScalarHeaderAnnotate'); + ], + "sorts": [] + }, + visradial: { + "visualization": { + "type": "radial", + "options": {} + }, + "components": [ + { + "content-selector": { + "type": "items-by-type", + "content-type": "all-content" + }, + "modifiers": [{ + "type": "filter", + "subtype": "relationship", + "content-types": [ + "all-types" + ], + "relationship": "any-relationship" + }] } - if(['edit','versions','history','annotation_editor','manage_lenses'].indexOf(base.dataType)!==-1){ - remove_edit_icons.push('#ScalarHeaderEdit'); + ], + "sorts": [] + }, + vismap: { + "visualization": { + "type": "map", + "options": {} + }, + "components": [ + { + "content-selector": { + "type": "items-by-type", + "content-type": "all-content" + }, + "modifiers": [] } - if(['versions','history','annotation_editor','manage_lenses'].indexOf(base.dataType)!==-1){ - remove_edit_icons.push('#ScalarHeaderDelete'); + ], + "sorts": [] + }, + viswordcloud: { + "visualization": { + "type": "word-cloud", + "options": {} + }, + "components": [ + { + "content-selector": { + "type": "items-by-type", + "content-type": "page" + }, + "modifiers": [] } - - //Join the IDs of the edit icons to be removed and strip them from the navbar - navbar.find(remove_edit_icons.join(', ')).remove(); - - base.$el.append(navbar).find('.title_wrapper').prepend(title_link.clone()); - - base.$el.find('.mainMenu').on('show.bs.dropdown',function(e){ - $(this).find('.body>ol>li').each(function(){ - var height = $(this).find('a').first().height()+'px'; - $(this).add($(this).find('.expand')).css({ - 'height' : height - }); - }); - if(!base.usingMobileView){ - var containerHeight = $('#mainMenuInside').height() + 50; - var max_height = $(window).height()-50; - if(containerHeight >= max_height){ - $('#mainMenuInside').css('max-height',max_height+'px').addClass('tall'); - } - } - }).children('.dropdown-menu').on('click', function(e){ - e.stopPropagation(); - }); - - base.$el.find('.mainMenu>a.dropdown-toggle').on('click', function(e){ - $(this).parent('.mainMenu').addClass('open').trigger('show.bs.dropdown'); - e.preventDefault(); - e.stopPropagation(); - return false; - }); - - base.$el.find('#ScalarHeaderMenuLeft .mainMenu').on('hide.bs.dropdown',function(){ - if(base.usingMobileView || $('#mainMenuSubmenus .expandedPage').length == 0){ - $('body').removeClass('in_menu'); //.css('margin-top','0px').scrollTop($('body').data('scrollTop')); - $(this).find('li.active').removeClass('active'); - $('#mainMenuInside').css('max-height','').removeClass('tall'); - return true; - }else{ - $(this).addClass('open'); - return false; - } - }); - base.$el.find('.mainMenuDropdown>#mainMenuInside>.close').on('click', function(e){ - $('#mainMenuSubmenus').hide().find('.expandedPage').remove(); - base.$el.find('#ScalarHeaderMenuLeft .mainMenu').removeClass('open').trigger('hide.bs.dropdown'); - e.preventDefault(); - e.stopPropagation(); - return false; - }); - base.$el.find('#ScalarHeaderMenuLeft>li.dropdown, #ScalarHeaderMenuRight>li.dropdown').on('mouseenter', function(e){ - var base = $('#scalarheader.navbar').data('scalarheader'); - if(!base.usingMobileView){ - if(!$(this).hasClass('mainMenu') && $('#mainMenuSubmenus .expandedPage').length > 0){ - $('#mainMenuSubmenus .expandedPage').remove(); - $('#mainMenusSubmenus').hide(); - base.$el.find('#ScalarHeaderMenuLeft .mainMenu').removeClass('open').trigger('hide.bs.dropdown'); - }else if($('#mainMenuSubmenus .expandedPage').length == 0){ - $('.mainMenuDropdown, #ScalarHeaderMenu').css({ - 'transform' : 'translateX(0px)', - '-webkit-transform' : 'translateX(0px)', - '-moz-transform' : 'translateX(0px)' - }).removeClass('expandedMenuOpen'); - } - $(this).addClass('open').trigger('show.bs.dropdown'); - } - }).on('mouseleave', function(e){ - // TODO: this is the area that is causing Win10 touch problems ~Craig - var base = $('#scalarheader.navbar').data('scalarheader'); - if(!base.usingMobileView){ - $(this).removeClass('open').trigger('hide.bs.dropdown'); - } - }).on('keydown', function(e){ - if(e.which == 27){ - var subdropdowns_open = $(this).find('li.dropdown.open'); - if(subdropdowns_open.length > 0){ - subdropdowns_open.removeClass('open').trigger('hide.bs.dropdown'); - subdropdowns_open.first().children('a').trigger('focus'); - }else{ - $(this).removeClass('open').trigger('hide.bs.dropdown'); - $(this).children('a').trigger('focus'); - } - e.stopPropagation(); - e.preventDefault(); - return false; - } - }).find("ul.dropdown-menu li.dropdown").on('mouseenter', function(e){ - var base = $('#scalarheader.navbar').data('scalarheader'); - if(!base.usingMobileView){ - - var timeout = $(this).data('hoverEvent'); - if($(this).data('hoverEvent')!=null){ - clearTimeout($(this).data('hoverEvent')); - $(this).data('hoverEvent',null); - } - - $(this).siblings('li.open').each(function(){ - var timeout = $(this).data('hoverEvent'); - if($(this).data('hoverEvent')!=null){ - clearTimeout($(this).data('hoverEvent')); - $(this).data('hoverEvent',null); - $(this).removeClass('open').trigger('hide.bs.dropdown'); - } - }); - - base.initSubmenus(this); - } - }).on('mouseleave', function(e){ - var base = $('#scalarheader.navbar').data('scalarheader'); - if(!base.usingMobileView){ - $(this).data('hoverEvent',setTimeout($.proxy(function(){ - $(this).removeClass('open').trigger('hide.bs.dropdown'); - },$(this)),200)); - }else{ - return true; - } - }).on('hide.bs.dropdown',function(e){ - e.stopPropagation(); - }).on('keydown', function(e){ - var base = $('#scalarheader.navbar').data('scalarheader'); - if($(this).children('a').first().is(':focus') && !base.usingMobileView){ - if(e.which == 38){ - //up - $(this).prev().children('a').trigger('focus'); - e.stopPropagation(); - return false; - }else if(e.which == 40){ - //down - $(this).next().children('a').trigger('focus'); - e.stopPropagation(); - return false; - } - } - }).children('a').on('click', function(e){ - var base = $('#scalarheader.navbar').data('scalarheader'); - if(!$(this).hasClass('expand') && (typeof $(this).attr('href') == 'undefined' || $(this).attr('href') == '')){ - base.initSubmenus(this); - e.preventDefault(); - return false; - } - }).on('keyup', function(e){ - var base = $('#scalarheader.navbar').data('scalarheader'); - if(!base.usingMobileView){ - if(e.which == 39 || e.which == 13 || e.which == 32){ - base.initSubmenus($(this).parent()); - e.stopPropagation(); - return false; - } - } - }) - - //Handle the book index... - var indexElement = $( '
    ' ).prependTo( 'body' ); - base.index = indexElement.scalarindex( {} ); - base.$el.find('.index_link a').on('click', function(e){ - $('#scalarheader.navbar').data('scalarheader').index.data('plugin_scalarindex').showIndex(); - }); - - //Handle the visualizations... - var visElement = $( '
    ' ).prependTo( 'body' ); - base.vis = visElement.scalarvis( { modal: true, local: false } ); - base.$el.find('.vis_link').on('click', function(e){ - - var options = { - modal: true - } - - switch ( $( this ).attr( 'data-vistype' ) ) { - - case "visconnections": - options.content = 'lens'; - options.lens = { - "visualization": { - "type": "force-directed", - "options": {} - }, - "components": [ - { - "content-selector": { - "type": "items-by-type", - "content-type": "all-content" - }, - "modifiers": [{ - "type": "filter", - "subtype": "relationship", - "content-types": [ - "all-types" - ], - "relationship": "any-relationship" - }] - } - ], - "sorts": [] - } - break; - - case "vistoc": - options.content = 'lens'; - options.lens = { - "visualization": { - "type": "tree", - "options": {} - }, - "components": [ - { - "content-selector": { - "type": "items-by-type", - "content-type": "table-of-contents" - }, - "modifiers": [{ - "type": "filter", - "subtype": "relationship", - "content-types": [ - "all-types" - ], - "relationship": "child" - }] - }, - { - "content-selector": { - "type": "items-by-type", - "content-type": "all-content" - }, - "modifiers": [] - } - ], - "sorts": [] - } - break; - - case "vis": - case "visindex": - options.content = 'lens'; - options.lens = { - "visualization": { - "type": "grid", - "options": {} - }, - "components": [ - { - "content-selector": { - "type": "items-by-type", - "content-type": "all-content" - }, - "modifiers": [ - { - "type": "filter", - "subtype": "relationship", - "content-types": [ - "all-types" - ], - "relationship": "any-relationship" - } - ] - } - ], - "sorts": [] - } - break; - - case "visradial": - options.content = 'lens'; - options.lens = { - "visualization": { - "type": "radial", - "options": {} - }, - "components": [ - { - "content-selector": { - "type": "items-by-type", - "content-type": "all-content" - }, - "modifiers": [{ - "type": "filter", - "subtype": "relationship", - "content-types": [ - "all-types" - ], - "relationship": "any-relationship" - }] - } - ], - "sorts": [] - } - break; - - case "vismap": - options.content = 'lens'; - options.lens = { - "visualization": { - "type": "map", - "options": {} - }, - "components": [ - { - "content-selector": { - "type": "items-by-type", - "content-type": "all-content" - }, - "modifiers": [] - } - ], - "sorts": [] - } - break; - - case "viswordcloud": - options.content = 'lens'; - options.lens = { - "visualization": { - "type": "word-cloud", - "options": {} - }, - "components": [ - { - "content-selector": { - "type": "items-by-type", - "content-type": "page" - }, - "modifiers": [] - } - ], - "sorts": [] - } - break; - - case "vispath": - options.content = 'lens'; - options.lens = { - "visualization": { - "type": "tree", - "options": {} - }, - "components": [ - { - "content-selector": { - "type": "items-by-type", - "content-type": "path" - }, - "modifiers": [ - { - "type": "filter", - "subtype": "relationship", - "content-types": [ - "path" - ], - "relationship": "child" - }, - { - "type": "filter", - "subtype": "relationship", - "content-types": [ - "path" - ], - "relationship": "child" - } - ] - } - ], - "sorts": [] - } - break; - - case "vismedia": - options.content = 'lens'; - options.lens = { - "visualization": { - "type": "force-directed", - "options": {} - }, - "components": [ - { - "content-selector": { - "type": "items-by-type", - "content-type": "media" - }, - "modifiers": [ - { - "type": "filter", - "subtype": "relationship", - "content-types": [ - "reference" - ], - "relationship": "any-relationship" - } - ] - } - ], - "sorts": [] - } - break; - - case "vistag": - options.content = 'lens'; - options.lens = { - "visualization": { - "type": "force-directed", - "options": {} - }, - "components": [ - { - "content-selector": { - "type": "items-by-type", - "content-type": "tag" - }, - "modifiers": [ - { - "type": "filter", - "subtype": "relationship", - "content-types": [ - "tag" - ], - "relationship": "child" - }, - { - "type": "filter", - "subtype": "relationship", - "content-types": [ - "path" - ], - "relationship": "child" - } - ] - } - ], - "sorts": [] - } - break; - - case "viscurrent": - options.content = 'lens'; - options.lens = { - "visualization": { - "type": "force-directed", - "options": {} - }, - "components": [ - { - "content-selector": { - "type": "specific-items", - "items": [] - }, - "modifiers": [ - { - "type": "filter", - "subtype": "relationship", - "content-types": ["all-types"], - "relationship": "any-relationship" - } - ] - } - ], - "sorts": [] - } - if (base.currentNode) { - options.lens.components[0]['content-selector'].items.push(base.currentNode.slug); - } - break; - } - $( '.modalVisualization' ).data( 'scalarvis' ).showModal( options ); - }); - - base.book_id = $('link#book_id').attr('href'); - - base.buildUserMenu(base.$el.find('#ScalarHeaderMenuUserList')); - - navbar.find('#header_authors').html(getAuthorCredit()); - - var helpElement = $('
    ').appendTo('body'); - base.help = $( helpElement ).scalarhelp( { root_url: modules_uri + '/cantaloupe' } ); - - $('body').on('click', function(e){ - var base = $('#scalarheader.navbar').data('scalarheader'); - if(!base.usingMobileView){ - $('#mainMenuSubmenus').hide().find('.expandedPage').remove(); - base.$el.find('#ScalarHeaderMenuLeft .mainMenu').removeClass('open').trigger('hide.bs.dropdown'); - } - }).on('pageLoadComplete',function(){ - $('#desktopTitleWrapper').trigger("update"); - }); - - $('body').on('lensUpdated', base.getLensData); - base.getLensData(); - - $( '#ScalarHeaderHelp>a' ).on('click', function(e) { - base.help.data( 'plugin_scalarhelp' ).toggleHelp(); - e.preventDefault(); - e.stopPropagation(); - return false; - }); - - $( '#ScalarHeaderVisualization>a' ).on('click', function(e) { - if (state != ViewState.Navigating) { - setState(ViewState.Navigating); - } else { - setState(ViewState.Reading); - } - e.preventDefault(); - e.stopPropagation(); - return false; - }); - - $('#ScalarHeaderMenuSearch a').on('click', function(e){ - if(base.isMobile || base.$el.find('.navbar-toggle').is(':visible')){ - $('#ScalarHeaderMenuSearch').toggleClass('search_open'); - $('#ScalarHeaderMenuSearchForm').toggleClass('open'); - }else{ - if($('#ScalarHeaderMenuSearch').hasClass('search_open')){ - $('#ScalarHeaderMenuSearchForm').animate({ - "width" : "0px" - },{ - "duration" : 250, - "step" : function(){ - base.handleResize(); - $('.navbar-header .title_wrapper, #ScalarHeaderMenuSearch').hide().show(0); - }, - "complete" : function(){ - $('#ScalarHeaderMenuSearch').removeClass('search_open'); - base.handleResize(); - }, - }); - }else{ - $('#ScalarHeaderMenuSearch').addClass('search_open'); - base.handleResize(190); - $('#ScalarHeaderMenuSearchForm').animate({ - "width" : "190px" - },{ - "duration" : 250, - "step" : function(){ - $('.navbar-header .title_wrapper, #ScalarHeaderMenuSearch').hide().show(0); - }, - "complete" : function(){ - base.handleResize(); - } - }); - $('#ScalarHeaderMenuSearchForm input').first().val('').trigger('focus').on('blur', function(e){ - if($('#ScalarHeaderMenuSearch').hasClass('search_open')){ - $('#ScalarHeaderMenuSearch a').trigger('click'); - } - $(this).off('blur'); - }); - - } - } - - e.preventDefault(); - e.stopPropagation(); - return false; - }); - - base.$el.find('.navbar-toggle').on('click', function(){ - $(this).parents('nav').toggleClass('in'); - }); - - var searchElement = $('
    ').appendTo('body'); - base.search = searchElement.scalarsearch( { root_url: modules_uri+'/cantaloupe'} ); - - $('#ScalarHeaderMenuSearchForm form').on('submit', function(e) { - if($('#ScalarHeaderMenuSearchForm form input').val() != ''){ - var base = $('#scalarheader.navbar').data('scalarheader'); - base.search.data('plugin_scalarsearch').doSearch($('#ScalarHeaderMenuSearchForm form input').first().val()); - if(base.isMobile || base.$el.find('.navbar-toggle').is(':visible')){ - $('#ScalarHeaderMenuSearchForm').removeClass('open'); - }else{ - $('#ScalarHeaderMenuSearchForm').css('width','0px'); - } - $('#ScalarHeaderMenuSearch').removeClass('search_open'); - }else{ - $('#ScalarHeaderMenuSearchForm form input').trigger('focus'); + ], + "sorts": [] + }, + vispath: { + "visualization": { + "type": "tree", + "options": {} + }, + "components": [ + { + "content-selector": { + "type": "items-by-type", + "content-type": "path" + }, + "modifiers": [ + { + "type": "filter", + "subtype": "relationship", + "content-types": [ + "path" + ], + "relationship": "child" + }, + { + "type": "filter", + "subtype": "relationship", + "content-types": [ + "path" + ], + "relationship": "child" } - - e.stopPropagation(); - e.preventDefault(); - return false; - }); - - //Check if the current page should be logged in the "recent" menu - if so, do that and then render the menu. Otherwise, just get renderin' - if(['import','edit'].indexOf($('head>link#view').attr('href')) > -1){ - base.load_recent(base.$el.find('#recent_menu>ul')); - }else{ - $.when(scalarrecent_log_page()).then(function(){ - var base = $('#scalarheader.navbar').data('scalarheader'); - base.load_recent(base.$el.find('#recent_menu>ul')); - }); + ] } - - base.$el.find('.dropdown-menu').on('mouseenter', function(){ - if(!base.usingMobileView){ - var containerHeight = $(this).height() + 50; - var max_height = $(window).height()-50; - if(containerHeight >= max_height){ - $(this).css('max-height',max_height+'px').addClass('tall'); - var offset = $('body').scrollTop(); - $('body').addClass('in_menu'); //.css('margin-top','-'+offset+'px').data('scrollTop',offset); - } - } - }).on('mouseleave', function(){ - if($(this).hasClass('tall')){ - $(this).css('max-height','').removeClass('tall'); - $('body').removeClass('in_menu'); //.css('margin-top','0px').scrollTop($('body').data('scrollTop')); - } - }); - - $(window).on('resize', function(){ - var base = $('#scalarheader.navbar').data('scalarheader'); - base.handleResize(); - }) - .on('scroll', function(e){ - var base = $('#scalarheader.navbar').data('scalarheader'); - if ('undefined' == typeof(base)) return; - if(base.usingMobileView){ - base.oldScrollTop = 0; - base.$el.removeClass('short'); - $('body').removeClass('shortHeader').trigger('headerSizeChanged'); - }else{ - var scrollTop = $(this).scrollTop(); - if(scrollTop >= 50 && scrollTop > base.oldScrollTop && $('#mainMenuSubmenus').find('.expandedPage').length == 0){ - base.$el.addClass('short'); - $('body').addClass('shortHeader').trigger('headerSizeChanged'); - }else{ - base.$el.removeClass('short'); - $('body').removeClass('shortHeader').trigger('headerSizeChanged'); - } - base.oldScrollTop = scrollTop; + ], + "sorts": [] + }, + vismedia: { + "visualization": { + "type": "force-directed", + "options": {} + }, + "components": [ + { + "content-selector": { + "type": "items-by-type", + "content-type": "media" + }, + "modifiers": [ + { + "type": "filter", + "subtype": "relationship", + "content-types": [ + "reference" + ], + "relationship": "any-relationship" } - }); - - - base.handleResize(); - base.handleBook(); // we used to bind this to the return of a loadBook call, but now we can call it immediately - - $('body').on('pageLoadComplete',$.proxy(function(){ - var base = this; - base.$el.find('.title_wrapper.visible-xs .book-title').dotdotdot({ - ellipsis: '…', - wrap: 'letter', - height: 50, - callback: function(isTruncated, fullText){ - var mobileTitle = base.$el.find('.title_wrapper.visible-xs'); - if (isTruncated && !mobileTitle.hasClass('withTooltip')) { - var titleHtml = $('#desktopTitleWrapper').text().split('by '); - titleHtml = ''+titleHtml[0]+' by '+(titleHtml.slice(1).join(' by ')); - - mobileTitle.tooltip({'title':titleHtml,'html':true,'container':'#scalarheader','placement':'bottom','template':''}) - .addClass('withTooltip') - .on('hide.bs.tooltip',function(){ - $(this).find('a').removeClass('tooltipVisible'); - }); - mobileTitle.find('a').on('click', function(e){ - if(!$(this).hasClass('tooltipVisible')){ - $(this).addClass('tooltipVisible'); - e.preventDefault(); - return false; - }else{ - return true; - } - }); - }else{ - mobileTitle.tooltip('destroy').removeClass('withTooltip').find('a').off('click'); - } - } - }); - - var fullText = base.$el.find('#desktopTitleWrapper').text(); - base.$el.find('#desktopTitleWrapper').dotdotdot({ - ellipsis: '…', - wrap: 'letter', - height: 50, - callback: function(isTruncated){ - //Check if author text is overflowed - if so, add a bootstrap tooltip. - var base = $('#scalarheader.navbar').data('scalarheader'); - var desktopTitle = base.$el.find('#desktopTitleWrapper'); - if (isTruncated && !desktopTitle.hasClass('withTooltip')) { - var titleHtml = fullText.split('by '); - titleHtml = ''+titleHtml[0]+' by '+(titleHtml.slice(1).join(' by ')); - - desktopTitle.tooltip({'title':titleHtml,'html':true,'container':'#scalarheader','placement':'bottom','template':''}).addClass('withTooltip'); - }else if(!isTruncated){ - desktopTitle.tooltip('destroy').removeClass('withTooltip'); - } - } - }).addClass('overflowCalculated'); - },base)); - - if(base.dataType == 'normal' && base.editorialWorkflowEnabled && scalarapi.getEdition(document.location.href) == -1){ - base.setupEditorialBar(); + ] } - - $('body').trigger('headerCreated'); - }; - base.setupEditorialBar = function() { - editorialBar = $('
    ').prependTo('article'); - if (typeof base.currentNode != 'undefined') { - var userType = "visitor"; - if (base.is_author) { - userType = "author"; - } else if (base.is_editor) { - userType = "editor"; - } - - scalarType = base.currentNode.getDominantScalarType('page'); - if (scalarType == null) { - scalarType = base.currentNode.getDominantScalarType('media'); - } - if (scalarType == null) { - contentType = 'content'; - } else { - contentType = scalarType.singular; - if (contentType == 'person') { - contentType = 'page'; - } + ], + "sorts": [] + }, + vistag: { + "visualization": { + "type": "force-directed", + "options": {} + }, + "components": [ + { + "content-selector": { + "type": "items-by-type", + "content-type": "tag" + }, + "modifiers": [ + { + "type": "filter", + "subtype": "relationship", + "content-types": [ + "tag" + ], + "relationship": "child" + }, + { + "type": "filter", + "subtype": "relationship", + "content-types": [ + "path" + ], + "relationship": "child" } - - var version = scalarapi.getVersionExtension(window.location.href); - - if (base.editorialBarData[userType] != null) { - var editorialBarData; - if (version == '') { - editorialBarData = base.editorialBarData[userType][base.editorialState.id]; - } else { - editorialBarData = base.editorialBarData[userType]['pastVersion']; - } - if (editorialBarData != null) { - editorialBar.addClass(base.editorialState.id + '-state'); - - // get number of open queries - var queryCount = 0; - if (base.currentNode.current != null) { - if (base.currentNode.current.editorialQueries != null) { - var queryData = JSON.parse(base.currentNode.current.editorialQueries); - var i = 0; - var n = queryData.queries.length; - for (i=0; i 0) { - text = text.replace('$openQueryCount', queryCount); - if (queryCount == 1) { - text = text.replace('open queries', 'open query'); - } - } - if (editorialBarData.previousEditorialState != null) { - text = text.replace('$previousEditorialState', base.editorialStates[editorialBarData.previousEditorialState].name); - } - if (editorialBarData.nextEditorialState != null) { - text = text.replace('$nextEditorialState', base.editorialStates[editorialBarData.nextEditorialState].name); - } - editorialBar.append('
    ' + text + '
    '); - if (queryCount == 0) { - editorialBar.find('span.query-msg').remove(); - } - - // buttons - editorialControls = $('
    ').appendTo(editorialBar); - editorialControls.wrap('
    '); - var button, action; - for (var i in editorialBarData.actions) { - action = editorialBarData.actions[i]; - action = action.replace('$contentType', contentType); - button = $('' + action + '').appendTo(editorialControls); - if ((i == 0) && (action != "Dashboard")) { - button.addClass('btn-primary'); - } else { - button.addClass('btn-default hidden-sm hidden-xs'); - } - switch (action) { - case "Dashboard": - button.attr('href', system_uri + '/dashboard?book_id=' + base.bookId + '&zone=editorial#tabs-editorial'); - break; - case "Editorial Path": - button.attr('href', base.parent + 'editorialpath'); - break; - case "Edit " + contentType: - button.attr('href', base.get_param(scalarapi.model.urlPrefix + base.current_slug + '.edit')); - break; - case "Latest version": - button.attr('href', scalarapi.stripEditionAndVersion(window.location.href)); - break; - } - } - } + ] + } + ], + "sorts": [] + }, + viscurrent: { + "visualization": { + "type": "force-directed", + "options": {} + }, + "components": [ + { + "content-selector": { + "type": "specific-items", + "items": base.currentNode ? [base.currentNode.slug] : [] + }, + "modifiers": [ + { + "type": "filter", + "subtype": "relationship", + "content-types": ["all-types"], + "relationship": "any-relationship" } + ] } + ], + "sorts": [] } - base.buildSubItem = function($container){ - var slug = $container.data('slug'); + } + + // add classes and attributes + if (scalarapi.model.getUser().canEdit()) base.$el.addClass('edit_enabled'); + if (scalarapi.model.usingHypothesis) base.$el.addClass('hypothesis_active'); + base.$el.addClass('text-uppercase heading_font navbar navbar-inverse navbar-fixed-top').attr('id','scalarheader'); + + // pop the title link DOM element off for a minute - we'll use this again later on + base.title_link = base.$el.find('#book-title').addClass('navbar-link').detach().attr('id','').addClass('book-title'); + + let navbar = $('
    ') + navbar.append(base.mobileHeader()) + navbar.append(base.desktopHeader()) + base.setupMobileMainMenu() + base.addCustomMenuItems() + + base.$el.append(navbar).find('.title_wrapper').prepend(base.title_link.clone()); + + base.setupMainMenuEventHandling() + base.setupGlobalMenuEventHandling() + base.setupIndexModal() + base.setupVisualizationModal() + base.setupUserMenu() + base.setupHelpModal() + base.setupLensUpdateHandling() + base.setupSearchModal() + base.addSearchFunctionality() + base.updateRecentMenu() + + $(window).on('resize', () => { base.handleResize(); }).on('scroll', base.handleScroll); + + base.handleResize() + base.handleBook() + + $('body').on('pageLoadComplete', $.proxy(base.setupTitleTruncate, base)) + + if (base.dataType == 'normal' && base.editorialWorkflowEnabled && scalarapi.getEdition(document.location.href) == -1) { + base.setupEditorialBar(); + } + + $('body').trigger('headerCreated'); + } + + base.setupEditorialBar = function() { + editorialBar = $('
    ').prependTo('article'); + if (typeof base.currentNode != 'undefined') { + var userType = "visitor"; + if (base.is_author) { + userType = "author"; + } else if (base.is_editor) { + userType = "editor"; } - base.expandMenu = function(node,n){ - var expanded_menu = $('#mainMenuSubmenus'); - - if(base.usingMobileView){ - $('#ScalarHeaderMenu').addClass('expandedMenuOpen'); - expanded_menu = $('#mobileMainMenuSubmenus').addClass('active').find('.pages'); - }else{ - $('#mainMenuSubmenus').show(); - } - - var currentMenuWidth = $('.mainMenuDropdown').width(); - - - var offset = 0; - if(!base.usingMobileView){ - expanded_menu.find('.expandedPage').each(function(){ - if($(this).data('index') >= n){ - $(this).remove(); - }else{ - currentMenuWidth += (base.remToPx*38); - } - }); + + scalarType = base.currentNode.getDominantScalarType('page'); + if (scalarType == null) { + scalarType = base.currentNode.getDominantScalarType('media'); + } + if (scalarType == null) { + contentType = 'content'; + } else { + contentType = scalarType.singular; + if (contentType == 'person') { + contentType = 'page'; + } + } + + var version = scalarapi.getVersionExtension(window.location.href); + + if (base.editorialBarData[userType] != null) { + var editorialBarData; + if (version == '') { + editorialBarData = base.editorialBarData[userType][base.editorialState.id]; + } else { + editorialBarData = base.editorialBarData[userType]['pastVersion']; + } + if (editorialBarData != null) { + editorialBar.addClass(base.editorialState.id + '-state'); + + // get number of open queries + var queryCount = 0; + if (base.currentNode.current != null) { + if (base.currentNode.current.editorialQueries != null) { + var queryData = JSON.parse(base.currentNode.current.editorialQueries); + var i = 0; + var n = queryData.queries.length; + for (i = 0; i < n; i++) { + if (!queryData.queries[i].resolved) { + queryCount++; + } + } + } } - - if(!base.usingMobileView && ($(window).width() - currentMenuWidth) < (base.remToPx*38)){ - offset = parseInt('-'+(currentMenuWidth - ($(window).width()-(base.remToPx*38)))); - }else if(base.usingMobileView){ - offset = ($(window).width()*-n); + + // text + var text = editorialBarData.text; + text = text.replace('$contentType', contentType); + text = text.replace('$versionNum', version); + text = text.replace('$editorialState', base.editorialState.name); + if (queryCount > 0) { + text = text.replace('$openQueryCount', queryCount); + if (queryCount == 1) { + text = text.replace('open queries', 'open query'); + } } - - var translateX = 'translateX('+offset+'px)'; - if(base.usingMobileView){ - $('#ScalarHeaderMenu').css({ - 'transform' : 'translateX(-'+$(window).width()+'px)', - '-webkit-transform' : 'translateX(-'+$(window).width()+'px)', - '-moz-transform' : 'translateX(-'+$(window).width()+'px)' - }); - $('#mobileMainMenuSubmenus .pages').css({ - 'transform' : translateX, - '-webkit-transform' : translateX, - '-moz-transform' : translateX - }); - }else{ - $('.mainMenuDropdown').css({ - 'transform' : translateX, - '-webkit-transform' : translateX, - '-moz-transform' : translateX - }); + if (editorialBarData.previousEditorialState != null) { + text = text.replace('$previousEditorialState', base.editorialStates[editorialBarData.previousEditorialState].name); } - - if(base.usingMobileView){ - offset = -n*$(window).width(); - }else{ - offset = -n*(base.remToPx*38); + if (editorialBarData.nextEditorialState != null) { + text = text.replace('$nextEditorialState', base.editorialStates[editorialBarData.nextEditorialState].name); } - - var description = node.current.description; - - var container = $('

    '+node.getDisplayTitle(true)+'

    '+description+'
    ').data({'index': n, 'slug': node.slug}).css('right',offset+'px').appendTo(expanded_menu); - - if(!base.usingMobileView){ - container.prepend('
    '); + editorialBar.append('
    ' + text + '
    '); + if (queryCount == 0) { + editorialBar.find('span.query-msg').remove(); } - if(typeof base.currentNode !== 'undefined' && container.data('slug') == base.currentNode.slug){ - container.addClass('is_current'); - }else if(typeof base.currentNode !== 'undefined' && base.parentNodes.indexOf(container.data('slug')) >= 0){ - container.addClass('is_parent'); + + // buttons + editorialControls = $('
    ').appendTo(editorialBar); + editorialControls.wrap('
    '); + var button, action; + for (var i in editorialBarData.actions) { + action = editorialBarData.actions[i]; + action = action.replace('$contentType', contentType); + button = $('' + action + '').appendTo(editorialControls); + if ((i == 0) && (action != "Dashboard")) { + button.addClass('btn-primary'); + } else { + button.addClass('btn-default hidden-sm hidden-xs'); + } + switch (action) { + case "Dashboard": + button.attr('href', system_uri + '/dashboard?book_id=' + base.bookId + '&zone=editorial#tabs-editorial'); + break; + case "Editorial Path": + button.attr('href', base.parent + 'editorialpath'); + break; + case "Edit " + contentType: + button.attr('href', base.get_param(scalarapi.model.urlPrefix + base.current_slug + '.edit')); + break; + case "Latest version": + button.attr('href', scalarapi.stripEditionAndVersion(window.location.href)); + break; + } } - container.on('click', function(e){ - e.stopPropagation(); - }).on('keydown', function(e){ - if(e.which == 27 || e.which == 9){ - e.stopPropagation(); - $(this).find('.close').trigger('click'); - e.preventDefault(); - return false; - } - }); - container.find('.close').add('#mobileMainMenuSubmenus footer button.back').off('click').on('click', function(e){ - var base = $('#scalarheader.navbar').data('scalarheader'); - var expanded_menu = $('#mainMenuSubmenus'); - if(base.usingMobileView){ - expanded_menu = $('#mobileMainMenuSubmenus .pages'); - } - var currentMenuWidth = base.remToPx*38; - - if(base.usingMobileView){ - max_n = $('#mobileMainMenuSubmenus .expandedPage').length - 2; - }else{ - max_n = parseInt($(this).parents('.expandedPage').data('index'))-1; - } - var removed_pages = []; - - expanded_menu.find('.expandedPage').each(function(){ - if(!base.usingMobileView){ - if($(this).data('index') > max_n){ - $(this).remove(); - } - } - }); - - if(expanded_menu.find('.expandedPage').length > 0){ - expanded_menu.find('.expandedPage').last().find('li.active').removeClass('active').find('.expand').trigger('focus'); - }else{ - $('.mainMenuDropdown li.active .expand').trigger('focus'); - } - - currentMenuWidth += (expanded_menu.find('.expandedPage').length * (base.remToPx*38)); - offset = 0; - if(!base.usingMobileView && ($(window).width() - currentMenuWidth) < 0){ - offset = ($(window).width() - currentMenuWidth); - }else if(base.usingMobileView){ - offset = $(window).width()*(-max_n); - } - - var translateX = 'translateX('+offset+'px)'; - if(base.usingMobileView){ - $('#ScalarHeaderMenu').css({ - 'transform' : 'translateX(-'+$(window).width()+'px)', - '-webkit-transform' : 'translateX(-'+$(window).width()+'px)', - '-moz-transform' : 'translateX(-'+$(window).width()+'px)' - }); - if(max_n < 0){ - translateX = 'translateX(0px)'; - } - $('#mobileMainMenuSubmenus .pages').css({ - 'transform' : translateX, - '-webkit-transform' : translateX, - '-moz-transform' : translateX - }); - }else{ - $('.mainMenuDropdown').css({ - 'transform' : translateX, - '-webkit-transform' : translateX, - '-moz-transform' : translateX - }); - } - - if(expanded_menu.find('.expandedPage').length == 0 || max_n < 0){ - if(base.usingMobileView){ - - $('#mobileMainMenuSubmenus').removeClass('active'); - $('.mainMenuDropdown, #ScalarHeaderMenu').css({ - 'transform' : 'translateX(0px)', - '-webkit-transform' : 'translateX(0px)', - '-moz-transform' : 'translateX(0px)', - 'position': '' - }); - setTimeout(function(){ - $('#mobileMainMenuSubmenus').find('.expandedPage').remove(); - },500); - }else{ - $('#mainMenuSubmenus').hide(); - $('.mainMenuDropdown li.active').removeClass('active'); - } - }else if(base.usingMobileView){ - setTimeout(function(){ - $('#mobileMainMenuSubmenus .expandedPage').last().remove(); - },500); - } - - if(!base.usingMobileView && expanded_menu.find('.tall').length == 0){ - $('body').removeClass('in_menu'); //.css('margin-top','0px').scrollTop($('body').data('scrollTop')); - } - - return false; - }); - if(description == null){ - container.find('.description').remove(); - } - container.find('.description,.title').dotdotdot({ - ellipsis: '…', - watch: "window" + } + } + } + } + + base.mobileHeader = function() { + let mobileHeader = $('') + // this is where the title will go + mobileHeader.append('') + mobileHeader.append(base.hamburgerMenu()) + mobileHeader.find('.navbar-toggle').on('click', function(){ + $(this).parents('nav').toggleClass('in'); + }); + return mobileHeader + } + + base.setupMobileMainMenu = function() { + base.mobileMainMenu = $('
    ' + + '
    ' + + '' + + '
    ' + + '' + + '
    ' + + '
    ' + + '
    ' + + '
    ').appendTo('body'); + base.mobileMainMenu.find('.close_menu, header > a').on('click', function(e){ + $('#mobileMainMenuSubmenus').removeClass('active'); + $('.mainMenuDropdown, #ScalarHeaderMenu').css({ + 'transform' : 'translateX(0px)', + '-webkit-transform' : 'translateX(0px)', + '-moz-transform' : 'translateX(0px)', + 'position': '' + }); + setTimeout(function(){ + $('#mobileMainMenuSubmenus').find('.expandedPage').remove(); + },500); + e.preventDefault(); + e.stopPropagation(); + return false; + }); + base.$el.on('hide.bs.collapse',function(){ + if($('#mobileMainMenuSubmenus').hasClass('active')){ + $('#mobileMainMenuSubmenus').removeClass('active'); + $('.mainMenuDropdown, #ScalarHeaderMenu').css({ + 'transform' : 'translateX(0px)', + '-webkit-transform' : 'translateX(0px)', + '-moz-transform' : 'translateX(0px)', + 'position': '' + }); + setTimeout(function(){ + $('#mobileMainMenuSubmenus').find('.expandedPage').remove(); + },500); + e.preventDefault(); + e.stopPropagation(); + return false; + } + }).on('mouseover', function(e){ + $(this).removeClass('short'); + $('body').removeClass('shortHeader').trigger('headerSizeChanged'); + }); + } + + base.setupMainMenuEventHandling = function() { + + // main menu opens + base.$el.find('.mainMenu').on('show.bs.dropdown',function(e){ + $(this).find('.body>ol>li').each(function(){ + var height = $(this).find('a').first().height()+'px'; + $(this).add($(this).find('.expand')).css({ + 'height' : height }); - - if(container.find('.description').triggerHandler("isTruncated")){ - container.find('.description_more_link').on('click', function(){ - if($(this).text() == 'more'){ - container.find('.description').trigger('destroy').css('max-height','none'); - container.find('.description_more_link').text('less'); - }else{ - container.find('.description').css('max-height','6.5rem') - .dotdotdot({ - ellipsis: '…', - watch: "window" - }); - container.find('.description_more_link').text('more'); - } - - }); - }else{ - container.find('.description_more_link_container').remove(); - } - - if(!base.usingMobileView){ - base.focusExpandedPage(container); - } - - var handleRequest = function(){ //this function is scoped instantaneously to this anonymous function, so we can pass it to loadPage while preserving the container reference - var relationships = $(this).find('.relationships'); - - var splitList = $('
      '); - - var node = scalarapi.getNode($(this).data('slug')); - var splitList = $('
        '); - - var path_of = node.getRelatedNodes('path', 'outgoing'); - var features = node.getRelatedNodes('reference', 'outgoing'); - var tag_of = node.getRelatedNodes('tag', 'incoming'); - var annotates = node.getRelatedNodes('annotation', 'outgoing'); - var comments_on = node.getRelatedNodes('comment', 'outgoing'); - - if(path_of.length > 0){ - var newList = $('
      • Contains
        1. ').appendTo(splitList).find('ol'); - for(var i in path_of){ - var relNode = path_of[i]; - var nodeItem = $('
        2. '+relNode.getDisplayTitle(true)+'
        3. ') - .data({ - 'slug': relNode.slug, - 'node': relNode - }) - .addClass(((base.parentNodes.indexOf(relNode.slug) < 0 && (typeof base.currentNode === 'undefined' || relNode.slug != base.currentNode.slug)) )?'':'is_parent') - .addClass((base.visitedPages.indexOf(relNode.url) < 0 && (typeof base.currentNode === 'undefined' || relNode.url != base.currentNode.url))?'':'visited'); - - $('').appendTo(nodeItem); - - newList.append(nodeItem); - } - } - - if(features.length > 0){ - var newList = $('
        4. Features
          1. ').appendTo(splitList).find('ol'); - for(var i in features){ - var relNode = features[i]; - var nodeItem = $('
          2. '+relNode.getDisplayTitle(true)+'
          3. ') - .data({ - 'slug': relNode.slug, - 'node': relNode - }) - .addClass(((base.parentNodes.indexOf(relNode.slug) < 0 && (typeof base.currentNode === 'undefined' || relNode.slug != base.currentNode.slug)))?'':'is_parent') - .addClass((base.visitedPages.indexOf(relNode.url) < 0 && (typeof base.currentNode === 'undefined' || relNode.url != base.currentNode.url))?'':'visited'); - - $('').appendTo(nodeItem); - - newList.append(nodeItem); - - } - } - - if(tag_of.length > 0){ - var newList = $('
          4. Tagged by
            1. ').appendTo(splitList).find('ol'); - for(var i in tag_of){ - var relNode = tag_of[i]; - var nodeItem = $('
            2. '+relNode.getDisplayTitle(true)+'
            3. ') - .data({ - 'slug': relNode.slug, - 'node': relNode - }) - .addClass(((base.parentNodes.indexOf(relNode.slug) < 0 && (typeof base.currentNode === 'undefined' || relNode.slug != base.currentNode.slug)))?'':'is_parent') - .addClass((base.visitedPages.indexOf(relNode.url) < 0 && (typeof base.currentNode === 'undefined' || relNode.url != base.currentNode.url))?'':'visited'); - - $('').appendTo(nodeItem); - - newList.append(nodeItem); - - } - } - - if(annotates.length > 0){ - var newList = $('
            4. Annotates
              1. ').appendTo(splitList).find('ol'); - for(var i in annotates){ - var relNode = annotates[i]; - var nodeItem = $('
              2. '+relNode.getDisplayTitle(true)+'
              3. ') - .data({ - 'slug': relNode.slug, - 'node': relNode - }) - .addClass(((base.parentNodes.indexOf(relNode.slug) < 0 && (typeof base.currentNode === 'undefined' || relNode.slug != base.currentNode.slug)))?'':'is_parent') - .addClass((base.visitedPages.indexOf(relNode.url) < 0 && (typeof base.currentNode === 'undefined' || relNode.url != base.currentNode.url))?'':'visited'); - - $('').appendTo(nodeItem); - - newList.append(nodeItem); - - } - } - - if(comments_on.length > 0){ - var newList = $('
              4. Comments on
                1. ').appendTo(splitList).find('ol'); - for(var i in comments_on){ - var relNode = comments_on[i]; - var nodeItem = $('
                2. '+relNode.getDisplayTitle(true)+'
                3. ') - .data({ - 'slug': relNode.slug, - 'node': relNode - }) - .addClass(((base.parentNodes.indexOf(relNode.slug) < 0 && (typeof base.currentNode === 'undefined' || relNode.slug != base.currentNode.slug)))?'':'is_parent') - .addClass((base.visitedPages.indexOf(relNode.url) < 0 && (typeof base.currentNode === 'undefined' || relNode.url != base.currentNode.url))?'':'visited'); - - $('').appendTo(nodeItem); - - newList.append(nodeItem); - } - } - if(splitList.children('li').length > 0){ - relationships.html(splitList); - relationships.find('.expand').on('click', function(e){ - var base = $('#scalarheader.navbar').data('scalarheader'); - base.expandMenu($(this).parent().data('node'),$(this).parents('.expandedPage').data('index')+1); - $(this).parents('.relationships').find('li.active').removeClass('active'); - $(this).parent().addClass('active'); - e.preventDefault(); - return false; - }); - if(!base.usingMobileView){ - var containerHeight = $(this).height() + 50; - var max_height = $(window).height()-50; - if(containerHeight >= max_height){ - $(this).css('max-height',max_height+'px').addClass('tall'); - - var offset = $('body').scrollTop(); - $('body').addClass('in_menu'); //.css('margin-top','-'+offset+'px').data('scrollTop',offset); - } - } - }else{ - relationships.remove(); - $(this).addClass('noRelations'); - splitList.remove(); - } - $(this).find('a').on('keyup', function(e){ - if(e.which == 13 || e.which == 32){ - $(this).trigger('click'); - } - }); - relationships.find('li>ol>li, li>ul>li').each(function(){ - $(this).add($(this).find('.expand')).height($(this).find('a').first().height()); - }); - } - scalarapi.loadPage( container.data('slug'), true, $.proxy(handleRequest,container), null, 1, false, null, 0, 20 ); - }; - base.focusExpandedPage = function(container){ - if(container != null && typeof container !== 'undefined'){ - container.find('a').attr('tabindex','-1').first().trigger('focus'); + }); + if(!base.usingMobileView){ + var containerHeight = $('#mainMenuInside').height() + 50; + var max_height = $(window).height()-50; + if(containerHeight >= max_height){ + $('#mainMenuInside').css('max-height',max_height+'px').addClass('tall'); } } - base.handleResize = function(extra_offset){ - - var base = $('#scalarheader.navbar').data('scalarheader'); - var screen_width = $(window).width(); - var menu_button_visible = base.$el.find('.navbar-toggle').is(':visible'); - var max_width = (base.$el.width() - ($('#ScalarHeaderMenuLeft').outerWidth() + $('#ScalarHeaderMenuRight').outerWidth()))-30; + }).children('.dropdown-menu').on('click', function(e){ + e.stopPropagation(); + }); + + // main menu closes + base.$el.find('#ScalarHeaderMenuLeft .mainMenu').on('hide.bs.dropdown',function(){ + if(base.usingMobileView || $('#mainMenuSubmenus .expandedPage').length == 0){ + $('body').removeClass('in_menu'); //.css('margin-top','0px').scrollTop($('body').data('scrollTop')); + $(this).find('li.active').removeClass('active'); + $('#mainMenuInside').css('max-height','').removeClass('tall'); + return true; + }else{ + $(this).addClass('open').find('[aria-expanded="false"]').attr('aria-expanded', 'true'); + return false; + } + }); + + // submenu opens + base.$el.find('.mainMenu>a.dropdown-toggle').on('click', function(e){ + $(this).attr('aria-expanded', 'true').parent('.mainMenu').addClass('open').trigger('show.bs.dropdown').find('[aria-expanded="false"]').attr('aria-expanded', 'true'); + e.preventDefault(); + e.stopPropagation(); + return false; + }); + + // submenu closes + base.$el.find('.mainMenuDropdown>#mainMenuInside>.close').on('click', function(e){ + $('#mainMenuSubmenus').hide().find('.expandedPage').remove(); + base.$el.find('#ScalarHeaderMenuLeft .mainMenu').removeClass('open').trigger('hide.bs.dropdown').find('[aria-expanded="true"]').attr('aria-expanded', 'false'); + e.preventDefault(); + e.stopPropagation(); + return false; + }); + } + + base.setupGlobalMenuEventHandling = function() { + // Top level menu item + base.$el.find('#ScalarHeaderMenuLeft>li.dropdown, #ScalarHeaderMenuRight>li.dropdown').on('mouseenter', function(e) { + var base = $('#scalarheader.navbar').data('scalarheader'); + if (!base.usingMobileView) { + if (!$(this).hasClass('mainMenu') && $('#mainMenuSubmenus .expandedPage').length > 0) { + $('#mainMenuSubmenus .expandedPage').remove(); + $('#mainMenusSubmenus').hide(); + base.$el.find('#ScalarHeaderMenuLeft .mainMenu').removeClass('open').trigger('hide.bs.dropdown').find('[aria-expanded="true"]').attr('aria-expanded', 'false'); + } else if ($('#mainMenuSubmenus .expandedPage').length == 0) { + $('.mainMenuDropdown, #ScalarHeaderMenu').css({ + 'transform': 'translateX(0px)', + '-webkit-transform': 'translateX(0px)', + '-moz-transform': 'translateX(0px)' + }).removeClass('expandedMenuOpen'); + } + $(this).addClass('open').trigger('show.bs.dropdown').find('[aria-expanded="false"]').attr('aria-expanded', 'true'); + } + }).on('mouseleave', function(e) { + // TODO: this is the area that is causing Win10 touch problems ~Craig + var base = $('#scalarheader.navbar').data('scalarheader'); + if (!base.usingMobileView) { + $(this).removeClass('open').trigger('hide.bs.dropdown').find('[aria-expanded="true"]').attr('aria-expanded', 'false'); + } + }).on('keydown', function(e) { + // press ESC + if (e.which == 27) { + var subdropdowns_open = $(this).find('li.dropdown.open'); + if (subdropdowns_open.length > 0) { + subdropdowns_open.removeClass('open').trigger('hide.bs.dropdown').find('[aria-expanded="true"]').attr('aria-expanded', 'false'); + subdropdowns_open.first().children('a').trigger('focus'); + } else { + $(this).removeClass('open').trigger('hide.bs.dropdown').find('[aria-expanded="true"]').attr('aria-expanded', 'false'); + $(this).children('a').trigger('focus'); + } + e.stopPropagation(); + e.preventDefault(); + return false; + } + }).find("ul.dropdown-menu li.dropdown").on('click', function(e) { + var base = $('#scalarheader.navbar').data('scalarheader'); + if (!base.usingMobileView) { + base.initSubmenus(this); + } + }).on('hide.bs.dropdown', function(e) { + e.stopPropagation(); + }).on('keydown', function(e) { + var base = $('#scalarheader.navbar').data('scalarheader'); + if ($(this).children('a').first().is(':focus') && !base.usingMobileView) { + if (e.which == 38) { + // up + $(this).prev().children('a').trigger('focus'); + e.stopPropagation(); + return false; + } else if (e.which == 40) { + // down + $(this).next().children('a').trigger('focus'); + e.stopPropagation(); + return false; + } + } + }).children('a').on('click', function(e) { + var base = $('#scalarheader.navbar').data('scalarheader'); + if (!$(this).hasClass('expand') && (typeof $(this).attr('href') == 'undefined' || $(this).attr('href') == '')) { + base.initSubmenus(this); + e.preventDefault(); + return false; + } + }).on('keyup', function(e) { + var base = $('#scalarheader.navbar').data('scalarheader'); + if (!base.usingMobileView) { + // right arrow, enter, space + if (e.which == 39 || e.which == 13 || e.which == 32) { + base.initSubmenus($(this).parent()); + e.stopPropagation(); + return false; + } + } + }) + $('body').on('click', function(e) { + var base = $('#scalarheader.navbar').data('scalarheader'); + if (!base.usingMobileView) { + $('#mainMenuSubmenus').hide().find('.expandedPage').remove(); + base.$el.find('#ScalarHeaderMenuLeft .mainMenu').removeClass('open').trigger('hide.bs.dropdown').find('[aria-expanded="true"]').attr('aria-expanded', 'false'); + } + }) + } + + base.setupIndexModal = function() { + var indexElement = $('
                  ').prependTo('body'); + base.index = indexElement.scalarindex( {} ); + base.$el.find('.index_link a').on('click', function(e){ + $('#scalarheader.navbar').data('scalarheader').index.data('plugin_scalarindex').showIndex(); + }); + } + + base.setupVisualizationModal = function() { + var visElement = $('
                  ').prependTo('body'); + base.vis = visElement.scalarvis({ modal: true, local: false }); + base.$el.find('.vis_link').on('click', function(e){ + var options = { + modal: true, + content: 'lens', + lens: base.visualizationData[$(this).attr('data-vistype')] + } + $('.modalVisualization').data('scalarvis').showModal(options); + e.preventDefault(); + e.stopPropagation(); + }) + } + + base.setupHelpModal = function() { + var helpElement = $('
                  ').appendTo('body'); + base.help = $( helpElement ).scalarhelp({ root_url: modules_uri + '/cantaloupe' }); + $( '#ScalarHeaderHelp>a' ).on('click', function(e) { + base.help.data( 'plugin_scalarhelp' ).toggleHelp(); + e.preventDefault(); + e.stopPropagation(); + return false; + }); + } + + base.setupSearchModal = function() { + var searchElement = $('
                  ').appendTo('body'); + base.search = searchElement.scalarsearch( { root_url: modules_uri+'/cantaloupe'} ); + } + + base.setupLensUpdateHandling = function() { + $('body').on('lensUpdated', base.getLensData); + base.getLensData(); + } + + base.getLensData = function(){ + let baseURL = scalarapi.model.baseURL.replace('application', 'lenses'); + let mainURL = `${baseURL}?book_id=${scalarapi.model.bookId}`; + $.ajax({ + url:mainURL, + type: "GET", + dataType: 'json', + contentType: 'application/json', + async: true, + context: this, + success: base.handleLensData, + error: function error(response) { + console.log('There was an error attempting to communicate with the server.'); + console.log(response); + } + }); + } + + base.handleLensData = function(response){ + let data = response; + let privateLensArray = []; + let publicLensArray = []; + + data.forEach(lens => { + if (!lens.hidden) { + publicLensArray.push(lens); + } else if (lens.user_id == base.userId) { + privateLensArray.push(lens); + } + }); + let lensMenu = $('#lenses_menu>ul'); + lensMenu.empty(); + + let manageLinkTitle = "Browse Lenses"; + if (base.is_author || base.is_editor) { + manageLinkTitle = "Manage Lenses"; + } + + lensMenu.append(''); + + // private lenses + if (privateLensArray.length > 0) { + lensMenu.append('
                4. My Private Lenses

                5. '); + privateLensArray.forEach(privateLensItem => { + let vizType = privateLensItem.visualization.type; + let lensLink = $('link#parent').attr('href') + privateLensItem.slug; + let markup = $(` +
                6. + ${privateLensItem.title} + +
                7. ` + ).appendTo(lensMenu); + }); + } + + // public lenses + if (publicLensArray.length > 0) { + lensMenu.append('
                8. Public Lenses

                9. '); + publicLensArray.forEach(publicLensItem => { + let vizType = publicLensItem.visualization.type; + let lensLink = $('link#parent').attr('href') + publicLensItem.slug; + let markup = $(` +
                10. + ${publicLensItem.title} + +
                11. ` + ).appendTo(lensMenu); + }); + } - base.$el.find('#desktopTitleWrapper,.title_wrapper.visible-xs .book-title').trigger("update"); + }; - base.$el.find('.mainMenuDropdown .relationships').find('li>ol>li, li>ul>li').each(function(){ - $(this).add($(this).find('.expand')).height($(this).find('a').first().height()); + base.setupUserMenu = function(){ + const userList = base.$el.find('#ScalarHeaderMenuUserList') + var redirect_url = ''; + if (base.currentNode) { + redirect_url = encodeURIComponent(base.currentNode.url); + }else{ + redirect_url = encodeURIComponent(window.location.href); + } + const user = scalarapi.model.getUser() + if (user.logged_in){ + userList.append('
                12. Account
                13. '); + userList.append('
                14. Sign out
                15. '); + } else { + userList.append('
                16. Sign in
                17. '); + userList.append('
                18. Register
                19. '); + } + } + + base.hamburgerMenu = function() { + return $('') + } + + base.desktopHeader = function() { + let desktopHeader = $('') + desktopHeader.append(base.navigationMenus()) + desktopHeader.append(base.titleAndCredit()) + desktopHeader.append(base.utilityOptions()) + return desktopHeader + } + + base.navigationMenus = function() { + let navigationMenus = $('') + navigationMenus.append(base.skipLink()) + navigationMenus.append(base.homeLink()) + navigationMenus.append(base.headerMenu(base.menuData.main)) + navigationMenus.append(base.headerMenu(base.menuData.wayfinding)) + return navigationMenus + } + + base.titleAndCredit = function() { + const element = $('') + element.find('#header_authors').html(getAuthorCredit()); + $('body').on('pageLoadComplete',function(){ + $('#desktopTitleWrapper').trigger("update"); + }); + return element + } + + base.utilityOptions = function() { + let utilityOptions = $('') + utilityOptions.append(base.headerControl(base.controlData.search, base.menuData.search)) + utilityOptions.append(base.searchForm()) + utilityOptions.append(base.headerControl(base.controlData.help)) + let user = scalarapi.model.getUser() + if (user.canAdd()) utilityOptions.append(base.headerControl(base.controlData.addPage)) + if (user.canCopyEdit() && !scalarapi.model.isEditorialPathPage) { + utilityOptions.append(base.headerControl(base.controlData.editContent)) + } + if (user.canAdd() && base.currentNode?.hasScalarType('media')) { + utilityOptions.append(base.headerControl(base.controlData.annotateMedia)) + } + if (user.role == ScalarRole.Author) { + utilityOptions.append(base.headerMenu(base.menuData.import)) + } + if (user.role == ScalarRole.Author || user.role == ScalarRole.Editor) { + if (user.canDelete() && !scalarapi.model.isEditorialPathPage && base.currentNode != null) { + utilityOptions.append(base.headerControl(base.controlData.delete)) + } + if (scalarapi.model.editorialWorkflowEnabled && !scalarapi.model.isEditorialPathPage && scalarapi.getEdition(document.location.href) == -1) { + utilityOptions.append(base.headerControl(base.controlData.editorialPath)) + } + utilityOptions.append(base.headerControl(base.controlData.dashboard)) + } + utilityOptions.append(base.headerMenu(base.menuData.account)) + base.addAirtableImportItems() + + return utilityOptions + } + + base.skipLink = function() { + const skipLink = $('') + skipLink.on('click', () => { + $('article a:not(.metadata)').first().focus() + }) + return skipLink + } + + base.homeLink = function() { + // home link is visible only on mobile + const homeUrl = base.applyCurrentQueryVarsToURL(addTemplateToURL( base.title_link.attr("href"), 'cantaloupe')) + const homeLink = $('
                20. '+ + ''+ + 'Home Page'+ + ''+ + '
                21. ') + return homeLink + } + + base.headerMenu = function(menuData) { + const menu = base.menuStructure(menuData.menu) + for (let i=0; i'+ + ''+ + ''+ + '') + if (menuData.id) menuStructure.attr('id', menuData.id) + if (menuData.class) menuStructure.addClass(menuData.class) + const labelId = 'label-' + menuData.label.split(' ')[0].toLowerCase() + menuStructure.find('span').attr('id', labelId).append(menuData.label) + menuStructure.find('a').attr('id', menuData.icon).attr('aria-labelledby', labelId).attr('title', menuData.description) + if (menuData.contentsId) menuStructure.find('ul').attr('id', menuData.contentsId) + if (menuData.contentsClass) menuStructure.find('ul').addClass(menuData.contentsClass) + if (menuData.contents) menuStructure.find('ul').append($(menuData.contents)) + return menuStructure + } + + base.headerControl = function(controlData, menuData) { + if (controlData.include == undefined || controlData.include) { + const control = $('
                22. ') + control.attr('id', controlData.id) + const labelId = 'label-' + controlData.label.split(' ')[0].toLowerCase() + control.find('a').attr('id', controlData.icon).attr('aria-labelledby', labelId).attr('title', controlData.description) + control.find('span').attr('id', labelId).append(controlData.label) + if (controlData.url) control.find('a').attr('href', controlData.url).attr('aria-role', 'link') + if (menuData) { + control.addClass('dropdown') + control.find('a').addClass('dropdown-toggle').attr({'data-toggle': 'dropdown', 'aria-expanded': 'false', 'role': 'menuitem'}) + control.append('') + for (let i=0; i'+ + ''+ + '') + return searchForm + } + + base.addSearchFunctionality = function() { + $('#ScalarHeaderMenuSearch>a').on('click', function(e) { + if (base.isMobile || base.$el.find('.navbar-toggle').is(':visible')) { + $('#ScalarHeaderMenuSearch').toggleClass('search_open'); + $('#ScalarHeaderMenuSearchForm').toggleClass('open'); + } else { + if ($('#ScalarHeaderMenuSearch').hasClass('search_open')) { + $('#ScalarHeaderMenuSearchForm').animate({ + "width" : "0px" + }, { + "duration" : 250, + "step" : function(){ + base.handleResize(); + $('.navbar-header .title_wrapper, #ScalarHeaderMenuSearch').hide().show(0); + }, + "complete" : function(){ + $('#ScalarHeaderMenuSearch').removeClass('search_open'); + base.handleResize(); + }, }); - - if(base.isMobile || menu_button_visible){ - - max_width -= base.$el.find('.navbar-toggle').outerWidth()+15; - if(!base.usingMobileView){ - base.$el.removeClass('short'); - $('body').removeClass('shortHeader').trigger('headerSizeChanged'); - $('#mainMenuSubmenus').hide().find('.expandedPage').remove(); - base.$el.find('#ScalarHeaderMenuLeft .mainMenu').removeClass('open').trigger('hide.bs.dropdown'); - //reset search form if switching to mobile view - $('#ScalarHeaderMenuSearchForm').stop().css('width','auto').removeClass('open'); - $('#ScalarHeaderMenuSearch').removeClass('search_open'); - $('#mainMenuSubmenus').hide(); - var translateX = 'translateX(0px)'; - $('.mainMenuDropdown').css({ - 'transform' : translateX, - '-webkit-transform' : translateX, - '-moz-transform' : translateX - }); - } - base.usingMobileView = true; - $(this).find('ul.dropdown-menu').css('max-width','auto'); - }else{ - if(base.usingMobileView){ - $('#ScalarHeaderMenuSearch').removeClass('search_open'); - $('#ScalarHeaderMenuSearchForm').css({"width" : "0px"}).removeClass('open'); - $('#mainMenuSubmenus').hide(); - $('.tocMenu').find('.expandedPage').remove(); - base.$el.find('#ScalarHeaderMenuLeft .mainMenu').removeClass('open').trigger('hide.bs.dropdown'); - //reset search form if switching from mobile view - $('#mobileMainMenuSubmenus').removeClass('active'); - $('.mainMenuDropdown, #ScalarHeaderMenu').css({ - 'transform' : 'translateX(0px)', - '-webkit-transform' : 'translateX(0px)', - '-moz-transform' : 'translateX(0px)', - 'position': '' - }); - setTimeout(function(){ - $('#mobileMainMenuSubmenus').find('.expandedPage').remove(); - },500); - }else{ - var max_height = $(window).height()-50; - $('.expandedPage').css('max-height',max_height+'px'); - } - var translateX = 'translateX(0px)'; - $('#ScalarHeaderMenu').css({ - 'transform' : translateX, - '-webkit-transform' : translateX, - '-moz-transform' : translateX - }); - $('#mobileMainMenuSubmenus').removeClass('active'); - $('.mainMenuDropdown, #ScalarHeaderMenu').css({ - 'transform' : 'translateX(0px)', - '-webkit-transform' : 'translateX(0px)', - '-moz-transform' : 'translateX(0px)', - 'position': '' - }); - setTimeout(function(){ - $('#mobileMainMenuSubmenus').find('.expandedPage').remove(); - },500); - base.usingMobileView = false; - //While we're here, handle sub-dropdowns - base.$el.find('ul.dropdown-menu>li.dropdown.open').each(function(){ - if($(this).hasClass('right')){ - var max_width = $(window).width() - ($(this).offset().left + $(this).outerWidth()); - }else{ - var max_width = $(this).offset().left; - } - $(this).find('ul.dropdown-menu').css('max-width',max_width+'px'); - }); - } - var title_width = $(window).width(); - - if(base.usingMobileView){ - title_width -= 120; - }else{ - title_width -= ($('#ScalarHeaderMenu>ul>li:not(.visible-xs)>a.headerIcon').length * 50) + 52; // 30 for the margin on the title, 2px for the border on the user menu items, then 20 for scrollbar - - $('#ScalarHeaderMenu>ul>li.customMenuItem').each(function() { - title_width -= $(this).outerWidth(); - }); - - if($('#ScalarHeaderMenuSearch').hasClass('search_open')){ - title_width -= 190; - }else if(typeof extra_offset != 'undefined' && extra_offset!=null){ - title_width -= extra_offset; - } - - if(base.usingHypothesis){ - title_width -= 60; - } - } - - $('#scalarheader .title_wrapper').css('max-width',title_width+'px'); - var desktopTitle = base.$el.find('#desktopTitleWrapper'); - if(desktopTitle.hasClass('overflowCalculated')){ - desktopTitle.trigger("update"); - } - base.$el.removeClass('mobile_view desktop_view').addClass(base.usingMobileView?'mobile_view':'desktop_view'); - }; - - base.buildUserMenu = function(userList){ - var redirect_url = ''; - if ( base.currentNode != null && typeof base.currentNode !== 'undefined') { - redirect_url = encodeURIComponent(base.currentNode.url); - }else{ - redirect_url = encodeURIComponent(window.location.href); - } - if (base.logged_in){ - userList.append('
                23. Account
                24. '); - userList.append('
                25. Sign out
                26. '); - } else { - userList.append('
                27. Sign in
                28. '); - userList.append('
                29. Register
                30. '); - } + } else { + $('#ScalarHeaderMenuSearch').addClass('search_open'); + base.handleResize(190); + $('#ScalarHeaderMenuSearchForm').animate({ + "width" : "190px" + }, { + "duration" : 250, + "step" : function(){ + $('.navbar-header .title_wrapper, #ScalarHeaderMenuSearch').hide().show(0); + }, + "complete" : function(){ + base.handleResize(); + } + }); + $('#ScalarHeaderMenuSearchForm input').first().val('').trigger('focus').on('blur', function(e) { + if ($('#ScalarHeaderMenuSearch').hasClass('search_open')) { + $('#ScalarHeaderMenuSearch a').trigger('click'); + } + $(this).off('blur'); + }); + } + } + e.preventDefault(); + e.stopPropagation(); + return false; + }); + $('#ScalarHeaderMenuSearchForm form').on('submit', function(e) { + if($('#ScalarHeaderMenuSearchForm form input').val() != ''){ + var base = $('#scalarheader.navbar').data('scalarheader'); + base.search.data('plugin_scalarsearch').doSearch($('#ScalarHeaderMenuSearchForm form input').first().val()); + if(base.isMobile || base.$el.find('.navbar-toggle').is(':visible')){ + $('#ScalarHeaderMenuSearchForm').removeClass('open'); + }else{ + $('#ScalarHeaderMenuSearchForm').css('width','0px'); + } + $('#ScalarHeaderMenuSearch').removeClass('search_open'); + }else{ + $('#ScalarHeaderMenuSearchForm form input').trigger('focus'); + } + e.stopPropagation(); + e.preventDefault(); + return false; + }); + $('#ScalarHeaderMenuSearch ul>li>a').on('click', function(e) { + base.search.data('plugin_scalarsearch').showSearch(); + e.stopPropagation(); + e.preventDefault(); + return false; + }) + } + + base.addAirtableImportItems = function() { + var $airtables = $('link#airtable'); + if ($airtables.length) { + for (var j = 0; j < $airtables.length; j++) { + navbar.find('#ScalarHeaderMenuImportList').find('ul.other-archives').append('
                31. Airtable: '+$airtables.eq(j).attr('href')+'
                32. '); } + } + } + + base.updateRecentMenu = function() { + // Check if the current page should be logged in the "recent" menu - if so, do that and then render the menu. Otherwise, just get renderin' + if (['import','edit'].indexOf($('head>link#view').attr('href')) > -1) { + base.loadRecentMenuEntries(base.$el.find('#recent_menu>ul')); + } else { + $.when(scalarrecent_log_page()).then(function(){ + var base = $('#scalarheader.navbar').data('scalarheader'); + base.loadRecentMenuEntries(base.$el.find('#recent_menu>ul')); + }); + } + } + + base.loadRecentMenuEntries = function(container) { + container.html($('
                  ').scalarrecent().find('.history_content').html()).find('li>a').each(function(){ + var base = $('#scalarheader.navbar').data('scalarheader'); + $(this).removeClass('page').attr('href',base.applyCurrentQueryVarsToURL($(this).parent().attr('title',$(this).text()).attr('id'))); + base.visitedPages.push($(this).parent().attr('id')); + $('.mainMenu>.dropdown-menu .body>ol>li>a').each(function() { + if (base.visitedPages.indexOf($(this).attr('href')) >= 0) { + $(this).parent('li').addClass('visited'); + } + }); + $('.expandedPage ol>li>a').each(function(){ + if (base.visitedPages.indexOf($(this).attr('href')) >= 0) { + $(this).parent('li').addClass('visited'); + } + }); + }); + }; - base.getLensData = function(){ - let bookId = $('link#book_id').attr('href'); - let baseURL = $('link#approot').attr('href').replace('application', 'lenses'); - let mainURL = `${baseURL}?book_id=${bookId}`; - $.ajax({ - url:mainURL, - type: "GET", - dataType: 'json', - contentType: 'application/json', - async: true, - context: this, - success: base.handleLensData, - error: function error(response) { - console.log('There was an error attempting to communicate with the server.'); - console.log(response); - } + base.menuItem = function(itemData) { + let listItem = $(``) + let link = $('') + if (itemData.icon) { + link.append(``) + } + link.append(itemData.text) + listItem.append(link) + if (itemData.submenu) { + link.find('span').eq(0).addClass('rightArrowIcon') + submenu = $('