/** * @file * JavaScript integrations between the Caption Filter module and particular * WYSIWYG editors. This file also implements Insert module hooks to respond * to the insertion of content into a WYSIWYG or textarea. */ (function ($) { $(document).bind('insertIntoActiveEditor', function(event, options) { if (options['fields']['title'] && Drupal.settings.captionFilter.widgets[options['widgetType']]) { options['content'] = '[caption caption="' + options['fields']['title'].replace(/"/g, '\\"') + '"]' + options['content'] + '[/caption]'; } }); Drupal.captionFilter = Drupal.captionFilter || {}; Drupal.captionFilter.toHTML = function(co, editor) { return co.replace(/(?:
)?\[caption([^\]]*)\]([\s\S]+?)\[\/caption\](?:<\/p>)?[\s\u00a0]*/g, function(a,b,c){ var id, cls, w, tempClass; b = b.replace(/\\?'|\\'|\\'/g, ''').replace(/\\"|\\"/g, '"'); c = c.replace(/\\'|\\'/g, ''').replace(/\\"/g, '"'); id = b.match(/id=['"]([^'"]+)/i); cls = b.match(/align=['"]([^'"]+)/i); ct = b.match(/caption=['"]([^'"]+)/i); w = c.match(/width=['"]([0-9]+)/); id = ( id && id[1] ) ? id[1] : ''; cls = ( cls && cls[1] ) ? 'caption-' + cls[1] : ''; ct = ( ct && ct[1] ) ? ct[1].replace(/\\\\"/,'"') : ''; w = ( w && w[1] ) ? parseInt(w[1])+'px' : 'auto'; if (editor == 'tinymce') tempClass = (cls == 'caption-center') ? 'mceTemp mceIEcenter' : 'mceTemp'; else if (editor == 'ckeditor') tempClass = (cls == 'caption-center') ? 'mceTemp mceIEcenter' : 'mceTemp'; else tempClass = ''; if (ct) { return '