r51164 - in /trunk/libjifty-plugin-wikitoolbar-perl: ./ debian/ lib/Jifty/Plugin/ lib/Jifty/Plugin/WikiToolbar/ share/web/static/js/ t/Testapp/

jawnsy-guest at users.alioth.debian.org jawnsy-guest at users.alioth.debian.org
Sun Jan 17 20:41:45 UTC 2010


Author: jawnsy-guest
Date: Sun Jan 17 20:41:39 2010
New Revision: 51164

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=51164
Log:
* New upstream release
* Update copyright to DEP5 format
* Rewrite control description
* Add myself to Copyright and Uploaders
* Standards-Version 3.8.3 (no changes)
* Update dependencies per upstream

Added:
    trunk/libjifty-plugin-wikitoolbar-perl/README
      - copied unchanged from r51163, branches/upstream/libjifty-plugin-wikitoolbar-perl/current/README
    trunk/libjifty-plugin-wikitoolbar-perl/t/Testapp/
      - copied from r51163, branches/upstream/libjifty-plugin-wikitoolbar-perl/current/t/Testapp/
Modified:
    trunk/libjifty-plugin-wikitoolbar-perl/Changes
    trunk/libjifty-plugin-wikitoolbar-perl/MANIFEST
    trunk/libjifty-plugin-wikitoolbar-perl/META.yml
    trunk/libjifty-plugin-wikitoolbar-perl/Makefile.PL
    trunk/libjifty-plugin-wikitoolbar-perl/debian/changelog
    trunk/libjifty-plugin-wikitoolbar-perl/debian/control
    trunk/libjifty-plugin-wikitoolbar-perl/debian/copyright
    trunk/libjifty-plugin-wikitoolbar-perl/lib/Jifty/Plugin/WikiToolbar.pm
    trunk/libjifty-plugin-wikitoolbar-perl/lib/Jifty/Plugin/WikiToolbar/Textarea.pm
    trunk/libjifty-plugin-wikitoolbar-perl/share/web/static/js/wikitoolbar.js

Modified: trunk/libjifty-plugin-wikitoolbar-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjifty-plugin-wikitoolbar-perl/Changes?rev=51164&op=diff
==============================================================================
--- trunk/libjifty-plugin-wikitoolbar-perl/Changes (original)
+++ trunk/libjifty-plugin-wikitoolbar-perl/Changes Sun Jan 17 20:41:39 2010
@@ -1,4 +1,9 @@
 Revision history for Perl module Jifty::Plugin::WikiToolbar
+
+1.00 Sun, 17 Jan 2010 12:08:52 +0100
+    - add WikiToolbar type, this is shorter than render_as
+    - use JQuery instead of Behaviour in js
+    - fix multi toolbar on one page
 
 0.9  Tue, 05 May 2009 16:36:50 +0200
     - allow to override rows and cols size

Modified: trunk/libjifty-plugin-wikitoolbar-perl/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjifty-plugin-wikitoolbar-perl/MANIFEST?rev=51164&op=diff
==============================================================================
--- trunk/libjifty-plugin-wikitoolbar-perl/MANIFEST (original)
+++ trunk/libjifty-plugin-wikitoolbar-perl/MANIFEST Sun Jan 17 20:41:39 2010
@@ -15,8 +15,9 @@
 lib/Jifty/Plugin/WikiToolbar/Textarea.pm
 LICENSE
 Makefile.PL
-MANIFEST			This list of files
+MANIFEST
 META.yml
+README
 share/web/static/img/wt/bold.png
 share/web/static/img/wt/box.png
 share/web/static/img/wt/center.png
@@ -40,3 +41,9 @@
 t/001_load.t
 t/pod.t
 t/pod_coverage.t
+t/Testapp/bin/jifty
+t/Testapp/etc/config.yml
+t/Testapp/lib/Testapp/Model/Texts.pm
+t/Testapp/lib/Testapp/View.pm
+t/Testapp/Makefile.PL
+t/Testapp/t/00-toolbar.t

Modified: trunk/libjifty-plugin-wikitoolbar-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjifty-plugin-wikitoolbar-perl/META.yml?rev=51164&op=diff
==============================================================================
--- trunk/libjifty-plugin-wikitoolbar-perl/META.yml (original)
+++ trunk/libjifty-plugin-wikitoolbar-perl/META.yml Sun Jan 17 20:41:39 2010
@@ -19,7 +19,8 @@
     - inc
     - t
 requires:
-  Jifty: 0.70416
+  Jifty: 0.91117
 resources:
   license: http://dev.perl.org/licenses/
-version: 0.9
+  repository: git at github.com:yvesago/jifty-plugin-wikitoolbar.git
+version: 1.00

Modified: trunk/libjifty-plugin-wikitoolbar-perl/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjifty-plugin-wikitoolbar-perl/Makefile.PL?rev=51164&op=diff
==============================================================================
--- trunk/libjifty-plugin-wikitoolbar-perl/Makefile.PL (original)
+++ trunk/libjifty-plugin-wikitoolbar-perl/Makefile.PL Sun Jan 17 20:41:39 2010
@@ -4,11 +4,13 @@
 all_from       'lib/Jifty/Plugin/WikiToolbar.pm';
 
 build_requires 'Test::More';
-requires('Jifty' => '0.70416');
+requires('Jifty' => '0.91117');
+
+resources repository => 'git at github.com:yvesago/jifty-plugin-wikitoolbar.git';
 
 install_share;
 
-tests('t/*.t');
+tests('t/*.t t/*/t/*.t');
 auto_install;
 WriteAll;
 

Modified: trunk/libjifty-plugin-wikitoolbar-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjifty-plugin-wikitoolbar-perl/debian/changelog?rev=51164&op=diff
==============================================================================
--- trunk/libjifty-plugin-wikitoolbar-perl/debian/changelog (original)
+++ trunk/libjifty-plugin-wikitoolbar-perl/debian/changelog Sun Jan 17 20:41:39 2010
@@ -1,4 +1,12 @@
-libjifty-plugin-wikitoolbar-perl (0.90000-2) UNRELEASED; urgency=low
+libjifty-plugin-wikitoolbar-perl (1.00-1) UNRELEASED; urgency=low
+
+  [ Jonathan Yu ]
+  * New upstream release
+  * Update copyright to DEP5 format
+  * Rewrite control description
+  * Add myself to Copyright and Uploaders
+  * Standards-Version 3.8.3 (no changes)
+  * Update dependencies per upstream
 
   [ Salvatore Bonaccorso ]
   * debian/control: Changed: Replace versioned (build-)dependency on
@@ -8,7 +16,7 @@
   [ gregor herrmann ]
   * debian/watch: adjust uversionmangle to newer uscan/PET.
 
- -- Salvatore Bonaccorso <salvatore.bonaccorso at gmail.com>  Sun, 16 Aug 2009 20:14:39 +0200
+ -- Jonathan Yu <jawnsy at cpan.org>  Sun, 17 Jan 2010 15:49:28 -0500
 
 libjifty-plugin-wikitoolbar-perl (0.90000-1) unstable; urgency=low
 

Modified: trunk/libjifty-plugin-wikitoolbar-perl/debian/control
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjifty-plugin-wikitoolbar-perl/debian/control?rev=51164&op=diff
==============================================================================
--- trunk/libjifty-plugin-wikitoolbar-perl/debian/control (original)
+++ trunk/libjifty-plugin-wikitoolbar-perl/debian/control Sun Jan 17 20:41:39 2010
@@ -2,24 +2,20 @@
 Section: perl
 Priority: optional
 Build-Depends: debhelper (>= 7)
-Build-Depends-Indep: perl,
- libjifty-perl (>= 0.90519), libtest-pod-perl, libtest-pod-coverage-perl
+Build-Depends-Indep: perl, libjifty-perl (>= 0.91117), libtest-pod-perl,
+ libtest-pod-coverage-perl
 Maintainer: Debian Perl Group <pkg-perl-maintainers at lists.alioth.debian.org>
-Uploaders: AGOSTINI Yves <agostini at univ-metz.fr>
-Standards-Version: 3.8.2
+Uploaders: AGOSTINI Yves <agostini at univ-metz.fr>,
+ Jonathan Yu <jawnsy at cpan.org>
+Standards-Version: 3.8.3
 Homepage: http://search.cpan.org/dist/Jifty-Plugin-WikiToolbar/
 Vcs-Svn: svn://svn.debian.org/pkg-perl/trunk/libjifty-plugin-wikitoolbar-perl/
 Vcs-Browser: http://svn.debian.org/viewsvn/pkg-perl/trunk/libjifty-plugin-wikitoolbar-perl/
 
 Package: libjifty-plugin-wikitoolbar-perl
 Architecture: all
-Depends: ${perl:Depends}, ${misc:Depends}, libjifty-perl (>= 0.90519)
-Description: Jifty plugin to add a wiki toolbar to your textarea box
- Jifty::Plugin::WikiToolbar adds a toolbar to your textarea field. 
- .
- In your model description, instead of 
-  render_as 'textarea';
- you can use:
-  render_as 'Jifty::Plugin::WikiToolbar::Textarea';
- .
- Default toolbar provide markdown markup syntax.
+Depends: ${perl:Depends}, ${misc:Depends}, libjifty-perl (>= 0.91117)
+Description: Jifty plugin to add a wiki toolbar to textarea boxes
+ Jifty::Plugin::WikiToolbar is a Jifty Plugin that simply adds a toolbar to
+ textarea fields as required. By default, the toolbar provides input using the
+ commonly-used Markdown formatting syntax.

Modified: trunk/libjifty-plugin-wikitoolbar-perl/debian/copyright
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjifty-plugin-wikitoolbar-perl/debian/copyright?rev=51164&op=diff
==============================================================================
--- trunk/libjifty-plugin-wikitoolbar-perl/debian/copyright (original)
+++ trunk/libjifty-plugin-wikitoolbar-perl/debian/copyright Sun Jan 17 20:41:39 2010
@@ -1,34 +1,36 @@
-Format-Specification:
-    http://wiki.debian.org/Proposals/CopyrightFormat?action=recall&rev=196
-Upstream-Maintainer: Yves Agostini, <yvesago at cpan.org>
-Upstream-Source: http://search.cpan.org/dist/Jifty-Plugin-WikiToolbar/
-Upstream-Name: Jifty-Plugin-WikiToolbar
+Format-Specification: http://svn.debian.org/wsvn/dep/web/deps/dep5.mdwn?op=file&rev=59
+Maintainer: Yves Agostini <yvesago at cpan.org>
+Source: http://search.cpan.org/dist/Jifty-Plugin-WikiToolbar/
+Name: Jifty-Plugin-WikiToolbar
 
 Files: *
-Copyright: 2007-2009, Yves Agostini <yvesago at cpan.org>
-License-Alias: Perl
-License: Artistic | GPL-1+
+Copyright: 2007-2010, Yves Agostini <yvesago at cpan.org>
+License: Artistic or GPL-1+
 
-Files: inc/*
-Copyright: Copyright 2002 - 2008 by Brian Ingerson, Audrey Tang and Adam Kennedy.
-License: GPL-1+ | Artistic
- This program is free software; you can redistribute it and/or modify it under
- the same terms as Perl itself.
+Files: inc/Module/*
+Copyright: 2002-2009, Adam Kennedy <adamk at cpan.org>
+ 2002-2009, Audrey Tang <autrijus at autrijus.org>
+ 2002-2009, Brian Ingerson <ingy at cpan.org>
+License: Artistic or GPL-1+
 
 Files: debian/*
-Copyright: 2009, AGOSTINI Yves <agostini at univ-metz.fr>
-License: Artistic | GPL-1+
+Copyright: 2010, Jonathan Yu <jawnsy at cpan.org>
+ 2009, AGOSTINI Yves <agostini at univ-metz.fr>
+License: Artistic or GPL-1+
 
 License: Artistic
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the Artistic License, which comes with Perl.
-    On Debian GNU/Linux systems, the complete text of the Artistic License
-    can be found in `/usr/share/common-licenses/Artistic'
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the Artistic License, which comes with Perl.
+ .
+ On Debian GNU/Linux systems, the complete text of the Artistic License
+ can be found in `/usr/share/common-licenses/Artistic'
 
 License: GPL-1+
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 1, or (at your option)
-    any later version.
-    On Debian GNU/Linux systems, the complete text of the GNU General
-    Public License can be found in `/usr/share/common-licenses/GPL'
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 1, or (at your option)
+ any later version.
+ .
+ On Debian GNU/Linux systems, the complete text of the GNU General
+ Public License can be found in `/usr/share/common-licenses/GPL'
+

Modified: trunk/libjifty-plugin-wikitoolbar-perl/lib/Jifty/Plugin/WikiToolbar.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjifty-plugin-wikitoolbar-perl/lib/Jifty/Plugin/WikiToolbar.pm?rev=51164&op=diff
==============================================================================
--- trunk/libjifty-plugin-wikitoolbar-perl/lib/Jifty/Plugin/WikiToolbar.pm (original)
+++ trunk/libjifty-plugin-wikitoolbar-perl/lib/Jifty/Plugin/WikiToolbar.pm Sun Jan 17 20:41:39 2010
@@ -4,7 +4,7 @@
 package Jifty::Plugin::WikiToolbar;
 use base qw/Jifty::Plugin/;
 
-our $VERSION = '0.9';
+our $VERSION = '1.00';
 
 =head1 NAME
 
@@ -23,11 +23,11 @@
 
 use
 
-  render_as 'Jifty::Plugin::WikiToolbar::Textarea';
+   is WikiToolbar;
 
 or you can custom rows size with
 
- sub Jifty::Plugin::WikiToolbar::Textarea::rows { return 5; };
+ sub Jifty::Plugin::WikiToolbar::Textarea::rows { return 15; };
 
 To custom the toolbar, copy wikitoolbar.js in your application, at the end of the file put your changes with addButton function.
 
@@ -49,7 +49,21 @@
     @{ Jifty->web->javascript_libs },
     "wikitoolbar.js",
     ]);
-}
+};
+
+use Jifty::DBI::Schema;
+
+sub _toolbar {
+        my ($column, $from) = @_;
+        my $name = $column->name;
+        $column->type('text');
+};
+
+Jifty::DBI::Schema->register_types(
+    WikiToolbar =>
+       sub { _init_handler is \&_toolbar, render_as 'Jifty::Plugin::WikiToolbar::Textarea' },
+);
+
 
 =head1 AUTHOR
 
@@ -57,7 +71,7 @@
 
 =head1 LICENSE
 
-Copyright 2007-2009 Yves Agostini. All Rights Reserved.
+Copyright 2007-2010, Yves Agostini
 
 This program is free software and may be modified and distributed under the same terms as Perl itself.
 

Modified: trunk/libjifty-plugin-wikitoolbar-perl/lib/Jifty/Plugin/WikiToolbar/Textarea.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjifty-plugin-wikitoolbar-perl/lib/Jifty/Plugin/WikiToolbar/Textarea.pm?rev=51164&op=diff
==============================================================================
--- trunk/libjifty-plugin-wikitoolbar-perl/lib/Jifty/Plugin/WikiToolbar/Textarea.pm (original)
+++ trunk/libjifty-plugin-wikitoolbar-perl/lib/Jifty/Plugin/WikiToolbar/Textarea.pm Sun Jan 17 20:41:39 2010
@@ -1,3 +1,6 @@
+use strict;
+use warnings;
+
 package Jifty::Plugin::WikiToolbar::Textarea;
 use base qw(Jifty::Web::Form::Field::Textarea);
 
@@ -24,16 +27,26 @@
 sub render_widget {
     my $self  = shift;
     my $field;
-    $field .= qq!<div id='toolbar'></div>!;
+    my $element_id = "@{[ $self->element_id ]}";
+        $element_id=~s/://g;
+
     $field .= qq!<textarea!;
     $field .= qq! name="@{[ $self->input_name ]}"!;
-    $field .= qq! id="@{[ $self->element_id ]}"!;
+    $field .= qq! id="$element_id"!;
     $field .= qq! rows="@{[$self->rows || 5 ]}"!;
     $field .= qq! cols="@{[$self->cols || 60]}"!;
     $field .= $self->_widget_class;
     $field .= qq! >!;
     $field .= Jifty->web->escape($self->current_value) if $self->current_value;
-	$field .= qq!</textarea>\n!;
+    $field .= qq!</textarea>\n!;
+    $field .= <<"EOF";
+<script language="javascript">
+    jQuery(document).ready(function() {
+      jQuery('#$element_id').each(function() { addWikiFormattingToolbar(this) });
+    });
+</script>
+EOF
+
     Jifty->web->out($field);
     '';
 }

Modified: trunk/libjifty-plugin-wikitoolbar-perl/share/web/static/js/wikitoolbar.js
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libjifty-plugin-wikitoolbar-perl/share/web/static/js/wikitoolbar.js?rev=51164&op=diff
==============================================================================
--- trunk/libjifty-plugin-wikitoolbar-perl/share/web/static/js/wikitoolbar.js (original)
+++ trunk/libjifty-plugin-wikitoolbar-perl/share/web/static/js/wikitoolbar.js Sun Jan 17 20:41:39 2010
@@ -1,137 +1,104 @@
-// Wikipedia JavaScript toolbar functions
+(function($){
 
-mwEditButtons = [];
-
-// this function generates the actual toolbar buttons with localized text
-// we use it to avoid creating the toolbar where javascript is not enabled
-function addButton(imageFile, speedTip, tagOpen, tagClose, sampleText) {
-	mwEditButtons[mwEditButtons.length] =
-		{"imageFile": imageFile,
-		 "speedTip": speedTip,
-		 "tagOpen": tagOpen,
-		 "tagClose": tagClose,
-		 "sampleText": sampleText};
-}
-
-// this function generates the actual toolbar buttons with localized text
-// we use it to avoid creating the toolbar where javascript is not enabled
-function mwInsertEditButton(parent, item) {
-    if (typeof item.imageFile == 'undefined') {
-        return;}
-	var image = document.createElement("img");
-	image.width = 16;
-	image.height = 16;
-	image.src = item.imageFile;
-	image.border = 0;
-	image.alt = item.speedTip;
-	image.title = item.speedTip;
-	image.style.cursor = "pointer";
-	image.onclick = function() {
-		insertTags(item.tagOpen, item.tagClose, item.sampleText);
-		return false;
-	}
-	parent.appendChild(image);
-}
-
-// apply tagOpen/tagClose to selection in textarea,
-// use sampleText instead of selection if there is none
-// copied and adapted from phpBB
-function insertTags(tagOpen, tagClose, sampleText) {
-
-   // var txtarea = document.getElementsByTagName('TEXTAREA')[0];
-    // TODO: need a better way to manage multi textarea
-    var txtarea;
-    var txtareas = document.getElementsByTagName('TEXTAREA');
-    for (i = 0; i < txtareas.length; i++) {
-        var textbox = txtareas[i];
-        if( textbox.selectionStart ) {
-            txtarea = textbox;
-        };
+  window.addWikiFormattingToolbar = function(textarea) {
+    if ((document.selection == undefined)
+     && (textarea.setSelectionRange == undefined)) {
+      return;
     }
 
-    if (typeof txtarea == 'undefined') {
-        txtarea = document.getElementsByTagName('TEXTAREA')[0];
+    var toolbar = document.createElement("div");
+    toolbar.className = "wikitoolbar";
+
+    function addButton(src, title, fn) {
+      var image = document.createElement("img");
+      image.width = 16;
+      image.height = 16;
+      image.src = src;
+      image.border = 0;
+      image.alt = title;
+      image.title = title;
+      image.style.cursor = "pointer";
+      image.onclick = function() { try { fn() } catch (e) { } return false };
+      toolbar.appendChild(image);
     }
 
-	// IE
-	if (document.selection && !is_gecko) {
-		var theSelection = document.selection.createRange().text;
-		if (!theSelection)
-			theSelection=sampleText;
-		txtarea.focus();
-		if (theSelection.charAt(theSelection.length - 1) == " ") { // exclude ending space char, if any
-			theSelection = theSelection.substring(0, theSelection.length - 1);
-			document.selection.createRange().text = tagOpen + theSelection + tagClose + " ";
-		} else {
-			document.selection.createRange().text = tagOpen + theSelection + tagClose;
-		}
+    function encloseSelection(prefix, suffix) {
+      textarea.focus();
+      var start, end, sel, scrollPos, subst;
+      if (document.selection != undefined) {
+        sel = document.selection.createRange().text;
+      } else if (textarea.setSelectionRange != undefined) {
+        start = textarea.selectionStart;
+        end = textarea.selectionEnd;
+        scrollPos = textarea.scrollTop;
+        sel = textarea.value.substring(start, end);
+      }
+      if (sel.match(/ $/)) { // exclude ending space char, if any
+        sel = sel.substring(0, sel.length - 1);
+        suffix = suffix + " ";
+      }
+      subst = prefix + sel + suffix;
+      if (document.selection != undefined) {
+        var range = document.selection.createRange().text = subst;
+        textarea.caretPos -= suffix.length;
+      } else if (textarea.setSelectionRange != undefined) {
+        textarea.value = textarea.value.substring(0, start) + subst +
+                         textarea.value.substring(end);
+        if (sel) {
+          textarea.setSelectionRange(start + subst.length, start + subst.length);
+        } else {
+          textarea.setSelectionRange(start + prefix.length, start + prefix.length);
+        }
+        textarea.scrollTop = scrollPos;
+      }
+    }
 
-	// Mozilla
-	} else if(txtarea.selectionStart || txtarea.selectionStart == '0') {
-		var replaced = false;
-		var startPos = txtarea.selectionStart;
-		var endPos = txtarea.selectionEnd;
-		if (endPos-startPos)
-			replaced = true;
-		var scrollTop = txtarea.scrollTop;
-		var myText = (txtarea.value).substring(startPos, endPos);
-		if (!myText)
-			myText=sampleText;
-		if (myText.charAt(myText.length - 1) == " ") { // exclude ending space char, if any
-			subst = tagOpen + myText.substring(0, (myText.length - 1)) + tagClose + " ";
-		} else {
-			subst = tagOpen + myText + tagClose;
-		}
-		txtarea.value = txtarea.value.substring(0, startPos) + subst +
-			txtarea.value.substring(endPos, txtarea.value.length);
-		txtarea.focus();
-		//set new selection
-		if (replaced) {
-			var cPos = startPos+(tagOpen.length+myText.length+tagClose.length);
-			txtarea.selectionStart = cPos;
-			txtarea.selectionEnd = cPos;
-		} else {
-			txtarea.selectionStart = startPos+tagOpen.length;
-			txtarea.selectionEnd = startPos+tagOpen.length+myText.length;
-		}
-		txtarea.scrollTop = scrollTop;
+// overide this addButtons to design your own toolbar
+    addButton('/static/img/wt/bold.png', "Bold text: \*\*Example\*\*", function() {
+      encloseSelection('\*\*','\*\*');
+    });
+    addButton('/static/img/wt/italic.png', "Italic text: \_Example\_", function() {
+      encloseSelection("\_", "\_");
+    });
+    addButton('/static/img/wt/empty.png', "", function() {
+      encloseSelection("", "");
+    });
+    addButton('/static/img/wt/h1.png', "Title: Example\n=======", function() {
+      encloseSelection("", "\n=======\n", "Title");
+    });
+    addButton('/static/img/wt/h2.png', "Sub title: Example\n-------", function() {
+      encloseSelection("", "\n-------\n", "Sub title");
+    });
+    addButton('/static/img/wt/h3.png', "Sub sub title: ### Example ###", function() {
+      encloseSelection("### ", " ###\n", "Sub sub title");
+    });
+    addButton('/static/img/wt/empty.png', "", function() {
+      encloseSelection("", "");
+    });
+    addButton('/static/img/wt/link.png', "Link: [Some text](http://www.example.com/)", function() {
+      encloseSelection("[", "](http://...)");
+    });
+    addButton('/static/img/wt/linkextern.png', "URL: <http://www.example.com/>", function() {
+      encloseSelection("<", ">");
+    });
+    addButton('/static/img/wt/empty.png', "", function() {
+      encloseSelection("", "");
+    });
+    addButton('/static/img/wt/ul.png', "List: - element 1", function() {
+      encloseSelection("", "\n- element 1\n- element 2\n- element 3\n\n");
+    });
+    addButton('/static/img/wt/ol.png', "Ordered list: 1. element 1", function() {
+      encloseSelection("", "\n1. element 1\n1. element 2\n1. element 3\n\n");
+    });
 
-	// All other browsers get no toolbar.
-	// There was previously support for a crippled "help"
-	// bar, but that caused more problems than it solved.
-	}
-	// reposition cursor if possible
-	if (txtarea.createTextRange)
-		txtarea.caretPos = document.selection.createRange().duplicate();
-}
+    $(textarea).before(toolbar);
+  }
 
+})(jQuery);
 
+// Add the toolbar to all <textarea> elements on the page with the class
+// 'toolbar'.
+/*jQuery(document).ready(function() {
+  jQuery("textarea.toolbar").each(function() { addWikiFormattingToolbar(this) });
+});*/
 
-var myrules = {
-        '#toolbar' : function(e){
-			mwEditButtons = [];
-// CUSTOM your toolbar HERE
-// addButton : image, help text, first tag before selected text, last tag, default text if nothing is selected
-addButton('/static/img/wt/bold.png','Bold text','\*\*','\*\*','Bold text');
-addButton('/static/img/wt/italic.png','Italic text','\_','\_','Italic text');
-  addButton('/static/img/wt/empty.png','','','','');
-addButton('/static/img/wt/h1.png','Title','','\n=======\n','Title');
-addButton('/static/img/wt/h2.png','Sub title','','\n-------\n','Sub title');
-addButton('/static/img/wt/h3.png','Sub sub title','### ',' ###\n','Sub sub title');
-  addButton('/static/img/wt/empty.png','','','','');
-addButton('/static/img/wt/link.png','Link','[','](http://...... )','Text');
-addButton('/static/img/wt/linkextern.png','URL','<','>','http://.....');
-  addButton('/static/img/wt/empty.png','','','','');
-addButton('/static/img/wt/ul.png','List','\n- element 1\n- element 2\n- element 3\n\n ','','');
-addButton('/static/img/wt/ol.png','Ordered list','\n1. element 1\n1. element 2\n1. element 3\n\n ','','');
-// END
-
-	for(i=0;i<mwEditButtons.length;i++) {
-		mwInsertEditButton(e, mwEditButtons[i]);
-	}
-
-        }
-    };
-    
-Behaviour.register(myrules);
-




More information about the Pkg-perl-cvs-commits mailing list