mirror of
https://github.com/openstf/stf
synced 2025-10-05 10:39:25 +02:00
Refactored basic mode to a directive.
This commit is contained in:
parent
eb3e7a40cc
commit
6429a681be
6 changed files with 45 additions and 9 deletions
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'))
|
|
@ -24,6 +24,7 @@ require('angular-loading-bar/src/loading-bar.js')
|
|||
require('angular-loading-bar/src/loading-bar.css')
|
||||
|
||||
module.exports = angular.module('layout', [
|
||||
require('stf/basic-mode').name,
|
||||
'ui.bootstrap',
|
||||
'fa.directive.borderLayout',
|
||||
'angular-loading-bar',
|
||||
|
|
|
@ -1,10 +1,3 @@
|
|||
module.exports = function LayoutCtrl(FatalMessageService, BrowserInfo, $rootScope) {
|
||||
|
||||
$rootScope.basicMode = false
|
||||
if (BrowserInfo.small) {
|
||||
$rootScope.basicMode = true
|
||||
} else {
|
||||
$rootScope.basicMode = false
|
||||
}
|
||||
module.exports = function LayoutCtrl(FatalMessageService) {
|
||||
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ html
|
|||
meta(name='viewport', content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui')
|
||||
title STF
|
||||
body(ng-app='app', ng-cloak).bg-1.fill-height
|
||||
div(ng-controller='LayoutCtrl').fill-height
|
||||
div(ng-controller='LayoutCtrl', basic-mode).fill-height
|
||||
div(pane).fill-height
|
||||
.pane-top-bar(pane, pane-anchor='north', pane-size='46px', pane-min='46px', pane-max='46px', pane-handle='')
|
||||
div(ng-include='"menu.jade"')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue