Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
P
pm-tools
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Yaroslav Lushnikov
pm-tools
Commits
ef02ce0f
Commit
ef02ce0f
authored
Apr 02, 2020
by
Yaroslav Lushnikov
🦆
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Coffee :)
parent
d22eed97
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
82 additions
and
10 deletions
+82
-10
search.js
extension/scripts/pm/search.js
+66
-3
search.css
extension/styles/i20/search.css
+16
-7
No files found.
extension/scripts/pm/search.js
View file @
ef02ce0f
...
...
@@ -26,7 +26,15 @@
event
.
preventDefault
();
}
}
});
})
.
bind
(
'click'
,
function
(
event
)
{
if
(
!
search
.
wrapper
.
hasClass
(
'hide-form'
))
{
if
(
$
(
event
.
target
).
closest
(
'.pm-tools-search-wrapper'
).
length
===
0
)
{
search
.
closeForm
();
}
}
});
search
.
input
.
on
(
'keyup'
,
function
()
{
let
$this
=
$
(
this
);
if
(
search
.
timers
.
change
)
{
...
...
@@ -37,6 +45,14 @@
search
.
searchValue
(
$this
.
val
());
},
100
);
});
search
.
wrapper
.
on
(
'keydown'
,
function
(
event
)
{
let
keyCode
=
event
.
keyCode
;
if
(
keyCode
===
40
||
keyCode
===
38
)
{
search
.
navigate
(
keyCode
===
40
?
'down'
:
'up'
);
event
.
preventDefault
();
return
false
;
}
});
};
search
.
showForm
=
function
()
{
...
...
@@ -50,7 +66,8 @@
};
search
.
searchValue
=
function
(
searchText
)
{
if
(
searchText
!==
''
)
{
if
(
searchText
!==
''
&&
searchText
!==
search
.
lastSearch
)
{
search
.
lastSearch
=
searchText
;
searchText
=
searchText
.
replace
(
' '
,
'+'
);
let
key
=
search
.
getApiKey
();
...
...
@@ -62,6 +79,10 @@
beforeSend
:
function
(
xhr
){
xhr
.
setRequestHeader
(
'X-Redmine-API-Key'
,
key
);},
success
:
function
(
data
)
{
if
(
data
&&
data
.
total_count
)
{
if
(
search
.
currentElement
)
{
search
.
currentElement
=
undefined
;
}
search
.
found
.
html
(
''
);
data
.
issues
.
forEach
(
function
(
element
)
{
let
issue
=
$
(
'<li><a href="https://pm.i20.biz/issues/'
+
element
.
id
+
'">'
...
...
@@ -75,7 +96,10 @@
}
},
async
:
true
})
});
}
else
{
search
.
found
.
append
(
'Введите API ключ в настройках экстеншена.'
)
}
}
}
...
...
@@ -87,6 +111,45 @@
return
search
.
apiKey
;
}
search
.
navigate
=
function
(
dest
)
{
if
(
typeof
search
.
currentElement
===
'undefined'
)
{
search
.
select
(
0
,
search
.
found
.
find
(
'li:first'
));
}
let
nextDelta
=
0
;
let
allFound
=
search
.
found
.
find
(
'li'
);
let
foundCount
=
allFound
.
length
-
1
;
if
(
dest
===
'up'
)
{
if
(
search
.
currentElement
.
delta
===
0
)
{
nextDelta
=
foundCount
;
}
else
{
nextDelta
=
search
.
currentElement
.
delta
-
1
;
}
}
else
if
(
dest
===
'down'
)
{
if
(
search
.
currentElement
.
delta
===
foundCount
)
{
nextDelta
=
0
;
}
else
{
nextDelta
=
search
.
currentElement
.
delta
+
1
;
}
search
.
select
(
nextDelta
,
$
(
allFound
.
eq
(
nextDelta
)));
}
search
.
select
(
nextDelta
,
$
(
allFound
.
eq
(
nextDelta
)));
}
search
.
select
=
function
(
delta
,
element
)
{
if
(
element
.
length
)
{
search
.
found
.
find
(
'li'
).
removeClass
(
'active'
);
search
.
currentElement
=
{
element
:
element
,
delta
:
delta
};
search
.
currentElement
.
element
.
addClass
(
'active'
).
find
(
'a'
).
focus
();
}
}
search
.
init
();
})(
jQuery
);
extension/styles/i20/search.css
View file @
ef02ce0f
.pm-tools-search-wrapper
{
width
:
100%
;
position
:
absolute
;
position
:
fixed
;
top
:
20%
;
z-index
:
500
;
display
:
flex
;
...
...
@@ -8,10 +8,12 @@
}
.pm-tools-search-wrapper
.search-form
{
background-color
:
#
cccccc
;
padding
-bottom
:
15
px
;
background-color
:
#
fff
;
padding
:
7
px
;
border-radius
:
7px
;
pointer-events
:
auto
;
border
:
1px
solid
#505050
;
font-size
:
15px
;
}
.pm-tools-search-wrapper.hide-form
{
...
...
@@ -21,16 +23,23 @@
.pm-tools-search-wrapper
ul
{
list-style
:
none
;
width
:
400px
;
padding
:
5px
;
padding
:
2px
;
margin
:
0
;
overflow
:
hidden
;
}
.pm-tools-search-wrapper
div
.found-issue
:hover
{
background-color
:
rgb
(
142
,
142
,
142
);
.pm-tools-search-wrapper
ul
li
:hover
,
.pm-tools-search-wrapper
ul
li
.active
{
background-color
:
#feffdd
;
}
.pm-tools-search-wrapper
input
{
width
:
400px
;
height
:
30px
;
font-size
:
x-large
;
}
\ No newline at end of file
}
.pm-tools-search-wrapper
ul
li
{
font-size
:
15px
;
border-bottom
:
1px
solid
#f5f5f5
;
}
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