Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
fb4c1efe
Commit
fb4c1efe
authored
Feb 10, 2018
by
Robert Knight
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert `spinner` Angular directive to a component
This is the last remaining directive which should be a component.
parent
8997d723
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
32 additions
and
21 deletions
+32
-21
spinner.js
src/sidebar/components/spinner.js
+18
-0
search-input-test.js
src/sidebar/components/test/search-input-test.js
+2
-2
spinner-test.js
src/sidebar/components/test/spinner-test.js
+10
-5
spinner.js
src/sidebar/directive/spinner.js
+0
-12
index.js
src/sidebar/index.js
+1
-1
search-input.html
src/sidebar/templates/search-input.html
+1
-1
No files found.
src/sidebar/components/spinner.js
0 → 100644
View file @
fb4c1efe
'use strict'
;
// @ngInject
function
SpinnerController
(
$animate
,
$element
)
{
// ngAnimate conflicts with the spinners own CSS
$animate
.
enabled
(
false
,
$element
);
}
module
.
exports
=
{
controller
:
SpinnerController
,
controllerAs
:
'vm'
,
template
:
`
<span class="spinner">
<span><span>
</span></span>
</span>
`
,
};
src/sidebar/components/test/search-input-test.js
View file @
fb4c1efe
...
...
@@ -46,13 +46,13 @@ describe('searchInput', function () {
describe
(
'loading indicator'
,
function
()
{
it
(
'is hidden when there are no network requests in flight'
,
function
()
{
const
el
=
util
.
createDirective
(
document
,
'search-input'
,
{});
const
spinner
=
el
[
0
].
querySelector
(
'
.
spinner'
);
const
spinner
=
el
[
0
].
querySelector
(
'spinner'
);
assert
.
equal
(
util
.
isHidden
(
spinner
),
true
);
});
it
(
'is visible when there are network requests in flight'
,
function
()
{
const
el
=
util
.
createDirective
(
document
,
'search-input'
,
{});
const
spinner
=
el
[
0
].
querySelector
(
'
.
spinner'
);
const
spinner
=
el
[
0
].
querySelector
(
'spinner'
);
fakeHttp
.
pendingRequests
.
push
([{}]);
el
.
scope
.
$digest
();
assert
.
equal
(
util
.
isHidden
(
spinner
),
false
);
...
...
src/sidebar/
directive
/test/spinner-test.js
→
src/sidebar/
components
/test/spinner-test.js
View file @
fb4c1efe
...
...
@@ -2,6 +2,8 @@
const
angular
=
require
(
'angular'
);
const
util
=
require
(
'../../directive/test/util'
);
const
module
=
angular
.
mock
.
module
;
const
inject
=
angular
.
mock
.
inject
;
...
...
@@ -11,19 +13,18 @@ describe('spinner', function () {
let
sandbox
=
null
;
before
(
function
()
{
angular
.
module
(
'h'
,
[]).
directive
(
'spinner'
,
require
(
'../spinner'
));
angular
.
module
(
'h'
,
[]).
component
(
'spinner'
,
require
(
'../spinner'
));
});
beforeEach
(
module
(
'h'
));
beforeEach
(
inject
(
function
(
_$animate_
,
$compile
,
$rootScope
)
{
beforeEach
(
inject
(
function
(
_$animate_
)
{
sandbox
=
sinon
.
sandbox
.
create
();
$animate
=
_$animate_
;
sandbox
.
spy
(
$animate
,
'enabled'
);
$element
=
angular
.
element
(
'<span class="spinner"></span>'
);
$compile
(
$element
)(
$rootScope
.
$new
());
$element
=
util
.
createDirective
(
document
,
'spinner'
);
}));
afterEach
(
function
()
{
...
...
@@ -31,6 +32,10 @@ describe('spinner', function () {
});
it
(
'disables ngAnimate animations for itself'
,
function
()
{
assert
.
calledWith
(
$animate
.
enabled
,
false
,
sinon
.
match
(
$element
));
assert
.
calledOnce
(
$animate
.
enabled
);
const
[
enabled
,
jqElement
]
=
$animate
.
enabled
.
getCall
(
0
).
args
;
assert
.
equal
(
enabled
,
false
);
assert
.
equal
(
jqElement
[
0
],
$element
[
0
]);
});
});
src/sidebar/directive/spinner.js
deleted
100644 → 0
View file @
8997d723
'use strict'
;
module
.
exports
=
[
'$animate'
,
function
(
$animate
)
{
return
{
link
:
function
(
scope
,
elem
)
{
// ngAnimate conflicts with the spinners own CSS
$animate
.
enabled
(
false
,
elem
);
},
restrict
:
'C'
,
template
:
'<span><span></span></span>'
,
};
}];
src/sidebar/index.js
View file @
fb4c1efe
...
...
@@ -160,6 +160,7 @@ function startAngularApp(config) {
.
component
(
'sidebarTutorial'
,
require
(
'./components/sidebar-tutorial'
))
.
component
(
'shareDialog'
,
require
(
'./components/share-dialog'
))
.
component
(
'sortDropdown'
,
require
(
'./components/sort-dropdown'
))
.
component
(
'spinner'
,
require
(
'./components/spinner'
))
.
component
(
'streamContent'
,
require
(
'./components/stream-content'
))
.
component
(
'svgIcon'
,
require
(
'./components/svg-icon'
))
.
component
(
'tagEditor'
,
require
(
'./components/tag-editor'
))
...
...
@@ -171,7 +172,6 @@ function startAngularApp(config) {
.
directive
(
'hBranding'
,
require
(
'./directive/h-branding'
))
.
directive
(
'hOnTouch'
,
require
(
'./directive/h-on-touch'
))
.
directive
(
'hTooltip'
,
require
(
'./directive/h-tooltip'
))
.
directive
(
'spinner'
,
require
(
'./directive/spinner'
))
.
directive
(
'windowScroll'
,
require
(
'./directive/window-scroll'
))
.
service
(
'analytics'
,
require
(
'./services/analytics'
))
...
...
src/sidebar/templates/search-input.html
View file @
fb4c1efe
...
...
@@ -11,6 +11,6 @@
<i
class=
"h-icon-search"
></i>
</button>
<button
type=
"button"
class=
"simple-search-icon btn btn-clean"
ng-show=
"vm.loading"
disabled
>
<span
class=
"btn-icon"
><sp
an
class=
"spinner"
></span
></span>
<span
class=
"btn-icon"
><sp
inner></spinner
></span>
</button>
</form>
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