guieditor/editor.js
changeset 1 960c1572df75
parent 0 640e15974415
child 2 307591683f3b
equal deleted inserted replaced
0:640e15974415 1:960c1572df75
    95 									</td> \
    95 									</td> \
    96 									<td valign="top"> \
    96 									<td valign="top"> \
    97 										<input type="text" id="guied_intlink_text" style="width: 100%;" /><br /> \
    97 										<input type="text" id="guied_intlink_text" style="width: 100%;" /><br /> \
    98 										<small>' + $lang.get('guied_intlink_text_hint') + '</small> \
    98 										<small>' + $lang.get('guied_intlink_text_hint') + '</small> \
    99 									</td> \
    99 									</td> \
   100 								</tr>';
   100 								</tr> \
       
   101 							</table>';
   101 					div.innerHTML += '<p style="text-align: right;"> \
   102 					div.innerHTML += '<p style="text-align: right;"> \
   102 									<a class="abutton abutton_blue" onclick="guied_intlink_finish(this); return false;" href="#">' + $lang.get('guied_btn_insert') + '</a> \
   103 									<a class="abutton abutton_blue" onclick="guied_intlink_finish(this); return false;" href="#">' + $lang.get('guied_btn_insert') + '</a> \
   103 									<a class="abutton abutton_red" onclick="miniPromptDestroy(this); return false;" href="#">' + $lang.get('etc_cancel') + '</a> \
   104 									<a class="abutton abutton_red" onclick="miniPromptDestroy(this); return false;" href="#">' + $lang.get('etc_cancel') + '</a> \
   104 								</p>';
   105 								</p>';
   105 				});
   106 				});
   134 									</td> \
   135 									</td> \
   135 									<td valign="top"> \
   136 									<td valign="top"> \
   136 										<input type="text" id="guied_extlink_text" style="width: 100%;" /><br /> \
   137 										<input type="text" id="guied_extlink_text" style="width: 100%;" /><br /> \
   137 										<small>' + $lang.get('guied_extlink_text_hint') + '</small> \
   138 										<small>' + $lang.get('guied_extlink_text_hint') + '</small> \
   138 									</td> \
   139 									</td> \
   139 								</tr>';
   140 								</tr> \
       
   141 							</table>';
   140 					div.innerHTML += '<p style="text-align: right;"> \
   142 					div.innerHTML += '<p style="text-align: right;"> \
   141 									<a class="abutton abutton_blue" onclick="guied_extlink_finish(this); return false;" href="#">' + $lang.get('guied_btn_insert') + '</a> \
   143 									<a class="abutton abutton_blue" onclick="guied_extlink_finish(this); return false;" href="#">' + $lang.get('guied_btn_insert') + '</a> \
   142 									<a class="abutton abutton_red" onclick="miniPromptDestroy(this); return false;" href="#">' + $lang.get('etc_cancel') + '</a> \
   144 									<a class="abutton abutton_red" onclick="miniPromptDestroy(this); return false;" href="#">' + $lang.get('etc_cancel') + '</a> \
   143 								</p>';
   145 								</p>';
   144 				});
   146 				});
   158 								<tr> \
   160 								<tr> \
   159 									<td valign="top" style="white-space: nowrap;"> \
   161 									<td valign="top" style="white-space: nowrap;"> \
   160 									' + $lang.get('guied_image_lbl_image') + ' \
   162 									' + $lang.get('guied_image_lbl_image') + ' \
   161 									</td> \
   163 									</td> \
   162 									<td valign="top"> \
   164 									<td valign="top"> \
   163 										<img id="guied_image_preview" src="' + cdnPath + '/images/spacer.gif" style="display: block;" /> \
   165 										<img id="guied_image_preview" src="' + cdnPath + '/images/spacer.gif" style="display: block;" onerror="this.style.display = \'none\';" /> \
   164 										<input type="text" id="guied_image_file" class="autofill guied_image" style="width: 100%;" onblur="guied_refresh_image();" /><br /> \
   166 										<input type="text" id="guied_image_file" class="autofill guied_image" style="width: 100%;" onblur="guied_refresh_image();" /><br /> \
   165 										<small>' + $lang.get('guied_image_af_hint') + '</small> \
   167 										<small>' + $lang.get('guied_image_af_hint') + '</small> \
   166 										<div id="guied_upload_body" style="padding: 4px 0;"> \
   168 										<div id="guied_upload_body" style="padding: 4px 0;"> \
   167 										<a class="abutton icon abutton_green" style="background-image: url(' + scriptPath + '/plugins/guieditor/icons/add.png);" href="#" onclick="guied_image_show_uploader(); return false;">' + $lang.get('guied_image_btn_upload') + '</a> \
   169 										<a class="abutton icon abutton_green" style="background-image: url(' + scriptPath + '/plugins/guieditor/icons/add.png);" href="#" onclick="guied_image_show_uploader(); return false;">' + $lang.get('guied_image_btn_upload') + '</a> \
   168 										</div> \
   170 										</div> \
   169 									</td> \
   171 									</td> \
   170 								</tr> \
   172 								</tr> \
   171 								<tr> \
   173 								<tr> \
   172 									<td valign="top" style="white-space: nowrap;"> \
   174 									<td valign="top" style="white-space: nowrap;"> \
   173 									' + $lang.get('guied_image_lbl_caption') + ' \
   175 										' + $lang.get('guied_image_lbl_resize') + ' \
       
   176 									</td> \
       
   177 									<td valign="top"> \
       
   178 										<label> \
       
   179 											<input type="checkbox" id="guied_image_resize" onclick="$(\'#guied_image_resizer\').toggle(\'blind\');" /> \
       
   180 											' + $lang.get('guied_image_checkbox_resize') + ' \
       
   181 										</label> \
       
   182 										<div id="guied_image_resizer" style="display: none;"> \
       
   183 											' + $lang.get('guied_image_lbl_dimensions') + ' \
       
   184 											<input type="text" id="guied_image_size_x" size="5" /> x \
       
   185 											<input type="text" id="guied_image_size_y" size="5" /> \
       
   186 											<br /> \
       
   187 											&nbsp;&nbsp;&nbsp; \
       
   188 												' + $lang.get('guied_image_resize_or') + ' \
       
   189 												<label><input type="checkbox" id="guied_image_resize_default" onclick="guied_image_toggle_default();" /> \
       
   190 												' + $lang.get('guied_image_resize_lbl_default') + '</label><br /> \
       
   191 											<small> \
       
   192 												' + $lang.get('guied_image_msg_preserve_aspect') + ' \
       
   193 											</small> \
       
   194 										</div> \
       
   195 									</td> \
       
   196 								</tr> \
       
   197 								<tr> \
       
   198 									<td valign="top" style="white-space: nowrap;"> \
       
   199 										' + $lang.get('guied_image_lbl_mode') + ' \
       
   200 									</td> \
       
   201 									<td valign="top"> \
       
   202 										<form> \
       
   203 										<label> \
       
   204 											<input class="guied_image_mode_radio" onclick="guied_image_set_mode(this.value);" type="radio" name="mode" value="framed" checked="checked" /> \
       
   205 											' + $lang.get('guied_image_lbl_framed') + ' \
       
   206 										</label> \
       
   207 										<label> \
       
   208 											<input class="guied_image_mode_radio" onclick="guied_image_set_mode(this.value);" type="radio" name="mode" value="inline" /> \
       
   209 											' + $lang.get('guied_image_lbl_inline') + ' \
       
   210 										</label> \
       
   211 										<label> \
       
   212 											<input class="guied_image_mode_radio" onclick="guied_image_set_mode(this.value);" type="radio" name="mode" value="raw" /> \
       
   213 											' + $lang.get('guied_image_lbl_raw') + ' \
       
   214 										</label><br /> \
       
   215 										</form> \
       
   216 										<small id="guied_mode_hint">' + $lang.get('guied_image_mode_hint_framed') + '</small> \
       
   217 									</td> \
       
   218 								</tr> \
       
   219 							</table> \
       
   220 							<div class="guied_image_mode framed"> \
       
   221 								<table border="0" cellspacing="5" cellpadding="0" style="width: 100%;"> \
       
   222 								<tr> \
       
   223 									<td valign="top" style="white-space: nowrap;"> \
       
   224 									' + $lang.get('guied_image_framed_lbl_side') + ' \
       
   225 									</td> \
       
   226 									<td valign="top"> \
       
   227 										<form> \
       
   228 										<label> \
       
   229 											<input class="guied_image_side" type="radio" name="side" value="left" checked="checked" /> \
       
   230 											' + $lang.get('guied_image_framed_left') + ' \
       
   231 										</label> \
       
   232 										<label> \
       
   233 											<input class="guied_image_side" type="radio" name="side" value="right" /> \
       
   234 											' + $lang.get('guied_image_framed_right') + ' \
       
   235 										</label> \
       
   236 										</form> \
       
   237 									</td> \
       
   238 								</tr> \
       
   239 								<tr> \
       
   240 									<td valign="top" style="white-space: nowrap;"> \
       
   241 										' + $lang.get('guied_image_lbl_caption') + ' \
   174 									</td> \
   242 									</td> \
   175 									<td valign="top"> \
   243 									<td valign="top"> \
   176 										<input type="text" id="guied_image_caption" style="width: 100%;" /> \
   244 										<input type="text" id="guied_image_caption" style="width: 100%;" /> \
   177 									</td> \
   245 									</td> \
   178 								</tr>';
   246 								</tr> \
       
   247 								</table> \
       
   248 							</div> \
       
   249 							<div class="guied_image_mode inline" style="display: none;"> \
       
   250 								<table border="0" cellspacing="5" cellpadding="0" style="width: 100%;"> \
       
   251 								<tr> \
       
   252 									<td valign="top" style="white-space: nowrap;"> \
       
   253 										' + $lang.get('guied_image_lbl_alttext') + ' \
       
   254 									</td> \
       
   255 									<td valign="top"> \
       
   256 										<input type="text" id="guied_image_alttext" style="width: 100%;" /> \
       
   257 									</td> \
       
   258 								</tr> \
       
   259 								</table> \
       
   260 							</div> \
       
   261 							<div class="guied_image_mode raw" style="display: none;"> \
       
   262 								' + $lang.get('guied_image_raw_msg_noopt') + ' \
       
   263 							</div>';
   179 					div.innerHTML += '<p style="text-align: right;"> \
   264 					div.innerHTML += '<p style="text-align: right;"> \
   180 									<a class="abutton abutton_blue" onclick="guied_image_finish(this); return false;" href="#">' + $lang.get('guied_btn_insert') + '</a> \
   265 									<a class="abutton abutton_blue" onclick="guied_image_finish(this); return false;" href="#">' + $lang.get('guied_btn_insert') + '</a> \
   181 									<a class="abutton abutton_red" onclick="miniPromptDestroy(this); return false;" href="#">' + $lang.get('etc_cancel') + '</a> \
   266 									<a class="abutton abutton_red" onclick="miniPromptDestroy(this); return false;" href="#">' + $lang.get('etc_cancel') + '</a> \
   182 								</p>';
   267 								</p>';
   183 				});
   268 				});
   190 			$('#guied_image_caption').val(selection);
   275 			$('#guied_image_caption').val(selection);
   191 			
   276 			
   192 			break;
   277 			break;
   193 		
   278 		
   194 	}
   279 	}
       
   280 	/*
       
   281 	
       
   282 										*/
   195 }
   283 }
   196 
   284 
   197 function guied_intlink_finish(insertbtn)
   285 function guied_intlink_finish(insertbtn)
   198 {
   286 {
   199 	var page = $('#guied_intlink_page').val();
   287 	var page = $('#guied_intlink_page').val();
   242 	return true;
   330 	return true;
   243 }
   331 }
   244 
   332 
   245 function guied_refresh_image()
   333 function guied_refresh_image()
   246 {
   334 {
   247 	$('#guied_image_preview').attr('src', makeUrlNS('Special', 'DownloadFile/' + $('#guied_image_file').val(), 'preview&width=200&height=400')).css('margin-bottom', '5px');
   335 	$('#guied_image_preview').css('display', 'block').attr('src', makeUrlNS('Special', 'DownloadFile/' + $('#guied_image_file').val(), 'preview&width=200&height=400')).css('margin-bottom', '5px');
   248 }
   336 }
   249 
   337 
   250 function guied_image_finish()
   338 function guied_image_toggle_default()
   251 {
   339 {
   252 	// yeah... working on this.
   340 	if ( $('#guied_image_resize_default:checked').length )
       
   341 	{
       
   342 		$('#guied_image_size_x, #guied_image_size_y').attr('disabled', 'disabled');
       
   343 	}
       
   344 	else
       
   345 	{
       
   346 		$('#guied_image_size_x, #guied_image_size_y').removeAttr('disabled');
       
   347 	}
       
   348 }
       
   349 
       
   350 function guied_image_set_mode(val)
       
   351 {
       
   352 	$('#guied_mode_hint').text($lang.get('guied_image_mode_hint_' + val));
       
   353 	$('.guied_image_mode').hide();
       
   354 	$('.guied_image_mode.' + val).show();
       
   355 }
       
   356 
       
   357 function guied_image_finish(insertbtn)
       
   358 {
       
   359 	var attrs = [];
       
   360 	var filename = $('#guied_image_file').val();
       
   361 	attrs.push(':' + namespace_list.File + filename);
       
   362 	if ( $('#guied_image_resize:checked').length )
       
   363 	{
       
   364 		if ( $('#guied_image_resize_default:checked').length )
       
   365 			attrs.push('thumb');
       
   366 		else
       
   367 			attrs.push($('#guied_image_size_x').val() + 'x' + $('#guied_image_size_y'));
       
   368 	}
       
   369 	var caption = '';
       
   370 	switch($('.guied_image_mode_radio:checked').val())
       
   371 	{
       
   372 		case 'framed':
       
   373 			attrs.push($('.guied_image_side:checked').val());
       
   374 			caption = $('#guied_image_caption').val();
       
   375 			break;
       
   376 		case 'inline':
       
   377 			caption = $('#guied_image_alttext').val();
       
   378 			break;
       
   379 	}
       
   380 	if ( caption != '' )
       
   381 		attrs.push(caption);
       
   382 	
       
   383 	var tag = '[[' + implode('|', attrs) + ']]';
       
   384 	
       
   385 	guied_replace_selection(document.getElementById('ajaxEditArea'), tag);
       
   386 	miniPromptDestroy(insertbtn);
   253 }
   387 }
   254 
   388 
   255 // Client detection from MediaWiki
   389 // Client detection from MediaWiki
   256 var clientPC = navigator.userAgent.toLowerCase(); // Get client info
   390 var clientPC = navigator.userAgent.toLowerCase(); // Get client info
   257 var is_gecko = ((clientPC.indexOf('gecko')!=-1) && (clientPC.indexOf('spoofer')==-1)
   391 var is_gecko = ((clientPC.indexOf('gecko')!=-1) && (clientPC.indexOf('spoofer')==-1)