Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring ads on website #2

Open
wants to merge 42 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
2731067
add getPlaceholder function to Pub factory
diadzine Mar 6, 2016
16af4dd
create directive ts-pub-placeholder
diadzine Mar 6, 2016
3ecc932
update templates to integrate the new ads directive
diadzine Mar 6, 2016
613c662
update ts-pub-placeholder directive
diadzine Mar 6, 2016
9488af9
update index view
diadzine Mar 6, 2016
4899a54
add placeholder view for directive
diadzine Mar 6, 2016
e139f73
update index.html template
diadzine Mar 6, 2016
c1a247b
rename tsPubPlaceholder to tsAdPlaceholder directive
diadzine Mar 8, 2016
ccd54ef
update ads blocks to use new ad placeholder directive
diadzine Mar 9, 2016
97a326d
add min-width rule to tsAdPlaceholder directive
diadzine Mar 9, 2016
38a17f5
change min-width value for ts-ad-placeholder
diadzine Mar 9, 2016
a200263
renamed placeholder actu-side to sides for sky scrapper ads on sides
diadzine Mar 9, 2016
a22cd04
add ng-hide directive to show ad section only if an ad is defined
diadzine Mar 9, 2016
f540975
Merge branch 'master' of bitbucket.org:ab_tooskich/website
diadzine Mar 10, 2016
aed6897
add a first version of gulp file
diadzine Jul 6, 2016
6e8d517
config gulp file and refresh of npm packages
diadzine Jul 7, 2016
18131ec
add app/styles/main.css to ignored files
diadzine Jul 8, 2016
06ee97b
add gulp bower task and npm packages
diadzine Jul 8, 2016
f73581a
update gulp file with images and fonts management
diadzine Jul 11, 2016
6e0bc0d
add recipes for images, misc, html, and others and new npm packages
diadzine Jul 11, 2016
bc18043
add gulp autoprefixer, rev and rev-replace npm packages
diadzine Jul 12, 2016
f7ea0c2
update gulp file
diadzine Jul 12, 2016
d826806
add gulp-gh-pages to npm packages
diadzine Jul 26, 2016
e0cacb5
add publish folder to ignored files
diadzine Jul 26, 2016
d3f4178
Add deploy task to gulp file
diadzine Jul 26, 2016
def705f
remove remoteUrl from deploy task in gulp file
diadzine Jul 26, 2016
3be1fae
update angularjs version 1.2.18 to 1.5.8 for cloudflare cdn
diadzine Aug 3, 2016
9a6c932
refactor gulp tasks
diadzine Aug 8, 2016
e803bbf
change API_URL to prod url
diadzine Aug 22, 2016
21909aa
add scripts to html watch method
diadzine Aug 22, 2016
f2cc7eb
Fixing DI
diadzine Aug 22, 2016
a7cb508
fix orderBy date in blog posts listing
diadzine Sep 5, 2016
0ec8217
change sponsors text and styles
diadzine Sep 26, 2016
585a487
remove "Contactez-nous" block on blog pages
diadzine Sep 26, 2016
c9388e1
hide column FIS Code in results table
diadzine Sep 26, 2016
b4d822e
hide column FIS Code in results large table
diadzine Sep 26, 2016
6b8695c
edit sense in sponsor page
diadzine Sep 27, 2016
e9bab9e
update standings for the new season 2016/17
diadzine Oct 10, 2016
fa9eb4b
comment out results and rankings pages, links and side blocks
diadzine Oct 28, 2016
13d8557
add St. Moritz 2017 link to navbar
diadzine Nov 17, 2016
0c56cf1
revomed distinct layout for mag==1, all news look the same
diadzine Nov 21, 2016
74c64ee
hide item menu for St Moritz 2017
diadzine Mar 15, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ node_modules
dist
.tmp
.sass-cache
.publish
app/bower_components
app/styles/main.css
28 changes: 14 additions & 14 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@
<!-- Disabled responsive: <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> -->
<!-- Place favicon.ico and apple-touch-icon.png in the root directory -->

<!-- build:css(.tmp) styles/main.css -->
<!-- build:css(app) styles/main.css -->
<link rel="stylesheet" href="styles/main.css" />

<link rel="stylesheet" href="bower_components/angular-loading-bar/build/loading-bar.css">
<link rel="stylesheet" href="bower_components/angular-bootstrap-lightbox/dist/angular-bootstrap-lightbox.css">


<!-- endbuild -->
</head>
<body ng-app="websiteApp">
Expand All @@ -35,9 +32,11 @@
<center>
<div style="max-width:1280px;">

<div ts-side-ads class="pull-left" style="margin-left:20px;" min-width="1280"></div>
<!-- Begin Ads -->
<div ts-ad-placeholder placeholder="sides" category="vertical" class="pull-left" style="margin-left:20px;" min-width="1280"></div>

<div ts-side-ads class="pull-right" style="margin-right:20px;" min-width="1175"></div>
<div ts-ad-placeholder placeholder="sides" category="vertical" class="pull-right" style="margin-right:20px;" min-width="1280"></div>
<!-- End Ads -->

<!-- Add your site or application content here -->
<div class="container">
Expand Down Expand Up @@ -66,13 +65,13 @@
</script>

<script src="bower_components/jquery/jquery.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.18/angular.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.18/angular-route.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.18/angular-resource.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.18/angular-cookies.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.18/angular-sanitize.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.18/angular-animate.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.18/angular-touch.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.8/angular.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.8/angular-route.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.8/angular-resource.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.8/angular-cookies.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.8/angular-sanitize.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.8/angular-animate.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.8/angular-touch.min.js"></script>

<!-- build:js scripts/modules.js -->
<script src="bower_components/angular-bootstrap/ui-bootstrap.min.js"></script>
Expand All @@ -83,7 +82,7 @@
<script src="bower_components/angular-bootstrap-lightbox/dist/angular-bootstrap-lightbox.js"></script>
<!-- endbuild -->

<!-- build:js({.tmp,app}) scripts/scripts.js -->
<!-- build:js(app) scripts/scripts.js -->
<script src="scripts/app.js"></script>
<script src="scripts/controllers/main.js"></script>
<script src="scripts/controllers/mag.js"></script>
Expand All @@ -93,6 +92,7 @@
<script src="scripts/directives/tsNewsCarousel.js"></script>
<script src="scripts/controllers/news.js"></script>
<script src="scripts/directives/tsPubSide.js"></script>
<script src="scripts/directives/tsAdPlaceholder.js"></script>
<script src="scripts/directives/tsComments.js"></script>
<script src="scripts/services/news.js"></script>
<script src="scripts/directives/tsNavbar.js"></script>
Expand Down
16 changes: 8 additions & 8 deletions app/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ angular
templateUrl: 'views/news.html',
controller: 'NewsCtrl'
})
.when('/Rankings', {
templateUrl: 'views/rankings.html',
controller: 'RankingsCtrl'
})
//.when('/Rankings', {
// templateUrl: 'views/rankings.html',
// controller: 'RankingsCtrl'
//})
.when('/Blog', {
templateUrl: 'views/blog.html',
controller: 'BlogCtrl'
Expand All @@ -40,10 +40,10 @@ angular
templateUrl: 'views/page.html',
controller: 'PageCtrl'
})
.when('/Result', {
templateUrl: 'views/result.html',
controller: 'ResultCtrl'
})
//.when('/Result', {
// templateUrl: 'views/result.html',
// controller: 'ResultCtrl'
//})
.when('/Skiclubs', {
templateUrl: 'views/skiclubs.html',
controller: 'SkiclubsCtrl'
Expand Down
8 changes: 8 additions & 0 deletions app/scripts/controllers/result.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ angular.module('websiteApp')
.html(result.table)
.find('table')
.addClass('table table-striped table-condensed');
// Hack to hide 'FIS Code' column
if (angular.element('#table-content tr:first() th').length > 8) {
var fis = angular.element('#table-content th:contains("FIS Code")');
var index = fis.parent().children().index(fis);
angular.element('#table-content tr').find('th:nth(' + index + ')').hide();
angular.element('#table-content tr').find('td:nth(' + index + ')').hide();
}

});
}
]);
12 changes: 7 additions & 5 deletions app/scripts/controllers/sponsors.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
* Controller of the websiteApp
*/
angular.module('websiteApp')
.controller('SponsorsCtrl', function ($scope, Widget) {
Widget.get(2, function(widget) {
$scope.widgetContent = widget;
});
});
.controller('SponsorsCtrl', ['$scope', 'Widget',
function ($scope, Widget) {
Widget.get(2, function(widget) {
$scope.widgetContent = widget;
});
}
]);
42 changes: 42 additions & 0 deletions app/scripts/directives/tsAdPlaceholder.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
'use strict';

angular.module('websiteApp')
.directive('tsAdPlaceholder', ['$window', 'Pub',
function($window, Pub) {
return {
templateUrl: 'views/directives/core/placeholder.html',
restrict: 'EACM',
replace: true,
scope: {
width: '=?minWidth',
},
link: function postLink(scope, element, attrs) {

var checkWidth = function(width) {
var width = width;
return function() {
if (width >= window.innerWidth) {
element.css('display', 'none');
}
else {
element.css('display', 'block');
}
};
};
checkWidth = checkWidth(scope.width);
checkWidth();

var pubs = Pub.getPlaceholder(
attrs.placeholder,
attrs.category,
function (pubs) {
scope.ad = pubs[0];
scope.cat = attrs.category;
}
);

angular.element($window).on('resize', checkWidth);
}
};
}
]);
68 changes: 35 additions & 33 deletions app/scripts/directives/tssideads.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,43 @@
'use strict';

angular.module('websiteApp')
.directive('tsSideAds', function($window, Pub) {
return {
templateUrl: 'views/directives/core/sideads.html',
restrict: 'EACM',
scope: {
width: '=minWidth',
},
link: function postLink(scope, element, attrs) {
function shuffle(o) { //v1.0
for (var j, x, i = o.length; i; j = Math.floor(Math.random() *
i), x = o[--i], o[i] = o[j], o[j] = x);
return o;
};
.directive('tsSideAds', ['$window', 'Pub',
function($window, Pub) {
return {
templateUrl: 'views/directives/core/sideads.html',
restrict: 'EACM',
scope: {
width: '=minWidth',
},
link: function postLink(scope, element, attrs) {
function shuffle(o) { //v1.0
for (var j, x, i = o.length; i; j = Math.floor(Math.random() *
i), x = o[--i], o[i] = o[j], o[j] = x);
return o;
};

var checkWidth = function(width) {
var width = width;
return function() {
if (width >= window.innerWidth) {
element.css('display', 'none');
}
else {
element.css('display', 'block');
}
var checkWidth = function(width) {
var width = width;
return function() {
if (width >= window.innerWidth) {
element.css('display', 'none');
}
else {
element.css('display', 'block');
}
};
};
};
checkWidth = checkWidth(scope.width);
checkWidth();
checkWidth = checkWidth(scope.width);
checkWidth();

Pub.getVerticalBanner(function(banners) {
scope.ad = shuffle(banners)[0];
});
Pub.getVerticalBanner(function(banners) {
scope.ad = shuffle(banners)[0];
});


angular.element($window)
.on('resize', checkWidth);
}
};
});
angular.element($window)
.on('resize', checkWidth);
}
};
}
]);
9 changes: 9 additions & 0 deletions app/scripts/services/pub.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ angular.module('websiteApp')

return {

getPlaceholder: function(placeholder, cat, callback) {
$http.get(pubApi + '?placeholder=' + placeholder + '&category=' + cat, {
cache: true
}).then(function(res) {
var data = shuffleArray(res.data);
callback(data);
}, Server.errorHandler);
},

getCat: function(cat, callback) {
$http.get(pubApi + '?category=' + cat, {
cache: true
Expand Down
49 changes: 25 additions & 24 deletions app/scripts/services/server.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
'use strict';

angular.module('websiteApp')
.service('Server', function Server($window, $location) {
// AngularJS will instantiate a singleton by calling "new" on this function
.service('Server', ['$window', '$location',
function Server($window, $location) {
// AngularJS will instantiate a singleton by calling "new" on this function

this.Url = 'http://tooski.webfactional.com/api/';
// this.Url = 'http://127.0.0.1:8000/';
this.Url = 'http://tooski.webfactional.com/api/';

this.sendAnalytics = function() {
$window.ga('send', 'pageview', {
page: $location.path()
});
};
this.sendAnalytics = function() {
$window.ga('send', 'pageview', {
page: $location.path()
});
};

this.processResponse = function(response) {
return response.map(function(el) {
var result = el.fields;
result.id = el.pk;
result.date = new Date(result.date)
.getTime();
return result;
});
};
this.processResponse = function(response) {
return response.map(function(el) {
var result = el.fields;
result.id = el.pk;
result.date = new Date(result.date)
.getTime();
return result;
});
};

this.errorHandler = function(status, response) {
console.log(
'There was a connection problem with the server. (' +
status + ')'
);
this.errorHandler = function(status, response) {
console.log(
'There was a connection problem with the server. (' +
status + ')'
);
}
}
});
]);
44 changes: 44 additions & 0 deletions app/styles/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,18 @@ div.blue {
padding-top:0px;
}

.sponsors-hl {
background-color: #eee;
color: #000;
padding: 10px;
margin: 20px 0 30px 0;
text-align: justify;

li {
margin: 20px 10px 20px 10px;
}
}

img {
max-width:100%;
}
Expand All @@ -213,3 +225,35 @@ article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,su
font-weight: bold;
background-color: $lightgray;
}

/***** ADS ****/
$ads_categories: (
square: (
width: 300px,
height: 250px,
),
vertical: (
width: 120px,
height: 600px,
),
horizontal: (
width: 468px,
height: 90px,
),
);

@each $category, $dimensions in $ads_categories {
.ad_block_#{$category} {
margin: 1px;

.ad_image_#{$category} {
@each $property, $value in $dimensions {
#{$property}: #{$value};
}
}
}
}

.ad_block_horizontal {
margin: 20px auto;
}
Loading