-
Notifications
You must be signed in to change notification settings - Fork 14
/
New-Region.ps1
2563 lines (2131 loc) · 101 KB
/
New-Region.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
function New-Region
{
<#
.Synopsis
Creates a new web region.
.Description
Creates a new web region. Web regions are lightweight HTML controls that help you create web pages.
.Link
New-Webpage
.Example
# Makes a JQueryUI tab
New-Region -Layer @{
"Tab1" = "Content In Tab One"
"Tab2" = "Content in Tab Two"
} -AsTab
.Example
# Makes a JQueryUI accordian
New-Region -Layer @{
"Accordian1" = "Content In The first Accordian"
"Accordian1" = "Content in the second Accordian"
} -AsAccordian
.Example
# Makes an empty region
New-Region -Style @{} -Content "My Layer" -LayerID MyId
.Example
# A Centered Region containing Microdata
New-Region -ItemType http://schema.org/Event -Style @{
'margin-left' = '7.5%'
'margin-right' = '7.5%'
} -Content '
<a itemprop="url" href="nba-miami-philidelphia-game3.html">
NBA Eastern Conference First Round Playoff Tickets:
<span itemprop="name"> Miami Heat at Philadelphia 76ers - Game 3 (Home Game 1) </span> </a>
<meta itemprop="startDate" content="2016-04-21T20:00"> Thu, 04/21/16 8:00 p.m.
<div itemprop="location" itemscope itemtype="http://schema.org/Place">
<a itemprop="url" href="wells-fargo-center.html"> Wells Fargo Center </a>
<div itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">
<span itemprop="addressLocality">Philadelphia</span>, <span itemprop="addressRegion">PA</span>
</div>
</div>
<div itemprop="offers" itemscope itemtype="http://schema.org/AggregateOffer">
Priced from: <span itemprop="lowPrice">$35</span> <span itemprop="offerCount">1938</span> tickets left
</div>'
.Notes
The Parameter set design on New-Region is a little complex.
There are two base parameter sets, raw layer content (-Content) and structured layer content (-Layer)
In each case, parameters named -As* determine how the actual layer will be rendered.
To make matters more complex, different -As* parameters require different JavaScript frameworks
#>
[CmdletBinding(DefaultParameterSetName='Content')]
[OutputType([string])]
param(
# The content within the region. This content will be placed on an unnamed layer.
[Parameter(ParameterSetName='Content',Position=0,ValueFromPipeline=$true)]
[string[]]$Content,
# A set of layer names and layer content
[Parameter(ParameterSetName='Layer',Position=0)]
[Alias('Item')]
[Hashtable]$Layer,
# A set of layer names and layer URLs. Any time the layer is brought up, the content will be loaded via AJAX
[Parameter(ParameterSetName='Layer')]
[Hashtable]$LayerUrl = @{},
# A set of layer direct links
[Parameter(ParameterSetName='Layer')]
[Hashtable]$LayerLink = @{},
# The order the layers should appear. If this is not set, the order will
# be the alphabetized list of layer names.
[Parameter(ParameterSetName='Layer')]
[Alias('LayerOrder')]
[string[]]$Order,
# The default layer. If this is not set and if -DefaultToFirst is not set, a layer
# will be randomly chosen.
[Parameter(ParameterSetName='Layer')]
[string]$Default,
# The default layer. If this is not set and if -DefaultToFirst is not set, a layer
# will be randomly chosen.
[Parameter(ParameterSetName='Layer')]
[switch]$DefaultToFirst,
# The Name of the the container. The names becomes the HTML element ID of the root container.
[Alias('Container')]
[Alias('Id')]
[string]$LayerID = 'Layer',
# The percentage margin on the left. The region will appear this % distance from the side of the screen, regardless of resolution
[Parameter(ValueFromPipelineByPropertyName=$true,Position=1)]
[ValidateRange(0,100)]
[Double]$LeftMargin = 2.5,
# The percentage margin on the right. The region will appear this % distance from the side of the screen, regardless of resolution
[Parameter(ValueFromPipelineByPropertyName=$true,Position=2)]
[ValidateRange(0,100)]
[Double]$RightMargin = 2.5,
# The percentage margin on the top. The region will appear this % distance from the top of the screen, regardless of resolution
[Parameter(ValueFromPipelineByPropertyName=$true,Position=3)]
[ValidateRange(0,100)]
[Double]$TopMargin = 10,
# The percentage margin on the bottom. The region will appear this % distance from the bottom of the screen, regardless of resolution
[Parameter(ValueFromPipelineByPropertyName=$true,Position=4)]
[ValidateRange(0,100)]
[Double]$BottomMargin = 10,
# The border for the region. Becomes the CSS border attribute of the main container
[string]$Border = "1px solid black",
# If set, hides the forward and back buttons
[switch]$HideDirectionButton,
# If set, hides the more button
[switch]$HideMoreButton,
# If set, hides the title area
[switch]$HideTitleArea,
# If set, shows a horizontal rule under the title
[switch]$HorizontalRuleUnderTitle,
# If set, places the toolbar above
[switch]$ToolbarAbove,
# The margin of the toolbar
[int]$ToolbarMargin,
# URL for a logo to go on the title of each page
[uri]$Logo,
# If set, the control will not be aware of the web request string.
# Otherwise, a URL can provide which layer of a region to show.
[switch]$NotRequestAware,
# If set, the region will have any commands to change its content,
# and will only have one layer
[switch]$IsStaticRegion,
# If set, turns off fade effects
[switch]$NotCool,
# The transition time for all fade effects. Defaults to 200ms
[Timespan]$TransitionTime = "0:0:0.2",
# The layer heading size
[ValidateRange(1, 6)]
[Uint32]$LayerHeadingSize = 2,
# The number of keyframes in all transitions
[ValidateRange(10, 100)]
[Uint32]$KeyFrameCount = 10,
# If set, enables a pan effect within the layers
[Switch]$CanPan,
# If set, the entire container can be dragged
[Switch]$CanDrag,
# The scroll speed (when on iOs or webkit)
[int]$ScrollSpeed = 25,
# The CSS class to use
[string[]]$CssClass,
# A custom CSS style.
[Hashtable]$Style,
# If set, the layer will not be automatically resized, and percentage based margins will be ignored
[switch]$FixedSize,
# If set, will not allow the contents of the layer to be switched
[switch]$DisableLayerSwitcher,
# If set, will automatically switch the contents on an interval
[Parameter(ParameterSetName='Layer')]
[Timespan]$AutoSwitch = "0:0:4",
# If set, will create the region as an JQueryUI Accordion.
[Parameter(ParameterSetName='Layer')]
[Switch]$AsAccordian,
# If set, will create the region as an JQueryUI Tab.
[Parameter(ParameterSetName='Layer')]
[Switch]$AsTab,
# If set, the JQueryUI tab will appear below the content, instead of above
[Parameter(ParameterSetName='Layer')]
[Switch]$TabBelow,
# If set, will open the tabs on a mouseover event
[Switch]$OpenOnMouseOver,
# If set, will create a set of popout regions. When the tile of each layer is clicked, the layer will be shown.
[Parameter(ParameterSetName='Layer')]
[Switch]$AsPopout,
# If set, will create a set of popdown regions. As region is clicked, the underlying content will be shown below.
[Parameter(ParameterSetName='Layer')]
[Switch]$AsPopdown,
# If set, will create a set of popdown regions. As region is clicked, the underlying content will be shown below.
[Parameter(ParameterSetName='Layer')]
[Switch]$AsPopIn,
# If set, will create a slide of the layers. If a layer title is clicked, the slideshow will stop
[Parameter(ParameterSetName='Layer')]
[Switch]$AsSlideShow,
# If set, the layer will be created as a portlet
[Parameter(ParameterSetName='Layer')]
[Switch]$AsPortlet,
# If set, the layer will be created as a newspaper
[Parameter(ParameterSetName='Layer')]
[Switch]$AsNewspaper,
# If set, the newspaper headline buttons will be underlined
[Switch]$UnderlineNewspaperHeadline,
# If set, newspaper headlines will be displayed as buttons
[Switch]$UseButtonForNewspaperHeadline,
# The alignment used for the heading in a newspaper
[ValidateSet("left", "center", "right")]
[string]$NewspaperHeadingAlignment = "left",
# The size of the headings in a newspaper
[ValidateRange(1,6)]
[Uint32]
$NewspaperHeadingSize = 2,
# The width of the columns in the newspaper
[Float[]]$NewspaperColumn = @(.67, .33, .5, .5, 1),
# The columns that will be expanded
[string[]]$ExpandNewspaperColumn = @(0, 1, 2, 3),
# The number of columns in a Portlet
[Uint32]$ColumnCount = 2,
# The width of a column within a Portlet
[string]$ColumnWidth,
# If set, will create a set of JQueryUI buttons which popup JQueryUI dialogs
[Switch]$AsPopup,
# If set, will create a set of JQueryUI simple widgets
[Switch]$AsWidget,
# If set, will create the layer as a series of resizable items
[Switch]$AsResizable,
# If set, will create the layer as a series of draggable items
[Switch]$AsDraggable,
# If set, the layer will be created as a left sidebar menu
[switch]$AsLeftSidebarMenu,
# If set, the layer will be created as a right sidebar menu
[Switch]$AsRightSidebarMenu,
# If set, the layer will be created as a grid
[Switch]$AsGrid,
# If set, the layer will be created as a menu
[Switch]$AsMenu,
# If set, the layer will be created as a Bootstrap navbar menu
[Switch]$AsNavbar,
# If set, the layer will be created as a Bootstrap carousel
[Switch]$AsCarousel,
# If set, the layer will be created as set of Bootstrap headlines
[Switch]$AsHeadline,
# If set, the layer will be created as set of Bootstrap buttons
[Switch]$AsButton,
# If set, the content will be displayed as a tree
[Switch]$AsTree,
# If set, the content will be displayed as a series of columns
[Switch]$AsColumn,
# The color of the branch in a tree
[string]$BranchColor = '#000000',
# If set, will show large item titles for items in the carousel
[switch]$ShowLayerTitle,
# If set, the layer will be created as a Bootstrap featurette
[Switch]$AsFeaturette,
# If set, the layer will be created as a Bootstrap row
[Switch]$AsRow,
# If set, the layer will be created as pair of Bootstrap rows, with content expanding down in the right half of the grid.
[Switch]$AsHangingSpan,
# The size (in Bootstrap spans) of the buttons used in -AsHangingSpan.
# The size of the hanging area will be the remainder of the 12 span grid, with one span reserved for offset
[Uint32]$SpanButtonSize = 2,
# The Bootstrap RowSpan
[string[]]$RowSpan = 'span4',
# The width of items within a grid
[Uint32]$GridItemWidth = 175,
# The height of items within a grid
[Uint32]$GridItemHeight = 112,
# The width of a sidebar in a left or right sidebar menu
[ValidateRange(1,100)]
[Uint32]$SidebarWidth = 20,
# One or more item types to apply to the region. If set, an itemscope and itemtype will be added to the region
[string[]]
$ItemType,
# If set, will use a vector (%percentage based layout) for the region.
[Switch]
$AsVectorLayout,
# If set, will hide the slide name buttons (effectively creating an endless slideshow)
[switch]
$HideSlideNameButton,
# If set, will use a middot instead of a slide name for a slideshow button.
[switch]
$UseDotInsteadOfName,
# The background color in a popin
[string]
$MenuBackgroundColor,
# The inner order within a
[Hashtable]
$LayerInnerOrder
)
begin {
# Creates an ID out of any input string
$getSafeLayerName = {
param($layerName)
$layerName.Replace(" ", "_space_").Replace("-", "").Replace("+", "").Replace("!", "_bang_").Replace(",", "").Replace("<", "").Replace(">","").Replace("'", "").Replace('"','').Replace('=', '').Replace('&', '').Replace('?', '').Replace("/", "").Replace(",", "_").Replace("|", "_").Replace(":","_").Replace(".", "_").Replace("@", "_at_").Replace("(", "-__").Replace(")","__-").Replace("#", "_Pound_").Replace('%', '_Percent_')
}
# Gets ajax script for a url
$getAjaxAndPutIntoContainer = {
param($url, $container, $UrlType)
if ($url -like "*.zip" -or
$url -like "*.exe" -or
$UrlType -eq 'Button') {
@"
window.location = '$url';
"@
} else {
$xmlHttpVar = "xmlRequest${Container}"
@"
var $xmlHttpVar;
if (window.XMLHttpRequest)
{
$xmlHttpVar = new XMLHttpRequest(); // code for IE7+, FireFox, Chrome, Opera, Safari
} else
{
$xmlHttpVar = new ActiveXObject("Microsoft.XMLHTTP"); // code for IE5, IE6
}
$xmlHttpVar.onreadystatechange = function() {
if (${xmlHttpVar}.readyState == 4) {
if (${xmlHttpVar}.status == 200) {
document.getElementById("${Container}").innerHTML = $xmlHttpVar.responseText;
var innerScripts = document.getElementById("${Container}").getElementsByTagName("script");
for(var i=0;i<innerScripts.length;i++)
{
try {
eval(innerScripts[i].text);
} catch (e) {
}
}
window.${Container}_Response = $xmlHttpVar.responseText;
} else {
document.getElementById("${Container}").innerHTML = $xmlHttpVar.Status;
}
} else {
window.show${Container}loading = function () {
var ih = document.getElementById("${Container}").innerHTML;
if (ih.length < 40) {
ih += "·"
} else {
ih = "·"
}
if (window.${Container}_Response == null) {
document.getElementById("${Container}").innerHTML= ih;
setTimeout('show${Container}loading()', 75);
}
}
setTimeout('show${Container}loading()', 75);
}
}
if (window.${Container}_Response == null) {
$xmlHttpVar.open('POST', "$Url", true);
$xmlHttpVar.send();
document.getElementById("${Container}").innerHTML = "·"
}
"@
}
}
$ShowLayerContent = {
param($showButtonId,
$popoutLayerId,
[string[]]$AdditionalElements,
[Switch]$Exclusive,
[Switch]$StopSlideShow,
[Switch]$IsCurrentSlide,
[string]$ShownState = 'inline')
@"
<script>
var ${LayerId}_currentSlide = $(if ($isCurrentSlide) { "'$popoutLayerId'"} else {'null'});
window.${ShowButtonId}_click = function () {
$(
if ($layerUrl -and $layerUrl[$layerName]) {
. $getAjaxAndPutIntoContainer $layerUrl[$layerName] $popoutLayerId
} elseif ($LayerLink -and $LayerLink[$layerName]) {
. $getAjaxAndPutIntoContainer $LayerLink[$layerName] $popoutLayerId "Button"
} else {
""
})
$(if ($Exclusive) {
"
if (${LayerId}_currentSlide != null) {
var documentElement = document.getElementById(${LayerId}_currentSlide);
documentElement.style.display = 'none';
}
"
})
$(
$AdditionalElements = @($popoutLayerId) + $AdditionalElements
foreach ($el in $AdditionalElements) {
if (-not $el) { continue }
"
var documentElement = document.getElementById('$el');
if (documentElement != null && documentElement.style.display == 'none') {
documentElement.style.display = '$ShownState';
} else {
if (documentElement != null) {
documentElement.style.display = 'none';
}
}
"
}
)
${LayerId}_currentSlide = '$popoutLayerId';
$(if ($StopSlideShow) {
"clearInterval(${LayerId}_SlideshowTimer);
for (i =0; i < ${LayerId}_SlideNames.length; i++) {
if (${LayerId}_SlideNames[i] != '$popoutLayerId') {
document.getElementById(${LayerId}_SlideNames[i]).style.display = 'none';
}
}
"
})
}
</script>
"@
}
$GetLayerContent = {
param($originalParameters)
@"
$(
if ($layer[$layerName] -is [Hashtable]) {
$parameterCopy = @{} + $originalParameters
$parameterCopy.Layer = $layer[$layerName]
$parameterCopy.Order = if ($layer[$layerName].InnerOrder) {
$layer[$layerName].InnerOrder
} else {
$layer[$layerName].Keys | Sort-Object
}
$parameterCopy.LayerId = $LayerID + "_" + $layerName + "_items"
$innerLayerOrder = $layer[$layerName].Keys | Sort-Object
New-Region @parameterCopy
} elseif ($layer[$layername] -is [string]) {
$layer[$layerName]
} elseif ($layer[$layerName]) {
$layer[$layerName] | Out-HTML
})
"@
}
$layerCount = 0
$originalLayerId = $layerId
}
process {
if ($layerCount -gt 0) {
$layerId = $originalLayerId + $layerCount
}
$layerCount++
#region Internal changing of parameters of parameter set overlaps
if ($psCmdlet.ParameterSetName -eq 'Content') {
if (-not $Layer) {
$Layer = @{}
}
$Layer.'Default' = $Content
$hideTitleArea = $true
$hideDirectionButton = $true
$hideMoreButton = $true
if (-not $asVectorLayout) {
$DisableLayerSwitcher = $true
}
}
$layerId= . $getSafeLayerName $layerId
if ($psBoundParameters.AutoSwitch -and (-not $AsSlideshow)) {
$DisableLayerSwitcher = $false
$NotRequestAware = $true
}
if ($AsAccordian -or $AsTab -or $AsPopout -or $asPopin -or $AsPopdown -or $asPopup -or
$asSlideshow -or $AsWidget -or $AsPortlet -or $AsLeftSidebarMEnu -or $ASRightSidebarMenu -or
$AsResizable -or $AsDraggable -or $AsGrid -or $AsNavbar -or $AsCarousel -or $asHeadline -or
$Asbutton -or $asTree -or $AsFeaturette -or $AsRow -or $AsColumn -or $AsHangingSpan -or $AsMenu -or $AsNewspaper) {
$NotRequestAware = $true
$IsStaticRegion = $true
$DisableLayerSwitcher = $true
$FixedSize = $true
} elseif (-not $AsVectorLayout -and -not $psboundParameters.Style -and -not $psBoundParameters.Keys -like "*as*") {
$NotRequestAware = $true
$IsStaticRegion = $true
$DisableLayerSwitcher = $true
$FixedSize = $true
if ($layer.Count -eq 1) {
$AsWidget = $true
$AsResizable = $true
} elseif ($layer.Count -le 5) {
$AsTab = $true
} else {
$AsAccordian = $true
}
}
if ($Style) {
$FixedSize = $true
}
if ($FixedSize) {
$HideDirectionButton = $true
$HideMoreButton = $true
# DCR : Make -*Margin turn into styles
if (-not $style) {
$style= @{}
}
if ($psBoundParameters.LeftMargin) {
$style["margin-left"] = "${LeftMargin}%"
}
if ($psBoundParameters.RightMargin) {
$style["margin-right"] = "${RightMargin}%"
}
if ($psBoundParameters.TopMargin) {
$style["margin-top"] = "${TopMargin}%"
}
if ($psBoundParameters.BottomMargin) {
$style["margin-bottom"] = "${BottomMargin}%"
}
if ($psBoundParameters.Border) {
$style["border"] = "$border"
}
}
if ($isStaticRegion) {
$hideTitleArea = $true
$HideMoreButton = $true
$hideDirectionButton = $true
}
#endregion Internal changing of parameters of parameter set overlaps
if (-not $psBoundParameters.Default) {
$randomOnLoad = ""
}
if (-not $psBoundParameters.Order) {
$order = $layer.Keys |Sort-Object
}
$layerTitleAreaText =if (-not $HideTitleArea) { "
<div style='margin-top:5px;margin-right:5px;z-index:-1' id='${LayerID}_TitleArea' NotALayer='true'>
</div>
"
} else {
""
}
$fadeJavaScriptFunctions = if (-not $NotCool) {
@"
function set${LayerID}LayerOpacity(id, opacityLevel)
{
var eStyle = document.getElementById(id).style;
eStyle.opacity = opacityLevel / 100;
eStyle.filter = 'alpha(opacity='+opacityLevel+')';
if (eStyle.filter != 'alpha(opacity=0)') {
eStyle.visibility = 'visible'
}
if (opacityLevel > 0) {
eStyle.visibility = 'visible'
} else {
eStyle.visibility = 'hidden'
}
}
function fade${LayerID}Layer(eID, startOpacity, stopOpacity, duration, steps) {
if (steps == null) { steps = duration }
var opacityStep = (stopOpacity - startOpacity) / steps;
var timerStep = duration / steps;
var timeStamp = 10
var opacity = startOpacity
for (var i=0; i < steps;i++) {
opacity += opacityStep
timeStamp += timerStep
setTimeout("set${LayerID}LayerOpacity('"+eID+"',"+opacity+")", timeStamp);
}
return
}
"@
} else { ""}
$dragChunk= if ($CanDrag) { @"
if (document.getElementById('$LayerID').addEventListener) {
document.getElementById('$LayerID').addEventListener('touchmove', function(e) {
e.preventDefault();
curX = e.targetTouches[0].pageX;
curY = e.targetTouches[0].pageY;
document.getElementById('$LayerID').style.webkitTransform = 'translate(' + curX + 'px, ' + curY + 'px)'
})
}
"@ } else { ""}
$enablePanChunk = if ($CanPan) { @"
var last${LayerID}touchX = null;
var last${LayerID}touchY = null;
var last${LayerID}scrollX = 0;
var last${LayerID}scrollY = 0;
var eventHandler = function(e) {
e.preventDefault();
container = document.getElementById('$LayerID')
layer = getCurrent${LayerID}Layer()
if (last${LayerID}touchX && last${LayerID}touchX > e.targetTouches[0].pageX) {
// Moving right
}
if (last${LayerID}touchX && last${LayerID}touchX < e.targetTouches[0].pageX) {
// Moving left
}
if (last${LayerID}touchY && last${LayerID}touchY < e.targetTouches[0].pageY) {
// Moving up
last${LayerID}scrollY+= $ScrollSpeed
if (last${LayerID}scrollY > 0) {
last${LayerID}scrollY = 0
}
}
if (last${LayerID}touchY && last${LayerID}touchY > e.targetTouches[0].pageY) {
// Moving down
last${LayerID}scrollY-= $ScrollSpeed
// if less than zero, set a timeout to bounce the content back
if (last${LayerID}scrollY < -layer.scrollHeight) {
last${LayerID}scrollY = -layer.scrollHeight
}
}
last${LayerID}touchX = e.targetTouches[0].pageX
last${LayerID}touchY = e.targetTouches[0].pageY
layer.style.webkitTransform = 'translate(' + last${LayerID}scrollX +"px," + last${LayerID}scrollY +"px)";
}
if (document.getElementById('$LayerID').addEventListener) {
document.getElementById('$LayerID').addEventListener('touchmove', eventHandler)
}
var layers = get${LayerID}Layer();
while (layers[layerCount]) {
if (layers[layerCount].addEventListener) {
layers[layerCount].addEventListener('touchmove', eventHandler)
}
layerCount++;
}
"@ } else { ""}
$layerSwitcherScripts = if (-not $DisableLayerSwitcher) {
$moreButtonText = if (-not $HideMoreButton) {
"
<span style='padding:5px;'>
<input type='button' id='${$LayerID}_MoreButton' onclick='show${LayerID}Morebar();' style='border:1px solid black;padding:5;font-size:medium' value='...' />
</span>
"
} else {
""
}
$directionButtonText = if (-not $HideDirectionButton) {
"
<span style='padding:5px;'>
<input type='button' id='${LayerID}_LastButton' onclick='moveToLast${LayerID}Item();' style='border:1px solid black;padding:5;font-size:medium' value='<' />
<input type='button' id='${LayerID}_NextButton' onclick='moveToNext${LayerID}Item();' style='border:1px solid black;padding:5;font-size:medium' value='>' />
</span>
"
} else {
""
}
@"
$fadeJavaScriptFunctions
function moveToNext${LayerID}Item() {
var layers = get${LayerID}Layer();
var layerCount = 0;
var lastLayerWasVisible = false;
while (layers[layerCount]) {
if (lastLayerWasVisible == true) {
select${LayerID}Layer(layers[layerCount].id);
lastLayerWasVisible = false;
break
}
if (layers[layerCount].style.opacity == 1) {
// This layer is visible. Hide it, and make sure we know to show the next one.
lastLayerWasVisible = true;
}
layerCount++;
}
if (lastLayerWasVisible == true) {
select${LayerID}Layer(layers[0].id);
}
}
function moveToLast${LayerID}Item() {
var layers = get${LayerID}Layer();
var layerCount = 0;
var lastLayer = null;
var lastLayerWasVisible = false;
var showLastLayer =false;
while (layers[layerCount]) {
if (layers[layerCount].style.visibility == 'visible') {
if (lastLayer == null) {
showLastLayer = true;
} else {
select${LayerID}Layer(lastLayer.id);
}
}
lastLayer = layers[layerCount];
layerCount++;
}
if (showLastLayer == true) {
select${LayerID}Layer(lastLayer.id);
}
}
function select${LayerID}Layer(name, hideMoreBar) {
var layers = get${LayerID}Layer();
var layerCount = 0;
var found = false;
while (layers[layerCount]) {
containerName = '${LayerID}_' + name
if (layers[layerCount].id == name ||
layers[layerCount].id == containerName ||
layers[layerCount].id == containerName.replace("-", "_").replace(" ", "")) {
if (typeof fade${LayerID}Layer == "function") {
layers[layerCount].style.zIndex = 1
fade${LayerID}Layer(layers[layerCount].id, 0, 100, $($TransitionTime.TotalMilliseconds), $KeyFrameCount)
} else {
layers[layerCount].style.visibility = 'visible';
layers[layerCount].style.opacity = 1;
}
if (document.getElementById('${LayerID}_TitleArea') != null) {
document.getElementById('${LayerID}_TitleArea').innerHTML = get${LayerID}LayerTitleHTML(layers[layerCount]);
}
} else {
if (typeof fade${LayerID}Layer == "function") {
if (layers[layerCount].style.opacity != 0) {
fade${LayerID}Layer(layers[layerCount].id, 100, 0, $($TransitionTime.TotalMilliseconds), $KeyFrameCount)
}
} else {
layers[layerCount].style.visibility = 'hidden';
}
}
layerCount++;
}
if (hideMoreBar == true) {
hide${LayerID}Morebar();
}
}
function add${LayerID}Layer(name, content, layerUrl, refreshInterval)
{
var layers = get${LayerID}Layer();
var safeLayerName = name.replace(' ', '').replace('-', '_');
newHtml = "<div id='${LayerID}_" + safeLayerName +"' style='$(if ($AsTab -or -not $DisableLayerSwitcher) {'visibility:hidden;'})position:absolute;margin-top:0px;margin-left:0px;opacity:0;overflow:auto;-webkit-overflow-scrolling: touch;'>"
newHtml += content
newHtml += "</div><script>"
newHtml += ("document.getElementById('${LayerID}_" + safeLayerName + "').setAttribute('friendlyName', '" + name + "');")
if (layerUrl) {
newHtml += ("document.getElementById('${LayerID}_" + safeLayerName + "').setAttribute('layerUrl', '" + layerUrl + "');")
}
newHtml += ("<" + "/script>")
document.getElementById("${LayerID}").innerHTML += newHtml;
layers = get${LayerID}Layer()
layerCount =0
while (layers[layerCount]) {
if (layers[layerCount].id == "${LayerID}_" + safeLayerName) {
layers[layerCount].setAttribute('friendlyName', name);
if (layerUrl) {
layers[layerCount].setAttribute('layerUrl', layerUrl);
}
if (refreshInterval) {
layers[layerCount].setAttribute('refreshInterval', refreshInterval);
}
if (layerCount == 0) {
// first layer, show it
select${LayerID}Layer(layers[layerCount].id, true);
}
}
layerCount++
}
}
function set${LayerID}Layer(name, newHTML)
{
var safeLayerName = name.replace(' ', '').replace('-', '_');
layerId ="${LayerID}_" + safeLayerName
document.getElementById(layerId).innerHTML = newHtml;
select${LayerID}Layer(layerId);
}
function new${LayerID}CrossLink(containerName, sectionName, displayName)
{
if (! displayName) {
displayName = sectionName
}
"<a href='javascript:void(0)' onclick='" + "select" +containerName + "layer(\"" + sectionName+ "\")'>" + displayName + "</a>'"
}
function show${LayerID}Morebar() {
var morebar = document.getElementById('${LayerID}_Toolbar')
var layers = get${LayerID}Layer();
var layerCount = layers.length;
newHtml = "<span><select id='${LayerID}_ToolbarJumplist' style='font-size:large;padding:5'>"
for (i =0 ;i < layerCount;i++) {
newHtml += "<option style='font-size:large;' value='";
newHtml += layers[i].id;
newHtml += "'>";
newHtml += layers[i].attributes['friendlyName'].value;
newHtml += "</option>"
}
newHtml += "</select> \
<input type='button' style='border:1px solid black;padding:5;font-size:medium' value='Go' onclick='select${LayerID}Layer(document.getElementById(\"${LayerID}_ToolbarJumplist\").value, true);'>\
</span>"
morebar.innerHTML = newHtml;
// morebar.style.visibility = 'visible';
}
function hide${LayerID}Morebar() {
document.getElementById('${LayerID}_Toolbar').innerHTML = "$($directionButtonText -split ([Environment]::NewLine) -join ('\' + [Environment]::NewLine)
$moreButtonText -split ([Environment]::NewLine) -join ('\' + [Environment]::NewLine))";
}
"@
} else {
""
}
$cssStyleAttr = if ($psBoundParameters.Style) {
. Write-CSS -Style $style -OutputAttribute
} else {
""
}
$cssFontAttr = if ($psBoundParameters.Style.Keys -like "font*"){
$2ndStyle = @{}
foreach ($k in $psBoundParameters.sTyle.keys) {
if ($k -like "font*"){
$2ndStyle[$k] = $style[$k]
}
}
. Write-CSS -Style $2ndStyle -outputAttribute
} else {
""
}
$cssStyleChunk = if ($psBoundParameters.Style) {
"style='" +$cssStyleAttr + "'"
} else {
""
}
if ($AsCarousel) {
if (-not $CssClass) {
$CssClass = @()
}
if ($CssClass -notcontains "carousel") {
$CssClass += "carousel"
}
if ($CssClass -notcontains "slide") {
$CssClass += "slide"
}
}
if ($AsRow) {
if (-not $CssClass) {
$CssClass = @()
}
if ($CssClass -notcontains "container") {
$CssClass += "container"
}
}
if ($Asnavbar) {
if (-not $CssClass) {
$CssClass = @()
}
if ($CssClass -notcontains "navbar-wrapper") {