function BotchaRecipeObscureUrl::getJsValue in BOTCHA Spam Prevention 7.2
Same name and namespace in other branches
- 6.2 controller/botcha_recipe.controller.inc \BotchaRecipeObscureUrl::getJsValue()
- 6.3 controller/recipe/botcha.recipe.controller.inc \BotchaRecipeObscureUrl::getJsValue()
- 7.3 controller/recipe/botcha.recipe.controller.inc \BotchaRecipeObscureUrl::getJsValue()
Overrides BotchaRecipeUsingJsAbstract::getJsValue
File
- controller/
botcha_recipe.controller.inc, line 779 - Controller layer of the BotchaRecipe objects.
Class
Code
function getJsValue() {
// Just ensure that parameters are set.
$fields = $this
->getProperty($this->settings['fields'], 'getFields');
$js = $this
->getProperty($this->settings['js'], 'getJs');
$chops_positions = array_keys($js['chops']);
$field2_name = $fields[2]['name'];
$form_id = str_replace('_', '-', $this
->getSetting('form_id'));
$submit = _botcha_url($this
->getSetting('form_action'), array(
'query' => array(
$field2_name => '__replace__',
),
));
// Secure_token.
$submit = preg_replace('/__replace__/', $js['chops'][$chops_positions[0]] . '\'+v+\'' . $js['chops'][$chops_positions[1]], $submit);
return <<<END
(function (\$) {
Drupal.behaviors.{<span class="php-variable">$js</span>[<span class="php-string">'name'</span>]} = {
attach: function (context, settings) {
\$("input.{<span class="php-variable">$fields</span>[<span class="php-constant">1</span>][<span class="php-string">'class'</span>]}").each(function() {
f=\$(this)[0];
if (f.value.indexOf("{<span class="php-variable">$js</span>[<span class="php-string">'match'</span>]}")==0){
v=f.value.substring({<span class="php-variable">$js</span>[<span class="php-string">'pos'</span>]});
\$("#{<span class="php-variable">$form_id</span>}").get(0).setAttribute('action', '{<span class="php-variable">$submit</span>}');
}
});
}
};
}(jQuery));
END;
}