nineskeletor/assets/js/app.js

103 lines
2.7 KiB
JavaScript
Executable File

$(document).ready(function() {
// Color
$(".pick-a-color").spectrum(
{
preferredFormat: "hex",
type: "string",
showPalette: true,
allowEmpty: true,
showAlpha: false,
}
);
$(".pick-a-color").attr("autocomplete","off");
// Method confirm
var doit = true;
$("a[data-method]").on('click',function(){
if($(this).data('confirm')){
doit = confirm($(this).data('confirm'));
if(!doit) return false;
}
});
$("button[data-method]").on('click',function(){
if($(this).data('confirm')){
doit = confirm($(this).data('confirm'));
if(!doit) return false;
}
});
// Modal
$(".btn-modal").click(function() {
$("#"+$(this).data("modalid")+" .modal-title").text($(this).data("modaltitle"));
$("#"+$(this).data("modalid")+" iframe").attr("src",$(this).data("modalurl"));
$("#"+$(this).data("modalid")).modal("show");
});
// Item
$( ".item" ).hover(function() {
$(this).find(".item-action a").show();
});
$( ".item" ).mouseleave(function() {
$(this).find(".item-action a").hide();
});
$( ".item-info" ).click(function() {
parent=$(this).parent().parent().parent().parent().parent();
if(parent.find(".item-description").hasClass("hide")) {
parent.find(".item-description").removeClass("hide");
parent.addClass("w-100");
parent.css("justify-content","flex-start");
}
else {
parent.find(".item-description").addClass("hide");
parent.removeClass("w-100");
if(parent.hasClass("item-large"))
parent.css("justify-content","flex-start");
else
parent.css("justify-content","center");
}
});
// select2-icon
function iformat(icon) {
return $('<span><i class="' + icon.id + '"></i> ' + icon.text + '</span>');
}
$('.select2-icon').select2({
width: "100%",
placeholder: 'choisir un icône',
allowClear: true,
templateSelection: iformat,
templateResult: iformat,
formatResult: iformat,
allowHtml: true,
escapeMarkup: function(m) {
return m;
}
})
// Menu
$(".dropdown-toggle").click(function(){
$(this).parent().find(".dropdown-menu").toggle();
})
$(".nav-toogle").click(function(){
$("#selmenu").modal("toggle");
})
// Forcer le resize des objects
Resize();
// Focus
$("#page").focus();
});
$( window ).resize(function() {
Resize();
});