first re-commit.
This commit is contained in:
69
sn_templates/editor_stuff/plugin/snstuff/js/code.js
Normal file
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
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
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
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
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
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
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
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
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);
|
Reference in New Issue
Block a user