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
|
{% extends "authed.twig" %}
{% import "inline.twig" as inline %}
{% block pageContent %}
<div class="widget">
<div class="widget-title">{% trans "All Layouts and Media" %}</div>
<div class="widget-body">
<div class="XiboGrid" id="{{ random() }}" data-grid-name="mediaManagerView">
<div class="XiboFilter well">
<div class="FilterDiv" id="Filter">
<form class="form-inline">
{% set title %}{% trans "Layout" %}{% endset %}
{{ inline.input("layout", title) }}
{% set title %}{% trans "Region" %}{% endset %}
{{ inline.input("region", title) }}
{% set title %}{% trans "Media" %}{% endset %}
{{ inline.input("media", title) }}
{% set title %}{% trans "Module" %}{% endset %}
{{ inline.dropdown("type", "single", title, "", [{type:null, name:""}]|merge(modules), "type", "name") }}
</form>
</div>
</div>
<div class="XiboData">
<table id="entries" class="table table-striped">
<thead>
<tr>
<th>{% trans "Layout" %}</th>
<th>{% trans "Region" %}</th>
<th>{% trans "Playlist" %}</th>
<th>{% trans "Widget" %}</th>
<th>{% trans "Type" %}</th>
<th>{% trans "Display Order" %}</th>
<th></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
</div>
{% endblock %}
{% block javaScript %}
<script type="text/javascript">
$(document).ready(function() {
var table = $("#entries").DataTable({
"language": dataTablesLanguage,
serverSide: false,
filter: false,
searchDelay: 3000,
"order": [[1, "asc"]],
ajax: {
url: "{{ urlFor("mediaManager.search") }}",
"data": function (d) {
$.extend(d, $("#entries").closest(".XiboGrid").find(".FilterDiv form").serializeObject());
}
},
"columns": [
{"data": "layout.layout"},
{"data": "region"},
{"data": "playlist"},
{"data": "widget"},
{"data": "type"},
{"data": "displayOrder"},
{
"orderable": false,
"data": dataTableButtonsColumn
}
]
});
table.on('draw', dataTableDraw);
table.on('processing.dt', dataTableProcessing);
dataTableAddButtons(table, $('#entries_wrapper').find('.col-sm-6').eq(1));
});
/**
* Open Upload Form
*/
function openUploadForm(templateOptions) {
// Close the current dialog
XiboDialogClose();
var template = Handlebars.compile($("#template-file-upload").html());
// Handle bars and open a dialog
bootbox.dialog({
message: template(templateOptions),
title: "{% trans "Upload media" %}",
buttons: {
main: {
label: "{% trans "Done" %}",
className: "btn-primary",
callback: function() {
table.ajax.reload();
XiboDialogClose();
}
}
}
}).on('shown.bs.modal', function() {
// Configure the upload form
var url = "{{ urlFor("library.add") }}";
var form = $(this).find("form");
// Initialize the jQuery File Upload widget:
form.fileupload({
url: url,
disableImageResize: false
});
// Upload server status check for browsers with CORS support:
if ($.support.cors) {
$.ajax({
url: url,
type: 'HEAD'
}).fail(function () {
$('<span class="alert alert-error"/>')
.text('Upload server currently unavailable - ' + new Date())
.appendTo(form);
});
}
// Enable iframe cross-domain access via redirect option:
form.fileupload(
'option',
'redirect',
window.location.href.replace(
/\/[^\/]*$/,
'/cors/result.html?%s'
)
);
form.bind('fileuploadsubmit', function (e, data) {
var inputs = data.context.find(':input');
if (inputs.filter('[required][value=""]').first().focus().length) {
return false;
}
data.formData = inputs.serializeArray().concat(form.serializeArray());
inputs.filter("input").prop("disabled", true);
});
});
}
/**
* Media Edit form
*/
function mediaEditFormOpen(dialog) {
if (dialog.find("form").data().mediaEditable != 1)
return;
// Create a new button
var footer = dialog.find(".modal-footer");
var mediaId = dialog.find("form").data().mediaId;
var widgetId = dialog.find("form").data().widgetId;
var validExtensions = dialog.find("form").data().validExtensions;
// Append
var replaceButton = $('<button class="btn btn-warning">').html("{% trans "Replace" %}");
replaceButton.click(function(e) {
e.preventDefault();
// Open the upload dialog with our options.
openUploadForm({
oldMediaId: mediaId,
widgetId: widgetId,
updateInAllChecked: {% if settings.LIBRARY_MEDIA_UPDATEINALL_CHECKB == "Checked" %}true{% else %}false{% endif %},
deleteOldRevisionsChecked: {% if settings.LIBRARY_MEDIA_DELETEOLDVER_CHECKB == "Checked" %}true{% else %}false{% endif %},
trans: {
addFiles: "{% trans "Add Replacement" %}",
startUpload: "{% trans "Start Replace" %}",
cancelUpload: "{% trans "Cancel Replace" %}",
updateInLayouts: {
title: "{% trans "Update this media in all layouts it is assigned to?" %}",
helpText: "{% trans "Note: It will only be updated in layouts you have permission to edit." %}"
},
deleteOldRevisions: {
title: "{% trans "Delete the old version?" %}",
helpText: "{% trans "Completely remove the old version of this media item if a new file is being uploaded." %}"
}
},
upload: {
maxSize: {{ libraryUpload.maxSize }},
maxSizeMessage: "{{ libraryUpload.maxSizeMessage }}",
validExt: validExtensions
}
});
});
footer.find(".btn-primary").before(replaceButton);
}
</script>
{% endblock %}
|