myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lof...@apache.org
Subject svn commit: r1698099 - in /myfaces/tobago/branches/tobago-3.0.x: tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/ tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/ tobago...
Date Thu, 27 Aug 2015 09:13:22 GMT
Author: lofwyr
Date: Thu Aug 27 09:13:21 2015
New Revision: 1698099

URL: http://svn.apache.org/r1698099
Log:
TOBAGO-1482: Using modal feature vom Bootstrap for Popups

Modified:
    myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlRoleValues.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/PopupRenderer.java
    myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-popup.js
    myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlRoleValues.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlRoleValues.java?rev=1698099&r1=1698098&r2=1698099&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlRoleValues.java
(original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/html/HtmlRoleValues.java
Thu Aug 27 09:13:21 2015
@@ -21,6 +21,8 @@ package org.apache.myfaces.tobago.render
 
 public enum HtmlRoleValues {
 
+  DIALOG("dialog"),
+  DOCUMENT("document"),
   MENU("menu"),
   NAVIGATION("navigation"),
   PRESENTATION("presentation"),

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/PopupRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/PopupRenderer.java?rev=1698099&r1=1698098&r2=1698099&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/PopupRenderer.java
(original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/standard/standard/tag/PopupRenderer.java
Thu Aug 27 09:13:21 2015
@@ -24,7 +24,9 @@ import org.apache.myfaces.tobago.interna
 import org.apache.myfaces.tobago.renderkit.LayoutComponentRendererBase;
 import org.apache.myfaces.tobago.renderkit.css.Style;
 import org.apache.myfaces.tobago.renderkit.html.BootstrapClass;
+import org.apache.myfaces.tobago.renderkit.html.HtmlAttributes;
 import org.apache.myfaces.tobago.renderkit.html.HtmlElements;
+import org.apache.myfaces.tobago.renderkit.html.HtmlRoleValues;
 import org.apache.myfaces.tobago.renderkit.html.TobagoClass;
 import org.apache.myfaces.tobago.renderkit.html.util.HtmlRendererUtils;
 import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
@@ -51,8 +53,12 @@ public class PopupRenderer extends Layou
     writer.startElement(HtmlElements.DIV, null);
     writer.writeClassAttribute(TobagoClass.POPUP, BootstrapClass.MODAL, BootstrapClass.FADE);
     writer.writeIdAttribute(popup.getClientId(facesContext));
+    writer.writeAttribute(HtmlAttributes.TABINDEX, -1);
+    writer.writeAttribute(HtmlAttributes.ROLE, HtmlRoleValues.DIALOG.toString(), false);
+    // todo: aria-labelledby
     writer.startElement(HtmlElements.DIV, null);
     writer.writeClassAttribute(BootstrapClass.MODAL_DIALOG);
+    writer.writeAttribute(HtmlAttributes.ROLE, HtmlRoleValues.DOCUMENT.toString(), false);
     final Style style = new Style();
     style.setWidth(popup.getWidth());
     style.setHeight(popup.getHeight());

Modified: myfaces/tobago/branches/tobago-3.0.x/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/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-popup.js?rev=1698099&r1=1698098&r2=1698099&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-popup.js
(original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-popup.js
Thu Aug 27 09:13:21 2015
@@ -18,325 +18,20 @@
 Tobago.Popup = {};
 
 /**
- * Init popup size
- */
-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"));
-
-  // TODO: remove later (after change AJAX, that they replace tags instead of fill them...)
-  jQuery('.tobago-popup-parent > .tobago-popup').unwrap();
-
-  // The shield is a protection against clicking controls, which are not allowed to click
in the modal case.
-  // The shield also makes an optical effect (alpha blending).
-
-  // hide all old shields
-  jQuery('.tobago-popup-shield').css({visibility:"hidden"});
-
-  // find highest modal popup
-  var maxZIndex = -Infinity;
-  var maxModalPopup = null;
-  jQuery('.tobago-popup-markup-modal').each(function () {
-    var zIndexString = jQuery(this).css('z-index');
-    var zIndex;
-    if (zIndexString == "auto") {
-      zIndex = -Infinity;
-    } else {
-      zIndex = parseInt(zIndexString);
-    }
-    if (zIndex >= maxZIndex) {
-      maxZIndex = zIndex;
-      maxModalPopup = jQuery(this);
-    }
-  });
-
-  // add the new shield to the highest modal popup
-  if (maxModalPopup != null && maxModalPopup.size() > 0) { // same as == 1
-
-    maxModalPopup.prepend("<div class='tobago-popup-shield' onclick='Tobago.Popup.blink(this)'/>");
-    var shield = maxModalPopup.children('.tobago-popup-shield');
-    shield.attr('id', maxModalPopup.attr('id') + '::shield');
-
-    // IE6 doesn't support position:fixed
-    if (Tobago.browser.isMsie6) {
-      var image = jQuery(".tobago-page-overlayBackgroundImage").attr("src");
-      shield.css({
-        position:'absolute',
-        left:-maxModalPopup.offset().left,
-        top:-maxModalPopup.offset().top,
-        width:jQuery(window).width(),
-        height:jQuery(window).height(),
-        background:'none',
-        filter:"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"
-            + image + "', sizingMethod='scale');"
-      });
-
-      // IE6 needs an iframe to protect the other controls and protect against select-tag
shining through.
-      maxModalPopup.prepend("<iframe class='tobago-popup-ie6bugfix' src='" + Tobago.blankPage
+ "' />");
-      var iframe = maxModalPopup.children('.tobago-popup-ie6bugfix');
-      iframe.css({
-        position:'absolute',
-        left:-maxModalPopup.offset().left,
-        top:-maxModalPopup.offset().top,
-        width:jQuery(window).width(),
-        height:jQuery(window).height()
-      });
-    }
-
-    // disable the page and all popups behind the highest modal popup
-    Tobago.Popup.lockBehind(maxModalPopup.get(0));
-  }
-
-  if (Tobago.browser.isMsie67) {
-    // not activated for IE 6 and 7, because the handling isn't smooth.
-  } else {
-    // enable drag-and-drop for popups
-    var popups = Tobago.Utils.selectWithJQuery(elements, ".tobago-popup");
-    // The box header is the drag handle (may change)
-    popups.find(".tobago-box-header")
-        .mousedown(function (event) {
-          var popup = jQuery(event.currentTarget).parents(".tobago-popup");
-          popup.css({cursor: "move"});
-          var page = jQuery(".tobago-page");
-          page.data("tobago-draganddrop", {
-            leftOffset:popup.position().left - event.pageX,
-            topOffset:popup.position().top - event.pageY,
-            popup:popup
-          });
-          page.css({
-            '-moz-user-select':'none',
-            '-webkit-user-select':'none',
-            'user-select':'none',
-            '-ms-user-select':'none'});
-
-          var doc = jQuery(document);
-          doc.bind("mousemove", Tobago.Popup.mousemove);
-          doc.bind("mouseup", Tobago.Popup.mouseup);
-        });
-  }
-
-  // Fix for TOBAGO-1401 popup is overlayed by PDF in IE
-  jQuery('.tobago-popup').each(function () {
-    if (Tobago.browser.isMsie) {
-      // IE needs an iframe to protect embedded PDF against shining through.
-      var popup = jQuery(this);
-      popup.prepend("<iframe/>");
-      var iframe = popup.children().eq(0);
-      iframe.addClass("tobago-popup-iebugfix");
-      iframe.attr("src", Tobago.blankPage);
-//      iframe.width(popup.outerWidth(true));
-//      iframe.height(popup.outerHeight(true));
-    }
-  });
-
-};
-
-Tobago.Popup.getDisabledElements = function(popupId) {
-  var data = jQuery("body").data("tobago-popups-disabled-elements");
-  if (data) {
-    // data is Array of {id: popupId, elements: jQueryObject}
-    for (var i = 0; i < data.length; i++) {
-      if (data[i].id == popupId) {
-        return data[i].elements;
-      }
-    }
-  }
-  return undefined;
-};
-
-Tobago.Popup.storeDisabledElements = function(popupId, elements) {
-  var jBody = jQuery("body");
-  var data = jBody.data("tobago-popups-disabled-elements");
-  if (!data) {
-    data = new Array();
-    jBody.data("tobago-popups-disabled-elements", data);
-  }
-  // data is Array of {id: popupId, elements: jQueryObject}
-  for (var i = 0; i < data.length; i++) {
-    if (data[i].id == popupId) {
-      data[i].elements = elements;
-      return;
-    }
-  }
-  data.push({id: popupId, elements: elements});
-};
-
-/**
- * Locks the parent page of a popup when it is opened
- */
-Tobago.Popup.lockBehind = function (popup) {
-  // disable all elements and anchors on page not initially disabled and
-  // store their ids in a data attribute of the popup
-  var id = popup.id;
-  // The attribute might be set by the last call, this may happen, when opening a non-modal
popup on a modal popup.
-  if (Tobago.Popup.getDisabledElements(popup.id) === undefined) {
-    var disabledElements = jQuery();
-    var firstPopupElement = null;
-//    var pageElements = jQuery(document.forms[0].elements);
-    var pageElements = jQuery("form:first :input");
-
-    // disable all active and visible page elements except the popup elements
-    pageElements.each(function () {
-      var element = jQuery(this);
-      if (element.prop("disabled")) {
-        return;
-      }
-      if (element.attr("type") == "hidden") {
-        return;
-      }
-      if (element[0].tagName.toLowerCase() == "form") {
-        return;
-      }
-      var fieldId = element.attr("id");
-      if (fieldId != null && fieldId.indexOf(id + ':') == 0) { // starts with means,
is in popup
-        if (firstPopupElement == null && jQuery.isFunction(element.focus)) {
-          firstPopupElement = element;
-        }
-      } else {
-        element.prop({disabled:true}); // disable element
-        jQuery.merge(disabledElements, jQuery(element)); // store it for reactivation
-      }
-    });
-    Tobago.Popup.storeDisabledElements(popup.id, disabledElements);
-
-    // find the first element in the popup for the focus
-    if (firstPopupElement != null) {
-      try {
-        if (Tobago.browser.isMsie678) {
-          // call the focus asynchronous, because of a bug in IE 6, 7, 8 (IE 9 works fine)
-          var focusId = firstPopupElement.attr("id");
-          var selector = Tobago.Utils.escapeClientId(focusId).replace(/\\/g, '\\\\');
-          window.setTimeout("jQuery('" + selector + "').focus()", 0);
-        } else {
-          firstPopupElement.focus();
-        }
-      } catch (e) {/* ignore */
-        console.warn("tried to setting the focus on'" + this + "'." + e); // @DEV_ONLY
-      }
-    }
-  }
-};
-
-/**
- * Make popup blink
- */
-Tobago.Popup.blink = function (element) {
-  var id = jQuery(element).attr('id');
-  console.debug("Blink: Popup id is '" + id + "'"); // @DEV_ONLY
-  Tobago.addCssClass(id, 'tobago-popup-blink');
-  setTimeout("Tobago.removeCssClass('" + id + "', 'tobago-popup-blink')", 20);
-};
-
-/**
- * remove a popup without request
- */
-Tobago.Popup.close = function (closeButton) {
-  var popup = jQuery(closeButton).parents('div.tobago-popup:first');
-  if (popup.hasClass("tobago-popup-markup-modal")) {
-    Tobago.Popup.unlockBehind(popup);
-    popup.remove();
-    var maxModalPopup = jQuery('.tobago-popup-shield').filter(":last");
-    maxModalPopup.css({visibility:"visible"});
-  } else {
-    popup.remove();
-  }
-};
-
-/**
- * Unlock the parent page of a popup when it is closed
- * @param popups The popups as jQuery object.
- */
-Tobago.Popup.unlockBehind = function (popups) {
-  if (popups == null) {
-    console.warn("Since Tobago 1.5.5 Tobago.Popup.unlockBehind() has the popup as parameter");
// @DEV_ONLY
-    popups = jQuery('.tobago-popup-shield').filter(":last").parent();
-  }
-  popups.each(function() {
-    // re-enable all elements and anchors on page stored in the attribute
-    var disabledElements = Tobago.Popup.getDisabledElements(this.id);
-    if (disabledElements != null) {
-      disabledElements.each(function() {
-        jQuery(this).prop({disabled: false});
-      });
-      Tobago.Popup.storeDisabledElements(this.id, undefined);
-    }
-  });
-};
-
-Tobago.Popup.openWithAction = function (source, popupId, actionId, options) {
-  // div creation moved to onComplete
-  Tobago.reloadComponent(source, popupId, actionId, options);
-};
-
-Tobago.Popup.mousemove = function (event) {
-  var page = jQuery(".tobago-page");
-  var dnd = page.data("tobago-draganddrop");
-  if (dnd) {
-    var popup = dnd.popup;
-    Tobago.Popup.move(event, page, popup, dnd);
-  } else {
-    console.warn("Should not happen!"); // @DEV_ONLY
-  }
-  return false;
-};
-
-Tobago.Popup.mouseup = function (event) {
-  var page = jQuery(".tobago-page");
-  var dnd = page.data("tobago-draganddrop");
-  var doc = jQuery(document);
-  if (dnd) {
-    var popup = dnd.popup;
-    Tobago.Popup.move(event, page, popup, dnd);
-    doc.unbind("mousemove", Tobago.Popup.mousemove);
-    doc.unbind("mouseup", Tobago.Popup.mouseup);
-    page.removeData("tobago-draganddrop");
-    popup.css({cursor: ''});
-    page.css({
-      '-moz-user-select':'',
-      '-webkit-user-select':'',
-      'user-select':'',
-      '-ms-user-select':''});
-  }
-};
-
-Tobago.Popup.move = function (event, page, popup, dnd) {
-  var left = event.pageX + dnd.leftOffset;
-  left = Math.max(0, left);
-  left = Math.min(page.width() - popup.width(), left);
-  popup.css("left", left);
-  var top = event.pageY + dnd.topOffset;
-  top = Math.max(0, top);
-  top = Math.min(page.height() - popup.height(), top);
-  popup.css("top", top);
-};
-
-Tobago.registerListener(Tobago.Popup.init, Tobago.Phase.DOCUMENT_READY);
-Tobago.registerListener(Tobago.Popup.init, Tobago.Phase.AFTER_UPDATE);
-
-
-/**
  * Init popup for bootstrap
  */
-Tobago.Popup.initBootstrap = function (elements) {
+Tobago.Popup.init = function(elements) {
 
   var popups = Tobago.Utils.selectWithJQuery(elements, ".modal");
   popups.each(function() {
     jQuery(this).modal(); // opens the popup
   });
-
 };
 
-Tobago.registerListener(Tobago.Popup.initBootstrap, Tobago.Phase.DOCUMENT_READY);
-Tobago.registerListener(Tobago.Popup.initBootstrap, Tobago.Phase.AFTER_UPDATE);
-
-// XXX rename me + namespace
-bs_info = function(message) {
-  console.info("info: " + message);
-  var menuStore = jQuery(".tobago-page-menuStore");
-  var confirmation = menuStore.find(".tobago-page-confirmation");
+Tobago.Popup.close = function(button) {
+  jQuery(button).parents('.modal:first').modal("hide");
 
-  return false;
 };
+
+Tobago.registerListener(Tobago.Popup.init, Tobago.Phase.DOCUMENT_READY);
+Tobago.registerListener(Tobago.Popup.init, Tobago.Phase.AFTER_UPDATE);

Modified: myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
URL: http://svn.apache.org/viewvc/myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js?rev=1698099&r1=1698098&r2=1698099&view=diff
==============================================================================
--- myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
(original)
+++ myfaces/tobago/branches/tobago-3.0.x/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
Thu Aug 27 09:13:21 2015
@@ -279,8 +279,6 @@ var Tobago = {
 
     Tobago.storeClientDimension();
 
-    Tobago.Popup.unlockBehind(jQuery(".tobago-popup-markup-modal"));
-
     Tobago.onBeforeUnload();
 
     return true;
@@ -801,16 +799,9 @@ var Tobago = {
             if (popup && popup.command == "close" && popup.immediate) {
               Tobago.Popup.close(this);
             } else {
-              if (popup && popup.command == "close") {
-                Tobago.Popup.unlockBehind();
-              }
               var action = commands.click.action ? commands.click.action : jQuery(this).attr("id");
               if (commands.click.partially) {
-                if (popup && popup.command == "open") {
-                  Tobago.Popup.openWithAction(this, commands.click.partially, action);
-                } else {
-                  Tobago.reloadComponent(this, commands.click.partially, action, commands.click);
-                }
+                Tobago.reloadComponent(this, commands.click.partially, action, commands.click);
                 event.preventDefault();
                 event.stopPropagation();
               } else if (commands.click.url) {



Mime
View raw message