nodebb-plugin-cards
Advanced tools
Comparing version 0.1.3 to 0.1.4
@@ -1,3 +0,1 @@ | ||
var Card = {}; | ||
module.exports = Card; | ||
module.exports = {}; |
{ | ||
"name": "nodebb-plugin-cards", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "NodeBB plugin that extends the mentions plugin with hover cards", | ||
@@ -20,3 +20,3 @@ "main": "library.js", | ||
"author": "Schamper <mrwafflewaffle@aim.com>", | ||
"license": "BSD-2-Clause", | ||
"license": "MIT", | ||
"bugs": { | ||
@@ -27,4 +27,4 @@ "url": "https://github.com/Schamper/nodebb-plugin-cards/issues" | ||
"nbbpm": { | ||
"compatibility": "^0.4.0" | ||
"compatibility": "^0.9.0" | ||
} | ||
} |
@@ -6,6 +6,6 @@ { | ||
"url": "https://github.com/Schamper/nodebb-plugin-cards", | ||
"library": "./library.js", | ||
"library": "library.js", | ||
"hooks": [], | ||
"staticDirs": { | ||
"public": "./public" | ||
"public": "public" | ||
}, | ||
@@ -18,3 +18,3 @@ "less": [ | ||
], | ||
"templates": "./templates" | ||
"templates": "templates" | ||
} |
@@ -0,1 +1,5 @@ | ||
"use strict"; | ||
/* globals app, utils, $ */ | ||
(function(window) { | ||
@@ -5,3 +9,3 @@ var delay, targetCard, currentCard, destroyDelay, | ||
exitEvent = 'click.card', | ||
selector = 'a[href*="/user/"]:not(.profile-card-img-container a)', | ||
selector = 'a[href*="/user/"]:not(.profile-card a)', | ||
exitSelector = 'body:not(".profile-card")', | ||
@@ -18,3 +22,2 @@ regex = /(\/user\/([^/]+))(?:\/$|$)/; | ||
if (href && (!utils.invalidLatinChars.test(href[2]) && !utils.invalidUnicodeChars.test(href[2]))) { | ||
if (target.children('img')) { | ||
@@ -37,2 +40,3 @@ //Destroy tooltips added by NodeBB | ||
}, 500); | ||
target.data('bs.popover')['$tip'].off(events).on(events, function(e) { | ||
@@ -48,2 +52,3 @@ if (e.type === "mouseenter") { | ||
} | ||
//Also clear the timeout for creating a new card | ||
@@ -61,2 +66,3 @@ clearTimeout(delay); | ||
} | ||
//Destroy any cards before ajaxifying | ||
@@ -66,2 +72,3 @@ if (currentCard) { | ||
} | ||
targetCard = null; | ||
@@ -82,43 +89,41 @@ }); | ||
result.name = result.fullname || result.username; | ||
window.templates.parse('cards/profile', result, function(html) { | ||
translator.translate(html, function(translated) { | ||
//If target is not the currentCard and if the target is the targetCard | ||
if (!target.is(currentCard) && target.is(targetCard)) { | ||
//If there's an existing card, destroy it | ||
if (currentCard) { | ||
destroyCard(currentCard); | ||
} | ||
app.parseAndTranslate('cards/profile', result, function(html) { | ||
//If target is not the currentCard and if the target is the targetCard | ||
if (!target.is(currentCard) && target.is(targetCard)) { | ||
//If there's an existing card, destroy it | ||
if (currentCard) { | ||
destroyCard(currentCard); | ||
} | ||
//Create card | ||
target.popover({ | ||
html: true, | ||
content: translated, | ||
placement: 'top', | ||
trigger: 'manual', | ||
container: 'body' | ||
}).popover('show'); | ||
//Create card | ||
target.popover({ | ||
html: true, | ||
content: html, | ||
placement: 'top', | ||
trigger: 'manual', | ||
container: 'body' | ||
}).popover('show'); | ||
$('.profile-card-stats li').tooltip(); | ||
$('.profile-card-stats li').tooltip(); | ||
utils.makeNumbersHumanReadable($('.profile-card-stats li span')); | ||
utils.makeNumbersHumanReadable($('.profile-card-stats li span')); | ||
$('.profile-card-chat').off('click.card').on('click.card', function(e) { | ||
var card = $(e.currentTarget).parents('.profile-card'); | ||
app.openChat(card.data('username'), card.data('uid')); | ||
return false; | ||
}); | ||
$('.profile-card-chat').off('click.card').on('click.card', function(e) { | ||
var card = $(e.currentTarget).parents('.profile-card'); | ||
app.openChat(card.data('username'), card.data('uid')); | ||
return false; | ||
}); | ||
currentCard = target; | ||
currentCard = target; | ||
$('html').off(exitEvent).on(exitEvent, function() { | ||
if (currentCard) { | ||
destroyCard(currentCard); | ||
} | ||
}); | ||
$('html').off(exitEvent).on(exitEvent, function() { | ||
if (currentCard) { | ||
destroyCard(currentCard); | ||
} | ||
}); | ||
$('.profile-card').off(exitEvent).on(exitEvent, function(e) { | ||
e.stopPropagation(); | ||
}); | ||
} | ||
}); | ||
$('.profile-card').off(exitEvent).on(exitEvent, function(e) { | ||
e.stopPropagation(); | ||
}); | ||
} | ||
}); | ||
@@ -125,0 +130,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
8837
10
129