(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/cs_CZ/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
/** úprava anchoru */
$(document).ready(function() {
var pathname = window.location.href.split('#')[0];
$('a[href^="#"]').each(function() {
var $this = $(this),
link = $this.attr('href');
$this.attr('href', pathname + link);
});
});
var barva = '';
var stopForm = 0;
/*
* jQuery UI Autocomplete HTML Extension
*
* Copyright 2010, Scott González (http://scottgonzalez.com)
* Dual licensed under the MIT or GPL Version 2 licenses.
*
* http://github.com/scottgonzalez/jquery-ui-extensions
*/
(function( $ ) {
var proto = $.ui.autocomplete.prototype,
initSource = proto._initSource;
function filter( array, term ) {
var matcher = new RegExp( $.ui.autocomplete.escapeRegex(term), "i" );
return $.grep( array, function(value) {
return matcher.test( $( "
" ).html( value.label || value.value || value ).text() );
});
}
$.extend( proto, {
_initSource: function() {
if ( this.options.html && $.isArray(this.options.source) ) {
this.source = function( request, response ) {
response( filter( this.options.source, request.term ) );
};
} else {
initSource.call( this );
}
},
_renderItem: function( ul, item) {
return $( "
" )
.data( "item.autocomplete", item )
.append( $( "
" )[ this.options.html ? "html" : "text" ]( item.label ) )
.appendTo( ul );
}
});
})( jQuery );
$(function() {
$('.tooltips').tooltip();
$('.napoveda').popover({title:"Nápověda",placement: 'auto top'});
/*$('#myCarousel').on('slid.bs.carousel', function (iam)
{
$("#mainMenu").removeClass(barva);
barva = $("#myCarousel .item.active").data("barva");
$("#mainMenu").addClass(barva);
});*/
$('#slideshowHome').cycle(
{
fx: 'fade',
pager: '#nav',
timeout: 6000,
delay: 4000,
slideExpr: 'img',
// callback fn that creates a thumbnail to use as pager anchor
pagerAnchorBuilder: function(idx, slide) {
var newsrc = slide.src;
newsrc = newsrc.replace("uvodnistranka/","uvodnistranka/thumb_");
return '

';
}
});
$("#searchIcon").click(function(){
$("#searchForm").fadeToggle();
$("#searchInput").focus();
});
$("#filtrForm input").change(function(){
$("#filtrForm").submit();
});
$("#searchForm").submit(function(){
$("#searchInput").focus();
return false;
});
});
jQuery.validator.addMethod("multiemail", function (value, element) {
if (this.optional(element)) {
return true;
}
var emails = value.split(','),
valid = true;
for (var i = 0, limit = emails.length; i < limit; i++) {
value = emails[i];
valid = valid && jQuery.validator.methods.email.call(this, value, element);
}
return valid;
}, "Špatný formát emailu: na rozdělení více emailů použijte čárku.");
jQuery.extend(jQuery.validator.messages, {
required: "Tento údaj je povinný.",
remote: "Prosím, opravte tento údaj.",
email: "Prosím, zadejte platný e-mail.",
url: "Prosím, zadejte platné URL.",
date: "Prosím, zadejte platné datum.",
dateISO: "Prosím, zadejte platné datum (ISO).",
number: "Prosím, zadejte číslo.",
digits: "Prosím, zadávejte pouze číslice.",
creditcard: "Prosím, zadejte číslo kreditní karty.",
equalTo: "Prosím, zadejte znovu stejnou hodnotu.",
accept: "Prosím, zadejte soubor se správnou příponou.",
maxlength: jQuery.validator.format("Prosím, zadejte nejvíce {0} znaků."),
minlength: jQuery.validator.format("Prosím, zadejte nejméně {0} znaků."),
rangelength: jQuery.validator.format("Prosím, zadejte od {0} do {1} znaků."),
range: jQuery.validator.format("Prosím, zadejte hodnotu od {0} do {1}."),
max: jQuery.validator.format("Prosím, zadejte hodnotu menší nebo rovnu {0}."),
min: jQuery.validator.format("Prosím, zadejte hodnotu větší nebo rovnu {0}.")
});
$(document).ready(function()
{
initColorPick('.colorpick');
//pro potřeby admina
$(".deleteRow").addClass("click");
$("body").on( "click", '.deleteRow', function() {
conf = confirm('Opravdu smazat?');
if(conf)
{
$(this).parent().parent().remove();
}
});
// end
//$(".gallery a").fancybox({'padding': 0,'overlayShow':true,'titlePosition' : 'over',centerOnScroll:'true',onStart: function(){ stopScroll=1; },onClosed: function(){ stopScroll=0; }});
$(".datum").datepicker({ dateFormat: 'yy-mm-dd' });
$("#form").validate();
$( "#searchInput" ).autocomplete({
source: "/ajax/search",
minLength: 2,
html: true,
autoFocus: true,
delay: 150,
change: function( event, ui ) {
if(ui.item != null)
{
if(ui.item.link != false)
{
window.location.href=ui.item.link;
}else{
$(this).val( ui.item.value );
}
}else{
}
return false;
},select: function( event, ui ) {
if(ui.item != null)
{
if(ui.item.link != false)
{
window.location.href=ui.item.link;
}else{
$(this).val( ui.item.value );
}
}else{
}
return false;
}
});
// Select all
$("button[name='select_all']").click( function() {
$("input[type='checkbox']").prop('checked', true).change();
return false;
});
// Select all
$(".select_all").click( function() {
$("input[type='checkbox']").prop('checked', true).change();
return false;
});
// Select none
$(".select_none").click( function() {
$("input[type='checkbox']").prop('checked', false).change();
return false;
});
// Invert selection
$(".invert_selection").click( function() {
$("input[type='checkbox']").each( function()
{
$(this).prop('checked', !$(this).prop('checked')).change();
});
return false;
});
});
function checkStateTRcontrol(_this)
{
if( $(_this).prop("checked") )
{
$(_this).parents("tr").addClass("active");
}else{
$(_this).parents("tr").removeClass("active");
}
}
function initColorPick(tuten)
{
$(tuten).ColorPicker({
onSubmit: function(hsb, hex, rgb, el) {
$(el).val('#'+hex).css('borderRight', '10px solid #'+hex);
$(el).ColorPickerHide();
},
onBeforeShow: function () {
$(this).ColorPickerSetColor(this.value);
}
})
.bind('keyup', function(){
$(this).ColorPickerSetColor(this.value);
});
}
function deleteLine(typ, id)
{
var dotaz = confirm('Opravdu vymazat položku?');
if(dotaz)
{
$.ajax({
type: "POST",
url: "/ajax/deleteLine",
data: {id: id, typ: typ},
success: function(html){
if (html=="x"){ alert("Vyskytla se chyba při úpravě."); }
else{
$("#uu"+id+"").fadeOut();
}
}
});
}
}
function changeLine(typ, id)
{
var dotaz = confirm('Opravdu změnit položku?');
if(dotaz)
{
$.ajax({
type: "POST",
url: "/ajax/changeLine",
data: {id: id, typ: typ},
success: function(html){
if (html=="x"){ alert("Vyskytla se chyba při úpravě."); }
else{
$("#uu"+id+"").find(".change").fadeOut();
}
}
});
}
}
function JSemailSend(email,predmet,text)
{
$.ajax({
type: "POST",
url: "/ajax/emailSend",
data: {email:email,predmet: predmet, text: text},
success: function(html){
if (html=="x"){ alert("Vyskytla se chyba při odesílání."); }
else{
}
}
});
}
function formSubmit()
{
$("#form").submit();
}
function bytesToSize(bytes, precision) {
var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
var posttxt = 0;
if (bytes == 0) return 'n/a';
while( bytes >= 1024 ) {
posttxt++;
bytes = bytes / 1024;
}
return parseInt(bytes).toFixed(precision) + " " + sizes[posttxt];
}
function roundNumber(num, dec) {
var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
return result;
}