]> git.mxchange.org Git - friendica.git/blobdiff - view/theme/frost-mobile/js/main.js
Merge pull request #556 from fermionic/20121224-smarty3-template-collision
[friendica.git] / view / theme / frost-mobile / js / main.js
index d233ba7b68f9e52a11751559496e544e21b6e4bb..a56c313125d77dfc4f0c14b0c692f50e6222bd7e 100644 (file)
@@ -38,6 +38,8 @@
 
                msie = $j.browser.msie ;
                
+               collapseHeight();
+
                /* setup tooltips *//*
                $j("a,.tt").each(function(){
                        var e = $j(this);
@@ -78,7 +80,7 @@
                        if( last_popup_menu ) {
                                if( '#' + last_popup_menu.attr('id') !== $j(e.target).attr('rel')) {
                                        last_popup_menu.hide();
-                                       if (last_popup_menu.attr('id') == "nav-notifications-menu" ) $j('section').show();
+                                       if (last_popup_menu.attr('id') == "nav-notifications-menu" ) $j('.main-container').show();
                                        last_popup_button.removeClass("selected");
                                        last_popup_menu = null;
                                        last_popup_button = null;
                        if (menu.css("display") == "none") {
                                $j(this).parent().addClass("selected");
                                menu.show();
-                               if (menu.attr('id') == "nav-notifications-menu" ) $j('section').hide();
+                               if (menu.attr('id') == "nav-notifications-menu" ) $j('.main-container').hide();
                                last_popup_menu = menu;
                                last_popup_button = $j(this).parent();
                        } else {
                                $j(this).parent().removeClass("selected");
                                menu.hide();
-                               if (menu.attr('id') == "nav-notifications-menu" ) $j('section').show();
+                               if (menu.attr('id') == "nav-notifications-menu" ) $j('.main-container').show();
                                last_popup_menu = null;
                                last_popup_button = null;
                        }
                        var eSysmsg = $j(data).find('sysmsgs');
                        eSysmsg.children("notice").each(function(){
                                text = $j(this).text();
-                               $j.jGrowl(text, { sticky: false, theme: 'notice', life: 1500 });
+                               $j.jGrowl(text, { sticky: false, theme: 'notice', life: 1000 });
                        });
                        eSysmsg.children("info").each(function(){
                                text = $j(this).text();
                                        if($j('#live-profile').length)   { src = 'profile'; liveUpdate(); }
                                        if($j('#live-community').length) { src = 'community'; liveUpdate(); }
                                        if($j('#live-notes').length)     { src = 'notes'; liveUpdate(); }
-                                       if($j('#live-display').length) {
+                                       if($j('#live-display').length) { src = 'display'; liveUpdate(); }
+                                       /*if($j('#live-display').length) {
                                                if(liking) {
                                                        liking = 0;
                                                        window.location.href=window.location.href 
                                                }
-                                       }
+                                       }*/
                                        if($j('#live-photos').length) {
                                                if(liking) {
                                                        liking = 0;
                                        $j('#' + prev).after($j(this));
                                }
                                else {
+                                       // Find out if the hidden comments are open, so we can keep it that way
+                                       // if a new comment has been posted
+                                       var id = $j('.hide-comments-total', this).attr('id');
+                                       if(typeof id != 'undefined') {
+                                               id = id.split('-')[3];
+                                               var commentsOpen = $j("#collapsed-comments-" + id).is(":visible");
+                                       }
+
                                        $j('img',this).each(function() {
                                                $j(this).attr('src',$j(this).attr('dst'));
                                        });
+                                       //vScroll = $j(document).scrollTop();
+                                       $j('html').height($j('html').height());
                                        $j('#' + ident).replaceWith($j(this));
+
+                                       if(typeof id != 'undefined') {
+                                               if(commentsOpen) showHideComments(id);
+                                       }
+                                       $j('html').height('auto');
+                                       //$j(document).scrollTop(vScroll);
                                }
                                prev = ident;
                        });
 
+
+                       collapseHeight();
+
                        // reset vars for inserting individual items
 
                        /*prev = 'live-' + src;
                        }
                        /* autocomplete @nicknames */
                        $j(".comment-edit-form  textarea").contact_autocomplete(baseurl+"/acl");
-
-                       var bimgs = $j(".wall-item-body > img").not(function() { return this.complete; });
-                       var bimgcount = bimgs.length;
-
-                       if (bimgcount) {
-                               bimgs.load(function() {
-                                       bimgcount--;
-                                       if (! bimgcount) {
-                                               collapseHeight();
-
-                                       }
-                               });
-                       } else {
-                               collapseHeight();
-                       }
-
                });
        }
 
-       function collapseHeight() {
-               $j(".wall-item-body").each(function() {
-                               if($j(this).height() > 310) {
-                               if(! $j(this).hasClass('divmore')) {
-                                       $j(this).divgrow({ initialHeight: 300, showBrackets: false, speed: 300 });
-                                       $j(this).addClass('divmore');
-                               }
-                       }                                       
+       function collapseHeight(elems) {
+               var elemName = '.wall-item-body:not(.divmore)';
+               if(typeof elems != 'undefined') {
+                       elemName = elems + ' ' + elemName;
+               }
+               $j(elemName).each(function() {
+                       if($j(this).height() > 350) {
+                               $j('html').height($j('html').height());
+                               $j(this).divgrow({ initialHeight: 300, showBrackets: false, speed: 0 });
+                               $j(this).addClass('divmore');
+                               $j('html').height('auto');
+                       }
                });
        }
 
        }
 
 
+       function showHideComments(id) {
+               if( $j("#collapsed-comments-" + id).is(":visible")) {
+                       $j("#collapsed-comments-" + id).hide();
+                       $j("#hide-comments-" + id).html(window.showMore);
+               }
+               else {
+                       $j("#collapsed-comments-" + id).show();
+                       $j("#hide-comments-" + id).html(window.showFewer);
+                       collapseHeight("#collapsed-comments-" + id);
+               }
+       }
+
 
        function preview_post() {
                $j("#jot-preview").val("1");
@@ -684,7 +706,7 @@ Array.prototype.remove = function(item) {
 function previewTheme(elm) {
        theme = $j(elm).val();
        $j.getJSON('pretheme?f=&theme=' + theme,function(data) {
-                       $j('#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>');
+                       $j('#theme-preview').html('<div id="theme-desc">' + data.desc + '</div><div id="theme-version">' + data.version + '</div><div id="theme-credits">' + data.credits + '</div>');
        });
 
 }