Package org.itsnat.impl.core.clientdoc

Examples of org.itsnat.impl.core.clientdoc.ClientDocumentStfulImpl


            // y ASV3. Da igual lo que pase en los dem�s (Opera, Chrome etc) no
            // tiene sentido ocultar un <script>
            String localName = elem.getLocalName();
            if (localName.equals("script")) return;

            ClientDocumentStfulImpl clientDoc = getClientDocumentStful();
            Browser browser = clientDoc.getBrowser();
            if (browser instanceof BrowserAdobeSVG)
            {
                // El <foreignObject> tampoco tiene objeto style en ASV3
                // este elemento ES visual pero como no est� reconocido
                // en ASV3 los elementos hijo son tratados como elementos SVG
View Full Code Here


        else
        {
            reverseBodyElements = bodyElementsBefore.toArray(reverseBodyElements);
        }

        ClientDocumentStfulImpl clientDoc = getClientDocumentStful();
        StringBuilder code = new StringBuilder();
        for(int i = 0; i < reverseBodyElements.length; i++ )
        {
            Element elem = reverseBodyElements[i];
            JSRenderElementImpl render = JSRenderElementImpl.getJSElementRender(elem,clientDoc);
            String elemRef = clientDoc.getNodeReference(elem,true,true);
            // No usar el nombre "elem" por si acaso porque es usado por el modal layer
            code.append("var elem = " + elemRef + ";\n");
            renderShowHide(elem,"elem",hide,code,render);
        }
        clientDoc.addCodeToSend(code.toString());
    }
View Full Code Here

        clientDoc.addCodeToSend(code.toString());
    }

    protected void renderShowHide(Element elem,String elemVarName,boolean hide,StringBuilder code,JSRenderElementImpl render)
    {
        ClientDocumentStfulImpl clientDoc = getClientDocumentStful();
        if (hide)
        {
            code.append(render.getBackupAndSetStyleProperty(elemVarName,"display","none",clientDoc));
        }
        else
View Full Code Here

    }


    public void dispatchRequestListeners()
    {
        ClientDocumentStfulImpl clientDoc = getClientDocumentStful();
        BrowserWebKit browser = (BrowserWebKit)clientDoc.getBrowser();
        if (browser.isChangeNotFiredHTMLSelectWithSizeOrMultiple(null))
            fixDOMHTMLSelectWithSizeOrMultipleElementsChangeNotFired();

        super.dispatchRequestListeners();
    }
View Full Code Here

        // con atributos multiple o size no lanzan el evento change
        // Detectamos blur para lanzar el change antes de ser procesado.
        // http://lists.apple.com/archives/safari-iphone-web-dev/2008/Jul/msg00025.html
        // http://groups.google.com/group/iphonewebdev/browse_thread/thread/33288230c30cbd53

        ClientDocumentStfulImpl clientDoc = getClientDocumentStful();
        if (!clientDoc.isScriptingEnabled())
            return;

        StringBuilder code = new StringBuilder();

        code.append("var func = function (evt)");
        code.append("{");
        code.append("  if (\"select\" != evt.target.localName) return;");
        code.append("  if (!evt.target.hasAttribute(\"multiple\")&&!evt.target.hasAttribute(\"size\")) return;");
        code.append("  var evtTmp = document.createEvent(\"UIEvents\");");
        code.append("  evtTmp.initUIEvent(\"change\",true,true,window,0);");
        code.append("  evt.target.dispatchEvent(evtTmp);");
        code.append("};");

        String type;
        Browser browser = clientDoc.getBrowser();
        if (browser instanceof BrowserWebKitS40) type = "click";
        else type = "blur"; // En Android el click es ignorado pues hay un editor especial, idem en iPhone adem�s hasta el blur el estado no es correcto

        code.append("document.addEventListener(\"" + type + "\",func,true);"); // Notar que es capture para asegurar que se ejecuta el primero de todo
View Full Code Here

        return (ItsNatModalLayerHTMLImpl)parentComp;
    }

    public void initModalLayer()
    {
        ClientDocumentStfulImpl clientDoc = getClientDocumentStful();
        Browser browser = clientDoc.getBrowser();

        Element layerElem = parentComp.getElement();
        int zIndex = parentComp.getZIndex();
        String background = parentComp.getBackground();
        float opacity = parentComp.getOpacity();

        // La no definici�n de la propiedad background supone usar los valores
        // por defecto, y lo normal es que background-color sea "transparent" por defecto.
        String backgroundProp;
        if ( (background != null) &&
             (browser.hasHTMLCSSOpacity() || (opacity >= (float)0.5)) )
            backgroundProp = background;
        else
        {
            if (background == null) // Transparente (valor por defecto normal)
            {
                // Vemos qu� casos el fondo transparente no es v�lido
                if ((browser instanceof BrowserMSIEOld)||(browser instanceof BrowserMSIE9))
                {
                    // El fondo transparente ignora el z-index, los elementos por debajo son pulsables,
                    // evitamos as� esto.
                    backgroundProp = "white";
                    opacity = 0;
                }
                else
                    backgroundProp = null;
            }
            else backgroundProp = background;
        }

        StringBuilder code = new StringBuilder();
        String elemLayerRef = clientDoc.getNodeReference(layerElem,true,true);
        code.append( "var elem = " + elemLayerRef + ";\n" );


        {
            StringBuilder styleCode = new StringBuilder();
            styleCode.append( "position:absolute; top:0px; left:0px; width:1px; height:1px; margin:0px; padding:0px; border:0px; " ); // border:1px red solid; para testear
            styleCode.append( "z-index:" + zIndex + "; " );
            if (browser.hasHTMLCSSOpacity()) // Evitamos poner la opacidad si no se soporta, por ej. en Opera Mobile 9.7 beta hay un bug que hace que se oculte el nodo si opacity < 1
            {
                styleCode.append( "opacity:" + opacity + "; " );

                if (browser instanceof BrowserMSIEOld)
                {
                    // Por script ser�a: http://msdn.microsoft.com/en-us/library/ms532847(VS.85).aspx#Scripting_Filters
                    int opInt = (int)(100*opacity);
                    styleCode.append( "filter:alpha(opacity=" + opInt + "); " ); // Equivale en CSS a: filter:alpha(opacity=" + opInt + ") La sintaxis:  elem.style.filter.opacity = .. s�lo funciona si el filtro ya est� presente
                }
            }

            if (backgroundProp != null)
                 styleCode.append( "background:" + backgroundProp + "; " );
            else
            {
                if (browser instanceof BrowserOpera)
                {
                    // El color transparente por s� solo no respeta el z-index, hay que "ayudar"
                    // Probado en Opera 9.63 y Mobile v9.5, 9.7 y 9.8 (la v10). Podemos arreglarlo con una imagen transparente.
                    styleCode.append( "background-image:url('data:image/gif;base64,R0lGODlhCgAKAIAAAP///////yH5BAEKAAEALAAAAAAKAAoAAAIIjI+py+0PYysAOw==');");
                }
            }

            // code.append( "elem.style.cssText = \"" + styleCode.toString() + "\";\n" );

            // En el caso de MSIE el cliente sabe que hay que utilizar cssText
            code.append("itsNatDoc.setAttribute(elem,\"style\",\"" + styleCode.toString() + "\");\n");
        }

        // Aparentemente podr�amos poner el layer con width:100% y height:100%
        // tal que se redimensionara autom�ticamente cuando cambiara la ventana,
        // sin embargo no es as�, este 100% representa el �rea visible sin contar
        // la parte oculta y accesible usando el scroll, por lo que el recalculado
        // es inevitable.

        // El timer es para cuando se redimensiona la ventana por el usuario
        // y se recoloca el HTML y tambi�n para el siguiente caso: aunque en
        // teor�a el HTML que se a�ada despu�s para que se vea "encima" del ModalLayer
        // puede cambiar las dimensiones de la p�gina, como tenemos un timer
        // no hay problema, se corregir� s�lo.

        // Lo de "style.width = '1px';" y "style.height = '1px';" tiene el siguiente
        // sentido: nuestra capa modal busca tapar lo que hay "debajo" para ello
        // se calcula la dimensi�n m�xima de la p�gina y la capa se redimensiona para ello.
        // El problema es que si hay redimensionamiento o bien porque el usuario cambia
        // el tama�o de la ventana, o porque nuevo HTML es a�adido (posiblemente con posicionamiento
        // absoluto), el teor�a la dimensi�n "natural" de la p�gina cambiar�a sin embargo la propia
        // capa modal ahora influye en el dimensionamiento, por eso haciendo
        // width/height = '1px'; antes de obtener la nueva dimensi�n conseguimos
        // que htmlElem.scrollWidth/scrollHeight se calculen sin contar con la capa modal.

        String methodName = "initModalLayerHTML";
        if (!clientDoc.isClientMethodBounded(methodName))
            code.append(bindInitModalLayerMethod(methodName));

        code.append("itsNatDoc." + methodName + "(elem);\n");

        clientDoc.addCodeToSend(code.toString());
    }
View Full Code Here

        showHideHTMLFormElements(true);
    }

    private void showHideHTMLFormElements(boolean show)
    {
        ClientDocumentStfulImpl clientDoc = getClientDocumentStful();

        ItsNatModalLayerHTMLImpl parentComp = getItsNatModalLayerHTML();
        ItsNatModalLayerImpl prevComp = parentComp.getPreviousItsNatModalLayer();
        int zIndex1 = prevComp != null? prevComp.getZIndex() : Integer.MIN_VALUE; // El z-index puede ser negativo
        int zIndex2 = parentComp.getZIndex();

        StringBuilder code = new StringBuilder();

        String methodName = "modalLayerShowHTMLFormCtrls";
        if (!clientDoc.isClientMethodBounded(methodName))
            code.append(bindModalLayerShowFormCtrlsMethod(methodName,clientDoc));

        Browser browser = clientDoc.getBrowser();
        Map<String,String[]> localNames = browser.getHTMLFormControlsIgnoreZIndex();
        Document doc = clientDoc.getItsNatStfulDocument().getDocument();

        for(Map.Entry<String,String[]> entry : localNames.entrySet())
        {
            String localName = entry.getKey();
            String[] types = entry.getValue();

            LinkedList<Node> elemList = DOMUtilInternal.getChildElementListWithTagNameNS(doc,NamespaceUtil.XHTML_NAMESPACE,localName,true);
            if (elemList != null)
            {
                for(Node node : elemList)
                {
                    Element elem = (Element)node;
                    if ((types != null) && (elem instanceof HTMLInputElement))
                    {
                        boolean found = false;
                        String type = elem.getAttribute("type");
                        if (type.equals("")) type = "text";
                        for(int i = 0; i < types.length; i++)
                            if (types[i].equals(type)) { found = true; break; }
                        if (!found) continue;
                    }
                    code.append("var elem = " + clientDoc.getNodeReference(elem, true, true) + ";\n");
                    code.append("itsNatDoc." + methodName + "(elem," + show + "," + zIndex1 + "," + zIndex2 + ");\n");
                }
            }
        }

        clientDoc.addCodeToSend(code);
    }
View Full Code Here

        return code.toString();
    }

    public static String getCallDispatchEvent(String varResName,NodeLocationImpl nodeLoc,Event evt,String evtVarName)
    {
        ClientDocumentStfulImpl clientDoc = nodeLoc.getClientDocumentStful();

        EventTarget target = evt.getTarget();
        LinkedList<String> captureList = new LinkedList<String>();
        LinkedList<String> atTargetList = new LinkedList<String>();
        LinkedList<String> bubbleList = new LinkedList<String>();
View Full Code Here

            return ResponseDelegateHTMLLoadDocW3CImpl.createResponseDelegateHTMLLoadDocW3C((BrowserW3C)browser,responseParent);
    }

    public ItsNatHTMLDocumentImpl getItsNatHTMLDocument()
    {
        ClientDocumentStfulImpl clientDoc = getClientDocumentStful();
        return (ItsNatHTMLDocumentImpl)clientDoc.getItsNatDocument();
    }
View Full Code Here

            }
        }

        if (svgWeb)
        {
            ClientDocumentStfulImpl clientDoc = getClientDocumentStful();
            clientDoc.setSVGWebInfo(forceFlash,metaDecPos);
            addScriptFileToLoad(LoadScriptImpl.ITSNAT_SVGWEB);
        }
    }
View Full Code Here

TOP

Related Classes of org.itsnat.impl.core.clientdoc.ClientDocumentStfulImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.