@@ -14,7 +14,7 @@ FramePatternMatcher.testRules = function(rules, frame, onmatch){
14
14
var matched_rules = [ ] ;
15
15
if ( rules && rules . length ) {
16
16
for ( var i = 0 ; i < rules . length ; i ++ ) {
17
- var match = ( ! rules [ i ] . pattern || FramePatternMatcher . patternMatchesFrame ( rules [ i ] . pattern , frame ) ) ;
17
+ var match = ( ! rules [ i ] . rule . pattern || FramePatternMatcher . patternMatchesFrame ( rules [ i ] . rule . pattern , frame ) ) ;
18
18
if ( match ) {
19
19
matched_rules . push ( rules [ i ] ) ;
20
20
if ( onmatch && typeof onmatch == "function" ) {
@@ -306,47 +306,162 @@ function FrameRule(){
306
306
return this ;
307
307
}
308
308
309
+ FrameRule . prototype . prettyPrint = function ( type ) {
310
+ //starts with obj. ...
311
+ if ( this . scope ( ) == "*" ) {
312
+ var str = ".all()" ;
313
+ }
314
+ else {
315
+ var str = "." + this . scope ( ) + "()" ;
316
+ }
317
+ if ( typeof this . frameType ( ) != "undefined" ) {
318
+ str += ".frame_type(" + JSON . stringify ( this . frameType ( ) ) + ")" ;
319
+ }
320
+ if ( typeof this . label ( ) != "undefined" ) {
321
+ str += ".label(" + JSON . stringify ( this . label ( ) ) + ")" ;
322
+ }
323
+ if ( typeof this . subject ( ) != "undefined" ) {
324
+ str += ".subject(" + JSON . stringify ( this . subject ( ) ) + ")" ;
325
+ }
326
+ if ( typeof this . subjectClass ( ) != "undefined" ) {
327
+ str += ".subjectClass(" + JSON . stringify ( this . subjectClass ( ) ) + ")" ;
328
+ }
329
+ if ( typeof this . property ( ) != "undefined" ) {
330
+ str += ".property(" + JSON . stringify ( this . property ( ) ) + ")" ;
331
+ }
332
+ if ( typeof this . range ( ) != "undefined" ) {
333
+ str += ".range(" + JSON . stringify ( this . range ( ) ) + ")" ;
334
+ }
335
+ if ( typeof this . value ( ) != "undefined" ) {
336
+ str += ".value(" + JSON . stringify ( this . range ( ) ) + ")" ;
337
+ }
338
+ if ( typeof this . children ( ) != "undefined" ) {
339
+ str += ".children(\n" ;
340
+ var kids = this . children ( ) ;
341
+ for ( var i = 0 ; i < kids . length ; i ++ ) {
342
+ str += kids . prettyPrint ( ) + "\n" ;
343
+ }
344
+ str += ")" ;
345
+ }
346
+ if ( typeof this . parent ( ) != "undefined" ) {
347
+ str += ".parent(" + this . parent . prettyPrint ( ) + ")" ;
348
+ }
349
+ if ( typeof this . depth ( ) != "undefined" ) {
350
+ str += ".depth('" + this . depth ( ) + "')" ;
351
+ }
352
+ if ( typeof this . index ( ) != "undefined" ) {
353
+ str += ".index(" + JSON . stringify ( this . index ( ) ) + ")" ;
354
+ }
355
+ if ( typeof this . status ( ) != "undefined" ) {
356
+ str += ".status(" + JSON . stringify ( this . status ( ) ) + ")" ;
357
+ }
358
+ if ( typeof this . args ( ) != "undefined" ) {
359
+ str += ".args(" + JSON . stringify ( this . status ( ) ) + ")" ;
360
+ }
361
+ if ( typeof this . renderer ( ) != "undefined" ) {
362
+ str += ".renderer('" + this . renderer ( ) + "')" ;
363
+ }
364
+ if ( typeof this . render ( ) != "undefined" ) {
365
+ str += ".render(" + this . render ( ) + ")" ;
366
+ }
367
+ if ( typeof this . compare ( ) != "undefined" ) {
368
+ str += ".compare(" + this . compare ( ) + ")" ;
369
+ }
370
+ if ( typeof this . mode ( ) != "undefined" ) {
371
+ str += ".mode('" + this . mode ( ) + "')" ;
372
+ }
373
+ if ( typeof this . collapse ( ) != "undefined" ) {
374
+ str += ".collapse(" + this . collapse ( ) + ")" ;
375
+ }
376
+ if ( typeof this . hidden ( ) != "undefined" ) {
377
+ str += ".hidden(" + this . hidden ( ) + ")" ;
378
+ }
379
+ if ( typeof this . view ( ) != "undefined" ) {
380
+ str += ".view('" + this . view ( ) + "')" ;
381
+ }
382
+ if ( typeof this . showDisabledButtons ( ) != "undefined" ) {
383
+ str += ".showDisabledButtons(" + this . showDisabledButtons ( ) + ")" ;
384
+ }
385
+ if ( typeof this . header ( ) != "undefined" ) {
386
+ str += ".header(" + this . header ( ) + ")" ;
387
+ }
388
+ if ( typeof this . features ( ) != "undefined" ) {
389
+ str += ".features(" + JSON . stringify ( this . features ( ) ) + ")" ;
390
+ }
391
+ if ( typeof this . headerFeatures ( ) != "undefined" ) {
392
+ str += ".headerFeatures(" + JSON . stringify ( this . headerFeatures ( ) ) + ")" ;
393
+ }
394
+ if ( typeof this . showEmpty ( ) != "undefined" ) {
395
+ str += ".showEmpty(" + this . show_empty ( ) + ")" ;
396
+ }
397
+ if ( typeof this . dataviewer ( ) != "undefined" ) {
398
+ str += ".dataviewer('" + this . dataviewer ( ) + "')" ;
399
+ }
400
+ if ( typeof this . args ( ) != "undefined" ) {
401
+ str += ".args(" + JSON . stringify ( this . args ( ) ) + ")" ;
402
+ }
403
+ if ( typeof this . featureRenderers ( ) != "undefined" ) {
404
+ str += ".featureRenderers({" ;
405
+ for ( var f in this . featureRenderers ( ) ) {
406
+ str += JSON . stringify ( f ) + ":" + this . rule . feature_renderers [ f ] + "," ;
407
+ }
408
+ str = str . substring ( 0 , str . length - 1 ) ;
409
+ str += "})" ;
410
+ }
411
+ return str ;
412
+ }
413
+
414
+
309
415
FrameRule . prototype . scope = function ( scope ) {
416
+ if ( typeof scope == "undefined" ) return this . rule . pattern . scope ;
310
417
this . rule . pattern . scope = scope ;
311
418
return this ;
312
419
}
313
420
314
- FrameRule . prototype . frame_type = function ( ...frametype ) {
421
+ FrameRule . prototype . frameType = function ( ...frametype ) {
422
+ if ( typeof frametype == "undefined" || frametype . length == 0 ) return this . rule . pattern . frametype ;
315
423
this . rule . pattern . frametype = frame_type ;
316
424
return this ;
317
425
}
318
426
319
427
FrameRule . prototype . label = function ( ...label ) {
428
+ if ( typeof label == "undefined" || label . length == 0 ) return this . rule . pattern . label ;
320
429
this . rule . pattern . label = label ;
321
430
return this ;
322
431
}
323
432
324
433
FrameRule . prototype . subject = function ( ...subject ) {
434
+ if ( typeof subject == "undefined" || subject . length == 0 ) return this . rule . pattern . subject ;
325
435
this . rule . pattern . subject = subject ;
326
436
return this ;
327
437
}
328
438
329
439
FrameRule . prototype . subjectClass = function ( ...subjectClass ) {
440
+ if ( typeof subjectClass == "undefined" || subjectClass . length == 0 ) return this . rule . pattern . subjectClass ;
330
441
this . rule . pattern . subjectClass = subjectClass ;
331
442
return this ;
332
443
}
333
444
334
445
FrameRule . prototype . property = function ( ...property ) {
446
+ if ( typeof property == "undefined" || property . length == 0 ) return this . rule . pattern . property ;
335
447
this . rule . pattern . property = property ;
336
448
return this ;
337
449
}
338
450
339
451
FrameRule . prototype . depth = function ( depth ) {
452
+ if ( typeof depth == "undefined" ) return this . rule . pattern . depth ;
340
453
this . rule . pattern . depth = depth ;
341
454
return this ;
342
455
}
343
456
344
457
FrameRule . prototype . range = function ( ...range ) {
458
+ if ( typeof range == "undefined" || range . length == 0 ) return this . rule . pattern . range ;
345
459
this . rule . pattern . range = range ;
346
460
return this ;
347
461
}
348
462
349
463
FrameRule . prototype . value = function ( ...value ) {
464
+ if ( typeof value == "undefined" || value . length == 0 ) return this . rule . pattern . value ;
350
465
this . rule . pattern . value = value ;
351
466
return this ;
352
467
}
@@ -360,11 +475,13 @@ FrameRule.prototype.json = function(){
360
475
}
361
476
362
477
FrameRule . prototype . parent = function ( parent ) {
478
+ if ( typeof parent == "undefined" ) return this . rule . pattern . parent ;
363
479
this . rule . pattern . parent = parent . pattern ( ) ;
364
480
return this ;
365
481
}
366
482
367
483
FrameRule . prototype . children = function ( ...children ) {
484
+ if ( typeof children == "undefined" ) return this . rule . pattern . children ;
368
485
if ( typeof this . rule . pattern . children == "undefined" ) {
369
486
this . rule . pattern . children = [ ] ;
370
487
}
@@ -375,11 +492,13 @@ FrameRule.prototype.children = function(...children){
375
492
}
376
493
377
494
FrameRule . prototype . index = function ( ...index ) {
495
+ if ( typeof index == "undefined" || index . length == 0 ) return this . rule . pattern . index ;
378
496
this . rule . pattern . index = index ;
379
497
return this ;
380
498
}
381
499
382
500
FrameRule . prototype . status = function ( ...status ) {
501
+ if ( typeof status == "undefined" || status . length == 0 ) return this . rule . pattern . status ;
383
502
this . rule . pattern . status = status ;
384
503
return this ;
385
504
}
@@ -435,20 +554,20 @@ FrameRule.prototype.view = function(m){
435
554
return this ;
436
555
}
437
556
438
- FrameRule . prototype . show_disabled_buttons = function ( m ) {
557
+ FrameRule . prototype . showDisabledButtons = function ( m ) {
439
558
if ( ! m ) return this . rule . show_disabled_buttons ;
440
- this . rule . hide_disabled_buttons = m ;
559
+ this . rule . show_disabled_buttons = m ;
441
560
return this ;
442
561
}
443
562
444
- FrameRule . prototype . features = function ( m ) {
445
- if ( ! m ) return this . rule . features ;
563
+ FrameRule . prototype . features = function ( ... m ) {
564
+ if ( typeof m == "undefined" || m . length == 0 ) return this . rule . features ;
446
565
this . rule . features = m ;
447
566
return this ;
448
567
}
449
568
450
- FrameRule . prototype . header_features = function ( m ) {
451
- if ( ! m ) return this . rule . header_features ;
569
+ FrameRule . prototype . headerFeatures = function ( ... m ) {
570
+ if ( typeof m == "undefined" || m . length == 0 ) return this . rule . header_features ;
452
571
this . rule . header_features = m ;
453
572
return this ;
454
573
}
@@ -459,13 +578,13 @@ FrameRule.prototype.header = function(m){
459
578
return this ;
460
579
}
461
580
462
- FrameRule . prototype . feature_renderers = function ( m ) {
581
+ FrameRule . prototype . featureRenderers = function ( m ) {
463
582
if ( ! m ) return this . rule . feature_renderers ;
464
583
this . rule . feature_renderers = m ;
465
584
return this ;
466
585
}
467
586
468
- FrameRule . prototype . show_empty = function ( m ) {
587
+ FrameRule . prototype . showEmpty = function ( m ) {
469
588
if ( ! m ) return this . rule . show_empty ;
470
589
this . rule . show_empty = m ;
471
590
return this ;
@@ -477,10 +596,4 @@ FrameRule.prototype.dataviewer = function(m){
477
596
return this ;
478
597
}
479
598
480
- FrameRule . prototype . dataviewer_options = function ( m ) {
481
- if ( ! m ) return this . rule . dataviewer_options ;
482
- this . rule . dataviewer_options = m ;
483
- return this ;
484
- }
485
-
486
599
module . exports = { FramePatternMatcher, FramePattern, FrameRule } ;
0 commit comments