Mercurial > public > sg101
diff media/js/markitup/jquery.markitup.js @ 244:a61b1c598001
Updated to markItUp 1.1.8. Ticket #94.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Fri, 17 Sep 2010 02:27:40 +0000 |
parents | 217119c87a06 |
children |
line wrap: on
line diff
--- a/media/js/markitup/jquery.markitup.js Thu Sep 16 01:06:43 2010 +0000 +++ b/media/js/markitup/jquery.markitup.js Fri Sep 17 02:27:40 2010 +0000 @@ -1,6 +1,6 @@ // ---------------------------------------------------------------------------- // markItUp! Universal MarkUp Engine, JQuery plugin -// v 1.1.7 +// v 1.1.x // Dual licensed under the MIT and GPL licenses. // ---------------------------------------------------------------------------- // Copyright (C) 2007-2010 Jay Salvat @@ -28,7 +28,7 @@ $.fn.markItUp = function(settings, extraSettings) { var options, ctrlKey, shiftKey, altKey; ctrlKey = shiftKey = altKey = false; - + options = { id: '', nameSpace: '', root: '', @@ -162,6 +162,8 @@ return false; }).click(function() { return false; + }).focusin(function(){ + $$.focus(); }).mousedown(function() { if (button.call) { eval(button.call)(); @@ -286,7 +288,7 @@ } string = { block:lines.join('\n')}; start = caretPosition; - len = string.block.length + (($.browser.opera) ? n : 0); + len = string.block.length + (($.browser.opera) ? n-1 : 0); } else if (ctrlKey === true) { string = build(selection); start = caretPosition + string.openWith.length; @@ -361,7 +363,7 @@ var newSelection = document.selection.createRange(); newSelection.text = block; } else { - $$.val($$.val().substring(0, caretPosition) + block + $$.val().substring(caretPosition + selection.length, $$.val().length)); + textarea.value = textarea.value.substring(0, caretPosition) + block + textarea.value.substring(caretPosition + selection.length, textarea.value.length); } } @@ -395,7 +397,7 @@ var range = document.selection.createRange(), rangeCopy = range.duplicate(); rangeCopy.moveToElementText(textarea); caretPosition = -1; - while(rangeCopy.inRange(range)) { // fix most of the ie bugs with linefeeds... + while(rangeCopy.inRange(range)) { rangeCopy.moveStart('character'); caretPosition ++; } @@ -404,7 +406,7 @@ } } else { // gecko & webkit caretPosition = textarea.selectionStart; - selection = $$.val().substring(caretPosition, textarea.selectionEnd); + selection = textarea.value.substring(caretPosition, textarea.selectionEnd); } return selection; } @@ -414,6 +416,9 @@ if (!previewWindow || previewWindow.closed) { if (options.previewInWindow) { previewWindow = window.open('', 'preview', options.previewInWindow); + $(window).unload(function() { + previewWindow.close(); + }); } else { iFrame = $('<iframe class="markItUpPreviewFrame"></iframe>'); if (options.previewPosition == 'after') { @@ -424,7 +429,6 @@ previewWindow = iFrame[iFrame.length - 1].contentWindow || frame[iFrame.length - 1]; } } else if (altKey === true) { - // Thx Stephen M. Redd for the IE8 fix if (iFrame) { iFrame.remove(); } else { @@ -435,6 +439,9 @@ if (!options.previewAutoRefresh) { refreshPreview(); } + if (options.previewInWindow) { + previewWindow.focus(); + } } // refresh Preview window @@ -478,9 +485,6 @@ previewWindow.document.close(); previewWindow.document.documentElement.scrollTop = sp; } - if (options.previewInWindow) { - previewWindow.focus(); - } } // set keys pressed @@ -515,7 +519,7 @@ } } if (e.keyCode === 9) { // Tab key - if (shiftKey == true || ctrlKey == true || altKey == true) { // Thx Dr Floob. + if (shiftKey == true || ctrlKey == true || altKey == true) { return false; } if (caretOffset !== -1) {