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