修改 js 的命名风格

This commit is contained in:
virusdefender
2015-08-15 13:54:30 +08:00
parent d031f14a68
commit 025335b40a
50 changed files with 1403 additions and 896 deletions

View File

@@ -0,0 +1,65 @@
require(["jquery", "avalon", "csrfToken", "bsAlert", "formValidation"], function ($, avalon, csrfTokenHeader, bsAlert) {
avalon.ready(function () {
avalon.vmodels.problemList = null;
var vm = avalon.define({
$id: "problemList",
problemList: [],
previousPage: 0,
nextPage: 0,
page: 1,
totalPage: 1,
keyword: "",
getNext: function () {
if (!vm.nextPage)
return;
getPageData(vm.page + 1);
},
getPrevious: function () {
if (!vm.previousPage)
return;
getPageData(vm.page - 1);
},
getBtnClass: function (btn) {
if (btn == "next") {
return vm.nextPage ? "btn btn-primary" : "btn btn-primary disabled";
}
else {
return vm.previousPage ? "btn btn-primary" : "btn btn-primary disabled";
}
},
getPage: function (page_index) {
getPageData(page_index);
},
showEditProblemPage: function (problem_id) {
vm.$fire("up!showEditProblemPage", problem_id);
}
});
function getPageData(page) {
var url = "/api/admin/problem/?paging=true&page=" + page + "&page_size=10";
if (vm.keyword != "")
url += "&keyword=" + vm.keyword;
$.ajax({
url: url,
dataType: "json",
method: "get",
success: function (data) {
if (!data.code) {
vm.problemList = data.data.results;
vm.totalPage = data.data.total_page;
vm.previousPage = data.data.previous_page;
vm.nextPage = data.data.next_page;
vm.page = page;
}
else {
bsAlert(data.data);
}
}
});
}
getPageData(1);
});
avalon.scan();
});