PATH:
home
/
rwabteecom
/
project_11
/
resources
/
views
/
dashboard
/
partials
/
Editing: design-scripts.blade.php
<script> $(document).ready(function() { // for changing logo $("#profile-img-select").on("click", function() { $("input[name='logo']").click(); }); function updateLogoImage(removeImg = false) { $("#profile-img-select").prop("disabled", true); var formData = new FormData($('#photo-upload-form')[0]); formData.append('_token', "{{ csrf_token() }}"); if (removeImg) { formData.append('remove_logo', "1"); } $.ajax({ url: '{{ route('dashboard.design.update.logo') }}', method: "POST", processData: false, contentType: false, data: formData, success: function(response) { let ImgLink = response.data.logo; $(".logo-container").html(ImgLink); $("#profile-img-select").prop("disabled", false); checkLogoImgage(); reloadIfram() }, error: function(response) { $("#profile-img-select").prop("disabled", false); } }); } $("input[name='logo']").on("change", function() { // update logo updateLogoImage(); }); function checkLogoImgage() { $(".remove-logo-image").addClass("d-none"); if ($(".logo-container img").length > 0) { $(".remove-logo-image").removeClass("d-none").prop("disabled", false); } } $(".remove-logo-image").on("click", function() { $(this).prop("disabled", true); updateLogoImage(true); }) checkLogoImgage(); // check background style checkbox function checkCorrspondingBackgroundStyle() { $(".background-select-con a").each(function() { if ($(this).hasClass("active")) { $(this).siblings("input").prop("checked", true); $(".background-style-tabs .tab-pane").removeClass("show active"); let tab = $(this).attr("aria-controls"); $("#" + tab).addClass("show active"); } }) } checkCorrspondingBackgroundStyle(); $(".background-select-con label").on("click", function() { checkCorrspondingBackgroundStyle(); }); $(".to-other-color").on("change", function() { getPickerColors($(this)); }); function getPickerColors(obj = null) { if (obj == null) { $(".to-other-color").each(function() { let to = $(this).attr("data-to"); let val = $(this).val(); $("input[name='" + to + "']").val(val); }); return; } let to = obj.attr("data-to"); let val = obj.val(); $("input[name='" + to + "']").val(val); setTimeout(() => { updateDesignFormPage(); }, 50); } getPickerColors(); $("body").on("click", ".color-picker-tabs .form-check-label", function() { let to = $(this).parent().parent().parent().parent().parent().attr("data-to"); let val = $(this).find("div").css("background-color"); let hexColor = rgbToHex(val); $("input[name='" + to + "']").val(hexColor); setTimeout(() => { updateDesignFormPage(); }, 50); }) function rgbToHex(rgbColor) { if (/^#[0-9A-F]{6}$/i.test(rgbColor)) { return rgbColor; } let [r, g, b] = rgbColor.match(/\d+/g); let hexColor = "#" + ((1 << 24) + (parseInt(r) << 16) + (parseInt(g) << 8) + parseInt(b)).toString( 16).slice(1); return hexColor; } function getGradientDirection() { if($(".gradiant-direction").length == 0){ return; } setTimeout(() => { let styleAttribute = $(".gradiant-direction").attr("style"); let regex = /rotate\((.+?)\)/; let match = styleAttribute.match(regex); let rotationValue = match ? match[1] : null; $("input[name='background_direction']").val(rotationValue); }, 50); } getGradientDirection(); $(".gradiant-direction").on("click", function() { getGradientDirection(); setTimeout(() => { updateDesignFormPage(); }, 50); }); $(".onblur").on("blur", function() { updateDesignFormPage(); }) $(".onchange").on("change", function() { updateDesignFormPage(); }) $(".onclick").on("click", function() { updateDesignFormPage(); }) function updateDesignFormPage() { @if(request()->routeIs('dashboard.onboarding')) return; @endif var formData = new FormData($('#design-page-form')[0]); formData.append('_token', "{{ csrf_token() }}"); isUpdateInProgress = true; $.ajax({ url: '{{ route('dashboard.design.update.design') }}', method: "POST", processData: false, contentType: false, data: formData, success: function(response) { console.log(response); reloadIfram() }, error: function(response) { console.log('error'); console.log(response); } }); } function checkIfAnyChangesMadeToButtonShadowBox() { $('.shadow-text').text('{{ __('No shadow') }}') let hasChanges = false; $(".shadows-boxer .range-value").each(function() { if ($(this).attr("data-default") != $(this).text().trim()) { hasChanges = true; } }); if (hasChanges) { $('.shadow-text').text('{{ __('With shadow') }}') } } checkIfAnyChangesMadeToButtonShadowBox(); $("body").on('click', '.reset-property-shadow .reset-shadow', function() { let parent = $(this).closest('.reset-property-shadow') parent.find('input[type=range]').val(0) parent.find('.range-value').text(0) $(this).find('button').addClass('d-none') $(this).removeClass('pointerClass'); checkIfAnyChangesMadeToButtonShadowBox(); setTimeout(() => { updateDesignFormPage(); }, 50); }) $("body").on('click', '.reset-property-shadow .save-shadow', function() { let parent = $(this).closest('.reset-property-shadow') let resetBtn = parent.find('.reset-shadow') resetBtn.addClass('pointerClass') resetBtn.find('button').removeClass('d-none'); checkIfAnyChangesMadeToButtonShadowBox(); setTimeout(() => { updateDesignFormPage(); }, 50); }); // change status of social icons $("body").on("change", "#sortableLinks input[type='checkbox']", function() { let status = 0; let SocialLinkId = $(this).parent().parent().parent().attr("data-icon"); if ($(this).is(":checked")) { status = 1; } $.ajax({ url: '{{ route('dashboard.design.social.update', 1) }}', method: "PUT", contentType: 'application/json', // Set content type to JSON headers: { 'X-CSRF-TOKEN': '{{ csrf_token() }}' }, data: JSON.stringify({ icon_id: SocialLinkId, status: status, type: 'status' }), success: function(response) { console.log(response); reloadIfram() }, error: function(response) { console.log("error"); console.log(response); } }); }) $("body").on("change", "#sortableLinks input[type='checkbox']", function() { let status = 0; let SocialLinkId = $(this).parent().parent().parent().attr("data-icon"); if ($(this).is(":checked")) { status = 1; } $.ajax({ url: '{{ route('dashboard.design.social.update', 1) }}', method: "PUT", contentType: 'application/json', // Set content type to JSON headers: { 'X-CSRF-TOKEN': '{{ csrf_token() }}' }, data: JSON.stringify({ icon_id: SocialLinkId, status: status, type: 'status' }), success: function(response) { console.log(response); reloadIfram(); }, error: function(response) { console.log("error"); console.log(response); } }); }) $("body").on('click', '#editSocialLinkBtn', function() { let link = $(this).attr("linkId"); let newurlValue = $("input#socialLinkurlEdit").val(); $("#sortableLinks #" + link + " .linkUrl").text(newurlValue); $("#sortableLinks #" + link + " .editSocialLink").attr("link-url", newurlValue); let url = $("#edit-social-link-form input[name='url']").val().trim(); let icon_id = $("#edit-social-link-form input[name='icon_id']").val().trim(); $.ajax({ url: '{{ route('dashboard.design.social.update', 1) }}', method: "PUT", contentType: 'application/json', headers: { 'X-CSRF-TOKEN': '{{ csrf_token() }}' }, data: JSON.stringify({ url: url, icon_id: icon_id, type: 'update' }), success: function(response) { reloadIfram(); }, error: function(response) { console.log('error'); console.log(response); } }); Toastify({ text: 'Social media link Updated Successflly', duration: 3000, close: true, className: "add-success", style: { background: "#FF8A2D", } }).showToast(); $('#EditSocialLinkModal').modal('hide') }) }) $("body").on("change", ".theme_id_change", function() { $.ajax({ url: '{{ route('dashboard.design.update.updateTheme') }}', method: "post", contentType: 'application/json', headers: { 'X-CSRF-TOKEN': '{{ csrf_token() }}' }, data: JSON.stringify({ theme_id: $(this).data('value'), }), success: function(response) { location.reload(); }, error: function(response) { console.log('error'); console.log(response); } }); Toastify({ text: 'Theme Updated Successflly', duration: 3000, close: true, className: "add-success", style: { background: "#FF8A2D", } }).showToast(); }) </script>
SAVE
CANCEL