JSFiddle - React, Tailwind, and code Playground
by aknuds1
HTML
<script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.js"></script>
<link rel="stylesheet" href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.20/themes/base/jquery-ui.css">
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.22/jquery-ui.min.js"></script>
<button id="button-status">Click me!</button>
CSS
div.loading
{
background: url(http://getitdone.googlecode.com/files/spinner.gif) no-repeat center center;
display: none;
width: 16px;
height: 16px;
}
JavaScript
var status = function() {
var init = function(id) {
var progressDialog = $("<div></div>").html("Getting binary ID... <div id=\"spinner\" class=\"loading\"></div>").dialog({
autoOpen: false,
title: "Launching Status Page"
});
var errorDialog = $("#errordialog-message").dialog({
autoOpen: false,
modal: true,
buttons: {
"OK": function() {
$(this).dialog("close");
}
}
});
var btn = $("#button-status");
btn.button().click(function() {
$("#spinner").show();
progressDialog.dialog("open");
alert("Clicked");
return;
var url = $.validator.format("/api/binid/?id={0}", id);
// Call Web service to get binary ID
$.ajax({
url: url,
datatype: "json"
}).always(function() {
progressDialog.dialog("close");
}).done(function(data) {
//window.open($.validator.format("http://status/?Page=Status&Id={0}", data), target = "_newtab");
}).fail(function(jqXHR, msg, errorThrown) {
errorDialog.dialog("open");
});
return false;
}); //.qtip({
//content: $.validator.format("Launch status page for binary corresponding to {0}", id)
//});
};
return {
init: init,
};
}();
$(document).ready(function() {
status.init("1");
});
var dialogSpy = null;
var windowStub = null;
module("FS14 build details", {
setup: function () {
windowStub = sinon.stub(window, "open");
dialogSpy = sinon.spy();
sinon.stub($.fn, "dialog", function () { return { "dialog": dialogSpy }; });
orig_$ = _$;
},
teardown: function () {
windowStub.restore();
$.fn.dialog.restore();
_$ = orig_$;
$.mockjaxClear();
...