integration/js/common.js
author cavaliet
Wed, 19 Dec 2012 13:23:34 +0100
changeset 139 ebaf7878c756
parent 115 e48bb5d43ac2
child 154 60ca7678f074
permissions -rw-r--r--
logout view and regexp for username creation.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15
56937307d7f4 cleaning css
veltr
parents:
diff changeset
     1
$(function(){
56937307d7f4 cleaning css
veltr
parents:
diff changeset
     2
56937307d7f4 cleaning css
veltr
parents:
diff changeset
     3
    $(".open-popin").click(function(){
56937307d7f4 cleaning css
veltr
parents:
diff changeset
     4
        var target = $(this).attr("href");
56937307d7f4 cleaning css
veltr
parents:
diff changeset
     5
        if($(target).is(':visible')){
16
7536b92a7775 a few changes before a merge
veltr
parents: 15
diff changeset
     6
            $(".popin").hide();
15
56937307d7f4 cleaning css
veltr
parents:
diff changeset
     7
        }else{
16
7536b92a7775 a few changes before a merge
veltr
parents: 15
diff changeset
     8
            $(".popin").hide();
15
56937307d7f4 cleaning css
veltr
parents:
diff changeset
     9
            $(target).show();
56937307d7f4 cleaning css
veltr
parents:
diff changeset
    10
        }
56937307d7f4 cleaning css
veltr
parents:
diff changeset
    11
        return false;
56937307d7f4 cleaning css
veltr
parents:
diff changeset
    12
    });
56937307d7f4 cleaning css
veltr
parents:
diff changeset
    13
    
115
e48bb5d43ac2 Clicking outside "popins" now hides them
veltr
parents: 104
diff changeset
    14
    $(document).click(function(e) {
e48bb5d43ac2 Clicking outside "popins" now hides them
veltr
parents: 104
diff changeset
    15
        if(!$(e.target).parents(".popin").length) {
e48bb5d43ac2 Clicking outside "popins" now hides them
veltr
parents: 104
diff changeset
    16
            $(".popin").hide();
e48bb5d43ac2 Clicking outside "popins" now hides them
veltr
parents: 104
diff changeset
    17
        }
e48bb5d43ac2 Clicking outside "popins" now hides them
veltr
parents: 104
diff changeset
    18
    });
e48bb5d43ac2 Clicking outside "popins" now hides them
veltr
parents: 104
diff changeset
    19
    
15
56937307d7f4 cleaning css
veltr
parents:
diff changeset
    20
    $(".change-account").click(function() {
91
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
    21
        $(".user-screen").hide();
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
    22
        $(".user-screen.login").show();
15
56937307d7f4 cleaning css
veltr
parents:
diff changeset
    23
    });
56937307d7f4 cleaning css
veltr
parents:
diff changeset
    24
    $(".signup-button").click(function() {
91
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
    25
        $(".user-screen").hide();
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
    26
        $(".user-screen.signup").show();
15
56937307d7f4 cleaning css
veltr
parents:
diff changeset
    27
    });
16
7536b92a7775 a few changes before a merge
veltr
parents: 15
diff changeset
    28
    $(".login-form, .signup-form").submit(function() {
7536b92a7775 a few changes before a merge
veltr
parents: 15
diff changeset
    29
        $(".user").hide();
91
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
    30
        $(".user-screen").hide();
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
    31
        $(".user-screen.info").show();
16
7536b92a7775 a few changes before a merge
veltr
parents: 15
diff changeset
    32
    });
24
1fbf7d835dc2 - update segment and bg video list
Anthony Ly <anthonyly.com@gmail.com>
parents: 16
diff changeset
    33
91
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
    34
});
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
    35
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
    36
// Social Plug-in
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
    37
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
    38
(function() {
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
    39
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
    40
var uid = 0;
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
    41
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
    42
window.social = function(opts) {
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
    43
    
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
    44
    var opts = opts || {};
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
    45
    opts.sel = opts.sel || $(".Ldt-Social");
104
1b84c7b2aeee Added Translations
veltr
parents: 91
diff changeset
    46
    opts.url = opts.url || document.location.href
1b84c7b2aeee Added Translations
veltr
parents: 91
diff changeset
    47
    opts.text = opts.text || $("title").text();
1b84c7b2aeee Added Translations
veltr
parents: 91
diff changeset
    48
    
1b84c7b2aeee Added Translations
veltr
parents: 91
diff changeset
    49
    if (!opts.sel.length) {
1b84c7b2aeee Added Translations
veltr
parents: 91
diff changeset
    50
        return;
1b84c7b2aeee Added Translations
veltr
parents: 91
diff changeset
    51
    }
1b84c7b2aeee Added Translations
veltr
parents: 91
diff changeset
    52
    
1b84c7b2aeee Added Translations
veltr
parents: 91
diff changeset
    53
    opts.sel.addClass("Ldt-Social");
91
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
    54
    
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
    55
    if (opts.swf) {
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
    56
        ZeroClipboard.setMoviePath(opts.swf);
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
    57
    }
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
    58
    
104
1b84c7b2aeee Added Translations
veltr
parents: 91
diff changeset
    59
    var clipId = "Social-Clip-" + (++uid),
1b84c7b2aeee Added Translations
veltr
parents: 91
diff changeset
    60
        clip,
1b84c7b2aeee Added Translations
veltr
parents: 91
diff changeset
    61
        html = '<div class="Ldt-Social-Url-Container"><a href="#" target="_blank" class="Ldt-Social-Square Ldt-Social-Url" title="'
1b84c7b2aeee Added Translations
veltr
parents: 91
diff changeset
    62
            + gettext("Share URL")
1b84c7b2aeee Added Translations
veltr
parents: 91
diff changeset
    63
            + '"></a><span class="Ldt-Social-UrlPop"><input class="Ldt-Social-Input"/><div class="Ldt-Social-CopyBtn" id="'
1b84c7b2aeee Added Translations
veltr
parents: 91
diff changeset
    64
            + clipId
1b84c7b2aeee Added Translations
veltr
parents: 91
diff changeset
    65
            + '">'
1b84c7b2aeee Added Translations
veltr
parents: 91
diff changeset
    66
            + gettext("Copy")
1b84c7b2aeee Added Translations
veltr
parents: 91
diff changeset
    67
            + '</div></span></div><a href="http://www.facebook.com/share.php?'
1b84c7b2aeee Added Translations
veltr
parents: 91
diff changeset
    68
            + $.param({ u: opts.url, t: opts.text })
1b84c7b2aeee Added Translations
veltr
parents: 91
diff changeset
    69
            + '" target="_blank" class="Ldt-Social-Fb Ldt-Social-Ext" title="'
1b84c7b2aeee Added Translations
veltr
parents: 91
diff changeset
    70
            + gettext("Share on Facebook")
1b84c7b2aeee Added Translations
veltr
parents: 91
diff changeset
    71
            + '"></a><a href="https://twitter.com/intent/tweet?'
1b84c7b2aeee Added Translations
veltr
parents: 91
diff changeset
    72
            + $.param({ url: opts.url, text: opts.text })
1b84c7b2aeee Added Translations
veltr
parents: 91
diff changeset
    73
            + '" target="_blank" class="Ldt-Social-Twitter Ldt-Social-Ext" title="'
1b84c7b2aeee Added Translations
veltr
parents: 91
diff changeset
    74
            + gettext("Share on Twitter")
1b84c7b2aeee Added Translations
veltr
parents: 91
diff changeset
    75
            + '"></a><a href="https://plus.google.com/share?'
1b84c7b2aeee Added Translations
veltr
parents: 91
diff changeset
    76
            + $.param({ url: opts.url, title: opts.text })
1b84c7b2aeee Added Translations
veltr
parents: 91
diff changeset
    77
            + '" target="_blank" class="Ldt-Social-Gplus Ldt-Social-Ext" title="'
1b84c7b2aeee Added Translations
veltr
parents: 91
diff changeset
    78
            + gettext("Share on Google+")
1b84c7b2aeee Added Translations
veltr
parents: 91
diff changeset
    79
            + '"></a><a href="mailto:?'
1b84c7b2aeee Added Translations
veltr
parents: 91
diff changeset
    80
            + $.param({ subject: opts.text, body: opts.text + ": " + opts.url })
1b84c7b2aeee Added Translations
veltr
parents: 91
diff changeset
    81
            + '" target="_blank" class="Ldt-Social-Mail" title="'
1b84c7b2aeee Added Translations
veltr
parents: 91
diff changeset
    82
            + gettext("Share via E-Mail")
1b84c7b2aeee Added Translations
veltr
parents: 91
diff changeset
    83
            + '"></a></div>';
1b84c7b2aeee Added Translations
veltr
parents: 91
diff changeset
    84
            
1b84c7b2aeee Added Translations
veltr
parents: 91
diff changeset
    85
    opts.sel.html(html);
91
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
    86
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
    87
    opts.sel.find(".Ldt-Social-Url").click(function() {
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
    88
        var _pop = opts.sel.find(".Ldt-Social-UrlPop");
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
    89
        _pop.toggle();
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
    90
        if (_pop.is(":visible")) {
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
    91
            if (typeof clip == "undefined") {
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
    92
                clip = new ZeroClipboard.Client();
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
    93
                clip.setHandCursor( true );
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
    94
                clip.glue(clipId);
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
    95
                
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
    96
                clip.addEventListener( 'onMouseUp', function() {
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
    97
                    _pop.hide();
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
    98
                    clip.hide();
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
    99
                });
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
   100
            }
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
   101
            clip.show();
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
   102
            clip.setText( opts.url );
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
   103
            opts.sel.find(".Ldt-Social-Input").val(opts.url).focus();
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
   104
        } else {
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
   105
            clip.hide();
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
   106
        }
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
   107
        return false;
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
   108
    });
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
   109
    opts.sel.find(".Ldt-Social-Input").focus(function() {
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
   110
        this.select();
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
   111
    });
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
   112
    opts.sel.find(".Ldt-Social-Ext").click(function() {
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
   113
        window.open(
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
   114
            opts.sel.find(this).attr("href"),
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
   115
            "_blank",
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
   116
            "height=300,width=450,left=100,top=100,toolbar=0,menubar=0,status=0,location=0");
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
   117
        return false;
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
   118
    });
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
   119
}
a94f5c62e4d7 unified templates + modified login form popin
veltr
parents: 24
diff changeset
   120
}());