1
|
|
|
/** |
2
|
|
|
* Symphony backend initialisation |
3
|
|
|
* |
4
|
|
|
* @package assets |
5
|
|
|
*/ |
6
|
|
|
|
7
|
|
|
(function($, Symphony) { |
8
|
|
|
|
9
|
|
|
// Set environment |
10
|
|
|
var environment = (function () { |
11
|
|
|
var env = document.getElementById('environment'); |
12
|
|
|
return env ? JSON.parse(env.textContent) : {}; |
13
|
|
|
})(); |
14
|
|
|
Symphony.Context.add(null, environment); |
15
|
|
|
|
16
|
|
|
// Get translations |
17
|
|
|
Symphony.Language.add({ |
18
|
|
|
'Are you sure you want to proceed?': false, |
19
|
|
|
'Reordering was unsuccessful.': false, |
20
|
|
|
'Change Password': false, |
21
|
|
|
'Remove File': false, |
22
|
|
|
'Untitled Field': false, |
23
|
|
|
'The field “{$title}” ({$type}) has been removed.': false, |
24
|
|
|
'Undo?': false, |
25
|
|
|
'untitled': false, |
26
|
|
|
'Expand all': false, |
27
|
|
|
'Collapse all': false, |
28
|
|
|
'drag to reorder': false, |
29
|
|
|
'Please reset your password': false, |
30
|
|
|
'required': false, |
31
|
|
|
'Click to select': false, |
32
|
|
|
'Type to search': false, |
33
|
|
|
'Clear': false, |
34
|
|
|
'Search for {$item}': false, |
35
|
|
|
'Add filter': false, |
36
|
|
|
'filtered': false, |
37
|
|
|
'None': false, |
38
|
|
|
'Clear filters': false, |
39
|
|
|
'Apply filters': false, |
40
|
|
|
'The Symphony calendar widget has been disabled because your system date format is currently not supported. Try one of the following instead or disable the calendar in the field settings:': false, |
41
|
|
|
'no leading zero': false |
42
|
|
|
}); |
43
|
|
|
|
44
|
|
|
// Initialise backend |
45
|
|
|
$(document).ready(function() { |
46
|
|
|
|
47
|
|
|
// Cache main elements |
48
|
|
|
Symphony.Elements.window = $(window); |
49
|
|
|
Symphony.Elements.html = $('html').addClass('js-active'); |
50
|
|
|
Symphony.Elements.body = $('body'); |
51
|
|
|
Symphony.Elements.wrapper = $('#wrapper'); |
52
|
|
|
Symphony.Elements.header = $('#header'); |
53
|
|
|
Symphony.Elements.nav = $('#nav'); |
54
|
|
|
Symphony.Elements.session = $('#session'); |
55
|
|
|
Symphony.Elements.context = $('#context'); |
56
|
|
|
Symphony.Elements.breadcrumbs = $('#breadcrumbs'); |
57
|
|
|
Symphony.Elements.contents = $('#contents'); |
58
|
|
|
|
59
|
|
|
// Create context id |
60
|
|
|
var path = Symphony.Context.get('path'); |
61
|
|
|
var route = Symphony.Context.get('route'); |
62
|
|
|
if (path && route) { |
63
|
|
|
var contextId = (path + route).split('/').filter(function(part) { |
64
|
|
|
return (part != 'edit' && part != 'new' && part != 'created' && part != 'saved' && part != ''); |
65
|
|
|
}).join('.'); |
66
|
|
|
Symphony.Context.add('context-id', contextId); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
// Render view |
70
|
|
|
Symphony.View.render(); |
71
|
|
|
|
72
|
|
|
// Update state to canonical url |
73
|
|
|
if (window.history.replaceState) { |
74
|
|
|
// Let extensions read the window.location, delay change on load |
75
|
|
|
$(window).load(function () { |
76
|
|
|
$('head > link[rel="canonical"][href]').eq(0).each(function () { |
77
|
|
|
var href = $(this).attr('href'); |
78
|
|
|
if (href) { |
79
|
|
|
window.history.replaceState(document.title, null, href); |
80
|
|
|
} |
81
|
|
|
}); |
82
|
|
|
}); |
83
|
|
|
} |
84
|
|
|
}); |
85
|
|
|
|
86
|
|
|
})(window.jQuery, window.Symphony); |
87
|
|
|
|