8
8
* @requires url-handler.js
9
9
*/
10
10
11
- var panelsViewer = {
11
+ import { Panels } from '@pattern-lab/ui-panels' ;
12
+ import { panelsUtil } from '@pattern-lab/ui-panels-util' ;
13
+ import { urlHandler } from '@pattern-lab/utils/url-handler' ;
14
+ import { Dispatcher } from '@pattern-lab/utils/eventemitter' ;
15
+ import Clipboard from 'clipboard' ;
16
+ import $ from 'jquery' ;
17
+ import Hogan from 'hogan.js' ;
18
+ import prism from 'prismjs' ;
19
+
20
+ export const panelsViewer = {
12
21
// set up some defaults
13
22
targetOrigin :
14
23
window . location . protocol === 'file:'
@@ -26,7 +35,7 @@ var panelsViewer = {
26
35
checkPanels : function ( panels , patternData , iframePassback , switchText ) {
27
36
// count how many panels have rendered content
28
37
var panelContentCount = 0 ;
29
- for ( var i = 0 ; i < panels . length ; ++ i ) {
38
+ for ( let i = 0 ; i < panels . length ; ++ i ) {
30
39
if ( panels [ i ] . content !== undefined ) {
31
40
panelContentCount ++ ;
32
41
}
@@ -84,7 +93,7 @@ var panelsViewer = {
84
93
var e = new XMLHttpRequest ( ) ;
85
94
e . onload = ( function ( i , panels , patternData , iframeRequest ) {
86
95
return function ( ) {
87
- prismedContent = Prism . highlight (
96
+ const prismedContent = Prism . highlight (
88
97
this . responseText ,
89
98
Prism . languages [ 'html' ]
90
99
) ;
@@ -156,7 +165,7 @@ var panelsViewer = {
156
165
patternData . annotations = [ ] ;
157
166
delete patternData [ 'patternMarkup' ] ;
158
167
159
- for ( i = 0 ; i < comments . comments . length ; ++ i ) {
168
+ for ( let i = 0 ; i < comments . comments . length ; ++ i ) {
160
169
item = comments . comments [ i ] ;
161
170
els = markup . querySelectorAll ( item . el ) ;
162
171
@@ -185,7 +194,7 @@ var panelsViewer = {
185
194
186
195
// add hasComma property to lineage
187
196
if ( patternData . lineage . length > 0 ) {
188
- for ( i = 0 ; i < patternData . lineage . length ; ++ i ) {
197
+ for ( let i = 0 ; i < patternData . lineage . length ; ++ i ) {
189
198
if ( i < patternData . lineage . length - 1 ) {
190
199
patternData . lineage [ i ] . hasComma = true ;
191
200
}
@@ -194,7 +203,7 @@ var panelsViewer = {
194
203
195
204
// add hasComma property to lineageR
196
205
if ( patternData . lineageR . length > 0 ) {
197
- for ( i = 0 ; i < patternData . lineageR . length ; ++ i ) {
206
+ for ( let i = 0 ; i < patternData . lineageR . length ; ++ i ) {
198
207
if ( i < patternData . lineageR . length - 1 ) {
199
208
patternData . lineageR [ i ] . hasComma = true ;
200
209
}
@@ -249,12 +258,12 @@ var panelsViewer = {
249
258
) ;
250
259
251
260
// add onclick events to the tabs in the rendered content
252
- for ( i = 0 ; i < panels . length ; ++ i ) {
253
- panel = panels [ i ] ;
261
+ for ( let i = 0 ; i < panels . length ; ++ i ) {
262
+ const panel = panels [ i ] ;
254
263
255
264
// default IDs
256
- panelTab = '#pl-' + patternPartial + '-' + panel . id + '-tab' ;
257
- panelBlock = '#pl-' + patternPartial + '-' + panel . id + '-panel' ;
265
+ const panelTab = '#pl-' + patternPartial + '-' + panel . id + '-tab' ;
266
+ const panelBlock = '#pl-' + patternPartial + '-' + panel . id + '-panel' ;
258
267
259
268
// show default options
260
269
if ( templateRendered . querySelector ( panelTab ) !== null && panel . default ) {
@@ -309,21 +318,29 @@ $('.pl-js-modal-resizer').mousedown(function(event) {
309
318
$ ( '.pl-js-modal-cover' ) . mousemove ( function ( event ) {
310
319
/* 3 */
311
320
var panelHeight = window . innerHeight - event . clientY + 32 ; /* 4 */
321
+ $ ( '.pl-js-modal' ) . css ( 'transition' , 'none' ) ;
322
+ $ ( '.pl-js-vp-iframe-container' ) . css ( 'transition' , 'none' ) ;
312
323
$ ( '.pl-js-modal' ) . css ( 'height' , panelHeight + 'px' ) ; /* 4 */
324
+ $ ( 'html' ) . css (
325
+ '--pl-viewport-height' ,
326
+ window . innerHeight - panelHeight - 32 + 'px'
327
+ ) ; /* 4 */
313
328
} ) ;
314
329
} ) ;
315
330
316
331
$ ( 'body' ) . mouseup ( function ( ) {
317
332
/* 5 */
318
333
$ ( '.pl-js-modal' ) . unbind ( 'mousemove' ) ; /* 5 */
319
334
$ ( '.pl-js-modal-cover' ) . css ( 'display' , 'none' ) ; /* 5 */
335
+ $ ( '.pl-js-modal' ) . css ( 'transition' , '' ) ;
336
+ $ ( '.pl-js-vp-iframe-container' ) . css ( 'transition' , '' ) ;
320
337
} ) ;
321
338
322
339
// Copy to clipboard functionality
323
340
var clipboard = new Clipboard ( '.pl-js-code-copy-btn' ) ;
324
341
clipboard . on ( 'success' , function ( e ) {
325
342
var copyButton = document . querySelectorAll ( '.pl-js-code-copy-btn' ) ;
326
- for ( i = 0 ; i < copyButton . length ; i ++ ) {
343
+ for ( let i = 0 ; i < copyButton . length ; i ++ ) {
327
344
copyButton [ i ] . innerText = 'Copy' ;
328
345
}
329
346
e . trigger . textContent = 'Copied' ;
0 commit comments