Skip to content

Commit

Permalink
chore: eslint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterRao committed Jul 27, 2021
1 parent 6d5a92d commit 80792f7
Show file tree
Hide file tree
Showing 82 changed files with 7,081 additions and 6,395 deletions.
138 changes: 70 additions & 68 deletions app/app.js
Original file line number Diff line number Diff line change
@@ -1,78 +1,80 @@
angular
.module("web", [
"ui.router",
"ui.bootstrap",
"ui.codemirror",
"pascalprecht.translate",
"ngSanitize",
"templates",
"ui.bootstrap.contextMenu",
])
.config([
"$stateProvider",
"$urlRouterProvider",
"$translateProvider",
function ($stateProvider, $urlRouterProvider, $translateProvider) {
moment.locale("zh-CN");
.module('web', [
'ui.router',
'ui.bootstrap',
'ui.codemirror',
'pascalprecht.translate',
'ngSanitize',
'templates',
'ui.bootstrap.contextMenu'
])
.config([
'$stateProvider',
'$urlRouterProvider',
'$translateProvider',
function($stateProvider, $urlRouterProvider, $translateProvider) {
moment.locale('zh-CN');

$stateProvider
.state("files", {
url: "/",
templateUrl: "main/files/files.html",
controller: "filesCtrl",
})
.state("login", {
url: "/login",
templateUrl: "main/auth/login.html",
controller: "loginCtrl",
});
$stateProvider
.state('files', {
url: '/',
templateUrl: 'main/files/files.html',
controller: 'filesCtrl'
})
.state('login', {
url: '/login',
templateUrl: 'main/auth/login.html',
controller: 'loginCtrl'
});

$urlRouterProvider.otherwise('/');

$urlRouterProvider.otherwise("/");
// i18n
for (var k in Global.i18n) {
$translateProvider.translations(k, Global.i18n[k].content);
}

//i18n
for (var k in Global.i18n) {
$translateProvider.translations(k, Global.i18n[k].content);
$translateProvider.preferredLanguage('zh-CN');

$translateProvider.useSanitizeValueStrategy('escapeParameters');
}
$translateProvider.preferredLanguage("zh-CN");
])
.run([
'$rootScope',
'$translate',
'Toast',
function($rootScope, $translate, Toast) {
$rootScope.openURL = function(url) {
openExternal(url);
};

$translateProvider.useSanitizeValueStrategy("escapeParameters");
},
])
.run([
"$rootScope",
"$translate",
"Toast",
function ($rootScope, $translate, Toast) {
$rootScope.openURL = function (url) {
openExternal(url);
};
// //i18n
var langMap = {};
var langList = [];

// //i18n
var langMap = {};
var langList = [];
angular.forEach(Global.i18n, function (v, k) {
langMap[k] = v;
langList.push({
lang: k,
label: v.label,
angular.forEach(Global.i18n, function(v, k) {
langMap[k] = v;
langList.push({
lang: k,
label: v.label
});
});
});
var lang = localStorage.getItem("lang") || langList[0].lang;
var lang = localStorage.getItem('lang') || langList[0].lang;

$rootScope.langSettings = {
langList: langList,
lang: lang,
changeLanguage: function (key) {
console.log("changeLanguage:", key);
key = langMap[key] ? key : langList[0].lang;
$translate.use(key);
localStorage.setItem("lang", key);
$rootScope.langSettings.lang = key;
Toast.success($translate.instant("setup.success")); //'已经设置成功'
},
};
$translate.use(lang);
$rootScope.langSettings = {
langList: langList,
lang: lang,
changeLanguage: function(key) {
console.log('changeLanguage:', key);
key = langMap[key] ? key : langList[0].lang;
$translate.use(key);
localStorage.setItem('lang', key);
$rootScope.langSettings.lang = key;
Toast.success($translate.instant('setup.success')); // '已经设置成功'
}
};
$translate.use(lang);

console.log("ready");
},
]);
console.log('ready');
}
]);
25 changes: 13 additions & 12 deletions app/components/directives/auto-height.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
angular.module("web").directive("autoHeight", [
"$timeout",
function ($timeout) {
angular.module('web').directive('autoHeight', [
'$timeout',
function($timeout) {
return {
link: linkFn,
restrict: "EA",
restrict: 'EA',
transclude: false,
scope: {
autoHeight: "=",
//bottomLoader: '&'
},
autoHeight: '='
// bottomLoader: '&'
}
};

function linkFn(scope, ele, attr) {
var h = parseInt(scope.autoHeight);

ele.css({
//'border-bottom': '1px solid #ccc',
overflow: "auto",
position: "relative",
// 'border-bottom': '1px solid #ccc',
overflow: 'auto',
position: 'relative'
});

var tid;

function resize() {
$timeout.cancel(tid);
tid = $timeout(function () {
tid = $timeout(function() {
var v = $(window).height() + h;

$(ele).height(v);
}, 300);
}
Expand All @@ -52,5 +53,5 @@ angular.module("web").directive("autoHeight", [
// $(ele).scroll(onScroll);
// }
}
},
}
]);
23 changes: 12 additions & 11 deletions app/components/directives/bottom-loader.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
angular.module("web").directive("bottomLoader", [
"$timeout",
function ($timeout) {
angular.module('web').directive('bottomLoader', [
'$timeout',
function($timeout) {
return {
link: linkFn,
restrict: "EA",
restrict: 'EA',
transclude: false,
scope: {
bottomLoader: "&",
},
bottomLoader: '&'
}
};

function linkFn(scope, ele, attr) {
ele.css({
//'border-bottom': '1px solid red',
overflow: "auto",
position: "relative",
// 'border-bottom': '1px solid red',
overflow: 'auto',
position: 'relative'
});
var tid2;

function onScroll() {
$timeout.cancel(tid2);
tid2 = $timeout(function () {
tid2 = $timeout(function() {
if (
$(ele)[0].scrollHeight > 0 &&
$(ele).parent().height() + $(ele).scrollTop() + 10 >=
Expand All @@ -33,5 +34,5 @@ angular.module("web").directive("bottomLoader", [
$(window).resize(onScroll);
$(ele).scroll(onScroll);
}
},
}
]);
90 changes: 46 additions & 44 deletions app/components/directives/cleanable-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,78 +2,80 @@
<input type="text" ng-model="abc" cleanable-input x="-3" y="-5"/>
*/

angular.module("web").directive("cleanableInput", [
"$timeout",
function ($timeout) {
angular.module('web').directive('cleanableInput', [
'$timeout',
function($timeout) {
return {
restrict: "EA",
require: "ngModel",
restrict: 'EA',
require: 'ngModel',

scope: {
model: "=ngModel",
ngChange: "&",
x: "=",
y: "=",
model: '=ngModel',
ngChange: '&',
x: '=',
y: '='
},
link: function link(scope, element) {
var id = "cleanable_inp-" + (Math.random() + "").substring(2);
var id = 'cleanable_inp-' + (Math.random() + '').substring(2);

element.wrap(
'<div id="' + id + '" style="position:relative;width:100%;"></div>'
'<div id="' + id + '" style="position:relative;width:100%;"></div>'
);
var btn = $(
'<a href="" style="font-size:14px;color:#999">' +
'<a href="" style="font-size:14px;color:#999">' +
'<i class="glyphicon glyphicon-remove-circle"></i></a>'
).appendTo($("#" + id));
).appendTo($('#' + id));

btn
.css({
display: "none",
position: "absolute",
"z-index": 10,
})
.click(function (e) {
scope.model = "";
if (!scope.$root.$$phase) {
scope.$apply();
}
.css({
display: 'none',
position: 'absolute',
'z-index': 10
})
.click(function(e) {
scope.model = '';

if (scope.ngChange) {
scope.$eval(scope.ngChange);
}
if (!scope.$root.$$phase) {
scope.$apply();
}

return false;
});
if (scope.ngChange) {
scope.$eval(scope.ngChange);
}

return false;
});

var y = isNaN(scope.y) ? 0 : parseInt(scope.y);
var x = isNaN(scope.x) ? 0 : parseInt(scope.x);

function onchange(v) {
if (v && v !== "") {
if (v && v !== '') {
btn
.css({
top: 6 + y,
right: 6 - x,
})
.show();
.css({
top: 6 + y,
right: 6 - x
})
.show();
} else {
btn.hide();
}
}

// Listen for any changes to the original model.
var tid;

scope.$watch(
"model",
function alteredValues(newValue, oldValue) {
$timeout.cancel(tid);
tid = $timeout(function () {
onchange(newValue);
}, 300);
},
true
'model',
function alteredValues(newValue, oldValue) {
$timeout.cancel(tid);
tid = $timeout(function() {
onchange(newValue);
}, 300);
},
true
);
},
}
};
},
}
]);
Loading

0 comments on commit 80792f7

Please sign in to comment.