Commit de7811d6 authored by Sergey Antonovich's avatar Sergey Antonovich 🇯🇵

Add new file

parent 205da63b
Pipeline #55 canceled with stages
AS.FORMS.bus.on('formShow',function(event,fModel,fView){
fModel.on('dataLoad',function(event,dModel){
if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)){
var __checkInvalidErrors = function(){
$('.asf-invalidInput').each(function(k,i){
var block = $(i).parent();
if($(i).hasClass('asf-invalidInput')){
//block.find('.asf-label').css('color','rgb(255, 19, 0)');
block.find('.asf-label').addClass('mw-invalid-label-color-error');
block.addClass('mw-invalid-color-error');
//block.css('border-bottom-color','rgb(255, 19, 0)');
if($(i).hasClass('asf-container'))
//$(i).css('border-bottom-color','rgb(255, 19, 0)');
$(i).addClass('mw-invalid-color-error');
$(i).removeClass('asf-invalidInput');
}else{
block.find('.asf-label').addClass('mw-invalid-label-color-success');
//block.find('.asf-label').css('color','rgb(63, 162, 63)');
//block.css('border-bottom-color','rgb(187, 187, 187)');
block.addClass('mw-invalid-color-success');
}
});
};
var __select = function(combobox){
var items = combobox.listElements.slice();
if(!Array.isArray(items)) items = [items];
items.forEach(function(item,key){
items[key] = '<option value="' + item.value + '"' + (combobox.getValue() == item.value ? ' selected' : '') + '>' + item.label + '</option>'
});
var box = $('<select class="mobile-window-system-select">' + items.join('') + '</select>');
box.on('change',function(){
combobox.setValue(""+box.val());
});
var container = $(fView.getViewWithId(combobox.asfProperty.id).container);
container.append(box);
container.find('.asf-dropdown-button').off();
container.find('.asf-dropdown-input').off();
};
var __date = function(date){
var container = $(fView.getViewWithId(date.asfProperty.id).container);
var box = $('<input type="date" class="mobile-window-system-date">');
var curDate = new Date(""+date.getValue());
var month = {0: '01',1: '02',2: '03',3: '04',4: '05',5: '06',6: '07',7: '08',8: '09',9: '10',10: '11',11: '12'}[curDate.getMonth()];
box.on('change',function(){
AS.FORMS.ApiUtils.formatDate($(this).val() + ' 00:00:00',date.asfProperty.config.dateFormat).then(function(resFormatDate){
date.setValue("" + resFormatDate);
if(resFormatDate){
container.find('.asf-label').animate({
'top': '0',
'font-size':'10px',
'color': 'rgb(63, 162, 63)'
},200);
container.animate({'border-bottom-color':'rgb(63, 162, 63)'},200);
container.find('.asf-dateBox').animate({'opacity':'1'},200);
}else{
container.find('.asf-label').animate({
'top': container.find('.mobile-window-systemAlign').position().top,
'font-size':'12px',
'color': 'rgb(187, 187, 187)'
},200);
container.animate({'border-bottom-color':'rgb(187, 187, 187)'},200);
container.find('.asf-dateBox').animate({'opacity':'0'},200);
}
});
});
box.val(curDate.getFullYear()+'.'+month+curDate.getDate());
container.append(box);
container.find('.asf-calendar-button').off();
container.find('.asf-dateBox').off();
};
$('.mobile-window-system-date').remove();
$('.mobile-window-system-select').remove();
$('.asf-emptyCell').parent().hide();
fModel.value.data.forEach(function(item){
var container = $(fView.getViewWithId(item.id).container);
var parent = container.parent();
$('<div class="mobile-window-systemAlign"></div>').appendTo(container);
container.parent().attr('colspan','1');
var placeholder = (fView.getViewWithId(item.id + '-label') ? ""+dModel.getModelWithId(item.id + '-label').getValue() : false);
/**
* Является ли компонент скрытым - для скрытия его в мобильной версии
*/
var visible = !container.is(':visible');
/**
* Переопределение отображения компонентов по их типу
*/
switch(item.type.toLowerCase()){
/**
* LABEL
*/
case 'label':
container.css({
'border': '0',
'border-radius': '0',
'border-bottom': '1px solid rgb(187, 187, 187)',
'display':'flex',
'align-items':'center'
});
if(!/title$/.test(item.id)){
parent.hide();
}else{
container.find('.asf-label').css({
'position':'relative',
'color':'#000',
'padding-bottom':'5px'
});
}
break;
/**
* TEXTBOX & NUMERICINPUT
*/
case 'textbox':
case 'numericinput':
var box = $('<div class="mobile-window-system-box"></div>');
box.css('opacity','1');
box.on('click',function(){
container.find('input').focus();
$(this).hide();
container.find('input').animate({'opacity':'1'},200);
});
container.append(box);
container.css({
'border': '0',
'border-radius': '0',
'border-bottom': '1px solid rgb(187, 187, 187)',
'display':'flex',
'align-items':'center'
});
container.css('min-height','35px');
container.find('.asf-label').text(placeholder ? placeholder : '');
container.find('.asf-label').click(function(){
container.find('input').focus();
});
container.find('input').css({
'padding-left': '6px',
'padding-top': '5px',
'opacity':'0'
});
container.find('input').attr('placeholder','');
container.find('input').focus(function(){
if($(this).val() && dModel.getModelWithId(item.id).inputUtils.defaultValue != $(this).val()) return;
$(this).parent().find('.asf-label').animate({
'top': '0',
'font-size':'10px',
'color': 'rgb(63, 162, 63)'
}, 200);
container.animate({
'border-bottom-color': 'rgb(63, 162, 63)'
},200);
container.find('.mobile-window-system-box').hide();
container.find('input').animate({'opacity':'1'},200);
});
container.find('input').blur(function(){
if(!$(this).val() || dModel.getModelWithId(item.id).inputUtils.defaultValue == $(this).val()){
$(this).parent().find('.asf-label').animate({
'top': container.find('.mobile-window-systemAlign').position().top,
'font-size':'12px',
'color': '#a0a0a0'
}, 200);
container.animate({
'border-bottom-color': '#a0a0a0'
},200);
container.find('.mobile-window-system-box').show();
container.find('input').animate({'opacity':'0'},200);
}
});
container.find('input').on('input',function(){
if($(this).hasClass('asf-invalidInput')){
$(this).parent().find('.asf-label').css('color','rgb(255, 19, 0)');
$(this).parent().css('border-bottom-color','rgb(255, 19, 0)');
}else{
if($(this).val()){
$(this).parent().find('.asf-label').css('color','rgb(63, 162, 63)');
$(this).parent().css('border-bottom-color','rgb(63, 162, 63)');
}else{
$(this).parent().find('.asf-label').css('color','rgb(187, 187, 187)');
$(this).parent().css('border-bottom-color','rgb(187, 187, 187)');
}
}
});
break;
/**
* TEXTAREA
*/
case 'textarea':
container.css({
'border': '0',
'border-radius': '0',
'border-bottom': '1px solid rgb(187, 187, 187)',
'display':'flex',
'align-items':'center'
});
container.css({
'min-height':'65px'
});
container.find('.asf-label').text(placeholder ? placeholder : '');
container.find('.asf-label').click(function(){
container.find('textarea').focus();
});
container.find('textarea').css({
'padding-left': '6px',
'padding-top': '10px',
'resize':'none'
});
container.find('textarea').attr('placeholder','');
container.find('textarea').focus(function(){
if($(this).val()) return;
$(this).parent().find('.asf-label').animate({
'top': '0',
'font-size':'10px',
'color': 'rgb(63, 162, 63)'
}, 200);
container.animate({
'border-bottom-color': 'rgb(63, 162, 63)'
},200);
});
container.find('textarea').blur(function(){
if(!$(this).val()){
$(this).parent().find('.asf-label').animate({
'top': container.find('.mobile-window-systemAlign').position().top,
'font-size':'12px',
'color': '#a0a0a0'
}, 200);
container.animate({
'border-bottom-color': '#a0a0a0'
},200);
}
});
container.find('textarea').on('textarea',function(){
if($(this).hasClass('asf-invalidInput')){
$(this).parent().css('border-bottom-color','rgb(255, 19, 0)');
}else{
$(this).parent().css('border-bottom-color','rgb(187, 187, 187)');
}
});
break;
/**
* LISTBOX
*/
case 'listbox':
__select(dModel.getModelWithId(item.id));
container.find('.asf-label').text(placeholder ? placeholder : '');
container.find('.asf-label').click(function(){
container.find('textarea').focus();
});
container.css({
'border': '0',
'border-radius': '0',
'border-bottom': '1px solid rgb(187, 187, 187)',
'padding': '5px 0 5px 5px',
'width':'calc(100% - 5px)'
});
container.css({
'display':'block'
});
container.find('.asf-dropdown-input').css({
'border':'0',
'padding-top': '4px'
});
container.find('.asf-dropdown-button').css({
'background':'url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDII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//8/AyWAiYFCMPAGsCBzEhMTidI0f/58nC6IYmBg+E8ARyFrYESPhcTExMMMDAw2OCw/Mn/+fFtCYZDLwMDwF4v4X6gc/kCcP3/+BQYGhllYDJgFlSMqFmoYGBjeIfHfQcWIi8b58+e/Y2Bg6EYS6oaKkZQO+hgYGO5AcR8uRYz48kJiYqI31EVbyTJgaOQFADeMNnXEP4BrAAAAAElFTkSuQmCC) no-repeat center',
'border':'0'
});
container.find('input').on('input',function(){
if($(this).hasClass('asf-invalidInput')){
$(this).parent().find('.asf-label').css('color','rgb(255, 19, 0)');
$(this).parent().css('border-bottom-color','rgb(255, 19, 0)');
}else{
$(this).parent().find('.asf-label').css('color','rgb(63, 162, 63)');
$(this).parent().css('border-bottom-color','rgb(187, 187, 187)');
}
});
if($(container).find('.asf-dropdown-input').text()){
container.find('.asf-label').css('color','rgb(63, 162, 63)');
container.css('border-bottom-color','rgb(63, 162, 63)');
}else{
container.find('.asf-label').css('color','#a0a0a0');
container.css('border-bottom-color','#a0a0a0');
}
dModel.getModelWithId(item.id).on('valueChange',function(){
var curModel = dModel.getModelWithId(item.id);
if(!curModel.getTextValue()){
container.find('.asf-label').animate({
'top': (parseInt(container.find('.mobile-window-systemAlign').position().top) - 20) + 'px',
'font-size':'12px',
'color': '#a0a0a0'
}, 200);
container.animate({
'border-bottom-color': '#a0a0a0'
},200);
}else{
container.find('.asf-label').animate({
'top': '0',
'font-size':'10px',
'color': 'rgb(63, 162, 63)'
}, 200);
container.animate({
'border-bottom-color': 'rgb(63, 162, 63)'
},200);
}
});
if(!dModel.getModelWithId(item.id).getTextValue()){
container.find('.asf-label').animate({
'top': (parseInt(container.find('.mobile-window-systemAlign').position().top) - 20) + 'px',
'font-size':'12px',
'color': '#a0a0a0'
}, 200);
container.animate({
'border-bottom-color': '#a0a0a0'
},200);
}else{
container.find('.asf-label').animate({
'top': '0',
'font-size':'10px',
'color': 'rgb(63, 162, 63)'
}, 200);
container.animate({
'border-bottom-color': 'rgb(63, 162, 63)'
},200);
}
break;
/**
* CHECKBOX & RADIOBOX
*/
case 'check':
case 'radio':
dModel.getModelWithId(item.id).on('dataLoad',function(){
var customLabel = $('<div class="asf-label" id="mw-label-listbox">' + (placeholder ? placeholder : '') + '</div>');
customLabel.css({
'top': '0',
'font-size':'10px'
});
$(container).prepend(customLabel);
dModel.getModelWithId(item.id).on('valueChange',function(){
if(dModel.getModelWithId(item.id).getValue()){
container.find('.asf-label').css({
'color':'rgb(63, 162, 63)'
});
container.css({
'border-bottom': '1px solid rgb(63, 162, 63)',
});
}else{
container.find('.asf-label').css({
'color':'rgb(187, 187, 187)'
});
container.css({
'border-bottom': '1px solid rgb(187, 187, 187)',
});
}
});
if(dModel.getModelWithId(item.id).getValue()){
container.find('.asf-label').css({
'color':'rgb(63, 162, 63)'
});
container.css({
'border-bottom': '1px solid rgb(63, 162, 63)',
});
}else{
container.find('.asf-label').css({
'color':'rgb(187, 187, 187)'
});
container.css({
'border-bottom': '1px solid rgb(187, 187, 187)',
});
}
});
break;
/**
* DATE
*/
case 'date':
__date(dModel.getModelWithId(item.id));
container.find('.asf-label').text(placeholder ? placeholder : '');
container.css({
'width':'100%',
'border-bottom': '1px solid rgb(187, 187, 187)',
'display':'flex',
'align-items':'center'
});
container.find('.asf-calendar-button').css({
'background':'url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABdElEQVR42q2SvyuFURjHr4GyyialDBbE7XblHzCyeBfD+7Pe/OjeLGInSSyyyCIDGQzqKkooRQbJYmJQSqF0Jwxcn6eeo4OX3sGtT88533PO9z7fc95M5r9/nuet+b6//l0PgmAO/SDxUBiGLSw6bMqKgZp0iKZ6lxjAPvM20VzXbf80QDiHCmyzqQ+DXuqWasIJWg91AFZVu7ENrq3Ni7BgzQ0rGsPM722DW9iDAowrBQ4MCZY+QSdF6iaUbYNHFibTXrSaPts3/wDTjuPUsHAGp9CEdkS9oDZTdzh4GcdxPePhHwYsTmFQy8IbvOhtlyUvN96pMWXckNgBwqy2l5UDDKvkqXjinIyjKGplntfIo4kRaK9aL3MXo0ZqCQ4lDvMNOMaojr0jf0WQJ3qXf9coFelKnk3HYjyYFGFGv8qcaVvj5E0c6Nb9xS8G8owwL69gNInz25i9Y9KdbXClt3+Xkld4sj+MfliSzzUNRFiGWM5+AHf0L2rZe6f2AAAAAElFTkSuQmCC) no-repeat center',
'border':'0'
});
container.find('.asf-dateBox').css({
'width':'100%',
'max-width':'unset',
'border':'0',
'border-radius':'0',
'opacity':'0'
});
if(dModel.getModelWithId(item.id).getValue()){
container.find('.asf-label').css({
'top': '0',
'font-size':'10px',
'color': 'rgb(63, 162, 63)'
});
container.css('border-bottom-color','rgb(63, 162, 63)');
container.find('.asf-dateBox').css('opacity','1');
}else{
container.find('.asf-label').css({
'top': container.find('.mobile-window-systemAlign').position().top,
'font-size':'12px',
'color': 'rgb(187, 187, 187)'
});
container.css('border-bottom-color','rgb(187, 187, 187)');
}
break;
}
if(visible) container.hide();
});
}
$(fView.container).append('<div style="display: flex;justify-content: center;align-items: center;"><div class="send" style=" padding: 15px 20px;background: #557fd2;color: #fff;font-weight: bold;font-size: 14px;min-width: 150px;min-height: 15px; text-align: center; cursor: pointer;">Send Form</div></div>')
$(fView.container).find('.send').on('click',function(){
if(portal.player.model.getErrors().length > 0){
__checkInvalidErrors();
}else{
// You`r code
}
});
});
});
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment