-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
/
toolbar_javascript.html
79 lines (75 loc) · 4.04 KB
/
toolbar_javascript.html
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
{% load i18n l10n sekizai_tags admin_static cms_tags %}
{% addtoblock "css" %}<link rel="stylesheet" href="{% static "cms/css/cms.base.css" %}?{{ cms_version }}" />{% endaddtoblock %}
{% addtoblock "js" %}
<script src="{% static "cms/js/modules/jquery.noconflict.pre.js" %}?{{ cms_version }}" type="text/javascript"></script>
<script src="{% static "cms/js/dist/bundle.toolbar.min.js" %}?{{ cms_version }}" type="text/javascript"></script>
{% language request.toolbar.toolbar_language %}
<script>
CMS._plugins = [];
(function($) {
// CMS.$ will be passed for $
$(document).ready(function () {
// this is a global shared configuration
CMS.config = {
'mode': {% if request.toolbar.edit_mode %}'draft'{% else %}'live'{% endif %},
'auth': {% if user.is_authenticated %}true{% else %}false{% endif %},
'debug': {% if debug %}true{% else %}false{% endif %},
'csrf': '{{ csrf_token }}',
'request': {
'language': '{{ request.GET.language }}',
'model': '{{ request.toolbar.get_object_model }}',
'page_id': '{% if request.current_page.publisher_is_draft %}{{ request.current_page.pk }}{% else %}{{ request.current_page.publisher_public_id }}{% endif %}',
'pk': '{{ request.toolbar.get_object_pk }}',
'url': '{% language request.toolbar.language %}{% cms_admin_url "cms_page_resolve" %}{% endlanguage %}',
'tree': '{% language request.toolbar.language %}{% cms_admin_url "cms_page_changelist" %}{% endlanguage %}'
},
'lang': {
'debug': '{% blocktrans %}Development version using django CMS {{ cms_version }}{% endblocktrans %}',
'cancel': '{% trans "Cancel" %}',
'error': '<strong>{% trans "The following error occured:" %}</strong> ',
'success': '{% trans "Action successfull... reloading." %}',
'confirm': '{% trans "Are you sure you want to delete this plugin?" %}',
'confirmEmpty': '{% trans "({1}) plugin is empty. Remove it?" %}',
'publish': '{% trans "Are you sure you want to publish this page?" %}',
'addPluginPlaceholder': '{% trans "Plugin will be added here" %}'
},
'urls': {
'settings': '{% cms_admin_url "cms_usersettings_session_store" %}', // url to save settings
'static': '{{ STATIC_URL }}'
},
'settings': {
'version': '{{ cms_version }}',
'toolbar': 'expanded',
'mode': 'edit',
'sideframe': { 'url': '' },
'states': [],
'edit': '{{ cms_edit_on }}',
'edit_off': '{{ cms_edit_off }}'
},
'clipboard': {
'id': '{{ request.toolbar.clipboard.pk|unlocalize }}',
'url': '{% if request.toolbar.clipboard.pk %}{% cms_admin_url "cms_page_clear_placeholder" request.toolbar.clipboard.pk %}{% endif %}'
},
'messages': '{% if messages %}{% for message in messages %}{{ message }}{% endfor %}{% endif %}',
'error': '{% if request.toolbar.login_form.errors or cms_toolbar_login_error %}{% blocktrans %}<strong>Login failed.</strong> Please check your credentials and try again.{% endblocktrans %}{% endif %}',
'publisher': '{% if not request.current_page.publisher_is_draft and request.current_page.publisher_draft.is_dirty and user.is_authenticated %}{% trans "This page has unpublished changes." %}{% endif %}',
'simpleStructureBoard': {{ request.toolbar.simple_structure_mode|lower }}
};
CMS.settings = CMS.API.Helpers.getSettings();
// extends API
$.extend(CMS.API, {
'Toolbar': new CMS.Toolbar(),
'Clipboard': new CMS.Clipboard(),
'StructureBoard': new CMS.StructureBoard(),
'Messages': new CMS.Messages(),
'Tooltip': new CMS.Tooltip()
});
$.each(CMS._plugins, function (index, args) {
new CMS.Plugin(args[0], args[1])
});
});
})(CMS.$);
</script>
{% endlanguage %}
<script src="{% static "cms/js/modules/jquery.noconflict.post.js" %}?{{ cms_version }}" type="text/javascript"></script>
{% endaddtoblock %}