guieditor/editor.js
changeset 5 28ef73d2e7e8
parent 3 1e6929f9978b
child 6 7398bdc17604
equal deleted inserted replaced
4:f8d8b3ef32e0 5:28ef73d2e7e8
    14 		});
    14 		});
    15 	
    15 	
    16 	toolbar += head.run();
    16 	toolbar += head.run();
    17 	
    17 	
    18 	var buttons = ['heading', '|', 'bold*', 'italic*', 'underline*', '|', 'intlink', 'extlink', 'image*', 'table*', '|', 'ulist*', 'olist*', '|', 'signature'];
    18 	var buttons = ['heading', '|', 'bold*', 'italic*', 'underline*', '|', 'intlink', 'extlink', 'image*', 'table*', '|', 'ulist*', 'olist*', '|', 'signature'];
       
    19 	// if new images are to be added, run sprite.sh under icons/ and update this array
       
    20 	var spritelist = ['add', 'bold', 'extlink', 'image', 'intlink', 'italic', 'olist', 'signature', 'table', 'ulist', 'underline', 'separator'];
    19 	
    21 	
    20 	// Button: Bold
    22 	// Button: Bold
    21 	var i;
    23 	var i;
    22 	var hide_label = false;
    24 	var hide_label = false;
    23 	for ( i = 0; i < buttons.length; i++ )
    25 	for ( i = 0; i < buttons.length; i++ )
    24 	{
    26 	{
    25 		if ( buttons[i] == '|' )
    27 		if ( buttons[i] == '|' )
    26 		{
    28 		{
    27 			label.assign_vars({
    29 			label.assign_vars({
    28 					TITLE: '<img alt="|" src="' + scriptPath + '/plugins/guieditor/icons/separator.png" />'
    30 					TITLE: gen_sprite_html(cdnPath + '/plugins/guieditor/icons/sprite.png', 8, 16, 0, (spritelist.length - 1) * 16),
    29 				});
    31 				});
    30 			toolbar += label.run();
    32 			toolbar += label.run();
    31 		}
    33 		}
    32 		else if ( buttons[i] == 'heading' )
    34 		else if ( buttons[i] == 'heading' )
    33 		{
    35 		{
    51 				buttons[i] = buttons[i].substr(0, buttons[i].length - 1);
    53 				buttons[i] = buttons[i].substr(0, buttons[i].length - 1);
    52 				button.assign_bool({ show_title: false });
    54 				button.assign_bool({ show_title: false });
    53 			}
    55 			}
    54 			button.assign_vars({
    56 			button.assign_vars({
    55 					TITLE: $lang.get('guied_btn_' + buttons[i]),
    57 					TITLE: $lang.get('guied_btn_' + buttons[i]),
    56 					IMAGE: cdnPath + '/plugins/guieditor/icons/' + buttons[i] + '.png',
    58 					// FIXME: indexOf is error prone here
       
    59 					SPRITE: gen_sprite_html(cdnPath + '/plugins/guieditor/icons/sprite.png', 16, 16, 0, spritelist.indexOf(buttons[i]) * 16),
    57 					FLAGS: 'href="#" onclick="guied_act(\'' + buttons[i] + '\'); return false;"'
    60 					FLAGS: 'href="#" onclick="guied_act(\'' + buttons[i] + '\'); return false;"'
    58 				});
    61 				});
    59 			toolbar += button.run();
    62 			toolbar += button.run();
    60 			if ( hide_label )
    63 			if ( hide_label )
    61 			{
    64 			{
    74 }
    77 }
    75 
    78 
    76 function guied_act(action)
    79 function guied_act(action)
    77 {
    80 {
    78 	var textarea = document.getElementById('ajaxEditArea');
    81 	var textarea = document.getElementById('ajaxEditArea');
       
    82 	var af_class = typeof(autofill_schemas.floodlight) == 'object' ? 'guied_floodlight' : 'page';
    79 	switch(action)
    83 	switch(action)
    80 	{
    84 	{
    81 		case 'bold':
    85 		case 'bold':
    82 			guied_insert_wikitext_tag(textarea, "'''", "'''", $lang.get('guied_sample_bold'));
    86 			guied_insert_wikitext_tag(textarea, "'''", "'''", $lang.get('guied_sample_bold'));
    83 			break;
    87 			break;
    97 								<tr> \
   101 								<tr> \
    98 									<td valign="top" style="white-space: nowrap;"> \
   102 									<td valign="top" style="white-space: nowrap;"> \
    99 									' + $lang.get('guied_intlink_lbl_page') + ' \
   103 									' + $lang.get('guied_intlink_lbl_page') + ' \
   100 									</td> \
   104 									</td> \
   101 									<td valign="top"> \
   105 									<td valign="top"> \
   102 										<input type="text" id="guied_intlink_page" class="autofill page" style="width: 100%;" /><br /> \
   106 										<input type="text" id="guied_intlink_page" class="autofill ' + af_class + '" style="width: 100%;" /><br /> \
   103 										<small>' + $lang.get('guied_intlink_af_hint') + '</small> \
   107 										<small>' + $lang.get('guied_intlink_af_hint') + '</small> \
   104 									</td> \
   108 									</td> \
   105 								</tr> \
   109 								</tr> \
   106 								<tr> \
   110 								<tr> \
   107 									<td valign="top" style="white-space: nowrap;"> \
   111 									<td valign="top" style="white-space: nowrap;"> \
   571 				}
   575 				}
   572 		});
   576 		});
   573 	}
   577 	}
   574 	
   578 	
   575 };
   579 };
       
   580 
       
   581 // This is only used if floodlight is available
       
   582 autofill_schemas.guied_floodlight = {
       
   583   init: function(element, fillclass, params)
       
   584   {
       
   585     params = params || {};
       
   586     $(element).autocomplete(makeUrlNS('Special', 'Autofill', 'type=floodlight') + '&userinput=', {
       
   587         minChars: 3,
       
   588         formatItem: function(row, _, __)
       
   589         {
       
   590           var type = ( typeof(row.type) == 'string' ) ? row.type : '';
       
   591           var html = '<big>' + row.title + '</big> <small>' + type + '</small>';
       
   592           html += '<br /><small>' + $lang.get('floodlight_lbl_score') + row.score + '% | ' + row.size + '</small>';
       
   593           row[0] = row[0].replace(/^go:/, '');
       
   594           return html;
       
   595         },
       
   596         tableHeader: '<tr><th>' + $lang.get('floodlight_table_heading') + '</th></tr>',
       
   597         showWhenNoResults: true,
       
   598         onItemSelect: function(li)
       
   599         {
       
   600         	$(element).val(li.selectValue.replace(/^go:/, ''));
       
   601         },
       
   602         width: 180,
       
   603         noResultsHTML: '<tr><td class="row1" style="font-size: smaller;">' + $lang.get('floodlight_msg_no_results') + '</td></tr>',
       
   604     });
       
   605   }
       
   606 };
       
   607