]> git.mxchange.org Git - friendica.git/commitdiff
Merge develop into 20170321_-_frio-fbbrowser
authorrabuzarus <trebor@central-unit>
Sun, 2 Apr 2017 22:51:34 +0000 (00:51 +0200)
committerrabuzarus <trebor@central-unit>
Sun, 2 Apr 2017 22:51:34 +0000 (00:51 +0200)
Conflicts:
view/theme/frio/js/filebrowser.js
view/theme/frio/js/theme.js
view/theme/frio/templates/filebrowser.tpl
view/theme/frio/templates/jot.tpl

mod/wall_upload.php
view/theme/frio/css/mod_events.css
view/theme/frio/css/style.css
view/theme/frio/js/filebrowser.js
view/theme/frio/js/theme.js
view/theme/frio/templates/filebrowser.tpl
view/theme/frio/templates/jot.tpl

index 1f71f36b62d1036f6b224e3df19f0b6d6463bc18..d29efecc6ad2319eb86365a7fae727e9fa3f0e36 100644 (file)
@@ -1,17 +1,33 @@
 <?php
 
-require_once('include/Photo.php');
+/**
+ * @file mod/wall_upload.php
+ * @brief Module for uploading a picture to the profile wall
+ * 
+ * By default the picture will be stored in the photo album with the name Wall Photos.
+ * You can specify a different album by adding an optional query string "album="
+ * 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);
 
-       $r_json = (x($_GET,'response') && $_GET['response']=='json');
+       $r_json = (x($_GET, 'response') && $_GET['response'] == 'json');
+       $album = (x($_GET, 'album') ? notags(trim($_GET['album'])) : '');
 
-       if($a->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)
                        );
 
@@ -24,7 +40,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'])
                        );
                }
@@ -36,6 +55,9 @@ function wall_upload_post(App $a, $desktopmode = true) {
                return;
        }
 
+       /*
+        * Setup permissions structures
+        */
        $can_post  = false;
        $visitor   = 0;
 
@@ -44,22 +66,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)
                                );
@@ -72,16 +96,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.')));
                }
@@ -89,32 +113,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=="") {
@@ -127,28 +155,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 = Config::get('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 {
@@ -159,10 +189,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'];
@@ -182,7 +214,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));
@@ -196,12 +228,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 = Config::get('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();
@@ -211,11 +244,16 @@ function wall_upload_post(App $a, $desktopmode = true) {
 
        $smallest = 0;
 
+       // If we don't have an album name use the Wall Photos album
+       if (! strlen($album)) {
+               $album = t('Wall Photos');
+       }
+
        $defperm = '<' . $default_cid . '>';
 
-       $r = $ph->store($page_owner_uid, $visitor, $hash, $filename, t('Wall Photos'), 0, 0, $defperm);
+       $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));
@@ -225,26 +263,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, t('Wall Photos'), 1, 0, $defperm);
-               if($r)
+               $r = $ph->store($page_owner_uid, $visitor, $hash, $filename, $album, 1, 0, $defperm);
+               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, t('Wall Photos'), 2, 0, $defperm);
-               if($r AND ($smallest == 0))
+               $r = $ph->store($page_owner_uid, $visitor, $hash, $filename, $album, 2, 0, $defperm);
+               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();
@@ -253,14 +296,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));
@@ -276,7 +319,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";
index 6512d1bbec8826c08594b1faa016bc644242807f..293ffe06b4b25de0d0ee947526c41fe1d8729c4a 100644 (file)
@@ -22,6 +22,9 @@
 #fc-header-right {
     margin-top: -4px;
 }
+#fc-header-right button {
+    color: inherit;
+}
 #event-calendar-title {
     vertical-align: middle;
 }
index 245cd39fff4bd2690fdee2d3afd7eaced8044f9a..f7659117dd2a2fabdbef769b8871a56f446cfdd4 100644 (file)
@@ -158,6 +158,7 @@ a#item-delete-selected {
     font-size: 14px;
     font-weight: 600;
     padding: 8px 16px;
+    color: inherit;
 }
 
 .btn-default {
@@ -190,12 +191,7 @@ a#item-delete-selected {
     outline: 0;
     background: $btn_primary_hover_color !important;
 }
-.btn-default:active, .btn-default.active {
-    color: $link_color;
-}
-.btn-default:active:hover, .btn-default.active:hover {
-    color: $link_hover_color;
-}
+
 .btn-primary.active.focus, .btn-primary.active:focus, .btn-primary.active:hover,
 .btn-primary:active.focus, .btn-primary:active:focus, .btn-primary:active:hover,
 .open>.dropdown-toggle.btn-primary.focus, .open>.dropdown-toggle.btn-primary:focus,
@@ -211,9 +207,6 @@ a#item-delete-selected {
     padding-left: 0;
     padding-right: 0;
 }
-.btn {
-       color: inherit;
-}
 .btn-eventnav, btn-eventnav:hover {
     font-size: 16px;
     background: none;
@@ -1310,6 +1303,59 @@ section #jotOpen {
 }
 
 /* Filebrowser */
+.fbrowser .breadcrumb {
+    margin-bottom: 0px;
+}
+.fbrowser .path a:before {
+    content: "";
+    padding: 0;
+}
+.fbrowser .breadcrumb > li:last-of-type a{
+    color: #777;
+    pointer-events: none;
+    cursor: default;
+}
+.fbrowser .folders {
+    box-shadow: -1.5px 0 0 0 rgba(0, 0, 0, .1) inset;
+    padding-right: 1px;
+}
+.fbrowser .folders ul {
+    padding: 0px;
+    margin-left: -15px;
+    margin-bottom: 0px;
+    overflow-y: auto;
+    min-width: 100px;
+    max-height: calc(100vh - 210px);
+    line-height: 1.3;
+}
+.fbrowser .folders li {
+    padding-left: 20px;
+    padding-right: 10px;
+    padding-top: 3px;
+    padding-bottom: 3px;
+}
+.fbrowser .folders li:hover {
+    z-index: 2;
+    color: #555;
+    background-color: rgba(247, 247, 247, $contentbg_transp);
+    border-left: 3px solid $link_color !important;
+    padding-left: 17px;
+}
+.fbrowser .folders li a,
+.fbrowser .folders li a:hover {
+    color: #555;
+    font-size: 13px;
+}
+.fbrowser .folders + .list {
+    padding-left: 10px;
+}
+.fbrowser .fbrowser-content-container {
+    overflow-y: auto;
+    max-height: calc(100vh - 175px);
+}
+.fbrowser.image .photo-album-image-wrapper img {
+    border: 1px solid #ddd;
+}
 .fbrowser .profile-rotator-wrapper {
     min-height: 200px;
 }
@@ -1610,6 +1656,10 @@ code > .hl-main {
 .wall-item-actions .button-likes {
     text-transform: capitalize;
 }
+.wall-item-actions button:hover {
+    color: #555;
+    text-decoration: underline;
+}
 .wall-item-actions .separator {
        margin: 0 .3em;
 }
index d216c40f33ba94558cde5d3e4ed14ce408d0a2a3..1ca24966a8bd2ff89f434369deff168d38d10c3b 100644 (file)
@@ -68,6 +68,7 @@ var FileBrowser = {
        nickname : "",\r
        type : "",\r
        event: "",\r
+       folder: "",\r
        id : null,\r
 \r
        init: function(nickname, type, hash) {\r
@@ -81,15 +82,14 @@ var FileBrowser = {
                        FileBrowser.id = h.split("-")[1];\r
                        FileBrowser.event = FileBrowser.event + "." + destination;\r
                        if (destination == "comment") {\r
-                               // get the comment textimput field\r
+                               // Get the comment textimput field\r
                                var commentElm = document.getElementById("comment-edit-text-" + FileBrowser.id);\r
                        }\r
                };\r
 \r
-               console.log("FileBrowser:", nickname, type,FileBrowser.event, FileBrowser.id );\r
+               console.log("FileBrowser:", nickname, type,FileBrowser.event, FileBrowser.id);\r
 \r
-               // We need to add the AjaxUpload to the button\r
-               FileBrowser.uploadButtons();\r
+               FileBrowser.postLoad();\r
 \r
                $(".error .close").on("click", function(e) {\r
                        e.preventDefault();\r
@@ -97,34 +97,25 @@ var FileBrowser = {
                });\r
 \r
                // Click on album link\r
-               $(".fbrowser").on("click", ".folders a, .path a, .folders button, .path button", function(e) {\r
+               $(".fbrowser").on("click", ".folders a, .path a", function(e) {\r
                        e.preventDefault();\r
                        var url = baseurl + "/fbrowser/" + FileBrowser.type + "/" + this.dataset.folder + "?mode=none";\r
-                       $(".fbrowser-content").hide();\r
-                       $(".fbrowser .profile-rotator-wrapper").show();\r
-\r
-                       // load new content to fbrowser window\r
-                       $(".fbrowser").load(url, function(responseText, textStatus){\r
-                               $(".profile-rotator-wrapper").hide();\r
-                               if (textStatus === 'success') {\r
-                                       $(".fbrowser_content").show();\r
-                                       // We need to add the AjaxUpload to the button\r
-                                       FileBrowser.uploadButtons();\r
-                               }\r
-                       });\r
+                       FileBrowser.folder = this.dataset.folder;\r
+\r
+                       FileBrowser.loadContent(url);\r
                });\r
 \r
-               //embed on click\r
+               //Embed on click\r
                $(".fbrowser").on('click', ".photo-album-photo-link", function(e) {\r
                        e.preventDefault();\r
 \r
                        var embed = "";\r
                        if (FileBrowser.type == "image") {\r
-                               embed = "[url="+this.dataset.link+"][img]"+this.dataset.img+"[/img][/url]";\r
+                               embed = "[url=" + this.dataset.link + "][img]" + this.dataset.img + "[/img][/url]";\r
                        }\r
-                       if (FileBrowser.type=="file") {\r
+                       if (FileBrowser.type == "file") {\r
                                // attachment links are "baseurl/attach/id"; we need id\r
-                               embed = "[attachment]"+this.dataset.link.split("/").pop()+"[/attachment]";\r
+                               embed = "[attachment]" + this.dataset.link.split("/").pop() + "[/attachment]";\r
                        }\r
 \r
                        // Delete prefilled Text of the comment input\r
@@ -140,61 +131,75 @@ var FileBrowser = {
                                }\r
 \r
                        }\r
+\r
                        console.log(FileBrowser.event, this.dataset.filename, embed, FileBrowser.id);\r
+\r
                        parent.$("body").trigger(FileBrowser.event, [\r
                                this.dataset.filename,\r
                                embed,\r
                                FileBrowser.id,\r
-                               this.dataset.img,\r
+                               this.dataset.img\r
                        ]);\r
 \r
-                       // close model\r
+                       // Close model\r
                        $('#modal').modal('hide');\r
-                       // update autosize for this textarea\r
+                       // Update autosize for this textarea\r
                        autosize.update($(".text-autosize"));\r
                });\r
+\r
+               // EventListener for switching between image and file mode\r
+               $(".fbrowser").on('click', ".fbswitcher .btn", function(e) {\r
+                       e.preventDefault();\r
+                       FileBrowser.type = this.getAttribute("data-mode");\r
+                       $(".fbrowser").removeClass().addClass("fbrowser " + FileBrowser.type);\r
+                       url = baseurl + "/fbrowser/" + FileBrowser.type + "?mode=none";\r
+\r
+                       FileBrowser.loadContent(url);\r
+               });\r
        },\r
 \r
+       // Initialize the AjaxUpload for the upload buttons\r
        uploadButtons: function() {\r
                if ($("#upload-image").length) {\r
+                       // To get the albumname we need to convert it from hex\r
+                       var albumname = hex2bin(FileBrowser.folder);\r
+                       //AjaxUpload for images\r
                        var image_uploader = new window.AjaxUpload(\r
                                'upload-image',\r
-                               {       action: 'wall_upload/'+FileBrowser.nickname+'?response=json',\r
+                               {       action: 'wall_upload/' + FileBrowser.nickname + '?response=json&album=' + albumname,\r
                                        name: 'userfile',\r
                                        responseType: 'json',\r
-                                       onSubmit: function(file,ext) {\r
+                                       onSubmit: function(file, ext) {\r
                                                $(".fbrowser-content").hide();\r
                                                $(".fbrowser .profile-rotator-wrapper").show();\r
                                                $(".error").addClass('hidden');\r
                                        },\r
                                        onComplete: function(file,response) {\r
-                                               if (response['error']!= undefined) {\r
+                                               if (response['error'] != undefined) {\r
                                                        $(".error span").html(response['error']);\r
                                                        $(".error").removeClass('hidden');\r
                                                        $(".fbrowser .profile-rotator-wrapper").hide();\r
                                                        return;\r
                                                }\r
 \r
-                                               $(".profile-rotator-wrapper").hide();\r
-                                               $(".fbrowser_content").show();\r
-\r
 //                                             location = baseurl + "/fbrowser/image/?mode=none"+location['hash'];\r
 //                                             location.reload(true);\r
 \r
-                                               var url = baseurl + "/fbrowser/" + FileBrowser.type + "?mode=none"\r
+                                               var url = baseurl + "/fbrowser/" + FileBrowser.type + "/" + FileBrowser.folder + "?mode=none";\r
                                                // load new content to fbrowser window\r
-                                               $(".fbrowser").load(url);\r
+                                               FileBrowser.loadContent(url);\r
                                        }\r
                                }\r
                        );\r
                }\r
 \r
                if ($("#upload-file").length) {\r
+                       //AjaxUpload for files\r
                        var file_uploader = new window.AjaxUpload(\r
                                'upload-file',\r
-                               {       action: 'wall_attach/'+FileBrowser.nickname+'?response=json',\r
+                               {       action: 'wall_attach/' + FileBrowser.nickname + '?response=json',\r
                                        name: 'userfile',\r
-                                       onSubmit: function(file,ext) {\r
+                                       onSubmit: function(file, ext) {\r
                                                $(".fbrowser-content").hide();\r
                                                $(".fbrowser .profile-rotator-wrapper").show();\r
                                                $(".error").addClass('hidden');\r
@@ -207,18 +212,49 @@ var FileBrowser = {
                                                        return;\r
                                                }\r
 \r
-                                               $(".profile-rotator-wrapper").hide();\r
-                                               $(".fbrowser_content").show();\r
-\r
 //                                             location = baseurl + "/fbrowser/file/?mode=none"+location['hash'];\r
 //                                             location.reload(true);\r
 \r
-                                               var url = baseurl + "/fbrowser/" + FileBrowser.type + "?mode=none"\r
-                                               // load new content to fbrowser window\r
-                                               $(".fbrowser").load(url);\r
+                                               var url = baseurl + "/fbrowser/" + FileBrowser.type + "?mode=none";\r
+                                               // Load new content to fbrowser window\r
+                                               FileBrowser.loadContent(url);\r
                                        }\r
                                }\r
                        );\r
                }\r
+       },\r
+\r
+       // Stuff which should be executed if ne content was loaded\r
+       postLoad: function() {\r
+               FileBrowser.initGallery();\r
+               $(".fbrowser .fbswitcher .btn").removeClass("active");\r
+               $(".fbrowser .fbswitcher [data-mode=" + FileBrowser.type + "]").addClass("active");\r
+               // We need to add the AjaxUpload to the button\r
+               FileBrowser.uploadButtons();\r
+               \r
+       },\r
+\r
+       // Load new content (e.g. change photo album)\r
+       loadContent: function(url) {\r
+               $(".fbrowser-content").hide();\r
+               $(".fbrowser .profile-rotator-wrapper").show();\r
+\r
+               // load new content to fbrowser window\r
+               $(".fbrowser").load(url, function(responseText, textStatus) {\r
+                       $(".profile-rotator-wrapper").hide();\r
+                       if (textStatus === 'success') {\r
+                               $(".fbrowser_content").show();\r
+                               FileBrowser.postLoad();\r
+                       }\r
+               });\r
+       },\r
+\r
+       // Initialize justified Gallery\r
+       initGallery: function() {\r
+               $(".fbrowser.image .fbrowser-content-container").justifiedGallery({\r
+                       'rowHeight': 80,\r
+                       'margins': 2,\r
+                       'border': 0\r
+               });\r
        }\r
 };\r
index 4e8ede07fd965289a63c996aa1fec2f0e50e4948..8a3bd4110972ff4235224098dad9f78976368328 100644 (file)
@@ -637,4 +637,54 @@ function doLikeAction(ident, verb) {
        $.get('like/' + ident.toString() + '?verb=' + verb, NavUpdate );
        liking = 1;
        force_update = true;
-}
\ No newline at end of file
+}
+
+// Decodes a hexadecimally encoded binary string
+function hex2bin (s) {
+       //  discuss at: http://locutus.io/php/hex2bin/
+       // original by: Dumitru Uzun (http://duzun.me)
+       //   example 1: hex2bin('44696d61')
+       //   returns 1: 'Dima'
+       //   example 2: hex2bin('00')
+       //   returns 2: '\x00'
+       //   example 3: hex2bin('2f1q')
+       //   returns 3: false
+       var ret = [];
+       var i = 0;
+       var l;
+       s += '';
+
+       for (l = s.length; i < l; i += 2) {
+               var c = parseInt(s.substr(i, 1), 16);
+               var k = parseInt(s.substr(i + 1, 1), 16);
+               if (isNaN(c) || isNaN(k)) {
+                       return false;
+               }
+               ret.push((c << 4) | k);
+       }
+       return String.fromCharCode.apply(String, ret);
+}
+
+// Convert binary data into hexadecimal representation
+function bin2hex (s) {
+       // From: http://phpjs.org/functions
+       // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
+       // +   bugfixed by: Onno Marsman
+       // +   bugfixed by: Linuxworld
+       // +   improved by: ntoniazzi (http://phpjs.org/functions/bin2hex:361#comment_177616)
+       // *     example 1: bin2hex('Kev');
+       // *     returns 1: '4b6576'
+       // *     example 2: bin2hex(String.fromCharCode(0x00));
+       // *     returns 2: '00'
+
+       var i, l, o = "", n;
+
+       s += "";
+
+       for (i = 0, l = s.length; i < l; i++) {
+               n = s.charCodeAt(i).toString(16);
+               o += n.length < 2 ? "0" + n : n;
+       }
+
+       return o;
+}
index 20227f87965edda0ce0c1c44bd493b1f5292f8f2..6fc091d95250db2b882c6546d8e40e4b75d189aa 100644 (file)
                <input id="fb-nickname" type="hidden" name="type" value="{{$nickname}}" />
                <input id="fb-type" type="hidden" name="type" value="{{$type}}" />
 
-        <div class="error hidden">
-            <span></span> <button type="button" class="btn btn-link" class="close">X</a>
-        </div>
-
-        <div class="path">
-            {{foreach $path as $p}}<button type="button" class="btn-link" data-folder="{{$p.0}}">{{$p.1}}</button>{{/foreach}}
-        </div>
-
-        {{if $folders }}
-        <div class="folders">
-            <ul>
-                {{foreach $folders as $f}}<li><button type="button" class="btn-link" data-folder="{{$f.0}}">{{$f.1}}</button></li>{{/foreach}}
-            </ul>
-        </div>
-        {{/if}}
-
-        <div class="list">
-            {{foreach $files as $f}}
-            <div class="photo-album-image-wrapper">
-                <button type="button" class="btn btn-link photo-album-photo-link" data-link="{{$f.0}}" data-filename="{{$f.1}}" data-img="{{$f.2}}">
-                    <img src="{{$f.2}}">
-                    <p>{{$f.1}}</p>
-                </button>
+               <div class="error hidden">
+                       <span></span> <button type="button" class="btn btn-link" class="close">X</a>
+               </div>
+
+               {{* The breadcrumb navigation *}}
+               <ol class="path breadcrumb">
+                       {{foreach $path as $p}}<li><a href="#" data-folder="{{$p.0}}">{{$p.1}}</a></li>{{/foreach}}
+
+                       {{* Switch between image and file mode *}}
+                       <div class="fbswitcher btn-group btn-group-xs pull-right">
+                               <button type="button" class="btn btn-default" data-mode="image"><i class="fa fa-picture-o" aria-hidden="true"></i></button>
+                               <button type="button" class="btn btn-default" data-mode="file"><i class="fa fa-file-o" aria-hidden="true"></i></button>
+                       </div>
+               </ol>
+
+               <div class="media">
+
+                       {{* List of photo albums *}}
+                       {{if $folders }}
+                       <div class="folders media-left">
+                               <ul>
+                                       {{foreach $folders as $f}}<li><a href="#" data-folder="{{$f.0}}">{{$f.1}}</a></li>{{/foreach}}
+                               </ul>
+                       </div>
+                       {{/if}}
+
+                       {{* The main content (images or files) *}}
+                       <div class="list {{$type}} media-body">
+                               <div class="fbrowser-content-container">
+                                       {{foreach $files as $f}}
+                                       <div class="photo-album-image-wrapper">
+                                               <a href="#" class="photo-album-photo-link" data-link="{{$f.0}}" data-filename="{{$f.1}}" data-img="{{$f.2}}">
+                                                       <img src="{{$f.2}}" alt="{{$f.1}}">
+                                                       <p>{{$f.1}}</p>
+                                               </a>
+                                       </div>
+                                       {{/foreach}}
+                               </div>
                        </div>
-                       {{/foreach}}
                </div>
 
                <div class="upload">
-                       <button id="upload-{{$type}}"><img id="profile-rotator" src="images/rotator.gif" alt="{{$wait}}" title="{{$wait|escape:'html'}}" style="display: none;" /> {{"Upload"|t}}</button>
+                       <button id="upload-{{$type}}">{{"Upload"|t}}</button>
                </div>
        </div>
+
+       {{* This part contains the conent loader icon which is visible when new conent is loaded *}}
        <div class="profile-rotator-wrapper" style="display: none;">
-               <i class="fa fa-circle-o-notch fa-spin"></i>
+               <i class="fa fa-circle-o-notch fa-spin" aria-hidden="true"></i>
        </div>
 </div>
index 71fdae7cd3433063db3045bee528a14a3d735d28..0e9a6fdde29596a847b01f1ae55b3bea650e24a5 100644 (file)
@@ -11,7 +11,7 @@
                        in with dropdows the close button needs to be inserted after the dropdown. *}}
                        <button type="button" class="close hidden-xs" data-dismiss="modal" style="float: right;">&times;</button>
 
-                       {{* The Jot navigation menu (text input, permissions, preview, filebrowser) *}}
+                       {{* The Jot navigation menu for desktop user (text input, permissions, preview, filebrowser) *}}
                        <ul class="nav nav-tabs hidden-xs jot-nav" role="menubar" data-tabs="tabs">
                                {{* 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 *}}
@@ -33,6 +33,7 @@
                                </li>
                        </ul>
 
+                       {{* The Jot navigation menu for small displays (text input, permissions, preview, filebrowser) *}}
                        <div class="dropdown dropdown-head dropdown-mobile-jot jot-nav hidden-lg hidden-md hidden-sm" role="menubar" data-tabs="tabs" style="float: left;">
                                <button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">{{$message}}&nbsp;<span class="caret"></span></button>
                                <ul class="dropdown-menu nav nav-pills">
                                        </div>
 
                                        <ul id="profile-jot-submit-wrapper" class="jothidden nav nav-pills">
-                                               {{* uncomment the button for "wall-immage-upload" because we have integrated it directly in the jot modal
-                                               <li><a href="#" id="wall-image-upload" title="{{$upload}}"><i class="fa fa-picture-o"></i></a></li>
-                                               *}}
-                                               <li><button type="button" class="btn-link" id="wall-file-upload" title="{{$attach}}"><i class="fa fa-paperclip"></i></button></li>
                                                <li><button type="button" class="btn-link" id="profile-link"  ondragenter="return linkdropper(event);" ondragover="return linkdropper(event);" ondrop="linkdrop(event);" onclick="jotGetLink();" title="{{$weblink}}"><i class="fa fa-link"></i></button></li>
                                                <li><button type="button" class="btn-link" id="profile-video" onclick="jotVideoURL();" title="{{$video}}"><i class="fa fa-film"></i></button></li>
                                                <li><button type="button" class="btn-link" id="profile-audio" onclick="jotAudioURL();" title="{{$audio}}"><i class="fa fa-music"></i></button></li>