@@ -29,7 +29,10 @@ WYMeditor.editor.prototype.image_upload = function() {
29
29
orig . call ( this , wDialog ) ;
30
30
var wym = this ,
31
31
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 ) ) ;
33
36
34
37
var oldSubmitLabel = jQuery ( "form#image_upload_form .submit" , doc ) . val ( ) ;
35
38
// WYMEditor automatically locks onto any form here, so remove the binding.
@@ -47,12 +50,40 @@ WYMeditor.editor.prototype.image_upload = function() {
47
50
} else {
48
51
jQuery ( options . srcSelector , doc ) . val ( response . thumbUrl ) ;
49
52
jQuery ( options . altSelector , doc ) . val ( response . original_filename ) ;
53
+ jQuery ( options . attributionSelector , doc ) . val ( response . attribution ) ;
50
54
}
51
55
jQuery ( "form#image_upload_form .submit" , doc ) . val ( oldSubmitLabel ) ;
52
56
}
53
57
} )
54
58
} ;
55
59
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
+
56
87
// Put together the whole dialog script
57
88
wym . _options . dialogImageHtml = String ( ) +
58
89
'<body class="wym_dialog wym_dialog_image">' +
@@ -95,6 +126,10 @@ WYMeditor.editor.prototype.image_upload = function() {
95
126
'<label>{Title}</label>' +
96
127
'<input type="text" class="wym_title" value="" size="40" />' +
97
128
'</div>' +
129
+ '<div class="row">' +
130
+ '<label>{Attribution}</label>' +
131
+ '<input type="text" class="wym_attribution" value="" size="40" placeholder="{Attribution_placeholder}" />' +
132
+ '</div>' +
98
133
'<div class="row row-indent">' +
99
134
'<input class="wym_submit" type="submit" ' + 'value="{Submit}" />' +
100
135
'<input class="wym_cancel" type="button" ' + 'value="{Cancel}" />' +
0 commit comments