Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cleaning-portalmec
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Richard Fernando Heise Ferreira
cleaning-portalmec
Commits
4d2d3904
Commit
4d2d3904
authored
9 years ago
by
Mateus Rambo Strey
Browse files
Options
Downloads
Patches
Plain Diff
add remove pagination view to see more
parent
d34b8cf5
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/assets/javascripts/application/search.js
+49
-11
49 additions, 11 deletions
app/assets/javascripts/application/search.js
app/views/search/_fetch.html.erb
+1
-1
1 addition, 1 deletion
app/views/search/_fetch.html.erb
with
50 additions
and
12 deletions
app/assets/javascripts/application/search.js
+
49
−
11
View file @
4d2d3904
...
...
@@ -3,12 +3,17 @@ var search = function() {
var
intervalId
=
0
;
var
params
=
{};
//// initialize search parameters
params
.
query
=
""
;
params
.
order
=
""
;
params
.
subject
=
[];
params
.
type
=
[];
params
.
school_year
=
[];
params
.
year
=
""
;
resetParam
();
function
resetParam
()
{
params
.
query
=
""
;
params
.
page
=
1
;
params
.
order
=
""
;
params
.
subject
=
[];
params
.
type
=
[];
params
.
school_year
=
[];
params
.
year
=
""
;
}
$
(
document
).
ready
(
function
()
{
checkUrl
();
...
...
@@ -49,6 +54,7 @@ var search = function() {
function
watchSearchInput
()
{
$
(
'
.search-input form
'
).
on
(
'
submit
'
,
function
(
event
)
{
event
.
preventDefault
();
resetParam
();
params
.
query
=
$
(
'
input[name="query"]
'
,
this
).
val
();
fetch
();
});
...
...
@@ -56,11 +62,19 @@ var search = function() {
function
watchOrder
()
{
$
(
'
select[name="order"]
'
).
on
(
'
change
'
,
function
(
event
)
{
params
.
order
=
$
(
this
).
val
()
params
.
order
=
$
(
this
).
val
()
;
fetch
();
});
}
function
watchMoreResults
()
{
$
(
'
.search-more
'
).
on
(
'
click
'
,
function
(
event
)
{
event
.
preventDefault
();
params
.
page
+=
1
;
fetch
(
true
);
});
}
function
watchFilters
()
{
$
(
'
.search-link
'
).
on
(
'
change
'
,
function
(
e
)
{
// cancel previous function call
...
...
@@ -135,22 +149,46 @@ var search = function() {
}
// get objects html to embed
function
fetch
()
{
function
fetch
(
append
)
{
// append result - see more
if
(
append
===
undefined
||
append
===
false
)
{
append
=
false
;
// reset pagination
params
.
page
=
1
;
}
// change url with new parameters
var
url
=
createUrlFromParameters
();
history
.
pushState
(
state
,
url
,
url
);
$
.
ajax
({
url
:
"
/search/fetch
"
,
type
:
'
get
'
,
data
:
params
,
beforeSend
:
function
()
{
$
(
"
#search-fetch
"
).
empty
();
$
(
"
#search-fetch
"
).
append
(
'
<br><br><div style="text-align:center;"><div class="pong-loader">Carregando...</div></div>
'
);
if
(
append
)
{
$
(
'
.search-more
'
).
remove
();
}
else
{
$
(
"
#search-fetch
"
).
empty
();
}
$
(
"
#search-fetch
"
).
append
(
'
<div class="search-loading" style="text-align:center;"><br><div class="pong-loader">Carregando...</div></div>
'
);
}
})
.
done
(
function
(
data
)
{
$
(
"
#search-fetch
"
).
empty
();
if
(
append
)
{
$
(
'
.search-more, .search-loading
'
).
remove
();
}
else
{
$
(
"
#search-fetch
"
).
empty
();
}
$
(
"
#search-fetch
"
).
append
(
data
);
watchMoreResults
();
});
}
};
...
...
This diff is collapsed.
Click to expand it.
app/views/search/_fetch.html.erb
+
1
−
1
View file @
4d2d3904
<%=
render
@objects
,
orientation:
"horizontal"
%>
<
%=
paginate
@result
%
>
<
a
href=
"javascript:void(0);"
class=
"btn btn-primary search-more"
>
Ver mais
</a
>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment