Commit inicial Ventas Productivo

This commit is contained in:
JORGE LUIS CAUDILLO ESPARZA
2019-08-14 16:40:54 -07:00
commit c35cf91883
13328 changed files with 3711549 additions and 0 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,376 @@
Type.registerNamespace('Sys.Extended.UI');
Sys.Extended.UI.HorizontalSide = function() {
// The HorizontalSide enumeration describes the horizontal side
// of the window used to anchor the element
throw Error.invalidOperation();
}
Sys.Extended.UI.HorizontalSide.prototype = {
Left: 0,
Center: 1,
Right: 2
}
Sys.Extended.UI.HorizontalSide.registerEnum("Sys.Extended.UI.HorizontalSide", false);
Sys.Extended.UI.VerticalSide = function() {
// The VerticalSide enumeration describes the vertical side
// of the window used to anchor the element
throw Error.invalidOperation();
}
Sys.Extended.UI.VerticalSide.prototype = {
Top: 0,
Middle: 1,
Bottom: 2
}
Sys.Extended.UI.VerticalSide.registerEnum("Sys.Extended.UI.VerticalSide", false);
Sys.Extended.UI.AlwaysVisibleControlBehavior = function(element) {
// The AlwaysVisibleControl behavior is used to fix a particular control a specified distance
// from the top/left corner at all times regardless of how the users scrolls or sizes the window.
Sys.Extended.UI.AlwaysVisibleControlBehavior.initializeBase(this, [element]);
/// <summary>
/// A distance to the horizontal edge of the browser in pixels from the same side of the target control.
/// The default is 0 pixels.
/// </summary>
/// <getter>get_horizontalOffset</getter>
/// <setter>set_horizontalOffset</setter>
/// <member name="cP:AjaxControlToolkit.AlwaysVisibleControlExtender.horizontalOffset" />
this._horizontalOffset = 0;
/// <summary>
/// A horizontal side of the browser to anchor the control against.
/// The default is the Left side.
/// </summary>
/// <getter>get_horizontalSide</getter>
/// <setter>set_horizontalSide</setter>
/// <member name="cP:AjaxControlToolkit.AlwaysVisibleControlExtender.horizontalSide" />
this._horizontalSide = Sys.Extended.UI.HorizontalSide.Left;
/// <summary>
/// A distance to the vertical edge of the browser in pixels from the same side of the target control.
/// The default is 0 pixels.
/// </summary>
/// <getter>get_verticalOffset</getter>
/// <setter>set_verticalOffset</setter>
/// <member name="cP:AjaxControlToolkit.AlwaysVisibleControlExtender.verticalOffset" />
this._verticalOffset = 0;
/// <summary>
/// A vertical side of the browser to anchor the control against.
/// The default is the Top side.
/// </summary>
/// <getter>get_verticalSide</getter>
/// <setter>set_verticalSide</setter>
/// <member name="cP:AjaxControlToolkit.AlwaysVisibleControlExtender.verticalSide" />
this._verticalSide = Sys.Extended.UI.VerticalSide.Top;
/// <summary>
/// Length of the scrolling effectn seconds when the target control is repositioned.
/// The default is 1
/// </summary>
/// <getter>get_scrollEffectDuration</getter>
/// <setter>set_scrollEffectDuration</setter>
/// <member name="cP:AjaxControlToolkit.AlwaysVisibleControlExtender.scrollEffectDuration" />
this._scrollEffectDuration = .1;
// Member variable used to handle the window's scroll and resize events
this._repositionHandler = null;
/// <summary>
/// Whether or not to animate the element's transposition. (note: this value should always be true in IE6).
/// </summary>
/// <getter>get_useAnimation</getter>
/// <setter>set_useAnimation</setter>
/// <member name="cP:AjaxControlToolkit.AlwaysVisibleControlExtender.useAnimation" />
this._animate = false;
// Animation to handle moving the element
this._animation = null;
}
Sys.Extended.UI.AlwaysVisibleControlBehavior.prototype = {
initialize: function() {
Sys.Extended.UI.AlwaysVisibleControlBehavior.callBaseMethod(this, 'initialize');
var element = this.get_element();
if(!element) throw Error.invalidOperation(Sys.Extended.UI.Resources.AlwaysVisible_ElementRequired);
// Create the resposition handler used to place the element
this._repositionHandler = Function.createDelegate(this, this._reposition);
// Determine whether or not to use animations (i.e. whether or not the browser
// supports CSS position: fixed). All major browsers except IE 6 or earlier support it.
// Otherwise we'll only animate if desired.
if(Sys.Browser.agent == Sys.Browser.InternetExplorer && Sys.Browser.version < 7) {
this._animate = true;
}
if(this._animate) {
// Initialize the animations to use the actual properties
this._animation = new Sys.Extended.UI.Animation.MoveAnimation(
element, this._scrollEffectDuration, 25, 0, 0, false, 'px');
// Make the control use absolute positioning to hover
// appropriately and move it to its new home
element.style.position = 'absolute';
} else {
// Make the control use fixed positioning to keep it from moving
// while the content behind it slides around
element.style.position = 'fixed';
}
// Attach the onResize handler
$addHandler(window, 'resize', this._repositionHandler);
// Attach the onscroll event handler for the animations
if(this._animate) {
$addHandler(window, 'scroll', this._repositionHandler);
}
// Move to the initial position
this._reposition();
},
dispose: function() {
// Detach the event and wipe the delegate
if(this._repositionHandler) {
if(this._animate) {
$removeHandler(window, 'scroll', this._repositionHandler);
}
$removeHandler(window, 'resize', this._repositionHandler);
this._repositionHandler = null;
}
// Dispose the animation
if(this._animation) {
this._animation.dispose();
this._animation = null;
}
Sys.Extended.UI.AlwaysVisibleControlBehavior.callBaseMethod(this, 'dispose');
},
_reposition: function(eventObject) {
// Handler to reposition the element and place it where it actually belongs
// whenever the browser is scrolled or resized
var element = this.get_element();
if(!element) return;
this.raise_repositioning(Sys.EventArgs.Empty);
var x = 0;
var y = 0;
// Compute the initial offset if we're animating
if(this._animate) {
if(document.documentElement && document.documentElement.scrollTop) {
x = document.documentElement.scrollLeft;
y = document.documentElement.scrollTop;
} else {
x = document.body.scrollLeft;
y = document.body.scrollTop;
}
}
// Compute the width and height of the client
var clientBounds = $common.getClientBounds();
var width = clientBounds.width;
var height = clientBounds.height;
// Compute the horizontal coordinate
switch(this._horizontalSide) {
case Sys.Extended.UI.HorizontalSide.Center:
x = Math.max(0, Math.floor(x + width / 2.0 - element.offsetWidth / 2.0 - this._horizontalOffset));
break;
case Sys.Extended.UI.HorizontalSide.Right:
x = Math.max(0, x + width - element.offsetWidth - this._horizontalOffset);
break;
case Sys.Extended.UI.HorizontalSide.Left:
default:
x += this._horizontalOffset;
break;
}
// Compute the vertical coordinate
switch(this._verticalSide) {
case Sys.Extended.UI.VerticalSide.Middle:
y = Math.max(0, Math.floor(y + height / 2.0 - element.offsetHeight / 2.0 - this._verticalOffset));
break;
case Sys.Extended.UI.VerticalSide.Bottom:
y = Math.max(0, y + height - element.offsetHeight - this._verticalOffset);
break;
case Sys.Extended.UI.VerticalSide.Top:
default:
y += this._verticalOffset;
break;
}
// Move the element to its new position
if(this._animate && this._animation) {
this._animation.stop();
this._animation.set_horizontal(x);
this._animation.set_vertical(y);
this._animation.play();
} else {
element.style.left = x + 'px';
element.style.top = y + 'px';
}
this.raise_repositioned(Sys.EventArgs.Empty);
},
get_horizontalOffset: function() {
return this._horizontalOffset;
},
get_HorizontalOffset: function() {
Sys.Extended.Deprecated("get_HorizontalOffset()", "get_horizontalOffset()");
return this.get_horizontalOffset();
},
set_horizontalOffset: function(value) {
if(this._horizontalOffset != value) {
this._horizontalOffset = value;
this._reposition();
this.raisePropertyChanged('HorizontalOffset');
}
},
set_HorizontalOffset: function(value) {
Sys.Extended.Deprecated("set_HorizontalOffset(value)", "set_horizontalOffset(value)");
this.set_horizontalOffset(value);
},
get_horizontalSide: function() {
return this._horizontalSide;
},
get_HorizontalSide: function() {
Sys.Extended.Deprecated("get_HorizontalSide()", "get_horizontalSide()");
return this.get_horizontalSide();
},
set_horizontalSide: function(value) {
if(this._horizontalSide != value) {
this._horizontalSide = value;
this._reposition();
this.raisePropertyChanged('HorizontalSide');
}
},
set_HorizontalSide: function(value) {
Sys.Extended.Deprecated("set_HorizontalSide(value)", "set_horizontalSide(value)");
this.set_horizontalSide(value);
},
get_verticalOffset: function() {
return this._verticalOffset;
},
get_VerticalOffset: function() {
Sys.Extended.Deprecated("get_VerticalOffset()", "get_verticalOffset()");
return this.get_verticalOffset();
},
set_verticalOffset: function(value) {
if(this._verticalOffset != value) {
this._verticalOffset = value;
this._reposition();
this.raisePropertyChanged('VerticalOffset');
}
},
set_VerticalOffset: function(value) {
Sys.Extended.Deprecated("set_VerticalOffset(value)", "set_verticalOffset(value)");
this.set_verticalOffset(value);
},
get_verticalSide: function() {
return this._verticalSide;
},
get_VerticalSide: function() {
Sys.Extended.Deprecated("get_VerticalSide()", "get_verticalSide()");
return this.get_verticalSide();
},
set_verticalSide: function(value) {
if(this._verticalSide != value) {
this._verticalSide = value;
this._reposition();
this.raisePropertyChanged('VerticalSide');
}
},
set_VerticalSide: function(value) {
Sys.Extended.Deprecated("set_VerticalSide(value)", "set_verticalSide(value)");
this.set_verticalSide(value);
},
get_scrollEffectDuration: function() {
return this._scrollEffectDuration;
},
get_ScrollEffectDuration: function() {
Sys.Extended.Deprecated("get_ScrollEffectDuration()", "get_scrollEffectDuration");
return this.get_scrollEffectDuration();
},
set_scrollEffectDuration: function(value) {
if(this._scrollEffectDuration != value) {
this._scrollEffectDuration = value;
if(this._animation) {
this._animation.set_duration(value);
}
this.raisePropertyChanged('ScrollEffectDuration');
}
},
set_ScrollEffectDuration: function(value) {
Sys.Extended.Deprecated("set_ScrollEffectDuration(value)", "set_scrollEffectDuration(value)");
this.set_scrollEffectDuration(value);
},
get_useAnimation: function() {
return this._animate;
},
set_useAnimation: function(value) {
value |= (Sys.Browser.agent == Sys.Browser.InternetExplorer && Sys.Browser.version < 7);
if(this._animate != value) {
this._animate = value;
this.raisePropertyChanged('useAnimation');
}
},
/// <summary>
/// Fires before control reposition
/// </summary>
/// <member name="cE:AjaxControlToolkit.AlwaysVisibleControlExtender.repositioning" />
/// <event add="add_repositioning" remove="remove_repositioning" raise="raise_repositioning" />
add_repositioning: function(handler) {
this.get_events().addHandler('repositioning', handler);
},
remove_repositioning: function(handler) {
this.get_events().removeHandler('repositioning', handler);
},
raise_repositioning: function(eventArgs) {
var handler = this.get_events().getHandler('repositioning');
if(handler) {
handler(this, eventArgs);
}
},
raiseRepositioning: function(eventArgs) {
Sys.Extended.Deprecated("raiseRepositioning(eventArgs)", "raise_repositioning(eventArgs)");
this.raise_repositioning(eventArgs);
},
/// <summary>
/// Fires after control reposition
/// </summary>
/// <member name="cE:AjaxControlToolkit.AlwaysVisibleControlExtender.repositioned" />
/// <event add="add_repositioned" remove="remove_repositioned" raise="raise_repositioned" />
add_repositioned: function(handler) {
this.get_events().addHandler('repositioned', handler);
},
remove_repositioned: function(handler) {
this.get_events().removeHandler('repositioned', handler);
},
raise_repositioned: function(eventArgs) {
var handler = this.get_events().getHandler('repositioned');
if(handler) {
handler(this, eventArgs);
}
},
raiseRepositioned: function(eventArgs) {
Sys.Extended.Deprecated("raiseRepositioned(eventArgs)", "raise_repositioned(eventArgs)");
this.raise_repositioned(eventArgs);
}
}
Sys.Extended.UI.AlwaysVisibleControlBehavior.registerClass('Sys.Extended.UI.AlwaysVisibleControlBehavior', Sys.Extended.UI.BehaviorBase);

View File

@@ -0,0 +1,477 @@
Type.registerNamespace('Sys.Extended.UI.Animation');
Sys.Extended.UI.Animation.AnimationBehavior = function(element) {
// The AnimationBehavior allows us to associate animations (described by JSON) with events and
// have them play when the events are fired. It relies heavily on the AJAX Control Toolkit
// animation framework provided in Animation.js, and the GenericAnimationBehavior defined below.
Sys.Extended.UI.Animation.AnimationBehavior.initializeBase(this, [element]);
// Generic animation behaviors that automatically build animations from JSON descriptions
/// <summary>
/// Generic OnLoad Animation's JSON definition.
/// Setting the OnLoad property will cause it to be played immediately
/// </summary>
/// <getter>get_onLoad</getter>
/// <setter>set_onLoad</setter>
/// <member name="cP:AjaxControlToolkit.AnimationExtender.onLoad" />
this._onLoad = null;
/// <summary>
/// Generic OnClick Animation's JSON definition
/// </summary>
/// <getter>get_onClick</getter>
/// <setter>set_onClick</setter>
/// <member name="cP:AjaxControlToolkit.AnimationExtender.onClick" />
this._onClick = null;
/// <summary>
/// Generic OnMouseOver Animation's JSON definition
/// </summary>
/// <getter>get_onMouseOver</getter>
/// <setter>set_onMouseOver</setter>
/// <member name="cP:AjaxControlToolkit.AnimationExtender.onMouseOver" />
this._onMouseOver = null;
/// <summary>
/// Generic OnMouseOut Animation's JSON definition
/// </summary>
/// <getter>get_onMouseOut</getter>
/// <setter>set_onMouseOut</setter>
/// <member name="cP:AjaxControlToolkit.AnimationExtender.onMouseOut" />
this._onMouseOut = null;
/// <summary>
/// Generic OnHoverOver Animation's JSON definition
/// </summary>
/// <getter>get_onHoverOver</getter>
/// <setter>set_onHoverOver</setter>
/// <member name="cP:AjaxControlToolkit.AnimationExtender.onHoverOver" />
this._onHoverOver = null;
/// <summary>
/// Generic OnHoverOut Animation's JSON definition
/// </summary>
/// <getter>get_onHoverOut</getter>
/// <setter>set_onHoverOut</setter>
/// <member name="cP:AjaxControlToolkit.AnimationExtender.onHoverOut" />
this._onHoverOut = null;
// Handlers for the events
this._onClickHandler = null;
this._onMouseOverHandler = null;
this._onMouseOutHandler = null;
}
Sys.Extended.UI.Animation.AnimationBehavior.prototype = {
initialize: function() {
Sys.Extended.UI.Animation.AnimationBehavior.callBaseMethod(this, 'initialize');
// Wireup the event handlers
var element = this.get_element();
if(element) {
this._onClickHandler = Function.createDelegate(this, this.playOnClick);
$addHandler(element, 'click', this._onClickHandler);
this._onMouseOverHandler = Function.createDelegate(this, this.playOnMouseOver);
$addHandler(element, 'mouseover', this._onMouseOverHandler);
this._onMouseOutHandler = Function.createDelegate(this, this.playOnMouseOut);
$addHandler(element, 'mouseout', this._onMouseOutHandler);
}
},
dispose: function() {
// Remove the event handlers
var element = this.get_element();
if(element) {
if(this._onClickHandler) {
$removeHandler(element, 'click', this._onClickHandler);
this._onClickHandler = null;
}
if(this._onMouseOverHandler) {
$removeHandler(element, 'mouseover', this._onMouseOverHandler);
this._onMouseOverHandler = null;
}
if(this._onMouseOutHandler) {
$removeHandler(element, 'mouseout', this._onMouseOutHandler);
this._onMouseOutHandler = null;
}
}
// Wipe the behaviors (we don't need to dispose them because
// that will happen automatically in our base dispose)
this._onLoad = null;
this._onClick = null;
this._onMouseOver = null;
this._onMouseOut = null;
this._onHoverOver = null;
this._onHoverOut = null;
Sys.Extended.UI.Animation.AnimationBehavior.callBaseMethod(this, 'dispose');
},
get_onLoad: function() {
return this._onLoad ? this._onLoad.get_json() : null;
},
get_OnLoad: function() {
Sys.Extended.Deprecated("get_OnLoad()", "get_onLoad()");
return this.get_onLoad();
},
set_onLoad: function(value) {
if(!this._onLoad) {
this._onLoad = new Sys.Extended.UI.Animation.GenericAnimationBehavior(this.get_element());
this._onLoad.initialize();
}
this._onLoad.set_json(value);
this.raisePropertyChanged('OnLoad');
this._onLoad.play();
},
set_OnLoad: function(value) {
Sys.Extended.Deprecated("set_OnLoad(value)", "set_onLoad(value)");
this.set_onLoad(value);
},
/// <summary>
/// Generic OnLoad Animation's behavior
/// </summary>
/// <getter>get_onLoadBehavior</getter>
/// <member name="cP:AjaxControlToolkit.AnimationExtender.onLoadBehavior" />
get_onLoadBehavior: function() {
return this._onLoad;
},
get_OnLoadBehavior: function() {
Sys.Extended.Deprecated("get_OnLoadBehavior()", "get_OnLoadBehavior()");
return this.get_onLoadBehavior();
},
get_onClick: function() {
return this._onClick ? this._onClick.get_json() : null;
},
get_OnClick: function() {
Sys.Extended.Deprecated("get_OnClick()", "get_onClick()");
return this.get_onClick();
},
set_OnClick: function(value) {
Sys.Extended.Deprecated("set_OnClick(value)", "set_onClick(value)");
this.set_onClick(value);
},
set_onClick: function(value) {
if(!this._onClick) {
this._onClick = new Sys.Extended.UI.Animation.GenericAnimationBehavior(this.get_element());
this._onClick.initialize();
}
this._onClick.set_json(value);
this.raisePropertyChanged('OnClick');
},
/// <summary>
/// Generic OnClick Animation's behavior
/// </summary>
/// <getter>get_onClickBehavior</getter>
/// <member name="cP:AjaxControlToolkit.AnimationExtender.onClickBehavior" />
get_onClickBehavior: function() {
return this._onClick;
},
get_OnClickBehavior: function() {
Sys.Extended.Deprecated("get_OnClickBehavior()", "get_onClickBehavior()");
return this.get_onClickBehavior();
},
/// <summary>
/// Plays animation.
/// </summary>
/// <member name="cM:AjaxControlToolkit.AnimationExtender.playOnClick" />
OnClick: function() {
Sys.Extended.Deprecated("OnClick()");
this.playOnClick();
},
playOnClick: function() {
if(this._onClick) {
this._onClick.play();
}
},
get_onMouseOver: function() {
return this._onMouseOver ? this._onMouseOver.get_json() : null;
},
get_OnMouseOver: function() {
Sys.Extended.Deprecated("get_OnMouseOver()", "get_onMouseOver()");
return this.get_onMouseOver();
},
set_onMouseOver: function(value) {
if(!this._onMouseOver) {
this._onMouseOver = new Sys.Extended.UI.Animation.GenericAnimationBehavior(this.get_element());
this._onMouseOver.initialize();
}
this._onMouseOver.set_json(value);
this.raisePropertyChanged('OnMouseOver');
},
set_OnMouseOver: function(value) {
Sys.Extended.Deprecated("set_OnMouseOver(value)", "set_onMouseOver(value)");
this.set_onMouseOver(value);
},
/// <summary>
/// Generic OnMouseOver Animation's behavior
/// </summary>
/// <getter>get_onLoadBehavior</getter>
/// <member name="cP:AjaxControlToolkit.AnimationExtender.onLoadBehavior" />
get_onMouseOverBehavior: function() {
return this._onMouseOver;
},
get_OnMouseOverBehavior: function() {
Sys.Extended.Deprecated("get_OnMouseOverBehavior()", "get_onMouseOverBehavior()");
},
/// <summary>
/// Plays OnMouseOver/OnHoverOver animations
/// </summary>
/// <member name="cM:AjaxControlToolkit.AnimationExtender.playOnMouseOver" />
OnMouseOver: function() {
Sys.Extended.Deprecated("OnMouseOver()");
this.playOnMouseOver();
},
playOnMouseOver: function() {
// Private property to track whether a mouseOver event has already occured, and thus eliminate dups
if(this._mouseHasEntered) {
// This is an additional onMouseOver triggered by child content
return;
}
if(this._onMouseOver) {
this._onMouseOver.play();
}
if(this._onHoverOver) {
if(this._onHoverOut) {
this._onHoverOut.quit();
}
this._onHoverOver.play();
}
this._mouseHasEntered = true;
},
get_onMouseOut: function() {
return this._onMouseOut ? this._onMouseOut.get_json() : null;
},
get_OnMouseOut: function() {
Sys.Extended.Deprecated("get_OnMouseOut()", "get_onMouseOut()");
return this.get_onMouseOut();
},
set_onMouseOut: function(value) {
if(!this._onMouseOut) {
this._onMouseOut = new Sys.Extended.UI.Animation.GenericAnimationBehavior(this.get_element());
this._onMouseOut.initialize();
}
this._onMouseOut.set_json(value);
this.raisePropertyChanged('OnMouseOut');
},
set_OnMouseOut: function(value) {
Sys.Extended.Deprecated("set_OnMouseOut(value)", "set_OnMouseOut(value)");
this.set_onMouseOut(value);
},
/// <summary>
/// Generic OnMouseOut Animation's behavior
/// </summary>
/// <getter>get_onMouseOutBehavior</getter>
/// <member name="cP:AjaxControlToolkit.AnimationExtender.onMouseOutBehavior" />
get_onMouseOutBehavior: function() {
return this._onMouseOut;
},
get_OnMouseOutBehavior: function() {
Sys.Extended.Deprecated("get_OnMouseOutBehavior()", "get_onMouseOutBehavior");
return this.get_onMouseOutBehavior();
},
/// <summary>
/// Plays OnMouseOver/OnHoverOver animations
/// </summary>
/// <member name="cM:AjaxControlToolkit.AnimationExtender.playOnMouseOut" />
OnMouseOut: function(e) {
Sys.Extended.Deprecated("OnMouseOut()");
this.playOnMouseOut();
},
playOnMouseOut: function(e) {
var ev = e.rawEvent;
var pt = this.get_element();
var tg = e.target;
if(tg.nodeName !== pt.nodeName) return;
var rel = ev.relatedTarget || ev.toElement;
if(pt != rel && !this._isChild(pt, rel)) {
this._mouseHasEntered = false;
if(this._onMouseOut) {
this._onMouseOut.play();
}
if(this._onHoverOut) {
if(this._onHoverOver) {
this._onHoverOver.quit();
}
this._onHoverOut.play();
}
}
},
_isChild: function(elmtA, elmtB) {
var body = document.body;
while(elmtB && elmtA != elmtB && body != elmtB) {
try {
elmtB = elmtB.parentNode;
} catch(e) {
// Firefox sometimes fires events for XUL elements, which throws
// a "permission denied" error. so this is not a child.
return false;
}
}
return elmtA == elmtB;
},
get_onHoverOver: function() {
return this._onHoverOver ? this._onHoverOver.get_json() : null;
},
get_OnHoverOver: function() {
Sys.Extended.Deprecated("get_OnHoverOver()", "get_onHoverOver");
return this.get_onHoverOver();
},
set_onHoverOver: function(value) {
if(!this._onHoverOver) {
this._onHoverOver = new Sys.Extended.UI.Animation.GenericAnimationBehavior(this.get_element());
this._onHoverOver.initialize();
}
this._onHoverOver.set_json(value);
this.raisePropertyChanged('OnHoverOver');
},
set_OnHoverOver: function(value) {
Sys.Extended.Deprecated("set_OnHoverOver(value)", "set_OnHoverOver(value)");
this.set_onHoverOver(value);
},
/// <summary>
/// Generic OnHoverOver Animation's behavior
/// </summary>
/// <getter>get_onHoverOverBehavior</getter>
/// <member name="cP:AjaxControlToolkit.AnimationExtender.onHoverOverBehavior" />
get_onHoverOverBehavior: function() {
return this._onHoverOver;
},
get_OnHoverOverBehavior: function() {
Sys.Extended.Deprecated("get_OnHoverOverBehavior()", "get_onHoverOverBehavior()");
return this.get_onHoverOverBehavior();
},
get_onHoverOut: function() {
return this._onHoverOut ? this._onHoverOut.get_json() : null;
},
get_OnHoverOut: function() {
Sys.Extended.Deprecated("get_OnHoverOut()", "get_onHoverOut()");
return this.get_onHoverOut();
},
set_onHoverOut: function(value) {
if(!this._onHoverOut) {
this._onHoverOut = new Sys.Extended.UI.Animation.GenericAnimationBehavior(this.get_element());
this._onHoverOut.initialize();
}
this._onHoverOut.set_json(value);
this.raisePropertyChanged('OnHoverOut');
},
set_OnHoverOut: function(value) {
Sys.Extended.Deprecated("set_OnHoverOut(value)", "set_onHoverOut(value)");
this.set_onHoverOut(value);
},
/// <summary>
/// Generic OnHoverOut Animation's behavior
/// </summary>
/// <getter>get_onHoverOverBehavior</getter>
/// <member name="cP:AjaxControlToolkit.AnimationExtender.onHoverOverBehavior" />
get_onHoverOutBehavior: function() {
return this._onHoverOut;
},
get_OnHoverOutBehavior: function() {
Sys.Extended.Deprecated("get_OnHoverOutBehavior()", "get_onHoverOutBehavior()");
return this.get_onHoverOutBehavior();
}
}
Sys.Extended.UI.Animation.AnimationBehavior.registerClass('Sys.Extended.UI.Animation.AnimationBehavior', Sys.Extended.UI.BehaviorBase);
Sys.Extended.UI.Animation.GenericAnimationBehavior = function(element) {
// The GenericAnimationBehavior handles the creation, playing, and disposing of animations
// created from a JSON description. As we intend to expose a lot of generic animations
// across the Toolkit, this behavior serves to simplify the amount of work required.
Sys.Extended.UI.Animation.GenericAnimationBehavior.initializeBase(this, [element]);
// JSON description of the animation that will be used to create it
this._json = null;
// Animation created from the JSON description that will be played
this._animation = null;
}
Sys.Extended.UI.Animation.GenericAnimationBehavior.prototype = {
dispose: function() {
// Dispose the behavior and its animation
this.disposeAnimation();
Sys.Extended.UI.Animation.GenericAnimationBehavior.callBaseMethod(this, 'dispose');
},
disposeAnimation: function() {
if(this._animation) {
this._animation.dispose();
}
this._animation = null;
},
play: function() {
// Play the animation if it isn't already playing. If it's already playing, this does nothing.
if(this._animation && !this._animation.get_isPlaying()) {
this.stop();
this._animation.play();
}
},
stop: function() {
if(this._animation) {
if(this._animation.get_isPlaying()) {
this._animation.stop(true);
}
}
},
quit: function() {
// Quit playing the animation without updating the final state (i.e. if
// the animation was moving, this would leave it in the middle of its path).
// This differs from the stop function which will update the final state. The
// quit function is most useful for scenarios where you're toggling back and forth
// between two animations (like those used in OnHoverOver/OnHoverOut) and you don't
// want to completely finish one animation if its counterpart is triggered.
if(this._animation) {
if(this._animation.get_isPlaying()) {
this._animation.stop(false);
}
}
},
get_json: function() {
return this._json;
},
set_json: function(value) {
// Only wipe and rebuild if they're changing the value
if(this._json != value) {
this._json = value;
this.raisePropertyChanged('json');
// Build the new animation
this.disposeAnimation();
var element = this.get_element();
if(element) {
this._animation = Sys.Extended.UI.Animation.buildAnimation(this._json, element);
if(this._animation) {
this._animation.initialize();
}
this.raisePropertyChanged('animation');
}
}
},
get_animation: function() {
// Animation created from the JSON description
return this._animation;
}
}
Sys.Extended.UI.Animation.GenericAnimationBehavior.registerClass('Sys.Extended.UI.Animation.GenericAnimationBehavior', Sys.Extended.UI.BehaviorBase);

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,588 @@
Type.registerNamespace("Sys.Extended.UI");
Sys.Extended.UI.AreaChart = function(element) {
Sys.Extended.UI.AreaChart.initializeBase(this, [element]);
var id = this.get_id();
id = id.replace("_ctl00", "");
this._parentDiv = document.getElementById(id + "__ParentDiv");
/// <summary>
/// Whether or not show series values.
/// </summary>
/// <getter>get_displayValues</getter>
/// <setter>set_displayValues</setter>
/// <member name="cP:AjaxControlToolkit.AreaChart.displayValues" />
this._displayValues = true;
/// <summary>
/// Chart width in pixels. Default value is 300
/// </summary>
/// <getter>get_chartWidth</getter>
/// <setter>set_chartWidth</setter>
/// <member name="cP:AjaxControlToolkit.AreaChart.chartWidth" />
this._chartWidth = '300';
/// <summary>
/// Chart height in pixels. Default value is 300
/// </summary>
/// <getter>get_chartHeight</getter>
/// <setter>set_chartHeight</setter>
/// <member name="cP:AjaxControlToolkit.AreaChart.chartHeight" />
this._chartHeight = '300';
/// <summary>
/// A chart title.
/// </summary>
/// <getter>get_chartTitle</getter>
/// <setter>set_chartTitle</setter>
/// <member name="cP:AjaxControlToolkit.AreaChart.chartTitle" />
this._chartTitle = '';
/// <summary>
/// Comma-separated text for each category rendered below X axis
/// </summary>
/// <getter>get_categoriesAxis</getter>
/// <setter>set_categoriesAxis</setter>
/// <member name="cP:AjaxControlToolkit.AreaChart.categoriesAxis" />
this._categoriesAxis = '';
/// <summary>
/// A list of series.
/// </summary>
/// <getter>get_clientSeries</getter>
/// <setter>set_clientSeries</setter>
/// <member name="cP:AjaxControlToolkit.AreaChart.clientSeries" />
this._series = null;
/// <summary>
/// A type of chart. The default value is Basic.
/// </summary>
/// <getter>get_chartType</getter>
/// <setter>set_chartType</setter>
/// <member name="cP:AjaxControlToolkit.AreaChart.chartType" />
this._chartType = Sys.Extended.UI.AreaChartType.Basic;
/// <summary>
/// A CSS file name for AreaChart. The default value is 'AreaChart'.
/// </summary>
/// <getter>get_theme</getter>
/// <setter>set_theme</setter>
/// <member name="cP:AjaxControlToolkit.AreaChart.theme" />
this._theme = 'AreaChart';
/// <summary>
/// Value axis lines count. The default value is 9.
/// </summary>
/// <getter>get_valueAxisLines</getter>
/// <setter>set_valueAxisLines</setter>
/// <member name="cP:AjaxControlToolkit.AreaChart.valueAxisLines" />
this._valueAxisLines = 9;
/// <summary>
/// Color of a chart title.
/// </summary>
/// <getter>get_chartTitleColor</getter>
/// <setter>set_chartTitleColor</setter>
/// <member name="cP:AjaxControlToolkit.AreaChart.chartTitleColor" />
this._chartTitleColor = '';
/// <summary>
/// Color of a value axis line.
/// </summary>
/// <getter>get_valueAxisLineColor</getter>
/// <setter>set_valueAxisLineColor</setter>
/// <member name="cP:AjaxControlToolkit.AreaChart.valueAxisLineColor" />
this._valueAxisLineColor = '';
/// <summary>
/// Color of a category axis line.
/// </summary>
/// <getter>get_categoryAxisLineColor</getter>
/// <setter>set_categoryAxisLineColor</setter>
/// <member name="cP:AjaxControlToolkit.AreaChart.categoryAxisLineColor" />
this._categoryAxisLineColor = '';
/// <summary>
/// Color of a base line.
/// </summary>
/// <getter>get_baseLineColor</getter>
/// <setter>set_baseLineColor</setter>
/// <member name="cP:AjaxControlToolkit.AreaChart.baseLineColor" />
this._baseLineColor = '';
// variables
this.yMax = 0;
this.yMin = 0;
this.roundedTickRange = 0;
this.startX = 0;
this.startY = 0;
this.endX = 0;
this.endY = 0;
this.xInterval = 0;
this.yInterval = 0;
this.arrXAxis;
this.arrXAxisLength = 0;
this.charLength = 3.5;
this.arrCombinedData = null;
}
Sys.Extended.UI.AreaChart.prototype = {
initialize: function() {
Sys.Extended.UI.AreaChart.callBaseMethod(this, "initialize");
if(!document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#Image", "1.1")) {
throw 'Current version of browser does not support SVG.'
}
if(this._valueAxisLines == 0) {
this._valueAxisLines = 9;
}
this.generateAreaChart();
},
dispose: function() {
Sys.Extended.UI.AreaChart.callBaseMethod(this, "dispose");
},
/// <summary>
/// Generates the AreaChart with the specified values
/// </summary>
/// <member name="cM:AjaxControlToolkit.AreaChart.generateAreaChart" />
generateAreaChart: function() {
this.arrXAxis = this._categoriesAxis.split(',');
this.arrXAxisLength = this.arrXAxis.length;
this.calculateMinMaxValues();
this.calculateInterval();
this.calculateValueAxis();
var svgContents = this.initializeSVG();
svgContents = svgContents + String.format('<text x="{0}" y="{1}" id="ChartTitle" style="fill:{3}">{2}</text>', parseInt(this._chartWidth) / 2 - (this._chartTitle.length * this.charLength), parseInt(this._chartHeight) * 5 / 100, this._chartTitle, this._chartTitleColor);
svgContents = svgContents + this.drawBackgroundHorizontalLines();
svgContents = svgContents + this.drawBackgroundVerticalLines();
svgContents = svgContents + this.drawBaseLines();
svgContents = svgContents + this.drawLegendArea();
svgContents = svgContents + this.drawAxisValues();
this._parentDiv.innerHTML = svgContents;
this.drawAreas();
},
// Calculates distance interval for the value axis.
calculateInterval: function() {
this.startX = (this._chartWidth * 10 / 100) + 0.5;
this.endX = parseInt(this._chartWidth) - 4.5;
if(this.yMin >= 0)
this.startY = Math.round(parseInt(this._chartHeight) - (parseInt(this._chartHeight) * 24 / 100)) + 0.5;
else
this.startY = Math.round(parseInt(this._chartHeight) - (parseInt(this._chartHeight) * 12 / 100)) / 2 + 0.5;
this.yInterval = this.startY / (this._valueAxisLines + 1);
},
calculateMinMaxValues: function() {
var seriesMax;
var seriesMin;
var arrData;
if(this._chartType == Sys.Extended.UI.AreaChartType.Basic) {
for(var i = 0; i < this._series.length; i++) {
arrData = this._series[i].Data;
seriesMax = Math.max.apply(null, arrData);
seriesMin = Math.min.apply(null, arrData);
if(i == 0) {
this.yMax = seriesMax;
this.yMin = seriesMin;
}
else {
if(seriesMax > this.yMax)
this.yMax = seriesMax;
if(seriesMin < this.yMin)
this.yMin = seriesMin;
}
}
}
else {
for(var i = 0; i < this._series.length; i++) {
arrData = new Array();
for(var j = 0; j < this._series[i].Data.length; j++) {
arrData[j] = this._series[i].Data[j];
}
if(this.arrCombinedData == null)
this.arrCombinedData = arrData;
else {
for(j = 0; j < arrData.length; j++) {
this.arrCombinedData[j] = parseFloat(this.arrCombinedData[j]) + parseFloat(arrData[j]);
}
}
}
for(var i = 0; i < this._series.length; i++) {
seriesMin = Math.min.apply(null, this._series[i].Data);
if(i == 0) {
this.yMin = seriesMin;
}
else {
if(seriesMin < this.yMin)
this.yMin = seriesMin;
}
}
this.yMax = Math.max.apply(null, this.arrCombinedData);
}
if(this.yMin < 0) {
this._valueAxisLines = Math.round(this._valueAxisLines / 2);
}
},
// Calculates label values for Value axis to display on the chart.
calculateValueAxis: function() {
var range;
var unroundedTickSize;
var x;
var pow10x;
if(this.yMin >= 0) {
range = this.yMax;
}
else {
range = this.yMax > Math.abs(this.yMin) ? this.yMax : Math.abs(this.yMin);
}
unroundedTickSize = range / (this._valueAxisLines - 1);
if(unroundedTickSize < 1) {
this.roundedTickRange = unroundedTickSize.toFixed(1);
}
else {
x = Math.ceil((Math.log(unroundedTickSize) / Math.log(10)) - 1);
pow10x = Math.pow(10, x);
this.roundedTickRange = Math.ceil(unroundedTickSize / pow10x) * pow10x;
}
this.startX = this.startX + (this.roundedTickRange * 10 * this._valueAxisLines / 10).toString().length * this.charLength;
},
drawBackgroundHorizontalLines: function() {
var horizontalLineContents = '';
// background grid's horizontal lines
for(var i = 1; i <= this._valueAxisLines; i++) {
horizontalLineContents = horizontalLineContents + String.format('<path d="M{0} {2} {1} {2}" id="HorizontalLine" style="stroke:{3}"></path>', this.startX, this.endX, this.startY - (this.yInterval * i), this._categoryAxisLineColor);
}
if(this.yMin < 0) {
// background grid's horizontal lines for negative values
for(var i = 1; i <= this._valueAxisLines; i++) {
horizontalLineContents = horizontalLineContents + String.format('<path d="M{0} {2} {1} {2}" id="HorizontalLine" style="stroke:{3}"></path>', this.startX, this.endX, this.startY + (this.yInterval * i), this._categoryAxisLineColor);
}
}
return horizontalLineContents;
},
drawBackgroundVerticalLines: function() {
// background grid's vertical lines
var verticalLineContents = '';
this.xInterval = Math.round((parseInt(this._chartWidth) - this.startX) / this.arrXAxisLength);
for(var i = 0; i < this.arrXAxisLength; i++) {
verticalLineContents = verticalLineContents + String.format('<path id="VerticalLine" d="M{0} {1} {0} {2}" style="stroke:{3}"></path>', ((parseInt(this._chartWidth) - 5) - (this.xInterval * i)), (this.startY - (this.yInterval * this._valueAxisLines)), this.startY, this._valueAxisLineColor);
}
if(this.yMin < 0) {
for(var i = 0; i < this.arrXAxisLength; i++) {
verticalLineContents = verticalLineContents + String.format('<path id="VerticalLine" d="M{0} {1} {0} {2}" style="stroke:{3}"></path>', ((parseInt(this._chartWidth) - 5) - (this.xInterval * i)), (this.startY + (this.yInterval * this._valueAxisLines)), this.startY, this._valueAxisLineColor);
}
}
return verticalLineContents;
},
drawBaseLines: function() {
var baseLineContents = '';
baseLineContents = baseLineContents + String.format('<path d="M{0} {1} {2} {1}" id="BaseLine" style="stroke:{3}"></path>', this.startX, this.startY, this.endX, this._baseLineColor);
baseLineContents = baseLineContents + String.format('<path d="M{0} {1} {0} {2}" id="BaseLine" style="stroke:{3}"></path>', this.startX, (this.startY - (this.yInterval * this._valueAxisLines)), this.startY, this._baseLineColor);
baseLineContents = baseLineContents + String.format('<path d="M{0} {1} {0} {2}" id="BaseLine" style="stroke:{3}"></path>', this.startX, this.startY, this.startY + 4, this._baseLineColor);
for(var i = 0; i < this.arrXAxisLength; i++) {
baseLineContents = baseLineContents + String.format('<path d="M{0} {1} {0} {2}" id="BaseLine" style="stroke:{3}"></path>', ((parseInt(this._chartWidth) - 5) - (this.xInterval * i)), this.startY, this.startY + 4, this._baseLineColor);
}
for(var i = 0; i <= this._valueAxisLines; i++) {
baseLineContents = baseLineContents + String.format('<path d="M{0} {2} {1} {2}" id="BaseLine" style="stroke:{3}"></path>', this.startX - 4, this.startX, this.startY - (this.yInterval * i), this._baseLineColor);
}
if(this.yMin < 0) {
baseLineContents = baseLineContents + String.format('<path d="M{0} {1} {0} {2}" id="BaseLine" style="stroke:{3}"></path>', this.startX, (this.startY + (this.yInterval * this._valueAxisLines)), this.startY, this._baseLineColor);
for(var i = 1; i <= this._valueAxisLines; i++) {
baseLineContents = baseLineContents + String.format('<path d="M{0} {2} {1} {2}" id="BaseLine" style="stroke:{3}"></path>', this.startX - 4, this.startX, this.startY + (this.yInterval * i), this._baseLineColor);
}
}
return baseLineContents;
},
drawLegendArea: function() {
var legendContents = '';
// Legend Area
var legendAreaStartHeight = (parseInt(this._chartHeight) * 82 / 100) + 5;
var legendBoxWidth = 7.5;
var legendBoxHeight = 7.5;
var spaceInLegendContents = 5;
// Get length of text to display in legend
var legendCharLength = 0;
for(var i = 0; i < this._series.length; i++) {
legendCharLength = legendCharLength + this._series[i].Name.length;
}
var legendAreaWidth = Math.round((legendCharLength * 5) / 2) + Math.round((legendBoxWidth + (spaceInLegendContents * 2)) * this._series.length);
var isLegendNextLine = false;
if(legendAreaWidth > parseInt(this._chartWidth) / 2) {
legendAreaWidth = legendAreaWidth / 2;
isLegendNextLine = true;
}
legendContents = legendContents + '<g>';
legendContents = legendContents + String.format('<path d="M{0} {1} {2} {1} {2} {3} {0} {3} z" id="LegendArea" stroke=""></path>', parseInt(this._chartWidth) * 50 / 100 - (legendAreaWidth / 2), legendAreaStartHeight, Math.round(parseInt(this._chartWidth) * 50 / 100 + (legendCharLength * 5)) + Math.round((legendBoxWidth + (spaceInLegendContents * 2)) * this._series.length), Math.round(parseInt(this._chartHeight) * 97.5 / 100));
var startText = parseInt(this._chartWidth) * 40 / 100 - (legendAreaWidth / 2) + legendBoxWidth + spaceInLegendContents;
var nextStartText = startText;
var startLegend = parseInt(this._chartWidth) * 40 / 100 - (legendAreaWidth / 2);
var nextStartLegend = startLegend;
for(var i = 0; i < this._series.length; i++) {
if(isLegendNextLine && i == Math.round(this._series.length / 2)) {
startText = parseInt(this._chartWidth) * 40 / 100 - (legendAreaWidth / 2) + legendBoxWidth + spaceInLegendContents;
nextStartText = startText;
startLegend = parseInt(this._chartWidth) * 40 / 100 - (legendAreaWidth / 2);
nextStartLegend = startLegend;
legendAreaStartHeight = (parseInt(this._chartHeight) * 89 / 100) + 5;
isLegendNextLine = false;
}
startLegend = nextStartLegend;
startText = nextStartText;
legendContents = legendContents + String.format('<path d="M{0} {1} {2} {1} {2} {3} {0} {3} z" id="Legend{4}" style="fill:{5}"></path>', startLegend, legendAreaStartHeight + legendBoxHeight, startLegend + legendBoxWidth, legendAreaStartHeight + 15, i + 1, this._series[i].AreaColor);
legendContents = legendContents + String.format('<text x="{0}" y="{1}" id="LegendText">{2}</text>', startText, legendAreaStartHeight + 15, this._series[i].Name);
if(this._series[i].Name.length > 10) {
nextStartLegend = startLegend + (this._series[i].Name.length * 5) + legendBoxWidth + (spaceInLegendContents * 2);
nextStartText = startText + (this._series[i].Name.length * 5) + legendBoxWidth + (spaceInLegendContents * 2);
}
else {
nextStartLegend = nextStartLegend + (this._series[i].Name.length * 6) + legendBoxWidth + (spaceInLegendContents * 2);
nextStartText = nextStartText + (this._series[i].Name.length * 6) + legendBoxWidth + (spaceInLegendContents * 2);
}
}
legendContents = legendContents + '</g>';
return legendContents;
},
drawAxisValues: function() {
var axisContents = '';
var textLength = 0;
for(var i = 0; i < this.arrXAxisLength; i++) {
textLength = (this.arrXAxis[i].toString().length * 10 * i / 10).toString().length * 5.5;
axisContents = axisContents + String.format('<text id="SeriesAxis" x="{0}" y="{1}" fill-opacity="1">{2}</text>', Math.round(this.startX + (this.xInterval * 10 * i / 10) + (this.xInterval * 50 / 100) - textLength), this.startY + Math.round(this.yInterval * 65 / 100), this.arrXAxis[i]);
}
for(var i = 0; i <= this._valueAxisLines; i++) {
textLength = (this.roundedTickRange * 10 * i / 10).toString().length * 5.5;
axisContents = axisContents + String.format('<text id="ValueAxis" x="{0}" y="{1}">{2}</text>', this.startX - textLength - 15, this.startY - (this.yInterval * 10 * i / 10) + 3.5, this.roundedTickRange * 10 * i / 10);
}
if(this.yMin < 0) {
for(var i = 1; i <= this._valueAxisLines; i++) {
textLength = (this.roundedTickRange * 10 * i / 10).toString().length * 5.5;
axisContents = axisContents + String.format('<text id="ValueAxis" x="{0}" y="{1}">-{2}</text>', this.startX - textLength - 19, this.startY + (this.yInterval * 10 * i / 10), this.roundedTickRange * 10 * i / 10);
}
}
return axisContents;
},
initializeSVG: function() {
var svgContents = String.format('<?xml-stylesheet type="text/css" href="{0}.css"?>', this._theme);
svgContents = svgContents + String.format('<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="{0}" height="{1}" style="position: relative; display: block;">', this._chartWidth, this._chartHeight);
svgContents = svgContents + '<defs>';
svgContents = svgContents + '<linearGradient gradientTransform="rotate(0)">';
svgContents = svgContents + '<stop offset="0%" id="LinearGradient1"></stop>';
svgContents = svgContents + '<stop offset="25%" id="LinearGradient2"></stop>';
svgContents = svgContents + '<stop offset="100%" id="LinearGradient3"></stop></linearGradient>';
svgContents = svgContents + '</defs>';
svgContents = svgContents + String.format('<path fill="none" stroke-opacity="1" fill-opacity="1" stroke-linejoin="round" stroke-linecap="square" d="M5 {0} {1} {0} {1} {2} 5 {2} z"></path>', parseInt(this._chartHeight) * 1 / 10 + 5, parseInt(this._chartWidth) - 5, parseInt(this._chartHeight) - parseInt(this._chartHeight) * 1 / 10);
svgContents = svgContents + String.format('<path id="ChartBackGround" stroke="" d="M0 0 {0} 0 {0} {1} 0 {1} z"></path>', this._chartWidth, this._chartHeight);
svgContents = svgContents + String.format('<path fill="#ffffff" stroke-opacity="1" fill-opacity="0" stroke-linejoin="round" stroke-linecap="square" stroke="" d="M5 {0} {1} {0} {1} {2} 5 {2} z"></path>', parseInt(this._chartHeight) * 1 / 10 + 5, parseInt(this._chartWidth) - 5, parseInt(this._chartHeight) - parseInt(this._chartHeight) * 1 / 10);
return svgContents;
},
drawAreas: function () {
var displayValues = this.get_displayValues();
var areaContents = '';
// Area section
var yVal = new Array();
var lastStartX = new Array();
var lastStartY = new Array();
var areaPath = new Array();
for(var i = 0; i < this.arrXAxisLength; i++) {
for(var j = 0; j < this._series.length; j++) {
yVal[j] = 0;
if(this._chartType == Sys.Extended.UI.AreaChartType.Stacked) {
for(var k = 0; k <= j; k++) {
yVal[j] = parseFloat(yVal[j]) + parseFloat(this._series[k].Data[i]);
}
} else {
yVal[j] = parseFloat(this._series[j].Data[i]);
}
if(i == 0) {
areaPath[j] = String.format('{0} {1} {0} {2} ', this.startX + (this.xInterval / 2), this.startY, this.startY - Math.round(yVal[j] * (this.yInterval / this.roundedTickRange)));
}
else if(i == this.arrXAxisLength - 1) {
areaPath[j] = areaPath[j] + String.format('{0} {1} {2} {3} {2} {4} ', lastStartX[j], lastStartY[j], this.startX + (this.xInterval * i) + (this.xInterval / 2), this.startY - Math.round(yVal[j] * (this.yInterval / this.roundedTickRange)), this.startY);
}
else {
areaPath[j] = areaPath[j] + String.format('{0} {1} ', this.startX + (this.xInterval * i) + (this.xInterval / 2), this.startY - Math.round(yVal[j] * (this.yInterval / this.roundedTickRange)));
}
if(yVal[j] > 0)
areaContents = areaContents + String.format('<text id="LegendText" x="{0}" y="{1}">{2}</text>', this.startX + (this.xInterval * i) + (this.xInterval * 50 / 100) - yVal[j].toString().length * this.charLength, this.startY - Math.round(yVal[j] * (this.yInterval / this.roundedTickRange)) - 7.5, displayValues ? yVal[j] : "");
else
areaContents = areaContents + String.format('<text id="LegendText" x="{0}" y="{1}">{2}</text>', this.startX + (this.xInterval * i) + (this.xInterval * 50 / 100) - yVal[j].toString().length * this.charLength, this.startY - Math.round(yVal[j] * (this.yInterval / this.roundedTickRange)) + 7.5, displayValues ? yVal[j] : "");
lastStartX[j] = this.startX + (this.xInterval * i) + (this.xInterval / 2);
lastStartY[j] = this.startY - Math.round(yVal[j] * (this.yInterval / this.roundedTickRange));
}
}
this._parentDiv.innerHTML = this._parentDiv.innerHTML + areaContents;
var svgContentsBeforeAnimation = this._parentDiv.innerHTML;
this._drawArea(areaPath, 0);
},
_drawArea: function(areaPath, seriesIndex) {
var self = this;
self._parentDiv.innerHTML = self._parentDiv.innerHTML.replace('</svg>', '') + String.format('<g><path id="AreaPath{1}" d="M{0} z" style="fill:{2};stroke:{2}"></path></g></svg>', areaPath[seriesIndex], seriesIndex + 1, self._series[seriesIndex].AreaColor);
seriesIndex++;
if(seriesIndex < self._series.length) {
setTimeout(function() {
self._drawArea(areaPath, seriesIndex);
}, 400);
}
},
drawArea: function(me, areaPath, seriesIndex) {
Sys.Extended.Deprecated("drawArea(me, areaPath, seriesIndex)");
this._drawArea(areaPath, seriesIndex);
},
get_displayValues: function () {
return this._displayValues;
},
set_displayValues: function (value) {
this._displayValues = value;
},
get_chartWidth: function() {
return this._chartWidth;
},
set_chartWidth: function(value) {
this._chartWidth = value;
},
get_chartHeight: function() {
return this._chartHeight;
},
set_chartHeight: function(value) {
this._chartHeight = value;
},
get_chartTitle: function() {
return this._chartTitle;
},
set_chartTitle: function(value) {
this._chartTitle = value;
},
get_categoriesAxis: function() {
return this._categoriesAxis;
},
set_categoriesAxis: function(value) {
this._categoriesAxis = value;
},
get_clientSeries: function() {
return this._series;
},
get_ClientSeries: function() {
Sys.Extended.Deprecated("get_ClientSeries()", "get_clientSeries()");
return this.get_clientSeries();
},
set_clientSeries: function(value) {
this._series = value;
},
set_ClientSeries: function(value) {
Sys.Extended.Deprecated("set_ClientSeries(value)", "set_clientSeries(value)");
this.set_clientSeries(value);
},
get_chartType: function() {
return this._chartType;
},
set_chartType: function(value) {
this._chartType = value;
},
get_theme: function() {
return this._theme;
},
set_theme: function(value) {
this._theme = value;
},
get_valueAxisLines: function() {
return this._valueAxisLines;
},
set_valueAxisLines: function(value) {
this._valueAxisLines = value;
},
get_chartTitleColor: function() {
return this._chartTitleColor;
},
set_chartTitleColor: function(value) {
this._chartTitleColor = value;
},
get_valueAxisLineColor: function() {
return this._valueAxisLineColor;
},
set_valueAxisLineColor: function(value) {
this._valueAxisLineColor = value;
},
get_categoryAxisLineColor: function() {
return this._categoryAxisLineColor;
},
set_categoryAxisLineColor: function(value) {
this._categoryAxisLineColor = value;
},
get_baseLineColor: function() {
return this._baseLineColor;
},
set_baseLineColor: function(value) {
this._baseLineColor = value;
}
};
Sys.Extended.UI.AreaChart.registerClass("Sys.Extended.UI.AreaChart", Sys.Extended.UI.ControlBase);
Sys.Extended.UI.AreaChartType = function() {
throw Error.invalidOperation();
}
Sys.Extended.UI.AreaChartType.prototype = {
Basic: 0,
Stacked: 1
}
Sys.Extended.UI.AreaChartType.registerEnum("Sys.Extended.UI.AreaChartType", false);

View File

@@ -0,0 +1,574 @@
Type.registerNamespace("Sys.Extended.UI");
Sys.Extended.UI.AsyncFileUpload = function(element) {
Sys.Extended.UI.AsyncFileUpload.initializeBase(this, [element]);
/// <summary>
/// Stores the file path.
/// </summary>
/// <getter>get_hiddenField</getter>
/// <setter>set_hiddenField</setter>
/// <member name="cP:AjaxControlToolkit.AsyncFileUpload.hiddenField" />
this._hiddenField = null;
/// <summary>
/// Inputs an element with type='file'.
/// </summary>
/// <getter>get_inputFile</getter>
/// <setter>set_inputFile</setter>
/// <member name="cP:AjaxControlToolkit.AsyncFileUpload.inputFile" />
this._inputFile = null;
/// <summary>
/// An inner throbber.
/// </summary>
/// <getter>get_innerTB</getter>
/// <setter>set_innerTB</setter>
/// <member name="cP:AjaxControlToolkit.AsyncFileUpload.innerTB" />
this._innerTB = null;
/// <summary>
/// Url that receives posted data relative to the form.
/// </summary>
/// <getter>get_postBackUrl</getter>
/// <setter>set_postBackUrl</setter>
/// <member name="cP:AjaxControlToolkit.AsyncFileUpload.postBackUrl" />
this._postBackUrl = "";
/// <summary>
/// A name of the form.
/// </summary>
/// <getter>get_postBackUrl</getter>
/// <setter>set_postBackUrl</setter>
/// <member name="cP:AjaxControlToolkit.AsyncFileUpload.postBackUrl" />
this._formName = "";
this._iframe = null;
this._waitTimer = null;
/// <summary>
/// The control's background color on upload complete. The default value - 'Lime'.
/// </summary>
/// <getter>get_completeBackColor</getter>
/// <setter>set_completeBackColor</setter>
/// <member name="cP:AjaxControlToolkit.AsyncFileUpload.completeBackColor" />
this._completeBackColor = "";
/// <summary>
/// The control's background color when uploading is in progress. The default value - 'White'.
/// </summary>
/// <getter>get_uploadingBackColor</getter>
/// <setter>set_uploadingBackColor</setter>
/// <member name="cP:AjaxControlToolkit.AsyncFileUpload.uploadingBackColor" />
this._uploadingBackColor = "";
/// <summary>
/// The control's background color on upload error. The default value - 'Red'.
/// </summary>
/// <getter>get_errorBackColor</getter>
/// <setter>set_errorBackColor</setter>
/// <member name="cP:AjaxControlToolkit.AsyncFileUpload.errorBackColor" />
this._errorBackColor = "";
/// <summary>
/// The control that is shown while the file is being uploaded.
/// </summary>
/// <getter>get_throbber</getter>
/// <setter>set_throbber</setter>
/// <member name="cP:AjaxControlToolkit.AsyncFileUpload.throbber" />
this._throbber = null;
this._onchange$delegate = null;
this._onload$delegate = null;
this._app_onload$delegate = Function.createDelegate(this, this._app_onload);
this._onmouseup$delegate = null;
}
Sys.Extended.UI.AsyncFileUpload.prototype = {
get_throbber: function() {
return this._throbber;
},
set_throbber: function(value) {
this._throbber = value;
},
get_completeBackColor: function() {
return this._completeBackColor;
},
set_completeBackColor: function(value) {
this._completeBackColor = value;
},
get_errorBackColor: function() {
return this._errorBackColor;
},
set_errorBackColor: function(value) {
this._errorBackColor = value;
},
get_uploadingBackColor: function() {
return this._uploadingBackColor;
},
set_uploadingBackColor: function(value) {
this._uploadingBackColor = value;
},
get_inputFile: function() {
return this._inputFile;
},
set_inputFile: function(value) {
this._inputFile = value;
},
get_hiddenField: function() {
return this._hiddenField;
},
set_hiddenField: function(value) {
this._hiddenField = value;
},
get_innerTB: function() {
return this._innerTB;
},
set_innerTB: function(value) {
this._innerTB = value;
},
get_postBackUrl: function() {
return this._postBackUrl;
},
set_postBackUrl: function(value) {
this._postBackUrl = value;
},
/// <summary>
/// Name of the form
/// </summary>
/// <getter>get_formName</getter>
/// <setter>set_formName</setter>
/// <member name="cP:AjaxControlToolkit.AsyncFileUpload.formName" />
get_formName: function() {
return this._formName;
},
set_formName: function(value) {
this._formName = value;
},
/// <summary>
/// Occurs when file uploading starts.
/// </summary>
/// <event add="add_uploadStarted" remove="remove_uploadStarted" raise="raise_uploadStarted" />
/// <member name="cE:AjaxControlToolkit.AsyncFileUpload.uploadStarted" />
add_uploadStarted: function(handler) {
this.get_events().addHandler("uploadStarted", handler);
},
remove_uploadStarted: function(handler) {
this.get_events().removeHandler("uploadStarted", handler);
},
raise_uploadStarted: function (e) {
var eh = this.get_events().getHandler("uploadStarted");
if (eh) {
return eh(this, e);
}
return true;
},
raiseUploadStarted: function(e) {
Sys.Extended.Deprecated("raiseUploadStarted(e)", "raise_uploadStarted(e)");
return this.raise_uploadStarted(e);
},
/// <summary>
/// Occurs when file uploading is completed.
/// </summary>
/// <event add="add_uploadComplete" remove="remove_uploadComplete" raise="raise_uploadComplete" />
/// <member name="cE:AjaxControlToolkit.AsyncFileUpload.uploadComplete" />
add_uploadComplete: function(handler) {
this.get_events().addHandler("uploadComplete", handler);
},
remove_uploadComplete: function(handler) {
this.get_events().removeHandler("uploadComplete", handler);
},
raise_uploadComplete: function(e) {
var eh = this.get_events().getHandler("uploadComplete");
if(eh) {
eh(this, e);
}
},
raiseUploadComplete: function (e) {
Sys.Extended.Deprecated("raiseUploadComplete(e)", "raise_uploadComplete(e)");
return this.raise_uploadComplete(e);
},
/// <summary>
/// Fires when file uploading encounters an error
/// </summary>
/// <event add="add_uploadError" remove="remove_uploadError" raise="raise_uploadError" />
/// <member name="cE:AjaxControlToolkit.AsyncFileUpload.uploadError" />
add_uploadError: function(handler) {
this.get_events().addHandler("uploadError", handler);
},
remove_uploadError: function(handler) {
this.get_events().removeHandler("uploadError", handler);
},
raise_uploadError: function(e) {
var eh = this.get_events().getHandler("uploadError");
if(eh) {
eh(this, e);
return true;
}
return false;
},
raiseUploadError: function (e) {
Sys.Extended.Deprecated("raiseUploadError(e)", "raise_uploadError(e)");
return this.raise_uploadError(e);
},
/// <summary>
/// Set throbber visual style
/// </summary>
/// <param name="value" type="String">Visual style value</param>
/// <member name="cM:AjaxControlToolkit.AsyncFileUpload.setThrobber" />
setThrobber: function(value) {
if(this.get_throbber() != null) {
this.get_throbber().style.display = value ? "" : "none";
}
},
_onStart: function(fileName) {
var valid = this.raise_uploadStarted(new Sys.Extended.UI.AsyncFileUploadEventArgs(fileName, null, null, null));
if(typeof valid == 'undefined') {
valid = true;
}
return valid;
},
// Initialize of AsyncFileUpload.
initialize: function() {
Sys.Extended.UI.AsyncFileUpload.callBaseMethod(this, "initialize");
Sys.Application.add_load(this._app_onload$delegate);
this._iframeName = this.get_element().id + "_iframe";
this.setThrobber(false);
},
// Dispose of AsyncFileUpload.
dispose: function() {
Sys.Application.remove_load(this._app_onload$delegate);
if(this._onchange$delegate != null) {
$common.removeHandlers(this._inputFile, {
change: this._onchange$delegate
});
this._onchange$delegate = null;
}
if(this._onmouseup$delegate != null) {
$common.removeHandlers(this._inputFile, {
mouseup: this._onmouseup$delegate
});
this._onmouseup$delegate = null;
}
this._removeIframe();
Sys.Extended.UI.AsyncFileUpload.callBaseMethod(this, "dispose");
},
_onmouseup: function() {
var inputFile = this._inputFile;
setTimeout(function() { inputFile.blur(); }, 0);
return true;
},
_app_onload: function(sender, e) {
this.setThrobber(false);
if(this._inputFile != null) {
if(this._onchange$delegate == null) {
this._onchange$delegate = Function.createDelegate(this, this._onchange);
$addHandlers(this._inputFile, {
change: this._onchange$delegate
});
}
if(this._innerTB != null) {
this._inputFile.blur();
var inputFile = this._inputFile;
setTimeout(function() { inputFile.blur(); }, 0);
this._innerTB.style.width = (this._inputFile.offsetWidth - 107) + "px";
this._inputFile.parentNode.style.width = this._inputFile.offsetWidth + "px";
if(Sys.Browser.agent == Sys.Browser.InternetExplorer) {
this._onmouseup$delegate = Function.createDelegate(this, this._onmouseup);
$addHandlers(this._inputFile, {
mouseup: this._onmouseup$delegate
});
}
}
}
},
_removeIframe: function() {
this._removeTimer();
if(this._iframe != null) {
if(this._onload$delegate != null) {
$common.removeHandlers(this._iframe, {
load: this._onload$delegate
});
this._onload$delegate = null;
}
document.body.removeChild(this._iframe);
this._iframe = null;
}
},
_removeTimer: function() {
if(this._waitTimer != null) {
window.clearTimeout(this._waitTimer);
this._waitTimer = null;
}
},
_onError: function(error) {
var unhandledException = Sys.Extended.UI.Resources.AsyncFileUpload_UnhandledException;
this.setThrobber(false);
if(this.get_errorBackColor() != "") {
if(this._innerTB != null) {
this._innerTB.style.backgroundColor = this.get_errorBackColor();
} else {
this._inputFile.style.backgroundColor = this.get_errorBackColor();
}
}
if(!this.raise_uploadError(new Sys.Extended.UI.AsyncFileUploadEventArgs(this._inputFile.value, null, null, error))) {
alert(unhandledException + ": " + error);
}
},
_onchange: function(e) {
var value = this._inputFile.value;
if(value == "") {
return;
}
if(this._innerTB != null) {
this._innerTB.value = value;
}
if(this._hiddenField != null) {
this._hiddenField.value = value;
}
try {
if(this._iframe == null) {
this._onload$delegate = Function.createDelegate(this, this._onload);
var iframe = document.createElement("IFRAME");
iframe.width = "0";
iframe.height = "0";
iframe.style.display = "none";
iframe.src = "about:blank";
iframe.id = this._iframeName;
iframe.name = this._iframeName;
$addHandlers(iframe, {
load: this._onload$delegate
});
this._iframe = iframe;
document.body.appendChild(this._iframe);
iframe.contentWindow.name = this._iframeName;
} else {
this._removeIframe();
var internalErrorMessage = Sys.Extended.UI.Resources.AsyncFileUpload_InternalErrorMessage;
this._onError(internalErrorMessage);
}
} catch(ex) {
this._onError(ex.message);
}
},
_stopLoad: function(result) {
var mainForm = document.getElementById(this._formName);
this._removeTimer();
this.setThrobber(false);
mainForm.target = "_top";
mainForm.action = this._postBackUrl;
var length;
var contentType = "";
var temp = result.split("------");
if(temp.length > 0) {
if(temp[0] == "error") {
this._onError(temp[1]);
return;
}
length = parseInt(temp[0]);
}
if(temp.length > 1) {
contentType = temp[1];
}
if(this.get_completeBackColor() != "") {
if(this._innerTB != null) {
this._innerTB.style.backgroundColor = this.get_completeBackColor();
} else {
this._inputFile.style.backgroundColor = this.get_completeBackColor();
}
}
this.raise_uploadComplete(new Sys.Extended.UI.AsyncFileUploadEventArgs(this._inputFile.value, length, contentType, null));
},
_onload: function(e) {
var cleanup = true;
var uploader = this;
var mainForm = document.getElementById(this._formName);
try {
var frameDocument = this._iframe.contentWindow.document;
if(frameDocument == null || frameDocument.location == null) {
var e = { "message": Sys.Extended.UI.Resources.AsyncFileUpload_UploadingProblem };
throw (e);
} else if(frameDocument.location.href == 'about:blank') {
this._removeTimer();
if(this.get_uploadingBackColor() != "") {
if(this._innerTB != null) {
this._innerTB.style.backgroundColor = this.get_uploadingBackColor();
} else {
this._inputFile.style.backgroundColor = this.get_uploadingBackColor();
}
}
var valid = this._onStart(this._inputFile.value);
if(valid) {
var url = this._postBackUrl;
url += url.indexOf("?") === -1 ? "?" : "&";
mainForm.action = url + 'AsyncFileUploadID=' + this.get_element().id + '&rnd=' + Math.random().toString().replace(/\./g, "");
mainForm.target = this._iframeName;
cleanup = false;
this.setThrobber(true);
setTimeout(function() {
mainForm.submit();
uploader._waitTimer = setTimeout(function() { uploader._wait() }, 100);
}, 0);
return true;
}
} else {
//----------------------------------------
if(frameDocument.body.innerHTML == "") {
return true;
}
// if (this._waitTimer == null) {
// setTimeout(function() { uploader._removeIframe(); }, 100);
// return true;
// }
//----------------------------------------
var result = frameDocument.getElementById(this.get_element().id);
var length;
var contentType = "";
if(result != null) {
var temp = result.innerHTML.split("------");
if(temp.length > 0) {
if(temp[0] == "error") {
var e = { "message": temp[1] };
throw (e);
}
length = parseInt(temp[0]);
}
if(temp.length > 1) {
contentType = temp[1];
}
} else {
var serverError = Sys.Extended.UI.Resources.AsyncFileUpload_UnknownServerError;
function replace_func(p0, p1) {
serverError = p1;
return "";
}
frameDocument.body.innerHTML.replace(/Exception\]:([^\n\r]+)[\n\r]/, replace_func);
var exMessage = Sys.Extended.UI.Resources.AsyncFileUpload_ServerResponseError + ": '" + serverError + "'";
var ret = confirm(exMessage + "\n\n" + Sys.Extended.UI.Resources.AsyncFileUpload_ConfirmToSeeErrorPage);
if(ret) {
var handle = window.open("", "NotFoundInAnswer", "toolbar=0,status=1,scrollbars=1,resizable=1,width=600,height=400");
function onOpen() {
try {
if(!handle.document)
setTimeout(onOpen, 100);
}
catch(e) { return; }
var _doc = handle.document;
_doc.open();
_doc.write("<body>" + frameDocument.body.innerHTML + "</body>");
_doc.close();
}
setTimeout(onOpen, 0);
}
var e = { "message": exMessage };
throw (e);
}
this._removeTimer();
mainForm.target = "_top";
mainForm.action = this._postBackUrl;
if(this.get_completeBackColor() != "") {
if(this._innerTB != null) {
this._innerTB.style.backgroundColor = this.get_completeBackColor();
} else {
this._inputFile.style.backgroundColor = this.get_completeBackColor();
}
}
this.setThrobber(false);
this.raise_uploadComplete(new Sys.Extended.UI.AsyncFileUploadEventArgs(this._inputFile.value, length, contentType, null));
}
}
catch(ex) {
this._removeTimer();
mainForm.target = "_top";
mainForm.action = this._postBackUrl;
this._onError(ex.message);
}
finally {
if(cleanup) {
setTimeout(function() { uploader._removeIframe(); }, 100);
}
}
},
_wait: function() {
if(this._waitTimer == null) {
return;
}
var uploader = this;
try {
var frameDocument = this._iframe.contentWindow.document;
var location = frameDocument.location;
var href = location.href;
this._waitTimer = setTimeout(function() { uploader._wait() }, 100);
} catch(ex) {
setTimeout(function() { uploader._removeIframe(); }, 100);
setTimeout(function() { uploader._onError(Sys.Extended.UI.Resources.AsyncFileUpload_UploadingProblem); }, 0);
this._waitTimer = null;
}
}
}
Sys.Extended.UI.AsyncFileUpload.registerClass("Sys.Extended.UI.AsyncFileUpload", Sys.Extended.UI.ControlBase);
Sys.Extended.UI.AsyncFileUploadEventArgs = function(fileName, length, contentType, errorMessage) {
if(arguments.length != 4) throw Error.parameterCount();
//Calling the base class constructor
Sys.Extended.UI.AsyncFileUploadEventArgs.initializeBase(this);
this._fileName = fileName;
this._length = length;
this._contentType = contentType;
this._errorMessage = errorMessage;
}
Sys.Extended.UI.AsyncFileUploadEventArgs.prototype =
{
get_fileName: function() {
var slashPos = this._fileName.lastIndexOf("/");
var backSlashPos = this._fileName.lastIndexOf("\\");
var fileName = this._fileName.substr(((slashPos > backSlashPos) ? slashPos : backSlashPos) + 1);
return fileName;
},
get_path: function() {
return this._fileName;
},
get_length: function() {
return this._length;
},
get_contentType: function() {
return this._contentType;
},
get_errorMessage: function() {
return this._errorMessage;
}
}
Sys.Extended.UI.AsyncFileUploadEventArgs.registerClass('Sys.Extended.UI.AsyncFileUploadEventArgs', Sys.EventArgs);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,858 @@
Type.registerNamespace("Sys.Extended.UI");
Sys.Extended.UI.BarChart = function(element) {
Sys.Extended.UI.BarChart.initializeBase(this, [element]);
var id = this.get_id();
id = id.replace("_ctl00", "");
this._parentDiv = document.getElementById(id + "__ParentDiv");
this._chartWidth = '300';
this._chartHeight = '200';
this._chartTitle = '';
this._categoriesAxis = '';
this._series = null;
this._chartType = Sys.Extended.UI.BarChartType.Column;
this._theme = 'BarChart';
this._valueAxisLines = 9;
this._chartTitleColor = '';
this._valueAxisLineColor = '';
this._categoryAxisLineColor = '';
this._baseLineColor = '';
// variables
this.yMax = 0;
this.yMin = 0;
this.xMax = 0;
this.xMin = 0;
this.roundedTickRange = 0;
this.startX = 0;
this.startY = 0;
this.endX = 0;
this.endY = 0;
this.xInterval = 0;
this.yInterval = 0;
this.arrXAxis;
this.arrXAxisLength = 0;
this.arrYAxis;
this.arrYAxisLength = 0;
this.charLength = 3.5;
this.arrCombinedData = null;
}
Sys.Extended.UI.BarChart.prototype = {
initialize: function() {
Sys.Extended.UI.BarChart.callBaseMethod(this, "initialize");
if(!document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#Image", "1.1")) {
throw 'Browser does not support SVG.';
}
if(this._valueAxisLines == 0) {
this._valueAxisLines = 9;
}
if(this._chartType == Sys.Extended.UI.BarChartType.Column || this._chartType == Sys.Extended.UI.BarChartType.StackedColumn)
this.generateColumnChart();
else if(this._chartType == Sys.Extended.UI.BarChartType.Bar || this._chartType == Sys.Extended.UI.BarChartType.StackedBar)
this.generateBarChart();
},
dispose: function() {
Sys.Extended.UI.BarChart.callBaseMethod(this, "dispose");
},
generateColumnChart: function() {
this.arrXAxis = this._categoriesAxis.split(',');
this.arrXAxisLength = this.arrXAxis.length;
this.calculateMinMaxValuesForColumnType();
this.calculateIntervalForColumnType();
this.calculateValueAxisForColumnType();
var svgContents = this.initializeSVG();
svgContents = svgContents + String.format('<text x="{0}" y="{1}" id="ChartTitle" style="fill:{3}">{2}</text>', parseInt(this._chartWidth) / 2 - (this._chartTitle.length * this.charLength), parseInt(this._chartHeight) * 5 / 100, this._chartTitle, this._chartTitleColor);
svgContents = svgContents + this.drawBackgroundHorizontalLinesForColumnType();
svgContents = svgContents + this.drawBackgroundVerticalLinesForColumnType();
svgContents = svgContents + this.drawBaseLinesForColumnType();
svgContents = svgContents + this.drawLegendArea();
svgContents = svgContents + this.drawAxisValuesForColumnType();
svgContents = svgContents + this.drawBarsForColumnType();
svgContents = svgContents + '</svg>';
this._parentDiv.innerHTML = svgContents;
},
// This calculates distance interval for the value axis.
calculateIntervalForColumnType: function() {
this.startX = (this._chartWidth * 10 / 100) + 0.5;
this.endX = parseInt(this._chartWidth) - 4.5;
if(this.yMin >= 0)
this.startY = Math.round(parseInt(this._chartHeight) - (parseInt(this._chartHeight) * 24 / 100)) + 0.5;
else
this.startY = Math.round(parseInt(this._chartHeight) - (parseInt(this._chartHeight) * 12 / 100)) / 2 + 0.5;
this.yInterval = this.startY / (this._valueAxisLines + 1);
},
// This calculates minimum and maximum values of the specified data.
calculateMinMaxValuesForColumnType: function(chartType) {
// calculate minimum and maximum value
var seriesMax;
var seriesMin;
var arrData;
if(this._chartType == Sys.Extended.UI.BarChartType.Column) {
for(var i = 0; i < this._series.length; i++) {
arrData = this._series[i].Data;
seriesMax = Math.max.apply(null, arrData);
seriesMin = Math.min.apply(null, arrData);
if(i == 0) {
this.yMax = seriesMax;
this.yMin = seriesMin;
}
else {
if(seriesMax > this.yMax)
this.yMax = seriesMax;
if(seriesMin < this.yMin)
this.yMin = seriesMin;
}
}
}
else {
this.arrCombinedData = null;
for(var i = 0; i < this._series.length; i++) {
arrData = new Array();
for(var j = 0; j < this._series[i].Data.length; j++) {
arrData[j] = this._series[i].Data[j];
}
if(this.arrCombinedData == null)
this.arrCombinedData = arrData;
else {
for(var j = 0; j < arrData.length; j++) {
this.arrCombinedData[j] = parseFloat(this.arrCombinedData[j]) + parseFloat(arrData[j]);
}
}
}
for(var i = 0; i < this._series.length; i++) {
seriesMin = Math.min.apply(null, this._series[i].Data);
if(i == 0) {
this.yMin = seriesMin;
}
else {
if(seriesMin < this.yMin)
this.yMin = seriesMin;
}
}
this.yMax = Math.max.apply(null, this.arrCombinedData);
}
if(this.yMin < 0) {
this._valueAxisLines = Math.round(this._valueAxisLines / 2);
}
},
// this calculates label values for Value axis to display on the chart.
calculateValueAxisForColumnType: function() {
// calculate value axis labels
var range;
var unroundedTickSize;
var x;
var pow10x;
if(this.yMin >= 0) {
range = this.yMax;
}
else {
range = this.yMax > Math.abs(this.yMin) ? this.yMax : Math.abs(this.yMin);
}
unroundedTickSize = range / (this._valueAxisLines - 1);
if(unroundedTickSize < 1) {
this.roundedTickRange = unroundedTickSize.toFixed(1);
}
else {
x = Math.ceil((Math.log(unroundedTickSize) / Math.log(10)) - 1);
pow10x = Math.pow(10, x);
this.roundedTickRange = Math.ceil(unroundedTickSize / pow10x) * pow10x;
}
this.startX = this.startX + (this.roundedTickRange * 10 * this._valueAxisLines / 10).toString().length * this.charLength;
},
// This draws background horizontal lines of the chart.
drawBackgroundHorizontalLinesForColumnType: function() {
var horizontalLineContents = '';
// background grid's horizontal lines
for(var i = 1; i <= this._valueAxisLines; i++) {
horizontalLineContents = horizontalLineContents + String.format('<path d="M{0} {2} {1} {2}" id="HorizontalLine" style="stroke:{3}"></path>', this.startX, this.endX, this.startY - (this.yInterval * i), this._categoryAxisLineColor);
}
if(this.yMin < 0) {
// background grid's horizontal lines for negative values
for(var i = 1; i <= this._valueAxisLines; i++) {
horizontalLineContents = horizontalLineContents + String.format('<path d="M{0} {2} {1} {2}" id="HorizontalLine" style="stroke:{3}"></path>', this.startX, this.endX, this.startY + (this.yInterval * i), this._categoryAxisLineColor);
}
}
return horizontalLineContents;
},
// This draws background vertical lines of the chart.
drawBackgroundVerticalLinesForColumnType: function() {
// background grid's vertical lines
var verticalLineContents = '';
this.xInterval = Math.round((parseInt(this._chartWidth) - this.startX) / this.arrXAxisLength);
for(var i = 0; i < this.arrXAxisLength; i++) {
verticalLineContents = verticalLineContents + String.format('<path id="VerticalLine" d="M{0} {1} {0} {2}" style="stroke:{3}"></path>', ((parseInt(this._chartWidth) - 5) - (this.xInterval * i)), (this.startY - (this.yInterval * this._valueAxisLines)), this.startY, this._valueAxisLineColor);
}
if(this.yMin < 0) {
for(var i = 0; i < this.arrXAxisLength; i++) {
verticalLineContents = verticalLineContents + String.format('<path id="VerticalLine" d="M{0} {1} {0} {2}" style="stroke:{3}"></path>', ((parseInt(this._chartWidth) - 5) - (this.xInterval * i)), (this.startY + (this.yInterval * this._valueAxisLines)), this.startY, this._valueAxisLineColor);
}
}
return verticalLineContents;
},
// This draws base lines of the chart.
drawBaseLinesForColumnType: function() {
var baseLineContents = '';
baseLineContents = baseLineContents + String.format('<path d="M{0} {1} {2} {1}" id="BaseLine" style="stroke:{3}"></path>', this.startX, this.startY, this.endX, this._baseLineColor);
baseLineContents = baseLineContents + String.format('<path d="M{0} {1} {0} {2}" id="BaseLine" style="stroke:{3}"></path>', this.startX, (this.startY - (this.yInterval * this._valueAxisLines)), this.startY, this._baseLineColor);
baseLineContents = baseLineContents + String.format('<path d="M{0} {1} {0} {2}" id="BaseLine" style="stroke:{3}"></path>', this.startX, this.startY, this.startY + 4, this._baseLineColor);
for(var i = 0; i < this.arrXAxisLength; i++) {
baseLineContents = baseLineContents + String.format('<path d="M{0} {1} {0} {2}" id="BaseLine" style="stroke:{3}"></path>', ((parseInt(this._chartWidth) - 5) - (this.xInterval * i)), this.startY, this.startY + 4, this._baseLineColor);
}
for(var i = 0; i <= this._valueAxisLines; i++) {
baseLineContents = baseLineContents + String.format('<path d="M{0} {2} {1} {2}" id="BaseLine" style="stroke:{3}"></path>', this.startX - 4, this.startX, this.startY - (this.yInterval * i), this._baseLineColor);
}
if(this.yMin < 0) {
baseLineContents = baseLineContents + String.format('<path d="M{0} {1} {0} {2}" id="BaseLine" style="stroke:{3}"></path>', this.startX, (this.startY + (this.yInterval * this._valueAxisLines)), this.startY, this._baseLineColor);
for(var i = 1; i <= this._valueAxisLines; i++) {
baseLineContents = baseLineContents + String.format('<path d="M{0} {2} {1} {2}" id="BaseLine" style="stroke:{3}"></path>', this.startX - 4, this.startX, this.startY + (this.yInterval * i), this._baseLineColor);
}
}
return baseLineContents;
},
// This writes horizontal and vertical axis values of the chart.
drawAxisValuesForColumnType: function() {
var axisContents = '';
var textLength = 0;
for(var i = 0; i < this.arrXAxisLength; i++) {
textLength = this.arrXAxis[i].toString().length * 5.5;
axisContents = axisContents + String.format('<text id="SeriesAxis" x="{0}" y="{1}" fill-opacity="1">{2}</text>', Math.round(this.startX + (this.xInterval * 10 * i / 10) + (this.xInterval * 50 / 100) - (textLength)), this.startY + Math.round(this.yInterval * 65 / 100), this.arrXAxis[i]);
}
for(var i = 0; i <= this._valueAxisLines; i++) {
textLength = (this.roundedTickRange * 10 * i / 10).toString().length * 5.5;
axisContents = axisContents + String.format('<text id="ValueAxis" x="{0}" y="{1}">{2}</text>', this.startX - textLength - 15, this.startY - (this.yInterval * 10 * i / 10) + 3.5, this.roundedTickRange * 10 * i / 10);
}
if(this.yMin < 0) {
for(var i = 1; i <= this._valueAxisLines; i++) {
textLength = (this.roundedTickRange * 10 * i / 10).toString().length * 5.5;
axisContents = axisContents + String.format('<text id="ValueAxis" x="{0}" y="{1}">-{2}</text>', this.startX - textLength - 19, this.startY + (this.yInterval * 10 * i / 10), this.roundedTickRange * 10 * i / 10);
}
}
return axisContents;
},
drawBarsForColumnType: function() {
// Bars section
var barContents = '';
var numberOfBars = this._series.length;
var widthBetweenBars = this.xInterval * 10 / 100;
var barWidth;
if(this._chartType == Sys.Extended.UI.BarChartType.Column) {
barWidth = Math.round(((this.xInterval * 80 / 100) - (widthBetweenBars * numberOfBars)) / numberOfBars);
}
else {
barWidth = Math.round(this.xInterval * 80 / 100);
}
var barColor = '';
for(var i = 0; i < this.arrXAxisLength; i++) {
barContents = barContents + '<g>';
if(this._chartType == Sys.Extended.UI.BarChartType.Column) {
for(var j = 0; j < this._series.length; j++) {
this.yVal = parseFloat(this._series[j].Data[i]);
if(i == 0) {
barContents = barContents + String.format('<path id="Bar{4}" style="fill:{5}" d="M{0} {2} {1} {2} {1} {3} {0} {3} z" />', this.startX + (this.xInterval * i) + (this.xInterval * 15 / 100) + ((widthBetweenBars + barWidth) * j), this.startX + (this.xInterval * i) + (this.xInterval * 15 / 100) + ((widthBetweenBars + barWidth) * j) + barWidth, this.startY, this.startY - Math.round(this.yVal * (this.yInterval / this.roundedTickRange)), j + 1, this._series[j].BarColor);
}
else {
barContents = barContents + String.format('<path id="Bar{4}" style="fill:{5}" d="M{0} {2} {1} {2} {1} {3} {0} {3} z" />', this.startX + (this.xInterval * i) + (this.xInterval * 12.5 / 100) + ((widthBetweenBars + barWidth) * j), this.startX + (this.xInterval * i) + (this.xInterval * 12.5 / 100) + ((widthBetweenBars + barWidth) * j) + barWidth, this.startY, this.startY - Math.round(this.yVal * (this.yInterval / this.roundedTickRange)), j + 1, this._series[j].BarColor);
}
if(this.yVal > 0)
barContents = barContents + String.format('<text id="LegendText" x="{0}" y="{1}">{2}</text>', this.startX + (this.xInterval * i) + (this.xInterval * 20 / 100) + ((widthBetweenBars + barWidth) * j) + (barWidth * 10 / 100) - Math.round((this.yVal.toString().length * this.charLength) / 2), this.startY - Math.round(this.yVal * (this.yInterval / this.roundedTickRange)) - 7.5, this.yVal);
else
barContents = barContents + String.format('<text id="LegendText" x="{0}" y="{1}">{2}</text>', this.startX + (this.xInterval * i) + (this.xInterval * 20 / 100) + ((widthBetweenBars + barWidth) * j) + (barWidth * 10 / 100) - Math.round((this.yVal.toString().length * this.charLength) / 2), this.startY - Math.round(this.yVal * (this.yInterval / this.roundedTickRange)) + 7.5, this.yVal);
}
}
else {
var lastStartYPositive = this.startY;
var lastStartYNegative = this.startY;
for(var j = 0; j < this._series.length; j++) {
this.yVal = parseFloat(this._series[j].Data[i]);
if(i == 0) {
if(this.yVal > 0)
barContents = barContents + String.format('<path id="Bar{4}" style="fill:{5}" d="M{0} {2} {1} {2} {1} {3} {0} {3} z" />', this.startX + (this.xInterval * 10 * i / 10) + (this.xInterval * 7.5 / 100), this.startX + (this.xInterval * 10 * i / 10) + (this.xInterval * 7.5 / 100) + barWidth, lastStartYPositive, lastStartYPositive - Math.round(this.yVal * (this.yInterval / this.roundedTickRange)), j + 1, this._series[j].BarColor);
else
barContents = barContents + String.format('<path id="Bar{4}" style="fill:{5}" d="M{0} {2} {1} {2} {1} {3} {0} {3} z" />', this.startX + (this.xInterval * 10 * i / 10) + (this.xInterval * 7.5 / 100), this.startX + (this.xInterval * 10 * i / 10) + (this.xInterval * 7.5 / 100) + barWidth, lastStartYNegative, lastStartYNegative - Math.round(this.yVal * (this.yInterval / this.roundedTickRange)), j + 1, this._series[j].BarColor);
}
else {
if(this.yVal > 0)
barContents = barContents + String.format('<path id="Bar{4}" style="fill:{5}" d="M{0} {2} {1} {2} {1} {3} {0} {3} z" />', this.startX + (this.xInterval * 10 * i / 10) + (this.xInterval * 5 / 100), this.startX + (this.xInterval * 10 * i / 10) + (this.xInterval * 5 / 100) + barWidth, lastStartYPositive, lastStartYPositive - Math.round(this.yVal * (this.yInterval / this.roundedTickRange)), j + 1, this._series[j].BarColor);
else
barContents = barContents + String.format('<path id="Bar{4}" style="fill:{5}" d="M{0} {2} {1} {2} {1} {3} {0} {3} z" />', this.startX + (this.xInterval * 10 * i / 10) + (this.xInterval * 5 / 100), this.startX + (this.xInterval * 10 * i / 10) + (this.xInterval * 5 / 100) + barWidth, lastStartYNegative, lastStartYNegative - Math.round(this.yVal * (this.yInterval / this.roundedTickRange)), j + 1, this._series[j].BarColor);
}
if(this.yVal > 0) {
barContents = barContents + String.format('<text id="LegendText" x="{0}" y="{1}">{2}</text>', this.startX + (this.xInterval * 10 * i / 10) + (this.xInterval * 30 / 100) + (barWidth * 10 / 100), lastStartYPositive - Math.round((this.yVal * (this.yInterval / this.roundedTickRange)) / 2), this.yVal);
lastStartYPositive = lastStartYPositive - Math.round(this.yVal * (this.yInterval / this.roundedTickRange));
}
else {
barContents = barContents + String.format('<text id="LegendText" x="{0}" y="{1}">{2}</text>', this.startX + (this.xInterval * 10 * i / 10) + (this.xInterval * 30 / 100) + (barWidth * 10 / 100), lastStartYNegative + Math.round((Math.abs(this.yVal) * (this.yInterval / this.roundedTickRange)) / 2), this.yVal);
lastStartYNegative = lastStartYNegative - Math.round(this.yVal * (this.yInterval / this.roundedTickRange));
}
}
}
barContents = barContents + '</g>';
}
return barContents;
},
// This creates svg and its initial contents.
initializeSVG: function() {
var svgContents = String.format('<?xml-stylesheet type="text/css" href="{0}.css"?>', this._theme);
svgContents = svgContents + String.format('<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="{0}" height="{1}" style="position: relative; display: block;">', this._chartWidth, this._chartHeight);
svgContents = svgContents + '<defs>';
svgContents = svgContents + '<linearGradient gradientTransform="rotate(0)">';
svgContents = svgContents + '<stop offset="0%" id="LinearGradient1"></stop>';
svgContents = svgContents + '<stop offset="25%" id="LinearGradient2"></stop>';
svgContents = svgContents + '<stop offset="100%" id="LinearGradient3"></stop></linearGradient>';
svgContents = svgContents + '</defs>';
svgContents = svgContents + String.format('<path fill="none" stroke-opacity="1" fill-opacity="1" stroke-linejoin="round" stroke-linecap="square" d="M5 {0} {1} {0} {1} {2} 5 {2} z"/>', parseInt(this._chartHeight) * 1 / 10 + 5, parseInt(this._chartWidth) - 5, parseInt(this._chartHeight) - parseInt(this._chartHeight) * 1 / 10);
svgContents = svgContents + String.format('<path id="ChartBackGround" stroke="" d="M0 0 {0} 0 {0} {1} 0 {1} z"/>', this._chartWidth, this._chartHeight);
svgContents = svgContents + String.format('<path fill="#ffffff" stroke-opacity="1" fill-opacity="0" stroke-linejoin="round" stroke-linecap="square" stroke="" d="M5 {0} {1} {0} {1} {2} 5 {2} z" />', parseInt(this._chartHeight) * 1 / 10 + 5, parseInt(this._chartWidth) - 5, parseInt(this._chartHeight) - parseInt(this._chartHeight) * 1 / 10);
return svgContents;
},
// This draws legends of the chart.
drawLegendArea: function() {
var legendContents = '';
// Legend Area
var legendAreaStartHeight = (parseInt(this._chartHeight) * 84 / 100) + 5;
var legendBoxWidth = 7.5;
var legendBoxHeight = 7.5;
var spaceInLegendContents = 5;
// Get length of text to display in legend
var legendCharLength = 0;
for(var i = 0; i < this._series.length; i++) {
legendCharLength = legendCharLength + this._series[i].Name.length;
}
var legendAreaWidth = Math.round((legendCharLength * 5) / 2) + Math.round((legendBoxWidth + (spaceInLegendContents * 2)) * this._series.length);
var isLegendNextLine = false;
if(legendAreaWidth > parseInt(this._chartWidth) / 2) {
legendAreaWidth = legendAreaWidth / 2;
isLegendNextLine = true;
}
legendContents = legendContents + '<g>';
legendContents = legendContents + String.format('<path d="M{0} {1} {2} {1} {2} {3} {0} {3} z" id="LegendArea" stroke=""></path>', Math.round(parseInt(this._chartWidth) / 2 - legendAreaWidth / 2), legendAreaStartHeight, Math.round(parseInt(this._chartWidth) / 2 + legendAreaWidth / 2), Math.round(parseInt(this._chartHeight) * 97.5 / 100));
var startText = parseInt(this._chartWidth) * 40 / 100 - (legendAreaWidth / 2) + legendBoxWidth + spaceInLegendContents;
var nextStartText = startText;
var startLegend = parseInt(this._chartWidth) * 40 / 100 - (legendAreaWidth / 2);
var nextStartLegend = startLegend;
for(var i = 0; i < this._series.length; i++) {
if(isLegendNextLine && i == Math.round(this._series.length / 2)) {
startText = parseInt(this._chartWidth) * 40 / 100 - (legendAreaWidth / 2) + legendBoxWidth + spaceInLegendContents;
nextStartText = startText;
startLegend = parseInt(this._chartWidth) * 40 / 100 - (legendAreaWidth / 2);
nextStartLegend = startLegend;
legendAreaStartHeight = (parseInt(this._chartHeight) * 91 / 100) + 5;
isLegendNextLine = false;
}
startLegend = nextStartLegend;
startText = nextStartText;
legendContents = legendContents + String.format('<path d="M{0} {1} {2} {1} {2} {3} {0} {3} z" id="Legend{4}" style="fill:{5}"></path>', startLegend, legendAreaStartHeight + legendBoxHeight, startLegend + legendBoxWidth, legendAreaStartHeight + 15, i + 1, this._series[i].BarColor);
legendContents = legendContents + String.format('<text x="{0}" y="{1}" id="LegendText">{2}</text>', startText, legendAreaStartHeight + 15, this._series[i].Name);
if(this._series[i].Name.length > 10) {
nextStartLegend = startLegend + (this._series[i].Name.length * 5) + legendBoxWidth + (spaceInLegendContents * 2);
nextStartText = startText + (this._series[i].Name.length * 5) + legendBoxWidth + (spaceInLegendContents * 2);
}
else {
nextStartLegend = nextStartLegend + (this._series[i].Name.length * 6) + legendBoxWidth + (spaceInLegendContents * 2);
nextStartText = nextStartText + (this._series[i].Name.length * 6) + legendBoxWidth + (spaceInLegendContents * 2);
}
}
legendContents = legendContents + '</g>';
return legendContents;
},
// This generates charts of Bar type.
generateBarChart: function() {
this.arrYAxis = this._categoriesAxis.split(',');
this.arrYAxisLength = this.arrYAxis.length;
this.calculateMinMaxValuesForBarType();
this.calculateIntervalForBarType();
this.calculateValueAxisForBarType();
var svgContents = this.initializeSVG();
svgContents = svgContents + String.format('<text x="{0}" y="{1}" id="ChartTitle" style="fill:{3}">{2}</text>', parseInt(this._chartWidth) / 2 - (this._chartTitle.length * this.charLength), parseInt(this._chartHeight) * 5 / 100, this._chartTitle, this._chartTitleColor);
svgContents = svgContents + this.drawBackgroundHorizontalLinesForBarType();
svgContents = svgContents + this.drawBackgroundVerticalLinesForBarType();
svgContents = svgContents + this.drawBaseLinesForBarType();
svgContents = svgContents + this.drawLegendArea();
svgContents = svgContents + this.drawAxisValuesForBarType();
svgContents = svgContents + this.drawBarsForBarType();
svgContents = svgContents + '</svg>';
this._parentDiv.innerHTML = svgContents;
},
// This calculates distance interval for the value axis.
calculateIntervalForBarType: function() {
this.startY = Math.round(parseInt(this._chartHeight) - (parseInt(this._chartHeight) * 20 / 100)) + 0.5;
this.endY = (parseInt(this._chartHeight) * 8 / 100) + 5;
this.endX = parseInt(this._chartWidth) - 10 + 0.5;
if(this.xMin >= 0) {
this.startX = (this._chartWidth * 15 / 100) + 0.5;
}
else {
this.startX = Math.round(parseInt(this._chartWidth) / 2) + 0.5;
}
this.xInterval = Math.round((this.endX - this.startX) / (this._valueAxisLines));
},
// This calculates minimum and maximum values of the specified data.
calculateMinMaxValuesForBarType: function(chartType) {
// calculate minimum and maximum value
var seriesMax;
var seriesMin;
var arrData;
if(this._chartType == Sys.Extended.UI.BarChartType.Bar) {
for(var i = 0; i < this._series.length; i++) {
arrData = this._series[i].Data;
seriesMax = Math.max.apply(null, arrData);
seriesMin = Math.min.apply(null, arrData);
if(i == 0) {
this.xMax = seriesMax;
this.xMin = seriesMin;
}
else {
if(seriesMax > this.xMax)
this.xMax = seriesMax;
if(seriesMin < this.yMin)
this.xMin = seriesMin;
}
}
}
else {
this.arrCombinedData = null;
for(var i = 0; i < this._series.length; i++) {
arrData = new Array();
for(var j = 0; j < this._series[i].Data.length; j++) {
arrData[j] = this._series[i].Data[j];
}
if(this.arrCombinedData == null)
this.arrCombinedData = arrData;
else {
for(j = 0; j < arrData.length; j++) {
this.arrCombinedData[j] = parseFloat(this.arrCombinedData[j]) + parseFloat(arrData[j]);
}
}
}
for(var i = 0; i < this._series.length; i++) {
seriesMin = Math.min.apply(null, this._series[i].Data);
if(i == 0) {
this.xMin = seriesMin;
}
else {
if(seriesMin < this.xMin)
this.xMin = seriesMin;
}
}
this.xMax = Math.max.apply(null, this.arrCombinedData);
}
if(this.xMin < 0) {
this._valueAxisLines = Math.round(this._valueAxisLines / 2);
}
},
// this calculates label values for Value axis to display on the chart.
calculateValueAxisForBarType: function() {
// calculate value axis labels
var range;
var unroundedTickSize;
var x;
var pow10x;
if(this.xMin >= 0) {
range = this.xMax;
}
else {
range = this.xMax > Math.abs(this.xMin) ? this.xMax : Math.abs(this.xMin);
}
unroundedTickSize = range / (this._valueAxisLines - 1);
if(unroundedTickSize < 1) {
this.roundedTickRange = unroundedTickSize.toFixed(1);
}
else {
x = Math.ceil((Math.log(unroundedTickSize) / Math.log(10)) - 1);
pow10x = Math.pow(10, x);
this.roundedTickRange = Math.ceil(unroundedTickSize / pow10x) * pow10x;
}
},
// This draws background Vertical lines of the chart.
drawBackgroundVerticalLinesForBarType: function() {
// background grid's vertical lines
var verticalLineContents = '';
for(var i = 1; i <= this._valueAxisLines; i++) {
verticalLineContents = verticalLineContents + String.format('<path id="VerticalLine" d="M{0} {1} {0} {2}" style="stroke:{3}"></path>', this.startX + (this.xInterval * i), this.startY, this.startY - (this.yInterval * this.arrYAxisLength), this._categoryAxisLineColor);
}
if(this.xMin < 0) {
// background grid's vertical lines for negative values
for(var i = 1; i <= this._valueAxisLines; i++) {
verticalLineContents = verticalLineContents + String.format('<path id="VerticalLine" d="M{0} {1} {0} {2}" style="stroke:{3}"></path>', this.startX - (this.xInterval * i), this.startY, this.startY - (this.yInterval * this.arrYAxisLength), this._categoryAxisLineColor);
}
}
return verticalLineContents;
},
// This draws background Horizontal lines of the chart.
drawBackgroundHorizontalLinesForBarType: function() {
// background grid's horizontal lines
var horizontalLineContents = '';
this.yInterval = Math.round((this.startY - this.endY) / this.arrYAxisLength);
for(var i = 0; i <= this.arrYAxisLength; i++) {
horizontalLineContents = horizontalLineContents + String.format('<path id="HorizontalLine" d="M{0} {2} {1} {2}" style="stroke:{3}"></path>', this.startX, this.startX + (this.xInterval * this._valueAxisLines), (this.startY - (this.yInterval * i)), this._valueAxisLineColor);
}
if(this.xMin < 0) {
for(var i = 0; i <= this.arrYAxisLength; i++) {
horizontalLineContents = horizontalLineContents + String.format('<path id="HorizontalLine" d="M{0} {2} {1} {2}" style="stroke:{3}"></path>', this.startX, this.startX - (this.xInterval * this._valueAxisLines), (this.startY - (this.yInterval * i)), this._valueAxisLineColor);
}
}
return horizontalLineContents;
},
// This draws base lines of the chart.
drawBaseLinesForBarType: function() {
var baseLineContents = '';
baseLineContents = baseLineContents + String.format('<path d="M{0} {1} {0} {2}" id="BaseLine" style="stroke:{3}"></path>', this.startX, this.startY, this.endY, this._baseLineColor);
baseLineContents = baseLineContents + String.format('<path d="M{0} {2} {1} {2}" id="BaseLine" style="stroke:{3}"></path>', this.startX, this.startX - 4, this.startY, this._baseLineColor);
baseLineContents = baseLineContents + String.format('<path d="M{0} {2} {1} {2}" id="BaseLine" style="stroke:{3}"></path>', this.startX, this.endX, this.startY, this._baseLineColor);
for(var i = 0; i < this.arrYAxisLength; i++) {
baseLineContents = baseLineContents + String.format('<path d="M{0} {2} {1} {2}" id="BaseLine" style="stroke:{3}"></path>', this.startX, this.startX - 4, this.startY - (this.yInterval * i), this._baseLineColor);
}
for(var i = 0; i <= this._valueAxisLines; i++) {
baseLineContents = baseLineContents + String.format('<path d="M{0} {1} {0} {2}" id="BaseLine" style="stroke:{3}"></path>', this.startX + (this.xInterval * i), this.startY, this.startY + 4, this._baseLineColor);
}
if(this.xMin < 0) {
baseLineContents = baseLineContents + String.format('<path d="M{0} {2} {1} {2}" id="BaseLine" style="stroke:{3}"></path>', this.startX, (this.startX - (this.xInterval * this._valueAxisLines)), this.startY, this._baseLineColor);
for(var i = 1; i <= this._valueAxisLines; i++) {
baseLineContents = baseLineContents + String.format('<path d="M{0} {1} {0} {2}" id="BaseLine" style="stroke:{3}"></path>', this.startX - (this.xInterval * i), this.startY, this.startY + 4, this._baseLineColor);
}
}
return baseLineContents;
},
// This writes horizontal and vertical axis values of the chart.
drawAxisValuesForBarType: function() {
var axisContents = '';
var textLength = 0;
for(var i = 0; i < this.arrYAxisLength; i++) {
textLength = this.arrYAxis[i].toString().length * 6.5;
axisContents = axisContents + String.format('<text id="SeriesAxis" x="{0}" y="{1}">{2}</text>', this.startX - (this.xInterval * 15 / 100) - textLength, Math.round(this.startY - (this.yInterval * (i + 1)) + (this.yInterval * 60 / 100)), this.arrYAxis[i]);
}
for(var i = 0; i <= this._valueAxisLines; i++) {
axisContents = axisContents + String.format('<text id="ValueAxis" x="{0}" y="{1}">{2}</text>', this.startX + (this.xInterval * i) - ((this.roundedTickRange * i).toString().length * this.charLength), this.startY + (this.yInterval * 35 / 100), this.roundedTickRange * i);
}
if(this.xMin < 0) {
for(var i = 1; i <= this._valueAxisLines; i++) {
axisContents = axisContents + String.format('<text id="ValueAxis" x="{0}" y="{1}">-{2}</text>', this.startX - (this.xInterval * i) - ((this.roundedTickRange * i).toString().length * this.charLength), this.startY + (this.yInterval * 35 / 100), this.roundedTickRange * i);
}
}
return axisContents;
},
drawBarsForBarType: function() {
// Bars section
var barContents = '';
var numberOfBars = this._series.length;
var widthBetweenBars = this.yInterval * 10 / 100;
var barWidth = this._chartType == Sys.Extended.UI.BarChartType.Bar ? Math.round(((this.yInterval * 80 / 100) - (widthBetweenBars * numberOfBars)) / numberOfBars) : Math.round(this.yInterval * 80 / 100);
for(var i = 0; i < this.arrYAxisLength; i++) {
barContents = barContents + '<g>';
if(this._chartType == Sys.Extended.UI.BarChartType.Bar) {
for(var j = 0; j < this._series.length; j++) {
this.xVal = this._series[j].Data[i];
if(i == 0) {
barContents = barContents + String.format('<path id="Bar{4}" style="fill:{5}" d="M{0} {2} {1} {2} {1} {3} {0} {3} z" />', this.startX, this.startX + Math.round(this.xVal * (this.xInterval / this.roundedTickRange)), this.startY - (this.yInterval * i) - (this.yInterval * 15 / 100) - ((widthBetweenBars + barWidth) * j), this.startY - (this.yInterval * i) - (this.yInterval * 15 / 100) - ((widthBetweenBars + barWidth) * j) - barWidth, j + 1, this._series[j].BarColor);
}
else {
barContents = barContents + String.format('<path id="Bar{4}" style="fill:{5}" d="M{0} {2} {1} {2} {1} {3} {0} {3} z" />', this.startX, this.startX + Math.round(this.xVal * (this.xInterval / this.roundedTickRange)), this.startY - (this.yInterval * i) - (this.yInterval * 12.5 / 100) - ((widthBetweenBars + barWidth) * j), this.startY - (this.yInterval * i) - (this.yInterval * 12.5 / 100) - ((widthBetweenBars + barWidth) * j) - barWidth, j + 1, this._series[j].BarColor);
}
if(this.xVal > 0)
barContents = barContents + String.format('<text id="LegendText" x="{0}" y="{1}">{2}</text>', this.startX + Math.round(this.xVal * (this.xInterval / this.roundedTickRange)) + (this.xVal.toString().length * this.charLength), this.startY - (this.yInterval * i) - (this.yInterval * 20 / 100) - ((widthBetweenBars + barWidth) * j) - (barWidth * 10 / 100), this.xVal);
else
barContents = barContents + String.format('<text id="LegendText" x="{0}" y="{1}">{2}</text>', this.startX + Math.round(this.xVal * (this.xInterval / this.roundedTickRange)) - ((this.xVal.toString().length + 1) * this.charLength) - 5, this.startY - (this.yInterval * i) - (this.yInterval * 20 / 100) - ((widthBetweenBars + barWidth) * j) - (barWidth * 10 / 100), this.xVal);
}
}
else {
var lastStartXPositive = this.startX;
var lastStartXNegative = this.startX;
for(var j = 0; j < this._series.length; j++) {
this.xVal = this._series[j].Data[i];
if(i == 0) {
if(this.xVal > 0)
barContents = barContents + String.format('<path id="Bar{4}" style="fill:{5}" d="M{0} {2} {1} {2} {1} {3} {0} {3} z" />', lastStartXPositive, lastStartXPositive + Math.round(this.xVal * (this.xInterval / this.roundedTickRange)), this.startY - (this.yInterval * i) - (this.yInterval * 10 / 100), this.startY - (this.yInterval * i) - (this.xInterval * 10 / 100) - barWidth, j + 1, this._series[j].BarColor);
else
barContents = barContents + String.format('<path id="Bar{4}" style="fill:{5}" d="M{0} {2} {1} {2} {1} {3} {0} {3} z" />', lastStartXNegative, lastStartXNegative + Math.round(this.xVal * (this.xInterval / this.roundedTickRange)), this.startY - (this.yInterval * i) - (this.yInterval * 10 / 100), this.startY - (this.yInterval * i) - (this.xInterval * 10 / 100) - barWidth, j + 1, this._series[j].BarColor);
}
else {
if(this.xVal > 0)
barContents = barContents + String.format('<path id="Bar{4}" style="fill:{5}" d="M{0} {2} {1} {2} {1} {3} {0} {3} z" />', lastStartXPositive, lastStartXPositive + Math.round(this.xVal * (this.xInterval / this.roundedTickRange)), this.startY - (this.yInterval * i) - (this.yInterval * 7.55 / 100), this.startY - (this.yInterval * i) - (this.xInterval * 7.5 / 100) - barWidth, j + 1, this._series[j].BarColor);
else
barContents = barContents + String.format('<path id="Bar{4}" style="fill:{5}" d="M{0} {2} {1} {2} {1} {3} {0} {3} z" />', lastStartXNegative, lastStartXNegative + Math.round(this.xVal * (this.xInterval / this.roundedTickRange)), this.startY - (this.yInterval * i) - (this.yInterval * 7.55 / 100), this.startY - (this.yInterval * i) - (this.xInterval * 7.5 / 100) - barWidth, j + 1, this._series[j].BarColor);
}
if(this.xVal > 0) {
barContents = barContents + String.format('<text id="LegendText" x="{0}" y="{1}">{2}</text>', lastStartXPositive + Math.round((this.xVal * (this.xInterval / this.roundedTickRange)) / 2), this.startY - (this.yInterval * i) - (this.yInterval * 30 / 100) - (barWidth * 10 / 100), this.xVal);
lastStartXPositive = lastStartXPositive + Math.round(this.xVal * (this.xInterval / this.roundedTickRange));
}
else {
barContents = barContents + String.format('<text id="LegendText" x="{0}" y="{1}">{2}</text>', lastStartXNegative + Math.round((this.xVal * (this.xInterval / this.roundedTickRange)) / 2), this.startY - (this.yInterval * i) - (this.yInterval * 30 / 100) - (barWidth * 10 / 100), this.xVal);
lastStartXNegative = lastStartXNegative + Math.round(this.xVal * (this.xInterval / this.roundedTickRange));
}
}
}
barContents = barContents + '</g>';
}
return barContents;
},
/// <summary>
/// Enables you to customize chart width.
/// </summary>
/// <getter>get_chartWidth</getter>
/// <setter>set_chartWidth</setter>
/// <member name="cP:AjaxControlToolkit.BarChart.chartWidth" />
get_chartWidth: function() {
return this._chartWidth;
},
set_chartWidth: function(value) {
this._chartWidth = value;
},
/// <summary>
/// Enables you to customize chart height.
/// </summary>
/// <getter>get_chartHeight</getter>
/// <setter>set_chartHeight</setter>
/// <member name="cP:AjaxControlToolkit.BarChart.chartHeight" />
get_chartHeight: function() {
return this._chartHeight;
},
set_chartHeight: function(value) {
this._chartHeight = value;
},
/// <summary>
/// Enables you to set the chart's title.
/// </summary>
/// <getter>get_chartTitle</getter>
/// <setter>set_chartTitle</setter>
/// <member name="cP:AjaxControlToolkit.BarChart.chartTitle" />
get_chartTitle: function() {
return this._chartTitle;
},
set_chartTitle: function(value) {
this._chartTitle = value;
},
/// <summary>
/// This is a required property. You need to provide a set of values for the category axis to create a bar chart
/// </summary>
/// <getter>get_categoriesAxis</getter>
/// <setter>set_categoriesAxis</setter>
/// <member name="cP:AjaxControlToolkit.BarChart.categoriesAxis" />
get_categoriesAxis: function() {
return this._categoriesAxis;
},
set_categoriesAxis: function(value) {
this._categoriesAxis = value;
},
/// <summary>
/// A list of series.
/// </summary>
/// <getter>get_clientSeries</getter>
/// <setter>set_clientSeries</setter>
/// <member name="cP:AjaxControlToolkit.BarChart.clientSeries" />
get_clientSeries: function() {
return this._series;
},
set_clientSeries: function(value) {
this._series = value;
},
get_ClientSeries: function() {
Sys.Extended.Deprecated("get_ClientSeries", "get_clientSeries");
return this.get_clientSeries();
},
set_ClientSeries: function(value) {
Sys.Extended.Deprecated("set_ClientSeries", "set_clientSeries");
this.set_clientSeries(value);
},
/// <summary>
/// Enables you to render different types of bar charts including Column, StackedColumn, Bar, and StackedBar
/// </summary>
/// <getter>get_chartType</getter>
/// <setter>set_chartType</setter>
/// <member name="cP:AjaxControlToolkit.BarChart.chartType" />
get_chartType: function() {
return this._chartType;
},
set_chartType: function(value) {
this._chartType = value;
},
/// <summary>
/// Enables you to control the appearance of the bar chart with a Cascading Style Sheet file
/// </summary>
/// <getter>get_theme</getter>
/// <setter>set_theme</setter>
/// <member name="cP:AjaxControlToolkit.BarChart.theme" />
get_theme: function() {
return this._theme;
},
set_theme: function(value) {
this._theme = value;
},
/// <summary>
/// Enables you to set interval size for a value axis line.
/// </summary>
/// <getter>get_valueAxisLines</getter>
/// <setter>set_valueAxisLines</setter>
/// <member name="cP:AjaxControlToolkit.BarChart.valueAxisLines" />
get_valueAxisLines: function() {
return this._valueAxisLines;
},
set_valueAxisLines: function(value) {
this._valueAxisLines = value;
},
/// <summary>
/// Enables you to set a font color of the chart title.
/// </summary>
/// <getter>get_chartTitleColor</getter>
/// <setter>set_chartTitleColor</setter>
/// <member name="cP:AjaxControlToolkit.BarChart.chartTitleColor" />
get_chartTitleColor: function() {
return this._chartTitleColor;
},
set_chartTitleColor: function(value) {
this._chartTitleColor = value;
},
/// <summary>
/// Enables you to set a color of the value axis lines.
/// </summary>
/// <getter>get_valueAxisLineColor</getter>
/// <setter>set_valueAxisLineColor</setter>
/// <member name="cP:AjaxControlToolkit.BarChart.valueAxisLineColor" />
get_valueAxisLineColor: function() {
return this._valueAxisLineColor;
},
set_valueAxisLineColor: function(value) {
this._valueAxisLineColor = value;
},
/// <summary>
/// Enables you to set a color of the category axis lines.
/// </summary>
/// <getter>get_categoryAxisLineColor</getter>
/// <setter>set_categoryAxisLineColor</setter>
/// <member name="cP:AjaxControlToolkit.BarChart.categoryAxisLineColor" />
get_categoryAxisLineColor: function() {
return this._categoryAxisLineColor;
},
set_categoryAxisLineColor: function(value) {
this._categoryAxisLineColor = value;
},
/// <summary>
/// Enables you to set a color of the base lines of the chart.
/// </summary>
/// <getter>get_baseLineColor</getter>
/// <setter>set_baseLineColor</setter>
/// <member name="cP:AjaxControlToolkit.BarChart.baseLineColor" />
get_baseLineColor: function() {
return this._baseLineColor;
},
set_baseLineColor: function(value) {
this._baseLineColor = value;
}
};
Sys.Extended.UI.BarChart.registerClass("Sys.Extended.UI.BarChart", Sys.Extended.UI.ControlBase);
Sys.Extended.UI.BarChartType = function() {
throw Error.invalidOperation();
}
Sys.Extended.UI.BarChartType.prototype = {
Column: 0,
Bar: 1,
StackedColumn: 2,
StackedBar: 3
}
Sys.Extended.UI.BarChartType.registerEnum("Sys.Extended.UI.BarChartType", false);

View File

@@ -0,0 +1,403 @@
Type.registerNamespace('Sys.Extended.UI');
Sys.Extended.UI.BehaviorBase = function(element) {
// Base behavior for all extender behaviors
// "element" - element the behavior is associated with
Sys.Extended.UI.BehaviorBase.initializeBase(this,[element]);
this._clientStateFieldID = null;
this._pageRequestManager = null;
this._partialUpdateBeginRequestHandler = null;
this._partialUpdateEndRequestHandler = null;
}
Sys.Extended.UI.BehaviorBase.prototype = {
initialize : function() {
Sys.Extended.UI.BehaviorBase.callBaseMethod(this, 'initialize');
},
dispose : function() {
Sys.Extended.UI.BehaviorBase.callBaseMethod(this, 'dispose');
if (this._pageRequestManager) {
if (this._partialUpdateBeginRequestHandler) {
this._pageRequestManager.remove_beginRequest(this._partialUpdateBeginRequestHandler);
this._partialUpdateBeginRequestHandler = null;
}
if (this._partialUpdateEndRequestHandler) {
this._pageRequestManager.remove_endRequest(this._partialUpdateEndRequestHandler);
this._partialUpdateEndRequestHandler = null;
}
this._pageRequestManager = null;
}
},
get_ClientStateFieldID : function() {
// ID of the hidden field used to store client state
return this._clientStateFieldID;
},
set_ClientStateFieldID : function(value) {
if (this._clientStateFieldID != value) {
this._clientStateFieldID = value;
this.raisePropertyChanged('ClientStateFieldID');
}
},
get_ClientState : function() {
if (this._clientStateFieldID) {
var input = document.getElementById(this._clientStateFieldID);
if (input) {
return input.value;
}
}
return null;
},
set_ClientState : function(value) {
if (this._clientStateFieldID) {
var input = document.getElementById(this._clientStateFieldID);
if (input) {
input.value = value;
}
}
},
registerPartialUpdateEvents : function() {
// Register for beginRequest and endRequest events on the PageRequestManager,
// (which cause _partialUpdateBeginRequest and _partialUpdateEndRequest to be
// called when an UpdatePanel refreshes)
if (Sys && Sys.WebForms && Sys.WebForms.PageRequestManager){
this._pageRequestManager = Sys.WebForms.PageRequestManager.getInstance();
if (this._pageRequestManager) {
this._partialUpdateBeginRequestHandler = Function.createDelegate(this, this._partialUpdateBeginRequest);
this._pageRequestManager.add_beginRequest(this._partialUpdateBeginRequestHandler);
this._partialUpdateEndRequestHandler = Function.createDelegate(this, this._partialUpdateEndRequest);
this._pageRequestManager.add_endRequest(this._partialUpdateEndRequestHandler);
}
}
},
_partialUpdateBeginRequest : function(sender, beginRequestEventArgs) {
// Method that will be called when a partial update (via an UpdatePanel) begins,
// if registerPartialUpdateEvents() has been called.
// "sender" - sender
// "beginRequestEventArgs" - event arguments
},
_partialUpdateEndRequest : function(sender, endRequestEventArgs) {
// Method that will be called when a partial update (via an UpdatePanel) finishes,
// if registerPartialUpdateEvents() has been called.
// "sender" - sender
// "endRequestEventArgs" - event arguments
}
}
Sys.Extended.UI.BehaviorBase.registerClass('Sys.Extended.UI.BehaviorBase', Sys.UI.Behavior);
Sys.Extended.UI.DynamicPopulateBehaviorBase = function(element) {
/// DynamicPopulateBehaviorBase is used to add DynamicPopulateBehavior funcitonality
/// to other extenders. It will dynamically populate the contents of the target element
/// when its populate method is called.
/// "element" - DOM Element the behavior is associated with
Sys.Extended.UI.DynamicPopulateBehaviorBase.initializeBase(this, [element]);
this._DynamicControlID = null;
this._DynamicContextKey = null;
this._DynamicServicePath = null;
this._DynamicServiceMethod = null;
this._cacheDynamicResults = false;
this._dynamicPopulateBehavior = null;
this._populatingHandler = null;
this._populatedHandler = null;
}
Sys.Extended.UI.DynamicPopulateBehaviorBase.prototype = {
initialize : function() {
Sys.Extended.UI.DynamicPopulateBehaviorBase.callBaseMethod(this, 'initialize');
this._populatingHandler = Function.createDelegate(this, this._onPopulating);
this._populatedHandler = Function.createDelegate(this, this._onPopulated);
},
dispose : function() {
if (this._populatedHandler) {
if (this._dynamicPopulateBehavior) {
this._dynamicPopulateBehavior.remove_populated(this._populatedHandler);
}
this._populatedHandler = null;
}
if (this._populatingHandler) {
if (this._dynamicPopulateBehavior) {
this._dynamicPopulateBehavior.remove_populating(this._populatingHandler);
}
this._populatingHandler = null;
}
if (this._dynamicPopulateBehavior) {
this._dynamicPopulateBehavior.dispose();
this._dynamicPopulateBehavior = null;
}
Sys.Extended.UI.DynamicPopulateBehaviorBase.callBaseMethod(this, 'dispose');
},
populate : function(contextKeyOverride) {
// Demand-create the DynamicPopulateBehavior and use it to populate the target element
// "contextKeyOverride" - 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.
if (this._dynamicPopulateBehavior && (this._dynamicPopulateBehavior.get_element() != $get(this._DynamicControlID))) {
this._dynamicPopulateBehavior.dispose();
this._dynamicPopulateBehavior = null;
}
if (!this._dynamicPopulateBehavior && this._DynamicControlID && this._DynamicServiceMethod) {
this._dynamicPopulateBehavior = $create(Sys.Extended.UI.DynamicPopulateBehavior,
{
"id" : this.get_id() + "_DynamicPopulateBehavior",
"ContextKey" : this._DynamicContextKey,
"ServicePath" : this._DynamicServicePath,
"ServiceMethod" : this._DynamicServiceMethod,
"cacheDynamicResults" : this._cacheDynamicResults
}, null, null, $get(this._DynamicControlID));
this._dynamicPopulateBehavior.add_populating(this._populatingHandler);
this._dynamicPopulateBehavior.add_populated(this._populatedHandler);
}
if (this._dynamicPopulateBehavior) {
this._dynamicPopulateBehavior.populate(contextKeyOverride ? contextKeyOverride : this._DynamicContextKey);
}
},
_onPopulating : function(sender, eventArgs) {
// Handler for DynamicPopulate behavior's Populating event
// "sender" - DynamicPopulate behavior
// "eventArgs" - event args
this.raisePopulating(eventArgs);
},
_onPopulated : function(sender, eventArgs) {
// Handler for DynamicPopulate behavior's Populated event
// "sender" - DynamicPopulate behavior
// "eventArgs" - event args
this.raisePopulated(eventArgs);
},
get_dynamicControlID : function() {
// ID of the element to populate with dynamic content
return this._DynamicControlID;
},
get_DynamicControlID : this.get_dynamicControlID,
set_dynamicControlID : function(value) {
if (this._DynamicControlID != value) {
this._DynamicControlID = value;
this.raisePropertyChanged('dynamicControlID');
this.raisePropertyChanged('DynamicControlID');
}
},
set_DynamicControlID : this.set_dynamicControlID,
get_dynamicContextKey : 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._DynamicContextKey;
},
get_DynamicContextKey : this.get_dynamicContextKey,
set_dynamicContextKey : function(value) {
if (this._DynamicContextKey != value) {
this._DynamicContextKey = value;
this.raisePropertyChanged('dynamicContextKey');
this.raisePropertyChanged('DynamicContextKey');
}
},
set_DynamicContextKey : this.set_dynamicContextKey,
get_dynamicServicePath : 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._DynamicServicePath;
},
get_DynamicServicePath : this.get_dynamicServicePath,
set_dynamicServicePath : function(value) {
if (this._DynamicServicePath != value) {
this._DynamicServicePath = value;
this.raisePropertyChanged('dynamicServicePath');
this.raisePropertyChanged('DynamicServicePath');
}
},
set_DynamicServicePath : this.set_dynamicServicePath,
get_dynamicServiceMethod : 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._DynamicServiceMethod;
},
get_DynamicServiceMethod : this.get_dynamicServiceMethod,
set_dynamicServiceMethod : function(value) {
if (this._DynamicServiceMethod != value) {
this._DynamicServiceMethod = value;
this.raisePropertyChanged('dynamicServiceMethod');
this.raisePropertyChanged('DynamicServiceMethod');
}
},
set_DynamicServiceMethod : this.set_dynamicServiceMethod,
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');
}
},
add_populated : function(handler) {
// Add a handler on the populated event
// "handler" - handler
this.get_events().addHandler("populated", handler);
},
remove_populated : function(handler) {
// Remove a handler from the populated event
// "handler" - handler
this.get_events().removeHandler("populated", handler);
},
raisePopulated : function(arg) {
// Raise the populated event
// "arg" - event arguments
var handler = this.get_events().getHandler("populated");
if (handler) handler(this, arg);
},
add_populating : function(handler) {
// Add an event handler for the populating event
// "handler" - event handler
this.get_events().addHandler('populating', handler);
},
remove_populating : function(handler) {
// Remove an event handler from the populating event
// "handler" - event handler
this.get_events().removeHandler('populating', handler);
},
raisePopulating : function(eventArgs) {
// Raise the populating event
// "eventArgs" - event arguments for the populating event
var handler = this.get_events().getHandler('populating');
if (handler) {
handler(this, eventArgs);
}
}
}
Sys.Extended.UI.DynamicPopulateBehaviorBase.registerClass('Sys.Extended.UI.DynamicPopulateBehaviorBase', Sys.Extended.UI.BehaviorBase);
Sys.Extended.UI.ControlBase = function(element) {
Sys.Extended.UI.ControlBase.initializeBase(this, [element]);
this._clientStateField = null;
this._callbackTarget = null;
this._onsubmit$delegate = Function.createDelegate(this, this._onsubmit);
this._oncomplete$delegate = Function.createDelegate(this, this._oncomplete);
this._onerror$delegate = Function.createDelegate(this, this._onerror);
}
Sys.Extended.UI.ControlBase.__doPostBack = function(eventTarget, eventArgument) {
if (!Sys.WebForms.PageRequestManager.getInstance().get_isInAsyncPostBack()) {
for (var i = 0; i < Sys.Extended.UI.ControlBase.onsubmitCollection.length; i++) {
Sys.Extended.UI.ControlBase.onsubmitCollection[i]();
}
}
Function.createDelegate(window, Sys.Extended.UI.ControlBase.__doPostBackSaved)(eventTarget, eventArgument);
}
Sys.Extended.UI.ControlBase.prototype = {
initialize: function() {
Sys.Extended.UI.ControlBase.callBaseMethod(this, "initialize");
if (this._clientStateField) {
this.loadClientState(this._clientStateField.value);
}
if (typeof (Sys.WebForms) !== "undefined" && typeof (Sys.WebForms.PageRequestManager) !== "undefined") {
Array.add(Sys.WebForms.PageRequestManager.getInstance()._onSubmitStatements, this._onsubmit$delegate);
if (Sys.Extended.UI.ControlBase.__doPostBackSaved == null || typeof Sys.Extended.UI.ControlBase.__doPostBackSaved == "undefined") {
Sys.Extended.UI.ControlBase.__doPostBackSaved = window.__doPostBack;
window.__doPostBack = Sys.Extended.UI.ControlBase.__doPostBack;
Sys.Extended.UI.ControlBase.onsubmitCollection = new Array();
}
Array.add(Sys.Extended.UI.ControlBase.onsubmitCollection, this._onsubmit$delegate);
} else {
$addHandler(document.forms[0], "submit", this._onsubmit$delegate);
}
},
dispose: function() {
if (typeof (Sys.WebForms) !== "undefined" && typeof (Sys.WebForms.PageRequestManager) !== "undefined") {
Array.remove(Sys.Extended.UI.ControlBase.onsubmitCollection, this._onsubmit$delegate);
Array.remove(Sys.WebForms.PageRequestManager.getInstance()._onSubmitStatements, this._onsubmit$delegate);
} else {
$removeHandler(document.forms[0], "submit", this._onsubmit$delegate);
}
Sys.Extended.UI.ControlBase.callBaseMethod(this, "dispose");
},
findElement: function(id) {
return $get(this.get_id() + '_' + id.split(':').join('_'));
},
get_clientStateField: function() {
return this._clientStateField;
},
set_clientStateField: function(value) {
if (this.get_isInitialized()) throw Error.invalidOperation(Sys.Extended.UI.Resources.ExtenderBase_CannotSetClientStateField);
if (this._clientStateField != value) {
this._clientStateField = value;
this.raisePropertyChanged('clientStateField');
}
},
loadClientState: function(value) {
// override this method to intercept client state loading after a callback
},
saveClientState: function() {
// override this method to intercept client state acquisition before a callback
return null;
},
_invoke: function(name, args, cb) {
// invokes a callback method on the server control
if (!this._callbackTarget) {
throw Error.invalidOperation(Sys.Extended.UI.Resources.ExtenderBase_ControlNotRegisteredForCallbacks);
}
if (typeof (WebForm_DoCallback) === "undefined") {
throw Error.invalidOperation(Sys.Extended.UI.Resources.ExtenderBase_PageNotRegisteredForCallbacks);
}
var ar = [];
for (var i = 0; i < args.length; i++)
ar[i] = args[i];
var clientState = this.saveClientState();
if (clientState != null && !String.isInstanceOfType(clientState)) {
throw Error.invalidOperation(Sys.Extended.UI.Resources.ExtenderBase_InvalidClientStateType);
}
var payload = Sys.Serialization.JavaScriptSerializer.serialize({ name: name, args: ar, state: this.saveClientState() });
WebForm_DoCallback(this._callbackTarget, payload, this._oncomplete$delegate, cb, this._onerror$delegate, true);
},
_oncomplete: function(result, context) {
result = Sys.Serialization.JavaScriptSerializer.deserialize(result);
if (result.error) {
throw Error.create(result.error);
}
this.loadClientState(result.state);
context(result.result);
},
_onerror: function(message, context) {
throw Error.create(message);
},
_onsubmit: function() {
if (this._clientStateField) {
this._clientStateField.value = this.saveClientState();
}
return true;
}
}
Sys.Extended.UI.ControlBase.registerClass("Sys.Extended.UI.ControlBase", Sys.UI.Control);

View File

@@ -0,0 +1,699 @@
Type.registerNamespace("Sys.Extended.UI");
Sys.Extended.UI.BubbleChart = function(element) {
Sys.Extended.UI.BubbleChart.initializeBase(this, [element]);
var id = this.get_id();
id = id.replace("_ctl00", "");
this._parentDiv = document.getElementById(id + "__ParentDiv");
/// <summary>
/// Enables you to customize the chart width.
/// The default is 300
/// </summary>
/// <getter>get_chartWidth</getter>
/// <setter>set_chartWidth</setter>
/// <member name="cP:AjaxControlToolkit.BubbleChart.chartWidth" />
this._chartWidth = '300';
/// <summary>
/// Enables you to customize the chart height.
/// The default is 200
/// </summary>
/// <getter>get_chartHeight</getter>
/// <setter>set_chartHeight</setter>
/// <member name="cP:AjaxControlToolkit.BubbleChart.chartHeight" />
this._chartHeight = '200';
/// <summary>
/// Enables you to set the chart's title.
/// </summary>
/// <getter>get_chartTitle</getter>
/// <setter>set_chartTitle</setter>
/// <member name="cP:AjaxControlToolkit.BubbleChart.chartTitle" />
this._chartTitle = '';
/// <summary>
/// A list of values.
/// </summary>
/// <getter>get_bubbleChartClientValues</getter>
/// <setter>set_bubbleChartClientValues</setter>
/// <member name="cP:AjaxControlToolkit.BubbleChart.bubbleChartClientValues" />
this._bubbleChartClientValues = null;
/// <summary>
/// Enables you to control the appearance of the bar chart with a CSS file.
/// The default is 'BubbleChart'
/// </summary>
/// <getter>get_theme</getter>
/// <setter>set_theme</setter>
/// <member name="cP:AjaxControlToolkit.BubbleChart.theme" />
this._theme = 'BubbleChart';
/// <summary>
/// Enables you to set interval size for the Y axis line of the chart.
/// The default is 6
/// </summary>
/// <getter>get_yAxisLines</getter>
/// <setter>set_yAxisLines</setter>
/// <member name="cP:AjaxControlToolkit.BubbleChart.yAxisLines" />
this._yAxisLines = 6;
/// <summary>
/// Enables you to set interval size for the X axis line of the chart.
/// The default is 6
/// </summary>
/// <getter>get_xAxisLines</getter>
/// <setter>set_xAxisLines</setter>
/// <member name="cP:AjaxControlToolkit.BubbleChart.xAxisLines" />
this._xAxisLines = 6;
/// <summary>
/// Enables you to set the number of different sizes of the bubbles
/// </summary>
/// <getter>get_bubbleSizes</getter>
/// <setter>set_bubbleSizes</setter>
/// <member name="cP:AjaxControlToolkit.BubbleChart.bubbleSizes" />
this._bubbleSizes = 5;
/// <summary>
/// A font color of the chart title.
/// </summary>
/// <getter>get_chartTitleColor</getter>
/// <setter>set_chartTitleColor</setter>
/// <member name="cP:AjaxControlToolkit.BubbleChart.chartTitleColor" />
this._chartTitleColor = '';
/// <summary>
/// Enables you to set the color of the Y axis lines of the chart
/// </summary>
/// <getter>get_yAxisLineColor</getter>
/// <setter>set_yAxisLineColor</setter>
/// <member name="cP:AjaxControlToolkit.BubbleChart.yAxisLineColor" />
this._yAxisLineColor = '';
/// <summary>
/// Enables you to set the color of the X axis lines of the chart
/// </summary>
/// <getter>get_xAxisLineColor</getter>
/// <setter>set_xAxisLineColor</setter>
/// <member name="cP:AjaxControlToolkit.BubbleChart.xAxisLineColor" />
this._xAxisLineColor = '';
/// <summary>
/// Enables you to set the color of the base lines of the chart
/// </summary>
/// <getter>get_baseLineColor</getter>
/// <setter>set_baseLineColor</setter>
/// <member name="cP:AjaxControlToolkit.BubbleChart.baseLineColor" />
this._baseLineColor = '';
/// <summary>
/// Enables you to set a background color of the tooltip box.
/// The default is #FFFFFF
/// </summary>
/// <getter>get_tooltipBackgroundColor</getter>
/// <setter>set_tooltipBackgroundColor</setter>
/// <member name="cP:AjaxControlToolkit.BubbleChart.tooltipBackgroundColor" />
this._tooltipBackgroundColor = '#FFFFFF';
/// <summary>
/// Enables you to set a font color of the tooltip box.
/// The default is #0E426C
/// </summary>
/// <getter>get_tooltipFontColor</getter>
/// <setter>set_tooptipFontColor</setter>
/// <member name="cP:AjaxControlToolkit.BubbleChart.tooltipFontColor" />
this._tooltipFontColor = '#0E426C';
/// <summary>
/// Enables you to set a border color of the tooltip box.
/// The default is #B85B3E
/// </summary>
/// <getter>get_tooltipBorderColor</getter>
/// <setter>set_tooltipBorderColor</setter>
/// <member name="cP:AjaxControlToolkit.BubbleChart.tooltipBorderColor" />
this._tooltipBorderColor = '#B85B3E';
/// <summary>
/// Enables you to set the text/label to describe what data is in XAxis.
/// </summary>
/// <getter>get_xAxisLabel</getter>
/// <setter>set_xAxisLabel</setter>
/// <member name="cP:AjaxControlToolkit.BubbleChart.xAxisLabel" />
this._xAxisLabel = '';
/// <summary>
/// Enables you to set the text/label to describe what data is in YAxis.
/// </summary>
/// <getter>get_yAxisLabel</getter>
/// <setter>set_yAxisLabel</setter>
/// <member name="cP:AjaxControlToolkit.BubbleChart.yAxisLabel" />
this._yAxisLabel = '';
/// <summary>
/// Enables you to set the text/label that will be shown in the tooltip and describe a bubble value.
/// </summary>
/// <getter>get_bubbleLabel</getter>
/// <setter>set_bubbleLabel</setter>
/// <member name="cP:AjaxControlToolkit.BubbleChart.bubbleLabel" />
this._bubbleLabel = '';
/// <summary>
/// Enables you to set the axis label font color.
/// The default is #000000
/// </summary>
/// <getter>get_axislabelFontColor</getter>
/// <setter>set_axislabelFontColor</setter>
/// <member name="cP:AjaxControlToolkit.BubbleChart.axislabelFontColor" />
this._axislabelFontColor = '#000000';
// variables
this.yMax = 0;
this.yMin = 0;
this.xMax = 0;
this.xMin = 0;
this.dataMax = 0;
this.dataMin = 0;
this.yRoundedIntervalLabelSize = 0;
this.xRoundedIntervalLabelSize = 0;
this.roundedBubbleSize = 0;
this.startX = 0;
this.startY = 0;
this.endX = 0;
this.endY = 0;
this.xInterval = 0;
this.yInterval = 0;
this.charLength = 3.5;
this._divTooltip = null;
}
Sys.Extended.UI.BubbleChart.prototype = {
initialize: function() {
Sys.Extended.UI.BubbleChart.callBaseMethod(this, "initialize");
if(!document.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#Image", "1.1")) {
throw 'Current version of browser does not support SVG.';
}
if(this._yAxisLines == 0) {
this._yAxisLines = 6;
}
if(this._xAxisLines == 0) {
this._xAxisLines = 6;
}
if(this._bubbleSizes == 0) {
this._bubbleSizes = 5;
}
this.generateTooltipDiv();
this.generateBubbleChart();
},
dispose: function() {
Sys.Extended.UI.BubbleChart.callBaseMethod(this, "dispose");
},
generateTooltipDiv: function() {
this._divTooltip = $common.createElementFromTemplate({
nodeName: 'div',
properties: {
id: this.get_id() + '_tooltipDiv',
style: {
position: 'absolute',
backgroundColor: this._tooltipBackgroundColor,
borderStyle: 'solid',
borderWidth: '5px',
borderColor: this._tooltipBorderColor,
left: '0px',
top: '0px',
color: this._tooltipFontColor,
visibility: 'hidden',
zIndex: Sys.Extended.UI.zIndex.BubbleChartTooltip,
padding: '10px'
}
}
}, this._parentDiv);
},
generateBubbleChart: function() {
this.calculateMinMaxValues();
this.calculateBubbleSize();
this.calculateAxisValues();
var svgContents = this.intializeSVG();
// Title Text
svgContents = svgContents + String.format('<text x="{0}" y="{1}" id="ChartTitle" style="fill:{3}">{2}</text>', parseInt(this._chartWidth) / 2 - (this._chartTitle.length * this.charLength), parseInt(this._chartHeight) * 5 / 100, this._chartTitle, this._chartTitleColor);
this.calculateIntervals();
// Draw backgound horizontal lines
svgContents = svgContents + this.drawBackgroundHorizontalLines();
//draw background vertical lines
svgContents = svgContents + this.drawBackgroundVerticalLines();
// draw background base lines
svgContents = svgContents + this.drawBaseLines();
// draw X and Y axis values
svgContents = svgContents + this.drawAxisValues();
this._parentDiv.innerHTML = this._parentDiv.innerHTML + svgContents;
// Bubble section
this.drawBubbles(this, 0);
},
intializeSVG: function() {
var svgContents = String.format('<?xml-stylesheet type="text/css" href="{0}.css"?>', this._theme);
svgContents = String.format('<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="{0}" height="{1}" preserveAspectRatio="xMidYMid meet" viewbox="0 0 {2} {3}" style="position: relative; display: block;" onload="init(evt)">', this._chartWidth, this._chartHeight, parseFloat(this._chartWidth) * 0.99, parseFloat(this._chartHeight) * 0.99);
//svgContents = svgContents + "<script type=\"text/ecmascript\"> function init(evt) { if ( window.svgDocument == null ) { gDocument = evt.target.ownerDocument; } } function ShowTooltip(evt) { alert('called'); } </script>";
svgContents = svgContents + String.format('<path fill="none" stroke-opacity="1" fill-opacity="1" stroke-linejoin="round" stroke-linecap="square" d="M5 {0} {1} {0} {1} {2} 5 {2} z"/>', parseInt(this._chartHeight) * 1 / 10 + 5, parseInt(this._chartWidth) - 5, parseInt(this._chartHeight) - parseInt(this._chartHeight) * 1 / 10);
svgContents = svgContents + String.format('<path id="ChartBackGround" stroke="" d="M0 0 {0} 0 {0} {1} 0 {1} z"/>', this._chartWidth, parseInt(this._chartHeight) - 5);
svgContents = svgContents + String.format('<path fill="#ffffff" stroke-opacity="1" fill-opacity="0" stroke-linejoin="round" stroke-linecap="square" stroke="" d="M5 {0} {1} {0} {1} {2} 5 {2} z" />', parseInt(this._chartHeight) * 1 / 10 + 5, parseInt(this._chartWidth) - 5, parseInt(this._chartHeight) - parseInt(this._chartHeight) * 1 / 10);
return svgContents;
},
drawBubbles: function(me, index) {
me._parentDiv.innerHTML = me._parentDiv.innerHTML.replace('</svg>', '') + String.format('<circle id="Dot{4}" cx="{0}" cy="{1}" r="{2}" style="fill:{3};stroke:{3}" onmouseover="ShowTooltip(this, evt,\'{5}\',{6}, \'{7}\')" onmouseout="HideTooltip(this, evt)"></circle></svg>', me.startX + Math.round((parseFloat(me._bubbleChartClientValues[index].X) / me.xRoundedIntervalLabelSize) * me.xInterval), me.startY + Math.round(((-1 * parseFloat(me._bubbleChartClientValues[index].Y)) / me.yRoundedIntervalLabelSize) * me.yInterval), Math.round((parseFloat(me._bubbleChartClientValues[index].Data) / me.roundedBubbleSize) * me._bubbleSizes), me._bubbleChartClientValues[index].BubbleColor, index + 1, me._bubbleChartClientValues[index].Category, me._bubbleChartClientValues[index].Data, me._bubbleLabel);
index++;
if(index < me._bubbleChartClientValues.length) { // if the counter < series length, call the loop function
setTimeout(function() {
me.drawBubbles(me, index);
}, 400);
}
},
// This calculates minimum and maximum values of the specified data.
calculateMinMaxValues: function() {
// calculate minimum and maximum value
for(var i = 0; i < this._bubbleChartClientValues.length; i++) {
if(i == 0) {
this.dataMax = parseFloat(this._bubbleChartClientValues[i].Data);
this.dataMin = parseFloat(this._bubbleChartClientValues[i].Data);
this.yMax = parseFloat(this._bubbleChartClientValues[i].Y);
this.yMin = parseFloat(this._bubbleChartClientValues[i].Y);
this.xMax = parseFloat(this._bubbleChartClientValues[i].X);
this.xMin = parseFloat(this._bubbleChartClientValues[i].X);
}
else {
// Data values
if(parseFloat(this._bubbleChartClientValues[i].Data) > this.dataMax)
this.dataMax = parseFloat(this._bubbleChartClientValues[i].Data);
if(parseFloat(this._bubbleChartClientValues[i].Data) < this.dataMin)
this.dataMin = parseFloat(this._bubbleChartClientValues[i].Data);
// X values
if(parseFloat(this._bubbleChartClientValues[i].X) > this.xMax)
this.xMax = parseFloat(this._bubbleChartClientValues[i].X);
if(parseFloat(this._bubbleChartClientValues[i].Data) < this.xMin)
this.xMin = parseFloat(this._bubbleChartClientValues[i].X);
// Y values
if(parseFloat(this._bubbleChartClientValues[i].Y) > this.yMax)
this.yMax = parseFloat(this._bubbleChartClientValues[i].Y);
if(parseFloat(this._bubbleChartClientValues[i].Y) < this.yMin)
this.yMin = parseFloat(this._bubbleChartClientValues[i].Y);
}
}
if(this.xMin < 0)
this._xAxisLines = Math.round(this._xAxisLines / 2);
if(this.yMin < 0)
this._yAxisLines = Math.round(this._yAxisLines / 2);
},
calculateBubbleSize: function() {
var pow10x;
var x;
// calculate size of bubble
var bubbleRange;
var unroundedBubbleSize;
bubbleRange = this.dataMax;
unroundedBubbleSize = bubbleRange / (this._bubbleSizes - 1);
x = Math.ceil((Math.log(unroundedBubbleSize) / Math.log(10)) - 1);
pow10x = Math.pow(10, x);
this.roundedBubbleSize = Math.ceil(unroundedBubbleSize / pow10x) * pow10x;
},
// this calculates label values for X and Y Value axis to display on the chart.
calculateAxisValues: function() {
// calculate value axis labels
var valueRange;
var unroundedValueSize;
if(this.yMin < 0) {
valueRange = this.yMax > Math.abs(this.yMin) ? this.yMax : Math.abs(this.yMin);
}
else {
valueRange = this.yMax;
}
unroundedValueSize = valueRange / (this._yAxisLines - 1);
if(unroundedValueSize < 1) {
this.yRoundedIntervalLabelSize = unroundedValueSize.toFixed(1);
}
else {
x = Math.ceil((Math.log(unroundedValueSize) / Math.log(10)) - 1);
pow10x = Math.pow(10, x);
this.yRoundedIntervalLabelSize = Math.ceil(unroundedValueSize / pow10x) * pow10x;
}
// calculate X axis labels
var xRange;
var unroundedXSize;
if(this.xMin < 0) {
xRange = this.xMax > Math.abs(this.xMin) ? this.xMax : Math.abs(this.xMin);
}
else {
xRange = this.xMax;
}
unroundedXSize = xRange / (this._xAxisLines - 1);
if(unroundedValueSize < 1) {
this.xRoundedIntervalLabelSize = unroundedXSize.toFixed(1);
}
else {
x = Math.ceil((Math.log(unroundedXSize) / Math.log(10)) - 1);
pow10x = Math.pow(10, x);
this.xRoundedIntervalLabelSize = Math.ceil(unroundedXSize / pow10x) * pow10x;
}
},
// This calculates distance interval for the value axis.
calculateIntervals: function() {
this.endX = parseFloat(this._chartWidth) - (parseFloat(this._chartWidth) * 5 / 100);
if(this.xMin < 0) {
this.startX = Math.round(parseFloat(this._chartWidth) + (parseFloat(this._chartWidth) * 10 / 100)) / 2 + 0.5;
}
else {
this.startX = (parseFloat(this._chartWidth) * 20 / 100) + 0.5;
}
if(this.xMin < 0)
this.xInterval = (this.endX - this.startX) / (this._xAxisLines);
else
this.xInterval = Math.round((this.endX - this.startX) / (this._xAxisLines));
if(this.yMin < 0)
this.startY = Math.round(parseInt(this._chartHeight) - (parseInt(this._chartHeight) * 5 / 100)) / 2 + 0.5;
else
this.startY = Math.round(parseInt(this._chartHeight) - (parseInt(this._chartHeight) * 20 / 100)) + 0.5;
this.yInterval = this.startY / (this._yAxisLines + 1);
this.endY = this.startY - (this.yInterval * this._yAxisLines);
},
// This draws background horizontal lines of the chart.
drawBackgroundHorizontalLines: function() {
var horizontalLineContents = '';
// For positive values.
for(var i = 1; i <= this._yAxisLines; i++) {
horizontalLineContents = horizontalLineContents + String.format('<path d="M{0} {2} {1} {2}" id="HorizontalLine" style="stroke:{3}"></path>', this.startX, this.endX, this.startY - (this.yInterval * i), this._xAxisLineColor);
}
if(this.yMin < 0) {
// background grid's horizontal lines for negative y values.
for(var i = 1; i <= this._yAxisLines; i++) {
horizontalLineContents = horizontalLineContents + String.format('<path d="M{0} {2} {1} {2}" id="HorizontalLine" style="stroke:{3}"></path>', this.startX, this.endX, this.startY + (this.yInterval * i), this._xAxisLineColor);
}
}
if(this.xMin < 0) {
// background grid's horizontal lines for negative x values.
for(var i = 1; i <= this._yAxisLines; i++) {
horizontalLineContents = horizontalLineContents + String.format('<path id="HorizontalLine" d="M{0} {2} {1} {2}" style="stroke:{3}"></path>', this.startX, (this.startX - (this.xInterval * this._xAxisLines)), (this.startY - (this.yInterval * i)), this._xAxisLineColor);
}
}
if(this.xMin < 0 && this.yMin < 0) {
// background grid's horizontal lines for negative values
for(var i = 1; i <= this._yAxisLines; i++) {
horizontalLineContents = horizontalLineContents + String.format('<path id="HorizontalLine" d="M{0} {2} {1} {2}" style="stroke:{3}"></path>', this.startX, this.startX - (this.xInterval * this._xAxisLines), (this.startY + (this.yInterval * i)), this._xAxisLineColor);
}
}
return horizontalLineContents;
},
// This draws background vertical lines of the chart.
drawBackgroundVerticalLines: function() {
var verticalLineContents = '';
// background grid's vertical lines
for(var i = 1; i <= this._xAxisLines; i++) {
verticalLineContents = verticalLineContents + String.format('<path d="M{0} {1} {0} {2}" id="VerticalLine" style="stroke:{3}"></path>', this.startX + (this.xInterval * i), this.startY, this.endY, this._yAxisLineColor);
}
if(this.xMin < 0) {
// background grid's vertical lines for negative values
for(var i = 1; i <= this._xAxisLines; i++) {
verticalLineContents = verticalLineContents + String.format('<path d="M{0} {1} {0} {2}" id="VerticalLine" style="stroke:{3}"></path>', this.startX - (this.xInterval * i), this.startY, this.endY, this._yAxisLineColor);
}
}
if(this.yMin < 0) {
// background grid's vertical lines for negative values
for(var i = 1; i <= this._xAxisLines; i++) {
verticalLineContents = verticalLineContents + String.format('<path id="VerticalLine" d="M{0} {1} {0} {2}" style="stroke:{3}"></path>', this.startX + (this.xInterval * i), this.startY, this.startY + (this.yInterval * this._yAxisLines), this._yAxisLineColor);
}
}
if(this.xMin < 0 && this.yMin < 0) {
// background grid's vertical lines for negative values
for(var i = 1; i <= this._xAxisLines; i++) {
verticalLineContents = verticalLineContents + String.format('<path id="VerticalLine" d="M{0} {1} {0} {2}" style="stroke:{3}"></path>', this.startX - (this.xInterval * i), this.startY, this.startY + (this.yInterval * this._yAxisLines), this._yAxisLineColor);
}
}
return verticalLineContents;
},
// This draws base lines of the chart.
drawBaseLines: function() {
var baseLineContents = '';
baseLineContents = baseLineContents + String.format('<path d="M{0} {1} {2} {1}" id="BaseLine" style="stroke:{3}"></path>', this.startX, this.startY, this.endX, this._baseLineColor);
baseLineContents = baseLineContents + String.format('<path d="M{0} {1} {0} {2}" id="BaseLine" style="stroke:{3}"></path>', this.startX, this.startY, this.startY + 4, this._baseLineColor);
baseLineContents = baseLineContents + String.format('<path d="M{0} {1} {0} {2}" id="BaseLine" style="stroke:{3}"></path>', this.startX, this.startY, this.endY, this._baseLineColor);
baseLineContents = baseLineContents + String.format('<path d="M{0} {1} {2} {1}" id="BaseLine" style="stroke:{3}"></path>', this.startX, this.startY, this.startX + 4, this._baseLineColor);
for(var i = 0; i <= this._yAxisLines; i++) {
baseLineContents = baseLineContents + String.format('<path d="M{0} {2} {1} {2}" id="BaseLine" style="stroke:{3}"></path>', this.startX - 4, this.startX, this.startY - (this.yInterval * i), this._baseLineColor);
}
if(this.yMin < 0) {
for(var i = 1; i <= this._yAxisLines; i++) {
baseLineContents = baseLineContents + String.format('<path d="M{0} {2} {1} {2}" id="BaseLine" style="stroke:{3}"></path>', this.startX - 4, this.startX, this.startY + (this.yInterval * i), this._baseLineColor);
}
baseLineContents = baseLineContents + String.format('<path d="M{0} {1} {0} {2}" id="BaseLine" style="stroke:{3}"></path>', (this.startX - (this.xInterval * this._xAxisLines)), this.startY, this.startY + 4, this._baseLineColor);
baseLineContents = baseLineContents + String.format('<path d="M{0} {1} {0} {2}" id="BaseLine" style="stroke:{3}"></path>', this.startX, this.startY, this.startY + (this.yInterval * this._yAxisLines), this._baseLineColor);
}
for(var i = 0; i <= this._xAxisLines; i++) {
baseLineContents = baseLineContents + String.format('<path d="M{0} {1} {0} {2}" id="BaseLine" style="stroke:{3}"></path>', this.startX + (this.xInterval * i), this.startY, this.startY + 4, this._baseLineColor);
}
if(this.xMin < 0) {
for(var i = 1; i <= this._xAxisLines; i++) {
baseLineContents = baseLineContents + String.format('<path d="M{0} {1} {0} {2}" id="BaseLine" style="stroke:{3}"></path>', this.startX - (this.xInterval * i), this.startY, this.startY + 4, this._baseLineColor);
}
baseLineContents = baseLineContents + String.format('<path d="M{0} {2} {1} {2}" id="BaseLine" style="stroke:{3}"></path>', this.startX, (this.startX - (this.xInterval * this._xAxisLines)), this.startY, this._baseLineColor);
}
return baseLineContents;
},
drawAxisValues: function() {
var axisValueContents = '';
var textLength = 0;
for(var i = 1; i <= this._yAxisLines; i++) {
textLength = (this.yRoundedIntervalLabelSize * 10 * i / 10).toString().length * 5.5;
axisValueContents = axisValueContents + String.format('<text id="ValueAxis" x="{0}" y="{1}">{2}</text>', this.startX - textLength - 10, this.startY - (this.yInterval * i) + 4, this.yRoundedIntervalLabelSize * 10 * i / 10);
}
if(this.yMin < 0) {
for(var i = 1; i <= this._yAxisLines; i++) {
textLength = (this.yRoundedIntervalLabelSize * 10 * i / 10).toString().length * 5.5 + 5.5; // add length for -ve character
axisValueContents = axisValueContents + String.format('<text id="ValueAxis" x="{0}" y="{1}">-{2}</text>', this.startX - textLength - 10, this.startY + (this.yInterval * i) + 4, this.yRoundedIntervalLabelSize * 10 * i / 10);
}
}
for(var i = 1; i <= this._xAxisLines; i++) {
textLength = (this.xRoundedIntervalLabelSize * 10 * i / 10).toString().length * 5.5;
axisValueContents = axisValueContents + String.format('<text id="SeriesAxis" x="{0}" y="{1}">{2}</text>', Math.round(this.startX + (this.xInterval * i) - (textLength / 2)), this.startY + Math.round(this.yInterval * 25 / 100) + 5, this.xRoundedIntervalLabelSize * 10 * i / 10);
}
if(this.xMin < 0) {
for(var i = 1; i <= this._xAxisLines; i++) {
textLength = (this.xRoundedIntervalLabelSize * 10 * i / 10).toString().length * 5.5 + 5.5; // add length for -ve character
axisValueContents = axisValueContents + String.format('<text id="SeriesAxis" x="{0}" y="{1}">-{2}</text>', Math.round(this.startX - (this.xInterval * i) - (textLength / 2)), this.startY + Math.round(this.yInterval * 25 / 100) + 5, this.xRoundedIntervalLabelSize * 10 * i / 10);
}
}
var yLabelStart;
if(this.yMin < 0)
yLabelStart = Math.round((this.startY + (this.yInterval * this._yAxisLines)) - (this.startY - (this.yInterval * this._yAxisLines))) / 2;
else
yLabelStart = Math.round((this.startY - this.endY) / 2);
axisValueContents = axisValueContents + String.format('<text id="AxisLabels" x="{0}" y="{1}" style="fill:{3};" transform="rotate(-90, {0}, {1})">{2}</text>', Math.round(parseFloat(this._chartWidth) * 5 / 100), yLabelStart + (this._yAxisLabel.toString().length * this.charLength), this._yAxisLabel, this._axislabelFontColor);
axisValueContents = axisValueContents + String.format('<text id="AxisLabels" x="{0}" y="{1}" style="fill:{3};">{2}</text>', Math.round(parseInt(this._chartWidth) / 2 - (this._xAxisLabel.toString().length * this.charLength) / 2), Math.round(parseInt(this._chartHeight) * 90 / 100 + 5), this._xAxisLabel, this._axislabelFontColor);
return axisValueContents;
},
get_chartWidth: function() {
return this._chartWidth;
},
set_chartWidth: function(value) {
this._chartWidth = value;
},
get_chartHeight: function() {
return this._chartHeight;
},
set_chartHeight: function(value) {
this._chartHeight = value;
},
get_chartTitle: function() {
return this._chartTitle;
},
set_chartTitle: function(value) {
this._chartTitle = value;
},
get_bubbleChartClientValues: function() {
return this._bubbleChartClientValues;
},
set_bubbleChartClientValues: function(value) {
this._bubbleChartClientValues = value;
},
get_BubbleChartClientValues: function() {
Sys.Extended.Deprecated("get_BubbleChartClientValues", "get_bubbleChartClientValues");
return this.get_bubbleChartClientValues();
},
set_BubbleChartClientValues: function(value) {
Sys.Extended.Deprecated("set_BubbleChartClientValues", "set_bubbleChartClientValues");
this.set_bubbleChartClientValues(value);
},
get_theme: function() {
return this._theme;
},
set_theme: function(value) {
this._theme = value;
},
get_yAxisLines: function() {
return this._yAxisLines;
},
set_yAxisLines: function(value) {
this._yAxisLines = value;
},
get_xAxisLines: function() {
return this._xAxisLines;
},
set_xAxisLines: function(value) {
this._xAxisLines = value;
},
get_chartTitleColor: function() {
return this._chartTitleColor;
},
set_chartTitleColor: function(value) {
this._chartTitleColor = value;
},
get_yAxisLineColor: function() {
return this._yAxisLineColor;
},
set_yAxisLineColor: function(value) {
this._yAxisLineColor = value;
},
get_xAxisLineColor: function() {
return this._xAxisLineColor;
},
set_xAxisLineColor: function(value) {
this._xAxisLineColor = value;
},
get_bubbleSizes: function() {
return this._bubbleSizes;
},
set_bubbleSizes: function(value) {
this._bubbleSizes = value;
},
get_baseLineColor: function() {
return this._baseLineColor;
},
set_baseLineColor: function(value) {
this._baseLineColor = value;
},
get_tooltipBackgroundColor: function() {
return this.tooltipBackgroundColor;
},
set_tooltipBackgroundColor: function(value) {
this.tooltipBackgroundColor = value;
},
get_tooltipFontColor: function() {
return this._tooltipFontColor;
},
set_tooltipFontColor: function(value) {
this._tooltipFontColor = value;
},
get_tooltipBorderColor: function() {
return this._tooltipBorderColor;
},
set_tooltipBorderColor: function(value) {
this._tooltipBorderColor = value;
},
get_xAxisLabel: function() {
return this._xAxisLabel;
},
set_xAxisLabel: function(value) {
this._xAxisLabel = value;
},
get_yAxisLabel: function() {
return this._yAxisLabel;
},
set_yAxisLabel: function(value) {
this._yAxisLabel = value;
},
get_bubbleLabel: function() {
return this._bubbleLabel;
},
set_bubbleLabel: function(value) {
this._bubbleLabel = value;
},
get_axislabelFontColor: function() {
return this._axislabelFontColor;
},
set_axislabelFontColor: function(value) {
this._axislabelFontColor = value;
}
};
Sys.Extended.UI.BubbleChart.registerClass("Sys.Extended.UI.BubbleChart", Sys.Extended.UI.ControlBase);

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,788 @@
Type.registerNamespace('Sys.Extended.UI');
Sys.Extended.UI.CascadingDropDownSelectionChangedEventArgs = function(oldValue, newValue) {
Sys.Extended.UI.CascadingDropDownSelectionChangedEventArgs.initializeBase(this);
this._oldValue = oldValue;
this._newValue = newValue;
}
Sys.Extended.UI.CascadingDropDownSelectionChangedEventArgs.prototype = {
get_oldValue: function() {
return this._oldValue;
},
get_newValue: function() {
return this._newValue;
}
}
Sys.Extended.UI.CascadingDropDownSelectionChangedEventArgs.registerClass('Sys.Extended.UI.CascadingDropDownSelectionChangedEventArgs', Sys.EventArgs);
Sys.Extended.UI.CascadingDropDownBehavior = function(e) {
// The CascadingDropDownBehavior is used to populate drop downs with values from a web service
// "e" - the DOM element the behavior is associated with
Sys.Extended.UI.CascadingDropDownBehavior.initializeBase(this, [e]);
/// <summary>
/// A string containing an ID of a parent dropdown in a hierarchy of dropdowns.
/// </summary>
/// <getter>get_parentControlID</getter>
/// <setter>set_parentControlID</setter>
/// <member name="cP:AjaxControlToolkit.CascadingDropDown.parentControlID" />
this._parentControlID = null;
/// <summary>
/// A string containing a category of this dropdown.
/// </summary>
/// <getter>get_category</getter>
/// <setter>set_category</setter>
/// <member name="cP:AjaxControlToolkit.CascadingDropDown.category" />
this._category = null;
/// <summary>
/// A string containing prompt text that is displayed as the first entry in the dropdown.
/// </summary>
/// <getter>get_promptText</getter>
/// <setter>set_promptText</setter>
/// <member name="cP:AjaxControlToolkit.CascadingDropDown.promptText" />
this._promptText = null;
/// <summary>
/// A string containing loading text to to be displayed when getting the dropdown's values from the Web service.
/// </summary>
/// <getter>get_loadingText</getter>
/// <setter>set_loadingText</setter>
/// <member name="cP:AjaxControlToolkit.CascadingDropDown.loadingText" />
this._loadingText = null;
/// <summary>
/// A string containing a value for an option displayed by DropDownList showing PromptText.
/// </summary>
/// <getter>get_promptValue</getter>
/// <setter>set_promptValue</setter>
/// <member name="cP:AjaxControlToolkit.CascadingDropDown.promptValue" />
this._promptValue = null;
/// <summary>
/// A string containing a value for an option displayed when the list is empty.
/// </summary>
/// <getter>get_emptyValue</getter>
/// <setter>set_emptyValue</setter>
/// <member name="cP:AjaxControlToolkit.CascadingDropDown.emptyValue" />
this._emptyValue = null;
/// <summary>
/// A string containing text for an option displayed when the list is empty.
/// </summary>
/// <getter>get_emptyText</getter>
/// <setter>set_emptyText</setter>
/// <member name="cP:AjaxControlToolkit.CascadingDropDown.emptyText" />
this._emptyText = null;
/// <summary>
/// A string containing a path of the Web service.
/// The default is page path
/// </summary>
/// <getter>get_servicePath</getter>
/// <setter>set_servicePath</setter>
/// <member name="cP:AjaxControlToolkit.CascadingDropDown.servicePath" />
this._servicePath = location.pathname;
/// <summary>
/// A string containing the name of the method to invoke on the Web service.
/// </summary>
/// <getter>get_serviceMethod</getter>
/// <setter>set_serviceMethod</setter>
/// <member name="cP:AjaxControlToolkit.CascadingDropDown.serviceMethod" />
this._serviceMethod = null;
/// <summary>
/// A string containing user or page-specific context provided to an optional overload of the Web method described by ServiceMethod or ServicePath.
/// </summary>
/// <remarks>
/// If the context key is used, it should have the same signature with an additional parameter named contextKey of the string type.
/// </remarks>
/// <getter>get_contextKey</getter>
/// <setter>set_contextKey</setter>
/// <member name="cP:AjaxControlToolkit.CascadingDropDown.contextKey" />
this._contextKey = null;
/// <summary>
/// A boolean value that determines whether or not the ContextKey property should be used.
/// </summary>
/// <remarks>
/// The useContextKey property will be automatically enabled if the ContextKey property is ever set either on the client or server side.
/// If the context key is used, it should have the same signature with an additional parameter named contextKey of the string type.
/// </remarks>
/// <getter>get_useContextKey</getter>
/// <setter>set_useContextKey</setter>
/// <member name="cP:AjaxControlToolkit.CascadingDropDown.useContextKey" />
this._useContextKey = false;
/// <summary>
/// Determines whether or not to use the HTTP GET method for requesting data.
/// </summary>
/// <getter>get_useHttpGet</getter>
/// <setter>set_useHttpGet</setter>
/// <member name="cP:AjaxControlToolkit.CascadingDropDown.useHttpGet" />
this._useHttpGet = false;
/// <summary>
/// Determines whether or not to disable the DropDownList control when it is waiting for
/// data from the service, so on loading a user can use the keyboard to navigate to the drop-down control.
/// </summary>
/// <getter>get_enableAtLoading</getter>
/// <setter>set_enableAtLoading</setter>
/// <member name="cP:AjaxControlToolkit.CascadingDropDown.enableAtLoading" />
this._enableAtLoading = false;
// Variables
this._parentElement = null;
this._changeHandler = null;
this._parentChangeHandler = null;
this._lastParentValues = null;
/// <summary>
/// A string containing the selected value of the dropdown.
/// </summary>
/// <getter>get_selectedValue</getter>
/// <setter>set_selectedValue</setter>
/// <member name="cP:AjaxControlToolkit.CascadingDropDown.selectedValue" />
this._selectedValue = null;
this._actualDisabledStatus = false;
}
Sys.Extended.UI.CascadingDropDownBehavior.prototype = {
initialize: function() {
Sys.Extended.UI.CascadingDropDownBehavior.callBaseMethod(this, 'initialize');
$common.prepareHiddenElementForATDeviceUpdate();
var e = this.get_element();
this._actualDisabledStatus = e.disabled;
// Clear any items that may have been put there for server side convenience
this._clearItems();
e.CascadingDropDownCategory = this._category;
// Attach change handler to self
this._changeHandler = Function.createDelegate(this, this._onChange);
$addHandler(e, "change", this._changeHandler);
if(this._parentControlID) {
// Set properties on element so that children controls (if any) can have easy access
this._parentElement = $get(this._parentControlID);
// Attach change handler to parent
if(!this._parentElement) {
Sys.Debug.fail(String.format(Sys.Extended.UI.Resources.CascadingDropDown_NoParentElement, this._parentControlID));
}
if(this._parentElement) {
e.CascadingDropDownParentControlID = this._parentControlID;
this._parentChangeHandler = Function.createDelegate(this, this._onParentChange);
$addHandler(this._parentElement, "change", this._parentChangeHandler);
if(!this._parentElement.childDropDown) {
this._parentElement.childDropDown = new Array();
}
this._parentElement.childDropDown.push(this);
}
}
// Simulate parent change to populate self, even if no parent exists.
this._onParentChange(null, true);
// Revert disable status to the actual.
var me = this;
setTimeout(function() {
if(me._actualDisabledStatus)
e.disabled = me._actualDisabledStatus;
}, 50);
},
dispose: function() {
var e = this.get_element();
// Detach change handler for self
if(this._changeHandler) {
$removeHandler(e, "change", this._changeHandler);
this._changeHandler = null;
}
// Detach change handler for parent
if(this._parentChangeHandler) {
if(this._parentElement) {
$removeHandler(this._parentElement, "change", this._parentChangeHandler);
}
this._parentChangeHandler = null;
}
Sys.Extended.UI.CascadingDropDownBehavior.callBaseMethod(this, 'dispose');
},
_clearItems: function() {
var e = this.get_element();
if(e != null && e.options != null) {
while(0 < e.options.length) {
e.remove(0);
}
}
},
_isPopulated: function() {
var items = this.get_element().options.length;
if(this._promptText) {
return items > 1;
} else {
return items > 0;
}
},
_setOptions: function(list, inInit, gettingList) {
// Set the contents of the DropDownList to the specified list
// "list" - array of options (where each option has name and value properties)
// "inInit" - whether this is being called from the initialize method
// "gettingList" - whether we are fetching the list of options from the web service
if(!this.get_isInitialized()) {
return;
}
var e = this.get_element();
// Remove existing contents
this._clearItems();
// Populate prompt text (if available)
var headerText;
var headerValue = "";
if(gettingList && this._loadingText) {
headerText = this._loadingText;
if(this._selectedValue) {
headerValue = this._selectedValue;
}
} else if(!gettingList && list && (0 == list.length) && (null != this._emptyText)) {
headerText = this._emptyText;
if(this._emptyValue) {
headerValue = this._emptyValue;
}
} else if(this._promptText) {
headerText = this._promptText;
if(this._promptValue) {
headerValue = this._promptValue;
}
}
var optionElement;
if(headerText) {
optionElement = new Option(headerText, headerValue);
e.options[e.options.length] = optionElement;
}
// Add each item to the DropDownList, selecting the previously selected item
var selectedValueOption = null,
defaultIndex = -1;
if(list) {
for(var i = 0; i < list.length; i++) {
var item = list[i],
listItemName = item.name,
listItemValue = item.value,
listItemOptionTitle = item.optionTitle;
if(item.isDefaultValue) {
this.set_selectedValue(listItemValue, listItemName, listItemOptionTitle);
defaultIndex = i;
if(this._promptText) {
// bump the index if there's a prompt item in the list.
//
defaultIndex++;
}
}
optionElement = new Option(listItemName, listItemValue);
if(listItemValue == this._selectedValue) {
selectedValueOption = optionElement;
}
// Populate the title attribute with the optionTitle value provided by the service (shows tooltip over item on some
// modern browsers)
if(listItemOptionTitle) {
optionElement.setAttribute('title', listItemOptionTitle);
}
e.options[e.options.length] = optionElement;
}
if(selectedValueOption) {
selectedValueOption.selected = true;
}
}
// if we didn't match the selected value, and we found a default
// item, select that one.
//
if(selectedValueOption) {
// Call set_selectedValue to store the text as well
this.set_selectedValue(e.options[e.selectedIndex].value, e.options[e.selectedIndex].text);
} else if(!selectedValueOption && defaultIndex != -1) {
e.options[defaultIndex].selected = true;
this.set_selectedValue(e.options[defaultIndex].value, e.options[defaultIndex].text);
} else if(!inInit && !selectedValueOption && !gettingList && !this._promptText && (e.options.length > 0)) {
// If no prompt text or default item, select the first item
this.set_selectedValue(e.options[0].value, e.options[0].text);
} else if(!inInit && !selectedValueOption && !gettingList) {
this.set_selectedValue('', '');
}
if(e.childDropDown && !gettingList) {
for(var i = 0; i < e.childDropDown.length; i++) {
e.childDropDown[i]._onParentChange();
}
}
else {
if(list && (Sys.Browser.agent !== Sys.Browser.Safari) && (Sys.Browser.agent !== Sys.Browser.Opera)) {
// Fire the onchange event for the control to notify any listeners of the change
if(document.createEvent) {
var onchangeEvent = document.createEvent('HTMLEvents');
onchangeEvent.initEvent('change', true, false);
this.get_element().dispatchEvent(onchangeEvent);
} else if(document.createEventObject) {
this.get_element().fireEvent('onchange');
}
}
}
// check whether to disable or not at loading.
if(!this._enableAtLoading) {
// Disable the control if loading/prompt text is present and an empty list was populated
if(this._loadingText || this._promptText || this._emptyText) {
e.disabled = !list || (0 == list.length);
}
if(this._actualDisabledStatus)
e.disabled = this._actualDisabledStatus;
}
},
_onChange: function() {
if(!this._isPopulated()) {
return;
}
var e = this.get_element();
// Record the selected value in the client state
if((-1 != e.selectedIndex) && !(this._promptText && (0 == e.selectedIndex))) {
this.set_selectedValue(e.options[e.selectedIndex].value, e.options[e.selectedIndex].text, e.options[e.selectedIndex].title);
} else {
this.set_selectedValue('', '');
}
},
_onParentChange: function(evt, inInit) {
// Handler for the parent drop down's change event
// "evt" - set by the browser when called as an event handler (unused here)
// "inInit" - whether this is being called from the initialize method
var e = this.get_element();
// Create the known category/value pairs string for sending to the helper web service
// Follow parent pointers so that the complete state can be sent
// Format: 'name1:value1;name2:value2;...'
var knownCategoryValues = '';
var parentControlID = this._parentControlID;
while(parentControlID) {
var parentElement = $get(parentControlID);
if(parentElement && (-1 != parentElement.selectedIndex)) {
var selectedValue = parentElement.options[parentElement.selectedIndex].value;
if(selectedValue && selectedValue != "") {
knownCategoryValues = parentElement.CascadingDropDownCategory + ':' + selectedValue + ';' + knownCategoryValues;
parentControlID = parentElement.CascadingDropDownParentControlID;
continue;
}
}
break;
}
if(knownCategoryValues != '' && this._lastParentValues == knownCategoryValues) {
return;
}
this._lastParentValues = knownCategoryValues;
// we have a parent but it doesn't have a valid value
//
if(knownCategoryValues == '' && this._parentControlID) {
this._setOptions(null, inInit);
return;
}
// Show the loading text (if any)
this._setOptions(null, inInit, true);
if(this._servicePath && this._serviceMethod) {
// Raise the populating event and optionally cancel the web service invocation
var eventArgs = new Sys.CancelEventArgs();
this.raise_populating(eventArgs);
if(eventArgs.get_cancel()) {
return;
}
// Create the service parameters and optionally add the context parameter
// (thereby determining which method signature we're expecting...)
var params = { knownCategoryValues: knownCategoryValues, category: this._category };
if(this._useContextKey) {
params.contextKey = this._contextKey;
}
// Call the helper web service
Sys.Net.WebServiceProxy.invoke(this._servicePath, this._serviceMethod, this._useHttpGet, params,
Function.createDelegate(this, this._onMethodComplete), Function.createDelegate(this, this._onMethodError));
$common.updateFormToRefreshATDeviceBuffer();
}
},
_onMethodComplete: function(result, userContext, methodName) {
// Success, update the DropDownList
this._setOptions(result);
this.raise_populated(Sys.EventArgs.Empty);
},
_onMethodError: function(webServiceError, userContext, methodName) {
// Indicate failure
if(webServiceError.get_timedOut()) {
this._setOptions([this._makeNameValueObject(Sys.Extended.UI.Resources.CascadingDropDown_MethodTimeout)]);
} else {
this._setOptions([this._makeNameValueObject(String.format(Sys.Extended.UI.Resources.CascadingDropDown_MethodError, webServiceError.get_statusCode()))]);
}
},
_makeNameValueObject: function(message) {
// Create an object with name and value properties set to the provided message
// "message" - message
// "Object" - object with name and value properties set to the message
return { 'name': message, 'value': message };
},
get_parentControlID: function() {
return this._parentControlID;
},
set_parentControlID: function(value) {
if(this._parentControlID != value) {
this._parentControlID = value;
this.raisePropertyChanged('parentControlID');
}
},
get_ParentControlID: function() {
Sys.Extended.Deprecated("get_ParentControlID", "get_parentControlID");
return this.get_parentControlID();
},
set_ParentControlID: function(value) {
Sys.Extended.Deprecated("set_ParentControlID", "set_parentControlID");
this.set_parentControlID(value);
},
get_category: function() {
return this._category;
},
set_category: function(value) {
if(this._category != value) {
this._category = value;
this.raisePropertyChanged('category');
}
},
get_Category: function() {
Sys.Extended.Deprecated("get_Category", "get_category");
return this.get_category();
},
set_Category: function(value) {
Sys.Extended.Deprecated("set_Category", "set_category");
this.set_category(value);
},
get_promptText: function() {
return this._promptText;
},
set_promptText: function(value) {
if(this._promptText != value) {
this._promptText = value;
this.raisePropertyChanged('promptText');
}
},
get_PromptText: function() {
Sys.Extended.Deprecated("get_PromptText", "get_promptText");
return this.get_promptText();
},
set_PromptText: function(value) {
Sys.Extended.Deprecated("set_PromptText", "set_promptText");
this.set_promptText(value);
},
get_promptValue: function() {
// Value for the option displayed by a DropDownList showing the PromptText
return this._promptValue;
},
set_promptValue: function(value) {
if(this._promptValue != value) {
this._promptValue = value;
this.raisePropertyChanged('promptValue');
}
},
get_PromptValue: function() {
Sys.Extended.Deprecated("get_PromptValue", "get_promptValue");
return this.get_promptValue();
},
set_PromptValue: function(value) {
Sys.Extended.Deprecated("set_PromptValue", "set_promptValue");
this.set_promptValue(value);
},
get_emptyText: function() {
return this._emptyText;
},
set_emptyText: function(value) {
if(this._emptyText != value) {
this._emptyText = value;
this.raisePropertyChanged('emptyText');
}
},
get_EmptyText: function() {
Sys.Extended.Deprecated("get_EmptyText", "get_emptyText");
return this.get_emptyText();
},
set_EmptyText: function(value) {
Sys.Extended.Deprecated("set_EmptyText", "set_emptyText");
this.set_emptyText(value);
},
get_emptyValue: function() {
// Value for the option displayed when the list is empty
return this._emptyValue;
},
set_emptyValue: function(value) {
if(this._emptyValue != value) {
this._emptyValue = value;
this.raisePropertyChanged('emptyValue');
}
},
get_EmptyValue: function() {
Sys.Extended.Deprecated("get_EmptyValue", "get_emptyValue");
return this.get_emptyValue();
},
set_EmptyValue: function(value) {
Sys.Extended.Deprecated("set_EmptyValue", "set_emptyValue");
this.set_emptyValue(value);
},
get_loadingText: function() {
return this._loadingText;
},
set_loadingText: function(value) {
if(this._loadingText != value) {
this._loadingText = value;
this.raisePropertyChanged('loadingText');
}
},
get_LoadingText: function() {
Sys.Extended.Deprecated("get_LoadingText", "get_loadingText");
return this.get_loadingText();
},
set_LoadingText: function(value) {
Sys.Extended.Deprecated("set_LoadingText", "set_loadingText");
this.set_loadingText(value);
},
get_selectedValue: function() {
return this._selectedValue;
},
set_selectedValue: function (value, text, title) {
if(this._selectedValue != value) {
if(!text) {
// Initial population by server; look for "value:::text" pair
var i = value.indexOf(':::');
if(-1 != i) {
text = value.slice(i + 3);
value = value.slice(0, i);
i = text.indexOf(':::');
if(-1 != i) {
title = text.slice(i + 3);
text = text.slice(0, i);
}
}
}
var oldValue = this._selectedValue;
this._selectedValue = value;
this.raisePropertyChanged('selectedValue');
this.raise_selectionChanged(new Sys.Extended.UI.CascadingDropDownSelectionChangedEventArgs(oldValue, value));
}
Sys.Extended.UI.CascadingDropDownBehavior.callBaseMethod(this, 'set_ClientState', [this._selectedValue + ':::' + text + ':::' + (title ? (':::' + title) : '')]);
},
get_SelectedValue: function() {
Sys.Extended.Deprecated("get_SelectedValue", "get_selectedValue");
return this.get_selectedValue();
},
set_SelectedValue: function(value, text, title) {
Sys.Extended.Deprecated("set_SelectedValue(value, text, title)", "set_selectedValue(value, text, title)");
this.set_selectedValue(value, text, title);
},
get_servicePath: function() {
return this._servicePath;
},
set_servicePath: function(value) {
if(this._servicePath != value) {
this._servicePath = value;
this.raisePropertyChanged('servicePath');
}
},
get_ServicePath: function() {
Sys.Extended.Deprecated("get_ServicePath", "get_servicePath");
return this.get_servicePath();
},
set_ServicePath: function(value) {
Sys.Extended.Deprecated("set_ServicePath", "set_servicePath");
this.set_servicePath(value);
},
get_serviceMethod: function() {
return this._serviceMethod;
},
set_serviceMethod: function(value) {
if(this._serviceMethod != value) {
this._serviceMethod = value;
this.raisePropertyChanged('serviceMethod');
}
},
get_ServiceMethod: function() {
Sys.Extended.Deprecated("get_ServiceMethod", "get_serviceMethod");
return this.get_serviceMethod();
},
set_ServiceMethod: function(value) {
Sys.Extended.Deprecated("set_ServiceMethod", "set_serviceMethod");
this.set_serviceMethod(value);
},
get_contextKey: function() {
// User/page specific context provided to an optional overload of the
// web method described by ServiceMethod/ServicePath. If the context
// key is used, it should have the same signature with an additional
// parameter named contextKey of type string.
return this._contextKey;
},
set_contextKey: function(value) {
if(this._contextKey != value) {
this._contextKey = value;
this.set_useContextKey(true);
this.raisePropertyChanged('contextKey');
}
},
get_useContextKey: function() {
// Whether or not the ContextKey property should be used. This will be
// automatically enabled if the ContextKey property is ever set
// (on either the client or the server). If the context key is used,
// it should have the same signature with an additional parameter
// named contextKey of type string.
return this._useContextKey;
},
set_useContextKey: function(value) {
if(this._useContextKey != value) {
this._useContextKey = value;
this.raisePropertyChanged('useContextKey');
}
},
get_useHttpGet: function() {
return this._useHttpGet;
},
set_useHttpGet: function(value) {
if(this._useHttpGet != value) {
this._useHttpGet = value;
this.raisePropertyChanged('useHttpGet');
}
},
get_enableAtLoading: function() {
return this._enableAtLoading;
},
set_enableAtLoading: function(value) {
if(this._enableAtLoading != value) {
this._enableAtLoading = value;
this.raisePropertyChanged('enableAtLoading');
}
},
/// <summary>
/// Fires when selection is changed.
/// </summary>
/// <event add="add_selectionChanged" remove="remove_selectionChanged" raise="raise_selectionChanged" />
/// <member name="cE:AjaxControlToolkit.CascadingDropDown.selectionChanged" />
add_selectionChanged: function(handler) {
this.get_events().addHandler('selectionChanged', handler);
},
remove_selectionChanged: function(handler) {
this.get_events().removeHandler('selectionChanged', handler);
},
raise_selectionChanged: function(eventArgs) {
var handler = this.get_events().getHandler('selectionChanged');
if(handler) {
handler(this, eventArgs);
}
},
raiseSelectionChanged: function(eventArgs) {
Sys.Extended.Deprecated("raiseSelectionChanged(eventArgs)", "raise_selectionChanged(eventArgs)");
this.raise_selectionChanged(eventArgs);
},
/// <summary>
/// Fires when the control is being populated.
/// </summary>
/// <event add="add_populating" remove="remove_populating" raise="raise_populating" />
/// <member name="cE:AjaxControlToolkit.CascadingDropDown.populating" />
add_populating: function(handler) {
this.get_events().addHandler('populating', handler);
},
remove_populating: function(handler) {
this.get_events().removeHandler('populating', handler);
},
raise_populating: function(eventArgs) {
// The populating event can be used to provide custom data to
// CascadingDropDown instead of using a web service. Just cancel the
// event (using the CancelEventArgs) and pass your own data to the
// _setOptions method.
var handler = this.get_events().getHandler('populating');
if(handler) {
handler(this, eventArgs);
}
},
raisePopulating: function(eventArgs) {
Sys.Extended.Deprecated("raisePopulating(eventArgs)", "raise_populating(eventArgs)");
this.raise_populating(eventArgs);
},
/// <summary>
/// Fires after the control is populated.
/// </summary>
/// <event add="add_populated" remove="remove_populated" raise="raise_populated" />
/// <member name="cE:AjaxControlToolkit.CascadingDropDown.populated" />
add_populated: function(handler) {
this.get_events().addHandler('populated', handler);
},
remove_populated: function(handler) {
this.get_events().removeHandler('populated', handler);
},
raise_populated: function(eventArgs) {
var handler = this.get_events().getHandler('populated');
if(handler) {
handler(this, eventArgs);
}
},
raisePopulated: function(eventArgs) {
Sys.Extended.Deprecated("raisePopulated(eventArgs)", "raise_populated(eventArgs)");
this.raise_populated(eventArgs);
}
}
Sys.Extended.UI.CascadingDropDownBehavior.registerClass('Sys.Extended.UI.CascadingDropDownBehavior', Sys.Extended.UI.BehaviorBase);

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,617 @@
Type.registerNamespace('Sys.Extended.UI');
Sys.Extended.UI.ColorPickerBehavior = function(element) {
// A behavior that attaches a color picker to a textbox
Sys.Extended.UI.ColorPickerBehavior.initializeBase(this, [element]);
this._textbox = Sys.Extended.UI.TextBoxWrapper.get_Wrapper(element);
this._button = null;
this._sample = null;
this._cssClass = "ajax__colorPicker";
this._popupPosition = Sys.Extended.UI.PositioningMode.BottomLeft;
this._selectedColor = null;
this._enabled = true;
this._selectedColorChanging = false;
this._popupMouseDown = false;
this._isOpen = false;
this._blur = new Sys.Extended.UI.DeferredOperation(1, this, this._doBlur);
this._popupBehavior = null;
this._container = null;
this._popupDiv = null;
this._colorsTable = null;
this._colorsBody = null;
this._button$delegates = {
click: Function.createDelegate(this, this._button_onclick),
keypress: Function.createDelegate(this, this._button_onkeypress),
blur: Function.createDelegate(this, this._button_onblur)
};
this._element$delegates = {
change: Function.createDelegate(this, this._element_onchange),
keypress: Function.createDelegate(this, this._element_onkeypress),
click: Function.createDelegate(this, this._element_onclick),
focus: Function.createDelegate(this, this._element_onfocus),
blur: Function.createDelegate(this, this._element_onblur)
};
this._popup$delegates = {
mousedown: Function.createDelegate(this, this._popup_onmousedown),
mouseup: Function.createDelegate(this, this._popup_onmouseup),
drag: Function.createDelegate(this, this._popup_onevent),
dragstart: Function.createDelegate(this, this._popup_onevent),
select: Function.createDelegate(this, this._popup_onevent)
};
this._cell$delegates = {
mouseover: Function.createDelegate(this, this._cell_onmouseover),
mouseout: Function.createDelegate(this, this._cell_onmouseout),
click: Function.createDelegate(this, this._cell_onclick)
};
}
Sys.Extended.UI.ColorPickerBehavior.prototype = {
initialize: function() {
Sys.Extended.UI.ColorPickerBehavior.callBaseMethod(this, 'initialize');
// Store the color validation Regex in a "static" object off of
// Sys.Extended.UI.ColorPickerBehavior. If this _colorRegex object hasn't been
// created yet, initialize it for the first time.
if (!Sys.Extended.UI.ColorPickerBehavior._colorRegex) {
Sys.Extended.UI.ColorPickerBehavior._colorRegex = new RegExp('^[A-Fa-f0-9]{6}$');
}
var elt = this.get_element();
$addHandlers(elt, this._element$delegates);
if (this._button) {
$addHandlers(this._button, this._button$delegates);
}
var value = this.get_selectedColor();
if (value) {
this.set_selectedColor(value);
}
this._restoreSample();
},
dispose: function() {
this._sample = null;
if (this._button) {
$clearHandlers(this._button);
this._button = null;
}
if (this._popupBehavior) {
this._popupBehavior.dispose();
this._popupBehavior = null;
}
if (this._container) {
if (this._container.parentNode) {
this._container.parentNode.removeChild(this._container);
}
this._container = null;
}
if (this._popupDiv) {
$clearHandlers(this._popupDiv);
this._popupDiv = null;
}
if (this._colorsBody) {
for (var i = 0; i < this._colorsBody.rows.length; i++) {
var row = this._colorsBody.rows[i];
for (var j = 0; j < row.cells.length; j++) {
$clearHandlers(row.cells[j].firstChild);
}
}
this._colorsBody = null;
}
this._colorsTable = null;
var elt = this.get_element();
if (elt) {
$clearHandlers(elt);
}
Sys.Extended.UI.ColorPickerBehavior.callBaseMethod(this, 'dispose');
},
/// <summary>
/// The Sys.UI.DomElement object that represents a button to use to show the color picker.
/// </summary>
/// <remarks>
/// This property is optional.
/// </remarks>
/// <getter>get_button</getter>
/// <setter>set_button</setter>
/// <member name="cP:AjaxControlToolkit.ColorPickerExtender.button" />
get_button: function() {
// The button to use to show the color picker (optional)
return this._button;
},
set_button: function(value) {
if (this._button !== value) {
if (this._button && this.get_isInitialized()) {
$common.removeHandlers(this._button, this._button$delegates);
}
this._button = value;
if (this._button && this.get_isInitialized()) {
$addHandlers(this._button, this._button$delegates);
}
this.raisePropertyChanged("button");
}
},
/// <summary>
/// The Sys.UI.DomElement object that represents an element to use to preview the color that is currently selected or over which a user is holding the mouse pointer.
/// </summary>
/// <remarks>
/// This property is optional.
/// </remarks>
/// <getter>get_sample</getter>
/// <setter>set_sample</setter>
/// <member name="cP:AjaxControlToolkit.ColorPickerExtender.sample" />
get_sample: function() {
// The element is to sample the color currently being hovered or selected (optional)
return this._sample;
},
set_sample: function(value) {
if (this._sample !== value) {
this._sample = value;
this.raisePropertyChanged("sample");
}
},
/// <summary>
/// A string that contains a color value that is represented by the text box.
/// </summary>
/// <getter>get_selectedColor</getter>
/// <setter>set_selectedColor</setter>
/// <member name="cP:AjaxControlToolkit.ColorPickerExtender.selectedColor" />
get_selectedColor: function() {
if (this._selectedColor === null) {
var value = this._textbox.get_Value();
if (this._validate(value)) {
this._selectedColor = value;
}
}
return this._selectedColor;
},
set_selectedColor: function(value) {
if (this._selectedColor !== value && this._validate(value)) {
this._selectedColor = value;
this._selectedColorChanging = true;
if (value !== this._textbox.get_Value()) {
this._textbox.set_Value(value);
}
this._showSample(value);
this._selectedColorChanging = false;
this.raisePropertyChanged("selectedColor");
}
},
/// <summary>
/// A Boolean value that specifies whether or not ColorPicker behavior is available for the current element.
/// </summary>
/// <getter>get_enabled</getter>
/// <setter>set_enabled</setter>
/// <member name="cP:AjaxControlToolkit.ColorPickerExtender.enabled" />
get_enabled: function() {
// Whether this behavior is available for the current element
return this._enabled;
},
set_enabled: function(value) {
if (this._enabled !== value) {
this._enabled = value;
this.raisePropertyChanged("enabled");
}
},
/// <summary>
/// The Sys.Extended.UI.PositionMode object that represents where the popup should be positioned relative to the target control.
/// The default is BottomLeft.
/// </summary>
/// <getter>get_popupPosition</getter>
/// <setter>set_popupPosition</setter>
/// <member name="cP:AjaxControlToolkit.ColorPickerExtender.popupPosition" />
get_popupPosition: function() {
// Where the popup should be positioned relative to the target control.
return this._popupPosition;
},
set_popupPosition: function(value) {
if (this._popupPosition !== value) {
this._popupPosition = value;
this.raisePropertyChanged('popupPosition');
}
},
/// <summary>
/// Fires when color selection is changed.
/// </summary>
/// <event add="add_colorSelectionChanged" remove="remove_colorSelectionChanged" raise="raise_colorSelectionChanged" />
/// <member name="cE:AjaxControlToolkit.ColorPickerExtender.colorSelectionChanged" />
add_colorSelectionChanged: function(handler) {
this.get_events().addHandler("colorSelectionChanged", handler);
},
remove_colorSelectionChanged: function(handler) {
this.get_events().removeHandler("colorSelectionChanged", handler);
},
raise_colorSelectionChanged: function() {
var handlers = this.get_events().getHandler("colorSelectionChanged");
if (handlers) {
handlers(this, Sys.EventArgs.Empty);
}
},
raiseColorSelectionChanged: function() {
Sys.Extended.Deprecated("raiseColorSelectionChanged", "raise_colorSelectionChanged");
this.raise_colorSelectionChanged();
},
/// <summary>
/// Fires when the control is being shown.
/// </summary>
/// <event add="add_showing" remove="remove_showing" raise="raise_showing" />
/// <member name="cE:AjaxControlToolkit.ColorPickerExtender.showing" />
add_showing: function(handler) {
this.get_events().addHandler("showing", handler);
},
remove_showing: function(handler) {
this.get_events().removeHandler("showing", handler);
},
raise_showing: function(eventArgs) {
var handler = this.get_events().getHandler('showing');
if (handler) {
handler(this, eventArgs);
}
},
raiseShowing: function(eventArgs) {
Sys.Extended.Deprecated("raiseShowing", "raise_showing");
this.raise_showing(eventArgs);
},
/// <summary>
/// Fires after the control is shown.
/// </summary>
/// <event add="add_shown" remove="remove_shown" raise="raise_shown" />
/// <member name="cE:AjaxControlToolkit.ColorPickerExtender.shown" />
add_shown: function(handler) {
this.get_events().addHandler("shown", handler);
},
remove_shown: function(handler) {
this.get_events().removeHandler("shown", handler);
},
raise_shown: function() {
var handlers = this.get_events().getHandler("shown");
if (handlers) {
handlers(this, Sys.EventArgs.Empty);
}
},
raiseShown: function() {
Sys.Extended.Deprecated("raiseShown", "raise_shown");
this.raise_shown();
},
/// <summary>
/// Fires when the control is being hidden.
/// </summary>
/// <event add="add_hiding" remove="remove_hiding" raise="raise_hiding" />
/// <member name="cE:AjaxControlToolkit.ColorPickerExtender.hiding" />
add_hiding: function(handler) {
this.get_events().addHandler("hiding", handler);
},
remove_hiding: function(handler) {
this.get_events().removeHandler("hiding", handler);
},
raise_hiding: function(eventArgs) {
var handler = this.get_events().getHandler('hiding');
if (handler) {
handler(this, eventArgs);
}
},
raiseHiding: function(eventArgs) {
Sys.Extended.Deprecated("raiseHiding", "raise_hiding");
this.raise_hiding(eventArgs);
},
/// <summary>
/// Fires after the control is hidden.
/// </summary>
/// <event add="add_hidden" remove="remove_hidden" raise="raise_hidden" />
/// <member name="cE:AjaxControlToolkit.ColorPickerExtender.hidden" />
add_hidden: function(handler) {
this.get_events().addHandler("hidden", handler);
},
remove_hidden: function(handler) {
this.get_events().removeHandler("hidden", handler);
},
raise_hidden: function() {
var handlers = this.get_events().getHandler("hidden");
if (handlers) {
handlers(this, Sys.EventArgs.Empty);
}
},
raiseHidden: function() {
Sys.Extended.Deprecated("raiseHidden", "raise_hidden");
this.raise_hidden();
},
/// <summary>
/// Shows the color picker.
/// </summary>
/// <member name="cM:AjaxControlToolkit.ColorPickerExtender.show" />
show: function() {
this._ensureColorPicker();
if (!this._isOpen) {
var eventArgs = new Sys.CancelEventArgs();
this.raiseShowing(eventArgs);
if (eventArgs.get_cancel()) {
return;
}
this._isOpen = true;
this._popupBehavior.show();
this.raiseShown();
}
},
/// <summary>
/// Hides the color picker.
/// </summary>
/// <member name="cM:AjaxControlToolkit.ColorPickerExtender.hide" />
hide: function() {
if (this._isOpen) {
var eventArgs = new Sys.CancelEventArgs();
this.raiseHiding(eventArgs);
if (eventArgs.get_cancel()) {
return;
}
if (this._container) {
this._popupBehavior.hide();
}
this._isOpen = false;
this.raiseHidden();
// make sure we clean up the flag due to issues with alert/alt-tab/etc
this._popupMouseDown = false;
}
},
_focus: function() {
if (this._button) {
this._button.focus();
} else {
this.get_element().focus();
}
},
_doBlur: function(force) {
if (!force && Sys.Browser.agent === Sys.Browser.Opera) {
this._blur.post(true);
} else {
if (!this._popupMouseDown) {
this.hide();
}
// make sure we clean up the flag due to issues with alert/alt-tab/etc
this._popupMouseDown = false;
}
},
_buildColorPicker: function() {
// Builds the color picker's layout
var elt = this.get_element();
var id = this.get_id();
this._container = $common.createElementFromTemplate({
nodeName: "div",
properties: { id: id + "_container" },
cssClasses: [this._cssClass]
}, elt.parentNode);
this._popupDiv = $common.createElementFromTemplate({
nodeName: "div",
events: this._popup$delegates,
properties: {
id: id + "_popupDiv"
},
cssClasses: ["ajax__colorPicker_container"],
visible: false
}, this._container);
},
_buildColors: function() {
// Builds a table of colors for the popup
var id = this.get_id();
this._colorsTable = $common.createElementFromTemplate({
nodeName: "table",
properties: {
id: id + "_colorsTable",
style: { margin: "auto" }
}
}, this._popupDiv);
this._colorsBody = $common.createElementFromTemplate({
nodeName: "tbody",
properties: { id: id + "_colorsBody" }
}, this._colorsTable);
var rgb = ['00', '99', '33', '66', 'FF', 'CC'], color, cssColor;
var l = rgb.length;
for (var r = 0; r < l; r++) {
var colorsRow = $common.createElementFromTemplate({ nodeName: "tr" }, this._colorsBody);
for (var g = 0; g < l; g++) {
if (g === 3) {
colorsRow = $common.createElementFromTemplate({ nodeName: "tr" }, this._colorsBody);
}
for (var b = 0; b < l; b++) {
color = rgb[r] + rgb[g] + rgb[b];
cssColor = '#' + color;
var colorCell = $common.createElementFromTemplate({ nodeName: "td" }, colorsRow);
var colorDiv = $common.createElementFromTemplate({
nodeName: "div",
properties: {
id: id + "_color_" + color,
color: color,
title: cssColor,
style: { backgroundColor: cssColor },
innerHTML: "&nbsp;"
},
events: this._cell$delegates
}, colorCell);
}
}
}
},
_ensureColorPicker: function() {
if (!this._container) {
var elt = this.get_element();
this._buildColorPicker();
this._buildColors();
this._popupBehavior = new $create(Sys.Extended.UI.PopupBehavior, { parentElement: elt }, {}, {}, this._popupDiv);
this._popupBehavior.set_positioningMode(this._popupPosition);
}
},
_showSample: function(value) {
if (this._sample) {
var color = "";
if (value) {
color = "#" + value;
}
this._sample.style.backgroundColor = color;
}
},
_restoreSample: function() {
this._showSample(this._selectedColor);
},
_validate: function(value) {
return value && Sys.Extended.UI.ColorPickerBehavior._colorRegex.test(value);
},
_element_onfocus: function(e) {
if (!this._enabled) { return; }
if (!this._button) {
this.show();
// make sure we clean up the flag due to issues with alert/alt-tab/etc
this._popupMouseDown = false;
}
},
_element_onblur: function(e) {
if (!this._enabled) { return; }
if (!this._button) {
this._doBlur();
}
},
_element_onchange: function(e) {
if (!this._selectedColorChanging) {
var value = this._textbox.get_Value();
if (this._validate(value) || value === "") {
this._selectedColor = value;
this._restoreSample();
}
}
},
_element_onkeypress: function(e) {
if (!this._enabled) { return; }
if (!this._button && e.charCode === Sys.UI.Key.esc) {
e.stopPropagation();
e.preventDefault();
this.hide();
}
},
_element_onclick: function(e) {
if (!this._enabled) { return; }
if (!this._button) {
this.show();
// make sure we clean up the flag due to issues with alert/alt-tab/etc
this._popupMouseDown = false;
}
},
_popup_onevent: function(e) {
e.stopPropagation();
e.preventDefault();
},
_popup_onmousedown: function(e) {
// signal that the popup has received a mousedown event, this handles
// onblur issues on browsers like FF, OP, and SF
this._popupMouseDown = true;
},
_popup_onmouseup: function(e) {
// signal that the popup has received a mouseup event, this handles
// onblur issues on browsers like FF, OP, and SF
if (Sys.Browser.agent === Sys.Browser.Opera && this._blur.get_isPending()) {
this._blur.cancel();
}
this._popupMouseDown = false;
this._focus();
},
_cell_onmouseover: function(e) {
e.stopPropagation();
var target = e.target;
this._showSample(target.color);
},
_cell_onmouseout: function(e) {
e.stopPropagation();
this._restoreSample();
},
_cell_onclick: function(e) {
e.stopPropagation();
e.preventDefault();
if (!this._enabled) {
return;
}
var target = e.target;
this.set_selectedColor(target.color);
this._blur.post(true);
this.raise_colorSelectionChanged();
},
_button_onclick: function(e) {
e.preventDefault();
e.stopPropagation();
if (!this._enabled) {
return;
}
if (!this._isOpen) {
this.show();
} else {
this.hide();
}
this._focus();
// make sure we clean up the flag due to issues with alert/alt-tab/etc
this._popupMouseDown = false;
},
_button_onblur: function(e) {
if (!this._enabled) {
return;
}
if (!this._popupMouseDown) {
this.hide();
}
// make sure we clean up the flag due to issues with alert/alt-tab/etc
this._popupMouseDown = false;
},
_button_onkeypress: function(e) {
if (!this._enabled) {
return;
}
if (e.charCode === Sys.UI.Key.esc) {
e.stopPropagation();
e.preventDefault();
this.hide();
}
// make sure we clean up the flag due to issues with alert/alt-tab/etc
this._popupMouseDown = false;
}
}
Sys.Extended.UI.ColorPickerBehavior.registerClass('Sys.Extended.UI.ColorPickerBehavior', Sys.Extended.UI.BehaviorBase);

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,335 @@
Type.registerNamespace("Sys.Extended.UI");
Sys.Extended.UI.TimeSpan = function() {
// Represents a period of time
if (arguments.length == 0) this._ctor$0.apply(this, arguments);
else if (arguments.length == 1) this._ctor$1.apply(this, arguments);
else if (arguments.length == 3) this._ctor$2.apply(this, arguments);
else if (arguments.length == 4) this._ctor$3.apply(this, arguments);
else if (arguments.length == 5) this._ctor$4.apply(this, arguments);
else throw Error.parameterCount();
}
Sys.Extended.UI.TimeSpan.prototype = {
_ctor$0 : function() {
this._ticks = 0;
},
_ctor$1 : function(ticks) {
this._ctor$0();
this._ticks = ticks;
},
_ctor$2 : function(hours, minutes, seconds) {
this._ctor$0();
this._ticks =
(hours * Sys.Extended.UI.TimeSpan.TicksPerHour) +
(minutes * Sys.Extended.UI.TimeSpan.TicksPerMinute) +
(seconds * Sys.Extended.UI.TimeSpan.TicksPerSecond);
},
_ctor$3 : function(days, hours, minutes, seconds) {
this._ctor$0();
this._ticks =
(days * Sys.Extended.UI.TimeSpan.TicksPerDay) +
(hours * Sys.Extended.UI.TimeSpan.TicksPerHour) +
(minutes * Sys.Extended.UI.TimeSpan.TicksPerMinute) +
(seconds * Sys.Extended.UI.TimeSpan.TicksPerSecond);
},
_ctor$4 : function(days, hours, minutes, seconds, milliseconds) {
this._ctor$0();
this._ticks =
(days * Sys.Extended.UI.TimeSpan.TicksPerDay) +
(hours * Sys.Extended.UI.TimeSpan.TicksPerHour) +
(minutes * Sys.Extended.UI.TimeSpan.TicksPerMinute) +
(seconds * Sys.Extended.UI.TimeSpan.TicksPerSecond) +
(milliseconds * Sys.Extended.UI.TimeSpan.TicksPerMillisecond);
},
getDays : function() {
return Math.floor(this._ticks / Sys.Extended.UI.TimeSpan.TicksPerDay);
},
getHours : function() {
return Math.floor(this._ticks / Sys.Extended.UI.TimeSpan.TicksPerHour) % 24;
},
getMinutes : function() {
return Math.floor(this._ticks / Sys.Extended.UI.TimeSpan.TicksPerMinute) % 60;
},
getSeconds : function() {
return Math.floor(this._ticks / Sys.Extended.UI.TimeSpan.TicksPerSecond) % 60;
},
getMilliseconds : function() {
return Math.floor(this._ticks / Sys.Extended.UI.TimeSpan.TicksPerMillisecond) % 1000;
},
getDuration : function() {
return new Sys.Extended.UI.TimeSpan(Math.abs(this._ticks));
},
getTicks : function() {
return this._ticks;
},
getTotalDays : function() {
Math.floor(this._ticks / Sys.Extended.UI.TimeSpan.TicksPerDay);
},
getTotalHours : function() {
return Math.floor(this._ticks / Sys.Extended.UI.TimeSpan.TicksPerHour);
},
getTotalMinutes : function() {
return Math.floor(this._ticks / Sys.Extended.UI.TimeSpan.TicksPerMinute);
},
getTotalSeconds : function() {
return Math.floor(this._ticks / Sys.Extended.UI.TimeSpan.TicksPerSecond);
},
getTotalMilliseconds : function() {
return Math.floor(this._ticks / Sys.Extended.UI.TimeSpan.TicksPerMillisecond);
},
add : function(value) {
// Adds the supplied TimeSpan to this TimeSpan
return new Sys.Extended.UI.TimeSpan(this._ticks + value.getTicks());
},
subtract : function(value) {
// Subtracts the supplied TimeSpan to this TimeSpan
return new Sys.Extended.UI.TimeSpan(this._ticks - value.getTicks());
},
negate : function() {
// Negates the TimeSpan
return new Sys.Extended.UI.TimeSpan(-this._ticks);
},
equals : function(value) {
// Whether this TimeSpan equals another TimeSpan
return this._ticks == value.getTicks();
},
compareTo : function(value) {
// Whether this TimeSpan greater or less than another TimeSpan
if(this._ticks > value.getTicks())
return 1;
else if(this._ticks < value.getTicks())
return -1;
else
return 0;
},
toString : function() {
return this.format("F");
},
format : function(format) {
if (!format) {
format = "F";
}
if (format.length == 1) {
switch (format) {
case "t": format = Sys.Extended.UI.TimeSpan.ShortTimeSpanPattern; break;
case "T": format = Sys.Extended.UI.TimeSpan.LongTimeSpanPattern; break;
case "F": format = Sys.Extended.UI.TimeSpan.FullTimeSpanPattern; break;
default: throw Error.createError(String.format(Sys.Extended.UI.Resources.Common_DateTime_InvalidTimeSpan, format));
}
}
var regex = /dd|d|hh|h|mm|m|ss|s|nnnn|nnn|nn|n/g;
var builder = new Sys.StringBuilder();
var ticks = this._ticks;
if (ticks < 0) {
builder.append("-");
ticks = -ticks;
}
for (;;) {
var index = regex.lastIndex;
var ar = regex.exec(format);
builder.append(format.slice(index, ar ? ar.index : format.length));
if (!ar) break;
switch (ar[0]) {
case "dd":
case "d":
builder.append($common.padLeft(Math.floor(ticks / Sys.Extended.UI.TimeSpan.TicksPerDay, ar[0].length, '0')));
break;
case "hh":
case "h":
builder.append($common.padLeft(Math.floor(ticks / Sys.Extended.UI.TimeSpan.TicksPerHour) % 24, ar[0].length, '0'));
break;
case "mm":
case "m":
builder.append($common.padLeft(Math.floor(ticks / Sys.Extended.UI.TimeSpan.TicksPerMinute) % 60, ar[0].length, '0'));
break;
case "ss":
case "s":
builder.append($common.padLeft(Math.floor(ticks / Sys.Extended.UI.TimeSpan.TicksPerSecond) % 60, ar[0].length, '0'));
break;
case "nnnn":
case "nnn":
case "nn":
case "n":
builder.append($common.padRight(Math.floor(ticks / Sys.Extended.UI.TimeSpan.TicksPerMillisecond) % 1000, ar[0].length, '0', true));
break;
default:
Sys.Debug.assert(false);
}
}
return builder.toString();
}
}
Sys.Extended.UI.TimeSpan.parse = function(text) {
// Parses a text value into a TimeSpan
var parts = text.split(":");
var d = 0;
var h = 0;
var m = 0;
var s = 0;
var n = 0;
var ticks = 0;
switch(parts.length) {
case 1:
if (parts[0].indexOf(".") != -1) {
var parts2 = parts[0].split(".");
s = parseInt(parts2[0]);
n = parseInt(parts2[1]);
} else {
ticks = parseInt(parts[0]);
}
break;
case 2:
h = parseInt(parts[0]);
m = parseInt(parts[1]);
break;
case 3:
h = parseInt(parts[0]);
m = parseInt(parts[1]);
if (parts[2].indexOf(".") != -1) {
var parts2 = parts[2].split(".");
s = parseInt(parts2[0]);
n = parseInt(parts2[1]);
} else {
s = parseInt(parts[2]);
}
break;
case 4:
d = parseInt(parts[0]);
h = parseInt(parts[1]);
m = parseInt(parts[2]);
if (parts[3].indexOf(".") != -1) {
var parts2 = parts[3].split(".");
s = parseInt(parts2[0]);
n = parseInt(parts2[1]);
} else {
s = parseInt(parts[3]);
}
break;
}
ticks += (d * Sys.Extended.UI.TimeSpan.TicksPerDay) +
(h * Sys.Extended.UI.TimeSpan.TicksPerHour) +
(m * Sys.Extended.UI.TimeSpan.TicksPerMinute) +
(s * Sys.Extended.UI.TimeSpan.TicksPerSecond) +
(n * Sys.Extended.UI.TimeSpan.TicksPerMillisecond);
if(!isNaN(ticks)) {
return new Sys.Extended.UI.TimeSpan(ticks);
}
throw Error.create(Sys.Extended.UI.Resources.Common_DateTime_InvalidFormat);
}
Sys.Extended.UI.TimeSpan.fromTicks = function(ticks) {
// Creates a TimeSpan for the specified number of ticks
return new Sys.Extended.UI.TimeSpan(ticks);
}
Sys.Extended.UI.TimeSpan.fromDays = function(days) {
// Creates a TimeSpan for the specified number of days
return new Sys.Extended.UI.TimeSpan(days * Sys.Extended.UI.TimeSpan.TicksPerDay);
}
Sys.Extended.UI.TimeSpan.fromHours = function(hours) {
// Creates a TimeSpan for the specified number of hours
return new Sys.Extended.UI.TimeSpan(hours * Sys.Extended.UI.TimeSpan.TicksPerHour);
}
Sys.Extended.UI.TimeSpan.fromMinutes = function(minutes) {
// Creates a TimeSpan for the specified number of minutes
return new Sys.Extended.UI.TimeSpan(minutes * Sys.Extended.UI.TimeSpan.TicksPerMinute);
}
Sys.Extended.UI.TimeSpan.fromSeconds = function(seconds) {
// Creates a TimeSpan for the specified number of seconds
return new Sys.Extended.UI.TimeSpan(minutes * Sys.Extended.UI.TimeSpan.TicksPerSecond);
}
Sys.Extended.UI.TimeSpan.fromMilliseconds = function(milliseconds) {
// Creates a TimeSpan for the specified number of milliseconds
return new Sys.Extended.UI.TimeSpan(minutes * Sys.Extended.UI.TimeSpan.TicksPerMillisecond);
}
Sys.Extended.UI.TimeSpan.TicksPerDay = 864000000000;
Sys.Extended.UI.TimeSpan.TicksPerHour = 36000000000;
Sys.Extended.UI.TimeSpan.TicksPerMinute = 600000000;
Sys.Extended.UI.TimeSpan.TicksPerSecond = 10000000;
Sys.Extended.UI.TimeSpan.TicksPerMillisecond = 10000;
Sys.Extended.UI.TimeSpan.FullTimeSpanPattern = "dd:hh:mm:ss.nnnn";
Sys.Extended.UI.TimeSpan.ShortTimeSpanPattern = "hh:mm";
Sys.Extended.UI.TimeSpan.LongTimeSpanPattern = "hh:mm:ss";
Date.prototype.getTimeOfDay = function Date$getTimeOfDay() {
// Gets a TimeSpan representing the current time of the Date
return new Sys.Extended.UI.TimeSpan(
0,
this.getHours(),
this.getMinutes(),
this.getSeconds(),
this.getMilliseconds());
}
Date.prototype.getDateOnly = function Date$getDateOnly() {
// Gets a Date representing the Date only part of the Date and Adjusts for DST switch at midnight.
var tempDate = new Date(this.getFullYear(), this.getMonth(), this.getDate());
if (!((this.getMonth() === tempDate.getMonth()) && (this.getDate() === tempDate.getDate()))) {
tempDate.setMinutes(120);
}
return tempDate;
}
Date.prototype.add = function Date$add(span) {
// Adds a TimeSpan to the current Date
// param "span"is the amount of time to add to the date
return new Date(this.getTime() + span.getTotalMilliseconds());
}
Date.prototype.subtract = function Date$subtract(span) {
// Subtracts a TimeSpan to the current Date
// param "span" is the amount of time to subtract from the date
return this.add(span.negate());
}
Date.prototype.getTicks = function Date$getTicks() {
return this.getTime() * Sys.Extended.UI.TimeSpan.TicksPerMillisecond;
}
Sys.Extended.UI.FirstDayOfWeek = function() {
}
Sys.Extended.UI.FirstDayOfWeek.prototype = {
Sunday : 0,
Monday : 1,
Tuesday : 2,
Wednesday : 3,
Thursday : 4,
Friday : 5,
Saturday : 6,
Default : 7
}
Sys.Extended.UI.FirstDayOfWeek.registerEnum("Sys.Extended.UI.FirstDayOfWeek");
(function(){
var D= new Date('2011-06-02T09:34:29+02:00');
if(!D || +D!== 1307000069000){
Date.fromISO= function(s){
var day, tz,
rx=/^(\d{4}\-\d\d\-\d\d([tT ][\d:\.]*)?)([zZ]|([+\-])(\d\d):(\d\d))?$/,
p= rx.exec(s) || [];
if(p[1]){
day= p[1].split(/\D/);
for(var i= 0, L= day.length; i<L; i++){
day[i]= parseInt(day[i], 10) || 0;
};
day[1]-= 1;
day= new Date(Date.UTC.apply(Date, day));
if(!day.getDate()) return NaN;
if(p[5]){
tz= (parseInt(p[5], 10)*60);
if(p[6]) tz+= parseInt(p[6], 10);
if(p[4]== '+') tz*= -1;
if(tz) day.setUTCMinutes(day.getUTCMinutes()+ tz);
}
return day;
}
return NaN;
}
}
else{
Date.fromISO= function(s){
return new Date(s);
}
}
})()

View File

@@ -0,0 +1,191 @@
Type.registerNamespace('Sys.Extended.UI');
Sys.Extended.UI.DeferredOperation = function(delay, context, callback) {
// Used to define a cancellable async operation
// "delay" - the number of milliseconds to delay execution
// "context" - an object used as the context for the callback method
// "callback" - the callback method to execute at the end of the delay
this._delay = delay;
this._context = context;
this._callback = callback;
this._completeCallback = null;
this._errorCallback = null;
this._timer = null;
this._callArgs = null;
this._isComplete = false;
this._completedSynchronously = false;
this._asyncResult = null;
this._exception = null;
this._throwExceptions = true;
this._oncomplete$delegate = Function.createDelegate(this, this._oncomplete);
// post to ensure that attaching it always gets the port as its context
this.post = Function.createDelegate(this, this.post);
}
Sys.Extended.UI.DeferredOperation.prototype = {
get_isPending: function() {
return (this._timer != null);
},
get_isComplete: function() {
return this._isComplete;
},
get_completedSynchronously: function() {
return this._completedSynchronously;
},
get_exception: function() {
return this._exception;
},
get_throwExceptions: function() {
return this._throwExceptions;
},
set_throwExceptions: function(value) {
// Sets whether to throw exceptions
this._throwExceptions = value;
},
get_delay: function() {
// Gets the current delay in milliseconds
return this._delay;
},
set_delay: function(value) {
// Sets the current delay in milliseconds
this._delay = value;
},
post: function(args) {
// A method that can be directly attached to a delegate
var ar = [];
for(var i = 0; i < arguments.length; i++)
ar[i] = arguments[i];
this.beginPost(ar, null, null);
},
beginPost: function(args, completeCallback, errorCallback) {
// Posts a call to an async operation on this port
// cancel any pending post
this.cancel();
// cache the call arguments
this._callArgs = Array.clone(args || []);
this._completeCallback = completeCallback;
this._errorCallback = errorCallback;
if(this._delay == -1) {
// if there is no delay (-1), complete synchronously
try {
this._oncomplete();
} finally {
this._completedSynchronously = true;
}
} else {
// complete the post on a seperate call after a delay
this._timer = setTimeout(this._oncomplete$delegate, this._delay);
}
},
cancel: function() {
if(this._timer) {
clearTimeout(this._timer);
this._timer = null;
}
this._callArgs = null;
this._isComplete = false;
this._asyncResult = null;
this._completeCallback = null;
this._errorCallback = null;
this._exception = null;
this._completedSynchronously = false;
},
call: function(args) {
// Executes the deferred operation synchronously
var ar = [];
for(var i = 0; i < arguments.length; i++)
ar[i] = arguments[i];
// cancel any pending post
this.cancel();
// cache the call arguments
this._callArgs = ar;
this._completeCallback = null;
this._errorCallback = null;
try {
this._oncomplete();
} finally {
this._completedSynchronously = true;
}
if(this._exception)
throw this._exception;
return this._asyncResult;
},
complete: function() {
// Completes a pending post synchronously
if(this._timer) {
try {
this._oncomplete();
} finally {
this._completedSynchronously = true;
}
return this._asyncResult;
} else if(this._isComplete) {
return this._asyncResult;
}
},
_oncomplete: function() {
// Completes a pending post asynchronously
var args = this._callArgs,
completeCallback = this._completeCallback,
errorCallback = this._errorCallback;
// clear the post state
this.cancel();
try {
// call the post callback
if(args)
this._asyncResult = this._callback.apply(this._context, args);
else
this._asyncResult = this._callback.call(this._context);
this._isComplete = true;
this._completedSynchronously = false;
if(completeCallback)
completeCallback(this);
} catch(e) {
this._isComplete = true;
this._completedSynchronously = false;
this._exception = e;
if(errorCallback)
if(errorCallback(this))
return;
if(this._throwExceptions)
throw e;
}
}
}
Sys.Extended.UI.DeferredOperation.registerClass("Sys.Extended.UI.DeferredOperation");

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,833 @@
Type.registerNamespace('Sys.Extended.UI');
Sys.Extended.UI.IDragSource = function() {
}
Sys.Extended.UI.IDragSource.prototype = {
// Type get_dragDataType()
get_dragDataType: function() { throw Error.notImplemented(); },
// Object getDragData(Context)
getDragData: function() { throw Error.notImplemented(); },
// DragMode get_dragMode()
get_dragMode: function() { throw Error.notImplemented(); },
// void onDragStart()
onDragStart: function() { throw Error.notImplemented(); },
// void onDrag()
onDrag: function() { throw Error.notImplemented(); },
// void onDragEnd(Cancelled)
onDragEnd: function() { throw Error.notImplemented(); }
}
Sys.Extended.UI.IDragSource.registerInterface('Sys.Extended.UI.IDragSource');
Sys.Extended.UI.IDropTarget = function() {
}
Sys.Extended.UI.IDropTarget.prototype = {
get_dropTargetElement: function() { throw Error.notImplemented(); },
// bool canDrop(DragMode, DataType, Data)
canDrop: function() { throw Error.notImplemented(); },
// void drop(DragMode, DataType, Data)
drop: function() { throw Error.notImplemented(); },
// void onDragEnterTarget(DragMode, DataType, Data)
onDragEnterTarget: function() { throw Error.notImplemented(); },
// void onDragLeaveTarget(DragMode, DataType, Data)
onDragLeaveTarget: function() { throw Error.notImplemented(); },
// void onDragInTarget(DragMode, DataType, Data)
onDragInTarget: function() { throw Error.notImplemented(); }
}
Sys.Extended.UI.IDropTarget.registerInterface('Sys.Extended.UI.IDropTarget');
Sys.Extended.UI.DragMode = function() {
throw Error.invalidOperation();
}
Sys.Extended.UI.DragMode.prototype = {
Copy: 0,
Move: 1
}
Sys.Extended.UI.DragMode.registerEnum('Sys.Extended.UI.DragMode');
Sys.Extended.UI.DragDropEventArgs = function(dragMode, dragDataType, dragData) {
this._dragMode = dragMode;
this._dataType = dragDataType;
this._data = dragData;
}
Sys.Extended.UI.DragDropEventArgs.prototype = {
get_dragMode: function() {
return this._dragMode || null;
},
get_dragDataType: function() {
return this._dataType || null;
},
get_dragData: function() {
return this._data || null;
}
}
Sys.Extended.UI.DragDropEventArgs.registerClass('Sys.Extended.UI.DragDropEventArgs');
Sys.Extended.UI._DragDropManager = function() {
this._instance = null;
this._events = null;
}
Sys.Extended.UI._DragDropManager.prototype = {
add_dragStart: function(handler) {
this.get_events().addHandler('dragStart', handler);
},
remove_dragStart: function(handler) {
this.get_events().removeHandler('dragStart', handler);
},
get_events: function() {
if(!this._events)
this._events = new Sys.EventHandlerList();
return this._events;
},
add_dragStop: function(handler) {
this.get_events().addHandler('dragStop', handler);
},
remove_dragStop: function(handler) {
this.get_events().removeHandler('dragStop', handler);
},
_getInstance: function() {
if(!this._instance) {
if(Sys.Browser.agent === Sys.Browser.InternetExplorer)
this._instance = new Sys.Extended.UI.IEDragDropManager();
else
this._instance = new Sys.Extended.UI.GenericDragDropManager();
this._instance.initialize();
this._instance.add_dragStart(Function.createDelegate(this, this._raiseDragStart));
this._instance.add_dragStop(Function.createDelegate(this, this._raiseDragStop));
}
return this._instance;
},
startDragDrop: function(dragSource, dragVisual, context, useBuiltInDragAndDropFunctions) {
this._getInstance().startDragDrop(dragSource, dragVisual, context, useBuiltInDragAndDropFunctions);
},
registerDropTarget: function(target) {
this._getInstance().registerDropTarget(target);
},
unregisterDropTarget: function(target) {
this._getInstance().unregisterDropTarget(target);
},
dispose: function() {
delete this._events;
Sys.Application.unregisterDisposableObject(this);
Sys.Application.removeComponent(this);
},
_raiseDragStart: function(sender, eventArgs) {
var handler = this.get_events().getHandler('dragStart');
if(handler)
handler(this, eventArgs);
},
_raiseDragStop: function(sender, eventArgs) {
var handler = this.get_events().getHandler('dragStop');
if(handler)
handler(this, eventArgs);
}
}
Sys.Extended.UI._DragDropManager.registerClass('Sys.Extended.UI._DragDropManager');
Sys.Extended.UI.DragDropManager = new Sys.Extended.UI._DragDropManager();
Sys.Extended.UI.IEDragDropManager = function() {
Sys.Extended.UI.IEDragDropManager.initializeBase(this);
this._dropTargets = null;
// Radius of the cursor used to determine what drop target we
// are hovering. Anything below the cursor's zone may be a
// potential drop target.
this._radius = 10;
this._useBuiltInDragAndDropFunctions = true;
this._activeDragVisual = null;
this._activeContext = null;
this._activeDragSource = null;
this._underlyingTarget = null;
this._oldOffset = null;
this._potentialTarget = null;
this._isDragging = false;
this._mouseUpHandler = null;
this._documentMouseMoveHandler = null;
this._documentDragOverHandler = null;
this._dragStartHandler = null;
this._mouseMoveHandler = null;
this._dragEnterHandler = null;
this._dragLeaveHandler = null;
this._dragOverHandler = null;
this._dropHandler = null;
}
Sys.Extended.UI.IEDragDropManager.prototype = {
add_dragStart: function(handler) {
this.get_events().addHandler("dragStart", handler);
},
remove_dragStart: function(handler) {
this.get_events().removeHandler("dragStart", handler);
},
add_dragStop: function(handler) {
this.get_events().addHandler("dragStop", handler);
},
remove_dragStop: function(handler) {
this.get_events().removeHandler("dragStop", handler);
},
initialize: function() {
Sys.Extended.UI.IEDragDropManager.callBaseMethod(this, 'initialize');
this._mouseUpHandler = Function.createDelegate(this, this._onMouseUp);
this._documentMouseMoveHandler = Function.createDelegate(this, this._onDocumentMouseMove);
this._documentDragOverHandler = Function.createDelegate(this, this._onDocumentDragOver);
this._dragStartHandler = Function.createDelegate(this, this._onDragStart);
this._mouseMoveHandler = Function.createDelegate(this, this._onMouseMove);
this._dragEnterHandler = Function.createDelegate(this, this._onDragEnter);
this._dragLeaveHandler = Function.createDelegate(this, this._onDragLeave);
this._dragOverHandler = Function.createDelegate(this, this._onDragOver);
this._dropHandler = Function.createDelegate(this, this._onDrop);
},
dispose: function() {
if(this._dropTargets) {
for(var i = 0; i < this._dropTargets; i++)
this.unregisterDropTarget(this._dropTargets[i]);
this._dropTargets = null;
}
Sys.Extended.UI.IEDragDropManager.callBaseMethod(this, 'dispose');
},
startDragDrop: function(dragSource, dragVisual, context, useBuiltInDragAndDropFunctions) {
var ev = window._event;
// Don't allow drag and drop if there is another active drag operation going on.
if(this._isDragging)
return;
this._underlyingTarget = null;
this._activeDragSource = dragSource;
this._activeDragVisual = dragVisual;
this._activeContext = context;
this._useBuiltInDragAndDropFunctions = typeof (useBuiltInDragAndDropFunctions) != 'undefined' ? useBuiltInDragAndDropFunctions : true;
var mousePosition = { x: ev.clientX, y: ev.clientY };
// By default we use absolute positioning, unless a different type
// of positioning is set explicitly.
dragVisual.originalPosition = dragVisual.style.position;
dragVisual.style.position = "absolute";
document._lastPosition = mousePosition;
dragVisual.startingPoint = mousePosition;
var scrollOffset = this.getScrollOffset(dragVisual, /* recursive */true);
dragVisual.startingPoint = this.addPoints(dragVisual.startingPoint, scrollOffset);
var left = parseInt(dragVisual.style.left),
top = parseInt(dragVisual.style.top);
if(isNaN(left))
left = "0";
if(isNaN(top))
top = "0";
dragVisual.startingPoint = this.subtractPoints(dragVisual.startingPoint, { x: left, y: top });
// Monitor DOM changes.
this._prepareForDomChanges();
dragSource.onDragStart();
var eventArgs = new Sys.Extended.UI.DragDropEventArgs(
dragSource.get_dragMode(),
dragSource.get_dragDataType(),
dragSource.getDragData(context));
var handler = this.get_events().getHandler('dragStart');
if(handler)
handler(this, eventArgs);
this._recoverFromDomChanges();
this._wireEvents();
this._drag(/* isInitialDrag */true);
},
_stopDragDrop: function(cancelled) {
var ev = window._event;
if(this._activeDragSource != null) {
this._unwireEvents();
if(!cancelled)
// The drag operation is cancelled if there
// is no drop target.
cancelled = (this._underlyingTarget == null);
if(!cancelled && this._underlyingTarget != null)
this._underlyingTarget.drop(this._activeDragSource.get_dragMode(), this._activeDragSource.get_dragDataType(), this._activeDragSource.getDragData(this._activeContext));
this._activeDragSource.onDragEnd(cancelled);
var handler = this.get_events().getHandler('dragStop');
if(handler)
handler(this, Sys.EventArgs.Empty);
this._activeDragVisual.style.position = this._activeDragVisual.originalPosition;
this._activeDragSource = null;
this._activeContext = null;
this._activeDragVisual = null;
this._isDragging = false;
this._potentialTarget = null;
ev.preventDefault();
}
},
_drag: function(isInitialDrag) {
var ev = window._event,
mousePosition = { x: ev.clientX, y: ev.clientY };
// NOTE: We store the event object to be able to determine the current
// mouse position in Mozilla in other event handlers such as keydown.
document._lastPosition = mousePosition;
var scrollOffset = this.getScrollOffset(this._activeDragVisual, /* recursive */true),
position = this.addPoints(this.subtractPoints(mousePosition, this._activeDragVisual.startingPoint), scrollOffset);
// Check if the visual moved at all.
if(!isInitialDrag && parseInt(this._activeDragVisual.style.left) == position.x && parseInt(this._activeDragVisual.style.top) == position.y)
return;
$common.setLocation(this._activeDragVisual, position);
// Monitor DOM changes.
this._prepareForDomChanges();
this._activeDragSource.onDrag();
this._recoverFromDomChanges();
// Find a potential target.
this._potentialTarget = this._findPotentialTarget(this._activeDragSource, this._activeDragVisual);
var movedToOtherTarget = (this._potentialTarget != this._underlyingTarget || this._potentialTarget == null);
// Check if we are leaving an underlying target.
if(movedToOtherTarget && this._underlyingTarget != null)
this._leaveTarget(this._activeDragSource, this._underlyingTarget);
if(this._potentialTarget != null) {
// Check if we are entering a new target.
if(movedToOtherTarget) {
this._underlyingTarget = this._potentialTarget;
// Enter the new target.
this._enterTarget(this._activeDragSource, this._underlyingTarget);
} else {
this._moveInTarget(this._activeDragSource, this._underlyingTarget);
}
} else {
this._underlyingTarget = null;
}
},
_wireEvents: function() {
if(this._useBuiltInDragAndDropFunctions) {
$addHandler(document, "mouseup", this._mouseUpHandler);
$addHandler(document, "mousemove", this._documentMouseMoveHandler);
$addHandler(document.body, "dragover", this._documentDragOverHandler);
$addHandler(this._activeDragVisual, "dragstart", this._dragStartHandler);
$addHandler(this._activeDragVisual, "dragend", this._mouseUpHandler);
$addHandler(this._activeDragVisual, "drag", this._mouseMoveHandler);
} else {
$addHandler(document, "mouseup", this._mouseUpHandler);
$addHandler(document, "mousemove", this._mouseMoveHandler);
}
},
_unwireEvents: function() {
if(this._useBuiltInDragAndDropFunctions) {
$removeHandler(this._activeDragVisual, "drag", this._mouseMoveHandler);
$removeHandler(this._activeDragVisual, "dragend", this._mouseUpHandler);
$removeHandler(this._activeDragVisual, "dragstart", this._dragStartHandler);
$removeHandler(document.body, "dragover", this._documentDragOverHandler);
$removeHandler(document, "mousemove", this._documentMouseMoveHandler);
$removeHandler(document, "mouseup", this._mouseUpHandler);
} else {
$removeHandler(document, "mousemove", this._mouseMoveHandler);
$removeHandler(document, "mouseup", this._mouseUpHandler);
}
},
registerDropTarget: function(dropTarget) {
if(this._dropTargets == null)
this._dropTargets = [];
Array.add(this._dropTargets, dropTarget);
this._wireDropTargetEvents(dropTarget);
},
unregisterDropTarget: function(dropTarget) {
this._unwireDropTargetEvents(dropTarget);
if(this._dropTargets)
Array.remove(this._dropTargets, dropTarget);
},
_wireDropTargetEvents: function(dropTarget) {
var associatedElement = dropTarget.get_dropTargetElement();
associatedElement._dropTarget = dropTarget;
$addHandler(associatedElement, "dragenter", this._dragEnterHandler);
$addHandler(associatedElement, "dragleave", this._dragLeaveHandler);
$addHandler(associatedElement, "dragover", this._dragOverHandler);
$addHandler(associatedElement, "drop", this._dropHandler);
},
_unwireDropTargetEvents: function(dropTarget) {
var associatedElement = dropTarget.get_dropTargetElement();
// make sure that the handlers are not removed twice
if(associatedElement._dropTarget) {
associatedElement._dropTarget = null;
$removeHandler(associatedElement, "dragenter", this._dragEnterHandler);
$removeHandler(associatedElement, "dragleave", this._dragLeaveHandler);
$removeHandler(associatedElement, "dragover", this._dragOverHandler);
$removeHandler(associatedElement, "drop", this._dropHandler);
}
},
_onDragStart: function(ev) {
window._event = ev;
document.selection.empty();
var dt = ev.dataTransfer;
if(!dt && ev.rawEvent)
dt = ev.rawEvent.dataTransfer;
var dataType = this._activeDragSource.get_dragDataType().toLowerCase(),
data = this._activeDragSource.getDragData(this._activeContext);
if(data) {
// TODO: How do we want to deal with 'non-compatible types'?
if(dataType != "text" && dataType != "url") {
dataType = "text";
if(data.innerHTML != null)
data = data.innerHTML;
}
dt.effectAllowed = "move";
dt.setData(dataType, data.toString());
}
},
_onMouseUp: function(ev) {
window._event = ev;
this._stopDragDrop(false);
},
_onDocumentMouseMove: function(ev) {
window._event = ev;
this._dragDrop();
},
_onDocumentDragOver: function(ev) {
window._event = ev;
if(this._potentialTarget)
ev.preventDefault();
},
_onMouseMove: function(ev) {
window._event = ev;
this._drag();
},
_onDragEnter: function(ev) {
window._event = ev;
if(this._isDragging) {
ev.preventDefault();
//ev.returnValue = false;
} else {
// An external object is dragged to the drop target.
var dataObjects = Sys.Extended.UI.IEDragDropManager._getDataObjectsForDropTarget(this._getDropTarget(ev.target));
for(var i = 0; i < dataObjects.length; i++)
this._dropTarget.onDragEnterTarget(Sys.Extended.UI.DragMode.Copy, dataObjects[i].type, dataObjects[i].value);
}
},
_onDragLeave: function(ev) {
window._event = ev;
if(this._isDragging) {
ev.preventDefault();
//ev.returnValue = false;
} else {
// An external object is dragged to the drop target.
var dataObjects = Sys.Extended.UI.IEDragDropManager._getDataObjectsForDropTarget(this._getDropTarget(ev.target));
for(var i = 0; i < dataObjects.length; i++)
this._dropTarget.onDragLeaveTarget(Sys.Extended.UI.DragMode.Copy, dataObjects[i].type, dataObjects[i].value);
}
},
_onDragOver: function(ev) {
window._event = ev;
if(this._isDragging) {
ev.preventDefault();
} else {
// An external object is dragged over the drop target.
var dataObjects = Sys.Extended.UI.IEDragDropManager._getDataObjectsForDropTarget(this._getDropTarget(ev.target));
for(var i = 0; i < dataObjects.length; i++)
this._dropTarget.onDragInTarget(Sys.Extended.UI.DragMode.Copy, dataObjects[i].type, dataObjects[i].value);
}
},
_onDrop: function(ev) {
window._event = ev;
if(!this._isDragging) {
// An external object is dropped on the drop target.
var dataObjects = Sys.Extended.UI.IEDragDropManager._getDataObjectsForDropTarget(this._getDropTarget(ev.target));
for(var i = 0; i < dataObjects.length; i++)
this._dropTarget.drop(Sys.Extended.UI.DragMode.Copy, dataObjects[i].type, dataObjects[i].value);
}
ev.preventDefault();
},
_getDropTarget: function(element) {
while(element) {
if(element._dropTarget != null)
return element._dropTarget;
element = element.parentNode;
}
return null;
},
_dragDrop: function() {
if(this._isDragging)
return;
this._isDragging = true;
this._activeDragVisual.dragDrop();
document.selection.empty();
},
_moveInTarget: function(dragSource, dropTarget) {
// Monitor DOM changes.
this._prepareForDomChanges();
dropTarget.onDragInTarget(dragSource.get_dragMode(), dragSource.get_dragDataType(), dragSource.getDragData(this._activeContext));
this._recoverFromDomChanges();
},
_enterTarget: function(dragSource, dropTarget) {
// Monitor DOM changes.
this._prepareForDomChanges();
dropTarget.onDragEnterTarget(dragSource.get_dragMode(), dragSource.get_dragDataType(), dragSource.getDragData(this._activeContext));
this._recoverFromDomChanges();
},
_leaveTarget: function(dragSource, dropTarget) {
// Monitor DOM changes.
this._prepareForDomChanges();
dropTarget.onDragLeaveTarget(dragSource.get_dragMode(), dragSource.get_dragDataType(), dragSource.getDragData(this._activeContext));
this._recoverFromDomChanges();
},
_findPotentialTarget: function(dragSource, dragVisual) {
var ev = window._event;
if(this._dropTargets == null)
return null;
var type = dragSource.get_dragDataType(),
mode = dragSource.get_dragMode(),
data = dragSource.getDragData(this._activeContext);
// Get the current cursor location.
var scrollOffset = this.getScrollOffset(document.body, /* recursive */true),
x = ev.clientX + scrollOffset.x,
y = ev.clientY + scrollOffset.y,
cursorRect = { x: x - this._radius, y: y - this._radius, width: this._radius * 2, height: this._radius * 2 };
// Find any targets near the current cursor location.
var targetRect;
for(var i = 0; i < this._dropTargets.length; i++) {
targetRect = $common.getBounds(this._dropTargets[i].get_dropTargetElement());
if($common.overlaps(cursorRect, targetRect) && this._dropTargets[i].canDrop(mode, type, data))
return this._dropTargets[i];
}
return null;
},
_prepareForDomChanges: function() {
this._oldOffset = $common.getLocation(this._activeDragVisual);
},
_recoverFromDomChanges: function() {
var newOffset = $common.getLocation(this._activeDragVisual);
if(this._oldOffset.x != newOffset.x || this._oldOffset.y != newOffset.y) {
this._activeDragVisual.startingPoint = this.subtractPoints(this._activeDragVisual.startingPoint, this.subtractPoints(this._oldOffset, newOffset));
scrollOffset = this.getScrollOffset(this._activeDragVisual, /* recursive */true);
var position = this.addPoints(this.subtractPoints(document._lastPosition, this._activeDragVisual.startingPoint), scrollOffset);
$common.setLocation(this._activeDragVisual, position);
}
},
addPoints: function(p1, p2) {
return { x: p1.x + p2.x, y: p1.y + p2.y };
},
subtractPoints: function(p1, p2) {
return { x: p1.x - p2.x, y: p1.y - p2.y };
},
// -- Drag and drop helper methods.
getScrollOffset: function(element, recursive) {
var left = element.scrollLeft,
top = element.scrollTop;
if(recursive) {
var parent = element.parentNode;
while(parent != null && parent.scrollLeft != null) {
left += parent.scrollLeft;
top += parent.scrollTop;
// Don't include anything below the body.
if(parent == document.body && (left != 0 && top != 0))
break;
parent = parent.parentNode;
}
}
return { x: left, y: top };
},
getBrowserRectangle: function() {
var width = window.innerWidth,
height = window.innerHeight;
if(width == null)
width = document.documentElement.clientWidth;
if(height == null)
height = document.documentElement.clientHeight;
return { x: 0, y: 0, width: width, height: height };
},
getNextSibling: function(item) {
for(item = item.nextSibling; item != null; item = item.nextSibling)
if(item.innerHTML != null)
return item;
return null;
},
hasParent: function(element) {
return (element.parentNode != null && element.parentNode.tagName != null);
}
}
Sys.Extended.UI.IEDragDropManager.registerClass('Sys.Extended.UI.IEDragDropManager', Sys.Component);
Sys.Extended.UI.IEDragDropManager._getDataObjectsForDropTarget = function(dropTarget) {
if(dropTarget == null)
return [];
var ev = window._event,
dataObjects = [],
dataTypes = ["URL", "Text"],
data;
for(var i = 0; i < dataTypes.length; i++) {
var dt = ev.dataTransfer;
if(!dt && ev.rawEvent)
dt = ev.rawEvent.dataTransfer;
data = dt.getData(dataTypes[i]);
if(dropTarget.canDrop(Sys.Extended.UI.DragMode.Copy, dataTypes[i], data))
if(data)
Array.add(dataObjects, { type: dataTypes[i], value: data });
}
return dataObjects;
}
Sys.Extended.UI.GenericDragDropManager = function() {
Sys.Extended.UI.GenericDragDropManager.initializeBase(this);
this._dropTargets = null;
// Radius of the cursor used to determine what drop target we
// are hovering. Anything below the cursor's zone may be a
// potential drop target.
this._scrollEdgeConst = 40;
this._scrollByConst = 10;
this._scroller = null;
this._scrollDeltaX = 0;
this._scrollDeltaY = 0;
this._activeDragVisual = null;
this._activeContext = null;
this._activeDragSource = null;
this._oldOffset = null;
this._potentialTarget = null;
this._mouseUpHandler = null;
this._mouseMoveHandler = null;
this._keyPressHandler = null;
this._scrollerTickHandler = null;
}
Sys.Extended.UI.GenericDragDropManager.prototype = {
initialize: function() {
Sys.Extended.UI.GenericDragDropManager.callBaseMethod(this, "initialize");
this._mouseUpHandler = Function.createDelegate(this, this._onMouseUp);
this._mouseMoveHandler = Function.createDelegate(this, this._onMouseMove);
this._keyPressHandler = Function.createDelegate(this, this._onKeyPress);
this._scrollerTickHandler = Function.createDelegate(this, this._onScrollerTick);
this._scroller = new Sys.Timer();
this._scroller.set_interval(10);
this._scroller.add_tick(this._scrollerTickHandler);
},
startDragDrop: function(dragSource, dragVisual, context) {
this._activeDragSource = dragSource;
this._activeDragVisual = dragVisual;
this._activeContext = context;
Sys.Extended.UI.GenericDragDropManager.callBaseMethod(this, "startDragDrop", [dragSource, dragVisual, context]);
},
_stopDragDrop: function(cancelled) {
this._scroller.set_enabled(false);
Sys.Extended.UI.GenericDragDropManager.callBaseMethod(this, "_stopDragDrop", [cancelled]);
},
_drag: function(isInitialDrag) {
Sys.Extended.UI.GenericDragDropManager.callBaseMethod(this, "_drag", [isInitialDrag]);
this._autoScroll();
},
_wireEvents: function() {
$addHandler(document, "mouseup", this._mouseUpHandler);
$addHandler(document, "mousemove", this._mouseMoveHandler);
$addHandler(document, "keypress", this._keyPressHandler);
},
_unwireEvents: function() {
$removeHandler(document, "keypress", this._keyPressHandler);
$removeHandler(document, "mousemove", this._mouseMoveHandler);
$removeHandler(document, "mouseup", this._mouseUpHandler);
},
_wireDropTargetEvents: function(dropTarget) {
},
_unwireDropTargetEvents: function(dropTarget) {
},
_onMouseUp: function(e) {
window._event = e;
this._stopDragDrop(false);
},
_onMouseMove: function(e) {
window._event = e;
this._drag();
},
_onKeyPress: function(e) {
window._event = e;
// Escape.
var k = e.keyCode ? e.keyCode : e.rawEvent.keyCode;
if(k == 27)
this._stopDragDrop(/* cancel */ true);
},
_autoScroll: function() {
var ev = window._event,
browserRect = this.getBrowserRectangle();
if(browserRect.width > 0) {
this._scrollDeltaX = this._scrollDeltaY = 0;
if(ev.clientX < browserRect.x + this._scrollEdgeConst)
this._scrollDeltaX = -this._scrollByConst;
else if(ev.clientX > browserRect.width - this._scrollEdgeConst)
this._scrollDeltaX = this._scrollByConst;
if(ev.clientY < browserRect.y + this._scrollEdgeConst)
this._scrollDeltaY = -this._scrollByConst;
else if(ev.clientY > browserRect.height - this._scrollEdgeConst)
this._scrollDeltaY = this._scrollByConst;
if(this._scrollDeltaX != 0 || this._scrollDeltaY != 0)
this._scroller.set_enabled(true);
else
this._scroller.set_enabled(false);
}
},
_onScrollerTick: function() {
var oldLeft = document.body.scrollLeft,
oldTop = document.body.scrollTop;
window.scrollBy(this._scrollDeltaX, this._scrollDeltaY);
var newLeft = document.body.scrollLeft,
newTop = document.body.scrollTop;
var dragVisual = this._activeDragVisual,
position = { x: parseInt(dragVisual.style.left) + (newLeft - oldLeft), y: parseInt(dragVisual.style.top) + (newTop - oldTop) };
$common.setLocation(dragVisual, position);
}
}
Sys.Extended.UI.GenericDragDropManager.registerClass('Sys.Extended.UI.GenericDragDropManager', Sys.Extended.UI.IEDragDropManager);

View File

@@ -0,0 +1,91 @@
Sys.Timer = function() {
Sys.Timer.initializeBase(this);
this._interval = 1000;
this._enabled = false;
this._timer = null;
}
Sys.Timer.prototype = {
get_interval: function() {
return this._interval;
},
set_interval: function(value) {
if(this._interval !== value) {
this._interval = value;
this.raisePropertyChanged('interval');
if(!this.get_isUpdating() && (this._timer !== null)) {
this._stopTimer();
this._startTimer();
}
}
},
get_enabled: function() {
return this._enabled;
},
set_enabled: function(value) {
if(value !== this.get_enabled()) {
this._enabled = value;
this.raisePropertyChanged('enabled');
if(!this.get_isUpdating())
if(value)
this._startTimer();
else
this._stopTimer();
}
},
add_tick: function(handler) {
this.get_events().addHandler("tick", handler);
},
remove_tick: function(handler) {
this.get_events().removeHandler("tick", handler);
},
dispose: function() {
this.set_enabled(false);
this._stopTimer();
Sys.Timer.callBaseMethod(this, 'dispose');
},
updated: function() {
Sys.Timer.callBaseMethod(this, 'updated');
if(this._enabled) {
this._stopTimer();
this._startTimer();
}
},
_timerCallback: function() {
var handler = this.get_events().getHandler("tick");
if(handler)
handler(this, Sys.EventArgs.Empty);
},
_startTimer: function() {
this._timer = window.setInterval(Function.createDelegate(this, this._timerCallback), this._interval);
},
_stopTimer: function() {
window.clearInterval(this._timer);
this._timer = null;
}
}
Sys.Timer.descriptor = {
properties: [{ name: 'interval', type: Number },
{ name: 'enabled', type: Boolean }],
events: [{ name: 'tick' }]
}
Sys.Timer.registerClass('Sys.Timer', Sys.Component);

View File

@@ -0,0 +1,75 @@
Sys.ComponentSet = function ComponentSet(elementSet, query, index) {
this._elementSet = elementSet || (elementSet = new Sys.ElementSet());
this._components = this._execute(elementSet, query, index);
}
Sys.ComponentSet.prototype = {
__class: true,
setProperties: function ComponentSet$setProperties(properties) {
// Sets properties on the matched components.
// "properties" - object with the names and values of the properties to set.
return this.each(function() {
Sys._set(this, properties);
});
},
get: function ComponentSet$get(index) {
// Returns the component at the specified index, or an array of all matches if not specified.
var components = this._components;
return (typeof (index) === "undefined") ? (Array.apply(null, components)) : (components[index || 0] || null);
},
each: function ComponentSet$each(callback) {
// Enumerate all the found components. The index of the component are passed as parameters to a callback. You may return 'false' to cancel the enumeration.
// "callback" - function called for each component.
foreach(this._components, function(c, i) {
if(callback.call(c, i) === false)
return true;
});
return this;
},
elements: function ComponentSet$elements() {
// Returns the underlying set of elements this component collection came from.
return this._elementSet;
},
_execute: function ComponentSet$_execute(elementSet, query, index) {
var components = [];
function match(c) {
var ctor;
return (c instanceof query) ||
((ctor = c.constructor) && (
(ctor === query) ||
(ctor.inheritsFrom && ctor.inheritsFrom(query)) ||
(ctor.implementsInterface && ctor.implementsInterface(query))));
}
if(query instanceof Array)
components.push.apply(components, query);
else
// query is a type or not set
elementSet.each(function() {
var c = this.control;
if(c && (!query || match(c)))
components.push(c);
foreach(this._behaviors, function(b) {
if(!query || match(b))
components.push(b);
});
});
if((typeof (index) !== "undefined")) {
if(components[index])
components = [components[index]];
else
components = [];
}
return components;
}
}

View File

@@ -0,0 +1,326 @@
Type.registerNamespace('Sys.Extended.UI');
Sys.Extended.UI.ConfirmButtonHiddenEventArgs = function(confirmed) {
Sys.Extended.UI.ConfirmButtonHiddenEventArgs.initializeBase(this);
this._confirmed = confirmed;
}
Sys.Extended.UI.ConfirmButtonHiddenEventArgs.prototype = {
get_confirmed: function() {
return this._confirmed;
}
}
Sys.Extended.UI.ConfirmButtonHiddenEventArgs.registerClass('Sys.Extended.UI.ConfirmButtonHiddenEventArgs', Sys.EventArgs);
Sys.Extended.UI.ConfirmButtonBehavior = function(element) {
Sys.Extended.UI.ConfirmButtonBehavior.initializeBase(this, [element]);
// Confirm text
this._ConfirmTextValue = null;
// Cancel value
this._OnClientCancelValue = null;
// Confirm on form submit
this._ConfirmOnFormSubmit = false;
// ModalPopup to use instead of window.confirm
this._displayModalPopupID = null;
// Script to call to initiate a postback
this._postBackScript = null;
// Click handler for the target control
this._clickHandler = null;
this._oldScript = null;
}
Sys.Extended.UI.ConfirmButtonBehavior.prototype = {
initialize: function() {
Sys.Extended.UI.ConfirmButtonBehavior.callBaseMethod(this, 'initialize');
var element = this.get_element();
// Attach the handler
this._clickHandler = Function.createDelegate(this, this._onClick);
$addHandler(element, "click", this._clickHandler);
// hoist out any existing script
//
this._oldScript = element.getAttribute("onclick");
if(this._oldScript)
element.setAttribute("onclick", null);
// Hook into the ASP.NET WebForm_OnSubmit function to display the confirm dialog prior to submission
if(this._ConfirmOnFormSubmit && (typeof (WebForm_OnSubmit) == 'function') && !Sys.Extended.UI.ConfirmButtonBehavior._originalWebForm_OnSubmit) {
if(Sys.Extended.UI.TextBoxWatermarkBehavior && Sys.Extended.UI.TextBoxWatermarkBehavior._originalWebForm_OnSubmit) {
// If TextBoxWatermark has already hooked the WebForm_OnSubmit, we want to run before it so the watermark removal is always last to run
Sys.Extended.UI.ConfirmButtonBehavior._originalWebForm_OnSubmit = Sys.Extended.UI.TextBoxWatermarkBehavior._originalWebForm_OnSubmit;
Sys.Extended.UI.TextBoxWatermarkBehavior._originalWebForm_OnSubmit = Sys.Extended.UI.ConfirmButtonBehavior.WebForm_OnSubmit;
} else {
// Hook WebForm_OnSubmit normally
Sys.Extended.UI.ConfirmButtonBehavior._originalWebForm_OnSubmit = WebForm_OnSubmit;
WebForm_OnSubmit = Sys.Extended.UI.ConfirmButtonBehavior.WebForm_OnSubmit;
}
}
},
dispose: function() {
// Detach event handlers
if(this._clickHandler) {
$removeHandler(this.get_element(), "click", this._clickHandler);
this._clickHandler = null;
}
if(this._oldScript) {
this.get_element().setAttribute("onclick", this._oldScript);
this._oldScript = null;
}
Sys.Extended.UI.ConfirmButtonBehavior.callBaseMethod(this, 'dispose');
},
_onClick: function(e) {
if(this.get_element() && !this.get_element().disabled) {
if(this._ConfirmOnFormSubmit) {
// Note that this behavior was triggered (for later)
Sys.Extended.UI.ConfirmButtonBehavior._clickedBehavior = this;
} else {
// Display the dialog and cancel the click if necessary
if(!this._displayConfirmDialog()) {
e.preventDefault();
return false;
} else if(this._oldScript) {
if(String.isInstanceOfType(this._oldScript))
eval(this._oldScript);
else if(typeof (this._oldScript) == 'function')
this._oldScript();
}
}
}
},
_displayConfirmDialog: function() {
// Raise the showing event and potentially cancel
var eventArgs = new Sys.CancelEventArgs();
this.raise_showing(eventArgs);
if(eventArgs.get_cancel())
return;
if(this._displayModalPopupID) {
// Using a ModalPopupBehavior instead of window.confirm
var mpe = $find(this._displayModalPopupID);
if(!mpe)
throw Error.argument('displayModalPopupID', String.format(Sys.Extended.UI.Resources.CollapsiblePanel_NoControlID, this._displayModalPopupID));
// Hook into ModalPopupBehavior for the confirm result
mpe.set_OnOkScript("$find('" + this.get_id() + "')._handleConfirmDialogCompletion(true);");
mpe.set_OnCancelScript("$find('" + this.get_id() + "')._handleConfirmDialogCompletion(false);");
// Show the ModalPopupBehavior
mpe.show();
// Cancel postback since ModalPopupBehavior.show is asynchronous - _handleConfirmDialogCompletion will handle the result
return false;
} else {
// Display window.confirm dialog
var result = window.confirm(this._ConfirmTextValue);
this._handleConfirmDialogCompletion(result);
return result;
}
},
_handleConfirmDialogCompletion: function(result) {
// Handle the completion of a confirm dialog (whether by window.confirm or ModalPopupBehavior)
this.raise_hidden(new Sys.Extended.UI.ConfirmButtonHiddenEventArgs(result));
if(result) {
// Confirmed - Initiate the postback if specified
if(this._postBackScript)
eval(this._postBackScript);
} else {
// Rejected - Execute the associated script if present
if(this._OnClientCancelValue)
window[this._OnClientCancelValue]();
}
},
/// <summary>
/// A string that contains a client script that executes when the Cancel button is clicked in the confirm dialog box.
/// </summary>
/// <getter>get_onClientCancel</getter>
/// <setter>set_onClientCancel</setter>
/// <member name="cP:AjaxControlToolkit.ConfirmButtonExtender.onClientCancel" />
get_onClientCancel: function() {
// The client-side script that executes when the cancel button is clicked on the confirm dialog.
return this._OnClientCancelValue;
},
set_onClientCancel: function(value) {
if(this._OnClientCancelValue != value) {
this._OnClientCancelValue = value;
this.raisePropertyChanged('onClientCancel');
}
},
get_OnClientCancel: function() {
Sys.Extended.Deprecated("get_OnClientCancel()", "get_onClientCancel()");
return this.get_onClientCancel();
},
set_OnClientCancel: function(value) {
Sys.Extended.Deprecated("set_OnClientCancel(value)", "set_onClientCancel(value)");
this.set_onClientCancel(value);
},
/// <summary>
/// Confirmation text to display.
/// </summary>
/// <remarks>
/// HTML entities can be used for a newline character.
/// </remarks>
/// <getter>get_confirmText</getter>
/// <setter>set_confirmText</setter>
/// <member name="cP:AjaxControlToolkit.ConfirmButtonExtender.confirmText" />
get_confirmText: function() {
// The text to show when you want to confirm the click. (Note: HTML entities can be used here (ex: "&#10;" for new-line))
return this._ConfirmTextValue;
},
set_confirmText: function(value) {
if(this._ConfirmTextValue != value) {
this._ConfirmTextValue = value;
this.raisePropertyChanged('confirmText');
}
},
get_ConfirmText: function() {
Sys.Extended.Deprecated("get_ConfirmText()", "get_confirmText()");
return this.get_confirmText();
},
set_ConfirmText: function(value) {
Sys.Extended.Deprecated("set_ConfirmText(value)", "set_confirmText(value)");
this.set_confirmText(value);
},
/// <summary>
/// A Boolean value that specifies that the confirm dialog box should not be displayed until the form is submitted.
/// </summary>
/// <remarks>
/// This is useful if a page contains ASP.NET validator controls and the confirm dialog box should be displayed only after all validation checks pass.
/// </remarks>
/// <getter>get_confirmOnFormSubmit</getter>
/// <setter>set_confirmOnFormSubmit</setter>
/// <member name="cP:AjaxControlToolkit.ConfirmButtonExtender.confirmOnFormSubmit" />
get_confirmOnFormSubmit: function() {
// True iff the confirm dialog should run for form submission (i.e., after validators are all satisfied)
return this._ConfirmOnFormSubmit;
},
set_confirmOnFormSubmit: function(value) {
if(this._ConfirmOnFormSubmit != value) {
this._ConfirmOnFormSubmit = value;
this.raisePropertyChanged('confirmOnFormSubmit');
}
},
get_ConfirmOnFormSubmit: function() {
Sys.Extended.Deprecated("get_ConfirmOnFormSubmit()", "get_confirmOnFormSubmit()");
return this.get_confirmOnFormSubmit();
},
set_ConfirmOnFormSubmit: function(value) {
Sys.Extended.Deprecated("set_ConfirmOnFormSubmit(value)", "set_confirmOnFormSubmit(value)");
this.set_confirmOnFormSubmit(value);
},
/// <summary>
/// A string that contains the ID of the ModalPopupBehavior control for use instead of the default window.confirm dialog box.
/// </summary>
/// <getter>get_displayModalPopupID</getter>
/// <setter>set_displayModalPopupID</setter>
/// <member name="cP:AjaxControlToolkit.ConfirmButtonExtender.displayModalPopupID" />
get_displayModalPopupID: function() {
// ID of a ModalPopupBehavior to be used instead of the default window.confirm dialog
return this._displayModalPopupID;
},
set_displayModalPopupID: function(value) {
if(this._displayModalPopupID != value) {
this._displayModalPopupID = value;
this.raisePropertyChanged('displayModalPopupID');
}
},
/// <summary>
/// A string that contains script to run in order to initiate a postback.
/// </summary>
/// <getter>get_postBackScript</getter>
/// <setter>set_postBackScript</setter>
/// <member name="cP:AjaxControlToolkit.ConfirmButtonExtender.postBackScript" />
get_postBackScript: function() {
return this._postBackScript;
},
set_postBackScript: function(value) {
if(this._postBackScript != value) {
this._postBackScript = value;
this.raisePropertyChanged('postBackScript');
}
},
/// <summary>
/// Fires when the control is being shown.
/// </summary>
/// <event add="add_showing" remove="remove_showing" raise="raise_showing" />
/// <member name="cE:AjaxControlToolkit.ConfirmButtonExtender.showing" />
add_showing: function(handler) {
this.get_events().addHandler('showing', handler);
},
remove_showing: function(handler) {
this.get_events().removeHandler('showing', handler);
},
raise_showing: function(eventArgs) {
var handler = this.get_events().getHandler('showing');
if(handler)
handler(this, eventArgs);
},
raiseShowing: function(eventArgs) {
Sys.Extended.Deprecated("raiseShowing", "raise_showing");
this.raise_showing(eventArgs);
},
/// <summary>
/// Fires when the control is hidden.
/// </summary>
/// <event add="add_hidden" remove="remove_hidden" raise="raise_hidden" />
/// <member name="cE:AjaxControlToolkit.ConfirmButtonExtender.hidden" />
add_hidden: function(handler) {
this.get_events().addHandler('hidden', handler);
},
remove_hidden: function(handler) {
this.get_events().removeHandler('hidden', handler);
},
raise_hidden: function(eventArgs) {
var handler = this.get_events().getHandler('hidden');
if(handler)
handler(this, eventArgs);
},
raiseHidden: function(eventArgs) {
Sys.Extended.Deprecated("raiseHidden", "raise_hidden");
this.raise_hidden(eventArgs);
}
}
Sys.Extended.UI.ConfirmButtonBehavior.registerClass('Sys.Extended.UI.ConfirmButtonBehavior', Sys.Extended.UI.BehaviorBase);
Sys.Extended.UI.ConfirmButtonBehavior.WebForm_OnSubmit = function() {
// Wraps ASP.NET's WebForm_OnSubmit in order to display the confirm dialog prior to submission
var result = Sys.Extended.UI.ConfirmButtonBehavior._originalWebForm_OnSubmit();
if(result && Sys.Extended.UI.ConfirmButtonBehavior._clickedBehavior)
result = Sys.Extended.UI.ConfirmButtonBehavior._clickedBehavior._displayConfirmDialog();
Sys.Extended.UI.ConfirmButtonBehavior._clickedBehavior = null;
return result;
}

View File

@@ -0,0 +1,132 @@
Type.registerNamespace('Sys.Extended.UI');
Sys.Extended.UI.DraggableListItem = function(e) {
Sys.Extended.UI.DraggableListItem.initializeBase(this, [e]);
this._data = null;
this._handle = null;
this._dragVisualTemplate = null;
this._dragVisualTemplateInstance = null;
this._mouseDownHandler = null;
}
Sys.Extended.UI.DraggableListItem.prototype = {
dispose: function() {
var e = this.get_element();
this.set_handle(null);
Sys.Extended.UI.DraggableListItem.callBaseMethod(this, 'dispose');
},
get_data: function() {
if(this._data == null) {
var dragSource = this._findDragSource();
if(dragSource != null && Sys.Extended.UI.DragDropList.IsValidDataType(dragSource.get_dragDataType()))
return this.get_element();
}
return this._data;
},
set_data: function(value) {
if(this._data != value) {
this._data = value;
this.raisePropertyChanged('data');
}
},
get_handle: function() {
return this._handle;
},
set_handle: function(value) {
if(this._handle != null) {
$removeHandler(this._handle, "mousedown", this.get_mouseDownHandler());
this._handle.__draggableBehavior = null;
}
if(value) {
if(value.element)
value = value.element;
this._handle = value;
this.raisePropertyChanged('handle');
this._handle.__draggableBehavior = this;
$addHandler(this._handle, "mousedown", this.get_mouseDownHandler());
this._handle.__draggableBehavior = this;
}
else
this._handle = null;
},
get_mouseDownHandler: function() {
if(this._mouseDownHandler == null)
this._mouseDownHandler = Function.createDelegate(this, this._onMouseDown);
return this._mouseDownHandler;
},
get_dragVisualTemplate: function() {
return this._dragVisualTemplate;
},
set_dragVisualTemplate: function(value) {
if(this._dragVisualTemplate != value) {
this._dragVisualTemplate = value;
this.raisePropertyChanged('dragVisualTemplate');
}
},
_onMouseDown: function(ev) {
window._event = ev.rawEvent;
this._handle.__draggableBehavior._mouseDownHandlerInternal(ev);
},
_mouseDownHandlerInternal: function(ev) {
var ev = window.testEvent ? window.testEvent : ev;
if(ev.button <= 1) {
var dragSource = this._findDragSource();
if(dragSource != null) {
var dragVisual = this._createDragVisual();
dragSource.startDragDrop(this.get_element(), this.get_data(), dragVisual);
ev.returnValue = false;
}
}
},
_createDragVisual: function() {
var ev = window.testEvent ? window.testEvent : window.event;
if(this._dragVisualTemplate != null) {
if(this._dragVisualTemplateInstance == null)
this._dragVisualTemplateInstance = this._dragVisualTemplate.cloneElement();
else if(!Sys.UI.DragDropManager._getInstance().hasParent(this._dragVisualTemplateInstance))
this.get_element().appendChild(this._dragVisualTemplateInstance);
var location = { x: ev.clientX, y: ev.clientY };
location = Sys.UI.DragDropManager._getInstance().addPoints(location, Sys.UI.DragDropManager._getInstance().getScrollOffset(document.body, true));
$common.setLocation(this._dragVisualTemplateInstance, location);
}
return this._dragVisualTemplateInstance;
},
_findDragSource: function() {
var element = this.get_element();
while(element != null) {
if(element.__dragDropList != null)
return element.__dragDropList;
element = element.parentNode;
}
return null;
}
}
Sys.Extended.UI.DraggableListItem.registerClass('Sys.Extended.UI.DraggableListItem', Sys.Extended.UI.BehaviorBase);

View File

@@ -0,0 +1,793 @@
Type.registerNamespace('Sys.Extended.UI');
Sys.Extended.UI.DropDownBehavior = function(element) {
Sys.Extended.UI.DropDownBehavior.initializeBase(this, [element]);
this._dropDownControl = null;
this._highlightBorderColor = "#2353B2";
this._highlightBackgroundColor = "#FFF3DB";
this._dropArrowBackgroundColor = "#C6E1FF";
this._dropArrowImageUrl = null;
this._dropArrowWidth = "16px";
this._oldBackgroundColor = null;
this._dropFrame = null;
this._dropArrow = null;
this._dropArrowImage = null;
this._dropWrapper = null;
this._isOpen = false;
this._isOver = false;
this._wasClicked = null;
this._dropWrapperHoverBehavior = null;
this._dropPopupPopupBehavior = null;
this._onShowJson = null;
this._onHideJson = null;
this._dropDownControl$delegates = {
click: Function.createDelegate(this, this._dropDownControl_onclick),
contextmenu: Function.createDelegate(this, this._dropDownControl_oncontextmenu)
}
this._dropFrame$delegates = {
click: Function.createDelegate(this, this._dropFrame_onclick),
contextmenu: Function.createDelegate(this, this._dropFrame_oncontextmenu)
}
this._dropWrapper$delegates = {
click: Function.createDelegate(this, this._dropWrapper_onclick),
contextmenu: Function.createDelegate(this, this._dropWrapper_oncontextmenu)
}
this._document$delegates = {
click: Function.createDelegate(this, this._document_onclick),
contextmenu: Function.createDelegate(this, this._document_oncontextmenu)
}
this._dropWrapperHoverBehavior$delegates = {
hover: Function.createDelegate(this, this._dropWrapperHoverBehavior_onhover),
unhover: Function.createDelegate(this, this._dropWrapperHoverBehavior_onunhover)
}
}
Sys.Extended.UI.DropDownBehavior.prototype = {
initialize: function() {
Sys.Extended.UI.DropDownBehavior.callBaseMethod(this, 'initialize');
var elt = this.get_element(),
parent = elt.parentNode;
// _dropDownControl
if(this._dropDownControl == null) {
$common.createElementFromTemplate({
parent: parent,
nameTable: this,
name: "_dropDownControl",
nodeName: "div",
visible: false,
cssClasses: this._dropDownControl ? null : ["ajax__dropdown_panel"],
properties: {
__GENERATED: true
}
});
}
$addHandlers(this._dropDownControl, this._dropDownControl$delegates);
// _dropFrame
// _dropArrow
// _dropArrowWrapper
// _dropArrowImage
var dropArrowImageProperties = {};
if(this._dropArrowImageUrl)
// Only set src if it has a value - otherwise IE gets a HTTP 404 response
dropArrowImageProperties["src"] = this._dropArrowImageUrl;
$common.createElementFromTemplate({
parent: parent,
nameTable: this,
name: "_dropFrame",
nodeName: "span",
visible: false,
children: [{
name: "_dropFrameTop",
nodeName: "div",
cssClasses: ["ajax__dropdown_frame_line"]
}, {
name: "_dropFrameRight",
nodeName: "div",
cssClasses: ["ajax__dropdown_frame_line"]
}, {
name: "_dropFrameBottom",
nodeName: "div",
cssClasses: ["ajax__dropdown_frame_line"]
}, {
name: "_dropFrameLeft",
nodeName: "div",
cssClasses: ["ajax__dropdown_frame_line"]
}, {
name: "_dropArrow",
nodeName: "div",
cssClasses: (!this._dropArrowImageUrl) ? ["ajax__dropdown_arrow", "ajax__dropdown_arrow_image"] : ["ajax__dropdown_arrow"],
properties: {
style: {
width: this._dropArrowWidth,
backgroundColor: this._dropArrowBackgroundColor
}
},
events: this._dropFrame$delegates,
children: [{
name: "_dropArrowWrapper",
nodeName: "div",
visible: !!this._dropArrowImageUrl,
cssClasses: ["ajax__dropdown_arrow_wrapper"],
children: [{
name: "_dropArrowImage",
nodeName: "img",
properties: dropArrowImageProperties
}]
}]
}]
});
// _dropWrapper
$common.createElementFromTemplate({
parent: null,
nameTable: this,
name: "_dropWrapper",
nodeName: "span",
properties: {
id: elt.id + "_dropWrapper",
style: {
cursor: "default"
}
},
events: this._dropWrapper$delegates,
content: elt
});
// _dropPopupPopupBehavior
this._dropPopupPopupBehavior = $create(Sys.Extended.UI.PopupBehavior, {
positioningMode: Sys.Extended.UI.PositioningMode.BottomRight,
parentElement: elt,
y: -1
}, null, null, this._dropDownControl);
// Create the animations (if they were set before initialize was called)
if(this._onShowJson)
this._dropPopupPopupBehavior.set_onShow(this._onShowJson);
if(this._onHideJson)
this._dropPopupPopupBehavior.set_onHide(this._onHideJson);
// _dropWrapperHoverBehavior
this._dropWrapperHoverBehavior = $create(Sys.Extended.UI.HoverBehavior, {
hoverElement: this._dropFrame
}, this._dropWrapperHoverBehavior$delegates, null, this._dropWrapper);
// wire events
$addHandlers(document, this._document$delegates);
},
dispose: function() {
var elt = this.get_element();
if(this._isOpen) {
this.hide();
this.unhover();
this._isOpen = false;
}
$common.removeHandlers(document, this._document$delegates);
this._onShowJson = null;
this._onHideJson = null;
if(this._dropPopupPopupBehavior) {
this._dropPopupPopupBehavior.dispose();
this._dropPopupPopupBehavior = null;
}
if(this._dropWrapperHoverBehavior) {
this._dropWrapperHoverBehavior.dispose();
this._dropWrapperHoverBehavior = null;
}
if(this._dropFrame) {
$common.removeElement(this._dropFrame);
this._dropFrame = null;
this._dropFrameTop = null;
this._dropFrameRight = null;
this._dropFrameBottom = null;
this._dropFrameLeft = null;
this._dropArrow = null;
this._dropArrowWrapper = null;
this._dropArrowImage = null;
}
if(this._dropWrapper) {
$common.removeHandlers(this._dropWrapper, this._dropWrapper$delegates);
$common.unwrapElement(elt, this._dropWrapper);
this._dropWrapper = null;
}
if(this._dropDownControl) {
$common.removeHandlers(this._dropDownControl, this._dropDownControl$delegates);
if(this._dropDownControl.__GENERATED)
$common.removeElement(this._dropDownControl);
this._dropDownControl = null;
}
Sys.Extended.UI.DropDownBehavior.callBaseMethod(this, 'dispose');
},
hover: function() {
var elt = this.get_element();
if(!this._isOver) {
this._isOver = true;
this.raiseHoverOver(Sys.EventArgs.Empty);
var bounds = $common.getBounds(elt);
// measure the offset caused by absolute/relative positioning:
// - set position to (0,0)
$common.setLocation(this._dropFrame, { x: 0, y: 0 });
// - show element
$common.setVisible(this._dropFrame, true);
// - get the actual position
var offset = $common.getLocation(this._dropFrame);
// - hide element
$common.setVisible(this._dropFrame, false);
// apply the measured offset
bounds.x -= offset.x;
bounds.y -= offset.y;
$common.setBounds(this._dropFrameTop, {
x: bounds.x,
y: bounds.y,
width: bounds.width,
height: 1
});
$common.setBounds(this._dropFrameRight, {
x: bounds.x + bounds.width - 1,
y: bounds.y,
width: 1,
height: bounds.height
});
$common.setBounds(this._dropFrameBottom, {
x: bounds.x,
y: bounds.y + bounds.height - 1,
width: bounds.width,
height: 1
});
$common.setBounds(this._dropFrameLeft, {
x: bounds.x,
y: bounds.y,
width: 1,
height: bounds.height
});
$common.setBounds(this._dropArrow, {
x: bounds.x + bounds.width - 17,
y: bounds.y + 1,
width: 16,
height: bounds.height - 2
});
this._dropFrameTop.style.backgroundColor = this._highlightBorderColor;
this._dropFrameRight.style.backgroundColor = this._highlightBorderColor;
this._dropFrameBottom.style.backgroundColor = this._highlightBorderColor;
this._dropFrameLeft.style.backgroundColor = this._highlightBorderColor;
$common.setVisible(this._dropFrame, true);
if(!this._oldBackgroundColor)
this._oldBackgroundColor = $common.getCurrentStyle(elt, 'backgroundColor');
var rgbColorRegEx = /\d{0,3},\s*\d{0,3},\s*\d{0,3}/;
if(rgbColorRegEx.test(this._highlightBackgroundColor))
elt.style.backgroundColor = "rgb(" + this._highlightBackgroundColor + ")";
else
elt.style.backgroundColor = this._highlightBackgroundColor;
}
},
unhover: function() {
var elt = this.get_element();
if(this._isOver || !this._isOpen) {
this._isOver = false;
if(!this._isOpen) {
$common.setVisible(this._dropFrame, false);
if(this._oldBackgroundColor) {
elt.style.backgroundColor = this._oldBackgroundColor;
this._oldBackgroundColor = null;
} else {
elt.style.backgroundColor = "transparent";
}
}
this.raise_hoverOut(Sys.EventArgs.Empty);
}
},
/// <summary>
/// Shows a drop-down list.
/// </summary>
/// <member name="cM:AjaxControlToolkit.DropDownExtender.show" />
show: function() {
if(!this._isOpen) {
this.hover();
var eventArgs = new Sys.CancelEventArgs();
this.raise_showing(eventArgs);
this.raise_popup(eventArgs);
if(eventArgs.get_cancel())
return;
this._isOpen = true;
this.populate();
if(!this._dynamicPopulateBehavior || (this._dynamicPopulateBehavior._populated && this._cacheDynamicResults))
this._showPopup();
}
},
_showPopup: function() {
this._dropPopupPopupBehavior.show();
this.raise_shown(Sys.EventArgs.Empty);
},
/// <summary>
/// Hides a drop-down list.
/// </summary>
/// <member name="cM:AjaxControlToolkit.DropDownExtender.hide" />
hide: function() {
if(this._isOpen) {
var eventArgs = new Sys.CancelEventArgs();
this.raise_hiding(eventArgs);
if(eventArgs.get_cancel())
return;
this._isOpen = false;
this._dropPopupPopupBehavior.hide();
this.raise_hidden(Sys.EventArgs.Empty);
}
},
_dropWrapperHoverBehavior_onhover: function(sender, e) {
this.hover();
},
_dropWrapperHoverBehavior_onunhover: function(sender, e) {
this.unhover();
},
_dropWrapper_onclick: function(e) {
if(e.target.tagName != "A") {
if(!this._isOpen)
this.show();
else
this.hide();
this._wasClicked = true;
}
},
_dropWrapper_oncontextmenu: function(e) {
if(e.target.tagName != "A") {
this._wasClicked = true;
e.preventDefault();
this.show();
}
},
_dropFrame_onclick: function(e) {
if(!this._isOpen)
this.show();
else
this.hide();
this._wasClicked = true;
},
_dropFrame_oncontextmenu: function(e) {
this._wasClicked = true;
e.preventDefault();
this.show();
},
_dropDownControl_onclick: function(e) {
//this._wasClicked = true;
},
_dropDownControl_oncontextmenu: function(e) {
this._wasClicked = true;
e.preventDefault();
},
_document_onclick: function(e) {
if(this._wasClicked) {
this._wasClicked = false;
} else if(this._isOpen) {
this.hide();
this.unhover();
}
},
_document_oncontextmenu: function(e) {
if(this._wasClicked) {
this._wasClicked = false;
} else if(this._isOpen) {
this.hide();
this.unhover();
}
},
_onPopulated: function(sender, eventArgs) {
Sys.Extended.UI.DropDownBehavior.callBaseMethod(this, '_onPopulated', [sender, eventArgs]);
if(this._isOpen)
this._showPopup();
},
/// <summary>
/// A JSON definition of a generic OnShow animation.
/// </summary>
/// <getter>get_onShow</getter>
/// <setter>set_onShow</setter>
/// <member name="cP:AjaxControlToolkit.DropDownExtender.onShow" />
get_onShow: function() {
return this._dropPopupPopupBehavior ? this._dropPopupPopupBehavior.get_onShow() : this._onShowJson;
},
set_onShow: function(value) {
if(this._dropPopupPopupBehavior)
this._dropPopupPopupBehavior.set_onShow(value)
else
this._onShowJson = value;
this.raisePropertyChanged('onShow');
},
/// <summary>
/// The Sys.Extended.UI.Animation.GenericAnimationBehavior object containing the generic OnShow animation behavior.
/// </summary>
/// <getter>get_onShowBehaior</getter>
/// <member name="cP:AjaxControlToolkit.DropDownExtender.onShowBehavior" />
get_onShowBehavior: function() {
return this._dropPopupPopupBehavior ? this._dropPopupPopupBehavior.get_onShowBehavior() : null;
},
/// <summary>
/// Plays OnShow animation.
/// </summary>
/// <member name="cM:AjaxControlToolkit.DropDownExtender.onShow" />
onShow: function() {
if(this._dropPopupPopupBehavior)
this._dropPopupPopupBehavior.onShow();
},
/// <summary>
/// A JSON definition of a generic OnHide animation.
/// </summary>
/// <getter>get_onHide</getter>
/// <setter>set_onHide</setter>
/// <member name="cP:AjaxControlToolkit.DropDownExtender.onHide" />
get_onHide: function() {
// Generic OnHide Animation's JSON definition
return this._dropPopupPopupBehavior ? this._dropPopupPopupBehavior.get_onHide() : this._onHideJson;
},
set_onHide: function(value) {
if(this._dropPopupPopupBehavior)
this._dropPopupPopupBehavior.set_onHide(value)
else
this._onHideJson = value;
this.raisePropertyChanged('onHide');
},
/// <summary>
/// The Sys.Extended.UI.Animation.GenericAnimationBehavior object containing the generic OnHide animation behavior.
/// </summary>
/// <getter>get_onHideBehavior</getter>
/// <member name="cP:AjaxControlToolkit.DropDownExtender.onHideBehavior" />
get_onHideBehavior: function() {
return this._dropPopupPopupBehavior ? this._dropPopupPopupBehavior.get_onHideBehavior() : null;
},
/// <summary>
/// Play OnHide animation.
/// </summary>
/// <member name="cM:AjaxControlToolkit.DropDownExtender.onHide" />
onHide: function() {
if(this._dropPopupPopupBehavior)
this._dropPopupPopupBehavior.onHide();
},
/// <summary>
/// A drop-down control.
/// </summary>
/// <getter>get_dropDownControl</getter>
/// <setter>set_dropDownControl</setter>
/// <member name="cP:AjaxControlToolkit.DropDownExtender.dropDownControl" />
get_dropDownControl: function() {
return this._dropDownControl;
},
set_dropDownControl: function(value) {
if(this._dropDownControl != value) {
this._dropDownControl = value;
this.raisePropertyChanged("dropDownControl");
}
},
/// <summary>
/// TThe highlighted border color of the DropDown control.
/// </summary>
/// <getter>get_highlightBorderColor</getter>
/// <setter>set_highlightBorderColor</setter>
/// <member name="cP:AjaxControlToolkit.DropDownExtender.highlightBorderColor" />
get_highlightBorderColor: function() {
return this._highlightBorderColor;
},
set_highlightBorderColor: function(value) {
if(this._highlightBorderColor != value) {
this._highlightBorderColor = value;
this.raisePropertyChanged("highlightBorderColor");
}
},
/// <summary>
/// The highlighted background color of the DropDown control.
/// </summary>
/// <getter>get_highlightBackgroundColor</getter>
/// <setter>set_highlightBackgroundColor</setter>
/// <member name="cP:AjaxControlToolkit.DropDownExtender.highlightBackgroundColor" />
get_highlightBackgroundColor: function() {
return this._highlightBackgroundColor;
},
set_highlightBackgroundColor: function(value) {
if(this._highlightBackgroundColor != value) {
this._highlightBackgroundColor = value;
if(this.get_isInitialized() && this._isOpen)
this._dropWrapper.style.backgroundColor = value;
this.raisePropertyChanged("highlightBackgroundColor");
}
},
/// <summary>
/// The arrow's background color of the DropDown control.
/// </summary>
/// <getter>get_dropArrowBackgroundColor</getter>
/// <setter>set_dropArrowBackgroundColor</setter>
/// <member name="cP:AjaxControlToolkit.DropDownExtender.dropArrowBackgroundColor" />
get_dropArrowBackgroundColor: function() {
return this._dropArrowBackgroundColor;
},
set_dropArrowBackgroundColor: function(value) {
if(this._dropArrowBackgroundColor != value) {
this._dropArrowBackgroundColor = value;
if(this.get_isInitialized())
this._dropArrow.style.backgroundColor = value;
this.raisePropertyChanged("dropArrowBackgroundColor");
}
},
/// <summary>
/// The arrow image URL of the DropDown control.
/// </summary>
/// <getter>get_dropArrowImageUrl</getter>
/// <setter>set_dropArrowImageUrl</setter>
/// <member name="cP:AjaxControlToolkit.DropDownExtender.dropArrowImageUrl" />
get_dropArrowImageUrl: function() {
return this._dropArrowImageUrl;
},
set_dropArrowImageUrl: function(value) {
if(this._dropArrowImageUrl != value) {
this._dropArrowImageUrl = value;
if(this.get_isInitialized()) {
if(this._dropArrow.className) {
this._dropArrow.className = "";
this._dropArrowWrapper.style.display = 'block';
}
this._dropArrowImage.src = value;
}
this.raisePropertyChanged("dropArrowImageUrl");
}
},
/// <summary>
/// The arrow width of the DropDown control.
/// </summary>
/// <getter>get_dropArrowWidth</getter>
/// <setter>set_dropArrowWidth</setter>
/// <member name="cP:AjaxControlToolkit.DropDownExtender.dropArrowWidth" />
get_dropArrowWidth: function() {
return this._dropArrowWidth;
},
set_dropArrowWidth: function(value) {
if(this._dropArrowWidth != value) {
this._dropArrowWidth = value;
if(this.get_isInitialized())
this._dropArrow.style.width = value;
this.raisePropertyChanged("dropArrowWidth");
}
},
/// <summary>
/// A Boolean value that specifies whether or not the cursor is over the DropDown control.
/// </summary>
/// <getter>get_isOver</getter>
/// <member name="cP:AjaxControlToolkit.DropDownExtender.isOver" />
get_isOver: function() {
return this._isOver;
},
/// <summary>
/// A Boolean value that specifies whether the DropDown control is open.
/// </summary>
/// <getter>get_isOpen</getter>
/// <member name="cP:AjaxControlToolkit.DropDownExtender.isOpen" />
get_isOpen: function() {
return this._isOpen;
},
/// <summary>
/// Fires when the control is being shown.
/// </summary>
/// <event add="add_showing" remove="remove_showing" raise="raise_showing" />
/// <member name="cE:AjaxControlToolkit.DropDownExtender.showing" />
add_showing: function(handler) {
this.get_events().addHandler('showing', handler);
},
remove_showing: function(handler) {
this.get_events().removeHandler('showing', handler);
},
raise_showing: function(eventArgs) {
var handler = this.get_events().getHandler('showing');
if(handler)
handler(this, eventArgs);
},
raiseShowing: function(eventArgs) {
Sys.Extended.Deprecated("raiseShowing(eventArgs)", "raise_showing(eventArgs)");
this.raise_showing(eventArgs);
},
/// <summary>
/// Fires after the control is shown.
/// </summary>
/// <event add="add_shown" remove="remove_shown" raise="raise_shown" />
/// <member name="cE:AjaxControlToolkit.DropDownExtender.shown" />
add_shown: function(handler) {
this.get_events().addHandler('shown', handler);
},
remove_shown: function(handler) {
this.get_events().removeHandler('shown', handler);
},
raise_shown: function(eventArgs) {
var handler = this.get_events().getHandler('shown');
if(handler)
handler(this, eventArgs);
},
raiseShown: function(eventArgs) {
Sys.Extended.Deprecated("raiseShown(eventArgs)", "raise_shown(eventArgs)");
this.raise_shown(eventArgs);
},
/// <summary>
/// Fires when the popup is shown.
/// </summary>
/// <event add="add_popup" remove="remove_popup" raise="raise_popup" />
/// <member name="cE:AjaxControlToolkit.DropDownExtender.popup" />
add_popup: function(handler) {
this.get_events().addHandler('popup', handler);
},
remove_popup: function(handler) {
this.get_events().removeHandler('popup', handler);
},
raise_popup: function(eventArgs) {
var handler = this.get_events().getHandler('popup');
if(handler)
handler(this, eventArgs);
},
raisePopup: function(eventArgs) {
Sys.Extended.Deprecated("raisePopup(eventArgs)", "raise_popup(eventArgs)");
this.raise_popup(eventArgs);
},
/// <summary>
/// Fires when the control is being hidden.
/// </summary>
/// <event add="add_hiding" remove="remove_hiding" raise="raise_hiding" />
/// <member name="cE:AjaxControlToolkit.DropDownExtender.hiding" />
add_hiding: function(handler) {
this.get_events().addHandler('hiding', handler);
},
remove_hiding: function(handler) {
this.get_events().removeHandler('hiding', handler);
},
raise_hiding: function(eventArgs) {
var handler = this.get_events().getHandler('hiding');
if(handler)
handler(this, eventArgs);
},
raiseHiding: function(eventArgs) {
Sys.Extended.Deprecated("raiseHiding(eventArgs)", "raise_hiding(eventArgs)");
this.raise_hiding(eventArgs);
},
/// <summary>
/// Fires after the control is hidden.
/// </summary>
/// <event add="add_hidden" remove="remove_hidden" raise="raise_hidden" />
/// <member name="cE:AjaxControlToolkit.DropDownExtender.hidden" />
add_hidden: function(handler) {
this.get_events().addHandler('hidden', handler);
},
remove_hidden: function(handler) {
this.get_events().removeHandler('hidden', handler);
},
raise_hidden: function(eventArgs) {
var handler = this.get_events().getHandler('hidden');
if(handler)
handler(this, eventArgs);
},
raiseHidden: function(eventArgs) {
Sys.Extended.Deprecated("raiseHidden(eventArgs)", "raise_hidden(eventArgs)");
this.raise_hidden(eventArgs);
},
/// <summary>
/// Fires on hovering over the control.
/// </summary>
/// <event add="add_hoverOver" remove="remove_hoverOver" raise="raise_hoverOver" />
/// <member name="cE:AjaxControlToolkit.DropDownExtender.hoverOver" />
add_hoverOver: function(handler) {
this.get_events().addHandler('hoverOver', handler);
},
remove_hoverOver: function(handler) {
this.get_events().removeHandler('hoverOver', handler);
},
raise_hoverOver: function(eventArgs) {
var handler = this.get_events().getHandler('hoverOver');
if(handler)
handler(this, eventArgs);
},
raiseHoverOver: function(eventArgs) {
Sys.Extended.Deprecated("raiseHoverOver(eventArgs)", "raise_hoverOver(eventArgs)");
this.raise_hoverOver(eventArgs);
},
/// <summary>
/// Fires on hovering out of the control.
/// </summary>
/// <event add="add_hoverOut" remove="remove_hoverOut" raise="raise_hoverOut" />
/// <member name="cE:AjaxControlToolkit.DropDownExtender.hoverOut" />
add_hoverOut: function(handler) {
this.get_events().addHandler('hoverOut', handler);
},
remove_hoverOut: function(handler) {
this.get_events().removeHandler('hoverOut', handler);
},
raise_hoverOut: function(eventArgs) {
var handler = this.get_events().getHandler('hoverOut');
if(handler)
handler(this, eventArgs);
},
raiseHoverOut: function(eventArgs) {
Sys.Extended.Deprecated("raiseHoverOut(eventArgs)", "raise_hoverOut(eventArgs)");
this.raise_hoverOut(eventArgs);
}
}
Sys.Extended.UI.DropDownBehavior.registerClass('Sys.Extended.UI.DropDownBehavior', Sys.Extended.UI.DynamicPopulateBehaviorBase);

View File

@@ -0,0 +1,483 @@
Type.registerNamespace('Sys.Extended.UI');
Sys.Extended.UI.DropShadowBehavior = function(element) {
// The DropShadowBehavior is used to attach a drop shadow to the element
// "element" - DOM Element the behavior is associated with
Sys.Extended.UI.DropShadowBehavior.initializeBase(this, [element]);
// our property values
this._opacity = 1.0;
this._width = 5;
// the div we create for the shadow.
this._shadowDiv = null;
// our timer for tracking position
this._trackPosition = null;
this._trackPositionDelay = 50;
this._timer = null;
this._tickHandler = null;
this._roundedBehavior = null;
this._shadowRoundedBehavior = null;
this._rounded = false;
this._radius = 5;
// our cache of our last size and position for tracking
this._lastX = null;
this._lastY = null;
this._lastW = null;
this._lastH = null;
}
Sys.Extended.UI.DropShadowBehavior.prototype = {
initialize: function() {
Sys.Extended.UI.DropShadowBehavior.callBaseMethod(this, 'initialize');
e = this.get_element();
// flip the styles position to relative so that we z-order properly.
if($common.getCurrentStyle(e, 'position', e.style.position) != "absolute")
e.style.position = "relative";
// set up our initial state
if(this._rounded)
this.setupRounded();
if(this._trackPosition)
this.startTimer();
this.setShadow();
},
dispose: function() {
this.stopTimer();
this.disposeShadowDiv();
Sys.Extended.UI.DropShadowBehavior.callBaseMethod(this, 'dispose');
},
buildShadowDiv: function() {
// Create the div that we'll use as the shadow
e = this.get_element();
if(!this.get_isInitialized() || !e || !this._width)
return;
// check if browser does not support css3
if(e.style.boxShadow == undefined && e.style.MozBoxShadow == undefined && e.style.WebkitBoxShadow == undefined) {
var div = document.createElement("DIV");
div.style.backgroundColor = "black";
div.style.position = "absolute";
if(e.id)
div.id = e.id + "_DropShadow";
// initialize a control around it, and
// set up the opacity behavior and rounding
this._shadowDiv = div;
e.parentNode.appendChild(div);
if(this._rounded) {
this._shadowDiv.style.height = Math.max(0, e.offsetHeight - (2 * this._radius)) + "px";
if(!this._shadowRoundedBehavior)
this._shadowRoundedBehavior = $create(Sys.Extended.UI.RoundedCornersBehavior, { "Radius": this._radius }, null, null, this._shadowDiv);
else
this._shadowRoundedBehavior.set_radius(this._radius);
} else if(this._shadowRoundedBehavior) {
this._shadowRoundedBehavior.set_radius(0);
}
if(this._opacity != 1.0)
this.setupOpacity();
this.setShadow(false, true);
this.updateZIndex();
}
},
disposeShadowDiv: function() {
// Dispose of the div we use as the shadow
if(this._shadowDiv) {
// on page teardown (or in an update panel, this may already
// be gone)
if(this._shadowDiv.parentNode)
this._shadowDiv.parentNode.removeChild(this._shadowDiv);
this._shadowDiv = null;
}
if(this._shadowRoundedBehavior) {
this._shadowRoundedBehavior.dispose();
this._shadowRoundedBehavior = null;
}
},
onTimerTick: function() {
// Timer's tick handler that is used to position the shadow when its target moves
this.setShadow();
},
startTimer: function() {
// Start the timer (and hence start tracking the bounds of the target element)
if(!this._timer) {
if(!this._tickHandler)
this._tickHandler = Function.createDelegate(this, this.onTimerTick);
this._timer = new Sys.Timer();
this._timer.set_interval(this._trackPositionDelay);
this._timer.add_tick(this._tickHandler);
this._timer.set_enabled(true);
}
},
stopTimer: function() {
// Stop the timer (and hence stop tracking the bounds of the target element)
// on stop, just clean the thing up completely
if(this._timer) {
this._timer.remove_tick(this._tickHandler);
this._timer.set_enabled(false);
this._timer.dispose();
this._timer = null;
}
},
///<summary>
/// Draws shadow around the control.
///</summary>
/// <remarks>
/// This function does most part of work when positioning and sizing the shadow.
/// It caches values to avoid extra work.
/// It's called on a timer so we need to keep its weight light.
/// </remarks>
/// <param name="force" type="Boolean">Whether to force the bounds change.</param>
/// <param name="norecurse" type="Boolean">Whether to recurse if we need to recreate the shadow div</param>
/// <member name="cM:AjaxControlToolkit.DropShadowExtender.setShadow" />
setShadow: function(force, norecurse) {
// This function does the heavy lifting of positioning and sizing the shadow.
// It caches values to avoid extra work - it's called on a timer so we need to
// keep it light weight.
// "force" - whether to force the bounds change
// "norecurse" - whether to recurse if we need to recreate the shadow div
e = this.get_element();
if(!this.get_isInitialized() || !e || (!this._width && !force))
return;
// execute if browser does not support css3
if(e.style.boxShadow == undefined && e.style.MozBoxShadow == undefined && e.style.WebkitBoxShadow == undefined) {
var existingShadow = this._shadowDiv;
if(!existingShadow)
this.buildShadowDiv();
var location = { x: e.offsetLeft, y: e.offsetTop };
if(force || this._lastX != location.x || this._lastY != location.y || !existingShadow) {
this._lastX = location.x;
this._lastY = location.y;
var w = this.get_width();
location.x += w;
location.y += w;
$common.setLocation(this._shadowDiv, location);
}
var h = e.offsetHeight,
w = e.offsetWidth;
if(force || h != this._lastH || w != this._lastW || !existingShadow) {
this._lastW = w;
this._lastH = h;
if(!this._rounded || !existingShadow || norecurse) {
this._shadowDiv.style.width = w + "px";
this._shadowDiv.style.height = h + "px";
} else {
// recurse if we need to redo the div
this.disposeShadowDiv();
this.setShadow();
}
}
if(this._shadowDiv)
this._shadowDiv.style.visibility = $common.getCurrentStyle(e, 'visibility');
} else { // create dropshadow effect on div if browser supports css3
var boxShadowVals;
//To display effect of opacity set different color
// on the basis of selected % of opacity
if(this._opacity == ".25")
boxShadowVals = this._width + "px " + this._width + "px " + this._width + "px " + "#D3D3D3";
else if(this._opacity == ".5")
boxShadowVals = this._width + "px " + this._width + "px " + this._width + "px " + "#778899";
else if(this._opacity == ".75")
boxShadowVals = this._width + "px " + this._width + "px " + this._width + "px " + "#808080";
else
boxShadowVals = this._width + "px " + this._width + "px " + this._width + "px " + "#000";
// this works in IE9 and Chrome latest versions
if(e.style.boxShadow != undefined)
e.style.boxShadow = boxShadowVals;
else if(e.style.MozBoxShadow != undefined) // this works for Mozila Firefox
e.style.MozBoxShadow = boxShadowVals; // this works for Chrome older version, Safari
else if(e.style.WebkitBoxShadow != undefined)
e.style.WebkitBoxShadow = boxShadowVals;
}
},
setupOpacity: function() {
// Set the opacity of the shadow div
if(this.get_isInitialized() && this._shadowDiv)
$common.setElementOpacity(this._shadowDiv, this._opacity);
},
setupRounded: function() {
// Demand create and initialize the RoundedCornersBehavior
if(!this._roundedBehavior && this._rounded)
this._roundedBehavior = $create(Sys.Extended.UI.RoundedCornersBehavior, null, null, null, this.get_element());
if(this._roundedBehavior)
this._roundedBehavior.set_radius(this._rounded ? this._radius : 0);
},
updateZIndex: function() {
// Update the z-Index so the shadow div remains behind the target element
if(!this._shadowDiv)
return;
var e = this.get_element(),
targetZIndex = e.style.zIndex,
shadowZIndex = this._shadowDiv.style.zIndex;
if(shadowZIndex && targetZIndex && targetZIndex > shadowZIndex) {
return;
} else {
targetZIndex = Math.max(2, targetZIndex);
shadowZIndex = targetZIndex - 1;
}
e.style.zIndex = targetZIndex;
this._shadowDiv.style.zIndex = shadowZIndex;
},
updateRoundedCorners: function() {
// Update the RoundedCorndersBehavior and recreate the shadow div so its corners are rounded as well
if(this.get_isInitialized()) {
this.setupRounded();
this.disposeShadowDiv();
this.setShadow();
}
},
/// <summary>
/// A number that represents the opacity of the drop shadow from 0 (fully transparent) to 1.0 (fully opaque).
/// </summary>
/// <remarks>
/// The default is .5.
/// </remarks>
/// <getter>get_opacity</getter>
/// <setter>set_opacity</setter>
/// <member name="cP:AjaxControlToolkit.DropShadowExtender.opacity" />
get_opacity: function() {
return this._opacity;
},
set_opacity: function(value) {
if(this._opacity != value) {
this._opacity = value;
this.setShadow();
this.setupOpacity();
this.raisePropertyChanged('opacity');
}
},
get_Opacity: function() {
Sys.Extended.Deprecated("get_Opacity", "get_opacity");
return this.get_opacity();
},
set_Opacity: function(value) {
Sys.Extended.Deprecated("set_Opacity", "set_opacity");
this.set_opacity(value);
},
/// <summary>
/// A Boolean value that specifies whether or not corners of the target and drop shadow should be rounded.
/// </summary>
/// <getter>get_rounded</getter>
/// <setter>set_rounded</setter>
/// <member name="cP:AjaxControlToolkit.DropShadowExtender.rounded" />
get_rounded: function() {
return this._rounded;
},
set_rounded: function(value) {
if(value != this._rounded) {
this._rounded = value;
this.updateRoundedCorners();
this.raisePropertyChanged('rounded');
}
},
get_Rounded: function() {
Sys.Extended.Deprecated("get_Rounded", "get_rounded");
return this.get_rounded();
},
set_Rounded: function(value) {
Sys.Extended.Deprecated("set_Rounded", "set_rounded");
this.set_rounded(value);
},
/// <summary>
/// An integer that specifies the radius of rounded corners in pixels.
/// </summary>
/// <getter>get_radius</getter>
/// <setter>set_radius</setter>
/// <member name="cP:AjaxControlToolkit.DropShadowExtender.radius" />
get_radius: function() {
return this._radius;
},
set_radius: function(value) {
if(value != this._radius) {
this._radius = value;
this.updateRoundedCorners();
this.raisePropertyChanged('radius');
}
},
get_Radius: function() {
Sys.Extended.Deprecated("get_Radius", "get_radius");
return this.get_radius();
},
set_Radius: function(value) {
Sys.Extended.Deprecated("set_Radius", "set_radius");
this.set_radius(value);
},
/// <summary>
/// An integer that specifies the drop shadow width in pixels.
/// </summary>
/// <remarks>
/// The default is 5.
/// </remarks>
/// <getter>get_width</getter>
/// <setter>set_width</setter>
/// <member name="cP:AjaxControlToolkit.DropShadowExtender.width" />
get_width: function() {
return this._width;
},
set_width: function(value) {
if(value != this._width) {
this._width = value;
if(this._shadowDiv)
$common.setVisible(this._shadowDiv, value > 0);
this.setShadow(true);
this.raisePropertyChanged('width');
}
},
get_Width: function() {
Sys.Extended.Deprecated("get_Width", "get_width");
return this.get_width();
},
set_Width: function(value) {
Sys.Extended.Deprecated("set_Width", "set_width");
this.set_width(value);
},
/// <summary>
/// A number that specifies the length of the timer interval that is used when tracking the targer position.
/// </summary>
/// <getter>get_trackPositionDelay</getter>
/// <setter>set_trackPositionDelay</setter>
/// <member name="cP:AjaxControlToolkit.DropShadowExtender.trackPositionDelay" />
get_trackPositionDelay: function() {
return this._trackPositionDelay;
},
set_trackPositionDelay: function(value) {
if(value != this._trackPositionDelay) {
this._trackPositionDelay = value;
if(!e)
e = this.get_element();
// execute if browser does not support css3
if(e.style.boxShadow == undefined && e.style.MozBoxShadow == undefined && e.style.WebkitBoxShadow == undefined) {
if(this._trackPosition) {
this.stopTimer();
this.startTimer();
}
this.raisePropertyChanged('trackPositionDelay');
}
}
},
get_TrackPositionDelay: function() {
Sys.Extended.Deprecated("get_TrackPositionDelay", "get_trackPositionDelay");
return this.get_trackPositionDelay();
},
set_TrackPositionDelay: function(value) {
Sys.Extended.Deprecated("set_TrackPositionDelay", "set_trackPositionDelay");
this.set_trackPositionDelay(value);
},
/// <summary>
/// A Boolean value that specifies whether the drop shadow should track the position of the panel to which it is attached.
/// </summary>
/// <remarks>
/// Set this property to true if the panel is absolutely positioned or if it might move at runtime. The default is false.
/// </remarks>
/// <getter>get_trackPosition</getter>
/// <setter>set_trackPosition</setter>
/// <member name="cP:AjaxControlToolkit.DropShadowExtender.trackPosition" />
get_trackPosition: function() {
// Whether the drop shadow should track the position of the panel it is attached to.
// Use this if the panel is absolutely positioned or will otherwise move.
return this._trackPosition;
},
set_trackPosition: function(value) {
if(value != this._trackPosition) {
this._trackPosition = value;
if(!e)
e = this.get_element();
// execute if browser does not support css3
if(e.style.boxShadow == undefined && e.style.MozBoxShadow == undefined && e.style.WebkitBoxShadow == undefined) {
if(this.get_element()) {
if(value)
this.startTimer();
else
this.stopTimer();
}
this.raisePropertyChanged('trackPosition');
}
}
},
get_TrackPosition: function() {
Sys.Extended.Deprecated("get_TrackPosition", "get_trackPosition");
return this.get_trackPosition();
},
set_TrackPosition: function(value) {
Sys.Extended.Deprecated("set_TrackPosition", "set_trackPosition");
this.set_trackPosition(value);
}
}
Sys.Extended.UI.DropShadowBehavior.registerClass('Sys.Extended.UI.DropShadowBehavior', Sys.Extended.UI.BehaviorBase);

View File

@@ -0,0 +1,757 @@
// This behavior exists to trap a drop on the list. When an item is dropped,
// this behavior owns firing the postback so the server-side ReorderList control knows it happened.
Type.registerNamespace('Sys.Extended.UI');
Sys.Extended.UI.RepeatDirection = function() {
throw Error.invalidOperation();
}
Sys.Extended.UI.RepeatDirection.prototype = {
Vertical: 0,
Horizontal: 1
}
Sys.Extended.UI.RepeatDirection.registerEnum('Sys.Extended.UI.RepeatDirection');
Sys.Extended.UI.DragDropList = function(associatedElement) {
Sys.Extended.UI.DragDropList.initializeBase(this, [associatedElement]);
this._acceptedDataTypes = [];
this._isDragging = null;
this._dataType = null;
this._dragMode = Sys.Extended.UI.DragMode.Move;
this._dragVisual = null;
this._direction = Sys.Extended.UI.RepeatDirection.Vertical;
this._emptyTemplate = null;
this._emptyTemplateInstance = null;
this._dropCueTemplate = null;
this._dropCueTemplateInstance = null;
this._floatContainerInstance = null;
this._originalParent = null;
this._originalNextSibling = null;
this._originalZIndex = null;
this._currentContext = null;
this._data = null;
}
Sys.Extended.UI.DragDropList.IsValidDataType = function(dataType) {
if(dataType && typeof (dataType) == 'string' && dataType.length >= 4)
return dataType.substring(0, 4) === "HTML";
return false;
}
Sys.Extended.UI.DragDropList.prototype = {
get_data: function() {
return this._data;
},
set_data: function(value) {
this._data = value;
},
initialize: function() {
Sys.Extended.UI.DragDropList.callBaseMethod(this, 'initialize');
this.get_element().__dragDropList = this;
Sys.Extended.UI.DragDropManager.registerDropTarget(this);
},
// -- IDragSource (related) members --
startDragDrop: function(dragObject, context, dragVisual) {
if(!this._isDragging) {
this._isDragging = true;
this._currentContext = context;
if(!dragVisual)
dragVisual = this.createDragVisual(dragObject);
else
this._dragVisual = dragVisual;
Sys.Extended.UI.DragDropManager.startDragDrop(this, dragVisual, context, !(Sys.Browser.agent == Sys.Browser.InternetExplorer && Sys.Browser.version > 7 && Sys.Browser.documentMode != 0));
}
},
createDragVisual: function(dragObject) {
if(this._dragMode === Sys.Extended.UI.DragMode.Copy)
this._dragVisual = dragObject.cloneNode(true);
else
this._dragVisual = dragObject;
var oldOffset = Sys.Extended.UI.DragDropManager._getInstance().getScrollOffset(dragObject, true);
this._dragVisual.preDragWidth = this._dragVisual.style.width;
this._dragVisual.preDragHeight = this._dragVisual.style.height;
this._dragVisual.style.width = dragObject.offsetWidth + "px";
this._dragVisual.style.height = dragObject.offsetHeight + "px";
this._dragVisual.style.opacity = "0.4";
this._dragVisual.style.filter = "progid:DXImageTransform.Microsoft.BasicImage(opacity=0.4);";
this._originalZIndex = this._dragVisual.style.zIndex;
this._dragVisual.style.zIndex = Sys.Extended.UI.zIndex.DropWatcherDragVisual;
this._originalParent = this._dragVisual.parentNode;
this._originalNextSibling = Sys.Extended.UI.DragDropManager._getInstance().getNextSibling(this._dragVisual);
var currentLocation = $common.getLocation(dragObject);
// Store the drag object in a temporary container to make it self-contained.
var dragVisualContainer = this._getFloatContainer();
$common.setLocation(dragVisualContainer, currentLocation);
if(Sys.Extended.UI.DragDropManager._getInstance().hasParent(this._dragVisual))
this._dragVisual.parentNode.removeChild(this._dragVisual);
dragVisualContainer.appendChild(this._dragVisual);
var newOffset = Sys.Extended.UI.DragDropManager._getInstance().getScrollOffset(dragObject, true);
if(oldOffset.x !== newOffset.x || oldOffset.y !== newOffset.y) {
var diff = Sys.Extended.UI.DragDropManager._getInstance().subtractPoints(oldOffset, newOffset);
var location = Sys.Extended.UI.DragDropManager._getInstance().subtractPoints(currentLocation, diff);
$common.setLocation(dragVisualContainer, location);
}
return dragVisualContainer;
},
get_emptyTemplate: function() {
return this._emptyTemplate;
},
set_emptyTemplate: function(value) {
this._emptyTemplate = value;
},
get_dragDataType: function() {
return this._dataType;
},
set_dragDataType: function(value) {
this._dataType = value;
},
getDragData: function(context) {
return context;
},
get_dragMode: function() {
return this._dragMode;
},
set_dragMode: function(value) {
this._dragMode = value;
},
dispose: function() {
Sys.Extended.UI.DragDropManager.unregisterDropTarget(this);
this.get_element().__dragDropList = null;
Sys.Extended.UI.DragDropList.callBaseMethod(this, 'dispose');
},
onDragStart: function() {
this._validate();
},
onDrag: function() {
},
onDragEnd: function(cancelled) {
if(this._floatContainerInstance) {
if(this._dragMode === Sys.Extended.UI.DragMode.Copy) {
this._floatContainerInstance.removeChild(this._dragVisual);
} else {
// NOTE: There seems to be a cursor issue in Mozilla when setting the opacity to 1. We
// can work around this by setting the opacity to anything lower than 1 instead.
this._dragVisual.style.opacity = "0.999";
//_dragVisual.style.opacity = "1";
this._dragVisual.style.filter = "";
this._dragVisual.style.zIndex = this._originalZIndex ? this._originalZIndex : 0;
// restore the height/width of the drag visual.
//
if(this._dragVisual.preDragWidth != null) {
this._dragVisual.style.width = this._dragVisual.preDragWidth;
this._dragVisual.preDragWidth = null;
}
if(this._dragVisual.preDragHeight != null) {
this._dragVisual.style.height = this._dragVisual.preDragHeight;
this._dragVisual.preDragHeight = null;
}
if(cancelled) {
// Re-parent the drag visual to its original position.
this._dragVisual.parentNode.removeChild(this._dragVisual);
if(this._originalNextSibling != null)
this._originalParent.insertBefore(this._dragVisual, this._originalNextSibling);
else
this._originalParent.appendChild(this._dragVisual);
} else {
if(this._dragVisual.parentNode === this._floatContainerInstance)
this._dragVisual.parentNode.removeChild(this._dragVisual);
}
}
// Remove the container.
document.body.removeChild(this._floatContainerInstance);
}
else {
this._dragVisual.parentNode.removeChild(this._dragVisual);
}
if(!cancelled && this._data && this._dragMode === Sys.Extended.UI.DragMode.Move) {
var data = this.getDragData(this._currentContext);
if(this._data && data)
Array.remove(this._data, data);
}
this._isDragging = false;
this._validate();
},
// -- IDropTarget (related) members --
get_direction: function() {
return this._direction;
},
set_direction: function(value) {
this._direction = value;
},
get_acceptedDataTypes: function() {
return this._acceptedDataTypes;
},
set_acceptedDataTypes: function(value) {
if(typeof (value) == "string")
this._acceptedDataTypes = value.split(",");
else
this._acceptedDataTypes = value;
},
get_dropCueTemplate: function() {
return this._dropCueTemplate;
},
set_dropCueTemplate: function(value) {
this._dropCueTemplate = value;
},
get_dropTargetElement: function() {
return this.get_element();
},
canDrop: function(dragMode, dataType, data) {
for(var i = 0; i < this._acceptedDataTypes.length; i++)
if(this._acceptedDataTypes[i] === dataType)
return true;
return false;
},
drop: function(dragMode, dataType, data) {
if(Sys.Extended.UI.DragDropList.IsValidDataType(dataType) && dragMode === Sys.Extended.UI.DragMode.Move) {
// Re-parent the drag visual.
dragVisual = data;
var potentialNextSibling = this._findPotentialNextSibling(dragVisual);
this._setDropCueVisible(false, dragVisual);
dragVisual.parentNode.removeChild(dragVisual);
if(potentialNextSibling)
this.get_element().insertBefore(dragVisual, potentialNextSibling);
else
this.get_element().appendChild(dragVisual);
} else {
this._setDropCueVisible(false);
}
},
onDragEnterTarget: function(dragMode, dataType, data) {
if(Sys.Extended.UI.DragDropList.IsValidDataType(dataType)) {
this._setDropCueVisible(true, data);
this._validate();
}
},
onDragLeaveTarget: function(dragMode, dataType, data) {
if(Sys.Extended.UI.DragDropList.IsValidDataType(dataType)) {
this._setDropCueVisible(false);
this._validate();
}
},
onDragInTarget: function(dragMode, dataType, data) {
if(Sys.Extended.UI.DragDropList.IsValidDataType(dataType))
this._setDropCueVisible(true, data);
},
_setDropCueVisible: function(visible, dragVisual) {
if(this._dropCueTemplate) {
if(visible) {
if(!this._dropCueTemplateInstance) {
var documentContext = document.createDocumentFragment();
this._dropCueTemplateInstance = this._dropCueTemplate.cloneNode(true);
}
var potentialNextSibling = this._findPotentialNextSibling(dragVisual);
if(!Sys.Extended.UI.DragDropManager._getInstance().hasParent(this._dropCueTemplateInstance)) {
// Add drop cue.
if(potentialNextSibling)
this.get_element().insertBefore(this._dropCueTemplateInstance, potentialNextSibling);
else
this.get_element().appendChild(this._dropCueTemplateInstance);
this._dropCueTemplateInstance.style.width = dragVisual.offsetWidth + "px";
this._dropCueTemplateInstance.style.height = dragVisual.offsetHeight + "px";
} else {
// Move drop cue.
if(Sys.Extended.UI.DragDropManager._getInstance().getNextSibling(this._dropCueTemplateInstance) !== potentialNextSibling) {
this.get_element().removeChild(this._dropCueTemplateInstance);
if(potentialNextSibling)
this.get_element().insertBefore(this._dropCueTemplateInstance, potentialNextSibling);
else
this.get_element().appendChild(this._dropCueTemplateInstance);
}
}
} else {
if(this._dropCueTemplateInstance && Sys.Extended.UI.DragDropManager._getInstance().hasParent(this._dropCueTemplateInstance))
this.get_element().removeChild(this._dropCueTemplateInstance);
}
}
},
_findPotentialNextSibling: function(dragVisual) {
var dragVisualRect = $common.getBounds(dragVisual),
isVertical = (this._direction === 0 /*Sys.Extended.UI.RepeatDirection.Vertical*/),
nodeRect;
for(var node = this.get_element().firstChild; node !== null; node = node.nextSibling) {
if(node.innerHTML && node !== this._dropCueTemplateInstance && node !== this._emptyTemplateInstance) {
nodeRect = $common.getBounds(node);
if((!isVertical && dragVisualRect.x <= nodeRect.x) || (isVertical && dragVisualRect.y <= nodeRect.y))
return node;
}
}
return null;
},
_validate: function() {
var visible = (this._dropCueTemplateInstance == null || !Sys.Extended.UI.DragDropManager._getInstance().hasParent(this._dropCueTemplateInstance));
// Check if there are draggables left in this host. If not, display a placeholder.
var count = 0;
for(var node = this.get_element().firstChild; node !== null; node = node.nextSibling)
if(node.innerHTML && node !== this._emptyTemplateInstance && node !== this._dropCueTemplateInstance)
count++;
if(count > 0)
visible = false;
this._setEmptyTemplateVisible(visible);
},
_setEmptyTemplateVisible: function(visible) {
if(this._emptyTemplate)
if(visible) {
if(!this._emptyTemplateInstance)
this._emptyTemplateInstance = this._emptyTemplate.createInstance(this.get_element()).instanceElement;
else if(!Sys.Extended.UI.DragDropManager._getInstance().hasParent(this._emptyTemplateInstance))
this.get_element().appendChild(this._emptyTemplateInstance);
} else {
if(this._emptyTemplateInstance && Sys.Extended.UI.DragDropManager._getInstance().hasParent(this._emptyTemplateInstance))
this.get_element().removeChild(this._emptyTemplateInstance);
}
},
_getFloatContainer: function() {
if(!this._floatContainerInstance) {
this._floatContainerInstance = document.createElement(this.get_element().tagName);
var none = "0px 0px 0px 0px";
this._floatContainerInstance.style.position = "absolute";
this._floatContainerInstance.style.padding = none;
this._floatContainerInstance.style.margin = none;
this._floatContainerInstance.className = 'dragVisualContainer';
document.body.appendChild(this._floatContainerInstance);
} else if(!Sys.Extended.UI.DragDropManager._getInstance().hasParent(this._floatContainerInstance)) {
document.body.appendChild(this._floatContainerInstance);
}
return this._floatContainerInstance;
}
}
Sys.Extended.UI.DragDropList.registerClass('Sys.Extended.UI.DragDropList', Sys.Extended.UI.BehaviorBase, Sys.Extended.UI.IDragSource, Sys.Extended.UI.IDropTarget, Sys.IDisposable);
function callbackSuccessStub(response, context) {
var contextSplit = context.split(":"),
id = contextSplit[0],
obj = $find(id);
if(obj)
obj._onCallbackSuccess(response, contextSplit[1]);
}
function callbackErrorStub(response, context) {
var contextSplit = context.split(":"),
id = contextSplit[0],
obj = $find(id);
alert('error');
if(obj)
obj._onCallbackError(response, contextSplit[1]);
}
Sys.Extended.UI.DragDropWatcher = function(e) {
Sys.Extended.UI.DragDropWatcher.initializeBase(this, [e]);
this._childList = new Array();
this._inProgressDrops = new Object();
this._postbackCode = null;
this._callbackCssStyle = null;
this._argReplaceString = null;
this._argContextString = null;
this._argErrorString = null;
this._argSuccessString = null;
}
Sys.Extended.UI.DragDropWatcher.prototype = {
dispose: function() {
Sys.Extended.UI.DragDropWatcher.callBaseMethod(this, 'dispose');
},
initialize: function() {
Sys.Extended.UI.DragDropWatcher.callBaseMethod(this, 'initialize');
this._saveChildOrder();
},
add_reorderComplete: function(handler) {
this.get_events().addHandler("reorderComplete", handler);
},
remove_reorderComplete: function(handler) {
this.get_events().removeHandler("reorderComplete", handler);
},
raiseReorderComplete: function() {
var handler = this.get_events().getHandler("reorderComplete");
if(handler)
handler(this, Sys.EventArgs.Empty);
},
findChild: function(parent, childId) {
// just walk through the list of children looking for the child
var childIndex = 0,
nodes = parent.childNodes;
for(var i = 0; i < nodes.length; i++) {
var item = nodes[i];
// nodeName check is for Safari which enumerates LI contents as well
if((item != null) && (item.nodeName == "LI")) {
if(item.id == childId)
return childIndex;
childIndex++;
}
}
return -1;
},
canDrop: function(dragMode, dataType, data) {
if(this._inProgressDrops && this._inProgressDrops.length > 0)
return false;
var dropOk = Sys.Extended.UI.DragDropWatcher.callBaseMethod(this, 'canDrop', [dragMode, dataType, data]);
if(dropOk) {
// data is the thing being dragged
var dragVisualRect = $common.getBounds(data),
nodeRect,
hitInsertNode = false,
e = this.get_element();
for(var node = e.firstChild; node != null && !hitInsertNode; node = node.nextSibling) {
if(!node.id)
continue;
nodeRect = $common.getBounds(node);
if(dragVisualRect.y <= nodeRect.y)
break;
hitInsertNode = (node.id.lastIndexOf("Insert", node.id.length - 6) != -1);
}
dropOk = !hitInsertNode;
}
return dropOk;
},
drop: function(dragMode, dataType, data) {
Sys.Extended.UI.DragDropWatcher.callBaseMethod(this, 'drop', [dragMode, dataType, data]);
var childId = data.id;
if(!this._postbackCode || !childId)
return;
// figure out which child index we're moving to
var newIndex = this.findChild(this.get_element(), childId);
Sys.Debug.assert(newIndex != -1, String.format(Sys.Extended.UI.Resources.ReorderList_DropWatcherBehavior_NoChild, childId));
var oldIndex = this._getSavedChildIndex(childId);
if(newIndex != -1 && newIndex != oldIndex) {
this._saveChildOrder();
this.doPostBack(childId, newIndex, oldIndex);
}
},
_setupDropState: function(childId, newIndex, oldIndex) {
if(childId) {
var child = $get(childId);
this._inProgressDrops[childId] = { "oldCss": child.className, "newIndex": newIndex, "oldIndex": oldIndex };
if(this._callbackCssStyle)
child.className = this._callbackCssStyle;
}
},
_onDropCallback: function(childId) {
if(childId) {
this.set_ClientState("true");
var item = this._inProgressDrops[childId];
if(item) {
var child = $get(childId);
if(this._callbackCssStyle)
child.className = item.oldCss;
delete this._inProgressDrops[childId];
}
return item;
}
},
doPostBack: function(childId, newIndex, oldIndex) {
var item = this._inProgressDrops[childId];
if(item)
// don't allow recursive drops.
return;
// setup the postback string
var postbackArg = "reorder:" + childId + ":" + oldIndex.toString() + ":" + newIndex.toString();
// replace the specified replace string with the arg and build the full postback string
var postbackCode = this._postbackCode.replace(this._argReplaceString, postbackArg);
if(this._argSuccessString)
postbackCode = postbackCode.replace(this._argSuccessString, "callbackSuccessStub");
if(this._argErrorString)
postbackCode = postbackCode.replace(this._argErrorString, "callbackErrorStub");
if(this._argContextString)
postbackCode = postbackCode.replace(this._argContextString, this.get_id() + ":" + childId);
this._setupDropState(childId, newIndex, oldIndex);
window.setTimeout(postbackCode, 0);
},
_onCallbackSuccess: function(response, context) {
if(response && response.length > 0) {
this._onCallbackError(response, context);
} else {
this._onDropCallback(context);
this.raiseReorderComplete();
}
},
_onCallbackError: function(response, context) {
var item = this._onDropCallback(context);
// undo the move
if(item.oldIndex || item.newIndex) {
this._saveChildOrder();
this.doReorder(item.newIndex, item.oldIndex, true);
}
alert(String.format(Sys.Extended.UI.Resources.ReorderList_DropWatcherBehavior_CallbackError, response));
},
doReorder: function(oldIndex, newIndex, skipPostback) {
var e = this.get_element(),
children = this._childList;
if(oldIndex >= 0 && children.length > oldIndex && oldIndex != newIndex) {
var child = $get(children[oldIndex]),
item = this._inProgressDrops[child.id];
if(item)
// don't allow recursive drops.
return;
if(child) {
if(newIndex > oldIndex)
// if the destination element is after the source element
// we can't insert after, we need to insert after.
// so we increment the newIndex.
newIndex++;
var append = newIndex >= children.length;
try {
e.removeChild(child);
} catch(e) {
// Safari likes to throw NOT_FOUND_ERR (DOMException 8)
// but it seems to work fine anyway.
//
}
if(append) {
e.appendChild(child);
} else {
var childAtNewIndex = $get(children[newIndex]);
e.insertBefore(child, childAtNewIndex);
}
if(!skipPostback) {
this.doPostBack(child.id, newIndex, oldIndex);
} else {
this._saveChildOrder();
this.raiseReorderComplete();
}
}
}
},
getItem: function(index) {
if(!this._childList)
this._saveChildOrder();
return this._childList[index];
},
_getSavedChildIndex: function(childId) {
if(this._childList && childId)
for(var i = 0; i < this._childList.length; i++)
if(childId == this._childList[i])
return i;
return -1;
},
_saveChildOrder: function() {
var e = this.get_element();
if(!e)
return;
var children = e.childNodes;
this._childList = [];
var childCount = 0;
for(var i = 0; i < children.length; i++)
// note Safari is returning all children, not just direct ones
if(children[i] && children[i].parentNode === e && children[i].tagName && children[i].tagName.toLowerCase() == "li")
this._childList[childCount++] = children[i].id;
},
get_argReplaceString: function() {
return this._argReplaceString;
},
set_argReplaceString: function(value) {
if(this._argReplaceString != value) {
this._argReplaceString = value;
this.raisePropertyChanged('argReplaceString');
}
},
get_argContextString: function() {
return this._argContextString;
},
set_argContextString: function(value) {
if(this._argContextString != value) {
this._argContextString = value;
this.raisePropertyChanged('argContextString');
}
},
get_argErrorString: function() {
return this._argErrorString;
},
set_argErrorString: function(value) {
if(this._argErrorString != value) {
this._argErrorString = value;
this.raisePropertyChanged('argErrorString');
}
},
get_argSuccessString: function() {
return this._argSuccessString;
},
set_argSuccessString: function(value) {
if(this._argSuccessString != value) {
this._argSuccessString = value;
this.raisePropertyChanged('argSuccessString');
}
},
get_postbackCode: function() {
return this._postbackCode;
},
set_postbackCode: function(value) {
if(this._postbackCode != value) {
this._postbackCode = value;
this.raisePropertyChanged('postbackCode');
}
},
get_callbackCssStyle: function() {
return this._callbackCssStyle;
},
set_callbackCssStyle: function(value) {
if(this._callbackCssStyle != value) {
this._callbackCssStyle = value;
this.raisePropertyChanged('callbackCssStyle');
}
}
}
Sys.Extended.UI.DragDropWatcher.registerClass('Sys.Extended.UI.DragDropWatcher', Sys.Extended.UI.DragDropList);

View File

@@ -0,0 +1,421 @@
Type.registerNamespace('Sys.Extended.UI');
Sys.Extended.UI.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.
// [element] is DOM Element the behavior is associated with.
Sys.Extended.UI.DynamicPopulateBehavior.initializeBase(this, [element]);
this._servicePath = location.pathname;
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;
this._populated = false;
}
Sys.Extended.UI.DynamicPopulateBehavior.prototype = {
initialize: function() {
Sys.Extended.UI.DynamicPopulateBehavior.callBaseMethod(this, 'initialize');
$common.prepareHiddenElementForATDeviceUpdate();
if(this._populateTriggerID) {
var populateTrigger = $get(this._populateTriggerID);
if(populateTrigger) {
this._clickHandler = Function.createDelegate(this, this._onPopulateTriggerClick);
$addHandler(populateTrigger, "click", this._clickHandler);
}
}
},
dispose: function() {
if(this._populateTriggerID && this._clickHandler) {
var populateTrigger = $get(this._populateTriggerID);
if(populateTrigger)
$removeHandler(populateTrigger, "click", this._clickHandler);
this._populateTriggerID = null;
this._clickHandler = null;
}
Sys.Extended.UI.DynamicPopulateBehavior.callBaseMethod(this, 'dispose');
},
/// <summary>
/// Uses dymanic content to populate the target element.
/// </summary>
/// <remarks>
/// If an element to populate is in a data-bound repeating control, the contextKey parameter can be an ID of the current row.
/// </remarks>
/// <param name="contextKey" type="String">A string to pass to the Web service method or page method.</param>
/// <member name="cM:AjaxControlToolkit.DynamicPopulateExtender.populate" />
populate: function(contextKey) {
// 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.
if(contextKey)
this._contextKey = contextKey;
if(this._populated && this._cacheDynamicResults)
return;
if(this._currentCallID == -1) {
var eventArgs = new Sys.CancelEventArgs();
this.raise_populating(eventArgs);
if(eventArgs.get_cancel())
return;
this._setUpdating(true);
}
if(this._customScript) {
var scriptResult = eval(this._customScript);
this._setTargetHtml(scriptResult);
this._setUpdating(false);
} else {
this._currentCallID = ++this._callID;
if(!this._servicePath || !this._serviceMethod)
return;
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
if(userContext != this._currentCallID)
return;
this._setTargetHtml(result);
this._setUpdating(false);
},
_onMethodError: function(webServiceError, userContext, methodName) {
// Callback used when the populating service fails
if(userContext != this._currentCallID)
return;
if(webServiceError.get_timedOut())
this._setTargetHtml(Sys.Extended.UI.Resources.DynamicPopulate_WebServiceTimeout);
else
this._setTargetHtml(String.format(Sys.Extended.UI.Resources.DynamicPopulate_WebServiceError, webServiceError.get_statusCode()));
this._setUpdating(false);
},
_onPopulateTriggerClick: function() {
this.populate(this._contextKey);
},
_setUpdating: function(updating) {
// Toggle the display elements to indicate if they are being updated or not
// updating - Whether or not the display should indicated it is being updated
this.setStyle(updating);
if(!updating) {
this._currentCallID = -1;
this._populated = true;
this.raise_populated(this, Sys.EventArgs.Empty);
}
},
_setTargetHtml: function(value) {
var e = this.get_element()
if(e) {
if(e.tagName == "INPUT")
e.value = value;
else
e.innerHTML = value;
}
},
/// <summary>
/// Sets the dislpayed style.
/// </summary>
/// <param name="updating" type="Boolean">A Boolean value that specifies whether the display is being updated.</param>
/// <member name="cM:AjaxControlToolkit.DynamicPopulateExtender.setStyle" />
setStyle: function(updating) {
// Set the style of the display
// updating - 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("");
},
/// <summary>
/// A Boolean value that specifies whether or the target content should be cleared when the update begins.
/// </summary>
/// <getter>get_clearContentsDuringUpdate</getter>
/// <setter>set_clearContentsDuringUpdate</setter>
/// <member name="cP:AjaxControlToolkit.DynamicPopulateExtender.clearContentsDuringUpdate" />
get_clearContentsDuringUpdate: function() {
return this._clearDuringUpdate;
},
set_clearContentsDuringUpdate: function(value) {
if(this._clearDuringUpdate != value) {
this._clearDuringUpdate = value;
this.raisePropertyChanged('clearContentsDuringUpdate');
}
},
get_ClearContentsDuringUpdate: function() {
Sys.Extended.Deprecated("get_ClearContentsDuringUpdate", "get_clearContentsDuringUpdate");
return this.get_clearContentsDuringUpdate();
},
set_ClearContentsDuringUpdate: function(value) {
Sys.Extended.Deprecated("set_ClearContentsDuringUpdate", "set_clearContentsDuringUpdate");
this.set_clearContentsDuringUpdate(value);
},
/// <summary>
/// A string to pass to the Web method.
/// </summary>
/// <getter>get_contextKey</getter>
/// <setter>set_contextKey</setter>
/// <member name="cP:AjaxControlToolkit.DynamicPopulateExtender.contextKey" />
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_ContextKey: function() {
Sys.Extended.Deprecated("get_ContextKey", "get_contextKey");
return this.get_contextKey();
},
set_ContextKey: function(value) {
Sys.Extended.Deprecated("set_ContextKey", "set_contextKey");
this.set_contextKey(value);
},
/// <summary>
/// TA name of an element that can be clicked to trigger the target element population.
/// </summary>
/// <getter>get_populateTriggerID</getter>
/// <setter>set_populateTriggerID</setter>
/// <member name="cP:AjaxControlToolkit.DynamicPopulateExtender.populateTriggerID" />
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_PopulateTriggerID: function() {
Sys.Extended.Deprecated("get_PopulateTriggerID", "get_populateTriggerID");
return this.get_populateTriggerID();
},
set_PopulateTriggerID: function(value) {
Sys.Extended.Deprecated("set_PopulateTriggerID", "set_populateTriggerID");
this.set_populateTriggerID(value);
},
/// <summary>
/// The Web service URL to call.
/// </summary>
/// <remarks>
/// This property is optional. If the ServicePath property is not set, a page method is invoked instead of a Web service.
/// </remarks>
/// <getter>get_servicePath</getter>
/// <setter>set_servicePath</setter>
/// <member name="cP:AjaxControlToolkit.DynamicPopulateExtender.servicePath" />
get_servicePath: function() {
return this._servicePath;
},
set_servicePath: function(value) {
if(this._servicePath != value) {
this._servicePath = value;
this.raisePropertyChanged('servicePath');
}
},
get_ServicePath: function() {
Sys.Extended.Deprecated("get_ServicePath", "get_servicePath");
return this.get_servicePath();
},
set_ServicePath: function(value) {
Sys.Extended.Deprecated("set_ServicePath", "set_servicePath");
this.set_servicePath(value);
},
/// <summary>
/// The method name to call on the Web service or a page.
/// </summary>
/// <getter>get_serviceMethod</getter>
/// <setter>set_serviceMethod</setter>
/// <member name="cP:AjaxControlToolkit.DynamicPopulateExtender.serviceMethod" />
get_serviceMethod: function() {
// 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_ServiceMethod: function() {
Sys.Extended.Deprecated("get_ServiceMethod", "get_serviceMethod");
return this.get_serviceMethod();
},
set_ServiceMethod: function(value) {
Sys.Extended.Deprecated("set_ServiceMethod", "set_serviceMethod");
this.set_serviceMethod(value);
},
/// <summary>
/// A Boolean value that specifies whether or not the results of the target
/// element population should be cached and not fetched again after the first load.
/// </summary>
/// <getter>get_cacheDynamicResults</getter>
/// <setter>set_cacheDynamicResults</setter>
/// <member name="cP:AjaxControlToolkit.DynamicPopulateExtender.cacheDynamicResults" />
get_cacheDynamicResults: function() {
return this._cacheDynamicResults;
},
set_cacheDynamicResults: function(value) {
if(this._cacheDynamicResults != value) {
this._cacheDynamicResults = value;
this.raisePropertyChanged('cacheDynamicResults');
}
},
/// <summary>
/// The name of the CSS class to apply to the target during asynchronous calls.
/// </summary>
/// <getter>get_updatingCssClass</getter>
/// <setter>set_updatingCssClass</setter>
/// <member name="cP:AjaxControlToolkit.DynamicPopulateExtender.updatingCssClass" />
get_updatingCssClass: function() {
return this._setUpdatingCssClass;
},
set_updatingCssClass: function(value) {
if(this._setUpdatingCssClass != value) {
this._setUpdatingCssClass = value;
this.raisePropertyChanged('updatingCssClass');
}
},
get_UpdatingCssClass: function() {
Sys.Extended.Deprecated("get_UpdatingCssClass", "get_updatingCssClass");
return this.get_updatingCssClass();
},
set_UpdatingCssClass: function(value) {
Sys.Extended.Deprecated("set_UpdatingCssClass", "set_updatingCssClass");
this.set_updatingCssClass(value);
},
/// <summary>
/// The script to invoke instead of calling a Web service or page method.
/// </summary>
/// <getter>get_customScript</getter>
/// <setter>set_customScript</setter>
/// <member name="cP:AjaxControlToolkit.DynamicPopulateExtender.customScript" />
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');
}
},
get_CustomScript: function() {
Sys.Extended.Deprecated("get_CustomScript", "get_customScript");
return this.get_customScript();
},
set_CustomScript: function(value) {
Sys.Extended.Deprecated("set_CustomScript", "set_customScript");
this.set_customScript(value);
},
/// <summary>
/// Fires when populating starts.
/// </summary>
/// <event add="add_populating" remove="remove_populating" raise="raise_populating" />
/// <member name="cE:AjaxControlToolkit.DynamicPopulateExtender.populating" />
add_populating: function(handler) {
this.get_events().addHandler('populating', handler);
},
remove_populating: function(handler) {
this.get_events().removeHandler('populating', handler);
},
raise_populating: function(eventArgs) {
var handler = this.get_events().getHandler('populating');
if(handler)
handler(this, eventArgs);
},
raisePopulating: function(eventArgs) {
Sys.Extended.Deprecated("raisePopulating(eventArgs)", "raise_populating(eventArgs)");
this.raise_populating(eventArgs);
},
/// <summary>
/// Fires when populating ends.
/// </summary>
/// <event add="add_populated" remove="remove_populated" raise="raise_populated" />
/// <member name="cE:AjaxControlToolkit.DynamicPopulateExtender.populated" />
add_populated: function(handler) {
this.get_events().addHandler('populated', handler);
},
remove_populated: function(handler) {
this.get_events().removeHandler('populated', handler);
},
raise_populated: function(eventArgs) {
var handler = this.get_events().getHandler('populated');
if(handler)
handler(this, eventArgs);
},
raisePopulated: function(eventArgs) {
Sys.Extended.Deprecated("raisePopulated(eventArgs)", "raise_populated(eventArgs)");
this.raise_populated(eventArgs);
}
}
Sys.Extended.UI.DynamicPopulateBehavior.registerClass('Sys.Extended.UI.DynamicPopulateBehavior', Sys.Extended.UI.BehaviorBase);

View File

@@ -0,0 +1,497 @@
Type.registerNamespace('Sys.Extended.UI');
Sys.Extended.UI.FilteredTextBoxBehavior = function(element) {
// The FilteredTextBoxBehavior is used to prevent invalid characters from being entered into a textbox
// "element" - the textbox element this behavior is associated with
Sys.Extended.UI.FilteredTextBoxBehavior.initializeBase(this, [element]);
this._keypressHandler = null;
this._changeHandler = null;
this._intervalID = null;
this._filterType = Sys.Extended.UI.FilterTypes.Custom;
this._filterMode = Sys.Extended.UI.FilterModes.ValidChars;
this._validChars = null;
this._invalidChars = null;
this._filterInterval = 250;
this.charTypes = {};
this.charTypes.LowercaseLetters = "abcdefghijklmnopqrstuvwxyz";
this.charTypes.UppercaseLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
this.charTypes.Numbers = "0123456789";
}
Sys.Extended.UI.FilteredTextBoxBehavior.prototype = {
initialize: function() {
Sys.Extended.UI.FilteredTextBoxBehavior.callBaseMethod(this, 'initialize');
var element = this.get_element();
this._keypressHandler = Function.createDelegate(this, this._onkeypress);
$addHandler(element, 'keypress', this._keypressHandler);
this._changeHandler = Function.createDelegate(this, this._onchange);
$addHandler(element, 'change', this._changeHandler);
var callback = Function.createDelegate(this, this._intervalCallback);
this._intervalID = window.setInterval(callback, this._filterInterval);
},
dispose: function() {
var element = this.get_element();
$removeHandler(element, 'keypress', this._keypressHandler);
this._keypressHandler = null;
$removeHandler(element, 'change', this._changeHandler);
this._changeHandler = null;
window.clearInterval(this._intervalID);
Sys.Extended.UI.FilteredTextBoxBehavior.callBaseMethod(this, 'dispose');
},
_getValidChars: function() {
if(this._validChars)
return this._validChars;
this._validChars = "";
for(type in this.charTypes) {
var filterType = Sys.Extended.UI.FilterTypes.toString(this._filterType);
if(filterType.indexOf(type) != -1)
this._validChars += this.charTypes[type];
}
return this._validChars;
},
_getInvalidChars: function() {
// Get all the invalid characters (in case of custom filtering and InvalidChars mode)
// returns all invalid characters
if(!this._invalidChars)
this._invalidChars = this.charTypes.Custom;
return this._invalidChars;
},
_onkeypress: function(evt) {
// Handler for the target textbox's key press event
// "evt" - event info
// This handler will only get called for valid characters in IE, we use keyCode
// In FireFox, this will be called for all key presses, with charCode/which
// being set for keys we should filter (e.g. the chars) and keyCode being
// set for all other keys.
// scanCode = event.charCode
// In Safari, charCode, which, and keyCode will all be filled with the same value,
// as well as keyIdentifier, which has the string representation either as "end" or "U+00000008"
// 1) Check for ctrl/alt/meta -> bail if true
// 2) Check for keyIdentifier.startsWith("U+") -> bail if false
// 3) Check keyCode < 0x20 -> bail
// 4) Special case Delete (63272) -> bail
var scanCode;
// Note (Supergibbs): Changed to handle all majors browsers
// IE and Safari only fires for valid characters
// Firefox sets charCode to 0 and uses keyCode for special keys
// Opera always fires but you cannot distinguish which are valid or special keys
if((((/* ff */ evt.rawEvent.charCode == 0) ||
(/* opera */ evt.rawEvent.keyCode == evt.rawEvent.which && evt.rawEvent.charCode == undefined)) &&
((evt.rawEvent.keyCode == Sys.UI.Key.pageUp) ||
(evt.rawEvent.keyCode == Sys.UI.Key.pageDown) ||
(evt.rawEvent.keyCode == Sys.UI.Key.up) ||
(evt.rawEvent.keyCode == Sys.UI.Key.down) ||
(evt.rawEvent.keyCode == Sys.UI.Key.left) ||
(evt.rawEvent.keyCode == Sys.UI.Key.right) ||
(evt.rawEvent.keyCode == Sys.UI.Key.home) ||
(evt.rawEvent.keyCode == Sys.UI.Key.end) ||
(evt.rawEvent.keyCode == 46 /* Delete */))) ||
(evt.ctrlKey /* Control keys */))
return;
if(evt.rawEvent.keyIdentifier) {
// Safari
// Note (Garbin): used the underlying rawEvent insted of the DomEvent instance.
if(evt.rawEvent.ctrlKey || evt.rawEvent.altKey || evt.rawEvent.metaKey)
return;
if(evt.rawEvent.keyIdentifier.substring(0, 2) != "U+")
return;
scanCode = evt.rawEvent.charCode;
if(scanCode == 63272 /* Delete */)
return;
} else {
scanCode = evt.charCode;
}
if(scanCode && scanCode >= 0x20 /* space */) {
var c = String.fromCharCode(scanCode);
if(!this._processKey(c))
evt.preventDefault();
}
},
_processKey: function(key) {
// Determine whether the key is valid or whether it should be filtered out
// "key" - character to be validated
// returns true if the character should be accepted, false if it should be filtered
// Allow anything that's not a printable character,
// e.g. backspace, arrows, etc. Everything above 32
// should be considered allowed, as it may be Unicode, etc.
var filter = "",
shouldFilter = false;
if(this._filterMode == Sys.Extended.UI.FilterModes.ValidChars) {
filter = this._getValidChars();
// Determine if we should accept the character
shouldFilter = filter && (filter.length > 0) && (filter.indexOf(key) == -1);
} else {
filter = this._getInvalidChars();
// Determine if we should accept the character
shouldFilter = filter && (filter.length > 0) && (filter.indexOf(key) > -1);
}
// Raise the processKey event and allow handlers to intercept
// and decide whether the key should be allowed
var eventArgs = new Sys.Extended.UI.FilteredTextBoxProcessKeyEventArgs(key, Sys.Extended.UI.TextBoxWrapper.get_Wrapper(this.get_element()).get_Value(), shouldFilter);
this.raise_processKey(eventArgs);
// If a processKey handler decided the key should be allowed, just
// return true and pass it through (note that the default value of
// allowKey is the opposite of shouldFilter so it will work as normal
// if no one is handling the event)
if(eventArgs.get_allowKey())
return true;
// Else if it was decided that it shouldn't be allowed,
// raise the Filtered event and return false to filter the key
this.raiseFiltered(new Sys.Extended.UI.FilteredTextBoxEventArgs(key));
return false;
},
_onchange: function() {
// Handler for the target textbox's key change event which will filter
// the text again (to make sure no text was inserted without keypresses, etc.)
var wrapper = Sys.Extended.UI.TextBoxWrapper.get_Wrapper(this.get_element()),
text = wrapper.get_Value() || '',
result = new Sys.StringBuilder();
for(var i = 0; i < text.length; i++) {
var ch = text.substring(i, i + 1);
if(this._processKey(ch))
result.append(ch);
}
// change the value only if it is different
if(wrapper.get_Value() != result.toString())
wrapper.set_Value(result.toString());
},
_intervalCallback: function() {
// Method that is repeatedly called to purge invalid characters from the textbox
this._changeHandler();
},
/// <summary>
/// A string that consists of all characters that are considered
/// valid for the text box when the field type is Custom.
/// </summary>
/// <remarks>
/// If the field type is not Custom, this property value is ignored.
/// </remarks>
/// <getter>get_validChars</getter>
/// <setter>set_validChars</setter>
/// <member name="cP:AjaxControlToolkit.FilteredTextBoxExtender.validChars" />
get_validChars: function() {
// A string consisting of all characters considered valid for the textbox, if
// "Custom" is specified as the field type. Otherwise this parameter is ignored.
return this.charTypes.Custom;
},
set_validChars: function(value) {
if(this._validChars != null || this.charTypes.Custom != value) {
this.charTypes.Custom = value;
this._validChars = null;
this.raisePropertyChanged('validChars');
}
},
get_ValidChars: function() {
Sys.Extended.Deprecated("get_ValidChars", "get_validChars");
return this.get_validChars();
},
set_ValidChars: function(value) {
Sys.Extended.Deprecated("set_ValidChars", "set_validChars");
this.set_validChars(value);
},
/// <summary>
/// A string that consists of all characters that are considered
/// invalid for the text box when the field type is Custom.
/// </summary>
/// <remarks>
/// If the field type is not Custom, this property value is ignored.
/// </remarks>
/// <getter>get_invalidChars</getter>
/// <setter>set_invalidChars</setter>
/// <member name="cP:AjaxControlToolkit.FilteredTextBoxExtender.invalidChars" />
get_invalidChars: function() {
return this.charTypes.Custom;
},
set_invalidChars: function(value) {
if(this._invalidChars != null || this.charTypes.Custom != value) {
this.charTypes.Custom = value;
this._invalidChars = null;
this.raisePropertyChanged('invalidChars');
}
},
get_InvalidChars: function() {
Sys.Extended.Deprecated("get_InvalidChars", "get_invalidChars");
return this.get_invalidChars();
},
set_InvalidChars: function(value) {
Sys.Extended.Deprecated("set_InvalidChars", "set_invalidChars");
this.set_invalidChars(value);
},
/// <summary>
/// The Sys.Extended.UI.FilterTypes object to apply to a FilterTextBox instance.
/// </summary>
/// <remarks>
/// The filter type to apply can be a comma-separated combination of the following values:
/// Numbers, LowercaseLetters, UppercaseLetters, and Custom.
/// If Custom is specified, the ValidChars property will be used in addition to other settings, such as Numbers.
/// </remarks>
/// <getter>get_filterType</getter>
/// <setter>set_filterType</setter>
/// <member name="cP:AjaxControlToolkit.FilteredTextBoxExtender.filterType" />
get_filterType: function() {
return this._filterType;
},
set_filterType: function(value) {
if(this._validChars != null || this._filterType != value) {
this._filterType = value;
this._validChars = null;
this.raisePropertyChanged('filterType');
}
},
get_FilterType: function() {
Sys.Extended.Deprecated("get_FilterType", "get_filterType");
return this.get_filterType();
},
set_FilterType: function(value) {
Sys.Extended.Deprecated("set_FilterType", "set_filterType");
this.set_filterType(value);
},
/// <summary>
/// The Sys.Extended.UI.FilterModes object that specifies the mode to apply to a FilterTextBox instance.
/// </summary>
/// <remarks>
/// Supported values are ValidChars and InvalidChars.
/// </remarks>
/// <getter>get_filterMode</getter>
/// <setter>set_filterMode</setter>
/// <member name="cP:AjaxControlToolkit.FilteredTextBoxExtender.filterMode" />
get_filterMode: function() {
return this._filterMode;
},
set_filterMode: function(value) {
if(this._validChars != null || this._invalidChars != null || this._filterMode != value) {
this._filterMode = value;
this._validChars = null;
this._invalidChars = null;
this.raisePropertyChanged('filterMode');
}
},
get_FilterMode: function() {
Sys.Extended.Deprecated("get_FilterMode", "get_filterMode");
return this.get_filterMode();
},
set_FilterMode: function(value) {
Sys.Extended.Deprecated("set_FilterMode", "set_filterMode");
this.set_filterMode(value);
},
/// <summary>
/// An interval in milliseconds, in which the field's content is filtered.
/// </summary>
/// <getter>get_filterInterval</getter>
/// <setter>set_filterInterval</setter>
/// <member name="cP:AjaxControlToolkit.FilteredTextBoxExtender.filterInterval" />
get_filterInterval: function() {
return this._filterInterval;
},
set_filterInterval: function(value) {
if(this._filterInterval != value) {
this._filterInterval = value;
this.raisePropertyChanged('filterInterval');
}
},
get_FilterInterval: function() {
Sys.Extended.Deprecated("get_FilterInterval", "get_filterInterval");
return this.get_filterInterval();
},
set_FilterInterval: function(value) {
Sys.Extended.Deprecated("set_FilterInterval", "set_filterInterval");
this.set_filterInterval(value);
},
/// <summary>
/// Fires when a key is processed.
/// </summary>
/// <event add="add_processKey" remove="remove_processKey" raise="raise_processKey" />
/// <member name="cE:AjaxControlToolkit.FilteredTextBoxExtender.processKey" />
add_processKey: function(handler) {
this.get_events().addHandler('processKey', handler);
},
remove_processKey: function(handler) {
this.get_events().removeHandler('processKey', handler);
},
raise_processKey: function(eventArgs) {
var handler = this.get_events().getHandler('processKey');
if(handler)
handler(this, eventArgs);
},
raiseProcessKey: function(eventArgs) {
Sys.Extended.Deprecated("raiseProcessKey(eventArgs)", "raise_processKey(eventArgs)");
this.raise_processKey(eventArgs);
},
/// <summary>
/// Fires when the TextBox is filtered.
/// </summary>
/// <event add="add_filtered" remove="remove_filtered" raise="raise_filtered" />
/// <member name="cE:AjaxControlToolkit.FilteredTextBoxExtender.filtered" />
add_filtered: function(handler) {
this.get_events().addHandler('filtered', handler);
},
remove_filtered: function(handler) {
this.get_events().removeHandler('filtered', handler);
},
raise_filtered: function(eventArgs) {
var handler = this.get_events().getHandler('filtered');
if(handler)
handler(this, eventArgs);
},
raiseFiltered: function(eventArgs) {
Sys.Extended.Deprecated("raiseFiltered(eventArgs)", "raise_filtered(eventArgs)");
this.raise_filtered(eventArgs);
}
}
Sys.Extended.UI.FilteredTextBoxBehavior.registerClass('Sys.Extended.UI.FilteredTextBoxBehavior', Sys.Extended.UI.BehaviorBase);
Sys.Extended.UI.FilterTypes = function() {
// Character filter to be applied to a textbox
// "Custom" - custom Characters
// "Numbers" - numbers (0123456789)
// "UppercaseLetters" - uppercase Letters (ABCDEFGHIJKLMNOPQRSTUVWXYZ)
// "LowercaseLetters" - lowercase Letters (abcdefghijklmnopqrstuvwxyz)
throw Error.invalidOperation();
}
Sys.Extended.UI.FilterTypes.prototype = {
Custom: 0x1,
Numbers: 0x2,
UppercaseLetters: 0x4,
LowercaseLetters: 0x8
}
Sys.Extended.UI.FilterTypes.registerEnum('Sys.Extended.UI.FilterTypes', true);
Sys.Extended.UI.FilterModes = function() {
// Filter mode to be applied to a textbox
// "ValidChars" - provide a list of valid characters
// "InvalidChars" - provide a list of invalid characters
throw Error.invalidOperation();
}
Sys.Extended.UI.FilterModes.prototype = {
ValidChars: 0x1,
InvalidChars: 0x2
}
Sys.Extended.UI.FilterModes.registerEnum('Sys.Extended.UI.FilterModes', true);
Sys.Extended.UI.FilteredTextBoxProcessKeyEventArgs = function(key, text, shouldFilter) {
// Event arguments used when the processKey event is raised
// "key" - key to be processed
// "text" - current text in the textbox
// "shouldFilter" - whether the character should be filtered given the current filteredTextBox settings
Sys.Extended.UI.FilteredTextBoxProcessKeyEventArgs.initializeBase(this);
this._key = key;
this._text = text;
this._shouldFilter = shouldFilter;
this._allowKey = !shouldFilter;
}
Sys.Extended.UI.FilteredTextBoxProcessKeyEventArgs.prototype = {
get_key: function() {
// Key to be processed
return this._key;
},
get_text: function() {
// Current text in the textbox
return this._text;
},
get_shouldFilter: function() {
// Whether the character should be filtered given the current
// FilteredTextBox settings
return this._shouldFilter;
},
get_allowKey: function() {
// Whether or not the key will be filtered. It defaults to the opposite of
// shouldFilter and should be set by handlers of the processKey event.
return this._allowKey;
},
set_allowKey: function(value) {
this._allowKey = value;
}
}
Sys.Extended.UI.FilteredTextBoxProcessKeyEventArgs.registerClass('Sys.Extended.UI.FilteredTextBoxProcessKeyEventArgs', Sys.EventArgs);
Sys.Extended.UI.FilteredTextBoxEventArgs = function(key) {
// Event arguments used when the filtered event is raised
// "key" - key that was filtered
Sys.Extended.UI.FilteredTextBoxEventArgs.initializeBase(this);
this._key = key;
}
Sys.Extended.UI.FilteredTextBoxEventArgs.prototype = {
get_key: function() {
// Key that was filtered
return this._key;
}
}
Sys.Extended.UI.FilteredTextBoxEventArgs.registerClass('Sys.Extended.UI.FilteredTextBoxEventArgs', Sys.EventArgs);

View File

@@ -0,0 +1,192 @@
Sys.Extended.UI.FloatingBehavior = function(element) {
Sys.Extended.UI.FloatingBehavior.initializeBase(this, [element]);
var _handle,
_location,
_dragStartLocation,
_profileProperty,
_profileComponent;
var _mouseDownHandler = Function.createDelegate(this, mouseDownHandler);
///<summary>
/// Move event handler.
///</summary>
///<member name="cE:AjaxControlToolkit.DragPanelExtender.move" />
///<event add="add_move" remove="remove_move" />
this.add_move = function(handler) {
this.get_events().addHandler('move', handler);
}
this.remove_move = function(handler) {
this.get_events().removeHandler('move', handler);
}
///<summary>
/// Handles to drag the panel around.
///</summary>
///<getter>get_handle</getter>
///<setter>set_handle</setter>
///<member name="cP:AjaxControlToolkit.DragPanelExtender.handle" />
this.get_handle = function() {
return _handle;
}
this.set_handle = function(value) {
if(_handle != null)
$removeHandler(_handle, "mousedown", _mouseDownHandler);
_handle = value;
$addHandler(_handle, "mousedown", _mouseDownHandler);
}
this.get_profileProperty = function() {
return _profileProperty;
}
this.set_profileProperty = function(value) {
_profileProperty = value;
}
this.get_profileComponent = function() {
return _profileComponent;
}
this.set_profileComponent = function(value) {
_profileComponent = value;
}
///<summary>
/// Defines the location of an element being dragged.
///</summary>
///<getter>get_location</getter>
///<setter>set_location</setter>
///<member name="cP:AjaxControlToolkit.DragPanelExtender.location" />
this.get_location = function() {
return _location;
}
this.set_location = function(value) {
if(_location != value) {
_location = value;
if(this.get_isInitialized())
$common.setLocation(this.get_element(), _location);
this.raisePropertyChanged('location');
}
}
this.initialize = function() {
Sys.Extended.UI.FloatingBehavior.callBaseMethod(this, 'initialize');
Sys.Extended.UI.DragDropManager.registerDropTarget(this);
var el = this.get_element();
if(!_location)
_location = $common.getLocation(el);
el.style.position = "fixed";
$common.setLocation(el, _location);
}
this.dispose = function() {
Sys.Extended.UI.DragDropManager.unregisterDropTarget(this);
if(_handle && _mouseDownHandler)
$removeHandler(_handle, "mousedown", _mouseDownHandler);
_mouseDownHandler = null;
Sys.Extended.UI.FloatingBehavior.callBaseMethod(this, 'dispose');
}
this.checkCanDrag = function(element) {
var undraggableTagNames = ["input", "button", "select", "textarea", "label"],
tagName = element.tagName;
if((tagName.toLowerCase() == "a") && (element.href != null) && (element.href.length > 0))
return false;
if(Array.indexOf(undraggableTagNames, tagName.toLowerCase()) > -1)
return false;
return true;
}
function mouseDownHandler(ev) {
window._event = ev;
var el = this.get_element();
if(this.checkCanDrag(ev.target)) {
_dragStartLocation = $common.getLocation(el);
ev.preventDefault();
this.startDragDrop(el);
}
}
// Type get_dataType()
this.get_dragDataType = function() {
return "_floatingObject";
}
// Object get_data(Context)
this.getDragData = function(context) {
return null;
}
// DragMode get_dragMode()
this.get_dragMode = function() {
return Sys.Extended.UI.DragMode.Move;
}
// void onDragStart()
this.onDragStart = function() { }
// void onDrag()
this.onDrag = function() { }
this.onDragEnd = function(canceled) {
if(!canceled) {
var handler = this.get_events().getHandler('move');
if(handler) {
var cancelArgs = new Sys.CancelEventArgs();
handler(this, cancelArgs);
canceled = cancelArgs.get_cancel();
}
}
var el = this.get_element();
if(canceled) {
// Restore the position of the control.
$common.setLocation(el, _dragStartLocation);
} else {
_location = $common.getLocation(el);
this.raisePropertyChanged('location');
}
}
this.startDragDrop = function(dragVisual) {
Sys.Extended.UI.DragDropManager.startDragDrop(this, dragVisual, null);
}
this.get_dropTargetElement = function() {
return document.body;
}
// bool canDrop(DragMode, DataType, Data)
this.canDrop = function(dragMode, dataType, data) {
return (dataType == "_floatingObject");
}
// void drop(DragMode, DataType, Data)
this.drop = function(dragMode, dataType, data) { }
// void onDragEnterTarget(DragMode, DataType, Data)
this.onDragEnterTarget = function(dragMode, dataType, data) { }
// void onDragLeaveTarget(DragMode, DataType, Data)
this.onDragLeaveTarget = function(dragMode, dataType, data) { }
// void onDragInTarget(DragMode, DataType, Data)
this.onDragInTarget = function(dragMode, dataType, data) { }
}
Sys.Extended.UI.FloatingBehavior.registerClass('Sys.Extended.UI.FloatingBehavior', Sys.Extended.UI.BehaviorBase, Sys.Extended.UI.IDragSource, Sys.Extended.UI.IDropTarget, Sys.IDisposable);

View File

@@ -0,0 +1,224 @@
Type.registerNamespace('Sys.Extended.UI');
Sys.Extended.UI.HoverBehavior = function(element) {
Sys.Extended.UI.HoverBehavior.initializeBase(this, [element]);
// NOTE: DomEvent handler is specific to the dom element; so these are now 2-element arrays
// where index 0 is the handler for element and index 1 is the handler for hoverElement.
this._elementHandlers = null;
this._hoverElementHandlers = null;
this._hoverElement = null;
this._hoverCount = 0;
this._unhoverDelay = 0;
this._hoverDelay = 0;
this._hoverScript = null;
this._unhoverScript = null;
this._hoverFired = false;
}
Sys.Extended.UI.HoverBehavior.prototype = {
_setupHandlersArray: function() {
var target = [];
target[0] = Function.createDelegate(this, this._onHover);
target[1] = Function.createDelegate(this, this._onUnhover);
return target;
},
get_elementHandlers: function() {
if(!this._elementHandlers)
this._elementHandlers = this._setupHandlersArray();
return this._elementHandlers;
},
get_hoverElementHandlers: function() {
if(!this._hoverElementHandlers)
this._hoverElementHandlers = this._setupHandlersArray();
return this._hoverElementHandlers;
},
get_hoverElement: function() {
// DOM element associated with this behavior.
return this._hoverElement;
},
set_hoverElement: function(element) {
// DOM element associated with this behavior.
if(element != this._hoverElement) {
if(this._hoverElement)
this._setupHandlers(this._hoverElement, this.get_hoverElementHandlers(), false);
this._hoverElement = element;
if(this._hoverElement)
this._setupHandlers(this._hoverElement, this.get_hoverElementHandlers(), true);
}
},
get_hoverDelay: function() {
// Delay in milliseconds before unhover event is raised.
return this._hoverDelay;
},
set_hoverDelay: function(value) {
// Delay in milliseconds before unhover event is raised.
this._hoverDelay = value;
this.raisePropertyChanged('hoverDelay');
},
get_hoverScript: function() {
return this._hoverScript;
},
set_hoverScript: function(script) {
this._hoverScript = script;
},
get_unhoverDelay: function() {
// Delay in milliseconds before unhover event is raised.
return this._unhoverDelay;
},
set_unhoverDelay: function(value) {
// Delay in milliseconds before unhover event is raised.
this._unhoverDelay = value;
this.raisePropertyChanged('unhoverDelay');
},
get_unhoverScript: function() {
return this._unhoverScript;
},
set_unhoverScript: function(script) {
this._unhoverScript = script;
},
dispose: function() {
var element = this.get_element();
if(this._elementHandlers) {
var handlers = this.get_elementHandlers();
this._setupHandlers(element, handlers, false);
this._elementHandlers = null;
}
if(this._hoverElement) {
var handlers = this.get_hoverElementHandlers();
this._setupHandlers(this._hoverElement, handlers, false);
this._hoverElement = null;
}
Sys.Extended.UI.HoverBehavior.callBaseMethod(this, 'dispose');
},
initialize: function() {
Sys.Extended.UI.HoverBehavior.callBaseMethod(this, 'initialize');
var handlers = this.get_elementHandlers();
this._setupHandlers(this.get_element(), handlers, true);
if(this._hoverElement) {
handlers = this.get_hoverElementHandlers();
this._setupHandlers(this._hoverElement, handlers, true);
}
},
add_hover: function(handler) {
this.get_events().addHandler("hover", handler);
},
remove_hover: function(handler) {
this.get_events().removeHandler("hover", handler);
},
_fireHover: function() {
if(!this._hoverCount || this._hoverFired)
return;
var handler = this.get_events().getHandler("hover");
if(handler)
handler(this, Sys.EventArgs.Empty);
if(this._hoverScript)
eval(this._hoverScript);
this._hoverFired = true;
},
_onHover: function() {
this._hoverCount++;
if(!this._hoverDelay)
this._fireHover();
else
window.setTimeout(Function.createDelegate(this, this._fireHover), this._hoverDelay);
},
add_unhover: function(handler) {
this.get_events().addHandler("unhover", handler);
},
remove_unhover: function(handler) {
this.get_events().removeHandler("unhover", handler);
},
_fireUnhover: function() {
if(this._hoverFired && !this._hoverCount) {
this._hoverFired = false;
var handler = this.get_events().getHandler("unhover");
if(handler)
handler(this, Sys.EventArgs.Empty);
if(this._unhoverScript)
eval(this._unhoverScript);
}
},
_onUnhover: function() {
this._hoverCount--;
if(this._hoverCount <= 0) {
// Because Safari fires events differently, it's possible in some scenarios to
// have mouseout fire before mouseover, so make sure we never get a negative _hoverCount
this._hoverCount = 0;
if(!this._unhoverDelay)
this._fireUnhover();
else
window.setTimeout(Function.createDelegate(this, this._fireUnhover), this._unhoverDelay);
}
},
_setupHandlers: function(element, handlers, hookup) {
if(!this.get_isInitialized() || !element)
return;
if(hookup) {
$addHandler(element, "mouseover", handlers[0]);
$addHandler(element, "focus", handlers[0]);
$addHandler(element, "mouseout", handlers[1]);
$addHandler(element, "blur", handlers[1]);
} else {
$removeHandler(element, "mouseover", handlers[0]);
$removeHandler(element, "focus", handlers[0]);
$removeHandler(element, "mouseout", handlers[1]);
$removeHandler(element, "blur", handlers[1]);
}
}
}
Sys.Extended.UI.HoverBehavior.descriptor = {
properties: [{ name: 'hoverElement', isDomElement: true },
{ name: 'unhoverDelay', type: Number }],
events: [{ name: 'hover' },
{ name: 'unhover' }]
}
Sys.Extended.UI.HoverBehavior.registerClass('Sys.Extended.UI.HoverBehavior', Sys.Extended.UI.BehaviorBase);

View File

@@ -0,0 +1,564 @@
Type.registerNamespace('Sys.Extended.UI');
Sys.Extended.UI.HoverMenuBehavior = function(element) {
// The HoverMenuBehavior is used to display a popup whenever the target is hovered over
Sys.Extended.UI.HoverMenuBehavior.initializeBase(this, [element]);
// Encapsulated behaviors
this._hoverBehavior = null;
this._popupBehavior = null;
// Handler delegates
this._mouseEnterHandler = null;
this._mouseLeaveHandler = null;
this._unhoverHandler = null;
this._hoverHandler = null;
// State variables
this._inHover = null;
this._oldClass = null;
this._popupElement = null;
this._onShowJson = null;
this._onHideJson = null;
// Property values
this._popupElement = null;
this._hoverCssClass = null;
this._offsetX = 0;
this._offsetY = 0;
this._popDelay = 100;
this._hoverDelay = 0;
this._popupPosition = null;
}
Sys.Extended.UI.HoverMenuBehavior.prototype = {
initialize: function() {
Sys.Extended.UI.HoverMenuBehavior.callBaseMethod(this, 'initialize');
// set up our delegates and handlers
this._hoverHandler = Function.createDelegate(this, this._onHover);
this._unhoverHandler = Function.createDelegate(this, this._onUnhover);
this._mouseEnterHandler = Function.createDelegate(this, this._onmouseover);
this._mouseLeaveHandler = Function.createDelegate(this, this._onmouseout);
var e = this.get_element();
$addHandler(e, "mouseover", this._mouseEnterHandler);
$addHandler(e, "mouseout", this._mouseLeaveHandler);
if(this._popupElement) {
// setup the popup behavior
this._popupBehavior = $create(Sys.Extended.UI.PopupBehavior, { "id": this.get_id() + "_PopupBehavior" }, null, null, this._popupElement);
if(this._popupPosition)
this._popupBehavior.set_positioningMode(Sys.Extended.UI.HoverMenuPopupPosition.Absolute);
else
this._popupBehavior.set_positioningMode(Sys.Extended.UI.HoverMenuPopupPosition.Center);
// Create the animations (if they were set before initialize was called)
if(this._onShowJson)
this._popupBehavior.set_onShow(this._onShowJson);
if(this._onHideJson)
this._popupBehavior.set_onHide(this._onHideJson);
// set up the hover behavior
this._hoverBehavior = $create(Sys.Extended.UI.HoverBehavior, { "id": this.get_id() + "_HoverBehavior", "hoverDelay": this._hoverDelay, "unhoverDelay": this._popDelay, "hoverElement": this._popupElement }, null, null, e);
this._hoverBehavior.add_hover(this._hoverHandler);
this._hoverBehavior.add_unhover(this._unhoverHandler);
}
},
dispose: function() {
// do cleanup
this._onShowJson = null;
this._onHideJson = null;
if(this._popupBehavior) {
this._popupBehavior.dispose();
this._popupBehavior = null;
}
if(this._popupElement)
this._popupElement = null;
if(this._mouseEnterHandler)
$removeHandler(this.get_element(), "mouseover", this._mouseEnterHandler);
if(this._mouseLeaveHandler)
$removeHandler(this.get_element(), "mouseout", this._mouseLeaveHandler);
if(this._hoverBehavior) {
if(this._hoverHandler) {
this._hoverBehavior.remove_hover(this._hoverHandler);
this._hoverHandler = null;
}
if(this._unhoverHandler) {
this._hoverBehavior.remove_hover(this._unhoverHandler);
this._unhoverHandler = null;
}
this._hoverBehavior.dispose();
this._hoverBehavior = null;
}
Sys.Extended.UI.HoverMenuBehavior.callBaseMethod(this, 'dispose');
},
_getLeftOffset: function() {
var defaultLeft = $common.getLocation(this.get_element()).x,
offsetLeft = $common.getLocation(this.get_popupElement().offsetParent).x,
delta = 0;
// this offset is always relative to the left edge of the hover element.
switch(this._popupPosition) {
case Sys.Extended.UI.HoverMenuPopupPosition.Left:
// if it's positioned left, it's the width of the popup plus the offset
delta = (-1 * this._popupElement.offsetWidth);
break;
case Sys.Extended.UI.HoverMenuPopupPosition.Right:
// if it's to the right, it's the width of the hover element plus the offset.
delta = this.get_element().offsetWidth;
break;
}
return delta + defaultLeft - offsetLeft + this._offsetX;
},
_getTopOffset: function() {
var defaultTop = $common.getLocation(this.get_element()).y,
offsetTop = $common.getLocation(this.get_popupElement().offsetParent).y,
delta = 0;
// this offset is always relative to the top edge of the hover element.
switch(this._popupPosition) {
case Sys.Extended.UI.HoverMenuPopupPosition.Top:
// if it's Top positioned, it's the height of the popup plus the offset.
delta = (-1 * this._popupElement.offsetHeight);
break;
case Sys.Extended.UI.HoverMenuPopupPosition.Bottom:
// if it's bottom positioned it's the height of the hover element plus the offset
delta = this.get_element().offsetHeight;
break;
}
return defaultTop - offsetTop + delta + this._offsetY;
},
_onHover: function() {
if(this._inHover)
return;
var eventArgs = new Sys.CancelEventArgs();
this.raise_showing(eventArgs);
if(eventArgs.get_cancel())
return;
this._inHover = true;
this.populate();
this._popupBehavior.show();
if($common.getCurrentStyle(this._popupElement, 'display') == 'none')
this._popupElement.style.display = 'block';
this._popupBehavior.set_x(this._getLeftOffset());
this._popupBehavior.set_y(this._getTopOffset());
this.raise_shown(Sys.EventArgs.Empty);
},
_onUnhover: function() {
var eventArgs = new Sys.CancelEventArgs();
this.raise_hiding(eventArgs);
if(eventArgs.get_cancel())
return;
this._inHover = false;
this._resetCssClass();
this._popupBehavior.hide();
this.raise_hidden(Sys.EventArgs.Empty);
},
_onmouseover: function() {
// Handler to change the CSS class when hovered over
// set up the CSS class
var e = this.get_element();
if(this._hoverCssClass && e.className != this._hoverCssClass) {
this._oldClass = e.className;
e.className = this._hoverCssClass;
}
},
_onmouseout: function() {
this._resetCssClass();
},
_resetCssClass: function() {
// Reset the CSS class if we changed it while hovering
// make sure we're not still in hover mode, and that the class is
// currently the hover class.
var e = this.get_element();
if(!this._inHover && this._hoverCssClass && e.className == this._hoverCssClass)
e.className = this._oldClass;
},
/// <summary>
/// A JSON definition of a generic OnShow animation.
/// </summary>
/// <getter>get_onShow</getter>
/// <setter>set_onShow</setter>
/// <member name="cP:AjaxControlToolkit.HoverMenuExtender.onShow" />
get_onShow: function() {
// Generic OnShow Animation's JSON definition
return this._popupBehavior ? this._popupBehavior.get_onShow() : this._onShowJson;
},
set_onShow: function(value) {
if(this._popupBehavior)
this._popupBehavior.set_onShow(value)
else
this._onShowJson = value;
this.raisePropertyChanged('onShow');
},
/// <summary>
/// The Sys.Extended.UI.Animation.GenericAnimationBehavior object containing the generic OnShow animation behavior.
/// </summary>
/// <getter>get_onShowBehavior</getter>
/// <member name="cP:AjaxControlToolkit.HoverMenuExtender.onShowBehavior" />
get_onShowBehavior: function() {
// Generic OnShow Animation's behavior
return this._popupBehavior ? this._popupBehavior.get_onShowBehavior() : null;
},
/// <summary>
/// Plays OnHide animation.
/// </summary>
/// <member name="cM:AjaxControlToolkit.HoverMenuExtender.onShow" />
onShow: function() {
if(this._popupBehavior)
this._popupBehavior.onShow();
},
/// <summary>
/// A JSON definition of a genericOnHide animation.
/// </summary>
/// <getter>get_onHide</getter>
/// <setter>set_onHide</setter>
/// <member name="cP:AjaxControlToolkit.HoverMenuExtender.onHide" />
get_onHide: function() {
// Generic OnHide Animation's JSON definition
return this._popupBehavior ? this._popupBehavior.get_onHide() : this._onHideJson;
},
set_onHide: function(value) {
if(this._popupBehavior)
this._popupBehavior.set_onHide(value)
else
this._onHideJson = value;
this.raisePropertyChanged('onHide');
},
/// <summary>
/// The Sys.Extended.UI.Animation.GenericAnimationBehavior object containing the generic OnHide animation behavior.
/// </summary>
/// <getter>get_onHideBehavior</getter>
/// <member name="cP:AjaxControlToolkit.HoverMenuExtender.onHideBehavior" />
get_onHideBehavior: function() {
// Generic OnHide Animation's behavior
return this._popupBehavior ? this._popupBehavior.get_onHideBehavior() : null;
},
/// <summary>
/// Plays OnHide animation.
/// </summary>
/// <member name="cM:AjaxControlToolkit.HoverMenuExtender.onHide" />
onHide: function() {
if(this._popupBehavior)
this._popupBehavior.onHide();
},
/// <summary>
/// Sys.UI.DomElement that acts as a popup and is displayed on hovering.
/// </summary>
/// <getter>get_popupElement</getter>
/// <setter>set_popupElement</setter>
/// <member name="cP:AjaxControlToolkit.HoverMenuExtender.popupElement" />
get_popupElement: function() {
// Popup that is displayed when hovering
return this._popupElement;
},
set_popupElement: function(value) {
if(this._popupElement != value) {
this._popupElement = value;
if(this.get_isInitialized() && this._hoverBehavior)
this._hoverBehavior.set_hoverElement(this._popupElement);
this.raisePropertyChanged('popupElement');
}
},
/// <summary>
/// A CSS class used on hovering.
/// </summary>
/// <getter>get_hoverCssClass</getter>
/// <setter>set_hoverCssClass</setter>
/// <member name="cP:AjaxControlToolkit.HoverMenuExtender.hoverCssClass" />
get_hoverCssClass: function() {
return this._hoverCssClass;
},
set_hoverCssClass: function(value) {
if(this._hoverCssClass != value) {
this._hoverCssClass = value;
this.raisePropertyChanged('hoverCssClass');
}
},
get_HoverCssClass: function() {
Sys.Extended.Deprecated("get_HoverCssClass", "get_hoverCssClass");
return this.get_hoverCssClass();
},
set_HoverCssClass: function(value) {
Sys.Extended.Deprecated("set_HoverCssClass", "set_hoverCssClass");
this.set_hoverCssClass(value);
},
/// <summary>
/// The number of pixels to offset the popup from its default horizontal position.
/// </summary>
/// <getter>get_offsetX</getter>
/// <setter>set_offsetX</setter>
/// <member name="cP:AjaxControlToolkit.HoverMenuExtender.offsetX" />
get_offsetX: function() {
return this._offsetX;
},
set_offsetX: function(value) {
if(this._offsetX != value) {
this._offsetX = value;
this.raisePropertyChanged('offsetX');
}
},
get_OffsetX: function() {
Sys.Extended.Deprecated("get_OffsetX()", "get_offsetX()");
return this.get_offsetX();
},
set_OffsetX: function(value) {
Sys.Extended.Deprecated("set_OffsetX(value)", "set_offsetX(value)");
this.set_offsetX(value);
},
/// <summary>
/// The number of pixels to offset the popup from its default vertical position.
/// </summary>
/// <getter>get_offsetY</getter>
/// <setter>set_offsetY</setter>
/// <member name="cP:AjaxControlToolkit.HoverMenuExtender.offsetY" />
get_offsetY: function() {
return this._offsetY;
},
set_offsetY: function(value) {
if(this._offsetY != value) {
this._offsetY = value;
this.raisePropertyChanged('offsetY');
}
},
get_OffsetY: function() {
Sys.Extended.Deprecated("get_OffsetY()", "get_offsetY()");
return this.get_offsetY();
},
set_OffsetY: function(value) {
Sys.Extended.Deprecated("set_OffsetY(value)", "set_offsetY(value)");
this.set_offsetY(value);
},
/// <summary>
/// The Sys.Extended.UI.HoverMenuPopupPosition object that contains the location where the popup should be positioned relative to the target control.
/// </summary>
/// <remarks>
/// Can be Left, Right, Top, Bottom, Center. Center is default
/// </remarks>
/// <getter>get_popupPosition</getter>
/// <setter>set_popupPosition</setter>
/// <member name="cP:AjaxControlToolkit.HoverMenuExtender.popupPosition" />
get_popupPosition: function() {
return this._popupPosition;
},
set_popupPosition: function(value) {
if(this._popupPosition != value) {
this._popupPosition = value;
this.raisePropertyChanged('popupPosition');
}
},
get_PopupPosition: function() {
Sys.Extended.Deprecated("get_PopupPosition()", "get_popupPosition()");
return this.get_popupPosition();
},
set_PopupPosition: function(value) {
Sys.Extended.Deprecated("set_PopupPosition(value)", "set_popupPosition(value)");
this.set_popupPosition(value);
},
/// <summary>
/// A number representing a time delay from the moment the mouse enters the target to the time when the popup is shown (displayed in milliseconds).
/// </summary>
/// <remarks>
/// Default is 100.
/// </remarks>
/// <getter>get_popDelay</getter>
/// <setter>set_popDelay</setter>
/// <member name="cP:AjaxControlToolkit.HoverMenuExtender.popDelay" />
get_popDelay: function() {
return this._popDelay;
},
set_popDelay: function(value) {
if(this._popDelay != value) {
this._popDelay = value;
this.raisePropertyChanged('popDelay');
}
},
get_PopDelay: function() {
Sys.Extended.Deprecated("get_PopDelay", "get_popDelay");
return this.get_popDelay();
},
set_PopDelay: function(value) {
Sys.Extended.Deprecated("set_PopDelay", "set_popDelay");
this.set_popDelay(value);
},
/// <summary>
/// A number representing a time delay after the mouse enters the target and before the popup is shown (in milliseconds).
/// </summary>
/// <remarks>
/// Default is 0.
/// </remarks>
/// <getter>get_hoverDelay</getter>
/// <setter>set_hoverDelay</setter>
/// <member name="cP:AjaxControlToolkit.HoverMenuExtender.hoverDelay" />
get_hoverDelay: function() {
return this._hoverDelay;
},
set_hoverDelay: function(value) {
if(this._hoverDelay != value) {
this._hoverDelay = value;
this.raisePropertyChanged('hoverDelay');
}
},
get_HoverDelay: function() {
Sys.Extended.Deprecated("get_HoverDelay", "get_hoverDelay");
return this.get_hoverDelay();
},
set_HoverDelay: function(value) {
Sys.Extended.Deprecated("set_HoverDelay", "set_hoverDelay");
this.set_hoverDelay(value);
},
/// <summary>
/// Fires when the hover menu is being shown.
/// </summary>
/// <event add="add_showing" remove="remove_showing" raise="raise_showing" />
/// <member name="cE:AjaxControlToolkit.HoverMenuExtender.showing" />
add_showing: function(handler) {
this.get_events().addHandler('showing', handler);
},
remove_showing: function(handler) {
this.get_events().removeHandler('showing', handler);
},
raise_showing: function(eventArgs) {
var handler = this.get_events().getHandler('showing');
if(handler)
handler(this, eventArgs);
},
raiseShowing: function(eventArgs) {
Sys.Extended.Deprecated("raiseShowing(eventArgs)", "raise_showing(eventArgs)");
this.raise_showing(eventArgs);
},
/// <summary>
/// Fires after the hover menu is shown.
/// </summary>
/// <event add="add_shown" remove="remove_shown" raise="raise_shown" />
/// <member name="cE:AjaxControlToolkit.HoverMenuExtender.shown" />
add_shown: function(handler) {
this.get_events().addHandler('shown', handler);
},
remove_shown: function(handler) {
this.get_events().removeHandler('shown', handler);
},
raise_shown: function(eventArgs) {
var handler = this.get_events().getHandler('shown');
if(handler)
handler(this, eventArgs);
},
raiseShown: function(eventArgs) {
Sys.Extended.Deprecated("raiseShown(eventArgs)", "raise_shown(eventArgs)");
this.raise_shown(eventArgs);
},
/// <summary>
/// Fires when the hover menu is being hidden.
/// </summary>
/// <event add="add_hiding" remove="remove_hiding" raise="raise_hiding" />
/// <member name="cE:AjaxControlToolkit.HoverMenuExtender.hiding" />
add_hiding: function(handler) {
this.get_events().addHandler('hiding', handler);
},
remove_hiding: function(handler) {
this.get_events().removeHandler('hiding', handler);
},
raise_hiding: function(eventArgs) {
var handler = this.get_events().getHandler('hiding');
if(handler)
handler(this, eventArgs);
},
raiseHiding: function(eventArgs) {
Sys.Extended.Deprecated("raiseHiding(eventArgs)", "raise_hiding(eventArgs)");
this.raise_hiding(eventArgs);
},
/// <summary>
/// Fires after the hover menu is hidden.
/// </summary>
/// <event add="add_hidden" remove="remove_hidden" raise="raise_hidden" />
/// <member name="cE:AjaxControlToolkit.HoverMenuExtender.hidden" />
add_hidden: function(handler) {
this.get_events().addHandler('hidden', handler);
},
remove_hidden: function(handler) {
this.get_events().removeHandler('hidden', handler);
},
raise_hidden: function(eventArgs) {
var handler = this.get_events().getHandler('hidden');
if(handler)
handler(this, eventArgs);
},
raiseHidden: function(eventArgs) {
Sys.Extended.Deprecated("raiseHidden(eventArgs)", "raise_hidden(eventArgs)");
this.raise_hidden(eventArgs);
}
}
Sys.Extended.UI.HoverMenuBehavior.registerClass('Sys.Extended.UI.HoverMenuBehavior', Sys.Extended.UI.DynamicPopulateBehaviorBase);
Sys.Extended.UI.HoverMenuPopupPosition = function() {
// Where the popup should be positioned relative to the target control
throw Error.invalidOperation();
}
Sys.Extended.UI.HoverMenuPopupPosition.prototype = {
Center: 0,
Top: 1,
Left: 2,
Bottom: 3,
Right: 4
}
Sys.Extended.UI.HoverMenuPopupPosition.registerEnum('Sys.Extended.UI.HoverMenuPopupPosition');

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,739 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor");
Sys.Extended.UI.HtmlEditor.LastFocusedEditPanel = null;
Sys.Extended.UI.HtmlEditor.EditPanel = function(element) {
Sys.Extended.UI.HtmlEditor.EditPanel.initializeBase(this, [element]);
this._loaded = false;
this._eAfter = null;
this._toolbars = null;
this._modePanels = null;
this._contentChangedElement = null;
this._contentElement = null;
this._contentForceElement = null;
this._activeModeElement = null;
this._suppressTabInDesignMode = false;
this._keyboardEnabled = true;
this._noPaste = false;
this._hotkeys = null;
this._showAnchors = false;
this._showPlaceHolders = false;
this._startEnd = true;
this._relativeImages = true;
this._documentCssPath = null;
this._designPanelCssPath = null;
this._imagePath_1x1 = null;
this._imagePath_flash = null;
this._imagePath_media = null;
this._imagePath_anchor = null;
this._imagePath_placeHolder = null;
this._autofocus = true;
this._initialCleanUp = false;
this._noScript = false;
this._noUnicode = false;
this._cachedToolbarIds = null;
this._contentPrepared = false;
this._activeMode = null;
this._pageRequestManager = null;
this._formOnSubmitSaved = null;
this._validators = null;
this._app_onload$delegate = Function.createDelegate(this, this._app_onload);
this._onsubmit$delegate = Function.createDelegate(this, this._onsubmit);
this._disposed = true;
}
Sys.Extended.UI.HtmlEditor.EditPanel.prototype = {
get_relativeImages: function() {
return this._relativeImages;
},
set_relativeImages: function(value) {
this._relativeImages = value;
if(this._loaded)
this.raisePropertyChanged("relativeImages");
},
get_startEnd: function() {
return this._startEnd;
},
set_startEnd: function(value) {
this._startEnd = value;
if(this._loaded)
this.raisePropertyChanged("startEnd");
},
get_showPlaceHolders: function() {
return this._showPlaceHolders;
},
set_showPlaceHolders: function(value) {
this._showPlaceHolders = value;
if(this._loaded)
this.raisePropertyChanged("showPlaceHolders");
},
get_showAnchors: function() {
return this._showAnchors;
},
set_showAnchors: function(value) {
this._showAnchors = value;
if(this._loaded)
this.raisePropertyChanged("showAnchors");
},
get_hotkeys: function() {
return this._hotkeys;
},
set_hotkeys: function(value) {
this._hotkeys = value;
if(this._loaded)
this.raisePropertyChanged("noPaste");
},
get_noPaste: function() {
return this._noPaste;
},
set_noPaste: function(value) {
this._noPaste = value;
if(this._loaded)
this.raisePropertyChanged("noPaste");
},
get_suppressTabInDesignMode: function() {
return this._suppressTabInDesignMode;
},
set_suppressTabInDesignMode: function(value) {
this._suppressTabInDesignMode = value;
if(this._loaded)
this.raisePropertyChanged("suppressTabInDesignMode");
},
get_keyboardEnabled: function() {
return this._keyboardEnabled;
},
set_keyboardEnabled: function(value) {
this._keyboardEnabled = value;
if(this._loaded)
this.raisePropertyChanged("keyboardEnabled");
},
get_noUnicode: function() {
return this._noUnicode;
},
set_noUnicode: function(value) {
this._noUnicode = value;
if(this._loaded)
this.raisePropertyChanged("noUnicode");
},
get_noScript: function() {
return this._noScript;
},
set_noScript: function(value) {
this._noScript = value;
if(this._loaded)
this.raisePropertyChanged("noScript");
},
get_initialCleanUp: function() {
return this._initialCleanUp;
},
set_initialCleanUp: function(value) {
this._initialCleanUp = value;
if(this._loaded)
this.raisePropertyChanged("initialCleanUp");
},
get_imagePath_1x1: function() {
return this._imagePath_1x1;
},
set_imagePath_1x1: function(value) {
this._imagePath_1x1 = value;
},
get_imagePath_flash: function() {
return this._imagePath_flash;
},
set_imagePath_flash: function(value) {
this._imagePath_flash = value;
},
get_imagePath_media: function() {
return this._imagePath_media;
},
set_imagePath_media: function(value) {
this._imagePath_media = value;
},
get_imagePath_anchor: function() {
return this._imagePath_anchor;
},
set_imagePath_anchor: function(value) {
this._imagePath_anchor = value;
},
get_imagePath_placeHolder: function() {
return this._imagePath_placeHolder;
},
set_imagePath_placeHolder: function(value) {
this._imagePath_placeHolder = value;
},
get_documentCssPath: function() {
return this._documentCssPath;
},
set_documentCssPath: function(value) {
this._documentCssPath = value;
if(this._loaded)
this.raisePropertyChanged("documentCssPath");
},
get_designPanelCssPath: function() {
return this._designPanelCssPath;
},
set_designPanelCssPath: function(value) {
this._designPanelCssPath = value;
if(this._loaded)
this.raisePropertyChanged("designPanelCssPath");
},
get_autofocus: function() {
return this._autofocus;
},
set_autofocus: function(value) {
this._autofocus = value;
if(this._loaded)
this.raisePropertyChanged("autofocus");
},
get_content: function() {
if(this._activeMode == null) {
if(this.get_contentElement() != null)
return this._getContentForPostback();
return "";
}
return this.getContent();
},
set_content: function(value) {
if(!this.get_isInitialized() || !this._loaded) {
if(this.get_contentElement() != null)
this.get_contentElement().value = value.replace(/\"/g, "&quot;");
return;
}
this.setContent(value);
this._contentPrepared = false;
if(this._loaded)
this.raisePropertyChanged("content");
},
get_activeMode: function() {
if(this._activeMode == null)
return Sys.Extended.UI.HtmlEditor.ActiveModeType.Design;
return this._activeMode;
},
set_activeMode: function(value) {
if(!Sys.Extended.UI.HtmlEditor.ActiveModeType_checkValue(value))
throw Error.argumentOutOfRange("value, function: Sys.Extended.UI.HtmlEditor.EditPanel.set_activeMode");
var oldMode = this._activeMode,
retval = true;
if(this._loaded && oldMode != null && oldMode != value) {
var eBefore = new Sys.Extended.UI.HtmlEditor.ActiveModeChangedArgs(oldMode, value, this);
this.raiseBeforeActiveModeChanged(eBefore);
this._eAfter = new Sys.Extended.UI.HtmlEditor.ActiveModeChangedArgs(oldMode, value, this);
retval = this._setMode(value);
} else {
this._activeMode = value;
}
this.get_activeModeElement().value = value;
return retval;
},
get_contentChangedElement: function() {
return this._contentChangedElement;
},
set_contentChangedElement: function(value) {
this._contentChangedElement = value;
},
get_contentElement: function() {
return this._contentElement;
},
set_contentElement: function(value) {
this._contentElement = value;
},
get_contentForceElement: function() {
return this._contentForceElement;
},
set_contentForceElement: function(value) {
this._contentForceElement = value;
},
get_activeModeElement: function() {
return this._activeModeElement;
},
set_activeModeElement: function(value) {
this._activeModeElement = value;
},
setCancelOnPostback: function() {
if(this._loaded)
this.get_contentForceElement().value = "";
},
setAcceptOnPostback: function() {
if(this._loaded)
this.get_contentForceElement().value = "1";
},
get_toolbars: function() {
if(this._toolbars == null)
this._toolbars = [];
return this._toolbars;
},
set_toolbars: function(value) {
this.get_toolbars().push(value);
},
get_toolbarIds: function() {
},
set_toolbarIds: function(value) {
if(!this.get_isInitialized()) {
this._cachedToolbarIds = value;
return;
}
var arr = value.split(";");
for(var i = 0; i < arr.length; i++)
if(arr[i].length > 0)
this.set_toolbars($find(arr[i]));
},
get_modePanels: function() {
if(this._modePanels == null)
this._modePanels = [];
return this._modePanels;
},
set_modePanel: function(value) {
this.get_modePanels().push(value);
},
get_modePanelIds: function() {
},
set_modePanelIds: function(value) {
var arr = value.split(";");
for(var i = 0; i < arr.length; i++)
this.set_modePanel($find(arr[i]));
},
add_focused: function(handler) {
this.get_events().addHandler("focused", handler);
},
remove_focused: function(handler) {
this.get_events().removeHandler("focused", handler);
},
raiseFocused: function(e) {
var eh = this.get_events().getHandler("focused");
if(eh)
eh(this, e);
},
add_activeModeChanged: function(handler) {
this.get_events().addHandler("activeModeChanged", handler);
},
remove_activeModeChanged: function(handler) {
this.get_events().removeHandler("activeModeChanged", handler);
},
raiseActiveModeChanged: function(e) {
var eh = this.get_events().getHandler("activeModeChanged");
if(eh)
eh(this, e);
},
add_beforeActiveModeChanged: function(handler) {
this.get_events().addHandler("beforeActiveModeChanged", handler);
},
remove_beforeActiveModeChanged: function(handler) {
this.get_events().removeHandler("beforeActiveModeChanged", handler);
},
raiseBeforeActiveModeChanged: function(e) {
var eh = this.get_events().getHandler("beforeActiveModeChanged");
if(eh)
eh(this, e);
},
get_activePanel: function() {
var modePanel = this.get_modePanels()[this.get_activeMode()];
if(modePanel == null || typeof modePanel == "undefined")
throw Error.argumentOutOfRange("activeMode, function: Sys.Extended.UI.HtmlEditor.EditPanel.get_activePanel");
return modePanel;
},
initialize: function() {
this.__appLoaded__ = false;
Sys.Extended.UI.HtmlEditor.EditPanel.callBaseMethod(this, "initialize");
this._disposed = false;
Sys.Application.add_load(this._app_onload$delegate);
if(Sys && Sys.WebForms && Sys.WebForms.PageRequestManager) {
this._pageRequestManager = Sys.WebForms.PageRequestManager.getInstance();
if(this._pageRequestManager) {
this._partialUpdateEndRequestHandler = Function.createDelegate(this, this._partialUpdateEndRequest);
this._pageRequestManager.add_endRequest(this._partialUpdateEndRequestHandler);
this._invokingRequestHandler = Function.createDelegate(this, this._invokingRequest);
Sys.Net.WebRequestManager.add_invokingRequest(this._invokingRequestHandler);
this._completedRequestHandler = Function.createDelegate(this, this._completedRequest);
Sys.Net.WebRequestManager.add_completedRequest(this._completedRequestHandler);
}
}
Sys.Extended.UI.HtmlEditor.addFormOnSubmit(this._onsubmit$delegate, this);
},
dispose: function() {
this._loaded = false;
this._disposed = true;
if(this._pageRequestManager) {
if(this._invokingRequestHandler) {
this._pageRequestManager.remove_endRequest(this._partialUpdateEndRequestHandler);
this._partialUpdateEndRequestHandler = null;
Sys.Net.WebRequestManager.remove_invokingRequest(this._invokingRequestHandler);
this._invokingRequestHandler = null;
Sys.Net.WebRequestManager.remove_completedRequest(this._completedRequestHandler);
this._completedRequestHandler = null;
}
this._pageRequestManager = null;
}
Sys.Extended.UI.HtmlEditor.removeFormOnSubmit(this._onsubmit$delegate);
Sys.Application.remove_load(this._app_onload$delegate);
this.disableToolbars();
Sys.Extended.UI.HtmlEditor.EditPanel.callBaseMethod(this, "dispose");
},
_onsubmit: function(e) {
if(!this._contentPrepared) {
this._prepareContentForPostback(this.get_content());
this._contentPrepared = true;
}
return true;
},
_invokingRequest: function(sender, args) {
if(this._contentPrepared)
return;
var webRequest = args.get_webRequest(),
body = webRequest.get_body();
// change body here...
var reg = new RegExp("([\\?&])(" + this.get_contentElement().name + "=)([^&$]*)([&$])", "g");
this._prepareContentForPostback(this.get_content());
body = body.replace(reg, "$1$2" + escape(this.get_contentElement().value) + "$4");
this._contentPrepared = true;
webRequest.set_body(body);
},
_completedRequest: function(sender, args) {
this._contentPrepared = false;
},
_partialUpdateEndRequest: function(sender, args) {
this._contentPrepared = false;
if(Sys.Extended.UI.HtmlEditor.isIE && this.__blured) {
this.__blured = false;
this.get_activePanel()._focus();
}
},
_app_onload: function(sender, e) {
if(this.__appLoaded__)
return;
this.__appLoaded__ = true;
if(this._disposed)
return;
var editPanel = this;
this._loaded = true;
this.set_activeMode(parseInt(this.get_activeModeElement().value));
if(this._cachedToolbarIds != null) {
this.set_toolbarIds(this._cachedToolbarIds);
this._cachedToolbarIds = null;
}
this._validators = this.get_modePanels()[Sys.Extended.UI.HtmlEditor.ActiveModeType.Html].get_element().Validators;
this._shouldResize = false;
if(Sys.Extended.UI.HtmlEditor.isIE && document.compatMode != "BackCompat")
this._shouldResize = true;
if(this._shouldResize) {
var modePanels = this.get_modePanels(),
iframePanel = modePanels[Sys.Extended.UI.HtmlEditor.ActiveModeType.Design];
if(iframePanel == null)
iframePanel = modePanels[Sys.Extended.UI.HtmlEditor.ActiveModeType.Preview];
var htmlPanel = modePanels[Sys.Extended.UI.HtmlEditor.ActiveModeType.Html];
if(iframePanel != null && htmlPanel != null) {
var iframePanelElement = iframePanel.get_element();
iframePanelElement.style.display = "";
var height = iframePanelElement.offsetHeight,
invisible = false,
save;
if(height == 0) {
invisible = true;
save = Sys.Extended.UI.HtmlEditor.setElementVisibility(iframePanelElement.parentNode);
height = iframePanelElement.offsetHeight;
}
htmlPanel.get_element().style.height = height + "px";
if(invisible) {
Sys.Extended.UI.HtmlEditor.restoreElementVisibility(save);
delete save;
}
iframePanelElement.style.display = "none";
}
}
var content = this.get_contentElement().value.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, "\"").replace(/&amp;/g, "&");
this.setContent(this._initialCleanUp ? Sys.Extended.UI.HtmlEditor.cleanUp(content.replace(/[\n\r]+/g, " ")) : content);
this.setAcceptOnPostback();
},
_setActive: function() {
for(var i = 0; i < this.get_toolbars().length; i++)
this.get_toolbars()[i].set_activeEditPanel(this, true);
if(this._eAfter != null) {
this.raisePropertyChanged("activeMode");
this.raiseActiveModeChanged(this._eAfter);
this._eAfter = null;
}
},
_focused: function(prize) {
if(!(typeof prize != "undefined" && prize))
for(var i = 0; i < this.get_toolbars().length; i++)
this.get_toolbars()[i].set_activeEditPanel(this);
//this.raiseFocused(new Sys.EventArgs());
Sys.Extended.UI.HtmlEditor.LastFocusedEditPanel = this;
},
_really_focused: function() {
this._focused();
this.raiseFocused(new Sys.EventArgs());
},
updateToolbar: function() {
this._focused();
},
getContent: function() {
var ret = this.get_activePanel().get_content()
.replace(/<\/?html(?=\s|>)(?:[^>]*?)>/gi, "")
.replace(/<\/?head(?=\s|>)(?:[^>]*?)>/gi, "")
.replace(/<\/?body(?=\s|>)(?:[^>]*?)>/gi, "")
.replace(/^([\n\r]+)/, "").replace(/([\n\r]+)$/, "");
if(!Sys.Extended.UI.HtmlEditor.isIE)
ret = ret.replace(/^<br\s*[\/]*>$/, "");
return ret;
},
setContent: function(content) {
var temptext = content;
if(this.get_noScript())
temptext = temptext.replace(/(<script(?:[^>]*?)>(?:[^<]*?)<\/script(?:[^>]*?)>)/ig, "");
temptext = temptext.replace(/<\/?html(?=\s|>)(?:[^>]*?)>/gi, "")
.replace(/<\/?head(?=\s|>)(?:[^>]*?)>/gi, "")
.replace(/<\/?body(?=\s|>)(?:[^>]*?)>/gi, "")
.replace(/^([\n\r]+)/, "").replace(/([\n\r]+)$/, "");
this._prepareContentForPostback(temptext);
this.get_activePanel().set_content(temptext);
this._validate(null, temptext);
},
_validate: function(event, content) {
var validators = this._validators;
if(validators != null && typeof validators != "undefined") {
this._contentForValidation = content;
try {
for(var i = 0; i < validators.length; i++)
window.ValidatorValidate(validators[i], null, event);
window.ValidatorUpdateIsValid();
} catch(ex) { }
this._contentForValidation = null;
}
},
_prepareContentForPostback: function(value) {
this.get_contentElement().value = value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/\"/g, "&quot;");
},
_getContentForPostback: function() {
return this.get_contentElement().value.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, "\"").replace(/&amp;/g, "&");
},
_setMode: function(mode) {
var activePanel = this.get_activePanel();
if(!activePanel._activated) {
var editPanel = this;
setTimeout(function() {
editPanel._setMode(mode);
}, 10);
return false;
}
var content = this.get_content();
if(Sys.Extended.UI.HtmlEditor.isOpera)
content = content.replace(/\r/ig, "");
if(this._shouldResize && mode == Sys.Extended.UI.HtmlEditor.ActiveModeType.Html) {
var iframePanel = this.get_activePanel(),
htmlPanel = this.get_modePanels()[Sys.Extended.UI.HtmlEditor.ActiveModeType.Html];
if(iframePanel != null && htmlPanel != null) {
var iframePanelElement = iframePanel.get_element(),
height = iframePanelElement.offsetHeight,
invisible = false,
save;
if(height == 0) {
invisible = true;
save = Sys.Extended.UI.HtmlEditor.setElementVisibility(iframePanelElement.parentNode);
height = iframePanelElement.offsetHeight;
}
htmlPanel.get_element().style.height = height + "px";
if(invisible) {
Sys.Extended.UI.HtmlEditor.restoreElementVisibility(save);
delete save;
}
}
}
this.disableToolbars(mode);
activePanel._deactivate();
this._activeMode = mode;
this.setContent(content);
return true;
},
disableToolbars: function(mode) {
for(var i = 0; i < this.get_toolbars().length; i++) {
var toolbar = this.get_toolbars()[i];
if(toolbar._loaded)
toolbar.disable(mode);
}
},
openWait: function() {
},
closeWait: function() {
}
}
Sys.Extended.UI.HtmlEditor.EditPanel.registerClass("Sys.Extended.UI.HtmlEditor.EditPanel", Sys.UI.Control);

View File

@@ -0,0 +1,185 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor");
Sys.Extended.UI.HtmlEditor.Editor = function(element) {
Sys.Extended.UI.HtmlEditor.Editor.initializeBase(this, [element]);
this._editPanel = null;
this._changingToolbar = null;
if(Sys.Extended.UI.HtmlEditor.isIE && Sys.Browser.version == 8 && document.compatMode != "BackCompat" || Sys.Extended.UI.HtmlEditor.isOpera)
this._onresize$delegate = Function.createDelegate(this, this._onresize);
}
Sys.Extended.UI.HtmlEditor.Editor.prototype = {
get_autofocus: function() {
return this._editPanel.get_autofocus();
},
set_autofocus: function(value) {
this._editPanel.set_autofocus(value);
},
get_content: function() {
return this._editPanel.get_content();
},
set_content: function(value) {
this._editPanel.set_content(value);
},
get_activeMode: function() {
return this._editPanel.get_activeMode();
},
set_activeMode: function(value) {
this._editPanel.set_activeMode(value);
},
get_editPanel: function() {
return this._editPanel;
},
set_editPanel: function(value) {
this._editPanel = value;
},
get_changingToolbar: function() {
return this._changingToolbar;
},
set_changingToolbar: function(value) {
this._changingToolbar = value;
},
add_propertyChanged: function(handler) {
this._editPanel.add_propertyChanged(handler);
},
remove_propertyChanged: function(handler) {
this._editPanel.remove_propertyChanged(handler);
},
initialize: function() {
Sys.Extended.UI.HtmlEditor.Editor.callBaseMethod(this, "initialize");
var element = this.get_element(),
oldStyle = element.className;
Sys.UI.DomElement.removeCssClass(element, oldStyle);
Sys.UI.DomElement.addCssClass(element, "ajax__htmleditor_editor_base");
Sys.UI.DomElement.addCssClass(element, oldStyle);
if(!Sys.Extended.UI.HtmlEditor.isIE && document.compatMode != "BackCompat")
this.get_element().style.height = "100%";
if(Sys.Extended.UI.HtmlEditor.isIE && Sys.Browser.version == 8 && document.compatMode != "BackCompat" || Sys.Extended.UI.HtmlEditor.isOpera) {
$addHandlers(element, {
resize: this._onresize$delegate
});
var editPanel = this.get_editPanel();
this._saved_setActive = editPanel._setActive;
editPanel._setActive = Function.createDelegate(this, this._setActive);
var editor = this;
if(Sys.Extended.UI.HtmlEditor.isOpera) {
setTimeout(function() {
editor._ensureVisibleResize();
}, 0);
} else {
editor._ensureVisibleResize();
}
}
},
_setActive: function(par) {
var editor = this;
(Function.createDelegate(this.get_editPanel(), this._saved_setActive))(par);
if(!Sys.Extended.UI.HtmlEditor.isReallyVisible(this.get_element())) {
setTimeout(function() {
editor._ensureVisibleResize();
}, 0);
} else {
editor._ensureVisibleResize();
}
},
_ensureVisibleResize: function() {
var invisible = false,
save;
if(!Sys.Extended.UI.HtmlEditor.isReallyVisible(this.get_element())) {
invisible = true;
save = Sys.Extended.UI.HtmlEditor.setElementVisibility(this.get_element());
}
this._onresize();
if(invisible) {
Sys.Extended.UI.HtmlEditor.restoreElementVisibility(save);
delete save;
}
},
dispose: function() {
if(Sys.Extended.UI.HtmlEditor.isIE && Sys.Browser.version == 8 && document.compatMode != "BackCompat" || Sys.Extended.UI.HtmlEditor.isOpera) {
$common.removeHandlers(this.get_element(), {
resize: this._onresize$delegate
});
this.get_editPanel()._setActive = this._saved_setActive;
}
Sys.Extended.UI.HtmlEditor.Editor.callBaseMethod(this, "dispose");
},
_onresize: function(e) {
try {
var editPanelTD = this.get_editPanel().get_element().parentNode;
if(typeof e == "undefined" || e == null)
editPanelTD.style.height = "";
var height = Sys.Extended.UI.HtmlEditor.Editor.MidleCellHeightForIE(editPanelTD.parentNode.parentNode.parentNode, editPanelTD.parentNode);
editPanelTD.style.height = height;
if(typeof this.get_editPanel().get_activePanel()._onresize != "undefined")
this.get_editPanel().get_activePanel()._onresize();
} catch(ex) { }
return true;
}
}
Sys.Extended.UI.HtmlEditor.Editor.registerClass("Sys.Extended.UI.HtmlEditor.Editor", Sys.UI.Control);
Sys.Extended.UI.HtmlEditor.Editor.MidleCellHeightForIE = function(table, row) {
var height = "100%";
if(Sys.Extended.UI.HtmlEditor.isIE && document.compatMode != "BackCompat" || Sys.Extended.UI.HtmlEditor.isOpera) {
try {
var decrease = 2;
for(var i = 0; i < table.rows.length; i++)
if(table.rows[i] != row)
decrease += (table.rows[i].offsetHeight + 1);
var clientHeight = table.clientHeight;
if(Sys.Browser.version == 8 || Sys.Extended.UI.HtmlEditor.isOpera) {
var styleHeight = table.style.height,
parentStyleHeight = table.parentNode.style.height;
if(styleHeight.indexOf("px") > 0)
clientHeight = parseInt(styleHeight);
else if(styleHeight == "100%" && parentStyleHeight.indexOf("px") > 0)
clientHeight = parseInt(parentStyleHeight);
}
height = ((clientHeight - decrease) * 100.00 / (clientHeight * 1.00)) + '%';
} catch(e) {
height = "";
}
}
return height;
}

View File

@@ -0,0 +1,18 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor");
Sys.Extended.UI.HtmlEditor.ActiveModeType = function() { }
Sys.Extended.UI.HtmlEditor.ActiveModeType.prototype = {
Design: 0x00,
Html: 0x01,
Preview: 0x02
}
Sys.Extended.UI.HtmlEditor.ActiveModeType_checkValue = function(value) {
if(value >= 0 && value <= 2)
return true;
return false;
}
Sys.Extended.UI.HtmlEditor.ActiveModeType.registerEnum("Sys.Extended.UI.HtmlEditor.ActiveModeType", true);

View File

@@ -0,0 +1,30 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor");
Sys.Extended.UI.HtmlEditor.ActiveModeChangedArgs = function(oldMode, newMode, editPanel) {
if(arguments.length != 3)
throw Error.parameterCount();
//Calling the base class constructor
Sys.Extended.UI.HtmlEditor.ActiveModeChangedArgs.initializeBase(this);
this._oldMode = oldMode;
this._newMode = newMode;
this._editPanel = editPanel;
}
Sys.Extended.UI.HtmlEditor.ActiveModeChangedArgs.prototype = {
get_oldMode: function() {
return this._oldMode;
},
get_newMode: function() {
return this._newMode;
},
get_editPanel: function() {
return this._editPanel;
}
}
Sys.Extended.UI.HtmlEditor.ActiveModeChangedArgs.registerClass('Sys.Extended.UI.HtmlEditor.ActiveModeChangedArgs', Sys.EventArgs);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,123 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor");
Sys.Extended.UI.HtmlEditor.HtmlPanel = function(element) {
Sys.Extended.UI.HtmlEditor.HtmlPanel.initializeBase(this, [element]);
this._onfocus$delegate = Function.createDelegate(this, this._onfocus);
if(Sys.Extended.UI.HtmlEditor.isIE && document.compatMode != "BackCompat")
this._onresize$delegate = Function.createDelegate(this, this._onresize);
}
Sys.Extended.UI.HtmlEditor.HtmlPanel.prototype = {
_activate: function(value) {
this._shouldResize = false;
var element = this.get_element();
if(Sys.Extended.UI.HtmlEditor.isIE && Sys.Browser.version > 6 && document.compatMode != "BackCompat" && element.parentNode.clientHeight > 0)
this._shouldResize = true;
Sys.Extended.UI.HtmlEditor.HtmlPanel.callBaseMethod(this, "_activate");
if(Sys.Extended.UI.HtmlEditor.isIE) {
element.value = "";
var panel = this;
setTimeout(function() {
element.value = value;
}, 0);
} else {
element.value = value;
}
$addHandlers(element, {
focus: this._onfocus$delegate
});
if(this._shouldResize)
$addHandlers(element, {
resize: this._onresize$delegate
});
this._activateFinished();
},
_deactivate: function() {
var element = this.get_element();
if(this._shouldResize)
$common.removeHandlers(element, {
resize: this._onresize$delegate
});
this._shouldResize = false;
$common.removeHandlers(element, {
focus: this._onfocus$delegate
});
element.value = "";
Sys.Extended.UI.HtmlEditor.HtmlPanel.callBaseMethod(this, "_deactivate");
},
_getContent: function() {
return this.get_element().value;
},
_setContent: function(value) {
this.get_element().value = value;
if(Sys.Extended.UI.HtmlEditor.isReallyVisible(this.get_element().parentNode)) {
try { // some browsers fail when invisible
var textarea = this.get_element();
textarea.focus();
setTimeout(function() {
try {
Sys.Extended.UI.HtmlEditor.setSelectionRange(textarea, 0, 0);
} catch(e) { }
}, 0);
} catch(e) { }
}
},
_focus: function() {
if(Sys.Extended.UI.HtmlEditor.isReallyVisible(this.get_element().parentNode)) {
try { // some browsers fail when invisible
var textarea = this.get_element();
textarea.focus();
setTimeout(function() {
try {
Sys.Extended.UI.HtmlEditor.setSelectionRange(textarea, 0, 0);
} catch(e) { }
}, 0);
} catch(e) { }
}
var panel = this;
setTimeout(function() {
panel._focused();
}, 0);
},
_onfocus: function(e) {
this._really_focused();
var textarea = this.get_element();
setTimeout(function() {
textarea.focus();
}, 0);
return true;
},
_onresize: function(e) {
var element = this.get_element();
var clientHeight = element.parentNode.clientHeight;
if(clientHeight > 0)
element.style.height = clientHeight + "px";
}
}
Sys.Extended.UI.HtmlEditor.HtmlPanel.registerClass("Sys.Extended.UI.HtmlEditor.HtmlPanel", Sys.Extended.UI.HtmlEditor.ModePanel);

View File

@@ -0,0 +1,123 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor");
Sys.Extended.UI.HtmlEditor.ModePanel = function(element) {
Sys.Extended.UI.HtmlEditor.ModePanel.initializeBase(this, [element]);
this._activated = false;
this._isActivating = false;
this._editPanel = null;
this._cachedContent = null;
this._onbeforeunload$delegate = Function.createDelegate(this, this._onbeforeunload);
}
Sys.Extended.UI.HtmlEditor.ModePanel.prototype = {
set_editPanel: function(value) {
this._editPanel = value;
},
get_content: function() {
if(this._activated) {
return this._getContent();
} else {
if(this._cachedContent != null)
return this._cachedContent;
else
return "";
}
},
set_content: function(value) {
this._cachedContent = value;
if(!this._activated && !this._isActivating) {
this._activate(value);
} else {
if(!this._isActivating) {
this._setContent(value);
} else {
var panel = this;
setTimeout(function() {
panel.set_content(value);
}, 10);
return false;
}
}
return true;
},
_activate: function() {
this.get_element().style.display = "";
this._isActivating = true;
},
_activateFinished: function() {
this._activated = true;
this._isActivating = false;
this._editPanel._setActive();
if(this._editPanel.get_autofocus())
this._focus();
},
_deactivate: function() {
this.get_element().style.display = "none";
this._activated = false;
this._isActivating = false;
},
initialize: function() {
Sys.Extended.UI.HtmlEditor.ModePanel.callBaseMethod(this, "initialize");
if(Sys.Extended.UI.HtmlEditor.isIE)
$addHandlers(window, { beforeunload: this._onbeforeunload$delegate });
},
dispose: function() {
if(Sys.Extended.UI.HtmlEditor.isIE)
$common.removeHandlers(window, { beforeunload: this._onbeforeunload$delegate });
if(this._activated) {
if(Sys.Extended.UI.HtmlEditor.isIE)
this._onbeforeunload();
this._deactivate();
}
Sys.Extended.UI.HtmlEditor.ModePanel.callBaseMethod(this, "dispose");
},
_onbeforeunload: function() {
if(this._activated)
if(!this._editPanel._contentPrepared) {
this._editPanel._prepareContentForPostback(this.get_content());
this._editPanel._contentPrepared = true;
}
},
_getContent: function() {
if(this._cachedContent != null)
return this._cachedContent;
else
return "";
},
_setContent: function(value) {
},
_focus: function() {
this._focused();
},
_focused: function(prize) {
this._editPanel._focused(prize);
this._editPanel.set_autofocus(true);
},
_really_focused: function() {
this._editPanel._really_focused();
this._editPanel.set_autofocus(true);
}
}
Sys.Extended.UI.HtmlEditor.ModePanel.registerClass("Sys.Extended.UI.HtmlEditor.ModePanel", Sys.UI.Control);

View File

@@ -0,0 +1,83 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.Popups");
Sys.Extended.UI.HtmlEditor.Popups.AttachedPopup = function(element) {
Sys.Extended.UI.HtmlEditor.Popups.AttachedPopup.initializeBase(this, [element]);
this._relatedElement = null;
}
Sys.Extended.UI.HtmlEditor.Popups.AttachedPopup.prototype = {
get_relatedElement: function() {
return this._relatedElement;
},
set_relatedElement: function(value) {
this._relatedElement = value;
},
open: function(callback) {
if(this._relatedElement != null) {
var popup = this;
if(!this.checkCorrectLoaded(function() { popup.open(callback); }))
return;
var location = $common.getLocation(this._relatedElement),
x = location.x,
y = location.y + this._relatedElement.offsetHeight;
var element = this.get_element().parentNode;
while(element && element.tagName && element.tagName.toUpperCase() != "BODY") {
var position = Sys.Extended.UI.HtmlEditor.getStyle(element, "position");
if(position == "absolute" || position == "fixed") {
var top = parseInt(Sys.Extended.UI.HtmlEditor.getStyle(element, "top")),
left = parseInt(Sys.Extended.UI.HtmlEditor.getStyle(element, "left"));
if(!isNaN(top) && !isNaN(left)) {
x -= left;
y -= top;
}
break;
} else if(position == "relative") {
var relativeLocation = $common.getLocation(element);
x -= relativeLocation.x;
y -= relativeLocation.y;
}
element = element.parentNode;
}
var viewportElement = Sys.Extended.UI.HtmlEditor.getClientViewportElement(this._iframe),
theVisibleWidth = viewportElement.clientWidth + viewportElement.scrollLeft,
theVisibleHeight = viewportElement.clientHeight + viewportElement.scrollTop;
if(y < viewportElement.scrollTop)
y = viewportElement.scrollTop;
if(x < viewportElement.scrollLeft)
x = viewportElement.scrollLeft;
if(y + this._iframe.offsetHeight > theVisibleHeight)
y -= y + this._iframe.offsetHeight - theVisibleHeight;
if(x + this._iframe.offsetWidth > theVisibleWidth)
x -= x + this._iframe.offsetWidth - theVisibleWidth;
Sys.Extended.UI.HtmlEditor.Popups.AttachedPopup.callBaseMethod(this, "open", [callback, y, x]);
}
},
close: function(callback) {
Sys.Extended.UI.HtmlEditor.Popups.AttachedPopup.callBaseMethod(this, "close", [callback]);
},
initialize: function() {
Sys.Extended.UI.HtmlEditor.Popups.AttachedPopup.callBaseMethod(this, "initialize");
},
dispose: function() {
Sys.Extended.UI.HtmlEditor.Popups.AttachedPopup.callBaseMethod(this, "dispose");
}
}
Sys.Extended.UI.HtmlEditor.Popups.AttachedPopup.registerClass("Sys.Extended.UI.HtmlEditor.Popups.AttachedPopup", Sys.Extended.UI.HtmlEditor.Popups.Popup);

View File

@@ -0,0 +1,29 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.Popups");
Sys.Extended.UI.HtmlEditor.Popups.AttachedTemplatePopup = function(element) {
Sys.Extended.UI.HtmlEditor.Popups.AttachedTemplatePopup.initializeBase(this, [element]);
this._contentDiv = null;
}
Sys.Extended.UI.HtmlEditor.Popups.AttachedTemplatePopup.prototype = {
get_contentDiv: function() {
return this._contentDiv;
},
set_contentDiv: function(value) {
this._contentDiv = value;
},
initialize: function() {
Sys.Extended.UI.HtmlEditor.Popups.AttachedTemplatePopup.callBaseMethod(this, "initialize");
this.set_initialContent(this._contentDiv.innerHTML);
},
dispose: function() {
Sys.Extended.UI.HtmlEditor.Popups.AttachedTemplatePopup.callBaseMethod(this, "dispose");
}
}
Sys.Extended.UI.HtmlEditor.Popups.AttachedTemplatePopup.registerClass("Sys.Extended.UI.HtmlEditor.Popups.AttachedTemplatePopup", Sys.Extended.UI.HtmlEditor.Popups.AttachedPopup);

View File

@@ -0,0 +1,10 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.Popups");
Sys.Extended.UI.HtmlEditor.Popups.BaseColorsPopup = function(element) {
Sys.Extended.UI.HtmlEditor.Popups.BaseColorsPopup.initializeBase(this, [element]);
}
Sys.Extended.UI.HtmlEditor.Popups.BaseColorsPopup.prototype = {
}
Sys.Extended.UI.HtmlEditor.Popups.BaseColorsPopup.registerClass("Sys.Extended.UI.HtmlEditor.Popups.BaseColorsPopup", Sys.Extended.UI.HtmlEditor.Popups.AttachedTemplatePopup);

View File

@@ -0,0 +1,22 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.Popups");
Sys.Extended.UI.HtmlEditor.Popups.LinkProperties = function(element) {
Sys.Extended.UI.HtmlEditor.Popups.LinkProperties.initializeBase(this, [element]);
this._defaultTarget = "_self";
this._targetTextHolder = null;
this._urlTextHolder = null;
}
Sys.Extended.UI.HtmlEditor.Popups.LinkProperties.prototype = {
get_defaultTarget: function() {
return this._defaultTarget;
},
set_defaultTarget: function(value) {
this._defaultTarget = value;
}
}
Sys.Extended.UI.HtmlEditor.Popups.LinkProperties.registerClass("Sys.Extended.UI.HtmlEditor.Popups.LinkProperties", Sys.Extended.UI.HtmlEditor.Popups.OkCancelAttachedTemplatePopup);

View File

@@ -0,0 +1,18 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.Popups");
Sys.Extended.UI.HtmlEditor.Popups.OkCancelAttachedTemplatePopup = function(element) {
Sys.Extended.UI.HtmlEditor.Popups.OkCancelAttachedTemplatePopup.initializeBase(this, [element]);
}
Sys.Extended.UI.HtmlEditor.Popups.OkCancelAttachedTemplatePopup.prototype = {
initialize: function() {
Sys.Extended.UI.HtmlEditor.Popups.OkCancelAttachedTemplatePopup.callBaseMethod(this, "initialize");
},
dispose: function() {
Sys.Extended.UI.HtmlEditor.Popups.OkCancelAttachedTemplatePopup.callBaseMethod(this, "dispose");
}
}
Sys.Extended.UI.HtmlEditor.Popups.OkCancelAttachedTemplatePopup.registerClass("Sys.Extended.UI.HtmlEditor.Popups.OkCancelAttachedTemplatePopup", Sys.Extended.UI.HtmlEditor.Popups.AttachedTemplatePopup);

View File

@@ -0,0 +1,323 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.Popups");
Sys.Extended.UI.HtmlEditor.Popups.Popup = function(element) {
Sys.Extended.UI.HtmlEditor.Popups.Popup.initializeBase(this, [element]);
this._iframe = null;
this._top = 0;
this._left = 0;
this._doc = null;
this._initialContent = "";
this._cssPath = "";
this._autoDimensions = true;
this._registeredFields = [];
this._registeredHandlers = [];
this._app_onload$delegate = Function.createDelegate(this, this._app_onload);
this.isOpened = false;
this.isLoaded = false;
this.isLoading = false;
}
Sys.Extended.UI.HtmlEditor.Popups.Popup.prototype = {
getDocument: function() {
return this._doc;
},
getPopupMediator: function() {
if(this._iframe.contentWindow && this._iframe.contentWindow.popupMediator)
return this._iframe.contentWindow.popupMediator;
else
return null;
},
get_registeredFields: function() {
return this._registeredFields;
},
set_registeredFields: function(value) {
this._registeredFields = eval(value);
},
get_registeredHandlers: function() {
return this._registeredHandlers;
},
set_registeredHandlers: function(value) {
this._registeredHandlers = eval(value);
},
get_initialContent: function() {
return this._initialContent;
},
set_initialContent: function(value) {
this._initialContent = value;
},
get_cssPath: function() {
return this._cssPath;
},
set_cssPath: function(value) {
this._cssPath = value;
},
get_autoDimensions: function() {
return this._autoDimensions;
},
set_autoDimensions: function(value) {
this._autoDimensions = value;
},
get_iframe: function() {
return this._iframe;
},
set_iframe: function(value) {
this._iframe = value;
},
checkCorrectLoaded: function(func) {
var popup = this;
if(popup.isLoaded && (popup._iframe.style.height == "0px" || popup._iframe.style.width == "0px"))
this.isLoaded = false;
if(!this.isLoaded) {
if(!this.isLoading)
this.reload();
if(typeof func != "undefined")
setTimeout(func, 10);
return false;
}
return true;
},
_baseOpen: function(callback, top, left) {
var popup = this;
if(!this.checkCorrectLoaded(function() { popup._baseOpen(callback, top, left); }))
return;
var element = this.get_element();
if(typeof left != "undefined")
this._left = parseInt(left);
if(typeof top != "undefined")
this._top = parseInt(top);
element.style.top = this._top + "px";
element.style.left = this._left + "px";
setTimeout(function() {
if(typeof callback == "function")
popup._onDocumentLoaded(callback);
popup.isOpened = true;
}, 0);
},
open: function(callback, top, left) {
this._baseOpen(callback, top, left);
},
close: function(callback) {
var element = this.get_element();
this.isOpened = false;
element.style.top = "-2000px";
element.style.left = "-2000px";
if(typeof callback == "function")
callback();
},
reload: function() {
this.isLoading = true;
var element = this.get_element();
var _parentNode_ = element.parentNode;
document.body.appendChild(element);
_parentNode_.appendChild(this.get_element());
this._doc = this._iframe.contentWindow.document;
this._doc.open();
var html = new Sys.StringBuilder();
html.append("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\"><html><head>");
if(this._cssPath.length > 0)
html.append("<link rel=\"stylesheet\" href=\"" + this._cssPath + "\" media=\"all\" />");
html.append("<script>var __loaded__ = false;</script></head><body style='margin:0px; padding:0px; border-width:0px;' onload='__loaded__ = true;'>");
if(this._autoDimensions)
html.append("<table cellspacing='0' cellpadding='0' border='0'><tr><td>");
html.append(this._initialContent);
if(this._autoDimensions)
html.append("</td></tr></table>");
html.append("</body></html>");
this._doc.write(html.toString());
this._doc.close();
this.isLoaded = false;
this._afterReload();
},
_afterReload: function() {
var contentWindow = this._iframe.contentWindow,
popup = this;
this.isLoaded = contentWindow.__loaded__;
if(!(popup._doc.body && popup._doc.body.innerHTML))
this.isLoaded = false;
if(!this.isLoaded) {
setTimeout(function() {
popup._afterReload()
}, 10); // waiting for loading
return;
}
this.isLoaded = false;
contentWindow.popupMediator = {};
contentWindow.popupMediator.registeredFields = this._registeredFields;
contentWindow.popupMediator.registeredHandlers = this._registeredHandlers;
contentWindow.popupMediator.get_callMethodByName = function(name) {
var handlers = contentWindow.popupMediator.registeredHandlers;
for(var i = 0; i < handlers.length; i++) {
var handler = handlers[i];
if(handler.name == name)
return handler.callMethod;
}
return null;
};
contentWindow.popupMediator.set_callMethodByName = function(name, value) {
var handlers = contentWindow.popupMediator.registeredHandlers;
for(var i = 0; i < handlers.length; i++) {
var handler = handlers[i];
if(handler.name == name)
handler.callMethod = value;
}
};
contentWindow.popupMediator.getField = function(name) {
var registeredFields = contentWindow.popupMediator.registeredFields;
for(var i = 0; i < registeredFields.length; i++) {
var registeredField = registeredFields[i];
if(registeredField.name == name)
return contentWindow.document.getElementById(registeredField.clientID);
}
return null;
};
contentWindow.Sys = Sys;
for(var i = 0; i < this._registeredHandlers.length; i++)
$find(this._registeredHandlers[i].clientID).activate(contentWindow.document.getElementById(this._registeredHandlers[i].clientID));
if(Sys.Extended.UI.HtmlEditor.isIE) {
popup._doc.onselectstart = function() {
var event = popup._iframe.contentWindow.event;
var tagName = event.srcElement.tagName.toUpperCase();
if(tagName == "INPUT" || tagName == "TEXTAREA")
return true;
return false;
};
} else {
popup._doc.onmousedown = function disableselect(e) {
var tagName = e.target.tagName.toUpperCase();
if(tagName == "INPUT" || tagName == "TEXTAREA" || tagName == "SELECT")
return true;
if(Sys.Extended.UI.HtmlEditor.isSafari)
if(tagName == "TABLE" || tagName == "TR" || tagName == "TD" || tagName == "DIV")
return true;
return false;
};
var aInp = popup._doc.getElementsByTagName('input');
for(var i = 0; i < aInp.length; i++)
aInp[i].setAttribute('autocomplete', 'off')
}
if(this._autoDimensions) {
popup._iframe.style.height = "1000px";
popup._iframe.style.width = "1000px";
setTimeout(function() {
popup._iframe.style.height = popup._doc.body.firstChild.offsetHeight + "px";
popup._iframe.style.width = popup._doc.body.firstChild.offsetWidth + "px";
popup.isLoaded = true;
popup.isLoading = false;
}, 0);
} else {
popup.isLoaded = true;
popup.isLoading = false;
}
},
_onDocumentLoaded: function(callback) {
var popup = this;
if(!this.isLoaded) {
setTimeout(function() {
popup._onDocumentLoaded(callback)
}, 10); // waiting for loading
return;
}
this.isLoaded = true;
callback(this._iframe.contentWindow);
},
initialize: function() {
this.__appLoaded__ = false;
Sys.Extended.UI.HtmlEditor.Popups.Popup.callBaseMethod(this, "initialize");
Sys.Application.add_load(this._app_onload$delegate);
},
dispose: function() {
Sys.Application.remove_load(this._app_onload$delegate);
if(this.isOpened)
this.close();
Sys.Extended.UI.HtmlEditor.Popups.Popup.callBaseMethod(this, "dispose");
},
_app_onload: function(sender, e) {
if(this.__appLoaded__)
return;
this.__appLoaded__ = true;
var element = this.get_element();
if(Sys.Extended.UI.HtmlEditor.isReallyVisible(element)) {
this._parentNode_ = element.parentNode;
this.reload();
}
}
}
Sys.Extended.UI.HtmlEditor.Popups.Popup.registerClass("Sys.Extended.UI.HtmlEditor.Popups.Popup", Sys.UI.Control);

View File

@@ -0,0 +1,10 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.Popups");
Sys.Extended.UI.HtmlEditor.Popups.PopupBGIButton = function(element) {
Sys.Extended.UI.HtmlEditor.Popups.PopupBGIButton.initializeBase(this, [element]);
}
Sys.Extended.UI.HtmlEditor.Popups.PopupBGIButton.prototype = {
}
Sys.Extended.UI.HtmlEditor.Popups.PopupBGIButton.registerClass("Sys.Extended.UI.HtmlEditor.Popups.PopupBGIButton", Sys.Extended.UI.HtmlEditor.Popups.PopupBoxButton);

View File

@@ -0,0 +1,12 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.Popups");
Sys.Extended.UI.HtmlEditor.Popups.PopupBoxButton = function(element) {
Sys.Extended.UI.HtmlEditor.Popups.PopupBoxButton.initializeBase(this, [element]);
this._designPanel = null;
}
Sys.Extended.UI.HtmlEditor.Popups.PopupBoxButton.prototype = {
}
Sys.Extended.UI.HtmlEditor.Popups.PopupBoxButton.registerClass("Sys.Extended.UI.HtmlEditor.Popups.PopupBoxButton", Sys.Extended.UI.HtmlEditor.Popups.PopupCommonButton);

View File

@@ -0,0 +1,195 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.Popups");
Sys.Extended.UI.HtmlEditor.Popups.PopupCommonButton = function(element) {
Sys.Extended.UI.HtmlEditor.Popups.PopupCommonButton.initializeBase(this, [element]);
this._loaded = false;
this._activated = null;
this._app_onload$delegate = Function.createDelegate(this, this._app_onload);
this._cssClass = "";
this._name = "";
this._onmouseover$delegate = Function.createDelegate(this, this._onmouseover);
this._onmouseout$delegate = Function.createDelegate(this, this._onmouseout);
this._onmousedown$delegate = Function.createDelegate(this, this._onmousedown);
this._onmouseup$delegate = Function.createDelegate(this, this._onmouseup);
this._onclick$delegate = Function.createDelegate(this, this._onclick);
}
Sys.Extended.UI.HtmlEditor.Popups.PopupCommonButton.prototype = {
isImage: function() {
return true;
},
set_toolTip: function(value) {
this.get_element().title = value;
},
get_toolTip: function() {
return this.get_element().title;
},
set_name: function(value) {
this._name = value;
},
get_name: function() {
return this._name;
},
initialize: function() {
var element = this.get_element();
Sys.Extended.UI.HtmlEditor.Popups.PopupCommonButton.callBaseMethod(this, "initialize");
Sys.Application.add_load(this._app_onload$delegate);
this._cssClass = element.className.split(" ")[0];
if(this.isImage()) {
$addHandlers(element, {
mouseover: this._onmouseover$delegate,
mouseout: this._onmouseout$delegate,
mousedown: this._onmousedown$delegate,
mouseup: this._onmouseup$delegate,
click: this._onclick$delegate
});
}
if(Sys.Extended.UI.HtmlEditor.isIE) {
function diveSelectable(el) {
if(el.nodeType == 1 && el.tagName) {
var tag = el.tagName.toUpperCase();
if(tag != "INPUT" && tag != "TEXTAREA" && tag != "IFRAME")
el.unselectable = "on";
for(var k = 0; k < el.childNodes.length; k++)
diveSelectable(el.childNodes.item(k));
}
}
diveSelectable(element);
} else {
try {
element.style.MozUserSelect = "none";
element.parentNode.style.MozUserSelect = "none";
} catch(ex) { }
}
},
activate: function(element) {
this._activated = element;
if(this.isImage()) {
Sys.Extended.UI.HtmlEditor._addEvent(this._activated, "mouseover", this._onmouseover$delegate);
Sys.Extended.UI.HtmlEditor._addEvent(this._activated, "mouseout", this._onmouseout$delegate);
Sys.Extended.UI.HtmlEditor._addEvent(this._activated, "mousedown", this._onmousedown$delegate);
Sys.Extended.UI.HtmlEditor._addEvent(this._activated, "mouseup", this._onmouseup$delegate);
Sys.Extended.UI.HtmlEditor._addEvent(this._activated, "click", this._onclick$delegate);
}
},
dispose: function() {
if(this.isImage() && this._activated != null) {
Sys.Extended.UI.HtmlEditor._removeEvent(this._activated, "mouseover", this._onmouseover$delegate);
Sys.Extended.UI.HtmlEditor._removeEvent(this._activated, "mouseout", this._onmouseout$delegate);
Sys.Extended.UI.HtmlEditor._removeEvent(this._activated, "mousedown", this._onmousedown$delegate);
Sys.Extended.UI.HtmlEditor._removeEvent(this._activated, "mouseup", this._onmouseup$delegate);
Sys.Extended.UI.HtmlEditor._removeEvent(this._activated, "click", this._onclick$delegate);
}
this._activated = null;
this._loaded = false;
Sys.Application.remove_load(this._app_onload$delegate);
Sys.Extended.UI.HtmlEditor.Popups.PopupCommonButton.callBaseMethod(this, "dispose");
},
_app_onload: function(sender, e) {
if(this._loaded)
return;
this.onButtonLoaded();
this._loaded = true;
},
onButtonLoaded: function() {
},
_onmouseover: function(e) {
if(!this.isEnable())
return false;
Sys.UI.DomElement.addCssClass(this._activated, this._cssClass + "_hover");
return true;
},
_onmouseout: function(e) {
if(!this.isEnable())
return false;
var _target1 = e.toElement || e.relatedTarget;
try {
while(_target1 && typeof _target1 != "undefined")
if(_target1 == this._activated)
break;
else
_target1 = _target1.parentNode;
} catch(e) {
_target1 = null;
}
if(_target1 != null)
return true;
Sys.UI.DomElement.removeCssClass(this._activated, this._cssClass + "_hover");
Sys.UI.DomElement.removeCssClass(this._activated, this._cssClass + "_mousedown");
return true;
},
_onmousedown: function(e) {
if(!this.isEnable())
return null;
Sys.UI.DomElement.addCssClass(this._activated, this._cssClass + "_mousedown");
return false;
},
_onmouseup: function(e) {
if(!this.isEnable())
return false;
Sys.UI.DomElement.removeCssClass(this._activated, this._cssClass + "_mousedown");
return true;
},
_onclick: function(e) {
if(!this.isEnable())
return false;
this.callMethod(e);
return true;
},
callMethod: function(e) {
var doc = this._activated.ownerDocument || this._activated.document || target,
contWin = doc.defaultView || doc.parentWindow,
method = contWin.popupMediator.get_callMethodByName(this._name);
Function.createDelegate(this, method)(contWin);
},
isEnable: function() {
if(!this._loaded)
return false;
return true;
}
}
Sys.Extended.UI.HtmlEditor.Popups.PopupCommonButton.registerClass("Sys.Extended.UI.HtmlEditor.Popups.PopupCommonButton", Sys.UI.Control);

View File

@@ -0,0 +1,98 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor");
Sys.Extended.UI.HtmlEditor.PreviewPanel = function(element) {
Sys.Extended.UI.HtmlEditor.PreviewPanel.initializeBase(this, [element]);
this._focus$delegate = Function.createDelegate(this, this._focus_event);
this._blur$delegate = Function.createDelegate(this, this._blur_event);
this._doc = null;
this._content = "";
this._panel_timer = null;
}
Sys.Extended.UI.HtmlEditor.PreviewPanel.prototype = {
_focus: function() {
try { // some browsers fail when invisible
this.get_element().contentWindow.focus();
} catch(e) { }
this._focused();
},
_focus_event: function() {
if(this._panel_timer == null) {
var contentWindow = this.get_element().contentWindow;
var panel = this;
this._really_focused();
this._panel_timer = setTimeout(function() { contentWindow.focus(); panel._really_focused(); panel._panel_timer = null; }, 0);
}
return true;
},
_blur_event: function() {
if(this._panel_timer != null) {
clearTimeout(this._panel_timer);
this._panel_timer = null;
}
return true;
},
_activate: function(value) {
Sys.Extended.UI.HtmlEditor.PreviewPanel.callBaseMethod(this, "_activate");
this._content = value;
this._wasFocused = false;
this._initIframe(value);
Sys.Extended.UI.HtmlEditor._addEvents(this.get_element().contentWindow, ["focus"], this._focus$delegate);
Sys.Extended.UI.HtmlEditor._addEvents(this.get_element().contentWindow, ["blur"], this._blur$delegate);
this._activateFinished();
},
_deactivate: function() {
Sys.Extended.UI.HtmlEditor._removeEvents(this.get_element().contentWindow, ["blur"], this._blur$delegate);
Sys.Extended.UI.HtmlEditor._removeEvents(this.get_element().contentWindow, ["focus"], this._focus$delegate);
if(Sys.Extended.UI.HtmlEditor.isIE) {
try { // if src changed (with link in document) - security exception can occur in IE
this._doc.open();
this._doc.write("");
this._doc.close();
this.get_element().src = "javascript:false;";
} catch(ex) { }
}
this._doc = null;
this._content = "";
Sys.Extended.UI.HtmlEditor.PreviewPanel.callBaseMethod(this, "_deactivate");
},
_initIframe: function(value) {
var str = Sys.Extended.UI.HtmlEditor.Trim(value);
this._doc = this.get_element().contentWindow.document;
if(Sys.Extended.UI.HtmlEditor.isIE)
str = str.replace(/&amp;/ig, "&");
this._doc.open();
this._doc.write("<html><head><link rel=\"stylesheet\" href=\"" + this._editPanel.get_documentCssPath() + "\" media=\"all\" /></head><body>" + str + "</body></html>");
this._doc.close();
},
_getContent: function() {
return this._content;
},
_setContent: function(value) {
this._content = value;
this._initIframe(value);
}
}
Sys.Extended.UI.HtmlEditor.PreviewPanel.registerClass("Sys.Extended.UI.HtmlEditor.PreviewPanel", Sys.Extended.UI.HtmlEditor.ModePanel);

View File

@@ -0,0 +1,98 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor");
Sys.Extended.UI.HtmlEditor.Toolbar = function(element) {
Sys.Extended.UI.HtmlEditor.Toolbar.initializeBase(this, [element]);
this._loaded = false;
this._cachedButtonIds = null;
this._cachedEditPanel = null;
this._buttons = null;
this._alwaysVisible = false;
this._app_onload$delegate = Function.createDelegate(this, this._app_onload);
}
Sys.Extended.UI.HtmlEditor.Toolbar.prototype = {
get_alwaysVisible: function() {
return this._alwaysVisible;
},
set_alwaysVisible: function(value) {
this._alwaysVisible = value;
if(this.get_isInitialized())
this.raisePropertyChanged("alwaysVisible");
},
set_activeEditPanel: function(value) {
if(!this._loaded) {
this._cachedEditPanel = value;
return;
}
for(var i = 0; i < this.get_buttons().length; i++)
this.get_buttons()[i].set_activeEditPanel(value);
},
disable: function() {
if(this.get_isInitialized()) {
if(this._alwaysVisible)
return;
for(var i = 0; i < this.get_buttons().length; i++)
this.get_buttons()[i].set_activeEditPanel(null);
}
},
get_buttons: function() {
if(this._buttons == null)
this._buttons = [];
return this._buttons;
},
set_buttons: function(value) {
this.get_buttons().push(value);
},
get_buttonIds: function() {
},
set_buttonIds: function(value) {
if(!this.get_isInitialized()) {
this._cachedButtonIds = value;
return;
}
var arr = value.split(";");
for(var i = 0; i < arr.length; i++)
if(arr[i].length > 0)
this.set_buttons($find(arr[i]));
},
initialize: function() {
Sys.Extended.UI.HtmlEditor.Toolbar.callBaseMethod(this, "initialize");
Sys.Application.add_load(this._app_onload$delegate);
},
dispose: function() {
this._loaded = false;
Sys.Application.remove_load(this._app_onload$delegate);
Sys.Extended.UI.HtmlEditor.Toolbar.callBaseMethod(this, "dispose");
},
_app_onload: function(sender, e) {
if(this._cachedButtonIds != null) {
this.set_buttonIds(this._cachedButtonIds);
this._cachedButtonIds = null;
}
this._loaded = true;
if(this._cachedEditPanel != null) {
this.set_activeEditPanel(this._cachedEditPanel);
this._cachedEditPanel = null;
}
}
}
Sys.Extended.UI.HtmlEditor.Toolbar.registerClass("Sys.Extended.UI.HtmlEditor.Toolbar", Sys.UI.Control);

View File

@@ -0,0 +1,17 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.ToolbarButtons");
Sys.Extended.UI.HtmlEditor.ToolbarButtons.BackColorClear = function(element) {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.BackColorClear.initializeBase(this, [element]);
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.BackColorClear.prototype = {
callMethod: function() {
if(!Sys.Extended.UI.HtmlEditor.ToolbarButtons.BackColorClear.callBaseMethod(this, "callMethod"))
return false;
this._designPanel._execCommand("backcolor", false, "");
}
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.BackColorClear.registerClass("Sys.Extended.UI.HtmlEditor.ToolbarButtons.BackColorClear", Sys.Extended.UI.HtmlEditor.ToolbarButtons.MethodButton);

View File

@@ -0,0 +1,20 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.ToolbarButtons");
Sys.Extended.UI.HtmlEditor.ToolbarButtons.BackColorSelector = function(element) {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.BackColorSelector.initializeBase(this, [element]);
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.BackColorSelector.prototype = {
callMethod: function() {
if(!Sys.Extended.UI.HtmlEditor.ToolbarButtons.BackColorSelector.callBaseMethod(this, "callMethod"))
return false;
},
setColor: function(color) {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.BackColorSelector.callBaseMethod(this, "setColor", [color]);
this._designPanel._execCommand("backcolor", false, color);
}
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.BackColorSelector.registerClass("Sys.Extended.UI.HtmlEditor.ToolbarButtons.BackColorSelector", Sys.Extended.UI.HtmlEditor.ToolbarButtons.ColorSelector);

View File

@@ -0,0 +1,24 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.ToolbarButtons");
Sys.Extended.UI.HtmlEditor.ToolbarButtons.Bold = function(element) {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.Bold.initializeBase(this, [element]);
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.Bold.prototype = {
callMethod: function() {
if(!Sys.Extended.UI.HtmlEditor.ToolbarButtons.Bold.callBaseMethod(this, "callMethod"))
return false;
this._designPanel._execCommand("bold", false, null);
},
checkState: function() {
if(!Sys.Extended.UI.HtmlEditor.ToolbarButtons.Bold.callBaseMethod(this, "checkState"))
return false;
return this._designPanel._queryCommandState("bold");
}
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.Bold.registerClass("Sys.Extended.UI.HtmlEditor.ToolbarButtons.Bold", Sys.Extended.UI.HtmlEditor.ToolbarButtons.EditorToggleButton);

View File

@@ -0,0 +1,14 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.ToolbarButtons");
Sys.Extended.UI.HtmlEditor.ToolbarButtons.BoxButton = function(element) {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.BoxButton.initializeBase(this, [element]);
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.BoxButton.prototype = {
initialize: function() {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.BoxButton.callBaseMethod(this, "initialize");
}
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.BoxButton.registerClass("Sys.Extended.UI.HtmlEditor.ToolbarButtons.BoxButton", Sys.Extended.UI.HtmlEditor.ToolbarButtons.CommonButton);

View File

@@ -0,0 +1,17 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.ToolbarButtons");
Sys.Extended.UI.HtmlEditor.ToolbarButtons.BulletedList = function(element) {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.BulletedList.initializeBase(this, [element]);
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.BulletedList.prototype = {
callMethod: function() {
if(!Sys.Extended.UI.HtmlEditor.ToolbarButtons.BulletedList.callBaseMethod(this, "callMethod"))
return false;
this._designPanel._execCommand("InsertUnorderedList");
}
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.BulletedList.registerClass("Sys.Extended.UI.HtmlEditor.ToolbarButtons.BulletedList", Sys.Extended.UI.HtmlEditor.ToolbarButtons.MethodButton);

View File

@@ -0,0 +1,27 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.ToolbarButtons");
Sys.Extended.UI.HtmlEditor.ToolbarButtons.ColorButton = function(element) {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.ColorButton.initializeBase(this, [element]);
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.ColorButton.prototype = {
callMethod: function() {
if(!Sys.Extended.UI.HtmlEditor.ToolbarButtons.ColorButton.callBaseMethod(this, "callMethod"))
return false;
this.openPopup(Function.createDelegate(this, this._onopened));
return true;
},
_onopened: function(contentWindow) {
contentWindow.setColor = Function.createDelegate(this, this.setColor);
},
setColor: function(color) {
this.closePopup();
}
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.ColorButton.registerClass("Sys.Extended.UI.HtmlEditor.ToolbarButtons.ColorButton", Sys.Extended.UI.HtmlEditor.ToolbarButtons.DesignModePopupImageButton);

View File

@@ -0,0 +1,39 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.ToolbarButtons");
Sys.Extended.UI.HtmlEditor.ToolbarButtons.ColorSelector = function(element) {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.ColorSelector.initializeBase(this, [element]);
this._fixedColorButton = null;
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.ColorSelector.prototype = {
get_fixedColorButton: function() {
return this._fixedColorButton;
},
set_fixedColorButton: function(value) {
this._fixedColorButton = value;
},
callMethod: function() {
if(!Sys.Extended.UI.HtmlEditor.ToolbarButtons.ColorSelector.callBaseMethod(this, "callMethod"))
return false;
this.openPopup(Function.createDelegate(this, this._onopened));
return true;
},
_onopened: function(contentWindow) {
contentWindow.setColor = Function.createDelegate(this, this.setColor);
},
setColor: function(color) {
this.closePopup();
if(this._fixedColorButton != null)
this._fixedColorButton.set_defaultColor(color);
}
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.ColorSelector.registerClass("Sys.Extended.UI.HtmlEditor.ToolbarButtons.ColorSelector", Sys.Extended.UI.HtmlEditor.ToolbarButtons.Selector);

View File

@@ -0,0 +1,285 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.ToolbarButtons");
Sys.Extended.UI.HtmlEditor.ToolbarButtons.CommonButton = function(element) {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.CommonButton.initializeBase(this, [element]);
this._loaded = false;
this._preservePlace = false;
this._editPanel = null;
this._activeModes = null;
this._app_onload$delegate = Function.createDelegate(this, this._app_onload);
this._cssClass = "";
this._onmouseover$delegate = Function.createDelegate(this, this._onmouseover);
this._onmouseout$delegate = Function.createDelegate(this, this._onmouseout);
this._onmousedown$delegate = Function.createDelegate(this, this._onmousedown);
this._onmouseup$delegate = Function.createDelegate(this, this._onmouseup);
this._onclick$delegate = Function.createDelegate(this, this._onclick);
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.CommonButton.prototype = {
get_preservePlace: function() {
return this._preservePlace;
},
set_preservePlace: function(value) {
this._preservePlace = value;
},
set_activeEditPanel: function(value) {
this._editPanel = value;
if(this._editPanel == null) {
this.hideButton();
} else {
if(this.isAllowedActiveMode(this._editPanel.get_activeMode()) && this.canBeShown()) {
this.showButton();
this.onEditPanelActivity();
} else {
this.hideButton();
}
}
},
isImage: function() {
return true;
},
checkRangeInDesign: function() {
if(typeof this._designPanel == "undefined")
return false;
if(this._designPanel == null)
return false;
if(this._designPanel.isPopup())
return false;
var parent = Sys.Extended.UI.HtmlEditor.getSelParent(this._designPanel);
if(parent.nodeType == 3)
parent = parent.parentNode;
return (parent.ownerDocument == this._designPanel._doc);
},
get_buttonName: function() {
var name = Object.getType(this).getName();
name = name.substring(name.lastIndexOf(".") + 1);
return name;
},
get_message: function(messageName) {
var expression = "Sys.Extended.UI.Resources.HtmlEditor_toolbar_button_" + this.get_buttonName() + "_message_" + messageName;
return eval(expression);
},
isDisplayed: function() {
var element = this.get_element();
if(element) {
var style = element.style;
return (style.display != "none" && style.visibility != "hidden");
} else {
return false;
}
},
hideButton: function() {
var element = this.get_element();
if(element) {
if(!this._preservePlace)
element.style.display = "none";
else
element.style.visibility = "hidden";
}
},
showButton: function() {
var element = this.get_element();
if(element) {
if(element.style.display == "none")
element.style.display = "";
if(this._preservePlace)
element.style.visibility = "visible";
}
},
canBeShown: function() {
return true;
},
onEditPanelActivity: function() {
},
get_activeModes: function() {
if(this._activeModes == null)
this._activeModes = [];
return this._activeModes;
},
set_activeModes: function(value) {
this.get_activeModes().push(value);
},
get_activeModesIds: function() {
},
set_activeModesIds: function(value) {
var arr = value.split(";");
for(var i = 0; i < arr.length; i++)
this.set_activeModes(parseInt(arr[i]));
},
set_toolTip: function(value) {
this.get_element().title = value;
},
get_toolTip: function() {
return this.get_element().title;
},
isAllowedActiveMode: function(value) {
for(var i = 0; i < this.get_activeModes().length; i++)
if(this.get_activeModes()[i] == value)
return true;
return false;
},
initialize: function() {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.CommonButton.callBaseMethod(this, "initialize");
Sys.Application.add_load(this._app_onload$delegate);
var element = this.get_element();
if(this._preservePlace && !this.canBeShown())
element.style.display = "none";
this._cssClass = element.className;
if(this.isImage())
$addHandlers(element, {
mouseover: this._onmouseover$delegate,
mouseout: this._onmouseout$delegate,
mousedown: this._onmousedown$delegate,
mouseup: this._onmouseup$delegate,
click: this._onclick$delegate
});
if(Sys.Extended.UI.HtmlEditor.isIE) {
function diveSelectable(el) {
if(el.nodeType == 1 && el.tagName) {
var tag = el.tagName.toUpperCase();
if(tag != "INPUT" && tag != "TEXTAREA" && tag != "IFRAME")
el.unselectable = "on";
for(var k = 0; k < el.childNodes.length; k++)
diveSelectable(el.childNodes.item(k));
}
}
diveSelectable(element);
} else {
try {
element.style.MozUserSelect = "none";
element.parentNode.style.MozUserSelect = "none";
} catch(ex) { }
}
},
dispose: function() {
if(this.isImage()) {
$common.removeHandlers(this.get_element(), {
mouseover: this._onmouseover$delegate,
mouseout: this._onmouseout$delegate,
mousedown: this._onmousedown$delegate,
mouseup: this._onmouseup$delegate,
click: this._onclick$delegate
});
}
this._loaded = false;
Sys.Application.remove_load(this._app_onload$delegate);
Sys.Extended.UI.HtmlEditor.ToolbarButtons.CommonButton.callBaseMethod(this, "dispose");
},
_app_onload: function(sender, e) {
this.onButtonLoaded();
this._loaded = true;
},
onButtonLoaded: function() {
},
_onmouseover: function(e) {
if(!this.isEnable())
return false;
Sys.UI.DomElement.addCssClass(this.get_element(), this._cssClass + "_hover");
return true;
},
_onmouseout: function(e) {
if(!this.isEnable())
return false;
Sys.UI.DomElement.removeCssClass(this.get_element(), this._cssClass + "_hover");
Sys.UI.DomElement.removeCssClass(this.get_element(), this._cssClass + "_mousedown");
return true;
},
_onmousedown: function(e) {
if(!this.isEnable())
return null;
Sys.UI.DomElement.addCssClass(this.get_element(), this._cssClass + "_mousedown");
return false;
},
_onmouseup: function(e) {
if(!this.isEnable())
return false;
Sys.UI.DomElement.removeCssClass(this.get_element(), this._cssClass + "_mousedown");
return true;
},
_onclick: function(e) {
if(!this.isEnable())
return false;
return true;
},
isEnable: function() {
if(!this._loaded)
return false;
if(this._editPanel == null)
return false;
return true;
},
setActivity: function(value) {
if(value)
Sys.UI.DomElement.addCssClass(this.get_element(), this._cssClass + "_active");
else
Sys.UI.DomElement.removeCssClass(this.get_element(), this._cssClass + "_active");
}
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.CommonButton.registerClass("Sys.Extended.UI.HtmlEditor.ToolbarButtons.CommonButton", Sys.UI.Control);

View File

@@ -0,0 +1,30 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.ToolbarButtons");
Sys.Extended.UI.HtmlEditor.ToolbarButtons.Copy = function(element) {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.Copy.initializeBase(this, [element]);
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.Copy.prototype = {
canBeShown: function() {
return Sys.Extended.UI.HtmlEditor.isIE;
},
callMethod: function() {
if(!Sys.Extended.UI.HtmlEditor.ToolbarButtons.Copy.callBaseMethod(this, "callMethod"))
return false;
var editor = this._designPanel;
if(Sys.Extended.UI.HtmlEditor.isIE) {
editor.openWait();
setTimeout(function() {
editor.isShadowed(); editor._copyCut('c', true); editor.closeWait(); editor._ifShadow();
}, 0)
} else {
editor._copyCut('c', true);
}
}
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.Copy.registerClass("Sys.Extended.UI.HtmlEditor.ToolbarButtons.Copy", Sys.Extended.UI.HtmlEditor.ToolbarButtons.MethodButton);

View File

@@ -0,0 +1,26 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.ToolbarButtons");
Sys.Extended.UI.HtmlEditor.ToolbarButtons.Cut = function(element) {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.Cut.initializeBase(this, [element]);
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.Cut.prototype = {
callMethod: function() {
if(!Sys.Extended.UI.HtmlEditor.ToolbarButtons.Cut.callBaseMethod(this, "callMethod"))
return false;
var editor = this._designPanel;
if(Sys.Extended.UI.HtmlEditor.isIE) {
editor.openWait();
setTimeout(function() {
editor.isShadowed(); editor._copyCut('x', true); editor.closeWait();
}, 0)
} else {
editor._copyCut('x', true);
}
}
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.Cut.registerClass("Sys.Extended.UI.HtmlEditor.ToolbarButtons.Cut", Sys.Extended.UI.HtmlEditor.ToolbarButtons.MethodButton);

View File

@@ -0,0 +1,18 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.ToolbarButtons");
Sys.Extended.UI.HtmlEditor.ToolbarButtons.DecreaseIndent = function(element) {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.DecreaseIndent.initializeBase(this, [element]);
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.DecreaseIndent.prototype = {
callMethod: function() {
if(!Sys.Extended.UI.HtmlEditor.ToolbarButtons.DecreaseIndent.callBaseMethod(this, "callMethod"))
return false;
this._designPanel._execCommand("Outdent");
}
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.DecreaseIndent.registerClass("Sys.Extended.UI.HtmlEditor.ToolbarButtons.DecreaseIndent", Sys.Extended.UI.HtmlEditor.ToolbarButtons.MethodButton);

View File

@@ -0,0 +1,10 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.ToolbarButtons");
Sys.Extended.UI.HtmlEditor.ToolbarButtons.DesignMode = function(element) {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.DesignMode.initializeBase(this, [element]);
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.DesignMode.prototype = {
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.DesignMode.registerClass("Sys.Extended.UI.HtmlEditor.ToolbarButtons.DesignMode", Sys.Extended.UI.HtmlEditor.ToolbarButtons.ModeButton);

View File

@@ -0,0 +1,42 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.ToolbarButtons");
Sys.Extended.UI.HtmlEditor.ToolbarButtons.DesignModeBoxButton = function(element) {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.DesignModeBoxButton.initializeBase(this, [element]);
this._designPanel = null;
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.DesignModeBoxButton.prototype = {
_onmousedown: function(e) {
if(this._designPanel == null)
return false;
if(this._designPanel.isPopup())
return false;
if(Sys.Extended.UI.HtmlEditor.ToolbarButtons.DesignModeBoxButton.callBaseMethod(this, "_onmousedown", [e]) === null)
return false;
this.callMethod();
return false;
},
onEditPanelActivity: function() {
this._designPanel = this._editPanel.get_activePanel();
},
callMethod: function() {
if(this._designPanel == null)
return false;
if(this._designPanel.isPopup())
return false;
return true;
}
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.DesignModeBoxButton.registerClass("Sys.Extended.UI.HtmlEditor.ToolbarButtons.DesignModeBoxButton", Sys.Extended.UI.HtmlEditor.ToolbarButtons.BoxButton);

View File

@@ -0,0 +1,40 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.ToolbarButtons");
Sys.Extended.UI.HtmlEditor.ToolbarButtons.DesignModeImageButton = function(element) {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.DesignModeImageButton.initializeBase(this, [element]);
this._designPanel = null;
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.DesignModeImageButton.prototype = {
_onmousedown: function(e) {
if(this._designPanel == null)
return false;
if(this._designPanel.isPopup())
return false;
if(Sys.Extended.UI.HtmlEditor.ToolbarButtons.DesignModeImageButton.callBaseMethod(this, "_onmousedown", [e]) === null)
return false;
this.callMethod();
return false;
},
onEditPanelActivity: function() {
this._designPanel = this._editPanel.get_activePanel();
},
callMethod: function() {
if(this._designPanel == null)
return false;
if(this._designPanel.isPopup())
return false;
return true;
}
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.DesignModeImageButton.registerClass("Sys.Extended.UI.HtmlEditor.ToolbarButtons.DesignModeImageButton", Sys.Extended.UI.HtmlEditor.ToolbarButtons.ImageButton);

View File

@@ -0,0 +1,179 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.ToolbarButtons");
Sys.Extended.UI.HtmlEditor.ToolbarButtons.DesignModePopupImageButton = function(element) {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.DesignModePopupImageButton.initializeBase(this, [element]);
this._relatedPopup = null;
this._autoClose = true;
this._forclose_onmousedown$delegate = null;
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.DesignModePopupImageButton.prototype = {
set_activeEditPanel: function(value) {
if(this._editPanel != value && this._editPanel != null)
this.closePopup();
Sys.Extended.UI.HtmlEditor.ToolbarButtons.DesignModePopupImageButton.callBaseMethod(this, "set_activeEditPanel", [value]);
},
get_autoClose: function() {
return this._autoClose;
},
set_autoClose: function(value) {
this._autoClose = value;
},
get_relatedPopup: function() {
return this._relatedPopup;
},
set_relatedPopup: function(value) {
this._relatedPopup = value;
},
openPopup: function(callback, top, left) {
if(this._autoClose && this._forclose_onmousedown$delegate != null)
return;
if(this._relatedPopup != null) {
this._bookmark = null;
if(Sys.Extended.UI.HtmlEditor.isIE) {
var sel = this._designPanel._getSelection();
this._selType = sel.type.toLowerCase();
var range = this._designPanel._createRange(sel);
if(this._selType == "text" || this._selType == "none") {
try {
this._bookmark = range.duplicate();
} catch(ex) { }
} else if(this._selType == "control") {
this._bookmark = range.item(0);
range.remove(0);
sel.empty();
}
}
if(typeof this._relatedPopup.set_relatedElement == "function") {
this._relatedPopup.set_relatedElement(this.get_element());
this._forclose_onmousedown$delegate = Function.createDelegate(this, this._forclose_onmousedown);
if(this._autoClose) {
var designWindow = this._designPanel.get_element().contentWindow,
designBody = designWindow.document.body,
button = this;
setTimeout(function() {
if(button._forclose_onmousedown$delegate != null) {
Sys.Extended.UI.HtmlEditor._addEvent(designBody, "mousedown", button._forclose_onmousedown$delegate);
Sys.Extended.UI.HtmlEditor._addEvent(designBody, "keydown", button._forclose_onmousedown$delegate);
Sys.Extended.UI.HtmlEditor._addEvent(document.body, "keydown", button._forclose_onmousedown$delegate);
Sys.Extended.UI.HtmlEditor._addEvent(window, "keydown", button._forclose_onmousedown$delegate);
Sys.Extended.UI.HtmlEditor._addEvent(designWindow, "mousedown", button._forclose_onmousedown$delegate);
Sys.Extended.UI.HtmlEditor._addEvent(document.body, "mousedown", button._forclose_onmousedown$delegate);
if(document.documentElement)
Sys.Extended.UI.HtmlEditor._addEvent(document.documentElement, "mousedown", button._forclose_onmousedown$delegate);
}
}, 0);
}
this._relatedPopup.open(callback);
} else {
this._relatedPopup.open(callback, top, left);
}
}
},
_forclose_onmousedown: function(e) {
if(this._forclose_onmousedown$delegate == null)
return true;
if(this._relatedPopup.isOpened)
this._relatedPopup.close();
else
return true;
if(this._editPanel == Sys.Extended.UI.HtmlEditor.LastFocusedEditPanel) {
try { // for the case if currently the Design panel is invisible
if(this._bookmark) {
if(Sys.Extended.UI.HtmlEditor.isIE) {
var range;
if(this._selType == "control") {
range = this._designPanel._doc.body.createControlRange();
range.add(this._bookmark);
} else {
range = this._bookmark;
}
range.select();
}
this._bookmark = null;
}
if(!Sys.Extended.UI.HtmlEditor.isIE) {
var sel = this._designPanel._getSelection(),
range = this._designPanel._createRange(sel);
this._designPanel._removeAllRanges(sel);
this._designPanel._selectRange(sel, range);
this._designPanel.focusEditor();
}
} catch(ex) { }
}
var button = this;
setTimeout(function() {
if(button._editPanel == Sys.Extended.UI.HtmlEditor.LastFocusedEditPanel)
try {
button._editPanel.updateToolbar();
} catch(ex) { }
}, 0);
if(this._autoClose) {
try {
var designWindow = this._designPanel.get_element().contentWindow,
designBody = designWindow.document.body;
if(document.documentElement)
Sys.Extended.UI.HtmlEditor._removeEvent(document.documentElement, "mousedown", this._forclose_onmousedown$delegate);
Sys.Extended.UI.HtmlEditor._removeEvent(designBody, "keydown", this._forclose_onmousedown$delegate);
Sys.Extended.UI.HtmlEditor._removeEvent(document.body, "keydown", this._forclose_onmousedown$delegate);
Sys.Extended.UI.HtmlEditor._removeEvent(window, "keydown", this._forclose_onmousedown$delegate);
Sys.Extended.UI.HtmlEditor._removeEvent(designBody, "mousedown", this._forclose_onmousedown$delegate);
Sys.Extended.UI.HtmlEditor._removeEvent(designWindow, "mousedown", this._forclose_onmousedown$delegate);
Sys.Extended.UI.HtmlEditor._removeEvent(document.body, "mousedown", this._forclose_onmousedown$delegate);
} catch(ex) { }
}
this._forclose_onmousedown$delegate = null;
if(e && e.type) {
if(e.type == "keydown") {
Sys.Extended.UI.HtmlEditor._stopEvent(e);
return false;
}
}
return true;
},
closePopup: function() {
if(this._forclose_onmousedown$delegate != null)
this._forclose_onmousedown$delegate(null);
},
dispose: function() {
if(this._forclose_onmousedown$delegate != null)
this._forclose_onmousedown$delegate(null);
Sys.Extended.UI.HtmlEditor.ToolbarButtons.DesignModePopupImageButton.callBaseMethod(this, "dispose");
}
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.DesignModePopupImageButton.registerClass("Sys.Extended.UI.HtmlEditor.ToolbarButtons.DesignModePopupImageButton", Sys.Extended.UI.HtmlEditor.ToolbarButtons.MethodButton);

View File

@@ -0,0 +1,36 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.ToolbarButtons");
Sys.Extended.UI.HtmlEditor.ToolbarButtons.DesignModeSelectButton = function(element) {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.DesignModeSelectButton.initializeBase(this, [element]);
this._designPanel = null;
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.DesignModeSelectButton.prototype = {
onEditPanelActivity: function() {
this._designPanel = this._editPanel.get_activePanel();
this.checkState()
},
checkState: function() {
if(!this.checkRangeInDesign())
return false;
return true;
},
callMethod: function(select, e) {
if(!Sys.Extended.UI.HtmlEditor.ToolbarButtons.DesignModeSelectButton.callBaseMethod(this, "callMethod"))
return false;
if(this._designPanel == null)
return false;
if(this._designPanel.isPopup())
return false;
return true;
}
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.DesignModeSelectButton.registerClass("Sys.Extended.UI.HtmlEditor.ToolbarButtons.DesignModeSelectButton", Sys.Extended.UI.HtmlEditor.ToolbarButtons.SelectButton);

View File

@@ -0,0 +1,22 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.ToolbarButtons");
Sys.Extended.UI.HtmlEditor.ToolbarButtons.EditorToggleButton = function(element) {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.EditorToggleButton.initializeBase(this, [element]);
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.EditorToggleButton.prototype = {
onEditPanelActivity: function() {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.EditorToggleButton.callBaseMethod(this, "onEditPanelActivity");
this.setActivity(this.checkState());
},
checkState: function() {
if(!this.checkRangeInDesign())
return false;
return true;
}
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.EditorToggleButton.registerClass("Sys.Extended.UI.HtmlEditor.ToolbarButtons.EditorToggleButton", Sys.Extended.UI.HtmlEditor.ToolbarButtons.DesignModeImageButton);

View File

@@ -0,0 +1,14 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.ToolbarButtons");
Sys.Extended.UI.HtmlEditor.ToolbarButtons.FixedBackColor = function(element) {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.FixedBackColor.initializeBase(this, [element]);
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.FixedBackColor.prototype = {
setColor: function(color) {
this._designPanel._execCommand("backcolor", false, color);
}
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.FixedBackColor.registerClass("Sys.Extended.UI.HtmlEditor.ToolbarButtons.FixedBackColor", Sys.Extended.UI.HtmlEditor.ToolbarButtons.FixedColorButton);

View File

@@ -0,0 +1,61 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.ToolbarButtons");
Sys.Extended.UI.HtmlEditor.ToolbarButtons.FixedColorButton = function(element) {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.FixedColorButton.initializeBase(this, [element]);
this._defaultColor = "#000000";
this._colorDiv = null;
this._methodButton = null;
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.FixedColorButton.prototype = {
get_defaultColor: function() {
return this._defaultColor;
},
set_defaultColor: function(value) {
this._defaultColor = value;
if(this._colorDiv != null)
this._colorDiv.get_element().style.backgroundColor = value;
},
get_colorDiv: function() {
return this._colorDiv;
},
set_colorDiv: function(value) {
this._colorDiv = value;
},
get_methodButton: function() {
return this._methodButton;
},
set_methodButton: function(value) {
this._methodButton = value;
},
callMethod: function() {
if(!Sys.Extended.UI.HtmlEditor.ToolbarButtons.FixedColorButton.callBaseMethod(this, "callMethod"))
return false;
this.setColor(this.get_defaultColor());
},
setColor: function(color) {
},
initialize: function() {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.FixedColorButton.callBaseMethod(this, "initialize");
if(this._methodButton != null)
this._methodButton.callMethod = Function.createDelegate(this, this.callMethod);
if(this._colorDiv != null)
this._colorDiv.callMethod = Function.createDelegate(this, this.callMethod);
}
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.FixedColorButton.registerClass("Sys.Extended.UI.HtmlEditor.ToolbarButtons.FixedColorButton", Sys.Extended.UI.HtmlEditor.ToolbarButtons.DesignModeBoxButton);

View File

@@ -0,0 +1,14 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.ToolbarButtons");
Sys.Extended.UI.HtmlEditor.ToolbarButtons.FixedForeColor = function(element) {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.FixedForeColor.initializeBase(this, [element]);
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.FixedForeColor.prototype = {
setColor: function(color) {
this._designPanel._execCommand("forecolor", false, color);
}
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.FixedForeColor.registerClass("Sys.Extended.UI.HtmlEditor.ToolbarButtons.FixedForeColor", Sys.Extended.UI.HtmlEditor.ToolbarButtons.FixedColorButton);

View File

@@ -0,0 +1,68 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.ToolbarButtons");
Sys.Extended.UI.HtmlEditor.ToolbarButtons.FontName = function(element) {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.FontName.initializeBase(this, [element]);
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.FontName.prototype = {
initialize: function() {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.FontName.callBaseMethod(this, "initialize");
},
callMethod: function(select, event) {
if(!Sys.Extended.UI.HtmlEditor.ToolbarButtons.FontName.callBaseMethod(this, "callMethod"))
return false;
try {
var editor = this._designPanel;
editor._execCommand("fontname", false, select.options.item(select.selectedIndex).value);
} catch(e) { }
},
checkState: function() {
if(!Sys.Extended.UI.HtmlEditor.ToolbarButtons.FontName.callBaseMethod(this, "checkState"))
return false;
var editor = this._designPanel,
param = null;
try {
param = (Function.createDelegate(editor, Sys.Extended.UI.HtmlEditor._queryCommandValue))("fontname");
} catch(e) { }
if(!editor._FontNotSet)
if(!param || param.length == 0)
param = Sys.Extended.UI.HtmlEditor.getStyle(editor._doc.body, "font-family");
var el = this._select,
i = 0;
if(param && param.length > 0) {
var seek = param.toLowerCase().split(",")[0].replace(/^(['"])/, "").replace(/(['"])$/, "");
for(i = 0; i < el.options.length; i++) {
var cur = el.options.item(i).value.toLowerCase().split(",")[0];
if(cur == seek)
break
}
if(i == el.options.length) {
try {
var newopt = document.createElement("OPTION");
newopt.value = param.replace(/^(['"])/, "").replace(/(['"])$/, "");
newopt.text = param.split(",")[0].replace(/^(['"])/, "").replace(/(['"])$/, "");
el.add(newopt, (Sys.Extended.UI.HtmlEditor.isIE) ? i : null);
$addHandler(newopt, "click", this._onclick_option$delegate);
} catch(e) {
i = 0;
}
}
}
el.selectedIndex = i;
}
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.FontName.registerClass("Sys.Extended.UI.HtmlEditor.ToolbarButtons.FontName", Sys.Extended.UI.HtmlEditor.ToolbarButtons.DesignModeSelectButton);

View File

@@ -0,0 +1,78 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.ToolbarButtons");
Sys.Extended.UI.HtmlEditor.ToolbarButtons.FontSize = function(element) {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.FontSize.initializeBase(this, [element]);
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.FontSize.prototype = {
initialize: function() {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.FontSize.callBaseMethod(this, "initialize");
},
callMethod: function(select, event) {
if(!Sys.Extended.UI.HtmlEditor.ToolbarButtons.FontSize.callBaseMethod(this, "callMethod"))
return false;
try {
var editor = this._designPanel;
editor._execCommand("FontSize", false, Sys.Extended.UI.HtmlEditor.fontSizeSeek(select.options.item(select.selectedIndex).value));
} catch(e) { }
},
checkState: function() {
if(!Sys.Extended.UI.HtmlEditor.ToolbarButtons.FontSize.callBaseMethod(this, "checkState"))
return false;
var editor = this._designPanel;
var param = null,
_id = this._select.id;
try {
param = (Function.createDelegate(editor, Sys.Extended.UI.HtmlEditor._queryCommandValue))("fontsize", _id);
} catch(e) { }
if(param)
param = param.toString();
if(!editor._FontNotSet)
if(!param || param.length == 0) {
param = Sys.Extended.UI.HtmlEditor.getStyle(editor._doc.body, "font-size");
param = Sys.Extended.UI.HtmlEditor._TryTransformFromPxToPt(param, this, _id);
}
try {
var el = this._select,
i = 0;
if(param && param.length > 0) {
var seek = param.toLowerCase().split(",")[0];
for(i = 0; i < el.options.length; i++) {
var cur = Sys.Extended.UI.HtmlEditor.fontSizeSeek(el.options.item(i).value.toLowerCase().split(",")[0]);
if(cur == seek)
break;
}
if(i == el.options.length) {
try {
var newopt = document.createElement("OPTION");
newopt.value = param;
newopt.text = param;
el.add(newopt, (Sys.Extended.UI.HtmlEditor.isIE) ? i : null);
$addHandler(newopt, "click", this._onclick_option$delegate);
} catch(e) {
i = 0;
}
}
}
el.selectedIndex = i;
} catch(e) { }
}
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.FontSize.registerClass("Sys.Extended.UI.HtmlEditor.ToolbarButtons.FontSize", Sys.Extended.UI.HtmlEditor.ToolbarButtons.DesignModeSelectButton);

View File

@@ -0,0 +1,20 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.ToolbarButtons");
Sys.Extended.UI.HtmlEditor.ToolbarButtons.ForeColor = function(element) {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.ForeColor.initializeBase(this, [element]);
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.ForeColor.prototype = {
callMethod: function() {
if(!Sys.Extended.UI.HtmlEditor.ToolbarButtons.ForeColor.callBaseMethod(this, "callMethod"))
return false;
},
setColor: function(color) {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.ForeColor.callBaseMethod(this, "setColor", [color]);
this._designPanel._execCommand("forecolor", false, color);
}
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.ForeColor.registerClass("Sys.Extended.UI.HtmlEditor.ToolbarButtons.ForeColor", Sys.Extended.UI.HtmlEditor.ToolbarButtons.ColorButton);

View File

@@ -0,0 +1,17 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.ToolbarButtons");
Sys.Extended.UI.HtmlEditor.ToolbarButtons.ForeColorClear = function(element) {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.ForeColorClear.initializeBase(this, [element]);
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.ForeColorClear.prototype = {
callMethod: function() {
if(!Sys.Extended.UI.HtmlEditor.ToolbarButtons.ForeColorClear.callBaseMethod(this, "callMethod"))
return false;
this._designPanel._execCommand("forecolor", false, "");
}
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.ForeColorClear.registerClass("Sys.Extended.UI.HtmlEditor.ToolbarButtons.ForeColorClear", Sys.Extended.UI.HtmlEditor.ToolbarButtons.MethodButton);

View File

@@ -0,0 +1,20 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.ToolbarButtons");
Sys.Extended.UI.HtmlEditor.ToolbarButtons.ForeColorSelector = function(element) {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.ForeColorSelector.initializeBase(this, [element]);
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.ForeColorSelector.prototype = {
callMethod: function() {
if(!Sys.Extended.UI.HtmlEditor.ToolbarButtons.ForeColorSelector.callBaseMethod(this, "callMethod"))
return false;
},
setColor: function(color) {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.ForeColorSelector.callBaseMethod(this, "setColor", [color]);
this._designPanel._execCommand("forecolor", false, color);
}
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.ForeColorSelector.registerClass("Sys.Extended.UI.HtmlEditor.ToolbarButtons.ForeColorSelector", Sys.Extended.UI.HtmlEditor.ToolbarButtons.ColorSelector);

View File

@@ -0,0 +1,14 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.ToolbarButtons");
Sys.Extended.UI.HtmlEditor.ToolbarButtons.HorizontalSeparator = function(element) {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.HorizontalSeparator.initializeBase(this, [element]);
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.HorizontalSeparator.prototype = {
isImage: function() {
return false;
}
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.HorizontalSeparator.registerClass("Sys.Extended.UI.HtmlEditor.ToolbarButtons.HorizontalSeparator", Sys.Extended.UI.HtmlEditor.ToolbarButtons.DesignModeImageButton);

View File

@@ -0,0 +1,11 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.ToolbarButtons");
Sys.Extended.UI.HtmlEditor.ToolbarButtons.HtmlMode = function(element) {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.HtmlMode.initializeBase(this, [element]);
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.HtmlMode.prototype = {
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.HtmlMode.registerClass("Sys.Extended.UI.HtmlEditor.ToolbarButtons.HtmlMode", Sys.Extended.UI.HtmlEditor.ToolbarButtons.ModeButton);

View File

@@ -0,0 +1,147 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.ToolbarButtons");
Sys.Extended.UI.HtmlEditor.ToolbarButtons.ImageButton = function(element) {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.ImageButton.initializeBase(this, [element]);
this._normalSrc = "";
this._hoverSrc = "";
this._downSrc = "";
this._activeSrc = "";
this._downTimer = null;
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.ImageButton.prototype = {
get_normalSrc: function() {
return this._normalSrc;
},
set_normalSrc: function(value) {
this._normalSrc = value;
var element = this.get_element();
if(/none$/.test(element.src))
element.src = value;
},
get_hoverSrc: function() {
return this._hoverSrc;
},
set_hoverSrc: function(value) {
this._hoverSrc = value;
},
get_downSrc: function() {
return this._downSrc;
},
set_downSrc: function(value) {
this._downSrc = value;
},
get_activeSrc: function() {
return this._activeSrc;
},
set_activeSrc: function(value) {
this._activeSrc = value;
},
isImage: function() {
return true;
},
_onmouseover: function(e) {
if(!Sys.Extended.UI.HtmlEditor.ToolbarButtons.ImageButton.callBaseMethod(this, "_onmouseover"))
return false;
if(this._hoverSrc.length > 0)
this.get_element().src = this._hoverSrc;
return true;
},
_onmouseout: function(e) {
var node = this.get_element();
if(!Sys.Extended.UI.HtmlEditor.ToolbarButtons.ImageButton.callBaseMethod(this, "_onmouseout"))
return false;
if(this._hoverSrc.length > 0) {
if(Sys.UI.DomElement.containsCssClass(node, this._cssClass + "_mousedown") && this._downSrc.length > 0) {
node.src = this._downSrc;
} else {
if(Sys.UI.DomElement.containsCssClass(node, this._cssClass + "_active") && this._activeSrc.length > 0)
node.src = this._activeSrc;
else
node.src = this._normalSrc;
}
}
return true;
},
_onmousedown: function(e) {
if(Sys.Extended.UI.HtmlEditor.ToolbarButtons.ImageButton.callBaseMethod(this, "_onmousedown") === null)
return null;
if(this._downSrc.length > 0) {
this.get_element().src = this._downSrc;
this._downTimer = setTimeout(Function.createDelegate(this, this._onmouseup), 1000); // one second delay
}
return true;
},
_onmouseup: function(e) {
var node = this.get_element();
if(!Sys.Extended.UI.HtmlEditor.ToolbarButtons.ImageButton.callBaseMethod(this, "_onmouseup"))
return false;
if(this._downSrc.length > 0) {
if(Sys.UI.DomElement.containsCssClass(node, this._cssClass + "_hover") && this._hoverSrc.length > 0) {
node.src = this._hoverSrc;
} else {
if(Sys.UI.DomElement.containsCssClass(node, this._cssClass + "_active") && this._activeSrc.length > 0)
node.src = this._activeSrc;
else
node.src = this._normalSrc;
}
if(this._downTimer != null) {
clearTimeout(this._downTimer);
this._downTimer = null;
}
}
return true;
},
setActivity: function(value) {
var node = this.get_element();
if(this._activeSrc.length > 0) {
if(value) {
if(!Sys.UI.DomElement.containsCssClass(node, this._cssClass + "_active"))
node.src = this._activeSrc;
} else {
if(Sys.UI.DomElement.containsCssClass(node, this._cssClass + "_active")) {
if(Sys.UI.DomElement.containsCssClass(node, this._cssClass + "_mousedown") && this._downSrc.length > 0) {
node.src = this._downSrc;
} else {
if(Sys.UI.DomElement.containsCssClass(node, this._cssClass + "_hover") && this._hoverSrc.length > 0)
node.src = this._hoverSrc;
else
node.src = this._normalSrc;
}
}
}
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.ImageButton.callBaseMethod(this, "setActivity", [value]);
}
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.ImageButton.registerClass("Sys.Extended.UI.HtmlEditor.ToolbarButtons.ImageButton", Sys.Extended.UI.HtmlEditor.ToolbarButtons.CommonButton);

View File

@@ -0,0 +1,16 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.ToolbarButtons");
Sys.Extended.UI.HtmlEditor.ToolbarButtons.IncreaseIndent = function(element) {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.IncreaseIndent.initializeBase(this, [element]);
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.IncreaseIndent.prototype = {
callMethod: function() {
if(!Sys.Extended.UI.HtmlEditor.ToolbarButtons.IncreaseIndent.callBaseMethod(this, "callMethod"))
return false;
this._designPanel._execCommand("Indent");
}
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.IncreaseIndent.registerClass("Sys.Extended.UI.HtmlEditor.ToolbarButtons.IncreaseIndent", Sys.Extended.UI.HtmlEditor.ToolbarButtons.MethodButton);

View File

@@ -0,0 +1,46 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.ToolbarButtons");
Sys.Extended.UI.HtmlEditor.ToolbarButtons.InsertHR = function(element) {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.InsertHR.initializeBase(this, [element]);
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.InsertHR.prototype = {
callMethod: function() {
if(!Sys.Extended.UI.HtmlEditor.ToolbarButtons.InsertHR.callBaseMethod(this, "callMethod"))
return false;
var editor = this._designPanel;
try {
editor._saveContent();
var _div = editor._doc.createElement("div");
_div.innerHTML = "<hr>";
var el = _div.firstChild,
place = editor._getSafePlace();
if(!place)
return;
var parent = place.parentNode;
parent.insertBefore(el, place);
parent.removeChild(place);
el = (el.nextSibling) ? el.nextSibling : el;
Sys.Extended.UI.HtmlEditor._setCursor(el, editor);
setTimeout(function() {
editor.onContentChanged(); editor._editPanel.updateToolbar();
}, 0);
editor.focusEditor();
return true;
} catch(e) { }
}
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.InsertHR.registerClass("Sys.Extended.UI.HtmlEditor.ToolbarButtons.InsertHR", Sys.Extended.UI.HtmlEditor.ToolbarButtons.MethodButton);

View File

@@ -0,0 +1,308 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.ToolbarButtons");
Sys.Extended.UI.HtmlEditor.ToolbarButtons.InsertLink = function(element) {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.InsertLink.initializeBase(this, [element]);
this._emptySrc = window.location.href.replace(/(http[s]*\:\/\/)[^\u0000]*/i, "$1");
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.InsertLink.prototype = {
callMethod: function() {
var editor = this._designPanel,
sel = editor._getSelection(),
range = editor._createRange(sel),
parent = Sys.Extended.UI.HtmlEditor.getSelParent(editor);
if(parent.nodeType == 3)
parent = parent.parentNode;
while(parent && Sys.Extended.UI.HtmlEditor.isStyleTag(parent.tagName) && parent.tagName.toUpperCase() != "A")
parent = parent.parentNode;
if(parent && parent.tagName.toUpperCase() == "A") {
this._edit = true;
this._editLink(parent);
} else {
this._edit = false;
if(!this._createLink())
return false;
}
if(!Sys.Extended.UI.HtmlEditor.ToolbarButtons.InsertLink.callBaseMethod(this, "callMethod"))
return false;
return true;
},
opened: function(contentWindow) {
this._preparePopup(contentWindow);
},
ok: function(contentWindow) {
var targetField = contentWindow.popupMediator.getField("target");
if(targetField != null)
this._obj.target = targetField.value;
var urlField = contentWindow.popupMediator.getField("url");
if(urlField != null)
this._obj.href = urlField.value;
if(/^javascript:/.test(this._obj.href)) {
this._obj.target = null;
try {
this._obj.removeAttribute("target");
} catch(e) { }
} else {
var targetField = contentWindow.popupMediator.getField("target");
if(targetField != null)
this._obj.target = targetField.value;
}
if(this._edit) {
this._edit_callback(true);
} else {
this._create_callback(true);
}
},
cancel: function(contentWindow) {
if(this._edit)
this._edit_callback(false);
else
this._create_callback(false);
},
_createLink: function() {
var editor = this._designPanel,
selectedHTML = (!Sys.Extended.UI.HtmlEditor.isIE) ? Sys.Extended.UI.HtmlEditor.Trim(editor.getSelectedHTML()) : "",
sel = editor._getSelection(),
range = editor._createRange(sel);
this._txt = null;
if(!(editor.isControl() && Sys.Extended.UI.HtmlEditor.getSelParent(editor).tagName && (Sys.Extended.UI.HtmlEditor.getSelParent(editor).tagName.toUpperCase() == "EMBED" || Sys.Extended.UI.HtmlEditor.getSelParent(editor).tagName.toUpperCase() == "IMG")) &&
!(!editor.isControl() && ((Sys.Extended.UI.HtmlEditor.isIE && range.text.length > 0) || (!Sys.Extended.UI.HtmlEditor.isIE && selectedHTML.length > 0)))) {
editor._saveContent();
var _span = editor._doc.createElement("span");
_span.innerHTML = "new link";
_span.id = Sys.Extended.UI.HtmlEditor.smartClassName;
var needSelect = true;
if(Sys.Extended.UI.HtmlEditor.isIE && editor.isControl()) {
var control = range.item(0);
var _span1 = editor._doc.createElement("span");
control.parentNode.insertBefore(_span1, control);
this._txt = _span.firstChild;
control.parentNode.insertBefore(this._txt, control);
var _span2 = editor._doc.createElement("span");
control.parentNode.insertBefore(_span2, control);
control.parentNode.removeChild(control);
editor.setSelectionAfterOperation([_span1, _span2], false);
needSelect = false;
} else {
editor.insertHTML(Sys.Extended.UI.HtmlEditor.getHTML(_span, true));
var el = editor._doc.getElementById(Sys.Extended.UI.HtmlEditor.smartClassName);
this._txt = el.firstChild;
el.parentNode.insertBefore(el.firstChild, el);
el.parentNode.removeChild(el);
}
if(!Sys.Extended.UI.HtmlEditor.isIE) {
range = editor._createRange();
range.setStart(this._txt, 0);
range.setEnd(this._txt, ("" + this._txt.data + "").length);
editor._removeAllRanges(sel);
editor._selectRange(sel, range);
} else {
if(needSelect)
range.select();
}
selectedHTML = (!Sys.Extended.UI.HtmlEditor.isIE) ? Sys.Extended.UI.HtmlEditor.Trim(editor.getSelectedHTML()) : "";
sel = editor._getSelection();
range = editor._createRange(sel);
}
if((editor.isControl() && Sys.Extended.UI.HtmlEditor.getSelParent(editor).tagName.toUpperCase() == "IMG") ||
(!editor.isControl() && ((Sys.Extended.UI.HtmlEditor.isIE && range.text.length > 0) || (!Sys.Extended.UI.HtmlEditor.isIE && selectedHTML.length > 0)))) {
editor._saveContent();
this._obj = { target: "default", href: this._emptySrc, title: "" };
var temp = editor._doc.getElementsByTagName("A");
var aList = [];
for(var i = 0; i < temp.length; i++)
aList.push([temp[i], "" + temp[i].href + ""]);
editor._execCommand("createLink", false, this._emptySrc);
this._oldList = [];
for(var i = 0; i < aList.length; i++) {
var a = aList[i][0];
var href = aList[i][1];
if(a.href == href)
this._oldList.push(a);
}
} else {
if(this._txt) {
editor._undo(false);
editor.__stack.pop();
}
return false;
}
return true;
},
_editLink: function(link) {
var editor = this._designPanel;
this._obj = link;
editor._saveContent();
},
_preparePopup: function(contentWindow) {
if(this._obj.target && this._obj.target.length > 0 && this._obj.target == "default")
this._obj.target = this.get_relatedPopup().get_defaultTarget();
var targetField = contentWindow.popupMediator.getField("target");
if(targetField != null)
targetField.value = (this._obj.target && this._obj.target.length > 0 && this._obj.target.substr(0, 1) == "_") ? this._obj.target.toLowerCase() : "_self";
var urlField = contentWindow.popupMediator.getField("url");
if(urlField != null) {
if(this._edit)
urlField.value = Sys.Extended.UI.HtmlEditor.getRealAttribute(this._obj, "href");
else
urlField.value = this._obj.href;
if(urlField.value.length == 0)
urlField.value = this._emptySrc;
urlField.value = urlField.value.replace(/\&quot;/g, "\"");
setTimeout(function() {
Sys.Extended.UI.HtmlEditor.setSelectionRange(urlField, 0, urlField.value.length);
}, 0);
}
},
_edit_callback: function(ok) {
var editor = this._designPanel;
try {
if(!ok) {
editor._undo(false);
} else {
if(this._obj.title.length == 0) {
this._obj.title = null;
this._obj.removeAttribute("title");
}
editor.onContentChanged();
}
} catch(ex) { }
return true;
},
okCheck: function(contentWindow) {
var urlField = contentWindow.popupMediator.getField("url");
if(urlField != null) {
var url = urlField.value;
if(url == "" || (url.length >= 3 && url.substr(url.length - 3, 3) == "://")) {
contentWindow.alert(this.get_message("EmptyURL"));
contentWindow.setTimeout(function() { try { urlField.focus(); } catch(e) { } }, 0);
return false;
}
return true;
}
return false;
},
_create_callback: function(ok) {
var editor = this._designPanel;
try {
if(ok) {
var aList = editor._doc.getElementsByTagName("A"),
aNumber = 0;
for(var i = 0; i < aList.length; i++) {
var good = true,
a = aList[i];
for(var j = 0; j < this._oldList.length; j++)
if(a == this._oldList[j]) {
good = false;
break;
}
if(!good)
continue;
aNumber = i;
if(this._obj.target)
a.target = this._obj.target;
a.href = this._obj.href;
if(this._obj.title.length > 0)
a.title = this._obj.title;
}
if(this._txt)
this._txt.data = this._obj.href;
if(aList.length > 0) {
var elka = aList[aNumber],
_span = editor._doc.createElement("span");
_span.innerHTML = "&nbsp;";
if(elka.nextSibling != null)
elka.parentNode.insertBefore(_span, elka.nextSibling);
else
elka.parentNode.appendChild(_span);
setTimeout(function() {
Sys.Extended.UI.HtmlEditor._setCursor(_span, editor);
setTimeout(function() {
elka.parentNode.removeChild(_span);
}, 0);
}, 0);
}
setTimeout(function() { editor._editPanel.updateToolbar(); editor.onContentChanged(); }, 0);
} else {
editor._undo(false);
editor.__stack.pop();
if(this._txt) {
editor._undo(false);
editor.__stack.pop();
}
}
editor.focusEditor();
} catch(e) { }
return true;
}
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.InsertLink.registerClass("Sys.Extended.UI.HtmlEditor.ToolbarButtons.InsertLink", Sys.Extended.UI.HtmlEditor.ToolbarButtons.OkCancelPopupButton);

View File

@@ -0,0 +1,24 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.ToolbarButtons");
Sys.Extended.UI.HtmlEditor.ToolbarButtons.Italic = function(element) {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.Italic.initializeBase(this, [element]);
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.Italic.prototype = {
callMethod: function() {
if(!Sys.Extended.UI.HtmlEditor.ToolbarButtons.Italic.callBaseMethod(this, "callMethod"))
return false;
this._designPanel._execCommand("italic", false, null);
},
checkState: function() {
if(!Sys.Extended.UI.HtmlEditor.ToolbarButtons.Italic.callBaseMethod(this, "checkState"))
return false;
return this._designPanel._queryCommandState("italic");
}
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.Italic.registerClass("Sys.Extended.UI.HtmlEditor.ToolbarButtons.Italic", Sys.Extended.UI.HtmlEditor.ToolbarButtons.EditorToggleButton);

View File

@@ -0,0 +1,24 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.ToolbarButtons");
Sys.Extended.UI.HtmlEditor.ToolbarButtons.JustifyCenter = function(element) {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.JustifyCenter.initializeBase(this, [element]);
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.JustifyCenter.prototype = {
checkState: function() {
if(!Sys.Extended.UI.HtmlEditor.ToolbarButtons.JustifyCenter.callBaseMethod(this, "checkState"))
return false;
return this._designPanel._textAlignState("center");
},
callMethod: function() {
if(!Sys.Extended.UI.HtmlEditor.ToolbarButtons.JustifyCenter.callBaseMethod(this, "callMethod"))
return false;
this._designPanel._execCommand("JustifyCenter");
}
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.JustifyCenter.registerClass("Sys.Extended.UI.HtmlEditor.ToolbarButtons.JustifyCenter", Sys.Extended.UI.HtmlEditor.ToolbarButtons.EditorToggleButton);

View File

@@ -0,0 +1,24 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.ToolbarButtons");
Sys.Extended.UI.HtmlEditor.ToolbarButtons.JustifyFull = function(element) {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.JustifyFull.initializeBase(this, [element]);
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.JustifyFull.prototype = {
checkState: function() {
if(!Sys.Extended.UI.HtmlEditor.ToolbarButtons.JustifyFull.callBaseMethod(this, "checkState"))
return false;
return this._designPanel._textAlignState("justify");
},
callMethod: function() {
if(!Sys.Extended.UI.HtmlEditor.ToolbarButtons.JustifyFull.callBaseMethod(this, "callMethod"))
return false;
this._designPanel._execCommand("JustifyFull");
}
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.JustifyFull.registerClass("Sys.Extended.UI.HtmlEditor.ToolbarButtons.JustifyFull", Sys.Extended.UI.HtmlEditor.ToolbarButtons.EditorToggleButton);

View File

@@ -0,0 +1,24 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.ToolbarButtons");
Sys.Extended.UI.HtmlEditor.ToolbarButtons.JustifyLeft = function(element) {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.JustifyLeft.initializeBase(this, [element]);
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.JustifyLeft.prototype = {
checkState: function() {
if(!Sys.Extended.UI.HtmlEditor.ToolbarButtons.JustifyLeft.callBaseMethod(this, "checkState"))
return false;
return this._designPanel._textAlignState("left");
},
callMethod: function() {
if(!Sys.Extended.UI.HtmlEditor.ToolbarButtons.JustifyLeft.callBaseMethod(this, "callMethod"))
return false;
this._designPanel._execCommand("JustifyLeft");
}
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.JustifyLeft.registerClass("Sys.Extended.UI.HtmlEditor.ToolbarButtons.JustifyLeft", Sys.Extended.UI.HtmlEditor.ToolbarButtons.EditorToggleButton);

View File

@@ -0,0 +1,24 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.ToolbarButtons");
Sys.Extended.UI.HtmlEditor.ToolbarButtons.JustifyRight = function(element) {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.JustifyRight.initializeBase(this, [element]);
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.JustifyRight.prototype = {
checkState: function() {
if(!Sys.Extended.UI.HtmlEditor.ToolbarButtons.JustifyRight.callBaseMethod(this, "checkState"))
return false;
return this._designPanel._textAlignState("right");
},
callMethod: function() {
if(!Sys.Extended.UI.HtmlEditor.ToolbarButtons.JustifyRight.callBaseMethod(this, "callMethod"))
return false;
this._designPanel._execCommand("JustifyRight");
}
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.JustifyRight.registerClass("Sys.Extended.UI.HtmlEditor.ToolbarButtons.JustifyRight", Sys.Extended.UI.HtmlEditor.ToolbarButtons.EditorToggleButton);

View File

@@ -0,0 +1,39 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.ToolbarButtons");
Sys.Extended.UI.HtmlEditor.ToolbarButtons.Ltr = function(element) {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.Ltr.initializeBase(this, [element]);
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.Ltr.prototype = {
callMethod: function() {
if(!Sys.Extended.UI.HtmlEditor.ToolbarButtons.Ltr.callBaseMethod(this, "callMethod"))
return false;
this._designPanel._doc.body.style.direction = (!this.checkState()) ? "" : "rtl";
if(!Sys.Extended.UI.HtmlEditor.isIE) {
var sel = this._designPanel._getSelection(),
range = this._designPanel._createRange(sel);
this._designPanel._removeAllRanges(sel);
this._designPanel._selectRange(sel, range);
this._designPanel.focusEditor();
}
var button = this;
setTimeout(function() {
button._editPanel.updateToolbar();
}, 0);
},
checkState: function() {
if(!Sys.Extended.UI.HtmlEditor.ToolbarButtons.Ltr.callBaseMethod(this, "checkState"))
return false;
if(!(this._designPanel._doc.body.style.direction && this._designPanel._doc.body.style.direction == "rtl"))
return true;
return false;
}
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.Ltr.registerClass("Sys.Extended.UI.HtmlEditor.ToolbarButtons.Ltr", Sys.Extended.UI.HtmlEditor.ToolbarButtons.EditorToggleButton);

View File

@@ -0,0 +1,10 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.ToolbarButtons");
Sys.Extended.UI.HtmlEditor.ToolbarButtons.MethodButton = function(element) {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.MethodButton.initializeBase(this, [element]);
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.MethodButton.prototype = {
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.MethodButton.registerClass("Sys.Extended.UI.HtmlEditor.ToolbarButtons.MethodButton", Sys.Extended.UI.HtmlEditor.ToolbarButtons.DesignModeImageButton);

View File

@@ -0,0 +1,36 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor");
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.ToolbarButtons");
Sys.Extended.UI.HtmlEditor.ToolbarButtons.ModeButton = function(element) {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.ModeButton.initializeBase(this, [element]);
this._activeMode = Sys.Extended.UI.HtmlEditor.ActiveModeType.Design;
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.ModeButton.prototype = {
get_activeMode: function() {
return this._activeMode;
},
set_activeMode: function(value) {
this._activeMode = value;
},
_onclick: function(e) {
if(!Sys.Extended.UI.HtmlEditor.ToolbarButtons.ModeButton.callBaseMethod(this, "_onclick"))
return false;
var modeButton = this;
setTimeout(function() {
modeButton._editPanel.set_activeMode(modeButton._activeMode);
}, 0);
return true;
},
onEditPanelActivity: function() {
this.setActivity(this._editPanel.get_activeMode() == this._activeMode);
}
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.ModeButton.registerClass("Sys.Extended.UI.HtmlEditor.ToolbarButtons.ModeButton", Sys.Extended.UI.HtmlEditor.ToolbarButtons.ImageButton);

View File

@@ -0,0 +1,79 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.ToolbarButtons");
Sys.Extended.UI.HtmlEditor.ToolbarButtons.OkCancelPopupButton = function(element) {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.OkCancelPopupButton.initializeBase(this, [element]);
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.OkCancelPopupButton.prototype = {
set_activeEditPanel: function(value) {
if(this._editPanel != value && this._editPanel != null) {
var relatedPopup = this.get_relatedPopup();
if(typeof relatedPopup._forceImClose == "function") {
var func = relatedPopup._forceImClose;
func(relatedPopup._iframe.contentWindow);
}
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.DesignModePopupImageButton.callBaseMethod(this, "set_activeEditPanel", [value]);
},
callMethod: function() {
if(!Sys.Extended.UI.HtmlEditor.ToolbarButtons.OkCancelPopupButton.callBaseMethod(this, "callMethod"))
return false;
this.openPopup(Function.createDelegate(this, this._onopened));
return true;
},
_onopened: function(contentWindow) {
contentWindow.popupMediator.set_callMethodByName("OK", Function.createDelegate(this, this._onOK));
contentWindow.popupMediator.set_callMethodByName("Cancel", Function.createDelegate(this, this._onCancel));
var relatedPopup = this.get_relatedPopup();
relatedPopup._popup = this._designPanel._popup;
relatedPopup._forceImClose = Function.createDelegate(this, this._onCancel);
this._designPanel._popup = this.get_relatedPopup();
this.opened(contentWindow);
},
opened: function(contentWindow) {
},
_onOK: function(contentWindow) {
if(this.okCheck(contentWindow))
this._exit(Function.createDelegate(this, this.ok), contentWindow);
},
_onCancel: function(contentWindow) {
if(this.cancelCheck(contentWindow))
this._exit(Function.createDelegate(this, this.cancel), contentWindow);
},
_exit: function(callback, contentWindow) {
this.closePopup();
this._designPanel._popup = this.get_relatedPopup()._popup;
this.get_relatedPopup()._popup = null;
this.get_relatedPopup()._forceImClose = null;
callback(contentWindow);
},
ok: function(contentWindow) {
},
cancel: function(contentWindow) {
},
okCheck: function(contentWindow) {
return true;
},
cancelCheck: function(contentWindow) {
return true;
}
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.OkCancelPopupButton.registerClass("Sys.Extended.UI.HtmlEditor.ToolbarButtons.OkCancelPopupButton", Sys.Extended.UI.HtmlEditor.ToolbarButtons.DesignModePopupImageButton);

View File

@@ -0,0 +1,16 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.ToolbarButtons");
Sys.Extended.UI.HtmlEditor.ToolbarButtons.OrderedList = function(element) {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.OrderedList.initializeBase(this, [element]);
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.OrderedList.prototype = {
callMethod: function() {
if(!Sys.Extended.UI.HtmlEditor.ToolbarButtons.OrderedList.callBaseMethod(this, "callMethod"))
return false;
this._designPanel._execCommand("InsertOrderedList");
}
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.OrderedList.registerClass("Sys.Extended.UI.HtmlEditor.ToolbarButtons.OrderedList", Sys.Extended.UI.HtmlEditor.ToolbarButtons.MethodButton);

View File

@@ -0,0 +1,23 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.ToolbarButtons");
Sys.Extended.UI.HtmlEditor.ToolbarButtons.Paragraph = function(element) {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.Paragraph.initializeBase(this, [element]);
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.Paragraph.prototype = {
checkState: function() {
if(!Sys.Extended.UI.HtmlEditor.ToolbarButtons.Paragraph.callBaseMethod(this, "checkState"))
return false;
return this._designPanel._textAlignState("");
},
callMethod: function() {
if(!Sys.Extended.UI.HtmlEditor.ToolbarButtons.Paragraph.callBaseMethod(this, "callMethod"))
return false;
this._designPanel._execCommand("Paragraph");
}
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.Paragraph.registerClass("Sys.Extended.UI.HtmlEditor.ToolbarButtons.Paragraph", Sys.Extended.UI.HtmlEditor.ToolbarButtons.EditorToggleButton);

View File

@@ -0,0 +1,39 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.ToolbarButtons");
Sys.Extended.UI.HtmlEditor.ToolbarButtons.Paste = function(element) {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.Paste.initializeBase(this, [element]);
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.Paste.prototype = {
canBeShown: function() {
return Sys.Extended.UI.HtmlEditor.isIE;
},
callMethod: function() {
if(!Sys.Extended.UI.HtmlEditor.ToolbarButtons.Paste.callBaseMethod(this, "callMethod"))
return false;
var editor = this._designPanel;
if(Sys.Extended.UI.HtmlEditor.isIE) {
editor._saveContent();
editor.openWait();
setTimeout(function() {
editor._paste(true); editor.closeWait();
}, 0)
} else {
var sel = editor._getSelection(),
range = editor._createRange(sel);
editor._removeAllRanges(sel);
alert(String.format(Sys.Extended.UI.Resources.HtmlEditor_toolbar_button_Use_verb, (Sys.Extended.UI.HtmlEditor.isSafari && navigator.userAgent.indexOf("mac") != -1) ? "Apple-V" : "Ctrl-V"));
editor._selectRange(sel, range);
editor.isWord = false;
editor.isPlainText = false;
}
}
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.Paste.registerClass("Sys.Extended.UI.HtmlEditor.ToolbarButtons.Paste", Sys.Extended.UI.HtmlEditor.ToolbarButtons.MethodButton);

View File

@@ -0,0 +1,39 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.ToolbarButtons");
Sys.Extended.UI.HtmlEditor.ToolbarButtons.PasteText = function(element) {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.PasteText.initializeBase(this, [element]);
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.PasteText.prototype = {
callMethod: function() {
if(!Sys.Extended.UI.HtmlEditor.ToolbarButtons.PasteText.callBaseMethod(this, "callMethod"))
return false;
var editor = this._designPanel;
if(Sys.Extended.UI.HtmlEditor.isIE) {
editor._saveContent();
editor.openWait();
setTimeout(function() {
editor._paste(false); editor.closeWait();
}, 0)
} else {
var sel = editor._getSelection(),
range = editor._createRange(sel),
useVerb = String.format(Sys.Extended.UI.Resources.HtmlEditor_toolbar_button_Use_verb, (Sys.Extended.UI.HtmlEditor.isSafari && navigator.userAgent.indexOf("mac") != -1) ? "Apple-V" : "Ctrl-V"),
mess = String.format(Sys.Extended.UI.Resources.HtmlEditor_toolbar_button_OnPastePlainText, useVerb);
alert(mess);
setTimeout(function() {
editor._removeAllRanges(sel);
editor._selectRange(sel, range);
}, 0);
editor.isPlainText = true;
}
}
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.PasteText.registerClass("Sys.Extended.UI.HtmlEditor.ToolbarButtons.PasteText", Sys.Extended.UI.HtmlEditor.ToolbarButtons.MethodButton);

View File

@@ -0,0 +1,39 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.ToolbarButtons");
Sys.Extended.UI.HtmlEditor.ToolbarButtons.PasteWord = function(element) {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.PasteWord.initializeBase(this, [element]);
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.PasteWord.prototype = {
callMethod: function() {
if(!Sys.Extended.UI.HtmlEditor.ToolbarButtons.PasteWord.callBaseMethod(this, "callMethod"))
return false;
var editor = this._designPanel;
if(Sys.Extended.UI.HtmlEditor.isIE) {
editor._saveContent();
editor.openWait();
setTimeout(function() {
editor._paste(true, true); editor.closeWait();
}, 0)
} else {
var sel = editor._getSelection(),
range = editor._createRange(sel),
useVerb = String.format(Sys.Extended.UI.Resources.HtmlEditor_toolbar_button_Use_verb, (Sys.Extended.UI.HtmlEditor.isSafari && navigator.userAgent.indexOf("mac") != -1) ? "Apple-V" : "Ctrl-V"),
mess = String.format(Sys.Extended.UI.Resources.HtmlEditor_toolbar_button_OnPasteFromMSWord, useVerb);
alert(mess);
setTimeout(function() {
editor._removeAllRanges(sel);
editor._selectRange(sel, range);
}, 0);
editor.isWord = true;
}
}
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.PasteWord.registerClass("Sys.Extended.UI.HtmlEditor.ToolbarButtons.PasteWord", Sys.Extended.UI.HtmlEditor.ToolbarButtons.MethodButton);

View File

@@ -0,0 +1,10 @@
Type.registerNamespace("Sys.Extended.UI.HtmlEditor.ToolbarButtons");
Sys.Extended.UI.HtmlEditor.ToolbarButtons.PreviewMode = function(element) {
Sys.Extended.UI.HtmlEditor.ToolbarButtons.PreviewMode.initializeBase(this, [element]);
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.PreviewMode.prototype = {
}
Sys.Extended.UI.HtmlEditor.ToolbarButtons.PreviewMode.registerClass("Sys.Extended.UI.HtmlEditor.ToolbarButtons.PreviewMode", Sys.Extended.UI.HtmlEditor.ToolbarButtons.ModeButton);

Some files were not shown because too many files have changed in this diff Show More