Open a dialog from a specific view class with some configuration

@param {DialogView} cls dialog view class
@param {options} options dialog view constructor options
@return {promise}
422342
function(cls, options) {
            var d = Q.defer();

            cls = cls || DialogView;
            var diag = new cls(options);

            diag.once("close", function(result, e) {
                if (result != null) {
                    d.resolve(result);
                } else {
                    d.reject(result);
                }
            });
            setTimeout(function() {
                d.notify(diag);
            }, 1);
            diag.update();

            return d.promise;
        }
55283
function View (name) {
  if (!(this instanceof View)) {
    return new View(name);
  }
  this.name = name;
  this.config = utils.clone(config);
  this.config.pathname += '/_view/' + this.name;
}
406838
function QuickNavigateDialog() {
        this.$searchField = undefined; // defined when showDialog() is called

        // ModalBar event handlers & callbacks
        this._handleCloseBar           = this._handleCloseBar.bind(this);

        // QuickSearchField callbacks
        this._handleItemSelect         = this._handleItemSelect.bind(this);
        this._handleItemHighlight      = this._handleItemHighlight.bind(this);
        this._filterCallback           = this._filterCallback.bind(this);
        this._resultsFormatterCallback = this._resultsFormatterCallback.bind(this);

        // StringMatchers that cache in-progress query data.
        this._filenameMatcher           = new StringMatch.StringMatcher({
            segmentedSearch: true
        });
        this._matchers                  = {};
    }
326912
function ViewportItem(options, parent) {
      classCallCheck(this, ViewportItem);

      this.parent = parent;
      this.id = Math.random().toString(36).substring(7);
      this.triggered = false;
      this.threshold = 200;
      this.isThresholdPercentage = false;

      // Override defaults with options.
      Object.assign(this, options);

      // The whole point is to have a callback function. Don't do anything if it's not given.
      if (typeof this.enter !== 'function') {
        throw new TypeError('Viewport.add :: No `enter` function provided in Viewport options.');
      }

      this.parseThreshold();

      this.hasExitCallback = typeof this.exit === 'function';

      // Cache element's offsets and dimensions.
      this.update();
    }
885108
protected void openDialog(DialogOptions dlgOptions) {

        m_dialog = new CmsPopup(
            Messages.get().key(Messages.GUI_DIALOG_CONTENTEDITOR_TITLE_0)
                + " - "
                + (m_isNew ? m_editableData.getNewTitle() : m_editableData.getSitePath()));
        m_dialog.addStyleName(I_CmsLayoutBundle.INSTANCE.contentEditorCss().contentEditor());

        // calculate width
        int width = Window.getClientWidth();
        width = (width < 1350) ? width - 50 : 1300;
        if (dlgOptions.getSuggestedWidth() != null) {
            width = dlgOptions.getSuggestedWidth().intValue();
        }

        m_dialog.setWidth(width);

        // calculate height
        int height = Window.getClientHeight() - 50;
        height = (height < 645) ? 645 : height;
        if (dlgOptions.getSuggestedHeight() != null) {
            height = dlgOptions.getSuggestedHeight().intValue();
        }
        m_dialog.setHeight(height);

        m_dialog.setGlassEnabled(true);
        m_dialog.setUseAnimation(false);
        final CmsIFrame editorFrame = new CmsIFrame(EDITOR_IFRAME_NAME, "");
        m_dialog.addDialogClose(new Command() {

            /**
             * @see com.google.gwt.user.client.Command#execute()
             */
            public void execute() {

                CmsConfirmDialog confirmDlg = new CmsConfirmDialog(
                    Messages.get().key(Messages.GUI_EDITOR_CLOSE_CAPTION_0),
                    Messages.get().key(Messages.GUI_EDITOR_CLOSE_TEXT_0));
                confirmDlg.setHandler(new I_CmsConfirmDialogHandler() {

                    public void onClose() {

                        // do nothing
                    }

                    public void onOk() {

                        // make sure the onunload event is triggered within the editor frames for ALL browsers
                        editorFrame.setUrl("about:blank");
                        Scheduler.get().scheduleDeferred(new ScheduledCommand() {

                            public void execute() {

                                CmsContentEditorDialog.this.close();
                            }
                        });
                    }
                });
                confirmDlg.center();
                // Let the confirm dialog handle the closing
                throw new CmsCancelCloseException();
            }
        });

        m_dialog.add(editorFrame);
        m_dialog.setPositionFixed();
        m_dialog.center();
        m_form = generateForm(m_editableData, m_isNew, EDITOR_IFRAME_NAME, m_mode);
        RootPanel.getBodyElement().appendChild(m_form);
        m_form.submit();

        // adding on close handler
        m_closingHandlerRegistration = Window.addWindowClosingHandler(new ClosingHandler() {

            public void onWindowClosing(ClosingEvent event) {

                onWindowClose();
            }
        });
    }
130956
function() {
        var editor = this;
        $.map(this.toolbar.commandMapping, function(value) {
          return [value];
        }).filter(function(commandObj) {
          return commandObj.dialog;
        }).map(function(commandObj) {
          return commandObj.dialog;
        }).forEach(function(dialog) {
          dialog.on('show', function() {
            $(this.container).modal('show');
          });
          dialog.on('hide', function() {
            $(this.container).modal('hide');
            setTimeout(editor.composer.focus, 0);
          });
          $(dialog.container).on('shown.bs.modal', function () {
            $(this).find('input, select, textarea').first().focus();
          });
        });
        this.on('change_view', function() {
          $(this.toolbar.container.children).find('a.btn').not('[data-wysihtml5-action="change_view"]').toggleClass('disabled');
        });
      }
918260
function Popup (opts) {
	if (!(this instanceof Popup)) return new Popup(opts);

	var typeOpts = this.types[opts.type || this.type] || {};

	//hook up type events and options events
	if (typeOpts.onInit) this.on('init', typeOpts.onInit);
	if (typeOpts.onShow) this.on('show', typeOpts.onShow);
	if (typeOpts.onHide) this.on('hide', typeOpts.onHide);
	if (typeOpts.onAfterShow) this.on('afterShow', typeOpts.onAfterShow);
	if (typeOpts.onAfterHide) this.on('afterHide', typeOpts.onAfterHide);
	if (opts.onInit) this.on('init', opts.onInit);
	if (opts.onShow) this.on('show', opts.onShow);
	if (opts.onHide) this.on('hide', opts.onHide);
	if (opts.onAfterShow) this.on('afterShow', opts.onAfterShow);
	if (opts.onAfterHide) this.on('afterHide', opts.onAfterHide);


	//generate unique id
	this.id = uid();

	//FIXME: :'(
	this.update = this.update.bind(this);

	//ensure element
	if (!this.element) this.element = document.createElement('div');
	this.element.classList.add('popoff');
	this.element.classList.add('popoff-popup');
	this.element.classList.add('popoff-hidden');

	//take over type’s options.
	//should be after element creation to init `content` property
	extend(this, typeOpts, opts);

	this.element.classList.add(`popoff-${this.type}`);

	//take over a target first
	if (!this.container) {
		this.container = document.body || document.documentElement;
	}
	this.container.classList.add('popoff-container');

	//create close element
	this.closeElement = document.createElement('div');
	this.closeElement.classList.add('popoff-close');
	if (this.closable) {
		this.closeElement.addEventListener('click', e => {
			this.hide();
		});
		this.element.appendChild(this.closeElement);
	}

	//create tip
	this.tipElement = document.createElement('div');
	this.tipElement.classList.add('popoff-tip');
	this.tipElement.classList.add('popoff-hidden');
	if (this.tip) {
		this.container.appendChild(this.tipElement);
		this.element.classList.add('popoff-popup-tip');
	}

	//apply custom style
	if (this.style) {
		for (var name in this.style) {
			let value = this.style[name];
			if (typeof value === 'number' && !/z/.test(name)) value += 'px';
			this.element.style[name] = value;
		}
	}

	//create overflow for tall content
	this.overflowElement = document.createElement('div');
	this.overflowElement.classList.add('popoff-overflow');

	this.container.appendChild(this.element);

	if (this.escapable) {
		document.addEventListener('keyup', e => {
			if (!this.isVisible) return;
			if (e.which === 27) {
				this.hide();
			}
		});
	}

	//init proper target
	if (typeof this.target === 'string') {
		this.target = document.querySelector(this.target);
	}

	//update on resize
	window.addEventListener('resize', () => {
		this.update();
	});

	this.emit('init');
}
765661
protected void openDialog(I_CmsGalleryConfiguration configuration) {

        Document.get().getBody().addClassName(I_CmsButton.ButtonData.WAND_BUTTON.getIconClass());
        if (m_dialog == null) {
            SimplePanel tabsContainer = new SimplePanel();
            tabsContainer.addStyleName(I_CmsLayoutBundle.INSTANCE.containerpageCss().menuTabContainer());
            int dialogHeight = CmsToolbarPopup.getAvailableHeight();
            int dialogWidth = CmsToolbarPopup.getAvailableWidth();
            m_dialog = createDialog(configuration, new I_CmsGalleryHandler() {

                public boolean filterDnd(CmsResultItemBean resultBean) {

                    return CmsGwtConstants.TYPE_IMAGE.equals(resultBean.getType());
                }

                public Widget getAdditionalTypeTabControl() {

                    return null;
                }

                public I_CmsAutoHider getAutoHideParent() {

                    return getPopup();
                }

                public CmsDNDHandler getDndHandler() {

                    return CmsContainerpageController.get().getDndHandler();
                }

                public void processResultItem(CmsResultListItem item) {

                    item.setData(DND_MARKER);
                    item.setDndHelperClass("imagedrag");
                    item.setDndParentClass(
                        "imageparent "
                            + org.opencms.ade.galleries.client.ui.css.I_CmsLayoutBundle.INSTANCE.galleryResultItemCss().tilingList());
                    //item.setDragHelperTransformer(DRAG_HELPER_TRANSFORMER);
                }

            });
            m_dialog.setDialogSize(dialogWidth, dialogHeight);
            getPopup().setWidth(dialogWidth);
            tabsContainer.add(m_dialog);
            m_contentPanel.add(tabsContainer);
        } else {
            int dialogWidth = CmsToolbarPopup.getAvailableWidth();
            getPopup().setWidth(dialogWidth);
            m_dialog.truncate("GALLERY_DIALOG_TM", dialogWidth);
            m_dialog.updateSizes();
        }
    }
771931
function dialogPopOut(container, options) {
      return options.reverseAnimate().then(function() {
        if (options.contentElement) {
          // When we use a contentElement, we want the element to be the same as before.
          // That means, that we have to clear all the animation properties, like transform.
          options.clearAnimate();
        }
      });
    }
1364132
function(options, parent) {
            View.__super__.initialize.call(this, options);
            this._ensureElement();
            this.delegateEvents();

            // Rendering queue
            this.renderQueue = new Queue();

            // Components map
            this.components = {};

            // parent view
            this.parent = parent || this;

            // Model
            this.model = this.options.model || null;

            // View state
            this.is_ready = false;

            // Counter for number of active components
            this.countComponents = 0;
            return this;
        }
585336
function(title, message) {
            if (!message) {
                message = title;
                title = null;
            }

            return Dialogs.open(null, {
                "title": title,
                "message": message,
                "dialog": "confirm"
            });
        }
890089
function(params, callback) {
        /**
         * Callback for QB.chat.dialog.create().
         * @param {Object} error - The error object
         * @param {Object} createdDialog - the dialog object
         * @callback createDialogCallback
         * */

        if (params && params.occupants_ids && Utils.isArray(params.occupants_ids)) {
            params.occupants_ids = params.occupants_ids.join(', ');
        }

        this.service.ajax({
            url: Utils.getUrl(DIALOGS_API_URL),
            type: 'POST',
            data: params
        }, callback);
    }
469412
function(url, options, replaceWindow) {

            if (!this.runsInBrowser()) {
                throw new Error("Cannot open popups.");
            }

            options = options || {};

            var window = this.$stage.$window,
                features = [];

            options = _.defaults(options, {
                name: null,
                menubar: false,
                toolbar: false,
                location: false,
                personalbar: false,
                status: false,
                resizeable: true,
                scrollbars: true,
                dependend: false,
                dialog: false,
                minimizable: true,

                top: null,
                left: null,
                height: null,
                width: null
            });

            for (var key in options) {
                if (options.hasOwnProperty(key) && key !== "name") {
                    if (options[key] === true) {
                        features.push(key + "=yes")
                    } else if (options[key]) {
                        features.push(key + "=" + options[key]);
                    }
                }
            }

            return window.open(url, options.name, features.join(","), replaceWindow);

        }
929712
function open(bool) {
    // Open
    if (bool || typeof bool === 'undefined') {
      // If present closes an opened instance of the plugin
      // Only one at time can be open
      const openedCustomSelect =
        document.querySelector(`.${containerClass}.${builderParams.isOpenClass}`);
      if (openedCustomSelect) {
        openedCustomSelect.customSelect.open = false;
      }

      // Opens only the clicked one
      container.classList.add(builderParams.isOpenClass);

      // aria-expanded update
      container.classList.add(builderParams.isOpenClass);
      opener.setAttribute('aria-expanded', 'true');

      // Updates the scrollTop position of the panel in relation with the focused option
      if (selectedElement) {
        panel.scrollTop = selectedElement.offsetTop;
      }

      // Dispatches the custom event open
      container.dispatchEvent(new CustomEvent('custom-select:open'));

      // Sets the global state
      isOpen = true;

    // Close
    } else {
      // Removes the css classes
      container.classList.remove(builderParams.isOpenClass);

      // aria-expanded update
      opener.setAttribute('aria-expanded', 'false');

      // Sets the global state
      isOpen = false;

      // When closing the panel the focused custom option must be the selected one
      setFocusedElement(selectedElement);

      // Dispatches the custom event close
      container.dispatchEvent(new CustomEvent('custom-select:close'));
    }
    return isOpen;
  }
1309079
function open(method, url, async, username, password) {
    this.method = method;
    this.url = url;
    this.async = typeof async == "boolean" ? async : true;
    this.username = username;
    this.password = password;
    this.responseText = null;
    this.responseXML = null;
    this.responseURL = url;
    this.requestHeaders = {};
    this.sendFlag = false;
    this._readyStateChange(FakeXMLHttpRequest.OPENED);
  }
415030
function(title, message, defaultmsg) {
            return Dialogs.open(null, {
                "title": title,
                "message": message,
                "dialog": "prompt",
                "default": defaultmsg,
                "autoFocus": true,
                "valueSelector": "selectorPrompt"
            });
        }
546473
function (elm, cls, state) {
        this.$$(elm).toggleClass(cls, state).each(function () {
          if (this.className === '') {
            DomQuery(this).attr('class', null);
          }
        });
      }