Simplify code highlighting

pull/656/head
Thibaut Courouble 8 years ago
parent bd7aec1311
commit 9b28702e3a

@ -10,22 +10,17 @@ class app.views.BasePage extends app.View
@previousTiming = null @previousTiming = null
@addClass "_#{@entry.doc.type}" unless @constructor.className @addClass "_#{@entry.doc.type}" unless @constructor.className
@html content @html content
@prepare?() unless fromCache @highlightCode() unless fromCache
@activate() @activate()
@delay @afterRender if @afterRender @delay @afterRender if @afterRender
if @highlightNodes.length > 0 if @highlightNodes.length > 0
$.requestAnimationFrame => $.requestAnimationFrame(@paintCode) $.requestAnimationFrame => $.requestAnimationFrame(@paintCode)
return return
highlightCode: (el, language) -> highlightCode: ->
return unless language for el in @findAll('pre[data-language]')
language = "language-#{language}" language = el.getAttribute('data-language')
if $.isCollection(el) el.classList.add("language-#{language}")
for e in el
e.classList.add(language)
@highlightNodes.push(e)
else if el
el.classList.add(language)
@highlightNodes.push(el) @highlightNodes.push(el)
return return

@ -1,6 +1,6 @@
#= require views/pages/simple #= require views/pages/base
class app.views.JqueryPage extends app.views.SimplePage class app.views.JqueryPage extends app.views.BasePage
@demoClassName: '_jquery-demo' @demoClassName: '_jquery-demo'
afterRender: -> afterRender: ->

@ -1,6 +1,6 @@
#= require views/pages/simple #= require views/pages/base
class app.views.RdocPage extends app.views.SimplePage class app.views.RdocPage extends app.views.BasePage
@events: @events:
click: 'onClick' click: 'onClick'

@ -1,80 +0,0 @@
#= require views/pages/base
class app.views.SimplePage extends app.views.BasePage
prepare: ->
for el in @findAll('pre[data-language]')
@highlightCode el, el.getAttribute('data-language')
return
app.views.AngularPage =
app.views.AngularjsPage =
app.views.AsyncPage =
app.views.BootstrapPage =
app.views.BowerPage =
app.views.CPage =
app.views.CakephpPage =
app.views.ChaiPage =
app.views.CodeceptionPage =
app.views.CodeceptjsPage =
app.views.CoffeescriptPage =
app.views.CordovaPage =
app.views.CrystalPage =
app.views.D3Page =
app.views.DockerPage =
app.views.DojoPage =
app.views.DrupalPage =
app.views.ElectronPage =
app.views.ElixirPage =
app.views.EmberPage =
app.views.ErlangPage =
app.views.ExpressPage =
app.views.FlowPage =
app.views.GithubPage =
app.views.GoPage =
app.views.GruntPage =
app.views.ImmutablePage =
app.views.InfluxdataPage =
app.views.JasminePage =
app.views.JestPage =
app.views.KnockoutPage =
app.views.KotlinPage =
app.views.LaravelPage =
app.views.LodashPage =
app.views.LovePage =
app.views.LuaPage =
app.views.MarionettePage =
app.views.MdnPage =
app.views.MeteorPage =
app.views.MochaPage =
app.views.ModernizrPage =
app.views.MomentPage =
app.views.MongoosePage =
app.views.NginxPage =
app.views.NodePage =
app.views.OpenjdkPage =
app.views.PerlPage =
app.views.PhalconPage =
app.views.PhaserPage =
app.views.PhpPage =
app.views.PhpunitPage =
app.views.PostgresPage =
app.views.RamdaPage =
app.views.ReactPage =
app.views.ReduxPage =
app.views.RequirejsPage =
app.views.RethinkdbPage =
app.views.RubydocPage =
app.views.RustPage =
app.views.SinonPage =
app.views.SocketioPage =
app.views.SphinxPage =
app.views.SphinxSimplePage =
app.views.TensorflowPage =
app.views.TypescriptPage =
app.views.UnderscorePage =
app.views.VagrantPage =
app.views.VuePage =
app.views.WebpackPage =
app.views.YarnPage =
app.views.YiiPage =
app.views.SimplePage

@ -1,6 +1,6 @@
#= require views/pages/simple #= require views/pages/base
class app.views.SqlitePage extends app.views.SimplePage class app.views.SqlitePage extends app.views.BasePage
@events: @events:
click: 'onClick' click: 'onClick'

Loading…
Cancel
Save