first re-commit.
455
sn_templates/editor_stuff/plugin/advimagescale/editor_plugin.js
Normal file
@@ -0,0 +1,455 @@
|
||||
/**
|
||||
* TinyMCE Advanced Image Resize Helper Plugin
|
||||
*
|
||||
* Forces images to maintain aspect ratio while scaling - also optionally enforces
|
||||
* min/max image dimensions, and appends width/height to the image URL for server-side
|
||||
* resizing
|
||||
*
|
||||
* @author Marc Hodgins
|
||||
* @link http://www.hodginsmedia.com Hodgins Media Ventures Inc.
|
||||
* @copyright Copyright (C) 2008 Hodgins Media Ventures Inc., All right reserved.
|
||||
* @license http://www.opensource.org/licenses/lgpl-3.0.html LGPLv3
|
||||
*/
|
||||
(function() {
|
||||
|
||||
/**
|
||||
* Stores pre-resize image dimensions
|
||||
* @var {array} (w,h)
|
||||
*/
|
||||
var originalDimensions = new Array();
|
||||
|
||||
/**
|
||||
* Stores last dimensions before a resize
|
||||
* @var {array} (w,h)
|
||||
*/
|
||||
var lastDimensions = new Array();
|
||||
|
||||
/**
|
||||
* Track mousedown status in editor
|
||||
* @var {boolean}
|
||||
*/
|
||||
var edMouseDown = false;
|
||||
|
||||
tinymce.create('tinymce.plugins.AdvImageScale', {
|
||||
/**
|
||||
* Initializes the plugin, this will be executed after the plugin has been created.
|
||||
*
|
||||
* @param {tinymce.Editor} ed Editor instance that the plugin is initialized in.
|
||||
* @param {string} url Absolute URL to where the plugin is located.
|
||||
*/
|
||||
init : function(ed, url) {
|
||||
|
||||
|
||||
// Watch for mousedown (as a fall through to ensure that prepareImage() definitely
|
||||
// got called on an image tag before mouseup).
|
||||
//
|
||||
// Normally this should have happened via the onPreProcess/onSetContent listeners, but
|
||||
// for completeness we check once more here in case there are edge cases we've missed.
|
||||
ed.onMouseDown.add(function(ed, e) {
|
||||
var el = tinyMCE.activeEditor.selection.getNode();
|
||||
if (el.nodeName == 'IMG') {
|
||||
// prepare image for resizing
|
||||
prepareImage(ed, e.target);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
// Watch for mouseup (catch image resizes)
|
||||
ed.onMouseUp.add(function(ed, e) {
|
||||
var el = tinyMCE.activeEditor.selection.getNode();
|
||||
if (el.nodeName == 'IMG') {
|
||||
// setTimeout is necessary to allow the browser to complete the resize so we have new dimensions
|
||||
setTimeout(function() {
|
||||
constrainSize(ed, el);
|
||||
}, 100);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
/*****************************************************
|
||||
* ENFORCE CONSTRAINTS ON CONTENT INSERTED INTO EDITOR
|
||||
*****************************************************/
|
||||
|
||||
// Catch editor.setContent() events via onPreProcess (because onPreProcess allows us to
|
||||
// modify the DOM before it is inserted, unlike onSetContent)
|
||||
ed.onPreProcess.add(function(ed, o) {
|
||||
if (!o.set) return; // only 'set' operations let us modify the nodes
|
||||
|
||||
// loop in each img node and run constrainSize
|
||||
tinymce.each(ed.dom.select('img', o.node), function(currentNode) {
|
||||
constrainSize(ed, currentNode);
|
||||
});
|
||||
});
|
||||
|
||||
// To be complete, we also need to watch for setContent() calls on the selection object so that
|
||||
// constraints are enforced (i.e. in case an <img> tag is inserted via mceInsertContent).
|
||||
// So, catch all insertions using the editor's selection object
|
||||
ed.onInit.add(function(ed) {
|
||||
// http://wiki.moxiecode.com/index.php/TinyMCE:API/tinymce.dom.Selection/onSetContent
|
||||
ed.selection.onSetContent.add(function(se, o) {
|
||||
// @todo This seems to grab the entire editor contents - it works but could
|
||||
// perform poorly on large documents
|
||||
var currentNode = se.getNode();
|
||||
tinymce.each(ed.dom.select('img', currentNode), function (currentNode) {
|
||||
// IF condition required as tinyMCE inserts 24x24 placeholders uner some conditions
|
||||
if (currentNode.id != "__mce_tmp")
|
||||
constrainSize(ed, currentNode);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
/*****************************
|
||||
* DISALLOW EXTERNAL IMAGE DRAG/DROPS
|
||||
*****************************/
|
||||
// This is a hack. Listening for drag events wasn't working.
|
||||
//
|
||||
// Watches for mousedown and mouseup/dragdrop events within the editor. If a mouseup or
|
||||
// dragdrop occurs in the editor without a preceeding mousedown, we assume it is an external
|
||||
// dragdrop that should be rejected.
|
||||
if (ed.getParam('advimagescale_reject_external_dragdrop', true)) {
|
||||
|
||||
// catch mousedowns mouseups and dragdrops (which are basically mouseups too..)
|
||||
ed.onMouseDown.add(function(e) { edMouseDown = true; });
|
||||
ed.onMouseUp.add(function(e) { edMouseDown = false; });
|
||||
ed.onInit.add(function(ed, o) {
|
||||
tinymce.dom.Event.add(ed.getBody().parentNode, 'dragdrop', function(e) { edMouseDown = false; });
|
||||
});
|
||||
|
||||
// watch for drag attempts
|
||||
var evt = (tinymce.isIE) ? 'dragenter' : 'dragover'; // IE allows dragdrop reject on dragenter (more efficient)
|
||||
ed.onInit.add(function(ed, o) {
|
||||
// use parentNode to go above editor content, to cover entire editor area
|
||||
tinymce.dom.Event.add(ed.getBody().parentNode, evt, function (e) {
|
||||
if (!edMouseDown) {
|
||||
// disallow drop
|
||||
return tinymce.dom.Event.cancel(e);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns information about the plugin as a name/value array.
|
||||
* The current keys are longname, author, authorurl, infourl and version.
|
||||
*
|
||||
* @return {Object} Name/value array containing information about the plugin.
|
||||
*/
|
||||
getInfo : function() {
|
||||
return {
|
||||
longname : 'Advanced Image Resize Helper',
|
||||
author : 'Marc Hodgins',
|
||||
authorurl : 'http://www.hodginsmedia.com',
|
||||
infourl : 'http://code.google.com/p/tinymce-plugin-advimagescale',
|
||||
version : '1.1.2'
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// Register plugin
|
||||
tinymce.PluginManager.add('advimagescale', tinymce.plugins.AdvImageScale);
|
||||
|
||||
/**
|
||||
* Store image dimensions, pre-resize
|
||||
*
|
||||
* @param {object} el HTMLDomNode
|
||||
*/
|
||||
function storeDimensions(ed, el) {
|
||||
var dom = ed.dom;
|
||||
var elId = dom.getAttrib(el, 'mce_advimageresize_id');
|
||||
|
||||
// store original dimensions if this is the first resize of this element
|
||||
if (!originalDimensions[elId]) {
|
||||
originalDimensions[elId] = lastDimensions[elId] = {width: dom.getAttrib(el, 'width', el.width), height: dom.getAttrib(el, 'height', el.height)};
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare image for resizing
|
||||
* Check to see if we've seen this IMG tag before; does tasks such as adding
|
||||
* unique IDs to image tags, saving "original" image dimensions, etc.
|
||||
* @param {object} e is optional
|
||||
*/
|
||||
function prepareImage(ed, el) {
|
||||
var dom = ed.dom;
|
||||
var elId= dom.getAttrib(el, 'mce_advimageresize_id');
|
||||
|
||||
// is this the first time this image tag has been seen?
|
||||
if (!elId) {
|
||||
var elId = ed.dom.uniqueId();
|
||||
dom.setAttrib(el, 'mce_advimageresize_id', elId);
|
||||
storeDimensions(ed, el);
|
||||
}
|
||||
|
||||
return elId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjusts width and height to keep within min/max bounds and also maintain aspect ratio
|
||||
* If mce_noresize attribute is set to image tag, then image resize is disallowed
|
||||
*/
|
||||
function constrainSize(ed, el, e) {
|
||||
var dom = ed.dom;
|
||||
var elId = prepareImage(ed, el); // also calls storeDimensions
|
||||
var resized = (dom.getAttrib(el, 'width') != lastDimensions[elId].width || dom.getAttrib(el, 'height') != lastDimensions[elId].height);
|
||||
|
||||
if (!resized)
|
||||
return; // nothing to do
|
||||
|
||||
// disallow image resize if mce_noresize or the noresize class is set on the image tag
|
||||
if (dom.getAttrib(el, 'mce_noresize') || dom.hasClass(el, ed.getParam('advimagescale_noresize_class', 'noresize')) || ed.getParam('advimagescale_noresize_all')) {
|
||||
dom.setAttrib(el, 'width', lastDimensions[elId].width);
|
||||
dom.setAttrib(el, 'height', lastDimensions[elId].height);
|
||||
if (tinymce.isGecko)
|
||||
fixGeckoHandles(ed);
|
||||
return;
|
||||
}
|
||||
|
||||
// Both IE7 and Gecko (as of FF3.0.03) has a "expands image by border width" bug before doing anything else
|
||||
if (ed.getParam('advimagescale_fix_border_glitch', true /* default to true */)) {
|
||||
fixImageBorderGlitch(ed, el);
|
||||
storeDimensions(ed, el); // store adjusted dimensions
|
||||
}
|
||||
|
||||
// filter by regexp so only some images get constrained
|
||||
var src_filter = ed.getParam('advimagescale_filter_src');
|
||||
if (src_filter) {
|
||||
var r = new RegExp(src_filter);
|
||||
if (!el.src.match(r)) {
|
||||
return; // skip this element
|
||||
}
|
||||
}
|
||||
|
||||
// allow filtering by classname
|
||||
var class_filter = ed.getParam('advimagescale_filter_class');
|
||||
if (class_filter) {
|
||||
if (!dom.hasClass(el, class_filter)) {
|
||||
return; // skip this element, doesn't have the class we want
|
||||
}
|
||||
}
|
||||
|
||||
// populate new dimensions object
|
||||
var newDimensions = { width: dom.getAttrib(el, 'width', el.width), height: dom.getAttrib(el, 'height', el.height) };
|
||||
|
||||
// adjust w/h to maintain aspect ratio
|
||||
if (ed.getParam('advimagescale_maintain_aspect_ratio', true /* default to true */)) {
|
||||
newDimensions = maintainAspect(ed, el, newDimensions.width, newDimensions.height);
|
||||
}
|
||||
|
||||
// enforce minW/minH/maxW/maxH
|
||||
newDimensions = checkBoundaries(ed, el, newDimensions.width, newDimensions.height);
|
||||
|
||||
// was an adjustment made?
|
||||
var adjusted = (dom.getAttrib(el, 'width', el.width) != newDimensions.width || dom.getAttrib(el, 'height', el.height) != newDimensions.height);
|
||||
|
||||
// apply new w/h
|
||||
if (adjusted) {
|
||||
dom.setAttrib(el, 'width', newDimensions.width);
|
||||
dom.setAttrib(el, 'height', newDimensions.height);
|
||||
if (tinymce.isGecko) fixGeckoHandles(ed);
|
||||
}
|
||||
|
||||
if (ed.getParam('advimagescale_append_to_url')) {
|
||||
appendToUri(ed, el, dom.getAttrib(el, 'width', el.width), dom.getAttrib(el, 'height', el.height));
|
||||
}
|
||||
|
||||
// was the image resized?
|
||||
if (lastDimensions[elId].width != dom.getAttrib(el, 'width', el.width) || lastDimensions[elId].height != dom.getAttrib(el, 'height', el.height)) {
|
||||
// call "image resized" callback (if set)
|
||||
if (ed.getParam('advimagescale_resize_callback')) {
|
||||
ed.getParam('advimagescale_resize_callback')(ed, el);
|
||||
}
|
||||
}
|
||||
|
||||
// remember "last dimensions" for next time
|
||||
lastDimensions[elId] = { width: dom.getAttrib(el, 'width', el.width), height: dom.getAttrib(el, 'height', el.height) };
|
||||
}
|
||||
|
||||
/**
|
||||
* Fixes IE7 and Gecko border width glitch
|
||||
*
|
||||
* Both "add" the border width to an image after the resize handles have been
|
||||
* dropped. This reverses it by looking at the "previous" known size and comparing
|
||||
* to the current size. If they don't match, then a resize has taken place and the browser
|
||||
* has (probably) messed it up. So, we reverse it. Note, this will probably need to be
|
||||
* wrapped in a conditional statement if/when each browser fixes this bug.
|
||||
*/
|
||||
function fixImageBorderGlitch(ed, el) {
|
||||
var dom = ed.dom;
|
||||
var elId = dom.getAttrib(el, 'mce_advimageresize_id');
|
||||
var currentWidth = dom.getAttrib(el, 'width', el.width);
|
||||
var currentHeight= dom.getAttrib(el, 'height', el.height);
|
||||
var adjusted = false;
|
||||
|
||||
// if current dimensions do not match what we last saw, then a resize has taken place
|
||||
if (currentWidth != lastDimensions[elId].width) {
|
||||
var adjustWidth = 0;
|
||||
|
||||
// get computed border left/right widths
|
||||
adjustWidth += parseInt(dom.getStyle(el, 'borderLeftWidth', 'borderLeftWidth'));
|
||||
adjustWidth += parseInt(dom.getStyle(el, 'borderRightWidth', 'borderRightWidth'));
|
||||
|
||||
// reset the width height to NOT include these amounts
|
||||
if (adjustWidth > 0) {
|
||||
dom.setAttrib(el, 'width', (currentWidth - adjustWidth));
|
||||
adjusted = true;
|
||||
}
|
||||
}
|
||||
if (currentHeight != lastDimensions[elId].height) {
|
||||
var adjustHeight = 0;
|
||||
|
||||
// get computed border top/bottom widths
|
||||
adjustHeight += parseInt(dom.getStyle(el, 'borderTopWidth', 'borderTopWidth'));
|
||||
adjustHeight += parseInt(dom.getStyle(el, 'borderBottomWidth', 'borderBottomWidth'));
|
||||
|
||||
if (adjustHeight > 0) {
|
||||
dom.setAttrib(el, 'height', (currentHeight - adjustHeight));
|
||||
adjusted = true;
|
||||
}
|
||||
}
|
||||
if (adjusted && tinymce.isGecko) fixGeckoHandles(ed);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix gecko resize handles glitch
|
||||
*/
|
||||
function fixGeckoHandles(ed) {
|
||||
ed.execCommand('mceRepaint', false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set image dimensions on into a uri as querystring params
|
||||
*/
|
||||
function appendToUri(ed, el, w, h) {
|
||||
var dom = ed.dom;
|
||||
var uri = dom.getAttrib(el, 'src');
|
||||
var wKey = ed.getParam('advimagescale_url_width_key', 'w');
|
||||
uri = setQueryParam(uri, wKey, w);
|
||||
var hKey = ed.getParam('advimagescale_url_height_key', 'h');
|
||||
uri = setQueryParam(uri, hKey, h);
|
||||
|
||||
// no need to continue if URL didn't change
|
||||
if (uri == dom.getAttrib(el, 'src')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// trigger image loading callback (if set)
|
||||
if (ed.getParam('advimagescale_loading_callback')) {
|
||||
// call loading callback
|
||||
ed.getParam('advimagescale_loading_callback')(el);
|
||||
}
|
||||
// hook image load(ed) callback (if set)
|
||||
if (ed.getParam('advimagescale_loaded_callback')) {
|
||||
// hook load event on the image tag to call the loaded callback
|
||||
tinymce.dom.Event.add(el, 'load', imageLoadedCallback, {el: el, ed: ed});
|
||||
}
|
||||
|
||||
// set new src
|
||||
dom.setAttrib(el, 'src', uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback event when an image is (re)loaded
|
||||
* @param {object} e Event (use e.target or this.el to access element, this.ed to access editor instance)
|
||||
*/
|
||||
function imageLoadedCallback(e) {
|
||||
var el = this.el; // image element
|
||||
var ed = this.ed; // editor
|
||||
var callback = ed.getParam('advimagescale_loaded_callback'); // user specified callback
|
||||
|
||||
// call callback, pass img as param
|
||||
callback(el);
|
||||
|
||||
// remove callback event
|
||||
tinymce.dom.Event.remove(el, 'load', imageLoadedCallback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets URL querystring parameters by appending or replacing existing params of same name
|
||||
*/
|
||||
function setQueryParam(uri, key, value) {
|
||||
if (!uri.match(/\?/)) uri += '?';
|
||||
if (!uri.match(new RegExp('([\?&])' + key + '='))) {
|
||||
if (!uri.match(/[&\?]$/)) uri += '&';
|
||||
uri += key + '=' + escape(value);
|
||||
} else {
|
||||
uri = uri.replace(new RegExp('([\?\&])' + key + '=[^&]*'), '$1' + key + '=' + escape(value));
|
||||
}
|
||||
return uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns w/h that maintain aspect ratio
|
||||
*/
|
||||
function maintainAspect(ed, el, w, h) {
|
||||
var elId = ed.dom.getAttrib(el, 'mce_advimageresize_id');
|
||||
|
||||
// calculate aspect ratio of original so we can maintain it
|
||||
var ratio = originalDimensions[elId].width / originalDimensions[elId].height;
|
||||
|
||||
// decide which dimension changed more (percentage), because that's the
|
||||
// one we'll respect (the other we'll adjust to keep aspect ratio)
|
||||
var lastW = lastDimensions[elId].width;
|
||||
var lastH = lastDimensions[elId].height;
|
||||
var deltaW = Math.abs(lastW - w); // absolute
|
||||
var deltaH = Math.abs(lastH - h); // absolute
|
||||
var pctW = Math.abs(deltaW / lastW); // percentage
|
||||
var pctH = Math.abs(deltaH / lastH); // percentage
|
||||
|
||||
if (deltaW || deltaH) {
|
||||
if (pctW > pctH) {
|
||||
// width changed more - use that as the locked point and adjust height
|
||||
return { width: w, height: Math.round(w / ratio) };
|
||||
} else {
|
||||
// height changed more - use that as the locked point and adjust width
|
||||
return { width: Math.round(h * ratio), height: h };
|
||||
}
|
||||
}
|
||||
|
||||
// nothing changed
|
||||
return { width: w, height: h };
|
||||
}
|
||||
|
||||
/**
|
||||
* Enforce min/max boundaries
|
||||
*
|
||||
* Returns true if an adjustment was made
|
||||
*/
|
||||
function checkBoundaries(ed, el, w, h) {
|
||||
|
||||
var elId = ed.dom.getAttrib(el, 'mce_advimageresize_id');
|
||||
var maxW = ed.getParam('advimagescale_max_width');
|
||||
var maxH = ed.getParam('advimagescale_max_height');
|
||||
var minW = ed.getParam('advimagescale_min_width');
|
||||
var minH = ed.getParam('advimagescale_min_height');
|
||||
var maintainAspect = ed.getParam('advimagescale_maintain_aspect_ratio', true);
|
||||
var oW = originalDimensions[elId].width;
|
||||
var oH = originalDimensions[elId].height;
|
||||
var ratio = oW/oH;
|
||||
|
||||
// max
|
||||
if (maxW && w > maxW) {
|
||||
w = maxW;
|
||||
h = maintainAspect ? Math.round(w / ratio) : h;
|
||||
}
|
||||
if (maxH && h > maxH) {
|
||||
h = maxH;
|
||||
w = maintainAspect ? Math.round(h * ratio) : w;
|
||||
}
|
||||
|
||||
// min
|
||||
if (minW && w < minW) {
|
||||
w = minW;
|
||||
h = maintainAspect ? Math.round(w / ratio) : h;
|
||||
}
|
||||
if (minH && h < minH) {
|
||||
h = minH;
|
||||
w = maintainAspect ? Math.round(h * ratio) : h;
|
||||
}
|
||||
|
||||
return { width: w, height:h };
|
||||
}
|
||||
|
||||
})();
|
@@ -0,0 +1,454 @@
|
||||
/**
|
||||
* TinyMCE Advanced Image Resize Helper Plugin
|
||||
*
|
||||
* Forces images to maintain aspect ratio while scaling - also optionally enforces
|
||||
* min/max image dimensions, and appends width/height to the image URL for server-side
|
||||
* resizing
|
||||
*
|
||||
* @author Marc Hodgins
|
||||
* @link http://www.hodginsmedia.com Hodgins Media Ventures Inc.
|
||||
* @copyright Copyright (C) 2008 Hodgins Media Ventures Inc., All right reserved.
|
||||
* @license http://www.opensource.org/licenses/lgpl-3.0.html LGPLv3
|
||||
*/
|
||||
(function() {
|
||||
|
||||
/**
|
||||
* Stores pre-resize image dimensions
|
||||
* @var {array} (w,h)
|
||||
*/
|
||||
var originalDimensions = new Array();
|
||||
|
||||
/**
|
||||
* Stores last dimensions before a resize
|
||||
* @var {array} (w,h)
|
||||
*/
|
||||
var lastDimensions = new Array();
|
||||
|
||||
/**
|
||||
* Track mousedown status in editor
|
||||
* @var {boolean}
|
||||
*/
|
||||
var edMouseDown = false;
|
||||
|
||||
tinymce.create('tinymce.plugins.AdvImageScale', {
|
||||
/**
|
||||
* Initializes the plugin, this will be executed after the plugin has been created.
|
||||
*
|
||||
* @param {tinymce.Editor} ed Editor instance that the plugin is initialized in.
|
||||
* @param {string} url Absolute URL to where the plugin is located.
|
||||
*/
|
||||
init : function(ed, url) {
|
||||
|
||||
// Watch for mousedown (as a fall through to ensure that prepareImage() definitely
|
||||
// got called on an image tag before mouseup).
|
||||
//
|
||||
// Normally this should have happened via the onPreProcess/onSetContent listeners, but
|
||||
// for completeness we check once more here in case there are edge cases we've missed.
|
||||
ed.onMouseDown.add(function(ed, e) {
|
||||
var el = tinyMCE.activeEditor.selection.getNode();
|
||||
if (el.nodeName == 'IMG') {
|
||||
// prepare image for resizing
|
||||
prepareImage(ed, e.target);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
// Watch for mouseup (catch image resizes)
|
||||
ed.onMouseUp.add(function(ed, e) {
|
||||
var el = tinyMCE.activeEditor.selection.getNode();
|
||||
if (el.nodeName == 'IMG') {
|
||||
// setTimeout is necessary to allow the browser to complete the resize so we have new dimensions
|
||||
setTimeout(function() {
|
||||
constrainSize(ed, el);
|
||||
}, 100);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
/*****************************************************
|
||||
* ENFORCE CONSTRAINTS ON CONTENT INSERTED INTO EDITOR
|
||||
*****************************************************/
|
||||
|
||||
// Catch editor.setContent() events via onPreProcess (because onPreProcess allows us to
|
||||
// modify the DOM before it is inserted, unlike onSetContent)
|
||||
ed.onPreProcess.add(function(ed, o) {
|
||||
if (!o.set) return; // only 'set' operations let us modify the nodes
|
||||
|
||||
// loop in each img node and run constrainSize
|
||||
tinymce.each(ed.dom.select('img', o.node), function(currentNode) {
|
||||
constrainSize(ed, currentNode);
|
||||
});
|
||||
});
|
||||
|
||||
// To be complete, we also need to watch for setContent() calls on the selection object so that
|
||||
// constraints are enforced (i.e. in case an <img> tag is inserted via mceInsertContent).
|
||||
// So, catch all insertions using the editor's selection object
|
||||
ed.onInit.add(function(ed) {
|
||||
// http://wiki.moxiecode.com/index.php/TinyMCE:API/tinymce.dom.Selection/onSetContent
|
||||
ed.selection.onSetContent.add(function(se, o) {
|
||||
// @todo This seems to grab the entire editor contents - it works but could
|
||||
// perform poorly on large documents
|
||||
var currentNode = se.getNode();
|
||||
tinymce.each(ed.dom.select('img', currentNode), function (currentNode) {
|
||||
// IF condition required as tinyMCE inserts 24x24 placeholders uner some conditions
|
||||
if (currentNode.id != "__mce_tmp")
|
||||
constrainSize(ed, currentNode);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
/*****************************
|
||||
* DISALLOW EXTERNAL IMAGE DRAG/DROPS
|
||||
*****************************/
|
||||
// This is a hack. Listening for drag events wasn't working.
|
||||
//
|
||||
// Watches for mousedown and mouseup/dragdrop events within the editor. If a mouseup or
|
||||
// dragdrop occurs in the editor without a preceeding mousedown, we assume it is an external
|
||||
// dragdrop that should be rejected.
|
||||
if (ed.getParam('advimagescale_reject_external_dragdrop', true)) {
|
||||
|
||||
// catch mousedowns mouseups and dragdrops (which are basically mouseups too..)
|
||||
ed.onMouseDown.add(function(e) { edMouseDown = true; });
|
||||
ed.onMouseUp.add(function(e) { edMouseDown = false; });
|
||||
ed.onInit.add(function(ed, o) {
|
||||
tinymce.dom.Event.add(ed.getBody().parentNode, 'dragdrop', function(e) { edMouseDown = false; });
|
||||
});
|
||||
|
||||
// watch for drag attempts
|
||||
var evt = (tinymce.isIE) ? 'dragenter' : 'dragover'; // IE allows dragdrop reject on dragenter (more efficient)
|
||||
ed.onInit.add(function(ed, o) {
|
||||
// use parentNode to go above editor content, to cover entire editor area
|
||||
tinymce.dom.Event.add(ed.getBody().parentNode, evt, function (e) {
|
||||
if (!edMouseDown) {
|
||||
// disallow drop
|
||||
return tinymce.dom.Event.cancel(e);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns information about the plugin as a name/value array.
|
||||
* The current keys are longname, author, authorurl, infourl and version.
|
||||
*
|
||||
* @return {Object} Name/value array containing information about the plugin.
|
||||
*/
|
||||
getInfo : function() {
|
||||
return {
|
||||
longname : 'Advanced Image Resize Helper',
|
||||
author : 'Marc Hodgins',
|
||||
authorurl : 'http://www.hodginsmedia.com',
|
||||
infourl : 'http://code.google.com/p/tinymce-plugin-advimagescale',
|
||||
version : '1.1.2'
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// Register plugin
|
||||
tinymce.PluginManager.add('advimagescale', tinymce.plugins.AdvImageScale);
|
||||
|
||||
/**
|
||||
* Store image dimensions, pre-resize
|
||||
*
|
||||
* @param {object} el HTMLDomNode
|
||||
*/
|
||||
function storeDimensions(ed, el) {
|
||||
var dom = ed.dom;
|
||||
var elId = dom.getAttrib(el, 'mce_advimageresize_id');
|
||||
|
||||
// store original dimensions if this is the first resize of this element
|
||||
if (!originalDimensions[elId]) {
|
||||
originalDimensions[elId] = lastDimensions[elId] = {width: dom.getAttrib(el, 'width', el.width), height: dom.getAttrib(el, 'height', el.height)};
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare image for resizing
|
||||
* Check to see if we've seen this IMG tag before; does tasks such as adding
|
||||
* unique IDs to image tags, saving "original" image dimensions, etc.
|
||||
* @param {object} e is optional
|
||||
*/
|
||||
function prepareImage(ed, el) {
|
||||
var dom = ed.dom;
|
||||
var elId= dom.getAttrib(el, 'mce_advimageresize_id');
|
||||
|
||||
// is this the first time this image tag has been seen?
|
||||
if (!elId) {
|
||||
var elId = ed.dom.uniqueId();
|
||||
dom.setAttrib(el, 'mce_advimageresize_id', elId);
|
||||
storeDimensions(ed, el);
|
||||
}
|
||||
|
||||
return elId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjusts width and height to keep within min/max bounds and also maintain aspect ratio
|
||||
* If mce_noresize attribute is set to image tag, then image resize is disallowed
|
||||
*/
|
||||
function constrainSize(ed, el, e) {
|
||||
var dom = ed.dom;
|
||||
var elId = prepareImage(ed, el); // also calls storeDimensions
|
||||
var resized = (dom.getAttrib(el, 'width') != lastDimensions[elId].width || dom.getAttrib(el, 'height') != lastDimensions[elId].height);
|
||||
|
||||
if (!resized)
|
||||
return; // nothing to do
|
||||
|
||||
// disallow image resize if mce_noresize or the noresize class is set on the image tag
|
||||
if (dom.getAttrib(el, 'mce_noresize') || dom.hasClass(el, ed.getParam('advimagescale_noresize_class', 'noresize')) || ed.getParam('advimagescale_noresize_all')) {
|
||||
dom.setAttrib(el, 'width', lastDimensions[elId].width);
|
||||
dom.setAttrib(el, 'height', lastDimensions[elId].height);
|
||||
if (tinymce.isGecko)
|
||||
fixGeckoHandles(ed);
|
||||
return;
|
||||
}
|
||||
|
||||
// Both IE7 and Gecko (as of FF3.0.03) has a "expands image by border width" bug before doing anything else
|
||||
if (ed.getParam('advimagescale_fix_border_glitch', true /* default to true */)) {
|
||||
fixImageBorderGlitch(ed, el);
|
||||
storeDimensions(ed, el); // store adjusted dimensions
|
||||
}
|
||||
|
||||
// filter by regexp so only some images get constrained
|
||||
var src_filter = ed.getParam('advimagescale_filter_src');
|
||||
if (src_filter) {
|
||||
var r = new RegExp(src_filter);
|
||||
if (!el.src.match(r)) {
|
||||
return; // skip this element
|
||||
}
|
||||
}
|
||||
|
||||
// allow filtering by classname
|
||||
var class_filter = ed.getParam('advimagescale_filter_class');
|
||||
if (class_filter) {
|
||||
if (!dom.hasClass(el, class_filter)) {
|
||||
return; // skip this element, doesn't have the class we want
|
||||
}
|
||||
}
|
||||
|
||||
// populate new dimensions object
|
||||
var newDimensions = { width: dom.getAttrib(el, 'width', el.width), height: dom.getAttrib(el, 'height', el.height) };
|
||||
|
||||
// adjust w/h to maintain aspect ratio
|
||||
if (ed.getParam('advimagescale_maintain_aspect_ratio', true /* default to true */)) {
|
||||
newDimensions = maintainAspect(ed, el, newDimensions.width, newDimensions.height);
|
||||
}
|
||||
|
||||
// enforce minW/minH/maxW/maxH
|
||||
newDimensions = checkBoundaries(ed, el, newDimensions.width, newDimensions.height);
|
||||
|
||||
// was an adjustment made?
|
||||
var adjusted = (dom.getAttrib(el, 'width', el.width) != newDimensions.width || dom.getAttrib(el, 'height', el.height) != newDimensions.height);
|
||||
|
||||
// apply new w/h
|
||||
if (adjusted) {
|
||||
dom.setAttrib(el, 'width', newDimensions.width);
|
||||
dom.setAttrib(el, 'height', newDimensions.height);
|
||||
if (tinymce.isGecko) fixGeckoHandles(ed);
|
||||
}
|
||||
|
||||
if (ed.getParam('advimagescale_append_to_url')) {
|
||||
appendToUri(ed, el, dom.getAttrib(el, 'width', el.width), dom.getAttrib(el, 'height', el.height));
|
||||
}
|
||||
|
||||
// was the image resized?
|
||||
if (lastDimensions[elId].width != dom.getAttrib(el, 'width', el.width) || lastDimensions[elId].height != dom.getAttrib(el, 'height', el.height)) {
|
||||
// call "image resized" callback (if set)
|
||||
if (ed.getParam('advimagescale_resize_callback')) {
|
||||
ed.getParam('advimagescale_resize_callback')(ed, el);
|
||||
}
|
||||
}
|
||||
|
||||
// remember "last dimensions" for next time
|
||||
lastDimensions[elId] = { width: dom.getAttrib(el, 'width', el.width), height: dom.getAttrib(el, 'height', el.height) };
|
||||
}
|
||||
|
||||
/**
|
||||
* Fixes IE7 and Gecko border width glitch
|
||||
*
|
||||
* Both "add" the border width to an image after the resize handles have been
|
||||
* dropped. This reverses it by looking at the "previous" known size and comparing
|
||||
* to the current size. If they don't match, then a resize has taken place and the browser
|
||||
* has (probably) messed it up. So, we reverse it. Note, this will probably need to be
|
||||
* wrapped in a conditional statement if/when each browser fixes this bug.
|
||||
*/
|
||||
function fixImageBorderGlitch(ed, el) {
|
||||
var dom = ed.dom;
|
||||
var elId = dom.getAttrib(el, 'mce_advimageresize_id');
|
||||
var currentWidth = dom.getAttrib(el, 'width', el.width);
|
||||
var currentHeight= dom.getAttrib(el, 'height', el.height);
|
||||
var adjusted = false;
|
||||
|
||||
// if current dimensions do not match what we last saw, then a resize has taken place
|
||||
if (currentWidth != lastDimensions[elId].width) {
|
||||
var adjustWidth = 0;
|
||||
|
||||
// get computed border left/right widths
|
||||
adjustWidth += parseInt(dom.getStyle(el, 'borderLeftWidth', 'borderLeftWidth'));
|
||||
adjustWidth += parseInt(dom.getStyle(el, 'borderRightWidth', 'borderRightWidth'));
|
||||
|
||||
// reset the width height to NOT include these amounts
|
||||
if (adjustWidth > 0) {
|
||||
dom.setAttrib(el, 'width', (currentWidth - adjustWidth));
|
||||
adjusted = true;
|
||||
}
|
||||
}
|
||||
if (currentHeight != lastDimensions[elId].height) {
|
||||
var adjustHeight = 0;
|
||||
|
||||
// get computed border top/bottom widths
|
||||
adjustHeight += parseInt(dom.getStyle(el, 'borderTopWidth', 'borderTopWidth'));
|
||||
adjustHeight += parseInt(dom.getStyle(el, 'borderBottomWidth', 'borderBottomWidth'));
|
||||
|
||||
if (adjustHeight > 0) {
|
||||
dom.setAttrib(el, 'height', (currentHeight - adjustHeight));
|
||||
adjusted = true;
|
||||
}
|
||||
}
|
||||
if (adjusted && tinymce.isGecko) fixGeckoHandles(ed);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix gecko resize handles glitch
|
||||
*/
|
||||
function fixGeckoHandles(ed) {
|
||||
ed.execCommand('mceRepaint', false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set image dimensions on into a uri as querystring params
|
||||
*/
|
||||
function appendToUri(ed, el, w, h) {
|
||||
var dom = ed.dom;
|
||||
var uri = dom.getAttrib(el, 'src');
|
||||
var wKey = ed.getParam('advimagescale_url_width_key', 'w');
|
||||
uri = setQueryParam(uri, wKey, w);
|
||||
var hKey = ed.getParam('advimagescale_url_height_key', 'h');
|
||||
uri = setQueryParam(uri, hKey, h);
|
||||
|
||||
// no need to continue if URL didn't change
|
||||
if (uri == dom.getAttrib(el, 'src')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// trigger image loading callback (if set)
|
||||
if (ed.getParam('advimagescale_loading_callback')) {
|
||||
// call loading callback
|
||||
ed.getParam('advimagescale_loading_callback')(el);
|
||||
}
|
||||
// hook image load(ed) callback (if set)
|
||||
if (ed.getParam('advimagescale_loaded_callback')) {
|
||||
// hook load event on the image tag to call the loaded callback
|
||||
tinymce.dom.Event.add(el, 'load', imageLoadedCallback, {el: el, ed: ed});
|
||||
}
|
||||
|
||||
// set new src
|
||||
dom.setAttrib(el, 'src', uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback event when an image is (re)loaded
|
||||
* @param {object} e Event (use e.target or this.el to access element, this.ed to access editor instance)
|
||||
*/
|
||||
function imageLoadedCallback(e) {
|
||||
var el = this.el; // image element
|
||||
var ed = this.ed; // editor
|
||||
var callback = ed.getParam('advimagescale_loaded_callback'); // user specified callback
|
||||
|
||||
// call callback, pass img as param
|
||||
callback(el);
|
||||
|
||||
// remove callback event
|
||||
tinymce.dom.Event.remove(el, 'load', imageLoadedCallback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets URL querystring parameters by appending or replacing existing params of same name
|
||||
*/
|
||||
function setQueryParam(uri, key, value) {
|
||||
if (!uri.match(/\?/)) uri += '?';
|
||||
if (!uri.match(new RegExp('([\?&])' + key + '='))) {
|
||||
if (!uri.match(/[&\?]$/)) uri += '&';
|
||||
uri += key + '=' + escape(value);
|
||||
} else {
|
||||
uri = uri.replace(new RegExp('([\?\&])' + key + '=[^&]*'), '$1' + key + '=' + escape(value));
|
||||
}
|
||||
return uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns w/h that maintain aspect ratio
|
||||
*/
|
||||
function maintainAspect(ed, el, w, h) {
|
||||
var elId = ed.dom.getAttrib(el, 'mce_advimageresize_id');
|
||||
|
||||
// calculate aspect ratio of original so we can maintain it
|
||||
var ratio = originalDimensions[elId].width / originalDimensions[elId].height;
|
||||
|
||||
// decide which dimension changed more (percentage), because that's the
|
||||
// one we'll respect (the other we'll adjust to keep aspect ratio)
|
||||
var lastW = lastDimensions[elId].width;
|
||||
var lastH = lastDimensions[elId].height;
|
||||
var deltaW = Math.abs(lastW - w); // absolute
|
||||
var deltaH = Math.abs(lastH - h); // absolute
|
||||
var pctW = Math.abs(deltaW / lastW); // percentage
|
||||
var pctH = Math.abs(deltaH / lastH); // percentage
|
||||
|
||||
if (deltaW || deltaH) {
|
||||
if (pctW > pctH) {
|
||||
// width changed more - use that as the locked point and adjust height
|
||||
return { width: w, height: Math.round(w / ratio) };
|
||||
} else {
|
||||
// height changed more - use that as the locked point and adjust width
|
||||
return { width: Math.round(h * ratio), height: h };
|
||||
}
|
||||
}
|
||||
|
||||
// nothing changed
|
||||
return { width: w, height: h };
|
||||
}
|
||||
|
||||
/**
|
||||
* Enforce min/max boundaries
|
||||
*
|
||||
* Returns true if an adjustment was made
|
||||
*/
|
||||
function checkBoundaries(ed, el, w, h) {
|
||||
|
||||
var elId = ed.dom.getAttrib(el, 'mce_advimageresize_id');
|
||||
var maxW = ed.getParam('advimagescale_max_width');
|
||||
var maxH = ed.getParam('advimagescale_max_height');
|
||||
var minW = ed.getParam('advimagescale_min_width');
|
||||
var minH = ed.getParam('advimagescale_min_height');
|
||||
var maintainAspect = ed.getParam('advimagescale_maintain_aspect_ratio', true);
|
||||
var oW = originalDimensions[elId].width;
|
||||
var oH = originalDimensions[elId].height;
|
||||
var ratio = oW/oH;
|
||||
|
||||
// max
|
||||
if (maxW && w > maxW) {
|
||||
w = maxW;
|
||||
h = maintainAspect ? Math.round(w / ratio) : h;
|
||||
}
|
||||
if (maxH && h > maxH) {
|
||||
h = maxH;
|
||||
w = maintainAspect ? Math.round(h * ratio) : w;
|
||||
}
|
||||
|
||||
// min
|
||||
if (minW && w < minW) {
|
||||
w = minW;
|
||||
h = maintainAspect ? Math.round(w / ratio) : h;
|
||||
}
|
||||
if (minH && h < minH) {
|
||||
h = minH;
|
||||
w = maintainAspect ? Math.round(h * ratio) : h;
|
||||
}
|
||||
|
||||
return { width: w, height:h };
|
||||
}
|
||||
|
||||
})();
|
337
sn_templates/editor_stuff/plugin/bbcode/editor_plugin.js
Normal file
@@ -0,0 +1,337 @@
|
||||
/**
|
||||
* $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $
|
||||
*
|
||||
* @author Moxiecode
|
||||
* @copyright Copyright <20> 2004-2008, Moxiecode Systems AB, All rights reserved.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
tinymce.create('tinymce.plugins.BBCodePlugin', {
|
||||
init : function(ed, url) {
|
||||
var t = this, dialect = ed.getParam('bbcode_dialect', 'punbb').toLowerCase();
|
||||
|
||||
ed.onBeforeSetContent.add(function(ed, o) {
|
||||
o.content = t['_' + dialect + '_bbcode2html'](o.content);
|
||||
});
|
||||
|
||||
ed.onSaveContent.add(function(ed, o) {
|
||||
o.content = t['_' + dialect + '_html2bbcode'](o.content);
|
||||
});
|
||||
|
||||
ed.onPostProcess.add(function(ed, o) {
|
||||
if (o.set)
|
||||
o.content = t['_' + dialect + '_bbcode2html'](o.content);
|
||||
|
||||
// if (o.get)
|
||||
// o.content = t['_' + dialect + '_html2bbcode'](o.content);
|
||||
});
|
||||
},
|
||||
|
||||
getInfo : function() {
|
||||
return {
|
||||
longname : 'BBCode Plugin',
|
||||
author : 'Moxiecode Systems AB',
|
||||
authorurl : 'http://tinymce.moxiecode.com',
|
||||
infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/bbcode',
|
||||
version : tinymce.majorVersion + "." + tinymce.minorVersion
|
||||
};
|
||||
},
|
||||
|
||||
// Private methods
|
||||
|
||||
// HTML -> BBCode in PunBB dialect
|
||||
_punbb_html2bbcode : function(s) {
|
||||
// alert("html2bbcode");
|
||||
s = tinymce.trim(s);
|
||||
|
||||
function rep(re, str) {
|
||||
s = s.replace(re, str);
|
||||
};
|
||||
|
||||
// rep(/(.*?>)[\n|\r]/g,"$1");
|
||||
rep(/[\n\r]{0,1}(<(ol|ul).*?>)[\n\r]{0,1}/g,"$1");
|
||||
rep(/(<\/(ul|ol|li)>)[\n\r]/g,"$1");
|
||||
|
||||
// bbcode of img for sn article
|
||||
while(/(<img class=\"(.+?)\" .+?>)/.test(s)){
|
||||
var _res = RegExp.$1;
|
||||
var _typ = RegExp.$2;
|
||||
var _rpl = "";
|
||||
|
||||
if(_typ == 'snVideo'){
|
||||
var _w = /width=\"(.*?)\"/.test(_res) ? RegExp.$1+';':'';
|
||||
var _h = /height=\"(.*?)\"/.test(_res) ? RegExp.$1+';':'';
|
||||
var _p = /alt=\"(.*?)\"/.test(_res) ? RegExp.$1:'';
|
||||
var _v = /title=\"(.*?)\"/.test(_res) ? RegExp.$1+';':'';
|
||||
_rpl = '[video='+_v+_w+_h+_p+']';
|
||||
} else{
|
||||
var _p = (/src=\"(.*?)\"/.test(_res) ? RegExp.$1:'').split('/').pop();
|
||||
var _f = (/alt=\"(.*?)\"/.test(_res) ? RegExp.$1:'').split('/').pop();
|
||||
var _s = (/style=\"float:(.*?);\"/.test(_res) ? RegExp.$1:'').replace(/ /g,'');
|
||||
var _i = 'img';
|
||||
switch(_s){
|
||||
case 'left':
|
||||
_i = 'imgl';
|
||||
break;
|
||||
case 'right':
|
||||
_i = 'imgr';
|
||||
break;
|
||||
|
||||
}
|
||||
_rpl = '['+_i+'='+_f+']'+_p+'[/'+_i+']';
|
||||
}
|
||||
|
||||
s = s.replace(_res,_rpl);
|
||||
}
|
||||
|
||||
//////
|
||||
|
||||
// replace list html-codeStyle
|
||||
var rl = new Array();
|
||||
rl[0] = {o:"[list]",c:"[/list]",f:/<ul>/};
|
||||
rl[1] = {o:"[list=d]",c:"[/list]",f:/<ul style="list-style-type: disc;">/};
|
||||
rl[2] = {o:"[list=c]",c:"[/list]",f:/<ul style="list-style-type: circle;">/};
|
||||
rl[3] = {o:"[list=s]",c:"[/list]",f:/<ul style="list-style-type: square;">/};
|
||||
|
||||
rl[4] = {o:"[list=i]",c:"[/list]",f:/<ol style="list-style-type: lower-roman;">/};
|
||||
rl[5] = {o:"[list=I]",c:"[/list]",f:/<ol style="list-style-type: upper-roman;">/};
|
||||
rl[6] = {o:"[list=a]",c:"[/list]",f:/<ol style="list-style-type: lower-alpha;">/};
|
||||
rl[7] = {o:"[list=A]",c:"[/list]",f:/<ol style="list-style-type: upper-alpha;">/};
|
||||
rl[8] = {o:"[list=1]",c:"[/list]",f:/<ol style="list-style-type: decimal;">/};
|
||||
rl[9] = {o:"[list=1]",c:"[/list]",f:/<ol>/};
|
||||
|
||||
|
||||
var cl = new Array();
|
||||
do{
|
||||
var p = s.search(/<\/ol>|<\/ul>/);
|
||||
var re = "";
|
||||
|
||||
for(var i = 0; i < rl.length; i++){
|
||||
var np = s.search(rl[i].f);
|
||||
|
||||
if(np != -1 && p > np){
|
||||
p = np;
|
||||
cl[cl.length] = rl[i];
|
||||
re = rl[i].f;
|
||||
}
|
||||
}
|
||||
|
||||
if(cl.length > 0){
|
||||
if(re == ""){
|
||||
s = s.replace(/<\/ol>|<\/ul>/,cl.pop().c);
|
||||
}else{
|
||||
s = s.replace(re, cl[cl.length-1].o);
|
||||
}
|
||||
}
|
||||
}while(cl.length > 0 || s.search(/<(ol|ul).*?>/) != -1 );
|
||||
|
||||
// s = s.replace(/<li>(.*?)<\/li>/g,"[*]$1[/*]");
|
||||
|
||||
s = s.replace(/<li>/g,"[*]");
|
||||
s = s.replace(/<\/li>/g,"[/*]");
|
||||
|
||||
while(s.match(/<a(.*?)>(.*?)<\/a>/i)){
|
||||
var lnkh = RegExp.$1;
|
||||
var lnkt = RegExp.$2;
|
||||
lnkh.match(/title=\"(.+?)\"/);
|
||||
var title = RegExp.$1;
|
||||
lnkh.match(/href=\"(.+?)\"/);
|
||||
var href = RegExp.$1;
|
||||
|
||||
if(title!=href){
|
||||
url = "[xurl="+href+"|"+title+"]"+lnkt+"[/url]";
|
||||
}else{
|
||||
url = "[url="+href+"]"+lnkt+"[/url]";
|
||||
}
|
||||
s = s.replace(/<a(.*?)>(.*?)<\/a>/i, url);
|
||||
}
|
||||
|
||||
rep(/<a.*?href=\"(.*?)\".*?>(.*?)<\/a>/gi,"[url=$1]$2[/url]");
|
||||
|
||||
|
||||
rep(/<(h[1|2|3])>(.*?)<\/(h[1|2|3])>/gi,"[$1]$2[/$3]");
|
||||
|
||||
rep(/<sup>(.*?)<\/sup>/gi,"[sup]$1[/sup]");
|
||||
rep(/<sub>(.*?)<\/sub>/gi,"[sub]$1[/sub]");
|
||||
|
||||
|
||||
|
||||
|
||||
// rep(/<font.*?color=\"(.*?)\".*?class=\"codeStyle\".*?>(.*?)<\/font>/gi,"[code][color=$1]$2[/color][/code]");
|
||||
// rep(/<font.*?color=\"(.*?)\".*?class=\"quoteStyle\".*?>(.*?)<\/font>/gi,"[quote][color=$1]$2[/color][/quote]");
|
||||
// rep(/<font.*?class=\"codeStyle\".*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[code][color=$1]$2[/color][/code]");
|
||||
// rep(/<font.*?class=\"quoteStyle\".*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[quote][color=$1]$2[/color][/quote]");
|
||||
// rep(/<span style=\"color: ?(.*?);\">(.*?)<\/span>/gi,"[color=$1]$2[/color]");
|
||||
// // rep(/<font.*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[color=$1]$2[/color]");
|
||||
// rep(/<span style=\"font-size:(.*?);\">(.*?)<\/span>/gi,"[size=$1]$2[/size]");
|
||||
// rep(/<font>(.*?)<\/font>/gi,"$1");
|
||||
|
||||
s = s.replace(/<span class=\"snInfoBoxHead\".*?>(.+?)<\/span>/g,"[boxhead]$1[/boxhead]");
|
||||
|
||||
while(s.match(/<span class=\"snInfoBox\" style=\"(.+?)\">(.+?)<\/span>/)){
|
||||
var l = RegExp.$1; var c = RegExp.$2;
|
||||
var b = l.indexOf("float: left") != -1 ? "infol":"infor";
|
||||
var w = "";
|
||||
|
||||
if(l.match(/width:(.+?);.+/)){
|
||||
var _cwn = parseInt(RegExp.$1);
|
||||
if(!isNaN(_cwn)){
|
||||
w = "="+_cwn;
|
||||
}
|
||||
}
|
||||
|
||||
s = s.replace(/<span class=\"snInfoBox\" style=\"(.+?)\">(.+?)<\/span>/,"["+b+w+"]"+c+"[/"+b+"]");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
rep(/<code>(.*?)<\/code>/gi,"[code]$1[/code]");
|
||||
rep(/<blockquote>(.*?)<\/blockquote>/gi,"[quote]$1[/quote]");
|
||||
rep(/<\/(strong|b)>/gi,"[/b]");
|
||||
rep(/<(strong|b)>/gi,"[b]");
|
||||
rep(/<\/(em|i)>/gi,"[/i]");
|
||||
rep(/<(em|i)>/gi,"[i]");
|
||||
rep(/<\/u>/gi,"[/u]");
|
||||
rep(/<span style=\"text-decoration: ?underline;\">(.*?)<\/span>/gi,"[u]$1[/u]");
|
||||
rep(/<u>/gi,"[u]");
|
||||
rep(/<blockquote[^>]*>/gi,"[quote]");
|
||||
rep(/<\/blockquote>/gi,"[/quote]");
|
||||
rep(/<br \/>/gi,"\n");
|
||||
rep(/<br\/>/gi,"\n");
|
||||
rep(/<br>/gi,"\n");
|
||||
rep(/<p(.*?)>/gi,"");
|
||||
rep(/<\/p>/gi,"\n");
|
||||
rep(/ /gi," ");
|
||||
rep(/"/gi,"\"");
|
||||
rep(/</gi,"<");
|
||||
rep(/>/gi,">");
|
||||
rep(/&/gi,"&");
|
||||
|
||||
rep(/\[\/(tr|td|table)\]\n/gi,"[/$1]");
|
||||
rep(/\[(tr|table|td)\]\n/gi,"[$1]");
|
||||
|
||||
|
||||
return s;
|
||||
},
|
||||
|
||||
// BBCode -> HTML from PunBB dialect
|
||||
_punbb_bbcode2html : function(s) {
|
||||
s = tinymce.trim(s);
|
||||
// alert("bbcode2html");
|
||||
function rep(re, str) {
|
||||
s = s.replace(re, str);
|
||||
};
|
||||
|
||||
var img_path = (tinyMCE.activeEditor.getParam("snstuff_img_url_image") || "/articleimage/{artikelid}/").replace(/\{artikelid\}/g,parent.entryid);
|
||||
img_path = img_path.replace(/\{imgname\}/g,"");
|
||||
|
||||
rep(/\[imgl=(.*?)\](.*?)\[\/imgl\]/gi,"<img class=\"noresize\" style=\"float:left;\" src=\""+img_path+"$2\" alt=\"$1\"/>");
|
||||
rep(/\[imgr=(.*?)\](.*?)\[\/imgr\]/gi,"<img class=\"noresize\" style=\"float:right;\" src=\""+img_path+"$2\" alt=\"$1\"/>");
|
||||
rep(/\[img=(.*?)\](.*?)\[\/img\]/gi,"<img class=\"noresize\" src=\""+img_path+"$2\" alt=\"$1\"/>");
|
||||
|
||||
|
||||
while(/(\[video=(.*?)\])/.test(s)){
|
||||
var _res = RegExp.$1;
|
||||
var _l = RegExp.$2.split(';');
|
||||
var _rpl = '<img class="snVideo" src="/editor_stuff/plugin/snstuff/images/trans.gif" title="'+_l[0]+'" width="'+parseInt(_l[1])+'" height="'+parseInt(_l[2])+'" ';
|
||||
_rpl += _l[3]?'alt="'+_l[3]+'" />':'/>';
|
||||
s = s.replace(_res,_rpl);
|
||||
}
|
||||
|
||||
// replace list bbcode
|
||||
var rl = new Array();
|
||||
rl[0] = {f:/\[list\]/, o:"<ul style=\"list-style-type: disc;\">",c:"</ul>"};
|
||||
rl[1] = {f:/\[list=d\]/, o:"<ul style=\"list-style-type: disc;\">",c:"</ul>"};
|
||||
rl[2] = {f:/\[list=s\]/, o:"<ul style=\"list-style-type: square;\">",c:"</ul>"};
|
||||
rl[3] = {f:/\[list=c\]/, o:"<ul style=\"list-style-type: circle;\">",c:"</ul>"};
|
||||
|
||||
rl[4] = {f:/\[list=1\]/, o:"<ol style=\"list-style-type: decimal;\">",c:"</ol>"};
|
||||
rl[5] = {f:/\[list=i\]/, o:"<ol style=\"list-style-type: lower-roman;\">",c:"</ol>"};
|
||||
rl[6] = {f:/\[list=I\]/, o:"<ol style=\"list-style-type: upper-roman;\">",c:"</ol>"};
|
||||
rl[7] = {f:/\[list=a\]/, o:"<ol style=\"list-style-type: lower-alpha;\">",c:"</ol>"};
|
||||
rl[8] = {f:/\[list=A\]/, o:"<ol style=\"list-style-type: upper-alpha;\">",c:"</ol>"};
|
||||
|
||||
var cl = new Array();
|
||||
do{
|
||||
var p = s.search(/\[\/list\]/);
|
||||
var re = "";
|
||||
|
||||
for(var i = 0; i < rl.length; i++){
|
||||
var np = s.search(rl[i].f);
|
||||
|
||||
if(np != -1 && p > np){
|
||||
p = np;
|
||||
cl[cl.length] = rl[i];
|
||||
re = rl[i].f;
|
||||
}
|
||||
}
|
||||
if(cl.length > 0){
|
||||
if(re == ""){
|
||||
s = s.replace(/\[\/list\]/,cl.pop().c);
|
||||
}else{
|
||||
s = s.replace(re, cl[cl.length-1].o);
|
||||
}
|
||||
}
|
||||
}while(cl.length > 0 || s.search(/\[list.*?\]/) != -1);
|
||||
|
||||
|
||||
s = s.replace(/\[\/\*\]/g,"</li>");
|
||||
s = s.replace(/\[\*\]/g,"<li>");
|
||||
|
||||
|
||||
s = s.replace(/\[infor\]/mg,"<span class=\"snInfoBox\" style=\"width:100px; float: right;\">");
|
||||
s = s.replace(/\[infol\]/mg,"<span class=\"snInfoBox\" style=\"width:100px; float: left;\">");
|
||||
|
||||
s = s.replace(/\[infor=(.+?){0,1}\]/mg,"<span class=\"snInfoBox\" style=\"width:$1px; float: right;\">");
|
||||
s = s.replace(/\[infol=(.+?){0,1}\]/mg,"<span class=\"snInfoBox\" style=\"width:$1px; float: left;\">");
|
||||
|
||||
s = s.replace(/\[\/(infor|infol)\]/g,"</span>");
|
||||
|
||||
s = s.replace(/\[boxhead\]/g,"<span class=\"snInfoBoxHead\">");
|
||||
s = s.replace(/\[\/boxhead\]/g,"</span>");
|
||||
|
||||
|
||||
// example: [b] to <strong>
|
||||
|
||||
rep(/\[b\]/gi,"<strong>");
|
||||
rep(/\[\/b\]/gi,"</strong>");
|
||||
rep(/\[i\]/gi,"<em>");
|
||||
rep(/\[\/i\]/gi,"</em>");
|
||||
rep(/\[u\]/gi,"<u>");
|
||||
rep(/\[\/u\]/gi,"</u>");
|
||||
rep(/\[url=([^\]]+)\](.*?)\[\/url\]/gi,"<a href=\"$1\" title=\"$1\">$2</a>");
|
||||
rep(/\[xurl=([^\]]+)\|(.*?)\](.*?)\[\/url\]/gi,"<a href=\"$1\" title=\"$2\">$3</a>");
|
||||
|
||||
rep(/\[url\](.*?)\[\/url\]/gi,"<a href=\"$1\" title=\"$1\">$1</a>");
|
||||
// rep(/\[img\](.*?)\[\/img\]/gi,"<img src=\"$1\" />");
|
||||
rep(/\[color=(.*?)\](.*?)\[\/color\]/gi,"<font color=\"$1\">$2</font>");
|
||||
rep(/\[code\](.*?)\[\/code\]/gi,"<code>$1</code>");
|
||||
rep(/\[quote.*?\](.*?)\[\/quote\]/gi,"<blockquote>$1</blockquote>");
|
||||
|
||||
|
||||
rep(/\[(h[1|2|3])\](.*?)\[\/(h[1|2|3])\]/gi,"<$1>$2</$3>");
|
||||
rep(/(<\/h[1|2|3]>)\n/gi,"$1");
|
||||
rep(/\n(<h[1|2|3]>)/gi,"$1");
|
||||
|
||||
|
||||
|
||||
rep(/\[sup\](.*?)\[\/sup\]/gi,"<sup>$1</sup>");
|
||||
rep(/\[sub\](.*?)\[\/sub\]/gi,"<sub>$1</sub>");
|
||||
|
||||
/*
|
||||
rep(/\[\/(tr|td|table)\]/gi,"[/$1]");
|
||||
rep(/\[(tr|table)\]/gi,"[$1]");*/
|
||||
|
||||
|
||||
rep(/\n/gi,"<br />");
|
||||
|
||||
|
||||
|
||||
return s;
|
||||
}
|
||||
});
|
||||
|
||||
// Register plugin
|
||||
tinymce.PluginManager.add('bbcode', tinymce.plugins.BBCodePlugin);
|
||||
})();
|
337
sn_templates/editor_stuff/plugin/bbcode/editor_plugin_src.js
Normal file
@@ -0,0 +1,337 @@
|
||||
/**
|
||||
* $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $
|
||||
*
|
||||
* @author Moxiecode
|
||||
* @copyright Copyright <20> 2004-2008, Moxiecode Systems AB, All rights reserved.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
tinymce.create('tinymce.plugins.BBCodePlugin', {
|
||||
init : function(ed, url) {
|
||||
var t = this, dialect = ed.getParam('bbcode_dialect', 'punbb').toLowerCase();
|
||||
|
||||
ed.onBeforeSetContent.add(function(ed, o) {
|
||||
o.content = t['_' + dialect + '_bbcode2html'](o.content);
|
||||
});
|
||||
|
||||
ed.onSaveContent.add(function(ed, o) {
|
||||
o.content = t['_' + dialect + '_html2bbcode'](o.content);
|
||||
});
|
||||
|
||||
ed.onPostProcess.add(function(ed, o) {
|
||||
if (o.set)
|
||||
o.content = t['_' + dialect + '_bbcode2html'](o.content);
|
||||
|
||||
// if (o.get)
|
||||
// o.content = t['_' + dialect + '_html2bbcode'](o.content);
|
||||
});
|
||||
},
|
||||
|
||||
getInfo : function() {
|
||||
return {
|
||||
longname : 'BBCode Plugin',
|
||||
author : 'Moxiecode Systems AB',
|
||||
authorurl : 'http://tinymce.moxiecode.com',
|
||||
infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/bbcode',
|
||||
version : tinymce.majorVersion + "." + tinymce.minorVersion
|
||||
};
|
||||
},
|
||||
|
||||
// Private methods
|
||||
|
||||
// HTML -> BBCode in PunBB dialect
|
||||
_punbb_html2bbcode : function(s) {
|
||||
// alert("html2bbcode");
|
||||
s = tinymce.trim(s);
|
||||
|
||||
function rep(re, str) {
|
||||
s = s.replace(re, str);
|
||||
};
|
||||
|
||||
// rep(/(.*?>)[\n|\r]/g,"$1");
|
||||
rep(/[\n\r]{0,1}(<(ol|ul).*?>)[\n\r]{0,1}/g,"$1");
|
||||
rep(/(<\/(ul|ol|li)>)[\n\r]/g,"$1");
|
||||
|
||||
// bbcode of img for sn article
|
||||
while(/(<img class=\"(.+?)\" .+?>)/.test(s)){
|
||||
var _res = RegExp.$1;
|
||||
var _typ = RegExp.$2;
|
||||
var _rpl = "";
|
||||
|
||||
if(_typ == 'snVideo'){
|
||||
var _w = /width=\"(.*?)\"/.test(_res) ? RegExp.$1+';':'';
|
||||
var _h = /height=\"(.*?)\"/.test(_res) ? RegExp.$1+';':'';
|
||||
var _p = /alt=\"(.*?)\"/.test(_res) ? RegExp.$1:'';
|
||||
var _v = /title=\"(.*?)\"/.test(_res) ? RegExp.$1+';':'';
|
||||
_rpl = '[video='+_v+_w+_h+_p+']';
|
||||
} else{
|
||||
var _p = (/src=\"(.*?)\"/.test(_res) ? RegExp.$1:'').split('/').pop();
|
||||
var _f = (/alt=\"(.*?)\"/.test(_res) ? RegExp.$1:'').split('/').pop();
|
||||
var _s = (/style=\"float:(.*?);\"/.test(_res) ? RegExp.$1:'').replace(/ /g,'');
|
||||
var _i = 'img';
|
||||
switch(_s){
|
||||
case 'left':
|
||||
_i = 'imgl';
|
||||
break;
|
||||
case 'right':
|
||||
_i = 'imgr';
|
||||
break;
|
||||
|
||||
}
|
||||
_rpl = '['+_i+'='+_f+']'+_p+'[/'+_i+']';
|
||||
}
|
||||
|
||||
s = s.replace(_res,_rpl);
|
||||
}
|
||||
|
||||
//////
|
||||
|
||||
// replace list html-codeStyle
|
||||
var rl = new Array();
|
||||
rl[0] = {o:"[list]",c:"[/list]",f:/<ul>/};
|
||||
rl[1] = {o:"[list=d]",c:"[/list]",f:/<ul style="list-style-type: disc;">/};
|
||||
rl[2] = {o:"[list=c]",c:"[/list]",f:/<ul style="list-style-type: circle;">/};
|
||||
rl[3] = {o:"[list=s]",c:"[/list]",f:/<ul style="list-style-type: square;">/};
|
||||
|
||||
rl[4] = {o:"[list=i]",c:"[/list]",f:/<ol style="list-style-type: lower-roman;">/};
|
||||
rl[5] = {o:"[list=I]",c:"[/list]",f:/<ol style="list-style-type: upper-roman;">/};
|
||||
rl[6] = {o:"[list=a]",c:"[/list]",f:/<ol style="list-style-type: lower-alpha;">/};
|
||||
rl[7] = {o:"[list=A]",c:"[/list]",f:/<ol style="list-style-type: upper-alpha;">/};
|
||||
rl[8] = {o:"[list=1]",c:"[/list]",f:/<ol style="list-style-type: decimal;">/};
|
||||
rl[9] = {o:"[list=1]",c:"[/list]",f:/<ol>/};
|
||||
|
||||
|
||||
var cl = new Array();
|
||||
do{
|
||||
var p = s.search(/<\/ol>|<\/ul>/);
|
||||
var re = "";
|
||||
|
||||
for(var i = 0; i < rl.length; i++){
|
||||
var np = s.search(rl[i].f);
|
||||
|
||||
if(np != -1 && p > np){
|
||||
p = np;
|
||||
cl[cl.length] = rl[i];
|
||||
re = rl[i].f;
|
||||
}
|
||||
}
|
||||
|
||||
if(cl.length > 0){
|
||||
if(re == ""){
|
||||
s = s.replace(/<\/ol>|<\/ul>/,cl.pop().c);
|
||||
}else{
|
||||
s = s.replace(re, cl[cl.length-1].o);
|
||||
}
|
||||
}
|
||||
}while(cl.length > 0 || s.search(/<(ol|ul).*?>/) != -1 );
|
||||
|
||||
// s = s.replace(/<li>(.*?)<\/li>/g,"[*]$1[/*]");
|
||||
|
||||
s = s.replace(/<li>/g,"[*]");
|
||||
s = s.replace(/<\/li>/g,"[/*]");
|
||||
|
||||
while(s.match(/<a(.*?)>(.*?)<\/a>/i)){
|
||||
var lnkh = RegExp.$1;
|
||||
var lnkt = RegExp.$2;
|
||||
lnkh.match(/title=\"(.+?)\"/);
|
||||
var title = RegExp.$1;
|
||||
lnkh.match(/href=\"(.+?)\"/);
|
||||
var href = RegExp.$1;
|
||||
|
||||
if(title!=href){
|
||||
url = "[xurl="+href+"|"+title+"]"+lnkt+"[/url]";
|
||||
}else{
|
||||
url = "[url="+href+"]"+lnkt+"[/url]";
|
||||
}
|
||||
s = s.replace(/<a(.*?)>(.*?)<\/a>/i, url);
|
||||
}
|
||||
|
||||
rep(/<a.*?href=\"(.*?)\".*?>(.*?)<\/a>/gi,"[url=$1]$2[/url]");
|
||||
|
||||
|
||||
rep(/<(h[1|2|3])>(.*?)<\/(h[1|2|3])>/gi,"[$1]$2[/$3]");
|
||||
|
||||
rep(/<sup>(.*?)<\/sup>/gi,"[sup]$1[/sup]");
|
||||
rep(/<sub>(.*?)<\/sub>/gi,"[sub]$1[/sub]");
|
||||
|
||||
|
||||
|
||||
|
||||
// rep(/<font.*?color=\"(.*?)\".*?class=\"codeStyle\".*?>(.*?)<\/font>/gi,"[code][color=$1]$2[/color][/code]");
|
||||
// rep(/<font.*?color=\"(.*?)\".*?class=\"quoteStyle\".*?>(.*?)<\/font>/gi,"[quote][color=$1]$2[/color][/quote]");
|
||||
// rep(/<font.*?class=\"codeStyle\".*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[code][color=$1]$2[/color][/code]");
|
||||
// rep(/<font.*?class=\"quoteStyle\".*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[quote][color=$1]$2[/color][/quote]");
|
||||
// rep(/<span style=\"color: ?(.*?);\">(.*?)<\/span>/gi,"[color=$1]$2[/color]");
|
||||
// // rep(/<font.*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[color=$1]$2[/color]");
|
||||
// rep(/<span style=\"font-size:(.*?);\">(.*?)<\/span>/gi,"[size=$1]$2[/size]");
|
||||
// rep(/<font>(.*?)<\/font>/gi,"$1");
|
||||
|
||||
s = s.replace(/<span class=\"snInfoBoxHead\".*?>(.+?)<\/span>/g,"[boxhead]$1[/boxhead]");
|
||||
|
||||
while(s.match(/<span class=\"snInfoBox\" style=\"(.+?)\">(.+?)<\/span>/)){
|
||||
var l = RegExp.$1; var c = RegExp.$2;
|
||||
var b = l.indexOf("float: left") != -1 ? "infol":"infor";
|
||||
var w = "";
|
||||
|
||||
if(l.match(/width:(.+?);.+/)){
|
||||
var _cwn = parseInt(RegExp.$1);
|
||||
if(!isNaN(_cwn)){
|
||||
w = "="+_cwn;
|
||||
}
|
||||
}
|
||||
|
||||
s = s.replace(/<span class=\"snInfoBox\" style=\"(.+?)\">(.+?)<\/span>/,"["+b+w+"]"+c+"[/"+b+"]");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
rep(/<code>(.*?)<\/code>/gi,"[code]$1[/code]");
|
||||
rep(/<blockquote>(.*?)<\/blockquote>/gi,"[quote]$1[/quote]");
|
||||
rep(/<\/(strong|b)>/gi,"[/b]");
|
||||
rep(/<(strong|b)>/gi,"[b]");
|
||||
rep(/<\/(em|i)>/gi,"[/i]");
|
||||
rep(/<(em|i)>/gi,"[i]");
|
||||
rep(/<\/u>/gi,"[/u]");
|
||||
rep(/<span style=\"text-decoration: ?underline;\">(.*?)<\/span>/gi,"[u]$1[/u]");
|
||||
rep(/<u>/gi,"[u]");
|
||||
rep(/<blockquote[^>]*>/gi,"[quote]");
|
||||
rep(/<\/blockquote>/gi,"[/quote]");
|
||||
rep(/<br \/>/gi,"\n");
|
||||
rep(/<br\/>/gi,"\n");
|
||||
rep(/<br>/gi,"\n");
|
||||
rep(/<p(.*?)>/gi,"");
|
||||
rep(/<\/p>/gi,"\n");
|
||||
rep(/ /gi," ");
|
||||
rep(/"/gi,"\"");
|
||||
rep(/</gi,"<");
|
||||
rep(/>/gi,">");
|
||||
rep(/&/gi,"&");
|
||||
|
||||
rep(/\[\/(tr|td|table)\]\n/gi,"[/$1]");
|
||||
rep(/\[(tr|table|td)\]\n/gi,"[$1]");
|
||||
|
||||
|
||||
return s;
|
||||
},
|
||||
|
||||
// BBCode -> HTML from PunBB dialect
|
||||
_punbb_bbcode2html : function(s) {
|
||||
s = tinymce.trim(s);
|
||||
// alert("bbcode2html");
|
||||
function rep(re, str) {
|
||||
s = s.replace(re, str);
|
||||
};
|
||||
|
||||
var img_path = (tinyMCE.activeEditor.getParam("snstuff_img_url_image") || "/articleimage/{artikelid}/").replace(/\{artikelid\}/g,parent.entryid);
|
||||
img_path = img_path.replace(/\{imgname\}/g,"");
|
||||
|
||||
rep(/\[imgl=(.*?)\](.*?)\[\/imgl\]/gi,"<img class=\"noresize\" style=\"float:left;\" src=\""+img_path+"$2\" alt=\"$1\"/>");
|
||||
rep(/\[imgr=(.*?)\](.*?)\[\/imgr\]/gi,"<img class=\"noresize\" style=\"float:right;\" src=\""+img_path+"$2\" alt=\"$1\"/>");
|
||||
rep(/\[img=(.*?)\](.*?)\[\/img\]/gi,"<img class=\"noresize\" src=\""+img_path+"$2\" alt=\"$1\"/>");
|
||||
|
||||
|
||||
while(/(\[video=(.*?)\])/.test(s)){
|
||||
var _res = RegExp.$1;
|
||||
var _l = RegExp.$2.split(';');
|
||||
var _rpl = '<img class="snVideo" src="/editor_stuff/plugin/snstuff/images/trans.gif" title="'+_l[0]+'" width="'+parseInt(_l[1])+'" height="'+parseInt(_l[2])+'" ';
|
||||
_rpl += _l[3]?'alt="'+_l[3]+'" />':'/>';
|
||||
s = s.replace(_res,_rpl);
|
||||
}
|
||||
|
||||
// replace list bbcode
|
||||
var rl = new Array();
|
||||
rl[0] = {f:/\[list\]/, o:"<ul style=\"list-style-type: disc;\">",c:"</ul>"};
|
||||
rl[1] = {f:/\[list=d\]/, o:"<ul style=\"list-style-type: disc;\">",c:"</ul>"};
|
||||
rl[2] = {f:/\[list=s\]/, o:"<ul style=\"list-style-type: square;\">",c:"</ul>"};
|
||||
rl[3] = {f:/\[list=c\]/, o:"<ul style=\"list-style-type: circle;\">",c:"</ul>"};
|
||||
|
||||
rl[4] = {f:/\[list=1\]/, o:"<ol style=\"list-style-type: decimal;\">",c:"</ol>"};
|
||||
rl[5] = {f:/\[list=i\]/, o:"<ol style=\"list-style-type: lower-roman;\">",c:"</ol>"};
|
||||
rl[6] = {f:/\[list=I\]/, o:"<ol style=\"list-style-type: upper-roman;\">",c:"</ol>"};
|
||||
rl[7] = {f:/\[list=a\]/, o:"<ol style=\"list-style-type: lower-alpha;\">",c:"</ol>"};
|
||||
rl[8] = {f:/\[list=A\]/, o:"<ol style=\"list-style-type: upper-alpha;\">",c:"</ol>"};
|
||||
|
||||
var cl = new Array();
|
||||
do{
|
||||
var p = s.search(/\[\/list\]/);
|
||||
var re = "";
|
||||
|
||||
for(var i = 0; i < rl.length; i++){
|
||||
var np = s.search(rl[i].f);
|
||||
|
||||
if(np != -1 && p > np){
|
||||
p = np;
|
||||
cl[cl.length] = rl[i];
|
||||
re = rl[i].f;
|
||||
}
|
||||
}
|
||||
if(cl.length > 0){
|
||||
if(re == ""){
|
||||
s = s.replace(/\[\/list\]/,cl.pop().c);
|
||||
}else{
|
||||
s = s.replace(re, cl[cl.length-1].o);
|
||||
}
|
||||
}
|
||||
}while(cl.length > 0 || s.search(/\[list.*?\]/) != -1);
|
||||
|
||||
|
||||
s = s.replace(/\[\/\*\]/g,"</li>");
|
||||
s = s.replace(/\[\*\]/g,"<li>");
|
||||
|
||||
|
||||
s = s.replace(/\[infor\]/mg,"<span class=\"snInfoBox\" style=\"width:100px; float: right;\">");
|
||||
s = s.replace(/\[infol\]/mg,"<span class=\"snInfoBox\" style=\"width:100px; float: left;\">");
|
||||
|
||||
s = s.replace(/\[infor=(.+?){0,1}\]/mg,"<span class=\"snInfoBox\" style=\"width:$1px; float: right;\">");
|
||||
s = s.replace(/\[infol=(.+?){0,1}\]/mg,"<span class=\"snInfoBox\" style=\"width:$1px; float: left;\">");
|
||||
|
||||
s = s.replace(/\[\/(infor|infol)\]/g,"</span>");
|
||||
|
||||
s = s.replace(/\[boxhead\]/g,"<span class=\"snInfoBoxHead\">");
|
||||
s = s.replace(/\[\/boxhead\]/g,"</span>");
|
||||
|
||||
|
||||
// example: [b] to <strong>
|
||||
|
||||
rep(/\[b\]/gi,"<strong>");
|
||||
rep(/\[\/b\]/gi,"</strong>");
|
||||
rep(/\[i\]/gi,"<em>");
|
||||
rep(/\[\/i\]/gi,"</em>");
|
||||
rep(/\[u\]/gi,"<u>");
|
||||
rep(/\[\/u\]/gi,"</u>");
|
||||
rep(/\[url=([^\]]+)\](.*?)\[\/url\]/gi,"<a href=\"$1\" title=\"$1\">$2</a>");
|
||||
rep(/\[xurl=([^\]]+)\|(.*?)\](.*?)\[\/url\]/gi,"<a href=\"$1\" title=\"$2\">$3</a>");
|
||||
|
||||
rep(/\[url\](.*?)\[\/url\]/gi,"<a href=\"$1\" title=\"$1\">$1</a>");
|
||||
// rep(/\[img\](.*?)\[\/img\]/gi,"<img src=\"$1\" />");
|
||||
rep(/\[color=(.*?)\](.*?)\[\/color\]/gi,"<font color=\"$1\">$2</font>");
|
||||
rep(/\[code\](.*?)\[\/code\]/gi,"<code>$1</code>");
|
||||
rep(/\[quote.*?\](.*?)\[\/quote\]/gi,"<blockquote>$1</blockquote>");
|
||||
|
||||
|
||||
rep(/\[(h[1|2|3])\](.*?)\[\/(h[1|2|3])\]/gi,"<$1>$2</$3>");
|
||||
rep(/(<\/h[1|2|3]>)\n/gi,"$1");
|
||||
rep(/\n(<h[1|2|3]>)/gi,"$1");
|
||||
|
||||
|
||||
|
||||
rep(/\[sup\](.*?)\[\/sup\]/gi,"<sup>$1</sup>");
|
||||
rep(/\[sub\](.*?)\[\/sub\]/gi,"<sub>$1</sub>");
|
||||
|
||||
/*
|
||||
rep(/\[\/(tr|td|table)\]/gi,"[/$1]");
|
||||
rep(/\[(tr|table)\]/gi,"[$1]");*/
|
||||
|
||||
|
||||
rep(/\n/gi,"<br />");
|
||||
|
||||
|
||||
|
||||
return s;
|
||||
}
|
||||
});
|
||||
|
||||
// Register plugin
|
||||
tinymce.PluginManager.add('bbcode', tinymce.plugins.BBCodePlugin);
|
||||
})();
|
@@ -0,0 +1,3 @@
|
||||
td.radio { text-align: right; }
|
||||
td.label { text-align: right; }
|
||||
.panel_wrapper div.current {height:auto;}
|
@@ -0,0 +1 @@
|
||||
(function(){tinymce.PluginManager.requireLangPack('liststyle');tinymce.create('tinymce.plugins.ListStylePlugin',{init:function(ed,url){ed.addCommand('mceListStyle',function(ui,v){var listStyleType='',listStart,isIE=tinyMCE.isIE;var listNode=ed.plugins.liststyle._findList(ed,ed.selection.getNode());if(listNode){listStyleType=listNode.style.listStyleType;if(listNode.nodeName.toLowerCase()=='ol'){listStart=parseInt(listNode.start);if(listStart<1){listStart=1}ed.windowManager.open({file:url+'/liststyle_ol.htm',width:340+parseInt(ed.getLang('liststyle.delta_width',0)),height:300+(isIE?40:0)+parseInt(ed.getLang('liststyle.delta_height',0)),inline:1},{plugin_url:url,listStyleType:listStyleType,listNode:listNode,listStart:listStart,classAttr:listNode.className,isIE:isIE})}else{ed.windowManager.open({file:url+'/liststyle_ul.htm',width:340+parseInt(ed.getLang('liststyle.delta_width',0)),height:300+(isIE?40:0)+parseInt(ed.getLang('liststyle.delta_height',0)),inline:1},{plugin_url:url,listStyleType:listStyleType,listNode:listNode,classAttr:listNode.className,isIE:isIE})}}});ed.onInit.add(function(){if(ed&&ed.plugins.contextmenu){ed.plugins.contextmenu.onContextMenu.add(function(th,m,e){if(ed.plugins.liststyle._findList(ed,ed.selection.getNode())){m.add({title:'liststyle.desc',cmd:'mceListStyle',icon:'liststyle',ui:true})}})}});ed.addButton('liststyle',{title:'liststyle.desc',cmd:'mceListStyle',image:url+'/img/liststyle.gif'});ed.onNodeChange.add(function(ed,cm,node){cm.setDisabled('liststyle',ed.plugins.liststyle._findList(ed,node)==null)})},_isList:function(node){if(node==null)return null;return node.nodeName=='OL'||node.nodeName=='UL'},_findList:function(ed,node){if(ed.plugins.liststyle._isList(node)){return node}return ed.dom.getParent(node,ed.plugins.liststyle._isList)},getInfo:function(){return{longname:'ListStyle',author:'PolicyPoint Technologies Pty. Ltd.',authorurl:'http://policypoint.net/',infourl:'http://policypoint.net/tinymce/docs/plugin_liststyle.html',version:"3.1-alfa"}}});tinymce.PluginManager.add('liststyle',tinymce.plugins.ListStylePlugin)})();
|
132
sn_templates/editor_stuff/plugin/liststyle/editor_plugin_src.js
Normal file
@@ -0,0 +1,132 @@
|
||||
/**
|
||||
* $Id:$
|
||||
* vim: expandtab ts=8 sw=8
|
||||
*
|
||||
* @author Scott Eade, PolicyPoint Technologies Pty. Ltd.
|
||||
* @copyright Copyright 2005-2008, PolicyPoint Technologies Pty. Ltd.
|
||||
* @author Mariusz P<>kala, iDelfi Polska sp. z o.o.
|
||||
* @copyright Copyright 2008, iDelfi Polska sp. z o.o.
|
||||
* @license LGPL
|
||||
*/
|
||||
|
||||
(function() {
|
||||
// Load plugin specific language pack
|
||||
tinymce.PluginManager.requireLangPack('liststyle');
|
||||
|
||||
tinymce.create('tinymce.plugins.ListStylePlugin', {
|
||||
/**
|
||||
* Initializes the plugin, this will be executed after the plugin has been created.
|
||||
* This call is done before the editor instance has finished it's initialization so use the onInit event
|
||||
* of the editor instance to intercept that event.
|
||||
*
|
||||
* @param {tinymce.Editor} ed Editor instance that the plugin is initialized in.
|
||||
* @param {string} url Absolute URL to where the plugin is located.
|
||||
*/
|
||||
init : function(ed, url) {
|
||||
// Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('mceExample');
|
||||
ed.addCommand('mceListStyle', function(ui, v) {
|
||||
var listStyleType = '', listStart, isIE = tinyMCE.isIE;
|
||||
// ed.selection.getNode(); => selectedElement - common ancestor
|
||||
var listNode = ed.plugins.liststyle._findList(ed, ed.selection.getNode() );
|
||||
if( listNode ) {
|
||||
listStyleType = listNode.style.listStyleType;
|
||||
if( listNode.nodeName.toLowerCase() == 'ol' ) {
|
||||
listStart = parseInt(listNode.start);
|
||||
if( listStart < 1) { listStart = 1; }
|
||||
|
||||
ed.windowManager.open({
|
||||
file : url + '/liststyle_ol.htm',
|
||||
width : 340 + parseInt(ed.getLang('liststyle.delta_width', 0)),
|
||||
height : 300 + (isIE ? 40 : 0) + parseInt(ed.getLang('liststyle.delta_height', 0)),
|
||||
inline : 1
|
||||
}, {
|
||||
plugin_url : url, // Plugin absolute URL
|
||||
listStyleType : listStyleType,
|
||||
listNode : listNode,
|
||||
listStart : listStart,
|
||||
classAttr : listNode.className,
|
||||
isIE : isIE
|
||||
}
|
||||
);
|
||||
} else {
|
||||
ed.windowManager.open({
|
||||
file : url + '/liststyle_ul.htm',
|
||||
width : 340 + parseInt(ed.getLang('liststyle.delta_width', 0)),
|
||||
height : 300 + (isIE ? 40 : 0) + parseInt(ed.getLang('liststyle.delta_height', 0)),
|
||||
inline : 1
|
||||
}, {
|
||||
plugin_url : url, // Plugin absolute URL
|
||||
listStyleType : listStyleType,
|
||||
listNode : listNode,
|
||||
classAttr : listNode.className,
|
||||
isIE : isIE
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
ed.onInit.add(function() {
|
||||
if (ed && ed.plugins.contextmenu) {
|
||||
ed.plugins.contextmenu.onContextMenu.add(function(th, m, e) {
|
||||
if( ed.plugins.liststyle._findList(ed,ed.selection.getNode() ) ) {
|
||||
m.add({title : 'liststyle.desc', cmd : 'mceListStyle', icon : 'liststyle', ui : true});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Register the button
|
||||
ed.addButton('liststyle', {
|
||||
title : 'liststyle.desc',
|
||||
cmd : 'mceListStyle',
|
||||
image : url + '/img/liststyle.gif'
|
||||
});
|
||||
|
||||
// Enable/disable the button depending on the current selection element
|
||||
// It looks like the node is the same as selection.getNode - it means, a common ancestor of
|
||||
// all selected nodes.
|
||||
ed.onNodeChange.add(function(ed, cm, node) {
|
||||
cm.setDisabled('liststyle', ed.plugins.liststyle._findList(ed,node) == null);
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Helper function: find a list element (<ol> or <ul>) being somewhere
|
||||
* amongst parents of given element.
|
||||
*/
|
||||
_isList : function(node) {
|
||||
if( node == null )
|
||||
return null;
|
||||
return node.nodeName == 'OL' || node.nodeName == 'UL';
|
||||
},
|
||||
|
||||
_findList : function(ed, node) {
|
||||
if( ed.plugins.liststyle._isList(node) ) {
|
||||
return node;
|
||||
}
|
||||
return ed.dom.getParent( node, ed.plugins.liststyle._isList );
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Returns information about the plugin as a name/value array.
|
||||
* The current keys are longname, author, authorurl, infourl and version.
|
||||
*
|
||||
* @return {Object} Name/value array containing information about the plugin.
|
||||
*/
|
||||
getInfo : function() {
|
||||
return {
|
||||
longname : 'ListStyle',
|
||||
author : 'PolicyPoint Technologies Pty. Ltd.',
|
||||
authorurl : 'http://policypoint.net/',
|
||||
infourl : 'http://policypoint.net/tinymce/docs/plugin_liststyle.html',
|
||||
version : "3.1-alfa"
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
// Register plugin
|
||||
tinymce.PluginManager.add('liststyle', tinymce.plugins.ListStylePlugin);
|
||||
})();
|
BIN
sn_templates/editor_stuff/plugin/liststyle/img/liststyle.gif
Normal file
After Width: | Height: | Size: 123 B |
73
sn_templates/editor_stuff/plugin/liststyle/js/liststyle.js
Normal file
@@ -0,0 +1,73 @@
|
||||
// vim: expandtab ts=8 sw=8
|
||||
tinyMCEPopup.requireLangPack();
|
||||
|
||||
|
||||
/**
|
||||
* Window args passed to the popup:
|
||||
* (retrieve by tinyMCEPopup.getWindowArg('isIE');
|
||||
*
|
||||
* - plugin_url : url, // Plugin absolute URL
|
||||
* - listStyleType : listStyleType, // 'decimal', 'disc', etc.
|
||||
* - listNode : listNode, // the list dom element
|
||||
* - listStart : listStart, // 1, 2, 3
|
||||
* - classAttr : p.className, // html class attribute class
|
||||
* - isIE : isIE // true / false
|
||||
*/
|
||||
function init() {
|
||||
tinyMCEPopup.resizeToInnerSize();
|
||||
|
||||
var formObj = document.forms[0];
|
||||
var isIE = tinyMCEPopup.getWindowArg('isIE');
|
||||
var classAttr = tinyMCEPopup.getWindowArg('classAttr') || '';
|
||||
var listStyleType = tinyMCEPopup.getWindowArg('listStyleType');
|
||||
|
||||
listSpecificInit();
|
||||
|
||||
setListStyleType( listSpecificSwitch( formObj, listStyleType) );
|
||||
|
||||
if (isIE) {
|
||||
document.getElementById("classAttrId").value = classAttr;
|
||||
} else {
|
||||
document.getElementById("classNameRow").style.display = "none";
|
||||
listSpecificNonIEInit();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Just copy a value from radio button to a hidden input.
|
||||
* This function is set as onclick event on radio controls.
|
||||
*/
|
||||
function setListStyleType(listStyleType) {
|
||||
document.forms[0].listStyleTypeId.value = listStyleType;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This function is set as onclick event on the 'OK' button.
|
||||
*/
|
||||
function okayAction() {
|
||||
var formObj = document.forms[0];
|
||||
|
||||
var listNode = tinyMCEPopup.getWindowArg('listNode');
|
||||
var classAttr = formObj.classAttr.value;
|
||||
var listStyleType = formObj.listStyleType.value;
|
||||
var isIE = tinyMCEPopup.getWindowArg('isIE');
|
||||
|
||||
if (listNode) {
|
||||
tinyMCEPopup.execCommand('mceBeginUndoLevel');
|
||||
listNode.style.listStyleType = listStyleType;
|
||||
listNode.removeAttribute('mce_style'); // MAGIC! FIXME: wyjaśnij, po co jest mce_style
|
||||
|
||||
listSpecificOkayAction( formObj, listNode );
|
||||
|
||||
if (isIE) {
|
||||
listNode.className = classAttr;
|
||||
}
|
||||
tinyMCEPopup.execCommand('mceEndUndoLevel');
|
||||
}
|
||||
tinyMCEPopup.close();
|
||||
}
|
||||
|
||||
|
||||
tinyMCEPopup.onInit.add(init);
|
@@ -0,0 +1,62 @@
|
||||
// vim: expandtab ts=8 sw=8
|
||||
|
||||
|
||||
function listSpecificInit() {
|
||||
var listStart = parseInt( tinyMCEPopup.getWindowArg('listStart') );
|
||||
if( listStart ) {
|
||||
if( listStart < 1 ) { listStart = 1; }
|
||||
} else {
|
||||
listStart = '';
|
||||
}
|
||||
// document.getElementById("listStartId").value = listStart || '';
|
||||
}
|
||||
|
||||
function listSpecificNonIEInit() {
|
||||
}
|
||||
|
||||
function listSpecificSwitch( formObj, listStyleType ) {
|
||||
switch (listStyleType) {
|
||||
case "decimal":
|
||||
formObj.decimalId.checked = true;
|
||||
break;
|
||||
case "lower-alpha":
|
||||
formObj.lowerAlphaId.checked = true;
|
||||
break;
|
||||
case "upper-alpha":
|
||||
formObj.upperAlphaId.checked = true;
|
||||
break;
|
||||
case "lower-roman":
|
||||
formObj.lowerRomanId.checked = true;
|
||||
break;
|
||||
case "upper-roman":
|
||||
formObj.upperRomanId.checked = true;
|
||||
break;
|
||||
case "none":
|
||||
formObj.noneId.checked = true;
|
||||
break;
|
||||
default:
|
||||
formObj.decimalId.checked = true;
|
||||
listStyleType = 'decimal';
|
||||
}
|
||||
return listStyleType;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is called from the onsubmit form handler "okAction()".
|
||||
*/
|
||||
function listSpecificOkayAction( formObj, listNode ) {
|
||||
|
||||
var listStart = 1;//parseInt(formObj.listStart.value); // may be NaN !
|
||||
if( listStart < 1) {
|
||||
listStart = 1;
|
||||
};
|
||||
|
||||
if (listNode) {
|
||||
if( listStart ) {
|
||||
listNode.start = listStart;
|
||||
} else {
|
||||
listNode.removeAttribute('start');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,37 @@
|
||||
// vim: expandtab ts=8 sw=8
|
||||
|
||||
function listSpecificInit() {
|
||||
}
|
||||
|
||||
function listSpecificNonIEInit() {
|
||||
// no additional properties left. Hide the section title:
|
||||
// document.getElementById("listAttrsRow").style.display = "none";
|
||||
}
|
||||
|
||||
|
||||
function listSpecificSwitch( formObj, listStyleType ) {
|
||||
switch (listStyleType) {
|
||||
case "disc":
|
||||
formObj.discId.checked = true;
|
||||
break;
|
||||
case "circle":
|
||||
formObj.circleId.checked = true;
|
||||
break;
|
||||
case "square":
|
||||
formObj.squareId.checked = true;
|
||||
break;
|
||||
case "none":
|
||||
formObj.noneId.checked = true;
|
||||
break;
|
||||
default:
|
||||
formObj.discId.checked = true;
|
||||
listStyleType = 'disc';
|
||||
}
|
||||
return listStyleType;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// do nothing
|
||||
function listSpecificOkayAction( formObj, listNode ) {
|
||||
}
|
19
sn_templates/editor_stuff/plugin/liststyle/langs/de.js
Normal file
@@ -0,0 +1,19 @@
|
||||
// UK lang variables
|
||||
|
||||
tinyMCE.addI18n("de.liststyle", {
|
||||
desc : 'List eigenschaften',
|
||||
listtype : 'List type',
|
||||
decimal : "1, 2, 3, ...",
|
||||
lalpha : 'a, b, c, ...',
|
||||
ualpha : 'A, B, C, ...',
|
||||
lroman : 'i, ii, iii, ...',
|
||||
uroman : 'I, II, III...',
|
||||
disc : 'Punkte',
|
||||
circle : 'Kreise',
|
||||
square : 'Quadrate',
|
||||
none : 'Keine',
|
||||
listattributes : 'List eigenschaften',
|
||||
start : 'start',
|
||||
startdesc : '1, 2, 3, ...',
|
||||
classname : 'class'
|
||||
});
|
@@ -0,0 +1 @@
|
||||
// UK lang variables
|
19
sn_templates/editor_stuff/plugin/liststyle/langs/en.js
Normal file
@@ -0,0 +1,19 @@
|
||||
// UK lang variables
|
||||
|
||||
tinyMCE.addI18n("en.liststyle", {
|
||||
desc : 'List properties',
|
||||
listtype : 'List type',
|
||||
decimal : "Decimal numbers (1, 2, 3, ...)",
|
||||
lalpha : 'Lower alphabetic letters (a, b, c, ...)',
|
||||
ualpha : 'Upper alphabetic letters (A, B, C, ...)',
|
||||
lroman : 'Lower roman numbers (i, ii, iii, ...)',
|
||||
uroman : 'Upper roman numbers (I, II, III...)',
|
||||
disc : 'Disc',
|
||||
circle : 'Circle',
|
||||
square : 'Square',
|
||||
none : 'None',
|
||||
listattributes : 'List attributes',
|
||||
start : 'start',
|
||||
startdesc : '(1, 2, 3, ...)',
|
||||
classname : 'class'
|
||||
});
|
@@ -0,0 +1 @@
|
||||
// UK lang variables
|
80
sn_templates/editor_stuff/plugin/liststyle/liststyle_ol.htm
Normal file
@@ -0,0 +1,80 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>{#liststyle.desc}</title>
|
||||
<script language="javascript" type="text/javascript" src="../../tiny_mce_popup.js"></script>
|
||||
<script language="javascript" type="text/javascript" src="js/liststyle_ol.js"></script>
|
||||
<script language="javascript" type="text/javascript" src="js/liststyle.js"></script>
|
||||
<script language="javascript" type="text/javascript" src="../../utils/mctabs.js"></script>
|
||||
<script language="javascript" type="text/javascript" src="../../utils/form_utils.js"></script>
|
||||
<link href="css/liststyle.css" rel="stylesheet" type="text/css" />
|
||||
<base target="_self" />
|
||||
</head>
|
||||
<body id="liststyle_ol">
|
||||
<form onsubmit="okayAction();return false;" action="#">
|
||||
<input type="hidden" name="listStyleType" id="listStyleTypeId" />
|
||||
<div class="tabs">
|
||||
<ul>
|
||||
<li id="general_tab" class="current"><span><a href="javascript:mcTabs.displayTab('general_tab','general_panel');" onmousedown="return false;">{#liststyle.desc}</a></span></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="panel_wrapper">
|
||||
<div id="general_panel" class="panel current">
|
||||
<table border="0" cellpadding="4" cellspacing="0">
|
||||
<tr>
|
||||
<td colspan="2" class="title">{#liststyle.listtype}</td>
|
||||
</tr>
|
||||
<tr id="decimalRow">
|
||||
<td class="radio"><input type="radio" name="typeRadio" id="decimalId" value="decimal" onclick="setListStyleType(this.value)" class="radio" /></td>
|
||||
<td><label for="decimalId">{#liststyle.decimal}</label></td>
|
||||
</tr>
|
||||
<tr id="laRow">
|
||||
<td class="radio"><input type="radio" name="typeRadio" id="lowerAlphaId" value="lower-alpha" onclick="setListStyleType(this.value)" class="radio" /></td>
|
||||
<td><label for="lowerAlphaId">{#liststyle.lalpha}</label></td>
|
||||
</tr>
|
||||
<tr id="uaRow">
|
||||
<td class="radio"><input type="radio" name="typeRadio" id="upperAlphaId" value="upper-alpha" onclick="setListStyleType(this.value)" class="radio" /></td>
|
||||
<td><label for="upperAlphaId">{#liststyle.ualpha}</label></td>
|
||||
</tr>
|
||||
<tr id="lrRow">
|
||||
<td class="radio"><input type="radio" name="typeRadio" id="lowerRomanId" value="lower-roman" onclick="setListStyleType(this.value)" class="radio" /></td>
|
||||
<td><label for="lowerRomanId">{#liststyle.lroman}</label></td>
|
||||
</tr>
|
||||
<tr id="urRow">
|
||||
<td class="radio"><input type="radio" name="typeRadio" id="upperRomanId" value="upper-roman" onclick="setListStyleType(this.value)" class="radio" /></td>
|
||||
<td><label for="upperRomanId">{#liststyle.uroman}</label></td>
|
||||
</tr>
|
||||
<!-- <tr>
|
||||
<td class="radio"><input type="radio" name="typeRadio" id="noneId" value="none" onclick="setListStyleType(this.value)" class="radio" /></td>
|
||||
<td><label for="noneId">{#liststyle.none}</label></td>
|
||||
</tr>-->
|
||||
<!--
|
||||
<tr id="listAttrsRow">
|
||||
<td colspan="2" class="title">{#liststyle.listattributes}</td>
|
||||
</tr>
|
||||
|
||||
<tr id="startRow">
|
||||
<td class="label"><label for="listStartId">{#liststyle.start}</label></td>
|
||||
<td><input name="listStart" type="text" id="listStartId" value="" size="4" maxlength="4" /> {#liststyle.startdesc}</td>
|
||||
</tr>
|
||||
-->
|
||||
<tr id="classNameRow">
|
||||
<td class="label"><label for="startId">{#liststyle.classname}</label></td>
|
||||
<td><input name="classAttr" type="text" id="classAttrId" value="" size="20" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mceActionPanel">
|
||||
<div style="float:left">
|
||||
<input type="submit" id="insert" name="insert" value="{#update}" />
|
||||
</div>
|
||||
<div style="float: right">
|
||||
<input type="button" id="cancel" name="cancel" value="{#cancel}" onclick="tinyMCEPopup.close();" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
67
sn_templates/editor_stuff/plugin/liststyle/liststyle_ul.htm
Normal file
@@ -0,0 +1,67 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>{#liststyle.desc}</title>
|
||||
<script language="javascript" type="text/javascript" src="../../tiny_mce_popup.js"></script>
|
||||
<script language="javascript" type="text/javascript" src="js/liststyle_ul.js"></script>
|
||||
<script language="javascript" type="text/javascript" src="js/liststyle.js"></script>
|
||||
<script language="javascript" type="text/javascript" src="../../utils/mctabs.js"></script>
|
||||
<script language="javascript" type="text/javascript" src="../../utils/form_utils.js"></script>
|
||||
<link href="css/liststyle.css" rel="stylesheet" type="text/css" />
|
||||
<base target="_self" />
|
||||
</head>
|
||||
<body id="liststyle_ul">
|
||||
<form onsubmit="okayAction();return false;" action="#">
|
||||
<input type="hidden" name="listStyleType" id="listStyleTypeId" />
|
||||
<div class="tabs">
|
||||
<ul>
|
||||
<li id="general_tab" class="current"><span><a href="javascript:mcTabs.displayTab('general_tab','general_panel');" onmousedown="return false;">{#liststyle.desc}</a></span></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="panel_wrapper">
|
||||
<div id="general_panel" class="panel current">
|
||||
<table border="0" cellpadding="4" cellspacing="0">
|
||||
<tr>
|
||||
<td colspan="2" class="title">{#liststyle.listtype}</td>
|
||||
</tr>
|
||||
<tr id="discRow">
|
||||
<td class="radio"><input type="radio" name="typeRadio" id="discId" value="disc" onclick="setListStyleType(this.value)" class="radio" /></td>
|
||||
<td><label for="discId">{#liststyle.disc}</label></td>
|
||||
</tr>
|
||||
<!-- <tr id="circleRow">
|
||||
<td class="radio"><input type="radio" name="typeRadio" id="circleId" value="circle" onclick="setListStyleType(this.value)" class="radio" /></td>
|
||||
<td><label for="circleId">{#liststyle.circle}</label></td>
|
||||
</tr>
|
||||
<tr id="squareRow">
|
||||
<td class="radio"><input type="radio" name="typeRadio" id="squareId" value="square" onclick="setListStyleType(this.value)" class="radio" /></td>
|
||||
<td><label for="squareId">{#liststyle.square}</label></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="radio"><input type="radio" name="typeRadio" id="noneId" value="none" onclick="setListStyleType(this.value)" class="radio" /></td>
|
||||
<td><label for="noneId">{#liststyle.none}</label></td>
|
||||
</tr>
|
||||
|
||||
<tr id="listAttrsRow">
|
||||
<td colspan="2" class="title">{#liststyle.listattributes}</td>
|
||||
</tr>-->
|
||||
|
||||
<tr id="classNameRow">
|
||||
<td class="label"><label for="startId">{#liststyle.classname}</label></td>
|
||||
<td><input name="classAttr" type="text" id="classAttrId" value="" size="20" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mceActionPanel">
|
||||
<div style="float:left">
|
||||
<input type="submit" id="insert" name="insert" value="{#update}" />
|
||||
</div>
|
||||
<div style="float: right">
|
||||
<input type="button" id="cancel" name="cancel" value="{#cancel}" onclick="tinyMCEPopup.close();" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
177
sn_templates/editor_stuff/plugin/liststyle/plugin_liststyle.html
Normal file
@@ -0,0 +1,177 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>Plugin: liststyle</title>
|
||||
<link href="css/screen.css" rel="stylesheet" type="text/css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="header">
|
||||
<h1>
|
||||
Plugin: liststyle
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
<p>
|
||||
The List Style plugin allows you to set the list-style-type CSS property on lists within the TinyMCE editor. This plugin caters for both ordered and unordered lists.
|
||||
</p>
|
||||
|
||||
<h3>
|
||||
Installation Instructions
|
||||
</h3>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
Copy the liststyle directory to the plugins directory of TinyMCE (/jscripts/tiny_mce/plugins).
|
||||
</li>
|
||||
<li>
|
||||
Add plugin to TinyMCE plugin option list. Example: plugins : "liststyle".
|
||||
</li>
|
||||
<li>
|
||||
Add the liststyle button to the button list. Example: theme_advanced_button3_add : "liststyle"
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>
|
||||
Initialization Example
|
||||
</h3>
|
||||
<br />
|
||||
<div class="example">
|
||||
<pre>
|
||||
tinyMCE.init({
|
||||
theme : "advanced",
|
||||
mode : "textareas",
|
||||
plugins : "liststyle",
|
||||
theme_advanced_button3_add : "liststyle"
|
||||
});
|
||||
</pre>
|
||||
</div>
|
||||
<br />
|
||||
<h3>
|
||||
Usage Instructions
|
||||
</h3>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
Position the cursor on an item in the list whose style you
|
||||
wish to alter and click the liststyle button.
|
||||
</li>
|
||||
<li>
|
||||
Select the list style type and click "Update".
|
||||
</li>
|
||||
<li>
|
||||
The plugin supports nested lists - the style of the list at the level
|
||||
of the item at the cursor position is altered, not the others.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>
|
||||
License
|
||||
</h3>
|
||||
|
||||
<blockquote>
|
||||
<a href="http://wiki.moxiecode.com/index.php/TinyMCE:License">LGPL 2.0</a>
|
||||
</blockquote>
|
||||
|
||||
<h3>
|
||||
History
|
||||
</h3>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
2008-05-07: Version 3.0 released.
|
||||
<ul>
|
||||
<li>
|
||||
Updated for TinyMCE 3.x.
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
2007-11-28: Version 1.1.3 released.
|
||||
<ul>
|
||||
<li>
|
||||
Tweaked the popup window height to allow for IE7 security address bar.
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
2006-08-25: Version 1.1.2 released.
|
||||
<ul>
|
||||
<li>
|
||||
Added Usage instructions.
|
||||
</li>
|
||||
<li>
|
||||
Added support for undo and redo.
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
2006-03-25: Version 1.1.1 released.
|
||||
<ul>
|
||||
<li>
|
||||
Fixed Javascript error under IE. Thanks to Bryan Costin
|
||||
for highlighting this issue.
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
2006-03-10: Version 1.1.0 released.
|
||||
<ul>
|
||||
<li>
|
||||
Updated for TinyMCE plugin architecture change introduced in TinyMCE 2.0.3.
|
||||
Use ListStyle 1.0.1 if you are using a TinyMCE 2.0.0 - 2.0.2.
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
2006-01-30: Version 1.0.2 released.
|
||||
<ul>
|
||||
<li>
|
||||
Fixed error that occurred when invoked on a non-LI element.
|
||||
</li>
|
||||
<li>
|
||||
Consistently use single quotes in plugin.
|
||||
</li>
|
||||
<li>
|
||||
Added compressed plugin file.
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
2005-10-11: Version 1.0.1 released. Changes made thanks to spocke:
|
||||
<ul>
|
||||
<li>
|
||||
Fixed so it uses inst.getFocusElement instead of the deprecated tinyMCE.selectedElement.
|
||||
</li>
|
||||
<li>
|
||||
Moved the style information to a separate .css file.
|
||||
</li>
|
||||
<li>
|
||||
Made it possible for translation of all labels.
|
||||
</li>
|
||||
<li>
|
||||
Translated the plugin into Swedish.
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
2005-10-07: Version 1.0 released.
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="footer">
|
||||
<div class="helpindexlink">
|
||||
<a href="http://wiki.moxiecode.com/index.php/TinyMCE:Index">TinyMCE Documentation</a>
|
||||
</div>
|
||||
|
||||
<div class="copyright">
|
||||
Copyright 2005-2008 PolicyPoint Technologies Pty. Ltd.
|
||||
</div>
|
||||
<br style="clear:both;" />
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
1
sn_templates/editor_stuff/plugin/snstuff/css/content.css
Normal file
@@ -0,0 +1 @@
|
||||
.snVideo{border:1px dotted #cc0000; background-position:center; background-repeat:no-repeat; background-color:#ffffcc;background-image:url(../images/video.png);}
|
14
sn_templates/editor_stuff/plugin/snstuff/css/default.css
Normal file
@@ -0,0 +1,14 @@
|
||||
#src_list, #over_list, #out_list {width:280px;}
|
||||
#video{display:none;}
|
||||
.mceActionPanel {margin-top:7px;}
|
||||
.alignPreview {border:1px solid #000; width:140px; height:140px; overflow:hidden; padding:5px;}
|
||||
.checkbox {border:0;}
|
||||
.panel_wrapper div.current {height:470px;}
|
||||
#prev, #prev2 {margin:0; border:1px solid #000; width:428px; height:260px; overflow:auto;}
|
||||
#align, #classlist {width:150px;}
|
||||
#width, #height {vertical-align:middle; width:50px; text-align:center;}
|
||||
#vspace, #hspace, #border {vertical-align:middle; width:30px; text-align:center;}
|
||||
#class_list {width:180px;}
|
||||
/* input {width: 100px;} */
|
||||
#constrain, #onmousemovecheck {width:auto;}
|
||||
#id, #dir, #lang, #usemap, #longdesc {width:200px;}
|
618
sn_templates/editor_stuff/plugin/snstuff/editor_plugin.js
Normal file
@@ -0,0 +1,618 @@
|
||||
(function() {
|
||||
|
||||
tinymce.create('tinymce.plugins.SNStuff', {
|
||||
|
||||
//// ImageUpload
|
||||
init : function(ed, url) {
|
||||
ed.onInit.add(function() {
|
||||
if (ed.settings.content_css !== false)
|
||||
ed.dom.loadCSS(url + "/css/content.css");
|
||||
});
|
||||
|
||||
ed.addCommand('mceSNImages', function() {
|
||||
ed.windowManager.open({
|
||||
file : url + '/html/image.html',
|
||||
width : 490,
|
||||
height : 550,
|
||||
inline : 1
|
||||
}, {
|
||||
plugin_url : url
|
||||
});
|
||||
});
|
||||
|
||||
ed.addButton('snimages', {
|
||||
title : 'snstuff.img_desc',
|
||||
cmd : 'mceSNImages',
|
||||
image : url + '/images/insert-image.png'
|
||||
});
|
||||
|
||||
ed.onNodeChange.add(function(ed, cm, n) {
|
||||
cm.setActive('snimages', n.nodeName == 'IMG');
|
||||
});
|
||||
|
||||
|
||||
/// Link
|
||||
ed.addCommand('mceSNLink', function() {
|
||||
ed.windowManager.open({
|
||||
file : url + '/html/link.html',
|
||||
width : 500 + parseInt(ed.getLang('snstuff.snlink_delta_width', 0)),
|
||||
height : 180 + parseInt(ed.getLang('snstuff.snlink_delta_height', 0)),
|
||||
inline : 1
|
||||
}, {
|
||||
plugin_url : url
|
||||
});
|
||||
});
|
||||
|
||||
ed.addButton('snlink', {title : 'snstuff.lnk_desc', cmd : 'mceSNLink', image: url+'/images/insert-link.png'});
|
||||
|
||||
ed.onNodeChange.add(function(ed, cm, n) {
|
||||
cm.setActive('snlink', false);
|
||||
var node = n;
|
||||
while(node != null){
|
||||
if(node.nodeName == 'A'){
|
||||
cm.setActive('snlink', true);
|
||||
break;
|
||||
}
|
||||
node = node.parentNode;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/// Code
|
||||
ed.addCommand('mceSNCode', function() {
|
||||
|
||||
handleSNCode(ed,url);
|
||||
|
||||
});
|
||||
ed.addButton('sncode', {title : 'snstuff.code_desc', cmd : 'mceSNCode', image: url+'/images/code-context.png'});
|
||||
|
||||
ed.onNodeChange.add(function(ed, cm, n) {
|
||||
cm.setActive('sncode', n.nodeName == 'CODE');
|
||||
});
|
||||
|
||||
/// Infobox
|
||||
ed.addCommand('mceSNInfoBox', function() { handleSNInfoBox(ed, url)});
|
||||
ed.addCommand('mceSNInfoBoxHead', function() { handleSNInfoBoxHead(ed, url) });
|
||||
|
||||
|
||||
ed.addButton('sninfobox', {title : 'snstuff.infobox_desc', cmd : 'mceSNInfoBox', image: url+'/images/textinfo.png'});
|
||||
ed.addButton('sninfoboxhead', {title : 'snstuff.infoboxhead_desc', cmd : 'mceSNInfoBoxHead', image: url+'/images/textinfo_head.png'});
|
||||
|
||||
|
||||
ed.onNodeChange.add(function(ed, cm, n) {
|
||||
var scas = ed.dom.getParent(ed.selection.getStart(), function(n) {return ed.dom.hasClass(n, "snInfoBox");}) != null;
|
||||
var scae = ed.dom.getParent(ed.selection.getEnd(), function(n) {return ed.dom.hasClass(n, "snInfoBox");}) != null;
|
||||
var sca = scas && scae;
|
||||
var scbs = ed.dom.getParent(ed.selection.getStart(), function(n) {return ed.dom.hasClass(n, "snInfoBoxHead");}) != null;
|
||||
var scbe = ed.dom.getParent(ed.selection.getStart(), function(n) {return ed.dom.hasClass(n, "snInfoBoxHead");}) != null;
|
||||
var scb = scbs && scbe;
|
||||
|
||||
var cs = ed.selection.getContent().length > 0;
|
||||
cm.setDisabled('sninfobox', scae != scas);
|
||||
cm.setDisabled('sninfoboxhead', (!((sca && cs) || scb) || scae != scas));
|
||||
cm.setActive('sninfobox', sca);
|
||||
cm.setActive('sninfoboxhead', scb);
|
||||
});
|
||||
|
||||
/// Quote
|
||||
ed.addCommand('mceSNQuote', function() {
|
||||
|
||||
handleSNQuote(ed,url);
|
||||
|
||||
});
|
||||
ed.addButton('snquote', {title : 'snstuff.quote_desc', cmd : 'mceSNQuote', image: url+'/images/quote.png'});
|
||||
|
||||
ed.onNodeChange.add(function(ed, cm, n) {
|
||||
|
||||
cm.setActive('snquote', n.nodeName == 'BLOCKQUOTE');
|
||||
});
|
||||
|
||||
/// LinkVorschlag
|
||||
Proposals.url = url;
|
||||
ed.addCommand('mceSNProposals', function(ui,v) {
|
||||
Proposals.findWordAll(ed);
|
||||
});
|
||||
ed.onKeyUp.add(
|
||||
function(ed,e){
|
||||
var an = ed.dom.getParent(ed.selection.getNode(),function(n){return n.nodeName == 'A'});
|
||||
if(an == null && e.keyCode == 32){
|
||||
var cm = ed.selection.getBookmark();
|
||||
var ps = ed.dom.get(cm.id+'_start').previousSibling;
|
||||
var pos = ps.nodeValue.length;
|
||||
ed.selection.moveToBookmark(cm);
|
||||
Proposals.findWord(ed,ps,pos);
|
||||
}else{
|
||||
Proposals.closeWin();
|
||||
}
|
||||
}
|
||||
);
|
||||
ed.addButton('snproposals', {title : 'snstuff.proposals_desc', cmd : 'mceSNProposals', image: url+'/images/proposals.png'});
|
||||
|
||||
ed.onLoadContent.add( SNStuffContentCounter.counter );
|
||||
ed.onChange.add( SNStuffContentCounter.counter );
|
||||
ed.onUndo.add( SNStuffContentCounter.counter );
|
||||
ed.onRedo.add( SNStuffContentCounter.counter );
|
||||
|
||||
ed.onKeyPress.add( SNStuffContentCounter.counter );
|
||||
|
||||
|
||||
}, // init
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
|
||||
getInfo : function() {
|
||||
return {
|
||||
longname : 'SN-Stuff (ImageUpload, Quote, Code, Link, etc.)',
|
||||
author : 'Member from .de',
|
||||
authorurl : 'http://www..de',
|
||||
infourl : 'http://www..de',
|
||||
version : "1.0"
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
tinymce.PluginManager.add('snstuff', tinymce.plugins.SNStuff);
|
||||
})();
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
var Proposals = {
|
||||
url: '',
|
||||
// ajaxBlock: tinyMCE.activeEditor.getParam("snstuff_proposals_ajax_block"),
|
||||
// ajaxLink: tinyMCE.activeEditor.getParam("snstuff_proposals_ajax_link"),
|
||||
|
||||
// ajaxBlock: "/ajax_block",
|
||||
// ajaxLink: "/ajax_link",
|
||||
proposalsFrame: undefined,
|
||||
proposalsFrameBody: undefined,
|
||||
proposalsFrameId: Math.round(Math.random()*1000),
|
||||
|
||||
running: false,
|
||||
cancel: function(){
|
||||
if(this.running){
|
||||
this.running = false;
|
||||
}
|
||||
},
|
||||
|
||||
findWord: function(ed, node,pos){
|
||||
running = true;
|
||||
var ntn = node;
|
||||
var word;
|
||||
var txt = node.nodeValue.substr(0,pos);
|
||||
word = txt.replace(/ $/,'').split(/ /).pop();
|
||||
if(word.length > 0){
|
||||
this.getProposals(ed,ntn, word, pos, false);
|
||||
}
|
||||
},// find word
|
||||
|
||||
findWordAll: function(ed){
|
||||
running = true;
|
||||
var wl = new Array();
|
||||
this._getContentWordList(ed.getBody(),wl);
|
||||
this.getProposals(ed,null,wl.join('+'),-1,true);
|
||||
},
|
||||
|
||||
getProposals: function(ed,node, word, pos, block){
|
||||
var po = this;
|
||||
if(!running){return;}
|
||||
|
||||
tinymce.util.XHR.send({
|
||||
url : block ? tinyMCE.activeEditor.getParam("snstuff_proposals_ajax_block", "/ajax_block")
|
||||
: tinyMCE.activeEditor.getParam("snstuff_proposals_ajax_link","/ajax_link"),
|
||||
content_type : "application/json",
|
||||
type : "POST",
|
||||
data : block ? "sn_msgbody="+escape(word) : "sn_key="+escape(word),
|
||||
async : true,
|
||||
scope : po,
|
||||
|
||||
success : function( data, req, o ) {
|
||||
var obj = tinymce.util.JSON.parse(data);
|
||||
po.showProposals(obj, ed, node, pos, block);
|
||||
},
|
||||
|
||||
error : function( type, req, o ){ alert("ERROR:"+type+"\n"+req+" - "+o);}
|
||||
});
|
||||
},
|
||||
|
||||
closeWin: function(){
|
||||
this.cancel();
|
||||
if(this.proposalsFrame && this.proposalsFrame.style.display != 'none'){
|
||||
this.proposalsFrame.style.display = 'none';
|
||||
}
|
||||
},
|
||||
showProposals:function(obj, ed, node, pos, block){
|
||||
if(!running){return;}
|
||||
// remove used Lnk
|
||||
tinymce.grep(ed.dom.select("a"), function(n) {
|
||||
var h = n.getAttributeNode('href');
|
||||
if(h != null){
|
||||
var v = h.nodeValue;
|
||||
for(var e in obj){
|
||||
if(v == obj[e].Link){
|
||||
delete obj[e];
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if(!this.proposalsFrame){this._buildFrame();}
|
||||
|
||||
var pf = this.proposalsFrameBody;
|
||||
while(pf.hasChildNodes()){
|
||||
pf.removeChild(pf.firstChild);
|
||||
}
|
||||
if(!obj){return;}
|
||||
for(var i = 0; i < obj.length; i++){
|
||||
if(!obj[i]){continue;}
|
||||
|
||||
var o = obj[i];
|
||||
var bgColor = (i%2 == 0) ? "#FFFAB3":"#FFFE9A";
|
||||
var root = this._buildHTMLElement("DIV","lnkBody_"+i,"border-bottom:black 1px solid;background-color:"+bgColor);
|
||||
var lnk = this._buildHTMLElement("IMG","lnkLnk_"+i,"float:right;cursor:pointer");
|
||||
var desc = this._buildHTMLElement("DIV", "lnkDesc_"+i, "",o.Comment);
|
||||
var prevLnk = this._buildHTMLElement("A","lnkPrevLnk_"+i,"", o.Link);
|
||||
var keyword = this._buildHTMLElement("DIV","lnkKeyWord_"+i, "font-weight:bold", o.Key);
|
||||
var small = this._buildHTMLElement("SMALL","lnkSmall_"+i);
|
||||
small.appendChild(prevLnk);
|
||||
lnk.src = this.url+"/images/add.png";
|
||||
lnk.alt = "Link einfügen";
|
||||
lnk.title = "Das Wort \""+o.Key+"\" im Text verlinken";
|
||||
prevLnk.href = o.Link;
|
||||
prevLnk.target = "blank";
|
||||
|
||||
root.appendChild(keyword); keyword.appendChild(lnk); root.appendChild(desc);root.appendChild(small);
|
||||
this._setOnclickEvent(lnk, {obj:o,block:block,ed:ed,node:node,pos:pos});
|
||||
pf.appendChild(root);
|
||||
}
|
||||
if(this.proposalsFrameBody.hasChildNodes()){
|
||||
this.proposalsFrame.style.display = "block";
|
||||
}
|
||||
},
|
||||
_setOnclickEvent:function(lnk, o){
|
||||
var p = this;
|
||||
lnk.onclick = function(){p._insertAction(o,this)};
|
||||
},
|
||||
_insertAction:function(o,fn){
|
||||
if(!o.block){
|
||||
this._insertLink(o);
|
||||
this.closeWin();
|
||||
}else{
|
||||
var fw = this._findWord(o.ed.getBody(),o.obj.Key);
|
||||
if(fw){
|
||||
this._insertLink(fw.node,fw.pos,o.obj.Link,o.ed);
|
||||
var pe = fn.parentNode.parentNode;
|
||||
pe.parentNode.removeChild(pe);
|
||||
if(!this.proposalsFrameBody.hasChildNodes()){
|
||||
this.proposalsFrame.style.display = "none";
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_insertLink: function(o){
|
||||
var node = o.node; var pos = o.pos; var lnk = o.obj.Link; var ed = o.ed;
|
||||
|
||||
var nv = node.nodeValue;
|
||||
var pre = nv.substring(0,pos).replace(/ $/,'').split(/ /);
|
||||
var post = " "+nv.substr(pos);
|
||||
var w = pre.pop();
|
||||
var a = ed.getDoc().createElement('A');
|
||||
var ha = ed.getDoc().createAttribute("href");
|
||||
var tit = ed.getDoc().createAttribute("title");
|
||||
|
||||
tit.nodeValue=o.obj.Comment;
|
||||
ha.nodeValue = lnk;
|
||||
a.setAttributeNode(ha);
|
||||
a.setAttributeNode(tit);
|
||||
a.appendChild(ed.getDoc().createTextNode(w));
|
||||
|
||||
var pnode = node.parentNode;
|
||||
|
||||
tinyMCE.execCommand("mceBeginUndoLevel");
|
||||
pnode.insertBefore(ed.getDoc().createTextNode(pre.join(' ')+' '),node);
|
||||
pnode.insertBefore(a,node);
|
||||
pnode.insertBefore(ed.getDoc().createTextNode(post),node);
|
||||
pnode.removeChild(node);
|
||||
tinyMCE.execCommand("mceEndUndoLevel");
|
||||
ed.focus();
|
||||
ed.selection.select(a);
|
||||
ed.selection.collapse();
|
||||
},
|
||||
|
||||
_findWord: function(doc, word){
|
||||
var node = doc;
|
||||
var w;
|
||||
while(node != null){
|
||||
if(node.nodeType == 1 && node.nodeName != "A"){
|
||||
w = this._findWord(node.firstChild,word);
|
||||
if(w){ return w;}
|
||||
}
|
||||
|
||||
if(node.nodeType == 3){
|
||||
var txt = node.nodeValue.toLowerCase();
|
||||
var p = txt.indexOf(word.toLowerCase());
|
||||
if(p != -1){
|
||||
return {pos:p+word.length, node: node};
|
||||
}
|
||||
}
|
||||
node = node.nextSibling;
|
||||
}
|
||||
return w;
|
||||
},
|
||||
|
||||
_getContentWordList: function(doc, wlist){
|
||||
var node = doc;
|
||||
|
||||
while(node != null){
|
||||
if(node.nodeType == 1 && node.nodeName != "A"){
|
||||
this._getContentWordList(node.firstChild, wlist);
|
||||
}
|
||||
|
||||
if(node.nodeType == 3){
|
||||
var lst = node.nodeValue.split(/ /);
|
||||
while(lst.length > 0){
|
||||
var s = lst.pop().replace(/\s/g,"");
|
||||
if(s != ""){
|
||||
wlist.push(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
node = node.nextSibling;
|
||||
}
|
||||
},
|
||||
///////////////////////
|
||||
_buildFrame: function(){
|
||||
var container = tinyMCE.activeEditor.getContentAreaContainer();
|
||||
var ot = container.offsetTop;
|
||||
var ol = container.offsetLeft + container.offsetWidth;
|
||||
|
||||
if(document.getElementsByTagName("body")[0].offsetWidth < ol+355){
|
||||
ol = document.getElementsByTagName("body")[0].offsetWidth - 360;
|
||||
}
|
||||
|
||||
var pa = (document.all) ? "absolute":"fixed";
|
||||
|
||||
var p = this._buildHTMLElement("DIV", "proposalsFrame","position:"+pa+";width:350px;left:"+ol+"px;top:"+ot+"px;padding:5px;background-color:#FFFE9A;border:solid black 1px;");
|
||||
var h = this._buildHTMLElement("DIV", "proposalsFrameHead","border-bottom:black 1px solid;font-weight:bold;background-color:#FFF27A;cursor:pointer;padding:2px;","Tipps zum Thema");
|
||||
var b = this._buildHTMLElement("DIV", "proposalsFrameBody","min-height:100px;max-height:300px;overflow:auto;padding:5px;");
|
||||
var c = this._buildHTMLElement("IMG", "proposalsFrameClose","float:right");
|
||||
|
||||
|
||||
h.onmousedown = function(){
|
||||
var p = this.parentNode;
|
||||
var ox,oy;
|
||||
this.onmouseup = function(){p.onmousemove = function(){}; p.onmouseout = function(){}}
|
||||
var m = function(ev){
|
||||
var px = (!ev) ? window.event.clientX : ev.pageX;var py = (!ev) ? window.event.clientY : ev.pageY;
|
||||
if(!ox){oy = py - parseInt(this.style.top); ox = px - parseInt(this.style.left); }
|
||||
this.style.left = (px-ox)+"px"; this.style.top = (py-oy)+"px";
|
||||
return false;
|
||||
}
|
||||
p.onmousemove = m;p.onmouseout = m;
|
||||
return false;
|
||||
}
|
||||
|
||||
var me = this;
|
||||
c.onclick = function(){me.closeWin()};
|
||||
|
||||
c.alt = "X";
|
||||
c.src = this.url+'/images/close.png';
|
||||
c.alt = "Fenster schlissen";
|
||||
c.title = "Fenster schliessen";
|
||||
|
||||
h.insertBefore(c,h.firstChild);
|
||||
p.appendChild(h); p.appendChild(b)
|
||||
|
||||
this.proposalsFrame = p;
|
||||
this.proposalsFrameBody = b;
|
||||
|
||||
document.getElementsByTagName("body")[0].appendChild(p);
|
||||
},
|
||||
|
||||
_buildHTMLElement: function(n, id, style, txt){
|
||||
var e = document.createElement(n);
|
||||
var an = document.createAttribute("id");
|
||||
an.nodeValue = id+"_"+this.proposalsFrameId;
|
||||
var clazz = document.createAttribute("class");
|
||||
clazz.nodeValue = id;
|
||||
e.setAttributeNode(clazz);
|
||||
e.setAttributeNode(an);
|
||||
|
||||
e.style.cssText = style;
|
||||
if(txt){ e.appendChild( document.createTextNode(txt)); }
|
||||
return e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
function handleSNCode(ed, url){
|
||||
var enode = ed.selection.getNode();
|
||||
var sel = ed.selection.getContent();
|
||||
var isBlock = (enode != null && enode.nodeName == 'CODE');
|
||||
|
||||
if(isBlock){
|
||||
|
||||
// Remove element
|
||||
if(enode.nodeName == 'CODE'){
|
||||
tinyMCE.execCommand("mceBeginUndoLevel");
|
||||
i = ed.selection.getBookmark();
|
||||
ed.dom.remove(enode, 1);
|
||||
ed.selection.moveToBookmark(i);
|
||||
tinyMCE.execCommand("mceEndUndoLevel");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
tinyMCE.execCommand("mceBeginUndoLevel");
|
||||
|
||||
if(sel.length == 0 ){
|
||||
|
||||
ed.windowManager.open({
|
||||
file : url + '/html/code.html',
|
||||
width : 410 + parseInt(ed.getLang('snstuff.snlink_delta_width', 0)),
|
||||
height : 480 + parseInt(ed.getLang('snstuff.snlink_delta_height', 0)),
|
||||
inline : 1
|
||||
}, {
|
||||
plugin_url : url
|
||||
});
|
||||
}else{
|
||||
ed.execCommand('mceInsertContent', false, '<code>'+ed.selection.getContent()+'</code>', {skip_undo : 1});
|
||||
}
|
||||
tinyMCE.execCommand("mceEndUndoLevel");
|
||||
|
||||
}
|
||||
|
||||
function handleSNQuote(ed, url){
|
||||
var enode = ed.selection.getNode();
|
||||
var sel = ed.selection.getContent();
|
||||
var isBlock = (enode != null && enode.nodeName == 'BLOCKQUOTE');
|
||||
|
||||
if(isBlock){
|
||||
|
||||
// Remove element
|
||||
if(enode.nodeName == 'BLOCKQUOTE'){
|
||||
tinyMCE.execCommand("mceBeginUndoLevel");
|
||||
i = ed.selection.getBookmark();
|
||||
ed.dom.remove(enode, 1);
|
||||
ed.selection.moveToBookmark(i);
|
||||
tinyMCE.execCommand("mceEndUndoLevel");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
tinyMCE.execCommand("mceBeginUndoLevel");
|
||||
|
||||
if(sel.length == 0 ){
|
||||
|
||||
ed.windowManager.open({
|
||||
file : url + '/html/quote.html',
|
||||
width : 410 + parseInt(ed.getLang('snstuff.snquote_delta_width', 0)),
|
||||
height : 480 + parseInt(ed.getLang('snstuff.snquote_delta_height', 0)),
|
||||
inline : 1
|
||||
}, {
|
||||
plugin_url : url
|
||||
});
|
||||
}else{
|
||||
ed.execCommand('mceInsertContent', false, '<blockquote>'+ed.selection.getContent()+'</blockquote>', {skip_undo : 1});
|
||||
}
|
||||
tinyMCE.execCommand("mceEndUndoLevel");
|
||||
|
||||
}
|
||||
|
||||
|
||||
function handleSNInfoBox(ed, url){
|
||||
var enode = ed.selection.getNode();
|
||||
var sel = ed.selection.getContent();
|
||||
|
||||
ed.windowManager.open({
|
||||
file : url + '/html/infobox.html',
|
||||
width : 250+ parseInt(ed.getLang('snstuff.snquote_delta_width', 0)),
|
||||
height : 100 + parseInt(ed.getLang('snstuff.snquote_delta_height', 0)),
|
||||
inline : 1
|
||||
}, {
|
||||
node: enode,
|
||||
plugin_url : url
|
||||
});
|
||||
}
|
||||
|
||||
function handleSNInfoBoxHead(ed, url){
|
||||
var enode = ed.dom.getParent(ed.selection.getNode(), function(n) {return ed.dom.hasClass(n, "snInfoBoxHead");})
|
||||
var sel = ed.selection.getContent();
|
||||
|
||||
tinyMCE.execCommand("mceBeginUndoLevel");
|
||||
if(sel.length > 0){
|
||||
ed.execCommand('mceInsertRawHTML', false, '<span id="__snInfoBoxHeadTmp">'+ed.selection.getContent()+'</span>',{skip_undo : 1});
|
||||
ed.dom.setAttribs('__snInfoBoxHeadTmp', {style:"", class:"snInfoBoxHead"});
|
||||
ed.dom.setAttrib('__snInfoBoxHeadTmp', 'id', '');
|
||||
}else{
|
||||
i = ed.selection.getBookmark();
|
||||
ed.dom.remove(enode, 1);
|
||||
ed.selection.moveToBookmark(i);
|
||||
}
|
||||
tinyMCE.execCommand("mceEndUndoLevel");
|
||||
}
|
||||
/////////////////////////////////////////////////
|
||||
|
||||
SNStuffContentCounter = {
|
||||
elm: Array(),
|
||||
|
||||
isInit:false,
|
||||
init: function(ed){
|
||||
|
||||
var elm = ed.getParam("snstuff_contentcounter","").replace(/ /g,"").split(",");
|
||||
for(var e = 0; e < elm.length; e++){
|
||||
var l = new Object();
|
||||
|
||||
var cv = ed.getParam("snstuff_charcolor_"+elm[e],"none").replace(/ /g,"");
|
||||
|
||||
if(cv != "none"){
|
||||
var a = new Array();
|
||||
cc = cv.split(",");
|
||||
for(var cci = 0; cci < cc.length; cci++){
|
||||
var v = cc[cci].split(":");
|
||||
a.push({v:v[0],c:v[1]});
|
||||
}
|
||||
l.c = a.sort(function(a,b){return a.v-b.v});
|
||||
}
|
||||
|
||||
var wv = ed.getParam("snstuff_wordcolor_"+elm[e],"none").replace(/ /g,"");
|
||||
|
||||
if(wv != "none"){
|
||||
var a = new Array();
|
||||
wc = wv.split(",");
|
||||
for(var wci = 0; wci < wc.length; wci++){
|
||||
var v = wc[wci].split(":");
|
||||
a.push({v:v[0],c:v[1]});
|
||||
}
|
||||
l.w = a.sort(function(a,b){return a.v-b.v});
|
||||
}
|
||||
|
||||
this.elm[elm[e]] = l;
|
||||
|
||||
}
|
||||
|
||||
this.isInit = true;
|
||||
},
|
||||
|
||||
counter : function(ed,e){
|
||||
if(!SNStuffContentCounter.isInit){
|
||||
SNStuffContentCounter.init(ed);
|
||||
}
|
||||
if(SNStuffContentCounter.elm[ed.id]){
|
||||
var c = ed.getContent().replace(/<br \/>/g," ").replace(/<.+?>/g,"").replace(/ {1,}/g," ").replace(/^ | $/g,"");
|
||||
var cl = c.length;
|
||||
var wl = c.split(" ").length;
|
||||
var p = tinymce.DOM.get(ed.id + '_path_row');
|
||||
html = "";
|
||||
|
||||
var cvl = SNStuffContentCounter.elm[ed.id];
|
||||
if(cvl.c){
|
||||
var col = "";
|
||||
for(var i = 0; i < cvl.c.length; i++){
|
||||
if(cl > cvl.c[i].v){
|
||||
col = "color:"+cvl.c[i].c;
|
||||
}
|
||||
}
|
||||
html += ' <span style="'+col+'"> Zeichen:'+cl+' </span> ';
|
||||
}
|
||||
|
||||
if(cvl.w){
|
||||
|
||||
var col = "";
|
||||
for(var i = 0; i < cvl.w.length; i++){
|
||||
if(wl > cvl.w[i].v){
|
||||
col = "color:"+cvl.w[i].c;
|
||||
}
|
||||
}
|
||||
html += ' <span style="'+col+'"> Wörter:'+wl+' </span> ';
|
||||
}
|
||||
tinymce.DOM.setHTML(p,html);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
618
sn_templates/editor_stuff/plugin/snstuff/editor_plugin_src.js
Normal file
@@ -0,0 +1,618 @@
|
||||
(function() {
|
||||
|
||||
tinymce.create('tinymce.plugins.SNStuff', {
|
||||
|
||||
//// ImageUpload
|
||||
init : function(ed, url) {
|
||||
ed.onInit.add(function() {
|
||||
if (ed.settings.content_css !== false)
|
||||
ed.dom.loadCSS(url + "/css/content.css");
|
||||
});
|
||||
|
||||
ed.addCommand('mceSNImages', function() {
|
||||
ed.windowManager.open({
|
||||
file : url + '/html/image.html',
|
||||
width : 490,
|
||||
height : 550,
|
||||
inline : 1
|
||||
}, {
|
||||
plugin_url : url
|
||||
});
|
||||
});
|
||||
|
||||
ed.addButton('snimages', {
|
||||
title : 'snstuff.img_desc',
|
||||
cmd : 'mceSNImages',
|
||||
image : url + '/images/insert-image.png'
|
||||
});
|
||||
|
||||
ed.onNodeChange.add(function(ed, cm, n) {
|
||||
cm.setActive('snimages', n.nodeName == 'IMG');
|
||||
});
|
||||
|
||||
|
||||
/// Link
|
||||
ed.addCommand('mceSNLink', function() {
|
||||
ed.windowManager.open({
|
||||
file : url + '/html/link.html',
|
||||
width : 500 + parseInt(ed.getLang('snstuff.snlink_delta_width', 0)),
|
||||
height : 180 + parseInt(ed.getLang('snstuff.snlink_delta_height', 0)),
|
||||
inline : 1
|
||||
}, {
|
||||
plugin_url : url
|
||||
});
|
||||
});
|
||||
|
||||
ed.addButton('snlink', {title : 'snstuff.lnk_desc', cmd : 'mceSNLink', image: url+'/images/insert-link.png'});
|
||||
|
||||
ed.onNodeChange.add(function(ed, cm, n) {
|
||||
cm.setActive('snlink', false);
|
||||
var node = n;
|
||||
while(node != null){
|
||||
if(node.nodeName == 'A'){
|
||||
cm.setActive('snlink', true);
|
||||
break;
|
||||
}
|
||||
node = node.parentNode;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/// Code
|
||||
ed.addCommand('mceSNCode', function() {
|
||||
|
||||
handleSNCode(ed,url);
|
||||
|
||||
});
|
||||
ed.addButton('sncode', {title : 'snstuff.code_desc', cmd : 'mceSNCode', image: url+'/images/code-context.png'});
|
||||
|
||||
ed.onNodeChange.add(function(ed, cm, n) {
|
||||
cm.setActive('sncode', n.nodeName == 'CODE');
|
||||
});
|
||||
|
||||
/// Infobox
|
||||
ed.addCommand('mceSNInfoBox', function() { handleSNInfoBox(ed, url)});
|
||||
ed.addCommand('mceSNInfoBoxHead', function() { handleSNInfoBoxHead(ed, url) });
|
||||
|
||||
|
||||
ed.addButton('sninfobox', {title : 'snstuff.infobox_desc', cmd : 'mceSNInfoBox', image: url+'/images/textinfo.png'});
|
||||
ed.addButton('sninfoboxhead', {title : 'snstuff.infoboxhead_desc', cmd : 'mceSNInfoBoxHead', image: url+'/images/textinfo_head.png'});
|
||||
|
||||
|
||||
ed.onNodeChange.add(function(ed, cm, n) {
|
||||
var scas = ed.dom.getParent(ed.selection.getStart(), function(n) {return ed.dom.hasClass(n, "snInfoBox");}) != null;
|
||||
var scae = ed.dom.getParent(ed.selection.getEnd(), function(n) {return ed.dom.hasClass(n, "snInfoBox");}) != null;
|
||||
var sca = scas && scae;
|
||||
var scbs = ed.dom.getParent(ed.selection.getStart(), function(n) {return ed.dom.hasClass(n, "snInfoBoxHead");}) != null;
|
||||
var scbe = ed.dom.getParent(ed.selection.getStart(), function(n) {return ed.dom.hasClass(n, "snInfoBoxHead");}) != null;
|
||||
var scb = scbs && scbe;
|
||||
|
||||
var cs = ed.selection.getContent().length > 0;
|
||||
cm.setDisabled('sninfobox', scae != scas);
|
||||
cm.setDisabled('sninfoboxhead', (!((sca && cs) || scb) || scae != scas));
|
||||
cm.setActive('sninfobox', sca);
|
||||
cm.setActive('sninfoboxhead', scb);
|
||||
});
|
||||
|
||||
/// Quote
|
||||
ed.addCommand('mceSNQuote', function() {
|
||||
|
||||
handleSNQuote(ed,url);
|
||||
|
||||
});
|
||||
ed.addButton('snquote', {title : 'snstuff.quote_desc', cmd : 'mceSNQuote', image: url+'/images/quote.png'});
|
||||
|
||||
ed.onNodeChange.add(function(ed, cm, n) {
|
||||
|
||||
cm.setActive('snquote', n.nodeName == 'BLOCKQUOTE');
|
||||
});
|
||||
|
||||
/// LinkVorschlag
|
||||
Proposals.url = url;
|
||||
ed.addCommand('mceSNProposals', function(ui,v) {
|
||||
Proposals.findWordAll(ed);
|
||||
});
|
||||
ed.onKeyUp.add(
|
||||
function(ed,e){
|
||||
var an = ed.dom.getParent(ed.selection.getNode(),function(n){return n.nodeName == 'A'});
|
||||
if(an == null && e.keyCode == 32){
|
||||
var cm = ed.selection.getBookmark();
|
||||
var ps = ed.dom.get(cm.id+'_start').previousSibling;
|
||||
var pos = ps.nodeValue.length;
|
||||
ed.selection.moveToBookmark(cm);
|
||||
Proposals.findWord(ed,ps,pos);
|
||||
}else{
|
||||
Proposals.closeWin();
|
||||
}
|
||||
}
|
||||
);
|
||||
ed.addButton('snproposals', {title : 'snstuff.proposals_desc', cmd : 'mceSNProposals', image: url+'/images/proposals.png'});
|
||||
|
||||
ed.onLoadContent.add( SNStuffContentCounter.counter );
|
||||
ed.onChange.add( SNStuffContentCounter.counter );
|
||||
ed.onUndo.add( SNStuffContentCounter.counter );
|
||||
ed.onRedo.add( SNStuffContentCounter.counter );
|
||||
|
||||
ed.onKeyPress.add( SNStuffContentCounter.counter );
|
||||
|
||||
|
||||
}, // init
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
|
||||
getInfo : function() {
|
||||
return {
|
||||
longname : 'SN-Stuff (ImageUpload, Quote, Code, Link, etc.)',
|
||||
author : 'Member from .de',
|
||||
authorurl : 'http://www..de',
|
||||
infourl : 'http://www..de',
|
||||
version : "1.0"
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
tinymce.PluginManager.add('snstuff', tinymce.plugins.SNStuff);
|
||||
})();
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
var Proposals = {
|
||||
url: '',
|
||||
// ajaxBlock: tinyMCE.activeEditor.getParam("snstuff_proposals_ajax_block"),
|
||||
// ajaxLink: tinyMCE.activeEditor.getParam("snstuff_proposals_ajax_link"),
|
||||
|
||||
// ajaxBlock: "/ajax_block",
|
||||
// ajaxLink: "/ajax_link",
|
||||
proposalsFrame: undefined,
|
||||
proposalsFrameBody: undefined,
|
||||
proposalsFrameId: Math.round(Math.random()*1000),
|
||||
|
||||
running: false,
|
||||
cancel: function(){
|
||||
if(this.running){
|
||||
this.running = false;
|
||||
}
|
||||
},
|
||||
|
||||
findWord: function(ed, node,pos){
|
||||
running = true;
|
||||
var ntn = node;
|
||||
var word;
|
||||
var txt = node.nodeValue.substr(0,pos);
|
||||
word = txt.replace(/ $/,'').split(/ /).pop();
|
||||
if(word.length > 0){
|
||||
this.getProposals(ed,ntn, word, pos, false);
|
||||
}
|
||||
},// find word
|
||||
|
||||
findWordAll: function(ed){
|
||||
running = true;
|
||||
var wl = new Array();
|
||||
this._getContentWordList(ed.getBody(),wl);
|
||||
this.getProposals(ed,null,wl.join('+'),-1,true);
|
||||
},
|
||||
|
||||
getProposals: function(ed,node, word, pos, block){
|
||||
var po = this;
|
||||
if(!running){return;}
|
||||
|
||||
tinymce.util.XHR.send({
|
||||
url : block ? tinyMCE.activeEditor.getParam("snstuff_proposals_ajax_block", "/ajax_block")
|
||||
: tinyMCE.activeEditor.getParam("snstuff_proposals_ajax_link","/ajax_link"),
|
||||
content_type : "application/json",
|
||||
type : "POST",
|
||||
data : block ? "sn_msgbody="+escape(word) : "sn_key="+escape(word),
|
||||
async : true,
|
||||
scope : po,
|
||||
|
||||
success : function( data, req, o ) {
|
||||
var obj = tinymce.util.JSON.parse(data);
|
||||
po.showProposals(obj, ed, node, pos, block);
|
||||
},
|
||||
|
||||
error : function( type, req, o ){ alert("ERROR:"+type+"\n"+req+" - "+o);}
|
||||
});
|
||||
},
|
||||
|
||||
closeWin: function(){
|
||||
this.cancel();
|
||||
if(this.proposalsFrame && this.proposalsFrame.style.display != 'none'){
|
||||
this.proposalsFrame.style.display = 'none';
|
||||
}
|
||||
},
|
||||
showProposals:function(obj, ed, node, pos, block){
|
||||
if(!running){return;}
|
||||
// remove used Lnk
|
||||
tinymce.grep(ed.dom.select("a"), function(n) {
|
||||
var h = n.getAttributeNode('href');
|
||||
if(h != null){
|
||||
var v = h.nodeValue;
|
||||
for(var e in obj){
|
||||
if(v == obj[e].Link){
|
||||
delete obj[e];
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if(!this.proposalsFrame){this._buildFrame();}
|
||||
|
||||
var pf = this.proposalsFrameBody;
|
||||
while(pf.hasChildNodes()){
|
||||
pf.removeChild(pf.firstChild);
|
||||
}
|
||||
if(!obj){return;}
|
||||
for(var i = 0; i < obj.length; i++){
|
||||
if(!obj[i]){continue;}
|
||||
|
||||
var o = obj[i];
|
||||
var bgColor = (i%2 == 0) ? "#FFFAB3":"#FFFE9A";
|
||||
var root = this._buildHTMLElement("DIV","lnkBody_"+i,"border-bottom:black 1px solid;background-color:"+bgColor);
|
||||
var lnk = this._buildHTMLElement("IMG","lnkLnk_"+i,"float:right;cursor:pointer");
|
||||
var desc = this._buildHTMLElement("DIV", "lnkDesc_"+i, "",o.Comment);
|
||||
var prevLnk = this._buildHTMLElement("A","lnkPrevLnk_"+i,"", o.Link);
|
||||
var keyword = this._buildHTMLElement("DIV","lnkKeyWord_"+i, "font-weight:bold", o.Key);
|
||||
var small = this._buildHTMLElement("SMALL","lnkSmall_"+i);
|
||||
small.appendChild(prevLnk);
|
||||
lnk.src = this.url+"/images/add.png";
|
||||
lnk.alt = "Link einfügen";
|
||||
lnk.title = "Das Wort \""+o.Key+"\" im Text verlinken";
|
||||
prevLnk.href = o.Link;
|
||||
prevLnk.target = "blank";
|
||||
|
||||
root.appendChild(keyword); keyword.appendChild(lnk); root.appendChild(desc);root.appendChild(small);
|
||||
this._setOnclickEvent(lnk, {obj:o,block:block,ed:ed,node:node,pos:pos});
|
||||
pf.appendChild(root);
|
||||
}
|
||||
if(this.proposalsFrameBody.hasChildNodes()){
|
||||
this.proposalsFrame.style.display = "block";
|
||||
}
|
||||
},
|
||||
_setOnclickEvent:function(lnk, o){
|
||||
var p = this;
|
||||
lnk.onclick = function(){p._insertAction(o,this)};
|
||||
},
|
||||
_insertAction:function(o,fn){
|
||||
if(!o.block){
|
||||
this._insertLink(o);
|
||||
this.closeWin();
|
||||
}else{
|
||||
var fw = this._findWord(o.ed.getBody(),o.obj.Key);
|
||||
if(fw){
|
||||
this._insertLink(fw.node,fw.pos,o.obj.Link,o.ed);
|
||||
var pe = fn.parentNode.parentNode;
|
||||
pe.parentNode.removeChild(pe);
|
||||
if(!this.proposalsFrameBody.hasChildNodes()){
|
||||
this.proposalsFrame.style.display = "none";
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_insertLink: function(o){
|
||||
var node = o.node; var pos = o.pos; var lnk = o.obj.Link; var ed = o.ed;
|
||||
|
||||
var nv = node.nodeValue;
|
||||
var pre = nv.substring(0,pos).replace(/ $/,'').split(/ /);
|
||||
var post = " "+nv.substr(pos);
|
||||
var w = pre.pop();
|
||||
var a = ed.getDoc().createElement('A');
|
||||
var ha = ed.getDoc().createAttribute("href");
|
||||
var tit = ed.getDoc().createAttribute("title");
|
||||
|
||||
tit.nodeValue=o.obj.Comment;
|
||||
ha.nodeValue = lnk;
|
||||
a.setAttributeNode(ha);
|
||||
a.setAttributeNode(tit);
|
||||
a.appendChild(ed.getDoc().createTextNode(w));
|
||||
|
||||
var pnode = node.parentNode;
|
||||
|
||||
tinyMCE.execCommand("mceBeginUndoLevel");
|
||||
pnode.insertBefore(ed.getDoc().createTextNode(pre.join(' ')+' '),node);
|
||||
pnode.insertBefore(a,node);
|
||||
pnode.insertBefore(ed.getDoc().createTextNode(post),node);
|
||||
pnode.removeChild(node);
|
||||
tinyMCE.execCommand("mceEndUndoLevel");
|
||||
ed.focus();
|
||||
ed.selection.select(a);
|
||||
ed.selection.collapse();
|
||||
},
|
||||
|
||||
_findWord: function(doc, word){
|
||||
var node = doc;
|
||||
var w;
|
||||
while(node != null){
|
||||
if(node.nodeType == 1 && node.nodeName != "A"){
|
||||
w = this._findWord(node.firstChild,word);
|
||||
if(w){ return w;}
|
||||
}
|
||||
|
||||
if(node.nodeType == 3){
|
||||
var txt = node.nodeValue.toLowerCase();
|
||||
var p = txt.indexOf(word.toLowerCase());
|
||||
if(p != -1){
|
||||
return {pos:p+word.length, node: node};
|
||||
}
|
||||
}
|
||||
node = node.nextSibling;
|
||||
}
|
||||
return w;
|
||||
},
|
||||
|
||||
_getContentWordList: function(doc, wlist){
|
||||
var node = doc;
|
||||
|
||||
while(node != null){
|
||||
if(node.nodeType == 1 && node.nodeName != "A"){
|
||||
this._getContentWordList(node.firstChild, wlist);
|
||||
}
|
||||
|
||||
if(node.nodeType == 3){
|
||||
var lst = node.nodeValue.split(/ /);
|
||||
while(lst.length > 0){
|
||||
var s = lst.pop().replace(/\s/g,"");
|
||||
if(s != ""){
|
||||
wlist.push(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
node = node.nextSibling;
|
||||
}
|
||||
},
|
||||
///////////////////////
|
||||
_buildFrame: function(){
|
||||
var container = tinyMCE.activeEditor.getContentAreaContainer();
|
||||
var ot = container.offsetTop;
|
||||
var ol = container.offsetLeft + container.offsetWidth;
|
||||
|
||||
if(document.getElementsByTagName("body")[0].offsetWidth < ol+355){
|
||||
ol = document.getElementsByTagName("body")[0].offsetWidth - 360;
|
||||
}
|
||||
|
||||
var pa = (document.all) ? "absolute":"fixed";
|
||||
|
||||
var p = this._buildHTMLElement("DIV", "proposalsFrame","position:"+pa+";width:350px;left:"+ol+"px;top:"+ot+"px;padding:5px;background-color:#FFFE9A;border:solid black 1px;");
|
||||
var h = this._buildHTMLElement("DIV", "proposalsFrameHead","border-bottom:black 1px solid;font-weight:bold;background-color:#FFF27A;cursor:pointer;padding:2px;","Tipps zum Thema");
|
||||
var b = this._buildHTMLElement("DIV", "proposalsFrameBody","min-height:100px;max-height:300px;overflow:auto;padding:5px;");
|
||||
var c = this._buildHTMLElement("IMG", "proposalsFrameClose","float:right");
|
||||
|
||||
|
||||
h.onmousedown = function(){
|
||||
var p = this.parentNode;
|
||||
var ox,oy;
|
||||
this.onmouseup = function(){p.onmousemove = function(){}; p.onmouseout = function(){}}
|
||||
var m = function(ev){
|
||||
var px = (!ev) ? window.event.clientX : ev.pageX;var py = (!ev) ? window.event.clientY : ev.pageY;
|
||||
if(!ox){oy = py - parseInt(this.style.top); ox = px - parseInt(this.style.left); }
|
||||
this.style.left = (px-ox)+"px"; this.style.top = (py-oy)+"px";
|
||||
return false;
|
||||
}
|
||||
p.onmousemove = m;p.onmouseout = m;
|
||||
return false;
|
||||
}
|
||||
|
||||
var me = this;
|
||||
c.onclick = function(){me.closeWin()};
|
||||
|
||||
c.alt = "X";
|
||||
c.src = this.url+'/images/close.png';
|
||||
c.alt = "Fenster schlissen";
|
||||
c.title = "Fenster schliessen";
|
||||
|
||||
h.insertBefore(c,h.firstChild);
|
||||
p.appendChild(h); p.appendChild(b)
|
||||
|
||||
this.proposalsFrame = p;
|
||||
this.proposalsFrameBody = b;
|
||||
|
||||
document.getElementsByTagName("body")[0].appendChild(p);
|
||||
},
|
||||
|
||||
_buildHTMLElement: function(n, id, style, txt){
|
||||
var e = document.createElement(n);
|
||||
var an = document.createAttribute("id");
|
||||
an.nodeValue = id+"_"+this.proposalsFrameId;
|
||||
var clazz = document.createAttribute("class");
|
||||
clazz.nodeValue = id;
|
||||
e.setAttributeNode(clazz);
|
||||
e.setAttributeNode(an);
|
||||
|
||||
e.style.cssText = style;
|
||||
if(txt){ e.appendChild( document.createTextNode(txt)); }
|
||||
return e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
function handleSNCode(ed, url){
|
||||
var enode = ed.selection.getNode();
|
||||
var sel = ed.selection.getContent();
|
||||
var isBlock = (enode != null && enode.nodeName == 'CODE');
|
||||
|
||||
if(isBlock){
|
||||
|
||||
// Remove element
|
||||
if(enode.nodeName == 'CODE'){
|
||||
tinyMCE.execCommand("mceBeginUndoLevel");
|
||||
i = ed.selection.getBookmark();
|
||||
ed.dom.remove(enode, 1);
|
||||
ed.selection.moveToBookmark(i);
|
||||
tinyMCE.execCommand("mceEndUndoLevel");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
tinyMCE.execCommand("mceBeginUndoLevel");
|
||||
|
||||
if(sel.length == 0 ){
|
||||
|
||||
ed.windowManager.open({
|
||||
file : url + '/html/code.html',
|
||||
width : 410 + parseInt(ed.getLang('snstuff.snlink_delta_width', 0)),
|
||||
height : 480 + parseInt(ed.getLang('snstuff.snlink_delta_height', 0)),
|
||||
inline : 1
|
||||
}, {
|
||||
plugin_url : url
|
||||
});
|
||||
}else{
|
||||
ed.execCommand('mceInsertContent', false, '<code>'+ed.selection.getContent()+'</code>', {skip_undo : 1});
|
||||
}
|
||||
tinyMCE.execCommand("mceEndUndoLevel");
|
||||
|
||||
}
|
||||
|
||||
function handleSNQuote(ed, url){
|
||||
var enode = ed.selection.getNode();
|
||||
var sel = ed.selection.getContent();
|
||||
var isBlock = (enode != null && enode.nodeName == 'BLOCKQUOTE');
|
||||
|
||||
if(isBlock){
|
||||
|
||||
// Remove element
|
||||
if(enode.nodeName == 'BLOCKQUOTE'){
|
||||
tinyMCE.execCommand("mceBeginUndoLevel");
|
||||
i = ed.selection.getBookmark();
|
||||
ed.dom.remove(enode, 1);
|
||||
ed.selection.moveToBookmark(i);
|
||||
tinyMCE.execCommand("mceEndUndoLevel");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
tinyMCE.execCommand("mceBeginUndoLevel");
|
||||
|
||||
if(sel.length == 0 ){
|
||||
|
||||
ed.windowManager.open({
|
||||
file : url + '/html/quote.html',
|
||||
width : 410 + parseInt(ed.getLang('snstuff.snquote_delta_width', 0)),
|
||||
height : 450 + parseInt(ed.getLang('snstuff.snquote_delta_height', 0)),
|
||||
inline : 1
|
||||
}, {
|
||||
plugin_url : url
|
||||
});
|
||||
}else{
|
||||
ed.execCommand('mceInsertContent', false, '<blockquote>'+ed.selection.getContent()+'</blockquote>', {skip_undo : 1});
|
||||
}
|
||||
tinyMCE.execCommand("mceEndUndoLevel");
|
||||
|
||||
}
|
||||
|
||||
|
||||
function handleSNInfoBox(ed, url){
|
||||
var enode = ed.selection.getNode();
|
||||
var sel = ed.selection.getContent();
|
||||
|
||||
ed.windowManager.open({
|
||||
file : url + '/html/infobox.html',
|
||||
width : 250+ parseInt(ed.getLang('snstuff.snquote_delta_width', 0)),
|
||||
height : 100 + parseInt(ed.getLang('snstuff.snquote_delta_height', 0)),
|
||||
inline : 1
|
||||
}, {
|
||||
node: enode,
|
||||
plugin_url : url
|
||||
});
|
||||
}
|
||||
|
||||
function handleSNInfoBoxHead(ed, url){
|
||||
var enode = ed.dom.getParent(ed.selection.getNode(), function(n) {return ed.dom.hasClass(n, "snInfoBoxHead");})
|
||||
var sel = ed.selection.getContent();
|
||||
|
||||
tinyMCE.execCommand("mceBeginUndoLevel");
|
||||
if(sel.length > 0){
|
||||
ed.execCommand('mceInsertRawHTML', false, '<span id="__snInfoBoxHeadTmp">'+ed.selection.getContent()+'</span>',{skip_undo : 1});
|
||||
ed.dom.setAttribs('__snInfoBoxHeadTmp', {style:"", class:"snInfoBoxHead"});
|
||||
ed.dom.setAttrib('__snInfoBoxHeadTmp', 'id', '');
|
||||
}else{
|
||||
i = ed.selection.getBookmark();
|
||||
ed.dom.remove(enode, 1);
|
||||
ed.selection.moveToBookmark(i);
|
||||
}
|
||||
tinyMCE.execCommand("mceEndUndoLevel");
|
||||
}
|
||||
/////////////////////////////////////////////////
|
||||
|
||||
SNStuffContentCounter = {
|
||||
elm: Array(),
|
||||
|
||||
isInit:false,
|
||||
init: function(ed){
|
||||
|
||||
var elm = ed.getParam("snstuff_contentcounter","").replace(/ /g,"").split(",");
|
||||
for(var e = 0; e < elm.length; e++){
|
||||
var l = new Object();
|
||||
|
||||
var cv = ed.getParam("snstuff_charcolor_"+elm[e],"none").replace(/ /g,"");
|
||||
|
||||
if(cv != "none"){
|
||||
var a = new Array();
|
||||
cc = cv.split(",");
|
||||
for(var cci = 0; cci < cc.length; cci++){
|
||||
var v = cc[cci].split(":");
|
||||
a.push({v:v[0],c:v[1]});
|
||||
}
|
||||
l.c = a.sort(function(a,b){return a.v-b.v});
|
||||
}
|
||||
|
||||
var wv = ed.getParam("snstuff_wordcolor_"+elm[e],"none").replace(/ /g,"");
|
||||
|
||||
if(wv != "none"){
|
||||
var a = new Array();
|
||||
wc = wv.split(",");
|
||||
for(var wci = 0; wci < wc.length; wci++){
|
||||
var v = wc[wci].split(":");
|
||||
a.push({v:v[0],c:v[1]});
|
||||
}
|
||||
l.w = a.sort(function(a,b){return a.v-b.v});
|
||||
}
|
||||
|
||||
this.elm[elm[e]] = l;
|
||||
|
||||
}
|
||||
|
||||
this.isInit = true;
|
||||
},
|
||||
|
||||
counter : function(ed,e){
|
||||
if(!SNStuffContentCounter.isInit){
|
||||
SNStuffContentCounter.init(ed);
|
||||
}
|
||||
if(SNStuffContentCounter.elm[ed.id]){
|
||||
var c = ed.getContent().replace(/<br \/>/g," ").replace(/<.+?>/g,"").replace(/ {1,}/g," ").replace(/^ | $/g,"");
|
||||
var cl = c.length;
|
||||
var wl = c.split(" ").length;
|
||||
var p = tinymce.DOM.get(ed.id + '_path_row');
|
||||
html = "";
|
||||
|
||||
var cvl = SNStuffContentCounter.elm[ed.id];
|
||||
if(cvl.c){
|
||||
var col = "";
|
||||
for(var i = 0; i < cvl.c.length; i++){
|
||||
if(cl > cvl.c[i].v){
|
||||
col = "color:"+cvl.c[i].c;
|
||||
}
|
||||
}
|
||||
html += ' <span style="'+col+'"> Zeichen:'+cl+' </span> ';
|
||||
}
|
||||
|
||||
if(cvl.w){
|
||||
|
||||
var col = "";
|
||||
for(var i = 0; i < cvl.w.length; i++){
|
||||
if(wl > cvl.w[i].v){
|
||||
col = "color:"+cvl.w[i].c;
|
||||
}
|
||||
}
|
||||
html += ' <span style="'+col+'"> Wörter:'+wl+' </span> ';
|
||||
}
|
||||
tinymce.DOM.setHTML(p,html);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
32
sn_templates/editor_stuff/plugin/snstuff/html/code.html
Normal file
@@ -0,0 +1,32 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>{#snstuff_dlg.code_title}</title>
|
||||
<script type="text/javascript" src="../../../tiny_mce_popup.js"></script>
|
||||
<!-- <script type="text/javascript" src="../../../utils/mctabs.js"></script> -->
|
||||
<script type="text/javascript" src="../../../utils/form_utils.js"></script>
|
||||
<script type="text/javascript" src="../../../utils/validate.js"></script>
|
||||
<script type="text/javascript" src="../js/sncode.js"></script>
|
||||
<!-- <link href="css/snlink.css" rel="stylesheet" type="text/css" /> -->
|
||||
</head>
|
||||
<body id="advlink" style="display: none">
|
||||
<form onsubmit="insertAction();return false;" action="#">
|
||||
<div class="panel">
|
||||
<fieldset>
|
||||
<legend>{#snstuff_dlg.code_general_props}</legend>
|
||||
|
||||
<textarea id="text" rows="30" cols="60"></textarea>
|
||||
</fieldset>
|
||||
</div>
|
||||
<div class="mceActionPanel">
|
||||
<div style="float: left">
|
||||
<input type="submit" id="insert" name="insert" value="{#insert}" />
|
||||
</div>
|
||||
|
||||
<div style="float: right">
|
||||
<input type="button" id="cancel" name="cancel" value="{#cancel}" onclick="tinyMCEPopup.close();" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
117
sn_templates/editor_stuff/plugin/snstuff/html/image.html
Normal file
@@ -0,0 +1,117 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>{#snstuff_dlg.img_dialog_title}</title>
|
||||
<script type="text/javascript" src="../../../tiny_mce_popup.js"></script>
|
||||
<!-- <script type="text/javascript" src="../../../utils/mctabs.js"></script> -->
|
||||
<script type="text/javascript" src="../../../utils/form_utils.js"></script>
|
||||
<!-- <script type="text/javascript" src="../../../utils/validate.js"></script> -->
|
||||
<script type="text/javascript" src="../../../utils/editable_selects.js"></script>
|
||||
|
||||
<script type="text/javascript" src="../js/config.js"></script>
|
||||
<script type="text/javascript" src="../js/image.js"></script>
|
||||
|
||||
<link href="../css/default.css" rel="stylesheet" type="text/css" />
|
||||
</head>
|
||||
<body id="snimages" style="display: none">
|
||||
|
||||
<div class="panel_wrapper">
|
||||
|
||||
<iframe id="actionTarget" name="actionTarget" style="width:1px; height:1px; visibility:hidden" onload="ImageDialog.actionStop()"></iframe>
|
||||
<div id="general_panel" class="panel current">
|
||||
|
||||
<form id="uploadForm" name="uploadForm" enctype="multipart/form-data" action="" method="post" target="actionTarget" onsubmit="ImageDialog.uploadStart()">
|
||||
<fieldset>
|
||||
<legend>{#snstuff_dlg.img_tab_upload}</legend>
|
||||
|
||||
<img id="waitImg" src="../images/wait.gif" style="float:right; visibility:hidden">
|
||||
|
||||
<table border="0" cellpadding="4" cellspacing="0">
|
||||
<tr>
|
||||
<td><lable for="input_filed">{#snstuff_dlg.img_imagefile_select}</lable>
|
||||
<input id="fileField" name="sn_filename" type="file">
|
||||
</td>
|
||||
<td>
|
||||
<input id="uploadSubmit" type="submit" value="{#snstuff_dlg.img_imagefile_sndbtn}">
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
</fieldset>
|
||||
</form>
|
||||
<br>
|
||||
<fieldset>
|
||||
<legend>{#snstuff_dlg.img_general}</legend>
|
||||
|
||||
<table class="properties">
|
||||
<!-- <tr rowspan="2">
|
||||
<td class="column1"><label id="srclabel" for="src">{#snstuff_dlg.src}</label></td>
|
||||
<td>
|
||||
<table border="0" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td><input name="src" disabled type="text" id="src" value="" class="mceFocus" onchange="ImageDialog.showPreviewImage(this.value);" /></td>
|
||||
<td id="srcbrowsercontainer"> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>-->
|
||||
<tr>
|
||||
<td colspan="2"><label for="src_list">{#snstuff_dlg.img_image_list}</label></td>
|
||||
<td colspan="2"><select id="src_list" name="src_list" onchange="ImageDialog.srcListAction( this.value );"><option value="">Lade Medienliste...</option></select></td>
|
||||
</tr>
|
||||
<tr id="pic">
|
||||
<td colspan="2">
|
||||
<label id="l_src_list_size" for="src_list_size">{#snstuff_dlg.img_pic_select}</label>
|
||||
<label id="l_src_list_vpic" for="src_list_vid_pic">{#snstuff_dlg.img_vpic_select}</label>
|
||||
</td>
|
||||
<td colspan="2">
|
||||
<span id="src_list_size_elm">{#snstuff_dlg.img_pic_show}<select id="src_list_size" name="src_list_size" onchange="ImageDialog.media1Action(this.value)"><option value=""></option></select></span>
|
||||
<span id="src_list_size_full_elm">{#snstuff_dlg.img_pic_show_full}<select id="src_list_size_full" name="src_list_size_full" onchange="ImageDialog.media2Action( this.value)"><option value=""></option></select></span>
|
||||
<span id="src_list_vid_pic_elm">
|
||||
{#snstuff_dlg.img_video_pic}<select id="src_list_vid_pic" name="src_list_vid_pic" onchange="ImageDialog.media1Action(this.value)"><option value=""></option></select>
|
||||
{#snstuff_dlg.img_width} <input id="video_width" name="video_width" type="text" size="4">
|
||||
{#snstuff_dlg.img_height} <input id="video_height" name="video_height" type="text" size="4">
|
||||
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" class="column1"><label id="alignlabel" for="align">{#snstuff_dlg.img_align}</label></td>
|
||||
<td>
|
||||
<select id="align" name="align" onchange="">
|
||||
<option value="none">{#snstuff_dlg.img_align_none}</option>
|
||||
<option value="left">{#snstuff_dlg.img_align_left}</option>
|
||||
<option value="right">{#snstuff_dlg.img_align_right}</option>
|
||||
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<input id="imgDelBtn" type="button" value="{#snstuff_dlg.img_imagedelete}" onclick="ImageDialog.doDeleteImg()" disabled>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
</fieldset>
|
||||
<br>
|
||||
<fieldset>
|
||||
<legend>{#snstuff_dlg.img_preview}</legend>
|
||||
<div id="prev"></div>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="mceActionPanel">
|
||||
<div style="float: left">
|
||||
<input type="button" id="insert" name="insert" value="{#insert}" onclick="ImageDialog.insert();" />
|
||||
</div>
|
||||
|
||||
<div style="float: right">
|
||||
<input type="button" id="cancel" name="cancel" value="{#cancel}" onclick="tinyMCEPopup.close();" />
|
||||
</div>
|
||||
</div>
|
||||
<!-- </form> -->
|
||||
<iframe name="upload_target" style="position:absolute;top:-999; left-999;border: 0;width: 0px;height: 0px;" onload=""></iframe>
|
||||
</body>
|
||||
</html>
|
108
sn_templates/editor_stuff/plugin/snstuff/html/image_bk.html
Normal file
@@ -0,0 +1,108 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>{#snstuff_dlg.img_dialog_title}</title>
|
||||
<script type="text/javascript" src="../../../tiny_mce_popup.js"></script>
|
||||
<!-- <script type="text/javascript" src="../../../utils/mctabs.js"></script> -->
|
||||
<script type="text/javascript" src="../../../utils/form_utils.js"></script>
|
||||
<script type="text/javascript" src="../../../utils/validate.js"></script>
|
||||
<script type="text/javascript" src="../../../utils/editable_selects.js"></script>
|
||||
|
||||
<script type="text/javascript" src="../js/config.js"></script>
|
||||
<script type="text/javascript" src="../js/image.js"></script>
|
||||
|
||||
<link href="../css/default.css" rel="stylesheet" type="text/css" />
|
||||
</head>
|
||||
<body id="snimages" style="display: none">
|
||||
|
||||
<div class="panel_wrapper">
|
||||
|
||||
<iframe id="actionTarget" name="actionTarget" style="width:1px; height:1px; visibility:hidden" onload="ImageDialog.actionStop()"></iframe>
|
||||
<div id="general_panel" class="panel current">
|
||||
|
||||
<form id="uploadForm" name="uploadForm" enctype="multipart/form-data" action="" method="post" target="actionTarget" onsubmit="ImageDialog.uploadStart()">
|
||||
<fieldset>
|
||||
<legend>{#snstuff_dlg.img_tab_upload}</legend>
|
||||
|
||||
<img id="waitImg" src="../images/wait.gif" style="float:right; visibility:hidden">
|
||||
|
||||
<table border="0" cellpadding="4" cellspacing="0">
|
||||
<tr>
|
||||
<td><lable for="input_filed">{#snstuff_dlg.img_imagefile_select}</lable>
|
||||
<input id="fileField" name="sn_filename" type="file">
|
||||
</td>
|
||||
<td>
|
||||
<input id="uploadSubmit" type="submit" value="{#snstuff_dlg.img_imagefile_sndbtn}">
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
</fieldset>
|
||||
</form>
|
||||
<br>
|
||||
<fieldset>
|
||||
<legend>{#snstuff_dlg.img_general}</legend>
|
||||
|
||||
<table class="properties">
|
||||
<!-- <tr rowspan="2">
|
||||
<td class="column1"><label id="srclabel" for="src">{#snstuff_dlg.src}</label></td>
|
||||
<td>
|
||||
<table border="0" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td><input name="src" disabled type="text" id="src" value="" class="mceFocus" onchange="ImageDialog.showPreviewImage(this.value);" /></td>
|
||||
<td id="srcbrowsercontainer"> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>-->
|
||||
<tr>
|
||||
<td colspan="2"><label for="src_list">{#snstuff_dlg.img_image_list}</label></td>
|
||||
<td colspan="2"><select id="src_list" name="src_list" onchange="ImageDialog.showImageSizeList(this);"><option value=""></option></select></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><label for="src_list_size">Size{#snstuff_dlg.img_image_list}</label></td>
|
||||
<td colspan="2">
|
||||
<select id="src_list_size" name="src_list_size" onchange="ImageDialog.showSelectedImage(this)"><option value=""></option></select>
|
||||
<select id="src_list_size_full" name="src_list_size_full" onchange=""><option value=""></option></select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" class="column1"><label id="alignlabel" for="align">{#snstuff_dlg.img_align}</label></td>
|
||||
<td>
|
||||
<select id="align" name="align" onchange="ImageDialog.updateStyle('align');ImageDialog.changeAppearance();">
|
||||
<option value="">{#snstuff_dlg.img_align_none}</option>
|
||||
<option value="left">{#snstuff_dlg.img_align_left}</option>
|
||||
<option value="right">{#snstuff_dlg.img_align_right}</option>
|
||||
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<input id="imgDelBtn" type="button" value="{#snstuff_dlg.img_imagedelete}" onclick="ImageDialog.doDeleteImg()" disabled>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
</fieldset>
|
||||
<br>
|
||||
<fieldset>
|
||||
<legend>{#snstuff_dlg.img_preview}</legend>
|
||||
<div id="prev"></div>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="mceActionPanel">
|
||||
<div style="float: left">
|
||||
<input type="button" id="insert" name="insert" value="{#insert}" onclick="ImageDialog.insert();" />
|
||||
</div>
|
||||
|
||||
<div style="float: right">
|
||||
<input type="button" id="cancel" name="cancel" value="{#cancel}" onclick="tinyMCEPopup.close();" />
|
||||
</div>
|
||||
</div>
|
||||
<!-- </form> -->
|
||||
<iframe name="upload_target" style="position:absolute;top:-999; left-999;border: 0;width: 0px;height: 0px;" onload=""></iframe>
|
||||
</body>
|
||||
</html>
|
41
sn_templates/editor_stuff/plugin/snstuff/html/infobox.html
Normal file
@@ -0,0 +1,41 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>{#snstuff_dlg.ibox_title}</title>
|
||||
<script type="text/javascript" src="../../../tiny_mce_popup.js"></script>
|
||||
<!-- <script type="text/javascript" src="../../../utils/mctabs.js"></script> -->
|
||||
<script type="text/javascript" src="../../../utils/form_utils.js"></script>
|
||||
<script type="text/javascript" src="../../../utils/validate.js"></script>
|
||||
<script type="text/javascript" src="../js/infobox.js"></script>
|
||||
<!-- <link href="css/snlink.css" rel="stylesheet" type="text/css" /> -->
|
||||
</head>
|
||||
<body style="display: none">
|
||||
<form onsubmit="insertAction();return false;" action="#">
|
||||
<div class="panel">
|
||||
<fieldset>
|
||||
<legend>{#snstuff_dlg.ibox_general_props}</legend>
|
||||
|
||||
<table border="0" cellpadding="4" cellspacing="0">
|
||||
<tr><td>{#snstuff_dlg.ibox_input_size}<input type="text" name="size" size="5" value="100">px</td>
|
||||
<td>{#snstuff_dlg.ibox_input_float}
|
||||
<select name="float">
|
||||
<option value="left">{#snstuff_dlg.ibox_fopt_left}</option>
|
||||
<option value="right">{#snstuff_dlg.ibox_fopt_right}</option>
|
||||
</select>
|
||||
</td></tr>
|
||||
|
||||
</table>
|
||||
</fieldset>
|
||||
</div>
|
||||
<div class="mceActionPanel">
|
||||
<div style="float: left">
|
||||
<input type="submit" id="insert" name="insert" value="{#insert}" />
|
||||
</div>
|
||||
|
||||
<div style="float: right">
|
||||
<input type="button" id="cancel" name="cancel" value="{#cancel}" onclick="tinyMCEPopup.close();" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
36
sn_templates/editor_stuff/plugin/snstuff/html/link.html
Normal file
@@ -0,0 +1,36 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>{#snstuff_dlg.lnk_title}</title>
|
||||
<script type="text/javascript" src="../../../tiny_mce_popup.js"></script>
|
||||
<!-- <script type="text/javascript" src="../../../utils/mctabs.js"></script> -->
|
||||
<script type="text/javascript" src="../../../utils/form_utils.js"></script>
|
||||
<script type="text/javascript" src="../../../utils/validate.js"></script>
|
||||
<script type="text/javascript" src="../js/snlink.js"></script>
|
||||
<!-- <link href="css/snlink.css" rel="stylesheet" type="text/css" /> -->
|
||||
</head>
|
||||
<body id="advlink" style="display: none">
|
||||
<form onsubmit="insertAction();return false;" action="#">
|
||||
<div class="panel">
|
||||
<fieldset>
|
||||
<legend>{#snstuff_dlg.lnk_general_props}</legend>
|
||||
|
||||
<table border="0" cellpadding="4" cellspacing="0">
|
||||
<tr style="float: right"><td>{#snstuff_dlg.lnk_field_url}</td><td><input id="urlField" type="text" size="45"></td></tr>
|
||||
<tr id="urlName" style="float: right"><td>{#snstuff_dlg.lnk_field_name}</td><td><input id="nameField" type="text" size="45"></td></tr>
|
||||
<tr id="urlDescription" style="float: right"><td>{#snstuff_dlg.lnk_field_desc}</td><td><input id="descField" type="text" size="45"></td></tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
</div>
|
||||
<div class="mceActionPanel">
|
||||
<div style="float: left">
|
||||
<input type="submit" id="insert" name="insert" value="{#insert}" />
|
||||
</div>
|
||||
|
||||
<div style="float: right">
|
||||
<input type="button" id="cancel" name="cancel" value="{#cancel}" onclick="tinyMCEPopup.close();" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
32
sn_templates/editor_stuff/plugin/snstuff/html/quote.html
Normal file
@@ -0,0 +1,32 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>{#snstuff_dlg.quote_title}</title>
|
||||
<script type="text/javascript" src="../../../tiny_mce_popup.js"></script>
|
||||
<!-- <script type="text/javascript" src="../../../utils/mctabs.js"></script> -->
|
||||
<script type="text/javascript" src="../../../utils/form_utils.js"></script>
|
||||
<script type="text/javascript" src="../../../utils/validate.js"></script>
|
||||
<script type="text/javascript" src="../js/snquote.js"></script>
|
||||
<!-- <link href="css/snlink.css" rel="stylesheet" type="text/css" /> -->
|
||||
</head>
|
||||
<body id="advlink" style="display: none">
|
||||
<form onsubmit="insertAction();return false;" action="#">
|
||||
<div class="panel">
|
||||
<fieldset>
|
||||
<legend>{#snstuff_dlg.qoute_general_props}</legend>
|
||||
|
||||
<textarea id="text" rows="30" cols="60"></textarea>
|
||||
</fieldset>
|
||||
</div>
|
||||
<div class="mceActionPanel">
|
||||
<div style="float: left">
|
||||
<input type="submit" id="insert" name="insert" value="{#insert}" />
|
||||
</div>
|
||||
|
||||
<div style="float: right">
|
||||
<input type="button" id="cancel" name="cancel" value="{#cancel}" onclick="tinyMCEPopup.close();" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
BIN
sn_templates/editor_stuff/plugin/snstuff/images/add.png
Normal file
After Width: | Height: | Size: 907 B |
BIN
sn_templates/editor_stuff/plugin/snstuff/images/close.png
Normal file
After Width: | Height: | Size: 842 B |
BIN
sn_templates/editor_stuff/plugin/snstuff/images/code-context.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
sn_templates/editor_stuff/plugin/snstuff/images/insert-image.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
BIN
sn_templates/editor_stuff/plugin/snstuff/images/insert-link.png
Normal file
After Width: | Height: | Size: 5.3 KiB |
BIN
sn_templates/editor_stuff/plugin/snstuff/images/player.png
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
sn_templates/editor_stuff/plugin/snstuff/images/proposals.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
sn_templates/editor_stuff/plugin/snstuff/images/quote.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
sn_templates/editor_stuff/plugin/snstuff/images/textinfo.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.2 KiB |
BIN
sn_templates/editor_stuff/plugin/snstuff/images/trans.gif
Normal file
After Width: | Height: | Size: 43 B |
BIN
sn_templates/editor_stuff/plugin/snstuff/images/video.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
sn_templates/editor_stuff/plugin/snstuff/images/wait.gif
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
sn_templates/editor_stuff/plugin/snstuff/images/window-new.png
Normal file
After Width: | Height: | Size: 680 B |
69
sn_templates/editor_stuff/plugin/snstuff/js/code.js
Normal file
@@ -0,0 +1,69 @@
|
||||
/* Functions for the advlink plugin popup */
|
||||
|
||||
tinyMCEPopup.requireLangPack();
|
||||
|
||||
function preinit() {
|
||||
var url;
|
||||
|
||||
if (url = tinyMCEPopup.getParam("external_link_list_url"))
|
||||
document.write('<script language="javascript" type="text/javascript" src="' + tinyMCEPopup.editor.documentBaseURI.toAbsolute(url) + '"></script>');
|
||||
}
|
||||
|
||||
function init() {
|
||||
|
||||
var formObj = document.forms[0];
|
||||
var ed = tinyMCEPopup.editor;
|
||||
var node = ed.selection.getNode();
|
||||
|
||||
node = ed.dom.getParent(node, "A");
|
||||
|
||||
if(node != null && typeof node != 'undefined' && node.nodeName == 'A'){
|
||||
formObj.insert.value = tinyMCEPopup.getLang('update', 'Insert', true);
|
||||
|
||||
var url = ed.dom.getAttrib(node,"href");
|
||||
var txt = node.firstChild.nodeValue;
|
||||
|
||||
formObj.urlField.value = url;
|
||||
formObj.descField.value = txt;
|
||||
}else{
|
||||
var selTxt = ed.selection.getContent();
|
||||
|
||||
if(isURL(selTxt)){
|
||||
formObj.urlField.value = selTxt.replace(/^\s*/,"");
|
||||
}
|
||||
if(selTxt.length > 0){
|
||||
document.getElementById("urlDescription").style.visibility = "hidden";
|
||||
}
|
||||
formObj.descField.value = selTxt;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
function insertAction() {
|
||||
var formObj = document.forms[0];
|
||||
var ed = tinyMCEPopup.editor;
|
||||
var node = ed.selection.getNode()
|
||||
|
||||
if (node && node.nodeName == 'A') {
|
||||
ed.dom.setAttrib(node, "href", document.getElementById("urlField").value);
|
||||
node.firstChild.nodeValue = document.getElementById("descField").value;
|
||||
}else {
|
||||
ed.execCommand('mceInsertContent', false, '<a href="'+formObj.urlField.value+'">'+formObj.descField.value+'</a>', {skip_undo : 1});
|
||||
ed.undoManager.add();
|
||||
}
|
||||
|
||||
tinyMCEPopup.close();
|
||||
}
|
||||
|
||||
function isURL(str){
|
||||
if(str.match(/^http(s){0,1}:\/\//) || str.match(/^\s*www.*\..+/)){
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// While loading
|
||||
preinit();
|
||||
tinyMCEPopup.onInit.add(init);
|
52
sn_templates/editor_stuff/plugin/snstuff/js/config.js
Normal file
@@ -0,0 +1,52 @@
|
||||
var Config = {
|
||||
|
||||
imageListUrl : "" ,
|
||||
uploadUrl : "" ,
|
||||
deleteUrl : "" ,
|
||||
imageUrl : "",
|
||||
artikelid : null ,
|
||||
pagetype : null,
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
getImageListUrl : function(){
|
||||
|
||||
var url = Config._replace( Config.imageListUrl );
|
||||
|
||||
return tinyMCEPopup.editor.documentBaseURI.toAbsolute(url);
|
||||
},
|
||||
|
||||
getUploadUrl : function(){
|
||||
|
||||
var url = Config._replace( Config.uploadUrl );
|
||||
|
||||
return tinyMCEPopup.editor.documentBaseURI.toAbsolute(url);
|
||||
},
|
||||
|
||||
getDeleteUrl : function(imgname){
|
||||
|
||||
var url = Config._replace( Config.deleteUrl );
|
||||
|
||||
url = url.replace(/\{imgname\}/g,imgname);
|
||||
return tinyMCEPopup.editor.documentBaseURI.toAbsolute(url);
|
||||
},
|
||||
|
||||
getImageUrl : function(imgname,nofull){
|
||||
|
||||
var url = Config._replace( Config.imageUrl );
|
||||
|
||||
url = url.replace(/\{imgname\}/g,imgname);
|
||||
return (nofull)?url:tinyMCEPopup.editor.documentBaseURI.toAbsolute(url);
|
||||
},
|
||||
|
||||
_replace : function(url){
|
||||
|
||||
if(Config.artikelid != null && typeof Config.artikelid != 'undefined'){
|
||||
url = url.replace(/\{artikelid\}/g,Config.artikelid);
|
||||
}
|
||||
if(Config.pagetype != null && typeof Config.pagetype != 'undefined'){
|
||||
url = url.replace(/\{pagetype\}/g,Config.pagetype);
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
}
|
445
sn_templates/editor_stuff/plugin/snstuff/js/image.js
Normal file
@@ -0,0 +1,445 @@
|
||||
var ImageDialog = {
|
||||
preInit : function() {
|
||||
var url;
|
||||
|
||||
tinyMCEPopup.requireLangPack();
|
||||
|
||||
Config.artikelid = parent.entryid;
|
||||
Config.pagetype = parent.pagetype;
|
||||
//Config.imageListUrl = tinyMCEPopup.getParam("snstuff_img_url_list") || "/admin_list_pictures_json/{artikelid}";
|
||||
Config.imageListUrl = tinyMCEPopup.getParam("snstuff_img_url_list") || "{pagetype}?sx_action=on_image_list&id={artikelid}";
|
||||
//Config.uploadUrl = tinyMCEPopup.getParam("snstuff_img_url_upload") || "/{pagetype}/{artikelid}?sx_action=on_user_upload";
|
||||
Config.uploadUrl = tinyMCEPopup.getParam("snstuff_img_url_upload") || "{pagetype}?sx_action=on_image_upload&id={artikelid}";
|
||||
Config.deleteUrl = tinyMCEPopup.getParam("snstuff_img_url_delete") || "/admin_kill_picture?name=articleimage/sn_computer/{artikelid}/{imgname}&id={artikelid}";
|
||||
Config.imageUrl = tinyMCEPopup.getParam("snstuff_img_url_image") || "/on_image_preview/{artikelid}/{imgname}";
|
||||
|
||||
},
|
||||
|
||||
srcData:{},
|
||||
|
||||
selectedData:'',
|
||||
|
||||
srcMedia:'',
|
||||
media1:'',
|
||||
media2:'',
|
||||
|
||||
selM1:'',
|
||||
selM2:'',
|
||||
|
||||
videoW:undefined,
|
||||
videoH:undefined,
|
||||
|
||||
selBigges: true,
|
||||
isUploading: false,
|
||||
isDeleting: false,
|
||||
|
||||
init : function(ed) {
|
||||
|
||||
tinyMCEPopup.dom.get("uploadForm").action = Config.getUploadUrl();
|
||||
tinyMCEPopup.dom.get("src_list_vid_pic_elm").style.display = 'none';
|
||||
tinyMCEPopup.dom.get("l_src_list_size").style.display = 'none';
|
||||
tinyMCEPopup.dom.get("l_src_list_vpic").style.display = 'none';
|
||||
|
||||
var ed = tinyMCEPopup.editor, dom = ed.dom, n = ed.selection.getNode();
|
||||
|
||||
tinyMCEPopup.resizeToInnerSize();
|
||||
|
||||
TinyMCE_EditableSelects.init();
|
||||
|
||||
if ( n != null && typeof n != 'undefined' && n.nodeName == 'IMG') {
|
||||
this.selBigges = false;
|
||||
document.getElementById("insert").value = ed.getLang('update');
|
||||
var imgURL = dom.getAttrib(n, 'src');
|
||||
if(n.className == 'snVideo'){
|
||||
this.selM2 = dom.getAttrib(n, 'alt');
|
||||
this.videoW = dom.getAttrib(n, 'width');
|
||||
this.videoH = dom.getAttrib(n, 'height');
|
||||
this.selM1 = dom.getAttrib(n, 'title');
|
||||
}else{
|
||||
|
||||
this.selM2 = dom.getAttrib(n, 'alt')
|
||||
this.selM1 = imgURL.split('/').pop();
|
||||
|
||||
var a = 'none';
|
||||
if (ed.settings.inline_styles) {
|
||||
if (!(a = dom.getStyle(n, 'float'))){
|
||||
a = dom.getStyle(n, 'vertical-align')
|
||||
}
|
||||
}
|
||||
if(!a){
|
||||
a = dom.getAttrib(n, 'align');
|
||||
}
|
||||
var al = tinyMCEPopup.dom.get("align");
|
||||
a = a.replace(/ /g,'');
|
||||
for(var i = 0; i < al.length; i++){
|
||||
if(al.options[i].value == a)
|
||||
al.selectedIndex = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tinyMCEPopup.dom.get("video_width").value = this.videoW;
|
||||
tinyMCEPopup.dom.get("video_height").value = this.videoH;
|
||||
this.loadData();
|
||||
},
|
||||
|
||||
srcListAction: function(v){
|
||||
this.srcMedia = v;
|
||||
tinyMCEPopup.dom.get("src_list_size_elm").style.display = 'none';
|
||||
tinyMCEPopup.dom.get("src_list_size_full_elm").style.display = 'none';
|
||||
tinyMCEPopup.dom.get("src_list_vid_pic_elm").style.display = 'none';
|
||||
tinyMCEPopup.dom.get("l_src_list_size").style.display = 'none';
|
||||
tinyMCEPopup.dom.get("l_src_list_vpic").style.display = 'none';
|
||||
tinyMCEPopup.dom.get("align").disabled = true;
|
||||
|
||||
if(this.srcMedia.indexOf(':') == -1){
|
||||
this.previewData();
|
||||
return;
|
||||
}
|
||||
var on = this.srcMedia.split(':');
|
||||
|
||||
var lst = tinyMCEPopup.dom.get("src_list_size");
|
||||
var lst2 = tinyMCEPopup.dom.get("src_list_size_full");
|
||||
var lstv = tinyMCEPopup.dom.get("src_list_vid_pic");
|
||||
|
||||
lst.options.length = 0;lst2.options.length = 0; lstv.options.length = 0;
|
||||
|
||||
|
||||
|
||||
if(on[0] == 'pic'){
|
||||
tinyMCEPopup.dom.get("src_list_size_elm").style.display = 'inline';
|
||||
tinyMCEPopup.dom.get("src_list_size_full_elm").style.display = 'inline';
|
||||
tinyMCEPopup.dom.get("l_src_list_size").style.display = 'inline';
|
||||
|
||||
tinyMCEPopup.dom.get("align").disabled = false;
|
||||
var obj = this.srcData.pic[on[1]];
|
||||
var m = undefined, m2 = undefined;
|
||||
for(var i = 0; i < obj.subpic.length; i++){
|
||||
obj.subpic[i].width = parseInt(obj.subpic[i].width);
|
||||
obj.subpic[i].height = parseInt(obj.subpic[i].height);
|
||||
|
||||
|
||||
var fname = obj.subpic[i].name;
|
||||
var wh = obj.subpic[i].width + ' X '+ obj.subpic[i].height;
|
||||
if( obj.subpic[i].isOrig ){
|
||||
wh += '*';
|
||||
}
|
||||
|
||||
lst.options[lst.options.length] = new Option(wh, v+':'+i);
|
||||
lst2.options[lst2.options.length] = new Option(wh, v+':'+i);
|
||||
if(fname == this.selM1){lst.selectedIndex = lst.options.length-1;}
|
||||
if(fname == this.selM2){lst2.selectedIndex = lst2.options.length-1;}
|
||||
|
||||
if(this.selBigges){
|
||||
if(!m || m && (obj.subpic[i].width < m.width && obj.subpic[i].height < m.height)){
|
||||
lst.selectedIndex = lst.options.length-1;
|
||||
m = obj.subpic[i];
|
||||
}
|
||||
if(!m2 || m2 && (obj.subpic[i].width > m2.width && obj.subpic[i].height > m2.height)){
|
||||
lst2.selectedIndex = lst2.options.length-1;
|
||||
m2 = obj.subpic[i];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
this.selBigges = true;
|
||||
|
||||
lst.onchange();lst2.onchange();
|
||||
}
|
||||
if(on[0] == 'vid'){
|
||||
var obj = this.srcData.video[on[1]];
|
||||
tinyMCEPopup.dom.get("src_list_vid_pic_elm").style.display = 'inline';
|
||||
tinyMCEPopup.dom.get("video_width").value = this.videoW ? this.videoW:obj.width;
|
||||
tinyMCEPopup.dom.get("video_height").value = this.videoH ? this.videoH:obj.height;
|
||||
tinyMCEPopup.dom.get("l_src_list_vpic").style.display = 'inline';
|
||||
|
||||
for(var e in this.srcData.pic){
|
||||
var pl = this.srcData.pic[e].subpic;
|
||||
lstv.options[lstv.options.length] = new Option('','');
|
||||
for(var i = 0; i < pl.length; i++){
|
||||
lstv.options[lstv.options.length] = new Option(pl[i].name,'pic:'+e+':'+i);
|
||||
if(pl[i].name == this.selM2){lstv.selectedIndex = lstv.options.length-1;}
|
||||
}
|
||||
}
|
||||
lstv.onchange();
|
||||
}
|
||||
},
|
||||
|
||||
media1Action: function(v){
|
||||
this.media1 = v;
|
||||
this.previewData();
|
||||
},
|
||||
|
||||
media2Action: function(v){
|
||||
this.media2 = v;
|
||||
},
|
||||
|
||||
|
||||
previewData : function() {
|
||||
if (!this.srcMedia) {
|
||||
tinyMCEPopup.dom.setHTML('prev', '');
|
||||
document.getElementById("imgDelBtn").disabled = true;
|
||||
return;
|
||||
}
|
||||
var on;
|
||||
if(this.srcMedia.indexOf("vid:") != -1){
|
||||
on = this.srcMedia.split(':');
|
||||
}else{
|
||||
on = this.media1.split(':');
|
||||
}
|
||||
|
||||
var u; var html = '';
|
||||
if(on[0] == 'pic'){
|
||||
var p = this.srcData.pic[on[1]].subpic[on[2]];
|
||||
u = tinyMCEPopup.editor.documentBaseURI.toAbsolute(Config.getImageUrl(p.name,true));
|
||||
html = '<img id="previewImg" src="' + u + '" border="0" />';
|
||||
|
||||
}else{
|
||||
var o = this.srcData.video[on[1]];
|
||||
var fvars = "file="+Config.getImageUrl(o.name,true);
|
||||
if(this.media1 && this.media1.indexOf(':') != -1){
|
||||
var m2 = this.media1.split(':');
|
||||
fvars += "&image="+Config.getImageUrl(this.srcData.pic[m2[1]].subpic[m2[2]].name,true);
|
||||
}
|
||||
fvars +="&autoload=false";
|
||||
html = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' width='350' height='280' id='"+o.name+"' name='"+o.name+"'>"
|
||||
+"<param name='movie' value='/video/player-viral.swf'><param name='allowfullscreen' value='false'><param name='play' value='false'>"
|
||||
+"<param name='flashvars' value='"+fvars+"'>"
|
||||
+"<embed type='application/x-shockwave-flash' id='"+o.name+"' name='"+o.name+"' src='/video/player-viral.swf' width='400' height='250' "
|
||||
+"allowscriptaccess='always' allowfullscreen='false' flashvars='"+fvars+"'/>"
|
||||
+"</object>";
|
||||
}
|
||||
document.getElementById("imgDelBtn").disabled = false
|
||||
tinyMCEPopup.dom.setHTML('prev', html);
|
||||
},
|
||||
|
||||
|
||||
insert:function(){
|
||||
var ed = tinyMCEPopup.editor, t = this
|
||||
if (!this.srcMedia) {
|
||||
if (ed.selection.getNode().nodeName == 'IMG') {
|
||||
ed.dom.remove(ed.selection.getNode());
|
||||
ed.execCommand('mceRepaint');
|
||||
}
|
||||
|
||||
tinyMCEPopup.close();
|
||||
return;
|
||||
}
|
||||
////// insert/update
|
||||
|
||||
tinyMCEPopup.restoreSelection();
|
||||
|
||||
// Fixes crash in Safari
|
||||
if (tinymce.isWebKit){ ed.getWin().focus();}
|
||||
|
||||
|
||||
|
||||
var args;
|
||||
var clazzName = 'noresize';
|
||||
if(this.srcMedia && this.srcMedia.indexOf('pic:') != -1){
|
||||
var m1 = this.media1.split(':');
|
||||
var m2 = this.media2.split(':');
|
||||
|
||||
args = {'class':'noresize',
|
||||
'align': tinyMCEPopup.dom.get("align").value,
|
||||
'src': Config.getImageUrl(this.srcData.pic[m1[1]].subpic[m1[2]].name,true),
|
||||
'alt': this.srcData.pic[m2[1]].subpic[m2[2]].name,
|
||||
'style': "float:"+tinyMCEPopup.dom.get("align").value+";"
|
||||
};
|
||||
}
|
||||
|
||||
if(this.srcMedia && this.srcMedia.indexOf('vid:') != -1){
|
||||
var sm = this.srcMedia.split(':');
|
||||
var o = this.srcData.video[sm[1]];
|
||||
this.videoW = parseInt(tinyMCEPopup.dom.get("video_width").value);
|
||||
this.videoH = parseInt(tinyMCEPopup.dom.get("video_height").value);
|
||||
|
||||
if(!this.videoH || this.videoH < 0){
|
||||
this.videoH = o.height;
|
||||
}
|
||||
if(!this.videoW || this.videoW < 0){
|
||||
this.videoW = o.width;
|
||||
}
|
||||
|
||||
|
||||
clazzName = 'snVideo';
|
||||
args = {'class':'snVideo',
|
||||
'align': tinyMCEPopup.dom.get("align").value,
|
||||
'src': tinyMCEPopup.getWindowArg("plugin_url")+'/images/trans.gif',
|
||||
'title': o.name,
|
||||
'width':this.videoW,
|
||||
'height':this.videoH
|
||||
}
|
||||
if(this.media1 && this.media1.indexOf(':') != -1){
|
||||
var m1 = this.media1.split(':');
|
||||
args.alt = this.srcData.pic[m1[1]].subpic[m1[2]].name;
|
||||
}
|
||||
}
|
||||
|
||||
el = ed.selection.getNode();
|
||||
tinyMCEPopup.execCommand("mceBeginUndoLevel");
|
||||
if (el && el.nodeName == 'IMG') {
|
||||
ed.dom.remove(ed.selection.getNode());
|
||||
}
|
||||
if(args){
|
||||
ed.execCommand('mceInsertContent', false, '<img id="__mce_tmp" />', {skip_undo : 1});
|
||||
// ed.dom.get('__mce_tmp').className = clazzName;
|
||||
ed.dom.setAttribs('__mce_tmp', args);
|
||||
ed.dom.setAttrib('__mce_tmp', 'id', '');
|
||||
}
|
||||
ed.undoManager.add();
|
||||
tinyMCEPopup.execCommand("mceEndUndoLevel");
|
||||
tinyMCEPopup.close();
|
||||
},
|
||||
//////////////////////////////// Helper ////////////////////////////
|
||||
|
||||
loadData: function(){
|
||||
var lst = tinyMCEPopup.dom.get("src_list");
|
||||
lst.options.length = 0;
|
||||
lst.options[lst.options.length] = new Option('Lade Medienliste...','');
|
||||
lst.disabled = true;
|
||||
var xmlHttp = this.getXMLHttpRequest();
|
||||
if(xmlHttp){
|
||||
xmlHttp.open('GET', Config.getImageListUrl(), true);
|
||||
xmlHttp.onreadystatechange = function () {
|
||||
|
||||
if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
|
||||
ImageDialog.parseAndSet(xmlHttp.responseText);
|
||||
}
|
||||
};
|
||||
xmlHttp.send(null);
|
||||
}
|
||||
},
|
||||
|
||||
deleteData: function(url){
|
||||
var xmlHttp = this.getXMLHttpRequest();
|
||||
if(xmlHttp){
|
||||
xmlHttp.open('GET', url, true);
|
||||
xmlHttp.onreadystatechange = function () {
|
||||
|
||||
if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
|
||||
ImageDialog.actionStop();
|
||||
}
|
||||
};
|
||||
xmlHttp.send(null);
|
||||
}
|
||||
},
|
||||
|
||||
doDeleteImg : function(){
|
||||
var dl = "";
|
||||
if(this.srcMedia.indexOf("pic:") != -1){
|
||||
var m = this.media1.split(':');
|
||||
dl = Config.getDeleteUrl(this.srcData.pic[m[1]].subpic[m[2]].name);
|
||||
}else{
|
||||
var m = this.srcMedia.split(':');
|
||||
dl = Config.getDeleteUrl(this.srcData.video[m[1]].name);
|
||||
}
|
||||
document.getElementById("imgDelBtn").disabled = true;
|
||||
document.getElementById("waitImg").style.visibility = "visible";
|
||||
ImageDialog.isDeleting = true;
|
||||
ImageDialog.deleteData(dl);
|
||||
|
||||
},
|
||||
|
||||
getXMLHttpRequest: function(){
|
||||
var xmlHttp = null;
|
||||
// Mozilla, Opera, Safari sowie Internet Explorer (ab v7)
|
||||
if (typeof XMLHttpRequest != 'undefined') {
|
||||
xmlHttp = new XMLHttpRequest();
|
||||
}
|
||||
if (!xmlHttp) {
|
||||
// Internet Explorer 6 und älter
|
||||
try {
|
||||
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
|
||||
} catch(e) {
|
||||
try {
|
||||
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
|
||||
} catch(e) {
|
||||
xmlHttp = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return xmlHttp;
|
||||
},
|
||||
|
||||
parseAndSet: function(xml){
|
||||
var obj = eval( '('+xml+')');
|
||||
|
||||
this.srcData = obj;
|
||||
|
||||
// parse loaded JSON object & create new object
|
||||
|
||||
var lst = tinyMCEPopup.dom.get("src_list");
|
||||
lst.options.length = 0;
|
||||
lst.options[lst.options.length] = new Option('','');
|
||||
if(obj.pic){
|
||||
|
||||
lst.options[lst.options.length] = new Option('------ Bilder -----','');
|
||||
for(var e in obj.pic){
|
||||
if(obj.pic[e].name && obj.pic[e].name.length > 0){
|
||||
var p = obj.pic[e];
|
||||
obj.pic[e].subpic.push({name:p.name,width:p.width,height:p.height,isOrig:true});
|
||||
}
|
||||
lst.options[lst.options.length] = new Option(e,'pic:'+e);
|
||||
if(this.selM1 && this.selM1.toLowerCase().indexOf(e.toLowerCase()) != -1){lst.selectedIndex = lst.options.length-1;}
|
||||
}
|
||||
}
|
||||
|
||||
if(obj.video && obj.video.length > 0){
|
||||
lst.options[lst.options.length] = new Option('------ Videos -----','');
|
||||
for(var i = 0; i < obj.video.length; i++){
|
||||
lst.options[lst.options.length] = new Option(obj.video[i].name,'vid:'+i);
|
||||
if(this.selM1 == obj.video[i].name){lst.selectedIndex = lst.options.length-1;}
|
||||
}
|
||||
}
|
||||
tinyMCEPopup.dom.get("src_list").disabled = false;
|
||||
lst.onchange();
|
||||
},
|
||||
|
||||
uploadStart : function(){
|
||||
ImageDialog.isUploading = true;
|
||||
document.getElementById("waitImg").style.visibility = "visible";
|
||||
document.getElementById("uploadSubmit").disabled = true;
|
||||
},
|
||||
|
||||
actionStop : function(){
|
||||
|
||||
|
||||
if(ImageDialog.isUploading){
|
||||
|
||||
document.getElementById("waitImg").style.visibility = "hidden";
|
||||
document.getElementById("uploadSubmit").disabled = false;
|
||||
document.getElementById("fileField").disabled = false;
|
||||
document.getElementById("fileField").value = "";
|
||||
this.loadData();
|
||||
ImageDialog.isUploading = false;
|
||||
}
|
||||
|
||||
if(ImageDialog.isDeleting){
|
||||
document.getElementById("waitImg").style.visibility = "hidden";
|
||||
document.getElementById("imgDelBtn").disabled = false;
|
||||
|
||||
this.loadData();
|
||||
|
||||
ImageDialog.isDeleting = false;
|
||||
}
|
||||
|
||||
// var http_status=507;
|
||||
// var http_message='507 Insufficient Storage';
|
||||
// var error_message='Upload zu gross, bitte maximal 2 MB hochladen.';
|
||||
|
||||
var iFrame = document.getElementById('actionTarget').contentWindow;
|
||||
|
||||
if(typeof iFrame.error_message != 'undefined'){
|
||||
alert(iFrame.error_message);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
|
||||
ImageDialog.preInit();
|
||||
tinyMCEPopup.onInit.add(ImageDialog.init, ImageDialog);
|
638
sn_templates/editor_stuff/plugin/snstuff/js/image_bk.js
Normal file
@@ -0,0 +1,638 @@
|
||||
var ImageDialog = {
|
||||
preInit : function() {
|
||||
var url;
|
||||
|
||||
tinyMCEPopup.requireLangPack();
|
||||
|
||||
Config.artikelid = parent.entryid;
|
||||
Config.pagetype = parent.pagetpye;
|
||||
Config.imageListUrl = tinyMCEPopup.getParam("snstuff_img_url_list") || "/admin_list_pictures_json/{artikelid}";
|
||||
Config.uploadUrl = tinyMCEPopup.getParam("snstuff_img_url_upload") || "/{pagetype}/{artikelid}?sx_action=on_user_upload";
|
||||
Config.deleteUrl = tinyMCEPopup.getParam("snstuff_img_url_delete") || "/admin_kill_picture?name=articleimage/sn_computer/{artikelid}/{imgname}&id={artikelid}";
|
||||
Config.imageUrl = tinyMCEPopup.getParam("snstuff_img_url_image") || "/articleimage/{artikelid}/{imgname}";
|
||||
|
||||
},
|
||||
|
||||
imgURL: "",
|
||||
imgAlign:"",
|
||||
|
||||
init : function(ed) {
|
||||
ImageDialog.ImageList = new ImageData();
|
||||
|
||||
document.forms["uploadForm"].action = Config.getUploadUrl();
|
||||
|
||||
var ed = tinyMCEPopup.editor, dom = ed.dom, n = ed.selection.getNode();
|
||||
|
||||
tinyMCEPopup.resizeToInnerSize();
|
||||
|
||||
TinyMCE_EditableSelects.init();
|
||||
|
||||
if ( n != null && typeof n != 'undefined' && n.nodeName == 'IMG') {
|
||||
this.imgURL = dom.getAttrib(n, 'src');
|
||||
this.selectByValue(document.getElementById('align'), this.getAttrib(n, 'align'));
|
||||
document.getElementById("insert").value = ed.getLang('update');
|
||||
this.imgAlign = dom.getAttrib(n, 'style');
|
||||
|
||||
if (ed.settings.inline_styles) {
|
||||
// Move attribs to styles
|
||||
if (dom.getAttrib(n, 'align'))
|
||||
this.updateStyle('align');
|
||||
|
||||
if (dom.getAttrib(n, 'hspace'))
|
||||
this.updateStyle('hspace');
|
||||
|
||||
if (dom.getAttrib(n, 'border'))
|
||||
this.updateStyle('border');
|
||||
|
||||
if (dom.getAttrib(n, 'vspace'))
|
||||
this.updateStyle('vspace');
|
||||
}
|
||||
}
|
||||
|
||||
this.changeAppearance();
|
||||
this.showPreviewImage(this.imgURL, 1);
|
||||
this.loadImages();
|
||||
},
|
||||
|
||||
|
||||
selectOptions : function(){
|
||||
var n = tinyMCEPopup.editor.selection.getNode(), ed = tinyMCEPopup.editor, dom = ed.dom, n = ed.selection.getNode();
|
||||
|
||||
if(n.nodeName != 'IMG')
|
||||
return;
|
||||
|
||||
var srcLstSize = tinyMCEPopup.dom.get("src_list_size").options;
|
||||
var imgurl = this.imgURL;
|
||||
var imgname = imgurl.split("/").pop();
|
||||
|
||||
// select image in selectbox
|
||||
var oname = ImageDialog.ImageList.getOrigNameOf(imgname);
|
||||
var slist = tinyMCEPopup.dom.get("src_list_size");
|
||||
slist.options.length = 0;
|
||||
|
||||
ImageDialog.showImageSizeList({value:oname});
|
||||
|
||||
this.selectInList(tinyMCEPopup.dom.get("src_list"),oname);
|
||||
this.selectInList(tinyMCEPopup.dom.get("src_list_size"),imgurl);
|
||||
this.showSelectedImage(tinyMCEPopup.dom.get("src_list_size"));
|
||||
this.selectInList(tinyMCEPopup.dom.get("src_list_size_full"),dom.getAttrib(n, 'href'));
|
||||
},
|
||||
|
||||
showSelectedImage : function(obj){
|
||||
|
||||
this.imgURL = obj.options[obj.selectedIndex].value;
|
||||
this.showPreviewImage(this.imgURL);
|
||||
},
|
||||
|
||||
insert : function(file, title) {
|
||||
var ed = tinyMCEPopup.editor, t = this;
|
||||
|
||||
if (this.imgURL === '') {
|
||||
if (ed.selection.getNode().nodeName == 'IMG') {
|
||||
ed.dom.remove(ed.selection.getNode());
|
||||
ed.execCommand('mceRepaint');
|
||||
}
|
||||
|
||||
tinyMCEPopup.close();
|
||||
return;
|
||||
}
|
||||
|
||||
t.insertAndClose();
|
||||
|
||||
},
|
||||
|
||||
insertAndClose : function() {
|
||||
var ed = tinyMCEPopup.editor, v, args = {}, el;
|
||||
|
||||
tinyMCEPopup.restoreSelection();
|
||||
|
||||
// Fixes crash in Safari
|
||||
if (tinymce.isWebKit)
|
||||
ed.getWin().focus();
|
||||
|
||||
if (!ed.settings.inline_styles) {
|
||||
args = {
|
||||
vspace : document.getElementById("vspace").value,
|
||||
hspace : document.getElementById("hspace").value,
|
||||
border : document.getElementById("border").value,
|
||||
align : document.getElementById("align").value
|
||||
};
|
||||
} else {
|
||||
// Remove deprecated values
|
||||
args = {
|
||||
vspace : '',
|
||||
hspace : '',
|
||||
border : '',
|
||||
align : ''
|
||||
};
|
||||
}
|
||||
var lnk = document.getElementById("src_list_size_full").value;
|
||||
if(lnk == "auto."){
|
||||
lnk = ImageDialog.ImageList.getBiggest(document.getElementById("src_list").value)
|
||||
}
|
||||
tinymce.extend(args, {
|
||||
src : this.imgURL,
|
||||
alt : lnk,
|
||||
style : this.imgAlign,
|
||||
href : lnk
|
||||
});
|
||||
|
||||
el = ed.selection.getNode();
|
||||
|
||||
tinyMCEPopup.execCommand("mceBeginUndoLevel");
|
||||
// entfernen und neu einfuegen. Weil das das advimagescale plugin sonst unerwuenschten nebeneffekt erzeugt
|
||||
if (el && el.nodeName == 'IMG') {
|
||||
ed.dom.remove(ed.selection.getNode());
|
||||
// ed.dom.setAttribs(el, args);
|
||||
} //else {
|
||||
|
||||
ed.execCommand('mceInsertContent', false, '<img id="__mce_tmp" />', {skip_undo : 1});
|
||||
ed.dom.setAttribs('__mce_tmp', args);
|
||||
ed.dom.setAttrib('__mce_tmp', 'id', '');
|
||||
ed.undoManager.add();
|
||||
// }
|
||||
|
||||
// ed.execCommand('mceRepaint');
|
||||
tinyMCEPopup.execCommand("mceEndUndoLevel");
|
||||
tinyMCEPopup.close();
|
||||
},
|
||||
|
||||
getAttrib : function(e, at) {
|
||||
var ed = tinyMCEPopup.editor, dom = ed.dom, v, v2;
|
||||
|
||||
if (ed.settings.inline_styles) {
|
||||
switch (at) {
|
||||
case 'align':
|
||||
if (v = dom.getStyle(e, 'float'))
|
||||
return v;
|
||||
|
||||
if (v = dom.getStyle(e, 'vertical-align'))
|
||||
return v;
|
||||
|
||||
break;
|
||||
|
||||
case 'hspace':
|
||||
v = dom.getStyle(e, 'margin-left')
|
||||
v2 = dom.getStyle(e, 'margin-right');
|
||||
|
||||
if (v && v == v2)
|
||||
return parseInt(v.replace(/[^0-9]/g, ''));
|
||||
|
||||
break;
|
||||
|
||||
case 'vspace':
|
||||
v = dom.getStyle(e, 'margin-top')
|
||||
v2 = dom.getStyle(e, 'margin-bottom');
|
||||
if (v && v == v2)
|
||||
return parseInt(v.replace(/[^0-9]/g, ''));
|
||||
|
||||
break;
|
||||
|
||||
case 'border':
|
||||
v = 0;
|
||||
|
||||
tinymce.each(['top', 'right', 'bottom', 'left'], function(sv) {
|
||||
sv = dom.getStyle(e, 'border-' + sv + '-width');
|
||||
|
||||
// False or not the same as prev
|
||||
if (!sv || (sv != v && v !== 0)) {
|
||||
v = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (sv)
|
||||
v = sv;
|
||||
});
|
||||
|
||||
if (v)
|
||||
return parseInt(v.replace(/[^0-9]/g, ''));
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (v = dom.getAttrib(e, at))
|
||||
return v;
|
||||
|
||||
return '';
|
||||
},
|
||||
|
||||
|
||||
fillSelectList : function() {
|
||||
|
||||
var dom = tinyMCEPopup.dom, lst = dom.get("src_list");
|
||||
|
||||
lst.options.length = 0;
|
||||
|
||||
lst.options[lst.options.length] = new Option('', '');
|
||||
ImageDialog.ImageList.fillListWithNames(lst);
|
||||
|
||||
},
|
||||
|
||||
showImageSizeList : function(obj){
|
||||
var dom = tinyMCEPopup.dom;
|
||||
var lst = dom.get("src_list_size");
|
||||
var lst2 = dom.get("src_list_size_full");
|
||||
|
||||
if(obj.selectedIndex == 0){
|
||||
this.imgURL = "";
|
||||
lst.options.length = 0;
|
||||
lst2.options.length = 0;
|
||||
this.showPreviewImage();
|
||||
}else{
|
||||
|
||||
lst.options.length = 0;
|
||||
ImageDialog.ImageList.fillListWithSizeOf(lst,obj.value);
|
||||
|
||||
|
||||
lst2.options.length = 0;
|
||||
lst2.options[lst2.options.length] = new Option("auto.","auto.");
|
||||
ImageDialog.ImageList.fillListWithSizeOf(lst2,obj.value);
|
||||
|
||||
ImageDialog.showSelectedImage(document.getElementById("src_list_size"));
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
resetImageData : function() {
|
||||
// document.getElementById("width").value = document.getElementById("height").value = '';
|
||||
},
|
||||
|
||||
|
||||
updateImageData : function(img, st) {
|
||||
|
||||
this.preloadImg = img;
|
||||
},
|
||||
|
||||
changeAppearance : function() {
|
||||
var ed = tinyMCEPopup.editor, img = document.getElementById('alignSampleImg');
|
||||
|
||||
if (img) {
|
||||
if (ed.getParam('inline_styles')) {
|
||||
ed.dom.setAttrib(img, 'style', ImageDialog.imgAlign);
|
||||
} else {
|
||||
img.align = document.getElementById("align").value;
|
||||
img.border = document.getElementById("border").value;
|
||||
img.hspace = document.getElementById("hspace").value;
|
||||
img.vspace = document.getElementById("vspace").value;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
updateStyle : function(ty) {
|
||||
var dom = tinyMCEPopup.dom, st, v, img = dom.create('img', {style : ImageDialog.imgAlign});
|
||||
|
||||
if (tinyMCEPopup.editor.settings.inline_styles) {
|
||||
// Handle align
|
||||
if (ty == 'align') {
|
||||
dom.setStyle(img, 'float', '');
|
||||
dom.setStyle(img, 'vertical-align', '');
|
||||
|
||||
v = document.getElementById("align").value;
|
||||
if (v) {
|
||||
if (v == 'left' || v == 'right')
|
||||
dom.setStyle(img, 'float', v);
|
||||
else
|
||||
img.style.verticalAlign = v;
|
||||
}
|
||||
}
|
||||
|
||||
// Handle border
|
||||
if (ty == 'border') {
|
||||
dom.setStyle(img, 'border', '');
|
||||
|
||||
v = document.getElementById("border").value;
|
||||
if (v || v == '0') {
|
||||
if (v == '0')
|
||||
img.style.border = '0';
|
||||
else
|
||||
img.style.border = v + 'px solid black';
|
||||
}
|
||||
}
|
||||
|
||||
// Handle hspace
|
||||
if (ty == 'hspace') {
|
||||
dom.setStyle(img, 'marginLeft', '');
|
||||
dom.setStyle(img, 'marginRight', '');
|
||||
|
||||
v = document.getElementById("hspace").value;
|
||||
if (v) {
|
||||
img.style.marginLeft = v + 'px';
|
||||
img.style.marginRight = v + 'px';
|
||||
}
|
||||
}
|
||||
|
||||
// Handle vspace
|
||||
if (ty == 'vspace') {
|
||||
dom.setStyle(img, 'marginTop', '');
|
||||
dom.setStyle(img, 'marginBottom', '');
|
||||
|
||||
v = document.getElementById("vspace").value;
|
||||
if (v) {
|
||||
img.style.marginTop = v + 'px';
|
||||
img.style.marginBottom = v + 'px';
|
||||
}
|
||||
}
|
||||
|
||||
// Merge
|
||||
ImageDialog.imgAlign = dom.serializeStyle(dom.parseStyle(img.style.cssText));
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
showPreviewImage : function(u, st) {
|
||||
|
||||
if (!u) {
|
||||
tinyMCEPopup.dom.setHTML('prev', '');
|
||||
document.getElementById("imgDelBtn").disabled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!st && tinyMCEPopup.getParam("advimage_update_dimensions_onchange", true))
|
||||
this.resetImageData();
|
||||
|
||||
u = tinyMCEPopup.editor.documentBaseURI.toAbsolute(u);
|
||||
document.getElementById("imgDelBtn").disabled = false
|
||||
|
||||
if (!st)
|
||||
tinyMCEPopup.dom.setHTML('prev', '<img id="previewImg" src="' + u + '" border="0" onload="ImageDialog.updateImageData(this);" onerror="ImageDialog.resetImageData();" />');
|
||||
else
|
||||
tinyMCEPopup.dom.setHTML('prev', '<img id="previewImg" src="' + u + '" border="0" onload="ImageDialog.updateImageData(this, 1);" />');
|
||||
},
|
||||
|
||||
|
||||
selectInList : function(list, val){
|
||||
|
||||
var lst = list.options;
|
||||
var vimg = val.split("/").pop();
|
||||
|
||||
for(var i = 0; i < lst.length; i++){
|
||||
var oimg = lst[i].value.split("/").pop();
|
||||
|
||||
if(oimg == vimg){
|
||||
list.selectedIndex = i;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
//////////////////////////////// Helper ////////////////////////////
|
||||
|
||||
loadImages: function(){
|
||||
var xmlHttp = this.getXMLHttpRequest();
|
||||
if(xmlHttp){
|
||||
xmlHttp.open('GET', Config.getImageListUrl(), true);
|
||||
xmlHttp.onreadystatechange = function () {
|
||||
|
||||
if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
|
||||
ImageDialog.parseAndSet(xmlHttp.responseText);
|
||||
}
|
||||
};
|
||||
xmlHttp.send(null);
|
||||
}
|
||||
},
|
||||
|
||||
deleteImage: function(url){
|
||||
var xmlHttp = this.getXMLHttpRequest();
|
||||
if(xmlHttp){
|
||||
xmlHttp.open('GET', url, true);
|
||||
xmlHttp.onreadystatechange = function () {
|
||||
|
||||
if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
|
||||
ImageDialog.actionStop();
|
||||
}
|
||||
};
|
||||
xmlHttp.send(null);
|
||||
}
|
||||
},
|
||||
|
||||
getXMLHttpRequest: function(){
|
||||
var xmlHttp = null;
|
||||
// Mozilla, Opera, Safari sowie Internet Explorer (ab v7)
|
||||
if (typeof XMLHttpRequest != 'undefined') {
|
||||
xmlHttp = new XMLHttpRequest();
|
||||
}
|
||||
if (!xmlHttp) {
|
||||
// Internet Explorer 6 und älter
|
||||
try {
|
||||
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
|
||||
} catch(e) {
|
||||
try {
|
||||
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
|
||||
} catch(e) {
|
||||
xmlHttp = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return xmlHttp;
|
||||
},
|
||||
|
||||
ImageList: null,
|
||||
|
||||
parseAndSet: function(xml){
|
||||
var obj = eval('(' + xml + ')');
|
||||
|
||||
ImageDialog.ImageList.clear()
|
||||
|
||||
// parse loaded JSON object & create new object
|
||||
for(var i = 0; i < obj.length; i++){
|
||||
var size = obj[i].Size;
|
||||
var lnk = obj[i].Link;
|
||||
var imgnameFull = lnk.split("/").pop();
|
||||
|
||||
imgname = imgnameFull.replace("_"+size,"");
|
||||
|
||||
var lnk_test = lnk.split("/");
|
||||
|
||||
if(lnk_test.length == 1 &&lnk_test.shift() != "http:"){
|
||||
lnk = Config.getImageUrl(lnk);
|
||||
}
|
||||
|
||||
if(size == 0)
|
||||
size = "Orig.";
|
||||
|
||||
ImageDialog.ImageList.add(imgname, lnk, size, imgnameFull);
|
||||
}
|
||||
|
||||
|
||||
this.fillSelectList();
|
||||
this.selectOptions();
|
||||
},
|
||||
|
||||
selectByValue: function (obj, value, add_custom, ignore_case) {
|
||||
if (!obj)
|
||||
return;
|
||||
|
||||
var found = false;
|
||||
for (var i=0; i<obj.options.length; i++) {
|
||||
var option = obj.options[i];
|
||||
|
||||
if (option.value == value || (ignore_case && option.value.toLowerCase() == value.toLowerCase())) {
|
||||
option.selected = true;
|
||||
found = true;
|
||||
} else{
|
||||
option.selected = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found && add_custom && value != '') {
|
||||
var option = new Option(value, value);
|
||||
option.selected = true;
|
||||
obj.options[sel.options.length] = option;
|
||||
obj.selectedIndex = obj.options.length - 1;
|
||||
}
|
||||
|
||||
return found;
|
||||
},
|
||||
|
||||
doDeleteImg : function(){
|
||||
var img = document.getElementById("src_list_size").value.split("/").pop();
|
||||
|
||||
document.getElementById("imgDelBtn").disabled = true;
|
||||
document.getElementById("waitImg").style.visibility = "visible";
|
||||
ImageDialog.isDeleting = true;
|
||||
ImageDialog.deleteImage(Config.getDeleteUrl(img));
|
||||
|
||||
},
|
||||
|
||||
isUploading : false,
|
||||
isDeleting : false,
|
||||
|
||||
uploadStart : function(){
|
||||
ImageDialog.isUploading = true;
|
||||
document.getElementById("waitImg").style.visibility = "visible";
|
||||
document.getElementById("uploadSubmit").disabled = true;
|
||||
},
|
||||
|
||||
actionStop : function(){
|
||||
|
||||
|
||||
if(ImageDialog.isUploading){
|
||||
|
||||
document.getElementById("waitImg").style.visibility = "hidden";
|
||||
document.getElementById("uploadSubmit").disabled = false;
|
||||
document.getElementById("fileField").disabled = false;
|
||||
document.getElementById("fileField").value = "";
|
||||
this.loadImages();
|
||||
ImageDialog.isUploading = false;
|
||||
}
|
||||
|
||||
if(ImageDialog.isDeleting){
|
||||
document.getElementById("waitImg").style.visibility = "hidden";
|
||||
document.getElementById("imgDelBtn").disabled = false;
|
||||
|
||||
this.loadImages();
|
||||
|
||||
ImageDialog.isDeleting = false;
|
||||
}
|
||||
|
||||
// var http_status=507;
|
||||
// var http_message='507 Insufficient Storage';
|
||||
// var error_message='Upload zu gross, bitte maximal 2 MB hochladen.';
|
||||
|
||||
var iFrame = document.getElementById('actionTarget').contentWindow;
|
||||
|
||||
if(typeof iFrame.error_message != 'undefined'){
|
||||
alert(iFrame.error_message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
function ImageData(){
|
||||
this.list = new Array();
|
||||
}
|
||||
|
||||
ImageData.prototype.add = function(n,u,s ,fn){
|
||||
if(typeof this.list[n] == 'undefined'){
|
||||
this.list[n] = new Array();
|
||||
}
|
||||
|
||||
this.list[n][this.list[n].length] = {url:u, size:s, fullname:fn};
|
||||
|
||||
}
|
||||
ImageData.prototype.clear = function(){
|
||||
this.list = new Array();
|
||||
}
|
||||
ImageData.prototype.getBiggest = function(n){
|
||||
|
||||
if(typeof this.list[n] == 'undefined')
|
||||
return;
|
||||
|
||||
var lst = this.list[n];
|
||||
var b = "";
|
||||
var s = -1;
|
||||
for(var i = 0; i < lst.length; i++){
|
||||
|
||||
if(lst[i].size == "Orig."){
|
||||
return lst[i].url;
|
||||
}
|
||||
|
||||
if( parseInt(lst[i].size) > parseInt(s) ){
|
||||
s = lst[i].size;
|
||||
b = lst[i].url;
|
||||
}
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
ImageData.prototype.getUrlOf = function(img){
|
||||
for(n in this.list){
|
||||
var lst = this.list[n];
|
||||
for(var i = 0; i < lst.length; i++){
|
||||
if(lst[i].fn == img){
|
||||
return lst[i].url;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ImageData.prototype.getOrigNameOf = function(img){
|
||||
|
||||
for(n in this.list){
|
||||
var lst = this.list[n];
|
||||
for(var i = 0; i < lst.length; i++){
|
||||
|
||||
if(lst[i].fullname == img){
|
||||
return n;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ImageData.prototype.fillListWithNames = function(list){
|
||||
for(n in this.list){
|
||||
list.options[list.options.length] = new Option(n, n);
|
||||
}
|
||||
}
|
||||
|
||||
ImageData.prototype.fillListWithSizeOf = function(list, img){
|
||||
|
||||
var lst = this.list[img];
|
||||
for(var i = 0; i < lst.length; i++){
|
||||
list.options[list.options.length] = new Option(lst[i].size, lst[i].url);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
ImageData.prototype.fillList = function(l){
|
||||
|
||||
for(n in this.list){
|
||||
var lst = this.list[n];
|
||||
// if(list.options.length > 0){
|
||||
l.options[l.options.length] = new Option("","");
|
||||
// }
|
||||
|
||||
for(var i = 0; i < lst.length; i++){
|
||||
l.options[l.options.length] = new Option(lst[i].fullname, lst[i].url);
|
||||
}
|
||||
}
|
||||
}
|
||||
////////////////////////////////////////////////////
|
||||
|
||||
ImageDialog.preInit();
|
||||
tinyMCEPopup.onInit.add(ImageDialog.init, ImageDialog);
|
565
sn_templates/editor_stuff/plugin/snstuff/js/image_old.js
Normal file
@@ -0,0 +1,565 @@
|
||||
var ImageDialog = {
|
||||
preInit : function() {
|
||||
var url;
|
||||
|
||||
tinyMCEPopup.requireLangPack();
|
||||
|
||||
Config.artikelid = parent.entryid;
|
||||
Config.pagetype = parent.pagetpye;
|
||||
Config.imageListUrl = tinyMCEPopup.getParam("snstuff_img_url_list") || "/admin_list_pictures_json/{artikelid}";
|
||||
Config.uploadUrl = tinyMCEPopup.getParam("snstuff_img_url_upload") || "/{pagetype}/{artikelid}?sx_action=on_user_upload";
|
||||
Config.deleteUrl = tinyMCEPopup.getParam("snstuff_img_url_delete") || "/admin_kill_picture?name=articleimage/sn_computer/{artikelid}/{imgname}&id={artikelid}";
|
||||
Config.imageUrl = tinyMCEPopup.getParam("snstuff_img_url_image") || "/articleimage/{artikelid}/{imgname}";
|
||||
|
||||
},
|
||||
|
||||
|
||||
objData:{a:{},c:{},t:'',l:''},
|
||||
|
||||
activeDataName:'',
|
||||
activeDataFullname:'',
|
||||
activeClickPic:'',
|
||||
isUploading: false,
|
||||
isDeleting : false,
|
||||
|
||||
srcData: {},
|
||||
isVideo: false,
|
||||
|
||||
srcList:'',
|
||||
srcListSize:'',
|
||||
srcListSizeFull:'',
|
||||
|
||||
selData: {},
|
||||
imgAlign:"",
|
||||
|
||||
tsrcData:'',
|
||||
tsrcDataName:'',
|
||||
tpicShow:'',
|
||||
tpicShowFull:'',
|
||||
tvideoPic:'',
|
||||
|
||||
init : function(ed) {
|
||||
|
||||
this.watch('tsrcDataName',this.tsrcDataNameAction);
|
||||
this.watch('tsrcData',this.tsrcDataAction);
|
||||
this.watch('tpicShow',this.tpicShowAction);
|
||||
|
||||
document.forms["uploadForm"].action = Config.getUploadUrl();
|
||||
|
||||
var ed = tinyMCEPopup.editor, dom = ed.dom, n = ed.selection.getNode();
|
||||
|
||||
tinyMCEPopup.resizeToInnerSize();
|
||||
|
||||
TinyMCE_EditableSelects.init();
|
||||
|
||||
if ( n != null && typeof n != 'undefined' && n.nodeName == 'IMG') {
|
||||
this.objData.t = 'pic';
|
||||
this.imgURL = dom.getAttrib(n, 'src');
|
||||
this.objData.a['click'] = dom.getAttrib(n, 'alt');
|
||||
this.selectByValue(document.getElementById('align'), this.getAttrib(n, 'align'));
|
||||
document.getElementById("insert").value = ed.getLang('update');
|
||||
this.imgAlign = dom.getAttrib(n, 'style');
|
||||
|
||||
if (ed.settings.inline_styles) {
|
||||
// Move attribs to styles
|
||||
if (dom.getAttrib(n, 'align'))
|
||||
this.updateStyle('align');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
// this.changeAppearance();
|
||||
this.loadData();
|
||||
},
|
||||
|
||||
////////////////////////////
|
||||
tsrcDataNameAction: function(p,o,n){
|
||||
this.tsrcData = this.srcData.o[n]
|
||||
},
|
||||
|
||||
tpicShowAction: function(p,o,n){
|
||||
this.previewData();
|
||||
},
|
||||
|
||||
tpicShowFullAction: function(p,o,n){},
|
||||
|
||||
|
||||
tsrcDataAction: function(p,o,n){
|
||||
|
||||
var lst = tinyMCEPopup.dom.get("src_list_size");
|
||||
var lst2 = tinyMCEPopup.dom.get("src_list_size_full");
|
||||
var lstv = tinyMCEPopup.dom.get("src_list_vid_pic");
|
||||
lstv.options.length = 0;
|
||||
lst.options.length = 0;
|
||||
lst2.options.length = 0;
|
||||
var sp = 0; var sp2 = 0;
|
||||
|
||||
if(typeof(this.tsrcData) != 'undefined'){
|
||||
var dl = this.tsrcData.l;
|
||||
|
||||
tinyMCEPopup.dom.get("src_list_size").style.display = 'inline';
|
||||
tinyMCEPopup.dom.get("src_list_size_full").style.display = 'inline';
|
||||
tinyMCEPopup.dom.get("src_list_vid_pic").style.display = 'none';
|
||||
tinyMCEPopup.dom.get("align").disabled = false;
|
||||
|
||||
for(var i = 0; i < dl.length; i++){
|
||||
var o = this.tsrcData.o[dl[i]];
|
||||
if(o.fullName == this.activeDataFullname){sp = i;}
|
||||
if(o.fullName == this.activeClickPic){sp2 = i;}
|
||||
lst.options[lst.options.length] = new Option(o.size, o.fullName);
|
||||
lst2.options[lst2.options.length] = new Option(o.size, o.fullName);
|
||||
}
|
||||
|
||||
if(!this.activeClickPic){
|
||||
var sd = -1;
|
||||
for(var i = 0; i < lst2.options.length;i++){
|
||||
var txt = lst2.options[i].text;
|
||||
var s = (txt == 'Orig.')?9999999:parseInt(txt);
|
||||
if(s > sd ){
|
||||
sd = s;
|
||||
sp2 = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
lst2.selectedIndex = sp2;
|
||||
lst.selectedIndex = sp;
|
||||
|
||||
lst.onchange();lst2.onchange();
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/////////////////////////////
|
||||
|
||||
// changeAppearance : function() {
|
||||
// var ed = tinyMCEPopup.editor, img = document.getElementById('alignSampleImg');
|
||||
//
|
||||
// if (img) {
|
||||
// if (ed.getParam('inline_styles')) {
|
||||
// ed.dom.setAttrib(img, 'style', ImageDialog.imgAlign);
|
||||
// } else {
|
||||
// img.align = document.getElementById("align").value;
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
insert : function(file, title) {
|
||||
var ed = tinyMCEPopup.editor, t = this;
|
||||
|
||||
if (!this.srcList) {
|
||||
if (ed.selection.getNode().nodeName == 'IMG') {
|
||||
ed.dom.remove(ed.selection.getNode());
|
||||
ed.execCommand('mceRepaint');
|
||||
}
|
||||
|
||||
tinyMCEPopup.close();
|
||||
return;
|
||||
}
|
||||
|
||||
t.insertPicAndClose();
|
||||
|
||||
},
|
||||
insertPicAndClose : function() {
|
||||
var ed = tinyMCEPopup.editor, v, args = {}, el;
|
||||
|
||||
tinyMCEPopup.restoreSelection();
|
||||
|
||||
// Fixes crash in Safari
|
||||
if (tinymce.isWebKit)
|
||||
ed.getWin().focus();
|
||||
|
||||
tinyMCEPopup.execCommand("mceBeginUndoLevel");
|
||||
|
||||
// if (!ed.settings.inline_styles) {
|
||||
args = {
|
||||
align : document.getElementById("align").value
|
||||
};
|
||||
// } else {
|
||||
// // Remove deprecated values
|
||||
// args = {
|
||||
// align : ''
|
||||
// };
|
||||
// }
|
||||
|
||||
tinymce.extend(args, {
|
||||
src : this.selData.lnk,
|
||||
alt : this.srcListSizeFull,
|
||||
style : this.imgAlign,
|
||||
href : this.selData.lnk
|
||||
});
|
||||
|
||||
el = ed.selection.getNode();
|
||||
|
||||
|
||||
// entfernen und neu einfuegen. Weil das advimagescale plugin sonst unerwuenschten nebeneffekt erzeugt
|
||||
if (el && el.nodeName == 'IMG') {
|
||||
ed.dom.remove(ed.selection.getNode());
|
||||
// ed.dom.setAttribs(el, args);
|
||||
} //else {
|
||||
// if(this.srcList){
|
||||
ed.execCommand('mceInsertContent', false, '<img class="noresize" id="__mce_tmp" />', {skip_undo : 1});
|
||||
ed.dom.setAttribs('__mce_tmp', args);
|
||||
ed.dom.setAttrib('__mce_tmp', 'id', '');
|
||||
ed.undoManager.add();
|
||||
// }
|
||||
// }
|
||||
|
||||
// ed.execCommand('mceRepaint');
|
||||
tinyMCEPopup.execCommand("mceEndUndoLevel");
|
||||
tinyMCEPopup.close();
|
||||
},
|
||||
|
||||
insertVideoAndClose: function(){
|
||||
var html = "";
|
||||
},
|
||||
|
||||
updateStyle : function(ty) {
|
||||
var dom = tinyMCEPopup.dom, st, v, img = dom.create('img', {style : ImageDialog.imgAlign});
|
||||
|
||||
if (tinyMCEPopup.editor.settings.inline_styles) {
|
||||
// Handle align
|
||||
if (ty == 'align') {
|
||||
dom.setStyle(img, 'float', '');
|
||||
dom.setStyle(img, 'vertical-align', '');
|
||||
|
||||
v = document.getElementById("align").value;
|
||||
if (v) {
|
||||
if (v == 'left' || v == 'right')
|
||||
dom.setStyle(img, 'float', v);
|
||||
else
|
||||
img.style.verticalAlign = v;
|
||||
}
|
||||
}
|
||||
// Merge
|
||||
ImageDialog.imgAlign = dom.serializeStyle(dom.parseStyle(img.style.cssText));
|
||||
}
|
||||
},
|
||||
|
||||
selectByValue: function (obj, value, add_custom, ignore_case) {
|
||||
if (!obj)
|
||||
return;
|
||||
|
||||
var found = false;
|
||||
for (var i=0; i<obj.options.length; i++) {
|
||||
var option = obj.options[i];
|
||||
|
||||
if (option.value == value || (ignore_case && option.value.toLowerCase() == value.toLowerCase())) {
|
||||
option.selected = true;
|
||||
found = true;
|
||||
} else{
|
||||
option.selected = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found && add_custom && value != '') {
|
||||
var option = new Option(value, value);
|
||||
option.selected = true;
|
||||
obj.options[sel.options.length] = option;
|
||||
obj.selectedIndex = obj.options.length - 1;
|
||||
}
|
||||
|
||||
return found;
|
||||
},
|
||||
|
||||
getAttrib : function(e, at) {
|
||||
var ed = tinyMCEPopup.editor, dom = ed.dom, v, v2;
|
||||
|
||||
if (ed.settings.inline_styles) {
|
||||
switch (at) {
|
||||
case 'align':
|
||||
if (v = dom.getStyle(e, 'float'))
|
||||
return v;
|
||||
|
||||
if (v = dom.getStyle(e, 'vertical-align'))
|
||||
return v;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (v = dom.getAttrib(e, at))
|
||||
return v;
|
||||
|
||||
return '';
|
||||
},
|
||||
srcListAction: function(v){
|
||||
|
||||
this.srcList = v;
|
||||
var lst = tinyMCEPopup.dom.get("src_list_size");
|
||||
var lst2 = tinyMCEPopup.dom.get("src_list_size_full");
|
||||
var lstv = tinyMCEPopup.dom.get("src_list_vid_pic");
|
||||
lstv.options.length = 0;
|
||||
lst.options.length = 0;
|
||||
lst2.options.length = 0;
|
||||
var sp = 0; var sp2 = 0;
|
||||
|
||||
if(this.srcData.data[v]){
|
||||
if(this.srcData.data[v].type == 'pic'){
|
||||
tinyMCEPopup.dom.get("src_list_size").style.display = 'inline';
|
||||
tinyMCEPopup.dom.get("src_list_size_full").style.display = 'inline';
|
||||
tinyMCEPopup.dom.get("src_list_vid_pic").style.display = 'none';
|
||||
tinyMCEPopup.dom.get("align").disabled = false;
|
||||
var d = this.srcData.data[v].lst;
|
||||
|
||||
for(var i = 0; i < d.length; i++){
|
||||
if(d[i].fullName == this.activeDataFullname){sp = i;}
|
||||
if(d[i].fullName == this.activeClickPic){sp2 = i;}
|
||||
|
||||
lst.options[lst.options.length] = new Option(d[i].size, d[i].fullName);
|
||||
lst2.options[lst2.options.length] = new Option(d[i].size, d[i].fullName);
|
||||
}
|
||||
|
||||
if(!this.activeClickPic){
|
||||
var sd = -1;
|
||||
for(var i = 0; i < lst2.options.length;i++){
|
||||
var txt = lst2.options[i].text;
|
||||
var s = (txt == 'Orig.')?9999999:parseInt(txt);
|
||||
if(s > sd ){
|
||||
sd = s;
|
||||
sp2 = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
lst2.selectedIndex = sp2;
|
||||
lst.selectedIndex = sp;
|
||||
|
||||
|
||||
this.srcListSize = lst.options[lst.selectedIndex].value;
|
||||
this.srcListSizeFull = lst2.options[lst2.selectedIndex].value;
|
||||
lst.onchange();
|
||||
}else{
|
||||
tinyMCEPopup.dom.get("src_list_size").style.display = 'none';
|
||||
tinyMCEPopup.dom.get("src_list_size_full").style.display = 'none';
|
||||
tinyMCEPopup.dom.get("src_list_vid_pic").style.display = 'inline';
|
||||
tinyMCEPopup.dom.get("align").disabled = true;
|
||||
|
||||
this.selData = this.srcData.data[v].lst[0];
|
||||
|
||||
var d = this.srcData;
|
||||
for(var i = 0; i < d.imgLst.length; i++){
|
||||
if(this.srcData.data[d.imgLst[i]].type != 'pic'){continue;}
|
||||
var pl = this.srcData.data[d.imgLst[i]].lst;
|
||||
lstv.options[lstv.options.length] = new Option('','');
|
||||
for(var j = 0; j < pl.length; j++){
|
||||
if(pl[j].fullName == this.srcListSize){ sp = lst.options.length};
|
||||
lstv.options[lstv.options.length] = new Option(pl[j].fullName,pl[j].fullName);
|
||||
}
|
||||
}
|
||||
lstv.selectedIndex = sp;
|
||||
lstv.onchange();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
|
||||
picSizeAction:function(v){
|
||||
this.srcListSize = v;
|
||||
this.selData = {};
|
||||
if(this.srcData.data[this.srcList]){
|
||||
var lst = this.srcData.data[this.srcList].lst;
|
||||
for(var i = 0; i < lst.length; i++){
|
||||
if(lst[i].fullName == v){
|
||||
this.selData = lst[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.previewData(this.selData);
|
||||
},
|
||||
|
||||
videoPicAction: function(v){
|
||||
this.srcListSize = v;
|
||||
},
|
||||
|
||||
picSizeFullAction:function(v){
|
||||
this.srcListSizeFull = v;
|
||||
},
|
||||
|
||||
previewData : function() {
|
||||
|
||||
if (!this.tsrcData) {
|
||||
tinyMCEPopup.dom.setHTML('prev', '');
|
||||
document.getElementById("imgDelBtn").disabled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// if (tinyMCEPopup.getParam("advimage_update_dimensions_onchange", true))
|
||||
// this.resetImageData();
|
||||
var o = this.tsrcData.o[this.tpicShow];
|
||||
var u = tinyMCEPopup.editor.documentBaseURI.toAbsolute(o.lnk);
|
||||
document.getElementById("imgDelBtn").disabled = false
|
||||
|
||||
// if (!st)
|
||||
// tinyMCEPopup.dom.setHTML('prev', '<img id="previewImg" src="' + u + '" border="0" onload="ImageDialog.updateImageData(this);" onerror="ImageDialog.resetImageData();" />');
|
||||
// else
|
||||
// tinyMCEPopup.dom.setHTML('prev', '<img id="previewImg" src="' + u + '" border="0" onload="ImageDialog.updateImageData(this, 1);" />');
|
||||
tinyMCEPopup.dom.setHTML('prev', '<img id="previewImg" src="' + u + '" border="0" onload="" />');
|
||||
},
|
||||
//////////////////////////////// Helper ////////////////////////////
|
||||
|
||||
loadData: function(){
|
||||
var xmlHttp = this.getXMLHttpRequest();
|
||||
if(xmlHttp){
|
||||
xmlHttp.open('GET', Config.getImageListUrl(), true);
|
||||
xmlHttp.onreadystatechange = function () {
|
||||
|
||||
if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
|
||||
ImageDialog.parseAndSet(xmlHttp.responseText);
|
||||
}
|
||||
};
|
||||
xmlHttp.send(null);
|
||||
}
|
||||
},
|
||||
|
||||
deleteData: function(url){
|
||||
var xmlHttp = this.getXMLHttpRequest();
|
||||
if(xmlHttp){
|
||||
xmlHttp.open('GET', url, true);
|
||||
xmlHttp.onreadystatechange = function () {
|
||||
|
||||
if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
|
||||
ImageDialog.actionStop();
|
||||
}
|
||||
};
|
||||
xmlHttp.send(null);
|
||||
}
|
||||
},
|
||||
|
||||
doDeleteImg : function(){
|
||||
var img = this.srcListSize;;
|
||||
|
||||
document.getElementById("imgDelBtn").disabled = true;
|
||||
document.getElementById("waitImg").style.visibility = "visible";
|
||||
ImageDialog.isDeleting = true;
|
||||
ImageDialog.deleteData(Config.getDeleteUrl(img));
|
||||
|
||||
},
|
||||
|
||||
getXMLHttpRequest: function(){
|
||||
var xmlHttp = null;
|
||||
// Mozilla, Opera, Safari sowie Internet Explorer (ab v7)
|
||||
if (typeof XMLHttpRequest != 'undefined') {
|
||||
xmlHttp = new XMLHttpRequest();
|
||||
}
|
||||
if (!xmlHttp) {
|
||||
// Internet Explorer 6 und älter
|
||||
try {
|
||||
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
|
||||
} catch(e) {
|
||||
try {
|
||||
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
|
||||
} catch(e) {
|
||||
xmlHttp = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return xmlHttp;
|
||||
},
|
||||
|
||||
parseAndSet: function(xml){
|
||||
var obj = eval('(' + xml + ')');
|
||||
|
||||
this.srcData = {'l':[],'o':{},'t':''};
|
||||
|
||||
var id = 0;
|
||||
// parse loaded JSON object & create new object
|
||||
|
||||
this.activeDataFullname = (this.imgURL)?this.imgURL.split('/').pop():undefined;
|
||||
|
||||
for(var i = 0; i < obj.length; i++){
|
||||
var size = obj[i].Size;
|
||||
var lnk = obj[i].Link;
|
||||
var imgnameFull = lnk.split("/").pop();
|
||||
|
||||
imgname = imgnameFull.replace("_"+size,"");
|
||||
|
||||
var lnk_test = lnk.split("/");
|
||||
|
||||
if(lnk_test.length == 1 &&lnk_test.shift() != "http:"){
|
||||
lnk = Config.getImageUrl(lnk);
|
||||
}
|
||||
|
||||
if(size == 0)
|
||||
size = "Orig.";
|
||||
|
||||
if(typeof(this.srcData.o[imgname]) == 'undefined'){
|
||||
this.srcData.l.push(imgname);
|
||||
this.srcData.o[imgname] = {'l':[],'o':{},'t':''};
|
||||
this.srcData.o[imgname]['t'] = obj[i].Type;
|
||||
}
|
||||
|
||||
|
||||
this.srcData.o[imgname].o[imgnameFull] = {'name':imgname, 'fullName':imgnameFull, 'size':size,'lnk':lnk};
|
||||
this.srcData.o[imgname].l.push(imgnameFull);
|
||||
|
||||
|
||||
if(imgnameFull == this.activeDataFullname){ this.activeDataName = imgname;}
|
||||
}
|
||||
////////////
|
||||
|
||||
var lst = tinyMCEPopup.dom.get("src_list");
|
||||
|
||||
lst.options.length = 0;
|
||||
|
||||
lst.options[lst.options.length] = new Option('', '');
|
||||
var d = this.srcData;
|
||||
var sp = 0;
|
||||
for(var i = 0; i < d.l.length; i++){
|
||||
if(d.l[i] == this.activeDataName){
|
||||
sp = i+1;
|
||||
}
|
||||
lst.options[lst.options.length] = new Option(d.l[i], d.l[i]);
|
||||
}
|
||||
lst.selectedIndex = sp;
|
||||
lst.onchange();
|
||||
},
|
||||
|
||||
uploadStart : function(){
|
||||
ImageDialog.isUploading = true;
|
||||
document.getElementById("waitImg").style.visibility = "visible";
|
||||
document.getElementById("uploadSubmit").disabled = true;
|
||||
},
|
||||
|
||||
actionStop : function(){
|
||||
|
||||
|
||||
if(ImageDialog.isUploading){
|
||||
|
||||
document.getElementById("waitImg").style.visibility = "hidden";
|
||||
document.getElementById("uploadSubmit").disabled = false;
|
||||
document.getElementById("fileField").disabled = false;
|
||||
document.getElementById("fileField").value = "";
|
||||
this.loadData();
|
||||
ImageDialog.isUploading = false;
|
||||
}
|
||||
|
||||
if(ImageDialog.isDeleting){
|
||||
document.getElementById("waitImg").style.visibility = "hidden";
|
||||
document.getElementById("imgDelBtn").disabled = false;
|
||||
|
||||
this.loadData();
|
||||
|
||||
ImageDialog.isDeleting = false;
|
||||
}
|
||||
|
||||
// var http_status=507;
|
||||
// var http_message='507 Insufficient Storage';
|
||||
// var error_message='Upload zu gross, bitte maximal 2 MB hochladen.';
|
||||
|
||||
var iFrame = document.getElementById('actionTarget').contentWindow;
|
||||
|
||||
if(typeof iFrame.error_message != 'undefined'){
|
||||
alert(iFrame.error_message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
|
||||
ImageDialog.preInit();
|
||||
tinyMCEPopup.onInit.add(ImageDialog.init, ImageDialog);
|
63
sn_templates/editor_stuff/plugin/snstuff/js/infobox.js
Normal file
@@ -0,0 +1,63 @@
|
||||
/* Functions for the advlink plugin popup */
|
||||
|
||||
tinyMCEPopup.requireLangPack();
|
||||
|
||||
function preinit() {
|
||||
var url;
|
||||
if (url = tinyMCEPopup.getParam("external_link_list_url"))
|
||||
document.write('<script language="javascript" type="text/javascript" src="' + tinyMCEPopup.editor.documentBaseURI.toAbsolute(url) + '"></script>');
|
||||
}
|
||||
|
||||
function init() {
|
||||
var formObj = document.forms[0];
|
||||
var ed = tinyMCEPopup.editor;
|
||||
var node = ed.selection.getNode()
|
||||
var sel = ed.selection.getContent();
|
||||
var pnode = ed.dom.getParent(node, function(n) {return ed.dom.hasClass(n, "snInfoBox");});
|
||||
|
||||
if(pnode){
|
||||
formObj.insert.value = tinyMCEPopup.getLang('update', 'Insert', true);
|
||||
var _pwv = parseInt(pnode.style.width);
|
||||
formObj.size.value = isNaN(_pwv) ? 100: _pwv;
|
||||
var f = pnode.style.cssText.indexOf("float: left") != -1 ? "left":"right"; // workroung becouse pnode.style.float return undefined
|
||||
var o = formObj.float.options;
|
||||
for(var i = 0; i < o.length;i++){
|
||||
if(o[i].value == f){
|
||||
o.selectedIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function insertAction() {
|
||||
var formObj = document.forms[0];
|
||||
var ed = tinyMCEPopup.editor;
|
||||
var node = ed.selection.getNode()
|
||||
var sel = ed.selection.getContent();
|
||||
var pnode = ed.dom.getParent(node, function(n) {return ed.dom.hasClass(n, "snInfoBox");});
|
||||
|
||||
var s = parseInt(formObj.size.value);
|
||||
var f = formObj.float.value;
|
||||
var args = {style: "width:"+s+"px; float:"+f+";", class:"snInfoBox"};
|
||||
|
||||
if(!pnode && sel.length == 0){ sel = tinyMCEPopup.getLang('snstuff_dlg.ibox_defaulttext', 'Text....', true);}
|
||||
|
||||
tinyMCEPopup.execCommand("mceBeginUndoLevel");
|
||||
if(sel.length > 0){
|
||||
ed.execCommand('mceInsertRawHTML', false, '<span id="__snInfoBoxTmp" >'+sel+'</span>', {skip_undo : 1});
|
||||
ed.dom.setAttribs('__snInfoBoxTmp', args);
|
||||
ed.dom.setAttrib('__snInfoBoxTmp', 'id', '');
|
||||
ed.undoManager.add();
|
||||
}else{
|
||||
ed.dom.setAttribs(pnode, args);
|
||||
}
|
||||
tinyMCEPopup.execCommand("mceEndUndoLevel");
|
||||
ed.execCommand('mceRepaint');
|
||||
tinyMCEPopup.close();
|
||||
}
|
||||
|
||||
// While loading
|
||||
preinit();
|
||||
tinyMCEPopup.onInit.add(init);
|
||||
|
32
sn_templates/editor_stuff/plugin/snstuff/js/sncode.js
Normal file
@@ -0,0 +1,32 @@
|
||||
/* Functions for the advlink plugin popup */
|
||||
|
||||
tinyMCEPopup.requireLangPack();
|
||||
|
||||
function preinit() {
|
||||
var url;
|
||||
|
||||
if (url = tinyMCEPopup.getParam("external_link_list_url"))
|
||||
document.write('<script language="javascript" type="text/javascript" src="' + tinyMCEPopup.editor.documentBaseURI.toAbsolute(url) + '"></script>');
|
||||
}
|
||||
|
||||
function init() {
|
||||
}
|
||||
function insertAction() {
|
||||
var formObj = document.forms[0];
|
||||
var ed = tinyMCEPopup.editor;
|
||||
var node = ed.selection.getNode()
|
||||
|
||||
// if (node && node.nodeName == 'CODE') {
|
||||
// node.firstChild.nodeValue = document.getElementById("text").value;
|
||||
// }else {
|
||||
ed.execCommand('mceInsertContent', false, '<code>'+formObj.text.value.replace(/\n/g,"<br />")+'</code>', {skip_undo : 1});
|
||||
ed.undoManager.add();
|
||||
// }
|
||||
|
||||
tinyMCEPopup.close();
|
||||
}
|
||||
|
||||
// While loading
|
||||
preinit();
|
||||
tinyMCEPopup.onInit.add(init);
|
||||
|
112
sn_templates/editor_stuff/plugin/snstuff/js/snlink.js
Normal file
@@ -0,0 +1,112 @@
|
||||
/* Functions for the advlink plugin popup */
|
||||
|
||||
tinyMCEPopup.requireLangPack();
|
||||
|
||||
function preinit() {
|
||||
/* var url;
|
||||
|
||||
if (url = tinyMCEPopup.getParam("external_link_list_url"))
|
||||
document.write('<script language="javascript" type="text/javascript" src="' + tinyMCEPopup.editor.documentBaseURI.toAbsolute(url) + '"></script>');*/
|
||||
}
|
||||
|
||||
|
||||
function init() {
|
||||
|
||||
var formObj = document.forms[0];
|
||||
var ed = tinyMCEPopup.editor;
|
||||
var enode = ed.selection.getNode();
|
||||
|
||||
var node = ed.dom.getParent(enode, "A");
|
||||
var selTxt = ed.selection.getContent();
|
||||
|
||||
if(enode.nodeName == 'IMG'){
|
||||
document.getElementById("urlName").style.visibility = "hidden";
|
||||
}
|
||||
|
||||
if(node != null && typeof node != 'undefined' && node.nodeName == 'A'){
|
||||
formObj.insert.value = tinyMCEPopup.getLang('update', 'Insert', true);
|
||||
|
||||
var url = ed.dom.getAttrib(node,"href");
|
||||
var txt = node.firstChild.nodeValue;
|
||||
var desc = ed.dom.getAttrib(node,"title");
|
||||
formObj.urlField.value = url;
|
||||
formObj.nameField.value = txt;
|
||||
formObj.descField.value = desc;
|
||||
|
||||
}else{
|
||||
|
||||
if(isURL(selTxt)){
|
||||
formObj.urlField.value = selTxt.replace(/^\s*/,"");
|
||||
}
|
||||
if(enode.nodeName != 'IMG'){
|
||||
formObj.nameField.value = selTxt;
|
||||
}
|
||||
if(selTxt.length > 0){
|
||||
document.getElementById("urlName").style.visibility = "hidden";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function insertAction() {
|
||||
var formObj = document.forms[0];
|
||||
var ed = tinyMCEPopup.editor;
|
||||
var enode = ed.selection.getNode();
|
||||
|
||||
var node = ed.dom.getParent(enode, "A");
|
||||
|
||||
// Remove element if there is no href
|
||||
if (!formObj.urlField.value) {
|
||||
tinyMCEPopup.execCommand("mceBeginUndoLevel");
|
||||
i = ed.selection.getBookmark();
|
||||
ed.dom.remove(node, 1);
|
||||
ed.selection.moveToBookmark(i);
|
||||
tinyMCEPopup.execCommand("mceEndUndoLevel");
|
||||
tinyMCEPopup.close();
|
||||
return;
|
||||
}
|
||||
tinyMCEPopup.execCommand("mceBeginUndoLevel");
|
||||
|
||||
var lnk = formObj.urlField.value;//ed.baseURI.toAbsolute(formObj.urlField.value);
|
||||
var title = formObj.descField.value;
|
||||
if(!title || title.length == 0){
|
||||
title = lnk;
|
||||
}
|
||||
if (node && node.nodeName == 'A') {
|
||||
ed.dom.setAttrib(node, "href", lnk);
|
||||
ed.dom.setAttrib(node, "title", title);
|
||||
node.firstChild.nodeValue = formObj.nameField.value;
|
||||
|
||||
}else {
|
||||
// if(ed.selection.getContent().length > 0){
|
||||
// ed.getDoc().execCommand("unlink", false, null);
|
||||
// tinyMCEPopup.execCommand("CreateLink", false, "#mce_temp_url#", {skip_undo : 1});
|
||||
//
|
||||
// elementArray = tinymce.grep(ed.dom.select("a"), function(n) {return ed.dom.getAttrib(n, 'href') == '#mce_temp_url#';});
|
||||
// for (i=0; i<elementArray.length; i++){
|
||||
// var elm = elementArray[i];
|
||||
// ed.dom.setAttrib(elm, "href", formObj.urlField.value);
|
||||
// }
|
||||
// }else{
|
||||
ed.execCommand('mceInsertContent', false, '<a href="'+lnk+'" title="'+title+'">'+formObj.nameField.value+'</a>', {skip_undo : 1});
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
tinyMCEPopup.execCommand("mceEndUndoLevel");
|
||||
tinyMCEPopup.close();
|
||||
|
||||
}
|
||||
|
||||
|
||||
function isURL(str){
|
||||
if(str.match(/^http(s){0,1}:\/\//) || str.match(/^\s*www.*\..+/)){
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// While loading
|
||||
preinit();
|
||||
tinyMCEPopup.onInit.add(init);
|
31
sn_templates/editor_stuff/plugin/snstuff/js/snquote.js
Normal file
@@ -0,0 +1,31 @@
|
||||
/* Functions for the advlink plugin popup */
|
||||
|
||||
tinyMCEPopup.requireLangPack();
|
||||
|
||||
function preinit() {
|
||||
var url;
|
||||
|
||||
if (url = tinyMCEPopup.getParam("external_link_list_url"))
|
||||
document.write('<script language="javascript" type="text/javascript" src="' + tinyMCEPopup.editor.documentBaseURI.toAbsolute(url) + '"></script>');
|
||||
}
|
||||
|
||||
function init() {
|
||||
}
|
||||
function insertAction() {
|
||||
var formObj = document.forms[0];
|
||||
var ed = tinyMCEPopup.editor;
|
||||
var node = ed.selection.getNode()
|
||||
|
||||
// if (node && node.nodeName == 'BLOCKQUOTE') {
|
||||
// node.firstChild.nodeValue = document.getElementById("text").value;
|
||||
// }else {
|
||||
ed.execCommand('mceInsertRawHTML', false, '<blockquote>'+formObj.text.value.replace(/\n/g,"<br />")+'</blockquote>', {skip_undo : 1});
|
||||
ed.undoManager.add();
|
||||
// }
|
||||
|
||||
tinyMCEPopup.close();
|
||||
}
|
||||
|
||||
// While loading
|
||||
preinit();
|
||||
tinyMCEPopup.onInit.add(init);
|
70
sn_templates/editor_stuff/plugin/snstuff/langs/de_dlg.js
Normal file
@@ -0,0 +1,70 @@
|
||||
tinyMCE.addI18n('de.snstuff_dlg',{
|
||||
img_tab_upload: "Bilder Hochladen",
|
||||
img_general:"Allgemein",
|
||||
img_title:"Title",
|
||||
img_preview:"Vorschau",
|
||||
img_style:"Style",
|
||||
img_classes:"Classes",
|
||||
img_ltr:"Links nach Rechts",
|
||||
img_rtl:"Rechts nach Links",
|
||||
img_id:"Id",
|
||||
img_map:"Bilderliste",
|
||||
img_dialog_title:"Bilder/Videos Einf\u00FCgen/Bearbeiten",
|
||||
img_list:"Medienliste",
|
||||
img_align:"Ausrichtung",
|
||||
img_align_top:"Oben",
|
||||
img_align_middle:"Mittig",
|
||||
img_align_bottom:"Unten",
|
||||
img_align_texttop:"Text oben",
|
||||
img_align_textbottom:"Text unten",
|
||||
img_align_left:"Links",
|
||||
img_align_right:"Reschts",
|
||||
img_align_none:"Keine",
|
||||
img_image_list:"Medienliste",
|
||||
img_image_delete:"Löschen",
|
||||
img_upload:"Bild/Video hochladen",
|
||||
img_imagefile_select:"Bild/Video:",
|
||||
img_imagefile_sndbtn: "Hochladen",
|
||||
img_imagefile_uploadnotify:"Bildvorschau",
|
||||
img_imagedelete:"Gewähltes Bild/Video löschen",
|
||||
img_imgsize_40height : "40 Pixel Höhe",
|
||||
img_imgsize_80height : "80 Pixel Höhe",
|
||||
img_imgsize_200width : "200 Pixel Breite",
|
||||
img_imgsize_470width : "470 Pixel Breite",
|
||||
img_width:"Breite",
|
||||
img_height:"Höhe",
|
||||
img_pic_select : "Bild größe",
|
||||
img_vpic_select : "Vorschaubild",
|
||||
img_video_pic : " ",
|
||||
img_pic_show : " ",
|
||||
img_pic_show_full : " Vollbild ",
|
||||
|
||||
|
||||
lnk_title: "Link Einf\u00FCgen/Bearbeiten",
|
||||
lnk_general_props: "Link bearbeiten",
|
||||
lnk_desc:"Link",
|
||||
lnk_field_url:"URL",
|
||||
lnk_field_desc:"Title (Opt.)",
|
||||
lnk_field_name:"Text",
|
||||
|
||||
|
||||
quote_desc:"Zitat",
|
||||
qoute_general_props: "Zitat",
|
||||
quote_title:"Zitat einf\u00FCgen",
|
||||
|
||||
code_desc:"Quelltext",
|
||||
code_general_props: "Quelltext",
|
||||
code_title:"Quelltext einf\u00FCgen",
|
||||
|
||||
ibox_title: "InfoBox Einf\u00FCgen/Bearbeiten",
|
||||
ibox_general_props:"InfoBox",
|
||||
ibox_input_titel:"Titel:",
|
||||
ibox_input_size:"Breite:",
|
||||
ibox_input_float:"Position:",
|
||||
ibox_fopt_none:"keine",
|
||||
ibox_fopt_right:"Rechts",
|
||||
ibox_fopt_left:"Links",
|
||||
ibox_defaulttext:"Bitte text eingeben..",
|
||||
////
|
||||
last:""
|
||||
});
|
83
sn_templates/editor_stuff/plugin/snstuff/langs/en_dlg.js
Normal file
@@ -0,0 +1,83 @@
|
||||
tinyMCE.addI18n('en.snimages_dlg',{
|
||||
tab_general:"General",
|
||||
tab_appearance:"Appearance",
|
||||
tab_advanced:"Advanced",
|
||||
tab_upload: "Image Upload",
|
||||
general:"General",
|
||||
title:"Title",
|
||||
preview:"Preview",
|
||||
constrain_proportions:"Constrain proportions",
|
||||
langdir:"Language direction",
|
||||
langcode:"Language code",
|
||||
long_desc:"Long description link",
|
||||
style:"Style",
|
||||
classes:"Classes",
|
||||
ltr:"Left to right",
|
||||
rtl:"Right to left",
|
||||
id:"Id",
|
||||
map:"Image map",
|
||||
swap_image:"Swap image",
|
||||
alt_image:"Alternative image",
|
||||
mouseover:"for mouse over",
|
||||
mouseout:"for mouse out",
|
||||
misc:"Miscellaneous",
|
||||
example_img:"Appearance preview image",
|
||||
missing_alt:"Are you sure you want to continue without including an Image Description? Without it the image may not be accessible to some users with disabilities, or to those using a text browser, or browsing the Web with images turned off.",
|
||||
dialog_title:"1Insert/edit image",
|
||||
src:"Image URL",
|
||||
alt:"Image description",
|
||||
list:"Image list",
|
||||
border:"Border",
|
||||
dimensions:"Dimensions",
|
||||
vspace:"Vertical space",
|
||||
hspace:"Horizontal space",
|
||||
align:"Alignment",
|
||||
align_baseline:"Baseline",
|
||||
align_top:"Top",
|
||||
align_middle:"Middle",
|
||||
align_bottom:"Bottom",
|
||||
align_texttop:"Text top",
|
||||
align_textbottom:"Text bottom",
|
||||
align_left:"Left",
|
||||
align_right:"Right",
|
||||
align_none:"None",
|
||||
image_list:"Image list",
|
||||
image_delete:"Delete",
|
||||
upload:"Image Upload",
|
||||
imagefile_select:"Select Image",
|
||||
imagefile_sndbtn: "Upload",
|
||||
imagefile_uploadnotify:"Image Preview",
|
||||
imagedelete:"Delete selected Image",
|
||||
imgsize_40height : "40 Pixel height",
|
||||
imgsize_80height : "80 Pixel height",
|
||||
imgsize_200width : "200 Pixel width",
|
||||
imgsize_470width : "470 Pixel width",
|
||||
|
||||
|
||||
lnk_title: "Insert/Edit link",
|
||||
lnk_general_props: "Edit Link",
|
||||
lnk_desc:"Link",
|
||||
lnk_field_url:"URL",
|
||||
lnk_field_desc:"Description",
|
||||
|
||||
quote_desc:"Quote",
|
||||
qoute_general_props: "Quote",
|
||||
quote_title:"Insert Quote",
|
||||
|
||||
code_desc:"Code",
|
||||
code_general_props: "Code",
|
||||
code_title:"Insert Code",
|
||||
|
||||
ibox_titel:"Insert/Edit InfoBox",
|
||||
ibox_general_props:"InfoBox",
|
||||
ibox_input_titel:"Titel:",
|
||||
ibox_input_size:"Width:",
|
||||
ibox_input_float:"Position:",
|
||||
ibox_fopt_none:"none",
|
||||
ibox_fopt_right:"Right",
|
||||
ibox_fopt_left:"Left",
|
||||
ibox_defaulttext:"Enter text here...",
|
||||
////
|
||||
last:""
|
||||
|
||||
});
|