{"version":3,"file":"../../js/llms-sl-share.min.js","sources":["llms-sl-share.js"],"sourcesContent":["/**\n * Student Sharing JS\n *\n * @package LifterLMS_Social_Learning/Scripts\n *\n * @since 1.0.0\n * @version 1.3.0\n */\n\n( function( $ ){\n\n\t/**\n\t * Story-related interactions\n\t *\n\t * @since 1.0.0\n\t */\n\tvar StoryInteractions = function() {\n\n\t\t/**\n\t\t * Clear an error message\n\t\t *\n\t\t * @since 1.0.0\n\t\t *\n\t\t * @param {object} $error The jQuery element for an error message to clean.\n\t\t * @return {void}\n\t\t */\n\t\tfunction clear_error( $error ) {\n\t\t\t$error.html( '' );\n\t\t}\n\n\t\t/**\n\t\t * Initiliaze LLMS Donuts on stories\n\t\t *\n\t\t * @since 1.0.0\n\t\t *\n\t\t * @return {void}\n\t\t */\n\t\tfunction donuts() {\n\n\t\t\t$( '.llms-sl-card--story-pass .llms-donut' ).each( function() {\n\t\t\t\tLLMS.Donut( $( this ) );\n\t\t\t} );\n\n\t\t}\n\n\t\t/**\n\t\t * Move the cursor to the end of an contenteditable element\n\t\t *\n\t\t * @since 1.1.0\n\t\t *\n\t\t * @param {object} $el The jQuery element of a contenteditable node.\n\t\t * @return {void}\n\t\t */\n\t\tfunction focus_end( $el ) {\n\n\t\t\tvar el = $el[0];\n\n\t\t\tel.focus();\n\n\t\t\tif ( typeof window.getSelection !== 'undefined' && typeof document.createRange !== 'undefined' ) {\n\n\t\t\t\tvar range = document.createRange();\n\t\t\t\trange.selectNodeContents( el );\n\t\t\t\trange.collapse( false );\n\n\t\t\t\tvar sel = window.getSelection();\n\t\t\t\tsel.removeAllRanges();\n\t\t\t\tsel.addRange( range );\n\n\t\t\t} else if (typeof document.body.createTextRange != \"undefined\") {\n\n\t\t\t\tvar textRange = document.body.createTextRange();\n\t\t\t\ttextRange.moveToElementText( el );\n\t\t\t\ttextRange.collapse( false );\n\t\t\t\ttextRange.select();\n\n\t\t\t}\n\n\t\t}\n\n\t\t/**\n\t\t * Show an error message\n\t\t *\n\t\t * @since 1.0.0\n\t\t *\n\t\t * @param {object} $error The jQuery element for an error message to show.\n\t\t * @param {string} msg    Error message text/string.\n\t\t * @return {void}\n\t\t */\n\t\tfunction show_error( $error, msg ) {\n\t\t\t$error.html( LLMS.l10n.translate( 'Error' ) + ': ' + msg );\n\t\t};\n\n\t\t/**\n\t\t * General method for posting story related data to the server via ajax\n\t\t *\n\t\t * Automatically starts a spinner on a parent element.\n\t\t *\n\t\t * @since 1.0.0\n\t\t *\n\t\t * @param {object}   data    Data to post to the server.\n\t\t * @param {object}   $parent The jQuery element for the parent node.\n\t\t * @param {function} cb      Callback function.\n\t\t * @param {string}   size    Optional spinner size (small).\n\t\t * @return {void}\n\t\t */\n\t\tfunction post( data, $parent, cb, size ) {\n\n\t\t\tLLMS.Ajax.call( {\n\t\t\t\tdata: data,\n\t\t\t\tbeforeSend: function() {\n\n\t\t\t\t\tLLMS.Spinner.start( $parent, size );\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\n\t\t\t\t\tcb( {\n\t\t\t\t\t\tmessage: msg,\n\t\t\t\t\t\tsuccess: false,\n\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\tstatus: status,\n\t\t\t\t\t\t\terror: error,\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\n\t\t\t\t\tconsole.error( status, error );\n\n\t\t\t\t\tLLMS.Spinner.stop( $parent );\n\n\t\t\t\t},\n\n\t\t\t\tsuccess: function( r ) {\n\n\t\t\t\t\tLLMS.Spinner.stop( $parent );\n\t\t\t\t\tcb( r );\n\n\t\t\t\t}\n\n\t\t\t} );\n\n\t\t};\n\n\t\t/**\n\t\t * Remove paragraphs from a content editable element\n\t\t *\n\t\t * @since 1.0.0\n\t\t *\n\t\t * @param {object} $html The jQuery element for the node to remove <p>s from.\n\t\t * @return {string}\n\t\t */\n\t\tfunction unautop( $html ) {\n\n\t\t\t$html.find( 'p' ).each( function() {\n\t\t\t\t$( this ).replaceWith( $( this ).text() + \"\\r\\n\" );\n\t\t\t} );\n\n\t\t\treturn $html;\n\n\t\t};\n\n\t\t/**\n\t\t * Handle filtering via select element on instructor's filter card.\n\t\t *\n\t\t * @since 1.1.0\n\t\t */\n\t\tvar Filtering = function() {\n\n\t\t\t/**\n\t\t\t * Bind dom events\n\t\t\t *\n\t\t\t * @since 1.1.0\n\t\t\t *\n\t\t\t * @return {void}\n\t\t\t */\n\t\t\tfunction bind() {\n\n\t\t\t\t$el.llmsSelect2( {\n\t\t\t\t\tajax: {\n\t\t\t\t\t\tdataType: 'JSON',\n\t\t\t\t\t\tdelay: 250,\n\t\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\t\turl: window.llms.ajaxurl,\n\t\t\t\t\t\tdata: function( params ) {\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\taction: 'llms_sl_filter_posts',\n\t\t\t\t\t\t\t\tterm: params.term,\n\t\t\t\t\t\t\t\tpage: params.page,\n\t\t\t\t\t\t\t\t_ajax_nonce: wp_ajax_data.nonce,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t},\n\t\t\t\t\t\terror: function( xhr, status, error ) {\n\t\t\t\t\t\t\tconsole.log( status, error );\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tdropdownParent: $( '#llms-sl-card--timeline-filters-instructor' ),\n\t\t\t\t\tplaceholder: LLMS.l10n.translate( 'Search by title...' ),\n\t\t\t\t\twidth: '100%',\n\t\t\t\t} ).on( 'select2:select', function( e ) {\n\n\t\t\t\t\twindow.location = e.params.data.url;\n\n\t\t\t\t} );\n\n\t\t\t};\n\n\t\t\tvar $el = $( '#llms-sl-instructor-filter-post' );\n\n\t\t\tif ( $el.length ) {\n\n\t\t\t\t// Bind dom events.\n\t\t\t\tbind();\n\n\t\t\t}\n\n\t\t};\n\n\t\t/**\n\t\t * User interactions for managing (editing and deleting) existing stories\n\t\t *\n\t\t * @since 1.0.0\n\t\t * @since 1.2.1 Unknown.\n\t\t */\n\t\tvar Managing = function() {\n\n\t\t\tvar\tcached_html;\n\n\t\t\t/**\n\t\t\t * Bind DOM events\n\t\t\t *\n\t\t\t * @since 1.0.0\n\t\t\t * @since 1.2.1 Unknown.\n\t\t\t * @since 1.3.0 Changed parent's selector from `'.llms-sl-timeline-main'` to `'.llms-sl-timeline'`\n\t\t\t *              so to target cards in profile's tab content too.\n\t\t\t *\n\t\t\t * @return {void}\n\t\t\t */\n\t\t\tfunction bind() {\n\n\t\t\t\t$parent = $( '.llms-sl-timeline-main, .llms-sl-profile-main' );\n\n\t\t\t\t// Prevent click events from hashing to the top.\n\t\t\t\t$parent.on( 'click', '.llms-sl-card-action.llms-sl-has-context-menu.manage-card', function( e ) {\n\t\t\t\t\te.preventDefault();\n\t\t\t\t} );\n\n\t\t\t\t// Make the story editable.\n\t\t\t\t$parent.on( 'click', '.llms-sl-card--story .llms-sl-context-menu a.edit-story', function( e ) {\n\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\tvar $btn = $( this ),\n\t\t\t\t\t$story   = $btn.closest( '.llms-sl-card--story' ),\n\t\t\t\t\t$main    = $story.find( '.llms-sl-card-main' ),\n\t\t\t\t\t$text    = $main.find( '.llms-sl-card-text' );\n\n\t\t\t\t\tif ( cached_html.$el && cached_html.html ) {\n\n\t\t\t\t\t\tcached_html.$el.find( 'button.llms-sl-edit-story-cancel' ).trigger( 'click' );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tset_cached_html( $story, $text.html() );\n\n\t\t\t\t\t$main.find( '.llms-sl-edit-story-actions' ).show();\n\n\t\t\t\t\tvar text = unautop( $text ).text().trim();\n\t\t\t\t\t$text.html( text );\n\n\t\t\t\t\t$text.attr( 'contenteditable', true );\n\n\t\t\t\t\tfocus_end( $text );\n\n\t\t\t\t\t// On keyup enable or disable the save button.\n\t\t\t\t\t$text.on( 'keyup', function( e ) {\n\n\t\t\t\t\t\tvar $save = $main.find( 'button.llms-sl-edit-story-submit' );\n\n\t\t\t\t\t\tif ( $text[0].innerText != text && $text[0].innerText.length ) {\n\t\t\t\t\t\t\t$save.removeAttr( 'disabled' );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t$save.attr( 'disabled', 'disabled' );\n\t\t\t\t\t\t}\n\n\t\t\t\t\t} );\n\n\t\t\t\t} );\n\n\t\t\t\t// Cancel a story edit.\n\t\t\t\t$parent.on( 'click', '.llms-sl-card--story button.llms-sl-edit-story-cancel', function( e ) {\n\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\tvar $btn = $( this ),\n\t\t\t\t\t$story   = $btn.closest( '.llms-sl-card--story' ),\n\t\t\t\t\t$main    = $story.find( '.llms-sl-card-main' ),\n\t\t\t\t\t$text    = $main.find( '.llms-sl-card-text' );\n\n\t\t\t\t\t$main.find( '.llms-sl-edit-story-actions' ).hide();\n\t\t\t\t\t$text.attr( 'contenteditable', false );\n\t\t\t\t\t$text.html( cached_html.html );\n\n\t\t\t\t\tset_cached_html(); // Clear the cache.\n\n\t\t\t\t} );\n\n\t\t\t\t// Save story edits to the database.\n\t\t\t\t$parent.on( 'click', '.llms-sl-card--story button.llms-sl-edit-story-submit', function( e ) {\n\n\t\t\t\t\te.preventDefault();\n\n\t\t\t\t\tvar $btn = $( this ),\n\t\t\t\t\t$story   = $btn.closest( '.llms-sl-card--story' ),\n\t\t\t\t\t$main    = $story.find( '.llms-sl-card-main' ),\n\t\t\t\t\t$text    = $main.find( '.llms-sl-card-text' ),\n\t\t\t\t\t$error   = $main.find( '.llms-sl-card-error' ),\n\t\t\t\t\tstory_id = $story.attr( 'data-story-id' ),\n\t\t\t\t\tdata     = {\n\t\t\t\t\t\taction: 'llms_sl_story_edit',\n\t\t\t\t\t\tstory_id: story_id,\n\t\t\t\t\t\tnonce: $( '#llms-sl-edit-story-nonce-' + story_id ).val(),\n\t\t\t\t\t\tcontent: $text[0].innerText,\n\t\t\t\t\t};\n\n\t\t\t\t\tclear_error( $error );\n\t\t\t\t\tpost( data, $main, function( r ) {\n\n\t\t\t\t\t\tif ( ! r ) {\n\n\t\t\t\t\t\t\tshow_error( $error, LLMS.l10n.translate( 'An unknown error occurred, please try again.' ) );\n\n\t\t\t\t\t\t} else if ( r && ! r.success ) {\n\n\t\t\t\t\t\t\tshow_error( $error, r.message );\n\n\t\t\t\t\t\t} else if ( r.data && r.data.html ) {\n\n\t\t\t\t\t\t\t$main.find( '.llms-sl-edit-story-actions' ).hide();\n\t\t\t\t\t\t\t$text.attr( 'contenteditable', false );\n\t\t\t\t\t\t\t$text.html( r.data.html );\n\t\t\t\t\t\t\tset_cached_html();\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t} );\n\n\t\t\t\t} );\n\n\t\t\t\t// Delete a story.\n\t\t\t\t$parent.on( 'click', '.llms-sl-card--story .llms-sl-context-menu a.delete-story', function( e ) {\n\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\tif ( window.confirm( LLMS.l10n.translate( 'Are you sure you want to delete this story? This action cannot be undone.' ) ) ) {\n\n\t\t\t\t\t\tvar $story = $( this ).closest( '.llms-sl-card--story' ),\n\t\t\t\t\t\tdata       = {\n\t\t\t\t\t\t\taction: 'llms_sl_story_delete',\n\t\t\t\t\t\t\tstory_id: $story.attr( 'data-story-id' ),\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tpost( data, $story, function( r ) {\n\n\t\t\t\t\t\t\tif ( ! r ) {\n\n\t\t\t\t\t\t\t\talert( LLMS.l10n.translate( 'An unknown error occurred, please try again.' ) );\n\n\t\t\t\t\t\t\t} else if ( r && ! r.success ) {\n\n\t\t\t\t\t\t\t\talert( r.message );\n\n\t\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t\t$story.fadeOut( 200 );\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t}\n\n\t\t\t\t} );\n\n\t\t\t};\n\n\t\t\t/**\n\t\t\t * Set the cached html for restoring cancelled edits\n\t\t\t *\n\t\t\t * Use set_cached_html() to clear the cache.\n\t\t\t *\n\t\t\t * @since 1.0.0\n\t\t\t *\n\t\t\t * @param {object} $el  The jQuery element of a story card node.\n\t\t\t * @param {string} html The .html() of the story.\n\t\t\t */\n\t\t\tfunction set_cached_html( $el, html ) {\n\t\t\t\tcached_html = {\n\t\t\t\t\t$el: $el,\n\t\t\t\t\thtml: html,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t// Setup empty cache on init.\n\t\t\tset_cached_html();\n\n\t\t\t// Bind dom events.\n\t\t\tbind();\n\n\t\t};\n\n\t\t/**\n\t\t * Paging related story interactions\n\t\t *\n\t\t * Autoloads stories when scrolling on timelines.\n\t\t *\n\t\t * @since 1.0.0\n\t\t */\n\t\tvar Paging = function() {\n\n\t\t\tvar load_interval = 14,\n\t\t\tnext_load_i       = 0,\n\t\t\tloading           = false,\n\t\t\tnext_offset;\n\n\t\t\t/**\n\t\t\t * Bind dom events\n\t\t\t *\n\t\t\t * @since 1.0.0\n\t\t\t *\n\t\t\t * @return {void}\n\t\t\t */\n\t\t\tfunction bind() {\n\n\t\t\t\tset_next_load_element();\n\n\t\t\t\t$( window ).on( 'scroll', function() {\n\t\t\t\t\tif ( ! loading && $( window ).scrollTop() >= next_offset ) {\n\t\t\t\t\t\t$( '#llms-sl-timeline-load-more' ).trigger( 'click' );\n\t\t\t\t\t}\n\t\t\t\t} );\n\n\t\t\t\t$( '.llms-sl' ).on( 'click', '#llms-sl-timeline-load-more', function() {\n\n\t\t\t\t\tloading = true;\n\n\t\t\t\t\tvar $btn = $( this ),\n\t\t\t\t\tdata     = {\n\t\t\t\t\t\taction: 'llms_sl_timeline_load_more',\n\t\t\t\t\t\targs: JSON.parse( $btn.attr( 'data-args' ) )\n\t\t\t\t\t};\n\n\t\t\t\t\tdata.args.page++;\n\n\t\t\t\t\tpost( data, $btn, function( r ) {\n\n\t\t\t\t\t\tif ( ! r ) {\n\t\t\t\t\t\t\tshow_error( $error, LLMS.l10n.translate( 'An unknown error occurred, please try again.' ) );\n\t\t\t\t\t\t} else if ( r && ! r.success ) {\n\t\t\t\t\t\t\tshow_error( $error, r.message );\n\t\t\t\t\t\t} else if ( r.data && r.data.html ) {\n\n\t\t\t\t\t\t\tloading = false;\n\n\t\t\t\t\t\t\tvar $stories = $( r.data.html ),\n\t\t\t\t\t\t\tr            = new Replying( $stories.find( '.llms-sl-story-reply-comment' ) );\n\n\t\t\t\t\t\t\t$btn.hide();\n\t\t\t\t\t\t\t$btn.parent().append( $stories );\n\t\t\t\t\t\t\tdonuts();\n\t\t\t\t\t\t\t$btn.remove();\n\n\t\t\t\t\t\t\tset_next_load_element();\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}, 'small' );\n\n\t\t\t\t} );\n\n\t\t\t};\n\n\t\t\t/**\n\t\t\t * Setup the next load element\n\t\t\t *\n\t\t\t * @since 1.0.0\n\t\t\t *\n\t\t\t * @return {void}\n\t\t\t */\n\t\t\tfunction set_next_load_element() {\n\n\t\t\t\tnext_load_i = next_load_i + load_interval;\n\n\t\t\t\tvar $el = $( '.llms-sl-timeline .llms-sl-card--story' ).eq( next_load_i );\n\n\t\t\t\tif ( $el.length ) {\n\t\t\t\t\tnext_offset = $el.offset().top;\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tbind();\n\n\t\t};\n\n\t\t/**\n\t\t * Interactions related to posting replies to stories\n\t\t *\n\t\t * @param {object} $fields The jQuery element of a reply field parent node.\n\t\t *\n\t\t * @since 1.0.0\n\t\t */\n\t\tvar Replying = function( $fields ) {\n\n\t\t\tvar $fields = $fields || $( '.llms-sl-story-reply-comment' );\n\n\t\t\t/**\n\t\t\t * Bind DOM events\n\t\t\t *\n\t\t\t * @since 1.0.0\n\t\t\t *\n\t\t\t * @return {void}\n\t\t\t */\n\t\t\tfunction bind() {\n\n\t\t\t\t$fields.each( function() {\n\n\t\t\t\t\tvar $field = $( this );\n\n\t\t\t\t\t$field.on( 'keydown', function( event ) {\n\n\t\t\t\t\t\tvar key = event.which || event.keyCode;\n\n\t\t\t\t\t\tswitch ( key ) {\n\n\t\t\t\t\t\t\tcase 13: // Enter.\n\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\tif ( get_content( $field ) ) {\n\t\t\t\t\t\t\t\t\tshare( $field );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase 27: // Escape.\n\t\t\t\t\t\t\t\tevent.target.blur();\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t} );\n\n\t\t\t\t} );\n\n\t\t\t};\n\n\t\t\t/**\n\t\t\t * Add the HTML for a new reply after it's been saved via AJAX\n\t\t\t *\n\t\t\t * @since 1.0.0\n\t\t\t *\n\t\t\t * @param {object} $card The jQuery element of the story card to add the reply to.\n\t\t\t * @param {string} html  Html of the reply.\n\t\t\t */\n\t\t\tfunction add_reply_html( $card, html ) {\n\n\t\t\t\t$card.find( '.llms-sl-story-replies' ).append( html );\n\n\t\t\t};\n\n\t\t\t/**\n\t\t\t * Retrieve the content of a reply from the reply text field element\n\t\t\t *\n\t\t\t * @since 1.0.0\n\t\t\t *\n\t\t\t * @param {object} $field The jQuery element of the text field node.\n\t\t\t * @return {string}\n\t\t\t */\n\t\t\tfunction get_content( $field ) {\n\t\t\t\treturn $field[0].innerText;\n\t\t\t};\n\n\t\t\t/**\n\t\t\t * Save a story to the DB via ajax\n\t\t\t *\n\t\t\t * @since 1.0.0\n\t\t\t *\n\t\t\t * @param {object} $field The jQuery element of the field.\n\t\t\t * @return {void}\n\t\t\t */\n\t\t\tfunction share( $field ) {\n\n\t\t\t\tvar $parent = $field.closest( '.llms-sl-story-reply' ),\n\t\t\t\t$card       = $field.closest( '.llms-sl-card--story' ),\n\t\t\t\t$error      = $card.find( '.llms-sl-card-footer .llms-sl-card-error' ),\n\t\t\t\tstory_id    = $card.attr( 'data-story-id' );\n\n\t\t\t\tvar data = {\n\t\t\t\t\taction: 'llms_sl_story_reply',\n\t\t\t\t\tstory_id: story_id,\n\t\t\t\t\tnonce: $( '#llms-sl-reply-nonce-' + story_id ).val(),\n\t\t\t\t\tcontent: get_content( $field ),\n\t\t\t\t};\n\n\t\t\t\tclear_error( $error );\n\t\t\t\tpost( data, $parent, function( r ) {\n\n\t\t\t\t\tif ( ! r ) {\n\t\t\t\t\t\tshow_error( $error, LLMS.l10n.translate( 'An unknown error occurred, please try again.' ) );\n\t\t\t\t\t} else if ( r && ! r.success ) {\n\t\t\t\t\t\tshow_error( $error, r.message );\n\t\t\t\t\t} else if ( r.data && r.data.html ) {\n\n\t\t\t\t\t\t$field.text( '' ).blur();\n\t\t\t\t\t\tadd_reply_html( $card, r.data.html );\n\n\t\t\t\t\t}\n\n\t\t\t\t}, 'small' );\n\n\t\t\t};\n\n\t\t\tbind();\n\n\t\t};\n\n\t\t/**\n\t\t * Interactions for sharing a new story\n\t\t *\n\t\t * @since 1.0.0\n\t\t */\n\t\tvar Sharing = function() {\n\n\t\t\tvar $card = $( '#llms-sl-card--new-share' ),\n\t\t\t$btn      = $( '#llms-sl-new-share-submit' ),\n\t\t\t$content  = $( '#llms-sl-new-share-content' ),\n\t\t\t$error    = $card.find( '.llms-sl-card-error' );\n\n\t\t\t/**\n\t\t\t * Bind DOM events\n\t\t\t *\n\t\t\t * @since 1.0.0\n\t\t\t *\n\t\t\t * @return {void}\n\t\t\t */\n\t\t\tfunction bind() {\n\n\t\t\t\t$content.on( 'keyup', function( ) {\n\n\t\t\t\t\tif ( ! get_content() ) {\n\t\t\t\t\t\t$btn.attr( 'disabled', 'disabled' );\n\t\t\t\t\t} else {\n\t\t\t\t\t\t$btn.removeAttr( 'disabled' );\n\t\t\t\t\t}\n\n\t\t\t\t} );\n\n\t\t\t\t$btn.on( 'click', function() {\n\n\t\t\t\t\tif ( ! get_content() ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tshare();\n\n\t\t\t\t} );\n\n\t\t\t};\n\n\t\t\t/**\n\t\t\t * Retrieve the share content\n\t\t\t *\n\t\t\t * @since 1.0.0\n\t\t\t *\n\t\t\t * @return {string}\n\t\t\t */\n\t\t\tfunction get_content() {\n\t\t\t\treturn $content[0].innerText;\n\t\t\t};\n\n\t\t\t/**\n\t\t\t * Share a new story via AJAX\n\t\t\t *\n\t\t\t * @since 1.0.0\n\t\t\t *\n\t\t\t * @return {void}\n\t\t\t */\n\t\t\tfunction share() {\n\n\t\t\t\tvar data = {\n\t\t\t\t\taction: 'llms_sl_new_share',\n\t\t\t\t\tnonce: $( '#llms-sl-new-share-nonce' ).val(),\n\t\t\t\t\tnoun: $( '#llms-sl-new-share-noun' ).val(),\n\t\t\t\t\tcontent: get_content(),\n\t\t\t\t};\n\n\t\t\t\tclear_error( $error );\n\t\t\t\tpost( data, $card, function( r ) {\n\n\t\t\t\t\tif ( ! r ) {\n\t\t\t\t\t\tshow_error( $error, LLMS.l10n.translate( 'An unknown error occurred, please try again.' ) );\n\t\t\t\t\t} else if ( r && ! r.success ) {\n\t\t\t\t\t\tshow_error( $error, r.message );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tLLMS.Spinner.start( $card );\n\t\t\t\t\t\twindow.location.reload();\n\t\t\t\t\t}\n\n\t\t\t\t} );\n\n\t\t\t};\n\n\t\t\tbind();\n\n\t\t};\n\n\t\tvar f = new Filtering(),\n\t\tm     = new Managing(),\n\t\tp     = new Paging(),\n\t\tr     = new Replying(),\n\t\ts     = new Sharing();\n\n\t\tdonuts();\n\n\t};\n\n\tvar a = new StoryInteractions();\n\n} )( jQuery );\n"],"names":["$","$el","length","llmsSelect2","ajax","dataType","delay","method","url","window","llms","ajaxurl","data","params","action","term","page","_ajax_nonce","wp_ajax_data","nonce","error","xhr","status","console","log","dropdownParent","placeholder","LLMS","l10n","translate","width","on","e","location","set_cached_html","$parent","preventDefault","range","textRange","$story","this","closest","$main","find","$text","text","cached_html","html","trigger","show","$html","each","replaceWith","trim","attr","el","focus","getSelection","document","createRange","selectNodeContents","collapse","sel","removeAllRanges","addRange","body","createTextRange","moveToElementText","select","$save","innerText","removeAttr","hide","$error","story_id","val","content","clear_error","post","r","success","show_error","message","confirm","fadeOut","alert","next_load_i","loading","load_interval","set_next_load_element","scrollTop","next_offset","$btn","args","JSON","parse","$stories","Replying","parent","append","donuts","remove","$card","$content","get_content","noun","Spinner","start","reload","Donut","msg","cb","size","Ajax","call","beforeSend","stop","$fields","$field","event","which","keyCode","blur","target","eq","offset","top","jQuery"],"mappings":"CASA,SAAYA,IA6MLC,EAAMD,EAAG,oCAEJE,QA/BRD,EAAIE,YAAa,CAChBC,KAAM,CACLC,SAAU,OACVC,MAAO,IACPC,OAAQ,OACRC,IAAKC,OAAOC,KAAKC,QACjBC,KAAM,SAAUC,GACf,MAAO,CACNC,OAAQ,uBACRC,KAAMF,EAAOE,KACbC,KAAMH,EAAOG,KACbC,YAAaC,aAAaC,QAG5BC,MAAO,SAAUC,EAAKC,EAAQF,GAC7BG,QAAQC,IAAKF,EAAQF,KAGvBK,eAAgBzB,EAAG,8CACnB0B,YAAaC,KAAKC,KAAKC,UAAW,sBAClCC,MAAO,SACJC,GAAI,iBAAkB,SAAUC,GAEnCvB,OAAOwB,SAAWD,EAAEnB,OAAOD,KAAKJ,MAwMlC0B,KAjKCC,QAAUnC,EAAG,kDAGL+B,GAAI,QAAS,4DAA6D,SAAUC,GAC3FA,EAAEI,mBAIHD,QAAQJ,GAAI,QAAS,0DAA2D,SAAUC,GAEzFA,EAAEI,iBACF,IArMGC,EAUAC,EA4LHC,EADWvC,EAAGwC,MACEC,QAAS,wBACzBC,EAAWH,EAAOI,KAAM,sBACxBC,EAAWF,EAAMC,KAAM,sBAYnBE,GAVCC,EAAY7C,KAAO6C,EAAYC,MAEnCD,EAAY7C,IAAI0C,KAAM,oCAAqCK,QAA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