Skip to content

Commit

Permalink
Добавил кнопку"Очистить URL" в секции настройки "Отмечать скаченные"
Browse files Browse the repository at this point in the history
  • Loading branch information
neyasbltb88 committed Mar 18, 2019
1 parent 3e514df commit c56a2d9
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 20 deletions.
2 changes: 1 addition & 1 deletion app/scripts/maps/vk-photo-download.min.js.map

Large diffs are not rendered by default.

16 changes: 10 additions & 6 deletions app/scripts/modules/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ export default class HandlersManager {
showSizeHandler: this._showSizeHandler.bind(this),
downloadEffect: this.tempClass.bind(this, this.sel.get('btn.download_effect'), this.timings.settings_open + 250, `.${this.sel.get('btn.icon')}`),
loadedUrlsHandler: this._loadedUrlsHandler.bind(this),
addloadedUrl: this._addloadedUrl.bind(this),
addLoadedUrl: this._addLoadedUrl.bind(this),
clearLoadedUrls: () => this.PhotoDownload.loaded_urls.clear(),
}

this.timers = {
Expand Down Expand Up @@ -63,6 +64,9 @@ export default class HandlersManager {
// Обработчик изменения настройки запоминания URL скаченных картинок
let loaded_urls_mode = wrap.querySelector('.' + this.sel.get('sett.loaded_urls_mode'));
this.set(loaded_urls_mode, 'loadedUrlsHandler', 'change');

let loaded_urls_mode_clear_control = wrap.querySelector('#' + this.sel.get('loaded_urls_mode_clear_control'));
this.set(loaded_urls_mode_clear_control, 'clearLoadedUrls', 'click');
}

// Обновляет настройки в кнопке
Expand Down Expand Up @@ -126,7 +130,7 @@ export default class HandlersManager {
this.PhotoDownload.settings.loaded_urls &&
this.PhotoDownload.state.settings == 'close') {

this._addloadedUrl(e);
this._addLoadedUrl(e);
}

return false;
Expand Down Expand Up @@ -175,9 +179,9 @@ export default class HandlersManager {
// Тут действие для простого клика
// В зависимости от флага вешаем либо обработчик скачивания, либо открытия новой вкладки
if (this.PhotoDownload.settings.download_mode) {
this.set(e.currentTarget, ['downloadHandler', 'downloadEffect', 'addloadedUrl']);
this.set(e.currentTarget, ['downloadHandler', 'downloadEffect', 'addLoadedUrl']);
} else {
this.set(e.currentTarget, ['newTabHandler', 'downloadEffect', 'addloadedUrl']);
this.set(e.currentTarget, ['newTabHandler', 'downloadEffect', 'addLoadedUrl']);
}
}

Expand Down Expand Up @@ -353,9 +357,9 @@ export default class HandlersManager {

// === Обработчики ===

_addloadedUrl(e) {
_addLoadedUrl(e) {
let url = e.currentTarget.href;
this.PhotoDownload._addloadedUrl(url);
this.PhotoDownload._addLoadedUrl(url);
}

// Меняет настройку запоминания URL скаченных картинок
Expand Down
3 changes: 2 additions & 1 deletion app/scripts/modules/photo-download.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export default class PhotoDownload {

loaded_urls_mode_control: 'loaded_urls_mode_control',
loaded_urls_mode_key_control: 'loaded_urls_mode_key_control',
loaded_urls_mode_clear_control: 'loaded_urls_mode_clear_control',
loaded_urls_active: 'loaded_urls_active',

sett: {
Expand Down Expand Up @@ -341,7 +342,7 @@ export default class PhotoDownload {
// === LoadedUrl ===

// Если разрешено в настройке, добавляет url в массив ранее скаченных
_addloadedUrl(url) {
_addLoadedUrl(url) {
if (this.settings.loaded_urls) {
this.loaded_urls.add(url);
}
Expand Down
20 changes: 20 additions & 0 deletions app/scripts/modules/template-css.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,26 @@ export default function(sel, timings, icons) {
display: none;
}
.${sel.get('sett.settings_item')} button {
margin: 0 auto;
background-color: transparent;
font-size: 12px;
padding: 2px;
border: 1px solid;
border-color: ${icons._colors.grey};
border-radius: 2px;
width: 100%;
cursor: pointer;
}
.${sel.get('sett.settings_item')} button:hover {
color: ${icons._colors.green} !important;
}
.${sel.get('sett.settings_item')} button:active {
border-color: ${icons._colors.green} !important;
}
.${sel.get('sett.settings_item_action')} {
display: flex;
align-items: center;
Expand Down
5 changes: 4 additions & 1 deletion app/scripts/modules/template-html.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,13 @@ export default function(sel, timings, icons) {
</li>
<li class="${sel.get('sett.settings_item')}">
<!-- disabled checked -->
<input type="checkbox" id="${sel.loaded_urls_mode_key_control}" name="loaded_urls_mode_key" value="true" disabled>
<label for="${sel.loaded_urls_mode_key_control}" class="${sel.get('sett.settings_item_action')}">+ клики ПКМ</label>
</li>
<li class="${sel.get('sett.settings_item')}">
<button id="${sel.loaded_urls_mode_clear_control}">Очистить URL</button>
</li>
</ul>
</div>
Expand Down
28 changes: 17 additions & 11 deletions app/scripts/vk-photo-download.min.js

Large diffs are not rendered by default.

0 comments on commit c56a2d9

Please sign in to comment.