implement new year's promo banner (bug 715548)

This commit is contained in:
Chris Van 2012-01-18 14:12:02 -08:00
Родитель b5be563f45
Коммит ad42a4cf87
7 изменённых файлов: 53 добавлений и 15 удалений

Просмотреть файл

@ -91,15 +91,26 @@ class CollectionPromo(PromoModule):
template = 'discovery/modules/collection.html'
title = None
subtitle = None
cls = 'promo'
limit = 3
linkify_title = False
def __init__(self, *args, **kw):
super(CollectionPromo, self).__init__(*args, **kw)
try:
self.collection = Collection.objects.get(pk=self.pk)
except Collection.DoesNotExist:
self.collection = None
self.collection = None
if hasattr(self, 'pk'):
try:
self.collection = Collection.objects.get(pk=self.pk)
except Collection.DoesNotExist:
pass
elif (hasattr(self, 'collection_author') and
hasattr(self, 'collection_slug')):
try:
self.collection = Collection.objects.get(
author__username=self.collection_author,
slug=self.collection_slug)
except Collection.DoesNotExist:
pass
def get_descriptions(self):
return {}
@ -244,3 +255,11 @@ class PromoVideoCollection():
def get_items(self):
items = Addon.objects.in_bulk(self.items)
return [items[i] for i in self.items if i in items]
class NewYearCollection(CollectionPromo):
slug = 'New Year'
# TODO: Change to 'newyear_2012' when fligtar adds the collection to -dev.
collection_author, collection_slug = 'mozilla', 'webdeveloper'
id = 'new-year'
title = _(u'Add-ons to help you on your way in 2012')

Просмотреть файл

@ -42,7 +42,7 @@
width: 38px;
height: 38px;
border: 2px solid #ccc;
font-family: Georgia;
font-family: @serif-stack;
margin: auto;
font-size: 44px;
line-height: 30px;
@ -79,9 +79,6 @@
overflow: hidden;
padding: 20px 10% 0 270px;
background: url(../../img/zamboni/discovery_pane/promos/ryff-bg.png) no-repeat;
h2 {
white-space: nowrap;
}
h3 {
margin-bottom: 10px;
a {
@ -120,7 +117,6 @@
}
h2 {
text-shadow: 0 1px 0 rgba(255,255,255,0.5);
white-space: nowrap;
}
hgroup {
margin: 10px auto 20px;
@ -206,7 +202,6 @@
}
#travel {
background: none;
background-image:
url(../../img/zamboni/discovery_pane/promos/travel-bg-left.png),
url(../../img/zamboni/discovery_pane/promos/travel-bg-right.png),
@ -219,7 +214,6 @@
}
#school {
background: none;
background-image:
url(../../img/zamboni/discovery_pane/promos/school-bg-left.png),
url(../../img/zamboni/discovery_pane/promos/school-bg-right.png),
@ -231,6 +225,16 @@
}
}
#promos #new-year {
background: url(../../img/zamboni/discovery_pane/promos/new-year.jpg) 50% 50% no-repeat;
h2 {
color: #ffc;
font-size: 28px;
margin: 30px 0;
text-shadow: 0 1px 0 rgba(0,0,0,.5);
}
}
.addons li {
float: left;
width: 30%;
@ -242,9 +246,6 @@
.addons li:nth-child(3n) {
margin-right: 0;
}
.html-rtl .addons li:nth-child(3n) {
margin-right: 0;
}
.addons li > a,
#monthly > div,

Двоичные данные
media/img/zamboni/discovery_pane/promos/new-year.jpg Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 32 KiB

Просмотреть файл

@ -37,6 +37,7 @@ function initPromos($context) {
$('.addons .desc', $promos).truncate({dir: 'v'});
$('.install', $promos).installButton();
$('#monthly .blurb > p').lineclamp(4);
$('h2', $promos).linefit();
});
$('.toplist .name').truncate({showTitle: true});
}

Просмотреть файл

@ -62,9 +62,11 @@ function initTrunc() {
$('.htruncate').truncate({dir: 'h'});
$('.vtruncate').truncate({dir: 'v'});
$('#monthly .blurb > p').lineclamp(4);
$('#promos h2').linefit();
$(window).resize(debounce(function() {
$('.htruncate').truncate({dir: 'h'});
$('.vtruncate').truncate({dir: 'v'});
$('#promos h2').linefit();
}, 200));
}

Просмотреть файл

@ -596,4 +596,3 @@ $.fn.objectUrl = function(offset) {
}
return url;
};

Просмотреть файл

@ -82,3 +82,19 @@ $.fn.lineclamp = function(lines) {
}
});
};
$.fn.linefit = function() {
// This function shrinks text to fit on one line.
var min_font_size = 7;
return this.each(function() {
var $this = $(this),
fs = parseFloat($this.css('font-size').replace('px', '')),
max_height = parseFloat($this.css('line-height').replace('px', '')),
height = $this.height();
while (height > max_height && fs > min_font_size) {
// Repeatedly shrink the text by 0.5px until all the text fits.
fs -= .5;
$this.css('font-size', fs);
height = $this.height();
}
});
};