DIR : /home/kozerus/public_html/dgs/js/tags.js

/home/kozerus/public_html/dgs/js

// <!--
/*
Dragon Go Server
Copyright (C) 2001-  Jens-Uwe Gaspar

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

// ---------- Forums -------------------------------

if (window.jQuery && DGS.constants.ENABLE_FORUM_TAGS) {
   $(function () {
      var $tagList = $('#TagList'); // re-use one edit-container for all posts inserting at post-editing position
      $tagList.data('post-id', 0);

      $('table.Forum a.EditTag').click(function () {
         var editPostId = $tagList.data('post-id');
         if (editPostId > 0) {  // redraw user-tags (with active tags stored in data('active-tags')
            var $editPostTagsContainer = $('#ptags' + editPostId);
            var activeTags = $tagList.data('active-tags');
            $('span.Tag', $tagList).filter(function() { // add in correct tag order
               return ($(this).attr('tag-id') in activeTags);
            }).each(function() {
               $(this).clone().appendTo($editPostTagsContainer).removeClass('Inactive');
            });
         }

         var postId = $(this).attr('data-post-id');
         if ($tagList.is(':visible') && editPostId == postId) { // close edit of post-tags
            $tagList.hide().detach();
            $tagList.data('post-id', 0);
         } else { // edit new or another tag-list for post
            var $postTagsContainer = $('#ptags' + postId);
            $tagList.data('post-id', postId);

            // set active-state for tags-edit (taken from user-tags)
            var activeTags = {};
            $('span.Tag', $postTagsContainer).detach().map(function () {
               return $(this).attr('tag-id');
            }).each(function (idx, tagId) {
               activeTags[tagId] = tagId;
            });
            $tagList.data('active-tags', activeTags);
            $('span.Tag', $tagList).addClass('Inactive').filter(function () {
               return ($(this).attr('tag-id') in activeTags);
            }).removeClass('Inactive');

            $tagList.hide().detach().appendTo($postTagsContainer).show();

            // add actions to toggle tag-state
            $('span.Tag', $tagList).off('click').click(function (evt) {
               var that = this;
               var tagId = $(this).attr('tag-id');
               var tagActive = (tagId in activeTags);
               var tagCommand = (tagActive) ? 'delete' : 'add';

               var fn_success_toggle_tag = function () {
                  if (tagActive) {
                     delete activeTags[tagId];
                  } else {
                     activeTags[tagId] = tagId;
                  }
                  $tagList.data('active-tags', activeTags);
                  $(that).toggleClass('Inactive', tagActive);
               };

               DGS.QuickRemoteApi.get_quick_do(fn_success_toggle_tag, '', that, evt, {
                  obj: 'tag',
                  cmd: tagCommand,
                  tag: tagId,
                  target: postId
               });
            });
         }//click@edit

         return false;
      });

      $('table.Forum a.LikePost').click(function (evt) {
         var that = this;
         var postId = $(this).attr('data-post-id');
         var $postLikeCounter = $('#plike' + postId);
         var $threadpostOverview = $('#povlike' + postId);

         var fn_success_toggle_like = function (data) {
            var isLiked = !!+data['liked'];
            var countLikes = data['count_likes'];

            $postLikeCounter.text(countLikes);
            $('img.Likes', that).toggleClass('Liked', isLiked);

            if ($threadpostOverview.length) {
               $('img.Likes', $threadpostOverview).toggleClass('Liked', isLiked);
               $('span.Likes', $threadpostOverview).text(countLikes);
               $threadpostOverview.toggleClass('hidden', (countLikes <= 0));
            }
         };

         DGS.QuickRemoteApi.get_quick_do(fn_success_toggle_like, '', this, evt, {
            obj: 'tag',
            cmd: 'toggle_like',
            target: postId
         });

         return false;
      });
   });
}//jQuery

// -->
//


koh5_pano



Your browser does not support the HTML5 canvas element.


Drag mouse to navigate.

Navigation





17.Aug.2010, Martin Wengenmayer