NewsBlur/media/ios/storyDetailView.js

60 lines
1.8 KiB
JavaScript
Raw Normal View History

2012-06-28 15:11:39 -07:00
$('.NB-story img').each(function() {
setImage(this);
});
2012-06-21 11:53:48 -07:00
2012-06-28 15:11:39 -07:00
$('.NB-story img').bind('load', function() {
setImage(this);
});
2012-06-21 11:53:48 -07:00
$('a.NB-show-profile').click(function(){
2012-07-11 18:08:07 -07:00
var offset = $('img', this).offset();
console.log(offset);
var url = $(this).attr('href') + "/" + offset.left + "/" + (offset.top - window.pageYOffset) + "/" + offset.width + "/" + offset.height;
window.location = url;
return false;
})
function setImage(img) {
var $img = $(img);
var width = $(img).width();
var height = $(img).height();
if ($img.attr('src').indexOf('feedburner') != -1) {
$img.attr('class', 'NB-feedburner');
} else if (width > 300 && height > 50) {
$img.attr('class', 'NB-large-image');
if ($img.parent().attr('href')) {
$img.parent().addClass('NB-contains-image')
}
} else if (width > 30 && height > 30) {
$img.attr('class', 'NB-medium-image');
if ($img.parent().attr('href')) {
$img.parent().addClass('NB-contains-image')
}
} else {
$img.attr('class', 'NB-small-image');
}
}
2012-06-21 11:53:48 -07:00
//window.onload = load;
//
//function load() {
// document.getElementsByClassName('NB-share-button')[0].addEventListener("touchstart", touchStart, false);
// document.getElementsByClassName('NB-share-button')[0].addEventListener("touchend", touchEnd, false);
//}
//
//function touchStart(e) {
// var original_class = e.target.getAttribute("class");
// e.target.setAttribute("class", original_class + " active");
// return false;
//}
//
//function touchEnd(e) {
// var original_class = e.target.getAttribute("class");
// e.target.setAttribute("class", original_class.replace('active', ''));
// window.location = "http://ios.newsblur.com/share";
// return false;
//}