// (c) Copyright Microsoft Corporation. // This source is subject to the Microsoft Permissive License. // See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx. // All other rights reserved. /// /// /// /// /// Type.registerNamespace('AjaxControlToolkit'); AjaxControlToolkit.DynamicPopulateBehavior = function(element) { /// /// The DynamicPopulateBehavior replaces the contents of an element with the result of a web service or page method call. The method call returns a string of HTML that is inserted as the children of the target element. /// /// /// DOM Element the behavior is associated with /// AjaxControlToolkit.DynamicPopulateBehavior.initializeBase(this, [element]); this._servicePath = null; this._serviceMethod = null; this._contextKey = null; this._cacheDynamicResults = false; this._populateTriggerID = null; this._setUpdatingCssClass = null; this._clearDuringUpdate = true; this._customScript = null; this._clickHandler = null; this._callID = 0; this._currentCallID = -1; // Whether or not we've already populated (used for cacheDynamicResults) this._populated = false; } AjaxControlToolkit.DynamicPopulateBehavior.prototype = { initialize : function() { /// /// Initialize the behavior /// AjaxControlToolkit.DynamicPopulateBehavior.callBaseMethod(this, 'initialize'); $common.prepareHiddenElementForATDeviceUpdate(); // hook up the trigger if we have one. if (this._populateTriggerID) { var populateTrigger = $get(this._populateTriggerID); if (populateTrigger) { this._clickHandler = Function.createDelegate(this, this._onPopulateTriggerClick); $addHandler(populateTrigger, "click", this._clickHandler); } } }, dispose : function() { /// /// Dispose the behavior /// // clean up the trigger event. if (this._populateTriggerID && this._clickHandler) { var populateTrigger = $get(this._populateTriggerID); if (populateTrigger) { $removeHandler(populateTrigger, "click", this._clickHandler); } this._populateTriggerID = null; this._clickHandler = null; } AjaxControlToolkit.DynamicPopulateBehavior.callBaseMethod(this, 'dispose'); }, populate : function(contextKey) { /// /// Get the dymanic content and use it to populate the target element /// /// /// An arbitrary string value to be passed to the web method. For example, if the element to be /// populated is within a data-bound repeater, this could be the ID of the current row. /// // Don't populate if we already cached the results if (this._populated && this._cacheDynamicResults) { return; } // Initialize the population if this is the very first call if (this._currentCallID == -1) { var eventArgs = new Sys.CancelEventArgs(); this.raisePopulating(eventArgs); if (eventArgs.get_cancel()) { return; } this._setUpdating(true); } // Either run the custom population script or invoke the web service if (this._customScript) { // Call custom javascript call to populate control var scriptResult = eval(this._customScript); this._setTargetHtml(scriptResult); this._setUpdating(false); } else { this._currentCallID = ++this._callID; if (this._servicePath && this._serviceMethod) { Sys.Net.WebServiceProxy.invoke(this._servicePath, this._serviceMethod, false, { contextKey:(contextKey ? contextKey : this._contextKey) }, Function.createDelegate(this, this._onMethodComplete), Function.createDelegate(this, this._onMethodError), this._currentCallID); $common.updateFormToRefreshATDeviceBuffer(); } } }, _onMethodComplete : function (result, userContext, methodName) { /// /// Callback used when the populating service returns successfully /// /// /// The data returned from the Web service method call /// /// /// The context information that was passed when the Web service method was invoked /// /// /// The Web service method that was invoked /// // ignore if it's not the current call. if (userContext != this._currentCallID) return; this._setTargetHtml(result); this._setUpdating(false); }, _onMethodError : function(webServiceError, userContext, methodName) { /// /// Callback used when the populating service fails /// /// /// Web service error /// /// /// The context information that was passed when the Web service method was invoked /// /// /// The Web service method that was invoked /// // ignore if it's not the current call. if (userContext != this._currentCallID) return; if (webServiceError.get_timedOut()) { this._setTargetHtml(AjaxControlToolkit.Resources.DynamicPopulate_WebServiceTimeout); } else { this._setTargetHtml(String.format(AjaxControlToolkit.Resources.DynamicPopulate_WebServiceError, webServiceError.get_statusCode())); } this._setUpdating(false); }, _onPopulateTriggerClick : function() { /// /// Handler for the element described by PopulateTriggerID's click event /// // just call through to the trigger. this.populate(this._contextKey); }, _setUpdating : function(updating) { /// /// Toggle the display elements to indicate if they are being updated or not /// /// /// Whether or not the display should indicated it is being updated /// this.setStyle(updating); if (!updating) { this._currentCallID = -1; this._populated = true; this.raisePopulated(this, Sys.EventArgs.Empty); } }, _setTargetHtml : function(value) { /// /// Populate the target element with the given value /// /// /// The data to populate the target element. /// // Make sure the element is still accessible var e = this.get_element() if (e) { // Use value for input elements; otherwise innerHTML if (e.tagName == "INPUT") { e.value = value; } else { e.innerHTML = value; } } }, setStyle : function(updating) { /// /// Set the style of the display /// /// /// Whether or not the display is being updated /// var e = this.get_element(); if (this._setUpdatingCssClass) { if (!updating) { e.className = this._oldCss; this._oldCss = null; } else { this._oldCss = e.className; e.className = this._setUpdatingCssClass; } } if (updating && this._clearDuringUpdate) { this._setTargetHtml(""); } }, get_ClearContentsDuringUpdate : function() { /// /// Whether the contents of the target should be cleared when an update begins /// return this._clearDuringUpdate; }, set_ClearContentsDuringUpdate : function(value) { if (this._clearDuringUpdate != value) { this._clearDuringUpdate = value; this.raisePropertyChanged('ClearContentsDuringUpdate'); } }, get_ContextKey : function() { /// /// An arbitrary string value to be passed to the web method. /// For example, if the element to be populated is within a /// data-bound repeater, this could be the ID of the current row. /// return this._contextKey; }, set_ContextKey : function(value) { if (this._contextKey != value) { this._contextKey = value; this.raisePropertyChanged('ContextKey'); } }, get_PopulateTriggerID : function() { /// /// Name of an element that triggers the population of the target when clicked /// return this._populateTriggerID; }, set_PopulateTriggerID : function(value) { if (this._populateTriggerID != value) { this._populateTriggerID = value; this.raisePropertyChanged('PopulateTriggerID'); } }, get_ServicePath : function() { /// /// The URL of the web service to call. If the ServicePath is not defined, then we will invoke a PageMethod instead of a web service. /// return this._servicePath; }, set_ServicePath : function(value) { if (this._servicePath != value) { this._servicePath = value; this.raisePropertyChanged('ServicePath'); } }, get_ServiceMethod : function() { /// /// The name of the method to call on the page or web service /// /// /// The signature of the method must exactly match the following: /// [WebMethod] /// string DynamicPopulateMethod(string contextKey) /// { /// ... /// } /// return this._serviceMethod; }, set_ServiceMethod : function(value) { if (this._serviceMethod != value) { this._serviceMethod = value; this.raisePropertyChanged('ServiceMethod'); } }, get_cacheDynamicResults : function() { /// /// Whether the results of the dynamic population should be cached and /// not fetched again after the first load /// return this._cacheDynamicResults; }, set_cacheDynamicResults : function(value) { if (this._cacheDynamicResults != value) { this._cacheDynamicResults = value; this.raisePropertyChanged('cacheDynamicResults'); } }, get_UpdatingCssClass : function() { /// /// The CSS class to apply to the target during asynchronous calls /// return this._setUpdatingCssClass; }, set_UpdatingCssClass : function(value) { if (this._setUpdatingCssClass != value) { this._setUpdatingCssClass = value; this.raisePropertyChanged('UpdatingCssClass'); } }, get_CustomScript : function() { /// /// The script to invoke instead of calling a Web or Page method. This script must evaluate to a string value. /// return this._customScript; }, set_CustomScript : function(value) { if (this._customScript != value) { this._customScript = value; this.raisePropertyChanged('CustomScript'); } }, add_populating : function(handler) { /// /// Add an event handler for the populating event /// /// /// Event handler /// /// this.get_events().addHandler('populating', handler); }, remove_populating : function(handler) { /// /// Remove an event handler from the populating event /// /// /// Event handler /// /// this.get_events().removeHandler('populating', handler); }, raisePopulating : function(eventArgs) { /// /// Raise the populating event /// /// /// Event arguments for the populating event /// /// var handler = this.get_events().getHandler('populating'); if (handler) { handler(this, eventArgs); } }, add_populated : function(handler) { /// /// Add an event handler for the populated event /// /// /// Event handler /// /// this.get_events().addHandler('populated', handler); }, remove_populated : function(handler) { /// /// Remove an event handler from the populated event /// /// /// Event handler /// /// this.get_events().removeHandler('populated', handler); }, raisePopulated : function(eventArgs) { /// /// Raise the populated event /// /// /// Event arguments for the populated event /// /// var handler = this.get_events().getHandler('populated'); if (handler) { handler(this, eventArgs); } } } AjaxControlToolkit.DynamicPopulateBehavior.registerClass('AjaxControlToolkit.DynamicPopulateBehavior', AjaxControlToolkit.BehaviorBase); if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();"scroll",this._windowScrollDelegate); }else{if(this._windowResizeDelegate){$telerik.removeExternalHandler(a,"resize",this._windowResizeDelegate); }this._windowResizeDelegate=null; if(this._windowScrollDelegate){$telerik.removeExternalHandler(a,"scroll",this._windowScrollDelegate); }this._windowScrollDelegate=null; }}}; Telerik.Web.PopupBehavior.registerClass("Telerik.Web.PopupBehavior",Sys.UI.Behavior); Type.registerNamespace("Telerik.Web"); Type.registerNamespace("Telerik.Web.UI"); (function(){var b=$telerik.$; var a=Telerik.Web.UI; a.ResizeExtender=function(g,d,e,i,h,c,j,f){this._document=h?h:document; this._documentMouseMoveDelegate=null; this._documentMouseUpDelegate=null; this._jsOwner=null; this._element=null; this._tableElement=null; this._saveDelegates={}; this._moveCursorType="move"; this._moveToMouseLocation=false; this._hideIframes=true; this._iframeToSkip=null; this._enabled=true; this._startX=0; this._startY=0; this._cancelResize=true; this._startCursorLocation=null; this._autoScrollEnabled=true; this.initialize(g,d,e,i,c,j,f); }; a.ResizeExtender.containsBounds=function(c,d){if(!c||!d){return false; }var g=$telerik.containsPoint(c,d.x,d.y); if(g){var f=d.x+d.width; var e=d.y+d.height; g=$telerik.containsPoint(c,f,e); }return g; }; a.ResizeExtender.prototype={initialize:function(g,f,d,i,c,h,e){if(!f){return; }if(this._element){alert("Element "+f.getAttribute("id")+" cannot be made resizable, as the resizeExtender already has the element "+this._element.getAttribute("id")+" associated with it. You must create a new extender resizer object"); return; }this._jsOwner=g; this._element=f; this._tableElement=i; this._handles=d; if(c){this._moveCursorType=c; }if(h!=null){this._autoScrollEnabled=h; }if(e!=null){this._moveToMouseLocation=e; }this._configureHandleElements(true); },dispose:function(){this._attachDocumentHandlers(false); this._configureHandleElements(false); this._startCursorLocation=null; this._iframeToSkip=null; this._jsOwner=null; this._element=null; this._handles=null; this._saveDelegates=null; this._constraints=null; },enable:function(c){this._enabled=c; },set_hideIframes:function(c){this._hideIframes=c; },get_hideIframes:function(){return this._hideIframes; },set_iframeToSkip:function(c){this._iframeToSkip=c; },get_iframeToSkip:function(){return this._iframeToSkip; },get_constraints:function(){return this._constraints; },set_constraints:function(c){this._constraints=c; },_raiseDragEvent:function(e,g,d){var f=this._jsOwner; if(f&&f["on"+e]){var c=g; if(!c){c={}; }c.element=this._element; c.ownerEvent=d; return f["on"+e](c); }return true; },_raiseEvent:function(d,e){var c=this._jsOwner; if(c&&c["on"+d]){if(!e){e=new Sys.EventArgs(); }else{if(d=="Resize"){e=this._resizeDir; }else{if(d=="Resizing"){e=this._getProposedBounds(e); }}}return c["on"+d](e); }return true; },_getProposedBounds:function(c){var d=$telerik.getBounds(this._element); return{x:c.x||d.x,y:c.y||d.y,width:c.width||d.width,height:c.height||d.height}; },getPositionedParent:function(){var c=this._element.parentNode; while(c&&c!=document){if("static"!=$telerik.getCurrentStyle(c,"position","static")){return c; }c=c.parentNode; }return null; },_storeStartCoords:function(n){if(!this._enabled){return; }this._cancelResize=false; var i=($telerik.isMobileSafari||$telerik.isAndroid); var g=$telerik.getTouchEventLocation(n); this._startX=i?g.x:n.clientX; this._startY=i?g.y:n.clientY; var f=this._element; var d=$telerik.getBounds(f); var p=(f.id!=null&&a.RadDock&&a.RadDock.isInstanceOfType($find(f.id))); if($telerik.isIE&&p!=true){var k=this.getPositionedParent(); if(k){d.x+=k.scrollLeft; d.y+=k.scrollTop; }}this._originalBounds=d; var h=n.target?n.target:n.srcElement; if(h&&h.type==3){h=h.parentNode; }this._resizeType=$telerik.getCurrentStyle(h,"cursor"); if(!this._resizeType&&n.currentTarget){this._resizeType=$telerik.getCurrentStyle(n.currentTarget,"cursor"); }this._resizeDir={north:this._resizeType.match(/n.?-/)?1:0,east:this._resizeType.match(/e-/)?1:0,south:this._resizeType.match(/s.?-/)?1:0,west:this._resizeType.match(/w-/)?1:0,move:new RegExp(this._moveCursorType).test(this._resizeType)?1:0}; this._leftHandleMouseDelta=0; if(this._resizeDir.west){this._leftHandleMouseDelta=Math.abs(d.x-this._startX); }var c=this._resizeDir.move?this._raiseDragEvent("DragStart",null,n):this._raiseEvent("ResizeStart"); this._cancelResize=(c==false); var o=$telerik.getCurrentStyle(f.parentNode,"position"); var j=("relative"==o)||("absolute"==o); this._offsetLocation=j?$telerik.getLocation(f.parentNode):0; if(this._moveToMouseLocation){var l=i?{left:this._startX,top:this._startY}:$telerik.getDocumentRelativeCursorPosition({clientX:this._startX,clientY:this._startY}); if(j){var m=$telerik.getBorderBox(f.parentNode); l.left-=m.left; l.top-=m.top; }this._startCursorLocation={x:l.left-Math.floor(d.width/2),y:l.top-Math.floor(d.height/2)}; }if(!this._cancelResize){this._clearSelection(); this._setIframesVisible(false); this._attachDocumentHandlers(false); this._attachDocumentHandlers(true); }},_resize:function(n){if(!this._enabled||this._cancelResize){return false; }var l=this._originalBounds; var d=new Sys.UI.Bounds(0,0,0,0); var m=($telerik.isMobileSafari||$telerik.isAndroid)?$telerik.getTouchEventLocation(n):{x:n.clientX,y:n.clientY}; var h=m.x-this._startX; var i=m.y-this._startY; var g=this._resizeDir; var j=g.move; if(j){var o=this._startCursorLocation; if(o){l.x=o.x; l.y=o.y; this._originalBounds=l; this._startCursorLocation=null; }d.x=l.x+h; d.y=l.y+i; var c=this._getMoveConstraints(l); if(c){d.x=this._constrainPosition(d.x,c.x,c.width); d.y=this._constrainPosition(d.y,c.y,c.height); }}else{if(g.east){d.x=l.x; d.width=l.width+h; }else{if(g.west){d.x=m.x-this._leftHandleMouseDelta; d.width=l.width-h; }}if(g.south){d.y=l.y; d.height=l.height+i; }else{if(g.north){d.y=l.y+i; d.height=l.height-i; }}var p=this._getSizeConstraints(l); if(p){d.x=this._constrainPosition(d.x,p.x,Math.min(d.x+d.width,p.width-d.width)); d.y=this._constrainPosition(d.y,p.y,Math.min(d.y+d.height,p.height-d.height)); d.width=this._constrainDimension(d.width,p.width-d.x); d.height=this._constrainDimension(d.height,p.height-d.y); }}var q=this._offsetLocation; if(q){d.x-=q.x; d.y-=q.y; }var k=j?this._raiseDragEvent("Drag",d,n):this._raiseEvent("Resizing",d); if(false==k){return true; }var f=this._element; if(j||d.x>0){f.style.left=d.x+"px"; }if(j||d.y>0){f.style.top=d.y+"px"; }if(d.width>0){f.style.width=d.width+"px"; }if(d.height>0){f.style.height=d.height+"px"; }if(!j){this._updateInnerTableSize(); }return true; },_updateInnerTableSize:function(){var d=this._resizeDir; if(d.south||d.north){var e=this._element.style.height; var c=this._tableElement; if(c){c.style.height=e; this._fixIeHeight(c,e); }}},_getMoveConstraints:function(d){var c=this._getSizeConstraints(); if(c){c.width-=d.width; c.height-=d.height; }return c; },_getSizeConstraints:function(f){var d=this._constraints; if(!d){return null; }var e=d.x+this._offsetLocation.x; var c=d.y+this._offsetLocation.y; return new Sys.UI.Bounds(e,c,e+d.width,c+d.height); },_constrainPosition:function(c,d,e){return Math.max(d,Math.min(e,c)); },_constrainDimension:function(d,c){return this._constrainPosition(d,0,c); },_fixIeHeight:function(d,c){if("CSS1Compat"==document.compatMode){var e=(d.offsetHeight-parseInt(c)); if(e>0){var f=(parseInt(d.style.height)-e); if(f>0){d.style.height=f+"px"; }}}},_setIframesVisible:function(e){if(!this.get_hideIframes()){return; }var g=this._document.getElementsByTagName("iframe"); var h=this.get_iframeToSkip(); for(var c=0,j=g.length; c1){return true; }this._storeStartCoords(c); if(!$telerik.isMobileSafari&&!$telerik.isAndroid){return $telerik.cancelRawEvent(c); }},_onDocumentMouseMove:function(d){var c=this._resize(d); if(this._autoScrollEnabled){this._autoScroll(d); }if(c){return $telerik.cancelRawEvent(d); }},_onDocumentMouseUp:function(d){var c=!this._cancelResize; this._cancelResize=true; this._startCursorLocation=null; if(c){this._clearSelection(); this._setIframesVisible(true); if(this._resizeDir&&this._resizeDir.move){this._raiseDragEvent("DragEnd",null,d); }else{this._raiseEvent("ResizeEnd"); }this._attachDocumentHandlers(false); if(this._scroller){this._scroller.set_enabled(false); }}},_clearSelection:function(){if(this._document.selection&&this._document.selection.empty){try{this._document.selection.empty(); }catch(c){}}},_initializeAutoScroll:function(){if(this._autoScrollInitialized){return; }this._scrollEdgeConst=40; this._scrollByConst=10; this._scroller=null; this._scrollDeltaX=0; this._scrollDeltaY=0; this._scrollerTickHandler=Function.createDelegate(this,this._onScrollerTick); this._scroller=new Telerik.Web.Timer(); this._scroller.set_interval(10); this._scroller.add_tick(this._scrollerTickHandler); this._autoScrollInitialized=true; },_autoScroll:function(e){this._initializeAutoScroll(); var d=$telerik.getClientBounds(); if(d.width>0){this._scrollDeltaX=this._scrollDeltaY=0; if(e.clientXd.width-this._scrollEdgeConst){this._scrollDeltaX=this._scrollByConst; }}if(e.clientYd.height-this._scrollEdgeConst){this._scrollDeltaY=this._scrollByConst; }}var c=this._scroller; if(this._scrollDeltaX!=0||this._scrollDeltaY!=0){this._originalStartX=this._startX; this._originalStartY=this._startY; c.set_enabled(true); }else{if(c.get_enabled()){this._startX=this._originalStartX; this._startY=this._originalStartY; }c.set_enabled(false); }}},_onScrollerTick:function(){var e=document.documentElement.scrollLeft||document.body.scrollLeft; var i=document.documentElement.scrollTop||document.body.scrollTop; window.scrollBy(this._scrollDeltaX,this._scrollDeltaY); var k=document.documentElement.scrollLeft||document.body.scrollLeft; var j=document.documentElement.scrollTop||document.body.scrollTop; var h=k-e; var d=j-i; var g=this._element; var f={x:parseInt(g.style.left)+h,y:parseInt(g.style.top)+d}; this._startX-=h; this._startY-=d; try{$telerik.setLocation(g,f); }catch(c){}}}; a.ResizeExtender.registerClass("Telerik.Web.UI.ResizeExtender",null,Sys.IDisposable); })();