1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-05 02:29:26 +02:00

Refactored basic mode to a directive.

This commit is contained in:
Gunther Brunner 2014-05-27 19:03:53 +09:00
parent eb3e7a40cc
commit 6429a681be
6 changed files with 45 additions and 9 deletions

View 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')
}
}
}
}

View 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');
*/
});
});

View file

@ -0,0 +1,4 @@
module.exports = angular.module('stf.basic-mode', [
])
.directive('basicMode', require('./basic-mode-directive'))

View file

@ -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',

View file

@ -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) {
}

View file

@ -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"')