(ed)
| 425 | menu.find('li[title]').tipsy({opacity: 1, delayIn: 1000, gravity: 'w'}); |
| 426 | |
| 427 | function handleShare(ed) { |
| 428 | var fork = $(this).attr('id') == 'fork'; |
| 429 | if (key == '') key = ''.random(8); |
| 430 | var count = 0; |
| 431 | function post_save(side, text) { |
| 432 | $.ajax({ |
| 433 | type: 'POST', async: true, dataType: 'text', |
| 434 | url: '/ajax/handle_file.php', |
| 435 | data: { 'key': key, 'name': side, 'content': text }, |
| 436 | success: function (nkey) { |
| 437 | ++count; |
| 438 | if (count == 2) { |
| 439 | var url = '/ajax/handle_save.php?key=' + key; |
| 440 | if (fork) url += '&nkey=' + ''.random(8); |
| 441 | $.ajax({ |
| 442 | type: 'GET', async: false, dataType: 'text', |
| 443 | url: url, |
| 444 | success: function (nkey) { |
| 445 | // redirect |
| 446 | if (nkey.length) window.location.href = '/' + $.trim(nkey) + '/'; |
| 447 | }, |
| 448 | error: function(xhr, ajaxOptions, thrownError){ |
| 449 | } |
| 450 | }); |
| 451 | } |
| 452 | }, |
| 453 | error: function(xhr, ajaxOptions, thrownError){ |
| 454 | alert(thrownError); |
| 455 | } |
| 456 | }); |
| 457 | } |
| 458 | function save_files() { |
| 459 | var lhs = ed.mergely('get', 'lhs'); |
| 460 | var rhs = ed.mergely('get', 'rhs'); |
| 461 | post_save('lhs', lhs); |
| 462 | post_save('rhs', rhs); |
| 463 | } |
| 464 | |
| 465 | $( '#dialog-confirm' ).dialog({ |
| 466 | resizable: false, width: 350, modal: true, |
| 467 | buttons: { |
| 468 | 'Save for Sharing': function() { |
| 469 | $( this ).dialog( 'close' ); |
| 470 | save_files(); |
| 471 | }, |
| 472 | Cancel: function() { |
| 473 | $( this ).dialog( 'close' ); |
| 474 | } |
| 475 | } |
| 476 | }); |
| 477 | } |
| 478 | |
| 479 | function crossdomainGET(ed, side, url) { |
| 480 | $.ajax({ |
no test coverage detected