{"version":3,"sources":["llms-view-manager.js"],"names":["$","window","llms","ViewManager","currentNonce","currentView","this","set_nonce","nonce","set_view","view","update_links","each","$link","split","attr","qs","length","i","pair","view_nonce","param","jQuery"],"mappings":"CAWA,SAAYA,GAEXC,OAAOC,KAAOD,OAAOC,MAAQ,GA2E7BD,OAAOC,KAAKC,YAAc,IAzER,WAEjB,IACCC,EADGC,EAAc,OAUlBC,KAAKC,UAAY,SAAUC,GAE1B,OADAJ,EAAeI,EACRF,MAURA,KAAKG,SAAW,SAAUC,GAEzB,OADAL,EAAcK,EACPJ,MAWRA,KAAKK,aAAe,WAEd,SAAWN,GAAiBD,GAIpBJ,EAAG,gMAETY,KAAM,WAEZ,IAAIC,EAAQb,EAAGM,MAEdQ,EADQD,EAAME,KAAM,QACPD,MAAO,KACpBE,EAAQ,GAEW,EAAfF,EAAMG,QAEVjB,EAAEY,KAAME,EAAM,GAAGA,MAAO,KAAO,SAAUI,EAAGC,GAC3CA,EAAgBA,EAAKL,MAAO,KAC5BE,EAAIG,EAAK,IAAOA,EAAK,KAKvBH,EAAG,gBAAkBX,EACrBW,EAAGI,WAAkBhB,EAErBS,EAAME,KAAM,OAAQD,EAAM,GAAK,IAAMd,EAAEqB,MAAOL,QApElD,CA+EKM","file":"../../js/llms-view-manager.min.js","sourcesContent":["/**\n * JS events for the view manager\n *\n * @package LifterLMS/Scripts\n *\n * @since 3.8.0\n * @since 4.2.0 Added access plans action button selector to the list of links to update.\n *\n * @version 4.2.0\n */\n\n( function( $, undefined ) {\n\n\twindow.llms = window.llms || {};\n\n\tvar ViewManager = function() {\n\n\t\tvar currentView = 'self',\n\t\t\tcurrentNonce;\n\n\t\t/**\n\t\t * Set the current Nonce\n\t\t *\n\t\t * @param string nonce a nonce\n\t\t * @since 3.8.0\n\t\t * @version 3.8.0\n\t\t */\n\t\tthis.set_nonce = function( nonce ) {\n\t\t\tcurrentNonce = nonce;\n\t\t\treturn this;\n\t\t}\n\n\t\t/**\n\t\t * Set the current view\n\t\t *\n\t\t * @param string view a view option\n\t\t * @since 3.8.0\n\t\t * @version 3.8.0\n\t\t */\n\t\tthis.set_view = function( view ) {\n\t\t\tcurrentView = view;\n\t\t\treturn this;\n\t\t}\n\n\t\t/**\n\t\t * Update various links on the page for easy navigation when using views.\n\t\t *\n\t\t * @since 3.8.0\n\t\t * @since 4.2.0 Added access plans action button selector to the list of links to update.\n\t\t *\n\t\t * @return void\n\t\t */\n\t\tthis.update_links = function() {\n\n\t\t\tif ( 'self' === currentView || ! currentNonce ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tvar $links = $( '.llms-widget-syllabus .llms-lesson a, .llms-course-progress a, .llms-lesson-preview a.llms-lesson-link, .llms-parent-course-link a.llms-lesson-link, .llms-access-plans a.llms-button-action' );\n\n\t\t\t$links.each( function() {\n\n\t\t\t\tvar $link = $( this ),\n\t\t\t\t\thref = $link.attr( 'href' ),\n\t\t\t\t\tsplit = href.split( '?' ),\n\t\t\t\t\tqs = {};\n\n\t\t\t\tif ( split.length > 1 ) {\n\n\t\t\t\t\t$.each( split[1].split( '&' ), function( i, pair ) {\n\t\t\t\t\t\tpair = pair.split( '=' );\n\t\t\t\t\t\tqs[ pair[0] ] = pair[1];\n\t\t\t\t\t} );\n\n\t\t\t\t}\n\n\t\t\t\tqs['llms-view-as'] = currentView;\n\t\t\t\tqs.view_nonce = currentNonce;\n\n\t\t\t\t$link.attr( 'href', split[0] + '?' + $.param( qs ) );\n\n\t\t\t} );\n\n\t\t}\n\n\t};\n\n\t// initialize the object\n\twindow.llms.ViewManager = new ViewManager();\n\n} )( jQuery );\n"],"sourceRoot":"../../js"}