1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-04 02:09:32 +02:00

- New nav menu.

- Polishing device list.
This commit is contained in:
Gunther Brunner 2014-03-25 21:18:10 +09:00
parent 8ed3ae1784
commit 593e14a80a
12 changed files with 115 additions and 10 deletions

View file

@ -28,6 +28,7 @@
}, },
"private": true, "private": true,
"resolutions": { "resolutions": {
"angular": "~1.3.0-beta.2" "angular": "~1.3.0-beta.2",
"localforage": "0.2.0"
} }
} }

View file

@ -0,0 +1,20 @@
module.exports = angular.module('stf.safe-apply', [])
.config([
'$provide', function ($provide) {
return $provide.decorator('$rootScope', [
'$delegate', function ($delegate) {
$delegate.safeApply = function (fn) {
var phase = $delegate.$$phase
if (phase === "$apply" || phase === "$digest") {
if (fn && typeof fn === 'function') {
fn()
}
} else {
$delegate.$apply(fn)
}
}
return $delegate
}
])
}
])

View file

@ -6,6 +6,7 @@
-moz-user-select: none; -moz-user-select: none;
-ms-user-select: none; -ms-user-select: none;
user-select: none; user-select: none;
font-weight: bold;
} }
.ng-table th.sortable { .ng-table th.sortable {

View file

@ -0,0 +1,2 @@
module.exports = angular.module('stf.nav-menu', [])
.directive('navMenu', require('./nav-menu-directive'))

View file

@ -0,0 +1,39 @@
module.exports = function ($location) {
return function (scope, element, attrs) {
var links = element.find('a')
var onClass = attrs.navMenu || 'current'
var routePattern
var link
var url
var currentLink
var urlMap = {}
var i
if (!$location.$$html5) {
routePattern = /^#[^/]*/
}
for (i = 0; i < links.length; i++) {
link = angular.element(links[i])
url = link.attr('href')
if ($location.$$html5) {
urlMap[url] = link
} else {
urlMap[url.replace(routePattern, '')] = link
}
}
scope.$on('$routeChangeStart', function () {
var pathLink = urlMap[$location.path()]
if (pathLink) {
if (currentLink) {
currentLink.removeClass(onClass);
}
currentLink = pathLink;
currentLink.addClass(onClass);
}
})
}
}

View file

@ -0,0 +1,23 @@
describe('navMenu', function () {
beforeEach(module('stf.nav-menu'));
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 nav-menu name="name">hi</div>')(scope);
expect(element.text()).toBe('hello, world');
*/
});
});

View file

@ -6,6 +6,11 @@
margin-top: -32px; margin-top: -32px;
} }
.stf-device-list .device-not-usable {
/*background: rgb(245, 245, 245);*/
opacity: 0.7;
}
.stf-device-list .devices-not-available { .stf-device-list .devices-not-available {
background: #f6f6f6; background: #f6f6f6;
} }

View file

@ -71,7 +71,7 @@ div.stf-device-list
div {{"User"|translate}} div {{"User"|translate}}
//tbody //tbody
tr(ng-repeat='device in $data') tr(ng-repeat='device in $data', ng-class='{ "device-not-usable": !device.usable }')
td(data-title="'Status'", td(data-title="'Status'",
sortable='"state"', sortable='"state"',
filter="{ 'usable': 'select' }", filter="{ 'usable': 'select' }",
@ -130,7 +130,7 @@ div.stf-device-list
a(ng-href='{{deviceUser(device).link}}', target='_blank') {{ deviceUser(device).name }} a(ng-href='{{deviceUser(device).link}}', target='_blank') {{ deviceUser(device).name }}
ul //ul
li(ng-repeat='device in tracker.devices track by device.serial') li(ng-repeat='device in tracker.devices track by device.serial')
pre {{device|json}} pre {{device|json}}

View file

@ -1,6 +1,7 @@
require('./menu.css') require('./menu.css')
module.exports = angular.module('stf.menu', [ module.exports = angular.module('stf.menu', [
require('stf/nav-menu').name
]) ])
.run(["$templateCache", function ($templateCache) { .run(["$templateCache", function ($templateCache) {
$templateCache.put('menu.jade', require('./menu.jade')) $templateCache.put('menu.jade', require('./menu.jade'))

View file

@ -1,3 +1,16 @@
module.exports = function MenuCtrl($scope) { module.exports = function MenuCtrl($scope) {
$scope.isActive = function (viewLocation) {
var pattern = '/' + viewLocation,
re = new RegExp(pattern);
return re.test($location.path());
};
$scope.isActive = function (path) {
console.log($location.path())
console.log($location.path().substr(0, path.length))
return $location.path().substr(0, path.length) == path;
}
} }

View file

@ -1,7 +1,7 @@
.navbar.stf-menu .navbar.stf-menu
.container-fluid.stf-top-bar .container-fluid.stf-top-bar
a.stf-logo(href="/") STF 2 a.stf-logo(href="/") STF 2
ul.nav.stf-nav ul.nav.stf-nav(nav-menu)
li(ng-cloak) li(ng-cloak)
a(href='/#!/control') a(href='/#!/control')
span.fa.fa-mobile span.fa.fa-mobile

View file

@ -33,15 +33,15 @@ module.exports = {
, { test: /\.png$/, loader: "url-loader?limit=5000&mimetype=image/png" } , { test: /\.png$/, loader: "url-loader?limit=5000&mimetype=image/png" }
, { test: /\.gif$/, loader: "url-loader?limit=5000&mimetype=image/gif" } , { test: /\.gif$/, loader: "url-loader?limit=5000&mimetype=image/gif" }
, { test: /\.svg$/ , { test: /\.svg$/
, loader: "url-loader?limit=5000&mimetype=image/svg+xml" } , loader: "url-loader?limit=1&mimetype=image/svg+xml" }
, { test: /\.woff$/ , { test: /\.woff$/
, loader: "url-loader?limit=5000&mimetype=application/font-woff" } , loader: "url-loader?limit=1&mimetype=application/font-woff" }
, { test: /\.otf$/ , { test: /\.otf$/
, loader: "url-loader?limit=5000&mimetype=application/font-woff" } , loader: "url-loader?limit=1&mimetype=application/font-woff" }
, { test: /\.ttf$/ , { test: /\.ttf$/
, loader: "url-loader?limit=5000&mimetype=application/font-woff" } , loader: "url-loader?limit=1&mimetype=application/font-woff" }
, { test: /\.eot$/ , { test: /\.eot$/
, loader: "url-loader?limit=5000&mimetype=vnd.ms-fontobject" } , loader: "url-loader?limit=1&mimetype=vnd.ms-fontobject" }
, { test: /\.jade/ , { test: /\.jade/
, loader: 'template-html-loader' } , loader: 'template-html-loader' }
, { test: /\.html/, loader: 'html-loader' } , { test: /\.html/, loader: 'html-loader' }