diff --git a/jquery/jquery-1.8.d.ts b/jquery/jquery-1.8.d.ts index 361d154de5..8d824cb0c2 100644 --- a/jquery/jquery-1.8.d.ts +++ b/jquery/jquery-1.8.d.ts @@ -346,8 +346,9 @@ interface JQuery { hasClass(className: string): bool; - html(htmlString: string): JQuery; html(): string; + html(htmlString: string): JQuery; + html(htmlContent: (index: number, oldhtml: string) => string): JQuery; prop(propertyName: string): any; prop(propertyName: string, value: any): JQuery; diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index bf9f9e71e8..f82ae04351 100644 --- a/jquery/jquery-tests.ts +++ b/jquery/jquery-tests.ts @@ -1484,10 +1484,8 @@ function test_get() { var jqxhr = $.get("example.php", function () { alert("success"); }) - .success(function () { alert("second success"); }) - .error(function () { alert("error"); }) - .complete(function () { alert("complete"); }); - jqxhr.complete(function () { alert("second complete"); }); + .done(function () { alert("second success"); }) + .fail(function () { alert("error"); }); $.get("test.php"); $.get("test.php", { name: "John", time: "2pm" }); @@ -1537,10 +1535,8 @@ function test_getJSON() { var jqxhr = $.getJSON("example.json", function () { alert("success"); }) - .success(function () { alert("second success"); }) - .error(function () { alert("error"); }) - .complete(function () { alert("complete"); }); - jqxhr.complete(function () { alert("second complete"); }); + .done(function () { alert("second success"); }) + .fail(function () { alert("error"); }); $.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?", { tags: "mount rainier", @@ -1610,6 +1606,130 @@ function test_grep() { }, true); } +function test_has() { + $('li').has('ul').css('background-color', 'red'); + $("ul").append("
  • " + ($("ul").has("li").length ? "Yes" : "No") + "
  • "); + $("ul").has("li").addClass("full"); +} + +function test_hasClass() { + $('#mydiv').hasClass('foo'); + $("div#result1").append($("p:first").hasClass("selected").toString()); + $("div#result2").append($("p:last").hasClass("selected").toString()); + $("div#result3").append($("p").hasClass("selected").toString()); +} + +function test_hasData() { + var $p = jQuery("p"), p = $p[0]; + $p.append(jQuery.hasData(p) + " "); + $.data(p, "testing", 123); + $p.append(jQuery.hasData(p) + " "); + $.removeData(p, "testing"); + $p.append(jQuery.hasData(p) + " "); + $p.on('click', function () { }); + $p.append(jQuery.hasData(p) + " "); + $p.off('click'); + $p.append(jQuery.hasData(p) + " "); +} + +function test_height() { + $(window).height(); + $(document).height(); + function showHeight(ele, h) { + $("div").text("The height for the " + ele + " is " + h + "px."); + } + $("#getp").click(function () { + showHeight("paragraph", $("p").height()); + }); + $("#getd").click(function () { + showHeight("document", $(document).height()); + }); + $("#getw").click(function () { + showHeight("window", $(window).height()); + }); + $("div").one('click', function () { + $(this).height(30) + .css({ cursor: "auto", backgroundColor: "green" }); + }); +} + +function test_hide() { + $('.target').hide(); + $('#clickme').click(function () { + $('#book').hide('slow', function () { + alert('Animation complete.'); + }); + }); + $("p").hide(); + $("a").click(function (event) { + event.preventDefault(); + $(this).hide(); + }); + $("button").click(function () { + $("p").hide("slow"); + }); + $("#hidr").click(function () { + $("span:last-child").hide("fast", function () { + $(this).prev().hide("fast", arguments.callee); + }); + }); + $("#showr").click(function () { + $("span").show(2000); + }); + $("div").click(function () { + $(this).hide(2000, function () { + $(this).remove(); + }); + }); +} + +function test_holdReady() { + $.holdReady(true); + $.getScript("myplugin.js", function () { + $.holdReady(false); + }); +} + +function test_hover() { + $("li").hover( + function () { + $(this).append($(" ***")); + }, + function () { + $(this).find("span:last").remove(); + } + ); + $("li.fade").hover(function () { $(this).fadeOut(100); $(this).fadeIn(500); }); + $("li") + .filter(":odd") + .hide() + .end() + .filter(":even") + .hover( + function () { + $(this).toggleClass("active") + .next().stop(true, true).slideToggle(); + } + ); +} + +function test_html() { + $('div.demo-container').html(); + $("p").click(function () { + var htmlStr = $(this).html(); + $(this).text(htmlStr); + }); + $('div.demo-container') + .html('

    All new content. You bet!

    '); + $('div.demo-container').html(function () { + var emph = '' + $('p').length + ' paragraphs!'; + return '

    All new content for ' + emph + '

    '; + }); + $("div").html("Wow! Such excitement..."); + $("div b").append(document.createTextNode("!!!")) + .css("color", "red"); +} + function test_mouseEvents() { var i = 0; $("div.overout").mouseover(function () {