Skip to content

Commit 7d206a8

Browse files
wymeditor: Adds attribution to image dialog
Fixes #119
1 parent 9ea64ad commit 7d206a8

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

system/wymeditor/lang/en.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ WYMeditor.STRINGS.en = {
2828
Title: 'Title',
2929
Relationship: 'Relationship',
3030
Alternative_Text: 'Alternative text',
31+
Attribution: 'Attribution',
32+
Attribution_placeholder: 'cc: author (date)',
3133
Caption: 'Caption',
3234
Summary: 'Summary',
3335
Number_Of_Rows: 'Number of rows',

system/wymeditor/lang/nl.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ WYMeditor.STRINGS.nl = {
2828
Title: 'Titel',
2929
Relationship: 'Relatie',
3030
Alternative_Text: 'Alternatieve tekst',
31+
Attribution: 'Bijdrage',
32+
Attribution_placeholder: 'cc: auteur (datum)',
3133
Caption: 'Bijschrift',
3234
Summary: 'Summary',
3335
Number_Of_Rows: 'Aantal rijen',
@@ -53,4 +55,4 @@ WYMeditor.STRINGS.nl = {
5355
File: 'File',
5456

5557
Preset: 'Preset',
56-
};
58+
};

system/wymeditor/plugins/image_upload/jquery.wymeditor.image_upload.js

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ WYMeditor.editor.prototype.image_upload = function() {
2929
orig.call(this, wDialog);
3030
var wym = this,
3131
doc = wDialog.document,
32-
options = wym._options;
32+
options = wym._options,
33+
selectedImage = wym.getSelectedImage();
34+
35+
jQuery(options.attributionSelector, doc).val(jQuery(selectedImage).attr(options.attributionImgAttribute));
3336

3437
var oldSubmitLabel = jQuery("form#image_upload_form .submit", doc).val();
3538
// WYMEditor automatically locks onto any form here, so remove the binding.
@@ -47,12 +50,40 @@ WYMeditor.editor.prototype.image_upload = function() {
4750
} else {
4851
jQuery(options.srcSelector, doc).val(response.thumbUrl);
4952
jQuery(options.altSelector, doc).val(response.original_filename);
53+
jQuery(options.attributionSelector, doc).val(response.attribution);
5054
}
5155
jQuery("form#image_upload_form .submit", doc).val(oldSubmitLabel);
5256
}
5357
})
5458
};
5559

60+
d.submitHandler = function (wDialog) {
61+
var wym = this,
62+
options = wym._options,
63+
imgAttrs,
64+
selectedImage = wym.getSelectedImage();
65+
66+
imgAttrs = {
67+
src: jQuery(options.srcSelector, wDialog.document).val(),
68+
title: jQuery(options.titleSelector, wDialog.document).val(),
69+
alt: jQuery(options.altSelector, wDialog.document).val(),
70+
};
71+
imgAttrs[options.attributionImgAttribute] = jQuery(options.attributionSelector, wDialog.document).val();
72+
73+
wym.focusOnDocument();
74+
75+
if (selectedImage) {
76+
wym._updateImageAttrs(selectedImage, imgAttrs);
77+
wym.registerModification();
78+
} else {
79+
wym.insertImage(imgAttrs);
80+
}
81+
wDialog.close();
82+
}
83+
84+
wym._options.attributionImgAttribute = 'data-attribution';
85+
wym._options.attributionSelector = '.wym_attribution';
86+
5687
// Put together the whole dialog script
5788
wym._options.dialogImageHtml = String() +
5889
'<body class="wym_dialog wym_dialog_image">' +
@@ -95,6 +126,10 @@ WYMeditor.editor.prototype.image_upload = function() {
95126
'<label>{Title}</label>' +
96127
'<input type="text" class="wym_title" value="" size="40" />' +
97128
'</div>' +
129+
'<div class="row">' +
130+
'<label>{Attribution}</label>' +
131+
'<input type="text" class="wym_attribution" value="" size="40" placeholder="{Attribution_placeholder}" />' +
132+
'</div>' +
98133
'<div class="row row-indent">' +
99134
'<input class="wym_submit" type="submit" ' + 'value="{Submit}" />' +
100135
'<input class="wym_cancel" type="button" ' + 'value="{Cancel}" />' +

0 commit comments

Comments
 (0)