Merge branch '1.0.x'

This commit is contained in:
William DURAND 2012-07-10 14:30:59 +02:00
commit f678fd4fe9
3 changed files with 59 additions and 6 deletions

View File

@ -440,7 +440,7 @@ li.operation.patch div.content h4 {
}
.pane.sandbox legend {
margin-bottom: 5px;
padding-bottom: 5px;
}
.remove {
@ -451,12 +451,22 @@ li.operation.patch div.content h4 {
display: none;
}
.parameters {
form .parameters,
form .headers,
form .request-content {
float: left;
width: 50%;
width: 33%;
}
.buttons {
clear: both;
padding-top: 10px;
}
.request-content textarea {
width:100%;
min-width:100%;
max-width:100%;
height:5em;
margin-bottom:10px;
}

View File

@ -132,6 +132,7 @@
_format: 'json' // default format if not overriden in the form
},
headers = {},
content = $(this).find('textarea.content').val();
result_container = $('.result', $(this).parent());
// retrieve all the parameters to send
@ -173,13 +174,13 @@
$.ajax({
url: '{{ sandboxTarget }}' + url,
type: method,
data: params,
data: content.length ? content : params,
headers: headers,
complete: function(xhr) {
displayResponse(xhr, method, url, result_container);
// and enable them back
$('input, button', $(self)).removeAttr('disabled');
$('input:not(.content-type), button', $(self)).removeAttr('disabled');
}
});
@ -226,6 +227,36 @@
$('.pane.sandbox').on('click', '.remove', function() {
$(this).parent().remove();
});
$('.pane.sandbox').on('click', '.set-content-type', function(e) {
var html;
var $element;
var $headers = $(this).parents('form').find('.headers');
var content_type = $(this).prev('input.value').val();
e.preventDefault();
if (content_type.length === 0) {
return;
}
$headers.find('input.key').each(function() {
if ($.trim($(this).val().toLowerCase()) === 'content-type') {
$element = $(this).parents('p');
return false;
}
});
if (typeof $element === 'undefined') {
html = $(this).parents('.pane').find('.tuple_template').html();
$element = $headers.find('legend').after(html).next('p');
}
$element.find('input.key').val('Content-Type');
$element.find('input.value').val(content_type);
});
</script>
</body>
</html>

View File

@ -136,8 +136,20 @@
<button class="add">New header</button>
</fieldset>
<div class="buttons">
<fieldset class="request-content">
<legend>Content</legend>
<textarea class="content" placeholder="Content set here will override the parameters that do not match the url"></textarea>
<p class="tuple">
<input type="text" class="key content-type" value="Content-Type" disabled="disabled" />
<span>=</span>
<input type="text" class="value" placeholder="Value" />
<button class="set-content-type">Set header</button> <small>Replaces header if set</small>
</p>
</fieldset>
<div class="buttons">
<input type="submit" value="Try!" />
</div>
</form>