Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modernization update #1076

Open
wants to merge 230 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
230 commits
Select commit Hold shift + click to select a range
a73a533
add tailwind and start on landing page
drusepth Jan 7, 2022
f955525
wip landing still
drusepth Jan 7, 2022
9346366
signup cta with devise on landing page
drusepth Jan 7, 2022
c38dfde
landing page redesign done
drusepth Jan 8, 2022
f42e0b0
landing page design tweaks
drusepth Jan 8, 2022
645c0b9
remove link to designers landing page
drusepth Jan 8, 2022
8f6a1d6
wip targeted landing pages
drusepth Jan 8, 2022
9d2464a
polish up pricing table
drusepth Jan 8, 2022
53f7c86
redesign for_writers landing
drusepth Jan 9, 2022
24dc487
redesign roleplayer landing page
drusepth Jan 9, 2022
3157059
remove for_designers landing flow
drusepth Jan 9, 2022
0a2d249
add cta to roleplayer landing page
drusepth Jan 9, 2022
ec86490
start on content_type landing pages wip
drusepth Jan 11, 2022
92c3220
Merge branch 'master' into tailwind-redesign
drusepth Jan 17, 2022
c502c5e
resolve mini_racer hell (make sure bundler is >=2.3)
drusepth Jan 17, 2022
e0bbd55
add alpine.js and wrap up content_type static pages
drusepth Jan 19, 2022
9b3a51d
start redoing signup page
drusepth Jan 19, 2022
880bace
logged out tailwind navbar
drusepth Feb 6, 2022
5ef75c4
customize colors, bleed into sign up page
drusepth Feb 6, 2022
0f46059
extend tailwind colors instead of overriding them
drusepth Feb 6, 2022
6f52e09
style new sign in form
drusepth Feb 6, 2022
6550ded
Devise styling consistency
drusepth Feb 6, 2022
bcf030c
tailwind color palette on all content types
drusepth Feb 10, 2022
e66be12
more landing polish
drusepth Feb 10, 2022
ff9979f
consistency
drusepth Feb 10, 2022
87d851b
switch to tailwind on content info pages
drusepth Feb 10, 2022
b1d3029
start on new logged-in navbar design mockups
drusepth Feb 10, 2022
ad9e408
add .env to gitignore
drusepth Feb 23, 2022
37dc3c8
more navbar work
drusepth Feb 26, 2022
7448cfc
more design work on navbar
drusepth Mar 21, 2022
5774890
placeholder for more nav pieces
drusepth Mar 21, 2022
a1557b3
more navbar wip
drusepth Mar 21, 2022
6478de7
maybe this is better navbar
drusepth Mar 21, 2022
a275b66
blend search and notifs
drusepth Mar 21, 2022
70e03da
universe picker placeholder
drusepth Mar 21, 2022
f44673c
Style notifications
drusepth Mar 21, 2022
4c5fd6b
hide notifs by default :)
drusepth Mar 21, 2022
00bfa63
style universe picker header placeholder
drusepth Mar 21, 2022
7628b50
hook up search
drusepth Mar 21, 2022
9ca3583
make unread notifications less obnoxious
drusepth Mar 21, 2022
b78b3c2
minor tweaks; hook up universe scope
drusepth Mar 21, 2022
5010aab
start on tailwind sidenav & page structure
drusepth Mar 21, 2022
75ac7a6
start prototyping different tailwind structure with sidenav
drusepth Mar 21, 2022
df0492e
bring in new navbar elements
drusepth Mar 21, 2022
1a044ab
start populating sidebar
drusepth Mar 21, 2022
cc8e6bd
wip sidebar
drusepth Mar 22, 2022
e478b7b
more wip
drusepth Mar 22, 2022
fa9287a
adjust sidenav icon positioning
drusepth Mar 22, 2022
2c891cd
start filling out the rest of the sidenav
drusepth Mar 22, 2022
adfcb49
use proper links
drusepth Mar 22, 2022
5a666af
build account dropdown menu
drusepth Mar 23, 2022
8fc483e
restructure page layout so we can properly toggle sidenav on/off
drusepth Mar 23, 2022
1b70b01
wrap up navbar for now
drusepth Mar 23, 2022
f99c980
start on new user profile designs
drusepth Mar 23, 2022
53d3806
more wip profile components
drusepth Mar 23, 2022
95cbad8
start on tw styleguide
drusepth Mar 24, 2022
6765c85
style present prompts page
drusepth Apr 12, 2022
1d7fc0f
wrap up prompts page for now
drusepth Apr 12, 2022
8f60c12
wip content#index styling
drusepth Apr 15, 2022
690dd47
wip filter bar, needs js
drusepth Apr 15, 2022
b4538fb
universe scope avatars on content#index pages
drusepth Apr 15, 2022
3dfeb5d
add stimulusjs
drusepth Apr 15, 2022
719ce14
get first stimulusjs dropdown working
drusepth Apr 15, 2022
10e7998
Merge branch 'master' into tailwind-redesign
drusepth Apr 15, 2022
0ac4bcf
wrap up filter bar styling for now
drusepth Apr 15, 2022
520a2aa
add empty state styling for content#index
drusepth Apr 15, 2022
9601563
quick x for removing per-tag
drusepth Apr 16, 2022
66bc408
tag filtering is working
drusepth Apr 16, 2022
3312a30
style multiverse universe picker page + add a few blank placeholder p…
drusepth Apr 16, 2022
a851f8b
start blocking ToC design
drusepth Apr 16, 2022
7dff1b3
wip
drusepth May 1, 2022
862ccbe
Merge branch 'master' into tailwind-redesign
drusepth Jun 1, 2022
95ec29b
tweak sidenav icon sizes/spacing for small/large screens
drusepth Jun 1, 2022
dc2a7ad
new dashboard design
drusepth Jun 1, 2022
88895cb
streak tweaks
drusepth Jun 1, 2022
ec2c189
Merge branch 'master' into tailwind-redesign
drusepth Jul 20, 2022
173c8a8
wip hub design that'll probably be per-universe
drusepth Jul 20, 2022
6a15c72
WIP content#show redesign
drusepth Jul 20, 2022
5a6545a
WIP for content#show and content#edit merge
drusepth Jul 25, 2022
0d0c07a
eod wip tweaks
drusepth Jul 26, 2022
2e9115a
tweaked gallery design based on feedback
drusepth Jul 30, 2022
02d9206
Merge branch 'master' into tailwind-redesign
drusepth Aug 11, 2022
a8b93b5
drop listen gem
drusepth Aug 14, 2022
1e9bb47
javascript is a blight
drusepth Aug 14, 2022
3eb6a23
use yarn instead i guess
drusepth Aug 14, 2022
86d6dea
kill node
drusepth Aug 15, 2022
b703e55
I don't know what js is doing anymore
drusepth Aug 15, 2022
a5291c3
things work again i guess, but at what cost
drusepth Aug 15, 2022
2388353
add tailwind purge
drusepth Aug 15, 2022
cc87340
i dunno try this
drusepth Aug 15, 2022
5277383
Merge branch 'master' into tailwind-redesign
drusepth Aug 15, 2022
a61f9dc
Merge branch 'master' into tailwind-redesign
drusepth Sep 5, 2022
1c06e24
adjust sidenav size
drusepth Sep 5, 2022
87f1089
fix padding on universe picker
drusepth Sep 5, 2022
d0cf995
start pruning features for v2
drusepth Sep 6, 2022
6598db4
replace old footer
drusepth Sep 6, 2022
35e2954
add ?u=all multiverse filter
drusepth Sep 6, 2022
560531c
eod toc work
drusepth Sep 6, 2022
e145d6d
basic table of contents rework
drusepth Sep 6, 2022
1c7c1f9
switch universes#index to tailwind container
drusepth Sep 6, 2022
7bc1495
timelines#index
drusepth Sep 6, 2022
90359c8
sweet documents#index skeleton
drusepth Sep 7, 2022
ec55782
reuse new foldered index view across content pages and documents
drusepth Sep 7, 2022
96c559f
unify new content view
drusepth Sep 8, 2022
3cc84fc
tweak doc table
drusepth Sep 9, 2022
e819517
eod on more doc table design
drusepth Sep 9, 2022
04c09db
Merge branch 'master' into tailwind-redesign
drusepth Sep 9, 2022
8ad0547
more doc table design
drusepth Sep 9, 2022
86ff9e5
document#show design
drusepth Sep 9, 2022
62631fa
lil more doc index polish
drusepth Sep 9, 2022
47046cc
Merge branch 'master' into tailwind-redesign
drusepth Oct 7, 2022
817ffd0
wip restructuring dashboard
drusepth Oct 7, 2022
bbbbe4f
dashboard work
drusepth Oct 9, 2022
646f79a
Merge branch 'master' into tailwind-redesign
drusepth Oct 19, 2022
54c4207
generalize toc mockup for universe/user
drusepth Oct 19, 2022
cac9971
universe context sidebar tweaks
drusepth Oct 20, 2022
553e214
stream skeleton design
drusepth Oct 20, 2022
2f73754
eod stream tweaks
drusepth Oct 21, 2022
3462882
Merge branch 'master' into tailwind-redesign
drusepth Nov 2, 2022
ee8252b
wip content types widget
drusepth Nov 2, 2022
62edc3f
Merge branch 'master' into tailwind-redesign
drusepth Nov 22, 2022
9c8e2bf
code cleanup
drusepth Nov 22, 2022
04cc5a4
reuse content#index for timeline#index
drusepth Nov 22, 2022
6c35dbb
page_collections#index
drusepth Nov 22, 2022
b56cc29
wip from eod
drusepth Nov 26, 2022
9144e03
Merge branch 'master' into tailwind-redesign
drusepth Nov 26, 2022
8c8b82d
dashboard tweaks again
drusepth Nov 27, 2022
264eec4
collection feed design
drusepth Nov 28, 2022
14f10d1
more collection#show design
drusepth Nov 29, 2022
d57bf7a
collections#edit wip from eod
drusepth Nov 30, 2022
5396ef5
collection#edit form design (pre-js)
drusepth Nov 30, 2022
f47a536
hook up collection#edit form
drusepth Nov 30, 2022
0651416
eoc tweaks
drusepth Nov 30, 2022
e00eb02
content#show polish from screenshot feedbacks
drusepth Nov 30, 2022
35341a2
eod wip
drusepth Dec 1, 2022
8c87a6c
universe hub verbiage
drusepth Dec 2, 2022
bfef399
Merge branch 'master' into tailwind-redesign
drusepth Dec 3, 2022
e66340c
add word counts to dashboard pages
drusepth Dec 3, 2022
308d9a1
hook up word count in content#index context sidenavs
drusepth Dec 3, 2022
672d81f
styling on recent edit cards on dashboard
drusepth Dec 3, 2022
eb056db
disable table of contents sidenav link
drusepth Dec 3, 2022
6e5ce5b
small tweak to hide broken stuff for now :)
drusepth Dec 4, 2022
193c1a5
minor qa polish
drusepth Dec 4, 2022
89386ef
start on thredded-tailwind redesign & analyses homepage
drusepth Dec 6, 2022
d4fc461
minor qa polish
drusepth Dec 6, 2022
1e19cf4
eod from yesterday
drusepth Dec 6, 2022
bb68258
move thredded navigation into site navigation
drusepth Dec 6, 2022
71fcd4f
style thredded posts in threads
drusepth Dec 7, 2022
5da39f8
fix 500s when logged out in forum layout
drusepth Dec 7, 2022
1677861
eod forums work from yesterday
drusepth Dec 7, 2022
1f5edd3
navbar polishing
drusepth Dec 12, 2022
b93b699
user profile design & notif#index design
drusepth Dec 13, 2022
d746d44
eod wip
drusepth Dec 15, 2022
b664dd3
update logged-out navbar
drusepth Jan 9, 2023
608d463
standardize logged-in navbar
drusepth Jan 9, 2023
ac85fad
fix recent content display list for docs with long titles + html in text
drusepth Jan 9, 2023
c40464b
folders in worldbuilding pages (waow)
drusepth Jan 9, 2023
c50aed7
allow creating folders from content pages with modal
drusepth Jan 9, 2023
cdceb87
styling on content#index sidenav header
drusepth Jan 9, 2023
462674b
more styling/polish/stats
drusepth Jan 10, 2023
0621b05
-w
drusepth Jan 11, 2023
7676742
Merge branch 'master' into tailwind-redesign
drusepth Jan 11, 2023
1b671a6
wip polish before ripping plumbing up
drusepth Jan 11, 2023
d7adaed
hook up new autosave on content#edit fields
drusepth Jan 16, 2023
3c941d4
code/design cleanup
drusepth Jan 16, 2023
b805795
styling wip
drusepth Jan 23, 2023
7cc3b07
Merge branch 'master' into tailwind-redesign
drusepth Jan 30, 2023
bec2b4d
work around browser triggering onblur with remote form submissions (oof)
drusepth Jan 31, 2023
b1b969f
autosize RTI textareas
drusepth Jan 31, 2023
bcbd688
get edit/read mode toggling working with content refreshing
drusepth Jan 31, 2023
3ac27fe
new universe picker on content#edit
drusepth Feb 1, 2023
cdad1ff
new tags field type
drusepth Feb 2, 2023
795c021
tag polish
drusepth Feb 2, 2023
fa997fc
Merge branch 'master' into tailwind-redesign
drusepth Feb 10, 2023
2026fe6
wip polish
drusepth Feb 14, 2023
6ad0581
Merge branch 'master' into tailwind-redesign (bad merge oof)
drusepth Feb 14, 2023
0470cb8
temporarily disable stimulus-dropdown
drusepth Feb 14, 2023
eebbfe1
restyle onboarding universe field type
drusepth Feb 16, 2023
d171533
move to new stim cdn
drusepth Feb 17, 2023
291e5c4
bring the errors
drusepth Feb 17, 2023
50f6574
add (lost?) mjs rule to get stimulus-dropdown working again
drusepth Feb 17, 2023
130db9e
align nav button again
drusepth Feb 17, 2023
43a19a3
basic multiselect dropdown in alpine
drusepth Feb 18, 2023
1a082c2
new link fields finally work
drusepth Feb 19, 2023
4ff76b0
Merge branch 'master' into tailwind-redesign (merge conflicts <3)
drusepth Apr 7, 2023
a644f50
only show recent threads container if there are any to show
drusepth Apr 8, 2023
065a2d0
get content category jumping working
drusepth Apr 8, 2023
f0f55be
fix weird ui interaction & leave dev note about it
drusepth Apr 8, 2023
572e390
gallery page wip
drusepth Apr 12, 2023
c9ad81c
Merge branch 'master' into tailwind-redesign
drusepth Apr 14, 2023
f94bfbc
Merge branch 'master' into tailwind-redesign
drusepth Apr 19, 2023
4c52702
fix 500 on null state content index pages
drusepth Apr 19, 2023
1577ecc
auto-expand worldbuilding sidebar pages
drusepth Apr 19, 2023
8c7b749
new content page toggle page
drusepth Apr 21, 2023
124960e
polish on multiverse, notifications, and page type toggling
drusepth Apr 21, 2023
610a6da
minor polish
drusepth Apr 21, 2023
d252d36
thredded wip
drusepth Apr 24, 2023
ef5dadb
Merge branch 'master' into tailwind-redesign
drusepth Apr 24, 2023
e27b133
Merge branch 'master' into tailwind-redesign
drusepth Apr 27, 2023
283b0dc
sort universes alphabetically in hub
drusepth Apr 28, 2023
c204b0e
static sizing for avatars in navbar
drusepth Apr 28, 2023
c6b1815
add styled serendipitous question back to content#index pages
drusepth Apr 28, 2023
7d1ae9b
polish serendipitous look
drusepth Apr 28, 2023
09f0a7a
Merge branch 'master' into tailwind-redesign
drusepth Apr 28, 2023
f62c063
new search results page
drusepth Apr 28, 2023
718744b
more search polish, filters, sorts
drusepth Apr 28, 2023
3e383ef
wip cleanup
drusepth May 9, 2023
6e9952d
another pass on content#show/edit design
drusepth May 10, 2023
9da0ed3
fix csrf encoding issue
drusepth May 19, 2023
6428fa7
minor ui polish
drusepth May 20, 2023
433c807
color-code fields based on autosave status
drusepth May 20, 2023
e66b082
form fixes
drusepth May 22, 2023
4913f71
finalize link field styling
drusepth May 22, 2023
6577cd1
omfg linking actually starting to work again
drusepth May 22, 2023
508480a
add a colored icon to each selected link chip
drusepth May 22, 2023
7b927fa
get the little x removal working on linked pages too
drusepth May 22, 2023
1897d8d
ux: don't confuse users by letting them type until it actually works …
drusepth May 22, 2023
4550d30
update content context link colors
drusepth May 22, 2023
88315bc
link placeholder for an empty dropdown
drusepth May 23, 2023
5967a43
minor tax ux
drusepth May 23, 2023
3fe80a6
better styling on linked chip removal
drusepth May 23, 2023
a269d3e
references page
drusepth May 25, 2023
8aceca0
fix jumps
drusepth May 25, 2023
6ff7e57
gallery page design
drusepth May 25, 2023
a09f577
wip gallery
drusepth Jun 3, 2023
727ac67
remove unused file
drusepth Jun 14, 2023
0ff6d4d
Merge branch 'master' into tailwind-redesign
drusepth Jun 14, 2023
f123a62
wip eod
drusepth Jun 14, 2023
e833bec
don't do new timeline customization yet
drusepth Jun 15, 2023
2bc65dd
containerize
drusepth Jul 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ node_modules
/yarn-error.log
yarn-debug.log*
.yarn-integrity

# Heroku stuff
.env
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ end

group :development do
gem 'web-console'
gem 'listen'
# gem 'listen'
gem 'bullet'
gem 'rack-mini-profiler'
gem 'memory_profiler'
Expand All @@ -149,3 +149,4 @@ group :worker do
gem 'ibm_watson'
gem 'textstat'
end

13 changes: 3 additions & 10 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1370,11 +1370,11 @@ GEM
flamegraph (0.9.5)
font-awesome-rails (4.7.0.8)
railties (>= 3.2, < 8.0)
friendly_id (5.4.2)
friendly_id (5.5.0)
activerecord (>= 4.0.0)
globalid (1.1.0)
activesupport (>= 5.0)
html-pipeline (2.14.2)
html-pipeline (2.14.3)
activesupport (>= 2)
nokogiri (>= 1.4)
htmlentities (4.3.4)
Expand Down Expand Up @@ -1430,9 +1430,6 @@ GEM
language_filter (0.3.01)
libv8-node (16.10.0.0)
libv8-node (16.10.0.0-x86_64-linux)
listen (3.8.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
loofah (2.20.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
Expand Down Expand Up @@ -1512,7 +1509,7 @@ GEM
nio4r (~> 2.0)
puma-heroku (2.0.0)
puma (>= 5.0, < 6.0)
pundit (2.2.0)
pundit (2.3.0)
activesupport (>= 3.0.0)
racc (1.6.2)
rack (2.2.6.4)
Expand Down Expand Up @@ -1561,9 +1558,6 @@ GEM
rake (>= 12.2)
thor (~> 1.0)
rake (13.0.6)
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
ffi (~> 1.0)
react-rails (2.6.2)
babel-transpiler (>= 0.7.0)
connection_pool
Expand Down Expand Up @@ -1719,7 +1713,6 @@ DEPENDENCIES
ibm_watson
image_processing
language_filter
listen
material_icons
medium-editor-rails
memory_profiler
Expand Down
Binary file added app/assets/images/tristan/face.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/tristan/portrait.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
105 changes: 105 additions & 0 deletions app/assets/javascripts/alpine.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
function alpineMultiSelectController() {
return {
optgroups: [],
options: [],
selected: [],
show: false,
sourceFieldId: '',
open() { this.show = true },
close() { this.show = false },
isOpen() { return this.show === true },
select(index, event) {
if (!this.options[index].selected) {
this.options[index].selected = true;
this.options[index].element = event.target;
this.selected.push(index);

} else {
this.selected.splice(this.selected.lastIndexOf(index), 1);
this.options[index].selected = false;
}

// Update the original select element's selected options
const originalSelect = document.getElementById(this.sourceFieldId);
for (let i = 0; i < originalSelect.options.length; i++) {
originalSelect.options[i].selected = this.options[i].selected;
}

// Finally, trigger a manual on-change event on the original select
// to make sure our autosave fires on it.
originalSelect.dispatchEvent(new Event('change'));
},
remove(index, option) {
this.options[option].selected = false;
this.selected.splice(index, 1);

// We also want to manually remove the `selected` attribute from the
// original select element's option.
const originalSelect = document.getElementById(this.sourceFieldId);
originalSelect.options[option].selected = false;

// After removing the option, we want to emit a change event to trigger
// a field autosave.
originalSelect.dispatchEvent(new Event('change'));
},
loadOptions(fieldId) {
this.sourceFieldId = fieldId;
const select = document.getElementById(fieldId);
const optgroups = select.getElementsByTagName('optgroup');

// Since we're effectively resetting indices per optgroup, we need to track
// a single running index throughout all optgroups to use as an index for
// each option for events, etc.
let runningOptionIndex = 0;

// For each optgroup (page type)...
for (let i = 0; i < optgroups.length; i++) {
const groupOptions = optgroups[i].getElementsByTagName('option');

// Prepare the `options` array for this optgroup
const optionsForThisOptGroup = [];
for (let j = 0; j < groupOptions.length; j++) {
const option = groupOptions[j];
const imageUrl = option.getAttribute('data-image-url');

optionsForThisOptGroup.push({
index: runningOptionIndex++,
value: option.value,
text: option.textContent.trim(),
imageUrl: imageUrl,
icon: option.getAttribute('data-icon'),
icon_color: option.getAttribute('data-icon-color'),
selected: !!option.selected
});

if (!!option.selected) {
this.selected.push(runningOptionIndex - 1);
}
}

// Finally, add it as a valid optgroup with options
if (optionsForThisOptGroup.length > 0) {
this.optgroups.push({
label: optgroups[i].label,
icon: window.ContentTypeData[optgroups[i].label].icon,
color: window.ContentTypeData[optgroups[i].label].color,
plural: window.ContentTypeData[optgroups[i].label].plural,
options: optionsForThisOptGroup
});

// And also track all the options in a flat array so we can reference them with a single index
for (let j = 0; j < optionsForThisOptGroup.length; j++) {
this.options.push(optionsForThisOptGroup[j]);
}
}
}
},
selectedValues(){
// Return all this.options where selected=true
return this.options.filter(op => op.selected === true); // .map(el => el.text)
// return this.selected.map((option)=>{
// return this.options[option].value;
// });
}
}
}
2 changes: 0 additions & 2 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,3 @@
//= require tribute
//= require d3
//= require_tree .


43 changes: 37 additions & 6 deletions app/assets/javascripts/autosave.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,55 @@
$(document).ready(function() {
var recent_autosave = false;

$('.autosave-closest-form-on-change').change(function () {
var content_form = $(this).closest('form');

var default_border_class = 'border-gray-200'; // This needs to match whatever the actual CSS on the element is!
var in_progress_saving_class = 'border-yellow-400';
var saved_successfully_class = 'border-green-400';
var error_saving_class = 'border-red-400';

// Submit content_form with ajax
if (content_form) {
M.toast({ html: 'Saving your changes...' });
recent_autosave = true;
setTimeout(() => recent_autosave = false, 1000);

var form_data = content_form.serialize();
form_data += "&authenticity_token=" + $('meta[name="csrf-token"]').attr('content');
form_data += "&authenticity_token=" + encodeURIComponent($('meta[name="csrf-token"]').attr('content'));

var field = $(this);

console.log('wip saving');
field.removeClass(default_border_class);
field.addClass(in_progress_saving_class);
$.ajax({
url: content_form.attr('action') + '.json',
type: content_form.attr('method').toUpperCase(),
data: form_data,
success: function(response) {
M.toast({ html: 'Saved successfully!' });
console.log('saved ok');
field.removeClass(in_progress_saving_class);
field.addClass(saved_successfully_class);

// Reset back to default coloring after 10 seconds
setTimeout(function () {
field.removeClass(saved_successfully_class);
field.addClass(default_border_class);
}, 10000);
},
error: function(response) {
M.toast({ html: "There was an error saving your changes. Please back up any changes and refresh the page." });
console.log('error saving');
field.removeClass(in_progress_saving_class);
field.addClass(error_saving_class);

// TODO show some modal or something
}
});
} else {
M.toast({ html: "There was an error saving your changes. Please back up any changes and refresh the page." });
console.log('error saving changes');

// TODO show some message to refresh the page or something
// M.toast({ html: "There was an error saving your changes. Please back up any changes and refresh the page." });
}
});

Expand All @@ -31,6 +60,8 @@ $(document).ready(function() {
// To ensure all fields get unblurred (and therefore autosaved) upon navigation,
// we use this little ditty:
window.onbeforeunload = function(e){
$(document.activeElement).blur();
if (!recent_autosave) {
$(document.activeElement).blur();
}
}
});
19 changes: 19 additions & 0 deletions app/assets/javascripts/autosize-textareas.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
$(document).ready(function() {
const yPadding = 16;
const lineHeight = 20; // 36
const elements = document.getElementsByClassName('js-autosize-textarea');
for (let i = 0; i < elements.length; i++) {
// Set the initial height of the textarea
const linesCount = elements[i].value.split("\n").length;
const contentHeight = yPadding + (linesCount * lineHeight);
elements[i].setAttribute("style", "height:" + contentHeight + "px;overflow-y:hidden;");

// Resize the textarea whenever the value changes
elements[i].addEventListener("input", OnInput, false);
}

function OnInput() {
this.style.height = lineHeight + "px";
this.style.height = this.scrollHeight + "px";
}
});
3 changes: 0 additions & 3 deletions app/assets/javascripts/basil.coffee

This file was deleted.

7 changes: 4 additions & 3 deletions app/assets/javascripts/content_type_data.js.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
window.ContentTypeData = {
<% (Rails.application.config.content_types[:all] + [Document, Timeline]).each do |content_type| %>
'<%= content_type.name %>': {
color: '<%= content_type.color %>',
hex: '<%= content_type.hex_color %>',
icon: '<%= content_type.icon %>'
color: '<%= content_type.color %>', // comment to bust cache :) -- should be safe to remove after release but double check the link dropdown optgroup bg colors when you do
hex: '<%= content_type.hex_color %>',
icon: '<%= content_type.icon %>',
plural: '<%= content_type.name.pluralize %>'
},
<% end %>
};
43 changes: 21 additions & 22 deletions app/assets/javascripts/content_types.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
$(document).ready(function() {
$('.js-enable-content-type').click(function () {
var content_type = $(this).data('content-type');
var related_card = $(this).children('.card').first();
var is_currently_active = related_card.hasClass('active');
var ie_badge = $(this).find('.enabled-badge');

$.post('/customization/toggle_content_type', {
// x-on:click="enabled = !enabled; togglePageType('Character', enabled)"
function togglePageType(content_type, active) {
const csrfToken = document.querySelector('meta[name="csrf-token"]').getAttribute('content');
fetch('/customization/toggle_content_type', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRF-Token': csrfToken
},
body: JSON.stringify({
content_type: content_type,
active: is_currently_active ? 'off' : 'on'
});

if (is_currently_active) {
related_card.removeClass('active');
ie_badge.attr('data-badge-caption', 'hidden');
} else {
related_card.addClass('active');
ie_badge.attr('data-badge-caption', 'active');
}

// Return false so we don't jump to the top of the page on link click
return false;
active: active ? 'on' : 'off'
})
})
.then(response => {
// Handle the response
console.log('toggled successfully');
})
.catch(error => {
// Handle the error
console.log('couldnt toggle');
});
});
}
9 changes: 0 additions & 9 deletions app/assets/javascripts/page_tags.js

This file was deleted.

15 changes: 15 additions & 0 deletions app/assets/javascripts/smoothscrolling.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
document.querySelectorAll('a[href^="#"]').forEach((anchor) => {
anchor.addEventListener('click', function (e) {
e.preventDefault();

const target = document.querySelector(this.getAttribute('href'));

// Check if the target element exists
if (target) {
window.scrollTo({
top: target.offsetTop,
behavior: 'smooth',
});
}
});
});
15 changes: 15 additions & 0 deletions app/assets/stylesheets/iconography.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.svg-icon {
width: 1em;
height: 1em;
}

.svg-icon path,
.svg-icon polygon,
.svg-icon rect {
fill: #333;
}

.svg-icon circle {
stroke: #4691f6;
stroke-width: 1;
}
Loading