From 17c102ebe115bd8272da830bf9523b691ce115ee Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 7 Mar 2018 21:11:57 +0100 Subject: we need the javascript in the template since strings are involved --- Zotlabs/Module/Cover_photo.php | 6 +++ Zotlabs/Module/Profile_photo.php | 6 +++ view/js/mod_cover_photo.js | 80 ------------------------------------- view/js/mod_profile_photo.js | 82 -------------------------------------- view/tpl/cover_photo.tpl | 83 ++++++++++++++++++++++++++++++++++++++ view/tpl/profile_photo.tpl | 86 ++++++++++++++++++++++++++++++++++++++++ 6 files changed, 181 insertions(+), 162 deletions(-) delete mode 100644 view/js/mod_cover_photo.js delete mode 100644 view/js/mod_profile_photo.js diff --git a/Zotlabs/Module/Cover_photo.php b/Zotlabs/Module/Cover_photo.php index 047bcf3d4..2da99b447 100644 --- a/Zotlabs/Module/Cover_photo.php +++ b/Zotlabs/Module/Cover_photo.php @@ -364,6 +364,12 @@ class Cover_photo extends \Zotlabs\Web\Controller { '$embedPhotosModalTitle' => t('Use a photo from your albums'), '$embedPhotosModalCancel' => t('Cancel'), '$embedPhotosModalOK' => t('OK'), + '$modalchooseimages' => t('Choose images to embed'), + '$modalchoosealbum' => t('Choose an album'), + '$modaldiffalbum' => t('Choose a different album'), + '$modalerrorlist' => t('Error getting album list'), + '$modalerrorlink' => t('Error getting photo link'), + '$modalerroralbum' => t('Error getting album'), '$form_security_token' => get_form_security_token("cover_photo"), /// @FIXME - yuk '$select' => t('Select existing photo'), diff --git a/Zotlabs/Module/Profile_photo.php b/Zotlabs/Module/Profile_photo.php index 44b7c18c6..2ce8686b9 100644 --- a/Zotlabs/Module/Profile_photo.php +++ b/Zotlabs/Module/Profile_photo.php @@ -463,6 +463,12 @@ class Profile_photo extends \Zotlabs\Web\Controller { '$embedPhotosModalTitle' => t('Use a photo from your albums'), '$embedPhotosModalCancel' => t('Cancel'), '$embedPhotosModalOK' => t('OK'), + '$modalchooseimages' => t('Choose images to embed'), + '$modalchoosealbum' => t('Choose an album'), + '$modaldiffalbum' => t('Choose a different album'), + '$modalerrorlist' => t('Error getting album list'), + '$modalerrorlink' => t('Error getting photo link'), + '$modalerroralbum' => t('Error getting album'), '$form_security_token' => get_form_security_token("profile_photo"), '$select' => t('Select existing photo'), )); diff --git a/view/js/mod_cover_photo.js b/view/js/mod_cover_photo.js deleted file mode 100644 index 5b64b8b91..000000000 --- a/view/js/mod_cover_photo.js +++ /dev/null @@ -1,80 +0,0 @@ - var initializeEmbedPhotoDialog = function () { - $('.embed-photo-selected-photo').each(function (index) { - $(this).removeClass('embed-photo-selected-photo'); - }); - getPhotoAlbumList(); - $('#embedPhotoModalBodyAlbumDialog').off('click'); - $('#embedPhotoModal').modal('show'); - }; - - var choosePhotoFromAlbum = function (album) { - $.post("embedphotos/album", {name: album}, - function(data) { - if (data['status']) { - $('#embedPhotoModalLabel').html("{{$modalchooseimages}}"); - $('#embedPhotoModalBodyAlbumDialog').html('\ -

') - $('#embedPhotoModalBodyAlbumDialog').append(data['content']); - $('#embedPhotoModalBodyAlbumDialog').click(function (evt) { - evt.preventDefault(); - var image = document.getElementById(evt.target.id); - if (typeof($(image).parent()[0]) !== 'undefined') { - var imageparent = document.getElementById($(image).parent()[0].id); - $(imageparent).toggleClass('embed-photo-selected-photo'); - var href = $(imageparent).attr('href'); - $.post("embedphotos/photolink", {href: href}, - function(ddata) { - if (ddata['status']) { - window.location.href = 'cover_photo/use/' + ddata['resource_id']; - } else { - window.console.log("{{$modalerrorlink}}" + ':' + ddata['errormsg']); - } - return false; - }, - 'json'); - $('#embedPhotoModalBodyAlbumDialog').html(''); - $('#embedPhotoModalBodyAlbumDialog').off('click'); - $('#embedPhotoModal').modal('hide'); - } - }); - - $('#embedPhotoModalBodyAlbumListDialog').addClass('d-none'); - $('#embedPhotoModalBodyAlbumDialog').removeClass('d-none'); - } else { - window.console.log("{{$modalerroralbum}} " + JSON.stringify(album) + ':' + data['errormsg']); - } - return false; - }, - 'json'); - }; - - var getPhotoAlbumList = function () { - $.post("embedphotos/albumlist", {}, - function(data) { - if (data['status']) { - var albums = data['albumlist']; //JSON.parse(data['albumlist']); - $('#embedPhotoModalLabel').html("{{$modalchoosealbum}}"); - $('#embedPhotoModalBodyAlbumList').html(''); - for(var i=0; i' + albumName + ''; - albumLink += ''; - $('#embedPhotoModalBodyAlbumList').find('ul').append(albumLink); - } - $('#embedPhotoModalBodyAlbumDialog').addClass('d-none'); - $('#embedPhotoModalBodyAlbumListDialog').removeClass('d-none'); - } else { - window.console.log("{{$modalerrorlist}}" + ':' + data['errormsg']); - } - return false; - }, - 'json'); - }; diff --git a/view/js/mod_profile_photo.js b/view/js/mod_profile_photo.js deleted file mode 100644 index c05c8e25e..000000000 --- a/view/js/mod_profile_photo.js +++ /dev/null @@ -1,82 +0,0 @@ - var initializeEmbedPhotoDialog = function () { - $('.embed-photo-selected-photo').each(function (index) { - $(this).removeClass('embed-photo-selected-photo'); - }); - getPhotoAlbumList(); - $('#embedPhotoModalBodyAlbumDialog').off('click'); - $('#embedPhotoModal').modal('show'); - }; - - var choosePhotoFromAlbum = function (album) { - $.post("embedphotos/album", {name: album}, - function(data) { - if (data['status']) { - $('#embedPhotoModalLabel').html("{{$modalchooseimages}}"); - $('#embedPhotoModalBodyAlbumDialog').html('\ -

') - $('#embedPhotoModalBodyAlbumDialog').append(data['content']); - $('#embedPhotoModalBodyAlbumDialog').click(function (evt) { - evt.preventDefault(); - var image = document.getElementById(evt.target.id); - if (typeof($(image).parent()[0]) !== 'undefined') { - var imageparent = document.getElementById($(image).parent()[0].id); - $(imageparent).toggleClass('embed-photo-selected-photo'); - var href = $(imageparent).attr('href'); - $.post("embedphotos/photolink", {href: href}, - function(ddata) { - if (ddata['status']) { - var pf = $('#profile-photo-profiles').val(); - var prof = ((typeof pf !== 'undefined') ? '?f=&pf=' + pf : ''); - window.location.href = 'profile_photo/use/' + ddata['resource_id'] + prof; - } else { - window.console.log("{{$modalerrorlink}}" + ':' + ddata['errormsg']); - } - return false; - }, - 'json'); - $('#embedPhotoModalBodyAlbumDialog').html(''); - $('#embedPhotoModalBodyAlbumDialog').off('click'); - $('#embedPhotoModal').modal('hide'); - } - }); - - $('#embedPhotoModalBodyAlbumListDialog').addClass('d-none'); - $('#embedPhotoModalBodyAlbumDialog').removeClass('d-none'); - } else { - window.console.log("{{$modalerroralbum}} " + JSON.stringify(album) + ':' + data['errormsg']); - } - return false; - }, - 'json'); - }; - - var getPhotoAlbumList = function () { - $.post("embedphotos/albumlist", {}, - function(data) { - if (data['status']) { - var albums = data['albumlist']; //JSON.parse(data['albumlist']); - $('#embedPhotoModalLabel').html("{{$modalchoosealbum}}"); - $('#embedPhotoModalBodyAlbumList').html(''); - for(var i=0; i' + albumName + ''; - albumLink += ''; - $('#embedPhotoModalBodyAlbumList').find('ul').append(albumLink); - } - $('#embedPhotoModalBodyAlbumDialog').addClass('d-none'); - $('#embedPhotoModalBodyAlbumListDialog').removeClass('d-none'); - } else { - window.console.log("{{$modalerrorlist}}" + ':' + data['errormsg']); - } - return false; - }, - 'json'); - }; diff --git a/view/tpl/cover_photo.tpl b/view/tpl/cover_photo.tpl index cbcf46320..829a3a556 100755 --- a/view/tpl/cover_photo.tpl +++ b/view/tpl/cover_photo.tpl @@ -1,3 +1,86 @@ + +

{{$title}}

diff --git a/view/tpl/profile_photo.tpl b/view/tpl/profile_photo.tpl index edde6af3f..e48d05330 100755 --- a/view/tpl/profile_photo.tpl +++ b/view/tpl/profile_photo.tpl @@ -1,3 +1,89 @@ + + +

{{$title}}

-- cgit v1.2.3