From 89011a09fd5294970dde76a041f9859383fe59dc Mon Sep 17 00:00:00 2001
From: themohooks <81331307+themohooks@users.noreply.github.com>
Date: Fri, 5 Jul 2024 07:59:53 +0300
Subject: [PATCH] add form upload support
---
static/js/core_lk.js | 206 +---------------------------
static/js/imageupload.js | 58 +-------
views/components/LoadHead.php | 61 +++++++-
views/pages/Profile/UploadPhoto.php | 124 ++++++++++++++++-
4 files changed, 184 insertions(+), 265 deletions(-)
diff --git a/static/js/core_lk.js b/static/js/core_lk.js
index d3720de..c7d3ed2 100644
--- a/static/js/core_lk.js
+++ b/static/js/core_lk.js
@@ -86,107 +86,7 @@ $(document).ready(function()
});
- // Строка добавления нового ТС
- $('#vlist').on('mouseenter mouseleave', '#add_new_vehicle', function()
- {
- var state = parseInt($(this).data('state'));
- $(this).toggleClass('s' + state + ' s' + (state+10));
- })
- .on('click', '#add_new_vehicle', function()
- {
- new_vehicle_idx++;
-
- var nid = -new_vehicle_idx;
-
- var cid = $('#search_cid').val();
- var num = $('#search_num').val();
- var gos = $('#search_gos').val();
- var type = $('#search_type').val();
- var cname = $('#cname').val();
- var by_gos = ($(this).attr('bygos') == 1);
-
- var html = '
\n';
-
- html += '\n';
- html += '' + (by_gos ? gos : num) + ' | \n';
- html += '' + $('#search_type option:selected').html() + ' | \n';
- html += '' + _text['UP_ROUTE'] + ': | \n';
- html += ', | \n';
- html += '× | \n';
- html += '
\n';
-
- html += '\n';
- html += '' + cname + ' | \n';
- html += '' + _text['VIEW'] + ': | \n';
- html += '' + views[0] + ' | \n';
- html += '
\n';
-
- html += '\n';
- html += ' | \n';
- html += '' + _text['UP_BIND'] + ': | \n';
- html += '' + binds[0].label + ' | \n';
- html += '
\n';
-
- html += '\n';
- html += '' + _text['UP_LOADING'] + ' | \n';
- html += '
\n';
-
- html += '\n';
-
- var row = $(html);
- $('#conn_veh').append(row).show().tablesort('recountRows');
- $('.pri-label', row).selector2(binds);
-
- $('.no-links').hide();
-
- cnames[cid] = cname;
-
-
- var form = $('.new_vehicle_template').clone(true).removeClass('new_vehicle_template').show();
-
- $('select[name="nv_service[]"]', form).change();
- $('select[name="nv_state[]"]', form).change();
-
- $('input[name="nv_cid[]"]', form).val(cid);
- $('input[name="nv_type[]"]', form).val(type);
- $('input[name="nv_num[]"]', form).val(num);
- $('input[name="nv_gos[]"]', form).val(gos);
-
- if (by_gos)
- $('.tbody_nv_num', form).css('display', '');
- else $('.tbody_nv_gos', form).css('display', '');
-
- $.get('/api.php', { action: 'get-depot-list', cid: cid }, function(data)
- {
- $('.did', form).html(data);
- $('.tbody_nv_did', form).css('display', (data != '') ? '' : 'none');
-
- $('#new_vehicle_' + new_vehicle_idx).empty().append(form);
-
- $('input[name="nv_mid[]"]', form).attr('id', 'mid_' + new_vehicle_idx);
- $('input[name="nv_chid[]"]', form).attr('id', 'chid_' + new_vehicle_idx);
-
- var nv_type = $('input[name="nv_type[]"]', form);
-
- $('.mname', form).autocompleteSelector('mid_' + new_vehicle_idx, '/api.php?action=get-models', {
- minLength: 1,
- paramsCallback: function(params) { params.type = nv_type.val(); },
- selectCallback: function(item) { form.closest('tbody').data('twoside', item.twoside); }
- });
-
- $('.chname', form).autocompleteSelector('chid_' + new_vehicle_idx, '/api.php?action=get-chassis', {
- minLength: 1,
- paramsCallback: function(params) { params.type = nv_type.val(); }
- });
-
- $('.did', form).select2();
-
- showDefaultCity();
- })
- .fail(function(jx) { alert(jx.responseText); });
-
- modify();
- });
+
@@ -409,110 +309,6 @@ function showDefaultCity()
-function checkForm()
-{
- var i, err = '';
-
- function addError(txt) { err += '' + txt + '.
'; }
-
- var image = $('#image');
- if (!pid && image.val() == '')
- {
- $('#step1')[0].scrollIntoView();
- image.focus();
- alert(_text['UP_NOFILE'] + '.');
- return false;
- }
-
- // Проверяем наличие привязок вообще
- if ($('#links input').length == 0)
- {
- $('#step2')[0].scrollIntoView();
- alert(_text['UP_NOLINKS'] + '.');
- return false;
- }
-
- if ($('#conn_veh .pri-value[value="1"]').length == 0 &&
- $('#conn_veh .pri-value[value="2"]').length == 0 &&
- $('#conn_gid tr').length == 0)
- {
- $('#step2')[0].scrollIntoView();
- alert(_text['UP_NO_PRI']);
- return false;
- }
-
-
- // Проверим, указаны ли ракурсы
- if ($('.view[value="0"]').length > 0)
- {
- $('#step2')[0].scrollIntoView();
- alert(_text['UP_NOVIEW']);
- return false;
- }
-
-
- // Проверим корректность привязки творческой фотографии
- if ($('#creative').val() == 1 && ($('#conn_veh input[name="nids[]"]').length || $('#conn_gid input[name="gids[]"]').length > 1))
- {
- $('#step2')[0].scrollIntoView();
- alert(_text['UP_CREATIVE']);
- return false;
- }
-
-
- // Проверяем наличие даты
- if ($('#year').val() == 0 && !confirm(_text['UP_NODATE'] + '.'))
- {
- $('#step1')[0].scrollIntoView();
- return false;
- }
-
-
- // Проверяем разрешение на публикацию
- if ($('#naa_hint').is(':visible') && $('#naa_allow').val().trim() == '')
- {
- alert(_text['UP_NAA_ALLOW_NO']);
- $('#step1')[3].scrollIntoView();
- return false;
- }
-
-
- // Уточняем, правильно ли, что выбрано "города нет в списке"
- var cid = $('#main-cid').val();
- if (pid == 0 && cid == 0 && !confirm(_text['UP_NOCITY'])) return false;
-
- // Уточняем, если город не соответствует привязкам
- if (cid != 0 && cnames[cid] == undefined && !confirm(_text['UP_OTHERCITY'])) return false;
-
-
- // Проверяем наличие МС
- if ($('.view[value="9"], .view[value="10"], .view[value="11"], .view[value="12"]').length == 0 && $('#place').val().trim() == '' && !confirm(_text['UP_NOPLACE'] + '.'))
- {
- $('#step3')[0].scrollIntoView();
- return false;
- }
-
-
- // Проверяем правильность указания координат
- if (!$('#nomap').prop('checked'))
- {
- if ($('#lat').val() == 0.0 || $('#lng').val() == 0.0)
- {
- $('#step4')[0].scrollIntoView();
- alert(_text['UP_NOCOORDS']);
- return false;
- }
-
- if ($('#directions input:checked').length == 0)
- {
- $('#step4')[0].scrollIntoView();
- alert(_text['UP_NODIR']);
- return false;
- }
- }
-
- return true;
-}
diff --git a/static/js/imageupload.js b/static/js/imageupload.js
index d6b81a5..3a7f626 100644
--- a/static/js/imageupload.js
+++ b/static/js/imageupload.js
@@ -18,7 +18,7 @@ function roundEx(n)
function cannotUpload(input, e)
{
- alert(e + '.');
+ console.log(e);
$(input).val('');
$('#filename, #preview').html('');
}
@@ -44,61 +44,7 @@ function checkImageForUpload(input, checksize, successCallback)
var img = new Image();
img.onload = function()
{
- var warn = '', need_resize = false;
-
- if (checksize)
- {
- try
- {
- if (UPLOAD_MIN_PX &&
- (
- (img.width >= img.height && img.width < UPLOAD_MIN_PX) ||
- (img.width < img.height && img.height < UPLOAD_MIN_PX)
- )
- ) throw formatUploadError(_text['UP_TOOSMALL'], img.width > img.height ? img.width : img.height, UPLOAD_MIN_PX);
-
- if (((ext == 'jpg' || ext == 'webp') && UPLOAD_JPG_MAX_PX && img.width + img.height > UPLOAD_JPG_MAX_PX) ||
- ((ext != 'jpg' && ext != 'webp') && UPLOAD_PNG_MAX_PX && img.width > UPLOAD_PNG_MAX_PX && img.height > UPLOAD_PNG_MAX_PX))
- {
- // Если нужно уменьшить - уменьшаем
- if (UPLOAD_STD_PX && (ext == 'jpg' || ext == 'webp'))
- {
- need_resize = true;
- warn = formatUploadError(_text['UP_NEEDRESIZE'], UPLOAD_JPG_MAX_PX, UPLOAD_STD_PX);
- }
- else
- if (!can_upload_oversized)
- {
- if (ext == 'jpg' || ext == 'webp')
- throw formatUploadError(_text['UP_OVERSIZE_JPG'], img.width + img.height, UPLOAD_JPG_MAX_PX);
- else throw formatUploadError(_text['UP_OVERSIZE_PNG'], img.width > img.height ? img.width : img.height, UPLOAD_PNG_MAX_PX);
- }
- }
-
- if (!need_resize)
- {
- var max_size;
-
- if ((ext == 'jpg' || ext == 'webp') && !can_upload_oversized)
- max_size = maxsize;
- else max_size = UPLOAD_MAX_SIZE * 1024;
-
- if (size > max_size)
- {
- if (ext == 'jpg' || ext == 'webp')
- throw formatUploadError(_text['UP_LARGEFILE_JPG'], Math.ceil(size), max_size);
- else throw formatUploadError(_text['UP_LARGEFILE_PNG'], roundEx(size / 1024), UPLOAD_MAX_SIZE);
- }
- }
- }
- catch (e)
- {
- cannotUpload(input, e);
- return;
- }
- }
-
- $('#preview').html((warn ? '' + warn + '.
' : '') + '
');
+
if (successCallback) successCallback(input);
};
diff --git a/views/components/LoadHead.php b/views/components/LoadHead.php
index aa0b125..4b67245 100644
--- a/views/components/LoadHead.php
+++ b/views/components/LoadHead.php
@@ -30,7 +30,19 @@
display: block;
}
+@media screen and (max-width: 768px) {
+ :root {
+ --bckgr: -1500px 0;
+ --bckgr2: 1500px 0;
+ }
+ }
+ @media screen and (min-width: 768px) {
+ :root {
+ --bckgr: -3500px 0;
+ --bckgr2: 3500px 0;
+ }
+ }
@-webkit-keyframes bg-move {
0% { background-position: var(--bckgr); }
100% { background-position: var(--bckgr2); }
@@ -41,14 +53,57 @@
}
.progress-bard {
- background-color: #3862eb;
+ background-color: var(--theme-bg-color);
width: 0%;
display: block;
height: inherit;
transition: width 0.6s ease;
- background-image: linear-gradient(270deg, rgba(100, 181, 239, 0) 48.44%, #64b5ef 75.52%, rgba(100, 181, 239, 0) 100%);
+ background-image: linear-gradient(270deg, rgba(100, 181, 239, 0) 48.44%, var(--theme-bg-hover-color) 75.52%, rgba(100, 181, 239, 0) 100%);
background-repeat: no-repeat;
animation: bg-move linear 2s infinite;
}
-
\ No newline at end of file
+
+
diff --git a/views/pages/Profile/UploadPhoto.php b/views/pages/Profile/UploadPhoto.php
index 0cc38af..031e318 100644
--- a/views/pages/Profile/UploadPhoto.php
+++ b/views/pages/Profile/UploadPhoto.php
@@ -645,7 +645,7 @@ $user = new User(Auth::userid());
|
- Отправить фотографию
+
|
@@ -662,7 +662,129 @@ $user = new User(Auth::userid());
+