Skip to content
This repository has been archived by the owner on Jun 16, 2021. It is now read-only.

Commit

Permalink
changes to allow resizing, and to not affect the style of outer box
Browse files Browse the repository at this point in the history
  • Loading branch information
NeoAlchemy committed Dec 9, 2011
1 parent 7ab2a21 commit d3112bd
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
2 changes: 1 addition & 1 deletion c/css/screen.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ h1.compress {
}

.json_input:focus {
border-width: 0;
border-color: transparent;
outline: none;
background-color: #EEEEEE;
}
Expand Down
5 changes: 5 additions & 0 deletions c/js/jquery-linedtextarea/jquery-linedtextarea.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*
* Copyright (c) 2010 Alan Williamson
*
* Contribution done by Ryan Zielke ([email protected])
*
* Released under the MIT License:
* http://www.opensource.org/licenses/mit-license.php
*
Expand All @@ -20,9 +22,12 @@
*
*/

textarea { resize:both; }

.linedwrap {
border: 1px solid #c0c0c0;
padding: 3px;
display: inline-block;
}

.linedtextarea {
Expand Down
24 changes: 17 additions & 7 deletions c/js/jquery-linedtextarea/jquery-linedtextarea.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*
* Copyright (c) 2010 Alan Williamson
*
* Contributions done by Ryan Zielke ([email protected])
*
* Version:
* $Id: jquery-linedtextarea.js 464 2010-01-08 10:36:33Z alan $
*
Expand All @@ -22,6 +24,7 @@
* });
*
* History:
* - 2011.12.08: Changes to allow resizing and not affect styling of the outer div
* - 2010.01.08: Fixed a Google Chrome layout problem
* - 2010.01.07: Refactored code for speed/readability; Fixed horizontal sizing
* - 2010.01.06: Initial Release
Expand Down Expand Up @@ -61,18 +64,16 @@

/* Turn off the wrapping of as we don't want to screw up the line numbers */
textarea.attr("wrap", "off");
textarea.css({resize:'none'});
textarea.css({resize:'both'});
var originalTextAreaWidth = textarea.outerWidth();

/* Wrap the text area in the elements we need */
textarea.wrap("<div class='linedtextarea'></div>");
var linedTextAreaDiv = textarea.parent().wrap("<div class='linedwrap' style='width:" + originalTextAreaWidth + "px'></div>");
var linedTextAreaDiv = textarea.wrap("<div class='linedwrap'></div>");
var linedWrapDiv = linedTextAreaDiv.parent();

linedWrapDiv.prepend("<div class='lines' style='width:50px'></div>");

var linesDiv = linedWrapDiv.find(".lines");
linesDiv.height( textarea.height() );


/* Draw the number bar; filling it out where necessary */
Expand All @@ -94,8 +95,8 @@
var linedWrapDivNewWidth = originalTextAreaWidth - paddingHorizontal;
var textareaNewWidth = originalTextAreaWidth - sidebarWidth - paddingHorizontal;

textarea.width( textareaNewWidth );
linedWrapDiv.width( linedWrapDivNewWidth );
textarea.width( textareaNewWidth);
textarea.css({maxWidth: textareaNewWidth - 6}); //TODO make this calculated



Expand All @@ -114,7 +115,16 @@
var domTextArea = $(this)[0];
linesDiv.height( domTextArea.clientHeight + 6 );
});



window.setInterval( function(tn) {
linesDiv.height(textarea.height());
var scrollTop = textarea[0].scrollTop;
var clientHeight = textarea[0].clientHeight;
codeLinesDiv.css( {'margin-top': (-1*scrollTop) + "px"} );
lineNo = fillOutLines( codeLinesDiv, scrollTop + clientHeight, lineNo );
},10);

});
};

Expand Down

3 comments on commit d3112bd

@shuvozula
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this commit is causing it, but I cant seem to paste large JSON strings anymore

@umbrae
Copy link
Owner

@umbrae umbrae commented on d3112bd Jun 25, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shuvozula Can you paste into this one? http://files.aw20.net/jquery-linedtextarea/jquery-linedtextarea.html

Trying to determine if it's linedtextarea in general or this bit.

@shuvozula
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, that worked.

Please sign in to comment.