llms-admin.min.js.map 12.6 KB
Newer Older
cyrille's avatar
cyrille committed
1
{"version":3,"sources":["llms-admin.js"],"names":["$","window","llms","widgets","this","$widgets","$info_toggles","init","bind","on","evt","closest","toggleClass","type","fn","llmsPostsSelect2","options","self","defaults","multiple","placeholder","undefined","LLMS","l10n","translate","post_type","attr","post_statuses","instructor_id","allow_clear","width","each","setting","extend","llmsSelect2","allowClear","ajax","dataType","delay","method","url","ajaxurl","data","params","action","page","term","_ajax_nonce","ajax_nonce","processResults","results","map_data","items","Array","isArray","map","item","text","name","id","label","children","pagination","more","cache","llmsStudentsSelect2","enrolled_in","not_enrolled_in","roles","email","emailConnectors","registerClient","fields","form","document","createElement","setAttribute","key","val","value","input","appendChild","body","submit","remoteInstall","$btn","callback","parent","find","remove","post","fail","jqxhr","Spinner","stop","msg","responseJSON","message","responseText","replace","%s","insertAfter","jQuery"],"mappings":"CASC,SAAYA,GAEZC,OAAOC,KAAOD,OAAOC,MAAQ,GAE7BD,OAAOC,KAAKC,QAAU,WAqBrB,OAnBAC,KAAKC,SAAgBL,EAAG,gBACxBI,KAAKE,cAAgBN,EAAG,4BAExBI,KAAKG,KAAO,WACXH,KAAKI,QAGNJ,KAAKI,KAAO,WAEXJ,KAAKE,cAAcG,GAAI,wBAAyB,SAAUC,GACzDV,EAAEI,MAAMO,QAAS,gBACfC,YAAa,eAAgB,eAAiBF,EAAIG,SAMtDT,KAAKG,OAEEH,MAIW,IAAIH,OAAOC,KAAKC,QAcnCH,EAAEc,GAAGC,iBAAmB,SAAUC,GAEjC,IAAIC,EAAOb,KAEVc,GADAF,EAAUA,GAAW,GACV,CACVG,UAAU,EACVC,iBAAaC,IAAcC,KAAKC,KAAOD,KAAKC,KAAKC,UAAW,8BAAiC,6BAC7FC,UAAWR,EAAKS,KAAM,mBAAsB,OAC5CC,cAAeV,EAAKS,KAAM,uBAA0B,UACpDE,cAAe,KACfC,YAAaZ,EAAKS,KAAM,oBAAsB,EAC9CI,MAAO,OAGT9B,EA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SAASQ,KAAKD,YAAaR,GAC3BA,EAAKU,UAgBNC,cAAe,SAAUC,EAAM3C,EAAM4C,GAEpCD,EAAKE,SAASC,KAAM,eAAgBC,SACpCzF,EAAE0F,KAAMjD,QAASC,EAAM4C,GAAWK,KAAM,SAAUC,GACjDtE,KAAKuE,QAAQC,KAAMT,GACnB,IAAIU,EAAMH,EAAMI,cAAgBJ,EAAMI,aAAaC,QAAUL,EAAMI,aAAaC,QAAUL,EAAMM,aAC3FH,GACJ/F,EAAG,yBAA2BsB,KAAKC,KAAK4E,QAAS,YAAa,CAAEC,KAAML,IAAU,QAASM,YAAahB,OArR1G,CA6RIiB","file":"../../js/llms-admin.min.js","sourcesContent":["/**\n * LifterLMS Admin Panel Javascript\n *\n * @since Unknown\n * @version 4.5.1\n *\n * @param obj $ Traditional jQuery reference.\n * @return void\n */\n;( function( $ ) {\n\n\twindow.llms = window.llms || {};\n\n\twindow.llms.widgets = function() {\n\n\t\tthis.$widgets      = $( '.llms-widget' );\n\t\tthis.$info_toggles = $( '.llms-widget-info-toggle' );\n\n\t\tthis.init = function() {\n\t\t\tthis.bind();\n\t\t};\n\n\t\tthis.bind = function() {\n\n\t\t\tthis.$info_toggles.on( 'mouseenter mouseleave', function( evt ) {\n\t\t\t\t$(this).closest( '.llms-widget' )\n\t\t\t\t\t.toggleClass( 'info-showing', 'mouseenter' === evt.type );\n\t\t\t} );\n\n\t\t};\n\n\t\t// Go.\n\t\tthis.init();\n\n\t\treturn this;\n\n\t};\n\n\tvar llms_widgets = new window.llms.widgets();\n\n\t/**\n\t * Simple jQuery plugin to transform select elements into Select2-powered elements to query for Courses/Memberships via AJAX.\n\t *\n\t * @since 3.19.4\n\t * @since 3.32.0 Added ability to fetch posts based on their post status.\n\t * @since 3.37.2 Added ability to fetch posts (llms posts) filtered by their instructor id.\n\t * @since 4.4.0 Update ajax nonce source.\n\t *\n\t * @param obj options Options passed to Select2.\n\t *                    Each default option will pulled from the elements data-attributes.\n\t * @return void\n\t */\n\t$.fn.llmsPostsSelect2 = function( options ) {\n\n\t\tvar self = this,\n\t\t\toptions = options || {},\n\t\t\tdefaults = {\n\t\t\t\tmultiple: false,\n\t\t\t\tplaceholder: undefined !== LLMS.l10n ? LLMS.l10n.translate( 'Select a Course/Membership' ) : 'Select a Course/Membership',\n\t\t\t\tpost_type: self.attr( 'data-post-type' ) || 'post',\n\t\t\t\tpost_statuses: self.attr( 'data-post-statuses' ) || 'publish',\n\t\t\t\tinstructor_id: null,\n\t\t\t\tallow_clear: self.attr( 'data-post-type' ) || false,\n\t\t\t\twidth: null,\n\t\t\t};\n\n\t\t$.each( defaults, function( setting ) {\n\t\t\tif ( self.attr( 'data-' + setting ) ) {\n\t\t\t\toptions[ setting ] = self.attr( 'data-' + setting );\n\t\t\t}\n\t\t} );\n\n\t\tif ( 'multiple' === self.attr( 'multiple' ) ) {\n\t\t\toptions.multiple = true;\n\t\t}\n\n\t\toptions = $.extend( defaults, options );\n\n\t\tthis.llmsSelect2( {\n\t\t\tallowClear: options.allow_clear,\n\t\t\tajax: {\n\t\t\t\tdataType: 'JSON',\n\t\t\t\tdelay: 250,\n\t\t\t\tmethod: 'POST',\n\t\t\t\turl: window.ajaxurl,\n\t\t\t\tdata: function( params ) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\taction: 'select2_query_posts',\n\t\t\t\t\t\tpage: ( params.page ) ? params.page - 1 : 0, // 0 index the pages to make it simpler for the database query\n\t\t\t\t\t\tpost_type: options.post_type,\n\t\t\t\t\t\tinstructor_id : options.instructor_id,\n\t\t\t\t\t\tpost_statuses: options.post_statuses,\n\t\t\t\t\t\tterm: params.term,\n\t\t\t\t\t\t_ajax_nonce: window.llms.ajax_nonce,\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t\tprocessResults: function( data, params ) {\n\n\t\t\t\t\t// recursive function for creating\n\t\t\t\t\tfunction map_data( items ) {\n\n\t\t\t\t\t\t// this is a flat array of results\n\t\t\t\t\t\t// used when only one post type is selected\n\t\t\t\t\t\t// and to format children when using optgroups with multiple post types\n\t\t\t\t\t\tif ( Array.isArray( items ) ) {\n\t\t\t\t\t\t\treturn $.map( items, function( item ) {\n\t\t\t\t\t\t\t\treturn format_item( item );\n\t\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t\t// this sets up the top level optgroups when using multiple post types\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\treturn $.map( items, function( item ) {\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\ttext: item.label,\n\t\t\t\t\t\t\t\t\tchildren: map_data( item.items ),\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// format a single result (option)\n\t\t\t\t\tfunction format_item( item ) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\ttext: item.name,\n\t\t\t\t\t\t\tid: item.id,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tresults: map_data( data.items ),\n\t\t\t\t\t\tpagination: {\n\t\t\t\t\t\t\tmore: data.more\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\n\t\t\t\t},\n\t\t\t},\n\t\t\tcache: true,\n\t\t\tplaceholder: options.placeholder,\n\t\t\tmultiple: options.multiple,\n\t\t\twidth: options.width,\n\t\t} );\n\n\t};\n\n\t// automatically setup any select with the `llms-posts-select2` class\n\t$( 'select.llms-posts-select2' ).llmsPostsSelect2();\n\n\t/**\n\t * Simple jQuery plugin to transform select elements into Select2-powered elements to query for Students via AJAX\n\t *\n\t * @since Unknown\n\t * @since 3.17.5 Unknown.\n\t * @since 4.4.0 Update ajax nonce source.\n\t *\n\t * @param obj options Options passed to Select2. Each default option will be pulled from the elements data-attributes.\n\t * @return void\n\t */\n\t$.fn.llmsStudentsSelect2 = function( options ) {\n\n\t\tvar self = this,\n\t\t\toptions = options || {},\n\t\t\tdefaults = {\n\t\t\t\tallow_clear: false,\n\t\t\t\tenrolled_in: '',\n\t\t\t\tmultiple: false,\n\t\t\t\tnot_enrolled_in: '',\n\t\t\t\tplaceholder: undefined !== LLMS.l10n ? LLMS.l10n.translate( 'Select a student' ) : 'Select a student',\n\t\t\t\troles: '',\n\t\t\t\twidth: '100%',\n\t\t\t};\n\n\t\t$.each( defaults, function( setting ) {\n\t\t\tif ( self.attr( 'data-' + setting ) ) {\n\t\t\t\toptions[ setting ] = self.attr( 'data-' + setting );\n\t\t\t}\n\t\t} );\n\n\t\toptions = $.extend( defaults, options );\n\n\t\tthis.llmsSelect2({\n\t\t\tallowClear: options.allow_clear,\n\t\t\tajax: {\n\t\t\t\tdataType: 'JSON',\n\t\t\t\tdelay: 250,\n\t\t\t\tmethod: 'POST',\n\t\t\t\turl: window.ajaxurl,\n\t\t\t\tdata: function( params ) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t_ajax_nonce: window.llms.ajax_nonce,\n\t\t\t\t\t\taction: 'query_students',\n\t\t\t\t\t\tpage: params.page,\n\t\t\t\t\t\tnot_enrolled_in: params.not_enrolled_in || options.not_enrolled_in,\n\t\t\t\t\t\tenrolled_in: params.enrolled_in || options.enrolled_in,\n\t\t\t\t\t\troles: params.roles || options.roles,\n\t\t\t\t\t\tterm: params.term,\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t\tprocessResults: function( data, params ) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tresults: $.map( data.items, function( item ) {\n\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\ttext: item.name + ' <' + item.email +'>',\n\t\t\t\t\t\t\t\tid: item.id,\n\t\t\t\t\t\t\t};\n\n\t\t\t\t\t\t} ),\n\t\t\t\t\t\tpagination: {\n\t\t\t\t\t\t\tmore: data.more\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\n\t\t\t\t},\n\t\t\t},\n\t\t\tcache: true,\n\t\t\tplaceholder: options.placeholder,\n\t\t\tmultiple: options.multiple,\n\t\t\twidth: options.width,\n\t\t});\n\n\t\treturn this;\n\n\t};\n\n\t/**\n\t * Scripts for use on the engagements settings tab for email provider connector plugins\n\t *\n\t * @since 3.40.0\n\t */\n\twindow.llms.emailConnectors = {\n\n\t\t/**\n\t\t * Register a client\n\t\t *\n\t\t * Builds and submits a form used to direct the user to the connector's oAuth\n\t\t * authorization endpoint.\n\t\t *\n\t\t * @since 3.40.0\n\t\t *\n\t\t * @param {String} url    Redirect URL.\n\t\t * @param {Object} fields Hash of fields where the key is the field name and the value if the field value.\n\t\t * @return {Void}\n\t\t */\n\t\tregisterClient: function( url, fields ) {\n\n\t\t\tvar form = document.createElement( 'form' );\n\t\t\tform.setAttribute( 'method', 'POST' );\n\t\t\tform.setAttribute( 'action', url );\n\n\t\t\tfunction appendInput( name, value ) {\n\t\t\t\tvar input = document.createElement( 'input' );\n\t\t\t\tinput.setAttribute( 'type', 'hidden' );\n\t\t\t\tinput.setAttribute( 'name', name );\n\t\t\t\tinput.setAttribute( 'value', value );\n\t\t\t\tform.appendChild( input );\n\t\t\t}\n\n\t\t\t$.each( fields, function( key, val ) {\n\t\t\t\tappendInput( key, val );\n\t\t\t} );\n\n\t\t\tdocument.body.appendChild( form );\n\t\t\tform.submit();\n\n\t\t},\n\n\t\t/**\n\t\t * Performs an AJAX request to perform remote installation of the connector plugin\n\t\t *\n\t\t * The callback will more than likely use `registerClient()` on success.\n\t\t *\n\t\t * @since 3.40.0\n\t\t *\n\t\t * @param {Object}   $btn     jQuery object for the connector button.\n\t\t * @param {Object}   data     Hash of data used for the ajax request.\n\t\t * @param {Function} callback Success callback function.\n\t\t * @return {Void}\n\t\t */\n\t\tremoteInstall: function( $btn, data, callback ) {\n\n\t\t\t$btn.parent().find( '.llms-error' ).remove();\n\t\t\t$.post( ajaxurl, data, callback ).fail( function( jqxhr ) {\n\t\t\t\tLLMS.Spinner.stop( $btn );\n\t\t\t\tvar msg = jqxhr.responseJSON && jqxhr.responseJSON.message ? jqxhr.responseJSON.message : jqxhr.responseText;\n\t\t\t\tif ( msg ) {\n\t\t\t\t\t$( '<p class=\"llms-error\">' + LLMS.l10n.replace( 'Error: %s', { '%s': msg } ) + '</p>' ).insertAfter( $btn );\n\t\t\t\t}\n\t\t\t} );\n\n\t\t}\n\n\t};\n\n} )( jQuery );\n"],"sourceRoot":"../../js"}