Mercurial > public > sg101
comparison media/js/markitup/jquery.markitup.js @ 199:217119c87a06
Fix #72: update to 1.1.7 of the MarkItUp! editor.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sun, 11 Apr 2010 18:56:30 +0000 |
parents | afb65fa947f1 |
children | a61b1c598001 |
comparison
equal
deleted
inserted
replaced
198:7e3ed3eb9b99 | 199:217119c87a06 |
---|---|
1 // ---------------------------------------------------------------------------- | 1 // ---------------------------------------------------------------------------- |
2 // markItUp! Universal MarkUp Engine, JQuery plugin | 2 // markItUp! Universal MarkUp Engine, JQuery plugin |
3 // v 1.1.6.1 | 3 // v 1.1.7 |
4 // Dual licensed under the MIT and GPL licenses. | 4 // Dual licensed under the MIT and GPL licenses. |
5 // ---------------------------------------------------------------------------- | 5 // ---------------------------------------------------------------------------- |
6 // Copyright (C) 2007-2010 Jay Salvat | 6 // Copyright (C) 2007-2010 Jay Salvat |
7 // http://markitup.jaysalvat.com/ | 7 // http://markitup.jaysalvat.com/ |
8 // ---------------------------------------------------------------------------- | 8 // ---------------------------------------------------------------------------- |
160 li = $('<li class="markItUpButton markItUpButton'+t+(i)+' '+(button.className||'')+'"><a href="" '+key+' title="'+title+'">'+(button.name||'')+'</a></li>') | 160 li = $('<li class="markItUpButton markItUpButton'+t+(i)+' '+(button.className||'')+'"><a href="" '+key+' title="'+title+'">'+(button.name||'')+'</a></li>') |
161 .bind("contextmenu", function() { // prevent contextmenu on mac and allow ctrl+click | 161 .bind("contextmenu", function() { // prevent contextmenu on mac and allow ctrl+click |
162 return false; | 162 return false; |
163 }).click(function() { | 163 }).click(function() { |
164 return false; | 164 return false; |
165 }).mouseup(function() { | 165 }).mousedown(function() { |
166 if (button.call) { | 166 if (button.call) { |
167 eval(button.call)(); | 167 eval(button.call)(); |
168 } | 168 } |
169 markup(button); | 169 setTimeout(function() { markup(button) },1); |
170 return false; | 170 return false; |
171 }).hover(function() { | 171 }).hover(function() { |
172 $('> ul', this).show(); | 172 $('> ul', this).show(); |
173 $(document).one('click', function() { // close dropmenu if click outside | 173 $(document).one('click', function() { // close dropmenu if click outside |
174 $('ul ul', header).hide(); | 174 $('ul ul', header).hide(); |
400 caretPosition ++; | 400 caretPosition ++; |
401 } | 401 } |
402 } else { // opera | 402 } else { // opera |
403 caretPosition = textarea.selectionStart; | 403 caretPosition = textarea.selectionStart; |
404 } | 404 } |
405 } else { // gecko | 405 } else { // gecko & webkit |
406 caretPosition = textarea.selectionStart; | 406 caretPosition = textarea.selectionStart; |
407 selection = $$.val().substring(caretPosition, textarea.selectionEnd); | 407 selection = $$.val().substring(caretPosition, textarea.selectionEnd); |
408 } | 408 } |
409 return selection; | 409 return selection; |
410 } | 410 } |
471 try { | 471 try { |
472 sp = previewWindow.document.documentElement.scrollTop | 472 sp = previewWindow.document.documentElement.scrollTop |
473 } catch(e) { | 473 } catch(e) { |
474 sp = 0; | 474 sp = 0; |
475 } | 475 } |
476 var h = "test"; | |
477 previewWindow.document.open(); | 476 previewWindow.document.open(); |
478 previewWindow.document.write(data); | 477 previewWindow.document.write(data); |
479 previewWindow.document.close(); | 478 previewWindow.document.close(); |
480 previewWindow.document.documentElement.scrollTop = sp; | 479 previewWindow.document.documentElement.scrollTop = sp; |
481 } | 480 } |
493 if (e.type === 'keydown') { | 492 if (e.type === 'keydown') { |
494 if (ctrlKey === true) { | 493 if (ctrlKey === true) { |
495 li = $("a[accesskey="+String.fromCharCode(e.keyCode)+"]", header).parent('li'); | 494 li = $("a[accesskey="+String.fromCharCode(e.keyCode)+"]", header).parent('li'); |
496 if (li.length !== 0) { | 495 if (li.length !== 0) { |
497 ctrlKey = false; | 496 ctrlKey = false; |
498 li.triggerHandler('mouseup'); | 497 setTimeout(function() { |
498 li.triggerHandler('mousedown'); | |
499 },1); | |
499 return false; | 500 return false; |
500 } | 501 } |
501 } | 502 } |
502 if (e.keyCode === 13 || e.keyCode === 10) { // Enter key | 503 if (e.keyCode === 13 || e.keyCode === 10) { // Enter key |
503 if (ctrlKey === true) { // Enter + Ctrl | 504 if (ctrlKey === true) { // Enter + Ctrl |
535 }); | 536 }); |
536 }; | 537 }; |
537 | 538 |
538 $.fn.markItUpRemove = function() { | 539 $.fn.markItUpRemove = function() { |
539 return this.each(function() { | 540 return this.each(function() { |
540 $$ = $(this).unbind().removeClass('markItUpEditor'); | 541 var $$ = $(this).unbind().removeClass('markItUpEditor'); |
541 $$.parent('div').parent('div.markItUp').parent('div').replaceWith($$); | 542 $$.parent('div').parent('div.markItUp').parent('div').replaceWith($$); |
542 } | 543 } |
543 ); | 544 ); |
544 }; | 545 }; |
545 | 546 |