1translate.add({ 2 'PrzenieÅ': 'Move', 3 'Zasoby': 'Resources', 4 'Åadowanie...': 'Loading...', 5 'BÅÄ d zarzÄ dzania katalogami': 'Directory management error', 6 'ProszÄ wskazaÄ katalog': 'Please indicate the directory', 7 'Zasób zostaÅ przeniesiony': 'The resource has been moved', 8 'Nie udaÅo siÄ przenieÅÄ zasobu': 'Resource could not be moved', 9 'Edycja': 'Edition', 10 'PrzesuÅ w lewo': 'Move left', 11 'PrzesuÅ w prawo': 'Move right', 12 'PrzesuÅ w górÄ': 'Move up', 13 'PrzesuÅ w doÅ': 'Move down', 14 'PowiÄksz': 'Zoom in', 15 'Zmniejsz': 'Reduce', 16 'ObrÃ³Ä w lewo': 'Rotate left', 17 'ObrÃ³Ä w prawo': 'Rotate right', 18 'OdwrÃ³Ä w poziomie': 'Flip horizontally', 19 'OdwrÃ³Ä w pionie': 'Flip vertically', 20 'Resetuj': 'Reset', 21 'Dowolny': 'Any', 22 'Anuluj': 'Cancel', 23 'Nadpisz': 'Overwrite', 24 'Zapisz kopiÄ': 'Save copy', 25 'ZdjÄcie zostaÅo zapisane': 'The photo has been saved', 26 'Nie udaÅo siÄ zapisaÄ zdjÄcia': 'The photo could not be saved', 27 ' (publiczny)': ' (public)', 28 'Pobierz zasób': 'Download resource', 29 'Edytuj wÅaÅciwoÅci zasobu': 'Edit resource properties', 30 'Edytuj zasób': 'Edit resource', 31 'Konwersja pliku do PDF': 'Convert a file to PDF', 32 'UsuÅ zasób': 'Delete resource', 33 'Nagrywanie': 'Recording', 34 'Wstrzymano': 'Paused', 35 'Oczekuje': 'Pending', 36 'PodglÄ d zasobu': 'Resource preview', 37 'Link do zasobu': 'Link to the resource', 38 'Czy na pewno chcesz usunÄ Ä plik?': 'Are you sure you want to delete the file?', 39 'WystÄ piÅ problem z usuwaniem pliku': 'There was a problem deleting the file', 40 'Edycja wÅaÅciwoÅci filmu': 'Editing movie properties', 41 'Sukces': 'Success', 42 'Dodano nowy zasób': 'A new resource has been added', 43 'WystÄ piÅ bÅÄ d podczas próby zapisu - skontaktuj siÄ z administratorem': 'An error occurred while trying to save - contact your administrator', 44 'WystÄ piÅ bÅÄ d podczas zapisywania danych': 'An error occurred while saving the data', 45 'Edycja wÅaÅciwoÅci streamingu': 'Editing streaming properties', 46 'Edytuj zasób LIVE': 'Edit LIVE Resource', 47 'Potwierdź rozpoczÄcie nagrywania': 'Confirm to start recording', 48 'RozpoczÄto nagrywanie': 'Recording has started', 49 'Potwierdź wstrzymanie nagrywania': 'Confirm record pause', 50 'Wstrzymano nagrywanie': 'Recording was paused', 51 'Potwierdź ZAKOÅCZENIE nagrywania': 'Confirm END of recording', 52 'ProszÄ dodaÄ miniaturÄ reprezentujÄ cÄ zasób': 'Please add a thumbnail representing the resource', 53 'Brak danych': 'No data', 54 'Nie udaÅo siÄ ustawiÄ wskazanej wartoÅci.': 'The indicated value could not be set.', 55 ' przez: ': ' by: ', 56 'Tak': 'Yes', 57 'Nie': 'No', 58 'WystÄ piÅ problem podczas zapisu.': 'There was a problem writing.', 59 'Utworzono plik PDF': 'PDF file created', 60 'Konwersja na plik PDF zakoÅczyÅa siÄ niepowodzeniem.': 'Converting to PDF file was unsuccessful.', 61 'PrzenieÅ': 'Move', 62 'Brak plików do wyÅwietlenia': 'No files to display', 63 'Rozmiar pliku': 'File size', 64 'Numer (ID) zasobu': 'Resource ID', 65 'PowiÄ zany tag': 'Related tag' 66}, 'en'); 67 68translate.setLocale($.cookie('language') ? $.cookie('language') : 'pl'); 69 70function FilesContainer() { 71 let _this = this; 72} 73 74FilesContainer.prototype = { 75 defaultIconPath: '/app/img/filemanager/', 76 defaultImagePath: '/resource/image/' + __institution_id + '/' + __project_id + '/', 77 defaultVideoPath: '/resource/video-thumb/' + __institution_id + '/' + __project_id + '/', 78 defaultLiveImagePath: '/itv/index/image/institution.' + __institution_id + '/project.' + __project_id + '/id.', 79 dataSource: '/resource/index/get-resources', 80 editResourceUrl: '/resource/index/edit-file', 81 deleteUrl: '/resource/index/remove-file', 82 downloadUrl: '/resource/file/download-file', 83 moveUrl: '/resource/index/move', 84 pdfUrl: '/resource/index/create-pdf', 85 conversionInfo: '/resource/index/conversion-info', 86 conversionSave: '/resource/index/conversion-set', 87 documentPreviewUrl: '/resource/file/preview', 88 videoSetFrameUrl: '/resource/index/video-create-frame', 89 tagsGetUrl: '/cms/tag/get-tags-json', 90 tagsEditUrl: '/cms/tag/edit-tags', //dodawanie/usuwanie tagów 91 uploadUrl: '/resource/index/upload-file', 92 currentNodeInputId: 'hidden-container-id', 93 container: '#files-list', 94 filesData: {}, 95 node: {}, 96 imageExtensions: ['png', 'jpg', 'jpeg', 'gif', 'bmp', 'svg'], 97 videoExtensions: ['flv', 'mp4'], 98 audioExtensions: ['mp3'], 99 supportedFormatsIcons: ['ac3', 'ace', 'ade', 'adp', 'ai', 'aiff', 'ani', 100 'asf', 'au', 'avi', 'bat', 'bin', 'bmp', 'bsp', 'bup', 'cab', 'cal', 'cat', 101 'css', 'cue', 'cur', 'daa', 'dat', 'dcr', 'der', 'dic', 'divx', 'diz', 'dll', 102 'doc', 'docx', 'dvd', 'dwg', 'dwt', 'fon', 'gam', 'gif', 'hlp', 'hst', 'html', 103 'ico', 'ifo', 'inf', 'ini', 'iso', 'java', 'jiff', 'jpg', 'log', 'm4a', 'mdl', 104 'mid', 'mmf', 'mmm', 'mov', 'mp2', 'mp2v', 'mp3', 'mp4', 'mpeg', 'mpg', 'msp', 'nfo', 105 'pdf', 'php', 'png', 'ppt', 'pptx', 'psd', 'ra', 'rar', 'reg', 'rtf', 'spr', 106 'theme', 'tif', 'tiff', 'tlb', 'torrent', 'ttf', 'txt', 'url', 'vob', 'vtf', 'wad', 107 'wav', 'wma', 'wmv', 'wpl', 'wri', 'xls', 'xlsx', 'xml', 'xps', 'xsl', 'zip'], 108 convertableToPdf: ['txt', 'doc', 'docx', 'ppt', 'pptx', /*'xls','xlsx',*/'odt'], 109 canEdit: false, 110 canRemove: false, 111 112 /** 113 * pobiera i wyÅwietla pliki wewnÄ trz folderu 114 * @param node 115 */ 116 addFolderFiles: function (node) { 117 let sn = 'sort_3'; 118 let sd = 'sorting_desc'; 119 let _this = this; 120 let id = node.li_attr['data-id']; 121 let sortBtn = $('.sort-buttons .active'); 122 123 // sterowanie pokazywaniem dodawania plików 124 // w zależnoÅci od tego czy katalog jest readonly 125 if (node.li_attr['data-ro'] == 1) { 126 // $('.file-upload').hide(); 127 $('#show-file-uploader').prop('checked', false); 128 // $('#show-file-uploader').change(); 129 $('#upload-files-box').parent().slideUp(); 130 } 131 132 // informacja o kierunku sortowania 133 if (sortBtn.hasClass('sorting_desc')) { 134 sd = 'sorting_desc'; 135 } else { 136 sd = 'sorting_asc'; 137 } 138 139 // informacja o elemencie wg. którego nastÄ pi sortowanie 140 if (sortBtn.hasClass('sort_1')) { 141 sn = 'sort_1'; 142 } 143 if (sortBtn.hasClass('sort_2')) { 144 sn = 'sort_2'; 145 } 146 if (sortBtn.hasClass('sort_3')) { 147 sn = 'sort_3'; 148 } 149 if (sortBtn.hasClass('sort_4')) { 150 sn = 'sort_4'; 151 } 152 153 if (sortBtn.hasClass('sort_5')) { 154 sn = 'sort_5'; 155 } 156 157 $.ajax({ 158 type: 'POST', 159 url: _this.dataSource, 160 data: {id: id, sn: sn, sd: sd}, 161 success: function (data) { 162 _this.filesData = data; 163 $(data).each(function (i, v) { 164 var $element = _this.createElement(v); 165 _this.addElement($element, 'append'); 166 }); 167 $('.colorboxElement').colorbox(colorbox_params); 168 } 169 }); 170 }, 171 172 /** 173 * akcja inicjacyjna 174 * @param node 175 */ 176 init: function (node) { 177 if (typeof node !== 'undefined') { 178 this.node = node; 179 } 180 this.clearContainer(); 181 this.addFolderFiles(this.node); 182 this.initCropModal(); 183 this.initMoveModal(); 184 185 new BitModal({ 186 name: 'editResource', 187 title: translate('Edycja zasobu'),
188 sizeClass: 'modal-lg', 189 onShowAction: function (bitModal) { 190 bitModal.options.resourceId = $(bitModal.parentTarget).data('id'); 191 }, 192 onLoadAction: (bitModal) => { 193 let editableParams = { 194 mode: 'popup', 195 placement: 'bottom', 196 emptytext: translate('Brak danych'), 197 emptyclass: 'red', 198 pk: bitModal.options.resourceId, 199 url: '/resource/index/edit-file', 200 success: function (response) { 201 if (!response.status) { 202 if (response.message) { 203 return response.message; 204 } else { 205 return translate('Nie udaÅo siÄ ustawiÄ wskazanej wartoÅci.'); 206 } 207 } 208 return true; 209 } 210 }; 211 $(bitModal.modal).find('.editable:not([data-name="public"])').editable(editableParams); 212 $(bitModal.modal).find('[data-name="public"]').editable({ 213 ...editableParams, source: [ 214 {value: 0, text: translate('Nie')}, 215 {value: 1, text: translate('Tak')}, 216 ] 217 }); 218 } 219 }); 220 }, 221 222 initMoveModal: function () { 223 var _this = this; 224 var url = this.moveUrl; 225 $('#move-modal').remove(); 226 let modal = $(`<div class="modal fade" tabindex="-1" role="dialog" id="move-modal"> 227 <div class="modal-dialog modal-lg" role="document"> 228 <div class="modal-content"> 229 <div class="modal-header"> 230 <button type="button" class="close" data-dismiss="modal" aria-label="Close"> 231 <span aria-hidden="true">×</span></button> 232 <h4 class="modal-title">
232` + translate('PrzenieÅ') + `</h4> 233 </div> 234 <div class="modal-body"> 235 <input class="fn-resource-id" type="hidden"> 236 <div id="move-tree"></div> 237 </div> 238 <div class="modal-footer"> 239 <button type="button" class="btn btn-default" data-dismiss="modal"> 240 <i class="ace-icon fa fa-times"></i>` + translate('Anuluj') + ` 241 </button> 242 <button type="button" class="fn-move-trigger btn btn-success"> 243 <i class="ace-icon fa fa-floppy-o"></i>` + translate('PrzenieÅ') + ` 244 </button> 245 </div> 246 </div> 247 </div> 248 </div>`); 249 250 var moveTree = modal.find('#move-tree'); 251 moveTree.jstree({ 252 'core': { 253 multiple: false, 254 'data': { 255 url: '/resource/index/get-dirs', 256 data: function (node) { 257 if (node.id !== '#') { 258 return { 259 id: node.li_attr['data-id'], 260 type: translate('Zasoby'), 261 showPages: 0, 262 selected: '' 263 }; 264 } else { 265 return { 266 id: 0, 267 type: translate('Zasoby'), 268 showPages: 0, 269 selected: '' 270 }; 271 } 272 } 273 }, 274 'strings': { 275 'Loading ...': translate('Åadowanie...') 276 }, 277 'check_callback': function (o, n, p, i, m) { 278 if (m && m.dnd && m.pos !== 'i') { 279 return false; 280 } 281 if (o === "move_node" || o === "copy_node") { 282 if (this.get_node(n).parent === this.get_node(p).id) { 283 return false; 284 } 285 } 286 return true; 287 } 288 }, 289 plugins: [ 290 "types", 291 "themes", 292 "html_data", 293 "ui" 294 ] 295 }); 296 297 modal.find('.fn-move-trigger').click((event) => { 298 event.preventDefault(); 299 300 let current = moveTree.jstree('get_selected'); 301 302 if (current.length == 0) { 303 bootbox.alert({ 304 title: '<span class="label label-lg label-danger">' + translate('BÅÄ d zarzÄ dzania katalogami') + '</span>', 305 message: '<i class="ace-icon fa fa-exclamation-triangle red bigger-150"></i> ' + translate('ProszÄ wskazaÄ katalog') 306 }); 307 } else { 308 $.ajax(url, { 309 method: "GET", 310 data: { 311 id: modal.find('.fn-resource-id').val(), 312 parent: $('#' + moveTree.jstree('get_selected')).data('id') 313 }, 314 success: function () { 315 $.flashMessenger(translate('Zasób zostaÅ przeniesiony'), 'success'); 316 modal.modal('hide'); 317 _this.refresh(); 318 }, 319 error: function () { 320 $.flashMessenger(translate('Nie udaÅo siÄ przenieÅÄ zasobu'), 'error'); 321 } 322 }); 323 } 324 }); 325 326 $('body').append(modal); 327 }, 328 329 initCropModal: function () { 330 let _this = this; 331 $('#crop-modal').remove(); 332 let modal = 333 $(`<div class="modal fade" tabindex="-1" role="dialog" id="crop-modal"> 334 <div class="modal-dialog modal-lg" role="document"> 335 <div class="modal-content"> 336 <div class="modal-header"> 337 <button type="button" class="close" data-dismiss="modal" aria-label="Close">
338 <span aria-hidden="true">×</span></button> 339 <h4 class="modal-title">` + translate('Edycja') + `</h4> 340 </div> 341 <div class="modal-body"> 342 <div class="row"> 343 <div class="col-md-12"> 344 <input class="hidden" name="resource-id"> 345 <input class="hidden" name="resource-name"> 346 <div class="img-container" style=" 347 margin-bottom: 1em; 348 position: relative; 349 display: flex; 350 justify-content: center;"> 351 <img src="" id="image-cropper" style="width: 100%"> 352 </div> 353 </div> 354 <div class="col-md-12"> 355 <div id="actions"> 356 <div class="col-md-8 docs-buttons"> 357 <div class="btn-group"> 358 <button type="button" class="btn btn-primary" data-method="zoom" data-option="0.1" title="` + translate('PowiÄksz') + `"> 359 <span class="fa fa-search-plus"></span> 360 </button> 361 <button type="button" class="btn btn-primary" data-method="zoom" data-option="-0.1" title="` + translate('Zmniejsz') + ` "> 362 <span class="fa fa-search-minus"></span> 363 </button> 364 </div> 365 366 <div class="btn-group"> 367 <button type="button" class="btn btn-primary" data-method="move" 368 data-option="-10" data-second-option="0" title="` + translate('PrzesuÅ w lewo') + `"> 369 <span class="fa fa-arrow-left"></span> 370 </button> 371 <button type="button" class="btn btn-primary" data-method="move" data-option="10" data-second-option="0" title="` + translate('PrzesuÅ w prawo') + `"> 372 <span class="fa fa-arrow-right"></span> 373 </button> 374 <button type="button" class="btn btn-primary" data-method="move" 375 data-option="0" data-second-option="-10" title="` + translate('PrzesuÅ w górÄ') + `"> 376 <span class="fa fa-arrow-up"></span> 377 </button> 378 <button type="button" class="btn btn-primary" data-method="move" 379 data-option="0" data-second-option="10" title="` + translate('PrzesuÅ w doÅ') + `"> 380 <span class="fa fa-arrow-down"></span> 381 </button> 382 </div> 383 384 <div class="btn-group"> 385 <button type="button" class="btn btn-primary" data-method="rotate" 386 data-option="-45" title="` + translate('ObrÃ³Ä w lewo') + `"> 387 <span class="fa fa-rotate-left"></span> 388 </button> 389 390 <button type="button" class="btn btn-primary" data-method="rotate" 391 data-option="45" title="` + translate('ObrÃ³Ä w prawo') + `">
392 <span class="fa fa-rotate-right"></span> 393 </button> 394 </div> 395 396 <div class="btn-group"> 397 <button type="button" class="btn btn-primary" data-method="scaleX" 398 data-option="-1" title="` + translate('OdwrÃ³Ä w poziomie') + `"> 399 <span class="fa fa-arrows-h"></span> 400 </button> 401 <button type="button" class="btn btn-primary" data-method="scaleY" 402 data-option="-1" title="` + translate('OdwrÃ³Ä w pionie') + `"> 403 <span class="fa fa-arrows-v"></span> 404 </button> 405 </div> 406 407 <div class="btn-group"> 408 <button type="button" class="btn btn-primary" data-method="reset" 409 title="` + translate('Resetuj') + `"> 410 <span class="fa fa-refresh"></span> 411 </button> 412 </div> 413 </div> 414 <div class="col-md-4 docs-toggles"> 415 <div class="btn-group d-flex flex-nowrap" data-toggle="buttons"> 416 <label class="btn btn-primary"> 417 <input type="radio" class="sr-only" id="aspectRatio1" name="aspectRatio" value="1.7777777777777777"> 418 16:9 419 </label> 420 <label class="btn btn-primary"> 421 <input type="radio" class="sr-only" id="aspectRatio2" name="aspectRatio" value="1.3333333333333333"> 422 4:3 423 </label> 424 <label class="btn btn-primary"> 425 <input type="radio" class="sr-only" id="aspectRatio3" name="aspectRatio" value="1"> 426 1:1 427 </label> 428 <label class="btn btn-primary"> 429 <input type="radio" class="sr-only" id="aspectRatio4" name="aspectRatio" value="0.6666666666666666"> 430 2:3 431 </label> 432 <label class="btn btn-primary"> 433 <input type="radio" class="sr-only" id="aspectRatio5" name="aspectRatio" value="NaN"> 434 ` + translate('Dowolny') + ` 435 </label> 436 </div> 437 </div> 438 </div> 439 </div> 440 </div> 441 </div> 442 <div class="modal-footer"> 443 <button type="button" class="btn btn-default" data-dismiss="modal"> 444 <i class="ace-icon fa fa-times"></i>` + translate('Anuluj') + ` 445 </button> 446 <div class="btn-group"> 447 <button type="submit" class="fn-save btn btn-success no-border"> 448 <i class="ace-icon fa fa-floppy-o"></i> 449 ` + translate('Nadpisz') + ` 450 </button> 451 <button type="button" class="btn btn-success no-border dropdown-toggle" data-toggle="dropdown" data-as-copy="1" 452 aria-haspopup="true" aria-expanded="false">
453 <span class="ace-icon fa fa-caret-down icon-only"></span> 454 <span class="sr-only"></span> 455 </button> 456 <ul class="dropdown-menu no-border"> 457 <li> 458 <a href="#" data-as-copy="1" class="fn-save">` + translate('Zapisz kopiÄ') + `</a> 459 </li> 460 </ul> 461 </div> 462 </div> 463 </div> 464 </div> 465 </div>`); 466 467 modal.on('hide.bs.modal', () => { 468 this.cropper.destroy(); 469 this.refresh(); 470 }); 471 472 modal.find('.fn-save').on('click', (element) => { 473 this.cropper.getCroppedCanvas().toBlob((blob) => { 474 let formData = new FormData(); 475 var name = modal.find('[name="resource-name"]').val(); 476 formData.append('container', $(`#${this.currentNodeInputId}`).val()); 477 478 if (parseInt($(element.target).data('as-copy')) === 1) { 479 name = modal.find('[name="resource-name"]').val().split('.').join(`-copy-${Date.now()}.`); 480 } 481 482 formData.append('file', blob, name); 483 484 $.ajax(this.uploadUrl, { 485 method: "POST", 486 data: formData, 487 processData: false, 488 contentType: false, 489 success: function () { 490 modal.modal('hide'); 491 $.flashMessenger(translate('ZdjÄcie zostaÅo zapisane'), 'success'); 492 }, 493 error: function () { 494 $.flashMessenger(translate('Nie udaÅo siÄ zapisaÄ zdjÄcia'), 'error'); 495 } 496 }); 497 }, 'image/jpg'); 498 }); 499 500 $('body').append(modal); 501 }, 502 503 initCropper: function (imgElement) { 504 let Cropper = window.Cropper; 505 let URL = window.URL || window.webkitURL; 506 let download = document.getElementById('download'); 507 let actions = document.getElementById('actions'); 508 let _this = this; 509 let options = { 510 aspectRatio: 16 / 9, 511 preview: '.img-preview', 512 responsive: true, 513 minContainerWidth: 800, 514 minContainerHeight: 400, 515 }; 516 this.cropper = new Cropper(imgElement, options); 517 let originalImageURL = imgElement.src; 518 let uploadedImageType = 'image/jpeg'; 519 let uploadedImageName = 'cropped.jpg'; 520 let uploadedImageURL; 521 522 // Tooltip 523 $('[data-toggle="tooltip"]').tooltip(); 524 525 // Buttons 526 if (!document.createElement('canvas').getContext) { 527 $('button[data-method="getCroppedCanvas"]').prop('disabled', true); 528 } 529 530 if (typeof document.createElement('cropper').style.transition === 'undefined') { 531 $('button[data-method="rotate"]').prop('disabled', true); 532 $('button[data-method="scale"]').prop('disabled', true); 533 } 534 535 // Methods 536 actions.querySelector('.docs-buttons').onclick = function (event) { 537 let e = event || window.event; 538 let target = e.target || e.srcElement; 539 let cropped; 540 let result; 541 let input; 542 let data; 543 544 if (!_this.cropper) { 545 return; 546 } 547 548 while (target !== this) { 549 if (target.getAttribute('data-method')) { 550 break; 551 } 552 553 target = target.parentNode; 554 } 555 556 if (target === this || target.disabled || target.className.indexOf('disabled') > -1) { 557 return; 558 } 559 560 data = { 561 method: target.getAttribute('data-method'), 562 target: target.getAttribute('data-target'), 563 option: target.getAttribute('data-option') || undefined, 564 secondOption: target.getAttribute('data-second-option') || undefined 565 }; 566 567 cropped = _this.cropper.cropped; 568 569 if (data.method) { 570 if (typeof data.target !== 'undefined') { 571 input = document.querySelector(data.target); 572 573 if (!target.hasAttribute('data-option') && data.target && input) { 574 try { 575 data.option = JSON.parse(input.value); 576 } catch (e) { 577 console.log(e.message); 578 } 579 } 580 } 581 582 switch (data.method) { 583 case 'rotate': 584 if (cropped && options.viewMode > 0) { 585 _this.cropper.clear(); 586 } 587 588 break; 589 590 case 'getCroppedCanvas': 591 try { 592 data.option = JSON.parse(data.option); 593 } catch (e) { 594 console.log(e.message); 595 } 596 597 if (uploadedImageType === 'image/jpeg') { 598 if (!data.option) { 599 data.option = {}; 600 } 601 602 data.option.fillColor = '#fff'; 603 } 604 605 break; 606 } 607 608 result = _this.cropper[data.method](data.option, data.secondOption); 609 610 switch (data.method) { 611 case 'rotate': 612 if (cropped && options.viewMode > 0) { 613 _this.cropper.crop(); 614 } 615 616 break; 617 618 case 'scaleX': 619 case 'scaleY': 620 target.setAttribute('data-option', -data.option); 621 break; 622 623 case 'getCroppedCanvas': 624 if (result) { 625 // Bootstrap's Modal 626 $('#getCroppedCanvasModal').modal().find('.modal
626-body').html(result); 627 628 if (!download.disabled) { 629 download.download = uploadedImageName; 630 download.href = result.toDataURL(uploadedImageType); 631 } 632 } 633 634 break; 635 636 case 'destroy': 637 _this.cropper = null; 638 639 if (uploadedImageURL) { 640 URL.revokeObjectURL(uploadedImageURL); 641 uploadedImageURL = ''; 642 imgElement.src = originalImageURL; 643 } 644 645 break; 646 } 647 648 if (typeof result === 'object' && result !== _this.cropper && input) { 649 try { 650 input.value = JSON.stringify(result); 651 } catch (e) { 652 console.log(e.message); 653 } 654 } 655 } 656 }; 657 actions.querySelector('.docs-toggles').onchange = (event) => { 658 let e = event || window.event; 659 let target = e.target || e.srcElement; 660 let cropBoxData; 661 let canvasData; 662 let isCheckbox; 663 let isRadio; 664 665 if (!this.cropper) { 666 return; 667 } 668 669 if (target.tagName.toLowerCase() === 'label') { 670 target = target.querySelector('input'); 671 } 672 673 isCheckbox = target.type === 'checkbox'; 674 isRadio = target.type === 'radio'; 675 676 if (isCheckbox || isRadio) { 677 if (isCheckbox) { 678 options[target.name] = target.checked; 679 cropBoxData = this.cropper.getCropBoxData(); 680 canvasData = this.cropper.getCanvasData(); 681 682 options.ready = () => { 683 this.cropper.setCropBoxData(cropBoxData).setCanvasData(canvasData); 684 }; 685 } else { 686 options[target.name] = target.value; 687 } 688 689 this.cropper.destroy(); 690 this.cropper = new Cropper(imgElement, options); 691 } 692 }; 693 }, 694 695 /** 696 * odÅwieżenie listy plików, alias do init 697 */ 698 refresh: function () { 699 this.init(); 700 }, 701 702 /** 703 * tworzy element - wykorzystywana przez addFolderFiles 704 * @param data 705 * @returns {*|jQuery|HTMLElement} 706 */ 707 createElement: function (data) { 708 let _this = this; 709 let fileImage = this.fileImagePath(data); 710 data.EXTRA = data.EXTRA ?? ''; 711 let html = 712 `<li style="line-height: normal" data-type="${data.TYPE}" class="${data.PUBLIC === 1 ? 'bg-danger' : ''}" title="${String(data.EXTRA) + (data.PUBLIC === 1 ? translate(' (publiczny)') : '')}"> 713 <a id="resource_${data.ID}"> 714 <img src="${fileImage}" class="filemanager-thumb" onerror="this.height=180;this.width=180;this.onerror=null;this.src='/app/img/filemanager/${data.EXTENSION}.png';" alt="${data.EXTRA}"> 715 </a> 716 <div class="tags">`; 717 718 if (data.TAGS) { 719 let tagsArray = data.TAGS.split(','); 720 tagsArray.forEach(tag => { 721 html += `<span class="label-holder"><span class="label label-warning" title="`+translate('PowiÄ zany tag')+`">${tag.trim()}</span></span>`; 722 }); 723 } 724 725 html += `<span class="label-holder"><span class="label label-success arrowed-in-right arrowed" title="`+translate('Numer (ID) zasobu')+`">${data.ID}</span></span> 726 <span class="label-holder"><span class="label label-info arrowed-in-right arrowed file-name" title="${data.NAME}">${data.NAME}</span></span> 727 <span class="label-holder"><span class="label label-danger file-size-info arrowed" title="`+translate('Rozmiar pliku')+`">${this.fileSize(data)}</span></span> 728 </div> 729 <div class="tools tools-top" style="font-size: 3px; display: flex;justify-content: center;width: auto;"> 730 <a href="${this.downloadUrl + '/id.' + data.ID}" title="` + translate('Pobierz zasób') + `"><i class="ace-icon fa fa-download"></i></a> 731 <a href="#" class="fn-move" title="` + translate('PrzenieÅ') + `"><i class="ace-icon fa fa-arrows"></i></a> 732 </div> 733 </li>` 734 ; 735 var $html = $(html); 736 // ZarzÄ dzanie edycjÄ zasobów 737 738 if (_this.canEdit) { 739 $html.find('.tools-top').append( 740 $('<a/>', { 741 class: 'element-edit', 742 title: translate('Edytuj wÅaÅciwoÅci zasobu'), 743 html: $('<i/>', {'class': 'ace-icon icon-only fa fa-pencil'}), 744 'data-bitmodal-url': `/resource/index/edit-resource/id.${data.ID}`, 745 'data-bitmodal': 'editResource', 746 'data-id': data.ID 747 } 748 ) 749 ); 750 if (data.TYPE == 1) { 751 $html.find('.tools-top').append($('<a/>', 752 { 753 'class': 'element-crop', 754 title: translate('Edytuj zasób'), 755 html: $('<i/>', {'class': 'ace-icon icon-only fa fa-crop'}) 756 })); 757 } 758 759 if (this.convertableToPdf.indexOf(data.EXTENSION) >= 0) { 760 $html.find('.tools-top').append($('<a/>', { 761 'class': 'generate-pdf', 762 title: translate('Konwersja pliku do PDF'), 763 html: $('<i/>', {'class': 'ace-icon icon-only fa fa-file-pdf-o'}) 764 })); 765 } 766 } 767 768 if (_this.canRemove) { 769 $html.find('.tools-top').append($('<a/>', 770 { 771 'class': 'element-remove', 772 title: translate('UsuÅ zasób'), 773 html: $('<i/>
773', {'class': 'ace-icon icon-only fa fa-trash-o'}) 774 })); 775 } 776 777 if (parseInt(data.LIVE) === 1) { 778 $html.find('.fa-download').parent().remove(); 779 if (parseInt(data.LIVE_TYPE) === 1) { 780 $html.find('.file-size-info') 781 .html(function () { 782 if (parseInt(data.LIVE_RECORDING) === 1) { 783 return translate('Nagrywanie') + ' <i class="fa fa-circle blink red"></i>'; 784 } else if (parseInt(data.LIVE_RECORDING) === 0) { 785 return translate('Wstrzymano') + ' <i class="fa fa-pause"></i>'; 786 } else { 787 return translate('Oczekuje'); 788 } 789 }) 790 .removeClass('label-danger').addClass('label-warning'); 791 } 792 793 if (parseInt(data.LIVE_TYPE) === 2) { 794 $html.find('.file-size-info') 795 .html('Youtube') 796 .removeClass('label-danger'); 797 } else if (parseInt(data.LIVE_TYPE) === 3) { 798 $html.find('.file-size-info') 799 .html('Facebook') 800 .removeClass('label-danger'); 801 } 802 803 } 804 805 if (data.EXTENSION == 'swf') { 806 $html.find('.filemanager-thumb').parent() 807 .addClass('mediaExt') 808 .flash({ 809 swf: this.downloadUrl + '/id.' + data.ID + '/0x0.swf', 810 width: 150, 811 height: 145, 812 play: true 813 }); 814 } 815 816 if (this.imageExtensions.indexOf(data.EXTENSION) >= 0) { 817 $html.find('img.filemanager-thumb').parent() 818 .attr('href', this.fileImagePath(data, 0, 0)) 819 .attr('data-rel', 'colorbox') 820 .addClass('colorboxElement') 821 ; 822 } 823 let $modal = $('#modal-wraper-preview'); 824 825 $modal.unbind().on('hide.bs.modal', function () { 826 if (window.adminVideoPlayer !== undefined) { 827 window.adminVideoPlayer.dispose(); 828 } 829 }); 830 831 if (this.videoExtensions.indexOf(data.EXTENSION) >= 0 || this.audioExtensions.indexOf(data.EXTENSION) >= 0) { 832 //video preview 833 var $previewButton = $('<a href="#" class="video-frame" title="' + translate('PodglÄ d zasobu') + '"><i class="ace-icon fa fa-eye"></i></a>'); 834 $previewButton.click(function () { 835 $modal.find('.modal-title span').text(data.NAME); 836 $modal.modal(); 837 838 createPlayer(data, 'video-js-player', _this.fileImagePath(data, 250, 200)); 839 }); 840 $html.find('.tools.tools-top').prepend($previewButton); 841 842 //video options 843 if (data.LIVE == 1 && data.LIVE_TYPE == 1) { 844 _this.elementEventVideoLiveOptions($html, data); 845 } else { 846 _this.elementEventVideoOptions($html, data); 847 } 848 849 // link do wideo 850 var $previewLink = $('<a href="' + data.VIDEO_LINK + '?modal=true" class="video-frame" title="' + translate('Link do zasobu') + '"><i class="ace-icon fa fa-search"></i></a>'); 851 $html.find('.tools.tools-top').prepend($previewLink); 852 } 853 854 if (this.convertableToPdf.indexOf(data.EXTENSION) >= 0 || data.EXTENSION == 'pdf') { 855 var url = this.documentPreviewUrl + '/id.' + data.ID; 856 $html.find('.tools.tools-top').prepend('<a href="' + url + '" target="_blank" class="video-frame" title="' + translate('PodglÄ d zasobu') + '"><i class="ace-icon fa fa-eye"></i></a>'); 857 } 858 859 this.elementEventEdit($html, data); 860 861 this.createEventPdf($html, data); 862 863 $html.find('.element-remove').click(function () { 864 if (confirm(translate('Czy na pewno chcesz usunÄ Ä plik?'))) { 865 $.ajax({ 866 type: 'POST', 867 url: _this.deleteUrl, 868 data: {id: data.ID}, 869 success: function (res) { 870 if (res.status == 0) { 871 alert(translate('WystÄ piÅ problem z usuwaniem pliku')); 872 } else { 873 $html.fadeOut(600, function () { 874 $(this).remove(); 875 }); 876 } 877 } 878 }); 879 } 880 }); 881 return $html; 882 }, 883 884 elementEventVideoOptions: function ($html, data) { 885 var _this = this; 886 var $optionsButton = $('<a href="#" title="' + translate('Edycja wÅaÅciwoÅci filmu') + '" class="video-frame"><i class="ace-icon fa fa-film"></i></a>'); 887 $optionsButton.unbind().click(function () { 888 889 //modal
890 let $modal = $('#modal-wraper-edit'); 891 $modal.modal(); 892 893 $(document).find('#modal-wraper-edit').on('hide.bs.modal', function () { 894 if (window.adminVideoPlayer !== undefined) { 895 window.adminVideoPlayer.dispose(); 896 } 897 _this.refresh(); 898 $modal.unbind(); 899 }); 900 901 //jeÅli audio ukrywam niepotrzebne taby 902 903 if (_this.audioExtensions.indexOf(data.EXTENSION) >= 0) { 904 $modal.find('[href="#tab-obrazek"]').parent().addClass('hidden'); 905 $modal.find('[href="#tab-polecamy"]').parent().addClass('hidden'); 906 907 $modal.find('ul#myTab li').removeClass('active'); 908 $modal.find('[href="#tab-komentarze"]').parent().addClass('active'); 909 910 $modal.find('.tab-pane').removeClass('active'); 911 $modal.find('#tab-komentarze').addClass('active'); 912 } else { 913 $modal.find('[href="#tab-obrazek"]').parent().removeClass('hidden'); 914 $modal.find('[href="#tab-polecamy"]').parent().removeClass('hidden'); 915 916 $modal.find('ul#myTab li').removeClass('active'); 917 $modal.find('[href="#tab-obrazek"]').parent().addClass('active'); 918 919 $modal.find('.tab-pane').removeClass('active'); 920 $modal.find('#tab-obrazek').addClass('active'); 921 } 922 923 //reset sec. 924 var $input_sec = $modal.find('#video-second'); 925 $input_sec.val(''); 926 927 928 createPlayer(data, 'video-js-player-edit', _this.fileImagePath(data, 250, 200)); 929 930 //image 931 $modal.find('#movie-snapshot').attr('src', _this.fileImagePath(data, 250, 200) + '?' + Math.random()); 932 933 //get current time 934 $modal.find('#frame-get-current').unbind().click(function () { 935 $input_sec.val(parseFloat(window.adminVideoPlayer.currentTime()).toFixed(3)); 936 }); 937 938 $modal.find('.button-thumbnail-save').unbind().click(function (_e) { 939 _e.preventDefault(); 940 let formData = new FormData(); 941 let a = $modal.find('input[name="video-thumbnail"]')[0]; 942 let b = a.files[0]; 943 formData.append('file', $modal.find('input[name="video-thumbnail"]')[0].files[0]); 944 formData.append('resource', data.ID); 945 formData.append('recommended', data.recommended); 946 $.ajax({ 947 type: 'POST', 948 url: '/itv/admin/edit-live-resource', 949 data: formData, 950 cache: false, 951 dataType: 'json', 952 processData: false, 953 contentType: false, 954 success: function (_data) { 955 if (_data.status == 1) { 956 $modal.modal('hide'); 957 setTimeout(function () { 958 $.gritter.add({ 959 // (string | mandatory) the heading of the notification 960 title: translate('Sukces'), 961 // (string | mandatory) the text inside the notification 962 text: translate('Dodano nowy zasób'), 963 class_name: 'gritter-success' 964 }); 965 }, 1000); 966 } else { 967 alert(translate('WystÄ piÅ bÅÄ d podczas próby zapisu - skontaktuj siÄ z administratorem')); 968 } 969 } 970 }); 971 }); 972 973 $modal.find('#hidden-resource-id').val(data.ID); 974 //save 975 $modal.find('#frame-set-save').unbind().click(function () { 976 $.ajax({ 977 type: 'POST', 978 url: _this.videoSetFrameUrl, 979 data: {id: data.ID, frame: $input_sec.val()}, 980 success: function (_data) { 981 if (_data.status != 1) { 982 alert(translate('WystÄ piÅ bÅÄ d podczas zapisywania danych')); 983 } 984 $modal.find('#movie-snapshot').attr('src', _this.fileImagePath(data, 250, 200) + '?' + Math.random()); 985 } 986 }) 987 }); 988 989 990 //inicjacja komentarzy 991 var comObj = new VideoComment(); 992 comObj.init(data.ID); 993 994 //konwersje 995 $modal.find('[data-rel="popover"]').unbind().popover({html: true}); 996 $modal.find('.create-bitrate').unbind(); 997 $.ajax({ 998 type: 'POST', 999 url: _this.conversionInfo, 1000 data: {id: data.ID}, 1001 success: function (convData) { 1002 $modal.find('.bitrate-value').text(convData.resource.BITRATE); 1003 $modal.find('.create-bitrate').each(function (i, v) { 1004 var $this = $(this); 1005 $this.removeClass('disabled'); 1006 1007 //usuwa konwersje o wyższym bitrate niż pliku bazowego 1008 var thresoldFactor = $this.data('thresoldfactor'); 1009 var _bitrate1 = parseInt($this.data('bitrate')) * parseFloat(thresoldFactor); 1010 if (_bitrate1 > convData.resource.BITRATE) { 1011 $this.addClass('disabled'); 1012 1013 } 1014 1015 1016 //dodaje informacje, że plik jest konwertowany 1017 $this.find('.w-trakcie').addClass('hidden'); 1018 $this.removeClass('btn-success'); 1019 $this.find('i').addClass('fa-cog').removeClass('fa-check'); 1020 $.each(convData.copies, function (i2, v2) { 1021 1022 if (parseInt(v2.BITRATE) == parseInt($this.data('bitrate'))) { 1023 $this.addClass('disabled'); 1024 if (parseInt(v2.CONVERTED) != 1) { 1025 $this.find('.w-trakcie').removeClass('hidden'); 1026 return false;//break 1027 } else { 1028 $this.addClass('btn-success'); 1029 $this.find('i').removeClass('fa-cog').addClass('fa-check'); 1030 } 1031 } 1032 }); 1033 1034 }); 1035 1036 //ustawia wartoÅÄ poczÄ tkowÄ dla POLECANY - jego obsÅuga 1037 $modal.find('[name="polecamy-checkbox"]').unbind(); 1038 if (convData.resource.RECOMMENDED == 1) { 1039 data.recommended = parseInt(convData.resource.RECOMMENDED); 1040 $modal.find('[name="polecamy-checkbox"]').prop('checked', true); 1041 } else { 1042 data.recommended = 0; 1043 $modal.find('[name="polecamy-checkbox"]').prop('checked', false); 1044 } 1045 1046 $modal.find('[name="polecamy-checkbox"]').change(function () { 1047 var val1 = $(this).is(':checked') ? '1' : '0'; 1048 $.ajax({ 1049 type: 'POST', 1050 url: _this.editResourceUrl, 1051 data: { 1052 pk: data.ID, 1053 name: 'recommended', 1054 value: val1 1055 }, 1056 success: function (_data) { 1057 if (_data.status != 1) { 1058 alert(translate('WystÄ piÅ bÅÄ d podczas zapisywania danych')); 1059 } 1060 data.recommended = parseInt(_data.value); 1061 $modal.find('[name="polecamy-checkbox"]').parent().animate({'background-color': 'green'}, 400, function () { 1062 $(this).animate({'background-color': ''}, 400); 1063 }); 1064 } 1065 }) 1066 }) 1067 } 1068 }).done(function () { //po zakoÅczeniu dodaÄ event na przyciski 1069 1070 $modal.find('.create-bitrate').click(function (e) { 1071 var $this = $(this); 1072 e.preventDefault(); 1073 $.ajax({ 1074 type: 'POST', 1075 url: _this.conversionSave, 1076 data: {id: data.ID, conversion: $(this).data('name')}, 1077 success: function (createData) { 1078 if (createData.status == 1) { 1079 $this.addClass('disabled'); 1080 $this.find('.w-trakcie').removeClass('hidden'); 1081 } 1082 } 1083 }) 1084 }); 1085 $modal.find('.create-bitrate .tooltip-info').tooltip({ 1086 content: function () { 1087 return $(this).prop('data-content'); 1088 } 1089 }); 1090 }) 1091 1092 }); 1093 $html.find('.tools.tools-top').append($optionsButton); 1094 }, 1095 1096 1097 elementEventVideoLiveOptions: function ($html, data) { 1098 var _this = this; 1099 var $optionsButton = $('<a href="#" title="' + translate('Edycja wÅaÅciwoÅci streamingu') + '" class="video-frame"><i class="ace-icon fa fa-cloud-download"></i></a>'); 1100 $optionsButton.unbind().click(function () { 1101
1102 let $modal = $('#modal-wraper-edit-live'); 1103 1104 $(document).find('#modal-wraper-edit-live').unbind().on('hide.bs.modal', () => { 1105 if (window.adminVideoPlayer !== undefined) { 1106 window.adminVideoPlayer.dispose(); 1107 } 1108 }); 1109 1110 $modal.find('.hide-in-edit').addClass('hidden'); 1111 $modal.find('.modal-title').text(translate('Edytuj zasób LIVE')); 1112 $modal.find('.movie-preview').removeClass('hidden'); 1113 1114 $modal.find('input[name="channel1"]').val(data.LIVE_CHANNEL_H); 1115 $modal.find('input[name="channel2"]').val(data.LIVE_CHANNEL_M); 1116 $modal.find('input[name="channel3"]').val(data.LIVE_CHANNEL_L); 1117 $modal.find('input[name="recommended"]').prop('checked', (parseInt(data.RECOMMENDED) ? true : false)); 1118 $modal.find('#preview-file-image').find('img').remove(); 1119 1120 if (data.LIVE_IMAGE) { 1121 1122 $modal.find('#preview-file-image').append($('<img src="/itv/image/' + __institution_id + '/' + __project_id + '/' + data.ID + '?' + Math.random() + '" width="200" >')); 1123 } 1124 1125 function changeVideoButtons(val) { 1126 if (parseInt(val) === 1) { 1127 $modal.find('.recording-start').addClass('disabled'); 1128 $modal.find('.recording-pause').removeClass('disabled'); 1129 $modal.find('.recording-stop').removeClass('disabled'); 1130 } else if (parseInt(val) === 0) { 1131 $modal.find('.recording-start').removeClass('disabled'); 1132 $modal.find('.recording-pause').addClass('disabled'); 1133 $modal.find('.recording-stop').removeClass('disabled'); 1134 } else { 1135 $modal.find('.recording-start').removeClass('disabled'); 1136 $modal.find('.recording-pause').addClass('disabled'); 1137 $modal.find('.recording-stop').addClass('disabled'); 1138 } 1139 } 1140 1141 let isEventRefresh = false; 1142 1143 function refreshResourcesSingletone() { 1144 if (isEventRefresh === false) { 1145 $modal.on('hide.bs.modal', function () { 1146 _this.refresh(); 1147 }); 1148 isEventRefresh = true; 1149 } 1150 } 1151 1152 changeVideoButtons(data.LIVE_RECORDING); 1153 1154 //recording buttons 1155 $modal.find('.recording-start').off().on('click', function () { 1156 let _$this = $(this); 1157 if (!_$this.hasClass('disabled')) { 1158 refreshResourcesSingletone(); 1159 if (confirm(translate('Potwierdź rozpoczÄcie nagrywania'))) { 1160 $.ajax({ 1161 type: 'POST', 1162 url: '/itv/admin/recording', 1163 data: { 1164 action: 'start', 1165 id: data.ID 1166 }, 1167 success: function (_data) { 1168 if (_data.status == 1) { 1169 changeVideoButtons('1'); 1170 $.gritter.add({ 1171 // (string | mandatory) the heading of the notification 1172 title: '', 1173 // (string | mandatory) the text inside the notification 1174 text: translate('RozpoczÄto nagrywanie'), 1175 class_name: 'gritter-success' 1176 }); 1177 } 1178 } 1179 }) 1180 } 1181 } 1182 }); 1183 1184 $modal.find('.recording-pause').off().on('click', function () { 1185 var _$this = $(this); 1186 if (!_$this.hasClass('disabled')) { 1187 refreshResourcesSingletone(); 1188 if (confirm(translate('Potwierdź wstrzymanie nagrywania'))) { 1189 $.ajax({ 1190 type: 'POST', 1191 url: '/itv/admin/recording', 1192 data: { 1193 action: 'pause', 1194 id: data.ID 1195 }, 1196 success: function (_data) { 1197 if (_data.status == 1) { 1198 changeVideoButtons('0'); 1199 $.gritter.add({ 1200 // (string | mandatory) the heading of the notification 1201 title: '', 1202 // (string | mandatory) the text inside the notification 1203 text: translate('Wstrzymano nagrywanie'), 1204 class_name: 'gritter-success' 1205 }); 1206 } 1207 } 1208 }) 1209 } 1210 } 1211 }); 1212 1213 $modal.find('.recording-stop').off().on('click', function () { 1214 var _$this = $(this); 1215 if (!_$this.hasClass('disabled')) { 1216 refreshResourcesSingletone(); 1217 if (confirm(translate('Potwierdź ZAKOÅCZENIE nagrywania'))) { 1218 $.ajax({ 1219 type: 'POST', 1220 url: '/itv/admin/recording', 1221 data: { 1222 action: 'stop', 1223 id: data.ID 1224 }, 1225 success: function (_data) { 1226 if (_data.status == 1) { 1227 refreshResourcesSingletone(); 1228 $modal.modal('hide'); 1229 } 1230 } 1231 }) 1232 } 1233 } 1234 }); 1235 1236 $modal.unbind().modal(); 1237 1238 1239 createPlayer(data, 'video-js-player-live', _this.fileImagePath(data, 250, 200)); 1240 1241 $modal.find('.button-anuluj').unbind().click(function (_e) { 1242 _e.preventDefault(); 1243 $modal.modal('hide'); 1244 }); 1245 1246 $modal.find('.button-zapisz').unbind().click(function (_e) { 1247 _e.preventDefault(); 1248 var canSave = false;
1249 var formData = new FormData(); 1250 formData.append('channel1', $modal.find('input[name="channel1"]').val()); 1251 formData.append('channel2', $modal.find('input[name="channel2"]').val()); 1252 formData.append('channel3', $modal.find('input[name="channel3"]').val()); 1253 formData.append('recommended', +$modal.find('input[name="recommended"]').is(':checked')); 1254 formData.append('file', $modal.find('input[name="file"]')[0].files[0]); 1255 formData.append('resource', data.ID); 1256 1257 // if (formData.file != undefined || $modal.find('img').length != 0) { 1258 canSave = true; 1259 // } 1260 1261 if (canSave) { 1262 $.ajax({ 1263 type: 'POST', 1264 url: '/itv/admin/edit-live-resource', 1265 data: formData, 1266 cache: false, 1267 dataType: 'json', 1268 processData: false, 1269 contentType: false, 1270 success: function (_data) { 1271 if (_data.status == 1) { 1272 $modal.modal('hide'); 1273 try { 1274 setTimeout(() => { 1275 _this.refresh(); 1276 }, 100); 1277 } catch (error) { 1278 console.log(error); 1279 } 1280 setTimeout(function () { 1281 $.gritter.add({ 1282 // (string | mandatory) the heading of the notification 1283 title: translate('Sukces'), 1284 // (string | mandatory) the text inside the notification 1285 text: translate('Dodano nowy zasób'), 1286 class_name: 'gritter-success' 1287 }); 1288 }, 1000); 1289 } else { 1290 alert(translate('WystÄ piÅ bÅÄ d podczas próby zapisu - skontaktuj siÄ z administratorem')); 1291 } 1292 } 1293 }); 1294 } else { 1295 alert(translate('ProszÄ dodaÄ miniaturÄ reprezentujÄ cÄ zasób')); 1296 } 1297 }); 1298 }); 1299 1300 $html.find('.tools.tools-top').append($optionsButton); 1301 1302 }, 1303 1304 /** 1305 * Event elementu po klikniÄciu w edycjÄ 1306 * @param $html 1307 * @param data 1308 */ 1309 elementEventEdit: function ($html, data) { 1310 var _this = this; 1311 1312 $html.find('.element-crop').click(function () { 1313 let cropModal = $('#crop-modal'); 1314 cropModal.find('#image-cropper').attr('src', data.PATH_PREVIEW); 1315 cropModal.find('[name="resource-id"]').val(data.ID); 1316 cropModal.find('[name="resource-name"]').val(data.NAME); 1317 cropModal.modal('show'); 1318 _this.initCropper(document.getElementById('image-cropper')) 1319 }); 1320 1321 $html.find('.fn-move').click(function () { 1322 let moveModal = $('#move-modal'); 1323 moveModal.find('.fn-resource-id').val(data.ID); 1324 moveModal.modal('show'); 1325 }) 1326 1327 $html.find('.element-edit').click(function () { 1328 1329 // ustawienie ID do wiÄ zania z tagami 1330 __tags_object_element_id__ = data.ID; 1331 1332 var needReload = false; 1333 1334 let $modal = $('#modal-wraper-edit-resource'); 1335 $modal.modal(); 1336 $modal.append('<span class="hide" id="resource_id" data-resource-id="' + data.ID + '"></span>') 1337 1338 var editableParams = { 1339 mode: 'popup', 1340 placement: 'bottom', 1341 emptytext: translate('Brak danych'), 1342 emptyclass: 'red', 1343 pk: data.ID, 1344 url: _this.editResourceUrl, 1345 success: function (response) { 1346 if (!response.status) { 1347 if (response.message) { 1348 return response.message; 1349 } else { 1350 return translate('Nie udaÅo siÄ ustawiÄ wskazanej wartoÅci.') 1351 } 1352 } 1353 return true; 1354 } 1355 }; 1356 1357 $modal.find('.editable').editable('destroy'); 1358 //set values 1359 $modal.find('[data-name="name"]').text(data.NAME).editable(editableParams, {value: data.NAME}).on('save', function () { 1360 needReload = true; 1361 }); 1362 $modal.find('[data-name="extra"]').text(data.EXTRA).editable(editableParams, {value: data.EXTRA}).on('save', function () { 1363 needReload = true; 1364 }); 1365 $modal.find('[data-name="description"]').text(data.DESCRIPTION).editable(editableParams, {value: data.DESCRIPTION}).on('save', function (e, params) { 1366 needReload = true; 1367 }); 1368 $modal.find('[data-name="author"]').text(data.AUTHOR).editable(editableParams, {value: data.AUTHOR}).on('save', function () { 1369 needReload = true; 1370 }); 1371 $modal.find('[data-name="source"]').text(data.SOURCE).editable(editableParams, {value: data.SOURCE}).on('save', function () { 1372 needReload = true; 1373 }); 1374 $modal.find('[data-name="eventDate"]').text(data.EVENT_DATE).editable($.extend({}, editableParams, { 1375 value: data.EVENT_DATE, 1376 date: {language: 'pl', format: 'yyyy-mm-dd'} 1377 })).on('save', function (e, params) { 1378 needReload = true; 1379 }); 1380 $modal.find('[data-name="fsize"]').text(_this.fileSize(data)); 1381 $modal.find('[data-name="extension"]').text(data.EXTENSION); 1382 $modal.find('[data-name="created"]').text(data.DATE_CREATE + translate(' przez: ') + data.FK_PERSON_CREATE_NAME); 1383 $modal.find('[data-name="modified"]').text(data.FK_PERSON_MODIFY ? data.DATE_MODIFY + translate(' przez: ') + data.FK_PERSON_MODIFY_NAME : '');
1384 $modal.find('[data-name="version"]').text(data.VERSION); 1385 1386 var checkboxParams = editableParams; 1387 checkboxParams['source'] = [ 1388 {value: 0, text: translate('Nie')}, 1389 {value: 1, text: translate('Tak')}, 1390 ]; 1391 1392 $modal.find('[data-name="public"]').text(data.PUBLIC === 1 ? translate('Tak') : translate('Nie')).editable($.extend({}, editableParams, { 1393 value: data.PUBLIC 1394 })).on('save', function (e, params) { 1395 needReload = true; 1396 }); 1397 1398 var selectElement = $modal.find('[data-name="tags"]'); 1399 if (data.TAGS !== null && data.TAGS !== undefined) { 1400 var tags = data.TAGS.split(','); 1401 if (tags.length > 0) { 1402 selectElement.val(tags).trigger("change"); 1403 } 1404 } 1405 selectElement.on('change', function () { 1406 needReload = true; 1407 }); 1408 1409 1410 $modal.on('hide.bs.modal', function () { 1411 selectElement.val(null).trigger("change"); 1412 1413 if (needReload) { 1414 _this.refresh(); 1415 } 1416 $modal.unbind(); 1417 }); 1418 1419 }); 1420 }, 1421 1422 createEventPdf: function (html, data) { 1423 var _this = this; 1424 html.find('.generate-pdf').on('click', function (e) { 1425 e.preventDefault(); 1426 $('.loading-box').fadeIn(); 1427 _this.createPdf(data.ID, function () { 1428 }); 1429 }); 1430 }, 1431 1432 /** 1433 * zmienia nazwÄ pliku 1434 * @param id 1435 * @param value 1436 */ 1437 renameFile: function (id, value) { 1438 $.ajax({ 1439 url: this.renameUrl, 1440 type: 'POST', 1441 data: {id: id, value: value}, 1442 success: function (data) { 1443 if (data.status == 0) { 1444 alert(translate('WystÄ piÅ problem podczas zapisu.')); 1445 } 1446 } 1447 }) 1448 }, 1449 1450 /** 1451 * dodaje element do kontenera 1452 * @param $element 1453 * @param position append|prepend default append 1454 */ 1455 addElement: function ($element, position) { 1456 var container = this.getContainer(); 1457 if (typeof position === 'undefined' || position == 'append') { 1458 container.append($element); 1459 } else if (position == 'prepend') { 1460 container.prepend($element); 1461 } 1462 }, 1463 1464 /** 1465 * generuje url obrazka do pliku 1466 * @param data 1467 * @param width 1468 * @param height 1469 * @returns {string} 1470 */ 1471 fileImagePath: function (data, width, height) { 1472 if (parseInt(data.LIVE) === 1 && data.LIVE_IMAGE != null && data.LIVE_IMAGE.length > 0) { 1473 return `${this.defaultLiveImagePath}${data.ID}`; 1474 } else if (data.LIVE == 1) { 1475 if (parseInt(data.LIVE_TYPE) === 3) { 1476 return this.defaultIconPath + 'facebook.png'; 1477 } 1478 return this.defaultIconPath + 'live.png'; 1479 } else if (this.imageExtensions.indexOf(data.EXTENSION) >= 0) //image thumb 1480 { 1481 if (typeof width === 'undefined') { 1482 width = 180; 1483 } 1484 if (typeof height === 'undefined') { 1485 height = 180; 1486 } 1487 return this.defaultImagePath + data.DLOAD_CONTAINER + '/' + data.ID + '/' + width + 'x' + height + '.' + data.EXTENSION; 1488 } else if (this.videoExtensions.indexOf(data.EXTENSION) >= 0) //video thumb 1489 { 1490 if (typeof width === 'undefined') { 1491 width = 180; 1492 } 1493 if (typeof height === 'undefined') { 1494 height = 180; 1495 } 1496 return this.defaultVideoPath + data.DLOAD_CONTAINER + '/' + data.ID + '/' + width + 'x' + height + '.jpg?' + Math.random().toString(); 1497 } else // file icon 1498 { 1499 if (this.supportedFormatsIcons.indexOf(data.EXTENSION) >= 0) { 1500 return this.defaultIconPath + data.EXTENSION + '.png'; 1501 } else { 1502 return this.defaultIconPath + 'file.png'; 1503 } 1504 } 1505 }, 1506 1507 /** 1508 * pobiera rozmiar pliku przeformatowany na skrócony format z odpowiednim przedrostkiem 1509 * @param data 1510 * @returns {string} 1511 */ 1512 fileSize: function (data) { 1513 var p = 1024; 1514 var filesize = parseInt(data.FSIZE); 1515 var ext = 'B'; 1516 if (filesize > p * p * p) { 1517 filesize = filesize / (p * p * p); 1518 ext = 'GB'; 1519 } else if (filesize > p * p) { 1520 filesize = filesize / (p * p); 1521 ext = 'MB'; 1522 } else if (filesize > p) { 1523 filesize = filesize / p; 1524 ext = 'kB'; 1525 } 1526 1527 if (ext === 'B') { 1528 return filesize.toFixed(0) + ' ' + ext; 1529 } 1530 return filesize.toFixed(2) + ' ' + ext; 1531 }, 1532 1533 getContainer: function () { 1534 if (typeof this.container !== 'object') { 1535 this.container = $(this.container); 1536 } 1537 return this.container; 1538 }, 1539 1540 /** 1541 * czyÅci zawartoÅÄ kontenera 1542 */ 1543 clearContainer: function () { 1544 var container = this.getContainer(); 1545 container.empty(); 1546 this.filesData = {}; 1547 }, 1548 1549 /** 1550 * tworzy PDF 1551 * @param id 1552 * @param callback 1553 */ 1554 createPdf: function (id, callback) { 1555 var _this = this; 1556 $.ajax({ 1557 type: 'POST', 1558 url: _this.pdfUrl, 1559 data: {id: id}, 1560 success: function (data) { 1561 $('.loading-box').fadeOut(800, function () { 1562 // szalewski #4151 konwertowanie do pdf 1563 if (+data.status === 1) { 1564 $.flashMessenger(translate('Utworzono plik PDF'), 'success'); 1565 _this.refresh(); 1566 } else { 1567 $.flashMessenger(translate('Konwersja na plik PDF zakoÅczyÅa siÄ niepowodzeniem.'), 'error'); 1568 } 1569 }); 1570 callback(data); 1571 } 1572 }); 1573 } 1574}; 1575 1576/* loading-box position settings */ 1577jQuery.fn.center = function () { 1578 this.css("position", "absolute"); 1579 this.css("top", Math.max(0, (($(window).height() - $(this).outerHeight()) / 2) + $(window).scrollTop()) + "px"); 1580 this.css("left", Math.max(0, (($(window).width() - $(this).outerWidth()) / 2) + $(window).scrollLeft()) + "px"); 1581 return this; 1582}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.