Improved error handling.
This commit is contained in:
parent
776e60f3a2
commit
72e2a73f63
2 changed files with 58 additions and 7 deletions
|
@ -95,6 +95,7 @@
|
|||
}
|
||||
}, this ))
|
||||
|
||||
// reduce buffer, in case close it
|
||||
this.$element.on('keydown', $.proxy(function (e) {
|
||||
|
||||
// backspace
|
||||
|
@ -109,8 +110,8 @@
|
|||
}
|
||||
}, this ))
|
||||
|
||||
// build buffer
|
||||
this.$element.on('keypress', $.proxy(function (e) {
|
||||
var value = this.$element.text()
|
||||
console.log('BUFF', this.buffer, e.keyCode, String.fromCharCode(e.which) )
|
||||
a = $.proxy(function() {
|
||||
|
||||
|
@ -119,6 +120,16 @@
|
|||
return
|
||||
}
|
||||
|
||||
// enter
|
||||
if ( e.keyCode === 13 ) {
|
||||
return
|
||||
}
|
||||
|
||||
// arrow keys
|
||||
if ( e.keyCode === 37 || e.keyCode === 38 || e.keyCode === 39 || e.keyCode === 40 ) {
|
||||
return
|
||||
}
|
||||
|
||||
// enter :
|
||||
if ( String.fromCharCode(e.which) === ':' ) {
|
||||
this.buffer = this.buffer + ':'
|
||||
|
@ -234,7 +245,13 @@
|
|||
}
|
||||
var range = sel.getRangeAt(0)
|
||||
var clone = range.cloneRange()
|
||||
clone.setStart(range.startContainer, range.startOffset - this.buffer.length)
|
||||
|
||||
// improve error handling
|
||||
start = range.startOffset - this.buffer.length
|
||||
if (start < 0) {
|
||||
start = 0
|
||||
}
|
||||
clone.setStart(range.startContainer, start)
|
||||
clone.setEnd(range.startContainer, range.startOffset)
|
||||
clone.deleteContents()
|
||||
this.buffer = ''
|
||||
|
|
|
@ -121,8 +121,9 @@ class AgentTicketActionLevel5Test < TestCase
|
|||
:css => 'a[href="#ticket/create"]',
|
||||
},
|
||||
{
|
||||
:execute => 'wait',
|
||||
:value => 2,
|
||||
:execute => 'watch_for',
|
||||
:area => '.active [data-name="body"]',
|
||||
:value => '',
|
||||
},
|
||||
{
|
||||
:execute => 'set',
|
||||
|
@ -138,6 +139,10 @@ class AgentTicketActionLevel5Test < TestCase
|
|||
:execute => 'sendkey',
|
||||
:value => [:arrow_down]
|
||||
},
|
||||
{
|
||||
:execute => 'wait',
|
||||
:value => 1,
|
||||
},
|
||||
{
|
||||
:execute => 'click',
|
||||
:css => '.active .shortcut > ul> li > a',
|
||||
|
@ -301,6 +306,11 @@ class AgentTicketActionLevel5Test < TestCase
|
|||
:execute => 'sendkey',
|
||||
:value => [:arrow_down]
|
||||
},
|
||||
{
|
||||
:where => :instance2,
|
||||
:execute => 'wait',
|
||||
:value => 3,
|
||||
},
|
||||
{
|
||||
:where => :instance2,
|
||||
:execute => 'click',
|
||||
|
@ -337,6 +347,11 @@ class AgentTicketActionLevel5Test < TestCase
|
|||
:execute => 'sendkey',
|
||||
:value => [:arrow_down]
|
||||
},
|
||||
{
|
||||
:where => :instance2,
|
||||
:execute => 'wait',
|
||||
:value => 1,
|
||||
},
|
||||
{
|
||||
:where => :instance2,
|
||||
:execute => 'click',
|
||||
|
@ -363,6 +378,11 @@ class AgentTicketActionLevel5Test < TestCase
|
|||
:execute => 'sendkey',
|
||||
:value => [:arrow_down]
|
||||
},
|
||||
{
|
||||
:where => :instance2,
|
||||
:execute => 'wait',
|
||||
:value => 10,
|
||||
},
|
||||
{
|
||||
:where => :instance2,
|
||||
:execute => 'click',
|
||||
|
@ -447,6 +467,11 @@ class AgentTicketActionLevel5Test < TestCase
|
|||
:execute => 'sendkey',
|
||||
:value => [:arrow_down]
|
||||
},
|
||||
{
|
||||
:where => :instance2,
|
||||
:execute => 'wait',
|
||||
:value => 1,
|
||||
},
|
||||
{
|
||||
:where => :instance2,
|
||||
:execute => 'click',
|
||||
|
@ -503,6 +528,11 @@ class AgentTicketActionLevel5Test < TestCase
|
|||
:execute => 'sendkey',
|
||||
:value => [:arrow_down]
|
||||
},
|
||||
{
|
||||
:where => :instance2,
|
||||
:execute => 'wait',
|
||||
:value => 1,
|
||||
},
|
||||
{
|
||||
:where => :instance2,
|
||||
:execute => 'click',
|
||||
|
@ -519,9 +549,8 @@ class AgentTicketActionLevel5Test < TestCase
|
|||
:css => '.modal-content .js-submit',
|
||||
},
|
||||
{
|
||||
:where => :instance2,
|
||||
:execute => 'wait',
|
||||
:value => 4,
|
||||
:execute => 'watch_for_disappear',
|
||||
:area => '.modal',
|
||||
},
|
||||
{
|
||||
:where => :instance2,
|
||||
|
@ -545,6 +574,11 @@ class AgentTicketActionLevel5Test < TestCase
|
|||
:execute => 'sendkey',
|
||||
:value => [:arrow_down]
|
||||
},
|
||||
{
|
||||
:where => :instance2,
|
||||
:execute => 'wait',
|
||||
:value => 1,
|
||||
},
|
||||
{
|
||||
:where => :instance2,
|
||||
:execute => 'click',
|
||||
|
|
Loading…
Reference in a new issue