Index: openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/ExtendedFileManager/assets/editor.js =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/ExtendedFileManager/assets/editor.js,v diff -u -r1.6 -r1.7 --- openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/ExtendedFileManager/assets/editor.js 27 Mar 2009 08:20:43 -0000 1.6 +++ openacs-4/packages/acs-templating/www/resources/xinha-nightly/plugins/ExtendedFileManager/assets/editor.js 23 May 2010 11:58:33 -0000 1.7 @@ -1,3 +1,231 @@ -/* This compressed file is part of Xinha. For uncompressed sources, forum, and bug reports, go to xinha.org */ -/* This file is part of version 0.96beta2 released Fri, 20 Mar 2009 11:01:14 +0100 */ -var current_action=null;var actions=["crop","scale","rotate","measure","save"];var orginal_width=null,orginal_height=null;function toggle(a){if(current_action!=a){for(var b in actions){if(actions[b]!=a){var d=document.getElementById("tools_"+actions[b]);d.style.display="none";var g=document.getElementById("icon_"+actions[b]);g.className=""}}current_action=a;var d=document.getElementById("tools_"+a);d.style.display="block";var g=document.getElementById("icon_"+a);g.className="iconActive";var k=document.getElementById("indicator_image");k.src="img/"+a+".gif";editor.setMode(current_action);if(a=="scale"){var f=editor.window.document.getElementById("theImage");orginal_width=f._width;orginal_height=f._height;var l=document.getElementById("sw");l.value=orginal_width;var c=document.getElementById("sh");c.value=orginal_height}if(a=="save"){var e=document.getElementById("save_format");var j=document.getElementById("save_filename").value.match(/\.(gif|png|jpe?g)/i)[1].toLowerCase();switch(j){case"png":e.selectedIndex="3";break;case"gif":e.selectedIndex="4";break;default:e.selectedIndex="0";break}e.onchange()}}}function toggleMarker(){var a=document.getElementById("markerImg");if(a!=null&&a.src!=null){if(a.src.indexOf("t_black.gif")>=0){a.src="img/t_white.gif"}else{a.src="img/t_black.gif"}editor.toggleMarker()}}function toggleConstraints(){var a=document.getElementById("scaleConstImg");var b=document.getElementById("constProp");if(a!=null&&a.src!=null){if(a.src.indexOf("unlocked2.gif")>=0){a.src="img/islocked2.gif";b.checked=true;checkConstrains("width")}else{a.src="img/unlocked2.gif";b.checked=false}}}function checkConstrains(f){var e=document.getElementById("constProp");if(e.checked){var b=document.getElementById("sw");var d=b.value;var c=document.getElementById("sh");var a=c.value;if(orginal_width>0&&orginal_height>0){if(f=="width"&&d>0){c.value=parseInt((d/orginal_width)*orginal_height)}else{if(f=="height"&&a>0){b.value=parseInt((a/orginal_height)*orginal_width)}}}}updateMarker("scale")}function updateMarker(f){if(f=="crop"){var e=document.getElementById("cx");var d=document.getElementById("cy");var g=document.getElementById("cw");var b=document.getElementById("ch");editor.setMarker(parseInt(e.value),parseInt(d.value),parseInt(g.value),parseInt(b.value))}else{if(f=="scale"){var a=document.getElementById("sw");var c=document.getElementById("sh");editor.setMarker(0,0,parseInt(a.value),parseInt(c.value))}}}function rotateSubActionSelect(a){var c=a.options[a.selectedIndex].value;var b=document.getElementById("rotate_preset_select");var d=document.getElementById("flip");var e=document.getElementById("ra").parentNode;switch(c){case"rotate":b.style.display="";d.style.display="none";e.style.display="";break;case"flip":b.style.display="none";d.style.display="";e.style.display="none";break}}function rotatePreset(a){var b=a.options[a.selectedIndex].value;if(b.length>0&&parseInt(b)!=0){var c=document.getElementById("ra");c.value=parseInt(b)}}function updateFormat(c){var b=c.options[c.selectedIndex].value;var a=b.split(",");if(a[0]!="jpeg"){document.getElementById("slider").style.display="none"}else{document.getElementById("slider").style.display="inline"}if(a.length>1){updateSlider(parseInt(a[1]))}}function zoom(){var a=editor.window.document.getElementById("theImage");var b=document.getElementById("zoom").value;a.width=a._width*parseInt(b,10)/100;a.height=a._height*parseInt(b,10)/100;editor.reset();editor.pic_width=null;editor.pic_height=null}function addEvent(d,c,a){if(d.addEventListener){d.addEventListener(c,a,true);return true}else{if(d.attachEvent){var b=d.attachEvent("on"+c,a);return b}else{return false}}}var init=function(){if(window.opener){__xinha_dlg_init();__dlg_translate("ExtendedFileManager")}addEvent(window,"resize",winOnResize);try{window.moveTo(0,0)}catch(a){}window.resizeTo(window.screen.availWidth,window.screen.availHeight);winOnResize()};function winOnResize(){if(typeof editor.reset=="function"&&typeof editor.ant!="undefined"){editor.reset()}var a=Xinha.viewportSize(window);document.getElementById("contents").style.height=a.y-parseInt(document.getElementById("indicator").offsetHeight,10)-5+"px"}Xinha.addOnloadHandler(init,window); \ No newline at end of file +/** + * Functions for the ImageEditor interface, used by editor.php only + * Authors: Wei Zhuo, Afru, Krzysztof Kotowicz + * Version: Updated on 08-01-2005 by Afru + * Version: Updated on 20-06-2006 by Krzysztof Kotowicz + * Version: Updated on 20-01-2008 by Raimund Meyer + * Package: ExtendedFileManager (EFM 1.4) + */ + +var current_action = null; +var actions = ['crop', 'scale', 'rotate', 'measure', 'save']; +var orginal_width = null, orginal_height=null; +function toggle(action) +{ + if(current_action != action) + { + + for (var i in actions) + { + if(actions[i] != action) + { + var tools = document.getElementById('tools_'+actions[i]); + tools.style.display = 'none'; + var icon = document.getElementById('icon_'+actions[i]); + icon.className = ''; + } + } + + current_action = action; + + var tools = document.getElementById('tools_'+action); + tools.style.display = 'block'; + var icon = document.getElementById('icon_'+action); + icon.className = 'iconActive'; + + var indicator = document.getElementById('indicator_image'); + indicator.src = 'img/'+action+'.gif'; + + editor.setMode(current_action); + + //constraints on the scale, + //code by Frédéric Klee + if(action == 'scale') + { + var theImage = editor.window.document.getElementById('theImage'); + orginal_width = theImage._width ; + orginal_height = theImage._height; + + var w = document.getElementById('sw'); + w.value = orginal_width ; + var h = document.getElementById('sh') ; + h.value = orginal_height ; + } + if ( action == 'save' ) + { + var formatSelect = document.getElementById('save_format'); + var format = document.getElementById('save_filename').value.match(/\.(gif|png|jpe?g)/i)[1].toLowerCase(); + switch ( format ) + { + case 'png': + formatSelect.selectedIndex = '3'; + break; + case 'gif': + formatSelect.selectedIndex = '4'; + break; + default: + formatSelect.selectedIndex = '0'; + break; + } + formatSelect.onchange(); + } + } +} + +function toggleMarker() +{ + var marker = document.getElementById("markerImg"); + + if(marker != null && marker.src != null) { + if(marker.src.indexOf("t_black.gif") >= 0) + marker.src = "img/t_white.gif"; + else + marker.src = "img/t_black.gif"; + + editor.toggleMarker(); + } +} + +//Togggle constraints, by Frédéric Klee +function toggleConstraints() +{ + var lock = document.getElementById("scaleConstImg"); + var checkbox = document.getElementById("constProp"); + + if(lock != null && lock.src != null) { + if(lock.src.indexOf("unlocked2.gif") >= 0) + { + lock.src = "img/islocked2.gif"; + checkbox.checked = true; + checkConstrains('width'); + + } + else + { + lock.src = "img/unlocked2.gif"; + checkbox.checked = false; + } + } +} + +//check the constraints, by Frédéric Klee +function checkConstrains(changed) +{ + var constrained = document.getElementById('constProp'); + if(constrained.checked) + { + var w = document.getElementById('sw') ; + var width = w.value ; + var h = document.getElementById('sh') ; + var height = h.value ; + + if(orginal_width > 0 && orginal_height > 0) + { + if(changed == 'width' && width > 0) + h.value = parseInt((width/orginal_width)*orginal_height); + else if(changed == 'height' && height > 0) + w.value = parseInt((height/orginal_height)*orginal_width); + } + } + + updateMarker('scale') ; +} + +function updateMarker(mode) +{ + if (mode == 'crop') + { + var t_cx = document.getElementById('cx'); + var t_cy = document.getElementById('cy'); + var t_cw = document.getElementById('cw'); + var t_ch = document.getElementById('ch'); + + editor.setMarker(parseInt(t_cx.value), parseInt(t_cy.value), parseInt(t_cw.value), parseInt(t_ch.value)); + } + else if(mode == 'scale') { + var s_sw = document.getElementById('sw'); + var s_sh = document.getElementById('sh'); + editor.setMarker(0, 0, parseInt(s_sw.value), parseInt(s_sh.value)); + } +} + +function rotateSubActionSelect(selection) +{ + var value = selection.options[selection.selectedIndex].value; + + var rotate_preset_select = document.getElementById('rotate_preset_select'); + var flip = document.getElementById('flip'); + var angle = document.getElementById('ra').parentNode; + + switch (value) + { + case 'rotate': + rotate_preset_select.style.display = ''; + flip.style.display = 'none'; + angle.style.display = ''; + break; + case 'flip': + rotate_preset_select.style.display = 'none'; + flip.style.display = ''; + angle.style.display = 'none'; + break; + } +} +function rotatePreset(selection) +{ + var value = selection.options[selection.selectedIndex].value; + + if(value.length > 0 && parseInt(value) != 0) { + var ra = document.getElementById('ra'); + ra.value = parseInt(value); + } +} + +function updateFormat(selection) +{ + var selected = selection.options[selection.selectedIndex].value; + + var values = selected.split(","); + if ( values[0] != 'jpeg' ) document.getElementById('slider').style.display = 'none'; + else document.getElementById('slider').style.display = 'inline'; + if(values.length >1) { + updateSlider(parseInt(values[1])); + } + +} +function zoom() +{ + var theImage = editor.window.document.getElementById('theImage'); + var value = document.getElementById('zoom').value; + theImage.width = theImage._width * parseInt( value, 10 ) / 100; + theImage.height = theImage._height * parseInt( value, 10 )/ 100; + editor.reset(); + editor.pic_width = null; + editor.pic_height = null; +} +function addEvent(obj, evType, fn) +{ + if (obj.addEventListener) { obj.addEventListener(evType, fn, true); return true; } + else if (obj.attachEvent) { var r = obj.attachEvent("on"+evType, fn); return r; } + else { return false; } +} + +var init = function() +{ + if(window.opener) + { + __xinha_dlg_init(); + __dlg_translate('ExtendedFileManager'); + } + addEvent(window, 'resize', winOnResize); + try { window.moveTo(0,0); } catch (e) {} + window.resizeTo(window.screen.availWidth,window.screen.availHeight); + winOnResize(); +} +function winOnResize () +{ + if ( typeof editor.reset == 'function' && typeof editor.ant != 'undefined' ) editor.reset(); + var win = Xinha.viewportSize(window); + document.getElementById("contents").style.height = win.y - parseInt(document.getElementById("indicator").offsetHeight,10) - 5 + 'px'; +} +Xinha.addOnloadHandler( init, window ); \ No newline at end of file