Mercurial > public > sg101
comparison media/js/markitup/jquery.markitup.js @ 185:afb65fa947f1
Committing version 1.1.6.1 of the MarkItUp! editor. This is for #57.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sun, 28 Mar 2010 23:25:10 +0000 |
parents | dbd703f7d63a |
children | 217119c87a06 |
comparison
equal
deleted
inserted
replaced
184:4e1abeb593c2 | 185:afb65fa947f1 |
---|---|
1 // ---------------------------------------------------------------------------- | 1 // ---------------------------------------------------------------------------- |
2 // markItUp! Universal MarkUp Engine, JQuery plugin | 2 // markItUp! Universal MarkUp Engine, JQuery plugin |
3 // v 1.1.5 | 3 // v 1.1.6.1 |
4 // Dual licensed under the MIT and GPL licenses. | 4 // Dual licensed under the MIT and GPL licenses. |
5 // ---------------------------------------------------------------------------- | 5 // ---------------------------------------------------------------------------- |
6 // Copyright (C) 2007-2008 Jay Salvat | 6 // Copyright (C) 2007-2010 Jay Salvat |
7 // http://markitup.jaysalvat.com/ | 7 // http://markitup.jaysalvat.com/ |
8 // ---------------------------------------------------------------------------- | 8 // ---------------------------------------------------------------------------- |
9 // Permission is hereby granted, free of charge, to any person obtaining a copy | 9 // Permission is hereby granted, free of charge, to any person obtaining a copy |
10 // of this software and associated documentation files (the "Software"), to deal | 10 // of this software and associated documentation files (the "Software"), to deal |
11 // in the Software without restriction, including without limitation the rights | 11 // in the Software without restriction, including without limitation the rights |
419 if (options.previewPosition == 'after') { | 419 if (options.previewPosition == 'after') { |
420 iFrame.insertAfter(footer); | 420 iFrame.insertAfter(footer); |
421 } else { | 421 } else { |
422 iFrame.insertBefore(header); | 422 iFrame.insertBefore(header); |
423 } | 423 } |
424 previewWindow = iFrame[iFrame.length-1].contentWindow || frame[iFrame.length-1]; | 424 previewWindow = iFrame[iFrame.length - 1].contentWindow || frame[iFrame.length - 1]; |
425 } | 425 } |
426 } else if (altKey === true) { | 426 } else if (altKey === true) { |
427 // Thx Stephen M. Redd for the IE8 fix | |
427 if (iFrame) { | 428 if (iFrame) { |
428 iFrame.remove(); | 429 iFrame.remove(); |
429 } | 430 } else { |
430 previewWindow.close(); | 431 previewWindow.close(); |
432 } | |
431 previewWindow = iFrame = false; | 433 previewWindow = iFrame = false; |
432 } | 434 } |
433 if (!options.previewAutoRefresh) { | 435 if (!options.previewAutoRefresh) { |
434 refreshPreview(); | 436 refreshPreview(); |
435 } | 437 } |
436 } | 438 } |
437 | 439 |
438 // refresh Preview window | 440 // refresh Preview window |
439 function refreshPreview() { | 441 function refreshPreview() { |
442 renderPreview(); | |
443 } | |
444 | |
445 function renderPreview() { | |
446 var phtml; | |
447 if (options.previewParserPath !== '') { | |
448 $.ajax( { | |
449 type: 'POST', | |
450 url: options.previewParserPath, | |
451 data: options.previewParserVar+'='+encodeURIComponent($$.val()), | |
452 success: function(data) { | |
453 writeInPreview( localize(data, 1) ); | |
454 } | |
455 } ); | |
456 } else { | |
457 if (!template) { | |
458 $.ajax( { | |
459 url: options.previewTemplatePath, | |
460 success: function(data) { | |
461 writeInPreview( localize(data, 1).replace(/<!-- content -->/g, $$.val()) ); | |
462 } | |
463 } ); | |
464 } | |
465 } | |
466 return false; | |
467 } | |
468 | |
469 function writeInPreview(data) { | |
440 if (previewWindow.document) { | 470 if (previewWindow.document) { |
441 try { | 471 try { |
442 sp = previewWindow.document.documentElement.scrollTop | 472 sp = previewWindow.document.documentElement.scrollTop |
443 } catch(e) { | 473 } catch(e) { |
444 sp = 0; | 474 sp = 0; |
445 } | 475 } |
476 var h = "test"; | |
446 previewWindow.document.open(); | 477 previewWindow.document.open(); |
447 previewWindow.document.write(renderPreview()); | 478 previewWindow.document.write(data); |
448 previewWindow.document.close(); | 479 previewWindow.document.close(); |
449 previewWindow.document.documentElement.scrollTop = sp; | 480 previewWindow.document.documentElement.scrollTop = sp; |
450 } | 481 } |
451 if (options.previewInWindow) { | 482 if (options.previewInWindow) { |
452 previewWindow.focus(); | 483 previewWindow.focus(); |
453 } | 484 } |
454 } | |
455 | |
456 function renderPreview() { | |
457 if (options.previewParserPath !== '') { | |
458 $.ajax( { | |
459 type: 'POST', | |
460 async: false, | |
461 url: options.previewParserPath, | |
462 data: options.previewParserVar+'='+encodeURIComponent($$.val()), | |
463 success: function(data) { | |
464 phtml = localize(data, 1); | |
465 } | |
466 } ); | |
467 } else { | |
468 if (!template) { | |
469 $.ajax( { | |
470 async: false, | |
471 url: options.previewTemplatePath, | |
472 success: function(data) { | |
473 template = localize(data, 1); | |
474 } | |
475 } ); | |
476 } | |
477 phtml = template.replace(/<!-- content -->/g, $$.val()); | |
478 } | |
479 return phtml; | |
480 } | 485 } |
481 | 486 |
482 // set keys pressed | 487 // set keys pressed |
483 function keyPressed(e) { | 488 function keyPressed(e) { |
484 shiftKey = e.shiftKey; | 489 shiftKey = e.shiftKey; |