Skip to content

Commit

Permalink
Update 1.1.14
Browse files Browse the repository at this point in the history
js-files
  • Loading branch information
gseilheimer committed Mar 9, 2013
1 parent b4b3689 commit bfddca5
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 51 deletions.
10 changes: 5 additions & 5 deletions config.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@
}

// Recht um das AddOn zu aendern
$REX['ADDON']['perm'][$addon_name] = 'markitup[1]';
#$REX['ADDON']['perm'][$addon_name] = 'markitup[1]';

// Credits
$REX['ADDON']['version'][$addon_name] = '1.1.12';
$REX['ADDON']['version'][$addon_name] = '1.1.14';
$REX['ADDON']['author'][$addon_name] = 'Gilbert Seilheimer';
$REX['ADDON']['supportpage'][$addon_name] = 'forum.redaxo.org';

// *************
$REX['PERM'][] = 'markitup[1]';
$REX['PERM'][] = 'markitup[2]';
#$REX['PERM'][] = 'markitup[1]';
#$REX['PERM'][] = 'markitup[2]';

// Fuer die Benutzervewaltung
$REX['EXTPERM'][] = 'markitup[3]';
#$REX['EXTPERM'][] = 'markitup[3]';

//////////////////////////////////////////////////////////////////////////////////
// SUBPAGES
Expand Down
150 changes: 111 additions & 39 deletions files/jquery.markitup.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// markItUp! Universal MarkUp Engine, JQuery plugin
// v 1.1.x
// Dual licensed under the MIT and GPL licenses.
// ----------------------------------------------------------------------------
// Copyright (C) 2007-2011 Jay Salvat
// Copyright (C) 2007-2012 Jay Salvat
// http://markitup.jaysalvat.com/
// ----------------------------------------------------------------------------
// Permission is hereby granted, free of charge, to any person obtaining a copy
Expand All @@ -26,13 +26,19 @@
// ----------------------------------------------------------------------------
(function($) {
$.fn.markItUp = function(settings, extraSettings) {
var options, ctrlKey, shiftKey, altKey;
ctrlKey = shiftKey = altKey = false;

var method, params, options, ctrlKey, shiftKey, altKey; ctrlKey = shiftKey = altKey = false;

if (typeof settings == 'string') {
method = settings;
params = extraSettings;
}

options = { id: '',
nameSpace: '',
root: '',
previewHandler: false,
previewInWindow: '', // 'width=800, height=600, resizable=yes, scrollbars=yes'
previewInElement: '',
previewAutoRefresh: true,
previewPosition: 'after',
previewTemplatePath: '~/templates/preview.html',
Expand Down Expand Up @@ -60,6 +66,35 @@
});
}

// Quick patch to keep compatibility with jQuery 1.9
var uaMatch = function(ua) {
ua = ua.toLowerCase();

var match = /(chrome)[ \/]([\w.]+)/.exec(ua) ||
/(webkit)[ \/]([\w.]+)/.exec(ua) ||
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) ||
/(msie) ([\w.]+)/.exec(ua) ||
ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) ||
[];

return {
browser: match[ 1 ] || "",
version: match[ 2 ] || "0"
};
};
var matched = uaMatch( navigator.userAgent );
var browser = {};

if (matched.browser) {
browser[matched.browser] = true;
browser.version = matched.version;
}
if (browser.chrome) {
browser.webkit = true;
} else if (browser.webkit) {
browser.safari = true;
}

return this.each(function() {
var $$, textarea, levels, scrollPosition, caretPosition, caretOffset,
clicked, hash, header, footer, previewWindow, template, iFrame, abort;
Expand All @@ -73,6 +108,20 @@
options.previewParserPath = localize(options.previewParserPath);
options.previewTemplatePath = localize(options.previewTemplatePath);

if (method) {
switch(method) {
case 'remove':
remove();
break;
case 'insert':
markup(params);
break;
default:
$.error('Method ' + method + ' does not exist on jQuery.markItUp');
}
return;
}

// apply the computed path to ~/
function localize(data, inText) {
if (inText) {
Expand Down Expand Up @@ -106,29 +155,29 @@
footer = $('<div class="markItUpFooter"></div>').insertAfter($$);

// add the resize handle after textarea
if (options.resizeHandle === true && $.browser.safari !== true) {
if (options.resizeHandle === true && browser.safari !== true) {
resizeHandle = $('<div class="markItUpResizeHandle"></div>')
.insertAfter($$)
.bind("mousedown", function(e) {
.bind("mousedown.markItUp", function(e) {
var h = $$.height(), y = e.clientY, mouseMove, mouseUp;
mouseMove = function(e) {
$$.css("height", Math.max(20, e.clientY+h-y)+"px");
return false;
};
mouseUp = function(e) {
$("html").unbind("mousemove", mouseMove).unbind("mouseup", mouseUp);
$("html").unbind("mousemove.markItUp", mouseMove).unbind("mouseup.markItUp", mouseUp);
return false;
};
$("html").bind("mousemove", mouseMove).bind("mouseup", mouseUp);
$("html").bind("mousemove.markItUp", mouseMove).bind("mouseup.markItUp", mouseUp);
});
footer.append(resizeHandle);
}

// listen key events
$$.keydown(keyPressed).keyup(keyPressed);
$$.bind('keydown.markItUp', keyPressed).bind('keyup', keyPressed);

// bind an event to catch external calls
$$.bind("insertion", function(e, settings) {
$$.bind("insertion.markItUp", function(e, settings) {
if (settings.target !== false) {
get();
}
Expand All @@ -138,9 +187,13 @@
});

// remember the last focus
$$.focus(function() {
$$.bind('focus.markItUp', function() {
$.markItUp.focused = this;
});

if (options.previewInElement) {
refreshPreview();
}
}

// recursively build header with dropMenus from markupset
Expand All @@ -159,28 +212,27 @@
t += levels[j]+"-";
}
li = $('<li class="markItUpButton markItUpButton'+t+(i)+' '+(button.className||'')+'"><a href="" '+key+' title="'+title+'">'+(button.name||'')+'</a></li>')
.bind("contextmenu", function() { // prevent contextmenu on mac and allow ctrl+click
.bind("contextmenu.markItUp", function() { // prevent contextmenu on mac and allow ctrl+click
return false;
}).click(function() {
return false;
}).bind("focusin", function(){
}).bind('click.markItUp', function(e) {
e.preventDefault();
}).bind("focusin.markItUp", function(){
$$.focus();
}).mouseup(function() {
}).bind('mouseup', function() {
if (button.call) {
eval(button.call)();
}
setTimeout(function() { markup(button) },1);
return false;
}).hover(function() {
}).bind('mouseenter.markItUp', function() {
$('> ul', this).show();
$(document).one('click', function() { // close dropmenu if click outside
$('ul ul', header).hide();
}
);
}, function() {
}).bind('mouseleave.markItUp', function() {
$('> ul', this).hide();
}
).appendTo(ul);
}).appendTo(ul);
if (button.dropMenu) {
levels.push(i);
$(li).addClass('markItUpDropMenu').append(dropMenus(button.dropMenu));
Expand Down Expand Up @@ -249,9 +301,13 @@
} else {
string = string || selection;

var lines = selection.split(/\r?\n/), blocks = [];
var lines = [string], blocks = [];

if (multiline === true) {
lines = string.split(/\r?\n/);
}

for (var l=0; l < lines.length; l++) {
for (var l = 0; l < lines.length; l++) {
line = lines[l];
var trailingSpaces;
if (trailingSpaces = line.match(/ *$/)) {
Expand All @@ -267,10 +323,12 @@
block = openBlockWith + block + closeBlockWith;

return { block:block,
openBlockWith:openBlockWith,
openWith:openWith,
replaceWith:replaceWith,
placeHolder:placeHolder,
closeWith:closeWith
closeWith:closeWith,
closeBlockWith:closeBlockWith
};
}

Expand Down Expand Up @@ -307,9 +365,10 @@
lines[i] = "";
}
}

string = { block:lines.join('\n')};
start = caretPosition;
len = string.block.length + (($.browser.opera) ? n-1 : 0);
len = string.block.length + ((browser.opera) ? n-1 : 0);
} else if (ctrlKey === true) {
string = build(selection);
start = caretPosition + string.openWith.length;
Expand All @@ -330,8 +389,8 @@
if ((selection === '' && string.replaceWith === '')) {
caretOffset += fixOperaBug(string.block);

start = caretPosition + string.openWith.length;
len = string.block.length - string.openWith.length - string.closeWith.length;
start = caretPosition + string.openBlockWith.length + string.openWith.length;
len = string.block.length - string.openBlockWith.length - string.openWith.length - string.closeWith.length - string.closeBlockWith.length;

caretOffset = $$.val().substring(caretPosition, $$.val().length).length;
caretOffset -= fixOperaBug($$.val().substring(0, caretPosition));
Expand Down Expand Up @@ -366,14 +425,14 @@

// Substract linefeed in Opera
function fixOperaBug(string) {
if ($.browser.opera) {
if (browser.opera) {
return string.length - string.replace(/\n*/g, '').length;
}
return 0;
}
// Substract linefeed in IE
function fixIeBug(string) {
if ($.browser.msie) {
if (browser.msie) {
return string.length - string.replace(/\r*/g, '').length;
}
return 0;
Expand All @@ -393,7 +452,7 @@
function set(start, len) {
if (textarea.createTextRange){
// quick fix to make it work on Opera 9.5
if ($.browser.opera && $.browser.version >= 9.5 && len == 0) {
if (browser.opera && browser.version >= 9.5 && len == 0) {
return false;
}
range = textarea.createTextRange();
Expand All @@ -415,7 +474,7 @@
scrollPosition = textarea.scrollTop;
if (document.selection) {
selection = document.selection.createRange().text;
if ($.browser.msie) { // ie
if (browser.msie) { // ie
var range = document.selection.createRange(), rangeCopy = range.duplicate();
rangeCopy.moveToElementText(textarea);
caretPosition = -1;
Expand All @@ -436,7 +495,11 @@

// open preview window
function preview() {
if (!previewWindow || previewWindow.closed) {
if (typeof options.previewHandler === 'function') {
previewWindow = true;
} else if (options.previewInElement) {
previewWindow = $(options.previewInElement);
} else if (!previewWindow || previewWindow.closed) {
if (options.previewInWindow) {
previewWindow = window.open('', 'preview', options.previewInWindow);
$(window).unload(function() {
Expand Down Expand Up @@ -472,11 +535,13 @@
renderPreview();
}

function renderPreview() {
function renderPreview() {
var phtml;
if (options.previewParser && typeof options.previewParser === 'function') {
if (options.previewHandler && typeof options.previewHandler === 'function') {
options.previewHandler( $$.val() );
} else if (options.previewParser && typeof options.previewParser === 'function') {
var data = options.previewParser( $$.val() );
writeInPreview( localize(data, 1) );
writeInPreview(localize(data, 1) );
} else if (options.previewParserPath !== '') {
$.ajax({
type: 'POST',
Expand Down Expand Up @@ -504,7 +569,9 @@
}

function writeInPreview(data) {
if (previewWindow.document) {
if (options.previewInElement) {
$(options.previewInElement).html(data);
} else if (previewWindow && previewWindow.document) {
try {
sp = previewWindow.document.documentElement.scrollTop
} catch(e) {
Expand All @@ -525,7 +592,7 @@

if (e.type === 'keydown') {
if (ctrlKey === true) {
li = $('a[accesskey="'+String.fromCharCode(e.keyCode)+'"]', header).parent('li');
li = $('a[accesskey="'+((e.keyCode == 13) ? '\\n' : String.fromCharCode(e.keyCode))+'"]', header).parent('li');
if (li.length !== 0) {
ctrlKey = false;
setTimeout(function() {
Expand Down Expand Up @@ -566,14 +633,19 @@
}
}

function remove() {
$$.unbind(".markItUp").removeClass('markItUpEditor');
$$.parent('div').parent('div.markItUp').parent('div').replaceWith($$);
$$.data('markItUp', null);
}

init();
});
};

$.fn.markItUpRemove = function() {
return this.each(function() {
var $$ = $(this).unbind().removeClass('markItUpEditor');
$$.parent('div').parent('div.markItUp').parent('div').replaceWith($$);
$(this).markItUp('remove');
}
);
};
Expand Down
2 changes: 1 addition & 1 deletion help.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<h3>Benutzung:</h3>
<p>
Das Standard-Textile-Modul wird einfach durch das mit MarkItUp ersetzt...<br />
Damit die Werte nicht verloren gehen ist in diesem zugehörigen Modul eventuell noch der REX_VALUE[XY] anzupassen.
Damit die Werte nicht verloren gehen ist in diesem zugehoerigen Modul eventuell noch der REX_VALUE[XY] anzupassen.
</p>

<br />
Expand Down
6 changes: 3 additions & 3 deletions install.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#
# Autor: G.Seilheimer
# Company: contic.de
# Version: 1.1.12
# Update: 2011-11-09
# CMS: Redaxo 4.3.2
# Version: 1.1.14
# Update: 2013-03-09
# CMS: Redaxo 4.5
#
#*********************************************

Expand Down
6 changes: 3 additions & 3 deletions uninstall.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#
# Autor: G.Seilheimer
# Company: contic.de
# Version: 1.1.12
# Update: 2011-11-09
# CMS: Redaxo 4.3.2
# Version: 1.1.14
# Update: 2013-03-09
# CMS: Redaxo 4.5
#
#*********************************************

Expand Down

0 comments on commit bfddca5

Please sign in to comment.