Orden de js y FIX: cambio a estado avisos
This commit is contained in:
@ -29,7 +29,7 @@ class Home {
|
|||||||
$avisos = json_decode(trim(file_get_contents($filename)));
|
$avisos = json_decode(trim(file_get_contents($filename)));
|
||||||
|
|
||||||
if (isset($post['estado'])) {
|
if (isset($post['estado'])) {
|
||||||
$avisos->activo = (bool) $post['estado'];
|
$avisos->activo = ($post['estado'] !== 'false');
|
||||||
} else {
|
} else {
|
||||||
$aviso = (object) [
|
$aviso = (object) [
|
||||||
'titulo' => '',
|
'titulo' => '',
|
||||||
|
@ -41,57 +41,62 @@
|
|||||||
|
|
||||||
@push('scripts')
|
@push('scripts')
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var edit = false
|
var faq = {
|
||||||
var faqs = [
|
edit: false,
|
||||||
@foreach ($faqs as $faq)
|
faqs: [
|
||||||
{
|
@foreach ($faqs as $faq)
|
||||||
titulo: '{{$faq->titulo}}',
|
{
|
||||||
contenido: '{{$faq->contenido}}'
|
titulo: '{{$faq->titulo}}',
|
||||||
},
|
contenido: '{{$faq->contenido}}'
|
||||||
@endforeach
|
},
|
||||||
]
|
@endforeach
|
||||||
$(document).ready(() => {
|
],
|
||||||
$('.titulo').css('cursor', 'pointer').click(function() {
|
setup: () => {
|
||||||
var id = $(this).attr('data-id')
|
$('.titulo').css('cursor', 'pointer').click(function() {
|
||||||
|
var id = $(this).attr('data-id')
|
||||||
|
|
||||||
$("input[name='id']").val(id)
|
$("input[name='id']").val(id)
|
||||||
$("input[name='titulo']").val(faqs[id].titulo)
|
$("input[name='titulo']").val(faq.faqs[id].titulo)
|
||||||
$("textarea[name='contenido']").val(faqs[id].contenido)
|
$("textarea[name='contenido']").val(faq.faqs[id].contenido)
|
||||||
$('.button.enviar').html('EDITAR')
|
$('.button.enviar').html('EDITAR')
|
||||||
edit = true
|
faq.edit = true
|
||||||
})
|
|
||||||
$('.trash.icon').css('cursor', 'pointer').click(function() {
|
|
||||||
var id = $(this).attr('data-id')
|
|
||||||
var url = '{{$urls->admin}}/faqs/delete'
|
|
||||||
$.post(url, {id: id}, (data) => {
|
|
||||||
if (data.estado) {
|
|
||||||
window.location.reload()
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
})
|
$('.trash.icon').css('cursor', 'pointer').click(function() {
|
||||||
$('.button.resetear').click(() => {
|
var id = $(this).attr('data-id')
|
||||||
$("input[name='id']").val('')
|
var url = '{{$urls->admin}}/faqs/delete'
|
||||||
$('.button.enviar').html('AGREGAR')
|
$.post(url, {id: id}, (data) => {
|
||||||
edit = false
|
if (data.estado) {
|
||||||
})
|
window.location.reload()
|
||||||
$('.form').trigger('reset')
|
}
|
||||||
$('.form').submit((e) => {
|
})
|
||||||
e.preventDefault()
|
|
||||||
var input = {
|
|
||||||
titulo: $("input[name='titulo']").val(),
|
|
||||||
contenido: $("textarea[name='contenido']").val()
|
|
||||||
}
|
|
||||||
if (edit) {
|
|
||||||
input['id'] = $("input[name='id']").val()
|
|
||||||
}
|
|
||||||
var url = '{{$urls->admin}}/faqs/add'
|
|
||||||
$.post(url, input, (data) => {
|
|
||||||
if (data.estado) {
|
|
||||||
window.location.reload()
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
return false
|
$('.button.resetear').click(() => {
|
||||||
})
|
$("input[name='id']").val('')
|
||||||
|
$('.button.enviar').html('AGREGAR')
|
||||||
|
faq.edit = false
|
||||||
|
})
|
||||||
|
$('.form').trigger('reset')
|
||||||
|
$('.form').submit((e) => {
|
||||||
|
e.preventDefault()
|
||||||
|
var input = {
|
||||||
|
titulo: $("input[name='titulo']").val(),
|
||||||
|
contenido: $("textarea[name='contenido']").val()
|
||||||
|
}
|
||||||
|
if (edit) {
|
||||||
|
input['id'] = $("input[name='id']").val()
|
||||||
|
}
|
||||||
|
var url = '{{$urls->admin}}/faqs/add'
|
||||||
|
$.post(url, input, (data) => {
|
||||||
|
if (data.estado) {
|
||||||
|
window.location.reload()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$(document).ready(() => {
|
||||||
|
faq.setup()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
@endpush
|
@endpush
|
||||||
|
@ -81,93 +81,98 @@
|
|||||||
|
|
||||||
@push('scripts')
|
@push('scripts')
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var edit = false
|
var home = {
|
||||||
function editAviso(id) {
|
edit: false,
|
||||||
var titulo = $(".link.titulo[data-id='" + id + "']").html()
|
editAviso: (id) => {
|
||||||
var contenido = $(".link.contenido[data-id='" + id + "']").html()
|
var titulo = $(".link.titulo[data-id='" + id + "']").html()
|
||||||
|
var contenido = $(".link.contenido[data-id='" + id + "']").html()
|
||||||
|
|
||||||
$("input[name='id']").val(id)
|
$("input[name='id']").val(id)
|
||||||
$("input[name='titulo']").val(titulo)
|
$("input[name='titulo']").val(titulo)
|
||||||
$("input[name='contenido']").val(contenido)
|
$("input[name='contenido']").val(contenido)
|
||||||
edit = true
|
home.edit = true
|
||||||
$('.accion').html('EDITAR')
|
$('.accion').html('EDITAR')
|
||||||
}
|
},
|
||||||
function submitAviso(e) {
|
submitAviso: (e) => {
|
||||||
e.preventDefault()
|
|
||||||
input = {
|
|
||||||
titulo: $("input[name='titulo']").val(),
|
|
||||||
contenido: $("input[name='contenido']").val()
|
|
||||||
}
|
|
||||||
if (edit) {
|
|
||||||
input['id'] = $("input[name='id']").val()
|
|
||||||
}
|
|
||||||
if (input['titulo'] == '') {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
var url = '{{$urls->admin}}/home/avisos/add'
|
|
||||||
$.post(url, input, (data) => {
|
|
||||||
if (data.estado) {
|
|
||||||
window.location.reload()
|
|
||||||
}
|
|
||||||
}, 'json')
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
function deleteAviso(id) {
|
|
||||||
var url = '{{$urls->admin}}/home/avisos/delete'
|
|
||||||
$.post(url, {id: id}, (data) => {
|
|
||||||
if (data.estado) {
|
|
||||||
window.location.reload()
|
|
||||||
}
|
|
||||||
}, 'json')
|
|
||||||
}
|
|
||||||
$(document).ready(() => {
|
|
||||||
$('.link').css('cursor', 'pointer').click(function() {
|
|
||||||
var id = $(this).attr('data-id')
|
|
||||||
editAviso(id)
|
|
||||||
})
|
|
||||||
$('#avisos').trigger('reset')
|
|
||||||
$('#avisos').submit((e) => {
|
|
||||||
submitAviso(e)
|
|
||||||
})
|
|
||||||
$(".button[type='reset']").click((e) => {
|
|
||||||
$("input[name='id']").val('')
|
|
||||||
$('.accion').html('CREAR')
|
|
||||||
edit = false
|
|
||||||
})
|
|
||||||
$('.trash.icon').css('cursor', 'pointer').click(function() {
|
|
||||||
var id = $(this).attr('data-id')
|
|
||||||
deleteAviso(id)
|
|
||||||
})
|
|
||||||
$('.checkbox').checkbox({
|
|
||||||
onChange: function() {
|
|
||||||
var state = $(this).is(':checked')
|
|
||||||
var url = '{{$urls->admin}}/home/avisos/add'
|
|
||||||
$.post(url, {estado: state}, (data) => {
|
|
||||||
console.debug(data)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
@if ($avisos->activo)
|
|
||||||
$('.checkbox').checkbox('set checked')
|
|
||||||
@endif
|
|
||||||
$('#resumen').submit((e) => {
|
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
return false
|
|
||||||
})
|
|
||||||
$('.guardar').click(function() {
|
|
||||||
var id = $(this).attr('data-id')
|
|
||||||
var url = '{{$urls->admin}}/home/resumen/edit'
|
|
||||||
input = {
|
input = {
|
||||||
id: id,
|
titulo: $("input[name='titulo']").val(),
|
||||||
titulo: $("input[name='titulo" + id + "']").val(),
|
contenido: $("input[name='contenido']").val()
|
||||||
cantidad: $("input[name='cantidad" + id + "']").val()
|
|
||||||
}
|
}
|
||||||
|
if (home.edit) {
|
||||||
|
input['id'] = $("input[name='id']").val()
|
||||||
|
}
|
||||||
|
if (input['titulo'] == '') {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
var url = '{{$urls->admin}}/home/avisos/add'
|
||||||
$.post(url, input, (data) => {
|
$.post(url, input, (data) => {
|
||||||
if (data.estado) {
|
if (data.estado) {
|
||||||
window.location.reload()
|
window.location.reload()
|
||||||
}
|
}
|
||||||
|
}, 'json')
|
||||||
|
return false
|
||||||
|
},
|
||||||
|
deleteAviso: (id) => {
|
||||||
|
var url = '{{$urls->admin}}/home/avisos/delete'
|
||||||
|
$.post(url, {id: id}, (data) => {
|
||||||
|
if (data.estado) {
|
||||||
|
window.location.reload()
|
||||||
|
}
|
||||||
|
}, 'json')
|
||||||
|
},
|
||||||
|
setup: () => {
|
||||||
|
$('.link').css('cursor', 'pointer').click(function() {
|
||||||
|
var id = $(this).attr('data-id')
|
||||||
|
home.editAviso(id)
|
||||||
})
|
})
|
||||||
})
|
$('#avisos').trigger('reset')
|
||||||
|
$('#avisos').submit((e) => {
|
||||||
|
home.submitAviso(e)
|
||||||
|
})
|
||||||
|
$(".button[type='reset']").click((e) => {
|
||||||
|
$("input[name='id']").val('')
|
||||||
|
$('.accion').html('CREAR')
|
||||||
|
home.edit = false
|
||||||
|
})
|
||||||
|
$('.trash.icon').css('cursor', 'pointer').click(function() {
|
||||||
|
var id = $(this).attr('data-id')
|
||||||
|
home.deleteAviso(id)
|
||||||
|
})
|
||||||
|
$('.checkbox').checkbox({
|
||||||
|
onChange: function() {
|
||||||
|
var state = $(this).is(':checked')
|
||||||
|
var url = '{{$urls->admin}}/home/avisos/add'
|
||||||
|
$.post(url, {estado: state}, (data) => {
|
||||||
|
console.debug(data)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
@if ($avisos->activo)
|
||||||
|
$('.checkbox').checkbox('set checked')
|
||||||
|
@endif
|
||||||
|
$('#resumen').submit((e) => {
|
||||||
|
e.preventDefault()
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
$('.guardar').click(function() {
|
||||||
|
var id = $(this).attr('data-id')
|
||||||
|
var url = '{{$urls->admin}}/home/resumen/edit'
|
||||||
|
input = {
|
||||||
|
id: id,
|
||||||
|
titulo: $("input[name='titulo" + id + "']").val(),
|
||||||
|
cantidad: $("input[name='cantidad" + id + "']").val()
|
||||||
|
}
|
||||||
|
$.post(url, input, (data) => {
|
||||||
|
if (data.estado) {
|
||||||
|
window.location.reload()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$(document).ready(() => {
|
||||||
|
home.setup()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
@endpush
|
@endpush
|
||||||
|
@ -153,112 +153,120 @@
|
|||||||
|
|
||||||
@push('scripts')
|
@push('scripts')
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var months = {
|
var producto = {
|
||||||
long: [],
|
months: {
|
||||||
short: []
|
long: [],
|
||||||
}
|
short: []
|
||||||
var date = new Date(2018, 0, 1)
|
},
|
||||||
for (i = 0; i < 12; i ++) {
|
date: new Date(2018, 0, 1),
|
||||||
date.setMonth(i)
|
listImage: (image) => {
|
||||||
months.long.push(date.toLocaleString('es-ES', {month: "long"}).replace(
|
var icon = $('<i></i>').attr('class', 'trash alternate outline icon')
|
||||||
/\w\S*/g,
|
icon.css('cursor', 'pointer').click(function() {
|
||||||
function(txt) {
|
var url = '{{$urls->admin}}/producto/{{$producto->id}}/imagen/delete'
|
||||||
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
|
$.post(url, {imagen: image}, (data) => {
|
||||||
}
|
if (data.estado) {
|
||||||
))
|
window.location.reload()
|
||||||
months.short.push(date.toLocaleString('es-ES', {month: "short"}).replace(
|
}
|
||||||
/\w\S*/g,
|
})
|
||||||
function(txt) {
|
})
|
||||||
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
|
$('#imagenes').append(
|
||||||
}
|
$('<div></div>').attr('class', 'item').append(
|
||||||
))
|
icon
|
||||||
}
|
).append(
|
||||||
function listImage(image) {
|
$('<div></div>').attr('class', 'content').html(image)
|
||||||
var icon = $('<i></i>').attr('class', 'trash alternate outline icon')
|
)
|
||||||
icon.css('cursor', 'pointer').click(function() {
|
)
|
||||||
var url = '{{$urls->admin}}/producto/{{$producto->id}}/imagen/delete'
|
},
|
||||||
$.post(url, {imagen: image}, (data) => {
|
setMonths: () => {
|
||||||
if (data.estado) {
|
for (i = 0; i < 12; i ++) {
|
||||||
window.location.reload()
|
producto.date.setMonth(i)
|
||||||
|
producto.months.long.push(producto.date.toLocaleString('es-ES', {month: "long"}).replace(
|
||||||
|
/\w\S*/g,
|
||||||
|
function(txt) {
|
||||||
|
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
|
||||||
|
}
|
||||||
|
))
|
||||||
|
producto.months.short.push(producto.date.toLocaleString('es-ES', {month: "short"}).replace(
|
||||||
|
/\w\S*/g,
|
||||||
|
function(txt) {
|
||||||
|
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
|
||||||
|
}
|
||||||
|
))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
setup: () => {
|
||||||
|
producto.setMonths()
|
||||||
|
$('.selection.dropdown').dropdown()
|
||||||
|
$('.selection.dropdown').dropdown('set selected', '{{$producto->segmento}}')
|
||||||
|
$('.calendar').calendar({
|
||||||
|
type: 'month',
|
||||||
|
text: {
|
||||||
|
months: producto.months.long,
|
||||||
|
monthsShort: producto.months.short
|
||||||
|
},
|
||||||
|
formatInput: false,
|
||||||
|
onChange: function(a, b) {
|
||||||
|
if (typeof a == 'undefined') {
|
||||||
|
a = new Date()
|
||||||
|
}
|
||||||
|
$(this).find('input').val(('0' + (a.getMonth() + 1)).slice(-2) + '/' + a.getFullYear())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
var entrega = new Date('{{str_pad(implode('-', array_reverse(explode('/', $producto->entrega))), 7, '20', STR_PAD_LEFT)}}-01T01:00')
|
||||||
$('#imagenes').append(
|
$('.calendar').calendar('set date', entrega)
|
||||||
$('<div></div>').attr('class', 'item').append(
|
$('.checkbox').checkbox()
|
||||||
icon
|
@if ($producto->destacado())
|
||||||
).append(
|
$('.checkbox').checkbox('set checked')
|
||||||
$('<div></div>').attr('class', 'content').html(image)
|
@endif
|
||||||
)
|
$("input[name='imagen']").change(function() {
|
||||||
)
|
var data = new FormData()
|
||||||
|
data.append('imagen', $(this)[0].files[0])
|
||||||
|
var url = '{{$urls->admin}}/producto/{{$producto->id}}/imagenes/add'
|
||||||
|
$.ajax({
|
||||||
|
url: url,
|
||||||
|
method: 'post',
|
||||||
|
data: data,
|
||||||
|
contentType: false,
|
||||||
|
processData: false,
|
||||||
|
success: (data) => {
|
||||||
|
if (data.estado) {
|
||||||
|
window.location.reload()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
@foreach ($producto->imagenes() as $image)
|
||||||
|
producto.listImage('{{$image}}')
|
||||||
|
@endforeach
|
||||||
|
$("input[name='video']").change(function() {
|
||||||
|
var fData = new FormData()
|
||||||
|
fData.append('video', $("input[name='video']")[0].files[0])
|
||||||
|
var url = '{{$urls->admin}}/producto/{{$producto->id}}/video/set'
|
||||||
|
$.ajax({
|
||||||
|
url: url,
|
||||||
|
method: 'post',
|
||||||
|
data: fData,
|
||||||
|
contentType: false,
|
||||||
|
processData: false,
|
||||||
|
success: (data) => {
|
||||||
|
if (data.estado) {
|
||||||
|
window.location.reload()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
$('.trash.video').attr('cursor', 'pointer').click(() => {
|
||||||
|
var url = '{{$urls->admin}}/producto/{{$producto->id}}/video/delete'
|
||||||
|
$.post(url, {}, (data) => {
|
||||||
|
if (data.estado) {
|
||||||
|
window.location.reload()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$(document).ready(() => {
|
$(document).ready(() => {
|
||||||
$('.selection.dropdown').dropdown()
|
producto.setup()
|
||||||
$('.selection.dropdown').dropdown('set selected', '{{$producto->segmento}}')
|
|
||||||
$('.calendar').calendar({
|
|
||||||
type: 'month',
|
|
||||||
text: {
|
|
||||||
months: months.long,
|
|
||||||
monthsShort: months.short
|
|
||||||
},
|
|
||||||
formatInput: false,
|
|
||||||
onChange: function(a, b) {
|
|
||||||
if (typeof a == 'undefined') {
|
|
||||||
a = new Date()
|
|
||||||
}
|
|
||||||
$(this).find('input').val(('0' + (a.getMonth() + 1)).slice(-2) + '/' + a.getFullYear())
|
|
||||||
}
|
|
||||||
})
|
|
||||||
var entrega = new Date('{{str_pad(implode('-', array_reverse(explode('/', $producto->entrega))), 7, '20', STR_PAD_LEFT)}}-01T01:00')
|
|
||||||
$('.calendar').calendar('set date', entrega)
|
|
||||||
$('.checkbox').checkbox()
|
|
||||||
@if ($producto->destacado())
|
|
||||||
$('.checkbox').checkbox('set checked')
|
|
||||||
@endif
|
|
||||||
$("input[name='imagen']").change(function() {
|
|
||||||
var data = new FormData()
|
|
||||||
data.append('imagen', $(this)[0].files[0])
|
|
||||||
var url = '{{$urls->admin}}/producto/{{$producto->id}}/imagenes/add'
|
|
||||||
$.ajax({
|
|
||||||
url: url,
|
|
||||||
method: 'post',
|
|
||||||
data: data,
|
|
||||||
contentType: false,
|
|
||||||
processData: false,
|
|
||||||
success: (data) => {
|
|
||||||
if (data.estado) {
|
|
||||||
window.location.reload()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
@foreach ($producto->imagenes() as $image)
|
|
||||||
listImage('{{$image}}')
|
|
||||||
@endforeach
|
|
||||||
$("input[name='video']").change(function() {
|
|
||||||
var fData = new FormData()
|
|
||||||
fData.append('video', $("input[name='video']")[0].files[0])
|
|
||||||
var url = '{{$urls->admin}}/producto/{{$producto->id}}/video/set'
|
|
||||||
$.ajax({
|
|
||||||
url: url,
|
|
||||||
method: 'post',
|
|
||||||
data: fData,
|
|
||||||
contentType: false,
|
|
||||||
processData: false,
|
|
||||||
success: (data) => {
|
|
||||||
if (data.estado) {
|
|
||||||
window.location.reload()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
$('.trash.video').attr('cursor', 'pointer').click(() => {
|
|
||||||
var url = '{{$urls->admin}}/producto/{{$producto->id}}/video/delete'
|
|
||||||
$.post(url, {}, (data) => {
|
|
||||||
if (data.estado) {
|
|
||||||
window.location.reload()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
@endpush
|
@endpush
|
||||||
|
@ -127,40 +127,48 @@
|
|||||||
|
|
||||||
@push('scripts')
|
@push('scripts')
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var months = {
|
var producto = {
|
||||||
long: [],
|
months: {
|
||||||
short: []
|
long: [],
|
||||||
}
|
short: []
|
||||||
var date = new Date(2018, 0, 1)
|
},
|
||||||
for (i = 0; i < 12; i ++) {
|
date: new Date(2018, 0, 1),
|
||||||
date.setMonth(i)
|
setMonths: () => {
|
||||||
months.long.push(date.toLocaleString('es-ES', {month: "long"}).replace(
|
for (i = 0; i < 12; i ++) {
|
||||||
/\w\S*/g,
|
producto.date.setMonth(i)
|
||||||
function(txt) {
|
producto.months.long.push(producto.date.toLocaleString('es-ES', {month: "long"}).replace(
|
||||||
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
|
/\w\S*/g,
|
||||||
|
function(txt) {
|
||||||
|
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
|
||||||
|
}
|
||||||
|
))
|
||||||
|
producto.months.short.push(producto.date.toLocaleString('es-ES', {month: "short"}).replace(
|
||||||
|
/\w\S*/g,
|
||||||
|
function(txt) {
|
||||||
|
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
|
||||||
|
}
|
||||||
|
))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
setup: () => {
|
||||||
|
producto.setMonths()
|
||||||
|
$('.selection.dropdown').dropdown()
|
||||||
|
$('.calendar').calendar({
|
||||||
|
type: 'month',
|
||||||
|
text: {
|
||||||
|
months: months.long,
|
||||||
|
monthsShort: months.short
|
||||||
|
},
|
||||||
|
formatInput: false,
|
||||||
|
onChange: function(a) {
|
||||||
|
$(this).find('input').val(('0' + (a.getMonth() + 1)).slice(-2) + '/' + a.getFullYear())
|
||||||
}
|
}
|
||||||
))
|
})
|
||||||
months.short.push(date.toLocaleString('es-ES', {month: "short"}).replace(
|
$('.checkbox').checkbox()
|
||||||
/\w\S*/g,
|
}
|
||||||
function(txt) {
|
|
||||||
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
|
|
||||||
}
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
$(document).ready(() => {
|
$(document).ready(() => {
|
||||||
$('.selection.dropdown').dropdown()
|
producto.setup()
|
||||||
$('.calendar').calendar({
|
|
||||||
type: 'month',
|
|
||||||
text: {
|
|
||||||
months: months.long,
|
|
||||||
monthsShort: months.short
|
|
||||||
},
|
|
||||||
formatInput: false,
|
|
||||||
onChange: function(a) {
|
|
||||||
$(this).find('input').val(('0' + (a.getMonth() + 1)).slice(-2) + '/' + a.getFullYear())
|
|
||||||
}
|
|
||||||
})
|
|
||||||
$('.checkbox').checkbox()
|
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
@endpush
|
@endpush
|
||||||
|
@ -28,17 +28,22 @@
|
|||||||
|
|
||||||
@push('scripts')
|
@push('scripts')
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var max_width = 0
|
var resumen = {
|
||||||
|
max_width: 0,
|
||||||
|
setup: () => {
|
||||||
|
$('#resumen .circular.segment').each(function(i, el) {
|
||||||
|
var width = $(this).css('width')
|
||||||
|
var w = parseInt(width)
|
||||||
|
if (w > resumen.max_width) {
|
||||||
|
resumen.max_width = w
|
||||||
|
}
|
||||||
|
$(this).css('width', resumen.max_width + 'px')
|
||||||
|
$(this).css('height', resumen.max_width + 'px')
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$('#resumen .circular.segment').each(function(i, el) {
|
resumen.setup()
|
||||||
var width = $(this).css('width')
|
|
||||||
var w = parseInt(width)
|
|
||||||
if (w > max_width) {
|
|
||||||
max_width = w
|
|
||||||
}
|
|
||||||
$(this).css('width', max_width + 'px')
|
|
||||||
$(this).css('height', max_width + 'px')
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
@endpush
|
@endpush
|
||||||
|
@ -34,64 +34,84 @@
|
|||||||
|
|
||||||
@push('scripts')
|
@push('scripts')
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var loaded = {
|
var productos = {
|
||||||
todo: false,
|
id: '#productos',
|
||||||
@foreach ($segmentos as $segmento)
|
current_hash: '',
|
||||||
|
loaded: {
|
||||||
|
todo: false,
|
||||||
|
@foreach ($segmentos as $segmento)
|
||||||
'{{mb_strtolower($segmento->titulo)}}': false,
|
'{{mb_strtolower($segmento->titulo)}}': false,
|
||||||
@endforeach
|
@endforeach
|
||||||
}
|
},
|
||||||
function loadSegmento(segmento) {
|
loadSegmento: (segmento) => {
|
||||||
if (loaded[segmento]) {
|
if (productos.loaded[segmento]) {
|
||||||
return
|
|
||||||
}
|
|
||||||
var name = segmento
|
|
||||||
if (name.indexOf(' ') > -1) {
|
|
||||||
name = name.replaceAll(' ', '_')
|
|
||||||
}
|
|
||||||
var url = '{{$urls->base}}/productos/segmento/' + name
|
|
||||||
$(".tab[data-tab='" + segmento + "']").find('.grid').html('')
|
|
||||||
loaded[segmento] = true
|
|
||||||
$.getJSON(url, (data) => {
|
|
||||||
$(".tab[data-tab='" + segmento + "']").find('.grid').append(
|
|
||||||
$('<div></div>').attr('class', 'ui active centered inline loader')
|
|
||||||
)
|
|
||||||
if (data.productos.length == 0) {
|
|
||||||
$(".tab[data-tab='" + segmento + "']").find('.grid').html('No hay productos en este segmento.')
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
$.each(data.productos, (i, el) => {
|
var name = segmento
|
||||||
getProducto(segmento, el)
|
if (name.indexOf(' ') > -1) {
|
||||||
})
|
name = name.replaceAll(' ', '_')
|
||||||
})
|
|
||||||
}
|
|
||||||
function getProducto(segmento, id_producto) {
|
|
||||||
var url = '{{$urls->base}}/producto/' + id_producto + '/ficha'
|
|
||||||
$.ajax({
|
|
||||||
url: url,
|
|
||||||
success: (data) => {
|
|
||||||
if ($(".tab[data-tab='" + segmento + "']").find('.grid').find('.loader').length > 0) {
|
|
||||||
$(".tab[data-tab='" + segmento + "']").find('.grid').html('')
|
|
||||||
}
|
|
||||||
$(".tab[data-tab='" + segmento + "']").find('.grid').append(
|
|
||||||
$('<div></div>').attr('class', 'column').append(data)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
})
|
var url = '{{$urls->base}}/productos/segmento/' + name
|
||||||
}
|
$(".tab[data-tab='" + segmento + "']").find('.grid').html('')
|
||||||
$(document).ready(() => {
|
productos.loaded[segmento] = true
|
||||||
loadSegmento('todo')
|
$.getJSON(url, (data) => {
|
||||||
$('#productos').find('.tabular.menu .item').tab({
|
$(".tab[data-tab='" + segmento + "']").find('.grid').append(
|
||||||
onFirstLoad: (tabPath, parameterArray, historyEvent) => {
|
$('<div></div>').attr('class', 'ui active centered inline loader')
|
||||||
if (tabPath == 'todo') {
|
)
|
||||||
|
if (data.productos.length == 0) {
|
||||||
|
$(".tab[data-tab='" + segmento + "']").find('.grid').html('No hay productos en este segmento.')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
loadSegmento(tabPath)
|
$.each(data.productos, (i, el) => {
|
||||||
|
productos.getProducto(segmento, el)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
getProducto: (segmento, id_producto) => {
|
||||||
|
var url = '{{$urls->base}}/producto/' + id_producto + '/ficha'
|
||||||
|
$.ajax({
|
||||||
|
url: url,
|
||||||
|
success: (data) => {
|
||||||
|
if ($(".tab[data-tab='" + segmento + "']").find('.grid').find('.loader').length > 0) {
|
||||||
|
$(".tab[data-tab='" + segmento + "']").find('.grid').html('')
|
||||||
|
}
|
||||||
|
$(".tab[data-tab='" + segmento + "']").find('.grid').append(
|
||||||
|
$('<div></div>').attr('class', 'column').append(data)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
setup: () => {
|
||||||
|
productos.loadSegmento('todo')
|
||||||
|
$(productos.id).find('.tabular.menu .item').tab({
|
||||||
|
onFirstLoad: (tabPath, parameterArray, historyEvent) => {
|
||||||
|
if (tabPath == 'todo') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
productos.loadSegmento(tabPath)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
$('#productos_menu').find('.menu .item').click(function() {
|
||||||
|
productos.getHash($(this).attr('href').split('#')[1])
|
||||||
|
})
|
||||||
|
if (window.location.hash) {
|
||||||
|
productos.getHash(window.location.hash)
|
||||||
}
|
}
|
||||||
})
|
},
|
||||||
if (window.location.hash) {
|
getHash: (hash) => {
|
||||||
var start = (window.location.hash).replace('#', '').replace('%20', ' ')
|
if (typeof hash == 'undefined') {
|
||||||
$('#productos').find('.tabular.menu .item').tab('change tab', start)
|
hash = window.location.hash
|
||||||
|
}
|
||||||
|
var start = (hash).replace('#', '').replace('%20', ' ')
|
||||||
|
if (productos.current_hash == start) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
productos.current_hash = start
|
||||||
|
$(productos.id).find('.tabular.menu .item').tab('change tab', start)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
$(document).ready(() => {
|
||||||
|
productos.setup()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
@endpush
|
@endpush
|
||||||
|
@ -30,15 +30,38 @@
|
|||||||
|
|
||||||
@push('scripts')
|
@push('scripts')
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function changePrice(min, max) {
|
var buscar = {
|
||||||
|
min: 1000,
|
||||||
|
max: 30000,
|
||||||
|
changePrice: (min, max) => {
|
||||||
|
$("input[name='precio']").val(min + '-' + max)
|
||||||
|
formatter = new Intl.NumberFormat('de-DE')
|
||||||
|
$('.price_label').html(formatter.format(min) + ' - ' + formatter.format(max) + ' UF')
|
||||||
|
},
|
||||||
|
setup: () => {
|
||||||
|
buscar.changePrice(buscar.min, buscar.max)
|
||||||
|
$('#precio').slider({
|
||||||
|
min: buscar.min,
|
||||||
|
max: buscar.max,
|
||||||
|
start: buscar.min,
|
||||||
|
end: buscar.max,
|
||||||
|
step: 500,
|
||||||
|
onChange: (range, min, max) => {
|
||||||
|
buscar.changePrice(min, max)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*function changePrice(min, max) {
|
||||||
$("input[name='precio']").val(min + '-' + max)
|
$("input[name='precio']").val(min + '-' + max)
|
||||||
formatter = new Intl.NumberFormat('de-DE')
|
formatter = new Intl.NumberFormat('de-DE')
|
||||||
$('.price_label').html(formatter.format(min) + ' - ' + formatter.format(max) + ' UF')
|
$('.price_label').html(formatter.format(min) + ' - ' + formatter.format(max) + ' UF')
|
||||||
}
|
}
|
||||||
var gMin = 1000
|
var gMin = 1000
|
||||||
var gMax = 30000
|
var gMax = 30000*/
|
||||||
$(document).ready(() => {
|
$(document).ready(() => {
|
||||||
changePrice(gMin, gMax)
|
buscar.setup()
|
||||||
|
/*changePrice(gMin, gMax)
|
||||||
$('#precio').slider({
|
$('#precio').slider({
|
||||||
min: gMin,
|
min: gMin,
|
||||||
max: gMax,
|
max: gMax,
|
||||||
@ -48,7 +71,7 @@
|
|||||||
onChange: (range, min, max) => {
|
onChange: (range, min, max) => {
|
||||||
changePrice(min, max)
|
changePrice(min, max)
|
||||||
}
|
}
|
||||||
})
|
})*/
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
@endpush
|
@endpush
|
||||||
|
@ -20,49 +20,47 @@
|
|||||||
|
|
||||||
@push('scripts')
|
@push('scripts')
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var images = [
|
var galeria = {
|
||||||
@foreach ($producto->imagenes() as $image)
|
images: [
|
||||||
'{{$urls->images}}/{{mb_strtolower($producto->nombre)}}/{{$image}}',
|
@foreach ($producto->imagenes() as $image)
|
||||||
@endforeach
|
'{{$urls->images}}/{{mb_strtolower($producto->nombre)}}/{{$image}}',
|
||||||
]
|
@endforeach
|
||||||
function populateThumbs(current) {
|
],
|
||||||
var thumbs = $('#thumbnails')
|
populateThumbs: (current) => {
|
||||||
thumbs.html('')
|
var thumbs = $('#thumbnails')
|
||||||
$.each(images, (i, el) => {
|
thumbs.html('')
|
||||||
if (i == current) {
|
$.each(galeria.images, (i, el) => {
|
||||||
return
|
if (i == current) {
|
||||||
}
|
return
|
||||||
thumbs.append(
|
}
|
||||||
$('<div></div>').attr('class', 'three wide column').append(
|
thumbs.append(
|
||||||
$('<div></div>').attr('class', 'ui image').attr('data-id', i).append(
|
$('<div></div>').attr('class', 'three wide column').append(
|
||||||
$('<img />').attr('src', el)
|
$('<div></div>').attr('class', 'ui image').attr('data-id', i).append(
|
||||||
|
$('<img />').attr('src', el)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
})
|
||||||
})
|
$('#galeria').find('.grid .image').click(function(e) {
|
||||||
$('#galeria').find('.grid .image').click(function(e) {
|
var id = $(this).attr('data-id')
|
||||||
var id = $(this).attr('data-id')
|
galeria.changeImage(id)
|
||||||
changeImage(id)
|
})
|
||||||
})
|
},
|
||||||
}
|
changeImage: (id) => {
|
||||||
function changeImage(id) {
|
var big = $('#galeria>.image')
|
||||||
var big = $('#galeria>.image')
|
|
||||||
big.find('img').attr('src', images[id])
|
|
||||||
big.attr('data-id', id)
|
|
||||||
populateThumbs(id)
|
|
||||||
}
|
|
||||||
$(document).ready(() => {
|
|
||||||
$('#galeria').find('.grid .image').click(function(e) {
|
|
||||||
var id = $(this).attr('data-id')
|
|
||||||
changeImage(id)
|
|
||||||
/*var big = $('#galeria>.image')
|
|
||||||
var big_id = big.attr('data-id')
|
|
||||||
big.find('img').attr('src', images[id])
|
big.find('img').attr('src', images[id])
|
||||||
big.attr('data-id', id)
|
big.attr('data-id', id)
|
||||||
$(this).find('img').attr('src', images[big_id])
|
galeria.populateThumbs(id)
|
||||||
$(this).attr('data-id', big_id)
|
},
|
||||||
populateThumbs(id)*/
|
setup: () => {
|
||||||
})
|
$('#galeria').find('.grid .image').click(function(e) {
|
||||||
|
var id = $(this).attr('data-id')
|
||||||
|
galeria.changeImage(id)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$(document).ready(() => {
|
||||||
|
galeria.setup()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
@endpush
|
@endpush
|
||||||
|
Reference in New Issue
Block a user