1/* 2 * Copyright (c) 2010-2020 openjournaltheme.com 3 * Copyright (c) 2010-2020 openjournaltheme team 4 * Read this term of use of this theme here : https://openjournaltheme.com/term-of-conditions/ 5 * 6 * Modify, redistribute or make commercial copy of this part or whole of this code is prohibited without written permission from openjournaltheme.com 7 * created by openjournaltheme.com 8 * 20 Agt 2020 9 * @brief Handle JavaScript functionality unique to this theme. 10 */ 11 12//var isRtl = document.body.classList.contains("rtl") ? true : false; 13var body = document.getElementsByTagName("BODY")[0].getAttribute("dir"); 14var isRtl = body == "rtl" ? true : false; 15var isMobile = window.matchMedia("only screen and (max-width: 760px)").matches; 16let isTablet = window.matchMedia("only screen and (min-width: 768px)").matches; 17 18(function ($) { 19 if (!isMobile) { 20 fixSearch08(); 21 } 22 23 let link = 24 document.querySelector("link[rel*='icon']") || 25 document.createElement("link"); 26 let fav_ico = link.href.length ? link.href : ""; 27 link.type = "image/x-icon"; 28 link.rel = "shortcut icon"; 29 link.href = fav_ico; 30 31 document.getElementsByTagName("head")[0].appendChild(link); 32 33 $("#customblock-SidebarMenu").length > 0 34 ? removeInlineCss("#customblock-SidebarMenu") 35 : removeInlineCss("#customblock-sidebarmenu"); 36 37 removeInlineCss(".page_editorial_team"); 38 39 removeCommaAfterAuthorNameOnArticleDetail(); 40 41 //fix article layout 42 fixArticleDetailLayout(); 43 44 //fix the submenu on main menu not shown 45 let navigationPrimary = "ul#navigationPrimary li a"; 46 let ulDropDown0 = "ul#navigationPrimary ul"; 47 let ulDropDown = "ul.dropdown-menu "; 48 49 // fixMenuOverFlow(navigationPrimary); 50 // fixMenuOverFlow(ulDropDown0); 51 // fixMenuOverFlow(ulDropDown); 52 53 //end fix submenu not shown 54 55 //add user-menu on the menu-light 56 57 // responsive menu 58 createResponsiveMenu(); 59 60 //end creating mobile menu 61 62 //annoucement animation 63 let annoucement_title = $(".pkp_page_index .cmp_announcements h2"); 64 annoucement_title.addClass("announcements_title"); 65 annoucement_title.addClass("animate__animated"); 66 annoucement_title.addClass("animate__fadeInUp"); 67 annoucement_title.addClass("animate__delay-2s"); 68 69 // typeText(annoucement_title); 70 71 // setInterval(function () { 72 // typeText(annoucement_title); 73 // }, 10000); 74 75 // const menu = new MmenuLight( 76 // document.querySelector(".pkp_navigation_primary_wrapper"), 77 // "(max-width: 600px)" 78 // ); 79})(jQuery); 80 81$(document).ready(function () { 82 let IndexContainer = $(".page_index_journal"); 83 84 setupSlider2(); 85 setUpIndexedIconList(); 86 //change additional info position 87 let additional_info = $(".additional_content").html(); 88 let current_issue = $(".current_issue"); 89 90 //$('<div class="additional_info"></div>').insertBefore(current_issue); 91 92 if (IndexContainer.length) { 93 IndexContainer.prepend('<div class="additional_info"></div>'); 94 $(".additional_info").html(additional_info); 95 removeInlineCss(".additional_info"); 96 } 97 98 if ($(".item.references").length) { 99 $(".item.references").readmore({ 100 moreLink: 101 '<div class="readmore_btn" ><span class="btn btn-xs btn-info"><i class="fa fa-chevron-circle-down" aria-hidden="true"></i> Read More</span></div>', 102 lessLink: 103 '<div class="readmore_btn" ><span class="btn btn-xs btn-info"> Read Less <i class="fa fa-chevron-circle-up" aria-hidden="true" style="margin-left: 10px"></i> </span></div>', 104 speed: 500, 105 collapsedHeight: 388, 106 }); 107 } 108}); 109 110function removeInlineCss(el) { 111 $(el).find("*").removeAttr("style"); 112} 113 114function createResponsiveMenu() { 115 //creating mobile menu 116 let menuLight = "#menu-light"; 117 118 const menu = new MmenuLight( 119 document.querySelector(menuLight), 120 "(max-width: 990PX)" 121 ); 122 123 const drawer = menu.offcanvas({ 124 // options 125 }); 126 127 document.addEventListener("DOMContentLoaded", () => { 128 document 129 .querySelector("a[href='#menu-light']") 130 .addEventListener("click", (event) => { 131 event.preventDefault(); 132 drawer.open(); 133 }); 134 }); 135 136 //clear all li class 137 $(menuLight).find("li").removeClass(); 138 $(menuLight).find("ul").removeClass(); 139 140 //make dropdown 141 let menuL = $(menuLight); 142 let subMenu = menuL.find("li").find("ul"); 143 if (subMenu.length) { 144 subMenu.css("display", "none"); 145 $( 146 `<i class="fa fa-sort-down dropdown-menu-icon" aria-hidden="true"></i>` 147 ).insertBefore(subMenu); 148 } 149 150 let dropDownMenuIcon = $(".dropdown-menu-icon"); 151 dropDownMenuIcon.click(function () { 152 $(this).next("ul").fadeToggle(); 153 $(this).toggleClass("fa fa-sort-up fa fa-sort-down"); 154 }); 155 156 if (isMobile) { 157 $(".pkp_navigation_user_wrapper").hide(); 158 } 159} 160 161// function typeText(el) { 162// let text_dummy = $(el).text().replace("|", ""); 163// let text = $.trim(text_dummy); 164// $(el).html(""); 165 166// jQuery(function ($) { 167// $(el).typist({ 168// speed: 6, 169// cursor: false, 170// text: text, 171// }); 172// }); 173// } 174 175function fixMenuOverFlow(el) { 176 let menuNav = $(".pkp_navigation_primary_row"); 177 178 menuNav = menuNav.length ? menuNav : $(".pkp_navigation_primary"); 179 180 let page_content = ".pkp_structure_content"; 181 182 $(el).hover(function () {
183 let className = $(this).attr("class"); 184 185 if ( 186 $(this).get(0).hasAttribute("data-toggle") || 187 className == "dropdown-menu" 188 ) { 189 $(page_content).css("z-index", " -1"); 190 menuNav.css("border-bottom", "1px solid #f3f3f3"); 191 } 192 }); 193 194 $(el).mouseleave(function () { 195 let className = $(this).attr("class"); 196 197 if ( 198 $(this).get(0).hasAttribute("data-toggle") || 199 className == "dropdown-menu" 200 ) { 201 $(page_content).css("z-index", " 1"); 202 menuNav.css("border-bottom", "1px solid transparent"); 203 } 204 }); 205} 206 207function setupSlider2() { 208 /** setup slider */ 209 210 $('<div class="slider-wrapper"></div>').insertAfter(".pkp_structure_content"); 211 212 $(".slider-wrapper").prepend('<div class="row custom-slider"></div>'); 213 $(".custom-slider").prepend('<div class="slider_footer"></div>'); 214 215 let slider_footer = $(".slider_footer"); 216 var dummy_slider_footer = $("#customblock-SliderFooter").length 217 ? $("#customblock-SliderFooter") 218 : false; 219 220 dummy_slider_footer = 221 !dummy_slider_footer.length || !dummy_slider_footer 222 ? $("#customblock-SliderFooter") 223 : dummy_slider_footer; 224 dummy_slider_footer = 225 !dummy_slider_footer.length || !dummy_slider_footer 226 ? $("#customblock-SliderFooter-img") 227 : dummy_slider_footer; 228 dummy_slider_footer = 229 !dummy_slider_footer.length || !dummy_slider_footer 230 ? $("#customblock-SliderFooter") 231 : dummy_slider_footer; 232 dummy_slider_footer = 233 !dummy_slider_footer.length || !dummy_slider_footer 234 ? $("#customblock-SliderFooter") 235 : dummy_slider_footer; 236 dummy_slider_footer = 237 !dummy_slider_footer.length || !dummy_slider_footer 238 ? $("#customblock-SliderFooterImg") 239 : dummy_slider_footer; 240 dummy_slider_footer = 241 !dummy_slider_footer.length || !dummy_slider_footer 242 ? $("#customblock-sliderfooterimg") 243 : dummy_slider_footer; 244 dummy_slider_footer = 245 !dummy_slider_footer.length || !dummy_slider_footer 246 ? $("#customblock-sliderfooter") 247 : dummy_slider_footer; 248 dummy_slider_footer = 249 !dummy_slider_footer.length || !dummy_slider_footer 250 ? $("#customblock-sliderfooter-img") 251 : dummy_slider_footer; 252 253 if (!dummy_slider_footer || !dummy_slider_footer.length) { 254 console.log("SliderFooter block not found"); 255 $(".slider_footer").parent(".row").remove(); 256 return; 257 } 258 259 //console.log(module_icon_list.length); 260 261 dummy_slider_footer.find("img").each(function (index) { 262 var link = $(this).parent("a"); 263 var content = link.length ? link : this; 264 slider_footer.append(content); 265 }); 266 267 var isThereIconList = slider_footer.find("img"); 268 269 if (isThereIconList.length) slider_footer.removeClass("hidden"); 270 271 autoplayEnable = isThereIconList.length > 5 ? true : false; 272 273 slideNumber = isMobile ? 2 : 6; 274 slideNumber = isTablet ? 4 : slideNumber; 275 276 //console.log(slideNumber); 277 278 $(".slider_footer").slick({ 279 infinite: true, 280 slidesToShow: slideNumber, 281 slidesToScroll: slideNumber, 282 autoplay: autoplayEnable, 283 autoplaySpeed: 4000, 284 rtl: isRtl, 285 dots: true, 286 }); 287 dummy_slider_footer.remove(); 288} 289 290function setUpIndexedIconList() { 291 //set up the indexed logo list 292 /** 293 * block name can be indexed_by or indexed-by or indexed_logo 294 */ 295 296 //$('<div class="indexed_by"></div>').insertBefore('.current_issue'); 297 298 $(".page_index_journal").prepend('<div class="indexed_by"></div>'); 299 300 let indexed_content = $(".indexed_by"); 301 var dummy_indexed_by = $("#customblock-indexed_by").length 302 ? $("#customblock-indexed_by") 303 : false; 304 305 dummy_indexed_by = 306 !dummy_indexed_by.length || !dummy_indexed_by 307 ? $("#customblock-indexed-by") 308 : dummy_indexed_by; 309 dummy_indexed_by = 310 !dummy_indexed_by.length || !dummy_indexed_by 311 ? $("#customblock-indexed_logo") 312 : dummy_indexed_by; 313 dummy_indexed_by = 314 !dummy_indexed_by.length || !dummy_indexed_by 315 ? $("#customblock-indexedBy") 316 : dummy_indexed_by; 317 dummy_indexed_by = 318 !dummy_indexed_by.length || !dummy_indexed_by 319 ? $("#customblock-IndexedBy") 320 : dummy_indexed_by; 321 dummy_indexed_by = 322 !dummy_indexed_by.length || !dummy_indexed_by 323 ? $("#customblock-indexedby") 324 : dummy_indexed_by; 325 dummy_indexed_by = 326 !dummy_indexed_by.length || !dummy_indexed_by 327 ? $("#customblock-IndexedLogo") 328 : dummy_indexed_by; 329 dummy_indexed_by = 330 !dummy_indexed_by.length || !dummy_indexed_by 331 ? $("#customblock-indexedlogo") 332 : dummy_indexed_by; 333 334 if (!dummy_indexed_by || !dummy_indexed_by.length) { 335 console.log("indexedBy block not found"); 336 return; 337 } 338 339 //console.log(module_icon_list.length); 340 341 dummy_indexed_by.find("img").each(function (index) { 342 var link = $(this).parent("a"); 343 var content = link.length ? link : this; 344 indexed_content.append(content); 345 }); 346 347 var isThereIconList = indexed_content.find("img"); 348 349 if (isThereIconList.length) indexed_content.removeClass("hidden"); 350 351 autoplayEnable = isThereIconList.length > 5 ? true : false;
352 353 slideNumber = isMobile ? 2 : 6; 354 slideNumber = isTablet ? 4 : slideNumber; 355 356 //console.log(slideNumber); 357 358 //let indexed_content = $('.indexed_by'); 359 indexed_content.slick({ 360 infinite: true, 361 slidesToShow: slideNumber, 362 slidesToScroll: slideNumber, 363 autoplay: autoplayEnable, 364 autoplaySpeed: 4000, 365 rtl: isRtl, 366 dots: true, 367 }); 368 369 dummy_indexed_by.remove(); 370} 371 372function fixArticleDetailLayout() { 373 if ($(".pkp_page_article").length == 0) return; 374 375 let doi = $(".item.doi"); 376 let insertTarget = $(".obj_article_details .subtitle").first(); 377 378 if (!insertTarget.length) { 379 insertTarget = $(".obj_article_details h1.page_title").first(); 380 } 381 382 if (doi.length && insertTarget.length) { 383 doi.clone().insertAfter(insertTarget); 384 doi.remove(); 385 } 386 387 let authors_list = $("ul.authors"); 388 authors_list.addClass("row"); 389 authors_list.children("li").addClass("col-6"); 390 391 pisahKeyword(); 392} 393 394//used on the article most read on the article detail page 395function removeCommaAfterAuthorNameOnArticleDetail(dom) { 396 //$('.flagstrap-icon').get(0).nextSibling.remove() 397 //$("#articlesBySameAuthorList ul li a").get(0).nextSibling.remove() 398 $("#articlesBySameAuthorList ul li a").each(function () { 399 $(this).get(0).nextSibling.remove(); 400 }); 401} 402 403function checkOrigin(isOriginTheme) { 404 let dom = `<div style='background-color:white !important;z-index:1000 !important;padding:20px !important;display:block;height:10px !important;position:fixed;bottom:0;right:0;border:1px solid #fcd7fd;'> 405 <span class='text-alert' style='position:relative;top:-11px;'><i class='fa fa-info' style='color:white;'></i>ð There are some obstructive modification on theme file, please contact<a href='https://openjournaltheme.com/' target='_blank'> our team</a></span> 406 </div>`; 407 408 if (!isOriginTheme) { 409 $("body").append(dom); 410 } 411} 412 413function pisahKeyword() { 414 //pisahkan keyword 415 416 let keyword_list = $(".item.keywords .value"); 417 418 if (!keyword_list.length) { 419 return; 420 } 421 422 let keyword = keyword_list.html(); 423 let list_of_keyword = keyword.split(","); 424 keyword_list.addClass("list_of_keyword"); 425 426 keyword_list.html(""); 427 428 // Display array values on page 429 for (let i = 0; i < list_of_keyword.length; i++) { 430 keyword_list.append("<div>" + $.trim(list_of_keyword[i]) + "</div>"); 431 } 432} 433 434function fixSearch08() { 435 $(".pkp_navigation_search_wrapper a").click(function (e) { 436 e.preventDefault(); 437 438 $(this).find("span.fa.fa-search").hide(); 439 $(this).contents().filter(function () { 440 return this.nodeType === 3; 441 }).wrap('<span class="hidden-text" style="display:none;"></span>'); 442 443 $(this).addClass("search_open"); 444 $(this).parent().css({ 445 position: "absolute", 446 top: 0, 447 right: 0, 448 "margin-top": "-7px", 449 }); 450 451 $(this).css({ 452 background: "transparent", 453 "border-bottom": "0px", 454 }); 455 456 let btnSearch = $(this); 457 458 let formSearch = ` 459 <form method="get" action="${$("#classy_base_url").text()}/search/index"> 460 <input class="classy_search" name="query" style="display:none;height:2em;width:14em;border:1px solid #ddd;margin-right:5px;"/> 461 <i class="fa fa-times cancel_search" style="position:absolute;top:21px;right:47px;"></i> 462 <i class="fa fa-search do_search" style="right:4px;top:24px;"></i> 463 <button type="submit" class="do_search" style="position:absolute;top:999px;"></button> 464 </form> 465 `; 466 467 if (!btnSearch.find(".classy_search").length) { 468 btnSearch.prepend(formSearch); 469 } 470 471 btnSearch.find(".classy_search").fadeIn(); 472 }); 473 474 $(document).on("click", ".cancel_search", function (e) { 475 $(".pkp_navigation_search_wrapper").css({ 476 "margin-top": "unset", 477 }); 478 $(".pkp_navigation_search_wrapper form").remove(); 479 480 $(".pkp_navigation_search_wrapper a").css({ 481 "border-bottom": "", 482 }); 483 484 $(".pkp_navigation_search_wrapper a span.fa.fa-search").show(); 485 $(".pkp_navigation_search_wrapper a .hidden-text").contents().unwrap(); 486 }); 487 488 $(document).on("click", ".do_search", function (e) { 489 if (!$(".classy_search").val()) return; 490 491 var xhr = new XMLHttpRequest(); 492 493 $.ajax({ 494 url: `${$("#classy_base_url").text()}/search/index`, 495 data: { 496 query: $(".classy_search").val(), 497 }, 498 xhr: function () { 499 return xhr; 500 }, 501 beforeSend: function () { 502 $(".classy_search").attr("disabled", true); 503 $(".classy_search").val("Searching..."); 504 }, 505 success: function (e) { 506 window.location.href = xhr.responseURL; 507 }, 508 }); 509 }); 510}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.