mirrorsettings.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. $(function() {
  2. /**
  3. * Append 'ajax=1' parameter onto URL.
  4. */
  5. function ajaxize(url) {
  6. if (url.indexOf('?') == '-1') {
  7. return url + '?ajax=1';
  8. } else {
  9. return url + '&ajax=1';
  10. }
  11. }
  12. var addMirror = $('#add-mirror');
  13. var wizard = $('#add-mirror-wizard');
  14. if (wizard.length > 0) {
  15. var list = wizard.find('.provider-list');
  16. var providers = list.find('.provider-heading');
  17. providers.click(function(event) {
  18. console.log(this);
  19. var targetUrl = $(this).find('a').attr('href');
  20. if (targetUrl) {
  21. // Make sure we don't accidentally follow the direct link
  22. event.preventDefault();
  23. var node = this;
  24. function showNew() {
  25. var detail = $('<div class="provider-detail" style="display: none"></div>').insertAfter(node);
  26. detail.load(ajaxize(targetUrl), function(responseText, testStatus, xhr) {
  27. detail.slideDown('fast', function() {
  28. detail.find('input[type="text"]').focus();
  29. });
  30. });
  31. }
  32. var old = addMirror.find('.provider-detail');
  33. if (old.length) {
  34. old.slideUp('fast', function() {
  35. old.remove();
  36. showNew();
  37. });
  38. } else {
  39. showNew();
  40. }
  41. }
  42. });
  43. }
  44. });