本文整理汇总了PHP中phpQuery::callbackRun方法的典型用法代码示例。如果您正苦于以下问题:PHP phpQuery::callbackRun方法的具体用法?PHP phpQuery::callbackRun怎么用?PHP phpQuery::callbackRun使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类phpQuery
的用法示例。
在下文中一共展示了phpQuery::callbackRun方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: script
/**
* Enter description here...
*
* @param phpQueryObject $self
*/
public static function script($self, $arg1)
{
$params = func_get_args();
$params = array_slice($params, 2);
$return = null;
$config = self::$config;
if (phpQueryPlugin_Scripts::$scriptMethods[$arg1]) {
phpQuery::callbackRun(phpQueryPlugin_Scripts::$scriptMethods[$arg1], array($self, $params, &$return, $config));
} elseif ($arg1 != '__config' && file_exists(dirname(__FILE__) . "/Scripts/{$arg1}.php")) {
phpQuery::debug("Loading script '{$arg1}'");
require dirname(__FILE__) . "/Scripts/{$arg1}.php";
} else {
phpQuery::debug("Requested script '{$arg1}' doesn't exist");
}
return $return ? $return : $self;
}
示例2: trigger
/**
* Trigger a type of event on every matched element.
*
* @param DOMNode|phpQueryObject|string $document
* @param unknown_type $type
* @param unknown_type $data
*
* @TODO exclusive events (with !)
* @TODO global events (test)
* @TODO support more than event in $type (space-separated)
*/
public static function trigger($document, $type, $data = array(), $node = null)
{
// trigger: function(type, data, elem, donative, extra) {
$documentID = phpQuery::getDocumentID($document);
$namespace = null;
if (strpos($type, '.') !== false) {
list($name, $namespace) = explode('.', $type);
} else {
$name = $type;
}
if (!$node) {
if (self::issetGlobal($documentID, $type)) {
$pq = phpQuery::getDocument($documentID);
// TODO check add($pq->document)
$pq->find('*')->add($pq->document)->trigger($type, $data);
}
} else {
if (isset($data[0]) && $data[0] instanceof DOMEvent) {
$event = $data[0];
$event->relatedTarget = $event->target;
$event->target = $node;
$data = array_slice($data, 1);
} else {
$event = new DOMEvent(array('type' => $type, 'target' => $node, 'timeStamp' => time()));
}
$i = 0;
while ($node) {
// TODO whois
phpQuery::debug("Triggering " . ($i ? "bubbled " : '') . "event '{$type}' on " . "node \n");
//.phpQueryObject::whois($node)."\n");
$event->currentTarget = $node;
$eventNode = self::getNode($documentID, $node);
if (isset($eventNode->eventHandlers)) {
foreach ($eventNode->eventHandlers as $eventType => $handlers) {
$eventNamespace = null;
if (strpos($type, '.') !== false) {
list($eventName, $eventNamespace) = explode('.', $eventType);
} else {
$eventName = $eventType;
}
if ($name != $eventName) {
continue;
}
if ($namespace && $eventNamespace && $namespace != $eventNamespace) {
continue;
}
foreach ($handlers as $handler) {
phpQuery::debug("Calling event handler\n");
$event->data = $handler['data'] ? $handler['data'] : null;
$params = array_merge(array($event), $data);
$return = phpQuery::callbackRun($handler['callback'], $params);
if ($return === false) {
$event->bubbles = false;
}
}
}
}
// to bubble or not to bubble...
if (!$event->bubbles) {
break;
}
$node = $node->parentNode;
$i++;
}
}
}
示例3: callback
/**
* Run callback on actual object.
*
* @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery
*/
public function callback($callback, $param1 = null, $param2 = null, $param3 = null)
{
$params = func_get_args();
$params[0] = $this;
phpQuery::callbackRun($callback, $params);
return $this;
}
示例4: map
/**
*
* @link http://docs.jquery.com/Utilities/jQuery.map
*/
public static function map($array, $callback, $param1 = null, $param2 = null, $param3 = null)
{
$result = array();
$paramStructure = null;
if (func_num_args() > 2) {
$paramStructure = func_get_args();
$paramStructure = array_slice($paramStructure, 2);
}
foreach ($array as $v) {
$vv = phpQuery::callbackRun($callback, array($v), $paramStructure);
// $callbackArgs = $args;
// foreach($args as $i => $arg) {
// $callbackArgs[$i] = $arg instanceof CallbackParam
// ? $v
// : $arg;
// }
// $vv = call_user_func_array($callback, $callbackArgs);
if (is_array($vv)) {
foreach ($vv as $vvv) {
$result[] = $vvv;
}
} else {
if ($vv !== null) {
$result[] = $vv;
}
}
}
return $result;
}
示例5: handleSubmit
/**
* Enter description here...
*
* @param unknown_type $e
* @TODO trigger submit for form after form's submit button has a click event
*/
public static function handleSubmit($e, $callback = null)
{
$node = phpQuery::pq($e->target);
if (!$node->is('form') || !$node->is('[action]')) {
return;
}
// TODO document.location
$xhr = isset($node->document->xhr) ? $node->document->xhr : null;
$submit = pq($e->relatedTarget)->is(':submit') ? $e->relatedTarget : $node->find('*:submit:first')->get(0);
$data = array();
foreach ($node->serializeArray($submit) as $r) {
// XXXt.c maybe $node->not(':submit')->add($sumit) would be better ?
// foreach($node->serializeArray($submit) as $r)
$data[$r['name']] = $r['value'];
}
$options = array('type' => $node->attr('method') ? $node->attr('method') : 'GET', 'url' => resolve_url($e->data[0], $node->attr('action')), 'data' => $data, 'referer' => $node->document->location);
if ($node->attr('enctype')) {
$options['contentType'] = $node->attr('enctype');
}
$xhr = phpQuery::ajax($options, $xhr);
if ((!$callback || !$callback instanceof Callback) && $e->data[1]) {
$callback = $e->data[1];
}
if ($xhr->getLastResponse()->isSuccessful() && $callback) {
phpQuery::callbackRun($callback, array(self::browserReceive($xhr)));
}
}