11var pug = require ( 'pug' )
22
3- /**
4- * On page load fetch the parameters via ajax
5- * and save them to window object. Set up mixins object
6- */
7- $ ( document ) . ready ( function ( ) {
8- $ . get ( 'docs/pug/_parameters.pug' , function ( response ) {
9- window . codeMixins = response
10- } )
11-
12- window . mixins = { }
13- } )
14-
153/**
164 * Show code blocks when a show code button is clicked
175 * No JS Fallback: ✅ // Don't show code buttons if js is disabled
@@ -48,13 +36,9 @@ function openCode (component) {
4836 $component . find ( '.result' ) . first ( ) . appendTo ( $html )
4937 }
5038
51- $ . get ( schema . mixinPath || 'pug/components/_' + component + '.pug' , function ( mixin ) {
52- window . mixins [ component ] = mixin
53-
54- updateMixin ( component , $component )
39+ updateMixin ( component , $component )
5540
56- $component . removeClass ( 'loading' )
57- } )
41+ $component . removeClass ( 'loading' )
5842}
5943
6044/**
@@ -136,7 +120,7 @@ function camelToTitle (camelCase) {
136120 */
137121function renderEnum ( params ) {
138122 return pug . render (
139- window . codeMixins + '\n' +
123+ window . components . _parameters + '\n' +
140124 '+docs_select(name, title, id, description, options, selected)' ,
141125 params
142126 )
@@ -149,7 +133,7 @@ function renderEnum (params) {
149133 */
150134function renderBoolean ( params ) {
151135 return pug . render (
152- window . codeMixins + '\n' +
136+ window . components . _parameters + '\n' +
153137 '+docs_radio(name, title, id, description, options, selected)' ,
154138 params
155139 )
@@ -162,7 +146,7 @@ function renderBoolean (params) {
162146 */
163147function renderString ( params ) {
164148 return pug . render (
165- window . codeMixins + '\n' +
149+ window . components . _parameters + '\n' +
166150 '+docs_text(name, title, id, description, value)' ,
167151 params
168152 )
@@ -175,7 +159,7 @@ function renderString (params) {
175159 */
176160function renderNumber ( params ) {
177161 return pug . render (
178- window . codeMixins + '\n' +
162+ window . components . _parameters + '\n' +
179163 '+docs_number(name, title, id, description, value, null, null, 1)' ,
180164 params
181165 )
@@ -188,7 +172,7 @@ function renderNumber (params) {
188172 */
189173function renderJSON ( params ) {
190174 return pug . render (
191- window . codeMixins + '\n' +
175+ window . components . _parameters + '\n' +
192176 '+docs_json(name, title, id, description)' + '\n' +
193177 ' |' + JSON . stringify ( params . value ) ,
194178 params
@@ -320,7 +304,7 @@ function writeMixinCall (component, $component) {
320304 */
321305function renderMixin ( component , mixinCall ) {
322306 return pug . render (
323- window . mixins [ component ] + '\n' + mixinCall ,
307+ window . components [ component ] . mixin + '\n' + mixinCall ,
324308 { pretty : ' ' }
325309 )
326310}
0 commit comments