Changeset 3
- Timestamp:
- 02/13/05 07:38:04 (8 years ago)
- Location:
- trunk/plugins/Linker
- Files:
-
- 2 modified
-
dTree/dtree.js (modified) (3 diffs)
-
linker.js (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/plugins/Linker/dTree/dtree.js
r1 r3 162 162 163 163 dTree.prototype.toString = function() { 164 164 this.setCS_All(); 165 165 var str = '<div class="dtree">\n'; 166 166 … … 205 205 cn._ai = n; 206 206 207 this.setCS(cn);207 // this.setCS(cn); 208 208 209 209 if (!cn.target && this.config.target) cn.target = this.config.target; … … 359 359 }; 360 360 361 361 dTree.prototype.setCS_All = function() 362 { 363 var ids = { }; // ID => { _hc: haschildren, _ls_is: lastsibling} 364 365 for(var n = 0; n < this.aNodes.length; n++) 366 { 367 var node = this.aNodes[n]; 368 if(!ids[node.pid]) 369 { 370 ids[node.pid] = { _hc: true, _ls_is: node.id }; 371 } 372 else 373 { 374 ids[node.pid]._hc = true; 375 ids[node.pid]._ls_is = node.id; 376 } 377 378 if(!ids[node.id]) 379 { 380 ids[node.id] = { _hc: false, _ls_is: null } 381 } 382 } 383 384 for(var n = 0; n < this.aNodes.length; n++) 385 { 386 var node = this.aNodes[n]; 387 node._ls = ids[node.pid]._ls_is == node.id ? true : false; 388 node._hc = ids[node.id]._hc; 389 } 390 } 362 391 363 392 // Returns the selected node -
trunk/plugins/Linker/linker.js
r1 r3 19 19 } 20 20 21 21 22 function Linker(editor, args) 22 23 { … … 25 26 26 27 var linker = this; 27 editor.config.registerButton( 28 'linker', 'Insert/Modify Hyperlink', [_editor_url + "images/ed_buttons_main.gif",6,1], false, 29 function(e, objname, obj) { linker._createLink(linker._getSelectedAnchor()); } 30 ); 31 32 // See if we can find 'insertlink' and replace it with superclean 28 if(editor.config.btnList.createlink) 29 { 30 editor.config.btnList.createlink[3] 31 = function(e, objname, obj) { linker._createLink(linker._getSelectedAnchor()); }; 32 } 33 else 34 { 35 editor.config.registerButton( 36 'createlink', 'Insert/Modify Hyperlink', [_editor_url + "images/ed_buttons_main.gif",6,1], false, 37 function(e, objname, obj) { linker._createLink(linker._getSelectedAnchor()); } 38 ); 39 } 40 41 // See if we can find 'createlink' 33 42 var t = editor.config.toolbar; 34 43 var done = false; … … 39 48 if(t[i][x] == 'createlink') 40 49 { 41 t[i][x] = 'linker';42 50 done = true; 43 51 } … … 47 55 if(!done) 48 56 { 49 t[t.length-1].push(' linker');57 t[t.length-1].push('createlink'); 50 58 } 51 59 } … … 53 61 Linker.prototype._createLink = function(a) 54 62 { 55 56 if(!this._dialog)57 {58 this._dialog = new Linker.Dialog(this);59 }60 63 61 64 var inputs = … … 246 249 } 247 250 248 251 Linker.prototype.onGenerate = function() 252 { 253 this._dialog = new Linker.Dialog(this); 254 } 249 255 // Inline Dialog for Linker 250 256 … … 260 266 261 267 this.ready = false; 268 this.files = false; 269 this.html = false; 270 this.dialog = false; 262 271 263 272 // load the dTree script 264 if(typeof dTree == 'undefined') 265 { 266 HTMLArea._loadback(_editor_url + 'plugins/Linker/dTree/dtree.js', 267 function() {lDialog._prepareDialog(); lDialog.ready = true; } 268 ); 269 } 270 else 271 { 272 lDialog._prepareDialog(); 273 lDialog.ready = true; 274 } 273 this._prepareDialog(); 274 275 275 } 276 276 277 277 Linker.Dialog.prototype._prepareDialog = function() 278 278 { 279 280 279 var lDialog = this; 281 280 var linker = this.linker; 282 var html = HTMLArea._geturlcontent(_editor_url + 'plugins/Linker/dialog.html'); 283 var dialog = this.dialog = new HTMLArea.Dialog(linker.editor, html, 'Linker'); 284 285 // Make a dtree 286 var files = HTMLArea._geturlcontent(linker.lConfig.backend); 287 288 files = eval(files); 289 281 282 // We load some stuff up int he background, recalling this function 283 // when they have loaded. This is to keep the editor responsive while 284 // we prepare the dialog. 285 if(typeof dTree == 'undefined') 286 { 287 HTMLArea._loadback(_editor_url + 'plugins/Linker/dTree/dtree.js', 288 function() {lDialog._prepareDialog(); } 289 ); 290 return; 291 } 292 293 if(this.files == false) 294 { 295 HTMLArea._getback(linker.lConfig.backend, function(txt) { lDialog.files = eval(txt); lDialog._prepareDialog(); }); 296 return; 297 } 298 var files = this.files; 299 300 if(this.html == false) 301 { 302 HTMLArea._getback(_editor_url + 'plugins/Linker/dialog.html', function(txt) { lDialog.html = txt; lDialog._prepareDialog(); }); 303 return; 304 } 305 var html = this.html; 306 307 // Now we have everything we need, so we can build the dialog. 308 var dialog = this.dialog = new HTMLArea.Dialog(linker.editor, this.html, 'Linker'); 290 309 var dTreeName = HTMLArea.uniq('dTree_'); 291 310 … … 298 317 // Put it in 299 318 var ddTree = this.dialog.getElementById('dTree'); 300 ddTree.innerHTML = this.dTree.toString(); 319 //ddTree.innerHTML = this.dTree.toString(); 320 ddTree.innerHTML = ''; 301 321 ddTree.style.position = 'absolute'; 302 322 ddTree.style.left = 1 + 'px'; 303 323 ddTree.style.top = 0 + 'px'; 304 324 ddTree.style.overflow = 'auto'; 325 this.ddTree = ddTree; 326 this.dTree._linker_premade = this.dTree.toString(); 305 327 306 328 var options = this.dialog.getElementById('options'); … … 318 340 } 319 341 320 342 this.ready = true; 321 343 } 322 344 … … 348 370 Linker.Dialog.prototype.show = function(inputs, ok, cancel) 349 371 { 350 351 372 if(!this.ready) 352 373 { … … 354 375 window.setTimeout(function() {lDialog.show(inputs,ok,cancel);},100); 355 376 return; 377 } 378 379 if(this.ddTree.innerHTML == '') 380 { 381 this.ddTree.innerHTML = this.dTree._linker_premade; 356 382 } 357 383
