]> git.mxchange.org Git - friendica.git/blobdiff - view/theme/frost-mobile/js/main.js
bug in main.js for VideoJS on initial page load
[friendica.git] / view / theme / frost-mobile / js / main.js
index 6daa19b4170ce295d8ad27f2d83808983032a5be..43782c8ecc5c6af09f8ab9d5d4bfda5f41851ff2 100644 (file)
@@ -1,20 +1,33 @@
 
-  function openClose(theID) {
-    if(document.getElementById(theID).style.display == "block") { 
-      document.getElementById(theID).style.display = "none" 
-    }
-    else { 
-      document.getElementById(theID).style.display = "block" 
-    } 
-  }
+       function openClose(listID) {
+/*             if(document.getElementById(theID).style.display == "block") { 
+                       document.getElementById(theID).style.display = "none" 
+               }
+               else { 
+                       document.getElementById(theID).style.display = "block" 
+               }*/
+               listID = "#" + listID.replace(/:/g, "\\:");
+               listID = listID.replace(/\./g, "\\.");
+               listID = listID.replace(/@/g, "\\@");
+
+               if($j(listID).is(":visible")) {
+                       $j(listID).hide();
+                       $j(listID+"-wrapper").show();
+                       alert($j(listID+"-wrapper").attr("id"));
+               }
+               else {
+                       $j(listID).show();
+                       $j(listID+"-wrapper").hide();
+               }
+       }
 
-  function openMenu(theID) {
-      document.getElementById(theID).style.display = "block" 
-  }
+       function openMenu(theID) {
+               document.getElementById(theID).style.display = "block" 
+       }
 
-  function closeMenu(theID) {
-      document.getElementById(theID).style.display = "none" 
-  }
+       function closeMenu(theID) {
+               document.getElementById(theID).style.display = "none" 
+       }
 
 
 
@@ -38,6 +51,8 @@
 
                msie = $j.browser.msie ;
                
+               collapseHeight();
+
                /* setup tooltips *//*
                $j("a,.tt").each(function(){
                        var e = $j(this);
                });
                
                // fancyboxes
-               /*$j("a.popupbox").fancybox({
-                       'transitionIn' : 'elastic',
-                       'transitionOut' : 'elastic'
+               /*$j("a.popupbox").colorbox({
+                       'inline' : true,
+                       'transition' : 'none'
                });*/
                
 
                                        html = notifications_tpl.format(e.attr('href'),e.attr('photo'), text, e.attr('date'), e.attr('seen'));
                                        nnm.append(html);
                                });
+
+                               $j("img[data-src]", nnm).each(function(i, el){
+                                       // Add src attribute for images with a data-src attribute
+                                       $j(el).attr('src', $j(el).data("src"));
+                               });
                        }
                        notif = eNotif.attr('count');
                        if (notif>0){
                                        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;
        }
 
        function liveUpdate() {
-               if((src == null) || (stopped) || (! profile_uid)) { $j('.like-rotator').hide(); return; }
+               if((src == null) || (stopped) || (typeof profile_uid == 'undefined') || (! profile_uid)) { $j('.like-rotator').hide(); return; }
                if(($j('.comment-edit-text-full').length) || (in_progress)) {
                        if(livetime) {
                                clearTimeout(livetime);
                                        $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;
                        });
 
 
-                       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();
-                       }
+                       collapseHeight();
 
                        // reset vars for inserting individual items
 
                        }
                        /* autocomplete @nicknames */
                        $j(".comment-edit-form  textarea").contact_autocomplete(baseurl+"/acl");
+
+                       // setup videos, since VideoJS won't take care of any loaded via AJAX
+                       if(typeof _V_ != 'undefined') _V_.autoSetup();
                });
        }
 
-       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: 0 });
-                                       $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 imgbright(node) {
+/*     function imgbright(node) {
                $j(node).removeClass("drophide").addClass("drop");
        }
 
        function imgdull(node) {
                $j(node).removeClass("drop").addClass("drophide");
-       }
+       }*/
 
        // Since our ajax calls are asynchronous, we will give a few 
        // seconds for the first ajax call (setting like/dislike), then 
 
        function getPosition(e) {
                var cursor = {x:0, y:0};
-               if ( e.touches[0].pageX || e.touches[0].pageY  ) {
-                       cursor.x = e.touches[0].pageX;
-                       cursor.y = e.touches[0].pageY;
+               if ( e.pageX || e.pageY  ) {
+                       cursor.x = e.pageX;
+                       cursor.y = e.pageY;
                }
                else {
-                       if( e.touches[0].clientX || e.touches[0].clientY ) {
-                               cursor.x = e.touches[0].clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
-                               cursor.y = e.touches[0].clientY + (document.documentElement.scrollTop  || document.body.scrollTop)  - document.documentElement.clientTop;
+                       if( e.clientX || e.clientY ) {
+                               cursor.x = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
+                               cursor.y = e.clientY + (document.documentElement.scrollTop  || document.body.scrollTop)  - document.documentElement.clientTop;
                        }
                        else {
-                               if( e.touches[0].x || e.touches[0].y ) {
-                                       cursor.touches[0].x = e.touches[0].x;
-                                       cursor.touches[0].y = e.touches[0].y;
+                               if( e.x || e.y ) {
+                                       cursor.x = e.x;
+                                       cursor.y = e.y;
                                }
                        }
                }
                        lockvisible = true;
                        $j.get('lockview/' + id, function(data) {
                                $j('#panel').html(data);
-                               $j('#panel').css({ 'left': cursor.x + 5 , 'top': cursor.y + 5});
+                               $j('#panel').css({ 'left': 10 , 'top': cursor.y + 20});
                                $j('#panel').show();
                        });
                }
        }
 
 
+       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");
@@ -650,9 +693,9 @@ function setupFieldRichtext(){
                entity_encoding : "raw",
                add_unload_trigger : false,
                remove_linebreaks : false,
-               force_p_newlines : false,
-               force_br_newlines : true,
-               forced_root_block : '',
+               //force_p_newlines : false,
+               //force_br_newlines : true,
+               forced_root_block : 'div',
                convert_urls: false,
                content_css: baseurl+"/view/custom_tinymce.css",
                theme_advanced_path : false,