* refactor autoResize textarea.

This commit is contained in:
Catouse
2018-09-13 10:56:08 +08:00
parent e7d358eeed
commit e2ee522bf1
6 changed files with 19 additions and 71 deletions
-9
View File
@@ -130,15 +130,6 @@ $(document).on('mousedown', 'select', function()
}
})
if(navigator.userAgent.indexOf("Firefox") < 0)
{
$(document).on('input keyup paste change', 'textarea.autosize', function()
{
this.style.height = 'auto';
this.style.height = (this.scrollHeight + 2) + "px";
});
}
$(document).keydown(function(event)
{
if(event.ctrlKey && event.keyCode == 38)
-9
View File
@@ -61,15 +61,6 @@ $(document).keydown(function(event)
}
});
if(navigator.userAgent.indexOf("Firefox") < 0)
{
$(document).on('input keyup paste change', 'textarea.autosize', function()
{
this.style.height = 'auto';
this.style.height = (this.scrollHeight + 2) + "px";
});
}
/**
* Set modules and plans.
*
-9
View File
@@ -150,15 +150,6 @@ $(document).on('mousedown', 'select', function()
}
})
if(navigator.userAgent.indexOf("Firefox") < 0)
{
$(document).on('input keyup paste change', 'textarea.autosize', function()
{
this.style.height = 'auto';
this.style.height = (this.scrollHeight + 2) + "px";
});
}
$(function()
{
/* Adjust width for ie chosen width. */
+14 -31
View File
@@ -14,8 +14,8 @@ $(function()
var newRowID = 0;
/**
* Load modules and stories of a product.
*
* @param int $productID
*
* @param int $productID
* @access public
* @return void
*/
@@ -43,7 +43,7 @@ function loadBranch()
/**
* Load product branches.
*
* @param int $productID
* @param int $productID
* @access public
* @return void
*/
@@ -61,7 +61,7 @@ function loadProductBranches(productID)
}
/**
* Load stories of module.
* Load stories of module.
*
* @access public
* @return void
@@ -74,7 +74,7 @@ function loadModuleRelated()
/**
* Load module.
*
* @param int $productID
* @param int $productID
* @access public
* @return void
*/
@@ -93,8 +93,8 @@ function loadProductModules(productID, branch)
/**
* Load module.
*
* @param int $libID
*
* @param int $libID
* @access public
* @return void
*/
@@ -112,7 +112,7 @@ function loadLibModules(libID, branch)
/**
* Set story field.
*
*
* @access public
* @return void
*/
@@ -136,35 +136,18 @@ function setStories()
/**
* Init testcase steps in form
*
*
* @param string selector
* @access public
* @return void
*/
function initSteps(selector)
{
$(document).on('input keyup paste change', 'textarea.autosize', function()
{
var height = (this.scrollHeight + 2) + "px";
this.style.height = 'auto';
this.style.height = height;
$(this).closest('tr').find('textarea').each(function()
{
this.style.height = height;
});
});
/* Fix bug #4832. Auto adjust textarea height. */
$('textarea.autosize').each(function()
{
var height = (this.scrollHeight + 2) + "px";
this.style.height = 'auto';
this.style.height = height;
});
/* Fix task #4832. Auto adjust textarea height. */
$('textarea.autosize').each($.autoResizeTextarea);
var $steps = $(selector || '#steps');
var $stepTemplate = $('#stepTemplate').detach().removeClass('template').attr('id', null);
var initSortableCallTask = null;
var groupNameText = $steps.data('groupName');
var insertStepRow = function($row, count, type, notFocus)
{
@@ -240,7 +223,7 @@ function initSteps(selector)
{
isMouseDown = true;
$moveStep = $(this).closest('.step').addClass('drag-row');
$(document).off('.sortable').one('mouseup.sortable', function()
{
isMouseDown = false;
@@ -286,7 +269,7 @@ function initSteps(selector)
var $step = $checkbox.closest('.step');
var isChecked = $checkbox.is(':checked');
var suggestType = isChecked ? 'group' : 'item';
if(!isChecked)
if(!isChecked)
{
var $prevStep = $step.prev('.step:not(.drag-shadow)');
var suggestChild = $prevStep.length && $prevStep.is('.step-group') && $step.next('.step:not(.drag-shadow)').length;
@@ -314,7 +297,7 @@ function initSteps(selector)
/**
* Update the step id.
*
*
* @access public
* @return void
*/
+3 -11
View File
@@ -12,21 +12,13 @@ function loadLibModules(libID)
/**
* Init testcase steps in form
*
*
* @param string selector
* @access public
* @return void
*/
function initSteps(selector)
{
if(navigator.userAgent.indexOf("Firefox") < 0)
{
$(document).on('input keyup paste change', 'textarea.autosize', function()
{
this.style.height = 'auto';
this.style.height = (this.scrollHeight + 2) + "px";
});
}
var $steps = $(selector || '#steps');
var $stepTemplate = $('#stepTemplate').detach().removeClass('template').attr('id', null);
var initSortableCallTask = null;
@@ -104,7 +96,7 @@ function initSteps(selector)
{
isMouseDown = true;
$moveStep = $(this).closest('.step').addClass('drag-row');
$(document).off('.sortable').one('mouseup.sortable', function()
{
isMouseDown = false;
@@ -156,7 +148,7 @@ function initSteps(selector)
/**
* Update the step id.
*
*
* @access public
* @return void
*/
+2 -2
View File
File diff suppressed because one or more lines are too long