Note that there are some explanatory texts on larger screens.

plurals
  1. PODrupal: add a js function callback to Drupal.settings
    primarykey
    data
    text
    <p>Im using <code>[drupal_add_js_()][1]</code> function to add a <a href="http://fancybox.net/" rel="nofollow">fancybox</a> effect to some image in my nodes (im not using the Fancybox module becose doesnt fit my needs).</p> <p>In short, i need to add the <code>titleFormat</code> function to format the image title; In my javascript file, it looks like:</p> <pre><code>$("a[rel=myfancy_group]").fancybox({ 'transitionIn': 'elastic', 'transitionOut': 'elastic', 'titlePosition': 'over', 'titleFormat': function(title, currentArray, currentIndex, currentOpts) { return '&lt;span&gt;&lt;b&gt;' + title + '&lt;/b&gt; | Image ' + (currentIndex + 1) + ' of ' + currentArray.length + (title.length ? ' &amp;nbsp; ' + title : '') + '&lt;/span&gt;'; } }); </code></pre> <p>And this is how my <code>drupal_add_js</code> function looks:</p> <pre><code>drupal_add_js( array( 'mycustom_fancybox' =&gt; array( 'selector' =&gt; 'div.field-field-immagini-minigallery a', 'group' =&gt; TRUE, 'options' =&gt; array( 'transitionIn' =&gt; 'elastic', 'transitionOut' =&gt; 'elastic', 'titlePosition' =&gt; 'inside', 'titleShow' =&gt; TRUE, 'width' =&gt; 500, 'cyclic' =&gt; TRUE, 'titleFormat' =&gt; ??? ) ) ), 'setting', 'footer', FALSE, TRUE, TRUE ); </code></pre> <p><strong>EDIT</strong> i've tryed with:</p> <pre><code>//add fancybox settings drupal_add_js( array( 'mycustom_fancybox' =&gt; array( 'selector' =&gt; 'div.field-field-immagini-minigallery a', 'group' =&gt; TRUE, 'options' =&gt; array( 'transitionIn' =&gt; 'elastic', 'transitionOut' =&gt; 'elastic', 'titlePosition' =&gt; 'inside', 'titleShow' =&gt; TRUE, 'width' =&gt; 500, 'cyclic' =&gt; TRUE, 'titleFormat' =&gt; "function my_title_format(title, currentArray, currentIndex, currentOpts) { return '&lt;span&gt;&lt;b&gt;&lt;i&gt;' + title + '&lt;/i&gt;&lt;/b&gt; | Immagine ' + (currentIndex + 1) + ' di ' + currentArray.length + (title.length ? ' &amp;nbsp; ' + title : '') + '&lt;/span&gt;'; }" ) ) ), 'setting', 'footer', FALSE, TRUE, TRUE ); </code></pre> <p>but (as i supposed) Drupal render it like:</p> <pre><code>"function (title, currentArray, currentIndex, currentOpts) { return \'\x3cspan\x3e\x3cb\x3e\x3ci\x3e\' + title + \'\x3c/i\x3e\x3c/b\x3e | Immagine \' + (currentIndex + 1) + \' di \' + currentArray.length + (title.length ? \' \x26nbsp; \' + title : \'\') + \'\x3c/span\x3e\'; }" </code></pre> <p>...and it doesnt work.</p> <p>I tryed </p> <pre><code>drupal_add_js( array( 'mycustom_fancybox' =&gt; array( 'selector' =&gt; 'div.field-field-immagini-minigallery a', 'group' =&gt; TRUE, 'options' =&gt; array( 'transitionIn' =&gt; 'elastic', 'transitionOut' =&gt; 'elastic', 'titlePosition' =&gt; 'inside', 'titleShow' =&gt; TRUE, 'width' =&gt; 500, 'cyclic' =&gt; TRUE, 'titleFormat' =&gt; 'my_title_format' ) ) ), 'setting', 'footer', FALSE, TRUE, TRUE ); //and, in my js file, added: function my_title_format(title, currentArray, currentIndex, currentOpts) { return '&lt;span&gt;&lt;b&gt;&lt;i&gt;' + title + '&lt;/i&gt;&lt;/b&gt; | Immagine ' + (currentIndex + 1) + ' di ' + currentArray.length + (title.length ? ' &amp;nbsp; ' + title : '') + '&lt;/span&gt;'; } </code></pre> <p>But again doestn work.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload