show modal window with video chat
166543
function clickJoinOrLeaveVideoChat(isStopByInitiator, isStopByBadNetwork) {
    if(!client){
      initialise();
    }

    var messageText,
        btnState;

    $('#videos div.row').empty();

    // Stop
    if (callIsInProgress) {
        $('#call_btn').prop('disabled', "disabled");

        stopAllICEFailedTimers();

        client.leave({
            success: function() {

                var next = function(){
                  client.destroySession({
                      success: function() {
                          clearEventsListeners();

                          $('.videoconf_ids').text(null);

                          if (isInitiator) {
                              if(isStopByBadNetwork){
                                notifyAboutCallState('dropCall');
                              }else{
                                notifyAboutCallState('stopCall');
                              }
                              messageText = 'Has finished video chat';
                              btnState = 'start';
                              isInitiator = false;

                              changeVideoChatStatus(currentDialog._id, false);
                          } else {
                              messageText = 'Has left video chat';
                              btnState = isStopByInitiator ? 'start' : 'join';
                          }

                          sendCallPresence(messageText);
                          updateVideoAndAudioChatButton(btnState);

                          // update UI
                          $("#video_chat_col").hide("slow", function() {
                              $("#chat_history_col").show("fast", function() {
                                  setTimeout(function() {
                                      $('#call_btn').prop('disabled', null);
                                  }, 1000);

                                  callIsInProgress = false;
                              });
                          });
                      },
                      error: function(error) {
                          console.warn("Error in 'destroySession': ", error);
                      }
                  });
                };

                client.detachVideoConferencingPlugin({
                    success: function() {
                        console.warn("Success detachVideoConferencingPlugin");
                        next();
                    },
                    error: function(error) {
                        console.warn("Error in 'detachVideoConferencingPlugin': ", error);
                        next();
                    }
                });

            }
        });


    // Start
    } else {
        if(!currentDialog){
          bootbox.alert("Please create a chat dialog first");
          return;
        }

        $('#call_btn').prop('disabled', "disabled");

        // Init Video engine
        //
        client.createSession({
            success: function() {

                initEventsListeners();

                // If this is Safari, let's avoid video
                if(adapter.browserDetails.browser === "safari") {
                    toastr.warning("Our video stream has been rejected because Safari does not support VP8 code. Viewers won't see us, only listen.");
                }

                client.attachVideoConferencingPlugin(false, null, {
                    success: function() {

                        actionsForTheInitiator();

                        $('.videoconf_ids').text("SID: " + client.getSessionId() + ". PID: " + client.getPluginId());

                        $("#chat_history_col").hide("slow", function() {
                            $("#video_chat_col").show("fast", function() {

                                // show local video feed
                                addFeedView(currentUser.id, true);

                                // join video chat
                                var roomIdToJoin = currentDialog._id;

                                client.join(roomIdToJoin, currentUser.id, isAudioCallOnly, {
                                    success: function() {
                                        console.log("JOINED " + client.currentDialogId + " dialog");

                                        if (isInitiator) {
                                            messageText = 'Started call';
                                            btnState = 'end';

                                            changeVideoChatStatus(currentDialog._id, true);
                                        } else {
                                            messageText = 'Joined call';
                                            btnState = 'leave';
                                        }

                                        sendCallPresence(messageText);
                                        updateVideoAndAudioChatButton(btnState);

                                        setTimeout(function() {
                                            $('#call_btn').prop('disabled', null);
                                        }, 1000);

                                        callIsInProgress = true;

                                        //
                                        // // TEMP
                                        // setTimeout(function() {
                                        //   clickJoinOrLeaveVideoChat(false, true);
                                        //
                                        //   bootbox.alert("TEST: The connectivity is gone because of heavy data loss. Please rejoin the call.");
                                        // }, 15000);
                                    },
                                    error: function(error) {
                                        bootbox.alert("Can't join video chat. Please check your Internet connection");
                                    }
                                });

                            });
                        });

                    },
                    error: function(error) {
                        console.error("Error in 'attachVideoConferencingPlugin': ", error);

                        // #define VIDEOROOM_ERROR_ID_EXISTS			436
                        // #define VIDEOROOM_ERROR_UNAUTHORIZED		433
                        // #define 'User ID xxx already exists'		400
                        //
                        if (error["error_code"] == 433 || error["error_code"] == 436 || error["error_code"] == 400) {
                            clickJoinOrLeaveVideoChat();
                        }

                        bootbox.alert("Error attaching plugin... " + (error["error"] || error));
                    },
                    webrtcState: function(on) {
                        console.info("LOCAL WebRTC PeerConnection is " + (on ? "up" : "down") + " now");

                        if(on){
                          QBVideoConferencingClient.listVideoinputDevices(function(videoinputDevices){
                            userVideoinputDevices = videoinputDevices;
                            readyLocalVideoUI(videoinputDevices);
                          });
                        }
                    },
                    consentDialog: function(on) {
                        console.info("Consent dialog should be " + (on ? "on" : "off") + " now");
                    },
                    mediaState: function(medium, on) {
                        console.info("LOCAL MediaState (own):  " + (on ? "started" : "stopped") + " receiving our " + medium);

                        // Trying to fix 'ICE failed' error.
                        // If it's happened - then close current session.
                        if(!on){
                          if(medium == "audio"){
                            runICEFailedTimer(medium);
                          }
                        }else{
                          if(medium == "audio"){
                            stopICEFailedTimer(medium);
                          }
                        }
                    },
                    slowLink: function(uplink, nacks) {
                      console.warn("LOCAL slowLink detected. uplink: " + uplink + ". nacks: " + nacks);
                      toastr.warning("slow link detected");
                    },
                    iceState: function(iceConnectionState){
                      console.warn("LOCAL iceState: " + iceConnectionState);

                      if(iceConnectionState == "disconnected" || iceConnectionState == "checking"){
                        playSoundOnNewMessage()

                        startSpiner("local");
                        hideLocalVideo();
                      }else if (iceConnectionState == "connected"){
                        playSoundOnNewMessage()

                        stopSpiner("local");
                        showLocalVideo();
                      }else if (iceConnectionState == "failed"){
                        playSoundOnNewMessage()

                        console.error("Local peer connection has failed because of ICE failed.");
                        console.info("Trying Local ICE restart...");

                        // perform ICE restart
                        //
                        client.iceRestart({
                          success: function() {
                            // console.info("iceRestart success");
                          },
                          error: function(error) {
                            console.warn("iceRestart error: " + JSON.stringify(error));
                          }
                        });
                      }
                    },
                    oncleanup: function() {

                    }
                });

            },

            error: function(error) {
                console.error("Error in 'createSession': ", error);

                $('#call_btn').prop('disabled', null);

                if(error == "Lost connection to the gateway (is it down?)"){

                }else if(error == "Error connecting to the Janus WebSockets server: Is the gateway down?"){
                  if (callIsInProgress) {
                      clickJoinOrLeaveVideoChat();
                  }
                  bootbox.alert("Lost connection to the server. Please check your Internet connection and restart the app.");
                }
            },

            destroyed: function() {
                console.info("Session is destroyed");
            },

            timeoutSessionCallback: function() {
                console.warn("timeoutSessionCallback CALL!!!!");
                bootbox.alert("Server session timeout (because of bad Internet connection). Please check your Internet connection and restart the app");
                clickJoinOrLeaveVideoChat(false, true);
            }
        });

    }
}
954074
public function showJS($options = null, $options_compat = array())
    {
        if (!empty($options_compat)) {
            $options = $options_compat;
        }

        $loader_js = $this->url ?
            $this->js()->atk4_load(array($this->url)) : $options['open_js'] ?: null;

        $this->js(true)->dialog(array_extend(array(
            'modal' => true,
            'dialogClass' => ($options['class'] ?: 'atk-popover').$this->pop_class.
                            ' atk-popover-'.($options['tip'] ?: 'top-center'),
            'dragable' => false,
            'resizable' => false,
            'minHeight' => 'auto',
            'autoOpen' => false,
            'width' => 250,
            'open' => $this->js(null, array(
                $this->js()->_selector('.ui-dialog-titlebar:last')->hide(),
                $loader_js,
            ))->click(
                $this->js()->dialog('close')->_enclose()
            )->_selector('.ui-widget-overlay:last')->_enclose()->css('opacity', '0'),

        ), $options))->parent()->append('<div class="atk-popover-arrow"></div>')
        ;

        return $this->js()->dialog('open')->dialog('option', array(
            'position' => $p = array(
                'my' => $options['my'] ?: 'center top',
                'at' => $options['at'] ?: 'center bottom+8',
                'of' => $this->js()->_selectorThis(),
                //'using'=>$this->js(
                //    null,
                //    'function(position,data){ $( this ).css( position ); console.log("Position: ",data); '.
                //    'var rev={vertical:"horizontal",horizontal:"vertical"}; '.
                //    '$(this).find(".arrow").addClass(rev[data.important]+" "+data.vertical+" "+data.horizontal);}'
                //)
            ),
        ));
    }
297585
def chat(room=None, stream=None, **kwargs):
    
    if room is None:
        room = _random_room()
        print("room =", room)
    if stream is None:
        stream = CameraStream()
    room = WebRTCRoomMqtt(stream=stream, room=room)
    box = widgets.HBox(children=[])
    widgets.jslink((room, 'streams'), (box, 'children'))
    display(box)
    return room
178772
private void pauseAndTrainModal(List<FormInput> formInputs) {

		/* If we are doing a training crawl, allow the user to edit remaining forms. */
		WebDriver driver = browser.getWebDriver();
		driver.manage().timeouts().setScriptTimeout(180, TimeUnit.SECONDS);

		String js = "";

		/* Inject the modal notification. */
		js += "function addStyleString(str) {";
		js += "	var node = document.createElement('style');";
		js += "	node.innerHTML = str;";
		js += "	document.body.appendChild(node);";
		js += "}";

		js += "function addHTMLString(str) {";
		js += "	var modal = document.createElement('div');";
		js += "	modal.setAttribute('id', 'myModal');";
		js += "	modal.setAttribute('class', 'modal');";
		js +=
				" modal.setAttribute('style', 'display:none;position:fixed;z-index:1;left:0;top:0;width:100%;height:100%;overflow:auto;background-color:rgb(0,0,0);background-color:rgba(0,0,0,0.4)');";
		js += "	modal.innerHTML = str;";
		js += "	document.body.appendChild(modal);";
		js += "}";

		js += "addHTMLString(\"" + MODAL_HTML + "\");";

		js += "var modal = document.getElementById('myModal');";
		js += "var span = document.getElementsByClassName('close')[0];";

		js += "span.onclick = function() {";
		js += "	modal.style.display = 'none';";
		js += "};";

		js += "window.onclick = function(event) {";
		js += "	if (event.target == modal) {";
		js += "		modal.style.display = 'none';";
		js += "	}";
		js += "};";

		js += "modal.style.display = 'block';";

		/* Inject the callback and continuation keys. */
		js += "var callback = arguments[arguments.length - 1];";
		js += "var title = document.title;";
		js += "document.onkeydown = function(e) {";
		js += "if(e.keyCode === 112) {";
		js += "document.title = title;";
		js += "setTimeout(callback, 1);";
		js += "}";
		js += "}";

		JavascriptExecutor executor = (JavascriptExecutor) driver;
		executor.executeAsyncScript(js);

		/*
		 * Save each FormInput element so the user does not have to enter them again.
		 */
		for (FormInput input : formInputs) {

			/* Create the InputValue for this element. */
			InputValue inputValue = getInputValue(input);

			/* Read the value from the DOM. */
			Set<InputValue> inputValues = new HashSet<>();
			inputValues.add(inputValue);

			/* The DOM value is the new input value. */
			input.inputValues(inputValues);

			/* Label the element as visited. */
			visited.add(input.getIdentification());

			/* Add this input value to the set. */
			formInputValueHelper.addTrainingInput(input.getIdentification(), input);

		}

	}
614984
function() {
            Ui.setupHtml();
            Ui.smoothScrollLink();
            Ui.openNewWindow();
            Ui.navigationHighlight();
            Ui.setupPalettes();
            Ui.listenForPaletteClick();
        }
726199
function openChat() {
        var num = validateNum();

        if(num) {
            socket.emit('setup', num, function() {
                number = num;
                $('#num').hide();
                $('#chat').show();
            });
        }
    }
819764
function(keepCurrentModal) {
			lib.returnFocus(this.$frameParent, this.$originalFocus, function() {
				if(!keepCurrentModal && modalDialogManager.dialog === this) {
					modalDialogManager.dialog = null;
				}
				if (typeof this._beforeHiding === "function") { //$NON-NLS-0$
					this._beforeHiding();
				}
				if (this._modalListener) {
					this.$frameParent.removeEventListener("focus", this._modalListener, true);  //$NON-NLS-0$
					this.$frameParent.removeEventListener("click", this._modalListener, true);  //$NON-NLS-0$
				}
	
				this.$frame.classList.remove("dialogShowing"); //$NON-NLS-0$
				lib.setFramesEnabled(true);
				if (typeof this._afterHiding === "function") { //$NON-NLS-0$
					this._afterHiding();
				}
			}.bind(this));
			var self = this;
			if (!this.keepAlive) {
				window.setTimeout(function() { self.destroy(); }, 0);
			}
		}
237480
function showUserIsTypingView(isTyping, userId, dialogId) {
    if (isMessageForCurrentDialog(userId, dialogId)) {

        if (!isTyping) {
            $('#' + userId + '_typing').remove();
        } else if (userId != currentUser.id) {
            var userLogin = getUserLoginById(userId);
            var typingUserHtml = buildTypingUserHtml(userId, userLogin);
            $('#messages-list').append(typingUserHtml);
        }

        // scroll to bottom
        var mydiv = $('#messages-list');
        mydiv.scrollTop(mydiv.prop('scrollHeight'));
    }
}
419462
function renderRevertModal() {
    var modal = null;
    if (this.state.revertModalIsOpen) {
      modal = React.createElement(_RevertModal2.default, {
        tabWindow: this.state.revertTabWindow,
        onClose: this.closeRevertModal,
        onSubmit: this.doRevert,
        appComponent: this
      });
    }

    return modal;
  }
132331
def showMessageDialog(title, text):
    '''
    
    '''
    dlg = QgsMessageOutput.createMessageOutput()
    dlg.setTitle(title)
    dlg.setMessage(text, QgsMessageOutput.MessageHtml)
    dlg.showMessage()
621060
def Show(self, value = True):
  """"""
  self.Bind(wx.EVT_BUTTON, lambda event: self.Close(True), wx.Button(self.pane, label = '&Cancel')) # Add a cancel button
  ok = wx.Button(self.pane, label = '&OK') # Add the ok button
  ok.SetDefault() # When the user presses enter, this is the button which gets activated
  self.Bind(wx.EVT_BUTTON, self.onOk, ok) # Bind it
  self.Bind(wx.EVT_BUTTON, self.apply, wx.Button(self.pane, label = '&Apply')) # Apply the configuration changes to the ConfigParser object, but don't close the window
  help = wx.Button(self.pane, label = '&Help')
  if not callable(self.config.helpFunc):
   help.Disable()
  help.Bind(wx.EVT_BUTTON, self.config.helpFunc) # Add a help button
  return super(ConfFrame, self).Show(value)
873842
function (id, width)
        {
            ModalDialog.id    = id;
            ModalDialog.width = width;
    
            ModalDialog.ShowBackground();
            ModalDialog.ShowDialog();
    
            // Install the event handlers
            window.onresize = ModalDialog.Resize;
    
            
            // Call them initially
            ModalDialog.Resize();
            
            if (typeof(ModalDialog.onmodaldialog) == 'function') {
                ModalDialog.onmodaldialog();
            }
            ModalDialog.FireCustomEvent('onmodaldialog');
        }
421095
function() {
			var self = this;
			var modal_wrapper = $( '#' + self.scope.id );
			var animation_type = self.options.animation;

			if (animation_type === 'none' ){
				modal_wrapper.removeClass('modaal-start_none');
				self.options.after_open.call(self, modal_wrapper);
			}

			// Open with fade
			if (animation_type === 'fade') {
				modal_wrapper.removeClass('modaal-start_fade');
			}

			// Open with slide down
			if (animation_type === 'slide-down') {
				modal_wrapper.removeClass('modaal-start_slide_down');
			}

			var focusTarget = modal_wrapper;

			// Switch focusTarget tabindex (switch from other modal if exists)
			$('.modaal-wrapper *[tabindex=0]').removeAttr('tabindex');

			if ( self.options.type == 'image' ) {
				focusTarget = $('#' + self.scope.id).find('.modaal-gallery-item.' + self.private_options.active_class);

			} else if ( modal_wrapper.find('.modaal-iframe-elem').length ) {
				focusTarget = modal_wrapper.find('.modaal-iframe-elem');

			} else if ( modal_wrapper.find('.modaal-video-wrap').length ) {
				focusTarget = modal_wrapper.find('.modaal-video-wrap');

			} else {
				focusTarget = modal_wrapper.find('.modaal-focus');

			}

			// now set the focus
			focusTarget.attr('tabindex', '0').focus();

			// Run after_open
			if (animation_type !== 'none') {
				// CB: after_open
				setTimeout(function() {
					self.options.after_open.call(self, modal_wrapper)
				}, self.options.after_callback_delay);
			}
		}
13927
function showMessage(userId, msg, attachmentFileId) {
    var userLogin = getUserLoginById(userId);
    var messageHtml = buildMessageHTML(msg.body, userLogin, new Date(), attachmentFileId, msg.id);

    $('#messages-list').append(messageHtml);

    // scroll to bottom
    var mydiv = $('#messages-list');
    mydiv.scrollTop(mydiv.prop('scrollHeight'));
}
238967
function($modal, callback) {
        var $input = $modal.querySelector('input');
        var $overlay = document.getElementById('overlay-'+$modal.id);

        // hide alerty with animation
        commonUse.removeClass($modal, 'alerty-show');
        commonUse.addClass($modal, 'alerty-hide');

        // remove alerty and other added elements
        setTimeout(function(){
          $overlay && commonUse.removeClass($overlay, 'active'), commonUse.removeClass(document.body, 'no-scrolling');
          
          commonUse.removeElement($modal);
          commonUse.removeElement($overlay);
          if (callback) {
            setTimeout(function(){
              !$input ? callback() : callback($input.value);  // handle prompt type, callback the input value
            }, 100);
          }
        },100);
      }
501543
function createOrientationModal (onClick) {
  var modal = document.createElement('div');
  modal.className = ORIENTATION_MODAL_CLASS;
  modal.classList.add(HIDDEN_CLASS);
  modal.setAttribute(constants.AFRAME_INJECTED, '');

  var exit = document.createElement('button');
  exit.setAttribute(constants.AFRAME_INJECTED, '');
  exit.innerHTML = 'Exit VR';

  // Exit VR on close.
  exit.addEventListener('click', onClick);

  modal.appendChild(exit);

  return modal;
}
1211641
function() {
      var t = this;

      // Show if loaded
      if (aboutTemplate) {
       return t.showDialog('#nm-pv-about');
      }

      UI.loadTemplate('', 'About', function(error, template) {
        if (error) {return;}

        t.$el.append(template.apply(t));
        t.$('.modal a').attr({target: '_blank'});
        t.$('.colorPicker').miniColors({opacity: true});
        t.showDialog('#nm-pv-about');
      });
    }