本文整理汇总了PHP中JS::minify方法的典型用法代码示例。如果您正苦于以下问题:PHP JS::minify方法的具体用法?PHP JS::minify怎么用?PHP JS::minify使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JS
的用法示例。
在下文中一共展示了JS::minify方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: JS
static function _create_file($src, $des)
{
if ($src == $des) {
return $src;
}
$read_file = LP_PLUGIN_PATH . '/' . $src;
$write_file = LP_PLUGIN_PATH . '/' . $des;
global $wp_filesystem;
if ($wp_filesystem) {
include_once LP_PLUGIN_PATH . '/inc/libraries/minify/src/Minify.php';
include_once LP_PLUGIN_PATH . '/inc/libraries/minify/src/JS.php';
$code = $wp_filesystem->get_contents($read_file);
$minifier = new JS($code);
$code = $minifier->minify();
$wp_filesystem->put_contents($write_file, $code);
if (file_exists($write_file)) {
$src = $des;
}
}
return $src;
}
示例2: buildTheViewScript
//.........这里部分代码省略.........
}
$func .= "\n\t}\n}\n" . $map;
}
// add the needed validation to file
if (isset($this->validationFixBuilder[$viewName]) && ComponentbuilderHelper::checkArray($this->validationFixBuilder[$viewName])) {
$validation .= "\n// update required fields";
$validation .= "\nfunction updateFieldRequired(name,status)";
$validation .= "\n{";
$validation .= "\n\tvar not_required = jQuery('#jform_not_required').val();";
$validation .= "\n\n\tif(status == 1)";
$validation .= "\n\t{";
$validation .= "\n\t\tif (isSet(not_required) && not_required != 0)";
$validation .= "\n\t\t{";
$validation .= "\n\t\t\tnot_required = not_required+','+name;";
$validation .= "\n\t\t}";
$validation .= "\n\t\telse";
$validation .= "\n\t\t{";
$validation .= "\n\t\t\tnot_required = ','+name;";
$validation .= "\n\t\t}";
$validation .= "\n\t}";
$validation .= "\n\telse";
$validation .= "\n\t{";
$validation .= "\n\t\tif (isSet(not_required) && not_required != 0)";
$validation .= "\n\t\t{";
$validation .= "\n\t\t\tnot_required = not_required.replace(','+name,'');";
$validation .= "\n\t\t}";
$validation .= "\n\t}";
$validation .= "\n\n\tjQuery('#jform_not_required').val(not_required);";
$validation .= "\n}\n";
}
// set the isSet function
$isSet = "\n// the isSet function";
$isSet .= "\nfunction isSet(val)";
$isSet .= "\n{";
$isSet .= "\n\tif ((val != undefined) && (val != null) && 0 !== val.length){";
$isSet .= "\n\t\treturn true;";
$isSet .= "\n\t}";
$isSet .= "\n\treturn false;";
$isSet .= "\n}";
}
// load to this buket
$fileScript = $initial . $func . $validation . $isSet;
$footerScript = $listener;
}
// add custom script to file
if (isset($this->customScriptBuilder['view_file'][$viewName]) && ComponentbuilderHelper::checkString($this->customScriptBuilder['view_file'][$viewName])) {
if (!isset($fileScript)) {
$fileScript = '';
}
$fileScript .= "\n\n" . str_replace(array_keys($this->placeholders), array_values($this->placeholders), $this->customScriptBuilder['view_file'][$viewName]);
}
// add custom script to footer
if (isset($this->customScriptBuilder['view_footer'][$viewName]) && ComponentbuilderHelper::checkString($this->customScriptBuilder['view_footer'][$viewName])) {
$customFooterScript = "\n\n" . str_replace(array_keys($this->placeholders), array_values($this->placeholders), $this->customScriptBuilder['view_footer'][$viewName]);
if (strpos($customFooterScript, '<?php') === false) {
// only add now if no php is added to the footer script
if (!isset($footerScript)) {
$footerScript = '';
}
$footerScript .= $customFooterScript;
unset($customFooterScript);
}
}
// minfy the script
if ($this->params->get('minify') && isset($fileScript) && ComponentbuilderHelper::checkString($fileScript)) {
// minify the fielScript javscript
$minifier = new JS();
$minifier->add($fileScript);
$fileScript = $minifier->minify();
}
// minfy the script
if ($this->params->get('minify') && isset($footerScript) && ComponentbuilderHelper::checkString($footerScript)) {
// minify the footerScript javscript
$minifier = new JS();
$minifier->add($footerScript);
$footerScript = $minifier->minify();
}
// make sure there is script to add
if (isset($fileScript) && ComponentbuilderHelper::checkString($fileScript)) {
// add the head script if set
if (isset($head) && ComponentbuilderHelper::checkString($head)) {
$fileScript = "// Some Global Values\n" . $head . "\n" . $fileScript;
}
// load the script
$this->editBodyViewScriptBuilder[$viewName]['fileScript'] = $fileScript;
}
// make sure to add custom footer script if php was found in it, since we canot minfy it with php
if (isset($customFooterScript) && ComponentbuilderHelper::checkString($customFooterScript)) {
if (!isset($footerScript)) {
$footerScript = '';
}
$footerScript .= $customFooterScript;
}
// make sure there is script to add
if (isset($footerScript) && ComponentbuilderHelper::checkString($footerScript)) {
// add the needed script tags
$footerScript = "\n\n" . '<script type="text/javascript">' . "\n" . $footerScript . "\n</script>";
$this->editBodyViewScriptBuilder[$viewName]['footerScript'] = $footerScript;
}
}