liuyg
2021-07-02 25ce610f6ecca7325e7a743dc032c4a76559c63d
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
define([
  'dojo/_base/declare',
  'dojo/_base/lang',
  'dojo/_base/array',
  'dojo/_base/html',
  'dojo/aspect',
  'dojo/query',
  'dojo/on',
  'dojo/Deferred',
  'dojo/mouse',
  'dojo/topic',
  'dojo/dom-construct',
  'dojo/dom-geometry',
  'jimu/BaseWidget',
  'jimu/PoolControllerMixin',
  'jimu/utils',
  'jimu/dijit/Message',
  './PopupTileNodes',
  'dijit/registry',
  'dojo/NodeList-manipulate'
],
  function (declare, lang, array, html, aspect, query, on, Deferred, mouse, topic,
    domConstruct, domGeometry, BaseWidget, PoolControllerMixin,
     utils, Message, PopupTileNodes, registry) {
    /* global jimuConfig */
    /* jshint scripturl:true */
    var clazz = declare([BaseWidget, PoolControllerMixin], {
 
      baseClass: 'jimu-widget-header-controller jimu-main-background',
 
      maxIconCount: -1,
 
      //whether need to create more icon
      createMoreIcon: false,
 
      //title, links are switchable depends the browser width
      switchableElements: {},
 
      //the default height of the widget
      height: 40,
 
      //the opened group/widget's id
      openedId: '',
 
      moveTopOnActive: false,
 
      postCreate: function () {
        this.inherited(arguments);
 
        this._processGroupSetting();
 
        this.switchableElements.title = this.titleNode;
 
        if (this.position && this.position.height) {
          this.height = this.position.height;
        }
 
        html.setStyle(this.signInSectionNode, 'display', 'none');
 
        if (this.appConfig && this.appConfig.logo) {
          this.logoNode.src = this.appConfig.logo;
          html.removeClass(this.logoNode, 'hide-logo');
        } else {
          this.logoNode.src = "";
          html.addClass(this.logoNode, 'hide-logo');
        }
        // If app title is not null then sanitize the title text
        if (this.appConfig.title) {
          this.appConfig.title = utils.sanitizeHTML(this.appConfig.title);
        }
        // If app title is not null then sanitize the subtitle text
        if (this.appConfig.subtitle) {
          this.appConfig.subtitle = utils.sanitizeHTML(this.appConfig.subtitle);
        }
 
        this.switchableElements.title.innerHTML = this.appConfig.title ? this.appConfig
          .title : '';
        this.switchableElements.title.title = this.appConfig.title ? this.appConfig
          .title : '';
        //If subtitle is valid them only add it to switchable elements and set its innerHTML
        //else empty the subtitle and don't add it in switchable elements
        if (this.appConfig.subtitle && lang.trim(this.appConfig.subtitle) !== "") {
          this.switchableElements.subtitle = this.subtitleNode;
          this.switchableElements.subtitle.innerHTML = this.appConfig.subtitle;
        } else {
          this.subtitleNode.innerHTML = '';
          html.setStyle(this.subtitleNode, 'display', 'none');
        }
        //creates links according to configuration
        this._createDynamicLinks(this.appConfig.links);
 
        this._setElementsSize();
 
        this._handleLogoLink(this.appConfig);
      },
 
      startup: function () {
        this.inherited(arguments);
        this.resize();
      },
 
      onAction: function (action, data) {
        /*jshint unused: false*/
        if (action === 'highLight' && data) {
          var node = query('div[settingid="' + data.widgetId + '"]', this.domNode)[0];
          this._highLight(node);
        }
        if (action === 'removeHighLight') {
          this._removeHighLight();
        }
      },
 
      onSignIn: function (credential) {
        this.inherited(arguments);
 
        html.setStyle(this.signinLinkNode, 'display', 'none');
        html.setStyle(this.userNameLinkNode, 'display', '');
        html.setStyle(this.signoutLinkNode, 'display', '');
 
        this.userNameLinkNode.innerHTML = credential.userId;
        html.setAttr(this.userNameLinkNode, 'href', this.appConfig.portalUrl + 'home/user.html');
 
        //popup
        if (this.popupLinkNode) {
          html.setStyle(this.popupSigninNode, 'display', 'none');
          html.setStyle(this.popupUserNameNode, 'display', '');
          html.setStyle(this.popupSignoutNode, 'display', '');
 
          query('a', this.popupUserNameNode).html(credential.userId)
            .attr('href', this.appConfig.portalUrl + 'home/user.html');
        }
        this.resize();
      },
 
      onSignOut: function () {
        this.inherited(arguments);
 
      },
 
      _onSignOut: function (signInTip) {
        html.setStyle(this.signinLinkNode, 'display', '');
        html.setAttr(this.signinLinkNode, 'innerHTML', signInTip);
        html.setStyle(this.userNameLinkNode, 'display', 'none');
        html.setStyle(this.signoutLinkNode, 'display', 'none');
 
        this.userNameLinkNode.innerHTML = '';
 
        //popup
        if (this.popupLinkNode) {
          html.setStyle(this.popupSigninNode, 'display', '');
          html.setAttr(this.popupSigninNode, 'innerHTML', signInTip);
          html.setStyle(this.popupUserNameNode, 'display', 'none');
          html.setStyle(this.popupSignoutNode, 'display', 'none');
 
          query('a', this.popupUserNameNode).html('');
        }
 
        this.resize();
      },
 
      resize: function () {
        var attributeTableHeight = 0;
        var headerNodeFloat = html.getStyle(this.headerNode, 'float');
        var logoNodeFloat = html.getStyle(this.logoNode, 'float');
        var titlesNodeFloat = html.getStyle(this.titlesNode, 'float');
        var linksNodeFloat = html.getStyle(this.linksNode, 'float');
        var allHasFloatStyle = (headerNodeFloat && headerNodeFloat !== 'none') &&
          (logoNodeFloat && logoNodeFloat !== 'none') &&
          (titlesNodeFloat && titlesNodeFloat !== 'none') &&
          (linksNodeFloat && linksNodeFloat !== 'none');
 
        if (allHasFloatStyle) {
          this._resize();
        } else {
          setTimeout(lang.hitch(this, this.resize), 200);
        }
 
        if (query(".jimu-widget-attributetable")[0]) {
          attributeTableHeight = query(".jimu-widget-attributetable")[0].clientHeight;
        }
        if (attributeTableHeight) {
          topic.publish('changeMapPosition', {
            bottom: attributeTableHeight
          });
        } else {
          topic.publish('changeMapPosition', {
            bottom: "0px"
          });
        }
      },
 
      _resize: function () {
        var box = html.getContentBox(this.domNode);
 
        //by default, we show all elements
        this._showSwitchableElements(['title', 'links', 'subtitle']);
        //as after showing all the elements title width may changed so update its width to fit other elements
        this._updateTitleNodeWidth();
        this._getTitleContainerWidth(box);
        this._createIconNodes(box);
        //again after changing/creating icon nodes title width may change so update its width to fit other elements
        this._updateTitleNodeWidth();
        if (this.morePane) {
          this.morePane.resize();
        }
        if (this.popupLinkNode) {
          html.setStyle(jimuConfig.layoutId, {
            left: html.getContentBox(this.popupLinkNode).w + 'px'
          });
        }
      },
 
      //Calculates and sets the Title Node Width
      _updateTitleNodeWidth: function () {
        var box, maxWidth, spaceLeft, containerWidth;
        box = html.getContentBox(this.domNode);
        //get complete header container width
        containerWidth = this._getHeaderContainerWidth(box);
        //calculate the available left space
        spaceLeft = containerWidth - this._getLogoWidth() - this._getTitlesWidth() -
          this._getSubtitleWidth() - this._getLinkWidth();
        //set the max width of the title by adding left space also extra 40px considering margins
        maxWidth = this._getTitlesWidth() + spaceLeft + 40;
        //if subtitle is not available increase the title's width by 20
        if (html.getStyle(this.subtitleNode, 'display') === "none") {
          maxWidth += 20;
          //if links are not available increase the title's width by 20
          if (html.getStyle(this.linksNode, 'display') === "none") {
            maxWidth += 20;
          }
        }
        //if calculated maxWidth is less tha 150 set max width as 15 else set the calculated max width
        if (maxWidth < 150) {
          html.setStyle(this.titleNode, 'max-width', '150px');
        } else {
          html.setStyle(this.titleNode, 'max-width', maxWidth + 'px');
        }
      },
 
      destroy: function () {
        if (this.timeoutHandle) {
          clearTimeout(this.timeoutHandle);
          this.timeoutHandle = null;
        }
        if (this.morePane) {
          this.morePane.destroy();
        }
        if (this.moreIconPaneCoverNode) {
          html.destroy(this.moreIconPaneCoverNode);
          this.moreIconPaneCoverNode = null;
        }
        if (this.popupLinkNode && this.popupLinksVisible) {
          this._hidePopupLink();
        }
        html.destroy(this.popupLinkNode);
        this.inherited(arguments);
      },
 
      onAppConfigChanged: function (appConfig, reason, changedData) {
        switch (reason) {
          case 'attributeChange':
            this._onAttributeChange(appConfig, changedData);
            break;
          default:
            return;
        }
        this.appConfig = appConfig;
        this.resize();
      },
 
      getOpenedIds: function () {
        this.inherited(arguments);
        if (this.openedId === '') {
          return [];
        }
        return [this.openedId];
      },
 
      setOpenedIds: function (ids) {
        if (ids.length === 0) {
          return;
        }
        var config = this.getConfigById(ids[0]);
        if (!config) {
          return;
        }
        this.openedId = ids[0];
        if (config.widgets && config.openType === 'openAll') {
          this._showIconContent(config);
        } else if (!config.widgets) {
          this._showIconContent(config);
        }
      },
 
      _onLogoLoad: function () {
        this.resize();
      },
 
      _highLight: function (node) {
        if (this.hlDiv) {
          this._removeHighLight();
        }
        if (!node) {
          return;
        }
        var position = domGeometry.getMarginBox(node);
        var hlStyle = {
          position: 'absolute',
          left: (position.l) + 'px',
          top: (position.t) + 'px',
          width: (position.w) + 'px',
          height: (position.h) + 'px'
        };
        this.hlDiv = domConstruct.create('div', {
          "style": hlStyle,
          "class": 'icon-highlight'
        }, node, 'before');
      },
 
      _removeHighLight: function () {
        if (this.hlDiv) {
          domConstruct.destroy(this.hlDiv);
          this.hlDiv = null;
        }
      },
 
 
      _onAttributeChange: function (appConfig, changedData) {
        /*jshint unused: false*/
        var appTitle;
        if ('title' in changedData && changedData.title !== this.appConfig.title) {
          appTitle = utils.sanitizeHTML(changedData.title);
          this.titleNode.innerHTML = appTitle;
          this.titleNode.title = appTitle;
        }
        if ('subtitle' in changedData && changedData.subtitle !== this.appConfig.subtitle) {
          this.subtitleNode.innerHTML = utils.sanitizeHTML(changedData.subtitle);
        }
        if ('logo' in changedData && changedData.logo !== this.appConfig.logo) {
          if (changedData.logo) {
            html.setAttr(this.logoNode, 'src', changedData.logo);
            html.removeClass(this.logoNode, 'hide-logo');
          } else {
            html.removeAttr(this.logoNode, 'src');
            html.addClass(this.logoNode, 'hide-logo');
          }
        }
 
        if ('links' in changedData) {
          this._createDynamicLinks(changedData.links);
        }
        this._handleLogoLink(appConfig);
      },
 
      _handleLogoLink: function(appConfig){
        if(appConfig.logoLink){
          html.setAttr(this.logoLinkNode, 'href', appConfig.logoLink);
          html.setStyle(this.logoNode, 'cursor', 'pointer');
        }else{
          html.setAttr(this.logoLinkNode, 'href', 'javascript:void(0)');
          html.setStyle(this.logoNode, 'cursor', 'default');
        }
      },
 
      _setElementsSize: function () {
        html.setStyle(this.logoNode, {
          height: '30px',
          marginTop: ((this.height - 30) / 2) + 'px'
        });
 
        html.setStyle(this.titleNode, {
          lineHeight: this.height + 'px'
        });
 
        html.setStyle(this.subtitleNode, {
          lineHeight: this.height + 'px'
        });
 
        query('.jimu-link', this.domNode).style({
          lineHeight: this.height + 'px'
        });
      },
 
      _processGroupSetting: function () {
        // Sets the map canvas area according to area
        // remained after opening and closing of widget panel
        this._setMapCanvasAreaToDefault();
        function getOpenType(gLabel) {
          if (this.config.groupSetting) {
            for (var i = 0; i < this.config.groupSetting.length; i++) {
              if (this.config.groupSetting[i].label === gLabel) {
                return this.config.groupSetting[i].type;
              }
            }
          }
          //this is the default open type
          return 'openAll';
        }
        array.forEach(this.appConfig.widgetPool.groups, function (g) {
          g.openType = getOpenType.call(this, g.label);
        }, this);
      },
 
      _createDynamicLinks: function (links) {
        if (window.isRTL) {
          var _links = [];
          array.forEach(links, function (link) {
            _links.unshift(link);
          });
          links = _links;
        }
        html.empty(this.dynamicLinksNode);
        //if no links are configured hide the link node else create configured links
        if (links.length <= 0) {
          html.setStyle(this.linksNode, 'display', 'none');
          //If dynamicLinks already exist in switchable elements remove it as links length is 0
          if (this.switchableElements.hasOwnProperty("links")) {
            delete this.switchableElements.links;
          }
        } else {
          //As dynamicLinks exist add linksNode to switchable elements
          this.switchableElements.links = this.linksNode;
          array.forEach(links, function (link) {
            html.create('a', {
              href: link.url,
              target: '_blank',
              innerHTML: utils.sanitizeHTML(link.label),
              'class': "jimu-link jimu-align-leading jimu-leading-margin1",
              style: {
                lineHeight: this.height + 'px'
              }
            }, this.dynamicLinksNode);
          }, this);
        }
      },
 
      _showSwitchableElements: function (showElement) {
        var es = this.switchableElements;
 
        for (var p in es) {
          if (es.hasOwnProperty(p)) {
            if (showElement.indexOf(p) > -1) {
              html.setStyle(es[p], 'display', 'block');
              es[p].visible = true;
            } else {
              html.setStyle(es[p], 'display', 'none');
              es[p].visible = false;
            }
          }
        }
        //links is hidden
        if (this.logoClickHandle) {
          this.logoClickHandle.remove();
        }
 
        if (showElement.indexOf('links') < 0) {
          this.logoClickHandle = on(this.logoNode, 'click', lang.hitch(this, this._onLogoClick));
        } else {
          if (this.popupLinksVisible) {
            this._hidePopupLink();
          }
          if(this.appConfig.logoLink){
            html.setStyle(this.logoNode, 'cursor', 'pointer');
          }else{
            html.setStyle(this.logoNode, 'cursor', 'default');
          }
        }
      },
 
      _switchSignin: function () {
 
      },
 
      _onLogoClick: function () {
        // return;
        if (this.popupLinkNode) {
          html.destroy(this.popupLinkNode);
 
        }
        this.popupLinkNode = this._createPopupLinkNode();
 
        if (this.popupLinksVisible) {
          this._hidePopupLink();
        } else {
          this._showPopupLink();
        }
      },
 
      _hidePopupLink: function () {
        html.setStyle(this.popupLinkNode, 'display', 'none');
 
        if (window.isRTL) {
          html.setStyle(jimuConfig.layoutId, {
            right: 0
          });
        } else {
          html.setStyle(jimuConfig.layoutId, {
            left: 0
          });
        }
 
        this.popupLinksVisible = false;
      },
 
      _showPopupLink: function () {
        html.setStyle(this.popupLinkNode, 'display', '');
 
        if (window.isRTL) {
          html.setStyle(jimuConfig.layoutId, {
            right: html.getContentBox(this.popupLinkNode).w + 'px'
          });
        } else {
          html.setStyle(jimuConfig.layoutId, {
            left: html.getContentBox(this.popupLinkNode).w + 'px'
          });
        }
 
        this.popupLinksVisible = true;
      },
 
      _createPopupLinkNode: function () {
        var node, titleNode, box;
        box = html.getContentBox(jimuConfig.mainPageId);
 
        node = html.create('div', {
          'class': 'popup-links jimu-main-background',
          style: {
            position: 'absolute',
            zIndex: 100,
            top: 0,
            bottom: 0
          }
        }, jimuConfig.mainPageId);
 
        if (window.isRTL) {
          html.setStyle(node, {
            right: 0,
            left: '50px'
          });
        } else {
          html.setStyle(node, {
            left: 0,
            right: '50px'
          });
        }
 
        titleNode = html.create('div', {
          'class': 'popup-title',
          style: {
            height: this.height + 'px',
            width: '100%'
          }
        }, node);
 
        html.create('img', {
          'class': 'logo jimu-float-leading jimu-leading-margin1',
          src: this.appConfig.logo ? this.appConfig.logo : this.folderUrl + 'images/app-logo.png',
          style: {
            width: '30px',
            height: '30px',
            marginTop: ((this.height - 30) / 2) + 'px'
          }
        }, titleNode);
 
        html.create('div', {
          'class': 'title jimu-float-leading jimu-leading-margin1',
          innerHTML: utils.sanitizeHTML(this.appConfig.title),
          style: {
            lineHeight: this.height + 'px'
          }
        }, titleNode);
 
        array.forEach(this.appConfig.links, function (link) {
          this._createLinkNode(node, link, false);
        }, this);
 
        this._createLinkNode(node, {
          label: '',
          url: '#'
        }, false);
        return node;
      },
 
      _createLinkNode: function (containerNode, link, isSign) {
        var node, lineNode, linkSectionNode, className;
 
        node = html.place('<div class="jimu-link"></div>', containerNode);
 
        lineNode = html.place('<div class="line"></div>', node);
        if (isSign) {
          className = 'link-section signin';
        } else {
          className = 'link-section';
        }
        linkSectionNode = html.place('<div class="' + className + '"></div>', node);
        html.create('a', {
          href: link.url,
          'class': 'jimu-ellipsis',
          target: '_blank',
          innerHTML: utils.sanitizeHTML(link.label),
          title: utils.sanitizeHTML(link.label),
          style: {
            lineHeight: '66px'
          }
        }, linkSectionNode);
 
        return node;
      },
 
      _onSigninClick: function () {
      },
 
      _onSignoutClick: function () {
 
      },
 
      _onUserNameClick: function () {
 
      },
 
      /*
      * Calculates the width of header section div
      * @memberOf widgets/HeaderController/widget.js
      */
      _getHeaderSectionWidth: function () {
        var width;
        width = html.getMarginBox(this.headerNode).w;
        return width;
      },
 
      /*
      * Calculate width for titles and subtitles
      * @memberOf widgets/HeaderController/widget.js
      */
      _getIconContainerWidth: function () {
        var iconContainerWidth;
        //the container width
        iconContainerWidth = html.getMarginBox(this.containerNode).w;
        return iconContainerWidth;
      },
 
      /*
      * Calculates the width of header title div
      * @memberOf widgets/HeaderController/widget.js
      */
      _getTitlesWidth: function () {
        var titlseWidth;
        titlseWidth = html.getMarginBox(this.titlesNode).w;
        return titlseWidth;
      },
 
      /*
      * Calculates the width of header link div
      * @memberOf widgets/HeaderController/widget.js
      */
      _getLinkWidth: function () {
        var linkWidth;
        linkWidth = html.getMarginBox(this.linksNode).w;
        return linkWidth;
      },
 
      /*
      * Calculates the width of header logo div
      * @memberOf widgets/HeaderController/widget.js
      */
      _getLogoWidth: function () {
        var width;
        width = html.getMarginBox(this.logoNode).w + 12;
        return width;
      },
 
      /*
      * Calculates the width of header Subtitle div
      * @memberOf widgets/HeaderController/widget.js
      */
      _getSubtitleWidth: function () {
        var subTitleWidth;
        subTitleWidth = html.getMarginBox(this.subtitleNode).w;
        return subTitleWidth;
      },
 
      /*
      * Calculates the header container which contains
      * app-logo, title, subtitle, links etc
      * @memberOf widgets/HeaderController/widget.js
      */
      _getHeaderContainerWidth: function (box) {
        var headSectionWidth = this._getIconContainerWidth();
        var logosectionWidth = this._getLogoWidth();
        //the container width
        var containerWidth = box.w - headSectionWidth - logosectionWidth;
        return containerWidth;
      },
 
      /*
      * Hide and show title, subtitle, link
      * according to the width of the there text
      * title is in first priority then subtitle and links subsequently
      * @memberOf widgets/HeaderController/widget.js
      */
      _getTitleContainerWidth: function (box) {
        var containerWidth = this._getHeaderContainerWidth(box);
        var tileswidth = this._getTitlesWidth();
        var linkWidth = this._getLinkWidth();
        // if the header container containing title, subtitle, link width is less
        // than titles and subtitle width then only
        if (containerWidth < (tileswidth + linkWidth)) {
          // if link div is visible then only
          if (this.switchableElements.hasOwnProperty("links") &&
            this.switchableElements.links.visible) {
            //hidden link first
            this._showSwitchableElements(['title', 'subtitle']);
            tileswidth = this._getTitlesWidth();
            if (containerWidth < tileswidth) {
              //hidden Subtitle first
              this._showSwitchableElements(['title']);
            }
          } else {
            //hiden the title, subtitle, links
            this._showSwitchableElements(['title']);
          }
        }
      },
 
      _createIconNodes: function (box, openingWidgetId) {
        query('.icon-node', this.containerNode).remove();
        this._closeDropMenu();
 
        var i, iconConfig, ret, allIconConfigs = this.getAllConfigs(), moveToHeader;
        //by default, the icon is square
        this.iconWidth = box.h;
        ret = this._getTitleContainerWidth(box);
 
        var iconContainerWidth = 360;
        if (window.innerWidth <= 760) {
          iconContainerWidth = 90;
        } else {
          iconContainerWidth = 360;
        }
 
        var containerStyle = {
          width: iconContainerWidth + 'px'
        };
 
        /* New Changes For showing panel below header in mobile devices  */
        html.setStyle(this.containerNode, containerStyle);
 
        if (window.innerWidth <= 760) {
          this.maxIconCount = 2;
        } else {
          this.maxIconCount = Math.floor(360 / 45);
        }
        if (this.maxIconCount >= allIconConfigs.length) {
          this.headerIconCount = allIconConfigs.length;
          this.createMoreIcon = false;
        } else {
          this.headerIconCount = this.maxIconCount - 1;
          this.createMoreIcon = true;
        }
        if (this.createMoreIcon) {
          this._createIconNode({
            label: this.nls.more
          });
          /*Move open widget to header icon List -
          *If any openAtStart/alreadyOpen widget goes into more panel this will bring it to header *icon list
          */
          if (!this.openAtStartWidget) {
            for (i = 0; i < allIconConfigs.length; i++) {
              if (allIconConfigs[i].openAtStart) {
                moveToHeader = allIconConfigs[i];
              }
            }
          }
          //if not opening widget from more list and and some widget is already opened,
          //show the opened widget icon in header icon list
          if (!openingWidgetId && this.openedId && this.getConfigById(this.openedId)) {
            moveToHeader = this.getConfigById(this.openedId);
          }
          if (moveToHeader) {
            this._moveConfigToHeader(moveToHeader);
          }
          /* End Move open widget to header icon List */
        }
 
        var openAtStartNode;
        for (i = this.headerIconCount - 1; i >= 0; i--) {
          iconConfig = allIconConfigs[i];
          var node = this._createIconNode(iconConfig);
 
          if (iconConfig.openAtStart) {
            openAtStartNode = node;
          }
        }
        //open the first openatstart widget
        if (openAtStartNode && !this.openAtStartWidget) {
          this._onIconClick(openAtStartNode);
          this.openAtStartWidget = openAtStartNode.config.name;
        }
 
        if (this.openedId && this.getConfigById(this.openedId) &&
          this.getConfigById(this.openedId).inPanel === false) {
          var openedIconNode = this._getIconNodeById(this.openedId);
          var openedWidget = this.widgetManager.getWidgetById(this.openedId);
          if (openedIconNode && openedWidget) {
            this._setOffPanelWidgetPosition(openedIconNode, openedWidget);
          } else {
            this.widgetManager.closeWidget(this.openedId);
            this.openedId = '';
          }
        }
      },
 
      _createIconNode: function (iconConfig) {
        var node, iconUrl, iconParent, iconSelectedDiv;
        if (iconConfig.label === this.nls.more) {
          iconUrl = this.folderUrl + 'images/more_icon.png';
        } else {
          iconUrl = iconConfig.icon;
        }
 
        node = html.create('div', {
          'class': 'icon-node jimu-float-trailing',
          title: iconConfig.label,
          settingId: iconConfig.id,
          style: {
            width: 45 + 'px',
            height: this.height + 'px',
            textAlign: 'center'
          }
        }, this.containerNode);
        /* New Changes For showing panel below header in mobile devices  */
        iconParent = html.create('div', {
          'class': 'widget-symbol-div',
          style: {
            width: 100 + '%'
          }
        }, node);
 
        html.create('img', {
          src: iconUrl,
          style: {
            marginTop: ((this.height - 30) / 2 + 3) + 'px',
            marginBottom: 3 + 'px'
          }
        }, iconParent);
 
        iconSelectedDiv = html.create('div', {
          'class': 'widget-open-symbol esriCTHidden'
        }, node);
 
        /* New Changes For showing panel below header in mobile devices  */
        if (iconConfig.label === this.nls.more) {
          on(node, 'click', lang.hitch(this, this._showMorePane, iconConfig));
        } else {
          on(node, 'click', lang.hitch(this, function () {
            this._onIconClick(node);
          }));
        }
        node.config = iconConfig;
        if (node.config.widgets && node.config.widgets.length > 1 &&
          node.config.openType === 'dropDown') {
          this._createDropTriangle(node);
        }
 
        //set current open node
        if (this.openedId === iconConfig.id) {
          html.addClass(node, 'jimu-state-selected');
          //Hide widget open symbol of all widgets
          query('.widget-open-symbol', this.domNode).addClass('esriCTHidden');
          //Show widget open symbol of the current open widget only
          html.removeClass(iconSelectedDiv, 'esriCTHidden');
          if (node.config.widgets && node.config.widgets.length > 1 &&
            node.config.openType === 'dropDown') {
            this._openDropMenu(node);
          }
        }
        return node;
      },
 
      _createDropTriangle: function (node) {
        var box = html.getMarginBox(node);
        var triangleLeft = box.l + box.w / 2 - 4;
        html.create('div', {
          'class': 'drop-triangle',
          style: {
            left: triangleLeft + 'px'
          }
        }, node);
      },
 
      _onIconClick: function (node) {
        if (!node.config.widgets || node.config.widgets.length === 1 ||
          node.config.openType === 'openAll') {
          //widget or group with 'openAll' open type
          if (this.openedId && this.openedId === node.config.id) {
            this._switchNodeToClose(this.openedId);
            return;
          } else {
            if (this.openedId) {
              this._switchNodeToClose(this.openedId).then(lang.hitch(this, function () {
                this._closeDropMenu();
                this._switchNodeToOpen(node.config.id);
              }));
            } else {
              this._switchNodeToOpen(node.config.id);
            }
          }
        } else {
          if (this.dropMenuNode) {
            this._closeDropMenu();
          } else {
            this._openDropMenu(node);
          }
        }
      },
 
      _closeDropMenu: function () {
        if (this.dropMenuNode) {
          html.destroy(this.dropMenuNode);
          this.dropMenuNode = null;
        }
      },
 
      _openDropMenu: function (pnode) {
        this.dropMenuNode = html.create('div', {
          'class': 'jimu-drop-menu jimu-main-background',
          title: pnode.config.label,
          style: {
            position: 'absolute',
            zIndex: '101'
          }
        });
 
        html.place(this.dropMenuNode, this.containerNode);
 
        array.forEach(pnode.config.widgets, function (widgetConfig) {
          this._createDropMenuItem(widgetConfig);
        }, this);
 
        this._setDropMenuPosition(pnode);
 
        if (this.morePane) {
          this.morePane.hide();
        }
      },
 
      _createDropMenuItem: function (sconfig) {
        var node = html.create('div', {
          'class': 'menu-item',
          title: utils.sanitizeHTML(sconfig.label),
          style: {
            height: this.height + 'px'
          }
        }, this.dropMenuNode);
 
        html.create('img', {
          'class': 'jimu-float-leading',
          src: sconfig.icon
        }, node);
 
        html.create('div', {
          'class': 'label jimu-float-leading',
          innerHTML: utils.sanitizeHTML(sconfig.label)
        }, node);
 
        this.own(on(node, 'click', lang.hitch(this, function () {
          this._closeDropMenu();
          if (this.openedId) {
            this._switchNodeToClose(this.openedId).then(lang.hitch(this, function () {
              this._showIconContent(node.config);
            }));
          } else {
            this._showIconContent(node.config);
          }
        })));
        node.config = sconfig;
        return node;
      },
 
      _setDropMenuPosition: function (pnode) {
        var position = {};
        var menuBox = html.getMarginBox(this.dropMenuNode);
 
        position = this._getDropdownPosition(pnode, menuBox);
        position.zIndex = 101;
        html.setStyle(this.dropMenuNode, utils.getPositionStyle(position));
      },
 
      _getDropdownPosition: function (pnode, sbox) {
        var position = {},
          pbox = html.getMarginBox(pnode),
          thisBox = html.getMarginBox(this.domNode);
 
        position.top = this.height + 1;
 
        if (window.isRTL) {
          if (pbox.l + pbox.w - sbox.w < 0) {
            position.right = 0;
          } else {
            position.right = pbox.l + pbox.w - sbox.w;
          }
        } else {
          if (pbox.l + sbox.w > thisBox.w) {
            position.right = 0;
          } else {
            position.left = pbox.l;
          }
        }
        return position;
      },
 
      _switchNodeToOpen: function (id) {
        var node = this._getIconNodeById(id);
        query('.icon-node', this.domNode).removeClass('jimu-state-selected');
        /* New Changes For showing panel below header in mobile devices  */
        query('.widget-open-symbol', this.domNode).addClass('esriCTHidden');
        html.addClass(node, 'jimu-state-selected');
        html.removeClass(node.children[1], 'esriCTHidden');
        /* New Changes For showing panel below header in mobile devices  */
        this._showIconContent(node.config);
      },
 
      _switchNodeToClose: function (id) {
        query('.icon-node', this.domNode).removeClass('jimu-state-selected');
        // Sets the map canvas area according to area
        // remained after opening and closing of widget panel
        this._setMapCanvasAreaToDefault();
 
        /* New Changes For showing panel below header in mobile devices  */
        query('.widget-open-symbol', this.domNode).addClass('esriCTHidden');
        var iconJson = this.appConfig.getConfigElementById(id);
        var def;
        if (iconJson) {
          if (iconJson.inPanel === false) {
            this.widgetManager.closeWidget(id);
            this.openedId = '';
            def = new Deferred();
            def.resolve();
            return def;
          } else {
            return this.panelManager.closePanel(id + '_panel');
          }
        } else {
          def = new Deferred();
          def.resolve();
          return def;
        }
      },
 
      /*
      * Sets map canvas area to default position
      * @memberOf widgets/HeaderController/widget.js
      */
      _setMapCanvasAreaToDefault: function () {
        // if application is running in desktop device then keep right zero
        // else for mobile devices keep bottom zero
        if (!window.appInfo.isRunInMobile) {
          topic.publish('changeMapPosition', {
            right: "0px"
          });
        } else {
          var attributeTableHeight = 0;
          if (query(".jimu-widget-attributetable")[0]) {
            attributeTableHeight = query(".jimu-widget-attributetable")[0].clientHeight;
          }
          // if attribute table widget height is greater than zero
          // then set bottom equal attributeTableHeight
          // else keep bottom as zero
          if (attributeTableHeight) {
            topic.publish('changeMapPosition', {
              bottom: attributeTableHeight
            });
          } else {
            topic.publish('changeMapPosition', {
              bottom: "0px"
            });
          }
        }
      },
 
      /*
      * Adjusts the map canvas area according to remaining area
      * after opening or closing, panel or other widgets
      * @memberOf widgets/HeaderController/widget.js
      */
      _setMapCanvasArea: function () {
        // if application is running in desktop device
        if (!window.appInfo.isRunInMobile) {
          // if browser is minimized the change map right position to zero
          // else change it by 360px
          if (this.panelManager && this.panelManager.activePanel &&
            this.panelManager.activePanel.windowState === "minimized") {
            topic.publish('changeMapPosition', {
              right: "0px"
            });
          } else {
            topic.publish('changeMapPosition', {
              right: "360px"
            });
 
            this._resizeAttributeTableinRTL();
          }
        } else {
          // if application is running in mobile devices and panel resizing state is
          // normal then set the bottom positioning of the map equal to the panel top
          // position so that map content pane can be visible in that remaining area only
          // else keep bottom position 36px for folded mode
          var attributeTableHeight = 0;
          if (query(".jimu-widget-attributetable")[0]) {
            attributeTableHeight = query(".jimu-widget-attributetable")[0].clientHeight;
          }
          if (this.panelManager && this.panelManager.panels && this.panelManager.panels[0] &&
            this.panelManager.panels[0].windowState === "normal") {
            var panelPosition = this.panelManager.getPositionOnMobile(this);
            // if attribute table widget height is greater than panelPosition.top
            // then set bottom equal attributeTableHeight
            // else keep bottom as panelPosition.top
            if (attributeTableHeight && attributeTableHeight > panelPosition.top) {
              topic.publish('changeMapPosition', {
                bottom: attributeTableHeight
              });
            } else {
              topic.publish('changeMapPosition', {
                bottom: panelPosition.top
              });
            }
          } else {
            // if attribute table widget height is greater than 36px
            // then set bottom position to attributeTableHeight
            // else keep bottom position to 36px
            if (attributeTableHeight > 36) {
              topic.publish('changeMapPosition', {
                bottom: attributeTableHeight
              });
            } else {
              // if it is touch devices or browser width is less than 760px
              // then set bottom position to 36px else set it to zero
              if (window.hasOwnProperty("ontouchstart") ||
                window.ontouchstart !== undefined || window.innerWidth <= 760) {
                topic.publish('changeMapPosition', {
                  bottom: "36px"
                });
              } else {
                topic.publish('changeMapPosition', {
                  bottom: "0px"
                });
              }
            }
          }
        }
      },
 
      /*
      * resizes the attribute table widget in case of RTL layout
      * after opening or closing, panel or other widgets
      * @memberOf widgets/HeaderController/widget.js
      */
      _resizeAttributeTableinRTL: function () {
        // if attribute table widget is available in the dom
        if (query(".jimu-widget-attributetable")[0]) {
          if (window.isRTL) {
            html.setStyle(query(".jimu-widget-attributetable")[0], 'right', '0px');
          } else {
            html.setStyle(query(".jimu-widget-attributetable")[0], 'left', '0px');
          }
          // if tab Container is  of attribute table widget is created in the dom
          if (query(".dijitTabContainer", query(".jimu-widget-attributetable")[0])[0]) {
            registry.byId(query(".dijitTabContainer",
              query(".jimu-widget-attributetable")[0])[0].id).resize();
          }
        }
      },
 
      _getIconNodeById: function (id) {
        var node = query('.icon-node[settingId="' + id + '"]', this.domNode);
        if (node.length === 0) {
          return;
        }
        return node[0];
      },
 
      _unSelectIcon: function (id) {
        query('.icon-node[settingId="' + id + '"]', this.domNode)
          .removeClass('jimu-state-selected');
        this.openedId = '';
      },
 
      _showIconContent: function (iconConfig) {
        if (iconConfig.inPanel === false) {
          this.widgetManager.loadWidget(iconConfig).then(lang.hitch(this, function (widget) {
            this.openedId = iconConfig.id;
            var iconNode = this._getIconNodeById(iconConfig.id);
 
            //we don't call widget.startup because getWidgetMarginBox has started widget
            //widget.startup();
 
            html.setStyle(widget.domNode, 'zIndex', 101);
 
            this._setOffPanelWidgetPosition(iconNode, widget);
            this.widgetManager.openWidget(widget);
 
            this.own(aspect.after(widget, 'onClose', lang.hitch(this, function () {
              query('.widget-open-symbol', this.domNode).addClass('esriCTHidden');
              // Sets the map canvas area according to area
              // remained after opening and closing of widget panel
              this._setMapCanvasAreaToDefault();
              // ST: Added to listen for out of panel widgets that can be closed
              this._unSelectIcon(iconConfig.id);
            })));
          }));
        } else {
          // Sets the map canvas area according to area
          // remained after opening and closing of widget panel
          this._setMapCanvasArea();
          this.panelManager.showPanel(iconConfig).then(lang.hitch(this, function (panel) {
            var node;
            this.openedId = iconConfig.id;
            node = this._getIconNodeById(this.openedId);
            query('.icon-node', this.domNode).removeClass('jimu-state-selected');
            /* New Changes For showing panel below header in mobile devices  */
            query('.widget-open-symbol', this.domNode).addClass('esriCTHidden');
            html.addClass(node, 'jimu-state-selected');
            html.removeClass(node.children[1], 'esriCTHidden');
 
            this.own(aspect.after(panel, 'onClose', lang.hitch(this, function () {
              this._unSelectIcon(iconConfig.id);
              // Sets the map canvas area according to area
              // remained after opening and closing of widget panel
              this._setMapCanvasAreaToDefault();
            })));
          }));
        }
      },
 
      _setOffPanelWidgetPosition: function (iconNode, widget) {
        var position = this._getDropdownPosition(iconNode,
          this.widgetManager.getWidgetMarginBox(widget));
        widget.setPosition(position, this.containerNode);
      },
 
      _showMorePane: function () {
        var i, iconConfig, moreItems = [],
          allIconConfigs = this.getAllConfigs();
 
        for (i = this.headerIconCount; i < allIconConfigs.length; i++) {
          iconConfig = allIconConfigs[i];
          if (iconConfig.id !== this.openedId) {
            moreItems.push(iconConfig);
          }
        }
        if (this.morePane) {
          this.morePane.destroy();
        }
        if (this.moreIconPaneCoverNode) {
          html.destroy(this.moreIconPaneCoverNode);
        }
 
        this._closeDropMenu();
 
        this.morePane = new PopupTileNodes({
          openedId: this.openedId,
          items: moreItems,
          numWidget: allIconConfigs
        });
        this._createCoverNode();
        html.place(this.morePane.domNode, jimuConfig.mapId);
        this.morePane.startup();
 
        aspect.after(this.morePane, 'onNodeClicked', lang.hitch(this, function (node) {
          this._moveConfigToHeader(node.config);
          this._createIconNodes(html.getContentBox(this.domNode), node.config.id);
          this._onIconClick(this._getIconNodeById(node.config.id));
        }), true);
        aspect.after(this.morePane, 'hide', lang.hitch(this, function () {
          html.destroy(this.moreIconPaneCoverNode);
        }), true);
      },
 
      _moveConfigToHeader: function (config) {
        var allIconConfigs = this.getAllConfigs();
 
        var tempIndex = config.index;
        config.index = allIconConfigs[this.headerIconCount - 1].index;
        allIconConfigs[this.headerIconCount - 1].index = tempIndex;
      },
 
      _createCoverNode: function () {
        this.moreIconPaneCoverNode = html.create('div', {
          'class': 'jimu-more-icon-cover'
        }, jimuConfig.layoutId);
      }
    });
    return clazz;
  });