lazy load scripts

This commit is contained in:
Luke Pulverenti 2015-05-18 21:46:31 -04:00
parent ca3ad030a0
commit 463ad6cfb1
13 changed files with 101 additions and 91 deletions

View File

@ -4,7 +4,7 @@
<title>${TitlePlugins}</title>
</head>
<body>
<div id="addPluginPage" data-role="page" class="page type-interior pluginConfigurationPage" data-helpurl="https://github.com/MediaBrowser/Wiki/wiki/Plugins" data-require="scripts/registrationservices">
<div id="addPluginPage" data-role="page" class="page type-interior pluginConfigurationPage" data-helpurl="https://github.com/MediaBrowser/Wiki/wiki/Plugins" data-require="scripts/registrationservices,scripts/ratingdialog">
<div data-role="content">
<div class="content-primary">

View File

@ -4,7 +4,7 @@
<title>Emby</title>
</head>
<body>
<div id="editItemImagesPage" data-role="page" class="page libraryPage metadataEditorPage" data-contextname="${HeaderMetadataManager}">
<div id="editItemImagesPage" data-role="page" class="page libraryPage metadataEditorPage" data-contextname="${HeaderMetadataManager}" data-require="scripts/edititemimages">
<div data-role="content editPageContent">
<div class="editPageSidebar">
<div class="libraryTree">
@ -60,7 +60,7 @@
</div>
<div data-role="popup" id="popupUpload" data-theme="a">
<form id="uploadItemImageForm" style="max-width: 100%; margin: 0 1.5em 1.5em;">
<form class="uploadItemImageForm" style="max-width: 100%; margin: 0 1.5em 1.5em;">
<h2>${HeaderAddUpdateImage}</h2>
<div>
<p>${LabelJpgPngOnly}</p>
@ -146,10 +146,6 @@
</div>
</div>
<script type="text/javascript">
$('#uploadItemImageForm').on('submit', EditItemImagesPage.onSubmit);
</script>
</div>
</body>
</html>

View File

@ -4,7 +4,7 @@
<title>${TitlePlugins}</title>
</head>
<body>
<div id="pluginCatalogPage" data-role="page" class="page type-interior pluginConfigurationPage" data-helpurl="https://github.com/MediaBrowser/Wiki/wiki/Plugins">
<div id="pluginCatalogPage" data-role="page" class="page type-interior pluginConfigurationPage" data-helpurl="https://github.com/MediaBrowser/Wiki/wiki/Plugins" data-require="scripts/ratingdialog">
<div data-role="content">
<div class="content-primary">
<div data-role="controlgroup" data-type="horizontal" data-mini="true">

View File

@ -440,39 +440,38 @@
reload(page);
}
function onSubmit() {
var file = currentFile;
if (!file) {
return false;
}
if (file.type != "image/png" && file.type != "image/jpeg" && file.type != "image/jpeg") {
return false;
}
Dashboard.showLoadingMsg();
var page = $.mobile.activePage;
var imageType = $('#selectImageType', page).val();
ApiClient.uploadItemImage(currentItem.Id, imageType, file).done(function () {
$('#uploadImage', page).val('').trigger('change');
$('#popupUpload', page).popup("close");
processImageChangeResult(page);
});
return false;
}
function editItemImages() {
var self = this;
self.onSubmit = function () {
var file = currentFile;
if (!file) {
return false;
}
if (file.type != "image/png" && file.type != "image/jpeg" && file.type != "image/jpeg") {
return false;
}
Dashboard.showLoadingMsg();
var page = $.mobile.activePage;
var imageType = $('#selectImageType', page).val();
ApiClient.uploadItemImage(currentItem.Id, imageType, file).done(function () {
$('#uploadImage', page).val('').trigger('change');
$('#popupUpload', page).popup("close");
processImageChangeResult(page);
});
return false;
};
self.deleteImage = function (type, index) {
var page = $.mobile.activePage;
@ -515,7 +514,7 @@
window.EditItemImagesPage = new editItemImages();
$(document).on('pageinit', "#editItemImagesPage", function () {
$(document).on('pageinitdepends', "#editItemImagesPage", function () {
var page = this;
@ -567,7 +566,10 @@
reloadBrowsableImages(page);
});
}).on('pagebeforeshow', "#editItemImagesPage", function () {
$('.uploadItemImageForm').off('submit', onSubmit).on('submit', onSubmit);
}).on('pageshown', "#editItemImagesPage", function () {
var page = this;

View File

@ -595,9 +595,14 @@
requiresLibraryMenuRefresh = true;
initializeApiClient(apiClient);
}).on('localusersignedin localusersignedout', function () {
}).on('localusersignedin', function () {
requiresLibraryMenuRefresh = true;
}).on('localusersignedout', function () {
$('.viewMenuBar').remove();
requiresLibraryMenuRefresh = true;
});
$(function () {

View File

@ -1083,6 +1083,11 @@
return s.Type == 'Subtitle';
});
// Reports of stuttering with h264 stream copy in IE
if (streamInfo.playMethod == 'Transcode' && videoUrl.indexOf('.m3u8') == -1) {
videoUrl += 'EnableAutoStreamCopy=false';
}
var posterCode = self.getPosterUrl(item);
posterCode = posterCode ? (' poster="' + posterCode + '"') : '';
//======================================================================================>

View File

@ -771,6 +771,7 @@
var startPositionInSeekParam = startPosition ? (startPosition / 10000000) : 0;
var seekParam = startPositionInSeekParam ? '#t=' + startPositionInSeekParam : '';
var playMethod = 'Transcode';
if (type == 'Video') {
@ -778,6 +779,7 @@
if (mediaSource.enableDirectPlay) {
mediaUrl = mediaSource.Path;
playMethod = 'DirectPlay';
} else {
if (mediaSource.SupportsDirectStream) {
@ -789,6 +791,7 @@
});
mediaUrl += seekParam;
playMethod = 'DirectStream';
} else {
startTimeTicksOffset = startPosition || 0;
@ -813,6 +816,7 @@
mediaUrl = mediaSource.Path;
playMethod = 'DirectPlay';
} else {
var isDirectStream = mediaSource.SupportsDirectStream;
@ -827,6 +831,8 @@
api_key: ApiClient.accessToken()
});
mediaUrl += "&static=true" + seekParam;
playMethod = 'DirectStream';
} else {
contentType = 'audio/' + mediaSource.TranscodingContainer;
@ -842,7 +848,8 @@
url: mediaUrl,
contentType: contentType,
startTimeTicksOffset: startTimeTicksOffset,
startPositionInSeekParam: startPositionInSeekParam
startPositionInSeekParam: startPositionInSeekParam,
playMethod: playMethod
};
};

View File

@ -208,11 +208,16 @@ var Dashboard = {
function onLogoutDone() {
var loginPage = !Dashboard.isConnectMode() ?
'login.html' :
'connectlogin.html';
var loginPage = 'login.html';
window.location.href = loginPage;
if (Dashboard.isConnectMode()) {
loginPage = 'connectlogin.html';
window.ApiClient = null;
} else {
}
Dashboard.navigate(loginPage);
}
if (logoutWithServer === false) {
@ -1511,7 +1516,7 @@ var AppInfo = {};
function setAppInfo() {
if (isTouchDevice()) {
if (isTouchDevice() && $.browser.mobile) {
AppInfo.isTouchPreferred = true;
}

View File

@ -72,24 +72,23 @@
});
}
$(document).on('pageshow', "#wizardSettingsPage", function () {
function onSubmit() {
var form = this;
save(form);
return false;
}
$(document).on('pageinitdepends', "#wizardSettingsPage", function () {
$('.wizardSettingsForm', page).off('submit', onSubmit).on('submit', onSubmit);
}).on('pageshown', "#wizardSettingsPage", function () {
var page = this;
reload(page);
});
window.WizardSettingsPage = {
onSubmit: function () {
var form = this;
save(form);
return false;
}
};
})(jQuery, document, window);

View File

@ -48,21 +48,19 @@
}).done(onUpdateUserComplete);
}
function wizardUserPage() {
function onSubmit() {
var form = this;
var self = this;
submit(form);
self.onSubmit = function () {
var form = this;
submit(form);
return false;
};
return false;
}
$(document).on('pageshow', "#wizardUserPage", function () {
$(document).on('pageinitdepends', "#wizardUserPage", function () {
$('.wizardUserForm').off('submit', onSubmit).on('submit', onSubmit);
}).on('pageshown', "#wizardUserPage", function () {
Dashboard.showLoadingMsg();
@ -80,6 +78,4 @@
});
window.WizardUserPage = new wizardUserPage();
})(jQuery, document, window);

View File

@ -166,13 +166,13 @@
self.unpause = function () {
sendMessageToDevice({
command: 'unpause'
command: 'Unpause'
});
};
self.pause = function () {
sendMessageToDevice({
command: 'pause'
command: 'Pause'
});
};
@ -222,7 +222,7 @@
self.stop = function () {
sendMessageToDevice({
command: 'stop'
command: 'Stop'
});
};
@ -236,7 +236,7 @@
self.mute = function () {
sendMessageToDevice({
command: 'mute'
command: 'Mute'
});
};
@ -383,7 +383,7 @@
sendMessageToDevice({
options: {
volume: (vol / 100)
volume: vol
},
command: 'SetVolume'
});

View File

@ -4,14 +4,15 @@
<title>Emby</title>
</head>
<body>
<div id="wizardSettingsPage" data-role="page" class="page standalonePage wizardPage mediaLibraryPage">
<div id="wizardSettingsPage" data-role="page" class="page standalonePage wizardPage mediaLibraryPage" data-require="scripts/wizardsettings">
<div data-role="content">
<div class="ui-corner-all ui-shadow wizardContent">
<form class="wizardSettingsForm">
<h2>
<img src="css/images/mblogoicon.png" />${LabelConfigureSettings}</h2>
<img src="css/images/mblogoicon.png" />${LabelConfigureSettings}
</h2>
<br />
<div style="margin: 1em 0;">
@ -45,9 +46,6 @@
</div>
</div>
<script type="text/javascript">
$('.wizardSettingsForm').off('submit', WizardSettingsPage.onSubmit).on('submit', WizardSettingsPage.onSubmit);
</script>
</div>
</body>
</html>

View File

@ -4,14 +4,15 @@
<title>Emby</title>
</head>
<body>
<div id="wizardUserPage" data-role="page" class="page standalonePage wizardPage">
<div id="wizardUserPage" data-role="page" class="page standalonePage wizardPage" data-require="scripts/wizarduserpage">
<div data-role="content">
<div class="ui-corner-all ui-shadow wizardContent">
<form id="wizardUserForm">
<form class="wizardUserForm">
<h2>
<img src="css/images/mblogoicon.png" style="height: 30px;" />${TellUsAboutYourself}</h2>
<img src="css/images/mblogoicon.png" style="height: 30px;" />${TellUsAboutYourself}
</h2>
<p>${UserProfilesIntro}</p>
@ -23,7 +24,7 @@
</li>
</ul>
<h2>${HeaderOptionalLinkEmbyAccount}</h2>
<br/>
<br />
<ul data-role="listview" class="ulForm">
<li>
<label for="txtConnectUserName">${LabelConnectUserName}</label>
@ -43,10 +44,6 @@
</div>
</div>
<script type="text/javascript">
$('#wizardUserForm').on('submit', WizardUserPage.onSubmit);
</script>
</div>
</body>
</html>