Callback for TinyMCE 4 file_picker_callback
@param array|string $url Url to TinyMCEAction
@param array $popupSettings TinyMCE popup settings
@param \yii\web\View|null $view
@return JsExpression
498573
public static function getFilePickerCallback($url, $popupSettings = [], $view = null)
    {
        $default = [
            'title' => 'elFinder',
            'width' => 900,
            'height' => 500,
        ];

        $settings = array_merge($default, $popupSettings);
        $settings['file'] = Url::to($url);

        $encodedSettings = Json::htmlEncode($settings);

        if ($view === null) {
            $view = Yii::$app->view;
        }
        HelperAsset::register($view);

        return new JsExpression("alexantr.elFinder.filePickerCallback($encodedSettings)");
    }
1029378
function createPopup(popupName, options, popupTypeClass, popupContent, popupHover) {

    // Check if popup already exists
    if (popups[popupName])
      return popups[popupName];

    // Create the popup
    var $popup = $(DIV_TAG)
      .hide()
      .addClass(POPUP_CLASS)
      .appendTo("body");

    // Add the content

    // Custom popup
    if (popupContent)
      $popup.html(popupContent);

    // Color
    else if (popupName == "color") {
      var colors = options.colors.split(" ");
      if (colors.length < 10)
        $popup.width("auto");
      $.each(colors, function(idx, color) {
        $(DIV_TAG).appendTo($popup)
          .css(BACKGROUND_COLOR, "#" + color);
      });
      popupTypeClass = COLOR_CLASS;
    }

    // Font
    else if (popupName == "font")
      $.each(options.fonts.split(","), function(idx, font) {
        $(DIV_TAG).appendTo($popup)
          .css("fontFamily", font)
          .html(font);
      });

    // Size
    else if (popupName == "size")
      $.each(options.sizes.split(","), function(idx, size) {
        $(DIV_TAG).appendTo($popup)
          .html("<font size=" + size + ">" + size + "</font>");
      });

    // Style
    else if (popupName == "style")
      $.each(options.styles, function(idx, style) {
        $(DIV_TAG).appendTo($popup)
          .html(style[1] + style[0] + style[1].replace("<", "</"));
      });

    // URL
    else if (popupName == "url") {
      $popup.html('Enter URL:<br><input type=text value="http://" size=35><br><input type=button value="Submit">');
      popupTypeClass = PROMPT_CLASS;
    }

    // Paste as Text
    else if (popupName == "pastetext") {
      $popup.html('Paste your content here and click submit.<br /><textarea cols=40 rows=3></textarea><br /><input type=button value=Submit>');
      popupTypeClass = PROMPT_CLASS;
    }

    // Add the popup type class name
    if (!popupTypeClass && !popupContent)
      popupTypeClass = LIST_CLASS;
    $popup.addClass(popupTypeClass);

    // Add the unselectable attribute to all items
    if (ie) {
      $popup.attr(UNSELECTABLE, "on")
        .find("div,font,p,h1,h2,h3,h4,h5,h6")
        .attr(UNSELECTABLE, "on");
    }

    // Add the hover effect to all items
    if ($popup.hasClass(LIST_CLASS) || popupHover === true)
      $popup.children().hover(hoverEnter, hoverLeave);

    // Add the popup to the array and return it
    popups[popupName] = $popup[0];
    return $popup[0];

  }
858539
public static function get($iCurrentPage, $iTotalCount, $arSettings = []) {

        if(!empty($arSettings) && isset($arSettings['button_list']) && !empty($arSettings['button_list'])) {
            $arSettings['button_list'] = explode(',', $arSettings['button_list']);
        }


        return parent::get($iCurrentPage, $iTotalCount, $arSettings);
    }
425804
public function addAction(Request $request, $popup)
    {
        $type = $request->get('type');

        return parent::doAddAction($this->getAdminListConfigurator($popup), $type, $request);
    }
820374
function () {
            var cfg = this._cfg;
            var modal = cfg.modal;

            if (this._showBack != null) {
                this._showBack();
                this._showBack = null;
            }

            if (this._popup) {
                this.waiReadText(cfg.waiCloseMsg);

                this._destroyDraggable();
                this._destroyResizable();

                if (cfg.maximized) {
                    this._setContainerOverflow(this._optionsBeforeMaximize.containerOverflow);
                }

                this._domElt = null;
                this._titleBarDomElt = null;
                this._titleDomElt = null;
                if (this._closeDelegateId) {
                    ariaUtilsDelegate.remove(this._closeDelegateId);
                }
                if (this._maximizeDelegateId) {
                    ariaUtilsDelegate.remove(this._maximizeDelegateId);
                }

                this._popup.close();
                this._popup.$unregisterListeners(this);
                this._popup.$dispose();
                this._popup = null;
                PopupContainerManager.releasePopupContainer(this._popupContainer);
                this._popupContainer = null;

                ariaTemplatesLayout.$removeListeners({
                    "viewportResized" : this._onViewportResized,
                    scope : this
                });

                if (modal) {
                    var previouslyFocusedElement = this._previouslyFocusedElement;
                    if (cfg.restoreFocusOnClose && ariaUtilsDom.isInDom(previouslyFocusedElement) && !/^body$/i.test(previouslyFocusedElement.tagName)) {
                        setTimeout(function () {
                            try {
                                // On IE 7 and 8, focusing an element which is no longer in the DOM
                                // throws the "Unexpected call to method or property access." exception
                                previouslyFocusedElement.focus();
                            } catch (e) {}
                        }, 0);
                        this._previouslyFocusedElement = null;
                    }
                }
            }
        }
960698
function openDialog (url) {
  const width = socialshares.config.dialog.width
  const height = socialshares.config.dialog.height

  // Center the popup
  const top = (window.screen.height / 2 - height / 2)
  const left = (window.screen.width / 2 - width / 2)

  window.open(url, 'Share', `width=${width},height=${height},top=${top},left=${left},menubar=no,toolbar=no,resizable=yes,scrollbars=yes`)
}
103130
public void onSingleClick(final View view) {
        final String name = "LicensesDialog";
        final String url = "http://psdev.de";
        final String copyright = "Copyright 2013 Philip Schiffer <admin@psdev.de>";
        final License license = new ApacheSoftwareLicense20();
        final Notice notice = new Notice(name, url, copyright, license);
        new LicensesDialog.Builder(this)
            .setNotices(notice)
            .build()
            .show();
    }
707824
public function getHtmlOutput(\Zend_View_Abstract $view)
    {
        $tabs = $this->getTabs();

        $tabCount = count($tabs);

        if ($tabs && ($this->displaySingleTab || $tabCount > 1)) {
            // Is there a better helper to include JS?
            $view->headScript()->appendFile($this->basepath->getBasePath()  .  '/gems/js/jquery.horizontalScrollMenu.js');

            $script = '(function($) {$(".'.$this->class.'").horizontalScrollMenu();}(jQuery));';

            $view->inlineScript()->appendScript($script);

            // Set the correct parameters
            $this->getCurrentTab();


            $scrollContainer = \MUtil_Html::create()->div();

            if ($tabCount > $this->scrollFromSize) {
                $scrollContainer->a('#', $this->prevLabel, array('class' => 'prev'));
            } else {
                $scrollContainer->span(array('class' => 'prev disabled'))
                        ->raw(str_repeat('&nbsp', strlen($this->prevLabel)));
            }

            $tabRow = $scrollContainer->div(array('class' => 'container'))->ul();

            foreach ($tabs as $tabId => $content) {
                $li = $tabRow->li(array('class' => $this->tabClass));

                if (strlen($content) > $this->tabLabelLength) {
                    $content = substr($content, 0, $this->tabLabelLength) . $this->tabLabelCutOffString;
                }

                $li->a($this->getParameterKeysFor($tabId) + $this->href, $content);

                if ($tabId == $this->currentTab) {
                    $li->appendAttrib('class', $this->tabActiveClass);
                }
            }

            if ($tabCount > $this->scrollFromSize) {
                $scrollContainer->a('#', $this->nextLabel, array('class' => 'next'));
            } else {
                $scrollContainer->span(array('class' => 'next disabled'))
                        ->raw(str_repeat('&nbsp', strlen($this->nextLabel)));
            }

            return $scrollContainer;
        } else {
            return null;
        }
    }
845204
public function downloadFromView($view, array $parameters = array(),
        array $options = array())
    {
        $this->log(sprintf('Download pdf from view (%s).', $view));

        $contentDisposition = 'attachment; filename="' . $this->getName() . '"';
        return $this->generateResponse($view, $contentDisposition, $parameters,
            $options);
    }
195086
function( popup, modify_a_href )
        {
            var textbox = document.createElement('input');
            textbox.placeholder = 'www.example.com';
            if( modify_a_href )
                textbox.value = modify_a_href.href;
            textbox.style.width = '20em';
            textbox.style.maxWidth = parseInt(node_container.offsetWidth *2/3) + 'px';
            textbox.autofocus = true;
            if( modify_a_href )
                addEvent( textbox, 'input', function( e )
                {
                    var url = textbox.value.trim();
                    if( url )
                        modify_a_href.href = url;
                });
            addEvent( textbox, 'keypress', function( e )
            {
                var key = e.which || e.keyCode;
                if( key != 13 )
                    return;
                var url = textbox.value.trim();
                if( modify_a_href )
                    ;
                else if( url )
                {
                    var url_scheme = url;
                    if( ! /^[a-z0-9]+:\/\//.test(url) )
                        url_scheme = "http://" + url;
                    if( commands.getSelectedHTML() )
                        commands.insertLink( url_scheme );
                    else
                    {
                        // Encode html entities - http://stackoverflow.com/questions/5499078/fastest-method-to-escape-html-tags-as-html-entities
                        var htmlencode = function( text ) {
                            return text.replace(/[&<>"]/g, function(tag)
                            {
                                var charsToReplace = { '&':'&amp;', '<':'&lt;', '>':'&gt;', '"':'&quot;' };
                                return charsToReplace[tag] || tag;
                            });
                        }
                        commands.insertHTML( '<a href="' + htmlencode(url_scheme) + '">' + htmlencode(url) + '</a>' );
                    }
                }
                commands.closePopup().collapseSelection();
                node_contenteditable.focus();
            });
            popup.appendChild( textbox );
            // set focus
            window.setTimeout( function()
            {
                textbox.focus();
                add_class_focus();
            }, 1 );
        }
985463
public static OnClickListener launchWebBrowserOnClick(final Context context, final String url){
        return new OnClickListener() {
            @Override
            public void onClick(View v) {
                launchWebBrowser(context, url);
            }
        };
    }
1026650
private void initOverviewPopup() {

        m_updateExceptionsButton = new CmsPushButton();
        m_updateExceptionsButton.setText(Messages.get().key(Messages.GUI_LOCALE_DIALOG_OK_0));
        m_updateExceptionsButton.addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {

                if (handleChange()) {
                    m_controller.updateExceptions(m_overviewList.getUncheckedDates());
                    m_overviewPopup.hide();
                }

            }
        });
        m_overviewPopup = new CmsPopup(Messages.get().key(Messages.GUI_SERIALDATE_OVERVIEW_POPUP_TITLE_0), 800);
        m_overviewPopup.center();
        m_overviewPopup.setAutoHideEnabled(true);
        m_overviewPopup.addDialogClose(null);
        m_overviewPopup.addButton(m_updateExceptionsButton);
        CmsScrollPanel panel = new CmsScrollPanel();
        m_overviewList = new CmsCheckableDatePanel(m_dateFormat, CmsCheckableDatePanel.Style.TWO_COLUMNS);
        m_overviewList.addDate(new Date());
        panel.getElement().getStyle().setPaddingLeft(10, Unit.PX);
        panel.getElement().getStyle().setProperty("maxHeight", m_overviewPopup.getAvailableHeight(0), Unit.PX);
        panel.add(m_overviewList);
        m_overviewPopup.add(panel);
        m_overviewPopup.hide();

    }
410481
public function FetchViewLocation($View = '', $ApplicationFolder = '') {
      if ($View == '')
         $View = strtolower($this->Name());
         
      if (substr($View, -6) == 'module')
         $View = substr($View, 0, -6);
               
      if (substr($View, 0, 4) == 'gdn_')
         $View = substr($View, 4);

      if ($ApplicationFolder == '')
         $ApplicationFolder = strpos($this->_ApplicationFolder, '/') ? $this->_ApplicationFolder : strtolower($this->_ApplicationFolder);

      $ThemeFolder = $this->_ThemeFolder;
      
      $ViewPath = NULL;
      
      // Try to use Gdn_Controller's FetchViewLocation
      if (Gdn::Controller() instanceof Gdn_Controller) {
         try {
            $ViewPath = Gdn::Controller()->FetchViewLocation($View, 'modules', $ApplicationFolder);
         } catch (Exception $Ex) {}
      }
      
      if (!$ViewPath) {
         
         $ViewPaths = array();
         // 1. An explicitly defined path to a view
         if (strpos($View, '/') !== FALSE)
            $ViewPaths[] = $View;

         // 2. A theme
         if ($ThemeFolder != '') {
            // a. Application-specific theme view. eg. /path/to/application/themes/theme_name/app_name/views/modules/
            $ViewPaths[] = CombinePaths(array(PATH_THEMES, $ThemeFolder, $ApplicationFolder, 'views', 'modules', $View . '.php'));
            
            // b. Garden-wide theme view. eg. /path/to/application/themes/theme_name/views/modules/
            $ViewPaths[] = CombinePaths(array(PATH_THEMES, $ThemeFolder, 'views', 'modules', $View . '.php'));
         }

         // 3. Application default. eg. /path/to/application/app_name/views/controller_name/
         if ($this->_ApplicationFolder)
            $ViewPaths[] = CombinePaths(array(PATH_APPLICATIONS, $ApplicationFolder, 'views', 'modules', $View . '.php'));
         else
            $ViewPaths[] = dirname($this->Path())."/../views/modules/$View.php";

         // 4. Garden default. eg. /path/to/application/dashboard/views/modules/
         $ViewPaths[] = CombinePaths(array(PATH_APPLICATIONS, 'dashboard', 'views', 'modules', $View . '.php'));

         $ViewPath = Gdn_FileSystem::Exists($ViewPaths);
      }
      
      if ($ViewPath === FALSE)
         throw new Exception(ErrorMessage('Could not find a `' . $View . '` view for the `' . $this->Name() . '` module in the `' . $ApplicationFolder . '` application.', get_class($this), 'FetchView'), E_USER_ERROR);

      return $ViewPath;
   }
1327519
public static <IMAGE extends ImageView> void doLoadImageUrl(@NonNull IMAGE view, @Nullable String url) {
        Preconditions.checkState(sImageSetter != null, "ImageSetter must be initialized before calling image load");
        sImageSetter.doLoadImageUrl(view, url);
    }
963143
public function buildView(FormView $view, FormInterface $form, array $options) {
        if(isset($options['ad_component_addon'])) {
            switch ($options['ad_component_addon']) {
                case 'pre':
                case 'post':
                    $addons=[$options['ad_component_addon']];
                    break;
                case 'both':
                    $addons=['pre','post'];
                    break;
                default:
                    throw new LogicException('Valor "'.$options['ad_component_addon'].'" parámetro "ad_component_addon" no válido. Valores permitidos: pre|post|both');
            }
            foreach ($addons as $addon) {
                $view->vars['ad_component_addon_type_'.$addon] = is_array($options['ad_component_addon_type']) ?
                    (isset($options['ad_component_addon_type'][$addon]) ? $options['ad_component_addon_type'][$addon] : null) :
                    $options['ad_component_addon_type'];
                if(is_null($view->vars['ad_component_addon_type_'.$addon])){
                    throw new LogicException('Falta parámetro "ad_component_addon_type" para "'.$addon.'" addon');
                }
                elseif(!in_array($view->vars['ad_component_addon_type_'.$addon], ['text','button','icon'])){
                    throw new LogicException('Valor "'.$view->vars['ad_component_addon_type_'.$addon].'" parámetro "ad_component_addon_type" para "'.$addon.'" addon no válido. Valores permitidos: text|button|icon');
                }

                $view->vars['ad_component_addon_content_type_'.$addon] = is_array($options['ad_component_addon_content_type']) ?
                    (isset($options['ad_component_addon_content_type'][$addon]) ? $options['ad_component_addon_content_type'][$addon] : null) :
                    $options['ad_component_addon_content_type'];
                if($view->vars['ad_component_addon_type_'.$addon]=='button') {
                    if(is_null($view->vars['ad_component_addon_content_type_'.$addon])) {
                        throw new LogicException('Falta Parámetro "ad_component_addon_content_type" para "' . $addon . '" addon');
                    }
                    elseif(!in_array($view->vars['ad_component_addon_content_type_'.$addon], ['text','icon'])) {
                        throw new LogicException('Valor "'.$view->vars['ad_component_addon_content_type_'.$addon].'" parámetro "ad_component_addon_content_type" para "'.$addon.'" addon no válido. Valores permitidos: text|icon');
                    }
                }

                $view->vars['ad_component_addon_content_'.$addon] = is_array($options['ad_component_addon_content']) ?
                    (isset($options['ad_component_addon_content'][$addon]) ? $options['ad_component_addon_content'][$addon] : null) :
                    $options['ad_component_addon_content'];
                if(is_null($view->vars['ad_component_addon_content_'.$addon])){
                    throw new LogicException('Falta Parámetro "ad_component_addon_content" para "'.$addon.'" addon');
                }

                $view->vars['ad_component_addon_attr_'.$addon] = isset($options['ad_component_addon_attr']) ?
                    (isset($options['ad_component_addon_attr'][$addon]) ? $options['ad_component_addon_attr'][$addon] : $options['ad_component_addon_attr']) :
                    array();
            }
        }
    }
813526
public function settingsAction(Request $request, View $view)
    {
        $pageSeo = $view->getSeo() ?: new PageSeo();
        $form = $this->createSettingsForm($pageSeo, $view);

        $form->handleRequest($request);

        $response = $this->getNotPersistedSettingsResponse(
            $form,
            $view,
            $request->query->get('novalidate', false)
        );

        return new JsonResponse($response);
    }
508332
function getViewParams(url, view) {
  let match = view.regex.exec(url);
  if (match) {
    match.shift();
    return zip(view.params, match);
  } else {
    return null;
  }
}