metamaps--metamaps/app/views/maps/create.js.erb
2014-02-10 01:47:48 -05:00

41 lines
1.3 KiB
Text

/*
* @file
* Javascript run on creation of a new map
*/
$('#map_name').val('');
$('#map_desc').val('');
$('#map_permission').val('commons');
<% if @forked %>
$('#map_topicsToMap').val('0');
$('#map_synapsesToMap').val('0');
var form = $('#fork_map');
<% else %>
var form = $('#new_map');
<% end %>
form.find('.mapPermIcon').removeClass('selected');
form.find('.mapCommonsIcon').addClass('selected');
var tempForm = form.html();
if (mapid == null) {
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>");
}
else if (mapid != null) {
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>");
}
$('#lightbox_main').css('margin-top', '-' + ($('#lightbox_main').height() / 2) + 'px' );
function closeIt() {
$('#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');
});
}