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

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

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Normal Normal
    • None
    • 8.5.2
    • Components
    • None

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

      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

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

              Created:
              Updated: