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 |
1 | 1 | + 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 |
2 | 2 | + 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 |
3 | 3 | + 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 @@ |
119 | 119 | this.div.style.display = 'none'; |
120 | 120 | } |
121 | 121 | |
| 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 | + |
122 | 142 | proto.make_button = function(type, label) { |
123 | 143 | var base = this.config.imagesLocation; |
124 | 144 | var ext = this.config.imagesExtension; |
— | — | @@ -179,7 +199,7 @@ |
180 | 200 | ); |
181 | 201 | |
182 | 202 | var link = Wikiwyg.createElementWithAttrs( |
183 | | - 'a', { href: '#' } |
| 203 | + 'a', { href: '#', id: 'wikiwyg_ctrl_lnk_' + text } |
184 | 204 | ); |
185 | 205 | link.appendChild(document.createTextNode(text)); |
186 | 206 | span.appendChild(link); |
Index: trunk/extensions/wikiwyg/lib/Wikiwyg/Wysiwyg.js |
— | — | @@ -81,6 +81,28 @@ |
82 | 82 | this.apply_stylesheets(); |
83 | 83 | this.enable_keybindings(); |
84 | 84 | 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 | + } |
85 | 107 | } |
86 | 108 | |
87 | 109 | proto.clear_inner_html = function() { |
— | — | @@ -156,8 +178,7 @@ |
157 | 179 | type: 'text/css' |
158 | 180 | }, head); |
159 | 181 | */ |
160 | | - |
161 | | - style_string += Ajax.get(style.cssRules[i].href); |
| 182 | + style_string += WKWAjax.get(style.cssRules[i].href); |
162 | 183 | } else { |
163 | 184 | style_string += style.cssRules[i].cssText + "\n"; |
164 | 185 | } |
— | — | @@ -201,7 +222,7 @@ |
202 | 223 | proto.apply_linked_stylesheet = function(style, head) { |
203 | 224 | var link = Wikiwyg.createElementWithAttrs( |
204 | 225 | 'link', { |
205 | | - href: style.href, |
| 226 | + href: style.href, |
206 | 227 | type: style.type, |
207 | 228 | media: 'screen', |
208 | 229 | rel: 'STYLESHEET' |
— | — | @@ -225,8 +246,65 @@ |
226 | 247 | this.exec_command('formatblock', '<' + command + '>'); |
227 | 248 | } |
228 | 249 | |
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 | + |
231 | 309 | proto.do_underline = proto.exec_command; |
232 | 310 | proto.do_strike = function() { |
233 | 311 | this.exec_command('strikethrough'); |
— | — | @@ -275,13 +353,19 @@ |
276 | 354 | var selection = this.get_link_selection_text(); |
277 | 355 | if (! selection) return; |
278 | 356 | 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+)(.*)/); |
280 | 364 | if (match) { |
281 | 365 | if (match[1] || match[3]) return null; |
282 | 366 | url = match[2]; |
283 | 367 | } |
284 | 368 | else { |
285 | | - url = '?' + escape(selection); |
| 369 | + url = '?' + escape(url); |
286 | 370 | } |
287 | 371 | this.exec_command('createlink', url); |
288 | 372 | } |
— | — | @@ -342,6 +426,40 @@ |
343 | 427 | range.select(); |
344 | 428 | } |
345 | 429 | |
| 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 | + |
346 | 464 | // Use IE's design mode default key bindings for now. |
347 | 465 | proto.enable_keybindings = function() {} |
348 | 466 | |
Index: trunk/extensions/wikiwyg/lib/Wikiwyg/Wikitext.js |
— | — | @@ -646,9 +646,9 @@ |
647 | 647 | |
648 | 648 | proto.normalize_span_whitespace = function(dom,tag ) { |
649 | 649 | var grep = function(element) { |
650 | | - return Boolean(element.getAttribute('style')); |
| 650 | + return Boolean(element.getAttribute('style')); |
651 | 651 | } |
652 | | - |
| 652 | + |
653 | 653 | var elements = this.array_elements_by_tag_name(dom, tag, grep); |
654 | 654 | for (var i = 0; i < elements.length; i++) { |
655 | 655 | var element = elements[i]; |
— | — | @@ -676,13 +676,22 @@ |
677 | 677 | for (var i = 0; i < elements.length; i++) { |
678 | 678 | var element = elements[i]; |
679 | 679 | var style = element.getAttribute('style'); |
680 | | - if (!style) continue; |
| 680 | + if (!style || this.style_is_bogus(style)) continue; |
681 | 681 | element.removeAttribute('style'); |
682 | 682 | element.innerHTML = |
683 | 683 | '<span style="' + style + '">' + element.innerHTML + '</span>'; |
684 | 684 | } |
685 | 685 | } |
686 | 686 | |
| 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 | + |
687 | 696 | proto.normalize_styled_lists = function(dom, tag) { |
688 | 697 | var elements = this.array_elements_by_tag_name(dom, tag); |
689 | 698 | for (var i = 0; i < elements.length; i++) { |
— | — | @@ -742,6 +751,16 @@ |
743 | 752 | var last_node = this.getLastTextNode(element); |
744 | 753 | var next_node = this.getNextTextNode(element); |
745 | 754 | |
| 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 . |
| 759 | + |
| 760 | + if(Wikiwyg.is_gecko && element.tagName == 'SPAN') { |
| 761 | + var tmp = element.innerHTML; |
| 762 | + element.innerHTML = tmp.replace(/<br>$/i, ''); |
| 763 | + } |
| 764 | + |
746 | 765 | if (this.destroyPhraseMarkup(element)) return; |
747 | 766 | |
748 | 767 | if (first_node && first_node.nodeValue.match(/^ /)) { |
— | — | @@ -789,12 +808,12 @@ |
790 | 809 | if (! last_node) return true; |
791 | 810 | if (last_node.nodeValue.match(/ $/)) return false; |
792 | 811 | 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); |
794 | 813 | } |
795 | 814 | |
796 | 815 | 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); |
799 | 818 | element.parentNode.replaceChild(span, element); |
800 | 819 | return true; |
801 | 820 | } |
— | — | @@ -852,18 +871,23 @@ |
853 | 872 | proto.walk = function(element) { |
854 | 873 | if (!element) return; |
855 | 874 | 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) { |
857 | 880 | this.dispatch_formatter(part); |
858 | 881 | } |
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]*$/) |
862 | 886 | ) { |
863 | 887 | if (this.no_collapse_text) { |
864 | | - this.appendOutput(part.nodeValue); |
| 888 | + this.appendOutput(nodeValue); |
865 | 889 | } |
866 | 890 | else { |
867 | | - this.appendOutput(this.collapse(part.nodeValue)); |
| 891 | + this.appendOutput(this.collapse(nodeValue)); |
868 | 892 | } |
869 | 893 | } |
870 | 894 | } |
— | — | @@ -1023,6 +1047,15 @@ |
1024 | 1048 | } |
1025 | 1049 | |
1026 | 1050 | 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 | + } |
1027 | 1060 | if (this.is_opaque(element)) { |
1028 | 1061 | this.handle_opaque_phrase(element); |
1029 | 1062 | return; |
— | — | @@ -1034,8 +1067,8 @@ |
1035 | 1068 | return; |
1036 | 1069 | } |
1037 | 1070 | |
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; |
1040 | 1073 | var attributes = [ 'line-through', 'bold', 'italic', 'underline' ]; |
1041 | 1074 | for (var i = 0; i < attributes.length; i++) |
1042 | 1075 | this.check_style_and_maybe_mark_up(style, attributes[i], 1); |
— | — | @@ -1402,8 +1435,10 @@ |
1403 | 1436 | proto.get_wiki_comment = function(element) { |
1404 | 1437 | for (var node = element.firstChild; node; node = node.nextSibling) { |
1405 | 1438 | if (node.nodeType == this.COMMENT_NODE_TYPE |
1406 | | - && node.data.match(/^\s*wiki/)) |
| 1439 | + && node.data.match(/^\s*wiki/) |
| 1440 | + ) { |
1407 | 1441 | return node; |
| 1442 | + } |
1408 | 1443 | } |
1409 | 1444 | return null; |
1410 | 1445 | } |
— | — | @@ -1438,16 +1473,9 @@ |
1439 | 1474 | |
1440 | 1475 | proto.smart_trailing_space = function(element) { |
1441 | 1476 | 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') { |
1452 | 1480 | this.appendOutput(' '); |
1453 | 1481 | } |
1454 | 1482 | } |
— | — | @@ -1475,7 +1503,7 @@ |
1476 | 1504 | before = this.config.markupRules.www[1]; |
1477 | 1505 | after = this.config.markupRules.www[2]; |
1478 | 1506 | } |
1479 | | - |
| 1507 | + |
1480 | 1508 | this.assert_space_or_newline(); |
1481 | 1509 | if (! href) { |
1482 | 1510 | this.appendOutput(label); |
— | — | @@ -1486,8 +1514,13 @@ |
1487 | 1515 | else if (this.href_is_wiki_link(href)) { |
1488 | 1516 | if (this.camel_case_link(label)) |
1489 | 1517 | 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 | + } |
1492 | 1525 | } |
1493 | 1526 | else { |
1494 | 1527 | this.appendOutput(before + href + ' ' + label + after); |
— | — | @@ -1505,7 +1538,7 @@ |
1506 | 1539 | return true; |
1507 | 1540 | if (! href.match(/\?/)) |
1508 | 1541 | return false; |
1509 | | - if (href.match(/\/static\/\d+\.\d+\.\d+\.\d+\//)) |
| 1542 | + if (href.match(/\/static\//) && href.match(/\/js-test\//)) |
1510 | 1543 | href = location.href; |
1511 | 1544 | var no_arg_input = href.split('?')[0]; |
1512 | 1545 | var no_arg_current = location.href.split('?')[0]; |
Index: trunk/extensions/wikiwyg/lib/Wikiwyg/Util.js |
— | — | @@ -48,7 +48,7 @@ |
49 | 49 | |
50 | 50 | // getStyle() |
51 | 51 | // http://www.robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/ |
52 | | -function getStyle(oElm, strCssRule) { |
| 52 | +function WKWgetStyle(oElm, strCssRule) { |
53 | 53 | var strValue = ""; |
54 | 54 | if(document.defaultView && document.defaultView.getComputedStyle){ |
55 | 55 | strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule); |
— | — | @@ -154,25 +154,25 @@ |
155 | 155 | //------------------------------------------------------------------------------ |
156 | 156 | // Ajax support |
157 | 157 | //------------------------------------------------------------------------------ |
158 | | -if (! this.Ajax) Ajax = {}; |
| 158 | +if (! this.WKWAjax) WKWAjax = {}; |
159 | 159 | |
160 | | -Ajax.get = function(url, callback) { |
| 160 | +WKWAjax.get = function(url, callback) { |
161 | 161 | var req = new XMLHttpRequest(); |
162 | 162 | req.open('GET', url, Boolean(callback)); |
163 | | - return Ajax._send(req, null, callback); |
| 163 | + return WKWAjax._send(req, null, callback); |
164 | 164 | } |
165 | 165 | |
166 | | -Ajax.post = function(url, data, callback) { |
| 166 | +WKWAjax.post = function(url, data, callback) { |
167 | 167 | var req = new XMLHttpRequest(); |
168 | 168 | req.open('POST', url, Boolean(callback)); |
169 | 169 | req.setRequestHeader( |
170 | 170 | 'Content-Type', |
171 | 171 | 'application/x-www-form-urlencoded' |
172 | 172 | ); |
173 | | - return Ajax._send(req, data, callback); |
| 173 | + return WKWAjax._send(req, data, callback); |
174 | 174 | } |
175 | 175 | |
176 | | -Ajax._send = function(req, data, callback) { |
| 176 | +WKWAjax._send = function(req, data, callback) { |
177 | 177 | if (callback) { |
178 | 178 | req.onreadystatechange = function() { |
179 | 179 | if (req.readyState == 4) { |
Index: trunk/extensions/wikiwyg/lib/Wikiwyg/Preview.js |
— | — | @@ -37,7 +37,7 @@ |
38 | 38 | if (this.config.divId) |
39 | 39 | this.div = document.getElementById(this.config.divId); |
40 | 40 | else |
41 | | - this.div = document.createElement('div'); |
| 41 | + this.div = document.createElement('span'); |
42 | 42 | // XXX Make this a config option. |
43 | 43 | this.div.style.backgroundColor = 'lightyellow'; |
44 | 44 | } |
Index: trunk/extensions/wikiwyg/lib/Wikiwyg.js |
— | — | @@ -274,13 +274,13 @@ |
275 | 275 | // This method is deprecated. Use Ajax.get and Ajax.post. |
276 | 276 | Wikiwyg.liveUpdate = function(method, url, query, callback) { |
277 | 277 | if (method == 'GET') { |
278 | | - return Ajax.get( |
| 278 | + return WKWAjax.get( |
279 | 279 | url + '?' + query, |
280 | 280 | callback |
281 | 281 | ); |
282 | 282 | } |
283 | 283 | if (method == 'POST') { |
284 | | - return Ajax.post( |
| 284 | + return WKWAjax.post( |
285 | 285 | url, |
286 | 286 | query, |
287 | 287 | callback |
Index: trunk/extensions/wikiwyg/COPYRIGHT |
— | — | @@ -3,6 +3,8 @@ |
4 | 4 | Palo Alto, CA 94301 U.S.A. |
5 | 5 | All rights reserved. |
6 | 6 | |
| 7 | + Copyright (c) 2007, Wikia Inc. |
| 8 | + |
7 | 9 | Wikiwyg is free software. |
8 | 10 | |
9 | 11 | This library is free software; you can redistribute it and/or modify it |
Index: trunk/extensions/wikiwyg/Changes |
— | — | @@ -9,7 +9,7 @@ |
10 | 10 | changes: |
11 | 11 | - Lots |
12 | 12 | --- |
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 |
15 | 15 | changes: |
16 | | -- Initial release |
| 16 | +- Lots |
Index: trunk/extensions/wikiwyg/AUTHORS |
— | — | @@ -8,3 +8,4 @@ |
9 | 9 | Dave Rolsky <autarch@urth.org> |
10 | 10 | Kang-min Liu <gugod@gugod.org> |
11 | 11 | 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\"> </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 |
1 | 186 | + 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 |
1 | 724 | + native |
Index: trunk/extensions/wikiwyg/share/MediaWiki/extensions/MediaWikiWyg.php |
— | — | @@ -1,24 +1,77 @@ |
2 | 2 | <?PHP |
3 | 3 | |
4 | | -global $wgHooks; |
| 4 | +global $wgHooks, $wgInPageEnabled ; |
| 5 | + if (!isset($wgInPageEnabled) || ($wgInPageEnabled == false)) { |
| 6 | + return ; |
| 7 | + } |
| 8 | + |
5 | 9 | $wgHooks['ParserBeforeTidy'][] = 'beforeTidyHook' ; |
| 10 | +$wgHooks['UserToggles'][] = 'wfWikiwygToggle' ; |
| 11 | +$wgHooks['handleWikiPrefs'][] = 'wfWikiwygHandleEditingPrefs' ; |
| 12 | +$wgHooks['getEditingPreferencesTab'][] = 'wfWikiwygAddEditingPrefs' ; |
6 | 13 | |
7 | 14 | $wgExtensionFunctions[] = 'registerWikiwygExtension'; |
8 | 15 | $wgExtensionCredits['other'][] = array( |
9 | 16 | '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', |
13 | 20 | 'description' => 'Mediawiki integration of the Wikiwyg WYSIWYG wiki editor' |
14 | 21 | ); |
15 | 22 | |
| 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 | + |
16 | 52 | function registerWikiwygExtension() { |
17 | | - global $wgOut,$wgSkin,$jsdir,$cssdir; |
18 | | - global $wgWikiwygPath; |
| 53 | + global $wgOut,$wgSkin,$jsdir,$cssdir, $wgScriptPath ; |
| 54 | + global $wgWikiwygPath, $wgUser, $wgTitle ; |
19 | 55 | global $wgServer,$wgWikiwygJsPath,$wgWikiwygCssPath,$wgWikiwygImagePath; |
| 56 | + global $wgRequest, $wgWysiwygEnabled, $wgMessageCache ; |
| 57 | + global $wgLang, $wgContLang, $wgEnableAjaxLogin ; |
20 | 58 | |
| 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 | + |
21 | 74 | if (! isset($wgWikiwygPath)) { |
22 | | - $wgWikiwygPath = "$wgServer/wikiwyg"; |
| 75 | + $wgWikiwygPath = $wgScriptPath . "/extensions/wikiwyg"; |
23 | 76 | } |
24 | 77 | if (! isset($wgWikiwygJsPath)) { |
25 | 78 | $wgWikiwygJsPath = "$wgWikiwygPath/share/MediaWiki"; |
— | — | @@ -29,137 +82,363 @@ |
30 | 83 | if (! isset($wgWikiwygImagePath)) { |
31 | 84 | $wgWikiwygImagePath = "$wgWikiwygPath/share/MediaWiki/images"; |
32 | 85 | } |
| 86 | + |
33 | 87 | $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 | + |
34 | 99 | $wgOut->addScript(" |
35 | 100 | <script type=\"text/javascript\"> |
36 | 101 | if (typeof(Wikiwyg) == 'undefined') Wikiwyg = function() {}; |
37 | 102 | 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) ) ."\" ; |
38 | 126 | </script> |
39 | 127 | "); |
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"); |
41 | 139 | } |
42 | 140 | |
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) { |
44 | 166 | $blocks = preg_split( |
45 | | - '/(<div class="editsection".*?<\/div>)/i', |
| 167 | + '/(<a name=".*?".*?<\/a><h'.$level.'><span class="editsection".*?<\/span>)/i', |
46 | 168 | $text, -1, PREG_SPLIT_DELIM_CAPTURE |
47 | 169 | ); |
48 | 170 | |
49 | 171 | $i = 0; |
50 | | - |
| 172 | + |
51 | 173 | $full = array_shift($blocks); |
| 174 | + $header_block = "" ; |
52 | 175 | 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 | + } |
60 | 202 | } |
61 | 203 | # This is a section body |
62 | 204 | else { |
63 | 205 | if ($i == 0) { |
64 | 206 | die("Wrong order!"); |
65 | 207 | } |
| 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 ; |
66 | 225 | $full .= " |
67 | | -<div class=\"wikiwyg_section\" id=\"wikiwyg_section_{$i}\"> |
68 | | -$block |
69 | | -</div> |
| 226 | +</span> |
70 | 227 | <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' |
73 | 230 | frameborder='0'> |
74 | 231 | </iframe> |
75 | 232 | "; |
76 | 233 | } |
77 | 234 | } |
78 | | - $text = $full; |
79 | | - return true; |
| 235 | + return $full ; |
80 | 236 | } |
81 | 237 | |
| 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 | + |
82 | 249 | # Not a valid entry point, skip unless MEDIAWIKI is defined |
83 | 250 | if (defined('MEDIAWIKI')) { |
84 | 251 | $wgExtensionFunctions[] = 'wfEZParser'; |
85 | 252 | |
86 | | -$wgAvailableRights[] = 'ezparser'; |
87 | | - |
88 | | -$wgGroupPermissions['ezparser']['ezparser'] = true; |
89 | | - |
90 | 253 | function wfEZParser() { |
91 | 254 | global $IP; |
92 | 255 | require_once( $IP.'/includes/SpecialPage.php' ); |
93 | 256 | |
94 | | -#class EZParser extends UnlistedSpecialPage |
95 | | -class EZParser extends SpecialPage |
| 257 | +class EZParser extends UnlistedSpecialPage |
96 | 258 | { |
97 | 259 | function EZParser() { |
98 | | -# UnlistedSpecialPage::UnlistedSpecialPage('EZParser'); |
99 | | - SpecialPage::SpecialPage('EZParser'); |
| 260 | + UnlistedSpecialPage::UnlistedSpecialPage('EZParser'); |
100 | 261 | } |
101 | 262 | |
102 | 263 | function execute( $par ) { |
103 | 264 | global $wgRequest, $wgOut, $wgTitle, $wgUser; |
104 | | - |
105 | | - if (!in_array( 'ezparser', $wgUser->getRights() ) ) { |
| 265 | + |
| 266 | +/* if (!in_array( 'ezparser', $wgUser->getRights() ) ) { |
106 | 267 | $wgOut->setArticleRelated( false ); |
107 | 268 | $wgOut->setRobotpolicy( 'noindex,follow' ); |
108 | 269 | $wgOut->errorpage( 'nosuchspecialpage', 'nospecialpagetext' ); |
109 | 270 | return; |
110 | 271 | } |
| 272 | +*/ |
111 | 273 | |
112 | 274 | $this->setHeaders(); |
113 | 275 | |
114 | | - $text = $wgRequest->getText( 'text' ); |
| 276 | + $text = $wgRequest->getText ('text') ; |
| 277 | + $title = $wgRequest->getText ('rtitle') ; |
| 278 | + $namespace = $wgRequest->getText ('rnamespace') ; |
115 | 279 | |
116 | 280 | if ( $text ) { |
117 | | - $this->parseText( $text ); |
| 281 | + $this->parseText( $text, $title ); |
| 282 | + } else { |
| 283 | + $wgOut->setArticleBodyOnly( true ); |
118 | 284 | } |
119 | | - else{ |
120 | | - $this->addForm(); |
121 | | - } |
122 | 285 | } |
123 | 286 | |
124 | | - function parseText($text){ |
| 287 | + function parseText($text, $title){ |
125 | 288 | #still need to make it actually parse the input. |
126 | 289 | global $wgOut, $wgUser, $wgTitle, $wgParser, $wgAllowDiffPreview, $wgEnableDiffPreviewPreference; |
127 | 290 | $parserOptions = ParserOptions::newFromUser( $wgUser ); |
128 | 291 | $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 ); |
130 | 296 | $wgOut->setArticleBodyOnly( true ); |
131 | 297 | |
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, |
133 | 299 | # 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. |
135 | 301 | |
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 | +} |
137 | 308 | |
138 | | - $wgOut->addHTML($goodHTML); |
| 309 | +global $wgMessageCache; |
| 310 | +SpecialPage::addPage( new EZParser ); |
| 311 | +$wgMessageCache->addMessage( 'ezparser', 'Simple parser test' ); |
139 | 312 | |
| 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'); |
140 | 324 | } |
141 | 325 | |
142 | | - function addForm(){ |
143 | | - global $wgOut, $wgTitle; |
| 326 | + function execute( $par ) { |
| 327 | + global $wgRequest, $wgOut, $wgTitle, $wgUser; |
144 | 328 | |
145 | | - $action = $wgTitle->escapeLocalUrl(); |
| 329 | + $this->setHeaders(); |
146 | 330 | |
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 | + } |
156 | 340 | } |
| 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 | + } |
157 | 372 | } |
158 | 373 | |
159 | 374 | 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' ); |
162 | 377 | |
163 | 378 | } |
| 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 | + |
164 | 443 | } # End if(defined MEDIAWIKI) |
165 | 444 | |
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 | + |
2 | 91 | // BEGIN ../../lib/Wikiwyg.js |
3 | 92 | /*============================================================================== |
4 | 93 | Wikiwyg - Turn any HTML div into a wikitext /and/ wysiwyg edit area. |
— | — | @@ -25,13 +114,20 @@ |
26 | 115 | |
27 | 116 | COPYRIGHT: |
28 | 117 | |
29 | | - Copyright (c) 2005 Socialtext Corporation |
| 118 | + Copyright (c) 2005 Socialtext Corporation |
30 | 119 | 655 High Street |
31 | 120 | Palo Alto, CA 94301 U.S.A. |
32 | 121 | All rights reserved. |
33 | 122 | |
34 | | -Wikiwyg is free software. |
35 | 123 | |
| 124 | +CHANGES AUTHOR: |
| 125 | + |
| 126 | + Bartek Lapinski <bartek@wikia.com> |
| 127 | + |
| 128 | + Copyright (c) 2007, Wikia Inc. |
| 129 | + |
| 130 | +Wikiwyg is free software. |
| 131 | + |
36 | 132 | This library is free software; you can redistribute it and/or modify it |
37 | 133 | under the terms of the GNU Lesser General Public License as published by |
38 | 134 | the Free Software Foundation; either version 2.1 of the License, or (at |
— | — | @@ -83,7 +179,7 @@ |
84 | 180 | Wikiwyg.ua = navigator.userAgent.toLowerCase(); |
85 | 181 | Wikiwyg.is_ie = ( |
86 | 182 | Wikiwyg.ua.indexOf("msie") != -1 && |
87 | | - Wikiwyg.ua.indexOf("opera") == -1 && |
| 183 | + Wikiwyg.ua.indexOf("opera") == -1 && |
88 | 184 | Wikiwyg.ua.indexOf("webtv") == -1 |
89 | 185 | ); |
90 | 186 | Wikiwyg.is_gecko = ( |
— | — | @@ -112,18 +208,21 @@ |
113 | 209 | }; |
114 | 210 | |
115 | 211 | proto.default_config = { |
116 | | - javascriptLocation: 'lib/', |
| 212 | + javascriptLocation: '/wikiwyg/lib/', |
117 | 213 | doubleClickToEdit: false, |
118 | 214 | toolbarClass: 'Wikiwyg.Toolbar', |
119 | 215 | firstMode: null, |
120 | 216 | modeClasses: [ |
121 | | - 'Wikiwyg.Wysiwyg', |
122 | | - 'Wikiwyg.Wikitext', |
| 217 | + 'Wikiwyg.Wysiwyg' , |
| 218 | + 'Wikiwyg.Wikitext' , |
123 | 219 | 'Wikiwyg.Preview' |
124 | 220 | ] |
125 | 221 | }; |
126 | 222 | |
127 | 223 | proto.initializeObject = function(div, config) { |
| 224 | + /* enable people to use Special:Createpage regardless of this preference */ |
| 225 | + if ((wgUseInPage == 0) && (wgCanonicalSpecialPageName != "Createpage") ) return ; |
| 226 | + |
128 | 227 | if (! Wikiwyg.browserIsSupported) return; |
129 | 228 | if (this.enabled) return; |
130 | 229 | this.enabled = true; |
— | — | @@ -146,16 +245,25 @@ |
147 | 246 | ? this.config.firstMode |
148 | 247 | : this.config.modeClasses[0]; |
149 | 248 | this.setFirstModeByName(firstMode); |
| 249 | + var section_number = this.div.id.replace(/.*?(\d+)$/, '$1') ; |
150 | 250 | |
151 | 251 | 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 | + } |
158 | 266 | } |
159 | | - |
| 267 | + |
160 | 268 | // These objects must be _created_ before the toolbar is created |
161 | 269 | // but _inserted_ after. |
162 | 270 | for (var i = 0; i < this.config.modeClasses.length; i++) { |
— | — | @@ -166,7 +274,7 @@ |
167 | 275 | |
168 | 276 | if (this.config.doubleClickToEdit) { |
169 | 277 | var self = this; |
170 | | - this.div.ondblclick = function() { self.editMode() }; |
| 278 | + this.div.ondblclick = function() { self.editMode() }; |
171 | 279 | } |
172 | 280 | } |
173 | 281 | |
— | — | @@ -195,23 +303,95 @@ |
196 | 304 | this.config = new_config; |
197 | 305 | } |
198 | 306 | |
199 | | -proto.insert_div_before = function(div) { |
| 307 | +proto.insert_div_before = function (div) { |
200 | 308 | div.style.display = 'none'; |
201 | 309 | if (! div.iframe_hack) { |
202 | 310 | this.div.parentNode.insertBefore(div, this.div); |
203 | 311 | } |
204 | 312 | } |
205 | 313 | |
| 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 | + |
206 | 373 | // Wikiwyg actions - public methods |
207 | 374 | proto.saveChanges = function() { |
208 | 375 | alert('Wikiwyg.prototype.saveChanges not subclassed'); |
209 | 376 | } |
210 | 377 | |
| 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 | + |
211 | 390 | proto.editMode = function() { // See IE, below |
| 391 | + currentWikiwyg = this ; |
212 | 392 | 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() ; |
216 | 396 | } |
217 | 397 | |
218 | 398 | proto.displayMode = function() { |
— | — | @@ -252,6 +432,10 @@ |
253 | 433 | this.displayMode(); |
254 | 434 | } |
255 | 435 | |
| 436 | +proto.initHtml = function (html) { |
| 437 | + this.fromHtml (html) ; |
| 438 | +} |
| 439 | + |
256 | 440 | proto.fromHtml = function(html) { |
257 | 441 | this.div.innerHTML = html; |
258 | 442 | } |
— | — | @@ -260,9 +444,14 @@ |
261 | 445 | this.insert_div_before(div); |
262 | 446 | } |
263 | 447 | |
| 448 | +proto.placeLowerToolbar = function (div) { |
| 449 | + this.insert_div_after(div) ; |
| 450 | +} |
| 451 | + |
264 | 452 | proto.setFirstModeByName = function(mode_name) { |
265 | | - if (!this.modeByName(mode_name)) |
| 453 | + if (!this.modeByName(mode_name)) { |
266 | 454 | die('No mode named ' + mode_name); |
| 455 | +} |
267 | 456 | this.first_mode = this.modeByName(mode_name); |
268 | 457 | } |
269 | 458 | |
— | — | @@ -272,16 +461,16 @@ |
273 | 462 | return 'wikiwyg_' + Wikiwyg.unique_id_base++; |
274 | 463 | } |
275 | 464 | |
276 | | -// This method is deprecated. Use Ajax.get and Ajax.post. |
| 465 | +// This method is deprecated. Use WKWAjax.get and WKWAjax.post. |
277 | 466 | Wikiwyg.liveUpdate = function(method, url, query, callback) { |
278 | 467 | if (method == 'GET') { |
279 | | - return Ajax.get( |
| 468 | + return WKWAjax.get( |
280 | 469 | url + '?' + query, |
281 | 470 | callback |
282 | 471 | ); |
283 | 472 | } |
284 | 473 | if (method == 'POST') { |
285 | | - return Ajax.post( |
| 474 | + return WKWAjax.post( |
286 | 475 | url, |
287 | 476 | query, |
288 | 477 | callback |
— | — | @@ -317,6 +506,28 @@ |
318 | 507 | document.getElementById(id).style.visibility = 'hidden'; |
319 | 508 | } |
320 | 509 | |
| 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 | +} |
321 | 532 | |
322 | 533 | Wikiwyg.changeLinksMatching = function(attribute, pattern, func) { |
323 | 534 | var links = document.getElementsByTagName('a'); |
— | — | @@ -402,6 +613,10 @@ |
403 | 614 | this.display_unsupported_toolbar_buttons('none'); |
404 | 615 | this.wikiwyg.toolbarObject.enableThis(); |
405 | 616 | 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 | + } |
406 | 621 | } |
407 | 622 | |
408 | 623 | proto.display_unsupported_toolbar_buttons = function(display) { |
— | — | @@ -435,6 +650,10 @@ |
436 | 651 | proto.disableThis = function() { |
437 | 652 | this.display_unsupported_toolbar_buttons('inline'); |
438 | 653 | 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 | + } |
439 | 658 | } |
440 | 659 | |
441 | 660 | proto.process_command = function(command) { |
— | — | @@ -479,6 +698,9 @@ |
480 | 699 | this.config.editHeightAdjustment |
481 | 700 | ); |
482 | 701 | var min = this.config.editHeightMinimum; |
| 702 | + if (this.config.overrideHeightMinimum) { |
| 703 | + return min ; |
| 704 | + } |
483 | 705 | return height < min |
484 | 706 | ? min |
485 | 707 | : height; |
— | — | @@ -567,13 +789,19 @@ |
568 | 790 | |
569 | 791 | COPYRIGHT: |
570 | 792 | |
571 | | - Copyright (c) 2005 Socialtext Corporation |
| 793 | + Copyright (c) 2005 Socialtext Corporation |
572 | 794 | 655 High Street |
573 | 795 | Palo Alto, CA 94301 U.S.A. |
574 | 796 | All rights reserved. |
575 | 797 | |
576 | | -Wikiwyg is free software. |
| 798 | +CHANGES AUTHOR: |
577 | 799 | |
| 800 | + Bartek Lapinski <bartek@wikia.com> |
| 801 | + |
| 802 | + Copyright (c) 2007, Wikia Inc. |
| 803 | + |
| 804 | +Wikiwyg is free software. |
| 805 | + |
578 | 806 | This library is free software; you can redistribute it and/or modify it |
579 | 807 | under the terms of the GNU Lesser General Public License as published by |
580 | 808 | the Free Software Foundation; either version 2.1 of the License, or (at |
— | — | @@ -610,9 +838,9 @@ |
611 | 839 | return list; |
612 | 840 | } |
613 | 841 | |
614 | | -// getStyle() |
| 842 | +// WKWgetStyle() |
615 | 843 | // http://www.robertnyman.com/2006/04/24/get-the-rendered-style-of-an-element/ |
616 | | -function getStyle(oElm, strCssRule) { |
| 844 | +function WKWgetStyle(oElm, strCssRule) { |
617 | 845 | var strValue = ""; |
618 | 846 | if(document.defaultView && document.defaultView.getComputedStyle){ |
619 | 847 | strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule); |
— | — | @@ -666,7 +894,7 @@ |
667 | 895 | Wait.EXPORT = [ 'wait' ]; |
668 | 896 | Wait.EXPORT_TAGS = { ':all': Wait.EXPORT }; |
669 | 897 | |
670 | | -Wait.interval = 100; |
| 898 | +Wait.interval = 300; |
671 | 899 | |
672 | 900 | Wait.wait = function(arg1, arg2, arg3, arg4) { |
673 | 901 | if ( typeof arg1 == 'function' |
— | — | @@ -718,25 +946,25 @@ |
719 | 947 | //------------------------------------------------------------------------------ |
720 | 948 | // Ajax support |
721 | 949 | //------------------------------------------------------------------------------ |
722 | | -if (! this.Ajax) Ajax = {}; |
| 950 | +if (! this.WKWAjax) WKWAjax = {}; |
723 | 951 | |
724 | | -Ajax.get = function(url, callback) { |
| 952 | +WKWAjax.get = function(url, callback) { |
725 | 953 | var req = new XMLHttpRequest(); |
726 | 954 | req.open('GET', url, Boolean(callback)); |
727 | | - return Ajax._send(req, null, callback); |
| 955 | + return WKWAjax._send(req, null, callback); |
728 | 956 | } |
729 | 957 | |
730 | | -Ajax.post = function(url, data, callback) { |
| 958 | +WKWAjax.post = function(url, data, callback) { |
731 | 959 | var req = new XMLHttpRequest(); |
732 | 960 | req.open('POST', url, Boolean(callback)); |
733 | 961 | req.setRequestHeader( |
734 | | - 'Content-Type', |
| 962 | + 'Content-Type', |
735 | 963 | 'application/x-www-form-urlencoded' |
736 | 964 | ); |
737 | | - return Ajax._send(req, data, callback); |
| 965 | + return WKWAjax._send(req, data, callback); |
738 | 966 | } |
739 | 967 | |
740 | | -Ajax._send = function(req, data, callback) { |
| 968 | +WKWAjax._send = function(req, data, callback) { |
741 | 969 | if (callback) { |
742 | 970 | req.onreadystatechange = function() { |
743 | 971 | if (req.readyState == 4) { |
— | — | @@ -1070,13 +1298,20 @@ |
1071 | 1299 | |
1072 | 1300 | COPYRIGHT: |
1073 | 1301 | |
1074 | | - Copyright (c) 2005 Socialtext Corporation |
| 1302 | + Copyright (c) 2005 Socialtext Corporation |
1075 | 1303 | 655 High Street |
1076 | 1304 | Palo Alto, CA 94301 U.S.A. |
1077 | 1305 | All rights reserved. |
1078 | 1306 | |
1079 | | -Wikiwyg is free software. |
| 1307 | +CHANGES AUTHOR: |
1080 | 1308 | |
| 1309 | + Bartek Lapinski <bartek@wikia.com> |
| 1310 | + |
| 1311 | + Copyright (c) 2007, Wikia Inc. |
| 1312 | + |
| 1313 | + |
| 1314 | +Wikiwyg is free software. |
| 1315 | + |
1081 | 1316 | This library is free software; you can redistribute it and/or modify it |
1082 | 1317 | under the terms of the GNU Lesser General Public License as published by |
1083 | 1318 | the Free Software Foundation; either version 2.1 of the License, or (at |
— | — | @@ -1144,13 +1379,19 @@ |
1145 | 1380 | |
1146 | 1381 | COPYRIGHT: |
1147 | 1382 | |
1148 | | - Copyright (c) 2005 Socialtext Corporation |
| 1383 | + Copyright (c) 2005 Socialtext Corporation |
1149 | 1384 | 655 High Street |
1150 | 1385 | Palo Alto, CA 94301 U.S.A. |
1151 | 1386 | All rights reserved. |
1152 | 1387 | |
1153 | | -Wikiwyg is free software. |
| 1388 | +CHANGES AUTHOR: |
1154 | 1389 | |
| 1390 | + Bartek Lapinski <bartek@wikia.com> |
| 1391 | + |
| 1392 | + Copyright (c) 2007, Wikia Inc. |
| 1393 | + |
| 1394 | +Wikiwyg is free software. |
| 1395 | + |
1155 | 1396 | This library is free software; you can redistribute it and/or modify it |
1156 | 1397 | under the terms of the GNU Lesser General Public License as published by |
1157 | 1398 | the Free Software Foundation; either version 2.1 of the License, or (at |
— | — | @@ -1174,31 +1415,35 @@ |
1175 | 1416 | imagesExtension: '.gif', |
1176 | 1417 | controlLayout: [ |
1177 | 1418 | 'save', 'cancel', 'mode_selector', '/', |
1178 | | - // 'selector', |
1179 | 1419 | 'h1', 'h2', 'h3', 'h4', 'p', 'pre', '|', |
1180 | 1420 | 'bold', 'italic', 'underline', 'strike', '|', |
1181 | 1421 | 'link', 'hr', '|', |
1182 | 1422 | 'ordered', 'unordered', '|', |
1183 | 1423 | 'indent', 'outdent', '|', |
1184 | | - 'table', '|', |
| 1424 | + 'table', '|', 'timestamp' , |
1185 | 1425 | 'help' |
1186 | 1426 | ], |
1187 | 1427 | styleSelector: [ |
1188 | 1428 | 'label', 'p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'pre' |
1189 | 1429 | ], |
| 1430 | + |
1190 | 1431 | controlLabels: { |
1191 | | - save: 'Save', |
1192 | | - cancel: 'Cancel', |
| 1432 | + save: wgSaveCaption , |
| 1433 | + cancel: wgCancelCaption , |
1193 | 1434 | bold: 'Bold (Ctrl+b)', |
1194 | 1435 | italic: 'Italic (Ctrl+i)', |
1195 | 1436 | underline: 'Underline (Ctrl+u)', |
| 1437 | + insertimage: wgInsertImageCaption , |
| 1438 | + youtube: 'Add YouTube Video' , |
| 1439 | + wikify: 'Wikify' , |
1196 | 1440 | strike: 'Strike Through (Ctrl+d)', |
1197 | | - hr: 'Horizontal Rule', |
| 1441 | + hr: wgHrTip , |
1198 | 1442 | ordered: 'Numbered List', |
1199 | 1443 | unordered: 'Bulleted List', |
1200 | 1444 | indent: 'More Indented', |
1201 | 1445 | outdent: 'Less Indented', |
1202 | 1446 | help: 'About Wikiwyg', |
| 1447 | + timestamp: wgTimestampTip , |
1203 | 1448 | label: '[Style]', |
1204 | 1449 | p: 'Normal Text', |
1205 | 1450 | pre: 'Preformatted', |
— | — | @@ -1208,13 +1453,14 @@ |
1209 | 1454 | h4: 'Heading 4', |
1210 | 1455 | h5: 'Heading 5', |
1211 | 1456 | h6: 'Heading 6', |
1212 | | - link: 'Create Link', |
| 1457 | + link: wgIntlinkTip , |
| 1458 | + www: wgExtlinkTip , |
1213 | 1459 | unlink: 'Remove Linkedness', |
1214 | 1460 | table: 'Create Table' |
1215 | 1461 | } |
1216 | 1462 | }; |
1217 | 1463 | |
1218 | | -proto.initializeObject = function() { |
| 1464 | +proto.initializeObject = function(section_number) { |
1219 | 1465 | if (this.config.divId) { |
1220 | 1466 | this.div = document.getElementById(this.config.divId); |
1221 | 1467 | } |
— | — | @@ -1222,34 +1468,233 @@ |
1223 | 1469 | this.div = Wikiwyg.createElementWithAttrs( |
1224 | 1470 | 'div', { |
1225 | 1471 | 'class': 'wikiwyg_toolbar', |
1226 | | - id: 'wikiwyg_toolbar' |
| 1472 | + id: 'wikiwyg_toolbar_' + section_number |
1227 | 1473 | } |
1228 | | - ); |
| 1474 | + ) ; |
1229 | 1475 | } |
| 1476 | + this.section_number = section_number ; |
| 1477 | + var config = this.config; |
1230 | 1478 | |
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) { |
1232 | 1499 | for (var i = 0; i < config.controlLayout.length; i++) { |
1233 | 1500 | var action = config.controlLayout[i]; |
1234 | 1501 | 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, '') ; |
1241 | 1519 | else if (action == 'selector') |
1242 | 1520 | this.add_styles(); |
1243 | 1521 | 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 | + } |
1247 | 1530 | 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 | + } |
1249 | 1542 | else |
1250 | | - this.add_button(action, label); |
| 1543 | + this.add_button (action, label, left_div) ; |
1251 | 1544 | } |
1252 | 1545 | } |
1253 | 1546 | |
| 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 | + |
1254 | 1699 | proto.enableThis = function() { |
1255 | 1700 | this.div.style.display = 'block'; |
1256 | 1701 | } |
— | — | @@ -1258,6 +1703,70 @@ |
1259 | 1704 | this.div.style.display = 'none'; |
1260 | 1705 | } |
1261 | 1706 | |
| 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 | + |
1262 | 1771 | proto.make_button = function(type, label) { |
1263 | 1772 | var base = this.config.imagesLocation; |
1264 | 1773 | var ext = this.config.imagesExtension; |
— | — | @@ -1277,31 +1786,41 @@ |
1278 | 1787 | ); |
1279 | 1788 | } |
1280 | 1789 | |
1281 | | -proto.add_button = function(type, label) { |
| 1790 | +proto.add_button = function(type, label, div) { |
1282 | 1791 | var img = this.make_button(type, label); |
1283 | 1792 | var self = this; |
1284 | 1793 | img.onclick = function() { |
1285 | 1794 | self.wikiwyg.current_mode.process_command(type); |
1286 | 1795 | }; |
1287 | | - this.div.appendChild(img); |
| 1796 | + div.appendChild(img); |
1288 | 1797 | } |
1289 | 1798 | |
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', { |
1294 | 1806 | target: 'wikiwyg_button', |
1295 | | - href: 'http://www.wikiwyg.net/about/' |
1296 | | - } |
| 1807 | + href: 'http://www.wikia.com/wiki/Help:Tutorial_2' |
| 1808 | + } |
1297 | 1809 | ); |
1298 | | - a.appendChild(img); |
1299 | | - this.div.appendChild(a); |
| 1810 | + link.appendChild(document.createTextNode(wgHelpCaption)); |
| 1811 | + span.appendChild(link); |
| 1812 | + div.appendChild(span); |
1300 | 1813 | } |
1301 | 1814 | |
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) { |
1303 | 1822 | var base = this.config.imagesLocation; |
1304 | 1823 | var ext = this.config.imagesExtension; |
1305 | | - this.div.appendChild( |
| 1824 | + div.appendChild( |
1306 | 1825 | Wikiwyg.createElementWithAttrs( |
1307 | 1826 | 'img', { |
1308 | 1827 | 'class': 'wikiwyg_separator', |
— | — | @@ -1313,23 +1832,96 @@ |
1314 | 1833 | ); |
1315 | 1834 | } |
1316 | 1835 | |
1317 | | -proto.addControlItem = function(text, method) { |
| 1836 | +proto.addControlItem = function (text, method, div, place) { |
1318 | 1837 | var span = Wikiwyg.createElementWithAttrs( |
1319 | 1838 | 'span', { 'class': 'wikiwyg_control_link' } |
1320 | | - ); |
| 1839 | + ) ; |
1321 | 1840 | |
| 1841 | + if (place != '') { |
| 1842 | + place = place + '_' ; |
| 1843 | + } |
| 1844 | + |
1322 | 1845 | var link = Wikiwyg.createElementWithAttrs( |
1323 | | - 'a', { href: '#' } |
| 1846 | + 'a', { href: '#', id: 'wikiwyg_ctrl_lnk_' + method + '_' + place + this.section_number } |
1324 | 1847 | ); |
| 1848 | + |
1325 | 1849 | link.appendChild(document.createTextNode(text)); |
1326 | 1850 | span.appendChild(link); |
1327 | | - |
| 1851 | + |
1328 | 1852 | var self = this; |
1329 | | - link.onclick = function() { eval('self.wikiwyg.' + method + '()'); return false }; |
1330 | 1853 | |
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); |
1332 | 1862 | } |
1333 | 1863 | |
| 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 | + |
1334 | 1926 | proto.resetModeSelector = function() { |
1335 | 1927 | if (this.firstModeRadio) { |
1336 | 1928 | var temp = this.firstModeRadio.onclick; |
— | — | @@ -1339,6 +1931,40 @@ |
1340 | 1932 | } |
1341 | 1933 | } |
1342 | 1934 | |
| 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 | + |
1343 | 1969 | proto.addModeSelector = function() { |
1344 | 1970 | var span = document.createElement('span'); |
1345 | 1971 | |
— | — | @@ -1346,27 +1972,25 @@ |
1347 | 1973 | for (var i = 0; i < this.wikiwyg.config.modeClasses.length; i++) { |
1348 | 1974 | var class_name = this.wikiwyg.config.modeClasses[i]; |
1349 | 1975 | var mode_object = this.wikiwyg.mode_objects[class_name]; |
1350 | | - |
| 1976 | + |
1351 | 1977 | var radio_id = Wikiwyg.createUniqueId(); |
1352 | | - |
1353 | | - var checked = i == 0 ? 'checked' : ''; |
1354 | 1978 | var radio = Wikiwyg.createElementWithAttrs( |
1355 | 1979 | '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 |
1361 | 1984 | } |
1362 | 1985 | ); |
1363 | 1986 | if (!this.firstModeRadio) |
1364 | 1987 | this.firstModeRadio = radio; |
1365 | | - |
| 1988 | + |
1366 | 1989 | var self = this; |
1367 | | - radio.onclick = function() { |
| 1990 | + |
| 1991 | + radio.onclick = function() { |
1368 | 1992 | self.wikiwyg.switchMode(this.value); |
1369 | 1993 | }; |
1370 | | - |
| 1994 | + |
1371 | 1995 | var label = Wikiwyg.createElementWithAttrs( |
1372 | 1996 | 'label', { 'for': radio_id } |
1373 | 1997 | ); |
— | — | @@ -1378,11 +2002,11 @@ |
1379 | 2003 | this.div.appendChild(span); |
1380 | 2004 | } |
1381 | 2005 | |
1382 | | -proto.add_break = function() { |
1383 | | - this.div.appendChild(document.createElement('br')); |
| 2006 | +proto.add_break = function (div) { |
| 2007 | + div.appendChild(document.createElement('br')); |
1384 | 2008 | } |
1385 | 2009 | |
1386 | | -proto.add_styles = function() { |
| 2010 | +proto.add_styles = function (div) { |
1387 | 2011 | var options = this.config.styleSelector; |
1388 | 2012 | var labels = this.config.controlLabels; |
1389 | 2013 | |
— | — | @@ -1401,10 +2025,10 @@ |
1402 | 2026 | this.styleSelect.appendChild(option); |
1403 | 2027 | } |
1404 | 2028 | 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) |
1407 | 2031 | }; |
1408 | | - this.div.appendChild(this.styleSelect); |
| 2032 | + div.appendChild(this.styleSelect); |
1409 | 2033 | } |
1410 | 2034 | |
1411 | 2035 | proto.set_style = function(style_name) { |
— | — | @@ -1420,13 +2044,19 @@ |
1421 | 2045 | |
1422 | 2046 | COPYRIGHT: |
1423 | 2047 | |
1424 | | - Copyright (c) 2005 Socialtext Corporation |
| 2048 | + Copyright (c) 2005 Socialtext Corporation |
1425 | 2049 | 655 High Street |
1426 | 2050 | Palo Alto, CA 94301 U.S.A. |
1427 | 2051 | All rights reserved. |
1428 | 2052 | |
1429 | | -Wikiwyg is free software. |
| 2053 | +CHANGES AUTHOR: |
1430 | 2054 | |
| 2055 | + Bartek Lapinski <bartek@wikia.com> |
| 2056 | + |
| 2057 | + Copyright (c) 2007, Wikia Inc. |
| 2058 | + |
| 2059 | +Wikiwyg is free software. |
| 2060 | + |
1431 | 2061 | This library is free software; you can redistribute it and/or modify it |
1432 | 2062 | under the terms of the GNU Lesser General Public License as published by |
1433 | 2063 | the Free Software Foundation; either version 2.1 of the License, or (at |
— | — | @@ -1444,7 +2074,7 @@ |
1445 | 2075 | proto = new Subclass('Wikiwyg.Preview', 'Wikiwyg.Mode'); |
1446 | 2076 | |
1447 | 2077 | proto.classtype = 'preview'; |
1448 | | -proto.modeDescription = 'Preview'; |
| 2078 | +proto.modeDescription = wgPreviewCaption ; |
1449 | 2079 | |
1450 | 2080 | proto.config = { |
1451 | 2081 | divId: null |
— | — | @@ -1456,9 +2086,16 @@ |
1457 | 2087 | else |
1458 | 2088 | this.div = document.createElement('div'); |
1459 | 2089 | // 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' ; |
1461 | 2094 | } |
1462 | 2095 | |
| 2096 | +proto.initHtml = function (html) { |
| 2097 | + this.fromHtml (html) ; |
| 2098 | +} |
| 2099 | + |
1463 | 2100 | proto.fromHtml = function(html) { |
1464 | 2101 | this.div.innerHTML = html; |
1465 | 2102 | } |
— | — | @@ -1476,13 +2113,19 @@ |
1477 | 2114 | |
1478 | 2115 | COPYRIGHT: |
1479 | 2116 | |
1480 | | - Copyright (c) 2005 Socialtext Corporation |
| 2117 | + Copyright (c) 2005 Socialtext Corporation |
1481 | 2118 | 655 High Street |
1482 | 2119 | Palo Alto, CA 94301 U.S.A. |
1483 | 2120 | All rights reserved. |
1484 | 2121 | |
1485 | | -Wikiwyg is free software. |
| 2122 | +CHANGES AUTHOR: |
1486 | 2123 | |
| 2124 | + Bartek Lapinski <bartek@wikia.com> |
| 2125 | + |
| 2126 | + Copyright (c) 2007, Wikia Inc. |
| 2127 | + |
| 2128 | +Wikiwyg is free software. |
| 2129 | + |
1487 | 2130 | This library is free software; you can redistribute it and/or modify it |
1488 | 2131 | under the terms of the GNU Lesser General Public License as published by |
1489 | 2132 | the Free Software Foundation; either version 2.1 of the License, or (at |
— | — | @@ -1601,15 +2244,63 @@ |
1602 | 2245 | return wikitext; |
1603 | 2246 | } |
1604 | 2247 | |
| 2248 | +proto.initHtml = function (html) { |
| 2249 | + this.fromHtml (html) ; |
| 2250 | +} |
| 2251 | + |
1605 | 2252 | proto.fromHtml = function(html) { |
1606 | 2253 | this.setTextArea('Loading...'); |
1607 | 2254 | var self = this; |
1608 | 2255 | 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 | + } |
1611 | 2261 | ); |
1612 | 2262 | } |
1613 | 2263 | |
| 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 | + |
1614 | 2305 | proto.getTextArea = function() { |
1615 | 2306 | return this.textarea.value; |
1616 | 2307 | } |
— | — | @@ -1639,15 +2330,15 @@ |
1640 | 2331 | proto.find_left = function(t, selection_start, matcher) { |
1641 | 2332 | var substring = t.substr(selection_start - 1, 1); |
1642 | 2333 | var nextstring = t.substr(selection_start - 2, 1); |
1643 | | - if (selection_start == 0) |
| 2334 | + if (selection_start == 0) |
1644 | 2335 | return selection_start; |
1645 | 2336 | if (substring.match(matcher)) { |
1646 | 2337 | // special case for word.word |
1647 | | - if ((substring != '.') || (nextstring.match(/\s/))) |
| 2338 | + if ((substring != '.') || (nextstring.match(/\s/))) |
1648 | 2339 | return selection_start; |
1649 | 2340 | } |
1650 | 2341 | return this.find_left(t, selection_start - 1, matcher); |
1651 | | -} |
| 2342 | +} |
1652 | 2343 | |
1653 | 2344 | proto.find_right = function(t, selection_end, matcher) { |
1654 | 2345 | var substring = t.substr(selection_end, 1); |
— | — | @@ -1712,12 +2403,11 @@ |
1713 | 2404 | proto.get_words = function() { |
1714 | 2405 | function is_insane(selection) { |
1715 | 2406 | return selection.match(/\r?\n(\r?\n|\*+ |\#+ |\=+ )/); |
1716 | | - } |
| 2407 | + } |
1717 | 2408 | |
1718 | 2409 | t = this.area; // XXX needs "var"? |
1719 | 2410 | var selection_start = t.selectionStart; |
1720 | 2411 | var selection_end = t.selectionEnd; |
1721 | | - |
1722 | 2412 | if (selection_start == null) { |
1723 | 2413 | selection_start = selection_end; |
1724 | 2414 | if (selection_start == null) { |
— | — | @@ -1894,7 +2584,7 @@ |
1895 | 2585 | var already_start = new RegExp('^' + this.clean_regexp(markup_start), 'gm'); |
1896 | 2586 | var already_finish = new RegExp(this.clean_regexp(markup_finish) + '$', 'gm'); |
1897 | 2587 | var other_start = /^(\^+|\=+|\*+|#+|>+) */gm; |
1898 | | - var other_finish = /( +(\^+|\=+))?$/gm; |
| 2588 | + var other_finish = /( +(\^+|\=+))?$/m; |
1899 | 2589 | |
1900 | 2590 | var match; |
1901 | 2591 | if (this.sel.match(already_start)) { |
— | — | @@ -1953,8 +2643,9 @@ |
1954 | 2644 | var scroll_top = this.area.scrollTop; |
1955 | 2645 | if (markup_finish == 'undefined') |
1956 | 2646 | markup_finish = markup_start; |
1957 | | - if (this.get_words()) |
| 2647 | + if (this.get_words()) { |
1958 | 2648 | this.add_markup_words(markup_start, markup_finish, null); |
| 2649 | + } |
1959 | 2650 | this.area.scrollTop = scroll_top; |
1960 | 2651 | } |
1961 | 2652 | |
— | — | @@ -1985,14 +2676,96 @@ |
1986 | 2677 | proto.do_ordered = klass.make_do('ordered'); |
1987 | 2678 | proto.do_unordered = klass.make_do('unordered'); |
1988 | 2679 | proto.do_hr = klass.make_do('hr'); |
| 2680 | +proto.do_timestamp = klass.make_do('timestamp') ; |
1989 | 2681 | proto.do_table = klass.make_do('table'); |
1990 | 2682 | |
| 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 | + |
1991 | 2763 | 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 ; |
1993 | 2766 | var old = this.config.markupRules.www[1]; |
1994 | 2767 | this.config.markupRules.www[1] += url + " "; |
1995 | | - |
1996 | | - // do the transformation |
| 2768 | + |
| 2769 | + // do the transformation |
1997 | 2770 | var markup = this.config.markupRules['www']; |
1998 | 2771 | var handler = markup[0]; |
1999 | 2772 | if (! this['markup_' + handler]) |
— | — | @@ -2000,7 +2773,7 @@ |
2001 | 2774 | this['markup_' + handler](markup); |
2002 | 2775 | |
2003 | 2776 | // reset |
2004 | | - this.config.markupRules.www[1] = old; |
| 2777 | + this.config.markupRules.www[1] = old; |
2005 | 2778 | } |
2006 | 2779 | |
2007 | 2780 | proto.selection_mangle = function(method) { |
— | — | @@ -2077,7 +2850,7 @@ |
2078 | 2851 | if (selection_start == null) { |
2079 | 2852 | selection_start = selection_end; |
2080 | 2853 | } |
2081 | | - |
| 2854 | + |
2082 | 2855 | var text = t.value; |
2083 | 2856 | this.selection_start = this.find_right(text, selection_start, /\r?\n/); |
2084 | 2857 | this.selection_end = this.selection_start; |
— | — | @@ -2106,18 +2879,36 @@ |
2107 | 2880 | this.list_type = []; |
2108 | 2881 | this.indent_level = 0; |
2109 | 2882 | this.no_collapse_text = false; |
2110 | | - |
| 2883 | + dom = this.fixChangedStructure (dom) ; |
2111 | 2884 | this.normalizeDomWhitespace(dom); |
2112 | 2885 | this.normalizeDomStructure(dom); |
2113 | | - |
2114 | 2886 | this.walk(dom); |
2115 | 2887 | |
2116 | 2888 | // add final whitespace |
2117 | 2889 | this.assert_new_line(); |
2118 | | - |
2119 | 2890 | return this.join_output(this.output); |
2120 | 2891 | } |
2121 | 2892 | |
| 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 | + |
2122 | 2913 | proto.normalizeDomStructure = function(dom) { |
2123 | 2914 | this.normalize_styled_blocks(dom, 'p'); |
2124 | 2915 | this.normalize_styled_lists(dom, 'ol'); |
— | — | @@ -2130,7 +2921,7 @@ |
2131 | 2922 | var grep = function(element) { |
2132 | 2923 | return Boolean(element.getAttribute('style')); |
2133 | 2924 | } |
2134 | | - |
| 2925 | + |
2135 | 2926 | var elements = this.array_elements_by_tag_name(dom, tag, grep); |
2136 | 2927 | for (var i = 0; i < elements.length; i++) { |
2137 | 2928 | var element = elements[i]; |
— | — | @@ -2175,7 +2966,7 @@ |
2176 | 2967 | |
2177 | 2968 | var items = element.getElementsByTagName('li'); |
2178 | 2969 | for (var j = 0; j < items.length; j++) { |
2179 | | - items[j].innerHTML = |
| 2970 | + items[j].innerHTML = |
2180 | 2971 | '<span style="' + style + '">' + items[j].innerHTML + '</span>'; |
2181 | 2972 | } |
2182 | 2973 | } |
— | — | @@ -2228,13 +3019,13 @@ |
2229 | 3020 | |
2230 | 3021 | if (first_node && first_node.nodeValue.match(/^ /)) { |
2231 | 3022 | first_node.nodeValue = first_node.nodeValue.replace(/^ +/, ''); |
2232 | | - if (prev_node && ! prev_node.nodeValue.match(/ $/)) |
| 3023 | + if (prev_node && ! prev_node.nodeValue.match(/ $/)) |
2233 | 3024 | prev_node.nodeValue = prev_node.nodeValue + ' '; |
2234 | 3025 | } |
2235 | 3026 | |
2236 | 3027 | if (last_node && last_node.nodeValue.match(/ $/)) { |
2237 | 3028 | last_node.nodeValue = last_node.nodeValue.replace(/ $/, ''); |
2238 | | - if (next_node && ! next_node.nodeValue.match(/^ /)) |
| 3029 | + if (next_node && ! next_node.nodeValue.match(/^ /)) |
2239 | 3030 | next_node.nodeValue = ' ' + next_node.nodeValue; |
2240 | 3031 | } |
2241 | 3032 | } |
— | — | @@ -2341,7 +3132,7 @@ |
2342 | 3133 | if (part.nodeValue.match(/[^\n]/) && |
2343 | 3134 | ! part.nodeValue.match(/^\n[\ \t]*$/) |
2344 | 3135 | ) { |
2345 | | - if (this.no_collapse_text) { |
| 3136 | + if (this.no_collapse_text) { |
2346 | 3137 | this.appendOutput(part.nodeValue); |
2347 | 3138 | } |
2348 | 3139 | else { |
— | — | @@ -2382,7 +3173,7 @@ |
2383 | 3174 | proto.format_big = proto.pass; |
2384 | 3175 | proto.format_blink = proto.pass; |
2385 | 3176 | proto.format_body = proto.pass; |
2386 | | -proto.format_br = proto.skip; |
| 3177 | +//proto.format_br = proto.skip; |
2387 | 3178 | proto.format_button = proto.skip; |
2388 | 3179 | proto.format_caption = proto.pass; |
2389 | 3180 | proto.format_center = proto.pass; |
— | — | @@ -2459,7 +3250,7 @@ |
2460 | 3251 | this.first_indent_line = true; |
2461 | 3252 | this.indent_level += indents; |
2462 | 3253 | |
2463 | | - this.output = defang_last_string(this.output); |
| 3254 | + this.output = defang_last_string (this.output) ; |
2464 | 3255 | this.assert_new_line(); |
2465 | 3256 | this.walk(element); |
2466 | 3257 | this.indent_level -= indents; |
— | — | @@ -2505,6 +3296,7 @@ |
2506 | 3297 | } |
2507 | 3298 | |
2508 | 3299 | proto.format_span = function(element) { |
| 3300 | + |
2509 | 3301 | if (this.is_opaque(element)) { |
2510 | 3302 | this.handle_opaque_phrase(element); |
2511 | 3303 | return; |
— | — | @@ -2515,7 +3307,6 @@ |
2516 | 3308 | this.pass(element); |
2517 | 3309 | return; |
2518 | 3310 | } |
2519 | | - |
2520 | 3311 | if ( ! this.element_has_text_content(element) |
2521 | 3312 | && ! this.element_has_only_image_content(element)) return; |
2522 | 3313 | var attributes = [ 'line-through', 'bold', 'italic', 'underline' ]; |
— | — | @@ -2610,14 +3401,20 @@ |
2611 | 3402 | proto.format_h6 = klass.make_formatter('h6'); |
2612 | 3403 | proto.format_pre = klass.make_formatter('pre'); |
2613 | 3404 | |
| 3405 | +proto.format_br = function (element) { |
| 3406 | + this.insert_new_line () ; |
| 3407 | + this.insert_new_line () ; |
| 3408 | +} |
| 3409 | + |
2614 | 3410 | proto.format_p = function(element) { |
2615 | 3411 | if (this.is_indented(element)) { |
2616 | 3412 | this.format_blockquote(element); |
2617 | 3413 | return; |
2618 | 3414 | } |
2619 | 3415 | this.assert_blank_line(); |
| 3416 | + this.assert_blank_line(); |
2620 | 3417 | this.walk(element); |
2621 | | - this.assert_blank_line(); |
| 3418 | +// this.assert_blank_line(); |
2622 | 3419 | } |
2623 | 3420 | |
2624 | 3421 | proto.format_a = function(element) { |
— | — | @@ -2626,7 +3423,13 @@ |
2627 | 3424 | label = label.replace(/\s+/g, ' '); |
2628 | 3425 | label = label.replace(/^\s+/, ''); |
2629 | 3426 | 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 | + } |
2631 | 3434 | if (! href) href = ''; // Necessary for <a name="xyz"></a>'s |
2632 | 3435 | this.make_wikitext_link(label, href, element); |
2633 | 3436 | } |
— | — | @@ -2685,7 +3488,7 @@ |
2686 | 3489 | ); |
2687 | 3490 | } |
2688 | 3491 | |
2689 | | -proto.make_list = function(element, list_type) { |
| 3492 | +proto.make_list = function(element, list_type) { |
2690 | 3493 | if (! this.previous_was_newline_or_start()) |
2691 | 3494 | this.insert_new_line(); |
2692 | 3495 | |
— | — | @@ -2910,7 +3713,7 @@ |
2911 | 3714 | var text = comment.data; |
2912 | 3715 | text = text.replace(/^ wiki:\s+/, '') |
2913 | 3716 | .replace(/-=/g, '-') |
2914 | | - .replace(/==/g, '=') |
| 3717 | + .replace(/==/g, '=') |
2915 | 3718 | .replace(/\s$/, '') |
2916 | 3719 | .replace(/\{(\w+):\s*\}/, '{$1}'); |
2917 | 3720 | this.appendOutput(Wikiwyg.htmlUnescape(text)) |
— | — | @@ -2951,13 +3754,12 @@ |
2952 | 3755 | proto.make_wikitext_link = function(label, href, element) { |
2953 | 3756 | var before = this.config.markupRules.link[1]; |
2954 | 3757 | var after = this.config.markupRules.link[2]; |
2955 | | - |
2956 | 3758 | // handle external links |
2957 | 3759 | if (this.looks_like_a_url(href)) { |
2958 | 3760 | before = this.config.markupRules.www[1]; |
2959 | 3761 | after = this.config.markupRules.www[2]; |
2960 | 3762 | } |
2961 | | - |
| 3763 | + |
2962 | 3764 | this.assert_space_or_newline(); |
2963 | 3765 | if (! href) { |
2964 | 3766 | this.appendOutput(label); |
— | — | @@ -2968,8 +3770,16 @@ |
2969 | 3771 | else if (this.href_is_wiki_link(href)) { |
2970 | 3772 | if (this.camel_case_link(label)) |
2971 | 3773 | 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 | + } |
2974 | 3784 | } |
2975 | 3785 | else { |
2976 | 3786 | this.appendOutput(before + href + ' ' + label + after); |
— | — | @@ -3025,13 +3835,19 @@ |
3026 | 3836 | |
3027 | 3837 | COPYRIGHT: |
3028 | 3838 | |
3029 | | - Copyright (c) 2005 Socialtext Corporation |
| 3839 | + Copyright (c) 2005 Socialtext Corporation |
3030 | 3840 | 655 High Street |
3031 | 3841 | Palo Alto, CA 94301 U.S.A. |
3032 | 3842 | All rights reserved. |
3033 | 3843 | |
3034 | | -Wikiwyg is free software. |
| 3844 | +CHANGES AUTHOR: |
3035 | 3845 | |
| 3846 | + Bartek Lapinski <bartek@wikia.com> |
| 3847 | + |
| 3848 | + Copyright (c) 2007, Wikia Inc. |
| 3849 | + |
| 3850 | +Wikiwyg is free software. |
| 3851 | + |
3036 | 3852 | This library is free software; you can redistribute it and/or modify it |
3037 | 3853 | under the terms of the GNU Lesser General Public License as published by |
3038 | 3854 | the Free Software Foundation; either version 2.1 of the License, or (at |
— | — | @@ -3049,7 +3865,7 @@ |
3050 | 3866 | proto = new Subclass('Wikiwyg.Wysiwyg', 'Wikiwyg.Mode'); |
3051 | 3867 | |
3052 | 3868 | proto.classtype = 'wysiwyg'; |
3053 | | -proto.modeDescription = 'Wysiwyg'; |
| 3869 | +proto.modeDescription = wgWysiwygCaption ; |
3054 | 3870 | |
3055 | 3871 | proto.config = { |
3056 | 3872 | useParentStyles: true, |
— | — | @@ -3057,11 +3873,12 @@ |
3058 | 3874 | iframeId: null, |
3059 | 3875 | iframeObject: null, |
3060 | 3876 | disabledToolbarButtons: [], |
3061 | | - editHeightMinimum: 150, |
| 3877 | + editHeightMinimum: 250, |
| 3878 | + overrideHeightMinimum: true , |
3062 | 3879 | editHeightAdjustment: 1.3, |
3063 | 3880 | clearRegex: null |
3064 | 3881 | }; |
3065 | | - |
| 3882 | + |
3066 | 3883 | proto.initializeObject = function() { |
3067 | 3884 | this.edit_iframe = this.get_edit_iframe(); |
3068 | 3885 | this.div = this.edit_iframe; |
— | — | @@ -3072,6 +3889,10 @@ |
3073 | 3890 | // Unneeded for Gecko |
3074 | 3891 | } |
3075 | 3892 | |
| 3893 | +proto.initHtml = function (html) { |
| 3894 | + this.fromHtml (html) ; |
| 3895 | +} |
| 3896 | + |
3076 | 3897 | proto.fromHtml = function(html) { |
3077 | 3898 | this.set_inner_html(this.sanitize_html(html)); |
3078 | 3899 | } |
— | — | @@ -3093,6 +3914,11 @@ |
3094 | 3915 | proto.enableThis = function() { |
3095 | 3916 | Wikiwyg.Mode.prototype.enableThis.call(this); |
3096 | 3917 | 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 | + } |
3097 | 3923 | this.edit_iframe.width = '100%'; |
3098 | 3924 | this.setHeightOf(this.edit_iframe); |
3099 | 3925 | this.fix_up_relative_imgs(); |
— | — | @@ -3100,6 +3926,28 @@ |
3101 | 3927 | this.apply_stylesheets(); |
3102 | 3928 | this.enable_keybindings(); |
3103 | 3929 | 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 | + } |
3104 | 3952 | } |
3105 | 3953 | |
3106 | 3954 | proto.clear_inner_html = function() { |
— | — | @@ -3167,15 +4015,15 @@ |
3168 | 4016 | // IMPORT_RULE |
3169 | 4017 | |
3170 | 4018 | /* 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 | + |
3173 | 4021 | this.apply_linked_stylesheet({ |
3174 | 4022 | href: style.cssRules[i].href, |
3175 | 4023 | type: 'text/css' |
3176 | 4024 | }, head); |
3177 | 4025 | */ |
3178 | | - |
3179 | | - style_string += Ajax.get(style.cssRules[i].href); |
| 4026 | + |
| 4027 | + style_string += WKWAjax.get(style.cssRules[i].href); |
3180 | 4028 | } else { |
3181 | 4029 | style_string += style.cssRules[i].cssText + "\n"; |
3182 | 4030 | } |
— | — | @@ -3243,8 +4091,14 @@ |
3244 | 4092 | this.exec_command('formatblock', '<' + command + '>'); |
3245 | 4093 | } |
3246 | 4094 | |
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 | + |
3249 | 4103 | proto.do_underline = proto.exec_command; |
3250 | 4104 | proto.do_strike = function() { |
3251 | 4105 | this.exec_command('strikethrough'); |
— | — | @@ -3255,6 +4109,11 @@ |
3256 | 4110 | proto.do_ordered = function() { |
3257 | 4111 | this.exec_command('insertorderedlist'); |
3258 | 4112 | } |
| 4113 | + |
| 4114 | +proto.do_timestamp = function () { |
| 4115 | + this.exec_command ('inserthtml', '~~~~') ; |
| 4116 | +} |
| 4117 | + |
3259 | 4118 | proto.do_unordered = function() { |
3260 | 4119 | this.exec_command('insertunorderedlist'); |
3261 | 4120 | } |
— | — | @@ -3293,13 +4152,18 @@ |
3294 | 4153 | var selection = this.get_link_selection_text(); |
3295 | 4154 | if (! selection) return; |
3296 | 4155 | 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+)(.*)/); |
3298 | 4162 | if (match) { |
3299 | 4163 | if (match[1] || match[3]) return null; |
3300 | 4164 | url = match[2]; |
3301 | 4165 | } |
3302 | 4166 | else { |
3303 | | - url = '?' + escape(selection); |
| 4167 | + url = '?' + escape(url); |
3304 | 4168 | } |
3305 | 4169 | this.exec_command('createlink', url); |
3306 | 4170 | } |
— | — | @@ -3307,7 +4171,7 @@ |
3308 | 4172 | proto.do_www = function() { |
3309 | 4173 | var selection = this.get_link_selection_text(); |
3310 | 4174 | 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://"); |
3312 | 4176 | this.exec_command('createlink', url); |
3313 | 4177 | } |
3314 | 4178 | } |
— | — | @@ -3371,13 +4235,19 @@ |
3372 | 4236 | |
3373 | 4237 | COPYRIGHT: |
3374 | 4238 | |
3375 | | - Copyright (c) 2005 Socialtext Corporation |
| 4239 | + Copyright (c) 2005 Socialtext Corporation |
3376 | 4240 | 655 High Street |
3377 | 4241 | Palo Alto, CA 94301 U.S.A. |
3378 | 4242 | All rights reserved. |
3379 | 4243 | |
3380 | | -Wikiwyg is free software. |
| 4244 | +CHANGES AUTHOR: |
3381 | 4245 | |
| 4246 | + Bartek Lapinski <bartek@wikia.com> |
| 4247 | + |
| 4248 | + Copyright (c) 2007, Wikia Inc. |
| 4249 | + |
| 4250 | +Wikiwyg is free software. |
| 4251 | + |
3382 | 4252 | This library is free software; you can redistribute it and/or modify it |
3383 | 4253 | under the terms of the GNU Lesser General Public License as published by |
3384 | 4254 | the Free Software Foundation; either version 2.1 of the License, or (at |
— | — | @@ -3413,9 +4283,13 @@ |
3414 | 4284 | proto.enableThis = function() { |
3415 | 4285 | Wikiwyg.Mode.prototype.enableThis.call(this); |
3416 | 4286 | this.textarea.style.width = '100%'; |
3417 | | - this.textarea.style.height = '200px'; |
| 4287 | + this.textarea.style.height = '300px'; |
3418 | 4288 | } |
3419 | 4289 | |
| 4290 | +proto.initHtml = function (html) { |
| 4291 | + this.fromHtml (html) ; |
| 4292 | +} |
| 4293 | + |
3420 | 4294 | proto.fromHtml = function(html) { |
3421 | 4295 | this.textarea.value = this.sanitize_html(html); |
3422 | 4296 | } |
— | — | @@ -3440,12 +4314,20 @@ |
3441 | 4315 | LivePreviewInstall = function() {}; |
3442 | 4316 | |
3443 | 4317 | function fixupRelativeUrl(url) { |
| 4318 | + return FixupRelativeUrl(url); |
| 4319 | +} |
| 4320 | + |
| 4321 | +function FixupRelativeUrl(url) { |
3444 | 4322 | var loc = String(location); |
| 4323 | + |
| 4324 | + if (wgArticlePath.match (/index\.php\?title=/) != '' ) { |
| 4325 | + url = url.replace (/index\.php\//, '?title=') ; |
| 4326 | + } |
3445 | 4327 | var base = loc.replace(/index\.php.*/, ''); |
3446 | 4328 | if (base == loc) |
3447 | 4329 | base = loc.replace(/(.*\/wiki\/).*/, '$1'); |
3448 | 4330 | if (base == loc) |
3449 | | - throw("fixupRelativeUrl error: " + loc); |
| 4331 | + throw ("fixupRelativeUrl error: " + loc); |
3450 | 4332 | return base + url; |
3451 | 4333 | } |
3452 | 4334 | |
— | — | @@ -3460,6 +4342,7 @@ |
3461 | 4343 | // Wikiwyg initialization/startup code |
3462 | 4344 | (function() { |
3463 | 4345 | addEvent("onload", function() {Wikiwyg.MediaWiki.initialize()}); |
| 4346 | + window.onbeforeunload = confirmExit ; |
3464 | 4347 | })(); |
3465 | 4348 | |
3466 | 4349 | //------------------------------------------------------------------------------ |
— | — | @@ -3471,41 +4354,22 @@ |
3472 | 4355 | klass.initialize = function() { |
3473 | 4356 | if (! Wikiwyg.browserIsSupported) return; |
3474 | 4357 | |
3475 | | - var wikiwyg_divs = grepElementsByTag('div', |
| 4358 | + var wikiwyg_divs = grepElementsByTag('span', |
3476 | 4359 | function(e) { return e.id.match(/^wikiwyg_section_\d+$/) } |
3477 | 4360 | ); |
3478 | 4361 | Wikiwyg.MediaWiki.wikiwyg_divs = wikiwyg_divs; |
3479 | 4362 | if (! Wikiwyg.MediaWiki.wikiwyg_enabled()) return; |
3480 | | - Wikiwyg.MediaWiki.enable(); |
3481 | 4363 | } |
3482 | 4364 | |
3483 | 4365 | klass.wikiwyg_enabled = function() { |
3484 | 4366 | 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 ; |
3498 | 4368 | var enabled = Cookie.get('wikiwyg_enabled'); |
3499 | 4369 | if (! enabled) enabled = "false"; |
3500 | 4370 | enabled = eval(enabled); |
3501 | 4371 | Cookie.set('wikiwyg_enabled', String(enabled)); |
| 4372 | + Wikiwyg.MediaWiki.enable (); |
3502 | 4373 | |
3503 | | - a.innerHTML = enabled |
3504 | | - ? 'Wikiwyg Enabled' |
3505 | | - : 'Wikiwyg Disabled'; |
3506 | | - a.onclick = enabled |
3507 | | - ? Wikiwyg.MediaWiki.disable |
3508 | | - : Wikiwyg.MediaWiki.enable; |
3509 | | - |
3510 | 4374 | return enabled; |
3511 | 4375 | } |
3512 | 4376 | |
— | — | @@ -3513,15 +4377,12 @@ |
3514 | 4378 | if (Wikiwyg.MediaWiki.busy) return false; |
3515 | 4379 | if (Wikiwyg.MediaWiki.checkEditInProgress()) return false; |
3516 | 4380 | Wikiwyg.MediaWiki.busy = true; |
3517 | | - a = document.getElementById('wikiwyg-enabler'); |
3518 | | - a.innerHTML = 'Wikiwyg Enabled'; |
3519 | | - a.onclick = Wikiwyg.MediaWiki.disable; |
3520 | 4381 | Cookie.set('wikiwyg_enabled', true); |
3521 | 4382 | // Code to actually enable Wikiwyg |
3522 | 4383 | var wikiwyg_divs = Wikiwyg.MediaWiki.wikiwyg_divs; |
3523 | 4384 | for (var i = 0; i < wikiwyg_divs.length; i++) { |
3524 | 4385 | var div = wikiwyg_divs[i]; |
3525 | | - var section_number = div.id.replace(/.*?(\d+)$/, '$1'); |
| 4386 | + var section_number = div.id.replace(/.*?(\d+)$/, '$1') ; |
3526 | 4387 | var success = Wikiwyg.MediaWiki.enable_wikiwyg_section( |
3527 | 4388 | div, section_number |
3528 | 4389 | ); |
— | — | @@ -3536,9 +4397,6 @@ |
3537 | 4398 | if (Wikiwyg.MediaWiki.busy) return false; |
3538 | 4399 | if (Wikiwyg.MediaWiki.checkEditInProgress()) return false; |
3539 | 4400 | Wikiwyg.MediaWiki.busy = true; |
3540 | | - a = document.getElementById('wikiwyg-enabler'); |
3541 | | - a.innerHTML = 'Wikiwyg Disabled'; |
3542 | | - a.onclick = Wikiwyg.MediaWiki.enable; |
3543 | 4401 | Cookie.set('wikiwyg_enabled', false); |
3544 | 4402 | // XXX Code to actually disable Wikiwyg |
3545 | 4403 | var wikiwyg_divs = Wikiwyg.MediaWiki.wikiwyg_divs; |
— | — | @@ -3567,21 +4425,21 @@ |
3568 | 4426 | doubleClickToEdit: true, |
3569 | 4427 | toolbarClass: 'Wikiwyg.Toolbar.MediaWiki', |
3570 | 4428 | toolbar: { |
3571 | | - imagesLocation: '/wikiwyg/share/MediaWiki/images/', |
| 4429 | + imagesLocation: wgScriptPath + '/extensions/wikiwyg/share/MediaWiki/images/', |
3572 | 4430 | imagesExtension: '.gif' |
3573 | 4431 | }, |
3574 | 4432 | wysiwyg: { |
3575 | 4433 | iframeId: 'wikiwyg_iframe_' + section_number |
3576 | 4434 | }, |
3577 | 4435 | modeClasses: [ |
3578 | | - 'Wikiwyg.Wysiwyg.MediaWiki', |
3579 | | - 'Wikiwyg.Wikitext.MediaWiki', |
| 4436 | + 'Wikiwyg.Wysiwyg.MediaWiki' , |
| 4437 | + 'Wikiwyg.Wikitext.MediaWiki' , |
3580 | 4438 | 'Wikiwyg.Preview.MediaWiki' |
3581 | 4439 | ] |
3582 | 4440 | } |
3583 | 4441 | |
3584 | 4442 | var hasWysiwyg = true; |
3585 | | - if (! klass.canSupportWysiwyg(section_div)) { |
| 4443 | + if (! klass.canSupportWysiwyg(section_div) || (wgUseWysiwyg == 0)) { |
3586 | 4444 | hasWysiwyg = false; |
3587 | 4445 | myConfig.modeClasses.shift(); |
3588 | 4446 | } |
— | — | @@ -3593,13 +4451,16 @@ |
3594 | 4452 | document.getElementById('wikiwyg_edit_' + section_number); |
3595 | 4453 | var edit_button = edit_button_span.getElementsByTagName('a')[0]; |
3596 | 4454 | |
3597 | | - edit_button.edit_button_text = hasWysiwyg |
3598 | | - ? 'Wikiwyg Edit' |
3599 | | - : 'Quick Edit'; |
| 4455 | + edit_button.edit_button_text = wgEditCaption ; |
3600 | 4456 | edit_button.innerHTML = edit_button.edit_button_text; |
3601 | 4457 | 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 | + } |
3604 | 4465 | } |
3605 | 4466 | Wikiwyg.MediaWiki.edit_buttons.push(edit_button); |
3606 | 4467 | |
— | — | @@ -3611,23 +4472,23 @@ |
3612 | 4473 | var edit_button_span = |
3613 | 4474 | document.getElementById('wikiwyg_edit_' + section_number); |
3614 | 4475 | var edit_button = edit_button_span.getElementsByTagName('a')[0]; |
3615 | | - |
3616 | | - edit_button.innerHTML = 'edit'; |
| 4476 | + edit_button.innerHTML = wgEditCaption ; |
3617 | 4477 | edit_button.onclick = null; |
3618 | 4478 | } |
3619 | 4479 | |
3620 | 4480 | klass.canSupportWysiwyg = function(div) { |
| 4481 | + /* now here the real fun begins */ |
3621 | 4482 | check_walk = function(elem) { |
3622 | 4483 | for (var part = elem.firstChild; part; part = part.nextSibling) { |
3623 | 4484 | if (part.nodeType == 1) { // element |
3624 | 4485 | 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)$/)) { |
3626 | 4487 | check_walk(part); |
3627 | 4488 | continue; |
3628 | 4489 | } |
3629 | 4490 | if (tag == 'SPAN') { |
3630 | 4491 | 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'))) { |
3632 | 4493 | check_walk(part); |
3633 | 4494 | continue; |
3634 | 4495 | } |
— | — | @@ -3640,22 +4501,55 @@ |
3641 | 4502 | } |
3642 | 4503 | } |
3643 | 4504 | } |
3644 | | - try {check_walk(div)} catch(e) {return false} |
| 4505 | +// return true ; |
| 4506 | + try {check_walk(div)} catch(e) { return false ; } |
3645 | 4507 | return true; |
3646 | 4508 | } |
3647 | 4509 | |
3648 | 4510 | 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 ; |
3649 | 4522 | 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 | + } |
3652 | 4531 | this.disableDoubleClicks(); |
3653 | 4532 | |
3654 | 4533 | 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 | + } |
3656 | 4550 | if ( modeName ) { |
3657 | | - this.first_mode = this.modeByName(modeName); |
| 4551 | + this.first_mode = this.modeByName(modeName) ; |
3658 | 4552 | } else { |
3659 | | - Cookie.set("WikiwygEditMode", this.first_mode.classname); |
| 4553 | + Cookie.set (cookieName, this.first_mode.classname) ; |
3660 | 4554 | } |
3661 | 4555 | // Fake click on mode radio. |
3662 | 4556 | var modeRadios = this.toolbarObject.div.getElementsByTagName("input"); |
— | — | @@ -3667,9 +4561,9 @@ |
3668 | 4562 | } |
3669 | 4563 | } |
3670 | 4564 | Wikiwyg.prototype.editMode.call(this); |
| 4565 | + needToConfirm = true ; |
3671 | 4566 | } |
3672 | 4567 | |
3673 | | - |
3674 | 4568 | proto.switchMode = function(new_mode_key) { |
3675 | 4569 | if ( Wikiwyg.MediaWiki.canSupportWysiwyg(this.div) ) { |
3676 | 4570 | if ( ! new_mode_key.match(/preview/i) ) { |
— | — | @@ -3677,53 +4571,134 @@ |
3678 | 4572 | } |
3679 | 4573 | } |
3680 | 4574 | var new_mode = this.modeByName(new_mode_key); |
| 4575 | + this.toolbarObject.changeMode () ; |
3681 | 4576 | Wikiwyg.prototype.switchMode.call(this, new_mode_key); |
3682 | 4577 | } |
3683 | 4578 | |
3684 | | - |
3685 | | -proto.disableEditButtons = function() { |
| 4579 | +proto.disableEditButtons = function(section_number) { |
3686 | 4580 | // Disable the main page button but save the old values |
3687 | 4581 | // 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 | + } |
3694 | 4590 | |
3695 | 4591 | var buttons = Wikiwyg.MediaWiki.edit_buttons; |
3696 | 4592 | for (var i = 0; i < buttons.length; i++) { |
3697 | 4593 | var button = buttons[i]; |
3698 | | - button.innerHTML = ''; |
| 4594 | + if ((i+1) == section_number) { |
| 4595 | + button.innerHTML = wgCancelCaption ; |
| 4596 | + button.parentNode.style.display = 'none' ; |
| 4597 | + } |
3699 | 4598 | } |
3700 | 4599 | } |
3701 | 4600 | |
| 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 | + |
3702 | 4617 | 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 ; |
3707 | 4627 | } |
3708 | 4628 | |
3709 | 4629 | proto.get_raw_section = function() { |
3710 | 4630 | 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 | | - "§ion=" + 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" + "§ion=" + this.section_number ; |
| 4638 | + } else { |
| 4639 | + url = wgServer + correctPath + encodeURI(wgPageName) + "?action=edit" + "§ion=" + this.section_number ; |
| 4640 | + } |
| 4641 | + } else { |
| 4642 | + correctPath = wgArticlePath.replace (/\?title=\$1/, '') ; |
| 4643 | + url = wgServer + correctPath + "?title=" + encodeURI(wgPageName) + "&action=edit" + "§ion=" + 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 | + "§ion=" + 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 | + |
3718 | 4690 | var raw_text = html.replace( |
3719 | 4691 | /[\s\S]*<textarea[^>]*?>([\s\S]*)<\/textarea>[\s\S]*/, |
3720 | 4692 | '$1' |
3721 | 4693 | ); |
| 4694 | + |
3722 | 4695 | raw_text = raw_text |
3723 | 4696 | .replace(/\</g, '<') |
3724 | 4697 | .replace(/\>/g, '>') |
3725 | | - .replace(/\&/g, '&'); |
| 4698 | + .replace(/\&/g, '&') |
| 4699 | + .replace(/\"/g,'"') ; |
| 4700 | + |
3726 | 4701 | 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 |
3728 | 4703 | // var sections = raw_text.match(/\n== [\s\S]*?(?=(\n== |$))/g); |
3729 | 4704 | // if (!sections) return; |
3730 | 4705 | // this.raw_section = sections[this.section_number - 1]. |
— | — | @@ -3731,7 +4706,7 @@ |
3732 | 4707 | } |
3733 | 4708 | |
3734 | 4709 | proto.disableDoubleClicks = function () { |
3735 | | - var wikiwyg_divs = grepElementsByTag('div', |
| 4710 | + var wikiwyg_divs = grepElementsByTag('span', |
3736 | 4711 | function(e) { return e.id.match(/^wikiwyg_section_\d+$/) } |
3737 | 4712 | ); |
3738 | 4713 | this.wikiwyg_divs_ondblclick = new Array(); |
— | — | @@ -3745,23 +4720,34 @@ |
3746 | 4721 | Wikiwyg.MediaWiki.editInProgress = false; |
3747 | 4722 | this.displayMode(); |
3748 | 4723 | 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 | + } |
3755 | 4731 | var buttons = Wikiwyg.MediaWiki.edit_buttons; |
3756 | 4732 | for (var i = 0; i < buttons.length; i++) { |
3757 | 4733 | var button = buttons[i]; |
3758 | 4734 | button.innerHTML = button.edit_button_text; |
| 4735 | + button.parentNode.style.display = 'inline' ; |
3759 | 4736 | } |
3760 | | - var wikiwyg_divs = grepElementsByTag('div', |
| 4737 | + var wikiwyg_divs = grepElementsByTag('span', |
3761 | 4738 | function(e) { return e.id.match(/^wikiwyg_section_\d+$/) } |
3762 | 4739 | ); |
3763 | 4740 | for ( var i = 0 ; i < wikiwyg_divs.length ; i++ ) { |
3764 | 4741 | wikiwyg_divs[i].ondblclick = this.wikiwyg_divs_ondblclick[i]; |
3765 | 4742 | } |
| 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 ; |
3766 | 4752 | } |
3767 | 4753 | |
3768 | 4754 | proto.get_page_title = function() { |
— | — | @@ -3771,11 +4757,10 @@ |
3772 | 4758 | // XXX This all seems so fragile and crufty... |
3773 | 4759 | proto.submit_action_form = function(action, value) { |
3774 | 4760 | var self = this; |
3775 | | - var page_title = this.get_page_title(); |
| 4761 | + var page_title = wgPageName ; |
3776 | 4762 | var url = fixupRelativeUrl( |
3777 | 4763 | 'index.php?title=' + page_title + '&action=edit§ion=' + this.section_number |
3778 | 4764 | ); |
3779 | | - |
3780 | 4765 | var tempIFrame=document.createElement('iframe'); |
3781 | 4766 | tempIFrame.setAttribute('id','RSIFrame'); |
3782 | 4767 | tempIFrame.style.height = "1px"; |
— | — | @@ -3809,46 +4794,87 @@ |
3810 | 4795 | ? IFrameObj.contentWindow.document |
3811 | 4796 | : IFrameObj.contentDocument; |
3812 | 4797 | 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 ; |
3813 | 4809 | form.submit(); |
3814 | 4810 | wait(function() { |
3815 | | - return (check_doc(IFrameDoc)) ? true : false; |
| 4811 | + // fix this up to *always* write |
| 4812 | + return (check_doc(IFrameDoc)) ? true : false; |
3816 | 4813 | },function() { |
3817 | 4814 | // Without remove tempIFrame here, the page scrolls down |
3818 | 4815 | // to the bottom, where the tempIFrame is located. |
3819 | | - document.body.removeChild(tempIFrame); |
| 4816 | + // document.body.removeChild(tempIFrame); |
| 4817 | + self.cancelEdit () ; |
3820 | 4818 | // XXX CrappyHack for save until we figure out how |
3821 | 4819 | // to submit without iframe. |
3822 | 4820 | setTimeout(function() { |
3823 | 4821 | // With this setTimeout it avoids page for being cached. |
3824 | 4822 | // Without this setTimeout the reloaded page is usually |
3825 | 4823 | // a cached one, weird. |
3826 | | - location.reload(); |
3827 | | - }, 1000); |
| 4824 | + document.body.removeChild(tempIFrame) ; |
| 4825 | + form.reset() ; |
| 4826 | + location.reload() ; |
| 4827 | + }, 400); |
3828 | 4828 | }); |
3829 | 4829 | } |
3830 | 4830 | wait(condition, callback); |
3831 | 4831 | } |
3832 | 4832 | |
| 4833 | +proto.imageUpload = function (tagOpen, tagClose, sampleText) { |
| 4834 | + Wikiwyg.prototype.imageUpload.call (this, tagOpen, tagClose, sampleText) ; |
| 4835 | +} |
| 4836 | + |
3833 | 4837 | 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 ; |
3835 | 4840 | 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 | + } |
3847 | 4873 | } |
3848 | 4874 | var self = this; |
3849 | 4875 | if (this.raw_section) { |
3850 | | - submit_changes(this.raw_section); |
| 4876 | +// submit_changes(this.raw_section); |
3851 | 4877 | } |
3852 | | - else if (this.current_mode.classname.match(/(Wysiwyg|Preview)/)) { |
| 4878 | + if (this.current_mode.classname.match(/(Wysiwyg|Preview)/)) { |
3853 | 4879 | this.current_mode.toHtml( |
3854 | 4880 | function(html) { |
3855 | 4881 | var wikitext_mode = self.mode_objects['Wikiwyg.Wikitext.MediaWiki']; |
— | — | @@ -3873,34 +4899,50 @@ |
3874 | 4900 | |
3875 | 4901 | proto.config = { |
3876 | 4902 | divId: null, |
3877 | | - imagesLocation: 'images/', |
3878 | | - imagesExtension: '.png', |
| 4903 | + imagesLocation: 'images/' , |
| 4904 | + imagesExtension: '.png' , |
3879 | 4905 | 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' |
3886 | 4923 | ], |
3887 | 4924 | 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 , |
3893 | 4932 | ordered: 'Numbered List', |
3894 | 4933 | unordered: 'Bulleted List', |
3895 | 4934 | indent: 'More Indented', |
3896 | 4935 | outdent: 'Less Indented', |
3897 | 4936 | label: '[Style]', |
3898 | | - p: 'Normal Text', |
| 4937 | + p: wgNowikiTip , |
3899 | 4938 | pre: 'Preformatted', |
3900 | 4939 | h1: 'Heading 1', |
3901 | 4940 | h2: 'Heading 2', |
3902 | 4941 | h3: 'Heading 3', |
3903 | 4942 | h4: 'Heading 4', |
3904 | | - link: 'Create Link', |
| 4943 | + timestamp : wgTimestampTip , |
| 4944 | + link: wgIntlinkTip , |
| 4945 | + www: wgExtlinkTip , |
| 4946 | + template: 'insert Template' , |
3905 | 4947 | table: 'Create Table' |
3906 | 4948 | } |
3907 | 4949 | }; |
— | — | @@ -3913,6 +4955,7 @@ |
3914 | 4956 | 'class': 'wikiwyg_button', |
3915 | 4957 | alt: label, |
3916 | 4958 | title: label, |
| 4959 | + id: 'wikiwyg_button_' + type + '_' + this.section_number , |
3917 | 4960 | src: base + type + ext |
3918 | 4961 | } |
3919 | 4962 | ); |
— | — | @@ -3930,14 +4973,15 @@ |
3931 | 4974 | with (this.toolbar_message) { |
3932 | 4975 | innerHTML = "Loading"; |
3933 | 4976 | style.textDecoration = "blink"; |
3934 | | - style.color = "red"; |
| 4977 | + style.color = "green"; |
3935 | 4978 | 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") |
3942 | 4986 | } |
3943 | 4987 | } |
3944 | 4988 | this.toolbar_message.style.display = "block"; |
— | — | @@ -3961,7 +5005,7 @@ |
3962 | 5006 | return buttons; |
3963 | 5007 | } |
3964 | 5008 | |
3965 | | -proto.disableButtons = function() { |
| 5009 | +proto.disableButtons = function (section_number) { |
3966 | 5010 | var buttons = this.getButtons(); |
3967 | 5011 | this.button_handlers = new Array(); |
3968 | 5012 | for ( var i = 0 ; i < buttons.length ; i++ ) { |
— | — | @@ -4001,16 +5045,64 @@ |
4002 | 5046 | this.wikiwyg.toolbarObject.disableMessage(); |
4003 | 5047 | } |
4004 | 5048 | |
| 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 | + |
4005 | 5087 | //------------------------------------------------------------------------------ |
4006 | 5088 | proto = new Subclass('Wikiwyg.Wikitext.MediaWiki', 'Wikiwyg.Wikitext'); |
4007 | 5089 | |
| 5090 | +proto.initHtml = function (html) { |
| 5091 | + this.fromHtml (html) ; |
| 5092 | +} |
| 5093 | + |
4008 | 5094 | 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); |
4015 | 5107 | } |
4016 | 5108 | |
4017 | 5109 | proto.toHtml = function(func) { |
— | — | @@ -4021,8 +5113,8 @@ |
4022 | 5114 | } |
4023 | 5115 | |
4024 | 5116 | 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, |
4027 | 5119 | "text=" + encodeURIComponent(wikitext), |
4028 | 5120 | func |
4029 | 5121 | ); |
— | — | @@ -4069,6 +5161,7 @@ |
4070 | 5162 | unordered: ['start_lines', '*'], |
4071 | 5163 | indent: ['start_lines', ''], |
4072 | 5164 | hr: ['line_alone', '----'], |
| 5165 | + timestamp: ['line_alone', '~~~~'] , |
4073 | 5166 | table: ['line_alone', '| A | B | C |\n| | | |\n| | | |'] |
4074 | 5167 | } |
4075 | 5168 | } |
— | — | @@ -4081,20 +5174,9 @@ |
4082 | 5175 | proto.enableFinished = function (){ |
4083 | 5176 | this.wikiwyg.toolbarObject.enableThis(); |
4084 | 5177 | this.wikiwyg.toolbarObject.disableMessage(); |
| 5178 | + this.textarea.style.height = '250px'; |
4085 | 5179 | } |
4086 | 5180 | |
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 | | - |
4099 | 5181 | proto.normalizeDomWhitespace = function(dom) { |
4100 | 5182 | Wikiwyg.Wikitext.prototype.normalizeDomWhitespace.call(this, dom); |
4101 | 5183 | var tags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'li']; |
— | — | @@ -4175,8 +5257,8 @@ |
4176 | 5258 | function(html) { |
4177 | 5259 | // Strip wrapper tags from ezparser. |
4178 | 5260 | 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,""); |
4181 | 5263 | Wikiwyg.Preview.prototype.fromHtml.call(self, html); |
4182 | 5264 | } |
4183 | 5265 | ) |
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 |
4184 | 5266 | + 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 |
4185 | 5267 | + 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 |
4186 | 5268 | + 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 |
4187 | 5269 | + 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 |
4188 | 5270 | + 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 |
4189 | 5271 | + 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 |
4190 | 5272 | + 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 |
4191 | 5273 | + 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 |
4192 | 5274 | + 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 |
4193 | 5275 | + 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 @@ |
286 | 286 | "?title=" + page_title + |
287 | 287 | "&action=edit" + |
288 | 288 | "§ion=" + this.section_number; |
289 | | - var html = Ajax.get(url); |
| 289 | + var html = WKWAjax.get(url); |
290 | 290 | var raw_text = html.replace( |
291 | 291 | /[\s\S]*<textarea[^>]*?>([\s\S]*)<\/textarea>[\s\S]*/, |
292 | 292 | '$1' |
— | — | @@ -504,12 +504,12 @@ |
505 | 505 | style.textDecoration = "blink"; |
506 | 506 | style.color = "red"; |
507 | 507 | 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") |
514 | 514 | } |
515 | 515 | } |
516 | 516 | this.toolbar_message.style.display = "block"; |
— | — | @@ -593,7 +593,7 @@ |
594 | 594 | } |
595 | 595 | |
596 | 596 | proto.convertWikitextToHtml = function(wikitext, func) { |
597 | | - Ajax.post( |
| 597 | + WKWAjax.post( |
598 | 598 | fixupRelativeUrl('index.php/Special:EZParser'), |
599 | 599 | "text=" + encodeURIComponent(wikitext), |
600 | 600 | func |
Index: trunk/extensions/wikiwyg/share/MediaWiki/css/MediaWikiwyg.css |
— | — | @@ -1,18 +1,18 @@ |
2 | 2 | .wikiwyg_toolbar { |
3 | | - background: #fff; |
4 | | - border: none; |
| 3 | + background: #F0F0EE none repeat scroll 0% ; |
| 4 | + border: 1px solid #DCDCDC ; |
5 | 5 | letter-spacing: 0; |
6 | | - padding:0; |
7 | | - margin: 5px 0; |
| 6 | + padding: 2px ; |
8 | 7 | } |
9 | 8 | |
10 | 9 | span.wikiwyg_control_link a { |
11 | | - padding-right: 8px; |
| 10 | + padding-right: 4px ; |
| 11 | + padding-left: 4px ; |
12 | 12 | } |
13 | 13 | |
14 | 14 | .wikiwyg_button { |
15 | | - background: #fff; |
16 | | - border: 1px solid #fff; |
| 15 | + background: #F0F0EE; |
| 16 | + border: 1px solid #F0F0EE; |
17 | 17 | cursor: pointer; |
18 | 18 | width: 20px; |
19 | 19 | height: 20px; |
— | — | @@ -28,8 +28,8 @@ |
29 | 29 | } |
30 | 30 | |
31 | 31 | .wikiwyg_button_disabled { |
32 | | - background: #fff; |
33 | | - border: 1px solid #fff; |
| 32 | + background: #F0F0EE; |
| 33 | + border: 1px solid #F0F0EE; |
34 | 34 | width: 20px; |
35 | 35 | height: 20px; |
36 | 36 | vertical-align: bottom; |
— | — | @@ -37,17 +37,22 @@ |
38 | 38 | } |
39 | 39 | |
40 | 40 | .wikiwyg_button_disabled:hover { |
41 | | - border: 1px solid #fff; |
| 41 | + border: 1px solid #F0F0EE; |
42 | 42 | } |
43 | 43 | |
44 | 44 | .wikiwyg_separator { |
45 | | - background: #fff; |
46 | | - border: 1px solid #fff; |
| 45 | + background: #F0F0EE; |
| 46 | + border: 1px solid #F0F0EE; |
47 | 47 | width: 9px; |
48 | 48 | height: 20px; |
49 | 49 | vertical-align: bottom; |
50 | 50 | } |
51 | 51 | |
| 52 | +.lower_tab .wikiwyg_separator { |
| 53 | + background: #fff; |
| 54 | + border: 1px solid #fff; |
| 55 | +} |
| 56 | + |
52 | 57 | .wikiwyg_selector { |
53 | 58 | width: 70px; |
54 | 59 | } |
— | — | @@ -63,3 +68,52 @@ |
64 | 69 | padding: .2em; |
65 | 70 | vertical-align: top; |
66 | 71 | } |
| 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( " |