Created
April 1, 2013 03:35
-
-
Save vstorm83/5283124 to your computer and use it in GitHub Desktop.
dialog patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/home/phuongvv/Desktop/Classy Groundcovers - Finding Your Perfect Plants_files/dialog.js b/Classy Groundcovers - Finding Your Perfect Plants_files/dialog.js | |
| index ee6badf..b941c2c 100644 | |
| --- a/home/phuongvv/Desktop/Classy Groundcovers - Finding Your Perfect Plants_files/dialog.js | |
| +++ b/Classy Groundcovers - Finding Your Perfect Plants_files/dialog.js | |
| @@ -18,6 +18,7 @@ $(function() { | |
| } else if (typeof (r.w) === 'number') { | |
| w = r.w; | |
| } | |
| + var $link = $(this); | |
| d | |
| .dialog({ | |
| width : w, | |
| @@ -34,9 +35,29 @@ $(function() { | |
| } | |
| }, | |
| close : function(event, ui) { | |
| + $(window).off('popstate'); | |
| + $(document).off('click.dialog.close.' + $link.data('hash')); | |
| $(this).empty().dialog('destroy'); | |
| }, | |
| open : function(event, ui) { | |
| + $(window) | |
| + .popstate( | |
| + function() { | |
| + if (d.dialog("isOpen") | |
| + && $link.data('hash') !== location.hash.replace('#', | |
| + '')) { | |
| + d.dialog('close'); | |
| + } | |
| + }); | |
| + | |
| + $(document).on( | |
| + 'click.dialog.close.' + $link.data('hash'), | |
| + function(e) { | |
| + if ($(e.target).closest(d.closest('.ui-dialog')).length == 0 | |
| + && d.dialog("isOpen")) { | |
| + d.dialog('close'); | |
| + } | |
| + }); | |
| var buttons = $(this).parents('div.ui-dialog').find( | |
| 'div.ui-dialog-buttonset').find('button'); | |
| buttons | |
| @@ -56,6 +77,7 @@ $(function() { | |
| if (j >= 0) { | |
| i = i.substr(j + 1); | |
| } | |
| + $(link).data('hash', i); | |
| if (i.toLowerCase() == 'contact') { | |
| return onGetDialog({ | |
| r : true, | |
| @@ -64,15 +86,30 @@ $(function() { | |
| w : 550 | |
| }); | |
| } | |
| - $.ajax({ | |
| - type : 'GET', | |
| - url : SCRIPT, | |
| - data : { | |
| - id : i | |
| - }, | |
| - dataType : 'json', | |
| - success : onGetDialog | |
| - }); | |
| + // pls uncomment this in production | |
| + // comment this one to make the test run offline | |
| + // $.ajax({ | |
| + // type : 'GET', | |
| + // url : SCRIPT, | |
| + // url : 'issues.htm', | |
| + // data : { | |
| + // id : i | |
| + // }, | |
| + // dataType : 'json', | |
| + // context: link, | |
| + // success : onGetDialog | |
| + // }); | |
| + | |
| + // This one is only for testing purpose, pls remove it in production | |
| + var tmp = { | |
| + "r" : true, | |
| + "e" : "", | |
| + "h" : "Planting instructions", | |
| + "b" : "Below are brief instructions. If you want a tutorial with photographs, see <a href=\"\/page----BareRootTutorial\" target=new>how to plant<\/a>.\r\n<br \/><br \/>\r\n<b>To plant container-grown plants<\/b>: Prepare planting holes twice as wide and deep as the plants you are planting. Water the plant thoroughly and let the excess water drain before carefully removing from the container. Carefully loosen the root ball and place the plant in the hole, working soil around the roots as you fill. If the plant is root bound, you may elect to separate the roots with your fingers to lessen transplant shock. Continue filling in soil, tamping lightly as you go to remove air pockets. Water thoroughly, ideally protecting from direct sun until stable (if possible).\r\n<br \/><br \/>\r\n<b>To plant bare-root plants<\/b>: Plant as soon as possible after delivery. Prepare suitable planting holes (3-4\" wide and 5-6\" deep), spread roots and work soil among roots as you fill in, tamping lightly as you go to remove air pockets. Water well and ideally protect from direct sun until stable (if possible).\r\n<br \/><br \/>\r\nAfter planting, apply a 2- to 4-inch layer of pinestraw or wood mulch. When planting groundcovers that have long runners (such as ivies), you can spread mulch before planting, and then rake aside a small area in order to dig the planting hole.\r\n<br \/><br \/>\r\nKeep the planting evenly watered (at least 1\" of water per week) for the first season to promote rooting and establishment.\r\n<br \/><br \/>\r\nSee also: <br \/>\r\n <a href=\"\/site\/page?view=groundPreparation\">Ground preparation and fertilizing<\/a><br \/>\r\n <a class=\"CGDialogReplace\" href=\"#pH\">Testing and adjusting pH of your soil<\/a><br \/>\r\n <a class=\"CGDialogReplace\" href=\"#WhenPlant\">When you should plant<\/a><br \/>\r\n <a class=\"CGDialogReplace\" href=\"#DefineBareRoot\">Explanation and description of bare roots<\/a><br \/>\r\n <a href=\"\/page----BareRootTutorial\" target=new>How to plant<\/a> (tutorial with photographs)<br \/>\r\n <a href=\"\/site\/page?view=plantCalculator\">Plant calculator<\/a>\r\n", | |
| + "w" : "L" | |
| + } | |
| + onGetDialog.call(link, tmp); | |
| + | |
| } | |
| function closeLinkDialog(link) { | |
| var $l = $(link); | |
| @@ -84,7 +121,6 @@ $(function() { | |
| } | |
| $('a.CGDialog').live('click', function(e) { | |
| createLinkDialog(this); | |
| - return false; | |
| }); | |
| $('a.CGDialogReplace').live('click', function(e) { | |
| closeLinkDialog(this); | |
| @@ -101,28 +137,52 @@ $(function() { | |
| type : 'GET', | |
| url : u, | |
| dataType : 'html', | |
| + context: link, | |
| success : function(r) { | |
| var d = '<div class="CGDialogBody ui-helper-reset" style="text-align: left; font-size: 14px; font-family: \'Verdana\';">' | |
| + r + '</div>', w = parseInt(M * document.body.clientWidth, 10); | |
| d = $(d).appendTo($(document.body)); | |
| - d.dialog({ | |
| - width : w, | |
| - minWidth : MIN_WIDTH, | |
| - resizable : true, | |
| - title : t, | |
| - modal : true, | |
| - position : 'center', | |
| - draggable : true, | |
| - buttons : { | |
| - "Close" : function() { | |
| - $(this).dialog('close'); | |
| - } | |
| - }, | |
| - close : function(event, ui) { | |
| - $(this).empty().dialog('destroy').parent().remove( | |
| - 'div.CGDialogBody'); | |
| - } | |
| - }); | |
| + d | |
| + .dialog({ | |
| + width : w, | |
| + minWidth : MIN_WIDTH, | |
| + resizable : true, | |
| + title : t, | |
| + modal : true, | |
| + position : 'center', | |
| + draggable : true, | |
| + buttons : { | |
| + "Close" : function() { | |
| + $(this).dialog('close'); | |
| + } | |
| + }, | |
| + close : function(event, ui) { | |
| + $(window).off('popstate'); | |
| + $(document).off( | |
| + 'click.dialog.close.' + $(link).data('hash')); | |
| + $(this).empty().dialog('destroy').parent().remove( | |
| + 'div.CGDialogBody'); | |
| + }, | |
| + open : function(event, ui) { | |
| + $(window).popstate( | |
| + function() { | |
| + if (d.dialog("isOpen") | |
| + && $link.data('hash') !== location.hash.replace( | |
| + '#', '')) { | |
| + d.dialog('close'); | |
| + } | |
| + }); | |
| + $(document) | |
| + .on( | |
| + 'click.dialog.close.' + $link.data('hash'), | |
| + function(e) { | |
| + if ($(e.target).closest(d.closest('.ui-dialog')).length == 0 | |
| + && d.dialog("isOpen")) { | |
| + d.dialog('close'); | |
| + } | |
| + }); | |
| + } | |
| + }); | |
| } | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment