2013-01-11 23:49:59 +00:00
/*
* @file
* Javascript run on creation of a new map
*/
2014-01-31 00:32:15 +00:00
2012-12-25 23:29:20 +00:00
$('#map_name').val('');
$('#map_desc').val('');
$('#map_permission').val('commons');
2014-01-31 00:32:15 +00:00
<% if @forked %>
$('#map_topicsToMap').val('0');
$('#map_synapsesToMap').val('0');
var form = $('#fork_map');
<% else %>
var form = $('#new_map');
<% end %>
2014-02-06 17:40:44 +00:00
form.find('.mapPermIcon').removeClass('selected');
form.find('.mapCommonsIcon').addClass('selected');
2014-01-31 00:32:15 +00:00
var tempForm = form.html();
2013-01-06 23:40:48 +00:00
if (mapid == null) {
2014-02-10 06:47:48 +00:00
form.html("Success! Do you want to <br> <a href='/maps/" + '<%= @map.id %>' + "'>Go to your new map?</a><br>or<br><a href='#' onclick='closeIt(); return false;'>Stay on this page?</a>");
2013-01-06 23:40:48 +00:00
}
else if (mapid != null) {
2014-02-10 06:47:48 +00:00
form.html("Success! Do you want to <br> <a href='/maps/" + '<%= @map.id %>' + "'>Go to your new map?</a><br>or<br><a href='#' onclick='closeIt(); return false;'>Stay on this map?</a>");
2013-01-06 23:40:48 +00:00
}
2014-02-06 17:40:44 +00:00
$('#lightbox_main').css('margin-top', '-' + ($('#lightbox_main').height() / 2) + 'px' );
2012-12-25 23:29:20 +00:00
function closeIt() {
2014-02-06 17:40:44 +00:00
$('#lightbox_overlay').hide();
form.html(tempForm);
// bind permission changer events
form.find('.permIcon').click(function() {
$(this).siblings('#map_permission').val( $(this).attr('data-permission') );
$(this).siblings('.permIcon').find('.mapPermIcon').removeClass('selected');
$(this).find('.mapPermIcon').addClass('selected');
});
2013-01-11 23:49:59 +00:00
}