1 /** 2 * Мы обрабатываем несколько классов устройств в зависимости от ширины браузера. 3 * 4 * - рабочий стол: > __tablet_width__ (как установлено в style.ini) 5 * - мобильный: 6 * - планшет <= __tablet_width__ 7 * - телефон <= __phone_width__ 8 */ 9 var device_class = ''; // пока неизвестно 10 var device_classes = 'desktop mobile tablet phone'; 11 12 function tpl_dokuwiki_mobile(){ 13 14 // z-index в mobile.css (неправильно) используется исключительно для определения режима экрана здесь 15 var screen_mode = jQuery('#screen__mode').css('z-index') + ''; 16 17 // определяем наш шаблон устройства 18 // TODO: рассмотреть возможность перехода на dokuwiki core 19 switch (screen_mode) { 20 case '1': 21 if (device_class.match(/tablet/)) return; 22 device_class = 'mobile tablet'; 23 break; 24 case '2': 25 if (device_class.match(/phone/)) return; 26 device_class = 'mobile phone'; 27 break; 28 default: 29 if (device_class == 'desktop') return; 30 device_class = 'desktop'; 31 } 32 33 jQuery('html').removeClass(device_classes).addClass(device_class); 34 35 // обработать некоторые изменения макета в зависимости от изменения устройства 36 var $handle = jQuery('#dokuwiki__aside h3.toggle'); 37 var $toc = jQuery('#dw__toc h3'); 38 39 if (device_class == 'desktop') { 40 // reset for desktop mode 41 if($handle.length) { 42 $handle[0].setState(1); 43 $handle.hide(); 44 } 45 if($toc.length) { 46 $toc[0].setState(1); 47 } 48 } 49 if (device_class.match(/mobile/)){ 50 // toc and sidebar hiding 51 if($handle.length) { 52 $handle.show(); 53 $handle[0].setState(-1); 54 } 55 if($toc.length) { 56 $toc[0].setState(-1); 57 } 58 } 59 } 60 61 jQuery(function(){ 62 var resizeTimer; 63 dw_page.makeToggle('#dokuwiki__aside h3.toggle','#dokuwiki__aside div.content'); 64 65 tpl_dokuwiki_mobile(); 66 jQuery(window).on('resize', 67 function(){ 68 if (resizeTimer) clearTimeout(resizeTimer); 69 resizeTimer = setTimeout(tpl_dokuwiki_mobile,200); 70 } 71 ); 72 73 // увеличить длину боковой панели для соответствия содержимому (только в режиме рабочего стола) 74 var sidebar_height = jQuery('.desktop #dokuwiki__aside').height(); 75 var pagetool_height = jQuery('.desktop #dokuwiki__pagetools ul:first').height(); 76 // pagetools div не имеет высоты; ul имеет высоту 77 var content_min = Math.max(sidebar_height || 0, pagetool_height || 0); 78 79 var content_height = jQuery('#dokuwiki__content div.page').height(); 80 if(content_min && content_min > content_height) { 81 var $content = jQuery('#dokuwiki__content div.page'); 82 $content.css('min-height', content_min); 83 } 84 85 // размытие при нажатии 86 jQuery('#dokuwiki__pagetools div.tools>ul>li>a').on('click', function(){ 87 this.blur(); 88 }); 89 }); 90