| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | |
|---|
| 23 | |
|---|
| 24 | |
|---|
| 25 | |
|---|
| 26 | |
|---|
| 27 | |
|---|
| 28 | |
|---|
| 29 | |
|---|
| 30 | |
|---|
| 31 | Xinha.version = |
|---|
| 32 | { |
|---|
| 33 | 'Release' : 'Trunk', |
|---|
| 34 | 'Head' : '$HeadURL$'.replace(/^[^:]*:\s*(.*)\s*\$$/, '$1'), |
|---|
| 35 | 'Date' : '$LastChangedDate$'.replace(/^[^:]*:\s*([0-9\-]*) ([0-9:]*) ([+0-9]*) \((.*)\)\s*\$/, '$4 $2 $3'), |
|---|
| 36 | 'Revision' : '$LastChangedRevision$'.replace(/^[^:]*:\s*(.*)\s*\$$/, '$1'), |
|---|
| 37 | 'RevisionBy': '$LastChangedBy$'.replace(/^[^:]*:\s*(.*)\s*\$$/, '$1') |
|---|
| 38 | }; |
|---|
| 39 | |
|---|
| 40 | |
|---|
| 41 | Xinha._resolveRelativeUrl = function( base, url ) |
|---|
| 42 | { |
|---|
| 43 | if(url.match(/^([^:]+\:)?\/\ |
|---|
| 44 | { |
|---|
| 45 | return url; |
|---|
| 46 | } |
|---|
| 47 | else |
|---|
| 48 | { |
|---|
| 49 | var b = base.split("/"); |
|---|
| 50 | if(b[b.length - 1] === "") |
|---|
| 51 | { |
|---|
| 52 | b.pop(); |
|---|
| 53 | } |
|---|
| 54 | var p = url.split("/"); |
|---|
| 55 | if(p[0] == ".") |
|---|
| 56 | { |
|---|
| 57 | p.shift(); |
|---|
| 58 | } |
|---|
| 59 | while(p[0] == "..") |
|---|
| 60 | { |
|---|
| 61 | b.pop(); |
|---|
| 62 | p.shift(); |
|---|
| 63 | } |
|---|
| 64 | return b.join("/") + "/" + p.join("/"); |
|---|
| 65 | } |
|---|
| 66 | }; |
|---|
| 67 | |
|---|
| 68 | if ( typeof _editor_url == "string" ) |
|---|
| 69 | { |
|---|
| 70 | |
|---|
| 71 | _editor_url = _editor_url.replace(/\x2f*$/, '/'); |
|---|
| 72 | |
|---|
| 73 | |
|---|
| 74 | if(!_editor_url.match(/^([^:]+\:)?\ |
|---|
| 75 | { |
|---|
| 76 | (function() |
|---|
| 77 | { |
|---|
| 78 | var tmpPath = window.location.toString().replace(/\?.*$/,'').split("/"); |
|---|
| 79 | tmpPath.pop(); |
|---|
| 80 | _editor_url = Xinha._resolveRelativeUrl(tmpPath.join("/"), _editor_url); |
|---|
| 81 | })(); |
|---|
| 82 | } |
|---|
| 83 | } |
|---|
| 84 | else |
|---|
| 85 | { |
|---|
| 86 | alert("WARNING: _editor_url is not set! You should set this variable to the editor files path; it should preferably be an absolute path, like in '/xinha/', but it can be relative if you prefer. Further we will try to load the editor files correctly but we'll probably fail."); |
|---|
| 87 | _editor_url = ''; |
|---|
| 88 | } |
|---|
| 89 | |
|---|
| 90 | |
|---|
| 91 | if ( typeof _editor_lang == "string" ) |
|---|
| 92 | { |
|---|
| 93 | _editor_lang = _editor_lang.toLowerCase(); |
|---|
| 94 | } |
|---|
| 95 | else |
|---|
| 96 | { |
|---|
| 97 | _editor_lang = "en"; |
|---|
| 98 | } |
|---|
| 99 | |
|---|
| 100 | |
|---|
| 101 | if ( typeof _editor_skin !== "string" ) |
|---|
| 102 | { |
|---|
| 103 | _editor_skin = ""; |
|---|
| 104 | } |
|---|
| 105 | |
|---|
| 106 | if ( typeof _editor_icons !== "string" ) |
|---|
| 107 | { |
|---|
| 108 | _editor_icons = ""; |
|---|
| 109 | } |
|---|
| 110 | |
|---|
| 111 | |
|---|
| 112 | |
|---|
| 113 | |
|---|
| 114 | |
|---|
| 115 | |
|---|
| 116 | |
|---|
| 117 | |
|---|
| 118 | |
|---|
| 119 | var __xinhas = []; |
|---|
| 120 | |
|---|
| 121 | |
|---|
| 122 | |
|---|
| 123 | |
|---|
| 124 | |
|---|
| 125 | |
|---|
| 126 | Xinha.agt = navigator.userAgent.toLowerCase(); |
|---|
| 127 | |
|---|
| 128 | |
|---|
| 129 | |
|---|
| 130 | Xinha.is_ie = ((Xinha.agt.indexOf("msie") != -1) && (Xinha.agt.indexOf("opera") == -1)); |
|---|
| 131 | |
|---|
| 132 | |
|---|
| 133 | |
|---|
| 134 | Xinha.ie_version= parseFloat(Xinha.agt.substring(Xinha.agt.indexOf("msie")+5)); |
|---|
| 135 | |
|---|
| 136 | |
|---|
| 137 | |
|---|
| 138 | Xinha.is_opera = (Xinha.agt.indexOf("opera") != -1); |
|---|
| 139 | |
|---|
| 140 | |
|---|
| 141 | |
|---|
| 142 | if(Xinha.is_opera && Xinha.agt.match(/opera[\/ ]([0-9.]+)/)) |
|---|
| 143 | { |
|---|
| 144 | Xinha.opera_version = parseFloat(RegExp.$1); |
|---|
| 145 | } |
|---|
| 146 | else |
|---|
| 147 | { |
|---|
| 148 | Xinha.opera_version = 0; |
|---|
| 149 | } |
|---|
| 150 | |
|---|
| 151 | |
|---|
| 152 | |
|---|
| 153 | Xinha.is_khtml = (Xinha.agt.indexOf("khtml") != -1); |
|---|
| 154 | |
|---|
| 155 | |
|---|
| 156 | |
|---|
| 157 | Xinha.is_webkit = (Xinha.agt.indexOf("applewebkit") != -1); |
|---|
| 158 | |
|---|
| 159 | |
|---|
| 160 | |
|---|
| 161 | Xinha.webkit_version = parseInt(navigator.appVersion.replace(/.*?AppleWebKit\/([\d]).*?/,'$1'), 10); |
|---|
| 162 | |
|---|
| 163 | |
|---|
| 164 | |
|---|
| 165 | |
|---|
| 166 | Xinha.is_safari = (Xinha.agt.indexOf("safari") != -1); |
|---|
| 167 | |
|---|
| 168 | |
|---|
| 169 | |
|---|
| 170 | |
|---|
| 171 | Xinha.is_chrome = (Xinha.agt.indexOf("chrome") != -1); |
|---|
| 172 | |
|---|
| 173 | |
|---|
| 174 | |
|---|
| 175 | |
|---|
| 176 | Xinha.is_mac = (Xinha.agt.indexOf("mac") != -1); |
|---|
| 177 | |
|---|
| 178 | |
|---|
| 179 | |
|---|
| 180 | Xinha.is_mac_ie = (Xinha.is_ie && Xinha.is_mac); |
|---|
| 181 | |
|---|
| 182 | |
|---|
| 183 | |
|---|
| 184 | Xinha.is_win_ie = (Xinha.is_ie && !Xinha.is_mac); |
|---|
| 185 | |
|---|
| 186 | |
|---|
| 187 | |
|---|
| 188 | |
|---|
| 189 | Xinha.is_gecko = (navigator.product == "Gecko") || Xinha.is_opera; |
|---|
| 190 | |
|---|
| 191 | |
|---|
| 192 | |
|---|
| 193 | Xinha.is_real_gecko = (navigator.product == "Gecko" && !Xinha.is_webkit); |
|---|
| 194 | |
|---|
| 195 | |
|---|
| 196 | |
|---|
| 197 | |
|---|
| 198 | Xinha.is_ff2 = Xinha.is_real_gecko && parseInt(navigator.productSub.substr(0,10), 10) < 20071210; |
|---|
| 199 | |
|---|
| 200 | |
|---|
| 201 | |
|---|
| 202 | |
|---|
| 203 | |
|---|
| 204 | Xinha.isRunLocally = document.URL.toLowerCase().search(/^file:/) != -1; |
|---|
| 205 | |
|---|
| 206 | |
|---|
| 207 | |
|---|
| 208 | |
|---|
| 209 | Xinha.is_designMode = (typeof document.designMode != 'undefined' && !Xinha.is_ie); |
|---|
| 210 | |
|---|
| 211 | |
|---|
| 212 | |
|---|
| 213 | |
|---|
| 214 | |
|---|
| 215 | Xinha.checkSupportedBrowser = function() |
|---|
| 216 | { |
|---|
| 217 | return Xinha.is_real_gecko || (Xinha.is_opera && Xinha.opera_version >= 9.2) || Xinha.ie_version >= 5.5 || Xinha.webkit_version >= 522; |
|---|
| 218 | }; |
|---|
| 219 | |
|---|
| 220 | |
|---|
| 221 | |
|---|
| 222 | |
|---|
| 223 | Xinha.isSupportedBrowser = Xinha.checkSupportedBrowser(); |
|---|
| 224 | |
|---|
| 225 | if ( Xinha.isRunLocally && Xinha.isSupportedBrowser) |
|---|
| 226 | { |
|---|
| 227 | alert('Xinha *must* be installed on a web server. Locally opened files (those that use the "file://" protocol) cannot properly function. Xinha will try to initialize but may not be correctly loaded.'); |
|---|
| 228 | } |
|---|
| 229 | |
|---|
| 230 | |
|---|
| 231 | |
|---|
| 232 | |
|---|
| 233 | |
|---|
| 234 | |
|---|
| 235 | |
|---|
| 236 | function Xinha(textarea, config) |
|---|
| 237 | { |
|---|
| 238 | if ( !Xinha.isSupportedBrowser ) |
|---|
| 239 | { |
|---|
| 240 | return; |
|---|
| 241 | } |
|---|
| 242 | |
|---|
| 243 | if ( !textarea ) |
|---|
| 244 | { |
|---|
| 245 | throw new Error ("Tried to create Xinha without textarea specified."); |
|---|
| 246 | } |
|---|
| 247 | |
|---|
| 248 | if ( typeof config == "undefined" ) |
|---|
| 249 | { |
|---|
| 250 | |
|---|
| 251 | |
|---|
| 252 | |
|---|
| 253 | this.config = new Xinha.Config(); |
|---|
| 254 | } |
|---|
| 255 | else |
|---|
| 256 | { |
|---|
| 257 | this.config = config; |
|---|
| 258 | } |
|---|
| 259 | |
|---|
| 260 | if ( typeof textarea != 'object' ) |
|---|
| 261 | { |
|---|
| 262 | textarea = Xinha.getElementById('textarea', textarea); |
|---|
| 263 | } |
|---|
| 264 | |
|---|
| 265 | |
|---|
| 266 | |
|---|
| 267 | this._textArea = textarea; |
|---|
| 268 | this._textArea.spellcheck = false; |
|---|
| 269 | Xinha.freeLater(this, '_textArea'); |
|---|
| 270 | |
|---|
| 271 | |
|---|
| 272 | |
|---|
| 273 | |
|---|
| 274 | |
|---|
| 275 | |
|---|
| 276 | this._initial_ta_size = |
|---|
| 277 | { |
|---|
| 278 | w: textarea.style.width ? textarea.style.width : ( textarea.offsetWidth ? ( textarea.offsetWidth + 'px' ) : ( textarea.cols + 'em') ), |
|---|
| 279 | h: textarea.style.height ? textarea.style.height : ( textarea.offsetHeight ? ( textarea.offsetHeight + 'px' ) : ( textarea.rows + 'em') ) |
|---|
| 280 | }; |
|---|
| 281 | |
|---|
| 282 | if ( document.getElementById("loading_" + textarea.id) || this.config.showLoading ) |
|---|
| 283 | { |
|---|
| 284 | if (!document.getElementById("loading_" + textarea.id)) |
|---|
| 285 | { |
|---|
| 286 | Xinha.createLoadingMessage(textarea); |
|---|
| 287 | } |
|---|
| 288 | this.setLoadingMessage(Xinha._lc("Constructing object")); |
|---|
| 289 | } |
|---|
| 290 | |
|---|
| 291 | |
|---|
| 292 | |
|---|
| 293 | |
|---|
| 294 | |
|---|
| 295 | this._editMode = "wysiwyg"; |
|---|
| 296 | |
|---|
| 297 | |
|---|
| 298 | |
|---|
| 299 | |
|---|
| 300 | this.plugins = {}; |
|---|
| 301 | |
|---|
| 302 | |
|---|
| 303 | |
|---|
| 304 | |
|---|
| 305 | this._timerToolbar = null; |
|---|
| 306 | |
|---|
| 307 | |
|---|
| 308 | |
|---|
| 309 | |
|---|
| 310 | this._timerUndo = null; |
|---|
| 311 | |
|---|
| 312 | |
|---|
| 313 | |
|---|
| 314 | |
|---|
| 315 | this._undoQueue = [this.config.undoSteps]; |
|---|
| 316 | |
|---|
| 317 | |
|---|
| 318 | |
|---|
| 319 | |
|---|
| 320 | this._undoPos = -1; |
|---|
| 321 | |
|---|
| 322 | |
|---|
| 323 | |
|---|
| 324 | |
|---|
| 325 | this._customUndo = true; |
|---|
| 326 | |
|---|
| 327 | |
|---|
| 328 | |
|---|
| 329 | |
|---|
| 330 | this._mdoc = document; |
|---|
| 331 | |
|---|
| 332 | |
|---|
| 333 | |
|---|
| 334 | |
|---|
| 335 | this.doctype = ''; |
|---|
| 336 | |
|---|
| 337 | |
|---|
| 338 | |
|---|
| 339 | |
|---|
| 340 | this.__htmlarea_id_num = __xinhas.length; |
|---|
| 341 | __xinhas[this.__htmlarea_id_num] = this; |
|---|
| 342 | |
|---|
| 343 | |
|---|
| 344 | |
|---|
| 345 | |
|---|
| 346 | |
|---|
| 347 | this._notifyListeners = {}; |
|---|
| 348 | |
|---|
| 349 | |
|---|
| 350 | var panels = |
|---|
| 351 | { |
|---|
| 352 | right: |
|---|
| 353 | { |
|---|
| 354 | on: true, |
|---|
| 355 | container: document.createElement('td'), |
|---|
| 356 | panels: [] |
|---|
| 357 | }, |
|---|
| 358 | left: |
|---|
| 359 | { |
|---|
| 360 | on: true, |
|---|
| 361 | container: document.createElement('td'), |
|---|
| 362 | panels: [] |
|---|
| 363 | }, |
|---|
| 364 | top: |
|---|
| 365 | { |
|---|
| 366 | on: true, |
|---|
| 367 | container: document.createElement('td'), |
|---|
| 368 | panels: [] |
|---|
| 369 | }, |
|---|
| 370 | bottom: |
|---|
| 371 | { |
|---|
| 372 | on: true, |
|---|
| 373 | container: document.createElement('td'), |
|---|
| 374 | panels: [] |
|---|
| 375 | } |
|---|
| 376 | }; |
|---|
| 377 | |
|---|
| 378 | for ( var i in panels ) |
|---|
| 379 | { |
|---|
| 380 | if(!panels[i].container) { continue; } |
|---|
| 381 | panels[i].div = panels[i].container; |
|---|
| 382 | panels[i].container.className = 'panels panels_' + i; |
|---|
| 383 | Xinha.freeLater(panels[i], 'container'); |
|---|
| 384 | Xinha.freeLater(panels[i], 'div'); |
|---|
| 385 | } |
|---|
| 386 | |
|---|
| 387 | |
|---|
| 388 | |
|---|
| 389 | |
|---|
| 390 | |
|---|
| 391 | this._panels = panels; |
|---|
| 392 | |
|---|
| 393 | |
|---|
| 394 | |
|---|
| 395 | |
|---|
| 396 | |
|---|
| 397 | this._statusBar = null; |
|---|
| 398 | |
|---|
| 399 | |
|---|
| 400 | |
|---|
| 401 | |
|---|
| 402 | this._statusBarTree = null; |
|---|
| 403 | |
|---|
| 404 | |
|---|
| 405 | |
|---|
| 406 | |
|---|
| 407 | this._statusBarTextMode = null; |
|---|
| 408 | |
|---|
| 409 | |
|---|
| 410 | |
|---|
| 411 | |
|---|
| 412 | this._statusBarItems = []; |
|---|
| 413 | |
|---|
| 414 | |
|---|
| 415 | |
|---|
| 416 | |
|---|
| 417 | this._framework = {}; |
|---|
| 418 | |
|---|
| 419 | |
|---|
| 420 | |
|---|
| 421 | |
|---|
| 422 | this._htmlArea = null; |
|---|
| 423 | |
|---|
| 424 | |
|---|
| 425 | |
|---|
| 426 | |
|---|
| 427 | |
|---|
| 428 | |
|---|
| 429 | this._iframe = null; |
|---|
| 430 | |
|---|
| 431 | |
|---|
| 432 | |
|---|
| 433 | |
|---|
| 434 | this._doc = null; |
|---|
| 435 | |
|---|
| 436 | |
|---|
| 437 | |
|---|
| 438 | |
|---|
| 439 | this._toolBar = this._toolbar = null; |
|---|
| 440 | |
|---|
| 441 | |
|---|
| 442 | |
|---|
| 443 | |
|---|
| 444 | this._toolbarObjects = {}; |
|---|
| 445 | |
|---|
| 446 | |
|---|
| 447 | this.plugins.Events = |
|---|
| 448 | { |
|---|
| 449 | name: 'Events', |
|---|
| 450 | developer : 'The Xinha Core Developer Team', |
|---|
| 451 | instance: config.Events |
|---|
| 452 | }; |
|---|
| 453 | }; |
|---|
| 454 | |
|---|
| 455 | Xinha.onload = function() { }; |
|---|
| 456 | Xinha.init = function() { Xinha.onload(); }; |
|---|
| 457 | |
|---|
| 458 | |
|---|
| 459 | |
|---|
| 460 | |
|---|
| 461 | |
|---|
| 462 | Xinha.RE_tagName = /(<\/|<)\s*([^ \t\n>]+)/ig; |
|---|
| 463 | |
|---|
| 464 | |
|---|
| 465 | |
|---|
| 466 | Xinha.RE_doctype = /(<!doctype((.|\n)*?)>)\n?/i; |
|---|
| 467 | |
|---|
| 468 | |
|---|
| 469 | |
|---|
| 470 | Xinha.RE_head = /<head>((.|\n)*?)<\/head>/i; |
|---|
| 471 | |
|---|
| 472 | |
|---|
| 473 | |
|---|
| 474 | Xinha.RE_body = /<body[^>]*>((.|\n|\r|\t)*?)<\/body>/i; |
|---|
| 475 | |
|---|
| 476 | |
|---|
| 477 | |
|---|
| 478 | |
|---|
| 479 | Xinha.RE_Specials = /([\/\^$*+?.()|{}\[\]])/g; |
|---|
| 480 | |
|---|
| 481 | |
|---|
| 482 | |
|---|
| 483 | |
|---|
| 484 | |
|---|
| 485 | Xinha.escapeStringForRegExp = function (string) |
|---|
| 486 | { |
|---|
| 487 | return string.replace(Xinha.RE_Specials, '\\$1'); |
|---|
| 488 | }; |
|---|
| 489 | |
|---|
| 490 | |
|---|
| 491 | |
|---|
| 492 | Xinha.RE_email = /^[_a-z\d\-\.]{3,}@[_a-z\d\-]{2,}(\.[_a-z\d\-]{2,})+$/i; |
|---|
| 493 | |
|---|
| 494 | |
|---|
| 495 | |
|---|
| 496 | Xinha.RE_url = /(https?:\/\/)?(([a-z0-9_]+:[a-z0-9_]+@)?[a-z0-9_\-]{2,}(\.[a-z0-9_\-]{2,}){2,}(:[0-9]+)?(\/\S+)*)/i; |
|---|
| 497 | |
|---|
| 498 | |
|---|
| 499 | |
|---|
| 500 | |
|---|
| 501 | |
|---|
| 502 | |
|---|
| 503 | |
|---|
| 504 | |
|---|
| 505 | |
|---|
| 506 | Xinha.Config = function() |
|---|
| 507 | { |
|---|
| 508 | |
|---|
| 509 | |
|---|
| 510 | |
|---|
| 511 | this.version = Xinha.version.Revision; |
|---|
| 512 | |
|---|
| 513 | |
|---|
| 514 | |
|---|
| 515 | |
|---|
| 516 | |
|---|
| 517 | |
|---|
| 518 | |
|---|
| 519 | |
|---|
| 520 | |
|---|
| 521 | |
|---|
| 522 | this.width = "auto"; |
|---|
| 523 | |
|---|
| 524 | |
|---|
| 525 | |
|---|
| 526 | |
|---|
| 527 | |
|---|
| 528 | |
|---|
| 529 | |
|---|
| 530 | this.height = "auto"; |
|---|
| 531 | |
|---|
| 532 | |
|---|
| 533 | |
|---|
| 534 | |
|---|
| 535 | |
|---|
| 536 | |
|---|
| 537 | |
|---|
| 538 | |
|---|
| 539 | |
|---|
| 540 | this.sizeIncludesBars = true; |
|---|
| 541 | |
|---|
| 542 | |
|---|
| 543 | |
|---|
| 544 | |
|---|
| 545 | |
|---|
| 546 | |
|---|
| 547 | |
|---|
| 548 | |
|---|
| 549 | |
|---|
| 550 | this.sizeIncludesPanels = true; |
|---|
| 551 | |
|---|
| 552 | |
|---|
| 553 | |
|---|
| 554 | |
|---|
| 555 | |
|---|
| 556 | |
|---|
| 557 | |
|---|
| 558 | |
|---|
| 559 | |
|---|
| 560 | |
|---|
| 561 | |
|---|
| 562 | |
|---|
| 563 | |
|---|
| 564 | |
|---|
| 565 | |
|---|
| 566 | |
|---|
| 567 | |
|---|
| 568 | |
|---|
| 569 | this.panel_dimensions = |
|---|
| 570 | { |
|---|
| 571 | left: '200px', |
|---|
| 572 | right: '200px', |
|---|
| 573 | top: '100px', |
|---|
| 574 | bottom: '100px' |
|---|
| 575 | }; |
|---|
| 576 | |
|---|
| 577 | |
|---|
| 578 | |
|---|
| 579 | |
|---|
| 580 | |
|---|
| 581 | |
|---|
| 582 | |
|---|
| 583 | |
|---|
| 584 | this.iframeWidth = null; |
|---|
| 585 | |
|---|
| 586 | |
|---|
| 587 | |
|---|
| 588 | |
|---|
| 589 | |
|---|
| 590 | |
|---|
| 591 | |
|---|
| 592 | this.statusBar = true; |
|---|
| 593 | |
|---|
| 594 | |
|---|
| 595 | |
|---|
| 596 | |
|---|
| 597 | |
|---|
| 598 | |
|---|
| 599 | |
|---|
| 600 | |
|---|
| 601 | this.htmlareaPaste = false; |
|---|
| 602 | |
|---|
| 603 | |
|---|
| 604 | |
|---|
| 605 | |
|---|
| 606 | |
|---|
| 607 | |
|---|
| 608 | |
|---|
| 609 | |
|---|
| 610 | |
|---|
| 611 | |
|---|
| 612 | this.mozParaHandler = 'best'; |
|---|
| 613 | |
|---|
| 614 | |
|---|
| 615 | |
|---|
| 616 | |
|---|
| 617 | |
|---|
| 618 | |
|---|
| 619 | |
|---|
| 620 | |
|---|
| 621 | |
|---|
| 622 | |
|---|
| 623 | |
|---|
| 624 | |
|---|
| 625 | |
|---|
| 626 | |
|---|
| 627 | |
|---|
| 628 | |
|---|
| 629 | |
|---|
| 630 | |
|---|
| 631 | |
|---|
| 632 | |
|---|
| 633 | |
|---|
| 634 | this.getHtmlMethod = 'DOMwalk'; |
|---|
| 635 | |
|---|
| 636 | |
|---|
| 637 | |
|---|
| 638 | |
|---|
| 639 | |
|---|
| 640 | this.undoSteps = 20; |
|---|
| 641 | |
|---|
| 642 | |
|---|
| 643 | |
|---|
| 644 | |
|---|
| 645 | |
|---|
| 646 | this.undoTimeout = 500; |
|---|
| 647 | |
|---|
| 648 | |
|---|
| 649 | |
|---|
| 650 | |
|---|
| 651 | |
|---|
| 652 | this.changeJustifyWithDirection = false; |
|---|
| 653 | |
|---|
| 654 | |
|---|
| 655 | |
|---|
| 656 | |
|---|
| 657 | |
|---|
| 658 | this.fullPage = false; |
|---|
| 659 | |
|---|
| 660 | |
|---|
| 661 | |
|---|
| 662 | |
|---|
| 663 | |
|---|
| 664 | |
|---|
| 665 | |
|---|
| 666 | |
|---|
| 667 | |
|---|
| 668 | |
|---|
| 669 | |
|---|
| 670 | |
|---|
| 671 | |
|---|
| 672 | this.pageStyle = ""; |
|---|
| 673 | |
|---|
| 674 | |
|---|
| 675 | |
|---|
| 676 | |
|---|
| 677 | |
|---|
| 678 | |
|---|
| 679 | |
|---|
| 680 | this.pageStyleSheets = []; |
|---|
| 681 | |
|---|
| 682 | |
|---|
| 683 | |
|---|
| 684 | |
|---|
| 685 | |
|---|
| 686 | |
|---|
| 687 | |
|---|
| 688 | this.baseHref = null; |
|---|
| 689 | |
|---|
| 690 | |
|---|
| 691 | |
|---|
| 692 | |
|---|
| 693 | |
|---|
| 694 | |
|---|
| 695 | |
|---|
| 696 | |
|---|
| 697 | |
|---|
| 698 | this.expandRelativeUrl = true; |
|---|
| 699 | |
|---|
| 700 | |
|---|
| 701 | |
|---|
| 702 | |
|---|
| 703 | |
|---|
| 704 | |
|---|
| 705 | |
|---|
| 706 | this.stripBaseHref = true; |
|---|
| 707 | |
|---|
| 708 | |
|---|
| 709 | |
|---|
| 710 | |
|---|
| 711 | |
|---|
| 712 | |
|---|
| 713 | |
|---|
| 714 | |
|---|
| 715 | this.stripSelfNamedAnchors = true; |
|---|
| 716 | |
|---|
| 717 | |
|---|
| 718 | |
|---|
| 719 | |
|---|
| 720 | |
|---|
| 721 | this.only7BitPrintablesInURLs = true; |
|---|
| 722 | |
|---|
| 723 | |
|---|
| 724 | |
|---|
| 725 | |
|---|
| 726 | |
|---|
| 727 | |
|---|
| 728 | |
|---|
| 729 | |
|---|
| 730 | |
|---|
| 731 | this.sevenBitClean = false; |
|---|
| 732 | |
|---|
| 733 | |
|---|
| 734 | |
|---|
| 735 | |
|---|
| 736 | |
|---|
| 737 | |
|---|
| 738 | |
|---|
| 739 | |
|---|
| 740 | |
|---|
| 741 | |
|---|
| 742 | |
|---|
| 743 | this.specialReplacements = {}; |
|---|
| 744 | |
|---|
| 745 | |
|---|
| 746 | |
|---|
| 747 | |
|---|
| 748 | |
|---|
| 749 | |
|---|
| 750 | |
|---|
| 751 | this.inwardHtml = function (html) { return html; }; |
|---|
| 752 | |
|---|
| 753 | |
|---|
| 754 | |
|---|
| 755 | |
|---|
| 756 | |
|---|
| 757 | |
|---|
| 758 | |
|---|
| 759 | this.outwardHtml = function (html) { return html; }; |
|---|
| 760 | |
|---|
| 761 | |
|---|
| 762 | |
|---|
| 763 | |
|---|
| 764 | |
|---|
| 765 | |
|---|
| 766 | |
|---|
| 767 | |
|---|
| 768 | |
|---|
| 769 | this.autofocus = false; |
|---|
| 770 | |
|---|
| 771 | |
|---|
| 772 | |
|---|
| 773 | |
|---|
| 774 | |
|---|
| 775 | |
|---|
| 776 | |
|---|
| 777 | this.killWordOnPaste = true; |
|---|
| 778 | |
|---|
| 779 | |
|---|
| 780 | |
|---|
| 781 | |
|---|
| 782 | |
|---|
| 783 | this.makeLinkShowsTarget = true; |
|---|
| 784 | |
|---|
| 785 | |
|---|
| 786 | |
|---|
| 787 | |
|---|
| 788 | this.charSet = (typeof document.characterSet != 'undefined') ? document.characterSet : document.charset; |
|---|
| 789 | |
|---|
| 790 | |
|---|
| 791 | |
|---|
| 792 | |
|---|
| 793 | |
|---|
| 794 | |
|---|
| 795 | |
|---|
| 796 | |
|---|
| 797 | |
|---|
| 798 | |
|---|
| 799 | |
|---|
| 800 | this.browserQuirksMode = null; |
|---|
| 801 | |
|---|
| 802 | |
|---|
| 803 | this.imgURL = "images/"; |
|---|
| 804 | this.popupURL = "popups/"; |
|---|
| 805 | |
|---|
| 806 | |
|---|
| 807 | |
|---|
| 808 | |
|---|
| 809 | |
|---|
| 810 | |
|---|
| 811 | |
|---|
| 812 | |
|---|
| 813 | |
|---|
| 814 | this.htmlRemoveTags = null; |
|---|
| 815 | |
|---|
| 816 | |
|---|
| 817 | |
|---|
| 818 | |
|---|
| 819 | |
|---|
| 820 | |
|---|
| 821 | |
|---|
| 822 | |
|---|
| 823 | |
|---|
| 824 | |
|---|
| 825 | |
|---|
| 826 | |
|---|
| 827 | |
|---|
| 828 | |
|---|
| 829 | |
|---|
| 830 | this.flowToolbars = true; |
|---|
| 831 | |
|---|
| 832 | |
|---|
| 833 | |
|---|
| 834 | |
|---|
| 835 | this.toolbarAlign = "left"; |
|---|
| 836 | |
|---|
| 837 | |
|---|
| 838 | |
|---|
| 839 | |
|---|
| 840 | |
|---|
| 841 | |
|---|
| 842 | this.showFontStylesInToolbar = false; |
|---|
| 843 | |
|---|
| 844 | |
|---|
| 845 | |
|---|
| 846 | |
|---|
| 847 | |
|---|
| 848 | this.showLoading = false; |
|---|
| 849 | |
|---|
| 850 | |
|---|
| 851 | |
|---|
| 852 | |
|---|
| 853 | |
|---|
| 854 | |
|---|
| 855 | this.stripScripts = true; |
|---|
| 856 | |
|---|
| 857 | |
|---|
| 858 | |
|---|
| 859 | |
|---|
| 860 | |
|---|
| 861 | |
|---|
| 862 | |
|---|
| 863 | |
|---|
| 864 | this.convertUrlsToLinks = true; |
|---|
| 865 | |
|---|
| 866 | |
|---|
| 867 | |
|---|
| 868 | |
|---|
| 869 | |
|---|
| 870 | this.hideObjectsBehindDialogs = false; |
|---|
| 871 | |
|---|
| 872 | |
|---|
| 873 | |
|---|
| 874 | |
|---|
| 875 | |
|---|
| 876 | |
|---|
| 877 | this.colorPickerCellSize = '6px'; |
|---|
| 878 | |
|---|
| 879 | |
|---|
| 880 | |
|---|
| 881 | |
|---|
| 882 | this.colorPickerGranularity = 18; |
|---|
| 883 | |
|---|
| 884 | |
|---|
| 885 | |
|---|
| 886 | |
|---|
| 887 | this.colorPickerPosition = 'bottom,right'; |
|---|
| 888 | |
|---|
| 889 | |
|---|
| 890 | |
|---|
| 891 | |
|---|
| 892 | this.colorPickerWebSafe = false; |
|---|
| 893 | |
|---|
| 894 | |
|---|
| 895 | |
|---|
| 896 | |
|---|
| 897 | this.colorPickerSaveColors = 20; |
|---|
| 898 | |
|---|
| 899 | |
|---|
| 900 | |
|---|
| 901 | |
|---|
| 902 | |
|---|
| 903 | this.fullScreen = false; |
|---|
| 904 | |
|---|
| 905 | |
|---|
| 906 | |
|---|
| 907 | |
|---|
| 908 | |
|---|
| 909 | |
|---|
| 910 | this.fullScreenMargins = [0,0,0,0]; |
|---|
| 911 | |
|---|
| 912 | |
|---|
| 913 | |
|---|
| 914 | |
|---|
| 915 | |
|---|
| 916 | |
|---|
| 917 | |
|---|
| 918 | |
|---|
| 919 | |
|---|
| 920 | |
|---|
| 921 | |
|---|
| 922 | |
|---|
| 923 | |
|---|
| 924 | |
|---|
| 925 | |
|---|
| 926 | |
|---|
| 927 | |
|---|
| 928 | |
|---|
| 929 | |
|---|
| 930 | |
|---|
| 931 | |
|---|
| 932 | |
|---|
| 933 | |
|---|
| 934 | this.fullScreenSizeDownMethod = 'initSize'; |
|---|
| 935 | |
|---|
| 936 | |
|---|
| 937 | |
|---|
| 938 | |
|---|
| 939 | |
|---|
| 940 | |
|---|
| 941 | |
|---|
| 942 | |
|---|
| 943 | |
|---|
| 944 | |
|---|
| 945 | |
|---|
| 946 | |
|---|
| 947 | |
|---|
| 948 | |
|---|
| 949 | |
|---|
| 950 | |
|---|
| 951 | |
|---|
| 952 | |
|---|
| 953 | |
|---|
| 954 | |
|---|
| 955 | |
|---|
| 956 | this.toolbar = |
|---|
| 957 | [ |
|---|
| 958 | ["popupeditor"], |
|---|
| 959 | ["separator","formatblock","fontname","fontsize","bold","italic","underline","strikethrough"], |
|---|
| 960 | ["separator","forecolor","hilitecolor","textindicator"], |
|---|
| 961 | ["separator","subscript","superscript"], |
|---|
| 962 | ["linebreak","separator","justifyleft","justifycenter","justifyright","justifyfull"], |
|---|
| 963 | ["separator","insertorderedlist","insertunorderedlist","outdent","indent"], |
|---|
| 964 | ["separator","inserthorizontalrule","createlink","insertimage","inserttable"], |
|---|
| 965 | ["linebreak","separator","undo","redo","selectall","print"], (Xinha.is_gecko ? [] : ["cut","copy","paste","overwrite","saveas"]), |
|---|
| 966 | ["separator","killword","clearfonts","removeformat","toggleborders","splitblock","lefttoright", "righttoleft"], |
|---|
| 967 | ["separator","htmlmode","showhelp","about"] |
|---|
| 968 | ]; |
|---|
| 969 | |
|---|
| 970 | |
|---|
| 971 | |
|---|
| 972 | |
|---|
| 973 | |
|---|
| 974 | |
|---|
| 975 | |
|---|
| 976 | |
|---|
| 977 | |
|---|
| 978 | |
|---|
| 979 | |
|---|
| 980 | |
|---|
| 981 | |
|---|
| 982 | |
|---|
| 983 | |
|---|
| 984 | |
|---|
| 985 | |
|---|
| 986 | |
|---|
| 987 | |
|---|
| 988 | this.fontname = |
|---|
| 989 | { |
|---|
| 990 | "— font —": "", |
|---|
| 991 | "Arial" : 'arial,helvetica,sans-serif', |
|---|
| 992 | "Courier New" : 'courier new,courier,monospace', |
|---|
| 993 | "Georgia" : 'georgia,times new roman,times,serif', |
|---|
| 994 | "Tahoma" : 'tahoma,arial,helvetica,sans-serif', |
|---|
| 995 | "Times New Roman" : 'times new roman,times,serif', |
|---|
| 996 | "Verdana" : 'verdana,arial,helvetica,sans-serif', |
|---|
| 997 | "impact" : 'impact', |
|---|
| 998 | "WingDings" : 'wingdings' |
|---|
| 999 | }; |
|---|
| 1000 | |
|---|
| 1001 | |
|---|
| 1002 | |
|---|
| 1003 | |
|---|
| 1004 | |
|---|
| 1005 | |
|---|
| 1006 | |
|---|
| 1007 | |
|---|
| 1008 | |
|---|
| 1009 | |
|---|
| 1010 | |
|---|
| 1011 | |
|---|
| 1012 | |
|---|
| 1013 | |
|---|
| 1014 | |
|---|
| 1015 | |
|---|
| 1016 | |
|---|
| 1017 | |
|---|
| 1018 | this.fontsize = |
|---|
| 1019 | { |
|---|
| 1020 | "— size —": "", |
|---|
| 1021 | "1 (8 pt)" : "1", |
|---|
| 1022 | "2 (10 pt)": "2", |
|---|
| 1023 | "3 (12 pt)": "3", |
|---|
| 1024 | "4 (14 pt)": "4", |
|---|
| 1025 | "5 (18 pt)": "5", |
|---|
| 1026 | "6 (24 pt)": "6", |
|---|
| 1027 | "7 (36 pt)": "7" |
|---|
| 1028 | }; |
|---|
| 1029 | |
|---|
| 1030 | |
|---|
| 1031 | |
|---|
| 1032 | |
|---|
| 1033 | |
|---|
| 1034 | |
|---|
| 1035 | |
|---|
| 1036 | |
|---|
| 1037 | |
|---|
| 1038 | |
|---|
| 1039 | |
|---|
| 1040 | |
|---|
| 1041 | |
|---|
| 1042 | |
|---|
| 1043 | |
|---|
| 1044 | |
|---|
| 1045 | |
|---|
| 1046 | |
|---|
| 1047 | |
|---|
| 1048 | this.formatblock = |
|---|
| 1049 | { |
|---|
| 1050 | "— format —": "", |
|---|
| 1051 | "Heading 1": "h1", |
|---|
| 1052 | "Heading 2": "h2", |
|---|
| 1053 | "Heading 3": "h3", |
|---|
| 1054 | "Heading 4": "h4", |
|---|
| 1055 | "Heading 5": "h5", |
|---|
| 1056 | "Heading 6": "h6", |
|---|
| 1057 | "Normal" : "p", |
|---|
| 1058 | "Address" : "address", |
|---|
| 1059 | "Formatted": "pre" |
|---|
| 1060 | }; |
|---|
| 1061 | |
|---|
| 1062 | |
|---|
| 1063 | |
|---|
| 1064 | |
|---|
| 1065 | |
|---|
| 1066 | |
|---|
| 1067 | |
|---|
| 1068 | |
|---|
| 1069 | |
|---|
| 1070 | |
|---|
| 1071 | |
|---|
| 1072 | |
|---|
| 1073 | |
|---|
| 1074 | |
|---|
| 1075 | |
|---|
| 1076 | |
|---|
| 1077 | |
|---|
| 1078 | |
|---|
| 1079 | |
|---|
| 1080 | |
|---|
| 1081 | |
|---|
| 1082 | |
|---|
| 1083 | |
|---|
| 1084 | this.formatblockDetector = {}; |
|---|
| 1085 | |
|---|
| 1086 | this.dialogOptions = |
|---|
| 1087 | { |
|---|
| 1088 | 'centered' : true, |
|---|
| 1089 | 'greyout':true, |
|---|
| 1090 | 'closeOnEscape':true |
|---|
| 1091 | }; |
|---|
| 1092 | |
|---|
| 1093 | |
|---|
| 1094 | |
|---|
| 1095 | |
|---|
| 1096 | |
|---|
| 1097 | |
|---|
| 1098 | |
|---|
| 1099 | |
|---|
| 1100 | |
|---|
| 1101 | |
|---|
| 1102 | |
|---|
| 1103 | |
|---|
| 1104 | this.Events = {}; |
|---|
| 1105 | |
|---|
| 1106 | |
|---|
| 1107 | |
|---|
| 1108 | |
|---|
| 1109 | |
|---|
| 1110 | this.customSelects = {}; |
|---|
| 1111 | |
|---|
| 1112 | |
|---|
| 1113 | |
|---|
| 1114 | |
|---|
| 1115 | |
|---|
| 1116 | |
|---|
| 1117 | this.debug = false; |
|---|
| 1118 | |
|---|
| 1119 | this.URIs = |
|---|
| 1120 | { |
|---|
| 1121 | "blank": _editor_url + "popups/blank.html", |
|---|
| 1122 | "link": _editor_url + "modules/CreateLink/link.html", |
|---|
| 1123 | "insert_image": _editor_url + "modules/InsertImage/insert_image.html", |
|---|
| 1124 | "insert_table": _editor_url + "modules/InsertTable/insert_table.html", |
|---|
| 1125 | "select_color": _editor_url + "popups/select_color.html", |
|---|
| 1126 | "help": _editor_url + "popups/editor_help.html" |
|---|
| 1127 | }; |
|---|
| 1128 | |
|---|
| 1129 | |
|---|
| 1130 | |
|---|
| 1131 | |
|---|
| 1132 | |
|---|
| 1133 | |
|---|
| 1134 | |
|---|
| 1135 | |
|---|
| 1136 | |
|---|
| 1137 | |
|---|
| 1138 | |
|---|
| 1139 | |
|---|
| 1140 | |
|---|
| 1141 | |
|---|
| 1142 | |
|---|
| 1143 | |
|---|
| 1144 | |
|---|
| 1145 | |
|---|
| 1146 | |
|---|
| 1147 | |
|---|
| 1148 | |
|---|
| 1149 | |
|---|
| 1150 | |
|---|
| 1151 | this.btnList = |
|---|
| 1152 | { |
|---|
| 1153 | bold: [ "Bold", Xinha._lc({key: 'button_bold', string: ["ed_buttons_main.png",3,2]}, 'Xinha'), false, function(e) { e.execCommand("bold"); } ], |
|---|
| 1154 | italic: [ "Italic", Xinha._lc({key: 'button_italic', string: ["ed_buttons_main.png",2,2]}, 'Xinha'), false, function(e) { e.execCommand("italic"); } ], |
|---|
| 1155 | underline: [ "Underline", Xinha._lc({key: 'button_underline', string: ["ed_buttons_main.png",2,0]}, 'Xinha'), false, function(e) { e.execCommand("underline"); } ], |
|---|
| 1156 | strikethrough: [ "Strikethrough", Xinha._lc({key: 'button_strikethrough', string: ["ed_buttons_main.png",3,0]}, 'Xinha'), false, function(e) { e.execCommand("strikethrough"); } ], |
|---|
| 1157 | subscript: [ "Subscript", Xinha._lc({key: 'button_subscript', string: ["ed_buttons_main.png",3,1]}, 'Xinha'), false, function(e) { e.execCommand("subscript"); } ], |
|---|
| 1158 | superscript: [ "Superscript", Xinha._lc({key: 'button_superscript', string: ["ed_buttons_main.png",2,1]}, 'Xinha'), false, function(e) { e.execCommand("superscript"); } ], |
|---|
| 1159 | |
|---|
| 1160 | justifyleft: [ "Justify Left", ["ed_buttons_main.png",0,0], false, function(e) { e.execCommand("justifyleft"); } ], |
|---|
| 1161 | justifycenter: [ "Justify Center", ["ed_buttons_main.png",1,1], false, function(e){ e.execCommand("justifycenter"); } ], |
|---|
| 1162 | justifyright: [ "Justify Right", ["ed_buttons_main.png",1,0], false, function(e) { e.execCommand("justifyright"); } ], |
|---|
| 1163 | justifyfull: [ "Justify Full", ["ed_buttons_main.png",0,1], false, function(e) { e.execCommand("justifyfull"); } ], |
|---|
| 1164 | |
|---|
| 1165 | orderedlist: [ "Ordered List", ["ed_buttons_main.png",0,3], false, function(e) { e.execCommand("insertorderedlist"); } ], |
|---|
| 1166 | unorderedlist: [ "Bulleted List", ["ed_buttons_main.png",1,3], false, function(e) { e.execCommand("insertunorderedlist"); } ], |
|---|
| 1167 | insertorderedlist: [ "Ordered List", ["ed_buttons_main.png",0,3], false, function(e) { e.execCommand("insertorderedlist"); } ], |
|---|
| 1168 | insertunorderedlist: [ "Bulleted List", ["ed_buttons_main.png",1,3], false, function(e) { e.execCommand("insertunorderedlist"); } ], |
|---|
| 1169 | |
|---|
| 1170 | outdent: [ "Decrease Indent", ["ed_buttons_main.png",1,2], false, function(e) { e.execCommand("outdent"); } ], |
|---|
| 1171 | indent: [ "Increase Indent",["ed_buttons_main.png",0,2], false, function(e) { e.execCommand("indent"); } ], |
|---|
| 1172 | forecolor: [ "Font Color", ["ed_buttons_main.png",3,3], false, function(e) { e.execCommand("forecolor"); } ], |
|---|
| 1173 | hilitecolor: [ "Background Color", ["ed_buttons_main.png",2,3], false, function(e) { e.execCommand("hilitecolor"); } ], |
|---|
| 1174 | |
|---|
| 1175 | undo: [ "Undoes your last action", ["ed_buttons_main.png",4,2], false, function(e) { e.execCommand("undo"); } ], |
|---|
| 1176 | redo: [ "Redoes your last action", ["ed_buttons_main.png",5,2], false, function(e) { e.execCommand("redo"); } ], |
|---|
| 1177 | cut: [ "Cut selection", ["ed_buttons_main.png",5,0], false, function (e, cmd) { e.execCommand(cmd); } ], |
|---|
| 1178 | copy: [ "Copy selection", ["ed_buttons_main.png",4,0], false, function (e, cmd) { e.execCommand(cmd); } ], |
|---|
| 1179 | paste: [ "Paste from clipboard", ["ed_buttons_main.png",4,1], false, function (e, cmd) { e.execCommand(cmd); } ], |
|---|
| 1180 | selectall: [ "Select all", ["ed_buttons_main.png",3,5], false, function(e) {e.execCommand("selectall");} ], |
|---|
| 1181 | |
|---|
| 1182 | inserthorizontalrule: [ "Horizontal Rule", ["ed_buttons_main.png",6,0], false, function(e) { e.execCommand("inserthorizontalrule"); } ], |
|---|
| 1183 | createlink: [ "Insert Web Link", ["ed_buttons_main.png",6,1], false, function(e) { e.execCommand("createlink"); } ], |
|---|
| 1184 | insertimage: [ "Insert/Modify Image", ["ed_buttons_main.png",6,3], false, function(e) { e.execCommand("insertimage"); } ], |
|---|
| 1185 | inserttable: [ "Insert Table", ["ed_buttons_main.png",6,2], false, function(e) { e.execCommand("inserttable"); } ], |
|---|
| 1186 | |
|---|
| 1187 | htmlmode: [ "Toggle HTML Source", ["ed_buttons_main.png",7,0], true, function(e) { e.execCommand("htmlmode"); } ], |
|---|
| 1188 | toggleborders: [ "Toggle Borders", ["ed_buttons_main.png",7,2], false, function(e) { e._toggleBorders(); } ], |
|---|
| 1189 | print: [ "Print document", ["ed_buttons_main.png",8,1], false, function(e) { if(Xinha.is_gecko) {e._iframe.contentWindow.print(); } else { e.focusEditor(); print(); } } ], |
|---|
| 1190 | saveas: [ "Save as", ["ed_buttons_main.png",9,1], false, function(e) { e.execCommand("saveas",false,"noname.htm"); } ], |
|---|
| 1191 | about: [ "About this editor", ["ed_buttons_main.png",8,2], true, function(e) { e.getPluginInstance("AboutBox").show(); } ], |
|---|
| 1192 | showhelp: [ "Help using editor", ["ed_buttons_main.png",9,2], true, function(e) { e.execCommand("showhelp"); } ], |
|---|
| 1193 | |
|---|
| 1194 | splitblock: [ "Split Block", "ed_splitblock.gif", false, function(e) { e._splitBlock(); } ], |
|---|
| 1195 | lefttoright: [ "Direction left to right", ["ed_buttons_main.png",0,2], false, function(e) { e.execCommand("lefttoright"); } ], |
|---|
| 1196 | righttoleft: [ "Direction right to left", ["ed_buttons_main.png",1,2], false, function(e) { e.execCommand("righttoleft"); } ], |
|---|
| 1197 | overwrite: [ "Insert/Overwrite", "ed_overwrite.gif", false, function(e) { e.execCommand("overwrite"); } ], |
|---|
| 1198 | |
|---|
| 1199 | wordclean: [ "MS Word Cleaner", ["ed_buttons_main.png",5,3], false, function(e) { e._wordClean(); } ], |
|---|
| 1200 | clearfonts: [ "Clear Inline Font Specifications", ["ed_buttons_main.png",5,4], true, function(e) { e._clearFonts(); } ], |
|---|
| 1201 | removeformat: [ "Remove formatting", ["ed_buttons_main.png",4,4], false, function(e) { e.execCommand("removeformat"); } ], |
|---|
| 1202 | killword: [ "Clear MSOffice tags", ["ed_buttons_main.png",4,3], false, function(e) { e.execCommand("killword"); } ] |
|---|
| 1203 | }; |
|---|
| 1204 | |
|---|
| 1205 | |
|---|
| 1206 | |
|---|
| 1207 | |
|---|
| 1208 | |
|---|
| 1209 | |
|---|
| 1210 | this.dblclickList = |
|---|
| 1211 | { |
|---|
| 1212 | "a": [function(e, target) {e.execCommand("createlink", false, target);}], |
|---|
| 1213 | "img": [function(e, target) {e._insertImage(target);}] |
|---|
| 1214 | }; |
|---|
| 1215 | |
|---|
| 1216 | |
|---|
| 1217 | |
|---|
| 1218 | |
|---|
| 1219 | |
|---|
| 1220 | |
|---|
| 1221 | |
|---|
| 1222 | this.bodyClass = null; |
|---|
| 1223 | |
|---|
| 1224 | |
|---|
| 1225 | |
|---|
| 1226 | |
|---|
| 1227 | |
|---|
| 1228 | |
|---|
| 1229 | |
|---|
| 1230 | this.bodyID = null; |
|---|
| 1231 | |
|---|
| 1232 | |
|---|
| 1233 | |
|---|
| 1234 | |
|---|
| 1235 | this.iconList = |
|---|
| 1236 | { |
|---|
| 1237 | dialogCaption : _editor_url + 'images/xinha-small-icon.gif', |
|---|
| 1238 | wysiwygmode : [_editor_url + 'images/ed_buttons_main.png',7,1] |
|---|
| 1239 | }; |
|---|
| 1240 | |
|---|
| 1241 | for ( var i in this.btnList ) |
|---|
| 1242 | { |
|---|
| 1243 | var btn = this.btnList[i]; |
|---|
| 1244 | |
|---|
| 1245 | if ( typeof btn != 'object' ) |
|---|
| 1246 | { |
|---|
| 1247 | continue; |
|---|
| 1248 | } |
|---|
| 1249 | if ( typeof btn[1] != 'string' ) |
|---|
| 1250 | { |
|---|
| 1251 | btn[1][0] = _editor_url + this.imgURL + btn[1][0]; |
|---|
| 1252 | } |
|---|
| 1253 | else |
|---|
| 1254 | { |
|---|
| 1255 | btn[1] = _editor_url + this.imgURL + btn[1]; |
|---|
| 1256 | } |
|---|
| 1257 | btn[0] = Xinha._lc(btn[0]); |
|---|
| 1258 | } |
|---|
| 1259 | }; |
|---|
| 1260 | |
|---|
| 1261 | |
|---|
| 1262 | |
|---|
| 1263 | |
|---|
| 1264 | |
|---|
| 1265 | Xinha.Config.prototype.registerIcon = function (id, icon) |
|---|
| 1266 | { |
|---|
| 1267 | this.iconList[id] = icon; |
|---|
| 1268 | }; |
|---|
| 1269 | |
|---|
| 1270 | |
|---|
| 1271 | |
|---|
| 1272 | |
|---|
| 1273 | |
|---|
| 1274 | |
|---|
| 1275 | |
|---|
| 1276 | |
|---|
| 1277 | |
|---|
| 1278 | |
|---|
| 1279 | |
|---|
| 1280 | |
|---|
| 1281 | |
|---|
| 1282 | |
|---|
| 1283 | |
|---|
| 1284 | |
|---|
| 1285 | |
|---|
| 1286 | |
|---|
| 1287 | |
|---|
| 1288 | |
|---|
| 1289 | |
|---|
| 1290 | |
|---|
| 1291 | |
|---|
| 1292 | |
|---|
| 1293 | |
|---|
| 1294 | |
|---|
| 1295 | |
|---|
| 1296 | |
|---|
| 1297 | |
|---|
| 1298 | |
|---|
| 1299 | |
|---|
| 1300 | |
|---|
| 1301 | |
|---|
| 1302 | |
|---|
| 1303 | |
|---|
| 1304 | |
|---|
| 1305 | |
|---|
| 1306 | |
|---|
| 1307 | Xinha.Config.prototype.registerButton = function(id, tooltip, image, textMode, action, context) |
|---|
| 1308 | { |
|---|
| 1309 | if ( typeof id == "string" ) |
|---|
| 1310 | { |
|---|
| 1311 | this.btnList[id] = [ tooltip, image, textMode, action, context ]; |
|---|
| 1312 | } |
|---|
| 1313 | else if ( typeof id == "object" ) |
|---|
| 1314 | { |
|---|
| 1315 | this.btnList[id.id] = [ id.tooltip, id.image, id.textMode, id.action, id.context ]; |
|---|
| 1316 | } |
|---|
| 1317 | else |
|---|
| 1318 | { |
|---|
| 1319 | alert("ERROR [Xinha.Config::registerButton]:\ninvalid arguments"); |
|---|
| 1320 | return false; |
|---|
| 1321 | } |
|---|
| 1322 | }; |
|---|
| 1323 | |
|---|
| 1324 | Xinha.prototype.registerPanel = function(side, object) |
|---|
| 1325 | { |
|---|
| 1326 | if ( !side ) |
|---|
| 1327 | { |
|---|
| 1328 | side = 'right'; |
|---|
| 1329 | } |
|---|
| 1330 | this.setLoadingMessage('Register ' + side + ' panel '); |
|---|
| 1331 | var panel = this.addPanel(side); |
|---|
| 1332 | if ( object ) |
|---|
| 1333 | { |
|---|
| 1334 | object.drawPanelIn(panel); |
|---|
| 1335 | } |
|---|
| 1336 | }; |
|---|
| 1337 | |
|---|
| 1338 | |
|---|
| 1339 | |
|---|
| 1340 | |
|---|
| 1341 | |
|---|
| 1342 | |
|---|
| 1343 | |
|---|
| 1344 | Xinha.Config.prototype.registerDropdown = function(object) |
|---|
| 1345 | { |
|---|
| 1346 | |
|---|
| 1347 | |
|---|
| 1348 | |
|---|
| 1349 | |
|---|
| 1350 | |
|---|
| 1351 | |
|---|
| 1352 | |
|---|
| 1353 | |
|---|
| 1354 | |
|---|
| 1355 | this.customSelects[object.id] = object; |
|---|
| 1356 | }; |
|---|
| 1357 | |
|---|
| 1358 | |
|---|
| 1359 | |
|---|
| 1360 | |
|---|
| 1361 | |
|---|
| 1362 | |
|---|
| 1363 | |
|---|
| 1364 | |
|---|
| 1365 | |
|---|
| 1366 | |
|---|
| 1367 | |
|---|
| 1368 | Xinha.Config.prototype.hideSomeButtons = function(remove) |
|---|
| 1369 | { |
|---|
| 1370 | var toolbar = this.toolbar; |
|---|
| 1371 | for ( var i = toolbar.length; --i >= 0; ) |
|---|
| 1372 | { |
|---|
| 1373 | var line = toolbar[i]; |
|---|
| 1374 | for ( var j = line.length; --j >= 0; ) |
|---|
| 1375 | { |
|---|
| 1376 | if ( remove.indexOf(" " + line[j] + " ") >= 0 ) |
|---|
| 1377 | { |
|---|
| 1378 | var len = 1; |
|---|
| 1379 | if ( /separator|space/.test(line[j + 1]) ) |
|---|
| 1380 | { |
|---|
| 1381 | len = 2; |
|---|
| 1382 | } |
|---|
| 1383 | line.splice(j, len); |
|---|
| 1384 | } |
|---|
| 1385 | } |
|---|
| 1386 | } |
|---|
| 1387 | }; |
|---|
| 1388 | |
|---|
| 1389 | |
|---|
| 1390 | |
|---|
| 1391 | |
|---|
| 1392 | |
|---|
| 1393 | |
|---|
| 1394 | |
|---|
| 1395 | |
|---|
| 1396 | |
|---|
| 1397 | |
|---|
| 1398 | |
|---|
| 1399 | |
|---|
| 1400 | |
|---|
| 1401 | Xinha.Config.prototype.addToolbarElement = function(id, where, position) |
|---|
| 1402 | { |
|---|
| 1403 | var toolbar = this.toolbar; |
|---|
| 1404 | var a, i, j, o, sid; |
|---|
| 1405 | var idIsArray = false; |
|---|
| 1406 | var whereIsArray = false; |
|---|
| 1407 | var whereLength = 0; |
|---|
| 1408 | var whereJ = 0; |
|---|
| 1409 | var whereI = 0; |
|---|
| 1410 | var exists = false; |
|---|
| 1411 | var found = false; |
|---|
| 1412 | |
|---|
| 1413 | if ( ( id && typeof id == "object" ) && ( id.constructor == Array ) ) |
|---|
| 1414 | { |
|---|
| 1415 | idIsArray = true; |
|---|
| 1416 | } |
|---|
| 1417 | if ( ( where && typeof where == "object" ) && ( where.constructor == Array ) ) |
|---|
| 1418 | { |
|---|
| 1419 | whereIsArray = true; |
|---|
| 1420 | whereLength = where.length; |
|---|
| 1421 | } |
|---|
| 1422 | |
|---|
| 1423 | if ( idIsArray ) |
|---|
| 1424 | { |
|---|
| 1425 | for ( i = 0; i < id.length; ++i ) |
|---|
| 1426 | { |
|---|
| 1427 | if ( ( id[i] != "separator" ) && ( id[i].indexOf("T[") !== 0) ) |
|---|
| 1428 | { |
|---|
| 1429 | sid = id[i]; |
|---|
| 1430 | } |
|---|
| 1431 | } |
|---|
| 1432 | } |
|---|
| 1433 | else |
|---|
| 1434 | { |
|---|
| 1435 | sid = id; |
|---|
| 1436 | } |
|---|
| 1437 | |
|---|
| 1438 | for ( i = 0; i < toolbar.length; ++i ) { |
|---|
| 1439 | a = toolbar[i]; |
|---|
| 1440 | for ( j = 0; j < a.length; ++j ) { |
|---|
| 1441 | |
|---|
| 1442 | if ( a[j] == sid ) { |
|---|
| 1443 | return; |
|---|
| 1444 | } |
|---|
| 1445 | } |
|---|
| 1446 | } |
|---|
| 1447 | |
|---|
| 1448 | |
|---|
| 1449 | for ( i = 0; !found && i < toolbar.length; ++i ) |
|---|
| 1450 | { |
|---|
| 1451 | a = toolbar[i]; |
|---|
| 1452 | for ( j = 0; !found && j < a.length; ++j ) |
|---|
| 1453 | { |
|---|
| 1454 | if ( whereIsArray ) |
|---|
| 1455 | { |
|---|
| 1456 | for ( o = 0; o < whereLength; ++o ) |
|---|
| 1457 | { |
|---|
| 1458 | if ( a[j] == where[o] ) |
|---|
| 1459 | { |
|---|
| 1460 | if ( o === 0 ) |
|---|
| 1461 | { |
|---|
| 1462 | found = true; |
|---|
| 1463 | j--; |
|---|
| 1464 | break; |
|---|
| 1465 | } |
|---|
| 1466 | else |
|---|
| 1467 | { |
|---|
| 1468 | whereI = i; |
|---|
| 1469 | whereJ = j; |
|---|
| 1470 | whereLength = o; |
|---|
| 1471 | } |
|---|
| 1472 | } |
|---|
| 1473 | } |
|---|
| 1474 | } |
|---|
| 1475 | else |
|---|
| 1476 | { |
|---|
| 1477 | |
|---|
| 1478 | if ( a[j] == where ) |
|---|
| 1479 | { |
|---|
| 1480 | found = true; |
|---|
| 1481 | break; |
|---|
| 1482 | } |
|---|
| 1483 | } |
|---|
| 1484 | } |
|---|
| 1485 | } |
|---|
| 1486 | |
|---|
| 1487 | |
|---|
| 1488 | if ( !found && whereIsArray ) |
|---|
| 1489 | { |
|---|
| 1490 | if ( where.length != whereLength ) |
|---|
| 1491 | { |
|---|
| 1492 | j = whereJ; |
|---|
| 1493 | a = toolbar[whereI]; |
|---|
| 1494 | found = true; |
|---|
| 1495 | } |
|---|
| 1496 | } |
|---|
| 1497 | if ( found ) |
|---|
| 1498 | { |
|---|
| 1499 | |
|---|
| 1500 | if ( position === 0 ) |
|---|
| 1501 | { |
|---|
| 1502 | if ( idIsArray) |
|---|
| 1503 | { |
|---|
| 1504 | a[j] = id[id.length-1]; |
|---|
| 1505 | for ( i = id.length-1; --i >= 0; ) |
|---|
| 1506 | { |
|---|
| 1507 | a.splice(j, 0, id[i]); |
|---|
| 1508 | } |
|---|
| 1509 | } |
|---|
| 1510 | else |
|---|
| 1511 | { |
|---|
| 1512 | a[j] = id; |
|---|
| 1513 | } |
|---|
| 1514 | } |
|---|
| 1515 | else |
|---|
| 1516 | { |
|---|
| 1517 | |
|---|
| 1518 | if ( position < 0 ) |
|---|
| 1519 | { |
|---|
| 1520 | j = j + position + 1; |
|---|
| 1521 | } |
|---|
| 1522 | else if ( position > 0 ) |
|---|
| 1523 | { |
|---|
| 1524 | j = j + position; |
|---|
| 1525 | } |
|---|
| 1526 | if ( idIsArray ) |
|---|
| 1527 | { |
|---|
| 1528 | for ( i = id.length; --i >= 0; ) |
|---|
| 1529 | { |
|---|
| 1530 | a.splice(j, 0, id[i]); |
|---|
| 1531 | } |
|---|
| 1532 | } |
|---|
| 1533 | else |
|---|
| 1534 | { |
|---|
| 1535 | a.splice(j, 0, id); |
|---|
| 1536 | } |
|---|
| 1537 | } |
|---|
| 1538 | } |
|---|
| 1539 | else |
|---|
| 1540 | { |
|---|
| 1541 | |
|---|
| 1542 | toolbar[0].splice(0, 0, "separator"); |
|---|
| 1543 | if ( idIsArray) |
|---|
| 1544 | { |
|---|
| 1545 | for ( i = id.length; --i >= 0; ) |
|---|
| 1546 | { |
|---|
| 1547 | toolbar[0].splice(0, 0, id[i]); |
|---|
| 1548 | } |
|---|
| 1549 | } |
|---|
| 1550 | else |
|---|
| 1551 | { |
|---|
| 1552 | toolbar[0].splice(0, 0, id); |
|---|
| 1553 | } |
|---|
| 1554 | } |
|---|
| 1555 | }; |
|---|
| 1556 | |
|---|
| 1557 | |
|---|
| 1558 | |
|---|
| 1559 | Xinha.Config.prototype.removeToolbarElement = Xinha.Config.prototype.hideSomeButtons; |
|---|
| 1560 | |
|---|
| 1561 | |
|---|
| 1562 | |
|---|
| 1563 | |
|---|
| 1564 | Xinha.replaceAll = function(config) |
|---|
| 1565 | { |
|---|
| 1566 | var tas = document.getElementsByTagName("textarea"); |
|---|
| 1567 | |
|---|
| 1568 | for ( var i = tas.length; i > 0; new Xinha(tas[--i], config).generate() ) |
|---|
| 1569 | { |
|---|
| 1570 | |
|---|
| 1571 | } |
|---|
| 1572 | }; |
|---|
| 1573 | |
|---|
| 1574 | |
|---|
| 1575 | |
|---|
| 1576 | |
|---|
| 1577 | |
|---|
| 1578 | Xinha.replace = function(id, config) |
|---|
| 1579 | { |
|---|
| 1580 | var ta = Xinha.getElementById("textarea", id); |
|---|
| 1581 | return ta ? new Xinha(ta, config).generate() : null; |
|---|
| 1582 | }; |
|---|
| 1583 | |
|---|
| 1584 | |
|---|
| 1585 | |
|---|
| 1586 | |
|---|
| 1587 | |
|---|
| 1588 | Xinha.prototype._createToolbar = function () |
|---|
| 1589 | { |
|---|
| 1590 | this.setLoadingMessage(Xinha._lc('Create Toolbar')); |
|---|
| 1591 | var editor = this; |
|---|
| 1592 | |
|---|
| 1593 | var toolbar = document.createElement("div"); |
|---|
| 1594 | |
|---|
| 1595 | this._toolBar = this._toolbar = toolbar; |
|---|
| 1596 | toolbar.className = "toolbar"; |
|---|
| 1597 | toolbar.align = this.config.toolbarAlign; |
|---|
| 1598 | |
|---|
| 1599 | Xinha.freeLater(this, '_toolBar'); |
|---|
| 1600 | Xinha.freeLater(this, '_toolbar'); |
|---|
| 1601 | |
|---|
| 1602 | var tb_row = null; |
|---|
| 1603 | var tb_objects = {}; |
|---|
| 1604 | this._toolbarObjects = tb_objects; |
|---|
| 1605 | |
|---|
| 1606 | this._createToolbar1(editor, toolbar, tb_objects); |
|---|
| 1607 | |
|---|
| 1608 | |
|---|
| 1609 | |
|---|
| 1610 | |
|---|
| 1611 | function noselect(e) |
|---|
| 1612 | { |
|---|
| 1613 | if(e.tagName) e.unselectable = "on"; |
|---|
| 1614 | if(e.childNodes) |
|---|
| 1615 | { |
|---|
| 1616 | for(var i = 0; i < e.childNodes.length; i++) if(e.tagName) noselect(e.childNodes(i)); |
|---|
| 1617 | } |
|---|
| 1618 | } |
|---|
| 1619 | if(Xinha.is_ie) noselect(toolbar); |
|---|
| 1620 | |
|---|
| 1621 | |
|---|
| 1622 | this._htmlArea.appendChild(toolbar); |
|---|
| 1623 | |
|---|
| 1624 | return toolbar; |
|---|
| 1625 | }; |
|---|
| 1626 | |
|---|
| 1627 | |
|---|
| 1628 | |
|---|
| 1629 | |
|---|
| 1630 | |
|---|
| 1631 | Xinha.prototype._setConfig = function(config) |
|---|
| 1632 | { |
|---|
| 1633 | this.config = config; |
|---|
| 1634 | }; |
|---|
| 1635 | |
|---|
| 1636 | |
|---|
| 1637 | |
|---|
| 1638 | Xinha.prototype._rebuildToolbar = function() |
|---|
| 1639 | { |
|---|
| 1640 | this._createToolbar1(this, this._toolbar, this._toolbarObjects); |
|---|
| 1641 | |
|---|
| 1642 | |
|---|
| 1643 | if ( Xinha._currentlyActiveEditor ) |
|---|
| 1644 | { |
|---|
| 1645 | if ( Xinha._currentlyActiveEditor == this ) |
|---|
| 1646 | { |
|---|
| 1647 | this.activateEditor(); |
|---|
| 1648 | } |
|---|
| 1649 | } |
|---|
| 1650 | else |
|---|
| 1651 | { |
|---|
| 1652 | this.disableToolbar(); |
|---|
| 1653 | } |
|---|
| 1654 | }; |
|---|
| 1655 | |
|---|
| 1656 | |
|---|
| 1657 | |
|---|
| 1658 | |
|---|
| 1659 | |
|---|
| 1660 | |
|---|
| 1661 | |
|---|
| 1662 | Xinha._createToolbarBreakingElement = function() |
|---|
| 1663 | { |
|---|
| 1664 | var brk = document.createElement('div'); |
|---|
| 1665 | brk.style.height = '1px'; |
|---|
| 1666 | brk.style.width = '1px'; |
|---|
| 1667 | brk.style.lineHeight = '1px'; |
|---|
| 1668 | brk.style.fontSize = '1px'; |
|---|
| 1669 | brk.style.clear = 'both'; |
|---|
| 1670 | return brk; |
|---|
| 1671 | }; |
|---|
| 1672 | |
|---|
| 1673 | |
|---|
| 1674 | |
|---|
| 1675 | |
|---|
| 1676 | |
|---|
| 1677 | |
|---|
| 1678 | Xinha.prototype._createToolbar1 = function (editor, toolbar, tb_objects) |
|---|
| 1679 | { |
|---|
| 1680 | |
|---|
| 1681 | while (toolbar.lastChild) |
|---|
| 1682 | { |
|---|
| 1683 | toolbar.removeChild(toolbar.lastChild); |
|---|
| 1684 | } |
|---|
| 1685 | |
|---|
| 1686 | var tb_row; |
|---|
| 1687 | |
|---|
| 1688 | |
|---|
| 1689 | |
|---|
| 1690 | if ( editor.config.flowToolbars ) |
|---|
| 1691 | { |
|---|
| 1692 | toolbar.appendChild(Xinha._createToolbarBreakingElement()); |
|---|
| 1693 | } |
|---|
| 1694 | |
|---|
| 1695 | |
|---|
| 1696 | function newLine() |
|---|
| 1697 | { |
|---|
| 1698 | if ( typeof tb_row != 'undefined' && tb_row.childNodes.length === 0) |
|---|
| 1699 | { |
|---|
| 1700 | return; |
|---|
| 1701 | } |
|---|
| 1702 | |
|---|
| 1703 | var table = document.createElement("table"); |
|---|
| 1704 | table.border = "0px"; |
|---|
| 1705 | table.cellSpacing = "0px"; |
|---|
| 1706 | table.cellPadding = "0px"; |
|---|
| 1707 | if ( editor.config.flowToolbars ) |
|---|
| 1708 | { |
|---|
| 1709 | if ( Xinha.is_ie ) |
|---|
| 1710 | { |
|---|
| 1711 | table.style.styleFloat = "left"; |
|---|
| 1712 | } |
|---|
| 1713 | else |
|---|
| 1714 | { |
|---|
| 1715 | table.style.cssFloat = "left"; |
|---|
| 1716 | } |
|---|
| 1717 | } |
|---|
| 1718 | |
|---|
| 1719 | toolbar.appendChild(table); |
|---|
| 1720 | |
|---|
| 1721 | |
|---|
| 1722 | var tb_body = document.createElement("tbody"); |
|---|
| 1723 | table.appendChild(tb_body); |
|---|
| 1724 | tb_row = document.createElement("tr"); |
|---|
| 1725 | tb_body.appendChild(tb_row); |
|---|
| 1726 | |
|---|
| 1727 | table.className = 'toolbarRow'; |
|---|
| 1728 | } |
|---|
| 1729 | |
|---|
| 1730 | |
|---|
| 1731 | newLine(); |
|---|
| 1732 | |
|---|
| 1733 | |
|---|
| 1734 | |
|---|
| 1735 | |
|---|
| 1736 | function setButtonStatus(id, newval) |
|---|
| 1737 | { |
|---|
| 1738 | var oldval = this[id]; |
|---|
| 1739 | var el = this.element; |
|---|
| 1740 | if ( oldval != newval ) |
|---|
| 1741 | { |
|---|
| 1742 | switch (id) |
|---|
| 1743 | { |
|---|
| 1744 | case "enabled": |
|---|
| 1745 | if ( newval ) |
|---|
| 1746 | { |
|---|
| 1747 | Xinha._removeClass(el, "buttonDisabled"); |
|---|
| 1748 | el.disabled = false; |
|---|
| 1749 | } |
|---|
| 1750 | else |
|---|
| 1751 | { |
|---|
| 1752 | Xinha._addClass(el, "buttonDisabled"); |
|---|
| 1753 | el.disabled = true; |
|---|
| 1754 | } |
|---|
| 1755 | break; |
|---|
| 1756 | case "active": |
|---|
| 1757 | if ( newval ) |
|---|
| 1758 | { |
|---|
| 1759 | Xinha._addClass(el, "buttonPressed"); |
|---|
| 1760 | } |
|---|
| 1761 | else |
|---|
| 1762 | { |
|---|
| 1763 | Xinha._removeClass(el, "buttonPressed"); |
|---|
| 1764 | } |
|---|
| 1765 | break; |
|---|
| 1766 | } |
|---|
| 1767 | this[id] = newval; |
|---|
| 1768 | } |
|---|
| 1769 | } |
|---|
| 1770 | |
|---|
| 1771 | |
|---|
| 1772 | |
|---|
| 1773 | |
|---|
| 1774 | |
|---|
| 1775 | function createSelect(txt) |
|---|
| 1776 | { |
|---|
| 1777 | var options = null; |
|---|
| 1778 | var el = null; |
|---|
| 1779 | var cmd = null; |
|---|
| 1780 | var customSelects = editor.config.customSelects; |
|---|
| 1781 | var context = null; |
|---|
| 1782 | var tooltip = ""; |
|---|
| 1783 | switch (txt) |
|---|
| 1784 | { |
|---|
| 1785 | case "fontsize": |
|---|
| 1786 | case "fontname": |
|---|
| 1787 | case "formatblock": |
|---|
| 1788 | |
|---|
| 1789 | |
|---|
| 1790 | |
|---|
| 1791 | |
|---|
| 1792 | |
|---|
| 1793 | |
|---|
| 1794 | |
|---|
| 1795 | options = editor.config[txt]; |
|---|
| 1796 | cmd = txt; |
|---|
| 1797 | break; |
|---|
| 1798 | default: |
|---|
| 1799 | |
|---|
| 1800 | cmd = txt; |
|---|
| 1801 | var dropdown = customSelects[cmd]; |
|---|
| 1802 | if ( typeof dropdown != "undefined" ) |
|---|
| 1803 | { |
|---|
| 1804 | options = dropdown.options; |
|---|
| 1805 | context = dropdown.context; |
|---|
| 1806 | if ( typeof dropdown.tooltip != "undefined" ) |
|---|
| 1807 | { |
|---|
| 1808 | tooltip = dropdown.tooltip; |
|---|
| 1809 | } |
|---|
| 1810 | } |
|---|
| 1811 | else |
|---|
| 1812 | { |
|---|
| 1813 | alert("ERROR [createSelect]:\nCan't find the requested dropdown definition"); |
|---|
| 1814 | } |
|---|
| 1815 | break; |
|---|
| 1816 | } |
|---|
| 1817 | if ( options ) |
|---|
| 1818 | { |
|---|
| 1819 | el = document.createElement("select"); |
|---|
| 1820 | el.title = tooltip; |
|---|
| 1821 | el.style.width = 'auto'; |
|---|
| 1822 | el.name = txt; |
|---|
| 1823 | var obj = |
|---|
| 1824 | { |
|---|
| 1825 | name : txt, |
|---|
| 1826 | element : el, |
|---|
| 1827 | enabled : true, |
|---|
| 1828 | text : false, |
|---|
| 1829 | cmd : cmd, |
|---|
| 1830 | state : setButtonStatus, |
|---|
| 1831 | context : context |
|---|
| 1832 | }; |
|---|
| 1833 | |
|---|
| 1834 | Xinha.freeLater(obj); |
|---|
| 1835 | |
|---|
| 1836 | tb_objects[txt] = obj; |
|---|
| 1837 | |
|---|
| 1838 | for ( var i in options ) |
|---|
| 1839 | { |
|---|
| 1840 | |
|---|
| 1841 | if ( typeof options[i] != 'string' ) |
|---|
| 1842 | { |
|---|
| 1843 | continue; |
|---|
| 1844 | } |
|---|
| 1845 | var op = document.createElement("option"); |
|---|
| 1846 | op.innerHTML = Xinha._lc(i); |
|---|
| 1847 | op.value = options[i]; |
|---|
| 1848 | if (txt =='fontname' && editor.config.showFontStylesInToolbar) |
|---|
| 1849 | { |
|---|
| 1850 | op.style.fontFamily = options[i]; |
|---|
| 1851 | } |
|---|
| 1852 | el.appendChild(op); |
|---|
| 1853 | } |
|---|
| 1854 | Xinha._addEvent(el, "change", function () { editor._comboSelected(el, txt); } ); |
|---|
| 1855 | } |
|---|
| 1856 | return el; |
|---|
| 1857 | } |
|---|
| 1858 | |
|---|
| 1859 | |
|---|
| 1860 | function createButton(txt) |
|---|
| 1861 | { |
|---|
| 1862 | |
|---|
| 1863 | var el, btn, obj = null; |
|---|
| 1864 | switch (txt) |
|---|
| 1865 | { |
|---|
| 1866 | case "separator": |
|---|
| 1867 | if ( editor.config.flowToolbars ) |
|---|
| 1868 | { |
|---|
| 1869 | newLine(); |
|---|
| 1870 | } |
|---|
| 1871 | el = document.createElement("div"); |
|---|
| 1872 | el.className = "separator"; |
|---|
| 1873 | break; |
|---|
| 1874 | case "space": |
|---|
| 1875 | el = document.createElement("div"); |
|---|
| 1876 | el.className = "space"; |
|---|
| 1877 | break; |
|---|
| 1878 | case "linebreak": |
|---|
| 1879 | newLine(); |
|---|
| 1880 | return false; |
|---|
| 1881 | case "textindicator": |
|---|
| 1882 | el = document.createElement("div"); |
|---|
| 1883 | el.appendChild(document.createTextNode("A")); |
|---|
| 1884 | el.className = "indicator"; |
|---|
| 1885 | el.title = Xinha._lc("Current style"); |
|---|
| 1886 | obj = |
|---|
| 1887 | { |
|---|
| 1888 | name : txt, |
|---|
| 1889 | element : el, |
|---|
| 1890 | enabled : true, |
|---|
| 1891 | active : false, |
|---|
| 1892 | text : false, |
|---|
| 1893 | cmd : "textindicator", |
|---|
| 1894 | state : setButtonStatus |
|---|
| 1895 | }; |
|---|
| 1896 | |
|---|
| 1897 | Xinha.freeLater(obj); |
|---|
| 1898 | |
|---|
| 1899 | tb_objects[txt] = obj; |
|---|
| 1900 | break; |
|---|
| 1901 | default: |
|---|
| 1902 | btn = editor.config.btnList[txt]; |
|---|
| 1903 | } |
|---|
| 1904 | if ( !el && btn ) |
|---|
| 1905 | { |
|---|
| 1906 | el = document.createElement("a"); |
|---|
| 1907 | el.style.display = 'block'; |
|---|
| 1908 | el.href = 'javascript:void(0)'; |
|---|
| 1909 | el.style.textDecoration = 'none'; |
|---|
| 1910 | el.title = btn[0]; |
|---|
| 1911 | el.className = "button"; |
|---|
| 1912 | el.style.direction = "ltr"; |
|---|
| 1913 | |
|---|
| 1914 | |
|---|
| 1915 | obj = |
|---|
| 1916 | { |
|---|
| 1917 | name : txt, |
|---|
| 1918 | element : el, |
|---|
| 1919 | enabled : true, |
|---|
| 1920 | active : false, |
|---|
| 1921 | text : btn[2], |
|---|
| 1922 | cmd : btn[3], |
|---|
| 1923 | state : setButtonStatus, |
|---|
| 1924 | context : btn[4] || null |
|---|
| 1925 | }; |
|---|
| 1926 | Xinha.freeLater(el); |
|---|
| 1927 | Xinha.freeLater(obj); |
|---|
| 1928 | |
|---|
| 1929 | tb_objects[txt] = obj; |
|---|
| 1930 | |
|---|
| 1931 | |
|---|
| 1932 | el.ondrag = function() { return false; }; |
|---|
| 1933 | |
|---|
| 1934 | |
|---|
| 1935 | Xinha._addEvent( |
|---|
| 1936 | el, |
|---|
| 1937 | "mouseout", |
|---|
| 1938 | function(ev) |
|---|
| 1939 | { |
|---|
| 1940 | if ( obj.enabled ) |
|---|
| 1941 | { |
|---|
| 1942 | |
|---|
| 1943 | Xinha._removeClass(el, "buttonActive"); |
|---|
| 1944 | if ( obj.active ) |
|---|
| 1945 | { |
|---|
| 1946 | Xinha._addClass(el, "buttonPressed"); |
|---|
| 1947 | } |
|---|
| 1948 | } |
|---|
| 1949 | } |
|---|
| 1950 | ); |
|---|
| 1951 | |
|---|
| 1952 | Xinha._addEvent( |
|---|
| 1953 | el, |
|---|
| 1954 | "mousedown", |
|---|
| 1955 | function(ev) |
|---|
| 1956 | { |
|---|
| 1957 | if ( obj.enabled ) |
|---|
| 1958 | { |
|---|
| 1959 | Xinha._addClass(el, "buttonActive"); |
|---|
| 1960 | Xinha._removeClass(el, "buttonPressed"); |
|---|
| 1961 | Xinha._stopEvent(Xinha.is_ie ? window.event : ev); |
|---|
| 1962 | } |
|---|
| 1963 | } |
|---|
| 1964 | ); |
|---|
| 1965 | |
|---|
| 1966 | |
|---|
| 1967 | Xinha._addEvent( |
|---|
| 1968 | el, |
|---|
| 1969 | "click", |
|---|
| 1970 | function(ev) |
|---|
| 1971 | { |
|---|
| 1972 | ev = ev || window.event; |
|---|
| 1973 | editor.btnClickEvent = {clientX : ev.clientX, clientY : ev.clientY}; |
|---|
| 1974 | if ( obj.enabled ) |
|---|
| 1975 | { |
|---|
| 1976 | Xinha._removeClass(el, "buttonActive"); |
|---|
| 1977 | |
|---|
| 1978 | if ( Xinha.is_gecko ) |
|---|
| 1979 | { |
|---|
| 1980 | editor.activateEditor(); |
|---|
| 1981 | } |
|---|
| 1982 | |
|---|
| 1983 | |
|---|
| 1984 | obj.cmd(editor, obj.name, obj, ev); |
|---|
| 1985 | Xinha._stopEvent(ev); |
|---|
| 1986 | } |
|---|
| 1987 | } |
|---|
| 1988 | ); |
|---|
| 1989 | |
|---|
| 1990 | var i_contain = Xinha.makeBtnImg(btn[1]); |
|---|
| 1991 | var img = i_contain.firstChild; |
|---|
| 1992 | Xinha.freeLater(i_contain); |
|---|
| 1993 | Xinha.freeLater(img); |
|---|
| 1994 | |
|---|
| 1995 | el.appendChild(i_contain); |
|---|
| 1996 | |
|---|
| 1997 | obj.imgel = img; |
|---|
| 1998 | obj.swapImage = function(newimg) |
|---|
| 1999 | { |
|---|
| 2000 | if ( typeof newimg != 'string' ) |
|---|
| 2001 | { |
|---|
| 2002 | img.src = newimg[0]; |
|---|
| 2003 | img.style.position = 'relative'; |
|---|
| 2004 | img.style.top = newimg[2] ? ('-' + (18 * (newimg[2] + 1)) + 'px') : '-18px'; |
|---|
| 2005 | img.style.left = newimg[1] ? ('-' + (18 * (newimg[1] + 1)) + 'px') : '-18px'; |
|---|
| 2006 | } |
|---|
| 2007 | else |
|---|
| 2008 | { |
|---|
| 2009 | obj.imgel.src = newimg; |
|---|
| 2010 | img.style.top = '0px'; |
|---|
| 2011 | img.style.left = '0px'; |
|---|
| 2012 | } |
|---|
| 2013 | }; |
|---|
| 2014 | |
|---|
| 2015 | } |
|---|
| 2016 | else if( !el ) |
|---|
| 2017 | { |
|---|
| 2018 | el = createSelect(txt); |
|---|
| 2019 | } |
|---|
| 2020 | |
|---|
| 2021 | return el; |
|---|
| 2022 | } |
|---|
| 2023 | |
|---|
| 2024 | var first = true; |
|---|
| 2025 | for ( var i = 0; i < this.config.toolbar.length; ++i ) |
|---|
| 2026 | { |
|---|
| 2027 | if ( !first ) |
|---|
| 2028 | { |
|---|
| 2029 | |
|---|
| 2030 | } |
|---|
| 2031 | else |
|---|
| 2032 | { |
|---|
| 2033 | first = false; |
|---|
| 2034 | } |
|---|
| 2035 | if ( this.config.toolbar[i] === null ) |
|---|
| 2036 | { |
|---|
| 2037 | this.config.toolbar[i] = ['separator']; |
|---|
| 2038 | } |
|---|
| 2039 | var group = this.config.toolbar[i]; |
|---|
| 2040 | |
|---|
| 2041 | for ( var j = 0; j < group.length; ++j ) |
|---|
| 2042 | { |
|---|
| 2043 | var code = group[j]; |
|---|
| 2044 | var tb_cell; |
|---|
| 2045 | if ( /^([IT])\[(.*?)\]/.test(code) ) |
|---|
| 2046 | { |
|---|
| 2047 | |
|---|
| 2048 | var l7ed = RegExp.$1 == "I"; |
|---|
| 2049 | var label = RegExp.$2; |
|---|
| 2050 | if ( l7ed ) |
|---|
| 2051 | { |
|---|
| 2052 | label = Xinha._lc(label); |
|---|
| 2053 | } |
|---|
| 2054 | tb_cell = document.createElement("td"); |
|---|
| 2055 | tb_row.appendChild(tb_cell); |
|---|
| 2056 | tb_cell.className = "label"; |
|---|
| 2057 | tb_cell.innerHTML = label; |
|---|
| 2058 | } |
|---|
| 2059 | else if ( typeof code != 'function' ) |
|---|
| 2060 | { |
|---|
| 2061 | var tb_element = createButton(code); |
|---|
| 2062 | if ( tb_element ) |
|---|
| 2063 | { |
|---|
| 2064 | tb_cell = document.createElement("td"); |
|---|
| 2065 | tb_cell.className = 'toolbarElement'; |
|---|
| 2066 | tb_row.appendChild(tb_cell); |
|---|
| 2067 | tb_cell.appendChild(tb_element); |
|---|
| 2068 | } |
|---|
| 2069 | else if ( tb_element === null ) |
|---|
| 2070 | { |
|---|
| 2071 | alert("FIXME: Unknown toolbar item: " + code); |
|---|
| 2072 | } |
|---|
| 2073 | } |
|---|
| 2074 | } |
|---|
| 2075 | } |
|---|
| 2076 | |
|---|
| 2077 | if ( editor.config.flowToolbars ) |
|---|
| 2078 | { |
|---|
| 2079 | toolbar.appendChild(Xinha._createToolbarBreakingElement()); |
|---|
| 2080 | } |
|---|
| 2081 | |
|---|
| 2082 | return toolbar; |
|---|
| 2083 | }; |
|---|
| 2084 | |
|---|
| 2085 | |
|---|
| 2086 | |
|---|
| 2087 | |
|---|
| 2088 | |
|---|
| 2089 | Xinha.makeBtnImg = function(imgDef, doc) |
|---|
| 2090 | { |
|---|
| 2091 | if ( !doc ) |
|---|
| 2092 | { |
|---|
| 2093 | doc = document; |
|---|
| 2094 | } |
|---|
| 2095 | |
|---|
| 2096 | if ( !doc._xinhaImgCache ) |
|---|
| 2097 | { |
|---|
| 2098 | doc._xinhaImgCache = {}; |
|---|
| 2099 | Xinha.freeLater(doc._xinhaImgCache); |
|---|
| 2100 | } |
|---|
| 2101 | |
|---|
| 2102 | var i_contain = null; |
|---|
| 2103 | if ( Xinha.is_ie && ( ( !doc.compatMode ) || ( doc.compatMode && doc.compatMode == "BackCompat" ) ) ) |
|---|
| 2104 | { |
|---|
| 2105 | i_contain = doc.createElement('span'); |
|---|
| 2106 | } |
|---|
| 2107 | else |
|---|
| 2108 | { |
|---|
| 2109 | i_contain = doc.createElement('div'); |
|---|
| 2110 | i_contain.style.position = 'relative'; |
|---|
| 2111 | } |
|---|
| 2112 | |
|---|
| 2113 | i_contain.style.overflow = 'hidden'; |
|---|
| 2114 | i_contain.style.width = "18px"; |
|---|
| 2115 | i_contain.style.height = "18px"; |
|---|
| 2116 | i_contain.className = 'buttonImageContainer'; |
|---|
| 2117 | |
|---|
| 2118 | var img = null; |
|---|
| 2119 | if ( typeof imgDef == 'string' ) |
|---|
| 2120 | { |
|---|
| 2121 | if ( doc._xinhaImgCache[imgDef] ) |
|---|
| 2122 | { |
|---|
| 2123 | img = doc._xinhaImgCache[imgDef].cloneNode(); |
|---|
| 2124 | } |
|---|
| 2125 | else |
|---|
| 2126 | { |
|---|
| 2127 | if (Xinha.ie_version < 7 && /\.png$/.test(imgDef[0])) |
|---|
| 2128 | { |
|---|
| 2129 | img = doc.createElement("span"); |
|---|
| 2130 | |
|---|
| 2131 | img.style.display = 'block'; |
|---|
| 2132 | img.style.width = '18px'; |
|---|
| 2133 | img.style.height = '18px'; |
|---|
| 2134 | img.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+imgDef+'")'; |
|---|
| 2135 | img.unselectable = 'on'; |
|---|
| 2136 | } |
|---|
| 2137 | else |
|---|
| 2138 | { |
|---|
| 2139 | img = doc.createElement("img"); |
|---|
| 2140 | img.src = imgDef; |
|---|
| 2141 | } |
|---|
| 2142 | } |
|---|
| 2143 | } |
|---|
| 2144 | else |
|---|
| 2145 | { |
|---|
| 2146 | if ( doc._xinhaImgCache[imgDef[0]] ) |
|---|
| 2147 | { |
|---|
| 2148 | img = doc._xinhaImgCache[imgDef[0]].cloneNode(); |
|---|
| 2149 | } |
|---|
| 2150 | else |
|---|
| 2151 | { |
|---|
| 2152 | if (Xinha.ie_version < 7 && /\.png$/.test(imgDef[0])) |
|---|
| 2153 | { |
|---|
| 2154 | img = doc.createElement("span"); |
|---|
| 2155 | img.style.display = 'block'; |
|---|
| 2156 | img.style.width = '18px'; |
|---|
| 2157 | img.style.height = '18px'; |
|---|
| 2158 | img.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+imgDef[0]+'")'; |
|---|
| 2159 | img.unselectable = 'on'; |
|---|
| 2160 | } |
|---|
| 2161 | else |
|---|
| 2162 | { |
|---|
| 2163 | img = doc.createElement("img"); |
|---|
| 2164 | img.src = imgDef[0]; |
|---|
| 2165 | } |
|---|
| 2166 | img.style.position = 'relative'; |
|---|
| 2167 | } |
|---|
| 2168 | |
|---|
| 2169 | |
|---|
| 2170 | |
|---|
| 2171 | img.style.top = imgDef[2] ? ('-' + (18 * (imgDef[2] + 1)) + 'px') : '-18px'; |
|---|
| 2172 | img.style.left = imgDef[1] ? ('-' + (18 * (imgDef[1] + 1)) + 'px') : '-18px'; |
|---|
| 2173 | } |
|---|
| 2174 | i_contain.appendChild(img); |
|---|
| 2175 | return i_contain; |
|---|
| 2176 | }; |
|---|
| 2177 | |
|---|
| 2178 | |
|---|
| 2179 | |
|---|
| 2180 | |
|---|
| 2181 | Xinha.prototype._createStatusBar = function() |
|---|
| 2182 | { |
|---|
| 2183 | |
|---|
| 2184 | this.setLoadingMessage(Xinha._lc('Create Statusbar')); |
|---|
| 2185 | var statusBar = document.createElement("div"); |
|---|
| 2186 | statusBar.style.position = "relative"; |
|---|
| 2187 | statusBar.className = "statusBar"; |
|---|
| 2188 | statusBar.style.width = "100%"; |
|---|
| 2189 | Xinha.freeLater(this, '_statusBar'); |
|---|
| 2190 | |
|---|
| 2191 | var widgetContainer = document.createElement("div"); |
|---|
| 2192 | widgetContainer.className = "statusBarWidgetContainer"; |
|---|
| 2193 | widgetContainer.style.position = "absolute"; |
|---|
| 2194 | widgetContainer.style.right = "0"; |
|---|
| 2195 | widgetContainer.style.top = "0"; |
|---|
| 2196 | widgetContainer.style.padding = "3px 3px 3px 10px"; |
|---|
| 2197 | statusBar.appendChild(widgetContainer); |
|---|
| 2198 | |
|---|
| 2199 | |
|---|
| 2200 | |
|---|
| 2201 | var statusBarTree = document.createElement("span"); |
|---|
| 2202 | statusBarTree.className = "statusBarTree"; |
|---|
| 2203 | statusBarTree.innerHTML = Xinha._lc("Path") + ": "; |
|---|
| 2204 | |
|---|
| 2205 | this._statusBarTree = statusBarTree; |
|---|
| 2206 | Xinha.freeLater(this, '_statusBarTree'); |
|---|
| 2207 | statusBar.appendChild(statusBarTree); |
|---|
| 2208 | var statusBarTextMode = document.createElement("span"); |
|---|
| 2209 | statusBarTextMode.innerHTML = Xinha.htmlEncode(Xinha._lc("You are in TEXT MODE. Use the [<>] button to switch back to WYSIWYG.")); |
|---|
| 2210 | statusBarTextMode.style.display = "none"; |
|---|
| 2211 | |
|---|
| 2212 | this._statusBarTextMode = statusBarTextMode; |
|---|
| 2213 | Xinha.freeLater(this, '_statusBarTextMode'); |
|---|
| 2214 | statusBar.appendChild(statusBarTextMode); |
|---|
| 2215 | |
|---|
| 2216 | statusBar.style.whiteSpace = "nowrap"; |
|---|
| 2217 | |
|---|
| 2218 | var self = this; |
|---|
| 2219 | this.notifyOn("before_resize", function(evt, size) { |
|---|
| 2220 | self._statusBar.style.width = null; |
|---|
| 2221 | }); |
|---|
| 2222 | this.notifyOn("resize", function(evt, size) { |
|---|
| 2223 | |
|---|
| 2224 | |
|---|
| 2225 | |
|---|
| 2226 | |
|---|
| 2227 | if (Xinha.is_ie && Xinha.ie_version == 6) |
|---|
| 2228 | { |
|---|
| 2229 | self._statusBar.style.width = "100%"; |
|---|
| 2230 | } |
|---|
| 2231 | else |
|---|
| 2232 | { |
|---|
| 2233 | var width = size['width']; |
|---|
| 2234 | self._statusBar.style.width = width + "px"; |
|---|
| 2235 | } |
|---|
| 2236 | }); |
|---|
| 2237 | |
|---|
| 2238 | this.notifyOn("modechange", function(evt, mode) { |
|---|
| 2239 | |
|---|
| 2240 | |
|---|
| 2241 | |
|---|
| 2242 | for (var i in self._statusWidgets) |
|---|
| 2243 | { |
|---|
| 2244 | var widget = self._statusWidgets[i]; |
|---|
| 2245 | for (var index=0; index<widget.modes.length; index++) |
|---|
| 2246 | { |
|---|
| 2247 | if (widget.modes[index] == mode.mode) |
|---|
| 2248 | { |
|---|
| 2249 | var found = true; |
|---|
| 2250 | } |
|---|
| 2251 | } |
|---|
| 2252 | if (typeof found == 'undefined') |
|---|
| 2253 | { |
|---|
| 2254 | widget.block.style.display = "none"; |
|---|
| 2255 | } |
|---|
| 2256 | else |
|---|
| 2257 | { |
|---|
| 2258 | widget.block.style.display = ""; |
|---|
| 2259 | } |
|---|
| 2260 | } |
|---|
| 2261 | }); |
|---|
| 2262 | |
|---|
| 2263 | if ( !this.config.statusBar ) |
|---|
| 2264 | { |
|---|
| 2265 | |
|---|
| 2266 | statusBar.style.display = "none"; |
|---|
| 2267 | } |
|---|
| 2268 | return statusBar; |
|---|
| 2269 | }; |
|---|
| 2270 | |
|---|
| 2271 | |
|---|
| 2272 | |
|---|
| 2273 | |
|---|
| 2274 | |
|---|
| 2275 | |
|---|
| 2276 | |
|---|
| 2277 | Xinha.prototype.registerStatusWidget = function(id, modes) |
|---|
| 2278 | { |
|---|
| 2279 | modes = modes || ['wysiwyg']; |
|---|
| 2280 | if (!this._statusWidgets) |
|---|
| 2281 | { |
|---|
| 2282 | this._statusWidgets = {}; |
|---|
| 2283 | } |
|---|
| 2284 | |
|---|
| 2285 | var block = document.createElement("div"); |
|---|
| 2286 | block.className = "statusBarWidget"; |
|---|
| 2287 | block = this._statusBar.firstChild.appendChild(block); |
|---|
| 2288 | |
|---|
| 2289 | var showWidget = false; |
|---|
| 2290 | for (var i=0; i<modes.length; i++) |
|---|
| 2291 | { |
|---|
| 2292 | if (modes[i] == this._editMode) |
|---|
| 2293 | { |
|---|
| 2294 | showWidget = true; |
|---|
| 2295 | } |
|---|
| 2296 | } |
|---|
| 2297 | block.style.display = showWidget == true ? "" : "none"; |
|---|
| 2298 | |
|---|
| 2299 | this._statusWidgets[id] = {block: block, modes: modes}; |
|---|
| 2300 | return block; |
|---|
| 2301 | }; |
|---|
| 2302 | |
|---|
| 2303 | |
|---|
| 2304 | |
|---|
| 2305 | |
|---|
| 2306 | Xinha.prototype.generate = function () |
|---|
| 2307 | { |
|---|
| 2308 | if ( !Xinha.isSupportedBrowser ) |
|---|
| 2309 | { |
|---|
| 2310 | return; |
|---|
| 2311 | } |
|---|
| 2312 | |
|---|
| 2313 | var i; |
|---|
| 2314 | var editor = this; |
|---|
| 2315 | var url; |
|---|
| 2316 | var found = false; |
|---|
| 2317 | var links = document.getElementsByTagName("link"); |
|---|
| 2318 | |
|---|
| 2319 | if (!document.getElementById("XinhaCoreDesign")) |
|---|
| 2320 | { |
|---|
| 2321 | _editor_css = (typeof _editor_css == "string") ? _editor_css : "Xinha.css"; |
|---|
| 2322 | for(i = 0; i<links.length; i++) |
|---|
| 2323 | { |
|---|
| 2324 | if ( ( links[i].rel == "stylesheet" ) && ( links[i].href == _editor_url + _editor_css ) ) |
|---|
| 2325 | { |
|---|
| 2326 | found = true; |
|---|
| 2327 | } |
|---|
| 2328 | } |
|---|
| 2329 | if ( !found ) |
|---|
| 2330 | { |
|---|
| 2331 | Xinha.loadStyle(_editor_css,null,"XinhaCoreDesign",true); |
|---|
| 2332 | } |
|---|
| 2333 | } |
|---|
| 2334 | |
|---|
| 2335 | if ( _editor_skin !== "" && !document.getElementById("XinhaSkin")) |
|---|
| 2336 | { |
|---|
| 2337 | found = false; |
|---|
| 2338 | for(i = 0; i<links.length; i++) |
|---|
| 2339 | { |
|---|
| 2340 | if ( ( links[i].rel == "stylesheet" ) && ( links[i].href == _editor_url + 'skins/' + _editor_skin + '/skin.css' ) ) |
|---|
| 2341 | { |
|---|
| 2342 | found = true; |
|---|
| 2343 | } |
|---|
| 2344 | } |
|---|
| 2345 | if ( !found ) |
|---|
| 2346 | { |
|---|
| 2347 | Xinha.loadStyle('skins/' + _editor_skin + '/skin.css',null,"XinhaSkin"); |
|---|
| 2348 | } |
|---|
| 2349 | } |
|---|
| 2350 | var callback = function() { editor.generate(); }; |
|---|
| 2351 | |
|---|
| 2352 | if (Xinha.is_ie) |
|---|
| 2353 | { |
|---|
| 2354 | url = _editor_url + 'modules/InternetExplorer/InternetExplorer.js'; |
|---|
| 2355 | if ( !Xinha.loadPlugins([{plugin:"InternetExplorer",url:url}], callback ) ) |
|---|
| 2356 | { |
|---|
| 2357 | return false; |
|---|
| 2358 | } |
|---|
| 2359 | if (!this.plugins.InternetExplorer) |
|---|
| 2360 | { |
|---|
| 2361 | editor._browserSpecificPlugin = editor.registerPlugin('InternetExplorer'); |
|---|
| 2362 | } |
|---|
| 2363 | } |
|---|
| 2364 | else if (Xinha.is_webkit) |
|---|
| 2365 | { |
|---|
| 2366 | url = _editor_url + 'modules/WebKit/WebKit.js'; |
|---|
| 2367 | if ( !Xinha.loadPlugins([{plugin:"WebKit",url:url}], callback ) ) |
|---|
| 2368 | { |
|---|
| 2369 | return false; |
|---|
| 2370 | } |
|---|
| 2371 | if (!this.plugins.Webkit) |
|---|
| 2372 | { |
|---|
| 2373 | editor._browserSpecificPlugin = editor.registerPlugin('WebKit'); |
|---|
| 2374 | } |
|---|
| 2375 | } |
|---|
| 2376 | else if (Xinha.is_opera) |
|---|
| 2377 | { |
|---|
| 2378 | url = _editor_url + 'modules/Opera/Opera.js'; |
|---|
| 2379 | if ( !Xinha.loadPlugins([{plugin:"Opera",url:url}], callback ) ) |
|---|
| 2380 | { |
|---|
| 2381 | return false; |
|---|
| 2382 | } |
|---|
| 2383 | if (!this.plugins.Opera) |
|---|
| 2384 | { |
|---|
| 2385 | editor._browserSpecificPlugin = editor.registerPlugin('Opera'); |
|---|
| 2386 | } |
|---|
| 2387 | } |
|---|
| 2388 | else if (Xinha.is_gecko) |
|---|
| 2389 | { |
|---|
| 2390 | url = _editor_url + 'modules/Gecko/Gecko.js'; |
|---|
| 2391 | if ( !Xinha.loadPlugins([{plugin:"Gecko",url:url}], callback ) ) |
|---|
| 2392 | { |
|---|
| 2393 | return false; |
|---|
| 2394 | } |
|---|
| 2395 | if (!this.plugins.Gecko) |
|---|
| 2396 | { |
|---|
| 2397 | editor._browserSpecificPlugin = editor.registerPlugin('Gecko'); |
|---|
| 2398 | } |
|---|
| 2399 | } |
|---|
| 2400 | |
|---|
| 2401 | if ( typeof Dialog == 'undefined' && !Xinha._loadback( _editor_url + 'modules/Dialogs/dialog.js', callback, this ) ) |
|---|
| 2402 | { |
|---|
| 2403 | return false; |
|---|
| 2404 | } |
|---|
| 2405 | |
|---|
| 2406 | if ( typeof Xinha.Dialog == 'undefined' && !Xinha._loadback( _editor_url + 'modules/Dialogs/XinhaDialog.js' , callback, this ) ) |
|---|
| 2407 | { |
|---|
| 2408 | return false; |
|---|
| 2409 | } |
|---|
| 2410 | |
|---|
| 2411 | url = _editor_url + 'modules/FullScreen/full-screen.js'; |
|---|
| 2412 | if ( !Xinha.loadPlugins([{plugin:"FullScreen",url:url}], callback )) |
|---|
| 2413 | { |
|---|
| 2414 | return false; |
|---|
| 2415 | } |
|---|
| 2416 | |
|---|
| 2417 | url = _editor_url + 'modules/ColorPicker/ColorPicker.js'; |
|---|
| 2418 | if ( !Xinha.loadPlugins([{plugin:"ColorPicker",url:url}], callback ) ) |
|---|
| 2419 | { |
|---|
| 2420 | return false; |
|---|
| 2421 | } |
|---|
| 2422 | else if ( typeof Xinha.getPluginConstructor('ColorPicker') != 'undefined' && !this.plugins.colorPicker) |
|---|
| 2423 | { |
|---|
| 2424 | editor.registerPlugin('ColorPicker'); |
|---|
| 2425 | } |
|---|
| 2426 | |
|---|
| 2427 | var toolbar = editor.config.toolbar; |
|---|
| 2428 | for ( i = toolbar.length; --i >= 0; ) |
|---|
| 2429 | { |
|---|
| 2430 | for ( var j = toolbar[i].length; --j >= 0; ) |
|---|
| 2431 | { |
|---|
| 2432 | switch (toolbar[i][j]) |
|---|
| 2433 | { |
|---|
| 2434 | case "popupeditor": |
|---|
| 2435 | case "fullscreen": |
|---|
| 2436 | if (!this.plugins.FullScreen) |
|---|
| 2437 | { |
|---|
| 2438 | editor.registerPlugin('FullScreen'); |
|---|
| 2439 | } |
|---|
| 2440 | break; |
|---|
| 2441 | case "insertimage": |
|---|
| 2442 | url = _editor_url + 'modules/InsertImage/insert_image.js'; |
|---|
| 2443 | if ( typeof Xinha.prototype._insertImage == 'undefined' && !Xinha.loadPlugins([{plugin:"InsertImage",url:url}], callback ) ) |
|---|
| 2444 | { |
|---|
| 2445 | return false; |
|---|
| 2446 | } |
|---|
| 2447 | else if ( typeof Xinha.getPluginConstructor('InsertImage') != 'undefined' && !this.plugins.InsertImage) |
|---|
| 2448 | { |
|---|
| 2449 | editor.registerPlugin('InsertImage'); |
|---|
| 2450 | } |
|---|
| 2451 | break; |
|---|
| 2452 | case "createlink": |
|---|
| 2453 | url = _editor_url + 'modules/CreateLink/link.js'; |
|---|
| 2454 | if ( typeof Xinha.getPluginConstructor('Linker') == 'undefined' && !Xinha.loadPlugins([{plugin:"CreateLink",url:url}], callback )) |
|---|
| 2455 | { |
|---|
| 2456 | return false; |
|---|
| 2457 | } |
|---|
| 2458 | else if ( typeof Xinha.getPluginConstructor('CreateLink') != 'undefined' && !this.plugins.CreateLink) |
|---|
| 2459 | { |
|---|
| 2460 | editor.registerPlugin('CreateLink'); |
|---|
| 2461 | } |
|---|
| 2462 | break; |
|---|
| 2463 | case "inserttable": |
|---|
| 2464 | url = _editor_url + 'modules/InsertTable/insert_table.js'; |
|---|
| 2465 | if ( !Xinha.loadPlugins([{plugin:"InsertTable",url:url}], callback ) ) |
|---|
| 2466 | { |
|---|
| 2467 | return false; |
|---|
| 2468 | } |
|---|
| 2469 | else if ( typeof Xinha.getPluginConstructor('InsertTable') != 'undefined' && !this.plugins.InsertTable) |
|---|
| 2470 | { |
|---|
| 2471 | editor.registerPlugin('InsertTable'); |
|---|
| 2472 | } |
|---|
| 2473 | break; |
|---|
| 2474 | case "about": |
|---|
| 2475 | url = _editor_url + 'modules/AboutBox/AboutBox.js'; |
|---|
| 2476 | if ( !Xinha.loadPlugins([{plugin:"AboutBox",url:url}], callback ) ) |
|---|
| 2477 | { |
|---|
| 2478 | return false; |
|---|
| 2479 | } |
|---|
| 2480 | else if ( typeof Xinha.getPluginConstructor('AboutBox') != 'undefined' && !this.plugins.AboutBox) |
|---|
| 2481 | { |
|---|
| 2482 | editor.registerPlugin('AboutBox'); |
|---|
| 2483 | } |
|---|
| 2484 | break; |
|---|
| 2485 | } |
|---|
| 2486 | } |
|---|
| 2487 | } |
|---|
| 2488 | |
|---|
| 2489 | |
|---|
| 2490 | if ( Xinha.is_gecko && editor.config.mozParaHandler != 'built-in' ) |
|---|
| 2491 | { |
|---|
| 2492 | if ( !Xinha.loadPlugins([{plugin:"EnterParagraphs",url: _editor_url + 'modules/Gecko/paraHandlerBest.js'}], callback ) ) |
|---|
| 2493 | { |
|---|
| 2494 | return false; |
|---|
| 2495 | } |
|---|
| 2496 | if (!this.plugins.EnterParagraphs) |
|---|
| 2497 | { |
|---|
| 2498 | editor.registerPlugin('EnterParagraphs'); |
|---|
| 2499 | } |
|---|
| 2500 | } |
|---|
| 2501 | var getHtmlMethodPlugin = this.config.getHtmlMethod == 'TransformInnerHTML' ? _editor_url + 'modules/GetHtml/TransformInnerHTML.js' : _editor_url + 'modules/GetHtml/DOMwalk.js'; |
|---|
| 2502 | |
|---|
| 2503 | if ( !Xinha.loadPlugins([{plugin:"GetHtmlImplementation",url:getHtmlMethodPlugin}], callback)) |
|---|
| 2504 | { |
|---|
| 2505 | return false; |
|---|
| 2506 | } |
|---|
| 2507 | else if (!this.plugins.GetHtmlImplementation) |
|---|
| 2508 | { |
|---|
| 2509 | editor.registerPlugin('GetHtmlImplementation'); |
|---|
| 2510 | } |
|---|
| 2511 | function getTextContent(node) |
|---|
| 2512 | { |
|---|
| 2513 | return node.textContent || node.text; |
|---|
| 2514 | } |
|---|
| 2515 | if (_editor_skin) |
|---|
| 2516 | { |
|---|
| 2517 | this.skinInfo = {}; |
|---|
| 2518 | var skinXML = Xinha._geturlcontent(_editor_url + 'skins/' + _editor_skin + '/skin.xml', true); |
|---|
| 2519 | if (skinXML) |
|---|
| 2520 | { |
|---|
| 2521 | var meta = skinXML.getElementsByTagName('meta'); |
|---|
| 2522 | for (i=0;i<meta.length;i++) |
|---|
| 2523 | { |
|---|
| 2524 | this.skinInfo[meta[i].getAttribute('name')] = meta[i].getAttribute('value'); |
|---|
| 2525 | } |
|---|
| 2526 | var recommendedIcons = skinXML.getElementsByTagName('recommendedIcons'); |
|---|
| 2527 | if (!_editor_icons && recommendedIcons.length && getTextContent(recommendedIcons[0])) |
|---|
| 2528 | { |
|---|
| 2529 | _editor_icons = getTextContent(recommendedIcons[0]); |
|---|
| 2530 | } |
|---|
| 2531 | } |
|---|
| 2532 | } |
|---|
| 2533 | if (_editor_icons) |
|---|
| 2534 | { |
|---|
| 2535 | var iconsXML = Xinha._geturlcontent(_editor_url + 'iconsets/' + _editor_icons + '/iconset.xml', true); |
|---|
| 2536 | |
|---|
| 2537 | if (iconsXML) |
|---|
| 2538 | { |
|---|
| 2539 | var icons = iconsXML.getElementsByTagName('icon'); |
|---|
| 2540 | var icon, id, path, type, x, y; |
|---|
| 2541 | |
|---|
| 2542 | for (i=0;i<icons.length;i++) |
|---|
| 2543 | { |
|---|
| 2544 | icon = icons[i]; |
|---|
| 2545 | id = icon.getAttribute('id'); |
|---|
| 2546 | |
|---|
| 2547 | if (icon.getElementsByTagName(_editor_lang).length) |
|---|
| 2548 | { |
|---|
| 2549 | icon = icon.getElementsByTagName(_editor_lang)[0]; |
|---|
| 2550 | } |
|---|
| 2551 | else |
|---|
| 2552 | { |
|---|
| 2553 | icon = icon.getElementsByTagName('default')[0]; |
|---|
| 2554 | } |
|---|
| 2555 | path = getTextContent(icon.getElementsByTagName('path')[0]); |
|---|
| 2556 | path = (!/^\ |
|---|
| 2557 | type = icon.getAttribute('type'); |
|---|
| 2558 | if (type == 'map') |
|---|
| 2559 | { |
|---|
| 2560 | x = parseInt(getTextContent(icon.getElementsByTagName('x')[0]), 10); |
|---|
| 2561 | y = parseInt(getTextContent(icon.getElementsByTagName('y')[0]), 10); |
|---|
| 2562 | if (this.config.btnList[id]) |
|---|
| 2563 | { |
|---|
| 2564 | this.config.btnList[id][1] = [path, x, y]; |
|---|
| 2565 | } |
|---|
| 2566 | if (this.config.iconList[id]) |
|---|
| 2567 | { |
|---|
| 2568 | this.config.iconList[id] = [path, x, y]; |
|---|
| 2569 | } |
|---|
| 2570 | |
|---|
| 2571 | } |
|---|
| 2572 | else |
|---|
| 2573 | { |
|---|
| 2574 | if (this.config.btnList[id]) |
|---|
| 2575 | { |
|---|
| 2576 | this.config.btnList[id][1] = path; |
|---|
| 2577 | } |
|---|
| 2578 | if (this.config.iconList[id]) |
|---|
| 2579 | { |
|---|
| 2580 | this.config.iconList[id] = path; |
|---|
| 2581 | } |
|---|
| 2582 | } |
|---|
| 2583 | } |
|---|
| 2584 | } |
|---|
| 2585 | } |
|---|
| 2586 | |
|---|
| 2587 | |
|---|
| 2588 | |
|---|
| 2589 | |
|---|
| 2590 | this.setLoadingMessage(Xinha._lc('Generate Xinha framework')); |
|---|
| 2591 | |
|---|
| 2592 | this._framework = |
|---|
| 2593 | { |
|---|
| 2594 | 'table': document.createElement('table'), |
|---|
| 2595 | 'tbody': document.createElement('tbody'), |
|---|
| 2596 | 'tb_row': document.createElement('tr'), |
|---|
| 2597 | 'tb_cell': document.createElement('td'), |
|---|
| 2598 | |
|---|
| 2599 | 'tp_row': document.createElement('tr'), |
|---|
| 2600 | 'tp_cell': this._panels.top.container, |
|---|
| 2601 | |
|---|
| 2602 | 'ler_row': document.createElement('tr'), |
|---|
| 2603 | 'lp_cell': this._panels.left.container, |
|---|
| 2604 | 'ed_cell': document.createElement('td'), |
|---|
| 2605 | 'rp_cell': this._panels.right.container, |
|---|
| 2606 | |
|---|
| 2607 | 'bp_row': document.createElement('tr'), |
|---|
| 2608 | 'bp_cell': this._panels.bottom.container, |
|---|
| 2609 | |
|---|
| 2610 | 'sb_row': document.createElement('tr'), |
|---|
| 2611 | 'sb_cell': document.createElement('td') |
|---|
| 2612 | |
|---|
| 2613 | }; |
|---|
| 2614 | Xinha.freeLater(this._framework); |
|---|
| 2615 | |
|---|
| 2616 | var fw = this._framework; |
|---|
| 2617 | fw.table.border = "0"; |
|---|
| 2618 | fw.table.cellPadding = "0"; |
|---|
| 2619 | fw.table.cellSpacing = "0"; |
|---|
| 2620 | |
|---|
| 2621 | fw.tb_row.style.verticalAlign = 'top'; |
|---|
| 2622 | fw.tp_row.style.verticalAlign = 'top'; |
|---|
| 2623 | fw.ler_row.style.verticalAlign= 'top'; |
|---|
| 2624 | fw.bp_row.style.verticalAlign = 'top'; |
|---|
| 2625 | fw.sb_row.style.verticalAlign = 'top'; |
|---|
| 2626 | fw.ed_cell.style.position = 'relative'; |
|---|
| 2627 | |
|---|
| 2628 | |
|---|
| 2629 | |
|---|
| 2630 | |
|---|
| 2631 | |
|---|
| 2632 | |
|---|
| 2633 | fw.tb_row.appendChild(fw.tb_cell); |
|---|
| 2634 | fw.tb_cell.colSpan = 3; |
|---|
| 2635 | |
|---|
| 2636 | fw.tp_row.appendChild(fw.tp_cell); |
|---|
| 2637 | fw.tp_cell.colSpan = 3; |
|---|
| 2638 | |
|---|
| 2639 | fw.ler_row.appendChild(fw.lp_cell); |
|---|
| 2640 | fw.ler_row.appendChild(fw.ed_cell); |
|---|
| 2641 | fw.ler_row.appendChild(fw.rp_cell); |
|---|
| 2642 | |
|---|
| 2643 | fw.bp_row.appendChild(fw.bp_cell); |
|---|
| 2644 | fw.bp_cell.colSpan = 3; |
|---|
| 2645 | |
|---|
| 2646 | fw.sb_row.appendChild(fw.sb_cell); |
|---|
| 2647 | fw.sb_cell.colSpan = 3; |
|---|
| 2648 | |
|---|
| 2649 | |
|---|
| 2650 | fw.tbody.appendChild(fw.tb_row); |
|---|
| 2651 | fw.tbody.appendChild(fw.tp_row); |
|---|
| 2652 | fw.tbody.appendChild(fw.ler_row); |
|---|
| 2653 | fw.tbody.appendChild(fw.bp_row); |
|---|
| 2654 | fw.tbody.appendChild(fw.sb_row); |
|---|
| 2655 | |
|---|
| 2656 | |
|---|
| 2657 | fw.table.appendChild(fw.tbody); |
|---|
| 2658 | |
|---|
| 2659 | var xinha = fw.table; |
|---|
| 2660 | this._htmlArea = xinha; |
|---|
| 2661 | Xinha.freeLater(this, '_htmlArea'); |
|---|
| 2662 | xinha.className = "htmlarea"; |
|---|
| 2663 | |
|---|
| 2664 | |
|---|
| 2665 | fw.tb_cell.appendChild( this._createToolbar() ); |
|---|
| 2666 | |
|---|
| 2667 | |
|---|
| 2668 | var iframe = document.createElement("iframe"); |
|---|
| 2669 | iframe.src = this.popupURL(editor.config.URIs.blank); |
|---|
| 2670 | iframe.id = "XinhaIFrame_" + this._textArea.id; |
|---|
| 2671 | fw.ed_cell.appendChild(iframe); |
|---|
| 2672 | this._iframe = iframe; |
|---|
| 2673 | this._iframe.className = 'xinha_iframe'; |
|---|
| 2674 | Xinha.freeLater(this, '_iframe'); |
|---|
| 2675 | |
|---|
| 2676 | |
|---|
| 2677 | var statusbar = this._createStatusBar(); |
|---|
| 2678 | this._statusBar = fw.sb_cell.appendChild(statusbar); |
|---|
| 2679 | |
|---|
| 2680 | |
|---|
| 2681 | |
|---|
| 2682 | var textarea = this._textArea; |
|---|
| 2683 | textarea.parentNode.insertBefore(xinha, textarea); |
|---|
| 2684 | textarea.className = 'xinha_textarea'; |
|---|
| 2685 | |
|---|
| 2686 | |
|---|
| 2687 | Xinha.removeFromParent(textarea); |
|---|
| 2688 | fw.ed_cell.appendChild(textarea); |
|---|
| 2689 | |
|---|
| 2690 | |
|---|
| 2691 | Xinha.addDom0Event( |
|---|
| 2692 | this._textArea, |
|---|
| 2693 | 'click', |
|---|
| 2694 | function() |
|---|
| 2695 | { |
|---|
| 2696 | if ( Xinha._currentlyActiveEditor != this) |
|---|
| 2697 | { |
|---|
| 2698 | editor.updateToolbar(); |
|---|
| 2699 | } |
|---|
| 2700 | return true; |
|---|
| 2701 | }); |
|---|
| 2702 | |
|---|
| 2703 | |
|---|
| 2704 | if ( textarea.form ) |
|---|
| 2705 | { |
|---|
| 2706 | |
|---|
| 2707 | Xinha.prependDom0Event( |
|---|
| 2708 | this._textArea.form, |
|---|
| 2709 | 'submit', |
|---|
| 2710 | function() |
|---|
| 2711 | { |
|---|
| 2712 | editor.firePluginEvent('onBeforeSubmit'); |
|---|
| 2713 | editor._textArea.value = editor.outwardHtml(editor.getHTML()); |
|---|
| 2714 | return true; |
|---|
| 2715 | } |
|---|
| 2716 | ); |
|---|
| 2717 | |
|---|
| 2718 | var initialTAContent = textarea.value; |
|---|
| 2719 | |
|---|
| 2720 | |
|---|
| 2721 | Xinha.prependDom0Event( |
|---|
| 2722 | this._textArea.form, |
|---|
| 2723 | 'reset', |
|---|
| 2724 | function() |
|---|
| 2725 | { |
|---|
| 2726 | editor.setHTML(editor.inwardHtml(initialTAContent)); |
|---|
| 2727 | editor.updateToolbar(); |
|---|
| 2728 | return true; |
|---|
| 2729 | } |
|---|
| 2730 | ); |
|---|
| 2731 | |
|---|
| 2732 | |
|---|
| 2733 | |
|---|
| 2734 | if ( !textarea.form.xinha_submit ) |
|---|
| 2735 | { |
|---|
| 2736 | try |
|---|
| 2737 | { |
|---|
| 2738 | textarea.form.xinha_submit = textarea.form.submit; |
|---|
| 2739 | textarea.form.submit = function() |
|---|
| 2740 | { |
|---|
| 2741 | this.onsubmit(); |
|---|
| 2742 | this.xinha_submit(); |
|---|
| 2743 | }; |
|---|
| 2744 | } catch(ex) {} |
|---|
| 2745 | } |
|---|
| 2746 | } |
|---|
| 2747 | |
|---|
| 2748 | |
|---|
| 2749 | |
|---|
| 2750 | |
|---|
| 2751 | Xinha.prependDom0Event( |
|---|
| 2752 | window, |
|---|
| 2753 | 'unload', |
|---|
| 2754 | function() |
|---|
| 2755 | { |
|---|
| 2756 | editor.firePluginEvent('onBeforeUnload'); |
|---|
| 2757 | textarea.value = editor.outwardHtml(editor.getHTML()); |
|---|
| 2758 | if (!Xinha.is_ie) |
|---|
| 2759 | { |
|---|
| 2760 | xinha.parentNode.replaceChild(textarea,xinha); |
|---|
| 2761 | } |
|---|
| 2762 | return true; |
|---|
| 2763 | } |
|---|
| 2764 | ); |
|---|
| 2765 | |
|---|
| 2766 | |
|---|
| 2767 | textarea.style.display = "none"; |
|---|
| 2768 | |
|---|
| 2769 | |
|---|
| 2770 | editor.initSize(); |
|---|
| 2771 | this.setLoadingMessage(Xinha._lc('Finishing')); |
|---|
| 2772 | |
|---|
| 2773 | editor._iframeLoadDone = false; |
|---|
| 2774 | if (Xinha.is_opera) |
|---|
| 2775 | { |
|---|
| 2776 | editor.initIframe(); |
|---|
| 2777 | } |
|---|
| 2778 | else |
|---|
| 2779 | { |
|---|
| 2780 | Xinha._addEvent( |
|---|
| 2781 | this._iframe, |
|---|
| 2782 | 'load', |
|---|
| 2783 | function(e) |
|---|
| 2784 | { |
|---|
| 2785 | if ( !editor._iframeLoadDone ) |
|---|
| 2786 | { |
|---|
| 2787 | editor._iframeLoadDone = true; |
|---|
| 2788 | editor.initIframe(); |
|---|
| 2789 | } |
|---|
| 2790 | return true; |
|---|
| 2791 | } |
|---|
| 2792 | ); |
|---|
| 2793 | } |
|---|
| 2794 | }; |
|---|
| 2795 | |
|---|
| 2796 | |
|---|
| 2797 | |
|---|
| 2798 | |
|---|
| 2799 | |
|---|
| 2800 | |
|---|
| 2801 | |
|---|
| 2802 | |
|---|
| 2803 | |
|---|
| 2804 | |
|---|
| 2805 | |
|---|
| 2806 | |
|---|
| 2807 | |
|---|
| 2808 | |
|---|
| 2809 | |
|---|
| 2810 | |
|---|
| 2811 | |
|---|
| 2812 | |
|---|
| 2813 | |
|---|
| 2814 | |
|---|
| 2815 | Xinha.prototype.initSize = function() |
|---|
| 2816 | { |
|---|
| 2817 | this.setLoadingMessage(Xinha._lc('Init editor size')); |
|---|
| 2818 | var editor = this; |
|---|
| 2819 | var width = null; |
|---|
| 2820 | var height = null; |
|---|
| 2821 | |
|---|
| 2822 | switch ( this.config.width ) |
|---|
| 2823 | { |
|---|
| 2824 | case 'auto': |
|---|
| 2825 | width = this._initial_ta_size.w; |
|---|
| 2826 | break; |
|---|
| 2827 | |
|---|
| 2828 | case 'toolbar': |
|---|
| 2829 | width = this._toolBar.offsetWidth + 'px'; |
|---|
| 2830 | break; |
|---|
| 2831 | |
|---|
| 2832 | default : |
|---|
| 2833 | |
|---|
| 2834 | |
|---|
| 2835 | width = /[^0-9]/.test(this.config.width) ? this.config.width : this.config.width + 'px'; |
|---|
| 2836 | break; |
|---|
| 2837 | } |
|---|
| 2838 | |
|---|
| 2839 | |
|---|
| 2840 | height = this.config.height == 'auto' ? this._initial_ta_size.h : /[^0-9]/.test(this.config.height) ? this.config.height : this.config.height + 'px'; |
|---|
| 2841 | |
|---|
| 2842 | this.sizeEditor(width, height, this.config.sizeIncludesBars, this.config.sizeIncludesPanels); |
|---|
| 2843 | |
|---|
| 2844 | |
|---|
| 2845 | |
|---|
| 2846 | this.notifyOn('panel_change',function() { editor.sizeEditor(); }); |
|---|
| 2847 | }; |
|---|
| 2848 | |
|---|
| 2849 | |
|---|
| 2850 | |
|---|
| 2851 | |
|---|
| 2852 | |
|---|
| 2853 | |
|---|
| 2854 | |
|---|
| 2855 | |
|---|
| 2856 | Xinha.prototype.sizeEditor = function(width, height, includingBars, includingPanels) |
|---|
| 2857 | { |
|---|
| 2858 | if (this._risizing) |
|---|
| 2859 | { |
|---|
| 2860 | return; |
|---|
| 2861 | } |
|---|
| 2862 | this._risizing = true; |
|---|
| 2863 | |
|---|
| 2864 | var framework = this._framework; |
|---|
| 2865 | |
|---|
| 2866 | this.notifyOf('before_resize', {width:width, height:height}); |
|---|
| 2867 | this.firePluginEvent('onBeforeResize', width, height); |
|---|
| 2868 | |
|---|
| 2869 | |
|---|
| 2870 | this._iframe.style.height = '100%'; |
|---|
| 2871 | |
|---|
| 2872 | this._textArea.style.height = '1px'; |
|---|
| 2873 | |
|---|
| 2874 | this._iframe.style.width = '0px'; |
|---|
| 2875 | this._textArea.style.width = '0px'; |
|---|
| 2876 | |
|---|
| 2877 | if ( includingBars !== null ) |
|---|
| 2878 | { |
|---|
| 2879 | this._htmlArea.sizeIncludesToolbars = includingBars; |
|---|
| 2880 | } |
|---|
| 2881 | if ( includingPanels !== null ) |
|---|
| 2882 | { |
|---|
| 2883 | this._htmlArea.sizeIncludesPanels = includingPanels; |
|---|
| 2884 | } |
|---|
| 2885 | |
|---|
| 2886 | if ( width ) |
|---|
| 2887 | { |
|---|
| 2888 | this._htmlArea.style.width = width; |
|---|
| 2889 | if ( !this._htmlArea.sizeIncludesPanels ) |
|---|
| 2890 | { |
|---|
| 2891 | |
|---|
| 2892 | var rPanel = this._panels.right; |
|---|
| 2893 | if ( rPanel.on && rPanel.panels.length && Xinha.hasDisplayedChildren(rPanel.div) ) |
|---|
| 2894 | { |
|---|
| 2895 | this._htmlArea.style.width = (this._htmlArea.offsetWidth + parseInt(this.config.panel_dimensions.right, 10)) + 'px'; |
|---|
| 2896 | } |
|---|
| 2897 | |
|---|
| 2898 | var lPanel = this._panels.left; |
|---|
| 2899 | if ( lPanel.on && lPanel.panels.length && Xinha.hasDisplayedChildren(lPanel.div) ) |
|---|
| 2900 | { |
|---|
| 2901 | this._htmlArea.style.width = (this._htmlArea.offsetWidth + parseInt(this.config.panel_dimensions.left, 10)) + 'px'; |
|---|
| 2902 | } |
|---|
| 2903 | } |
|---|
| 2904 | } |
|---|
| 2905 | |
|---|
| 2906 | if ( height ) |
|---|
| 2907 | { |
|---|
| 2908 | this._htmlArea.style.height = height; |
|---|
| 2909 | if ( !this._htmlArea.sizeIncludesToolbars ) |
|---|
| 2910 | { |
|---|
| 2911 | |
|---|
| 2912 | this._htmlArea.style.height = (this._htmlArea.offsetHeight + this._toolbar.offsetHeight + this._statusBar.offsetHeight) + 'px'; |
|---|
| 2913 | } |
|---|
| 2914 | |
|---|
| 2915 | if ( !this._htmlArea.sizeIncludesPanels ) |
|---|
| 2916 | { |
|---|
| 2917 | |
|---|
| 2918 | var tPanel = this._panels.top; |
|---|
| 2919 | if ( tPanel.on && tPanel.panels.length && Xinha.hasDisplayedChildren(tPanel.div) ) |
|---|
| 2920 | { |
|---|
| 2921 | this._htmlArea.style.height = (this._htmlArea.offsetHeight + parseInt(this.config.panel_dimensions.top, 10)) + 'px'; |
|---|
| 2922 | } |
|---|
| 2923 | |
|---|
| 2924 | var bPanel = this._panels.bottom; |
|---|
| 2925 | if ( bPanel.on && bPanel.panels.length && Xinha.hasDisplayedChildren(bPanel.div) ) |
|---|
| 2926 | { |
|---|
| 2927 | this._htmlArea.style.height = (this._htmlArea.offsetHeight + parseInt(this.config.panel_dimensions.bottom, 10)) + 'px'; |
|---|
| 2928 | } |
|---|
| 2929 | } |
|---|
| 2930 | } |
|---|
| 2931 | |
|---|
| 2932 | |
|---|
| 2933 | |
|---|
| 2934 | |
|---|
| 2935 | width = this._htmlArea.offsetWidth; |
|---|
| 2936 | height = this._htmlArea.offsetHeight; |
|---|
| 2937 | |
|---|
| 2938 | |
|---|
| 2939 | |
|---|
| 2940 | var panels = this._panels; |
|---|
| 2941 | var editor = this; |
|---|
| 2942 | var col_span = 1; |
|---|
| 2943 | |
|---|
| 2944 | function panel_is_alive(pan) |
|---|
| 2945 | { |
|---|
| 2946 | if ( panels[pan].on && panels[pan].panels.length && Xinha.hasDisplayedChildren(panels[pan].container) ) |
|---|
| 2947 | { |
|---|
| 2948 | panels[pan].container.style.display = ''; |
|---|
| 2949 | return true; |
|---|
| 2950 | } |
|---|
| 2951 | |
|---|
| 2952 | else |
|---|
| 2953 | { |
|---|
| 2954 | panels[pan].container.style.display='none'; |
|---|
| 2955 | return false; |
|---|
| 2956 | } |
|---|
| 2957 | } |
|---|
| 2958 | |
|---|
| 2959 | if ( panel_is_alive('left') ) |
|---|
| 2960 | { |
|---|
| 2961 | col_span += 1; |
|---|
| 2962 | } |
|---|
| 2963 | |
|---|
| 2964 | |
|---|
| 2965 | |
|---|
| 2966 | |
|---|
| 2967 | |
|---|
| 2968 | |
|---|
| 2969 | if ( panel_is_alive('right') ) |
|---|
| 2970 | { |
|---|
| 2971 | col_span += 1; |
|---|
| 2972 | } |
|---|
| 2973 | |
|---|
| 2974 | |
|---|
| 2975 | |
|---|
| 2976 | |
|---|
| 2977 | |
|---|
| 2978 | |
|---|
| 2979 | framework.tb_cell.colSpan = col_span; |
|---|
| 2980 | framework.tp_cell.colSpan = col_span; |
|---|
| 2981 | framework.bp_cell.colSpan = col_span; |
|---|
| 2982 | framework.sb_cell.colSpan = col_span; |
|---|
| 2983 | |
|---|
| 2984 | |
|---|
| 2985 | if ( !framework.tp_row.childNodes.length ) |
|---|
| 2986 | { |
|---|
| 2987 | Xinha.removeFromParent(framework.tp_row); |
|---|
| 2988 | } |
|---|
| 2989 | else |
|---|
| 2990 | { |
|---|
| 2991 | if ( !Xinha.hasParentNode(framework.tp_row) ) |
|---|
| 2992 | { |
|---|
| 2993 | framework.tbody.insertBefore(framework.tp_row, framework.ler_row); |
|---|
| 2994 | } |
|---|
| 2995 | } |
|---|
| 2996 | |
|---|
| 2997 | |
|---|
| 2998 | if ( !framework.bp_row.childNodes.length ) |
|---|
| 2999 | { |
|---|
| 3000 | Xinha.removeFromParent(framework.bp_row); |
|---|
| 3001 | } |
|---|
| 3002 | else |
|---|
| 3003 | { |
|---|
| 3004 | if ( !Xinha.hasParentNode(framework.bp_row) ) |
|---|
| 3005 | { |
|---|
| 3006 | framework.tbody.insertBefore(framework.bp_row, framework.ler_row.nextSibling); |
|---|
| 3007 | } |
|---|
| 3008 | } |
|---|
| 3009 | |
|---|
| 3010 | |
|---|
| 3011 | if ( !this.config.statusBar ) |
|---|
| 3012 | { |
|---|
| 3013 | Xinha.removeFromParent(framework.sb_row); |
|---|
| 3014 | } |
|---|
| 3015 | else |
|---|
| 3016 | { |
|---|
| 3017 | if ( !Xinha.hasParentNode(framework.sb_row) ) |
|---|
| 3018 | { |
|---|
| 3019 | framework.table.appendChild(framework.sb_row); |
|---|
| 3020 | } |
|---|
| 3021 | } |
|---|
| 3022 | |
|---|
| 3023 | |
|---|
| 3024 | framework.lp_cell.style.width = this.config.panel_dimensions.left; |
|---|
| 3025 | framework.rp_cell.style.width = this.config.panel_dimensions.right; |
|---|
| 3026 | framework.tp_cell.style.height = this.config.panel_dimensions.top; |
|---|
| 3027 | framework.bp_cell.style.height = this.config.panel_dimensions.bottom; |
|---|
| 3028 | framework.tb_cell.style.height = this._toolBar.offsetHeight + 'px'; |
|---|
| 3029 | framework.sb_cell.style.height = this._statusBar.offsetHeight + 'px'; |
|---|
| 3030 | |
|---|
| 3031 | var edcellheight = height - this._toolBar.offsetHeight - this._statusBar.offsetHeight; |
|---|
| 3032 | if ( panel_is_alive('top') ) |
|---|
| 3033 | { |
|---|
| 3034 | edcellheight -= parseInt(this.config.panel_dimensions.top, 10); |
|---|
| 3035 | } |
|---|
| 3036 | if ( panel_is_alive('bottom') ) |
|---|
| 3037 | { |
|---|
| 3038 | edcellheight -= parseInt(this.config.panel_dimensions.bottom, 10); |
|---|
| 3039 | } |
|---|
| 3040 | this._iframe.style.height = edcellheight + 'px'; |
|---|
| 3041 | |
|---|
| 3042 | var edcellwidth = width; |
|---|
| 3043 | if ( panel_is_alive('left') ) |
|---|
| 3044 | { |
|---|
| 3045 | edcellwidth -= parseInt(this.config.panel_dimensions.left, 10); |
|---|
| 3046 | } |
|---|
| 3047 | if ( panel_is_alive('right') ) |
|---|
| 3048 | { |
|---|
| 3049 | edcellwidth -= parseInt(this.config.panel_dimensions.right, 10); |
|---|
| 3050 | } |
|---|
| 3051 | var iframeWidth = this.config.iframeWidth ? parseInt(this.config.iframeWidth,10) : null; |
|---|
| 3052 | this._iframe.style.width = (iframeWidth && iframeWidth < edcellwidth) ? iframeWidth + "px": edcellwidth + "px"; |
|---|
| 3053 | |
|---|
| 3054 | this._textArea.style.height = this._iframe.style.height; |
|---|
| 3055 | this._textArea.style.width = this._iframe.style.width; |
|---|
| 3056 | |
|---|
| 3057 | this.notifyOf('resize', {width:this._htmlArea.offsetWidth, height:this._htmlArea.offsetHeight}); |
|---|
| 3058 | this.firePluginEvent('onResize',this._htmlArea.offsetWidth, this._htmlArea.offsetWidth); |
|---|
| 3059 | this._risizing = false; |
|---|
| 3060 | }; |
|---|
| 3061 | |
|---|
| 3062 | |
|---|
| 3063 | |
|---|
| 3064 | |
|---|
| 3065 | Xinha.prototype.registerPanel = function(side, object) |
|---|
| 3066 | { |
|---|
| 3067 | if ( !side ) |
|---|
| 3068 | { |
|---|
| 3069 | side = 'right'; |
|---|
| 3070 | } |
|---|
| 3071 | this.setLoadingMessage('Register ' + side + ' panel '); |
|---|
| 3072 | var panel = this.addPanel(side); |
|---|
| 3073 | if ( object ) |
|---|
| 3074 | { |
|---|
| 3075 | object.drawPanelIn(panel); |
|---|
| 3076 | } |
|---|
| 3077 | }; |
|---|
| 3078 | |
|---|
| 3079 | |
|---|
| 3080 | |
|---|
| 3081 | |
|---|
| 3082 | |
|---|
| 3083 | Xinha.prototype.addPanel = function(side) |
|---|
| 3084 | { |
|---|
| 3085 | var div = document.createElement('div'); |
|---|
| 3086 | div.side = side; |
|---|
| 3087 | if ( side == 'left' || side == 'right' ) |
|---|
| 3088 | { |
|---|
| 3089 | div.style.width = this.config.panel_dimensions[side]; |
|---|
| 3090 | if (this._iframe) |
|---|
| 3091 | { |
|---|
| 3092 | div.style.height = this._iframe.style.height; |
|---|
| 3093 | } |
|---|
| 3094 | } |
|---|
| 3095 | Xinha.addClasses(div, 'panel'); |
|---|
| 3096 | this._panels[side].panels.push(div); |
|---|
| 3097 | this._panels[side].div.appendChild(div); |
|---|
| 3098 | |
|---|
| 3099 | this.notifyOf('panel_change', {'action':'add','panel':div}); |
|---|
| 3100 | this.firePluginEvent('onPanelChange','add',div); |
|---|
| 3101 | return div; |
|---|
| 3102 | }; |
|---|
| 3103 | |
|---|
| 3104 | |
|---|
| 3105 | |
|---|
| 3106 | Xinha.prototype.removePanel = function(panel) |
|---|
| 3107 | { |
|---|
| 3108 | this._panels[panel.side].div.removeChild(panel); |
|---|
| 3109 | var clean = []; |
|---|
| 3110 | for ( var i = 0; i < this._panels[panel.side].panels.length; i++ ) |
|---|
| 3111 | { |
|---|
| 3112 | if ( this._panels[panel.side].panels[i] != panel ) |
|---|
| 3113 | { |
|---|
| 3114 | clean.push(this._panels[panel.side].panels[i]); |
|---|
| 3115 | } |
|---|
| 3116 | } |
|---|
| 3117 | this._panels[panel.side].panels = clean; |
|---|
| 3118 | this.notifyOf('panel_change', {'action':'remove','panel':panel}); |
|---|
| 3119 | this.firePluginEvent('onPanelChange','remove',panel); |
|---|
| 3120 | }; |
|---|
| 3121 | |
|---|
| 3122 | |
|---|
| 3123 | |
|---|
| 3124 | Xinha.prototype.hidePanel = function(panel) |
|---|
| 3125 | { |
|---|
| 3126 | if ( panel && panel.style.display != 'none' ) |
|---|
| 3127 | { |
|---|
| 3128 | try { var pos = this.scrollPos(this._iframe.contentWindow); } catch(e) { } |
|---|
| 3129 | panel.style.display = 'none'; |
|---|
| 3130 | this.notifyOf('panel_change', {'action':'hide','panel':panel}); |
|---|
| 3131 | this.firePluginEvent('onPanelChange','hide',panel); |
|---|
| 3132 | try { this._iframe.contentWindow.scrollTo(pos.x,pos.y); } catch(e) { } |
|---|
| 3133 | } |
|---|
| 3134 | }; |
|---|
| 3135 | |
|---|
| 3136 | |
|---|
| 3137 | |
|---|
| 3138 | Xinha.prototype.showPanel = function(panel) |
|---|
| 3139 | { |
|---|
| 3140 | if ( panel && panel.style.display == 'none' ) |
|---|
| 3141 | { |
|---|
| 3142 | try { var pos = this.scrollPos(this._iframe.contentWindow); } catch(e) {} |
|---|
| 3143 | panel.style.display = ''; |
|---|
| 3144 | this.notifyOf('panel_change', {'action':'show','panel':panel}); |
|---|
| 3145 | this.firePluginEvent('onPanelChange','show',panel); |
|---|
| 3146 | try { this._iframe.contentWindow.scrollTo(pos.x,pos.y); } catch(e) { } |
|---|
| 3147 | } |
|---|
| 3148 | }; |
|---|
| 3149 | |
|---|
| 3150 | |
|---|
| 3151 | |
|---|
| 3152 | Xinha.prototype.hidePanels = function(sides) |
|---|
| 3153 | { |
|---|
| 3154 | if ( typeof sides == 'undefined' ) |
|---|
| 3155 | { |
|---|
| 3156 | sides = ['left','right','top','bottom']; |
|---|
| 3157 | } |
|---|
| 3158 | |
|---|
| 3159 | var reShow = []; |
|---|
| 3160 | for ( var i = 0; i < sides.length;i++ ) |
|---|
| 3161 | { |
|---|
| 3162 | if ( this._panels[sides[i]].on ) |
|---|
| 3163 | { |
|---|
| 3164 | reShow.push(sides[i]); |
|---|
| 3165 | this._panels[sides[i]].on = false; |
|---|
| 3166 | } |
|---|
| 3167 | } |
|---|
| 3168 | this.notifyOf('panel_change', {'action':'multi_hide','sides':sides}); |
|---|
| 3169 | this.firePluginEvent('onPanelChange','multi_hide',sides); |
|---|
| 3170 | }; |
|---|
| 3171 | |
|---|
| 3172 | |
|---|
| 3173 | |
|---|
| 3174 | Xinha.prototype.showPanels = function(sides) |
|---|
| 3175 | { |
|---|
| 3176 | if ( typeof sides == 'undefined' ) |
|---|
| 3177 | { |
|---|
| 3178 | sides = ['left','right','top','bottom']; |
|---|
| 3179 | } |
|---|
| 3180 | |
|---|
| 3181 | var reHide = []; |
|---|
| 3182 | for ( var i = 0; i < sides.length; i++ ) |
|---|
| 3183 | { |
|---|
| 3184 | if ( !this._panels[sides[i]].on ) |
|---|
| 3185 | { |
|---|
| 3186 | reHide.push(sides[i]); |
|---|
| 3187 | this._panels[sides[i]].on = true; |
|---|
| 3188 | } |
|---|
| 3189 | } |
|---|
| 3190 | this.notifyOf('panel_change', {'action':'multi_show','sides':sides}); |
|---|
| 3191 | this.firePluginEvent('onPanelChange','multi_show',sides); |
|---|
| 3192 | }; |
|---|
| 3193 | |
|---|
| 3194 | |
|---|
| 3195 | |
|---|
| 3196 | |
|---|
| 3197 | Xinha.objectProperties = function(obj) |
|---|
| 3198 | { |
|---|
| 3199 | var props = []; |
|---|
| 3200 | for ( var x in obj ) |
|---|
| 3201 | { |
|---|
| 3202 | props[props.length] = x; |
|---|
| 3203 | } |
|---|
| 3204 | return props; |
|---|
| 3205 | }; |
|---|
| 3206 | |
|---|
| 3207 | |
|---|
| 3208 | |
|---|
| 3209 | |
|---|
| 3210 | |
|---|
| 3211 | |
|---|
| 3212 | |
|---|
| 3213 | |
|---|
| 3214 | |
|---|
| 3215 | |
|---|
| 3216 | |
|---|
| 3217 | Xinha.prototype.editorIsActivated = function() |
|---|
| 3218 | { |
|---|
| 3219 | try |
|---|
| 3220 | { |
|---|
| 3221 | return Xinha.is_designMode ? this._doc.designMode == 'on' : this._doc.body.contentEditable; |
|---|
| 3222 | } |
|---|
| 3223 | catch (ex) |
|---|
| 3224 | { |
|---|
| 3225 | return false; |
|---|
| 3226 | } |
|---|
| 3227 | }; |
|---|
| 3228 | |
|---|
| 3229 | |
|---|
| 3230 | |
|---|
| 3231 | |
|---|
| 3232 | |
|---|
| 3233 | Xinha._someEditorHasBeenActivated = false; |
|---|
| 3234 | |
|---|
| 3235 | |
|---|
| 3236 | |
|---|
| 3237 | |
|---|
| 3238 | Xinha._currentlyActiveEditor = null; |
|---|
| 3239 | |
|---|
| 3240 | |
|---|
| 3241 | |
|---|
| 3242 | |
|---|
| 3243 | |
|---|
| 3244 | Xinha.prototype.activateEditor = function() |
|---|
| 3245 | { |
|---|
| 3246 | if (this.currentModal) |
|---|
| 3247 | { |
|---|
| 3248 | return; |
|---|
| 3249 | } |
|---|
| 3250 | |
|---|
| 3251 | if ( Xinha._currentlyActiveEditor ) |
|---|
| 3252 | { |
|---|
| 3253 | if ( Xinha._currentlyActiveEditor == this ) |
|---|
| 3254 | { |
|---|
| 3255 | return true; |
|---|
| 3256 | } |
|---|
| 3257 | Xinha._currentlyActiveEditor.deactivateEditor(); |
|---|
| 3258 | } |
|---|
| 3259 | |
|---|
| 3260 | if ( Xinha.is_designMode && this._doc.designMode != 'on' ) |
|---|
| 3261 | { |
|---|
| 3262 | try |
|---|
| 3263 | { |
|---|
| 3264 | |
|---|
| 3265 | if ( this._iframe.style.display == 'none' ) |
|---|
| 3266 | { |
|---|
| 3267 | this._iframe.style.display = ''; |
|---|
| 3268 | this._doc.designMode = 'on'; |
|---|
| 3269 | this._iframe.style.display = 'none'; |
|---|
| 3270 | } |
|---|
| 3271 | else |
|---|
| 3272 | { |
|---|
| 3273 | this._doc.designMode = 'on'; |
|---|
| 3274 | } |
|---|
| 3275 | |
|---|
| 3276 | |
|---|
| 3277 | |
|---|
| 3278 | if(Xinha.is_opera) this.setEditorEvents(true); |
|---|
| 3279 | |
|---|
| 3280 | } catch (ex) {} |
|---|
| 3281 | } |
|---|
| 3282 | else if ( Xinha.is_ie&& this._doc.body.contentEditable !== true ) |
|---|
| 3283 | { |
|---|
| 3284 | this._doc.body.contentEditable = true; |
|---|
| 3285 | } |
|---|
| 3286 | |
|---|
| 3287 | Xinha._someEditorHasBeenActivated = true; |
|---|
| 3288 | Xinha._currentlyActiveEditor = this; |
|---|
| 3289 | |
|---|
| 3290 | var editor = this; |
|---|
| 3291 | this.enableToolbar(); |
|---|
| 3292 | }; |
|---|
| 3293 | |
|---|
| 3294 | |
|---|
| 3295 | |
|---|
| 3296 | Xinha.prototype.deactivateEditor = function() |
|---|
| 3297 | { |
|---|
| 3298 | |
|---|
| 3299 | this.disableToolbar(); |
|---|
| 3300 | |
|---|
| 3301 | if ( Xinha.is_designMode && this._doc.designMode != 'off' ) |
|---|
| 3302 | { |
|---|
| 3303 | try |
|---|
| 3304 | { |
|---|
| 3305 | this._doc.designMode = 'off'; |
|---|
| 3306 | } catch (ex) {} |
|---|
| 3307 | } |
|---|
| 3308 | else if ( !Xinha.is_designMode && this._doc.body.contentEditable !== false ) |
|---|
| 3309 | { |
|---|
| 3310 | this._doc.body.contentEditable = false; |
|---|
| 3311 | } |
|---|
| 3312 | |
|---|
| 3313 | if ( Xinha._currentlyActiveEditor != this ) |
|---|
| 3314 | { |
|---|
| 3315 | |
|---|
| 3316 | |
|---|
| 3317 | return; |
|---|
| 3318 | |
|---|
| 3319 | |
|---|
| 3320 | } |
|---|
| 3321 | |
|---|
| 3322 | Xinha._currentlyActiveEditor = false; |
|---|
| 3323 | }; |
|---|
| 3324 | |
|---|
| 3325 | |
|---|
| 3326 | |
|---|
| 3327 | Xinha.prototype.initIframe = function() |
|---|
| 3328 | { |
|---|
| 3329 | this.disableToolbar(); |
|---|
| 3330 | var doc = null; |
|---|
| 3331 | var editor = this; |
|---|
| 3332 | try |
|---|
| 3333 | { |
|---|
| 3334 | if ( editor._iframe.contentDocument ) |
|---|
| 3335 | { |
|---|
| 3336 | this._doc = editor._iframe.contentDocument; |
|---|
| 3337 | } |
|---|
| 3338 | else |
|---|
| 3339 | { |
|---|
| 3340 | this._doc = editor._iframe.contentWindow.document; |
|---|
| 3341 | } |
|---|
| 3342 | doc = this._doc; |
|---|
| 3343 | |
|---|
| 3344 | if ( !doc ) |
|---|
| 3345 | { |
|---|
| 3346 | if ( Xinha.is_gecko ) |
|---|
| 3347 | { |
|---|
| 3348 | setTimeout(function() { editor.initIframe(); }, 50); |
|---|
| 3349 | return false; |
|---|
| 3350 | } |
|---|
| 3351 | else |
|---|
| 3352 | { |
|---|
| 3353 | alert("ERROR: IFRAME can't be initialized."); |
|---|
| 3354 | } |
|---|
| 3355 | } |
|---|
| 3356 | } |
|---|
| 3357 | catch(ex) |
|---|
| 3358 | { |
|---|
| 3359 | setTimeout(function() { editor.initIframe(); }, 50); |
|---|
| 3360 | return false; |
|---|
| 3361 | } |
|---|
| 3362 | |
|---|
| 3363 | Xinha.freeLater(this, '_doc'); |
|---|
| 3364 | |
|---|
| 3365 | doc.open("text/html","replace"); |
|---|
| 3366 | var html = '', doctype; |
|---|
| 3367 | if ( editor.config.browserQuirksMode === false ) |
|---|
| 3368 | { |
|---|
| 3369 | doctype = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'; |
|---|
| 3370 | } |
|---|
| 3371 | else if ( editor.config.browserQuirksMode === true ) |
|---|
| 3372 | { |
|---|
| 3373 | doctype = ''; |
|---|
| 3374 | } |
|---|
| 3375 | else |
|---|
| 3376 | { |
|---|
| 3377 | doctype = Xinha.getDoctype(document); |
|---|
| 3378 | } |
|---|
| 3379 | |
|---|
| 3380 | if ( !editor.config.fullPage ) |
|---|
| 3381 | { |
|---|
| 3382 | html += doctype + "\n"; |
|---|
| 3383 | html += "<html>\n"; |
|---|
| 3384 | html += "<head>\n"; |
|---|
| 3385 | html += "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=" + editor.config.charSet + "\">\n"; |
|---|
| 3386 | if ( typeof editor.config.baseHref != 'undefined' && editor.config.baseHref !== null ) |
|---|
| 3387 | { |
|---|
| 3388 | html += "<base href=\"" + editor.config.baseHref + "\"/>\n"; |
|---|
| 3389 | } |
|---|
| 3390 | |
|---|
| 3391 | html += Xinha.addCoreCSS(); |
|---|
| 3392 | |
|---|
| 3393 | if ( typeof editor.config.pageStyleSheets !== 'undefined' ) |
|---|
| 3394 | { |
|---|
| 3395 | for ( var i = 0; i < editor.config.pageStyleSheets.length; i++ ) |
|---|
| 3396 | { |
|---|
| 3397 | if ( editor.config.pageStyleSheets[i].length > 0 ) |
|---|
| 3398 | { |
|---|
| 3399 | html += "<link rel=\"stylesheet\" type=\"text/css\" href=\"" + editor.config.pageStyleSheets[i] + "\">"; |
|---|
| 3400 | |
|---|
| 3401 | } |
|---|
| 3402 | } |
|---|
| 3403 | } |
|---|
| 3404 | |
|---|
| 3405 | if ( editor.config.pageStyle ) |
|---|
| 3406 | { |
|---|
| 3407 | html += "<style type=\"text/css\">\n" + editor.config.pageStyle + "\n</style>"; |
|---|
| 3408 | } |
|---|
| 3409 | |
|---|
| 3410 | html += "</head>\n"; |
|---|
| 3411 | html += "<body" + (editor.config.bodyID ? (" id=\"" + editor.config.bodyID + "\"") : '') + (editor.config.bodyClass ? (" class=\"" + editor.config.bodyClass + "\"") : '') + ">\n"; |
|---|
| 3412 | html += editor.inwardHtml(editor._textArea.value); |
|---|
| 3413 | html += "</body>\n"; |
|---|
| 3414 | html += "</html>"; |
|---|
| 3415 | } |
|---|
| 3416 | else |
|---|
| 3417 | { |
|---|
| 3418 | html = editor.inwardHtml(editor._textArea.value); |
|---|
| 3419 | if ( html.match(Xinha.RE_doctype) ) |
|---|
| 3420 | { |
|---|
| 3421 | editor.setDoctype(RegExp.$1); |
|---|
| 3422 | |
|---|
| 3423 | } |
|---|
| 3424 | |
|---|
| 3425 | |
|---|
| 3426 | var match = html.match(/<link\s+[\s\S]*?["']\s*\/?>/gi); |
|---|
| 3427 | html = html.replace(/<link\s+[\s\S]*?["']\s*\/?>\s*/gi, ''); |
|---|
| 3428 | if (match) |
|---|
| 3429 | { |
|---|
| 3430 | html = html.replace(/<\/head>/i, match.join('\n') + "\n</head>"); |
|---|
| 3431 | } |
|---|
| 3432 | } |
|---|
| 3433 | doc.write(html); |
|---|
| 3434 | doc.close(); |
|---|
| 3435 | if ( this.config.fullScreen ) |
|---|
| 3436 | { |
|---|
| 3437 | this._fullScreen(); |
|---|
| 3438 | } |
|---|
| 3439 | this.setEditorEvents(); |
|---|
| 3440 | |
|---|
| 3441 | |
|---|
| 3442 | // If this IFRAME had been configured for autofocus, we'll focus it now, |
|---|
| 3443 | |
|---|
| 3444 | if ((typeof editor.config.autofocus != "undefined") && editor.config.autofocus !== false && |
|---|
| 3445 | ((editor.config.autofocus == editor._textArea.id) || editor.config.autofocus == true)) |
|---|
| 3446 | { |
|---|
| 3447 | editor.activateEditor(); |
|---|
| 3448 | editor.focusEditor(); |
|---|
| 3449 | } |
|---|
| 3450 | }; |
|---|
| 3451 | |
|---|
| 3452 | |
|---|
| 3453 | |
|---|
| 3454 | |
|---|
| 3455 | |
|---|
| 3456 | |
|---|
| 3457 | |
|---|
| 3458 | Xinha.prototype.whenDocReady = function(f) |
|---|
| 3459 | { |
|---|
| 3460 | var e = this; |
|---|
| 3461 | if ( this._doc && this._doc.body ) |
|---|
| 3462 | { |
|---|
| 3463 | f(); |
|---|
| 3464 | } |
|---|
| 3465 | else |
|---|
| 3466 | { |
|---|
| 3467 | setTimeout(function() { e.whenDocReady(f); }, 50); |
|---|
| 3468 | } |
|---|
| 3469 | }; |
|---|
| 3470 | |
|---|
| 3471 | |
|---|
| 3472 | |
|---|
| 3473 | |
|---|
| 3474 | |
|---|
| 3475 | Xinha.prototype.setMode = function(mode) |
|---|
| 3476 | { |
|---|
| 3477 | var html; |
|---|
| 3478 | if ( typeof mode == "undefined" ) |
|---|
| 3479 | { |
|---|
| 3480 | mode = this._editMode == "textmode" ? "wysiwyg" : "textmode"; |
|---|
| 3481 | } |
|---|
| 3482 | switch ( mode ) |
|---|
| 3483 | { |
|---|
| 3484 | case "textmode": |
|---|
| 3485 | this.firePluginEvent('onBeforeMode', 'textmode'); |
|---|
| 3486 | this._toolbarObjects.htmlmode.swapImage(this.config.iconList.wysiwygmode); |
|---|
| 3487 | this.setCC("iframe"); |
|---|
| 3488 | html = this.outwardHtml(this.getHTML()); |
|---|
| 3489 | this.setHTML(html); |
|---|
| 3490 | |
|---|
| 3491 | |
|---|
| 3492 | this.deactivateEditor(); |
|---|
| 3493 | this._iframe.style.display = 'none'; |
|---|
| 3494 | this._textArea.style.display = ''; |
|---|
| 3495 | |
|---|
| 3496 | if ( this.config.statusBar ) |
|---|
| 3497 | { |
|---|
| 3498 | this._statusBarTree.style.display = "none"; |
|---|
| 3499 | this._statusBarTextMode.style.display = ""; |
|---|
| 3500 | } |
|---|
| 3501 | this.findCC("textarea"); |
|---|
| 3502 | this.notifyOf('modechange', {'mode':'text'}); |
|---|
| 3503 | this.firePluginEvent('onMode', 'textmode'); |
|---|
| 3504 | break; |
|---|
| 3505 | |
|---|
| 3506 | case "wysiwyg": |
|---|
| 3507 | this.firePluginEvent('onBeforeMode', 'wysiwyg'); |
|---|
| 3508 | this._toolbarObjects.htmlmode.swapImage([this.imgURL('images/ed_buttons_main.png'),7,0]); |
|---|
| 3509 | this.setCC("textarea"); |
|---|
| 3510 | html = this.inwardHtml(this.getHTML()); |
|---|
| 3511 | this.deactivateEditor(); |
|---|
| 3512 | this.setHTML(html); |
|---|
| 3513 | this._iframe.style.display = ''; |
|---|
| 3514 | this._textArea.style.display = "none"; |
|---|
| 3515 | this.activateEditor(); |
|---|
| 3516 | if ( this.config.statusBar ) |
|---|
| 3517 | { |
|---|
| 3518 | this._statusBarTree.style.display = ""; |
|---|
| 3519 | this._statusBarTextMode.style.display = "none"; |
|---|
| 3520 | } |
|---|
| 3521 | this.findCC("iframe"); |
|---|
| 3522 | this.notifyOf('modechange', {'mode':'wysiwyg'}); |
|---|
| 3523 | this.firePluginEvent('onMode', 'wysiwyg'); |
|---|
| 3524 | |
|---|
| 3525 | break; |
|---|
| 3526 | |
|---|
| 3527 | default: |
|---|
| 3528 | alert("Mode <" + mode + "> not defined!"); |
|---|
| 3529 | return false; |
|---|
| 3530 | } |
|---|
| 3531 | this._editMode = mode; |
|---|
| 3532 | }; |
|---|
| 3533 | |
|---|
| 3534 | |
|---|
| 3535 | |
|---|
| 3536 | |
|---|
| 3537 | Xinha.prototype.setFullHTML = function(html) |
|---|
| 3538 | { |
|---|
| 3539 | var save_multiline = RegExp.multiline; |
|---|
| 3540 | RegExp.multiline = true; |
|---|
| 3541 | if ( html.match(Xinha.RE_doctype) ) |
|---|
| 3542 | { |
|---|
| 3543 | this.setDoctype(RegExp.$1); |
|---|
| 3544 | |
|---|
| 3545 | } |
|---|
| 3546 | RegExp.multiline = save_multiline; |
|---|
| 3547 | |
|---|
| 3548 | if ( 0 ) |
|---|
| 3549 | { |
|---|
| 3550 | if ( html.match(Xinha.RE_head) ) |
|---|
| 3551 | { |
|---|
| 3552 | this._doc.getElementsByTagName("head")[0].innerHTML = RegExp.$1; |
|---|
| 3553 | } |
|---|
| 3554 | if ( html.match(Xinha.RE_body) ) |
|---|
| 3555 | { |
|---|
| 3556 | this._doc.getElementsByTagName("body")[0].innerHTML = RegExp.$1; |
|---|
| 3557 | } |
|---|
| 3558 | } |
|---|
| 3559 | else |
|---|
| 3560 | { |
|---|
| 3561 | |
|---|
| 3562 | |
|---|
| 3563 | var reac = this.editorIsActivated(); |
|---|
| 3564 | if ( reac ) |
|---|
| 3565 | { |
|---|
| 3566 | this.deactivateEditor(); |
|---|
| 3567 | } |
|---|
| 3568 | var html_re = /<html>((.|\n)*?)<\/html>/i; |
|---|
| 3569 | html = html.replace(html_re, "$1"); |
|---|
| 3570 | this._doc.open("text/html","replace"); |
|---|
| 3571 | this._doc.write(html); |
|---|
| 3572 | this._doc.close(); |
|---|
| 3573 | if ( reac ) |
|---|
| 3574 | { |
|---|
| 3575 | this.activateEditor(); |
|---|
| 3576 | } |
|---|
| 3577 | this.setEditorEvents(); |
|---|
| 3578 | return true; |
|---|
| 3579 | } |
|---|
| 3580 | }; |
|---|
| 3581 | |
|---|
| 3582 | |
|---|
| 3583 | |
|---|
| 3584 | Xinha.prototype.setEditorEvents = function(resetting_events_for_opera) |
|---|
| 3585 | { |
|---|
| 3586 | var editor=this; |
|---|
| 3587 | var doc = this._doc; |
|---|
| 3588 | |
|---|
| 3589 | editor.whenDocReady( |
|---|
| 3590 | function() |
|---|
| 3591 | { |
|---|
| 3592 | if(!resetting_events_for_opera) { |
|---|
| 3593 | |
|---|
| 3594 | Xinha._addEvents( |
|---|
| 3595 | doc, |
|---|
| 3596 | ["mousedown"], |
|---|
| 3597 | function() |
|---|
| 3598 | { |
|---|
| 3599 | editor.activateEditor(); |
|---|
| 3600 | return true; |
|---|
| 3601 | } |
|---|
| 3602 | ); |
|---|
| 3603 | if (Xinha.is_ie) |
|---|
| 3604 | { |
|---|
| 3605 | Xinha._addEvent( |
|---|
| 3606 | editor._doc.getElementsByTagName("html")[0], |
|---|
| 3607 | "click", |
|---|
| 3608 | function() |
|---|
| 3609 | { |
|---|
| 3610 | if (editor._iframe.contentWindow.event.srcElement.tagName.toLowerCase() == 'html') |
|---|
| 3611 | { |
|---|
| 3612 | var r = editor._doc.body.createTextRange(); |
|---|
| 3613 | r.collapse(); |
|---|
| 3614 | r.select(); |
|---|
| 3615 | |
|---|
| 3616 | } |
|---|
| 3617 | return true; |
|---|
| 3618 | } |
|---|
| 3619 | ); |
|---|
| 3620 | } |
|---|
| 3621 | } |
|---|
| 3622 | |
|---|
| 3623 | |
|---|
| 3624 | Xinha._addEvents( |
|---|
| 3625 | doc, |
|---|
| 3626 | ["keydown", "keypress", "mousedown", "mouseup", "drag"], |
|---|
| 3627 | function (event) |
|---|
| 3628 | { |
|---|
| 3629 | return editor._editorEvent(Xinha.is_ie ? editor._iframe.contentWindow.event : event); |
|---|
| 3630 | } |
|---|
| 3631 | ); |
|---|
| 3632 | |
|---|
| 3633 | Xinha._addEvents( |
|---|
| 3634 | doc, |
|---|
| 3635 | ["dblclick"], |
|---|
| 3636 | function (event) |
|---|
| 3637 | { |
|---|
| 3638 | return editor._onDoubleClick(Xinha.is_ie ? editor._iframe.contentWindow.event : event); |
|---|
| 3639 | } |
|---|
| 3640 | ); |
|---|
| 3641 | |
|---|
| 3642 | if(resetting_events_for_opera) return; |
|---|
| 3643 | |
|---|
| 3644 | |
|---|
| 3645 | |
|---|
| 3646 | |
|---|
| 3647 | |
|---|
| 3648 | |
|---|
| 3649 | for ( var i in editor.plugins ) |
|---|
| 3650 | { |
|---|
| 3651 | var plugin = editor.plugins[i].instance; |
|---|
| 3652 | Xinha.refreshPlugin(plugin); |
|---|
| 3653 | } |
|---|
| 3654 | |
|---|
| 3655 | |
|---|
| 3656 | if ( typeof editor._onGenerate == "function" ) |
|---|
| 3657 | { |
|---|
| 3658 | editor._onGenerate(); |
|---|
| 3659 | } |
|---|
| 3660 | |
|---|
| 3661 | if(editor._textArea.hasAttribute('onxinhaready')) |
|---|
| 3662 | { |
|---|
| 3663 | (function() { eval(editor._textArea.getAttribute('onxinhaready')) }).call(editor.textArea); |
|---|
| 3664 | } |
|---|
| 3665 | |
|---|
| 3666 | |
|---|
| 3667 | Xinha.addDom0Event(window, 'resize', function(e) |
|---|
| 3668 | { |
|---|
| 3669 | if (Xinha.ie_version > 7 && !window.parent) |
|---|
| 3670 | { |
|---|
| 3671 | if (editor.execResize) |
|---|
| 3672 | { |
|---|
| 3673 | editor.sizeEditor(); |
|---|
| 3674 | editor.execResize = false; |
|---|
| 3675 | } |
|---|
| 3676 | else |
|---|
| 3677 | { |
|---|
| 3678 | editor.execResize = true; |
|---|
| 3679 | } |
|---|
| 3680 | } |
|---|
| 3681 | else |
|---|
| 3682 | { |
|---|
| 3683 | editor.sizeEditor(); |
|---|
| 3684 | } |
|---|
| 3685 | }); |
|---|
| 3686 | editor.removeLoadingMessage(); |
|---|
| 3687 | } |
|---|
| 3688 | ); |
|---|
| 3689 | }; |
|---|
| 3690 | |
|---|
| 3691 | |
|---|
| 3692 | |
|---|
| 3693 | |
|---|
| 3694 | |
|---|
| 3695 | |
|---|
| 3696 | |
|---|
| 3697 | |
|---|
| 3698 | |
|---|
| 3699 | |
|---|
| 3700 | Xinha.getPluginConstructor = function(pluginName) |
|---|
| 3701 | { |
|---|
| 3702 | return Xinha.plugins[pluginName] || window[pluginName]; |
|---|
| 3703 | }; |
|---|
| 3704 | |
|---|
| 3705 | |
|---|
| 3706 | |
|---|
| 3707 | |
|---|
| 3708 | |
|---|
| 3709 | Xinha.prototype.registerPlugin = function() |
|---|
| 3710 | { |
|---|
| 3711 | if (!Xinha.isSupportedBrowser) |
|---|
| 3712 | { |
|---|
| 3713 | return; |
|---|
| 3714 | } |
|---|
| 3715 | var plugin = arguments[0]; |
|---|
| 3716 | |
|---|
| 3717 | |
|---|
| 3718 | if ( plugin === null || typeof plugin == 'undefined' || (typeof plugin == 'string' && Xinha.getPluginConstructor(plugin) == 'undefined') ) |
|---|
| 3719 | { |
|---|
| 3720 | return false; |
|---|
| 3721 | } |
|---|
| 3722 | var args = []; |
|---|
| 3723 | for ( var i = 1; i < arguments.length; ++i ) |
|---|
| 3724 | { |
|---|
| 3725 | args.push(arguments[i]); |
|---|
| 3726 | } |
|---|
| 3727 | return this.registerPlugin2(plugin, args); |
|---|
| 3728 | }; |
|---|
| 3729 | |
|---|
| 3730 | |
|---|
| 3731 | |
|---|
| 3732 | |
|---|
| 3733 | |
|---|
| 3734 | |
|---|
| 3735 | Xinha.prototype.registerPlugin2 = function(plugin, args) |
|---|
| 3736 | { |
|---|
| 3737 | if ( typeof plugin == "string" && typeof Xinha.getPluginConstructor(plugin) == 'function' ) |
|---|
| 3738 | { |
|---|
| 3739 | var pluginName = plugin; |
|---|
| 3740 | plugin = Xinha.getPluginConstructor(plugin); |
|---|
| 3741 | } |
|---|
| 3742 | if ( typeof plugin == "undefined" ) |
|---|
| 3743 | { |
|---|
| 3744 | |
|---|
| 3745 | return false; |
|---|
| 3746 | } |
|---|
| 3747 | if (!plugin._pluginInfo) |
|---|
| 3748 | { |
|---|
| 3749 | plugin._pluginInfo = |
|---|
| 3750 | { |
|---|
| 3751 | name: pluginName |
|---|
| 3752 | }; |
|---|
| 3753 | } |
|---|
| 3754 | var obj = new plugin(this, args); |
|---|
| 3755 | if ( obj ) |
|---|
| 3756 | { |
|---|
| 3757 | var clone = {}; |
|---|
| 3758 | var info = plugin._pluginInfo; |
|---|
| 3759 | for ( var i in info ) |
|---|
| 3760 | { |
|---|
| 3761 | clone[i] = info[i]; |
|---|
| 3762 | } |
|---|
| 3763 | clone.instance = obj; |
|---|
| 3764 | clone.args = args; |
|---|
| 3765 | this.plugins[plugin._pluginInfo.name] = clone; |
|---|
| 3766 | return obj; |
|---|
| 3767 | } |
|---|
| 3768 | else |
|---|
| 3769 | { |
|---|
| 3770 | Xinha.debugMsg("Can't register plugin " + plugin.toString() + ".", 'warn'); |
|---|
| 3771 | } |
|---|
| 3772 | }; |
|---|
| 3773 | |
|---|
| 3774 | |
|---|
| 3775 | |
|---|
| 3776 | |
|---|
| 3777 | |
|---|
| 3778 | |
|---|
| 3779 | |
|---|
| 3780 | |
|---|
| 3781 | |
|---|
| 3782 | |
|---|
| 3783 | Xinha.getPluginDir = function(plugin, forceUnsupported) |
|---|
| 3784 | { |
|---|
| 3785 | if (Xinha.externalPlugins[plugin]) |
|---|
| 3786 | { |
|---|
| 3787 | return Xinha.externalPlugins[plugin][0]; |
|---|
| 3788 | } |
|---|
| 3789 | if (forceUnsupported || |
|---|
| 3790 | |
|---|
| 3791 | (Xinha.getPluginConstructor(plugin) && (typeof Xinha.getPluginConstructor(plugin).supported != 'undefined') && !Xinha.getPluginConstructor(plugin).supported)) |
|---|
| 3792 | { |
|---|
| 3793 | return _editor_url + "unsupported_plugins/" + plugin ; |
|---|
| 3794 | } |
|---|
| 3795 | return _editor_url + "plugins/" + plugin ; |
|---|
| 3796 | }; |
|---|
| 3797 | |
|---|
| 3798 | |
|---|
| 3799 | |
|---|
| 3800 | |
|---|
| 3801 | |
|---|
| 3802 | |
|---|
| 3803 | Xinha.loadPlugin = function(pluginName, callback, url) |
|---|
| 3804 | { |
|---|
| 3805 | if (!Xinha.isSupportedBrowser) |
|---|
| 3806 | { |
|---|
| 3807 | return; |
|---|
| 3808 | } |
|---|
| 3809 | Xinha.setLoadingMessage (Xinha._lc("Loading plugin $plugin="+pluginName+"$")); |
|---|
| 3810 | |
|---|
| 3811 | |
|---|
| 3812 | if ( typeof Xinha.getPluginConstructor(pluginName) != 'undefined' ) |
|---|
| 3813 | { |
|---|
| 3814 | if ( callback ) |
|---|
| 3815 | { |
|---|
| 3816 | callback(pluginName); |
|---|
| 3817 | } |
|---|
| 3818 | return true; |
|---|
| 3819 | } |
|---|
| 3820 | Xinha._pluginLoadStatus[pluginName] = 'loading'; |
|---|
| 3821 | |
|---|
| 3822 | |
|---|
| 3823 | |
|---|
| 3824 | |
|---|
| 3825 | |
|---|
| 3826 | |
|---|
| 3827 | |
|---|
| 3828 | |
|---|
| 3829 | |
|---|
| 3830 | function multiStageLoader(stage,pluginName) |
|---|
| 3831 | { |
|---|
| 3832 | var nextstage, dir, file, success_message; |
|---|
| 3833 | switch (stage) |
|---|
| 3834 | { |
|---|
| 3835 | case 'start': |
|---|
| 3836 | nextstage = 'old_naming'; |
|---|
| 3837 | dir = Xinha.getPluginDir(pluginName); |
|---|
| 3838 | file = pluginName + ".js"; |
|---|
| 3839 | break; |
|---|
| 3840 | case 'old_naming': |
|---|
| 3841 | nextstage = 'unsupported'; |
|---|
| 3842 | dir = Xinha.getPluginDir(pluginName); |
|---|
| 3843 | file = pluginName.replace(/([a-z])([A-Z])([a-z])/g, function (str, l1, l2, l3) { return l1 + "-" + l2.toLowerCase() + l3; }).toLowerCase() + ".js"; |
|---|
| 3844 | success_message = 'You are using an obsolete naming scheme for the Xinha plugin '+pluginName+'. Please rename '+file+' to '+pluginName+'.js'; |
|---|
| 3845 | break; |
|---|
| 3846 | case 'unsupported': |
|---|
| 3847 | nextstage = 'unsupported_old_name'; |
|---|
| 3848 | dir = Xinha.getPluginDir(pluginName, true); |
|---|
| 3849 | file = pluginName + ".js"; |
|---|
| 3850 | success_message = 'You are using the unsupported Xinha plugin '+pluginName+'. If you wish continued support, please see http://trac.xinha.org/wiki/Documentation/UnsupportedPlugins'; |
|---|
| 3851 | break; |
|---|
| 3852 | case 'unsupported_old_name': |
|---|
| 3853 | nextstage = ''; |
|---|
| 3854 | dir = Xinha.getPluginDir(pluginName, true); |
|---|
| 3855 | file = pluginName.replace(/([a-z])([A-Z])([a-z])/g, function (str, l1, l2, l3) { return l1 + "-" + l2.toLowerCase() + l3; }).toLowerCase() + ".js"; |
|---|
| 3856 | success_message = 'You are using the unsupported Xinha plugin '+pluginName+'. If you wish continued support, please see http://trac.xinha.org/wiki/Documentation/UnsupportedPlugins'; |
|---|
| 3857 | break; |
|---|
| 3858 | default: |
|---|
| 3859 | Xinha._pluginLoadStatus[pluginName] = 'failed'; |
|---|
| 3860 | Xinha.debugMsg('Xinha was not able to find the plugin '+pluginName+'. Please make sure the plugin exists.', 'warn'); |
|---|
| 3861 | return; |
|---|
| 3862 | } |
|---|
| 3863 | var url = dir + "/" + file; |
|---|
| 3864 | |
|---|
| 3865 | |
|---|
| 3866 | |
|---|
| 3867 | function statusCallback(pluginName) |
|---|
| 3868 | { |
|---|
| 3869 | Xinha.getPluginConstructor(pluginName).supported = stage.indexOf('unsupported') !== 0; |
|---|
| 3870 | callback(pluginName); |
|---|
| 3871 | } |
|---|
| 3872 | |
|---|
| 3873 | |
|---|
| 3874 | |
|---|
| 3875 | Xinha._loadback(url, statusCallback, this, pluginName); |
|---|
| 3876 | |
|---|
| 3877 | Xinha.ping(url, |
|---|
| 3878 | |
|---|
| 3879 | function() |
|---|
| 3880 | { |
|---|
| 3881 | if (success_message) |
|---|
| 3882 | { |
|---|
| 3883 | Xinha.debugMsg(success_message); |
|---|
| 3884 | } |
|---|
| 3885 | }, |
|---|
| 3886 | |
|---|
| 3887 | function() |
|---|
| 3888 | { |
|---|
| 3889 | Xinha.removeFromParent(document.getElementById(url)); |
|---|
| 3890 | multiStageLoader(nextstage, pluginName); |
|---|
| 3891 | }); |
|---|
| 3892 | } |
|---|
| 3893 | |
|---|
| 3894 | if(!url) |
|---|
| 3895 | { |
|---|
| 3896 | if (Xinha.externalPlugins[pluginName]) |
|---|
| 3897 | { |
|---|
| 3898 | Xinha._loadback(Xinha.externalPlugins[pluginName][0]+Xinha.externalPlugins[pluginName][1], callback, this, pluginName); |
|---|
| 3899 | } |
|---|
| 3900 | else |
|---|
| 3901 | { |
|---|
| 3902 | var editor = this; |
|---|
| 3903 | multiStageLoader('start',pluginName); |
|---|
| 3904 | } |
|---|
| 3905 | } |
|---|
| 3906 | else |
|---|
| 3907 | { |
|---|
| 3908 | Xinha._loadback(url, callback, this, pluginName); |
|---|
| 3909 | } |
|---|
| 3910 | |
|---|
| 3911 | return false; |
|---|
| 3912 | }; |
|---|
| 3913 | |
|---|
| 3914 | |
|---|
| 3915 | |
|---|
| 3916 | |
|---|
| 3917 | Xinha._pluginLoadStatus = {}; |
|---|
| 3918 | |
|---|
| 3919 | |
|---|
| 3920 | |
|---|
| 3921 | |
|---|
| 3922 | Xinha.externalPlugins = {}; |
|---|
| 3923 | |
|---|
| 3924 | |
|---|
| 3925 | |
|---|
| 3926 | |
|---|
| 3927 | Xinha.plugins = {}; |
|---|
| 3928 | |
|---|
| 3929 | |
|---|
| 3930 | |
|---|
| 3931 | |
|---|
| 3932 | |
|---|
| 3933 | |
|---|
| 3934 | |
|---|
| 3935 | Xinha.loadPlugins = function(plugins, callbackIfNotReady,url) |
|---|
| 3936 | { |
|---|
| 3937 | if (!Xinha.isSupportedBrowser) |
|---|
| 3938 | { |
|---|
| 3939 | return; |
|---|
| 3940 | } |
|---|
| 3941 | |
|---|
| 3942 | var m,i; |
|---|
| 3943 | for (i=0;i<plugins.length;i++) |
|---|
| 3944 | { |
|---|
| 3945 | if (typeof plugins[i] == 'object') |
|---|
| 3946 | { |
|---|
| 3947 | m = plugins[i].url.match(/(.*)(\/[^\/]*)$/); |
|---|
| 3948 | Xinha.externalPlugins[plugins[i].plugin] = [m[1],m[2]]; |
|---|
| 3949 | plugins[i] = plugins[i].plugin; |
|---|
| 3950 | } |
|---|
| 3951 | } |
|---|
| 3952 | |
|---|
| 3953 | |
|---|
| 3954 | var retVal = true; |
|---|
| 3955 | var nuPlugins = Xinha.cloneObject(plugins); |
|---|
| 3956 | for (i=0;i<nuPlugins.length;i++ ) |
|---|
| 3957 | { |
|---|
| 3958 | var p = nuPlugins[i]; |
|---|
| 3959 | |
|---|
| 3960 | if (p == 'FullScreen' && !Xinha.externalPlugins.FullScreen) |
|---|
| 3961 | { |
|---|
| 3962 | continue; |
|---|
| 3963 | } |
|---|
| 3964 | |
|---|
| 3965 | if ( typeof Xinha._pluginLoadStatus[p] == 'undefined') |
|---|
| 3966 | { |
|---|
| 3967 | |
|---|
| 3968 | Xinha.loadPlugin(p, |
|---|
| 3969 | function(plugin) |
|---|
| 3970 | { |
|---|
| 3971 | Xinha.setLoadingMessage (Xinha._lc("Finishing")); |
|---|
| 3972 | |
|---|
| 3973 | if ( typeof Xinha.getPluginConstructor(plugin) != 'undefined' ) |
|---|
| 3974 | { |
|---|
| 3975 | Xinha._pluginLoadStatus[plugin] = 'ready'; |
|---|
| 3976 | } |
|---|
| 3977 | else |
|---|
| 3978 | { |
|---|
| 3979 | Xinha._pluginLoadStatus[plugin] = 'failed'; |
|---|
| 3980 | } |
|---|
| 3981 | }, url); |
|---|
| 3982 | retVal = false; |
|---|
| 3983 | } |
|---|
| 3984 | else if ( Xinha._pluginLoadStatus[p] == 'loading') |
|---|
| 3985 | { |
|---|
| 3986 | retVal = false; |
|---|
| 3987 | } |
|---|
| 3988 | } |
|---|
| 3989 | |
|---|
| 3990 | |
|---|
| 3991 | if ( retVal ) |
|---|
| 3992 | { |
|---|
| 3993 | return true; |
|---|
| 3994 | } |
|---|
| 3995 | |
|---|
| 3996 | |
|---|
| 3997 | |
|---|
| 3998 | if ( callbackIfNotReady ) |
|---|
| 3999 | { |
|---|
| 4000 | setTimeout(function() |
|---|
| 4001 | { |
|---|
| 4002 | if ( Xinha.loadPlugins(plugins, callbackIfNotReady) ) |
|---|
| 4003 | { |
|---|
| 4004 | callbackIfNotReady(); |
|---|
| 4005 | } |
|---|
| 4006 | }, 50); |
|---|
| 4007 | } |
|---|
| 4008 | return retVal; |
|---|
| 4009 | }; |
|---|
| 4010 | |
|---|
| 4011 | |
|---|
| 4012 | |
|---|
| 4013 | |
|---|
| 4014 | |
|---|
| 4015 | |
|---|
| 4016 | Xinha.refreshPlugin = function(plugin) |
|---|
| 4017 | { |
|---|
| 4018 | if ( plugin && typeof plugin.onGenerate == "function" ) |
|---|
| 4019 | { |
|---|
| 4020 | plugin.onGenerate(); |
|---|
| 4021 | } |
|---|
| 4022 | if ( plugin && typeof plugin.onGenerateOnce == "function" ) |
|---|
| 4023 | { |
|---|
| 4024 | |
|---|
| 4025 | |
|---|
| 4026 | plugin._ongenerateOnce = plugin.onGenerateOnce; |
|---|
| 4027 | delete(plugin.onGenerateOnce); |
|---|
| 4028 | plugin._ongenerateOnce(); |
|---|
| 4029 | delete(plugin._ongenerateOnce); |
|---|
| 4030 | } |
|---|
| 4031 | }; |
|---|
| 4032 | |
|---|
| 4033 | |
|---|
| 4034 | |
|---|
| 4035 | |
|---|
| 4036 | |
|---|
| 4037 | |
|---|
| 4038 | |
|---|
| 4039 | |
|---|
| 4040 | |
|---|
| 4041 | |
|---|
| 4042 | |
|---|
| 4043 | |
|---|
| 4044 | |
|---|
| 4045 | |
|---|
| 4046 | |
|---|
| 4047 | |
|---|
| 4048 | |
|---|
| 4049 | |
|---|
| 4050 | |
|---|
| 4051 | |
|---|
| 4052 | |
|---|
| 4053 | |
|---|
| 4054 | |
|---|
| 4055 | |
|---|
| 4056 | |
|---|
| 4057 | |
|---|
| 4058 | |
|---|
| 4059 | |
|---|
| 4060 | |
|---|
| 4061 | |
|---|
| 4062 | |
|---|
| 4063 | Xinha.prototype.firePluginEvent = function(methodName) |
|---|
| 4064 | { |
|---|
| 4065 | |
|---|
| 4066 | var argsArray = [ ]; |
|---|
| 4067 | for(var i = 1; i < arguments.length; i++) |
|---|
| 4068 | { |
|---|
| 4069 | argsArray[i-1] = arguments[i]; |
|---|
| 4070 | } |
|---|
| 4071 | |
|---|
| 4072 | for ( i in this.plugins ) |
|---|
| 4073 | { |
|---|
| 4074 | var plugin = this.plugins[i].instance; |
|---|
| 4075 | |
|---|
| 4076 | |
|---|
| 4077 | if (plugin == this._browserSpecificPlugin) |
|---|
| 4078 | { |
|---|
| 4079 | continue; |
|---|
| 4080 | } |
|---|
| 4081 | if ( plugin && typeof plugin[methodName] == "function" ) |
|---|
| 4082 | { |
|---|
| 4083 | var thisArg = (i == 'Events') ? this : plugin; |
|---|
| 4084 | if ( plugin[methodName].apply(thisArg, argsArray) ) |
|---|
| 4085 | { |
|---|
| 4086 | return true; |
|---|
| 4087 | } |
|---|
| 4088 | } |
|---|
| 4089 | } |
|---|
| 4090 | |
|---|
| 4091 | |
|---|
| 4092 | plugin = this._browserSpecificPlugin; |
|---|
| 4093 | if ( plugin && typeof plugin[methodName] == "function" ) |
|---|
| 4094 | { |
|---|
| 4095 | if ( plugin[methodName].apply(plugin, argsArray) ) |
|---|
| 4096 | { |
|---|
| 4097 | return true; |
|---|
| 4098 | } |
|---|
| 4099 | } |
|---|
| 4100 | return false; |
|---|
| 4101 | }; |
|---|
| 4102 | |
|---|
| 4103 | |
|---|
| 4104 | |
|---|
| 4105 | |
|---|
| 4106 | |
|---|
| 4107 | |
|---|
| 4108 | Xinha.loadStyle = function(style, plugin, id,prepend) |
|---|
| 4109 | { |
|---|
| 4110 | var url = _editor_url || ''; |
|---|
| 4111 | if ( plugin ) |
|---|
| 4112 | { |
|---|
| 4113 | url = Xinha.getPluginDir( plugin ) + "/"; |
|---|
| 4114 | } |
|---|
| 4115 | url += style; |
|---|
| 4116 | |
|---|
| 4117 | |
|---|
| 4118 | |
|---|
| 4119 | |
|---|
| 4120 | |
|---|
| 4121 | if ( /^\ |
|---|
| 4122 | { |
|---|
| 4123 | url = style; |
|---|
| 4124 | } |
|---|
| 4125 | var head = document.getElementsByTagName("head")[0]; |
|---|
| 4126 | var link = document.createElement("link"); |
|---|
| 4127 | link.rel = "stylesheet"; |
|---|
| 4128 | link.href = url; |
|---|
| 4129 | link.type = "text/css"; |
|---|
| 4130 | if (id) |
|---|
| 4131 | { |
|---|
| 4132 | link.id = id; |
|---|
| 4133 | } |
|---|
| 4134 | if (prepend && head.getElementsByTagName('link')[0]) |
|---|
| 4135 | { |
|---|
| 4136 | head.insertBefore(link,head.getElementsByTagName('link')[0]); |
|---|
| 4137 | } |
|---|
| 4138 | else |
|---|
| 4139 | { |
|---|
| 4140 | head.appendChild(link); |
|---|
| 4141 | } |
|---|
| 4142 | |
|---|
| 4143 | }; |
|---|
| 4144 | |
|---|
| 4145 | |
|---|
| 4146 | |
|---|
| 4147 | |
|---|
| 4148 | |
|---|
| 4149 | |
|---|
| 4150 | |
|---|
| 4151 | |
|---|
| 4152 | |
|---|
| 4153 | Xinha.loadScript = function(script, plugin, callback) |
|---|
| 4154 | { |
|---|
| 4155 | var url = _editor_url || ''; |
|---|
| 4156 | if ( plugin ) |
|---|
| 4157 | { |
|---|
| 4158 | url = Xinha.getPluginDir( plugin ) + "/"; |
|---|
| 4159 | } |
|---|
| 4160 | url += script; |
|---|
| 4161 | |
|---|
| 4162 | |
|---|
| 4163 | |
|---|
| 4164 | |
|---|
| 4165 | |
|---|
| 4166 | if ( /^\ |
|---|
| 4167 | { |
|---|
| 4168 | url = script; |
|---|
| 4169 | } |
|---|
| 4170 | |
|---|
| 4171 | Xinha._loadback(url, callback); |
|---|
| 4172 | |
|---|
| 4173 | }; |
|---|
| 4174 | |
|---|
| 4175 | |
|---|
| 4176 | |
|---|
| 4177 | |
|---|
| 4178 | |
|---|
| 4179 | |
|---|
| 4180 | |
|---|
| 4181 | |
|---|
| 4182 | |
|---|
| 4183 | |
|---|
| 4184 | |
|---|
| 4185 | |
|---|
| 4186 | |
|---|
| 4187 | |
|---|
| 4188 | |
|---|
| 4189 | |
|---|
| 4190 | |
|---|
| 4191 | |
|---|
| 4192 | Xinha.includeAssets = function() |
|---|
| 4193 | { |
|---|
| 4194 | var assetLoader = { pendingAssets: [ ], loaderRunning: false, loadedScripts: [ ] }; |
|---|
| 4195 | |
|---|
| 4196 | assetLoader.callbacks = [ ]; |
|---|
| 4197 | |
|---|
| 4198 | assetLoader.loadNext = function() |
|---|
| 4199 | { |
|---|
| 4200 | var self = this; |
|---|
| 4201 | this.loaderRunning = true; |
|---|
| 4202 | |
|---|
| 4203 | if(this.pendingAssets.length) |
|---|
| 4204 | { |
|---|
| 4205 | var nxt = this.pendingAssets[0]; |
|---|
| 4206 | this.pendingAssets.splice(0,1); |
|---|
| 4207 | switch(nxt.type) |
|---|
| 4208 | { |
|---|
| 4209 | case 'text/css': |
|---|
| 4210 | Xinha.loadStyle(nxt.url, nxt.plugin); |
|---|
| 4211 | return this.loadNext(); |
|---|
| 4212 | |
|---|
| 4213 | case 'text/javascript': |
|---|
| 4214 | this.loadedScripts.push(nxt); |
|---|
| 4215 | Xinha.loadScript(nxt.url, nxt.plugin, function() { self.loadNext(); }); |
|---|
| 4216 | } |
|---|
| 4217 | } |
|---|
| 4218 | else |
|---|
| 4219 | { |
|---|
| 4220 | this.loaderRunning = false; |
|---|
| 4221 | this.runCallback(); |
|---|
| 4222 | } |
|---|
| 4223 | }; |
|---|
| 4224 | |
|---|
| 4225 | assetLoader.loadScript = function(url, plugin) |
|---|
| 4226 | { |
|---|
| 4227 | var self = this; |
|---|
| 4228 | |
|---|
| 4229 | this.pendingAssets.push({ 'type': 'text/javascript', 'url': url, 'plugin': plugin }); |
|---|
| 4230 | if(!this.loaderRunning) this.loadNext(); |
|---|
| 4231 | |
|---|
| 4232 | return this; |
|---|
| 4233 | }; |
|---|
| 4234 | |
|---|
| 4235 | assetLoader.loadScriptOnce = function(url, plugin) |
|---|
| 4236 | { |
|---|
| 4237 | for(var i = 0; i < this.loadedScripts.length; i++) |
|---|
| 4238 | { |
|---|
| 4239 | if(this.loadedScripts[i].url == url && this.loadedScripts[i].plugin == plugin) |
|---|
| 4240 | { |
|---|
| 4241 | if(!this.loaderRunning) this.loadNext(); |
|---|
| 4242 | return this; |
|---|
| 4243 | } |
|---|
| 4244 | } |
|---|
| 4245 | |
|---|
| 4246 | for(var i = 0; i < this.pendingAssets.length; i++) |
|---|
| 4247 | { |
|---|
| 4248 | if(this.pendingAssets[i].url == url && this.pendingAssets[i].plugin == plugin) |
|---|
| 4249 | { |
|---|
| 4250 | if(!this.loaderRunning) this.loadNext(); |
|---|
| 4251 | return this; |
|---|
| 4252 | } |
|---|
| 4253 | } |
|---|
| 4254 | |
|---|
| 4255 | return this.loadScript(url, plugin); |
|---|
| 4256 | } |
|---|
| 4257 | |
|---|
| 4258 | assetLoader.loadStyle = function(url, plugin) |
|---|
| 4259 | { |
|---|
| 4260 | var self = this; |
|---|
| 4261 | |
|---|
| 4262 | this.pendingAssets.push({ 'type': 'text/css', 'url': url, 'plugin': plugin }); |
|---|
| 4263 | if(!this.loaderRunning) this.loadNext(); |
|---|
| 4264 | |
|---|
| 4265 | return this; |
|---|
| 4266 | }; |
|---|
| 4267 | |
|---|
| 4268 | assetLoader.whenReady = function(callback) |
|---|
| 4269 | { |
|---|
| 4270 | this.callbacks.push(callback); |
|---|
| 4271 | if(!this.loaderRunning) this.loadNext(); |
|---|
| 4272 | |
|---|
| 4273 | return this; |
|---|
| 4274 | }; |
|---|
| 4275 | |
|---|
| 4276 | assetLoader.runCallback = function() |
|---|
| 4277 | { |
|---|
| 4278 | while(this.callbacks.length) |
|---|
| 4279 | { |
|---|
| 4280 | var _callback = this.callbacks.splice(0,1); |
|---|
| 4281 | _callback[0](); |
|---|
| 4282 | _callback = null; |
|---|
| 4283 | } |
|---|
| 4284 | return this; |
|---|
| 4285 | } |
|---|
| 4286 | |
|---|
| 4287 | for(var i = 0 ; i < arguments.length; i++) |
|---|
| 4288 | { |
|---|
| 4289 | if(typeof arguments[i] == 'string') |
|---|
| 4290 | { |
|---|
| 4291 | if(arguments[i].match(/\.css$/i)) |
|---|
| 4292 | { |
|---|
| 4293 | assetLoader.loadStyle(arguments[i]); |
|---|
| 4294 | } |
|---|
| 4295 | else |
|---|
| 4296 | { |
|---|
| 4297 | assetLoader.loadScript(arguments[i]); |
|---|
| 4298 | } |
|---|
| 4299 | } |
|---|
| 4300 | else if(arguments[i].type) |
|---|
| 4301 | { |
|---|
| 4302 | if(arguments[i].type.match(/text\/css/i)) |
|---|
| 4303 | { |
|---|
| 4304 | assetLoader.loadStyle(arguments[i].url, arguments[i].plugin); |
|---|
| 4305 | } |
|---|
| 4306 | else if(arguments[i].type.match(/text\/javascript/i)) |
|---|
| 4307 | { |
|---|
| 4308 | assetLoader.loadScript(arguments[i].url, arguments[i].plugin); |
|---|
| 4309 | } |
|---|
| 4310 | } |
|---|
| 4311 | else if(arguments[i].length >= 1) |
|---|
| 4312 | { |
|---|
| 4313 | if(arguments[i][0].match(/\.css$/i)) |
|---|
| 4314 | { |
|---|
| 4315 | assetLoader.loadStyle(arguments[i][0], arguments[i][1]); |
|---|
| 4316 | } |
|---|
| 4317 | else |
|---|
| 4318 | { |
|---|
| 4319 | assetLoader.loadScript(arguments[i][0], arguments[i][1]); |
|---|
| 4320 | } |
|---|
| 4321 | } |
|---|
| 4322 | } |
|---|
| 4323 | |
|---|
| 4324 | return assetLoader; |
|---|
| 4325 | } |
|---|
| 4326 | |
|---|
| 4327 | |
|---|
| 4328 | |
|---|
| 4329 | |
|---|
| 4330 | |
|---|
| 4331 | Xinha.prototype.debugTree = function() |
|---|
| 4332 | { |
|---|
| 4333 | var ta = document.createElement("textarea"); |
|---|
| 4334 | ta.style.width = "100%"; |
|---|
| 4335 | ta.style.height = "20em"; |
|---|
| 4336 | ta.value = ""; |
|---|
| 4337 | function debug(indent, str) |
|---|
| 4338 | { |
|---|
| 4339 | for ( ; --indent >= 0; ) |
|---|
| 4340 | { |
|---|
| 4341 | ta.value += " "; |
|---|
| 4342 | } |
|---|
| 4343 | ta.value += str + "\n"; |
|---|
| 4344 | } |
|---|
| 4345 | function _dt(root, level) |
|---|
| 4346 | { |
|---|
| 4347 | var tag = root.tagName.toLowerCase(), i; |
|---|
| 4348 | var ns = Xinha.is_ie ? root.scopeName : root.prefix; |
|---|
| 4349 | debug(level, "- " + tag + " [" + ns + "]"); |
|---|
| 4350 | for ( i = root.firstChild; i; i = i.nextSibling ) |
|---|
| 4351 | { |
|---|
| 4352 | if ( i.nodeType == 1 ) |
|---|
| 4353 | { |
|---|
| 4354 | _dt(i, level + 2); |
|---|
| 4355 | } |
|---|
| 4356 | } |
|---|
| 4357 | } |
|---|
| 4358 | _dt(this._doc.body, 0); |
|---|
| 4359 | document.body.appendChild(ta); |
|---|
| 4360 | }; |
|---|
| 4361 | |
|---|
| 4362 | |
|---|
| 4363 | |
|---|
| 4364 | |
|---|
| 4365 | Xinha.getInnerText = function(el) |
|---|
| 4366 | { |
|---|
| 4367 | var txt = '', i; |
|---|
| 4368 | for ( i = el.firstChild; i; i = i.nextSibling ) |
|---|
| 4369 | { |
|---|
| 4370 | if ( i.nodeType == 3 ) |
|---|
| 4371 | { |
|---|
| 4372 | txt += i.data; |
|---|
| 4373 | } |
|---|
| 4374 | else if ( i.nodeType == 1 ) |
|---|
| 4375 | { |
|---|
| 4376 | txt += Xinha.getInnerText(i); |
|---|
| 4377 | } |
|---|
| 4378 | } |
|---|
| 4379 | return txt; |
|---|
| 4380 | }; |
|---|
| 4381 | |
|---|
| 4382 | |
|---|
| 4383 | |
|---|
| 4384 | |
|---|
| 4385 | Xinha.prototype._wordClean = function() |
|---|
| 4386 | { |
|---|
| 4387 | var editor = this; |
|---|
| 4388 | var stats = |
|---|
| 4389 | { |
|---|
| 4390 | empty_tags : 0, |
|---|
| 4391 | cond_comm : 0, |
|---|
| 4392 | mso_elmts : 0, |
|---|
| 4393 | mso_class : 0, |
|---|
| 4394 | mso_style : 0, |
|---|
| 4395 | mso_xmlel : 0, |
|---|
| 4396 | orig_len : this._doc.body.innerHTML.length, |
|---|
| 4397 | T : new Date().getTime() |
|---|
| 4398 | }; |
|---|
| 4399 | var stats_txt = |
|---|
| 4400 | { |
|---|
| 4401 | empty_tags : "Empty tags removed: ", |
|---|
| 4402 | cond_comm : "Conditional comments removed", |
|---|
| 4403 | mso_elmts : "MSO invalid elements removed", |
|---|
| 4404 | mso_class : "MSO class names removed: ", |
|---|
| 4405 | mso_style : "MSO inline style removed: ", |
|---|
| 4406 | mso_xmlel : "MSO XML elements stripped: " |
|---|
| 4407 | }; |
|---|
| 4408 | |
|---|
| 4409 | function showStats() |
|---|
| 4410 | { |
|---|
| 4411 | var txt = "Xinha word cleaner stats: \n\n"; |
|---|
| 4412 | for ( var i in stats ) |
|---|
| 4413 | { |
|---|
| 4414 | if ( stats_txt[i] ) |
|---|
| 4415 | { |
|---|
| 4416 | txt += stats_txt[i] + stats[i] + "\n"; |
|---|
| 4417 | } |
|---|
| 4418 | } |
|---|
| 4419 | txt += "\nInitial document length: " + stats.orig_len + "\n"; |
|---|
| 4420 | txt += "Final document length: " + editor._doc.body.innerHTML.length + "\n"; |
|---|
| 4421 | txt += "Clean-up took " + ((new Date().getTime() - stats.T) / 1000) + " seconds"; |
|---|
| 4422 | alert(txt); |
|---|
| 4423 | } |
|---|
| 4424 | |
|---|
| 4425 | function clearClass(node) |
|---|
| 4426 | { |
|---|
| 4427 | var newc = node.className.replace(/(^|\s)mso.*?(\s|$)/ig, ' '); |
|---|
| 4428 | if ( newc != node.className ) |
|---|
| 4429 | { |
|---|
| 4430 | node.className = newc; |
|---|
| 4431 | if ( !/\S/.test(node.className)) |
|---|
| 4432 | { |
|---|
| 4433 | node.removeAttribute("className"); |
|---|
| 4434 | ++stats.mso_class; |
|---|
| 4435 | } |
|---|
| 4436 | } |
|---|
| 4437 | } |
|---|
| 4438 | |
|---|
| 4439 | function clearStyle(node) |
|---|
| 4440 | { |
|---|
| 4441 | var declarations = node.style.cssText.split(/\s*;\s*/); |
|---|
| 4442 | for ( var i = declarations.length; --i >= 0; ) |
|---|
| 4443 | { |
|---|
| 4444 | if ( /^mso|^tab-stops/i.test(declarations[i]) || /^margin\s*:\s*0..\s+0..\s+0../i.test(declarations[i]) ) |
|---|
| 4445 | { |
|---|
| 4446 | ++stats.mso_style; |
|---|
| 4447 | declarations.splice(i, 1); |
|---|
| 4448 | } |
|---|
| 4449 | } |
|---|
| 4450 | node.style.cssText = declarations.join("; "); |
|---|
| 4451 | } |
|---|
| 4452 | |
|---|
| 4453 | function removeElements(el) |
|---|
| 4454 | { |
|---|
| 4455 | if (('link' == el.tagName.toLowerCase() && |
|---|
| 4456 | (el.attributes && /File-List|Edit-Time-Data|themeData|colorSchemeMapping/.test(el.attributes.rel.nodeValue))) || |
|---|
| 4457 | /^(style|meta)$/i.test(el.tagName)) |
|---|
| 4458 | { |
|---|
| 4459 | Xinha.removeFromParent(el); |
|---|
| 4460 | ++stats.mso_elmts; |
|---|
| 4461 | return true; |
|---|
| 4462 | } |
|---|
| 4463 | return false; |
|---|
| 4464 | } |
|---|
| 4465 | |
|---|
| 4466 | function checkEmpty(el) |
|---|
| 4467 | { |
|---|
| 4468 | |
|---|
| 4469 | |
|---|
| 4470 | if ( /^(a|span|b|strong|i|em|font|div|p)$/i.test(el.tagName) && !el.firstChild) |
|---|
| 4471 | { |
|---|
| 4472 | Xinha.removeFromParent(el); |
|---|
| 4473 | ++stats.empty_tags; |
|---|
| 4474 | return true; |
|---|
| 4475 | } |
|---|
| 4476 | return false; |
|---|
| 4477 | } |
|---|
| 4478 | |
|---|
| 4479 | function parseTree(root) |
|---|
| 4480 | { |
|---|
| 4481 | clearClass(root); |
|---|
| 4482 | clearStyle(root); |
|---|
| 4483 | var next; |
|---|
| 4484 | for (var i = root.firstChild; i; i = next ) |
|---|
| 4485 | { |
|---|
| 4486 | next = i.nextSibling; |
|---|
| 4487 | if ( i.nodeType == 1 && parseTree(i) ) |
|---|
| 4488 | { |
|---|
| 4489 | if ((Xinha.is_ie && root.scopeName != 'HTML') || (!Xinha.is_ie && /:/.test(i.tagName))) |
|---|
| 4490 | { |
|---|
| 4491 | |
|---|
| 4492 | |
|---|
| 4493 | |
|---|
| 4494 | |
|---|
| 4495 | |
|---|
| 4496 | |
|---|
| 4497 | |
|---|
| 4498 | for (var index=i.childNodes && i.childNodes.length-1; i.childNodes && i.childNodes.length && i.childNodes[index]; --index) |
|---|
| 4499 | { |
|---|
| 4500 | if (i.nextSibling) |
|---|
| 4501 | { |
|---|
| 4502 | i.parentNode.insertBefore(i.childNodes[index],i.nextSibling); |
|---|
| 4503 | } |
|---|
| 4504 | else |
|---|
| 4505 | { |
|---|
| 4506 | i.parentNode.appendChild(i.childNodes[index]); |
|---|
| 4507 | } |
|---|
| 4508 | } |
|---|
| 4509 | Xinha.removeFromParent(i); |
|---|
| 4510 | continue; |
|---|
| 4511 | } |
|---|
| 4512 | if (checkEmpty(i)) |
|---|
| 4513 | { |
|---|
| 4514 | continue; |
|---|
| 4515 | } |
|---|
| 4516 | if (removeElements(i)) |
|---|
| 4517 | { |
|---|
| 4518 | continue; |
|---|
| 4519 | } |
|---|
| 4520 | } |
|---|
| 4521 | else if (i.nodeType == 8) |
|---|
| 4522 | { |
|---|
| 4523 | |
|---|
| 4524 | |
|---|
| 4525 | if (/(\s*\[\s*if\s*(([gl]te?|!)\s*)?(IE|mso)\s*(\d+(\.\d+)?\s*)?\]>)/.test(i.nodeValue)) |
|---|
| 4526 | { |
|---|
| 4527 | |
|---|
| 4528 | Xinha.removeFromParent(i); |
|---|
| 4529 | ++stats.cond_comm; |
|---|
| 4530 | } |
|---|
| 4531 | } |
|---|
| 4532 | } |
|---|
| 4533 | return true; |
|---|
| 4534 | } |
|---|
| 4535 | parseTree(this._doc.body); |
|---|
| 4536 | |
|---|
| 4537 | |
|---|
| 4538 | |
|---|
| 4539 | |
|---|
| 4540 | |
|---|
| 4541 | this.updateToolbar(); |
|---|
| 4542 | }; |
|---|
| 4543 | |
|---|
| 4544 | |
|---|
| 4545 | |
|---|
| 4546 | |
|---|
| 4547 | |
|---|
| 4548 | Xinha.prototype._clearFonts = function() |
|---|
| 4549 | { |
|---|
| 4550 | var D = this.getInnerHTML(); |
|---|
| 4551 | |
|---|
| 4552 | if ( confirm(Xinha._lc("Would you like to clear font typefaces?")) ) |
|---|
| 4553 | { |
|---|
| 4554 | D = D.replace(/face="[^"]*"/gi, ''); |
|---|
| 4555 | D = D.replace(/font-family:[^;}"']+;?/gi, ''); |
|---|
| 4556 | } |
|---|
| 4557 | |
|---|
| 4558 | if ( confirm(Xinha._lc("Would you like to clear font sizes?")) ) |
|---|
| 4559 | { |
|---|
| 4560 | D = D.replace(/size="[^"]*"/gi, ''); |
|---|
| 4561 | D = D.replace(/font-size:[^;}"']+;?/gi, ''); |
|---|
| 4562 | } |
|---|
| 4563 | |
|---|
| 4564 | if ( confirm(Xinha._lc("Would you like to clear font colours?")) ) |
|---|
| 4565 | { |
|---|
| 4566 | D = D.replace(/color="[^"]*"/gi, ''); |
|---|
| 4567 | D = D.replace(/([^\-])color:[^;}"']+;?/gi, '$1'); |
|---|
| 4568 | } |
|---|
| 4569 | |
|---|
| 4570 | D = D.replace(/(style|class)="\s*"/gi, ''); |
|---|
| 4571 | D = D.replace(/<(font|span)\s*>/gi, ''); |
|---|
| 4572 | this.setHTML(D); |
|---|
| 4573 | this.updateToolbar(); |
|---|
| 4574 | }; |
|---|
| 4575 | |
|---|
| 4576 | Xinha.prototype._splitBlock = function() |
|---|
| 4577 | { |
|---|
| 4578 | this._doc.execCommand('formatblock', false, 'div'); |
|---|
| 4579 | }; |
|---|
| 4580 | |
|---|
| 4581 | /** Sometimes the display has to be refreshed to make DOM changes visible (?) (Gecko bug?) */ |
|---|
| 4582 | Xinha.prototype.forceRedraw = function() |
|---|
| 4583 | { |
|---|
| 4584 | this._doc.body.style.visibility = "hidden"; |
|---|
| 4585 | this._doc.body.style.visibility = ""; |
|---|
| 4586 | // this._doc.body.innerHTML = this.getInnerHTML(); |
|---|
| 4587 | }; |
|---|
| 4588 | |
|---|
| 4589 | /** Focuses the iframe window. |
|---|
| 4590 | * @returns {document} a reference to the editor document |
|---|
| 4591 | */ |
|---|
| 4592 | Xinha.prototype.focusEditor = function() |
|---|
| 4593 | { |
|---|
| 4594 | switch (this._editMode) |
|---|
| 4595 | { |
|---|
| 4596 | // notice the try { ... } catch block to avoid some rare exceptions in FireFox |
|---|
| 4597 | // (perhaps also in other Gecko browsers). Manual focus by user is required in |
|---|
| 4598 | // case of an error. Somebody has an idea? |
|---|
| 4599 | case "wysiwyg" : |
|---|
| 4600 | try |
|---|
| 4601 | { |
|---|
| 4602 | // We don't want to focus the field unless at least one field has been activated. |
|---|
| 4603 | if ( Xinha._someEditorHasBeenActivated ) |
|---|
| 4604 | { |
|---|
| 4605 | this.activateEditor(); |
|---|
| 4606 | this._iframe.contentWindow.focus(); |
|---|
| 4607 | } |
|---|
| 4608 | } catch (ex) {} |
|---|
| 4609 | break; |
|---|
| 4610 | case "textmode": |
|---|
| 4611 | try |
|---|
| 4612 | { |
|---|
| 4613 | this._textArea.focus(); |
|---|
| 4614 | } catch (e) {} |
|---|
| 4615 | break; |
|---|
| 4616 | default: |
|---|
| 4617 | alert("ERROR: mode " + this._editMode + " is not defined"); |
|---|
| 4618 | } |
|---|
| 4619 | return this._doc; |
|---|
| 4620 | }; |
|---|
| 4621 | |
|---|
| 4622 | |
|---|
| 4623 | |
|---|
| 4624 | |
|---|
| 4625 | Xinha.prototype._undoTakeSnapshot = function() |
|---|
| 4626 | { |
|---|
| 4627 | ++this._undoPos; |
|---|
| 4628 | if ( this._undoPos >= this.config.undoSteps ) |
|---|
| 4629 | { |
|---|
| 4630 | |
|---|
| 4631 | this._undoQueue.shift(); |
|---|
| 4632 | --this._undoPos; |
|---|
| 4633 | } |
|---|
| 4634 | |
|---|
| 4635 | var take = true; |
|---|
| 4636 | var txt = this.getInnerHTML(); |
|---|
| 4637 | if ( this._undoPos > 0 ) |
|---|
| 4638 | { |
|---|
| 4639 | take = (this._undoQueue[this._undoPos - 1] != txt); |
|---|
| 4640 | } |
|---|
| 4641 | if ( take ) |
|---|
| 4642 | { |
|---|
| 4643 | this._undoQueue[this._undoPos] = txt; |
|---|
| 4644 | } |
|---|
| 4645 | else |
|---|
| 4646 | { |
|---|
| 4647 | this._undoPos--; |
|---|
| 4648 | } |
|---|
| 4649 | }; |
|---|
| 4650 | |
|---|
| 4651 | |
|---|
| 4652 | |
|---|
| 4653 | Xinha.prototype.undo = function() |
|---|
| 4654 | { |
|---|
| 4655 | if ( this._undoPos > 0 ) |
|---|
| 4656 | { |
|---|
| 4657 | var txt = this._undoQueue[--this._undoPos]; |
|---|
| 4658 | if ( txt ) |
|---|
| 4659 | { |
|---|
| 4660 | this.setHTML(txt); |
|---|
| 4661 | } |
|---|
| 4662 | else |
|---|
| 4663 | { |
|---|
| 4664 | ++this._undoPos; |
|---|
| 4665 | } |
|---|
| 4666 | } |
|---|
| 4667 | }; |
|---|
| 4668 | |
|---|
| 4669 | |
|---|
| 4670 | |
|---|
| 4671 | Xinha.prototype.redo = function() |
|---|
| 4672 | { |
|---|
| 4673 | if ( this._undoPos < this._undoQueue.length - 1 ) |
|---|
| 4674 | { |
|---|
| 4675 | var txt = this._undoQueue[++this._undoPos]; |
|---|
| 4676 | if ( txt ) |
|---|
| 4677 | { |
|---|
| 4678 | this.setHTML(txt); |
|---|
| 4679 | } |
|---|
| 4680 | else |
|---|
| 4681 | { |
|---|
| 4682 | --this._undoPos; |
|---|
| 4683 | } |
|---|
| 4684 | } |
|---|
| 4685 | }; |
|---|
| 4686 | |
|---|
| 4687 | |
|---|
| 4688 | |
|---|
| 4689 | Xinha.prototype.disableToolbar = function(except) |
|---|
| 4690 | { |
|---|
| 4691 | if ( this._timerToolbar ) |
|---|
| 4692 | { |
|---|
| 4693 | clearTimeout(this._timerToolbar); |
|---|
| 4694 | } |
|---|
| 4695 | if ( typeof except == 'undefined' ) |
|---|
| 4696 | { |
|---|
| 4697 | except = [ ]; |
|---|
| 4698 | } |
|---|
| 4699 | else if ( typeof except != 'object' ) |
|---|
| 4700 | { |
|---|
| 4701 | except = [except]; |
|---|
| 4702 | } |
|---|
| 4703 | |
|---|
| 4704 | for ( var i in this._toolbarObjects ) |
|---|
| 4705 | { |
|---|
| 4706 | var btn = this._toolbarObjects[i]; |
|---|
| 4707 | if ( except.contains(i) ) |
|---|
| 4708 | { |
|---|
| 4709 | continue; |
|---|
| 4710 | } |
|---|
| 4711 | |
|---|
| 4712 | if ( typeof btn.state != 'function' ) |
|---|
| 4713 | { |
|---|
| 4714 | continue; |
|---|
| 4715 | } |
|---|
| 4716 | btn.state("enabled", false); |
|---|
| 4717 | } |
|---|
| 4718 | }; |
|---|
| 4719 | |
|---|
| 4720 | Xinha.prototype.enableToolbar = function() |
|---|
| 4721 | { |
|---|
| 4722 | this.updateToolbar(); |
|---|
| 4723 | }; |
|---|
| 4724 | |
|---|
| 4725 | |
|---|
| 4726 | |
|---|
| 4727 | |
|---|
| 4728 | |
|---|
| 4729 | |
|---|
| 4730 | |
|---|
| 4731 | |
|---|
| 4732 | |
|---|
| 4733 | Xinha.prototype.updateToolbar = function(noStatus) |
|---|
| 4734 | { |
|---|
| 4735 | if (this.suspendUpdateToolbar) |
|---|
| 4736 | { |
|---|
| 4737 | return; |
|---|
| 4738 | } |
|---|
| 4739 | var doc = this._doc; |
|---|
| 4740 | var text = (this._editMode == "textmode"); |
|---|
| 4741 | var ancestors = null; |
|---|
| 4742 | if ( !text ) |
|---|
| 4743 | { |
|---|
| 4744 | ancestors = this.getAllAncestors(); |
|---|
| 4745 | if ( this.config.statusBar && !noStatus ) |
|---|
| 4746 | { |
|---|
| 4747 | while ( this._statusBarItems.length ) |
|---|
| 4748 | { |
|---|
| 4749 | var item = this._statusBarItems.pop(); |
|---|
| 4750 | item.el = null; |
|---|
| 4751 | item.editor = null; |
|---|
| 4752 | item.onclick = null; |
|---|
| 4753 | item.oncontextmenu = null; |
|---|
| 4754 | item._xinha_dom0Events.click = null; |
|---|
| 4755 | item._xinha_dom0Events.contextmenu = null; |
|---|
| 4756 | item = null; |
|---|
| 4757 | } |
|---|
| 4758 | |
|---|
| 4759 | this._statusBarTree.innerHTML = ' '; |
|---|
| 4760 | this._statusBarTree.appendChild(document.createTextNode(Xinha._lc("Path") + ": ")); |
|---|
| 4761 | for ( var i = ancestors.length; --i >= 0; ) |
|---|
| 4762 | { |
|---|
| 4763 | var el = ancestors[i]; |
|---|
| 4764 | if ( !el ) |
|---|
| 4765 | { |
|---|
| 4766 | |
|---|
| 4767 | |
|---|
| 4768 | |
|---|
| 4769 | |
|---|
| 4770 | continue; |
|---|
| 4771 | } |
|---|
| 4772 | var a = document.createElement("a"); |
|---|
| 4773 | a.href = "javascript:void(0);"; |
|---|
| 4774 | a.el = el; |
|---|
| 4775 | a.editor = this; |
|---|
| 4776 | this._statusBarItems.push(a); |
|---|
| 4777 | Xinha.addDom0Event( |
|---|
| 4778 | a, |
|---|
| 4779 | 'click', |
|---|
| 4780 | function() { |
|---|
| 4781 | this.blur(); |
|---|
| 4782 | this.editor.selectNodeContents(this.el); |
|---|
| 4783 | this.editor.updateToolbar(true); |
|---|
| 4784 | return false; |
|---|
| 4785 | } |
|---|
| 4786 | ); |
|---|
| 4787 | Xinha.addDom0Event( |
|---|
| 4788 | a, |
|---|
| 4789 | 'contextmenu', |
|---|
| 4790 | function() |
|---|
| 4791 | { |
|---|
| 4792 | |
|---|
| 4793 | this.blur(); |
|---|
| 4794 | var info = "Inline style:\n\n"; |
|---|
| 4795 | info += this.el.style.cssText.split(/;\s*/).join(";\n"); |
|---|
| 4796 | alert(info); |
|---|
| 4797 | return false; |
|---|
| 4798 | } |
|---|
| 4799 | ); |
|---|
| 4800 | var txt = el.tagName.toLowerCase(); |
|---|
| 4801 | switch (txt) |
|---|
| 4802 | { |
|---|
| 4803 | case 'b': |
|---|
| 4804 | txt = 'strong'; |
|---|
| 4805 | break; |
|---|
| 4806 | case 'i': |
|---|
| 4807 | txt = 'em'; |
|---|
| 4808 | break; |
|---|
| 4809 | case 'strike': |
|---|
| 4810 | txt = 'del'; |
|---|
| 4811 | break; |
|---|
| 4812 | } |
|---|
| 4813 | if (typeof el.style != 'undefined') |
|---|
| 4814 | { |
|---|
| 4815 | a.title = el.style.cssText; |
|---|
| 4816 | } |
|---|
| 4817 | if ( el.id ) |
|---|
| 4818 | { |
|---|
| 4819 | txt += "#" + el.id; |
|---|
| 4820 | } |
|---|
| 4821 | if ( el.className ) |
|---|
| 4822 | { |
|---|
| 4823 | txt += "." + el.className; |
|---|
| 4824 | } |
|---|
| 4825 | a.appendChild(document.createTextNode(txt)); |
|---|
| 4826 | this._statusBarTree.appendChild(a); |
|---|
| 4827 | if ( i !== 0 ) |
|---|
| 4828 | { |
|---|
| 4829 | this._statusBarTree.appendChild(document.createTextNode(String.fromCharCode(0xbb))); |
|---|
| 4830 | } |
|---|
| 4831 | Xinha.freeLater(a); |
|---|
| 4832 | } |
|---|
| 4833 | } |
|---|
| 4834 | } |
|---|
| 4835 | |
|---|
| 4836 | for ( var cmd in this._toolbarObjects ) |
|---|
| 4837 | { |
|---|
| 4838 | var btn = this._toolbarObjects[cmd]; |
|---|
| 4839 | var inContext = true; |
|---|
| 4840 | |
|---|
| 4841 | if ( typeof btn.state != 'function' ) |
|---|
| 4842 | { |
|---|
| 4843 | continue; |
|---|
| 4844 | } |
|---|
| 4845 | if ( btn.context && !text ) |
|---|
| 4846 | { |
|---|
| 4847 | inContext = false; |
|---|
| 4848 | var context = btn.context; |
|---|
| 4849 | var attrs = []; |
|---|
| 4850 | if ( /(.*)\[(.*?)\]/.test(context) ) |
|---|
| 4851 | { |
|---|
| 4852 | context = RegExp.$1; |
|---|
| 4853 | attrs = RegExp.$2.split(","); |
|---|
| 4854 | } |
|---|
| 4855 | context = context.toLowerCase(); |
|---|
| 4856 | var match = (context == "*"); |
|---|
| 4857 | for ( var k = 0; k < ancestors.length; ++k ) |
|---|
| 4858 | { |
|---|
| 4859 | if ( !ancestors[k] ) |
|---|
| 4860 | { |
|---|
| 4861 | |
|---|
| 4862 | continue; |
|---|
| 4863 | } |
|---|
| 4864 | if ( match || ( ancestors[k].tagName.toLowerCase() == context ) ) |
|---|
| 4865 | { |
|---|
| 4866 | inContext = true; |
|---|
| 4867 | var contextSplit = null; |
|---|
| 4868 | var att = null; |
|---|
| 4869 | var comp = null; |
|---|
| 4870 | var attVal = null; |
|---|
| 4871 | for ( var ka = 0; ka < attrs.length; ++ka ) |
|---|
| 4872 | { |
|---|
| 4873 | contextSplit = attrs[ka].match(/(.*)(==|!=|===|!==|>|>=|<|<=)(.*)/); |
|---|
| 4874 | att = contextSplit[1]; |
|---|
| 4875 | comp = contextSplit[2]; |
|---|
| 4876 | attVal = contextSplit[3]; |
|---|
| 4877 | |
|---|
| 4878 | if (!eval(ancestors[k][att] + comp + attVal)) |
|---|
| 4879 | { |
|---|
| 4880 | inContext = false; |
|---|
| 4881 | break; |
|---|
| 4882 | } |
|---|
| 4883 | } |
|---|
| 4884 | if ( inContext ) |
|---|
| 4885 | { |
|---|
| 4886 | break; |
|---|
| 4887 | } |
|---|
| 4888 | } |
|---|
| 4889 | } |
|---|
| 4890 | } |
|---|
| 4891 | btn.state("enabled", (!text || btn.text) && inContext); |
|---|
| 4892 | if ( typeof cmd == "function" ) |
|---|
| 4893 | { |
|---|
| 4894 | continue; |
|---|
| 4895 | } |
|---|
| 4896 | |
|---|
| 4897 | var dropdown = this.config.customSelects[cmd]; |
|---|
| 4898 | if ( ( !text || btn.text ) && ( typeof dropdown != "undefined" ) ) |
|---|
| 4899 | { |
|---|
| 4900 | dropdown.refresh(this); |
|---|
| 4901 | continue; |
|---|
| 4902 | } |
|---|
| 4903 | switch (cmd) |
|---|
| 4904 | { |
|---|
| 4905 | case "fontname": |
|---|
| 4906 | case "fontsize": |
|---|
| 4907 | if ( !text ) |
|---|
| 4908 | { |
|---|
| 4909 | try |
|---|
| 4910 | { |
|---|
| 4911 | var value = ("" + doc.queryCommandValue(cmd)).toLowerCase(); |
|---|
| 4912 | if ( !value ) |
|---|
| 4913 | { |
|---|
| 4914 | btn.element.selectedIndex = 0; |
|---|
| 4915 | break; |
|---|
| 4916 | } |
|---|
| 4917 | |
|---|
| 4918 | |
|---|
| 4919 | |
|---|
| 4920 | |
|---|
| 4921 | |
|---|
| 4922 | var options = this.config[cmd]; |
|---|
| 4923 | var sIndex = 0; |
|---|
| 4924 | for ( var j in options ) |
|---|
| 4925 | { |
|---|
| 4926 | |
|---|
| 4927 | if ( ( j.toLowerCase() == value ) || ( options[j].substr(0, value.length).toLowerCase() == value ) ) |
|---|
| 4928 | { |
|---|
| 4929 | btn.element.selectedIndex = sIndex; |
|---|
| 4930 | throw "ok"; |
|---|
| 4931 | } |
|---|
| 4932 | ++sIndex; |
|---|
| 4933 | } |
|---|
| 4934 | btn.element.selectedIndex = 0; |
|---|
| 4935 | } catch(ex) {} |
|---|
| 4936 | } |
|---|
| 4937 | break; |
|---|
| 4938 | |
|---|
| 4939 | |
|---|
| 4940 | |
|---|
| 4941 | |
|---|
| 4942 | |
|---|
| 4943 | case "formatblock": |
|---|
| 4944 | var blocks = []; |
|---|
| 4945 | for ( var indexBlock in this.config.formatblock ) |
|---|
| 4946 | { |
|---|
| 4947 | var blockname = this.config.formatblock[indexBlock]; |
|---|
| 4948 | |
|---|
| 4949 | if ( typeof blockname == 'string' ) |
|---|
| 4950 | { |
|---|
| 4951 | blocks[blocks.length] = this.config.formatblockDetector[blockname] || blockname; |
|---|
| 4952 | } |
|---|
| 4953 | } |
|---|
| 4954 | |
|---|
| 4955 | var match = this._getFirstAncestorAndWhy(this.getSelection(), blocks); |
|---|
| 4956 | var deepestAncestor = match[0]; |
|---|
| 4957 | var matchIndex = match[1]; |
|---|
| 4958 | |
|---|
| 4959 | |
|---|
| 4960 | if ( deepestAncestor ) |
|---|
| 4961 | { |
|---|
| 4962 | |
|---|
| 4963 | |
|---|
| 4964 | btn.element.selectedIndex = matchIndex; |
|---|
| 4965 | } |
|---|
| 4966 | else |
|---|
| 4967 | { |
|---|
| 4968 | btn.element.selectedIndex = 0; |
|---|
| 4969 | } |
|---|
| 4970 | break; |
|---|
| 4971 | |
|---|
| 4972 | case "textindicator": |
|---|
| 4973 | if ( !text ) |
|---|
| 4974 | { |
|---|
| 4975 | try |
|---|
| 4976 | { |
|---|
| 4977 | var style = btn.element.style; |
|---|
| 4978 | style.backgroundColor = Xinha._makeColor(doc.queryCommandValue(Xinha.is_ie ? "backcolor" : "hilitecolor")); |
|---|
| 4979 | if ( /transparent/i.test(style.backgroundColor) ) |
|---|
| 4980 | { |
|---|
| 4981 | |
|---|
| 4982 | style.backgroundColor = Xinha._makeColor(doc.queryCommandValue("backcolor")); |
|---|
| 4983 | } |
|---|
| 4984 | style.color = Xinha._makeColor(doc.queryCommandValue("forecolor")); |
|---|
| 4985 | style.fontFamily = doc.queryCommandValue("fontname"); |
|---|
| 4986 | style.fontWeight = doc.queryCommandState("bold") ? "bold" : "normal"; |
|---|
| 4987 | style.fontStyle = doc.queryCommandState("italic") ? "italic" : "normal"; |
|---|
| 4988 | } catch (ex) { |
|---|
| 4989 | |
|---|
| 4990 | } |
|---|
| 4991 | } |
|---|
| 4992 | break; |
|---|
| 4993 | |
|---|
| 4994 | case "htmlmode": |
|---|
| 4995 | btn.state("active", text); |
|---|
| 4996 | break; |
|---|
| 4997 | |
|---|
| 4998 | case "lefttoright": |
|---|
| 4999 | case "righttoleft": |
|---|
| 5000 | var eltBlock = this.getParentElement(); |
|---|
| 5001 | while ( eltBlock && !Xinha.isBlockElement(eltBlock) ) |
|---|
| 5002 | { |
|---|
| 5003 | eltBlock = eltBlock.parentNode; |
|---|
| 5004 | } |
|---|
| 5005 | if ( eltBlock ) |
|---|
| 5006 | { |
|---|
| 5007 | btn.state("active", (eltBlock.style.direction == ((cmd == "righttoleft") ? "rtl" : "ltr"))); |
|---|
| 5008 | } |
|---|
| 5009 | break; |
|---|
| 5010 | |
|---|
| 5011 | default: |
|---|
| 5012 | cmd = cmd.replace(/(un)?orderedlist/i, "insert$1orderedlist"); |
|---|
| 5013 | try |
|---|
| 5014 | { |
|---|
| 5015 | btn.state("active", (!text && doc.queryCommandState(cmd))); |
|---|
| 5016 | } catch (ex) {} |
|---|
| 5017 | break; |
|---|
| 5018 | } |
|---|
| 5019 | } |
|---|
| 5020 | |
|---|
| 5021 | if ( this._customUndo && !this._timerUndo ) |
|---|
| 5022 | { |
|---|
| 5023 | this._undoTakeSnapshot(); |
|---|
| 5024 | var editor = this; |
|---|
| 5025 | this._timerUndo = setTimeout(function() { editor._timerUndo = null; }, this.config.undoTimeout); |
|---|
| 5026 | } |
|---|
| 5027 | this.firePluginEvent('onUpdateToolbar'); |
|---|
| 5028 | }; |
|---|
| 5029 | |
|---|
| 5030 | |
|---|
| 5031 | |
|---|
| 5032 | |
|---|
| 5033 | |
|---|
| 5034 | |
|---|
| 5035 | |
|---|
| 5036 | |
|---|
| 5037 | |
|---|
| 5038 | |
|---|
| 5039 | Xinha.getEditor = function(ref) |
|---|
| 5040 | { |
|---|
| 5041 | for ( var i = __xinhas.length; i--; ) |
|---|
| 5042 | { |
|---|
| 5043 | var editor = __xinhas[i]; |
|---|
| 5044 | if ( editor && ( editor._textArea.id == ref || editor._textArea.name == ref || editor._textArea == ref ) ) |
|---|
| 5045 | { |
|---|
| 5046 | return editor; |
|---|
| 5047 | } |
|---|
| 5048 | } |
|---|
| 5049 | return null; |
|---|
| 5050 | }; |
|---|
| 5051 | |
|---|
| 5052 | |
|---|
| 5053 | |
|---|
| 5054 | |
|---|
| 5055 | |
|---|
| 5056 | |
|---|
| 5057 | |
|---|
| 5058 | |
|---|
| 5059 | |
|---|
| 5060 | Xinha.prototype.getPluginInstance = function (plugin) |
|---|
| 5061 | { |
|---|
| 5062 | if (this.plugins[plugin]) |
|---|
| 5063 | { |
|---|
| 5064 | return this.plugins[plugin].instance; |
|---|
| 5065 | } |
|---|
| 5066 | else |
|---|
| 5067 | { |
|---|
| 5068 | return null; |
|---|
| 5069 | } |
|---|
| 5070 | }; |
|---|
| 5071 | |
|---|
| 5072 | |
|---|
| 5073 | |
|---|
| 5074 | Xinha.prototype.getAllAncestors = function() |
|---|
| 5075 | { |
|---|
| 5076 | var p = this.getParentElement(); |
|---|
| 5077 | var a = []; |
|---|
| 5078 | while ( p && (p.nodeType == 1) && ( p.tagName.toLowerCase() != 'body' ) ) |
|---|
| 5079 | { |
|---|
| 5080 | a.push(p); |
|---|
| 5081 | p = p.parentNode; |
|---|
| 5082 | } |
|---|
| 5083 | a.push(this._doc.body); |
|---|
| 5084 | return a; |
|---|
| 5085 | }; |
|---|
| 5086 | |
|---|
| 5087 | |
|---|
| 5088 | |
|---|
| 5089 | |
|---|
| 5090 | |
|---|
| 5091 | |
|---|
| 5092 | Xinha.prototype._getFirstAncestor = function(sel, types) |
|---|
| 5093 | { |
|---|
| 5094 | return this._getFirstAncestorAndWhy(sel, types)[0]; |
|---|
| 5095 | }; |
|---|
| 5096 | |
|---|
| 5097 | |
|---|
| 5098 | |
|---|
| 5099 | |
|---|
| 5100 | |
|---|
| 5101 | |
|---|
| 5102 | |
|---|
| 5103 | Xinha.prototype._getFirstAncestorAndWhy = function(sel, types) |
|---|
| 5104 | { |
|---|
| 5105 | var prnt = this.activeElement(sel); |
|---|
| 5106 | if ( prnt === null ) |
|---|
| 5107 | { |
|---|
| 5108 | |
|---|
| 5109 | try |
|---|
| 5110 | { |
|---|
| 5111 | prnt = (Xinha.is_ie ? this.createRange(sel).parentElement() : this.createRange(sel).commonAncestorContainer); |
|---|
| 5112 | } |
|---|
| 5113 | catch(ex) |
|---|
| 5114 | { |
|---|
| 5115 | return [null, null]; |
|---|
| 5116 | } |
|---|
| 5117 | } |
|---|
| 5118 | |
|---|
| 5119 | if ( typeof types == 'string' ) |
|---|
| 5120 | { |
|---|
| 5121 | types = [types]; |
|---|
| 5122 | } |
|---|
| 5123 | |
|---|
| 5124 | while ( prnt ) |
|---|
| 5125 | { |
|---|
| 5126 | if ( prnt.nodeType == 1 ) |
|---|
| 5127 | { |
|---|
| 5128 | if ( types === null ) |
|---|
| 5129 | { |
|---|
| 5130 | return [prnt, null]; |
|---|
| 5131 | } |
|---|
| 5132 | for (var index=0; index<types.length; ++index) { |
|---|
| 5133 | if (typeof types[index] == 'string' && types[index] == prnt.tagName.toLowerCase()){ |
|---|
| 5134 | |
|---|
| 5135 | return [prnt, index]; |
|---|
| 5136 | } |
|---|
| 5137 | else if (typeof types[index] == 'function' && types[index](this, prnt)) { |
|---|
| 5138 | |
|---|
| 5139 | return [prnt, index]; |
|---|
| 5140 | } |
|---|
| 5141 | } |
|---|
| 5142 | |
|---|
| 5143 | if ( prnt.tagName.toLowerCase() == 'body' ) |
|---|
| 5144 | { |
|---|
| 5145 | break; |
|---|
| 5146 | } |
|---|
| 5147 | if ( prnt.tagName.toLowerCase() == 'table' ) |
|---|
| 5148 | { |
|---|
| 5149 | break; |
|---|
| 5150 | } |
|---|
| 5151 | } |
|---|
| 5152 | prnt = prnt.parentNode; |
|---|
| 5153 | } |
|---|
| 5154 | |
|---|
| 5155 | return [null, null]; |
|---|
| 5156 | }; |
|---|
| 5157 | |
|---|
| 5158 | |
|---|
| 5159 | |
|---|
| 5160 | |
|---|
| 5161 | |
|---|
| 5162 | Xinha.prototype._getAncestorBlock = function(sel) |
|---|
| 5163 | { |
|---|
| 5164 | |
|---|
| 5165 | var prnt = (Xinha.is_ie ? this.createRange(sel).parentElement : this.createRange(sel).commonAncestorContainer); |
|---|
| 5166 | |
|---|
| 5167 | while ( prnt && ( prnt.nodeType == 1 ) ) |
|---|
| 5168 | { |
|---|
| 5169 | switch ( prnt.tagName.toLowerCase() ) |
|---|
| 5170 | { |
|---|
| 5171 | case 'div': |
|---|
| 5172 | case 'p': |
|---|
| 5173 | case 'address': |
|---|
| 5174 | case 'blockquote': |
|---|
| 5175 | case 'center': |
|---|
| 5176 | case 'del': |
|---|
| 5177 | case 'ins': |
|---|
| 5178 | case 'pre': |
|---|
| 5179 | case 'h1': |
|---|
| 5180 | case 'h2': |
|---|
| 5181 | case 'h3': |
|---|
| 5182 | case 'h4': |
|---|
| 5183 | case 'h5': |
|---|
| 5184 | case 'h6': |
|---|
| 5185 | case 'h7': |
|---|
| 5186 | |
|---|
| 5187 | return prnt; |
|---|
| 5188 | |
|---|
| 5189 | case 'body': |
|---|
| 5190 | case 'noframes': |
|---|
| 5191 | case 'dd': |
|---|
| 5192 | case 'li': |
|---|
| 5193 | case 'th': |
|---|
| 5194 | case 'td': |
|---|
| 5195 | case 'noscript' : |
|---|
| 5196 | |
|---|
| 5197 | return null; |
|---|
| 5198 | |
|---|
| 5199 | default: |
|---|
| 5200 | |
|---|
| 5201 | break; |
|---|
| 5202 | } |
|---|
| 5203 | } |
|---|
| 5204 | |
|---|
| 5205 | return null; |
|---|
| 5206 | }; |
|---|
| 5207 | |
|---|
| 5208 | |
|---|
| 5209 | |
|---|
| 5210 | |
|---|
| 5211 | |
|---|
| 5212 | Xinha.prototype._createImplicitBlock = function(type) |
|---|
| 5213 | { |
|---|
| 5214 | |
|---|
| 5215 | |
|---|
| 5216 | var sel = this.getSelection(); |
|---|
| 5217 | if ( Xinha.is_ie ) |
|---|
| 5218 | { |
|---|
| 5219 | sel.empty(); |
|---|
| 5220 | } |
|---|
| 5221 | else |
|---|
| 5222 | { |
|---|
| 5223 | sel.collapseToStart(); |
|---|
| 5224 | } |
|---|
| 5225 | |
|---|
| 5226 | var rng = this.createRange(sel); |
|---|
| 5227 | |
|---|
| 5228 | |
|---|
| 5229 | |
|---|
| 5230 | |
|---|
| 5231 | }; |
|---|
| 5232 | |
|---|
| 5233 | |
|---|
| 5234 | |
|---|
| 5235 | |
|---|
| 5236 | |
|---|
| 5237 | |
|---|
| 5238 | |
|---|
| 5239 | |
|---|
| 5240 | |
|---|
| 5241 | |
|---|
| 5242 | Xinha.prototype.surroundHTML = function(startTag, endTag) |
|---|
| 5243 | { |
|---|
| 5244 | var html = this.getSelectedHTML(); |
|---|
| 5245 | |
|---|
| 5246 | this.insertHTML(startTag + html + endTag); |
|---|
| 5247 | }; |
|---|
| 5248 | |
|---|
| 5249 | |
|---|
| 5250 | |
|---|
| 5251 | |
|---|
| 5252 | Xinha.prototype.hasSelectedText = function() |
|---|
| 5253 | { |
|---|
| 5254 | |
|---|
| 5255 | return this.getSelectedHTML() !== ''; |
|---|
| 5256 | }; |
|---|
| 5257 | |
|---|
| 5258 | |
|---|
| 5259 | |
|---|
| 5260 | |
|---|
| 5261 | |
|---|
| 5262 | |
|---|
| 5263 | |
|---|
| 5264 | |
|---|
| 5265 | |
|---|
| 5266 | |
|---|
| 5267 | |
|---|
| 5268 | Xinha.prototype._comboSelected = function(el, txt) |
|---|
| 5269 | { |
|---|
| 5270 | this.focusEditor(); |
|---|
| 5271 | var value = el.options[el.selectedIndex].value; |
|---|
| 5272 | switch (txt) |
|---|
| 5273 | { |
|---|
| 5274 | case "fontname": |
|---|
| 5275 | case "fontsize": |
|---|
| 5276 | this.execCommand(txt, false, value); |
|---|
| 5277 | break; |
|---|
| 5278 | case "formatblock": |
|---|
| 5279 | |
|---|
| 5280 | if ( !value ) |
|---|
| 5281 | { |
|---|
| 5282 | this.updateToolbar(); |
|---|
| 5283 | break; |
|---|
| 5284 | } |
|---|
| 5285 | if( !Xinha.is_gecko || value !== 'blockquote' ) |
|---|
| 5286 | { |
|---|
| 5287 | value = "<" + value + ">"; |
|---|
| 5288 | } |
|---|
| 5289 | this.execCommand(txt, false, value); |
|---|
| 5290 | break; |
|---|
| 5291 | default: |
|---|
| 5292 | |
|---|
| 5293 | var dropdown = this.config.customSelects[txt]; |
|---|
| 5294 | if ( typeof dropdown != "undefined" ) |
|---|
| 5295 | { |
|---|
| 5296 | dropdown.action(this, value, el, txt); |
|---|
| 5297 | } |
|---|
| 5298 | else |
|---|
| 5299 | { |
|---|
| 5300 | alert("FIXME: combo box " + txt + " not implemented"); |
|---|
| 5301 | } |
|---|
| 5302 | break; |
|---|
| 5303 | } |
|---|
| 5304 | }; |
|---|
| 5305 | |
|---|
| 5306 | |
|---|
| 5307 | |
|---|
| 5308 | |
|---|
| 5309 | |
|---|
| 5310 | Xinha.prototype._colorSelector = function(cmdID) |
|---|
| 5311 | { |
|---|
| 5312 | var editor = this; |
|---|
| 5313 | |
|---|
| 5314 | |
|---|
| 5315 | |
|---|
| 5316 | if ( Xinha.is_gecko ) |
|---|
| 5317 | { |
|---|
| 5318 | try |
|---|
| 5319 | { |
|---|
| 5320 | editor._doc.execCommand('useCSS', false, false); |
|---|
| 5321 | editor._doc.execCommand('styleWithCSS', false, true); |
|---|
| 5322 | |
|---|
| 5323 | } catch (ex) {} |
|---|
| 5324 | } |
|---|
| 5325 | |
|---|
| 5326 | var btn = editor._toolbarObjects[cmdID].element; |
|---|
| 5327 | var initcolor; |
|---|
| 5328 | if ( cmdID == 'hilitecolor' ) |
|---|
| 5329 | { |
|---|
| 5330 | if ( Xinha.is_ie ) |
|---|
| 5331 | { |
|---|
| 5332 | cmdID = 'backcolor'; |
|---|
| 5333 | initcolor = Xinha._colorToRgb(editor._doc.queryCommandValue("backcolor")); |
|---|
| 5334 | } |
|---|
| 5335 | else |
|---|
| 5336 | { |
|---|
| 5337 | initcolor = Xinha._colorToRgb(editor._doc.queryCommandValue("hilitecolor")); |
|---|
| 5338 | } |
|---|
| 5339 | } |
|---|
| 5340 | else |
|---|
| 5341 | { |
|---|
| 5342 | initcolor = Xinha._colorToRgb(editor._doc.queryCommandValue("forecolor")); |
|---|
| 5343 | } |
|---|
| 5344 | var cback = function(color) { editor._doc.execCommand(cmdID, false, color); }; |
|---|
| 5345 | if ( Xinha.is_ie ) |
|---|
| 5346 | { |
|---|
| 5347 | var range = editor.createRange(editor.getSelection()); |
|---|
| 5348 | cback = function(color) |
|---|
| 5349 | { |
|---|
| 5350 | range.select(); |
|---|
| 5351 | editor._doc.execCommand(cmdID, false, color); |
|---|
| 5352 | }; |
|---|
| 5353 | } |
|---|
| 5354 | var picker = new Xinha.colorPicker( |
|---|
| 5355 | { |
|---|
| 5356 | cellsize:editor.config.colorPickerCellSize, |
|---|
| 5357 | callback:cback, |
|---|
| 5358 | granularity:editor.config.colorPickerGranularity, |
|---|
| 5359 | websafe:editor.config.colorPickerWebSafe, |
|---|
| 5360 | savecolors:editor.config.colorPickerSaveColors |
|---|
| 5361 | }); |
|---|
| 5362 | picker.open(editor.config.colorPickerPosition, btn, initcolor); |
|---|
| 5363 | }; |
|---|
| 5364 | |
|---|
| 5365 | |
|---|
| 5366 | |
|---|
| 5367 | |
|---|
| 5368 | |
|---|
| 5369 | |
|---|
| 5370 | |
|---|
| 5371 | |
|---|
| 5372 | |
|---|
| 5373 | |
|---|
| 5374 | |
|---|
| 5375 | |
|---|
| 5376 | |
|---|
| 5377 | |
|---|
| 5378 | |
|---|
| 5379 | Xinha.prototype.execCommand = function(cmdID, UI, param) |
|---|
| 5380 | { |
|---|
| 5381 | var editor = this; |
|---|
| 5382 | this.focusEditor(); |
|---|
| 5383 | cmdID = cmdID.toLowerCase(); |
|---|
| 5384 | |
|---|
| 5385 | |
|---|
| 5386 | if(this.firePluginEvent('onExecCommand', cmdID, UI, param)) |
|---|
| 5387 | { |
|---|
| 5388 | this.updateToolbar(); |
|---|
| 5389 | return false; |
|---|
| 5390 | } |
|---|
| 5391 | |
|---|
| 5392 | switch (cmdID) |
|---|
| 5393 | { |
|---|
| 5394 | case "htmlmode": |
|---|
| 5395 | this.setMode(); |
|---|
| 5396 | break; |
|---|
| 5397 | |
|---|
| 5398 | case "hilitecolor": |
|---|
| 5399 | case "forecolor": |
|---|
| 5400 | this._colorSelector(cmdID); |
|---|
| 5401 | break; |
|---|
| 5402 | |
|---|
| 5403 | case "createlink": |
|---|
| 5404 | this._createLink(); |
|---|
| 5405 | break; |
|---|
| 5406 | |
|---|
| 5407 | case "undo": |
|---|
| 5408 | case "redo": |
|---|
| 5409 | if (this._customUndo) |
|---|
| 5410 | { |
|---|
| 5411 | this[cmdID](); |
|---|
| 5412 | } |
|---|
| 5413 | else |
|---|
| 5414 | { |
|---|
| 5415 | this._doc.execCommand(cmdID, UI, param); |
|---|
| 5416 | } |
|---|
| 5417 | break; |
|---|
| 5418 | |
|---|
| 5419 | case "inserttable": |
|---|
| 5420 | this._insertTable(); |
|---|
| 5421 | break; |
|---|
| 5422 | |
|---|
| 5423 | case "insertimage": |
|---|
| 5424 | this._insertImage(); |
|---|
| 5425 | break; |
|---|
| 5426 | |
|---|
| 5427 | case "showhelp": |
|---|
| 5428 | this._popupDialog(editor.config.URIs.help, null, this); |
|---|
| 5429 | break; |
|---|
| 5430 | |
|---|
| 5431 | case "killword": |
|---|
| 5432 | this._wordClean(); |
|---|
| 5433 | break; |
|---|
| 5434 | |
|---|
| 5435 | case "cut": |
|---|
| 5436 | case "copy": |
|---|
| 5437 | case "paste": |
|---|
| 5438 | this._doc.execCommand(cmdID, UI, param); |
|---|
| 5439 | if ( this.config.killWordOnPaste ) |
|---|
| 5440 | { |
|---|
| 5441 | this._wordClean(); |
|---|
| 5442 | } |
|---|
| 5443 | break; |
|---|
| 5444 | case "lefttoright": |
|---|
| 5445 | case "righttoleft": |
|---|
| 5446 | if (this.config.changeJustifyWithDirection) |
|---|
| 5447 | { |
|---|
| 5448 | this._doc.execCommand((cmdID == "righttoleft") ? "justifyright" : "justifyleft", UI, param); |
|---|
| 5449 | } |
|---|
| 5450 | var dir = (cmdID == "righttoleft") ? "rtl" : "ltr"; |
|---|
| 5451 | var el = this.getParentElement(); |
|---|
| 5452 | while ( el && !Xinha.isBlockElement(el) ) |
|---|
| 5453 | { |
|---|
| 5454 | el = el.parentNode; |
|---|
| 5455 | } |
|---|
| 5456 | if ( el ) |
|---|
| 5457 | { |
|---|
| 5458 | if ( el.style.direction == dir ) |
|---|
| 5459 | { |
|---|
| 5460 | el.style.direction = ""; |
|---|
| 5461 | } |
|---|
| 5462 | else |
|---|
| 5463 | { |
|---|
| 5464 | el.style.direction = dir; |
|---|
| 5465 | } |
|---|
| 5466 | } |
|---|
| 5467 | break; |
|---|
| 5468 | |
|---|
| 5469 | case 'justifyleft' : |
|---|
| 5470 | case 'justifyright' : |
|---|
| 5471 | cmdID.match(/^justify(.*)$/); |
|---|
| 5472 | var ae = this.activeElement(this.getSelection()); |
|---|
| 5473 | if(ae && ae.tagName.toLowerCase() == 'img') |
|---|
| 5474 | { |
|---|
| 5475 | ae.align = ae.align == RegExp.$1 ? '' : RegExp.$1; |
|---|
| 5476 | } |
|---|
| 5477 | else |
|---|
| 5478 | { |
|---|
| 5479 | this._doc.execCommand(cmdID, UI, param); |
|---|
| 5480 | } |
|---|
| 5481 | break; |
|---|
| 5482 | |
|---|
| 5483 | default: |
|---|
| 5484 | try |
|---|
| 5485 | { |
|---|
| 5486 | this._doc.execCommand(cmdID, UI, param); |
|---|
| 5487 | } |
|---|
| 5488 | catch(ex) |
|---|
| 5489 | { |
|---|
| 5490 | if ( this.config.debug ) |
|---|
| 5491 | { |
|---|
| 5492 | alert(ex + "\n\nby execCommand(" + cmdID + ");"); |
|---|
| 5493 | } |
|---|
| 5494 | } |
|---|
| 5495 | break; |
|---|
| 5496 | } |
|---|
| 5497 | |
|---|
| 5498 | this.updateToolbar(); |
|---|
| 5499 | return false; |
|---|
| 5500 | }; |
|---|
| 5501 | |
|---|
| 5502 | |
|---|
| 5503 | |
|---|
| 5504 | |
|---|
| 5505 | |
|---|
| 5506 | |
|---|
| 5507 | |
|---|
| 5508 | |
|---|
| 5509 | Xinha.prototype._editorEvent = function(ev) |
|---|
| 5510 | { |
|---|
| 5511 | var editor = this; |
|---|
| 5512 | |
|---|
| 5513 | |
|---|
| 5514 | if ( typeof editor._textArea['on'+ev.type] == "function" ) |
|---|
| 5515 | { |
|---|
| 5516 | editor._textArea['on'+ev.type](ev); |
|---|
| 5517 | } |
|---|
| 5518 | |
|---|
| 5519 | if ( this.isKeyEvent(ev) ) |
|---|
| 5520 | { |
|---|
| 5521 | |
|---|
| 5522 | if(editor.firePluginEvent('onKeyPress', ev)) |
|---|
| 5523 | { |
|---|
| 5524 | return false; |
|---|
| 5525 | } |
|---|
| 5526 | |
|---|
| 5527 | |
|---|
| 5528 | if ( this.isShortCut( ev ) ) |
|---|
| 5529 | { |
|---|
| 5530 | this._shortCuts(ev); |
|---|
| 5531 | } |
|---|
| 5532 | } |
|---|
| 5533 | |
|---|
| 5534 | if ( ev.type == 'mousedown' ) |
|---|
| 5535 | { |
|---|
| 5536 | if(editor.firePluginEvent('onMouseDown', ev)) |
|---|
| 5537 | { |
|---|
| 5538 | return false; |
|---|
| 5539 | } |
|---|
| 5540 | } |
|---|
| 5541 | |
|---|
| 5542 | |
|---|
| 5543 | if ( editor._timerToolbar ) |
|---|
| 5544 | { |
|---|
| 5545 | clearTimeout(editor._timerToolbar); |
|---|
| 5546 | } |
|---|
| 5547 | if (!this.suspendUpdateToolbar) |
|---|
| 5548 | { |
|---|
| 5549 | editor._timerToolbar = setTimeout( |
|---|
| 5550 | function() |
|---|
| 5551 | { |
|---|
| 5552 | editor.updateToolbar(); |
|---|
| 5553 | editor._timerToolbar = null; |
|---|
| 5554 | }, |
|---|
| 5555 | 250); |
|---|
| 5556 | } |
|---|
| 5557 | }; |
|---|
| 5558 | |
|---|
| 5559 | |
|---|
| 5560 | |
|---|
| 5561 | |
|---|
| 5562 | |
|---|
| 5563 | Xinha.prototype._onDoubleClick = function(ev) |
|---|
| 5564 | { |
|---|
| 5565 | var editor=this; |
|---|
| 5566 | var target = Xinha.is_ie ? ev.srcElement : ev.target; |
|---|
| 5567 | var tag = target.tagName; |
|---|
| 5568 | var className = target.className; |
|---|
| 5569 | if (tag) { |
|---|
| 5570 | tag = tag.toLowerCase(); |
|---|
| 5571 | if (className && (this.config.dblclickList[tag+"."+className] != undefined)) |
|---|
| 5572 | this.config.dblclickList[tag+"."+className][0](editor, target); |
|---|
| 5573 | else if (this.config.dblclickList[tag] != undefined) |
|---|
| 5574 | this.config.dblclickList[tag][0](editor, target); |
|---|
| 5575 | }; |
|---|
| 5576 | }; |
|---|
| 5577 | |
|---|
| 5578 | |
|---|
| 5579 | |
|---|
| 5580 | |
|---|
| 5581 | |
|---|
| 5582 | |
|---|
| 5583 | Xinha.prototype._shortCuts = function (ev) |
|---|
| 5584 | { |
|---|
| 5585 | var key = this.getKey(ev).toLowerCase(); |
|---|
| 5586 | var cmd = null; |
|---|
| 5587 | var value = null; |
|---|
| 5588 | switch (key) |
|---|
| 5589 | { |
|---|
| 5590 | |
|---|
| 5591 | |
|---|
| 5592 | case 'b': cmd = "bold"; break; |
|---|
| 5593 | case 'i': cmd = "italic"; break; |
|---|
| 5594 | case 'u': cmd = "underline"; break; |
|---|
| 5595 | case 's': cmd = "strikethrough"; break; |
|---|
| 5596 | case 'l': cmd = "justifyleft"; break; |
|---|
| 5597 | case 'e': cmd = "justifycenter"; break; |
|---|
| 5598 | case 'r': cmd = "justifyright"; break; |
|---|
| 5599 | case 'j': cmd = "justifyfull"; break; |
|---|
| 5600 | case 'z': cmd = "undo"; break; |
|---|
| 5601 | case 'y': cmd = "redo"; break; |
|---|
| 5602 | case 'v': cmd = "paste"; break; |
|---|
| 5603 | case 'n': |
|---|
| 5604 | cmd = "formatblock"; |
|---|
| 5605 | value = "p"; |
|---|
| 5606 | break; |
|---|
| 5607 | |
|---|
| 5608 | case '0': cmd = "killword"; break; |
|---|
| 5609 | |
|---|
| 5610 | |
|---|
| 5611 | case '1': |
|---|
| 5612 | case '2': |
|---|
| 5613 | case '3': |
|---|
| 5614 | case '4': |
|---|
| 5615 | case '5': |
|---|
| 5616 | case '6': |
|---|
| 5617 | cmd = "formatblock"; |
|---|
| 5618 | value = "h" + key; |
|---|
| 5619 | break; |
|---|
| 5620 | } |
|---|
| 5621 | if ( cmd ) |
|---|
| 5622 | { |
|---|
| 5623 | |
|---|
| 5624 | this.execCommand(cmd, false, value); |
|---|
| 5625 | Xinha._stopEvent(ev); |
|---|
| 5626 | } |
|---|
| 5627 | }; |
|---|
| 5628 | |
|---|
| 5629 | |
|---|
| 5630 | |
|---|
| 5631 | |
|---|
| 5632 | |
|---|
| 5633 | Xinha.prototype.convertNode = function(el, newTagName) |
|---|
| 5634 | { |
|---|
| 5635 | var newel = this._doc.createElement(newTagName); |
|---|
| 5636 | while ( el.firstChild ) |
|---|
| 5637 | { |
|---|
| 5638 | newel.appendChild(el.firstChild); |
|---|
| 5639 | } |
|---|
| 5640 | return newel; |
|---|
| 5641 | }; |
|---|
| 5642 | |
|---|
| 5643 | |
|---|
| 5644 | |
|---|
| 5645 | |
|---|
| 5646 | Xinha.prototype.scrollToElement = function(e) |
|---|
| 5647 | { |
|---|
| 5648 | if(!e) |
|---|
| 5649 | { |
|---|
| 5650 | e = this.getParentElement(); |
|---|
| 5651 | if(!e) |
|---|
| 5652 | { |
|---|
| 5653 | return; |
|---|
| 5654 | } |
|---|
| 5655 | } |
|---|
| 5656 | |
|---|
| 5657 | |
|---|
| 5658 | var position = Xinha.getElementTopLeft(e); |
|---|
| 5659 | this._iframe.contentWindow.scrollTo(position.left, position.top); |
|---|
| 5660 | }; |
|---|
| 5661 | |
|---|
| 5662 | |
|---|
| 5663 | |
|---|
| 5664 | |
|---|
| 5665 | |
|---|
| 5666 | |
|---|
| 5667 | Xinha.prototype.getEditorContent = function() |
|---|
| 5668 | { |
|---|
| 5669 | return this.outwardHtml(this.getHTML()); |
|---|
| 5670 | }; |
|---|
| 5671 | |
|---|
| 5672 | |
|---|
| 5673 | |
|---|
| 5674 | |
|---|
| 5675 | |
|---|
| 5676 | |
|---|
| 5677 | Xinha.prototype.setEditorContent = function(html) |
|---|
| 5678 | { |
|---|
| 5679 | this.setHTML(this.inwardHtml(html)); |
|---|
| 5680 | }; |
|---|
| 5681 | |
|---|
| 5682 | |
|---|
| 5683 | |
|---|
| 5684 | Xinha.updateTextareas = function() |
|---|
| 5685 | { |
|---|
| 5686 | var e; |
|---|
| 5687 | for (var i=0;i<__xinhas.length;i++) |
|---|
| 5688 | { |
|---|
| 5689 | e = __xinhas[i]; |
|---|
| 5690 | e._textArea.value = e.getEditorContent(); |
|---|
| 5691 | } |
|---|
| 5692 | } |
|---|
| 5693 | |
|---|
| 5694 | |
|---|
| 5695 | |
|---|
| 5696 | |
|---|
| 5697 | |
|---|
| 5698 | Xinha.prototype.getHTML = function() |
|---|
| 5699 | { |
|---|
| 5700 | var html = ''; |
|---|
| 5701 | switch ( this._editMode ) |
|---|
| 5702 | { |
|---|
| 5703 | case "wysiwyg": |
|---|
| 5704 | if ( !this.config.fullPage ) |
|---|
| 5705 | { |
|---|
| 5706 | html = Xinha.getHTML(this._doc.body, false, this).trim(); |
|---|
| 5707 | } |
|---|
| 5708 | else |
|---|
| 5709 | { |
|---|
| 5710 | html = this.doctype + "\n" + Xinha.getHTML(this._doc.documentElement, true, this); |
|---|
| 5711 | } |
|---|
| 5712 | break; |
|---|
| 5713 | case "textmode": |
|---|
| 5714 | html = this._textArea.value; |
|---|
| 5715 | break; |
|---|
| 5716 | default: |
|---|
| 5717 | alert("Mode <" + this._editMode + "> not defined!"); |
|---|
| 5718 | return false; |
|---|
| 5719 | } |
|---|
| 5720 | return html; |
|---|
| 5721 | }; |
|---|
| 5722 | |
|---|
| 5723 | |
|---|
| 5724 | |
|---|
| 5725 | |
|---|
| 5726 | |
|---|
| 5727 | |
|---|
| 5728 | |
|---|
| 5729 | |
|---|
| 5730 | |
|---|
| 5731 | |
|---|
| 5732 | Xinha.prototype.outwardHtml = function(html) |
|---|
| 5733 | { |
|---|
| 5734 | for ( var i in this.plugins ) |
|---|
| 5735 | { |
|---|
| 5736 | var plugin = this.plugins[i].instance; |
|---|
| 5737 | if ( plugin && typeof plugin.outwardHtml == "function" ) |
|---|
| 5738 | { |
|---|
| 5739 | html = plugin.outwardHtml(html); |
|---|
| 5740 | } |
|---|
| 5741 | } |
|---|
| 5742 | |
|---|
| 5743 | html = html.replace(/<(\/?)b(\s|>|\/)/ig, "<$1strong$2"); |
|---|
| 5744 | html = html.replace(/<(\/?)i(\s|>|\/)/ig, "<$1em$2"); |
|---|
| 5745 | html = html.replace(/<(\/?)strike(\s|>|\/)/ig, "<$1del$2"); |
|---|
| 5746 | |
|---|
| 5747 | |
|---|
| 5748 | html = html.replace(/(<[^>]*on(click|mouse(over|out|up|down))=['"])if\(window\.parent && window\.parent\.Xinha\)\{return false\}/gi,'$1'); |
|---|
| 5749 | |
|---|
| 5750 | // Figure out what our server name is, and how it's referenced |
|---|
| 5751 | var serverBase = location.href.replace(/(https?:\/\/[^\/]*)\/.*/, '$1') + '/'; |
|---|
| 5752 | |
|---|
| 5753 | |
|---|
| 5754 | |
|---|
| 5755 | |
|---|
| 5756 | |
|---|
| 5757 | html = html.replace(/https?:\/\/null\ |
|---|
| 5758 | |
|---|
| 5759 | |
|---|
| 5760 | |
|---|
| 5761 | |
|---|
| 5762 | html = html.replace(/((href|src|background)=[\'\"])\/+/ig, '$1' + serverBase); |
|---|
| 5763 | |
|---|
| 5764 | html = this.outwardSpecialReplacements(html); |
|---|
| 5765 | |
|---|
| 5766 | html = this.fixRelativeLinks(html); |
|---|
| 5767 | |
|---|
| 5768 | if ( this.config.sevenBitClean ) |
|---|
| 5769 | { |
|---|
| 5770 | html = html.replace(/[^ -~\r\n\t]/g, function(c) { return (c != Xinha.cc) ? '&#'+c.charCodeAt(0)+';' : c; }); |
|---|
| 5771 | } |
|---|
| 5772 | |
|---|
| 5773 | //prevent execution of JavaScript (Ticket #685) |
|---|
| 5774 | html = html.replace(/(<script[^>]*((type=[\"\']text\/)|(language=[\"\'])))(freezescript)/gi,"$1javascript"); |
|---|
| 5775 | |
|---|
| 5776 | // If in fullPage mode, strip the coreCSS |
|---|
| 5777 | if(this.config.fullPage) |
|---|
| 5778 | { |
|---|
| 5779 | html = Xinha.stripCoreCSS(html); |
|---|
| 5780 | } |
|---|
| 5781 | |
|---|
| 5782 | if (typeof this.config.outwardHtml == 'function' ) |
|---|
| 5783 | { |
|---|
| 5784 | html = this.config.outwardHtml(html); |
|---|
| 5785 | } |
|---|
| 5786 | |
|---|
| 5787 | return html; |
|---|
| 5788 | }; |
|---|
| 5789 | |
|---|
| 5790 | /** Performs various transformations of the HTML to be edited |
|---|
| 5791 | * Plugins can provide their own, additional transformations by defining a plugin.prototype.inwardHtml() implematation, |
|---|
| 5792 | * which is called by this function |
|---|
| 5793 | * |
|---|
| 5794 | * @private |
|---|
| 5795 | * @see Xinha#outwardHtml |
|---|
| 5796 | * @param {String} html |
|---|
| 5797 | * @returns {String} transformed HTML |
|---|
| 5798 | */ |
|---|
| 5799 | Xinha.prototype.inwardHtml = function(html) |
|---|
| 5800 | { |
|---|
| 5801 | for ( var i in this.plugins ) |
|---|
| 5802 | { |
|---|
| 5803 | var plugin = this.plugins[i].instance; |
|---|
| 5804 | if ( plugin && typeof plugin.inwardHtml == "function" ) |
|---|
| 5805 | { |
|---|
| 5806 | html = plugin.inwardHtml(html); |
|---|
| 5807 | } |
|---|
| 5808 | } |
|---|
| 5809 | |
|---|
| 5810 | // Both IE and Gecko use strike instead of del (#523) |
|---|
| 5811 | html = html.replace(/<(\/?)del(\s|>|\/)/ig, "<$1strike$2"); |
|---|
| 5812 | |
|---|
| 5813 | // disable inline event handle inside Xinha iframe |
|---|
| 5814 | html = html.replace(/(<[^>]*on(click|mouse(over|out|up|down))=["'])/gi,'$1if(window.parent && window.parent.Xinha){return false}'); |
|---|
| 5815 | |
|---|
| 5816 | html = this.inwardSpecialReplacements(html); |
|---|
| 5817 | |
|---|
| 5818 | html = html.replace(/(<script)(?![^>]*((type=[\"\']text\/)|(language=[\"\']))javascript[\"\'])/gi,'$1 type="text/javascript"'); |
|---|
| 5819 | html = html.replace(/(<script[^>]*((type=[\"\']text\/)|(language=[\"\'])))(javascript)/gi,"$1freezescript"); |
|---|
| 5820 | |
|---|
| 5821 | // For IE's sake, make any URLs that are semi-absolute (="/....") to be |
|---|
| 5822 | // truely absolute |
|---|
| 5823 | var nullRE = new RegExp('((href|src|background)=[\'"])/+', 'gi'); |
|---|
| 5824 | html = html.replace(nullRE, '$1' + location.href.replace(/(https?:\/\/[^\/]*)\/.*/, '$1') + '/'); |
|---|
| 5825 | |
|---|
| 5826 | html = this.fixRelativeLinks(html); |
|---|
| 5827 | |
|---|
| 5828 | // If in fullPage mode, add the coreCSS |
|---|
| 5829 | if(this.config.fullPage) |
|---|
| 5830 | { |
|---|
| 5831 | html = Xinha.addCoreCSS(html); |
|---|
| 5832 | } |
|---|
| 5833 | |
|---|
| 5834 | if (typeof this.config.inwardHtml == 'function' ) |
|---|
| 5835 | { |
|---|
| 5836 | html = this.config.inwardHtml(html); |
|---|
| 5837 | } |
|---|
| 5838 | |
|---|
| 5839 | return html; |
|---|
| 5840 | }; |
|---|
| 5841 | /** Apply the replacements defined in Xinha.Config.specialReplacements |
|---|
| 5842 | * |
|---|
| 5843 | * @private |
|---|
| 5844 | * @see Xinha#inwardSpecialReplacements |
|---|
| 5845 | * @param {String} html |
|---|
| 5846 | * @returns {String} transformed HTML |
|---|
| 5847 | */ |
|---|
| 5848 | Xinha.prototype.outwardSpecialReplacements = function(html) |
|---|
| 5849 | { |
|---|
| 5850 | for ( var i in this.config.specialReplacements ) |
|---|
| 5851 | { |
|---|
| 5852 | var from = this.config.specialReplacements[i]; |
|---|
| 5853 | var to = i; // why are declaring a new variable here ? Seems to be better to just do : for (var to in config) |
|---|
| 5854 | // prevent iterating over wrong type |
|---|
| 5855 | if ( typeof from.replace != 'function' || typeof to.replace != 'function' ) |
|---|
| 5856 | { |
|---|
| 5857 | continue; |
|---|
| 5858 | } |
|---|
| 5859 | // alert('out : ' + from + '=>' + to); |
|---|
| 5860 | var reg = new RegExp(Xinha.escapeStringForRegExp(from), 'g'); |
|---|
| 5861 | html = html.replace(reg, to.replace(/\$/g, '$$$$')); |
|---|
| 5862 | //html = html.replace(from, to); |
|---|
| 5863 | } |
|---|
| 5864 | return html; |
|---|
| 5865 | }; |
|---|
| 5866 | /** Apply the replacements defined in Xinha.Config.specialReplacements |
|---|
| 5867 | * |
|---|
| 5868 | * @private |
|---|
| 5869 | * @see Xinha#outwardSpecialReplacements |
|---|
| 5870 | * @param {String} html |
|---|
| 5871 | * @returns {String} transformed HTML |
|---|
| 5872 | */ |
|---|
| 5873 | Xinha.prototype.inwardSpecialReplacements = function(html) |
|---|
| 5874 | { |
|---|
| 5875 | // alert("inward"); |
|---|
| 5876 | for ( var i in this.config.specialReplacements ) |
|---|
| 5877 | { |
|---|
| 5878 | var from = i; // why are declaring a new variable here ? Seems to be better to just do : for (var from in config) |
|---|
| 5879 | var to = this.config.specialReplacements[i]; |
|---|
| 5880 | // prevent iterating over wrong type |
|---|
| 5881 | if ( typeof from.replace != 'function' || typeof to.replace != 'function' ) |
|---|
| 5882 | { |
|---|
| 5883 | continue; |
|---|
| 5884 | } |
|---|
| 5885 | // alert('in : ' + from + '=>' + to); |
|---|
| 5886 | // |
|---|
| 5887 | // html = html.replace(reg, to); |
|---|
| 5888 | // html = html.replace(from, to); |
|---|
| 5889 | var reg = new RegExp(Xinha.escapeStringForRegExp(from), 'g'); |
|---|
| 5890 | html = html.replace(reg, to.replace(/\$/g, '$$$$')); // IE uses doubled dollar signs to escape backrefs, also beware that IE also implements $& $_ and $' like perl. |
|---|
| 5891 | } |
|---|
| 5892 | return html; |
|---|
| 5893 | }; |
|---|
| 5894 | |
|---|
| 5895 | |
|---|
| 5896 | |
|---|
| 5897 | |
|---|
| 5898 | |
|---|
| 5899 | |
|---|
| 5900 | |
|---|
| 5901 | |
|---|
| 5902 | |
|---|
| 5903 | |
|---|
| 5904 | Xinha.prototype.fixRelativeLinks = function(html) |
|---|
| 5905 | { |
|---|
| 5906 | if ( typeof this.config.expandRelativeUrl != 'undefined' && this.config.expandRelativeUrl ) |
|---|
| 5907 | { |
|---|
| 5908 | if (html == null) |
|---|
| 5909 | { |
|---|
| 5910 | return ""; |
|---|
| 5911 | } |
|---|
| 5912 | var src = html.match(/(src|href)="([^"]*)"/gi); |
|---|
| 5913 | var b = document.location.href; |
|---|
| 5914 | if ( src ) |
|---|
| 5915 | { |
|---|
| 5916 | var url,url_m,relPath,base_m,absPath; |
|---|
| 5917 | for ( var i=0;i<src.length;++i ) |
|---|
| 5918 | { |
|---|
| 5919 | url = src[i].match(/(src|href)="([^"]*)"/i); |
|---|
| 5920 | url_m = url[2].match( /\.\.\ |
|---|
| 5921 | if ( url_m ) |
|---|
| 5922 | { |
|---|
| 5923 | relPath = new RegExp( "(.*?)(([^\/]*\/){"+ url_m.length+"})[^\/]*$" ); |
|---|
| 5924 | base_m = b.match( relPath ); |
|---|
| 5925 | absPath = url[2].replace(/(\.\.\/)*/,base_m[1]); |
|---|
| 5926 | html = html.replace( new RegExp(Xinha.escapeStringForRegExp(url[2])),absPath ); |
|---|
| 5927 | } |
|---|
| 5928 | } |
|---|
| 5929 | } |
|---|
| 5930 | } |
|---|
| 5931 | |
|---|
| 5932 | if ( typeof this.config.stripSelfNamedAnchors != 'undefined' && this.config.stripSelfNamedAnchors ) |
|---|
| 5933 | { |
|---|
| 5934 | var stripRe = new RegExp("((href|src|background)=\")("+Xinha.escapeStringForRegExp(window.unescape(document.location.href.replace(/&/g,'&'))) + ')([#?][^\'" ]*)', 'g'); |
|---|
| 5935 | html = html.replace(stripRe, '$1$4'); |
|---|
| 5936 | } |
|---|
| 5937 | |
|---|
| 5938 | if ( typeof this.config.stripBaseHref != 'undefined' && this.config.stripBaseHref ) |
|---|
| 5939 | { |
|---|
| 5940 | var baseRe = null; |
|---|
| 5941 | if ( typeof this.config.baseHref != 'undefined' && this.config.baseHref !== null ) |
|---|
| 5942 | { |
|---|
| 5943 | baseRe = new RegExp( "((href|src|background|action)=\")(" + Xinha.escapeStringForRegExp(this.config.baseHref.replace(/([^\/]\/)(?=.+\.)[^\/]*$/, "$1")) + ")", 'g' ); |
|---|
| 5944 | html = html.replace(baseRe, '$1'); |
|---|
| 5945 | } |
|---|
| 5946 | baseRe = new RegExp( "((href|src|background|action)=\")(" + Xinha.escapeStringForRegExp(document.location.href.replace( /^(https?:\/\/[^\/]*)(.*)/, '$1' )) + ")", 'g' ); |
|---|
| 5947 | html = html.replace(baseRe, '$1'); |
|---|
| 5948 | } |
|---|
| 5949 | |
|---|
| 5950 | return html; |
|---|
| 5951 | }; |
|---|
| 5952 | |
|---|
| 5953 | |
|---|
| 5954 | |
|---|
| 5955 | |
|---|
| 5956 | |
|---|
| 5957 | |
|---|
| 5958 | Xinha.prototype.getInnerHTML = function() |
|---|
| 5959 | { |
|---|
| 5960 | if ( !this._doc.body ) |
|---|
| 5961 | { |
|---|
| 5962 | return ''; |
|---|
| 5963 | } |
|---|
| 5964 | var html = ""; |
|---|
| 5965 | switch ( this._editMode ) |
|---|
| 5966 | { |
|---|
| 5967 | case "wysiwyg": |
|---|
| 5968 | if ( !this.config.fullPage ) |
|---|
| 5969 | { |
|---|
| 5970 | |
|---|
| 5971 | html = this._doc.body.innerHTML; |
|---|
| 5972 | } |
|---|
| 5973 | else |
|---|
| 5974 | { |
|---|
| 5975 | html = this.doctype + "\n" + this._doc.documentElement.innerHTML; |
|---|
| 5976 | } |
|---|
| 5977 | break; |
|---|
| 5978 | case "textmode" : |
|---|
| 5979 | html = this._textArea.value; |
|---|
| 5980 | break; |
|---|
| 5981 | default: |
|---|
| 5982 | alert("Mode <" + this._editMode + "> not defined!"); |
|---|
| 5983 | return false; |
|---|
| 5984 | } |
|---|
| 5985 | |
|---|
| 5986 | return html; |
|---|
| 5987 | }; |
|---|
| 5988 | |
|---|
| 5989 | |
|---|
| 5990 | |
|---|
| 5991 | |
|---|
| 5992 | |
|---|
| 5993 | |
|---|
| 5994 | Xinha.prototype.setHTML = function(html) |
|---|
| 5995 | { |
|---|
| 5996 | if ( !this.config.fullPage ) |
|---|
| 5997 | { |
|---|
| 5998 | this._doc.body.innerHTML = html; |
|---|
| 5999 | } |
|---|
| 6000 | else |
|---|
| 6001 | { |
|---|
| 6002 | this.setFullHTML(html); |
|---|
| 6003 | } |
|---|
| 6004 | this._textArea.value = html; |
|---|
| 6005 | }; |
|---|
| 6006 | |
|---|
| 6007 | |
|---|
| 6008 | |
|---|
| 6009 | |
|---|
| 6010 | |
|---|
| 6011 | |
|---|
| 6012 | Xinha.prototype.setDoctype = function(doctype) |
|---|
| 6013 | { |
|---|
| 6014 | this.doctype = doctype; |
|---|
| 6015 | }; |
|---|
| 6016 | |
|---|
| 6017 | |
|---|
| 6018 | |
|---|
| 6019 | |
|---|
| 6020 | |
|---|
| 6021 | |
|---|
| 6022 | |
|---|
| 6023 | |
|---|
| 6024 | |
|---|
| 6025 | |
|---|
| 6026 | |
|---|
| 6027 | Xinha._object = null; |
|---|
| 6028 | |
|---|
| 6029 | |
|---|
| 6030 | |
|---|
| 6031 | Array.prototype.isArray = true; |
|---|
| 6032 | |
|---|
| 6033 | |
|---|
| 6034 | RegExp.prototype.isRegExp = true; |
|---|
| 6035 | |
|---|
| 6036 | |
|---|
| 6037 | |
|---|
| 6038 | |
|---|
| 6039 | |
|---|
| 6040 | |
|---|
| 6041 | Xinha.cloneObject = function(obj) |
|---|
| 6042 | { |
|---|
| 6043 | if ( !obj ) |
|---|
| 6044 | { |
|---|
| 6045 | return null; |
|---|
| 6046 | } |
|---|
| 6047 | var newObj = obj.isArray ? [] : {}; |
|---|
| 6048 | |
|---|
| 6049 | |
|---|
| 6050 | if ( obj.constructor.toString().match( /\s*function Function\(/ ) || typeof obj == 'function' ) |
|---|
| 6051 | { |
|---|
| 6052 | newObj = obj; |
|---|
| 6053 | } |
|---|
| 6054 | else if ( obj.isRegExp ) |
|---|
| 6055 | { |
|---|
| 6056 | newObj = eval( obj.toString() ); |
|---|
| 6057 | } |
|---|
| 6058 | else |
|---|
| 6059 | { |
|---|
| 6060 | for ( var n in obj ) |
|---|
| 6061 | { |
|---|
| 6062 | var node = obj[n]; |
|---|
| 6063 | if ( typeof node == 'object' ) |
|---|
| 6064 | { |
|---|
| 6065 | newObj[n] = Xinha.cloneObject(node); |
|---|
| 6066 | } |
|---|
| 6067 | else |
|---|
| 6068 | { |
|---|
| 6069 | newObj[n] = node; |
|---|
| 6070 | } |
|---|
| 6071 | } |
|---|
| 6072 | } |
|---|
| 6073 | |
|---|
| 6074 | return newObj; |
|---|
| 6075 | }; |
|---|
| 6076 | |
|---|
| 6077 | |
|---|
| 6078 | |
|---|
| 6079 | |
|---|
| 6080 | |
|---|
| 6081 | |
|---|
| 6082 | |
|---|
| 6083 | |
|---|
| 6084 | |
|---|
| 6085 | |
|---|
| 6086 | |
|---|
| 6087 | |
|---|
| 6088 | |
|---|
| 6089 | |
|---|
| 6090 | |
|---|
| 6091 | |
|---|
| 6092 | |
|---|
| 6093 | |
|---|
| 6094 | |
|---|
| 6095 | |
|---|
| 6096 | |
|---|
| 6097 | |
|---|
| 6098 | |
|---|
| 6099 | |
|---|
| 6100 | |
|---|
| 6101 | |
|---|
| 6102 | |
|---|
| 6103 | |
|---|
| 6104 | |
|---|
| 6105 | |
|---|
| 6106 | |
|---|
| 6107 | |
|---|
| 6108 | |
|---|
| 6109 | |
|---|
| 6110 | |
|---|
| 6111 | |
|---|
| 6112 | |
|---|
| 6113 | |
|---|
| 6114 | |
|---|
| 6115 | |
|---|
| 6116 | |
|---|
| 6117 | |
|---|
| 6118 | |
|---|
| 6119 | |
|---|
| 6120 | |
|---|
| 6121 | |
|---|
| 6122 | |
|---|
| 6123 | |
|---|
| 6124 | |
|---|
| 6125 | |
|---|
| 6126 | |
|---|
| 6127 | |
|---|
| 6128 | |
|---|
| 6129 | |
|---|
| 6130 | |
|---|
| 6131 | |
|---|
| 6132 | |
|---|
| 6133 | |
|---|
| 6134 | |
|---|
| 6135 | |
|---|
| 6136 | |
|---|
| 6137 | |
|---|
| 6138 | |
|---|
| 6139 | |
|---|
| 6140 | |
|---|
| 6141 | |
|---|
| 6142 | |
|---|
| 6143 | |
|---|
| 6144 | |
|---|
| 6145 | |
|---|
| 6146 | |
|---|
| 6147 | |
|---|
| 6148 | |
|---|
| 6149 | |
|---|
| 6150 | |
|---|
| 6151 | |
|---|
| 6152 | |
|---|
| 6153 | |
|---|
| 6154 | |
|---|
| 6155 | |
|---|
| 6156 | |
|---|
| 6157 | |
|---|
| 6158 | |
|---|
| 6159 | |
|---|
| 6160 | |
|---|
| 6161 | |
|---|
| 6162 | |
|---|
| 6163 | |
|---|
| 6164 | |
|---|
| 6165 | |
|---|
| 6166 | |
|---|
| 6167 | |
|---|
| 6168 | |
|---|
| 6169 | |
|---|
| 6170 | Xinha.extend = function(subClass, baseClass) { |
|---|
| 6171 | function inheritance() {} |
|---|
| 6172 | inheritance.prototype = baseClass.prototype; |
|---|
| 6173 | |
|---|
| 6174 | subClass.prototype = new inheritance(); |
|---|
| 6175 | subClass.prototype.constructor = subClass; |
|---|
| 6176 | subClass.parentConstructor = baseClass; |
|---|
| 6177 | subClass.superClass = baseClass.prototype; |
|---|
| 6178 | } |
|---|
| 6179 | |
|---|
| 6180 | |
|---|
| 6181 | |
|---|
| 6182 | |
|---|
| 6183 | |
|---|
| 6184 | |
|---|
| 6185 | |
|---|
| 6186 | |
|---|
| 6187 | |
|---|
| 6188 | Xinha.flushEvents = function() |
|---|
| 6189 | { |
|---|
| 6190 | var x = 0; |
|---|
| 6191 | |
|---|
| 6192 | var e = Xinha._eventFlushers.pop(); |
|---|
| 6193 | while ( e ) |
|---|
| 6194 | { |
|---|
| 6195 | try |
|---|
| 6196 | { |
|---|
| 6197 | if ( e.length == 3 ) |
|---|
| 6198 | { |
|---|
| 6199 | Xinha._removeEvent(e[0], e[1], e[2]); |
|---|
| 6200 | x++; |
|---|
| 6201 | } |
|---|
| 6202 | else if ( e.length == 2 ) |
|---|
| 6203 | { |
|---|
| 6204 | e[0]['on' + e[1]] = null; |
|---|
| 6205 | e[0]._xinha_dom0Events[e[1]] = null; |
|---|
| 6206 | x++; |
|---|
| 6207 | } |
|---|
| 6208 | } |
|---|
| 6209 | catch(ex) |
|---|
| 6210 | { |
|---|
| 6211 | |
|---|
| 6212 | } |
|---|
| 6213 | e = Xinha._eventFlushers.pop(); |
|---|
| 6214 | } |
|---|
| 6215 | |
|---|
| 6216 | |
|---|
| 6217 | |
|---|
| 6218 | |
|---|
| 6219 | |
|---|
| 6220 | |
|---|
| 6221 | |
|---|
| 6222 | |
|---|
| 6223 | |
|---|
| 6224 | |
|---|
| 6225 | |
|---|
| 6226 | |
|---|
| 6227 | |
|---|
| 6228 | |
|---|
| 6229 | |
|---|
| 6230 | |
|---|
| 6231 | |
|---|
| 6232 | |
|---|
| 6233 | |
|---|
| 6234 | |
|---|
| 6235 | |
|---|
| 6236 | }; |
|---|
| 6237 | |
|---|
| 6238 | |
|---|
| 6239 | |
|---|
| 6240 | Xinha._eventFlushers = []; |
|---|
| 6241 | |
|---|
| 6242 | if ( document.addEventListener ) |
|---|
| 6243 | { |
|---|
| 6244 | |
|---|
| 6245 | |
|---|
| 6246 | |
|---|
| 6247 | |
|---|
| 6248 | |
|---|
| 6249 | |
|---|
| 6250 | |
|---|
| 6251 | |
|---|
| 6252 | |
|---|
| 6253 | |
|---|
| 6254 | Xinha._addEvent = function(el, evname, func) |
|---|
| 6255 | { |
|---|
| 6256 | el.addEventListener(evname, func, false); |
|---|
| 6257 | Xinha._eventFlushers.push([el, evname, func]); |
|---|
| 6258 | }; |
|---|
| 6259 | |
|---|
| 6260 | |
|---|
| 6261 | |
|---|
| 6262 | |
|---|
| 6263 | |
|---|
| 6264 | |
|---|
| 6265 | |
|---|
| 6266 | |
|---|
| 6267 | |
|---|
| 6268 | Xinha._removeEvent = function(el, evname, func) |
|---|
| 6269 | { |
|---|
| 6270 | el.removeEventListener(evname, func, false); |
|---|
| 6271 | }; |
|---|
| 6272 | |
|---|
| 6273 | |
|---|
| 6274 | |
|---|
| 6275 | |
|---|
| 6276 | |
|---|
| 6277 | |
|---|
| 6278 | Xinha._stopEvent = function(ev) |
|---|
| 6279 | { |
|---|
| 6280 | ev.preventDefault(); |
|---|
| 6281 | ev.stopPropagation(); |
|---|
| 6282 | }; |
|---|
| 6283 | } |
|---|
| 6284 | |
|---|
| 6285 | |
|---|
| 6286 | |
|---|
| 6287 | else if ( document.attachEvent ) |
|---|
| 6288 | { |
|---|
| 6289 | Xinha._addEvent = function(el, evname, func) |
|---|
| 6290 | { |
|---|
| 6291 | el.attachEvent("on" + evname, func); |
|---|
| 6292 | Xinha._eventFlushers.push([el, evname, func]); |
|---|
| 6293 | }; |
|---|
| 6294 | Xinha._removeEvent = function(el, evname, func) |
|---|
| 6295 | { |
|---|
| 6296 | el.detachEvent("on" + evname, func); |
|---|
| 6297 | }; |
|---|
| 6298 | Xinha._stopEvent = function(ev) |
|---|
| 6299 | { |
|---|
| 6300 | try |
|---|
| 6301 | { |
|---|
| 6302 | ev.cancelBubble = true; |
|---|
| 6303 | ev.returnValue = false; |
|---|
| 6304 | } |
|---|
| 6305 | catch (ex) |
|---|
| 6306 | { |
|---|
| 6307 | |
|---|
| 6308 | |
|---|
| 6309 | |
|---|
| 6310 | } |
|---|
| 6311 | }; |
|---|
| 6312 | } |
|---|
| 6313 | else |
|---|
| 6314 | { |
|---|
| 6315 | Xinha._addEvent = function(el, evname, func) |
|---|
| 6316 | { |
|---|
| 6317 | alert('_addEvent is not supported'); |
|---|
| 6318 | }; |
|---|
| 6319 | Xinha._removeEvent = function(el, evname, func) |
|---|
| 6320 | { |
|---|
| 6321 | alert('_removeEvent is not supported'); |
|---|
| 6322 | }; |
|---|
| 6323 | Xinha._stopEvent = function(ev) |
|---|
| 6324 | { |
|---|
| 6325 | alert('_stopEvent is not supported'); |
|---|
| 6326 | }; |
|---|
| 6327 | } |
|---|
| 6328 | |
|---|
| 6329 | |
|---|
| 6330 | |
|---|
| 6331 | |
|---|
| 6332 | |
|---|
| 6333 | |
|---|
| 6334 | |
|---|
| 6335 | |
|---|
| 6336 | Xinha._addEvents = function(el, evs, func) |
|---|
| 6337 | { |
|---|
| 6338 | for ( var i = evs.length; --i >= 0; ) |
|---|
| 6339 | { |
|---|
| 6340 | Xinha._addEvent(el, evs[i], func); |
|---|
| 6341 | } |
|---|
| 6342 | }; |
|---|
| 6343 | |
|---|
| 6344 | |
|---|
| 6345 | |
|---|
| 6346 | |
|---|
| 6347 | |
|---|
| 6348 | |
|---|
| 6349 | |
|---|
| 6350 | |
|---|
| 6351 | Xinha._removeEvents = function(el, evs, func) |
|---|
| 6352 | { |
|---|
| 6353 | for ( var i = evs.length; --i >= 0; ) |
|---|
| 6354 | { |
|---|
| 6355 | Xinha._removeEvent(el, evs[i], func); |
|---|
| 6356 | } |
|---|
| 6357 | }; |
|---|
| 6358 | |
|---|
| 6359 | |
|---|
| 6360 | |
|---|
| 6361 | |
|---|
| 6362 | |
|---|
| 6363 | |
|---|
| 6364 | |
|---|
| 6365 | |
|---|
| 6366 | |
|---|
| 6367 | Xinha.addOnloadHandler = function (func, scope) |
|---|
| 6368 | { |
|---|
| 6369 | scope = scope ? scope : window; |
|---|
| 6370 | |
|---|
| 6371 | var init = function () |
|---|
| 6372 | { |
|---|
| 6373 | |
|---|
| 6374 | if (arguments.callee.done) |
|---|
| 6375 | { |
|---|
| 6376 | return; |
|---|
| 6377 | } |
|---|
| 6378 | |
|---|
| 6379 | arguments.callee.done = true; |
|---|
| 6380 | |
|---|
| 6381 | if (Xinha.onloadTimer) |
|---|
| 6382 | { |
|---|
| 6383 | clearInterval(Xinha.onloadTimer); |
|---|
| 6384 | } |
|---|
| 6385 | |
|---|
| 6386 | func(); |
|---|
| 6387 | }; |
|---|
| 6388 | if (Xinha.is_ie) |
|---|
| 6389 | { |
|---|
| 6390 | |
|---|
| 6391 | |
|---|
| 6392 | document.attachEvent("onreadystatechange", function(){ |
|---|
| 6393 | if ( document.readyState === "complete" ) { |
|---|
| 6394 | document.detachEvent( "onreadystatechange", arguments.callee ); |
|---|
| 6395 | init(); |
|---|
| 6396 | } |
|---|
| 6397 | }); |
|---|
| 6398 | if ( document.documentElement.doScroll && typeof window.frameElement === "undefined" ) (function(){ |
|---|
| 6399 | if (arguments.callee.done) return; |
|---|
| 6400 | try { |
|---|
| 6401 | |
|---|
| 6402 | |
|---|
| 6403 | document.documentElement.doScroll("left"); |
|---|
| 6404 | } catch( error ) { |
|---|
| 6405 | setTimeout( arguments.callee, 0 ); |
|---|
| 6406 | return; |
|---|
| 6407 | } |
|---|
| 6408 | |
|---|
| 6409 | init(); |
|---|
| 6410 | })(); |
|---|
| 6411 | } |
|---|
| 6412 | else if (/applewebkit|KHTML/i.test(navigator.userAgent) ) |
|---|
| 6413 | { |
|---|
| 6414 | Xinha.onloadTimer = scope.setInterval(function() |
|---|
| 6415 | { |
|---|
| 6416 | if (/loaded|complete/.test(scope.document.readyState)) |
|---|
| 6417 | { |
|---|
| 6418 | init(); |
|---|
| 6419 | } |
|---|
| 6420 | }, 10); |
|---|
| 6421 | } |
|---|
| 6422 | else |
|---|
| 6423 | { |
|---|
| 6424 | scope.document.addEventListener("DOMContentLoaded", init, false); |
|---|
| 6425 | |
|---|
| 6426 | } |
|---|
| 6427 | Xinha._addEvent(scope, 'load', init); |
|---|
| 6428 | }; |
|---|
| 6429 | |
|---|
| 6430 | |
|---|
| 6431 | |
|---|
| 6432 | |
|---|
| 6433 | |
|---|
| 6434 | |
|---|
| 6435 | |
|---|
| 6436 | |
|---|
| 6437 | |
|---|
| 6438 | |
|---|
| 6439 | |
|---|
| 6440 | |
|---|
| 6441 | |
|---|
| 6442 | |
|---|
| 6443 | |
|---|
| 6444 | |
|---|
| 6445 | |
|---|
| 6446 | |
|---|
| 6447 | |
|---|
| 6448 | |
|---|
| 6449 | |
|---|
| 6450 | |
|---|
| 6451 | |
|---|
| 6452 | Xinha.addDom0Event = function(el, ev, fn) |
|---|
| 6453 | { |
|---|
| 6454 | Xinha._prepareForDom0Events(el, ev); |
|---|
| 6455 | el._xinha_dom0Events[ev].unshift(fn); |
|---|
| 6456 | }; |
|---|
| 6457 | |
|---|
| 6458 | |
|---|
| 6459 | |
|---|
| 6460 | |
|---|
| 6461 | |
|---|
| 6462 | |
|---|
| 6463 | |
|---|
| 6464 | |
|---|
| 6465 | |
|---|
| 6466 | |
|---|
| 6467 | |
|---|
| 6468 | |
|---|
| 6469 | |
|---|
| 6470 | |
|---|
| 6471 | Xinha.prependDom0Event = function(el, ev, fn) |
|---|
| 6472 | { |
|---|
| 6473 | Xinha._prepareForDom0Events(el, ev); |
|---|
| 6474 | el._xinha_dom0Events[ev].push(fn); |
|---|
| 6475 | }; |
|---|
| 6476 | |
|---|
| 6477 | Xinha.getEvent = function(ev) |
|---|
| 6478 | { |
|---|
| 6479 | return ev || window.event; |
|---|
| 6480 | }; |
|---|
| 6481 | |
|---|
| 6482 | |
|---|
| 6483 | |
|---|
| 6484 | |
|---|
| 6485 | |
|---|
| 6486 | |
|---|
| 6487 | Xinha._prepareForDom0Events = function(el, ev) |
|---|
| 6488 | { |
|---|
| 6489 | |
|---|
| 6490 | if ( typeof el._xinha_dom0Events == 'undefined' ) |
|---|
| 6491 | { |
|---|
| 6492 | el._xinha_dom0Events = {}; |
|---|
| 6493 | Xinha.freeLater(el, '_xinha_dom0Events'); |
|---|
| 6494 | } |
|---|
| 6495 | |
|---|
| 6496 | |
|---|
| 6497 | if ( typeof el._xinha_dom0Events[ev] == 'undefined' ) |
|---|
| 6498 | { |
|---|
| 6499 | el._xinha_dom0Events[ev] = [ ]; |
|---|
| 6500 | if ( typeof el['on'+ev] == 'function' ) |
|---|
| 6501 | { |
|---|
| 6502 | el._xinha_dom0Events[ev].push(el['on'+ev]); |
|---|
| 6503 | } |
|---|
| 6504 | |
|---|
| 6505 | |
|---|
| 6506 | |
|---|
| 6507 | |
|---|
| 6508 | el['on'+ev] = function(event) |
|---|
| 6509 | { |
|---|
| 6510 | var a = el._xinha_dom0Events[ev]; |
|---|
| 6511 | |
|---|
| 6512 | var allOK = true; |
|---|
| 6513 | for ( var i = a.length; --i >= 0; ) |
|---|
| 6514 | { |
|---|
| 6515 | |
|---|
| 6516 | el._xinha_tempEventHandler = a[i]; |
|---|
| 6517 | if ( el._xinha_tempEventHandler(event) === false ) |
|---|
| 6518 | { |
|---|
| 6519 | el._xinha_tempEventHandler = null; |
|---|
| 6520 | allOK = false; |
|---|
| 6521 | break; |
|---|
| 6522 | } |
|---|
| 6523 | el._xinha_tempEventHandler = null; |
|---|
| 6524 | } |
|---|
| 6525 | return allOK; |
|---|
| 6526 | }; |
|---|
| 6527 | |
|---|
| 6528 | Xinha._eventFlushers.push([el, ev]); |
|---|
| 6529 | } |
|---|
| 6530 | }; |
|---|
| 6531 | |
|---|
| 6532 | Xinha.prototype.notifyOn = function(ev, fn) |
|---|
| 6533 | { |
|---|
| 6534 | if ( typeof this._notifyListeners[ev] == 'undefined' ) |
|---|
| 6535 | { |
|---|
| 6536 | this._notifyListeners[ev] = []; |
|---|
| 6537 | Xinha.freeLater(this, '_notifyListeners'); |
|---|
| 6538 | } |
|---|
| 6539 | this._notifyListeners[ev].push(fn); |
|---|
| 6540 | }; |
|---|
| 6541 | |
|---|
| 6542 | Xinha.prototype.notifyOf = function(ev, args) |
|---|
| 6543 | { |
|---|
| 6544 | if ( this._notifyListeners[ev] ) |
|---|
| 6545 | { |
|---|
| 6546 | for ( var i = 0; i < this._notifyListeners[ev].length; i++ ) |
|---|
| 6547 | { |
|---|
| 6548 | this._notifyListeners[ev][i](ev, args); |
|---|
| 6549 | } |
|---|
| 6550 | } |
|---|
| 6551 | }; |
|---|
| 6552 | |
|---|
| 6553 | |
|---|
| 6554 | |
|---|
| 6555 | |
|---|
| 6556 | |
|---|
| 6557 | |
|---|
| 6558 | |
|---|
| 6559 | Xinha._blockTags = " body form textarea fieldset ul ol dl li div " + |
|---|
| 6560 | "p h1 h2 h3 h4 h5 h6 quote pre table thead " + |
|---|
| 6561 | "tbody tfoot tr td th iframe address blockquote title meta link style head "; |
|---|
| 6562 | |
|---|
| 6563 | |
|---|
| 6564 | |
|---|
| 6565 | |
|---|
| 6566 | |
|---|
| 6567 | |
|---|
| 6568 | Xinha.isBlockElement = function(el) |
|---|
| 6569 | { |
|---|
| 6570 | return el && el.nodeType == 1 && (Xinha._blockTags.indexOf(" " + el.tagName.toLowerCase() + " ") != -1); |
|---|
| 6571 | }; |
|---|
| 6572 | |
|---|
| 6573 | |
|---|
| 6574 | |
|---|
| 6575 | |
|---|
| 6576 | |
|---|
| 6577 | |
|---|
| 6578 | Xinha._paraContainerTags = " body td th caption fieldset div "; |
|---|
| 6579 | |
|---|
| 6580 | |
|---|
| 6581 | |
|---|
| 6582 | |
|---|
| 6583 | |
|---|
| 6584 | Xinha.isParaContainer = function(el) |
|---|
| 6585 | { |
|---|
| 6586 | return el && el.nodeType == 1 && (Xinha._paraContainerTags.indexOf(" " + el.tagName.toLowerCase() + " ") != -1); |
|---|
| 6587 | }; |
|---|
| 6588 | |
|---|
| 6589 | |
|---|
| 6590 | |
|---|
| 6591 | |
|---|
| 6592 | |
|---|
| 6593 | |
|---|
| 6594 | |
|---|
| 6595 | |
|---|
| 6596 | |
|---|
| 6597 | Xinha._closingTags = " a abbr acronym address applet b bdo big blockquote button caption center cite code del dfn dir div dl em fieldset font form frameset h1 h2 h3 h4 h5 h6 i iframe ins kbd label legend map menu noframes noscript object ol optgroup pre q s samp script select small span strike strong style sub sup table textarea title tt u ul var "; |
|---|
| 6598 | |
|---|
| 6599 | |
|---|
| 6600 | |
|---|
| 6601 | |
|---|
| 6602 | |
|---|
| 6603 | |
|---|
| 6604 | Xinha.needsClosingTag = function(el) |
|---|
| 6605 | { |
|---|
| 6606 | return el && el.nodeType == 1 && (Xinha._closingTags.indexOf(" " + el.tagName.toLowerCase() + " ") != -1); |
|---|
| 6607 | }; |
|---|
| 6608 | |
|---|
| 6609 | |
|---|
| 6610 | |
|---|
| 6611 | |
|---|
| 6612 | |
|---|
| 6613 | |
|---|
| 6614 | Xinha.htmlEncode = function(str) |
|---|
| 6615 | { |
|---|
| 6616 | if (!str) |
|---|
| 6617 | { |
|---|
| 6618 | return ''; |
|---|
| 6619 | } if ( typeof str.replace == 'undefined' ) |
|---|
| 6620 | { |
|---|
| 6621 | str = str.toString(); |
|---|
| 6622 | } |
|---|
| 6623 | |
|---|
| 6624 | str = str.replace(/&/ig, "&"); |
|---|
| 6625 | str = str.replace(/</ig, "<"); |
|---|
| 6626 | str = str.replace(/>/ig, ">"); |
|---|
| 6627 | str = str.replace(/\xA0/g, " "); |
|---|
| 6628 | str = str.replace(/\x22/g, """); |
|---|
| 6629 | |
|---|
| 6630 | |
|---|
| 6631 | return str; |
|---|
| 6632 | }; |
|---|
| 6633 | |
|---|
| 6634 | |
|---|
| 6635 | |
|---|
| 6636 | |
|---|
| 6637 | |
|---|
| 6638 | |
|---|
| 6639 | Xinha.prototype.stripBaseURL = function(string) |
|---|
| 6640 | { |
|---|
| 6641 | if ( this.config.baseHref === null || !this.config.stripBaseHref ) |
|---|
| 6642 | { |
|---|
| 6643 | return string; |
|---|
| 6644 | } |
|---|
| 6645 | var baseurl = this.config.baseHref.replace(/^(https?:\/\/[^\/]+)(.*)$/, '$1'); |
|---|
| 6646 | var basere = new RegExp(baseurl); |
|---|
| 6647 | return string.replace(basere, ""); |
|---|
| 6648 | }; |
|---|
| 6649 | |
|---|
| 6650 | if (typeof String.prototype.trim != 'function') |
|---|
| 6651 | { |
|---|
| 6652 | |
|---|
| 6653 | |
|---|
| 6654 | |
|---|
| 6655 | |
|---|
| 6656 | String.prototype.trim = function() |
|---|
| 6657 | { |
|---|
| 6658 | return this.replace(/^\s+/, '').replace(/\s+$/, ''); |
|---|
| 6659 | }; |
|---|
| 6660 | } |
|---|
| 6661 | |
|---|
| 6662 | |
|---|
| 6663 | |
|---|
| 6664 | |
|---|
| 6665 | |
|---|
| 6666 | |
|---|
| 6667 | Xinha._makeColor = function(v) |
|---|
| 6668 | { |
|---|
| 6669 | if ( typeof v != "number" ) |
|---|
| 6670 | { |
|---|
| 6671 | |
|---|
| 6672 | return v; |
|---|
| 6673 | } |
|---|
| 6674 | |
|---|
| 6675 | var r = v & 0xFF; |
|---|
| 6676 | var g = (v >> 8) & 0xFF; |
|---|
| 6677 | var b = (v >> 16) & 0xFF; |
|---|
| 6678 | return "rgb(" + r + "," + g + "," + b + ")"; |
|---|
| 6679 | }; |
|---|
| 6680 | |
|---|
| 6681 | |
|---|
| 6682 | |
|---|
| 6683 | |
|---|
| 6684 | |
|---|
| 6685 | |
|---|
| 6686 | Xinha._colorToRgb = function(v) |
|---|
| 6687 | { |
|---|
| 6688 | if ( !v ) |
|---|
| 6689 | { |
|---|
| 6690 | return ''; |
|---|
| 6691 | } |
|---|
| 6692 | var r,g,b; |
|---|
| 6693 | |
|---|
| 6694 | |
|---|
| 6695 | function hex(d) |
|---|
| 6696 | { |
|---|
| 6697 | return (d < 16) ? ("0" + d.toString(16)) : d.toString(16); |
|---|
| 6698 | } |
|---|
| 6699 | |
|---|
| 6700 | if ( typeof v == "number" ) |
|---|
| 6701 | { |
|---|
| 6702 | |
|---|
| 6703 | r = v & 0xFF; |
|---|
| 6704 | g = (v >> 8) & 0xFF; |
|---|
| 6705 | b = (v >> 16) & 0xFF; |
|---|
| 6706 | return "#" + hex(r) + hex(g) + hex(b); |
|---|
| 6707 | } |
|---|
| 6708 | |
|---|
| 6709 | if ( v.substr(0, 3) == "rgb" ) |
|---|
| 6710 | { |
|---|
| 6711 | |
|---|
| 6712 | var re = /rgb\s*\(\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\s*\)/; |
|---|
| 6713 | if ( v.match(re) ) |
|---|
| 6714 | { |
|---|
| 6715 | r = parseInt(RegExp.$1, 10); |
|---|
| 6716 | g = parseInt(RegExp.$2, 10); |
|---|
| 6717 | b = parseInt(RegExp.$3, 10); |
|---|
| 6718 | return "#" + hex(r) + hex(g) + hex(b); |
|---|
| 6719 | } |
|---|
| 6720 | |
|---|
| 6721 | |
|---|
| 6722 | return null; |
|---|
| 6723 | } |
|---|
| 6724 | |
|---|
| 6725 | if ( v.substr(0, 1) == "#" ) |
|---|
| 6726 | { |
|---|
| 6727 | |
|---|
| 6728 | return v; |
|---|
| 6729 | } |
|---|
| 6730 | |
|---|
| 6731 | |
|---|
| 6732 | return null; |
|---|
| 6733 | }; |
|---|
| 6734 | |
|---|
| 6735 | |
|---|
| 6736 | |
|---|
| 6737 | |
|---|
| 6738 | |
|---|
| 6739 | |
|---|
| 6740 | |
|---|
| 6741 | |
|---|
| 6742 | Xinha.prototype._popupDialog = function(url, action, init) |
|---|
| 6743 | { |
|---|
| 6744 | Dialog(this.popupURL(url), action, init); |
|---|
| 6745 | }; |
|---|
| 6746 | |
|---|
| 6747 | |
|---|
| 6748 | |
|---|
| 6749 | |
|---|
| 6750 | |
|---|
| 6751 | |
|---|
| 6752 | |
|---|
| 6753 | |
|---|
| 6754 | Xinha.prototype.imgURL = function(file, plugin) |
|---|
| 6755 | { |
|---|
| 6756 | if ( typeof plugin == "undefined" ) |
|---|
| 6757 | { |
|---|
| 6758 | return _editor_url + file; |
|---|
| 6759 | } |
|---|
| 6760 | else |
|---|
| 6761 | { |
|---|
| 6762 | return Xinha.getPluginDir(plugin) + "/img/" + file; |
|---|
| 6763 | } |
|---|
| 6764 | }; |
|---|
| 6765 | |
|---|
| 6766 | |
|---|
| 6767 | |
|---|
| 6768 | |
|---|
| 6769 | |
|---|
| 6770 | |
|---|
| 6771 | Xinha.prototype.popupURL = function(file) |
|---|
| 6772 | { |
|---|
| 6773 | var url = ""; |
|---|
| 6774 | if ( file.match(/^plugin:\/\/(.*?)\/(.*)/) ) |
|---|
| 6775 | { |
|---|
| 6776 | var plugin = RegExp.$1; |
|---|
| 6777 | var popup = RegExp.$2; |
|---|
| 6778 | if ( !/\.(html?|php)$/.test(popup) ) |
|---|
| 6779 | { |
|---|
| 6780 | popup += ".html"; |
|---|
| 6781 | } |
|---|
| 6782 | url = Xinha.getPluginDir(plugin) + "/popups/" + popup; |
|---|
| 6783 | } |
|---|
| 6784 | else if ( file.match(/^\/.*?/) || file.match(/^https?:\/\ |
|---|
| 6785 | { |
|---|
| 6786 | url = file; |
|---|
| 6787 | } |
|---|
| 6788 | else |
|---|
| 6789 | { |
|---|
| 6790 | url = _editor_url + this.config.popupURL + file; |
|---|
| 6791 | } |
|---|
| 6792 | return url; |
|---|
| 6793 | }; |
|---|
| 6794 | |
|---|
| 6795 | |
|---|
| 6796 | |
|---|
| 6797 | |
|---|
| 6798 | |
|---|
| 6799 | |
|---|
| 6800 | |
|---|
| 6801 | |
|---|
| 6802 | |
|---|
| 6803 | |
|---|
| 6804 | |
|---|
| 6805 | Xinha.getElementById = function(tag, id) |
|---|
| 6806 | { |
|---|
| 6807 | var el, i, objs = document.getElementsByTagName(tag); |
|---|
| 6808 | for ( i = objs.length; --i >= 0 && (el = objs[i]); ) |
|---|
| 6809 | { |
|---|
| 6810 | if ( el.id == id ) |
|---|
| 6811 | { |
|---|
| 6812 | return el; |
|---|
| 6813 | } |
|---|
| 6814 | } |
|---|
| 6815 | return null; |
|---|
| 6816 | }; |
|---|
| 6817 | |
|---|
| 6818 | |
|---|
| 6819 | |
|---|
| 6820 | |
|---|
| 6821 | |
|---|
| 6822 | |
|---|
| 6823 | Xinha.prototype._toggleBorders = function() |
|---|
| 6824 | { |
|---|
| 6825 | var tables = this._doc.getElementsByTagName('TABLE'); |
|---|
| 6826 | if ( tables.length !== 0 ) |
|---|
| 6827 | { |
|---|
| 6828 | if ( !this.borders ) |
|---|
| 6829 | { |
|---|
| 6830 | this.borders = true; |
|---|
| 6831 | } |
|---|
| 6832 | else |
|---|
| 6833 | { |
|---|
| 6834 | this.borders = false; |
|---|
| 6835 | } |
|---|
| 6836 | |
|---|
| 6837 | for ( var i=0; i < tables.length; i++ ) |
|---|
| 6838 | { |
|---|
| 6839 | if ( this.borders ) |
|---|
| 6840 | { |
|---|
| 6841 | Xinha._addClass(tables[i], 'htmtableborders'); |
|---|
| 6842 | } |
|---|
| 6843 | else |
|---|
| 6844 | { |
|---|
| 6845 | Xinha._removeClass(tables[i], 'htmtableborders'); |
|---|
| 6846 | } |
|---|
| 6847 | } |
|---|
| 6848 | } |
|---|
| 6849 | return true; |
|---|
| 6850 | }; |
|---|
| 6851 | |
|---|
| 6852 | |
|---|
| 6853 | |
|---|
| 6854 | |
|---|
| 6855 | |
|---|
| 6856 | |
|---|
| 6857 | |
|---|
| 6858 | Xinha.addCoreCSS = function(html) |
|---|
| 6859 | { |
|---|
| 6860 | var coreCSS = "<style title=\"XinhaInternalCSS\" type=\"text/css\">" + |
|---|
| 6861 | ".htmtableborders, .htmtableborders td, .htmtableborders th {border : 1px dashed lightgrey ! important;}\n" + |
|---|
| 6862 | "html, body { border: 0px; } \n" + |
|---|
| 6863 | "body { background-color: #ffffff; } \n" + |
|---|
| 6864 | "img, hr { cursor: default } \n" + |
|---|
| 6865 | "</style>\n"; |
|---|
| 6866 | |
|---|
| 6867 | if( html && /<head>/i.test(html)) |
|---|
| 6868 | { |
|---|
| 6869 | return html.replace(/<head>/i, '<head>' + coreCSS); |
|---|
| 6870 | } |
|---|
| 6871 | else if ( html) |
|---|
| 6872 | { |
|---|
| 6873 | return coreCSS + html; |
|---|
| 6874 | } |
|---|
| 6875 | else |
|---|
| 6876 | { |
|---|
| 6877 | return coreCSS; |
|---|
| 6878 | } |
|---|
| 6879 | }; |
|---|
| 6880 | |
|---|
| 6881 | |
|---|
| 6882 | |
|---|
| 6883 | |
|---|
| 6884 | |
|---|
| 6885 | Xinha.prototype.addEditorStylesheet = function (stylesheet) |
|---|
| 6886 | { |
|---|
| 6887 | var style = this._doc.createElement("link"); |
|---|
| 6888 | style.rel = 'stylesheet'; |
|---|
| 6889 | style.type = 'text/css'; |
|---|
| 6890 | style.title = 'XinhaInternalCSS'; |
|---|
| 6891 | style.href = stylesheet; |
|---|
| 6892 | this._doc.getElementsByTagName("HEAD")[0].appendChild(style); |
|---|
| 6893 | }; |
|---|
| 6894 | |
|---|
| 6895 | |
|---|
| 6896 | |
|---|
| 6897 | |
|---|
| 6898 | |
|---|
| 6899 | |
|---|
| 6900 | |
|---|
| 6901 | Xinha.stripCoreCSS = function(html) |
|---|
| 6902 | { |
|---|
| 6903 | return html.replace(/<style[^>]+title="XinhaInternalCSS"(.|\n)*?<\/style>/ig, '').replace(/<link[^>]+title="XinhaInternalCSS"(.|\n)*?>/ig, ''); |
|---|
| 6904 | }; |
|---|
| 6905 | |
|---|
| 6906 | |
|---|
| 6907 | |
|---|
| 6908 | |
|---|
| 6909 | |
|---|
| 6910 | |
|---|
| 6911 | |
|---|
| 6912 | Xinha._removeClass = function(el, className) |
|---|
| 6913 | { |
|---|
| 6914 | if ( ! ( el && el.className ) ) |
|---|
| 6915 | { |
|---|
| 6916 | return; |
|---|
| 6917 | } |
|---|
| 6918 | var cls = el.className.split(" "); |
|---|
| 6919 | var ar = []; |
|---|
| 6920 | for ( var i = cls.length; i > 0; ) |
|---|
| 6921 | { |
|---|
| 6922 | if ( cls[--i] != className ) |
|---|
| 6923 | { |
|---|
| 6924 | ar[ar.length] = cls[i]; |
|---|
| 6925 | } |
|---|
| 6926 | } |
|---|
| 6927 | el.className = ar.join(" "); |
|---|
| 6928 | }; |
|---|
| 6929 | |
|---|
| 6930 | |
|---|
| 6931 | |
|---|
| 6932 | |
|---|
| 6933 | |
|---|
| 6934 | |
|---|
| 6935 | |
|---|
| 6936 | Xinha._addClass = function(el, className) |
|---|
| 6937 | { |
|---|
| 6938 | |
|---|
| 6939 | Xinha._removeClass(el, className); |
|---|
| 6940 | el.className += " " + className; |
|---|
| 6941 | }; |
|---|
| 6942 | |
|---|
| 6943 | |
|---|
| 6944 | |
|---|
| 6945 | |
|---|
| 6946 | |
|---|
| 6947 | |
|---|
| 6948 | |
|---|
| 6949 | |
|---|
| 6950 | Xinha.addClasses = function(el, classes) |
|---|
| 6951 | { |
|---|
| 6952 | if ( el !== null ) |
|---|
| 6953 | { |
|---|
| 6954 | var thiers = el.className.trim().split(' '); |
|---|
| 6955 | var ours = classes.split(' '); |
|---|
| 6956 | for ( var x = 0; x < ours.length; x++ ) |
|---|
| 6957 | { |
|---|
| 6958 | var exists = false; |
|---|
| 6959 | for ( var i = 0; exists === false && i < thiers.length; i++ ) |
|---|
| 6960 | { |
|---|
| 6961 | if ( thiers[i] == ours[x] ) |
|---|
| 6962 | { |
|---|
| 6963 | exists = true; |
|---|
| 6964 | } |
|---|
| 6965 | } |
|---|
| 6966 | if ( exists === false ) |
|---|
| 6967 | { |
|---|
| 6968 | thiers[thiers.length] = ours[x]; |
|---|
| 6969 | } |
|---|
| 6970 | } |
|---|
| 6971 | el.className = thiers.join(' ').trim(); |
|---|
| 6972 | } |
|---|
| 6973 | }; |
|---|
| 6974 | |
|---|
| 6975 | |
|---|
| 6976 | |
|---|
| 6977 | |
|---|
| 6978 | |
|---|
| 6979 | |
|---|
| 6980 | |
|---|
| 6981 | |
|---|
| 6982 | Xinha.removeClasses = function(el, classes) |
|---|
| 6983 | { |
|---|
| 6984 | var existing = el.className.trim().split(); |
|---|
| 6985 | var new_classes = []; |
|---|
| 6986 | var remove = classes.trim().split(); |
|---|
| 6987 | |
|---|
| 6988 | for ( var i = 0; i < existing.length; i++ ) |
|---|
| 6989 | { |
|---|
| 6990 | var found = false; |
|---|
| 6991 | for ( var x = 0; x < remove.length && !found; x++ ) |
|---|
| 6992 | { |
|---|
| 6993 | if ( existing[i] == remove[x] ) |
|---|
| 6994 | { |
|---|
| 6995 | found = true; |
|---|
| 6996 | } |
|---|
| 6997 | } |
|---|
| 6998 | if ( !found ) |
|---|
| 6999 | { |
|---|
| 7000 | new_classes[new_classes.length] = existing[i]; |
|---|
| 7001 | } |
|---|
| 7002 | } |
|---|
| 7003 | return new_classes.join(' '); |
|---|
| 7004 | }; |
|---|
| 7005 | |
|---|
| 7006 | |
|---|
| 7007 | |
|---|
| 7008 | |
|---|
| 7009 | Xinha.addClass = Xinha._addClass; |
|---|
| 7010 | |
|---|
| 7011 | |
|---|
| 7012 | |
|---|
| 7013 | Xinha.removeClass = Xinha._removeClass; |
|---|
| 7014 | |
|---|
| 7015 | |
|---|
| 7016 | |
|---|
| 7017 | Xinha._addClasses = Xinha.addClasses; |
|---|
| 7018 | |
|---|
| 7019 | |
|---|
| 7020 | |
|---|
| 7021 | Xinha._removeClasses = Xinha.removeClasses; |
|---|
| 7022 | |
|---|
| 7023 | |
|---|
| 7024 | |
|---|
| 7025 | |
|---|
| 7026 | |
|---|
| 7027 | |
|---|
| 7028 | |
|---|
| 7029 | Xinha._hasClass = function(el, className) |
|---|
| 7030 | { |
|---|
| 7031 | if ( ! ( el && el.className ) ) |
|---|
| 7032 | { |
|---|
| 7033 | return false; |
|---|
| 7034 | } |
|---|
| 7035 | var cls = el.className.split(" "); |
|---|
| 7036 | for ( var i = cls.length; i > 0; ) |
|---|
| 7037 | { |
|---|
| 7038 | if ( cls[--i] == className ) |
|---|
| 7039 | { |
|---|
| 7040 | return true; |
|---|
| 7041 | } |
|---|
| 7042 | } |
|---|
| 7043 | return false; |
|---|
| 7044 | }; |
|---|
| 7045 | |
|---|
| 7046 | |
|---|
| 7047 | |
|---|
| 7048 | |
|---|
| 7049 | |
|---|
| 7050 | |
|---|
| 7051 | |
|---|
| 7052 | |
|---|
| 7053 | |
|---|
| 7054 | |
|---|
| 7055 | |
|---|
| 7056 | |
|---|
| 7057 | |
|---|
| 7058 | |
|---|
| 7059 | |
|---|
| 7060 | |
|---|
| 7061 | |
|---|
| 7062 | |
|---|
| 7063 | |
|---|
| 7064 | |
|---|
| 7065 | |
|---|
| 7066 | |
|---|
| 7067 | |
|---|
| 7068 | Xinha._postback_send_charset = true; |
|---|
| 7069 | |
|---|
| 7070 | |
|---|
| 7071 | |
|---|
| 7072 | |
|---|
| 7073 | |
|---|
| 7074 | |
|---|
| 7075 | |
|---|
| 7076 | |
|---|
| 7077 | Xinha._postback = function(url, data, success, failure) |
|---|
| 7078 | { |
|---|
| 7079 | var req = null; |
|---|
| 7080 | req = Xinha.getXMLHTTPRequestObject(); |
|---|
| 7081 | |
|---|
| 7082 | var content = ''; |
|---|
| 7083 | if (typeof data == 'string') |
|---|
| 7084 | { |
|---|
| 7085 | content = data; |
|---|
| 7086 | } |
|---|
| 7087 | else if(typeof data == "object") |
|---|
| 7088 | { |
|---|
| 7089 | for ( var i in data ) |
|---|
| 7090 | { |
|---|
| 7091 | content += (content.length ? '&' : '') + i + '=' + encodeURIComponent(data[i]); |
|---|
| 7092 | } |
|---|
| 7093 | } |
|---|
| 7094 | |
|---|
| 7095 | function callBack() |
|---|
| 7096 | { |
|---|
| 7097 | if ( req.readyState == 4 ) |
|---|
| 7098 | { |
|---|
| 7099 | if ( ((req.status / 100) == 2) || Xinha.isRunLocally && req.status === 0 ) |
|---|
| 7100 | { |
|---|
| 7101 | if ( typeof success == 'function' ) |
|---|
| 7102 | { |
|---|
| 7103 | success(req.responseText, req); |
|---|
| 7104 | } |
|---|
| 7105 | } |
|---|
| 7106 | else if(Xinha._postback_send_charset) |
|---|
| 7107 | { |
|---|
| 7108 | Xinha._postback_send_charset = false; |
|---|
| 7109 | Xinha._postback(url,data,success, failure); |
|---|
| 7110 | } |
|---|
| 7111 | else if (typeof failure == 'function') |
|---|
| 7112 | { |
|---|
| 7113 | failure(req); |
|---|
| 7114 | } |
|---|
| 7115 | else |
|---|
| 7116 | { |
|---|
| 7117 | alert('An error has occurred: ' + req.statusText + '\nURL: ' + url); |
|---|
| 7118 | } |
|---|
| 7119 | } |
|---|
| 7120 | } |
|---|
| 7121 | |
|---|
| 7122 | req.onreadystatechange = callBack; |
|---|
| 7123 | |
|---|
| 7124 | req.open('POST', url, true); |
|---|
| 7125 | req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'+(Xinha._postback_send_charset ? '; charset=UTF-8' : '')); |
|---|
| 7126 | |
|---|
| 7127 | req.send(content); |
|---|
| 7128 | }; |
|---|
| 7129 | |
|---|
| 7130 | |
|---|
| 7131 | |
|---|
| 7132 | |
|---|
| 7133 | |
|---|
| 7134 | |
|---|
| 7135 | |
|---|
| 7136 | |
|---|
| 7137 | |
|---|
| 7138 | Xinha._getback = function(url, success, failure) |
|---|
| 7139 | { |
|---|
| 7140 | var req = null; |
|---|
| 7141 | req = Xinha.getXMLHTTPRequestObject(); |
|---|
| 7142 | |
|---|
| 7143 | function callBack() |
|---|
| 7144 | { |
|---|
| 7145 | if ( req.readyState == 4 ) |
|---|
| 7146 | { |
|---|
| 7147 | if ( ((req.status / 100) == 2) || Xinha.isRunLocally && req.status === 0 ) |
|---|
| 7148 | { |
|---|
| 7149 | success(req.responseText, req); |
|---|
| 7150 | } |
|---|
| 7151 | else if (typeof failure == 'function') |
|---|
| 7152 | { |
|---|
| 7153 | failure(req); |
|---|
| 7154 | } |
|---|
| 7155 | else |
|---|
| 7156 | { |
|---|
| 7157 | alert('An error has occurred: ' + req.statusText + '\nURL: ' + url); |
|---|
| 7158 | } |
|---|
| 7159 | } |
|---|
| 7160 | } |
|---|
| 7161 | |
|---|
| 7162 | req.onreadystatechange = callBack; |
|---|
| 7163 | req.open('GET', url, true); |
|---|
| 7164 | req.send(null); |
|---|
| 7165 | }; |
|---|
| 7166 | |
|---|
| 7167 | Xinha.ping = function(url, successHandler, failHandler) |
|---|
| 7168 | { |
|---|
| 7169 | var req = null; |
|---|
| 7170 | req = Xinha.getXMLHTTPRequestObject(); |
|---|
| 7171 | |
|---|
| 7172 | function callBack() |
|---|
| 7173 | { |
|---|
| 7174 | if ( req.readyState == 4 ) |
|---|
| 7175 | { |
|---|
| 7176 | if ( ((req.status / 100) == 2) || Xinha.isRunLocally && req.status === 0 ) |
|---|
| 7177 | { |
|---|
| 7178 | if (successHandler) |
|---|
| 7179 | { |
|---|
| 7180 | successHandler(req); |
|---|
| 7181 | } |
|---|
| 7182 | } |
|---|
| 7183 | else |
|---|
| 7184 | { |
|---|
| 7185 | if (failHandler) |
|---|
| 7186 | { |
|---|
| 7187 | failHandler(req); |
|---|
| 7188 | } |
|---|
| 7189 | } |
|---|
| 7190 | } |
|---|
| 7191 | } |
|---|
| 7192 | |
|---|
| 7193 | |
|---|
| 7194 | |
|---|
| 7195 | |
|---|
| 7196 | var method = 'GET'; |
|---|
| 7197 | req.onreadystatechange = callBack; |
|---|
| 7198 | req.open(method, url, true); |
|---|
| 7199 | req.send(null); |
|---|
| 7200 | }; |
|---|
| 7201 | |
|---|
| 7202 | |
|---|
| 7203 | |
|---|
| 7204 | |
|---|
| 7205 | Xinha._geturlcontent = function(url, returnXML) |
|---|
| 7206 | { |
|---|
| 7207 | var req = null; |
|---|
| 7208 | req = Xinha.getXMLHTTPRequestObject(); |
|---|
| 7209 | |
|---|
| 7210 | |
|---|
| 7211 | req.open('GET', url, false); |
|---|
| 7212 | req.send(null); |
|---|
| 7213 | if ( ((req.status / 100) == 2) || Xinha.isRunLocally && req.status === 0 ) |
|---|
| 7214 | { |
|---|
| 7215 | return (returnXML) ? req.responseXML : req.responseText; |
|---|
| 7216 | } |
|---|
| 7217 | else |
|---|
| 7218 | { |
|---|
| 7219 | return ''; |
|---|
| 7220 | } |
|---|
| 7221 | }; |
|---|
| 7222 | |
|---|
| 7223 | |
|---|
| 7224 | |
|---|
| 7225 | |
|---|
| 7226 | |
|---|
| 7227 | |
|---|
| 7228 | |
|---|
| 7229 | Xinha._posturlcontent = function(url, data, returnXML) |
|---|
| 7230 | { |
|---|
| 7231 | var req = null; |
|---|
| 7232 | req = Xinha.getXMLHTTPRequestObject(); |
|---|
| 7233 | |
|---|
| 7234 | var content = ''; |
|---|
| 7235 | if (typeof data == 'string') |
|---|
| 7236 | { |
|---|
| 7237 | content = data; |
|---|
| 7238 | } |
|---|
| 7239 | else if(typeof data == "object") |
|---|
| 7240 | { |
|---|
| 7241 | for ( var i in data ) |
|---|
| 7242 | { |
|---|
| 7243 | content += (content.length ? '&' : '') + i + '=' + encodeURIComponent(data[i]); |
|---|
| 7244 | } |
|---|
| 7245 | } |
|---|
| 7246 | |
|---|
| 7247 | req.open('POST', url, false); |
|---|
| 7248 | req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'+(Xinha._postback_send_charset ? '; charset=UTF-8' : '')); |
|---|
| 7249 | req.send(content); |
|---|
| 7250 | |
|---|
| 7251 | if ( ((req.status / 100) == 2) || Xinha.isRunLocally && req.status === 0 ) |
|---|
| 7252 | { |
|---|
| 7253 | return (returnXML) ? req.responseXML : req.responseText; |
|---|
| 7254 | } |
|---|
| 7255 | else |
|---|
| 7256 | { |
|---|
| 7257 | return ''; |
|---|
| 7258 | } |
|---|
| 7259 | |
|---|
| 7260 | }; |
|---|
| 7261 | |
|---|
| 7262 | |
|---|
| 7263 | if (typeof dumpValues == 'undefined') |
|---|
| 7264 | { |
|---|
| 7265 | dumpValues = function(o) |
|---|
| 7266 | { |
|---|
| 7267 | var s = ''; |
|---|
| 7268 | for (var prop in o) |
|---|
| 7269 | { |
|---|
| 7270 | if (window.console && typeof window.console.log == 'function') |
|---|
| 7271 | { |
|---|
| 7272 | if (typeof console.firebug != 'undefined') |
|---|
| 7273 | { |
|---|
| 7274 | console.log(o); |
|---|
| 7275 | } |
|---|
| 7276 | else |
|---|
| 7277 | { |
|---|
| 7278 | console.log(prop + ' = ' + o[prop] + '\n'); |
|---|
| 7279 | } |
|---|
| 7280 | } |
|---|
| 7281 | else |
|---|
| 7282 | { |
|---|
| 7283 | s += prop + ' = ' + o[prop] + '\n'; |
|---|
| 7284 | } |
|---|
| 7285 | } |
|---|
| 7286 | if (s) |
|---|
| 7287 | { |
|---|
| 7288 | if (document.getElementById('errors')) |
|---|
| 7289 | { |
|---|
| 7290 | document.getElementById('errors').value += s; |
|---|
| 7291 | } |
|---|
| 7292 | else |
|---|
| 7293 | { |
|---|
| 7294 | var x = window.open("", "debugger"); |
|---|
| 7295 | x.document.write('<pre>' + s + '</pre>'); |
|---|
| 7296 | } |
|---|
| 7297 | |
|---|
| 7298 | } |
|---|
| 7299 | }; |
|---|
| 7300 | } |
|---|
| 7301 | if ( !Array.prototype.contains ) |
|---|
| 7302 | { |
|---|
| 7303 | |
|---|
| 7304 | |
|---|
| 7305 | |
|---|
| 7306 | |
|---|
| 7307 | Array.prototype.contains = function(needle) |
|---|
| 7308 | { |
|---|
| 7309 | var haystack = this; |
|---|
| 7310 | for ( var i = 0; i < haystack.length; i++ ) |
|---|
| 7311 | { |
|---|
| 7312 | if ( needle == haystack[i] ) |
|---|
| 7313 | { |
|---|
| 7314 | return true; |
|---|
| 7315 | } |
|---|
| 7316 | } |
|---|
| 7317 | return false; |
|---|
| 7318 | }; |
|---|
| 7319 | } |
|---|
| 7320 | |
|---|
| 7321 | if ( !Array.prototype.indexOf ) |
|---|
| 7322 | { |
|---|
| 7323 | |
|---|
| 7324 | |
|---|
| 7325 | |
|---|
| 7326 | |
|---|
| 7327 | Array.prototype.indexOf = function(needle) |
|---|
| 7328 | { |
|---|
| 7329 | var haystack = this; |
|---|
| 7330 | for ( var i = 0; i < haystack.length; i++ ) |
|---|
| 7331 | { |
|---|
| 7332 | if ( needle == haystack[i] ) |
|---|
| 7333 | { |
|---|
| 7334 | return i; |
|---|
| 7335 | } |
|---|
| 7336 | } |
|---|
| 7337 | return -1; |
|---|
| 7338 | }; |
|---|
| 7339 | } |
|---|
| 7340 | if ( !Array.prototype.append ) |
|---|
| 7341 | { |
|---|
| 7342 | |
|---|
| 7343 | |
|---|
| 7344 | |
|---|
| 7345 | |
|---|
| 7346 | Array.prototype.append = function(a) |
|---|
| 7347 | { |
|---|
| 7348 | for ( var i = 0; i < a.length; i++ ) |
|---|
| 7349 | { |
|---|
| 7350 | this.push(a[i]); |
|---|
| 7351 | } |
|---|
| 7352 | return this; |
|---|
| 7353 | }; |
|---|
| 7354 | } |
|---|
| 7355 | |
|---|
| 7356 | |
|---|
| 7357 | |
|---|
| 7358 | |
|---|
| 7359 | |
|---|
| 7360 | |
|---|
| 7361 | if (!Array.prototype.forEach) |
|---|
| 7362 | { |
|---|
| 7363 | Array.prototype.forEach = function(fn ) |
|---|
| 7364 | { |
|---|
| 7365 | var len = this.length; |
|---|
| 7366 | if (typeof fn != "function") |
|---|
| 7367 | { |
|---|
| 7368 | throw new TypeError(); |
|---|
| 7369 | } |
|---|
| 7370 | |
|---|
| 7371 | var thisObject = arguments[1]; |
|---|
| 7372 | for (var i = 0; i < len; i++) |
|---|
| 7373 | { |
|---|
| 7374 | if (i in this) |
|---|
| 7375 | { |
|---|
| 7376 | fn.call(thisObject, this[i], i, this); |
|---|
| 7377 | } |
|---|
| 7378 | } |
|---|
| 7379 | }; |
|---|
| 7380 | } |
|---|
| 7381 | |
|---|
| 7382 | |
|---|
| 7383 | |
|---|
| 7384 | |
|---|
| 7385 | |
|---|
| 7386 | Xinha.getElementsByClassName = function(el,className) |
|---|
| 7387 | { |
|---|
| 7388 | if (el.getElementsByClassName) |
|---|
| 7389 | { |
|---|
| 7390 | return Array.prototype.slice.call(el.getElementsByClassName(className)); |
|---|
| 7391 | } |
|---|
| 7392 | else |
|---|
| 7393 | { |
|---|
| 7394 | var els = el.getElementsByTagName('*'); |
|---|
| 7395 | var result = []; |
|---|
| 7396 | var classNames; |
|---|
| 7397 | for (var i=0;i<els.length;i++) |
|---|
| 7398 | { |
|---|
| 7399 | classNames = els[i].className.split(' '); |
|---|
| 7400 | if (classNames.contains(className)) |
|---|
| 7401 | { |
|---|
| 7402 | result.push(els[i]); |
|---|
| 7403 | } |
|---|
| 7404 | } |
|---|
| 7405 | return result; |
|---|
| 7406 | } |
|---|
| 7407 | }; |
|---|
| 7408 | |
|---|
| 7409 | |
|---|
| 7410 | |
|---|
| 7411 | |
|---|
| 7412 | |
|---|
| 7413 | |
|---|
| 7414 | Xinha.arrayContainsArray = function(a1, a2) |
|---|
| 7415 | { |
|---|
| 7416 | var all_found = true; |
|---|
| 7417 | for ( var x = 0; x < a2.length; x++ ) |
|---|
| 7418 | { |
|---|
| 7419 | var found = false; |
|---|
| 7420 | for ( var i = 0; i < a1.length; i++ ) |
|---|
| 7421 | { |
|---|
| 7422 | if ( a1[i] == a2[x] ) |
|---|
| 7423 | { |
|---|
| 7424 | found = true; |
|---|
| 7425 | break; |
|---|
| 7426 | } |
|---|
| 7427 | } |
|---|
| 7428 | if ( !found ) |
|---|
| 7429 | { |
|---|
| 7430 | all_found = false; |
|---|
| 7431 | break; |
|---|
| 7432 | } |
|---|
| 7433 | } |
|---|
| 7434 | return all_found; |
|---|
| 7435 | }; |
|---|
| 7436 | |
|---|
| 7437 | |
|---|
| 7438 | |
|---|
| 7439 | |
|---|
| 7440 | |
|---|
| 7441 | Xinha.arrayFilter = function(a1, filterfn) |
|---|
| 7442 | { |
|---|
| 7443 | var new_a = [ ]; |
|---|
| 7444 | for ( var x = 0; x < a1.length; x++ ) |
|---|
| 7445 | { |
|---|
| 7446 | if ( filterfn(a1[x]) ) |
|---|
| 7447 | { |
|---|
| 7448 | new_a[new_a.length] = a1[x]; |
|---|
| 7449 | } |
|---|
| 7450 | } |
|---|
| 7451 | return new_a; |
|---|
| 7452 | }; |
|---|
| 7453 | |
|---|
| 7454 | |
|---|
| 7455 | |
|---|
| 7456 | |
|---|
| 7457 | Xinha.collectionToArray = function(collection) |
|---|
| 7458 | { |
|---|
| 7459 | try |
|---|
| 7460 | { |
|---|
| 7461 | return collection.length ? Array.prototype.slice.call(collection) : []; |
|---|
| 7462 | } |
|---|
| 7463 | catch(e) |
|---|
| 7464 | { |
|---|
| 7465 | |
|---|
| 7466 | |
|---|
| 7467 | |
|---|
| 7468 | } |
|---|
| 7469 | |
|---|
| 7470 | var array = [ ]; |
|---|
| 7471 | for ( var i = 0; i < collection.length; i++ ) |
|---|
| 7472 | { |
|---|
| 7473 | array.push(collection.item(i)); |
|---|
| 7474 | } |
|---|
| 7475 | return array; |
|---|
| 7476 | }; |
|---|
| 7477 | |
|---|
| 7478 | |
|---|
| 7479 | |
|---|
| 7480 | |
|---|
| 7481 | Xinha.uniq_count = 0; |
|---|
| 7482 | |
|---|
| 7483 | |
|---|
| 7484 | |
|---|
| 7485 | |
|---|
| 7486 | Xinha.uniq = function(prefix) |
|---|
| 7487 | { |
|---|
| 7488 | return prefix + Xinha.uniq_count++; |
|---|
| 7489 | }; |
|---|
| 7490 | |
|---|
| 7491 | |
|---|
| 7492 | |
|---|
| 7493 | |
|---|
| 7494 | |
|---|
| 7495 | |
|---|
| 7496 | |
|---|
| 7497 | |
|---|
| 7498 | |
|---|
| 7499 | Xinha._loadlang = function(context,url) |
|---|
| 7500 | { |
|---|
| 7501 | var lang; |
|---|
| 7502 | |
|---|
| 7503 | if ( typeof _editor_lcbackend == "string" ) |
|---|
| 7504 | { |
|---|
| 7505 | |
|---|
| 7506 | url = _editor_lcbackend; |
|---|
| 7507 | url = url.replace(/%lang%/, _editor_lang); |
|---|
| 7508 | url = url.replace(/%context%/, context); |
|---|
| 7509 | } |
|---|
| 7510 | else if (!url) |
|---|
| 7511 | { |
|---|
| 7512 | |
|---|
| 7513 | if ( context != 'Xinha') |
|---|
| 7514 | { |
|---|
| 7515 | url = Xinha.getPluginDir(context)+"/lang/"+_editor_lang+".js"; |
|---|
| 7516 | } |
|---|
| 7517 | else |
|---|
| 7518 | { |
|---|
| 7519 | Xinha.setLoadingMessage("Loading language"); |
|---|
| 7520 | url = _editor_url+"lang/"+_editor_lang+".js"; |
|---|
| 7521 | } |
|---|
| 7522 | } |
|---|
| 7523 | |
|---|
| 7524 | var langData = Xinha._geturlcontent(url); |
|---|
| 7525 | if ( langData !== "" ) |
|---|
| 7526 | { |
|---|
| 7527 | try |
|---|
| 7528 | { |
|---|
| 7529 | eval('lang = ' + langData); |
|---|
| 7530 | } |
|---|
| 7531 | catch(ex) |
|---|
| 7532 | { |
|---|
| 7533 | alert('Error reading Language-File ('+url+'):\n'+Error.toString()); |
|---|
| 7534 | lang = {}; |
|---|
| 7535 | } |
|---|
| 7536 | } |
|---|
| 7537 | else |
|---|
| 7538 | { |
|---|
| 7539 | lang = {}; |
|---|
| 7540 | } |
|---|
| 7541 | |
|---|
| 7542 | return lang; |
|---|
| 7543 | }; |
|---|
| 7544 | |
|---|
| 7545 | |
|---|
| 7546 | |
|---|
| 7547 | |
|---|
| 7548 | |
|---|
| 7549 | |
|---|
| 7550 | |
|---|
| 7551 | Xinha._lc = function(string, context, replace) |
|---|
| 7552 | { |
|---|
| 7553 | var url,ret; |
|---|
| 7554 | if (typeof context == 'object' && context.url && context.context) |
|---|
| 7555 | { |
|---|
| 7556 | url = context.url + _editor_lang + ".js"; |
|---|
| 7557 | context = context.context; |
|---|
| 7558 | } |
|---|
| 7559 | |
|---|
| 7560 | var m = null; |
|---|
| 7561 | if (typeof string == 'string') |
|---|
| 7562 | { |
|---|
| 7563 | m = string.match(/\$(.*?)=(.*?)\$/g); |
|---|
| 7564 | } |
|---|
| 7565 | if (m) |
|---|
| 7566 | { |
|---|
| 7567 | if (!replace) |
|---|
| 7568 | { |
|---|
| 7569 | replace = {}; |
|---|
| 7570 | } |
|---|
| 7571 | for (var i = 0;i<m.length;i++) |
|---|
| 7572 | { |
|---|
| 7573 | var n = m[i].match(/\$(.*?)=(.*?)\$/); |
|---|
| 7574 | replace[n[1]] = n[2]; |
|---|
| 7575 | string = string.replace(n[0],'$'+n[1]); |
|---|
| 7576 | } |
|---|
| 7577 | } |
|---|
| 7578 | if ( _editor_lang == "en" ) |
|---|
| 7579 | { |
|---|
| 7580 | if ( typeof string == 'object' && string.string ) |
|---|
| 7581 | { |
|---|
| 7582 | ret = string.string; |
|---|
| 7583 | } |
|---|
| 7584 | else |
|---|
| 7585 | { |
|---|
| 7586 | ret = string; |
|---|
| 7587 | } |
|---|
| 7588 | } |
|---|
| 7589 | else |
|---|
| 7590 | { |
|---|
| 7591 | if ( typeof Xinha._lc_catalog == 'undefined' ) |
|---|
| 7592 | { |
|---|
| 7593 | Xinha._lc_catalog = [ ]; |
|---|
| 7594 | } |
|---|
| 7595 | |
|---|
| 7596 | if ( typeof context == 'undefined' ) |
|---|
| 7597 | { |
|---|
| 7598 | context = 'Xinha'; |
|---|
| 7599 | } |
|---|
| 7600 | |
|---|
| 7601 | if ( typeof Xinha._lc_catalog[context] == 'undefined' ) |
|---|
| 7602 | { |
|---|
| 7603 | Xinha._lc_catalog[context] = Xinha._loadlang(context,url); |
|---|
| 7604 | } |
|---|
| 7605 | |
|---|
| 7606 | var key; |
|---|
| 7607 | if ( typeof string == 'object' && string.key ) |
|---|
| 7608 | { |
|---|
| 7609 | key = string.key; |
|---|
| 7610 | } |
|---|
| 7611 | else if ( typeof string == 'object' && string.string ) |
|---|
| 7612 | { |
|---|
| 7613 | key = string.string; |
|---|
| 7614 | } |
|---|
| 7615 | else |
|---|
| 7616 | { |
|---|
| 7617 | key = string; |
|---|
| 7618 | } |
|---|
| 7619 | |
|---|
| 7620 | if ( typeof Xinha._lc_catalog[context][key] == 'undefined' ) |
|---|
| 7621 | { |
|---|
| 7622 | if ( context=='Xinha' ) |
|---|
| 7623 | { |
|---|
| 7624 | |
|---|
| 7625 | if ( typeof string == 'object' && string.string ) |
|---|
| 7626 | { |
|---|
| 7627 | ret = string.string; |
|---|
| 7628 | } |
|---|
| 7629 | else |
|---|
| 7630 | { |
|---|
| 7631 | ret = string; |
|---|
| 7632 | } |
|---|
| 7633 | } |
|---|
| 7634 | else |
|---|
| 7635 | { |
|---|
| 7636 | |
|---|
| 7637 | return Xinha._lc(string, 'Xinha', replace); |
|---|
| 7638 | } |
|---|
| 7639 | } |
|---|
| 7640 | else |
|---|
| 7641 | { |
|---|
| 7642 | ret = Xinha._lc_catalog[context][key]; |
|---|
| 7643 | } |
|---|
| 7644 | } |
|---|
| 7645 | |
|---|
| 7646 | if ( typeof string == 'object' && string.replace ) |
|---|
| 7647 | { |
|---|
| 7648 | replace = string.replace; |
|---|
| 7649 | } |
|---|
| 7650 | if ( typeof replace != "undefined" ) |
|---|
| 7651 | { |
|---|
| 7652 | for ( i in replace ) |
|---|
| 7653 | { |
|---|
| 7654 | ret = ret.replace('$'+i, replace[i]); |
|---|
| 7655 | } |
|---|
| 7656 | } |
|---|
| 7657 | |
|---|
| 7658 | return ret; |
|---|
| 7659 | }; |
|---|
| 7660 | |
|---|
| 7661 | |
|---|
| 7662 | |
|---|
| 7663 | |
|---|
| 7664 | Xinha.hasDisplayedChildren = function(el) |
|---|
| 7665 | { |
|---|
| 7666 | var children = el.childNodes; |
|---|
| 7667 | for ( var i = 0; i < children.length; i++ ) |
|---|
| 7668 | { |
|---|
| 7669 | if ( children[i].tagName ) |
|---|
| 7670 | { |
|---|
| 7671 | if ( children[i].style.display != 'none' ) |
|---|
| 7672 | { |
|---|
| 7673 | return true; |
|---|
| 7674 | } |
|---|
| 7675 | } |
|---|
| 7676 | } |
|---|
| 7677 | return false; |
|---|
| 7678 | }; |
|---|
| 7679 | |
|---|
| 7680 | |
|---|
| 7681 | |
|---|
| 7682 | |
|---|
| 7683 | |
|---|
| 7684 | |
|---|
| 7685 | |
|---|
| 7686 | |
|---|
| 7687 | |
|---|
| 7688 | |
|---|
| 7689 | |
|---|
| 7690 | |
|---|
| 7691 | Xinha._loadback = function(url, callback, scope, bonus) |
|---|
| 7692 | { |
|---|
| 7693 | if ( document.getElementById(url) ) |
|---|
| 7694 | { |
|---|
| 7695 | return true; |
|---|
| 7696 | } |
|---|
| 7697 | var t = !Xinha.is_ie ? "onload" : 'onreadystatechange'; |
|---|
| 7698 | var s = document.createElement("script"); |
|---|
| 7699 | s.type = "text/javascript"; |
|---|
| 7700 | s.src = url; |
|---|
| 7701 | s.id = url; |
|---|
| 7702 | if ( callback ) |
|---|
| 7703 | { |
|---|
| 7704 | s[t] = function() |
|---|
| 7705 | { |
|---|
| 7706 | if (Xinha.is_ie && (!/loaded|complete/.test(window.event.srcElement.readyState))) |
|---|
| 7707 | { |
|---|
| 7708 | return; |
|---|
| 7709 | } |
|---|
| 7710 | |
|---|
| 7711 | callback.call(scope ? scope : this, bonus); |
|---|
| 7712 | s[t] = null; |
|---|
| 7713 | }; |
|---|
| 7714 | } |
|---|
| 7715 | document.getElementsByTagName("head")[0].appendChild(s); |
|---|
| 7716 | return false; |
|---|
| 7717 | }; |
|---|
| 7718 | |
|---|
| 7719 | |
|---|
| 7720 | |
|---|
| 7721 | |
|---|
| 7722 | |
|---|
| 7723 | |
|---|
| 7724 | |
|---|
| 7725 | Xinha.makeEditors = function(editor_names, default_config, plugin_names) |
|---|
| 7726 | { |
|---|
| 7727 | if (!Xinha.isSupportedBrowser) |
|---|
| 7728 | { |
|---|
| 7729 | return; |
|---|
| 7730 | } |
|---|
| 7731 | |
|---|
| 7732 | if ( typeof default_config == 'function' ) |
|---|
| 7733 | { |
|---|
| 7734 | default_config = default_config(); |
|---|
| 7735 | } |
|---|
| 7736 | |
|---|
| 7737 | var editors = {}; |
|---|
| 7738 | var textarea; |
|---|
| 7739 | for ( var x = 0; x < editor_names.length; x++ ) |
|---|
| 7740 | { |
|---|
| 7741 | if ( typeof editor_names[x] == 'string' ) |
|---|
| 7742 | { |
|---|
| 7743 | textarea = Xinha.getElementById('textarea', editor_names[x] ); |
|---|
| 7744 | if (!textarea) |
|---|
| 7745 | { |
|---|
| 7746 | editor_names[x] = null; |
|---|
| 7747 | continue; |
|---|
| 7748 | } |
|---|
| 7749 | } |
|---|
| 7750 | |
|---|
| 7751 | else if ( typeof editor_names[x] == 'object' && editor_names[x].tagName && editor_names[x].tagName.toLowerCase() == 'textarea' ) |
|---|
| 7752 | { |
|---|
| 7753 | textarea = editor_names[x]; |
|---|
| 7754 | if ( !textarea.id ) |
|---|
| 7755 | { |
|---|
| 7756 | textarea.id = 'xinha_id_' + x; |
|---|
| 7757 | } |
|---|
| 7758 | } |
|---|
| 7759 | var editor = new Xinha(textarea, Xinha.cloneObject(default_config)); |
|---|
| 7760 | editor.registerPlugins(plugin_names); |
|---|
| 7761 | editors[textarea.id] = editor; |
|---|
| 7762 | } |
|---|
| 7763 | return editors; |
|---|
| 7764 | }; |
|---|
| 7765 | |
|---|
| 7766 | |
|---|
| 7767 | |
|---|
| 7768 | Xinha.startEditors = function(editors) |
|---|
| 7769 | { |
|---|
| 7770 | if (!Xinha.isSupportedBrowser) |
|---|
| 7771 | { |
|---|
| 7772 | return; |
|---|
| 7773 | } |
|---|
| 7774 | |
|---|
| 7775 | for ( var i in editors ) |
|---|
| 7776 | { |
|---|
| 7777 | if ( editors[i].generate ) |
|---|
| 7778 | { |
|---|
| 7779 | editors[i].generate(); |
|---|
| 7780 | } |
|---|
| 7781 | } |
|---|
| 7782 | }; |
|---|
| 7783 | |
|---|
| 7784 | |
|---|
| 7785 | |
|---|
| 7786 | |
|---|
| 7787 | Xinha.prototype.registerPlugins = function(plugin_names) |
|---|
| 7788 | { |
|---|
| 7789 | if (!Xinha.isSupportedBrowser) |
|---|
| 7790 | { |
|---|
| 7791 | return; |
|---|
| 7792 | } |
|---|
| 7793 | |
|---|
| 7794 | if ( plugin_names ) |
|---|
| 7795 | { |
|---|
| 7796 | for ( var i = 0; i < plugin_names.length; i++ ) |
|---|
| 7797 | { |
|---|
| 7798 | this.setLoadingMessage(Xinha._lc('Register plugin $plugin', 'Xinha', {'plugin': plugin_names[i]})); |
|---|
| 7799 | this.registerPlugin(plugin_names[i]); |
|---|
| 7800 | } |
|---|
| 7801 | } |
|---|
| 7802 | }; |
|---|
| 7803 | |
|---|
| 7804 | |
|---|
| 7805 | |
|---|
| 7806 | |
|---|
| 7807 | |
|---|
| 7808 | Xinha.base64_encode = function(input) |
|---|
| 7809 | { |
|---|
| 7810 | var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; |
|---|
| 7811 | var output = ""; |
|---|
| 7812 | var chr1, chr2, chr3; |
|---|
| 7813 | var enc1, enc2, enc3, enc4; |
|---|
| 7814 | var i = 0; |
|---|
| 7815 | |
|---|
| 7816 | do |
|---|
| 7817 | { |
|---|
| 7818 | chr1 = input.charCodeAt(i++); |
|---|
| 7819 | chr2 = input.charCodeAt(i++); |
|---|
| 7820 | chr3 = input.charCodeAt(i++); |
|---|
| 7821 | |
|---|
| 7822 | enc1 = chr1 >> 2; |
|---|
| 7823 | enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); |
|---|
| 7824 | enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); |
|---|
| 7825 | enc4 = chr3 & 63; |
|---|
| 7826 | |
|---|
| 7827 | if ( isNaN(chr2) ) |
|---|
| 7828 | { |
|---|
| 7829 | enc3 = enc4 = 64; |
|---|
| 7830 | } |
|---|
| 7831 | else if ( isNaN(chr3) ) |
|---|
| 7832 | { |
|---|
| 7833 | enc4 = 64; |
|---|
| 7834 | } |
|---|
| 7835 | |
|---|
| 7836 | output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) + keyStr.charAt(enc3) + keyStr.charAt(enc4); |
|---|
| 7837 | } while ( i < input.length ); |
|---|
| 7838 | |
|---|
| 7839 | return output; |
|---|
| 7840 | }; |
|---|
| 7841 | |
|---|
| 7842 | |
|---|
| 7843 | |
|---|
| 7844 | |
|---|
| 7845 | |
|---|
| 7846 | Xinha.base64_decode = function(input) |
|---|
| 7847 | { |
|---|
| 7848 | var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; |
|---|
| 7849 | var output = ""; |
|---|
| 7850 | var chr1, chr2, chr3; |
|---|
| 7851 | var enc1, enc2, enc3, enc4; |
|---|
| 7852 | var i = 0; |
|---|
| 7853 | |
|---|
| 7854 | |
|---|
| 7855 | input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); |
|---|
| 7856 | |
|---|
| 7857 | do |
|---|
| 7858 | { |
|---|
| 7859 | enc1 = keyStr.indexOf(input.charAt(i++)); |
|---|
| 7860 | enc2 = keyStr.indexOf(input.charAt(i++)); |
|---|
| 7861 | enc3 = keyStr.indexOf(input.charAt(i++)); |
|---|
| 7862 | enc4 = keyStr.indexOf(input.charAt(i++)); |
|---|
| 7863 | |
|---|
| 7864 | chr1 = (enc1 << 2) | (enc2 >> 4); |
|---|
| 7865 | chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); |
|---|
| 7866 | chr3 = ((enc3 & 3) << 6) | enc4; |
|---|
| 7867 | |
|---|
| 7868 | output = output + String.fromCharCode(chr1); |
|---|
| 7869 | |
|---|
| 7870 | if ( enc3 != 64 ) |
|---|
| 7871 | { |
|---|
| 7872 | output = output + String.fromCharCode(chr2); |
|---|
| 7873 | } |
|---|
| 7874 | if ( enc4 != 64 ) |
|---|
| 7875 | { |
|---|
| 7876 | output = output + String.fromCharCode(chr3); |
|---|
| 7877 | } |
|---|
| 7878 | } while ( i < input.length ); |
|---|
| 7879 | |
|---|
| 7880 | return output; |
|---|
| 7881 | }; |
|---|
| 7882 | |
|---|
| 7883 | |
|---|
| 7884 | |
|---|
| 7885 | |
|---|
| 7886 | Xinha.removeFromParent = function(el) |
|---|
| 7887 | { |
|---|
| 7888 | if ( !el.parentNode ) |
|---|
| 7889 | { |
|---|
| 7890 | return; |
|---|
| 7891 | } |
|---|
| 7892 | var pN = el.parentNode; |
|---|
| 7893 | return pN.removeChild(el); |
|---|
| 7894 | }; |
|---|
| 7895 | |
|---|
| 7896 | |
|---|
| 7897 | |
|---|
| 7898 | |
|---|
| 7899 | Xinha.hasParentNode = function(el) |
|---|
| 7900 | { |
|---|
| 7901 | if ( el.parentNode ) |
|---|
| 7902 | { |
|---|
| 7903 | |
|---|
| 7904 | |
|---|
| 7905 | if ( el.parentNode.nodeType == 11 ) |
|---|
| 7906 | { |
|---|
| 7907 | return false; |
|---|
| 7908 | } |
|---|
| 7909 | return true; |
|---|
| 7910 | } |
|---|
| 7911 | |
|---|
| 7912 | return false; |
|---|
| 7913 | }; |
|---|
| 7914 | |
|---|
| 7915 | |
|---|
| 7916 | |
|---|
| 7917 | |
|---|
| 7918 | |
|---|
| 7919 | Xinha.viewportSize = function(scope) |
|---|
| 7920 | { |
|---|
| 7921 | scope = (scope) ? scope : window; |
|---|
| 7922 | var x,y; |
|---|
| 7923 | if (scope.innerHeight) |
|---|
| 7924 | { |
|---|
| 7925 | x = scope.innerWidth; |
|---|
| 7926 | y = scope.innerHeight; |
|---|
| 7927 | } |
|---|
| 7928 | else if (scope.document.documentElement && scope.document.documentElement.clientHeight) |
|---|
| 7929 | |
|---|
| 7930 | { |
|---|
| 7931 | x = scope.document.documentElement.clientWidth; |
|---|
| 7932 | y = scope.document.documentElement.clientHeight; |
|---|
| 7933 | } |
|---|
| 7934 | else if (scope.document.body) |
|---|
| 7935 | { |
|---|
| 7936 | x = scope.document.body.clientWidth; |
|---|
| 7937 | y = scope.document.body.clientHeight; |
|---|
| 7938 | } |
|---|
| 7939 | return {'x':x,'y':y}; |
|---|
| 7940 | }; |
|---|
| 7941 | |
|---|
| 7942 | |
|---|
| 7943 | |
|---|
| 7944 | |
|---|
| 7945 | Xinha.pageSize = function(scope) |
|---|
| 7946 | { |
|---|
| 7947 | scope = (scope) ? scope : window; |
|---|
| 7948 | var x,y; |
|---|
| 7949 | |
|---|
| 7950 | var test1 = scope.document.body.scrollHeight; |
|---|
| 7951 | var test2 = scope.document.documentElement.scrollHeight; |
|---|
| 7952 | |
|---|
| 7953 | if (test1 > test2) |
|---|
| 7954 | { |
|---|
| 7955 | x = scope.document.body.scrollWidth; |
|---|
| 7956 | y = scope.document.body.scrollHeight; |
|---|
| 7957 | } |
|---|
| 7958 | else |
|---|
| 7959 | { |
|---|
| 7960 | x = scope.document.documentElement.scrollWidth; |
|---|
| 7961 | y = scope.document.documentElement.scrollHeight; |
|---|
| 7962 | } |
|---|
| 7963 | return {'x':x,'y':y}; |
|---|
| 7964 | }; |
|---|
| 7965 | |
|---|
| 7966 | |
|---|
| 7967 | |
|---|
| 7968 | |
|---|
| 7969 | Xinha.prototype.scrollPos = function(scope) |
|---|
| 7970 | { |
|---|
| 7971 | scope = (scope) ? scope : window; |
|---|
| 7972 | var x,y; |
|---|
| 7973 | if (typeof scope.pageYOffset != 'undefined') |
|---|
| 7974 | { |
|---|
| 7975 | x = scope.pageXOffset; |
|---|
| 7976 | y = scope.pageYOffset; |
|---|
| 7977 | } |
|---|
| 7978 | else if (scope.document.documentElement && typeof document.documentElement.scrollTop != 'undefined') |
|---|
| 7979 | |
|---|
| 7980 | { |
|---|
| 7981 | x = scope.document.documentElement.scrollLeft; |
|---|
| 7982 | y = scope.document.documentElement.scrollTop; |
|---|
| 7983 | } |
|---|
| 7984 | else if (scope.document.body) |
|---|
| 7985 | { |
|---|
| 7986 | x = scope.document.body.scrollLeft; |
|---|
| 7987 | y = scope.document.body.scrollTop; |
|---|
| 7988 | } |
|---|
| 7989 | return {'x':x,'y':y}; |
|---|
| 7990 | }; |
|---|
| 7991 | |
|---|
| 7992 | |
|---|
| 7993 | |
|---|
| 7994 | |
|---|
| 7995 | |
|---|
| 7996 | |
|---|
| 7997 | Xinha.getElementTopLeft = function(element) |
|---|
| 7998 | { |
|---|
| 7999 | var curleft = 0; |
|---|
| 8000 | var curtop = 0; |
|---|
| 8001 | if (element.offsetParent) |
|---|
| 8002 | { |
|---|
| 8003 | curleft = element.offsetLeft; |
|---|
| 8004 | curtop = element.offsetTop; |
|---|
| 8005 | while (element = element.offsetParent) |
|---|
| 8006 | { |
|---|
| 8007 | curleft += element.offsetLeft; |
|---|
| 8008 | curtop += element.offsetTop; |
|---|
| 8009 | } |
|---|
| 8010 | } |
|---|
| 8011 | return { top:curtop, left:curleft }; |
|---|
| 8012 | }; |
|---|
| 8013 | |
|---|
| 8014 | |
|---|
| 8015 | |
|---|
| 8016 | |
|---|
| 8017 | Xinha.findPosX = function(obj) |
|---|
| 8018 | { |
|---|
| 8019 | var curleft = 0; |
|---|
| 8020 | if ( obj.offsetParent ) |
|---|
| 8021 | { |
|---|
| 8022 | return Xinha.getElementTopLeft(obj).left; |
|---|
| 8023 | } |
|---|
| 8024 | else if ( obj.x ) |
|---|
| 8025 | { |
|---|
| 8026 | curleft += obj.x; |
|---|
| 8027 | } |
|---|
| 8028 | return curleft; |
|---|
| 8029 | }; |
|---|
| 8030 | |
|---|
| 8031 | |
|---|
| 8032 | |
|---|
| 8033 | |
|---|
| 8034 | Xinha.findPosY = function(obj) |
|---|
| 8035 | { |
|---|
| 8036 | var curtop = 0; |
|---|
| 8037 | if ( obj.offsetParent ) |
|---|
| 8038 | { |
|---|
| 8039 | return Xinha.getElementTopLeft(obj).top; |
|---|
| 8040 | } |
|---|
| 8041 | else if ( obj.y ) |
|---|
| 8042 | { |
|---|
| 8043 | curtop += obj.y; |
|---|
| 8044 | } |
|---|
| 8045 | return curtop; |
|---|
| 8046 | }; |
|---|
| 8047 | |
|---|
| 8048 | Xinha.createLoadingMessages = function(xinha_editors) |
|---|
| 8049 | { |
|---|
| 8050 | if ( Xinha.loadingMessages || !Xinha.isSupportedBrowser ) |
|---|
| 8051 | { |
|---|
| 8052 | return; |
|---|
| 8053 | } |
|---|
| 8054 | Xinha.loadingMessages = []; |
|---|
| 8055 | |
|---|
| 8056 | for (var i=0;i<xinha_editors.length;i++) |
|---|
| 8057 | { |
|---|
| 8058 | if (!document.getElementById(xinha_editors[i])) |
|---|
| 8059 | { |
|---|
| 8060 | continue; |
|---|
| 8061 | } |
|---|
| 8062 | Xinha.loadingMessages.push(Xinha.createLoadingMessage(Xinha.getElementById('textarea', xinha_editors[i]))); |
|---|
| 8063 | } |
|---|
| 8064 | }; |
|---|
| 8065 | |
|---|
| 8066 | Xinha.createLoadingMessage = function(textarea,text) |
|---|
| 8067 | { |
|---|
| 8068 | if ( document.getElementById("loading_" + textarea.id) || !Xinha.isSupportedBrowser) |
|---|
| 8069 | { |
|---|
| 8070 | return; |
|---|
| 8071 | } |
|---|
| 8072 | |
|---|
| 8073 | |
|---|
| 8074 | var loading_message = document.createElement("div"); |
|---|
| 8075 | loading_message.id = "loading_" + textarea.id; |
|---|
| 8076 | loading_message.className = "loading"; |
|---|
| 8077 | |
|---|
| 8078 | loading_message.style.left = (Xinha.findPosX(textarea) + textarea.offsetWidth / 2) - 106 + 'px'; |
|---|
| 8079 | loading_message.style.top = (Xinha.findPosY(textarea) + textarea.offsetHeight / 2) - 50 + 'px'; |
|---|
| 8080 | |
|---|
| 8081 | var loading_main = document.createElement("div"); |
|---|
| 8082 | loading_main.className = "loading_main"; |
|---|
| 8083 | loading_main.id = "loading_main_" + textarea.id; |
|---|
| 8084 | loading_main.appendChild(document.createTextNode(Xinha._lc("Loading in progress. Please wait!"))); |
|---|
| 8085 | |
|---|
| 8086 | var loading_sub = document.createElement("div"); |
|---|
| 8087 | loading_sub.className = "loading_sub"; |
|---|
| 8088 | loading_sub.id = "loading_sub_" + textarea.id; |
|---|
| 8089 | text = text ? text : Xinha._lc("Loading Core"); |
|---|
| 8090 | loading_sub.appendChild(document.createTextNode(text)); |
|---|
| 8091 | loading_message.appendChild(loading_main); |
|---|
| 8092 | loading_message.appendChild(loading_sub); |
|---|
| 8093 | document.body.appendChild(loading_message); |
|---|
| 8094 | |
|---|
| 8095 | Xinha.freeLater(loading_message); |
|---|
| 8096 | Xinha.freeLater(loading_main); |
|---|
| 8097 | Xinha.freeLater(loading_sub); |
|---|
| 8098 | |
|---|
| 8099 | return loading_sub; |
|---|
| 8100 | }; |
|---|
| 8101 | |
|---|
| 8102 | Xinha.prototype.setLoadingMessage = function(subMessage, mainMessage) |
|---|
| 8103 | { |
|---|
| 8104 | if ( !document.getElementById("loading_sub_" + this._textArea.id) ) |
|---|
| 8105 | { |
|---|
| 8106 | return; |
|---|
| 8107 | } |
|---|
| 8108 | document.getElementById("loading_main_" + this._textArea.id).innerHTML = mainMessage ? mainMessage : Xinha._lc("Loading in progress. Please wait!"); |
|---|
| 8109 | document.getElementById("loading_sub_" + this._textArea.id).innerHTML = subMessage; |
|---|
| 8110 | }; |
|---|
| 8111 | |
|---|
| 8112 | Xinha.setLoadingMessage = function(string) |
|---|
| 8113 | { |
|---|
| 8114 | if (!Xinha.loadingMessages) |
|---|
| 8115 | { |
|---|
| 8116 | return; |
|---|
| 8117 | } |
|---|
| 8118 | for ( var i = 0; i < Xinha.loadingMessages.length; i++ ) |
|---|
| 8119 | { |
|---|
| 8120 | Xinha.loadingMessages[i].innerHTML = string; |
|---|
| 8121 | } |
|---|
| 8122 | }; |
|---|
| 8123 | |
|---|
| 8124 | Xinha.prototype.removeLoadingMessage = function() |
|---|
| 8125 | { |
|---|
| 8126 | if (document.getElementById("loading_" + this._textArea.id) ) |
|---|
| 8127 | { |
|---|
| 8128 | document.body.removeChild(document.getElementById("loading_" + this._textArea.id)); |
|---|
| 8129 | } |
|---|
| 8130 | }; |
|---|
| 8131 | |
|---|
| 8132 | Xinha.removeLoadingMessages = function(xinha_editors) |
|---|
| 8133 | { |
|---|
| 8134 | for (var i=0;i< xinha_editors.length;i++) |
|---|
| 8135 | { |
|---|
| 8136 | if (!document.getElementById(xinha_editors[i])) |
|---|
| 8137 | { |
|---|
| 8138 | continue; |
|---|
| 8139 | } |
|---|
| 8140 | var main = document.getElementById("loading_" + document.getElementById(xinha_editors[i]).id); |
|---|
| 8141 | main.parentNode.removeChild(main); |
|---|
| 8142 | } |
|---|
| 8143 | Xinha.loadingMessages = null; |
|---|
| 8144 | }; |
|---|
| 8145 | |
|---|
| 8146 | |
|---|
| 8147 | |
|---|
| 8148 | |
|---|
| 8149 | |
|---|
| 8150 | |
|---|
| 8151 | |
|---|
| 8152 | |
|---|
| 8153 | Xinha.toFree = []; |
|---|
| 8154 | |
|---|
| 8155 | |
|---|
| 8156 | |
|---|
| 8157 | |
|---|
| 8158 | |
|---|
| 8159 | |
|---|
| 8160 | |
|---|
| 8161 | |
|---|
| 8162 | Xinha.freeLater = function(obj,prop) |
|---|
| 8163 | { |
|---|
| 8164 | Xinha.toFree.push({o:obj,p:prop}); |
|---|
| 8165 | }; |
|---|
| 8166 | |
|---|
| 8167 | |
|---|
| 8168 | |
|---|
| 8169 | |
|---|
| 8170 | |
|---|
| 8171 | |
|---|
| 8172 | |
|---|
| 8173 | |
|---|
| 8174 | Xinha.free = function(obj, prop) |
|---|
| 8175 | { |
|---|
| 8176 | if ( obj && !prop ) |
|---|
| 8177 | { |
|---|
| 8178 | for ( var p in obj ) |
|---|
| 8179 | { |
|---|
| 8180 | Xinha.free(obj, p); |
|---|
| 8181 | } |
|---|
| 8182 | } |
|---|
| 8183 | else if ( obj ) |
|---|
| 8184 | { |
|---|
| 8185 | if ( prop.indexOf('src') == -1 ) |
|---|
| 8186 | { |
|---|
| 8187 | try { obj[prop] = null; } catch(x) {} |
|---|
| 8188 | } |
|---|
| 8189 | } |
|---|
| 8190 | }; |
|---|
| 8191 | |
|---|
| 8192 | |
|---|
| 8193 | |
|---|
| 8194 | |
|---|
| 8195 | |
|---|
| 8196 | |
|---|
| 8197 | |
|---|
| 8198 | |
|---|
| 8199 | Xinha.collectGarbageForIE = function() |
|---|
| 8200 | { |
|---|
| 8201 | Xinha.flushEvents(); |
|---|
| 8202 | for ( var x = 0; x < Xinha.toFree.length; x++ ) |
|---|
| 8203 | { |
|---|
| 8204 | Xinha.free(Xinha.toFree[x].o, Xinha.toFree[x].p); |
|---|
| 8205 | Xinha.toFree[x].o = null; |
|---|
| 8206 | } |
|---|
| 8207 | }; |
|---|
| 8208 | |
|---|
| 8209 | |
|---|
| 8210 | |
|---|
| 8211 | |
|---|
| 8212 | |
|---|
| 8213 | |
|---|
| 8214 | |
|---|
| 8215 | |
|---|
| 8216 | |
|---|
| 8217 | |
|---|
| 8218 | Xinha.prototype.insertNodeAtSelection = function(toBeInserted) { Xinha.notImplemented("insertNodeAtSelection"); }; |
|---|
| 8219 | |
|---|
| 8220 | |
|---|
| 8221 | |
|---|
| 8222 | |
|---|
| 8223 | |
|---|
| 8224 | |
|---|
| 8225 | Xinha.prototype.getParentElement = function(sel) { Xinha.notImplemented("getParentElement"); }; |
|---|
| 8226 | |
|---|
| 8227 | |
|---|
| 8228 | |
|---|
| 8229 | |
|---|
| 8230 | |
|---|
| 8231 | |
|---|
| 8232 | |
|---|
| 8233 | |
|---|
| 8234 | |
|---|
| 8235 | Xinha.prototype.activeElement = function(sel) { Xinha.notImplemented("activeElement"); }; |
|---|
| 8236 | |
|---|
| 8237 | |
|---|
| 8238 | |
|---|
| 8239 | |
|---|
| 8240 | |
|---|
| 8241 | |
|---|
| 8242 | |
|---|
| 8243 | Xinha.prototype.selectionEmpty = function(sel) { Xinha.notImplemented("selectionEmpty"); }; |
|---|
| 8244 | |
|---|
| 8245 | |
|---|
| 8246 | |
|---|
| 8247 | |
|---|
| 8248 | |
|---|
| 8249 | |
|---|
| 8250 | Xinha.prototype.saveSelection = function() { Xinha.notImplemented("saveSelection"); }; |
|---|
| 8251 | |
|---|
| 8252 | |
|---|
| 8253 | |
|---|
| 8254 | |
|---|
| 8255 | Xinha.prototype.restoreSelection = function(savedSelection) { Xinha.notImplemented("restoreSelection"); }; |
|---|
| 8256 | |
|---|
| 8257 | |
|---|
| 8258 | |
|---|
| 8259 | |
|---|
| 8260 | |
|---|
| 8261 | |
|---|
| 8262 | |
|---|
| 8263 | |
|---|
| 8264 | Xinha.prototype.selectNodeContents = function(node,pos) { Xinha.notImplemented("selectNodeContents"); }; |
|---|
| 8265 | |
|---|
| 8266 | |
|---|
| 8267 | |
|---|
| 8268 | |
|---|
| 8269 | |
|---|
| 8270 | |
|---|
| 8271 | Xinha.prototype.insertHTML = function(html) { Xinha.notImplemented("insertHTML"); }; |
|---|
| 8272 | |
|---|
| 8273 | |
|---|
| 8274 | |
|---|
| 8275 | |
|---|
| 8276 | |
|---|
| 8277 | Xinha.prototype.getSelectedHTML = function() { Xinha.notImplemented("getSelectedHTML"); }; |
|---|
| 8278 | |
|---|
| 8279 | |
|---|
| 8280 | |
|---|
| 8281 | |
|---|
| 8282 | |
|---|
| 8283 | |
|---|
| 8284 | Xinha.prototype.getSelection = function() { Xinha.notImplemented("getSelection"); }; |
|---|
| 8285 | |
|---|
| 8286 | |
|---|
| 8287 | |
|---|
| 8288 | |
|---|
| 8289 | |
|---|
| 8290 | |
|---|
| 8291 | Xinha.prototype.createRange = function(sel) { Xinha.notImplemented("createRange"); }; |
|---|
| 8292 | |
|---|
| 8293 | |
|---|
| 8294 | |
|---|
| 8295 | |
|---|
| 8296 | |
|---|
| 8297 | |
|---|
| 8298 | |
|---|
| 8299 | Xinha.prototype.isKeyEvent = function(event) { Xinha.notImplemented("isKeyEvent"); }; |
|---|
| 8300 | |
|---|
| 8301 | |
|---|
| 8302 | |
|---|
| 8303 | |
|---|
| 8304 | |
|---|
| 8305 | |
|---|
| 8306 | |
|---|
| 8307 | |
|---|
| 8308 | Xinha.prototype.isShortCut = function(keyEvent) |
|---|
| 8309 | { |
|---|
| 8310 | if(keyEvent.ctrlKey && !keyEvent.altKey) |
|---|
| 8311 | { |
|---|
| 8312 | return true; |
|---|
| 8313 | } |
|---|
| 8314 | |
|---|
| 8315 | return false; |
|---|
| 8316 | }; |
|---|
| 8317 | |
|---|
| 8318 | |
|---|
| 8319 | |
|---|
| 8320 | |
|---|
| 8321 | |
|---|
| 8322 | |
|---|
| 8323 | |
|---|
| 8324 | |
|---|
| 8325 | Xinha.prototype.getKey = function(keyEvent) { Xinha.notImplemented("getKey"); }; |
|---|
| 8326 | |
|---|
| 8327 | |
|---|
| 8328 | |
|---|
| 8329 | |
|---|
| 8330 | |
|---|
| 8331 | |
|---|
| 8332 | |
|---|
| 8333 | Xinha.getOuterHTML = function(element) { Xinha.notImplemented("getOuterHTML"); }; |
|---|
| 8334 | |
|---|
| 8335 | |
|---|
| 8336 | |
|---|
| 8337 | |
|---|
| 8338 | |
|---|
| 8339 | |
|---|
| 8340 | Xinha.getXMLHTTPRequestObject = function() |
|---|
| 8341 | { |
|---|
| 8342 | try |
|---|
| 8343 | { |
|---|
| 8344 | if (typeof XMLHttpRequest != "undefined" && typeof XMLHttpRequest.constructor == 'function' ) |
|---|
| 8345 | { |
|---|
| 8346 | return new XMLHttpRequest(); |
|---|
| 8347 | } |
|---|
| 8348 | else if (typeof ActiveXObject == "function") |
|---|
| 8349 | { |
|---|
| 8350 | return new ActiveXObject("Microsoft.XMLHTTP"); |
|---|
| 8351 | } |
|---|
| 8352 | } |
|---|
| 8353 | catch(e) |
|---|
| 8354 | { |
|---|
| 8355 | Xinha.notImplemented('getXMLHTTPRequestObject'); |
|---|
| 8356 | } |
|---|
| 8357 | }; |
|---|
| 8358 | |
|---|
| 8359 | |
|---|
| 8360 | |
|---|
| 8361 | |
|---|
| 8362 | |
|---|
| 8363 | |
|---|
| 8364 | |
|---|
| 8365 | Xinha.prototype._activeElement = function(sel) { return this.activeElement(sel); }; |
|---|
| 8366 | |
|---|
| 8367 | |
|---|
| 8368 | |
|---|
| 8369 | |
|---|
| 8370 | |
|---|
| 8371 | |
|---|
| 8372 | Xinha.prototype._selectionEmpty = function(sel) { return this.selectionEmpty(sel); }; |
|---|
| 8373 | |
|---|
| 8374 | |
|---|
| 8375 | |
|---|
| 8376 | |
|---|
| 8377 | |
|---|
| 8378 | Xinha.prototype._getSelection = function() { return this.getSelection(); }; |
|---|
| 8379 | |
|---|
| 8380 | |
|---|
| 8381 | |
|---|
| 8382 | |
|---|
| 8383 | |
|---|
| 8384 | |
|---|
| 8385 | Xinha.prototype._createRange = function(sel) { return this.createRange(sel); }; |
|---|
| 8386 | HTMLArea = Xinha; |
|---|
| 8387 | |
|---|
| 8388 | |
|---|
| 8389 | Xinha.init(); |
|---|
| 8390 | |
|---|
| 8391 | if ( Xinha.ie_version < 8 ) |
|---|
| 8392 | { |
|---|
| 8393 | Xinha.addDom0Event(window,'unload',Xinha.collectGarbageForIE); |
|---|
| 8394 | } |
|---|
| 8395 | |
|---|
| 8396 | |
|---|
| 8397 | |
|---|
| 8398 | |
|---|
| 8399 | |
|---|
| 8400 | Xinha.debugMsg = function(text, level) |
|---|
| 8401 | { |
|---|
| 8402 | if (typeof console != 'undefined' && typeof console.log == 'function') |
|---|
| 8403 | { |
|---|
| 8404 | if (level && level == 'warn' && typeof console.warn == 'function') |
|---|
| 8405 | { |
|---|
| 8406 | console.warn(text); |
|---|
| 8407 | } |
|---|
| 8408 | else |
|---|
| 8409 | if (level && level == 'info' && typeof console.info == 'function') |
|---|
| 8410 | { |
|---|
| 8411 | console.info(text); |
|---|
| 8412 | } |
|---|
| 8413 | else |
|---|
| 8414 | { |
|---|
| 8415 | console.log(text); |
|---|
| 8416 | } |
|---|
| 8417 | } |
|---|
| 8418 | else if (typeof opera != 'undefined' && typeof opera.postError == 'function') |
|---|
| 8419 | { |
|---|
| 8420 | opera.postError(text); |
|---|
| 8421 | } |
|---|
| 8422 | }; |
|---|
| 8423 | Xinha.notImplemented = function(methodName) |
|---|
| 8424 | { |
|---|
| 8425 | throw new Error("Method Not Implemented", "Part of Xinha has tried to call the " + methodName + " method which has not been implemented."); |
|---|
| 8426 | }; |
|---|