{"version":3,"file":"../../js/llms-sl-profile.min.js","sources":["llms-sl-profile.js"],"sourcesContent":["/**\n * Student Profile JS\n *\n * @package LifterLMS_Social_Learning/Scripts\n *\n * @since 1.0.0\n * @version 1.1.0\n */\n\n( function( $ ){\n\t/**\n\t * UI & UX for Student Profiles\n\t *\n\t * @since 1.0.0\n\t * @since 1.1.0 Unknown.\n\t */\n\tvar Profile = function() {\n\n\t\tvar $modal = $( '#llms-sl-upload-modal' );\n\n\t\t/**\n\t\t * Bind DOM events\n\t\t *\n\t\t * @since 1.0.0\n\t\t * @since 1.1.0 Unknown.\n\t\t *\n\t\t * @return void\n\t\t */\n\t\tfunction bind() {\n\n\t\t\t$modal.iziModal();\n\n\t\t\t$( '#llms-sl-upload-cover' ).on( 'click', function( e ) {\n\t\t\t\t$modal.iziModal( 'open' );\n\t\t\t\t$( '#llms-sl-uploader-zone' ).attr( 'data-upload-type', 'cover' );\n\t\t\t\t$( '#llms-sl-upload-type' ).val( 'cover' );\n\t\t\t} );\n\n\t\t\t$( '#llms-sl-upload-avatar' ).on( 'click', function( e ) {\n\t\t\t\t$modal.iziModal( 'open' );\n\t\t\t\t$( '#llms-sl-uploader-zone' ).attr( 'data-upload-type', 'avatar' );\n\t\t\t\t$( '#llms-sl-upload-type' ).val( 'avatar' );\n\t\t\t} );\n\n\t\t\twindow.ondragover = function( e ) {\n\t\t\t\te.preventDefault();\n\t\t\t};\n\n\t\t\twindow.ondrop = onDrop;\n\n\t\t\t$( '#llms-sl-uploader-zone' ).on( 'dragover', function() {\n\t\t\t\t$( this ).addClass( 'dragover' );\n\t\t\t} ).on( 'dragout', function() {\n\t\t\t\t$( this ).removeClass( 'dragover' );\n\t\t\t} );\n\n\t\t\t$( '#llms-sl-upload-image' ).on( 'change', onUploadChange );\n\n\t\t};\n\n\t\t/**\n\t\t * Handle drop events to allow dragging images into uploader\n\t\t *\n\t\t * @since 1.0.0\n\t\t *\n\t\t * @param obj e JS Event object.\n\t\t * @return void\n\t\t */\n\t\tfunction onDrop( e ) {\n\n\t\t\te.preventDefault();\n\n\t\t\tvar $target = $( e.target );\n\n\t\t\tif ( ! $target.closest( '.llms-sl-uploader' ).length ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tupload( e.dataTransfer.files[0] );\n\n\t\t};\n\n\t\t/**\n\t\t * Handle upload when files are added to the file uploader\n\t\t *\n\t\t * @since 1.0.0\n\t\t *\n\t\t * @param obj e JS Event object.\n\t\t * @return void\n\t\t */\n\t\tfunction onUploadChange( e ) {\n\n\t\t\tupload( e.target.files[0] );\n\n\t\t};\n\n\t\t/**\n\t\t * Upload files via AJAX\n\t\t *\n\t\t * @since 1.0.0\n\t\t * @since 1.1.0 Unknown.\n\t\t *\n\t\t * @param obj file JS file transfer object.\n\t\t * @return void\n\t\t */\n\t\tfunction upload( file ) {\n\n\t\t\tvar $wrap = $( '#llms-sl-uploader-zone' ),\n\t\t\ttype = $( '#llms-sl-upload-type' ).val(),\n\t\t\tdata = new FormData();\n\t\t\tdata.append( 'action', 'llms_sl_upload_image' );\n\t\t\tdata.append( 'image', file );\n\t\t\tdata.append( 'nonce', $( '#llms-sl-upload-nonce' ).val() );\n\t\t\tdata.append( 'type', type );\n\n\t\t\tLLMS.Ajax.call( {\n\t\t\t\tdata: data,\n\t\t\t\tcontentType: false,\n\t\t\t\tprocessData: false,\n\t\t\t\tbeforeSend: function() {\n\n\t\t\t\t\t$wrap.find( '.llms-sl-error' ).remove();\n\t\t\t\t\tLLMS.Spinner.start( $wrap );\n\n\t\t\t\t},\n\t\t\t\terror: function( xhr, status, error ) {\n\n\t\t\t\t\tvar msg = '';\n\n\t\t\t\t\tif ( 'object' === typeof error && error.message ) {\n\t\t\t\t\t\tmsg = error.message;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tmsg = error;\n\t\t\t\t\t}\n\t\t\t\t\tshow_error( msg, status, error );\n\t\t\t\t\tLLMS.Spinner.stop( $wrap );\n\n\t\t\t\t},\n\t\t\t\tsuccess: function( r ) {\n\n\t\t\t\t\tLLMS.Spinner.stop( $wrap );\n\t\t\t\t\tif ( r && r.success ) {\n\t\t\t\t\t\tif ( 'avatar' === type ) {\n\t\t\t\t\t\t\t$( '#llms-avatar-img' ).html( r.data.image );\n\t\t\t\t\t\t} else if ( 'cover' === type ) {\n\t\t\t\t\t\t\t$( '#llms-cover-img' ).html( r.data.image );\n\t\t\t\t\t\t}\n\t\t\t\t\t\t$modal.iziModal( 'close' );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tshow_error( r.message, 'error', r );\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t} );\n\n\t\t};\n\n\t\t/**\n\t\t * Show an uploader error message\n\t\t *\n\t\t * @since 1.1.0\n\t\t * @since 1.1.0 Unknown.\n\t\t *\n\t\t * @param string msg Error message string.\n\t\t * @param string status Error status string.\n\t\t * @param obj data Additional data to log to the console.\n\t\t * @return void\n\t\t */\n\t\tfunction show_error( msg, status, data ) {\n\n\t\t\tconsole.error( status, data );\n\n\t\t\tmsg = LLMS.l10n.translate( 'Error' ) + ': ' + msg;\n\n\t\t\t$( '#llms-sl-uploader-zone' ).append( '<p class=\"llms-sl-error\">' + msg + '</p>' );\n\n\t\t};\n\n\t\t// Go.\n\t\tbind();\n\n\t\treturn {\n\n\t\t\tupload: upload,\n\n\t\t};\n\n\t};\n\n\twindow.llms_sl = window.llms_sl || {};\n\twindow.llms_sl.profile = new Profile();\n\n} )( jQuery );\n"],"names":["$","window","llms_sl","profile","$modal","onDrop","e","preventDefault","target","closest","length","upload","dataTransfer","files","onUploadChange","file","$wrap","type","val","data","FormData","append","LLMS","Ajax","call","contentType","processData","beforeSend","find","remove","Spinner","start","error","xhr","status","show_error","message","stop","success","r","html","image","iziModal","msg","console","l10n","translate","on","attr","ondragover","ondrop","this","addClass","removeClass","jQuery"],"mappings":"CASA,SAAYA,GAqLXC,OAAOC,QAAkBD,OAAOC,SAAW,GAC3CD,OAAOC,QAAQC,QAAU,IA/KX,WAEb,IAAI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