diff -upr insert/insert.js insert/insert.js
--- insert/insert.js 2010-07-27 06:46:18.000000000 +0200
+++ insert/insert.js 2010-08-24 12:12:29.000000000 +0200
@@ -16,6 +16,28 @@ Drupal.behaviors.insert = function(conte
// Add the click handler to the insert button.
$('.insert-button', context).unbind('click').click(insert);
+ $(".display-style-select").hide();
+ $(".target-style-select").hide();
+
+ $(".insert-style").change(function() {
+ wrapper = $(this).parent(2);
+ if ( $(this).val() == "link"){
+ wrapper.siblings(".display-style-select").show();
+ wrapper.siblings(".target-style-select").show();
+ } else {
+ wrapper.siblings(".display-style-select").hide();
+ wrapper.siblings(".target-style-select").hide();
+ }
+ });
+
+ $(".insert-style").each(function(index) {
+ if ($(this).val() == "link") {
+ wrapper = $(this).parent(2);
+ wrapper.siblings(".display-style-select").show();
+ wrapper.siblings(".target-style-select").show();
+ }
+ });
+
function insertSetActive() {
insertTextarea = this;
this.insertHasFocus = true;
@@ -37,32 +59,45 @@ Drupal.behaviors.insert = function(conte
var style = $('.insert-style', wrapper).val();
var content = $('input.insert-template[name$="[' + style + ']"]', wrapper).val();
+ var display_style = $('.display-style', wrapper).val();
+ var display_content = $('input.insert-template[name$="[' + display_style + ']"]', wrapper).val();
+ var target_style = $('.target-style', wrapper).val();
+ var target_content = $('input.insert-template[name$="[' + target_style + ']"]', wrapper).val();
+
// Update replacements.
for (var fieldName in settings.fields) {
var fieldValue = $(settings.fields[fieldName], wrapper).val();
var fieldRegExp = new RegExp('__' + fieldName + '__', 'g');
if (fieldValue) {
content = content.replace(fieldRegExp, fieldValue);
+ display_content = display_content.replace(fieldRegExp, fieldValue);
+ target_content = target_content.replace(fieldRegExp, fieldValue);
}
}
// Cleanup unused replacements.
content = content.replace(/__([a-z0-9_]+)__/g, '');
+ display_content = display_content.replace(/__([a-z0-9_]+)__/g, '');
+ target_content = target_content.replace(/__([a-z0-9_]+)__/g, '');
// Check for a maximum dimension and scale down the width if necessary.
// This is intended for use with Image Resize Filter.
- var widthMatches = content.match(/width[ ]*=[ ]*"(\d*)"/i);
- var heightMatches = content.match(/height[ ]*=[ ]*"(\d*)"/i);
+ var widthMatches = display_content.match(/width[ ]*=[ ]*"(\d*)"/i);
+ var heightMatches = display_content.match(/height[ ]*=[ ]*"(\d*)"/i);
if (settings.maxWidth && widthMatches && parseInt(widthMatches[1]) > settings.maxWidth) {
var insertRatio = settings.maxWidth / widthMatches[1];
var width = settings.maxWidth;
- content = content.replace(/width[ ]*=[ ]*"?(\d*)"?/i, 'width="' + width + '"');
+ display_content = display_content.replace(/width[ ]*=[ ]*"?(\d*)"?/i, 'width="' + width + '"');
if (heightMatches) {
var height = Math.round(heightMatches[1] * insertRatio);
- content = content.replace(/height[ ]*=[ ]*"?(\d*)"?/i, 'height="' + height + '"');
+ display_content = display_content.replace(/height[ ]*=[ ]*"?(\d*)"?/i, 'height="' + height + '"');
}
}
+ target_content = target_content.replace(/.*src[ ]*=[ ]*"([^"]*)".*/i, '$1');
+ content = content.replace(/@target_preset/i, target_content);
+ content = content.replace(/@display_preset/i, display_content);
+
// Insert the text.
Drupal.insert.insertIntoActiveEditor(content);
}
@@ -178,4 +213,5 @@ Drupal.insert = {
}
};
+
})(jQuery);
diff -upr insert/insert.module insert/insert.module
--- insert/insert.module 2010-08-07 20:45:25.000000000 +0200
+++ insert/insert.module 2010-08-24 11:22:57.000000000 +0200
@@ -205,9 +205,17 @@ function insert_element_process($element
if ($element['fid']['#value']) {
$insert_styles = array_filter((array) $widget_settings['insert_styles']);
$default = !empty($widget_settings['insert_default']) ? $widget_settings['insert_default'] : 'auto';
+ $default_display = !empty($widget_settings['insert_default_display']) ? $widget_settings['insert_default_display'] : 'auto';
+ $default_target = !empty($widget_settings['insert_default_target']) ? $widget_settings['insert_default_target'] : 'auto';
if (!isset($insert_styles[$default])) {
$insert_styles[$default] = $default;
}
+ if (!isset($insert_styles[$default_display])) {
+ $insert_styles[$default_display] = $default_display;
+ }
+ if (!isset($insert_styles[$default_target])) {
+ $insert_styles[$default_target] = $default_target;
+ }
foreach ($insert_styles as $style_name => $enabled) {
if ($enabled && ($style = insert_style_load($style_name))) {
$element['insert_templates'][$style_name] = array(
@@ -221,13 +229,20 @@ function insert_element_process($element
}
}
+ $style_options2 = $style_options;
+ unset($style_options2['link']);
+
$element['insert'] = array(
'#theme' => 'insert_widget',
'#type' => 'markup',
'#options' => $style_options,
+ '#display_options' => $style_options2,
+ '#target_options' => $style_options2,
'#widget' => $field['widget'],
'#weight' => -1,
'#default_value' => $default,
+ '#default_display_value' => $default_display,
+ '#default_target_value' => $default_target,
);
}
@@ -263,6 +278,8 @@ function insert_widget_settings() {
'insert',
'insert_styles',
'insert_default',
+ 'insert_default_display',
+ 'insert_default_target',
'insert_class',
'insert_width',
);
@@ -304,6 +321,20 @@ function insert_widget_form($widget) {
'#default_value' => (array) $widget['insert_default'],
'#description' => t('Select the default style which will be selected by default or used if no specific styles above are enabled.'),
);
+ $form['insert']['insert_default_display'] = array(
+ '#title' => t('Default display insert style'),
+ '#type' => 'select',
+ '#options' => insert_styles_list(),
+ '#default_value' => (array) $widget['insert_default_display'],
+ '#description' => t('Select the default display style which will be selected by default or used if no specific styles above are enabled.'),
+ );
+ $form['insert']['insert_default_target'] = array(
+ '#title' => t('Default target insert style'),
+ '#type' => 'select',
+ '#options' => insert_styles_list(),
+ '#default_value' => (array) $widget['insert_default_target'],
+ '#description' => t('Select the default target style which will be selected by default or used if no specific styles above are enabled.'),
+ );
$form['insert']['insert_class'] = array(
'#title' => t('Additional CSS classes'),
@@ -365,7 +396,11 @@ function insert_create_url($path) {
function template_preprocess_insert_widget(&$vars) {
$element = $vars['element'];
+ $vars['display_styles'] = $element['#display_options'];
+ $vars['target_styles'] = $element['#target_options'];
$vars['insert_styles'] = $element['#options'];
$vars['default_style'] = $element['#default_value'];
+ $vars['default_display_style'] = $element['#default_display_value'];
+ $vars['default_target_style'] = $element['#default_target_value'];
$vars['widget_type'] = $element['#widget']['type'];
}
diff -upr insert/templates/imagecache-insert-image.tpl.php insert/templates/imagecache-insert-image.tpl.php
--- insert/templates/imagecache-insert-image.tpl.php 2009-10-21 08:23:43.000000000 +0200
+++ insert/templates/imagecache-insert-image.tpl.php 2010-08-24 01:21:33.000000000 +0200
@@ -21,4 +21,4 @@
* - __description__: A description of the image, sometimes used as a caption.
*/
?>
-
\ No newline at end of file
+
diff -upr insert/templates/insert-link.tpl.php insert/templates/insert-link.tpl.php
--- insert/templates/insert-link.tpl.php 2009-10-21 08:23:43.000000000 +0200
+++ insert/templates/insert-link.tpl.php 2010-08-24 02:20:05.000000000 +0200
@@ -19,4 +19,4 @@
* - __description__: A description of the item.
*/
?>
- title="__description__">
\ No newline at end of file
+ title="__description__">@display_preset
diff -upr insert/templates/insert-widget.tpl.php insert/templates/insert-widget.tpl.php
--- insert/templates/insert-widget.tpl.php 2009-10-21 08:23:43.000000000 +0200
+++ insert/templates/insert-widget.tpl.php 2010-08-24 03:22:24.000000000 +0200
@@ -20,8 +20,26 @@
+