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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
iv
gitlab-ce
Commits
1e689bfb
Commit
1e689bfb
authored
12 years ago
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed notes logic
parent
f0f14c8e
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
108 additions
and
78 deletions
+108
-78
app/assets/javascripts/application.js
app/assets/javascripts/application.js
+3
-20
app/assets/javascripts/note.js
app/assets/javascripts/note.js
+93
-32
app/assets/stylesheets/notes.scss
app/assets/stylesheets/notes.scss
+6
-1
app/controllers/notes_controller.rb
app/controllers/notes_controller.rb
+1
-1
app/views/notes/_load.js.haml
app/views/notes/_load.js.haml
+3
-7
app/views/notes/_notes.html.haml
app/views/notes/_notes.html.haml
+2
-17
No files found.
app/assets/javascripts/application.js
View file @
1e689bfb
...
@@ -23,9 +23,6 @@ $(document).ready(function(){
...
@@ -23,9 +23,6 @@ $(document).ready(function(){
$
(
this
).
select
();
$
(
this
).
select
();
});
});
$
(
'
select#branch
'
).
selectmenu
({
style
:
'
popup
'
,
width
:
200
});
$
(
'
select#tag
'
).
selectmenu
({
style
:
'
popup
'
,
width
:
200
});
$
(
"
.account-box
"
).
mouseenter
(
showMenu
);
$
(
"
.account-box
"
).
mouseenter
(
showMenu
);
$
(
"
.account-box
"
).
mouseleave
(
resetMenu
);
$
(
"
.account-box
"
).
mouseleave
(
resetMenu
);
...
@@ -45,6 +42,9 @@ $(document).ready(function(){
...
@@ -45,6 +42,9 @@ $(document).ready(function(){
}
}
});
});
/**
* Focus search field by pressing 's' key
*/
$
(
document
).
keypress
(
function
(
e
)
{
$
(
document
).
keypress
(
function
(
e
)
{
if
(
$
(
e
.
target
).
is
(
"
:input
"
)
)
return
;
if
(
$
(
e
.
target
).
is
(
"
:input
"
)
)
return
;
switch
(
e
.
which
)
{
switch
(
e
.
which
)
{
...
@@ -52,27 +52,12 @@ $(document).ready(function(){
...
@@ -52,27 +52,12 @@ $(document).ready(function(){
e
.
preventDefault
();
e
.
preventDefault
();
}
}
});
});
});
});
function
focusSearch
()
{
function
focusSearch
()
{
$
(
"
#search
"
).
focus
();
$
(
"
#search
"
).
focus
();
}
}
function
taggifyForm
(){
var
tag_field
=
$
(
'
#tag_field
'
).
tagify
();
tag_field
.
tagify
(
'
inputField
'
).
autocomplete
({
source
:
'
/tags.json
'
});
$
(
'
form
'
).
submit
(
function
()
{
var
tag_field
=
$
(
'
#tag_field
'
)
tag_field
.
val
(
tag_field
.
tagify
(
'
serialize
'
)
);
return
true
;
});
}
function
updatePage
(
data
){
function
updatePage
(
data
){
$
.
ajax
({
type
:
"
GET
"
,
url
:
location
.
href
,
data
:
data
,
dataType
:
"
script
"
});
$
.
ajax
({
type
:
"
GET
"
,
url
:
location
.
href
,
data
:
data
,
dataType
:
"
script
"
});
}
}
...
@@ -84,5 +69,3 @@ function showMenu() {
...
@@ -84,5 +69,3 @@ function showMenu() {
function
resetMenu
()
{
function
resetMenu
()
{
$
(
this
).
removeClass
(
"
hover
"
);
$
(
this
).
removeClass
(
"
hover
"
);
}
}
This diff is collapsed.
Click to expand it.
app/assets/javascripts/note.js
View file @
1e689bfb
...
@@ -13,46 +13,54 @@ init:
...
@@ -13,46 +13,54 @@ init:
this
.
notes_path
=
path
+
"
.js
"
;
this
.
notes_path
=
path
+
"
.js
"
;
this
.
target_id
=
tid
;
this
.
target_id
=
tid
;
this
.
target_type
=
tt
;
this
.
target_type
=
tt
;
this
.
target_params
=
"
&target_type=
"
+
this
.
target_type
+
"
&target_id=
"
+
this
.
target_id
this
.
target_params
=
"
&target_type=
"
+
this
.
target_type
+
"
&target_id=
"
+
this
.
target_id
;
this
.
refresh
();
// get notes
this
.
getContent
();
// get new notes every n seconds
this
.
initRefresh
();
this
.
initRefresh
();
this
.
initLoadMore
();
},
getOld
:
$
(
'
.delete-note
'
).
live
(
'
ajax:success
'
,
function
()
{
function
()
{
$
(
this
).
closest
(
'
li
'
).
fadeOut
();
});
$
(
'
.loading
'
).
show
();
$
.
ajax
({
$
(
"
#new_note
"
).
live
(
"
ajax:before
"
,
function
(){
type
:
"
GET
"
,
$
(
"
#submit_note
"
).
attr
(
"
disabled
"
,
"
disabled
"
);
url
:
this
.
notes_path
,
})
data
:
"
first_id=
"
+
this
.
first_id
+
this
.
target_params
,
complete
:
function
(){
$
(
'
.loading
'
).
hide
()},
$
(
"
#new_note
"
).
live
(
"
ajax:complete
"
,
function
(){
dataType
:
"
script
"
});
$
(
"
#submit_note
"
).
removeAttr
(
"
disabled
"
);
})
$
(
"
#note_note
"
).
live
(
"
click
"
,
function
(){
$
(
this
).
css
(
"
height
"
,
"
100px
"
);
$
(
'
.attach_holder
'
).
show
();
});
},
},
append
:
function
(
id
,
html
)
{
/**
if
(
this
.
first_id
==
id
)
{
* Load new notes to fresh list called 'new_notes_list':
this
.
disable
=
true
;
* - Replace 'new_notes_list' with new list every n seconds
}
else
{
* - Append new notes to this list after submit
this
.
first_id
=
id
;
*/
$
(
"
#notes-list
"
).
append
(
html
);
}
initRefresh
:
function
()
{
// init timer
var
intNew
=
setInterval
(
"
NoteList.getNew()
"
,
10000
);
},
},
replace
:
replace
:
function
(
fid
,
lid
,
html
)
{
function
(
html
)
{
this
.
first_id
=
fid
;
$
(
"
#new_notes_list
"
).
html
(
html
);
this
.
last_id
=
lid
;
$
(
"
#notes-list
"
).
html
(
html
);
this
.
initLoadMore
();
},
},
prepend
:
prepend
:
function
(
id
,
html
)
{
function
(
id
,
html
)
{
if
(
id
!=
this
.
last_id
)
{
if
(
id
!=
this
.
last_id
)
{
this
.
last_id
=
id
;
$
(
"
#new_notes_list
"
).
prepend
(
html
);
$
(
"
#notes-list
"
).
prepend
(
html
);
}
}
},
},
...
@@ -76,13 +84,66 @@ refresh:
...
@@ -76,13 +84,66 @@ refresh:
dataType
:
"
script
"
});
dataType
:
"
script
"
});
},
},
initRefresh
:
/**
* Init load of notes:
* 1. Get content with ajax call
* 2. Set content of notes list with loaded one
*/
getContent
:
function
()
{
$
.
ajax
({
type
:
"
GET
"
,
url
:
this
.
notes_path
,
data
:
"
?
"
+
this
.
target_params
,
dataType
:
"
script
"
});
},
setContent
:
function
(
fid
,
lid
,
html
)
{
this
.
last_id
=
lid
;
this
.
first_id
=
fid
;
$
(
"
#notes-list
"
).
html
(
html
);
// Init infinite scrolling
this
.
initLoadMore
();
},
/**
* Paging for old notes when scroll to bottom:
* 1. Init scroll events with 'initLoadMore'
* 2. Load onlder notes with 'getOld' method
* 3. append old notes to bottom of list with 'append'
*
*/
getOld
:
function
()
{
function
()
{
// init timer
$
(
'
.loading
'
).
show
();
var
intNew
=
setInterval
(
"
NoteList.getNew()
"
,
15000
);
$
.
ajax
({
var
intRefresh
=
setInterval
(
"
NoteList.refresh()
"
,
90000
);
type
:
"
GET
"
,
url
:
this
.
notes_path
,
data
:
"
first_id=
"
+
this
.
first_id
+
this
.
target_params
,
complete
:
function
(){
$
(
'
.status
'
).
removeClass
(
"
loading
"
)},
beforeSend
:
function
()
{
$
(
'
.status
'
).
addClass
(
"
loading
"
)
},
dataType
:
"
script
"
});
},
append
:
function
(
id
,
html
)
{
if
(
this
.
first_id
==
id
)
{
this
.
disable
=
true
;
}
else
{
this
.
first_id
=
id
;
$
(
"
#notes-list
"
).
append
(
html
);
}
},
},
initLoadMore
:
initLoadMore
:
function
()
{
function
()
{
$
(
document
).
endlessScroll
({
$
(
document
).
endlessScroll
({
...
...
This diff is collapsed.
Click to expand it.
app/assets/stylesheets/notes.scss
View file @
1e689bfb
...
@@ -2,13 +2,18 @@
...
@@ -2,13 +2,18 @@
* Notes
* Notes
*
*
*/
*/
#notes-list
{
#notes-list
,
#new_notes_list
{
display
:block
;
display
:block
;
list-style
:none
;
list-style
:none
;
margin
:
0px
;
margin
:
0px
;
padding
:
0px
;
padding
:
0px
;
}
}
#new_notes_list
li
:last-child
{
border-bottom
:
1px
solid
#aaa
;
}
.issue_notes
{
.issue_notes
{
.note_content
{
.note_content
{
float
:left
;
float
:left
;
...
...
This diff is collapsed.
Click to expand it.
app/controllers/notes_controller.rb
View file @
1e689bfb
...
@@ -16,7 +16,7 @@ class NotesController < ApplicationController
...
@@ -16,7 +16,7 @@ class NotesController < ApplicationController
when
"snippet"
when
"snippet"
then
project
.
snippets
.
find
(
params
[
:target_id
]).
notes
then
project
.
snippets
.
find
(
params
[
:target_id
]).
notes
when
"wall"
when
"wall"
then
project
.
common_notes
.
order
(
"created_at DESC"
).
fresh
.
limit
(
6
0
)
then
project
.
common_notes
.
order
(
"created_at DESC"
).
fresh
.
limit
(
1
0
)
when
"issue"
when
"issue"
then
project
.
issues
.
find
(
params
[
:target_id
]).
notes
.
inc_author
.
order
(
"created_at DESC"
).
limit
(
20
)
then
project
.
issues
.
find
(
params
[
:target_id
]).
notes
.
inc_author
.
order
(
"created_at DESC"
).
limit
(
20
)
when
"merge_request"
when
"merge_request"
...
...
This diff is collapsed.
Click to expand it.
app/views/notes/_load.js.haml
View file @
1e689bfb
-
unless
@notes
.
blank?
-
unless
@notes
.
blank?
-
if
params
[
:last_id
]
-
if
params
[
:last_id
]
&&
params
[
:first_id
]
:plain
NoteList.replace(
#{
@notes
.
last
.
id
}
,
#{
@notes
.
first
.
id
}
, "
#{
escape_javascript
(
render
(
:partial
=>
'notes/notes_list'
))
}
");
-
elsif
params
[
:last_id
]
:plain
:plain
NoteList.
prepend(
#{
@notes
.
first
.
id
}
,
"
#{
escape_javascript
(
render
(
:partial
=>
'notes/notes_list'
))
}
");
NoteList.
replace(
"
#{
escape_javascript
(
render
(
:partial
=>
'notes/notes_list'
))
}
");
-
elsif
params
[
:first_id
]
-
elsif
params
[
:first_id
]
:plain
:plain
...
@@ -14,6 +9,7 @@
...
@@ -14,6 +9,7 @@
-
else
-
else
:plain
:plain
NoteList.setContent(
#{
@notes
.
last
.
id
}
,
#{
@notes
.
first
.
id
}
, "
#{
escape_javascript
(
render
(
:partial
=>
'notes/notes_list'
))
}
");
-
else
-
else
-
if
params
[
:first_id
]
-
if
params
[
:first_id
]
...
...
This diff is collapsed.
Click to expand it.
app/views/notes/_notes.html.haml
View file @
1e689bfb
...
@@ -2,27 +2,12 @@
...
@@ -2,27 +2,12 @@
=
render
"notes/form"
=
render
"notes/form"
.clear
.clear
%hr
%hr
%ul
#new_notes_list
%ul
#notes-list
%ul
#notes-list
.
loading
.
status
:javascript
:javascript
$
(
'
.delete-note
'
).
live
(
'
ajax:success
'
,
function
()
{
$
(
this
).
closest
(
'
li
'
).
fadeOut
();
});
$
(
"
#new_note
"
).
live
(
"
ajax:before
"
,
function
(){
$
(
"
#submit_note
"
).
attr
(
"
disabled
"
,
"
disabled
"
);
})
$
(
"
#new_note
"
).
live
(
"
ajax:complete
"
,
function
(){
$
(
"
#submit_note
"
).
removeAttr
(
"
disabled
"
);
})
$
(
function
(){
$
(
function
(){
$
(
"
#note_note
"
).
live
(
"
click
"
,
function
(){
$
(
this
).
css
(
"
height
"
,
"
100px
"
);
$
(
'
.attach_holder
'
).
show
();
});
NoteList
.
init
(
"
#{
tid
}
"
,
"
#{
tt
}
"
,
"
#{
project_notes_path
(
@project
)
}
"
);
NoteList
.
init
(
"
#{
tid
}
"
,
"
#{
tt
}
"
,
"
#{
project_notes_path
(
@project
)
}
"
);
});
});
This diff is collapsed.
Click to expand it.
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