This commit is contained in:
Dean Putney 2013-11-20 17:39:50 -08:00
commit 510adf1aed
6 changed files with 75 additions and 50 deletions

View File

@ -10,10 +10,6 @@ body {
-moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box;
}
.sponsored {
color: #5f99cf;
}
.center-align { text-align:center; }
.left-align { text-align: left; }
.right-align { text-align: right; }
@ -160,7 +156,7 @@ input.add-channel {
background-size: calc(100% + 4px);
}
#video-list .thumbnail.promo {
#video-list .thumbnail.sponsored {
border: 2px solid #ef4b23;
background-size: calc(100% + 4px);
}
@ -359,11 +355,11 @@ body.video-loading #loading {
position: relative;
}
#video-container.promo #video-actions, #promo-actions {
#video-container.sponsored #video-actions, #sponsored-actions {
display: none;
}
#video-container.promo #promo-actions {
#video-container.sponsored #sponsored-actions {
display: block;
}
@ -425,7 +421,7 @@ body.video-loading #loading {
font-weight: 300;
}
#video-actions, #promo-actions {
#video-actions, #sponsored-actions {
color:#5f99cf;
font-weight: 600;
font-size: 13px;
@ -691,10 +687,15 @@ body.video-loading #loading {
margin: 0;
}
#channels a.channel:not(#add-channel-button):not(.promo) .name {
#channels a.channel:not(#add-channel-button):not(.sponsor) .name,
#channels.ss-current-container a.channel {
cursor: move;
}
#add-channel-button:focus, #channels a.sponsor.channel:focus {
outline: none;
}
#channels.animate, #channels.animate a.channel {
-webkit-transition: all 0.3s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
@ -739,7 +740,6 @@ body.video-loading #loading {
position: absolute;
}
#channels a.channel.user .thumbnail span.add {
font-size: 24px;
}
@ -820,6 +820,10 @@ body.video-loading #loading {
-webkit-transition: border 0.1s;
}
.channels a.sponsor.channel:not(.focus):not(:hover) .thumbnail {
border-color: #ef4b23;
}
#add-channel-button .thumbnail {
background-image:url(../img/addChannel.jpg);
}

View File

@ -118,7 +118,7 @@ Globals = {
<span id="video-sponsored-label" class="sponsored">SPONSORED </span>
<span id="video-title"></span>
</div>
<div id="promo-actions" class="grid-30 right-align">
<div id="sponsored-actions" class="grid-30 right-align">
SPONSORED
</div>
<div id="video-actions" class="grid-30 right-align">

View File

@ -106,11 +106,13 @@
};
Plugin.prototype.setGlobals = function() {
this.globals.initializing = true;
this.globals.animated = this.options.animateOnInit;
return this.globals.dragging = false;
};
Plugin.prototype.afterInit = function() {
this.globals.initializing = false;
return this.globals.animated = this.options.animated;
};
@ -254,7 +256,7 @@
placeholder_class = options.placeholderClass;
$child = $child.siblings("." + placeholder_class);
}
if ( options.ignore && !$child.is(options.ignore) ) {
if ( globals.initializing || ( options.ignore && !$child.is(options.ignore) ) ) {
if (animated && !is_dragged_child) {
$child.stop(true, false).animate(attributes, animation_speed, function() {});
} else {
@ -540,10 +542,12 @@
}
if (target_position === parsed_children.length) {
$target = parsed_children[target_position - 1].el;
$selected.insertAfter($target);
if (options.ignore && !$target.is(options.ignore))
$selected.insertAfter($target);
} else {
$target = parsed_children[target_position].el;
$selected.insertBefore($target);
if (options.ignore && !$target.is(options.ignore))
$selected.insertBefore($target);
}
} else {
if (total_positions === 1) {

File diff suppressed because one or more lines are too long

View File

@ -70,10 +70,10 @@ var RedditTV = Class.extend({
}, Globals); // end Globals
// Load ads
self.Globals.videos['/promo'] = { 'video': [] };
self.Globals.videos['/sponsor'] = { 'video': [] };
self.apiCall('ads', null, function(data) {
self.Globals.ads = data;
self.Globals.videos['/promo'].video = self.formatAdVideos(data.videos);
self.Globals.videos['/sponsor'].video = self.formatAdVideos(data.videos);
$(document).trigger('adsLoaded');
});
@ -92,8 +92,10 @@ var RedditTV = Class.extend({
self.setBindings();
self.displayChannels();
if (!self.Globals.current_anchor)
self.loadChannel(self.Globals.channels[0], null);
if (!self.Globals.current_anchor) {
var firstChannel = $('#channels a.channel:not(#add-channel-button):first');
if (firstChannel.length) self.loadChannel(self.getChanObj(firstChannel.data('feed')), null);
}
}, // init()
loadSettings: function() {
@ -263,7 +265,7 @@ var RedditTV = Class.extend({
self.closeVideoList();
self.Globals.videoListMouse = false;
if ( $(this).hasClass('promo') ) {
if ( $(this).hasClass('sponsored') ) {
self.loadVideo(parseInt($(this).attr('data-adNum')), true);
}
}
@ -480,7 +482,7 @@ var RedditTV = Class.extend({
channels.shapeshift({
selector: 'a.channel',
ignore: '#add-channel-button, .promo',
ignore: '#add-channel-button, .sponsor',
align: 'center',
colWidth: 250,
columns: 4,
@ -496,7 +498,7 @@ var RedditTV = Class.extend({
saveChannelOrder: function() {
var feeds = [];
$('#channels a.channel:not(#add-channel-button):not(.promo):not(.temp)').each(function() {
$('#channels a.channel:not(#add-channel-button):not(.sponsor):not(.temp)').each(function() {
feeds.push($(this).data('feed'));
});
@ -504,7 +506,7 @@ var RedditTV = Class.extend({
if (self.Globals.channels.length > feeds.length) {
$.each(self.Globals.channels, function(i, chan) {
if (self.Globals.channel_sorting.indexOf(chan.feed) == -1)
if (chan.owner != 'sponsor' && self.Globals.channel_sorting.indexOf(chan.feed) == -1)
self.Globals.channel_sorting.push(chan.feed);
});
}
@ -518,10 +520,14 @@ var RedditTV = Class.extend({
$channel_base = $('#channels a.channel:first'),
sorted = (self.Globals.channel_sorting.length);
$.each(self.Globals.channels, function(i, chan) {
if (chan.owner == 'sponsor' && chan.feed) self.displayChannel(chan);
});
var channels = (sorted) ? self.Globals.channel_sorting : self.Globals.channels;
$.each(channels, function(i, chan) {
chan = (sorted) ? self.getChanObj(chan) : chan;
if (chan.feed) self.displayChannel(chan);
if (chan.owner != 'sponsor' && chan.feed) self.displayChannel(chan);
});
self.bindChannelSorting();
@ -563,9 +569,11 @@ var RedditTV = Class.extend({
if (chan.owner) {
chanAttr['data-owner'] = chan.owner;
$channel.addClass(chan.owner)
.find('.thumbnail')
.append('<span class="delete" title="Delete this channel">&times;</span>');
$channel.addClass(chan.owner);
if (chan.owner == 'user')
$channel.find('.thumbnail')
.append('<span class="delete" title="Delete this channel">&times;</span>');
}
$channel
@ -575,7 +583,7 @@ var RedditTV = Class.extend({
.html(display_title);
// .removeClass('loading') // temp
if (added) {
if (added || chan.owner == 'sponsor') {
$channel.insertAfter('#add-channel-button');
} else {
$channel.appendTo('#channels');
@ -982,7 +990,7 @@ var RedditTV = Class.extend({
self.loadVideo(promoIndex, true);
});
} else {
self.loadVideo(self.findVideoById(parts[2], '/promo'), true);
self.loadVideo(self.findVideoById(parts[2], '/sponsor'), true);
}
}else{
var feed = '/' + parts[1] + '/' + parts[2];
@ -1105,7 +1113,7 @@ var RedditTV = Class.extend({
.html($list);
// Populate with ads
if (this_chan.feed.match('/sponsor/').length == 0 && self.Globals.ads && self.Globals.ads.videos.length > 0) {
if ( !this_chan.feed.match('/sponsor/') && self.Globals.ads && self.Globals.ads.videos.length > 0 ) {
var adNum = 0;
$('#video-list .thumbnail').each(function(i) {
@ -1117,10 +1125,10 @@ var RedditTV = Class.extend({
if ( adNum == self.Globals.ads.settings.every ) {
ad = self.getRandomAd();
thumbnail = self.thumbElement(ad, {feed: '/promo' }, rtv.Globals.ads.videos.indexOf(ad));
thumbnail = self.thumbElement(ad, {feed: '/sponsor' }, rtv.Globals.ads.videos.indexOf(ad));
thumbnail.insertBefore($(this));
thumbnail.addClass('promo')
.attr('data-adNum', $('#video-list .promo.thumbnail').length - 1);
thumbnail.addClass('sponsored')
.attr('data-adNum', $('#video-list .sponsored.thumbnail').length - 1);
adNum = 1;
}
@ -1150,7 +1158,7 @@ var RedditTV = Class.extend({
setTimeout(self.closeVideoList, 2000);
}, // loadVideoList()
loadVideo: function(video, promo) {
loadVideo: function(video, sponsored) {
var this_chan = self.Globals.cur_chan,
this_video = self.Globals.cur_video,
selected_video = this_video,
@ -1158,7 +1166,7 @@ var RedditTV = Class.extend({
thumbAnchor, newAnchor;
if (this_chan.feed) videos_size = Object.size(self.Globals.videos[this_chan.feed].video)-1;
if (!promo) promo = false;
if (!sponsored) sponsored = (self.Globals.cur_chan.owner == 'sponsor');
// if (video === false) self.loadVideo('next');
/*if(!videoList.open) {
@ -1174,20 +1182,20 @@ var RedditTV = Class.extend({
selected_video = self.Globals.shuffled.indexOf(selected_video);
}
thumbAnchor = $('#video-list .promo.thumbnail.focus:first');
thumbAnchor = $('#video-list .sponsored.thumbnail.focus:first');
if (!thumbAnchor.length) thumbAnchor = $('#video-list-thumb-' + selected_video);
newAnchor = (video == 'next') ? thumbAnchor.next() : thumbAnchor.prev();
if ( newAnchor.length && (video == 'next' || video == 'prev') ) {
if ( thumbAnchor.hasClass('promo') ) {
if ( thumbAnchor.hasClass('sponsored') ) {
var next_video = parseInt(newAnchor.data('id'))
next_video = (video == 'next') ? next_video + 1 : next_video - 1;
this_video = selected_video = next_video;
}
if ( newAnchor.hasClass('promo') || thumbAnchor.hasClass('promo') ) {
if ( newAnchor.hasClass('sponsored') || thumbAnchor.hasClass('sponsored') ) {
newAnchor.trigger('click');
if (thumbAnchor.hasClass('promo')) window.location.hash = newAnchor.attr('href');
if (thumbAnchor.hasClass('sponsored')) window.location.hash = newAnchor.attr('href');
return;
}
}
@ -1229,18 +1237,23 @@ var RedditTV = Class.extend({
}
//exit if trying to load over_18 content without confirmed over 18
if (!promo && self.sfwCheck(selected_video, this_chan.feed) ) {
if (!sponsored && self.sfwCheck(selected_video, this_chan.feed) ) {
return false;
}
if ( self.Globals.ads && self.Globals.ads.settings && self.Globals.ads.settings.start == 1 && ( video === 'first' || video === null ) ) {
sponsored = true;
$('#video-list a.thumbnail:first').addClass('focus');
}
if(selected_video !== this_video || video === 'first' || video === 0) {
self.Globals.cur_video = selected_video;
var video = (!promo) ? self.Globals.videos[this_chan.feed].video[selected_video] : self.Globals.ads.videos[selected_video];
var video = ( sponsored && self.Globals.cur_chan.owner != 'sponsor' ) ? self.Globals.ads.videos[selected_video] : self.Globals.videos[this_chan.feed].video[selected_video];
// scroll to thumbnail in video list and highlight it
$('#video-list .focus:not(.promo)').removeClass('focus');
$('#video-list .focus:not(.sponsored)').removeClass('focus');
// To-do: Focus and scroll to promo somehow, needs unique ID
if (!promo) $('#video-list-thumb-' + selected_video).addClass('focus');
if (!sponsored) $('#video-list-thumb-' + selected_video).addClass('focus');
$('#video-list:not(.scrollbar)').stop(true,true).scrollTo('.focus', { duration:1000, offset:-280 });
if ($('#video-list').hasClass('scrollbar')) { // Only do this for the jScrollPane-esque thing
var focused = $('#video-list .focus'),
@ -1277,7 +1290,7 @@ var RedditTV = Class.extend({
//set location hash
var parts, hash = document.location.hash;
if (promo) {
if (sponsored) {
hash = '';
} else {
if (!hash) {
@ -1303,14 +1316,14 @@ var RedditTV = Class.extend({
var embed = $.unescapifyHTML(video.media_embed.content);
embed = self.prepEmbed(embed, video.domain);
embed = self.prepEmbed(embed, 'size');
$('#video-container').toggleClass('promo', promo);
$('#video-container').toggleClass('sponsored', sponsored);
var redditlink = 'http://reddit.com'+$.unescapifyHTML(video.permalink);
var videoTitle = '<a href="' + redditlink + '" target="_blank"'
+ ' title="' + video.title_quot + '">'
+ video.title_unesc + '</a>';
if (promo) videoTitle = ( video.title ) ? video.title_unesc : '';
if (sponsored) videoTitle = ( video.title ) ? video.title_unesc : '';
$('#video-title').html(videoTitle);
$('#video-comments-link').attr("href", redditlink);
@ -1347,7 +1360,7 @@ var RedditTV = Class.extend({
thumbElement: function(this_video, this_chan, id) {
var videoId, url, $thumbnail, thumbnail_image, anchorId,
anchorClass = [ 'thumbnail' ],
isPromo = (this_chan.feed == '/promo');
sponsored = (this_chan.feed == '/sponsor');
// console.log(this_video, this_chan);
if ( this_video.title && !this_video.title_unesc ) {
@ -1357,10 +1370,10 @@ var RedditTV = Class.extend({
if ( !this_video.title ) this_video.title_unesc = this_video.title_quot = '';
videoId = (self.Globals.videos[this_chan.feed]) ? self.Globals.videos[this_chan.feed].video[id].id : id;
url = ( this_chan.feed != '/promo' ) ? this_chan.feed + '/' + videoId : '';
url = ( !sponsored ) ? this_chan.feed + '/' + videoId : '';
anchorId = ( this_chan.feed != '/promo' ) ? ' id="video-list-thumb-' + id + '"' : '';
if (isPromo) anchorClass.push('promo');
anchorId = ( !sponsored ) ? ' id="video-list-thumb-' + id + '"' : '';
if (sponsored) anchorClass.push('sponsored');
$thumbnail = $('<a href="#' + url + '"' + anchorId + ' class="' + anchorClass.join(' ') + '"></a>');
if (this_video.title_quot) $thumbnail.attr('title', this_video.title_quot);
$thumbnail.data('id', id);

View File

@ -22,6 +22,8 @@ function getChannels() {
' feed = ? LIMIT 1 ', array( $channel->feed )
);
$channels[$id]->owner = 'site';
if ( $thumb && $thumb->thumbnail_url != '' )
$channels[$id]->thumbnail = $thumb->thumbnail_url;
}