$(".fbrowser").remove();
});
- // Add Colorbox for viewing Network page images
+ // Clear bs modal on close
+ // We need this to prevent that the modal displays old content
+ $('body').on('hidden.bs.modal', '#jot-modal', function () {
+ // restore cached jot at its hidden position ("#jot-content")
+ $("#jot-content").append(jotcache);
+ // clear the jotcache
+ jotcache = '';
+ });
+
+ // Add Colorbox for viewing Network page images
//var cBoxClasses = new Array();
$("body").on("click", ".wall-item-body a img", function(){
var aElem = $(this).parent();
}
});
-
+ // Navbar login
+ $("body").on("click", "#nav-login", function(e){
+ e.preventDefault();
+ Dialog.show(this.href, this.dataset.originalTitle || this.title);
+ });
// Jot nav menu.
$("body").on("click", "#jot-modal .jot-nav li a", function(e){
toggleJotNav(this);
});
+ // bookmarklet page needs an jot modal which appears automatically
+ if(window.location.pathname.indexOf("/bookmarklet") >=0 && $("#jot-modal").length){
+ jotShow();
+ }
+
// Open filebrowser for elements with the class "image-select"
// The following part handles the filebrowser for field_fileinput.tpl
- $("body").on("click", ".image-select", function(e){
+ $("body").on("click", ".image-select", function(){
// set a extra attribute to mark the clicked button
this.setAttribute("image-input", "select");
Dialog.doImageBrowser("input");
// Insert filebrowser images into the input field (field_fileinput.tpl)
$("body").on("fbrowser.image.input", function(e, filename, embedcode, id, img) {
// select the clicked button by it's attribute
- var elm = $("[image-input='select']")
+ var elm = $("[image-input='select']");
// select the input field which belongs to this button
var input = elm.parent(".input-group").children("input");
// remove the special indicator attribut from the button
});
// overwrite Dialog.show from main js to load the filebrowser into a bs modal
-Dialog.show = function(url) {
+Dialog.show = function(url, title) {
+ if (typeof(title) === 'undefined') {
+ title = "";
+ }
+
var modal = $('#modal').modal();
+ modal.find("#modal-header h4").html(title);
modal
.find('#modal-body')
.load(url, function (responseText, textStatus) {
// try to fetch the hash form the url
var match = url.match(/fbrowser\/[a-z]+\/\?mode=none(.*)/);
+ if (match===null) return; //not fbrowser
var hash = match[1];
// initialize the filebrowser
var jsbrowser = function() {
FileBrowser.init(nickname, type, hash);
- }
+ };
loadScript("view/theme/frio/js/filebrowser.js", jsbrowser);
};
/**
- * @brief Add first h3 element as modal title
+ * @brief Add first element with the class "heading" as modal title
*
* Note: this should be really done in the template
* and is the solution where we havent done it until this
*/
function loadModalTitle() {
// clear the text of the title
- //$("#modal-title").empty();
+ $("#modal-title").empty();
- // hide the first h3 child element of the modal body
+ // hide the first element with the class "heading" of the modal body
$("#modal-body .heading").first().hide();
- // get the text of the first element with heading class
- var title = $("#modal-body .heading").first().text();
+ var title = "";
+
+ // get the text of the first element with "heading" class
+ title = $("#modal-body .heading").first().text();
+
+ // for event modals we need some speacial handling
+ if($("#modal-body .event-wrapper .event-summary").length) {
+ title = '<i class="fa fa-calendar" aria-hidden="true"></i> ';
+ var eventsum = $("#modal-body .event-wrapper .event-summary").text();
+ title = title + eventsum;
+ }
// and append it to modal title
if (title!=="") {
function addToModal(url) {
var char = qOrAmp(url);
- var url = url + char + 'mode=none';
+ url = url + char + 'mode=none';
var modal = $('#modal').modal();
modal
{
modal.show();
- //Get first h3 element and use it as title
+ //Get first element with the class "heading"
+ //and use it as title
loadModalTitle();
}
});
-};
+}
+
+// Add a element (by it's id) to a bootstrap modal
+function addElmToModal(id) {
+ var elm = $(id).html();
+ var modal = $('#modal').modal();
+
+ modal
+ .find('#modal-body')
+ .append(elm)
+ .modal.show;
+
+ loadModalTitle();
+}
// function to load the html from the edit post page into
// the jot modal
function editpost(url) {
+ // next to normel posts the post can be an event post. The event posts don't
+ // use the normal Jot modal. For event posts we will use a normal modal
+ // But first we have to test if the url links to an event. So we will split up
+ // the url in its parts
+ var splitURL = parseUrl(url);
+ // Test if in the url path containing "events/event". If the path containing this
+ // expression then we will call the addToModal function and exit this function at
+ // this point
+ if (splitURL.path.indexOf('events/event') > -1) {
+ addToModal(splitURL.path);
+ return;
+ }
+
var modal = $('#jot-modal').modal();
- var url = url + " #profile-jot-form";
+ url = url + " #jot-sections";
+
//var rand_num = random_digits(12);
- $(".jot-nav #jot-perms-lnk").parent("li").hide();
-
- // rename the the original div jot-preview-content because the edit function
- // does load the content for the modal from another source and preview won't work
- // if this div would exist twice
- // $("#jot-content #profile-jot-form").attr("id","#profile-jot-form-renamed");
- // $("#jot-content #jot-preview-content").attr("id","#jot-preview-content-renamed");
-
- // For editpost we load the modal html form the edit page. So we would have two jot forms in
- // the page html. To avoid js conflicts we move the original jot to the end of the page
- // so the editpost jot would be the first jot in html structure.
- // After closing the modal we move the original jot back to it's orginal position in the html structure.
- //
- // Note: For now it seems to work but this isn't optimal because we have doubled ID names for the jot div's.
- // We need to have a better solution for this in the future.
- $("section #jot-content #profile-jot-form").appendTo("footer #cache-container");
+ $(".jot-nav .jot-perms-lnk").parent("li").addClass("hidden");
+
+ // For editpost we load the modal html of "jot-sections" of the edit page. So we would have two jot forms in
+ // the page html. To avoid js conflicts we store the original jot in the variable jotcache.
+ // After closing the modal original jot should be restored at its orginal position in the html structure.
+ jotcache = $("#jot-content > #jot-sections");
+
+ // remove the original Jot as long as the edit Jot is open
+ jotcache.remove();
+
+ // add the class "edit" to the modal to have some kind of identifier to
+ // have the possibility to e.g. put special event-listener
+ $("#jot-modal").addClass("edit-jot");
jotreset();
modal
- .find('#jot-modal-body')
+ .find('#jot-modal-content')
.load(url, function (responseText, textStatus) {
if ( textStatus === 'success' ||
textStatus === 'notmodified')
var type = $(responseText).find("#profile-jot-form input[name='type']").val();
if(type === "wall-comment" || type === "remote-comment")
{
+ // hide title and category input fields because we don't
$("#profile-jot-form #jot-title-wrap").hide();
$("#profile-jot-form #jot-category-wrap").hide();
}
function jotreset() {
// Clear bs modal on close
// We need this to prevent that the modal displays old content
- $('body').on('hidden.bs.modal', '#jot-modal', function () {
+ $('body').on('hidden.bs.modal', '#jot-modal.edit-jot', function () {
$(this).removeData('bs.modal');
- $(".jot-nav #jot-perms-lnk").parent("li").show();
+ $(".jot-nav .jot-perms-lnk").parent("li").removeClass("hidden");
$("#profile-jot-form #jot-title-wrap").show();
$("#profile-jot-form #jot-category-wrap").show();
// $( "#profile-jot-form input[name='type']" ).val("wall");
// $( "#profile-jot-form input[name='post_id']" ).val("");
// $( "#profile-jot-form input[name='post_id_random']" ).val(rand_num);
- $("#jot-modal-body").empty();
-
- // rename the div #jot-preview-content-renamed back to it's original
- // name. Have a look at function editpost() for further explanation
- //$("#jot-content #profile-jot-form-renamed").attr("id","#profile-jot-form");
- //$("#jot-content #jot-preview-content-renamed").attr("id","#jot-preview-content");
- // Move the original jot back to it's old place in the html structure
- // For explaination have a look at function editpost()
- $("footer #cache-container #profile-jot-form").appendTo("section #jot-content");
- });
+ // remove the "edit-jot" class so we can the standard behavior on close
+ $("#jot-modal.edit-jot").removeClass("edit-jot");
+ $("#jot-modal-content").empty();
+ });
}
// Give the active "jot-nav" list element the class "active"
function toggleJotNav (elm) {
// select all li of jot-nav and remove the active class
- $(elm).closest(".jot-nav").children("li").removeClass("active");
+ $(".jot-nav li").removeClass("active");
// add the active class to the parent of the link which was selected
$(elm).parent("li").addClass("active");
}
+// Wall Message needs a special handling because in some cases
+// it redirects you to your own server. In such cases we can't
+// load it into a modal
+function openWallMessage(url) {
+ // split the the url in its parts
+ var parts = parseUrl(url);
+
+ // If the host isn't the same we can't load it in a modal.
+ // So we will go to to the url directly
+ if( ("host" in parts) && (parts.host !== window.location.host)) {
+ window.location.href = url;
+ } else {
+ // otherwise load the wall message into a modal
+ addToModal(url);
+ }
+}