Permalink
Browse files

Fix pagedown & pageup.

  • Loading branch information...
1 parent 6ebd406 commit 62a935a9e69b0c3ed5eee122aa03774a8a3e178a @arcusfelis committed Dec 21, 2012
Showing with 89 additions and 25 deletions.
  1. +15 −0 priv/html/index.html
  2. +1 −0 priv/js_lib/jquery.jscrollpane.js
  3. +25 −5 priv/js_src/relatio.js
  4. +30 −6 priv/js_src/relatio.world.js
  5. +18 −14 src/relatio_data_handler.erl
View
@@ -153,6 +153,21 @@
</div>
<div id="module-list" class="content-block"></div>
</div>
+
+ <div class="sub-block">
+ <div class="sub-block-header">
+ <a tabindex="0" class="header-closed">Detalize&hellip;</a>
+ <a tabindex="0" class="header-opened">Detalize:</a>
+ </div>
+ <div class="content-block">
+ <fieldset>
+ <legend>Nodes:</legend>
+ <a>&#x25c9; Visible now</a>
+ <a>&#x25ef; Selected</a>
+ </fieldset>
+ <input type="button" value="Go" />
+ </div>
+ </div>
</div>
</div>
@@ -1389,6 +1389,7 @@
if (jspApi) {
jspApi.reinitialise(settings);
} else {
+ $("script",elem).filter('[type="text/javascript"],not([type])').remove();
jspApi = new JScrollPane(elem, settings);
elem.data('jsp', jspApi);
}
View
@@ -724,6 +724,7 @@ $.fn.activateAutoResizeMonitor = function() {
};
$.fn.updateScrolling = function() {
+ console.log("upd");
var area = this;
if (area.jspUpdateTimeout)
clearTimeout(area.timeout);
@@ -747,10 +748,12 @@ var relatio = {};
relatio.keyBoard = {};
relatio.utils = {};
relatio.keyBoard.keyCodes = {
- ESCAPE: 27,
- ENTER: 13,
- SHIFT: 16,
- TAB: 9
+ ESCAPE: 27,
+ ENTER: 13,
+ SHIFT: 16,
+ TAB: 9,
+ PAGEDOWN: 34,
+ PAGEUP: 33
};
relatio.keyBoard.charCodes = {
H: 72,
@@ -784,7 +787,8 @@ relatio.keyBoard.charCodes = {
SLASH: 47,
TILDA: 126,
GRAVE: 96,
- RIGHT_PARENTHESIS: 41
+ RIGHT_PARENTHESIS: 41,
+ WHITESPACE: 32
};
// Move from id on `offset` nodes forward using ids as an index,
@@ -801,3 +805,19 @@ relatio.utils = function nextNode(offset, id, ids)
};
+(function($) {
+ $.expr[":"].onScreen = function(elem) {
+ var $window = $(window),
+ viewport_top = $window.scrollTop(),
+ viewport_height = $window.height(),
+ viewport_bottom = viewport_top + viewport_height,
+ $elem = $(elem),
+ top = $elem.offset().top,
+ height = $elem.height(),
+ bottom = top + height;
+
+ return (top >= viewport_top && top < viewport_bottom) &&
+ (bottom > viewport_top && bottom <= viewport_bottom);
+}
+})(jQuery);
+
@@ -527,15 +527,21 @@ relatio.initWorld = function() {
return si._core.width - calculateRightPanelSize();
}
+ var isEmptyArea = function(elem) {
+ return !~["LABEL", "INPUT"].indexOf(elem.tagName);
+ }
// Handler for closing the pane
$("#graph-directions").click(function(e) {
- closeDirectionSidebar();
+ if (isEmptyArea(e.target))
+ closeDirectionSidebar();
});
$("#search-pane").click(function(e) {
- closeSearchSidebar();
+ if (isEmptyArea(e.target))
+ closeSearchSidebar();
});
+
/////////////////////// Key Handlers ///////////////////////////////
var repeatCount = 0;
@@ -658,13 +664,20 @@ relatio.initWorld = function() {
var cc = e.charCode;
switch (kc) {
+ case keyCodes.PAGEUP:
+ case keyCodes.PAGEDOWN:
+ var dir = kc == keyCodes.PAGEUP ? 0.5 : -0.5;
+ var p = this.pane;
+ p.data("jsp").scrollByY(-p.innerHeight() * dir, false);
+ $("a:visible:onScreen:first", this.pane).focus();
+ break;
+
case keyCodes.ESCAPE:
if (isDirectionSidebarOpen())
closeDirectionSidebar();
else if (isSearchingSidebarOpen())
closeSearchSidebar();
break;
-
case keyCodes.ENTER:
if ($(":focus").attr("id") == "search-field")
@@ -679,6 +692,14 @@ relatio.initWorld = function() {
switch (cc) {
+ case charCodes.WHITESPACE:
+ // Emulate click on a checkbox
+ var ee = $.Event("click");
+ ee.shiftKey = e.shiftKey;
+ $(":focus").prevAll(".checkbox:first").trigger(ee);
+ return false;
+ break;
+
case charCodes.h:
// the left key, the prev pane
case charCodes.l:
@@ -803,7 +824,7 @@ relatio.initWorld = function() {
- $(document).keypress(function(e) {
+ $(document).on("keypress.relatioWindowHandler", function(e) {
var win = wm.current();
@@ -1003,7 +1024,10 @@ relatio.initWorld = function() {
}
});
$("#search-field").keyup(tryToSearch);
- $("#search-results, #graph-directions").jScrollPane({trackClickRepeatFreq: 20});
+ $("#search-results, #graph-directions").jScrollPane({
+ trackClickRepeatFreq: 20,
+ enableKeyboardNavigation: false
+ });
@@ -1086,7 +1110,7 @@ relatio.initWorld = function() {
});
- $(document).on("keydown keyup", function(e) {
+ $(document).on("keydown.relatio keyup.relatio", function(e) {
if (e.keyCode == keyCodes.SHIFT) {
switch (e.type) {
case "keydown":
@@ -38,41 +38,43 @@ terminate(_Req, _State) ->
generate_xml() ->
%% TODO: rewrite this function completely.
- Dir = "/home/user/erlang/esl/ejabberd/apps/ejabberd",
- case whereis(relatio_ex1) of
- undefined ->
- {ok, Xref} = xref:start(relatio_ex1),
- xref:add_application(Xref, Dir),
- Xref;
- Xref ->
- Xref
- end,
+ Dir1 = "/home/user/erlang/esl/ejabberd/apps/ejabberd",
+ Dir2 = code:lib_dir(stdlib),
+ Dir3 = code:lib_dir(kernel),
case whereis(inferno_server) of
undefined ->
- {ok, Info} = inferno_server:start(Dir, []),
+ {ok, Info} = inferno_server:start([]),
+ inferno_server:add_application(Info, Dir1),
+ inferno_server:add_application(Info, Dir2),
+ inferno_server:add_application(Info, Dir3),
erlang:register(inferno_server, self()),
Info;
Info ->
Info
end,
- link(Xref),
link(Info),
+
+ {ok, Xref} = xref:start([]),
+%% xref:add_module(Xref, Path),
+ link(Xref),
+
try
gexf:to_string(gexf_xref:generate(Xref, Info))
after
- unlink(Xref),
+ xref:stop(Xref),
unlink(Info)
end.
+
generate_world_xml() ->
%% TODO: rewrite this function completely.
Dir1 = "/home/user/erlang/esl/ejabberd/apps/ejabberd",
Dir2 = code:lib_dir(stdlib),
Dir3 = code:lib_dir(kernel),
- case whereis(relatio_ex2) of
+ case whereis(relatio_world) of
undefined ->
- {ok, Xref} = xref:start(relatio_ex2),
+ {ok, Xref} = xref:start(relatio_world),
xref:add_application(Xref, Dir1),
xref:add_application(Xref, Dir2),
xref:add_application(Xref, Dir3),
@@ -86,3 +88,5 @@ generate_world_xml() ->
after
unlink(Xref)
end.
+
+

0 comments on commit 62a935a

Please sign in to comment.