Separacion de js a archivos por pagina

This commit is contained in:
2020-06-17 23:16:29 -04:00
parent 429e4187fb
commit 5967a6c931
13 changed files with 363 additions and 347 deletions

View File

@ -34,54 +34,11 @@
</div>
</div>
@push('scripts')
<script type="text/javascript">
var clientes = [
@foreach ($clientes as $cliente)
'{!!$cliente!!}',
@endforeach
]
var current = 0
var rows = 2
var cols = 6
function decreaseClientes() {
$('#img_clientes').find('.row').find('.column:last-child').remove()
current -= rows
if (current < - cols * rows) {
current = clientes.length - (cols - 1) * rows
}
n = current
if (n < 0) {
n = clientes.length + n
}
$('#img_clientes').find('.row:first-child').prepend(
$('<div></div>').attr('class', 'five wide tablet two wide computer column').append(clientes[n])
)
$('#img_clientes').find('.row:last-child').prepend(
$('<div></div>').attr('class', 'five wide tablet two wide computer column').append(clientes[n + 1])
)
}
function increaseClientes() {
$('#img_clientes').find('.row').find('.column:first-child').remove()
current += 2
if (current > clientes.length - cols * rows) {
current = - (cols - 1) * rows
}
$('#img_clientes').find('.row:first-child').append(
$('<div></div>').attr('class', 'five wide tablet two wide computer column').append(clientes[current + (cols - 1) * rows])
)
$('#img_clientes').find('.row:last-child').append(
$('<div></div>').attr('class', 'five wide tablet two wide computer column').append(clientes[current + cols * rows - 1])
)
}
$(document).ready(function() {
$('.ci .icon').css('cursor', 'pointer').click(function() {
if ($(this).attr('class').indexOf('left') != -1) {
decreaseClientes()
return
}
increaseClientes()
})
})
</script>
@push('readyjs')
clientes.clientes = [
@foreach ($clientes as $cliente)
'{!!$cliente!!}',
@endforeach
]
clientes.setup()
@endpush

View File

@ -32,24 +32,20 @@
</div>
</div>
@push('scripts')
<script type="text/javascript">
$(document).ready(function() {
$('#formulario_contacto').submit(function(e) {
e.preventDefault()
@push('readyjs')
$('#formulario_contacto').submit(function(e) {
e.preventDefault()
var nombre = $(this).find("[name='nombre']").val()
var telefono = $(this).find("[name='telefono']").val()
var email = $(this).find("[name='email']").val()
var mensaje = $(this).find("[name='mensaje']").val()
var nombre = $(this).find("[name='nombre']").val()
var telefono = $(this).find("[name='telefono']").val()
var email = $(this).find("[name='email']").val()
var mensaje = $(this).find("[name='mensaje']").val()
$.post('{{$urls->base}}/contacto', {nombre: nombre, telefono: telefono, email: email, mensaje: mensaje}, function(data) {
console.debug(data)
}, 'json')
$.post('{{$urls->base}}/contacto', {nombre: nombre, telefono: telefono, email: email, mensaje: mensaje}, function(data) {
console.debug(data)
}, 'json')
return false
})
$('#map').embed()
})
</script>
return false
})
$('#map').embed()
@endpush

View File

@ -34,63 +34,17 @@
</div>
</div>
@push('scripts')
<script type="text/javascript">
var eventos = {
eventos: [
@foreach ($eventos as $evento)
{
titulo: '{{$evento->titulo}}',
image: '{!!$evento->imagen!!}',
empresa: '{{$evento->empresa}}',
servicio: '{{$evento->servicio}}'
},
@endforeach
],
current_tab: 'none',
changeEventos: (filter) => {
var grid = $('#eventos_cards')
grid.html('')
$.each(eventos.eventos, function(i, el) {
if (filter != 'none' && el.servicio != filter) {
return
}
grid.append(
$('<div></div>').attr('class', 'eight wide tablet four wide computer column').append(
$('<div></div>').attr('class', 'ui basic segment').append(
$('<a></a>').attr('href', '{{$urls->base}}/evento/' + i).append(
$('<div></div>').attr('class', 'ui image').append(
$('<img />').attr('src', el.image)
)
).append(
$('<div></div>').attr('class', 'ui center aligned header').append(el.titulo).append(
$('<br />')
).append(el.empresa)
)
)
)
)
})
@push('readyjs')
eventos.eventos = [
@foreach ($eventos as $evento)
{
titulo: '{{$evento->titulo}}',
image: '{!!$evento->imagen!!}',
empresa: '{{$evento->empresa}}',
servicio: '{{$evento->servicio}}'
},
changeTab: (filter) => {
$('.servicio.active').removeClass('active')
$(".servicio[data-filter='" + filter + "']").addClass('active')
eventos.current_tab = filter
},
setup: () => {
$('.servicio').click(function(e) {
e.preventDefault()
var filter = $(this).attr('data-filter')
if (filter == eventos.current_tab) {
return
}
eventos.changeTab(filter)
eventos.changeEventos(filter)
})
}
}
$(document).ready(function() {
eventos.setup()
})
</script>
@endforeach
]
eventos.base_url = '{{$urls->base}}'
eventos.setup()
@endpush

View File

@ -22,38 +22,14 @@
</div>
</div>
@push('scripts')
<script type="text/javascript">
var testimonios = [
@foreach ($testimonios as $testimonio)
{
contenido: '{{$testimonio->contenido}}',
emisor: '{{$testimonio->emisor}}'
},
@endforeach
]
var current_testimonio = 0
function cambiar(id) {
if (id == current_testimonio) {
return
}
$('#testimonio').html('').append(
$('<p></p>').html(testimonios[id].contenido)
).append(
$('<div></div>').attr('class', 'ui header').html(testimonios[id].emisor)
)
$('#marcador').find(".icon[data-id='" + current_testimonio + "']").addClass('outline')
$('#marcador').find(".icon[data-id='" + id + "']").removeClass('outline')
$('#marcador').find('.icon.outline').css('cursor', 'pointer')
$('#marcador').find('.icon:not(.outline)').css('cursor', 'default')
current_testimonio = id
}
$(document).ready(function() {
$('#marcador').find('.icon').click(function() {
var id = $(this).attr('data-id')
cambiar(id)
})
$('#marcador').find('.icon.outline').css('cursor', 'pointer')
})
</script>
@push('readyjs')
testimonios.testimonios = [
@foreach ($testimonios as $testimonio)
{
contenido: '{{$testimonio->contenido}}',
emisor: '{{$testimonio->emisor}}'
},
@endforeach
]
testimonios.setup()
@endpush