1/*! 2 * DokuWiki Bootstrap3 Template: Hacks! 3 * 4 * Home http://dokuwiki.org/template:bootstrap3 5 * Author Giuseppe Di Terlizzi <giuseppe.diterlizzi@gmail.com> 6 * License GPL 2 (http://www.gnu.org/licenses/gpl.html) 7 */ 8 9/* DOKUWIKI:include assets/bootstrap/js/bootstrap.min.js */ 10/* DOKUWIKI:include assets/anchorjs/anchor.min.js */ 11/* DOKUWIKI:include assets/typeahead/bootstrap3-typeahead.min.js */ 12/* DOKUWIKI:include assets/iconify/iconify.min.js */ 13/* DOKUWIKI:include assets/iconify/plugins/fa.js */ 14 15// Detect Icoonify support with Icon Plugin 16if (!Iconify.getConfig('defaultAPI').match('lib/plugins/icons')) { 17 Iconify.setConfig('defaultAPI', DOKU_TPL + 'iconify.php?prefix={prefix}&icons={icons}'); 18} 19 20if (typeof JSINFO.bootstrap3 === 'undefined') { 21 JSINFO.bootstrap3 = { 22 config: {} 23 }; 24} 25 26if (typeof JSINFO.plugin === 'undefined') { 27 JSINFO.plugin = {}; 28} 29 30function dw_mode(id) { 31 return ((JSINFO.bootstrap3.mode === id) ? true : false); 32} 33 34function dw_admin(page) { 35 return ((JSINFO.bootstrap3.admin === page) ? true : false); 36} 37 38function mediaSize(media) { 39 return jQuery(['#screen__mode .visible-', media, '-block'].join('')).is(':visible'); 40} 41 42var dw_template = { 43 44 init: function () { 45 46 dw_template.common(); 47 dw_template.mobileLayout(); 48 dw_template.toc(); 49 dw_template.tabs(); 50 dw_template.tocMenu(); 51 dw_template.nav(); 52 dw_template.backToTop(); 53 dw_template.anchorJS(); 54 dw_template.pageTools(); 55 dw_template.pageIcons(); 56 dw_template.dropdownPage(); 57 dw_template.footnotes(); 58 dw_template.mediaManager(); 59 dw_template.collapseSections(); 60 dw_template.pageRestoreConfirm(); 61 dw_template.alerts(); 62 dw_template.detail(); 63 64 dw_template.menuitem(); 65 dw_template.cookieLaw(); 66 dw_template.plugins(); 67 68 // Enable Typeahead 69 if (! JSINFO.bootstrap3.config.disableSearchSuggest) { 70 dw_template.typeahead(); 71 } 72 73 // Preload icons 74 Iconify.preloadImages(['mdi:folder-open', 'mdi:folder', 'mdi:file-document-outline', 'mdi:chevron-up', 'mdi:chevron-down']); 75 76 // Mobile Layout 77 jQuery(window).resize(function () { 78 dw_template.mobileLayout(); 79 dw_template.collapseSections(); 80 dw_template.tocResize(); 81 }); 82 83 // Re-initialize some components in media-manager 84 if (dw_mode('media') || jQuery('#media__manager').length) { 85 86 jQuery(document).ajaxSuccess(function () { 87 dw_template.common(); 88 dw_template.buttons(); 89 dw_template.tabs(); 90 dw_template.mediaManager(); 91 dw_template.alerts(); 92 }); 93 } 94 95 // Index Mode 96 if (dw_mode('index')) { 97 98 jQuery(document).ajaxSuccess(function () { 99 dw_template.modeIndex(); 100 }); 101 102 jQuery('#index__tree').click(function (e) { 103 dw_template.modeIndex(); 104 }); 105 106 } 107 108 // Hash change 109 if (JSINFO.bootstrap3.config.fixedTopNavbar) { 110 111 var scrollOnHashChange = function () { 112 scrollBy(0, - (parseInt(jQuery('body').css('marginTop')) || 0)); 113 }; 114 115 if (location.hash) { 116 setTimeout(function () { 117 scrollOnHashChange(); 118 }, 1); 119 } 120 121 jQuery(window).on('hashchange', function () { 122 scrollOnHashChange(); 123 }); 124 } 125 126 }, 127 128 // Normalization & Basic Styling 129 common: function () { 130 131 var $dw_content = jQuery('#dokuwiki__content, #media__manager'); // Page Content node 132 133 // Abbr tooltips 134 jQuery('abbr').tooltip(); 135 136 // Search Hit 137 jQuery('.search_hit').removeClass('search_hit').addClass('mark'); 138 139 // Fix accesskey issue on dropdown menu 140 if (jQuery('#dw__pagetools').length) { 141 jQuery('ul.dropdown-menu li a[accesskey]') 142 .closest('.top, .revs, .show, .edit') 143 .removeAttr('accesskey'); 144 } 145 146 // Form and controls 147 // TODO ported 148 $dw_content.find(':submit, :button, :reset').addClass('btn btn-default'); 149 jQuery('input, select, textarea') 150 .not('[type=submit], [type=reset], [type=button], [type=hidden], [type=image], [type=checkbox], [type=radio]') 151 .addClass('form-control'); 152 jQuery('input[type=checkbox]').addClass('checkbox-inline'); 153 jQuery('input[type=radio]').addClass('radio-inline'); 154 jQuery('label').addClass('control-label'); 155 jQuery('main form:not(.form-horizontal)').addClass('form-inline'); 156 157 // Toolbar 158 jQuery('#tool__bar').addClass('btn-group'); 159 160 // Add icons 161 jQuery('[data-dw-icon]').each(function () { 162 var $self = jQuery(this); 163 var $icon = jQuery('<span class="iconify mr-1">').attr('data-icon', $self.attr('data-dw-icon')); 164 165 if ($self.attr('data-dw-icon-target')) { 166 $self.find($self.attr('data-dw-icon-target')).prepend($icon); 167 } else { 168 $self.prepend($icon); 169 } 170 171 }); 172 173 // Picker 174 // if (dw_mode('edit')) { 175 // jQuery('.picker').addClass('btn-group'); 176 // } 177 178 // Footer links 179 jQuery('footer a').addClass('navbar-link'); 180 181 // Personal Home-Page icon 182 if (NS == 'user' && dw_mode('show') && !jQuery('.notFound').length) { 183 jQuery('.mode_show #dokuwiki__content h1').prepend('<span class="iconify mr-2" data-icon="mdi:account"/> '); 184 } 185 186 // Scrolling animation (on TOC and FootNotes) 187 jQuery('#dw__toc a, #dw__toc_menu a, a.fn_top, a.fn_bot').on('click', function (e) { 188 189 var $link = jQuery(this); 190 191 if ($link.attr('href').match(/^#/) && $link.attr('href').length > 1) { 192 193 e.preventDefault(); 194 195 if (mediaSize('xs') && $link.hasClass('fn_top')) { 196 return false; 197 } 198 199 if (JSINFO.bootstrap3.config.tocCollapseOnScroll && JSINFO.bootstrap3.config.tocAffix) { 200 dw_template.tocClose(); 201 } 202 203 var $target = jQuery('body ' + $link.attr('href')); 204 205 if ($target.length) { 206 207 var body_offset = (parseInt(jQuery('body').css('marginTop')) || 0), 208 target_position = Math.round($target.offset().top - body_offset); 209 210 jQuery('html, body').animate({ 211 scrollTop: target_position 212 }, 600); 213 214 document.location.hash = $link.attr('href'); 215 216 } 217 218 return false; 219 220 } 221 222 }); 223 224 }, 225 226 /** 227 * Customize jQuery UI with Bootstrap v3 classes 228 */ 229 jQueryUI: function () { 230 231 if (typeof jQuery.ui === 'undefined') return false; 232 233 // accordion 234 jQuery.ui.accordion.prototype.options.classes["ui-accordion"] = "panel panel-default"; 235 jQuery.ui.accordion.prototype.options.classes["ui-accordion-content"] = "panel-collapse collapse"; 236 jQuery.ui.accordion.prototype.options.classes["ui-accordion-content-active"] = "in"; 237 jQuery.ui.accordion.prototype.options.classes["ui-accordion-header"] = "panel-heading"; 238 239 // button 240 jQuery.ui.button.prototype.options.classes["ui-button"] = "btn btn-default"; 241 jQuery.ui.button.prototype.options.classes["ui-button-icon"] = "glyphicon"; 242 243 // dialog 244 jQuery.ui.dialog.prototype.options.classes["ui-dialog"] = "modal-content"; 245 jQuery.ui.dialog.prototype.options.classes["ui-dialog-titlebar"] = "modal-header"; 246 jQuery.ui.dialog.prototype.options.classes["ui-dialog-title"] = "modal-title"; 247 jQuery.ui.dialog.prototype.options.classes["ui-dialog-titlebar-close"] = "btn btn-default"; 248 jQuery.ui.dialog.prototype.options.classes["ui-dialog-content"] = "modal-body"; 249 jQuery.ui.dialog.prototype.options.classes["ui-dialog-buttonpane"] = "modal-footer"; 250 251 // menu 252 jQuery.ui.menu.prototype.options.classes["ui-menu"] = "list-group"; 253 jQuery.ui.menu.prototype.options.classes["ui-menu-icons"] = ""; 254 jQuery.ui.menu.prototype.options.classes["ui-menu-icon"] = "glyphicon glyphicon-chevron-right"; 255 jQuery.ui.menu.prototype.options.classes["ui-menu-item"] = "list-group-item"; 256 jQuery.ui.menu.prototype.options.classes["ui-menu-divider"] = ""; 257 jQuery.ui.menu.prototype.options.classes["ui-menu-item-wrapper"] = ""; 258 259 // progressbar 260 jQuery.ui.progressbar.prototype.options.classes["ui-progressbar"] = "progress"; 261 jQuery.ui.progressbar.prototype.options.classes["ui-progressbar-value"] = "progress-bar"; 262 263 // selectmenu 264 jQuery.ui.selectmenu.prototype.options.classes["ui-selectmenu-button"] = "btn btn-default dropdown-toggle"; 265 jQuery.ui.selectmenu.prototype.options.classes["ui-selectmenu-open"] = "open"; 266 jQuery.ui.selectmenu.prototype.options.icons.button = "caret"; 267 jQuery.ui.selectmenu.prototype.options.width = "auto"; 268 269 // tabs 270 jQuery.ui.tabs.prototype.options.classes["ui-tabs-nav"] = "nav nav-tabs"; 271 jQuery.ui.tabs.prototype.options.classes["ui-tabs-panel"] = "tab-pane"; 272 jQuery.ui.tabs.prototype.options.classes["ui-tabs-active"] = "active"; 273 274 // tooltip 275 jQuery.ui.tooltip.prototype.options.classes["ui-tooltip"] = "tooltip top fade in"; 276 jQuery.ui.tooltip.prototype.options.classes["ui-tooltip-content"] = "tooltip-inner"; 277 278 }, 279 280 nav: function () { 281 // Unwrap unnecessary tags inside list items for Bootstrap nav component 282 jQuery('.nav div.li').contents().unwrap(); 283 284 // Move the font-icons inside a link 285 jQuery('.nav li .dw-icons + a').each(function () { 286 var $link = jQuery(this), 287 $icon = $link.prev(); 288 $icon.prependTo($link); 289 $icon.after(' '); 290 }); 291 292 }, 293 294 tabs: function () { 295 jQuery('ul.tabs').addClass('nav nav-tabs'); 296 297 jQuery('.nav-tabs strong').replaceWith(function () { 298 299 jQuery(this).parent().addClass('active'); 300 return jQuery('<a href="#"/>').html(jQuery(this).contents()); 301 }); 302 }, 303 304 buttons: function () { 305 // TODO ported 306 jQuery('.button').removeClass('button'); // Not ported 307 jQuery('.alert button').removeClass('btn btn-default'); 308 jQuery('#dw__login, #dw__register, #subscribe__form, #media__manager').find(':submit').addClass('btn-success'); 309 jQuery('#dw__profiledelete').find(':submit').addClass('btn-danger'); 310 jQuery('#edbtn__save').addClass('btn-success'); 311 312 // Section Button edit 313 // TODO ported 314 jQuery('.btn_secedit .btn').addClass('btn-xs'); 315 }, 316 317 backToTop: function () { 318 jQuery('.back-to-top').click(function (e) { 319 e.preventDefault(); 320 jQuery('html, body').animate({ scrollTop: 0 }, 600); 321 }); 322 323 // Display back-to-top during scroll 324 jQuery(window).scroll(function () { 325 if (jQuery(this).scrollTop()) { 326 jQuery('.back-to-top').fadeIn(); 327 } else { 328 jQuery('.back-to-top').fadeOut(); 329 } 330 }); 331 }, 332 333 footnotes: function () { 334 335 var orig_insituPopup = dw_page.insituPopup; 336 337 dw_page.insituPopup = function (target, popup_id) { 338 var $fndiv = orig_insituPopup(target, popup_id); 339 $fndiv.addClass('panel panel-body panel-default'); 340 return $fndiv; 341 } 342 343 }, 344 345 alerts: function () { 346 // Info 347 jQuery('div.info') 348 .removeClass('info') 349 .addClass('alert alert-info') 350 .prepend('<span class="iconify mr-2" data-height="18" data-icon="mdi:information"/>'); 351 352 // Error 353 jQuery('div.error') 354 .removeClass('error') 355 .addClass('alert alert-danger') 356 .prepend('<span class="iconify mr-2" data-height="18" data-icon="mdi:alert-octagon"/>'); 357 358 // Success 359 jQuery('div.success') 360 .removeClass('success') 361 .addClass('alert alert-success') 362 .prepend('<span class="iconify mr-2" data-height="18" data-icon="mdi:check-circle"/>'); 363 364 // Notify 365 jQuery('div.notify') 366 .removeClass('notify') 367 .addClass('alert alert-warning') 368 .prepend('<span class="iconify mr-2" data-height="18" data-icon="mdi:alert"/>'); 369 }, 370 371 cookieLaw: function () { 372 jQuery('#cookieDismiss').on('click', function () { 373 jQuery('#cookieNotice').hide(); 374 DokuCookie.setValue('cookieNoticeAccepted', 1); 375 }); 376 377 }, 378 379 anchorJS: function () { 380 381 if (!JSINFO.bootstrap3.config.useAnchorJS) return false; 382 383 anchors.add('.mode_show article .dw-content h1, .mode_show article ' + 384 '.dw-content h2, .mode_show article .dw-content h3, ' + 385 '.mode_show article .dw-content h4, .mode_show article ' + 386 '.dw-content h5'); 387 388 }, 389 390 dropdownPage: function () { 391 jQuery('.dw__dropdown_page .dropdown').hover(function () { 392 if (!jQuery('#screen_mode').find('.visible-xs').is(':visible')) { 393 jQuery(this).addClass('open'); 394 } 395 }, 396 function () { 397 if (!jQuery('#screen_mode').find('.visible-xs').is(':visible')) { 398 jQuery(this).removeClass('open'); 399 } 400 }); 401 }, 402 403 pageIcons: function () { 404 405 var $dw_page_icons = jQuery('.dw-page-icons'); 406 407 if (!$dw_page_icons.length) return false; 408 409 var title = encodeURIComponent(document.title), 410 url = encodeURIComponent(location), 411 window_options = 'width=800,height=600,menubar=no,location=no,status=no'; 412 413 var share_to = { 414 'twitter': (function () { return ['https://twitter.com/intent/tweet?text=', title, '&url=', url].join(''); })(), 415 'linkedin': (function () { return ['https://www.linkedin.com/shareArticle?mini=true&url=', url, '&title=', title].join(''); })(), 416 'facebook': (function () { return ['https://www.facebook.com/sharer/sharer.php?u=', url, '&t=', title].join(''); })(), 417 'pinterest': (function () { return ['https://pinterest.com/pin/create/button/?url=', url, '&description=', title].join(''); })(), 418 'telegram': (function () { return ['https://telegram.me/share/url?url=', url].join(''); })(), 419 'whatsapp': (function () { return ['https://wa.me/?text=', title, ': ', url].join(''); })(), 420 'yammer': (function () { return ['https://www.yammer.com/messages/new?login=true&trk_event=yammer_share&status=', url, '#/Messages/bookmarklet'].join(''); })(), 421 'sendmail': (function () { return ['mailto:?subject=', document.title, '&body=', document.URL].join(''); })(), 422 'reddit': (function () { return ['https://www.reddit.com/submit?url=', url, '&title=', title].join(''); })(), 423 'msteams': (function () { return ['https://teams.microsoft.com/share?href=', url, '&referrer=', location.host].join(''); })(), 424 }; 425 426 $dw_page_icons.find('.share-twitter').on('click', function () { 427 window.open(share_to.twitter, 'Share to Twitter', window_options); 428 }); 429 430 $dw_page_icons.find('.share-linkedin').on('click', function () { 431 window.open(share_to.linkedin, 'Share to Linkedin', window_options); 432 }); 433 434 $dw_page_icons.find('.share-facebook').on('click', function () { 435 window.open(share_to.facebook, 'Share to Facebook', window_options); 436 }); 437 438 $dw_page_icons.find('.share-pinterest').on('click', function () { 439 window.open(share_to.pinterest, 'Share to Pinterest', window_options); 440 }); 441 442 $dw_page_icons.find('.share-telegram').on('click', function () { 443 window.open(share_to.telegram, 'Share to Telegram', window_options); 444 }); 445 446 $dw_page_icons.find('.share-yammer').on('click', function () { 447 window.open(share_to.yammer, 'Share to Yammer', window_options); 448 }); 449 450 $dw_page_icons.find('.share-reddit').on('click', function () { 451 window.open(share_to.reddit, 'Share to Reddit', window_options); 452 }); 453 454 $dw_page_icons.find('.sendmail').on('click', function (e) { 455 e.preventDefault(); 456 window.location = share_to['sendmail']; 457 }); 458 459 $dw_page_icons.find('.share-whatsapp').on('click', function () { 460 window.open(share_to.whatsapp, 'Share to WhatsApp', window_options); 461 }); 462 463 $dw_page_icons.find('.share-microsoft-teams').on('click', function () { 464 window.open(share_to.msteams, 'Share to Microsoft Teams', window_options); 465 }); 466 467 }, 468 469 pageTools: function () { 470 471 if (!jQuery('#dw__pagetools').length) return false; 472 473 // Page Tools Affix 474 jQuery('#dw__pagetools .tools').affix({ 475 offset: { 476 top: (jQuery('main').position().top), 477 bottom: (jQuery(document).height() 478 - jQuery('#dokuwiki__content').height() 479 - jQuery('#dokuwiki__pageheader').height() 480 - jQuery('#dokuwiki__header').height()) 481 } 482 }); 483 484 var $pagetools = jQuery('#dw__pagetools'); 485 486 $pagetools.find('svg').hover( 487 488 function () { 489 var $node = jQuery(this); 490 $node.closest('li.active').removeClass('active'); 491 $node.closest('li').addClass('active'); 492 }, 493 494 function () { 495 var $node = jQuery(this); 496 $node.closest('li.active').removeClass('active'); 497 } 498 ); 499 500 }, 501 502 collapseSections: function () { 503 504 if (!JSINFO.bootstrap3.config.collapsibleSections) return false; 505 506 var $sections = jQuery('article div.level2'), 507 $headings = $sections.prev(); 508 509 if (mediaSize('xs')) { 510 511 $sections.addClass('hide'); 512 513 if (!$headings.find('svg').length) { 514 515 $headings 516 .css('cursor', 'pointer') 517 .prepend(Iconify.getSVG('mdi:chevron-down')); 518 519 $headings.on('click', function () { 520 521 var $heading = jQuery(this), 522 $icon = $heading.find('svg'), 523 $section = $heading.nextUntil('h2'); 524 525 $section.toggleClass('hide'); 526 $heading.css('cursor', 'pointer'); 527 528 $section.hasClass('hide') 529 ? $icon.replaceWith(Iconify.getSVG('mdi:chevron-down')) 530 : $icon.replaceWith(Iconify.getSVG('mdi:chevron-up')); 531 532 }); 533 534 if (mediaSize('xs')) { 535 $headings.trigger('click'); 536 } 537 538 } 539 540 } else { 541 if ($sections.hasClass('hide')) { 542 $sections.removeClass('hide'); 543 } 544 } 545 546 }, 547 548 mobileLayout: function () { 549 550 var $dw_aside = jQuery('.dw__sidebar'); 551 if (!$dw_aside.length) return false; 552 553 if (mediaSize('xs')) { 554 555 if (JSINFO.bootstrap3.config.sidebarOnNavbar) { 556 557 if (!jQuery('header aside').length) { 558 jQuery('<aside/>').prependTo('header nav div .navbar-collapse'); 559 $dw_aside.find('.dw-sidebar-content').clone().appendTo('header aside'); 560 jQuery('header aside .dw-sidebar-title').addClass('navbar-text'); 561 } 562 jQuery('header aside').show(); 563 $dw_aside.hide(); 564 565 } else { 566 567 if (!$dw_aside.find('.dw-sidebar-content').hasClass('panel')) { 568 $dw_aside.find('.dw-sidebar-content').addClass('panel panel-default'); 569 $dw_aside.find('.dw-sidebar-title').addClass('panel-heading'); 570 $dw_aside.find('.dw-sidebar-body').addClass('panel-body').removeClass('in'); 571 } 572 573 } 574 575 } else { 576 577 jQuery('header aside').hide(); 578 $dw_aside.find('.dw-sidebar-content').removeClass('panel panel-default'); 579 $dw_aside.find('.dw-sidebar-title').removeClass('panel-heading'); 580 $dw_aside.find('.dw-sidebar-body').removeClass('panel-body').addClass('in'); 581 $dw_aside.show(); 582 } 583 584 }, 585 586 modeIndex: function () { 587 588 if (!dw_mode('index')) return false; 589 590 var $directories = jQuery('ul.idx a.idx_dir'), 591 $pages = jQuery('ul.idx a.wikilink1'); 592 593 jQuery.each($directories, function () { 594 595 var $directory = jQuery(this), 596 $closed = $directory.parents('.closed'), 597 $open = $directory.parents('.open'); 598 599 if (!$directory.find('svg').length) { 600 $directory.prepend(Iconify.getSVG('mdi:folder')); 601 } 602 603 if ($open.length) { 604 $directory.find('svg').replaceWith(Iconify.getSVG('mdi:folder-open')); 605 } 606 607 if ($closed.length) { 608 $directory.find('svg').replaceWith(Iconify.getSVG('mdi:folder')); 609 } 610 611 $directory.find('svg').addClass('iconify text-primary mr-2'); 612 613 }); 614 615 jQuery.each($pages, function () { 616 617 var $page = jQuery(this); 618 619 if (!$page.find('svg').length) { 620 $page.prepend(Iconify.getSVG('mdi:file-document-outline')); 621 } 622 $page.find('svg').addClass('text-muted mr-2'); 623 624 }); 625 626 }, 627 628 mediaManager: function () { 629 630 var $media_popup = jQuery('#media__content'), // Media Manager (pop-up) 631 $media_manager = jQuery('#mediamanager__page'); // Media Manager (page) 632 633 // Media Manager (pop-up) 634 if ($media_popup.length || $media_manager.length) { 635 636 jQuery('.qq-upload-button').addClass('btn btn-default'); 637 jQuery('.qq-upload-action').addClass('btn btn-success'); 638 639 var $btn_delete = jQuery('#mediamanager__btn_delete [type=submit]'); 640 var $btn_update = jQuery('#mediamanager__btn_update [type=submit]'); 641 642 if (!$btn_delete.find('span').length) { 643 $btn_delete.addClass('btn btn-danger'); 644 $btn_delete.prepend(jQuery('<span class="iconify mr-2" data-icon="mdi:delete"/>')); 645 $btn_update.prepend(jQuery('<span class="iconify mr-2" data-icon="mdi:image-plus"/>')); 646 } 647 648 jQuery('#page__revisions .sizechange').addClass('label label-primary'); 649 jQuery('#page__revisions .sizechange.positive').addClass('label-success'); 650 jQuery('#page__revisions .sizechange.negative').addClass('label-danger'); 651 652 } 653 654 // Media Manager (page) 655 if ($media_manager.length) { 656 657 var $sort_buttons = jQuery('.ui-buttonset'); 658 659 //$media_manager.find('.file dl').addClass('dl-horizontal'); 660 $media_manager.find('.file dd').addClass('pl-4'); 661 $media_manager.find('.panel').removeClass('panel').addClass('pull-left'); 662 663 $sort_buttons.addClass('btn-group'); 664 $sort_buttons.find('label').addClass('btn btn-xs btn-default'); 665 $sort_buttons.find('input').hide(); 666 667 function buttonHandler() { 668 669 var $button = jQuery(this), 670 option_for = $button.attr('for'), 671 option_set = option_for.replace('sortBy__', '').replace('listType__', ''); 672 673 $sort_buttons.find('.active').removeClass('active'); 674 $button.addClass('active'); 675 $sort_buttons.find('#' + option_for).prop('checked', true); 676 677 switch (option_set) { 678 case 'thumbs': 679 case 'rows': 680 dw_mediamanager.set_fileview_list(option_set); 681 $sort_buttons.find('[name=list_dwmedia]').val(option_set); 682 break; 683 case 'name': 684 case 'date': 685 dw_mediamanager.set_fileview_sort(option_set); 686 $sort_buttons.find('[name=sort_dwmedia]').val(option_set); 687 dw_mediamanager.list.call(jQuery('#dw__mediasearch')[0] || this, event); 688 break; 689 } 690 691 } 692 693 $sort_buttons.find('label').on('click', buttonHandler); 694 695 } 696 697 }, 698 699 detail: function () { 700 701 var $detail_page = jQuery('#dokuwiki__detail'); // Detail Page node 702 703 if (!$detail_page.length) return false; 704 705 $detail_page.find('img.img_detail') 706 .addClass('img-responsive'); 707 $detail_page.find('dl') 708 .addClass('dl-horizontal'); 709 710 }, 711 712 tocResize: function () { 713 714 var $dw_toc = jQuery('#dw__toc'); 715 if (!$dw_toc.length) return false; 716 717 if (JSINFO.bootstrap3.config.tocAffix) { 718 $dw_toc.affix('checkPosition'); 719 } 720 721 jQuery('#dw__toc .toc-body > ul').css({ 722 'max-height': (jQuery(window).height() - 50 - jQuery('#dokuwiki__content').position().top) + 'px', 723 'overflow-y': 'scroll' 724 }); 725 726 jQuery('.toc-body').width(jQuery('.dw-toc').width()); 727 728 }, 729 730 tocClose: function () { 731 732 var $dw_toc = jQuery('#dw__toc'); 733 if (!$dw_toc.length) return false; 734 735 if (!$dw_toc.hasClass('affix-bottom')) { 736 jQuery('.dw-content-page').addClass('dw-toc-closed'); 737 $dw_toc.find('.toc-body').collapse('hide'); 738 } 739 740 }, 741 742 tocOpen: function () { 743 744 var $dw_toc = jQuery('#dw__toc'); 745 if (!$dw_toc.length) return false; 746 747 jQuery('.dw-content-page').removeClass('dw-toc-closed'); 748 749 $dw_toc.find('.toc-body').collapse('show'); 750 751 }, 752 753 // Table of Contents (Navbar) 754 tocMenu: function () { 755 756 if (!jQuery("#dw__toc_menu").length) return false; 757 758 if (jQuery(JSINFO.bootstrap3.toc).length) { 759 jQuery("#dw__toc_menu").removeClass("hide"); 760 } 761 762 jQuery.each(JSINFO.bootstrap3.toc, function (idx, item) { 763 764 var indent = ""; 765 766 if (item.level > 1) { 767 for (var i = 0; i <= item.level; i++) { 768 indent += " " 769 } 770 } 771 772 jQuery("#dw__toc_menu ul").append(['<li><a class="small" href="', item.link, '">', indent, item.title, '</a></li>'].join('')); 773 774 }); 775 776 }, 777 778 toc: function () { 779 780 var $dw_toc = jQuery('#dw__toc'); 781 if (!$dw_toc.length) return false; 782 783 // Set TOC Affix 784 if (JSINFO.bootstrap3.config.tocAffix) { 785 $dw_toc.affix({ 786 offset: { 787 top: (jQuery("#dokuwiki__content").position().top), 788 bottom: (jQuery(document).height() - jQuery("#dokuwiki__content").height()), 789 } 790 }); 791 } 792 793 // ScrollSpy 794 var scrollspy_target = '#dw__toc'; 795 796 if (JSINFO.bootstrap3.config.tocLayout == 'navbar') { 797 scrollspy_target = '#dw__navbar_items'; 798 } 799 800 jQuery('body').scrollspy({ 801 target: scrollspy_target, 802 offset: ((parseInt(jQuery('body').css('marginTop')) || 0) + 10), 803 }); 804 805 dw_template.tocResize(); 806 807 if (mediaSize('xs')) { 808 dw_template.tocClose(); 809 } 810 811 $dw_toc.css('backgroundColor', jQuery('article > .panel').css('backgroundColor')); 812 $dw_toc.find('a').css('color', jQuery('body').css('color')); 813 814 if (JSINFO.bootstrap3.config.tocCollapseOnScroll && JSINFO.bootstrap3.config.tocAffix) { 815 816 $dw_toc.on('affix.bs.affix', function () { 817 dw_template.tocClose(); 818 }); 819 820 if (!JSINFO.bootstrap3.config.tocCollapsed) { 821 $dw_toc.on('affix-top.bs.affix', function () { 822 dw_template.tocOpen(); 823 }); 824 } 825 826 } 827 828 $dw_toc.find('.toc-title').on('click', function () { 829 830 jQuery('.dw-content-page').toggleClass('dw-toc-closed'); 831 832 if (jQuery('.dw-toc').hasClass('dw-toc-bootstrap')) { 833 if (jQuery('.dw-content-page').hasClass('dw-toc-closed')) { 834 jQuery('.dw-toc').removeClass('col-md-3'); 835 jQuery('.dw-content-page').removeClass('col-md-9').addClass('col-md-12'); 836 } else { 837 jQuery('.dw-toc').addClass('col-md-3'); 838 jQuery('.dw-content-page').removeClass('col-md-12').addClass('col-md-9'); 839 dw_template.tocResize(); 840 } 841 } 842 843 if (!jQuery('.dw-toc-closed').length) { 844 dw_template.tocResize(); 845 } 846 847 }); 848 849 if ((jQuery(window).height() < $dw_toc.height())) { 850 dw_template.tocResize(); 851 } 852 853 }, 854 855 // Add typeahead support for quick seach 856 typeahead: function () { 857 858 jQuery("#qsearch").typeahead({ 859 860 source: function (query, process) { 861 862 return jQuery.post(DOKU_BASE + 'lib/exe/ajax.php', 863 { 864 call: 'qsearch', 865 q: encodeURI(query) 866 }, 867 function (data) { 868 869 var results = []; 870 871 jQuery(data).find('a').each(function () { 872 873 var page = jQuery(this); 874 875 results.push({ 876 name: page.text(), 877 href: page.attr('href'), 878 title: page.attr('title'), 879 category: page.attr('title').replace(/:/g, ' » '), 880 }); 881 882 }); 883 884 return process(results); 885 886 }); 887 }, 888 889 itemLink: function (item) { 890 return item.href; 891 }, 892 893 itemTitle: function (item) { 894 return item.title; 895 }, 896 897 followLinkOnSelect: true, 898 autoSelect: false, 899 items: 50, 900 fitToElement: true, 901 delay: 500, 902 903 }); 904 }, 905 906 // Replace all OOTB DokuWiki toolbar icon with Material Design Icons 907 toolbarIcons: function () { 908 909 if (typeof window.toolbar === 'undefined') return false; 910 if (!JSINFO.bootstrap3.config.useAlternativeToolbarIcons) return false; 911 912 var icons = { 913 'bold.png': 'format-bold.svg', 914 'chars.png': 'omega.svg', 915 'h.png': 'format-header-pound.svg', 916 'h1.png': 'format-header-1.svg', 917 'hequal.png': 'format-header-equal.svg', 918 'hminus.png': 'format-header-decrease.svg', 919 'hplus.png': 'format-header-increase.svg', 920 'hr.png': 'minus.svg', // ?? 921 'image.png': 'image.svg', 922 'italic.png': 'format-italic.svg', 923 'link.png': 'link.svg', 924 'linkextern.png': 'link-variant.svg', // ?? 925 'mono.png': 'format-title.svg', 926 'ol.png': 'format-list-numbered.svg', 927 'sig.png': 'signature.svg', 928 'smiley.png': 'emoticon-outline.svg', 929 'strike.png': 'format-strikethrough.svg', 930 'ul.png': 'format-list-bulleted.svg', 931 'underline.png': 'format-underline.svg', 932 933 }; 934 935 for (var i in window.toolbar) { 936 937 // Replace all icons in "H(eaders)" picker 938 if (window.toolbar[i].icon == 'h.png') { 939 for (var x in window.toolbar[i].list) { 940 var hn = parseInt(x) + 1; 941 window.toolbar[i].list[x].icon = '../../tpl/bootstrap3/iconify.php?icon=mdi-format-header-' + hn + '.svg'; 942 } 943 } 944 945 for (var icon in icons) { 946 if (window.toolbar[i].icon == icon) { 947 window.toolbar[i].icon = '../../tpl/bootstrap3/iconify.php?icon=mdi-' + icons[icon]; 948 } 949 } 950 951 } 952 953 }, 954 955 // Display confirm dialog on page restore action 956 pageRestoreConfirm: function () { 957 jQuery('li.action a.revert').on('click', 958 function () { 959 return confirm(LANG.restore_confirm); 960 } 961 ); 962 }, 963 964 menuitem: function () { 965 jQuery('.menuitem.help').on('click', function () { 966 var $self = jQuery(this); 967 jQuery('.modal.help .modal-title').html($self.attr('title')); 968 jQuery('.modal.help .modal-body').load($self.data('link')); 969 }); 970 jQuery('.menuitem.printpage').on('click', function () { 971 window.print(); 972 }); 973 }, 974 975 976 plugins: function () { 977 /* DOKUWIKI:include js/plugins/csv.js */ 978 /* DOKUWIKI:include js/plugins/data.js */ 979 /* DOKUWIKI:include js/plugins/database2.js */ 980 /* DOKUWIKI:include js/plugins/datatables.js */ 981 /* DOKUWIKI:include js/plugins/davcal.js */ 982 /* DOKUWIKI:include js/plugins/discussion.js */ 983 /* DOKUWIKI:include js/plugins/explain.js */ 984 /* DOKUWIKI:include js/plugins/folded.js */ 985 /* DOKUWIKI:include js/plugins/gallery.js */ 986 /* DOKUWIKI:include js/plugins/include.js */ 987 /* DOKUWIKI:include js/plugins/inlinetoc.js */ 988 /* DOKUWIKI:include js/plugins/monthcal.js */ 989 /* DOKUWIKI:include js/plugins/move.js */ 990 /* DOKUWIKI:include js/plugins/overlay.js */ 991 /* DOKUWIKI:include js/plugins/plantuml.js */ 992 /* DOKUWIKI:include js/plugins/publish.js */ 993 /* DOKUWIKI:include js/plugins/semantic.js */ 994 /* DOKUWIKI:include js/plugins/simplenavi.js */ 995 /* DOKUWIKI:include js/plugins/struct.js */ 996 /* DOKUWIKI:include js/plugins/tabbox.js */ 997 /* DOKUWIKI:include js/plugins/tagalerts.js */ 998 /* DOKUWIKI:include js/plugins/tagging.js */ 999 /* DOKUWIKI:include js/plugins/translation.js */ 1000 /* DOKUWIKI:include js/plugins/wrap.js */ 1001 /* DOKUWIKI:include js/plugins/watchcycle.js */ 1002 }, 1003}; 1004 1005dw_template.toolbarIcons(); 1006dw_template.jQueryUI(); 1007 1008jQuery(dw_template.init); 1009