-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Enh: Support
[data-contentcontainer-guid]
e.g. in mentionings
- Enh: Refactored Js as HumHub module - Fix: Force close on pjax load
- Loading branch information
buddh4
committed
Oct 17, 2019
1 parent
fbf43d9
commit 417e789
Showing
8 changed files
with
153 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
"keywords": [ | ||
"" | ||
], | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"humhub": { | ||
"minVersion": "1.3.0" | ||
}, | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
/* | ||
* @link https://www.humhub.org/ | ||
* @copyright Copyright (c) 2018 HumHub GmbH & Co. KG | ||
* @license https://www.humhub.com/licences | ||
*/ | ||
|
||
|
||
humhub.module('vcard.popover', function (module, require, $) { | ||
|
||
var additions = require('ui.additions'); | ||
var client = require('client'); | ||
|
||
var vCardDelayTimer; | ||
|
||
|
||
module.initOnPjaxLoad = true; | ||
|
||
function init(pjax) { | ||
$('.vcardPopover').remove(); | ||
|
||
if (pjax) { | ||
return; | ||
} | ||
|
||
$(document).on('mouseenter', '[data-contentcontainer-id],[data-contentcontainer-guid]', function () { | ||
var trigger = this; | ||
var selector = '#' + getVCardId(trigger); | ||
clearTimeout(vCardDelayTimer); | ||
vCardDelayTimer = setTimeout(function () { | ||
if (!$(selector).length) { | ||
createPopover(trigger) | ||
} else { | ||
showPopOver(trigger, $(selector).html()); | ||
} | ||
}, module.config.delay); | ||
}); | ||
|
||
$(document).on('mouseleave', '[data-contentcontainer-id],[data-contentcontainer-guid]', function () { | ||
clearTimeout(vCardDelayTimer); | ||
|
||
var $this = $(this); | ||
setTimeout(function () { | ||
if (!$('.popover:hover').length) { | ||
$this.popover('hide'); | ||
} | ||
}, 300); | ||
}); | ||
} | ||
|
||
function getVCardId(trigger) { | ||
var contentContainerId = $(trigger).data('contentcontainer-id'); | ||
var contentContainerGuid = $(trigger).data('contentcontainer-guid'); | ||
return 'vCard' + (contentContainerId || contentContainerGuid); | ||
} | ||
|
||
function createPopover(trigger) { | ||
var $trigger = $(trigger); | ||
var vCardId = getVCardId(trigger); | ||
var contentContainerId = $trigger.data('contentcontainer-id'); | ||
var contentContainerGuid = $trigger.data('contentcontainer-guid'); | ||
|
||
|
||
$("body").append('<div id="' + vCardId + '" class="hidden"></div>'); | ||
|
||
var data = { | ||
guid: contentContainerGuid, | ||
id: contentContainerId | ||
}; | ||
|
||
client.post(module.config.loadUrl, {data: data}).then(function (response) { | ||
if (response.html) { | ||
$("#" + vCardId).html(response.html); | ||
showPopOver(trigger, response.html); | ||
} | ||
}).catch(function (e) { | ||
module.log.error(e); | ||
}); | ||
} | ||
|
||
function showPopOver(trigger, content) { | ||
var $trigger = $(trigger); | ||
var $content = $(content); | ||
|
||
var $popover = $trigger.popover({ | ||
trigger: 'manual', | ||
html: true, | ||
placement: 'auto left', | ||
container: 'body', | ||
content: content, | ||
animation: true | ||
}).data('bs.popover').tip().addClass('vcardPopover'); | ||
|
||
$trigger.popover('show'); | ||
|
||
// Popover seems to get rid of inline styles, so we replace the content | ||
$popover.find('.vcardContent').replaceWith($content.find('.vcardContent')); | ||
|
||
// Make sure the image itself is not a popover target | ||
$popover.find('[data-contentcontainer-id]').removeAttr('data-contentcontainer-id'); | ||
|
||
$('.vcardPopover').one('mouseleave', function () { | ||
$trigger.popover('hide'); | ||
}); | ||
} | ||
|
||
module.export({ | ||
init: init | ||
}); | ||
|
||
}); | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters