replace some item_photo_menu links so we can call js functions

This commit is contained in:
rabuzarus 2016-04-17 00:55:43 +02:00
parent c3225a1631
commit d9e2562f4b
4 changed files with 43 additions and 24 deletions

View file

@ -269,6 +269,25 @@ function loadModalTitle() {
}
}
function addToModal(url) {
var url = url + '?mode=modal';
var modal = $('#modal').modal();
modal
.find('#modal-body')
.load(url, function (responseText, textStatus) {
if ( textStatus === 'success' ||
textStatus === 'notmodified')
{
modal.show();
//Get first h3 element and use it as title
loadModalTitle();
}
});
};
function editpost(url) {
var modal = $('#jot-modal').modal();
var url = url + " #profile-jot-form";

View file

@ -240,10 +240,6 @@
<script>
// Note this is the same script like in wall_thread.tpl
$(document).ready(function() {
// replace data target for poke & private Message to make Modal Dialog possible
$('li a[href^="poke/?f"]').attr('rel','modal');
$('li a[href^="message/new"]').attr('rel','modal');
// put shared content in an own wrapper div
$('#wall-item-content-{{$item.id}} > #wall-item-body-{{$item.id}} > .shared_content').after('<div class="shared-content-wrapper content-card"></div>');
$("#wall-item-content-{{$item.id}} > #wall-item-body-{{$item.id}} > .shared_header, #wall-item-content-{{$item.id}} > #wall-item-body-{{$item.id}} > .shared_content").appendTo("#wall-item-content-{{$item.id}} .shared-content-wrapper");

View file

@ -414,30 +414,10 @@ as the value of $top_child_total (this is done at the end of this file)
</div><!--./comment-container-->
{{/if}}
{{* The Modals - They have to be in this file to call remote content
@todo: Move them somerhere else - we don't want this in every new message
*}}
<div class="modal" id="MailModal" tabindex="-1" role="dialog" aria-labelledby="MailModal" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
</div> <!-- /.modal-content -->
</div> <!-- /.modal-dialog -->
</div> <!-- /.modal -->
<div class="modal" id="PokeModal" tabindex="-1" role="dialog" aria-labelledby="PokeModal" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
</div> <!-- /.modal-content -->
</div> <!-- /.modal-dialog -->
</div> <!-- /.modal -->
<script>
// Note: this is the same script like in search_item.tpl
$(document).ready(function() {
// replace data target for poke & private Message to make Modal Dialog possible
$('li a[href^="poke/?f"]').attr('rel','modal');
$('li a[href^="message/new"]').attr('rel','modal');
// put shared content in an own wrapper div
$('#wall-item-content-{{$item.id}} > #wall-item-body-{{$item.id}} > .shared_content').after('<div class="shared-content-wrapper content-card"></div>');
$("#wall-item-content-{{$item.id}} > #wall-item-body-{{$item.id}} > .shared_header, #wall-item-content-{{$item.id}} > #wall-item-body-{{$item.id}} > .shared_content").appendTo("#wall-item-content-{{$item.id}} .shared-content-wrapper");

View file

@ -31,12 +31,14 @@ function frio_init(&$a) {
function frio_install() {
register_hook('prepare_body_final', 'view/theme/frio/theme.php', 'frio_item_photo_links');
register_hook('item_photo_menu', 'view/theme/frio/theme.php', 'frio_item_photo_menu');
logger("installed theme frio");
}
function frio_uninstall() {
unregister_hook('prepare_body_final', 'view/theme/frio/theme.php', 'frio_item_photo_links');
unregister_hook('item_photo_menu', 'view/theme/frio/theme.php', 'frio_item_photo_menu');
logger("uninstalled theme frio");
}
@ -80,3 +82,25 @@ function frio_item_photo_links(&$a, &$body_info) {
$p = bb_find_open_close($body_info['html'], "<a", ">", $occurence);
}
}
/**
* @brief Replace links of the item_photo_menu
*
* This function replaces the original poke and the message links
* to call the addToModal javascript function so this pages can
* be loaded in a bootstrap modal
*
* @param app $a The app data
* @param array $arr Contains item data and the original photo_menu
*/
function frio_item_photo_menu($a, &$arr){
foreach($arr["menu"] as $k =>$v) {
if(strpos($v,'poke/?f=&c=') === 0 || strpos($v,'message/new/') === 0) {
$v = "javascript:addToModal('" . $v . "'); return false;";
$arr["menu"][$k] = $v;
$testvariable = $testvariable+1;
}
}
$args = array('item' => $item, 'menu' => $menu);
}