{{/foreach}}
+
+ {{* Switch between image and file mode *}}
@@ -25,6 +28,8 @@
+
+ {{* List of photo albums *}}
{{if $folders }}
@@ -33,6 +38,7 @@
{{/if}}
+ {{* The main content (images or files) *}}
{{foreach $files as $f}}
@@ -48,9 +54,11 @@
-
+
+
+ {{* This part contains the conent loader icon which is visible when new conent is loaded *}}
From a2ad01383082a01eb540ffa6c89c82519fec7b11 Mon Sep 17 00:00:00 2001
From: rabuzarus <>
Date: Sat, 25 Mar 2017 19:12:16 +0100
Subject: [PATCH 05/19] some work on code standards compliance
---
mod/wall_upload.php | 153 ++++++++++++++++++------------
view/theme/frio/js/filebrowser.js | 18 ++--
2 files changed, 103 insertions(+), 68 deletions(-)
diff --git a/mod/wall_upload.php b/mod/wall_upload.php
index 2f3bd1415..3e88bd76b 100644
--- a/mod/wall_upload.php
+++ b/mod/wall_upload.php
@@ -1,18 +1,30 @@
argc > 1) {
- if(! x($_FILES,'media')) {
+ if ($a->argc > 1) {
+ if (! x($_FILES, 'media')) {
$nick = $a->argv[1];
- $r = q("SELECT `user`.*, `contact`.`id` FROM `user` INNER JOIN `contact` on `user`.`uid` = `contact`.`uid` WHERE `user`.`nickname` = '%s' AND `user`.`blocked` = 0 and `contact`.`self` = 1 LIMIT 1",
+ $r = q("SELECT `user`.*, `contact`.`id` FROM `user`
+ INNER JOIN `contact` on `user`.`uid` = `contact`.`uid`
+ WHERE `user`.`nickname` = '%s' AND `user`.`blocked` = 0
+ AND `contact`.`self` = 1 LIMIT 1",
dbesc($nick)
);
@@ -25,7 +37,10 @@ function wall_upload_post(App $a, $desktopmode = true) {
}
} else {
$user_info = api_get_user($a);
- $r = q("SELECT `user`.*, `contact`.`id` FROM `user` INNER JOIN `contact` on `user`.`uid` = `contact`.`uid` WHERE `user`.`nickname` = '%s' AND `user`.`blocked` = 0 and `contact`.`self` = 1 LIMIT 1",
+ $r = q("SELECT `user`.*, `contact`.`id` FROM `user`
+ INNER JOIN `contact` on `user`.`uid` = `contact`.`uid`
+ WHERE `user`.`nickname` = '%s' AND `user`.`blocked` = 0
+ AND `contact`.`self` = 1 LIMIT 1",
dbesc($user_info['screen_name'])
);
}
@@ -37,6 +52,9 @@ function wall_upload_post(App $a, $desktopmode = true) {
return;
}
+ /*
+ * Setup permissions structures
+ */
$can_post = false;
$visitor = 0;
@@ -45,22 +63,24 @@ function wall_upload_post(App $a, $desktopmode = true) {
$page_owner_nick = $r[0]['nickname'];
$community_page = (($r[0]['page-flags'] == PAGE_COMMUNITY) ? true : false);
- if((local_user()) && (local_user() == $page_owner_uid))
+ if ((local_user()) && (local_user() == $page_owner_uid)) {
$can_post = true;
- else {
- if($community_page && remote_user()) {
+ } else {
+ if ($community_page && remote_user()) {
$contact_id = 0;
- if(is_array($_SESSION['remote'])) {
- foreach($_SESSION['remote'] as $v) {
- if($v['uid'] == $page_owner_uid) {
+ if (is_array($_SESSION['remote'])) {
+ foreach ($_SESSION['remote'] as $v) {
+ if ($v['uid'] == $page_owner_uid) {
$contact_id = $v['cid'];
break;
}
}
}
- if($contact_id) {
- $r = q("SELECT `uid` FROM `contact` WHERE `blocked` = 0 AND `pending` = 0 AND `id` = %d AND `uid` = %d LIMIT 1",
+ if ($contact_id) {
+ $r = q("SELECT `uid` FROM `contact`
+ WHERE `blocked` = 0 AND `pending` = 0
+ AND `id` = %d AND `uid` = %d LIMIT 1",
intval($contact_id),
intval($page_owner_uid)
);
@@ -73,16 +93,16 @@ function wall_upload_post(App $a, $desktopmode = true) {
}
- if(! $can_post) {
+ if (! $can_post) {
if ($r_json) {
echo json_encode(array('error'=>t('Permission denied.')));
killme();
}
- notice( t('Permission denied.') . EOL );
+ notice(t('Permission denied.') . EOL);
killme();
}
- if(! x($_FILES,'userfile') && ! x($_FILES,'media')){
+ if (! x($_FILES, 'userfile') && ! x($_FILES, 'media')) {
if ($r_json) {
echo json_encode(array('error'=>t('Invalid request.')));
}
@@ -90,32 +110,36 @@ function wall_upload_post(App $a, $desktopmode = true) {
}
$src = "";
- if(x($_FILES,'userfile')) {
+ if (x($_FILES, 'userfile')) {
$src = $_FILES['userfile']['tmp_name'];
$filename = basename($_FILES['userfile']['name']);
$filesize = intval($_FILES['userfile']['size']);
$filetype = $_FILES['userfile']['type'];
- }
- elseif(x($_FILES,'media')) {
- if (is_array($_FILES['media']['tmp_name']))
+
+ } elseif (x($_FILES, 'media')) {
+ if (is_array($_FILES['media']['tmp_name'])) {
$src = $_FILES['media']['tmp_name'][0];
- else
+ } else {
$src = $_FILES['media']['tmp_name'];
+ }
- if (is_array($_FILES['media']['name']))
+ if (is_array($_FILES['media']['name'])) {
$filename = basename($_FILES['media']['name'][0]);
- else
+ } else {
$filename = basename($_FILES['media']['name']);
+ }
- if (is_array($_FILES['media']['size']))
+ if (is_array($_FILES['media']['size'])) {
$filesize = intval($_FILES['media']['size'][0]);
- else
+ } else {
$filesize = intval($_FILES['media']['size']);
+ }
- if (is_array($_FILES['media']['type']))
+ if (is_array($_FILES['media']['type'])) {
$filetype = $_FILES['media']['type'][0];
- else
+ } else {
$filetype = $_FILES['media']['type'];
+ }
}
if ($src=="") {
@@ -128,28 +152,30 @@ function wall_upload_post(App $a, $desktopmode = true) {
}
// This is a special treatment for picture upload from Twidere
- if (($filename == "octet-stream") AND ($filetype != "")) {
+ if (($filename == "octet-stream") && ($filetype != "")) {
$filename = $filetype;
$filetype = "";
}
- if ($filetype=="")
+ if ($filetype=="") {
$filetype=guess_image_type($filename);
+ }
// If there is a temp name, then do a manual check
// This is more reliable than the provided value
$imagedata = getimagesize($src);
- if ($imagedata)
+ if ($imagedata) {
$filetype = $imagedata['mime'];
+ }
- logger("File upload src: ".$src." - filename: ".$filename.
- " - size: ".$filesize." - type: ".$filetype, LOGGER_DEBUG);
+ logger("File upload src: " . $src . " - filename: " . $filename .
+ " - size: " . $filesize . " - type: " . $filetype, LOGGER_DEBUG);
- $maximagesize = get_config('system','maximagesize');
+ $maximagesize = get_config('system', 'maximagesize');
- if(($maximagesize) && ($filesize > $maximagesize)) {
- $msg = sprintf( t('Image exceeds size limit of %s'), formatBytes($maximagesize));
+ if (($maximagesize) && ($filesize > $maximagesize)) {
+ $msg = sprintf(t('Image exceeds size limit of %s'), formatBytes($maximagesize));
if ($r_json) {
echo json_encode(array('error'=>$msg));
} else {
@@ -160,10 +186,12 @@ function wall_upload_post(App $a, $desktopmode = true) {
}
- $limit = service_class_fetch($page_owner_uid,'photo_upload_limit');
+ $limit = service_class_fetch($page_owner_uid, 'photo_upload_limit');
if ($limit) {
- $r = q("select sum(octet_length(data)) as total from photo where uid = %d and scale = 0 and album != 'Contact Photos' ",
+ $r = q("SELECT SUM(OCTET_LENGTH(`data`)) AS `total` FROM `photo`
+ WHERE `uid` = %d AND `scale` = 0
+ AND `album` != 'Contact Photos' ",
intval($page_owner_uid)
);
$size = $r[0]['total'];
@@ -183,7 +211,7 @@ function wall_upload_post(App $a, $desktopmode = true) {
$imagedata = @file_get_contents($src);
$ph = new Photo($imagedata, $filetype);
- if(! $ph->is_valid()) {
+ if (! $ph->is_valid()) {
$msg = t('Unable to process image.');
if ($r_json) {
echo json_encode(array('error'=>$msg));
@@ -197,12 +225,13 @@ function wall_upload_post(App $a, $desktopmode = true) {
$ph->orient($src);
@unlink($src);
- $max_length = get_config('system','max_image_length');
- if(! $max_length)
+ $max_length = get_config('system', 'max_image_length');
+ if (! $max_length) {
$max_length = MAX_IMAGE_LENGTH;
- if($max_length > 0) {
+ }
+ if ($max_length > 0) {
$ph->scaleImage($max_length);
- logger("File upload: Scaling picture to new size ".$max_length, LOGGER_DEBUG);
+ logger("File upload: Scaling picture to new size " . $max_length, LOGGER_DEBUG);
}
$width = $ph->getWidth();
@@ -221,7 +250,7 @@ function wall_upload_post(App $a, $desktopmode = true) {
$r = $ph->store($page_owner_uid, $visitor, $hash, $filename, $album, 0, 0, $defperm);
- if(! $r) {
+ if (! $r) {
$msg = t('Image upload failed.');
if ($r_json) {
echo json_encode(array('error'=>$msg));
@@ -231,26 +260,31 @@ function wall_upload_post(App $a, $desktopmode = true) {
killme();
}
- if($width > 640 || $height > 640) {
+ if ($width > 640 || $height > 640) {
$ph->scaleImage(640);
$r = $ph->store($page_owner_uid, $visitor, $hash, $filename, $album, 1, 0, $defperm);
- if($r)
+ if ($r) {
$smallest = 1;
+ }
}
- if($width > 320 || $height > 320) {
+ if ($width > 320 || $height > 320) {
$ph->scaleImage(320);
$r = $ph->store($page_owner_uid, $visitor, $hash, $filename, $album, 2, 0, $defperm);
- if($r AND ($smallest == 0))
+ if ($r && ($smallest == 0)) {
$smallest = 2;
+ }
}
$basename = basename($filename);
if (!$desktopmode) {
-
- $r = q("SELECT `id`, `datasize`, `width`, `height`, `type` FROM `photo` WHERE `resource-id` = '%s' ORDER BY `width` DESC LIMIT 1", $hash);
- if (!$r){
+ $r = q("SELECT `id`, `datasize`, `width`, `height`, `type` FROM `photo`
+ WHERE `resource-id` = '%s'
+ ORDER BY `width` DESC LIMIT 1",
+ $hash
+ );
+ if (!$r) {
if ($r_json) {
echo json_encode(array('error'=>''));
killme();
@@ -259,14 +293,14 @@ function wall_upload_post(App $a, $desktopmode = true) {
}
$picture = array();
- $picture["id"] = $r[0]["id"];
- $picture["size"] = $r[0]["datasize"];
- $picture["width"] = $r[0]["width"];
- $picture["height"] = $r[0]["height"];
- $picture["type"] = $r[0]["type"];
- $picture["albumpage"] = App::get_baseurl().'/photos/'.$page_owner_nick.'/image/'.$hash;
- $picture["picture"] = App::get_baseurl()."/photo/{$hash}-0.".$ph->getExt();
- $picture["preview"] = App::get_baseurl()."/photo/{$hash}-{$smallest}.".$ph->getExt();
+ $picture["id"] = $r[0]["id"];
+ $picture["size"] = $r[0]["datasize"];
+ $picture["width"] = $r[0]["width"];
+ $picture["height"] = $r[0]["height"];
+ $picture["type"] = $r[0]["type"];
+ $picture["albumpage"] = App::get_baseurl() . '/photos/' . $page_owner_nick . '/image/' . $hash;
+ $picture["picture"] = App::get_baseurl() . "/photo/{$hash}-0." . $ph->getExt();
+ $picture["preview"] = App::get_baseurl() . "/photo/{$hash}-{$smallest}." . $ph->getExt();
if ($r_json) {
echo json_encode(array('picture'=>$picture));
@@ -282,7 +316,6 @@ function wall_upload_post(App $a, $desktopmode = true) {
}
/* mod Waitman Gobble NO WARRANTY */
-
// if we get the signal then return the image url info in BBCODE
if ($_REQUEST['hush']!='yeah') {
echo "\n\n" . '[url=' . App::get_baseurl() . '/photos/' . $page_owner_nick . '/image/' . $hash . '][img]' . App::get_baseurl() . "/photo/{$hash}-{$smallest}.".$ph->getExt()."[/img][/url]\n\n";
diff --git a/view/theme/frio/js/filebrowser.js b/view/theme/frio/js/filebrowser.js
index 8617e8020..5985ac742 100644
--- a/view/theme/frio/js/filebrowser.js
+++ b/view/theme/frio/js/filebrowser.js
@@ -87,7 +87,7 @@ var FileBrowser = {
}
};
- console.log("FileBrowser:", nickname, type,FileBrowser.event, FileBrowser.id );
+ console.log("FileBrowser:", nickname, type,FileBrowser.event, FileBrowser.id);
FileBrowser.postLoad();
@@ -111,11 +111,11 @@ var FileBrowser = {
var embed = "";
if (FileBrowser.type == "image") {
- embed = "[url="+this.dataset.link+"][img]"+this.dataset.img+"[/img][/url]";
+ embed = "[url=" + this.dataset.link + "][img]" + this.dataset.img + "[/img][/url]";
}
if (FileBrowser.type == "file") {
// attachment links are "baseurl/attach/id"; we need id
- embed = "[attachment]"+this.dataset.link.split("/").pop()+"[/attachment]";
+ embed = "[attachment]" + this.dataset.link.split("/").pop() + "[/attachment]";
}
// Delete prefilled Text of the comment input
@@ -131,7 +131,9 @@ var FileBrowser = {
}
}
+
console.log(FileBrowser.event, this.dataset.filename, embed, FileBrowser.id);
+
parent.$("body").trigger(FileBrowser.event, [
this.dataset.filename,
embed,
@@ -164,16 +166,16 @@ var FileBrowser = {
//AjaxUpload for images
var image_uploader = new window.AjaxUpload(
'upload-image',
- { action: 'wall_upload/'+FileBrowser.nickname+'?response=json&album=' + albumname,
+ { action: 'wall_upload/' + FileBrowser.nickname + '?response=json&album=' + albumname,
name: 'userfile',
responseType: 'json',
- onSubmit: function(file,ext) {
+ onSubmit: function(file, ext) {
$(".fbrowser-content").hide();
$(".fbrowser .profile-rotator-wrapper").show();
$(".error").addClass('hidden');
},
onComplete: function(file,response) {
- if (response['error']!= undefined) {
+ if (response['error'] != undefined) {
$(".error span").html(response['error']);
$(".error").removeClass('hidden');
$(".fbrowser .profile-rotator-wrapper").hide();
@@ -197,7 +199,7 @@ var FileBrowser = {
'upload-file',
{ action: 'wall_attach/' + FileBrowser.nickname + '?response=json',
name: 'userfile',
- onSubmit: function(file,ext) {
+ onSubmit: function(file, ext) {
$(".fbrowser-content").hide();
$(".fbrowser .profile-rotator-wrapper").show();
$(".error").addClass('hidden');
@@ -238,7 +240,7 @@ var FileBrowser = {
$(".fbrowser .profile-rotator-wrapper").show();
// load new content to fbrowser window
- $(".fbrowser").load(url, function(responseText, textStatus){
+ $(".fbrowser").load(url, function(responseText, textStatus) {
$(".profile-rotator-wrapper").hide();
if (textStatus === 'success') {
$(".fbrowser_content").show();
From b6ab3bdd360dc6e326807a826855193b6d4b7726 Mon Sep 17 00:00:00 2001
From: rabuzarus <>
Date: Sat, 25 Mar 2017 21:07:12 +0100
Subject: [PATCH 06/19] make use of Config class
---
mod/wall_upload.php | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/mod/wall_upload.php b/mod/wall_upload.php
index 3e88bd76b..d29efecc6 100644
--- a/mod/wall_upload.php
+++ b/mod/wall_upload.php
@@ -9,8 +9,11 @@
* to the url
*/
+use \Friendica\Core\Config;
+
require_once 'include/Photo.php';
+
function wall_upload_post(App $a, $desktopmode = true) {
logger("wall upload: starting new upload", LOGGER_DEBUG);
@@ -172,7 +175,7 @@ function wall_upload_post(App $a, $desktopmode = true) {
logger("File upload src: " . $src . " - filename: " . $filename .
" - size: " . $filesize . " - type: " . $filetype, LOGGER_DEBUG);
- $maximagesize = get_config('system', 'maximagesize');
+ $maximagesize = Config::get('system', 'maximagesize');
if (($maximagesize) && ($filesize > $maximagesize)) {
$msg = sprintf(t('Image exceeds size limit of %s'), formatBytes($maximagesize));
@@ -225,7 +228,7 @@ function wall_upload_post(App $a, $desktopmode = true) {
$ph->orient($src);
@unlink($src);
- $max_length = get_config('system', 'max_image_length');
+ $max_length = Config::get('system', 'max_image_length');
if (! $max_length) {
$max_length = MAX_IMAGE_LENGTH;
}
From aeb999c4d9f4bbdf5e30a047c1e5f74992544420 Mon Sep 17 00:00:00 2001
From: rabuzarus <>
Date: Sat, 25 Mar 2017 23:33:53 +0100
Subject: [PATCH 07/19] enable fbrowser for mobile view
---
view/theme/frio/css/style.css | 9 ++++++++-
view/theme/frio/templates/jot.tpl | 4 +++-
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/view/theme/frio/css/style.css b/view/theme/frio/css/style.css
index 7f3d522a9..346abb02d 100644
--- a/view/theme/frio/css/style.css
+++ b/view/theme/frio/css/style.css
@@ -1290,8 +1290,11 @@ section #jotOpen {
padding-right: 1px;
}
.fbrowser .folders ul {
- padding-left: 0px;
+ padding: 0px;
margin-left: -15px;
+ margin-bottom: 0px;
+ overflow-y: auto;
+ max-height: calc(100vh - 210px);
}
.fbrowser .folders li {
padding-left: 20px;
@@ -1314,6 +1317,10 @@ section #jotOpen {
.fbrowser .folders + .list {
padding-left: 10px;
}
+.fbrowser .fbrowser-content-container {
+ overflow-y: auto;
+ max-height: calc(100vh - 175px);
+}
.fbrowser .profile-rotator-wrapper {
min-height: 200px;
}
diff --git a/view/theme/frio/templates/jot.tpl b/view/theme/frio/templates/jot.tpl
index 1436182b8..d461f733f 100644
--- a/view/theme/frio/templates/jot.tpl
+++ b/view/theme/frio/templates/jot.tpl
@@ -11,7 +11,7 @@
in with dropdows the close button needs to be inserted after the dropdown. *}}
- {{* The Jot navigation menu (text input, permissions, preview, filebrowser) *}}
+ {{* The Jot navigation menu for desktop user (text input, permissions, preview, filebrowser) *}}
{{* Mark the first list entry as active because it is the first which is active after opening
the modal. Changing of the activity status is done by js in jot.tpl-header *}}
@@ -21,6 +21,7 @@
From 9f37acc6d4fd71acc6625e5394d64e7be94cc34e Mon Sep 17 00:00:00 2001
From: rabuzarus <>
Date: Mon, 3 Apr 2017 14:00:27 +0200
Subject: [PATCH 13/19] add href attribute to jot links
---
view/theme/frio/templates/jot.tpl | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/view/theme/frio/templates/jot.tpl b/view/theme/frio/templates/jot.tpl
index 75a0cbc05..d9e2faf57 100644
--- a/view/theme/frio/templates/jot.tpl
+++ b/view/theme/frio/templates/jot.tpl
@@ -16,20 +16,20 @@
{{* Mark the first list entry as active because it is the first which is active after opening
the modal. Changing of the activity status is done by js in jot.tpl-header *}}
@@ -40,20 +40,20 @@
{{* mark the first list entry as active because it is the first which is active after opening
the modal. Changing of the activity status is done by js in jot.tpl-header *}}
From dd919b7f80256af4730dff2a317352d5c994a3e4 Mon Sep 17 00:00:00 2001
From: rabuzarus <>
Date: Mon, 3 Apr 2017 15:04:54 +0200
Subject: [PATCH 16/19] small css fix
---
view/theme/frio/css/style.css | 3 ---
1 file changed, 3 deletions(-)
diff --git a/view/theme/frio/css/style.css b/view/theme/frio/css/style.css
index a9b6f4755..8db41ab7a 100644
--- a/view/theme/frio/css/style.css
+++ b/view/theme/frio/css/style.css
@@ -1307,9 +1307,6 @@ section #jotOpen {
}
/* Filebrowser */
-#jot-fbrowser-wrapper {
- overflow: hidden;
-}
.fbrowser .breadcrumb {
margin-bottom: 0px;
}
From 0542cd6a14735e0a4dd7270ad5b6986c5f5dff55 Mon Sep 17 00:00:00 2001
From: rabuzarus <>
Date: Wed, 5 Apr 2017 11:46:42 +0200
Subject: [PATCH 17/19] add aria attributes + restructure some js to change the
aria attributes
---
view/theme/frio/js/filebrowser.js | 10 +++---
view/theme/frio/js/modal.js | 35 +++++++++++++++---
view/theme/frio/js/theme.js | 21 ++++++++---
view/theme/frio/templates/jot-header.tpl | 41 +++++----------------
view/theme/frio/templates/jot.tpl | 46 ++++++++++++------------
5 files changed, 83 insertions(+), 70 deletions(-)
diff --git a/view/theme/frio/js/filebrowser.js b/view/theme/frio/js/filebrowser.js
index 468188b35..77e9e5088 100644
--- a/view/theme/frio/js/filebrowser.js
+++ b/view/theme/frio/js/filebrowser.js
@@ -81,13 +81,13 @@ var FileBrowser = {
var destination = h.split("-")[0];
FileBrowser.id = h.split("-")[1];
FileBrowser.event = FileBrowser.event + "." + destination;
- if (destination == "comment") {
+ if (destination === "comment") {
// Get the comment textimput field
var commentElm = document.getElementById("comment-edit-text-" + FileBrowser.id);
}
};
- console.log("FileBrowser:", nickname, type,FileBrowser.event, FileBrowser.id);
+ console.log("FileBrowser: " + nickname, type, FileBrowser.event, FileBrowser.id);
FileBrowser.postLoad();
@@ -110,10 +110,10 @@ var FileBrowser = {
e.preventDefault();
var embed = "";
- if (FileBrowser.type == "image") {
+ if (FileBrowser.type === "image") {
embed = "[url=" + this.dataset.link + "][img]" + this.dataset.img + "[/img][/url]";
}
- if (FileBrowser.type == "file") {
+ if (FileBrowser.type === "file") {
// attachment links are "baseurl/attach/id"; we need id
embed = "[attachment]" + this.dataset.link.split("/").pop() + "[/attachment]";
}
@@ -123,7 +123,7 @@ var FileBrowser = {
// work as expected (we need a way to wait until commentOpenUI would be finished).
// As for now we insert pieces of this function here
if ((commentElm !== null) && (typeof commentElm !== "undefined")) {
- if (commentElm.value == "") {
+ if (commentElm.value === "") {
$("#comment-edit-text-" + FileBrowser.id).addClass("comment-edit-text-full").removeClass("comment-edit-text-empty");
$("#comment-edit-submit-wrapper-" + FileBrowser.id).show();
$("#comment-edit-text-" + FileBrowser.id).attr('tabindex','9');
diff --git a/view/theme/frio/js/modal.js b/view/theme/frio/js/modal.js
index b77f62161..1fd03ddfa 100644
--- a/view/theme/frio/js/modal.js
+++ b/view/theme/frio/js/modal.js
@@ -59,7 +59,7 @@ $(document).ready(function(){
});
// Jot nav menu.
- $("body").on("click", "#jot-modal .jot-nav li a", function(e){
+ $("body").on("click", "#jot-modal .jot-nav li .jot-nav-lnk", function(e){
e.preventDefault();
toggleJotNav(this);
});
@@ -306,10 +306,37 @@ function jotreset() {
// Give the active "jot-nav" list element the class "active"
function toggleJotNav (elm) {
- // select all li of jot-nav and remove the active class
- $(".jot-nav li").removeClass("active");
- // add the active class to the parent of the link which was selected
+ // 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");
+
+ // Select all li of jot-nav and remove the active class
+ $(elm).parent("li").siblings("li").removeClass("active");
+ // Add the active class to the parent of the link which was selected
$(elm).parent("li").addClass("active");
+
+ // Minimize all tab content wrapper and activate only the selected
+ // tab panel
+ $('#jot-modal [role=tabpanel]').addClass("minimize").attr("aria-hidden" ,"true");
+ $('#jot-modal #' + tabpanel).removeClass("minimize").attr("aria-hidden" ,"false");
+
+ // Set the aria-selected states
+ $("#jot-modal .nav-tabs .jot-nav-lnk").attr("aria-selected", "false");
+ elm.setAttribute("aria-selected", "true");
+
+ // For some some tab panels we need to execute other js functions
+ if (tabpanel === "jot-preview-content") {
+ preview_post();
+ } else if (tabpanel === "jot-fbrowser-wrapper") {
+ $(function() {
+ Dialog.showJot();
+ });
+ }
+
+ // If element is a mobile dropdown nav menu we need to change the botton text
+ if (cls) {
+ toggleDropdownText(elm);
+ }
}
// Wall Message needs a special handling because in some cases
diff --git a/view/theme/frio/js/theme.js b/view/theme/frio/js/theme.js
index 8a3bd4110..00f969101 100644
--- a/view/theme/frio/js/theme.js
+++ b/view/theme/frio/js/theme.js
@@ -208,11 +208,8 @@ $(document).ready(function(){
// Dropdown menus with the class "dropdown-head" will display the active tab
// as button text
- $("body").on('click', '.dropdown-head .dropdown-menu li a', function(){
- $(this).closest(".dropdown").find('.btn').html($(this).text() + ' ');
- $(this).closest(".dropdown").find('.btn').val($(this).data('value'));
- $(this).closest("ul").children("li").show();
- $(this).parent("li").hide();
+ $("body").on('click', '.dropdown-head .dropdown-menu li a, .dropdown-head .dropdown-menu li button', function(){
+ toggleDropdownText(this);
});
/* setup onoff widgets */
@@ -688,3 +685,17 @@ function bin2hex (s) {
return o;
}
+
+// Dropdown menus with the class "dropdown-head" will display the active tab
+// as button text
+function toggleDropdownText(elm) {
+ $(elm).closest(".dropdown").find('.btn').html($(elm).text() + ' ');
+ $(elm).closest(".dropdown").find('.btn').val($(elm).data('value'));
+ $(elm).closest("ul").children("li").show();
+ $(elm).parent("li").hide();
+}
+
+// Check if element does have a specific class
+function hasClass(elem, cls) {
+ return (" " + elem.className + " " ).indexOf( " "+cls+" " ) > -1;
+}
diff --git a/view/theme/frio/templates/jot-header.tpl b/view/theme/frio/templates/jot-header.tpl
index 6aad9889d..d52f4b98d 100644
--- a/view/theme/frio/templates/jot-header.tpl
+++ b/view/theme/frio/templates/jot-header.tpl
@@ -280,39 +280,14 @@
.modal.show;
}
- // the following functions show/hide the specific jot content
- // in dependence of the selected nav
- function aclActive() {
- $(".modal-body #profile-jot-wrapper, .modal-body #jot-preview-content, .modal-body #jot-fbrowser-wrapper").addClass("minimize");
- $(".modal-body #profile-jot-acl-wrapper").removeClass("minimize");
- }
-
-
- function previewActive() {
- $(".modal-body #profile-jot-wrapper, .modal-body #profile-jot-acl-wrapper,.modal-body #jot-fbrowser-wrapper").addClass("minimize");
- var postPreview = preview_post();
- if (postPreview && typeof postPreview !== "undefined") {
- $(".modal-body #jot-preview-content").removeClass("minimize");
- }
- }
-
+ // Activate the jot text section in the jot modal
function jotActive() {
- $(".modal-body #profile-jot-acl-wrapper, .modal-body #jot-preview-content, .modal-body #jot-fbrowser-wrapper").addClass("minimize");
- $(".modal-body #profile-jot-wrapper").removeClass("minimize");
-
- //make sure jot text does have really the active class (we do this because there are some
- // other events which trigger jot text
- toggleJotNav($("#jot-modal .jot-nav #jot-text-lnk"));
+ // Make sure jot text does have really the active class (we do this because there are some
+ // other events which trigger jot text (we need to do this for the desktop and mobile
+ // jot nav
+ var elem = $("#jot-modal .jot-nav #jot-text-lnk");
+ var elemMobile = $("#jot-modal .jot-nav #jot-text-lnk-mobile")
+ toggleJotNav(elem[0]);
+ toggleJotNav(elemMobile[0]);
}
-
- function fbrowserActive() {
- $(".modal-body #profile-jot-wrapper, .modal-body #jot-preview-content, .modal-body #profile-jot-acl-wrapper").addClass("minimize");
-
- $(".modal-body #jot-fbrowser-wrapper").removeClass("minimize");
-
- $(function() {Dialog.showJot();});
- }
-
-
-
diff --git a/view/theme/frio/templates/jot.tpl b/view/theme/frio/templates/jot.tpl
index 36e0f7797..2ebd1c1dd 100644
--- a/view/theme/frio/templates/jot.tpl
+++ b/view/theme/frio/templates/jot.tpl
@@ -12,48 +12,48 @@
{{* The Jot navigation menu for desktop user (text input, permissions, preview, filebrowser) *}}
-
+
{{* Mark the first list entry as active because it is the first which is active after opening
the modal. Changing of the activity status is done by js in jot.tpl-header *}}
-
{{* The Jot navigation menu for small displays (text input, permissions, preview, filebrowser) *}}
-
-
+
+
{{* mark the first list entry as active because it is the first which is active after opening
the modal. Changing of the activity status is done by js in jot.tpl-header *}}
-