Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-4042

Notifications - opts can be undefined when calling setZIndex without them (override ZK)

    Details

    • Type: Bug
    • Status: Open
    • Priority: Normal
    • Resolution: Unresolved
    • Affects Version/s: 8.5.2
    • Fix Version/s: None
    • Component/s: Components
    • Labels:
      None

      Description

      I need to workaround default ZK z-index value (1800) with this override:

      Unable to find source-code formatter for language: js. Available languages are: actionscript, html, java, javascript, none, sql, xhtml, xml
      zk.afterLoad('zul.wgt', function () {
          // zk.wpd:20167 Uncaught TypeError: Cannot read property 'floatZIndex' of undefined
          var _xNotification = {};
          zk.override(zul.wgt.Notification.prototype, _xNotification, {
              reposition: function () {
                  this.$supers('reposition', arguments);
                  if (this._ref) this._fixarrow(this._ref);
              },
              // Zajisteni spravneho z-indexu (ZK dava vzdy 1800+)
              _maxZIndex: function (ref) {
      
                  var parent = ref.parent,
                          refn = ref.$n(),
                          pzi = 1;
                  if (parent) {
                      pzi = this._maxZIndex(parent);
                  }
                  var zi = (refn && refn.style && refn.style.zIndex) ? zk.parseInt(refn.style.zIndex) : 0;
                  return (pzi && pzi > zi) ? pzi : zi;
              },
              _fixarrow: function (ref) {
                  _xNotification._fixarrow.apply(this, arguments); //call the original method
                  //do whatever you want
      
                  var zi = this._maxZIndex(ref);
      
                  this.setZIndex(zi ? zi + 1 : 1, {fire: false, floatZIndex: true});
              }
          });
      });
      
      • first part is related to http://tracker.zkoss.org/browse/ZK-4021
      • second part is my custom function for getting max z-index from component parents
      • third part is override after z-index is set in ZK js

      Explanation:

      • we need to have menu allways above other content
      • our menu is list of anchors with onHover displaying menu invisible content

      I think that solution is quite easy, adding check on opts like when using opts.fire

        Activity

        Hide
        Worsik Worsik added a comment - - edited

        In my code there is this.setZIndex(zi ? zi + 1 : 1, {fire: false, floatZIndex: true}); as workaround, originally i had this.setZIndex(zi ? zi + 1 : 1);

        Show
        Worsik Worsik added a comment - - edited In my code there is this.setZIndex(zi ? zi + 1 : 1, {fire: false, floatZIndex: true}); as workaround, originally i had this.setZIndex(zi ? zi + 1 : 1);

          People

          • Assignee:
            Unassigned
            Reporter:
            Worsik Worsik
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: