52 lines
1.6 KiB
JavaScript
52 lines
1.6 KiB
JavaScript
$(document).ready(function(){
|
|
$('body').append('<a href="#city" id="city-menu"><img src="images/interface/weather.png" /></a><div style="display:none;"><div id="city"></div></div>');
|
|
$('#menu-bar').prepend($('#city-menu'));
|
|
$('#city').append('<h3>Quelle ville pour la météo ?</h3><br/><input type="text" id="cityChoice" name="cityChoice"/><span id="city-submit" class="green-button">Enregistrer</span>');
|
|
$('#city-menu').fancybox({
|
|
'zoomSpeedIn' : 600,
|
|
'zoomSpeedOut' : 500,
|
|
'easingIn' : 'easeOutBack',
|
|
'easingOut' : 'easeInBack',
|
|
'hideOnContentClick': false,
|
|
'padding' : 15
|
|
});
|
|
$('#city-submit').live('click', function(){
|
|
var ville = $('#cityChoice').val();
|
|
if(ville != '' || ville != null){
|
|
$.get('ajax/update-city.php', {city: ville}, function(msg){
|
|
if(msg=='ok'){
|
|
location.reload();
|
|
}else{
|
|
$('#city').append('<span class="error">An error occured while changing city.</span>');
|
|
}
|
|
});
|
|
}else{
|
|
$('#city').append('<span class="error">City can\'t be empty.</span>');
|
|
}
|
|
});
|
|
|
|
var tmp;
|
|
|
|
/* A helper function for converting a set of elements to draggables: */
|
|
make_draggable($('#weather'));
|
|
|
|
var zIndex = 0;
|
|
|
|
function make_draggable(elements)
|
|
{
|
|
/* Elements is a jquery object: */
|
|
elements.draggable({
|
|
containment:'parent',
|
|
start:function(e,ui){ ui.helper.css('z-index',++zIndex); },
|
|
stop:function(e,ui){
|
|
|
|
/* Sending the z-index and positon of the note to update_position.php via AJAX GET: */
|
|
$.get('ajax/update_position_config.php',{
|
|
x : ui.position.left,
|
|
y : ui.position.top,
|
|
id : ui.helper.attr('id')
|
|
});
|
|
}
|
|
});}
|
|
});
|