Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
acd8b21d9343
Commit
0b981eb9
authored
May 02, 2013
by
Dmitriy Zaporozhets
Browse files
coffescript refactoring pt.1
parent
8787804a0bd2
Changes
12
Hide whitespace changes
Inline
Side-by-side
app/assets/javascripts/commit.js.coffee
View file @
acd8b21d
@
Commit
=
init
:
->
class
Commit
constructor
:
->
$
(
'.files .file'
).
each
->
new
CommitFile
(
this
)
@
Commit
=
Commit
app/assets/javascripts/dashboard.js.coffee
View file @
acd8b21d
window
.
dashboardPage
=
->
Pager
.
init
20
,
true
initSidebarTab
()
$
(
".event_filter_link"
).
bind
"click"
,
(
event
)
->
event
.
preventDefault
()
toggleFilter
$
(
this
)
reloadActivities
()
reloadActivities
=
->
$
(
".content_list"
).
html
''
Pager
.
init
20
,
true
toggleFilter
=
(
sender
)
->
sender
.
parent
().
toggleClass
"inactive"
event_filters
=
$
.
cookie
(
"event_filter"
)
filter
=
sender
.
attr
(
"id"
).
split
(
"_"
)[
0
]
if
event_filters
event_filters
=
event_filters
.
split
(
","
)
else
event_filters
=
new
Array
()
index
=
event_filters
.
indexOf
(
filter
)
if
index
is
-
1
event_filters
.
push
filter
else
event_filters
.
splice
index
,
1
$
.
cookie
"event_filter"
,
event_filters
.
join
(
","
)
initSidebarTab
=
->
key
=
"dashboard_sidebar_filter"
# store selection in cookie
$
(
'.dash-sidebar-tabs a'
).
on
'click'
,
(
e
)
->
$
.
cookie
(
key
,
$
(
e
.
target
).
attr
(
'id'
))
# show tab from cookie
sidebar_filter
=
$
.
cookie
(
key
)
$
(
"#"
+
sidebar_filter
).
tab
(
'show'
)
if
sidebar_filter
class
Dashboard
constructor
:
->
Pager
.
init
20
,
true
@
initSidebarTab
()
$
(
".event_filter_link"
).
bind
"click"
,
(
event
)
=>
event
.
preventDefault
()
@
toggleFilter
(
$
(
event
.
currentTarget
))
@
reloadActivities
()
reloadActivities
:
->
$
(
".content_list"
).
html
''
Pager
.
init
20
,
true
toggleFilter
:
(
sender
)
->
sender
.
parent
().
toggleClass
"inactive"
event_filters
=
$
.
cookie
(
"event_filter"
)
filter
=
sender
.
attr
(
"id"
).
split
(
"_"
)[
0
]
if
event_filters
event_filters
=
event_filters
.
split
(
","
)
else
event_filters
=
new
Array
()
index
=
event_filters
.
indexOf
(
filter
)
if
index
is
-
1
event_filters
.
push
filter
else
event_filters
.
splice
index
,
1
$
.
cookie
"event_filter"
,
event_filters
.
join
(
","
)
initSidebarTab
:
->
key
=
"dashboard_sidebar_filter"
# store selection in cookie
$
(
'.dash-sidebar-tabs a'
).
on
'click'
,
(
e
)
->
$
.
cookie
(
key
,
$
(
e
.
target
).
attr
(
'id'
))
# show tab from cookie
sidebar_filter
=
$
.
cookie
(
key
)
$
(
"#"
+
sidebar_filter
).
tab
(
'show'
)
if
sidebar_filter
@
Dashboard
=
Dashboard
app/assets/javascripts/dispatcher.js.coffee
View file @
acd8b21d
...
...
@@ -4,16 +4,27 @@ $ ->
class
Dispatcher
constructor
:
()
->
page
=
$
(
'body'
).
attr
(
'data-page'
)
project_id
=
$
(
'body'
).
attr
(
'data-project-id'
)
console
.
log
(
page
)
path
=
page
.
split
(
':'
)
switch
page
when
'issues:index'
then
Issues
.
init
()
when
'dashboard:show'
then
dashboardPage
()
when
'commit:show'
then
Commit
.
init
()
when
'issues:index'
Issues
.
init
()
when
'dashboard:show'
new
Dashboard
()
when
'commit:show'
new
Commit
()
when
'groups:show'
,
'teams:show'
,
'projects:show'
Pager
.
init
(
20
,
true
)
when
'projects:new'
,
'projects:edit'
new
Projects
()
when
'admin:teams:show'
,
'admin:groups:show'
,
'admin:logs:show'
,
'admin:users:new'
Admin
.
init
()
new
Project
()
when
'walls:show'
new
Wall
(
project_id
)
switch
path
.
first
()
when
'admin'
then
Admin
.
init
()
when
'wikis'
then
new
Wikis
()
app/assets/javascripts/project.js.coffee
0 → 100644
View file @
acd8b21d
class
Project
constructor
:
->
$
(
'.new_project, .edit_project'
).
on
'ajax:before'
,
->
$
(
'.project_new_holder, .project_edit_holder'
).
hide
()
$
(
'.save-project-loader'
).
show
()
$
(
'form #project_default_branch'
).
chosen
()
disableButtonIfEmptyField
'#project_name'
,
'.project-submit'
$
(
'#project_issues_enabled'
).
change
->
if
(
$
(
this
).
is
(
':checked'
)
==
true
)
$
(
'#project_issues_tracker'
).
removeAttr
(
'disabled'
)
else
$
(
'#project_issues_tracker'
).
attr
(
'disabled'
,
'disabled'
)
$
(
'#project_issues_tracker'
).
change
()
$
(
'#project_issues_tracker'
).
change
->
if
(
$
(
this
).
val
()
==
gon
.
default_issues_tracker
||
$
(
this
).
is
(
':disabled'
))
$
(
'#project_issues_tracker_id'
).
attr
(
'disabled'
,
'disabled'
)
else
$
(
'#project_issues_tracker_id'
).
removeAttr
(
'disabled'
)
@
Project
=
Project
$
->
# Git clone panel switcher
scope
=
$
'.project_clone_holder'
if
scope
.
length
>
0
$
(
'a, button'
,
scope
).
click
->
$
(
'a, button'
,
scope
).
removeClass
'active'
$
(
@
).
addClass
'active'
$
(
'#project_clone'
,
scope
).
val
$
(
@
).
data
'clone'
# Ref switcher
$
(
'.project-refs-select'
).
on
'change'
,
->
$
(
@
).
parents
(
'form'
).
submit
()
app/assets/javascripts/projects.js.coffee
deleted
100644 → 0
View file @
8787804a
window
.
Projects
=
->
$
(
'.new_project, .edit_project'
).
on
'ajax:before'
,
->
$
(
'.project_new_holder, .project_edit_holder'
).
hide
()
$
(
'.save-project-loader'
).
show
()
$
(
'form #project_default_branch'
).
chosen
()
disableButtonIfEmptyField
'#project_name'
,
'.project-submit'
$
->
# Git clone panel switcher
scope
=
$
'.project_clone_holder'
if
scope
.
length
>
0
$
(
'a, button'
,
scope
).
click
->
$
(
'a, button'
,
scope
).
removeClass
'active'
$
(
@
).
addClass
'active'
$
(
'#project_clone'
,
scope
).
val
$
(
@
).
data
'clone'
# Ref switcher
$
(
'.project-refs-select'
).
on
'change'
,
->
$
(
@
).
parents
(
'form'
).
submit
()
$
(
'#project_issues_enabled'
).
change
->
if
(
$
(
this
).
is
(
':checked'
)
==
true
)
$
(
'#project_issues_tracker'
).
removeAttr
(
'disabled'
)
else
$
(
'#project_issues_tracker'
).
attr
(
'disabled'
,
'disabled'
)
$
(
'#project_issues_tracker'
).
change
()
$
(
'#project_issues_tracker'
).
change
->
if
(
$
(
this
).
val
()
==
gon
.
default_issues_tracker
||
$
(
this
).
is
(
':disabled'
))
$
(
'#project_issues_tracker_id'
).
attr
(
'disabled'
,
'disabled'
)
else
$
(
'#project_issues_tracker_id'
).
removeAttr
(
'disabled'
)
app/assets/javascripts/wall.js.coffee
View file @
acd8b21d
@
Wall
=
note_ids
:
[]
project_id
:
null
init
:
(
project_id
)
->
Wall
.
project_id
=
project_id
Wall
.
getContent
()
Wall
.
initRefresh
()
Wall
.
initForm
()
class
Wall
constructor
:
(
project_id
)
->
@
project_id
=
project_id
@
note_ids
=
[]
@
getContent
()
@
initRefresh
()
@
initForm
()
#
# Gets an initial set of notes.
#
getContent
:
->
Api
.
notes
Wall
.
project_id
,
(
notes
)
-
>
$
.
each
notes
,
(
i
,
note
)
-
>
Api
.
notes
@
project_id
,
(
notes
)
=
>
$
.
each
notes
,
(
i
,
note
)
=
>
# render note if it not present in loaded list
# or skip if rendered
if
$
.
inArray
(
note
.
id
,
Wall
.
note_ids
)
==
-
1
Wall
.
note_ids
.
push
(
note
.
id
)
Wall
.
renderNote
(
note
)
Wall
.
scrollDown
()
if
$
.
inArray
(
note
.
id
,
@
note_ids
)
==
-
1
@
note_ids
.
push
(
note
.
id
)
@
renderNote
(
note
)
@
scrollDown
()
$
(
"abbr.timeago"
).
timeago
()
initRefresh
:
->
setInterval
(
"Wall.refresh()"
,
10000
)
setInterval
=>
@
refresh
()
,
10000
refresh
:
->
Wall
.
getContent
()
@
getContent
()
scrollDown
:
->
notes
=
$
(
'ul.notes'
)
...
...
@@ -36,8 +36,8 @@
form
=
$
(
'.wall-note-form'
)
form
.
find
(
"#target_type"
).
val
(
'wall'
)
form
.
on
'ajax:success'
,
-
>
Wall
.
refresh
()
form
.
on
'ajax:success'
,
=
>
@
refresh
()
form
.
find
(
".js-note-text"
).
val
(
""
).
trigger
(
"input"
)
form
.
on
'ajax:complete'
,
->
...
...
@@ -58,7 +58,7 @@
form
.
show
()
renderNote
:
(
note
)
->
template
=
Wall
.
noteTemplate
()
template
=
@
noteTemplate
()
template
=
template
.
replace
(
'{{author_name}}'
,
note
.
author
.
name
)
template
=
template
.
replace
(
'{{created_at}}'
,
note
.
created_at
)
template
=
template
.
replace
(
'{{text}}'
,
linkify
(
sanitize
(
note
.
body
)))
...
...
@@ -81,3 +81,5 @@
</span>
<abbr class="timeago" title="{{created_at}}">{{created_at}}</abbr>
</li>'
@
Wall
=
Wall
app/assets/javascripts/wikis.js.coffee
0 → 100644
View file @
acd8b21d
class
Wikis
constructor
:
->
modal
=
$
(
'#modal-new-wiki'
).
modal
({
modal
:
true
,
show
:
false
})
$
(
'.add-new-wiki'
).
bind
"click"
,
->
modal
.
show
()
$
(
'.build-new-wiki'
).
bind
"click"
,
->
field
=
$
(
'#new_wiki_path'
)
slug
=
field
.
val
()
path
=
field
.
attr
(
'data-wikis-path'
)
if
(
slug
.
length
>
0
)
location
.
href
=
path
+
"/"
+
slug
$
(
'.modal-header .close'
).
bind
"click"
,
->
modal
.
hide
()
@
Wikis
=
Wikis
app/views/graph/show.html.haml
View file @
acd8b21d
...
...
@@ -7,11 +7,10 @@
:javascript
var
branch_graph
;
$
(
function
(){
branch_graph
=
new
BranchGraph
(
$
(
"
#holder
"
),
{
url
:
'
#{
project_graph_path
(
@project
,
@ref
,
q:
@q
,
format: :json
)
}
'
,
commit_url
:
'
#{
project_commit_path
(
@project
,
'ae45ca32'
).
gsub
(
"ae45ca32"
,
"%s"
)
}
'
,
ref
:
'
#{
@ref
}
'
,
commit_id
:
'
#{
@commit
.
id
}
'
});
branch_graph
=
new
BranchGraph
(
$
(
"
#holder
"
),
{
url
:
'
#{
project_graph_path
(
@project
,
@ref
,
q:
@q
,
format: :json
)
}
'
,
commit_url
:
'
#{
project_commit_path
(
@project
,
'ae45ca32'
).
gsub
(
"ae45ca32"
,
"%s"
)
}
'
,
ref
:
'
#{
@ref
}
'
,
commit_id
:
'
#{
@commit
.
id
}
'
});
app/views/layouts/project_resource.html.haml
View file @
acd8b21d
!!! 5
%html
{
lang:
"en"
}
=
render
"layouts/head"
,
title:
@project
.
name_with_namespace
%body
{
class:
"#{app_theme} project"
,
:'data-page'
=>
body_data_page
}
%body
{
class:
"#{app_theme} project"
,
:'data-page'
=>
body_data_page
,
:'data-project-id'
=>
@project
.
id
}
=
render
"layouts/head_panel"
,
title:
project_title
(
@project
)
=
render
"layouts/flash"
-
if
can?
(
current_user
,
:download_code
,
@project
)
...
...
app/views/merge_requests/_show.html.haml
View file @
acd8b21d
...
...
@@ -26,14 +26,12 @@
:javascript
var
merge_request
;
$
(
function
(){
merge_request
=
new
MergeRequest
({
url_to_automerge_check
:
"
#{
automerge_check_project_merge_request_path
(
@project
,
@merge_request
)
}
"
,
check_enable
:
#{
@merge_request
.
unchecked?
?
"true"
:
"false"
}
,
url_to_ci_check
:
"
#{
ci_status_project_merge_request_path
(
@project
,
@merge_request
)
}
"
,
ci_enable
:
#{
@project
.
gitlab_ci?
?
"true"
:
"false"
}
,
current_status
:
"
#{
@merge_request
.
merge_status_name
}
"
,
action
:
"
#{
controller
.
action_name
}
"
});
});
merge_request
=
new
MergeRequest
({
url_to_automerge_check
:
"
#{
automerge_check_project_merge_request_path
(
@project
,
@merge_request
)
}
"
,
check_enable
:
#{
@merge_request
.
unchecked?
?
"true"
:
"false"
}
,
url_to_ci_check
:
"
#{
ci_status_project_merge_request_path
(
@project
,
@merge_request
)
}
"
,
ci_enable
:
#{
@project
.
gitlab_ci?
?
"true"
:
"false"
}
,
current_status
:
"
#{
@merge_request
.
merge_status_name
}
"
,
action
:
"
#{
controller
.
action_name
}
"
});
app/views/walls/show.html.haml
View file @
acd8b21d
...
...
@@ -21,8 +21,3 @@
.hint.pull-right
CTRL + Enter to send message
.clearfix
:javascript
$
(
function
(){
Wall
.
init
(
#{
@project
.
id
}
);
});
app/views/wikis/_new.html.haml
View file @
acd8b21d
...
...
@@ -5,27 +5,8 @@
.modal-body
=
label_tag
:new_wiki_path
do
%span
Page slug
=
text_field_tag
:new_wiki_path
,
nil
,
placeholder:
'how-to-setup'
,
class:
'input-xlarge'
,
required:
true
=
text_field_tag
:new_wiki_path
,
nil
,
placeholder:
'how-to-setup'
,
class:
'input-xlarge'
,
required:
true
,
:'data-wikis-path'
=>
project_wikis_path
(
@project
)
%p
.hint
Please dont use spaces and slashes
.modal-footer
=
link_to
'Build'
,
'#'
,
class:
'build-new-wiki btn btn-create'
:javascript
$
(
function
(){
var
modal
=
$
(
'
#modal-new-wiki
'
).
modal
({
modal
:
true
,
show
:
false
});
$
(
'
.add-new-wiki
'
).
bind
(
"
click
"
,
function
(){
modal
.
show
();
});
$
(
'
.build-new-wiki
'
).
bind
(
"
click
"
,
function
(){
var
slug
=
$
(
'
#new_wiki_path
'
).
val
();
if
(
slug
.
length
>
0
)
{
location
.
href
=
"
#{
project_wikis_path
(
@project
)
}
/
"
+
slug
;
}
});
$
(
'
.modal-header .close
'
).
bind
(
"
click
"
,
function
(){
modal
.
hide
();
})
})
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