Changeset 1011
- Timestamp:
- 06/07/08 09:08:53 (4 months ago)
- Location:
- branches/new-dialogs-merge
- Files:
-
- 10 modified
- 2 copied
-
XinhaCore.js (modified) (1 diff)
-
modules/CreateLink/link.js (modified) (2 diffs)
-
modules/CreateLink/pluginMethods.js (modified) (1 diff)
-
modules/InsertImage/insert_image.js (modified) (2 diffs)
-
modules/InsertImage/pluginMethods.js (modified) (2 diffs)
-
modules/InsertTable/insert_table.js (modified) (3 diffs)
-
modules/InsertTable/pluginMethods.js (modified) (1 diff)
-
plugins/Linker/linker.js (modified) (1 diff)
-
plugins/Linker/pluginMethods.js (copied) (copied from branches/new-dialogs-merge/plugins/Linker/linker.js) (5 diffs)
-
plugins/PasteText/paste-text.js (modified) (3 diffs)
-
plugins/SuperClean/pluginMethods.js (copied) (copied from branches/new-dialogs-merge/plugins/SuperClean/super-clean.js) (13 diffs)
-
plugins/SuperClean/super-clean.js (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/new-dialogs-merge/XinhaCore.js
r1010 r1011 6799 6799 scope = (scope) ? scope : window; 6800 6800 var x,y; 6801 if ( scope.pageYOffset) // all except Explorer6801 if (typeof scope.pageYOffset != 'undefined') // all except Explorer 6802 6802 { 6803 6803 x = scope.pageXOffset; 6804 6804 y = scope.pageYOffset; 6805 6805 } 6806 else if (scope.document.documentElement && document.documentElement.scrollTop)6806 else if (scope.document.documentElement && typeof document.documentElement.scrollTop != 'undefined') 6807 6807 // Explorer 6 Strict 6808 6808 { -
branches/new-dialogs-merge/modules/CreateLink/link.js
r1009 r1011 50 50 CreateLink.prototype.onGenerateOnce = function() 51 51 { 52 this.prepareDialog(); 53 this.loadScripts(); 52 CreateLink.loadAssets(); 54 53 }; 55 54 56 CreateLink. prototype.loadScripts = function()55 CreateLink.loadAssets = function() 57 56 { 58 var self = this; 59 if(!this.methodsReady) 60 { 61 Xinha._getback(_editor_url + 'modules/CreateLink/pluginMethods.js', function(getback) { eval(getback); self.methodsReady = true; }); 62 return; 63 } 64 }; 57 var self = CreateLink; 58 if (self.loading) return; 59 self.loading = true; 60 Xinha._getback(_editor_url + 'modules/CreateLink/dialog.html', function(getback) { self.html = getback; self.dialogReady = true; }); 61 Xinha._getback(_editor_url + 'modules/CreateLink/pluginMethods.js', function(getback) { eval(getback); self.methodsReady = true; }); 62 } 65 63 66 64 CreateLink.prototype.onUpdateToolbar = function() 67 65 { 68 if (!(this.dialogReady && this.methodsReady))66 if (!(CreateLink.dialogReady && CreateLink.methodsReady)) 69 67 { 70 this.editor._toolbarObjects.createlink.state("enabled", false);68 this.editor._toolbarObjects.createlink.state("enabled", false); 71 69 } 70 else this.onUpdateToolbar = null; 72 71 }; 73 72 … … 77 76 var editor = this.editor; 78 77 79 if(!this.html) // retrieve the raw dialog contents 80 { 81 Xinha._getback(_editor_url + 'modules/CreateLink/dialog.html', function(getback) { self.html = getback; self.prepareDialog(); }); 82 return; 83 } 84 85 // Now we have everything we need, so we can build the dialog. 86 87 var dialog = this.dialog = new Xinha.Dialog(editor, this.html, 'Xinha',{width:400}) 78 var dialog = this.dialog = new Xinha.Dialog(editor, CreateLink.html, 'Xinha',{width:400}) 88 79 // Connect the OK and Cancel buttons 89 80 dialog.getElementById('ok').onclick = function() {self.apply();} -
branches/new-dialogs-merge/modules/CreateLink/pluginMethods.js
r1008 r1011 2 2 CreateLink.prototype.show = function(a) 3 3 { 4 if (!this.dialog) 5 { 6 this.prepareDialog(); 7 } 4 8 var editor = this.editor; 5 9 this.a = a; -
branches/new-dialogs-merge/modules/InsertImage/insert_image.js
r1008 r1011 46 46 InsertImage.prototype.onGenerateOnce = function() 47 47 { 48 this.prepareDialog(); 49 this.loadScripts(); 48 InsertImage.loadAssets(); 50 49 }; 51 50 52 InsertImage. prototype.loadScripts = function()51 InsertImage.loadAssets = function() 53 52 { 54 var self = this; 55 if(!this.methodsReady) 56 { 57 Xinha._getback(_editor_url + 'modules/InsertImage/pluginMethods.js', function(getback) { eval(getback); self.methodsReady = true; }); 58 return; 59 } 53 var self = InsertImage; 54 if (self.loading) return; 55 self.loading = true; 56 Xinha._getback(_editor_url + 'modules/InsertImage/dialog.html', function(getback) { self.html = getback; self.dialogReady = true; }); 57 Xinha._getback(_editor_url + 'modules/InsertImage/pluginMethods.js', function(getback) { eval(getback); self.methodsReady = true; }); 60 58 }; 61 62 59 InsertImage.prototype.onUpdateToolbar = function() 63 60 { 64 if (!( this.dialogReady && this.methodsReady))61 if (!(InsertImage.dialogReady && InsertImage.methodsReady)) 65 62 { 66 63 this.editor._toolbarObjects.insertimage.state("enabled", false); 67 64 } 65 else this.onUpdateToolbar = null; 68 66 }; 69 67 … … 73 71 var editor = this.editor; 74 72 75 if(!this.html) // retrieve the raw dialog contents 76 { 77 Xinha._getback(_editor_url + 'modules/InsertImage/dialog.html', function(getback) { self.html = getback; self.prepareDialog(); }); 78 return; 79 } 80 81 // Now we have everything we need, so we can build the dialog. 82 83 var dialog = this.dialog = new Xinha.Dialog(editor, this.html, 'Xinha',{width:410}) 73 var dialog = this.dialog = new Xinha.Dialog(editor, InsertImage.html, 'Xinha',{width:410}) 84 74 // Connect the OK and Cancel buttons 85 75 dialog.getElementById('ok').onclick = function() {self.apply();} -
branches/new-dialogs-merge/modules/InsertImage/pluginMethods.js
r1008 r1011 1 1 InsertImage.prototype.show = function(image) 2 2 { 3 var editor = this.editor; 3 if (!this.dialog) this.prepareDialog(); 4 5 var editor = this.editor; 4 6 if ( typeof image == "undefined" ) 5 7 { … … 60 62 InsertImage.prototype.apply = function() 61 63 { 62 63 64 var param = this.dialog.hide(); 64 65 if (!param.f_url) -
branches/new-dialogs-merge/modules/InsertTable/insert_table.js
r1008 r1011 37 37 var self = this; 38 38 39 editor.config.btnList.inserttable[3] = function() { self.show(); }39 editor.config.btnList.inserttable[3] = function() { self.show(); } 40 40 } 41 41 … … 47 47 InsertTable.prototype.onGenerateOnce = function() 48 48 { 49 this.prepareDialog(); 50 this.loadScripts(); 49 InsertTable.loadAssets(); 51 50 }; 52 53 InsertTable.prototype.loadScripts = function() 51 InsertTable.loadAssets = function() 54 52 { 55 var self = this; 56 if(!this.methodsReady) 57 { 58 Xinha._getback(_editor_url + 'modules/InsertTable/pluginMethods.js', function(getback) { eval(getback); self.methodsReady = true; }); 59 return; 60 } 53 var self = InsertTable; 54 if (self.loading) return; 55 self.loading = true; 56 Xinha._getback(_editor_url + 'modules/InsertTable/dialog.html', function(getback) { self.html = getback; self.dialogReady = true; }); 57 Xinha._getback(_editor_url + 'modules/InsertTable/pluginMethods.js', function(getback) { eval(getback); self.methodsReady = true; }); 61 58 }; 62 59 63 60 InsertTable.prototype.onUpdateToolbar = function() 64 61 { 65 if (!( this.dialogReady && this.methodsReady))62 if (!(InsertTable.dialogReady && InsertTable.methodsReady)) 66 63 { 67 64 this.editor._toolbarObjects.inserttable.state("enabled", false); 68 65 } 66 else this.onUpdateToolbar = null; 69 67 }; 70 68 … … 74 72 var editor = this.editor; 75 73 76 if(!this.html) // retrieve the raw dialog contents 77 { 78 Xinha._getback(_editor_url + 'modules/InsertTable/dialog.html', function(getback) { self.html = getback; self.prepareDialog(); }); 79 return; 80 } 81 82 // Now we have everything we need, so we can build the dialog. 83 84 var dialog = this.dialog = new Xinha.Dialog(editor, this.html, 'Xinha',{width:400}) 74 var dialog = this.dialog = new Xinha.Dialog(editor, InsertTable.html, 'Xinha',{width:400}) 85 75 // Connect the OK and Cancel buttons 86 76 dialog.getElementById('ok').onclick = function() {self.apply();} -
branches/new-dialogs-merge/modules/InsertTable/pluginMethods.js
r1008 r1011 1 1 InsertTable.prototype.show = function(image) 2 2 { 3 var editor = this.editor; 3 if (!this.dialog) this.prepareDialog(); 4 5 var editor = this.editor; 4 6 5 7 var values = -
branches/new-dialogs-merge/plugins/Linker/linker.js
r1007 r1011 51 51 }; 52 52 53 Linker.prototype._createLink = function(a)54 {55 if(!a && this.editor.selectionEmpty(this.editor.getSelection()))56 {57 alert(this._lc("You must select some text before making a new link."));58 return false;59 }60 61 var inputs =62 {63 type: 'url',64 href: 'http://www.example.com/',65 target: '',66 p_width: '',67 p_height: '',68 p_options: ['menubar=no','toolbar=yes','location=no','status=no','scrollbars=yes','resizeable=yes'],69 to: 'alice@example.com',70 subject: '',71 body: '',72 anchor: ''73 };74 75 if(a && a.tagName.toLowerCase() == 'a')76 {77 var href =this.editor.fixRelativeLinks(a.getAttribute('href'));78 var m = href.match(/^mailto:(.*@[^?&]*)(\?(.*))?$/);79 var anchor = href.match(/^#(.*)$/);80 81 if(m)82 {83 // Mailto84 inputs.type = 'mailto';85 inputs.to = m[1];86 if(m[3])87 {88 var args = m[3].split('&');89 for(var x = 0; x<args.length; x++)90 {91 var j = args[x].match(/(subject|body)=(.*)/);92 if(j)93 {94 inputs[j[1]] = decodeURIComponent(j[2]);95 }96 }97 }98 }99 else if (anchor)100 {101 //Anchor-Link102 inputs.type = 'anchor';103 inputs.anchor = anchor[1];104 105 }106 else107 {108 109 110 if(a.getAttribute('onclick'))111 {112 var m = a.getAttribute('onclick').match(/window\.open\(\s*this\.href\s*,\s*'([a-z0-9_]*)'\s*,\s*'([a-z0-9_=,]*)'\s*\)/i);113 114 // Popup Window115 inputs.href = href ? href : '';116 inputs.target = 'popup';117 inputs.p_name = m[1];118 inputs.p_options = [ ];119 120 121 var args = m[2].split(',');122 for(var x = 0; x < args.length; x++)123 {124 var i = args[x].match(/(width|height)=([0-9]+)/);125 if(i)126 {127 inputs['p_' + i[1]] = parseInt(i[2]);128 }129 else130 {131 inputs.p_options.push(args[x]);132 }133 }134 }135 else136 {137 // Normal138 inputs.href = href;139 inputs.target = a.target;140 }141 }142 }143 144 var linker = this;145 146 // If we are not editing a link, then we need to insert links now using execCommand147 // because for some reason IE is losing the selection between now and when doOK is148 // complete. I guess because we are defocusing the iframe when we click stuff in the149 // linker dialog.150 151 this.a = a; // Why doesn't a get into the closure below, but if I set it as a property then it's fine?152 153 var doOK = function()154 {155 //if(linker.a) alert(linker.a.tagName);156 var a = linker.a;157 158 var values = linker._dialog.hide();159 var atr =160 {161 href: '',162 target:'',163 title:'',164 onclick:''165 };166 167 if(values.type == 'url')168 {169 if(values.href)170 {171 atr.href = values.href;172 atr.target = values.target;173 if(values.target == 'popup')174 {175 176 if(values.p_width)177 {178 values.p_options.push('width=' + values.p_width);179 }180 if(values.p_height)181 {182 values.p_options.push('height=' + values.p_height);183 }184 atr.onclick = 'if(window.parent && window.parent.Xinha){return false}window.open(this.href, \'' + (values.p_name.replace(/[^a-z0-9_]/i, '_')) + '\', \'' + values.p_options.join(',') + '\');return false;';185 }186 }187 }188 else if(values.type == 'anchor')189 {190 if(values.anchor)191 {192 atr.href = values.anchor.value;193 }194 }195 else196 {197 if(values.to)198 {199 atr.href = 'mailto:' + values.to;200 if(values.subject) atr.href += '?subject=' + encodeURIComponent(values.subject);201 if(values.body) atr.href += (values.subject ? '&' : '?') + 'body=' + encodeURIComponent(values.body);202 }203 }204 205 if(a && a.tagName.toLowerCase() == 'a')206 {207 if(!atr.href)208 {209 if(confirm(linker._dialog._lc('Are you sure you wish to remove this link?')))210 {211 var p = a.parentNode;212 while(a.hasChildNodes())213 {214 p.insertBefore(a.removeChild(a.childNodes[0]), a);215 }216 p.removeChild(a);217 linker.editor.updateToolbar();218 return;219 }220 }221 else222 {223 // Update the link224 for(var i in atr)225 {226 a.setAttribute(i, atr[i]);227 }228 229 // If we change a mailto link in IE for some hitherto unknown230 // reason it sets the innerHTML of the link to be the231 // href of the link. Stupid IE.232 if(Xinha.is_ie)233 {234 if(/mailto:([^?<>]*)(\?[^<]*)?$/i.test(a.innerHTML))235 {236 a.innerHTML = RegExp.$1;237 }238 }239 }240 }241 else242 {243 if(!atr.href) return true;244 245 // Insert a link, we let the browser do this, we figure it knows best246 var tmp = Xinha.uniq('http://www.example.com/Link');247 linker.editor._doc.execCommand('createlink', false, tmp);248 249 // Fix them up250 var anchors = linker.editor._doc.getElementsByTagName('a');251 for(var i = 0; i < anchors.length; i++)252 {253 var anchor = anchors[i];254 if(anchor.href == tmp)255 {256 // Found one.257 if (!a) a = anchor;258 for(var j in atr)259 {260 anchor.setAttribute(j, atr[j]);261 }262 }263 }264 }265 linker.editor.selectNodeContents(a);266 linker.editor.updateToolbar();267 };268 269 this._dialog.show(inputs, doOK);270 271 };272 273 Linker.prototype._getSelectedAnchor = function()274 {275 var sel = this.editor.getSelection();276 var rng = this.editor.createRange(sel);277 var a = this.editor.activeElement(sel);278 if(a != null && a.tagName.toLowerCase() == 'a')279 {280 return a;281 }282 else283 {284 a = this.editor._getFirstAncestor(sel, 'a');285 if(a != null)286 {287 return a;288 }289 }290 return null;291 };292 53 293 54 Linker.prototype.onGenerateOnce = function() 294 55 { 295 this._dialog = new Linker.Dialog(this); 56 Linker.loadAssets(); 57 this.loadFiles(); 296 58 }; 297 // Inline Dialog for Linker 59 60 Linker.prototype.onUpdateToolbar = function() 61 { 62 if (typeof dTree == 'undefined' || !Linker.methodsReady || !Linker.html || !this.files) 63 { 64 this.editor._toolbarObjects.createlink.state("enabled", false); 65 } 66 else this.onUpdateToolbar = null; 67 }; 298 68 299 69 Linker.Dialog_dTrees = [ ]; 300 70 71 Linker.loadAssets = function() 72 { 73 var self = Linker; 74 if (self.loading) return; 75 self.loading = true; 76 Xinha._getback(Xinha.getPluginDir("Linker") + '/pluginMethods.js', function(getback) { eval(getback); self.methodsReady = true; }); 77 Xinha._loadback( Xinha.getPluginDir("Linker") + '/dTree/dtree.js', function() {Linker.dTreeReady = true; } ); 78 Xinha._getback( Xinha.getPluginDir("Linker") + '/dialog.html', function(getback) { self.html = getback; } ); 79 } 301 80 302 Linker. Dialog = function (linker)81 Linker.prototype.loadFiles = function() 303 82 { 304 var lDialog = this; 305 this.Dialog_nxtid = 0; 306 this.linker = linker; 307 this.id = { }; // This will be filled below with a replace, nifty 308 309 this.ready = false; 310 this.files = false; 311 this.html = false; 312 this.dialog = false; 313 314 // load the dTree script 315 this._prepareDialog(); 316 317 }; 318 319 Linker.Dialog.prototype._prepareDialog = function() 320 { 321 var lDialog = this; 322 var linker = this.linker; 323 324 // We load some stuff up int he background, recalling this function 325 // when they have loaded. This is to keep the editor responsive while 326 // we prepare the dialog. 327 if(typeof dTree == 'undefined') 328 { 329 this.linker.editor.setLoadingMessage('Loading Tree script'); 330 Xinha._loadback(Xinha.getPluginDir("Linker") + '/dTree/dtree.js', 331 function() {lDialog._prepareDialog(); } 332 ); 333 return; 334 } 335 336 if(this.files === false) 337 { 83 var linker = this; 338 84 if(linker.lConfig.backend) 339 85 { 340 86 //get files from backend 341 this.linker.editor.setLoadingMessage('Loading files from backend');342 87 Xinha._postback(linker.lConfig.backend, 343 88 linker.lConfig.backend_data, 344 89 function(txt) { 345 90 try { 346 l Dialog.files = eval(txt);91 linker.files = eval(txt); 347 92 } catch(Error) { 348 l Dialog.files = [ {url:'',title:Error.toString()} ];93 linker.files = [ {url:'',title:Error.toString()} ]; 349 94 } 350 lDialog._prepareDialog();});95 }); 351 96 } 352 97 else if(linker.lConfig.files != null) 353 98 { 354 99 //get files from plugin-config 355 lDialog.files = linker.lConfig.files; 356 lDialog._prepareDialog(); 100 linker.files = linker.lConfig.files; 357 101 } 358 return; 359 } 360 var files = this.files; 361 362 if(this.html == false) 363 { 364 Xinha._getback(Xinha.getPluginDir("Linker") + '/dialog.html', function(txt) { lDialog.html = txt; lDialog._prepareDialog(); }); 365 return; 366 } 367 var html = this.html; 368 369 // Now we have everything we need, so we can build the dialog. 370 var dialog = this.dialog = new Xinha.Dialog(linker.editor, this.html, 'Linker',{width:600,height:400}); 371 var dTreeName = Xinha.uniq('dTree_'); 372 373 this.dTree = new dTree(dTreeName, Xinha.getPluginDir("Linker") + '/dTree/'); 374 eval(dTreeName + ' = this.dTree'); 375 376 this.dTree.add(this.Dialog_nxtid++, -1, linker.lConfig.treeCaption , null, linker.lConfig.treeCaption); 377 this.makeNodes(files, 0); 378 379 // Put it in 380 var ddTree = this.dialog.getElementById('dTree'); 381 //ddTree.innerHTML = this.dTree.toString(); 382 ddTree.innerHTML = ''; 383 // ddTree.style.position = 'absolute'; 384 // ddTree.style.left = 1 + 'px'; 385 // ddTree.style.top = 0 + 'px'; 386 ddTree.style.overflow = 'auto'; 387 ddTree.style.height = '300px'; 388 if ( Xinha.is_ie ) 389 { 390 ddTree.style.styleFloat = "left"; 391 } 392 else 393 { 394 ddTree.style.cssFloat = "left"; 395 } 396 ddTree.style.backgroundColor = 'white'; 397 this.ddTree = ddTree; 398 399 this.dTree._linker_premade = this.dTree.toString(); 400 401 var options = this.dialog.getElementById('options'); 402 //options.style.position = 'absolute'; 403 //options.style.top = 0 + 'px'; 404 //options.style.right = 0 + 'px'; 405 options.style.width = 320 + 'px'; 406 options.style.overflow = 'auto'; 407 408 // Hookup the resizer 409 this.dialog.rootElem.style.paddingBottom ="0"; 410 this.dialog.onresize = function() 411 { 412 var h = parseInt(dialog.height) - dialog.getElementById('h1').offsetHeight; 413 var w = parseInt(dialog.width) - 330 ; 414 415 // An error is thrown with IE when trying to set a negative width or a negative height 416 // But perhaps a width / height of 0 is not the minimum required we need to set 417 if (w<0) w = 0; 418 if (h<0) h = 0; 419 //options.style.height = 420 lDialog.ddTree.style.height = h + 'px'; 421 lDialog.ddTree.style.width = w + 'px'; 422 } 423 this.ready = true; 424 ddTree = null; 425 Xinha.freeLater(lDialog, 'ddTree'); 426 options = null; 427 }; 428 429 Linker.Dialog.prototype.makeNodes = function(files, parent) 430 { 431 for(var i = 0; i < files.length; i++) 432 { 433 if(typeof files[i] == 'string') 434 { 435 this.dTree.add(Linker.nxtid++, parent, 436 files[i].replace(/^.*\//, ''), 437 'javascript:document.getElementsByName(\'' + this.dialog.id.href + '\')[0].value=decodeURIComponent(\'' + encodeURIComponent(files[i]) + '\');document.getElementsByName(\'' + this.dialog.id.type + '\')[0].click();document.getElementsByName(\'' + this.dialog.id.href + '\')[0].focus();void(0);', 438 files[i]); 439 } 440 else if(typeof files[i]=="object" && files[i] && typeof files[i].length==="number") // there seems to be a strange bug in IE that requires this complicated check, see #1197 441 { 442 var id = this.Dialog_nxtid++; 443 this.dTree.add(id, parent, files[i][0].replace(/^.*\//, ''), null, files[i][0]); 444 this.makeNodes(files[i][1], id); 445 } 446 else if(typeof files[i] == 'object') 447 { 448 if(files[i].children) { 449 var id = this.Dialog_nxtid++; 450 } else { 451 var id = Linker.nxtid++; 452 } 453 454 if(files[i].title) var title = files[i].title; 455 else if(files[i].url) var title = files[i].url.replace(/^.*\//, ''); 456 else var title = "no title defined"; 457 if(files[i].url) var link = 'javascript:document.getElementsByName(\'' + this.dialog.id.href + '\')[0].value=decodeURIComponent(\'' + encodeURIComponent(files[i].url) + '\');document.getElementsByName(\'' + this.dialog.id.type + '\')[0].click();document.getElementsByName(\'' + this.dialog.id.href + '\')[0].focus();void(0);'; 458 else var link = ''; 459 460 this.dTree.add(id, parent, title, link, title); 461 if(files[i].children) { 462 this.makeNodes(files[i].children, id); 463 } 464 } 465 } 466 }; 467 468 Linker.Dialog.prototype._lc = Linker.prototype._lc; 469 470 Linker.Dialog.prototype.show = function(inputs, ok, cancel) 471 { 472 if(!this.ready) 473 { 474 var lDialog = this; 475 window.setTimeout(function() {lDialog.show(inputs,ok,cancel);},100); 476 return; 477 } 478 479 if(this.ddTree.innerHTML == '') 480 { 481 this.ddTree.innerHTML = this.dTree._linker_premade; 482 } 483 484 if(inputs.type=='url') 485 { 486 this.dialog.getElementById('urltable').sty
