Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
linphone-desktop
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
linphone-desktop
Commits
c7319281
Commit
c7319281
authored
Nov 10, 2016
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(Utils): sort functions declarations
parent
ba804f5d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
81 additions
and
75 deletions
+81
-75
InvertedMouseArea.qml
tests/ui/modules/Common/InvertedMouseArea.qml
+7
-1
utils.js
tests/ui/scripts/Utils/utils.js
+74
-74
No files found.
tests/ui/modules/Common/InvertedMouseArea.qml
View file @
c7319281
...
...
@@ -35,6 +35,9 @@ Item {
}
_mouseArea
.
parent
=
parent
// Must be true if a fake parent is used and if `mouseArea`
// is not in the same window that `item`.
_mouseAlwaysOutside
=
_mouseArea
.
parent
!==
Utils
.
getTopParent
(
item
)
}
...
...
@@ -74,7 +77,10 @@ Item {
positionEvent
.
accepted
=
false
// Click is outside or not.
if
(
_mouseAlwaysOutside
||
!
Utils
.
pointIsInItem
(
this
,
item
,
positionEvent
))
{
if
(
_mouseAlwaysOutside
||
!
Utils
.
pointIsInItem
(
this
,
item
,
positionEvent
)
)
{
if
(
_timeout
!=
null
)
{
// Remove existing timeout to avoid the creation of
// many children.
...
...
tests/ui/scripts/Utils/utils.js
View file @
c7319281
...
...
@@ -212,13 +212,28 @@ function _computeOptimizedCb (func, context) {
})
:
func
}
// -------------------------------------------------------------------
function
_indexFinder
(
array
,
cb
,
context
)
{
var
length
=
array
.
length
// Convert a snake_case string to a lowerCamelCase string.
function
snakeToCamel
(
s
)
{
return
s
.
replace
(
/
(\_\w)
/g
,
function
(
matches
)
{
return
matches
[
1
].
toUpperCase
()
})
for
(
var
i
=
0
;
i
<
length
;
i
++
)
{
if
(
cb
(
array
[
index
],
index
,
array
))
{
return
i
}
}
return
-
1
}
function
_keyFinder
(
obj
,
cb
,
context
)
{
var
keys
=
Object
.
keys
(
obj
)
var
length
=
keys
.
length
for
(
var
i
=
0
;
i
<
length
;
i
++
)
{
var
key
=
keys
[
i
]
if
(
cb
(
obj
[
key
],
key
,
obj
))
{
return
key
}
}
}
// -------------------------------------------------------------------
...
...
@@ -232,49 +247,34 @@ function assert (condition, message) {
// -------------------------------------------------------------------
// Returns the extension of a filename.
function
getExtension
(
str
)
{
var
index
=
str
.
lastIndexOf
(
'
.
'
)
if
(
index
===
-
1
)
{
return
''
// Returns an array from a `object` or `array` argument.
function
ensureArray
(
obj
)
{
if
(
isArray
(
obj
))
{
return
obj
}
return
str
.
slice
(
index
+
1
)
}
// -------------------------------------------------------------------
// Test if a string starts by a given string.
function
startsWith
(
str
,
searchStr
)
{
return
str
.
slice
(
0
,
searchStr
.
length
)
===
searchStr
}
// -------------------------------------------------------------------
// Invoke a `cb` function with each value of the interval: `[0, n[`.
// Return a mapped array created with the returned values of `cb`.
function
times
(
n
,
cb
,
context
)
{
var
arr
=
Array
(
Math
.
max
(
0
,
n
))
cb
=
_computeOptimizedCb
(
cb
,
context
,
1
)
var
keys
=
Object
.
keys
(
obj
)
var
length
=
keys
.
length
var
values
=
Array
(
length
)
for
(
var
i
=
0
;
i
<
n
;
i
++
)
{
arr
[
i
]
=
cb
(
i
)
for
(
var
i
=
0
;
i
<
length
;
i
++
)
{
values
[
i
]
=
obj
[
keys
[
i
]]
}
return
arr
return
values
}
// -------------------------------------------------------------------
function
isArray
(
array
)
{
return
(
array
instanceof
Array
)
}
// Get the first matching value in a array or object.
// The matching value is obtained if `cb` returns true.
function
find
(
obj
,
cb
,
context
)
{
cb
=
_computeOptimizedCb
(
cb
,
context
)
// -------------------------------------------------------------------
var
finder
=
isArray
(
obj
)
?
_indexFinder
:
_keyFinder
var
key
=
finder
(
obj
,
cb
,
context
)
function
isString
(
string
)
{
return
typeof
string
===
'
string
'
||
string
instanceof
String
return
key
!=
null
&&
key
!==
-
1
?
obj
[
key
]
:
null
}
// -------------------------------------------------------------------
...
...
@@ -319,21 +319,15 @@ function genRandomNumberBetweenIntervals (intervals) {
// -------------------------------------------------------------------
// Returns an array from a `object` or `array` argument.
function
ensureArray
(
obj
)
{
if
(
isArray
(
obj
))
{
return
obj
}
var
keys
=
Object
.
keys
(
obj
)
var
length
=
keys
.
length
var
values
=
Array
(
length
)
// Returns the extension of a filename.
function
getExtension
(
str
)
{
var
index
=
str
.
lastIndexOf
(
'
.
'
)
for
(
var
i
=
0
;
i
<
length
;
i
++
)
{
values
[
i
]
=
obj
[
keys
[
i
]]
if
(
index
===
-
1
)
{
return
''
}
return
values
return
str
.
slice
(
index
+
1
)
}
// -------------------------------------------------------------------
...
...
@@ -359,37 +353,43 @@ function includes (obj, value, startIndex) {
// -------------------------------------------------------------------
function
_indexFinder
(
array
,
cb
,
context
)
{
var
length
=
array
.
length
function
isArray
(
array
)
{
return
(
array
instanceof
Array
)
}
for
(
var
i
=
0
;
i
<
length
;
i
++
)
{
if
(
cb
(
array
[
index
],
index
,
array
))
{
return
i
}
}
// -------------------------------------------------------------------
return
-
1
function
isString
(
string
)
{
return
typeof
string
===
'
string
'
||
string
instanceof
String
}
function
_keyFinder
(
obj
,
cb
,
context
)
{
var
keys
=
Object
.
keys
(
obj
)
var
length
=
keys
.
length
// -------------------------------------------------------------------
for
(
var
i
=
0
;
i
<
length
;
i
++
)
{
var
key
=
keys
[
i
]
if
(
cb
(
obj
[
key
],
key
,
obj
))
{
return
key
}
}
// Convert a snake_case string to a lowerCamelCase string.
function
snakeToCamel
(
s
)
{
return
s
.
replace
(
/
(\_\w)
/g
,
function
(
matches
)
{
return
matches
[
1
].
toUpperCase
()
})
}
// Get the first matching value in a array or object.
// The matching value is obtained if `cb` returns true.
function
find
(
obj
,
cb
,
context
)
{
cb
=
_computeOptimizedCb
(
cb
,
context
)
// -------------------------------------------------------------------
var
finder
=
isArray
(
obj
)
?
_indexFinder
:
_keyFinder
var
key
=
finder
(
obj
,
cb
,
context
)
// Test if a string starts by a given string.
function
startsWith
(
str
,
searchStr
)
{
return
str
.
slice
(
0
,
searchStr
.
length
)
===
searchStr
}
return
key
!=
null
&&
key
!==
-
1
?
obj
[
key
]
:
null
// -------------------------------------------------------------------
// Invoke a `cb` function with each value of the interval: `[0, n[`.
// Return a mapped array created with the returned values of `cb`.
function
times
(
n
,
cb
,
context
)
{
var
arr
=
Array
(
Math
.
max
(
0
,
n
))
cb
=
_computeOptimizedCb
(
cb
,
context
,
1
)
for
(
var
i
=
0
;
i
<
n
;
i
++
)
{
arr
[
i
]
=
cb
(
i
)
}
return
arr
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment