MyBB Codes

Full Version: There is anything like this?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
When someone gets a new PM one popup will display a message with the ok button them another popup will be displayed with a "To open in another window click ok. Click cancel to open in another tab but in the same window".

There is anything like this?
(12-10-2009 06:19 PM)Light33 Wrote: [ -> ]When someone gets a new PM one popup will display a message with the ok button them another popup will be displayed with a "To open in another window click ok. Click cancel to open in another tab but in the same window".

There is anything like this?

Try this. Go to the Ungrouped templates and choose the headerinclude. Put the following code all the way to the top, before anything else. I will have to go now but let me know how it will go.

<script type="text/javascript">
<!--
// script to show new private message popup

if (confirm("You have {$mybb->user['pms_unread']} unread private messages.\n\nFrom: {$pm['fromusername']}\nTitle: {$pm['subject']}"))
{
    // Output when OK is clicked
    if (confirm("Open message in a new window?"))
    {
        var winobj = window.open("{$mybb->settings['bburl']}/private.php?action=read&pmid={$pm['pmid']}", "pmnew", "statusbar=yes,menubar=yes,scrollbars=yes,toolbar=yes,location=yes,directories=ye​s,resizable=yes,top=50,left=50");
        if (winobj == null)
        {
            if(confirm("Could not open a new window. Open PM in current window instead?"))
            {
                window.location = "{$mybb->settings['bburl']}/private.php?action=read&pmid={$pm['pmid']}";
            }
        }
    }
    else
    {
        window.location = "{$mybb->settings['bburl']}/private.php?action=read&pmid={$pm['pmid']}";
    }
}

new Ajax.Request('private.php?action=dismiss_notice', {method: 'post', postBody: 'ajax=1&my_post_key='+my_post_key});

// end pm popup script
//-->
</script>
(12-10-2009 06:40 PM)babjusi Wrote: [ -> ][quote='Light33' pid='382' dateline='1260483578']
When someone gets a new PM one popup will display a message with the ok button them another popup will be displayed with a "To open in another window click ok. Click cancel to open in another tab but in the same window".

There is anything like this?

If you want a simple popup check this out:

http://www.forumsecurity.eu/showthread.php?tid=35


Otherwise, try this. Go to the Ungrouped templates and choose the headerinclude. Put the following code all the way to the top, before anything else. I will have to go now but let me know how it will work out for you.

<script type="text/javascript">
<!--
//Show the pm in a pop up way

if (confirm("You have {$mybb->user['pms_unread']} unread private messages.\n\nFrom: {$pm['fromusername']}\nTitle: {$pm['subject']}"))
{
    // Output when OK is clicked
    if (confirm("Open message in a new window?"))
    {
        var winobj = window.open("{$mybb->settings['bburl']}/private.php?action=read&pmid={$pm['pmid']}", "pmnew", "statusbar=yes,menubar=yes,scrollbars=yes,toolbar=yes,location=yes,directories=ye​s,resizable=yes,top=50,left=50");
        if (winobj == null)
        {
            if(confirm("Could not open a new window. Open PM in current window instead?"))
            {
                window.location = "{$mybb->settings['bburl']}/private.php?action=read&pmid={$pm['pmid']}";
            }
        }
    }
    else
    {
        window.location = "{$mybb->settings['bburl']}/private.php?action=read&pmid={$pm['pmid']}";
    }
}

new Ajax.Request('private.php?action=dismiss_notice', {method: 'post', postBody: 'ajax=1&my_post_key='+my_post_key});
//-->
</script>
Didn't work..
My headerinclude template:
<link rel="alternate" type="application/rss+xml" title="{$lang->latest_threads} (RSS 2.0)" href="{$mybb->settings['bburl']}/syndication.php" />
<link rel="alternate" type="application/atom+xml" title="{$lang->latest_threads} (Atom 1.0)" href="{$mybb->settings['bburl']}/syndication.php?type=atom1.0" />
<meta http-equiv="Content-Type" content="text/html; charset={$charset}" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<script type="text/javascript" src="{$mybb->settings['bburl']}/jscripts/prototype.js?ver=1400"></script>
<script type="text/javascript" src="{$mybb->settings['bburl']}/jscripts/general.js?ver=1400"></script>
<script type="text/javascript" src="{$mybb->settings['bburl']}/jscripts/popup_menu.js?ver=1400"></script>
{$stylesheets}<link type="text/css" rel="stylesheet" href="{$mybb->settings['bburl']}/css/regbar.css" />
<script type="text/javascript">
<!--
    var cookieDomain = "{$mybb->settings['cookiedomain']}";
    var cookiePath = "{$mybb->settings['cookiepath']}";
    var cookiePrefix = "{$mybb->settings['cookieprefix']}";
    var deleteevent_confirm = "{$lang->deleteevent_confirm}";
    var removeattach_confirm = "{$lang->removeattach_confirm}";
    var loading_text = '{$lang->ajax_loading}';
    var saving_changes = '{$lang->saving_changes}';
    var use_xmlhttprequest = "{$mybb->settings['use_xmlhttprequest']}";
    var my_post_key = "{$mybb->post_code}";
    var imagepath = "{$theme['imgdir']}";
// -->
</script>
<script type="text/javascript">
<!--
//Show the pm in a pop up way
if (confirm("You have {$mybb->user['pms_unread']} unread private
messages.\n\nFrom: {$pm['fromusername']}\nTitle: {$pm['subject']}"))
{
// Output when OK is clicked
if (confirm("Open message in a new window?"))
{
var winobj =
window.open("{$mybb->settings['bburl']}/private.php?action=read&pmid={$pm['pmid']}",
"pmnew",
"statusbar=yes,menubar=yes,scrollbars=yes,toolbar=yes,location=yes,directories=ye​
​s,resizable=yes,top=50,left=50");
if (winobj == null)
{
if(confirm("Could not open a new window. Open PM in current window instead?"))
{
window.location = "{$mybb->settings['bburl']}/private.php?action=read&pmid={$pm['pmid']}";
}
}
}
else
{
window.location = "{$mybb->settings['bburl']}/private.php?action=read&pmid={$pm['pmid']}";
}
}
new Ajax.Request('private.php?action=dismiss_notice', {method: 'post', postBody: 'ajax=1&my_post_key='+my_post_key});
//-->
</script>

                            
<script type="text/javascript" src="jscripts/thx.js?ver=1400"></script>
{$newpmmsg}
<script type="text/javascript">
function selectCode(a)
{
   var e = a.parentNode.parentNode.getElementsByTagName('CODE')[0];
   if (window.getSelection)
   {
      var s = window.getSelection();
       if (s.setBaseAndExtent)
      {
         s.setBaseAndExtent(e, 0, e, e.innerText.length - 1);
      }
      else
      {
         var r = document.createRange();
         r.selectNodeContents(e);
         s.removeAllRanges();
         s.addRange(r);
      }
   }
   else if (document.getSelection)
   {
      var s = document.getSelection();
      var r = document.createRange();
      r.selectNodeContents(e);
      s.removeAllRanges();
      s.addRange(r);
   }
   else if (document.selection)
   {
      var r = document.body.createTextRange();
      r.moveToElementText(e);
      r.select();
   }
}
</script>
It works cos I have tested it. Replace all your header include with this code.

<script type="text/javascript">
<!--
//Show the pm in a pop up way

if (confirm("You have {$mybb->user['pms_unread']} unread private messages.\n\nFrom: {$pm['fromusername']}\nTitle: {$pm['subject']}"))
{
    // Output when OK is clicked
    if (confirm("Open message in a new window?"))
    {
        var winobj = window.open("{$mybb->settings['bburl']}/private.php?action=read&pmid={$pm['pmid']}", "pmnew", "statusbar=yes,menubar=yes,scrollbars=yes,toolbar=yes,location=yes,directories=ye​ ​s,resizable=yes,top=50,left=50");
        if (winobj == null)
        {
            if(confirm("Could not open a new window. Open PM in current window instead?"))
            {
                window.location = "{$mybb->settings['bburl']}/private.php?action=read&pmid={$pm['pmid']}";
            }
        }
    }
    else
    {
        window.location = "{$mybb->settings['bburl']}/private.php?action=read&pmid={$pm['pmid']}";
    }
}

new Ajax.Request('private.php?action=dismiss_notice', {method: 'post', postBody: 'ajax=1&my_post_key='+my_post_key});
//-->
</script>
<link rel="alternate" type="application/rss+xml" title="{$lang->latest_threads} (RSS 2.0)" href="{$mybb->settings['bburl']}/syndication.php" />
<link rel="alternate" type="application/atom+xml" title="{$lang->latest_threads} (Atom 1.0)" href="{$mybb->settings['bburl']}/syndication.php?type=atom1.0" />
<meta http-equiv="Content-Type" content="text/html; charset={$charset}" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<script type="text/javascript" src="{$mybb->settings['bburl']}/jscripts/prototype.js?ver=1400"></script>
<script type="text/javascript" src="{$mybb->settings['bburl']}/jscripts/general.js?ver=1400"></script>
<script type="text/javascript" src="{$mybb->settings['bburl']}/jscripts/popup_menu.js?ver=1400"></script>
{$stylesheets}<link type="text/css" rel="stylesheet" href="{$mybb->settings['bburl']}/css/regbar.css" />
<script type="text/javascript">
<!--
    var cookieDomain = "{$mybb->settings['cookiedomain']}";
    var cookiePath = "{$mybb->settings['cookiepath']}";
    var cookiePrefix = "{$mybb->settings['cookieprefix']}";
    var deleteevent_confirm = "{$lang->deleteevent_confirm}";
    var removeattach_confirm = "{$lang->removeattach_confirm}";
    var loading_text = '{$lang->ajax_loading}';
    var saving_changes = '{$lang->saving_changes}';
    var use_xmlhttprequest = "{$mybb->settings['use_xmlhttprequest']}";
    var my_post_key = "{$mybb->post_code}";
    var imagepath = "{$theme['imgdir']}";
// -->
</script>
<script type="text/javascript">
<!--
//Show the pm in a pop up way
if (confirm("You have {$mybb->user['pms_unread']} unread private
messages.\n\nFrom: {$pm['fromusername']}\nTitle: {$pm['subject']}"))
{
// Output when OK is clicked
if (confirm("Open message in a new window?"))
{
var winobj =
window.open("{$mybb->settings['bburl']}/private.php?action=read&pmid={$pm['pmid']}",
"pmnew",
"statusbar=yes,menubar=yes,scrollbars=yes,toolbar=yes,location=yes,directories=ye​​
​s,resizable=yes,top=50,left=50");
if (winobj == null)
{
if(confirm("Could not open a new window. Open PM in current window instead?"))
{
window.location = "{$mybb->settings['bburl']}/private.php?action=read&pmid={$pm['pmid']}";
}
}
}
else
{
window.location = "{$mybb->settings['bburl']}/private.php?action=read&pmid={$pm['pmid']}";
}
}
new Ajax.Request('private.php?action=dismiss_notice', {method: 'post', postBody: 'ajax=1&my_post_key='+my_post_key});
//-->
</script>

                            
<script type="text/javascript" src="jscripts/thx.js?ver=1400"></script>
{$newpmmsg}
<script type="text/javascript">
function selectCode(a)
{
   var e = a.parentNode.parentNode.getElementsByTagName('CODE')[0];
   if (window.getSelection)
   {
      var s = window.getSelection();
       if (s.setBaseAndExtent)
      {
         s.setBaseAndExtent(e, 0, e, e.innerText.length - 1);
      }
      else
      {
         var r = document.createRange();
         r.selectNodeContents(e);
         s.removeAllRanges();
         s.addRange(r);
      }
   }
   else if (document.getSelection)
   {
      var s = document.getSelection();
      var r = document.createRange();
      r.selectNodeContents(e);
      s.removeAllRanges();
      s.addRange(r);
   }
   else if (document.selection)
   {
      var r = document.body.createTextRange();
      r.moveToElementText(e);
      r.select();
   }
}
</script>
It works well here. I have this at my Smf forum and I wanted to have it for my Mybb forum. You saved me some time with this request Big Grin
Ohh.. I didn't put the script in the top of all codes!
Thank you.
Glad to have been of help, enjoy it Smile
I have added the code to the TOP but now always when I enter in the forum I get a popup... And I don't have PM to be displayed in the popup...
I get this message all the time I enter in the forums.
(12-11-2009 04:01 PM)Light33 Wrote: [ -> ]I have added the code to the TOP but now always when I enter in the forum I get a popup... And I don't have PM to be displayed in the popup...
I get this message all the time I enter in the forums.

Sorry about that. I meant it at the global_pm_alert template. The pm is not displayed in the template only the notification that you have a new pm along with the title and where to read it, in a new window or not. Just like you asked at your topic.
Pages: 1 2
Reference URL's