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
5bf3a898
Commit
5bf3a898
authored
Mar 19, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove wall from basic notes logic
parent
1752c6dc
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
3 additions
and
183 deletions
+3
-183
app/assets/javascripts/notes.js
app/assets/javascripts/notes.js
+0
-141
app/contexts/notes/load_context.rb
app/contexts/notes/load_context.rb
+0
-13
app/views/notes/_reversed_notes_with_form.html.haml
app/views/notes/_reversed_notes_with_form.html.haml
+0
-12
app/views/notes/create.js.haml
app/views/notes/create.js.haml
+2
-5
app/views/notes/index.js.haml
app/views/notes/index.js.haml
+1
-12
No files found.
app/assets/javascripts/notes.js
View file @
5bf3a898
...
...
@@ -4,31 +4,16 @@ var NoteList = {
target_params
:
null
,
target_id
:
0
,
target_type
:
null
,
top_id
:
0
,
bottom_id
:
0
,
loading_more_disabled
:
false
,
reversed
:
false
,
init
:
function
(
tid
,
tt
,
path
)
{
NoteList
.
notes_path
=
path
+
"
.js
"
;
NoteList
.
target_id
=
tid
;
NoteList
.
target_type
=
tt
;
NoteList
.
reversed
=
$
(
"
#notes-list
"
).
is
(
"
.reversed
"
);
NoteList
.
target_params
=
"
target_type=
"
+
NoteList
.
target_type
+
"
&target_id=
"
+
NoteList
.
target_id
;
NoteList
.
setupMainTargetNoteForm
();
if
(
NoteList
.
reversed
)
{
var
form
=
$
(
"
.js-main-target-form
"
);
form
.
find
(
"
.note-form-actions
"
).
hide
();
var
textarea
=
form
.
find
(
"
.js-note-text
"
);
textarea
.
css
(
"
height
"
,
"
40px
"
);
textarea
.
on
(
"
focus
"
,
function
(){
textarea
.
css
(
"
height
"
,
"
80px
"
);
form
.
find
(
"
.note-form-actions
"
).
show
();
});
}
// get initial set of notes
NoteList
.
getContent
();
...
...
@@ -344,126 +329,9 @@ var NoteList = {
* Replaces the content of #notes-list with the given html.
*/
setContent
:
function
(
newNoteIds
,
html
)
{
NoteList
.
top_id
=
newNoteIds
.
first
();
NoteList
.
bottom_id
=
newNoteIds
.
last
();
$
(
"
#notes-list
"
).
html
(
html
);
// for the wall
if
(
NoteList
.
reversed
)
{
// init infinite scrolling
NoteList
.
initLoadMore
();
// init getting new notes
NoteList
.
initRefreshNew
();
}
},
/**
* Handle loading more notes when scrolling to the bottom of the page.
* The id of the last note in the list is in NoteList.bottom_id.
*
* Set up refreshing only new notes after all notes have been loaded.
*/
/**
* Initializes loading more notes when scrolling to the bottom of the page.
*/
initLoadMore
:
function
()
{
$
(
document
).
endlessScroll
({
bottomPixels
:
400
,
fireDelay
:
1000
,
fireOnce
:
true
,
ceaseFire
:
function
()
{
return
NoteList
.
loading_more_disabled
;
},
callback
:
function
(
i
)
{
NoteList
.
getMore
();
}
});
},
/**
* Gets an additional set of notes.
*/
getMore
:
function
()
{
// only load more notes if there are no "new" notes
$
(
'
.loading
'
).
show
();
$
.
ajax
({
url
:
NoteList
.
notes_path
,
data
:
NoteList
.
target_params
+
"
&loading_more=1&
"
+
(
NoteList
.
reversed
?
"
before_id
"
:
"
after_id
"
)
+
"
=
"
+
NoteList
.
bottom_id
,
complete
:
function
(){
$
(
'
.js-notes-busy
'
).
removeClass
(
"
loading
"
)},
beforeSend
:
function
()
{
$
(
'
.js-notes-busy
'
).
addClass
(
"
loading
"
)
},
dataType
:
"
script
"
});
},
/**
* Called in response to getMore().
* Append notes to #notes-list.
*/
appendMoreNotes
:
function
(
newNoteIds
,
html
)
{
var
lastNewNoteId
=
newNoteIds
.
last
();
if
(
lastNewNoteId
!=
NoteList
.
bottom_id
)
{
NoteList
.
bottom_id
=
lastNewNoteId
;
$
(
"
#notes-list
"
).
append
(
html
);
}
},
/**
* Called in response to getMore().
* Disables loading more notes when scrolling to the bottom of the page.
*/
finishedLoadingMore
:
function
()
{
NoteList
.
loading_more_disabled
=
true
;
// make sure we are up to date
NoteList
.
updateVotes
();
},
/**
* Handle refreshing and adding of new notes.
*
* New notes are all notes that are created after the site has been loaded.
* The "old" notes are in #notes-list the "new" ones will be in #new-notes-list.
* The id of the last "old" note is in NoteList.bottom_id.
*/
/**
* Initializes getting new notes every n seconds.
*
* Note: only used on wall.
*/
initRefreshNew
:
function
()
{
setInterval
(
"
NoteList.getNew()
"
,
10000
);
},
/**
* Gets the new set of notes.
*
* Note: only used on wall.
*/
getNew
:
function
()
{
$
.
ajax
({
url
:
NoteList
.
notes_path
,
data
:
NoteList
.
target_params
+
"
&loading_new=1&after_id=
"
+
(
NoteList
.
reversed
?
NoteList
.
top_id
:
NoteList
.
bottom_id
),
dataType
:
"
script
"
});
},
/**
* Called in response to getNew().
* Replaces the content of #new-notes-list with the given html.
*
* Note: only used on wall.
*/
replaceNewNotes
:
function
(
newNoteIds
,
html
)
{
$
(
"
#new-notes-list
"
).
html
(
html
);
NoteList
.
updateVotes
();
},
/**
* Adds a single common note to #notes-list.
...
...
@@ -497,15 +365,6 @@ var NoteList = {
$
.
proxy
(
NoteList
.
removeDiscussionNoteForm
,
form
).
call
();
},
/**
* Adds a single wall note to #new-notes-list.
*
* Note: only used on wall.
*/
appendNewWallNote
:
function
(
id
,
html
)
{
$
(
"
#new-notes-list
"
).
prepend
(
html
);
},
/**
* Called in response the main target form has been successfully submitted.
*
...
...
app/contexts/notes/load_context.rb
View file @
5bf3a898
...
...
@@ -3,8 +3,6 @@ module Notes
def
execute
target_type
=
params
[
:target_type
]
target_id
=
params
[
:target_id
]
after_id
=
params
[
:after_id
]
before_id
=
params
[
:before_id
]
@notes
=
case
target_type
...
...
@@ -16,17 +14,6 @@ module Notes
project
.
merge_requests
.
find
(
target_id
).
mr_and_commit_notes
.
inc_author
.
fresh
when
"snippet"
project
.
snippets
.
find
(
target_id
).
notes
.
fresh
when
"wall"
# this is the only case, where the order is DESC
project
.
notes
.
common
.
inc_author_project
.
order
(
"created_at DESC, id DESC"
).
limit
(
50
)
end
@notes
=
if
after_id
@notes
.
where
(
"id > ?"
,
after_id
)
elsif
before_id
@notes
.
where
(
"id < ?"
,
before_id
)
else
@notes
end
end
end
...
...
app/views/notes/_reversed_notes_with_form.html.haml
deleted
100644 → 0
View file @
1752c6dc
.js-main-target-form
-
if
can?
current_user
,
:write_note
,
@project
=
render
"notes/form"
%ul
#new-notes-list
.reversed.notes
%ul
#notes-list
.reversed.notes
.notes-busy.js-notes-busy
:javascript
$
(
function
(){
NoteList
.
init
(
"
#{
@target_id
}
"
,
"
#{
@target_type
}
"
,
"
#{
project_notes_path
(
@project
)
}
"
);
});
app/views/notes/create.js.haml
View file @
5bf3a898
...
...
@@ -2,9 +2,6 @@
var noteHtml = "
#{
escape_javascript
(
render
"notes/note"
,
note:
@note
)
}
";
-
if
note_for_main_target?
(
@note
)
-
if
@note
.
for_wall?
NoteList.appendNewWallNote(
#{
@note
.
id
}
, noteHtml);
-
else
NoteList.appendNewNote(
#{
@note
.
id
}
, noteHtml);
-
else
:plain
...
...
app/views/notes/index.js.haml
View file @
5bf3a898
-
unless
@notes
.
blank?
var notesHtml = "
#{
escape_javascript
(
render
'notes/notes'
)
}
";
-
new_note_ids
=
@notes
.
map
(
&
:id
)
-
if
loading_more_notes?
NoteList.appendMoreNotes(
#{
new_note_ids
}
, notesHtml);
-
elsif
loading_new_notes?
NoteList.replaceNewNotes(
#{
new_note_ids
}
, notesHtml);
-
else
NoteList.setContent(
#{
new_note_ids
}
, notesHtml);
-
else
-
if
loading_more_notes?
NoteList.finishedLoadingMore();
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