Commit 4f00ad8b authored by catch's avatar catch

Issue #1138258 by Rob Loach, idflood, nod_, ericduran: Drop textarea.js in favor of CSS3 resize.

parent 6b5fff7f
......@@ -3815,7 +3815,7 @@ function theme_form($variables) {
* An associative array containing:
* - element: An associative array containing the properties of the element.
* Properties used: #title, #value, #description, #rows, #cols,
* #placeholder, #required, #attributes
* #placeholder, #required, #attributes, #resizable
*
* @ingroup themeable
*/
......@@ -3830,8 +3830,7 @@ function theme_textarea($variables) {
// Add resizable behavior.
if (!empty($element['#resizable'])) {
drupal_add_library('system', 'drupal.textarea');
$wrapper_attributes['class'][] = 'resizable';
$element['#attributes']['class'][] = 'resize-' . $element['#resizable'];
}
$output = '<div' . drupal_attributes($wrapper_attributes) . '>';
......
(function ($) {
Drupal.behaviors.textarea = {
attach: function (context, settings) {
$('.form-textarea-wrapper.resizable', context).once('textarea', function () {
var staticOffset = null;
var textarea = $(this).addClass('resizable-textarea').find('textarea');
var grippie = $('<div class="grippie"></div>').mousedown(startDrag);
grippie.insertAfter(textarea);
function startDrag(e) {
staticOffset = textarea.height() - e.pageY;
textarea.css('opacity', 0.25);
$(document).mousemove(performDrag).mouseup(endDrag);
return false;
}
function performDrag(e) {
textarea.height(Math.max(32, staticOffset + e.pageY) + 'px');
return false;
}
function endDrag(e) {
$(document).unbind('mousemove', performDrag).unbind('mouseup', endDrag);
textarea.css('opacity', 1);
}
});
}
};
})(jQuery);
......@@ -916,7 +916,7 @@ function filter_process_format($element) {
$element['value']['#rows'] = 3;
}
$element['value']['#disabled'] = TRUE;
$element['value']['#resizable'] = FALSE;
$element['value']['#resizable'] = 'none';
// Hide the text format selector and any other child element (such as text
// field's summary).
......
......@@ -61,8 +61,6 @@ fieldset.collapsible .fieldset-legend {
/**
* Resizable textareas.
*
* @see textarea.js
*/
.form-textarea-wrapper textarea {
display: block;
......@@ -72,13 +70,21 @@ fieldset.collapsible .fieldset-legend {
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
.resizable-textarea .grippie {
background: #eee url(../../misc/grippie.png) no-repeat center 2px;
border: 1px solid #ddd;
border-top-width: 0;
cursor: s-resize;
height: 9px;
overflow: hidden;
.resize-none {
resize: none;
}
.resize-vertical {
resize: vertical;
min-height: 2em;
}
.resize-horizontal {
resize: horizontal;
max-width: 100%;
}
.resize-both {
resize: both;
max-width: 100%;
min-height: 2em;
}
/**
......
......@@ -403,7 +403,7 @@ function system_element_info() {
'#input' => TRUE,
'#cols' => 60,
'#rows' => 5,
'#resizable' => TRUE,
'#resizable' => 'vertical',
'#process' => array('ajax_process_form'),
'#theme' => 'textarea',
'#theme_wrappers' => array('form_element'),
......@@ -1162,15 +1162,6 @@ function system_library_info() {
),
);
// Drupal's resizable textarea.
$libraries['drupal.textarea'] = array(
'title' => 'Drupal resizable textarea',
'version' => VERSION,
'js' => array(
'core/misc/textarea.js' => array('group' => JS_DEFAULT),
),
);
// Drupal's autocomplete widget.
$libraries['drupal.autocomplete'] = array(
'title' => 'Drupal autocomplete',
......
......@@ -1247,13 +1247,6 @@ input.form-submit:focus {
border-top-left-radius: 4px;
border-top-right-radius: 4px;
}
.contact-form .resizable-textarea .grippie {
width: 76%;
-moz-border-radius-bottomleft: 4px;
-moz-border-radius-bottomright: 4px;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
}
/* Disabled form elements */
input.form-button-disabled,
......@@ -1267,10 +1260,6 @@ input.form-button-disabled:active,
border-color: #bbb;
color: #717171;
}
.form-disabled .grippie {
background-color: #ededed;
border-color: #bbb;
}
.form-disabled label {
color: #717171;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment