Compare commits
1 Commits
cybrespace
...
feature_lo
Author | SHA1 | Date |
---|---|---|
|
6f15035cad |
|
@ -18,6 +18,12 @@ window.addEventListener('message', e => {
|
||||||
id: data.id,
|
id: data.id,
|
||||||
height: document.getElementsByTagName('html')[0].scrollHeight,
|
height: document.getElementsByTagName('html')[0].scrollHeight,
|
||||||
}, '*');
|
}, '*');
|
||||||
|
|
||||||
|
if (document.fonts && document.fonts.ready) {
|
||||||
|
document.fonts.ready.then(sizeBioText);
|
||||||
|
} else {
|
||||||
|
sizeBioText();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -117,6 +123,25 @@ function main() {
|
||||||
|
|
||||||
delegate(document, '.custom-emoji', 'mouseover', getEmojiAnimationHandler('data-original'));
|
delegate(document, '.custom-emoji', 'mouseover', getEmojiAnimationHandler('data-original'));
|
||||||
delegate(document, '.custom-emoji', 'mouseout', getEmojiAnimationHandler('data-static'));
|
delegate(document, '.custom-emoji', 'mouseout', getEmojiAnimationHandler('data-static'));
|
||||||
|
|
||||||
|
if (document.body.classList.contains('with-modals')) {
|
||||||
|
const scrollbarWidth = window.innerWidth - document.documentElement.clientWidth;
|
||||||
|
const scrollbarWidthStyle = document.createElement('style');
|
||||||
|
scrollbarWidthStyle.id = 'scrollbar-width';
|
||||||
|
document.head.appendChild(scrollbarWidthStyle);
|
||||||
|
scrollbarWidthStyle.sheet.insertRule(`body.with-modals--active { margin-right: ${scrollbarWidth}px; }`, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
[].forEach.call(document.querySelectorAll('[data-component="Card"]'), (content) => {
|
||||||
|
const props = JSON.parse(content.getAttribute('data-props'));
|
||||||
|
ReactDOM.render(<CardContainer locale={locale} {...props} />, content);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (document.fonts && document.fonts.ready) {
|
||||||
|
document.fonts.ready.then(sizeBioText);
|
||||||
|
} else {
|
||||||
|
sizeBioText();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
delegate(document, '.webapp-btn', 'click', ({ target, button }) => {
|
delegate(document, '.webapp-btn', 'click', ({ target, button }) => {
|
||||||
|
@ -257,6 +282,22 @@ function main() {
|
||||||
target.style.display = 'block';
|
target.style.display = 'block';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
delegate(document, '#account_note', 'input', sizeBioText);
|
||||||
|
|
||||||
|
function sizeBioText() {
|
||||||
|
const noteCounter = document.querySelector('.note-counter');
|
||||||
|
const bioTextArea = document.querySelector('#account_note');
|
||||||
|
|
||||||
|
if (noteCounter) {
|
||||||
|
noteCounter.textContent = 413 - length(bioTextArea.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bioTextArea) {
|
||||||
|
bioTextArea.style.height = 'auto';
|
||||||
|
bioTextArea.style.height = (bioTextArea.scrollHeight+3) + 'px';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
loadPolyfills().then(main).catch(error => {
|
loadPolyfills().then(main).catch(error => {
|
||||||
|
|
|
@ -81,6 +81,7 @@ class Account < ApplicationRecord
|
||||||
validates_with UnreservedUsernameValidator, if: -> { local? && will_save_change_to_username? }
|
validates_with UnreservedUsernameValidator, if: -> { local? && will_save_change_to_username? }
|
||||||
validates :display_name, length: { maximum: 30 }, if: -> { local? && will_save_change_to_display_name? }
|
validates :display_name, length: { maximum: 30 }, if: -> { local? && will_save_change_to_display_name? }
|
||||||
validates :note, note_length: { maximum: 500 }, if: -> { local? && will_save_change_to_note? }
|
validates :note, note_length: { maximum: 500 }, if: -> { local? && will_save_change_to_note? }
|
||||||
|
validate :note_has_eight_newlines?, if: -> { local? && will_save_change_to_note? }
|
||||||
validates :fields, length: { maximum: 4 }, if: -> { local? && will_save_change_to_fields? }
|
validates :fields, length: { maximum: 4 }, if: -> { local? && will_save_change_to_fields? }
|
||||||
|
|
||||||
scope :remote, -> { where.not(domain: nil) }
|
scope :remote, -> { where.not(domain: nil) }
|
||||||
|
@ -310,10 +311,8 @@ class Account < ApplicationRecord
|
||||||
def save_with_optional_media!
|
def save_with_optional_media!
|
||||||
save!
|
save!
|
||||||
rescue ActiveRecord::RecordInvalid
|
rescue ActiveRecord::RecordInvalid
|
||||||
self.avatar = nil
|
self.avatar = nil if errors[:avatar].present?
|
||||||
self.header = nil
|
self.header = nil if errors[:header].present?
|
||||||
self[:avatar_remote_url] = ''
|
|
||||||
self[:header_remote_url] = ''
|
|
||||||
save!
|
save!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -337,6 +336,10 @@ class Account < ApplicationRecord
|
||||||
shared_inbox_url.presence || inbox_url
|
shared_inbox_url.presence || inbox_url
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def note_has_eight_newlines?
|
||||||
|
errors.add(:note, 'Bio can\'t have more then 8 newlines') unless note.count("\n") <= 8
|
||||||
|
end
|
||||||
|
|
||||||
class Field < ActiveModelSerializers::Model
|
class Field < ActiveModelSerializers::Model
|
||||||
attributes :name, :value, :verified_at, :account, :errors
|
attributes :name, :value, :verified_at, :account, :errors
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue