2010-05-10 22:39:52 +00:00
|
|
|
$(document).ready(function() {
|
|
|
|
|
2010-05-19 16:17:45 +00:00
|
|
|
var defaultValue = $('fieldset.editable-list li.template input[type=text]').val();
|
2010-07-15 20:48:02 +00:00
|
|
|
|
2010-05-10 22:39:52 +00:00
|
|
|
/* __ fields ___ */
|
2010-05-19 16:17:45 +00:00
|
|
|
$('fieldset.editable-list li.template input[type=text]').focus(function() {
|
|
|
|
if ($(this).hasClass('void') && $(this).parents('li').hasClass('template'))
|
2010-05-10 22:39:52 +00:00
|
|
|
$(this).val('').removeClass('void');
|
|
|
|
});
|
|
|
|
|
2010-05-19 16:17:45 +00:00
|
|
|
$('fieldset.editable-list li.template button').click(function() {
|
|
|
|
var lastRow = $(this).parents('li.template');
|
2010-05-10 22:39:52 +00:00
|
|
|
|
|
|
|
var currentValue = lastRow.find('input.label').val();
|
|
|
|
if (currentValue == defaultValue || currentValue == '') return;
|
|
|
|
|
2010-05-19 16:17:45 +00:00
|
|
|
var newRow = lastRow.clone(true).removeClass('template').addClass('added').insertBefore(lastRow);
|
2010-05-10 22:39:52 +00:00
|
|
|
|
|
|
|
// should copy the value of the select box
|
|
|
|
var input = newRow.find('input.label')
|
|
|
|
.attr('name', 'site[domains][]');
|
|
|
|
if (lastRow.find('input.label').val() == '') input.val("undefined");
|
|
|
|
|
|
|
|
// then reset the form
|
|
|
|
lastRow.find('input').val(defaultValue).addClass('void');
|
|
|
|
lastRow.find('select').val('input');
|
|
|
|
});
|
|
|
|
|
|
|
|
$('fieldset.editable-list li a.remove').click(function(e) {
|
|
|
|
if (confirm($(this).attr('data-confirm')))
|
|
|
|
$(this).parents('li').remove();
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
});
|
2010-07-15 20:48:02 +00:00
|
|
|
|
|
|
|
$.subscribe('form.saved.success', function(event, data) {
|
|
|
|
$('#header h1 a').html($('#current_site_name').val());
|
|
|
|
}, []);
|
2010-05-10 22:39:52 +00:00
|
|
|
});
|