Skip to content

Commit

Permalink
refactor the code
Browse files Browse the repository at this point in the history
  • Loading branch information
Junaid committed Feb 12, 2015
1 parent a98642a commit c68cea5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 35 deletions.
40 changes: 9 additions & 31 deletions lib/app/js/controllers/element.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,8 @@ angular.module('sgApp')
updatePageData();
});

function previousSection() {
var sections, result, mod, sec, i, m;
if (!Styleguide.sections.data) {
return;
}
sections = Styleguide.sections.data;

// Find correct element definition from styleguide data
result = sections.filter(function(item) {
return reference === item.reference;
});
function previousSection(sections, result) {
var sec, i, m;
sec = result[0];
m = modifier;
if (result.length > 0) {
Expand All @@ -46,30 +37,19 @@ angular.module('sgApp')
}
}
}
if (sec.modifiers.length > 0) {
if (sec.hasOwnProperty('modifiers') && sec.modifiers.length > 0) {
m = sec.modifiers.length + 1;
} else {
return false;
}
}
}

mod = sec.reference + '-' + (parseInt(m) - 1);
return sec.reference + '-' + (parseInt(m) - 1);
}
return mod;
}

function nextSection() {
var sections, result, mod, sec, i, m;
if (!Styleguide.sections.data) {
return;
}
sections = Styleguide.sections.data;

// Find correct element definition from styleguide data
result = sections.filter(function(item) {
return reference === item.reference;
});
function nextSection(sections, result) {
var sec, i, m;
sec = result[0];
m = modifier;
if (result.length > 0) {
Expand All @@ -94,10 +74,8 @@ angular.module('sgApp')
}
}
}

mod = sec.reference + '-' + (parseInt(m) + 1);
return sec.reference + '-' + (parseInt(m) + 1);
}
return mod;
}

function updatePageData() {
Expand Down Expand Up @@ -127,8 +105,8 @@ angular.module('sgApp')
}

// Set the actual page content
$scope.previousSection = previousSection();
$scope.nextSection = nextSection();
$scope.previousSection = previousSection(sections, result);
$scope.nextSection = nextSection(sections, result);
$scope.section = element;
$scope.variables = Variables.variables;
$scope.markup = $filter('setVariables')(element.wrappedMarkup, $scope.variables);
Expand Down
4 changes: 2 additions & 2 deletions lib/app/sass/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1217,13 +1217,13 @@ Styleguide 4.4
}

.navigation-section {
padding: 10px;
position: fixed;
z-index: 1000;
z-index: 99999;
right: 0;
display: inline;
.next-nav, .prev-nav {
float: left;
margin: 10px;
cursor: pointer;
}
}
Expand Down
8 changes: 6 additions & 2 deletions lib/app/views/element-fullscreen.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<div class="navigation-section">
<a ng-hide="!previousSection" ui-sref="app.fullscreen({section: previousSection })" target="_blank">Previous</a>
<a ng-hide="!nextSection" ui-sref="app.fullscreen({section: nextSection })" target="_blank">Next</a>
<a ng-hide="!previousSection" ui-sref="app.fullscreen({section: previousSection })" target="_blank">
<i class="fa fa-arrow-left"></i>
</a>
<a ng-hide="!nextSection" ui-sref="app.fullscreen({section: nextSection })" target="_blank">
<i class="fa fa-arrow-right"></i>
</a>
</div>
<shadow-dom>
<div ng-bind-html="markup | addWrapper | unsafe" dynamic-compile></div>
Expand Down

0 comments on commit c68cea5

Please sign in to comment.