Ver Fonte

Merge branch 'master' of https://github.com/unaio/una

AntonLV há 3 anos atrás
pai
commit
085ce27daa

+ 0 - 1013
inc/js/classes/BxDolUploader - Copy [2].js

@@ -1,1013 +0,0 @@
-/**
- * Copyright (c) UNA, Inc - https://una.io
- * MIT License - https://opensource.org/licenses/MIT
- *
- * @defgroup    UnaCore UNA Core
- * @{
- */
-
-/**
- * Simple Uploader js class
- */
-function BxDolUploaderSimple (sUploaderObject, sStorageObject, sUniqId, options) {
-
-    this.init(sUploaderObject, sStorageObject, sUniqId, options);
-
-    this._sIframeId = 'bx-form-input-files-' + sUniqId + '-iframe';
-    this._eForm = null;
-}
-
-BxDolUploaderSimple.prototype.init = function (sUploaderObject, sStorageObject, sUniqId, options) {
-    this._isUploadsInProgress = false;
-
-    this._sUploaderObject = sUploaderObject;
-    this._sStorageObject = sStorageObject;
-
-    this._sUniqId = sUniqId;
-
-    this._sUploaderJsInstance = 'glUploader_' + sUniqId + '_' + this._sUploaderObject;
-    this._sUploadInProgressContainerId = 'bx-form-input-files-' + sUniqId + '-upload-in-progress-' + this._sUploaderObject;
-    this._sPopupContainerId = 'bx-form-input-files-' + sUniqId + '-popup-wrapper-' + this._sUploaderObject;
-
-    this._sResultContainerId = 'bx-form-input-files-' + sUniqId + '-upload-result';
-    this._sErrorsContainerId = 'bx-form-input-files-' + sUniqId + '-errors'; 
-    this._sProgressContainerId = 'bx-form-input-files-' + sUniqId + '-progress'; 
-
-    this._sFormContainerId = 'bx-form-input-files-' + sUniqId + '-form-cont';
-
-    this._sTemplateGhost = options.template_ghost ? options.template_ghost : '<div id="' + this._getFileContainerId('{file_id}') + '"><input type="hidden" name="f[]" value="{file_id}" />{file_name} (<a href="javascript:void(0);" onclick="{js_instance_name}.deleteGhost(\'{file_id}\')">delete</a>)</div>';
-    this._sTemplateReorder = options.template_reorder ? options.template_reorder : '<div class="bx-uploader-ghost-reorder bx-btn bx-btn-small"><i class="sys-icon bars"></i></div>';
-    this._sTemplateError = options.template_error_msg ? options.template_error_msg : '<div>{error}</div>' ;
-    this._sTemplateErrorGhosts = options.template_error_ghosts ? options.template_error_ghosts : this._sTemplateError;
-
-    this._isMultiple = undefined == options.multiple || !options.multiple ? false : true;
-    this._isReordering = undefined == options.reordering || !options.reordering ? false : true;
-
-    this._iContentId = undefined == options.content_id || '' == options.content_id ? '' : parseInt(options.content_id);
-
-    this._sImagesTranscoder = options.images_transcoder ? options.images_transcoder : '';
-
-    this._isPrivate = undefined == options.storage_private || parseInt(options.storage_private) ? 1 : 0;
-
-    this._isErrorShown = false;
-}
-
-BxDolUploaderSimple.prototype.isMultiple = function () {    
-    return this._isMultiple;
-}
-
-BxDolUploaderSimple.prototype.getCurrentFilesCount = function () {
-    return $('#' + $this._sResultContainerId + ' .bx-uploader-ghost').length;
-}
-
-BxDolUploaderSimple.prototype.showUploaderForm = function () {
-    var $this = this;
-    var sUrl = this._getUrlWithStandardParams() + '&a=show_uploader_form&m=' + (this._isMultiple ? 1 : 0) + '&c=' + this._iContentId + '&p=' + this._isPrivate + '&_t=' + escape(new Date());
-
-    $(window).dolPopupAjax({
-        url: sUrl,
-        id: {force: true, value: this._sPopupContainerId},
-        onBeforeShow: function() {
-            if ($this.isMultiple())
-                $('#' + $this._sPopupContainerId + ' .bx-uploader-add-more-files').show();
-            else
-                $('#' + $this._sPopupContainerId + ' .bx-uploader-add-more-files').hide();
-            $('#' + $this._sPopupContainerId + ' .bx-popup-element-close').click(function() {
-                $this.onClickCancel();
-            });
-			$("#" + $this._sFormContainerId + " .bx-btn.bx-btn-primary:not(.bx-crop-upload)").hide();
-            if ('undefined' !== typeof($this.onBeforeShowPopup))
-                $this.onBeforeShowPopup();
-        },
-        onShow: function () {
-            if ('undefined' !== typeof($this.onShowPopup))
-                $this.onShowPopup();
-        },
-        closeElement: false,
-        closeOnOuterClick: false
-    });
-}
-
-BxDolUploaderSimple.prototype.onClickCancel = function () {
-	var $this = this;
-    if (this._isUploadsInProgress) {
-    	bx_confirm(_t('_sys_uploader_confirm_close_popup'), function() {
-    		$this.cancelAll();
-            $('#' + $this._sPopupContainerId).dolPopupHide({});
-    	});
-    } else {
-        $('#' + this._sPopupContainerId).dolPopupHide();
-    }
-}
-
-BxDolUploaderSimple.prototype.onBeforeUpload = function (params) {
-
-    this._eForm = params;
-
-    this._loading(true, false);
-        
-    this._isUploadsInProgress = true;
-    this._lockPageFromLeaving();
-    this._clearErrors();
-}
-
-BxDolUploaderSimple.prototype.onProgress = function (params) {
-
-}
-
-BxDolUploaderSimple.prototype.onUploadCompleted = function (sErrorMsg) {
-
-    this._isUploadsInProgress = false;
-    this._unlockPageFromLeaving();
-    this._loading(false, true);
-
-    if (sErrorMsg.length) {
-        this.restoreGhosts();        
-        this._showError(sErrorMsg);
-    } else {        
-        this.restoreGhosts();
-        $('#' + this._sPopupContainerId).dolPopupHide({});
-    }
-}
-
-BxDolUploaderSimple.prototype.cancelAll = function () {
-    $('#' + this._sIframeId).attr('src', 'javascript:false;');
-    this.onUploadCompleted(_t('_sys_uploader_upload_canceled'));
-}
-
-BxDolUploaderSimple.prototype.restoreGhosts = function (bInitReordering, onComplete) {
-    var sUrl = this._getUrlWithStandardParams() + '&img_trans=' + this._sImagesTranscoder + '&a=restore_ghosts&f=json' + '&c=' + this._iContentId + '&_t=' + escape(new Date());
-    var $this = this;
-
-    bInitReordering = bInitReordering !== undefined ? bInitReordering : this._isReordering;
-
-    $.getJSON(sUrl, function (aData) {
-
-        if (!$this.isMultiple())
-            $('#' + $this._sResultContainerId + ' .bx-uploader-ghost').remove();
-
-        if ('object' === typeof(aData)) {
-            if('object' === typeof(aData.g) && 'object' === typeof(aData.o)) 
-                for(var i in aData.o) {
-                    var iFileId = aData.o[i];
-                    $this.showGhost(iFileId, aData.g[iFileId]);
-                }
-            else
-                $.each(aData, function(iFileId, oVars) {
-                    $this.showGhost(iFileId, oVars);
-                });
-
-            $('#' + $this._sResultContainerId).bx_show_more_check_overflow();
-
-            if(bInitReordering) {
-                var sClassGhost = 'bx-uploader-ghost';
-                $('#' + $this._sResultContainerId).find('.' + sClassGhost).each(function() {
-                    if($(this).find('.bx-uploader-ghost-reorder').length == 0)
-                        $(this).find('.bx-base-general-uploader-ghost').prepend($this._sTemplateReorder);
-                });
-
-                var fInitReordering = function() {                    
-                    $('#' + $this._sResultContainerId).sortable({
-                        items: '.' + sClassGhost, 
-                        start: function(oEvent, oUi) {
-                            oUi.item.addClass('bx-uploader-ghost-dragging');
-                        },
-                        stop: function(oEvent, oUi) {
-                            oUi.item.removeClass('bx-uploader-ghost-dragging');
-
-                            $this.reorderGhosts(oUi.item);
-                        }
-                    });
-                };
-
-                if($.sortable !== undefined)
-                    fInitReordering();
-                else
-                    setTimeout(fInitReordering, 2000);
-            }
-        }
-
-        if(typeof onComplete === 'function')
-            return onComplete(aData);
-    });
-};
-
-BxDolUploaderSimple.prototype.reorderGhosts = function(oDraggable) {
-    var sUrl = this._getUrlWithStandardParams() + '&a=reorder_ghosts&f=json' + '&c=' + this._iContentId + '&' + $('#' + this._sResultContainerId).sortable('serialize', {key: 'ghosts[]'}) + '&_t=' + escape(new Date());
-
-    $.getJSON(sUrl, function (aData) {
-        processJsonData(aData);
-    });
-};
-
-BxDolUploaderSimple.prototype.showGhost = function(iId, oVars) {
-    var oFileContainer = $('#' + this._getFileContainerId(iId));
-    if(oFileContainer.length > 0)
-        return;
-
-    var sHTML;
-    if (typeof this._sTemplateGhost == 'object')
-        sHTML = this._sTemplateGhost[iId];
-    else
-        sHTML = this._sTemplateGhost;
-
-    for(var i in oVars)
-        sHTML = sHTML.replace (new RegExp('{' + i + '}', 'g'), oVars[i]);
-
-    $('#' + this._sResultContainerId).append(sHTML);
-
-    oFileContainer.find('.bx-uploader-ghost-preview img').hide().fadeIn(1000);
-};
-
-BxDolUploaderSimple.prototype.deleteGhost = function (iFileId) {
-    var sUrl = this._getUrlWithStandardParams() + '&a=delete&id=' + iFileId;
-    var $this = this;
-
-    var sFileContainerId = $this._getFileContainerId(iFileId);
-    bx_loading(sFileContainerId, true);
-
-    $.post(sUrl, {_t: escape(new Date())}, function (sMsg) {
-        bx_loading(sFileContainerId, false);
-        if ('ok' == sMsg) {
-            $('#' + sFileContainerId).slideUp('slow', function () {
-                $(this).remove();
-            });
-        } else {
-            $('#' + this._sResultContainerId).prepend($this._sTemplateErrorGhosts.replace('{error}', sMsg));
-        }        
-    });
-};
-
-BxDolUploaderSimple.prototype._clearErrors = function () {
-    $('#' + this._sPopupContainerId + ' #' + this._sErrorsContainerId).html('');
-    this._isErrorShown = false;
-}
-
-BxDolUploaderSimple.prototype._showError = function (s, bAppend) {
-    if (s == undefined || !s.length)
-        return;
-    if (!bAppend)
-        $('#' + this._sPopupContainerId + ' #' + this._sErrorsContainerId).html(this._sTemplateError.replace('{error}', s));
-    else
-        $('#' + this._sPopupContainerId + ' #' + this._sErrorsContainerId).prepend(this._sTemplateError.replace('{error}', s));
-    this._isErrorShown = true;
-};
-
-BxDolUploaderSimple.prototype._getFileContainerId = function (iFileId) {
-	return 'bx-uploader-file-' + this._sStorageObject + '-' + iFileId;
-};
-
-BxDolUploaderSimple.prototype._getUrlWithStandardParams = function () {
-    return sUrlRoot + 'storage_uploader.php?uo=' + this._sUploaderObject + '&so=' + this._sStorageObject + '&uid=' + this._sUniqId;
-}
-
-BxDolUploaderSimple.prototype._lockPageFromLeaving = function () {
-    $(window).bind('beforeunload', function (e) {
-        var e = e || window.event;
-        // for ie, ff
-        e.returnValue = _t('_sys_uploader_confirm_leaving_page');
-        // for webkit
-        return _t('_sys_uploader_confirm_leaving_page');
-    });
-}
-
-BxDolUploaderSimple.prototype._unlockPageFromLeaving = function () {
-    $(window).unbind('beforeunload');
-}
-
-BxDolUploaderSimple.prototype._loading = function (bShowProgress, bShowForm) {
-
-    var eForm = $('#' + this._sFormContainerId + ' .bx-uploader-files-list');
-    var eBtn = $('#' + this._sFormContainerId + ' .bx-btn-primary');
-
-    if (bShowForm) {
-        if (null != this._eForm) {
-            eForm.find('.bx-uploader-simple-file').filter(':not(:first)').remove();
-            if ('undefined' !== typeof(this._eForm.reset)) 
-                this._eForm.reset();
-        }
-        eForm.show();
-        eBtn.show();
-    } else {
-        eForm.hide();
-        eBtn.hide();
-    }
-
-    bx_loading($('#' + this._sFormContainerId + ' .bx-uploader-loading').get(0), bShowProgress);
-}
-
-BxDolUploaderSimple.prototype.getMimeTypefromString  = function (ext) {
-    
-    var mimeTypes = 
-    {
-        
-        '3gp'    : 'video/3gpp',
-        '3g2'    : 'video/3gpp2',
-        'a'      : 'application/octet-stream',
-        'ai'     : 'application/postscript',
-        'aif'    : 'audio/x-aiff',
-        'aifc'   : 'audio/x-aiff',
-        'aiff'   : 'audio/x-aiff',
-        'asf'   : 'video/x-ms-asf',
-        'au'     : 'audio/basic',
-        'avi'    : 'video/x-msvideo',
-        'avi'    : 'video/avi',
-        'bat'    : 'text/plain',
-        'bin'    : 'application/octet-stream',
-        'bmp'    : 'image/x-ms-bmp',
-        'c'      : 'text/plain',
-        'cdf'    : 'application/x-cdf',
-        'csh'    : 'application/x-csh',
-        'css'    : 'text/css',
-        'divx'   : 'video/divx',
-        'dll'    : 'application/octet-stream',
-        'doc'    : 'application/msword',
-        'dot'    : 'application/msword',
-        'drc'    : 'video/drc',
-        'dvi'    : 'application/x-dvi',
-        'eml'    : 'message/rfc822',
-        'eps'    : 'application/postscript',
-        'etx'    : 'text/x-setext',
-        'exe'    : 'application/octet-stream',
-        'gif'    : 'image/gif',
-        'gtar'   : 'application/x-gtar',
-        'h'      : 'text/plain',
-        'hdf'    : 'application/x-hdf',
-        'htm'    : 'text/html',
-        'html'   : 'text/html',
-        'jpe'    : 'image/jpeg',
-        'jpeg'   : 'image/jpeg',
-        'jpg'    : 'image/jpeg',
-        'js'     : 'application/x-javascript',
-        'ksh'    : 'text/plain',
-        'latex'  : 'application/x-latex',
-        'm1v'    : 'video/mpeg',
-        'man'    : 'application/x-troff-man',
-        'me'     : 'application/x-troff-me',
-        'mht'    : 'message/rfc822',
-        'mhtml'  : 'message/rfc822',
-        'mkv'    : 'video/x-matroska',
-        'mif'    : 'application/x-mif',
-        'mov'    : 'video/quicktime',
-        'movie'  : 'video/x-sgi-movie',
-        'mp2'    : 'audio/mpeg',
-        'mp3'    : 'audio/mpeg',
-        'mp4'    : 'video/mp4',  
-        'm4v'    : 'video/mp4', 
-        'mpa'    : 'video/mpeg',
-        'mpe'    : 'video/mpeg',
-        'mpeg'   : 'video/mpeg',
-        'mpg'    : 'video/mpeg',
-        'ms'     : 'application/x-troff-ms',
-        'nc'     : 'application/x-netcdf',
-        'nws'    : 'message/rfc822',
-        'o'      : 'application/octet-stream',
-        'obj'    : 'application/octet-stream',
-        'oda'    : 'application/oda',
-        'ogv'    : 'video/ogg',
-        'ogg'    : 'video/ogg',
-        'pbm'    : 'image/x-portable-bitmap',
-        'pdf'    : 'application/pdf',
-        'pfx'    : 'application/x-pkcs12',
-        'pgm'    : 'image/x-portable-graymap',
-        'png'    : 'image/png',
-        'pnm'    : 'image/x-portable-anymap',
-        'pot'    : 'application/vnd.ms-powerpoint',
-        'ppa'    : 'application/vnd.ms-powerpoint',
-        'ppm'    : 'image/x-portable-pixmap',
-        'pps'    : 'application/vnd.ms-powerpoint',
-        'ppt'    : 'application/vnd.ms-powerpoint',
-        'pptx'   : 'application/vnd.ms-powerpoint',
-        'ps'     : 'application/postscript',
-        'pwz'    : 'application/vnd.ms-powerpoint',
-        'py'     : 'text/x-python',
-        'pyc'    : 'application/x-python-code',
-        'pyo'    : 'application/x-python-code',
-        'qt'     : 'video/quicktime',
-        'ra'     : 'audio/x-pn-realaudio',
-        'ram'    : 'application/x-pn-realaudio',
-        'ras'    : 'image/x-cmu-raster',
-        'rdf'    : 'application/xml',
-        'rgb'    : 'image/x-rgb',
-        'rm'     : 'application/vnd.rn-realmedia',
-        'rmvb'   : 'application/vnd.rn-realmedia-vbr',
-        'roff'   : 'application/x-troff',
-        'rtx'    : 'text/richtext',
-        'sgm'    : 'text/x-sgml',
-        'sgml'   : 'text/x-sgml',
-        'sh'     : 'application/x-sh',
-        'shar'   : 'application/x-shar',
-        'snd'    : 'audio/basic',
-        'so'     : 'application/octet-stream',
-        'src'    : 'application/x-wais-source',
-        'swf'    : 'application/x-shockwave-flash',
-        't'      : 'application/x-troff',
-        'tar'    : 'application/x-tar',
-        'tcl'    : 'application/x-tcl',
-        'tex'    : 'application/x-tex',
-        'texi'   : 'application/x-texinfo',
-        'texinfo': 'application/x-texinfo',
-        'tif'    : 'image/tiff',
-        'tiff'   : 'image/tiff',
-        'tr'     : 'application/x-troff',
-        'tsv'    : 'text/tab-separated-values',
-        'txt'    : 'text/plain',
-        'ustar'  : 'application/x-ustar',
-        'vcf'    : 'text/x-vcard',
-        'wav'    : 'audio/x-wav',
-        'wav'    : 'audio/wav',
-        'webm'   : 'video/webm',
-        'wmv'    : 'video/wmv',
-        'wiz'    : 'application/msword',
-        'wsdl'   : 'application/xml',
-        'xbm'    : 'image/x-xbitmap',
-        'xlb'    : 'application/vnd.ms-excel',
-        'xls'    : 'application/vnd.ms-excel',
-        'xlsx'    : 'application/vnd.ms-excel',
-        'xml'    : 'text/xml',
-        'xpdl'   : 'application/xml',
-        'xpm'    : 'image/x-xpixmap',
-        'xsl'    : 'application/xml',
-        'xvid'   : 'video/xvid',
-        'webp'   : 'image/webp',
-        'xwd'    : 'image/x-xwindowdump',
-        'svg'    : 'image/svg+xml',
-        'zip'    : ['application/zip', 'application/x-zip-compressed']
-       
-    }
-    return mimeTypes[ext.replace('.', '')];
-}
-
-/**
- * HTML5 Uploader js class
- */
-function BxDolUploaderHTML5 (sUploaderObject, sStorageObject, sUniqId, options) {
-
-    this.init(sUploaderObject, sStorageObject, sUniqId, options);
-
-    this._sIframeId = 'bx-form-input-files-' + sUniqId + '-iframe';
-    this._eForm = null;    
-
-    this._sDivId = 'bx-form-input-files-' + sUniqId + '-div-' + this._sUploaderObject;
-
-    this._sFocusDivId = 'bx-form-input-files-' + sUniqId + '-focus-' + this._sUploaderObject;
-
-    this._uploader = null;
-    
-    this._aFiles = [];
-  
-
-    this.initUploader = function (o) {
-
-        var $this = this;
-
-        if (null != this._uploader)
-            this._uploader = null;
-
-        var $this = this;
-
-        var _options = {
-            allowProcess: false,
-            allowRevert: false,
-            allowRemove: false,
-            imagePreviewHeight: 100,
-            credits: {},
-            allowMultiple: $this._isMultiple ? true : false,
-            maxFiles: $this.isMultiple() ? 50 : 1,
-            maxFileSize: o.maxFilesize +'MB',
-            instantUpload: true,
-            onaddfile: (error, file) => { 
-                if (error){
-                    $this._uploader.removeFile(file);
-                    if($this._uploader.status != 3)
-                        $this.onUploadCompleted(''); 
-                }
-                else{
-                    $this.onBeforeUpload(''); 
-                }
-            },
-            onerror: (error) => { 
-                if (error.main)
-                    $this._showError(error.main + '. ' + error.sub, true);
-            },
-            onprocessfiles: (files) => { 
-                $this.onUploadCompleted(''); 
-            },
-            onprocessfileprogress(file, progress) {
-                $this._aFiles[file.source.lastModified+'-'+file.source.size+'-'+file.source.name] = progress * file.source.size;
-                iTotal = 0;
-                iUploaded = 0; 
-                for (const propertyName in $this._aFiles) {
-                    iUploaded += $this._aFiles[propertyName];
-                }
-                
-                for (i = 0; i < $this._uploader.getFiles().length; i++){
-                    iTotal += $this._uploader.getFiles()[i].source.size;
-                }
-            
-                iProgress = iUploaded / iTotal * 100;
-            
-                oProgress =  $('#' + $this._sProgressContainerId);
-                
-                if (oProgress.parents('form').find('.uploader_progress').length > 0){
-                    oProgress = oProgress.parents('form').find('.uploader_progress');
-                }
-                if (iProgress == 100){
-                    oProgress.hide();
-                    $this._aFiles = [];
-                }
-                else{
-                    oProgress.show();
-                    oProgress.find('.progress_line').css('width', iProgress + '%');
-                }
-            },
-            server: {
-				process: (fieldName, file, metadata, load, error, progress, abort) => {
-					const formData = new FormData();
-					formData.append('file', file, file.name);
-					formData.append('uo', this._sUploaderObject);
-					formData.append('so', this._sStorageObject);
-					formData.append('uid', this._sUniqId);
-					formData.append('m', this._isMultiple ? 1 : 0);
-					formData.append('c', this._iContentId);
-					formData.append('p', this._isPrivate);
-					formData.append('a', 'upload');
-
-					const request = new XMLHttpRequest();
-					request.open('POST', sUrlRoot + 'storage_uploader.php');
-
-					request.upload.onprogress = (e) => {
-						progress(e.lengthComputable, e.loaded, e.total);
-					};
-
-					request.onload = function(res) {
-						if (request.status >= 200 && request.status < 300) {
-							var o = null;
-                            try {
-                                o = JSON.parse(request.responseText);
-                            } 
-                            catch (e) {}
-                            if (o && 'undefined' !== typeof(o.error)) {
-                                $this._showError(o.error, true);
-                                error('error');
-                            }
-                            
-                            load(request.responseText);
-						}
-						else {
-							error('error');
-						}
-					};
-					request.send(formData);
-				}
-			},
-        };
-        
-        aAcceptableFiles = [];
-        if (o.acceptedFiles && o.acceptedFiles != ''){
-            a = o.acceptedFiles.trim().split(/\s*,\s*/);
-            a.forEach(function(item, i, arr) {
-                if ($this.getMimeTypefromString(item)){
-                    oT = $this.getMimeTypefromString(item);
-                    if (Array.isArray(oT)){
-                        oT.forEach(function(oTs, j, ar) {
-                            aAcceptableFiles.push(oTs);
-                        });
-                    }
-                    else{
-                        aAcceptableFiles.push(oT);
-                    }
-                }
-                    
-            });
-        }
-        
-        if (aAcceptableFiles.length){
-            _options.acceptedFileTypes = aAcceptableFiles;
-        }
-        
-        if (o.resizeWidth || o.resizeHeight){
-            _options.allowImageResize = true;
-            _options.imageResizeTargetWidth = o.resizeWidth;
-            _options.imageResizeTargetHeight = o.resizeHeight;
-            _options.imageResizeMode = o.resizeMethod;
-        }
-        else{
-            _options.allowImageResize = false;
-            _options.allowImageTransform = false;
-        }
-        
-        FilePond.registerPlugin(
-            FilePondPluginImagePreview,
-            FilePondPluginFileValidateType,
-            FilePondPluginFileValidateSize,
-            FilePondPluginImageTransform,
-            FilePondPluginImageCrop,
-            FilePondPluginImageResize,
-            
-        );
-
-        this._uploader = FilePond.create(
-            document.querySelector('#' + this._sDivId),
-            $.extend({}, _options, o)
-        );    
-        console.log(1);
-        this.initPasteEditor();
-    }
-
-    this.onUploadCompleted = function (sErrorMsg) {        
-        if (sErrorMsg.length)
-            this._showError(sErrorMsg);        
-        
-        var $this = this;
-        if($this._uploader.status != 3){
-            this._isUploadsInProgress = false;
-            this.restoreGhosts();
-            if (!this._isErrorShown) {
-                $('#' + this._sPopupContainerId).dolPopupHide({});
-                this.removeFiles();
-            }
-        }
-    }
-
-    this.removeFiles = function () {
-        oFiles = this._uploader.getFiles();
-        for (i = 0; i < oFiles.length; i++){
-            this._uploader.removeFile(i);
-        }
-    }
-
-    this.cancelAll = function () {
-        this.removeFiles();
-    }
-
-    this.onBeforeUpload = function (params) {
-        this._isUploadsInProgress = true;
-        this._clearErrors();
-    }
-
-    this.onProgress = function (params) {
-        console.log(params);    
-    }
-
-    this.onClickCancel = function () {
-        var $this = this;
-        if (this._isUploadsInProgress) {
-            bx_confirm(_t('_sys_uploader_confirm_close_popup'), function() {
-                $this.removeFiles();
-                $this.cancelAll();
-                $('#' + $this._sPopupContainerId).dolPopupHide({});
-            });
-        } else {
-            $this.removeFiles();
-            $('#' + this._sPopupContainerId).dolPopupHide();
-        }
-        
-        BxDolUploaderSimple.prototype._clearErrors.call(this);
-    }
-
-    this.onShowPopup = function () {
-        var $this = this;
-        setTimeout(function () {
-            $this.focusPasteEditor();
-        }, 200);
-    }
-
-    this.focusPasteEditor = function () {
-        $('#' + this._sFocusDivId).focus();
-    }
-
-    this.initPasteEditor = function () {
-        var $this = this;
-        $('#' + this._sFocusDivId).on('paste', function (e) {
-            var aFiles = [];
-            if (e.type == 'paste') {
-                var aItems = (e.clipboardData || e.originalEvent.clipboardData).items;
-                
-                for (var i in aItems) {
-                    var oItem = aItems[i];
-                    if (oItem.kind === 'file')
-                        aFiles.push(oItem.getAsFile());
-                }
-                $this._uploader.addFiles(aFiles);
-            }
-        });
-    }
-    
-    this.showUploaderForm = function() {
-        this._uploader.browse();
-    }
-    
-    this.initUploader({
-        'maxFilesize': options.maxFilesize,
-        'acceptedFiles': options.acceptedFiles,
-        'resizeWidth': options.resizeWidth,
-        'resizeHeight': options.resizeHeight,
-        'resizeMethod': options.resizeMethod,
-        'dictDefaultMessage': options.dictDefaultMessage,
-        'dictFileTooBig': options.dictFileTooBig,
-        'dictMaxFilesExceeded': options.dictMaxFilesExceeded,
-        'dictInvalidFileType': options.dictInvalidFileType,
-    });
-}
-
-BxDolUploaderHTML5.prototype = BxDolUploaderSimple.prototype;
-
-/**
- * Crop Image Uploader js class
- */
-function BxDolUploaderCrop (sUploaderObject, sStorageObject, sUniqId, options) {
-
-    this.init(sUploaderObject, sStorageObject, sUniqId, options);
-
-    this._eForm = null;
-
-    this.initUploader = function (oOptions) {
-
-        var $this = this;
-
-        var aExt = ['jpg', 'jpeg', 'png', 'gif', 'webp'];
-
-        var eCroppie = $("#" + this._sFormContainerId + " .bx-croppie-element").croppie(oOptions);
-
-		$("#" + this._sFormContainerId + ' .bx-crop-rotate').on('click', function(ev) {
-			eCroppie.croppie('rotate', parseInt($(this).data('deg')));
-		});
-        
-        $("#" + this._sFormContainerId + " input[name=f]").on("change", function() {
-            var input = this;            
-
-            if (input.files && input.files[0]) {
-
-                var m = input.files[0].name.match(/\.([A-Za-z0-9]+)$/);
-
-                if (2 != m.length || -1 == aExt.indexOf(m[1].toLowerCase())) {                    
-                    $(input).replaceWith($(input).val('').clone(true));
-                    $this._showError(_t('_sys_uploader_crop_wrong_ext'));
-                    return;
-                }
-
-                $this._clearErrors();
-
-                var reader = new FileReader()
-
-                reader.onload = function(e) {
-                    eCroppie.croppie('bind', {
-                        url: e.target.result
-                    });
-                    $("#" + $this._sFormContainerId + " .bx-croppie-element").addClass('ready');
-                    $("#" + $this._sFormContainerId + " .bx-crop-action").removeClass('bx-btn-disabled');
-                    $("#" + $this._sFormContainerId + " .bx-croppie-element").data('bx-filename', input.files[0].name.replace(/(\.[A-Za-z0-9]+)$/, '.jpg'));
-                }
-                reader.readAsDataURL(input.files[0]);
-            }
-        });
-
-        $("#" + this._sFormContainerId + " .bx-crop-upload").on('click', function(ev) {
-            eCroppie.croppie('result', {
-                type: 'canvas',
-                size: 'original',
-                format: 'jpeg',
-                quality: '0.85',
-            }).then(function(resp) {
-                var fd = new FormData();
-
-                fd.append("f", dataURItoBlob(resp), $("#" + $this._sFormContainerId + " .bx-croppie-element").data('bx-filename'));
-                $.each(oOptions.bx_form, function (sName) {
-                    fd.append(sName, this);
-                });
-                
-                $this.onBeforeUpload(fd);
-
-                $.ajax({
-                    url: sUrlRoot + 'storage_uploader.php',
-                    type: "POST",
-                    processData: false,
-                    contentType: false,
-                    data: fd,
-                    success: function(data) {
-                        eval(data);
-                    },
-                    error: function() {
-                        $this._showError(_t('_sys_uploader_crop_err_upload'));
-                    }
-                })
-
-            });
-        });
-
-        function dataURItoBlob(dataURI) {
-            var split = dataURI.split(','),
-                dataTYPE = split[0].match(/:(.*?);/)[1],
-                binary = atob(split[1]),
-                array = [];
-                
-            for (var i = 0; i < binary.length; i++) 
-                array.push(binary.charCodeAt(i));
-
-            return new Blob([new Uint8Array(array)], {
-                type: dataTYPE
-            });
-        }
-
-        
-    };
-}
-
-BxDolUploaderCrop.prototype = BxDolUploaderSimple.prototype;
-
-
-/**
- * Record Video Uploader js class
- */
-function BxDolUploaderRecordVideo (sUploaderObject, sStorageObject, sUniqId, options) {
-    this._camera = null;
-    this._blob = null;
-    this._recorder = null;
-    this._camera_type = 'user';
-
-    this._audio_bitrate = undefined !== options.audio_bitrate ? parseInt(options.audio_bitrate) : 128000;
-    this._video_bitrate = undefined !== options.video_bitrate ? parseInt(options.video_bitrate) : 1000000;
-
-    this.init(sUploaderObject, sStorageObject, sUniqId, options);
-
-    this.showUploaderForm = function() {
-        if (typeof MediaRecorder == 'undefined' || !('requestData' in MediaRecorder.prototype)) {
-            bx_alert(_t('_sys_uploader_unsupported_browser'));
-            return;
-        }
-
-        BxDolUploaderSimple.prototype.showUploaderForm.call(this);
-    }
-
-    this.onBeforeShowPopup = function() {
-        this._blob = null;
-        this._camera = null;
-        this._recorder = null
-        this._clearErrors();
-
-        $('#bx-upoloader-recording-preview').hide();
-        $('#bx-upoloader-camera-capture').show();
-
-        $('#' + this._sFormContainerId + ' .bx-uploader-record-video-controls').hide();
-    }
-
-    this.switchCamera = function () {
-        this._camera_type = this._camera_type == 'user' ? 'environment' : 'user';
-
-        this.releaseCamera();
-        this.onShowPopup();
-    }
-
-    this.onShowPopup = function () {
-        var $this = this;
-        try {
-            navigator.mediaDevices.getUserMedia({ audio: true, video: {facingMode: this._camera_type} }).then(function(camera) {
-                $this._camera = camera;
-                $this.showCameraCapture();
-
-                $('#' + $this._sFormContainerId + ' .bx-uploader-recording-start').show();
-                $('#' + $this._sFormContainerId + ' .bx-uploader-recording-stop').hide();
-                $('#' + $this._sFormContainerId + ' .bx-uploader-record-video-controls').show();
-
-                navigator.mediaDevices.enumerateDevices().then(function(mediaDevices){
-                    let constraints = navigator.mediaDevices.getSupportedConstraints();
-                    if ($this.getDevicesNum(mediaDevices) > 1 && typeof constraints.facingMode != 'undefined' && constraints.facingMode) {
-                        $('#' + $this._sFormContainerId + ' .bx-record-camera-switch').show();
-                    } else {
-                        $('#' + $this._sFormContainerId + ' .bx-record-camera-switch').hide();
-                    }
-                });
-
-            })
-        } catch (err) {
-            $this._showError(_t('_sys_uploader_camera_capture_failed'));
-        }
-    }
-
-    this.onClickCancel = function () {
-        this.releaseCamera();
-
-        BxDolUploaderSimple.prototype.onClickCancel.call(this);
-    }
-
-    this.startRecording = function() {
-        this._recorder = RecordRTC(this._camera, {
-            type: 'video',
-            audioBitsPerSecond: this._audio_bitrate,
-            videoBitsPerSecond: this._video_bitrate,
-            disableLogs: true
-        });
-
-        if (!this._recorder) {
-            this._showError(_t('_sys_uploader_unsupported_browser'));
-            return;
-        }
-
-        $("#" + this._sFormContainerId + " .bx-btn.bx-btn-primary:not(.bx-crop-upload)").hide();
-        $('#' + this._sFormContainerId + ' .bx-uploader-recording-start').hide();
-        $('#' + this._sFormContainerId + ' .bx-uploader-recording-stop').show();
-
-        this._recorder.startRecording();
-
-        this.showCameraCapture();
-    }
-
-    this.stopRecording = function(bSubmitWhenReady) {
-        $('#' + this._sFormContainerId + ' .bx-uploader-recording-start').show();
-        $('#' + this._sFormContainerId + ' .bx-uploader-recording-stop').hide();
-
-        var $this = this;
-        this._recorder.stopRecording(function(){
-            $this._blob = $this._recorder.getBlob();
-            $this.showRecordingPreview();
-
-            $this._recorder.destroy();
-            $this._recorder = null;
-
-            $("#" + $this._sFormContainerId + " .bx-btn.bx-btn-primary:not(.bx-crop-upload)").show();
-            if (bSubmitWhenReady)
-                $this.submitRecording($('#' + $this._sFormContainerId + ' form').get(0));
-        });
-    }
-
-    this.showCameraCapture = function() {
-        var video = $('#bx-upoloader-recording-preview').hide().get(0);
-        if (video.pause !== 'undefined') video.pause();
-        video.removeAttribute('src');
-
-        video = $('#bx-upoloader-camera-capture').show().get(0);
-        video.srcObject = this._camera;
-        video.muted = true;
-        video.volume = 0;
-        $('#' + this._sFormContainerId + ' .bx-record-video-preview .bx-record-video-preview-filesize').html('');
-    }
-
-    this.showRecordingPreview = function() {
-        $('#bx-upoloader-camera-capture').hide();
-        $('#bx-upoloader-recording-preview').show().get(0).src = URL.createObjectURL(this._blob);
-
-        var mbytes = (this._blob.size/1024/1024).toFixed(2);
-        $('#' + this._sFormContainerId + ' .bx-record-video-preview .bx-record-video-preview-filesize').html(mbytes + ' ' + _t('_sys_uploader_record_video_mb'));
-    }
-
-    this.submitRecording = function(form) {
-        if (this._recorder) {
-            this.stopRecording(true);
-            return;
-        }
-
-        this.onBeforeUpload(form);
-
-        var data = new FormData(form);
-        if (this._blob != null) data.append("f[]", this._blob, new Date().toISOString() + '.webm');
-
-        var $this = this;
-        $.ajax({
-            url: $(form).attr('action'),
-            type: "POST",
-            data: data,
-            processData: false,
-            contentType: false,
-            success:function(sErrorMsg, textStatus, jqXHR) {
-                $this.onUploadCompleted(sErrorMsg);
-                if (!sErrorMsg.length) {
-                    $this.releaseCamera();
-                }
-            },
-        });
-    }
-
-    this.releaseCamera = function() {
-        //stop playing recorded file
-        var video = $('#bx-upoloader-recording-preview').get(0);
-        if (video.pause != 'undefined') video.pause();
-        video.removeAttribute('src');
-
-        if (this._recorder) {
-            this._recorder.destroy();
-            this._recorder = null;
-        }
-
-        if (this._camera) {
-            if (typeof this._camera.stop != 'undefined') this._camera.stop();
-            this._camera.getTracks().forEach(function (track) {
-                if (track.readyState == 'live') {
-                    track.stop();
-                }
-            });
-        }
-    }
-
-    this.getDevicesNum = function(mediaDevices) {
-        let count = 0;
-        mediaDevices.forEach(mediaDevice => {
-            if (mediaDevice.kind === 'videoinput') count++;
-        });
-        return count;
-    }
-}
-
-BxDolUploaderRecordVideo.prototype = BxDolUploaderSimple.prototype;
-
-/** @} */

+ 0 - 967
inc/js/classes/BxDolUploader - Copy.js

@@ -1,967 +0,0 @@
-/**
- * Copyright (c) UNA, Inc - https://una.io
- * MIT License - https://opensource.org/licenses/MIT
- *
- * @defgroup    UnaCore UNA Core
- * @{
- */
-
-/**
- * Simple Uploader js class
- */
-function BxDolUploaderSimple (sUploaderObject, sStorageObject, sUniqId, options) {
-
-    this.init(sUploaderObject, sStorageObject, sUniqId, options);
-
-    this._sIframeId = 'bx-form-input-files-' + sUniqId + '-iframe';
-    this._eForm = null;
-}
-
-BxDolUploaderSimple.prototype.init = function (sUploaderObject, sStorageObject, sUniqId, options) {
-    this._isUploadsInProgress = false;
-
-    this._sUploaderObject = sUploaderObject;
-    this._sStorageObject = sStorageObject;
-
-    this._sUniqId = sUniqId;
-
-    this._sUploaderJsInstance = 'glUploader_' + sUniqId + '_' + this._sUploaderObject;
-    this._sUploadInProgressContainerId = 'bx-form-input-files-' + sUniqId + '-upload-in-progress-' + this._sUploaderObject;
-    this._sPopupContainerId = 'bx-form-input-files-' + sUniqId + '-popup-wrapper-' + this._sUploaderObject;
-
-    this._sResultContainerId = 'bx-form-input-files-' + sUniqId + '-upload-result';
-    this._sErrorsContainerId = 'bx-form-input-files-' + sUniqId + '-errors'; 
-
-    this._sFormContainerId = 'bx-form-input-files-' + sUniqId + '-form-cont';
-
-    this._sTemplateGhost = options.template_ghost ? options.template_ghost : '<div id="' + this._getFileContainerId('{file_id}') + '"><input type="hidden" name="f[]" value="{file_id}" />{file_name} (<a href="javascript:void(0);" onclick="{js_instance_name}.deleteGhost(\'{file_id}\')">delete</a>)</div>';
-    this._sTemplateReorder = options.template_reorder ? options.template_reorder : '<div class="bx-uploader-ghost-reorder"><i class="sys-icon bars"></i></div>';
-    this._sTemplateError = options.template_error_msg ? options.template_error_msg : '<div>{error}</div>' ;
-    this._sTemplateErrorGhosts = options.template_error_ghosts ? options.template_error_ghosts : this._sTemplateError;
-
-    this._isMultiple = undefined == options.multiple || !options.multiple ? false : true;
-    this._isReordering = undefined == options.reordering || !options.reordering ? false : true;
-
-    this._iContentId = undefined == options.content_id || '' == options.content_id ? '' : parseInt(options.content_id);
-
-    this._sImagesTranscoder = options.images_transcoder ? options.images_transcoder : '';
-
-    this._isPrivate = undefined == options.storage_private || parseInt(options.storage_private) ? 1 : 0;
-
-    this._isErrorShown = false;
-}
-
-BxDolUploaderSimple.prototype.isMultiple = function () {    
-    return this._isMultiple;
-}
-
-BxDolUploaderSimple.prototype.getCurrentFilesCount = function () {
-    return $('#' + $this._sResultContainerId + ' .bx-uploader-ghost').length;
-}
-
-BxDolUploaderSimple.prototype.showUploaderForm = function () {
-    var $this = this;
-    var sUrl = this._getUrlWithStandardParams() + '&a=show_uploader_form&m=' + (this._isMultiple ? 1 : 0) + '&c=' + this._iContentId + '&p=' + this._isPrivate + '&_t=' + escape(new Date());
-
-    $(window).dolPopupAjax({
-        url: sUrl,
-        id: {force: true, value: this._sPopupContainerId},
-        onBeforeShow: function() {
-            if ($this.isMultiple())
-                $('#' + $this._sPopupContainerId + ' .bx-uploader-add-more-files').show();
-            else
-                $('#' + $this._sPopupContainerId + ' .bx-uploader-add-more-files').hide();
-            $('#' + $this._sPopupContainerId + ' .bx-popup-element-close').click(function() {
-                $this.onClickCancel();
-            });
-			$("#" + $this._sFormContainerId + " .bx-btn.bx-btn-primary:not(.bx-crop-upload)").hide();
-            if ('undefined' !== typeof($this.onBeforeShowPopup))
-                $this.onBeforeShowPopup();
-        },
-        onShow: function () {
-            if ('undefined' !== typeof($this.onShowPopup))
-                $this.onShowPopup();
-        },
-        closeElement: false,
-        closeOnOuterClick: false
-    });
-}
-
-BxDolUploaderSimple.prototype.onClickCancel = function () {
-	var $this = this;
-    if (this._isUploadsInProgress) {
-    	bx_confirm(_t('_sys_uploader_confirm_close_popup'), function() {
-    		$this.cancelAll();
-            $('#' + $this._sPopupContainerId).dolPopupHide({});
-    	});
-    } else {
-        $('#' + this._sPopupContainerId).dolPopupHide();
-    }
-}
-
-BxDolUploaderSimple.prototype.onBeforeUpload = function (params) {
-
-    this._eForm = params;
-
-    this._loading(true, false);
-        
-    this._isUploadsInProgress = true;
-    this._lockPageFromLeaving();
-    this._clearErrors();
-}
-
-BxDolUploaderSimple.prototype.onProgress = function (params) {
-
-}
-
-BxDolUploaderSimple.prototype.onUploadCompleted = function (sErrorMsg) {
-
-    this._isUploadsInProgress = false;
-    this._unlockPageFromLeaving();
-    this._loading(false, true);
-
-    if (sErrorMsg.length) {
-        this.restoreGhosts();        
-        this._showError(sErrorMsg);
-    } else {        
-        this.restoreGhosts();
-        $('#' + this._sPopupContainerId).dolPopupHide({});
-    }
-}
-
-BxDolUploaderSimple.prototype.cancelAll = function () {
-    $('#' + this._sIframeId).attr('src', 'javascript:false;');
-    this.onUploadCompleted(_t('_sys_uploader_upload_canceled'));
-}
-
-BxDolUploaderSimple.prototype.restoreGhosts = function (bInitReordering, onComplete) {
-    var sUrl = this._getUrlWithStandardParams() + '&img_trans=' + this._sImagesTranscoder + '&a=restore_ghosts&f=json' + '&c=' + this._iContentId + '&_t=' + escape(new Date());
-    var $this = this;
-
-    bInitReordering = bInitReordering !== undefined ? bInitReordering : this._isReordering;
-
-    $.getJSON(sUrl, function (aData) {
-
-        if (!$this.isMultiple())
-            $('#' + $this._sResultContainerId + ' .bx-uploader-ghost').remove();
-
-        if ('object' === typeof(aData)) {
-            if('object' === typeof(aData.g) && 'object' === typeof(aData.o)) 
-                for(var i in aData.o) {
-                    var iFileId = aData.o[i];
-                    $this.showGhost(iFileId, aData.g[iFileId]);
-                }
-            else
-                $.each(aData, function(iFileId, oVars) {
-                    $this.showGhost(iFileId, oVars);
-                });
-
-            $('#' + $this._sResultContainerId).bx_show_more_check_overflow();
-
-            if(bInitReordering) {
-                var sClassGhost = 'bx-uploader-ghost';
-                $('#' + $this._sResultContainerId).find('.' + sClassGhost).each(function() {
-                    if($(this).find('.bx-uploader-ghost-reorder').length == 0)
-                        $(this).prepend($this._sTemplateReorder);
-                });
-
-                var fInitReordering = function() {                    
-                    $('#' + $this._sResultContainerId).sortable({
-                        items: '.' + sClassGhost, 
-                        start: function(oEvent, oUi) {
-                            oUi.item.addClass('bx-uploader-ghost-dragging');
-                        },
-                        stop: function(oEvent, oUi) {
-                            oUi.item.removeClass('bx-uploader-ghost-dragging');
-
-                            $this.reorderGhosts(oUi.item);
-                        }
-                    });
-                };
-
-                if($.sortable !== undefined)
-                    fInitReordering();
-                else
-                    setTimeout(fInitReordering, 2000);
-            }
-        }
-
-        if(typeof onComplete === 'function')
-            return onComplete(aData);
-    });
-};
-
-BxDolUploaderSimple.prototype.reorderGhosts = function(oDraggable) {
-    var sUrl = this._getUrlWithStandardParams() + '&a=reorder_ghosts&f=json' + '&c=' + this._iContentId + '&' + $('#' + this._sResultContainerId).sortable('serialize', {key: 'ghosts[]'}) + '&_t=' + escape(new Date());
-
-    $.getJSON(sUrl, function (aData) {
-        processJsonData(aData);
-    });
-};
-
-BxDolUploaderSimple.prototype.showGhost = function(iId, oVars) {
-    var oFileContainer = $('#' + this._getFileContainerId(iId));
-    if(oFileContainer.length > 0)
-        return;
-
-    var sHTML;
-    if (typeof this._sTemplateGhost == 'object')
-        sHTML = this._sTemplateGhost[iId];
-    else
-        sHTML = this._sTemplateGhost;
-
-    for(var i in oVars)
-        sHTML = sHTML.replace (new RegExp('{' + i + '}', 'g'), oVars[i]);
-
-    $('#' + this._sResultContainerId).append(sHTML);
-
-    oFileContainer.find('.bx-uploader-ghost-preview img').hide().fadeIn(1000);
-};
-
-BxDolUploaderSimple.prototype.deleteGhost = function (iFileId) {
-    var sUrl = this._getUrlWithStandardParams() + '&a=delete&id=' + iFileId;
-    var $this = this;
-
-    var sFileContainerId = $this._getFileContainerId(iFileId);
-    bx_loading(sFileContainerId, true);
-
-    $.post(sUrl, {_t: escape(new Date())}, function (sMsg) {
-        bx_loading(sFileContainerId, false);
-        if ('ok' == sMsg) {
-            $('#' + sFileContainerId).slideUp('slow', function () {
-                $(this).remove();
-            });
-        } else {
-            $('#' + this._sResultContainerId).prepend($this._sTemplateErrorGhosts.replace('{error}', sMsg));
-        }        
-    });
-};
-
-BxDolUploaderSimple.prototype._clearErrors = function () {
-    $('#' + this._sPopupContainerId + ' #' + this._sErrorsContainerId).html('');
-    this._isErrorShown = false;
-}
-
-BxDolUploaderSimple.prototype._showError = function (s, bAppend) {
-    if (s == undefined || !s.length)
-        return;
-    if (!bAppend)
-        $('#' + this._sPopupContainerId + ' #' + this._sErrorsContainerId).html(this._sTemplateError.replace('{error}', s));
-    else
-        $('#' + this._sPopupContainerId + ' #' + this._sErrorsContainerId).prepend(this._sTemplateError.replace('{error}', s));
-    this._isErrorShown = true;
-};
-
-BxDolUploaderSimple.prototype._getFileContainerId = function (iFileId) {
-	return 'bx-uploader-file-' + this._sStorageObject + '-' + iFileId;
-};
-
-BxDolUploaderSimple.prototype._getUrlWithStandardParams = function () {
-    return sUrlRoot + 'storage_uploader.php?uo=' + this._sUploaderObject + '&so=' + this._sStorageObject + '&uid=' + this._sUniqId;
-}
-
-BxDolUploaderSimple.prototype._lockPageFromLeaving = function () {
-    $(window).bind('beforeunload', function (e) {
-        var e = e || window.event;
-        // for ie, ff
-        e.returnValue = _t('_sys_uploader_confirm_leaving_page');
-        // for webkit
-        return _t('_sys_uploader_confirm_leaving_page');
-    });
-}
-
-BxDolUploaderSimple.prototype._unlockPageFromLeaving = function () {
-    $(window).unbind('beforeunload');
-}
-
-BxDolUploaderSimple.prototype._loading = function (bShowProgress, bShowForm) {
-
-    var eForm = $('#' + this._sFormContainerId + ' .bx-uploader-files-list');
-    var eBtn = $('#' + this._sFormContainerId + ' .bx-btn-primary');
-
-    if (bShowForm) {
-        if (null != this._eForm) {
-            eForm.find('.bx-uploader-simple-file').filter(':not(:first)').remove();
-            if ('undefined' !== typeof(this._eForm.reset)) 
-                this._eForm.reset();
-        }
-        eForm.show();
-        eBtn.show();
-    } else {
-        eForm.hide();
-        eBtn.hide();
-    }
-
-    bx_loading($('#' + this._sFormContainerId + ' .bx-uploader-loading').get(0), bShowProgress);
-}
-
-BxDolUploaderSimple.prototype.getMimeTypefromString  = function (ext) {
-    
-    var mimeTypes = 
-    {
-        
-        '3gp'    : 'video/3gpp',
-        '3g2'    : 'video/3gpp2',
-        'a'      : 'application/octet-stream',
-        'ai'     : 'application/postscript',
-        'aif'    : 'audio/x-aiff',
-        'aifc'   : 'audio/x-aiff',
-        'aiff'   : 'audio/x-aiff',
-        'asf'   : 'video/x-ms-asf',
-        'au'     : 'audio/basic',
-        'avi'    : 'video/x-msvideo',
-        'avi'    : 'video/avi',
-        'bat'    : 'text/plain',
-        'bin'    : 'application/octet-stream',
-        'bmp'    : 'image/x-ms-bmp',
-        'c'      : 'text/plain',
-        'cdf'    : 'application/x-cdf',
-        'csh'    : 'application/x-csh',
-        'css'    : 'text/css',
-        'divx'   : 'video/divx',
-        'dll'    : 'application/octet-stream',
-        'doc'    : 'application/msword',
-        'dot'    : 'application/msword',
-        'drc'    : 'video/drc',
-        'dvi'    : 'application/x-dvi',
-        'eml'    : 'message/rfc822',
-        'eps'    : 'application/postscript',
-        'etx'    : 'text/x-setext',
-        'exe'    : 'application/octet-stream',
-        'gif'    : 'image/gif',
-        'gtar'   : 'application/x-gtar',
-        'h'      : 'text/plain',
-        'hdf'    : 'application/x-hdf',
-        'htm'    : 'text/html',
-        'html'   : 'text/html',
-        'jpe'    : 'image/jpeg',
-        'jpeg'   : 'image/jpeg',
-        'jpg'    : 'image/jpeg',
-        'js'     : 'application/x-javascript',
-        'ksh'    : 'text/plain',
-        'latex'  : 'application/x-latex',
-        'm1v'    : 'video/mpeg',
-        'man'    : 'application/x-troff-man',
-        'me'     : 'application/x-troff-me',
-        'mht'    : 'message/rfc822',
-        'mhtml'  : 'message/rfc822',
-        'mkv'    : 'video/x-matroska',
-        'mif'    : 'application/x-mif',
-        'mov'    : 'video/quicktime',
-        'movie'  : 'video/x-sgi-movie',
-        'mp2'    : 'audio/mpeg',
-        'mp3'    : 'audio/mpeg',
-        'mp4'    : 'video/mp4',  
-        'm4v'    : 'video/mp4', 
-        'mpa'    : 'video/mpeg',
-        'mpe'    : 'video/mpeg',
-        'mpeg'   : 'video/mpeg',
-        'mpg'    : 'video/mpeg',
-        'ms'     : 'application/x-troff-ms',
-        'nc'     : 'application/x-netcdf',
-        'nws'    : 'message/rfc822',
-        'o'      : 'application/octet-stream',
-        'obj'    : 'application/octet-stream',
-        'oda'    : 'application/oda',
-        'ogv'    : 'video/ogg',
-        'ogg'    : 'video/ogg',
-        'pbm'    : 'image/x-portable-bitmap',
-        'pdf'    : 'application/pdf',
-        'pfx'    : 'application/x-pkcs12',
-        'pgm'    : 'image/x-portable-graymap',
-        'png'    : 'image/png',
-        'pnm'    : 'image/x-portable-anymap',
-        'pot'    : 'application/vnd.ms-powerpoint',
-        'ppa'    : 'application/vnd.ms-powerpoint',
-        'ppm'    : 'image/x-portable-pixmap',
-        'pps'    : 'application/vnd.ms-powerpoint',
-        'ppt'    : 'application/vnd.ms-powerpoint',
-        'pptx'   : 'application/vnd.ms-powerpoint',
-        'ps'     : 'application/postscript',
-        'pwz'    : 'application/vnd.ms-powerpoint',
-        'py'     : 'text/x-python',
-        'pyc'    : 'application/x-python-code',
-        'pyo'    : 'application/x-python-code',
-        'qt'     : 'video/quicktime',
-        'ra'     : 'audio/x-pn-realaudio',
-        'ram'    : 'application/x-pn-realaudio',
-        'ras'    : 'image/x-cmu-raster',
-        'rdf'    : 'application/xml',
-        'rgb'    : 'image/x-rgb',
-        'rm'     : 'application/vnd.rn-realmedia',
-        'rmvb'   : 'application/vnd.rn-realmedia-vbr',
-        'roff'   : 'application/x-troff',
-        'rtx'    : 'text/richtext',
-        'sgm'    : 'text/x-sgml',
-        'sgml'   : 'text/x-sgml',
-        'sh'     : 'application/x-sh',
-        'shar'   : 'application/x-shar',
-        'snd'    : 'audio/basic',
-        'so'     : 'application/octet-stream',
-        'src'    : 'application/x-wais-source',
-        'swf'    : 'application/x-shockwave-flash',
-        't'      : 'application/x-troff',
-        'tar'    : 'application/x-tar',
-        'tcl'    : 'application/x-tcl',
-        'tex'    : 'application/x-tex',
-        'texi'   : 'application/x-texinfo',
-        'texinfo': 'application/x-texinfo',
-        'tif'    : 'image/tiff',
-        'tiff'   : 'image/tiff',
-        'tr'     : 'application/x-troff',
-        'tsv'    : 'text/tab-separated-values',
-        'txt'    : 'text/plain',
-        'ustar'  : 'application/x-ustar',
-        'vcf'    : 'text/x-vcard',
-        'wav'    : 'audio/x-wav',
-        'wav'    : 'audio/wav',
-        'webm'   : 'video/webm',
-        'wmv'    : 'video/wmv',
-        'wiz'    : 'application/msword',
-        'wsdl'   : 'application/xml',
-        'xbm'    : 'image/x-xbitmap',
-        'xlb'    : 'application/vnd.ms-excel',
-        'xls'    : 'application/vnd.ms-excel',
-        'xlsx'    : 'application/vnd.ms-excel',
-        'xml'    : 'text/xml',
-        'xpdl'   : 'application/xml',
-        'xpm'    : 'image/x-xpixmap',
-        'xsl'    : 'application/xml',
-        'xvid'   : 'video/xvid',
-        'webp'   : 'image/webp',
-        'xwd'    : 'image/x-xwindowdump',
-        'svg'    : 'image/svg+xml',
-        'zip'    : ['application/zip', 'application/x-zip-compressed']
-       
-    }
-    return mimeTypes[ext.replace('.', '')];
-}
-
-/**
- * HTML5 Uploader js class
- */
-function BxDolUploaderHTML5 (sUploaderObject, sStorageObject, sUniqId, options) {
-
-    this.init(sUploaderObject, sStorageObject, sUniqId, options);
-
-    this._sIframeId = 'bx-form-input-files-' + sUniqId + '-iframe';
-    this._eForm = null;    
-
-    this._sDivId = 'bx-form-input-files-' + sUniqId + '-div-' + this._sUploaderObject;
-
-    this._sFocusDivId = 'bx-form-input-files-' + sUniqId + '-focus-' + this._sUploaderObject;
-
-    this._uploader = null;
-
-    this.initUploader = function (o) {
-
-        var $this = this;
-
-        if (null != this._uploader)
-            this._uploader = null;
-
-        var $this = this;
-
-        var _options = {
-            allowProcess: false,
-            allowRevert: false,
-            allowRemove: false,
-            imagePreviewHeight: 100,
-            credits: {},
-            allowMultiple: $this._isMultiple ? true : false,
-            maxFiles: $this.isMultiple() ? 50 : 1,
-            maxFileSize: o.maxFilesize +'MB',
-            instantUpload: true,
-            onaddfile: (error, file) => { 
-                if (error){
-                    $this._uploader.removeFile(file);
-                    if($this._uploader.status != 3)
-                        $this.onUploadCompleted(''); 
-                }
-                else{
-                    $this.onBeforeUpload(''); 
-                }
-            },
-            onerror: (error) => { 
-                if (error.main)
-                    $this._showError(error.main + '. ' + error.sub, true);
-            },
-            onprocessfiles: (files) => { 
-                $this.onUploadCompleted(''); 
-            },
-            onprocessfileprogress(file, progress) {
-               
-            },
-            server: {
-				process: (fieldName, file, metadata, load, error, progress, abort) => {
-					const formData = new FormData();
-					formData.append('file', file, file.name);
-					formData.append('uo', this._sUploaderObject);
-					formData.append('so', this._sStorageObject);
-					formData.append('uid', this._sUniqId);
-					formData.append('m', this._isMultiple ? 1 : 0);
-					formData.append('c', this._iContentId);
-					formData.append('p', this._isPrivate);
-					formData.append('a', 'upload');
-
-					const request = new XMLHttpRequest();
-					request.open('POST', sUrlRoot + 'storage_uploader.php');
-
-					request.upload.onprogress = (e) => {
-						progress(e.lengthComputable, e.loaded, e.total);
-					};
-
-					request.onload = function(res) {
-						if (request.status >= 200 && request.status < 300) {
-							var o = null;
-                            try {
-                                o = JSON.parse(request.responseText);
-                            } 
-                            catch (e) {}
-                            if (o && 'undefined' !== typeof(o.error)) {
-                                $this._showError(o.error, true);
-                                error('error');
-                            }
-                            
-                            load(request.responseText);
-						}
-						else {
-							error('error');
-						}
-					};
-					request.send(formData);
-				}
-			},
-        };
-        
-        aAcceptableFiles = [];
-        if (o.acceptedFiles && o.acceptedFiles != ''){
-            a = o.acceptedFiles.trim().split(/\s*,\s*/);
-            a.forEach(function(item, i, arr) {
-                if ($this.getMimeTypefromString(item)){
-                    oT = $this.getMimeTypefromString(item);
-                    if (Array.isArray(oT)){
-                        oT.forEach(function(oTs, j, ar) {
-                            aAcceptableFiles.push(oTs);
-                        });
-                    }
-                    else{
-                        aAcceptableFiles.push(oT);
-                    }
-                }
-                    
-            });
-        }
-        
-        if (aAcceptableFiles.length){
-            _options.acceptedFileTypes = aAcceptableFiles;
-        }
-        
-        if (o.resizeWidth || o.resizeHeight){
-            _options.allowImageResize = true;
-            _options.imageResizeTargetWidth = o.resizeWidth;
-            _options.imageResizeTargetHeight = o.resizeHeight;
-            _options.imageResizeMode = o.resizeMethod;
-        }
-        else{
-            _options.allowImageResize = false;
-            _options.allowImageTransform = false;
-        }
-        
-        FilePond.registerPlugin(
-            FilePondPluginImagePreview,
-            FilePondPluginFileValidateType,
-            FilePondPluginFileValidateSize,
-            FilePondPluginImageTransform,
-            FilePondPluginImageCrop,
-            FilePondPluginImageResize,
-            
-        );
-
-        this._uploader = FilePond.create(
-            document.querySelector('#' + this._sDivId),
-            $.extend({}, _options, o)
-        );    
-
-        this.initPasteEditor();
-    }
-
-    this.onUploadCompleted = function (sErrorMsg) {        
-        if (sErrorMsg.length)
-            this._showError(sErrorMsg);        
-        
-        var $this = this;
-        if($this._uploader.status != 3){
-            this._isUploadsInProgress = false;
-            this.restoreGhosts();
-            if (!this._isErrorShown) {
-                $('#' + this._sPopupContainerId).dolPopupHide({});
-                this.removeFiles();
-            }
-        }
-    }
-
-    this.removeFiles = function () {
-        oFiles = this._uploader.getFiles();
-        for (i = 0; i < oFiles.length; i++){
-            this._uploader.removeFile(i);
-        }
-    }
-
-    this.cancelAll = function () {
-        this.removeFiles();
-    }
-
-    this.onBeforeUpload = function (params) {
-        this._isUploadsInProgress = true;
-        this._clearErrors();
-    }
-
-    this.onProgress = function (params) {
-
-    }
-
-    this.onClickCancel = function () {
-        var $this = this;
-        if (this._isUploadsInProgress) {
-            bx_confirm(_t('_sys_uploader_confirm_close_popup'), function() {
-                $this.removeFiles();
-                $this.cancelAll();
-                $('#' + $this._sPopupContainerId).dolPopupHide({});
-            });
-        } else {
-            $this.removeFiles();
-            $('#' + this._sPopupContainerId).dolPopupHide();
-        }
-        
-        BxDolUploaderSimple.prototype._clearErrors.call(this);
-    }
-
-    this.onShowPopup = function () {
-        var $this = this;
-        setTimeout(function () {
-            $this.focusPasteEditor();
-        }, 200);
-    }
-
-    this.focusPasteEditor = function () {
-        $('#' + this._sFocusDivId).focus();
-    }
-
-    this.initPasteEditor = function () {
-        var $this = this;
-        $('#' + this._sFocusDivId).on('paste', function (e) {
-            var aFiles = [];
-            if (e.type == 'paste') {
-                var aItems = (e.clipboardData || e.originalEvent.clipboardData).items;
-                
-                for (var i in aItems) {
-                    var oItem = aItems[i];
-                    if (oItem.kind === 'file')
-                        aFiles.push(oItem.getAsFile());
-                }
-                $this._uploader.addFiles(aFiles);
-            }
-        });
-    }
-}
-
-BxDolUploaderHTML5.prototype = BxDolUploaderSimple.prototype;
-
-/**
- * Crop Image Uploader js class
- */
-function BxDolUploaderCrop (sUploaderObject, sStorageObject, sUniqId, options) {
-
-    this.init(sUploaderObject, sStorageObject, sUniqId, options);
-
-    this._eForm = null;
-
-    this.initUploader = function (oOptions) {
-
-        var $this = this;
-
-        var aExt = ['jpg', 'jpeg', 'png', 'gif', 'webp'];
-
-        var eCroppie = $("#" + this._sFormContainerId + " .bx-croppie-element").croppie(oOptions);
-
-		$("#" + this._sFormContainerId + ' .bx-crop-rotate').on('click', function(ev) {
-			eCroppie.croppie('rotate', parseInt($(this).data('deg')));
-		});
-        
-        $("#" + this._sFormContainerId + " input[name=f]").on("change", function() {
-            var input = this;            
-
-            if (input.files && input.files[0]) {
-
-                var m = input.files[0].name.match(/\.([A-Za-z0-9]+)$/);
-
-                if (2 != m.length || -1 == aExt.indexOf(m[1].toLowerCase())) {                    
-                    $(input).replaceWith($(input).val('').clone(true));
-                    $this._showError(_t('_sys_uploader_crop_wrong_ext'));
-                    return;
-                }
-
-                $this._clearErrors();
-
-                var reader = new FileReader()
-
-                reader.onload = function(e) {
-                    eCroppie.croppie('bind', {
-                        url: e.target.result
-                    });
-                    $("#" + $this._sFormContainerId + " .bx-croppie-element").addClass('ready');
-                    $("#" + $this._sFormContainerId + " .bx-crop-action").removeClass('bx-btn-disabled');
-                    $("#" + $this._sFormContainerId + " .bx-croppie-element").data('bx-filename', input.files[0].name.replace(/(\.[A-Za-z0-9]+)$/, '.jpg'));
-                }
-                reader.readAsDataURL(input.files[0]);
-            }
-        });
-
-        $("#" + this._sFormContainerId + " .bx-crop-upload").on('click', function(ev) {
-            eCroppie.croppie('result', {
-                type: 'canvas',
-                size: 'original',
-                format: 'jpeg',
-                quality: '0.85',
-            }).then(function(resp) {
-                var fd = new FormData();
-
-                fd.append("f", dataURItoBlob(resp), $("#" + $this._sFormContainerId + " .bx-croppie-element").data('bx-filename'));
-                $.each(oOptions.bx_form, function (sName) {
-                    fd.append(sName, this);
-                });
-                
-                $this.onBeforeUpload(fd);
-
-                $.ajax({
-                    url: sUrlRoot + 'storage_uploader.php',
-                    type: "POST",
-                    processData: false,
-                    contentType: false,
-                    data: fd,
-                    success: function(data) {
-                        eval(data);
-                    },
-                    error: function() {
-                        $this._showError(_t('_sys_uploader_crop_err_upload'));
-                    }
-                })
-
-            });
-        });
-
-        function dataURItoBlob(dataURI) {
-            var split = dataURI.split(','),
-                dataTYPE = split[0].match(/:(.*?);/)[1],
-                binary = atob(split[1]),
-                array = [];
-                
-            for (var i = 0; i < binary.length; i++) 
-                array.push(binary.charCodeAt(i));
-
-            return new Blob([new Uint8Array(array)], {
-                type: dataTYPE
-            });
-        }
-
-        
-    };
-}
-
-BxDolUploaderCrop.prototype = BxDolUploaderSimple.prototype;
-
-
-/**
- * Record Video Uploader js class
- */
-function BxDolUploaderRecordVideo (sUploaderObject, sStorageObject, sUniqId, options) {
-    this._camera = null;
-    this._blob = null;
-    this._recorder = null;
-    this._camera_type = 'user';
-
-    this._audio_bitrate = undefined !== options.audio_bitrate ? parseInt(options.audio_bitrate) : 128000;
-    this._video_bitrate = undefined !== options.video_bitrate ? parseInt(options.video_bitrate) : 1000000;
-
-    this.init(sUploaderObject, sStorageObject, sUniqId, options);
-
-    this.showUploaderForm = function() {
-        if (typeof MediaRecorder == 'undefined' || !('requestData' in MediaRecorder.prototype)) {
-            bx_alert(_t('_sys_uploader_unsupported_browser'));
-            return;
-        }
-
-        BxDolUploaderSimple.prototype.showUploaderForm.call(this);
-    }
-
-    this.onBeforeShowPopup = function() {
-        this._blob = null;
-        this._camera = null;
-        this._recorder = null
-        this._clearErrors();
-
-        $('#bx-upoloader-recording-preview').hide();
-        $('#bx-upoloader-camera-capture').show();
-
-        $('#' + this._sFormContainerId + ' .bx-uploader-record-video-controls').hide();
-    }
-
-    this.switchCamera = function () {
-        this._camera_type = this._camera_type == 'user' ? 'environment' : 'user';
-
-        this.releaseCamera();
-        this.onShowPopup();
-    }
-
-    this.onShowPopup = function () {
-        var $this = this;
-
-        navigator.mediaDevices.getUserMedia({ audio: true, video: {facingMode: this._camera_type} }).then(function(camera) {
-            $this._camera = camera;
-            $this.showCameraCapture();
-
-            $('#' + $this._sFormContainerId + ' .bx-uploader-recording-start').show();
-            $('#' + $this._sFormContainerId + ' .bx-uploader-recording-stop').hide();
-            $('#' + $this._sFormContainerId + ' .bx-uploader-record-video-controls').show();
-
-            navigator.mediaDevices.enumerateDevices().then(function(mediaDevices){
-                let constraints = navigator.mediaDevices.getSupportedConstraints();
-                if ($this.getDevicesNum(mediaDevices) > 1 && typeof constraints.facingMode != 'undefined' && constraints.facingMode) {
-                    $('#' + $this._sFormContainerId + ' .bx-record-camera-switch').show();
-                } else {
-                    $('#' + $this._sFormContainerId + ' .bx-record-camera-switch').hide();
-                }
-            });
-
-        }).catch(function(error) {
-            $this._showError(_t('_sys_uploader_camera_capture_failed'));
-        });
-    }
-
-    this.onClickCancel = function () {
-        this.releaseCamera();
-
-        BxDolUploaderSimple.prototype.onClickCancel.call(this);
-    }
-
-    this.startRecording = function() {
-        this._recorder = RecordRTC(this._camera, {
-            type: 'video',
-            audioBitsPerSecond: this._audio_bitrate,
-            videoBitsPerSecond: this._video_bitrate,
-            disableLogs: true
-        });
-
-        if (!this._recorder) {
-            this._showError(_t('_sys_uploader_unsupported_browser'));
-            return;
-        }
-
-        $("#" + this._sFormContainerId + " .bx-btn.bx-btn-primary:not(.bx-crop-upload)").hide();
-        $('#' + this._sFormContainerId + ' .bx-uploader-recording-start').hide();
-        $('#' + this._sFormContainerId + ' .bx-uploader-recording-stop').show();
-
-        this._recorder.startRecording();
-
-        this.showCameraCapture();
-    }
-
-    this.stopRecording = function(bSubmitWhenReady) {
-        $('#' + this._sFormContainerId + ' .bx-uploader-recording-start').show();
-        $('#' + this._sFormContainerId + ' .bx-uploader-recording-stop').hide();
-
-        var $this = this;
-        this._recorder.stopRecording(function(){
-            $this._blob = $this._recorder.getBlob();
-            $this.showRecordingPreview();
-
-            $this._recorder.destroy();
-            $this._recorder = null;
-
-            $("#" + $this._sFormContainerId + " .bx-btn.bx-btn-primary:not(.bx-crop-upload)").show();
-            if (bSubmitWhenReady)
-                $this.submitRecording($('#' + $this._sFormContainerId + ' form').get(0));
-        });
-    }
-
-    this.showCameraCapture = function() {
-        var video = $('#bx-upoloader-recording-preview').hide().get(0);
-        if (video.pause !== 'undefined') video.pause();
-        video.removeAttribute('src');
-
-        video = $('#bx-upoloader-camera-capture').show().get(0);
-        video.srcObject = this._camera;
-        video.muted = true;
-        video.volume = 0;
-        $('#' + this._sFormContainerId + ' .bx-record-video-preview .bx-record-video-preview-filesize').html('');
-    }
-
-    this.showRecordingPreview = function() {
-        $('#bx-upoloader-camera-capture').hide();
-        $('#bx-upoloader-recording-preview').show().get(0).src = URL.createObjectURL(this._blob);
-
-        var mbytes = (this._blob.size/1024/1024).toFixed(2);
-        $('#' + this._sFormContainerId + ' .bx-record-video-preview .bx-record-video-preview-filesize').html(mbytes + ' ' + _t('_sys_uploader_record_video_mb'));
-    }
-
-    this.submitRecording = function(form) {
-        if (this._recorder) {
-            this.stopRecording(true);
-            return;
-        }
-
-        this.onBeforeUpload(form);
-
-        var data = new FormData(form);
-        if (this._blob != null) data.append("f[]", this._blob, new Date().toISOString() + '.webm');
-
-        var $this = this;
-        $.ajax({
-            url: $(form).attr('action'),
-            type: "POST",
-            data: data,
-            processData: false,
-            contentType: false,
-            success:function(sErrorMsg, textStatus, jqXHR) {
-                $this.onUploadCompleted(sErrorMsg);
-                if (!sErrorMsg.length) {
-                    $this.releaseCamera();
-                }
-            },
-        });
-    }
-
-    this.releaseCamera = function() {
-        //stop playing recorded file
-        var video = $('#bx-upoloader-recording-preview').get(0);
-        if (video.pause != 'undefined') video.pause();
-        video.removeAttribute('src');
-
-        if (this._recorder) {
-            this._recorder.destroy();
-            this._recorder = null;
-        }
-
-        if (this._camera) {
-            if (typeof this._camera.stop != 'undefined') this._camera.stop();
-            this._camera.getTracks().forEach(function (track) {
-                if (track.readyState == 'live') {
-                    track.stop();
-                }
-            });
-        }
-    }
-
-    this.getDevicesNum = function(mediaDevices) {
-        let count = 0;
-        mediaDevices.forEach(mediaDevice => {
-            if (mediaDevice.kind === 'videoinput') count++;
-        });
-        return count;
-    }
-}
-
-BxDolUploaderRecordVideo.prototype = BxDolUploaderSimple.prototype;
-
-/** @} */

+ 6 - 10
inc/js/classes/BxDolUploader.js

@@ -487,6 +487,8 @@ function BxDolUploaderHTML5 (sUploaderObject, sStorageObject, sUniqId, options)
             },
             onprocessfiles: (files) => { 
                 $this.onUploadCompleted(''); 
+                oProgress.hide();
+                $this._aFiles = [];
             },
             onprocessfileprogress(file, progress) {
                 $this._aFiles[file.source.lastModified+'-'+file.source.size+'-'+file.source.name] = progress * file.source.size;
@@ -504,17 +506,12 @@ function BxDolUploaderHTML5 (sUploaderObject, sStorageObject, sUniqId, options)
             
                 oProgress =  $('#' + $this._sProgressContainerId);
                 
-                if (oProgress.parents('form').find('.uploader_progress').length > 0){
+                if (oProgress.parents('.bx-db-container').find('.uploader_progress').length > 0){
                     oProgress = oProgress.parents('.bx-db-container').find('.uploader_progress');
                 }
-                if (iProgress == 100){
-                    oProgress.hide();
-                    $this._aFiles = [];
-                }
-                else{
-                    oProgress.show();
-                    oProgress.find('.progress_line').css('width', iProgress + '%');
-                }
+                
+                oProgress.show();
+                oProgress.find('.progress_line').css('width', iProgress + '%');
             },
             server: {
 				process: (fieldName, file, metadata, load, error, progress, abort) => {
@@ -544,7 +541,6 @@ function BxDolUploaderHTML5 (sUploaderObject, sStorageObject, sUniqId, options)
                             catch (e) {}
                             if (o && 'undefined' !== typeof(o.error)) {
                                 $this._showError(o.error, true);
-                                error('error');
                             }
                             
                             load(request.responseText);

+ 0 - 4
inc/js/classes/_notes/dwsync.xml

@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<dwsync>
-<file name="BxDolUploader.js" server="online.me:5190/public_html/" local="133142914931825395" remote="133142915040000000" Dst="1" />
-</dwsync>

+ 2 - 2
modules/base/groups/template/cover_block.html

@@ -8,8 +8,8 @@
                         <div class="absolute top-6 -right-1/4 w-2/3 h-2/3 bg-green-700 filter blur-3xl z-0 opacity-50 animate-goo"></div>
                     </div>
                     <div class="bx-base-pofile-cover-image relative h-64 lg:h-40 max-w-7xl mx-auto opacity-100 __add_class__">
-                        <a class="bx-base-pofile-cover-image box-border absolute h-full w-full" href="__cover_href__" onclick="$('#__cover_popup_id__').dolPopupImage('__cover_url__', this)">
-                            <img class="bx-base-pofile-cover-image h-64 mx-auto w-full object-cover bg-cover lg:h-40 rounded-t z-10 __img_class__" style="background-image:url(__cover_url__)" src="<bx_icon_url:spacer.gif />" />
+                        <a class="bx-base-pofile-cover-image box-border absolute h-full w-full" href="__cover_href__" >
+                            <img class="bx-base-pofile-cover-image h-64 mx-auto w-full object-cover bg-cover lg:h-40 rounded-t z-10 __img_class__ bx-image-edit-source-__unique_id__" style="background-image:url(__cover_url__);__cover_settins__" src="<bx_icon_url:spacer.gif />" />
                         </a>
                     </div>
                 </div>

+ 21 - 4
modules/base/profile/classes/BxBaseModProfileTemplate.php

@@ -287,7 +287,6 @@ class BxBaseModProfileTemplate extends BxBaseModGeneralTemplate
         $sShowData = isset($aParams['show_data']) ? $aParams['show_data'] : '';
         $bShowCover = !isset($aParams['show_cover']) || $aParams['show_cover'] === true;
         $bShowAvatar = !isset($aParams['show_avatar']) || $aParams['show_avatar'] === true;
-        $bShowClickable = !isset($aParams['show_clickable']) || $aParams['show_clickable'] === true; //--- Is available for UseAsBlock appearance only.
         $sAddCode = "";
         
 
@@ -299,9 +298,6 @@ class BxBaseModProfileTemplate extends BxBaseModGeneralTemplate
         else
             BxDolTemplate::getInstance()->addInjection('injection_main_class', 'text', 'bx-base-profile-view');
 
-        if($bUseAsBlock && $bShowClickable)
-            $sClass .= ' bx-clickable';
-
         $bProfileViewAllowed = $oModule->checkAllowedView($aData) === CHECK_ACTION_RESULT_ALLOWED;
 
         if($oModule->checkAllowedViewProfileImage($aData) !== CHECK_ACTION_RESULT_ALLOWED)
@@ -388,6 +384,7 @@ class BxBaseModProfileTemplate extends BxBaseModGeneralTemplate
 
         $bTmplVarsShowAvatar = $bShowAvatar && ($bUrlAvatar || $this->_bLetterAvatar);
         $aTmplVarsShowAvatar = [];
+        $sPicturePopup = '';
 
         if($bTmplVarsShowAvatar) {
             $sPicturePopupId = $this->MODULE . '-popup-picture';
@@ -447,6 +444,18 @@ class BxBaseModProfileTemplate extends BxBaseModGeneralTemplate
                 'picture_url' => $sUrlPicture,
                 'picture_href' => !$aData[$CNF['FIELD_PICTURE']] && CHECK_ACTION_RESULT_ALLOWED === $oModule->checkAllowedEdit($aData) ? $sUrlPictureChange : 'javascript:void(0);',
             );
+            
+            if($bProfileViewAllowed && $aData[$CNF['FIELD_PICTURE']]) {
+                $sPicturePopup = BxTemplFunctions::getInstance()->transBox($sPicturePopupId, $this->parseHtmlByName('image_popup.html', array (
+                    'image_url' => $sUrlPicture,
+                    'bx_if:owner' => array (
+                        'condition' => false,
+                        'content' => array (
+                            'change_image_url' => $sUrlPictureChange,
+                        ),
+                    ),
+                )), true, true);
+            }
         }
 
         //--- Process Actions menu
@@ -499,9 +508,17 @@ class BxBaseModProfileTemplate extends BxBaseModGeneralTemplate
             'action_menu' => $sActionsMenu,
             'meta' => $sMetaMenu,
             'show_data' => $sShowData,
+            'picture_popup' => $sPicturePopup,
             'additional_code' => $sAddCode,
             'cover_tweak' => $sCoverTweak,
         ];
+        
+        $bShowClickable = !isset($aParams['show_clickable']) || $aParams['show_clickable'] === true; //--- Is available for UseAsBlock appearance only.
+        if ($sCoverTweak != '')
+            $bShowClickable = false;
+        
+        if($bUseAsBlock && $bShowClickable)
+            $sClass .= ' bx-clickable';
 
         if($bUseAsBlock)
             $aTmplVars = array_merge($aTmplVars, [

+ 2 - 1
modules/base/profile/template/cover.html

@@ -11,7 +11,7 @@
                 <div class="bx-base-pofile-ci-cnt bx-def-padding-leftright">
                     <bx_if:show_avatar>
                         <div class="bx-base-pofile-cover-thumb __add_class__">
-                            <a class="bx-base-pofile-cover-thumb" href="__picture_href__">
+                            <a class="bx-base-pofile-cover-thumb" href="__picture_href__"  onclick="$('#__picture_popup_id__').dolPopupImage('__picture_url__', $(this).parent()); event.stopPropagation();">
                                 <img class="bx-base-pofile-unit-thumb bx-def-ava-big bx-def-ava-big-size rounded-full ring-4 mx-auto ring-white dark:ring-gray-900 __img_class__ bx-image-edit-source-__unique_id__" src="__ava_url__" <bx_if:show_ava_letter> style="display:none" </bx_if:show_ava_letter> />
                                 <p class="bx-base-pofile-unit-thumb bx-def-ava-big bx-def-ava-big-size flex items-center justify-center box-border m-0 rounded-full ring-4 mx-auto ring-white dark:ring-gray-900 text-white font-bold text-5xl __img_class__-placeholder" style="background-color:rgba(__color__);<bx_if:show_ava_image>display:none</bx_if:show_ava_image>">__letter__</p>
                             </a>
@@ -33,5 +33,6 @@
             __cover_tweak__
         </div>
     </div>
+    __picture_popup__
 </div>
 __additional_code__

+ 5 - 3
modules/base/profile/template/cover_block.html

@@ -3,10 +3,10 @@
         <div class="bx-base-pofile-cover bx-def-cover-color-bg bx-def-box-sizing"<bx_if:show_clickable> onclick="bx_click_area('__content_url__', event)"</bx_if:show_clickable>>
             <bx_if:show_cover>
                 <div class="bx-base-pofile-cover-image __add_class__">
-                    <a class="bx-base-pofile-cover-image bx-def-box-sizing" href="__cover_href__" onclick="$('#__cover_popup_id__').dolPopupImage('__cover_url__', this)">
-                        <img class="bx-base-pofile-cover-image __img_class__" style="background-image:url(__cover_url__)" src="<bx_icon_url:spacer.gif />"/>
+                    <a class="bx-base-pofile-cover-image bx-def-box-sizing flex justify-center items-center">
+                        <img class="bx-base-pofile-cover-image h-full object-cover bg-cover w-full __img_class__ bx-image-edit-source-__unique_id__" style="background-image:url(__cover_url__);__cover_settins__" src="<bx_icon_url:spacer.gif />"/>
                     </a>
-                    <div class="bx-cover-gradient"></div>
+                    
                 </div>
             </bx_if:show_cover>
             <div class="bx-base-pofile-cover-info">
@@ -40,7 +40,9 @@
                 </div>
                 __show_data__
             </div>
+            __cover_tweak__
         </div>
     </div>
+    __picture_popup__
 </div>
 __additional_code__

+ 2 - 1
modules/boonex/artificer/data/template/mod_profile/cover.html

@@ -13,7 +13,7 @@
                 <div class="bx-base-pofile-ci-cnt relative flex flex-col -mt-24 lg:-mt-16 lg:flex-row lg:items-center">
                     <bx_if:show_avatar>
                         <div class="bx-base-pofile-cover-thumb bx-def-ava-big-size relative lg:absolute flex self-center lg:flex-none z-10 __add_class__">
-                            <a class="bx-base-pofile-cover-thumb hover:no-underline" href="__picture_href__">
+                            <a class="bx-base-pofile-cover-thumb hover:no-underline" href="__picture_href__" onclick="$('#__picture_popup_id__').dolPopupImage('__picture_url__', $(this).parent()); event.stopPropagation();">
                                 <img class="bx-base-pofile-unit-thumb bx-def-ava-big bx-def-ava-big-size rounded-full ring-4 mx-auto ring-white dark:ring-gray-900 h-48 w-48 __img_class__ bx-image-edit-source-__unique_id__" src="__ava_url__"  <bx_if:show_ava_letter> style="display:none" </bx_if:show_ava_letter> />
                                 <p class="bx-base-pofile-unit-thumb bx-def-ava-big bx-def-ava-big-size flex items-center justify-center box-border m-0 rounded-full ring-4 mx-auto ring-white dark:ring-gray-900 h-48 w-48 text-white font-bold text-5xl __img_class__-placeholder" style="background-color:rgba(__color__);<bx_if:show_ava_image>display:none</bx_if:show_ava_image>" >__letter__</p>
                             </a>
@@ -40,5 +40,6 @@
         </div>
         <div class="bx-def-page-width mx-auto pt-5 px-4 sm:px-6 lg:px-8 border-b border-gray-200 dark:border-gray-800 box-border"></div>
     </div>
+    __picture_popup__
 </div>
 __additional_code__

+ 4 - 2
modules/boonex/artificer/data/template/mod_profile/cover_block.html

@@ -4,8 +4,8 @@
             <bx_if:show_cover>
                 <div class="bx-base-pofile-cover-image-wrp relative overflow-hidden">
                     <div class="bx-base-pofile-cover-image relative h-64 lg:h-40 max-w-7xl mx-auto opacity-100 bg-gradient-to-b from-blue-400 to-blue-500 rounded-t-md __add_class__">
-                        <a class="bx-base-pofile-cover-image box-border absolute h-full w-full" href="__cover_href__" onclick="$('#__cover_popup_id__').dolPopupImage('__cover_url__', this)">
-                            <img class="bx-base-pofile-cover-image h-64 mx-auto w-full object-cover bg-cover lg:h-40 rounded-t-md z-10 __img_class__" style="background-image:url(__cover_url__)" src="<bx_icon_url:spacer.gif />" />
+                        <a class="bx-base-pofile-cover-image box-border absolute h-full w-full" href="__cover_href__" >
+                            <img class="bx-base-pofile-cover-image h-64 mx-auto w-full object-cover bg-cover lg:h-40 rounded-t-md z-10 __img_class__ bx-image-edit-source-__unique_id__" style="background-image:url(__cover_url__);__cover_settins__" src="<bx_icon_url:spacer.gif />" />
                         </a>
                     </div>
                 </div>
@@ -48,7 +48,9 @@
                 </div>
                 __show_data__
             </div>
+            __cover_tweak__
         </div>
     </div>
+    __picture_popup__
 </div>
 __additional_code__

+ 3 - 1
modules/boonex/artificer/data/template/system/css/cover.css

@@ -14,12 +14,14 @@ import url(../../../../../../../template/css/cover.css);
 .dark .bx-cover-wrapper {
     background-image: url(../images/cover-default-dark.svg);
 }
-
 .bx-image-edit-buttons{
     position: absolute;
     left:1rem;
     top:1rem;
 }
+.bx-image-edit-buttons .bx-btn.bx-btn-small{
+    padding: 0.375rem 0.5rem;
+}
 .bx-base-pofile-cover-thumb .bx-image-edit-buttons{
     display: flex;
     width: 100%;

+ 1 - 0
modules/boonex/decorous/data/template/bx_organizations/cover.html

@@ -33,4 +33,5 @@
         __cover_tweak__
         </div>
     </div>
+    __picture_popup__
 </div>

+ 1 - 0
modules/boonex/decorous/data/template/bx_persons/cover.html

@@ -35,4 +35,5 @@
             __cover_tweak__
         </div>
     </div>
+    __picture_popup__
 </div>

+ 1 - 1
modules/boonex/files/template/files_browser_toolbar.html

@@ -58,7 +58,7 @@
         </bx_repeat:bulk_actions>
     </div>
 </div>
-<div class="hidden uploader_progress bx-def-padding-top">
+<div class="hidden uploader_progress bx-def-padding-sec-leftright" style="width: 100%">
     <div class="w-full bg-gray-200 rounded-full h-1 dark:bg-gray-700">
         <div class="bg-blue-600 h-1 rounded-full progress_line" style="width: 0%"></div>
     </div>

+ 3 - 0
template/css/cover.css

@@ -24,6 +24,9 @@
     left:1rem;
     top:1rem;
 }
+.bx-image-edit-buttons .bx-btn.bx-btn-small{
+    padding: 0.375rem 0.5rem;
+}
 .bx-base-pofile-cover-thumb .bx-image-edit-buttons{
     display: flex;
     width: 100%;