fix xbox one browser access

This commit is contained in:
Luke Pulverenti 2015-05-06 23:11:51 -04:00
parent 0a24cd2dc6
commit 173773d5bc
22 changed files with 1229 additions and 172 deletions

View File

@ -34,12 +34,12 @@
</p>
<div class="skip">
<br />
<a class="btn btnDarkAccent" href="connectlogin.html?mode=manualserver">
<button class="btn btnDarkAccent btnSkipConnect" data-role="none" type="button">
<span>
${ButtonSkip}
</span>
<i class="fa fa-close"></i>
</a>
</button>
<div class="fieldDescription">${TextConnectToServerManually}</div>
</div>

View File

@ -49,6 +49,10 @@
margin: 1px;
}
.largeCardMargin .cardBox {
margin: 8px;
}
/*@media all and (max-width: 600px) {
.cardBox {
@ -229,6 +233,11 @@
height: 100%;
}
.cardImage canvas {
width: 100%;
height: 100%;
}
.coveredCardImage {
background-size: cover;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 B

View File

@ -188,7 +188,7 @@
.librarySidebarLinks a {
font-weight: 300 !important;
padding: .7em 20px .7em 0;
padding: .8em 20px .8em 0;
}
.librarySidebarLinks a:hover {

View File

@ -1120,3 +1120,14 @@ h1 + .accentButton {
.disabledUserBanner {
margin: 0 0 2em;
}
.modalLoading {
position: fixed;
top: 0;
right: 0;
left: 0;
bottom: 0;
background: rgba(0, 0, 0, .3);
/* One less than jqm loading spinner, so we can combine them */
z-index: 9999998;
}

View File

@ -119,7 +119,16 @@
}
}
$(document).on('pageshow', "#connectLoginPage", function () {
$(document).on('pageinit', "#connectLoginPage", function () {
var page = this;
$('.btnSkipConnect', page).on('click', function() {
Dashboard.navigate('connectlogin.html?mode=manualserver');
});
}).on('pageshow', "#connectLoginPage", function () {
var page = this;

View File

@ -1177,6 +1177,8 @@
var chapters = item.Chapters || [];
var maxWwidth = LibraryBrowser.getPosterViewSizes().thumbWidth;
for (var i = 0, length = chapters.length; i < length; i++) {
if (limit && i >= limit) {
@ -1198,7 +1200,7 @@
if (chapter.ImageTag) {
imgUrl = ApiClient.getScaledImageUrl(item.Id, {
maxWidth: 210,
maxWidth: maxWwidth,
tag: chapter.ImageTag,
type: "Chapter",
index: i
@ -1397,6 +1399,8 @@
var html = '';
var maxWwidth = LibraryBrowser.getPosterViewSizes().thumbWidth;
for (var i = 0, length = items.length; i < length; i++) {
if (limit && i >= limit) {
@ -1423,7 +1427,7 @@
if (imageTags.Primary) {
imgUrl = ApiClient.getScaledImageUrl(item.Id, {
maxWidth: 210,
maxWidth: maxWwidth,
tag: imageTags.Primary,
type: "primary"
});

View File

@ -945,6 +945,63 @@
return itemCommands;
},
screenWidth: function () {
var screenWidth = $(window).width();
if (!AppInfo.isTouchPreferred) {
screenWidth = window.screen.availWidth;
}
return screenWidth;
},
getPostersPerRow: function () {
var screenWidth = LibraryBrowser.screenWidth();
var div = $('<div class="card squareCard"><div class="cardBox"><div class="cardImage"></div></div></div>').appendTo(document.body);
var square = screenWidth / $('.cardImage', div).innerWidth();
div.remove();
div = $('<div class="card backdropCard">><div class="cardBox"><div class="cardImage"></div></div></div>').appendTo(document.body);
var thumb = screenWidth / $('.cardImage', div).innerWidth();
div.remove();
div = $('<div class="card portraitCard">><div class="cardBox"><div class="cardImage"></div></div></div>').appendTo(document.body);
var poster = screenWidth / $('.cardImage', div).innerWidth();
div.remove();
return {
thumb: thumb,
poster: poster,
square: square
};
},
getPosterViewSizes: function () {
var imagesPerRow = LibraryBrowser.getPostersPerRow();
var screenWidth = LibraryBrowser.screenWidth();
if (AppInfo.hasLowImageBandwidth) {
screenWidth *= .95;
} else {
screenWidth *= 1.25;
}
var thumbWidth = screenWidth / imagesPerRow.thumb;
var posterWidth = screenWidth / imagesPerRow.poster;
var squareSize = screenWidth / imagesPerRow.square;
return {
thumbWidth: parseInt(thumbWidth),
posterWidth: parseInt(posterWidth),
squareSize: parseInt(squareSize)
};
},
getPosterViewHtml: function (options) {
var items = options.items;
@ -978,6 +1035,12 @@
}
}
var sizes = LibraryBrowser.getPosterViewSizes();
var thumbWidth = sizes.thumbWidth;
var posterWidth = sizes.posterWidth;
var squareSize = sizes.squareSize;
for (var i = 0, length = items.length; i < length; i++) {
var item = items[i];
@ -1044,13 +1107,12 @@
var forceName = false;
var downloadHeight = 576;
var enableImageEnhancers = options.enableImageEnhancers !== false;
if (options.autoThumb && item.ImageTags && item.ImageTags.Primary && item.PrimaryImageAspectRatio && item.PrimaryImageAspectRatio >= 1.5) {
height = 400;
width = primaryImageAspectRatio ? Math.round(height * primaryImageAspectRatio) : null;
width = posterWidth;
height = primaryImageAspectRatio ? Math.round(posterWidth / primaryImageAspectRatio) : null;
imgUrl = ApiClient.getImageUrl(item.Id, {
type: "Primary",
@ -1064,7 +1126,7 @@
imgUrl = ApiClient.getScaledImageUrl(item.Id, {
type: "Thumb",
maxWidth: downloadHeight,
maxWidth: thumbWidth,
tag: item.ImageTags.Thumb,
enableImageEnhancers: enableImageEnhancers
});
@ -1073,7 +1135,7 @@
imgUrl = ApiClient.getScaledImageUrl(item.Id, {
type: "Backdrop",
maxWidth: downloadHeight,
maxWidth: thumbWidth,
tag: item.BackdropImageTags[0],
enableImageEnhancers: enableImageEnhancers
});
@ -1082,7 +1144,7 @@
imgUrl = ApiClient.getScaledImageUrl(item.Id, {
type: "Thumb",
maxWidth: downloadHeight,
maxWidth: thumbWidth,
tag: item.ImageTags.Thumb,
enableImageEnhancers: enableImageEnhancers
});
@ -1100,7 +1162,7 @@
imgUrl = ApiClient.getScaledImageUrl(item.SeriesId, {
type: "Thumb",
maxWidth: downloadHeight,
maxWidth: thumbWidth,
tag: item.SeriesThumbImageTag,
enableImageEnhancers: enableImageEnhancers
});
@ -1109,7 +1171,7 @@
imgUrl = ApiClient.getThumbImageUrl(item.ParentThumbItemId, {
type: "Thumb",
maxWidth: downloadHeight,
maxWidth: thumbWidth,
enableImageEnhancers: enableImageEnhancers
});
@ -1117,7 +1179,7 @@
imgUrl = ApiClient.getScaledImageUrl(item.Id, {
type: "Backdrop",
maxWidth: downloadHeight,
maxWidth: thumbWidth,
tag: item.BackdropImageTags[0],
enableImageEnhancers: enableImageEnhancers
});
@ -1126,8 +1188,8 @@
} else if (item.ImageTags && item.ImageTags.Primary) {
height = 400;
width = primaryImageAspectRatio ? Math.round(height * primaryImageAspectRatio) : null;
width = posterWidth;
height = primaryImageAspectRatio ? Math.round(posterWidth / primaryImageAspectRatio) : null;
imgUrl = ApiClient.getImageUrl(item.Id, {
type: "Primary",
@ -1140,18 +1202,16 @@
}
else if (item.ParentPrimaryImageTag) {
height = 400;
imgUrl = ApiClient.getImageUrl(item.ParentPrimaryImageItemId, {
type: "Primary",
height: height,
width: posterWidth,
tag: item.ParentPrimaryImageTag,
enableImageEnhancers: enableImageEnhancers
});
}
else if (item.AlbumId && item.AlbumPrimaryImageTag) {
height = 220;
height = squareSize;
width = primaryImageAspectRatio ? Math.round(height * primaryImageAspectRatio) : null;
imgUrl = ApiClient.getScaledImageUrl(item.AlbumId, {
@ -1167,7 +1227,7 @@
imgUrl = ApiClient.getScaledImageUrl(item.Id, {
type: "Thumb",
maxWidth: downloadHeight,
maxWidth: thumbWidth,
tag: item.ImageTags.Thumb,
enableImageEnhancers: enableImageEnhancers
});
@ -1177,7 +1237,7 @@
imgUrl = ApiClient.getScaledImageUrl(item.Id, {
type: "Backdrop",
maxWidth: downloadHeight,
maxWidth: thumbWidth,
tag: item.BackdropImageTags[0],
enableImageEnhancers: enableImageEnhancers
});
@ -1186,7 +1246,7 @@
imgUrl = ApiClient.getScaledImageUrl(item.Id, {
type: "Thumb",
maxWidth: downloadHeight,
maxWidth: thumbWidth,
tag: item.ImageTags.Thumb,
enableImageEnhancers: enableImageEnhancers
});
@ -1195,7 +1255,7 @@
imgUrl = ApiClient.getScaledImageUrl(item.SeriesId, {
type: "Thumb",
maxWidth: downloadHeight,
maxWidth: thumbWidth,
tag: item.SeriesThumbImageTag,
enableImageEnhancers: enableImageEnhancers
});
@ -1204,7 +1264,7 @@
imgUrl = ApiClient.getThumbImageUrl(item, {
type: "Thumb",
maxWidth: downloadHeight,
maxWidth: thumbWidth,
enableImageEnhancers: enableImageEnhancers
});

View File

@ -912,6 +912,17 @@
return false;
}
function resetCardImage() {
this.style.backgroundImage = "url('css/images/empty.png')";
}
function resetImages(page) {
//$('cardImage', page).remove();
$('.cardImage', page).each(resetCardImage);
}
$(document).on('pageinit', ".libraryPage", function () {
var page = this;
@ -964,6 +975,11 @@
hideSelections(page);
$('.viewTabButton:first', page).trigger('click');
}).on('pagebeforehide', ".libraryPage", function () {
var page = this;
resetImages(page);
});
function renderUserDataChanges(card, userData) {

View File

@ -1,10 +1,10 @@
(function (window, document, $) {
(function (window, document, $, devicePixelRatio) {
function renderHeader(user) {
var html = '<div class="viewMenuBar ui-bar-b">';
if (($.browser.safari && $.browser.mobile && window.navigator.standalone) || Dashboard.isRunningInCordova()) {
if (($.browser.safari && window.navigator.standalone) || Dashboard.isRunningInCordova()) {
html += '<a data-rel="back" data-role="none" href="#" class="headerButton headerButtonLeft headerBackButton"><div class="fa fa-arrow-circle-o-left"></div></a>';
}
@ -40,9 +40,9 @@
html += '<button id="btnCast" class="btnCast btnDefaultCast headerButton headerButtonRight" type="button" data-role="none" style="visibility:hidden;"><div class="headerSelectedPlayer"></div><div class="btnCastImage"></div></button>';
}
if (user.name) {
html += '<a class="headerButton headerButtonRight headerUserButton" href="#" onclick="Dashboard.showUserFlyout(this);">';
if (user.imageUrl) {
@ -80,12 +80,12 @@
function bindMenuEvents() {
if ($.browser.mobile) {
if (AppInfo.isTouchPreferred) {
$('.libraryMenuButton').on('mousedown', function () {
$('.libraryMenuButton').on('click', function () {
showLibraryMenu(false);
});
$('.dashboardMenuButton').on('mousedown', function () {
$('.dashboardMenuButton').on('click', function () {
showDashboardMenu(false);
});
@ -96,10 +96,7 @@
// grab an element
var viewMenuBar = document.getElementsByClassName("viewMenuBar")[0];
// construct an instance of Headroom, passing the element
var headroom = new Headroom(viewMenuBar);
// initialise
headroom.init();
initHeadRoom(viewMenuBar);
}
function getItemHref(item, context) {
@ -263,7 +260,7 @@
html += '<div class="sidebarLinks librarySidebarLinks">';
var showUserAtTop = $.browser.mobile;
var showUserAtTop = AppInfo.isTouchPreferred;
if (showUserAtTop) {
@ -545,16 +542,25 @@
$(document).scrollTop(0);
}
$('.libraryViewNav', page).each(function() {
// construct an instance of Headroom, passing the element
var headroom = new Headroom(this);
// initialise
headroom.init();
$('.libraryViewNav', page).each(function () {
initHeadRoom(this);
});
});
function initHeadRoom(elem) {
if (!AppInfo.enableHeadRoom) {
return;
}
// construct an instance of Headroom, passing the element
var headroom = new Headroom(elem);
// initialise
headroom.init();
}
function initializeApiClient(apiClient) {
$(apiClient).off('websocketmessage.librarymenu', onWebSocketMessage).on('websocketmessage.librarymenu', onWebSocketMessage);
@ -573,7 +579,7 @@
});
})(window, document, jQuery);
})(window, document, jQuery, window.devicePixelRatio);
$.fn.createHoverTouch = function () {

View File

@ -419,14 +419,16 @@
});
}
$('.tvGuideHeader', page).each(function () {
if (AppInfo.enableHeadRoom) {
$('.tvGuideHeader', page).each(function () {
// construct an instance of Headroom, passing the element
var headroom = new Headroom(this);
// initialise
headroom.init();
// construct an instance of Headroom, passing the element
var headroom = new Headroom(this);
// initialise
headroom.init();
});
});
}
}).on('pageshow', "#liveTvGuidePage", function () {

View File

@ -90,6 +90,7 @@
function onPopupOpen(elem) {
elem.popup("open").parents(".ui-popup-container").css("margin-top", 30);
// TODO: With iOS 8 this might not be required anymore
if ($.browser.safari) {
$('.itemVideo').css('visibility', 'hidden');
}

View File

@ -26,7 +26,7 @@
self.getTargets = function () {
var targets = [{
name: 'My Browser',
name: Globalize.translate('MyDevice'),
id: ConnectionManager.deviceId(),
playerName: self.name,
playableMediaTypes: ['Audio', 'Video'],
@ -139,6 +139,13 @@
VideoCodec: 'h264',
AudioCodec: 'aac,mp3'
});
// TODO: Test this
//profile.DirectPlayProfiles.push({
// Container: 'mov',
// Type: 'Video',
// VideoCodec: 'h264',
// AudioCodec: 'aac,mp3'
//});
}
profile.DirectPlayProfiles.push({
@ -208,7 +215,6 @@
profile.ContainerProfiles = [];
var audioConditions = [];
var videoAudioAacConditions = [];
var videoAudioMp3Conditions = [];
var maxAudioChannels = $.browser.msie || $.browser.safari ?
@ -222,7 +228,6 @@
};
audioConditions.push(channelCondition);
videoAudioAacConditions.push(channelCondition);
videoAudioMp3Conditions.push(channelCondition);
profile.CodecProfiles = [];
@ -239,22 +244,32 @@
});
}
videoAudioAacConditions.push({
Condition: 'NotEquals',
Property: 'AudioProfile',
Value: 'LC'
});
videoAudioAacConditions.push({
Condition: 'NotEquals',
Property: 'AudioProfile',
Value: 'HE-AAC'
profile.CodecProfiles.push({
Type: 'VideoAudio',
Codec: 'aac',
Container: 'mkv,mov',
Conditions: [
channelCondition,
{
Condition: 'NotEquals',
Property: 'AudioProfile',
Value: 'HE-AAC'
},
{
Condition: 'NotEquals',
Property: 'AudioProfile',
Value: 'LC'
}
]
});
profile.CodecProfiles.push({
Type: 'VideoAudio',
Codec: 'aac',
Conditions: videoAudioAacConditions
Container: 'mp4,m4v',
Conditions: [
channelCondition
]
});
profile.CodecProfiles.push({
@ -319,6 +334,18 @@
MimeType: 'video/mp4'
});
//profile.ResponseProfiles.push({
// Type: 'Video',
// Container: 'mkv',
// MimeType: 'video/webm'
//});
profile.ResponseProfiles.push({
Type: 'Video',
Container: 'mov',
MimeType: 'video/webm'
});
return profile;
};
@ -833,7 +860,10 @@
var deviceProfile = self.getDeviceProfile();
Dashboard.showLoadingMsg();
if (item.MediaType === "Video") {
Dashboard.showModalLoadingMsg();
}
getPlaybackInfo(item.Id, deviceProfile, startPosition).done(function (playbackInfoResult) {
@ -856,7 +886,7 @@
playInternalPostMediaSourceSelection(item, mediaSource, startPosition, callback);
}
} else {
Dashboard.hideLoadingMsg();
Dashboard.hideModalLoadingMsg();
showPlaybackInfoErrorMessage('NoCompatibleStream');
}
}
@ -866,7 +896,7 @@
function playInternalPostMediaSourceSelection(item, mediaSource, startPosition, callback) {
Dashboard.hideLoadingMsg();
Dashboard.hideModalLoadingMsg();
self.currentMediaSource = mediaSource;
self.currentItem = item;

View File

@ -128,12 +128,12 @@
var id = this.getAttribute('data-serverid');
if (id == 'new') {
window.location = 'connectlogin.html?mode=manualserver';
Dashboard.navigate('connectlogin.html?mode=manualserver');
return;
}
if (id == 'connect') {
window.location = 'connectlogin.html?mode=connect';
Dashboard.navigate('connectlogin.html?mode=connect');
return;
}

View File

@ -368,6 +368,10 @@ var Dashboard = {
showFooterNotification: function (options) {
if (Dashboard.isRunningInCordova()) {
return;
}
var removeOnHide = !options.id;
options.id = options.id || "notification" + new Date().getTime() + parseInt(Math.random());
@ -441,6 +445,29 @@ var Dashboard = {
$.mobile.loading("hide");
},
getModalLoadingMsg: function () {
var elem = $('.modalLoading');
if (!elem.length) {
elem = $('<div class="modalLoading"></div>').appendTo(document.body);
}
return elem;
},
showModalLoadingMsg: function () {
Dashboard.showLoadingMsg();
Dashboard.getModalLoadingMsg().show();
},
hideModalLoadingMsg: function () {
Dashboard.getModalLoadingMsg().hide();
Dashboard.hideLoadingMsg();
},
processPluginConfigurationUpdateResult: function () {
Dashboard.hideLoadingMsg();
@ -613,7 +640,7 @@ var Dashboard = {
var url = user.imageUrl;
if (user.supportsImageParams) {
url += "&width=" + (imgWidth * Math.max(devicePixelRatio || 1, 2));
url += "&width=" + (imgWidth * Math.max(window.devicePixelRatio || 1, 2));
}
html += '<img style="max-width:' + imgWidth + 'px;vertical-align:middle;margin-right:.5em;border-radius: 50px;" src="' + url + '" />';
@ -1330,7 +1357,7 @@ var Dashboard = {
quality -= 15;
}
if ($.browser.safari && $.browser.mobile) {
if (AppInfo.hasLowImageBandwidth) {
quality -= 10;
@ -1416,11 +1443,34 @@ var Dashboard = {
}
};
var AppInfo = {};
(function () {
if (!window.WebSocket) {
function isTouchDevice() {
return (('ontouchstart' in window)
|| (navigator.MaxTouchPoints > 0)
|| (navigator.msMaxTouchPoints > 0));
}
alert(Globalize.translate('MessageBrowserDoesNotSupportWebSockets'));
function setAppInfo() {
if (isTouchDevice()) {
AppInfo.isTouchPreferred = true;
}
if ($.browser.safari) {
if ($.browser.mobile) {
AppInfo.hasLowImageBandwidth = true;
}
}
else {
if (!$.browser.tv) {
AppInfo.enableHeadRoom = true;
}
}
}
function initializeApiClient(apiClient) {
@ -1487,6 +1537,12 @@ var Dashboard = {
function onReady() {
//FastClick.attach(document.body);
if (AppInfo.hasLowImageBandwidth) {
$(document.body).addClass('largeCardMargin');
}
var videoPlayerHtml = '<div id="mediaPlayer" data-theme="b" class="ui-bar-b" style="display: none;">';
videoPlayerHtml += '<div class="videoBackdrop">';
@ -1589,21 +1645,12 @@ var Dashboard = {
e.preventDefault();
return false;
});
function isTouchDevice() {
return (('ontouchstart' in window)
|| (navigator.MaxTouchPoints > 0)
|| (navigator.msMaxTouchPoints > 0));
}
if (isTouchDevice()) {
$(document.body).addClass('touch');
}
}
if (Dashboard.isRunningInCordova()) {
setAppInfo();
createConnectionManager();
createConnectionManager();
if (Dashboard.isRunningInCordova()) {
document.addEventListener("deviceready", function () {
@ -1613,8 +1660,6 @@ var Dashboard = {
} else {
createConnectionManager();
$(onReady);
}
})();
@ -1677,13 +1722,13 @@ $(document).on('pagecreate', ".page", function () {
var isConnectMode = Dashboard.isConnectMode();
if (isConnectMode) {
if (!Dashboard.isServerlessPage()) {
Dashboard.logout();
return;
}
}
if (this.id !== "loginPage" && !page.hasClass('forgotPasswordPage') && !page.hasClass('wizardPage') && !isConnectMode) {
console.log('Not logged into server. Redirecting to login.');

View File

@ -47,7 +47,7 @@
var val = store.getItem('enableThemeSongs-' + userId);
// For bandwidth
return val == '1' || (val != '0' && !$.browser.mobile);
return val == '1' || (val != '0' && MediaPlayer.canAutoPlayAudio());
}
function getPlayer() {

View File

@ -2419,7 +2419,7 @@
url += "/" + options.index;
}
options.quality = options.quality || (options.type.toLowerCase() == 'backdrop' ? 80 : 90);
options.quality = options.quality || self.getDefaultImageQuality(options.type);
// Don't put these on the query string
delete options.type;

View File

@ -1,5 +1,19 @@
(function (globalScope) {
function stringToArrayBuffer(string) {
// UTF-16LE
var buf = new ArrayBuffer(string.length * 2);
var bufView = new Uint16Array(buf);
for (var i = 0, strLen = string.length; i < strLen; i++) {
bufView[i] = string.charCodeAt(i);
}
return buf;
}
function arrayBufferToString(buf) {
return String.fromCharCode.apply(null, new Uint16Array(buf));
}
globalScope.ServerDiscovery = {
findServers: function (timeoutMs) {
@ -11,7 +25,83 @@
// Expected server properties
// Name, Id, Address, EndpointAddress (optional)
deferred.resolveWith(null, [servers]);
var chrome = globalScope.chrome;
if (!chrome) {
deferred.resolveWith(null, [servers]);
return deferred.promise();
}
var isTimedOut = false;
var socketId;
var timeout = setTimeout(function () {
isTimedOut = true;
deferred.resolveWith(null, [servers]);
if (socketId) {
chrome.sockets.udp.onReceive.removeListener(onReceive);
chrome.sockets.udp.close(socketId);
}
}, timeoutMs);
function onReceive(info) {
console.log('ServerDiscovery message received');
console.log(info);
if (info.socketId == socketId) {
var json = arrayBufferToString(info.data);
var server = JSON.parse(json);
server.RemoteAddress = info.remoteAddress;
if (info.remotePort) {
server.RemoteAddress += ':' + info.remotePort;
}
servers.push(server);
}
}
var port = 7359;
chrome.sockets.udp.create(function (createInfo) {
socketId = createInfo.socketId;
chrome.sockets.udp.bind(createInfo.socketId, '0.0.0.0', port, function (result) {
var data = stringToArrayBuffer('who is EmbyServer?');
chrome.sockets.udp.send(createInfo.socketId, data, '255.255.255.255', port, function (result) {
if (result < 0) {
console.log('send fail: ' + result);
chrome.sockets.udp.close(createInfo.socketId);
if (!isTimedOut) {
clearTimeout(timeout);
deferred.resolveWith(null, [servers]);
}
} else {
console.log('sendTo: success ' + port);
if (!isTimedOut) {
chrome.sockets.udp.onReceive.addListener(onReceive);
}
}
});
});
});
return deferred.promise();
}
};

View File

@ -1,15 +1,5 @@
(function (globalScope) {
function stringToArrayBuffer(string) {
// UTF-16LE
var buf = new ArrayBuffer(string.length * 2);
var bufView = new Uint16Array(buf);
for (var i = 0, strLen = string.length; i < strLen; i++) {
bufView[i] = string.charCodeAt(i);
}
return buf;
}
globalScope.ServerDiscovery = {
findServers: function (timeoutMs) {
@ -21,67 +11,7 @@
// Expected server properties
// Name, Id, Address, EndpointAddress (optional)
var chrome = globalScope.chrome;
if (!chrome) {
deferred.resolveWith(null, [servers]);
return deferred.promise();
}
var data = stringToArrayBuffer('who is EmbyServer?');
var isTimedOut = false;
var socketId;
var timeout = setTimeout(function () {
isTimedOut = true;
deferred.resolveWith(null, [servers]);
if (socketId) {
chrome.sockets.udp.onReceive.removeListener(onReceive);
chrome.sockets.udp.close(socketId);
}
}, timeoutMs);
function onReceive(info) {
if (info.socketId == socketId) {
//expect(info.remotePort).toBeTruthy();
//expect(info.remoteAddress).toBeTruthy();
//expect(info).toBeValidUdpReadResultEqualTo(data);
}
}
var port = 7359;
chrome.sockets.udp.create(function (createInfo) {
socketId = createInfo.socketId;
chrome.sockets.udp.bind(createInfo.socketId, '0.0.0.0', port, function (result) {
chrome.sockets.udp.send(createInfo.socketId, data, '255.255.255.255', port, function (result) {
if (result < 0) {
console.log('send fail: ' + result);
chrome.sockets.udp.close(createInfo.socketId);
if (!isTimedOut) {
clearTimeout(timeout);
deferred.resolveWith(null, [servers]);
}
} else {
console.log('sendTo: success ' + port);
if (!isTimedOut) {
chrome.sockets.udp.onReceive.addListener(onReceive);
}
}
});
});
});
deferred.resolveWith(null, [servers]);
return deferred.promise();
}
};

View File

@ -931,7 +931,8 @@
};
};
matched = jQuery.uaMatch(window.navigator.userAgent);
var userAgent = window.navigator.userAgent;
matched = jQuery.uaMatch(userAgent);
browser = {};
if (matched.browser) {
@ -950,9 +951,13 @@
browser.safari = true;
}
var md = new MobileDetect(window.navigator.userAgent);
var md = new MobileDetect(userAgent);
browser.mobile = md.mobile();
if (browser.msie && !browser.mobile && userAgent.toLowerCase().indexOf("xbox") != -1) {
browser.tv = true;
}
jQuery.browser = browser;

841
dashboard-ui/thirdparty/fastclick.js vendored Normal file
View File

@ -0,0 +1,841 @@
;(function () {
'use strict';
/**
* @preserve FastClick: polyfill to remove click delays on browsers with touch UIs.
*
* @codingstandard ftlabs-jsv2
* @copyright The Financial Times Limited [All Rights Reserved]
* @license MIT License (see LICENSE.txt)
*/
/*jslint browser:true, node:true*/
/*global define, Event, Node*/
/**
* Instantiate fast-clicking listeners on the specified layer.
*
* @constructor
* @param {Element} layer The layer to listen on
* @param {Object} [options={}] The options to override the defaults
*/
function FastClick(layer, options) {
var oldOnClick;
options = options || {};
/**
* Whether a click is currently being tracked.
*
* @type boolean
*/
this.trackingClick = false;
/**
* Timestamp for when click tracking started.
*
* @type number
*/
this.trackingClickStart = 0;
/**
* The element being tracked for a click.
*
* @type EventTarget
*/
this.targetElement = null;
/**
* X-coordinate of touch start event.
*
* @type number
*/
this.touchStartX = 0;
/**
* Y-coordinate of touch start event.
*
* @type number
*/
this.touchStartY = 0;
/**
* ID of the last touch, retrieved from Touch.identifier.
*
* @type number
*/
this.lastTouchIdentifier = 0;
/**
* Touchmove boundary, beyond which a click will be cancelled.
*
* @type number
*/
this.touchBoundary = options.touchBoundary || 10;
/**
* The FastClick layer.
*
* @type Element
*/
this.layer = layer;
/**
* The minimum time between tap(touchstart and touchend) events
*
* @type number
*/
this.tapDelay = options.tapDelay || 200;
/**
* The maximum time for a tap
*
* @type number
*/
this.tapTimeout = options.tapTimeout || 700;
if (FastClick.notNeeded(layer)) {
return;
}
// Some old versions of Android don't have Function.prototype.bind
function bind(method, context) {
return function() { return method.apply(context, arguments); };
}
var methods = ['onMouse', 'onClick', 'onTouchStart', 'onTouchMove', 'onTouchEnd', 'onTouchCancel'];
var context = this;
for (var i = 0, l = methods.length; i < l; i++) {
context[methods[i]] = bind(context[methods[i]], context);
}
// Set up event handlers as required
if (deviceIsAndroid) {
layer.addEventListener('mouseover', this.onMouse, true);
layer.addEventListener('mousedown', this.onMouse, true);
layer.addEventListener('mouseup', this.onMouse, true);
}
layer.addEventListener('click', this.onClick, true);
layer.addEventListener('touchstart', this.onTouchStart, false);
layer.addEventListener('touchmove', this.onTouchMove, false);
layer.addEventListener('touchend', this.onTouchEnd, false);
layer.addEventListener('touchcancel', this.onTouchCancel, false);
// Hack is required for browsers that don't support Event#stopImmediatePropagation (e.g. Android 2)
// which is how FastClick normally stops click events bubbling to callbacks registered on the FastClick
// layer when they are cancelled.
if (!Event.prototype.stopImmediatePropagation) {
layer.removeEventListener = function(type, callback, capture) {
var rmv = Node.prototype.removeEventListener;
if (type === 'click') {
rmv.call(layer, type, callback.hijacked || callback, capture);
} else {
rmv.call(layer, type, callback, capture);
}
};
layer.addEventListener = function(type, callback, capture) {
var adv = Node.prototype.addEventListener;
if (type === 'click') {
adv.call(layer, type, callback.hijacked || (callback.hijacked = function(event) {
if (!event.propagationStopped) {
callback(event);
}
}), capture);
} else {
adv.call(layer, type, callback, capture);
}
};
}
// If a handler is already declared in the element's onclick attribute, it will be fired before
// FastClick's onClick handler. Fix this by pulling out the user-defined handler function and
// adding it as listener.
if (typeof layer.onclick === 'function') {
// Android browser on at least 3.2 requires a new reference to the function in layer.onclick
// - the old one won't work if passed to addEventListener directly.
oldOnClick = layer.onclick;
layer.addEventListener('click', function(event) {
oldOnClick(event);
}, false);
layer.onclick = null;
}
}
/**
* Windows Phone 8.1 fakes user agent string to look like Android and iPhone.
*
* @type boolean
*/
var deviceIsWindowsPhone = navigator.userAgent.indexOf("Windows Phone") >= 0;
/**
* Android requires exceptions.
*
* @type boolean
*/
var deviceIsAndroid = navigator.userAgent.indexOf('Android') > 0 && !deviceIsWindowsPhone;
/**
* iOS requires exceptions.
*
* @type boolean
*/
var deviceIsIOS = /iP(ad|hone|od)/.test(navigator.userAgent) && !deviceIsWindowsPhone;
/**
* iOS 4 requires an exception for select elements.
*
* @type boolean
*/
var deviceIsIOS4 = deviceIsIOS && (/OS 4_\d(_\d)?/).test(navigator.userAgent);
/**
* iOS 6.0-7.* requires the target element to be manually derived
*
* @type boolean
*/
var deviceIsIOSWithBadTarget = deviceIsIOS && (/OS [6-7]_\d/).test(navigator.userAgent);
/**
* BlackBerry requires exceptions.
*
* @type boolean
*/
var deviceIsBlackBerry10 = navigator.userAgent.indexOf('BB10') > 0;
/**
* Determine whether a given element requires a native click.
*
* @param {EventTarget|Element} target Target DOM element
* @returns {boolean} Returns true if the element needs a native click
*/
FastClick.prototype.needsClick = function(target) {
switch (target.nodeName.toLowerCase()) {
// Don't send a synthetic click to disabled inputs (issue #62)
case 'button':
case 'select':
case 'textarea':
if (target.disabled) {
return true;
}
break;
case 'input':
// File inputs need real clicks on iOS 6 due to a browser bug (issue #68)
if ((deviceIsIOS && target.type === 'file') || target.disabled) {
return true;
}
break;
case 'label':
case 'iframe': // iOS8 homescreen apps can prevent events bubbling into frames
case 'video':
return true;
}
return (/\bneedsclick\b/).test(target.className);
};
/**
* Determine whether a given element requires a call to focus to simulate click into element.
*
* @param {EventTarget|Element} target Target DOM element
* @returns {boolean} Returns true if the element requires a call to focus to simulate native click.
*/
FastClick.prototype.needsFocus = function(target) {
switch (target.nodeName.toLowerCase()) {
case 'textarea':
return true;
case 'select':
return !deviceIsAndroid;
case 'input':
switch (target.type) {
case 'button':
case 'checkbox':
case 'file':
case 'image':
case 'radio':
case 'submit':
return false;
}
// No point in attempting to focus disabled inputs
return !target.disabled && !target.readOnly;
default:
return (/\bneedsfocus\b/).test(target.className);
}
};
/**
* Send a click event to the specified element.
*
* @param {EventTarget|Element} targetElement
* @param {Event} event
*/
FastClick.prototype.sendClick = function(targetElement, event) {
var clickEvent, touch;
// On some Android devices activeElement needs to be blurred otherwise the synthetic click will have no effect (#24)
if (document.activeElement && document.activeElement !== targetElement) {
document.activeElement.blur();
}
touch = event.changedTouches[0];
// Synthesise a click event, with an extra attribute so it can be tracked
clickEvent = document.createEvent('MouseEvents');
clickEvent.initMouseEvent(this.determineEventType(targetElement), true, true, window, 1, touch.screenX, touch.screenY, touch.clientX, touch.clientY, false, false, false, false, 0, null);
clickEvent.forwardedTouchEvent = true;
targetElement.dispatchEvent(clickEvent);
};
FastClick.prototype.determineEventType = function(targetElement) {
//Issue #159: Android Chrome Select Box does not open with a synthetic click event
if (deviceIsAndroid && targetElement.tagName.toLowerCase() === 'select') {
return 'mousedown';
}
return 'click';
};
/**
* @param {EventTarget|Element} targetElement
*/
FastClick.prototype.focus = function(targetElement) {
var length;
// Issue #160: on iOS 7, some input elements (e.g. date datetime month) throw a vague TypeError on setSelectionRange. These elements don't have an integer value for the selectionStart and selectionEnd properties, but unfortunately that can't be used for detection because accessing the properties also throws a TypeError. Just check the type instead. Filed as Apple bug #15122724.
if (deviceIsIOS && targetElement.setSelectionRange && targetElement.type.indexOf('date') !== 0 && targetElement.type !== 'time' && targetElement.type !== 'month') {
length = targetElement.value.length;
targetElement.setSelectionRange(length, length);
} else {
targetElement.focus();
}
};
/**
* Check whether the given target element is a child of a scrollable layer and if so, set a flag on it.
*
* @param {EventTarget|Element} targetElement
*/
FastClick.prototype.updateScrollParent = function(targetElement) {
var scrollParent, parentElement;
scrollParent = targetElement.fastClickScrollParent;
// Attempt to discover whether the target element is contained within a scrollable layer. Re-check if the
// target element was moved to another parent.
if (!scrollParent || !scrollParent.contains(targetElement)) {
parentElement = targetElement;
do {
if (parentElement.scrollHeight > parentElement.offsetHeight) {
scrollParent = parentElement;
targetElement.fastClickScrollParent = parentElement;
break;
}
parentElement = parentElement.parentElement;
} while (parentElement);
}
// Always update the scroll top tracker if possible.
if (scrollParent) {
scrollParent.fastClickLastScrollTop = scrollParent.scrollTop;
}
};
/**
* @param {EventTarget} targetElement
* @returns {Element|EventTarget}
*/
FastClick.prototype.getTargetElementFromEventTarget = function(eventTarget) {
// On some older browsers (notably Safari on iOS 4.1 - see issue #56) the event target may be a text node.
if (eventTarget.nodeType === Node.TEXT_NODE) {
return eventTarget.parentNode;
}
return eventTarget;
};
/**
* On touch start, record the position and scroll offset.
*
* @param {Event} event
* @returns {boolean}
*/
FastClick.prototype.onTouchStart = function(event) {
var targetElement, touch, selection;
// Ignore multiple touches, otherwise pinch-to-zoom is prevented if both fingers are on the FastClick element (issue #111).
if (event.targetTouches.length > 1) {
return true;
}
targetElement = this.getTargetElementFromEventTarget(event.target);
touch = event.targetTouches[0];
if (deviceIsIOS) {
// Only trusted events will deselect text on iOS (issue #49)
selection = window.getSelection();
if (selection.rangeCount && !selection.isCollapsed) {
return true;
}
if (!deviceIsIOS4) {
// Weird things happen on iOS when an alert or confirm dialog is opened from a click event callback (issue #23):
// when the user next taps anywhere else on the page, new touchstart and touchend events are dispatched
// with the same identifier as the touch event that previously triggered the click that triggered the alert.
// Sadly, there is an issue on iOS 4 that causes some normal touch events to have the same identifier as an
// immediately preceeding touch event (issue #52), so this fix is unavailable on that platform.
// Issue 120: touch.identifier is 0 when Chrome dev tools 'Emulate touch events' is set with an iOS device UA string,
// which causes all touch events to be ignored. As this block only applies to iOS, and iOS identifiers are always long,
// random integers, it's safe to to continue if the identifier is 0 here.
if (touch.identifier && touch.identifier === this.lastTouchIdentifier) {
event.preventDefault();
return false;
}
this.lastTouchIdentifier = touch.identifier;
// If the target element is a child of a scrollable layer (using -webkit-overflow-scrolling: touch) and:
// 1) the user does a fling scroll on the scrollable layer
// 2) the user stops the fling scroll with another tap
// then the event.target of the last 'touchend' event will be the element that was under the user's finger
// when the fling scroll was started, causing FastClick to send a click event to that layer - unless a check
// is made to ensure that a parent layer was not scrolled before sending a synthetic click (issue #42).
this.updateScrollParent(targetElement);
}
}
this.trackingClick = true;
this.trackingClickStart = event.timeStamp;
this.targetElement = targetElement;
this.touchStartX = touch.pageX;
this.touchStartY = touch.pageY;
// Prevent phantom clicks on fast double-tap (issue #36)
if ((event.timeStamp - this.lastClickTime) < this.tapDelay) {
event.preventDefault();
}
return true;
};
/**
* Based on a touchmove event object, check whether the touch has moved past a boundary since it started.
*
* @param {Event} event
* @returns {boolean}
*/
FastClick.prototype.touchHasMoved = function(event) {
var touch = event.changedTouches[0], boundary = this.touchBoundary;
if (Math.abs(touch.pageX - this.touchStartX) > boundary || Math.abs(touch.pageY - this.touchStartY) > boundary) {
return true;
}
return false;
};
/**
* Update the last position.
*
* @param {Event} event
* @returns {boolean}
*/
FastClick.prototype.onTouchMove = function(event) {
if (!this.trackingClick) {
return true;
}
// If the touch has moved, cancel the click tracking
if (this.targetElement !== this.getTargetElementFromEventTarget(event.target) || this.touchHasMoved(event)) {
this.trackingClick = false;
this.targetElement = null;
}
return true;
};
/**
* Attempt to find the labelled control for the given label element.
*
* @param {EventTarget|HTMLLabelElement} labelElement
* @returns {Element|null}
*/
FastClick.prototype.findControl = function(labelElement) {
// Fast path for newer browsers supporting the HTML5 control attribute
if (labelElement.control !== undefined) {
return labelElement.control;
}
// All browsers under test that support touch events also support the HTML5 htmlFor attribute
if (labelElement.htmlFor) {
return document.getElementById(labelElement.htmlFor);
}
// If no for attribute exists, attempt to retrieve the first labellable descendant element
// the list of which is defined here: http://www.w3.org/TR/html5/forms.html#category-label
return labelElement.querySelector('button, input:not([type=hidden]), keygen, meter, output, progress, select, textarea');
};
/**
* On touch end, determine whether to send a click event at once.
*
* @param {Event} event
* @returns {boolean}
*/
FastClick.prototype.onTouchEnd = function(event) {
var forElement, trackingClickStart, targetTagName, scrollParent, touch, targetElement = this.targetElement;
if (!this.trackingClick) {
return true;
}
// Prevent phantom clicks on fast double-tap (issue #36)
if ((event.timeStamp - this.lastClickTime) < this.tapDelay) {
this.cancelNextClick = true;
return true;
}
if ((event.timeStamp - this.trackingClickStart) > this.tapTimeout) {
return true;
}
// Reset to prevent wrong click cancel on input (issue #156).
this.cancelNextClick = false;
this.lastClickTime = event.timeStamp;
trackingClickStart = this.trackingClickStart;
this.trackingClick = false;
this.trackingClickStart = 0;
// On some iOS devices, the targetElement supplied with the event is invalid if the layer
// is performing a transition or scroll, and has to be re-detected manually. Note that
// for this to function correctly, it must be called *after* the event target is checked!
// See issue #57; also filed as rdar://13048589 .
if (deviceIsIOSWithBadTarget) {
touch = event.changedTouches[0];
// In certain cases arguments of elementFromPoint can be negative, so prevent setting targetElement to null
targetElement = document.elementFromPoint(touch.pageX - window.pageXOffset, touch.pageY - window.pageYOffset) || targetElement;
targetElement.fastClickScrollParent = this.targetElement.fastClickScrollParent;
}
targetTagName = targetElement.tagName.toLowerCase();
if (targetTagName === 'label') {
forElement = this.findControl(targetElement);
if (forElement) {
this.focus(targetElement);
if (deviceIsAndroid) {
return false;
}
targetElement = forElement;
}
} else if (this.needsFocus(targetElement)) {
// Case 1: If the touch started a while ago (best guess is 100ms based on tests for issue #36) then focus will be triggered anyway. Return early and unset the target element reference so that the subsequent click will be allowed through.
// Case 2: Without this exception for input elements tapped when the document is contained in an iframe, then any inputted text won't be visible even though the value attribute is updated as the user types (issue #37).
if ((event.timeStamp - trackingClickStart) > 100 || (deviceIsIOS && window.top !== window && targetTagName === 'input')) {
this.targetElement = null;
return false;
}
this.focus(targetElement);
this.sendClick(targetElement, event);
// Select elements need the event to go through on iOS 4, otherwise the selector menu won't open.
// Also this breaks opening selects when VoiceOver is active on iOS6, iOS7 (and possibly others)
if (!deviceIsIOS || targetTagName !== 'select') {
this.targetElement = null;
event.preventDefault();
}
return false;
}
if (deviceIsIOS && !deviceIsIOS4) {
// Don't send a synthetic click event if the target element is contained within a parent layer that was scrolled
// and this tap is being used to stop the scrolling (usually initiated by a fling - issue #42).
scrollParent = targetElement.fastClickScrollParent;
if (scrollParent && scrollParent.fastClickLastScrollTop !== scrollParent.scrollTop) {
return true;
}
}
// Prevent the actual click from going though - unless the target node is marked as requiring
// real clicks or if it is in the whitelist in which case only non-programmatic clicks are permitted.
if (!this.needsClick(targetElement)) {
event.preventDefault();
this.sendClick(targetElement, event);
}
return false;
};
/**
* On touch cancel, stop tracking the click.
*
* @returns {void}
*/
FastClick.prototype.onTouchCancel = function() {
this.trackingClick = false;
this.targetElement = null;
};
/**
* Determine mouse events which should be permitted.
*
* @param {Event} event
* @returns {boolean}
*/
FastClick.prototype.onMouse = function(event) {
// If a target element was never set (because a touch event was never fired) allow the event
if (!this.targetElement) {
return true;
}
if (event.forwardedTouchEvent) {
return true;
}
// Programmatically generated events targeting a specific element should be permitted
if (!event.cancelable) {
return true;
}
// Derive and check the target element to see whether the mouse event needs to be permitted;
// unless explicitly enabled, prevent non-touch click events from triggering actions,
// to prevent ghost/doubleclicks.
if (!this.needsClick(this.targetElement) || this.cancelNextClick) {
// Prevent any user-added listeners declared on FastClick element from being fired.
if (event.stopImmediatePropagation) {
event.stopImmediatePropagation();
} else {
// Part of the hack for browsers that don't support Event#stopImmediatePropagation (e.g. Android 2)
event.propagationStopped = true;
}
// Cancel the event
event.stopPropagation();
event.preventDefault();
return false;
}
// If the mouse event is permitted, return true for the action to go through.
return true;
};
/**
* On actual clicks, determine whether this is a touch-generated click, a click action occurring
* naturally after a delay after a touch (which needs to be cancelled to avoid duplication), or
* an actual click which should be permitted.
*
* @param {Event} event
* @returns {boolean}
*/
FastClick.prototype.onClick = function(event) {
var permitted;
// It's possible for another FastClick-like library delivered with third-party code to fire a click event before FastClick does (issue #44). In that case, set the click-tracking flag back to false and return early. This will cause onTouchEnd to return early.
if (this.trackingClick) {
this.targetElement = null;
this.trackingClick = false;
return true;
}
// Very odd behaviour on iOS (issue #18): if a submit element is present inside a form and the user hits enter in the iOS simulator or clicks the Go button on the pop-up OS keyboard the a kind of 'fake' click event will be triggered with the submit-type input element as the target.
if (event.target.type === 'submit' && event.detail === 0) {
return true;
}
permitted = this.onMouse(event);
// Only unset targetElement if the click is not permitted. This will ensure that the check for !targetElement in onMouse fails and the browser's click doesn't go through.
if (!permitted) {
this.targetElement = null;
}
// If clicks are permitted, return true for the action to go through.
return permitted;
};
/**
* Remove all FastClick's event listeners.
*
* @returns {void}
*/
FastClick.prototype.destroy = function() {
var layer = this.layer;
if (deviceIsAndroid) {
layer.removeEventListener('mouseover', this.onMouse, true);
layer.removeEventListener('mousedown', this.onMouse, true);
layer.removeEventListener('mouseup', this.onMouse, true);
}
layer.removeEventListener('click', this.onClick, true);
layer.removeEventListener('touchstart', this.onTouchStart, false);
layer.removeEventListener('touchmove', this.onTouchMove, false);
layer.removeEventListener('touchend', this.onTouchEnd, false);
layer.removeEventListener('touchcancel', this.onTouchCancel, false);
};
/**
* Check whether FastClick is needed.
*
* @param {Element} layer The layer to listen on
*/
FastClick.notNeeded = function(layer) {
var metaViewport;
var chromeVersion;
var blackberryVersion;
var firefoxVersion;
// Devices that don't support touch don't need FastClick
if (typeof window.ontouchstart === 'undefined') {
return true;
}
// Chrome version - zero for other browsers
chromeVersion = +(/Chrome\/([0-9]+)/.exec(navigator.userAgent) || [,0])[1];
if (chromeVersion) {
if (deviceIsAndroid) {
metaViewport = document.querySelector('meta[name=viewport]');
if (metaViewport) {
// Chrome on Android with user-scalable="no" doesn't need FastClick (issue #89)
if (metaViewport.content.indexOf('user-scalable=no') !== -1) {
return true;
}
// Chrome 32 and above with width=device-width or less don't need FastClick
if (chromeVersion > 31 && document.documentElement.scrollWidth <= window.outerWidth) {
return true;
}
}
// Chrome desktop doesn't need FastClick (issue #15)
} else {
return true;
}
}
if (deviceIsBlackBerry10) {
blackberryVersion = navigator.userAgent.match(/Version\/([0-9]*)\.([0-9]*)/);
// BlackBerry 10.3+ does not require Fastclick library.
// https://github.com/ftlabs/fastclick/issues/251
if (blackberryVersion[1] >= 10 && blackberryVersion[2] >= 3) {
metaViewport = document.querySelector('meta[name=viewport]');
if (metaViewport) {
// user-scalable=no eliminates click delay.
if (metaViewport.content.indexOf('user-scalable=no') !== -1) {
return true;
}
// width=device-width (or less than device-width) eliminates click delay.
if (document.documentElement.scrollWidth <= window.outerWidth) {
return true;
}
}
}
}
// IE10 with -ms-touch-action: none or manipulation, which disables double-tap-to-zoom (issue #97)
if (layer.style.msTouchAction === 'none' || layer.style.touchAction === 'manipulation') {
return true;
}
// Firefox version - zero for other browsers
firefoxVersion = +(/Firefox\/([0-9]+)/.exec(navigator.userAgent) || [,0])[1];
if (firefoxVersion >= 27) {
// Firefox 27+ does not have tap delay if the content is not zoomable - https://bugzilla.mozilla.org/show_bug.cgi?id=922896
metaViewport = document.querySelector('meta[name=viewport]');
if (metaViewport && (metaViewport.content.indexOf('user-scalable=no') !== -1 || document.documentElement.scrollWidth <= window.outerWidth)) {
return true;
}
}
// IE11: prefixed -ms-touch-action is no longer supported and it's recomended to use non-prefixed version
// http://msdn.microsoft.com/en-us/library/windows/apps/Hh767313.aspx
if (layer.style.touchAction === 'none' || layer.style.touchAction === 'manipulation') {
return true;
}
return false;
};
/**
* Factory method for creating a FastClick object
*
* @param {Element} layer The layer to listen on
* @param {Object} [options={}] The options to override the defaults
*/
FastClick.attach = function(layer, options) {
return new FastClick(layer, options);
};
if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {
// AMD. Register as an anonymous module.
define(function() {
return FastClick;
});
} else if (typeof module !== 'undefined' && module.exports) {
module.exports = FastClick.attach;
module.exports.FastClick = FastClick;
} else {
window.FastClick = FastClick;
}
}());

View File

@ -14,23 +14,21 @@
var $w = $(window),
th = threshold || 0,
retina = window.devicePixelRatio > 1,
attrib = retina ? "data-src-retina" : "data-src",
attrib = "data-src",
images = this,
loaded;
this.one("unveil", function () {
var elemType = $(this).get(0).tagName;
var elemType = this.tagName;
var source = this.getAttribute(attrib);
source = source || this.getAttribute("data-src");
if (source) {
if (elemType === "DIV") {
this.style.backgroundImage = "url('" + source + "')";
} else {
this.setAttribute("src", source);
}
this.setAttribute("data-src", '');
if (typeof callback === "function") callback.call(this);
}
});
@ -62,7 +60,7 @@
$.fn.lazyChildren = function () {
$(".lazy", this).unveil(300);
$(".lazy", this).unveil(150);
return this;
};