From 699be131379259ca5ecfee800a301b4e7f9e168d Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Sat, 27 Jun 2015 17:01:16 +0300 Subject: [PATCH] Explorer Layout Fixed + Init() Function that splits to 3 sized array --- .../js/controllers/campusesController.js | 46 +++++++------------ templates/views/campuses.html | 30 ++++++++++-- 2 files changed, 42 insertions(+), 34 deletions(-) diff --git a/templates/js/controllers/campusesController.js b/templates/js/controllers/campusesController.js index ead0ef2..9c251a2 100644 --- a/templates/js/controllers/campusesController.js +++ b/templates/js/controllers/campusesController.js @@ -7,36 +7,24 @@ angular.module('SeHub') var init = function() { - var i, j, counter = 0; - var newLength = 0; - - if(($scope.campuses.length % 3) === 0) - { - newLength = ($scope.campuses.length / 3); - } - else - { - newLength = (Math.ceil($scope.campuses.length / 3)); // Rounds number up - } - - console.log("length: " + newLength); - $scope.threeSizedArray.length = newLength; - - for(j = 0; j < newLength; j++) - { - $scope.threeSizedArray[j] = [3]; // Creating array in size of 3 in each array cell - } - - for(i = 0; i < newLength; i++) - { - for(j = 0; j < newLength; j++) - { - if($scope.campuses[(3*i) + j] != null) - { - $scope.threeSizedArray[i][j] = $scope.campuses[(3*i) + j]; + $scope.threeSizedArray = []; + var tempArr = []; + var sizeOfSmallArrays = 3; + for (var i = 0 ; i < $scope.campuses.length ; i++) { + if(i % sizeOfSmallArrays !== 0){ + tempArr.push($scope.campuses[i]); + }else{ + if(i !== 0){ + $scope.threeSizedArray.push(tempArr); + tempArr = []; + tempArr.push($scope.campuses[i]); + }else{ + tempArr.push($scope.campuses[i]); } - } - } + } + }; + + $scope.threeSizedArray.push(tempArr); console.log($scope.threeSizedArray); // TODO REMOVE } diff --git a/templates/views/campuses.html b/templates/views/campuses.html index 66d3654..edb7911 100644 --- a/templates/views/campuses.html +++ b/templates/views/campuses.html @@ -5,11 +5,31 @@
-
- - - {{campus.title}} - +
+
+ + + + Washed Out + +

{{campus.title}}

+
+
+
+
+ +
+ + + + Washed Out + +

{{campus.title}}

+
+
+
+
+