Skip to content

Commit

Permalink
Cherry-Pie#2 Global headers functionality with headers autocomplete
Browse files Browse the repository at this point in the history
  • Loading branch information
Cherry-Pie committed Aug 18, 2017
1 parent 35b2d4d commit 840eeee
Show file tree
Hide file tree
Showing 8 changed files with 182 additions and 3 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ Route::get('/docs', function() {


## TODO
- add `global headers` section.
- generate plain html page with all documentation info.
- fullsize block with response.
- generate blueprint for https://apiblueprint.org.
Expand Down
29 changes: 29 additions & 0 deletions public/css/easyautocomplete.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions public/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -2125,3 +2125,14 @@ label>span {
user-select: none; /* Non-prefixed version, currently
supported by Chrome and Opera */
}

.global-headers-section {
display: none;
padding: 30px 30px 30px 0;
height: 400px;
top: 60px;
position: fixed;
box-shadow: 0 0 10px rgba(0,0,0,0.5);
width: 630px;
background: #ffffff;
}
99 changes: 98 additions & 1 deletion public/js/app.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@

$(window).on('resize', function() {
$('.global-headers-section').width($('.method-copy').width() - 30);
});

$(document).ready(function(){
$('#documenter_nav').tendina({activeMenu: '.current'});

Expand Down Expand Up @@ -38,7 +43,73 @@ $(document).ready(function(){
});
return false;
});
});

autocompleteHeaders();

});

function autocompleteHeaders()
{
$('.req-header').easyAutocomplete({
data: [
'Accept',
'Accept-Charset',
'Accept-Encoding',
'Accept-Language',
'Accept-Datetime',
'Access-Control-Request-Method',
'Access-Control-Request-Headers',
'Authorization',
'Cache-Control',
'Connection',
'Cookie',
'Content-Length',
'Content-MD5',
'Content-Type',
'Content-Disposition',
'Date',
'Expect',
'Forwarded',
'From',
'Host',
'If-Match',
'If-Modified-Since',
'If-None-Match',
'If-Range',
'If-Unmodified-Since',
'Max-Forwards',
'Origin',
'Pragma',
'Proxy-Authorization',
'Range',
'Referer',
'TE',
'User-Agent',
'Upgrade',
'Via',
'Warning',
'X-Requested-With',
'DNT',
'X-Forwarded-For',
'X-Forwarded-Host',
'X-Forwarded-Proto',
'Front-End-Https',
'X-Http-Method-Override',
'X-ATT-DeviceId',
'X-Wap-Profile',
'Proxy-Connection',
'X-UIDH',
'X-Csrf-Token',
'X-Request-ID',
'X-Correlation-ID',
],
list: {
match: {
enabled: true
}
},
});
}

function openUl(ul)
{
Expand Down Expand Up @@ -67,6 +138,13 @@ function sendRequest(form)
headers[header] = $el.find('.req-header-value').val();
}
});
$('.global-headers-form .form-group').not('.except').each(function(key, element) {
var $el = $(element);
if ($el.find('.req-header-active').is(':checked')) {
var header = $el.find('.req-header').val();
headers[header] = $el.find('.req-header-value').val();
}
});

$.ajax({
url : $section.find('.action-url').val(),
Expand Down Expand Up @@ -159,3 +237,22 @@ function changeSourceView(ctx)
}
}

function addNewHeaderInput(ctx)
{
$(ctx).closest('.form-group').before($('#header-row-template').html());
autocompleteHeaders();
}

function showGlobalHeaders(ctx)
{
var $li = $(ctx).parent();
if ($li.hasClass('dx-nav-active')) {
$li.removeClass('dx-nav-active');
$('.global-headers-section').slideUp();
} else {
$li.addClass('dx-nav-active');
$(window).trigger('resize')
$('.global-headers-section').slideDown();
}
}

0 comments on commit 840eeee

Please sign in to comment.