-
-
Notifications
You must be signed in to change notification settings - Fork 477
/
App.js
853 lines (758 loc) · 29.2 KB
/
App.js
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
/*
* Copyright (C) 2012 GeoNetwork
*
* This file is part of GeoNetwork
*
* GeoNetwork is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GeoNetwork is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GeoNetwork. If not, see <http://www.gnu.org/licenses/>.
*/
Ext.namespace('GeoNetwork');
var catalogue;
var app;
var cookie;
var urlParameters;
/**
* Main App class. It should only contain specific GUI behaviour.
*/
GeoNetwork.app = function() {
var createLatestUpdate = function() {
var latestView = new GeoNetwork.MetadataResultsView({
catalogue : catalogue,
autoScroll : true,
tpl : GeoNetwork.HTML5UI.Templates.THUMBNAIL_SIMPLER
});
var latestStore = new GeoNetwork.Settings.mdStore();
latestView.setStore(latestStore);
latestStore.on('load', function() {
Ext.ux.Lightbox.register('a[rel^=lightbox]');
});
var p = new Ext.Panel({
shadow: 'drop',
shadowOffset: 10,
border : true,
bodyCssClass : 'md-view',
items : latestView,
renderTo : 'latest-metadata'
});
latestView.tpl = GeoNetwork.HTML5UI.Templates.THUMBNAIL_SIMPLER;
catalogue.kvpSearch(
"fast=index&from=1&to=4&sortBy=changeDate",
function(e) {
Ext.each(Ext.DomQuery.select('.md-action-menu'), function(
el) {
hide(el);
});
}, null, null, true, latestView.getStore());
};
function createMainTagCloud() {
var tagCloudView = new GeoNetwork.TagCloudView({
catalogue : catalogue,
query : 'fast=true&summaryOnly=true&from=1&to=4',
renderTo : 'cloud-tag',
onSuccess : 'app.loadResults',
itemSelector : 'div.tag-cloud',
tpl: new Ext.XTemplate(
'<tpl for=".">',
'<div class="tag-cloud">',
'<a href="#" onclick="javascript:catalogue.kvpSearch(\'fast=' + catalogue.metadataStore.fast + '&summaryOnly=0&from=1&to=20&hitsPerPage=20&' +
'themekey' +
'={value}\', app.loadResults, null, null);app.searchApp.firstSearch=true;showSearch();" alt="{value}">{value} ({count})</a>',
'</div>',
'</tpl>')
});
return tagCloudView;
}
;
var createPopularUpdate = function() {
var latestView = new GeoNetwork.MetadataResultsView({
catalogue : catalogue,
autoScroll : true,
tpl : GeoNetwork.HTML5UI.Templates.THUMBNAIL_SIMPLER
});
var latestStore = new GeoNetwork.Settings.mdStore();
latestView.setStore(latestStore);
latestStore.on('load', function() {
Ext.ux.Lightbox.register('a[rel^=lightbox]');
});
var p = new Ext.Panel({
shadow: 'drop',
shadowOffset: 10,
border : true,
bodyCssClass : 'md-view',
items : latestView,
renderTo : 'popular-metadata'
});
latestView.tpl = GeoNetwork.HTML5UI.Templates.THUMBNAIL_SIMPLER;
catalogue.kvpSearch(
"fast=index&from=1&to=4&sortBy=popularity",
function(e) {
Ext.each(Ext.DomQuery.select('.md-action-menu'), function(
el) {
hide(el);
});
}, null, null, true, latestView.getStore());
};
/**
*
* Given a metadata, load a map on the metadata associated map and creates
* the checkbox for downloading or adding layers to the big map
*
*/
var loadMetadataMap = function(metadata) {
var checkboxes = [];
var layers = [];
// add data to map
Ext.each(metadata.record.get("links"), function(link) {
if (link.protocol === 'application/vnd.ogc.wms_xml'
|| link.protocol.toUpperCase().indexOf("OGC:WMS") >= 0) {
var layers = app.mapApp.getCapabilitiesWMS(link.href);
Ext.each(layers, function(layer) {
var wms = new OpenLayers.Layer.WMS(link.name, link.href, {
layers : layer,
transparent : true
});
wms.setVisibility(true);
checkboxes.push(new Ext.form.Checkbox({
boxLabel : layer,
layer : wms
}));
layers.push(wms);
});
} else if (link.protocol === 'application/vnd.ogc.wfs_xml'
|| link.protocol.toUpperCase().indexOf("OGC:WFS") >= 0) {
var layers = [];
try {
layers = app.mapApp.getCapabilitiesWFS(link.href);
} catch (ex) {
layers = [];
}
var styleMap = new OpenLayers.StyleMap({
strokeWidth : 3,
strokeColor : "#333333"
});
var strategies = [ new OpenLayers.Strategy.BBOX() ];
Ext.each(layers, function(layer) {
var wfs = new OpenLayers.Layer.Vector(link.name, {
strategies : strategies,
protocol : layer,
styleMap : styleMap
});
wfs.setVisibility(true);
checkboxes.push(new Ext.form.Checkbox({
boxLabel : layer.featurePrefix + ":"
+ layer.geometryName,
layer : wfs
}));
layers.push(wfs);
});
}
});
var wfs_href = metadata.record.get("href");
// var form = new Ext.form.FormPanel(
// {
// renderTo : "download_" + metadata.title,
// defaultType : 'checkboxgroup',
// buttonAlign : 'left',
// width : 200,
// layout : 'column',
// items : [ checkboxes ],
// fbar : {
// xtype : 'toolbar',
// items : [
// {
// text : OpenLayers.i18n('Add to map'),
// handler : function() {
// form.items
// .each(function(c) {
// if (c.checked && !c.added) {
// c.added = true;
// app.mapApp
// .createLayer(c.layer);
// }
// });
// }
// },
// {
// text : OpenLayers.i18n('prepareDownload'),
// handler : function() {
// // FIXME : this call require the
// // catalogue to be named
// // catalogue
// catalogue
// .metadataPrepareDownload(metadata.record
// .get('id'));
// }
// } ]
// }
// });
var map = app.mapApp.generateAuxiliaryMap("map_" + metadata.title);
Ext.each(layers, function(layer) {
map.addLayer(layer);
});
};
/**
* Create a language switcher menu.
* PRI - turned off
*
*/
var createLanguagesMenu = function(lang) {
// var items = [],
// lang = /srv\/([a-z]{3})\/search/.exec(window.location.href);
//
// if (Ext.isArray(lang)) {
// lang = lang[1];
// }
//
// var href;
// if (lang === null) currentLang = 'eng';
// else currentLang = lang;
//
// Ext.each(GeoNetwork.Util.locales, function(locale) {
// if (lang === null) {
// href = window.location.pathname.replace('/srv/search', '/srv/'+ locale[2] + '/search');
// } else {
// href = window.location.pathname.replace(lang, locale[2]);
// }
//
// if (currentLang === locale[2] || currentLang === locale[0]) currentLang = locale[1];
// items.push({
// text: locale[1],
// href: href,
// height: '100%'
// });
// });
// return new Ext.menu.Menu({
// id: 'lang-menu',
// renderTo: 'lang-form',
// floating: false,
// border: false,
// plain: true,
// showSeparator: false,
// items: items
// });
};
function edit(metadataId, create, group, child) {
Ext.getCmp('metadata-panel') && Ext.getCmp('metadata-panel').destroy();
var editorPanel = new GeoNetwork.editor.EditorPanel({
defaultViewMode : GeoNetwork.Settings.editor.defaultViewMode,
catalogue : catalogue,
selectionPanelImgPath: '../../apps/js/ext-ux/images',
renderTo : 'metadata-info',
layout : 'border',
xlinkOptions : {
CONTACT : true
},
listeners : {
editorClosed : function() {
showSearch();
Ext.getCmp('advanced-search-options-content-form').fireEvent('search');
Ext.get("search-form").show();
}
}
});
editorPanel.init(metadataId, create, group, child);
editorPanel.doLayout(false);
showMetadata();
hide("search-form");
app.breadcrumb.setCurrent({
text : OpenLayers.i18n('mdEditor'),
func : "app.edit('" + metadataId + "', " + create + ", " + group
+ "," + child + ")"
});
}
function show(uuid, record, url, maximized, width, height, clean) {
Ext.get("metadata-info").update("");
var button_width = '24px';
var button_height = '24px';
var aResTab = new GeoNetwork.view.ViewPanel({
serviceUrl : catalogue.services.mdView + '?uuid=' + uuid,
lang : catalogue.lang,
id : 'metadata-panel',
renderTo : 'metadata-info',
autoScroll : true,
resultsView : catalogue.resultsView,
layout : 'fit',
// autoHeight:true,
//padding : '5px 25px',
currTab : GeoNetwork.defaultViewMode || 'simple',
printDefaultForTabs : GeoNetwork.printDefaultForTabs || false,
printUrl : '../../apps/html5ui/print.html',
catalogue : catalogue,
// maximized: true,
metadataUuid : uuid,
record : record,
buttonWidth : button_width,
buttonHeight : button_height,
viewPanelButtonCSS: GeoNetwork.Settings.viewPanelButtonCSS
});
// aResTab.on("afterrender", function() {
// // Initialize map and links
// loadMetadataMap({
// record : record,
// title : record.get('title')
// });
// });
showMetadata();
app.breadcrumb.setDefaultPrevious(2);
app.breadcrumb.setCurrent({
text : record.get('title'),
func : "app.searchApp.addMetadata('" + uuid + "', true)"
});
// Get title, keywords and author for current record
// in order to populate the META tag in the HEAD of the HTML page.
var contacts = [];
Ext.each(record.get('contact'), function(item) {
contacts.push(item.name);
});
var subjects = [];
Ext.each(record.get('subject'), function(item) {
subjects.push(item.value);
});
GeoNetwork.Util.updateHeadInfo({
title : catalogue.getInfo().name
+ ' | '
+ record.get('title')
+ (record.get('type') ? ' (' + record.get('type') + ')'
: ''),
meta : {
subject : record.get('abstract'),
keywords : subjects,
author : contacts
}
});
token = "|" + uuid;
if (!GeoNetwork.state.History.getToken()
|| GeoNetwork.state.History.getToken().indexOf("edit=") != 0) {
if (!Ext.state.Manager.getProvider().restoring) {
GeoNetwork.state.History.eventsSuspended = true;
GeoNetwork.state.History.suspendEvents();
GeoNetwork.state.History.add(token);
GeoNetwork.state.History.resumeEvents();
GeoNetwork.state.History.eventsSuspended = false;
}
}
Ext.state.Manager.getProvider().restoring = false;
hide("share-capabilities");
hide("permalink-div");
var test = Ext.getCmp("metadata-panel");
// Adding social capabilities
Ext.getCmp("metadata-panel").getTopToolbar().addButton({
id : 'viewpanel-share',
width : button_width,
height : button_height,
handler : function() {
toggle("share-capabilities");
},
text : '',
tooltip : 'Share this',
type : 'submit',
tooltip : OpenLayers.i18n('Social Share'),
enableToggle : true,
iconCls: GeoNetwork.Settings.viewPanelButtonCSS('viewpanel-share')
});
GeoNetwork.Util.removeMetaTags({
'og:title' : true,
'og:url' : true
});
GeoNetwork.Util.addMetaTag("og:title", record.get('title'));
GeoNetwork.Util.addMetaTag("og:url", Ext.state.Manager.getProvider()
.getPrettyLink());
// Updating social
Ext.get("custom-tweet-button").dom.href = "https://twitter.com/share?text="
+ record.get('title')
+ " "
+ Ext.state.Manager.getProvider().getPrettyLink();
Ext.get("custom-tweet-button").dom.title = "Tweet this";
var fb_url = "https://www.facebook.com/dialog/feed?app_id=307560442683468&redirect_uri="
+ Ext.state.Manager.getProvider().getPrettyLink()
+ '&link='
+ Ext.state.Manager.getProvider().getPrettyLink();
Ext.get("fb-button")
.update(
'<a href="' + fb_url + '">' + OpenLayers.i18n('Like!')
+ '</a>');
Ext.get("fb-button").dom.title = "Like this";
// feedback window
// var feedbackWindow;
// var newFeedbackWindow = function() {
// feedbackWindow = new GeoNetwork.FeedbackForm(null, record);
// feedbackWindow.show();
// };
//
// feedback button to open window
// Ext.getCmp("metadata-panel").getTopToolbar().addButton({
// id : 'feedback-button',
// width : button_width,
// height : button_height,
// tooltip : 'Feedback',
// handler : newFeedbackWindow,
// text : '',
// tooltip : OpenLayers.i18n('Feedback'),
// type : 'submit'
// });
// Adding permalink
Ext.getCmp("metadata-panel").getTopToolbar().addButton({
id : 'viewpanel-permalink',
width : button_width,
height : button_height,
handler : function() {
var url = Ext.state.Manager.getProvider().getPrettyLink();
Ext.get("permalink-div").update(url);
toggle("permalink-div");
},
text : '',
tooltip : OpenLayers.i18n('Permalink'),
enableToggle : true,
type : 'submit',
iconCls: GeoNetwork.Settings.viewPanelButtonCSS('viewpanel-permalink')
});
Ext.getCmp("metadata-panel").doLayout();
// Add to recent viewed removed for EEA IPG layout
// addToRecentViewed(record);
}
function addToRecentViewed(record) {
var div = Ext.getCmp("recent-viewed");
if (!div) {
var store = new Ext.data.ArrayStore({
autoDestroy : true,
autoSave : true,
storeId : 'recent-viewed-store',
idIndex : 0,
fields : [ 'thumbnail', 'description', 'uuid', 'title' ]
});
var tpl = new Ext.XTemplate(
'<tpl for=".">',
'<div class="thumb-wrap" id="recent-viewed_{uuid}">',
'<a href="javascript:app.searchApp.addMetadata(\'{uuid}\', true);">',
//'<div class="thumb">',
'<h1>{title}</h1>',
//'<span>{description}</span>',
//'</div>',
'</a>',
'</div>',
'</tpl>');
div = new Ext.DataView({
store : store,
tpl : tpl,
autoHeight : true,
overClass : 'x-view-over',
id : "recent-viewed",
emptyText: 'No metadata viewed/edited recently'
});
var p = new Ext.Panel({
border : false,
bodyCssClass : 'md-view',
items : div,
renderTo: "recent-viewed-div",
id: "recent-items-panel"
});
catalogue.on('afterLogout', function() {
store.removeAll(); // empty store underlying dataview
});
}
var description = record.get('abstract');
if (description.length > 140) {
description = description.substring(0, 140) + "...";
}
var alreadyThere = false;
Ext.each(div.store.data.items, function(e) {
if (e.data.uuid === record.get('uuid')) {
// just in case any info changed, then update
e.beginEdit();
e.data.title = record.get('title');
e.data.thumbnail = record.get('thumbnail'),
e.data.description = description;
alreadyThere = true;
e.endEdit();
e.commit(true);
}
});
if (!alreadyThere) {
div.store.insert(0, new div.store.recordType({
title : record.get('title'),
uuid : record.get('uuid'),
thumbnail : record.get('thumbnail'),
description : description
}));
} else {
div.refresh(); // store may have been updated above
}
while (div.store.data.length > 5) {
div.store.remove(div.store.data.items[div.store.data.length - 1]);
}
}
// public space:
return {
mapApp : null,
searchApp : null,
loginApp : null,
breadcrumb : null,
switchMode : function(i, j) {
},
/**
* Deprecated, but maintained for compatibility with old UI versions. Do
* not use, look for app.mapApp.maps or app.mapApp.getMap
*/
getIMap : function() {
return this.mapApp;
},
/**
* Hides everything but the map, which becomes "fullscreen"
*/
showBigMap : function() {
showBigMap();
},
/**
* Hides the "fullscreen" map in order to show the rest of the elements
* (search and results, mostly).
*/
hideBigMap : function() {
hideBigMap();
},
/**
* Initializes cookies, connections, url, etc,...
*/
initializeEnvironment : function() {
var geonetworkUrl = window.location.href.match(
/(http.*\/.*)\/srv\.*/, '')[1];
urlParameters = GeoNetwork.Util.getParameters(location.href);
var lang = /srv\/([a-z]{3})\/search/.exec(location.href);
if (lang === null) {
lang = GeoNetwork.Util.defaultLocale;
} else if (Ext.isArray(lang)) {
lang = lang[1];
}
if (urlParameters.extent) {
urlParameters.bounds = new OpenLayers.Bounds(
urlParameters.extent[0], urlParameters.extent[1],
urlParameters.extent[2], urlParameters.extent[3]);
}
createLanguagesMenu(lang);
// Init cookie
cookie = new Ext.state.CookieProvider({
expires : new Date(new Date().getTime()
+ (1000 * 60 * 60 * 24 * 365))
});
// Create connection to the catalogue
catalogue = new GeoNetwork.Catalogue(
{
// statusBarId: 'info',
lang : lang,
statusBarId : 'info',
hostUrl : geonetworkUrl,
mdOverlayedCmpId : 'resultsPanel',
adminAppUrl : geonetworkUrl + '/srv/' + lang + '/admin',
// Declare default store to be used for records and
// summary
metadataStore : GeoNetwork.Settings.mdStore ? new GeoNetwork.Settings.mdStore()
: new GeoNetwork.data.MetadataResultsStore(),
metadataCSWStore : GeoNetwork.data
.MetadataCSWResultsStore(),
summaryStore : GeoNetwork.data.MetadataSummaryStore(),
editMode : 2,
metadataEditFn : edit,
metadataShowFn : show
});
// Make sure we are still logged in:
var response = OpenLayers.Request.GET({
url : geonetworkUrl + '/srv/' + lang + '/admin',
async : false
}), exception;
// Check status and also check than an Exception is not described in
// the
// HTML response
// in case of bad startup
exception = response.responseText.indexOf('Exception') !== -1;
//PRI: All user are logged in using ECAS and inherently Registered users - This is important to set to get menus etc working correctly
catalogue.identifiedUser = 'RegisteredUser';
// if (response.status !== 200 || exception) {
// delete cookie.state.user;
// } else {
// catalogue.identifiedUser = cookie.get('user');
// }
// set a permalink provider which will be the main state provider.
Ext.state.Manager
.setProvider(new GeoNetwork.state.PermalinkProvider({
encodeType : false
}));
createLatestUpdate();
createPopularUpdate();
createMainTagCloud();
this.breadcrumb = GeoNetwork.BreadCrumb();
this.breadcrumb.setCurrent(this.breadcrumb.defaultSteps[0]);
},
/**
* Function to initialize the App. Should only call utilities and their
* init function. Keep it clean.
*/
init : function() {
this.initializeEnvironment();
// Initialize utils
this.loginApp = new GeoNetwork.loginApp();
this.loginApp.init();
this.mapApp = new GeoNetwork.mapApp();
var layers={}, options={};
if(GeoNetwork.map.CONTEXT || GeoNetwork.map.OWS) {
options = GeoNetwork.map.CONTEXT_MAIN_MAP_OPTIONS;
} else {
options = GeoNetwork.map.MAIN_MAP_OPTIONS;
layers = GeoNetwork.map.BACKGROUND_LAYERS;
}
this.mapApp.init(options, layers);
this.searchApp = new GeoNetwork.searchApp();
this.searchApp.init();
if (urlParameters.create !== undefined && catalogue.isIdentified()) {
var actionCtn = Ext.getCmp('resultsPanel').getTopToolbar();
actionCtn.createMetadataAction.handler.apply(actionCtn);
}
},
edit : function(uuid) {
edit(uuid);
},
switchMode : function() {
// Deprecated
}
};
};
Ext.onReady(function() {
resetAdvancedSearch();
hideAdvancedSearch();
var lang = /srv\/([a-z]{3})\/search/.exec(location.href);
if (lang === null) {
lang = GeoNetwork.Util.defaultLocale;
} else if (Ext.isArray(lang)) {
lang = lang[1];
}
var url = /(.*)\/srv/.exec(location.href)[1];
GeoNetwork.Util.setLang(lang, url + '/apps');
// This should be on search.xls, but IE9 is too fast
var spiders = Ext.get("only_for_spiders");
if (spiders) {
spiders.setVisibilityMode(Ext.Element.DISPLAY);
spiders.hide();
}
if (Ext.isIE6) {
Ext.get(Ext.query("html")[0]).addClass("lt-ie9 lt-ie8 lt-ie7");
} else if (Ext.isIE7) {
Ext.get(Ext.query("html")[0]).addClass("lt-ie9 lt-ie8");
} else if (Ext.isIE8) {
Ext.get(Ext.query("html")[0]).addClass("lt-ie9");
}
Ext.QuickTips.init();
app = new GeoNetwork.app();
app.init();
GeoNetwork.Util.updateHeadInfo({
title : catalogue.getInfo().name
});
initShortcut();
if (Ext.getDom('E_any')) {
Ext.getDom('E_any').focus(true);
}
// Restoring session (if any)
Ext.state.Manager.getProvider().restore(location.href);
GeoNetwork.state.History.init();
// Register events where the search should be triggered
var events = [ 'afterDelete', 'afterRating', 'afterLogin' ];
Ext.each(events, function(e) {
// for all events - do the following
catalogue.on(e, function() {
if (Ext.get(resultsPanel).isVisible()) {
var e = Ext.getCmp('advanced-search-options-content-form');
e.getEl().fadeIn();
e.fireEvent('search');
}
});
// if after login then refresh metadata record in view and
// action menu
if (e === 'afterLogin') {
catalogue.on(e, function() {
var metadataPanel = Ext.getCmp('metadata-panel');
if (metadataPanel && metadataPanel.isVisible()) {
var theUuid = metadataPanel.metadataUuid;
// Refresh metadata record in view, otherwise destroy
// the viewer and display an error as metadata record
// may no longer be available
if (!metadataPanel.refreshView()) {
metadataPanel.destroy();
var e = Ext.getCmp('advanced-search-options-content-form');
e.getEl().fadeIn();
e.fireEvent('search');
GeoNetwork.Message().msg({
title: OpenLayers.i18n('error'),
msg: OpenLayers.i18n('metadata-not-found'),
tokens: {
uuid: theUuid
},
status: 'warning',
target: document.body
});
}
}
});
}
// if after delete event called then destroy metadataPanel as view
// is no longer valid/available
if (e === 'afterDelete') {
catalogue.on(e, function() {
var metadataPanel = Ext.getCmp('metadata-panel');
if (metadataPanel && metadataPanel.isVisible()) {
metadataPanel.destroy();
var e = Ext.getCmp('advanced-search-options-content-form');
e.getEl().fadeIn();
e.fireEvent('search');
}
});
}
});
if (!cookie.get("alreadyShowMessage")) {
GeoNetwork.Message().msg({
title : OpenLayers.i18n('cookies'),
msg : OpenLayers.i18n('cookies.warning')
+ "<p><input type='button' value='"
+ OpenLayers.i18n('disclaimer.buttonClose')
+ "' onclick=\"Ext.get('cookie-warning').remove();\"/></p>",
status : 'information',
target : document.body,
id : 'cookie-warning',
pause : 40
});
cookie.set('alreadyShowMessage', true);
}
Ext.getCmp("fullTextField").keyNav.enter = function(e) {
Ext.getCmp('advanced-search-options-content-form').fireEvent(
'search');
};
});
/**
* Resize maps and panels on window resize to acomodate content
*/
Ext.fly(window).on('resize', function(e, w) {
resizeMap();
resizeResultsPanel();
var doLayout_children = function(obj) {
if (obj.doLayout) {
obj.doLayout(true, true);
}
if (obj.items && obj.items.items) {
Ext.each(obj.items.items, function(e) {
if (e.doLayout) {
doLayout_children(e);
}
});
}
if (obj.doLayout) {
obj.doLayout(true, true);
}
};
//doLayout_children(Ext.getCmp("advSearchTabs"));
});