annotate code-docs/resize.js @ 7:66d125fb8b42 tip

Added tag vamp-plugin-sdk-v2.7 for changeset 27319718b1f8
author Chris Cannam
date Fri, 24 Feb 2017 16:45:00 +0000
parents 27319718b1f8
children
rev   line source
Chris@6 1 function initResizable()
Chris@6 2 {
Chris@6 3 var cookie_namespace = 'doxygen';
Chris@6 4 var sidenav,navtree,content,header,collapsed,collapsedWidth=0,barWidth=6,desktop_vp=768,titleHeight;
Chris@1 5
Chris@6 6 function readCookie(cookie)
Chris@1 7 {
Chris@6 8 var myCookie = cookie_namespace+"_"+cookie+"=";
Chris@6 9 if (document.cookie) {
Chris@6 10 var index = document.cookie.indexOf(myCookie);
Chris@6 11 if (index != -1) {
Chris@6 12 var valStart = index + myCookie.length;
Chris@6 13 var valEnd = document.cookie.indexOf(";", valStart);
Chris@6 14 if (valEnd == -1) {
Chris@6 15 valEnd = document.cookie.length;
Chris@6 16 }
Chris@6 17 var val = document.cookie.substring(valStart, valEnd);
Chris@6 18 return val;
Chris@1 19 }
Chris@6 20 }
Chris@6 21 return 0;
Chris@6 22 }
Chris@6 23
Chris@6 24 function writeCookie(cookie, val, expiration)
Chris@6 25 {
Chris@6 26 if (val==undefined) return;
Chris@6 27 if (expiration == null) {
Chris@6 28 var date = new Date();
Chris@6 29 date.setTime(date.getTime()+(10*365*24*60*60*1000)); // default expiration is one week
Chris@6 30 expiration = date.toGMTString();
Chris@6 31 }
Chris@6 32 document.cookie = cookie_namespace + "_" + cookie + "=" + val + "; expires=" + expiration+"; path=/";
Chris@6 33 }
Chris@6 34
Chris@6 35 function resizeWidth()
Chris@6 36 {
Chris@6 37 var windowWidth = $(window).width() + "px";
Chris@6 38 var sidenavWidth = $(sidenav).outerWidth();
Chris@6 39 content.css({marginLeft:parseInt(sidenavWidth)+"px"});
Chris@6 40 writeCookie('width',sidenavWidth-barWidth, null);
Chris@6 41 }
Chris@6 42
Chris@6 43 function restoreWidth(navWidth)
Chris@6 44 {
Chris@6 45 var windowWidth = $(window).width() + "px";
Chris@6 46 content.css({marginLeft:parseInt(navWidth)+barWidth+"px"});
Chris@6 47 sidenav.css({width:navWidth + "px"});
Chris@6 48 }
Chris@6 49
Chris@6 50 function resizeHeight()
Chris@6 51 {
Chris@6 52 var headerHeight = header.outerHeight();
Chris@6 53 var footerHeight = footer.outerHeight();
Chris@6 54 var windowHeight = $(window).height() - headerHeight - footerHeight;
Chris@6 55 content.css({height:windowHeight + "px"});
Chris@6 56 navtree.css({height:windowHeight + "px"});
Chris@6 57 sidenav.css({height:windowHeight + "px"});
Chris@6 58 var width=$(window).width();
Chris@6 59 if (width!=collapsedWidth) {
Chris@6 60 if (width<desktop_vp && collapsedWidth>=desktop_vp) {
Chris@6 61 if (!collapsed) {
Chris@6 62 collapseExpand();
Chris@6 63 }
Chris@6 64 } else if (width>desktop_vp && collapsedWidth<desktop_vp) {
Chris@6 65 if (collapsed) {
Chris@6 66 collapseExpand();
Chris@6 67 }
Chris@6 68 }
Chris@6 69 collapsedWidth=width;
Chris@1 70 }
Chris@1 71 }
Chris@1 72
Chris@6 73 function collapseExpand()
Chris@1 74 {
Chris@6 75 if (sidenav.width()>0) {
Chris@6 76 restoreWidth(0);
Chris@6 77 collapsed=true;
Chris@6 78 }
Chris@6 79 else {
Chris@6 80 var width = readCookie('width');
Chris@6 81 if (width>200 && width<$(window).width()) { restoreWidth(width); } else { restoreWidth(200); }
Chris@6 82 collapsed=false;
Chris@6 83 }
Chris@1 84 }
Chris@1 85
Chris@1 86 header = $("#top");
Chris@1 87 sidenav = $("#side-nav");
Chris@1 88 content = $("#doc-content");
Chris@1 89 navtree = $("#nav-tree");
Chris@1 90 footer = $("#nav-path");
Chris@1 91 $(".side-nav-resizable").resizable({resize: function(e, ui) { resizeWidth(); } });
Chris@6 92 $(sidenav).resizable({ minWidth: 0 });
Chris@1 93 $(window).resize(function() { resizeHeight(); });
Chris@6 94 var device = navigator.userAgent.toLowerCase();
Chris@6 95 var touch_device = device.match(/(iphone|ipod|ipad|android)/);
Chris@6 96 if (touch_device) { /* wider split bar for touch only devices */
Chris@6 97 $(sidenav).css({ paddingRight:'20px' });
Chris@6 98 $('.ui-resizable-e').css({ width:'20px' });
Chris@6 99 $('#nav-sync').css({ right:'34px' });
Chris@6 100 barWidth=20;
Chris@6 101 }
Chris@1 102 var width = readCookie('width');
Chris@1 103 if (width) { restoreWidth(width); } else { resizeWidth(); }
Chris@1 104 resizeHeight();
Chris@1 105 var url = location.href;
Chris@1 106 var i=url.indexOf("#");
Chris@1 107 if (i>=0) window.location.hash=url.substr(i);
Chris@1 108 var _preventDefault = function(evt) { evt.preventDefault(); };
Chris@1 109 $("#splitbar").bind("dragstart", _preventDefault).bind("selectstart", _preventDefault);
Chris@6 110 $(".ui-resizable-handle").dblclick(collapseExpand);
Chris@6 111 $(window).load(resizeHeight);
Chris@1 112 }
Chris@1 113
Chris@1 114