//Layer.open と Layer.confirm の共存
$(document).on("click", ".setTemplate", function (index,raw){
var area = ['40%','40%'];
Layer.open({
content: Template("setTemplateTpl",[]),
zIndex: 99,
area: area,
title: __('Set Template Name'),
resize: false,
type:1,
btn: [__('Confirm'), __('Close')],
yes: function (index, layero) {
let tplName = $('#tplName').val()
if (!tplName){
Toastr.error(__('Cannot be empty'));
return false
}
var templateJson = {};
var formData = $('form').serializeArray();
$.each(formData, function() {
if ($.inArray(this.name,['__token__','begin_time','loop_switch']) < 0){
templateJson[this.name] = this.value;
}
});
let row = {
name: tplName,
templateJson:JSON.stringify(templateJson)
}
let content = __('テンプレートを保存しますか?');
Layer.confirm(content, {
type:0,
btn: [__('OK'),__('Cancel')] //ボタン
}, function(){
Fast.api.ajax({
url: "game/game/setTemplate",
data: {
row:row
}
}, function (data) {
layer.closeAll();
},function (){
layer.closeAll('dialog');
});
//Layer.closeAll();
}, function(){
Layer.closeAll('dialog');
});
},
btn2: function(index, layero){
//ボタン【ボタン二】のコールバック
layer.close(index)
//return false //このボタンを無効にする
},
success: function (layero, index) {
//時間コントロールをバインド
Form.events.datetimepicker($("form"));
}
});
/*let content = __('テンプレートを保存しますか?');
Layer.confirm(content, {
btn: [__('OK'),__('Cancel')] //ボタン
}, function(){
Fast.api.open("game/game/setTemplate", __('テンプレート名を設定'), {
area:['400px', '200px']
});
Layer.closeAll('dialog');
}, function(){
Layer.closeAll('dialog');
});*/
})
//ボタンアプリケーション と Layer.open のバインド時間コントロール
{field: 'operate', title: __('Operate'), table: table, events: {
'click .btn-chooseone': function (e, value, row, index) {
if (row.game_mode == 3 && row.play_mode == 0){
var area = ['60%','80%'];
Layer.open({
content: Template("selectTimeTpl",[]),
zIndex: 99,
area: area,
title: __('Begin_time'),
resize: false,
btn: [__('Confirm'), __('Close')],
yes: function (index, layero) {
let begin_time = $('#begin_time').val()
if (!begin_time){
Toastr.error(__('Cannot be empty'));
return false
}
let templateJson = row.templateJson
templateJson.begin_time = begin_time
Fast.api.close({templateJson: templateJson});
layer.closeAll();
},
btn2: function(index, layero){
//ボタン【ボタン二】のコールバック
layer.close(index)
//return false //このボタンを無効にする
},
success: function (layero, index) {
//時間コントロールをバインド
Form.events.datetimepicker($("form"));
}
});
}else{
let content = __('テンプレートを使用しますか?');
Layer.confirm(content, {
btn: [__('OK'),__('Cancel')] //ボタン
}, function(){
Fast.api.close({templateJson: row.templateJson});
Layer.closeAll('dialog');
}, function(){
Layer.closeAll('dialog');
});
}
},
}, formatter: function () {
return '<a href="javascript:;" class="btn btn-danger btn-chooseone btn-xs"><i class="fa fa-check"></i> ' + __('Use Template') + '</a>';
},
},