Adding highlight.js, bigfoot.js, and fitvid.js. Bigfoot needs love.

This commit is contained in:
Samuel Clay 2014-01-03 17:13:21 -08:00
parent 0486603ff0
commit a460bece9d
8 changed files with 1813 additions and 5 deletions

View file

@ -61,6 +61,9 @@ javascripts:
- media/js/vendor/underscore.string.js
- media/js/vendor/backbone-*.js
- media/js/vendor/bootstrap-transition.js
- media/js/vendor/highlight.js
- media/js/vendor/fitvid.js
- media/js/vendor/bigfoot.js
- media/js/newsblur/reader/reader_utils.js
- media/js/newsblur/reader/reader.js
- media/js/newsblur/reader/reader_popover.js
@ -117,6 +120,8 @@ stylesheets:
- media/css/jquery-ui/jquery.theme.css
- media/css/jquery.tipsy.css
- media/css/vendor/bootstrap-progressbar.css
- media/css/vendor/highlight.css
- media/css/vendor/bigfoot.css
- media/css/*.css
mobile:
- media/css/mobile/jquery.mobile-1.0b1.css

View file

@ -2095,10 +2095,10 @@ background: transparent;
}
.NB-feed-story blockquote {
border-left: 5px solid #C2C5BE;
padding: 0 1.5em;
border-left: 2px solid #ECEFE9;
padding: .5em 1.5em;
margin: 0px;
color: rgba(10, 12, 38, .6);
background-color: #F4F6F2;
}
.NB-feed-story .NB-feed-story-content iframe,

295
media/css/vendor/bigfoot.css vendored Normal file
View file

@ -0,0 +1,295 @@
.footnote-button {
position: relative;
z-index: 5;
top: -0.15em;
box-sizing: border-box;
-moz-box-sizing: border-box;
display: inline-block;
padding: 0.34em;
margin: 0 0.1em 0 0.2em;
border: none;
border-radius: 0.3em;
cursor: pointer;
opacity: 0.3;
background-color: #464646;
line-height: 0;
vertical-align: middle;
text-decoration: none;
font-smoothing: antialiased;
-webkit-transition: opacity;
-moz-transition: opacity;
-ms-transition: opacity;
transition: opacity;
-webkit-transition-duration: 0.25s;
-moz-transition-duration: 0.25s;
transition-duration: 0.25s;
}
.footnote-button:hover {
opacity: 0.6;
}
.footnote-button:active {
opacity: 0.6;
}
.footnote-button.active {
opacity: 0.9;
-webkit-transition-delay: 0.15s;
-moz-transition-delay: 0.15s;
transition-delay: 0.15s;
}
.footnote-circle {
display: inline-block;
width: 0.32em;
height: 0.32em;
margin-right: 0.224em;
border-radius: 100%;
background-color: #e6e6e6;
border: none;
}
.footnote-circle:last-child {
margin-right: 0;
}
@media not print {
.footnote-print-only {
display: none !important;
}
}
@media print {
.footnote-button {
display: none !important;
}
}
.footnote-content {
position: fixed;
z-index: 10;
bottom: auto;
left: auto;
box-sizing: border-box;
-moz-box-sizing: border-box;
max-width: 90%;
margin: 1.21924em auto;
display: inline-block;
background: #fafafa;
opacity: 0;
border-radius: 0.5em;
border: 1px solid #c3c3c3;
box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3);
-webkit-transition: opacity, -webkit-transform;
-moz-transition: opacity, -moz-transform;
-ms-transition: opacity, -ms-transform;
transition: opacity, transform;
-webkit-transition-duration: 0.25s;
-moz-transition-duration: 0.25s;
transition-duration: 0.25s;
}
.footnote-content:not(.fixed-bottom) {
-webkit-transform: scale(0.1) translateZ(0);
-moz-transform: scale(0.1) translateZ(0);
-ms-transform: scale(0.1) translateZ(0);
-o-transform: scale(0.1) translateZ(0);
transform: scale(0.1) translateZ(0);
-webkit-transform-origin: 50% 0;
-moz-transform-origin: 50% 0;
-ms-transform-origin: 50% 0;
-o-transform-origin: 50% 0;
transform-origin: 50% 0;
}
.footnote-content.active:not(.fixed-bottom) {
-webkit-transform: scale(1) translateZ(0);
-moz-transform: scale(1) translateZ(0);
-ms-transform: scale(1) translateZ(0);
-o-transform: scale(1) translateZ(0);
transform: scale(1) translateZ(0);
opacity: 0.97;
}
.footnote-content.bottom {
-webkit-transform-origin: top;
-moz-transform-origin: top;
-ms-transform-origin: top;
-o-transform-origin: top;
transform-origin: top;
}
.footnote-content.top {
-webkit-transform-origin: bottom;
-moz-transform-origin: bottom;
-ms-transform-origin: bottom;
-o-transform-origin: bottom;
transform-origin: bottom;
}
.footnote-content.fixed-bottom {
bottom: 0 !important;
top: auto !important;
left: 0 !important;
width: 100%;
max-width: 100%;
margin: 0;
-webkit-transform: translateY(105%);
-moz-transform: translateY(105%);
-ms-transform: translateY(105%);
-o-transform: translateY(105%);
transform: translateY(105%);
border-radius: 0;
opacity: 1;
-webkit-transition: -webkit-transform;
-moz-transition: -moz-transform;
-ms-transition: -ms-transform;
transition: transform;
-webkit-transition-duration: 0.25s;
-moz-transition-duration: 0.25s;
transition-duration: 0.25s;
}
.footnote-content.fixed-bottom.active {
-webkit-transform: translateY(0);
-moz-transform: translateY(0);
-ms-transform: translateY(0);
-o-transform: translateY(0);
transform: translateY(0);
}
.footnote-content.fixed-bottom .footnote-main-wrapper {
max-width: 90%;
width: 22em;
margin: 0 auto;
}
.footnote-content.fixed-bottom .tooltip {
display: none;
}
.footnote-content.scrollable:after {
content: '...';
position: fixed;
bottom: 0.45em;
right: 50%;
z-index: 20;
width: 1.5em;
margin-right: -0.75em;
opacity: 1;
background-color: #fafafa;
font-family: Georgia;
font-weight: bold;
font-size: 1.8em;
text-align: center;
color: rgba(0, 0, 0, 0.08);
line-height: 0;
-webkit-transition: opacity;
-moz-transition: opacity;
-ms-transition: opacity;
transition: opacity;
-webkit-transition-duration: 0.25s;
-moz-transition-duration: 0.25s;
transition-duration: 0.25s;
-webkit-transition-delay: 0.4s;
-moz-transition-delay: 0.4s;
transition-delay: 0.4s;
}
.footnote-content.scrollable.fully-scrolled:after {
opacity: 0;
-webkit-transition-delay: 0s;
-moz-transition-delay: 0s;
transition-delay: 0s;
}
.footnote-content.scrollable .footnote-main-wrapper:before, .footnote-content.scrollable .footnote-main-wrapper:after {
content: ' ';
position: absolute;
width: 100%;
z-index: 12;
}
.footnote-content.scrollable .footnote-main-wrapper:before {
top: -1px;
left: 0;
height: 1.1em;
border-radius: 0.5em 0.5em 0 0;
background: #fafafa;
background: -moz-linear-gradient(top, #fafafa 0%, #fafafa 50%, rgba(250, 250, 250, 0) 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #fafafa), color-stop(50%, #fafafa), color-stop(100%, rgba(250, 250, 250, 0)));
background: -webkit-linear-gradient(top, #fafafa 0%, #fafafa 50%, rgba(250, 250, 250, 0) 100%);
background: -o-linear-gradient(top, #fafafa 0%, #fafafa 50%, rgba(250, 250, 250, 0) 100%);
background: -ms-linear-gradient(top, #fafafa 0%, #fafafa 50%, rgba(250, 250, 250, 0) 100%);
background: linear, to bottom, #fafafa 0%, #fafafa 50%, rgba(250, 250, 250, 0) 100%;
}
.footnote-content.scrollable .footnote-main-wrapper:after {
bottom: -1px;
left: 0;
height: 1.2em;
border-radius: 0 0 0.5em 0.5em;
background: #fafafa;
background: -moz-linear-gradient(bottom, #fafafa 0%, #fafafa 50%, rgba(250, 250, 250, 0) 100%);
background: -webkit-gradient(linear, left bottom, left top, color-stop(0%, #fafafa), color-stop(50%, #fafafa), color-stop(100%, rgba(250, 250, 250, 0)));
background: -webkit-linear-gradient(bottom, #fafafa 0%, #fafafa 50%, rgba(250, 250, 250, 0) 100%);
background: -o-linear-gradient(bottom, #fafafa 0%, #fafafa 50%, rgba(250, 250, 250, 0) 100%);
background: -ms-linear-gradient(bottom, #fafafa 0%, #fafafa 50%, rgba(250, 250, 250, 0) 100%);
background: linear, to top, #fafafa 0%, #fafafa 50%, rgba(250, 250, 250, 0) 100%;
}
.footnote-content ::-webkit-scrollbar {
display: none;
}
.footnote-main-wrapper {
position: relative;
z-index: 14;
box-sizing: border-box;
-moz-box-sizing: border-box;
overflow: hidden;
margin: 0;
max-width: 22em;
background-color: #fafafa;
border-radius: 0.5em;
-webkit-transition: max-height;
-moz-transition: max-height;
-ms-transition: max-height;
transition: max-height;
-webkit-transition-duration: 0.25s;
-moz-transition-duration: 0.25s;
transition-duration: 0.25s;
}
.footnote-content-wrapper {
position: relative;
z-index: 8;
max-height: 15em;
padding: 1.1em 1.3em 1.2em;
box-sizing: border-box;
-moz-box-sizing: border-box;
overflow: auto;
-webkit-overflow-scrolling: touch;
background: #fafafa;
border-radius: 0.5em;
-webkit-font-smoothing: subpixel-antialiased;
}
.footnote-content-wrapper img {
max-width: 100%;
}
.footnote-content-wrapper *:last-child {
margin-bottom: 0;
}
.footnote-content-wrapper *:first-child {
margin-top: 0;
}
.tooltip {
position: absolute;
z-index: 12;
box-sizing: border-box;
-moz-box-sizing: border-box;
margin-left: -0.65em;
width: 1.3em;
height: 1.3em;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
background: #fafafa;
border: 1px solid #c3c3c3;
box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.3);
border-top-left-radius: 0;
}
.bottom .tooltip {
top: -0.65em;
bottom: auto;
}
.top .tooltip {
bottom: -0.65em;
top: auto;
}

162
media/css/vendor/highlight.css vendored Normal file
View file

@ -0,0 +1,162 @@
/*
Docco style used in http://jashkenas.github.com/docco/ converted by Simon Madine (@thingsinjars)
*/
pre, code {
background: #F4F6F2;
padding: 0.15em 0.35em;
}
pre {
padding: 0.5em;
}
pre code {
padding: 0;
display: block;
color: #000;
background: #F4F6F2;
}
pre .comment,
pre .template_comment,
pre .diff .header,
pre .javadoc {
color: #408080;
font-style: italic
}
pre .keyword,
pre .assignment,
pre .literal,
pre .css .rule .keyword,
pre .winutils,
pre .javascript .title,
pre .lisp .title,
pre .subst {
color: #954121;
}
pre .number,
pre .hexcolor {
color: #40a070
}
pre .string,
pre .tag .value,
pre .phpdoc,
pre .tex .formula {
color: #219161;
}
pre .title,
pre .id {
color: #19469D;
}
pre .params {
color: #00F;
}
pre .javascript .title,
pre .lisp .title,
pre .subst {
font-weight: normal
}
pre .class .title,
pre .haskell .label,
pre .tex .command {
color: #458;
font-weight: bold
}
pre .tag,
pre .tag .title,
pre .rules .property,
pre .django .tag .keyword {
color: #000080;
}
pre .keyword,
pre .id,
pre .title,
pre .built_in,
pre .aggregate,
pre .css .tag,
pre .javadoctag,
pre .phpdoc,
pre .yardoctag,
pre .smalltalk .class,
pre .winutils,
pre .bash .variable,
pre .apache .tag,
pre .go .typename,
pre .tex .command,
pre .asciidoc .strong,
pre .markdown .strong,
pre .request,
pre .status {
font-weight: bold;
}
pre .attribute,
pre .variable,
pre .instancevar,
pre .lisp .body {
color: #008080
}
pre .regexp {
color: #B68
}
pre .class {
color: #458;
font-weight: bold
}
pre .symbol,
pre .ruby .symbol .string,
pre .ruby .symbol .keyword,
pre .ruby .symbol .keymethods,
pre .lisp .keyword,
pre .tex .special,
pre .input_number {
color: #990073
}
pre .builtin,
pre .constructor,
pre .built_in,
pre .lisp .title {
color: #0086b3
}
pre .preprocessor,
pre .pragma,
pre .pi,
pre .doctype,
pre .shebang,
pre .cdata {
color: #999;
font-weight: bold
}
pre .deletion {
background: #fdd
}
pre .addition {
background: #dfd
}
pre .diff .change {
background: #0086b3
}
pre .chunk {
color: #aaa
}
pre .tex .formula {
opacity: 0.5;
}

View file

@ -87,7 +87,10 @@ NEWSBLUR.Views.StoryDetailView = Backbone.View.extend({
this.toggle_intelligence();
this.generate_gradients();
this.render_comments();
this.attach_audio_handler_to_stories();
this.attach_audio_handler();
this.attach_footnotes_handler();
this.attach_syntax_highlighter_handler();
this.attach_fitvid_handler();
return this;
},
@ -510,7 +513,7 @@ NEWSBLUR.Views.StoryDetailView = Backbone.View.extend({
}
},
attach_audio_handler_to_stories: function() {
attach_audio_handler: function() {
_.delay(_.bind(function() {
var $audio = this.$('audio').filter(function() {
return !$(this).closest('.audiojs').length;
@ -528,6 +531,33 @@ NEWSBLUR.Views.StoryDetailView = Backbone.View.extend({
}, this), 500);
},
attach_syntax_highlighter_handler: function() {
_.delay(_.bind(function() {
this.$('pre').each(function(i, e) {
hljs.highlightBlock(e);
});
}, this), 1000);
},
attach_footnotes_handler: function() {
_.delay(_.bind(function() {
$.bigfoot({
scope: this.$el,
actionOriginalFN: 'ignore'
});
}, this), 500);
},
attach_fitvid_handler: function() {
// Thanks to feedbin for the custom selector
_.delay(_.bind(function() {
this.$el.fitVids({
customSelector: "iframe[src*='youtu.be'],iframe[src*='www.flickr.com'],iframe[src*='view.vzaar.com']"
});
}, this), 500);
},
// ==========
// = Events =
// ==========

1241
media/js/vendor/bigfoot.js vendored Normal file

File diff suppressed because it is too large Load diff

74
media/js/vendor/fitvid.js vendored Normal file
View file

@ -0,0 +1,74 @@
/*global jQuery */
/*jshint multistr:true browser:true */
/*!
* FitVids 1.0.3
*
* Copyright 2013, Chris Coyier - http://css-tricks.com + Dave Rupert - http://daverupert.com
* Credit to Thierry Koblentz - http://www.alistapart.com/articles/creating-intrinsic-ratios-for-video/
* Released under the WTFPL license - http://sam.zoy.org/wtfpl/
*
* Date: Thu Sept 01 18:00:00 2011 -0500
*/
(function( $ ){
"use strict";
$.fn.fitVids = function( options ) {
var settings = {
customSelector: null
};
if(!document.getElementById('fit-vids-style')) {
var div = document.createElement('div'),
ref = document.getElementsByTagName('base')[0] || document.getElementsByTagName('script')[0],
cssStyles = '&shy;<style>.fluid-width-video-wrapper{width:100%;position:relative;padding:0;}.fluid-width-video-wrapper iframe,.fluid-width-video-wrapper object,.fluid-width-video-wrapper embed {position:absolute;top:0;left:0;width:100%;height:100%;}</style>';
div.className = 'fit-vids-style';
div.id = 'fit-vids-style';
div.style.display = 'none';
div.innerHTML = cssStyles;
ref.parentNode.insertBefore(div,ref);
}
if ( options ) {
$.extend( settings, options );
}
return this.each(function(){
var selectors = [
"iframe[src*='player.vimeo.com']",
"iframe[src*='youtube.com']",
"iframe[src*='youtube-nocookie.com']",
"iframe[src*='kickstarter.com'][src*='video.html']",
"object",
"embed"
];
if (settings.customSelector) {
selectors.push(settings.customSelector);
}
var $allVideos = $(this).find(selectors.join(','));
$allVideos = $allVideos.not("object object"); // SwfObj conflict patch
$allVideos.each(function(){
var $this = $(this);
if (this.tagName.toLowerCase() === 'embed' && $this.parent('object').length || $this.parent('.fluid-width-video-wrapper').length) { return; }
var height = ( this.tagName.toLowerCase() === 'object' || ($this.attr('height') && !isNaN(parseInt($this.attr('height'), 10))) ) ? parseInt($this.attr('height'), 10) : $this.height(),
width = !isNaN(parseInt($this.attr('width'), 10)) ? parseInt($this.attr('width'), 10) : $this.width(),
aspectRatio = height / width;
if(!$this.attr('id')){
var videoID = 'fitvid' + Math.floor(Math.random()*999999);
$this.attr('id', videoID);
}
$this.wrap('<div class="fluid-width-video-wrapper"></div>').parent('.fluid-width-video-wrapper').css('padding-top', (aspectRatio * 100)+"%");
$this.removeAttr('height').removeAttr('width');
});
});
};
// Works with either jQuery or Zepto
})( window.jQuery || window.Zepto );

1
media/js/vendor/highlight.js vendored Normal file

File diff suppressed because one or more lines are too long