r24521 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24520‎ | r24521 | r24522 >
Date:14:30, 1 August 2007
Author:bartek
Status:old
Tags:
Comment:

latest changes regarding Wikiwyg-MediaWiki integration from Wikia
Modified paths:
  • /trunk/extensions/wikiwyg/AUTHORS (modified) (history)
  • /trunk/extensions/wikiwyg/COPYRIGHT (modified) (history)
  • /trunk/extensions/wikiwyg/Changes (modified) (history)
  • /trunk/extensions/wikiwyg/images/YouTube_placeholder.gif (added) (history)
  • /trunk/extensions/wikiwyg/images/link.gif (modified) (history)
  • /trunk/extensions/wikiwyg/images/unlink.gif (modified) (history)
  • /trunk/extensions/wikiwyg/images/wikify.gif (added) (history)
  • /trunk/extensions/wikiwyg/images/www.gif (modified) (history)
  • /trunk/extensions/wikiwyg/images/youtube.gif (added) (history)
  • /trunk/extensions/wikiwyg/lib/Wikiwyg.js (modified) (history)
  • /trunk/extensions/wikiwyg/lib/Wikiwyg/Preview.js (modified) (history)
  • /trunk/extensions/wikiwyg/lib/Wikiwyg/Toolbar.js (modified) (history)
  • /trunk/extensions/wikiwyg/lib/Wikiwyg/Util.js (modified) (history)
  • /trunk/extensions/wikiwyg/lib/Wikiwyg/Wikitext.js (modified) (history)
  • /trunk/extensions/wikiwyg/lib/Wikiwyg/Wysiwyg.js (modified) (history)
  • /trunk/extensions/wikiwyg/share/MediaWiki/MediaWikiWyg.js (modified) (history)
  • /trunk/extensions/wikiwyg/share/MediaWiki/css/MediaWikiwyg.css (modified) (history)
  • /trunk/extensions/wikiwyg/share/MediaWiki/extensions/MediaWikiWyg.php (modified) (history)
  • /trunk/extensions/wikiwyg/share/MediaWiki/extensions/WikiwygEditing (added) (history)
  • /trunk/extensions/wikiwyg/share/MediaWiki/extensions/WikiwygEditing/WikiwygEditing.php (added) (history)
  • /trunk/extensions/wikiwyg/share/MediaWiki/extensions/WikiwygEditing/js (added) (history)
  • /trunk/extensions/wikiwyg/share/MediaWiki/extensions/WikiwygEditing/js/editpage.js (added) (history)
  • /trunk/extensions/wikiwyg/share/MediaWiki/images/h1.gif (added) (history)
  • /trunk/extensions/wikiwyg/share/MediaWiki/images/h2.gif (modified) (history)
  • /trunk/extensions/wikiwyg/share/MediaWiki/images/h3.gif (added) (history)
  • /trunk/extensions/wikiwyg/share/MediaWiki/images/h4.gif (added) (history)
  • /trunk/extensions/wikiwyg/share/MediaWiki/images/h5.gif (added) (history)
  • /trunk/extensions/wikiwyg/share/MediaWiki/images/h6.gif (added) (history)
  • /trunk/extensions/wikiwyg/share/MediaWiki/images/link.gif (modified) (history)
  • /trunk/extensions/wikiwyg/share/MediaWiki/images/pre.gif (added) (history)
  • /trunk/extensions/wikiwyg/share/MediaWiki/images/separator.gif (modified) (history)
  • /trunk/extensions/wikiwyg/share/MediaWiki/images/table.gif (added) (history)
  • /trunk/extensions/wikiwyg/share/MediaWiki/images/timestamp.gif (added) (history)
  • /trunk/extensions/wikiwyg/share/MediaWiki/images/unlink.gif (modified) (history)
  • /trunk/extensions/wikiwyg/share/MediaWiki/images/wikify.gif (added) (history)
  • /trunk/extensions/wikiwyg/share/MediaWiki/images/www.gif (modified) (history)
  • /trunk/extensions/wikiwyg/share/MediaWiki/images/youtube.gif (added) (history)
  • /trunk/extensions/wikiwyg/share/MediaWiki/lib/Wikiwyg/MediaWiki.js (modified) (history)
  • /trunk/extensions/wikiwyg/share/MediaWiki/mediawiki-1.10.1bleed.patch (added) (history)

Diff [purge]

Index: trunk/extensions/wikiwyg/images/youtube.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: trunk/extensions/wikiwyg/images/youtube.gif
___________________________________________________________________
Added: svn:mime-type
11 + application/octet-stream
Index: trunk/extensions/wikiwyg/images/link.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: trunk/extensions/wikiwyg/images/YouTube_placeholder.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: trunk/extensions/wikiwyg/images/YouTube_placeholder.gif
___________________________________________________________________
Added: svn:mime-type
22 + application/octet-stream
Index: trunk/extensions/wikiwyg/images/unlink.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: trunk/extensions/wikiwyg/images/wikify.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: trunk/extensions/wikiwyg/images/wikify.gif
___________________________________________________________________
Added: svn:mime-type
33 + application/octet-stream
Index: trunk/extensions/wikiwyg/images/www.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: trunk/extensions/wikiwyg/lib/Wikiwyg/Toolbar.js
@@ -118,6 +118,26 @@
119119 this.div.style.display = 'none';
120120 }
121121
 122+proto.setup_widgets_pulldown = function(title) {
 123+ var widgets_list = Wikiwyg.Widgets.widgets;
 124+ var widget_data = Wikiwyg.Widgets.widget;
 125+
 126+ var tb = eval(this.classname).prototype;
 127+
 128+ tb.styleSelector = [ 'label' ];
 129+ for (var i = 0; i < widgets_list.length; i++) {
 130+ var widget = widgets_list[i];
 131+ tb.styleSelector.push('widget_' + widget);
 132+ }
 133+ tb.controlLayout.push('selector');
 134+
 135+ tb.controlLabels.label = title;
 136+ for (var i = 0; i < widgets_list.length; i++) {
 137+ var widget = widgets_list[i];
 138+ tb.controlLabels['widget_' + widget] = widget_data[widget].label;
 139+ }
 140+}
 141+
122142 proto.make_button = function(type, label) {
123143 var base = this.config.imagesLocation;
124144 var ext = this.config.imagesExtension;
@@ -179,7 +199,7 @@
180200 );
181201
182202 var link = Wikiwyg.createElementWithAttrs(
183 - 'a', { href: '#' }
 203+ 'a', { href: '#', id: 'wikiwyg_ctrl_lnk_' + text }
184204 );
185205 link.appendChild(document.createTextNode(text));
186206 span.appendChild(link);
Index: trunk/extensions/wikiwyg/lib/Wikiwyg/Wysiwyg.js
@@ -81,6 +81,28 @@
8282 this.apply_stylesheets();
8383 this.enable_keybindings();
8484 this.clear_inner_html();
 85+ if ( Wikiwyg.is_ie ) {
 86+ var self = this;
 87+ var win = this.get_edit_window();
 88+ var doc = this.get_edit_document();
 89+ self.ieSelectionBookmark = null;
 90+ var bookmark = function() {
 91+ var range = doc.selection.createRange();
 92+ if ( range.getBookmark ) {
 93+ self.ieSelectionBookmark = range.getBookmark();
 94+ }
 95+ }
 96+ doc.attachEvent("onbeforedeactivate", bookmark);
 97+ var restoreBookmark = function() {
 98+ if (self.ieSelectionBookmark) {
 99+ var range = doc.body.createTextRange();
 100+ range.moveToBookmark(self.ieSelectionBookmark);
 101+ range.collapse();
 102+ range.select();
 103+ }
 104+ }
 105+ doc.attachEvent("onactivate", restoreBookmark);
 106+ }
85107 }
86108
87109 proto.clear_inner_html = function() {
@@ -156,8 +178,7 @@
157179 type: 'text/css'
158180 }, head);
159181 */
160 -
161 - style_string += Ajax.get(style.cssRules[i].href);
 182+ style_string += WKWAjax.get(style.cssRules[i].href);
162183 } else {
163184 style_string += style.cssRules[i].cssText + "\n";
164185 }
@@ -201,7 +222,7 @@
202223 proto.apply_linked_stylesheet = function(style, head) {
203224 var link = Wikiwyg.createElementWithAttrs(
204225 'link', {
205 - href: style.href,
 226+ href: style.href,
206227 type: style.type,
207228 media: 'screen',
208229 rel: 'STYLESHEET'
@@ -225,8 +246,65 @@
226247 this.exec_command('formatblock', '<' + command + '>');
227248 }
228249
229 -proto.do_bold = proto.exec_command;
230 -proto.do_italic = proto.exec_command;
 250+proto.checkTags = function () {
 251+
 252+}
 253+
 254+proto.getSelectedStyle = function (strCssRule) {
 255+ var strValue = "";
 256+ oElm = this.getSelectedElement().parentNode ;
 257+ if(document.defaultView && document.defaultView.getComputedStyle){
 258+ strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule);
 259+ }
 260+ else if (oElm.currentStyle){
 261+ strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1){
 262+ return p1.toUpperCase();
 263+ });
 264+ strValue = oElm.currentStyle[strCssRule];
 265+ }
 266+ return strValue;
 267+}
 268+
 269+/* this essentially should get the element we're in */
 270+proto.getSelectedElement = function () {
 271+ /* IE */
 272+ if (Wikiwyg.is_ie) {
 273+ var selection = this.get_edit_document().selection ;
 274+ rng = this.getRng (selection) ;
 275+ var element = rng.item ? rng.item (0) : rng.parentElement () ;
 276+ } else {
 277+ /* FF and stuff */
 278+ var selection = this.edit_iframe.contentWindow.getSelection () ;
 279+ rng = this.getRng (selection) ;
 280+ var element = rng.commonAncestorContainer ;
 281+ }
 282+ return element ;
 283+}
 284+
 285+proto.getRng = function (selection) {
 286+ if (selection == null) {
 287+ return false ;
 288+ }
 289+ if (Wikiwyg.is_ie) {
 290+ return selection.createRange () ;
 291+ } else {
 292+ if (selection.rangeCount > 0) {
 293+ return selection.getRangeAt (0) ;
 294+ }
 295+ }
 296+}
 297+
 298+proto.do_bold = function () {
 299+ /* set the switch and select mode if necessary */
 300+ this.getSelectedStyle ('font-weight') ;
 301+ this.exec_command ('bold') ;
 302+}
 303+
 304+proto.do_italic = function () {
 305+ /* set the switch and select mode if necessary */
 306+ this.exec_command ('italic') ;
 307+}
 308+
231309 proto.do_underline = proto.exec_command;
232310 proto.do_strike = function() {
233311 this.exec_command('strikethrough');
@@ -275,13 +353,19 @@
276354 var selection = this.get_link_selection_text();
277355 if (! selection) return;
278356 var url;
279 - var match = selection.match(/(.*?)\b((?:http|https|ftp|irc|file):\/\/\S+)(.*)/);
 357+ url = prompt("Enter the link or leave blank to link to selected page", "Type in your link here");
 358+ /* if blank, get selection */
 359+ if (!url) {
 360+ url = selection ;
 361+ }
 362+
 363+ var match = url.match(/(.*?)\b((?:http|https|ftp|irc|file):\/\/\S+)(.*)/);
280364 if (match) {
281365 if (match[1] || match[3]) return null;
282366 url = match[2];
283367 }
284368 else {
285 - url = '?' + escape(selection);
 369+ url = '?' + escape(url);
286370 }
287371 this.exec_command('createlink', url);
288372 }
@@ -342,6 +426,40 @@
343427 range.select();
344428 }
345429
 430+proto.get_inner_html = function( cb ) {
 431+ if ( cb ) {
 432+ this.get_inner_html_async( cb );
 433+ return;
 434+ }
 435+ return this.get_edit_document().body.innerHTML;
 436+}
 437+
 438+proto.get_inner_html_async = function( cb ) {
 439+ var self = this;
 440+ var doc = this.get_edit_document();
 441+ if ( doc.readyState == 'loading' ) {
 442+ setTimeout( function() {
 443+ self.get_inner_html(cb);
 444+ }, 50);
 445+ } else {
 446+ var html = this.get_edit_document().body.innerHTML;
 447+ cb(html);
 448+ return html;
 449+ }
 450+}
 451+
 452+proto.set_inner_html = function(html) {
 453+ var self = this;
 454+ var doc = this.get_edit_document();
 455+ if ( doc.readyState == 'loading' ) {
 456+ setTimeout( function() {
 457+ self.set_inner_html(html);
 458+ }, 50);
 459+ } else {
 460+ this.get_edit_document().body.innerHTML = html;
 461+ }
 462+}
 463+
346464 // Use IE's design mode default key bindings for now.
347465 proto.enable_keybindings = function() {}
348466
Index: trunk/extensions/wikiwyg/lib/Wikiwyg/Wikitext.js
@@ -646,9 +646,9 @@
647647
648648 proto.normalize_span_whitespace = function(dom,tag ) {
649649 var grep = function(element) {
650 - return Boolean(element.getAttribute('style'));
 650+ return Boolean(element.getAttribute('style'));
651651 }
652 -
 652+
653653 var elements = this.array_elements_by_tag_name(dom, tag, grep);
654654 for (var i = 0; i < elements.length; i++) {
655655 var element = elements[i];
@@ -676,13 +676,22 @@
677677 for (var i = 0; i < elements.length; i++) {
678678 var element = elements[i];
679679 var style = element.getAttribute('style');
680 - if (!style) continue;
 680+ if (!style || this.style_is_bogus(style)) continue;
681681 element.removeAttribute('style');
682682 element.innerHTML =
683683 '<span style="' + style + '">' + element.innerHTML + '</span>';
684684 }
685685 }
686686
 687+proto.style_is_bogus = function(style) {
 688+ var attributes = [ 'line-through', 'bold', 'italic', 'underline' ];
 689+ for (var i = 0; i < attributes.length; i++) {
 690+ if (this.check_style_for_attribute(style, attributes[i]))
 691+ return false;
 692+ }
 693+ return true;
 694+}
 695+
687696 proto.normalize_styled_lists = function(dom, tag) {
688697 var elements = this.array_elements_by_tag_name(dom, tag);
689698 for (var i = 0; i < elements.length; i++) {
@@ -742,6 +751,16 @@
743752 var last_node = this.getLastTextNode(element);
744753 var next_node = this.getNextTextNode(element);
745754
 755+ // This if() here is for a special condition on firefox.
 756+ // When a bold span is the last visible thing in the dom,
 757+ // Firefox puts an extra <br> in right before </span> when user
 758+ // press space, while normally it put &nbsp;.
 759+
 760+ if(Wikiwyg.is_gecko && element.tagName == 'SPAN') {
 761+ var tmp = element.innerHTML;
 762+ element.innerHTML = tmp.replace(/<br>$/i, '');
 763+ }
 764+
746765 if (this.destroyPhraseMarkup(element)) return;
747766
748767 if (first_node && first_node.nodeValue.match(/^ /)) {
@@ -789,12 +808,12 @@
790809 if (! last_node) return true;
791810 if (last_node.nodeValue.match(/ $/)) return false;
792811 if (! next_node || next_node.nodeValue == '\n') return false;
793 - return ! next_node.nodeValue.match(/^[ ."\n]/);
 812+ return ! next_node.nodeValue.match(Wikiwyg.Wikitext.phrase_end_re);
794813 }
795814
796815 proto.destroyElement = function(element) {
797 - var span = document.createElement('font');
798 - span.innerHTML = element.innerHTML;
 816+ var value = element.innerHTML;
 817+ var span = document.createTextNode(value);
799818 element.parentNode.replaceChild(span, element);
800819 return true;
801820 }
@@ -852,18 +871,23 @@
853872 proto.walk = function(element) {
854873 if (!element) return;
855874 for (var part = element.firstChild; part; part = part.nextSibling) {
856 - if (part.nodeType == 1) {
 875+ /* Saving the part's properties in local vars seems to give us
 876+ * a minor speed boost in this method, which can be called
 877+ * thousands of times for large documents. */
 878+ var nodeType = part.nodeType;
 879+ if (nodeType == 1) {
857880 this.dispatch_formatter(part);
858881 }
859 - else if (part.nodeType == 3) {
860 - if (part.nodeValue.match(/[^\n]/) &&
861 - ! part.nodeValue.match(/^\n[\ \t]*$/)
 882+ else if (nodeType == 3) {
 883+ var nodeValue = part.nodeValue;
 884+ if (nodeValue.match(/[^\n]/) &&
 885+ ! nodeValue.match(/^\n[\n\ \t]*$/)
862886 ) {
863887 if (this.no_collapse_text) {
864 - this.appendOutput(part.nodeValue);
 888+ this.appendOutput(nodeValue);
865889 }
866890 else {
867 - this.appendOutput(this.collapse(part.nodeValue));
 891+ this.appendOutput(this.collapse(nodeValue));
868892 }
869893 }
870894 }
@@ -1023,6 +1047,15 @@
10241048 }
10251049
10261050 proto.format_span = function(element) {
 1051+ // This fixes a mysterious wrapper SPAN in IE for the "asap" link.
 1052+ if (element.firstChild &&
 1053+ element.firstChild.nodeName == 'SPAN' &&
 1054+ (! (element.style && element.style.fontWeight != '')) &&
 1055+ element.firstChild == element.lastChild
 1056+ ) {
 1057+ this.walk(element);
 1058+ return;
 1059+ }
10271060 if (this.is_opaque(element)) {
10281061 this.handle_opaque_phrase(element);
10291062 return;
@@ -1034,8 +1067,8 @@
10351068 return;
10361069 }
10371070
1038 - if ( ! this.element_has_text_content(element)
1039 - && ! this.element_has_only_image_content(element)) return;
 1071+ if (! this.element_has_text_content(element) &&
 1072+ ! this.element_has_only_image_content(element)) return;
10401073 var attributes = [ 'line-through', 'bold', 'italic', 'underline' ];
10411074 for (var i = 0; i < attributes.length; i++)
10421075 this.check_style_and_maybe_mark_up(style, attributes[i], 1);
@@ -1402,8 +1435,10 @@
14031436 proto.get_wiki_comment = function(element) {
14041437 for (var node = element.firstChild; node; node = node.nextSibling) {
14051438 if (node.nodeType == this.COMMENT_NODE_TYPE
1406 - && node.data.match(/^\s*wiki/))
 1439+ && node.data.match(/^\s*wiki/)
 1440+ ) {
14071441 return node;
 1442+ }
14081443 }
14091444 return null;
14101445 }
@@ -1438,16 +1473,9 @@
14391474
14401475 proto.smart_trailing_space = function(element) {
14411476 var next = element.nextSibling;
1442 - if (! next) {
1443 - // do nothing
1444 - }
1445 - else if (next.nodeType == 1) {
1446 - if (next.nodeName == 'BR') {
1447 - var nn = next.nextSibling;
1448 - if (! (nn && nn.nodeType == 1 && nn.nodeName == 'SPAN'))
1449 - this.appendOutput('\n');
1450 - }
1451 - else {
 1477+ if (! next) return;
 1478+ if (next.nodeType == 1) {
 1479+ if (next.nodeName != 'BR') {
14521480 this.appendOutput(' ');
14531481 }
14541482 }
@@ -1475,7 +1503,7 @@
14761504 before = this.config.markupRules.www[1];
14771505 after = this.config.markupRules.www[2];
14781506 }
1479 -
 1507+
14801508 this.assert_space_or_newline();
14811509 if (! href) {
14821510 this.appendOutput(label);
@@ -1486,8 +1514,13 @@
14871515 else if (this.href_is_wiki_link(href)) {
14881516 if (this.camel_case_link(label))
14891517 this.appendOutput(label);
1490 - else
1491 - this.appendOutput(before + label + after);
 1518+ else {
 1519+ if (label != href) {
 1520+ this.appendOutput(before + href.substring(1) + '|' + label + after);
 1521+ } else {
 1522+ this.appendOutput (before + label + after) ;
 1523+ }
 1524+ }
14921525 }
14931526 else {
14941527 this.appendOutput(before + href + ' ' + label + after);
@@ -1505,7 +1538,7 @@
15061539 return true;
15071540 if (! href.match(/\?/))
15081541 return false;
1509 - if (href.match(/\/static\/\d+\.\d+\.\d+\.\d+\//))
 1542+ if (href.match(/\/static\//) && href.match(/\/js-test\//))
15101543 href = location.href;
15111544 var no_arg_input = href.split('?')[0];
15121545 var no_arg_current = location.href.split('?')[0];
Index: trunk/extensions/wikiwyg/lib/Wikiwyg/Util.js
@@ -48,7 +48,7 @@
4949
5050 // getStyle()
5151 // http://www.robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/
52 -function getStyle(oElm, strCssRule) {
 52+function WKWgetStyle(oElm, strCssRule) {
5353 var strValue = "";
5454 if(document.defaultView && document.defaultView.getComputedStyle){
5555 strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule);
@@ -154,25 +154,25 @@
155155 //------------------------------------------------------------------------------
156156 // Ajax support
157157 //------------------------------------------------------------------------------
158 -if (! this.Ajax) Ajax = {};
 158+if (! this.WKWAjax) WKWAjax = {};
159159
160 -Ajax.get = function(url, callback) {
 160+WKWAjax.get = function(url, callback) {
161161 var req = new XMLHttpRequest();
162162 req.open('GET', url, Boolean(callback));
163 - return Ajax._send(req, null, callback);
 163+ return WKWAjax._send(req, null, callback);
164164 }
165165
166 -Ajax.post = function(url, data, callback) {
 166+WKWAjax.post = function(url, data, callback) {
167167 var req = new XMLHttpRequest();
168168 req.open('POST', url, Boolean(callback));
169169 req.setRequestHeader(
170170 'Content-Type',
171171 'application/x-www-form-urlencoded'
172172 );
173 - return Ajax._send(req, data, callback);
 173+ return WKWAjax._send(req, data, callback);
174174 }
175175
176 -Ajax._send = function(req, data, callback) {
 176+WKWAjax._send = function(req, data, callback) {
177177 if (callback) {
178178 req.onreadystatechange = function() {
179179 if (req.readyState == 4) {
Index: trunk/extensions/wikiwyg/lib/Wikiwyg/Preview.js
@@ -37,7 +37,7 @@
3838 if (this.config.divId)
3939 this.div = document.getElementById(this.config.divId);
4040 else
41 - this.div = document.createElement('div');
 41+ this.div = document.createElement('span');
4242 // XXX Make this a config option.
4343 this.div.style.backgroundColor = 'lightyellow';
4444 }
Index: trunk/extensions/wikiwyg/lib/Wikiwyg.js
@@ -274,13 +274,13 @@
275275 // This method is deprecated. Use Ajax.get and Ajax.post.
276276 Wikiwyg.liveUpdate = function(method, url, query, callback) {
277277 if (method == 'GET') {
278 - return Ajax.get(
 278+ return WKWAjax.get(
279279 url + '?' + query,
280280 callback
281281 );
282282 }
283283 if (method == 'POST') {
284 - return Ajax.post(
 284+ return WKWAjax.post(
285285 url,
286286 query,
287287 callback
Index: trunk/extensions/wikiwyg/COPYRIGHT
@@ -3,6 +3,8 @@
44 Palo Alto, CA 94301 U.S.A.
55 All rights reserved.
66
 7+ Copyright (c) 2007, Wikia Inc.
 8+
79 Wikiwyg is free software.
810
911 This library is free software; you can redistribute it and/or modify it
Index: trunk/extensions/wikiwyg/Changes
@@ -9,7 +9,7 @@
1010 changes:
1111 - Lots
1212 ---
13 -version: 0.10
14 -date: Tue Aug 16 15:08:07 PDT 2005
 13+version: 0.20
 14+date: Wed Aug 1 14:20:09 UTC 2007
1515 changes:
16 -- Initial release
 16+- Lots
Index: trunk/extensions/wikiwyg/AUTHORS
@@ -8,3 +8,4 @@
99 Dave Rolsky <autarch@urth.org>
1010 Kang-min Liu <gugod@gugod.org>
1111 Jason Richey <jasonr@wikia.com>
 12+ Bartek Lapinski <bartek@wikia.com>
Index: trunk/extensions/wikiwyg/share/MediaWiki/extensions/WikiwygEditing/WikiwygEditing.php
@@ -0,0 +1,184 @@
 2+<?PHP
 3+
 4+global $wgHooks;
 5+$wgHooks['EditPage::showEditForm:initial'][] = 'WikiwygAlternateEdit' ;
 6+$wgHooks['EditForm:BeforeDisplayingTextbox'][] = 'WikiwygHideTextarea' ;
 7+$wgHooks['EditForm::AfterEdit:Form'][] = 'WikiwygEditTagCloud' ;
 8+
 9+$wgExtensionFunctions[] = 'registerWikiwygEditing';
 10+$wgExtensionCredits['other'][] = array(
 11+ 'name' => 'WikiwygEditing' ,
 12+ 'author' => 'Bartek Lapinski' ,
 13+ 'version' => 1.0 ,
 14+ 'url' => 'http://www.wikia.com' ,
 15+ 'description' => 'Mediawiki integration of the Wikiwyg WYSIWYG wiki editor - for full page editing '
 16+);
 17+
 18+function registerWikiwygEditing () {
 19+}
 20+
 21+
 22+function wfIsCategoryCloudAllowed ($epage) {
 23+ global $wgRequest ;
 24+ if (($epage->mArticle->mTitle->getNamespace() != NS_MAIN) || ($wgRequest->getVal ('categoryCloud') == 'off' ) ) {
 25+ /* allow parameter override */
 26+ if ($wgRequest->getVal ('categoryCloud') != 'on' ) {
 27+ return false ;
 28+ }
 29+ }
 30+ return true ;
 31+}
 32+
 33+function WikiwygAlternateEdit ($epage) {
 34+ global $wgOut,$wgSkin,$jsdir,$cssdir;
 35+ global $wgWikiwygPath;
 36+ global $wgServer,$wgWikiwygJsPath,$wgWikiwygCssPath,$wgWikiwygImagePath,$wgStyleVersion;
 37+ global $wgUser, $wgMessageCache, $wgServer, $wgArticlePath, $wgEnableAjaxLogin ;
 38+
 39+ $wgMessageCache->addMessages(
 40+ array(
 41+ 'wikiwyg_editing_option' => 'you can switch to old editor in preferences $1' ,
 42+ 'wikiwyg_use_cloud' => ', for editing with CategoryCloud, use $1 link' ,
 43+ 'wikiwyg_editing_here' => 'here' ,
 44+ 'wikiwyg_editing_this' => 'this'
 45+ )
 46+ );
 47+
 48+ /* in-page disabled automatically disables this loading */
 49+ if ( wfGetDependingOnSkin () == 0 ) {
 50+ return true ;
 51+ }
 52+ if (! isset($wgWikiwygPath)) {
 53+ $wgWikiwygPath = $wgScriptPath . "/extensions/wikiwyg";
 54+ }
 55+ if (! isset($wgWikiwygJsPath)) {
 56+ $wgWikiwygJsPath = "$wgWikiwygPath/share/MediaWiki";
 57+ }
 58+ if (! isset($wgWikiwygCssPath)) {
 59+ $wgWikiwygCssPath = "$wgWikiwygPath/share/MediaWiki/css";
 60+ }
 61+ if (! isset($wgWikiwygImagePath)) {
 62+ $wgWikiwygImagePath = "$wgWikiwygPath/share/MediaWiki/images";
 63+ }
 64+
 65+ $wgOut->addScript("<style type=\"text/css\" media=\"screen,projection\">/*<![CDATA[*/ @import \"$wgWikiwygCssPath/MediaWikiwyg.css\"; /*]]>*/</style>\n");
 66+ $wgOut->addScript("<script type=\"text/javascript\" src=\"$wgWikiwygJsPath/extensions/WikiwygEditing/js/editpage.js?$wgStyleVersion\"></script>\n");
 67+
 68+ if (! isset($wgEnableAjaxLogin) || ($wgEnableAjaxLogin == false)) {
 69+ $wgEnableAjaxLogin = 0 ;
 70+ }
 71+
 72+ $wgOut->addScript("
 73+ <script type=\"text/javascript\">
 74+ if (typeof(Wikiwyg) == 'undefined') Wikiwyg = function() {};
 75+ Wikiwyg.mediawiki_source_path = \"$wgWikiwygPath\";
 76+ var wgEnableAjaxLogin = $wgEnableAjaxLogin ;
 77+ </script>
 78+");
 79+
 80+ $wgOut->addScript("<script type=\"text/javascript\" src=\"$wgWikiwygJsPath/MediaWikiWyg.js\"></script>\n");
 81+ $fixed_art_path = preg_replace ('/\$1/', "", $wgArticlePath) ;
 82+
 83+ $alternate_link = "<a href=\"".$fixed_art_path."Special:Preferences#prefsection-4\" >".wfMsg ('wikiwyg_editing_here')."</a>" ;
 84+ $has_cloud = wfIsCategoryCloudAllowed ($epage) ;
 85+
 86+ $subtitle_text = wfMsg ('wikiwyg_editing_option', $alternate_link) ;
 87+ if ($has_cloud) {
 88+ $nocloud_link = "<a href=\"".$fixed_art_path.$epage->mArticle->mTitle->getPrefixedUrl()."?action=edit&categoryCloud=off\" >".wfMsg ('wikiwyg_editing_this')."</a>" ;
 89+ } else {
 90+ $nocloud_link = "<a href=\"".$fixed_art_path.$epage->mArticle->mTitle->getPrefixedUrl()."?action=edit&categoryCloud=on\" >".wfMsg ('wikiwyg_editing_this')."</a>" ;
 91+ $subtitle_text .= wfMsg('wikiwyg_use_cloud', $nocloud_link) ;
 92+ }
 93+
 94+ $wgOut->addHTML ("<div id=\"wikiwyg_cancel_form\" style=\"display:none;\">
 95+ <form id=\"wikiwyg_toggle_editor\" action=\"\" >
 96+ ".$subtitle_text) ;
 97+
 98+ $wgOut->addHTML ("</form>
 99+ </div>") ;
 100+ $wgOut->addHTML ("<div id=\"backup_textarea_placeholder\"></div>") ;
 101+ return true ;
 102+}
 103+
 104+function WikiwygHideTextarea ($epage, $hidden) {
 105+ global $wgOut ;
 106+ if (wfGetDependingOnSkin () == 1) {
 107+ $hidden = 'style="display:none;"' ;
 108+ $wgOut->addHTML ("<div id=\"WikiwygEditingLoadingMesg\" style=\"font-weight:bold\">Loading...</div>") ;
 109+ $wgOut->addHTML ("<div id=\"WikiwygEditingUpperToolbar\" style=\"display:none; float: clear;\">
 110+ <div style=\"float: right\"><a href=\"#article\">Return to editing</a></div>
 111+ <div><a href=\"#article\">Return to editing</a></div>
 112+ </div>") ;
 113+ $wgOut->addHTML ("<div id=\"WikiwygEditingPreviewArea\" style=\"display:none\"></div>") ;
 114+ /* allow for users not having js enabled to edit too */
 115+ $wgOut->addHTML ("
 116+ <noscript>
 117+ <style type=\"text/css\">
 118+ #wpTextbox1 {
 119+ display: block !important ;
 120+ }
 121+ #WikiwygEditingLoadingMesg, #wikiwyg_lower_wrapper {
 122+ display: none ;
 123+ }
 124+ </style>
 125+ </noscript>
 126+ ") ;
 127+ }
 128+ return true ;
 129+}
 130+
 131+function WikiwygEditTagCloud ($epage) {
 132+ global $wgOut, $wgRequest ;
 133+ if (wfGetDependingOnSkin () == 1) {
 134+ /* only for NS_MAIN, except on override */
 135+ if ( !wfIsCategoryCloudAllowed ($epage) ) {
 136+ return true ;
 137+ }
 138+ require_once($IP. 'extensions/TagCloud/TagCloudClass.php') ;
 139+
 140+ $MyCloud = new TagCloud ;
 141+ $num = 0 ;
 142+ $cloud_html = '' ;
 143+
 144+ if (is_array ($MyCloud->tags)) {
 145+ foreach ($MyCloud->tags as $name => $tag) {
 146+ /* take care of the sorting parameter */
 147+ $core_name = str_replace('/|.*/','',$name) ;
 148+ $cloud_html .= "<span id=\"tag-$num\" style=\"font-size:". $tag["size"]."pt\">
 149+ <a href=\"#\" id=\"cloud_$num\" onclick=\"EditPageAddCategory ('$name', $num) ; return false ;\">$core_name</a>
 150+ </span>" ;
 151+ $num++ ;
 152+ }
 153+ }
 154+
 155+ $wgOut->addHTML ("
 156+ <br/>
 157+ <div id=\"wikiwyg_lower_wrapper\">
 158+ <table id=\"editpage_table\">
 159+ <tr>
 160+ <td class=\"editpage_header\">".wfMsg ('edit-summary').":</td>
 161+ <td id=\"editpage_summary_td\"></td>
 162+ </tr>
 163+ <tr style=\"padding: 6px 0px 6px 0px\">
 164+ <td class=\"editpage_header\">&nbsp;</td>
 165+ <td>".wfMsg ('createpage_categories_help')."</td>
 166+ </tr>
 167+ <tr>
 168+ <td class=\"editpage_header\">".wfMsg ('createpage_categories')."</td>
 169+ <td>
 170+ <span id=\"category_textarea_placeholder\"></span>
 171+ <div id=\"category_cloud_wrapper\" style=\"display: none\" class=\editpage_inside\">
 172+ <div id=\"editpage_cloud_section\" style=\"line-height: 22pt; border: 1px solid gray; padding: 15px 15px 15px 15px\">
 173+ ".$cloud_html."
 174+ </div>
 175+ </td>
 176+ </tr>
 177+ </table>
 178+ </div>
 179+ <input type=\"hidden\" name=\"wpCategoryTagCount\", id=\"category_tag_count\" value=\"$num\" />
 180+ ") ;
 181+ }
 182+ return true ;
 183+}
 184+
 185+?>
Property changes on: trunk/extensions/wikiwyg/share/MediaWiki/extensions/WikiwygEditing/WikiwygEditing.php
___________________________________________________________________
Added: svn:eol-style
1186 + native
Index: trunk/extensions/wikiwyg/share/MediaWiki/extensions/WikiwygEditing/js/editpage.js
@@ -0,0 +1,722 @@
 2+
 3+/*
 4+ @author Bartek Lapinski
 5+ @copyright Copyright © 2007, Wikia Inc.
 6+ @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
 7+*/
 8+
 9+var WikiwygInstance ;
 10+var wgFullPageEditing = true ;
 11+
 12+/* copied and adapted from upload image script... */
 13+// apply tagOpen/tagClose to selection in textarea,
 14+// use sampleText instead of selection if there is none
 15+// copied and adapted from phpBB
 16+function WKWinsertTags(tagOpen, tagClose, sampleText) {
 17+ if (WikiwygInstance.enabled) {
 18+ var out = WikiwygInstance.current_mode ;
 19+ out.insert_html (tagOpen + sampleText + tagClose) ;
 20+ }
 21+}
 22+
 23+/* fall back if edit mode not supported - provide a normal interface */
 24+EditPageFallBack = function () {
 25+ /* todo give standard edit toolbar */
 26+ document.insertTags = insertTags ;
 27+ WikiwygInstance.textbox.style.display = '' ;
 28+ document.getElementById ('WikiwygEditingLoadingMesg').style.display = 'none' ;
 29+}
 30+
 31+document.insertTags = WKWinsertTags ;
 32+
 33+function EditPageShowSection (section) {
 34+ var this_section = document.getElementById ('editpage_' + section + '_section') ;
 35+ var show_this = document.getElementById ('editpage_show_' + section) ;
 36+ var hide_this = document.getElementById ('editpage_hide_' + section) ;
 37+
 38+ this_section.style.display = '' ;
 39+ show_this.style.display = 'none' ;
 40+ hide_this.style.display = '' ;
 41+}
 42+
 43+function EditPageHideSection (section) {
 44+ var this_section = document.getElementById ('editpage_' + section + '_section') ;
 45+ var show_this = document.getElementById ('editpage_show_' + section) ;
 46+ var hide_this = document.getElementById ('editpage_hide_' + section) ;
 47+
 48+ this_section.style.display = 'none' ;
 49+ show_this.style.display = '' ;
 50+ hide_this.style.display = 'none' ;
 51+}
 52+
 53+function EditPageAddCategory (category, num) {
 54+ if (category != '') {
 55+ var category_field = document.getElementById ('category_textarea') ;
 56+ category = unescape (category) ;
 57+ if (category_field.value == '') {
 58+ category_field.value += category ;
 59+ } else {
 60+ category_field.value += ',' + category ;
 61+ }
 62+ this_button = document.getElementById ('cloud_'+ num) ;
 63+ this_span = document.getElementById ('tag-' + num) ;
 64+ this_button.onclick = function() { eval("EditPageRemoveCategory('" + escape(category) + "', " + num + ")"); return false };
 65+ this_button.style["color"] = "#419636" ;
 66+ }
 67+}
 68+function EditPageRemoveCategory (category, num) {
 69+ var category_field = document.getElementById('category_textarea') ;
 70+ category_text = category_field.value ;
 71+ category = unescape (category) ;
 72+ this_pos = category_text.indexOf(category) ;
 73+ if (this_pos != -1) {
 74+ category_text = category_text.substr (0, this_pos-1 ) + category_text.substr (this_pos + category.length) ;
 75+ category_field.value = category_text ;
 76+ }
 77+
 78+ this_button = document.getElementById ('cloud_'+ num) ;
 79+ category = category.replace (/\|.*/,'') ;
 80+ this_button.onclick = function() { eval("EditPageAddCategory('" + escape(category) + "', " + num + ")"); return false };
 81+ this_button.style["color"] = "" ;
 82+}
 83+
 84+
 85+/* modified function for image upload (omitting HACK section for non-existing watchthis link) */
 86+var imageUploadDialog = null;
 87+
 88+function fixupRelativeUrl(url) {
 89+ var loc = String(location);
 90+ var base = loc.replace(/index\.php.*/, '');
 91+ if (base == loc)
 92+ base = loc.replace(/(.*\/wiki\/).*/, '$1');
 93+ if (base == loc)
 94+ throw("fixupRelativeUrl error: " + loc);
 95+ return base + url;
 96+}
 97+
 98+window.onbeforeunload = confirmExit ;
 99+
 100+window.onload = function() {
 101+ var editform = document.getElementById ('editform') ;
 102+ var edit_text = document.getElementById ('wpTextbox1') ;
 103+ var wiki_diff = document.getElementById ('wikiDiff') ;
 104+
 105+ if (wiki_diff) {
 106+ var upper_toolbar = document.getElementById ('WikiwygEditingUpperToolbar') ;
 107+ var new_upper_toolbar = Wikiwyg.createElementWithAttrs ('div', {id: 'WikiwygEditingUpperToolbarBis'}) ;
 108+ new_upper_toolbar.innerHTML = upper_toolbar.innerHTML ;
 109+ wiki_diff.parentNode.insertBefore (new_upper_toolbar, wiki_diff) ;
 110+ }
 111+
 112+ var subtitle = document.getElementById ('contentSub') ;
 113+ var cp_subtitle = document.getElementById ('wikiwyg_cancel_form') ;
 114+ var copywarn = document.getElementById ('editpage-copywarn') ;
 115+ copywarn.style.display = 'none' ;
 116+ subtitle.innerHTML = cp_subtitle.innerHTML ;
 117+ var summary_holder = document.getElementById ('wpSummaryLabel').firstChild ;
 118+ summary_holder.innerHTML = wgSummaryCaption + ':' ;
 119+ var content = edit_text.value ;
 120+
 121+ var templates_used = document.getElementById ('templates_used_explanation') ;
 122+ var editpage_table = document.getElementById ('editpage_table') ;
 123+
 124+ if (templates_used) {
 125+ templates_used.style.display = 'none' ;
 126+ var templates_list = document.getElementById ('templates_used_list') ;
 127+ templates_list.style.display = 'none' ;
 128+ var templates_tr = document.createElement ('tr') ;
 129+ var templates_td_header = Wikiwyg.createElementWithAttrs ('td', {'class': 'editpage_header'}) ;
 130+ var templates_container = Wikiwyg.createElementWithAttrs ('div', {'style': 'border: 1px solid gray; '}) ;
 131+ var templates_list_ul = document.createElement ('ul') ;
 132+ templates_td_header.appendChild (document.createTextNode('Templates:')) ;
 133+ var templates_td_body = document.createElement ('td') ;
 134+ templates_list_ul.innerHTML = templates_list.innerHTML ;
 135+ templates_list_ul.innerHTML += '<li class="last"></li>'
 136+ templates_container.appendChild (templates_list_ul) ;
 137+ templates_td_body.appendChild (templates_container) ;
 138+ templates_tr.appendChild (templates_td_header) ;
 139+ templates_tr.appendChild (templates_td_body) ;
 140+ editpage_table.appendChild (templates_tr) ;
 141+ }
 142+
 143+ /* remove those, move to the template table */
 144+ var summaryInput = document.getElementById ('wpSummary') ;
 145+ var summaryTd = document.getElementById ('editpage_summary_td') ;
 146+ var old_sum_text = summaryInput.value ;
 147+ if (summaryInput) {
 148+ summaryInput.parentNode.removeChild (summaryInput) ;
 149+ var newSummaryInput = Wikiwyg.createElementWithAttrs ('input',
 150+ {'id': 'wpSummary' ,
 151+ 'name': 'wpSummary' ,
 152+ 'type': 'text' ,
 153+ 'value': '' ,
 154+ 'style': 'width: 360px !important'
 155+ }) ;
 156+ newSummaryInput.value = old_sum_text ;
 157+ summaryTd.appendChild (newSummaryInput) ;
 158+ /* clean up too */
 159+ var summaryLabel = getLabelFor ('wpSummary') ;
 160+ summaryLabel.parentNode.removeChild (summaryLabel) ;
 161+ }
 162+
 163+ var minorInput = document.getElementById ('wpMinoredit') ;
 164+ if (minorInput) {
 165+ minorInput.parentNode.removeChild (minorInput) ;
 166+ var minorInputLabel = getLabelFor ('wpMinoredit') ;
 167+ var minorInputText = minorInputLabel.innerHTML ;
 168+ minorInputLabel.parentNode.removeChild (minorInputLabel) ;
 169+ /* add input plus label */
 170+ var newMinorInput = Wikiwyg.createElementWithAttrs ('input',
 171+ {'id': 'wpMinoredit' ,
 172+ 'name': 'wpMinoredit' ,
 173+ 'type': 'checkbox' ,
 174+ 'value': '1' ,
 175+ 'accesskey': 'i'
 176+ }) ;
 177+ var newMinorInputLabel = Wikiwyg.createElementWithAttrs ('label',
 178+ {'for': 'wpMinoredit' ,
 179+ 'accesskey': 'i' ,
 180+ 'title': '' ,
 181+ 'class': 'no-float'
 182+ }) ;
 183+ newMinorInputLabel.innerHTML = minorInputText ;
 184+ summaryTd.appendChild (newMinorInput) ;
 185+ summaryTd.appendChild (newMinorInputLabel) ;
 186+ }
 187+
 188+ var watchthisInput = document.getElementById ('wpWatchthis') ;
 189+ if (watchthisInput) {
 190+ watchthisInput.parentNode.removeChild (watchthisInput) ;
 191+ var watchthisLabel = getLabelFor ('wpWatchthis') ;
 192+ var watchthisText = watchthisLabel.innerHTML ;
 193+ watchthisLabel.parentNode.removeChild (watchthisLabel) ;
 194+ /* add input plus label */
 195+ var newWatchthisInput = Wikiwyg.createElementWithAttrs ('input',
 196+ {'id': 'wpWatchthis' ,
 197+ 'name': 'wpWatchthis' ,
 198+ 'type': 'checkbox' ,
 199+ 'value': '1' ,
 200+ 'accesskey': 'w',
 201+ 'checked': 'checked'
 202+ }) ;
 203+ var newWatchthisInputLabel = Wikiwyg.createElementWithAttrs ('label',
 204+ {'for': 'wpWatchthis' ,
 205+ 'accesskey': 'w' ,
 206+ 'title': '' ,
 207+ 'class': 'no-float'
 208+ }) ;
 209+ newWatchthisInputLabel.innerHTML = watchthisText ;
 210+ summaryTd.appendChild (newWatchthisInput) ;
 211+ summaryTd.appendChild (newWatchthisInputLabel) ;
 212+ }
 213+
 214+ var WikiwygDiv = document.createElement ('div') ;
 215+ WikiwygDiv.setAttribute ('id','wikiwyg') ;
 216+
 217+ var WikiwygIframe = document.createElement ('iframe') ;
 218+ WikiwygIframe.setAttribute ('id','wikiwyg-iframe') ;
 219+ WikiwygIframe.setAttribute ('height','0') ;
 220+ WikiwygIframe.setAttribute ('width','0') ;
 221+ WikiwygIframe.setAttribute ('frameborder','0') ;
 222+ document.editform.insertBefore (WikiwygIframe, edit_text) ;
 223+ document.editform.insertBefore (WikiwygDiv, WikiwygIframe) ;
 224+
 225+ var WikiwygConfig = {
 226+ doubleClickToEdit: true ,
 227+ editHeightMinimum: 300 ,
 228+ wysiwyg: {
 229+ iframeId: 'wikiwyg-iframe'
 230+ },
 231+ toolbar: {
 232+ imagesLocation: wgScriptPath + '/extensions/wikiwyg/share/MediaWiki/images/',
 233+ markupRules: {
 234+ link: ['bound_phrase', '[', ']']
 235+ },
 236+ controlLayout: [
 237+ 'bold' ,
 238+ 'italic' ,
 239+ 'strike' ,
 240+ 'www' ,
 241+ 'link',
 242+ 'h1' ,
 243+ 'h2' ,
 244+ 'h3' ,
 245+ 'h4' ,
 246+ 'pre',
 247+ 'hr' ,
 248+ 'unordered' ,
 249+ 'ordered' ,
 250+ '|l' ,
 251+ 'insertimage' ,
 252+ '|l' ,
 253+ 'help' ,
 254+ '[' ,
 255+ 'mode_selector' ,
 256+ '|r' ,
 257+ 'save' ,
 258+ '|r' ,
 259+ 'cancel' ,
 260+ ']'
 261+
 262+ ]
 263+ },
 264+ modeClasses: [
 265+ 'Wikiwyg.Wysiwyg.Custom' ,
 266+ 'Wikiwyg.Wikitext.Custom' ,
 267+ 'Wikiwyg.Preview.Custom'
 268+ ]
 269+ } ;
 270+ if (wgUseWysiwyg == 0) {
 271+ WikiwygConfig.modeClasses.shift () ;
 272+ }
 273+
 274+ WikiwygInstance = new Wikiwyg.Test () ;
 275+ WikiwygInstance.textbox = edit_text ;
 276+ WikiwygInstance.createWikiwygArea(WikiwygDiv, WikiwygConfig);
 277+
 278+ if (WikiwygInstance.enabled) {
 279+ setTimeout("WikiwygInstance.editMode();",400);
 280+ needToConfirm = true ;
 281+ WikiwygInstance.textbox.style.display = 'none' ;
 282+ document.getElementById ('WikiwygEditingLoadingMesg').style.display = 'none' ;
 283+ document.getElementById ('toolbar').style.display = 'none' ;
 284+ var anchor = Wikiwyg.createElementWithAttrs ('a', {'name': 'article'}) ;
 285+ var anchor_div = Wikiwyg.createElementWithAttrs ('div', {id: 'WikiwygEditingAnchor'}) ;
 286+ anchor_div.appendChild (anchor) ;
 287+
 288+ var SaveLink = document.getElementById ('wpSave') ;
 289+ var ButtonsPanel = SaveLink.parentNode ;
 290+ ButtonsPanel.style.display = 'none' ;
 291+ WikiwygInstance.toolbarObject.placeLowerLinksSection () ;
 292+ WikiwygInstance.insert_clean_after (editpage_table, WikiwygInstance.toolbarObject.linksDiv) ;
 293+ WikiwygInstance.insert_clean_after (WikiwygInstance.toolbarObject.div, anchor_div) ;
 294+ Event.addListener ('wikiwyg_ctrl_lnk_showLicense_wikiwyg', 'click', YAHOO.Wikia.Wikiwyg.showLicensePanel) ;
 295+ var cat_textarea = document.createElement('textarea') ;
 296+ var cat_placeholder = document.getElementById ('category_textarea_placeholder') ;
 297+ if (cat_placeholder) {
 298+ cat_textarea.setAttribute ('id', 'category_textarea') ;
 299+ cat_textarea.setAttribute ('name', 'category') ;
 300+ cat_textarea.setAttribute ('rows', '1') ;
 301+ cat_textarea.setAttribute ('cols', '80') ;
 302+ cat_placeholder.appendChild (cat_textarea) ;
 303+ /* extract categories from text and place them into the category textarea */
 304+ WikiwygInstance.categories_array = new Array () ;
 305+ cat_textarea.value += WikiwygInstance.extractCategories (WikiwygInstance.textbox.value) ;
 306+ var cat_full_section = document.getElementById ('editpage_cloud_section') ;
 307+
 308+ /* plus, extract the categories present in the current cloud */
 309+ var cloud_num = document.getElementById ('category_tag_count').value ;
 310+ var n_cat_count = cloud_num ;
 311+ var cloud_categories = new Array () ;
 312+ for (i=0;i<cloud_num;i++) {
 313+ var cloud_id = 'cloud_' + i ;
 314+ cloud_categories[i] = document.getElementById (cloud_id).innerHTML ;
 315+ }
 316+ var onclick_cat_fn = function (cat, id) {
 317+ return function () {
 318+ EditPageRemoveCategory(escape(cat), id) ;
 319+ return false ;
 320+ }
 321+ }
 322+
 323+ for (i=0; i<WikiwygInstance.categories_array.length;i++) {
 324+ var c_found = false ;
 325+ for (j in cloud_categories) {
 326+ var core_cat = WikiwygInstance.categories_array[i].replace (/\|.*/,'') ;
 327+ if (cloud_categories[j] == core_cat) {
 328+ this_button = document.getElementById ('cloud_'+ j) ;
 329+ var actual_cloud = cloud_categories[j] ;
 330+ var cl_num = j ;
 331+
 332+ this_button.onclick = onclick_cat_fn (WikiwygInstance.categories_array[i],j) ;
 333+ this_button.style.color = "#419636" ;
 334+ c_found = true ;
 335+ break ;
 336+ }
 337+ }
 338+ if (!c_found) { /* that category is not present in the cloud, add it */
 339+ var n_cat = document.createElement ('a') ;
 340+ var s_cat = document.createElement ('span') ;
 341+ n_cat_count++ ;
 342+ var cat_num = n_cat_count - 1 ;
 343+ n_cat.setAttribute ('id','cloud_' + cat_num) ;
 344+ n_cat.setAttribute ('href','#') ;
 345+ n_cat.onclick = onclick_cat_fn (WikiwygInstance.categories_array[i], cat_num) ;
 346+ n_cat.style.color = '#419636' ;
 347+ n_cat.style.fontSize = '10pt' ;
 348+ s_cat.setAttribute ('id','tag-' + n_cat_count) ;
 349+ t_cat = document.createTextNode (core_cat) ;
 350+ space = document.createTextNode (' ') ;
 351+ n_cat.appendChild (t_cat) ;
 352+ s_cat.appendChild (n_cat) ;
 353+ s_cat.appendChild (space) ;
 354+ cat_full_section.appendChild (s_cat) ;
 355+ }
 356+ }
 357+ }
 358+ } else {
 359+ EditPageFallBack () ;
 360+ }
 361+}
 362+
 363+proto = new Subclass('Wikiwyg.Test', 'Wikiwyg');
 364+
 365+proto.getCategories = function () {
 366+ var category_txt = document.getElementById ('category_textarea') ;
 367+ if (!category_txt) {
 368+ return ;
 369+ }
 370+ /* get categories separated by commas */
 371+ var categories = category_txt.value ;
 372+ categories = categories.split (",") ;
 373+ for (i=0;i<categories.length;i++) {
 374+ this.addCategory (categories[i]) ;
 375+ }
 376+}
 377+
 378+proto.imageUpload = function (tagOpen, tagClose, sampleText) {
 379+ Wikiwyg.prototype.imageUpload.call (this, tagOpen, tagClose, sampleText) ;
 380+}
 381+
 382+proto.addCategory = function (text) {
 383+ if (text != '') {
 384+ WikiwygInstance.textbox.value += '\n\n[[' + wgCategoryPrefix + ':'+text+']]' ;
 385+ }
 386+}
 387+
 388+proto.insert_clean_after = function (container, cargo) {
 389+ if (container.parentNode.lastchild == container) {
 390+ container.parentNode.appendChild (cargo) ;
 391+ } else {
 392+ container.parentNode.insertBefore (cargo, container.nextSibling);
 393+ }
 394+}
 395+
 396+proto.cancelEdit = function () {
 397+ var re = /http:\/\/([^\/]*)\//g;
 398+ var matches = re.exec(window.location.href);
 399+ if ( !matches ) {
 400+ // TAH: firefox bug: have to do it twice for it to work
 401+ matches = re.exec(window.location.href);
 402+ }
 403+ var domain = matches[1];
 404+ needToConfirm = false ;
 405+ window.location.replace (wgServer + wgScriptPath + "/wiki/" + wgPageName) ;
 406+}
 407+
 408+proto.showChanges = function () {
 409+ needToConfirm = false ;
 410+ this.current_mode.showChanges () ;
 411+}
 412+
 413+proto.saveChanges = function () {
 414+ needToConfirm = false ;
 415+ var class_name = this.config.modeClasses[1];
 416+ var mode_object = this.mode_objects[class_name];
 417+ this.current_mode.saveChanges (mode_object) ;
 418+}
 419+
 420+proto.extractCategories = function (wikitext) {
 421+ var cat_reg = new RegExp ('[\\r\\n]*\\[\\[' + wgCategoryPrefix + ':[^\\[\\]]*\\]\\]','gi') ;
 422+ var short_cat = new RegExp ('[\\r\\n]*\\[\\[' + wgCategoryPrefix + ':') ;
 423+ var found = wikitext.match (cat_reg) ;
 424+ if (!found) {
 425+ return '' ;
 426+ }
 427+ this.textbox.value = this.textbox.value.replace (cat_reg,'') ;
 428+ var allcategories = "" ;
 429+ for (i = 0 ; i < found.length; i++) {
 430+ if (allcategories != '') {
 431+ allcategories += ',' ;
 432+ }
 433+
 434+ found[i] = found[i].replace (short_cat,'')
 435+ .replace (/\]\]/,'')
 436+ allcategories += found[i] ;
 437+ this.categories_array[i] = found [i] ;
 438+ }
 439+ return allcategories ;
 440+}
 441+
 442+proto.updateStuff = function () {
 443+ var article_text = this.current_mode.normalizeContent () ;
 444+ this.textbox.value = article_text ;
 445+// document.editform.submit () ;
 446+}
 447+
 448+proto.clearModes = function () {
 449+ /* run through all elements and clear them */
 450+ for (var i = 0; i < this.config.modeClasses.length; i++) {
 451+ var mode_radio = document.getElementById () ;
 452+ if (this.config.modeClasses[i] == this.current_mode.classname) {
 453+ mode_radio.checked = 'checked' ;
 454+ } else {
 455+ mode_radio.checked = false ;
 456+ }
 457+ }
 458+}
 459+
 460+proto.switchMode = function(new_mode_key) {
 461+ /* don't really switch mode, just show preview plus links */
 462+ var preview_div = document.getElementById ('wikiwyg_preview_area') ;
 463+ var preview_area = document.getElementById ('WikiwygEditingPreviewArea') ;
 464+ var preview_toolbar = document.getElementById ('WikiwygEditingUpperToolbar') ;
 465+ var second_preview_toolbar = document.getElementById ('WikiwygEditingUpperToolbarBis') ;
 466+ var wiki_diff = document.getElementById ('wikiDiff') ;
 467+
 468+
 469+ if (wiki_diff) {
 470+ wiki_diff.style.display = 'none' ;
 471+ second_preview_toolbar.style.display = 'none' ;
 472+ }
 473+
 474+ if (!preview_div) {
 475+ var preview_div = document.createElement ('div') ;
 476+ preview_div.id = 'wikiwyg_preview_area' ;
 477+ preview_div.style.backgroundColor = 'lightyellow' ;
 478+ preview_div.style.padding = '4px 4px 4px 4px' ;
 479+ preview_div.style.border = '1px solid #cccccc' ;
 480+ } else {
 481+ preview_div.style.display = '' ;
 482+ }
 483+
 484+ preview_area.appendChild (preview_div) ;
 485+
 486+ var preview_text = WikiwygInstance.current_mode.textarea.value ;
 487+ Wikiwyg.Wysiwyg.Custom.prototype.convertWikitextToHtml (
 488+ preview_text ,
 489+ function (preview_text) {
 490+ preview_div.innerHTML = preview_text ;
 491+ if (preview_area.style.display == 'none') {
 492+ preview_area.style.display = '' ;
 493+ preview_toolbar.style.display = '' ;
 494+ }
 495+ }
 496+ ) ;
 497+
 498+}
 499+
 500+proto = new Subclass('Wikiwyg.Wysiwyg.Custom', 'Wikiwyg.Wysiwyg');
 501+
 502+/* taken from Wysiwig.MediaWiki */
 503+proto.enableThis = function() {
 504+ Wikiwyg.Mode.prototype.enableThis.call(this);
 505+ this.edit_iframe.style.border = '1px black solid';
 506+ this.edit_iframe.width = '100%';
 507+ this.setHeightOf(this.edit_iframe);
 508+ this.fix_up_relative_imgs();
 509+ this.get_edit_document().designMode = 'on';
 510+ this.apply_stylesheets();
 511+ this.enable_keybindings();
 512+ this.clear_inner_html();
 513+ var to_convert = WikiwygInstance.textbox.value ;
 514+ var self = this ;
 515+ this.convertWikitextToHtml (
 516+ to_convert,
 517+ function (to_convert) {
 518+ self.set_inner_html (to_convert) ;
 519+ }
 520+ ) ;
 521+}
 522+
 523+proto.convertWikitextToHtml = function(wikitext, func) {
 524+ WKWAjax.post(
 525+ fixupRelativeUrl('index.php/'+ wgSpecialPrefix +':EZParser') + "&rtitle=" + wgPageName ,
 526+ "text=" + encodeURIComponent(wikitext),
 527+ func
 528+ );
 529+}
 530+
 531+
 532+proto.disableCreateButtons = function () {
 533+ var EditPageLink = document.getElementById ('wpSave') ;
 534+ EditPageLink.disabled = true ;
 535+}
 536+
 537+proto.normalizeContent = function () {
 538+ var class_name = WikiwygInstance.config.modeClasses[1] ;
 539+ var mode_object = WikiwygInstance.mode_objects[class_name] ;
 540+
 541+ var content = this.get_edit_document().body.innerHTML ;
 542+ content = content.replace(/<br[^>]+./gi,"<br>") ;
 543+ content = content.replace(/<br><br>/gi,"<p>") ;
 544+ content = mode_object.convert_html_to_wikitext (content) ;
 545+ return content ;
 546+}
 547+
 548+proto.saveChanges = function (mode) {
 549+ document.editform.action="index.php?title=" + wgPageName + "&action=submit" ;
 550+ this.disableCreateButtons () ;
 551+ var input1 = document.createElement ('input') ;
 552+ var article_text = this.get_edit_document().body.innerHTML ;
 553+ article_text = article_text.replace(/<br[^>]+./gi,"<br>") ;
 554+ article_text = article_text.replace(/<br><br>/gi,"<p>") ;
 555+ article_text = mode.convert_html_to_wikitext(article_text) ;
 556+ WikiwygInstance.textbox.value = article_text ;
 557+ WikiwygInstance.getCategories () ;
 558+ document.editform.submit() ;
 559+}
 560+
 561+proto = new Subclass('Wikiwyg.Wikitext.Custom', 'Wikiwyg.Wikitext');
 562+
 563+proto.initialize_object = function() {
 564+ this.div = document.createElement('div');
 565+ if (this.config.textareaId)
 566+ this.textarea = document.getElementById(this.config.textareaId);
 567+ else
 568+ this.textarea = document.createElement('textarea');
 569+ this.textarea.setAttribute ('id', 'wikiwyg_wikitext_textarea') ;
 570+ var categories_panel = document.getElementById ('category_cloud_wrapper') ;
 571+ this.div.appendChild(this.textarea);
 572+ this.area = this.textarea;
 573+ this.clear_inner_text();
 574+ if (categories_panel) {
 575+ this.stripCategories (this.textarea.value) ;
 576+ categories_panel.style.display = '' ;
 577+ }
 578+}
 579+
 580+/* fetch categories from text, throw them all into textarea */
 581+proto.stripCategories = function (text) {
 582+ var found = text.match (/\[\[Category:.*\]\]/gi) ;
 583+ if (!found) {
 584+ return '' ;
 585+ }
 586+ var tempcat = "" ;
 587+ for (i = 0 ; i < found.length; i++) {
 588+ tempcat = found[i].replace (/\[\[Category:/,'')
 589+ .replace (/\]\]/,'') ;
 590+ }
 591+
 592+ var splitted = text.split (/\[\[Category:[^\]]*\]\]/) ;
 593+
 594+}
 595+
 596+proto.enableThis = function() {
 597+ Wikiwyg.Mode.prototype.enableThis.call(this);
 598+ this.textarea.style.width = '100%';
 599+ this.setHeightOfEditor();
 600+ this.enable_keybindings();
 601+}
 602+
 603+proto.normalizeContent = function () {
 604+ return this.textarea.value ;
 605+}
 606+
 607+proto.saveChanges = function () {
 608+ article_text = this.normalizeContent () ;
 609+ WikiwygInstance.textbox.value = article_text ;
 610+ WikiwygInstance.getCategories () ;
 611+ document.editform.submit() ;
 612+}
 613+
 614+proto.showChanges = function () {
 615+ article_text = this.normalizeContent () ;
 616+ WikiwygInstance.textbox.value = article_text ;
 617+ WikiwygInstance.getCategories () ;
 618+ var diff = Wikiwyg.createElementWithAttrs ('input', {
 619+ 'name': 'wpDiff' ,
 620+ 'value': 'OK',
 621+ 'type': 'hidden'
 622+ }) ;
 623+ document.editform.appendChild (diff) ;
 624+ document.editform.submit() ;
 625+}
 626+
 627+proto.addCategory = function (text) {
 628+ if (text != '') {
 629+ WikiwygInstance.textbox.value += '[[Category:'+text+']]' ;
 630+ }
 631+}
 632+
 633+proto.getCategories = function () {
 634+ /* get categories separated by commas */
 635+ var categories = document.getElementById ('category_textarea').value ;
 636+ categories = categories.split (",") ;
 637+ for (i=0;i<categories.length;i++) {
 638+ this.addCategory (categories[i]) ;
 639+ }
 640+}
 641+
 642+proto.enableThis = function() {
 643+ Wikiwyg.Mode.prototype.enableThis.call(this);
 644+ this.textarea.style.width = '100%';
 645+ this.textarea.style.height = '300px' ;
 646+ this.setHeightOfEditor();
 647+ this.enable_keybindings();
 648+ this.textarea.value = WikiwygInstance.textbox.value ;
 649+}
 650+
 651+proto.format_table = function(element) {
 652+ this.insert_new_line();
 653+ this.appendOutput ('{|') ;
 654+ this.assert_blank_line() ;
 655+ this.walk(element);
 656+ this.assert_blank_line() ;
 657+ this.appendOutput ('|}') ;
 658+ this.insert_new_line();
 659+}
 660+
 661+proto.format_tr = function(element) {
 662+ this.appendOutput('|-') ;
 663+ this.assert_new_line() ;
 664+ this.appendOutput('|') ;
 665+ this.walk(element) ;
 666+ this.assert_blank_line() ;
 667+ this.assert_new_line() ;
 668+}
 669+
 670+proto.format_td = function(element) {
 671+ this.no_following_whitespace();
 672+ this.walk(element);
 673+ this.chomp();
 674+ this.appendOutput('||');
 675+}
 676+
 677+proto.convertWikitextToHtml = function(wikitext, func) {
 678+ WKWAjax.post(
 679+ fixupRelativeUrl('index.php/' + wgSpecialPrefix + ':EZParser') + "&rtitle=" + wgPageName ,
 680+ "text=" + encodeURIComponent(wikitext),
 681+ func
 682+ );
 683+}
 684+
 685+proto.normalizeContent = function () {
 686+ return this.textarea.value ;
 687+}
 688+
 689+proto.config = {
 690+javascriptLocation: '/wikiwyg/lib/' ,
 691+markupRules: {
 692+link: ['bound_phrase', '[[', ']]'],
 693+ www: ['bound_phrase', '[', ']'],
 694+ bold: ['bound_phrase', "'''", "'''"],
 695+ italic: ['bound_phrase', "''", "''"],
 696+ strike: ['bound_phrase', "<s>", "</s>"],
 697+ pre: ['start_lines', ' '],
 698+ p: ['bound_line', '', ''],
 699+ h1: ['bound_line', '= ', ' ='],
 700+ h2: ['bound_line', '== ', ' =='],
 701+ h3: ['bound_line', '=== ', ' ==='],
 702+ h4: ['bound_line', '==== ', ' ===='],
 703+ ordered: ['start_lines', '#'],
 704+ unordered: ['start_lines', '*'],
 705+ indent: ['start_lines', ''],
 706+ hr: ['line_alone', '----'],
 707+ timestamp: ['line_alone', '~~~~'] ,
 708+ table: ['line_alone', '{ | | A | B | C |- | D | E | F |- | G | H | I | }']
 709+ }
 710+}
 711+
 712+proto = new Subclass ('Wikiwyg.Preview.Custom', 'Wikiwyg.Preview') ;
 713+
 714+proto.normalizeContent = function () {
 715+ var content = WikiwygInstance.textbox.value ;
 716+ return content ;
 717+}
 718+
 719+proto.saveChanges = function () {
 720+ WikiwygInstance.getCategories () ;
 721+ document.editform.submit() ;
 722+}
 723+
Property changes on: trunk/extensions/wikiwyg/share/MediaWiki/extensions/WikiwygEditing/js/editpage.js
___________________________________________________________________
Added: svn:eol-style
1724 + native
Index: trunk/extensions/wikiwyg/share/MediaWiki/extensions/MediaWikiWyg.php
@@ -1,24 +1,77 @@
22 <?PHP
33
4 -global $wgHooks;
 4+global $wgHooks, $wgInPageEnabled ;
 5+ if (!isset($wgInPageEnabled) || ($wgInPageEnabled == false)) {
 6+ return ;
 7+ }
 8+
59 $wgHooks['ParserBeforeTidy'][] = 'beforeTidyHook' ;
 10+$wgHooks['UserToggles'][] = 'wfWikiwygToggle' ;
 11+$wgHooks['handleWikiPrefs'][] = 'wfWikiwygHandleEditingPrefs' ;
 12+$wgHooks['getEditingPreferencesTab'][] = 'wfWikiwygAddEditingPrefs' ;
613
714 $wgExtensionFunctions[] = 'registerWikiwygExtension';
815 $wgExtensionCredits['other'][] = array(
916 'name' => 'MediaWikiWyg',
10 - 'author' => 'http://svn.wikiwyg.net/code/trunk/wikiwyg/AUTHORS',
11 - 'version' => 0.10,
12 - 'url' => 'http://www.wikiwyg.net',
 17+ 'author' => 'http://svn.wikiwyg.net/code/trunk/wikiwyg/AUTHORS, Bartek Lapinski',
 18+ 'version' => 0.20,
 19+ 'url' => 'http://www.wikiwyg.net, http://www.wikia.com',
1320 'description' => 'Mediawiki integration of the Wikiwyg WYSIWYG wiki editor'
1421 );
1522
 23+function wfGetDependingOnSkin () {
 24+ $useInPageTrue = '' ;
 25+ global $wgCookiePrefix, $wgUser, $wgInPageEnabled ;
 26+
 27+ /* do not forget about editor disabled from variable... */
 28+ if (!$wgInPageEnabled || !isset ($wgInPageEnabled)) {
 29+ return 0 ;
 30+ }
 31+
 32+ if ($wgUser->getOption ('in-page', 2) == 2) {
 33+ $skin = $wgUser->getSkin() ;
 34+ if (is_object ($skin)){
 35+ /* forget about the _real_ skinname - it's not loaded yet */
 36+ $skinname = get_class ($skin) ;
 37+ /*
 38+ if (($skinname == 'SkinMonoBook') ) {
 39+ return 1 ;
 40+ } else {
 41+ return 0 ;
 42+ }*/
 43+ return 1 ;
 44+ } else {
 45+ return 0 ;
 46+ }
 47+ } else {
 48+ return $wgUser->getOption ('in-page', 1) ;
 49+ }
 50+}
 51+
1652 function registerWikiwygExtension() {
17 - global $wgOut,$wgSkin,$jsdir,$cssdir;
18 - global $wgWikiwygPath;
 53+ global $wgOut,$wgSkin,$jsdir,$cssdir, $wgScriptPath ;
 54+ global $wgWikiwygPath, $wgUser, $wgTitle ;
1955 global $wgServer,$wgWikiwygJsPath,$wgWikiwygCssPath,$wgWikiwygImagePath;
 56+ global $wgRequest, $wgWysiwygEnabled, $wgMessageCache ;
 57+ global $wgLang, $wgContLang, $wgEnableAjaxLogin ;
2058
 59+ if (wfGetDependingOnSkin () == 0) {
 60+ return ;
 61+ }
 62+
 63+ $wgMessageCache->addMessages(
 64+ array(
 65+ 'wysiwygcaption' => 'Visual editing' ,
 66+ 'insertimage' => 'Insert image' ,
 67+ 'save' => 'Save' ,
 68+ 'wysiwygcaption' => 'Visual editing' ,
 69+ 'insertimage' => 'Insert image' ,
 70+ 'edit-summary' => 'Edit summary'
 71+ )
 72+ );
 73+
2174 if (! isset($wgWikiwygPath)) {
22 - $wgWikiwygPath = "$wgServer/wikiwyg";
 75+ $wgWikiwygPath = $wgScriptPath . "/extensions/wikiwyg";
2376 }
2477 if (! isset($wgWikiwygJsPath)) {
2578 $wgWikiwygJsPath = "$wgWikiwygPath/share/MediaWiki";
@@ -29,137 +82,363 @@
3083 if (! isset($wgWikiwygImagePath)) {
3184 $wgWikiwygImagePath = "$wgWikiwygPath/share/MediaWiki/images";
3285 }
 86+
3387 $wgOut->addScript("<style type=\"text/css\" media=\"screen,projection\">/*<![CDATA[*/ @import \"$wgWikiwygCssPath/MediaWikiwyg.css\"; /*]]>*/</style>\n");
 88+ if (isset($wgWysiwygEnabled) && ($wgWysiwygEnabled == true)) {
 89+ $useWysiwygTrue = 1 ;
 90+ } else {
 91+ $useWysiwygTrue = 0 ;
 92+ }
 93+
 94+ if (! isset($wgEnableAjaxLogin) || ($wgEnableAjaxLogin == false)) {
 95+ $wgEnableAjaxLogin = 0 ;
 96+ }
 97+
 98+
3499 $wgOut->addScript("
35100 <script type=\"text/javascript\">
36101 if (typeof(Wikiwyg) == 'undefined') Wikiwyg = function() {};
37102 Wikiwyg.mediawiki_source_path = \"$wgWikiwygPath\";
 103+ var wgEditCaption = \"".mb_strtolower(wfMsg('qbedit'))."\";
 104+ var wgSaveCaption = \"".mb_strtolower(wfMsg ('save'))."\";
 105+ var wgCancelCaption = \"".mb_strtolower(wfMsg ('cancel'))."\";
 106+ var wgSummaryCaption = \"".wfMsg ('edit-summary')."\";
 107+ var wgPreviewCaption = \"".wfMsg ('preview')."\";
 108+ var wgHelpCaption = \"".wfMsg ('help')."\" ;
 109+ var wgBoldTip = \"".wfMsg ('bold_tip')."\";
 110+ var wgItalicTip = \"".wfMsg ('italic_tip')."\";
 111+ var wgIntlinkTip = \"".wfMsg ('mwlink_tip')."\";
 112+ var wgExtlinkTip = \"".wfMsg ('extlink_tip')."\";
 113+ var wgNowikiTip = \"".wfMsg ('nowiki_tip')."\";
 114+ var wgHrTip = \"".wfMsg ('hr_tip')."\";
 115+ var wgTimestampTip = \"".wfMsg ('sig_tip')."\";
 116+ var wgUseWysiwyg = " .$useWysiwygTrue." ;
 117+ var wgUseInPage = ".wfGetDependingOnSkin ().";
 118+ var wgFullPageEditing = false ;
 119+ var wgWysiwygCaption = \"".wfMsg ('wysiwygcaption') ."\" ;
 120+ var wgInsertImageCaption = \"".wfMsg ('insertimage') ."\" ;
 121+ var wgMinoreditCaption = \"" .wfMsg ('minoredit') ."\" ;
 122+ var wgWatchthisCaption = \"" .wfMsg ('watchthis') ."\" ;
 123+ var wgDefaultMode = \"".$wgUser->getOption ('visualeditormode','wysiwyg') ."\" ;
 124+ var wgCategoryPrefix = \"".urlencode ($wgContLang->getNsText (NS_CATEGORY) ) ."\" ;
 125+ var wgSpecialPrefix = \"".urlencode ($wgContLang->getNsText (NS_SPECIAL) ) ."\" ;
38126 </script>
39127 ");
40 - $wgOut->addScript("<script type=\"text/javascript\" src=\"$wgWikiwygJsPath/MediaWikiWyg.js\"></script>\n");
 128+
 129+ $wgOut->addScript("
 130+ <script type=\"text/javascript\">
 131+ function insertTags (tagOpen, tagClose, sampleText) {
 132+ currentWikiwyg.current_mode.markup_line_alone (['line_alone', tagOpen + sampleText + tagClose]) ;
 133+ }
 134+ document.insertTags = insertTags ;
 135+ </script>
 136+ ") ;
 137+
 138+ $wgOut->addScript("<script type=\"text/javascript\" src=\"$wgWikiwygJsPath/MediaWikiWyg.js?".$GLOBALS['wgStyleVersion']."\"></script>\n");
41139 }
42140
43 -function beforeTidyHook($parser,$text) {
 141+/* gets the lowest header level present in the article
 142+ or the next level when deeper in the structure,
 143+ depending on the given level
 144+*/
 145+
 146+function wfDetermineStartingLevel ($text) {
 147+ for ($i = 0; $i < 8 ; $i++) {
 148+ if ( preg_match ('/<h'.$i.'>/i', $text) ) {
 149+ return $i ;
 150+ }
 151+ }
 152+ return "NONE" ;
 153+}
 154+
 155+function wfDetermineNextLevel ($level, $text) {
 156+ for ($i = $level + 1; $i < 8; $i++) {
 157+ if ( preg_match ('/<h'.$i.'>/i', $text) ) {
 158+ return $i ;
 159+ }
 160+ }
 161+ return "NONE" ;
 162+}
 163+
 164+/* parse recurrently depending on current header level */
 165+function wfRecurrentParse ($text, $level) {
44166 $blocks = preg_split(
45 - '/(<div class="editsection".*?<\/div>)/i',
 167+ '/(<a name=".*?".*?<\/a><h'.$level.'><span class="editsection".*?<\/span>)/i',
46168 $text, -1, PREG_SPLIT_DELIM_CAPTURE
47169 );
48170
49171 $i = 0;
50 -
 172+
51173 $full = array_shift($blocks);
 174+ $header_block = "" ;
52175 foreach ($blocks as $block) {
53 - # This is an edit link
54 - if (preg_match('/<div class="editsection".*?<\/div>/i', $block)) {
55 - $i++;
56 - $full .= "<span class='wikiwyg_edit' id=\"wikiwyg_edit_{$i}\">
57 -$block
58 -</span>
59 -";
 176+ /* now, _this_ is an edit link */
 177+ if (preg_match('/<h'.$level.'><span class="editsection".*?<\/span>/i', $block)) {
 178+ $inner_blocks = preg_split(
 179+ '/(<h'.$level.'>)/i',
 180+ $block, -1, PREG_SPLIT_DELIM_CAPTURE
 181+ );
 182+ foreach ($inner_blocks as $inner_block) {
 183+ if (preg_match('/<span class="editsection".*?<\/span>/i', $inner_block)) {
 184+ /* now, this is a real edit link... */
 185+ $i++;
 186+ /* extract the _real_ section number */
 187+ preg_match ('/section=[0-9]+/',$inner_block, $section_number) ;
 188+ $section_number = substr ($section_number[0], 8) ;
 189+ $full .= "<span class='wikiwyg_edit' id=\"wikiwyg_edit_{$section_number}\">
 190+ $inner_block
 191+ </span>
 192+ ";
 193+ } else {
 194+ /* not an edit link... */
 195+ if (!preg_match('/<h'.$level.'>/i', $inner_block)) {
 196+ $full .= $inner_block ;
 197+ } else {
 198+ $header_block = $inner_block ;
 199+ }
 200+ }
 201+ }
60202 }
61203 # This is a section body
62204 else {
63205 if ($i == 0) {
64206 die("Wrong order!");
65207 }
 208+ /* correct next level to actually match next level... */
 209+ $next_level = wfDetermineNextLevel ($level - 1,$block) ;
 210+ if (preg_match('/<h'.$next_level.'>/i',$block)) {
 211+ /* investigate matter further - there may be subsections */
 212+ /* we found more sections - split it up, add the main thing and go deeper */
 213+ $blocked_splits = preg_split(
 214+ '/(<\/h'.$level.'>)/i',
 215+ $block, -1, PREG_SPLIT_DELIM_CAPTURE
 216+ );
 217+ $block = '' ;
 218+ $block .= $blocked_splits[0].$blocked_splits[1] ;
 219+ $block .= wfRecurrentParse($blocked_splits[2], $next_level) ;
 220+ }
 221+
 222+ /* split it up further to insert the throbber - we need to put it after mw-headline */
 223+ $full .= "<span class=\"wikiwyg_section\" id=\"wikiwyg_section_{$section_number}\">$header_block" ;
 224+ $full .= $block ;
66225 $full .= "
67 -<div class=\"wikiwyg_section\" id=\"wikiwyg_section_{$i}\">
68 -$block
69 -</div>
 226+</span>
70227 <iframe class='wikiwyg_iframe'
71 - id=\"wikiwyg_iframe_{$i}\"
72 - height='0' width='0'
 228+ id=\"wikiwyg_iframe_{$section_number}\"
 229+ height='0' width='0'
73230 frameborder='0'>
74231 </iframe>
75232 ";
76233 }
77234 }
78 - $text = $full;
79 - return true;
 235+ return $full ;
80236 }
81237
 238+function beforeTidyHook($parser,$text) {
 239+ global $wgServer, $wgScriptPath, $wgUser ;
 240+ if ($wgUser->getOption ('in-page', 1) == 0 ) return ;
 241+ $wgScriptPath != "" ? $fixedPath = $wgServer."/".$wgScriptPath : $fixedPath = $wgServer ;
 242+ /* stuff changed in MW 1.9.3, the order of elements is different now */
 243+ /* one more interesting thing - determine the maximum depth of the headers
 244+ (remember, MW uses level 2 headers as suggested ones...) */
 245+ $starting_level = wfDetermineStartingLevel ($text) ;
 246+ $text = wfRecurrentParse ($text, $starting_level, 0) ;
 247+}
 248+
82249 # Not a valid entry point, skip unless MEDIAWIKI is defined
83250 if (defined('MEDIAWIKI')) {
84251 $wgExtensionFunctions[] = 'wfEZParser';
85252
86 -$wgAvailableRights[] = 'ezparser';
87 -
88 -$wgGroupPermissions['ezparser']['ezparser'] = true;
89 -
90253 function wfEZParser() {
91254 global $IP;
92255 require_once( $IP.'/includes/SpecialPage.php' );
93256
94 -#class EZParser extends UnlistedSpecialPage
95 -class EZParser extends SpecialPage
 257+class EZParser extends UnlistedSpecialPage
96258 {
97259 function EZParser() {
98 -# UnlistedSpecialPage::UnlistedSpecialPage('EZParser');
99 - SpecialPage::SpecialPage('EZParser');
 260+ UnlistedSpecialPage::UnlistedSpecialPage('EZParser');
100261 }
101262
102263 function execute( $par ) {
103264 global $wgRequest, $wgOut, $wgTitle, $wgUser;
104 -
105 - if (!in_array( 'ezparser', $wgUser->getRights() ) ) {
 265+
 266+/* if (!in_array( 'ezparser', $wgUser->getRights() ) ) {
106267 $wgOut->setArticleRelated( false );
107268 $wgOut->setRobotpolicy( 'noindex,follow' );
108269 $wgOut->errorpage( 'nosuchspecialpage', 'nospecialpagetext' );
109270 return;
110271 }
 272+*/
111273
112274 $this->setHeaders();
113275
114 - $text = $wgRequest->getText( 'text' );
 276+ $text = $wgRequest->getText ('text') ;
 277+ $title = $wgRequest->getText ('rtitle') ;
 278+ $namespace = $wgRequest->getText ('rnamespace') ;
115279
116280 if ( $text ) {
117 - $this->parseText( $text );
 281+ $this->parseText( $text, $title );
 282+ } else {
 283+ $wgOut->setArticleBodyOnly( true );
118284 }
119 - else{
120 - $this->addForm();
121 - }
122285 }
123286
124 - function parseText($text){
 287+ function parseText($text, $title){
125288 #still need to make it actually parse the input.
126289 global $wgOut, $wgUser, $wgTitle, $wgParser, $wgAllowDiffPreview, $wgEnableDiffPreviewPreference;
127290 $parserOptions = ParserOptions::newFromUser( $wgUser );
128291 $parserOptions->setEditSection( false );
129 - $output = $wgParser->parse( $text, $wgTitle, $parserOptions );
 292+ $rtitle = Title::newFromText ($title) ;
 293+
 294+ $pre_parsed = $wgParser->preSaveTransform ($text, $rtitle, $wgUser, $parserOptions, true) ;
 295+ $output = $wgParser->parse( $pre_parsed, $rtitle, $parserOptions );
130296 $wgOut->setArticleBodyOnly( true );
131297
132 -# Here we filter the output. If there's a secion header in the beginning,
 298+# Here we filter the output. If there's a section header in the beginning,
133299 # we'll have an empty wikiwyg_section_0 div, and we do not want it.
134 -# So we strip the empty div out.
 300+# So we strip the empty span out.
135301
136 - $goodHTML = str_replace("<div class=\"wikiwyg_section_0\">\n<p><!-- before block -->\n</p><p><br />\n</p><p><!-- After block -->\n</p>\n</div><iframe class=\"wikiwyg_iframe\" id=\"wikiwyg_iframe_0\" height='0' width='0' frameborder='0'></iframe>", "", $output->mText);
 302+ $goodHTML = str_replace("<span class=\"wikiwyg_section_0\">\n<p><!-- before block -->\n</p><p><br />\n</p><p><!-- After block -->\n</p>\n</span><iframe class=\"wikiwyg_iframe\" id=\"wikiwyg_iframe_0\" height='0' width='0' frameborder='0'></iframe>", "", $output->mText) ;
 303+ /* manually strip away TOC */
 304+ $goodHTML = preg_replace ('/<table id="toc".*<\/table>*.<script type="text\/javascript"> if \(window\.showTocToggle\).*<\/script>/is', "", $goodHTML) ;
 305+ $wgOut->addHTML($goodHTML) ;
 306+ }
 307+}
137308
138 - $wgOut->addHTML($goodHTML);
 309+global $wgMessageCache;
 310+SpecialPage::addPage( new EZParser );
 311+$wgMessageCache->addMessage( 'ezparser', 'Simple parser test' );
139312
 313+}
 314+
 315+$wgExtensionFunctions[] = 'wfPocketDiff' ;
 316+function wfPocketDiff () {
 317+global $IP;
 318+require_once( $IP.'/includes/SpecialPage.php' );
 319+
 320+class PocketDiff extends UnlistedSpecialPage
 321+{
 322+ function PocketDiff() {
 323+ UnlistedSpecialPage::UnlistedSpecialPage('PocketDiff');
140324 }
141325
142 - function addForm(){
143 - global $wgOut, $wgTitle;
 326+ function execute( $par ) {
 327+ global $wgRequest, $wgOut, $wgTitle, $wgUser;
144328
145 - $action = $wgTitle->escapeLocalUrl();
 329+ $this->setHeaders();
146330
147 - $wgOut->addHTML( <<<EOF
148 -<form name="ezparser" action="$action" method=post>
149 -<textarea name="text">
150 -enter wikitext here
151 -</textarea>
152 -<input type="submit" name="submit" value="OK" />
153 -</form>
154 -EOF
155 - );
 331+ $text = $wgRequest->getText ('text') ;
 332+ $title = $wgRequest->getText ('rtitle') ;
 333+ $section = $wgRequest->getText ('rsection') ;
 334+ $namespace = $wgRequest->getText ('rnamespace') ;
 335+ $wgOut->setArticleBodyOnly( true );
 336+
 337+ if ( $text ) {
 338+ $this->makeADifference( $text, $title, $section );
 339+ }
156340 }
 341+
 342+ function makeADifference ($text, $title, $section) {
 343+ global $wgOut ;
 344+ /* make an article object */
 345+ $rtitle = Title::newFromText ($title) ;
 346+
 347+ $rarticle = new Article ($rtitle, $rtitle->getArticleID ()) ;
 348+ $epage = new EditPage ($rarticle) ;
 349+ $epage->section = $section ;
 350+
 351+ /* customized getDiff from EditPage */
 352+ $oldtext = $epage->mArticle->fetchContent();
 353+ $edittime = $epage->mArticle->getTimestamp();
 354+ $newtext = $epage->mArticle->replaceSection(
 355+ $section, $text, '', $edittime );
 356+
 357+ $newtext = $epage->mArticle->preSaveTransform( $newtext );
 358+ $oldtitle = wfMsgExt( 'currentrev', array('parseinline') );
 359+ $newtitle = wfMsgExt( 'yourtext', array('parseinline') );
 360+ if ( $oldtext !== false || $newtext != '' ) {
 361+ $de = new DifferenceEngine( $epage->mTitle );
 362+ $de->setText( $oldtext, $newtext );
 363+ $difftext = $de->getDiff( $oldtitle, $newtitle );
 364+ } else {
 365+ $difftext = '';
 366+ }
 367+
 368+ $diffdiv = '<div id="wikiDiff">' . $difftext . '</div>';
 369+ $wgOut->addHTML ($diffdiv) ;
 370+
 371+ }
157372 }
158373
159374 global $wgMessageCache;
160 -SpecialPage::addPage( new EZParser );
161 -$wgMessageCache->addMessage( 'ezparser', 'Simple parser test' );
 375+SpecialPage::addPage( new PocketDiff );
 376+$wgMessageCache->addMessage( 'pocketdiff', 'retrieves difference' );
162377
163378 }
 379+
 380+function wfWikiwygToggle ($toggles) {
 381+ global $wgMessageCache, $wgWysiwygEnabled ;
 382+ $wgMessageCache->addMessages (
 383+ array (
 384+ 'tog-in-page' => 'use in-page editor' ,
 385+ 'wysiwygdef' => 'wysiwyg default mode' ,
 386+ 'wikitextdef' => 'wikitext default mode'
 387+ )
 388+ ) ;
 389+ $toggles ["in-page"] = "in-page" ;
 390+}
 391+
 392+function wfWikiwygAddEditingPrefs ($prefsForm, $prefs) {
 393+ global $wgWysiwygEnabled ;
 394+ $prefs = array_merge ($prefs, array (
 395+ 'in-page'
 396+ )) ;
 397+}
 398+
 399+function wfWikiwygHandleEditingPrefs () {
 400+ global $wgOut, $wgWysiwygEnabled ;
 401+ if (isset($wgWysiwygEnabled) && $wgWysiwygEnabled) {
 402+ $wgOut->addScript("
 403+ <script type=\"text/javascript\">
 404+ function WikiwygEnhanceControls () {
 405+
 406+ var inPageControl = document.getElementById ('in-page') ;
 407+ var WysiwygControl = document.getElementById ('wpVisualEditorWysiwyg') ;
 408+ var WikitextControl = document.getElementById ('wpVisualEditorWikitext') ;
 409+
 410+ //initial enable
 411+ if (inPageControl.checked) {
 412+ WysiwygControl.disabled = false ;
 413+ WysiwygControl.parentNode.style.fontColor = 'black' ;
 414+ WikitextControl.disabled = false ;
 415+ WikitextControl.parentNode.style.fontColor = 'black' ;
 416+ }
 417+
 418+ var PreferencesSave = document.getElementById ('wpSaveprefs') ;
 419+ inPageControl.onclick = function () {
 420+ if (inPageControl.checked) {
 421+ WysiwygControl.disabled = false ;
 422+ WysiwygControl.parentNode.style.fontColor = 'black' ;
 423+ WikitextControl.disabled = false ;
 424+ WikitextControl.parentNode.style.fontColor = 'black' ;
 425+ } else {
 426+ WysiwygControl.parentNode.style.fontColor = 'gray' ;
 427+ WysiwygControl.disabled = true ;
 428+ WikitextControl.parentNode.style.fontColor = 'gray' ;
 429+ WikitextControl.disabled = true ;
 430+ }
 431+ }
 432+ PreferencesSave.onclick = function () {
 433+ Cookie.del (\"WikiwygEditMode\") ;
 434+ //Cookie.del (\"WikiwygFPEditMode\") ;
 435+ }
 436+ }
 437+ addOnloadHook (WikiwygEnhanceControls) ;
 438+ </script>"
 439+ ) ;
 440+ }
 441+}
 442+
164443 } # End if(defined MEDIAWIKI)
165444
166 -
 445+?>
Index: trunk/extensions/wikiwyg/share/MediaWiki/MediaWikiWyg.js
@@ -1,3 +1,92 @@
 2+
 3+// BEGIN ../../lib/Wikiwyg/Init.js
 4+
 5+/*==============================================================================
 6+Initial stuff by Bartek Lapinski
 7+
 8+COPYRIGHT:
 9+
 10+ Copyright (c) 2005 Socialtext Corporation
 11+ 655 High Street
 12+ Palo Alto, CA 94301 U.S.A.
 13+ All rights reserved.
 14+
 15+ Copyright (c) 2007, Wikia Inc.
 16+
 17+CHANGES AUTHOR:
 18+
 19+ Bartek Lapinski <bartek@wikia.com>
 20+
 21+ Copyright (c) 2007, Wikia Inc.
 22+
 23+Wikiwyg is free software.
 24+
 25+This library is free software; you can redistribute it and/or modify it
 26+under the terms of the GNU Lesser General Public License as published by
 27+the Free Software Foundation; either version 2.1 of the License, or (at
 28+your option) any later version.
 29+
 30+This library is distributed in the hope that it will be useful, but
 31+WITHOUT ANY WARRANTY; without even the implied warranty of
 32+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
 33+General Public License for more details.
 34+
 35+ http://www.gnu.org/copyleft/lesser.txt
 36+
 37+ =============================================================================*/
 38+
 39+var currentWikiwyg ;
 40+var needToConfirm = false ;
 41+
 42+/* comfirming exit from page */
 43+function confirmExit(){
 44+ if (needToConfirm){
 45+ return "You have attempted to leave this page. If you have made any changes to the fields without clicking the Save button, your changes will be lost. Are you sure you want to exit this page?";
 46+}
 47+}
 48+
 49+/* Yahoo stuff - Bartek Lapinski */
 50+YAHOO.namespace('Wikia');
 51+var Event = YAHOO.util.Event ;
 52+
 53+YAHOO.Wikia.Wikiwyg = {
 54+ buildLicensePanel: function () {
 55+ var copywarn = document.getElementById ('editpage-copywarn') ;
 56+ var copywarn_copy = document.createElement ('div') ;
 57+ copywarn_copy.id = 'copywarn-license' ;
 58+ copywarn_copy.innerHTML = copywarn.innerHTML ;
 59+ YAHOO.Wikia.Wikiwyg.applyTargetToLinks (copywarn_copy, "_new") ;
 60+ document.body.appendChild (copywarn_copy) ;
 61+ YAHOO.Wikia.Wikiwyg.licensePanel = new YAHOO.widget.Panel('copywarn-license', {
 62+ width: "600px" ,
 63+ modal: true ,
 64+ constraintoviewport: true ,
 65+ draggable: false ,
 66+ fixedcenter: true ,
 67+ underlay: "none"
 68+ } );
 69+ YAHOO.Wikia.Wikiwyg.licensePanel.render () ;
 70+ } ,
 71+
 72+ // apply target to all links included in the selected element
 73+ applyTargetToLinks: function (element, target) {
 74+ var links = element.getElementsByTagName ('a') ;
 75+ if (links && (links.length > 0)) {
 76+ for (var i=0 ; i < links.length; i++) {
 77+ links[i].target = target ;
 78+ }
 79+ }
 80+ } ,
 81+
 82+ showLicensePanel: function (e) {
 83+ YAHOO.util.Event.preventDefault (e) ;
 84+ if (!YAHOO.Wikia.Wikiwyg.licensePanel) {
 85+ YAHOO.Wikia.Wikiwyg.buildLicensePanel () ;
 86+ }
 87+ YAHOO.Wikia.Wikiwyg.licensePanel.show () ;
 88+ }
 89+}
 90+
291 // BEGIN ../../lib/Wikiwyg.js
392 /*==============================================================================
493 Wikiwyg - Turn any HTML div into a wikitext /and/ wysiwyg edit area.
@@ -25,13 +114,20 @@
26115
27116 COPYRIGHT:
28117
29 - Copyright (c) 2005 Socialtext Corporation
 118+ Copyright (c) 2005 Socialtext Corporation
30119 655 High Street
31120 Palo Alto, CA 94301 U.S.A.
32121 All rights reserved.
33122
34 -Wikiwyg is free software.
35123
 124+CHANGES AUTHOR:
 125+
 126+ Bartek Lapinski <bartek@wikia.com>
 127+
 128+ Copyright (c) 2007, Wikia Inc.
 129+
 130+Wikiwyg is free software.
 131+
36132 This library is free software; you can redistribute it and/or modify it
37133 under the terms of the GNU Lesser General Public License as published by
38134 the Free Software Foundation; either version 2.1 of the License, or (at
@@ -83,7 +179,7 @@
84180 Wikiwyg.ua = navigator.userAgent.toLowerCase();
85181 Wikiwyg.is_ie = (
86182 Wikiwyg.ua.indexOf("msie") != -1 &&
87 - Wikiwyg.ua.indexOf("opera") == -1 &&
 183+ Wikiwyg.ua.indexOf("opera") == -1 &&
88184 Wikiwyg.ua.indexOf("webtv") == -1
89185 );
90186 Wikiwyg.is_gecko = (
@@ -112,18 +208,21 @@
113209 };
114210
115211 proto.default_config = {
116 - javascriptLocation: 'lib/',
 212+ javascriptLocation: '/wikiwyg/lib/',
117213 doubleClickToEdit: false,
118214 toolbarClass: 'Wikiwyg.Toolbar',
119215 firstMode: null,
120216 modeClasses: [
121 - 'Wikiwyg.Wysiwyg',
122 - 'Wikiwyg.Wikitext',
 217+ 'Wikiwyg.Wysiwyg' ,
 218+ 'Wikiwyg.Wikitext' ,
123219 'Wikiwyg.Preview'
124220 ]
125221 };
126222
127223 proto.initializeObject = function(div, config) {
 224+ /* enable people to use Special:Createpage regardless of this preference */
 225+ if ((wgUseInPage == 0) && (wgCanonicalSpecialPageName != "Createpage") ) return ;
 226+
128227 if (! Wikiwyg.browserIsSupported) return;
129228 if (this.enabled) return;
130229 this.enabled = true;
@@ -146,16 +245,25 @@
147246 ? this.config.firstMode
148247 : this.config.modeClasses[0];
149248 this.setFirstModeByName(firstMode);
 249+ var section_number = this.div.id.replace(/.*?(\d+)$/, '$1') ;
150250
151251 if (this.config.toolbarClass) {
152 - var class_name = this.config.toolbarClass;
153 - this.toolbarObject = eval('new ' + class_name + '()');
154 - this.toolbarObject.wikiwyg = this;
155 - this.toolbarObject.set_config(config.toolbar);
156 - this.toolbarObject.initializeObject();
157 - this.placeToolbar(this.toolbarObject.div);
 252+ var class_name = this.config.toolbarClass ;
 253+ this.toolbarObject = eval('new ' + class_name + '()') ;
 254+ this.toolbarObject.wikiwyg = this ;
 255+ this.toolbarObject.set_config(config.toolbar) ;
 256+ this.toolbarObject.initializeObject(section_number) ;
 257+ this.placeToolbar(this.toolbarObject.div) ;
 258+
 259+ if (!wgFullPageEditing) {
 260+ this.toolbarObject.placeLowerToolbar () ;
 261+ this.placeLowerToolbar (this.toolbarObject.linksDiv) ;
 262+ this.placeLowerToolbar (this.toolbarObject.summaryDiv) ;
 263+ /* attach the event for the license */
 264+ Event.addListener ('wikiwyg_ctrl_lnk_showLicense_' + section_number, 'click', YAHOO.Wikia.Wikiwyg.showLicensePanel) ;
 265+ }
158266 }
159 -
 267+
160268 // These objects must be _created_ before the toolbar is created
161269 // but _inserted_ after.
162270 for (var i = 0; i < this.config.modeClasses.length; i++) {
@@ -166,7 +274,7 @@
167275
168276 if (this.config.doubleClickToEdit) {
169277 var self = this;
170 - this.div.ondblclick = function() { self.editMode() };
 278+ this.div.ondblclick = function() { self.editMode() };
171279 }
172280 }
173281
@@ -195,23 +303,95 @@
196304 this.config = new_config;
197305 }
198306
199 -proto.insert_div_before = function(div) {
 307+proto.insert_div_before = function (div) {
200308 div.style.display = 'none';
201309 if (! div.iframe_hack) {
202310 this.div.parentNode.insertBefore(div, this.div);
203311 }
204312 }
205313
 314+proto.toggleCategory = function () {
 315+ var category_tab = document.getElementById ('editpage_cloud_section') ;
 316+ var category_link = document.getElementById ('wikiwyg_ctrl_lnk_toggleCategory_wikiwyg') ;
 317+ if (category_tab.style.display == 'none') {
 318+ category_tab.style.display = '' ;
 319+ category_link.innerHTML = 'Hide category' ;
 320+ } else {
 321+ category_tab.style.display = 'none' ;
 322+ category_link.innerHTML = 'Add category' ;
 323+ }
 324+}
 325+
 326+proto.showLicense = function () {
 327+
 328+}
 329+
 330+/* this 'prototype' is here for purpose */
 331+proto.imageUpload = function (tagOpen, tagClose, sampleText) {
 332+ var re = /http:\/\/([^\/]*)\//g;
 333+ var matches = re.exec(window.location.href);
 334+ if ( !matches ) {
 335+ // TAH: firefox bug: have to do it twice for it to work
 336+ matches = re.exec(window.location.href);
 337+ }
 338+ var domain = matches[1];
 339+ if (imageUploadDialog && imageUploadDialog.open && !imageUploadDialog.closed)
 340+ imageUploadDialog.close();
 341+
 342+ /* check if the user is logged-in
 343+ if not, avoid the road of pain and use AjaxLogin if enabled
 344+ */
 345+ if ((wgEnableAjaxLogin == 1) && (typeof wgUserName != 'string')) {
 346+ wgAjaxLoginSkipSuccess = true ;
 347+ if ( ! YAHOO.Wikia.AjaxLoginApp.loginPanel ) {
 348+ YAHOO.Wikia.AjaxLoginApp.buildLoginPanel();
 349+ }
 350+ YAHOO.Wikia.AjaxLoginApp.loginPanel.show();
 351+ return ;
 352+ }
 353+ /* add a guard for Ajax login disabled and reload in this window, as done before */
 354+ if (typeof wgUserName == 'string') {
 355+ imageUploadDialog = window.open("http://" + domain + "/wiki/Special:MiniUpload?type=image", "upload_file", "height=520,width=500,toolbar=no,location=no,resizable=no,top=0,left=0,menubar=0");
 356+
 357+ } else {
 358+ window.location.replace ("http://" + domain + "/wiki/Special:Userlogin?returnto=" + wgPageName) ;
 359+ }
 360+}
 361+
 362+proto.insert_div_after = function (div) {
 363+ div.style.display = 'none';
 364+ if (! div.iframe_hack) {
 365+ if (this.div.parentNode.lastchild == this.div) {
 366+ this.div.parentNode.appendChild (div) ;
 367+ } else {
 368+ this.div.parentNode.insertBefore (div, this.div.nextSibling);
 369+ }
 370+ }
 371+}
 372+
206373 // Wikiwyg actions - public methods
207374 proto.saveChanges = function() {
208375 alert('Wikiwyg.prototype.saveChanges not subclassed');
209376 }
210377
 378+/* indicate action */
 379+proto.toggleThrobber = function (section) {
 380+ return ;
 381+ var Throbber = document.getElementById ('ajaxProgressIcon_' + section) ;
 382+ if (Throbber.style.visibility == 'hidden') {
 383+ Throbber.style.visibility = 'visible' ;
 384+ } else {
 385+ Throbber.style.visibility = 'hidden' ;
 386+ }
 387+ return true ;
 388+}
 389+
211390 proto.editMode = function() { // See IE, below
 391+ currentWikiwyg = this ;
212392 this.current_mode = this.first_mode;
213 - this.current_mode.fromHtml(this.div.innerHTML);
214 - this.toolbarObject.resetModeSelector();
215 - this.current_mode.enableThis();
 393+ this.current_mode.initHtml(this.div.innerHTML);
 394+ this.toolbarObject.resetModeSelector() ;
 395+ this.current_mode.enableThis() ;
216396 }
217397
218398 proto.displayMode = function() {
@@ -252,6 +432,10 @@
253433 this.displayMode();
254434 }
255435
 436+proto.initHtml = function (html) {
 437+ this.fromHtml (html) ;
 438+}
 439+
256440 proto.fromHtml = function(html) {
257441 this.div.innerHTML = html;
258442 }
@@ -260,9 +444,14 @@
261445 this.insert_div_before(div);
262446 }
263447
 448+proto.placeLowerToolbar = function (div) {
 449+ this.insert_div_after(div) ;
 450+}
 451+
264452 proto.setFirstModeByName = function(mode_name) {
265 - if (!this.modeByName(mode_name))
 453+ if (!this.modeByName(mode_name)) {
266454 die('No mode named ' + mode_name);
 455+}
267456 this.first_mode = this.modeByName(mode_name);
268457 }
269458
@@ -272,16 +461,16 @@
273462 return 'wikiwyg_' + Wikiwyg.unique_id_base++;
274463 }
275464
276 -// This method is deprecated. Use Ajax.get and Ajax.post.
 465+// This method is deprecated. Use WKWAjax.get and WKWAjax.post.
277466 Wikiwyg.liveUpdate = function(method, url, query, callback) {
278467 if (method == 'GET') {
279 - return Ajax.get(
 468+ return WKWAjax.get(
280469 url + '?' + query,
281470 callback
282471 );
283472 }
284473 if (method == 'POST') {
285 - return Ajax.post(
 474+ return WKWAjax.post(
286475 url,
287476 query,
288477 callback
@@ -317,6 +506,28 @@
318507 document.getElementById(id).style.visibility = 'hidden';
319508 }
320509
 510+proto.showChanges = function () {
 511+ wikitext = this.current_mode.toWikitext () ;
 512+ var self = this ;
 513+ WKWAjax.post(
 514+ fixupRelativeUrl('index.php/' + wgSpecialPrefix + ':PocketDiff') + "&rtitle=" + wgPageName + "&rsection=" + this.section_number ,
 515+ "text=" + encodeURIComponent(wikitext),
 516+ function (html) {
 517+ /* hide the textbox, make return to editing links, allow save and all that stuff
 518+ remove all pre-existing wrappers
 519+ */
 520+ self.toolbarObject.rebuildDiffs () ;
 521+ var diff_div_wrapper = document.getElementById ('wikiwyg_diff_wrapper') ;
 522+ if (!diff_div_wrapper) {
 523+ diff_div_wrapper = Wikiwyg.createElementWithAttrs ('div', {id: 'wikiwyg_diff_wrapper'}) ;
 524+ }
 525+ diff_div_wrapper.innerHTML = html ;
 526+ self.insert_div_before (diff_div_wrapper) ;
 527+ self.current_mode.textarea.style.display = 'none' ;
 528+ diff_div_wrapper.style.display = '' ;
 529+ }
 530+ );
 531+}
321532
322533 Wikiwyg.changeLinksMatching = function(attribute, pattern, func) {
323534 var links = document.getElementsByTagName('a');
@@ -402,6 +613,10 @@
403614 this.display_unsupported_toolbar_buttons('none');
404615 this.wikiwyg.toolbarObject.enableThis();
405616 this.wikiwyg.div.style.display = 'none';
 617+ if (!wgFullPageEditing && (wgCanonicalSpecialPageName != 'Createpage')) {
 618+ this.wikiwyg.toolbarObject.summaryDiv.style.display = 'block' ;
 619+ this.wikiwyg.toolbarObject.linksDiv.style.display = 'block' ;
 620+ }
406621 }
407622
408623 proto.display_unsupported_toolbar_buttons = function(display) {
@@ -435,6 +650,10 @@
436651 proto.disableThis = function() {
437652 this.display_unsupported_toolbar_buttons('inline');
438653 this.div.style.display = 'none';
 654+ if (!wgFullPageEditing) {
 655+ this.wikiwyg.toolbarObject.summaryDiv.style.display = 'none' ;
 656+ this.wikiwyg.toolbarObject.linksDiv.style.display = 'none' ;
 657+ }
439658 }
440659
441660 proto.process_command = function(command) {
@@ -479,6 +698,9 @@
480699 this.config.editHeightAdjustment
481700 );
482701 var min = this.config.editHeightMinimum;
 702+ if (this.config.overrideHeightMinimum) {
 703+ return min ;
 704+ }
483705 return height < min
484706 ? min
485707 : height;
@@ -567,13 +789,19 @@
568790
569791 COPYRIGHT:
570792
571 - Copyright (c) 2005 Socialtext Corporation
 793+ Copyright (c) 2005 Socialtext Corporation
572794 655 High Street
573795 Palo Alto, CA 94301 U.S.A.
574796 All rights reserved.
575797
576 -Wikiwyg is free software.
 798+CHANGES AUTHOR:
577799
 800+ Bartek Lapinski <bartek@wikia.com>
 801+
 802+ Copyright (c) 2007, Wikia Inc.
 803+
 804+Wikiwyg is free software.
 805+
578806 This library is free software; you can redistribute it and/or modify it
579807 under the terms of the GNU Lesser General Public License as published by
580808 the Free Software Foundation; either version 2.1 of the License, or (at
@@ -610,9 +838,9 @@
611839 return list;
612840 }
613841
614 -// getStyle()
 842+// WKWgetStyle()
615843 // http://www.robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/
616 -function getStyle(oElm, strCssRule) {
 844+function WKWgetStyle(oElm, strCssRule) {
617845 var strValue = "";
618846 if(document.defaultView && document.defaultView.getComputedStyle){
619847 strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule);
@@ -666,7 +894,7 @@
667895 Wait.EXPORT = [ 'wait' ];
668896 Wait.EXPORT_TAGS = { ':all': Wait.EXPORT };
669897
670 -Wait.interval = 100;
 898+Wait.interval = 300;
671899
672900 Wait.wait = function(arg1, arg2, arg3, arg4) {
673901 if ( typeof arg1 == 'function'
@@ -718,25 +946,25 @@
719947 //------------------------------------------------------------------------------
720948 // Ajax support
721949 //------------------------------------------------------------------------------
722 -if (! this.Ajax) Ajax = {};
 950+if (! this.WKWAjax) WKWAjax = {};
723951
724 -Ajax.get = function(url, callback) {
 952+WKWAjax.get = function(url, callback) {
725953 var req = new XMLHttpRequest();
726954 req.open('GET', url, Boolean(callback));
727 - return Ajax._send(req, null, callback);
 955+ return WKWAjax._send(req, null, callback);
728956 }
729957
730 -Ajax.post = function(url, data, callback) {
 958+WKWAjax.post = function(url, data, callback) {
731959 var req = new XMLHttpRequest();
732960 req.open('POST', url, Boolean(callback));
733961 req.setRequestHeader(
734 - 'Content-Type',
 962+ 'Content-Type',
735963 'application/x-www-form-urlencoded'
736964 );
737 - return Ajax._send(req, data, callback);
 965+ return WKWAjax._send(req, data, callback);
738966 }
739967
740 -Ajax._send = function(req, data, callback) {
 968+WKWAjax._send = function(req, data, callback) {
741969 if (callback) {
742970 req.onreadystatechange = function() {
743971 if (req.readyState == 4) {
@@ -1070,13 +1298,20 @@
10711299
10721300 COPYRIGHT:
10731301
1074 - Copyright (c) 2005 Socialtext Corporation
 1302+ Copyright (c) 2005 Socialtext Corporation
10751303 655 High Street
10761304 Palo Alto, CA 94301 U.S.A.
10771305 All rights reserved.
10781306
1079 -Wikiwyg is free software.
 1307+CHANGES AUTHOR:
10801308
 1309+ Bartek Lapinski <bartek@wikia.com>
 1310+
 1311+ Copyright (c) 2007, Wikia Inc.
 1312+
 1313+
 1314+Wikiwyg is free software.
 1315+
10811316 This library is free software; you can redistribute it and/or modify it
10821317 under the terms of the GNU Lesser General Public License as published by
10831318 the Free Software Foundation; either version 2.1 of the License, or (at
@@ -1144,13 +1379,19 @@
11451380
11461381 COPYRIGHT:
11471382
1148 - Copyright (c) 2005 Socialtext Corporation
 1383+ Copyright (c) 2005 Socialtext Corporation
11491384 655 High Street
11501385 Palo Alto, CA 94301 U.S.A.
11511386 All rights reserved.
11521387
1153 -Wikiwyg is free software.
 1388+CHANGES AUTHOR:
11541389
 1390+ Bartek Lapinski <bartek@wikia.com>
 1391+
 1392+ Copyright (c) 2007, Wikia Inc.
 1393+
 1394+Wikiwyg is free software.
 1395+
11551396 This library is free software; you can redistribute it and/or modify it
11561397 under the terms of the GNU Lesser General Public License as published by
11571398 the Free Software Foundation; either version 2.1 of the License, or (at
@@ -1174,31 +1415,35 @@
11751416 imagesExtension: '.gif',
11761417 controlLayout: [
11771418 'save', 'cancel', 'mode_selector', '/',
1178 - // 'selector',
11791419 'h1', 'h2', 'h3', 'h4', 'p', 'pre', '|',
11801420 'bold', 'italic', 'underline', 'strike', '|',
11811421 'link', 'hr', '|',
11821422 'ordered', 'unordered', '|',
11831423 'indent', 'outdent', '|',
1184 - 'table', '|',
 1424+ 'table', '|', 'timestamp' ,
11851425 'help'
11861426 ],
11871427 styleSelector: [
11881428 'label', 'p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'pre'
11891429 ],
 1430+
11901431 controlLabels: {
1191 - save: 'Save',
1192 - cancel: 'Cancel',
 1432+ save: wgSaveCaption ,
 1433+ cancel: wgCancelCaption ,
11931434 bold: 'Bold (Ctrl+b)',
11941435 italic: 'Italic (Ctrl+i)',
11951436 underline: 'Underline (Ctrl+u)',
 1437+ insertimage: wgInsertImageCaption ,
 1438+ youtube: 'Add YouTube Video' ,
 1439+ wikify: 'Wikify' ,
11961440 strike: 'Strike Through (Ctrl+d)',
1197 - hr: 'Horizontal Rule',
 1441+ hr: wgHrTip ,
11981442 ordered: 'Numbered List',
11991443 unordered: 'Bulleted List',
12001444 indent: 'More Indented',
12011445 outdent: 'Less Indented',
12021446 help: 'About Wikiwyg',
 1447+ timestamp: wgTimestampTip ,
12031448 label: '[Style]',
12041449 p: 'Normal Text',
12051450 pre: 'Preformatted',
@@ -1208,13 +1453,14 @@
12091454 h4: 'Heading 4',
12101455 h5: 'Heading 5',
12111456 h6: 'Heading 6',
1212 - link: 'Create Link',
 1457+ link: wgIntlinkTip ,
 1458+ www: wgExtlinkTip ,
12131459 unlink: 'Remove Linkedness',
12141460 table: 'Create Table'
12151461 }
12161462 };
12171463
1218 -proto.initializeObject = function() {
 1464+proto.initializeObject = function(section_number) {
12191465 if (this.config.divId) {
12201466 this.div = document.getElementById(this.config.divId);
12211467 }
@@ -1222,34 +1468,233 @@
12231469 this.div = Wikiwyg.createElementWithAttrs(
12241470 'div', {
12251471 'class': 'wikiwyg_toolbar',
1226 - id: 'wikiwyg_toolbar'
 1472+ id: 'wikiwyg_toolbar_' + section_number
12271473 }
1228 - );
 1474+ ) ;
12291475 }
 1476+ this.section_number = section_number ;
 1477+ var config = this.config;
12301478
1231 - var config = this.config;
 1479+ /* add two containers for two sets of controls */
 1480+ var left_div = Wikiwyg.createElementWithAttrs(
 1481+ 'div', {
 1482+ id: 'wikiwyg_toolbar_left' + section_number
 1483+ }
 1484+ ) ;
 1485+
 1486+ var right_div = Wikiwyg.createElementWithAttrs(
 1487+ 'div', {
 1488+ id: 'wikiwyg_toolbar_right' + section_number ,
 1489+ 'style': 'float: right'
 1490+ }
 1491+ ) ;
 1492+
 1493+ this.div.appendChild (right_div) ;
 1494+ this.div.appendChild (left_div) ;
 1495+ this.addControls (config, left_div, right_div) ;
 1496+}
 1497+
 1498+proto.addControls = function (config, left_div, right_div) {
12321499 for (var i = 0; i < config.controlLayout.length; i++) {
12331500 var action = config.controlLayout[i];
12341501 var label = config.controlLabels[action];
1235 - if (action == 'save')
1236 - this.addControlItem(label, 'saveChanges');
1237 - else if (action == 'cancel')
1238 - this.addControlItem(label, 'cancelEdit');
1239 - else if (action == 'mode_selector')
1240 - this.addModeSelector();
 1502+ if (action == 'save') {
 1503+ if (right_div != '') {
 1504+ this.addControlItem(label, 'saveChanges', right_div, '');
 1505+ }
 1506+ }
 1507+ else if (action == 'cancel') {
 1508+ if (right_div != '') {
 1509+ this.addControlItem(label, 'cancelEdit', right_div, '');
 1510+ }
 1511+ }
 1512+ else if (action == 'mode_selector') {
 1513+ if (right_div != '') {
 1514+ this.addFixedModeSelector ('', right_div, 'Wikitext', '') ;
 1515+ }
 1516+ }
 1517+ else if (action == 'insertimage')
 1518+ this.addControlItem(label, "imageUpload('[[Image:',']]')", left_div, '') ;
12411519 else if (action == 'selector')
12421520 this.add_styles();
12431521 else if (action == 'help')
1244 - this.add_help_button(action, label);
1245 - else if (action == '|')
1246 - this.add_separator();
 1522+ this.addHelpItem (left_div);
 1523+ else if (action == '|l')
 1524+ this.add_separator (left_div) ;
 1525+ else if (action == '|r') {
 1526+ if (right_div != '') {
 1527+ this.add_separator (right_div) ;
 1528+ }
 1529+ }
12471530 else if (action == '/')
1248 - this.add_break();
 1531+ this.add_break (left_div) ;
 1532+ else if (action == '[') {
 1533+ if (right_div != '') {
 1534+ this.add_text ('[', right_div) ;
 1535+ }
 1536+ }
 1537+ else if (action == ']') {
 1538+ if (right_div != '') {
 1539+ this.add_text (']', right_div) ;
 1540+ }
 1541+ }
12491542 else
1250 - this.add_button(action, label);
 1543+ this.add_button (action, label, left_div) ;
12511544 }
12521545 }
12531546
 1547+/* rebuild the toolbar for preview mode mostly */
 1548+proto.changeMode = function () {
 1549+ this.rebuild () ;
 1550+}
 1551+
 1552+/* divided for more convenience */
 1553+proto.placeSummarySection = function () {
 1554+ this.summaryDiv = Wikiwyg.createElementWithAttrs (
 1555+ 'div', {
 1556+ 'class': '',
 1557+ id: 'wikiwyg_summary_' + this.section_number ,
 1558+ 'style': 'clear'
 1559+
 1560+ }
 1561+ ) ;
 1562+
 1563+ /* place bowels of the summary here */
 1564+ var summaryInput = Wikiwyg.createElementWithAttrs(
 1565+ 'input', {
 1566+ 'type': 'text' ,
 1567+ 'value': '',
 1568+ 'name': 'wpSummary_' + this.section_number ,
 1569+ id: 'wpSummary_' + this.section_number ,
 1570+ 'style': 'min-width:300px; max-width:600px'
 1571+ }
 1572+ ) ;
 1573+
 1574+ var edit_table = document.createElement ('table') ;
 1575+ var first_row = document.createElement ('tr') ;
 1576+ var edit_td1 = Wikiwyg.createElementWithAttrs ('td', {'class': 'editpage-header'} ) ;
 1577+ var edit_td2 = document.createElement ('td') ;
 1578+
 1579+ edit_td1.appendChild (document.createTextNode (wgSummaryCaption + ':') ) ;
 1580+ edit_td2.appendChild (summaryInput) ;
 1581+
 1582+ /* for logged in, create two additional checkboxes */
 1583+ if ((typeof wgUserName == 'string') && (wgCanonicalSpecialPageName != "Createpage") ) {
 1584+ var newMinorInput = Wikiwyg.createElementWithAttrs ('input',
 1585+ {'id': 'wpMinoredit_' + this.section_number ,
 1586+ 'name': 'wpMinoredit' + this.section_number ,
 1587+ 'type': 'checkbox' ,
 1588+ 'value': '1' ,
 1589+ 'accesskey': 'i'
 1590+ }) ;
 1591+
 1592+ var newMinorInputLabel = Wikiwyg.createElementWithAttrs ('label',
 1593+ {'for': 'wpMinoredit_' + this.section_number ,
 1594+ 'accesskey': 'i' ,
 1595+ 'title': '' ,
 1596+ 'class': 'no-float'
 1597+ }) ;
 1598+
 1599+ newMinorInputLabel.innerHTML = wgMinoreditCaption ;
 1600+
 1601+ var newWatchthisInput = Wikiwyg.createElementWithAttrs ('input',
 1602+ {'id': 'wpWatchthis_' + this.section_number ,
 1603+ 'name': 'wpWatchthis_' + this.section_number ,
 1604+ 'type': 'checkbox' ,
 1605+ 'value': '1' ,
 1606+ 'accesskey': 'w',
 1607+ 'checked': 'checked'
 1608+ }) ;
 1609+
 1610+ var newWatchthisInputLabel = Wikiwyg.createElementWithAttrs ('label',
 1611+ {'for': 'wpWatchthis_' + this.section_number ,
 1612+ 'accesskey': 'w' ,
 1613+ 'title': '' ,
 1614+ 'class': 'no-float'
 1615+ }) ;
 1616+
 1617+ newWatchthisInputLabel.innerHTML = wgWatchthisCaption ;
 1618+ edit_td2.appendChild (newMinorInput) ;
 1619+ edit_td2.appendChild (newMinorInputLabel) ;
 1620+
 1621+ edit_td2.appendChild (newWatchthisInput) ;
 1622+ edit_td2.appendChild (newWatchthisInputLabel) ;
 1623+ }
 1624+
 1625+
 1626+ first_row.appendChild (edit_td1) ;
 1627+ first_row.appendChild (edit_td2) ;
 1628+ edit_table.appendChild (first_row) ;
 1629+ this.summaryDiv.appendChild (edit_table) ;
 1630+}
 1631+
 1632+proto.placeLowerLinksSection = function () {
 1633+ /* two more divs, one will include real edit summary, the second will hold checkboxes */
 1634+ this.linksDiv = Wikiwyg.createElementWithAttrs (
 1635+ 'div', {
 1636+ 'class': 'wikiwyg_toolbar' ,
 1637+ id: 'wikiwyg_links_' + this.section_number
 1638+ }
 1639+ ) ;
 1640+
 1641+ /* left and right, one floats, one not */
 1642+ var linksLeft = Wikiwyg.createElementWithAttrs (
 1643+ 'div', {
 1644+ 'class': '' ,
 1645+ id: 'wikiwyg_links_l_' + this.section_number
 1646+ }
 1647+ ) ;
 1648+
 1649+ var linksRight = Wikiwyg.createElementWithAttrs (
 1650+ 'div', {
 1651+ 'class': '' ,
 1652+ id: 'wikiwyg_links_r_' + this.section_number ,
 1653+ 'style': 'float: right'
 1654+ }
 1655+ ) ;
 1656+
 1657+ this.linksDiv.appendChild (linksRight) ;
 1658+ this.linksDiv.appendChild (linksLeft) ;
 1659+ if (wgFullPageEditing == true) {
 1660+ this.addCategoryItem (linksLeft) ;
 1661+ this.add_separator (linksLeft) ;
 1662+ }
 1663+ this.addControlItem ('Show changes', 'showChanges', linksLeft, '') ;
 1664+ this.add_separator (linksLeft) ;
 1665+ this.addControlItem ('License', 'showLicense', linksLeft, '') ;
 1666+
 1667+ this.add_text ('[', linksRight) ;
 1668+ this.addFixedModeSelector ('', linksRight, 'Wikitext', 'lower') ;
 1669+ this.add_separator (linksRight) ;
 1670+ this.addControlItem (wgSaveCaption,'saveChanges', linksRight, 'lower') ;
 1671+ this.add_separator (linksRight) ;
 1672+ this.addControlItem(wgCancelCaption, 'cancelEdit', linksRight, 'lower') ;
 1673+ this.add_text (']', linksRight) ;
 1674+}
 1675+
 1676+/* let's do it here, then apply this within the initialization process */
 1677+proto.placeLowerToolbar = function () {
 1678+ this.placeSummarySection () ;
 1679+ this.placeLowerLinksSection () ;
 1680+}
 1681+
 1682+proto.addCategoryItem = function (div) {
 1683+ /* if categories are shown, procure a link to hide them, if not,
 1684+ procure a link to show them
 1685+ */
 1686+ var cloud_section = document.getElementById ('editpage_cloud_section') ;
 1687+ if (!cloud_section) {
 1688+ /* temporary placeholder to avoid error */
 1689+ this.addControlItem ('Add category', 'toggleCategory', div, '') ;
 1690+ return ;
 1691+ }
 1692+ if (cloud_section.style.display == 'none' ) {
 1693+ this.addControlItem ('Add category', 'toggleCategory', div, '') ;
 1694+ } else {
 1695+ this.addControlItem ('Hide category', 'toggleCategory', div, '') ;
 1696+ }
 1697+}
 1698+
12541699 proto.enableThis = function() {
12551700 this.div.style.display = 'block';
12561701 }
@@ -1258,6 +1703,70 @@
12591704 this.div.style.display = 'none';
12601705 }
12611706
 1707+proto.rebuild = function () {
 1708+ /* depending on current mode, mangle the toolbar or rebuild it */
 1709+ var left_links = document.getElementById ('wikiwyg_toolbar_left' + this.section_number) ;
 1710+ var lower_left_links = document.getElementById ('wikiwyg_links_l_' + this.section_number) ;
 1711+ var right_mode = document.getElementById ('wikiwyg_ctrl_lnk_preview' + this.section_number ) ;
 1712+ var right_lower_mode = document.getElementById ('wikiwyg_ctrl_lnk_lower_preview' + this.section_number ) ;
 1713+
 1714+ left_links.innerHTML = '' ;
 1715+ lower_left_links.innerHTML = '' ;
 1716+
 1717+ if (this.wikiwyg.current_mode.classname.match(/(Wikitext)/)) {
 1718+ this.addFixedModeSelector ('Return to editing', left_links, 'Preview', '') ;
 1719+ this.addFixedModeSelector ('Return to editing', lower_left_links, 'Preview', 'lower') ;
 1720+ right_mode.innerHTML = wgEditCaption.toLowerCase () ;
 1721+ right_lower_mode.innerHTML = wgEditCaption.toLowerCase () ;
 1722+ this.updateModeSelector (right_mode, 'Preview') ;
 1723+ this.updateModeSelector (right_lower_mode, 'Preview') ;
 1724+ } else {
 1725+ /* rebuild the toolbar */
 1726+ this.addControls (this.config, left_links, '') ;
 1727+ this.addControlItem ('Show changes', 'showChanges', lower_left_links, '') ;
 1728+ this.add_separator (lower_left_links) ;
 1729+ this.addControlItem ('License', 'showLicense', lower_left_links, '') ;
 1730+ Event.addListener ('wikiwyg_ctrl_lnk_showLicense_' + this.section_number, 'click', YAHOO.Wikia.Wikiwyg.showLicensePanel) ;
 1731+ right_mode.innerHTML = wgPreviewCaption.toLowerCase () ;
 1732+ right_lower_mode.innerHTML = wgPreviewCaption.toLowerCase () ;
 1733+ this.updateModeSelector (right_mode, 'Wikitext') ;
 1734+ this.updateModeSelector (right_lower_mode, 'Wikitext') ;
 1735+ }
 1736+}
 1737+
 1738+proto.rebuildDiffs = function () {
 1739+ /* depending on showing/not showing Diffs, mangle the toolbar or rebuild it */
 1740+ var left_links = document.getElementById ('wikiwyg_toolbar_left' + this.section_number) ;
 1741+ var lower_left_links = document.getElementById ('wikiwyg_links_l_' + this.section_number) ;
 1742+ var right_mode = document.getElementById ('wikiwyg_ctrl_lnk_preview' + this.section_number ) ;
 1743+ var right_lower_mode = document.getElementById ('wikiwyg_ctrl_lnk_lower_preview' + this.section_number ) ;
 1744+ var diff_div = document.getElementById ('wikiwyg_diff_wrapper') ;
 1745+ left_links.innerHTML = '' ;
 1746+ lower_left_links.innerHTML = '' ;
 1747+ if (!diff_div) {
 1748+ this.addFakeModeSelector ('Return to editing', left_links) ;
 1749+ this.addFakeModeSelector ('Return to editing', lower_left_links) ;
 1750+ /* todo change caption for Preview button to Edit plus switch functionality */
 1751+ right_mode.innerHTML = wgEditCaption.toLowerCase () ;
 1752+ right_lower_mode.innerHTML = wgEditCaption.toLowerCase () ;
 1753+ this.updateFakeModeSelector (right_mode) ;
 1754+ this.updateFakeModeSelector (right_lower_mode) ;
 1755+ } else {
 1756+ /* rebuild the toolbar */
 1757+ this.addControls (this.config, left_links, '') ;
 1758+ this.addControlItem ('Show changes', 'showChanges', lower_left_links, '') ;
 1759+ this.add_separator (lower_left_links) ;
 1760+ this.addControlItem ('License', 'showLicense', lower_left_links, '') ;
 1761+ Event.addListener ('wikiwyg_ctrl_lnk_showLicense_' + this.section_number, 'click', YAHOO.Wikia.Wikiwyg.showLicensePanel) ;
 1762+ right_mode.innerHTML = wgPreviewCaption.toLowerCase () ;
 1763+ right_lower_mode.innerHTML = wgPreviewCaption.toLowerCase () ;
 1764+ this.updateModeSelector (right_mode, 'Wikitext') ;
 1765+ this.updateModeSelector (right_lower_mode, 'Wikitext') ;
 1766+ this.wikiwyg.current_mode.textarea.style.display = '' ;
 1767+ diff_div.parentNode.removeChild (diff_div) ;
 1768+ }
 1769+}
 1770+
12621771 proto.make_button = function(type, label) {
12631772 var base = this.config.imagesLocation;
12641773 var ext = this.config.imagesExtension;
@@ -1277,31 +1786,41 @@
12781787 );
12791788 }
12801789
1281 -proto.add_button = function(type, label) {
 1790+proto.add_button = function(type, label, div) {
12821791 var img = this.make_button(type, label);
12831792 var self = this;
12841793 img.onclick = function() {
12851794 self.wikiwyg.current_mode.process_command(type);
12861795 };
1287 - this.div.appendChild(img);
 1796+ div.appendChild(img);
12881797 }
12891798
1290 -proto.add_help_button = function(type, label) {
1291 - var img = this.make_button(type, label);
1292 - var a = Wikiwyg.createElementWithAttrs(
1293 - 'a', {
 1799+proto.addHelpItem = function(div) {
 1800+ var span = Wikiwyg.createElementWithAttrs(
 1801+ 'span', { 'class': 'wikiwyg_control_link' }
 1802+ );
 1803+
 1804+ var link = Wikiwyg.createElementWithAttrs(
 1805+ 'a', {
12941806 target: 'wikiwyg_button',
1295 - href: 'http://www.wikiwyg.net/about/'
1296 - }
 1807+ href: 'http://www.wikia.com/wiki/Help:Tutorial_2'
 1808+ }
12971809 );
1298 - a.appendChild(img);
1299 - this.div.appendChild(a);
 1810+ link.appendChild(document.createTextNode(wgHelpCaption));
 1811+ span.appendChild(link);
 1812+ div.appendChild(span);
13001813 }
13011814
1302 -proto.add_separator = function() {
 1815+proto.add_text = function (text, div) {
 1816+ div.appendChild(
 1817+ document.createTextNode(text)
 1818+ ) ;
 1819+}
 1820+
 1821+proto.add_separator = function (div) {
13031822 var base = this.config.imagesLocation;
13041823 var ext = this.config.imagesExtension;
1305 - this.div.appendChild(
 1824+ div.appendChild(
13061825 Wikiwyg.createElementWithAttrs(
13071826 'img', {
13081827 'class': 'wikiwyg_separator',
@@ -1313,23 +1832,96 @@
13141833 );
13151834 }
13161835
1317 -proto.addControlItem = function(text, method) {
 1836+proto.addControlItem = function (text, method, div, place) {
13181837 var span = Wikiwyg.createElementWithAttrs(
13191838 'span', { 'class': 'wikiwyg_control_link' }
1320 - );
 1839+ ) ;
13211840
 1841+ if (place != '') {
 1842+ place = place + '_' ;
 1843+ }
 1844+
13221845 var link = Wikiwyg.createElementWithAttrs(
1323 - 'a', { href: '#' }
 1846+ 'a', { href: '#', id: 'wikiwyg_ctrl_lnk_' + method + '_' + place + this.section_number }
13241847 );
 1848+
13251849 link.appendChild(document.createTextNode(text));
13261850 span.appendChild(link);
1327 -
 1851+
13281852 var self = this;
1329 - link.onclick = function() { eval('self.wikiwyg.' + method + '()'); return false };
13301853
1331 - this.div.appendChild(span);
 1854+ if ( method.match (/\(/) ) {
 1855+ var add = '' ;
 1856+ } else {
 1857+ var add = '()' ;
 1858+ }
 1859+ link.onclick = function() { eval('self.wikiwyg.' + method + add); return false };
 1860+
 1861+ div.appendChild(span);
13321862 }
13331863
 1864+proto.addFixedModeSelector = function (text, div, mode, place) {
 1865+ var span = Wikiwyg.createElementWithAttrs(
 1866+ 'span', { 'class': 'wikiwyg_control_link' }
 1867+ );
 1868+ var class_name = this.wikiwyg.first_mode.classname ;
 1869+ var second_mode_short = '' ;
 1870+ var second_mode_full = '' ;
 1871+ /* for now, extract the _other_ mode classname
 1872+ in our case, it's preview
 1873+ but let's not be _too_ sure about it...
 1874+ */
 1875+ var mode_regex = new RegExp (mode) ;
 1876+
 1877+ for (var i = 0; i < this.wikiwyg.config.modeClasses.length; i++) {
 1878+ var class_name = this.wikiwyg.config.modeClasses[i] ;
 1879+ if (!class_name.match (mode_regex)) {
 1880+ second_mode_short = this.wikiwyg.mode_objects[class_name].modeDescription.toLowerCase () ;
 1881+ second_mode_full = class_name ;
 1882+ }
 1883+ }
 1884+ if (place != '') {
 1885+ place = place + '_' ;
 1886+ }
 1887+
 1888+ var link = Wikiwyg.createElementWithAttrs(
 1889+ 'a', { href: '#', id: 'wikiwyg_ctrl_lnk_' + place + second_mode_short + this.section_number }
 1890+ );
 1891+ if (text == '') {
 1892+ link.appendChild (document.createTextNode (second_mode_short)) ;
 1893+ } else {
 1894+ link.appendChild (document.createTextNode (text)) ;
 1895+ }
 1896+ span.appendChild (link) ;
 1897+
 1898+ var self = this;
 1899+ link.onclick = function() { self.wikiwyg.switchMode (second_mode_full) ; return false };
 1900+ div.appendChild(span);
 1901+}
 1902+
 1903+proto.updateFakeModeSelector = function (link) {
 1904+ var self = this;
 1905+ /* todo track this properly */
 1906+ link.onclick = function() { self.rebuildDiffs () ; return false };
 1907+}
 1908+
 1909+proto.updateModeSelector = function (link, mode) {
 1910+ var second_mode_short = '' ;
 1911+ var second_mode_full = '' ;
 1912+ var mode_regex = new RegExp (mode) ;
 1913+
 1914+ for (var i = 0; i < this.wikiwyg.config.modeClasses.length; i++) {
 1915+ var class_name = this.wikiwyg.config.modeClasses[i] ;
 1916+ if (!class_name.match (mode_regex)) {
 1917+ second_mode_short = this.wikiwyg.mode_objects[class_name].modeDescription.toLowerCase () ;
 1918+ second_mode_full = class_name ;
 1919+ }
 1920+ }
 1921+
 1922+ var self = this;
 1923+ link.onclick = function() { self.wikiwyg.switchMode (second_mode_full) ; return false };
 1924+}
 1925+
13341926 proto.resetModeSelector = function() {
13351927 if (this.firstModeRadio) {
13361928 var temp = this.firstModeRadio.onclick;
@@ -1339,6 +1931,40 @@
13401932 }
13411933 }
13421934
 1935+proto.addFakeModeSelector = function (text, div, mode) {
 1936+ var span = Wikiwyg.createElementWithAttrs(
 1937+ 'span', { 'class': 'wikiwyg_control_link' }
 1938+ );
 1939+ var class_name = this.wikiwyg.first_mode.classname ;
 1940+ var second_mode_short = '' ;
 1941+ var second_mode_full = '' ;
 1942+
 1943+ /* todo there are *two* buttons - make each have unique div */
 1944+ var link = Wikiwyg.createElementWithAttrs(
 1945+ 'a', { href: '#', id: 'wikiwyg_ctrl_lnk_ReturnFromDiff'}
 1946+ );
 1947+ if (text == '') {
 1948+ link.appendChild (document.createTextNode (second_mode_short)) ;
 1949+ } else {
 1950+ link.appendChild (document.createTextNode (text)) ;
 1951+ }
 1952+ span.appendChild (link) ;
 1953+
 1954+ var self = this;
 1955+ link.onclick = function() { self.rebuildDiffs () ; return false };
 1956+ div.appendChild(span);
 1957+}
 1958+
 1959+proto.resetModeSelector = function() {
 1960+ if (this.firstModeRadio) {
 1961+ var temp = this.firstModeRadio.onclick;
 1962+ this.firstModeRadio.onclick = null;
 1963+ this.firstModeRadio.click();
 1964+ this.firstModeRadio.onclick = temp;
 1965+ }
 1966+}
 1967+
 1968+
13431969 proto.addModeSelector = function() {
13441970 var span = document.createElement('span');
13451971
@@ -1346,27 +1972,25 @@
13471973 for (var i = 0; i < this.wikiwyg.config.modeClasses.length; i++) {
13481974 var class_name = this.wikiwyg.config.modeClasses[i];
13491975 var mode_object = this.wikiwyg.mode_objects[class_name];
1350 -
 1976+
13511977 var radio_id = Wikiwyg.createUniqueId();
1352 -
1353 - var checked = i == 0 ? 'checked' : '';
13541978 var radio = Wikiwyg.createElementWithAttrs(
13551979 'input', {
1356 - type: 'radio',
1357 - name: radio_name,
1358 - id: radio_id,
1359 - value: mode_object.classname,
1360 - 'checked': checked
 1980+ type: 'radio' ,
 1981+ name: radio_name ,
 1982+ id: radio_id ,
 1983+ value: mode_object.classname
13611984 }
13621985 );
13631986 if (!this.firstModeRadio)
13641987 this.firstModeRadio = radio;
1365 -
 1988+
13661989 var self = this;
1367 - radio.onclick = function() {
 1990+
 1991+ radio.onclick = function() {
13681992 self.wikiwyg.switchMode(this.value);
13691993 };
1370 -
 1994+
13711995 var label = Wikiwyg.createElementWithAttrs(
13721996 'label', { 'for': radio_id }
13731997 );
@@ -1378,11 +2002,11 @@
13792003 this.div.appendChild(span);
13802004 }
13812005
1382 -proto.add_break = function() {
1383 - this.div.appendChild(document.createElement('br'));
 2006+proto.add_break = function (div) {
 2007+ div.appendChild(document.createElement('br'));
13842008 }
13852009
1386 -proto.add_styles = function() {
 2010+proto.add_styles = function (div) {
13872011 var options = this.config.styleSelector;
13882012 var labels = this.config.controlLabels;
13892013
@@ -1401,10 +2025,10 @@
14022026 this.styleSelect.appendChild(option);
14032027 }
14042028 var self = this;
1405 - this.styleSelect.onchange = function() {
1406 - self.set_style(this.value)
 2029+ this.styleSelect.onchange = function() {
 2030+ self.set_style(this.value)
14072031 };
1408 - this.div.appendChild(this.styleSelect);
 2032+ div.appendChild(this.styleSelect);
14092033 }
14102034
14112035 proto.set_style = function(style_name) {
@@ -1420,13 +2044,19 @@
14212045
14222046 COPYRIGHT:
14232047
1424 - Copyright (c) 2005 Socialtext Corporation
 2048+ Copyright (c) 2005 Socialtext Corporation
14252049 655 High Street
14262050 Palo Alto, CA 94301 U.S.A.
14272051 All rights reserved.
14282052
1429 -Wikiwyg is free software.
 2053+CHANGES AUTHOR:
14302054
 2055+ Bartek Lapinski <bartek@wikia.com>
 2056+
 2057+ Copyright (c) 2007, Wikia Inc.
 2058+
 2059+Wikiwyg is free software.
 2060+
14312061 This library is free software; you can redistribute it and/or modify it
14322062 under the terms of the GNU Lesser General Public License as published by
14332063 the Free Software Foundation; either version 2.1 of the License, or (at
@@ -1444,7 +2074,7 @@
14452075 proto = new Subclass('Wikiwyg.Preview', 'Wikiwyg.Mode');
14462076
14472077 proto.classtype = 'preview';
1448 -proto.modeDescription = 'Preview';
 2078+proto.modeDescription = wgPreviewCaption ;
14492079
14502080 proto.config = {
14512081 divId: null
@@ -1456,9 +2086,16 @@
14572087 else
14582088 this.div = document.createElement('div');
14592089 // XXX Make this a config option.
1460 - this.div.style.backgroundColor = 'lightyellow';
 2090+ this.div.id = 'wikiwyg_preview_area' ;
 2091+ this.div.style.backgroundColor = 'lightyellow' ;
 2092+ this.div.style.padding = '4px 4px 4px 4px' ;
 2093+ this.div.style.border = '1px solid #cccccc' ;
14612094 }
14622095
 2096+proto.initHtml = function (html) {
 2097+ this.fromHtml (html) ;
 2098+}
 2099+
14632100 proto.fromHtml = function(html) {
14642101 this.div.innerHTML = html;
14652102 }
@@ -1476,13 +2113,19 @@
14772114
14782115 COPYRIGHT:
14792116
1480 - Copyright (c) 2005 Socialtext Corporation
 2117+ Copyright (c) 2005 Socialtext Corporation
14812118 655 High Street
14822119 Palo Alto, CA 94301 U.S.A.
14832120 All rights reserved.
14842121
1485 -Wikiwyg is free software.
 2122+CHANGES AUTHOR:
14862123
 2124+ Bartek Lapinski <bartek@wikia.com>
 2125+
 2126+ Copyright (c) 2007, Wikia Inc.
 2127+
 2128+Wikiwyg is free software.
 2129+
14872130 This library is free software; you can redistribute it and/or modify it
14882131 under the terms of the GNU Lesser General Public License as published by
14892132 the Free Software Foundation; either version 2.1 of the License, or (at
@@ -1601,15 +2244,63 @@
16022245 return wikitext;
16032246 }
16042247
 2248+proto.initHtml = function (html) {
 2249+ this.fromHtml (html) ;
 2250+}
 2251+
16052252 proto.fromHtml = function(html) {
16062253 this.setTextArea('Loading...');
16072254 var self = this;
16082255 this.convertHtmlToWikitext(
1609 - html,
1610 - function(value) { self.setTextArea(value) }
 2256+ html,
 2257+ function(value) {
 2258+ value = self.fixDoubleWeightBug (value) ;
 2259+ self.setTextArea(value) ;
 2260+ }
16112261 );
16122262 }
16132263
 2264+/* seven apostrophes' solution */
 2265+proto.fixDoubleWeightBug = function (text) {
 2266+ text = this.fixBoldItalic (text) ;
 2267+ text = this.fixItalicBold (text) ;
 2268+ return text ;
 2269+}
 2270+
 2271+proto.fixBoldItalic = function (text) {
 2272+ var found = text.match (/'''''[^']+'''''''[^']+''/gi) ;
 2273+ var split = "" ;
 2274+ var modtext = "" ;
 2275+ if (!found) { /* do not touch otherwise */
 2276+ return text ;
 2277+ }
 2278+ var vtext = text ;
 2279+ var tofix = "" ;
 2280+ split = vtext.split (/'''''[^']+'''''''[^']+''/gi) ;
 2281+ for (i=0; i < found.length; i++) {
 2282+ tofix = found[i].replace ("'''''''","'''") ;
 2283+ modtext = modtext + split[i] + tofix ;
 2284+ }
 2285+ return modtext + split[found.length] ;
 2286+}
 2287+
 2288+proto.fixItalicBold = function (text) {
 2289+ var found = text.match (/'''''[^']+''''''''[^']+'''/gi) ;
 2290+ var split = "" ;
 2291+ var modtext = "" ;
 2292+ if (!found) { /* do not touch otherwise */
 2293+ return text ;
 2294+ }
 2295+ var vtext = text ;
 2296+ var tofix = "" ;
 2297+ split = vtext.split (/'''''[^']+''''''''[^']+'''/gi) ;
 2298+ for (i=0; i < found.length; i++) {
 2299+ tofix = found[i].replace ("''''''''","''") ;
 2300+ modtext = modtext + split[i] + tofix ;
 2301+ }
 2302+ return modtext + split[found.length] ;
 2303+}
 2304+
16142305 proto.getTextArea = function() {
16152306 return this.textarea.value;
16162307 }
@@ -1639,15 +2330,15 @@
16402331 proto.find_left = function(t, selection_start, matcher) {
16412332 var substring = t.substr(selection_start - 1, 1);
16422333 var nextstring = t.substr(selection_start - 2, 1);
1643 - if (selection_start == 0)
 2334+ if (selection_start == 0)
16442335 return selection_start;
16452336 if (substring.match(matcher)) {
16462337 // special case for word.word
1647 - if ((substring != '.') || (nextstring.match(/\s/)))
 2338+ if ((substring != '.') || (nextstring.match(/\s/)))
16482339 return selection_start;
16492340 }
16502341 return this.find_left(t, selection_start - 1, matcher);
1651 -}
 2342+}
16522343
16532344 proto.find_right = function(t, selection_end, matcher) {
16542345 var substring = t.substr(selection_end, 1);
@@ -1712,12 +2403,11 @@
17132404 proto.get_words = function() {
17142405 function is_insane(selection) {
17152406 return selection.match(/\r?\n(\r?\n|\*+ |\#+ |\=+ )/);
1716 - }
 2407+ }
17172408
17182409 t = this.area; // XXX needs "var"?
17192410 var selection_start = t.selectionStart;
17202411 var selection_end = t.selectionEnd;
1721 -
17222412 if (selection_start == null) {
17232413 selection_start = selection_end;
17242414 if (selection_start == null) {
@@ -1894,7 +2584,7 @@
18952585 var already_start = new RegExp('^' + this.clean_regexp(markup_start), 'gm');
18962586 var already_finish = new RegExp(this.clean_regexp(markup_finish) + '$', 'gm');
18972587 var other_start = /^(\^+|\=+|\*+|#+|>+) */gm;
1898 - var other_finish = /( +(\^+|\=+))?$/gm;
 2588+ var other_finish = /( +(\^+|\=+))?$/m;
18992589
19002590 var match;
19012591 if (this.sel.match(already_start)) {
@@ -1953,8 +2643,9 @@
19542644 var scroll_top = this.area.scrollTop;
19552645 if (markup_finish == 'undefined')
19562646 markup_finish = markup_start;
1957 - if (this.get_words())
 2647+ if (this.get_words()) {
19582648 this.add_markup_words(markup_start, markup_finish, null);
 2649+ }
19592650 this.area.scrollTop = scroll_top;
19602651 }
19612652
@@ -1985,14 +2676,96 @@
19862677 proto.do_ordered = klass.make_do('ordered');
19872678 proto.do_unordered = klass.make_do('unordered');
19882679 proto.do_hr = klass.make_do('hr');
 2680+proto.do_timestamp = klass.make_do('timestamp') ;
19892681 proto.do_table = klass.make_do('table');
19902682
 2683+do_wikify = function() {
 2684+ var selection = this.get_link_selection_text();
 2685+ if (!selection) return ;
 2686+ var self = this ;
 2687+ WKWAjax.post (
 2688+ fixupRelativeUrl('Special:Createpage') ,
 2689+ 'action=check&to_check=' + selection ,
 2690+ function (response) {
 2691+ if (response.indexOf("pagetitleexists") != -1) {
 2692+ link_color = "26579A";
 2693+ } else {
 2694+ link_color = "FF0000";
 2695+ }
 2696+ var url;
 2697+ var match = selection.match(/(.*?)\b((?:http|https|ftp|irc):\/\/\S+)(.*)/);
 2698+ if (match) {
 2699+ if (match[1] || match[3]) return null;
 2700+ url = match[2];
 2701+ }
 2702+ else {
 2703+ url = '?' + escape(selection);
 2704+ }
 2705+
 2706+ self.exec_command('createlink', url);
 2707+ self.exec_command('underline', selection);
 2708+ self.exec_command('ForeColor', "#" + link_color);
 2709+ }
 2710+ ) ;
 2711+}
 2712+
 2713+proto.do_youtube = function() {
 2714+
 2715+ if (Wikiwyg.is_ie) {
 2716+ //hack to remember Caret Position in IE
 2717+ this.ieRange = this.get_edit_document().selection.createRange();
 2718+ this.ieRange.moveStart ('character', -this.get_inner_html().length) ;
 2719+ this.ieCaretPos = this.ieRange.text.length;
 2720+ }
 2721+
 2722+ var url = prompt("Add YouTube Video. Copy and paste the video's URL or Embed code.", "");
 2723+ if (url == null) return ;
 2724+
 2725+ if(Wikiwyg.is_ie){
 2726+ // Move selection start and end to 0 position
 2727+ self.ieRange.moveStart ('character', -self.get_inner_html().length);
 2728+
 2729+ // Move selection start and end to desired position
 2730+ self.ieRange.moveStart ('character', self.ieCaretPos);
 2731+ self.ieRange.moveEnd ('character', 0);
 2732+ self.ieRange.select ();
 2733+ }
 2734+ this.insert_youtube(url) ;
 2735+}
 2736+
 2737+proto.extract_youtube_id = function(youTubeCode) {
 2738+ id = 0;
 2739+ inURL = youTubeCode.indexOf("watch?v=")
 2740+ if(inURL > -1){
 2741+ id = youTubeCode.substring(inURL+8)
 2742+ }else{
 2743+ r = /http:\/\/www.youtube.com\/v\/\w+/
 2744+ test = r.exec(youTubeCode);
 2745+ if(test){
 2746+ id = test.toString().replace("http://www.youtube.com/v/","")
 2747+ }
 2748+ }
 2749+ return id;
 2750+}
 2751+
 2752+proto.insert_youtube = function(url) {
 2753+ youTubeID = this.extract_youtube_id(url);
 2754+ if(!id){
 2755+ alert("Invalid Youtube url");
 2756+ return;
 2757+ }
 2758+ TheURL = window.location.href
 2759+ TheURL = TheURL.substring(0,TheURL.lastIndexOf("/"))
 2760+ this.exec_command('InsertImage', TheURL + "/images/YouTube_placeholder.gif?id=" + youTubeID);
 2761+}
 2762+
19912763 proto.do_www = function() {
1992 - var url = prompt("Please enter a link", "Type in your link here");
 2764+ var url = prompt("Enter the link or leave blank to link to selected page", "http://");
 2765+ if (url == null) return ;
19932766 var old = this.config.markupRules.www[1];
19942767 this.config.markupRules.www[1] += url + " ";
1995 -
1996 - // do the transformation
 2768+
 2769+ // do the transformation
19972770 var markup = this.config.markupRules['www'];
19982771 var handler = markup[0];
19992772 if (! this['markup_' + handler])
@@ -2000,7 +2773,7 @@
20012774 this['markup_' + handler](markup);
20022775
20032776 // reset
2004 - this.config.markupRules.www[1] = old;
 2777+ this.config.markupRules.www[1] = old;
20052778 }
20062779
20072780 proto.selection_mangle = function(method) {
@@ -2077,7 +2850,7 @@
20782851 if (selection_start == null) {
20792852 selection_start = selection_end;
20802853 }
2081 -
 2854+
20822855 var text = t.value;
20832856 this.selection_start = this.find_right(text, selection_start, /\r?\n/);
20842857 this.selection_end = this.selection_start;
@@ -2106,18 +2879,36 @@
21072880 this.list_type = [];
21082881 this.indent_level = 0;
21092882 this.no_collapse_text = false;
2110 -
 2883+ dom = this.fixChangedStructure (dom) ;
21112884 this.normalizeDomWhitespace(dom);
21122885 this.normalizeDomStructure(dom);
2113 -
21142886 this.walk(dom);
21152887
21162888 // add final whitespace
21172889 this.assert_new_line();
2118 -
21192890 return this.join_output(this.output);
21202891 }
21212892
 2893+proto.fixChangedStructure = function (dom) {
 2894+ var divs = this.array_elements_by_tag_name (dom, 'div', false) ;
 2895+ for (var i = 0; i < divs.length; i++) {
 2896+ if (divs[i].id == "wikiwyg_toolbar") {
 2897+ divs[i].parentNode.removeChild (divs[i]) ;
 2898+ }
 2899+ }
 2900+ var textareas = this.array_elements_by_tag_name (dom, 'textarea', false) ;
 2901+ for (var i = 0; i < textareas.length; i++) {
 2902+ textareas[i].parentNode.removeChild (textareas[i]) ;
 2903+ }
 2904+ var spans = this.array_elements_by_tag_name (dom, 'span', false) ;
 2905+ for (var i = 0; i < spans.length; i++) {
 2906+ if (spans[i].className == "editsection") {
 2907+ spans[i].parentNode.removeChild (spans[i]) ;
 2908+ }
 2909+ }
 2910+ return dom ;
 2911+}
 2912+
21222913 proto.normalizeDomStructure = function(dom) {
21232914 this.normalize_styled_blocks(dom, 'p');
21242915 this.normalize_styled_lists(dom, 'ol');
@@ -2130,7 +2921,7 @@
21312922 var grep = function(element) {
21322923 return Boolean(element.getAttribute('style'));
21332924 }
2134 -
 2925+
21352926 var elements = this.array_elements_by_tag_name(dom, tag, grep);
21362927 for (var i = 0; i < elements.length; i++) {
21372928 var element = elements[i];
@@ -2175,7 +2966,7 @@
21762967
21772968 var items = element.getElementsByTagName('li');
21782969 for (var j = 0; j < items.length; j++) {
2179 - items[j].innerHTML =
 2970+ items[j].innerHTML =
21802971 '<span style="' + style + '">' + items[j].innerHTML + '</span>';
21812972 }
21822973 }
@@ -2228,13 +3019,13 @@
22293020
22303021 if (first_node && first_node.nodeValue.match(/^ /)) {
22313022 first_node.nodeValue = first_node.nodeValue.replace(/^ +/, '');
2232 - if (prev_node && ! prev_node.nodeValue.match(/ $/))
 3023+ if (prev_node && ! prev_node.nodeValue.match(/ $/))
22333024 prev_node.nodeValue = prev_node.nodeValue + ' ';
22343025 }
22353026
22363027 if (last_node && last_node.nodeValue.match(/ $/)) {
22373028 last_node.nodeValue = last_node.nodeValue.replace(/ $/, '');
2238 - if (next_node && ! next_node.nodeValue.match(/^ /))
 3029+ if (next_node && ! next_node.nodeValue.match(/^ /))
22393030 next_node.nodeValue = ' ' + next_node.nodeValue;
22403031 }
22413032 }
@@ -2341,7 +3132,7 @@
23423133 if (part.nodeValue.match(/[^\n]/) &&
23433134 ! part.nodeValue.match(/^\n[\ \t]*$/)
23443135 ) {
2345 - if (this.no_collapse_text) {
 3136+ if (this.no_collapse_text) {
23463137 this.appendOutput(part.nodeValue);
23473138 }
23483139 else {
@@ -2382,7 +3173,7 @@
23833174 proto.format_big = proto.pass;
23843175 proto.format_blink = proto.pass;
23853176 proto.format_body = proto.pass;
2386 -proto.format_br = proto.skip;
 3177+//proto.format_br = proto.skip;
23873178 proto.format_button = proto.skip;
23883179 proto.format_caption = proto.pass;
23893180 proto.format_center = proto.pass;
@@ -2459,7 +3250,7 @@
24603251 this.first_indent_line = true;
24613252 this.indent_level += indents;
24623253
2463 - this.output = defang_last_string(this.output);
 3254+ this.output = defang_last_string (this.output) ;
24643255 this.assert_new_line();
24653256 this.walk(element);
24663257 this.indent_level -= indents;
@@ -2505,6 +3296,7 @@
25063297 }
25073298
25083299 proto.format_span = function(element) {
 3300+
25093301 if (this.is_opaque(element)) {
25103302 this.handle_opaque_phrase(element);
25113303 return;
@@ -2515,7 +3307,6 @@
25163308 this.pass(element);
25173309 return;
25183310 }
2519 -
25203311 if ( ! this.element_has_text_content(element)
25213312 && ! this.element_has_only_image_content(element)) return;
25223313 var attributes = [ 'line-through', 'bold', 'italic', 'underline' ];
@@ -2610,14 +3401,20 @@
26113402 proto.format_h6 = klass.make_formatter('h6');
26123403 proto.format_pre = klass.make_formatter('pre');
26133404
 3405+proto.format_br = function (element) {
 3406+ this.insert_new_line () ;
 3407+ this.insert_new_line () ;
 3408+}
 3409+
26143410 proto.format_p = function(element) {
26153411 if (this.is_indented(element)) {
26163412 this.format_blockquote(element);
26173413 return;
26183414 }
26193415 this.assert_blank_line();
 3416+ this.assert_blank_line();
26203417 this.walk(element);
2621 - this.assert_blank_line();
 3418+// this.assert_blank_line();
26223419 }
26233420
26243421 proto.format_a = function(element) {
@@ -2626,7 +3423,13 @@
26273424 label = label.replace(/\s+/g, ' ');
26283425 label = label.replace(/^\s+/, '');
26293426 label = label.replace(/\s+$/, '');
2630 - var href = element.getAttribute('href');
 3427+ var href = element.getAttribute('href') ;
 3428+ /* fix for IE's absolute url */
 3429+ if (Wikiwyg.is_ie) {
 3430+ if (href.indexOf(wgServer) != -1) {
 3431+ href = href.replace (wgServer, "") ;
 3432+ }
 3433+ }
26313434 if (! href) href = ''; // Necessary for <a name="xyz"></a>'s
26323435 this.make_wikitext_link(label, href, element);
26333436 }
@@ -2685,7 +3488,7 @@
26863489 );
26873490 }
26883491
2689 -proto.make_list = function(element, list_type) {
 3492+proto.make_list = function(element, list_type) {
26903493 if (! this.previous_was_newline_or_start())
26913494 this.insert_new_line();
26923495
@@ -2910,7 +3713,7 @@
29113714 var text = comment.data;
29123715 text = text.replace(/^ wiki:\s+/, '')
29133716 .replace(/-=/g, '-')
2914 - .replace(/==/g, '=')
 3717+ .replace(/==/g, '=')
29153718 .replace(/\s$/, '')
29163719 .replace(/\{(\w+):\s*\}/, '{$1}');
29173720 this.appendOutput(Wikiwyg.htmlUnescape(text))
@@ -2951,13 +3754,12 @@
29523755 proto.make_wikitext_link = function(label, href, element) {
29533756 var before = this.config.markupRules.link[1];
29543757 var after = this.config.markupRules.link[2];
2955 -
29563758 // handle external links
29573759 if (this.looks_like_a_url(href)) {
29583760 before = this.config.markupRules.www[1];
29593761 after = this.config.markupRules.www[2];
29603762 }
2961 -
 3763+
29623764 this.assert_space_or_newline();
29633765 if (! href) {
29643766 this.appendOutput(label);
@@ -2968,8 +3770,16 @@
29693771 else if (this.href_is_wiki_link(href)) {
29703772 if (this.camel_case_link(label))
29713773 this.appendOutput(label);
2972 - else
2973 - this.appendOutput(before + label + after);
 3774+ else {
 3775+ if (label != href) {
 3776+ href = href.replace (/^\/index.php\?title=/i,"?") ;
 3777+ href = href.replace (/wiki\//i, "") ;
 3778+ href = href.replace (/&action=.*$/i, "") ;
 3779+ this.appendOutput(before + href.substring(1) + '|' + label + after);
 3780+ } else {
 3781+ this.appendOutput(before + label + after);
 3782+ }
 3783+ }
29743784 }
29753785 else {
29763786 this.appendOutput(before + href + ' ' + label + after);
@@ -3025,13 +3835,19 @@
30263836
30273837 COPYRIGHT:
30283838
3029 - Copyright (c) 2005 Socialtext Corporation
 3839+ Copyright (c) 2005 Socialtext Corporation
30303840 655 High Street
30313841 Palo Alto, CA 94301 U.S.A.
30323842 All rights reserved.
30333843
3034 -Wikiwyg is free software.
 3844+CHANGES AUTHOR:
30353845
 3846+ Bartek Lapinski <bartek@wikia.com>
 3847+
 3848+ Copyright (c) 2007, Wikia Inc.
 3849+
 3850+Wikiwyg is free software.
 3851+
30363852 This library is free software; you can redistribute it and/or modify it
30373853 under the terms of the GNU Lesser General Public License as published by
30383854 the Free Software Foundation; either version 2.1 of the License, or (at
@@ -3049,7 +3865,7 @@
30503866 proto = new Subclass('Wikiwyg.Wysiwyg', 'Wikiwyg.Mode');
30513867
30523868 proto.classtype = 'wysiwyg';
3053 -proto.modeDescription = 'Wysiwyg';
 3869+proto.modeDescription = wgWysiwygCaption ;
30543870
30553871 proto.config = {
30563872 useParentStyles: true,
@@ -3057,11 +3873,12 @@
30583874 iframeId: null,
30593875 iframeObject: null,
30603876 disabledToolbarButtons: [],
3061 - editHeightMinimum: 150,
 3877+ editHeightMinimum: 250,
 3878+ overrideHeightMinimum: true ,
30623879 editHeightAdjustment: 1.3,
30633880 clearRegex: null
30643881 };
3065 -
 3882+
30663883 proto.initializeObject = function() {
30673884 this.edit_iframe = this.get_edit_iframe();
30683885 this.div = this.edit_iframe;
@@ -3072,6 +3889,10 @@
30733890 // Unneeded for Gecko
30743891 }
30753892
 3893+proto.initHtml = function (html) {
 3894+ this.fromHtml (html) ;
 3895+}
 3896+
30763897 proto.fromHtml = function(html) {
30773898 this.set_inner_html(this.sanitize_html(html));
30783899 }
@@ -3093,6 +3914,11 @@
30943915 proto.enableThis = function() {
30953916 Wikiwyg.Mode.prototype.enableThis.call(this);
30963917 this.edit_iframe.style.border = '1px black solid';
 3918+ if (this.edit_iframe.contentDocument) {
 3919+ this.edit_iframe.contentDocument.body.style.background = '#fff' ;
 3920+ } else {
 3921+ this.edit_iframe.document.body.style.background = '#fff' ;
 3922+ }
30973923 this.edit_iframe.width = '100%';
30983924 this.setHeightOf(this.edit_iframe);
30993925 this.fix_up_relative_imgs();
@@ -3100,6 +3926,28 @@
31013927 this.apply_stylesheets();
31023928 this.enable_keybindings();
31033929 this.clear_inner_html();
 3930+ if ( Wikiwyg.is_ie ) {
 3931+ var self = this;
 3932+ var win = this.get_edit_window();
 3933+ var doc = this.get_edit_document();
 3934+ self.ieSelectionBookmark = null;
 3935+ var bookmark = function() {
 3936+ var range = doc.selection.createRange();
 3937+ if ( range.getBookmark ) {
 3938+ self.ieSelectionBookmark = range.getBookmark();
 3939+ }
 3940+ }
 3941+ doc.attachEvent("onbeforedeactivate", bookmark);
 3942+ var restoreBookmark = function() {
 3943+ if (self.ieSelectionBookmark) {
 3944+ var range = doc.body.createTextRange();
 3945+ range.moveToBookmark(self.ieSelectionBookmark);
 3946+ range.collapse();
 3947+ range.select();
 3948+ }
 3949+ }
 3950+ doc.attachEvent("onactivate", restoreBookmark);
 3951+ }
31043952 }
31053953
31063954 proto.clear_inner_html = function() {
@@ -3167,15 +4015,15 @@
31684016 // IMPORT_RULE
31694017
31704018 /* It's pretty strange that this doesnt work.
3171 - That's why Ajax.get() is used to retrive the css text.
3172 -
 4019+ That's why WKWAjax.get() is used to retrive the css text.
 4020+
31734021 this.apply_linked_stylesheet({
31744022 href: style.cssRules[i].href,
31754023 type: 'text/css'
31764024 }, head);
31774025 */
3178 -
3179 - style_string += Ajax.get(style.cssRules[i].href);
 4026+
 4027+ style_string += WKWAjax.get(style.cssRules[i].href);
31804028 } else {
31814029 style_string += style.cssRules[i].cssText + "\n";
31824030 }
@@ -3243,8 +4091,14 @@
32444092 this.exec_command('formatblock', '<' + command + '>');
32454093 }
32464094
3247 -proto.do_bold = proto.exec_command;
3248 -proto.do_italic = proto.exec_command;
 4095+proto.do_bold = function () {
 4096+ this.exec_command ('bold') ;
 4097+}
 4098+
 4099+proto.do_italic = function () {
 4100+ this.exec_command ('italic') ;
 4101+}
 4102+
32494103 proto.do_underline = proto.exec_command;
32504104 proto.do_strike = function() {
32514105 this.exec_command('strikethrough');
@@ -3255,6 +4109,11 @@
32564110 proto.do_ordered = function() {
32574111 this.exec_command('insertorderedlist');
32584112 }
 4113+
 4114+proto.do_timestamp = function () {
 4115+ this.exec_command ('inserthtml', '~~~~') ;
 4116+}
 4117+
32594118 proto.do_unordered = function() {
32604119 this.exec_command('insertunorderedlist');
32614120 }
@@ -3293,13 +4152,18 @@
32944153 var selection = this.get_link_selection_text();
32954154 if (! selection) return;
32964155 var url;
3297 - var match = selection.match(/(.*?)\b((?:http|https|ftp|irc|file):\/\/\S+)(.*)/);
 4156+ url = prompt("Enter the link or leave blank to link to selected page", "");
 4157+ /* if blank, get selection */
 4158+ if (!url) {
 4159+ url = selection ;
 4160+ }
 4161+ var match = url.match(/(.*?)\b((?:http|https|ftp|irc|file):\/\/\S+)(.*)/);
32984162 if (match) {
32994163 if (match[1] || match[3]) return null;
33004164 url = match[2];
33014165 }
33024166 else {
3303 - url = '?' + escape(selection);
 4167+ url = '?' + escape(url);
33044168 }
33054169 this.exec_command('createlink', url);
33064170 }
@@ -3307,7 +4171,7 @@
33084172 proto.do_www = function() {
33094173 var selection = this.get_link_selection_text();
33104174 if (selection != null) {
3311 - var url = prompt("Please enter a link", "Type in your link here");
 4175+ var url = prompt("Enter the link or leave blank to link to selected page", "http://");
33124176 this.exec_command('createlink', url);
33134177 }
33144178 }
@@ -3371,13 +4235,19 @@
33724236
33734237 COPYRIGHT:
33744238
3375 - Copyright (c) 2005 Socialtext Corporation
 4239+ Copyright (c) 2005 Socialtext Corporation
33764240 655 High Street
33774241 Palo Alto, CA 94301 U.S.A.
33784242 All rights reserved.
33794243
3380 -Wikiwyg is free software.
 4244+CHANGES AUTHOR:
33814245
 4246+ Bartek Lapinski <bartek@wikia.com>
 4247+
 4248+ Copyright (c) 2007, Wikia Inc.
 4249+
 4250+Wikiwyg is free software.
 4251+
33824252 This library is free software; you can redistribute it and/or modify it
33834253 under the terms of the GNU Lesser General Public License as published by
33844254 the Free Software Foundation; either version 2.1 of the License, or (at
@@ -3413,9 +4283,13 @@
34144284 proto.enableThis = function() {
34154285 Wikiwyg.Mode.prototype.enableThis.call(this);
34164286 this.textarea.style.width = '100%';
3417 - this.textarea.style.height = '200px';
 4287+ this.textarea.style.height = '300px';
34184288 }
34194289
 4290+proto.initHtml = function (html) {
 4291+ this.fromHtml (html) ;
 4292+}
 4293+
34204294 proto.fromHtml = function(html) {
34214295 this.textarea.value = this.sanitize_html(html);
34224296 }
@@ -3440,12 +4314,20 @@
34414315 LivePreviewInstall = function() {};
34424316
34434317 function fixupRelativeUrl(url) {
 4318+ return FixupRelativeUrl(url);
 4319+}
 4320+
 4321+function FixupRelativeUrl(url) {
34444322 var loc = String(location);
 4323+
 4324+ if (wgArticlePath.match (/index\.php\?title=/) != '' ) {
 4325+ url = url.replace (/index\.php\//, '?title=') ;
 4326+ }
34454327 var base = loc.replace(/index\.php.*/, '');
34464328 if (base == loc)
34474329 base = loc.replace(/(.*\/wiki\/).*/, '$1');
34484330 if (base == loc)
3449 - throw("fixupRelativeUrl error: " + loc);
 4331+ throw ("fixupRelativeUrl error: " + loc);
34504332 return base + url;
34514333 }
34524334
@@ -3460,6 +4342,7 @@
34614343 // Wikiwyg initialization/startup code
34624344 (function() {
34634345 addEvent("onload", function() {Wikiwyg.MediaWiki.initialize()});
 4346+ window.onbeforeunload = confirmExit ;
34644347 })();
34654348
34664349 //------------------------------------------------------------------------------
@@ -3471,41 +4354,22 @@
34724355 klass.initialize = function() {
34734356 if (! Wikiwyg.browserIsSupported) return;
34744357
3475 - var wikiwyg_divs = grepElementsByTag('div',
 4358+ var wikiwyg_divs = grepElementsByTag('span',
34764359 function(e) { return e.id.match(/^wikiwyg_section_\d+$/) }
34774360 );
34784361 Wikiwyg.MediaWiki.wikiwyg_divs = wikiwyg_divs;
34794362 if (! Wikiwyg.MediaWiki.wikiwyg_enabled()) return;
3480 - Wikiwyg.MediaWiki.enable();
34814363 }
34824364
34834365 klass.wikiwyg_enabled = function() {
34844366 Wikiwyg.MediaWiki.main_edit_button = findEditLink();
3485 - if (! Wikiwyg.MediaWiki.main_edit_button) return false;
3486 - try {
3487 - var div = document.getElementById('p-tb');
3488 - var ul = div.getElementsByTagName('ul')[0];
3489 - } catch(e) {return false}
3490 - var li = document.createElement('li');
3491 - ul.appendChild(li);
3492 - var a = Wikiwyg.createElementWithAttrs('a', {
3493 - id: 'wikiwyg-enabler',
3494 - href: '#'
3495 - });
3496 - li.appendChild(a);
3497 -
 4367+ if (!wgIsArticle) return false ;
34984368 var enabled = Cookie.get('wikiwyg_enabled');
34994369 if (! enabled) enabled = "false";
35004370 enabled = eval(enabled);
35014371 Cookie.set('wikiwyg_enabled', String(enabled));
 4372+ Wikiwyg.MediaWiki.enable ();
35024373
3503 - a.innerHTML = enabled
3504 - ? 'Wikiwyg Enabled'
3505 - : 'Wikiwyg Disabled';
3506 - a.onclick = enabled
3507 - ? Wikiwyg.MediaWiki.disable
3508 - : Wikiwyg.MediaWiki.enable;
3509 -
35104374 return enabled;
35114375 }
35124376
@@ -3513,15 +4377,12 @@
35144378 if (Wikiwyg.MediaWiki.busy) return false;
35154379 if (Wikiwyg.MediaWiki.checkEditInProgress()) return false;
35164380 Wikiwyg.MediaWiki.busy = true;
3517 - a = document.getElementById('wikiwyg-enabler');
3518 - a.innerHTML = 'Wikiwyg Enabled';
3519 - a.onclick = Wikiwyg.MediaWiki.disable;
35204381 Cookie.set('wikiwyg_enabled', true);
35214382 // Code to actually enable Wikiwyg
35224383 var wikiwyg_divs = Wikiwyg.MediaWiki.wikiwyg_divs;
35234384 for (var i = 0; i < wikiwyg_divs.length; i++) {
35244385 var div = wikiwyg_divs[i];
3525 - var section_number = div.id.replace(/.*?(\d+)$/, '$1');
 4386+ var section_number = div.id.replace(/.*?(\d+)$/, '$1') ;
35264387 var success = Wikiwyg.MediaWiki.enable_wikiwyg_section(
35274388 div, section_number
35284389 );
@@ -3536,9 +4397,6 @@
35374398 if (Wikiwyg.MediaWiki.busy) return false;
35384399 if (Wikiwyg.MediaWiki.checkEditInProgress()) return false;
35394400 Wikiwyg.MediaWiki.busy = true;
3540 - a = document.getElementById('wikiwyg-enabler');
3541 - a.innerHTML = 'Wikiwyg Disabled';
3542 - a.onclick = Wikiwyg.MediaWiki.enable;
35434401 Cookie.set('wikiwyg_enabled', false);
35444402 // XXX Code to actually disable Wikiwyg
35454403 var wikiwyg_divs = Wikiwyg.MediaWiki.wikiwyg_divs;
@@ -3567,21 +4425,21 @@
35684426 doubleClickToEdit: true,
35694427 toolbarClass: 'Wikiwyg.Toolbar.MediaWiki',
35704428 toolbar: {
3571 - imagesLocation: '/wikiwyg/share/MediaWiki/images/',
 4429+ imagesLocation: wgScriptPath + '/extensions/wikiwyg/share/MediaWiki/images/',
35724430 imagesExtension: '.gif'
35734431 },
35744432 wysiwyg: {
35754433 iframeId: 'wikiwyg_iframe_' + section_number
35764434 },
35774435 modeClasses: [
3578 - 'Wikiwyg.Wysiwyg.MediaWiki',
3579 - 'Wikiwyg.Wikitext.MediaWiki',
 4436+ 'Wikiwyg.Wysiwyg.MediaWiki' ,
 4437+ 'Wikiwyg.Wikitext.MediaWiki' ,
35804438 'Wikiwyg.Preview.MediaWiki'
35814439 ]
35824440 }
35834441
35844442 var hasWysiwyg = true;
3585 - if (! klass.canSupportWysiwyg(section_div)) {
 4443+ if (! klass.canSupportWysiwyg(section_div) || (wgUseWysiwyg == 0)) {
35864444 hasWysiwyg = false;
35874445 myConfig.modeClasses.shift();
35884446 }
@@ -3593,13 +4451,16 @@
35944452 document.getElementById('wikiwyg_edit_' + section_number);
35954453 var edit_button = edit_button_span.getElementsByTagName('a')[0];
35964454
3597 - edit_button.edit_button_text = hasWysiwyg
3598 - ? 'Wikiwyg Edit'
3599 - : 'Quick Edit';
 4455+ edit_button.edit_button_text = wgEditCaption ;
36004456 edit_button.innerHTML = edit_button.edit_button_text;
36014457 edit_button.onclick = function() {
3602 - myWikiwyg.editMode();
3603 - return false;
 4458+ if ((Wikiwyg.MediaWiki.sectionEdited == myWikiwyg.section_number) && Wikiwyg.MediaWiki.editInProgress) {
 4459+ myWikiwyg.cancelEdit () ;
 4460+ return false ;
 4461+ } else {
 4462+ myWikiwyg.editMode() ;
 4463+ return false ;
 4464+ }
36044465 }
36054466 Wikiwyg.MediaWiki.edit_buttons.push(edit_button);
36064467
@@ -3611,23 +4472,23 @@
36124473 var edit_button_span =
36134474 document.getElementById('wikiwyg_edit_' + section_number);
36144475 var edit_button = edit_button_span.getElementsByTagName('a')[0];
3615 -
3616 - edit_button.innerHTML = 'edit';
 4476+ edit_button.innerHTML = wgEditCaption ;
36174477 edit_button.onclick = null;
36184478 }
36194479
36204480 klass.canSupportWysiwyg = function(div) {
 4481+ /* now here the real fun begins */
36214482 check_walk = function(elem) {
36224483 for (var part = elem.firstChild; part; part = part.nextSibling) {
36234484 if (part.nodeType == 1) { // element
36244485 var tag = part.nodeName;
3625 - if (tag.match(/^(H2|P|BR|HR|UL|LI|A|S)$/)) {
 4486+ if (tag.match(/^(H2|P|BR|HR|UL|LI|A|S|I|B|PRE)$/)) {
36264487 check_walk(part);
36274488 continue;
36284489 }
36294490 if (tag == 'SPAN') {
36304491 var class_name = part.className;
3631 - if (class_name && (class_name == 'wikiwyg-nowiki')) {
 4492+ if (class_name && ((class_name == 'wikiwyg-nowiki') || (class_name == 'mw-headline'))) {
36324493 check_walk(part);
36334494 continue;
36344495 }
@@ -3640,22 +4501,55 @@
36414502 }
36424503 }
36434504 }
3644 - try {check_walk(div)} catch(e) {return false}
 4505+// return true ;
 4506+ try {check_walk(div)} catch(e) { return false ; }
36454507 return true;
36464508 }
36474509
36484510 proto.editMode = function() {
 4511+ if (Wikiwyg.MediaWiki.editInProgress) {
 4512+ /* an open section exists, ask whether to abandon it or not */
 4513+ /* todo check if we have any changes */
 4514+ var c = confirm ("Another section is already opened. Do you wish to discard changes and open a new one?") ;
 4515+ if (c) {
 4516+ Wikiwyg.MediaWiki.instance.cancelEdit () ;
 4517+ } else {
 4518+ return ;
 4519+ }
 4520+ }
 4521+ needToConfirm = true ;
36494522 Wikiwyg.MediaWiki.editInProgress = true;
3650 - this.disableEditButtons();
3651 - this.getRawPage();
 4523+ Wikiwyg.MediaWiki.sectionEdited = this.section_number ;
 4524+ Wikiwyg.MediaWiki.instance = this ;
 4525+ this.disableEditButtons (this.section_number) ;
 4526+ if ( !this.getRawPage() ) {
 4527+ Wikiwyg.MediaWiki.editInProgress = false ;
 4528+ this.enableEditButtons () ;
 4529+ return ;
 4530+ }
36524531 this.disableDoubleClicks();
36534532
36544533 if ( Wikiwyg.MediaWiki.canSupportWysiwyg(this.div) ) {
3655 - var modeName = Cookie.get("WikiwygEditMode");
 4534+ if (wgFullPageEditing == true) {
 4535+ var cookieName = "WikiwygFPEditMode" ;
 4536+ } else {
 4537+ var cookieName = "WikiwygEditMode" ;
 4538+ }
 4539+ if (wgUseWysiwyg == 0) {
 4540+ var modeName = "Wikiwyg.Wikitext.MediaWiki" ;
 4541+ } else {
 4542+ /* change that to correspond */
 4543+ if (wgDefaultMode == 'wysiwyg') {
 4544+ var modeName = 'Wikiwyg.Wysiwyg.MediaWiki' ;
 4545+ } else {
 4546+ var modeName = 'Wikiwyg.Wikitext.MediaWiki' ;
 4547+ }
 4548+ //var modeName = Cookie.get (cookieName) ;
 4549+ }
36564550 if ( modeName ) {
3657 - this.first_mode = this.modeByName(modeName);
 4551+ this.first_mode = this.modeByName(modeName) ;
36584552 } else {
3659 - Cookie.set("WikiwygEditMode", this.first_mode.classname);
 4553+ Cookie.set (cookieName, this.first_mode.classname) ;
36604554 }
36614555 // Fake click on mode radio.
36624556 var modeRadios = this.toolbarObject.div.getElementsByTagName("input");
@@ -3667,9 +4561,9 @@
36684562 }
36694563 }
36704564 Wikiwyg.prototype.editMode.call(this);
 4565+ needToConfirm = true ;
36714566 }
36724567
3673 -
36744568 proto.switchMode = function(new_mode_key) {
36754569 if ( Wikiwyg.MediaWiki.canSupportWysiwyg(this.div) ) {
36764570 if ( ! new_mode_key.match(/preview/i) ) {
@@ -3677,53 +4571,134 @@
36784572 }
36794573 }
36804574 var new_mode = this.modeByName(new_mode_key);
 4575+ this.toolbarObject.changeMode () ;
36814576 Wikiwyg.prototype.switchMode.call(this, new_mode_key);
36824577 }
36834578
3684 -
3685 -proto.disableEditButtons = function() {
 4579+proto.disableEditButtons = function(section_number) {
36864580 // Disable the main page button but save the old values
36874581 // in case the user does cancels the edit.
3688 - Wikiwyg.MediaWiki.main_edit_button.old_href =
3689 - Wikiwyg.MediaWiki.main_edit_button.getAttribute('href');
3690 - Wikiwyg.MediaWiki.main_edit_button.old_color =
3691 - Wikiwyg.MediaWiki.main_edit_button.style.color;
3692 - Wikiwyg.MediaWiki.main_edit_button.style.color = 'black';
3693 - Wikiwyg.MediaWiki.main_edit_button.removeAttribute('href');
 4582+ if (Wikiwyg.MediaWiki.main_edit_button){
 4583+ Wikiwyg.MediaWiki.main_edit_button.old_href =
 4584+ Wikiwyg.MediaWiki.main_edit_button.getAttribute('href');
 4585+ Wikiwyg.MediaWiki.main_edit_button.old_color =
 4586+ Wikiwyg.MediaWiki.main_edit_button.style.color;
 4587+ Wikiwyg.MediaWiki.main_edit_button.style.color = 'black';
 4588+ Wikiwyg.MediaWiki.main_edit_button.removeAttribute('href');
 4589+ }
36944590
36954591 var buttons = Wikiwyg.MediaWiki.edit_buttons;
36964592 for (var i = 0; i < buttons.length; i++) {
36974593 var button = buttons[i];
3698 - button.innerHTML = '';
 4594+ if ((i+1) == section_number) {
 4595+ button.innerHTML = wgCancelCaption ;
 4596+ button.parentNode.style.display = 'none' ;
 4597+ }
36994598 }
37004599 }
37014600
 4601+proto.enableEditButtons = function () {
 4602+ if (Wikiwyg.MediaWiki.main_edit_button){
 4603+ Wikiwyg.MediaWiki.main_edit_button.setAttribute(
 4604+ 'href', Wikiwyg.MediaWiki.main_edit_button.old_href
 4605+ );
 4606+ Wikiwyg.MediaWiki.main_edit_button.style.color =
 4607+ Wikiwyg.MediaWiki.main_edit_button.old_color;
 4608+ }
 4609+ var buttons = Wikiwyg.MediaWiki.edit_buttons;
 4610+ for (var i = 0; i < buttons.length; i++) {
 4611+ var button = buttons[i];
 4612+ button.innerHTML = button.edit_button_text;
 4613+ button.parentNode.style.display = 'inline' ;
 4614+ }
 4615+}
 4616+
37024617 proto.getRawPage = function() {
3703 - if (this.config.modeClasses[0].match(/Wysiwyg/)) return;
3704 - if (! this.raw_section_orig)
3705 - this.raw_section_orig = this.get_raw_section();
3706 - this.raw_section = this.raw_section_orig;
 4618+// if (this.config.modeClasses[0].match(/Wysiwyg/)) return true ;
 4619+ if (! this.raw_section_orig) {
 4620+ this.raw_section_orig = this.get_raw_section();
 4621+ }
 4622+ this.raw_section = this.raw_section_orig;
 4623+ if (!this.raw_section) {
 4624+ return false ;
 4625+ }
 4626+ return true ;
37074627 }
37084628
37094629 proto.get_raw_section = function() {
37104630 var url = location.toString().replace(/#.*/, '');
3711 - var page_title = url.replace(/.*index\.php\/(\w+).*/, '$1');
3712 - url = url.replace(/(.*index\.php).*/, '$1');
3713 - url = url +
3714 - "?title=" + page_title +
3715 - "&action=edit" +
3716 - "&section=" + this.section_number;
3717 - var html = Ajax.get(url);
 4631+ /* look out for titles already containing title... */
 4632+ if (url.match ('/title/') != '') {
 4633+ var correctPath = '' ;
 4634+ if (wgArticlePath.match (/\/\$1/) != '') {
 4635+ correctPath = wgArticlePath.replace (/\$1/, '') ;
 4636+ if(wgArticlePath.indexOf('?') > 0) {
 4637+ url = wgServer + correctPath + encodeURI(wgPageName) + "&action=edit" + "&section=" + this.section_number ;
 4638+ } else {
 4639+ url = wgServer + correctPath + encodeURI(wgPageName) + "?action=edit" + "&section=" + this.section_number ;
 4640+ }
 4641+ } else {
 4642+ correctPath = wgArticlePath.replace (/\?title=\$1/, '') ;
 4643+ url = wgServer + correctPath + "?title=" + encodeURI(wgPageName) + "&action=edit" + "&section=" + this.section_number ;
 4644+ }
 4645+ } else {
 4646+ var page_title = url.replace(/.*index\.php\/(\w+).*/, '$1');
 4647+ url = url.replace(/(.*index\.php).*/, '$1');
 4648+ url = url +
 4649+ "?title=" + encodeURI(wgPageName) +
 4650+ "&action=edit" +
 4651+ "&section=" + this.section_number;
 4652+ }
 4653+
 4654+ var html = WKWAjax.get(url);
 4655+
 4656+ /* do not allow blocked users to edit...
 4657+ it won't actually save, but will it look nice?
 4658+ */
 4659+ if (html.match (/<textarea[^>]*?readonly=\"readonly\"[^>]*?>/) ) {
 4660+ return false ;
 4661+ }
 4662+
 4663+ /* fetch things like wpStarttime and wpEdittime _here_
 4664+ */
 4665+
 4666+ var matched_sttime = html.match(
 4667+ /<input[^>]*? name=\"wpStarttime\" \/>/
 4668+ ) ;
 4669+
 4670+ var matched_edtime = html.match(
 4671+ /<input[^>]*? name=\"wpEdittime\" \/>/
 4672+ ) ;
 4673+
 4674+ if (matched_sttime && matched_edtime) {
 4675+ var starttime = matched_sttime[0] ;
 4676+ var edittime = matched_edtime[0] ;
 4677+
 4678+ starttime = starttime.match (
 4679+ /[0-9]+/
 4680+ ) ;
 4681+ edittime = edittime.match (
 4682+ /[0-9]+/
 4683+ ) ;
 4684+ var starttime = starttime[0] ;
 4685+ var edittime = edittime[0] ;
 4686+ Wikiwyg.MediaWiki.starttime = starttime ;
 4687+ Wikiwyg.MediaWiki.edittime = edittime ;
 4688+ }
 4689+
37184690 var raw_text = html.replace(
37194691 /[\s\S]*<textarea[^>]*?>([\s\S]*)<\/textarea>[\s\S]*/,
37204692 '$1'
37214693 );
 4694+
37224695 raw_text = raw_text
37234696 .replace(/\&lt;/g, '<')
37244697 .replace(/\&gt;/g, '>')
3725 - .replace(/\&amp;/g, '&');
 4698+ .replace(/\&amp;/g, '&')
 4699+ .replace(/\&quot;/g,'"') ;
 4700+
37264701 return raw_text;
3727 - // XXX Use code like this when action=raw is fixed in 1.7a
 4702+ // XXX Use code like this when action=raw is fixed in 1.7a
37284703 // var sections = raw_text.match(/\n== [\s\S]*?(?=(\n== |$))/g);
37294704 // if (!sections) return;
37304705 // this.raw_section = sections[this.section_number - 1].
@@ -3731,7 +4706,7 @@
37324707 }
37334708
37344709 proto.disableDoubleClicks = function () {
3735 - var wikiwyg_divs = grepElementsByTag('div',
 4710+ var wikiwyg_divs = grepElementsByTag('span',
37364711 function(e) { return e.id.match(/^wikiwyg_section_\d+$/) }
37374712 );
37384713 this.wikiwyg_divs_ondblclick = new Array();
@@ -3745,23 +4720,34 @@
37464721 Wikiwyg.MediaWiki.editInProgress = false;
37474722 this.displayMode();
37484723 this.toolbarObject.disableMessage();
3749 -
3750 - Wikiwyg.MediaWiki.main_edit_button.setAttribute(
3751 - 'href', Wikiwyg.MediaWiki.main_edit_button.old_href
3752 - );
3753 - Wikiwyg.MediaWiki.main_edit_button.style.color =
3754 - Wikiwyg.MediaWiki.main_edit_button.old_color;
 4724+ if (Wikiwyg.MediaWiki.main_edit_button){
 4725+ Wikiwyg.MediaWiki.main_edit_button.setAttribute(
 4726+ 'href', Wikiwyg.MediaWiki.main_edit_button.old_href
 4727+ );
 4728+ Wikiwyg.MediaWiki.main_edit_button.style.color =
 4729+ Wikiwyg.MediaWiki.main_edit_button.old_color;
 4730+ }
37554731 var buttons = Wikiwyg.MediaWiki.edit_buttons;
37564732 for (var i = 0; i < buttons.length; i++) {
37574733 var button = buttons[i];
37584734 button.innerHTML = button.edit_button_text;
 4735+ button.parentNode.style.display = 'inline' ;
37594736 }
3760 - var wikiwyg_divs = grepElementsByTag('div',
 4737+ var wikiwyg_divs = grepElementsByTag('span',
37614738 function(e) { return e.id.match(/^wikiwyg_section_\d+$/) }
37624739 );
37634740 for ( var i = 0 ; i < wikiwyg_divs.length ; i++ ) {
37644741 wikiwyg_divs[i].ondblclick = this.wikiwyg_divs_ondblclick[i];
37654742 }
 4743+ /* if show diff, disable it */
 4744+ var diff_div = document.getElementById ('wikiwyg_diff_wrapper') ;
 4745+ if (diff_div) {
 4746+ this.toolbarObject.rebuildDiffs () ;
 4747+ }
 4748+ if (this.current_mode.classname.match(/Preview/)) {
 4749+ this.toolbarObject.rebuild () ;
 4750+ }
 4751+ needToConfirm = false ;
37664752 }
37674753
37684754 proto.get_page_title = function() {
@@ -3771,11 +4757,10 @@
37724758 // XXX This all seems so fragile and crufty...
37734759 proto.submit_action_form = function(action, value) {
37744760 var self = this;
3775 - var page_title = this.get_page_title();
 4761+ var page_title = wgPageName ;
37764762 var url = fixupRelativeUrl(
37774763 'index.php?title=' + page_title + '&action=edit&section=' + this.section_number
37784764 );
3779 -
37804765 var tempIFrame=document.createElement('iframe');
37814766 tempIFrame.setAttribute('id','RSIFrame');
37824767 tempIFrame.style.height = "1px";
@@ -3809,46 +4794,87 @@
38104795 ? IFrameObj.contentWindow.document
38114796 : IFrameObj.contentDocument;
38124797 form.wpTextbox1.value = value.wpTextbox1;
 4798+ form.wpSummary.value = value.wpSummary ;
 4799+ if (typeof wgUserName == 'string') {
 4800+ form.wpMinoredit.value = 1 ;
 4801+ form.wpWatchthis.value = 1 ;
 4802+ /* checkboxes, ah */
 4803+ form.wpMinoredit.checked = value.wpMinoredit ;
 4804+ form.wpWatchthis.checked = value.wpWatchthis ;
 4805+ }
 4806+ /* also give variables needed for edit conflicts... */
 4807+ form.wpEdittime.value = Wikiwyg.MediaWiki.edittime ;
 4808+ form.wpStarttime.value = Wikiwyg.MediaWiki.starttime ;
38134809 form.submit();
38144810 wait(function() {
3815 - return (check_doc(IFrameDoc)) ? true : false;
 4811+ // fix this up to *always* write
 4812+ return (check_doc(IFrameDoc)) ? true : false;
38164813 },function() {
38174814 // Without remove tempIFrame here, the page scrolls down
38184815 // to the bottom, where the tempIFrame is located.
3819 - document.body.removeChild(tempIFrame);
 4816+ // document.body.removeChild(tempIFrame);
 4817+ self.cancelEdit () ;
38204818 // XXX CrappyHack for save until we figure out how
38214819 // to submit without iframe.
38224820 setTimeout(function() {
38234821 // With this setTimeout it avoids page for being cached.
38244822 // Without this setTimeout the reloaded page is usually
38254823 // a cached one, weird.
3826 - location.reload();
3827 - }, 1000);
 4824+ document.body.removeChild(tempIFrame) ;
 4825+ form.reset() ;
 4826+ location.reload() ;
 4827+ }, 400);
38284828 });
38294829 }
38304830 wait(condition, callback);
38314831 }
38324832
 4833+proto.imageUpload = function (tagOpen, tagClose, sampleText) {
 4834+ Wikiwyg.prototype.imageUpload.call (this, tagOpen, tagClose, sampleText) ;
 4835+}
 4836+
38334837 proto.saveChanges = function() {
3834 - var page_title = this.get_page_title();
 4838+ var page_title = encodeURI(wgPageName) ;
 4839+ var summary = document.getElementById ('wpSummary_'+ this.section_number).value ;
38354840 var self = this;
3836 - var submit_changes = function(wikitext) {
3837 - self.submit_action_form(
3838 - fixupRelativeUrl('index.php'),
3839 - {
3840 - 'title': page_title,
3841 - 'action': "submit",
3842 - 'wpSection': self.section_number,
3843 - 'wpTextbox1': wikitext,
3844 - 'wpSave': "Save page"
3845 - }
3846 - );
 4841+ if (typeof wgUserName == 'string') {
 4842+ var minoredit = document.getElementById ('wpMinoredit_'+ this.section_number).checked ;
 4843+ var watchthis = document.getElementById ('wpWatchthis_'+ this.section_number).checked ;
 4844+ var submit_changes = function(wikitext) {
 4845+ self.submit_action_form(
 4846+ fixupRelativeUrl('index.php'),
 4847+ {
 4848+ 'title': page_title,
 4849+ 'action': "submit",
 4850+ 'wpSection': self.section_number,
 4851+ 'wpTextbox1': wikitext,
 4852+ 'wpSummary' : summary,
 4853+ 'wpMinoredit' : minoredit,
 4854+ 'wpWatchthis' : watchthis,
 4855+ 'wpSave': "Save page"
 4856+ }
 4857+ );
 4858+ }
 4859+ } else {
 4860+ var submit_changes = function(wikitext) {
 4861+ self.submit_action_form(
 4862+ fixupRelativeUrl('index.php'),
 4863+ {
 4864+ 'title': page_title,
 4865+ 'action': "submit",
 4866+ 'wpSection': self.section_number,
 4867+ 'wpTextbox1': wikitext,
 4868+ 'wpSummary' : summary,
 4869+ 'wpSave': "Save page"
 4870+ }
 4871+ );
 4872+ }
38474873 }
38484874 var self = this;
38494875 if (this.raw_section) {
3850 - submit_changes(this.raw_section);
 4876+// submit_changes(this.raw_section);
38514877 }
3852 - else if (this.current_mode.classname.match(/(Wysiwyg|Preview)/)) {
 4878+ if (this.current_mode.classname.match(/(Wysiwyg|Preview)/)) {
38534879 this.current_mode.toHtml(
38544880 function(html) {
38554881 var wikitext_mode = self.mode_objects['Wikiwyg.Wikitext.MediaWiki'];
@@ -3873,34 +4899,50 @@
38744900
38754901 proto.config = {
38764902 divId: null,
3877 - imagesLocation: 'images/',
3878 - imagesExtension: '.png',
 4903+ imagesLocation: 'images/' ,
 4904+ imagesExtension: '.png' ,
38794905 controlLayout: [
3880 - 'bold', 'italic', 'strike',
3881 - 'link', 'www',
3882 - 'h2', 'p',
3883 - 'hr',
3884 - 'unordered', 'ordered', 'outdent', 'indent',
3885 - 'mode_selector', '|', 'save', '|', 'cancel'
 4906+ 'bold', 'italic', 'strike' ,
 4907+ 'www' , 'link' ,
 4908+ 'h1', 'h2', 'h3',
 4909+ 'p' ,
 4910+ 'hr' ,
 4911+ 'unordered', 'ordered' ,
 4912+ '|l' ,
 4913+ 'insertimage' ,
 4914+ '[' ,
 4915+ 'mode_selector' ,
 4916+ '|r' ,
 4917+ 'save' ,
 4918+ '|r' ,
 4919+ 'cancel' ,
 4920+ ']' ,
 4921+ '|l' ,
 4922+ 'help'
38864923 ],
38874924 controlLabels: {
3888 - save: 'Save',
3889 - cancel: 'Cancel',
3890 - bold: 'Bold (Ctrl+b)',
3891 - italic: 'Italic (Ctrl+i)',
3892 - hr: 'Horizontal Rule',
 4925+ save: wgSaveCaption ,
 4926+ cancel: wgCancelCaption ,
 4927+ insertimage: wgInsertImageCaption ,
 4928+ help: wgHelpCaption ,
 4929+ bold: wgBoldTip +' (Ctrl+b)',
 4930+ italic: wgItalicTip + ' (Ctrl+i)',
 4931+ hr: wgHrTip ,
38934932 ordered: 'Numbered List',
38944933 unordered: 'Bulleted List',
38954934 indent: 'More Indented',
38964935 outdent: 'Less Indented',
38974936 label: '[Style]',
3898 - p: 'Normal Text',
 4937+ p: wgNowikiTip ,
38994938 pre: 'Preformatted',
39004939 h1: 'Heading 1',
39014940 h2: 'Heading 2',
39024941 h3: 'Heading 3',
39034942 h4: 'Heading 4',
3904 - link: 'Create Link',
 4943+ timestamp : wgTimestampTip ,
 4944+ link: wgIntlinkTip ,
 4945+ www: wgExtlinkTip ,
 4946+ template: 'insert Template' ,
39054947 table: 'Create Table'
39064948 }
39074949 };
@@ -3913,6 +4955,7 @@
39144956 'class': 'wikiwyg_button',
39154957 alt: label,
39164958 title: label,
 4959+ id: 'wikiwyg_button_' + type + '_' + this.section_number ,
39174960 src: base + type + ext
39184961 }
39194962 );
@@ -3930,14 +4973,15 @@
39314974 with (this.toolbar_message) {
39324975 innerHTML = "Loading";
39334976 style.textDecoration = "blink";
3934 - style.color = "red";
 4977+ style.color = "green";
39354978 style.background = "#fff";
3936 - style.width = getStyle(this.div, "width");
3937 - style.height = getStyle(this.div, "height");
3938 - style.marginTop = getStyle(this.div, "margin-top")
3939 - style.marginBottom = getStyle(this.div, "margin-bottom")
3940 - style.lineHight = getStyle(this.div, "line-height")
3941 - style.fontSize = getStyle(this.div, "font-size")
 4979+ style.fontWeight = "bold" ;
 4980+ style.width = WKWgetStyle(this.div, "width");
 4981+ style.height = WKWgetStyle(this.div, "height");
 4982+ style.marginTop = WKWgetStyle(this.div, "margin-top")
 4983+ style.marginBottom = WKWgetStyle(this.div, "margin-bottom")
 4984+ style.lineHight = WKWgetStyle(this.div, "line-height")
 4985+ style.fontSize = WKWgetStyle(this.div, "font-size")
39424986 }
39434987 }
39444988 this.toolbar_message.style.display = "block";
@@ -3961,7 +5005,7 @@
39625006 return buttons;
39635007 }
39645008
3965 -proto.disableButtons = function() {
 5009+proto.disableButtons = function (section_number) {
39665010 var buttons = this.getButtons();
39675011 this.button_handlers = new Array();
39685012 for ( var i = 0 ; i < buttons.length ; i++ ) {
@@ -4001,16 +5045,64 @@
40025046 this.wikiwyg.toolbarObject.disableMessage();
40035047 }
40045048
 5049+// a first strike tactic on templates and other stuff
 5050+// fetch the wikitext and then convert to html
 5051+// don't operate on plain html in any case
 5052+proto.initHtml = function(html) {
 5053+ var dom = document.createElement('div');
 5054+ dom.innerHTML = html;
 5055+ var myInstance = Wikiwyg.MediaWiki.instance ;
 5056+ var wikitext_mode = myInstance.mode_objects['Wikiwyg.Wikitext.MediaWiki'] ;
 5057+ wikitext_mode.fixChangedStructure (dom) ;
 5058+ var fixed_content = myInstance.raw_section ;
 5059+ // do things with stuff here
 5060+ fixed_content = this.disableTemplates (fixed_content) ;
 5061+ var self = this ;
 5062+ wikitext_mode.convertWikitextToHtml (
 5063+ fixed_content,
 5064+ function (html) {
 5065+ self.set_inner_html (self.sanitize_html (html) ) ;
 5066+ }
 5067+ ) ;
 5068+}
 5069+
 5070+// for future use
 5071+proto.disableTemplates = function (wikitext) {
 5072+ wikitext = wikitext.replace (/\{\{.+\}\}/gi, '') ;
 5073+ return wikitext ;
 5074+}
 5075+
 5076+proto.fromHtml = function(html) {
 5077+ var dom = document.createElement('div');
 5078+ dom.innerHTML = html;
 5079+ var myInstance = Wikiwyg.MediaWiki.instance ;
 5080+ var wikitext_mode = myInstance.mode_objects['Wikiwyg.Wikitext.MediaWiki'] ;
 5081+ wikitext_mode.fixChangedStructure (dom) ;
 5082+ html = dom.innerHTML ;
 5083+ this.set_inner_html(this.sanitize_html(html));
 5084+}
 5085+
 5086+
40055087 //------------------------------------------------------------------------------
40065088 proto = new Subclass('Wikiwyg.Wikitext.MediaWiki', 'Wikiwyg.Wikitext');
40075089
 5090+proto.initHtml = function (html) {
 5091+ this.fromHtml (html) ;
 5092+}
 5093+
40085094 proto.fromHtml = function(html) {
4009 - if (this.wikiwyg.raw_section) {
4010 - this.setTextArea(this.wikiwyg.raw_section);
4011 - delete this.wikiwyg.raw_section;
4012 - return;
4013 - }
4014 - Wikiwyg.Wikitext.prototype.fromHtml.call(this, html);
 5095+// this.wikiwyg.previous_mode.classname ;
 5096+ if (!this.wikiwyg.previous_mode) {
 5097+ this.setTextArea(this.wikiwyg.raw_section);
 5098+ delete this.wikiwyg.raw_section;
 5099+ return;
 5100+ }
 5101+ if (this.wikiwyg.raw_section && (!this.wikiwyg.previous_mode.classname.match(/Wysiwyg/))) {
 5102+ this.setTextArea(this.wikiwyg.raw_section);
 5103+ delete this.wikiwyg.raw_section;
 5104+ return;
 5105+ }
 5106+ Wikiwyg.Wikitext.prototype.fromHtml.call(this, html);
40155107 }
40165108
40175109 proto.toHtml = function(func) {
@@ -4021,8 +5113,8 @@
40225114 }
40235115
40245116 proto.convertWikitextToHtml = function(wikitext, func) {
4025 - Ajax.post(
4026 - fixupRelativeUrl('index.php/Special:EZParser'),
 5117+ WKWAjax.post(
 5118+ fixupRelativeUrl('index.php/' + wgSpecialPrefix + ':EZParser') + "&rtitle=" + wgPageName,
40275119 "text=" + encodeURIComponent(wikitext),
40285120 func
40295121 );
@@ -4069,6 +5161,7 @@
40705162 unordered: ['start_lines', '*'],
40715163 indent: ['start_lines', ''],
40725164 hr: ['line_alone', '----'],
 5165+ timestamp: ['line_alone', '~~~~'] ,
40735166 table: ['line_alone', '| A | B | C |\n| | | |\n| | | |']
40745167 }
40755168 }
@@ -4081,20 +5174,9 @@
40825175 proto.enableFinished = function (){
40835176 this.wikiwyg.toolbarObject.enableThis();
40845177 this.wikiwyg.toolbarObject.disableMessage();
 5178+ this.textarea.style.height = '250px';
40855179 }
40865180
4087 -proto.format_span = function(element) {
4088 - var class_name = element.className;
4089 - if (!(class_name && class_name == 'wikiwyg-nowiki')) {
4090 - this.pass(element);
4091 - return;
4092 - }
4093 - this.appendOutput('<nowiki>');
4094 - this.no_collapse_text = true;
4095 - this.walk(element);
4096 - this.appendOutput('</nowiki>');
4097 -}
4098 -
40995181 proto.normalizeDomWhitespace = function(dom) {
41005182 Wikiwyg.Wikitext.prototype.normalizeDomWhitespace.call(this, dom);
41015183 var tags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'li'];
@@ -4175,8 +5257,8 @@
41765258 function(html) {
41775259 // Strip wrapper tags from ezparser.
41785260 html = html
4179 - .replace(/<\/div><iframe.*/i,"")
4180 - .replace(/^.*<div.*?class="wikiwyg_section".*?>/i,"");
 5261+ .replace(/<\/span><iframe.*/i,"")
 5262+ .replace(/^.*<span.*?class="wikiwyg_section".*?>/i,"");
41815263 Wikiwyg.Preview.prototype.fromHtml.call(self, html);
41825264 }
41835265 )
Index: trunk/extensions/wikiwyg/share/MediaWiki/images/pre.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: trunk/extensions/wikiwyg/share/MediaWiki/images/pre.gif
___________________________________________________________________
Added: svn:mime-type
41845266 + application/octet-stream
Index: trunk/extensions/wikiwyg/share/MediaWiki/images/table.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: trunk/extensions/wikiwyg/share/MediaWiki/images/table.gif
___________________________________________________________________
Added: svn:mime-type
41855267 + application/octet-stream
Index: trunk/extensions/wikiwyg/share/MediaWiki/images/youtube.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: trunk/extensions/wikiwyg/share/MediaWiki/images/youtube.gif
___________________________________________________________________
Added: svn:mime-type
41865268 + application/octet-stream
Index: trunk/extensions/wikiwyg/share/MediaWiki/images/link.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: trunk/extensions/wikiwyg/share/MediaWiki/images/unlink.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: trunk/extensions/wikiwyg/share/MediaWiki/images/separator.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: trunk/extensions/wikiwyg/share/MediaWiki/images/wikify.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: trunk/extensions/wikiwyg/share/MediaWiki/images/wikify.gif
___________________________________________________________________
Added: svn:mime-type
41875269 + application/octet-stream
Index: trunk/extensions/wikiwyg/share/MediaWiki/images/timestamp.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: trunk/extensions/wikiwyg/share/MediaWiki/images/timestamp.gif
___________________________________________________________________
Added: svn:mime-type
41885270 + application/octet-stream
Index: trunk/extensions/wikiwyg/share/MediaWiki/images/h1.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: trunk/extensions/wikiwyg/share/MediaWiki/images/h1.gif
___________________________________________________________________
Added: svn:mime-type
41895271 + application/octet-stream
Index: trunk/extensions/wikiwyg/share/MediaWiki/images/h2.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: trunk/extensions/wikiwyg/share/MediaWiki/images/h3.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: trunk/extensions/wikiwyg/share/MediaWiki/images/h3.gif
___________________________________________________________________
Added: svn:mime-type
41905272 + application/octet-stream
Index: trunk/extensions/wikiwyg/share/MediaWiki/images/h4.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: trunk/extensions/wikiwyg/share/MediaWiki/images/h4.gif
___________________________________________________________________
Added: svn:mime-type
41915273 + application/octet-stream
Index: trunk/extensions/wikiwyg/share/MediaWiki/images/h5.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: trunk/extensions/wikiwyg/share/MediaWiki/images/h5.gif
___________________________________________________________________
Added: svn:mime-type
41925274 + application/octet-stream
Index: trunk/extensions/wikiwyg/share/MediaWiki/images/h6.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: trunk/extensions/wikiwyg/share/MediaWiki/images/h6.gif
___________________________________________________________________
Added: svn:mime-type
41935275 + application/octet-stream
Index: trunk/extensions/wikiwyg/share/MediaWiki/images/www.gif
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: trunk/extensions/wikiwyg/share/MediaWiki/lib/Wikiwyg/MediaWiki.js
@@ -285,7 +285,7 @@
286286 "?title=" + page_title +
287287 "&action=edit" +
288288 "&section=" + this.section_number;
289 - var html = Ajax.get(url);
 289+ var html = WKWAjax.get(url);
290290 var raw_text = html.replace(
291291 /[\s\S]*<textarea[^>]*?>([\s\S]*)<\/textarea>[\s\S]*/,
292292 '$1'
@@ -504,12 +504,12 @@
505505 style.textDecoration = "blink";
506506 style.color = "red";
507507 style.background = "#fff";
508 - style.width = getStyle(this.div, "width");
509 - style.height = getStyle(this.div, "height");
510 - style.marginTop = getStyle(this.div, "margin-top")
511 - style.marginBottom = getStyle(this.div, "margin-bottom")
512 - style.lineHight = getStyle(this.div, "line-height")
513 - style.fontSize = getStyle(this.div, "font-size")
 508+ style.width = WKWgetStyle(this.div, "width");
 509+ style.height = WKWgetStyle(this.div, "height");
 510+ style.marginTop = WKWgetStyle(this.div, "margin-top")
 511+ style.marginBottom = WKWgetStyle(this.div, "margin-bottom")
 512+ style.lineHight = WKWgetStyle(this.div, "line-height")
 513+ style.fontSize = WKWgetStyle(this.div, "font-size")
514514 }
515515 }
516516 this.toolbar_message.style.display = "block";
@@ -593,7 +593,7 @@
594594 }
595595
596596 proto.convertWikitextToHtml = function(wikitext, func) {
597 - Ajax.post(
 597+ WKWAjax.post(
598598 fixupRelativeUrl('index.php/Special:EZParser'),
599599 "text=" + encodeURIComponent(wikitext),
600600 func
Index: trunk/extensions/wikiwyg/share/MediaWiki/css/MediaWikiwyg.css
@@ -1,18 +1,18 @@
22 .wikiwyg_toolbar {
3 - background: #fff;
4 - border: none;
 3+ background: #F0F0EE none repeat scroll 0% ;
 4+ border: 1px solid #DCDCDC ;
55 letter-spacing: 0;
6 - padding:0;
7 - margin: 5px 0;
 6+ padding: 2px ;
87 }
98
109 span.wikiwyg_control_link a {
11 - padding-right: 8px;
 10+ padding-right: 4px ;
 11+ padding-left: 4px ;
1212 }
1313
1414 .wikiwyg_button {
15 - background: #fff;
16 - border: 1px solid #fff;
 15+ background: #F0F0EE;
 16+ border: 1px solid #F0F0EE;
1717 cursor: pointer;
1818 width: 20px;
1919 height: 20px;
@@ -28,8 +28,8 @@
2929 }
3030
3131 .wikiwyg_button_disabled {
32 - background: #fff;
33 - border: 1px solid #fff;
 32+ background: #F0F0EE;
 33+ border: 1px solid #F0F0EE;
3434 width: 20px;
3535 height: 20px;
3636 vertical-align: bottom;
@@ -37,17 +37,22 @@
3838 }
3939
4040 .wikiwyg_button_disabled:hover {
41 - border: 1px solid #fff;
 41+ border: 1px solid #F0F0EE;
4242 }
4343
4444 .wikiwyg_separator {
45 - background: #fff;
46 - border: 1px solid #fff;
 45+ background: #F0F0EE;
 46+ border: 1px solid #F0F0EE;
4747 width: 9px;
4848 height: 20px;
4949 vertical-align: bottom;
5050 }
5151
 52+.lower_tab .wikiwyg_separator {
 53+ background: #fff;
 54+ border: 1px solid #fff;
 55+}
 56+
5257 .wikiwyg_selector {
5358 width: 70px;
5459 }
@@ -63,3 +68,52 @@
6469 padding: .2em;
6570 vertical-align: top;
6671 }
 72+
 73+#wikiwyg_lower_wrapper label, #category_wrapper label {
 74+ display:block;
 75+ float:left;
 76+ width:200px;
 77+}
 78+
 79+#wikiwyg_lower_wrapper .no-float, #category_wrapper .no_float {
 80+ float: none ;
 81+ display: inline ;
 82+}
 83+
 84+#wikiwyg_lower_wrapper .editpage-tier, #category_wrapper .editpage_tier {
 85+ clear:both;
 86+ overflow:auto;
 87+}
 88+
 89+#wikiwyg_lower_wrapper table, #category_wrapper table {
 90+ width: 100% ;
 91+}
 92+
 93+#wikiwyg_lower_wrapper .editpage_header, #category_wrapper .editpage_header {
 94+ vertical-align: top ;
 95+ font-weight: bold ;
 96+ width: 14% ;
 97+}
 98+
 99+#wikiwyg_lower_wrapper textarea, #category_wrapper textarea {
 100+ width: 100% ;
 101+}
 102+
 103+#wikiwyg_lower_wrapper li, #category_wrapper li {
 104+ margin-left: 30px ;
 105+ vertical-align: middle ;
 106+ float: left ;
 107+}
 108+
 109+#wikiwyg_lower_wrapper .last, #category_wrapper .last {
 110+ clear: both ;
 111+ float: none ;
 112+ list-style-image: none ;
 113+ list-style-position: outside ;
 114+ list-style-type: none ;
 115+}
 116+
 117+#wikiwyg_lower_wrapper .editpage-inside, #category_wrapper .editpage_inside {
 118+ float:left;
 119+}
 120+
Index: trunk/extensions/wikiwyg/share/MediaWiki/mediawiki-1.10.1bleed.patch
@@ -0,0 +1,279 @@
 2+Index: skins/common/wikibits.js
 3+===================================================================
 4+--- skins/common/wikibits.js (wersja 24284)
 5+@@ -229,6 +229,17 @@
 6+ return false;
 7+ }
 8+
 9++function getLabelFor (obj_id) {
 10++ var labels = document.getElementsByTagName ('label') ;
 11++ if (labels && (labels.length > 0)) {
 12++ for (var i=0 ; i < labels.length; i++) {
 13++ if (labels[i].htmlFor == obj_id)
 14++ return labels[i] ;
 15++ }
 16++ }
 17++ return false ;
 18++}
 19++
 20+ // Timezone stuff
 21+ // tz in format [+-]HHMM
 22+ function checkTimezone(tz, msg) {
 23+@@ -371,6 +382,11 @@
 24+ var textbox = document.getElementById('wpTextbox1');
 25+ if (!textbox) { return false; }
 26+
 27++ /* Bartek - FF bug fix */
 28++ if (textbox.style.display == 'none') {
 29++ return false ;
 30++ }
 31++
 32+ // Don't generate buttons for browsers which don't fully
 33+ // support it.
 34+ if (!document.selection && textbox.selectionStart === null) {
 35+Index: skins/MonoBook.php
 36+===================================================================
 37+--- skins/MonoBook.php (wersja 24284)
 38+@@ -70,6 +70,15 @@
 39+ <meta http-equiv="imagetoolbar" content="no" /><![endif]-->
 40+
 41+ <?php print Skin::makeGlobalVariablesScript( $this->data ); ?>
 42++
 43++ <!-- YUI -->
 44++ <script type="text/javascript" src="http://images.wikia.com/common/yui/utilities/utilities.js"></script>
 45++ <script type="text/javascript" src="http://images.wikia.com/common/yui/container/container-min.js"></script>
 46++ <script type="text/javascript" src="http://images.wikia.com/common/yui/autocomplete/autocomplete-min.js"></script>
 47++ <script type="text/javascript" src="http://images.wikia.com/common/yui/logger/logger-min.js"></script>
 48++ <script type="text/javascript" src="http://images.wikia.com/common/yui/3rdpart/yui-cookie.js"></script>
 49++ <script type="text/javascript" src="http://images.wikia.com/common/yui/3rdpart/tools-min.js"></script>
 50++ <script type="text/javascript" src="<?php $this->text('stylepath') ?>/common/tracker.js?<?= $GLOBALS['wgStyleVersion'] ?>"></script>
 51+
 52+ <script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('stylepath' ) ?>/common/wikibits.js?<?php echo $GLOBALS['wgStyleVersion'] ?>"><!-- wikibits js --></script>
 53+ <?php if($this->data['jsvarurl' ]) { ?>
 54+@@ -90,6 +99,10 @@
 55+ if($this->data['trackbackhtml']) print $this->data['trackbackhtml']; ?>
 56+ <!-- Head Scripts -->
 57+ <?php $this->html('headscripts') ?>
 58++
 59++ <link rel="stylesheet" type="text/css" href="http://images.wikia.com/common/yui/container/assets/container.css" />
 60++ <link rel="stylesheet" type="text/css" href="http://images.wikia.com/common/yui/logger/assets/logger.css" />
 61++
 62+ </head>
 63+ <body <?php if($this->data['body_ondblclick']) { ?>ondblclick="<?php $this->text('body_ondblclick') ?>"<?php } ?>
 64+ <?php if($this->data['body_onload' ]) { ?>onload="<?php $this->text('body_onload') ?>"<?php } ?>
 65+@@ -108,6 +121,31 @@
 66+ <?php if($this->data['showjumplinks']) { ?><div id="jump-to-nav"><?php $this->msg('jumpto') ?> <a href="#column-one"><?php $this->msg('jumptonavigation') ?></a>, <a href="#searchInput"><?php $this->msg('jumptosearch') ?></a></div><?php } ?>
 67+ <!-- start content -->
 68+ <?php $this->html('bodytext') ?>
 69++ <?php
 70++ global $wgRightsText, $wgInPageEnabled, $wgOut ;
 71++ //make people happy and load only when wikiwyg is enabled - Bartek
 72++ if ( isset($wgInPageEnabled)) {
 73++ //if (wfGetDependingOnSkin () == 1) {
 74++ echo "<div id=\"editpage-copywarn\" style=\"display: none\">\n" ;
 75++ $copywarn =
 76++ wfMsg( $wgRightsText ? 'copyrightwarning' : 'copyrightwarning2',
 77++ '[[' . wfMsgForContent( 'copyrightpage' ) . ']]',
 78++ $wgRightsText );
 79++
 80++ global $wgTitle;
 81++ global $wgParser;
 82++
 83++ $popts = $wgOut->parserOptions();
 84++ $popts->setTidy(false);
 85++
 86++ $parserOutput = $wgParser->parse( $copywarn, $wgTitle, $popts,
 87++ $true, true, $wgOut->mRevisionId );
 88++ echo $parserOutput->getText () ;
 89++ echo "\n</div>" ;
 90++ //}
 91++ }
 92++ ?>
 93++
 94+ <?php if($this->data['catlinks']) { ?><div id="catlinks"><?php $this->html('catlinks') ?></div><?php } ?>
 95+ <!-- end content -->
 96+ <div class="visualClear"></div>
 97+Index: includes/Parser.php
 98+===================================================================
 99+--- includes/Parser.php (wersja 24284)
 100+@@ -532,7 +532,7 @@
 101+ * @private
 102+ */
 103+ function strip( $text, $state, $stripcomments = false , $dontstrip = array () ) {
 104+- global $wgContLang;
 105++ global $wgContLang, $wgWikiwygEnabled;
 106+ wfProfileIn( __METHOD__ );
 107+ $render = ($this->mOutputType == OT_HTML);
 108+
 109+@@ -584,7 +584,11 @@
 110+ }
 111+ // Shouldn't happen otherwise. :)
 112+ case 'nowiki':
 113+- $output = Xml::escapeTagsOnly( $content );
 114++ if ($wgWikiwygEnabled == true) {
 115++ $output = "<span class=\"wikiwyg-nowiki\">".Xml::escapeTagsOnly( $content )."</span>";
 116++ } else {
 117++ $output = Xml::escapeTagsOnly( $content );
 118++ }
 119+ break;
 120+ case 'math':
 121+ $output = $wgContLang->armourMath( MathRenderer::renderMath( $content ) );
 122+@@ -2894,7 +2898,7 @@
 123+ * @private
 124+ */
 125+ function braceSubstitution( $piece ) {
 126+- global $wgContLang, $wgLang, $wgAllowDisplayTitle, $wgNonincludableNamespaces;
 127++ global $wgContLang, $wgLang, $wgAllowDisplayTitle, $wgNonincludableNamespaces, $wgWikiwygEnabled;
 128+ $fname = __METHOD__ /*. '-L' . count( $this->mArgStack )*/;
 129+ wfProfileIn( $fname );
 130+ wfProfileIn( __METHOD__.'-setup' );
 131+Index: includes/EditPage.php
 132+===================================================================
 133+--- includes/EditPage.php (wersja 24284)
 134+@@ -1175,6 +1175,8 @@
 135+ <input type='hidden' value=\"{$this->starttime}\" name=\"wpStarttime\" />\n
 136+ <input type='hidden' value=\"{$this->edittime}\" name=\"wpEdittime\" />\n
 137+ <input type='hidden' value=\"{$this->scrolltop}\" name=\"wpScrolltop\" id=\"wpScrolltop\" />\n" );
 138++
 139++ wfRunHooks ('EditForm:BeforeDisplayingTextbox', array (&$this, &$hidden) ) ;
 140+
 141+ $wgOut->addHTML( <<<END
 142+ $recreate
 143+@@ -1188,6 +1190,8 @@
 144+ </textarea>
 145+ " );
 146+
 147++ wfRunHooks ( 'EditForm::AfterEdit:Form', array (&$this) ) ;
 148++
 149+ $wgOut->addWikiText( $copywarn );
 150+ $wgOut->addHTML( $this->editFormTextAfterWarn );
 151+ $wgOut->addHTML( "
 152+Index: includes/SpecialPreferences.php
 153+===================================================================
 154+--- includes/SpecialPreferences.php (wersja 24284)
 155+@@ -32,7 +32,7 @@
 156+ * Load some values
 157+ */
 158+ function PreferencesForm( &$request ) {
 159+- global $wgContLang, $wgUser, $wgAllowRealName;
 160++ global $wgContLang, $wgUser, $wgAllowRealName, $wgInPageEnabled, $wgWysiwygEnabled ;
 161+
 162+ $this->mQuickbar = $request->getVal( 'wpQuickbar' );
 163+ $this->mOldpass = $request->getVal( 'wpOldpass' );
 164+@@ -66,6 +66,10 @@
 165+ $this->mWatchlistDays = $request->getVal( 'wpWatchlistDays' );
 166+ $this->mWatchlistEdits = $request->getVal( 'wpWatchlistEdits' );
 167+
 168++ if (isset ($wgInPageEnabled) && $wgInPageEnabled && $wgWysiwygEnabled && isset($wgWysiwygEnabled)) {
 169++ $this->mVisualEditor = $request->getVal ('wpVisualEditor') ;
 170++ }
 171++
 172+ $this->mSaveprefs = $request->getCheck( 'wpSaveprefs' ) &&
 173+ $this->mPosted &&
 174+ $wgUser->matchEditToken( $request->getVal( 'wpEditToken' ) );
 175+@@ -206,7 +210,7 @@
 176+ global $wgUser, $wgOut, $wgParser;
 177+ global $wgEnableUserEmail, $wgEnableEmail;
 178+ global $wgEmailAuthentication;
 179+- global $wgAuth;
 180++ global $wgAuth, $wgWysiwygEnabled;
 181+
 182+
 183+ if ( '' != $this->mNewpass && $wgAuth->allowPasswordChange() ) {
 184+@@ -273,6 +277,11 @@
 185+ $wgUser->setOption( 'underline', $this->validateInt($this->mUnderline, 0, 2) );
 186+ $wgUser->setOption( 'watchlistdays', $this->validateFloat( $this->mWatchlistDays, 0, 7 ) );
 187+
 188++ /* wikiwyg mode */
 189++ if (isset($wgWysiwygEnabled) && $wgWysiwygEnabled) {
 190++ $wgUser->setOption( 'visualeditormode', $this->mVisualEditor );
 191++ }
 192++
 193+ # Set search namespace options
 194+ foreach( $this->mSearchNs as $i => $value ) {
 195+ $wgUser->setOption( "searchNs{$i}", $value );
 196+@@ -437,6 +446,26 @@
 197+ return $out;
 198+ }
 199+
 200++ function getEditingTab () {
 201++ /* moved here to better customize later */
 202++ $default_array = array (
 203++ 'editsection',
 204++ 'editsectiononrightclick',
 205++ 'editondblclick',
 206++ 'editwidth',
 207++ 'showtoolbar',
 208++ 'previewonfirst',
 209++ 'previewontop',
 210++ 'minordefault',
 211++ 'externaleditor',
 212++ 'externaldiff',
 213++ $wgLivePreview ? 'uselivepreview' : false,
 214++ 'forceeditsummary',
 215++ ) ;
 216++ wfRunHooks ('getEditingPreferencesTab', array (&$this, &$default_array) ) ;
 217++ return $default_array ;
 218++ }
 219++
 220+ function addRow($td1, $td2) {
 221+ return "<tr><td align='right'>$td1</td><td align='left'>$td2</td></tr>";
 222+ }
 223+@@ -452,6 +481,7 @@
 224+ global $wgRCShowWatchingUsers, $wgEnotifRevealEditorAddress;
 225+ global $wgEnableEmail, $wgEnableUserEmail, $wgEmailAuthentication;
 226+ global $wgContLanguageCode, $wgDefaultSkin, $wgSkipSkins, $wgAuth;
 227++ global $wgWysiwygEnabled ;
 228+
 229+ $wgOut->setPageTitle( wfMsg( 'preferences' ) );
 230+ $wgOut->setArticleRelated( false );
 231+@@ -846,22 +876,20 @@
 232+ ' ' .
 233+ wfInputLabel( wfMsg( 'columns' ), 'wpCols', 'wpCols', 3, $this->mCols ) .
 234+ "</div>" .
 235+- $this->getToggles( array(
 236+- 'editsection',
 237+- 'editsectiononrightclick',
 238+- 'editondblclick',
 239+- 'editwidth',
 240+- 'showtoolbar',
 241+- 'previewonfirst',
 242+- 'previewontop',
 243+- 'minordefault',
 244+- 'externaleditor',
 245+- 'externaldiff',
 246+- $wgLivePreview ? 'uselivepreview' : false,
 247+- 'forceeditsummary',
 248+- ) ) . '</fieldset>'
 249+- );
 250++ $this->getToggles( $this->getEditingTab ()) . '</fieldset>'
 251++ ) ;
 252+
 253++ /* wikiwyg stuff */
 254++ global $wgInPageEnabled ;
 255++ /* I guess no sense showing it without wysiwyg mode, eh? */
 256++ if (isset ($wgInPageEnabled) && $wgInPageEnabled && isset ($wgWysiwygEnabled) && $wgWysiwygEnabled) {
 257++ $ws_checked = '' ;
 258++ $wk_checked = '' ;
 259++ ( $this->mVisualEditor == 'wysiwyg') ? $ws_checked = "checked=\"checked\"" : $wk_checked = "checked=\"checked\"" ;
 260++ $wgOut->addHTML ("<div style=\"font-color: gray; margin-left: 10px;\"><input type='radio' name='wpVisualEditor' id=\"wpVisualEditorWysiwyg\" value=\"wysiwyg\" $ws_checked disabled=\"disabled\" /> <label for=\"wpVisualEditorWysiwyg\">".wfMsg ('wysiwygdef')."</label></div>") ;
 261++ $wgOut->addHTML ("<div style=\"font-color: gray; margin-left: 10px;\"><input type='radio' name='wpVisualEditor' id=\"wpVisualEditorWikitext\" value=\"wikitext\" $wk_checked disabled=\"disabled\" /> <label for=\"wpVisualEditorWikitext\">".wfMsg ('wikitextdef')."</label></div>") ;
 262++ }
 263++
 264+ # Recent changes
 265+ $wgOut->addHtml( '<fieldset><legend>' . wfMsgHtml( 'prefs-rc' ) . '</legend>' );
 266+
 267+@@ -953,6 +981,8 @@
 268+ }
 269+ $wgOut->addHTML( '</fieldset>' );
 270+
 271++ wfRunHooks ('handleWikiPrefs') ;
 272++
 273+ $token = $wgUser->editToken();
 274+ $skin = $wgUser->getSkin();
 275+ $wgOut->addHTML( "

Status & tagging log