[pLog-svn] r4002 - plugins/branches/lifetype-1.1/templateeditor/js/editor

BalearWeb balearweb at balearweb.com
Fri Sep 22 11:10:19 GMT 2006


I s this update only for 1.1 and not for 1.1.1?
Sorry I don't quite understand if I have to add this update to 1.1.1 or 
not.

Thank you

Elena


oscar at devel.lifetype.net wrote:
> Author: oscar
> Date: 2006-09-20 21:57:08 +0000 (Wed, 20 Sep 2006)
> New Revision: 4002
>
> Modified:
>    plugins/branches/lifetype-1.1/templateeditor/js/editor/smartyeditor.js
> Log:
> fixed an issue with the template editor plugin, where the javascript editor was not working anymore. Right now I've just copied pLogEditor and renamed it to SmartyEditor, kind of a brute force solution but it works...
>
>
> Modified: plugins/branches/lifetype-1.1/templateeditor/js/editor/smartyeditor.js
> ===================================================================
> --- plugins/branches/lifetype-1.1/templateeditor/js/editor/smartyeditor.js	2006-09-20 21:10:13 UTC (rev 4001)
> +++ plugins/branches/lifetype-1.1/templateeditor/js/editor/smartyeditor.js	2006-09-20 21:57:08 UTC (rev 4002)
> @@ -1,54 +1,4 @@
>  /**
> - * SmartyEditor.js (Based on pLogEditor.js)
> - *
> - * Non-wysiwyg javascript-based editor for textarea controls in browsers. It works in
> - * exactly the same as HTMLArea control but instead of graphically showing the contents
> - * of the post, works based on raw html code. It does not offer as many features as
> - * htmlarea but it does offer some other things as customizable toolbars, support
> - * for text selections and ranges, etc. It should work in every major browser with
> - * some support for DOM and DHTML.
> - * It is very loosely based on Alex King's js_quicktags.js which is also used in Wordpress.
> - * However, js_quicktags has the limitation that it can only work with one textarea per page
> - * and plog for example needs two in the "new post" page. The code is javascript with OOP
> - * so it might look a bit weird at first...
> - * This code is licensed under the terms of the GPL license.
> - *
> - * -- Installation and usage --
> - *
> - * Place this file somewhere in your web server tree and from your html files, call it like
> - * <html>
> - *  <head>
> - *   <link rel="stylesheet" href="smartyeditor.css" type="text/css">
> - *   <script type="text/javascript" src="smartyeditor.js"></script>
> - *   <script type="text/javascript">
> - *    // define where your images are...
> - *    var baseImageFolder='/devel/js/htmlarea/images';
> - *   </script>
> - *  </head>
> - *  <body>
> - *   <h1>SmartyEditor Javascript Sample</h1>
> - *   <form name="textEditor" id="textEditor">
> - *    text1:<br/>
> - *    <script type="text/javascript">ed1 = new SmartyEditor('text1', 'ed1');</script>
> - *    <textarea id="text1" name="text1" rows="8" cols="60"></textarea>
> - *    <br/>text2:<br/>
> - *    <script type="text/javascript">ed2 = new SmartyEditor('text2', 'ed2');</script>
> - *    <textarea id="text2" name="text1" rows="8" cols="60"></textarea>
> - *   </form>
> - *  </body>
> - * </html>
> - *
> - * Create a new SmartyEditor object in the place where you would like to show the 
> - * toolbar of the editor. The first paramter for the constructor is the value of the 'id'
> - * attribute of the textarea that will be the content area for the toolbar. The second parameter
> - * is the name of the object itself, so if you are creating an editor called 'myEditor', the second
> - * parameter will be 'myEditor'
> - *
> - * Please set the value of baseImageFolder to the base path where your icons are stored.
> - */
> - 
> - 
> -/**
>   * please change this if your icons are somewhere else!
>   */
>  var baseImageFolder = 'plugins/templateeditor/js/editor/images';
> @@ -266,7 +216,7 @@
>  		this.toggle();		
>  
>  		// if everything went fine, add the link and return
> -		var linkTag = '<a href="' + linkDest + '">' + linkDest + '</a>'; 
> +		var linkTag = '<a href="' + linkDest + '">' + linkText + '</a>'; 
>  		return linkTag;
>  	}
>  	
> @@ -383,6 +333,39 @@
>  }
>  
>  /**
> + * special button that only adds an resource
> + *
> + * @param id
> + * @param display
> + * @param icon
> + */
> +edButtonResource = function(id, display, icon)
> +{
> +	//
> +	// strange javascript thingies used for object inheritance...
> +	//
> +	this.prototype = new edButton(id, display, '', '', icon, -1 );
> +	this.prototype.constructor = edButton;
> +	this.superclass = edButton;
> +	
> +	this.superclass(id, display, '', '', icon, -1 );
> +
> +	/**
> +	 * reimplemented from edButton so that we can ask for an image url and a description
> +	 *
> +	 * @param txtId
> +	 */
> +	this.execute = function( txtId, param )
> +	{
> +		if ( txtId == 'postText' )
> +			resource_list_window(1);
> +		else
> +		    resource_list_window(2);
> +		return '';
> +	}
> +}
> +
> +/**
>   * implements drop-down lists
>   */
>  edButtonList = function( id, options )
> @@ -408,6 +391,8 @@
>  	{
>  		selectBox = '<select class="editorDropDownList" name=\''+this.id+'\' onChange="'+objName+'.execute(\'' + txtId + '\', \'' + this.id + '\', this);">';
>  		for( var key in this.options ) {
> +            if ( prototypeCompatibabilityCheck( key ) )
> +	            continue;			
>  			selectBox += '<option value=\''+key+'\'>'+this.options[key]+'</option>';
>  		}
>  		selectBox += '</select>';
> @@ -503,48 +488,47 @@
>    // --
>    // our very own toolbar
>    // --
> -  this.toolBar = Array();
> -  options = new Array();
> -  options['8'] = '8 pt';
> -  options['10'] = '10 pt';
> -  options['12'] = '12 pt';
> -  options['14'] = '14 pt';
> -  options['18'] = '18 pt';
> -  options['24'] = '24 pt';  
> -  options['36'] = '36 pt';
> -  this.toolBar['list_font_size'] = new edFontSizeList( 'list_font_size', options );
> -  this.toolBar['1_but_b']  = new edButton( '1_but_b', 'bold', '<strong>', '</strong>', 'ed_format_bold.gif', 1 );
> -  this.toolBar['2_but_i']  = new edButton( '2_but_i', 'italics', '<em>', '</em>', 'ed_format_italic.gif', 1 );
> -  this.toolBar['3_but_u']  = new edButton( '3_but_u', 'underline', '<span style="text-decoration:underline">', '</span>', 'ed_format_underline.gif', 1 );
> -  this.toolBar['4_but_strikethrough'] = new edButton( '4_but_strikethrough', 'strikethrough', '<span style="text-decoration: line-through;">', '</span>', 'ed_format_strike.gif', 1 );
> -  this.toolBar['but_sep1'] =  new edButtonSeparator();
> -  this.toolBar['but_align_left'] = new edButton( 'but_align_left', 'align center', '<div style="text-align: left;">', '</div>', 'ed_align_left.gif' );
> -  this.toolBar['but_align_center'] = new edButton( 'but_align_center', 'align center', '<div style="text-align: center;">', '</div>', 'ed_align_center.gif' );
> -  this.toolBar['but_align_right'] = new edButton( 'but_align_right', 'align center', '<div style="text-align: right;">', '</div>', 'ed_align_right.gif' );
> -  this.toolBar['but_align_justify'] = new edButton( 'but_align_justify', 'align center', '<div style="text-align: justify;">', '</div>', 'ed_align_justify.gif' );
> -  this.toolBar['but_sep2'] =  new edButtonSeparator();
> -  this.toolBar['but_ordered_list'] = new edButton( 'but_ordered_list', 'ordered list', '<ol><li></li></ol>', '', 'ed_list_num.gif', -1 );
> -  this.toolBar['but_unordered_list'] = new edButton( 'but_unordered_list', 'unordered list', '<ul><li></li></ul>', '', 'ed_list_bullet.gif', -1 );  
> -  this.toolBar['5_but_a']  = new edButtonLink( '5_but_a', 'anchor', 'ed_link.gif' );
> -  this.toolBar['6_but_img']= new edButtonImage( '6_but_img', 'image', 'ed_image.gif' );
> +	this.toolBar = Array();
> +	options = new Array();
> +	options['8'] = '8 pt';
> +	options['10'] = '10 pt';
> +	options['12'] = '12 pt';
> +	options['14'] = '14 pt';
> +	options['18'] = '18 pt';
> +	options['24'] = '24 pt';  
> +	options['36'] = '36 pt';
> +	this.toolBar['list_font_size'] = new edFontSizeList( 'list_font_size', options );
> +	this.toolBar['1_but_b']  = new edButton( '1_but_b', 'bold', '<strong>', '</strong>', 'ed_format_bold.gif', 1 );
> +	this.toolBar['2_but_i']  = new edButton( '2_but_i', 'italics', '<em>', '</em>', 'ed_format_italic.gif', 1 );
> +	this.toolBar['3_but_u']  = new edButton( '3_but_u', 'underline', '<span style="text-decoration:underline">', '</span>', 'ed_format_underline.gif', 1 );
> +	this.toolBar['4_but_strikethrough'] = new edButton( '4_but_strikethrough', 'strikethrough', '<span style="text-decoration: line-through;">', '</span>', 'ed_format_strike.gif', 1 );
> +	this.toolBar['but_sep1'] =  new edButtonSeparator();
> +	this.toolBar['but_align_left'] = new edButton( 'but_align_left', 'align center', '<div style="text-align: left;">', '</div>', 'ed_align_left.gif' );
> +	this.toolBar['but_align_center'] = new edButton( 'but_align_center', 'align center', '<div style="text-align: center;">', '</div>', 'ed_align_center.gif' );
> +	this.toolBar['but_align_right'] = new edButton( 'but_align_right', 'align center', '<div style="text-align: right;">', '</div>', 'ed_align_right.gif' );
> +	this.toolBar['but_align_justify'] = new edButton( 'but_align_justify', 'align center', '<div style="text-align: justify;">', '</div>', 'ed_align_justify.gif' );
> +	this.toolBar['but_sep2'] =  new edButtonSeparator();
> +	this.toolBar['but_ordered_list'] = new edButton( 'but_ordered_list', 'ordered list', '<ol><li></li></ol>', '', 'ed_list_num.gif', -1 );
> +	this.toolBar['but_unordered_list'] = new edButton( 'but_unordered_list', 'unordered list', '<ul><li></li></ul>', '', 'ed_list_bullet.gif', -1 );  
> +	this.toolBar['5_but_a']  = new edButtonLink( '5_but_a', 'anchor', 'ed_link.gif' );
> +	this.toolBar['6_but_img']= new edButtonImage( '6_but_img', 'image', 'ed_image.gif' );
>  
> -  this.toolBar['but_sep3'] =  new edButtonSeparator();
> -  this.toolBar['but_smarty_assign'] = new edButton( 'but_smarty_assign', 'assign', '{assign var="" value=""}', '', 'smarty_assign.gif', -1 );
> -  this.toolBar['but_smarty_capture'] = new edButton( 'but_smarty_capture', 'capture', '{capture name=""}', '{/capture}', 'smarty_capture.gif' );
> -  this.toolBar['but_smarty_comment'] = new edButton( 'but_smarty_comment', 'comment', '{* *}', '', 'smarty_comment.gif', -1 );
> -  this.toolBar['but_smarty_config_load'] = new edButton( 'but_smarty_config_load', 'config_load', '{config_load file="" section="" scope=""}', '', 'smarty_config_load.gif', -1 );
> -  this.toolBar['but_smarty_delimiter'] = new edButton( 'but_smarty_delimiter', 'delimiter', '{ }', '', 'smarty_delimiter.gif', -1 );  
> -  this.toolBar['but_smarty_foreach'] = new edButton( 'but_smarty_foreach', 'foreach', '{foreach from= item= name= key=}', '{/foreach}', 'smarty_foreach.gif' );  
> -  this.toolBar['but_smarty_if'] = new edButton( 'but_smarty_if', 'if', '{if }', '{/if}', 'smarty_if.gif' );  
> -  this.toolBar['but_smarty_include'] = new edButton( 'but_smarty_include', 'include', '{include file=""}', '', 'smarty_include.gif', -1 );  
> -  // this.toolBar['but_smarty_includephp'] = new edButton( 'but_smarty_includephp', 'includephp', '{include_php file=""}', '', 'smarty_includephp.gif', -1 );  
> -  this.toolBar['but_smarty_insert'] = new edButton( 'but_smarty_insert', 'insert', '{insert name=""}', '', 'smarty_insert.gif', -1 );  
> -  this.toolBar['but_smarty_literal'] = new edButton( 'but_smarty_literal', 'literal', '{literal}', '{/literal}', 'smarty_literal.gif' );  
> -  // this.toolBar['but_smarty_php'] = new edButton( 'but_smarty_php', 'php', '{php}', '{/php}', 'smarty_php.gif' );  
> -  this.toolBar['but_smarty_section'] = new edButton( 'but_smarty_section', 'section', '{section name="" loop=}', '{/section}', 'smarty_section.gif' );  
> -  this.toolBar['but_smarty_strip'] = new edButton( 'but_smarty_strip', 'strip', '{strip}', '{/strip}', 'smarty_strip.gif' );  
> -
> -  
> +	this.toolBar['but_sep3'] =  new edButtonSeparator();
> +	this.toolBar['but_smarty_assign'] = new edButton( 'but_smarty_assign', 'assign', '{assign var="" value=""}', '', 'smarty_assign.gif', -1 );
> +	this.toolBar['but_smarty_capture'] = new edButton( 'but_smarty_capture', 'capture', '{capture name=""}', '{/capture}', 'smarty_capture.gif' );
> +	this.toolBar['but_smarty_comment'] = new edButton( 'but_smarty_comment', 'comment', '{* *}', '', 'smarty_comment.gif', -1 );
> +	this.toolBar['but_smarty_config_load'] = new edButton( 'but_smarty_config_load', 'config_load', '{config_load file="" section="" scope=""}', '', 'smarty_config_load.gif', -1 );
> +	this.toolBar['but_smarty_delimiter'] = new edButton( 'but_smarty_delimiter', 'delimiter', '{ }', '', 'smarty_delimiter.gif', -1 );  
> +	this.toolBar['but_smarty_foreach'] = new edButton( 'but_smarty_foreach', 'foreach', '{foreach from= item= name= key=}', '{/foreach}', 'smarty_foreach.gif' );  
> +	this.toolBar['but_smarty_if'] = new edButton( 'but_smarty_if', 'if', '{if }', '{/if}', 'smarty_if.gif' );  
> +	this.toolBar['but_smarty_include'] = new edButton( 'but_smarty_include', 'include', '{include file=""}', '', 'smarty_include.gif', -1 );  
> +// toolBar['but_smarty_includephp'] = new edButton( 'but_smarty_includephp', 'includephp', '{include_php file=""}', '', 'smarty_includephp.gif', -1 );  
> +	this.toolBar['but_smarty_insert'] = new edButton( 'but_smarty_insert', 'insert', '{insert name=""}', '', 'smarty_insert.gif', -1 );  
> +	this.toolBar['but_smarty_literal'] = new edButton( 'but_smarty_literal', 'literal', '{literal}', '{/literal}', 'smarty_literal.gif' );  
> +// toolBar['but_smarty_php'] = new edButton( 'but_smarty_php', 'php', '{php}', '{/php}', 'smarty_php.gif' );  
> +	this.toolBar['but_smarty_section'] = new edButton( 'but_smarty_section', 'section', '{section name="" loop=}', '{/section}', 'smarty_section.gif' );  
> +	this.toolBar['but_smarty_strip'] = new edButton( 'but_smarty_strip', 'strip', '{strip}', '{/strip}', 'smarty_strip.gif' );  
> +	
>    /**
>     * returns whether our browser supports the features that we are going
>     * to use or not
> @@ -571,11 +555,12 @@
>  		
>  	  markup = '';
>  	  
> -	  this.toolBar.sort();
>  	  document.write('<div class="textEditorToolbar" id="textEditorToolbar">');
>  	  for( var buttonId in this.toolBar ) {
> -		  button = this.toolBar[buttonId];
> -		  markup += button.show(this.txtId, this.objName);
> +          if ( prototypeCompatibabilityCheck( buttonId ) )
> +	          continue;
> +	      button = this.toolBar[buttonId];
> +	      markup += button.show(this.txtId, this.objName);
>  	  }
>  	  document.write(markup);
>  	  document.write('</div>');
> @@ -745,4 +730,50 @@
>  
>  	return selection;
>    }
> +}
> +
> +// Add this function to Prototype Lib Compatibability Check
> +function prototypeCompatibabilityCheck( str )
> +{
> +    if ( str == '_each' ||
> +	  	 str == '_reverse' ||
> +         str == 'all' ||
> +         str == 'any' ||
> +         str == 'clear' ||
> +         str == 'collect' ||
> +         str == 'compact' ||
> +         str == 'detect' ||
> +         str == 'each' ||
> +         str == 'entries' ||
> +         str == 'extend' ||
> +         str == 'find' ||
> +         str == 'findAll' ||
> +         str == 'first' ||
> +         str == 'flatten' ||
> +         str == 'grep' ||
> +         str == 'include' ||
> +         str == 'indices' ||
> +         str == 'indexOf' ||
> +         str == 'inject' ||
> +         str == 'inspect' ||
> +         str == 'invoke' ||
> +         str == 'last' ||
> +         str == 'map' ||
> +         str == 'max' ||
> +         str == 'member' ||
> +         str == 'min' ||
> +         str == 'partition' ||
> +         str == 'pluck' ||
> +         str == 'reject' ||
> +         str == 'remove' ||
> +         str == 'removeItem' ||
> +         str == 'select' ||
> +         str == 'shift' ||
> +         str == 'sortBy' ||
> +         str == 'toArray' ||
> +         str == 'without' ||
> +         str == 'zip')
> +        return true;
> +    else
> +    	return false;
>  }
> \ No newline at end of file



More information about the pLog-svn mailing list