You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2012/07/04 10:09:53 UTC

svn commit: r1357148 - in /myfaces/tobago/trunk/tobago-theme: tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/ tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/st...

Author: lofwyr
Date: Wed Jul  4 08:09:52 2012
New Revision: 1357148

URL: http://svn.apache.org/viewvc?rev=1357148&view=rev
Log:
Moving JavaScript from *.java to *.js
Using Tobago.registerListener for initialization

Modified:
    myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PopupRenderer.java
    myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-popup.js

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PopupRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PopupRenderer.java?rev=1357148&r1=1357147&r2=1357148&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PopupRenderer.java (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-scarborough/src/main/java/org/apache/myfaces/tobago/renderkit/html/scarborough/standard/tag/PopupRenderer.java Wed Jul  4 08:09:52 2012
@@ -49,12 +49,9 @@ public class PopupRenderer extends Layou
   @Override
   public void prepareRender(FacesContext facesContext, UIComponent component) throws IOException {
 
-    UIPopup popup = (UIPopup) component;
-
+    final UIPopup popup = (UIPopup) component;
     FacesContextUtils.addPopup(facesContext, popup);
 
-    FacesContextUtils.addScriptBlock(facesContext, "jQuery(document).ready(function() {Tobago.Popup.setup();});");
-
     super.prepareRender(facesContext, popup);
 
     if (popup.isModal()) {
@@ -64,17 +61,11 @@ public class PopupRenderer extends Layou
 
   @Override
   public void encodeBegin(FacesContext facesContext, UIComponent component) throws IOException {
-    TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
-    // TODO check ajaxId
-    if (FacesContextUtils.isAjax(facesContext)) {
-      writer.startJavascript();
-      writer.write("Tobago.Popup.setup();");
-      writer.endJavascript();
-    }
-    
-    UIPopup popup = (UIPopup) component;
 
-    LayoutContext layoutContext = new LayoutContext(popup);
+    final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
+    final UIPopup popup = (UIPopup) component;
+
+    final LayoutContext layoutContext = new LayoutContext(popup);
     layoutContext.layout();
 
     // XXX fixing invisible popups

Modified: myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-popup.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-popup.js?rev=1357148&r1=1357147&r2=1357148&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-popup.js (original)
+++ myfaces/tobago/trunk/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-popup.js Wed Jul  4 08:09:52 2012
@@ -18,9 +18,12 @@
 Tobago.Popup = {};
 
 /**
- * Setup popup size
+ * Init popup size
  */
-Tobago.Popup.setup = function () {
+Tobago.Popup.init = function (elements) {
+
+  // here the "elements" are not used in the moment, may change in the future...
+  // this is because this init() function works globally instead of the other init functions
 
   Tobago.Utils.keepElementInVisibleArea(jQuery(".tobago-popup"));
 
@@ -225,6 +228,14 @@ Tobago.openPopupWithAction = function (s
   Tobago.Popup.openWithAction(source, popupId, actionId, options);
 };
 
+/**
+ * Setup popup size
+ * @deprecated since Tobago 1.6.0
+ */
+Tobago.Popup.setup = function () {
+  LOG.warn("Deprecated method was called. Please use Tobago.Popup.init()"); // @DEV_ONLY
+  Tobago.Popup.init();
+};
 
 // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 // old functions...
@@ -305,3 +316,5 @@ function setPopupPara(width, height, opt
   return width + height + parent + dirbar + locationbar + menubar + resizable + scrollbars + statusbar + toolbar;
 }
 
+Tobago.registerListener(Tobago.Popup.init, Tobago.Phase.DOCUMENT_READY);
+Tobago.registerListener(Tobago.Popup.init, Tobago.Phase.AFTER_UPDATE);