make backdrops optional

This commit is contained in:
Luke Pulverenti 2014-05-21 14:38:12 -04:00
parent 0a7b7a14e3
commit 2c7636b291
7 changed files with 173 additions and 25 deletions

View File

@ -493,7 +493,7 @@ a.itemTag:hover {
.detailSectionHeader {
background-clip: border-box;
background-color: rgb(51, 51, 51);
background-color: rgb(20, 20, 20);
border-bottom-color: rgb(31, 31, 31);
border-bottom-style: solid;
border-bottom-width: 1px;

View File

@ -12,6 +12,56 @@
<a href="#" class="ui-btn-active lnkWebClientPreferences">${TabWebClient}</a>
</div>
<br />
<br />
<form class="webClientPreferencesForm" style="margin: 0 auto;">
<div class="detailSectionHeader" style="margin: 0 .5em;">
${HeaderAllDevices}
</div>
<br />
<div class="detailSectionHeader" style="margin: 0 .5em;">
${HeaderThisDevice}
</div>
<br />
<ul data-role="listview" class="ulForm">
<li>
<label for="selectThemeSong">${LabelEnableThemeSongs}</label>
<select id="selectThemeSong" data-mini="true">
<option value="">${OptionAuto}</option>
<option value="1">${OptionYes}</option>
<option value="0">${OptionNo}</option>
</select>
<div class="fieldDescription">${LabelEnableThemeSongsHelp}</div>
</li>
<li>
<label for="selectBackdrop">${LabelEnableBackdrops}</label>
<select id="selectBackdrop" data-mini="true">
<option value="">${OptionAuto}</option>
<option value="1">${OptionYes}</option>
<option value="0">${OptionNo}</option>
</select>
<div class="fieldDescription">${LabelEnableBackdropsHelp}</div>
</li>
</ul>
<ul data-role="listview" class="ulForm">
<li>
<button type="submit" data-theme="a" data-icon="check" data-mini="true">
${ButtonOk}
</button>
<button type="button" onclick="history.back();" data-icon="delete" data-mini="true">
${ButtonCancel}
</button>
</li>
</ul>
</form>
<script type="text/javascript">
$('.webClientPreferencesForm').off('submit', WebClientPreferencesPage.onSubmit).on('submit', WebClientPreferencesPage.onSubmit);
</script>
</div>
</body>
</html>

View File

@ -87,18 +87,32 @@
$('.backdropContainer').css('backgroundImage', '');
}
$(document).on('pagebeforeshow', ".backdropPage", function () {
var page = this;
function enabled() {
// Gets real messy and jumps around the page when scrolling
// Can be reviewed later.
if ($.browser.msie) {
$(page).removeClass('backdropPage');
} else {
return false;
}
var userId = Dashboard.getCurrentUserId();
var val = LocalSettings.val('enableBackdrops', userId);
return val != '0';
}
$(document).on('pagebeforeshow', ".backdropPage", function () {
var page = this;
if (enabled()) {
var type = page.getAttribute('data-backdroptype');
showBackdrop(type);
} else {
$(page).removeClass('backdropPage');
clearBackdrop();
}
});

View File

@ -0,0 +1,30 @@
(function ($, window, document) {
function get(key, userId) {
return localStorage.getItem(key + '-' + userId);
}
function set(key, userId, value) {
localStorage.setItem(key + '-' + userId, value);
}
function localSettings() {
var self = this;
self.val = function (key, userId, value) {
if (arguments.length < 3) {
return get(key, userId);
}
set(key, userId, value);
};
}
window.LocalSettings = new localSettings();
})(jQuery, window, document);

View File

@ -69,6 +69,12 @@
var page = this;
$('#selectSubtitlePlaybackMode', page).on('change', function () {
$('.subtitlesHelp', page).hide();
$('.subtitles' + this.value + 'Help', page).show();
});
}).on('pageshow', "#languagePreferencesPage", function () {
var page = this;

View File

@ -1 +1,64 @@

(function ($, window, document) {
function loadForm(page, user) {
$('#selectThemeSong', page).val(LocalSettings.val('enableThemeSongs', user.Id) || '').selectmenu("refresh");
$('#selectBackdrop', page).val(LocalSettings.val('enableBackdrops', user.Id) || '').selectmenu("refresh");
Dashboard.hideLoadingMsg();
}
function saveUser(page, user) {
LocalSettings.val('enableThemeSongs', user.Id, $('#selectThemeSong', page).val());
LocalSettings.val('enableBackdrops', user.Id, $('#selectBackdrop', page).val());
//ApiClient.updateUser(user).done(function () {
//Dashboard.alert(Globalize.translate("SettingsSaved"));
//});
Dashboard.alert(Globalize.translate("SettingsSaved"));
}
function onSubmit() {
var page = $(this).parents('.page');
Dashboard.showLoadingMsg();
var userId = getParameterByName('userId') || Dashboard.getCurrentUserId();
ApiClient.getUser(userId).done(function (result) {
saveUser(page, result);
});
// Disable default form submission
return false;
}
$(document).on('pageinit', "#webClientPreferencesPage", function () {
var page = this;
}).on('pagebeforeshow', "#webClientPreferencesPage", function () {
var page = this;
Dashboard.showLoadingMsg();
var userId = getParameterByName('userId') || Dashboard.getCurrentUserId();
ApiClient.getUser(userId).done(function (user) {
loadForm(page, user);
});
});
window.WebClientPreferencesPage = {
onSubmit: onSubmit
};
})(jQuery, window, document);

View File

@ -40,20 +40,11 @@
}
}
function enabled(isEnabled) {
function enabled() {
var userId = Dashboard.getCurrentUserId();
var val = LocalSettings.val('enableThemeSongs', userId);
var key = userId + '-themesongs';
if (isEnabled == null) {
return localStorage.getItem(key) == '1';
}
var val = isEnabled ? '1' : '0';
localStorage.setItem(key, val);
return val == '1';
}
function getPlayer() {
@ -73,10 +64,4 @@
}
});
window.ThemeSongManager = {
enabled: function (isEnabled) {
return enabled(isEnabled);
}
};
})(document, jQuery, window.localStorage);