mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-18 08:03:30 +02:00
Refactored basic mode to a directive.
This commit is contained in:
15
res/app/components/stf/basic-mode/basic-mode-directive.js
Normal file
15
res/app/components/stf/basic-mode/basic-mode-directive.js
Normal file
@@ -0,0 +1,15 @@
|
||||
module.exports = function basicModeDirective($rootScope, BrowserInfo) {
|
||||
return {
|
||||
restrict: 'AE',
|
||||
link: function (scope, element, attrs) {
|
||||
$rootScope.basicMode = !!BrowserInfo.small // TODO: use .mobile
|
||||
if ($rootScope.basicMode) {
|
||||
element.addClass('basic-mode')
|
||||
}
|
||||
|
||||
if (BrowserInfo.mobile) {
|
||||
element.addClass('mobile')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
23
res/app/components/stf/basic-mode/basic-mode-spec.js
Normal file
23
res/app/components/stf/basic-mode/basic-mode-spec.js
Normal file
@@ -0,0 +1,23 @@
|
||||
describe('basicMode', function () {
|
||||
|
||||
beforeEach(module('stf.basic-mode'));
|
||||
|
||||
var scope, compile;
|
||||
|
||||
beforeEach(inject(function ($rootScope, $compile) {
|
||||
scope = $rootScope.$new();
|
||||
compile = $compile;
|
||||
}));
|
||||
|
||||
it('should ...', function () {
|
||||
|
||||
/*
|
||||
To test your directive, you need to create some html that would use your directive,
|
||||
send that through compile() then compare the results.
|
||||
|
||||
var element = compile('<div basic-mode name="name">hi</div>')(scope);
|
||||
expect(element.text()).toBe('hello, world');
|
||||
*/
|
||||
|
||||
});
|
||||
});
|
||||
4
res/app/components/stf/basic-mode/index.js
Normal file
4
res/app/components/stf/basic-mode/index.js
Normal file
@@ -0,0 +1,4 @@
|
||||
module.exports = angular.module('stf.basic-mode', [
|
||||
|
||||
])
|
||||
.directive('basicMode', require('./basic-mode-directive'))
|
||||
Reference in New Issue
Block a user