]> git.mxchange.org Git - friendica.git/commitdiff
replace pm & poke links in contact_photo_menu and use js for modal instead
authorrabuzarus <>
Wed, 20 Apr 2016 17:32:19 +0000 (19:32 +0200)
committerrabuzarus <>
Wed, 20 Apr 2016 17:32:19 +0000 (19:32 +0200)
templates/contact_template.tpl
templates/contacts-template.tpl
theme.php

index 21241d0ab022fc12ca509f5d176a21b049d01ff5..31d7971ac3b018eb81d9af0decb390a428df8625 100644 (file)
@@ -22,6 +22,8 @@
                                        {{foreach $contact.photo_menu as $c}}
                                        {{if $c.2}}
                                        <li role="menuitem"><a target="redir" href="{{$c.1}}">{{$c.0}}</a></li>
+                                       {{elseif $c.3}}
+                                       <li role="menuitem"><a onclick="addToModal('{{$c.1}}')">{{$c.0}}</a></li>
                                        {{else}}
                                        <li role="menuitem"><a href="{{$c.1}}">{{$c.0}}</a></li>
                                        {{/if}}
index e33855b6d54f20af65c334049f54a35f3e1ed43b..9c5b0498c4fd320c26711c44e9f290bf758a1d53 100644 (file)
@@ -74,8 +74,8 @@ this needs to be removed and do it with js *}}
 <script>
  $(document).ready(function() {
   // replace data target for poke & private Message to make Modal Dialog possible
-  $('li a[href^="{{$baseurl}}/poke/?f"]').attr('data-target','#PokeModal').attr('data-toggle', 'modal');
-  $('li a[href^="{{$baseurl}}/message/new"]').attr('data-target','#MailModal').attr('data-toggle', 'modal');
+//  $('li a[href^="{{$baseurl}}/poke/?f"]').attr('data-target','#PokeModal').attr('data-toggle', 'modal');
+//  $('li a[href^="{{$baseurl}}/message/new"]').attr('data-target','#MailModal').attr('data-toggle', 'modal');
  
   // javascript dialog to batch actions
   $(".batch-action").click(function(e){
index 2fed9fdfa3addccaaefc9feb1707abc859836dbd..6094b84f70a0019af0a735e950ca4af66969dab7 100644 (file)
--- a/theme.php
+++ b/theme.php
@@ -32,6 +32,7 @@ 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');
+       register_hook('contact_photo_menu', 'view/theme/frio/theme.php', 'frio_contact_photo_menu');
        register_hook('nav_info', 'view/theme/frio/theme.php', 'frio_remote_nav');
 
        logger("installed theme frio");
@@ -40,6 +41,7 @@ function frio_install() {
 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');
+       unregister_hook('nav_info', 'view/theme/frio/theme.php', 'frio_remote_nav');
 
        logger("uninstalled theme frio");
 }
@@ -100,12 +102,43 @@ function frio_item_photo_menu($a, &$arr){
                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);
 }
 
+/**
+ * @brief Replace links of the contact_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 $args Contains contact data and the original photo_menu
+ */
+function frio_contact_photo_menu($a, &$args){
+
+       $pokelink = "";
+       $pmlink = "";
+       $cid = "";
+
+       $cid = $args["contact"]["id"];
+       $pokelink = $args["menu"]["poke"][1];
+       $pmlink = $args["menu"]["pm"][1];
+
+       // Add to pm and poke links a new key with the value 'modal'.
+       // Later we can make conditions in the corresponing templates (e.g.
+       // contact_template.tpl)
+       if(strpos($pokelink,'poke/?f=&c='. $cid) !== false)
+               $args["menu"]["poke"][3] = "modal";
+
+       if(strpos($pmlink,'message/new/' . $cid) !== false)
+               $args["menu"]["pm"][3] = "modal";
+
+       $args = array('contact' => $contact, 'menu' => &$menu);
+}
+
 /**
  * @brief Construct remote nav menu
  *