Added fit mode to browsing settings

This commit is contained in:
rr- 2015-07-19 11:53:34 +02:00
parent 5882998c20
commit 5ad854e38a
7 changed files with 55 additions and 7 deletions

View file

@ -33,6 +33,7 @@ App.BrowsingSettings = function(
unsafe: true,
},
keyboardShortcuts: true,
fitMode: 'fit-width',
};
}
@ -91,7 +92,6 @@ App.BrowsingSettings = function(
getSettings: getSettings,
setSettings: setSettings,
};
};
App.DI.registerSingleton('browsingSettings', ['promise', 'auth', 'api'], App.BrowsingSettings);

View file

@ -7,7 +7,8 @@ App.Presenters.PostContentPresenter = function(
promise,
keyboard,
presenterManager,
postNotesPresenter) {
postNotesPresenter,
browsingSettings) {
var post;
var templates = {};
@ -72,7 +73,7 @@ App.Presenters.PostContentPresenter = function(
updatePostNotesSize();
}
changeFitMode('fit-width');
changeFitMode(browsingSettings.getSettings().fitMode);
keyboard.keyup('f', cycleFitMode);
jQuery(window).resize(updatePostNotesSize);
@ -114,5 +115,6 @@ App.DI.register('postContentPresenter', [
'promise',
'keyboard',
'presenterManager',
'postNotesPresenter'],
'postNotesPresenter',
'browsingSettings'],
App.Presenters.PostContentPresenter);

View file

@ -52,6 +52,7 @@ App.Presenters.UserBrowsingSettingsPresenter = function(
unsafe: $el.find('[name=listUnsafePosts]').is(':checked'),
},
keyboardShortcuts: $el.find('[name=keyboardShortcuts]').is(':checked'),
fitMode: $el.find('[name=fitMode]:checked').val(),
};
promise.wait(browsingSettings.setSettings(newSettings))

View file

@ -51,6 +51,26 @@
</div>
</div>
<div class="form-row">
<label class="form-label">Default fit mode:</label>
<div class="form-input">
<input <% print(settings.fitMode === 'fit-width' ? 'checked="checked"' : '') %> type="radio" id="browsing-settings-fit-width" name="fitMode" value="fit-width"/>
<label for="browsing-settings-fit-width">
Fit width
</label>
<input <% print(settings.fitMode === 'fit-height' ? 'checked="checked"' : '') %> type="radio" id="browsing-settings-fit-height" name="fitMode" value="fit-height"/>
<label for="browsing-settings-fit-height">
Fit height
</label>
<input <% print(settings.fitMode === 'original' ? 'checked="checked"' : '') %> type="radio" id="browsing-settings-fit-original" name="fitMode" value="original"/>
<label for="browsing-settings-fit-original">
Original
</label>
</div>
</div>
<div class="form-row">
<label class="form-label"></label>
<div class="form-input">
@ -58,5 +78,3 @@
</div>
</div>
</form>

View file

@ -16,7 +16,6 @@ class Upgrade37 implements IUpgrade
{
foreach ($this->userDao->findAll() as $user)
{
echo $user->getName() . PHP_EOL;
$browsingSettings = $user->getBrowsingSettings();
if ($browsingSettings === null)
$browsingSettings = new \StdClass;

View file

@ -0,0 +1,27 @@
<?php
namespace Szurubooru\Upgrades;
use Szurubooru\Dao\UserDao;
use Szurubooru\DatabaseConnection;
class Upgrade40 implements IUpgrade
{
private $userDao;
public function __construct(UserDao $userDao)
{
$this->userDao = $userDao;
}
public function run(DatabaseConnection $databaseConnection)
{
foreach ($this->userDao->findAll() as $user)
{
$browsingSettings = $user->getBrowsingSettings();
if ($browsingSettings === null)
$browsingSettings = new \StdClass;
$browsingSettings->fitMode = 'fit-width';
$user->setBrowsingSettings($browsingSettings);
$this->userDao->save($user);
}
}
}

View file

@ -56,6 +56,7 @@ return [
$container->get(\Szurubooru\Upgrades\Upgrade37::class),
$container->get(\Szurubooru\Upgrades\Upgrade38::class),
$container->get(\Szurubooru\Upgrades\Upgrade39::class),
$container->get(\Szurubooru\Upgrades\Upgrade40::class),
];
}),