本文整理汇总了PHP中Zend\View\Renderer\PhpRenderer::headScript方法的典型用法代码示例。如果您正苦于以下问题:PHP PhpRenderer::headScript方法的具体用法?PHP PhpRenderer::headScript怎么用?PHP PhpRenderer::headScript使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\View\Renderer\PhpRenderer
的用法示例。
在下文中一共展示了PhpRenderer::headScript方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createAction
public function createAction()
{
$headScript = new PhpRenderer();
$headScript->headScript()->appendFile('/js/form/create.form.js');
$headScript->headScript()->appendFile('/js/form/line.text.js');
$headScript->headScript()->appendFile('/js/form/add.form.js');
$headScript->headScript()->appendFile('/js/form/json.form.js');
$form = '';
return ['form' => $form];
}
示例2: renderPost
public function renderPost(Renderer $renderer)
{
$coreformsjs = $renderer->basepath('/Core/js/core.forms.js');
$javaScript = <<<JS
\$(document).ready(function() {
console.log('attached yk.forms.done to ', \$('form'));
\$('form').on('yk.forms.done', function(event, data) {
//if (typeof data != 'undefined' && typeof data['data'] != 'undefined') {}
if (typeof data != 'undefined' && typeof data['data'] != 'undefined') {
if (typeof data['data']['jobvalid'] != 'undefined' && data['data']['jobvalid'] === true) {
\$('#job_incomplete').hide();
\$('#finalize_jobentry').show();
}
else {
\$('#job_incomplete').show();
\$('#finalize_jobentry').hide();
}
}
\$('#job_errormessages').empty();
if (typeof data['data']['errorMessage'] != 'undefined') {
\$('#job_errormessages').append(data['data']['errorMessage']);
}
console.debug('job-form-inline', event, data);
});
});
JS;
$renderer->headScript()->appendScript($javaScript);
return parent::renderPost($renderer);
}
示例3: render
public function render(PhpRenderer $view, MediaRepresentation $media, array $options = [])
{
$IIIFData = $media->mediaData();
$view->headScript()->appendFile($view->assetUrl('js/openseadragon/openseadragon.min.js', 'Omeka'));
$prefixUrl = $view->assetUrl('js/openseadragon/images/', 'Omeka');
$image = '<div class="openseadragon" id="iiif-' . $media->id() . '"></div>
<script type="text/javascript">
var viewer = OpenSeadragon({
id: "iiif-' . $media->id() . '",
prefixUrl: "' . $prefixUrl . '",
tileSources: [
' . json_encode($IIIFData) . '
]
});
</script>';
return $image;
}
示例4: testViewHelperPersist
public function testViewHelperPersist()
{
$view = new PhpRenderer();
$view->setHelperPluginManager($this->serviceManager->get('ViewHelperManager'));
$view->dojo()->activate();
$headLink = $view->headLink();
$this->assertEquals('js/dojo_rel/dojo/resources/dojo.css', $headLink[0]->href);
$this->assertEquals('screen', $headLink[0]->media);
$this->assertEquals('stylesheet', $headLink[0]->rel);
$this->assertEquals('text/css', $headLink[0]->type);
$this->assertEquals('js/dojo_rel/dijit/themes/claro/claro.css', $headLink[1]->href);
$this->assertEquals('screen', $headLink[1]->media);
$this->assertEquals('stylesheet', $headLink[1]->rel);
$this->assertEquals('text/css', $headLink[1]->type);
$headScript = $view->headScript();
$this->assertEquals('async: true, baseUrl: "js/dojo_rel/dojo"', $headScript[0]->attributes['data-dojo-config']);
$this->assertEquals('js/dojo_rel/dojo/dojo.js', $headScript[0]->attributes['src']);
$this->assertEquals('text/javascript', $headScript[0]->type);
$this->assertEquals("require(['dojo/parser', 'dojo/domReady!'], function(parser) {parser.parse();})", $headScript[1]->source);
$this->assertEquals('text/javascript', $headScript[1]->type);
$this->assertEquals('claro', $view->dojo()->getTheme());
}
示例5: render
/** {@inheritdoc} */
public function render(\Zend\View\Renderer\PhpRenderer $view)
{
$commandLine = $view->translate('Command line');
$labels = array('launch' => $commandLine, 'execute' => $commandLine, 'store' => $view->translate('Target Path'));
$labels = ' var actionParamLabels = ' . json_encode($labels) . ";\n";
$view->headScript()->captureStart();
print $labels;
?>
/**
* Hide or display a block element.
*/
function display(name, display)
{
document.getElementsByName(name)[0].parentNode.style.display = display ? 'table-row' : 'none';
}
/*
* Event handler for Platform combobox. Also called for form
* initialization. Hides/displays notification elements which have no
* effect on non-Windows platforms.
*/
function changePlatform()
{
if (document.getElementById('form_package_build_platform').value == 'windows') {
display('Warn', true);
display('PostInstMessage', true);
toggleWarn();
} else {
display('Warn', false);
display('WarnMessage', false);
display('WarnCountdown', false);
display('WarnAllowAbort', false);
display('WarnAllowDelay', false);
display('PostInstMessage', false);
}
}
/*
* Event handler for Action combobox. Also called for form initialization.
* Changes label of parameter input field according to selected action.
*/
function changeParam()
{
var label = actionParamLabels[document.getElementsByName('DeployAction')[0].value];
document.getElementsByName('ActionParam')[0].parentNode.getElementsByTagName('span')[0].innerHTML = label;
}
/*
* Event handler for Warn checkbox. Also called for form initialization.
* Hides or displays Warn* fields according to checked state.
*/
function toggleWarn()
{
var checked = document.getElementById('form_package_build_warn').checked &&
document.getElementById('form_package_build_platform').value == 'windows';
display('WarnMessage', checked);
display('WarnCountdown', checked);
display('WarnAllowAbort', checked);
display('WarnAllowDelay', checked);
}
<?php
$view->headScript()->captureEnd();
$view->placeholder('BodyOnLoad')->append('changePlatform()');
$view->placeholder('BodyOnLoad')->append('changeParam()');
$view->placeholder('BodyOnLoad')->append('toggleWarn()');
$view->placeholder('BodyOnLoad')->append('document.getElementsByName("Name")[0].focus()');
return parent::render($view);
}
示例6: render
/** {@inheritdoc} */
public function render(\Zend\View\Renderer\PhpRenderer $view)
{
$view->headScript()->captureStart();
?>
// Hide or show all label elements following the checkbox within the same fieldset
function toggle(element)
{
var node = element.parentNode.parentNode;
while (node = node.nextSibling) {
switch (node.nodeName) {
case 'LABEL':
node.style.display = element.checked ? 'table-row' : 'none';
break;
case 'UL':
node.style.display = element.checked ? 'block' : 'none';
break;
default:
// Invisible text node, nothing to be changed
}
}
}
// Initialize display of fieldset content
function toggleByName(name)
{
var elements = document.getElementsByName(name);
for (var i = elements.length - 1; i >= 0; i--) {
if (elements[i].type == 'checkbox') {
toggle(elements[i]);
break;
}
}
}
<?php
$view->headScript()->captureEnd();
$view->placeholder('BodyOnLoad')->append('toggleByName("Download[packageDeployment]")');
$view->placeholder('BodyOnLoad')->append('toggleByName("Scan[allowScan]")');
return parent::render($view);
}
示例7: render
/** {@inheritdoc} */
public function render(\Zend\View\Renderer\PhpRenderer $view)
{
$view->headScript()->captureStart();
?>
/**
* Show/hide elements according to selected "Where" radio button
*/
function selectElements()
{
var buttons = document.getElementsByName('Where');
var newGroup;
for (var i = 0; i < buttons.length; i++) {
if (buttons[i].value == 'new') {
newGroup = buttons[i].checked;
break;
}
}
if (newGroup) {
display('NewGroup', true);
display('Description', true);
display('ExistingGroup', false);
} else {
display('NewGroup', false);
display('Description', false);
display('ExistingGroup', true);
}
var errors = document.getElementsByClassName('error');
for (i = 0; i < errors.length; i++) {
errors[i].style.display = newGroup ? 'block' : 'none';
}
}
/**
* Hide or show a form element
*
* name (string): element name
* show (bool): true to show, false to hide
*/
function display(name, show)
{
document.getElementsByName(name)[0].parentNode.style.display = show ? 'table-row' : 'none';
}
<?php
$view->headScript()->captureEnd();
$view->placeholder('BodyOnLoad')->append('selectElements()');
return parent::render($view);
}
示例8: render
/**
* Render form
*
* @param \Zend\View\Renderer\PhpRenderer $view
* @return string
*/
public function render(\Zend\View\Renderer\PhpRenderer $view)
{
$view->headScript()->captureStart();
?>
// Filter types
var types = <?php
print json_encode($this->_types);
?>
;
/**
* Event handler for Filter combobox
*
* Sets options for "operators" element according to selected filter.
*/
function filterChanged()
{
var elements = document.getElementById('form_search').elements;
var operators;
switch (types[elements['filter'].value]) {
case 'integer':
case 'float':
case 'date':
operators = <?php
print json_encode($this->_operatorsOrdinal);
?>
;
break;
default:
operators = <?php
print json_encode($this->_operatorsText);
?>
;
}
var options = elements['operator'].options;
options.length = 0;
for (var value in operators) {
options.add(new Option(operators[value], value));
}
}
<?php
$view->headScript()->captureEnd();
$onload = $view->placeholder('BodyOnLoad');
$onload->append('filterChanged()');
// Set operator value manually because the element creation code does
// not know it's valid and ignores it.
$initialOperator = $this->get('operator')->getValue();
if ($initialOperator) {
$onload->append(sprintf('document.getElementById("form_search").elements["operator"].value = %s', json_encode($initialOperator)));
}
return parent::render($view);
}
示例9: renderPost
public function renderPost(Renderer $renderer)
{
$coreformsjs = $renderer->basepath('/Core/js/core.forms.js');
$javaScript = <<<JS
\$(document).ready(function() {
console.log('attached yk.forms.done to ', \$('form'));
\$('form').on('yk.forms.done', function(event, data) {
//if (typeof data != 'undefined' && typeof data['data'] != 'undefined') {}
if (typeof data != 'undefined' && typeof data['data'] != 'undefined') {
if (typeof data['data']['jobvalid'] != 'undefined' && data['data']['jobvalid'] === true) {
\$('#job_incomplete').hide();
\$('.wizard-container .finish').removeClass('disabled');
}
else {
\$('#job_incomplete').show();
\$('.wizard-container .finish').addClass('disabled');
}
}
\$('#job_errormessages').empty();
if (typeof data['data']['errorMessage'] != 'undefined') {
\$('#job_errormessages').append(data['data']['errorMessage']);
}
console.debug('job-form-inline', event, data);
});
\$('.wizard-container').on('wizard:tabShow.jobcontainer', function(e, \$tab, \$nav, index) {
var \$link = \$tab.find('a');
var href = \$link.attr('href');
var \$target = \$(href);
var \$iframe = \$target.find('iframe');
\$iframe.each(function() { this.contentDocument.location.reload(true); });
var \$productList = \$target.find('#product-list-wrapper');
if (\$productList.length) {
\$productList.html('').load('/' + lang + '/jobs/channel-list?id=' + \$('#general-nameForm-job').val());
}
});
\$('.wizard-container .finish a').click(function (e) {
if (\$(e.currentTarget).parent().hasClass('disabled')) {
e.preventDefault();
return false;
}
});
});
JS;
$renderer->headScript()->appendScript($javaScript);
return parent::renderPost($renderer);
}