D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
tattooscyy
/
test
/
public
/
js
/
Filename :
main.js
back
Copy
$(function () { var size = $('#size_out').text() $('#size_out').text(Math.round(size)); $('#price_button').show(); $('#service_order').hide(); $('.all_artists').click(function () { $('.artist').fadeIn(); }); $('.cities').click(function () { $('.artist').fadeIn(); $.ajax({ method: 'POST', url: 'ajax/cities', success: function (data) { $('.data_cities').html(data); $('.data_cities3').html(data); } }); }); $('.data_cities').bind('change', function () { var city_id = $(this).val(); if(city_id != 0){ $.ajax({ method: 'POST', url: 'ajax/city/saloon', data:'city_id='+city_id, success: function (datas) { $('#saloon_select').hide(); $('#saloon_hide').show().change(saloon_hide_change).html(datas); var artsn = $('#saloon_hide option:selected').attr('data-artists'); if(artsn){ var html = html_artists(artsn); $('#artist_hide').html(html).show(); $('#artist_select').hide(); arts_name(artsn); }else{ $('#artist_select').show(); $('#artist_hide').hide(); $('.artist').fadeIn(); } } }); }else{ $('#saloon_select').show(); $('#saloon_hide').hide(); $('#artist_select').show(); $('#artist_hide').hide(); $('.artist').fadeIn(); } }); $('.data_cities3').bind('change', function () { var city_id = $(this).val(); if(city_id != 0){ $.ajax({ method: 'POST', url: 'ajax/city/saloon', data:'city_id='+city_id, success: function (datas) { $('#saloon_select3').hide(); $('#saloon_hide3').show().change(saloon_hide_change3).html(datas); var artsn = $('#saloon_hide3 option:selected').attr('data-artists'); if(artsn){ var html = html_artists(artsn); $('#artist_hide3').html(html).show(); $('#artist_select3').hide(); arts_name(artsn); }else{ $('#artist_select3').show(); $('#artist_hide3').hide(); $('.artist').fadeIn(); } } }); }else{ $('#saloon_select3').show(); $('#saloon_hide3').hide(); $('#artist_select3').show(); $('#artist_hide3').hide(); $('.artist').fadeIn(); } }); $('#service_select').change(function () { data = $(this).val(); if (data == 2 || data == 3) { $('#price_button').hide(); if (data == 2) { href = 'piercing'; } else if (data == 3) { href = 'makeuptattoo'; } $('#service_order').attr('href', href).show(); } else { $('#price_button').show(); $('#service_order').hide(); } }); $('#artist_select').change(function () { $('#service_order').hide(); $('#price_button').show(); $('#service_select').val(1); var id = $(this).val(); artists(id); $('#service_select').val(1); //var saloon = $('#artist_select [value=' + id + ']').attr('data-saloon'); var saloon_id = $('#artist_select [value=' + id + ']').attr('data-saloon-id'); if (saloon_id) { $('#saloon_select').val(saloon_id); } else { $('#saloon_select').val(''); } }); $('#saloon_select').change(function () { $('#service_order').hide(); $('#price_button').show(); var id = $(this).val(); var artist_id = $('#artist_select').val(); if (id > 0) { var arts = $('#saloon_select [value=' + id + ']').attr('data-artists'); var html = html_artists(arts); $('#artist_hide').html(html).show(); $('#artist_select').hide(); arts_name(arts); } else { $('#artist_select').show(); $('#artist_hide').hide(); } }); $('#saloon_select3').change(function () { var id = $(this).val(); if (id > 0) { var arts = $('#saloon_select3 [value=' + id + ']').attr('data-artists'); var arr = arts.split(','); //alert(arr[0]); var html = "<select name='artist_name' class='form-control'>"; arr.forEach(function (e) { html += "<option value='" + e + "'>" + e + "</option>"; }); html += "</select>"; $('#artist_hide3').html(html).show(); $('#artist_select3').hide(); arts_name(arts); } else { $('#artist_select3').show(); $('#artist_hide3').hide(); $('.artist').fadeIn(); } }); $('#artist_select_more').change(function () { var id = $(this).val(); if(id > 0){ var saloon = $('#artist_select_more [value=' + id + ']').attr('data-saloon'); artists(id); if (saloon) { $('#saloon_hide_more').text(saloon); $('#saloon_select_more').hide(); } else { $('#saloon_hide_more').text(''); $('#saloon_select_more').show(); } }else{ $('.artist').fadeIn(); $('#saloon_hide_more').text(''); $('#saloon_select_more').show(); } }); $('#style').change(function () { var catalog = parseInt($(this).val()); var width = $('#width').val(); var height = $('#height').val(); getSize(width, height, catalog); }); $('#width').change(function () { var data = $(this).val(); var width = data; var width_out = $('#width_out').attr('data_real'); var height_out = $('#height_out').attr('data_real'); //var height = $('#height').val(); var height = Math.ceil(data * height_out / width_out); if (height == 0) { height = 1; } console.log(width, height); var catalog = parseInt($('#style').val()); $('#print').attr('href', '/tattooprint?width=' + width + '&height=' + height); $('#height_out').text(Math.round(height)); $('#size_out').text(Math.round(width) * Math.round(height)); $('#height').val(Math.round(height)); $('#height_b').val(Math.round(height)); $('#pic').width(width * 38).height($('#height').val() * 38); $('#width_out').text(width); $('#cropContainerPreload').width(width * 38).height($('#height').val() * 38); getSize(width, height, catalog); // document.location.href = '?width=' + width + '&height=' + $('#height').val() + '#calculate'; }); $('#height').change(function () { var data = $(this).val(); var height = data; if (height == 0) { height = 1; } $('#pic').height(height * 38).width($('#width').val() * 38); $('#height_out').text(height); $('#cropContainerPreload').height(height * 38).width($('#width').val() * 38); // document.location.href = '?width=' + $('#width').val() + '&height=' + height + '#calculate'; }); $('#service_select').change(function () { var data = $(this).val(); if (data == 2 || data == 3) { $('#saloon_select').prop('disabled', true); $('#artist_select').prop('disabled', true); $('#service_order').prop('disabled', true); } else { $('#saloon_select').prop('disabled', false); $('#artist_select').prop('disabled', false); $('#service_order').prop('disabled', false); } }); }); function getSize(width, height, catalog) { if (!width) { width = 1; } if (!height) { height = 1; } if (!catalog) { catalog = 0; } $.ajaxSetup({ headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') }, type: "post" }); $.ajax({ url: '/ajax/sum', data: 'width=' + width + '&height=' + height + '&catalog=' + catalog, success: function (data) { $('#sum').text(data); var wor = Math.ceil(data / 80) / 2; console.log(wor); $('#works_hours').text(wor); }, error: function (data) { console.log(data); } }); } function artists(id) { $('.artist').fadeOut(1000, function () { $('#a_' + id).fadeIn(); }); } function arts_name(arts) { var arr = arts.split(','); $('.artist').fadeOut(); arr.forEach(function (e) { $('.' + e).fadeIn(); }); } function html_artists(arts){ var arr = arts.split(','); //alert(arr[0]); var html = "<select name='artist_name' class='form-control'>"; arr.forEach(function (e) { html += "<option value='" + e + "'>" + e + "</option>"; }); html += "</select>"; return html; } function saloon_hide_change(){ var arts = $('#saloon_hide option:selected').attr('data-artists'); if(arts){ $('#artist_select').hide(); $('#artist_hide').hide(); var html = html_artists(arts); $('#artist_hide').html(html).show(); arts_name(arts); }else{ $('#artist_select').show(); $('#artist_hide').hide(); $('.artist').fadeIn(); } } function saloon_hide_change3(){ var arts = $('#saloon_hide3 option:selected').attr('data-artists'); if(arts){ $('#artist_select3').hide(); $('#artist_hide3').hide(); var html = html_artists(arts); $('#artist_hide3').html(html).show(); arts_name(arts); }else{ $('#artist_select3').show(); $('#artist_hide3').hide(); $('.artist').fadeIn(); } }