mirror of
https://gitee.com/coder-xiaomo/flashsale
synced 2025-09-11 22:41:38 +08:00
添加Metronic(作为LFS)
This commit is contained in:
112
frontend/static/admin/pages/scripts/appDetail.js
Normal file
112
frontend/static/admin/pages/scripts/appDetail.js
Normal file
@@ -0,0 +1,112 @@
|
||||
|
||||
var AppUpdate = function() {
|
||||
|
||||
var handleAppUpdate = function() {
|
||||
|
||||
$('#form').validate({
|
||||
errorElement: 'span', //default input error message container
|
||||
errorClass: 'help-block', // default input error message class
|
||||
focusInvalid: false, // do not focus the last invalid input
|
||||
rules: {
|
||||
name: {
|
||||
required: true
|
||||
},
|
||||
icon_url: {
|
||||
required: true,
|
||||
url: true
|
||||
},
|
||||
ios_link: {
|
||||
url: true
|
||||
},
|
||||
android_link: {
|
||||
url: true
|
||||
}
|
||||
},
|
||||
|
||||
messages: {
|
||||
name: {
|
||||
required: "请输入名称"
|
||||
},
|
||||
icon_url: {
|
||||
required: "请输入下载url",
|
||||
url: "请输入正确的url链接"
|
||||
},
|
||||
ios_link: {
|
||||
url: "请输入正确的url链接"
|
||||
},
|
||||
android_link: {
|
||||
url: "请输入正确的url链接"
|
||||
}
|
||||
},
|
||||
|
||||
invalidHandler: function(event, validator) { //display error alert on form submit
|
||||
$('.alert-danger', $('.form')).show();
|
||||
},
|
||||
|
||||
highlight: function(element) { // hightlight error inputs
|
||||
$(element)
|
||||
.closest('.form-group').addClass('has-error'); // set error class to the control group
|
||||
},
|
||||
|
||||
success: function(label) {
|
||||
label.closest('.form-group').removeClass('has-error');
|
||||
label.remove();
|
||||
},
|
||||
|
||||
errorPlacement: function(error, element) {
|
||||
error.insertAfter(element.closest('input'));
|
||||
},
|
||||
|
||||
submitHandler: function(form) {
|
||||
form.submit(); // form validation success, call ajax form submit
|
||||
}
|
||||
});
|
||||
|
||||
$('.form input').keypress(function(e) {
|
||||
if (e.which == 13) {
|
||||
if ($('.form').validate().form()) {
|
||||
$('#form').submit(); //form validation success, call ajax form submit
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
//main function to initiate the module
|
||||
init: function() {
|
||||
|
||||
handleAppUpdate();
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}();
|
||||
|
||||
jQuery(document).ready(function() {
|
||||
AppUpdate.init();
|
||||
});
|
||||
|
||||
function updateApp(){
|
||||
|
||||
$.ajax( {
|
||||
url:'/admin/applications/update',
|
||||
data:$('#form').serialize(),
|
||||
type:'POST',
|
||||
processData:true,
|
||||
contentType:"application/x-www-form-urlencoded",
|
||||
success:function(data) {
|
||||
alert(data.status);
|
||||
if(data.status=="success"){
|
||||
window.location.reload(true);
|
||||
}else if(data.status=="fail"){
|
||||
alert(data.data.errMessage);
|
||||
}
|
||||
},
|
||||
error : function(e) {
|
||||
// view("异常!");
|
||||
alert(e);
|
||||
}
|
||||
});
|
||||
}
|
170
frontend/static/admin/pages/scripts/appList.js
Normal file
170
frontend/static/admin/pages/scripts/appList.js
Normal file
@@ -0,0 +1,170 @@
|
||||
var url = "/admin/applications/indexjson";
|
||||
|
||||
$('#dataTables-app').DataTable({
|
||||
"bPaginate": true,
|
||||
"bLengthChange": false,
|
||||
"bSort": false,
|
||||
"bFilter": true,
|
||||
"bAutoWidth": true,
|
||||
"bStateSave": true,
|
||||
"bServerSide": false,
|
||||
"bProcessing":true,
|
||||
"iDisplayLength": 20,
|
||||
"searching": true,
|
||||
"deferRender": true,
|
||||
"bDestroy":true,
|
||||
ajax:{
|
||||
"url" : url,
|
||||
"dataSrc" : "data.content"
|
||||
},
|
||||
columns : [
|
||||
{"data" : "id"},
|
||||
{"data" : "name"},
|
||||
{"data" : "iconUrl"},
|
||||
{"data" : "id"}
|
||||
],
|
||||
columnDefs: [{
|
||||
// 指定第一列,从0开始,0表示第一列,1表示第二列……
|
||||
targets: 2,
|
||||
render: function(data, type, row) {
|
||||
return "<img src='"+data+"' style='width:100px;' />";
|
||||
}
|
||||
},{
|
||||
targets: 3,
|
||||
render: function(data, type, row) {
|
||||
return "<a href='get?id="+data+"' class='btn btn-outline btn-circle red'><i class='fa fa-info-circle'></i> 查看详情</a>";
|
||||
|
||||
}
|
||||
},
|
||||
{
|
||||
//屏蔽警告
|
||||
sDefaultContent : '',
|
||||
aTargets : [ '_all' ]
|
||||
}
|
||||
],
|
||||
language: {
|
||||
"sProcessing": "处理中...",
|
||||
"sLengthMenu": "显示 _MENU_ 项结果",
|
||||
"sZeroRecords": "没有匹配结果",
|
||||
"sInfo": "显示第 _START_ 至 _END_ 项结果,共 _TOTAL_ 项",
|
||||
"sInfoEmpty": "显示第 0 至 0 项结果,共 0 项",
|
||||
"sInfoFiltered": "(由 _MAX_ 项结果过滤)",
|
||||
"sInfoPostFix": "",
|
||||
"sSearch": "搜索:",
|
||||
"sUrl": "",
|
||||
"sEmptyTable": "表中数据为空",
|
||||
"sLoadingRecords": "载入中...",
|
||||
"sInfoThousands": ",",
|
||||
"oPaginate": {
|
||||
"sFirst": "首页",
|
||||
"sPrevious": "上页",
|
||||
"sNext": "下页",
|
||||
"sLast": "末页"
|
||||
},
|
||||
"oAria": {
|
||||
"sSortAscending": ": 以升序排列此列",
|
||||
"sSortDescending": ": 以降序排列此列"
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
var AppAdd = function() {
|
||||
|
||||
var handleAppAdd = function() {
|
||||
|
||||
$('#form').validate({
|
||||
errorElement: 'span', //default input error message container
|
||||
errorClass: 'help-block', // default input error message class
|
||||
focusInvalid: false, // do not focus the last invalid input
|
||||
rules: {
|
||||
name: {
|
||||
required: true
|
||||
},
|
||||
iconUrl: {
|
||||
required: true,
|
||||
url: true
|
||||
}
|
||||
},
|
||||
|
||||
messages: {
|
||||
name: {
|
||||
required: "请输入名称"
|
||||
},
|
||||
iconUrl: {
|
||||
required: "请输入下载url",
|
||||
url: "请输入正确的url链接"
|
||||
}
|
||||
},
|
||||
|
||||
invalidHandler: function(event, validator) { //display error alert on form submit
|
||||
$('.alert-danger', $('.form')).show();
|
||||
},
|
||||
|
||||
highlight: function(element) { // hightlight error inputs
|
||||
$(element)
|
||||
.closest('.form-group').addClass('has-error'); // set error class to the control group
|
||||
},
|
||||
|
||||
success: function(label) {
|
||||
label.closest('.form-group').removeClass('has-error');
|
||||
label.remove();
|
||||
},
|
||||
|
||||
errorPlacement: function(error, element) {
|
||||
error.insertAfter(element.closest('input'));
|
||||
},
|
||||
|
||||
submitHandler: function(form) {
|
||||
form.submit(); // form validation success, call ajax form submit
|
||||
}
|
||||
});
|
||||
|
||||
$('.form input').keypress(function(e) {
|
||||
if (e.which == 13) {
|
||||
if ($('.form').validate().form()) {
|
||||
$('#form').submit(); //form validation success, call ajax form submit
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
//main function to initiate the module
|
||||
init: function() {
|
||||
|
||||
handleAppAdd();
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}();
|
||||
|
||||
jQuery(document).ready(function() {
|
||||
AppAdd.init();
|
||||
});
|
||||
|
||||
function addApp(){
|
||||
|
||||
$.ajax( {
|
||||
url:'/admin/applications/create',
|
||||
data:$('#form').serialize(),
|
||||
type:'POST',
|
||||
processData:true,
|
||||
contentType:"application/x-www-form-urlencoded",
|
||||
success:function(data) {
|
||||
alert(data.status);
|
||||
if(data.status=="success"){
|
||||
window.location.reload(true);
|
||||
}else if(data.status=="fail"){
|
||||
alert(data.data.errMessage);
|
||||
}
|
||||
},
|
||||
error : function(e) {
|
||||
// view("异常!");
|
||||
alert(e);
|
||||
}
|
||||
});
|
||||
}
|
1392
frontend/static/admin/pages/scripts/dashboard.js
Normal file
1392
frontend/static/admin/pages/scripts/dashboard.js
Normal file
File diff suppressed because it is too large
Load Diff
100
frontend/static/admin/pages/scripts/login.js
Normal file
100
frontend/static/admin/pages/scripts/login.js
Normal file
@@ -0,0 +1,100 @@
|
||||
var Login = function() {
|
||||
|
||||
var handleLogin = function() {
|
||||
|
||||
$('.login-form').validate({
|
||||
errorElement: 'span', //default input error message container
|
||||
errorClass: 'help-block', // default input error message class
|
||||
focusInvalid: false, // do not focus the last invalid input
|
||||
rules: {
|
||||
email: {
|
||||
required: true
|
||||
},
|
||||
password: {
|
||||
required: true
|
||||
},
|
||||
remember: {
|
||||
required: false
|
||||
}
|
||||
},
|
||||
|
||||
messages: {
|
||||
email: {
|
||||
required: "请输入登录邮箱"
|
||||
},
|
||||
password: {
|
||||
required: "请输入密码"
|
||||
}
|
||||
},
|
||||
|
||||
invalidHandler: function(event, validator) { //display error alert on form submit
|
||||
$('.alert-danger', $('.login-form')).show();
|
||||
},
|
||||
|
||||
highlight: function(element) { // hightlight error inputs
|
||||
$(element)
|
||||
.closest('.form-group').addClass('has-error'); // set error class to the control group
|
||||
},
|
||||
|
||||
success: function(label) {
|
||||
label.closest('.form-group').removeClass('has-error');
|
||||
label.remove();
|
||||
},
|
||||
|
||||
errorPlacement: function(error, element) {
|
||||
error.insertAfter(element.closest('.input-icon'));
|
||||
},
|
||||
|
||||
submitHandler: function(form) {
|
||||
form.submit(); // form validation success, call ajax form submit
|
||||
}
|
||||
});
|
||||
|
||||
$('.login-form input').keypress(function(e) {
|
||||
if (e.which == 13) {
|
||||
if ($('.login-form').validate().form()) {
|
||||
$('.login-form').submit(); //form validation success, call ajax form submit
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
//main function to initiate the module
|
||||
init: function() {
|
||||
|
||||
handleLogin();
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}();
|
||||
|
||||
jQuery(document).ready(function() {
|
||||
Login.init();
|
||||
});
|
||||
|
||||
function doLogin(){
|
||||
|
||||
$.ajax( {
|
||||
url:'/admin/admin/login',// 跳转到 action
|
||||
data:$('.login-form').serialize(),
|
||||
type:'POST',
|
||||
processData:true,
|
||||
contentType:"application/x-www-form-urlencoded",
|
||||
success:function(data) {
|
||||
alert(data.status);
|
||||
if(data.status=="success"){
|
||||
location.href = "/admin/index/index";
|
||||
}else if(data.status=="fail"){
|
||||
alert(data.data.errMessage);
|
||||
}
|
||||
},
|
||||
error : function(e) {
|
||||
// view("异常!");
|
||||
alert(e);
|
||||
}
|
||||
});
|
||||
}
|
@@ -0,0 +1,88 @@
|
||||
var TableDatatablesButtons = function () {
|
||||
|
||||
var initTable3 = function () {
|
||||
var table = $('#sample_3');
|
||||
|
||||
var oTable = table.dataTable({
|
||||
|
||||
// Internationalisation. For more info refer to http://datatables.net/manual/i18n
|
||||
"language": {
|
||||
"aria": {
|
||||
"sortAscending": ": activate to sort column ascending",
|
||||
"sortDescending": ": activate to sort column descending"
|
||||
},
|
||||
"emptyTable": "No data available in table",
|
||||
"info": "Showing _START_ to _END_ of _TOTAL_ entries",
|
||||
"infoEmpty": "No entries found",
|
||||
"infoFiltered": "(filtered1 from _MAX_ total entries)",
|
||||
"lengthMenu": "_MENU_ entries",
|
||||
"search": "Search:",
|
||||
"zeroRecords": "No matching records found"
|
||||
},
|
||||
|
||||
// Or you can use remote translation file
|
||||
//"language": {
|
||||
// url: '//cdn.datatables.net/plug-ins/3cfcc339e89/i18n/Portuguese.json'
|
||||
//},
|
||||
|
||||
buttons: [
|
||||
{ extend: 'print', className: 'btn dark btn-outline' },
|
||||
{ extend: 'copy', className: 'btn red btn-outline' },
|
||||
{ extend: 'pdf', className: 'btn green btn-outline' },
|
||||
{ extend: 'excel', className: 'btn yellow btn-outline ' },
|
||||
{ extend: 'csv', className: 'btn purple btn-outline ' },
|
||||
{ extend: 'colvis', className: 'btn dark btn-outline', text: 'Columns'}
|
||||
],
|
||||
|
||||
// setup responsive extension: http://datatables.net/extensions/responsive/
|
||||
responsive: true,
|
||||
|
||||
//"ordering": false, disable column ordering
|
||||
//"paging": false, disable pagination
|
||||
|
||||
"order": [
|
||||
[0, 'asc']
|
||||
],
|
||||
|
||||
"lengthMenu": [
|
||||
[5, 10, 15, 20, -1],
|
||||
[5, 10, 15, 20, "All"] // change per page values here
|
||||
],
|
||||
// set the initial value
|
||||
"pageLength": 10,
|
||||
|
||||
//"dom": "<'row' <'col-md-12'>><'row'<'col-md-6 col-sm-12'l><'col-md-6 col-sm-12'f>r><'table-scrollable't><'row'<'col-md-5 col-sm-12'i><'col-md-7 col-sm-12'p>>", // horizobtal scrollable datatable
|
||||
|
||||
// Uncomment below line("dom" parameter) to fix the dropdown overflow issue in the datatable cells. The default datatable layout
|
||||
// setup uses scrollable div(table-scrollable) with overflow:auto to enable vertical scroll(see: assets/global/plugins/datatables/plugins/bootstrap/dataTables.bootstrap.js).
|
||||
// So when dropdowns used the scrollable div should be removed.
|
||||
//"dom": "<'row' <'col-md-12'T>><'row'<'col-md-6 col-sm-12'l><'col-md-6 col-sm-12'f>r>t<'row'<'col-md-5 col-sm-12'i><'col-md-7 col-sm-12'p>>",
|
||||
});
|
||||
|
||||
// handle datatable custom tools
|
||||
$('#sample_3_tools > li > a.tool-action').on('click', function() {
|
||||
var action = $(this).attr('data-action');
|
||||
oTable.DataTable().button(action).trigger();
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
//main function to initiate the module
|
||||
init: function () {
|
||||
|
||||
if (!jQuery().dataTable) {
|
||||
return;
|
||||
}
|
||||
|
||||
initTable3();
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}();
|
||||
|
||||
jQuery(document).ready(function() {
|
||||
TableDatatablesButtons.init();
|
||||
});
|
161
frontend/static/admin/pages/scripts/tagCategoryList.js
Normal file
161
frontend/static/admin/pages/scripts/tagCategoryList.js
Normal file
@@ -0,0 +1,161 @@
|
||||
var url = "/admin/tags/indexcategoryjson";
|
||||
|
||||
$('#dataTables-tagcategory').DataTable({
|
||||
"bPaginate": true,
|
||||
"bLengthChange": false,
|
||||
"bSort": false,
|
||||
"bFilter": true,
|
||||
"bAutoWidth": true,
|
||||
"bStateSave": true,
|
||||
"bServerSide": false,
|
||||
"bProcessing":true,
|
||||
"iDisplayLength": 20,
|
||||
"searching": true,
|
||||
"deferRender": true,
|
||||
"bDestroy":true,
|
||||
ajax:{
|
||||
"url" : url,
|
||||
"dataSrc" : "data"
|
||||
},
|
||||
columns : [
|
||||
{"data" : "id"},
|
||||
{"data" : "name"},
|
||||
{"data" : "useCount"}
|
||||
],
|
||||
columnDefs: [
|
||||
// {
|
||||
// // 指定第一列,从0开始,0表示第一列,1表示第二列……
|
||||
// targets: 1,
|
||||
// render: function(data, type, row) {
|
||||
// switch(data){
|
||||
// case 0: return "待审核";
|
||||
// case 1: return "审核通过";
|
||||
// case 2: return "审核不通过";
|
||||
// case 3: return "失效";
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
{
|
||||
//屏蔽警告
|
||||
sDefaultContent : '',
|
||||
aTargets : [ '_all' ]
|
||||
}
|
||||
],
|
||||
language: {
|
||||
"sProcessing": "处理中...",
|
||||
"sLengthMenu": "显示 _MENU_ 项结果",
|
||||
"sZeroRecords": "没有匹配结果",
|
||||
"sInfo": "显示第 _START_ 至 _END_ 项结果,共 _TOTAL_ 项",
|
||||
"sInfoEmpty": "显示第 0 至 0 项结果,共 0 项",
|
||||
"sInfoFiltered": "(由 _MAX_ 项结果过滤)",
|
||||
"sInfoPostFix": "",
|
||||
"sSearch": "搜索:",
|
||||
"sUrl": "",
|
||||
"sEmptyTable": "表中数据为空",
|
||||
"sLoadingRecords": "载入中...",
|
||||
"sInfoThousands": ",",
|
||||
"oPaginate": {
|
||||
"sFirst": "首页",
|
||||
"sPrevious": "上页",
|
||||
"sNext": "下页",
|
||||
"sLast": "末页"
|
||||
},
|
||||
"oAria": {
|
||||
"sSortAscending": ": 以升序排列此列",
|
||||
"sSortDescending": ": 以降序排列此列"
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
var CategoryAdd = function() {
|
||||
|
||||
var handleCategoryAdd = function() {
|
||||
|
||||
$('#form').validate({
|
||||
errorElement: 'span', //default input error message container
|
||||
errorClass: 'help-block', // default input error message class
|
||||
focusInvalid: false, // do not focus the last invalid input
|
||||
rules: {
|
||||
name: {
|
||||
required: true
|
||||
}
|
||||
},
|
||||
|
||||
messages: {
|
||||
name: {
|
||||
required: "请输入名称"
|
||||
}
|
||||
},
|
||||
|
||||
invalidHandler: function(event, validator) { //display error alert on form submit
|
||||
$('.alert-danger', $('.form')).show();
|
||||
},
|
||||
|
||||
highlight: function(element) { // hightlight error inputs
|
||||
$(element)
|
||||
.closest('.form-group').addClass('has-error'); // set error class to the control group
|
||||
},
|
||||
|
||||
success: function(label) {
|
||||
label.closest('.form-group').removeClass('has-error');
|
||||
label.remove();
|
||||
},
|
||||
|
||||
errorPlacement: function(error, element) {
|
||||
error.insertAfter(element.closest('input'));
|
||||
},
|
||||
|
||||
submitHandler: function(form) {
|
||||
form.submit(); // form validation success, call ajax form submit
|
||||
}
|
||||
});
|
||||
|
||||
$('.form input').keypress(function(e) {
|
||||
if (e.which == 13) {
|
||||
if ($('.form').validate().form()) {
|
||||
$('#form').submit(); //form validation success, call ajax form submit
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
//main function to initiate the module
|
||||
init: function() {
|
||||
|
||||
handleCategoryAdd();
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}();
|
||||
|
||||
jQuery(document).ready(function() {
|
||||
CategoryAdd.init();
|
||||
});
|
||||
|
||||
function addCategory(){
|
||||
|
||||
$.ajax( {
|
||||
url:'/admin/tags/createcategory',
|
||||
data:$('#form').serialize(),
|
||||
type:'POST',
|
||||
processData:true,
|
||||
contentType:"application/x-www-form-urlencoded",
|
||||
success:function(data) {
|
||||
alert(data.status);
|
||||
if(data.status=="success"){
|
||||
window.location.reload(true);
|
||||
}else if(data.status=="fail"){
|
||||
alert(data.data.errMessage);
|
||||
}
|
||||
},
|
||||
error : function(e) {
|
||||
// view("异常!");
|
||||
alert(e);
|
||||
}
|
||||
});
|
||||
}
|
182
frontend/static/admin/pages/scripts/tagList.js
Normal file
182
frontend/static/admin/pages/scripts/tagList.js
Normal file
@@ -0,0 +1,182 @@
|
||||
var url = "/admin/tags/indexjson";
|
||||
|
||||
function refreshList(a){
|
||||
if(a!=0){
|
||||
var urlTmp = url + "?categoryId=" + a;
|
||||
}else var urlTmp = url;
|
||||
|
||||
$('#dataTables-tag').DataTable({
|
||||
"bPaginate": true,
|
||||
"bLengthChange": false,
|
||||
"bSort": false,
|
||||
"bFilter": true,
|
||||
"bAutoWidth": true,
|
||||
"bStateSave": true,
|
||||
"bServerSide": false,
|
||||
"bProcessing":true,
|
||||
"iDisplayLength": 20,
|
||||
"searching": true,
|
||||
"deferRender": true,
|
||||
"bDestroy":true,
|
||||
ajax:{
|
||||
"url" : urlTmp,
|
||||
"dataSrc" : "data"
|
||||
},
|
||||
columns : [
|
||||
{"data" : "id"},
|
||||
{"data" : "name"} ,
|
||||
{"data" : "useCount"},
|
||||
{"data" : "categoryVO.name"}
|
||||
],
|
||||
columnDefs: [
|
||||
{
|
||||
//屏蔽警告
|
||||
sDefaultContent : '',
|
||||
aTargets : [ '_all' ]
|
||||
}
|
||||
],
|
||||
language: {
|
||||
"sProcessing": "处理中...",
|
||||
"sLengthMenu": "显示 _MENU_ 项结果",
|
||||
"sZeroRecords": "没有匹配结果",
|
||||
"sInfo": "显示第 _START_ 至 _END_ 项结果,共 _TOTAL_ 项",
|
||||
"sInfoEmpty": "显示第 0 至 0 项结果,共 0 项",
|
||||
"sInfoFiltered": "(由 _MAX_ 项结果过滤)",
|
||||
"sInfoPostFix": "",
|
||||
"sSearch": "搜索:",
|
||||
"sUrl": "",
|
||||
"sEmptyTable": "表中数据为空",
|
||||
"sLoadingRecords": "载入中...",
|
||||
"sInfoThousands": ",",
|
||||
"oPaginate": {
|
||||
"sFirst": "首页",
|
||||
"sPrevious": "上页",
|
||||
"sNext": "下页",
|
||||
"sLast": "末页"
|
||||
},
|
||||
"oAria": {
|
||||
"sSortAscending": ": 以升序排列此列",
|
||||
"sSortDescending": ": 以降序排列此列"
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function loadCategories(){
|
||||
$.ajax( {
|
||||
url:'/admin/tags/indexcategoryjson',
|
||||
type:'GET',
|
||||
success:function(data) {
|
||||
if(data.status=="success"){
|
||||
for(var i=0;i<data.data.length;i++){
|
||||
var h = "<option value='"+data.data[i].id+"'>"+data.data[i].name+"</option>";
|
||||
$('#category-container').append(h);
|
||||
$('#category-container2').append(h);
|
||||
}
|
||||
$('select').select2();
|
||||
refreshList(data.data[0].id);
|
||||
|
||||
}else if(data.status=="fail"){
|
||||
alert(data.data.errMessage);
|
||||
}
|
||||
},
|
||||
error : function(e) {
|
||||
// view("异常!");
|
||||
alert(e);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
var TagAdd = function() {
|
||||
|
||||
var handleTagAdd = function() {
|
||||
|
||||
$('#form').validate({
|
||||
errorElement: 'span', //default input error message container
|
||||
errorClass: 'help-block', // default input error message class
|
||||
focusInvalid: false, // do not focus the last invalid input
|
||||
rules: {
|
||||
name: {
|
||||
required: true
|
||||
}
|
||||
},
|
||||
|
||||
messages: {
|
||||
name: {
|
||||
required: "请输入名称"
|
||||
}
|
||||
},
|
||||
|
||||
invalidHandler: function(event, validator) { //display error alert on form submit
|
||||
$('.alert-danger', $('.form')).show();
|
||||
},
|
||||
|
||||
highlight: function(element) { // hightlight error inputs
|
||||
$(element)
|
||||
.closest('.form-group').addClass('has-error'); // set error class to the control group
|
||||
},
|
||||
|
||||
success: function(label) {
|
||||
label.closest('.form-group').removeClass('has-error');
|
||||
label.remove();
|
||||
},
|
||||
|
||||
errorPlacement: function(error, element) {
|
||||
error.insertAfter(element.closest('input'));
|
||||
},
|
||||
|
||||
submitHandler: function(form) {
|
||||
form.submit(); // form validation success, call ajax form submit
|
||||
}
|
||||
});
|
||||
|
||||
$('.form input').keypress(function(e) {
|
||||
if (e.which == 13) {
|
||||
if ($('.form').validate().form()) {
|
||||
$('#form').submit(); //form validation success, call ajax form submit
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
//main function to initiate the module
|
||||
init: function() {
|
||||
|
||||
handleTagAdd();
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}();
|
||||
|
||||
jQuery(document).ready(function() {
|
||||
TagAdd.init();
|
||||
});
|
||||
|
||||
function addTag(){
|
||||
|
||||
$.ajax( {
|
||||
url:'/admin/tags/create',
|
||||
data:$('#form').serialize(),
|
||||
type:'POST',
|
||||
processData:true,
|
||||
contentType:"application/x-www-form-urlencoded",
|
||||
success:function(data) {
|
||||
alert(data.status);
|
||||
if(data.status=="success"){
|
||||
window.location.reload(true);
|
||||
}else if(data.status=="fail"){
|
||||
alert(data.data.errMessage);
|
||||
}
|
||||
},
|
||||
error : function(e) {
|
||||
// view("异常!");
|
||||
alert(e);
|
||||
}
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user