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
@addClass "_#{@entry.doc.type}" unless @constructor.className
@html content
@prepare?() unless fromCache
@highlightCode() unless fromCache
@activate()
@delay @afterRender if @afterRender
if @highlightNodes.length > 0
$.requestAnimationFrame => $.requestAnimationFrame(@paintCode)
return
highlightCode: (el, language) ->
return unless language
language = "language-#{language}"
if $.isCollection(el)
for e in el
e.classList.add(language)
@highlightNodes.push(e)
else if el
el.classList.add(language)
highlightCode: ->
for el in @findAll('pre[data-language]')
language = el.getAttribute('data-language')
el.classList.add("language-#{language}")
@highlightNodes.push(el)
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'
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:
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:
click: 'onClick'

Loading…
Cancel
Save