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
|
{#
/*
* Spring Signage Ltd - http://www.springsignage.com
* Copyright (C) 2015 Spring Signage Ltd
* (${FILE_NAME})
*/
#}
{% extends "authed.twig" %}
{% import "inline.twig" as inline %}
{% block pageContent %}
{# Get the display width / height #}
{% set designerScale = min((resolution.designerWidth / layout.width), (resolution.designerHeight / layout.height)) %}
{# Version 2 layout can support zooming? #}
{% if layout.schemaVersion > 1 %}
{% set designerScale = designerScale * zoom %}
{% endif %}
{# Reset the designer width / height based on the zoom #}
{% set width = layout.width * designerScale %}
{% set height = layout.height * designerScale %}
{# Layout Background #}
{% if layout.backgroundImageId == 0 %}
{% set backgroundCss = layout.backgroundColor %}
{% else %}
{% set backgroundCss %}url('{{ urlFor("layout.download.background", {id: layout.layoutId}) }}?preview=1&width={{ width }}&height={{ height }}&proportional=0&layoutBackgroundId={{ layout.backgroundImageId }}') top center no-repeat; background-color: {{ layout.backgroundColor }}{% endset %}
{% endif %}
<div class="layout-toolbox row">
<div class="col-md-12">
<div class="panel bttm-fix with-nav-tabs panel-primary">
<div class="panel-heading">
<ul class="nav nav-tabs">
<li class="active tab-design">
<a class="text-center" id="designer-tab" href="#tab1primary" data-toggle="tab"><i class="fa fa-pencil-square-o" aria-hidden="true"></i> {% trans "Designer" %}</a>
</li>
<li class="tab-design">
<a class="text-center" id="action-tab" href="#tab2primary" data-toggle="tab"><i class="fa fa-bell" aria-hidden="true"></i> {% trans "Actions" %}</a>
</li>
<div class="pull-right">
<span class="text-center" data-toggle="tooltip" data-placement="bottom" data-title="{% trans "Layout Duration: Duration may change depending on the exact number of items in ticker/twitter media items." %}">
<i class="fa fa-clock-o" aria-hidden="true"></i> {% trans "" %}
<span id="layout-duration" class="label label-success big-duration"></span></span>
<span>| <b>Currently Editing</b></span>
<select id="layoutJumpList" data-live-search="true" data-width="auto">
{% for item in layouts %}
<option value="{{ urlFor("layout.designer", {id: item.layoutId}) }}"{% if item.layoutId == layout.layoutId %} selected{% endif %}>{{ item.layout }}</option>
{% endfor %}
</select>
</div>
</ul>
</div>
<div class="panel-body">
<div class="tab-content">
<div class="tab-pane no-pad fade in active" id="tab1primary">
<div class="col-md-3 text-center">
<div class="btn-group btn-group-justified" role="group" aria-label="...">
<div class="btn-group" role="group">
<a class="XiboFormButton btn btn-default btn-sm" role="button" href="{{ urlFor("layout.edit.form", {id: layout.layoutId}) }}" title="{% trans "Edit the Layout Properties" %}"><span><i class="fa fa-picture-o" aria-hidden="true"></i> {% trans "Background" %}</span></a>
</div>
<div class="btn-group" role="group">
<a class="btn btn-info btn-sm" id="regionAddButton" role="button" href="{{ urlFor("region.add", {id: layout.layoutId}) }}"><span><i class="fa fa-plus" aria-hidden="true"></i> {% trans "Region" %}</span></a>
</div>
</div>
</div>
<div class="col-md-2 text-center">
{% if currentUser.routeViewable("/user") %}
<div class="designer-control-panel-checkbox override-layout">
<input type="checkbox" class="switch-check-box" name="lockPosition" data-size="small" data-off-color="danger" data-on-color="success" data-label-width="100" data-label-text="{% trans "Lock Positions" %}" {% if currentUser.getOptionValue("lockPosition", "false") == "true" %}checked="checked"{% endif %}
data-on-text="{% trans "On" %}" data-off-text="{% trans "Off" %}"/>
</div>
{% endif %}
</div>
<div class="col-md-2 text-center">
{% if currentUser.routeViewable("/user") %}
<div class="designer-control-panel-checkbox override-layout">
<input type="checkbox" data-size="small" data-off-color="danger" data-on-color="success" class="switch-check-box" data-label-text="{% trans "Hide Controls" %}" data-label-width="100" name="hideControls" {% if currentUser.getOptionValue("hideControls", "false") == "true" %}checked="checked"{% endif %}
data-on-text="{% trans "On" %}" data-off-text="{% trans "Off" %}"/>
</div>
{% endif %}
</div>
<div class="col-md-2 text-center">
<div class="btn-group btn-group-justified" role="group" aria-label="...">
<div class="btn-group" role="group">
<a class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="bottom" title="{% trans "Decrease the canvas size" %}" role="button" href="{{ urlFor("layout.designer", {id: layout.layoutId}) }}?zoom={{ zoom - 0.3 }}" ><span><i class="fa fa-search-minus" aria-hidden="true"></i>{% trans "" %}</span> </a>
</div>
<div class="btn-group" role="group">
<a class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="bottom" title="{% trans "Increase the canvas size" %}" role="button" href="{{ urlFor("layout.designer", {id: layout.layoutId}) }}?zoom={{ zoom + 0.3 }}"><span><i class="fa fa-search-plus" aria-hidden="true"></i> {% trans "" %}</span></a>
</div>
<div class="btn-group" role="group">
<button id="saveDesignerSize" data-toggle="tooltip" data-placement="bottom" title="{% trans "Save canvas size as default" %}" class="btn btn-success btn-sm " role="button" data-designer-size="{{ zoom }}">
<i class="fa fa-floppy-o" aria-hidden="true"></i></button>
</div>
</div>
</div>
<div class="col-md-3 text-center">
<div class="btn-group" role="group" aria-label="...">
<div class="btn-group" role="group">
<button id="layout-revert" class="btn btn-warning btn-sm disabled btn-block">
<i class="fa fa-undo" aria-hidden="true"></i> {% trans "Undo" %}</button>
</div>
<div class="btn-group" role="group">
<button id="layout-save-all" class="btn btn-success btn-sm disabled btn-block">
<i class="fa fa-floppy-o" aria-hidden="true"></i> {% trans "Save Region Positions" %}
</button>
</div>
</div>
</div>
</div>
<div class="tab-pane no-pad fade" id="tab2primary">
<div class="col-md-6">
<div class="btn-group btn-group-justified" role="group" aria-label="...">
<div class="btn-group" role="group">
<a class="btn btn-success btn-sm" role="button" href="{{ urlFor("layout.preview", {id: layout.layoutId}) }}" target="_blank"><span><i class="fa fa-eye" aria-hidden="true"></i> {% trans "Preview Layout" %}</span></a>
</div>
<div class="btn-group" role="group">
<a class="XiboFormButton btn btn-info btn-sm" id="schedule-btn" role="button" href="{{ urlFor("schedule.now.form", {id: layout.campaignId, from: "Campaign"}) }}"><span><i class="fa fa-clock-o" aria-hidden="true"></i> {% trans "Schedule Now" %}</span></a>
</div>
<div class="btn-group" role="group">
<a class="XiboFormButton btn btn-warning btn-sm" role="button" href="{{ urlFor("template.from.layout.form", {id: layout.layoutId}) }}"><span><i class="fa fa-floppy-o" aria-hidden="true"></i> {% trans "Save Template" %}</span></a>
</div>
{% if layout.schemaVersion < 2 %}
<div class="btn-group" role="group">
<a class="XiboFormButton btn btn-warning btn-sm" role="button" href="{{ urlFor("layout.upgrade.form", {id: layout.layoutId}) }}"><span><i class="fa fa-floppy-o" aria-hidden="true"></i> {% trans "Upgrade Layout" %}</span></a>
</div>
{% endif %}
</div>
</div>
<div class="col-md-6">
{% if isTemplate %}
<div class="alert no-pad alert-info text-right">{% trans "Editing a Template will only affect future Layouts." %}</div>
{% else %}
<div id="layout-status" class="alert no-pad text-center" style="margin-bottom: 0px;"></div>
{% endif %}
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div id="layout" zoom="{{ zoom }}" tip_scale="1" designer_scale="{{ designerScale }}" class="layout center-block" layoutid="{{ layout.layoutId }}" data-background-color="{{ layout.backgroundColor }}" data-status-url="{{ urlFor("layout.status", {id: layout.layoutId}) }}" data-position-all-url="{{ urlFor("region.position.all", {id: layout.layoutId}) }}" style="position:relative; width:{{ width }}px; height:{{ height }}px; background:{{ backgroundCss }};">
{% for region in layout.regions %}
{% set regionWidth = region.width * designerScale %}
{% set regionHeight = region.height * designerScale %}
{% set regionLeft = region.left * designerScale %}
{% set regionTop = region.top * designerScale %}
{# Disabled / Enabled CSS #}
{% if currentUser.checkEditable(region) %}
{% set disabledCss = "region" %}
{% set trasparencyCss = "" %}
{% else %}
{% set disabledCss = "regionDis" %}
{% set trasparencyCss = "regionDisabled" %}
{% endif %}
{% if currentUser.checkViewable(region) %}
{% set previewCss = "regionPreview" %}
{% else %}
{% set previewCss = "" %}
{% endif %}
<div id="region_{{ region.regionId }}" regionEnabled="{{ currentUser.checkEditable(region) }}" regionid="{{ region.regionId }}" layoutid="{{ layout.layoutId }}" zindex="{{ region.zIndex }}" tip_scale="1" designer_scale="{{ designerScale }}" width="{{ region.width }}" height="{{ region.height }}" href="{{ urlFor("region.timeline.form", {id: region.regionId}) }}" {% if currentUser.checkEditable(region) %}ondblclick="XiboFormRender($(this))"{% endif %} class="{{ disabledCss }} {{ previewCss }}" data-preview-url="{{ urlFor("region.preview", {id: region.regionId}) }}" style="position:absolute; width:{{ regionWidth }}px; height:{{ regionHeight }}px; top: {{ regionTop }}px; left:{{ regionLeft }}px; z-index: {{ region.zIndex }};">
<div class="regionTransparency {{ transparencyCss }}" style="width:100%; height:100%;"></div>
{% if currentUser.checkEditable(region) %}
<div class="btn-group regionInfo pull-right">
<button class="btn dropdown-toggle" data-toggle="dropdown">
<span class="region-tip">{{ region.width|round }} x {{ region.height|round }} ({{ region.left|round }} ,{{ region.top|round }})</span> <span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li>
<a class="XiboFormButton" href="{{ urlFor("region.timeline.form", {id: region.regionId}) }}">{% trans "Edit Timeline" %}</a>
</li>
<li>
<a class="RegionOptionsMenuItem" href="{{ urlFor("region.edit.form", {id: region.regionId}) }}">{% trans "Options" %}</a>
</li>
<li>
<a class="XiboFormButton" href="{{ urlFor("region.delete.form", {id: region.regionId}) }}">{% trans "Delete" %}</a>
</li>
<li>
<a class="XiboFormButton" href="{{ urlFor("user.permissions.form", {entity: "Region", id: region.regionId}) }}">{% trans "Permissions" %}</a>
</li>
</ul>
</div>
{% elseif layout.schemaVersion >= 2 and currentUser.checkViewable(region) %}
<div class="regionInfo">
<span class="region-tip">{{ region.width|round }} x {{ region.height|round }}
({{ region.left|round }}
,{{ region.top|round }})</span>
</div>
{% endif %}
<div class="preview">
<div class="previewContent">
</div>
<div class="previewNav label label-info"></div>
</div>
</div>
{% endfor %}
</div>
</div>
</div>
{% if layout.schemaVersion < 2 %}
<div class="row">
<div class="col-sm-12">
<p class="alert alert-danger">{% trans "This is an old format layout, please consider upgrading using Actions tab" %}</p>
</div>
</div>
{% endif %}
{% if designerScale < 0.41 %}
<div class="row">
<div class="col-sm-12">
<p class="alert alert-danger">{% trans "This Layout is very large, so we have disabled region drag and drop. You could enlarge the designer from the options menu or use Region Options to Manually Position your regions." %}</p>
</div>
</div>
{% endif %}
{% endblock %}
{% block javaScript %}
<script src="{{ theme.uri("js/xibo-layout-designer.js") }}?{{ version }}"></script>
<script type="text/javascript">
var translation = {
savePositionsFirst: "{% autoescape "js" %}{{ "Please save the pending position changes first by clicking Save Positions or cancel by clicking Undo."|trans }}{% endautoescape %}"
};
// Callback for the media form
function mediaFormCallBack(dialog) {
$(dialog).closest(".modal").addClass("modal-big");
// prevent filter form submit
$("#libraryAssignFilterOptions").find("form").on("submit", function(e) {
e.preventDefault();
return false;
});
var mediaTable = $("#mediaAssignments").DataTable({
"language": dataTablesLanguage,
serverSide: true, stateSave: true,
searchDelay: 3000,
"order": [[1, "asc"]],
"filter": false,
ajax: {
url: "{{ urlFor("library.search") }}",
"data": function (d) {
$.extend(d, $("#libraryAssignFilterOptions").find("form").serializeObject());
}
},
"columns": [
{"data": "mediaId"},
{"data": "name"},
{"data": "mediaType"},
{
"name": "mediaId",
"data": null,
"render": function (data, type, row, meta) {
if (type === "display") {
// Return only the image part of the data
if (data.thumbnailUrl === '')
return '';
else
return '<img src="' + data.thumbnailUrl + '"/>';
return data;
} else {
return row.mediaId;
}
}
},
{
"sortable": false,
"data": function (data, type, row, meta) {
if (type !== "display")
return "";
// Create a click-able span
return "<a href=\"#\" class=\"assignItem\"><span class=\"glyphicon glyphicon-plus-sign\"></a>";
}
}
]
});
mediaTable.on('draw', function (e, settings) {
dataTableDraw(e, settings);
// Clicky on the +spans
$(".assignItem", "#mediaAssignments").click(function () {
// Get the row that this is in.
var data = mediaTable.row($(this).closest("tr")).data();
// Construct a new list item for the lower list and append it.
var newItem = $("<li/>", {
"text": " " + data.name,
"data-media-id": data.mediaId,
"class": "li-sortable",
"dblclick": function () {
$(this).remove();
}
});
newItem.appendTo("#LibraryAssignSortable");
// Add a span to that new item
$("<span/>", {
"class": "glyphicon glyphicon-minus-sign",
click: function () {
$(this).parent().remove();
}
}).prependTo(newItem);
});
});
mediaTable.on('processing.dt', dataTableProcessing);
// Make our little list sortable
$("#LibraryAssignSortable").sortable();
// Bind the filter form
$("#libraryAssignFilterOptions").find("input, select").change(function () {
mediaTable.ajax.reload();
});
}
/**
* Open Upload Form
*/
function openUploadForm(templateOptions, buttons) {
// 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: buttons,
animate: false,
updateInAllChecked: {% if settings.LIBRARY_MEDIA_UPDATEINALL_CHECKB == "Checked" %}true{% else %}false{% endif %},
deleteOldRevisionsChecked: {% if settings.LIBRARY_MEDIA_DELETEOLDVER_CHECKB == "Checked" %}true{% else %}false{% endif %}
});
openUploadFormModelShown($(".modal-body").find("form"));
}
/**
* Modal shown
*/
function openUploadFormModelShown(form) {
// Configure the upload form
var url = "{{ urlFor("library.add") }}";
// Initialize the jQuery File Upload widget:
form.fileupload({
url: url,
disableImageResize: true
});
// 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);
});
}
// Click Handler for Library Upload Buttons (image, video, powerpoint, flash)
function libraryUploadClick(e) {
e.preventDefault();
var validExt = $(this).data().validExt.replace(/,/g, "|");
var playlistId = $(this).data().playlistId;
openUploadForm({
trans: {
addFiles: "{% trans "Add files" %}",
startUpload: "{% trans "Start upload" %}",
cancelUpload: "{% trans "Cancel upload" %}"
},
upload: {
maxSize: {{ libraryUpload.maxSize }},
maxSizeMessage: "{{ libraryUpload.maxSizeMessage }}",
validExt: validExt
},
playlistId: playlistId
}, {
library: {
label: "{% trans "View Library" %}",
callback: function () {
XiboFormRender("{{ urlFor("playlist.library.assign.form") }}".replace(":id", playlistId));
}
},
main: {
label: "{% trans "Done" %}",
className: "btn-primary",
callback: function () {
XiboFormRender(timelineForm.url, timelineForm.value);
}
}
});
}
/**
* 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,
{% if config.LIBRARY_MEDIA_UPDATEINALL_CHECKB == "Checked" %}
updateInAllChecked: true,
{% else %}
updateInAllChecked: 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
}
}, {
main: {
label: "{% trans "Done" %}",
className: "btn-primary",
callback: function () {
XiboFormRender(timelineForm.url, timelineForm.value);
}
}
});
});
footer.find(".btn-primary").before(replaceButton);
}
function timelineGridCallback(dialog) {
dialog.addClass("modal-big");
var timelineWidgetTabel = $("#timelineWidgets").DataTable({
"language": dataTablesLanguage,
serverSide: true, stateSave: true,
filter: false,
searchDelay: 3000,
"order": [[0, "asc"]],
ajax: {
url: "{{ urlFor("playlist.widget.search") }}",
"data": function (d) {
$.extend(d, $("#timelineWidgets").closest(".XiboGrid").find(".FilterDiv form").serializeObject());
}
},
"columns": [
{"data": "displayOrder"},
{"data": "name", "orderable": false},
{"data": "type"},
{
"data": "calculatedDuration",
"render": function(data) {
return (data == 0) ? 'N/A' : data;
}
},
{"data": "transition"},
{
"orderable": false,
"data": dataTableButtonsColumn
}
]
});
timelineWidgetTabel.on('draw', dataTableDraw);
timelineWidgetTabel.on('processing.dt', dataTableProcessing);
// Hook up the library Upload Buttons
$(".libraryUploadForm").click(libraryUploadClick);
}
function DeleteRegion(form, regionId) {
$.ajax({
type: form.attr("method"),
url: form.attr("action"),
cache: false,
dataType: "json",
data: form.serialize(),
success: function (xhr, textStatus, error) {
XiboSubmitResponse(xhr, form);
if (xhr.success)
$("#region_" + regionId).remove();
},
error: function (xhr, textStatus, errorThrown) {
SystemMessage(xhr.responseText, false);
}
});
}
// Bind to the add button when we load
$(document).ready(function () {
// Add region button
$("#regionAddButton").click(function (e) {
e.preventDefault();
$.ajax({
type: "post",
url: $(this).attr("href"),
cache: false,
dataType: "json",
success: function (xhr, textStatus, error) {
XiboSubmitResponse(xhr);
if (xhr.success) {
// Reload the designer
window.location.reload();
}
}
});
});
});
$("[name='my-checkbox']").bootstrapSwitch();
</script>
{% for module in modules %}
{% if module.layoutDesignerJavaScript() != "" %}
{% include module.layoutDesignerJavaScript() ~ ".twig" %}
{% endif %}
{% endfor %}
{% endblock %}
|