Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
bd60a4ed
Commit
bd60a4ed
authored
Oct 30, 2012
by
Riyad Preukschas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make notes JS know which notes are new in a request
parent
ae067ee3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
22 deletions
+31
-22
app/assets/javascripts/extensions/array.js
app/assets/javascripts/extensions/array.js
+7
-0
app/assets/javascripts/notes.js
app/assets/javascripts/notes.js
+20
-19
app/views/notes/index.js.haml
app/views/notes/index.js.haml
+4
-3
No files found.
app/assets/javascripts/extensions/array.js
0 → 100644
View file @
bd60a4ed
Array
.
prototype
.
first
=
function
()
{
return
this
[
0
];
}
Array
.
prototype
.
last
=
function
()
{
return
this
[
this
.
length
-
1
];
}
\ No newline at end of file
app/assets/javascripts/notes.js
View file @
bd60a4ed
...
@@ -89,12 +89,12 @@ var NoteList = {
...
@@ -89,12 +89,12 @@ var NoteList = {
getContent
:
getContent
:
function
()
{
function
()
{
$
.
ajax
({
$
.
ajax
({
type
:
"
GET
"
,
url
:
this
.
notes_path
,
url
:
this
.
notes_path
,
data
:
this
.
target_params
,
data
:
this
.
target_params
,
complete
:
function
(){
$
(
'
.notes-status
'
).
removeClass
(
"
loading
"
)}
,
complete
:
function
(){
$
(
'
.notes-status
'
).
removeClass
(
"
loading
"
)
},
beforeSend
:
function
()
{
$
(
'
.notes-status
'
).
addClass
(
"
loading
"
)
},
beforeSend
:
function
()
{
$
(
'
.notes-status
'
).
addClass
(
"
loading
"
)
},
dataType
:
"
script
"
dataType
:
"
script
"
});
});
},
},
/**
/**
...
@@ -102,9 +102,9 @@ var NoteList = {
...
@@ -102,9 +102,9 @@ var NoteList = {
* Replaces the content of #notes-list with the given html.
* Replaces the content of #notes-list with the given html.
*/
*/
setContent
:
setContent
:
function
(
first_id
,
last_id
,
html
)
{
function
(
newNoteIds
,
html
)
{
this
.
top_id
=
first_id
;
this
.
top_id
=
newNoteIds
.
first
()
;
this
.
bottom_id
=
last_id
;
this
.
bottom_id
=
newNoteIds
.
last
()
;
$
(
"
#notes-list
"
).
html
(
html
);
$
(
"
#notes-list
"
).
html
(
html
);
// init infinite scrolling
// init infinite scrolling
...
@@ -151,12 +151,12 @@ var NoteList = {
...
@@ -151,12 +151,12 @@ var NoteList = {
// only load more notes if there are no "new" notes
// only load more notes if there are no "new" notes
$
(
'
.loading
'
).
show
();
$
(
'
.loading
'
).
show
();
$
.
ajax
({
$
.
ajax
({
type
:
"
GET
"
,
url
:
this
.
notes_path
,
url
:
this
.
notes_path
,
data
:
this
.
target_params
+
"
&loading_more=1&
"
+
(
this
.
reversed
?
"
before_id
"
:
"
after_id
"
)
+
"
=
"
+
this
.
bottom_id
,
data
:
this
.
target_params
+
"
&loading_more=1&
"
+
(
this
.
reversed
?
"
before_id
"
:
"
after_id
"
)
+
"
=
"
+
this
.
bottom_id
,
complete
:
function
(){
$
(
'
.notes-status
'
).
removeClass
(
"
loading
"
)},
complete
:
function
(){
$
(
'
.notes-status
'
).
removeClass
(
"
loading
"
)},
beforeSend
:
function
()
{
$
(
'
.notes-status
'
).
addClass
(
"
loading
"
)
},
beforeSend
:
function
()
{
$
(
'
.notes-status
'
).
addClass
(
"
loading
"
)
},
dataType
:
"
script
"
});
dataType
:
"
script
"
});
},
},
/**
/**
...
@@ -164,9 +164,10 @@ var NoteList = {
...
@@ -164,9 +164,10 @@ var NoteList = {
* Append notes to #notes-list.
* Append notes to #notes-list.
*/
*/
appendMoreNotes
:
appendMoreNotes
:
function
(
id
,
html
)
{
function
(
newNoteIds
,
html
)
{
if
(
id
!=
this
.
bottom_id
)
{
var
lastNewNoteId
=
newNoteIds
.
last
();
this
.
bottom_id
=
id
;
if
(
lastNewNoteId
!=
this
.
bottom_id
)
{
this
.
bottom_id
=
lastNewNoteId
;
$
(
"
#notes-list
"
).
append
(
html
);
$
(
"
#notes-list
"
).
append
(
html
);
}
}
},
},
...
@@ -212,10 +213,10 @@ var NoteList = {
...
@@ -212,10 +213,10 @@ var NoteList = {
getNew
:
getNew
:
function
()
{
function
()
{
$
.
ajax
({
$
.
ajax
({
type
:
"
GET
"
,
url
:
this
.
notes_path
,
url
:
this
.
notes_path
,
data
:
this
.
target_params
+
"
&loading_new=1&after_id=
"
+
(
this
.
reversed
?
this
.
top_id
:
this
.
bottom_id
)
,
data
:
this
.
target_params
+
"
&loading_new=1&after_id=
"
+
(
this
.
reversed
?
this
.
top_id
:
this
.
bottom_id
),
dataType
:
"
script
"
dataType
:
"
script
"
});
});
},
},
/**
/**
...
@@ -223,7 +224,7 @@ var NoteList = {
...
@@ -223,7 +224,7 @@ var NoteList = {
* Replaces the content of #new-notes-list with the given html.
* Replaces the content of #new-notes-list with the given html.
*/
*/
replaceNewNotes
:
replaceNewNotes
:
function
(
html
)
{
function
(
newNoteIds
,
html
)
{
$
(
"
#new-notes-list
"
).
html
(
html
);
$
(
"
#new-notes-list
"
).
html
(
html
);
this
.
updateVotes
();
this
.
updateVotes
();
},
},
...
...
app/views/notes/index.js.haml
View file @
bd60a4ed
-
unless
@notes
.
blank?
-
unless
@notes
.
blank?
-
new_note_ids
=
@notes
.
map
(
&
:id
)
-
if
loading_more_notes?
-
if
loading_more_notes?
:plain
:plain
NoteList.appendMoreNotes(
#{
@notes
.
last
.
id
}
, "
#{
escape_javascript
(
render
'notes/notes'
)
}
");
NoteList.appendMoreNotes(
#{
new_note_ids
}
, "
#{
escape_javascript
(
render
'notes/notes'
)
}
");
-
elsif
loading_new_notes?
-
elsif
loading_new_notes?
:plain
:plain
NoteList.replaceNewNotes("
#{
escape_javascript
(
render
'notes/notes'
)
}
");
NoteList.replaceNewNotes(
#{
new_note_ids
}
,
"
#{
escape_javascript
(
render
'notes/notes'
)
}
");
-
else
-
else
:plain
:plain
NoteList.setContent(
#{
@notes
.
first
.
id
}
,
#{
@notes
.
last
.
id
}
, "
#{
escape_javascript
(
render
'notes/notes'
)
}
");
NoteList.setContent(
#{
new_note_ids
}
, "
#{
escape_javascript
(
render
'notes/notes'
)
}
");
-
else
-
else
-
if
loading_more_notes?
-
if
loading_more_notes?
...
...
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