Add Custom CSS ricing. #932

This commit is contained in:
Nicolas Stepien 2013-02-28 03:03:50 +01:00
parent e8012a38da
commit de8226e96e
5 changed files with 80 additions and 12 deletions

File diff suppressed because one or more lines are too long

View File

@ -277,6 +277,9 @@ a[href="javascript:;"] {
.section-sauce textarea { .section-sauce textarea {
height: 350px; height: 350px;
} }
.section-rice textarea {
height: 150px;
}
#fourchanx-settings textarea { #fourchanx-settings textarea {
font-family: monospace; font-family: monospace;
min-width: 100%; min-width: 100%;

View File

@ -10,6 +10,7 @@ Config =
'Comment Expansion': [true, 'Can expand too long comments.'] 'Comment Expansion': [true, 'Can expand too long comments.']
'Thread Expansion': [true, 'Can expand threads to view all replies.'] 'Thread Expansion': [true, 'Can expand threads to view all replies.']
'Index Navigation': [false, 'Navigate to previous / next thread.'] 'Index Navigation': [false, 'Navigate to previous / next thread.']
'Custom CSS': [false, 'Apply custom CSS to 4chan.']
'Check for Updates': [true, 'Check for updated versions of <%= meta.name %>.'] 'Check for Updates': [true, 'Check for updated versions of <%= meta.name %>.']
'Filtering': 'Filtering':
'Anonymize': [false, 'Turn everyone Anonymous.'] 'Anonymize': [false, 'Turn everyone Anonymous.']
@ -129,6 +130,7 @@ Config =
backlink: '>>%id' backlink: '>>%id'
fileInfo: '%l (%p%s, %r)' fileInfo: '%l (%p%s, %r)'
favicon: 'ferongr' favicon: 'ferongr'
usercss: ''
hotkeys: hotkeys:
# QR & Options # QR & Options
'Open empty QR': ['q', 'Open QR without post number inserted.'] 'Open empty QR': ['q', 'Open QR without post number inserted.']

View File

@ -496,18 +496,23 @@ Settings =
<option value=Original>Original</option> <option value=Original>Original</option>
</select> </select>
<span class=favicon-preview></span> <span class=favicon-preview></span>
<div>Custom CSS</div>
<div class=warning #{if Conf['Custom CSS'] then 'hidden' else ''}><code>Custom CSS</code> is disabled.</div>
<button id=apply-css>Apply CSS</button>
<textarea name=usercss class=field></textarea>
""" """
for name in ['time', 'backlink', 'fileInfo', 'favicon'] for name in ['time', 'backlink', 'fileInfo', 'favicon', 'usercss']
input = $ "[name=#{name}]", section input = $ "[name=#{name}]", section
input.value = $.get name, Conf[name] input.value = $.get name, Conf[name]
event = if input.nodeName is 'SELECT' event = if name in ['favicon', 'usercss']
'change' 'change'
else else
'input' 'input'
$.on input, event, $.cb.value $.on input, event, $.cb.value
$.on input, event, Settings[name] unless name in ['usercss']
Settings[name].call input $.on input, event, Settings[name]
return Settings[name].call input
$.on $.id('apply-css'), 'click', Settings.usercss
time: -> time: ->
funk = Time.createFunc @value funk = Time.createFunc @value
@nextElementSibling.textContent = funk Time, new Date() @nextElementSibling.textContent = funk Time, new Date()
@ -530,6 +535,11 @@ Settings =
Favicon.switch() Favicon.switch()
Unread.update() if g.VIEW is 'thread' and Conf['Unread Tab Icon'] Unread.update() if g.VIEW is 'thread' and Conf['Unread Tab Icon']
@nextElementSibling.innerHTML = "<img src=#{Favicon.unreadSFW}> <img src=#{Favicon.unreadNSFW}> <img src=#{Favicon.unreadDead}>" @nextElementSibling.innerHTML = "<img src=#{Favicon.unreadSFW}> <img src=#{Favicon.unreadNSFW}> <img src=#{Favicon.unreadDead}>"
usercss: ->
if Conf['Custom CSS']
CustomCSS.update()
else
CustomCSS.rmStyle()
keybinds: (section) -> keybinds: (section) ->
section.innerHTML = """ section.innerHTML = """
@ -598,6 +608,21 @@ Fourchan =
offset: offset offset: offset
limit: limit limit: limit
CustomCSS =
init: ->
return if !Conf['Custom CSS']
@addStyle()
addStyle: ->
@style = $.addStyle Conf['usercss']
rmStyle: ->
if @style
$.rm @style
delete @style
update: ->
unless @style
@addStyle()
@style.textContent = Conf['usercss']
Filter = Filter =
filters: {} filters: {}
init: -> init: ->

View File

@ -314,6 +314,7 @@ Main =
initFeature 'Header', Header initFeature 'Header', Header
initFeature 'Settings', Settings initFeature 'Settings', Settings
initFeature 'Fourchan thingies', Fourchan initFeature 'Fourchan thingies', Fourchan
initFeature 'Custom CSS', CustomCSS
initFeature 'Resurrect Quotes', Quotify initFeature 'Resurrect Quotes', Quotify
initFeature 'Filter', Filter initFeature 'Filter', Filter
initFeature 'Thread Hiding', ThreadHiding initFeature 'Thread Hiding', ThreadHiding