[marginalia] r559 committed - Enter key to create an annotation is fixed

4 views
Skip to first unread message

margi...@googlecode.com

unread,
Jul 12, 2012, 5:45:23 PM7/12/12
to marginali...@googlegroups.com
Revision: 559
Author: geof.glass
Date: Thu Jul 12 14:44:58 2012
Log: Enter key to create an annotation is fixed


http://code.google.com/p/marginalia/source/detail?r=559

Modified:
/marginalia-lib/trunk/marginalia/marginalia.js

=======================================
--- /marginalia-lib/trunk/marginalia/marginalia.js Fri Jun 22 13:59:30 2012
+++ /marginalia-lib/trunk/marginalia/marginalia.js Thu Jul 12 14:44:58 2012
@@ -1171,7 +1171,15 @@
// Enter to create a regular note
if ( 13 == event.keyCode )
{
- if ( createAnnotation( null, false, marginalia.newEditor() ) )
+ // Find the post
+ var textRange = marginalia.cachedSelection;
+ if ( ! textRange )
+ textRange = marginalia.getSelection( );
+ var post = marginalia.posts.getPostByElement( textRange.startContainer
);
+ if ( null == post )
+ return false;
+
+ if ( createAnnotation( post, false, marginalia.newEditor() ) )
event.stopPropagation( );
}
}
@@ -1345,7 +1353,6 @@

return textRange;
}
-


/**
@@ -1365,9 +1372,9 @@
if ( marginalia.noteEditor )
return false;

- textRange = marginalia.cachedSelection;
+ var textRange = marginalia.cachedSelection;
if ( ! textRange )
- var textRange = marginalia.getSelection( warn );
+ textRange = marginalia.getSelection( warn );

if ( ! textRange )
{
@@ -1384,17 +1391,6 @@
return;


-/* // Find the post
- var post;
- if ( null == postId )
- {
- post = marginalia.posts.getPostByElement( textRange.startContainer );
- if ( null == post )
- return false;
- }
- else
- post = marginalia.listPosts( ).getPostById( postId );
-*/
// Confirm that the selection is within the post
var contentElement = post.getContentElement( );
if ( ! ( ( domutil.isElementDescendant( textRange.startContainer,
contentElement )
Reply all
Reply to author
Forward
0 new messages