mirror of
https://github.com/friendica/friendica
synced 2025-04-26 03:50:12 +00:00
frio: formating, otherwise untouched
This commit is contained in:
parent
cb24e8987c
commit
91d3e72be7
25 changed files with 3300 additions and 2937 deletions
|
@ -2,13 +2,13 @@
|
|||
/**
|
||||
* Contains functions for bootstrap modal handling.
|
||||
*/
|
||||
$(document).ready(function(){
|
||||
$(document).ready(function () {
|
||||
// Clear bs modal on close.
|
||||
// We need this to prevent that the modal displays old content.
|
||||
$('body, footer').on('hidden.bs.modal', '.modal', function () {
|
||||
$(this).removeData('bs.modal');
|
||||
$("body, footer").on("hidden.bs.modal", ".modal", function () {
|
||||
$(this).removeData("bs.modal");
|
||||
$("#modal-title").empty();
|
||||
$('#modal-body').empty();
|
||||
$("#modal-body").empty();
|
||||
// Remove the file browser from jot (else we would have problems
|
||||
// with AjaxUpload.
|
||||
$(".fbrowser").remove();
|
||||
|
@ -18,20 +18,20 @@ $(document).ready(function(){
|
|||
|
||||
// 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", function () {
|
||||
// Restore cached jot at its hidden position ("#jot-content").
|
||||
$("#jot-content").append(jotcache);
|
||||
// Clear the jotcache.
|
||||
jotcache = '';
|
||||
jotcache = "";
|
||||
// Destroy the attachment linkPreviw for Jot.
|
||||
if (typeof linkPreview === 'object') {
|
||||
if (typeof linkPreview === "object") {
|
||||
linkPreview.destroy();
|
||||
}
|
||||
});
|
||||
|
||||
// Add Colorbox for viewing Network page images.
|
||||
//var cBoxClasses = new Array();
|
||||
$("body").on("click", ".wall-item-body a img", function(){
|
||||
$("body").on("click", ".wall-item-body a img", function () {
|
||||
var aElem = $(this).parent();
|
||||
var imgHref = aElem.attr("href");
|
||||
|
||||
|
@ -39,51 +39,50 @@ $(document).ready(function(){
|
|||
// We'll try to do this by looking for links of the form
|
||||
// .../photo/ab803d8eg08daf85023adfec08 (with nothing more following), in hopes
|
||||
// that that will be unique enough.
|
||||
if(imgHref.match(/\/photo\/[a-fA-F0-9]+(-[0-9]\.[\w]+?)?$/)) {
|
||||
|
||||
if (imgHref.match(/\/photo\/[a-fA-F0-9]+(-[0-9]\.[\w]+?)?$/)) {
|
||||
// Add a unique class to all the images of a certain post, to allow scrolling through
|
||||
var cBoxClass = $(this).closest(".wall-item-body").attr("id") + "-lightbox";
|
||||
$(this).addClass(cBoxClass);
|
||||
|
||||
// if( $.inArray(cBoxClass, cBoxClasses) < 0 ) {
|
||||
// cBoxClasses.push(cBoxClass);
|
||||
// }
|
||||
// if( $.inArray(cBoxClass, cBoxClasses) < 0 ) {
|
||||
// cBoxClasses.push(cBoxClass);
|
||||
// }
|
||||
|
||||
aElem.colorbox({
|
||||
maxHeight: '90%',
|
||||
maxHeight: "90%",
|
||||
photo: true, // Colorbox doesn't recognize a URL that don't end in .jpg, etc. as a photo.
|
||||
rel: cBoxClass //$(this).attr("class").match(/wall-item-body-[\d]+-lightbox/)[0].
|
||||
rel: cBoxClass, //$(this).attr("class").match(/wall-item-body-[\d]+-lightbox/)[0].
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Navbar login.
|
||||
$("body").on("click", "#nav-login", function(e){
|
||||
$("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 .jot-nav-lnk", function(e){
|
||||
$("body").on("click", "#jot-modal .jot-nav li .jot-nav-lnk", function (e) {
|
||||
e.preventDefault();
|
||||
toggleJotNav(this);
|
||||
});
|
||||
|
||||
// Bookmarklet page needs an jot modal which appears automatically.
|
||||
if(window.location.pathname.indexOf("/bookmarklet") >=0 && $("#jot-modal").length){
|
||||
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(){
|
||||
$("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) {
|
||||
$("body").on("fbrowser.image.input", function (e, filename, embedcode, id, img) {
|
||||
// Select the clicked button by it's attribute.
|
||||
var elm = $("[image-input='select']");
|
||||
// Select the input field which belongs to this button.
|
||||
|
@ -92,15 +91,14 @@ $(document).ready(function(){
|
|||
elm.removeAttr("image-input");
|
||||
// Insert the link from the image into the input field.
|
||||
input.val(img);
|
||||
|
||||
});
|
||||
|
||||
// Generic delegated event to open an anchor URL in a modal.
|
||||
// Used in the hovercard.
|
||||
document.getElementsByTagName('body')[0].addEventListener('click', function(e) {
|
||||
document.getElementsByTagName("body")[0].addEventListener("click", function (e) {
|
||||
var target = e.target;
|
||||
while (target) {
|
||||
if (target.matches && target.matches('a.add-to-modal')) {
|
||||
if (target.matches && target.matches("a.add-to-modal")) {
|
||||
addToModal(target.href);
|
||||
e.preventDefault();
|
||||
return false;
|
||||
|
@ -112,55 +110,53 @@ $(document).ready(function(){
|
|||
});
|
||||
|
||||
// Overwrite Dialog.show from main js to load the filebrowser into a bs modal.
|
||||
Dialog.show = function(url, title) {
|
||||
if (typeof(title) === 'undefined') {
|
||||
Dialog.show = function (url, title) {
|
||||
if (typeof title === "undefined") {
|
||||
title = "";
|
||||
}
|
||||
|
||||
var modal = $('#modal').modal();
|
||||
var modal = $("#modal").modal();
|
||||
modal.find("#modal-header h4").html(title);
|
||||
modal
|
||||
.find('#modal-body')
|
||||
.load(url, function (responseText, textStatus) {
|
||||
if ( textStatus === 'success' ||
|
||||
textStatus === 'notmodified')
|
||||
{
|
||||
modal.show();
|
||||
modal.find("#modal-body").load(url, function (responseText, textStatus) {
|
||||
if (textStatus === "success" || textStatus === "notmodified") {
|
||||
modal.show();
|
||||
|
||||
$(function() {Dialog._load(url);});
|
||||
}
|
||||
});
|
||||
$(function () {
|
||||
Dialog._load(url);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// Overwrite the function _get_url from main.js.
|
||||
Dialog._get_url = function(type, name, id) {
|
||||
Dialog._get_url = function (type, name, id) {
|
||||
var hash = name;
|
||||
if (id !== undefined) hash = hash + "-" + id;
|
||||
return "fbrowser/"+type+"/?mode=none&theme=frio#"+hash;
|
||||
return "fbrowser/" + type + "/?mode=none&theme=frio#" + hash;
|
||||
};
|
||||
|
||||
// Does load the filebrowser into the jot modal.
|
||||
Dialog.showJot = function() {
|
||||
Dialog.showJot = function () {
|
||||
var type = "image";
|
||||
var name = "main";
|
||||
|
||||
var url = Dialog._get_url(type, name);
|
||||
if(($(".modal-body #jot-fbrowser-wrapper .fbrowser").length) < 1 ) {
|
||||
if ($(".modal-body #jot-fbrowser-wrapper .fbrowser").length < 1) {
|
||||
// Load new content to fbrowser window.
|
||||
$("#jot-fbrowser-wrapper").load(url,function(responseText, textStatus){
|
||||
if ( textStatus === 'success' ||
|
||||
textStatus === 'notmodified')
|
||||
{
|
||||
$(function() {Dialog._load(url);});
|
||||
$("#jot-fbrowser-wrapper").load(url, function (responseText, textStatus) {
|
||||
if (textStatus === "success" || textStatus === "notmodified") {
|
||||
$(function () {
|
||||
Dialog._load(url);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// Init the filebrowser after page load.
|
||||
Dialog._load = function(url) {
|
||||
Dialog._load = function (url) {
|
||||
// Get nickname & filebrowser type from the modal content.
|
||||
let filebrowser = document.getElementById('filebrowser');
|
||||
let filebrowser = document.getElementById("filebrowser");
|
||||
|
||||
// Try to fetch the hash form the url.
|
||||
let match = url.match(/fbrowser\/[a-z]+\/.*(#.*)/);
|
||||
|
@ -170,14 +166,14 @@ Dialog._load = function(url) {
|
|||
|
||||
// Initialize the filebrowser.
|
||||
loadScript("view/js/ajaxupload.js");
|
||||
loadScript("view/theme/frio/js/filebrowser.js", function() {
|
||||
loadScript("view/theme/frio/js/filebrowser.js", function () {
|
||||
FileBrowser.init(filebrowser.dataset.nickname, filebrowser.dataset.type, match[1]);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 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
|
||||
* moment or where it isn't possible because of design
|
||||
|
@ -195,22 +191,21 @@ function loadModalTitle() {
|
|||
title = $("#modal-body .heading").first().html();
|
||||
|
||||
// for event modals we need some speacial handling
|
||||
if($("#modal-body .event-wrapper .event-summary").length) {
|
||||
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").html();
|
||||
title = title + eventsum;
|
||||
}
|
||||
|
||||
// And append it to modal title.
|
||||
if (title!=="") {
|
||||
if (title !== "") {
|
||||
$("#modal-title").append(title);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This function loads html content from a friendica page into a modal.
|
||||
*
|
||||
*
|
||||
* @param {string} url The url with html content.
|
||||
* @param {string} id The ID of a html element (can be undefined).
|
||||
* @returns {void}
|
||||
|
@ -218,42 +213,35 @@ function loadModalTitle() {
|
|||
function addToModal(url, id) {
|
||||
var char = qOrAmp(url);
|
||||
|
||||
url = url + char + 'mode=none';
|
||||
var modal = $('#modal').modal();
|
||||
url = url + char + "mode=none";
|
||||
var modal = $("#modal").modal();
|
||||
|
||||
// Only search for an element if we have an ID.
|
||||
if (typeof id !== "undefined") {
|
||||
url = url + " div#" + id;
|
||||
}
|
||||
|
||||
modal
|
||||
.find('#modal-body')
|
||||
.load(url, function (responseText, textStatus) {
|
||||
if ( textStatus === 'success' ||
|
||||
textStatus === 'notmodified')
|
||||
{
|
||||
modal.show();
|
||||
modal.find("#modal-body").load(url, function (responseText, textStatus) {
|
||||
if (textStatus === "success" || textStatus === "notmodified") {
|
||||
modal.show();
|
||||
|
||||
//Get first element with the class "heading"
|
||||
//and use it as title.
|
||||
loadModalTitle();
|
||||
//Get first element with the class "heading"
|
||||
//and use it as title.
|
||||
loadModalTitle();
|
||||
|
||||
// We need to initialize autosize again for new
|
||||
// modal conent.
|
||||
autosize($('.modal .text-autosize'));
|
||||
}
|
||||
});
|
||||
// We need to initialize autosize again for new
|
||||
// modal conent.
|
||||
autosize($(".modal .text-autosize"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Add an element (by its id) to a bootstrap modal.
|
||||
function addElmToModal(id) {
|
||||
var elm = $(id).html();
|
||||
var modal = $('#modal').modal();
|
||||
var modal = $("#modal").modal();
|
||||
|
||||
modal
|
||||
.find('#modal-body')
|
||||
.append(elm)
|
||||
.modal.show;
|
||||
modal.find("#modal-body").append(elm).modal.show;
|
||||
|
||||
loadModalTitle();
|
||||
}
|
||||
|
@ -269,12 +257,12 @@ function editpost(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) {
|
||||
if (splitURL.path.indexOf("events/event") > -1) {
|
||||
addToModal(splitURL.path);
|
||||
return;
|
||||
}
|
||||
|
||||
var modal = $('#jot-modal').modal();
|
||||
var modal = $("#jot-modal").modal();
|
||||
url = url + " #jot-sections";
|
||||
|
||||
$(".jot-nav .jot-perms-lnk").parent("li").addClass("hidden");
|
||||
|
@ -293,34 +281,29 @@ function editpost(url) {
|
|||
|
||||
jotreset();
|
||||
|
||||
modal
|
||||
.find('#jot-modal-content')
|
||||
.load(url, function (responseText, textStatus) {
|
||||
if ( textStatus === 'success' ||
|
||||
textStatus === 'notmodified')
|
||||
{
|
||||
// get the item type and hide the input for title and category if it isn't needed.
|
||||
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();
|
||||
}
|
||||
|
||||
modal.show();
|
||||
$("#jot-popup").show();
|
||||
linkPreview = $('#profile-jot-text').linkPreview();
|
||||
modal.find("#jot-modal-content").load(url, function (responseText, textStatus) {
|
||||
if (textStatus === "success" || textStatus === "notmodified") {
|
||||
// get the item type and hide the input for title and category if it isn't needed.
|
||||
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();
|
||||
}
|
||||
});
|
||||
|
||||
modal.show();
|
||||
$("#jot-popup").show();
|
||||
linkPreview = $("#profile-jot-text").linkPreview();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Remove content from the jot modal.
|
||||
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.edit-jot', function () {
|
||||
$(this).removeData('bs.modal');
|
||||
$("body").on("hidden.bs.modal", "#jot-modal.edit-jot", function () {
|
||||
$(this).removeData("bs.modal");
|
||||
$(".jot-nav .jot-perms-lnk").parent("li").removeClass("hidden");
|
||||
$("#profile-jot-form #jot-title-wrap").show();
|
||||
$("#profile-jot-form #jot-category-wrap").show();
|
||||
|
@ -332,7 +315,7 @@ function jotreset() {
|
|||
}
|
||||
|
||||
// Give the active "jot-nav" list element the class "active".
|
||||
function toggleJotNav (elm) {
|
||||
function toggleJotNav(elm) {
|
||||
// Get the ID of the tab panel which should be activated.
|
||||
var tabpanel = elm.getAttribute("aria-controls");
|
||||
var cls = hasClass(elm, "jot-nav-lnk-mobile");
|
||||
|
@ -344,8 +327,10 @@ function toggleJotNav (elm) {
|
|||
|
||||
// Minimize all tab content wrapper and activate only the selected
|
||||
// tab panel.
|
||||
$('#profile-jot-form > [role=tabpanel]').addClass("minimize").attr("aria-hidden" ,"true");
|
||||
$('#' + tabpanel).removeClass("minimize").attr("aria-hidden" ,"false");
|
||||
$("#profile-jot-form > [role=tabpanel]").addClass("minimize").attr("aria-hidden", "true");
|
||||
$("#" + tabpanel)
|
||||
.removeClass("minimize")
|
||||
.attr("aria-hidden", "false");
|
||||
|
||||
// Set the aria-selected states
|
||||
$("#jot-modal .modal-header .nav-tabs .jot-nav-lnk").attr("aria-selected", "false");
|
||||
|
@ -355,9 +340,9 @@ function toggleJotNav (elm) {
|
|||
if (tabpanel === "jot-preview-content") {
|
||||
preview_post();
|
||||
// Make Share button visivle in preview
|
||||
$('#jot-preview-share').removeClass("minimize").attr("aria-hidden" ,"false");
|
||||
$("#jot-preview-share").removeClass("minimize").attr("aria-hidden", "false");
|
||||
} else if (tabpanel === "jot-fbrowser-wrapper") {
|
||||
$(function() {
|
||||
$(function () {
|
||||
Dialog.showJot();
|
||||
});
|
||||
}
|
||||
|
@ -377,7 +362,7 @@ function openWallMessage(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)) {
|
||||
if ("host" in parts && parts.host !== window.location.host) {
|
||||
window.location.href = url;
|
||||
} else {
|
||||
// Otherwise load the wall message into a modal.
|
||||
|
@ -389,12 +374,12 @@ function openWallMessage(url) {
|
|||
/// @todo Rename this function because it can be used for more than events.
|
||||
function eventEdit(url) {
|
||||
var char = qOrAmp(url);
|
||||
url = url + char + 'mode=none';
|
||||
url = url + char + "mode=none";
|
||||
|
||||
$.get(url, function(data) {
|
||||
$.get(url, function (data) {
|
||||
$("#modal-body").empty();
|
||||
$("#modal-body").append(data);
|
||||
}).done(function() {
|
||||
}).done(function () {
|
||||
loadModalTitle();
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue