Add jquery resizing to all pages

This commit is contained in:
Eliot Whalan 2016-06-24 16:22:06 +10:00
parent 46d46f70cd
commit 565a11a2aa
3 changed files with 23 additions and 6 deletions

View File

@ -38,8 +38,7 @@
</div> </div>
<div class="form-group is-empty" style="margin-top: 0px;"> <div class="form-group is-empty" style="margin-top: 0px;">
<textarea class="form-control" rows="20" id="textArea">{{printf "%s" .Body}}</textarea> <textarea class="form-control" rows="20" id="textArea" data-autoresize>{{printf "%s" .Body}}</textarea>
<span class="help-block">Paste your text here</span> <span class="help-block">Paste your text here</span>
</div> </div>
</div> </div>
@ -479,6 +478,14 @@
<script src="https://cdn.jsdelivr.net/bootstrap.material-design/0.5.10/js/ripples.min.js" integrity="sha256-TY/EO/++Ug/P+fSBjaqlmtuphCBKwlP7TOnS+SGnN8g=" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/bootstrap.material-design/0.5.10/js/ripples.min.js" integrity="sha256-TY/EO/++Ug/P+fSBjaqlmtuphCBKwlP7TOnS+SGnN8g=" crossorigin="anonymous"></script>
<script> <script>
$.material.init(); $.material.init();
jQuery.each(jQuery('textarea[data-autoresize]'), function() {
var offset = this.offsetHeight - this.clientHeight;
var resizeTextarea = function(el) {
jQuery(el).css('height', 'auto').css('height', el.scrollHeight + offset);
};
jQuery(this).on('keyup input', function() { resizeTextarea(this); }).removeAttr('data-autoresize');
});
</script> </script>
</body> </body>

View File

@ -31,7 +31,7 @@
</div> </div>
<div class="well" style="padding-top: 10px;"> <div class="well" style="padding-top: 10px;">
<textarea class="form-control" rows="20" id="textArea">{{printf "%s" .Body}}</textarea> <textarea class="form-control" rows="20" id="textArea" data-autoresize>{{printf "%s" .Body}}</textarea>
</div> </div>
<div class="pull-right"> <div class="pull-right">
@ -52,6 +52,15 @@
<script src="https://cdn.jsdelivr.net/bootstrap.material-design/0.5.10/js/ripples.min.js" integrity="sha256-TY/EO/++Ug/P+fSBjaqlmtuphCBKwlP7TOnS+SGnN8g=" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/bootstrap.material-design/0.5.10/js/ripples.min.js" integrity="sha256-TY/EO/++Ug/P+fSBjaqlmtuphCBKwlP7TOnS+SGnN8g=" crossorigin="anonymous"></script>
<script> <script>
$.material.init(); $.material.init();
jQuery.each(jQuery('textarea[data-autoresize]'), function() {
var offset = this.offsetHeight - this.clientHeight;
var resizeTextarea = function(el) {
jQuery(el).css('height', 'auto').css('height', el.scrollHeight + offset);
};
jQuery(this).on('keyup input', function() { resizeTextarea(this); }).removeAttr('data-autoresize');
});
</script> </script>
</body> </body>

View File

@ -29,9 +29,10 @@
<div class="page-header"> <div class="page-header">
<h1>%s</h1> <h1>%s</h1>
</div> </div>
<div class="well" style="padding-top: 10px;"> <div class="well" style="padding-top: 10px;">
%s <div class="col-md-12">
%s
</div>
</div> </div>
<div class="pull-right"> <div class="pull-right">