1
0
forked from GitHub/gf-core

RGL Browser: some interface and behavioural improvements

This commit is contained in:
john.j.camilleri
2012-05-23 07:11:59 +00:00
parent 2a6ab3543e
commit 470a531931
3 changed files with 96 additions and 19 deletions

View File

@@ -21,7 +21,7 @@ $(document).ready(function() {
showPanel("#code", function() {
// Find exact line, using the classes generated by google prettify
var obj = $("#code pre li.L"+(lineNo%10)+":eq("+Math.floor(lineNo/10)+")").prev();
var y = obj.offset().top - 20;
var y = Math.max(obj.offset().top - 75, 0);
scrollToY(y, function(){
highlight(obj);
});
@@ -131,7 +131,8 @@ $(document).ready(function() {
showPanel(b);
return false;
})
.appendTo("#tabbar");
// .appendTo("#tabbar")
.insertBefore("#tabbar *:last-child")
});
showPanel(".panel:first");
@@ -227,7 +228,7 @@ $(document).ready(function() {
url: urlPrefix + "/lib/src/"+lang+"/"+module+".gf",
type: "GET",
dataType: "text",
success: function(data){
success: function(data, status, xhr){
setCode(data);
loading(false);
if (lineNo) {
@@ -288,10 +289,54 @@ $(document).ready(function() {
}
});
$("#clear").click(function(){
$("#search").val('');
$("#search")
.val('')
.focus()
runFilter();
});
$("#case_sensitive").change(runFilter);
$("#show_all").change(runFilter);
$("#show_local").change(runFilter);
// Window resize stuff
// refer: http://paulirish.com/2009/throttled-smartresize-jquery-event-handler/
(function($,sr){
// debouncing function from John Hann
// http://unscriptable.com/index.php/2009/03/20/debouncing-javascript-methods/
var debounce = function (func, threshold, execAsap) {
var timeout;
return function debounced () {
var obj = this, args = arguments;
function delayed () {
if (!execAsap)
func.apply(obj, args);
timeout = null;
};
if (timeout)
clearTimeout(timeout);
else if (execAsap)
func.apply(obj, args);
timeout = setTimeout(delayed, threshold || 100);
};
}
// smartresize
jQuery.fn[sr] = function(fn){ return fn ? this.bind('resize', debounce(fn)) : this.trigger(sr); };
})(jQuery,'smartresize');
// usage:
$(window).smartresize(function() {
recalculateHeights();
});
var recalculateHeights = function() {
$('body').height( $(window).height()-80 )
}
recalculateHeights();
});