Description
Comments
' + tagLabel + '
' + html; return html; } function fetchAllComments() { fetchComments( id, true ); } function fetchComments( id, showAllParams ) { var info = joms.jQuery('.joms-js--photo-info'), comments = joms.jQuery('.joms-js--photo-comment'); joms.ajax({ func: 'photos,ajaxSwitchPhotoTrigger', data: [ id, showAllParams ? 1 : 0 ], callback: function( json ) { var $info, $tags; if ( !showAllParams ) { if ( json.comments && json.showall ) { json.showall = ''; json.comments = joms.jQuery( joms.jQuery.trim( json.comments ) ); json.comments.prepend( json.showall ); } } if ( showAllParams ) { comments.find('.joms-comment').replaceWith( json.comments ); } else { $info = joms.jQuery( joms.jQuery.trim( json.head || '' ) ); $info.filter('.joms-stream__header').css( 'padding', 0 ); info.html( $info ); comments.html( json.comments ).append( json.form || '' ); comments.find('textarea.joms-textarea'); joms.fn.tagging.initInputbox(); // Render description. joms.jQuery('.joms-js--photodesc').html( renderDescription( json.description || {} ) ); // Cache tag info. tags = json.tagged || []; tagLabel = json.tagLabel || ''; tagRemoveLabel = json.tagRemoveLabel || ''; // Render tag info. $tags = joms.jQuery('.joms-js--photo-tag-ct'); $tags.html( _tagBuildHtml() ); } var $mobile = comments.siblings('.joms-stream__status--mobile'); $mobile.find('a').attr( 'onclick', 'joms.api.streamShowComments(\'' + id + '\', \'photos\')'); $mobile.find('span').html( json.comments_count || '0' ) .attr( 'class', 'joms-comment__counter--' + id ); like = ''; if ( json && json.like ) { like += ''; } joms.jQuery('.joms-js--btn-like').replaceWith( like ); initVideoPlayers(); } }); } function setAsCover() { joms.api.photoSetCover( album, id ); } function setAsProfilePicture() { joms.api.photoSetAvatar( id ); } function initVideoPlayers() { var initialized = '.joms-js--initialized', cssVideos = '.joms-js--video', videos = joms.jQuery('.joms-comment__body,.joms-js--inbox').find( cssVideos ).not( initialized ).addClass( initialized.substr(1) ); if ( !videos.length ) { return; } joms.loadCSS( joms.ASSETS_URL + 'vendors/mediaelement/mediaelementplayer.min.css' ); videos.on( 'click.joms-video', cssVideos + '-play', function() { var $el = joms.jQuery( this ).closest( cssVideos ); joms.util.video.play( $el, $el.data() ); }); if ( joms.ios ) { setTimeout(function() { videos.find( cssVideos + '-play' ).click(); }, 2000 ); } } function stripTags( html ) { html = html.replace( /]+>/g, '' ); return html; } function renderDescription( json ) { if ( typeof json !== 'object' ) { json = {}; } return [ '
', ( json.content || '' ), '
', '
', '', '
', ' ', '', '
', '
', '' ].join(''); } function br2nl( text ) { text = text || ''; text = text.replace( /
/g, '\n' ); return text; } function editDescription() { joms.jQuery('.joms-js--btn-desc-content').hide(); joms.jQuery('.joms-js--btn-desc-edit').hide(); joms.jQuery('.joms-js--btn-desc-editor').show(); } function cancelDescription() { joms.jQuery('.joms-js--btn-desc-editor').hide(); joms.jQuery('.joms-js--btn-desc-content').show(); joms.jQuery('.joms-js--btn-desc-edit').show(); } function saveDescription() { var content = joms.jQuery('.joms-js--btn-desc-content'), editor = joms.jQuery('.joms-js--btn-desc-editor'), button = joms.jQuery('.joms-js--btn-desc-edit'), textarea = editor.find('textarea'), value = joms.jQuery.trim( textarea.val() ); joms.ajax({ func: 'photos,ajaxSaveCaption', data: [ id, value ], callback: function( json ) { var a = button.find('a'); if ( json.error ) { window.alert( json.error ); return; } if ( json.success ) { editor.hide(); content.html( json.caption ).show(); a.html( a.data( 'lang-' + ( value ? 'edit' : 'add' ) ) ); button.show(); } } }); } // Trigger ini on ready. w.joms_queue || (w.joms_queue = []); w.joms_queue.push(function() { var timer = setInterval(function() { if ( joms.ajax ) { clearInterval( timer ); init(); } }, 200 ); }); w.joms_delete_photo = function() { if ( list && list[ index ] ) { joms.api.photoRemove( list[ index ].id ); } }; w.joms_set_as_profile_picture = function() { setAsProfilePicture(); }; w.joms_set_as_album_cover = function() { setAsCover(); }; w.joms_download_photo = function() { if ( list && list[ index ] ) { window.open( list[ index ].original ); } }; })( window );