]> git.mxchange.org Git - friendica.git/blobdiff - js/main.js
Merge pull request #466 from pixelroot/master
[friendica.git] / js / main.js
index 8cb522743a7f7e7febdfea20d4b278f9c79c8ea7..6ab574c4e818f449742f9d9668c2b43b12b5ee2f 100644 (file)
                setupFieldRichtext();
 
                /* popup menus */
+       function close_last_popup_menu() {
+               if(last_popup_menu) {
+               last_popup_menu.hide();
+               last_popup_button.removeClass("selected");
+               last_popup_menu = null;
+               last_popup_button = null;
+               }
+               }
                $('a[rel^=#]').click(function(e){
+                       close_last_popup_menu();
                        menu = $( $(this).attr('rel') );
                        e.preventDefault();
                        e.stopPropagation();
                        return false;
                });
                $('html').click(function() {
-                       if(last_popup_menu) {
-                               last_popup_menu.hide();
-                               last_popup_button.removeClass("selected");
-                               last_popup_menu = null;
-                               last_popup_button = null;
-                       }
+                                               close_last_popup_menu();
                });
                
                // fancyboxes
                
                /* nav update event  */
                $('nav').bind('nav-update', function(e,data){;
+                       var invalid = $(data).find('invalid').text();
+                       if(invalid == 1) { window.location.href=window.location.href }
+
                        var net = $(data).find('net').text();
                        if(net == 0) { net = ''; $('#net-update').removeClass('show') } else { $('#net-update').addClass('show') }
                        $('#net-update').html(net);
        function NavUpdate() {
 
                if(! stopped) {
-                       $.get("ping",function(data) {
+                       var pingCmd = 'ping' + ((localUser != 0) ? '?f=&uid=' + localUser : '');
+                       $.get(pingCmd,function(data) {
                                $(data).find('result').each(function() {
                                        // send nav-update event
                                        $('nav').trigger('nav-update', this);
                        //});
 
                        // add a new thread
-
-                       $('.tread-wrapper',data).each(function() {
+                       $('.toplevel_item',data).each(function() {
                                var ident = $(this).attr('id');
 
                                if($('#' + ident).length == 0 && profile_page == 1) {
        function dolike(ident,verb) {
                unpause();
                $('#like-rotator-' + ident.toString()).show();
-               $.get('like/' + ident.toString() + '?verb=' + verb );
-               if(timer) clearTimeout(timer);
-               timer = setTimeout(NavUpdate,3000);
+               $.get('like/' + ident.toString() + '?verb=' + verb, NavUpdate );
+//             if(timer) clearTimeout(timer);
+//             timer = setTimeout(NavUpdate,3000);
                liking = 1;
        }
 
@@ -588,7 +595,7 @@ function setupFieldRichtext(){
                theme : "advanced",
                mode : "specific_textareas",
                editor_selector: "fieldRichtext",
-               plugins : "bbcode,paste",
+               plugins : "bbcode,paste, inlinepopups",
                theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor,formatselect,code",
                theme_advanced_buttons2 : "",
                theme_advanced_buttons3 : "",
@@ -633,7 +640,7 @@ Array.prototype.remove = function(item) {
 function previewTheme(elm) {
        theme = $(elm).val();
        $.getJSON('pretheme?f=&theme=' + theme,function(data) {
-                       $('#theme-preview').html('<div id="theme-desc">' + data.desc + '</div><a href="' + data.img + '"><img src="' + data.img + '" width="320" height="240" alt="' + theme + '" /></a>');
+                       $('#theme-preview').html('<div id="theme-desc">' + data.desc + '</div><div id="theme-version">' + data.version + '</div><div id="theme-credits">' + data.credits + '</div><a href="' + data.img + '"><img src="' + data.img + '" width="320" height="240" alt="' + theme + '" /></a>');
        });
 
 }