Displays a jQuery input mask.

@param string $selector The selector.
@param string $mask The mask.
@param array $options The options.
@param bool $scriptTag Script tag ?
@return string Returns the jQuery input mask.
355995
protected function jQueryInputMask($selector, $mask, array $options, $scriptTag) {

        $template = "$('%selector%').inputmask(\"%mask%\",%arguments%);";

        $innerHTML = StringHelper::replace($template, ["%selector%", "%mask%", "%arguments%"], [$selector, $mask, json_encode($options)]);

        if (true === $scriptTag) {
            return $this->getRendererTwigExtension()->coreScriptFilter($innerHTML);
        }
        return $innerHTML;
    }
896052
public function write($mask = '%s')
    {
        $str='';
        foreach ($this->cleanStack($this->get(), 'name') as $entry) {
            $tag_attrs = array();
            if (true===$entry['http-equiv']) {
                $tag_attrs['http-equiv'] = $entry['name'];
            } else {
                $tag_attrs['name'] = $entry['name'];
            }
            $tag_attrs['content'] = $entry['content'];
            $tag = Html::writeHtmlTag('meta', null, $tag_attrs, true);
            if (isset($entry['condition']) && !empty($entry['condition'])) {
                $tag = ConditionalComment::buildCondition($tag, $entry['condition']);
            }
            $str .= sprintf($mask, $tag);
        }
        return $str;
    }
99786
function getPasswordMeter($selector)
    {
        $this->debug->group(__METHOD__);
        \add_head_tag('script','/common/js/pwd_meter/password-meter.js', array('defer'=>true));
        \add_head_tag('script','/common/js/pwd_meter/new_password_jquery.js', array('defer'=>true));
        $style = <<<EOD
    .passwordFeedback {
        /*
        margin-top:2em;
        */
    }
    #scorebarBorder {
        float:left;
        width: 100px;
        height: 20px;
        border: 1px #000 solid;
        margin-left: 1em;
        margin-right: 1em;
    }
    #score {
        position:absolute;
        margin-top:1px;
        width: 100px;
        z-index: 10;
        color: #000;
        font-weight: bold;
        line-height:normal;
        text-align: center;
    }
    #scorebar {
        background: url(/common/js/pwd_meter/images/bg_strength.jpg) repeat 0px 0px;
        position:absolute;
        width: 100px;
        height: 20px;
        z-index: 0;
    }
    #criteria {
        list-style-type:none;
        padding-left:0px;
        /*
        padding-top:10px;
        */
    }
    #criteria .checkbox {
        display: inline-block;
        width: 16px;
        height: 16px;
        min-height: inherit;
        margin: 0 .5em 0 0;
        padding: 0;
    }
    #criteria .checked .checkbox {
        background-image:url(/images/tiny/png-8/16-em-check.png);
    }
EOD;
        \append_content('style', $style);
        //
        $script = <<<EOD
    passwordmeter = new PasswordFeedback({
        selector : '{$selector}',
        criteria : ['alphaL','alphaU','exclude','length','numeric','special'],  // the checkmarks below
        init : function(pm) {
            pm.PasswordLength.minimum = 8;
            pm.PasswordLength.maximum = 32;
        },
        onchange : function(pm, pwd, matchOpacity) {
            console.log('pwdOnChange custom');
            var checkmarks = {
                    alphaL      : pm.LowercaseLetters.status,
                    alphaU      : pm.UppercaseLetters.status,
                    //exclude   : !pwd.match(/[&*( )< >^]/),
                    length      : pm.PasswordLength.status,
                    match       : matchOpacity,
                    numeric     : pm.Numerics.status,
                    special     : pm.Symbols.status
                },
                k = '',
                v = '',
                \$node = null;
            // console.log('cs',cs);
            // console.log('checkmarks',checkmarks);
            if (checkmarks.length) {
                // console.log('minimum met');
                $('.passwordFeedback .length .min').hide();
                $('.passwordFeedback .length .max').show();
                if ( pwd.length > pm.PasswordLength.maximum ) {
                    //console.log('too long');
                    checkmarks.length = false;
                }
            } else {
                $('.passwordFeedback .length .min').show();
                $('.passwordFeedback .length .max').hide();
            }
            for (k in checkmarks) {
                // console.log('pair.key',pair.key);
                v = checkmarks[k];
                \$node = $('#criteria .'+k);
                if ( v ) {
                    \$node.addClass('checked');
                    \$node.find('.checkbox').css({'opacity': v});
                } else {
                    \$node.removeClass('checked');
                }
            };
        } // end onchange
    });
EOD;
        append_content('script', $script);
        $html = <<<'EOD'
            <div class="passwordFeedback">
                <h3>Password Strength:</h3>
                <div id="scorebarBorder" class="reset-box-sizing">
                    <div id="score">0%</div>
                    <div id="scorebar">&nbsp;</div>
                </div>
                <span id="complexity">Too Short</span>
                <h3>Criteria:</h3>
                <ul id="criteria">
                    <li class="length"><span class="checkbox"></span><span class="min">Must be at least 8 characters long.</span><span class="max" style="display:none;">No more than 32 characters long.</span></li>
                    <li class="alphaL"><span class="checkbox"></span>Must contain at least one lowercase letter.</li>
                    <li class="alphaU"><span class="checkbox"></span>Must contain at least one uppercase letter.</li>
                    <li class="numeric"><span class="checkbox"></span>Must contain at least one number.</li>
                    <li class="special"><span class="checkbox"></span>Must contain at least one special character.</li>
                    <!--
                    <li class="exclude"><span class="checkbox"></span>Must NOT contain &amp;*()&lt;&gt;^ or space.</li>
                    -->
                    <li class="match"><span class="checkbox"></span>Passwords must match</li>
                </ul>
            </div>
EOD;
        $this->debug->groupEnd();
        return $html;
    }
307733
public function setTagOptions($tag, array $options) 
    {
        $this->tagOptions[$tag] = $options; 
        $this->keyTagParamsComposite = null;
    }
167333
public function toggleField($selector = '.jsToggleField', $widget = 'JBZoo.FieldToggle', array $options = [])
    {
        $this->jqueryFactory();

        $this->Html->script('Core.admin/widget/field-toggle.js', $this->_setOptions([
            'alias'  => __FUNCTION__,
            'weight' => self::WEIGHT_WIDGET
        ]));

        $options = Hash::merge(['token' => $this->request->getCookie('csrfToken')], $options);
        $this->Js->widget($selector, $widget, $options);

        return $this;
    }
5397
public static function widget(Tag $tag, $name, $options = array()) {
    //$tag->addClass('\Psc\jquery-widget');
    
    $js = sprintf("%s(%s)",
                  $name, JSHelper::convertHashMap((object) $options)
                  );
    
    $tag->chain(new Code($js));
    
    return $tag;
  }
462525
private static function getTemplateAttributeFakeJs(array $options, DOMElement $dom)
    {
        $expressionsByLine = self::getVueAttributeExpressions($options['attributePrefixes'], $dom);

        if (empty($expressionsByLine)) {
            return '';
        }

        $maxLines = max(array_keys($expressionsByLine));
        $fakeJs = '';

        for ($line = 1; $line <= $maxLines; $line++) {
            if (isset($expressionsByLine[$line])) {
                $fakeJs .= implode("; ", $expressionsByLine[$line]);
            }
            $fakeJs .= "\n";
        }

        return $fakeJs;
    }
706544
public static function hide($script, $openTag, $closeTag)
    {
        $data = Strings::splite($script, $openTag);
        //
        $output = $data[0];
        //
        for ($i = 1; $i < Collection::count($data); $i++) {
            $output .= '';
            //
            $next = Strings::splite($data[$i], $closeTag);
            $output .= '';
            //
            for ($j = 1; $j < Collection::count($next); $j++) {
                if ($j == (Collection::count($next) - 1)) {
                    $output .= $next[$j];
                } else {
                    $output .= $next[$j].$closeTag;
                }
            }
        }

        return $output;
    }
251371
public function write($mask = '%s')
    {
        $str='';
        foreach ($this->cleanStack($this->get()) as $entry) {
            $str .= (strlen($str)>0 ? $this->separator : '').$entry;
        }
        $title_str = Html::writeHtmlTag('title', strip_tags($str));
        return sprintf($mask, $title_str);
    }
652825
public function highlight($text, $needle, $tag = 'em', $options = [])
    {
        $this->options = array_merge($this->options, $options);

        $tagAttributes = '';
        if (count($this->options['tagOptions'])) {
            foreach ($this->options['tagOptions'] as $attr => $value) {
                $tagAttributes .= $attr . '="' . $value . '" ';
            }
            $tagAttributes = ' ' . trim($tagAttributes);
        }

        $highlight = '<' . $tag . $tagAttributes .'>\1</' . $tag . '>';
        $needle    = preg_split('/\PL+/u', $needle, -1, PREG_SPLIT_NO_EMPTY);

        // Select pattern to use
        if ($this->options['simple']) {
            $pattern    = '#(%s)#';
            $sl_pattern = '#(%s)#';
        } else {
            $pattern    = '#(?!<.*?)(%s)(?![^<>]*?>)#';
            $sl_pattern = '#<a\s(?:.*?)>(%s)</a>#';
        }

	    // Add Forgotten Unicode
	    $pattern .= 'u';

        // Case sensitivity
        if (!($this->options['caseSensitive'])) {
            $pattern .= 'i';
            $sl_pattern .= 'i';
        }

        $needle = (array) $needle;
        foreach ($needle as $needle_s) {
            $needle_s = preg_quote($needle_s);

            // Escape needle with optional whole word check
            if ($this->options['wholeWord']) {
                $needle_s = '\b' . $needle_s . '\b';
            }

            // Strip links
            if ($this->options['stripLinks']) {
                $sl_regex = sprintf($sl_pattern, $needle_s);
                $text     = preg_replace($sl_regex, '\1', $text);
            }

            $regex = sprintf($pattern, $needle_s);
            $text  = preg_replace($regex, $highlight, $text);
        }

        return $text;
    }
677819
private function getMatchingElementRepresentation($selectorType, $selector, $plural = false)
    {
        $pluralization = $plural ? 's' : '';

        if (in_array($selectorType, array('named', 'named_exact', 'named_partial'))
            && is_array($selector) && 2 === count($selector)
        ) {
            return sprintf('%s%s matching locator "%s"', $selector[0], $pluralization, $selector[1]);
        }

        if (is_array($selector)) {
            $selector = implode(' ', $selector);
        }

        return sprintf('element%s matching %s "%s"', $pluralization, $selectorType, $selector);
    }
11623
public function input($fieldName, $options = [])
    {
        //** we need to make the input combine with <span class="input-group-addon">@</span>
        if (isset($options['icon'])) {
            $icon = $this->Html->icon($options['icon']);

            $between = '<div class="input-group">' . '<span class="input-group-addon">' . $icon . '</span>';

            $after = '</div>';
            $options = [
                'between' => $between,
                'after' => $after,
            ];
        }
        if (!isset($options['placeholder'])) {
            $options['placeholder'] = __(Inflector::humanize(Inflector::underscore($fieldName)));
        }
        return parent::input($fieldName, $options);
    }
721204
public static function caption($selector = 'img.caption')
	{
		if (isset(self::$loaded[__METHOD__][$selector]))
		{
			return;
		}

		self::framework(true);

		App::get('document')->addScriptDeclaration(
			"jQuery(document).ready(function($){
				$('" . $selector . "').tooltip({
					position: {
						my: 'center bottom',
						at: 'center top'
					},
					create: function(event, ui) {
						var tip = $(this),
							tipText = tip.attr('title');

						if (tipText.indexOf('::') != -1) {
							var parts = tipText.split('::');
							tip.attr('title', parts[1]);
						}
					},
					tooltipClass: 'tooltip'
				});
			});"
		);

		// Set static array
		self::$loaded[__METHOD__][$selector] = true;
	}
357035
public static function a($href, $content = '', $title = '', $target = '', $options = [])
    {
        $a_tag_tpl = '<a href="%s" title="%s" target="%s"%s>%s</a>';
        return sprintf($a_tag_tpl, $href, $title, $target, self::assembleTagOptions($options), $content);
    }
86112
public function scrollIntoView($selector)
    {
        $locator = substr($selector, 0, 1);
        
        switch ($locator) {
            case '/': // XPath selector
                $function = <<<JS
(function(){
  var elem = document.evaluate($selector, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  elem.scrollIntoView(false);
})(jQuery)
JS;
                break;
            
            case '#': // ID selector
                $selector = substr($selector, 1);
                $function = <<<JS
(function(){
  var elem = document.getElementById("$selector");
  elem.scrollIntoView(false);
})(jQuery)
JS;
                break;
            
            case '.': // Class selector
                $selector = substr($selector, 1);
                $function = <<<JS
(function(){
  var elem = document.getElementsByClassName("$selector");
  elem[0].scrollIntoView(false);
})(jQuery)
JS;
                break;
            
            default:
                throw new \Exception(__METHOD__ . ' Couldn\'t find selector: ' . $selector . ' - Allowed selectors: #id, .className, //xpath');
                break;
        }
        
        try {
            $this->getSession()->executeScript($function);
        } catch (\Exception $e) {
            throw new \Exception(__METHOD__ . ' failed'. ' Message: for this locator:"'.$selector.'"');
        }
    }
614315
public function fillForm($selector, $data = array(), $submit = false)
    {
        $jsonData = json_encode($data);
        $jsonSubmit = ($submit) ? 'true' : 'false';

        $fragment = <<<FRAGMENT
casper.then(function () {
    this.fill('$selector', $jsonData, $jsonSubmit);
});
FRAGMENT;

        $this->script .= $fragment;

        return $this;
    }
702680
public function render($menu, $tag = 'ul', $options){
        return $this->renderMenu(
            $this->menuCollection[$menu],
            $tag,
            $options,
            $this->menuCollection[$menu]->getActiveMenu(),
            0
        );
    }