Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Nicholas Westby 2054 posts 7103 karma points c-trib
    Jan 29, 2014 @ 01:02
    Nicholas Westby
    0

    Bug: uHidesy Has Issues with Properties with Descriptions

    Umbraco 6.1.6. uHidesy 1.13. Chrome. Windows 8.1.

    I have a development and a production environment, and some properties that have a description in one environment do not have a description in another environment.

    It seems that uHidesy has issues with this, as it doesn't hide properties the same in each environment, and the only variable seems to be the existence of property descriptions.

    This seems to be related to the fact that Umbraco injects BR tags after property names when those properties also have descriptions. When that happens, uHidesy includes an encoded form of the BR tag in the property name in the settings.json file, like this (note the "\u003cbr\u003e" at the end of the property name):

    {
       "name":"Page Title\u003cbr\u003e",
       "index":1,
       "status":"show"
    },
  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    Apr 05, 2014 @ 18:30
    Anthony Dang
    0

    uHidesy is basically hacking the DOM with jquery. If you have a solution to this, I'm happy to add it to the package.

  • Nicholas Westby 2054 posts 7103 karma points c-trib
    Apr 06, 2014 @ 22:19
    Nicholas Westby
    0

    Should be simple enough. Here is what a property with a description looks like:

    <div class="propertyItemheader">Header<br><small>This is the header.</small></div>

    You only want "Header". So, you can select the element (".propertyItemheader"), clone it, remove the "small" element within it (using $.remove), and then call $.text (rather than $.html) on the result element. Calling $.text ensures you don't get the "br" element when you convert it to a string. Here are the existing uHidesy lines you'd want to change (I think... you'd want to make sure any time you interact with a property that you do exactly this procedure to ensure consistent results):

    var propertyName = propertyItemheader.length == 0 ? '-Property-name-not-displayed-' : $(propertyItemheader).html();
    propertyName = propertyName.indexOf('<small>') == -1 ? propertyName : propertyName.substring(0, propertyName.indexOf('<small>'));

    I just tried the following in the Chrome console to get a result of "Header" (the property name):

    (function () {var clone = $(".propertyItemheader").first().clone(); clone.children("small").remove(); return clone.text();})();

    You should be able to adapt that for use with uHidesy. Note that you could also future-proof it a bit by removing all children. Since the $.children does not include text elements, removing all children would leave the property name text intact but would remove the "br" and "small" tags (and any other tags that may get added down the road for whatever reason).

  • Nicholas Westby 2054 posts 7103 karma points c-trib
    Apr 07, 2014 @ 18:24
    Nicholas Westby
    0

    Also, you may want to trim leading/trailing whitespace ($.trim), just to be on the safe side.

Please Sign in or register to post replies

Write your reply to:

Draft