Exemplo n.º 1
0
        private JsArray <HtmlElement> findChildNodesForSelector(JsArray <HtmlElement> elements, JsArray <JsString> selectorArray)
        {
            var selector = selectorArray.shift();

            //We need to actually abstract this so we can deal with IE and Opera returning a collection instead of a NodeList

            var newElements = new JsArray <HtmlElement>();

            if (selector.substr(0, 1) == ".")
            {
                var className = selector.substring(1);
                //Lets assume this is a class selector
                while (elements.length > 0)
                {
                    var element = elements.pop();
                    var nodes   = element.getElementsByClassName(className);
                    for (var j = 0; j < nodes.length; j++)
                    {
                        newElements.push(nodes[j].As <HtmlElement>());
                    }
                }
            }
            else
            {
                //invalid but going to assume type for now
                while (elements.length > 0)
                {
                    var element = elements.pop();
                    var nodes   = element.getElementsByTagName(selector);

                    for (var j = 0; j < nodes.length; j++)
                    {
                        newElements.push(nodes[j].As <HtmlElement>());
                    }
                }
            }

            //Only recurse if there is another selector
            if (selectorArray.length > 0)
            {
                newElements = findChildNodesForSelector(newElements, selectorArray);
            }

            return(newElements);
        }
Exemplo n.º 2
0
        public void _moveBallInternal(ball b, JsArray<point> points, JsAction callback)
        {
            itemBase self = this;

            point point = points.pop();
            if (point != null)
            {
                b.getDiv().style.left = point.x + "%";
                b.getDiv().style.top = point.y + "%";
                if (point.inSide != ESlide.none)
                {
                    b.setInSide(point.inSide);
                }
                HtmlContext.window.setTimeout(delegate { self._moveBallInternal(b, points, callback); }, 50);
            }
            else
            {
                callback();
            }
        }
Exemplo n.º 3
0
 public T Pop()
 {
     return(storage.pop().As <T>());
 }
Exemplo n.º 4
0
 public void removeFromArray(JsArray items, JsObject obj)
 {
     JsArray tmpArray = new JsArray();
     foreach (JsObject tmp in items)
     {
         if (tmp != obj)
         {
             tmpArray.push(tmp);
         }
     }
     while (items.length > 0)
     {
         items.pop();
     }
     foreach (object tmp in tmpArray)
     {
         items.push(tmp);
     }
 }
        private JsArray<HtmlElement> findChildNodesForSelector(JsArray<HtmlElement> elements, JsArray<JsString> selectorArray)
        {
            var selector = selectorArray.shift();

            //We need to actually abstract this so we can deal with IE and Opera returning a collection instead of a NodeList

            var newElements = new JsArray<HtmlElement>();

            if ( selector.substr( 0, 1 ) == "." ) {
                var className = selector.substring( 1 );
                //Lets assume this is a class selector
                while ( elements.length > 0 ) {
                    var element = elements.pop();
                    var nodes = element.getElementsByClassName( className );
                    for ( var j=0; j<nodes.length; j++) {
                        newElements.push( nodes[ j ].As<HtmlElement>() );
                    }
                }

            } else {
                //invalid but going to assume type for now
                while (elements.length > 0) {
                    var element = elements.pop();
                    var nodes = element.getElementsByTagName(selector);

                    for (var j = 0; j < nodes.length; j++) {
                        newElements.push( nodes[j].As<HtmlElement>() );
                    }
                }
            }

            //Only recurse if there is another selector
            if (selectorArray.length > 0) {
                newElements = findChildNodesForSelector(newElements, selectorArray);
            }

            return newElements;
        }