BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
f90b6200
Commit
f90b6200
authored
Nov 07, 2016
by
winniehell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up common_utils.js (!7318)
parent
629624f3
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
33 additions
and
103 deletions
+33
-103
application.js
app/assets/javascripts/application.js
+16
-2
gfm_auto_complete.js.es6
app/assets/javascripts/gfm_auto_complete.js.es6
+11
-7
common_utils.js
app/assets/javascripts/lib/utils/common_utils.js
+0
-54
merge_request_tabs.js
app/assets/javascripts/merge_request_tabs.js
+2
-1
cleanup-common_utils-js.yml
changelogs/unreleased/cleanup-common_utils-js.yml
+4
-0
application_spec.js
spec/javascripts/application_spec.js
+0
-37
application.html.haml
spec/javascripts/fixtures/application.html.haml
+0
-2
No files found.
app/assets/javascripts/application.js
View file @
f90b6200
...
...
@@ -56,7 +56,13 @@
/*= require es6-promise.auto */
(
function
()
{
document
.
addEventListener
(
'page:fetch'
,
gl
.
utils
.
cleanupBeforeFetch
);
document
.
addEventListener
(
'page:fetch'
,
function
()
{
// Unbind scroll events
$
(
document
).
off
(
'scroll'
);
// Close any open tooltips
$
(
'.has-tooltip, [data-toggle="tooltip"]'
).
tooltip
(
'destroy'
);
});
window
.
addEventListener
(
'hashchange'
,
gl
.
utils
.
handleLocationHash
);
window
.
addEventListener
(
'load'
,
function
onLoad
()
{
window
.
removeEventListener
(
'load'
,
onLoad
,
false
);
...
...
@@ -76,7 +82,15 @@
// Set the default path for all cookies to GitLab's root directory
Cookies
.
defaults
.
path
=
gon
.
relative_url_root
||
'/'
;
gl
.
utils
.
preventDisabledButtons
();
// prevent default action for disabled buttons
$
(
'.btn'
).
click
(
function
(
e
)
{
if
(
$
(
this
).
hasClass
(
'disabled'
))
{
e
.
preventDefault
();
e
.
stopImmediatePropagation
();
return
false
;
}
});
$
(
'.nav-sidebar'
).
niceScroll
({
cursoropacitymax
:
'0.4'
,
cursorcolor
:
'#FFF'
,
...
...
app/assets/javascripts/gfm_auto_complete.js.es6
View file @
f90b6200
...
...
@@ -5,6 +5,10 @@
window.GitLab = {};
}
function sanitize(str) {
return str.replace(/<(?:.|\n)*?>/gm, '');
}
GitLab.GfmAutoComplete = {
dataLoading: false,
dataLoaded: false,
...
...
@@ -160,8 +164,8 @@
return {
username: m.username,
avatarTag: autoCompleteAvatar.length === 1 ? txtAvatar : imgAvatar,
title:
gl.utils.
sanitize(title),
search:
gl.utils.
sanitize(m.username + " " + m.name)
title: sanitize(title),
search: sanitize(m.username + " " + m.name)
};
});
}
...
...
@@ -195,7 +199,7 @@
}
return {
id: i.iid,
title:
gl.utils.
sanitize(i.title),
title: sanitize(i.title),
search: i.iid + " " + i.title
};
});
...
...
@@ -228,7 +232,7 @@
}
return {
id: m.iid,
title:
gl.utils.
sanitize(m.title),
title: sanitize(m.title),
search: "" + m.title
};
});
...
...
@@ -263,7 +267,7 @@
}
return {
id: m.iid,
title:
gl.utils.
sanitize(m.title),
title: sanitize(m.title),
search: m.iid + " " + m.title
};
});
...
...
@@ -284,9 +288,9 @@
var sanitizeLabelTitle;
sanitizeLabelTitle = function(title) {
if (/[\w\?&]+\s+[\w\?&]+/g.test(title)) {
return "\"" + (
gl.utils.
sanitize(title)) + "\"";
return "\"" + (sanitize(title)) + "\"";
} else {
return
gl.utils.
sanitize(title);
return sanitize(title);
}
};
return $.map(merges, function(m) {
...
...
app/assets/javascripts/lib/utils/common_utils.js
View file @
f90b6200
...
...
@@ -33,10 +33,6 @@
});
};
w
.
gl
.
utils
.
split
=
function
(
val
)
{
return
val
.
split
(
/,
\s
*/
);
};
w
.
gl
.
utils
.
extractLast
=
function
(
term
)
{
return
this
.
split
(
term
).
pop
();
};
...
...
@@ -67,33 +63,6 @@
});
};
w
.
gl
.
utils
.
disableButtonIfAnyEmptyField
=
function
(
form
,
form_selector
,
button_selector
)
{
var
closest_submit
,
updateButtons
;
closest_submit
=
form
.
find
(
button_selector
);
updateButtons
=
function
()
{
var
filled
;
filled
=
true
;
form
.
find
(
'input'
).
filter
(
form_selector
).
each
(
function
()
{
return
filled
=
this
.
rstrip
(
$
(
this
).
val
())
!==
""
||
!
$
(
this
).
attr
(
'required'
);
});
if
(
filled
)
{
return
closest_submit
.
enable
();
}
else
{
return
closest_submit
.
disable
();
}
};
updateButtons
();
return
form
.
keyup
(
updateButtons
);
};
w
.
gl
.
utils
.
sanitize
=
function
(
str
)
{
return
str
.
replace
(
/<
(?:
.|
\n)
*
?
>/gm
,
''
);
};
w
.
gl
.
utils
.
unbindEvents
=
function
()
{
return
$
(
document
).
off
(
'scroll'
);
};
// automatically adjust scroll position for hash urls taking the height of the navbar into account
// https://github.com/twitter/bootstrap/issues/1768
w
.
gl
.
utils
.
handleLocationHash
=
function
()
{
...
...
@@ -124,32 +93,9 @@
}
};
gl
.
utils
.
updateTooltipTitle
=
function
(
$tooltipEl
,
newTitle
)
{
return
$tooltipEl
.
tooltip
(
'destroy'
).
attr
(
'title'
,
newTitle
).
tooltip
(
'fixTitle'
);
};
gl
.
utils
.
preventDisabledButtons
=
function
()
{
return
$
(
'.btn'
).
click
(
function
(
e
)
{
if
(
$
(
this
).
hasClass
(
'disabled'
))
{
e
.
preventDefault
();
e
.
stopImmediatePropagation
();
return
false
;
}
});
};
gl
.
utils
.
getPagePath
=
function
()
{
return
$
(
'body'
).
data
(
'page'
).
split
(
':'
)[
0
];
};
gl
.
utils
.
parseUrl
=
function
(
url
)
{
var
parser
=
document
.
createElement
(
'a'
);
parser
.
href
=
url
;
return
parser
;
};
gl
.
utils
.
cleanupBeforeFetch
=
function
()
{
// Unbind scroll events
$
(
document
).
off
(
'scroll'
);
// Close any open tooltips
$
(
'.has-tooltip, [data-toggle="tooltip"]'
).
tooltip
(
'destroy'
);
};
gl
.
utils
.
isMetaKey
=
function
(
e
)
{
return
e
.
metaKey
||
e
.
ctrlKey
||
e
.
altKey
||
e
.
shiftKey
;
...
...
app/assets/javascripts/merge_request_tabs.js
View file @
f90b6200
...
...
@@ -220,7 +220,8 @@
// We extract pathname for the current Changes tab anchor href
// some pages like MergeRequestsController#new has query parameters on that anchor
var
url
=
gl
.
utils
.
parseUrl
(
source
);
var
url
=
document
.
createElement
(
'a'
);
url
.
href
=
source
;
return
this
.
_get
({
url
:
(
url
.
pathname
+
".json"
)
+
this
.
_location
.
search
,
...
...
changelogs/unreleased/cleanup-common_utils-js.yml
0 → 100644
View file @
f90b6200
---
title
:
Clean up common_utils.js
merge_request
:
7318
author
:
winniehell
spec/javascripts/application_spec.js
deleted
100644 → 0
View file @
629624f3
/* eslint-disable space-before-function-paren, one-var, no-var, one-var-declaration-per-line, no-return-assign, padded-blocks, max-len */
/*= require lib/utils/common_utils */
(
function
()
{
describe
(
'Application'
,
function
()
{
return
describe
(
'disable buttons'
,
function
()
{
fixture
.
preload
(
'application.html'
);
beforeEach
(
function
()
{
return
fixture
.
load
(
'application.html'
);
});
it
(
'should prevent default action for disabled buttons'
,
function
()
{
var
$button
,
isClicked
;
gl
.
utils
.
preventDisabledButtons
();
isClicked
=
false
;
$button
=
$
(
'#test-button'
);
expect
(
$button
).
toExist
();
$button
.
click
(
function
()
{
return
isClicked
=
true
;
});
$button
.
trigger
(
'click'
);
return
expect
(
isClicked
).
toBe
(
false
);
});
it
(
'should be on the same page if a disabled link clicked'
,
function
()
{
var
locationBeforeLinkClick
,
$link
;
locationBeforeLinkClick
=
window
.
location
.
href
;
gl
.
utils
.
preventDisabledButtons
();
$link
=
$
(
'#test-link'
);
expect
(
$link
).
toExist
();
$link
.
click
();
return
expect
(
window
.
location
.
href
).
toBe
(
locationBeforeLinkClick
);
});
});
});
}).
call
(
this
);
spec/javascripts/fixtures/application.html.haml
deleted
100644 → 0
View file @
629624f3
%a
#test-link
.btn.disabled
{
:href
=>
"/foo"
}
Test link
%button
#test-button
.btn.disabled
Test Button
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