NBash

Форк
0
145 строк · 5.5 Кб
1
/*
2
 @licstart  The following is the entire license notice for the JavaScript code in this file.
3

4
 The MIT License (MIT)
5

6
 Copyright (C) 1997-2020 by Dimitri van Heesch
7

8
 Permission is hereby granted, free of charge, to any person obtaining a copy of this software
9
 and associated documentation files (the "Software"), to deal in the Software without restriction,
10
 including without limitation the rights to use, copy, modify, merge, publish, distribute,
11
 sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
12
 furnished to do so, subject to the following conditions:
13

14
 The above copyright notice and this permission notice shall be included in all copies or
15
 substantial portions of the Software.
16

17
 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
18
 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20
 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22

23
 @licend  The above is the entire license notice for the JavaScript code in this file
24
 */
25

26
function initResizable(treeview) {
27
  let sidenav,navtree,content,header,footer,barWidth=6;
28
  const RESIZE_COOKIE_NAME = '85fe94dddf165f44ed4872b508947595_'+'width';
29

30
  function resizeWidth() {
31
    const sidenavWidth = $(sidenav).outerWidth();
32
    content.css({marginLeft:parseInt(sidenavWidth)+"px"});
33
    if (typeof page_layout!=='undefined' && page_layout==1) {
34
      footer.css({marginLeft:parseInt(sidenavWidth)+"px"});
35
    }
36
    Cookie.writeSetting(RESIZE_COOKIE_NAME,sidenavWidth-barWidth);
37
  }
38

39
  function restoreWidth(navWidth) {
40
    content.css({marginLeft:parseInt(navWidth)+barWidth+"px"});
41
    if (typeof page_layout!=='undefined' && page_layout==1) {
42
      footer.css({marginLeft:parseInt(navWidth)+barWidth+"px"});
43
    }
44
    sidenav.css({width:navWidth + "px"});
45
  }
46

47
  function resizeHeight(treeview) {
48
    const headerHeight = header.outerHeight();
49
    const windowHeight = $(window).height();
50
    let contentHeight;
51
    if (treeview)
52
    {
53
      const footerHeight = footer.outerHeight();
54
      let navtreeHeight,sideNavHeight;
55
      if (typeof page_layout==='undefined' || page_layout==0) { /* DISABLE_INDEX=NO */
56
        contentHeight = windowHeight - headerHeight - footerHeight;
57
        navtreeHeight = contentHeight;
58
        sideNavHeight = contentHeight;
59
      } else if (page_layout==1) { /* DISABLE_INDEX=YES */
60
        contentHeight = windowHeight - footerHeight;
61
        navtreeHeight = windowHeight - headerHeight;
62
        sideNavHeight = windowHeight;
63
      }
64
      navtree.css({height:navtreeHeight + "px"});
65
      sidenav.css({height:sideNavHeight + "px"});
66
    }
67
    else
68
    {
69
      contentHeight = windowHeight - headerHeight;
70
    }
71
    content.css({height:contentHeight + "px"});
72
    if (location.hash.slice(1)) {
73
      (document.getElementById(location.hash.slice(1))||document.body).scrollIntoView();
74
    }
75
  }
76

77
  function collapseExpand() {
78
    let newWidth;
79
    if (sidenav.width()>0) {
80
      newWidth=0;
81
    } else {
82
      const width = Cookie.readSetting(RESIZE_COOKIE_NAME,250);
83
      newWidth = (width>250 && width<$(window).width()) ? width : 250;
84
    }
85
    restoreWidth(newWidth);
86
    const sidenavWidth = $(sidenav).outerWidth();
87
    Cookie.writeSetting(RESIZE_COOKIE_NAME,sidenavWidth-barWidth);
88
  }
89

90
  header  = $("#top");
91
  content = $("#doc-content");
92
  footer  = $("#nav-path");
93
  sidenav = $("#side-nav");
94
  if (!treeview) {
95
//    title   = $("#titlearea");
96
//    titleH  = $(title).height();
97
//    let animating = false;
98
//    content.on("scroll", function() {
99
//      slideOpts = { duration: 200,
100
//                    step: function() {
101
//                        contentHeight = $(window).height() - header.outerHeight();
102
//                        content.css({ height : contentHeight + "px" });
103
//                      },
104
//                    done: function() { animating=false; }
105
//                  };
106
//      if (content.scrollTop()>titleH && title.css('display')!='none' && !animating) {
107
//        title.slideUp(slideOpts);
108
//        animating=true;
109
//      } else if (content.scrollTop()<=titleH && title.css('display')=='none' && !animating) {
110
//        title.slideDown(slideOpts);
111
//        animating=true;
112
//      }
113
//    });
114
  } else {
115
    navtree = $("#nav-tree");
116
    $(".side-nav-resizable").resizable({resize: function(e, ui) { resizeWidth(); } });
117
    $(sidenav).resizable({ minWidth: 0 });
118
  }
119
  $(window).resize(function() { resizeHeight(treeview); });
120
  if (treeview)
121
  {
122
    const device = navigator.userAgent.toLowerCase();
123
    const touch_device = device.match(/(iphone|ipod|ipad|android)/);
124
    if (touch_device) { /* wider split bar for touch only devices */
125
      $(sidenav).css({ paddingRight:'20px' });
126
      $('.ui-resizable-e').css({ width:'20px' });
127
      $('#nav-sync').css({ right:'34px' });
128
      barWidth=20;
129
    }
130
    const width = Cookie.readSetting(RESIZE_COOKIE_NAME,250);
131
    if (width) { restoreWidth(width); } else { resizeWidth(); }
132
  }
133
  resizeHeight(treeview);
134
  const url = location.href;
135
  const i=url.indexOf("#");
136
  if (i>=0) window.location.hash=url.substr(i);
137
  const _preventDefault = function(evt) { evt.preventDefault(); };
138
  if (treeview)
139
  {
140
    $("#splitbar").bind("dragstart", _preventDefault).bind("selectstart", _preventDefault);
141
    $(".ui-resizable-handle").dblclick(collapseExpand);
142
  }
143
  $(window).on('load',resizeHeight);
144
}
145
/* @license-end */
146

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.