Skip to content

Commit d953f15

Browse files
author
Damian Martinez Gelabert
committed
Merge pull request #92 from mulesoft/bugs/minor-fixes
Fix several issues
2 parents f07ed8a + c2c43df commit d953f15

File tree

10 files changed

+6211
-141
lines changed

10 files changed

+6211
-141
lines changed

dist/scripts/api-console-vendor.js

Lines changed: 6111 additions & 115 deletions
Large diffs are not rendered by default.

dist/scripts/api-console.js

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -936,8 +936,12 @@
936936
$location.hash(hash);
937937
$anchorScroll();
938938

939-
var lines = jqXhr.responseText.split('\n').length;
940-
var editorHeight = lines > 100 ? 2000 : 25*lines;
939+
// If the response fails because of CORS, responseText is null
940+
var editorHeight = 50;
941+
if (jqXhr.responseText) {
942+
var lines = jqXhr.responseText.split('\n').length;
943+
var editorHeight = lines > 100 ? 2000 : 25*lines;
944+
}
941945

942946
$scope.editorStyle = {
943947
height: editorHeight + 'px'
@@ -1246,27 +1250,29 @@
12461250
var $panelContent = $panel.find('.raml-console-resource-panel-primary');
12471251
var $sidebar = $panel.find('.raml-console-sidebar');
12481252
var animation = 430;
1253+
var speed = 200;
12491254

12501255
if ((!$sidebar.hasClass('raml-console-is-fullscreen') && !$sidebar.hasClass('raml-console-is-collapsed')) || $sidebar.hasClass('raml-console-is-responsive')) {
12511256
animation = 0;
12521257
}
12531258

12541259
if ($scope.singleView) {
12551260
$panel.toggleClass('raml-console-has-sidebar-fullscreen');
1261+
speed = 0;
12561262
}
12571263

12581264
$sidebar.velocity(
12591265
{ width: animation },
12601266
{
1261-
duration: 200,
1267+
duration: speed,
12621268
complete: completeAnimation
12631269
}
12641270
);
12651271

12661272
$panelContent.velocity(
12671273
{ 'padding-right': animation },
12681274
{
1269-
duration: 200,
1275+
duration: speed,
12701276
complete: completeAnimation
12711277
}
12721278
);
@@ -1525,6 +1531,29 @@
15251531
$this.toggleClass('raml-console-is-active');
15261532
};
15271533

1534+
$scope.toggleInverted = function ($event) {
1535+
var $section = jQuery($event.currentTarget)
1536+
.closest('.raml-console-resource-list-item')
1537+
.find('.raml-console-resource-list');
1538+
1539+
var $this = $section
1540+
.closest('.raml-console-resource-list-item')
1541+
.find('.raml-console-resource-root-toggle');
1542+
1543+
if ($section.hasClass('raml-console-is-collapsed')) {
1544+
$section.velocity('slideDown', {
1545+
duration: 200
1546+
});
1547+
} else {
1548+
$section.velocity('slideUp', {
1549+
duration: 200
1550+
});
1551+
}
1552+
1553+
$section.toggleClass('raml-console-is-collapsed');
1554+
$this.toggleClass('raml-console-is-active');
1555+
};
1556+
15281557
$scope.collapseAll = function ($event) {
15291558
var $this = jQuery($event.currentTarget);
15301559

@@ -5025,7 +5054,7 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
50255054

50265055

50275056
$templateCache.put('directives/resource-panel.tpl.html',
5028-
"<div class=\"raml-console-resource-panel\" ng-if=\"showPanel\" ng-class=\"{ 'raml-console-has-sidebar-fullscreen': singleView }\">\n" +
5057+
"<div class=\"raml-console-resource-panel\" ng-if=\"showPanel\" ng-class=\"{ 'raml-console-has-sidebar-collapsed': singleView }\">\n" +
50295058
" <div class=\"raml-console-resource-panel-wrapper\">\n" +
50305059
" <documentation></documentation>\n" +
50315060
"\n" +
@@ -5114,7 +5143,7 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
51145143

51155144

51165145
$templateCache.put('directives/sidebar.tpl.html',
5117-
" <form name=\"form\" class=\"raml-console-sidebar\" novalidate ng-class=\"{ 'raml-console-is-fullscreen': singleView }\">\n" +
5146+
" <form name=\"form\" class=\"raml-console-sidebar\" novalidate ng-class=\"{ 'raml-console-is-collapsed': singleView }\">\n" +
51185147
" <div class=\"raml-console-sidebar-flex-wrapper\">\n" +
51195148
" <div class=\"raml-console-sidebar-content\">\n" +
51205149
" <header class=\"raml-console-sidebar-row raml-console-sidebar-header\">\n" +
@@ -5360,7 +5389,9 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
53605389
" <button class=\"raml-console-resource-root-toggle\" ng-class=\"{'raml-console-is-active': collapsed}\" ng-if=\"resourceGroup.length > 1\" ng-click=\"toggle($event)\"></button>\n" +
53615390
"\n" +
53625391
" <h2 class=\"raml-console-resource-heading raml-console-resource-heading-large\">\n" +
5363-
" <span class=\"raml-console-resource-path-active\" ng-repeat='segment in resource.pathSegments'>{{segment.toString()}}</span>\n" +
5392+
" <a class=\"raml-console-resource-path-active\" ng-repeat='segment in resource.pathSegments' ng-if=\"resourceGroup.length > 1\" ng-click=\"toggleInverted($event)\">{{segment.toString()}}</a>\n" +
5393+
"\n" +
5394+
" <span class=\"raml-console-resource-path-active\" ng-repeat='segment in resource.pathSegments' ng-if=\"resourceGroup.length <= 1\">{{segment.toString()}}</span>\n" +
53645395
" </h2>\n" +
53655396
"\n" +
53665397
" <resource-type></resource-type>\n" +

dist/styles/api-console-dark-theme.css

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1924,6 +1924,14 @@ th {
19241924
}
19251925
}
19261926

1927+
span.raml-console-resource-path-active {
1928+
cursor: default;
1929+
}
1930+
1931+
a.raml-console-resource-path-active {
1932+
cursor: pointer;
1933+
}
1934+
19271935
.raml-console-resource-heading {
19281936
display: inline-block;
19291937
margin: 0;
@@ -1936,10 +1944,6 @@ th {
19361944
background-image: linear-gradient(to top, rgba(255, 255, 255, 0) 1px, #999 2px, rgba(255, 255, 255, 0) 1px);
19371945
}
19381946

1939-
.raml-console-resource .raml-console-resource-heading:hover {
1940-
cursor: pointer;
1941-
}
1942-
19431947
@media only screen and (min-width: 600px) {
19441948
.raml-console-resource-heading {
19451949
margin-right: 15px;

dist/styles/api-console-light-theme.css

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1924,6 +1924,14 @@ th {
19241924
}
19251925
}
19261926

1927+
span.raml-console-resource-path-active {
1928+
cursor: default;
1929+
}
1930+
1931+
a.raml-console-resource-path-active {
1932+
cursor: pointer;
1933+
}
1934+
19271935
.raml-console-resource-heading {
19281936
display: inline-block;
19291937
margin: 0;
@@ -1936,10 +1944,6 @@ th {
19361944
background-image: linear-gradient(to top, rgba(255, 255, 255, 0) 1px, #999 2px, rgba(255, 255, 255, 0) 1px);
19371945
}
19381946

1939-
.raml-console-resource .raml-console-resource-heading:hover {
1940-
cursor: pointer;
1941-
}
1942-
19431947
@media only screen and (min-width: 600px) {
19441948
.raml-console-resource-heading {
19451949
margin-right: 15px;

src/app/directives/resource-panel.tpl.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="raml-console-resource-panel" ng-if="showPanel" ng-class="{ 'raml-console-has-sidebar-fullscreen': singleView }">
1+
<div class="raml-console-resource-panel" ng-if="showPanel" ng-class="{ 'raml-console-has-sidebar-collapsed': singleView }">
22
<div class="raml-console-resource-panel-wrapper">
33
<documentation></documentation>
44

src/app/directives/sidebar.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,12 @@
8080
$location.hash(hash);
8181
$anchorScroll();
8282

83-
var lines = jqXhr.responseText.split('\n').length;
84-
var editorHeight = lines > 100 ? 2000 : 25*lines;
83+
// If the response fails because of CORS, responseText is null
84+
var editorHeight = 50;
85+
if (jqXhr.responseText) {
86+
var lines = jqXhr.responseText.split('\n').length;
87+
var editorHeight = lines > 100 ? 2000 : 25*lines;
88+
}
8589

8690
$scope.editorStyle = {
8791
height: editorHeight + 'px'
@@ -390,27 +394,29 @@
390394
var $panelContent = $panel.find('.raml-console-resource-panel-primary');
391395
var $sidebar = $panel.find('.raml-console-sidebar');
392396
var animation = 430;
397+
var speed = 200;
393398

394399
if ((!$sidebar.hasClass('raml-console-is-fullscreen') && !$sidebar.hasClass('raml-console-is-collapsed')) || $sidebar.hasClass('raml-console-is-responsive')) {
395400
animation = 0;
396401
}
397402

398403
if ($scope.singleView) {
399404
$panel.toggleClass('raml-console-has-sidebar-fullscreen');
405+
speed = 0;
400406
}
401407

402408
$sidebar.velocity(
403409
{ width: animation },
404410
{
405-
duration: 200,
411+
duration: speed,
406412
complete: completeAnimation
407413
}
408414
);
409415

410416
$panelContent.velocity(
411417
{ 'padding-right': animation },
412418
{
413-
duration: 200,
419+
duration: speed,
414420
complete: completeAnimation
415421
}
416422
);

src/app/directives/sidebar.tpl.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<form name="form" class="raml-console-sidebar" novalidate ng-class="{ 'raml-console-is-fullscreen': singleView }">
1+
<form name="form" class="raml-console-sidebar" novalidate ng-class="{ 'raml-console-is-collapsed': singleView }">
22
<div class="raml-console-sidebar-flex-wrapper">
33
<div class="raml-console-sidebar-content">
44
<header class="raml-console-sidebar-row raml-console-sidebar-header">

src/app/resources/resources.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,29 @@
5858
$this.toggleClass('raml-console-is-active');
5959
};
6060

61+
$scope.toggleInverted = function ($event) {
62+
var $section = jQuery($event.currentTarget)
63+
.closest('.raml-console-resource-list-item')
64+
.find('.raml-console-resource-list');
65+
66+
var $this = $section
67+
.closest('.raml-console-resource-list-item')
68+
.find('.raml-console-resource-root-toggle');
69+
70+
if ($section.hasClass('raml-console-is-collapsed')) {
71+
$section.velocity('slideDown', {
72+
duration: 200
73+
});
74+
} else {
75+
$section.velocity('slideUp', {
76+
duration: 200
77+
});
78+
}
79+
80+
$section.toggleClass('raml-console-is-collapsed');
81+
$this.toggleClass('raml-console-is-active');
82+
};
83+
6184
$scope.collapseAll = function ($event) {
6285
var $this = jQuery($event.currentTarget);
6386

src/app/resources/resources.tpl.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ <h2 class="raml-console-resource-section-title">
4343
<button class="raml-console-resource-root-toggle" ng-class="{'raml-console-is-active': collapsed}" ng-if="resourceGroup.length > 1" ng-click="toggle($event)"></button>
4444

4545
<h2 class="raml-console-resource-heading raml-console-resource-heading-large">
46-
<span class="raml-console-resource-path-active" ng-repeat='segment in resource.pathSegments'>{{segment.toString()}}</span>
46+
<a class="raml-console-resource-path-active" ng-repeat='segment in resource.pathSegments' ng-if="resourceGroup.length > 1" ng-click="toggleInverted($event)">{{segment.toString()}}</a>
47+
48+
<span class="raml-console-resource-path-active" ng-repeat='segment in resource.pathSegments' ng-if="resourceGroup.length <= 1">{{segment.toString()}}</span>
4749
</h2>
4850

4951
<resource-type></resource-type>

src/scss/_resource.scss

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,14 @@
316316
}
317317
}
318318

319+
span.resource-path-active {
320+
cursor: default;
321+
}
322+
323+
a.resource-path-active {
324+
cursor: pointer;
325+
}
326+
319327
.resource-heading {
320328
// font-family: 'Source Code Pro';
321329
display: inline-block;
@@ -329,10 +337,6 @@
329337
background-image: linear-gradient(to top, rgba(255,255,255,0) 1px, #999 2px, rgba(255,255,255,0) 1px);
330338
}
331339

332-
.resource &:hover {
333-
cursor: pointer;
334-
}
335-
336340
@media only screen and (min-width: $medium-screen) {
337341
margin-right: 15px;
338342
}

0 commit comments

Comments
 (0)