reader.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. //занчение toolButtons.name не должно совпадать с settingDefaults-propertyName
  2. const toolButtons = [
  3. {name: 'undoAction', show: true, text: 'Действие назад'},
  4. {name: 'redoAction', show: true, text: 'Действие вперед'},
  5. {name: 'fullScreen', show: true, text: 'На весь экран'},
  6. {name: 'scrolling', show: false, text: 'Плавный скроллинг'},
  7. {name: 'setPosition', show: true, text: 'На страницу'},
  8. {name: 'search', show: true, text: 'Найти в тексте'},
  9. {name: 'copyText', show: false, text: 'Скопировать текст со страницы'},
  10. {name: 'refresh', show: true, text: 'Принудительно обновить книгу'},
  11. {name: 'recentBooks', show: true, text: 'Открыть недавние'},
  12. ];
  13. const fonts = [
  14. {name: 'ReaderDefault', label: 'По-умолчанию', fontVertShift: 0},
  15. {name: 'GEO_1', label: 'BPG Arial', fontVertShift: 10},
  16. {name: 'Arimo', fontVertShift: 0},
  17. {name: 'Avrile', fontVertShift: -10},
  18. {name: 'OpenSans', fontVertShift: -5},
  19. {name: 'Roboto', fontVertShift: 0},
  20. {name: 'Rubik', fontVertShift: 0},
  21. ];
  22. const webFonts = [
  23. {css: 'https://fonts.googleapis.com/css?family=Alegreya', name: 'Alegreya', fontVertShift: -5},
  24. {css: 'https://fonts.googleapis.com/css?family=Alegreya+Sans', name: 'Alegreya Sans', fontVertShift: 5},
  25. {css: 'https://fonts.googleapis.com/css?family=Alegreya+SC', name: 'Alegreya SC', fontVertShift: -5},
  26. {css: 'https://fonts.googleapis.com/css?family=Alice', name: 'Alice', fontVertShift: 5},
  27. {css: 'https://fonts.googleapis.com/css?family=Amatic+SC', name: 'Amatic SC', fontVertShift: 0},
  28. {css: 'https://fonts.googleapis.com/css?family=Andika', name: 'Andika', fontVertShift: -35},
  29. {css: 'https://fonts.googleapis.com/css?family=Anonymous+Pro', name: 'Anonymous Pro', fontVertShift: 5},
  30. {css: 'https://fonts.googleapis.com/css?family=Arsenal', name: 'Arsenal', fontVertShift: 0},
  31. {css: 'https://fonts.googleapis.com/css?family=Bad+Script', name: 'Bad Script', fontVertShift: -30},
  32. {css: 'https://fonts.googleapis.com/css?family=Caveat', name: 'Caveat', fontVertShift: -5},
  33. {css: 'https://fonts.googleapis.com/css?family=Comfortaa', name: 'Comfortaa', fontVertShift: 10},
  34. {css: 'https://fonts.googleapis.com/css?family=Cormorant', name: 'Cormorant', fontVertShift: 0},
  35. {css: 'https://fonts.googleapis.com/css?family=Cormorant+Garamond', name: 'Cormorant Garamond', fontVertShift: 0},
  36. {css: 'https://fonts.googleapis.com/css?family=Cormorant+Infant', name: 'Cormorant Infant', fontVertShift: 5},
  37. {css: 'https://fonts.googleapis.com/css?family=Cormorant+Unicase', name: 'Cormorant Unicase', fontVertShift: 0},
  38. {css: 'https://fonts.googleapis.com/css?family=Cousine', name: 'Cousine', fontVertShift: 0},
  39. {css: 'https://fonts.googleapis.com/css?family=Cuprum', name: 'Cuprum', fontVertShift: 5},
  40. {css: 'https://fonts.googleapis.com/css?family=Didact+Gothic', name: 'Didact Gothic', fontVertShift: -10},
  41. {css: 'https://fonts.googleapis.com/css?family=EB+Garamond', name: 'EB Garamond', fontVertShift: -5},
  42. {css: 'https://fonts.googleapis.com/css?family=El+Messiri', name: 'El Messiri', fontVertShift: -5},
  43. {css: 'https://fonts.googleapis.com/css?family=Fira+Mono', name: 'Fira Mono', fontVertShift: 5},
  44. {css: 'https://fonts.googleapis.com/css?family=Fira+Sans', name: 'Fira Sans', fontVertShift: 5},
  45. {css: 'https://fonts.googleapis.com/css?family=Fira+Sans+Condensed', name: 'Fira Sans Condensed', fontVertShift: 5},
  46. {css: 'https://fonts.googleapis.com/css?family=Fira+Sans+Extra+Condensed', name: 'Fira Sans Extra Condensed', fontVertShift: 5},
  47. {css: 'https://fonts.googleapis.com/css?family=Forum', name: 'Forum', fontVertShift: 5},
  48. {css: 'https://fonts.googleapis.com/css?family=Gabriela', name: 'Gabriela', fontVertShift: 5},
  49. {css: 'https://fonts.googleapis.com/css?family=IBM+Plex+Mono', name: 'IBM Plex Mono', fontVertShift: -5},
  50. {css: 'https://fonts.googleapis.com/css?family=IBM+Plex+Sans', name: 'IBM Plex Sans', fontVertShift: -5},
  51. {css: 'https://fonts.googleapis.com/css?family=IBM+Plex+Serif', name: 'IBM Plex Serif', fontVertShift: -5},
  52. {css: 'https://fonts.googleapis.com/css?family=Istok+Web', name: 'Istok Web', fontVertShift: -5},
  53. {css: 'https://fonts.googleapis.com/css?family=Jura', name: 'Jura', fontVertShift: 0},
  54. {css: 'https://fonts.googleapis.com/css?family=Kelly+Slab', name: 'Kelly Slab', fontVertShift: 0},
  55. {css: 'https://fonts.googleapis.com/css?family=Kosugi', name: 'Kosugi', fontVertShift: 5},
  56. {css: 'https://fonts.googleapis.com/css?family=Kosugi+Maru', name: 'Kosugi Maru', fontVertShift: 10},
  57. {css: 'https://fonts.googleapis.com/css?family=Kurale', name: 'Kurale', fontVertShift: -15},
  58. {css: 'https://fonts.googleapis.com/css?family=Ledger', name: 'Ledger', fontVertShift: -5},
  59. {css: 'https://fonts.googleapis.com/css?family=Lobster', name: 'Lobster', fontVertShift: 0},
  60. {css: 'https://fonts.googleapis.com/css?family=Lora', name: 'Lora', fontVertShift: 0},
  61. {css: 'https://fonts.googleapis.com/css?family=Marck+Script', name: 'Marck Script', fontVertShift: 0},
  62. {css: 'https://fonts.googleapis.com/css?family=Marmelad', name: 'Marmelad', fontVertShift: 0},
  63. {css: 'https://fonts.googleapis.com/css?family=Merriweather', name: 'Merriweather', fontVertShift: 0},
  64. {css: 'https://fonts.googleapis.com/css?family=Montserrat', name: 'Montserrat', fontVertShift: 0},
  65. {css: 'https://fonts.googleapis.com/css?family=Montserrat+Alternates', name: 'Montserrat Alternates', fontVertShift: 0},
  66. {css: 'https://fonts.googleapis.com/css?family=Neucha', name: 'Neucha', fontVertShift: 0},
  67. {css: 'https://fonts.googleapis.com/css?family=Noto+Sans', name: 'Noto Sans', fontVertShift: -10},
  68. {css: 'https://fonts.googleapis.com/css?family=Noto+Sans+SC', name: 'Noto Sans SC', fontVertShift: -15},
  69. {css: 'https://fonts.googleapis.com/css?family=Noto+Serif', name: 'Noto Serif', fontVertShift: -10},
  70. {css: 'https://fonts.googleapis.com/css?family=Noto+Serif+TC', name: 'Noto Serif TC', fontVertShift: -15},
  71. {css: 'https://fonts.googleapis.com/css?family=Old+Standard+TT', name: 'Old Standard TT', fontVertShift: 15},
  72. {css: 'https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300', name: 'Open Sans Condensed', fontVertShift: -5},
  73. {css: 'https://fonts.googleapis.com/css?family=Oranienbaum', name: 'Oranienbaum', fontVertShift: 5},
  74. {css: 'https://fonts.googleapis.com/css?family=Oswald', name: 'Oswald', fontVertShift: -20},
  75. {css: 'https://fonts.googleapis.com/css?family=Pacifico', name: 'Pacifico', fontVertShift: -35},
  76. {css: 'https://fonts.googleapis.com/css?family=Pangolin', name: 'Pangolin', fontVertShift: 5},
  77. {css: 'https://fonts.googleapis.com/css?family=Pattaya', name: 'Pattaya', fontVertShift: 0},
  78. {css: 'https://fonts.googleapis.com/css?family=Philosopher', name: 'Philosopher', fontVertShift: 5},
  79. {css: 'https://fonts.googleapis.com/css?family=Play', name: 'Play', fontVertShift: 5},
  80. {css: 'https://fonts.googleapis.com/css?family=Playfair+Display', name: 'Playfair Display', fontVertShift: -5},
  81. {css: 'https://fonts.googleapis.com/css?family=Playfair+Display+SC', name: 'Playfair Display SC', fontVertShift: -5},
  82. {css: 'https://fonts.googleapis.com/css?family=Podkova', name: 'Podkova', fontVertShift: 10},
  83. {css: 'https://fonts.googleapis.com/css?family=Poiret+One', name: 'Poiret One', fontVertShift: 0},
  84. {css: 'https://fonts.googleapis.com/css?family=Prata', name: 'Prata', fontVertShift: 5},
  85. {css: 'https://fonts.googleapis.com/css?family=Prosto+One', name: 'Prosto One', fontVertShift: 0},
  86. {css: 'https://fonts.googleapis.com/css?family=PT+Mono', name: 'PT Mono', fontVertShift: 5},
  87. {css: 'https://fonts.googleapis.com/css?family=PT+Sans', name: 'PT Sans', fontVertShift: -10},
  88. {css: 'https://fonts.googleapis.com/css?family=PT+Sans+Caption', name: 'PT Sans Caption', fontVertShift: -10},
  89. {css: 'https://fonts.googleapis.com/css?family=PT+Sans+Narrow', name: 'PT Sans Narrow', fontVertShift: -10},
  90. {css: 'https://fonts.googleapis.com/css?family=PT+Serif', name: 'PT Serif', fontVertShift: -10},
  91. {css: 'https://fonts.googleapis.com/css?family=PT+Serif+Caption', name: 'PT Serif Caption', fontVertShift: -10},
  92. {css: 'https://fonts.googleapis.com/css?family=Roboto+Condensed', name: 'Roboto Condensed', fontVertShift: 0},
  93. {css: 'https://fonts.googleapis.com/css?family=Roboto+Mono', name: 'Roboto Mono', fontVertShift: -5},
  94. {css: 'https://fonts.googleapis.com/css?family=Roboto+Slab', name: 'Roboto Slab', fontVertShift: 0},
  95. {css: 'https://fonts.googleapis.com/css?family=Ruslan+Display', name: 'Ruslan Display', fontVertShift: 20},
  96. {css: 'https://fonts.googleapis.com/css?family=Russo+One', name: 'Russo One', fontVertShift: 5},
  97. {css: 'https://fonts.googleapis.com/css?family=Sawarabi+Gothic', name: 'Sawarabi Gothic', fontVertShift: -15},
  98. {css: 'https://fonts.googleapis.com/css?family=Scada', name: 'Scada', fontVertShift: 0},
  99. {css: 'https://fonts.googleapis.com/css?family=Seymour+One', name: 'Seymour One', fontVertShift: 0},
  100. {css: 'https://fonts.googleapis.com/css?family=Source+Sans+Pro', name: 'Source Sans Pro', fontVertShift: 0},
  101. {css: 'https://fonts.googleapis.com/css?family=Spectral', name: 'Spectral', fontVertShift: -5},
  102. {css: 'https://fonts.googleapis.com/css?family=Stalinist+One', name: 'Stalinist One', fontVertShift: 0},
  103. {css: 'https://fonts.googleapis.com/css?family=Tinos', name: 'Tinos', fontVertShift: 5},
  104. {css: 'https://fonts.googleapis.com/css?family=Tenor+Sans', name: 'Tenor Sans', fontVertShift: 5},
  105. {css: 'https://fonts.googleapis.com/css?family=Underdog', name: 'Underdog', fontVertShift: 10},
  106. {css: 'https://fonts.googleapis.com/css?family=Ubuntu+Mono', name: 'Ubuntu Mono', fontVertShift: 0},
  107. {css: 'https://fonts.googleapis.com/css?family=Ubuntu+Condensed', name: 'Ubuntu Condensed', fontVertShift: -5},
  108. {css: 'https://fonts.googleapis.com/css?family=Vollkorn', name: 'Vollkorn', fontVertShift: -5},
  109. {css: 'https://fonts.googleapis.com/css?family=Vollkorn+SC', name: 'Vollkorn SC', fontVertShift: 0},
  110. {css: 'https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz', name: 'Yanone Kaffeesatz', fontVertShift: 20},
  111. {css: 'https://fonts.googleapis.com/css?family=Yeseva+One', name: 'Yeseva One', fontVertShift: 10},
  112. ];
  113. const settingDefaults = {
  114. textColor: '#000000',
  115. backgroundColor: '#EBE2C9',
  116. wallpaper: '',
  117. fontStyle: '',// 'italic'
  118. fontWeight: '',// 'bold'
  119. fontSize: 20,// px
  120. fontName: 'ReaderDefault',
  121. webFontName: '',
  122. fontVertShift: 0,
  123. textVertShift: -20,
  124. lineInterval: 3,// px, межстрочный интервал
  125. textAlignJustify: true,// выравнивание по ширине
  126. p: 25,// px, отступ параграфа
  127. indentLR: 15,// px, отступ всего текста слева и справа
  128. indentTB: 0,// px, отступ всего текста сверху и снизу
  129. wordWrap: true,//перенос по слогам
  130. keepLastToFirst: false,// перенос последней строки в первую при листании
  131. showStatusBar: true,
  132. statusBarTop: false,// top, bottom
  133. statusBarHeight: 19,// px
  134. statusBarColorAlpha: 0.4,
  135. scrollingDelay: 3000,// замедление, ms
  136. scrollingType: 'ease-in-out', //linear, ease, ease-in, ease-out, ease-in-out
  137. pageChangeAnimation: 'flip',// '' - нет, downShift, rightShift, thaw - протаивание, blink - мерцание, rotate - вращение, flip - листание
  138. pageChangeAnimationSpeed: 80, //0-100%
  139. allowUrlParamBookPos: false,
  140. lazyParseEnabled: false,
  141. copyFullText: false,
  142. showClickMapPage: true,
  143. clickControl: true,
  144. cutEmptyParagraphs: false,
  145. addEmptyParagraphs: 0,
  146. blinkCachedLoad: true,
  147. showImages: true,
  148. showInlineImagesInCenter: true,
  149. compactTextPerc: 0,
  150. imageHeightLines: 100,
  151. imageFitWidth: true,
  152. showServerStorageMessages: true,
  153. showWhatsNewDialog: true,
  154. fontShifts: {},
  155. showToolButton: {},
  156. };
  157. for (const font of fonts)
  158. settingDefaults.fontShifts[font.name] = font.fontVertShift;
  159. for (const font of webFonts)
  160. settingDefaults.fontShifts[font.name] = font.fontVertShift;
  161. for (const button of toolButtons)
  162. settingDefaults.showToolButton[button.name] = button.show;
  163. // initial state
  164. const state = {
  165. toolBarActive: true,
  166. serverSyncEnabled: false,
  167. serverStorageKey: '',
  168. profiles: {},
  169. profilesRev: 0,
  170. allowProfilesSave: false,//подстраховка для разработки
  171. whatsNewContentHash: '',
  172. currentProfile: '',
  173. settings: Object.assign({}, settingDefaults),
  174. settingsRev: {},
  175. };
  176. // getters
  177. const getters = {};
  178. // actions
  179. const actions = {};
  180. // mutations
  181. const mutations = {
  182. setToolBarActive(state, value) {
  183. state.toolBarActive = value;
  184. },
  185. setServerSyncEnabled(state, value) {
  186. state.serverSyncEnabled = value;
  187. },
  188. setServerStorageKey(state, value) {
  189. state.serverStorageKey = value;
  190. },
  191. setProfiles(state, value) {
  192. state.profiles = value;
  193. },
  194. setProfilesRev(state, value) {
  195. state.profilesRev = value;
  196. },
  197. setAllowProfilesSave(state, value) {
  198. state.allowProfilesSave = value;
  199. },
  200. setWhatsNewContentHash(state, value) {
  201. state.whatsNewContentHash = value;
  202. },
  203. setCurrentProfile(state, value) {
  204. state.currentProfile = value;
  205. },
  206. setSettings(state, value) {
  207. state.settings = Object.assign({}, state.settings, value);
  208. },
  209. setSettingsRev(state, value) {
  210. state.settingsRev = Object.assign({}, state.settingsRev, value);
  211. },
  212. };
  213. export default {
  214. toolButtons,
  215. fonts,
  216. webFonts,
  217. settingDefaults,
  218. namespaced: true,
  219. state,
  220. getters,
  221. actions,
  222. mutations
  223. };