nodebb-plugin-cards
Advanced tools
Comparing version 0.3.1 to 0.4.0
{ | ||
"name": "nodebb-plugin-cards", | ||
"version": "0.3.1", | ||
"version": "0.4.0", | ||
"description": "NodeBB plugin that extends the mentions plugin with hover cards", | ||
@@ -26,4 +26,4 @@ "main": "library.js", | ||
"nbbpm": { | ||
"compatibility": "^1.19.0" | ||
"compatibility": "^3.0.0" | ||
} | ||
} |
@@ -11,4 +11,4 @@ { | ||
}, | ||
"less": [ | ||
"public/less/style.less" | ||
"scss": [ | ||
"public/scss/style.scss" | ||
], | ||
@@ -15,0 +15,0 @@ "scripts": [ |
@@ -6,7 +6,6 @@ "use strict"; | ||
(function(window) { | ||
var delay, targetCard, currentCard, destroyDelay, | ||
var delay, targetCard, currentCard, | ||
events = 'mouseenter.card mouseleave.card', | ||
exitEvent = 'click.card', | ||
selector = 'a[href*="/user/"]:not(.profile-card a)', | ||
exitSelector = 'body:not(".profile-card")', | ||
regex = /(\/user\/([^/]+))(?:\/$|$)/; | ||
@@ -41,3 +40,3 @@ | ||
if (target.children('img')) { | ||
target.children('img').tooltip('destroy'); | ||
target.children('img').tooltip('dispose'); | ||
} | ||
@@ -50,15 +49,2 @@ | ||
} else { | ||
// Otherwise add some handlers for destroying a card | ||
if (target.is(currentCard)) { | ||
destroyDelay = destroyCard(target); | ||
target.data('bs.popover')['$tip'].off(events).on(events, function(e) { | ||
if (e.type === "mouseenter") { | ||
clearTimeout(destroyDelay); | ||
} else { | ||
destroyDelay = destroyCard(target); | ||
} | ||
}); | ||
} | ||
// Also clear the timeout for creating a new card | ||
@@ -83,3 +69,2 @@ clearTimeout(delay); | ||
}); | ||
return false; | ||
} | ||
@@ -98,3 +83,3 @@ | ||
if (currentCard) { | ||
destroyCard(currentCard); | ||
destroyCard(currentCard, true); | ||
} | ||
@@ -104,12 +89,14 @@ | ||
cardHTML.find('[component="account/chat"]').on('click', function() { | ||
socket.emit('modules.chats.hasPrivateChat', result.uid, function(err, roomId) { | ||
socket.emit('modules.chats.hasPrivateChat', result.uid, async function (err, roomId) { | ||
if (err) { | ||
return app.alertError(err.message); | ||
} | ||
const chat = await app.require('chat'); | ||
if (roomId) { | ||
app.openChat(roomId); | ||
chat.openChat(roomId); | ||
} else { | ||
app.newChat(result.uid); | ||
chat.newChat(result.uid); | ||
} | ||
}); | ||
return false; | ||
}); | ||
@@ -119,5 +106,7 @@ // Bind follow and unfollow | ||
toggleFollow(cardHTML, 'follow', result.uid, result.username); | ||
return false; | ||
}); | ||
cardHTML.find('[component="account/unfollow"]').on('click', function(){ | ||
toggleFollow(cardHTML, 'unfollow', result.uid, result.username); | ||
return false; | ||
}); | ||
@@ -132,7 +121,7 @@ | ||
container: 'body' | ||
}).popover('show').data('bs.popover')['$tip'].css('z-index', 1000000); | ||
}).popover('show'); | ||
// Bind some other stuff | ||
$('.profile-card .timeago').timeago(); | ||
$('.card-fab button').dropdown(); | ||
utils.makeNumbersHumanReadable($('.profile-card .human-readable-number')); | ||
@@ -143,3 +132,3 @@ | ||
if (currentCard) { | ||
destroyCard(currentCard); | ||
destroyCard(currentCard, true); | ||
} | ||
@@ -164,7 +153,7 @@ }); | ||
if (instantly) { | ||
target.popover('destroy'); | ||
target.popover('dispose'); | ||
currentCard = null; | ||
} else { | ||
return setTimeout(function() { | ||
target.popover('destroy'); | ||
target.popover('dispose'); | ||
currentCard = null; | ||
@@ -171,0 +160,0 @@ }, 500); |
Sorry, the diff of this file is not supported yet
14237
172