diff --git a/css/style.css b/css/style.css index 33e2157b6..949c9eef8 100644 --- a/css/style.css +++ b/css/style.css @@ -9,7 +9,7 @@ and open the template in the editor. */ /* Imports */ -@import url("frameworks/bootstrap/css/bootstrap.min.css"); +/*@import url("frameworks/bootstrap/css/bootstrap.min.css"); @import url("frameworks/bootstrap/css/bootstrap-theme.min.css"); @import url("frameworks/font-awesome/css/font-awesome.min.css"); @import url("frameworks/jasny/css/jasny-bootstrap.min.css"); @@ -19,7 +19,7 @@ and open the template in the editor. @import url("frameworks/justifiedGallery/justifiedGallery.min.css"); @import url("frameworks/bootstrap-colorpicker/css/bootstrap-colorpicker.min.css"); @import url("font/open_sans/open-sans.css"); -@import url("css/hovercard.css"); +@import url("css/hovercard.css");*/ body { diff --git a/js/hovercard.js b/js/hovercard.js index c42b0ce2f..c40d6331e 100644 --- a/js/hovercard.js +++ b/js/hovercard.js @@ -7,90 +7,103 @@ * It is licensed under the GNU Affero General Public License * */ +$(document).ready(function(){ + // Elements with the class "userinfo" will get a hover-card. + // Note that this elements does need a href attribute which links to + // a valid profile url + $("body").on("mouseover", ".userinfo", function(e) { + var timeNow = new Date().getTime(); + removeAllhoverCards(e,timeNow); + var hoverCardData = false; + var hrefAttr = false; + var targetElement = $(this); -// Elements with the class "userinfo" will get a hover-card. -// Note that this elements does need a href attribute which links to -// a valid profile url -$("body").on("mouseover", ".userinfo", function(e) { + // get href-attribute + if(targetElement.is('[href]')) { + hrefAttr = targetElement.attr('href'); + } else { + return true; + } + + // no hover card if the element has the no-hover-card class + if(targetElement.hasClass('no-hover-card')) { + return true; + } + + // no hovercard for anchor links + if(hrefAttr.substring(0,1) == '#') { + return true; + } + + targetElement.attr('data-awaiting-hover-card',timeNow); + + // Take link href attribute as link to the profile + var profileurl = hrefAttr; + // the url to get the contact and template data + var url = baseurl + "/frio_hovercard"; + + // store the title in an other data attribute beause bootstrap + // popover destroys the title.attribute. We can restore it later + var title = targetElement.attr("title"); + targetElement.attr({"data-orig-title": title, title: ""}); + + // Timeoute until the hover-card does appear + setTimeout(function(){ + if(targetElement.is(":hover") && parseInt(targetElement.attr('data-awaiting-hover-card'),10) == timeNow) { + if($('.hovercard').length == 0) { // no card if there already is one open + // get an additional data atribute if the card is active + targetElement.attr('data-hover-card-active',timeNow); + // get the whole html content of the hover card and + // push it to the bootstrap popover + getHoverCardContent(profileurl, url, function(data){ + if(data) { + targetElement.popover({ + html: true, + placement: function () { + // Calculate the placement of the the hovercard (if top or bottom) + // The placement depence on the distance between window top and the element + // which triggers the hover-card + var get_position = $(targetElement).offset().top - $(window).scrollTop(); + if (get_position < 270 ){ + return "bottom"; + } + return "top"; + }, + trigger: 'manual', + template: '
', + content: data + }).popover('show'); + } + }); + } + } + }, 500); + }).on("mouseleave", ".userinfo", function(e) { // action when mouse leaves the hover-card + var timeNow = new Date().getTime(); + // copy the original title to the title atribute + var title = $(this).attr("data-orig-title"); + $(this).attr({"data-orig-title": "", title: title}); + removeAllhoverCards(e,timeNow); + }); + + + + // hover cards should be removed very easily, e.g. when any of these events happen + $('body').on("mouseleave touchstart scroll click dblclick mousedown mouseup submit keydown keypress keyup", function(e){ var timeNow = new Date().getTime(); removeAllhoverCards(e,timeNow); - var hoverCardData = false; - var hrefAttr = false; - var targetElement = $(this); + }); - // get href-attribute - if(targetElement.is('[href]')) { - hrefAttr = targetElement.attr('href'); - } else { - return true; - } + // if we're hovering a hover card, give it a class, so we don't remove it + $('body').on('mouseover','.hovercard', function(e) { + $(this).addClass('dont-remove-card'); + }); + $('body').on('mouseleave','.hovercard', function(e) { + $(this).removeClass('dont-remove-card'); + $(this).popover("hide"); + }); - // no hover card if the element has the no-hover-card class - if(targetElement.hasClass('no-hover-card')) { - return true; - } - - // no hovercard for anchor links - if(hrefAttr.substring(0,1) == '#') { - return true; - } - - targetElement.attr('data-awaiting-hover-card',timeNow); - - // Take link href attribute as link to the profile - var profileurl = hrefAttr; - // the url to get the contact and template data - var url = baseurl + "/frio_hovercard"; - - // store the title in an other data attribute beause bootstrap - // popover destroys the title.attribute. We can restore it later - var title = targetElement.attr("title"); - targetElement.attr({"data-orig-title": title, title: ""}); - - // Timeoute until the hover-card does appear - setTimeout(function(){ - if(targetElement.is(":hover") && parseInt(targetElement.attr('data-awaiting-hover-card'),10) == timeNow) { - if($('.hovercard').length == 0) { // no card if there already is one open - // get an additional data atribute if the card is active - targetElement.attr('data-hover-card-active',timeNow); - // get the whole html content of the hover card and - // push it to the bootstrap popover - getHoverCardContent(profileurl, url, function(data){ - if(data) { - targetElement.popover({ - html: true, - placement: function () { - // Calculate the placement of the the hovercard (if top or bottom) - // The placement depence on the distance between window top and the element - // which triggers the hover-card - var get_position = $(targetElement).offset().top - $(window).scrollTop(); - if (get_position < 270 ){ - return "bottom"; - } - return "top"; - }, - trigger: 'manual', - template: '
', - content: data - }).popover('show'); - } - }); - } - } - }, 500); -}).on("mouseleave", ".userinfo", function(e) { // action when mouse leaves the hover-card - var timeNow = new Date().getTime(); - // copy the original title to the title atribute - var title = $(this).attr("data-orig-title"); - $(this).attr({"data-orig-title": "", title: title}); - removeAllhoverCards(e,timeNow); -}); - -// hover cards should be removed very easily, e.g. when any of these events happen -$('body').on("mouseleave touchstart scroll click dblclick mousedown mouseup submit keydown keypress keyup", function(e){ - var timeNow = new Date().getTime(); - removeAllhoverCards(e,timeNow); -}); +}); // End of $(document).ready // removes all hover cards function removeAllhoverCards(event,priorTo) { @@ -110,15 +123,6 @@ function removeAllhoverCards(event,priorTo) { },100); } -// if we're hovering a hover card, give it a class, so we don't remove it -$('body').on('mouseover','.hovercard', function(e) { - $(this).addClass('dont-remove-card'); -}); -$('body').on('mouseleave','.hovercard', function(e) { - $(this).removeClass('dont-remove-card'); - $(this).popover("hide"); -}); - // Ajax request to get json contact data function getContactData(purl, url, actionOnSuccess) { var postdata = { diff --git a/js/textedit.js b/js/textedit.js new file mode 100644 index 000000000..f7d5ee57f --- /dev/null +++ b/js/textedit.js @@ -0,0 +1,83 @@ +/* + * @brief The file contains functions for text editing and commenting + */ + + +function insertFormatting(comment,BBcode,id) { + + var tmpStr = $("#comment-edit-text-" + id).val(); + if(tmpStr == comment) { + tmpStr = ""; + $("#comment-edit-text-" + id).addClass("comment-edit-text-full"); + $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty"); + openMenu("comment-edit-submit-wrapper-" + id); + $("#comment-edit-text-" + id).val(tmpStr); + } + + textarea = document.getElementById("comment-edit-text-" +id); + if (document.selection) { + textarea.focus(); + selected = document.selection.createRange(); + if (BBcode == "url"){ + selected.text = "["+BBcode+"]" + "http://" + selected.text + "[/"+BBcode+"]"; + } else + selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]"; + } else if (textarea.selectionStart || textarea.selectionStart == "0") { + var start = textarea.selectionStart; + var end = textarea.selectionEnd; + if (BBcode == "url"){ + textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + "http://" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length); + } else + textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length); + } + return true; +} + + +function showThread(id) { + $("#collapsed-comments-" + id).show() + $("#collapsed-comments-" + id + " .collapsed-comments").show() +} +function hideThread(id) { + $("#collapsed-comments-" + id).hide() + $("#collapsed-comments-" + id + " .collapsed-comments").hide() +} + + +function cmtBbOpen(id) { + $("#comment-edit-bb-" + id).show(); +} +function cmtBbClose(id) { + $("#comment-edit-bb-" + id).hide(); +} + +function commentExpand(id) { + $("#comment-edit-text-" + id).value = ''; + $("#comment-edit-text-" + id).addClass("comment-edit-text-full"); + $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty"); + $("#comment-edit-text-" + id).focus(); + $("#mod-cmnt-wrap-" + id).show(); + openMenu("comment-edit-submit-wrapper-" + id); + return true; +} + +function commentClose(obj,id) { + if(obj.value == '') { + obj.value = '{{$comment}}'; + $("#comment-edit-text-" + id).removeClass("comment-edit-text-full"); + $("#comment-edit-text-" + id).addClass("comment-edit-text-empty"); + $("#mod-cmnt-wrap-" + id).hide(); + closeMenu("comment-edit-submit-wrapper-" + id); + return true; + } + return false; +} + +function showHideCommentBox(id) { + if( $('#comment-edit-form-' + id).is(':visible')) { + $('#comment-edit-form-' + id).hide(); + } + else { + $('#comment-edit-form-' + id).show(); + } +} diff --git a/js/theme.js b/js/theme.js index de3617a8a..c0eed6b40 100644 --- a/js/theme.js +++ b/js/theme.js @@ -281,54 +281,6 @@ function qOrAmp(url) { } } -function insertFormatting(comment,BBcode,id) { - - var tmpStr = $("#comment-edit-text-" + id).val(); - if(tmpStr == comment) { - tmpStr = ""; - $("#comment-edit-text-" + id).addClass("comment-edit-text-full"); - $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty"); - openMenu("comment-edit-submit-wrapper-" + id); - $("#comment-edit-text-" + id).val(tmpStr); - } - - textarea = document.getElementById("comment-edit-text-" +id); - if (document.selection) { - textarea.focus(); - selected = document.selection.createRange(); - if (BBcode == "url"){ - selected.text = "["+BBcode+"]" + "http://" + selected.text + "[/"+BBcode+"]"; - } else - selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]"; - } else if (textarea.selectionStart || textarea.selectionStart == "0") { - var start = textarea.selectionStart; - var end = textarea.selectionEnd; - if (BBcode == "url"){ - textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + "http://" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length); - } else - textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length); - } - return true; -} - - -function showThread(id) { - $("#collapsed-comments-" + id).show() - $("#collapsed-comments-" + id + " .collapsed-comments").show() -} -function hideThread(id) { - $("#collapsed-comments-" + id).hide() - $("#collapsed-comments-" + id + " .collapsed-comments").hide() -} - - -function cmtBbOpen(id) { - $("#comment-edit-bb-" + id).show(); -} -function cmtBbClose(id) { - $("#comment-edit-bb-" + id).hide(); -} - function contact_filter(item) { // get the html content from the js template of the contact-wrapper contact_tpl = unescape($(".javascript-template[rel=contact-template]").html()); diff --git a/php/modes/default.php b/php/modes/default.php index 182dcfa98..e5971aefa 100644 --- a/php/modes/default.php +++ b/php/modes/default.php @@ -17,7 +17,6 @@ <?php if(x($page,'title')) echo $page['title'] ?> - @@ -110,60 +109,7 @@ else