@@ -18,7 +18,6 @@ var enhancedEditor = {
18
18
$ ( '[id^="enhancedEditor"]' ) . not ( '#sox-settings-dialog input' ) . remove ( ) ;
19
19
var s = '#' + wmd ; //s is the selector we pass onto each function so the action is applied to the correct textarea (and not, for example the 'add answer' textarea *and* the 'edit' textarea!)
20
20
enhancedEditor . startInsertLink ( s ) ;
21
- enhancedEditor . startInsertImages ( s ) ;
22
21
enhancedEditor . betterTabKey ( s ) ;
23
22
enhancedEditor . keyboardShortcuts ( s ) ;
24
23
@@ -102,53 +101,6 @@ var enhancedEditor = {
102
101
} , 3000 ) ;
103
102
} ,
104
103
105
- startInsertImages : function ( s ) {
106
- var imagesDiv = "<div id='enhancedEditor-insertImageDialog' class='wmd-prompt-dialog enhancedEditor-centered' style='position:fixed; display:none;'> \
107
- <span class='enhancedEditor-closeDialog'>x</span>\
108
- <h2>Insert image</h2>\
109
- <div class='addImage'>\
110
- <div class='addOwnImage-container'>Select file:\
111
- <input class='ownImage' type='file' />\
112
- <input class='go' id='ownGoImage' type='button' value='insert' />\
113
- <label class='enhancedEditor-asLinkContainer'><input type='checkbox' id='enhancedEditor-imageAsLink'>Insert smaller image with link to bigger?</label>\
114
- </div>\
115
- <br>\
116
- <hr class='or'>\
117
- <div class='addLinkImage-container'>Enter URL:\
118
- <input class='URLImage' type='url' value='http://' />\
119
- <input class='go' id='goImage' type='button' value='insert' />\
120
- <label class='enhancedEditor-asLinkContainer'><input type='checkbox' id='enhancedEditor-imageAsLink'>Insert smaller image with link to bigger?</label>\
121
- </div>\
122
- </div>\
123
- </div>" ;
124
- $ ( 'body' ) . append ( imagesDiv ) ;
125
-
126
- setTimeout ( function ( ) {
127
- $ ( '#wmd-image-button > span' ) . click ( function ( e ) {
128
- $ ( '#enhancedEditor-insertImageDialog' ) . show ( 500 ) ;
129
- setTimeout ( function ( ) {
130
- query = $ ( s ) . getSelection ( ) ;
131
-
132
- $ ( '#ownGoImage' ) . click ( function ( ) {
133
- $check = $ ( this ) . next ( ) ;
134
- enhancedEditor . uploadToImgur ( 'file' , $ ( this ) . prev ( ) , function ( url ) {
135
- enhancedEditor . addImageLink ( query , url , $check , s ) ;
136
- } ) ;
137
- } ) ;
138
- $ ( '#goImage' ) . click ( function ( ) {
139
- $check = $ ( this ) . next ( ) ;
140
- enhancedEditor . uploadToImgur ( 'url' , $ ( this ) . prev ( ) , function ( url ) {
141
- enhancedEditor . addImageLink ( query , url , $check , s ) ;
142
- } ) ;
143
- } ) ;
144
- } , 1000 ) ;
145
- e . stopPropagation ( ) ;
146
- e . preventDefault ( ) ;
147
- return false ;
148
- } ) ;
149
- } , 3000 ) ;
150
- } ,
151
-
152
104
betterTabKey : function ( s ) {
153
105
$ ( s ) . on ( 'keydown' , function ( e ) {
154
106
if ( e . which === 9 ) { //http://stackoverflow.com/a/25430815/3541881
@@ -284,43 +236,6 @@ var enhancedEditor = {
284
236
} ) ;
285
237
} ,
286
238
287
- uploadToImgur : function ( type , $fileData , callback ) {
288
- var formData = new FormData ( ) ,
289
- data = '' ;
290
- if ( type == 'file' ) {
291
- formData . append ( "image" , $fileData [ 0 ] . files [ 0 ] ) ;
292
- } else {
293
- data = $fileData . val ( ) ;
294
- }
295
-
296
- $ . ajax ( {
297
- url : "https://api.imgur.com/3/image" ,
298
- type : "POST" ,
299
- headers : {
300
- 'Authorization' : 'Client-ID 1ebf24e58286774'
301
- } ,
302
- data : ( type == 'file' ? formData : data ) ,
303
- success : function ( response ) {
304
- callback ( response . data . link ) ;
305
- } ,
306
- processData : false ,
307
- contentType : false
308
- } ) ;
309
-
310
- } ,
311
-
312
- addImageLink : function ( query , url , $check , s ) {
313
- if ( $check . find ( 'input' ) . is ( ':checked' ) ) {
314
- urlsplit = url . split ( '/' ) [ 3 ] . split ( '.' ) ;
315
- urlToUse = 'http://i.imgur.com/' + urlsplit [ 0 ] + 'm.' + urlsplit [ 1 ] ;
316
- $ ( s ) . replaceSelectedText ( '[](' + url + ')\n\n<sub>click image for larger variant</sub>' ) ;
317
- } else {
318
- $ ( s ) . replaceSelectedText ( '' ) ;
319
- }
320
- $ ( '#enhancedEditor-insertImageDialog' ) . hide ( ) ;
321
- enhancedEditor . refreshPreview ( ) ;
322
- } ,
323
-
324
239
refreshPreview : function ( ) {
325
240
SOHelper . StackExchange ( ) . MarkdownEditor . refreshAllPreviews ( ) ;
326
241
}
0 commit comments