diff options
author | Mario Vavti <mario@mariovavti.com> | 2016-11-28 11:29:10 +0100 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2016-11-28 11:29:10 +0100 |
commit | 1ce4eda0b92e13615991ec22d3b789c640991431 (patch) | |
tree | 46e6634f403d9e2d9870b2aaee8287c41d4bc8e3 | |
parent | 68fd1c28b0bf21864753106e4345f0908b4f2e49 (diff) | |
download | volse-hubzilla-1ce4eda0b92e13615991ec22d3b789c640991431.tar.gz volse-hubzilla-1ce4eda0b92e13615991ec22d3b789c640991431.tar.bz2 volse-hubzilla-1ce4eda0b92e13615991ec22d3b789c640991431.zip |
wiki: move delete page functionality to the widget
-rw-r--r-- | include/wiki.php | 23 | ||||
-rw-r--r-- | view/css/widgets.css | 35 | ||||
-rw-r--r-- | view/theme/redbasic/css/style.css | 11 | ||||
-rwxr-xr-x | view/tpl/group_side.tpl | 6 | ||||
-rw-r--r-- | view/tpl/wiki.tpl | 30 | ||||
-rw-r--r-- | view/tpl/wiki_page_list.tpl | 34 |
6 files changed, 99 insertions, 40 deletions
diff --git a/include/wiki.php b/include/wiki.php index d2cb51bd3..eb87840f6 100644 --- a/include/wiki.php +++ b/include/wiki.php @@ -31,16 +31,29 @@ function wiki_page_list($resource_id) { if (!$w['path']) { return array('pages' => null, 'wiki' => null); } - $pages = array(); - $pages[] = array('title' => 'Home', 'url' => 'Home'); + + $pages[] = [ + 'resource_id' => '', + 'title' => 'Home', + 'url' => 'Home', + 'link_id' => 'id_wiki_home_0' + ]; + if (is_dir($w['path']) === true) { $files = array_diff(scandir($w['path']), array('.', '..', '.git')); // TODO: Check that the files are all text files - + $i = 1; foreach($files as $file) { // strip the .md file extension and unwrap URL encoding to leave HTML encoded name - if( urldecode(substr($file, 0, -3)) !== 'Home') { - $pages[] = array('title' => urldecode(substr($file, 0, -3)), 'url' => urlencode(substr($file, 0, -3))); + $title = substr($file, 0, -3); + if(urldecode($title) !== 'Home') { + $pages[] = [ + 'resource_id' => $resource_id, + 'title' => urldecode($title), + 'url' => $title, + 'link_id' => 'id_' . substr($resource_id, 0, 10) . '_' . $i + ]; + $i++; } } } diff --git a/view/css/widgets.css b/view/css/widgets.css index 10c66c213..402c3f473 100644 --- a/view/css/widgets.css +++ b/view/css/widgets.css @@ -18,6 +18,41 @@ word-wrap: break-word; } +.widget-nav-pills-icons { + opacity: 0; + padding: 6px 10px; + float: right; + position: relative; + z-index:1; +} + + +.widget-nav-pills-checkbox { + padding: 6px 10px; + float: right; + position: relative; + z-index:1; + cursor: pointer; +} + +i.widget-nav-pills-icons, +i.widget-nav-pills-checkbox { + margin-top: 2px; +} + +.widget-nav-pills-icons:hover + a { + background-color: #eee; +} + +.widget-nav-pills-checkbox:hover + a { + background-color: #eee; +} + +li:hover .widget-nav-pills-icons { + opacity: 1; +} + + /* suggest */ .suggest-widget-more { diff --git a/view/theme/redbasic/css/style.css b/view/theme/redbasic/css/style.css index fba6da17a..2f3da7542 100644 --- a/view/theme/redbasic/css/style.css +++ b/view/theme/redbasic/css/style.css @@ -2040,3 +2040,14 @@ dl.bb-dl > dd > li { padding-left: 15px; border-left: 3px solid #eee; } + +.nav-pills-stacked-icons { + padding: 6px 10px; + float: right; + position: relative; + z-index:1; +} + +.nav-pills-stacked-icons:hover + a { + background-color: #eee; +} diff --git a/view/tpl/group_side.tpl b/view/tpl/group_side.tpl index e58cf060d..35f79a07e 100755 --- a/view/tpl/group_side.tpl +++ b/view/tpl/group_side.tpl @@ -5,12 +5,10 @@ {{foreach $groups as $group}} <li> {{if $group.cid}} - <a class="pull-right group-edit-tool fakelink" onclick="contactgroupChangeMember('{{$group.id}}','{{$group.enc_cid}}'); return true;"/> - <i id="group-{{$group.id}}" class="fa {{if $group.ismember}}fa-check-square-o{{else}}fa-square-o{{/if}}"></i> - </a> + <i id="group-{{$group.id}}" class="widget-nav-pills-checkbox fa {{if $group.ismember}}fa-check-square-o{{else}}fa-square-o{{/if}}" onclick="contactgroupChangeMember('{{$group.id}}','{{$group.enc_cid}}'); return true;"></i> {{/if}} {{if $group.edit}} - <a class="pull-right group-edit-tool" href="{{$group.edit.href}}" title="{{$edittext}}"><i class="group-edit-icon fa fa-pencil"></i></a> + <a href="{{$group.edit.href}}" class="widget-nav-pills-icons" title="{{$edittext}}"><i class="fa fa-pencil"></i></a> {{/if}} <a{{if $group.selected}} class="group-selected"{{/if}} href="{{$group.href}}">{{$group.text}}</a> </li> diff --git a/view/tpl/wiki.tpl b/view/tpl/wiki.tpl index 6d9f78800..6025ded27 100644 --- a/view/tpl/wiki.tpl +++ b/view/tpl/wiki.tpl @@ -11,9 +11,6 @@ <a id="rename-page" class="nav-link" href="#"><i class="fa fa-edit"></i> Rename Page</a> </li> <li class="nav-item"> - <a id="delete-page" class="nav-link" href="#"><i class="fa fa-trash-o"></i> Delete Page</a> - </li> - <li class="nav-item"> <a id="embed-image" class="nav-link" href="#"><i class="fa fa-picture-o"></i> Embed Image</a> </li> </ul> @@ -239,33 +236,6 @@ ev.preventDefault(); }); - $('#delete-page').click(function (ev) { - if (window.wiki_resource_id === '' || window.wiki_page_name === '' || window.wiki_page_name === 'Home') { - window.console.log('You must have a wiki page open in order to delete pages.'); - ev.preventDefault(); - return false; - } - if(!confirm('Are you sure you want to delete the page: ' + window.wiki_page_name)) { - ev.preventDefault(); - return; - } - $.post("wiki/{{$channel}}/delete/page", {name: window.wiki_page_name, resource_id: window.wiki_resource_id}, - function (data) { - if (data.success) { - window.console.log('Page deleted successfully.'); - var url = window.location.href; - if (url.substr(-1) == '/') url = url.substr(0, url.length - 2); - url = url.split('/'); - url.pop(); - window.location = url.join('/'); - } else { - alert('Error deleting page.'); // TODO: Replace alerts with auto-timeout popups - window.console.log('Error deleting page.'); - } - }, 'json'); - ev.preventDefault(); - }); - function wiki_revert_page(commitHash) { if (window.wiki_resource_id === '' || window.wiki_page_name === '') { window.console.log('You must have a wiki page open in order to revert pages.'); diff --git a/view/tpl/wiki_page_list.tpl b/view/tpl/wiki_page_list.tpl index 723cd0904..bd6d2d759 100644 --- a/view/tpl/wiki_page_list.tpl +++ b/view/tpl/wiki_page_list.tpl @@ -4,7 +4,12 @@ <ul class="nav nav-pills nav-stacked"> {{if $pages}} {{foreach $pages as $page}} - <li><a href="/wiki/{{$channel}}/{{$wikiname}}/{{$page.url}}">{{$page.title}}</a></li> + <li id="{{$page.link_id}}"> + {{if $page.resource_id && $canadd}} + <i class="widget-nav-pills-icons fa fa-trash-o drop-icons" onclick="wiki_delete_page('{{$page.title}}', '{{$page.url}}', '{{$page.resource_id}}', '{{$page.link_id}}')"></i> + {{/if}} + <a href="/wiki/{{$channel}}/{{$wikiname}}/{{$page.url}}">{{$page.title}}</a> + </li> {{/foreach}} {{/if}} {{if $canadd}} @@ -39,4 +44,31 @@ }, 'json'); ev.preventDefault(); }); + + function wiki_delete_page(wiki_page_name, wiki_page_url, wiki_resource_id, wiki_link_id) { + if(!confirm('Are you sure you want to delete the page: ' + wiki_page_name)) { + return; + } + $.post("wiki/{{$channel}}/delete/page", {name: wiki_page_url, resource_id: wiki_resource_id}, + function (data) { + if (data.success) { + window.console.log('Page deleted successfully.'); + if(wiki_page_url == window.wiki_page_name) { + var url = window.location.href; + if(url.substr(-1) == '/') + url = url.substr(0, url.length - 2); + url = url.split('/'); + url.pop(); + window.location = url.join('/'); + } + else { + $('#' + wiki_link_id).remove(); + } + } else { + alert('Error deleting page.'); // TODO: Replace alerts with auto-timeout popups + window.console.log('Error deleting page.'); + } + }, 'json'); + return false; + } </script> |