habAlert

Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Web Developer Markshall is offline
    MemberRank
    Oct 2009 Join Date
    EnglandLocation
    628Posts

    habAlert

    Damn I haven't posted in this section for years I think.

    Anyway, I decided to take a check back at how this section is doing, then logged into Habbo for the first time in like 2 or 3 years and saw a nice alert I liked and decided to make a jQuery plugin out of it.

    Anyway, here it is.

    http://mark-eriksson.com/work/plugins/habAlert/

    Files: http://uploadir.com/u/myuw7lty



    habAlert.js
    PHP Code:
    /**
      * Modify as you like
      * Created by Mark Eriksson http://mark-eriksson.com
      */

    (function($) {    
        $.
    habAlert = function(opts) {
            var 
    options = $.extend({
                
    title'habAlert',
                
    image'',
                
    leadTitle'',
                
    body'<p>No default body text has been set for this habAlert.</p>',
                
    bodyType'html',
                
    controls: {
                    
    links: [],
                    
    buttons: []
                }
            }, 
    opts);
            
            var 
    closehabAlert = function(el) {
                $(
    el).closest('.habalert').fadeOut('medium', function() {
                    $(
    this).remove();
                });
            }
            
            var 
    wrapper = $('<div />').addClass('habalert');
            
            var 
    header = $('<div />').addClass('habalert-header').append(($('<a />').attr({href:'#close', class:'habalert-close'}).on('click', function(e) {
                
    e.preventDefault();
                
    closehabAlert($(this));
            })), ($(
    '<span />').addClass('habalert-title').text(options.title)));
            
            var 
    border = $('<div />').addClass('habalert-border');
            
            if (
    options.image && options.leadTitle) {
                var 
    leadWrapper = $('<div />').addClass('habalert-lead habalert-cf').append(($('<img />').attr({srcoptions.imagealt'habAlert image'})), ($('<h3 />').text(options.leadTitle)));
            }
            
            var 
    body = $('<div />').addClass('habalert-body');
            
    options.bodyType === 'html' body.html(options.body) : body.text(options.body);
            
            var 
    controlsWrapper = $('<div />').addClass('habalert-controls-wrapper');
            var 
    controls = $('<div />').addClass('habalert-controls');
            
            if (
    options.controls.links.length 0) {
                for (
    i=0;i<=options.controls.links.length-1;i++) {
                    var 
    thisLink options.controls.links[i];
                    
                    if (!
    thisLink.targetthisLink.target '';
                    
                    
    controls.append(($('<a />').addClass('habalert-link').attr({hrefthisLink.hreftargetthisLink.target}).text(thisLink.text)));
                }
            }
            
            if (
    options.controls.buttons.length 0) {
                for (
    s=0;s<=options.controls.buttons.length-1;s++) {
                    var 
    thisButton options.controls.buttons[s];
                    
                    if (!
    thisButton.targetthisButton.target '';
                    
                    
    controls.append(($('<a />').addClass('habalert-button').attr({hrefthisButton.hreftargetthisButton.target}).text(thisButton.text)));
                }
            }
            
            
    wrapper.append(headerborder.append(body), (controlsWrapper.append(controls)));
            
            if (
    leadWrapperborder.prepend(leadWrapper);
            
            $(
    'body').append(wrapper);
        }
    })(
    jQuery); 


    index.html
    PHP Code:
    <!DOCTYPE html>
    <
    html lang="en">
        <
    head>
            <
    meta charset="UTF-8">
            <
    title>habAlert</title>
            <
    link rel="stylesheet" href="css/habalert.css" />
            <
    link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Ubuntu:400,500,700" />
        </
    head>

        <
    body>
            
            <
    a href="#" id="openhabAlert">Open a habAlert</a>
            
            <
    br /><br />
            
            <
    fieldset>
                <
    legend>Create your own habAlert</legend>
                <
    table>
                    <
    tr>
                        <
    td>Title:</td>
                        <
    td><input type="text" id="title" /></td>
                    </
    tr>
                    <
    tr>
                        <
    td>Image URL:</td>
                        <
    td><input type="text" id="image" /> <em>(optional)</em></td>
                    </
    tr>
                    <
    tr>
                        <
    td>Lead title:</td>
                        <
    td><input type="text" id="leadTitle" /> <em>(optional)</em></td>
                    </
    tr>
                    <
    tr>
                        <
    td>Body content:</td>
                        <
    td><input type="text" id="body" /> <em>(text only)</em></td>
                    </
    tr>
                    <
    tr>
                        <
    td>Link URL:</td>
                        <
    td><input type="text" id="linkURL" /></td>
                    </
    tr>
                    <
    tr>
                        <
    td>Link label:</td>
                        <
    td><input type="text" id="linkLabel" /></td>
                    </
    tr>
                    <
    tr>
                        <
    td>Button URL:</td>
                        <
    td><input type="text" id="buttonURL" /></td>
                    </
    tr>
                    <
    tr>
                        <
    td>Button label:</td>
                        <
    td><input type="text" id="buttonLabel" /></td>
                    </
    tr>
                    <
    tr>
                        <
    td><button id="makeit">Make it</button></td>
                    </
    tr>
                </
    table>
            </
    fieldset>
            
            <
    script src="http://code.jquery.com/jquery-latest.js"></script>
            <script src="js/habAlert.js"></script>
            <script>
                $('#makeit').on('click', function() {
                    var title       = $('#title').val() || 'habAlert',
                        image       = $('#image').val(),
                        leadTitle   = $('#leadTitle').val(),
                        body        = $('#body').val() || 'Test habAlert',
                        linkURL     = $('#linkURL').val() || '#',
                        linkLabel   = $('#linkLabel').val() || 'Link',
                        buttonURL   = $('#buttonURL').val() || '#',
                        buttonLabel = $('#buttonLabel').val() || 'Button',
                        allowedExts = ['png', 'gif', 'jpg', 'jpeg', 'bmp'],
                        extFound    = false;
                    
                    if (image.length > 0) {
                        allowedExts.forEach(function(e) {
                            console.log(e);
                            if (image.split('.').pop().toLowerCase() == e)
                                extFound = true;
                        });
                    }
                    
                    if (extFound === false)
                        image = '';
                    
                    $.habAlert({
                        title: title,
                        image: image,
                        leadTitle: leadTitle,
                        body: body,
                        bodyType: 'text',
                        controls: {
                            links: [
                                {href: linkURL, text: linkLabel}
                            ],
                            buttons: [
                                {href: buttonURL, text: buttonLabel}
                            ]
                        }
                    });
                });
                
                $('#openhabAlert').on('click', function() {
                    $.habAlert({
                        title: 'habAlert Poll',
                        image: 'img/qmarks.png',
                        leadTitle: 'Answer our poll!',
                        body: '<p><strong>Please</strong> answer our poll, we appreciate all feedback.</p>',
                        controls: {
                            links: [
                                {href: '#rofl', text: 'View previous polls'}
                            ],
                            buttons: [
                                {href: 'index.html', text: 'ok let\'s go'}
                            ]
                        }
                    });
                });
            </script>
        </body>
    </html> 
    habalert.css
    PHP Code:
    @charset "utf-8";

    .
    habalert-cf:before, .habalert-cf:after {
        
    content" ";
        
    displaytable;
    }

    .
    habalert-cf:after clearboth; }

    .
    habalert, .habalert * { box-sizingborder-box; }

    .
    habalert {
        
    color#080808;
        
    max-width390px;
        
    width100%;
        
    font14px 'Ubuntu'sans-serif;
        
    box-shadow0 2px 6px 1px rgba(0,0,0,.4);
        
    border-radius13px;
        
    positionabsolute;
        -
    webkit-user-selectnone;
        
    top40px;
        
    left50%;
        
    transformtranslateX(-50%);
        -
    webkit-transformtranslateX(-50%);
    }

    .
    habalert-header {
        
    background-color#367897;
        
    color#fff;
        
    text-aligncenter;
        
    padding10px;
        
    border-top-left-radius13px;
        
    border-top-right-radius13px;
        
    border1px solid #000;
        
    font-weight700;
        
    font-size13px;
    }

        .
    habalert-header .habalert-close {
            
    floatright;
            
    background-imageurl('../img/close-sprite.png');
            
    background-position0 0;
            
    displayblock;
            
    height20px;
            
    width19px;
            
    font-size0;
            
    margin-top: -1px;
            
    margin-right: -2px;
        }

            .
    habalert-header .habalert-close:hover background-position-40px; }
            .
    habalert-header .habalert-close:active background-position-20pxheight19px; }

    .
    habalert-border {
        
    border1px solid #000;
        
    border-topnone;
        
    border-bottomnone;
    }

    .
    habalert-lead {
        
    background-color#0e3f52;
        
    color#fff;
        
    font-size16px;
        
    padding8px 12px;
    }

        .
    habalert-lead img {
            
    floatleft;
            
    max-width80px;
            
    max-height80px;
            
    vertical-alignmiddle;
        }

        .
    habalert-lead h3 {
            
    positionrelative;
            
    top4px;
            
    left20px;
        }

    .
    habalert-body {
        
    line-height19px;
        
    padding7px 17px;
        
    font-size13px;
        
    border6px solid rgba(0,0,0,.07);
        
    border-topnone;
        
    border-bottomnone;
    }

        .
    habalert-body p:first-child margin-top0!important; }
        .
    habalert-body p:last-child margin-bottom0!important; }

    .
    habalert-controls-wrapper {
        
    border1px solid #000;
        
    border-topnone;
        
    border-bottom-left-radius:13px;
        
    border-bottom-right-radius:13px;
    }

    .
    habalert-controls {
        
    border6px solid rgba(0,0,0,.07);
        
    border-topnone;
        
    border-bottom-left-radius13px;
        
    border-bottom-right-radius13px;
        
    text-alignright;
        
    padding10px 8px;
    }

        .
    habalert-controls a {
            
    vertical-alignbottom;
            
    margin0 20px;
            
    font-size13px;
        }

            .
    habalert-controls a:first-child margin-left0!important; }
            .
    habalert-controls a:last-child margin-right0!important; }

            .
    habalert-controls a.habalert-link {
                
    color#333;
                
    text-decorationnone;
                
    border-bottom1px solid #333;
                
    padding-bottom1px;
                
    positionrelative;
                
    top: -7px;
            }

            .
    habalert-controls a.habalert-button {
                
    displayinline-block;
                
    text-decorationnone;
                
    color#fff;
                
    height40px;
                
    text-aligncenter;
                
    padding10px 6px 0;
                
    min-width80px;
                
    font-weight700;
                
    border2px solid #000;
                
    border-bottom-width3px;
                
    background-imageurl('../img/button-bg.png');
                
    border-radius5px;
            }

                .
    habalert-controls a.habalert-button:hover background-imageurl('../img/button-bg-hover.png'); }
                .
    habalert-controls a.habalert-button:active background-imageurl('../img/button-bg-click.png'); } 
    There are 6 options, detailed below:

    title is display across the blue header
    image is an optional image to be displayed, can be local or external (if omitted, the whole section .habalert-lead will not be displayed)
    leadTitle is an optional header to be displayed (if omitted, the whole section .habalert-lead will not be displayed)
    body is the main body content. Can be HTML or plain text, depending on the next option below...
    bodyType is what type of content you want the body to be (html | text) [default html]
    controls is an array of the controls that will be displayed as links and/or buttons

    How to use controls
    controls contains two optional separate arrays which then consist of objects. If you want to display 2 standard links and 1 big green button, the following code would suffice:
    PHP Code:
    controls: {
        
    links: [
            {
    href'http://mark-eriksson.com'target'_blank'text'Mark Eriksson'},
            {
    href'login.php'text'Log in'}
        ],
        
    buttons: [
            {
    href'http://google.co.uk'target'_blank'text'Google'}
        ]

    Damn this could be optimised a lot more but I only made it because I was bored.

    Hope it helps if you decide to use it anyway.

    Cheers, Mark.
    Last edited by Markshall; 01-01-15 at 08:58 PM. Reason: CODE and HTML tags not working?


  2. #2
    Check http://arcturus.pw The General is offline
    DeveloperRank
    Aug 2011 Join Date
    7,607Posts

    Re: habAlert

    Well looks like somebody knows his jQuery.

    Looks pretty neat. I like it.

  3. #3
    Ragezone Furni Releaser maartenvn is offline
    MemberRank
    Dec 2012 Join Date
    Ragezone WorldLocation
    928Posts

    Re: habAlert

    I love the idea!
    Thanks for sharing.

  4. #4
    apt-get install xcowsay 3M1L is offline
    MemberRank
    Jul 2012 Join Date
    SwedenLocation
    268Posts

    Re: habAlert

    Damn, nigga where have u been?

    OT: You always release useful stuff, actually i havent seen anything similar to this for ages, I'm glad you are back

    Edit: I noticed something that some people might find very annoying, when you have multiple habAlert's open and you only want to close 1, all visible alerts get closed too.

    Here's a fix for that, find
    var closehabAlert = function() {
    $('.habalert').fadeOut('medium', function() {
    $(this).remove();
    });
    }
    Replace with the following
    var closehabAlert = function(element) {
    $(element).closest(".habalert").fadeOut('medium', function() {
    $(this).remove();
    });
    }
    Find
    var header = $('<div />').addClass('habalert-header').append(($('<a />').attr({href:'#close', class:'habalert-close'}).on('click', function(e) {
    e.preventDefault();
    closehabAlert();
    })), ($('<span />').addClass('habalert-title').text(options.title)));
    Replace it with
    var header = $('<div />').addClass('habalert-header').append(($('<a />').attr({href:'#close', class:'habalert-close'}).on('click', function(e) {
    e.preventDefault();
    closehabAlert($(this));
    })), ($('<span />').addClass('habalert-title').text(options.title)));
    Last edited by 3M1L; 31-12-14 at 11:27 AM. Reason: Additional fixes ^_^

  5. #5
    Web Developer Markshall is offline
    MemberRank
    Oct 2009 Join Date
    EnglandLocation
    628Posts

    Re: habAlert

    I've been a busy boy. I quit habbo lol got bored when they released that horrible flash client, fuck that

  6. #6
    HabboFont.net Cankiee is offline
    MemberRank
    May 2013 Join Date
    North KoreaLocation
    978Posts

    Re: habAlert

    Looks sick.

    Gonna use it, thanks!:)

  7. #7
    Web Developer Markshall is offline
    MemberRank
    Oct 2009 Join Date
    EnglandLocation
    628Posts

    Re: habAlert

    Thanks for the feedback guys.

    You can now create your own habAlert on the website to see how it works. (can only have one link and one button on the creator though, however you can have as many as you want when you use habAlert.js in production).

    Original post updated with a new download link and revised code. Positioning is better; if you had more than one habAlert open, it would be placed directly underneath the other, now they are placed on top of each other.

    Also fixed the issue @3M1L mentioned.

  8. #8
    Account Upgraded | Title Enabled! AskethZ is offline
    MemberRank
    Jul 2012 Join Date
    232Posts

    Re: habAlert

    Thanks a lot!

  9. #9
    ☮TAKU???? seanrom is offline
    MemberRank
    Nov 2009 Join Date
    1,004Posts

    Re: habAlert

    Welcome back. You have never disappointed, and you don't do that either with this release. Good Release!

  10. #10
    Web Developer Markshall is offline
    MemberRank
    Oct 2009 Join Date
    EnglandLocation
    628Posts

    Re: habAlert

    Quote Originally Posted by oleaa View Post
    Welcome back. You have never disappointed, and you don't do that either with this release. Good Release!
    Lol I aim to please, nice one. Glad you like it.

  11. #11
    Apprentice Momotjeee is offline
    MemberRank
    May 2012 Join Date
    Istanboel, TurkLocation
    7Posts

    Re: habAlert

    Excellent work! Well, I am not best in jQuerysettings and other shizzle.
    Is there any option, possibility, to make this jQuery script work if one user visite the page /me and that the alert then automatically opens?

    I don't wanna open the alert if the user is clicking on text.. Can you fix this for me?
    Thanks, anyway!

  12. #12
    Hakuna Matata Matata is offline
    MemberRank
    Sep 2012 Join Date
    DenmarkLocation
    807Posts

    Re: habAlert

    Quote Originally Posted by Momotjeee View Post
    Excellent work! Well, I am not best in jQuerysettings and other shizzle.
    Is there any option, possibility, to make this jQuery script work if one user visite the page /me and that the alert then automatically opens?

    I don't wanna open the alert if the user is clicking on text.. Can you fix this for me?
    Thanks, anyway!
    This will do it for you.

    Code:
     $( document ).ready(function() {
    
    //Alert code here 
    
    });
    Once document (your website) is loaded, the code inside the function will be executed.

  13. #13
    I use to love it more! Jmandupree is offline
    MemberRank
    Oct 2009 Join Date
    /ragezone/homeLocation
    995Posts

    Re: habAlert

    Long time!

    This is good at first I thought it was a MODAL window until I read on good job!

  14. #14
    Apprentice Momotjeee is offline
    MemberRank
    May 2012 Join Date
    Istanboel, TurkLocation
    7Posts

    Re: habAlert

    Thanks for your reply @Matata
    Is there any possibility to make the textcolumns make work with the database columns?

    Like: I have in my database, named: Habbo and column: Text, if I type text in the textcolumn, then on the alert it shows, the text that is writed in the database column will show up?

  15. #15
    Account Upgraded | Title Enabled! UartigZone is offline
    MemberRank
    Dec 2013 Join Date
    LoserlandLocation
    441Posts

    Re: habAlert

    Can someone code this so if you press View Previous Polls it will close and then nothing happen? And so if you open the client/me page it will show?

    I'm not the best to this ...



Page 1 of 2 12 LastLast

Advertisement