how do I disable click on item

Development-related discussion, including bundled plugins
AMA3
Bear Rating Trainee
Bear Rating Trainee
Posts: 5
Joined: 11 Apr 2013, 17:49

how do I disable click on item

Postby AMA3 » 11 Apr 2013, 18:00

Hi everyone,

I'm a little bit click-happy so I would like to prevent an item from being marked read when I click on it. My guess is that I have to disable a click handler for elements with class "cdm" or possibly with ID beginning "RROW-", but I've searched the code for "click" and can't find such a thing.

Can you please point me in the right direction?

Thanks in advance for any help.

AMA3

koalabear7410
Bear Rating Trainee
Bear Rating Trainee
Posts: 10
Joined: 10 Apr 2013, 05:09

Re: how do I disable click on item

Postby koalabear7410 » 12 Apr 2013, 01:05

Just so you know, as far as I can tell, your desire to not have things marked-as-read when you click them makes you an insufferable buffoon who wouldn't know good UX if it licked you in the pucker. Please, don't shoot the messenger (me).

That being said, I wanted the exact same thing. I found the answer in the viewfeed.js file, in the js folder. Look for the function called cdmClicked, and comment out the bits that handle the mark-as-read functionality.

Code: Select all

function cdmClicked(event, id) {
   try {
      //var shift_key = event.shiftKey;

      if (!event.ctrlKey) {

         if (!getInitParam("cdm_expanded")) {
            return cdmExpandArticle(id);
         } else {

            var elem = $("RROW-" + getActiveArticleId());

            if (elem) elem.removeClassName("active");

            selectArticles("none");
            toggleSelected(id);

            var elem = $("RROW-" + id);
            var article_is_unread = elem.hasClassName("Unread");

            // elem.removeClassName("Unread");
            elem.addClassName("active");

            setActiveArticleId(id);

            // if (article_is_unread) {
            //    decrementFeedCounter(getActiveFeedId(), activeFeedIsCat());
            // }

            // var query = "?op=rpc&method=catchupSelected" +
            //    "&cmode=2&ids=" + param_escape(id);

            // new Ajax.Request("backend.php", {
            //   parameters: query,
            //   onComplete: function(transport) {
            //      handle_rpc_json(transport);
            //   } });

            return !event.shiftKey;
         }

      } else {
         toggleSelected(id, true);

         var elem = $("RROW-" + id);
         var article_is_unread = elem.hasClassName("Unread");

         //if (article_is_unread) {
         //   decrementFeedCounter(getActiveFeedId(), activeFeedIsCat());
         //}

         // toggleUnread(id, 0, false);

         openArticleInNewWindow(id);
      }

      var unread_in_buffer = $$("#headlines-frame > div[id*=RROW][class*=Unread]").length
      request_counters(unread_in_buffer == 0);

   } catch (e) {
      exception_error("cdmClicked");
   }

   return false;
}
.

There are other calls to toggleUnread in other functions, which you may want to comment-out as well. I commented out the instance within function cdmExpandArticle, to stop posts from being marked-as-read when they became active. When I get time, I'm going to figure out how to make a mobile-friendly Mark As Read/Unread button somewhere on each post.

Again, this is terrible, horrible, UX design and I am duly ashamed for wanting my tt-rss to be this way.

User avatar
idoxlr8
Bear Rating Trainee
Bear Rating Trainee
Posts: 46
Joined: 25 Mar 2013, 20:04
Location: Texas, USA
Contact:

Re: how do I disable click on item

Postby idoxlr8 » 12 Apr 2013, 03:29


AMA3
Bear Rating Trainee
Bear Rating Trainee
Posts: 5
Joined: 11 Apr 2013, 17:49

Re: how do I disable click on item

Postby AMA3 » 12 Apr 2013, 03:59

koalabear7410 wrote:I found the answer in the viewfeed.js file [...] There are other calls to toggleUnread in other functions, which you may want to comment-out as well.


Thank you so much, that advice was spot-on! I uncommented all of the calls to toggleUnread().


koalabear7410 wrote:When I get time, I'm going to figure out how to make a mobile-friendly Mark As Read/Unread button somewhere on each post.


As you might guess, I also wanted that functionality at the end of each post, and I think I've got it. I added the following to the end of viewfeed.js:

Code: Select all

function toggleReadButton(e,id)
{
  toggleUnread(id, 2, false);
  e.target.value = 'Mark ' + ($("RROW-" + id).hasClassName('Unread')?'R':'Unr')+'ead';
}


Next, inside classes/feeds.php, I found this (near line #679):

Code: Select all

$reply['content'] .= "<div class=\"cdmFooter\">";


Immediately after that line, I added the following:

Code: Select all

$reply['content'] .= "<input type=\"button\" value=\"Mark " .
    (strpos($class,'Unread')?'R':'Unr') .
    "ead\" onclick=\"toggleReadButton(event,'$id')\"/>";


This presents a simply button that switches from "Mark Read" (when the item is Unread) to "Mark Unread" (when the item is read). Of course, you could style it however you want in the CSS.

I hope this is as helpful to you (and other people who prefer a terrible UX :)) as much as your answer was helpful to me!

koalabear7410
Bear Rating Trainee
Bear Rating Trainee
Posts: 10
Joined: 10 Apr 2013, 05:09

Re: how do I disable click on item

Postby koalabear7410 » 12 Apr 2013, 04:24

idoxlr8, that is awesome! Thank you for sharing that link! I'm (obviously) really new here, and I haven't been able to dig into prior threads too much yet.

AMA3, you are my new hero.

For posterity:

I was actually able to hack in an ugly, but working, button up top with minimal effort. In my usual pattern, I'm at a keyboard using hotkeys to navigate up and down in a feed and to toggle read/unread. When I'm on a mobile device, sans keyboard, I need to be able to do the read/unread toggle in one click/touch.

I've found that in my hacked solution, the "current" article could be in a previously viewed feed, and since I'm toggling the current article, hilarity ensues. I'm hoping to see that idoxlr8's method solves for that (among other awesome things).

What I would prefer is a button on each individual post, in otherwise "empty" space, where I know that clicking that button is toggling for that post only. AMA3's solution appears to do just that: not only is the button streamed into the content at the bottom of the post, but the id of the post it belongs to is streamed right into the onclick handling code. I do see a right-click context menu on every post header that I presume does the same thing. However, I want one-click or one-touch, especially on mobile devices where I cannot reliably right-click.

So, thank you both!


Return to “Development”

Who is online

Users browsing this forum: No registered users and 2 guests