// MODAL
var modal_flg = false;
$(document).on('click', '.modal-btn-open', function(){
if(modal_flg){ return; }
modal_flg = true;
var modal_url = $(this).attr('data-modal-url');
if(!modal_url){ modal_url = $(this).attr('href'); }
var modal_style = $(this).attr('data-modal-style');
var html = '
';
$('body').append(html);
wjs_modal_open();
return false;
});
$(document).on('click', '.confirm-btn-open', function(){
if(modal_flg){ return; }
modal_flg = true;
var modal_url = $(this).attr('data-modal-url');
if(!modal_url){ modal_url = $(this).attr('href'); }
var html = '';
$('body').append(html);
wjs_modal_open();
return false;
});
function wjs_modal_open(){ $('#modal-iframe').modal('show'); }
function wjs_modal_close(){
$('#modal-iframe').modal('hide');
$('#modal-iframe').remove();
modal_flg = false;
};
$(document).on('click', '.modal-btn-close', function(){
parent.wjs_modal_close();
return false;
});
function wjs_update_contents(obj){
var contents_url = $(obj).attr('data-contents-url');
$.ajax({
url: contents_url,
cache: false,
success: function(html){
$(obj).after(html);
$(obj).remove();
}
});
}
function wjs_entry_loading(json_url, target){
$(target).append(' 読み込み中..
');
$(target).find('.nextloading').remove();
$.ajax({
url:json_url,
dataType: 'json',
success: function(data){
$(target).find('.nowloading').remove();
if(data['found'] <= 0){
$(target).append('データがありません。
');
return;
}
for(var i=0; i次を読み込む');
}
}
});
return true;
}
$(function(){
__wjs__wjsblocklist__init_();
});
function __wjs__wjsblocklist__init_(){
var objlist = {};
$('.form-multiple').each(function(i, val){
var category = $(val).attr('id');
category = category.replace( /[0-9]+$/g , "" );
objlist[category] = objlist[category]?objlist[category]:[];
objlist[category].push(val);
});
for(var key in objlist){
var grouplist = objlist[key];
for(var i=0; i this.minGroupNum){ this.minGroupNum = this.groupNum; }
// Modelに合わせてスキーマ追加
var keys = [];
if(Array.isArray(this.modelName)){
keys = Object.keys(this.app[this.modelName[0]][this.modelName[1]]);
}else{
keys = Object.keys(this.app[this.modelName]);
}
for(var i=0; i 0 && groupKeys.length >= this.maxGroupNum){
this.removeButtons('add');
}else{
this.appendButtons('add');
}
if(groupKeys.length == 1){
this.removeButtons('exchange');
}else{
this.appendButtons('exchange');
}
if(groupKeys.length == 1 || (this.minGroupNum > 0 && this.minGroupNum >= groupKeys.length)){
this.removeButtons('delete');
}else{
this.appendButtons('delete');
}
for(var i=0; i= addGroupNo){
for(var i=group_keys.length; i>=addGroupNo; i--){
var new_key = this.groupName+('000'+(i+1)).substr(-2);
var old_key = this.groupName+('000'+i).substr(-2);
app.$set(model, new_key, Object.assign({}, JSON.parse(JSON.stringify(model[old_key]))));
// console.log(['move', new_key, old_key]);
}
}
// Modelを初期化
var key = this.groupName+('000'+addGroupNo).substr(-2);
app.$set(model, key, Object.assign({}, JSON.parse(JSON.stringify(this.defaultModel))));
// app.saveSetting();
// console.log('model');
// console.log(model);
}
exchangeModel (model, exchangeGroupNo){
// グループリスト取得
var group_keys = this.getGroupList();
if(exchangeGroupNo >= group_keys.length){ return; }
var new_key = this.groupName+('000'+(exchangeGroupNo+1)).substr(-2);
var old_key = this.groupName+('000'+exchangeGroupNo).substr(-2);
if(!model[new_key]){ app.$set(model, new_key, Object.assign({}, JSON.parse(JSON.stringify(this.defaultModel)))); }
if(!model[old_key]){ app.$set(model, old_key, Object.assign({}, JSON.parse(JSON.stringify(this.defaultModel)))); }
var obj = Object.assign({}, JSON.parse(JSON.stringify(model[new_key])));
app.$set(model, new_key, Object.assign({}, JSON.parse(JSON.stringify(model[old_key]))));
app.$set(model, old_key, obj);
// app.saveSetting();
}
removeModel (model, removeGroupNo){
// グループリスト取得
var group_keys = this.getGroupList();
// 以降のModelの番号変更
if(group_keys.length > removeGroupNo){
for(var i=removeGroupNo; i= this.maxGroupNum){
alert('これ以上追加できません');
return;
}
this.appendModel(model, addGroupNo);
this.appendSchema();
this.manageButtons();
}
onDelete (model, field) {
var delGroupNo = field.groupNo;
// グループリスト取得
var group_keys = this.getGroupList();
if(group_keys.length == 1 || group_keys.length <= this.minGroupNum){
alert('これ削除できません');
return;
}
this.removeModel(model, delGroupNo);
this.removeSchema();
this.manageButtons();
}
onExchange (model, field) {
// console.log('onExchange');
// console.log(model);
// console.log(field);
var exchangeGroupNo = field.groupNo;
this.exchangeModel(model, exchangeGroupNo);
}
};
function wjs_set_group_form(app, schema, modelName) {
var groupNameHash = {};
if(schema && schema.groups){
for(var i=0; i'+
''+
''+
''+
'',
props: {
value: {default: null},
accept: {default: 'image/*'},
label: {default: ''},
data: {default: {
image: null,
name: null,
type: null
}},
},
methods: {
deleteFile: function(){
this.$emit('input', '');
this.$emit('change');
},
setImage: function(e){
var file = (e.target.files || e.dataTransfer.files)[0];
if (file !== undefined && file !== null) {
if (file.name.lastIndexOf('.') <= 0) { return }
const fr = new FileReader()
fr.readAsDataURL(file)
fr.addEventListener('load', () => {
var imageData = fr.result;
return new Promise((resolve, reject) => {
setTimeout(() => {
const url = 'uploadImage?t='+(new Date()).getTime();
axios.post(url, {
image: imageData
})
.then(response => {
this.$emit('input', response.data.url);
this.$emit('change');
})
.catch(response => {});
},0)
});
})
} else {
}
}
}
});
// スクロールfix
jQuery(function() {
function fixFunction() {
var fixClass = 'is-fixed';
var fixEndClass = 'is-fixed-end';
var fixElement = jQuery('.scrollfix');
if(fixElement.length == 0){ return; }
var parent = fixElement.parent();
// console.log([parent.height(), fixElement.outerHeight()])
if(parent.height() <= fixElement.outerHeight()){
fixElement.removeClass([fixClass, fixEndClass]);
return;
}
if(!parent.hasClass('scrollfix-parent')){ parent.addClass('scrollfix-parent'); }
fixEnd = parent.offset().top + parent.outerHeight() - fixElement.outerHeight();
var baseFixPoint = -999;
if(!fixElement.hasClass(fixClass)){
baseFixPoint = fixElement.offset().top;
fixElement.attr('data-init-top', baseFixPoint);
}else{
baseFixPoint = fixElement.attr('data-init-top');
}
var windowScrolltop = jQuery(window).scrollTop();
// console.log([windowScrolltop, baseFixPoint, fixEnd]);
if(windowScrolltop >= fixEnd) {
fixElement.addClass([fixClass, fixEndClass]);
}else if(windowScrolltop >= baseFixPoint) {
fixElement.removeClass(fixEndClass).addClass(fixClass);
} else {
fixElement.removeClass([fixClass, fixEndClass]);
}
}
jQuery(window).on('load scroll', function() {
fixFunction();
});
});