[Bps-public-commit] rt-extension-hotkeys branch, master, updated. c46b0212e78b1958d32b502f04967917a7a7cffa
? sunnavy
sunnavy at bestpractical.com
Sun Jan 15 07:42:50 EST 2012
The branch, master has been updated
via c46b0212e78b1958d32b502f04967917a7a7cffa (commit)
via c1f0afd920f4d4a9af9271d94644cf743415b4bd (commit)
from 9aa7557a67f8d6d30f35ba28d16023448ebb972f (commit)
Summary of changes:
html/NoAuth/js/hotkeys.js | 21 +++++++++++++++------
lib/RT/Extension/Hotkeys.pm | 39 ++++++++++++++++++++++++++-------------
2 files changed, 41 insertions(+), 19 deletions(-)
- Log -----------------------------------------------------------------
commit c1f0afd920f4d4a9af9271d94644cf743415b4bd
Author: sunnavy <sunnavy at bestpractical.com>
Date: Sun Jan 15 20:20:27 2012 +0800
allow simple form of %Hotkeys with body only.
so we can simply write "'v' => 'version()'"
diff --git a/lib/RT/Extension/Hotkeys.pm b/lib/RT/Extension/Hotkeys.pm
index e6e37a0..3d9f2b3 100644
--- a/lib/RT/Extension/Hotkeys.pm
+++ b/lib/RT/Extension/Hotkeys.pm
@@ -24,11 +24,16 @@ sub Convert {
my $str = '{';
for my $key ( keys %$conf ) {
$key =~ s!'!\\'!g;
- if ( exists $conf->{$key}{body} ) {
- $str .= "'$key': function() { $conf->{$key}{body} },\n";
+ if ( ref $conf->{$key} ) {
+ if ( exists $conf->{$key}{body} ) {
+ $str .= "'$key': function() { $conf->{$key}{body} },\n";
+ }
+ else {
+ $str .= "'$key': " . Convert( $conf->{$key} ) . ",\n";
+ }
}
else {
- $str .= "'$key': " . Convert( $conf->{$key} ) . ",\n";
+ $str .= "'$key': function() { $conf->{$key} },\n";
}
}
$str =~ s!,\n$!\}!; # \} is to make vim happy
@@ -43,12 +48,20 @@ sub Help {
my $str;
for my $key ( sort keys %$conf ) {
- if ( exists $conf->{$key}{body} ) {
- no warnings 'uninitialized';
- $str .= ' ' x $level . "$key -> $conf->{$key}{doc}\\n";
+ if ( ref $conf->{$key} ) {
+ if ( !ref $conf->{$key} || exists $conf->{$key}{body} ) {
+ my $doc = $conf->{$key}{doc} || $conf->{$key}{body};
+ $str .= ' ' x $level . "$key -> $doc\\n";
+ }
+ else {
+ $str .=
+ ' ' x $level
+ . "$key ->\\n"
+ . Help( $conf->{$key}, $level + 1 );
+ }
}
else {
- $str .= ' ' x $level . "$key ->\\n" . Help( $conf->{$key}, $level+1 );
+ $str .= ' ' x $level . "$key -> $conf->{$key}\\n";
}
}
return $str;
@@ -86,6 +99,7 @@ customize %Hotkeys to meet your needs:
(
'v' => { body => q!version()!, doc => 'version', },
'shift+/' => { body => q!help()!, doc => 'help', },
+ 'shift+/' => { body => q!help()!, doc => 'help', },
'h' => { body => q!open('/')!, doc => 'home', },
'/' => {
body => q!open('/Search/Build.html')!,
commit c46b0212e78b1958d32b502f04967917a7a7cffa
Author: sunnavy <sunnavy at bestpractical.com>
Date: Sun Jan 15 20:36:15 2012 +0800
make javascript calls more secure.
use jQuery.find instead so we can limit elements to existing ones only
diff --git a/html/NoAuth/js/hotkeys.js b/html/NoAuth/js/hotkeys.js
index 518aeee..e3f74d3 100644
--- a/html/NoAuth/js/hotkeys.js
+++ b/html/NoAuth/js/hotkeys.js
@@ -19,8 +19,9 @@
}
function submit( e ) {
- if ( jQuery(e).size() ) {
- jQuery(e).submit();
+ var obj = jQuery(document).find(e).filter(':first');
+ if ( obj.size() ) {
+ obj.submit();
}
else {
notFound( e );
@@ -28,19 +29,27 @@
}
function click( e ) {
- if ( jQuery(e).size() ) {
- jQuery(e).click();
+ var obj = jQuery(document).find(e).filter(':first');
+ if ( obj.size() ) {
+ obj.click();
}
else {
notFound( e );
}
}
- function open( e ) {
+ function openLink( e ) {
if ( e.match(/^\//) ) {
window.location = '<% $web_path %>' + e;
}
- else if ( jQuery(e).size() ) {
+ else {
+ window.location = e;
+ }
+ }
+
+ function open( e ) {
+ var obj = jQuery(document).find(e).filter(':first');
+ if ( obj.size() ) {
window.location = jQuery(e).filter(':first').attr('href');
}
else {
diff --git a/lib/RT/Extension/Hotkeys.pm b/lib/RT/Extension/Hotkeys.pm
index 3d9f2b3..3ea029c 100644
--- a/lib/RT/Extension/Hotkeys.pm
+++ b/lib/RT/Extension/Hotkeys.pm
@@ -99,13 +99,12 @@ customize %Hotkeys to meet your needs:
(
'v' => { body => q!version()!, doc => 'version', },
'shift+/' => { body => q!help()!, doc => 'help', },
- 'shift+/' => { body => q!help()!, doc => 'help', },
- 'h' => { body => q!open('/')!, doc => 'home', },
+ 'h' => { body => q!openLink('/')!, doc => 'home', },
'/' => {
- body => q!open('/Search/Build.html')!,
+ body => q!openLink('/Search/Build.html')!,
doc => 'search builder',
},
- 't' => { body => q!ticket()!, doc => 'go to ticket' },
+ 't' => { body => q!ticket()!, doc => 'goto ticket' },
'b' => {
body =>
q!click('a[href*="/Helpers/Toggle/TicketBookmark"]:first')!,
@@ -120,12 +119,12 @@ customize %Hotkeys to meet your needs:
doc => 'reply',
},
'g' => {
- 'a' => { body => q!open("/Admin")!, doc => 'admin', },
- 't' => { body => q!open("/Tools")!, doc => 'tools', },
+ 'a' => { body => q!openLink("/Admin")!, doc => 'admin', },
+ 't' => { body => q!openLink("/Tools")!, doc => 'tools', },
},
'n' => {
body => q!submit('#CreateTicketInQueue')!,
- doc => 'create ticket',
+ doc => 'create ticket in default queue',
},
)
);
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list