748
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 1
// The "Dynano" Javascript framework. Similar in syntax to JQuery but highly Enano-specific (TinyMCE, etc).
1
+ − 2
+ − 3
var $ = function(id)
+ − 4
{
+ − 5
return new DNobj(id);
+ − 6
}
+ − 7
var $dynano = $;
+ − 8
function DNobj(id)
+ − 9
{
582
+ − 10
if ( id == undefined )
+ − 11
{
+ − 12
return {};
+ − 13
}
1
+ − 14
this.object = ( typeof(id) == 'object' ) ? id : document.getElementById(id);
29
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
diff
changeset
+ − 15
if ( !this.object )
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
diff
changeset
+ − 16
{
493
+ − 17
console.warn('Dynano: requested object is bad. id parameter follows.');
+ − 18
console.debug(id);
29
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
diff
changeset
+ − 19
this.object = false;
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
diff
changeset
+ − 20
return this;
e5484a9e0818
Rewrote change theme dialog; a few minor stability fixes here and there; fixed IE + St Patty background image
Dan
diff
changeset
+ − 21
}
748
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 22
if ( this.object.Dynano )
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 23
{
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 24
return this.object.Dynano;
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 25
}
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 26
this.object.Dynano = this;
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 27
1
+ − 28
this.height = __DNObjGetHeight(this.object);
+ − 29
this.width = __DNObjGetWidth(this.object);
+ − 30
588
+ − 31
if ( this.object.tagName == 'TEXTAREA' && ( typeof(tinyMCE) == 'object' || typeof(tinyMCE_GZ) == 'object' ) )
1
+ − 32
{
+ − 33
this.object.dnIsMCE = 'no';
+ − 34
this.switchToMCE = DN_switchToMCE;
+ − 35
this.destroyMCE = DN_destroyMCE;
+ − 36
this.getContent = DN_mceFetchContent;
413
6607cd646d6d
Added autosave functionality and resurrected the old toolbar code that was added about a year ago but never uesd.
Dan
diff
changeset
+ − 37
this.setContent = DN_mceSetContent;
748
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 38
this.makeSwitchable = DN_makeSwitchableTA;
832
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 39
this.isMCE = DN_isMCE;
1
+ − 40
}
+ − 41
}
+ − 42
function __DNObjGetHeight(o) {
+ − 43
return o.offsetHeight;
+ − 44
}
+ − 45
+ − 46
function __DNObjGetWidth(o) {
+ − 47
return o.offsetWidth;
+ − 48
}
+ − 49
+ − 50
function addClass(obj, clsname)
+ − 51
{
+ − 52
var cnt = obj.className;
+ − 53
var space = ( (cnt + '').length > 0 ) ? ' ' : '';
+ − 54
var cls = cnt + space + clsname;
+ − 55
obj.className = cls;
+ − 56
}
+ − 57
+ − 58
function rmClass(obj, clsname)
+ − 59
{
+ − 60
var cnt = obj.className;
+ − 61
if ( cnt == clsname )
+ − 62
{
+ − 63
obj.className = '';
+ − 64
}
+ − 65
else
+ − 66
{
+ − 67
cnt = cnt.replace(clsname, '');
+ − 68
cnt = trim(cnt);
+ − 69
obj.className = cnt;
+ − 70
}
+ − 71
}
+ − 72
+ − 73
function hasClass(obj, clsname)
+ − 74
{
+ − 75
var cnt = obj.className;
+ − 76
if ( !cnt )
+ − 77
return false;
+ − 78
if ( cnt == clsname )
+ − 79
return true;
+ − 80
cnt = cnt.split(' ');
+ − 81
+ − 82
for ( var i in cnt )
+ − 83
if ( cnt[i] == clsname )
+ − 84
return true;
+ − 85
+ − 86
return false;
+ − 87
}
+ − 88
function __DNObjGetLeft(obj) {
+ − 89
var left_offset = obj.offsetLeft;
+ − 90
while ((obj = obj.offsetParent) != null) {
+ − 91
left_offset += obj.offsetLeft;
+ − 92
}
+ − 93
return left_offset;
+ − 94
}
+ − 95
+ − 96
function __DNObjGetTop(obj) {
+ − 97
var left_offset = obj.offsetTop;
+ − 98
while ((obj = obj.offsetParent) != null) {
+ − 99
left_offset += obj.offsetTop;
+ − 100
}
+ − 101
return left_offset;
+ − 102
}
+ − 103
335
67bd3121a12e
Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
diff
changeset
+ − 104
function DN_switchToMCE(performWikiTransform)
1
+ − 105
{
+ − 106
if ( !this.object.id )
+ − 107
this.object.id = 'textarea_' + Math.floor(Math.random() * 1000000);
+ − 108
if ( !this.object.name )
+ − 109
this.object.name = 'textarea_' + Math.floor(Math.random() * 1000000);
474
+ − 110
// Updated for TinyMCE 3.x
335
67bd3121a12e
Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
diff
changeset
+ − 111
if ( performWikiTransform )
67bd3121a12e
Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
diff
changeset
+ − 112
{
67bd3121a12e
Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
diff
changeset
+ − 113
this.object.value = DN_WikitextToXHTML(this.object.value);
67bd3121a12e
Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
diff
changeset
+ − 114
}
474
+ − 115
// If tinyMCE init hasn't been called yet, do it now.
+ − 116
if ( !tinymce_initted )
+ − 117
{
699
c7d737202d59
Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
diff
changeset
+ − 118
console.info('$dynano().switchToMCE(): doing "exact"-type MCE init');
474
+ − 119
enano_tinymce_options.mode = 'exact';
493
+ − 120
enano_tinymce_options.elements = this.object.id;
474
+ − 121
initTinyMCE();
+ − 122
this.object.dnIsMCE = 'yes';
+ − 123
return true;
+ − 124
}
+ − 125
else
+ − 126
{
699
c7d737202d59
Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
diff
changeset
+ − 127
console.info('$dynano().switchToMCE(): tinyMCE already loaded, calling mceAddControl');
588
+ − 128
tinymce.EditorManager.execCommand("mceAddControl", true, this.object.id);
474
+ − 129
this.object.dnIsMCE = 'yes';
+ − 130
}
1
+ − 131
return this;
+ − 132
}
+ − 133
335
67bd3121a12e
Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
diff
changeset
+ − 134
function DN_destroyMCE(performWikiTransform)
1
+ − 135
{
+ − 136
//if ( !this.object.dn_is_mce )
+ − 137
// return this;
864
+ − 138
if ( this.object.id && window.tinymce )
335
67bd3121a12e
Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
diff
changeset
+ − 139
{
67bd3121a12e
Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
diff
changeset
+ − 140
// TinyMCE 2.x
588
+ − 141
// tinymce.EditorManager.removeMCEControl(this.object.name);
335
67bd3121a12e
Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
diff
changeset
+ − 142
// TinyMCE 3.x
588
+ − 143
var ed = tinymce.EditorManager.getInstanceById(this.object.id);
335
67bd3121a12e
Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
diff
changeset
+ − 144
if ( ed )
67bd3121a12e
Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
diff
changeset
+ − 145
{
588
+ − 146
if ( !tinymce.EditorManager.execCommand("mceRemoveEditor", false, this.object.id) )
335
67bd3121a12e
Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
diff
changeset
+ − 147
alert('could not destroy editor');
67bd3121a12e
Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
diff
changeset
+ − 148
if ( performWikiTransform )
67bd3121a12e
Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
diff
changeset
+ − 149
{
67bd3121a12e
Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
diff
changeset
+ − 150
this.object.value = DN_XHTMLToWikitext(this.object.value);
67bd3121a12e
Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
diff
changeset
+ − 151
}
67bd3121a12e
Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
diff
changeset
+ − 152
}
67bd3121a12e
Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
diff
changeset
+ − 153
}
1
+ − 154
this.object.dnIsMCE = 'no';
+ − 155
return this;
+ − 156
}
+ − 157
832
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 158
function DN_isMCE()
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 159
{
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 160
return ( this.object.dnIsMCE == 'yes' );
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 161
}
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 162
1
+ − 163
function DN_mceFetchContent()
+ − 164
{
+ − 165
if ( this.object.name )
+ − 166
{
+ − 167
var text = this.object.value;
588
+ − 168
if ( tinymce.EditorManager.get(this.object.id) )
335
67bd3121a12e
Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
diff
changeset
+ − 169
{
588
+ − 170
var editor = tinymce.EditorManager.get(this.object.id);
335
67bd3121a12e
Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
diff
changeset
+ − 171
text = editor.getContent();
67bd3121a12e
Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
diff
changeset
+ − 172
}
1
+ − 173
return text;
+ − 174
}
+ − 175
else
+ − 176
{
+ − 177
return this.object.value;
+ − 178
}
+ − 179
}
+ − 180
413
6607cd646d6d
Added autosave functionality and resurrected the old toolbar code that was added about a year ago but never uesd.
Dan
diff
changeset
+ − 181
function DN_mceSetContent(text)
6607cd646d6d
Added autosave functionality and resurrected the old toolbar code that was added about a year ago but never uesd.
Dan
diff
changeset
+ − 182
{
6607cd646d6d
Added autosave functionality and resurrected the old toolbar code that was added about a year ago but never uesd.
Dan
diff
changeset
+ − 183
if ( this.object.name )
6607cd646d6d
Added autosave functionality and resurrected the old toolbar code that was added about a year ago but never uesd.
Dan
diff
changeset
+ − 184
{
6607cd646d6d
Added autosave functionality and resurrected the old toolbar code that was added about a year ago but never uesd.
Dan
diff
changeset
+ − 185
this.object.value = text;
588
+ − 186
if ( tinymce.EditorManager.get(this.object.id) )
413
6607cd646d6d
Added autosave functionality and resurrected the old toolbar code that was added about a year ago but never uesd.
Dan
diff
changeset
+ − 187
{
588
+ − 188
var editor = tinymce.EditorManager.get(this.object.id);
413
6607cd646d6d
Added autosave functionality and resurrected the old toolbar code that was added about a year ago but never uesd.
Dan
diff
changeset
+ − 189
editor.setContent(text);
6607cd646d6d
Added autosave functionality and resurrected the old toolbar code that was added about a year ago but never uesd.
Dan
diff
changeset
+ − 190
}
6607cd646d6d
Added autosave functionality and resurrected the old toolbar code that was added about a year ago but never uesd.
Dan
diff
changeset
+ − 191
}
6607cd646d6d
Added autosave functionality and resurrected the old toolbar code that was added about a year ago but never uesd.
Dan
diff
changeset
+ − 192
else
6607cd646d6d
Added autosave functionality and resurrected the old toolbar code that was added about a year ago but never uesd.
Dan
diff
changeset
+ − 193
{
6607cd646d6d
Added autosave functionality and resurrected the old toolbar code that was added about a year ago but never uesd.
Dan
diff
changeset
+ − 194
this.object.value = text;
6607cd646d6d
Added autosave functionality and resurrected the old toolbar code that was added about a year ago but never uesd.
Dan
diff
changeset
+ − 195
}
6607cd646d6d
Added autosave functionality and resurrected the old toolbar code that was added about a year ago but never uesd.
Dan
diff
changeset
+ − 196
}
6607cd646d6d
Added autosave functionality and resurrected the old toolbar code that was added about a year ago but never uesd.
Dan
diff
changeset
+ − 197
748
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 198
var P_BOTTOM = 1;
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 199
var P_TOP = 2;
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 200
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 201
function DN_makeSwitchableTA(pos)
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 202
{
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 203
if ( this.toggler )
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 204
return false;
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 205
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 206
if ( !pos )
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 207
pos = P_BOTTOM;
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 208
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 209
load_component('l10n');
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 210
var cookiename = 'enano_editor_mode';
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 211
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 212
var toggler = document.createElement('div');
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 213
toggler.dynano = this;
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 214
this.toggler = toggler;
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 215
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 216
if ( !this.object.id )
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 217
this.object.id = 'dynano_auto_' + Math.floor(Math.random() * 1000000);
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 218
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 219
toggler.s_mode_text = $lang.get('editor_btn_wikitext');
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 220
toggler.s_mode_graphical = $lang.get('editor_btn_graphical');
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 221
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 222
toggler.set_text = function()
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 223
{
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 224
if ( this.dynano.object.dnIsMCE == 'yes' )
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 225
this.dynano.destroyMCE();
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 226
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 227
this.innerHTML = '';
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 228
this.appendChild(document.createTextNode(this.s_mode_text + ' | '));
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 229
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 230
var link = document.createElement('a');
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 231
link.href = '#';
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 232
link.onclick = function()
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 233
{
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 234
this.parentNode.set_graphical();
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 235
return false;
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 236
}
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 237
link.appendChild(document.createTextNode(this.s_mode_graphical));
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 238
this.appendChild(link);
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 239
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 240
createCookie('enano_editor_mode', 'text', 365);
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 241
}
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 242
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 243
toggler.set_graphical = function()
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 244
{
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 245
this.dynano.switchToMCE();
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 246
this.innerHTML = '';
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 247
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 248
var link = document.createElement('a');
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 249
link.href = '#';
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 250
link.onclick = function()
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 251
{
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 252
this.parentNode.set_text();
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 253
return false;
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 254
}
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 255
link.appendChild(document.createTextNode(this.s_mode_text));
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 256
this.appendChild(link);
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 257
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 258
this.appendChild(document.createTextNode(' | ' + this.s_mode_graphical));
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 259
createCookie('enano_editor_mode', 'tinymce', 365);
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 260
}
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 261
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 262
toggler.style.styleFloat = 'right';
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 263
toggler.style.cssFloat = 'right';
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 264
if ( pos == P_BOTTOM )
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 265
{
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 266
insertAfter(this.object.parentNode, toggler, this.object);
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 267
}
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 268
else
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 269
{
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 270
this.object.parentNode.insertBefore(toggler, this.object);
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 271
}
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 272
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 273
if ( readCookie(cookiename) == 'tinymce' )
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 274
{
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 275
toggler.set_graphical();
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 276
}
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 277
else
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 278
{
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 279
toggler.set_text();
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 280
}
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 281
}
e39454295bbb
Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
Dan
diff
changeset
+ − 282
335
67bd3121a12e
Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
diff
changeset
+ − 283
function DN_WikitextToXHTML(text)
67bd3121a12e
Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
diff
changeset
+ − 284
{
832
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 285
return DN_AjaxGetTransformedText(text, 'xhtml');
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 286
}
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 287
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 288
function DN_XHTMLToWikitext(text)
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 289
{
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 290
return DN_AjaxGetTransformedText(text, 'wikitext');
335
67bd3121a12e
Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
diff
changeset
+ − 291
}
67bd3121a12e
Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
diff
changeset
+ − 292
832
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 293
// AJAX to the server to transform text
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 294
function DN_AjaxGetTransformedText(text, to)
335
67bd3121a12e
Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
diff
changeset
+ − 295
{
832
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 296
// get an XHR instance
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 297
var ajax = ajaxMakeXHR();
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 298
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 299
var uri = stdAjaxPrefix + '&_mode=transform&to=' + to;
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 300
var parms = 'text=' + ajaxEscape(text);
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 301
try
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 302
{
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 303
ajax.open('POST', uri, false);
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 304
ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 305
// Setting Content-length in Safari triggers a warning
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 306
if ( !is_Safari )
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 307
{
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 308
ajax.setRequestHeader("Content-length", parms.length);
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 309
}
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 310
ajax.send(parms);
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 311
// async request, so if status != 200 at this point then we're screwed
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 312
if ( ajax.readyState == 4 && ajax.status == 200 )
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 313
{
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 314
var response = String(ajax.responseText + '');
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 315
if ( !check_json_response(response) )
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 316
{
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 317
handle_invalid_json(response);
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 318
return text;
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 319
}
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 320
response = parseJSON(response);
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 321
if ( response.mode == 'error' )
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 322
{
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 323
alert(response.error);
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 324
return text;
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 325
}
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 326
return response.text;
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 327
}
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 328
}
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 329
catch(e)
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 330
{
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 331
console.warn('DN_AjaxGetTransformedText: XHR failed');
7152ca0a0ce9
Major redesign of rendering pipeline that separates pages saved with MCE from pages saved with the plaintext editor (full description in long commit message)
Dan
diff
changeset
+ − 332
}
335
67bd3121a12e
Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
diff
changeset
+ − 333
return text;
67bd3121a12e
Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
diff
changeset
+ − 334
}
67bd3121a12e
Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
diff
changeset
+ − 335
1
+ − 336
DNobj.prototype.addClass = function(clsname) { addClass(this.object, clsname); return this; };
+ − 337
DNobj.prototype.rmClass = function(clsname) { rmClass( this.object, clsname); return this; };
+ − 338
DNobj.prototype.hasClass = function(clsname) { return hasClass(this.object, clsname); };
+ − 339
DNobj.prototype.Height = function() { return __DNObjGetHeight(this.object); }
+ − 340
DNobj.prototype.Width = function() { return __DNObjGetWidth( this.object); }
+ − 341
DNobj.prototype.Left = function() { /* return this.object.offsetLeft; */ return __DNObjGetLeft(this.object); }
+ − 342
DNobj.prototype.Top = function() { /* return this.object.offsetTop; */ return __DNObjGetTop( this.object); }
+ − 343