http://www.mediawiki.org/wiki/Special:Code/MediaWiki/89700
Revision: 89700
Author: tparscal
Date: 2011-06-07 21:55:49 +0000 (Tue, 07 Jun 2011)
Log Message:
-----------
Fixed imporperly initialized variable (sel, which needed to contain
active=false initially) and added blinking cursor.
Modified Paths:
--------------
trunk/parsers/wikidom/lib/jquery.editSurface.css
trunk/parsers/wikidom/lib/jquery.editSurface.js
Modified: trunk/parsers/wikidom/lib/jquery.editSurface.css
===================================================================
--- trunk/parsers/wikidom/lib/jquery.editSurface.css 2011-06-07 21:51:43 UTC
(rev 89699)
+++ trunk/parsers/wikidom/lib/jquery.editSurface.css 2011-06-07 21:55:49 UTC
(rev 89700)
@@ -43,3 +43,11 @@
background-color: Highlight;
cursor: text;
}
+
+.editSurface-cursor {
+ position: absolute;
+ background-color: black;
+ width: 1px;
+ height: 1.5em;
+ display: none;
+}
\ No newline at end of file
Modified: trunk/parsers/wikidom/lib/jquery.editSurface.js
===================================================================
--- trunk/parsers/wikidom/lib/jquery.editSurface.js 2011-06-07 21:51:43 UTC
(rev 89699)
+++ trunk/parsers/wikidom/lib/jquery.editSurface.js 2011-06-07 21:55:49 UTC
(rev 89700)
@@ -1,6 +1,8 @@
$.fn.editSurface = function( options ) {
var $this = $(this);
- var sel;
+ sel = {
+ 'active': false
+ };
options = $.extend( {
// Defaults
@@ -11,6 +13,7 @@
$this
.addClass( 'editSurface-container' )
.append( '<div class="editSurface-document"></div>' )
+ .after( '<div class="editSurface-cursor"></div>' )
.before( '<div class="editSurface-range"></div>'
+ '<div class="editSurface-range"></div>'
+ '<div class="editSurface-range"></div>')
@@ -27,7 +30,15 @@
'start': getSelection( e ),
'end': null
};
+ cursor.show();
drawSelection( $target.parent() );
+ // Move cursor
+ if ( sel.start ) {
+ cursor.$.css( {
+ 'top': sel.start.top,
+ 'left': sel.start.left
+ } );
+ }
}
return false;
} )
@@ -39,6 +50,7 @@
sel.to = null;
sel.start = null;
sel.end = null;
+ cursor.show();
}
sel.active = false;
drawSelection( $target.parent() );
@@ -57,6 +69,7 @@
sel.from = sel.end;
sel.to = sel.start;
}
+ cursor.hide();
drawSelection( $target.parent() );
}
} );
@@ -201,6 +214,36 @@
}
}
+ var cursor = {
+ '$': $( '.editSurface-cursor' ),
+ 'visible': true,
+ 'timeout': null,
+ 'speed': 500
+ };
+ cursor.blink = function() {
+ // Flip
+ cursor.visible = !cursor.visible;
+ // Hide/show
+ cursor.visible ? cursor.$.hide() : cursor.$.show();
+ // Repeat
+ cursor.timeout = setTimeout( cursor.blink, cursor.speed )
+ }
+ cursor.show = function() {
+ // Start visible (will flip when run)
+ cursor.visible = true;
+ cursor.$.show();
+ // Start/restart blinking
+ clearTimeout( cursor.timeout );
+ cursor.blink();
+ };
+ cursor.hide = function() {
+ // Hide
+ cursor.$.hide();
+ // Stop blinking
+ clearTimeout( cursor.timeout );
+ };
+
$(window).resize( update );
update();
+ cursor.show();
};
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs