44 lines
1.9 KiB
JavaScript
44 lines
1.9 KiB
JavaScript
|
|
var arr = window.location.href.split("/");
|
|
if (arr[3].indexOf('app') == 0)
|
|
baseUrl = '';
|
|
else
|
|
baseUrl = '/' + arr[3];
|
|
|
|
angular.module('View.Directive').directive('headerContentLayout',
|
|
function (CONSTANTS) {
|
|
return {
|
|
restrict: 'A',
|
|
scope: true,
|
|
controller: function ($scope) {
|
|
$scope.headerLayout = {};
|
|
$scope.headerLayout.headerImageChange = function (sn, m) {
|
|
var k = 'header_image' + sn;
|
|
var s = 'show' + sn;
|
|
$scope.headerLayout[k] = 'url(\'' + baseUrl + '/Browser_Local/img/' + k + '_' + m + '.png\')';
|
|
if (m == 1) $scope.headerLayout[s] = false;
|
|
if (m == 2) $scope.headerLayout[s] = true;
|
|
}
|
|
|
|
for (var h = 0; h < CONSTANTS.HeaderContent.length; h++) {
|
|
$scope.headerLayout.headerImageChange(h + 1, 1);
|
|
}
|
|
$scope.headerLayout.HeaderContent = CONSTANTS.HeaderContent;
|
|
|
|
$scope.headerLayout.tooltipWidth = function (n) {
|
|
if (typeof CONSTANTS != 'undefined' && typeof CONSTANTS.HeaderContent != 'undefined' && n <= CONSTANTS.HeaderContent.length) {
|
|
var char_length = countLength(CONSTANTS.HeaderContent[n - 1]);
|
|
var space_length = 0;
|
|
var temp = CONSTANTS.HeaderContent[n - 1].substr(0);
|
|
while (temp.indexOf(' ') > -1) {
|
|
temp = temp.substr(temp.indexOf(' ') + 1);
|
|
space_length++;
|
|
}
|
|
// 字體 10px, 字距 2px
|
|
return char_length * 5 + (char_length - space_length - 1) * 2 + space_length * 10 + 15 + 8 + 'px';
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
}) |