RadContextMenu Ipad

3 posts, 0 answers
  1. Rodrigo
    Rodrigo avatar
    7 posts
    Member since:
    Jan 2012

    Posted 10 Nov 2012 Link to this post

    Hello,

    I have a radcontextmenu that targets a RadDock and I'm trying to make the right click work for ipad. I saw the implementation in a radtree, but I'm trying to adopt it without success.

    Thanks,

    Rod

    function pageLoad() {
                    var isMobileSafari = (navigator.userAgent.search(/like\sMac\sOS\sX;.*Mobile\/\S+/) != -1)
                    if (isMobileSafari) {
                        var ctx = document.getElementById("<%= RadDock1.ClientID "%>);
                        ctx.addEventListener('touchstart', handleTouchStart, false);
                        ctx.addEventListener('touchend', handleTouchEnd, false);
                    }
                }
     
                var lastContext = null;
                var longTouchID = 0;
                var menuShown = false;
     
                function longTouch() {
                    longTouchID = 0;
                    menuShown = true;
     
                    var ctx = document.getElementById("<%= radMenu1.ClientID "%>);
                    ctx.show();
                }
     
                function handleTouchStart(e) {
                    longTouchID = setTimeout(longTouch, 1000);
                }
     
                function handleClick(e) {
                    if (menuShown) {
                        menuShown = false;
                        document.body.removeEventListener('click', handleClick, true);
                        e.stopPropagation();
                        e.preventDefault();
                    }
                }
     
                function handleTouchEnd(e) {
                    if (longTouchID != 0)
                        clearTimeout(longTouchID);
                    if (menuShown) {
                        document.body.addEventListener('click', handleClick, true);
                        e.preventDefault();
                    }
                }
  2. AMS
    AMS avatar
    34 posts
    Member since:
    Aug 2008

    Posted 20 Nov 2012 Link to this post

    you are not closing your quotes properly:
    var ctx = document.getElementById("<%= RadDock1.ClientID %>"); write this line

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. AMS
    AMS avatar
    34 posts
    Member since:
    Aug 2008

    Posted 20 Nov 2012 Link to this post

    I am getting the error in the Telerik code:

    tree._contextMenu[undefined] is not a function. Its probably due to this line:

     var lastContext = null; 

    Anybody to give suggestion/help?

    <script type="text/javascript"  language="javascript">
        function ClientMouseOver(sender, e) {
            var contextMenu = $find("<%= completedContextMenu.ClientID %>");
     
            if ((!e.relatedTarget) || (!$telerik.isDescendantOrSelf(contextMenu.get_element(), e.relatedTarget))) {
                contextMenu.show(e);
            }
     
            $telerik.cancelRawEvent(e);
        }
     
        function pageLoad() {
            if (document.getElementById('<%= hdnVisited.ClientID %>').value == "") {
                var popup = $find('<%= pnlMessagePopup.ClientID %>');
                if (popup != null) {
                    popup.show();
                    document.getElementById('<%= hdnVisited.ClientID %>').value = "visited";
                }
            }
     
            // for context menu
            if ($telerik.isMobileSafari) {
                            //var treeArea = $telerik.$($find('tvCompletedCourses').get_element())[0];
                var treeArea = document.getElementById('<%= tvCompletedCourses.ClientID %>');
                alert(treeArea);
                treeArea.addEventListener('touchstart', handleTouchStart, false);
                treeArea.addEventListener('touchend', handleTouchEnd, false);
            }
     
     
        }
     
        function closePopup() {
            var popup = $find('<%= pnlMessagePopup.ClientID %>');
            if (popup != null) {
                popup.close();
            }
        }
     
        var lastContext = null;
        var longTouchID = 0;
        var menuShown = false;
     
        function longTouch() {
            longTouchID = 0;
            menuShown = true;
     
            var tree = document.getElementById('<%= tvCompletedCourses.ClientID %>');
            tree._contextMenu(lastContext);
        }
     
        function handleTouchStart(e) {
            lastContext = e;
            lastContext.button = 2;
            lastContext.target = e.originalTarget;
            lastContext.eventMapTarget = lastContext.target;
            lastContext.pageX = e.changedTouches[0].pageX;
            lastContext.pageY = e.changedTouches[0].pageY;
            lastContext.clientX = e.changedTouches[0].clientX;
            lastContext.clientY = e.changedTouches[0].clientY;
            longTouchID = setTimeout(longTouch, 1000);
        }
     
        function handleClick(e) {
            if (menuShown) {
                menuShown = false;
                document.body.removeEventListener('click', handleClick, true);
                e.stopPropagation();
                e.preventDefault();
            }
        }
     
        function handleTouchEnd(e) {
            if (longTouchID != 0)
                clearTimeout(longTouchID);
     
            if (menuShown) {
                document.body.addEventListener('click', handleClick, true);
                e.preventDefault();
            }
        }
     
    </script>
Back to Top