2011-10-22 13:44:34 +00:00
|
|
|
$(document).ready(function(){
|
2012-03-02 20:32:17 +00:00
|
|
|
newSiteHtml = '<li><input type="text" class="site_name" name="site_name[]" value="" placeholder="Name" />\n\
|
|
|
|
<input type="text" name="site_url[]" class="site_url" value="" placeholder="URL" />\n\
|
|
|
|
<img class="svg action delete_button" src="'+OC.imagePath("core", "actions/delete") +'" title="Remove site" /></li>';
|
2011-10-22 13:44:34 +00:00
|
|
|
|
2012-03-02 20:32:17 +00:00
|
|
|
// Handler functions
|
|
|
|
function addSiteEventHandler(event) {
|
2011-10-22 13:44:34 +00:00
|
|
|
event.preventDefault();
|
2012-03-02 20:32:17 +00:00
|
|
|
|
|
|
|
saveSites();
|
|
|
|
}
|
2011-10-22 13:44:34 +00:00
|
|
|
|
2012-03-02 20:32:17 +00:00
|
|
|
function deleteButtonEventHandler(event) {
|
2011-10-22 13:44:34 +00:00
|
|
|
event.preventDefault();
|
|
|
|
|
2012-03-02 20:32:17 +00:00
|
|
|
$(this).tipsy('hide');
|
|
|
|
$(this).parent().remove();
|
2011-10-22 13:44:34 +00:00
|
|
|
|
2012-03-02 20:32:17 +00:00
|
|
|
saveSites();
|
|
|
|
}
|
2011-10-22 13:44:34 +00:00
|
|
|
|
2012-03-02 20:32:17 +00:00
|
|
|
function saveSites() {
|
|
|
|
var post = $('#external').serialize();
|
|
|
|
$.post( OC.filePath('external','ajax','setsites.php') , post, function(data) {
|
|
|
|
// OC.msg.finishedSaving('#site_name .msg', data);
|
|
|
|
});
|
|
|
|
}
|
2011-10-22 13:44:34 +00:00
|
|
|
|
2012-03-02 20:32:17 +00:00
|
|
|
function showDeleteButton(event) {
|
|
|
|
$(this).find('img.delete_button').fadeIn(100);
|
|
|
|
}
|
2011-10-22 13:44:34 +00:00
|
|
|
|
2012-03-02 20:32:17 +00:00
|
|
|
function hideDeleteButton(event) {
|
|
|
|
$(this).find('img.delete_button').fadeOut(100);
|
|
|
|
}
|
2011-10-22 13:44:34 +00:00
|
|
|
|
2012-03-02 20:32:17 +00:00
|
|
|
// Initialize events
|
|
|
|
$('input[name^=site_]').change(addSiteEventHandler);
|
|
|
|
$('img.delete_button').click(deleteButtonEventHandler);
|
|
|
|
$('img.delete_button').tipsy();
|
2011-10-22 13:44:34 +00:00
|
|
|
|
2012-03-02 20:32:17 +00:00
|
|
|
$('#external li').hover(showDeleteButton, hideDeleteButton);
|
2011-10-22 13:44:34 +00:00
|
|
|
|
2012-03-02 20:32:17 +00:00
|
|
|
$('#add_external_site').click(function(event) {
|
2011-10-22 13:44:34 +00:00
|
|
|
event.preventDefault();
|
2012-03-02 20:32:17 +00:00
|
|
|
$('#external ul').append(newSiteHtml);
|
2011-10-22 13:44:34 +00:00
|
|
|
|
2012-03-02 20:32:17 +00:00
|
|
|
$('input.site_url:last').prev('input.site_name').andSelf().change(addSiteEventHandler);
|
|
|
|
$('img.delete_button').click(deleteButtonEventHandler);
|
|
|
|
$('img.delete_button:last').tipsy();
|
|
|
|
$('#external li:last').hover(showDeleteButton, hideDeleteButton);
|
|
|
|
|
|
|
|
});
|
2011-10-22 13:44:34 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|