From: Matous H. <svn...@pl...> - 2008-03-31 17:47:01
|
Author: mhora Date: Mon Mar 31 17:46:57 2008 New Revision: 61760 Added: kss.plugin.cns/trunk/kss/plugin/cns/plugins/dynamicposition.js Modified: kss.plugin.cns/trunk/kss/plugin/cns/plugins/configure.zcml Log: - added dynamicPosition plugin Modified: kss.plugin.cns/trunk/kss/plugin/cns/plugins/configure.zcml ============================================================================== --- kss.plugin.cns/trunk/kss/plugin/cns/plugins/configure.zcml (original) +++ kss.plugin.cns/trunk/kss/plugin/cns/plugins/configure.zcml Mon Mar 31 17:46:57 2008 @@ -41,6 +41,13 @@ params_mandatory="text" jsfile="confirm.js" /> + + <kss:action + name="dynamicPosition" + command_factory="selector" + params_mandatory="position property" + jsfile="dynamicposition.js" + /> <!-- CSS resources --> <browser:resource Added: kss.plugin.cns/trunk/kss/plugin/cns/plugins/dynamicposition.js ============================================================================== --- (empty file) +++ kss.plugin.cns/trunk/kss/plugin/cns/plugins/dynamicposition.js Mon Mar 31 17:46:57 2008 @@ -0,0 +1,39 @@ +/* Set the object into specified place in window no matter on scrollig - IE 6 fix */ +kukit.actionsGlobalRegistry.register("dynamicPosition", function(oper) { + oper.evaluateParameters(['position', 'property'], {}, 'dynamicPosition action'); + + position = oper.parms.position; + property = oper.parms.property; + + if (position == "center") { + if (property == 'Left') { + position = parseInt(document.documentElement.clientWidth) / 2;// - oper.node.clientWidth / 2; + } + else { + position = parseInt(document.documentElement.clientHeight) / 2;// - oper.node.clientHeight / 2; + } + } + else + { + // Suppose a number + position = parseInt(position); + } + position = correctPosition(oper.node, position, property); + oper.node.style[oper.parms.property.toLowerCase()] = parseInt(position)+ "px"; + +}); +kukit.commandsGlobalRegistry.registerFromAction('dynamicPosition', + kukit.cr.makeGlobalCommand); + +function correctPosition(oElement,oPos,oWhich) { + /*while( oElement.offsetParent ) { + oPos -= parseInt(oElement['offset'+oWhich]); + oElement = oElement.offsetParent; + }*/ + oPos += document.documentElement['scroll'+oWhich] ? parseInt(document.documentElement['scroll'+oWhich]) : parseInt(document.body['scroll'+oWhich]); + + //debugger + + //Pos = parseInt(oPos) + parseInt(document.body['scroll'+oWhich]); + return oPos; +} \ No newline at end of file |