Skip to content

Commit a51aefc

Browse files
committed
added option to customize getTitle() function
I have removed function from fancybox.php, added new field in options 'calls' tab, and set current getTitle() function as default.
1 parent 9b7479f commit a51aefc

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

fancybox.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ function mfbfw_defaults() {
117117
'callbackOnComplete' => 'function() { alert("Complete!"); }',
118118
'callbackOnCleanup' => 'function() { alert("CleanUp!"); }',
119119
'callbackOnClose' => 'function() { alert("Close!"); }',
120+
'copyTitleFunction' => 'var arr = jQuery("a.fancybox");
121+
jQuery.each(arr, function() {
122+
var title = jQuery(this).children("img").attr("title");
123+
jQuery(this).attr("title",title);
124+
})',
120125

121126
// Troubleshooting
122127
'nojQuery' => '',
@@ -231,12 +236,9 @@ function mfbfw_init() {
231236
<script type="text/javascript">
232237
jQuery(function(){
233238
234-
jQuery.fn.getTitle = function() { // Copy the title of every IMG tag and add it to its parent A so that fancybox can show titles
235-
var arr = jQuery("a.fancybox");
236-
jQuery.each(arr, function() {
237-
var title = jQuery(this).children("img").attr("title");
238-
jQuery(this).attr("title",title);
239-
})
239+
jQuery.fn.getTitle = function() { // Copy the title of every IMG tag and add it to its parent A so that fancybox can show titles';
240+
<?php echo $settings['copyTitleFunction']; ?>
241+
echo '
240242
}
241243

242244
// Supported file extensions

lib/admin-tab-other.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@
8585
<?php _e('Callback on <strong>Closed</strong> event: Will be called once FancyBox is closed', 'mfbfw'); ?>
8686
<textarea rows="10" cols="50" class="large-text code" name="mfbfw[callbackOnClose]" wrap="physical" id="callbackOnClosed"><?php echo ($mfbfw['callbackOnClose']); ?></textarea>
8787
</label><br /><br/>
88+
89+
<label for="copyTitleFunction">
90+
<?php _e('Function to copy title from different source then Fancybox default anchor title', 'mfbfw'); ?>
91+
<textarea rows="10" cols="50" class="large-text code" name="mfbfw[copyTitleFunction]" wrap="physical" id="copyTitleFunction"><?php echo ($settings['copyTitleFunction']); ?></textarea>
92+
</label><br /><br/>
8893

8994
<small><strong><em><?php _e('Example:', 'mfbfw'); ?></em></strong></small><br />
9095
<small><em><code>function() { alert('Hello world!'); }</code></em></small><br />

0 commit comments

Comments
 (0)