From 1b7918f9afc34b370453fe41b60d383eab73924a Mon Sep 17 00:00:00 2001 From: filesite Date: Tue, 7 May 2024 23:34:39 +0000 Subject: [PATCH] tag manage ui ready --- themes/tajian/controller/SiteController.php | 3 +- themes/tajian/views/my/tags.php | 10 +++ www/css/tajian.css | 1 + www/img/arrow-down.svg | 4 ++ www/img/arrow-up.svg | 4 ++ www/js/tajian.js | 79 +++++++++++++++++++++ 6 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 www/img/arrow-down.svg create mode 100644 www/img/arrow-up.svg diff --git a/themes/tajian/controller/SiteController.php b/themes/tajian/controller/SiteController.php index 61c84b0..bf293dd 100644 --- a/themes/tajian/controller/SiteController.php +++ b/themes/tajian/controller/SiteController.php @@ -146,10 +146,9 @@ Class SiteController extends Controller { $sorted_tags[$id] = $item; } } - } - return $sorted_tags; + return array_merge($sorted_tags, $tags); } //根据tag的filenames获取它们的files数据,数据结构保持跟原file一致 diff --git a/themes/tajian/views/my/tags.php b/themes/tajian/views/my/tags.php index ba9e901..ff044be 100644 --- a/themes/tajian/views/my/tags.php +++ b/themes/tajian/views/my/tags.php @@ -8,13 +8,23 @@ if (!empty(FSC::$app['config']['multipleUserUriParse']) && !empty(FSC::$app['use
$tag) { + $tagsTotal ++; + } + $index = 0; foreach($viewData['tags'] as $id => $tag) { + $upIconCls = $index == 0 ? 'hide' : ''; + $downIconCls = $index < $tagsTotal - 1 ? '' : 'hide'; + $index ++; echo << + 向上移动 + 向下移动 eof; diff --git a/www/css/tajian.css b/www/css/tajian.css index 338edff..e7cb005 100644 --- a/www/css/tajian.css +++ b/www/css/tajian.css @@ -260,6 +260,7 @@ a:link{text-decoration:none;} .mg_menus li a:hover{background-color:lightblue;color:#FFF;font-weight:bold} .mg_menus li img{vertical-align:middle} .tag-item .btn-danger{float:right} +.tag-item img{cursor:pointer} /* layout index */ body.layout_index{background-color:#e5f1f3} diff --git a/www/img/arrow-down.svg b/www/img/arrow-down.svg new file mode 100644 index 0000000..5286adf --- /dev/null +++ b/www/img/arrow-down.svg @@ -0,0 +1,4 @@ + + + + diff --git a/www/img/arrow-up.svg b/www/img/arrow-up.svg new file mode 100644 index 0000000..8506d92 --- /dev/null +++ b/www/img/arrow-up.svg @@ -0,0 +1,4 @@ + + + + diff --git a/www/js/tajian.js b/www/js/tajian.js index ad29347..64f2620 100644 --- a/www/js/tajian.js +++ b/www/js/tajian.js @@ -8,6 +8,7 @@ var taJian = { apis: { addVideos: '/frontapi/addfav', //添加视频 setNickname: '/frontapi/setnickname', //设置昵称 + saveTags: '/frontapi/savetags', //保存分类 sendSmsCode: '/frontapi/sendsmscode', //发送短信验证码 register: '/frontapi/createuser', //注册 login: '/frontapi/loginuser' //登入 @@ -396,4 +397,82 @@ if ($('#nickname_form').get(0)) { }); } +// tag分类管理 +if ($('#tags_form').get(0)) { + $('#tags_form .tag-item img').click(function(e) { + var action = $(this).attr('data-action'); + var current_el = $(this).parents('.tag-item'), + next_el = current_el.next('.tag-item'), + prev_el = current_el.prev('.tag-item'); + + var current_tag = current_el.find('input').val(), another_tag; + if (action == 'up' && prev_el.length > 0) { + another_tag = prev_el.find('input').val(); + prev_el.find('input').val(current_tag); + }else if (action == 'down' && next_el.length > 0) { + another_tag = next_el.find('input').val(); + next_el.find('input').val(current_tag); + } + + current_el.find('input').val(another_tag); + }); + + $('#tags_form .tag-item button.btn-danger').click(function(e) { + var current_el = $(this).parents('.tag-item'), + current_tag = current_el.find('input').val(); + + if ($('#tags_form input').length == 1) { + alert('请至少保留一个分类!'); + return false; + } + + if (confirm('确定删除分类“' + current_tag + '”吗?')) { + current_el.remove(); + } + }); + + $('#tags_form .jsbtn').click(function(e) { + e.preventDefault(); + + var tag_els = $('#tags_form input'), + tags = []; + + if (tag_els.length == 0) { + alert('请至少保留一个分类!'); + return false; + } + + for (var index=0;index