From 2c1d9d453404ec2e3344ef477bf834a2a3c065af Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Thu, 6 Feb 2014 16:23:42 +0100 Subject: Implemented basic support for callback events for JUI controls; TJuiDraggable and TJuiDroppable examples --- .../source/prado/activecontrols/ajax3.js | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'framework/Web/Javascripts') diff --git a/framework/Web/Javascripts/source/prado/activecontrols/ajax3.js b/framework/Web/Javascripts/source/prado/activecontrols/ajax3.js index e6616176..98802b0a 100644 --- a/framework/Web/Javascripts/source/prado/activecontrols/ajax3.js +++ b/framework/Web/Javascripts/source/prado/activecontrols/ajax3.js @@ -892,6 +892,44 @@ Prado.Callback = function(UniqueID, parameter, onSuccess, options) return false; }; +/** + * Create a new callback request initiated by jQuery-UI elements. + * @param event object as sent by jQuery-UI events + * @param ui object as sent by jQuery-UI events + * @return boolean always false. + */ +Prado.JuiCallback = function(UniqueID, eventType, event, ui, target) +{ + // Retuns an array of all properties of the object received as parameter and their values. + // If a property represent a jQuery element, its id is returnet instead + var cleanUi = {}; + jQuery.each( ui, function( key, value ) { + if(value instanceof jQuery) + cleanUi[key]=value[0].id; + else + cleanUi[key]=value; + }); + + target=jQuery(target); + cleanUi['target']= { + 'position' : target.position(), + 'offset' : target.offset() + }; + + var callback = + { + 'EventTarget' : UniqueID, + 'CallbackParameter' : { + 'event' : eventType, + 'ui' : cleanUi + }, + }; + + var request = new Prado.CallbackRequest(UniqueID, callback); + request.dispatch(); + return false; +}; + /** * Asset manager classes for lazy loading of scripts and stylesheets * @author Gabor Berczi (gabor.berczi@devworx.hu) -- cgit v1.2.3