importCSS

This commit is contained in:
Zixaphir 2015-01-12 17:04:18 -07:00
parent 03ec051087
commit c6aa15c64d
8 changed files with 58 additions and 44 deletions

View File

@ -1,6 +1,9 @@
module.exports = (grunt) ->
grunt.util.linefeed = '\n'
importCSS = (filename) ->
"\"\"\"#{grunt.file.read("src/General/css/#{filename}.css").replace(/\s+/g, ' ').trim()}\"\"\""
importHTML = (filename) ->
"(innerHTML: #{JSON.stringify(grunt.file.read("src/General/html/#{filename}.html").replace(/^\s+|\s+$</gm, '').replace(/\n/g, '')).replace(/\\\\u/g, '\\u')})"
@ -37,6 +40,7 @@ module.exports = (grunt) ->
get: ->
pkg = grunt.config 'pkg'
pkg.importHTML = importHTML
pkg.importCSS = importCSS
pkg.html = html
pkg.assert = assert
pkg.tests_enabled or= false

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,16 +1,16 @@
#mascot img {
height: #{
if mascot.height and isNaN parseFloat mascot.height
if mascot.height and isNaN parseFloat mascot.height then
mascot.height
else if mascot.height
else if mascot.height then
parseInt(mascot.height, 10) + 'px'
else
'auto'
};
width: #{
if mascot.width and isNaN parseFloat mascot.width
if mascot.width and isNaN parseFloat mascot.width then
mascot.width
else if mascot.width
else if mascot.width then
parseInt(mascot.width, 10) + 'px'
else
'auto'

View File

@ -1,6 +1,6 @@
JSColor =
css: ->
"""<%= grunt.file.read('src/General/css/jscolor.css').replace(/\s+/g, ' ').trim() %>"""
<%= importCSS('jscolor') %>
bind: (el) ->
el.color = new JSColor.color(el) if not el.color

View File

@ -399,4 +399,4 @@ MascotTools =
position: (mascot) ->
return unless Style.sheets.mascots
mascot.image? or mascot = Mascots[Conf['mascot']] or {} # event
Style.sheets.mascots.textContent = """<%= grunt.file.read('src/General/css/mascot.css') %>"""
Style.sheets.mascots.textContent = <%= importCSS('mascot') %>

View File

@ -2,10 +2,10 @@ Style =
sheets: {}
init: ->
Style.svgs = {
<% if (type === 'crx') { %>
<% if (type === 'crx') { %>
el: $.el 'div',
id: 'svg_filters'
<% } %>
<% } %>
}
theme = Themes[Conf[g.THEMESTRING]] or Themes['Yotsuba B']
@ -26,8 +26,8 @@ Style =
$.asap (-> d.body), @asapInit
$.asap (-> Header.bar.parentElement), Style.padding
$.asap (-> $.id 'boardNavDesktopFoot' ), @readyInit
$.on window, "resize", Style.padding
$.ready @readyInit
asapInit: ->
<% if (type === 'crx') { %>
@ -95,11 +95,8 @@ Style =
silhouette: ([fg]) ->
"0 0 0 0 #{fg.r} 0 0 0 0 #{fg.g} 0 0 0 0 #{fg.b}"
layout: """<%=
grunt.file.read('src/General/css/layout.css').replace(/\s+/g, ' ').trim()
+ ' ' +
grunt.file.read('src/General/css/font-awesome.css').replace(/\s+/g, ' ').replace(/\\/g, '\\\\').trim()
%>"""
layout:
<%= importCSS('layout') %> + ' ' + <%= importCSS('font-awesome') %>
dynamic: ->
sidebarLocation = if Conf["Sidebar Location"] is "left"
@ -116,7 +113,7 @@ Style =
left: 0
right: 0
"""<%= grunt.file.read('src/General/css/dynamic.css').replace(/\s+/g, ' ').trim() %>"""
<%= importCSS('dynamic') %>
setTheme: (theme) -> Style.sheets.theme.textContent = Style.theme theme
@ -144,14 +141,15 @@ Style =
Style.svgs.el.innerHTML = svgs.join ''
<% } %>
"""<%= grunt.file.read('src/General/css/theme.css').replace(/\s+/g, ' ').trim() %>""" + <%= grunt.file.read('src/General/css/themeoptions.css').replace(/\s+/g, ' ').trim() %>
<%= importCSS('theme') %> + ' ' + <%= importCSS('themeoptions') %>
iconPositions: ->
# Slideout Navigation
slideNav = $.el 'span',
id: 'so-nav'
innerHTML: '<i class=a-icon></a>'
$.add slideNav, $.id('boardNavDesktopFoot')
$.extend slideNav, <%= html('<i class="a-icon"></a>') %>
$.add slideNav, $.id 'boardNavDesktopFoot'
Header.addShortcut slideNav, true
# Announcements
@ -159,7 +157,7 @@ Style =
if (psa = $.id 'globalMessage') and !psa.hidden
psaIcon = $.el 'i',
id: 'so-psa'
innerHTML: '<i class=a-icon></a>'
$.extend psaIcon, <%= html('<i class="a-icon"></a>') %>
$.add psaIcon, psa
Header.addShortcut psaIcon, true
@ -173,7 +171,7 @@ Style =
padding: ->
navHeight = Header.bar.offsetHeight
pageHeight = ($ '.pagelist', d.body)?.offsetHeight or 15
Style.sheets.padding.textContent = """<%= grunt.file.read('src/General/css/padding.nav.css').replace(/\s+/g, ' ').trim() %> """ +
Style.sheets.padding.textContent = <%= importCSS('padding.nav') %> +
if pageHeight
"""<%= grunt.file.read('src/General/css/padding.pages.css').replace(/\s+/g, ' ').trim() %>"""
' ' + <%= importCSS('padding.pages') %>
else ''

View File

@ -311,7 +311,7 @@ ThemeTools =
'Inputs': "rgb(#{textColor.rgb()})"
'Warnings': "rgb(#{sageColor.rgb()})"
'Shadow Color': "rbga(0,0,0,0.1)"
'Custom CSS': """<%= grunt.file.read('src/General/css/theme.import.css') %> #{imported.customCSS or ''}"""
'Custom CSS': <%= importCSS('theme.import') %> + " #{imported.customCSS or ''}"
else
Themes[name] = imported