@@ -51,11 +51,11 @@ window.scalarvis = { instanceCount: -1 };
51
51
base . VisualizationTypes = {
52
52
'force-directed' : 'Force-directed' ,
53
53
'grid' : 'Grid' ,
54
- /*'list': 'List',*/
55
- 'map' : 'Map' ,
54
+ /*'list': 'List',
55
+ 'map': 'Map',*/
56
56
'radial' : 'Radial' ,
57
57
'tree' : 'Tree' ,
58
- 'word-cloud' : 'Word cloud'
58
+ /* 'word-cloud': 'Word cloud'*/
59
59
}
60
60
base . VisualizationContent = {
61
61
"all-content" : "All content" ,
@@ -65,7 +65,7 @@ window.scalarvis = { instanceCount: -1 };
65
65
"tag" : "All tags" ,
66
66
"annotation" : "All annotations" ,
67
67
"media" : "All media" ,
68
- "comment " : "All comments" ,
68
+ "reply " : "All comments" ,
69
69
"current" : "Current page"
70
70
}
71
71
base . VisualizationFilters = {
@@ -171,23 +171,6 @@ window.scalarvis = { instanceCount: -1 };
171
171
172
172
base . controls = $ ( '<div class="vis-controls form-inline form-group-sm"></div>' ) . appendTo ( base . visElement ) ;
173
173
174
- /*var controls_html = '<select class="vis-content-control form-control">';
175
- for (var prop in base.VisualizationContent) {
176
- controls_html += '<option value="' + prop + '">' + base.VisualizationContent[prop] + '</option>';
177
- }
178
- controls_html += '</select> ' +
179
- '<select class="vis-relations-control form-control">' +
180
- '<option value="all">All relationships</option>' +
181
- '<option value="parents-children">Parents and children</option>' +
182
- '<option value="none">No relationships</option>' +
183
- '</select> ' +
184
- '<select class="vis-format-control form-control">' +
185
- '<option value="grid">Grid format</option>' +
186
- '<option value="tree">Tree format</option>' +
187
- '<option value="radial">Radial format</option>' +
188
- '<option value="force-directed">Force-directed format</option>' +
189
- '</select>';*/
190
-
191
174
var controls_html = '<div class="vis-control-header"><b>Type</b></br><select class="vis-type-control form-control">' ;
192
175
for ( var prop in base . VisualizationTypes ) {
193
176
controls_html += '<option value="' + prop + '">' + base . VisualizationTypes [ prop ] + '</option>' ;
@@ -327,8 +310,9 @@ window.scalarvis = { instanceCount: -1 };
327
310
base . options . lens . components [ 0 ] [ 'content-selector' ] [ 'items' ] = [ base . currentNode . slug ] ;
328
311
} else {
329
312
base . options . lens . components [ 0 ] [ 'content-selector' ] [ 'content-type' ] = $ ( this ) . val ( ) ;
330
- base . options . lens . components [ 0 ] [ 'content-selector' ] [ ' items' ] = [ ] ;
313
+ delete base . options . lens . components [ 0 ] [ 'content-selector' ] . items ;
331
314
}
315
+ base . updateLensModifiers ( ) ;
332
316
base . getLensResults ( ) ;
333
317
}
334
318
@@ -356,7 +340,25 @@ window.scalarvis = { instanceCount: -1 };
356
340
"subtype" : "relationship" ,
357
341
"relationship" : base . visElement . find ( ".vis-filter-control" ) . val ( )
358
342
} ;
359
- filter [ "content-types" ] = [ "all-types" ] ;
343
+ let contentControlVal = base . visElement . find ( ".vis-content-control" ) . val ( ) ;
344
+ switch ( contentControlVal ) {
345
+
346
+ case 'all-content' :
347
+ case 'table-of-contents' :
348
+ case 'current' :
349
+ case 'page' :
350
+ filter [ "content-types" ] = [ "all-types" ] ;
351
+ break ;
352
+
353
+ case 'media' :
354
+ filter [ "content-types" ] = [ "reference" ] ;
355
+ break ;
356
+
357
+ default :
358
+ filter [ "content-types" ] = [ contentControlVal ] ;
359
+ break ;
360
+
361
+ }
360
362
base . options . lens . components [ 0 ] . modifiers . push ( filter ) ;
361
363
}
362
364
if ( base . visElement . find ( ".vis-sort-control" ) . val ( ) != 'none' ) {
@@ -1453,7 +1455,9 @@ window.scalarvis = { instanceCount: -1 };
1453
1455
} )
1454
1456
let hasSingleType ;
1455
1457
if ( base . options . lens . components . length === 1 && base . options . lens . components [ 0 ] [ 'content-selector' ] . type === 'items-by-type' ) {
1456
- hasSingleType = base . options . lens . components [ 0 ] [ 'content-selector' ] [ 'content-type' ] ;
1458
+ if ( base . options . lens . components [ 0 ] [ 'content-selector' ] [ 'content-type' ] != 'all-content' ) {
1459
+ hasSingleType = base . options . lens . components [ 0 ] [ 'content-selector' ] [ 'content-type' ] ;
1460
+ }
1457
1461
}
1458
1462
base . updateTypeHierarchy ( false , true , hasSingleType , hasToc ) ;
1459
1463
break ;
@@ -1576,7 +1580,18 @@ window.scalarvis = { instanceCount: -1 };
1576
1580
}
1577
1581
}
1578
1582
1583
+ let isCurrentContent = false ;
1579
1584
if ( base . options . content == "current" ) {
1585
+ isCurrentContent = true ;
1586
+ } else if ( base . options . lens ) {
1587
+ if ( base . options . lens . components [ 0 ] [ 'content-selector' ] . items ) {
1588
+ if ( base . options . lens . components [ 0 ] [ 'content-selector' ] . type == 'items-by-type' && base . options . lens . components [ 0 ] [ 'content-selector' ] . items . length == 1 && base . options . lens . components [ 0 ] [ 'content-selector' ] . items [ 0 ] == base . currentNode . slug ) {
1589
+ isCurrentContent = true ;
1590
+ }
1591
+ }
1592
+ }
1593
+
1594
+ if ( isCurrentContent ) {
1580
1595
1581
1596
// replace the root node with the current node if showing types
1582
1597
// is not a priority
@@ -1612,6 +1627,18 @@ window.scalarvis = { instanceCount: -1 };
1612
1627
}
1613
1628
break ;
1614
1629
1630
+ case "lens" :
1631
+ if ( topLevelType ) {
1632
+ if ( isCurrentContent ) {
1633
+ typeList = [ ] ;
1634
+ } else {
1635
+ typeList = [ topLevelType ] ;
1636
+ }
1637
+ } else {
1638
+ typeList = base . canonicalTypeOrder ;
1639
+ }
1640
+ break ;
1641
+
1615
1642
default :
1616
1643
if ( topLevelType ) {
1617
1644
typeList = [ topLevelType ] ;
@@ -1817,23 +1844,35 @@ window.scalarvis = { instanceCount: -1 };
1817
1844
sourceData . children = [ ] ;
1818
1845
}
1819
1846
o = nodes . length ;
1847
+ let okToProcess ;
1820
1848
for ( j = 0 ; j < o ; j ++ ) {
1821
1849
destNode = nodes [ j ] ;
1822
- base . processNode ( destNode ) ;
1823
- destData = {
1824
- title : destNode . title ,
1825
- shortTitle : destNode . shortTitle ,
1826
- node : destNode ,
1827
- type : destNode . type . id ,
1828
- showsTitle : true ,
1829
- parent : sourceData ,
1830
- children : null ,
1831
- localIndex : sourceData . children . length
1832
- } ;
1833
- sourceData . children . push ( destData ) ;
1834
- if ( base . processedNodesForHierarchy . indexOf ( destNode ) == - 1 ) {
1835
- base . processedNodesForHierarchy . push ( destNode ) ;
1836
- base . addRelationsForHierarchyNode ( destData ) ;
1850
+ okToProcess = true ;
1851
+ // if this is a lens, don't include items not returned by the lens
1852
+ if ( base . options . content == 'lens' ) {
1853
+ if ( base . options . lens . items ) {
1854
+ if ( ! base . options . lens . items [ destNode . url ] ) {
1855
+ okToProcess = false ;
1856
+ }
1857
+ }
1858
+ }
1859
+ if ( okToProcess ) {
1860
+ base . processNode ( destNode ) ;
1861
+ destData = {
1862
+ title : destNode . title ,
1863
+ shortTitle : destNode . shortTitle ,
1864
+ node : destNode ,
1865
+ type : destNode . type . id ,
1866
+ showsTitle : true ,
1867
+ parent : sourceData ,
1868
+ children : null ,
1869
+ localIndex : sourceData . children . length
1870
+ } ;
1871
+ sourceData . children . push ( destData ) ;
1872
+ if ( base . processedNodesForHierarchy . indexOf ( destNode ) == - 1 ) {
1873
+ base . processedNodesForHierarchy . push ( destNode ) ;
1874
+ base . addRelationsForHierarchyNode ( destData ) ;
1875
+ }
1837
1876
}
1838
1877
}
1839
1878
}
@@ -1991,16 +2030,10 @@ window.scalarvis = { instanceCount: -1 };
1991
2030
base . visualization . empty ( ) ;
1992
2031
}
1993
2032
1994
- switch ( base . getFormat ( ) ) {
1995
-
1996
- case "force-directed" :
1997
- if ( base . force != null ) {
1998
- base . force . on ( "tick" , null ) ;
1999
- }
2000
- base . force = null ;
2001
- base . links = [ ] ;
2002
- break ;
2003
-
2033
+ if ( base . getFormat ( ) != 'force-directed' && base . force != null ) {
2034
+ base . force . on ( "tick" , null ) ;
2035
+ base . force = null ;
2036
+ base . links = [ ] ;
2004
2037
}
2005
2038
}
2006
2039
0 commit comments