|
| 1 | +function replaceJournalDiff() |
| 2 | +{ |
| 3 | + $("#history div.journal ul > li > a").each(function(){ |
| 4 | + //find li |
| 5 | + var orgDiff = $(this).parent(); |
| 6 | + var popDiff = $(this).parents("div.journal:first").next("li"); |
| 7 | + |
| 8 | + //replace and set func |
| 9 | + popDiff.replaceAll(orgDiff).find("a").on("click", function(){ |
| 10 | + var diffUrl = $(this).attr("href"); |
| 11 | + var journalIndice = diffUrl.split("&indice=")[1]; |
| 12 | + var dlgName = "#diffpopup" + journalIndice; |
| 13 | + |
| 14 | + //on top dialog |
| 15 | + if ($(dlgName).size() == 1) |
| 16 | + { |
| 17 | + $(dlgName).dialog("moveToTop"); |
| 18 | + return; |
| 19 | + } |
| 20 | + |
| 21 | + //show dialog |
| 22 | + $.get(diffUrl, function (data) { |
| 23 | + var journalIndice = decodeURIComponent(this.url.split("?")[1].split("&indice=")[1]); |
| 24 | + var popupId = "diffpopup" + journalIndice; |
| 25 | + $("#content").append("<div id='" + popupId + "'></div>"); |
| 26 | + $("#" + popupId).html(data).dialog({ |
| 27 | + title: "#" + journalIndice, |
| 28 | + width: window.innerWidth / 2 - 40, |
| 29 | + maxHeight: window.innerHeight - 160, |
| 30 | + position: { my: "center center", at: "right center", of: window }, |
| 31 | + create: function(event) { |
| 32 | + $(event.target).dialog("widget").css({ "position": "fixed" }); |
| 33 | + }, |
| 34 | + open: function() { |
| 35 | + $(this).find("a").blur(); |
| 36 | + }, |
| 37 | + close: function (event) { |
| 38 | + $(this).dialog("destroy"); |
| 39 | + $(event.target).remove(); |
| 40 | + } |
| 41 | + }).show(); |
| 42 | + }); |
| 43 | + }); |
| 44 | + }); |
| 45 | +} |
0 commit comments