diff --git a/public_html/js/BrowsingSettings.js b/public_html/js/BrowsingSettings.js index 142958d8..4f1f3fd4 100644 --- a/public_html/js/BrowsingSettings.js +++ b/public_html/js/BrowsingSettings.js @@ -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); diff --git a/public_html/js/Presenters/PostContentPresenter.js b/public_html/js/Presenters/PostContentPresenter.js index d5e0b15c..30a9a8e3 100644 --- a/public_html/js/Presenters/PostContentPresenter.js +++ b/public_html/js/Presenters/PostContentPresenter.js @@ -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); diff --git a/public_html/js/Presenters/UserBrowsingSettingsPresenter.js b/public_html/js/Presenters/UserBrowsingSettingsPresenter.js index 43bea35e..db129e21 100644 --- a/public_html/js/Presenters/UserBrowsingSettingsPresenter.js +++ b/public_html/js/Presenters/UserBrowsingSettingsPresenter.js @@ -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)) diff --git a/public_html/templates/browsing-settings.tpl b/public_html/templates/browsing-settings.tpl index 20b029e1..fc51a058 100644 --- a/public_html/templates/browsing-settings.tpl +++ b/public_html/templates/browsing-settings.tpl @@ -51,6 +51,26 @@ +
+ +
+ type="radio" id="browsing-settings-fit-width" name="fitMode" value="fit-width"/> + + + type="radio" id="browsing-settings-fit-height" name="fitMode" value="fit-height"/> + + + type="radio" id="browsing-settings-fit-original" name="fitMode" value="original"/> + +
+
+
@@ -58,5 +78,3 @@
- - diff --git a/src/Upgrades/Upgrade37.php b/src/Upgrades/Upgrade37.php index 463c1e55..da6d8172 100644 --- a/src/Upgrades/Upgrade37.php +++ b/src/Upgrades/Upgrade37.php @@ -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; diff --git a/src/Upgrades/Upgrade40.php b/src/Upgrades/Upgrade40.php new file mode 100644 index 00000000..a834becb --- /dev/null +++ b/src/Upgrades/Upgrade40.php @@ -0,0 +1,27 @@ +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); + } + } +} diff --git a/src/di.php b/src/di.php index c9f00a6a..c6068023 100644 --- a/src/di.php +++ b/src/di.php @@ -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), ]; }),