Valerii Vasin (valerii) wrote in changelog,
Valerii Vasin
valerii
changelog

[livejournal] r22513: LJSUP-12784: "Tags" field. Provide funct...

Committer: vvasin
LJSUP-12784: "Tags" field. Provide functionality.
U   trunk/htdocs/js/jquery_fn.js
Modified: trunk/htdocs/js/jquery_fn.js
===================================================================
--- trunk/htdocs/js/jquery_fn.js	2012-07-27 07:17:30 UTC (rev 22512)
+++ trunk/htdocs/js/jquery_fn.js	2012-07-27 08:01:26 UTC (rev 22513)
@@ -22,8 +22,20 @@
  * @param  {number} endPos   End caret position.
  */
 jQuery.fn.caret = function (startPos, endPos) {
-	var $el = this.length > 1 ? this.first() : this;
+	var $el = this.length > 1 ? this.first() : this,
+		length;
 
+	if (startPos === 'start') {
+		length = $el.val().length;
+		LJ.DOM.setSelection($el, 0, 0);
+		return this;
+	}
+	if (startPos === 'end') {
+		length = $el.val().length;
+		LJ.DOM.setSelection($el, length, length);
+		return this;
+	}
+
 	if (typeof startPos === 'number') {
 		if (typeof endPos !== 'number') {
 			LJ.DOM.setCursor($el, startPos);

Tags: invis89, js, livejournal, vvasin
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments