Ngiler SH3LL 360
Home
Information
Create File
Create Folder
:
/
home
/
tbf
/
duplicat_sala_palatului
/
resources
/
js
/
Information Server
MySQL :
OFF
Perl :
OFF
CURL :
ON
WGET :
OFF
PKEXEC :
OFF
Directive
Local Value
IP Address
89.40.16.97
System
Linux server.atelieruldeit.ro 3.10.0-1160.el7.x86_64 #1 SMP Mon Oct 19 16:18:59 UTC 2020 x86_64
User
tbf
PHP Version
7.3.33
Software
Apache
Doc root
Writable
close
Edit File :
custom.js
| Size :
10.42
KB
Copy
$( document ).ready( function() { /* Hover step thumbnail. */ $( ".empty-step .thumbnail" ).on({ mouseenter: function() { $( this ).removeClass( 'alert-secondary' ); $( this ).addClass( 'alert-dark' ); }, mouseleave: function() { $( this ).removeClass( 'alert-dark' ); $( this ).addClass( 'alert-secondary' ); } }); $( ".step .thumbnail" ).on({ mouseenter: function() { $( this ).removeClass( 'alert-info' ); $( this ).addClass( 'alert-primary' ); }, mouseleave: function() { $( this ).removeClass( 'alert-primary' ); $( this ).addClass( 'alert-info' ); } }); /* END: Hover step thumbnail. */ /* Add step. */ $( "#add-step" ).click( function() { var action_url = $( this ).attr( 'action' ); $.ajax({ url: action_url, success: function( data ) { $( ".step-form" ).html( data ); $( "#step_modal" ).modal( 'show' ); }, error: function( request, status, error ) { alert( request.responseText ); }, dataType: 'html' }); }); /* END: Add step. */ /* Add answer. */ $( "body" ).on( 'click', '#add-answer', function() { $.ajaxSetup({ headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') } }); var action_url = $( this ).attr( 'action' ); $.ajax({ url: action_url, success: function( data ) { $( ".answers" ).append( data ); }, error: function( request, status, error ) { alert( request.responseText ); }, dataType: 'html', }); }); /* END: Add answer. */ /* Add title. */ $( document ).on( 'click', '.add-title', function() { $.ajaxSetup({ headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') } }); var action_url = $( this ).attr( 'action' ); var current_item = $( this ); $.ajax({ url: action_url, dataType: 'html', success: function( data ) { current_item.parent().before( data ); }, error: function( request, status, error ) { alert( request.responseText ); } }); }); /* END: Add title. */ /* Add next step. */ $( document ).on( 'click', '.add-nextq', function() { $.ajaxSetup({ headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') } }); var action_url = $( this ).attr( 'action' ); var current_item = $( this ); var entity_id = current_item.data('entity_id'); $.ajax({ url: action_url, dataType: 'html', data: {'entity_id':entity_id}, success: function( data ) { current_item.parent().before( data ); }, error: function( request, status, error ) { alert( request.responseText ); } }); }); /* END: Add next step. */ /* Add field. */ $( "body" ).on( 'click', '.add-field', function() { $.ajaxSetup({ headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') } }); var action_url = $( this ).attr( 'action' ); var entity_id = $( this ).data( 'entity_id' ); var current_item = $( this ); $.ajax({ url: action_url, success: function( data ) { current_item.replaceWith( data ); }, error: function( request, status, error ) { alert( request.responseText ); }, dataType: 'html', data: {'entity_id':entity_id}, }); }); /* END: Add field. */ /* Delete option. */ $( "body" ).on( 'click', '.delete', function() { $( this ).closest( '.step_answers' ).remove(); }); /* END: Delete option. */ /* Delete destination. */ $( document ).on( 'click', '.delete-destination', function() { $( this ).closest( '.next_steps' ).remove(); }); /* END: Delete destination. */ /* Delete title. */ $( document ).on( 'click', '.delete-title', function() { $( this ).closest( '.step_titles' ).remove(); }); /* END: Delete title. */ /* Save step. */ $( "body" ).on( 'submit', '#step-form', function( e ) { e.preventDefault(); $.ajaxSetup({ headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') } }); var form = $( this ); // Defining the current form. var form_type = form.find( "[name^=form_type]" ).val(); var step_id = form.find( "[name^=step_id]" ).val(); var step_answers = $( ".step_answers" ); // Will loop all of this fields to get each answer. var step_titles = $( ".step_titles" ); // Will loop all of this fields to get each question title. var next_steps = $( ".next_steps" ); // Will loop all of this fields to get each next step. var empty_step = $( ".empty-step" ); $.each( step_answers, function(key) { $( "[name^=title]", this ).attr('name','answers[' + key + '][title]'); $( "[name^=description]", this ).attr('name','answers[' + key + '][description]'); $( "[name^=image]", this ).attr('name','answers[' + key + '][image]'); $( "[name^=old_img]", this ).attr('name','answers[' + key + '][old_img]'); $( "[name^=video]", this ).attr('name','answers[' + key + '][video]'); $( "[name^=answer_value]", this ).attr('name','answers[' + key + '][value]'); }); $.each( step_titles, function(key) { $( "[name^=title]", this ).attr('name','step_titles[' + key + '][title]'); $( "[name^=condition]", this ).attr('name','step_titles[' + key + '][condition]'); }); $.each( next_steps, function(key) { $( "[name^=destination]", this ).attr('name','next_steps[' + key + '][destination]'); $( "[name^=condition]", this ).attr('name','next_steps[' + key + '][condition]'); }); $.ajax({ type: "POST", url: '/admin/json-generate-store', data: new FormData($(this)[0]), dataType: 'HTML', processData:false, contentType: false, success: function(data){ if ( empty_step.length ) { empty_step.remove(); } if(form_type == 'edit'){ $( "." + step_id ).html( data ); }else{ $( ".steps-list" ).append( data ); } // RESET FORM $( ".modal" ).modal( 'hide' ); $( ".modal" ).on( 'hidden.bs.modal', function() { $( this ).closest( 'form' )[0].reset(); }); }, error: function( request, status, error ) { alert( request.responseText ); }, }); }); /* END: Save step. */ /* Edit step. */ $( document ).on( 'click', '.edit_entity', function( e ) { e.preventDefault(); $.ajaxSetup({ headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') } }); var ajax_url = $( this ).data( 'url_ajax' ); var entity_id = $( this ).data( 'entity_id' ); var holder = $(this).data( 'holder' ); var modal = $(this).data( 'modal' ); $.ajax({ type: "POST", url: "/" + ajax_url, data:{ 'entity_id': entity_id }, dataType: 'HTML', success: function( data ) { $( "." + holder ).html( data ); $( "#" + modal ).modal( 'show' ); }, error: function( data ){} }); }); /* END: Edit step. */ /* Remove step. */ $( document ).on( 'click', '.remove', function( e ) { e.preventDefault(); $.ajaxSetup({ headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') } }); var curr_elem = $( this ); var ajax_url = curr_elem.data( 'url_ajax' ); var entity_id = curr_elem.data( 'entity_id' ); $.ajax({ type: "POST", url: "/" + ajax_url, data:{ 'entity_id': entity_id }, dataType: 'JSON', success: function( data ) { curr_elem.parent().addClass( 'd-none' ); }, error: function( data ){} }); }); /* END: Remove step. */ /* Define start step. */ $( document ).on( 'submit', '#start_step_form', function( e ) { e.preventDefault(); $.ajaxSetup({ headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') } }); var ajax_url = $(this).data( 'url_ajax' ); var modal = $(this).data( 'modal' ); $.ajax({ type: "POST", url: "/" + ajax_url, data: $(this).serialize(), dataType: 'JSON', success: function( data ) { $( "#" + modal ).modal( 'hide' ); }, error: function( data ){} }); }); /* END: Define start step. */ /* Getting the modal for changing the start step. */ $( document ).on( 'click', '.change_entity', function( e ) { e.preventDefault(); var ajax_url = $(this).data( 'url_ajax' ); var holder = $(this).data( 'holder' ); var modal = $(this).data( 'modal' ); $.ajax({ type: "GET", url: "/" + ajax_url, dataType: 'HTML', success: function( data ) { $( "." + holder ).html( data ); $( "#" + modal ).modal( 'show' ); }, error: function( data ){} }); }); /* END: Getting the modal for changing the start step. */ /* Activate or deactivate a .form-control element. */ $( document ).on( 'click', '.headline .form-control, .next-steps .form-control', function( e ) { if ( !$( this ).hasClass( 'active' ) ) { $( '.form-control' ).removeClass( 'active' ); $( this ).addClass( 'active' ); } }); /* END: Activate or deactivate a .form-control element. */ /* On click on variable button, extract it's value and insert to the current cursor position in any input field. */ $( document ).on( 'click', '.variables button', function( e ) { e.preventDefault(); // insert to the current cursor position var button_text = $( this ).text(); var text = jQuery( '.form-control.active' ); var cursor_position = text[ 0 ].selectionStart; var text_value = text.val(); text.val( text_value.substring(0, cursor_position) + button_text + text_value.substring( cursor_position ) ); console.log( button_text ); }); /* END: On click on variable button, extract it's value and insert to the current cursor position in any input field. */ $( document ).on( 'click', '.get_variables', function( e ) { e.preventDefault(); var ajax_url = $(this).data( 'url_ajax' ); var holder = $(this).data( 'holder' ); var variable_type = $(this).data( 'variable_type' ); $.ajax({ type: "GET", url: "/" + ajax_url, dataType: 'HTML', data:{'variable_type':variable_type}, success: function( data ) { $( "." + holder ).html( data ); }, error: function( data ){} }); }); $( document ).on( 'change', '.change_status', function( e ) { e.preventDefault(); $.ajaxSetup({ headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') } }); var ajax_url = $(this).data( 'url_ajax' ); var entity_id = $(this).data( 'entity_id' ); var status = $(this).val(); $.ajax({ type: "POST", url: "/" + ajax_url, dataType: 'JSON', data:{'entity_id':entity_id, 'status':status}, success: function( data ) { location.reload(); }, error: function( data ){} }); }); });
Back