Skip to content

Commit

Permalink
Merge pull request #50 from emagnier/resizable
Browse files Browse the repository at this point in the history
Add option to disable or change the resize property.
  • Loading branch information
toopay committed Mar 12, 2014
2 parents 6c451ea + 8980a04 commit 9a4baa6
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 11 deletions.
2 changes: 1 addition & 1 deletion css/bootstrap-markdown.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 30 additions & 10 deletions js/bootstrap-markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@
rowsVal = hasRows ? this.$textarea.attr('rows') : maxRows

this.$textarea.attr('rows',rowsVal)
this.$textarea.css('resize','none')
if (this.$options.resize) {
this.$textarea.css('resize',this.$options.resize)
}

this.$textarea
.on('focus', $.proxy(this.focus, this))
Expand Down Expand Up @@ -257,16 +259,27 @@
editor.append(editorFooter)
}

// Set width/height
$.each(['height','width'],function(k,attr){
if (options[attr] != 'inherit') {
if (jQuery.isNumeric(options[attr])) {
editor.css(attr,options[attr]+'px')
} else {
editor.addClass(options[attr])
}
// Set width
if (options.width && options.width !== 'inherit') {
if (jQuery.isNumeric(options.width)) {
editor.css('display', 'table')
textarea.css('width', options.width + 'px')
} else {
editor.addClass(options.width)
}
})
}

// Set height
if (options.height && options.height !== 'inherit') {
if (jQuery.isNumeric(options.height)) {
var height = options.height
if (editorHeader) height = Math.max(0, height - editorHeader.outerHeight())
if (editorFooter) height = Math.max(0, height - editorFooter.outerHeight())
textarea.css('height', height + 'px')
} else {
editor.addClass(options.height)
}
}

// Reference
this.$editor = editor
Expand Down Expand Up @@ -334,6 +347,12 @@
container.parent().append(replacementContainer)
}

// Set the preview element dimensions
replacementContainer.css({
width: container.outerWidth() + 'px',
height: container.outerHeight() + 'px'
})

// Hide the last-active textarea
container.hide()

Expand Down Expand Up @@ -678,6 +697,7 @@
savable:false,
width: 'inherit',
height: 'inherit',
resize: 'none',
iconlibrary: 'glyph',

/* Buttons Properties */
Expand Down
1 change: 1 addition & 0 deletions less/bootstrap-markdown.less
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
border-top: 1px dashed @table-border-color;
border-bottom: 1px dashed @table-border-color;
min-height: 10px;
overflow: auto;
}

> textarea {
Expand Down

0 comments on commit 9a4baa6

Please sign in to comment.