Initial commit
336
crystalreportviewers13/js/FlexParameterBridge.js
Normal file
@@ -0,0 +1,336 @@
|
||||
/* Copyright (c) Business Objects 2006. All rights reserved. */
|
||||
|
||||
if (typeof (bobj) == 'undefined') {
|
||||
bobj = {};
|
||||
}
|
||||
|
||||
if (typeof (bobj.crv) == 'undefined') {
|
||||
bobj.crv = {};
|
||||
}
|
||||
|
||||
if (typeof (bobj.crv.params) == 'undefined') {
|
||||
bobj.crv.params = {};
|
||||
}
|
||||
|
||||
/*
|
||||
================================================================================
|
||||
FlexParameterBridge
|
||||
|
||||
Base functionality for flex prompting UI
|
||||
================================================================================
|
||||
*/
|
||||
|
||||
bobj.crv.params.FlexParameterBridge = {
|
||||
_swfID : [],
|
||||
_swf : [],
|
||||
_cb : [],
|
||||
|
||||
// TODO: Ryan - clean this up when the CAF actions are also cleaned up
|
||||
_promptData : [],
|
||||
|
||||
setPromptData : function(id, d) {
|
||||
this._promptData[id] = d;
|
||||
},
|
||||
|
||||
setMasterCallBack : function(viewerName, callBack) {
|
||||
this._cb[viewerName] = callBack;
|
||||
},
|
||||
|
||||
getSWF : function(viewerName) {
|
||||
if (this._swf[viewerName]) {
|
||||
return this._swf[viewerName];
|
||||
} else {
|
||||
var swf = document.getElementById(this._swfID[viewerName]);
|
||||
this._swf[viewerName] = swf;
|
||||
return swf;
|
||||
}
|
||||
},
|
||||
|
||||
getInstallHTML : function() {
|
||||
return L_bobj_crv_FlashRequired.replace("{0}", "<br><a href='http://www.adobe.com/go/getflash/' target='_blank' rel='noopener noreferrer'>") + "</a>";
|
||||
},
|
||||
|
||||
checkFlashPlayer : function() {
|
||||
return swfobject.hasFlashPlayerVersion("9.0.0");
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates the swf and replaces the div specified with the flash object.
|
||||
*/
|
||||
createSWF : function(viewerName, divID, servletURL, showMinUI, locale, rptSrcKey) {
|
||||
var cb = this._cb[viewerName];
|
||||
if (!cb) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (cb.logger) {
|
||||
cb.logger('Create the SWF');
|
||||
}
|
||||
|
||||
if (this.checkFlashPlayer()) {
|
||||
|
||||
var swfBaseURL = cb.getSWFBaseURL();
|
||||
var swfPath = swfBaseURL + "prompting.swf";
|
||||
var swfID = cb.getSWFID();
|
||||
var useSavedData = cb.getUseSavedData ? cb.getUseSavedData(viewerName) : false;
|
||||
var useOKCancelButtons = cb.getUseOKCancelButtons ? cb.getUseOKCancelButtons(viewerName) : false;
|
||||
var isDialog = cb.getIsDialog ? cb.getIsDialog (viewerName) : false;
|
||||
var allowFullScreen = cb.getAllowFullScreen ? cb.getAllowFullScreen (viewerName) : false;
|
||||
var enforceRequiredPrompt = cb.getEnforceRequiredPrompt ? cb.getEnforceRequiredPrompt () : true;
|
||||
var shouldAutoResize = cb.getShouldAutoResize ? cb.getShouldAutoResize(viewerName) : false;
|
||||
|
||||
var flashvars = {
|
||||
"eventTarget" : viewerName,
|
||||
"locale" : locale,
|
||||
"showMinUI" : showMinUI,
|
||||
"baseURL" : swfBaseURL,
|
||||
"servletURL" : servletURL, // The SWF will use javascript to handle all async requests if this is null or empty
|
||||
"reportSourceKey" : rptSrcKey,
|
||||
"useSavedData" : useSavedData,
|
||||
"useOKCancelButtons" : useOKCancelButtons,
|
||||
"isDialog" : isDialog,
|
||||
"allowFullScreen" : allowFullScreen,
|
||||
"enforceRequiredPrompt" : enforceRequiredPrompt,
|
||||
"shouldAutoResize" : shouldAutoResize
|
||||
};
|
||||
|
||||
// Important: Do not specify play=true as one of the params. If this
|
||||
// is set to true we could end up in an infinite loop reloading
|
||||
// the swf when viewing using the embedded browser in eclipse.
|
||||
var params = {
|
||||
menu : "false",
|
||||
wmode : "window",
|
||||
allowscriptaccess : "sameDomain"
|
||||
};
|
||||
|
||||
var attributes = {
|
||||
id : swfID,
|
||||
name : swfID,
|
||||
style : 'z-index:' + cb.getZIndex()
|
||||
};
|
||||
|
||||
if (cb.processingDelayedShow) {
|
||||
cb.processingDelayedShow('hidden', divID);
|
||||
}
|
||||
|
||||
var h = cb.getSWFHeight ? cb.getSWFHeight(viewerName) + "" : "600";
|
||||
var w = cb.getSWFWidth ? cb.getSWFWidth(viewerName) + "" : "800";
|
||||
|
||||
swfobject.embedSWF(swfPath, divID, w, h, "9.0.0", "", flashvars, params, attributes);
|
||||
this._swfID[viewerName] = swfID;
|
||||
|
||||
if (cb.processingDelayedShow) {
|
||||
cb.processingDelayedShow();
|
||||
}
|
||||
|
||||
} else {
|
||||
document.getElementById(divID).innerHTML = "<p>" + cb.getInstallHTML() + "</p>";
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* This function will initialize the data in the flex swf with the
|
||||
* current state of the parameter ui. The Flex swf will call back to
|
||||
* this method when it has first been created and all external interface
|
||||
* connections have been setup. If the swf has already been created this will
|
||||
* be called when showing the parameter UI.
|
||||
*/
|
||||
|
||||
init : function(viewerName) {
|
||||
if (!viewerName) {
|
||||
return;
|
||||
}
|
||||
|
||||
var cb = this._cb[viewerName];
|
||||
var swf = this.getSWF(viewerName);
|
||||
if (!swf || !cb) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (cb.logger) {
|
||||
cb.logger('Init the SWF');
|
||||
}
|
||||
|
||||
if(swf.setShowMinUI && cb.getShowMinUI) {
|
||||
swf.setShowMinUI(cb.getShowMinUI(viewerName));
|
||||
}
|
||||
|
||||
if(swf.setUseSavedData && cb.getUseSavedData) {
|
||||
swf.setUseSavedData(cb.getUseSavedData(viewerName));
|
||||
}
|
||||
|
||||
if(swf.setUseOKCancelButtons && cb.getUseOKCancelButtons) {
|
||||
swf.setUseOKCancelButtons(cb.getUseOKCancelButtons(viewerName));
|
||||
}
|
||||
|
||||
if(swf.setAllowFullScreen && cb.getAllowFullScreen) {
|
||||
swf.setAllowFullScreen(cb.getAllowFullScreen(viewerName));
|
||||
}
|
||||
|
||||
if (swf.setReportStateInfo && cb.getReportStateInfo) {
|
||||
swf.setReportStateInfo(cb.getReportStateInfo(viewerName));
|
||||
}
|
||||
|
||||
if (swf.setPromptData) {
|
||||
if (cb.getPromptData && cb.getPromptData(viewerName)) {
|
||||
swf.setPromptData(cb.getPromptData(viewerName));
|
||||
} else {
|
||||
swf.setPromptData(this._promptData[viewerName]);
|
||||
}
|
||||
}
|
||||
|
||||
if (cb.getShouldAutoResize && cb.getShouldAutoResize(viewerName))
|
||||
this.resize(viewerName, 1, 1, true);
|
||||
else if (cb.getSWFHeight && cb.getSWFWidth)
|
||||
this.resize(viewerName, cb.getSWFHeight(viewerName), cb.getSWFWidth(viewerName), true);
|
||||
},
|
||||
|
||||
/**
|
||||
* Flex callback for closing the current dialog window.
|
||||
*/
|
||||
closeDialog : function (viewerName){
|
||||
var cb = this._cb[viewerName];
|
||||
if (cb && cb.closeDialog) {
|
||||
cb.closeDialog(viewerName);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Flex callback for adjusting the size of the swf to fit the number of
|
||||
* prompts being displayed.
|
||||
*/
|
||||
|
||||
resize : function(viewerName, height, width, shouldCenter) {
|
||||
var swf = this.getSWF(viewerName);
|
||||
var cb = this._cb[viewerName];
|
||||
if (swf && cb) {
|
||||
cb.logger('Resizing the SWF h:' + height + ' w:' + width);
|
||||
|
||||
if (cb.getScreenHeight && cb.getScreenWidth)
|
||||
{
|
||||
var screenHeight = cb.getScreenHeight(viewerName);
|
||||
var screenWidth = cb.getScreenWidth(viewerName);
|
||||
var p = MochiKit.Style.getElementPosition(swf.parentNode);
|
||||
|
||||
// Do not allow resizing beyond the screen size
|
||||
if ((p.x >= 0) && ((p.x + width) >= screenWidth) && !shouldCenter) {
|
||||
width = screenWidth - p.x;
|
||||
}
|
||||
else if (width > screenWidth) {
|
||||
width = screenWidth;
|
||||
}
|
||||
|
||||
if ((p.y >= 0) && ((p.y + height) >= screenHeight) && !shouldCenter) {
|
||||
height = screenHeight - p.y;
|
||||
}
|
||||
else if (height > screenHeight) {
|
||||
height = screenHeight;
|
||||
}
|
||||
}
|
||||
|
||||
if(swf.setWidth && swf.setHeight) {
|
||||
swf.setWidth(width);
|
||||
swf.setHeight(height);
|
||||
}
|
||||
|
||||
swf.style.width = width + 'px';
|
||||
swf.style.height = height + 'px';
|
||||
|
||||
if (shouldCenter) {
|
||||
this.move(viewerName, ((screenWidth - width) / 2), ((screenHeight - height) / 2));
|
||||
}
|
||||
|
||||
cb.setVisibility(viewerName);
|
||||
|
||||
swf._isMaximized = false;
|
||||
}
|
||||
},
|
||||
|
||||
fitScreen : function (viewerName){
|
||||
var swf = this.getSWF(viewerName);
|
||||
var cb = this._cb[viewerName];
|
||||
if (swf && cb && cb.getScreenHeight && cb.getScreenWidth && swf.setHeight && swf.setWidth) {
|
||||
cb.logger('Fitting SWF to the screen');
|
||||
var h = cb.getScreenHeight(viewerName);
|
||||
var w = cb.getScreenWidth(viewerName);
|
||||
|
||||
// Resize the html object
|
||||
// We must call move before resize so that we can calculate the width/height appropriately when resizing
|
||||
this.move(viewerName, 0, 0);
|
||||
this.resize(viewerName, h, w, false);
|
||||
|
||||
swf._isMaximized = true;
|
||||
}
|
||||
},
|
||||
|
||||
startDrag : function(viewerName) {
|
||||
var cb = this._cb[viewerName];
|
||||
if (cb && cb.startDrag) {
|
||||
cb.startDrag(viewerName);
|
||||
}
|
||||
},
|
||||
|
||||
stopDrag : function(viewerName) {
|
||||
var cb = this._cb[viewerName];
|
||||
if (cb && cb.stopDrag) {
|
||||
cb.stopDrag(viewerName);
|
||||
}
|
||||
},
|
||||
|
||||
drag : function(viewerName, x, y) {
|
||||
var cb = this._cb[viewerName];
|
||||
if (cb && cb.drag) {
|
||||
cb.drag(viewerName, x, y);
|
||||
}
|
||||
},
|
||||
|
||||
move : function(viewerName, x, y) {
|
||||
var cb = this._cb[viewerName];
|
||||
if (cb && cb.move) {
|
||||
cb.move(viewerName, x, y);
|
||||
}
|
||||
},
|
||||
|
||||
setParamValues : function(viewerName, paramData) {
|
||||
var cb = this._cb[viewerName];
|
||||
if (cb && cb.setParamValues) {
|
||||
cb.setParamValues(viewerName, paramData);
|
||||
}
|
||||
},
|
||||
|
||||
logon : function(viewerName, logonData) {
|
||||
var cb = this._cb[viewerName];
|
||||
if (cb && cb.logon) {
|
||||
cb.logon(viewerName, logonData);
|
||||
}
|
||||
},
|
||||
|
||||
setReportStateInfo : function(viewerName, rsInfo) {
|
||||
var cb = this._cb[viewerName];
|
||||
if (cb && cb.setReportStateInfo) {
|
||||
cb.setReportStateInfo(viewerName, rsInfo);
|
||||
}
|
||||
},
|
||||
|
||||
sendAsyncRequest : function(viewerName, args) {
|
||||
var cb = this._cb[viewerName];
|
||||
if (cb && cb.sendAsyncRequest) {
|
||||
cb.sendAsyncRequest(viewerName, args);
|
||||
}
|
||||
},
|
||||
|
||||
handleAsyncResponse : function(viewerName, args) {
|
||||
var swf = this.getSWF(viewerName);
|
||||
if (swf && swf.handleAsyncResponse){
|
||||
swf.handleAsyncResponse(args);
|
||||
}
|
||||
},
|
||||
|
||||
readyToShow: function(viewerName) {
|
||||
var cb = this._cb[viewerName];
|
||||
if (cb && cb.readyToShow) {
|
||||
cb.readyToShow(viewerName);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
44
crystalreportviewers13/js/KeyDownEvent.js
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
File Version Start - Do not remove this if you are modifying the file
|
||||
Build: 9.5.0
|
||||
File Version End
|
||||
*/
|
||||
/*
|
||||
this function is used to verify whether the 'Enter' key is pressed.
|
||||
if the 'Enter' key is pressed, then either call the event handler function passed in as a parameter (evntHdlrName)
|
||||
or if evntHdlrName is an empty string, submit the form that contains the input box (that triggers this function).
|
||||
The form name is passed in as the third parameter, if it's an empty string, it's set to 0 by default.
|
||||
The first parameter is an event object
|
||||
|
||||
written by Paul Chong, 17th May 01
|
||||
*/
|
||||
|
||||
function keydownfn(e, evntHdlrName, formName)
|
||||
{
|
||||
var nav4;
|
||||
var keyPressed;
|
||||
|
||||
//check if the brower is Netscape Navigator 4 or not
|
||||
var nav4 = window.Event ? true : false;
|
||||
|
||||
//if browser is Navigator 4, the key pressed is called <event object>.which else it's called <event object>.keyCode
|
||||
keyPressed = nav4 ? e.which : e.keyCode;
|
||||
|
||||
if (keyPressed == 13)
|
||||
{
|
||||
if (evntHdlrName != "")
|
||||
{
|
||||
// append empty parentheses if none given
|
||||
if(evntHdlrName.substr(evntHdlrName.length-1) != ")")
|
||||
evntHdlrName += "()";
|
||||
eval(evntHdlrName);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (formName == "")
|
||||
formName = 0;
|
||||
document.forms[formName].submit();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
66
crystalreportviewers13/js/MochiKit/3rdParty.txt
Normal file
@@ -0,0 +1,66 @@
|
||||
MochiKit is dual-licensed software. It is available under the terms of the
|
||||
MIT License, or the Academic Free License version 2.1. The full text of
|
||||
each license is included below.
|
||||
|
||||
MIT License
|
||||
===========
|
||||
|
||||
Copyright (c) 2005 Bob Ippolito. All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
Academic Free License v. 2.1
|
||||
============================
|
||||
|
||||
Copyright (c) 2005 Bob Ippolito. All rights reserved.
|
||||
|
||||
This Academic Free License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following notice immediately following the copyright notice for the Original Work:
|
||||
|
||||
Licensed under the Academic Free License version 2.1
|
||||
|
||||
1) Grant of Copyright License. Licensor hereby grants You a world-wide, royalty-free, non-exclusive, perpetual, sublicenseable license to do the following:
|
||||
|
||||
a) to reproduce the Original Work in copies;
|
||||
|
||||
b) to prepare derivative works ("Derivative Works") based upon the Original Work;
|
||||
|
||||
c) to distribute copies of the Original Work and Derivative Works to the public;
|
||||
|
||||
d) to perform the Original Work publicly; and
|
||||
|
||||
e) to display the Original Work publicly.
|
||||
|
||||
2) Grant of Patent License. Licensor hereby grants You a world-wide, royalty-free, non-exclusive, perpetual, sublicenseable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, to make, use, sell and offer for sale the Original Work and Derivative Works.
|
||||
|
||||
3) Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor hereby agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work, and by publishing the address of that information repository in a notice immediately following the copyright notice that applies to the Original Work.
|
||||
|
||||
4) Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior written permission of the Licensor. Nothing in this License shall be deemed to grant any rights to trademarks, copyrights, patents, trade secrets or any other intellectual property of Licensor except as expressly stated herein. No patent license is granted to make, use, sell or offer to sell embodiments of any patent claims other than the licensed claims defined in Section 2. No right is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under different terms from this License any Original Work that Licensor otherwise would have a right to license.
|
||||
|
||||
5) This section intentionally omitted.
|
||||
|
||||
6) Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work.
|
||||
|
||||
7) Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately proceeding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of NON-INFRINGEMENT, MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to Original Work is granted hereunder except under this disclaimer.
|
||||
|
||||
8) Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to any person for any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to liability for death or personal injury resulting from Licensor's negligence to the extent applicable law prohibits such limitation. Some jurisdictions do not allow the exclusion or limitation of incidental or consequential damages, so this exclusion and limitation may not apply to You.
|
||||
|
||||
9) Acceptance and Termination. If You distribute copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. Nothing else but this License (or another written agreement between Licensor and You) grants You permission to create Derivative Works based upon the Original Work or to exercise any of the rights granted in Section 1 herein, and any attempt to do so except under the terms of this License (or another written agreement between Licensor and You) is expressly prohibited by U.S. copyright law, the equivalent laws of other countries, and by international treaty. Therefore, by exercising any of the rights granted to You in Section 1 herein, You indicate Your acceptance of this License and all of its terms and conditions.
|
||||
|
||||
10) Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware.
|
||||
|
||||
11) Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of the U.S. Copyright Act, 17 U.S.C. § 101 et seq., the equivalent laws of other countries, and international treaty. This section shall survive the termination of this License.
|
||||
|
||||
12) Attorneys Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License.
|
||||
|
||||
13) Miscellaneous. This License represents the complete agreement concerning the subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable.
|
||||
|
||||
14) Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
15) Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You.
|
||||
|
||||
This license is Copyright (C) 2003-2004 Lawrence E. Rosen. All rights reserved. Permission is hereby granted to copy and distribute this license without modification. This license may not be modified without the express written permission of its copyright owner.
|
||||
602
crystalreportviewers13/js/MochiKit/Async.js
Normal file
@@ -0,0 +1,602 @@
|
||||
/***
|
||||
|
||||
MochiKit.Async 1.4
|
||||
|
||||
See <http://mochikit.com/> for documentation, downloads, license, etc.
|
||||
|
||||
(c) 2005 Bob Ippolito. All rights Reserved.
|
||||
|
||||
***/
|
||||
|
||||
if (typeof(dojo) != 'undefined') {
|
||||
dojo.provide("MochiKit.Async");
|
||||
dojo.require("MochiKit.Base");
|
||||
}
|
||||
if (typeof(JSAN) != 'undefined') {
|
||||
JSAN.use("MochiKit.Base", []);
|
||||
}
|
||||
|
||||
try {
|
||||
if (typeof(MochiKit.Base) == 'undefined') {
|
||||
throw "";
|
||||
}
|
||||
} catch (e) {
|
||||
throw "MochiKit.Async depends on MochiKit.Base!";
|
||||
}
|
||||
|
||||
if (typeof(MochiKit.Async) == 'undefined') {
|
||||
MochiKit.Async = {};
|
||||
}
|
||||
|
||||
MochiKit.Async.NAME = "MochiKit.Async";
|
||||
MochiKit.Async.VERSION = "1.4";
|
||||
MochiKit.Async.__repr__ = function () {
|
||||
return "[" + this.NAME + " " + this.VERSION + "]";
|
||||
};
|
||||
MochiKit.Async.toString = function () {
|
||||
return this.__repr__();
|
||||
};
|
||||
|
||||
MochiKit.Async.Deferred = function (/* optional */ canceller) {
|
||||
this.chain = [];
|
||||
this.id = this._nextId();
|
||||
this.fired = -1;
|
||||
this.paused = 0;
|
||||
this.results = [null, null];
|
||||
this.canceller = canceller;
|
||||
this.silentlyCancelled = false;
|
||||
this.chained = false;
|
||||
};
|
||||
|
||||
MochiKit.Async.Deferred.prototype = {
|
||||
repr: function () {
|
||||
var state;
|
||||
if (this.fired == -1) {
|
||||
state = 'unfired';
|
||||
} else if (this.fired === 0) {
|
||||
state = 'success';
|
||||
} else {
|
||||
state = 'error';
|
||||
}
|
||||
return 'Deferred(' + this.id + ', ' + state + ')';
|
||||
},
|
||||
|
||||
toString: MochiKit.Base.forwardCall("repr"),
|
||||
|
||||
_nextId: MochiKit.Base.counter(),
|
||||
|
||||
cancel: function () {
|
||||
var self = MochiKit.Async;
|
||||
if (this.fired == -1) {
|
||||
if (this.canceller) {
|
||||
this.canceller(this);
|
||||
} else {
|
||||
this.silentlyCancelled = true;
|
||||
}
|
||||
if (this.fired == -1) {
|
||||
this.errback(new self.CancelledError(this));
|
||||
}
|
||||
} else if ((this.fired === 0) && (this.results[0] instanceof self.Deferred)) {
|
||||
this.results[0].cancel();
|
||||
}
|
||||
},
|
||||
|
||||
_resback: function (res) {
|
||||
/***
|
||||
|
||||
The primitive that means either callback or errback
|
||||
|
||||
***/
|
||||
this.fired = ((res instanceof Error) ? 1 : 0);
|
||||
this.results[this.fired] = res;
|
||||
this._fire();
|
||||
},
|
||||
|
||||
_check: function () {
|
||||
if (this.fired != -1) {
|
||||
if (!this.silentlyCancelled) {
|
||||
throw new MochiKit.Async.AlreadyCalledError(this);
|
||||
}
|
||||
this.silentlyCancelled = false;
|
||||
return;
|
||||
}
|
||||
},
|
||||
|
||||
callback: function (res) {
|
||||
this._check();
|
||||
if (res instanceof MochiKit.Async.Deferred) {
|
||||
throw new Error("Deferred instances can only be chained if they are the result of a callback");
|
||||
}
|
||||
this._resback(res);
|
||||
},
|
||||
|
||||
errback: function (res) {
|
||||
this._check();
|
||||
var self = MochiKit.Async;
|
||||
if (res instanceof self.Deferred) {
|
||||
throw new Error("Deferred instances can only be chained if they are the result of a callback");
|
||||
}
|
||||
if (!(res instanceof Error)) {
|
||||
res = new self.GenericError(res);
|
||||
}
|
||||
this._resback(res);
|
||||
},
|
||||
|
||||
addBoth: function (fn) {
|
||||
if (arguments.length > 1) {
|
||||
fn = MochiKit.Base.partial.apply(null, arguments);
|
||||
}
|
||||
return this.addCallbacks(fn, fn);
|
||||
},
|
||||
|
||||
addCallback: function (fn) {
|
||||
if (arguments.length > 1) {
|
||||
fn = MochiKit.Base.partial.apply(null, arguments);
|
||||
}
|
||||
return this.addCallbacks(fn, null);
|
||||
},
|
||||
|
||||
addErrback: function (fn) {
|
||||
if (arguments.length > 1) {
|
||||
fn = MochiKit.Base.partial.apply(null, arguments);
|
||||
}
|
||||
return this.addCallbacks(null, fn);
|
||||
},
|
||||
|
||||
addCallbacks: function (cb, eb) {
|
||||
if (this.chained) {
|
||||
throw new Error("Chained Deferreds can not be re-used");
|
||||
}
|
||||
this.chain.push([cb, eb]);
|
||||
if (this.fired >= 0) {
|
||||
this._fire();
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
_fire: function () {
|
||||
/***
|
||||
|
||||
Used internally to exhaust the callback sequence when a result
|
||||
is available.
|
||||
|
||||
***/
|
||||
var chain = this.chain;
|
||||
var fired = this.fired;
|
||||
var res = this.results[fired];
|
||||
var self = this;
|
||||
var cb = null;
|
||||
while (chain.length > 0 && this.paused === 0) {
|
||||
// Array
|
||||
var pair = chain.shift();
|
||||
var f = pair[fired];
|
||||
if (f === null) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
res = f(res);
|
||||
fired = ((res instanceof Error) ? 1 : 0);
|
||||
if (res instanceof MochiKit.Async.Deferred) {
|
||||
cb = function (res) {
|
||||
self._resback(res);
|
||||
self.paused--;
|
||||
if ((self.paused === 0) && (self.fired >= 0)) {
|
||||
self._fire();
|
||||
}
|
||||
};
|
||||
this.paused++;
|
||||
}
|
||||
} catch (err) {
|
||||
fired = 1;
|
||||
if (!(err instanceof Error)) {
|
||||
err = new MochiKit.Async.GenericError(err);
|
||||
}
|
||||
res = err;
|
||||
}
|
||||
}
|
||||
this.fired = fired;
|
||||
this.results[fired] = res;
|
||||
if (cb && this.paused) {
|
||||
// this is for "tail recursion" in case the dependent deferred
|
||||
// is already fired
|
||||
res.addBoth(cb);
|
||||
res.chained = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
MochiKit.Base.update(MochiKit.Async, {
|
||||
evalJSONRequest: function (/* req */) {
|
||||
return eval('(' + arguments[0].responseText + ')');
|
||||
},
|
||||
|
||||
succeed: function (/* optional */result) {
|
||||
var d = new MochiKit.Async.Deferred();
|
||||
d.callback.apply(d, arguments);
|
||||
return d;
|
||||
},
|
||||
|
||||
fail: function (/* optional */result) {
|
||||
var d = new MochiKit.Async.Deferred();
|
||||
d.errback.apply(d, arguments);
|
||||
return d;
|
||||
},
|
||||
|
||||
getXMLHttpRequest: function () {
|
||||
var self = arguments.callee;
|
||||
if (!self.XMLHttpRequest) {
|
||||
var tryThese = [
|
||||
function () { return new XMLHttpRequest(); },
|
||||
function () { return new ActiveXObject('Msxml2.XMLHTTP'); },
|
||||
function () { return new ActiveXObject('Microsoft.XMLHTTP'); },
|
||||
function () { return new ActiveXObject('Msxml2.XMLHTTP.4.0'); },
|
||||
function () {
|
||||
throw new MochiKit.Async.BrowserComplianceError("Browser does not support XMLHttpRequest");
|
||||
}
|
||||
];
|
||||
for (var i = 0; i < tryThese.length; i++) {
|
||||
var func = tryThese[i];
|
||||
try {
|
||||
self.XMLHttpRequest = func;
|
||||
return func();
|
||||
} catch (e) {
|
||||
// pass
|
||||
}
|
||||
}
|
||||
}
|
||||
return self.XMLHttpRequest();
|
||||
},
|
||||
|
||||
_xhr_onreadystatechange: function (d) {
|
||||
// MochiKit.Logging.logDebug('this.readyState', this.readyState);
|
||||
var m = MochiKit.Base;
|
||||
if (this.readyState == 4) {
|
||||
// IE SUCKS
|
||||
try {
|
||||
this.onreadystatechange = null;
|
||||
} catch (e) {
|
||||
try {
|
||||
this.onreadystatechange = m.noop;
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
var status = null;
|
||||
try {
|
||||
status = this.status;
|
||||
if (!status && m.isNotEmpty(this.responseText)) {
|
||||
// 0 or undefined seems to mean cached or local
|
||||
status = 304;
|
||||
}
|
||||
} catch (e) {
|
||||
// pass
|
||||
// MochiKit.Logging.logDebug('error getting status?', repr(items(e)));
|
||||
}
|
||||
// 200 is OK, 304 is NOT_MODIFIED
|
||||
if (status == 200 || status == 304) { // OK
|
||||
d.callback(this);
|
||||
} else {
|
||||
var err = new MochiKit.Async.XMLHttpRequestError(this, "Request failed");
|
||||
if (err.number) {
|
||||
// XXX: This seems to happen on page change
|
||||
d.errback(err);
|
||||
} else {
|
||||
// XXX: this seems to happen when the server is unreachable
|
||||
d.errback(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_xhr_canceller: function (req) {
|
||||
// IE SUCKS
|
||||
try {
|
||||
req.onreadystatechange = null;
|
||||
} catch (e) {
|
||||
try {
|
||||
req.onreadystatechange = MochiKit.Base.noop;
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
req.abort();
|
||||
},
|
||||
|
||||
|
||||
sendXMLHttpRequest: function (req, /* optional */ sendContent) {
|
||||
if (typeof(sendContent) == "undefined" || sendContent === null) {
|
||||
sendContent = "";
|
||||
}
|
||||
|
||||
var m = MochiKit.Base;
|
||||
var self = MochiKit.Async;
|
||||
var d = new self.Deferred(m.partial(self._xhr_canceller, req));
|
||||
|
||||
try {
|
||||
req.onreadystatechange = m.bind(self._xhr_onreadystatechange,
|
||||
req, d);
|
||||
req.send(sendContent);
|
||||
} catch (e) {
|
||||
try {
|
||||
req.onreadystatechange = null;
|
||||
} catch (ignore) {
|
||||
// pass
|
||||
}
|
||||
d.errback(e);
|
||||
}
|
||||
|
||||
return d;
|
||||
|
||||
},
|
||||
|
||||
doSimpleXMLHttpRequest: function (url/*, ...*/) {
|
||||
var self = MochiKit.Async;
|
||||
var req = self.getXMLHttpRequest();
|
||||
if (arguments.length > 1) {
|
||||
var m = MochiKit.Base;
|
||||
var qs = m.queryString.apply(null, m.extend(null, arguments, 1));
|
||||
if (qs) {
|
||||
url += "?" + qs;
|
||||
}
|
||||
}
|
||||
req.open("GET", url, true);
|
||||
return self.sendXMLHttpRequest(req);
|
||||
},
|
||||
|
||||
loadJSONDoc: function (url) {
|
||||
var self = MochiKit.Async;
|
||||
var d = self.doSimpleXMLHttpRequest.apply(self, arguments);
|
||||
d = d.addCallback(self.evalJSONRequest);
|
||||
return d;
|
||||
},
|
||||
|
||||
wait: function (seconds, /* optional */value) {
|
||||
var d = new MochiKit.Async.Deferred();
|
||||
var m = MochiKit.Base;
|
||||
if (typeof(value) != 'undefined') {
|
||||
d.addCallback(function () { return value; });
|
||||
}
|
||||
var timeout = setTimeout(
|
||||
m.bind("callback", d),
|
||||
Math.floor(seconds * 1000));
|
||||
d.canceller = function () {
|
||||
try {
|
||||
clearTimeout(timeout);
|
||||
} catch (e) {
|
||||
// pass
|
||||
}
|
||||
};
|
||||
return d;
|
||||
},
|
||||
|
||||
callLater: function (seconds, func) {
|
||||
var m = MochiKit.Base;
|
||||
var pfunc = m.partial.apply(m, m.extend(null, arguments, 1));
|
||||
return MochiKit.Async.wait(seconds).addCallback(
|
||||
function (res) { return pfunc(); }
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
MochiKit.Async.DeferredLock = function () {
|
||||
this.waiting = [];
|
||||
this.locked = false;
|
||||
this.id = this._nextId();
|
||||
};
|
||||
|
||||
MochiKit.Async.DeferredLock.prototype = {
|
||||
__class__: MochiKit.Async.DeferredLock,
|
||||
acquire: function () {
|
||||
d = new MochiKit.Async.Deferred();
|
||||
if (this.locked) {
|
||||
this.waiting.push(d);
|
||||
} else {
|
||||
this.locked = true;
|
||||
d.callback(this);
|
||||
}
|
||||
return d;
|
||||
},
|
||||
release: function () {
|
||||
if (!this.locked) {
|
||||
throw TypeError("Tried to release an unlocked DeferredLock");
|
||||
}
|
||||
this.locked = false;
|
||||
if (this.waiting.length > 0) {
|
||||
this.locked = true;
|
||||
this.waiting.shift().callback(this);
|
||||
}
|
||||
},
|
||||
_nextId: MochiKit.Base.counter(),
|
||||
repr: function () {
|
||||
var state;
|
||||
if (this.locked) {
|
||||
state = 'locked, ' + this.waiting.length + ' waiting';
|
||||
} else {
|
||||
state = 'unlocked';
|
||||
}
|
||||
return 'DeferredLock(' + this.id + ', ' + state + ')';
|
||||
},
|
||||
toString: MochiKit.Base.forwardCall("repr")
|
||||
|
||||
};
|
||||
|
||||
MochiKit.Async.DeferredList = function (list, /* optional */fireOnOneCallback, fireOnOneErrback, consumeErrors, canceller) {
|
||||
|
||||
// call parent constructor
|
||||
MochiKit.Async.Deferred.apply(this, [canceller]);
|
||||
|
||||
this.list = list;
|
||||
var resultList = [];
|
||||
this.resultList = resultList;
|
||||
|
||||
this.finishedCount = 0;
|
||||
this.fireOnOneCallback = fireOnOneCallback;
|
||||
this.fireOnOneErrback = fireOnOneErrback;
|
||||
this.consumeErrors = consumeErrors;
|
||||
|
||||
var cb = MochiKit.Base.bind(this._cbDeferred, this);
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
var d = list[i];
|
||||
resultList.push(undefined);
|
||||
d.addCallback(cb, i, true);
|
||||
d.addErrback(cb, i, false);
|
||||
}
|
||||
|
||||
if (list.length === 0 && !fireOnOneCallback) {
|
||||
this.callback(this.resultList);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
MochiKit.Async.DeferredList.prototype = new MochiKit.Async.Deferred();
|
||||
|
||||
MochiKit.Async.DeferredList.prototype._cbDeferred = function (index, succeeded, result) {
|
||||
this.resultList[index] = [succeeded, result];
|
||||
this.finishedCount += 1;
|
||||
if (this.fired !== 0) {
|
||||
if (succeeded && this.fireOnOneCallback) {
|
||||
this.callback([index, result]);
|
||||
} else if (!succeeded && this.fireOnOneErrback) {
|
||||
this.errback(result);
|
||||
} else if (this.finishedCount == this.list.length) {
|
||||
this.callback(this.resultList);
|
||||
}
|
||||
}
|
||||
if (!succeeded && this.consumeErrors) {
|
||||
result = null;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
MochiKit.Async.gatherResults = function (deferredList) {
|
||||
var d = new MochiKit.Async.DeferredList(deferredList, false, true, false);
|
||||
d.addCallback(function (results) {
|
||||
var ret = [];
|
||||
for (var i = 0; i < results.length; i++) {
|
||||
ret.push(results[i][1]);
|
||||
}
|
||||
return ret;
|
||||
});
|
||||
return d;
|
||||
};
|
||||
|
||||
MochiKit.Async.maybeDeferred = function (func) {
|
||||
var self = MochiKit.Async;
|
||||
var result;
|
||||
try {
|
||||
var r = func.apply(null, MochiKit.Base.extend([], arguments, 1));
|
||||
if (r instanceof self.Deferred) {
|
||||
result = r;
|
||||
} else if (r instanceof Error) {
|
||||
result = self.fail(r);
|
||||
} else {
|
||||
result = self.succeed(r);
|
||||
}
|
||||
} catch (e) {
|
||||
result = self.fail(e);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
|
||||
MochiKit.Async.EXPORT = [
|
||||
"AlreadyCalledError",
|
||||
"CancelledError",
|
||||
"BrowserComplianceError",
|
||||
"GenericError",
|
||||
"XMLHttpRequestError",
|
||||
"Deferred",
|
||||
"succeed",
|
||||
"fail",
|
||||
"getXMLHttpRequest",
|
||||
"doSimpleXMLHttpRequest",
|
||||
"loadJSONDoc",
|
||||
"wait",
|
||||
"callLater",
|
||||
"sendXMLHttpRequest",
|
||||
"DeferredLock",
|
||||
"DeferredList",
|
||||
"gatherResults",
|
||||
"maybeDeferred"
|
||||
];
|
||||
|
||||
MochiKit.Async.EXPORT_OK = [
|
||||
"evalJSONRequest"
|
||||
];
|
||||
|
||||
MochiKit.Async.__new__ = function () {
|
||||
var m = MochiKit.Base;
|
||||
var ne = m.partial(m._newNamedError, this);
|
||||
ne("AlreadyCalledError",
|
||||
function (deferred) {
|
||||
/***
|
||||
|
||||
Raised by the Deferred if callback or errback happens
|
||||
after it was already fired.
|
||||
|
||||
***/
|
||||
this.deferred = deferred;
|
||||
}
|
||||
);
|
||||
|
||||
ne("CancelledError",
|
||||
function (deferred) {
|
||||
/***
|
||||
|
||||
Raised by the Deferred cancellation mechanism.
|
||||
|
||||
***/
|
||||
this.deferred = deferred;
|
||||
}
|
||||
);
|
||||
|
||||
ne("BrowserComplianceError",
|
||||
function (msg) {
|
||||
/***
|
||||
|
||||
Raised when the JavaScript runtime is not capable of performing
|
||||
the given function. Technically, this should really never be
|
||||
raised because a non-conforming JavaScript runtime probably
|
||||
isn't going to support exceptions in the first place.
|
||||
|
||||
***/
|
||||
this.message = msg;
|
||||
}
|
||||
);
|
||||
|
||||
ne("GenericError",
|
||||
function (msg) {
|
||||
this.message = msg;
|
||||
}
|
||||
);
|
||||
|
||||
ne("XMLHttpRequestError",
|
||||
function (req, msg) {
|
||||
/***
|
||||
|
||||
Raised when an XMLHttpRequest does not complete for any reason.
|
||||
|
||||
***/
|
||||
this.req = req;
|
||||
this.message = msg;
|
||||
try {
|
||||
// Strange but true that this can raise in some cases.
|
||||
this.number = req.status;
|
||||
} catch (e) {
|
||||
// pass
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
this.EXPORT_TAGS = {
|
||||
":common": this.EXPORT,
|
||||
":all": m.concat(this.EXPORT, this.EXPORT_OK)
|
||||
};
|
||||
|
||||
m.nameFunctions(this);
|
||||
|
||||
};
|
||||
|
||||
MochiKit.Async.__new__();
|
||||
|
||||
MochiKit.Base._exportSymbols(this, MochiKit.Async);
|
||||
1259
crystalreportviewers13/js/MochiKit/Base.js
Normal file
845
crystalreportviewers13/js/MochiKit/Color.js
Normal file
@@ -0,0 +1,845 @@
|
||||
/***
|
||||
|
||||
MochiKit.Color 1.4
|
||||
|
||||
See <http://mochikit.com/> for documentation, downloads, license, etc.
|
||||
|
||||
(c) 2005 Bob Ippolito and others. All rights Reserved.
|
||||
|
||||
***/
|
||||
|
||||
if (typeof(dojo) != 'undefined') {
|
||||
dojo.provide('MochiKit.Color');
|
||||
dojo.require('MochiKit.Base');
|
||||
dojo.require('MochiKit.DOM');
|
||||
dojo.require('MochiKit.Style');
|
||||
}
|
||||
|
||||
if (typeof(JSAN) != 'undefined') {
|
||||
JSAN.use("MochiKit.Base", []);
|
||||
JSAN.use("MochiKit.DOM", []);
|
||||
JSAN.use("MochiKit.Style", []);
|
||||
}
|
||||
|
||||
try {
|
||||
if (typeof(MochiKit.Base) == 'undefined') {
|
||||
throw "";
|
||||
}
|
||||
} catch (e) {
|
||||
throw "MochiKit.Color depends on MochiKit.Base";
|
||||
}
|
||||
|
||||
try {
|
||||
if (typeof(MochiKit.Base) == 'undefined') {
|
||||
throw "";
|
||||
}
|
||||
} catch (e) {
|
||||
throw "MochiKit.Color depends on MochiKit.DOM";
|
||||
}
|
||||
|
||||
try {
|
||||
if (typeof(MochiKit.Base) == 'undefined') {
|
||||
throw "";
|
||||
}
|
||||
} catch (e) {
|
||||
throw "MochiKit.Color depends on MochiKit.Style";
|
||||
}
|
||||
|
||||
if (typeof(MochiKit.Color) == "undefined") {
|
||||
MochiKit.Color = {};
|
||||
}
|
||||
|
||||
MochiKit.Color.NAME = "MochiKit.Color";
|
||||
MochiKit.Color.VERSION = "1.4";
|
||||
|
||||
MochiKit.Color.__repr__ = function () {
|
||||
return "[" + this.NAME + " " + this.VERSION + "]";
|
||||
};
|
||||
|
||||
MochiKit.Color.toString = function () {
|
||||
return this.__repr__();
|
||||
};
|
||||
|
||||
|
||||
MochiKit.Color.Color = function (red, green, blue, alpha) {
|
||||
if (typeof(alpha) == 'undefined' || alpha === null) {
|
||||
alpha = 1.0;
|
||||
}
|
||||
this.rgb = {
|
||||
r: red,
|
||||
g: green,
|
||||
b: blue,
|
||||
a: alpha
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
// Prototype methods
|
||||
MochiKit.Color.Color.prototype = {
|
||||
|
||||
__class__: MochiKit.Color.Color,
|
||||
|
||||
// colorWithAlpha: function (alpha) {
|
||||
// var rgb = this.rgb;
|
||||
// var m = MochiKit.Color;
|
||||
// return m.Color.fromRGB(rgb.r, rgb.g, rgb.b, alpha);
|
||||
// },
|
||||
//
|
||||
// colorWithHue: function (hue) {
|
||||
// // get an HSL model, and set the new hue...
|
||||
// var hsl = this.asHSL();
|
||||
// hsl.h = hue;
|
||||
// var m = MochiKit.Color;
|
||||
// // convert back to RGB...
|
||||
// return m.Color.fromHSL(hsl);
|
||||
// },
|
||||
//
|
||||
// colorWithSaturation: function (saturation) {
|
||||
// // get an HSL model, and set the new hue...
|
||||
// var hsl = this.asHSL();
|
||||
// hsl.s = saturation;
|
||||
// var m = MochiKit.Color;
|
||||
// // convert back to RGB...
|
||||
// return m.Color.fromHSL(hsl);
|
||||
// },
|
||||
//
|
||||
// colorWithLightness: function (lightness) {
|
||||
// // get an HSL model, and set the new hue...
|
||||
// var hsl = this.asHSL();
|
||||
// hsl.l = lightness;
|
||||
// var m = MochiKit.Color;
|
||||
// // convert back to RGB...
|
||||
// return m.Color.fromHSL(hsl);
|
||||
// },
|
||||
//
|
||||
// darkerColorWithLevel: function (level) {
|
||||
// var hsl = this.asHSL();
|
||||
// hsl.l = Math.max(hsl.l - level, 0);
|
||||
// var m = MochiKit.Color;
|
||||
// return m.Color.fromHSL(hsl);
|
||||
// },
|
||||
//
|
||||
// lighterColorWithLevel: function (level) {
|
||||
// var hsl = this.asHSL();
|
||||
// hsl.l = Math.min(hsl.l + level, 1);
|
||||
// var m = MochiKit.Color;
|
||||
// return m.Color.fromHSL(hsl);
|
||||
// },
|
||||
//
|
||||
// blendedColor: function (other, /* optional */ fraction) {
|
||||
// if (typeof(fraction) == 'undefined' || fraction === null) {
|
||||
// fraction = 0.5;
|
||||
// }
|
||||
// var sf = 1.0 - fraction;
|
||||
// var s = this.rgb;
|
||||
// var d = other.rgb;
|
||||
// var df = fraction;
|
||||
// return MochiKit.Color.Color.fromRGB(
|
||||
// (s.r * sf) + (d.r * df),
|
||||
// (s.g * sf) + (d.g * df),
|
||||
// (s.b * sf) + (d.b * df),
|
||||
// (s.a * sf) + (d.a * df)
|
||||
// );
|
||||
// },
|
||||
//
|
||||
// compareRGB: function (other) {
|
||||
// var a = this.asRGB();
|
||||
// var b = other.asRGB();
|
||||
// return MochiKit.Base.compare(
|
||||
// [a.r, a.g, a.b, a.a],
|
||||
// [b.r, b.g, b.b, b.a]
|
||||
// );
|
||||
// },
|
||||
//
|
||||
// isLight: function () {
|
||||
// return this.asHSL().b > 0.5;
|
||||
// },
|
||||
//
|
||||
// isDark: function () {
|
||||
// return (!this.isLight());
|
||||
// },
|
||||
//
|
||||
// toHSLString: function () {
|
||||
// var c = this.asHSL();
|
||||
// var ccc = MochiKit.Color.clampColorComponent;
|
||||
// var rval = this._hslString;
|
||||
// if (!rval) {
|
||||
// var mid = (
|
||||
// ccc(c.h, 360).toFixed(0)
|
||||
// + "," + ccc(c.s, 100).toPrecision(4) + "%"
|
||||
// + "," + ccc(c.l, 100).toPrecision(4) + "%"
|
||||
// );
|
||||
// var a = c.a;
|
||||
// if (a >= 1) {
|
||||
// a = 1;
|
||||
// rval = "hsl(" + mid + ")";
|
||||
// } else {
|
||||
// if (a <= 0) {
|
||||
// a = 0;
|
||||
// }
|
||||
// rval = "hsla(" + mid + "," + a + ")";
|
||||
// }
|
||||
// this._hslString = rval;
|
||||
// }
|
||||
// return rval;
|
||||
// },
|
||||
//
|
||||
// toRGBString: function () {
|
||||
// var c = this.rgb;
|
||||
// var ccc = MochiKit.Color.clampColorComponent;
|
||||
// var rval = this._rgbString;
|
||||
// if (!rval) {
|
||||
// var mid = (
|
||||
// ccc(c.r, 255).toFixed(0)
|
||||
// + "," + ccc(c.g, 255).toFixed(0)
|
||||
// + "," + ccc(c.b, 255).toFixed(0)
|
||||
// );
|
||||
// if (c.a != 1) {
|
||||
// rval = "rgba(" + mid + "," + c.a + ")";
|
||||
// } else {
|
||||
// rval = "rgb(" + mid + ")";
|
||||
// }
|
||||
// this._rgbString = rval;
|
||||
// }
|
||||
// return rval;
|
||||
// },
|
||||
//
|
||||
// asRGB: function () {
|
||||
// return MochiKit.Base.clone(this.rgb);
|
||||
// },
|
||||
//
|
||||
// toHexString: function () {
|
||||
// var m = MochiKit.Color;
|
||||
// var c = this.rgb;
|
||||
// var ccc = MochiKit.Color.clampColorComponent;
|
||||
// var rval = this._hexString;
|
||||
// if (!rval) {
|
||||
// rval = ("#" +
|
||||
// m.toColorPart(ccc(c.r, 255)) +
|
||||
// m.toColorPart(ccc(c.g, 255)) +
|
||||
// m.toColorPart(ccc(c.b, 255))
|
||||
// );
|
||||
// this._hexString = rval;
|
||||
// }
|
||||
// return rval;
|
||||
// },
|
||||
//
|
||||
// asHSV: function () {
|
||||
// var hsv = this.hsv;
|
||||
// var c = this.rgb;
|
||||
// if (typeof(hsv) == 'undefined' || hsv === null) {
|
||||
// hsv = MochiKit.Color.rgbToHSV(this.rgb);
|
||||
// this.hsv = hsv;
|
||||
// }
|
||||
// return MochiKit.Base.clone(hsv);
|
||||
// },
|
||||
//
|
||||
// asHSL: function () {
|
||||
// var hsl = this.hsl;
|
||||
// var c = this.rgb;
|
||||
// if (typeof(hsl) == 'undefined' || hsl === null) {
|
||||
// hsl = MochiKit.Color.rgbToHSL(this.rgb);
|
||||
// this.hsl = hsl;
|
||||
// }
|
||||
// return MochiKit.Base.clone(hsl);
|
||||
// },
|
||||
|
||||
toString: function () {
|
||||
return this.toRGBString();
|
||||
},
|
||||
|
||||
repr: function () {
|
||||
var c = this.rgb;
|
||||
var col = [c.r, c.g, c.b, c.a];
|
||||
return this.__class__.NAME + "(" + col.join(", ") + ")";
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// Constructor methods
|
||||
MochiKit.Base.update(MochiKit.Color.Color, {
|
||||
// fromRGB: function (red, green, blue, alpha) {
|
||||
// // designated initializer
|
||||
// var Color = MochiKit.Color.Color;
|
||||
// if (arguments.length == 1) {
|
||||
// var rgb = red;
|
||||
// red = rgb.r;
|
||||
// green = rgb.g;
|
||||
// blue = rgb.b;
|
||||
// if (typeof(rgb.a) == 'undefined') {
|
||||
// alpha = undefined;
|
||||
// } else {
|
||||
// alpha = rgb.a;
|
||||
// }
|
||||
// }
|
||||
// return new Color(red, green, blue, alpha);
|
||||
// },
|
||||
//
|
||||
// fromHSL: function (hue, saturation, lightness, alpha) {
|
||||
// var m = MochiKit.Color;
|
||||
// return m.Color.fromRGB(m.hslToRGB.apply(m, arguments));
|
||||
// },
|
||||
//
|
||||
// fromHSV: function (hue, saturation, value, alpha) {
|
||||
// var m = MochiKit.Color;
|
||||
// return m.Color.fromRGB(m.hsvToRGB.apply(m, arguments));
|
||||
// },
|
||||
//
|
||||
// fromName: function (name) {
|
||||
// var Color = MochiKit.Color.Color;
|
||||
// // Opera 9 seems to "quote" named colors(?!)
|
||||
// if (name.charAt(0) == '"') {
|
||||
// name = name.substr(1, name.length - 2);
|
||||
// }
|
||||
// var htmlColor = Color._namedColors[name.toLowerCase()];
|
||||
// if (typeof(htmlColor) == 'string') {
|
||||
// return Color.fromHexString(htmlColor);
|
||||
// } else if (name == "transparent") {
|
||||
// return Color.transparentColor();
|
||||
// }
|
||||
// return null;
|
||||
// },
|
||||
//
|
||||
// fromString: function (colorString) {
|
||||
// var self = MochiKit.Color.Color;
|
||||
// var three = colorString.substr(0, 3);
|
||||
// if (three == "rgb") {
|
||||
// return self.fromRGBString(colorString);
|
||||
// } else if (three == "hsl") {
|
||||
// return self.fromHSLString(colorString);
|
||||
// } else if (colorString.charAt(0) == "#") {
|
||||
// return self.fromHexString(colorString);
|
||||
// }
|
||||
// return self.fromName(colorString);
|
||||
// },
|
||||
//
|
||||
//
|
||||
// fromHexString: function (hexCode) {
|
||||
// if (hexCode.charAt(0) == '#') {
|
||||
// hexCode = hexCode.substring(1);
|
||||
// }
|
||||
// var components = [];
|
||||
// var i, hex;
|
||||
// if (hexCode.length == 3) {
|
||||
// for (i = 0; i < 3; i++) {
|
||||
// hex = hexCode.substr(i, 1);
|
||||
// components.push(parseInt(hex + hex, 16) / 255.0);
|
||||
// }
|
||||
// } else {
|
||||
// for (i = 0; i < 6; i += 2) {
|
||||
// hex = hexCode.substr(i, 2);
|
||||
// components.push(parseInt(hex, 16) / 255.0);
|
||||
// }
|
||||
// }
|
||||
// var Color = MochiKit.Color.Color;
|
||||
// return Color.fromRGB.apply(Color, components);
|
||||
// },
|
||||
//
|
||||
//
|
||||
// _fromColorString: function (pre, method, scales, colorCode) {
|
||||
// // parses either HSL or RGB
|
||||
// if (colorCode.indexOf(pre) === 0) {
|
||||
// colorCode = colorCode.substring(colorCode.indexOf("(", 3) + 1, colorCode.length - 1);
|
||||
// }
|
||||
// var colorChunks = colorCode.split(/\s*,\s*/);
|
||||
// var colorFloats = [];
|
||||
// for (var i = 0; i < colorChunks.length; i++) {
|
||||
// var c = colorChunks[i];
|
||||
// var val;
|
||||
// var three = c.substring(c.length - 3);
|
||||
// if (c.charAt(c.length - 1) == '%') {
|
||||
// val = 0.01 * parseFloat(c.substring(0, c.length - 1));
|
||||
// } else if (three == "deg") {
|
||||
// val = parseFloat(c) / 360.0;
|
||||
// } else if (three == "rad") {
|
||||
// val = parseFloat(c) / (Math.PI * 2);
|
||||
// } else {
|
||||
// val = scales[i] * parseFloat(c);
|
||||
// }
|
||||
// colorFloats.push(val);
|
||||
// }
|
||||
// return this[method].apply(this, colorFloats);
|
||||
// },
|
||||
|
||||
fromComputedStyle: function (elem, style) {
|
||||
var d = MochiKit.DOM;
|
||||
var cls = MochiKit.Color.Color;
|
||||
for (elem = d.getElement(elem); elem; elem = elem.parentNode) {
|
||||
var actualColor = MochiKit.Style.computedStyle.apply(d, arguments);
|
||||
if (!actualColor) {
|
||||
continue;
|
||||
}
|
||||
var color = cls.fromString(actualColor);
|
||||
if (!color) {
|
||||
break;
|
||||
}
|
||||
if (color.asRGB().a > 0) {
|
||||
return color;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
fromBackground: function (elem) {
|
||||
var cls = MochiKit.Color.Color;
|
||||
return cls.fromComputedStyle(
|
||||
elem, "backgroundColor", "background-color") || cls.whiteColor();
|
||||
},
|
||||
|
||||
fromText: function (elem) {
|
||||
var cls = MochiKit.Color.Color;
|
||||
return cls.fromComputedStyle(
|
||||
elem, "color", "color") || cls.blackColor();
|
||||
},
|
||||
|
||||
namedColors: function () {
|
||||
return MochiKit.Base.clone(MochiKit.Color.Color._namedColors);
|
||||
}
|
||||
});
|
||||
|
||||
// Module level functions
|
||||
MochiKit.Base.update(MochiKit.Color, {
|
||||
// clampColorComponent: function (v, scale) {
|
||||
// v *= scale;
|
||||
// if (v < 0) {
|
||||
// return 0;
|
||||
// } else if (v > scale) {
|
||||
// return scale;
|
||||
// } else {
|
||||
// return v;
|
||||
// }
|
||||
// },
|
||||
//
|
||||
// _hslValue: function (n1, n2, hue) {
|
||||
// if (hue > 6.0) {
|
||||
// hue -= 6.0;
|
||||
// } else if (hue < 0.0) {
|
||||
// hue += 6.0;
|
||||
// }
|
||||
// var val;
|
||||
// if (hue < 1.0) {
|
||||
// val = n1 + (n2 - n1) * hue;
|
||||
// } else if (hue < 3.0) {
|
||||
// val = n2;
|
||||
// } else if (hue < 4.0) {
|
||||
// val = n1 + (n2 - n1) * (4.0 - hue);
|
||||
// } else {
|
||||
// val = n1;
|
||||
// }
|
||||
// return val;
|
||||
// },
|
||||
//
|
||||
// hsvToRGB: function (hue, saturation, value, alpha) {
|
||||
// if (arguments.length == 1) {
|
||||
// var hsv = hue;
|
||||
// hue = hsv.h;
|
||||
// saturation = hsv.s;
|
||||
// value = hsv.v;
|
||||
// alpha = hsv.a;
|
||||
// }
|
||||
// var red;
|
||||
// var green;
|
||||
// var blue;
|
||||
// if (saturation === 0) {
|
||||
// red = 0;
|
||||
// green = 0;
|
||||
// blue = 0;
|
||||
// } else {
|
||||
// var i = Math.floor(hue * 6);
|
||||
// var f = (hue * 6) - i;
|
||||
// var p = value * (1 - saturation);
|
||||
// var q = value * (1 - (saturation * f));
|
||||
// var t = value * (1 - (saturation * (1 - f)));
|
||||
// switch (i) {
|
||||
// case 1: red = q; green = value; blue = p; break;
|
||||
// case 2: red = p; green = value; blue = t; break;
|
||||
// case 3: red = p; green = q; blue = value; break;
|
||||
// case 4: red = t; green = p; blue = value; break;
|
||||
// case 5: red = value; green = p; blue = q; break;
|
||||
// case 6: // fall through
|
||||
// case 0: red = value; green = t; blue = p; break;
|
||||
// }
|
||||
// }
|
||||
// return {
|
||||
// r: red,
|
||||
// g: green,
|
||||
// b: blue,
|
||||
// a: alpha
|
||||
// };
|
||||
// },
|
||||
//
|
||||
// hslToRGB: function (hue, saturation, lightness, alpha) {
|
||||
// if (arguments.length == 1) {
|
||||
// var hsl = hue;
|
||||
// hue = hsl.h;
|
||||
// saturation = hsl.s;
|
||||
// lightness = hsl.l;
|
||||
// alpha = hsl.a;
|
||||
// }
|
||||
// var red;
|
||||
// var green;
|
||||
// var blue;
|
||||
// if (saturation === 0) {
|
||||
// red = lightness;
|
||||
// green = lightness;
|
||||
// blue = lightness;
|
||||
// } else {
|
||||
// var m2;
|
||||
// if (lightness <= 0.5) {
|
||||
// m2 = lightness * (1.0 + saturation);
|
||||
// } else {
|
||||
// m2 = lightness + saturation - (lightness * saturation);
|
||||
// }
|
||||
// var m1 = (2.0 * lightness) - m2;
|
||||
// var f = MochiKit.Color._hslValue;
|
||||
// var h6 = hue * 6.0;
|
||||
// red = f(m1, m2, h6 + 2);
|
||||
// green = f(m1, m2, h6);
|
||||
// blue = f(m1, m2, h6 - 2);
|
||||
// }
|
||||
// return {
|
||||
// r: red,
|
||||
// g: green,
|
||||
// b: blue,
|
||||
// a: alpha
|
||||
// };
|
||||
// },
|
||||
//
|
||||
// rgbToHSV: function (red, green, blue, alpha) {
|
||||
// if (arguments.length == 1) {
|
||||
// var rgb = red;
|
||||
// red = rgb.r;
|
||||
// green = rgb.g;
|
||||
// blue = rgb.b;
|
||||
// alpha = rgb.a;
|
||||
// }
|
||||
// var max = Math.max(Math.max(red, green), blue);
|
||||
// var min = Math.min(Math.min(red, green), blue);
|
||||
// var hue;
|
||||
// var saturation;
|
||||
// var value = max;
|
||||
// if (min == max) {
|
||||
// hue = 0;
|
||||
// saturation = 0;
|
||||
// } else {
|
||||
// var delta = (max - min);
|
||||
// saturation = delta / max;
|
||||
//
|
||||
// if (red == max) {
|
||||
// hue = (green - blue) / delta;
|
||||
// } else if (green == max) {
|
||||
// hue = 2 + ((blue - red) / delta);
|
||||
// } else {
|
||||
// hue = 4 + ((red - green) / delta);
|
||||
// }
|
||||
// hue /= 6;
|
||||
// if (hue < 0) {
|
||||
// hue += 1;
|
||||
// }
|
||||
// if (hue > 1) {
|
||||
// hue -= 1;
|
||||
// }
|
||||
// }
|
||||
// return {
|
||||
// h: hue,
|
||||
// s: saturation,
|
||||
// v: value,
|
||||
// a: alpha
|
||||
// };
|
||||
// },
|
||||
//
|
||||
// rgbToHSL: function (red, green, blue, alpha) {
|
||||
// if (arguments.length == 1) {
|
||||
// var rgb = red;
|
||||
// red = rgb.r;
|
||||
// green = rgb.g;
|
||||
// blue = rgb.b;
|
||||
// alpha = rgb.a;
|
||||
// }
|
||||
// var max = Math.max(red, Math.max(green, blue));
|
||||
// var min = Math.min(red, Math.min(green, blue));
|
||||
// var hue;
|
||||
// var saturation;
|
||||
// var lightness = (max + min) / 2.0;
|
||||
// var delta = max - min;
|
||||
// if (delta === 0) {
|
||||
// hue = 0;
|
||||
// saturation = 0;
|
||||
// } else {
|
||||
// if (lightness <= 0.5) {
|
||||
// saturation = delta / (max + min);
|
||||
// } else {
|
||||
// saturation = delta / (2 - max - min);
|
||||
// }
|
||||
// if (red == max) {
|
||||
// hue = (green - blue) / delta;
|
||||
// } else if (green == max) {
|
||||
// hue = 2 + ((blue - red) / delta);
|
||||
// } else {
|
||||
// hue = 4 + ((red - green) / delta);
|
||||
// }
|
||||
// hue /= 6;
|
||||
// if (hue < 0) {
|
||||
// hue += 1;
|
||||
// }
|
||||
// if (hue > 1) {
|
||||
// hue -= 1;
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// return {
|
||||
// h: hue,
|
||||
// s: saturation,
|
||||
// l: lightness,
|
||||
// a: alpha
|
||||
// };
|
||||
// },
|
||||
//
|
||||
// toColorPart: function (num) {
|
||||
// num = Math.round(num);
|
||||
// var digits = num.toString(16);
|
||||
// if (num < 16) {
|
||||
// return '0' + digits;
|
||||
// }
|
||||
// return digits;
|
||||
// },
|
||||
|
||||
__new__: function () {
|
||||
var m = MochiKit.Base;
|
||||
// this.Color.fromRGBString = m.bind(
|
||||
// this.Color._fromColorString, this.Color, "rgb", "fromRGB",
|
||||
// [1.0/255.0, 1.0/255.0, 1.0/255.0, 1]
|
||||
// );
|
||||
// this.Color.fromHSLString = m.bind(
|
||||
// this.Color._fromColorString, this.Color, "hsl", "fromHSL",
|
||||
// [1.0/360.0, 0.01, 0.01, 1]
|
||||
// );
|
||||
//
|
||||
// var third = 1.0 / 3.0;
|
||||
// var colors = {
|
||||
// // NSColor colors plus transparent
|
||||
// black: [0, 0, 0],
|
||||
// blue: [0, 0, 1],
|
||||
// brown: [0.6, 0.4, 0.2],
|
||||
// cyan: [0, 1, 1],
|
||||
// darkGray: [third, third, third],
|
||||
// gray: [0.5, 0.5, 0.5],
|
||||
// green: [0, 1, 0],
|
||||
// lightGray: [2 * third, 2 * third, 2 * third],
|
||||
// magenta: [1, 0, 1],
|
||||
// orange: [1, 0.5, 0],
|
||||
// purple: [0.5, 0, 0.5],
|
||||
// red: [1, 0, 0],
|
||||
// transparent: [0, 0, 0, 0],
|
||||
// white: [1, 1, 1],
|
||||
// yellow: [1, 1, 0]
|
||||
// };
|
||||
//
|
||||
// var makeColor = function (name, r, g, b, a) {
|
||||
// var rval = this.fromRGB(r, g, b, a);
|
||||
// this[name] = function () { return rval; };
|
||||
// return rval;
|
||||
// };
|
||||
//
|
||||
// for (var k in colors) {
|
||||
// var name = k + "Color";
|
||||
// var bindArgs = m.concat(
|
||||
// [makeColor, this.Color, name],
|
||||
// colors[k]
|
||||
// );
|
||||
// this.Color[name] = m.bind.apply(null, bindArgs);
|
||||
// }
|
||||
//
|
||||
// var isColor = function () {
|
||||
// for (var i = 0; i < arguments.length; i++) {
|
||||
// if (!(arguments[i] instanceof Color)) {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// return true;
|
||||
// };
|
||||
//
|
||||
// var compareColor = function (a, b) {
|
||||
// return a.compareRGB(b);
|
||||
// };
|
||||
|
||||
m.nameFunctions(this);
|
||||
|
||||
// m.registerComparator(this.Color.NAME, isColor, compareColor);
|
||||
|
||||
this.EXPORT_TAGS = {
|
||||
":common": this.EXPORT,
|
||||
":all": m.concat(this.EXPORT, this.EXPORT_OK)
|
||||
};
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
MochiKit.Color.EXPORT = [
|
||||
"Color"
|
||||
];
|
||||
|
||||
MochiKit.Color.EXPORT_OK = [
|
||||
"clampColorComponent",
|
||||
"rgbToHSL",
|
||||
"hslToRGB",
|
||||
"rgbToHSV",
|
||||
"hsvToRGB",
|
||||
"toColorPart"
|
||||
];
|
||||
|
||||
MochiKit.Color.__new__();
|
||||
|
||||
MochiKit.Base._exportSymbols(this, MochiKit.Color);
|
||||
|
||||
// Full table of css3 X11 colors <http://www.w3.org/TR/css3-color/#X11COLORS>
|
||||
|
||||
//MochiKit.Color.Color._namedColors = {
|
||||
// aliceblue: "#f0f8ff",
|
||||
// antiquewhite: "#faebd7",
|
||||
// aqua: "#00ffff",
|
||||
// aquamarine: "#7fffd4",
|
||||
// azure: "#f0ffff",
|
||||
// beige: "#f5f5dc",
|
||||
// bisque: "#ffe4c4",
|
||||
// black: "#000000",
|
||||
// blanchedalmond: "#ffebcd",
|
||||
// blue: "#0000ff",
|
||||
// blueviolet: "#8a2be2",
|
||||
// brown: "#a52a2a",
|
||||
// burlywood: "#deb887",
|
||||
// cadetblue: "#5f9ea0",
|
||||
// chartreuse: "#7fff00",
|
||||
// chocolate: "#d2691e",
|
||||
// coral: "#ff7f50",
|
||||
// cornflowerblue: "#6495ed",
|
||||
// cornsilk: "#fff8dc",
|
||||
// crimson: "#dc143c",
|
||||
// cyan: "#00ffff",
|
||||
// darkblue: "#00008b",
|
||||
// darkcyan: "#008b8b",
|
||||
// darkgoldenrod: "#b8860b",
|
||||
// darkgray: "#a9a9a9",
|
||||
// darkgreen: "#006400",
|
||||
// darkgrey: "#a9a9a9",
|
||||
// darkkhaki: "#bdb76b",
|
||||
// darkmagenta: "#8b008b",
|
||||
// darkolivegreen: "#556b2f",
|
||||
// darkorange: "#ff8c00",
|
||||
// darkorchid: "#9932cc",
|
||||
// darkred: "#8b0000",
|
||||
// darksalmon: "#e9967a",
|
||||
// darkseagreen: "#8fbc8f",
|
||||
// darkslateblue: "#483d8b",
|
||||
// darkslategray: "#2f4f4f",
|
||||
// darkslategrey: "#2f4f4f",
|
||||
// darkturquoise: "#00ced1",
|
||||
// darkviolet: "#9400d3",
|
||||
// deeppink: "#ff1493",
|
||||
// deepskyblue: "#00bfff",
|
||||
// dimgray: "#696969",
|
||||
// dimgrey: "#696969",
|
||||
// dodgerblue: "#1e90ff",
|
||||
// firebrick: "#b22222",
|
||||
// floralwhite: "#fffaf0",
|
||||
// forestgreen: "#228b22",
|
||||
// fuchsia: "#ff00ff",
|
||||
// gainsboro: "#dcdcdc",
|
||||
// ghostwhite: "#f8f8ff",
|
||||
// gold: "#ffd700",
|
||||
// goldenrod: "#daa520",
|
||||
// gray: "#808080",
|
||||
// green: "#008000",
|
||||
// greenyellow: "#adff2f",
|
||||
// grey: "#808080",
|
||||
// honeydew: "#f0fff0",
|
||||
// hotpink: "#ff69b4",
|
||||
// indianred: "#cd5c5c",
|
||||
// indigo: "#4b0082",
|
||||
// ivory: "#fffff0",
|
||||
// khaki: "#f0e68c",
|
||||
// lavender: "#e6e6fa",
|
||||
// lavenderblush: "#fff0f5",
|
||||
// lawngreen: "#7cfc00",
|
||||
// lemonchiffon: "#fffacd",
|
||||
// lightblue: "#add8e6",
|
||||
// lightcoral: "#f08080",
|
||||
// lightcyan: "#e0ffff",
|
||||
// lightgoldenrodyellow: "#fafad2",
|
||||
// lightgray: "#d3d3d3",
|
||||
// lightgreen: "#90ee90",
|
||||
// lightgrey: "#d3d3d3",
|
||||
// lightpink: "#ffb6c1",
|
||||
// lightsalmon: "#ffa07a",
|
||||
// lightseagreen: "#20b2aa",
|
||||
// lightskyblue: "#87cefa",
|
||||
// lightslategray: "#778899",
|
||||
// lightslategrey: "#778899",
|
||||
// lightsteelblue: "#b0c4de",
|
||||
// lightyellow: "#ffffe0",
|
||||
// lime: "#00ff00",
|
||||
// limegreen: "#32cd32",
|
||||
// linen: "#faf0e6",
|
||||
// magenta: "#ff00ff",
|
||||
// maroon: "#800000",
|
||||
// mediumaquamarine: "#66cdaa",
|
||||
// mediumblue: "#0000cd",
|
||||
// mediumorchid: "#ba55d3",
|
||||
// mediumpurple: "#9370db",
|
||||
// mediumseagreen: "#3cb371",
|
||||
// mediumslateblue: "#7b68ee",
|
||||
// mediumspringgreen: "#00fa9a",
|
||||
// mediumturquoise: "#48d1cc",
|
||||
// mediumvioletred: "#c71585",
|
||||
// midnightblue: "#191970",
|
||||
// mintcream: "#f5fffa",
|
||||
// mistyrose: "#ffe4e1",
|
||||
// moccasin: "#ffe4b5",
|
||||
// navajowhite: "#ffdead",
|
||||
// navy: "#000080",
|
||||
// oldlace: "#fdf5e6",
|
||||
// olive: "#808000",
|
||||
// olivedrab: "#6b8e23",
|
||||
// orange: "#ffa500",
|
||||
// orangered: "#ff4500",
|
||||
// orchid: "#da70d6",
|
||||
// palegoldenrod: "#eee8aa",
|
||||
// palegreen: "#98fb98",
|
||||
// paleturquoise: "#afeeee",
|
||||
// palevioletred: "#db7093",
|
||||
// papayawhip: "#ffefd5",
|
||||
// peachpuff: "#ffdab9",
|
||||
// peru: "#cd853f",
|
||||
// pink: "#ffc0cb",
|
||||
// plum: "#dda0dd",
|
||||
// powderblue: "#b0e0e6",
|
||||
// purple: "#800080",
|
||||
// red: "#ff0000",
|
||||
// rosybrown: "#bc8f8f",
|
||||
// royalblue: "#4169e1",
|
||||
// saddlebrown: "#8b4513",
|
||||
// salmon: "#fa8072",
|
||||
// sandybrown: "#f4a460",
|
||||
// seagreen: "#2e8b57",
|
||||
// seashell: "#fff5ee",
|
||||
// sienna: "#a0522d",
|
||||
// silver: "#c0c0c0",
|
||||
// skyblue: "#87ceeb",
|
||||
// slateblue: "#6a5acd",
|
||||
// slategray: "#708090",
|
||||
// slategrey: "#708090",
|
||||
// snow: "#fffafa",
|
||||
// springgreen: "#00ff7f",
|
||||
// steelblue: "#4682b4",
|
||||
// tan: "#d2b48c",
|
||||
// teal: "#008080",
|
||||
// thistle: "#d8bfd8",
|
||||
// tomato: "#ff6347",
|
||||
// turquoise: "#40e0d0",
|
||||
// violet: "#ee82ee",
|
||||
// wheat: "#f5deb3",
|
||||
// white: "#ffffff",
|
||||
// whitesmoke: "#f5f5f5",
|
||||
// yellow: "#ffff00",
|
||||
// yellowgreen: "#9acd32"
|
||||
//};
|
||||
0
crystalreportviewers13/js/MochiKit/Controls.js
Normal file
926
crystalreportviewers13/js/MochiKit/DOM.js
Normal file
@@ -0,0 +1,926 @@
|
||||
/***
|
||||
|
||||
MochiKit.DOM 1.4
|
||||
|
||||
See <http://mochikit.com/> for documentation, downloads, license, etc.
|
||||
|
||||
(c) 2005 Bob Ippolito. All rights Reserved.
|
||||
|
||||
***/
|
||||
|
||||
if (typeof(dojo) != 'undefined') {
|
||||
dojo.provide("MochiKit.DOM");
|
||||
dojo.require("MochiKit.Base");
|
||||
}
|
||||
if (typeof(JSAN) != 'undefined') {
|
||||
JSAN.use("MochiKit.Base", []);
|
||||
}
|
||||
|
||||
try {
|
||||
if (typeof(MochiKit.Base) == 'undefined') {
|
||||
throw "";
|
||||
}
|
||||
} catch (e) {
|
||||
throw "MochiKit.DOM depends on MochiKit.Base!";
|
||||
}
|
||||
|
||||
if (typeof(MochiKit.DOM) == 'undefined') {
|
||||
MochiKit.DOM = {};
|
||||
}
|
||||
|
||||
MochiKit.DOM.NAME = "MochiKit.DOM";
|
||||
MochiKit.DOM.VERSION = "1.4";
|
||||
MochiKit.DOM.__repr__ = function () {
|
||||
return "[" + this.NAME + " " + this.VERSION + "]";
|
||||
};
|
||||
MochiKit.DOM.toString = function () {
|
||||
return this.__repr__();
|
||||
};
|
||||
|
||||
MochiKit.DOM.EXPORT = [
|
||||
"removeEmptyTextNodes",
|
||||
"formContents",
|
||||
"currentWindow",
|
||||
"currentDocument",
|
||||
"withWindow",
|
||||
"withDocument",
|
||||
"registerDOMConverter",
|
||||
"coerceToDOM",
|
||||
"createDOM",
|
||||
"createDOMFunc",
|
||||
"getNodeAttribute",
|
||||
"setNodeAttribute",
|
||||
"updateNodeAttributes",
|
||||
"appendChildNodes",
|
||||
"replaceChildNodes",
|
||||
"removeElement",
|
||||
"swapDOM",
|
||||
"BUTTON",
|
||||
"TT",
|
||||
"PRE",
|
||||
"H1",
|
||||
"H2",
|
||||
"H3",
|
||||
"BR",
|
||||
"CANVAS",
|
||||
"HR",
|
||||
"LABEL",
|
||||
"TEXTAREA",
|
||||
"FORM",
|
||||
"STRONG",
|
||||
"SELECT",
|
||||
"OPTION",
|
||||
"OPTGROUP",
|
||||
"LEGEND",
|
||||
"FIELDSET",
|
||||
"P",
|
||||
"UL",
|
||||
"OL",
|
||||
"LI",
|
||||
"TD",
|
||||
"TR",
|
||||
"THEAD",
|
||||
"TBODY",
|
||||
"TFOOT",
|
||||
"TABLE",
|
||||
"TH",
|
||||
"INPUT",
|
||||
"SPAN",
|
||||
"A",
|
||||
"DIV",
|
||||
"IMG",
|
||||
"getElement",
|
||||
"$",
|
||||
"getElementsByTagAndClassName",
|
||||
"addToCallStack",
|
||||
"addLoadEvent",
|
||||
"focusOnLoad",
|
||||
"setElementClass",
|
||||
"toggleElementClass",
|
||||
"addElementClass",
|
||||
"removeElementClass",
|
||||
"swapElementClass",
|
||||
"hasElementClass",
|
||||
"escapeHTML",
|
||||
"toHTML",
|
||||
"emitHTML",
|
||||
"scrapeText"
|
||||
];
|
||||
|
||||
MochiKit.DOM.EXPORT_OK = [
|
||||
"domConverters"
|
||||
];
|
||||
|
||||
MochiKit.DOM.DEPRECATED = [
|
||||
['computedStyle', 'MochiKit.Style.computedStyle', '1.4'],
|
||||
['elementDimensions', 'MochiKit.Style.getElementDimensions', '1.4'],
|
||||
['elementPosition', 'MochiKit.Style.getElementPosition', '1.4'],
|
||||
['hideElement', 'MochiKit.Style.hideElement', '1.4'],
|
||||
['setElementDimensions', 'MochiKit.Style.setElementDimensions', '1.4'],
|
||||
['setElementPosition', 'MochiKit.Style.setElementPosition', '1.4'],
|
||||
['setDisplayForElement', 'MochiKit.Style.setDisplayForElement', '1.4'],
|
||||
['setOpacity', 'MochiKit.Style.setOpacity', '1.4'],
|
||||
['showElement', 'MochiKit.Style.showElement', '1.4'],
|
||||
['Coordinates', 'MochiKit.Style.Coordinates', '1.4'], // FIXME: broken
|
||||
['Dimensions', 'MochiKit.Style.Dimensions', '1.4'] // FIXME: broken
|
||||
];
|
||||
|
||||
MochiKit.DOM.getViewportDimensions = new Function('' +
|
||||
'if (!MochiKit["Style"]) {' +
|
||||
' throw new Error("This function has been deprecated and depends on MochiKit.Style.");' +
|
||||
'}' +
|
||||
'return MochiKit.Style.getViewportDimensions.apply(this, arguments);');
|
||||
|
||||
MochiKit.Base.update(MochiKit.DOM, {
|
||||
|
||||
currentWindow: function () {
|
||||
return MochiKit.DOM._window;
|
||||
},
|
||||
|
||||
currentDocument: function () {
|
||||
return MochiKit.DOM._document;
|
||||
},
|
||||
|
||||
withWindow: function (win, func) {
|
||||
var self = MochiKit.DOM;
|
||||
var oldDoc = self._document;
|
||||
var oldWin = self._win;
|
||||
var rval;
|
||||
try {
|
||||
self._window = win;
|
||||
self._document = win.document;
|
||||
rval = func();
|
||||
} catch (e) {
|
||||
self._window = oldWin;
|
||||
self._document = oldDoc;
|
||||
throw e;
|
||||
}
|
||||
self._window = oldWin;
|
||||
self._document = oldDoc;
|
||||
return rval;
|
||||
},
|
||||
|
||||
formContents: function (elem/* = document */) {
|
||||
var names = [];
|
||||
var values = [];
|
||||
var m = MochiKit.Base;
|
||||
var self = MochiKit.DOM;
|
||||
if (typeof(elem) == "undefined" || elem === null) {
|
||||
elem = self._document;
|
||||
} else {
|
||||
elem = self.getElement(elem);
|
||||
}
|
||||
m.nodeWalk(elem, function (elem) {
|
||||
var name = elem.name;
|
||||
if (m.isNotEmpty(name)) {
|
||||
var tagName = elem.nodeName;
|
||||
if (tagName == "INPUT"
|
||||
&& (elem.type == "radio" || elem.type == "checkbox")
|
||||
&& !elem.checked
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
if (tagName == "SELECT") {
|
||||
if (elem.type == "select-one") {
|
||||
if (elem.selectedIndex >= 0) {
|
||||
var opt = elem.options[elem.selectedIndex];
|
||||
names.push(name);
|
||||
values.push((opt.value) ? opt.value : opt.text);
|
||||
return null;
|
||||
}
|
||||
// no form elements?
|
||||
names.push(name);
|
||||
values.push("");
|
||||
return null;
|
||||
} else {
|
||||
var opts = elem.options;
|
||||
if (!opts.length) {
|
||||
names.push(name);
|
||||
values.push("");
|
||||
return null;
|
||||
}
|
||||
for (var i = 0; i < opts.length; i++) {
|
||||
var opt = opts[i];
|
||||
if (!opt.selected) {
|
||||
continue;
|
||||
}
|
||||
names.push(name);
|
||||
values.push((opt.value) ? opt.value : opt.text);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (tagName == "FORM" || tagName == "P" || tagName == "SPAN"
|
||||
|| tagName == "DIV"
|
||||
) {
|
||||
return elem.childNodes;
|
||||
}
|
||||
names.push(name);
|
||||
values.push(elem.value || '');
|
||||
return null;
|
||||
}
|
||||
return elem.childNodes;
|
||||
});
|
||||
return [names, values];
|
||||
},
|
||||
|
||||
withDocument: function (doc, func) {
|
||||
var self = MochiKit.DOM;
|
||||
var oldDoc = self._document;
|
||||
var rval;
|
||||
try {
|
||||
self._document = doc;
|
||||
rval = func();
|
||||
} catch (e) {
|
||||
self._document = oldDoc;
|
||||
throw e;
|
||||
}
|
||||
self._document = oldDoc;
|
||||
return rval;
|
||||
},
|
||||
|
||||
registerDOMConverter: function (name, check, wrap, /* optional */override) {
|
||||
MochiKit.DOM.domConverters.register(name, check, wrap, override);
|
||||
},
|
||||
|
||||
coerceToDOM: function (node, ctx) {
|
||||
var m = MochiKit.Base;
|
||||
var im = MochiKit.Iter;
|
||||
var self = MochiKit.DOM;
|
||||
if (im) {
|
||||
var iter = im.iter;
|
||||
var repeat = im.repeat;
|
||||
var map = m.map;
|
||||
}
|
||||
var domConverters = self.domConverters;
|
||||
var coerceToDOM = arguments.callee;
|
||||
var NotFound = m.NotFound;
|
||||
while (true) {
|
||||
if (typeof(node) == 'undefined' || node === null) {
|
||||
return null;
|
||||
}
|
||||
if (typeof(node.nodeType) != 'undefined' && node.nodeType > 0) {
|
||||
return node;
|
||||
}
|
||||
if (typeof(node) == 'number' || typeof(node) == 'boolean') {
|
||||
node = node.toString();
|
||||
// FALL THROUGH
|
||||
}
|
||||
if (typeof(node) == 'string') {
|
||||
return self._document.createTextNode(node);
|
||||
}
|
||||
if (typeof(node.__dom__) == 'function') {
|
||||
node = node.__dom__(ctx);
|
||||
continue;
|
||||
}
|
||||
if (typeof(node.dom) == 'function') {
|
||||
node = node.dom(ctx);
|
||||
continue;
|
||||
}
|
||||
if (typeof(node) == 'function') {
|
||||
node = node.apply(ctx, [ctx]);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (im) {
|
||||
// iterable
|
||||
var iterNodes = null;
|
||||
try {
|
||||
iterNodes = iter(node);
|
||||
} catch (e) {
|
||||
// pass
|
||||
}
|
||||
if (iterNodes) {
|
||||
return map(coerceToDOM, iterNodes, repeat(ctx));
|
||||
}
|
||||
}
|
||||
|
||||
// adapter
|
||||
try {
|
||||
node = domConverters.match(node, ctx);
|
||||
continue;
|
||||
} catch (e) {
|
||||
if (e != NotFound) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
// fallback
|
||||
return self._document.createTextNode(node.toString());
|
||||
}
|
||||
// mozilla warnings aren't too bright
|
||||
return undefined;
|
||||
},
|
||||
|
||||
setNodeAttribute: function (node, attr, value) {
|
||||
var o = {};
|
||||
o[attr] = value;
|
||||
try {
|
||||
return MochiKit.DOM.updateNodeAttributes(node, o);
|
||||
} catch (e) {
|
||||
// pass
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
getNodeAttribute: function (node, attr) {
|
||||
var self = MochiKit.DOM;
|
||||
var rename = self.attributeArray.renames[attr];
|
||||
node = self.getElement(node);
|
||||
try {
|
||||
if (rename) {
|
||||
return node[rename];
|
||||
}
|
||||
return node.getAttribute(attr);
|
||||
} catch (e) {
|
||||
// pass
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
updateNodeAttributes: function (node, attrs) {
|
||||
var elem = node;
|
||||
var self = MochiKit.DOM;
|
||||
if (typeof(node) == 'string') {
|
||||
elem = self.getElement(node);
|
||||
}
|
||||
if (attrs) {
|
||||
var updatetree = MochiKit.Base.updatetree;
|
||||
if (self.attributeArray.compliant) {
|
||||
// not IE, good.
|
||||
for (var k in attrs) {
|
||||
var v = attrs[k];
|
||||
if (typeof(v) == 'object' && typeof(elem[k]) == 'object') {
|
||||
updatetree(elem[k], v);
|
||||
} else if (k.substring(0, 2) == "on") {
|
||||
if (typeof(v) == "string") {
|
||||
v = new Function(v);
|
||||
}
|
||||
elem[k] = v;
|
||||
} else {
|
||||
elem.setAttribute(k, v);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// IE is insane in the membrane
|
||||
var renames = self.attributeArray.renames;
|
||||
for (k in attrs) {
|
||||
v = attrs[k];
|
||||
var renamed = renames[k];
|
||||
if (k == "style" && typeof(v) == "string") {
|
||||
elem.style.cssText = v;
|
||||
} else if (typeof(renamed) == "string") {
|
||||
elem[renamed] = v;
|
||||
} else if (typeof(elem[k]) == 'object'
|
||||
&& typeof(v) == 'object') {
|
||||
updatetree(elem[k], v);
|
||||
} else if (k.substring(0, 2) == "on") {
|
||||
if (typeof(v) == "string") {
|
||||
v = new Function(v);
|
||||
}
|
||||
elem[k] = v;
|
||||
} else {
|
||||
elem.setAttribute(k, v);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return elem;
|
||||
},
|
||||
|
||||
appendChildNodes: function (node/*, nodes...*/) {
|
||||
var elem = node;
|
||||
var self = MochiKit.DOM;
|
||||
if (typeof(node) == 'string') {
|
||||
elem = self.getElement(node);
|
||||
}
|
||||
var nodeStack = [
|
||||
self.coerceToDOM(
|
||||
MochiKit.Base.extend(null, arguments, 1),
|
||||
elem
|
||||
)
|
||||
];
|
||||
var concat = MochiKit.Base.concat;
|
||||
while (nodeStack.length) {
|
||||
var n = nodeStack.shift();
|
||||
if (typeof(n) == 'undefined' || n === null) {
|
||||
// pass
|
||||
} else if (typeof(n.nodeType) == 'number') {
|
||||
elem.appendChild(n);
|
||||
} else {
|
||||
nodeStack = concat(n, nodeStack);
|
||||
}
|
||||
}
|
||||
return elem;
|
||||
},
|
||||
|
||||
replaceChildNodes: function (node/*, nodes...*/) {
|
||||
var elem = node;
|
||||
var self = MochiKit.DOM;
|
||||
if (typeof(node) == 'string') {
|
||||
elem = self.getElement(node);
|
||||
arguments[0] = elem;
|
||||
}
|
||||
var child;
|
||||
while ((child = elem.firstChild)) {
|
||||
elem.removeChild(child);
|
||||
}
|
||||
if (arguments.length < 2) {
|
||||
return elem;
|
||||
} else {
|
||||
return self.appendChildNodes.apply(this, arguments);
|
||||
}
|
||||
},
|
||||
|
||||
createDOM: function (name, attrs/*, nodes... */) {
|
||||
var elem;
|
||||
var self = MochiKit.DOM;
|
||||
var m = MochiKit.Base;
|
||||
if (typeof(attrs) == "string" || typeof(attrs) == "number") {
|
||||
var args = m.extend([name, null], arguments, 1);
|
||||
return arguments.callee.apply(this, args);
|
||||
}
|
||||
if (typeof(name) == 'string') {
|
||||
// Internet Explorer is dumb
|
||||
if (attrs && !self.attributeArray.compliant) {
|
||||
// http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/name_2.asp
|
||||
var contents = "";
|
||||
if ('name' in attrs) {
|
||||
contents += ' name="' + self.escapeHTML(attrs.name) + '"';
|
||||
}
|
||||
if (name == 'input' && 'type' in attrs) {
|
||||
contents += ' type="' + self.escapeHTML(attrs.type) + '"';
|
||||
}
|
||||
if (contents) {
|
||||
name = "<" + name + contents + ">";
|
||||
}
|
||||
}
|
||||
elem = self._document.createElement(name);
|
||||
} else {
|
||||
elem = name;
|
||||
}
|
||||
if (attrs) {
|
||||
self.updateNodeAttributes(elem, attrs);
|
||||
}
|
||||
if (arguments.length <= 2) {
|
||||
return elem;
|
||||
} else {
|
||||
var args = m.extend([elem], arguments, 2);
|
||||
return self.appendChildNodes.apply(this, args);
|
||||
}
|
||||
},
|
||||
|
||||
createDOMFunc: function (/* tag, attrs, *nodes */) {
|
||||
var m = MochiKit.Base;
|
||||
return m.partial.apply(
|
||||
this,
|
||||
m.extend([MochiKit.DOM.createDOM], arguments)
|
||||
);
|
||||
},
|
||||
|
||||
removeElement: function (elem) {
|
||||
var e = MochiKit.DOM.getElement(elem);
|
||||
e.parentNode.removeChild(e);
|
||||
return e;
|
||||
},
|
||||
|
||||
swapDOM: function (dest, src) {
|
||||
var self = MochiKit.DOM;
|
||||
dest = self.getElement(dest);
|
||||
var parent = dest.parentNode;
|
||||
if (src) {
|
||||
src = self.getElement(src);
|
||||
parent.replaceChild(src, dest);
|
||||
} else {
|
||||
parent.removeChild(dest);
|
||||
}
|
||||
return src;
|
||||
},
|
||||
|
||||
getElement: function (id) {
|
||||
var self = MochiKit.DOM;
|
||||
if (arguments.length == 1) {
|
||||
return ((typeof(id) == "string") ?
|
||||
self._document.getElementById(id) : id);
|
||||
} else {
|
||||
return MochiKit.Base.map(self.getElement, arguments);
|
||||
}
|
||||
},
|
||||
|
||||
getElementsByTagAndClassName: function (tagName, className,
|
||||
/* optional */parent) {
|
||||
var self = MochiKit.DOM;
|
||||
if (typeof(tagName) == 'undefined' || tagName === null) {
|
||||
tagName = '*';
|
||||
}
|
||||
if (typeof(parent) == 'undefined' || parent === null) {
|
||||
parent = self._document;
|
||||
}
|
||||
parent = self.getElement(parent);
|
||||
var children = (parent.getElementsByTagName(tagName)
|
||||
|| self._document.all);
|
||||
if (typeof(className) == 'undefined' || className === null) {
|
||||
return MochiKit.Base.extend(null, children);
|
||||
}
|
||||
|
||||
var elements = [];
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
var child = children[i];
|
||||
var classNames = child.className.split(' ');
|
||||
for (var j = 0; j < classNames.length; j++) {
|
||||
if (classNames[j] == className) {
|
||||
elements.push(child);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return elements;
|
||||
},
|
||||
|
||||
_newCallStack: function (path, once) {
|
||||
var rval = function () {
|
||||
var callStack = arguments.callee.callStack;
|
||||
for (var i = 0; i < callStack.length; i++) {
|
||||
if (callStack[i].apply(this, arguments) === false) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (once) {
|
||||
try {
|
||||
this[path] = null;
|
||||
} catch (e) {
|
||||
// pass
|
||||
}
|
||||
}
|
||||
};
|
||||
rval.callStack = [];
|
||||
return rval;
|
||||
},
|
||||
|
||||
addToCallStack: function (target, path, func, once) {
|
||||
var self = MochiKit.DOM;
|
||||
var existing = target[path];
|
||||
var regfunc = existing;
|
||||
if (!(typeof(existing) == 'function'
|
||||
&& typeof(existing.callStack) == "object"
|
||||
&& existing.callStack !== null)) {
|
||||
regfunc = self._newCallStack(path, once);
|
||||
if (typeof(existing) == 'function') {
|
||||
regfunc.callStack.push(existing);
|
||||
}
|
||||
target[path] = regfunc;
|
||||
}
|
||||
regfunc.callStack.push(func);
|
||||
},
|
||||
|
||||
addLoadEvent: function (func) {
|
||||
var self = MochiKit.DOM;
|
||||
self.addToCallStack(self._window, "onload", func, true);
|
||||
|
||||
},
|
||||
|
||||
focusOnLoad: function (element) {
|
||||
var self = MochiKit.DOM;
|
||||
self.addLoadEvent(function () {
|
||||
element = self.getElement(element);
|
||||
if (element) {
|
||||
element.focus();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
setElementClass: function (element, className) {
|
||||
var self = MochiKit.DOM;
|
||||
var obj = self.getElement(element);
|
||||
if (self.attributeArray.compliant) {
|
||||
obj.setAttribute("class", className);
|
||||
} else {
|
||||
obj.setAttribute("className", className);
|
||||
}
|
||||
},
|
||||
|
||||
toggleElementClass: function (className/*, element... */) {
|
||||
var self = MochiKit.DOM;
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
var obj = self.getElement(arguments[i]);
|
||||
if (!self.addElementClass(obj, className)) {
|
||||
self.removeElementClass(obj, className);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
addElementClass: function (element, className) {
|
||||
var self = MochiKit.DOM;
|
||||
var obj = self.getElement(element);
|
||||
var cls = obj.className;
|
||||
// trivial case, no className yet
|
||||
if (cls.length === 0) {
|
||||
self.setElementClass(obj, className);
|
||||
return true;
|
||||
}
|
||||
// the other trivial case, already set as the only class
|
||||
if (cls == className) {
|
||||
return false;
|
||||
}
|
||||
var classes = obj.className.split(" ");
|
||||
for (var i = 0; i < classes.length; i++) {
|
||||
// already present
|
||||
if (classes[i] == className) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// append class
|
||||
self.setElementClass(obj, cls + " " + className);
|
||||
return true;
|
||||
},
|
||||
|
||||
removeElementClass: function (element, className) {
|
||||
var self = MochiKit.DOM;
|
||||
var obj = self.getElement(element);
|
||||
var cls = obj.className;
|
||||
// trivial case, no className yet
|
||||
if (cls.length === 0) {
|
||||
return false;
|
||||
}
|
||||
// other trivial case, set only to className
|
||||
if (cls == className) {
|
||||
self.setElementClass(obj, "");
|
||||
return true;
|
||||
}
|
||||
var classes = obj.className.split(" ");
|
||||
for (var i = 0; i < classes.length; i++) {
|
||||
// already present
|
||||
if (classes[i] == className) {
|
||||
// only check sane case where the class is used once
|
||||
classes.splice(i, 1);
|
||||
self.setElementClass(obj, classes.join(" "));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// not found
|
||||
return false;
|
||||
},
|
||||
|
||||
swapElementClass: function (element, fromClass, toClass) {
|
||||
var obj = MochiKit.DOM.getElement(element);
|
||||
var res = MochiKit.DOM.removeElementClass(obj, fromClass);
|
||||
if (res) {
|
||||
MochiKit.DOM.addElementClass(obj, toClass);
|
||||
}
|
||||
return res;
|
||||
},
|
||||
|
||||
hasElementClass: function (element, className/*...*/) {
|
||||
var obj = MochiKit.DOM.getElement(element);
|
||||
var classes = obj.className.split(" ");
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
var good = false;
|
||||
for (var j = 0; j < classes.length; j++) {
|
||||
if (classes[j] == arguments[i]) {
|
||||
good = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!good) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
escapeHTML: function (s) {
|
||||
return s.replace(/&/g, "&"
|
||||
).replace(/"/g, """
|
||||
).replace(/</g, "<"
|
||||
).replace(/>/g, ">");
|
||||
},
|
||||
|
||||
toHTML: function (dom) {
|
||||
return MochiKit.DOM.emitHTML(dom).join("");
|
||||
},
|
||||
|
||||
emitHTML: function (dom, /* optional */lst) {
|
||||
if (typeof(lst) == 'undefined' || lst === null) {
|
||||
lst = [];
|
||||
}
|
||||
// queue is the call stack, we're doing this non-recursively
|
||||
var queue = [dom];
|
||||
var self = MochiKit.DOM;
|
||||
var escapeHTML = self.escapeHTML;
|
||||
var attributeArray = self.attributeArray;
|
||||
while (queue.length) {
|
||||
dom = queue.pop();
|
||||
if (typeof(dom) == 'string') {
|
||||
lst.push(dom);
|
||||
} else if (dom.nodeType == 1) {
|
||||
// we're not using higher order stuff here
|
||||
// because safari has heisenbugs.. argh.
|
||||
//
|
||||
// I think it might have something to do with
|
||||
// garbage collection and function calls.
|
||||
lst.push('<' + dom.nodeName.toLowerCase());
|
||||
var attributes = [];
|
||||
var domAttr = attributeArray(dom);
|
||||
for (var i = 0; i < domAttr.length; i++) {
|
||||
var a = domAttr[i];
|
||||
attributes.push([
|
||||
" ",
|
||||
a.name,
|
||||
'="',
|
||||
escapeHTML(a.value),
|
||||
'"'
|
||||
]);
|
||||
}
|
||||
attributes.sort();
|
||||
for (i = 0; i < attributes.length; i++) {
|
||||
var attrs = attributes[i];
|
||||
for (var j = 0; j < attrs.length; j++) {
|
||||
lst.push(attrs[j]);
|
||||
}
|
||||
}
|
||||
if (dom.hasChildNodes()) {
|
||||
lst.push(">");
|
||||
// queue is the FILO call stack, so we put the close tag
|
||||
// on first
|
||||
queue.push("</" + dom.nodeName.toLowerCase() + ">");
|
||||
var cnodes = dom.childNodes;
|
||||
for (i = cnodes.length - 1; i >= 0; i--) {
|
||||
queue.push(cnodes[i]);
|
||||
}
|
||||
} else {
|
||||
lst.push('/>');
|
||||
}
|
||||
} else if (dom.nodeType == 3) {
|
||||
lst.push(escapeHTML(dom.nodeValue));
|
||||
}
|
||||
}
|
||||
return lst;
|
||||
},
|
||||
|
||||
scrapeText: function (node, /* optional */asArray) {
|
||||
var rval = [];
|
||||
(function (node) {
|
||||
var cn = node.childNodes;
|
||||
if (cn) {
|
||||
for (var i = 0; i < cn.length; i++) {
|
||||
arguments.callee.call(this, cn[i]);
|
||||
}
|
||||
}
|
||||
var nodeValue = node.nodeValue;
|
||||
if (typeof(nodeValue) == 'string') {
|
||||
rval.push(nodeValue);
|
||||
}
|
||||
})(MochiKit.DOM.getElement(node));
|
||||
if (asArray) {
|
||||
return rval;
|
||||
} else {
|
||||
return rval.join("");
|
||||
}
|
||||
},
|
||||
|
||||
removeEmptyTextNodes: function (element) {
|
||||
element = MochiKit.DOM.getElement(element);
|
||||
for (var i = 0; i < element.childNodes.length; i++) {
|
||||
var node = element.childNodes[i];
|
||||
if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) {
|
||||
node.parentNode.removeChild(node);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
__new__: function (win) {
|
||||
|
||||
var m = MochiKit.Base;
|
||||
if (typeof(document) != "undefined") {
|
||||
this._document = document;
|
||||
} else if (MochiKit.MockDOM) {
|
||||
this._document = MochiKit.MockDOM.document;
|
||||
}
|
||||
this._window = win;
|
||||
|
||||
this.domConverters = new m.AdapterRegistry();
|
||||
|
||||
var __tmpElement = this._document.createElement("span");
|
||||
var attributeArray;
|
||||
if (__tmpElement && __tmpElement.attributes &&
|
||||
__tmpElement.attributes.length > 0) {
|
||||
// for braindead browsers (IE) that insert extra junk
|
||||
var filter = m.filter;
|
||||
attributeArray = function (node) {
|
||||
return filter(attributeArray.ignoreAttrFilter, node.attributes);
|
||||
};
|
||||
attributeArray.ignoreAttr = {};
|
||||
var attrs = __tmpElement.attributes;
|
||||
var ignoreAttr = attributeArray.ignoreAttr;
|
||||
for (var i = 0; i < attrs.length; i++) {
|
||||
var a = attrs[i];
|
||||
ignoreAttr[a.name] = a.value;
|
||||
}
|
||||
attributeArray.ignoreAttrFilter = function (a) {
|
||||
return (attributeArray.ignoreAttr[a.name] != a.value);
|
||||
};
|
||||
attributeArray.compliant = false;
|
||||
attributeArray.renames = {
|
||||
"class": "className",
|
||||
"checked": "defaultChecked",
|
||||
"usemap": "useMap",
|
||||
"for": "htmlFor",
|
||||
"readonly": "readOnly"
|
||||
};
|
||||
} else {
|
||||
attributeArray = function (node) {
|
||||
/***
|
||||
|
||||
Return an array of attributes for a given node,
|
||||
filtering out attributes that don't belong for
|
||||
that are inserted by "Certain Browsers".
|
||||
|
||||
***/
|
||||
return node.attributes;
|
||||
};
|
||||
attributeArray.compliant = true;
|
||||
attributeArray.renames = {};
|
||||
}
|
||||
this.attributeArray = attributeArray;
|
||||
|
||||
// FIXME: this really belongs in Base, and could probably be cleaner
|
||||
var _deprecated = function(fromModule, arr) {
|
||||
var modules = arr[1].split('.');
|
||||
var str = '';
|
||||
var obj = {};
|
||||
|
||||
str += 'if (!MochiKit.' + modules[1] + ') { throw new Error("';
|
||||
str += 'This function has been deprecated and depends on MochiKit.';
|
||||
str += modules[1] + '.");}';
|
||||
str += 'return MochiKit.' + modules[1] + '.' + arr[0];
|
||||
str += '.apply(this, arguments);';
|
||||
|
||||
obj[modules[2]] = new Function(str);
|
||||
MochiKit.Base.update(MochiKit[fromModule], obj);
|
||||
}
|
||||
for (var i; i < MochiKit.DOM.DEPRECATED.length; i++) {
|
||||
_deprecated('DOM', MochiKit.DOM.DEPRECATED[i]);
|
||||
}
|
||||
|
||||
// shorthand for createDOM syntax
|
||||
var createDOMFunc = this.createDOMFunc;
|
||||
this.UL = createDOMFunc("ul");
|
||||
this.OL = createDOMFunc("ol");
|
||||
this.LI = createDOMFunc("li");
|
||||
this.TD = createDOMFunc("td");
|
||||
this.TR = createDOMFunc("tr");
|
||||
this.TBODY = createDOMFunc("tbody");
|
||||
this.THEAD = createDOMFunc("thead");
|
||||
this.TFOOT = createDOMFunc("tfoot");
|
||||
this.TABLE = createDOMFunc("table");
|
||||
this.TH = createDOMFunc("th");
|
||||
this.INPUT = createDOMFunc("input");
|
||||
this.SPAN = createDOMFunc("span");
|
||||
this.A = createDOMFunc("a");
|
||||
this.DIV = createDOMFunc("div");
|
||||
this.IMG = createDOMFunc("img");
|
||||
this.BUTTON = createDOMFunc("button");
|
||||
this.TT = createDOMFunc("tt");
|
||||
this.PRE = createDOMFunc("pre");
|
||||
this.H1 = createDOMFunc("h1");
|
||||
this.H2 = createDOMFunc("h2");
|
||||
this.H3 = createDOMFunc("h3");
|
||||
this.BR = createDOMFunc("br");
|
||||
this.HR = createDOMFunc("hr");
|
||||
this.LABEL = createDOMFunc("label");
|
||||
this.TEXTAREA = createDOMFunc("textarea");
|
||||
this.FORM = createDOMFunc("form");
|
||||
this.P = createDOMFunc("p");
|
||||
this.SELECT = createDOMFunc("select");
|
||||
this.OPTION = createDOMFunc("option");
|
||||
this.OPTGROUP = createDOMFunc("optgroup");
|
||||
this.LEGEND = createDOMFunc("legend");
|
||||
this.FIELDSET = createDOMFunc("fieldset");
|
||||
this.STRONG = createDOMFunc("strong");
|
||||
this.CANVAS = createDOMFunc("canvas");
|
||||
|
||||
this.$ = this.getElement;
|
||||
|
||||
this.EXPORT_TAGS = {
|
||||
":common": this.EXPORT,
|
||||
":all": m.concat(this.EXPORT, this.EXPORT_OK)
|
||||
};
|
||||
|
||||
m.nameFunctions(this);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
MochiKit.DOM.__new__(((typeof(window) == "undefined") ? this : window));
|
||||
|
||||
//
|
||||
// XXX: Internet Explorer blows
|
||||
//
|
||||
if (MochiKit.__export__) {
|
||||
withWindow = MochiKit.DOM.withWindow;
|
||||
withDocument = MochiKit.DOM.withDocument;
|
||||
}
|
||||
|
||||
MochiKit.Base._exportSymbols(this, MochiKit.DOM);
|
||||
208
crystalreportviewers13/js/MochiKit/DateTime.js
Normal file
@@ -0,0 +1,208 @@
|
||||
/***
|
||||
|
||||
MochiKit.DateTime 1.4
|
||||
|
||||
See <http://mochikit.com/> for documentation, downloads, license, etc.
|
||||
|
||||
(c) 2005 Bob Ippolito. All rights Reserved.
|
||||
|
||||
***/
|
||||
|
||||
if (typeof(dojo) != 'undefined') {
|
||||
dojo.provide('MochiKit.DateTime');
|
||||
}
|
||||
|
||||
if (typeof(MochiKit) == 'undefined') {
|
||||
MochiKit = {};
|
||||
}
|
||||
|
||||
if (typeof(MochiKit.DateTime) == 'undefined') {
|
||||
MochiKit.DateTime = {};
|
||||
}
|
||||
|
||||
MochiKit.DateTime.NAME = "MochiKit.DateTime";
|
||||
MochiKit.DateTime.VERSION = "1.4";
|
||||
MochiKit.DateTime.__repr__ = function () {
|
||||
return "[" + this.NAME + " " + this.VERSION + "]";
|
||||
};
|
||||
MochiKit.DateTime.toString = function () {
|
||||
return this.__repr__();
|
||||
};
|
||||
|
||||
MochiKit.DateTime.isoDate = function (str) {
|
||||
str = str + "";
|
||||
if (typeof(str) != "string" || str.length === 0) {
|
||||
return null;
|
||||
}
|
||||
var iso = str.split('-');
|
||||
if (iso.length === 0) {
|
||||
return null;
|
||||
}
|
||||
return new Date(iso[0], iso[1] - 1, iso[2]);
|
||||
};
|
||||
|
||||
MochiKit.DateTime._isoRegexp = /(\d{4,})(?:-(\d{1,2})(?:-(\d{1,2})(?:[T ](\d{1,2}):(\d{1,2})(?::(\d{1,2})(?:\.(\d+))?)?(?:(Z)|([+-])(\d{1,2})(?::(\d{1,2}))?)?)?)?)?/;
|
||||
|
||||
MochiKit.DateTime.isoTimestamp = function (str) {
|
||||
str = str + "";
|
||||
if (typeof(str) != "string" || str.length === 0) {
|
||||
return null;
|
||||
}
|
||||
var res = str.match(MochiKit.DateTime._isoRegexp);
|
||||
if (typeof(res) == "undefined" || res === null) {
|
||||
return null;
|
||||
}
|
||||
var year, month, day, hour, min, sec, msec;
|
||||
year = parseInt(res[1], 10);
|
||||
if (typeof(res[2]) == "undefined" || res[2] === '') {
|
||||
return new Date(year);
|
||||
}
|
||||
month = parseInt(res[2], 10) - 1;
|
||||
day = parseInt(res[3], 10);
|
||||
if (typeof(res[4]) == "undefined" || res[4] === '') {
|
||||
return new Date(year, month, day);
|
||||
}
|
||||
hour = parseInt(res[4], 10);
|
||||
min = parseInt(res[5], 10);
|
||||
sec = (typeof(res[6]) != "undefined" && res[6] !== '') ? parseInt(res[6], 10) : 0;
|
||||
if (typeof(res[7]) != "undefined" && res[7] !== '') {
|
||||
msec = Math.round(1000.0 * parseFloat("0." + res[7]));
|
||||
} else {
|
||||
msec = 0;
|
||||
}
|
||||
if ((typeof(res[8]) == "undefined" || res[8] === '') && (typeof(res[9]) == "undefined" || res[9] === '')) {
|
||||
return new Date(year, month, day, hour, min, sec, msec);
|
||||
}
|
||||
var ofs;
|
||||
if (typeof(res[9]) != "undefined" && res[9] !== '') {
|
||||
ofs = parseInt(res[10], 10) * 3600000;
|
||||
if (typeof(res[11]) != "undefined" && res[11] !== '') {
|
||||
ofs += parseInt(res[11], 10) * 60000;
|
||||
}
|
||||
if (res[9] == "-") {
|
||||
ofs = -ofs;
|
||||
}
|
||||
} else {
|
||||
ofs = 0;
|
||||
}
|
||||
return new Date(Date.UTC(year, month, day, hour, min, sec, msec) - ofs);
|
||||
};
|
||||
|
||||
MochiKit.DateTime.toISOTime = function (date, realISO/* = false */) {
|
||||
if (typeof(date) == "undefined" || date === null) {
|
||||
return null;
|
||||
}
|
||||
var hh = date.getHours();
|
||||
var mm = date.getMinutes();
|
||||
var ss = date.getSeconds();
|
||||
var lst = [
|
||||
((realISO && (hh < 10)) ? "0" + hh : hh),
|
||||
((mm < 10) ? "0" + mm : mm),
|
||||
((ss < 10) ? "0" + ss : ss)
|
||||
];
|
||||
return lst.join(":");
|
||||
};
|
||||
|
||||
MochiKit.DateTime.toISOTimestamp = function (date, realISO/* = false*/) {
|
||||
if (typeof(date) == "undefined" || date === null) {
|
||||
return null;
|
||||
}
|
||||
var sep = realISO ? "T" : " ";
|
||||
var foot = realISO ? "Z" : "";
|
||||
if (realISO) {
|
||||
date = new Date(date.getTime() + (date.getTimezoneOffset() * 60000));
|
||||
}
|
||||
return MochiKit.DateTime.toISODate(date) + sep + MochiKit.DateTime.toISOTime(date, realISO) + foot;
|
||||
};
|
||||
|
||||
MochiKit.DateTime.toISODate = function (date) {
|
||||
if (typeof(date) == "undefined" || date === null) {
|
||||
return null;
|
||||
}
|
||||
var _padTwo = MochiKit.DateTime._padTwo;
|
||||
return [
|
||||
date.getFullYear(),
|
||||
_padTwo(date.getMonth() + 1),
|
||||
_padTwo(date.getDate())
|
||||
].join("-");
|
||||
};
|
||||
|
||||
MochiKit.DateTime.americanDate = function (d) {
|
||||
d = d + "";
|
||||
if (typeof(d) != "string" || d.length === 0) {
|
||||
return null;
|
||||
}
|
||||
var a = d.split('/');
|
||||
return new Date(a[2], a[0] - 1, a[1]);
|
||||
};
|
||||
|
||||
MochiKit.DateTime._padTwo = function (n) {
|
||||
return (n > 9) ? n : "0" + n;
|
||||
};
|
||||
|
||||
MochiKit.DateTime.toPaddedAmericanDate = function (d) {
|
||||
if (typeof(d) == "undefined" || d === null) {
|
||||
return null;
|
||||
}
|
||||
var _padTwo = MochiKit.DateTime._padTwo;
|
||||
return [
|
||||
_padTwo(d.getMonth() + 1),
|
||||
_padTwo(d.getDate()),
|
||||
d.getFullYear()
|
||||
].join('/');
|
||||
};
|
||||
|
||||
MochiKit.DateTime.toAmericanDate = function (d) {
|
||||
if (typeof(d) == "undefined" || d === null) {
|
||||
return null;
|
||||
}
|
||||
return [d.getMonth() + 1, d.getDate(), d.getFullYear()].join('/');
|
||||
};
|
||||
|
||||
MochiKit.DateTime.EXPORT = [
|
||||
"isoDate",
|
||||
"isoTimestamp",
|
||||
"toISOTime",
|
||||
"toISOTimestamp",
|
||||
"toISODate",
|
||||
"americanDate",
|
||||
"toPaddedAmericanDate",
|
||||
"toAmericanDate"
|
||||
];
|
||||
|
||||
MochiKit.DateTime.EXPORT_OK = [];
|
||||
MochiKit.DateTime.EXPORT_TAGS = {
|
||||
":common": MochiKit.DateTime.EXPORT,
|
||||
":all": MochiKit.DateTime.EXPORT
|
||||
};
|
||||
|
||||
MochiKit.DateTime.__new__ = function () {
|
||||
// MochiKit.Base.nameFunctions(this);
|
||||
var base = this.NAME + ".";
|
||||
for (var k in this) {
|
||||
var o = this[k];
|
||||
if (typeof(o) == 'function' && typeof(o.NAME) == 'undefined') {
|
||||
try {
|
||||
o.NAME = base + k;
|
||||
} catch (e) {
|
||||
// pass
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
MochiKit.DateTime.__new__();
|
||||
|
||||
if (typeof(MochiKit.Base) != "undefined") {
|
||||
MochiKit.Base._exportSymbols(this, MochiKit.DateTime);
|
||||
} else {
|
||||
(function (globals, module) {
|
||||
if ((typeof(JSAN) == 'undefined' && typeof(dojo) == 'undefined')
|
||||
|| (MochiKit.__export__ === false)) {
|
||||
var all = module.EXPORT_TAGS[":all"];
|
||||
for (var i = 0; i < all.length; i++) {
|
||||
globals[all[i]] = module[all[i]];
|
||||
}
|
||||
}
|
||||
})(this, MochiKit.DateTime);
|
||||
}
|
||||
774
crystalreportviewers13/js/MochiKit/DragAndDrop.js
Normal file
@@ -0,0 +1,774 @@
|
||||
/***
|
||||
MochiKit.DragAndDrop 1.4
|
||||
|
||||
See <http://mochikit.com/> for documentation, downloads, license, etc.
|
||||
|
||||
Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
|
||||
Mochi-ized By Thomas Herve (_firstname_@nimail.org)
|
||||
|
||||
***/
|
||||
|
||||
if (typeof(dojo) != 'undefined') {
|
||||
dojo.provide('MochiKit.DragAndDrop');
|
||||
dojo.require('MochiKit.Base');
|
||||
dojo.require('MochiKit.DOM');
|
||||
dojo.require('MochiKit.Iter');
|
||||
dojo.require('MochiKit.Visual');
|
||||
dojo.require('MochiKit.Signal');
|
||||
}
|
||||
|
||||
if (typeof(JSAN) != 'undefined') {
|
||||
JSAN.use("MochiKit.Base", []);
|
||||
JSAN.use("MochiKit.DOM", []);
|
||||
JSAN.use("MochiKit.Visual", []);
|
||||
JSAN.use("MochiKit.Iter", []);
|
||||
JSAN.use("MochiKit.Signal", []);
|
||||
}
|
||||
|
||||
try {
|
||||
if (typeof(MochiKit.Base) == 'undefined' ||
|
||||
typeof(MochiKit.DOM) == 'undefined' ||
|
||||
typeof(MochiKit.Visual) == 'undefined' ||
|
||||
typeof(MochiKit.Signal) == 'undefined' ||
|
||||
typeof(MochiKit.Iter) == 'undefined') {
|
||||
throw "";
|
||||
}
|
||||
} catch (e) {
|
||||
throw "MochiKit.DragAndDrop depends on MochiKit.Base, MochiKit.DOM, MochiKit.Visual, MochiKit.Signal and MochiKit.Iter!";
|
||||
}
|
||||
|
||||
if (typeof(MochiKit.DragAndDrop) == 'undefined') {
|
||||
MochiKit.DragAndDrop = {};
|
||||
}
|
||||
|
||||
MochiKit.DragAndDrop.NAME = 'MochiKit.DragAndDrop';
|
||||
MochiKit.DragAndDrop.VERSION = '1.4';
|
||||
|
||||
MochiKit.DragAndDrop.__repr__ = function () {
|
||||
return '[' + this.NAME + ' ' + this.VERSION + ']';
|
||||
};
|
||||
|
||||
MochiKit.DragAndDrop.toString = function () {
|
||||
return this.__repr__();
|
||||
};
|
||||
|
||||
MochiKit.DragAndDrop.EXPORT = [
|
||||
"Droppable",
|
||||
"Draggable"
|
||||
];
|
||||
|
||||
MochiKit.DragAndDrop.EXPORT_OK = [
|
||||
"Droppables",
|
||||
"Draggables"
|
||||
];
|
||||
|
||||
MochiKit.DragAndDrop.Droppables = {
|
||||
/***
|
||||
|
||||
Manage all droppables. Shouldn't be used, use the Droppable object instead.
|
||||
|
||||
***/
|
||||
drops: [],
|
||||
|
||||
remove: function (element) {
|
||||
this.drops = MochiKit.Base.filter(function (d) {
|
||||
return d.element != MochiKit.DOM.getElement(element)
|
||||
}, this.drops);
|
||||
},
|
||||
|
||||
register: function (drop) {
|
||||
this.drops.push(drop);
|
||||
},
|
||||
|
||||
unregister: function (drop) {
|
||||
this.drops = MochiKit.Base.filter(function (d) {
|
||||
return d != drop;
|
||||
}, this.drops);
|
||||
},
|
||||
|
||||
prepare: function (element) {
|
||||
MochiKit.Base.map(function (drop) {
|
||||
if (drop.isAccepted(element)) {
|
||||
if (drop.options.activeclass) {
|
||||
MochiKit.DOM.addElementClass(drop.element,
|
||||
drop.options.activeclass);
|
||||
}
|
||||
drop.options.onactive(drop.element, element);
|
||||
}
|
||||
}, this.drops);
|
||||
},
|
||||
|
||||
findDeepestChild: function (drops) {
|
||||
deepest = drops[0];
|
||||
|
||||
for (i = 1; i < drops.length; ++i) {
|
||||
if (MochiKit.DOM.isParent(drops[i].element, deepest.element)) {
|
||||
deepest = drops[i];
|
||||
}
|
||||
}
|
||||
return deepest;
|
||||
},
|
||||
|
||||
show: function (point, element) {
|
||||
if (!this.drops.length) {
|
||||
return;
|
||||
}
|
||||
var affected = [];
|
||||
|
||||
if (this.last_active) {
|
||||
this.last_active.deactivate();
|
||||
}
|
||||
MochiKit.Iter.forEach(this.drops, function (drop) {
|
||||
if (drop.isAffected(point, element)) {
|
||||
affected.push(drop);
|
||||
}
|
||||
});
|
||||
if (affected.length > 0) {
|
||||
drop = this.findDeepestChild(affected);
|
||||
MochiKit.Position.within(drop.element, point.page.x, point.page.y);
|
||||
drop.options.onhover(element, drop.element,
|
||||
MochiKit.Position.overlap(drop.options.overlap, drop.element));
|
||||
drop.activate();
|
||||
}
|
||||
},
|
||||
|
||||
fire: function (event, element) {
|
||||
if (!this.last_active) {
|
||||
return;
|
||||
}
|
||||
MochiKit.Position.prepare();
|
||||
|
||||
if (this.last_active.isAffected(event.mouse(), element)) {
|
||||
this.last_active.options.ondrop(element,
|
||||
this.last_active.element, event);
|
||||
}
|
||||
},
|
||||
|
||||
reset: function (element) {
|
||||
MochiKit.Base.map(function (drop) {
|
||||
if (drop.options.activeclass) {
|
||||
MochiKit.DOM.removeElementClass(drop.element,
|
||||
drop.options.activeclass);
|
||||
}
|
||||
drop.options.ondesactive(drop.element, element);
|
||||
}, this.drops);
|
||||
if (this.last_active) {
|
||||
this.last_active.deactivate();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
MochiKit.DragAndDrop.Droppable = function (element, options) {
|
||||
this.__init__(element, options);
|
||||
};
|
||||
|
||||
MochiKit.DragAndDrop.Droppable.prototype = {
|
||||
/***
|
||||
|
||||
A droppable object. Simple use is to create giving an element:
|
||||
|
||||
new MochiKit.DragAndDrop.Droppable('myelement');
|
||||
|
||||
Generally you'll want to define the 'ondrop' function and maybe the
|
||||
'accept' option to filter draggables.
|
||||
|
||||
***/
|
||||
__class__: MochiKit.DragAndDrop.Droppable,
|
||||
|
||||
__init__: function (element, /* optional */options) {
|
||||
var d = MochiKit.DOM;
|
||||
var b = MochiKit.Base;
|
||||
this.element = d.getElement(element);
|
||||
this.options = b.update({
|
||||
greedy: true,
|
||||
hoverclass: null,
|
||||
activeclass: null,
|
||||
hoverfunc: b.noop,
|
||||
accept: null,
|
||||
onactive: b.noop,
|
||||
ondesactive: b.noop,
|
||||
onhover: b.noop,
|
||||
ondrop: b.noop,
|
||||
containment: [],
|
||||
tree: false
|
||||
}, options || {});
|
||||
|
||||
// cache containers
|
||||
this.options._containers = [];
|
||||
b.map(MochiKit.Base.bind(function (c) {
|
||||
this.options._containers.push(d.getElement(c));
|
||||
}, this), this.options.containment);
|
||||
|
||||
d.makePositioned(this.element); // fix IE
|
||||
|
||||
MochiKit.DragAndDrop.Droppables.register(this);
|
||||
},
|
||||
|
||||
isContained: function (element) {
|
||||
if (this._containers) {
|
||||
var containmentNode;
|
||||
if (this.options.tree) {
|
||||
containmentNode = element.treeNode;
|
||||
} else {
|
||||
containmentNode = element.parentNode;
|
||||
}
|
||||
return MochiKit.Iter.some(this._containers, function (c) {
|
||||
return containmentNode == c;
|
||||
});
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
isAccepted: function (element) {
|
||||
return ((!this.options.accept) || MochiKit.Iter.some(
|
||||
this.options.accept, function (c) {
|
||||
return MochiKit.DOM.hasElementClass(element, c);
|
||||
}));
|
||||
},
|
||||
|
||||
isAffected: function (point, element) {
|
||||
return ((this.element != element) &&
|
||||
this.isContained(element) &&
|
||||
this.isAccepted(element) &&
|
||||
MochiKit.Position.within(this.element, point.page.x,
|
||||
point.page.y));
|
||||
},
|
||||
|
||||
deactivate: function () {
|
||||
/***
|
||||
|
||||
A droppable is deactivate when a draggable has been over it and left.
|
||||
|
||||
***/
|
||||
if (this.options.hoverclass) {
|
||||
MochiKit.DOM.removeElementClass(this.element,
|
||||
this.options.hoverclass);
|
||||
}
|
||||
this.options.hoverfunc(this.element, false);
|
||||
MochiKit.DragAndDrop.Droppables.last_active = null;
|
||||
},
|
||||
|
||||
activate: function () {
|
||||
/***
|
||||
|
||||
A droppable is active when a draggable is over it.
|
||||
|
||||
***/
|
||||
if (this.options.hoverclass) {
|
||||
MochiKit.DOM.addElementClass(this.element, this.options.hoverclass);
|
||||
}
|
||||
this.options.hoverfunc(this.element, true);
|
||||
MochiKit.DragAndDrop.Droppables.last_active = this;
|
||||
},
|
||||
|
||||
destroy: function () {
|
||||
/***
|
||||
|
||||
Delete this droppable.
|
||||
|
||||
***/
|
||||
MochiKit.DragAndDrop.Droppables.unregister(this);
|
||||
},
|
||||
|
||||
repr: function () {
|
||||
return '[' + this.__class__.NAME + ", options:" + MochiKit.Base.repr(this.options) + "]";
|
||||
}
|
||||
};
|
||||
|
||||
MochiKit.DragAndDrop.Draggables = {
|
||||
/***
|
||||
|
||||
Manage draggables elements. Not intended to direct use.
|
||||
|
||||
***/
|
||||
drags: [],
|
||||
|
||||
observers: [],
|
||||
|
||||
register: function (draggable) {
|
||||
if (this.drags.length === 0) {
|
||||
var conn = MochiKit.Signal.connect;
|
||||
this.eventMouseUp = conn(document, 'onmouseup', this, this.endDrag);
|
||||
this.eventMouseMove = conn(document, 'onmousemove', this,
|
||||
this.updateDrag);
|
||||
this.eventKeypress = conn(document, 'onkeypress', this,
|
||||
this.keyPress);
|
||||
}
|
||||
this.drags.push(draggable);
|
||||
},
|
||||
|
||||
unregister: function (draggable) {
|
||||
this.drags = MochiKit.Base.filter(function (d) {
|
||||
return d != draggable;
|
||||
}, this.drags);
|
||||
if (this.drags.length === 0) {
|
||||
var disc = MochiKit.Signal.disconnect
|
||||
disc(this.eventMouseUp);
|
||||
disc(this.eventMouseMove);
|
||||
disc(this.eventKeypress);
|
||||
}
|
||||
},
|
||||
|
||||
activate: function (draggable) {
|
||||
// allows keypress events if window is not currently focused
|
||||
// fails for Safari
|
||||
window.focus();
|
||||
this.activeDraggable = draggable;
|
||||
},
|
||||
|
||||
deactivate: function () {
|
||||
this.activeDraggable = null;
|
||||
},
|
||||
|
||||
updateDrag: function (event) {
|
||||
if (!this.activeDraggable) {
|
||||
return;
|
||||
}
|
||||
var pointer = event.mouse();
|
||||
// Mozilla-based browsers fire successive mousemove events with
|
||||
// the same coordinates, prevent needless redrawing (moz bug?)
|
||||
if (this._lastPointer && (MochiKit.Base.repr(this._lastPointer.page) ==
|
||||
MochiKit.Base.repr(pointer.page))) {
|
||||
return;
|
||||
}
|
||||
this._lastPointer = pointer;
|
||||
this.activeDraggable.updateDrag(event, pointer);
|
||||
},
|
||||
|
||||
endDrag: function (event) {
|
||||
if (!this.activeDraggable) {
|
||||
return;
|
||||
}
|
||||
this._lastPointer = null;
|
||||
this.activeDraggable.endDrag(event);
|
||||
this.activeDraggable = null;
|
||||
},
|
||||
|
||||
keyPress: function (event) {
|
||||
if (this.activeDraggable) {
|
||||
this.activeDraggable.keyPress(event);
|
||||
}
|
||||
},
|
||||
|
||||
addObserver: function (observer) {
|
||||
this.observers.push(observer);
|
||||
this._cacheObserverCallbacks();
|
||||
},
|
||||
|
||||
removeObserver: function (element) {
|
||||
// element instead of observer fixes mem leaks
|
||||
this.observers = MochiKit.Base.filter(function (o) {
|
||||
return o.element != element;
|
||||
}, this.observers);
|
||||
this._cacheObserverCallbacks();
|
||||
},
|
||||
|
||||
notify: function (eventName, draggable, event) {
|
||||
// 'onStart', 'onEnd', 'onDrag'
|
||||
if (this[eventName + 'Count'] > 0) {
|
||||
MochiKit.Base.map(function (o) {
|
||||
if (o[eventName]) {
|
||||
o[eventName](eventName, draggable, event);
|
||||
}
|
||||
}, this.observers);
|
||||
}
|
||||
},
|
||||
|
||||
_cacheObserverCallbacks: function () {
|
||||
var b = MochiKit.Base;
|
||||
var self = MochiKit.DragAndDrop.Draggables;
|
||||
b.map(function (eventName) {
|
||||
self[eventName + 'Count'] = b.filter(function (o) {
|
||||
return o[eventName];
|
||||
}, self.observers).length;
|
||||
}, ['onStart', 'onEnd', 'onDrag']);
|
||||
}
|
||||
};
|
||||
|
||||
MochiKit.DragAndDrop.Draggable = function (element, options) {
|
||||
this.__init__(element, options);
|
||||
};
|
||||
|
||||
MochiKit.DragAndDrop.Draggable.prototype = {
|
||||
/***
|
||||
|
||||
A draggable object. Simple instantiate :
|
||||
|
||||
new MochiKit.DragAndDrop.Draggable('myelement');
|
||||
|
||||
***/
|
||||
__class__ : MochiKit.DragAndDrop.Draggable,
|
||||
|
||||
__init__: function (element, /* optional */options) {
|
||||
var v = MochiKit.Visual;
|
||||
var b = MochiKit.Base;
|
||||
options = b.update({
|
||||
handle: false,
|
||||
starteffect: function (innerelement) {
|
||||
this._savedOpacity = MochiKit.DOM.getOpacity(innerelement) || 1.0;
|
||||
new v.Opacity(innerelement, {duration:0.2, from:this._savedOpacity, to:0.7});
|
||||
},
|
||||
reverteffect: function (innerelement, top_offset, left_offset) {
|
||||
var dur = Math.sqrt(Math.abs(top_offset^2) +
|
||||
Math.abs(left_offset^2))*0.02;
|
||||
return new v.Move(innerelement,
|
||||
{x: -left_offset, y: -top_offset, duration: dur});
|
||||
},
|
||||
endeffect: function (innerelement) {
|
||||
new v.Opacity(innerelement, {duration:0.2, from:0.7, to:this._savedOpacity});
|
||||
},
|
||||
onchange: b.noop,
|
||||
zindex: 1000,
|
||||
revert: false,
|
||||
scroll: false,
|
||||
scrollSensitivity: 20,
|
||||
scrollSpeed: 15,
|
||||
// false, or xy or [x, y] or function (x, y){return [x, y];}
|
||||
snap: false
|
||||
}, options || {});
|
||||
|
||||
var d = MochiKit.DOM;
|
||||
this.element = d.getElement(element);
|
||||
|
||||
if (options.handle && (typeof(options.handle) == 'string')) {
|
||||
this.handle = d.getFirstElementByTagAndClassName(null,
|
||||
options.handle, this.element);
|
||||
}
|
||||
if (!this.handle) {
|
||||
this.handle = d.getElement(options.handle);
|
||||
}
|
||||
if (!this.handle) {
|
||||
this.handle = this.element;
|
||||
}
|
||||
|
||||
if (options.scroll && !options.scroll.scrollTo && !options.scroll.outerHTML) {
|
||||
options.scroll = d.getElement(options.scroll);
|
||||
}
|
||||
|
||||
d.makePositioned(this.element); // fix IE
|
||||
|
||||
this.delta = this.currentDelta();
|
||||
this.options = options;
|
||||
this.dragging = false;
|
||||
|
||||
this.eventMouseDown = MochiKit.Signal.connect(this.handle,
|
||||
'onmousedown', this, this.initDrag);
|
||||
MochiKit.DragAndDrop.Draggables.register(this);
|
||||
},
|
||||
|
||||
destroy: function () {
|
||||
MochiKit.Signal.disconnect(this.eventMouseDown);
|
||||
MochiKit.DragAndDrop.Draggables.unregister(this);
|
||||
},
|
||||
|
||||
currentDelta: function () {
|
||||
var s = MochiKit.DOM.getStyle;
|
||||
return [
|
||||
parseInt(s(this.element, 'left') || '0'),
|
||||
parseInt(s(this.element, 'top') || '0')];
|
||||
},
|
||||
|
||||
initDrag: function (event) {
|
||||
if (!event.mouse().button.left) {
|
||||
return;
|
||||
}
|
||||
// abort on form elements, fixes a Firefox issue
|
||||
var src = event.target;
|
||||
if (src.tagName && (
|
||||
src.tagName == 'INPUT' || src.tagName == 'SELECT' ||
|
||||
src.tagName == 'OPTION' || src.tagName == 'BUTTON' ||
|
||||
src.tagName == 'TEXTAREA')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this._revert) {
|
||||
this._revert.cancel();
|
||||
this._revert = null;
|
||||
}
|
||||
|
||||
var pointer = event.mouse();
|
||||
var pos = MochiKit.Position.cumulativeOffset(this.element);
|
||||
this.offset = [pointer.page.x - pos.x, pointer.page.y - pos.y]
|
||||
|
||||
MochiKit.DragAndDrop.Draggables.activate(this);
|
||||
event.stop();
|
||||
},
|
||||
|
||||
startDrag: function (event) {
|
||||
this.dragging = true;
|
||||
if (this.options.selectclass) {
|
||||
MochiKit.DOM.addElementClass(this.element,
|
||||
this.options.selectclass);
|
||||
}
|
||||
if (this.options.zindex) {
|
||||
this.originalZ = parseInt(MochiKit.DOM.getStyle(this.element,
|
||||
'z-index') || '0');
|
||||
this.element.style.zIndex = this.options.zindex;
|
||||
}
|
||||
|
||||
if (this.options.ghosting) {
|
||||
this._clone = this.element.cloneNode(true);
|
||||
this.ghostPosition = MochiKit.Position.absolutize(this.element);
|
||||
this.element.parentNode.insertBefore(this._clone, this.element);
|
||||
}
|
||||
|
||||
if (this.options.scroll) {
|
||||
if (this.options.scroll == window) {
|
||||
var where = this._getWindowScroll(this.options.scroll);
|
||||
this.originalScrollLeft = where.left;
|
||||
this.originalScrollTop = where.top;
|
||||
} else {
|
||||
this.originalScrollLeft = this.options.scroll.scrollLeft;
|
||||
this.originalScrollTop = this.options.scroll.scrollTop;
|
||||
}
|
||||
}
|
||||
|
||||
MochiKit.DragAndDrop.Droppables.prepare(this.element);
|
||||
MochiKit.DragAndDrop.Draggables.notify('onStart', this, event);
|
||||
if (this.options.starteffect) {
|
||||
this.options.starteffect(this.element);
|
||||
}
|
||||
},
|
||||
|
||||
updateDrag: function (event, pointer) {
|
||||
if (!this.dragging) {
|
||||
this.startDrag(event);
|
||||
}
|
||||
MochiKit.Position.prepare();
|
||||
MochiKit.DragAndDrop.Droppables.show(pointer, this.element);
|
||||
MochiKit.DragAndDrop.Draggables.notify('onDrag', this, event);
|
||||
this.draw(pointer);
|
||||
this.options.onchange(this);
|
||||
|
||||
if (this.options.scroll) {
|
||||
this.stopScrolling();
|
||||
var p, q;
|
||||
if (this.options.scroll == window) {
|
||||
var s = this._getWindowScroll(this.options.scroll);
|
||||
p = new MochiKit.Style.Coordinates(s.left, s.top);
|
||||
q = new MochiKit.Style.Coordinates(s.left + s.width,
|
||||
s.top + s.height);
|
||||
} else {
|
||||
p = MochiKit.Position.page(this.options.scroll);
|
||||
p.x += this.options.scroll.scrollLeft;
|
||||
p.y += this.options.scroll.scrollTop;
|
||||
q = new MochiKit.Style.Coordinates(p.x + this.options.scroll.offsetWidth,
|
||||
p.y + this.options.scroll.offsetHeight);
|
||||
}
|
||||
var speed = [0, 0];
|
||||
if (pointer.page.x > (q.x - this.options.scrollSensitivity)) {
|
||||
speed[0] = pointer.page.x - (q.x - this.options.scrollSensitivity);
|
||||
} else if (pointer.page.x < (p.x + this.options.scrollSensitivity)) {
|
||||
speed[0] = pointer.page.x - (p.x + this.options.scrollSensitivity);
|
||||
}
|
||||
if (pointer.page.y > (q.y - this.options.scrollSensitivity)) {
|
||||
speed[1] = pointer.page.y - (q.y - this.options.scrollSensitivity);
|
||||
} else if (pointer.page.y < (p.y + this.options.scrollSensitivity)) {
|
||||
speed[1] = pointer.page.y - (p.y + this.options.scrollSensitivity);
|
||||
}
|
||||
this.startScrolling(speed);
|
||||
}
|
||||
|
||||
// fix AppleWebKit rendering
|
||||
if (MochiKit.Base.isSafari()) {
|
||||
window.scrollBy(0, 0);
|
||||
}
|
||||
event.stop();
|
||||
},
|
||||
|
||||
finishDrag: function (event, success) {
|
||||
var dr = MochiKit.DragAndDrop;
|
||||
this.dragging = false;
|
||||
if (this.options.selectclass) {
|
||||
MochiKit.DOM.removeElementClass(this.element,
|
||||
this.options.selectclass);
|
||||
}
|
||||
|
||||
if (this.options.ghosting) {
|
||||
// XXX: from a user point of view, it would be better to remove
|
||||
// the node only *after* the MochiKit.Visual.Move end when used
|
||||
// with revert.
|
||||
MochiKit.Position.relativize(this.element, this.ghostPosition);
|
||||
MochiKit.DOM.removeElement(this._clone);
|
||||
this._clone = null;
|
||||
}
|
||||
|
||||
if (success) {
|
||||
dr.Droppables.fire(event, this.element);
|
||||
}
|
||||
dr.Draggables.notify('onEnd', this, event);
|
||||
|
||||
var revert = this.options.revert;
|
||||
if (revert && typeof(revert) == 'function') {
|
||||
revert = revert(this.element);
|
||||
}
|
||||
|
||||
var d = this.currentDelta();
|
||||
if (revert && this.options.reverteffect) {
|
||||
this._revert = this.options.reverteffect(this.element,
|
||||
d[1] - this.delta[1], d[0] - this.delta[0]);
|
||||
} else {
|
||||
this.delta = d;
|
||||
}
|
||||
|
||||
if (this.options.zindex) {
|
||||
this.element.style.zIndex = this.originalZ;
|
||||
}
|
||||
|
||||
if (this.options.endeffect) {
|
||||
this.options.endeffect(this.element);
|
||||
}
|
||||
|
||||
dr.Draggables.deactivate();
|
||||
dr.Droppables.reset(this.element);
|
||||
},
|
||||
|
||||
keyPress: function (event) {
|
||||
if (event.keyString != "KEY_ESCAPE") {
|
||||
return;
|
||||
}
|
||||
this.finishDrag(event, false);
|
||||
event.stop();
|
||||
},
|
||||
|
||||
endDrag: function (event) {
|
||||
if (!this.dragging) {
|
||||
return;
|
||||
}
|
||||
this.stopScrolling();
|
||||
this.finishDrag(event, true);
|
||||
event.stop();
|
||||
},
|
||||
|
||||
draw: function (point) {
|
||||
var pos = MochiKit.Position.cumulativeOffset(this.element);
|
||||
var d = this.currentDelta();
|
||||
pos.x -= d[0];
|
||||
pos.y -= d[1];
|
||||
|
||||
if (this.options.scroll && !this.options.scroll.scrollTo) {
|
||||
pos.x -= this.options.scroll.scrollLeft - this.originalScrollLeft;
|
||||
pos.y -= this.options.scroll.scrollTop - this.originalScrollTop;
|
||||
}
|
||||
|
||||
var p = [point.page.x - pos.x - this.offset[0],
|
||||
point.page.y - pos.y - this.offset[1]]
|
||||
|
||||
if (this.options.snap) {
|
||||
if (typeof(this.options.snap) == 'function') {
|
||||
p = this.options.snap(p[0], p[1]);
|
||||
} else {
|
||||
if (this.options.snap instanceof Array) {
|
||||
var i = -1;
|
||||
p = MochiKit.Base.map(MochiKit.Base.bind(function (v) {
|
||||
i += 1;
|
||||
return Math.round(v/this.options.snap[i]) *
|
||||
this.options.snap[i]
|
||||
}, this), p)
|
||||
} else {
|
||||
p = MochiKit.Base.map(MochiKit.Base.bind(function (v) {
|
||||
return Math.round(v/this.options.snap) *
|
||||
this.options.snap
|
||||
}, this), p)
|
||||
}
|
||||
}
|
||||
}
|
||||
var style = this.element.style;
|
||||
if ((!this.options.constraint) ||
|
||||
(this.options.constraint == 'horizontal')) {
|
||||
style.left = p[0] + 'px';
|
||||
}
|
||||
if ((!this.options.constraint) ||
|
||||
(this.options.constraint == 'vertical')) {
|
||||
style.top = p[1] + 'px';
|
||||
}
|
||||
if (style.visibility == 'hidden') {
|
||||
style.visibility = ''; // fix gecko rendering
|
||||
}
|
||||
},
|
||||
|
||||
stopScrolling: function () {
|
||||
if (this.scrollInterval) {
|
||||
clearInterval(this.scrollInterval);
|
||||
this.scrollInterval = null;
|
||||
}
|
||||
},
|
||||
|
||||
startScrolling: function (speed) {
|
||||
if (!speed[0] || !speed[1]) {
|
||||
return;
|
||||
}
|
||||
this.scrollSpeed = [speed[0] * this.options.scrollSpeed,
|
||||
speed[1] * this.options.scrollSpeed];
|
||||
this.lastScrolled = new Date();
|
||||
this.scrollInterval = setInterval(MochiKit.Base.bind(this.scroll, this), 10);
|
||||
},
|
||||
|
||||
scroll: function () {
|
||||
var current = new Date();
|
||||
var delta = current - this.lastScrolled;
|
||||
this.lastScrolled = current;
|
||||
|
||||
if (this.options.scroll == window) {
|
||||
var s = this._getWindowScroll(this.options.scroll);
|
||||
if (this.scrollSpeed[0] || this.scrollSpeed[1]) {
|
||||
var d = delta / 1000;
|
||||
this.options.scroll.scrollTo(s.left + d * this.scrollSpeed[0],
|
||||
s.top + d * this.scrollSpeed[1]);
|
||||
}
|
||||
} else {
|
||||
this.options.scroll.scrollLeft += this.scrollSpeed[0] * delta / 1000;
|
||||
this.options.scroll.scrollTop += this.scrollSpeed[1] * delta / 1000;
|
||||
}
|
||||
|
||||
var d = MochiKit.DragAndDrop;
|
||||
|
||||
MochiKit.Position.prepare();
|
||||
d.Droppables.show(d.Draggables._lastPointer, this.element);
|
||||
this.draw(d.Draggables._lastPointer);
|
||||
this.options.onchange(this);
|
||||
},
|
||||
|
||||
_getWindowScroll: function (w) {
|
||||
var T, L, W, H;
|
||||
with (w.document) {
|
||||
if (w.document.documentElement && documentElement.scrollTop) {
|
||||
T = documentElement.scrollTop;
|
||||
L = documentElement.scrollLeft;
|
||||
} else if (w.document.body) {
|
||||
T = body.scrollTop;
|
||||
L = body.scrollLeft;
|
||||
}
|
||||
if (w.innerWidth) {
|
||||
W = w.innerWidth;
|
||||
H = w.innerHeight;
|
||||
} else if (w.document.documentElement && documentElement.clientWidth) {
|
||||
W = documentElement.clientWidth;
|
||||
H = documentElement.clientHeight;
|
||||
} else {
|
||||
W = body.offsetWidth;
|
||||
H = body.offsetHeight
|
||||
}
|
||||
}
|
||||
return {top: T, left: L, width: W, height: H};
|
||||
},
|
||||
|
||||
repr: function () {
|
||||
return '[' + this.__class__.NAME + ", options:" + MochiKit.Base.repr(this.options) + "]";
|
||||
}
|
||||
};
|
||||
|
||||
MochiKit.DragAndDrop.__new__ = function () {
|
||||
MochiKit.Base.nameFunctions(this);
|
||||
|
||||
this.EXPORT_TAGS = {
|
||||
":common": this.EXPORT,
|
||||
":all": MochiKit.Base.concat(this.EXPORT, this.EXPORT_OK)
|
||||
};
|
||||
};
|
||||
|
||||
MochiKit.DragAndDrop.__new__();
|
||||
|
||||
MochiKit.Base._exportSymbols(this, MochiKit.DragAndDrop);
|
||||
|
||||
294
crystalreportviewers13/js/MochiKit/Format.js
Normal file
@@ -0,0 +1,294 @@
|
||||
/***
|
||||
|
||||
MochiKit.Format 1.4
|
||||
|
||||
See <http://mochikit.com/> for documentation, downloads, license, etc.
|
||||
|
||||
(c) 2005 Bob Ippolito. All rights Reserved.
|
||||
|
||||
***/
|
||||
|
||||
if (typeof(dojo) != 'undefined') {
|
||||
dojo.provide('MochiKit.Format');
|
||||
}
|
||||
|
||||
if (typeof(MochiKit) == 'undefined') {
|
||||
MochiKit = {};
|
||||
}
|
||||
|
||||
if (typeof(MochiKit.Format) == 'undefined') {
|
||||
MochiKit.Format = {};
|
||||
}
|
||||
|
||||
MochiKit.Format.NAME = "MochiKit.Format";
|
||||
MochiKit.Format.VERSION = "1.4";
|
||||
MochiKit.Format.__repr__ = function () {
|
||||
return "[" + this.NAME + " " + this.VERSION + "]";
|
||||
};
|
||||
MochiKit.Format.toString = function () {
|
||||
return this.__repr__();
|
||||
};
|
||||
|
||||
MochiKit.Format._numberFormatter = function (placeholder, header, footer, locale, isPercent, precision, leadingZeros, separatorAt, trailingZeros) {
|
||||
return function (num) {
|
||||
num = parseFloat(num);
|
||||
if (typeof(num) == "undefined" || num === null || isNaN(num)) {
|
||||
return placeholder;
|
||||
}
|
||||
var curheader = header;
|
||||
var curfooter = footer;
|
||||
if (num < 0) {
|
||||
num = -num;
|
||||
} else {
|
||||
curheader = curheader.replace(/-/, "");
|
||||
}
|
||||
var me = arguments.callee;
|
||||
var fmt = MochiKit.Format.formatLocale(locale);
|
||||
if (isPercent) {
|
||||
num = num * 100.0;
|
||||
curfooter = fmt.percent + curfooter;
|
||||
}
|
||||
num = MochiKit.Format.roundToFixed(num, precision);
|
||||
var parts = num.split(/\./);
|
||||
var whole = parts[0];
|
||||
var frac = (parts.length == 1) ? "" : parts[1];
|
||||
var res = "";
|
||||
while (whole.length < leadingZeros) {
|
||||
whole = "0" + whole;
|
||||
}
|
||||
if (separatorAt) {
|
||||
while (whole.length > separatorAt) {
|
||||
var i = whole.length - separatorAt;
|
||||
//res = res + fmt.separator + whole.substring(i, whole.length);
|
||||
res = fmt.separator + whole.substring(i, whole.length) + res;
|
||||
whole = whole.substring(0, i);
|
||||
}
|
||||
}
|
||||
res = whole + res;
|
||||
if (precision > 0) {
|
||||
while (frac.length < trailingZeros) {
|
||||
frac = frac + "0";
|
||||
}
|
||||
res = res + fmt.decimal + frac;
|
||||
}
|
||||
return curheader + res + curfooter;
|
||||
};
|
||||
};
|
||||
|
||||
MochiKit.Format.numberFormatter = function (pattern, placeholder/* = "" */, locale/* = "default" */) {
|
||||
// http://java.sun.com/docs/books/tutorial/i18n/format/numberpattern.html
|
||||
// | 0 | leading or trailing zeros
|
||||
// | # | just the number
|
||||
// | , | separator
|
||||
// | . | decimal separator
|
||||
// | % | Multiply by 100 and format as percent
|
||||
if (typeof(placeholder) == "undefined") {
|
||||
placeholder = "";
|
||||
}
|
||||
var match = pattern.match(/((?:[0#]+,)?[0#]+)(?:\.([0#]+))?(%)?/);
|
||||
if (!match) {
|
||||
throw TypeError("Invalid pattern");
|
||||
}
|
||||
var header = pattern.substr(0, match.index);
|
||||
var footer = pattern.substr(match.index + match[0].length);
|
||||
if (header.search(/-/) == -1) {
|
||||
header = header + "-";
|
||||
}
|
||||
var whole = match[1];
|
||||
var frac = (typeof(match[2]) == "string" && match[2] != "") ? match[2] : "";
|
||||
var isPercent = (typeof(match[3]) == "string" && match[3] != "");
|
||||
var tmp = whole.split(/,/);
|
||||
var separatorAt;
|
||||
if (typeof(locale) == "undefined") {
|
||||
locale = "default";
|
||||
}
|
||||
if (tmp.length == 1) {
|
||||
separatorAt = null;
|
||||
} else {
|
||||
separatorAt = tmp[1].length;
|
||||
}
|
||||
var leadingZeros = whole.length - whole.replace(/0/g, "").length;
|
||||
var trailingZeros = frac.length - frac.replace(/0/g, "").length;
|
||||
var precision = frac.length;
|
||||
var rval = MochiKit.Format._numberFormatter(
|
||||
placeholder, header, footer, locale, isPercent, precision,
|
||||
leadingZeros, separatorAt, trailingZeros
|
||||
);
|
||||
var m = MochiKit.Base;
|
||||
if (m) {
|
||||
var fn = arguments.callee;
|
||||
var args = m.concat(arguments);
|
||||
rval.repr = function () {
|
||||
return [
|
||||
self.NAME,
|
||||
"(",
|
||||
map(m.repr, args).join(", "),
|
||||
")"
|
||||
].join("");
|
||||
};
|
||||
}
|
||||
return rval;
|
||||
};
|
||||
|
||||
MochiKit.Format.formatLocale = function (locale) {
|
||||
if (typeof(locale) == "undefined" || locale === null) {
|
||||
locale = "default";
|
||||
}
|
||||
if (typeof(locale) == "string") {
|
||||
var rval = MochiKit.Format.LOCALE[locale];
|
||||
if (typeof(rval) == "string") {
|
||||
rval = arguments.callee(rval);
|
||||
MochiKit.Format.LOCALE[locale] = rval;
|
||||
}
|
||||
return rval;
|
||||
} else {
|
||||
return locale;
|
||||
}
|
||||
};
|
||||
|
||||
MochiKit.Format.twoDigitAverage = function (numerator, denominator) {
|
||||
if (denominator) {
|
||||
var res = numerator / denominator;
|
||||
if (!isNaN(res)) {
|
||||
return MochiKit.Format.twoDigitFloat(numerator / denominator);
|
||||
}
|
||||
}
|
||||
return "0";
|
||||
};
|
||||
|
||||
MochiKit.Format.twoDigitFloat = function (someFloat) {
|
||||
var sign = (someFloat < 0 ? '-' : '');
|
||||
var s = Math.floor(Math.abs(someFloat) * 100).toString();
|
||||
if (s == '0') {
|
||||
return s;
|
||||
}
|
||||
if (s.length < 3) {
|
||||
while (s.charAt(s.length - 1) == '0') {
|
||||
s = s.substring(0, s.length - 1);
|
||||
}
|
||||
return sign + '0.' + s;
|
||||
}
|
||||
var head = sign + s.substring(0, s.length - 2);
|
||||
var tail = s.substring(s.length - 2, s.length);
|
||||
if (tail == '00') {
|
||||
return head;
|
||||
} else if (tail.charAt(1) == '0') {
|
||||
return head + '.' + tail.charAt(0);
|
||||
} else {
|
||||
return head + '.' + tail;
|
||||
}
|
||||
};
|
||||
|
||||
MochiKit.Format.lstrip = function (str, /* optional */chars) {
|
||||
str = str + "";
|
||||
if (typeof(str) != "string") {
|
||||
return null;
|
||||
}
|
||||
if (!chars) {
|
||||
return str.replace(/^\s+/, "");
|
||||
} else {
|
||||
return str.replace(new RegExp("^[" + chars + "]+"), "");
|
||||
}
|
||||
};
|
||||
|
||||
MochiKit.Format.rstrip = function (str, /* optional */chars) {
|
||||
str = str + "";
|
||||
if (typeof(str) != "string") {
|
||||
return null;
|
||||
}
|
||||
if (!chars) {
|
||||
return str.replace(/\s+$/, "");
|
||||
} else {
|
||||
return str.replace(new RegExp("[" + chars + "]+$"), "");
|
||||
}
|
||||
};
|
||||
|
||||
MochiKit.Format.strip = function (str, /* optional */chars) {
|
||||
var self = MochiKit.Format;
|
||||
return self.rstrip(self.lstrip(str, chars), chars);
|
||||
};
|
||||
|
||||
MochiKit.Format.truncToFixed = function (aNumber, precision) {
|
||||
aNumber = Math.floor(aNumber * Math.pow(10, precision));
|
||||
var res = (aNumber * Math.pow(10, -precision)).toFixed(precision);
|
||||
if (res.charAt(0) == ".") {
|
||||
res = "0" + res;
|
||||
}
|
||||
return res;
|
||||
};
|
||||
|
||||
MochiKit.Format.roundToFixed = function (aNumber, precision) {
|
||||
return MochiKit.Format.truncToFixed(
|
||||
aNumber + 0.5 * Math.pow(10, -precision),
|
||||
precision
|
||||
);
|
||||
};
|
||||
|
||||
MochiKit.Format.percentFormat = function (someFloat) {
|
||||
return MochiKit.Format.twoDigitFloat(100 * someFloat) + '%';
|
||||
};
|
||||
|
||||
MochiKit.Format.EXPORT = [
|
||||
"truncToFixed",
|
||||
"roundToFixed",
|
||||
"numberFormatter",
|
||||
"formatLocale",
|
||||
"twoDigitAverage",
|
||||
"twoDigitFloat",
|
||||
"percentFormat",
|
||||
"lstrip",
|
||||
"rstrip",
|
||||
"strip"
|
||||
];
|
||||
|
||||
MochiKit.Format.LOCALE = {
|
||||
en_US: {separator: ",", decimal: ".", percent: "%"},
|
||||
de_DE: {separator: ".", decimal: ",", percent: "%"},
|
||||
fr_FR: {separator: " ", decimal: ",", percent: "%"},
|
||||
"default": "en_US"
|
||||
};
|
||||
|
||||
MochiKit.Format.EXPORT_OK = [];
|
||||
MochiKit.Format.EXPORT_TAGS = {
|
||||
':all': MochiKit.Format.EXPORT,
|
||||
':common': MochiKit.Format.EXPORT
|
||||
};
|
||||
|
||||
MochiKit.Format.__new__ = function () {
|
||||
// MochiKit.Base.nameFunctions(this);
|
||||
var base = this.NAME + ".";
|
||||
var k, v, o;
|
||||
for (k in this.LOCALE) {
|
||||
o = this.LOCALE[k];
|
||||
if (typeof(o) == "object") {
|
||||
o.repr = function () { return this.NAME; };
|
||||
o.NAME = base + "LOCALE." + k;
|
||||
}
|
||||
}
|
||||
for (k in this) {
|
||||
o = this[k];
|
||||
if (typeof(o) == 'function' && typeof(o.NAME) == 'undefined') {
|
||||
try {
|
||||
o.NAME = base + k;
|
||||
} catch (e) {
|
||||
// pass
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
MochiKit.Format.__new__();
|
||||
|
||||
if (typeof(MochiKit.Base) != "undefined") {
|
||||
MochiKit.Base._exportSymbols(this, MochiKit.Format);
|
||||
} else {
|
||||
(function (globals, module) {
|
||||
if ((typeof(JSAN) == 'undefined' && typeof(dojo) == 'undefined')
|
||||
|| (MochiKit.__export__ === false)) {
|
||||
var all = module.EXPORT_TAGS[":all"];
|
||||
for (var i = 0; i < all.length; i++) {
|
||||
globals[all[i]] = module[all[i]];
|
||||
}
|
||||
}
|
||||
})(this, MochiKit.Format);
|
||||
}
|
||||
807
crystalreportviewers13/js/MochiKit/Iter.js
Normal file
@@ -0,0 +1,807 @@
|
||||
/***
|
||||
|
||||
MochiKit.Iter 1.4
|
||||
|
||||
See <http://mochikit.com/> for documentation, downloads, license, etc.
|
||||
|
||||
(c) 2005 Bob Ippolito. All rights Reserved.
|
||||
|
||||
***/
|
||||
if (typeof(dojo) != 'undefined') {
|
||||
dojo.provide('MochiKit.Iter');
|
||||
dojo.require('MochiKit.Base');
|
||||
}
|
||||
|
||||
if (typeof(JSAN) != 'undefined') {
|
||||
JSAN.use("MochiKit.Base", []);
|
||||
}
|
||||
|
||||
try {
|
||||
if (typeof(MochiKit.Base) == 'undefined') {
|
||||
throw "";
|
||||
}
|
||||
} catch (e) {
|
||||
throw "MochiKit.Iter depends on MochiKit.Base!";
|
||||
}
|
||||
|
||||
if (typeof(MochiKit.Iter) == 'undefined') {
|
||||
MochiKit.Iter = {};
|
||||
}
|
||||
|
||||
MochiKit.Iter.NAME = "MochiKit.Iter";
|
||||
MochiKit.Iter.VERSION = "1.4";
|
||||
MochiKit.Base.update(MochiKit.Iter, {
|
||||
__repr__: function () {
|
||||
return "[" + this.NAME + " " + this.VERSION + "]";
|
||||
},
|
||||
toString: function () {
|
||||
return this.__repr__();
|
||||
},
|
||||
|
||||
registerIteratorFactory: function (name, check, iterfactory, /* optional */ override) {
|
||||
MochiKit.Iter.iteratorRegistry.register(name, check, iterfactory, override);
|
||||
},
|
||||
|
||||
iter: function (iterable, /* optional */ sentinel) {
|
||||
var self = MochiKit.Iter;
|
||||
if (arguments.length == 2) {
|
||||
return self.takewhile(
|
||||
function (a) { return a != sentinel; },
|
||||
iterable
|
||||
);
|
||||
}
|
||||
if (typeof(iterable.next) == 'function') {
|
||||
return iterable;
|
||||
} else if (typeof(iterable.iter) == 'function') {
|
||||
return iterable.iter();
|
||||
/*
|
||||
} else if (typeof(iterable.__iterator__) == 'function') {
|
||||
//
|
||||
// XXX: We can't support JavaScript 1.7 __iterator__ directly
|
||||
// because of Object.prototype.__iterator__
|
||||
//
|
||||
return iterable.__iterator__();
|
||||
*/
|
||||
}
|
||||
|
||||
try {
|
||||
return self.iteratorRegistry.match(iterable);
|
||||
} catch (e) {
|
||||
var m = MochiKit.Base;
|
||||
if (e == m.NotFound) {
|
||||
e = new TypeError(typeof(iterable) + ": " + m.repr(iterable) + " is not iterable");
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
},
|
||||
|
||||
// count: function (n) {
|
||||
// if (!n) {
|
||||
// n = 0;
|
||||
// }
|
||||
// var m = MochiKit.Base;
|
||||
// return {
|
||||
// repr: function () { return "count(" + n + ")"; },
|
||||
// toString: m.forwardCall("repr"),
|
||||
// next: m.counter(n)
|
||||
// };
|
||||
// },
|
||||
|
||||
// cycle: function (p) {
|
||||
// var self = MochiKit.Iter;
|
||||
// var m = MochiKit.Base;
|
||||
// var lst = [];
|
||||
// var iterator = self.iter(p);
|
||||
// return {
|
||||
// repr: function () { return "cycle(...)"; },
|
||||
// toString: m.forwardCall("repr"),
|
||||
// next: function () {
|
||||
// try {
|
||||
// var rval = iterator.next();
|
||||
// lst.push(rval);
|
||||
// return rval;
|
||||
// } catch (e) {
|
||||
// if (e != self.StopIteration) {
|
||||
// throw e;
|
||||
// }
|
||||
// if (lst.length === 0) {
|
||||
// this.next = function () {
|
||||
// throw self.StopIteration;
|
||||
// };
|
||||
// } else {
|
||||
// var i = -1;
|
||||
// this.next = function () {
|
||||
// i = (i + 1) % lst.length;
|
||||
// return lst[i];
|
||||
// };
|
||||
// }
|
||||
// return this.next();
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
// },
|
||||
|
||||
repeat: function (elem, /* optional */n) {
|
||||
var m = MochiKit.Base;
|
||||
if (typeof(n) == 'undefined') {
|
||||
return {
|
||||
repr: function () {
|
||||
return "repeat(" + m.repr(elem) + ")";
|
||||
},
|
||||
toString: m.forwardCall("repr"),
|
||||
next: function () {
|
||||
return elem;
|
||||
}
|
||||
};
|
||||
}
|
||||
return {
|
||||
repr: function () {
|
||||
return "repeat(" + m.repr(elem) + ", " + n + ")";
|
||||
},
|
||||
toString: m.forwardCall("repr"),
|
||||
next: function () {
|
||||
if (n <= 0) {
|
||||
throw MochiKit.Iter.StopIteration;
|
||||
}
|
||||
n -= 1;
|
||||
return elem;
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
next: function (iterator) {
|
||||
return iterator.next();
|
||||
},
|
||||
|
||||
// izip: function (p, q/*, ...*/) {
|
||||
// var m = MochiKit.Base;
|
||||
// var self = MochiKit.Iter;
|
||||
// var next = self.next;
|
||||
// var iterables = m.map(self.iter, arguments);
|
||||
// return {
|
||||
// repr: function () { return "izip(...)"; },
|
||||
// toString: m.forwardCall("repr"),
|
||||
// next: function () { return m.map(next, iterables); }
|
||||
// };
|
||||
// },
|
||||
|
||||
ifilter: function (pred, seq) {
|
||||
var m = MochiKit.Base;
|
||||
seq = MochiKit.Iter.iter(seq);
|
||||
if (pred === null) {
|
||||
pred = m.operator.truth;
|
||||
}
|
||||
return {
|
||||
repr: function () { return "ifilter(...)"; },
|
||||
toString: m.forwardCall("repr"),
|
||||
next: function () {
|
||||
while (true) {
|
||||
var rval = seq.next();
|
||||
if (pred(rval)) {
|
||||
return rval;
|
||||
}
|
||||
}
|
||||
// mozilla warnings aren't too bright
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
ifilterfalse: function (pred, seq) {
|
||||
var m = MochiKit.Base;
|
||||
seq = MochiKit.Iter.iter(seq);
|
||||
if (pred === null) {
|
||||
pred = m.operator.truth;
|
||||
}
|
||||
return {
|
||||
repr: function () { return "ifilterfalse(...)"; },
|
||||
toString: m.forwardCall("repr"),
|
||||
next: function () {
|
||||
while (true) {
|
||||
var rval = seq.next();
|
||||
if (!pred(rval)) {
|
||||
return rval;
|
||||
}
|
||||
}
|
||||
// mozilla warnings aren't too bright
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
// islice: function (seq/*, [start,] stop[, step] */) {
|
||||
// var self = MochiKit.Iter;
|
||||
// var m = MochiKit.Base;
|
||||
// seq = self.iter(seq);
|
||||
// var start = 0;
|
||||
// var stop = 0;
|
||||
// var step = 1;
|
||||
// var i = -1;
|
||||
// if (arguments.length == 2) {
|
||||
// stop = arguments[1];
|
||||
// } else if (arguments.length == 3) {
|
||||
// start = arguments[1];
|
||||
// stop = arguments[2];
|
||||
// } else {
|
||||
// start = arguments[1];
|
||||
// stop = arguments[2];
|
||||
// step = arguments[3];
|
||||
// }
|
||||
// return {
|
||||
// repr: function () {
|
||||
// return "islice(" + ["...", start, stop, step].join(", ") + ")";
|
||||
// },
|
||||
// toString: m.forwardCall("repr"),
|
||||
// next: function () {
|
||||
// var rval;
|
||||
// while (i < start) {
|
||||
// rval = seq.next();
|
||||
// i++;
|
||||
// }
|
||||
// if (start >= stop) {
|
||||
// throw self.StopIteration;
|
||||
// }
|
||||
// start += step;
|
||||
// return rval;
|
||||
// }
|
||||
// };
|
||||
// },
|
||||
|
||||
imap: function (fun, p, q/*, ...*/) {
|
||||
var m = MochiKit.Base;
|
||||
var self = MochiKit.Iter;
|
||||
var iterables = m.map(self.iter, m.extend(null, arguments, 1));
|
||||
var map = m.map;
|
||||
var next = self.next;
|
||||
return {
|
||||
repr: function () { return "imap(...)"; },
|
||||
toString: m.forwardCall("repr"),
|
||||
next: function () {
|
||||
return fun.apply(this, map(next, iterables));
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
// applymap: function (fun, seq, self) {
|
||||
// seq = MochiKit.Iter.iter(seq);
|
||||
// var m = MochiKit.Base;
|
||||
// return {
|
||||
// repr: function () { return "applymap(...)"; },
|
||||
// toString: m.forwardCall("repr"),
|
||||
// next: function () {
|
||||
// return fun.apply(self, seq.next());
|
||||
// }
|
||||
// };
|
||||
// },
|
||||
|
||||
// chain: function (p, q/*, ...*/) {
|
||||
// // dumb fast path
|
||||
// var self = MochiKit.Iter;
|
||||
// var m = MochiKit.Base;
|
||||
// if (arguments.length == 1) {
|
||||
// return self.iter(arguments[0]);
|
||||
// }
|
||||
// var argiter = m.map(self.iter, arguments);
|
||||
// return {
|
||||
// repr: function () { return "chain(...)"; },
|
||||
// toString: m.forwardCall("repr"),
|
||||
// next: function () {
|
||||
// while (argiter.length > 1) {
|
||||
// try {
|
||||
// return argiter[0].next();
|
||||
// } catch (e) {
|
||||
// if (e != self.StopIteration) {
|
||||
// throw e;
|
||||
// }
|
||||
// argiter.shift();
|
||||
// }
|
||||
// }
|
||||
// if (argiter.length == 1) {
|
||||
// // optimize last element
|
||||
// var arg = argiter.shift();
|
||||
// this.next = m.bind("next", arg);
|
||||
// return this.next();
|
||||
// }
|
||||
// throw self.StopIteration;
|
||||
// }
|
||||
// };
|
||||
// },
|
||||
|
||||
// takewhile: function (pred, seq) {
|
||||
// var self = MochiKit.Iter;
|
||||
// seq = self.iter(seq);
|
||||
// return {
|
||||
// repr: function () { return "takewhile(...)"; },
|
||||
// toString: MochiKit.Base.forwardCall("repr"),
|
||||
// next: function () {
|
||||
// var rval = seq.next();
|
||||
// if (!pred(rval)) {
|
||||
// this.next = function () {
|
||||
// throw self.StopIteration;
|
||||
// };
|
||||
// this.next();
|
||||
// }
|
||||
// return rval;
|
||||
// }
|
||||
// };
|
||||
// },
|
||||
|
||||
// dropwhile: function (pred, seq) {
|
||||
// seq = MochiKit.Iter.iter(seq);
|
||||
// var m = MochiKit.Base;
|
||||
// var bind = m.bind;
|
||||
// return {
|
||||
// "repr": function () { return "dropwhile(...)"; },
|
||||
// "toString": m.forwardCall("repr"),
|
||||
// "next": function () {
|
||||
// while (true) {
|
||||
// var rval = seq.next();
|
||||
// if (!pred(rval)) {
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// this.next = bind("next", seq);
|
||||
// return rval;
|
||||
// }
|
||||
// };
|
||||
// },
|
||||
|
||||
// _tee: function (ident, sync, iterable) {
|
||||
// sync.pos[ident] = -1;
|
||||
// var m = MochiKit.Base;
|
||||
// var listMin = m.listMin;
|
||||
// return {
|
||||
// repr: function () { return "tee(" + ident + ", ...)"; },
|
||||
// toString: m.forwardCall("repr"),
|
||||
// next: function () {
|
||||
// var rval;
|
||||
// var i = sync.pos[ident];
|
||||
//
|
||||
// if (i == sync.max) {
|
||||
// rval = iterable.next();
|
||||
// sync.deque.push(rval);
|
||||
// sync.max += 1;
|
||||
// sync.pos[ident] += 1;
|
||||
// } else {
|
||||
// rval = sync.deque[i - sync.min];
|
||||
// sync.pos[ident] += 1;
|
||||
// if (i == sync.min && listMin(sync.pos) != sync.min) {
|
||||
// sync.min += 1;
|
||||
// sync.deque.shift();
|
||||
// }
|
||||
// }
|
||||
// return rval;
|
||||
// }
|
||||
// };
|
||||
// },
|
||||
|
||||
// tee: function (iterable, n/* = 2 */) {
|
||||
// var rval = [];
|
||||
// var sync = {
|
||||
// "pos": [],
|
||||
// "deque": [],
|
||||
// "max": -1,
|
||||
// "min": -1
|
||||
// };
|
||||
// if (arguments.length == 1 || typeof(n) == "undefined" || n === null) {
|
||||
// n = 2;
|
||||
// }
|
||||
// var self = MochiKit.Iter;
|
||||
// iterable = self.iter(iterable);
|
||||
// var _tee = self._tee;
|
||||
// for (var i = 0; i < n; i++) {
|
||||
// rval.push(_tee(i, sync, iterable));
|
||||
// }
|
||||
// return rval;
|
||||
// },
|
||||
|
||||
list: function (iterable) {
|
||||
// Fast-path for Array and Array-like
|
||||
var m = MochiKit.Base;
|
||||
if (typeof(iterable.slice) == 'function') {
|
||||
return iterable.slice();
|
||||
} else if (m.isArrayLike(iterable)) {
|
||||
return m.concat(iterable);
|
||||
}
|
||||
|
||||
var self = MochiKit.Iter;
|
||||
iterable = self.iter(iterable);
|
||||
var rval = [];
|
||||
try {
|
||||
while (true) {
|
||||
rval.push(iterable.next());
|
||||
}
|
||||
} catch (e) {
|
||||
if (e != self.StopIteration) {
|
||||
throw e;
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
// mozilla warnings aren't too bright
|
||||
return undefined;
|
||||
},
|
||||
|
||||
|
||||
// reduce: function (fn, iterable, /* optional */initial) {
|
||||
// var i = 0;
|
||||
// var x = initial;
|
||||
// var self = MochiKit.Iter;
|
||||
// iterable = self.iter(iterable);
|
||||
// if (arguments.length < 3) {
|
||||
// try {
|
||||
// x = iterable.next();
|
||||
// } catch (e) {
|
||||
// if (e == self.StopIteration) {
|
||||
// e = new TypeError("reduce() of empty sequence with no initial value");
|
||||
// }
|
||||
// throw e;
|
||||
// }
|
||||
// i++;
|
||||
// }
|
||||
// try {
|
||||
// while (true) {
|
||||
// x = fn(x, iterable.next());
|
||||
// }
|
||||
// } catch (e) {
|
||||
// if (e != self.StopIteration) {
|
||||
// throw e;
|
||||
// }
|
||||
// }
|
||||
// return x;
|
||||
// },
|
||||
|
||||
// range: function (/* [start,] stop[, step] */) {
|
||||
// var start = 0;
|
||||
// var stop = 0;
|
||||
// var step = 1;
|
||||
// if (arguments.length == 1) {
|
||||
// stop = arguments[0];
|
||||
// } else if (arguments.length == 2) {
|
||||
// start = arguments[0];
|
||||
// stop = arguments[1];
|
||||
// } else if (arguments.length == 3) {
|
||||
// start = arguments[0];
|
||||
// stop = arguments[1];
|
||||
// step = arguments[2];
|
||||
// } else {
|
||||
// throw new TypeError("range() takes 1, 2, or 3 arguments!");
|
||||
// }
|
||||
// if (step === 0) {
|
||||
// throw new TypeError("range() step must not be 0");
|
||||
// }
|
||||
// return {
|
||||
// next: function () {
|
||||
// if ((step > 0 && start >= stop) || (step < 0 && start <= stop)) {
|
||||
// throw MochiKit.Iter.StopIteration;
|
||||
// }
|
||||
// var rval = start;
|
||||
// start += step;
|
||||
// return rval;
|
||||
// },
|
||||
// repr: function () {
|
||||
// return "range(" + [start, stop, step].join(", ") + ")";
|
||||
// },
|
||||
// toString: MochiKit.Base.forwardCall("repr")
|
||||
// };
|
||||
// },
|
||||
//
|
||||
// sum: function (iterable, start/* = 0 */) {
|
||||
// if (typeof(start) == "undefined" || start === null) {
|
||||
// start = 0;
|
||||
// }
|
||||
// var x = start;
|
||||
// var self = MochiKit.Iter;
|
||||
// iterable = self.iter(iterable);
|
||||
// try {
|
||||
// while (true) {
|
||||
// x += iterable.next();
|
||||
// }
|
||||
// } catch (e) {
|
||||
// if (e != self.StopIteration) {
|
||||
// throw e;
|
||||
// }
|
||||
// }
|
||||
// return x;
|
||||
// },
|
||||
|
||||
// exhaust: function (iterable) {
|
||||
// var self = MochiKit.Iter;
|
||||
// iterable = self.iter(iterable);
|
||||
// try {
|
||||
// while (true) {
|
||||
// iterable.next();
|
||||
// }
|
||||
// } catch (e) {
|
||||
// if (e != self.StopIteration) {
|
||||
// throw e;
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
|
||||
forEach: function (iterable, func, /* optional */self) {
|
||||
var m = MochiKit.Base;
|
||||
if (arguments.length > 2) {
|
||||
func = m.bind(func, self);
|
||||
}
|
||||
// fast path for array
|
||||
if (m.isArrayLike(iterable)) {
|
||||
try {
|
||||
for (var i = 0; i < iterable.length; i++) {
|
||||
func(iterable[i]);
|
||||
}
|
||||
} catch (e) {
|
||||
if (e != MochiKit.Iter.StopIteration) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
self = MochiKit.Iter;
|
||||
self.exhaust(self.imap(func, iterable));
|
||||
}
|
||||
},
|
||||
|
||||
every: function (iterable, func) {
|
||||
var self = MochiKit.Iter;
|
||||
try {
|
||||
self.ifilterfalse(func, iterable).next();
|
||||
return false;
|
||||
} catch (e) {
|
||||
if (e != self.StopIteration) {
|
||||
throw e;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
// sorted: function (iterable, /* optional */cmp) {
|
||||
// var rval = MochiKit.Iter.list(iterable);
|
||||
// if (arguments.length == 1) {
|
||||
// cmp = MochiKit.Base.compare;
|
||||
// }
|
||||
// rval.sort(cmp);
|
||||
// return rval;
|
||||
// },
|
||||
|
||||
// reversed: function (iterable) {
|
||||
// var rval = MochiKit.Iter.list(iterable);
|
||||
// rval.reverse();
|
||||
// return rval;
|
||||
// },
|
||||
//
|
||||
// some: function (iterable, func) {
|
||||
// var self = MochiKit.Iter;
|
||||
// try {
|
||||
// self.ifilter(func, iterable).next();
|
||||
// return true;
|
||||
// } catch (e) {
|
||||
// if (e != self.StopIteration) {
|
||||
// throw e;
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
// },
|
||||
//
|
||||
// iextend: function (lst, iterable) {
|
||||
// if (MochiKit.Base.isArrayLike(iterable)) {
|
||||
// // fast-path for array-like
|
||||
// for (var i = 0; i < iterable.length; i++) {
|
||||
// lst.push(iterable[i]);
|
||||
// }
|
||||
// } else {
|
||||
// var self = MochiKit.Iter;
|
||||
// iterable = self.iter(iterable);
|
||||
// try {
|
||||
// while (true) {
|
||||
// lst.push(iterable.next());
|
||||
// }
|
||||
// } catch (e) {
|
||||
// if (e != self.StopIteration) {
|
||||
// throw e;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return lst;
|
||||
// },
|
||||
|
||||
// groupby: function(iterable, /* optional */ keyfunc) {
|
||||
// var m = MochiKit.Base;
|
||||
// var self = MochiKit.Iter;
|
||||
// if (arguments.length < 2) {
|
||||
// keyfunc = m.operator.identity;
|
||||
// }
|
||||
// iterable = self.iter(iterable);
|
||||
//
|
||||
// // shared
|
||||
// var pk = undefined;
|
||||
// var k = undefined;
|
||||
// var v;
|
||||
//
|
||||
// function fetch() {
|
||||
// v = iterable.next();
|
||||
// k = keyfunc(v);
|
||||
// };
|
||||
//
|
||||
// function eat() {
|
||||
// var ret = v;
|
||||
// v = undefined;
|
||||
// return ret;
|
||||
// };
|
||||
//
|
||||
// var first = true;
|
||||
// return {
|
||||
// repr: function () { return "groupby(...)"; },
|
||||
// next: function() {
|
||||
// // iterator-next
|
||||
//
|
||||
// // iterate until meet next group
|
||||
// while (k == pk) {
|
||||
// fetch();
|
||||
// if (first) {
|
||||
// first = false;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// pk = k;
|
||||
// return [k, {
|
||||
// next: function() {
|
||||
// // subiterator-next
|
||||
// if (v == undefined) { // Is there something to eat?
|
||||
// fetch();
|
||||
// }
|
||||
// if (k != pk) {
|
||||
// throw self.StopIteration;
|
||||
// }
|
||||
// return eat();
|
||||
// }
|
||||
// }];
|
||||
// }
|
||||
// };
|
||||
// },
|
||||
|
||||
// groupby_as_array: function (iterable, /* optional */ keyfunc) {
|
||||
// var m = MochiKit.Base;
|
||||
// var self = MochiKit.Iter;
|
||||
// if (arguments.length < 2) {
|
||||
// keyfunc = m.operator.identity;
|
||||
// }
|
||||
//
|
||||
// iterable = self.iter(iterable);
|
||||
// var result = [];
|
||||
// var first = true;
|
||||
// var prev_key;
|
||||
// while (true) {
|
||||
// try {
|
||||
// var value = iterable.next();
|
||||
// var key = keyfunc(value);
|
||||
// } catch (e) {
|
||||
// if (e == self.StopIteration) {
|
||||
// break;
|
||||
// }
|
||||
// throw e;
|
||||
// }
|
||||
// if (first || key != prev_key) {
|
||||
// var values = [];
|
||||
// result.push([key, values]);
|
||||
// }
|
||||
// values.push(value);
|
||||
// first = false;
|
||||
// prev_key = key;
|
||||
// }
|
||||
// return result;
|
||||
// },
|
||||
|
||||
arrayLikeIter: function (iterable) {
|
||||
var i = 0;
|
||||
return {
|
||||
repr: function () { return "arrayLikeIter(...)"; },
|
||||
toString: MochiKit.Base.forwardCall("repr"),
|
||||
next: function () {
|
||||
if (i >= iterable.length) {
|
||||
throw MochiKit.Iter.StopIteration;
|
||||
}
|
||||
return iterable[i++];
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
hasIterateNext: function (iterable) {
|
||||
return (iterable && typeof(iterable.iterateNext) == "function");
|
||||
},
|
||||
|
||||
iterateNextIter: function (iterable) {
|
||||
return {
|
||||
repr: function () { return "iterateNextIter(...)"; },
|
||||
toString: MochiKit.Base.forwardCall("repr"),
|
||||
next: function () {
|
||||
var rval = iterable.iterateNext();
|
||||
if (rval === null || rval === undefined) {
|
||||
throw MochiKit.Iter.StopIteration;
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
MochiKit.Iter.EXPORT_OK = [
|
||||
"iteratorRegistry",
|
||||
"arrayLikeIter",
|
||||
"hasIterateNext",
|
||||
"iterateNextIter",
|
||||
];
|
||||
|
||||
MochiKit.Iter.EXPORT = [
|
||||
"StopIteration",
|
||||
"registerIteratorFactory",
|
||||
"iter",
|
||||
"count",
|
||||
"cycle",
|
||||
"repeat",
|
||||
"next",
|
||||
"izip",
|
||||
"ifilter",
|
||||
"ifilterfalse",
|
||||
"islice",
|
||||
"imap",
|
||||
"applymap",
|
||||
"chain",
|
||||
"takewhile",
|
||||
"dropwhile",
|
||||
"tee",
|
||||
"list",
|
||||
"reduce",
|
||||
"range",
|
||||
"sum",
|
||||
"exhaust",
|
||||
"forEach",
|
||||
"every",
|
||||
"sorted",
|
||||
"reversed",
|
||||
"some",
|
||||
"iextend",
|
||||
"groupby",
|
||||
"groupby_as_array"
|
||||
];
|
||||
|
||||
MochiKit.Iter.__new__ = function () {
|
||||
var m = MochiKit.Base;
|
||||
// Re-use StopIteration if exists (e.g. SpiderMonkey)
|
||||
if (typeof(StopIteration) != "undefined") {
|
||||
this.StopIteration = StopIteration;
|
||||
} else {
|
||||
this.StopIteration = new m.NamedError("StopIteration");
|
||||
}
|
||||
this.iteratorRegistry = new m.AdapterRegistry();
|
||||
// Register the iterator factory for arrays
|
||||
this.registerIteratorFactory(
|
||||
"arrayLike",
|
||||
m.isArrayLike,
|
||||
this.arrayLikeIter
|
||||
);
|
||||
|
||||
this.registerIteratorFactory(
|
||||
"iterateNext",
|
||||
this.hasIterateNext,
|
||||
this.iterateNextIter
|
||||
);
|
||||
|
||||
this.EXPORT_TAGS = {
|
||||
":common": this.EXPORT,
|
||||
":all": m.concat(this.EXPORT, this.EXPORT_OK)
|
||||
};
|
||||
|
||||
m.nameFunctions(this);
|
||||
|
||||
};
|
||||
|
||||
MochiKit.Iter.__new__();
|
||||
|
||||
//
|
||||
// XXX: Internet Explorer blows
|
||||
//
|
||||
if (MochiKit.__export__) {
|
||||
reduce = MochiKit.Iter.reduce;
|
||||
}
|
||||
|
||||
MochiKit.Base._exportSymbols(this, MochiKit.Iter);
|
||||
9
crystalreportviewers13/js/MochiKit/License.js
Normal file
@@ -0,0 +1,9 @@
|
||||
/***
|
||||
|
||||
MochiKit.Base 1.4
|
||||
|
||||
See <http://mochikit.com/> for documentation, downloads, license, etc.
|
||||
|
||||
(c) 2005 Bob Ippolito. All rights Reserved.
|
||||
|
||||
***/
|
||||
299
crystalreportviewers13/js/MochiKit/Logging.js
Normal file
@@ -0,0 +1,299 @@
|
||||
/***
|
||||
|
||||
MochiKit.Logging 1.4
|
||||
|
||||
See <http://mochikit.com/> for documentation, downloads, license, etc.
|
||||
|
||||
(c) 2005 Bob Ippolito. All rights Reserved.
|
||||
|
||||
***/
|
||||
if (typeof(dojo) != 'undefined') {
|
||||
dojo.provide('MochiKit.Logging');
|
||||
dojo.require('MochiKit.Base');
|
||||
}
|
||||
|
||||
if (typeof(JSAN) != 'undefined') {
|
||||
JSAN.use("MochiKit.Base", []);
|
||||
}
|
||||
|
||||
try {
|
||||
if (typeof(MochiKit.Base) == 'undefined') {
|
||||
throw "";
|
||||
}
|
||||
} catch (e) {
|
||||
throw "MochiKit.Logging depends on MochiKit.Base!";
|
||||
}
|
||||
|
||||
if (typeof(MochiKit.Logging) == 'undefined') {
|
||||
MochiKit.Logging = {};
|
||||
}
|
||||
|
||||
MochiKit.Logging.NAME = "MochiKit.Logging";
|
||||
MochiKit.Logging.VERSION = "1.4";
|
||||
MochiKit.Logging.__repr__ = function () {
|
||||
return "[" + this.NAME + " " + this.VERSION + "]";
|
||||
};
|
||||
|
||||
MochiKit.Logging.toString = function () {
|
||||
return this.__repr__();
|
||||
};
|
||||
|
||||
|
||||
MochiKit.Logging.EXPORT = [
|
||||
"LogLevel",
|
||||
"LogMessage",
|
||||
"Logger",
|
||||
"alertListener",
|
||||
"logger",
|
||||
"log",
|
||||
"logError",
|
||||
"logDebug",
|
||||
"logFatal",
|
||||
"logWarning"
|
||||
];
|
||||
|
||||
|
||||
MochiKit.Logging.EXPORT_OK = [
|
||||
"logLevelAtLeast",
|
||||
"isLogMessage",
|
||||
"compareLogMessage"
|
||||
];
|
||||
|
||||
|
||||
MochiKit.Logging.LogMessage = function (num, level, info) {
|
||||
this.num = num;
|
||||
this.level = level;
|
||||
this.info = info;
|
||||
this.timestamp = new Date();
|
||||
};
|
||||
|
||||
MochiKit.Logging.LogMessage.prototype = {
|
||||
repr: function () {
|
||||
var m = MochiKit.Base;
|
||||
return 'LogMessage(' +
|
||||
m.map(
|
||||
m.repr,
|
||||
[this.num, this.level, this.info]
|
||||
).join(', ') + ')';
|
||||
},
|
||||
toString: MochiKit.Base.forwardCall("repr")
|
||||
};
|
||||
|
||||
MochiKit.Base.update(MochiKit.Logging, {
|
||||
logLevelAtLeast: function (minLevel) {
|
||||
var self = MochiKit.Logging;
|
||||
if (typeof(minLevel) == 'string') {
|
||||
minLevel = self.LogLevel[minLevel];
|
||||
}
|
||||
return function (msg) {
|
||||
var msgLevel = msg.level;
|
||||
if (typeof(msgLevel) == 'string') {
|
||||
msgLevel = self.LogLevel[msgLevel];
|
||||
}
|
||||
return msgLevel >= minLevel;
|
||||
};
|
||||
},
|
||||
|
||||
isLogMessage: function (/* ... */) {
|
||||
var LogMessage = MochiKit.Logging.LogMessage;
|
||||
for (var i = 0; i < arguments.length; i++) {
|
||||
if (!(arguments[i] instanceof LogMessage)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
compareLogMessage: function (a, b) {
|
||||
return MochiKit.Base.compare([a.level, a.info], [b.level, b.info]);
|
||||
},
|
||||
|
||||
alertListener: function (msg) {
|
||||
alert(
|
||||
"num: " + msg.num +
|
||||
"\nlevel: " + msg.level +
|
||||
"\ninfo: " + msg.info.join(" ")
|
||||
);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
MochiKit.Logging.Logger = function (/* optional */maxSize) {
|
||||
this.counter = 0;
|
||||
if (typeof(maxSize) == 'undefined' || maxSize === null) {
|
||||
maxSize = -1;
|
||||
}
|
||||
this.maxSize = maxSize;
|
||||
this._messages = [];
|
||||
this.listeners = {};
|
||||
this.useNativeConsole = false;
|
||||
};
|
||||
|
||||
MochiKit.Logging.Logger.prototype = {
|
||||
clear: function () {
|
||||
this._messages.splice(0, this._messages.length);
|
||||
},
|
||||
|
||||
logToConsole: function (msg) {
|
||||
if (typeof(window) != "undefined" && window.console
|
||||
&& window.console.log) {
|
||||
// Safari and FireBug 0.4
|
||||
// Percent replacement is a workaround for cute Safari crashing bug
|
||||
window.console.log(msg.replace(/%/g, '\uFF05'));
|
||||
} else if (typeof(opera) != "undefined" && opera.postError) {
|
||||
// Opera
|
||||
opera.postError(msg);
|
||||
} else if (typeof(printfire) == "function") {
|
||||
// FireBug 0.3 and earlier
|
||||
printfire(msg);
|
||||
} else if (typeof(Debug) != "undefined" && Debug.writeln) {
|
||||
// IE Web Development Helper (?)
|
||||
// http://www.nikhilk.net/Entry.aspx?id=93
|
||||
Debug.writeln(msg);
|
||||
} else if (typeof(debug) != "undefined" && debug.trace) {
|
||||
// Atlas framework (?)
|
||||
// http://www.nikhilk.net/Entry.aspx?id=93
|
||||
debug.trace(msg);
|
||||
}
|
||||
},
|
||||
|
||||
dispatchListeners: function (msg) {
|
||||
for (var k in this.listeners) {
|
||||
var pair = this.listeners[k];
|
||||
if (pair.ident != k || (pair[0] && !pair[0](msg))) {
|
||||
continue;
|
||||
}
|
||||
pair[1](msg);
|
||||
}
|
||||
},
|
||||
|
||||
addListener: function (ident, filter, listener) {
|
||||
if (typeof(filter) == 'string') {
|
||||
filter = MochiKit.Logging.logLevelAtLeast(filter);
|
||||
}
|
||||
var entry = [filter, listener];
|
||||
entry.ident = ident;
|
||||
this.listeners[ident] = entry;
|
||||
},
|
||||
|
||||
removeListener: function (ident) {
|
||||
delete this.listeners[ident];
|
||||
},
|
||||
|
||||
baseLog: function (level, message/*, ...*/) {
|
||||
var msg = new MochiKit.Logging.LogMessage(
|
||||
this.counter,
|
||||
level,
|
||||
MochiKit.Base.extend(null, arguments, 1)
|
||||
);
|
||||
this._messages.push(msg);
|
||||
this.dispatchListeners(msg);
|
||||
if (this.useNativeConsole) {
|
||||
this.logToConsole(msg.level + ": " + msg.info.join(" "));
|
||||
}
|
||||
this.counter += 1;
|
||||
while (this.maxSize >= 0 && this._messages.length > this.maxSize) {
|
||||
this._messages.shift();
|
||||
}
|
||||
},
|
||||
|
||||
getMessages: function (howMany) {
|
||||
var firstMsg = 0;
|
||||
if (!(typeof(howMany) == 'undefined' || howMany === null)) {
|
||||
firstMsg = Math.max(0, this._messages.length - howMany);
|
||||
}
|
||||
return this._messages.slice(firstMsg);
|
||||
},
|
||||
|
||||
getMessageText: function (howMany) {
|
||||
if (typeof(howMany) == 'undefined' || howMany === null) {
|
||||
howMany = 30;
|
||||
}
|
||||
var messages = this.getMessages(howMany);
|
||||
if (messages.length) {
|
||||
var lst = map(function (m) {
|
||||
return '\n [' + m.num + '] ' + m.level + ': ' + m.info.join(' ');
|
||||
}, messages);
|
||||
lst.unshift('LAST ' + messages.length + ' MESSAGES:');
|
||||
return lst.join('');
|
||||
}
|
||||
return '';
|
||||
},
|
||||
|
||||
debuggingBookmarklet: function (inline) {
|
||||
if (typeof(MochiKit.LoggingPane) == "undefined") {
|
||||
alert(this.getMessageText());
|
||||
} else {
|
||||
MochiKit.LoggingPane.createLoggingPane(inline || false);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
MochiKit.Logging.__new__ = function () {
|
||||
this.LogLevel = {
|
||||
ERROR: 40,
|
||||
FATAL: 50,
|
||||
WARNING: 30,
|
||||
INFO: 20,
|
||||
DEBUG: 10
|
||||
};
|
||||
|
||||
var m = MochiKit.Base;
|
||||
m.registerComparator("LogMessage",
|
||||
this.isLogMessage,
|
||||
this.compareLogMessage
|
||||
);
|
||||
|
||||
var partial = m.partial;
|
||||
|
||||
var Logger = this.Logger;
|
||||
var baseLog = Logger.prototype.baseLog;
|
||||
m.update(this.Logger.prototype, {
|
||||
debug: partial(baseLog, 'DEBUG'),
|
||||
log: partial(baseLog, 'INFO'),
|
||||
error: partial(baseLog, 'ERROR'),
|
||||
fatal: partial(baseLog, 'FATAL'),
|
||||
warning: partial(baseLog, 'WARNING')
|
||||
});
|
||||
|
||||
// indirectly find logger so it can be replaced
|
||||
var self = this;
|
||||
var connectLog = function (name) {
|
||||
return function () {
|
||||
self.logger[name].apply(self.logger, arguments);
|
||||
};
|
||||
};
|
||||
|
||||
this.log = connectLog('log');
|
||||
this.logError = connectLog('error');
|
||||
this.logDebug = connectLog('debug');
|
||||
this.logFatal = connectLog('fatal');
|
||||
this.logWarning = connectLog('warning');
|
||||
this.logger = new Logger();
|
||||
this.logger.useNativeConsole = true;
|
||||
|
||||
this.EXPORT_TAGS = {
|
||||
":common": this.EXPORT,
|
||||
":all": m.concat(this.EXPORT, this.EXPORT_OK)
|
||||
};
|
||||
|
||||
m.nameFunctions(this);
|
||||
|
||||
};
|
||||
|
||||
if (typeof(printfire) == "undefined" &&
|
||||
typeof(document) != "undefined" && document.createEvent &&
|
||||
typeof(dispatchEvent) != "undefined") {
|
||||
// FireBug really should be less lame about this global function
|
||||
printfire = function () {
|
||||
printfire.args = arguments;
|
||||
var ev = document.createEvent("Events");
|
||||
ev.initEvent("printfire", false, true);
|
||||
dispatchEvent(ev);
|
||||
};
|
||||
}
|
||||
|
||||
MochiKit.Logging.__new__();
|
||||
|
||||
MochiKit.Base._exportSymbols(this, MochiKit.Logging);
|
||||
356
crystalreportviewers13/js/MochiKit/LoggingPane.js
Normal file
@@ -0,0 +1,356 @@
|
||||
/***
|
||||
|
||||
MochiKit.LoggingPane 1.4
|
||||
|
||||
See <http://mochikit.com/> for documentation, downloads, license, etc.
|
||||
|
||||
(c) 2005 Bob Ippolito. All rights Reserved.
|
||||
|
||||
***/
|
||||
if (typeof(dojo) != 'undefined') {
|
||||
dojo.provide('MochiKit.LoggingPane');
|
||||
dojo.require('MochiKit.Logging');
|
||||
dojo.require('MochiKit.Base');
|
||||
}
|
||||
|
||||
if (typeof(JSAN) != 'undefined') {
|
||||
JSAN.use("MochiKit.Logging", []);
|
||||
JSAN.use("MochiKit.Base", []);
|
||||
}
|
||||
|
||||
try {
|
||||
if (typeof(MochiKit.Base) == 'undefined' || typeof(MochiKit.Logging) == 'undefined') {
|
||||
throw "";
|
||||
}
|
||||
} catch (e) {
|
||||
throw "MochiKit.LoggingPane depends on MochiKit.Base and MochiKit.Logging!";
|
||||
}
|
||||
|
||||
if (typeof(MochiKit.LoggingPane) == 'undefined') {
|
||||
MochiKit.LoggingPane = {};
|
||||
}
|
||||
|
||||
MochiKit.LoggingPane.NAME = "MochiKit.LoggingPane";
|
||||
MochiKit.LoggingPane.VERSION = "1.4";
|
||||
MochiKit.LoggingPane.__repr__ = function () {
|
||||
return "[" + this.NAME + " " + this.VERSION + "]";
|
||||
};
|
||||
|
||||
MochiKit.LoggingPane.toString = function () {
|
||||
return this.__repr__();
|
||||
};
|
||||
|
||||
MochiKit.LoggingPane.createLoggingPane = function (inline/* = false */) {
|
||||
var m = MochiKit.LoggingPane;
|
||||
inline = !(!inline);
|
||||
if (m._loggingPane && m._loggingPane.inline != inline) {
|
||||
m._loggingPane.closePane();
|
||||
m._loggingPane = null;
|
||||
}
|
||||
if (!m._loggingPane || m._loggingPane.closed) {
|
||||
m._loggingPane = new m.LoggingPane(inline, MochiKit.Logging.logger);
|
||||
}
|
||||
return m._loggingPane;
|
||||
};
|
||||
|
||||
MochiKit.LoggingPane.LoggingPane = function (inline/* = false */, logger/* = MochiKit.Logging.logger */) {
|
||||
/* Use a div if inline, pop up a window if not */
|
||||
/* Create the elements */
|
||||
if (typeof(logger) == "undefined" || logger === null) {
|
||||
logger = MochiKit.Logging.logger;
|
||||
}
|
||||
this.logger = logger;
|
||||
var update = MochiKit.Base.update;
|
||||
var updatetree = MochiKit.Base.updatetree;
|
||||
var bind = MochiKit.Base.bind;
|
||||
var clone = MochiKit.Base.clone;
|
||||
var win = window;
|
||||
var uid = "_MochiKit_LoggingPane";
|
||||
if (typeof(MochiKit.DOM) != "undefined") {
|
||||
win = MochiKit.DOM.currentWindow();
|
||||
}
|
||||
if (!inline) {
|
||||
// name the popup with the base URL for uniqueness
|
||||
var url = win.location.href.split("?")[0].replace(/[:\/.><&-]/g, "_");
|
||||
var name = uid + "_" + url;
|
||||
var nwin = win.open("", name, "dependent,resizable,height=200");
|
||||
if (!nwin) {
|
||||
alert("Not able to open debugging window due to pop-up blocking.");
|
||||
return undefined;
|
||||
}
|
||||
nwin.document.write(
|
||||
'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" '
|
||||
+ '"http://www.w3.org/TR/html4/loose.dtd">'
|
||||
+ '<html><head><title>[MochiKit.LoggingPane]</title></head>'
|
||||
+ '<body></body></html>'
|
||||
);
|
||||
nwin.document.close();
|
||||
nwin.document.title += ' ' + win.document.title;
|
||||
win = nwin;
|
||||
}
|
||||
var doc = win.document;
|
||||
this.doc = doc;
|
||||
|
||||
// Connect to the debug pane if it already exists (i.e. in a window orphaned by the page being refreshed)
|
||||
var debugPane = doc.getElementById(uid);
|
||||
var existing_pane = !!debugPane;
|
||||
if (debugPane && typeof(debugPane.loggingPane) != "undefined") {
|
||||
debugPane.loggingPane.logger = this.logger;
|
||||
debugPane.loggingPane.buildAndApplyFilter();
|
||||
return debugPane.loggingPane;
|
||||
}
|
||||
|
||||
if (existing_pane) {
|
||||
// clear any existing contents
|
||||
var child;
|
||||
while ((child = debugPane.firstChild)) {
|
||||
debugPane.removeChild(child);
|
||||
}
|
||||
} else {
|
||||
debugPane = doc.createElement("div");
|
||||
debugPane.id = uid;
|
||||
}
|
||||
debugPane.loggingPane = this;
|
||||
var levelFilterField = doc.createElement("input");
|
||||
var infoFilterField = doc.createElement("input");
|
||||
var filterButton = doc.createElement("button");
|
||||
var loadButton = doc.createElement("button");
|
||||
var clearButton = doc.createElement("button");
|
||||
var closeButton = doc.createElement("button");
|
||||
var logPaneArea = doc.createElement("div");
|
||||
var logPane = doc.createElement("div");
|
||||
|
||||
/* Set up the functions */
|
||||
var listenerId = uid + "_Listener";
|
||||
this.colorTable = clone(this.colorTable);
|
||||
var messages = [];
|
||||
var messageFilter = null;
|
||||
|
||||
var messageLevel = function (msg) {
|
||||
var level = msg.level;
|
||||
if (typeof(level) == "number") {
|
||||
level = MochiKit.Logging.LogLevel[level];
|
||||
}
|
||||
return level;
|
||||
};
|
||||
|
||||
var messageText = function (msg) {
|
||||
return msg.info.join(" ");
|
||||
};
|
||||
|
||||
var addMessageText = bind(function (msg) {
|
||||
var level = messageLevel(msg);
|
||||
var text = messageText(msg);
|
||||
var c = this.colorTable[level];
|
||||
var p = doc.createElement("span");
|
||||
p.className = "MochiKit-LogMessage MochiKit-LogLevel-" + level;
|
||||
p.style.cssText = "margin: 0px; white-space: -moz-pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; white-space: pre-line; word-wrap: break-word; wrap-option: emergency; color: " + c;
|
||||
p.appendChild(doc.createTextNode(level + ": " + text));
|
||||
logPane.appendChild(p);
|
||||
logPane.appendChild(doc.createElement("br"));
|
||||
if (logPaneArea.offsetHeight > logPaneArea.scrollHeight) {
|
||||
logPaneArea.scrollTop = 0;
|
||||
} else {
|
||||
logPaneArea.scrollTop = logPaneArea.scrollHeight;
|
||||
}
|
||||
}, this);
|
||||
|
||||
var addMessage = function (msg) {
|
||||
messages[messages.length] = msg;
|
||||
addMessageText(msg);
|
||||
};
|
||||
|
||||
var buildMessageFilter = function () {
|
||||
var levelre, infore;
|
||||
try {
|
||||
/* Catch any exceptions that might arise due to invalid regexes */
|
||||
levelre = new RegExp(levelFilterField.value);
|
||||
infore = new RegExp(infoFilterField.value);
|
||||
} catch(e) {
|
||||
/* If there was an error with the regexes, do no filtering */
|
||||
logDebug("Error in filter regex: " + e.message);
|
||||
return null;
|
||||
}
|
||||
|
||||
return function (msg) {
|
||||
return (
|
||||
levelre.test(messageLevel(msg)) &&
|
||||
infore.test(messageText(msg))
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
var clearMessagePane = function () {
|
||||
while (logPane.firstChild) {
|
||||
logPane.removeChild(logPane.firstChild);
|
||||
}
|
||||
};
|
||||
|
||||
var clearMessages = function () {
|
||||
messages = [];
|
||||
clearMessagePane();
|
||||
};
|
||||
|
||||
var closePane = bind(function () {
|
||||
if (this.closed) {
|
||||
return;
|
||||
}
|
||||
this.closed = true;
|
||||
if (MochiKit.LoggingPane._loggingPane == this) {
|
||||
MochiKit.LoggingPane._loggingPane = null;
|
||||
}
|
||||
this.logger.removeListener(listenerId);
|
||||
|
||||
debugPane.loggingPane = null;
|
||||
|
||||
if (inline) {
|
||||
debugPane.parentNode.removeChild(debugPane);
|
||||
} else {
|
||||
this.win.close();
|
||||
}
|
||||
}, this);
|
||||
|
||||
var filterMessages = function () {
|
||||
clearMessagePane();
|
||||
|
||||
for (var i = 0; i < messages.length; i++) {
|
||||
var msg = messages[i];
|
||||
if (messageFilter === null || messageFilter(msg)) {
|
||||
addMessageText(msg);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.buildAndApplyFilter = function () {
|
||||
messageFilter = buildMessageFilter();
|
||||
|
||||
filterMessages();
|
||||
|
||||
this.logger.removeListener(listenerId);
|
||||
this.logger.addListener(listenerId, messageFilter, addMessage);
|
||||
};
|
||||
|
||||
|
||||
var loadMessages = bind(function () {
|
||||
messages = this.logger.getMessages();
|
||||
filterMessages();
|
||||
}, this);
|
||||
|
||||
var filterOnEnter = bind(function (event) {
|
||||
event = event || window.event;
|
||||
key = event.which || event.keyCode;
|
||||
if (key == 13) {
|
||||
this.buildAndApplyFilter();
|
||||
}
|
||||
}, this);
|
||||
|
||||
/* Create the debug pane */
|
||||
var style = "display: block; z-index: 1000; left: 0px; bottom: 0px; position: fixed; width: 100%; background-color: white; font: " + this.logFont;
|
||||
if (inline) {
|
||||
style += "; height: 10em; border-top: 2px solid black";
|
||||
} else {
|
||||
style += "; height: 100%;";
|
||||
}
|
||||
debugPane.style.cssText = style;
|
||||
|
||||
if (!existing_pane) {
|
||||
doc.body.appendChild(debugPane);
|
||||
}
|
||||
|
||||
/* Create the filter fields */
|
||||
style = {"cssText": "width: 33%; display: inline; font: " + this.logFont};
|
||||
|
||||
updatetree(levelFilterField, {
|
||||
"value": "FATAL|ERROR|WARNING|INFO|DEBUG",
|
||||
"onkeypress": filterOnEnter,
|
||||
"style": style
|
||||
});
|
||||
debugPane.appendChild(levelFilterField);
|
||||
|
||||
updatetree(infoFilterField, {
|
||||
"value": ".*",
|
||||
"onkeypress": filterOnEnter,
|
||||
"style": style
|
||||
});
|
||||
debugPane.appendChild(infoFilterField);
|
||||
|
||||
/* Create the buttons */
|
||||
style = "width: 8%; display:inline; font: " + this.logFont;
|
||||
|
||||
filterButton.appendChild(doc.createTextNode("Filter"));
|
||||
filterButton.onclick = bind("buildAndApplyFilter", this);
|
||||
filterButton.style.cssText = style;
|
||||
debugPane.appendChild(filterButton);
|
||||
|
||||
loadButton.appendChild(doc.createTextNode("Load"));
|
||||
loadButton.onclick = loadMessages;
|
||||
loadButton.style.cssText = style;
|
||||
debugPane.appendChild(loadButton);
|
||||
|
||||
clearButton.appendChild(doc.createTextNode("Clear"));
|
||||
clearButton.onclick = clearMessages;
|
||||
clearButton.style.cssText = style;
|
||||
debugPane.appendChild(clearButton);
|
||||
|
||||
closeButton.appendChild(doc.createTextNode("Close"));
|
||||
closeButton.onclick = closePane;
|
||||
closeButton.style.cssText = style;
|
||||
debugPane.appendChild(closeButton);
|
||||
|
||||
/* Create the logging pane */
|
||||
logPaneArea.style.cssText = "overflow: auto; width: 100%";
|
||||
logPane.style.cssText = "width: 100%; height: " + (inline ? "8em" : "100%");
|
||||
|
||||
logPaneArea.appendChild(logPane);
|
||||
debugPane.appendChild(logPaneArea);
|
||||
|
||||
this.buildAndApplyFilter();
|
||||
loadMessages();
|
||||
|
||||
if (inline) {
|
||||
this.win = undefined;
|
||||
} else {
|
||||
this.win = win;
|
||||
}
|
||||
this.inline = inline;
|
||||
this.closePane = closePane;
|
||||
this.closed = false;
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
MochiKit.LoggingPane.LoggingPane.prototype = {
|
||||
"logFont": "8pt Verdana,sans-serif",
|
||||
"colorTable": {
|
||||
"ERROR": "red",
|
||||
"FATAL": "darkred",
|
||||
"WARNING": "blue",
|
||||
"INFO": "black",
|
||||
"DEBUG": "green"
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
MochiKit.LoggingPane.EXPORT_OK = [
|
||||
"LoggingPane"
|
||||
];
|
||||
|
||||
MochiKit.LoggingPane.EXPORT = [
|
||||
"createLoggingPane"
|
||||
];
|
||||
|
||||
MochiKit.LoggingPane.__new__ = function () {
|
||||
this.EXPORT_TAGS = {
|
||||
":common": this.EXPORT,
|
||||
":all": MochiKit.Base.concat(this.EXPORT, this.EXPORT_OK)
|
||||
};
|
||||
|
||||
MochiKit.Base.nameFunctions(this);
|
||||
|
||||
MochiKit.LoggingPane._loggingPane = null;
|
||||
|
||||
};
|
||||
|
||||
MochiKit.LoggingPane.__new__();
|
||||
|
||||
MochiKit.Base._exportSymbols(this, MochiKit.LoggingPane);
|
||||
149
crystalreportviewers13/js/MochiKit/MochiKit.js
vendored
Normal file
@@ -0,0 +1,149 @@
|
||||
/***
|
||||
|
||||
MochiKit.MochiKit 1.4
|
||||
|
||||
See <http://mochikit.com/> for documentation, downloads, license, etc.
|
||||
|
||||
(c) 2005 Bob Ippolito. All rights Reserved.
|
||||
|
||||
***/
|
||||
|
||||
if (typeof(MochiKit) == 'undefined') {
|
||||
MochiKit = {};
|
||||
}
|
||||
|
||||
if (typeof(MochiKit.MochiKit) == 'undefined') {
|
||||
MochiKit.MochiKit = {};
|
||||
}
|
||||
|
||||
MochiKit.MochiKit.NAME = "MochiKit.MochiKit";
|
||||
MochiKit.MochiKit.VERSION = "1.4";
|
||||
MochiKit.MochiKit.__repr__ = function () {
|
||||
return "[" + this.NAME + " " + this.VERSION + "]";
|
||||
};
|
||||
|
||||
MochiKit.MochiKit.toString = function () {
|
||||
return this.__repr__();
|
||||
};
|
||||
|
||||
MochiKit.MochiKit.SUBMODULES = [
|
||||
"Base",
|
||||
"Iter",
|
||||
"Logging",
|
||||
"DateTime",
|
||||
"Format",
|
||||
"Async",
|
||||
"DOM",
|
||||
"Style",
|
||||
"LoggingPane",
|
||||
"Color",
|
||||
"Signal",
|
||||
"Visual"
|
||||
];
|
||||
|
||||
if (typeof(JSAN) != 'undefined' || typeof(dojo) != 'undefined') {
|
||||
if (typeof(dojo) != 'undefined') {
|
||||
dojo.provide('MochiKit.MochiKit');
|
||||
dojo.require("MochiKit.*");
|
||||
}
|
||||
if (typeof(JSAN) != 'undefined') {
|
||||
(function (lst) {
|
||||
for (var i = 0; i < lst.length; i++) {
|
||||
JSAN.use("MochiKit." + lst[i], []);
|
||||
}
|
||||
})(MochiKit.MochiKit.SUBMODULES);
|
||||
}
|
||||
(function () {
|
||||
var extend = MochiKit.Base.extend;
|
||||
var self = MochiKit.MochiKit;
|
||||
var modules = self.SUBMODULES;
|
||||
var EXPORT = [];
|
||||
var EXPORT_OK = [];
|
||||
var EXPORT_TAGS = {};
|
||||
var i, k, m, all;
|
||||
for (i = 0; i < modules.length; i++) {
|
||||
m = MochiKit[modules[i]];
|
||||
extend(EXPORT, m.EXPORT);
|
||||
extend(EXPORT_OK, m.EXPORT_OK);
|
||||
for (k in m.EXPORT_TAGS) {
|
||||
EXPORT_TAGS[k] = extend(EXPORT_TAGS[k], m.EXPORT_TAGS[k]);
|
||||
}
|
||||
all = m.EXPORT_TAGS[":all"];
|
||||
if (!all) {
|
||||
all = extend(null, m.EXPORT, m.EXPORT_OK);
|
||||
}
|
||||
var j;
|
||||
for (j = 0; j < all.length; j++) {
|
||||
k = all[j];
|
||||
self[k] = m[k];
|
||||
}
|
||||
}
|
||||
self.EXPORT = EXPORT;
|
||||
self.EXPORT_OK = EXPORT_OK;
|
||||
self.EXPORT_TAGS = EXPORT_TAGS;
|
||||
}());
|
||||
|
||||
} else {
|
||||
if (typeof(MochiKit.__compat__) == 'undefined') {
|
||||
MochiKit.__compat__ = true;
|
||||
}
|
||||
(function () {
|
||||
if (typeof(document) == "undefined") {
|
||||
return;
|
||||
}
|
||||
var scripts = document.getElementsByTagName("script");
|
||||
var kXULNSURI = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
||||
var base = null;
|
||||
var baseElem = null;
|
||||
var allScripts = {};
|
||||
var i;
|
||||
for (i = 0; i < scripts.length; i++) {
|
||||
var src = scripts[i].getAttribute("src");
|
||||
if (!src) {
|
||||
continue;
|
||||
}
|
||||
allScripts[src] = true;
|
||||
if (src.match(/MochiKit.js$/)) {
|
||||
base = src.substring(0, src.lastIndexOf('MochiKit.js'));
|
||||
baseElem = scripts[i];
|
||||
}
|
||||
}
|
||||
if (base === null) {
|
||||
return;
|
||||
}
|
||||
var modules = MochiKit.MochiKit.SUBMODULES;
|
||||
for (var i = 0; i < modules.length; i++) {
|
||||
if (MochiKit[modules[i]]) {
|
||||
continue;
|
||||
}
|
||||
var uri = base + modules[i] + '.js';
|
||||
if (uri in allScripts) {
|
||||
continue;
|
||||
}
|
||||
if (document.documentElement &&
|
||||
document.documentElement.namespaceURI == kXULNSURI) {
|
||||
// XUL
|
||||
var s = document.createElementNS(kXULNSURI, 'script');
|
||||
s.setAttribute("id", "MochiKit_" + base + modules[i]);
|
||||
s.setAttribute("src", uri);
|
||||
s.setAttribute("type", "application/x-javascript");
|
||||
baseElem.parentNode.appendChild(s);
|
||||
} else {
|
||||
// HTML
|
||||
/*
|
||||
DOM can not be used here because Safari does
|
||||
deferred loading of scripts unless they are
|
||||
in the document or inserted with document.write
|
||||
|
||||
This is not XHTML compliant. If you want XHTML
|
||||
compliance then you must use the packed version of MochiKit
|
||||
or include each script individually (basically unroll
|
||||
these document.write calls into your XHTML source)
|
||||
|
||||
*/
|
||||
document.write('<script src="' + uri +
|
||||
'" type="text/javascript"></script>');
|
||||
}
|
||||
};
|
||||
})();
|
||||
}
|
||||
88
crystalreportviewers13/js/MochiKit/MockDOM.js
Normal file
@@ -0,0 +1,88 @@
|
||||
/***
|
||||
|
||||
MochiKit.MockDOM 1.4
|
||||
|
||||
See <http://mochikit.com/> for documentation, downloads, license, etc.
|
||||
|
||||
(c) 2005 Bob Ippolito. All rights Reserved.
|
||||
|
||||
***/
|
||||
if (typeof(MochiKit) == "undefined") {
|
||||
MochiKit = {};
|
||||
}
|
||||
|
||||
if (typeof(MochiKit.MockDOM) == "undefined") {
|
||||
MochiKit.MockDOM = {};
|
||||
}
|
||||
|
||||
MochiKit.MockDOM.NAME = "MochiKit.MockDOM";
|
||||
MochiKit.MockDOM.VERSION = "1.4";
|
||||
|
||||
MochiKit.MockDOM.__repr__ = function () {
|
||||
return "[" + this.NAME + " " + this.VERSION + "]";
|
||||
};
|
||||
|
||||
MochiKit.MockDOM.toString = function () {
|
||||
return this.__repr__();
|
||||
};
|
||||
|
||||
MochiKit.MockDOM.createDocument = function () {
|
||||
var doc = new MochiKit.MockDOM.MockElement("DOCUMENT");
|
||||
doc.body = doc.createElement("BODY");
|
||||
doc.appendChild(doc.body);
|
||||
return doc;
|
||||
};
|
||||
|
||||
MochiKit.MockDOM.MockElement = function (name, data) {
|
||||
this.nodeName = name.toUpperCase();
|
||||
if (typeof(data) == "string") {
|
||||
this.nodeValue = data;
|
||||
this.nodeType = 3;
|
||||
} else {
|
||||
this.nodeType = 1;
|
||||
this.childNodes = [];
|
||||
}
|
||||
if (name.substring(0, 1) == "<") {
|
||||
var nameattr = name.substring(
|
||||
name.indexOf('"') + 1, name.lastIndexOf('"'));
|
||||
name = name.substring(1, name.indexOf(" "));
|
||||
this.nodeName = name.toUpperCase();
|
||||
this.setAttribute("name", nameattr);
|
||||
}
|
||||
};
|
||||
|
||||
MochiKit.MockDOM.MockElement.prototype = {
|
||||
createElement: function (nodeName) {
|
||||
return new MochiKit.MockDOM.MockElement(nodeName);
|
||||
},
|
||||
createTextNode: function (text) {
|
||||
return new MochiKit.MockDOM.MockElement("text", text);
|
||||
},
|
||||
setAttribute: function (name, value) {
|
||||
this[name] = value;
|
||||
},
|
||||
getAttribute: function (name) {
|
||||
return this[name];
|
||||
},
|
||||
appendChild: function (child) {
|
||||
this.childNodes.push(child);
|
||||
},
|
||||
toString: function () {
|
||||
return "MockElement(" + this.nodeName + ")";
|
||||
}
|
||||
};
|
||||
|
||||
MochiKit.MockDOM.EXPORT_OK = [
|
||||
"mockElement",
|
||||
"createDocument"
|
||||
];
|
||||
|
||||
MochiKit.MockDOM.EXPORT = [
|
||||
"document"
|
||||
];
|
||||
|
||||
MochiKit.MockDOM.__new__ = function () {
|
||||
this.document = this.createDocument();
|
||||
};
|
||||
|
||||
MochiKit.MockDOM.__new__();
|
||||
365
crystalreportviewers13/js/MochiKit/New.js
Normal file
@@ -0,0 +1,365 @@
|
||||
|
||||
MochiKit.Base.update(MochiKit.Base, {
|
||||
isIE: function () {
|
||||
return /MSIE/.test(navigator.userAgent);
|
||||
},
|
||||
|
||||
isGecko: function () {
|
||||
return /Gecko/.test(navigator.userAgent);
|
||||
},
|
||||
|
||||
isKHTML: function () {
|
||||
return /Konqueror|Safari|KHTML/.test(navigator.userAgent)
|
||||
},
|
||||
|
||||
isSafari: function () {
|
||||
return /AppleWebKit'/.test(navigator.appVersion);
|
||||
},
|
||||
|
||||
isOpera: function () {
|
||||
return /Opera/.test(navigator.userAgent);
|
||||
}
|
||||
});
|
||||
|
||||
MochiKit.Base.update(MochiKit.DOM, {
|
||||
getStyle: function (element, style) {
|
||||
element = MochiKit.DOM.getElement(element);
|
||||
var value = element.style[MochiKit.Base.camelize(style)];
|
||||
if (!value) {
|
||||
if (document.defaultView && document.defaultView.getComputedStyle) {
|
||||
var css = document.defaultView.getComputedStyle(element, null);
|
||||
value = css ? css.getPropertyValue(style) : null;
|
||||
} else if (element.currentStyle) {
|
||||
value = element.currentStyle[MochiKit.Base.camelize(style)];
|
||||
}
|
||||
}
|
||||
|
||||
if (MochiKit.Base.isOpera() && (MochiKit.Base.find(['left', 'top', 'right', 'bottom'], style))) {
|
||||
if (MochiKit.DOM.getStyle(element, 'position') == 'static') {
|
||||
value = 'auto';
|
||||
}
|
||||
}
|
||||
|
||||
return value == 'auto' ? null : value;
|
||||
},
|
||||
|
||||
setStyle: function (element, style) {
|
||||
element = MochiKit.DOM.getElement(element);
|
||||
for (var name in style) {
|
||||
element.style[MochiKit.Base.camelize(name)] = style[name];
|
||||
}
|
||||
},
|
||||
|
||||
getOpacity: function (element) {
|
||||
var opacity;
|
||||
if (opacity = MochiKit.DOM.getStyle(element, 'opacity')) {
|
||||
return parseFloat(opacity);
|
||||
}
|
||||
if (opacity = (MochiKit.DOM.getStyle(element, 'filter') || '').match(/alpha\(opacity=(.*)\)/)) {
|
||||
if (opacity[1]) {
|
||||
return parseFloat(opacity[1]) / 100;
|
||||
}
|
||||
}
|
||||
return 1.0;
|
||||
},
|
||||
|
||||
getInlineOpacity: function (element) {
|
||||
return MochiKit.DOM.getElement(element).style.opacity || '';
|
||||
},
|
||||
|
||||
setOpacity: function (element, value) {
|
||||
element = MochiKit.DOM.getElement(element);
|
||||
if (value == 1) {
|
||||
var cssText = element.style.cssText;
|
||||
if(MochiKit.Base.isIE())
|
||||
cssText = cssText.replace(/filter: ?alpha\([^\)]*\);?/gi, '');
|
||||
|
||||
element.style.cssText = cssText.replace(/opacity: ?\d\.?\d*/gi, '');
|
||||
} else {
|
||||
if (value < 0.00001) {
|
||||
value = 0;
|
||||
}
|
||||
MochiKit.DOM.setStyle(element, {opacity: value});
|
||||
if (MochiKit.Base.isIE()) {
|
||||
MochiKit.DOM.setStyle(element,
|
||||
{filter: MochiKit.DOM.getStyle(element, 'filter').replace(/alpha\([^\)]*\)/gi, '') + 'alpha(opacity=' + value * 100 + ')' });
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
isVisible: function (element) {
|
||||
return MochiKit.DOM.getElement(element).style.display != 'none';
|
||||
},
|
||||
|
||||
makeClipping: function (element) {
|
||||
element = MochiKit.DOM.getElement(element);
|
||||
if (element._overflow) {
|
||||
return;
|
||||
}
|
||||
element._overflow = element.style.overflow;
|
||||
if ((MochiKit.DOM.getStyle(element, 'overflow') || 'visible') != 'hidden') {
|
||||
element.style.overflow = 'hidden';
|
||||
}
|
||||
},
|
||||
|
||||
undoClipping: function (element) {
|
||||
element = MochiKit.DOM.getElement(element);
|
||||
if (!element._overflow) {
|
||||
return;
|
||||
}
|
||||
element.style.overflow = element._overflow;
|
||||
element._overflow = undefined;
|
||||
},
|
||||
|
||||
makePositioned: function (element) {
|
||||
element = MochiKit.DOM.getElement(element);
|
||||
/*if (!element.style) {
|
||||
alert(element);
|
||||
}*/
|
||||
var pos = MochiKit.DOM.getStyle(element, 'position');
|
||||
if ((pos == 'static' || !pos) && !element._madePositioned) {
|
||||
element._madePositioned = true;
|
||||
element.style.position = 'relative';
|
||||
// Opera returns the offset relative to the positioning context,
|
||||
// when an element is position relative but top and left have
|
||||
// not been defined
|
||||
if (MochiKit.Base.isOpera()) {
|
||||
element.style.top = 0;
|
||||
element.style.left = 0;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
undoPositioned: function (element) {
|
||||
element = MochiKit.DOM.getElement(element);
|
||||
if (element._madePositioned) {
|
||||
element._madePositioned = undefined;
|
||||
element.style.position = element.style.top = element.style.left = element.style.bottom = element.style.right = '';
|
||||
}
|
||||
},
|
||||
|
||||
getFirstElementByTagAndClassName: function (tagName, className,
|
||||
/* optional */parent) {
|
||||
var self = MochiKit.DOM;
|
||||
if (typeof(tagName) == 'undefined' || tagName === null) {
|
||||
tagName = '*';
|
||||
}
|
||||
if (typeof(parent) == 'undefined' || parent === null) {
|
||||
parent = self._document;
|
||||
}
|
||||
parent = self.getElement(parent);
|
||||
var children = (parent.getElementsByTagName(tagName)
|
||||
|| self._document.all);
|
||||
if (typeof(className) == 'undefined' || className === null) {
|
||||
return MochiKit.Base.extend(null, children);
|
||||
}
|
||||
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
var child = children[i];
|
||||
var classNames = child.className.split(' ');
|
||||
for (var j = 0; j < classNames.length; j++) {
|
||||
if (classNames[j] == className) {
|
||||
return child;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
isParent: function (child, element) {
|
||||
if (!child.parentNode || child == element) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (child.parentNode == element) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return MochiKit.DOM.isParent(child.parentNode, element);
|
||||
}
|
||||
});
|
||||
|
||||
MochiKit.Position = {
|
||||
// set to true if needed, warning: firefox performance problems
|
||||
// NOT neeeded for page scrolling, only if draggable contained in
|
||||
// scrollable elements
|
||||
includeScrollOffsets: false,
|
||||
|
||||
prepare: function () {
|
||||
var deltaX = window.pageXOffset
|
||||
|| document.documentElement.scrollLeft
|
||||
|| document.body.scrollLeft
|
||||
|| 0;
|
||||
var deltaY = window.pageYOffset
|
||||
|| document.documentElement.scrollTop
|
||||
|| document.body.scrollTop
|
||||
|| 0;
|
||||
this.windowOffset = new MochiKit.Style.Coordinates(deltaX, deltaY);
|
||||
},
|
||||
|
||||
cumulativeOffset: function (element) {
|
||||
var valueT = 0;
|
||||
var valueL = 0;
|
||||
do {
|
||||
valueT += element.offsetTop || 0;
|
||||
valueL += element.offsetLeft || 0;
|
||||
element = element.offsetParent;
|
||||
} while (element);
|
||||
return new MochiKit.Style.Coordinates(valueL, valueT);
|
||||
},
|
||||
|
||||
realOffset: function (element) {
|
||||
var valueT = 0;
|
||||
var valueL = 0;
|
||||
do {
|
||||
valueT += element.scrollTop || 0;
|
||||
valueL += element.scrollLeft || 0;
|
||||
element = element.parentNode;
|
||||
} while (element);
|
||||
return new MochiKit.Style.Coordinates(valueL, valueT);
|
||||
},
|
||||
|
||||
within: function (element, x, y) {
|
||||
if (this.includeScrollOffsets) {
|
||||
return this.withinIncludingScrolloffsets(element, x, y);
|
||||
}
|
||||
this.xcomp = x;
|
||||
this.ycomp = y;
|
||||
this.offset = this.cumulativeOffset(element);
|
||||
if (element.style.position == "fixed") {
|
||||
this.offset.x += this.windowOffset.x;
|
||||
this.offset.y += this.windowOffset.y;
|
||||
}
|
||||
|
||||
return (y >= this.offset.y &&
|
||||
y < this.offset.y + element.offsetHeight &&
|
||||
x >= this.offset.x &&
|
||||
x < this.offset.x + element.offsetWidth);
|
||||
},
|
||||
|
||||
withinIncludingScrolloffsets: function (element, x, y) {
|
||||
var offsetcache = this.realOffset(element);
|
||||
|
||||
this.xcomp = x + offsetcache.x - this.windowOffset.x;
|
||||
this.ycomp = y + offsetcache.y - this.windowOffset.y;
|
||||
this.offset = this.cumulativeOffset(element);
|
||||
|
||||
return (this.ycomp >= this.offset.y &&
|
||||
this.ycomp < this.offset.y + element.offsetHeight &&
|
||||
this.xcomp >= this.offset.x &&
|
||||
this.xcomp < this.offset.x + element.offsetWidth);
|
||||
},
|
||||
|
||||
// within must be called directly before
|
||||
overlap: function (mode, element) {
|
||||
if (!mode) {
|
||||
return 0;
|
||||
}
|
||||
if (mode == 'vertical') {
|
||||
return ((this.offset.y + element.offsetHeight) - this.ycomp) /
|
||||
element.offsetHeight;
|
||||
}
|
||||
if (mode == 'horizontal') {
|
||||
return ((this.offset.x + element.offsetWidth) - this.xcomp) /
|
||||
element.offsetWidth;
|
||||
}
|
||||
},
|
||||
|
||||
absolutize: function (element) {
|
||||
element = MochiKit.DOM.getElement(element);
|
||||
if (element.style.position == 'absolute') {
|
||||
return;
|
||||
}
|
||||
MochiKit.Position.prepare();
|
||||
|
||||
var offsets = MochiKit.Position.positionedOffset(element);
|
||||
var width = element.clientWidth;
|
||||
var height = element.clientHeight;
|
||||
|
||||
var oldStyle = {
|
||||
'position': element.style.position,
|
||||
'left': offsets.x - parseFloat(element.style.left || 0),
|
||||
'top': offsets.y - parseFloat(element.style.top || 0),
|
||||
'width': element.style.width,
|
||||
'height': element.style.height
|
||||
};
|
||||
|
||||
element.style.position = 'absolute';
|
||||
element.style.top = offsets.y + 'px';
|
||||
element.style.left = offsets.x + 'px';
|
||||
element.style.width = width + 'px';
|
||||
element.style.height = height + 'px';
|
||||
|
||||
return oldStyle;
|
||||
},
|
||||
|
||||
positionedOffset: function (element) {
|
||||
var valueT = 0, valueL = 0;
|
||||
do {
|
||||
valueT += element.offsetTop || 0;
|
||||
valueL += element.offsetLeft || 0;
|
||||
element = element.offsetParent;
|
||||
if (element) {
|
||||
p = MochiKit.DOM.getStyle(element, 'position');
|
||||
if (p == 'relative' || p == 'absolute') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} while (element);
|
||||
return new MochiKit.Style.Coordinates(valueL, valueT);
|
||||
},
|
||||
|
||||
relativize: function (element, oldPos) {
|
||||
element = MochiKit.DOM.getElement(element);
|
||||
if (element.style.position == 'relative') {
|
||||
return;
|
||||
}
|
||||
MochiKit.Position.prepare();
|
||||
|
||||
var top = parseFloat(element.style.top || 0) -
|
||||
(oldPos['top'] || 0);
|
||||
var left = parseFloat(element.style.left || 0) -
|
||||
(oldPos['left'] || 0);
|
||||
|
||||
element.style.position = oldPos['position'];
|
||||
element.style.top = top + 'px';
|
||||
element.style.left = left + 'px';
|
||||
element.style.width = oldPos['width'];
|
||||
element.style.height = oldPos['height'];
|
||||
},
|
||||
|
||||
clone: function (source, target) {
|
||||
source = MochiKit.DOM.getElement(source);
|
||||
target = MochiKit.DOM.getElement(target);
|
||||
target.style.position = 'absolute';
|
||||
var offsets = this.cumulativeOffset(source);
|
||||
target.style.top = offsets.y + 'px';
|
||||
target.style.left = offsets.x + 'px';
|
||||
target.style.width = source.offsetWidth + 'px';
|
||||
target.style.height = source.offsetHeight + 'px';
|
||||
},
|
||||
|
||||
page: function (forElement) {
|
||||
var valueT = 0;
|
||||
var valueL = 0;
|
||||
|
||||
var element = forElement;
|
||||
do {
|
||||
valueT += element.offsetTop || 0;
|
||||
valueL += element.offsetLeft || 0;
|
||||
|
||||
// Safari fix
|
||||
if (element.offsetParent == document.body && MochiKit.DOM.getStyle(element, 'position') == 'absolute') {
|
||||
break;
|
||||
}
|
||||
} while (element = element.offsetParent);
|
||||
|
||||
element = forElement;
|
||||
do {
|
||||
valueT -= element.scrollTop || 0;
|
||||
valueL -= element.scrollLeft || 0;
|
||||
} while (element = element.parentNode);
|
||||
|
||||
return new MochiKit.Style.Coordinates(valueL, valueT);
|
||||
}
|
||||
};
|
||||
|
||||
712
crystalreportviewers13/js/MochiKit/Signal.js
Normal file
@@ -0,0 +1,712 @@
|
||||
/***
|
||||
|
||||
MochiKit.Signal 1.4
|
||||
|
||||
See <http://mochikit.com/> for documentation, downloads, license, etc.
|
||||
|
||||
(c) 2006 Jonathan Gardner, Beau Hartshorne, Bob Ippolito. All rights Reserved.
|
||||
|
||||
***/
|
||||
|
||||
if (typeof(dojo) != 'undefined') {
|
||||
dojo.provide('MochiKit.Signal');
|
||||
dojo.require('MochiKit.Base');
|
||||
dojo.require('MochiKit.DOM');
|
||||
dojo.require('MochiKit.Style');
|
||||
}
|
||||
if (typeof(JSAN) != 'undefined') {
|
||||
JSAN.use('MochiKit.Base', []);
|
||||
JSAN.use('MochiKit.DOM', []);
|
||||
}
|
||||
|
||||
try {
|
||||
if (typeof(MochiKit.Base) == 'undefined') {
|
||||
throw '';
|
||||
}
|
||||
} catch (e) {
|
||||
throw 'MochiKit.Signal depends on MochiKit.Base!';
|
||||
}
|
||||
|
||||
try {
|
||||
if (typeof(MochiKit.DOM) == 'undefined') {
|
||||
throw '';
|
||||
}
|
||||
} catch (e) {
|
||||
throw 'MochiKit.Signal depends on MochiKit.DOM!';
|
||||
}
|
||||
|
||||
try {
|
||||
if (typeof(MochiKit.Style) == 'undefined') {
|
||||
throw '';
|
||||
}
|
||||
} catch (e) {
|
||||
throw 'MochiKit.Signal depends on MochiKit.Style!';
|
||||
}
|
||||
|
||||
if (typeof(MochiKit.Signal) == 'undefined') {
|
||||
MochiKit.Signal = {};
|
||||
}
|
||||
|
||||
MochiKit.Signal.NAME = 'MochiKit.Signal';
|
||||
MochiKit.Signal.VERSION = '1.4';
|
||||
|
||||
MochiKit.Signal._observers = [];
|
||||
|
||||
MochiKit.Signal.Event = function (src, e) {
|
||||
this._event = e || window.event;
|
||||
this._src = src;
|
||||
};
|
||||
|
||||
MochiKit.Base.update(MochiKit.Signal.Event.prototype, {
|
||||
|
||||
__repr__: function() {
|
||||
var repr = MochiKit.Base.repr;
|
||||
var str = '{event(): ' + repr(this.event()) +
|
||||
', src(): ' + repr(this.src()) +
|
||||
', type(): ' + repr(this.type()) +
|
||||
', target(): ' + repr(this.target()) +
|
||||
', modifier(): ' + '{alt: ' + repr(this.modifier().alt) +
|
||||
', ctrl: ' + repr(this.modifier().ctrl) +
|
||||
', meta: ' + repr(this.modifier().meta) +
|
||||
', shift: ' + repr(this.modifier().shift) +
|
||||
', any: ' + repr(this.modifier().any) + '}';
|
||||
|
||||
if (this.type() && this.type().indexOf('key') === 0) {
|
||||
str += ', key(): {code: ' + repr(this.key().code) +
|
||||
', string: ' + repr(this.key().string) + '}';
|
||||
}
|
||||
|
||||
if (this.type() && (
|
||||
this.type().indexOf('mouse') === 0 ||
|
||||
this.type().indexOf('click') != -1 ||
|
||||
this.type() == 'contextmenu')) {
|
||||
|
||||
str += ', mouse(): {page: ' + repr(this.mouse().page) +
|
||||
', client: ' + repr(this.mouse().client);
|
||||
|
||||
if (this.type() != 'mousemove') {
|
||||
str += ', button: {left: ' + repr(this.mouse().button.left) +
|
||||
', middle: ' + repr(this.mouse().button.middle) +
|
||||
', right: ' + repr(this.mouse().button.right) + '}}';
|
||||
} else {
|
||||
str += '}';
|
||||
}
|
||||
}
|
||||
if (this.type() == 'mouseover' || this.type() == 'mouseout') {
|
||||
str += ', relatedTarget(): ' + repr(this.relatedTarget());
|
||||
}
|
||||
str += '}';
|
||||
return str;
|
||||
},
|
||||
|
||||
toString: function () {
|
||||
return this.__repr__();
|
||||
},
|
||||
|
||||
src: function () {
|
||||
return this._src;
|
||||
},
|
||||
|
||||
event: function () {
|
||||
return this._event;
|
||||
},
|
||||
|
||||
type: function () {
|
||||
return this._event.type || undefined;
|
||||
},
|
||||
|
||||
target: function () {
|
||||
return this._event.target || this._event.srcElement;
|
||||
},
|
||||
|
||||
_relatedTarget: null,
|
||||
relatedTarget: function () {
|
||||
if (this._relatedTarget !== null) {
|
||||
return this._relatedTarget;
|
||||
}
|
||||
|
||||
var elem = null;
|
||||
if (this.type() == 'mouseover') {
|
||||
elem = (this._event.relatedTarget ||
|
||||
this._event.fromElement);
|
||||
} else if (this.type() == 'mouseout') {
|
||||
elem = (this._event.relatedTarget ||
|
||||
this._event.toElement);
|
||||
}
|
||||
if (elem !== null) {
|
||||
this._relatedTarget = elem;
|
||||
return elem;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
},
|
||||
|
||||
_modifier: null,
|
||||
modifier: function () {
|
||||
if (this._modifier !== null) {
|
||||
return this._modifier;
|
||||
}
|
||||
var m = {};
|
||||
m.alt = this._event.altKey;
|
||||
m.ctrl = this._event.ctrlKey;
|
||||
m.meta = this._event.metaKey || false; // IE and Opera punt here
|
||||
m.shift = this._event.shiftKey;
|
||||
m.any = m.alt || m.ctrl || m.shift || m.meta;
|
||||
this._modifier = m;
|
||||
return m;
|
||||
},
|
||||
|
||||
_key: null,
|
||||
key: function () {
|
||||
if (this._key !== null) {
|
||||
return this._key;
|
||||
}
|
||||
var k = {};
|
||||
if (this.type() && this.type().indexOf('key') === 0) {
|
||||
|
||||
/*
|
||||
|
||||
If you're looking for a special key, look for it in keydown or
|
||||
keyup, but never keypress. If you're looking for a Unicode
|
||||
chracter, look for it with keypress, but never keyup or
|
||||
keydown.
|
||||
|
||||
Notes:
|
||||
|
||||
FF key event behavior:
|
||||
key event charCode keyCode
|
||||
DOWN ku,kd 0 40
|
||||
DOWN kp 0 40
|
||||
ESC ku,kd 0 27
|
||||
ESC kp 0 27
|
||||
a ku,kd 0 65
|
||||
a kp 97 0
|
||||
shift+a ku,kd 0 65
|
||||
shift+a kp 65 0
|
||||
1 ku,kd 0 49
|
||||
1 kp 49 0
|
||||
shift+1 ku,kd 0 0
|
||||
shift+1 kp 33 0
|
||||
|
||||
IE key event behavior:
|
||||
(IE doesn't fire keypress events for special keys.)
|
||||
key event keyCode
|
||||
DOWN ku,kd 40
|
||||
DOWN kp undefined
|
||||
ESC ku,kd 27
|
||||
ESC kp 27
|
||||
a ku,kd 65
|
||||
a kp 97
|
||||
shift+a ku,kd 65
|
||||
shift+a kp 65
|
||||
1 ku,kd 49
|
||||
1 kp 49
|
||||
shift+1 ku,kd 49
|
||||
shift+1 kp 33
|
||||
|
||||
Safari key event behavior:
|
||||
(Safari sets charCode and keyCode to something crazy for
|
||||
special keys.)
|
||||
key event charCode keyCode
|
||||
DOWN ku,kd 63233 40
|
||||
DOWN kp 63233 63233
|
||||
ESC ku,kd 27 27
|
||||
ESC kp 27 27
|
||||
a ku,kd 97 65
|
||||
a kp 97 97
|
||||
shift+a ku,kd 65 65
|
||||
shift+a kp 65 65
|
||||
1 ku,kd 49 49
|
||||
1 kp 49 49
|
||||
shift+1 ku,kd 33 49
|
||||
shift+1 kp 33 33
|
||||
|
||||
*/
|
||||
|
||||
/* look for special keys here */
|
||||
if (this.type() == 'keydown' || this.type() == 'keyup') {
|
||||
k.code = this._event.keyCode;
|
||||
k.string = (MochiKit.Signal._specialKeys[k.code] ||
|
||||
'KEY_UNKNOWN');
|
||||
this._key = k;
|
||||
return k;
|
||||
|
||||
/* look for characters here */
|
||||
} else if (this.type() == 'keypress') {
|
||||
|
||||
/*
|
||||
|
||||
Special key behavior:
|
||||
|
||||
IE: does not fire keypress events for special keys
|
||||
FF: sets charCode to 0, and sets the correct keyCode
|
||||
Safari: sets keyCode and charCode to something stupid
|
||||
|
||||
*/
|
||||
|
||||
k.code = 0;
|
||||
k.string = '';
|
||||
|
||||
if (typeof(this._event.charCode) != 'undefined' &&
|
||||
this._event.charCode !== 0 &&
|
||||
!MochiKit.Signal._specialMacKeys[this._event.charCode]) {
|
||||
k.code = this._event.charCode;
|
||||
k.string = String.fromCharCode(k.code);
|
||||
} else if (this._event.keyCode &&
|
||||
typeof(this._event.charCode) == 'undefined') { // IE
|
||||
k.code = this._event.keyCode;
|
||||
k.string = String.fromCharCode(k.code);
|
||||
}
|
||||
|
||||
this._key = k;
|
||||
return k;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
},
|
||||
|
||||
_mouse: null,
|
||||
mouse: function () {
|
||||
if (this._mouse !== null) {
|
||||
return this._mouse;
|
||||
}
|
||||
|
||||
var m = {};
|
||||
var e = this._event;
|
||||
|
||||
if (this.type() && (
|
||||
this.type().indexOf('mouse') === 0 ||
|
||||
this.type().indexOf('click') != -1 ||
|
||||
this.type() == 'contextmenu')) {
|
||||
|
||||
m.client = new MochiKit.Style.Coordinates(0, 0);
|
||||
if (e.clientX || e.clientY) {
|
||||
m.client.x = (!e.clientX || e.clientX < 0) ? 0 : e.clientX;
|
||||
m.client.y = (!e.clientY || e.clientY < 0) ? 0 : e.clientY;
|
||||
}
|
||||
|
||||
m.page = new MochiKit.Style.Coordinates(0, 0);
|
||||
if (e.pageX || e.pageY) {
|
||||
m.page.x = (!e.pageX || e.pageX < 0) ? 0 : e.pageX;
|
||||
m.page.y = (!e.pageY || e.pageY < 0) ? 0 : e.pageY;
|
||||
} else {
|
||||
/*
|
||||
|
||||
The IE shortcut can be off by two. We fix it. See:
|
||||
http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/getboundingclientrect.asp
|
||||
|
||||
This is similar to the method used in
|
||||
MochiKit.Style.getElementPosition().
|
||||
|
||||
*/
|
||||
var de = MochiKit.DOM._document.documentElement;
|
||||
var b = MochiKit.DOM._document.body;
|
||||
|
||||
m.page.x = e.clientX +
|
||||
(de.scrollLeft || b.scrollLeft) -
|
||||
(de.clientLeft || 0);
|
||||
|
||||
m.page.y = e.clientY +
|
||||
(de.scrollTop || b.scrollTop) -
|
||||
(de.clientTop || 0);
|
||||
|
||||
}
|
||||
if (this.type() != 'mousemove') {
|
||||
m.button = {};
|
||||
m.button.left = false;
|
||||
m.button.right = false;
|
||||
m.button.middle = false;
|
||||
|
||||
/* we could check e.button, but which is more consistent */
|
||||
if (e.which) {
|
||||
m.button.left = (e.which == 1);
|
||||
m.button.middle = (e.which == 2);
|
||||
m.button.right = (e.which == 3);
|
||||
|
||||
/*
|
||||
|
||||
Mac browsers and right click:
|
||||
|
||||
- Safari doesn't fire any click events on a right
|
||||
click:
|
||||
http://bugzilla.opendarwin.org/show_bug.cgi?id=6595
|
||||
|
||||
- Firefox fires the event, and sets ctrlKey = true
|
||||
|
||||
- Opera fires the event, and sets metaKey = true
|
||||
|
||||
oncontextmenu is fired on right clicks between
|
||||
browsers and across platforms.
|
||||
|
||||
*/
|
||||
|
||||
} else {
|
||||
m.button.left = !!(e.button & 1);
|
||||
m.button.right = !!(e.button & 2);
|
||||
m.button.middle = !!(e.button & 4);
|
||||
}
|
||||
}
|
||||
this._mouse = m;
|
||||
return m;
|
||||
}
|
||||
return undefined;
|
||||
},
|
||||
|
||||
stop: function () {
|
||||
this.stopPropagation();
|
||||
this.preventDefault();
|
||||
},
|
||||
|
||||
stopPropagation: function () {
|
||||
if (this._event.stopPropagation) {
|
||||
this._event.stopPropagation();
|
||||
} else {
|
||||
this._event.cancelBubble = true;
|
||||
}
|
||||
},
|
||||
|
||||
preventDefault: function () {
|
||||
if (this._event.preventDefault) {
|
||||
this._event.preventDefault();
|
||||
} else if (this._confirmUnload === null) {
|
||||
this._event.returnValue = false;
|
||||
}
|
||||
},
|
||||
|
||||
_confirmUnload: null,
|
||||
confirmUnload: function (msg) {
|
||||
if (this.type() == 'beforeunload') {
|
||||
this._confirmUnload = msg;
|
||||
this._event.returnValue = msg;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/* Safari sets keyCode to these special values onkeypress. */
|
||||
MochiKit.Signal._specialMacKeys = {
|
||||
3: 'KEY_ENTER',
|
||||
63289: 'KEY_NUM_PAD_CLEAR',
|
||||
63276: 'KEY_PAGE_UP',
|
||||
63277: 'KEY_PAGE_DOWN',
|
||||
63275: 'KEY_END',
|
||||
63273: 'KEY_HOME',
|
||||
63234: 'KEY_ARROW_LEFT',
|
||||
63232: 'KEY_ARROW_UP',
|
||||
63235: 'KEY_ARROW_RIGHT',
|
||||
63233: 'KEY_ARROW_DOWN',
|
||||
63302: 'KEY_INSERT',
|
||||
63272: 'KEY_DELETE'
|
||||
};
|
||||
|
||||
/* for KEY_F1 - KEY_F12 */
|
||||
for (i = 63236; i <= 63242; i++) {
|
||||
MochiKit.Signal._specialMacKeys[i] = 'KEY_F' + (i - 63236 + 1); // no F0
|
||||
}
|
||||
|
||||
/* Standard keyboard key codes. */
|
||||
MochiKit.Signal._specialKeys = {
|
||||
8: 'KEY_BACKSPACE',
|
||||
9: 'KEY_TAB',
|
||||
12: 'KEY_NUM_PAD_CLEAR', // weird, for Safari and Mac FF only
|
||||
13: 'KEY_ENTER',
|
||||
16: 'KEY_SHIFT',
|
||||
17: 'KEY_CTRL',
|
||||
18: 'KEY_ALT',
|
||||
19: 'KEY_PAUSE',
|
||||
20: 'KEY_CAPS_LOCK',
|
||||
27: 'KEY_ESCAPE',
|
||||
32: 'KEY_SPACEBAR',
|
||||
33: 'KEY_PAGE_UP',
|
||||
34: 'KEY_PAGE_DOWN',
|
||||
35: 'KEY_END',
|
||||
36: 'KEY_HOME',
|
||||
37: 'KEY_ARROW_LEFT',
|
||||
38: 'KEY_ARROW_UP',
|
||||
39: 'KEY_ARROW_RIGHT',
|
||||
40: 'KEY_ARROW_DOWN',
|
||||
44: 'KEY_PRINT_SCREEN',
|
||||
45: 'KEY_INSERT',
|
||||
46: 'KEY_DELETE',
|
||||
59: 'KEY_SEMICOLON', // weird, for Safari and IE only
|
||||
91: 'KEY_WINDOWS_LEFT',
|
||||
92: 'KEY_WINDOWS_RIGHT',
|
||||
93: 'KEY_SELECT',
|
||||
106: 'KEY_NUM_PAD_ASTERISK',
|
||||
107: 'KEY_NUM_PAD_PLUS_SIGN',
|
||||
109: 'KEY_NUM_PAD_HYPHEN-MINUS',
|
||||
110: 'KEY_NUM_PAD_FULL_STOP',
|
||||
111: 'KEY_NUM_PAD_SOLIDUS',
|
||||
144: 'KEY_NUM_LOCK',
|
||||
145: 'KEY_SCROLL_LOCK',
|
||||
186: 'KEY_SEMICOLON',
|
||||
187: 'KEY_EQUALS_SIGN',
|
||||
188: 'KEY_COMMA',
|
||||
189: 'KEY_HYPHEN-MINUS',
|
||||
190: 'KEY_FULL_STOP',
|
||||
191: 'KEY_SOLIDUS',
|
||||
192: 'KEY_GRAVE_ACCENT',
|
||||
219: 'KEY_LEFT_SQUARE_BRACKET',
|
||||
220: 'KEY_REVERSE_SOLIDUS',
|
||||
221: 'KEY_RIGHT_SQUARE_BRACKET',
|
||||
222: 'KEY_APOSTROPHE'
|
||||
// undefined: 'KEY_UNKNOWN'
|
||||
};
|
||||
|
||||
/* for KEY_0 - KEY_9 */
|
||||
for (var i = 48; i <= 57; i++) {
|
||||
MochiKit.Signal._specialKeys[i] = 'KEY_' + (i - 48);
|
||||
}
|
||||
|
||||
/* for KEY_A - KEY_Z */
|
||||
for (i = 65; i <= 90; i++) {
|
||||
MochiKit.Signal._specialKeys[i] = 'KEY_' + String.fromCharCode(i);
|
||||
}
|
||||
|
||||
/* for KEY_NUM_PAD_0 - KEY_NUM_PAD_9 */
|
||||
for (i = 96; i <= 105; i++) {
|
||||
MochiKit.Signal._specialKeys[i] = 'KEY_NUM_PAD_' + (i - 96);
|
||||
}
|
||||
|
||||
/* for KEY_F1 - KEY_F12 */
|
||||
for (i = 112; i <= 123; i++) {
|
||||
MochiKit.Signal._specialKeys[i] = 'KEY_F' + (i - 112 + 1); // no F0
|
||||
}
|
||||
|
||||
MochiKit.Base.update(MochiKit.Signal, {
|
||||
|
||||
__repr__: function () {
|
||||
return '[' + this.NAME + ' ' + this.VERSION + ']';
|
||||
},
|
||||
|
||||
toString: function () {
|
||||
return this.__repr__();
|
||||
},
|
||||
|
||||
_unloadCache: function () {
|
||||
var self = MochiKit.Signal;
|
||||
var observers = self._observers;
|
||||
|
||||
for (var i = 0; i < observers.length; i++) {
|
||||
self._disconnect(observers[i]);
|
||||
}
|
||||
|
||||
delete self._observers;
|
||||
|
||||
try {
|
||||
window.onload = undefined;
|
||||
} catch(e) {
|
||||
// pass
|
||||
}
|
||||
|
||||
try {
|
||||
window.onunload = undefined;
|
||||
} catch(e) {
|
||||
// pass
|
||||
}
|
||||
},
|
||||
|
||||
_listener: function (src, func, obj, isDOM) {
|
||||
var E = MochiKit.Signal.Event;
|
||||
if (!isDOM) {
|
||||
return MochiKit.Base.bind(func, obj);
|
||||
}
|
||||
obj = obj || src;
|
||||
if (typeof(func) == "string") {
|
||||
return function (nativeEvent) {
|
||||
obj[func].apply(obj, [new E(src, nativeEvent)]);
|
||||
};
|
||||
} else {
|
||||
return function (nativeEvent) {
|
||||
func.apply(obj, [new E(src, nativeEvent)]);
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
connect: function (src, sig, objOrFunc/* optional */, funcOrStr) {
|
||||
src = MochiKit.DOM.getElement(src);
|
||||
var self = MochiKit.Signal;
|
||||
|
||||
if (typeof(sig) != 'string') {
|
||||
throw new Error("'sig' must be a string");
|
||||
}
|
||||
|
||||
var obj = null;
|
||||
var func = null;
|
||||
if (typeof(funcOrStr) != 'undefined') {
|
||||
obj = objOrFunc;
|
||||
func = funcOrStr;
|
||||
if (typeof(funcOrStr) == 'string') {
|
||||
if (typeof(objOrFunc[funcOrStr]) != "function") {
|
||||
throw new Error("'funcOrStr' must be a function on 'objOrFunc'");
|
||||
}
|
||||
} else if (typeof(funcOrStr) != 'function') {
|
||||
throw new Error("'funcOrStr' must be a function or string");
|
||||
}
|
||||
} else if (typeof(objOrFunc) != "function") {
|
||||
throw new Error("'objOrFunc' must be a function if 'funcOrStr' is not given");
|
||||
} else {
|
||||
func = objOrFunc;
|
||||
}
|
||||
if (typeof(obj) == 'undefined' || obj === null) {
|
||||
obj = src;
|
||||
}
|
||||
|
||||
var isDOM = !!(src.addEventListener || src.attachEvent);
|
||||
var listener = self._listener(src, func, obj, isDOM);
|
||||
|
||||
if (src.addEventListener) {
|
||||
src.addEventListener(sig.substr(2), listener, false);
|
||||
} else if (src.attachEvent) {
|
||||
src.attachEvent(sig, listener); // useCapture unsupported
|
||||
}
|
||||
|
||||
var ident = [src, sig, listener, isDOM, objOrFunc, funcOrStr];
|
||||
self._observers.push(ident);
|
||||
|
||||
|
||||
return ident;
|
||||
},
|
||||
|
||||
_disconnect: function (ident) {
|
||||
// check isDOM
|
||||
if (!ident[3]) { return; }
|
||||
var src = ident[0];
|
||||
var sig = ident[1];
|
||||
var listener = ident[2];
|
||||
if (src.removeEventListener) {
|
||||
src.removeEventListener(sig.substr(2), listener, false);
|
||||
} else if (src.detachEvent) {
|
||||
src.detachEvent(sig, listener); // useCapture unsupported
|
||||
} else {
|
||||
throw new Error("'src' must be a DOM element");
|
||||
}
|
||||
},
|
||||
|
||||
disconnect: function (ident) {
|
||||
var self = MochiKit.Signal;
|
||||
var observers = self._observers;
|
||||
var m = MochiKit.Base;
|
||||
if (arguments.length > 1) {
|
||||
// compatibility API
|
||||
var src = MochiKit.DOM.getElement(arguments[0]);
|
||||
var sig = arguments[1];
|
||||
var obj = arguments[2];
|
||||
var func = arguments[3];
|
||||
for (var i = observers.length - 1; i >= 0; i--) {
|
||||
var o = observers[i];
|
||||
if (o[0] === src && o[1] === sig && o[4] === obj && o[5] === func) {
|
||||
self._disconnect(o);
|
||||
observers.splice(i, 1);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var idx = m.findIdentical(observers, ident);
|
||||
if (idx >= 0) {
|
||||
self._disconnect(ident);
|
||||
observers.splice(idx, 1);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
disconnectAll: function(src/* optional */, sig) {
|
||||
src = MochiKit.DOM.getElement(src);
|
||||
var m = MochiKit.Base;
|
||||
var signals = m.flattenArguments(m.extend(null, arguments, 1));
|
||||
var self = MochiKit.Signal;
|
||||
var disconnect = self._disconnect;
|
||||
var observers = self._observers;
|
||||
if (signals.length === 0) {
|
||||
// disconnect all
|
||||
for (var i = observers.length - 1; i >= 0; i--) {
|
||||
var ident = observers[i];
|
||||
if (ident[0] === src) {
|
||||
disconnect(ident);
|
||||
observers.splice(i, 1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var sigs = {};
|
||||
for (var i = 0; i < signals.length; i++) {
|
||||
sigs[signals[i]] = true;
|
||||
}
|
||||
for (var i = observers.length - 1; i >= 0; i--) {
|
||||
var ident = observers[i];
|
||||
if (ident[0] === src && ident[1] in sigs) {
|
||||
disconnect(ident);
|
||||
observers.splice(i, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
signal: function (src, sig) {
|
||||
var observers = MochiKit.Signal._observers;
|
||||
src = MochiKit.DOM.getElement(src);
|
||||
var args = MochiKit.Base.extend(null, arguments, 2);
|
||||
var errors = [];
|
||||
for (var i = 0; i < observers.length; i++) {
|
||||
var ident = observers[i];
|
||||
if (ident[0] === src && ident[1] === sig) {
|
||||
try {
|
||||
ident[2].apply(src, args);
|
||||
} catch (e) {
|
||||
errors.push(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (errors.length == 1) {
|
||||
throw errors[0];
|
||||
} else if (errors.length > 1) {
|
||||
var e = new Error("Multiple errors thrown in handling 'sig', see errors property");
|
||||
e.errors = errors;
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
MochiKit.Signal.EXPORT_OK = [];
|
||||
|
||||
MochiKit.Signal.EXPORT = [
|
||||
'connect',
|
||||
'disconnect',
|
||||
'signal',
|
||||
'disconnectAll'
|
||||
];
|
||||
|
||||
MochiKit.Signal.__new__ = function (win) {
|
||||
var m = MochiKit.Base;
|
||||
this._document = document;
|
||||
this._window = win;
|
||||
|
||||
try {
|
||||
this.connect(window, 'onunload', this._unloadCache);
|
||||
} catch (e) {
|
||||
// pass: might not be a browser
|
||||
}
|
||||
|
||||
this.EXPORT_TAGS = {
|
||||
':common': this.EXPORT,
|
||||
':all': m.concat(this.EXPORT, this.EXPORT_OK)
|
||||
};
|
||||
|
||||
m.nameFunctions(this);
|
||||
};
|
||||
|
||||
MochiKit.Signal.__new__(this);
|
||||
|
||||
//
|
||||
// XXX: Internet Explorer blows
|
||||
//
|
||||
if (MochiKit.__export__) {
|
||||
connect = MochiKit.Signal.connect;
|
||||
disconnect = MochiKit.Signal.disconnect;
|
||||
disconnectAll = MochiKit.Signal.disconnectAll;
|
||||
signal = MochiKit.Signal.signal;
|
||||
}
|
||||
|
||||
MochiKit.Base._exportSymbols(this, MochiKit.Signal);
|
||||
531
crystalreportviewers13/js/MochiKit/Sortable.js
Normal file
@@ -0,0 +1,531 @@
|
||||
/***
|
||||
Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
|
||||
Mochi-ized By Thomas Herve (_firstname_@nimail.org)
|
||||
|
||||
See scriptaculous.js for full license.
|
||||
|
||||
***/
|
||||
|
||||
if (typeof(dojo) != 'undefined') {
|
||||
dojo.provide('MochiKit.DragAndDrop');
|
||||
dojo.require('MochiKit.Base');
|
||||
dojo.require('MochiKit.DOM');
|
||||
dojo.require('MochiKit.Iter');
|
||||
}
|
||||
|
||||
if (typeof(JSAN) != 'undefined') {
|
||||
JSAN.use("MochiKit.Base", []);
|
||||
JSAN.use("MochiKit.DOM", []);
|
||||
JSAN.use("MochiKit.Iter", []);
|
||||
}
|
||||
|
||||
try {
|
||||
if (typeof(MochiKit.Base) == 'undefined' ||
|
||||
typeof(MochiKit.DOM) == 'undefined' ||
|
||||
typeof(MochiKit.Iter) == 'undefined') {
|
||||
throw "";
|
||||
}
|
||||
} catch (e) {
|
||||
throw "MochiKit.DragAndDrop depends on MochiKit.Base, MochiKit.DOM and MochiKit.Iter!";
|
||||
}
|
||||
|
||||
if (typeof(MochiKit.Sortable) == 'undefined') {
|
||||
MochiKit.Sortable = {};
|
||||
}
|
||||
|
||||
MochiKit.Sortable.NAME = 'MochiKit.Sortable';
|
||||
MochiKit.Sortable.VERSION = '1.4';
|
||||
|
||||
MochiKit.Sortable.__repr__ = function () {
|
||||
return '[' + this.NAME + ' ' + this.VERSION + ']';
|
||||
};
|
||||
|
||||
MochiKit.Sortable.toString = function () {
|
||||
return this.__repr__();
|
||||
};
|
||||
|
||||
MochiKit.Sortable.EXPORT = [
|
||||
"SortableObserver"
|
||||
];
|
||||
|
||||
MochiKit.DragAndDrop.EXPORT_OK = [
|
||||
"Sortable"
|
||||
];
|
||||
|
||||
MochiKit.Sortable.SortableObserver = function (element, observer) {
|
||||
this.__init__(element, observer);
|
||||
};
|
||||
|
||||
MochiKit.Sortable.SortableObserver.prototype = {
|
||||
/***
|
||||
|
||||
Observe events of drag and drop sortables.
|
||||
|
||||
***/
|
||||
__init__: function (element, observer) {
|
||||
this.element = MochiKit.DOM.getElement(element);
|
||||
this.observer = observer;
|
||||
this.lastValue = MochiKit.Sortable.Sortable.serialize(this.element);
|
||||
},
|
||||
|
||||
onStart: function () {
|
||||
this.lastValue = MochiKit.Sortable.Sortable.serialize(this.element);
|
||||
},
|
||||
|
||||
onEnd: function () {
|
||||
MochiKit.Sortable.Sortable.unmark();
|
||||
if (this.lastValue != MochiKit.Sortable.Sortable.serialize(this.element)) {
|
||||
this.observer(this.element)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
MochiKit.Sortable.Sortable = {
|
||||
/***
|
||||
|
||||
Manage sortables. Mainly use the create function to add a sortable.
|
||||
|
||||
***/
|
||||
sortables: {},
|
||||
|
||||
_findRootElement: function (element) {
|
||||
while (element.tagName != "BODY") {
|
||||
if (element.id && MochiKit.Sortable.Sortable.sortables[element.id]) {
|
||||
return element;
|
||||
}
|
||||
element = element.parentNode;
|
||||
}
|
||||
},
|
||||
|
||||
options: function (element) {
|
||||
element = MochiKit.Sortable.Sortable._findRootElement(MochiKit.DOM.getElement(element));
|
||||
if (!element) {
|
||||
return;
|
||||
}
|
||||
return MochiKit.Sortable.Sortable.sortables[element.id];
|
||||
},
|
||||
|
||||
destroy: function (element){
|
||||
var s = MochiKit.Sortable.Sortable.options(element);
|
||||
var b = MochiKit.Base;
|
||||
var d = MochiKit.DragAndDrop;
|
||||
|
||||
if (s) {
|
||||
d.Draggables.removeObserver(s.element);
|
||||
b.map(function (dr) {
|
||||
d.Droppables.remove(dr);
|
||||
}, s.droppables);
|
||||
b.map(function (dr) {
|
||||
dr.destroy();
|
||||
}, s.draggables);
|
||||
|
||||
delete MochiKit.Sortable.Sortable.sortables[s.element.id];
|
||||
}
|
||||
},
|
||||
|
||||
create: function (element, options) {
|
||||
element = MochiKit.DOM.getElement(element);
|
||||
var self = MochiKit.Sortable.Sortable;
|
||||
options = MochiKit.Base.update({
|
||||
element: element,
|
||||
tag: 'li', // assumes li children, override with tag: 'tagname'
|
||||
dropOnEmpty: false,
|
||||
tree: false,
|
||||
treeTag: 'ul',
|
||||
overlap: 'vertical', // one of 'vertical', 'horizontal'
|
||||
constraint: 'vertical', // one of 'vertical', 'horizontal', false
|
||||
// also takes array of elements (or ids); or false
|
||||
containment: [element],
|
||||
handle: false, // or a CSS class
|
||||
only: false,
|
||||
hoverclass: null,
|
||||
ghosting: false,
|
||||
scroll: false,
|
||||
scrollSensitivity: 20,
|
||||
scrollSpeed: 15,
|
||||
format: /^[^_]*_(.*)$/,
|
||||
onChange: MochiKit.Base.noop,
|
||||
onUpdate: MochiKit.Base.noop,
|
||||
accept: null
|
||||
}, options);
|
||||
|
||||
// clear any old sortable with same element
|
||||
self.destroy(element);
|
||||
|
||||
// build options for the draggables
|
||||
var options_for_draggable = {
|
||||
revert: true,
|
||||
ghosting: options.ghosting,
|
||||
scroll: options.scroll,
|
||||
scrollSensitivity: options.scrollSensitivity,
|
||||
scrollSpeed: options.scrollSpeed,
|
||||
constraint: options.constraint,
|
||||
handle: options.handle
|
||||
};
|
||||
|
||||
if (options.starteffect) {
|
||||
options_for_draggable.starteffect = options.starteffect;
|
||||
}
|
||||
|
||||
if (options.reverteffect) {
|
||||
options_for_draggable.reverteffect = options.reverteffect;
|
||||
} else if (options.ghosting) {
|
||||
options_for_draggable.reverteffect = function (innerelement) {
|
||||
innerelement.style.top = 0;
|
||||
innerelement.style.left = 0;
|
||||
};
|
||||
}
|
||||
|
||||
if (options.endeffect) {
|
||||
options_for_draggable.endeffect = options.endeffect;
|
||||
}
|
||||
|
||||
if (options.zindex) {
|
||||
options_for_draggable.zindex = options.zindex;
|
||||
}
|
||||
|
||||
// build options for the droppables
|
||||
var options_for_droppable = {
|
||||
overlap: options.overlap,
|
||||
containment: options.containment,
|
||||
hoverclass: options.hoverclass,
|
||||
onhover: self.onHover,
|
||||
tree: options.tree,
|
||||
accept: options.accept
|
||||
}
|
||||
|
||||
var options_for_tree = {
|
||||
onhover: self.onEmptyHover,
|
||||
overlap: options.overlap,
|
||||
containment: options.containment,
|
||||
hoverclass: options.hoverclass,
|
||||
accept: options.accept
|
||||
}
|
||||
|
||||
// fix for gecko engine
|
||||
MochiKit.DOM.removeEmptyTextNodes(element);
|
||||
|
||||
options.draggables = [];
|
||||
options.droppables = [];
|
||||
|
||||
// drop on empty handling
|
||||
if (options.dropOnEmpty || options.tree) {
|
||||
new MochiKit.DragAndDrop.Droppable(element, options_for_tree);
|
||||
options.droppables.push(element);
|
||||
}
|
||||
MochiKit.Base.map(function (e) {
|
||||
// handles are per-draggable
|
||||
var handle = options.handle ?
|
||||
MochiKit.DOM.getFirstElementByTagAndClassName(null,
|
||||
options.handle, e) : e;
|
||||
options.draggables.push(
|
||||
new MochiKit.DragAndDrop.Draggable(e,
|
||||
MochiKit.Base.update(options_for_draggable,
|
||||
{handle: handle})));
|
||||
new MochiKit.DragAndDrop.Droppable(e, options_for_droppable);
|
||||
if (options.tree) {
|
||||
e.treeNode = element;
|
||||
}
|
||||
options.droppables.push(e);
|
||||
}, (self.findElements(element, options) || []));
|
||||
|
||||
if (options.tree) {
|
||||
MochiKit.Base.map(function (e) {
|
||||
new MochiKit.DragAndDrop.Droppable(e, options_for_tree);
|
||||
e.treeNode = element;
|
||||
options.droppables.push(e);
|
||||
}, (self.findTreeElements(element, options) || []));
|
||||
}
|
||||
|
||||
// keep reference
|
||||
self.sortables[element.id] = options;
|
||||
|
||||
// for onupdate
|
||||
MochiKit.DragAndDrop.Draggables.addObserver(
|
||||
new MochiKit.Sortable.SortableObserver(element, options.onUpdate));
|
||||
},
|
||||
|
||||
// return all suitable-for-sortable elements in a guaranteed order
|
||||
findElements: function (element, options) {
|
||||
return MochiKit.Sortable.Sortable.findChildren(
|
||||
element, options.only, options.tree ? true : false, options.tag);
|
||||
},
|
||||
|
||||
findTreeElements: function (element, options) {
|
||||
return MochiKit.Sortable.Sortable.findChildren(
|
||||
element, options.only, options.tree ? true : false, options.treeTag);
|
||||
},
|
||||
|
||||
findChildren: function (element, only, recursive, tagName) {
|
||||
if (!element.hasChildNodes()) {
|
||||
return null;
|
||||
}
|
||||
tagName = tagName.toUpperCase();
|
||||
if (only) {
|
||||
only = MochiKit.Base.flattenArray([only]);
|
||||
}
|
||||
var elements = [];
|
||||
MochiKit.Base.map(function (e) {
|
||||
if (e.tagName &&
|
||||
e.tagName.toUpperCase() == tagName &&
|
||||
(!only ||
|
||||
MochiKit.Iter.some(only, function (c) {
|
||||
return MochiKit.DOM.hasElementClass(e, c);
|
||||
}))) {
|
||||
elements.push(e);
|
||||
}
|
||||
if (recursive) {
|
||||
var grandchildren = MochiKit.Sortable.Sortable.findChildren(e, only, recursive, tagName);
|
||||
if (grandchildren && grandchildren.length > 0) {
|
||||
elements = elements.concat(grandchildren);
|
||||
}
|
||||
}
|
||||
}, element.childNodes);
|
||||
return elements;
|
||||
},
|
||||
|
||||
onHover: function (element, dropon, overlap) {
|
||||
if (MochiKit.DOM.isParent(dropon, element)) {
|
||||
return;
|
||||
}
|
||||
var self = MochiKit.Sortable.Sortable;
|
||||
|
||||
if (overlap > .33 && overlap < .66 && self.options(dropon).tree) {
|
||||
return;
|
||||
} else if (overlap > 0.5) {
|
||||
self.mark(dropon, 'before');
|
||||
if (dropon.previousSibling != element) {
|
||||
var oldParentNode = element.parentNode;
|
||||
element.style.visibility = 'hidden'; // fix gecko rendering
|
||||
dropon.parentNode.insertBefore(element, dropon);
|
||||
if (dropon.parentNode != oldParentNode) {
|
||||
self.options(oldParentNode).onChange(element);
|
||||
}
|
||||
self.options(dropon.parentNode).onChange(element);
|
||||
}
|
||||
} else {
|
||||
self.mark(dropon, 'after');
|
||||
var nextElement = dropon.nextSibling || null;
|
||||
if (nextElement != element) {
|
||||
var oldParentNode = element.parentNode;
|
||||
element.style.visibility = 'hidden'; // fix gecko rendering
|
||||
dropon.parentNode.insertBefore(element, nextElement);
|
||||
if (dropon.parentNode != oldParentNode) {
|
||||
self.options(oldParentNode).onChange(element);
|
||||
}
|
||||
self.options(dropon.parentNode).onChange(element);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_offsetSize: function (element, type) {
|
||||
if (type == 'vertical' || type == 'height') {
|
||||
return element.offsetHeight;
|
||||
} else {
|
||||
return element.offsetWidth;
|
||||
}
|
||||
},
|
||||
|
||||
onEmptyHover: function (element, dropon, overlap) {
|
||||
var oldParentNode = element.parentNode;
|
||||
var self = MochiKit.Sortable.Sortable;
|
||||
var droponOptions = self.options(dropon);
|
||||
|
||||
if (!MochiKit.DOM.isParent(dropon, element)) {
|
||||
var index;
|
||||
|
||||
var children = self.findElements(dropon, {tag: droponOptions.tag,
|
||||
only: droponOptions.only});
|
||||
var child = null;
|
||||
|
||||
if (children) {
|
||||
var offset = self._offsetSize(dropon, droponOptions.overlap) * (1.0 - overlap);
|
||||
|
||||
for (index = 0; index < children.length; index += 1) {
|
||||
if (offset - self._offsetSize(children[index], droponOptions.overlap) >= 0) {
|
||||
offset -= self._offsetSize(children[index], droponOptions.overlap);
|
||||
} else if (offset - (self._offsetSize (children[index], droponOptions.overlap) / 2) >= 0) {
|
||||
child = index + 1 < children.length ? children[index + 1] : null;
|
||||
break;
|
||||
} else {
|
||||
child = children[index];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dropon.insertBefore(element, child);
|
||||
|
||||
self.options(oldParentNode).onChange(element);
|
||||
droponOptions.onChange(element);
|
||||
}
|
||||
},
|
||||
|
||||
unmark: function () {
|
||||
var m = MochiKit.Sortable.Sortable._marker;
|
||||
if (m) {
|
||||
MochiKit.Style.hideElement(m);
|
||||
}
|
||||
},
|
||||
|
||||
mark: function (dropon, position) {
|
||||
// mark on ghosting only
|
||||
var d = MochiKit.DOM;
|
||||
var self = MochiKit.Sortable.Sortable;
|
||||
var sortable = self.options(dropon.parentNode);
|
||||
if (sortable && !sortable.ghosting) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!self._marker) {
|
||||
self._marker = d.getElement('dropmarker') ||
|
||||
document.createElement('DIV');
|
||||
MochiKit.Style.hideElement(self._marker);
|
||||
d.addElementClass(self._marker, 'dropmarker');
|
||||
self._marker.style.position = 'absolute';
|
||||
document.getElementsByTagName('body').item(0).appendChild(self._marker);
|
||||
}
|
||||
var offsets = MochiKit.Position.cumulativeOffset(dropon);
|
||||
self._marker.style.left = offsets.x + 'px';
|
||||
self._marker.style.top = offsets.y + 'px';
|
||||
|
||||
if (position == 'after') {
|
||||
if (sortable.overlap == 'horizontal') {
|
||||
self._marker.style.left = (offsets.x + dropon.clientWidth) + 'px';
|
||||
} else {
|
||||
self._marker.style.top = (offsets.y + dropon.clientHeight) + 'px';
|
||||
}
|
||||
}
|
||||
MochiKit.Style.showElement(self._marker);
|
||||
},
|
||||
|
||||
_tree: function (element, options, parent) {
|
||||
var self = MochiKit.Sortable.Sortable;
|
||||
var children = self.findElements(element, options) || [];
|
||||
|
||||
for (var i = 0; i < children.length; ++i) {
|
||||
var match = children[i].id.match(options.format);
|
||||
|
||||
if (!match) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var child = {
|
||||
id: encodeURIComponent(match ? match[1] : null),
|
||||
element: element,
|
||||
parent: parent,
|
||||
children: [],
|
||||
position: parent.children.length,
|
||||
container: self._findChildrenElement(children[i], options.treeTag.toUpperCase())
|
||||
}
|
||||
|
||||
/* Get the element containing the children and recurse over it */
|
||||
if (child.container) {
|
||||
self._tree(child.container, options, child)
|
||||
}
|
||||
|
||||
parent.children.push (child);
|
||||
}
|
||||
|
||||
return parent;
|
||||
},
|
||||
|
||||
/* Finds the first element of the given tag type within a parent element.
|
||||
Used for finding the first LI[ST] within a L[IST]I[TEM].*/
|
||||
_findChildrenElement: function (element, containerTag) {
|
||||
if (element && element.hasChildNodes) {
|
||||
for (var i = 0; i < element.childNodes.length; ++i) {
|
||||
if (element.childNodes[i].tagName == containerTag) {
|
||||
return element.childNodes[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
tree: function (element, options) {
|
||||
element = MochiKit.DOM.getElement(element);
|
||||
var sortableOptions = MochiKit.Sortable.Sortable.options(element);
|
||||
options = MochiKit.Base.update({
|
||||
tag: sortableOptions.tag,
|
||||
treeTag: sortableOptions.treeTag,
|
||||
only: sortableOptions.only,
|
||||
name: element.id,
|
||||
format: sortableOptions.format
|
||||
}, options || {});
|
||||
|
||||
var root = {
|
||||
id: null,
|
||||
parent: null,
|
||||
children: new Array,
|
||||
container: element,
|
||||
position: 0
|
||||
}
|
||||
|
||||
return MochiKit.Sortable.Sortable._tree(element, options, root);
|
||||
},
|
||||
|
||||
setSequence: function (element, newSequence, options) {
|
||||
var self = MochiKit.Sortable.Sortable;
|
||||
var b = MochiKit.Base;
|
||||
element = MochiKit.DOM.getElement(element);
|
||||
options = b.update(self.options(element), options || {});
|
||||
|
||||
var nodeMap = {};
|
||||
b.map(function (n) {
|
||||
var m = n.id.match(options.format);
|
||||
if (m) {
|
||||
nodeMap[m[1]] = [n, n.parentNode];
|
||||
}
|
||||
n.parentNode.removeChild(n);
|
||||
}, self.findElements(element, options));
|
||||
|
||||
b.map(function (ident) {
|
||||
var n = nodeMap[ident];
|
||||
if (n) {
|
||||
n[1].appendChild(n[0]);
|
||||
delete nodeMap[ident];
|
||||
}
|
||||
}, newSequence);
|
||||
},
|
||||
|
||||
/* Construct a [i] index for a particular node */
|
||||
_constructIndex: function (node) {
|
||||
var index = '';
|
||||
do {
|
||||
if (node.id) {
|
||||
index = '[' + node.position + ']' + index;
|
||||
}
|
||||
} while ((node = node.parent) != null);
|
||||
return index;
|
||||
},
|
||||
|
||||
sequence: function (element, options) {
|
||||
element = MochiKit.DOM.getElement(element);
|
||||
var self = MochiKit.Sortable.Sortable;
|
||||
var options = MochiKit.Base.update(self.options(element), options || {});
|
||||
|
||||
return MochiKit.Base.map(function (item) {
|
||||
return item.id.match(options.format) ? item.id.match(options.format)[1] : '';
|
||||
}, MochiKit.DOM.getElement(self.findElements(element, options) || []));
|
||||
},
|
||||
|
||||
serialize: function (element, options) {
|
||||
element = MochiKit.DOM.getElement(element);
|
||||
var self = MochiKit.Sortable.Sortable;
|
||||
options = MochiKit.Base.update(self.options(element), options || {});
|
||||
var name = encodeURIComponent(options.name || element.id);
|
||||
|
||||
if (options.tree) {
|
||||
return MochiKit.Base.flattenArray(MochiKit.Base.map(function (item) {
|
||||
return [name + self._constructIndex(item) + "[id]=" +
|
||||
encodeURIComponent(item.id)].concat(item.children.map(arguments.callee));
|
||||
}, self.tree(element, options).children)).join('&');
|
||||
} else {
|
||||
return MochiKit.Base.map(function (item) {
|
||||
return name + "[]=" + encodeURIComponent(item);
|
||||
}, self.sequence(element, options)).join('&');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
374
crystalreportviewers13/js/MochiKit/Style.js
Normal file
@@ -0,0 +1,374 @@
|
||||
/***
|
||||
|
||||
MochiKit.Style 1.4
|
||||
|
||||
See <http://mochikit.com/> for documentation, downloads, license, etc.
|
||||
|
||||
(c) 2005-2006 Bob Ippolito, Beau Hartshorne. All rights Reserved.
|
||||
|
||||
***/
|
||||
|
||||
if (typeof(dojo) != 'undefined') {
|
||||
dojo.provide('MochiKit.Style');
|
||||
dojo.require('MochiKit.Base');
|
||||
dojo.require('MochiKit.DOM');
|
||||
}
|
||||
if (typeof(JSAN) != 'undefined') {
|
||||
JSAN.use('MochiKit.Base', []);
|
||||
}
|
||||
|
||||
try {
|
||||
if (typeof(MochiKit.Base) == 'undefined') {
|
||||
throw '';
|
||||
}
|
||||
} catch (e) {
|
||||
throw 'MochiKit.Style depends on MochiKit.Base!';
|
||||
}
|
||||
|
||||
try {
|
||||
if (typeof(MochiKit.DOM) == 'undefined') {
|
||||
throw '';
|
||||
}
|
||||
} catch (e) {
|
||||
throw 'MochiKit.Style depends on MochiKit.DOM!';
|
||||
}
|
||||
|
||||
|
||||
if (typeof(MochiKit.Style) == 'undefined') {
|
||||
MochiKit.Style = {};
|
||||
}
|
||||
|
||||
MochiKit.Style.NAME = 'MochiKit.Style';
|
||||
MochiKit.Style.VERSION = '1.4';
|
||||
MochiKit.Style.__repr__ = function () {
|
||||
return '[' + this.NAME + ' ' + this.VERSION + ']';
|
||||
};
|
||||
MochiKit.Style.toString = function () {
|
||||
return this.__repr__();
|
||||
};
|
||||
|
||||
MochiKit.Style.EXPORT_OK = [];
|
||||
|
||||
MochiKit.Style.EXPORT = [
|
||||
'setOpacity',
|
||||
'computedStyle',
|
||||
'getElementDimensions',
|
||||
'elementDimensions', // deprecated
|
||||
'setElementDimensions',
|
||||
'getElementPosition',
|
||||
'elementPosition', // deprecated
|
||||
'setElementPosition',
|
||||
'setDisplayForElement',
|
||||
'hideElement',
|
||||
'showElement',
|
||||
'getViewportDimensions',
|
||||
'Dimensions',
|
||||
'Coordinates'
|
||||
];
|
||||
|
||||
|
||||
/*
|
||||
|
||||
Dimensions
|
||||
|
||||
*/
|
||||
MochiKit.Style.Dimensions = function (w, h) {
|
||||
this.w = w;
|
||||
this.h = h;
|
||||
};
|
||||
|
||||
MochiKit.Style.Dimensions.prototype.__repr__ = function () {
|
||||
var repr = MochiKit.Base.repr;
|
||||
return '{w: ' + repr(this.w) + ', h: ' + repr(this.h) + '}';
|
||||
};
|
||||
|
||||
MochiKit.Style.Dimensions.prototype.toString = function () {
|
||||
return this.__repr__();
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
|
||||
Coordinates
|
||||
|
||||
*/
|
||||
MochiKit.Style.Coordinates = function (x, y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
};
|
||||
|
||||
MochiKit.Style.Coordinates.prototype.__repr__ = function () {
|
||||
var repr = MochiKit.Base.repr;
|
||||
return '{x: ' + repr(this.x) + ', y: ' + repr(this.y) + '}';
|
||||
};
|
||||
|
||||
MochiKit.Style.Coordinates.prototype.toString = function () {
|
||||
return this.__repr__();
|
||||
};
|
||||
|
||||
|
||||
MochiKit.Base.update(MochiKit.Style, {
|
||||
|
||||
computedStyle: function (elem, cssProperty) {
|
||||
var dom = MochiKit.DOM;
|
||||
var d = dom._document;
|
||||
|
||||
elem = dom.getElement(elem);
|
||||
cssProperty = MochiKit.Base.camelize(cssProperty);
|
||||
|
||||
if (!elem || elem == d) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/* from YUI 0.10.0 */
|
||||
if (cssProperty == 'opacity' && elem.filters) { // IE opacity
|
||||
try {
|
||||
return elem.filters.item('DXImageTransform.Microsoft.Alpha'
|
||||
).opacity / 100;
|
||||
} catch(e) {
|
||||
try {
|
||||
return elem.filters.item('alpha').opacity / 100;
|
||||
} catch(e) {}
|
||||
}
|
||||
}
|
||||
|
||||
if (elem.currentStyle) {
|
||||
return elem.currentStyle[cssProperty];
|
||||
}
|
||||
if (typeof(d.defaultView) == 'undefined') {
|
||||
return undefined;
|
||||
}
|
||||
if (d.defaultView === null) {
|
||||
return undefined;
|
||||
}
|
||||
var style = d.defaultView.getComputedStyle(elem, null);
|
||||
if (typeof(style) == 'undefined' || style === null) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var selectorCase = cssProperty.replace(/([A-Z])/g, '-$1'
|
||||
).toLowerCase(); // from dojo.style.toSelectorCase
|
||||
|
||||
return style.getPropertyValue(selectorCase);
|
||||
},
|
||||
|
||||
setOpacity: function(elem, o) {
|
||||
elem = MochiKit.DOM.getElement(elem);
|
||||
MochiKit.DOM.updateNodeAttributes(elem, {'style': {
|
||||
'opacity': o,
|
||||
'-moz-opacity': o,
|
||||
'-khtml-opacity': o,
|
||||
'filter':' alpha(opacity=' + (o * 100) + ')'
|
||||
}});
|
||||
},
|
||||
|
||||
/*
|
||||
|
||||
getElementPosition is adapted from YAHOO.util.Dom.getXY v0.9.0.
|
||||
Copyright: Copyright (c) 2006, Yahoo! Inc. All rights reserved.
|
||||
License: BSD, http://developer.yahoo.net/yui/license.txt
|
||||
|
||||
*/
|
||||
getElementPosition: function (elem, /* optional */relativeTo, doc) {
|
||||
var self = MochiKit.Style;
|
||||
var dom = MochiKit.DOM;
|
||||
elem = dom.getElement(elem);
|
||||
|
||||
if (!elem ||
|
||||
(!(elem.x && elem.y) &&
|
||||
(!elem.parentNode == null ||
|
||||
self.computedStyle(elem, 'display') == 'none'))) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var c = new self.Coordinates(0, 0);
|
||||
var box = null;
|
||||
var parent = null;
|
||||
|
||||
var d = doc ? doc : MochiKit.DOM._document;
|
||||
var de = d.documentElement;
|
||||
var b = d.body;
|
||||
|
||||
if (!elem.parentNode && elem.x && elem.y) {
|
||||
/* it's just a MochiKit.Style.Coordinates object */
|
||||
c.x += elem.x || 0;
|
||||
c.y += elem.y || 0;
|
||||
} else if (elem.getBoundingClientRect) { // IE shortcut
|
||||
/*
|
||||
|
||||
The IE shortcut can be off by two. We fix it. See:
|
||||
http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/getboundingclientrect.asp
|
||||
|
||||
This is similar to the method used in
|
||||
MochiKit.Signal.Event.mouse().
|
||||
|
||||
*/
|
||||
box = elem.getBoundingClientRect();
|
||||
|
||||
c.x += box.left +
|
||||
(de.scrollLeft || b.scrollLeft) -
|
||||
(de.clientLeft || 0);
|
||||
|
||||
c.y += box.top +
|
||||
(de.scrollTop || b.scrollTop) -
|
||||
(de.clientTop || 0);
|
||||
|
||||
} else if (elem.offsetParent) {
|
||||
c.x += elem.offsetLeft;
|
||||
c.y += elem.offsetTop;
|
||||
parent = elem.offsetParent;
|
||||
|
||||
if (parent != elem) {
|
||||
while (parent) {
|
||||
c.x += parent.offsetLeft;
|
||||
c.y += parent.offsetTop;
|
||||
parent = parent.offsetParent;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Opera < 9 and old Safari (absolute) incorrectly account for
|
||||
body offsetTop and offsetLeft.
|
||||
|
||||
*/
|
||||
var ua = navigator.userAgent.toLowerCase();
|
||||
if ((typeof(opera) != 'undefined' &&
|
||||
parseFloat(opera.version()) < 9) ||
|
||||
(ua.indexOf('safari') != -1 &&
|
||||
self.computedStyle(elem, 'position') == 'absolute')) {
|
||||
|
||||
c.x -= b.offsetLeft;
|
||||
c.y -= b.offsetTop;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof(relativeTo) != 'undefined') {
|
||||
relativeTo = arguments.callee(relativeTo);
|
||||
if (relativeTo) {
|
||||
c.x -= (relativeTo.x || 0);
|
||||
c.y -= (relativeTo.y || 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (elem.parentNode) {
|
||||
parent = elem.parentNode;
|
||||
} else {
|
||||
parent = null;
|
||||
}
|
||||
|
||||
while (parent && parent.tagName != 'BODY' &&
|
||||
parent.tagName != 'HTML') {
|
||||
c.x -= parent.scrollLeft;
|
||||
c.y -= parent.scrollTop;
|
||||
if (parent.parentNode) {
|
||||
parent = parent.parentNode;
|
||||
} else {
|
||||
parent = null;
|
||||
}
|
||||
}
|
||||
|
||||
return c;
|
||||
},
|
||||
|
||||
setElementPosition: function (elem, newPos/* optional */, units) {
|
||||
elem = MochiKit.DOM.getElement(elem);
|
||||
if (typeof(units) == 'undefined') {
|
||||
units = 'px';
|
||||
}
|
||||
MochiKit.DOM.updateNodeAttributes(elem, {'style': {
|
||||
'left': newPos.x + units,
|
||||
'top': newPos.y + units
|
||||
}});
|
||||
},
|
||||
|
||||
getElementDimensions: function (elem) {
|
||||
var self = MochiKit.Style;
|
||||
var dom = MochiKit.DOM;
|
||||
if (typeof(elem.w) == 'number' || typeof(elem.h) == 'number') {
|
||||
return new self.Dimensions(elem.w || 0, elem.h || 0);
|
||||
}
|
||||
elem = dom.getElement(elem);
|
||||
if (!elem) {
|
||||
return undefined;
|
||||
}
|
||||
if (self.computedStyle(elem, 'display') != 'none') {
|
||||
return new self.Dimensions(elem.offsetWidth || 0,
|
||||
elem.offsetHeight || 0);
|
||||
}
|
||||
var s = elem.style;
|
||||
var originalVisibility = s.visibility;
|
||||
var originalPosition = s.position;
|
||||
s.visibility = 'hidden';
|
||||
s.position = 'absolute';
|
||||
s.display = '';
|
||||
var originalWidth = elem.offsetWidth;
|
||||
var originalHeight = elem.offsetHeight;
|
||||
s.display = 'none';
|
||||
s.position = originalPosition;
|
||||
s.visibility = originalVisibility;
|
||||
return new self.Dimensions(originalWidth, originalHeight);
|
||||
},
|
||||
|
||||
setElementDimensions: function (elem, newSize/* optional */, units) {
|
||||
elem = MochiKit.DOM.getElement(elem);
|
||||
if (typeof(units) == 'undefined') {
|
||||
units = 'px';
|
||||
}
|
||||
MochiKit.DOM.updateNodeAttributes(elem, {'style': {
|
||||
'width': newSize.w + units,
|
||||
'height': newSize.h + units
|
||||
}});
|
||||
},
|
||||
|
||||
setDisplayForElement: function (display, element/*, ...*/) {
|
||||
var elements = MochiKit.Base.extend(null, arguments, 1);
|
||||
var getElement = MochiKit.DOM.getElement;
|
||||
for (var i = 0; i < elements.length; i++) {
|
||||
var element = getElement(elements[i]);
|
||||
if (element) {
|
||||
element.style.display = display;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
getViewportDimensions: function() {
|
||||
var d = new MochiKit.Style.Dimensions();
|
||||
|
||||
var w = MochiKit.DOM._window;
|
||||
var b = MochiKit.DOM._document.body;
|
||||
|
||||
if (w.innerWidth) {
|
||||
d.w = w.innerWidth;
|
||||
d.h = w.innerHeight;
|
||||
} else if (b.parentElement.clientWidth) {
|
||||
d.w = b.parentElement.clientWidth;
|
||||
d.h = b.parentElement.clientHeight;
|
||||
} else if (b && b.clientWidth) {
|
||||
d.w = b.clientWidth;
|
||||
d.h = b.clientHeight;
|
||||
}
|
||||
return d;
|
||||
},
|
||||
|
||||
__new__: function () {
|
||||
var m = MochiKit.Base;
|
||||
|
||||
this.elementPosition = this.getElementPosition;
|
||||
this.elementDimensions = this.getElementDimensions;
|
||||
|
||||
this.hideElement = m.partial(this.setDisplayForElement, 'none');
|
||||
this.showElement = m.partial(this.setDisplayForElement, 'block');
|
||||
|
||||
this.EXPORT_TAGS = {
|
||||
':common': this.EXPORT,
|
||||
':all': m.concat(this.EXPORT, this.EXPORT_OK)
|
||||
};
|
||||
|
||||
m.nameFunctions(this);
|
||||
}
|
||||
});
|
||||
|
||||
MochiKit.Style.__new__();
|
||||
MochiKit.Base._exportSymbols(this, MochiKit.Style);
|
||||
181
crystalreportviewers13/js/MochiKit/Test.js
Normal file
@@ -0,0 +1,181 @@
|
||||
/***
|
||||
|
||||
MochiKit.Test 1.4
|
||||
|
||||
See <http://mochikit.com/> for documentation, downloads, license, etc.
|
||||
|
||||
(c) 2005 Bob Ippolito. All rights Reserved.
|
||||
|
||||
***/
|
||||
|
||||
if (typeof(dojo) != 'undefined') {
|
||||
dojo.provide('MochiKit.Test');
|
||||
dojo.require('MochiKit.Base');
|
||||
}
|
||||
|
||||
if (typeof(JSAN) != 'undefined') {
|
||||
JSAN.use("MochiKit.Base", []);
|
||||
}
|
||||
|
||||
try {
|
||||
if (typeof(MochiKit.Base) == 'undefined') {
|
||||
throw "";
|
||||
}
|
||||
} catch (e) {
|
||||
throw "MochiKit.Test depends on MochiKit.Base!";
|
||||
}
|
||||
|
||||
if (typeof(MochiKit.Test) == 'undefined') {
|
||||
MochiKit.Test = {};
|
||||
}
|
||||
|
||||
MochiKit.Test.NAME = "MochiKit.Test";
|
||||
MochiKit.Test.VERSION = "1.4";
|
||||
MochiKit.Test.__repr__ = function () {
|
||||
return "[" + this.NAME + " " + this.VERSION + "]";
|
||||
};
|
||||
|
||||
MochiKit.Test.toString = function () {
|
||||
return this.__repr__();
|
||||
};
|
||||
|
||||
|
||||
MochiKit.Test.EXPORT = ["runTests"];
|
||||
MochiKit.Test.EXPORT_OK = [];
|
||||
|
||||
MochiKit.Test.runTests = function (obj) {
|
||||
if (typeof(obj) == "string") {
|
||||
obj = JSAN.use(obj);
|
||||
}
|
||||
var suite = new MochiKit.Test.Suite();
|
||||
suite.run(obj);
|
||||
};
|
||||
|
||||
MochiKit.Test.Suite = function () {
|
||||
this.testIndex = 0;
|
||||
MochiKit.Base.bindMethods(this);
|
||||
};
|
||||
|
||||
MochiKit.Test.Suite.prototype = {
|
||||
run: function (obj) {
|
||||
try {
|
||||
obj(this);
|
||||
} catch (e) {
|
||||
this.traceback(e);
|
||||
}
|
||||
},
|
||||
traceback: function (e) {
|
||||
var items = MochiKit.Iter.sorted(MochiKit.Base.items(e));
|
||||
print("not ok " + this.testIndex + " - Error thrown");
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
var kv = items[i];
|
||||
if (kv[0] == "stack") {
|
||||
kv[1] = kv[1].split(/\n/)[0];
|
||||
}
|
||||
this.print("# " + kv.join(": "));
|
||||
}
|
||||
},
|
||||
print: function (s) {
|
||||
print(s);
|
||||
},
|
||||
is: function (got, expected, /* optional */message) {
|
||||
var res = 1;
|
||||
var msg = null;
|
||||
try {
|
||||
res = MochiKit.Base.compare(got, expected);
|
||||
} catch (e) {
|
||||
msg = "Can not compare " + typeof(got) + ":" + typeof(expected);
|
||||
}
|
||||
if (res) {
|
||||
msg = "Expected value did not compare equal";
|
||||
}
|
||||
if (!res) {
|
||||
return this.testResult(true, message);
|
||||
}
|
||||
return this.testResult(false, message,
|
||||
[[msg], ["got:", got], ["expected:", expected]]);
|
||||
},
|
||||
|
||||
testResult: function (pass, msg, failures) {
|
||||
this.testIndex += 1;
|
||||
if (pass) {
|
||||
this.print("ok " + this.testIndex + " - " + msg);
|
||||
return;
|
||||
}
|
||||
this.print("not ok " + this.testIndex + " - " + msg);
|
||||
if (failures) {
|
||||
for (var i = 0; i < failures.length; i++) {
|
||||
this.print("# " + failures[i].join(" "));
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
isDeeply: function (got, expected, /* optional */message) {
|
||||
var m = MochiKit.Base;
|
||||
var res = 1;
|
||||
try {
|
||||
res = m.compare(got, expected);
|
||||
} catch (e) {
|
||||
// pass
|
||||
}
|
||||
if (res === 0) {
|
||||
return this.ok(true, message);
|
||||
}
|
||||
var gk = m.keys(got);
|
||||
var ek = m.keys(expected);
|
||||
gk.sort();
|
||||
ek.sort();
|
||||
if (m.compare(gk, ek)) {
|
||||
// differing keys
|
||||
var cmp = {};
|
||||
var i;
|
||||
for (i = 0; i < gk.length; i++) {
|
||||
cmp[gk[i]] = "got";
|
||||
}
|
||||
for (i = 0; i < ek.length; i++) {
|
||||
if (ek[i] in cmp) {
|
||||
delete cmp[ek[i]];
|
||||
} else {
|
||||
cmp[ek[i]] = "expected";
|
||||
}
|
||||
}
|
||||
var diffkeys = m.keys(cmp);
|
||||
diffkeys.sort();
|
||||
var gotkeys = [];
|
||||
var expkeys = [];
|
||||
while (diffkeys.length) {
|
||||
var k = diffkeys.shift();
|
||||
if (k in Object.prototype) {
|
||||
continue;
|
||||
}
|
||||
(cmp[k] == "got" ? gotkeys : expkeys).push(k);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return this.testResult((!res), msg,
|
||||
(msg ? [["got:", got], ["expected:", expected]] : undefined)
|
||||
);
|
||||
},
|
||||
|
||||
ok: function (res, message) {
|
||||
return this.testResult(res, message);
|
||||
}
|
||||
};
|
||||
|
||||
MochiKit.Test.__new__ = function () {
|
||||
var m = MochiKit.Base;
|
||||
|
||||
this.EXPORT_TAGS = {
|
||||
":common": this.EXPORT,
|
||||
":all": m.concat(this.EXPORT, this.EXPORT_OK)
|
||||
};
|
||||
|
||||
m.nameFunctions(this);
|
||||
|
||||
};
|
||||
|
||||
MochiKit.Test.__new__();
|
||||
|
||||
MochiKit.Base._exportSymbols(this, MochiKit.Test);
|
||||
1735
crystalreportviewers13/js/MochiKit/Visual.js
Normal file
19
crystalreportviewers13/js/MochiKit/__package__.js
Normal file
@@ -0,0 +1,19 @@
|
||||
dojo.hostenv.conditionalLoadModule({
|
||||
"common": [
|
||||
"MochiKit.Base",
|
||||
"MochiKit.Iter",
|
||||
"MochiKit.Logging",
|
||||
"MochiKit.DateTime",
|
||||
"MochiKit.Format",
|
||||
"MochiKit.Async",
|
||||
"MochiKit.Color"
|
||||
],
|
||||
"browser": [
|
||||
"MochiKit.DOM",
|
||||
"MochiKit.Style",
|
||||
"MochiKit.Signal",
|
||||
"MochiKit.LoggingPane",
|
||||
"MochiKit.Visual"
|
||||
]
|
||||
});
|
||||
dojo.hostenv.moduleLoaded("MochiKit.*");
|
||||
695
crystalreportviewers13/js/calendar.js
Normal file
@@ -0,0 +1,695 @@
|
||||
// BEGIN USER-EDITABLE SECTION -----------------------------------------------------
|
||||
|
||||
// CALENDAR COLORS
|
||||
topBackground = "black"; // BG COLOR OF THE TOP FRAME
|
||||
bottomBackground = "white"; // BG COLOR OF THE BOTTOM FRAME
|
||||
tableBGColor = "black"; // BG COLOR OF THE BOTTOM FRAME'S TABLE
|
||||
cellColor = "lightgrey"; // TABLE CELL BG COLOR OF THE DATE CELLS IN THE BOTTOM FRAME
|
||||
headingCellColor = "white"; // TABLE CELL BG COLOR OF THE WEEKDAY ABBREVIATIONS
|
||||
headingTextColor = "black"; // TEXT COLOR OF THE WEEKDAY ABBREVIATIONS
|
||||
dateColor = "blue"; // TEXT COLOR OF THE LISTED DATES (1-28+)
|
||||
focusColor = "#ff0000"; // TEXT COLOR OF THE SELECTED DATE (OR CURRENT DATE)
|
||||
hoverColor = "darkred"; // TEXT COLOR OF A LINK WHEN YOU HOVER OVER IT
|
||||
fontStyle = "12pt arial, helvetica"; // TEXT STYLE FOR DATES
|
||||
headingFontStyle = "bold 12pt arial, helvetica"; // TEXT STYLE FOR WEEKDAY ABBREVIATIONS
|
||||
|
||||
// FORMATTING PREFERENCES
|
||||
bottomBorder = false; // TRUE/FALSE (WHETHER TO DISPLAY BOTTOM CALENDAR BORDER)
|
||||
tableBorder = 0; // SIZE OF CALENDAR TABLE BORDER (BOTTOM FRAME) 0=none
|
||||
|
||||
var DateTimeFormat = true; //"DateTime" if true, else a "Date"
|
||||
|
||||
// END USER-EDITABLE SECTION -------------------------------------------------------
|
||||
|
||||
// DETERMINE BROWSER BRAND
|
||||
var isNav = false;
|
||||
var isIE = false;
|
||||
|
||||
// ASSUME IT'S EITHER NETSCAPE OR MSIE
|
||||
if (navigator.appName == "Netscape") {
|
||||
isNav = true;
|
||||
}
|
||||
else {
|
||||
isIE = true;
|
||||
}
|
||||
|
||||
// global variable for top frame and bottom frame
|
||||
var calDocTop;
|
||||
var calDocBottom;
|
||||
|
||||
// PRE-BUILD PORTIONS OF THE CALENDAR WHEN THIS JS LIBRARY LOADS INTO THE BROWSER
|
||||
buildCalParts();
|
||||
|
||||
// CALENDAR FUNCTIONS BEGIN HERE ---------------------------------------------------
|
||||
|
||||
// SET THE INITIAL VALUE OF THE GLOBAL DATE FIELD
|
||||
function setDateField(formName, dateField) {
|
||||
|
||||
// ASSIGN THE INCOMING FIELD OBJECT TO A GLOBAL VARIABLE
|
||||
thisform = document.forms[formName];
|
||||
calDateField = thisform[dateField];
|
||||
|
||||
// GET THE VALUE OF THE INCOMING FIELD
|
||||
inDate = thisform[dateField].value;
|
||||
|
||||
// SET calDate TO THE DATE IN THE INCOMING FIELD OR DEFAULT TO TODAY'S DATE
|
||||
setInitialDate();
|
||||
|
||||
// THE CALENDAR FRAMESET DOCUMENTS ARE CREATED BY JAVASCRIPT FUNCTIONS
|
||||
calDocTop = buildTopCalFrame();
|
||||
calDocBottom = buildBottomCalFrame();
|
||||
}
|
||||
|
||||
|
||||
// SET THE INITIAL CALENDAR DATE TO TODAY OR TO THE EXISTING VALUE IN dateField
|
||||
function setInitialDate() {
|
||||
|
||||
calDate = ParseDate(inDate, DateTimeFormat);
|
||||
|
||||
// IF THE INCOMING DATE IS INVALID, USE THE CURRENT DATE
|
||||
if (isNaN(calDate)) {
|
||||
|
||||
// ADD CUSTOM DATE PARSING HERE
|
||||
// IF IT FAILS, SIMPLY CREATE A NEW DATE OBJECT WHICH DEFAULTS TO THE CURRENT DATE
|
||||
calDate = new Date();
|
||||
}
|
||||
|
||||
// KEEP TRACK OF THE CURRENT DAY VALUE
|
||||
calDay = calDate.getDate();
|
||||
|
||||
// SET DAY VALUE TO 1... TO AVOID JAVASCRIPT DATE CALCULATION ANOMALIES
|
||||
// (IF THE MONTH CHANGES TO FEB AND THE DAY IS 30, THE MONTH WOULD CHANGE TO MARCH
|
||||
// AND THE DAY WOULD CHANGE TO 2. SETTING THE DAY TO 1 WILL PREVENT THAT)
|
||||
calDate.setDate(1);
|
||||
}
|
||||
|
||||
// CREATE THE TOP CALENDAR FRAME
|
||||
function buildTopCalFrame() {
|
||||
|
||||
// CREATE THE TOP FRAME OF THE CALENDAR
|
||||
var calDoc =
|
||||
"<HTML>" +
|
||||
"<HEAD>" +
|
||||
"</HEAD>" +
|
||||
"<BODY BGCOLOR='" + topBackground + "'>" +
|
||||
"<FORM NAME='calControl' onSubmit='return false;'>" +
|
||||
"<CENTER>" +
|
||||
"<TABLE CELLPADDING=0 CELLSPACING=1 BORDER=0 WIDTH=100%>" +
|
||||
"<TR><TD COLSPAN=7>" +
|
||||
"<CENTER>" +
|
||||
getMonthSelect() +
|
||||
"<INPUT NAME='year' VALUE='" + calDate.getFullYear() + "'TYPE=TEXT SIZE=4 MAXLENGTH=4 onChange='parent.opener.setYear()' onKeyDown='if (window.event != null && window.event.keyCode == 13) parent.opener.setYear()'>" +
|
||||
"</CENTER>" +
|
||||
"</TD>" +
|
||||
"</TR>" +
|
||||
"<TR>" +
|
||||
"<TD COLSPAN=7>" +
|
||||
"<CENTER>" +
|
||||
"<INPUT " +
|
||||
"TYPE=BUTTON NAME='previousYear' VALUE='<<' onClick='parent.opener.setPreviousYear()'><INPUT " +
|
||||
"TYPE=BUTTON NAME='previousMonth' VALUE=' < ' onClick='parent.opener.setPreviousMonth()'><INPUT " +
|
||||
"TYPE=BUTTON NAME='today' VALUE=\"" + L_Today + "\" onClick='parent.opener.setToday()'><INPUT " +
|
||||
"TYPE=BUTTON NAME='nextMonth' VALUE=' > ' onClick='parent.opener.setNextMonth()'><INPUT " +
|
||||
"TYPE=BUTTON NAME='nextYear' VALUE='>>' onClick='parent.opener.setNextYear()'>" +
|
||||
"</CENTER>" +
|
||||
"</TD>" +
|
||||
"</TR>" +
|
||||
"</TABLE>" +
|
||||
"</CENTER>" +
|
||||
"</FORM>" +
|
||||
"</BODY>" +
|
||||
"</HTML>";
|
||||
|
||||
return calDoc;
|
||||
}
|
||||
|
||||
// CREATE THE BOTTOM CALENDAR FRAME
|
||||
// (THE MONTHLY CALENDAR)
|
||||
function buildBottomCalFrame() {
|
||||
// START CALENDAR DOCUMENT
|
||||
var calDoc = calendarBegin;
|
||||
|
||||
// GET MONTH, AND YEAR FROM GLOBAL CALENDAR DATE
|
||||
month = calDate.getMonth();
|
||||
year = calDate.getFullYear();
|
||||
|
||||
|
||||
// GET GLOBALLY-TRACKED DAY VALUE (PREVENTS JAVASCRIPT DATE ANOMALIES)
|
||||
day = calDay;
|
||||
|
||||
var i = 0;
|
||||
|
||||
// DETERMINE THE NUMBER OF DAYS IN THE CURRENT MONTH
|
||||
var days = getDaysInMonth();
|
||||
|
||||
// IF GLOBAL DAY VALUE IS > THAN DAYS IN MONTH, HIGHLIGHT LAST DAY IN MONTH
|
||||
if (day > days) {
|
||||
day = days;
|
||||
}
|
||||
|
||||
// DETERMINE WHAT DAY OF THE WEEK THE CALENDAR STARTS ON
|
||||
var firstOfMonth = new Date (year, month, 1);
|
||||
|
||||
// GET THE DAY OF THE WEEK THE FIRST DAY OF THE MONTH FALLS ON
|
||||
var startingPos = firstOfMonth.getDay();
|
||||
days += startingPos;
|
||||
|
||||
// KEEP TRACK OF THE COLUMNS, START A NEW ROW AFTER EVERY 7 COLUMNS
|
||||
var columnCount = 0;
|
||||
|
||||
// MAKE BEGINNING NON-DATE CELLS BLANK
|
||||
for (i = 0; i < startingPos; i++) {
|
||||
|
||||
calDoc += blankCell;
|
||||
columnCount++;
|
||||
}
|
||||
|
||||
// SET VALUES FOR DAYS OF THE MONTH
|
||||
var currentDay = 0;
|
||||
var dayType = "weekday";
|
||||
|
||||
// DATE CELLS CONTAIN A NUMBER
|
||||
for (i = startingPos; i < days; i++) {
|
||||
|
||||
var paddingChar = " ";
|
||||
|
||||
// ADJUST SPACING SO THAT ALL LINKS HAVE RELATIVELY EQUAL WIDTHS
|
||||
if (i-startingPos+1 < 10) {
|
||||
padding = " ";
|
||||
}
|
||||
else {
|
||||
padding = " ";
|
||||
}
|
||||
|
||||
// GET THE DAY CURRENTLY BEING WRITTEN
|
||||
currentDay = i-startingPos+1;
|
||||
|
||||
// SET THE TYPE OF DAY, THE focusDay GENERALLY APPEARS AS A DIFFERENT COLOR
|
||||
if (currentDay == day) {
|
||||
dayType = "focusDay";
|
||||
}
|
||||
else {
|
||||
dayType = "weekDay";
|
||||
}
|
||||
|
||||
// ADD THE DAY TO THE CALENDAR STRING
|
||||
calDoc += "<TD align=center bgcolor='" + cellColor + "'>" +
|
||||
"<a class='" + dayType + "' href='javascript:parent.opener.returnDate(" +
|
||||
currentDay + ")'>" + padding + currentDay + paddingChar + "</a></TD>";
|
||||
|
||||
columnCount++;
|
||||
|
||||
// START A NEW ROW WHEN NECESSARY
|
||||
if (columnCount % 7 == 0) {
|
||||
calDoc += "</TR><TR>";
|
||||
}
|
||||
}
|
||||
|
||||
// MAKE REMAINING NON-DATE CELLS BLANK
|
||||
for (i=days; i<42; i++) {
|
||||
|
||||
calDoc += blankCell;
|
||||
columnCount++;
|
||||
|
||||
// START A NEW ROW WHEN NECESSARY
|
||||
if (columnCount % 7 == 0) {
|
||||
calDoc += "</TR>";
|
||||
if (i<41) {
|
||||
calDoc += "<TR>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FINISH THE NEW CALENDAR PAGE
|
||||
calDoc += calendarEnd;
|
||||
|
||||
// RETURN THE COMPLETED CALENDAR PAGE
|
||||
return calDoc;
|
||||
}
|
||||
|
||||
|
||||
// WRITE THE MONTHLY CALENDAR TO THE BOTTOM CALENDAR FRAME
|
||||
function writeCalendar() {
|
||||
// CREATE THE NEW CALENDAR FOR THE SELECTED MONTH & YEAR
|
||||
calDocBottom = buildBottomCalFrame();
|
||||
|
||||
if (document.getElementById) { // ns6 & ie
|
||||
top.newWin.frames['bottomCalFrame'].document.getElementById('bottomDiv').innerHTML = calDocBottom;
|
||||
} else {
|
||||
// WRITE THE NEW CALENDAR TO THE BOTTOM FRAME
|
||||
top.newWin.frames['bottomCalFrame'].document.open();
|
||||
top.newWin.frames['bottomCalFrame'].document.write(calDocBottom);
|
||||
top.newWin.frames['bottomCalFrame'].document.close();
|
||||
}
|
||||
}
|
||||
|
||||
// SET THE CALENDAR TO TODAY'S DATE AND DISPLAY THE NEW CALENDAR
|
||||
function setToday() {
|
||||
|
||||
// SET GLOBAL DATE TO TODAY'S DATE
|
||||
calDate = new Date();
|
||||
|
||||
// SET DAY MONTH AND YEAR TO TODAY'S DATE
|
||||
var month = calDate.getMonth();
|
||||
var year = calDate.getFullYear();
|
||||
|
||||
// SET MONTH IN DROP-DOWN LIST
|
||||
top.newWin.frames['topCalFrame'].document.calControl.month.selectedIndex = month;
|
||||
|
||||
// SET YEAR VALUE
|
||||
top.newWin.frames['topCalFrame'].document.calControl.year.value = year;
|
||||
|
||||
// SET THE DAY VALUE
|
||||
calDay = calDate.getDate();
|
||||
|
||||
// DISPLAY THE NEW CALENDAR
|
||||
writeCalendar();
|
||||
}
|
||||
|
||||
|
||||
// SET THE GLOBAL DATE TO THE NEWLY ENTERED YEAR AND REDRAW THE CALENDAR
|
||||
function setYear() {
|
||||
|
||||
// GET THE NEW YEAR VALUE
|
||||
var year = top.newWin.frames['topCalFrame'].document.calControl.year.value;
|
||||
|
||||
// IF IT'S A FOUR-DIGIT YEAR THEN CHANGE THE CALENDAR
|
||||
if (isFourDigitYear(year)) {
|
||||
calDate.setFullYear(year);
|
||||
writeCalendar();
|
||||
top.newWin.frames['topCalFrame'].document.calControl.year.blur();
|
||||
}
|
||||
else {
|
||||
// HIGHLIGHT THE YEAR IF THE YEAR IS NOT FOUR DIGITS IN LENGTH
|
||||
top.newWin.frames['topCalFrame'].document.calControl.year.focus();
|
||||
top.newWin.frames['topCalFrame'].document.calControl.year.select();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// SET THE GLOBAL DATE TO THE SELECTED MONTH AND REDRAW THE CALENDAR
|
||||
function setCurrentMonth() {
|
||||
|
||||
// GET THE NEWLY SELECTED MONTH AND CHANGE THE CALENDAR ACCORDINGLY
|
||||
var month = top.newWin.frames['topCalFrame'].document.calControl.month.selectedIndex;
|
||||
|
||||
calDate.setMonth(month);
|
||||
writeCalendar();
|
||||
}
|
||||
|
||||
|
||||
// SET THE GLOBAL DATE TO THE PREVIOUS YEAR AND REDRAW THE CALENDAR
|
||||
function setPreviousYear() {
|
||||
|
||||
var year = top.newWin.frames['topCalFrame'].document.calControl.year.value;
|
||||
|
||||
if (isFourDigitYear(year) && year > 1000) {
|
||||
year--;
|
||||
calDate.setFullYear(year);
|
||||
top.newWin.frames['topCalFrame'].document.calControl.year.value = year;
|
||||
writeCalendar();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// SET THE GLOBAL DATE TO THE PREVIOUS MONTH AND REDRAW THE CALENDAR
|
||||
function setPreviousMonth() {
|
||||
|
||||
var year = top.newWin.frames['topCalFrame'].document.calControl.year.value;
|
||||
if (isFourDigitYear(year)) {
|
||||
var month = top.newWin.frames['topCalFrame'].document.calControl.month.selectedIndex;
|
||||
|
||||
// IF MONTH IS JANUARY, SET MONTH TO DECEMBER AND DECREMENT THE YEAR
|
||||
if (month == 0) {
|
||||
month = 11;
|
||||
if (year > 1000) {
|
||||
year--;
|
||||
calDate.setFullYear(year);
|
||||
top.newWin.frames['topCalFrame'].document.calControl.year.value = year;
|
||||
}
|
||||
}
|
||||
else {
|
||||
month--;
|
||||
}
|
||||
calDate.setMonth(month);
|
||||
top.newWin.frames['topCalFrame'].document.calControl.month.selectedIndex = month;
|
||||
writeCalendar();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// SET THE GLOBAL DATE TO THE NEXT MONTH AND REDRAW THE CALENDAR
|
||||
function setNextMonth() {
|
||||
|
||||
var year = top.newWin.frames['topCalFrame'].document.calControl.year.value;
|
||||
|
||||
if (isFourDigitYear(year)) {
|
||||
var month = top.newWin.frames['topCalFrame'].document.calControl.month.selectedIndex;
|
||||
|
||||
// IF MONTH IS DECEMBER, SET MONTH TO JANUARY AND INCREMENT THE YEAR
|
||||
if (month == 11) {
|
||||
month = 0;
|
||||
year++;
|
||||
calDate.setFullYear(year);
|
||||
top.newWin.frames['topCalFrame'].document.calControl.year.value = year;
|
||||
}
|
||||
else {
|
||||
month++;
|
||||
}
|
||||
calDate.setMonth(month);
|
||||
top.newWin.frames['topCalFrame'].document.calControl.month.selectedIndex = month;
|
||||
writeCalendar();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// SET THE GLOBAL DATE TO THE NEXT YEAR AND REDRAW THE CALENDAR
|
||||
function setNextYear() {
|
||||
|
||||
var year = top.newWin.frames['topCalFrame'].document.calControl.year.value;
|
||||
if (isFourDigitYear(year)) {
|
||||
year++;
|
||||
calDate.setFullYear(year);
|
||||
top.newWin.frames['topCalFrame'].document.calControl.year.value = year;
|
||||
writeCalendar();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// GET NUMBER OF DAYS IN MONTH
|
||||
function getDaysInMonth() {
|
||||
|
||||
var days;
|
||||
var month = calDate.getMonth()+1;
|
||||
var year = calDate.getFullYear();
|
||||
|
||||
// RETURN 31 DAYS
|
||||
if (month==1 || month==3 || month==5 || month==7 || month==8 ||
|
||||
month==10 || month==12) {
|
||||
days=31;
|
||||
}
|
||||
// RETURN 30 DAYS
|
||||
else if (month==4 || month==6 || month==9 || month==11) {
|
||||
days=30;
|
||||
}
|
||||
// RETURN 29 DAYS
|
||||
else if (month==2) {
|
||||
if (isLeapYear(year)) {
|
||||
days=29;
|
||||
}
|
||||
// RETURN 28 DAYS
|
||||
else {
|
||||
days=28;
|
||||
}
|
||||
}
|
||||
return (days);
|
||||
}
|
||||
|
||||
|
||||
// CHECK TO SEE IF YEAR IS A LEAP YEAR
|
||||
function isLeapYear (Year) {
|
||||
|
||||
if (((Year % 4)==0) && ((Year % 100)!=0) || ((Year % 400)==0)) {
|
||||
return (true);
|
||||
}
|
||||
else {
|
||||
return (false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ENSURE THAT THE YEAR IS FOUR DIGITS IN LENGTH
|
||||
function isFourDigitYear(year) {
|
||||
|
||||
if (year == null || year.match(/^[0-9]{4}$/) == null){
|
||||
top.newWin.frames['topCalFrame'].document.calControl.year.value = calDate.getFullYear();
|
||||
top.newWin.frames['topCalFrame'].document.calControl.year.select();
|
||||
top.newWin.frames['topCalFrame'].document.calControl.year.focus();
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// BUILD THE MONTH SELECT LIST
|
||||
function getMonthSelect() {
|
||||
|
||||
monthArray = new Array(L_January, L_February, L_March, L_April, L_May, L_June,
|
||||
L_July, L_August, L_September, L_October, L_November, L_December);
|
||||
|
||||
|
||||
// DETERMINE MONTH TO SET AS DEFAULT
|
||||
var activeMonth = calDate.getMonth();
|
||||
|
||||
// START HTML SELECT LIST ELEMENT
|
||||
monthSelect = "<SELECT NAME='month' onChange='parent.opener.setCurrentMonth()'>";
|
||||
|
||||
// LOOP THROUGH MONTH ARRAY
|
||||
for (i in monthArray) {
|
||||
|
||||
// SHOW THE CORRECT MONTH IN THE SELECT LIST
|
||||
if (i == activeMonth) {
|
||||
monthSelect += "<OPTION SELECTED>" + monthArray[i] + "\n";
|
||||
}
|
||||
else {
|
||||
monthSelect += "<OPTION>" + monthArray[i] + "\n";
|
||||
}
|
||||
}
|
||||
monthSelect += "</SELECT>";
|
||||
|
||||
// RETURN A STRING VALUE WHICH CONTAINS A SELECT LIST OF ALL 12 MONTHS
|
||||
return monthSelect;
|
||||
}
|
||||
|
||||
|
||||
// SET DAYS OF THE WEEK DEPENDING ON LANGUAGE
|
||||
function createWeekdayList() {
|
||||
|
||||
weekdayArray = new Array(L_Su,L_Mo,L_Tu,L_We,L_Th,L_Fr,L_Sa);
|
||||
|
||||
|
||||
// START HTML TO HOLD WEEKDAY NAMES IN TABLE FORMAT
|
||||
var weekdays = "<TR BGCOLOR='" + headingCellColor + "'>";
|
||||
|
||||
// LOOP THROUGH WEEKDAY ARRAY
|
||||
for (i in weekdayArray) {
|
||||
|
||||
weekdays += "<TD class='heading' align=center>" + weekdayArray[i] + "</TD>";
|
||||
}
|
||||
weekdays += "</TR>";
|
||||
|
||||
// RETURN TABLE ROW OF WEEKDAY ABBREVIATIONS TO DISPLAY ABOVE THE CALENDAR
|
||||
return weekdays;
|
||||
}
|
||||
|
||||
|
||||
// PRE-BUILD PORTIONS OF THE CALENDAR (FOR PERFORMANCE REASONS)
|
||||
function buildCalParts() {
|
||||
|
||||
// GENERATE WEEKDAY HEADERS FOR THE CALENDAR
|
||||
weekdays = createWeekdayList();
|
||||
|
||||
// BUILD THE BLANK CELL ROWS
|
||||
blankCell = "<TD align=center bgcolor='" + cellColor + "'> </TD>";
|
||||
|
||||
// BUILD THE TOP PORTION OF THE CALENDAR PAGE USING CSS TO CONTROL SOME DISPLAY ELEMENTS
|
||||
calendarBegin =
|
||||
"<HTML>" +
|
||||
"<HEAD>" +
|
||||
// STYLESHEET DEFINES APPEARANCE OF CALENDAR
|
||||
"<STYLE type='text/css'>" +
|
||||
"<!--" +
|
||||
"TD.heading { text-decoration: none; color:" + headingTextColor + "; font: " + headingFontStyle + "; }" +
|
||||
"A.focusDay:link { color: " + focusColor + "; text-decoration: none; font: " + fontStyle + "; }" +
|
||||
"A.focusDay:hover { color: " + focusColor + "; text-decoration: none; font: " + fontStyle + "; }" +
|
||||
"A.focusDay:visited { color: " + focusColor + "; text-decoration: none; font: " + fontStyle + "; }" +
|
||||
"A.weekday:link { color: " + dateColor + "; text-decoration: none; font: " + fontStyle + "; }" +
|
||||
"A.weekday:hover { color: " + hoverColor + "; font: " + fontStyle + "; }" +
|
||||
"A.weekday:visited { color: " + dateColor + "; text-decoration: none; font: " + fontStyle + "; }" +
|
||||
"-->" +
|
||||
"</STYLE>" +
|
||||
|
||||
"</HEAD>" +
|
||||
"<BODY BGCOLOR='" + bottomBackground + "' onload='javascript:self.focus()'>";
|
||||
if (document.getElementById) { // ns6 & ie
|
||||
calendarBegin +=
|
||||
"<DIV ID='bottomDiv'>";
|
||||
}
|
||||
calendarBegin +=
|
||||
"<CENTER>";
|
||||
|
||||
// NAVIGATOR NEEDS A TABLE CONTAINER TO DISPLAY THE TABLE OUTLINES PROPERLY
|
||||
if (isNav) {
|
||||
calendarBegin +=
|
||||
"<TABLE CELLPADDING=0 CELLSPACING=1 BORDER=" + tableBorder + " ALIGN=CENTER BGCOLOR='" + tableBGColor + "'><TR><TD>";
|
||||
}
|
||||
|
||||
// BUILD WEEKDAY HEADINGS
|
||||
calendarBegin +=
|
||||
"<TABLE CELLPADDING=0 CELLSPACING=1 BORDER=" + tableBorder + " ALIGN=CENTER BGCOLOR='" + tableBGColor + "'>" +
|
||||
weekdays +
|
||||
"<TR>";
|
||||
|
||||
|
||||
// BUILD THE BOTTOM PORTION OF THE CALENDAR PAGE
|
||||
calendarEnd = "";
|
||||
|
||||
// WHETHER OR NOT TO DISPLAY A THICK LINE BELOW THE CALENDAR
|
||||
if (bottomBorder) {
|
||||
calendarEnd += "<TR></TR>";
|
||||
}
|
||||
|
||||
// NAVIGATOR NEEDS A TABLE CONTAINER TO DISPLAY THE BORDERS PROPERLY
|
||||
if (isNav) {
|
||||
calendarEnd += "</TD></TR></TABLE>";
|
||||
}
|
||||
|
||||
// END THE TABLE AND HTML DOCUMENT
|
||||
calendarEnd +=
|
||||
"</TABLE>" +
|
||||
"</CENTER>";
|
||||
if (document.getElementById) { // ns6 & ie
|
||||
calendarEnd +=
|
||||
"</DIV>";
|
||||
}
|
||||
calendarEnd +=
|
||||
"</BODY>" +
|
||||
"</HTML>";
|
||||
}
|
||||
|
||||
|
||||
// REPLACE ALL INSTANCES OF find WITH replace
|
||||
// inString: the string you want to convert
|
||||
// find: the value to search for
|
||||
// replace: the value to substitute
|
||||
//
|
||||
// usage: jsReplace(inString, find, replace);
|
||||
// example: jsReplace("To be or not to be", "be", "ski");
|
||||
// result: "To ski or not to ski"
|
||||
//
|
||||
function jsReplace(inString, find, replace) {
|
||||
|
||||
var outString = "";
|
||||
|
||||
if (!inString) {
|
||||
return "";
|
||||
}
|
||||
|
||||
// REPLACE ALL INSTANCES OF find WITH replace
|
||||
if (inString.indexOf(find) != -1) {
|
||||
// SEPARATE THE STRING INTO AN ARRAY OF STRINGS USING THE VALUE IN find
|
||||
t = inString.split(find);
|
||||
|
||||
// JOIN ALL ELEMENTS OF THE ARRAY, SEPARATED BY THE VALUE IN replace
|
||||
return (t.join(replace));
|
||||
}
|
||||
else {
|
||||
return inString;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// JAVASCRIPT FUNCTION -- DOES NOTHING (USED FOR THE HREF IN THE CALENDAR CALL)
|
||||
function doNothing() {
|
||||
}
|
||||
|
||||
|
||||
// ENSURE THAT VALUE IS TWO DIGITS IN LENGTH
|
||||
function makeTwoDigit(inValue) {
|
||||
|
||||
var numVal = parseInt(inValue, 10);
|
||||
|
||||
// VALUE IS LESS THAN TWO DIGITS IN LENGTH
|
||||
if (numVal < 10) {
|
||||
|
||||
// ADD A LEADING ZERO TO THE VALUE AND RETURN IT
|
||||
return("0" + numVal);
|
||||
}
|
||||
else {
|
||||
return numVal;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// SET FIELD VALUE TO THE DATE SELECTED AND CLOSE THE CALENDAR WINDOW
|
||||
function returnDate(inDay)
|
||||
{
|
||||
// inDay = THE DAY THE USER CLICKED ON
|
||||
calDate.setDate(inDay);
|
||||
|
||||
// SET THE DATE RETURNED TO THE USER
|
||||
var day = calDate.getDate();
|
||||
var month = calDate.getMonth()+1;
|
||||
var year = calDate.getFullYear();
|
||||
|
||||
if ( DateTimeFormat == true )
|
||||
outDate = "DateTime(";
|
||||
else
|
||||
outDate = "Date(";
|
||||
|
||||
outDate += year + ",";
|
||||
outDate += month + ",";
|
||||
outDate += day;
|
||||
|
||||
if ( DateTimeFormat == true ) {
|
||||
outDate += ",";
|
||||
outDate += gHour + ","; gHour = "0";
|
||||
outDate += gMin + ","; gMin = "0";
|
||||
outDate += gSec; gSec = "0";
|
||||
}
|
||||
outDate += ")";
|
||||
|
||||
// SET THE VALUE OF THE FIELD THAT WAS PASSED TO THE CALENDAR
|
||||
calDateField.value = outDate;
|
||||
|
||||
// GIVE FOCUS BACK TO THE DATE FIELD
|
||||
calDateField.focus();
|
||||
|
||||
// CLOSE THE CALENDAR WINDOW
|
||||
top.newWin.close()
|
||||
}
|
||||
|
||||
var gHour = "0";
|
||||
var gMin = "0";
|
||||
var gSec = "0";
|
||||
var regDateTimePrompt = /^(D|d)(A|a)(T|t)(E|e)(T|t)(I|i)(M|m)(E|e) *\( *\d{4} *, *(0?[1-9]|1[0-2]) *, *((0?[1-9]|[1-2]\d)|3(0|1)) *, *([0-1]?\d|2[0-3]) *, *[0-5]?\d *, *[0-5]?\d *\)$/
|
||||
function ParseDateTimePrompt(inDate)
|
||||
{
|
||||
if ( regDateTimePrompt.test ( inDate ) )
|
||||
{
|
||||
var sDate = inDate.substr ( inDate.indexOf("(")+1 ); //move past "DateTime ("
|
||||
sDate = sDate.substr ( 0, sDate.lastIndexOf(")") ); //remove trailing ")"
|
||||
var dateArray = sDate.split (',');
|
||||
var _date = new Date ( dateArray[0], Number(dateArray[1]) - 1, dateArray[2] );
|
||||
gHour = dateArray[3]; gMin = dateArray[4]; gSec = dateArray[5];
|
||||
return _date;
|
||||
}
|
||||
return new Date ();
|
||||
}
|
||||
|
||||
var regDatePrompt = /^(D|d)(A|a)(T|t)(E|e) *\( *\d{4} *, *(0?[1-9]|1[0-2]) *, *((0?[1-9]|[1-2]\d)|3(0|1)) *\)$/
|
||||
function ParseDatePrompt(inDate)
|
||||
{
|
||||
if ( regDatePrompt.test ( inDate ) )
|
||||
{
|
||||
var sDate = inDate.substr ( inDate.indexOf("(")+1 ); //move past "Date ("
|
||||
sDate = sDate.substr ( 0, sDate.lastIndexOf(")") ); //remove trailing ")"
|
||||
var dateArray = sDate.split (',');
|
||||
return new Date ( dateArray[0], Number(dateArray[1]) - 1, dateArray[2] );
|
||||
}
|
||||
return new Date();
|
||||
}
|
||||
|
||||
function ParseDate(inDate, bDateTimeFormat)
|
||||
{
|
||||
var result;
|
||||
|
||||
if (bDateTimeFormat == true) {
|
||||
result = ParseDateTimePrompt(inDate);
|
||||
} else {
|
||||
result = ParseDatePrompt(inDate);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
704
crystalreportviewers13/js/calendar_param.js
Normal file
@@ -0,0 +1,704 @@
|
||||
// Modified Date: 11/30/1999
|
||||
// Modified By: Robert W. Husted
|
||||
// Notes: Added frameset support (changed reference for "newWin" to "top.newWin")
|
||||
// Also changed Spanish "March" from "Marcha" to "Marzo"
|
||||
// Fixed JavaScript Date Anomaly affecting days > 28
|
||||
//
|
||||
// Modified by Crystal Decisions
|
||||
// Removed large amounts of comments to shrink file size.
|
||||
// Removed multi language support as language set by user as accept-language and navigator.language don't necessarily match
|
||||
// Removed formatting code as only format wanted is for Crystal Reports Date/DateTime parameters
|
||||
// Moved resource strings to top of file for translation
|
||||
// Added A.whatever:visited styles so that followed links appear as if they weren't followed
|
||||
|
||||
|
||||
// BEGIN USER-EDITABLE SECTION -----------------------------------------------------
|
||||
|
||||
// CALENDAR COLORS
|
||||
topBackground = "black"; // BG COLOR OF THE TOP FRAME
|
||||
bottomBackground = "white"; // BG COLOR OF THE BOTTOM FRAME
|
||||
tableBGColor = "black"; // BG COLOR OF THE BOTTOM FRAME'S TABLE
|
||||
cellColor = "lightgrey"; // TABLE CELL BG COLOR OF THE DATE CELLS IN THE BOTTOM FRAME
|
||||
headingCellColor = "white"; // TABLE CELL BG COLOR OF THE WEEKDAY ABBREVIATIONS
|
||||
headingTextColor = "black"; // TEXT COLOR OF THE WEEKDAY ABBREVIATIONS
|
||||
dateColor = "blue"; // TEXT COLOR OF THE LISTED DATES (1-28+)
|
||||
focusColor = "#ff0000"; // TEXT COLOR OF THE SELECTED DATE (OR CURRENT DATE)
|
||||
hoverColor = "darkred"; // TEXT COLOR OF A LINK WHEN YOU HOVER OVER IT
|
||||
fontStyle = "12pt arial, helvetica"; // TEXT STYLE FOR DATES
|
||||
headingFontStyle = "bold 12pt arial, helvetica"; // TEXT STYLE FOR WEEKDAY ABBREVIATIONS
|
||||
|
||||
// FORMATTING PREFERENCES
|
||||
bottomBorder = false; // TRUE/FALSE (WHETHER TO DISPLAY BOTTOM CALENDAR BORDER)
|
||||
tableBorder = 0; // SIZE OF CALENDAR TABLE BORDER (BOTTOM FRAME) 0=none
|
||||
|
||||
var DateTimeFormat = true; //"DateTime" if true, else a "Date"
|
||||
|
||||
// END USER-EDITABLE SECTION -------------------------------------------------------
|
||||
|
||||
// DETERMINE BROWSER BRAND
|
||||
var isNav = false;
|
||||
var isIE = false;
|
||||
|
||||
// ASSUME IT'S EITHER NETSCAPE OR MSIE
|
||||
if (navigator.appName == "Netscape") {
|
||||
isNav = true;
|
||||
}
|
||||
else {
|
||||
isIE = true;
|
||||
}
|
||||
|
||||
// global variable for top frame and bottom frame
|
||||
var calDocTop;
|
||||
var calDocBottom;
|
||||
|
||||
// PRE-BUILD PORTIONS OF THE CALENDAR WHEN THIS JS LIBRARY LOADS INTO THE BROWSER
|
||||
buildCalParts();
|
||||
|
||||
// CALENDAR FUNCTIONS BEGIN HERE ---------------------------------------------------
|
||||
|
||||
// SET THE INITIAL VALUE OF THE GLOBAL DATE FIELD
|
||||
function setDateField(formName, dateField, hiddenField) {
|
||||
|
||||
// ASSIGN THE INCOMING FIELD OBJECT TO A GLOBAL VARIABLE
|
||||
thisform = document.forms[formName];
|
||||
calDateField = thisform[dateField];
|
||||
calHiddenField = thisform[hiddenField];
|
||||
|
||||
// GET THE VALUE OF THE INCOMING FIELD
|
||||
inDate = thisform[hiddenField].value;
|
||||
|
||||
// SET calDate TO THE DATE IN THE INCOMING FIELD OR DEFAULT TO TODAY'S DATE
|
||||
setInitialDate();
|
||||
|
||||
// THE CALENDAR FRAMESET DOCUMENTS ARE CREATED BY JAVASCRIPT FUNCTIONS
|
||||
calDocTop = buildTopCalFrame();
|
||||
calDocBottom = buildBottomCalFrame();
|
||||
}
|
||||
|
||||
|
||||
// SET THE INITIAL CALENDAR DATE TO TODAY OR TO THE EXISTING VALUE IN dateField
|
||||
function setInitialDate() {
|
||||
|
||||
calDate = ParseDate(inDate, DateTimeFormat);
|
||||
|
||||
// IF THE INCOMING DATE IS INVALID, USE THE CURRENT DATE
|
||||
if (isNaN(calDate)) {
|
||||
|
||||
// ADD CUSTOM DATE PARSING HERE
|
||||
// IF IT FAILS, SIMPLY CREATE A NEW DATE OBJECT WHICH DEFAULTS TO THE CURRENT DATE
|
||||
calDate = new Date();
|
||||
}
|
||||
|
||||
// KEEP TRACK OF THE CURRENT DAY VALUE
|
||||
calDay = calDate.getDate();
|
||||
|
||||
// SET DAY VALUE TO 1... TO AVOID JAVASCRIPT DATE CALCULATION ANOMALIES
|
||||
// (IF THE MONTH CHANGES TO FEB AND THE DAY IS 30, THE MONTH WOULD CHANGE TO MARCH
|
||||
// AND THE DAY WOULD CHANGE TO 2. SETTING THE DAY TO 1 WILL PREVENT THAT)
|
||||
calDate.setDate(1);
|
||||
}
|
||||
|
||||
// CREATE THE TOP CALENDAR FRAME
|
||||
function buildTopCalFrame() {
|
||||
|
||||
// CREATE THE TOP FRAME OF THE CALENDAR
|
||||
var calDoc =
|
||||
"<HTML>" +
|
||||
"<HEAD>" +
|
||||
"</HEAD>" +
|
||||
"<BODY BGCOLOR='" + topBackground + "'>" +
|
||||
"<FORM NAME='calControl' onSubmit='return false;'>" +
|
||||
"<CENTER>" +
|
||||
"<TABLE CELLPADDING=0 CELLSPACING=1 BORDER=0 WIDTH=100%>" +
|
||||
"<TR><TD COLSPAN=7>" +
|
||||
"<CENTER>" +
|
||||
getMonthSelect() +
|
||||
"<INPUT NAME='year' VALUE='" + calDate.getFullYear() + "'TYPE=TEXT SIZE=4 MAXLENGTH=4 onKeyDown='parent.opener.keydownfn(event, \"setYear\", \"\");' onChange='parent.opener.setYear()'>" +
|
||||
"</CENTER>" +
|
||||
"</TD>" +
|
||||
"</TR>" +
|
||||
"<TR>" +
|
||||
"<TD COLSPAN=7>" +
|
||||
"<CENTER>" +
|
||||
"<INPUT " +
|
||||
"TYPE=BUTTON NAME='previousYear' VALUE='<<' onClick='parent.opener.setPreviousYear()'><INPUT " +
|
||||
"TYPE=BUTTON NAME='previousMonth' VALUE=' < ' onClick='parent.opener.setPreviousMonth()'><INPUT " +
|
||||
"TYPE=BUTTON NAME='today' VALUE=\"" + L_Today + "\" onClick='parent.opener.setToday()'><INPUT " +
|
||||
"TYPE=BUTTON NAME='nextMonth' VALUE=' > ' onClick='parent.opener.setNextMonth()'><INPUT " +
|
||||
"TYPE=BUTTON NAME='nextYear' VALUE='>>' onClick='parent.opener.setNextYear()'>" +
|
||||
"</CENTER>" +
|
||||
"</TD>" +
|
||||
"</TR>" +
|
||||
"</TABLE>" +
|
||||
"</CENTER>" +
|
||||
"</FORM>" +
|
||||
"</BODY>" +
|
||||
"</HTML>";
|
||||
|
||||
return calDoc;
|
||||
}
|
||||
|
||||
// CREATE THE BOTTOM CALENDAR FRAME
|
||||
// (THE MONTHLY CALENDAR)
|
||||
function buildBottomCalFrame() {
|
||||
// START CALENDAR DOCUMENT
|
||||
var calDoc = calendarBegin;
|
||||
|
||||
// GET MONTH, AND YEAR FROM GLOBAL CALENDAR DATE
|
||||
month = calDate.getMonth();
|
||||
year = calDate.getFullYear();
|
||||
|
||||
|
||||
// GET GLOBALLY-TRACKED DAY VALUE (PREVENTS JAVASCRIPT DATE ANOMALIES)
|
||||
day = calDay;
|
||||
|
||||
var i = 0;
|
||||
|
||||
// DETERMINE THE NUMBER OF DAYS IN THE CURRENT MONTH
|
||||
var days = getDaysInMonth();
|
||||
|
||||
// IF GLOBAL DAY VALUE IS > THAN DAYS IN MONTH, HIGHLIGHT LAST DAY IN MONTH
|
||||
if (day > days) {
|
||||
day = days;
|
||||
}
|
||||
|
||||
// DETERMINE WHAT DAY OF THE WEEK THE CALENDAR STARTS ON
|
||||
var firstOfMonth = new Date (year, month, 1);
|
||||
|
||||
// GET THE DAY OF THE WEEK THE FIRST DAY OF THE MONTH FALLS ON
|
||||
var startingPos = firstOfMonth.getDay();
|
||||
days += startingPos;
|
||||
|
||||
// KEEP TRACK OF THE COLUMNS, START A NEW ROW AFTER EVERY 7 COLUMNS
|
||||
var columnCount = 0;
|
||||
|
||||
// MAKE BEGINNING NON-DATE CELLS BLANK
|
||||
for (i = 0; i < startingPos; i++) {
|
||||
|
||||
calDoc += blankCell;
|
||||
columnCount++;
|
||||
}
|
||||
|
||||
// SET VALUES FOR DAYS OF THE MONTH
|
||||
var currentDay = 0;
|
||||
var dayType = "weekday";
|
||||
|
||||
// DATE CELLS CONTAIN A NUMBER
|
||||
for (i = startingPos; i < days; i++) {
|
||||
|
||||
var paddingChar = " ";
|
||||
|
||||
// ADJUST SPACING SO THAT ALL LINKS HAVE RELATIVELY EQUAL WIDTHS
|
||||
if (i-startingPos+1 < 10) {
|
||||
padding = " ";
|
||||
}
|
||||
else {
|
||||
padding = " ";
|
||||
}
|
||||
|
||||
// GET THE DAY CURRENTLY BEING WRITTEN
|
||||
currentDay = i-startingPos+1;
|
||||
|
||||
// SET THE TYPE OF DAY, THE focusDay GENERALLY APPEARS AS A DIFFERENT COLOR
|
||||
if (currentDay == day) {
|
||||
dayType = "focusDay";
|
||||
}
|
||||
else {
|
||||
dayType = "weekDay";
|
||||
}
|
||||
|
||||
// ADD THE DAY TO THE CALENDAR STRING
|
||||
calDoc += "<TD align=center bgcolor='" + cellColor + "'>" +
|
||||
"<a class='" + dayType + "' href='javascript:parent.opener.returnDate(" +
|
||||
currentDay + ")'>" + padding + currentDay + paddingChar + "</a></TD>";
|
||||
|
||||
columnCount++;
|
||||
|
||||
// START A NEW ROW WHEN NECESSARY
|
||||
if (columnCount % 7 == 0) {
|
||||
calDoc += "</TR><TR>";
|
||||
}
|
||||
}
|
||||
|
||||
// MAKE REMAINING NON-DATE CELLS BLANK
|
||||
for (i=days; i<42; i++) {
|
||||
|
||||
calDoc += blankCell;
|
||||
columnCount++;
|
||||
|
||||
// START A NEW ROW WHEN NECESSARY
|
||||
if (columnCount % 7 == 0) {
|
||||
calDoc += "</TR>";
|
||||
if (i<41) {
|
||||
calDoc += "<TR>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FINISH THE NEW CALENDAR PAGE
|
||||
calDoc += calendarEnd;
|
||||
|
||||
// RETURN THE COMPLETED CALENDAR PAGE
|
||||
return calDoc;
|
||||
}
|
||||
|
||||
|
||||
// WRITE THE MONTHLY CALENDAR TO THE BOTTOM CALENDAR FRAME
|
||||
function writeCalendar() {
|
||||
// CREATE THE NEW CALENDAR FOR THE SELECTED MONTH & YEAR
|
||||
calDocBottom = buildBottomCalFrame();
|
||||
|
||||
if (document.getElementById) { // ns6 & ie
|
||||
top.newWin.frames['bottomCalFrame'].document.getElementById('bottomDiv').innerHTML = calDocBottom;
|
||||
} else {
|
||||
// WRITE THE NEW CALENDAR TO THE BOTTOM FRAME
|
||||
top.newWin.frames['bottomCalFrame'].document.open();
|
||||
top.newWin.frames['bottomCalFrame'].document.write(calDocBottom);
|
||||
top.newWin.frames['bottomCalFrame'].document.close();
|
||||
}
|
||||
}
|
||||
|
||||
// SET THE CALENDAR TO TODAY'S DATE AND DISPLAY THE NEW CALENDAR
|
||||
function setToday() {
|
||||
|
||||
// SET GLOBAL DATE TO TODAY'S DATE
|
||||
calDate = new Date();
|
||||
|
||||
// SET DAY MONTH AND YEAR TO TODAY'S DATE
|
||||
var month = calDate.getMonth();
|
||||
var year = calDate.getFullYear();
|
||||
|
||||
// SET MONTH IN DROP-DOWN LIST
|
||||
top.newWin.frames['topCalFrame'].document.calControl.month.selectedIndex = month;
|
||||
|
||||
// SET YEAR VALUE
|
||||
top.newWin.frames['topCalFrame'].document.calControl.year.value = year;
|
||||
|
||||
// SET THE DAY VALUE
|
||||
calDay = calDate.getDate();
|
||||
|
||||
// DISPLAY THE NEW CALENDAR
|
||||
writeCalendar();
|
||||
}
|
||||
|
||||
|
||||
// SET THE GLOBAL DATE TO THE NEWLY ENTERED YEAR AND REDRAW THE CALENDAR
|
||||
function setYear() {
|
||||
|
||||
// GET THE NEW YEAR VALUE
|
||||
var year = top.newWin.frames['topCalFrame'].document.calControl.year.value;
|
||||
|
||||
// IF IT'S A FOUR-DIGIT YEAR THEN CHANGE THE CALENDAR
|
||||
if (isFourDigitYear(year)) {
|
||||
calDate.setFullYear(year);
|
||||
writeCalendar();
|
||||
top.newWin.frames['topCalFrame'].document.calControl.year.blur();
|
||||
}
|
||||
else {
|
||||
// HIGHLIGHT THE YEAR IF THE YEAR IS NOT FOUR DIGITS IN LENGTH
|
||||
top.newWin.frames['topCalFrame'].document.calControl.year.focus();
|
||||
top.newWin.frames['topCalFrame'].document.calControl.year.select();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// SET THE GLOBAL DATE TO THE SELECTED MONTH AND REDRAW THE CALENDAR
|
||||
function setCurrentMonth() {
|
||||
|
||||
// GET THE NEWLY SELECTED MONTH AND CHANGE THE CALENDAR ACCORDINGLY
|
||||
var month = top.newWin.frames['topCalFrame'].document.calControl.month.selectedIndex;
|
||||
|
||||
calDate.setMonth(month);
|
||||
writeCalendar();
|
||||
}
|
||||
|
||||
|
||||
// SET THE GLOBAL DATE TO THE PREVIOUS YEAR AND REDRAW THE CALENDAR
|
||||
function setPreviousYear() {
|
||||
|
||||
var year = top.newWin.frames['topCalFrame'].document.calControl.year.value;
|
||||
|
||||
if (isFourDigitYear(year) && year > 1000) {
|
||||
year--;
|
||||
calDate.setFullYear(year);
|
||||
top.newWin.frames['topCalFrame'].document.calControl.year.value = year;
|
||||
writeCalendar();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// SET THE GLOBAL DATE TO THE PREVIOUS MONTH AND REDRAW THE CALENDAR
|
||||
function setPreviousMonth() {
|
||||
|
||||
var year = top.newWin.frames['topCalFrame'].document.calControl.year.value;
|
||||
if (isFourDigitYear(year)) {
|
||||
var month = top.newWin.frames['topCalFrame'].document.calControl.month.selectedIndex;
|
||||
|
||||
// IF MONTH IS JANUARY, SET MONTH TO DECEMBER AND DECREMENT THE YEAR
|
||||
if (month == 0) {
|
||||
month = 11;
|
||||
if (year > 1000) {
|
||||
year--;
|
||||
calDate.setFullYear(year);
|
||||
top.newWin.frames['topCalFrame'].document.calControl.year.value = year;
|
||||
}
|
||||
}
|
||||
else {
|
||||
month--;
|
||||
}
|
||||
calDate.setMonth(month);
|
||||
top.newWin.frames['topCalFrame'].document.calControl.month.selectedIndex = month;
|
||||
writeCalendar();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// SET THE GLOBAL DATE TO THE NEXT MONTH AND REDRAW THE CALENDAR
|
||||
function setNextMonth() {
|
||||
|
||||
var year = top.newWin.frames['topCalFrame'].document.calControl.year.value;
|
||||
|
||||
if (isFourDigitYear(year)) {
|
||||
var month = top.newWin.frames['topCalFrame'].document.calControl.month.selectedIndex;
|
||||
|
||||
// IF MONTH IS DECEMBER, SET MONTH TO JANUARY AND INCREMENT THE YEAR
|
||||
if (month == 11) {
|
||||
month = 0;
|
||||
year++;
|
||||
calDate.setFullYear(year);
|
||||
top.newWin.frames['topCalFrame'].document.calControl.year.value = year;
|
||||
}
|
||||
else {
|
||||
month++;
|
||||
}
|
||||
calDate.setMonth(month);
|
||||
top.newWin.frames['topCalFrame'].document.calControl.month.selectedIndex = month;
|
||||
writeCalendar();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// SET THE GLOBAL DATE TO THE NEXT YEAR AND REDRAW THE CALENDAR
|
||||
function setNextYear() {
|
||||
var year = top.newWin.frames['topCalFrame'].document.calControl.year.value;
|
||||
if (isFourDigitYear(year)) {
|
||||
year++;
|
||||
calDate.setFullYear(year);
|
||||
top.newWin.frames['topCalFrame'].document.calControl.year.value = year;
|
||||
writeCalendar();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// GET NUMBER OF DAYS IN MONTH
|
||||
function getDaysInMonth() {
|
||||
|
||||
var days;
|
||||
var month = calDate.getMonth()+1;
|
||||
var year = calDate.getFullYear();
|
||||
|
||||
// RETURN 31 DAYS
|
||||
if (month==1 || month==3 || month==5 || month==7 || month==8 ||
|
||||
month==10 || month==12) {
|
||||
days=31;
|
||||
}
|
||||
// RETURN 30 DAYS
|
||||
else if (month==4 || month==6 || month==9 || month==11) {
|
||||
days=30;
|
||||
}
|
||||
// RETURN 29 DAYS
|
||||
else if (month==2) {
|
||||
if (isLeapYear(year)) {
|
||||
days=29;
|
||||
}
|
||||
// RETURN 28 DAYS
|
||||
else {
|
||||
days=28;
|
||||
}
|
||||
}
|
||||
return (days);
|
||||
}
|
||||
|
||||
|
||||
// CHECK TO SEE IF YEAR IS A LEAP YEAR
|
||||
function isLeapYear (Year) {
|
||||
|
||||
if (((Year % 4)==0) && ((Year % 100)!=0) || ((Year % 400)==0)) {
|
||||
return (true);
|
||||
}
|
||||
else {
|
||||
return (false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ENSURE THAT THE YEAR IS FOUR DIGITS IN LENGTH
|
||||
function isFourDigitYear(year) {
|
||||
|
||||
if (year == null || year.match(/^[0-9]{4}$/) == null){
|
||||
top.newWin.frames['topCalFrame'].document.calControl.year.value = calDate.getFullYear();
|
||||
top.newWin.frames['topCalFrame'].document.calControl.year.select();
|
||||
top.newWin.frames['topCalFrame'].document.calControl.year.focus();
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// BUILD THE MONTH SELECT LIST
|
||||
function getMonthSelect() {
|
||||
|
||||
monthArray = new Array(L_January, L_February, L_March, L_April, L_May, L_June,
|
||||
L_July, L_August, L_September, L_October, L_November, L_December);
|
||||
|
||||
|
||||
// DETERMINE MONTH TO SET AS DEFAULT
|
||||
var activeMonth = calDate.getMonth();
|
||||
|
||||
// START HTML SELECT LIST ELEMENT
|
||||
monthSelect = "<SELECT NAME='month' onChange='parent.opener.setCurrentMonth()'>";
|
||||
|
||||
// LOOP THROUGH MONTH ARRAY
|
||||
for (i in monthArray) {
|
||||
|
||||
// SHOW THE CORRECT MONTH IN THE SELECT LIST
|
||||
if (i == activeMonth) {
|
||||
monthSelect += "<OPTION SELECTED>" + monthArray[i] + "\n";
|
||||
}
|
||||
else {
|
||||
monthSelect += "<OPTION>" + monthArray[i] + "\n";
|
||||
}
|
||||
}
|
||||
monthSelect += "</SELECT>";
|
||||
|
||||
// RETURN A STRING VALUE WHICH CONTAINS A SELECT LIST OF ALL 12 MONTHS
|
||||
return monthSelect;
|
||||
}
|
||||
|
||||
|
||||
// SET DAYS OF THE WEEK DEPENDING ON LANGUAGE
|
||||
function createWeekdayList() {
|
||||
|
||||
weekdayArray = new Array(L_Su,L_Mo,L_Tu,L_We,L_Th,L_Fr,L_Sa);
|
||||
|
||||
|
||||
// START HTML TO HOLD WEEKDAY NAMES IN TABLE FORMAT
|
||||
var weekdays = "<TR BGCOLOR='" + headingCellColor + "'>";
|
||||
|
||||
// LOOP THROUGH WEEKDAY ARRAY
|
||||
for (i in weekdayArray) {
|
||||
|
||||
weekdays += "<TD class='heading' align=center>" + weekdayArray[i] + "</TD>";
|
||||
}
|
||||
weekdays += "</TR>";
|
||||
|
||||
// RETURN TABLE ROW OF WEEKDAY ABBREVIATIONS TO DISPLAY ABOVE THE CALENDAR
|
||||
return weekdays;
|
||||
}
|
||||
|
||||
|
||||
// PRE-BUILD PORTIONS OF THE CALENDAR (FOR PERFORMANCE REASONS)
|
||||
function buildCalParts() {
|
||||
|
||||
// GENERATE WEEKDAY HEADERS FOR THE CALENDAR
|
||||
weekdays = createWeekdayList();
|
||||
|
||||
// BUILD THE BLANK CELL ROWS
|
||||
blankCell = "<TD align=center bgcolor='" + cellColor + "'> </TD>";
|
||||
|
||||
// BUILD THE TOP PORTION OF THE CALENDAR PAGE USING CSS TO CONTROL SOME DISPLAY ELEMENTS
|
||||
calendarBegin =
|
||||
"<HTML>" +
|
||||
"<HEAD>" +
|
||||
// STYLESHEET DEFINES APPEARANCE OF CALENDAR
|
||||
"<STYLE type='text/css'>" +
|
||||
"<!--" +
|
||||
"TD.heading { text-decoration: none; color:" + headingTextColor + "; font: " + headingFontStyle + "; }" +
|
||||
"A.focusDay:link { color: " + focusColor + "; text-decoration: none; font: " + fontStyle + "; }" +
|
||||
"A.focusDay:hover { color: " + focusColor + "; text-decoration: none; font: " + fontStyle + "; }" +
|
||||
"A.focusDay:visited { color: " + focusColor + "; text-decoration: none; font: " + fontStyle + "; }" +
|
||||
"A.weekday:link { color: " + dateColor + "; text-decoration: none; font: " + fontStyle + "; }" +
|
||||
"A.weekday:hover { color: " + hoverColor + "; font: " + fontStyle + "; }" +
|
||||
"A.weekday:visited { color: " + dateColor + "; text-decoration: none; font: " + fontStyle + "; }" +
|
||||
"-->" +
|
||||
"</STYLE>" +
|
||||
|
||||
"</HEAD>" +
|
||||
"<BODY BGCOLOR='" + bottomBackground + "' onload='javascript:self.focus()'>";
|
||||
if (document.getElementById) { // ns6 & ie
|
||||
calendarBegin +=
|
||||
"<DIV ID='bottomDiv'>";
|
||||
}
|
||||
calendarBegin +=
|
||||
"<CENTER>";
|
||||
|
||||
// NAVIGATOR NEEDS A TABLE CONTAINER TO DISPLAY THE TABLE OUTLINES PROPERLY
|
||||
if (isNav) {
|
||||
calendarBegin +=
|
||||
"<TABLE CELLPADDING=0 CELLSPACING=1 BORDER=" + tableBorder + " ALIGN=CENTER BGCOLOR='" + tableBGColor + "'><TR><TD>";
|
||||
}
|
||||
|
||||
// BUILD WEEKDAY HEADINGS
|
||||
calendarBegin +=
|
||||
"<TABLE CELLPADDING=0 CELLSPACING=1 BORDER=" + tableBorder + " ALIGN=CENTER BGCOLOR='" + tableBGColor + "'>" +
|
||||
weekdays +
|
||||
"<TR>";
|
||||
|
||||
|
||||
// BUILD THE BOTTOM PORTION OF THE CALENDAR PAGE
|
||||
calendarEnd = "";
|
||||
|
||||
// WHETHER OR NOT TO DISPLAY A THICK LINE BELOW THE CALENDAR
|
||||
if (bottomBorder) {
|
||||
calendarEnd += "<TR></TR>";
|
||||
}
|
||||
|
||||
// NAVIGATOR NEEDS A TABLE CONTAINER TO DISPLAY THE BORDERS PROPERLY
|
||||
if (isNav) {
|
||||
calendarEnd += "</TD></TR></TABLE>";
|
||||
}
|
||||
|
||||
// END THE TABLE AND HTML DOCUMENT
|
||||
calendarEnd +=
|
||||
"</TABLE>" +
|
||||
"</CENTER>";
|
||||
if (document.getElementById) { // ns6 & ie
|
||||
calendarEnd +=
|
||||
"</DIV>";
|
||||
}
|
||||
calendarEnd +=
|
||||
"</BODY>" +
|
||||
"</HTML>";
|
||||
}
|
||||
|
||||
|
||||
// REPLACE ALL INSTANCES OF find WITH replace
|
||||
// inString: the string you want to convert
|
||||
// find: the value to search for
|
||||
// replace: the value to substitute
|
||||
//
|
||||
// usage: jsReplace(inString, find, replace);
|
||||
// example: jsReplace("To be or not to be", "be", "ski");
|
||||
// result: "To ski or not to ski"
|
||||
//
|
||||
function jsReplace(inString, find, replace) {
|
||||
|
||||
var outString = "";
|
||||
|
||||
if (!inString) {
|
||||
return "";
|
||||
}
|
||||
|
||||
// REPLACE ALL INSTANCES OF find WITH replace
|
||||
if (inString.indexOf(find) != -1) {
|
||||
// SEPARATE THE STRING INTO AN ARRAY OF STRINGS USING THE VALUE IN find
|
||||
t = inString.split(find);
|
||||
|
||||
// JOIN ALL ELEMENTS OF THE ARRAY, SEPARATED BY THE VALUE IN replace
|
||||
return (t.join(replace));
|
||||
}
|
||||
else {
|
||||
return inString;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// JAVASCRIPT FUNCTION -- DOES NOTHING (USED FOR THE HREF IN THE CALENDAR CALL)
|
||||
function doNothing() {
|
||||
}
|
||||
|
||||
|
||||
// ENSURE THAT VALUE IS TWO DIGITS IN LENGTH
|
||||
function makeTwoDigit(inValue) {
|
||||
|
||||
var numVal = parseInt(inValue, 10);
|
||||
|
||||
// VALUE IS LESS THAN TWO DIGITS IN LENGTH
|
||||
if (numVal < 10) {
|
||||
|
||||
// ADD A LEADING ZERO TO THE VALUE AND RETURN IT
|
||||
return("0" + numVal);
|
||||
}
|
||||
else {
|
||||
return numVal;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// SET FIELD VALUE TO THE DATE SELECTED AND CLOSE THE CALENDAR WINDOW
|
||||
function returnDate(inDay)
|
||||
{
|
||||
// inDay = THE DAY THE USER CLICKED ON
|
||||
calDate.setDate(inDay);
|
||||
|
||||
// SET THE DATE RETURNED TO THE USER
|
||||
var day = calDate.getDate();
|
||||
var month = calDate.getMonth()+1;
|
||||
var year = calDate.getFullYear();
|
||||
|
||||
// SET THE VALUE OF THE FIELD THAT WAS PASSED TO THE CALENDAR
|
||||
var dt = new Date(year, month - 1, day, 0, 0, 0);
|
||||
if (this.formatJsDate)
|
||||
calDateField.value = formatJsDate(dt);
|
||||
else
|
||||
calDateField.value = GLDT(dt,true, false);
|
||||
|
||||
calHiddenField.value = "Date(";
|
||||
calHiddenField.value += year;
|
||||
calHiddenField.value += ",";
|
||||
calHiddenField.value += month;
|
||||
calHiddenField.value += ",";
|
||||
calHiddenField.value += day;
|
||||
calHiddenField.value += ")";
|
||||
|
||||
// GIVE FOCUS BACK TO THE DATE FIELD
|
||||
calDateField.focus();
|
||||
|
||||
// CLOSE THE CALENDAR WINDOW
|
||||
top.newWin.close()
|
||||
}
|
||||
|
||||
var gHour = "0";
|
||||
var gMin = "0";
|
||||
var gSec = "0";
|
||||
var regDateTimePrompt = /^(D|d)(A|a)(T|t)(E|e)(T|t)(I|i)(M|m)(E|e) *\( *\d{4} *, *(0?[1-9]|1[0-2]) *, *((0?[1-9]|[1-2]\d)|3(0|1)) *, *([0-1]?\d|2[0-3]) *, *[0-5]?\d *, *[0-5]?\d *\)$/
|
||||
function ParseDateTimePrompt(inDate)
|
||||
{
|
||||
if ( regDateTimePrompt.test ( inDate ) )
|
||||
{
|
||||
var sDate = inDate.substr ( inDate.indexOf("(")+1 ); //move past "DateTime ("
|
||||
sDate = sDate.substr ( 0, sDate.lastIndexOf(")") ); //remove trailing ")"
|
||||
var dateArray = sDate.split (',');
|
||||
var _date = new Date ( dateArray[0], Number(dateArray[1]) - 1, dateArray[2] );
|
||||
gHour = dateArray[3]; gMin = dateArray[4]; gSec = dateArray[5];
|
||||
return _date;
|
||||
}
|
||||
return new Date ();
|
||||
}
|
||||
|
||||
var regDatePrompt = /^(D|d)(A|a)(T|t)(E|e) *\( *\d{4} *, *(0?[1-9]|1[0-2]) *, *((0?[1-9]|[1-2]\d)|3(0|1)) *\)$/
|
||||
function ParseDatePrompt(inDate)
|
||||
{
|
||||
if ( regDatePrompt.test ( inDate ) )
|
||||
{
|
||||
var sDate = inDate.substr ( inDate.indexOf("(")+1 ); //move past "Date ("
|
||||
sDate = sDate.substr ( 0, sDate.lastIndexOf(")") ); //remove trailing ")"
|
||||
var dateArray = sDate.split (',');
|
||||
return new Date ( dateArray[0], Number(dateArray[1]) - 1, dateArray[2] );
|
||||
}
|
||||
return new Date();
|
||||
}
|
||||
|
||||
function ParseDate(inDate, bDateTimeFormat)
|
||||
{
|
||||
var result;
|
||||
|
||||
if (bDateTimeFormat == true) {
|
||||
result = ParseDateTimePrompt(inDate);
|
||||
} else {
|
||||
result = ParseDatePrompt(inDate);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
126
crystalreportviewers13/js/crviewer/ArgumentNormalizer.js
Normal file
@@ -0,0 +1,126 @@
|
||||
/* Copyright (c) Business Objects 2006. All rights reserved. */
|
||||
|
||||
/**
|
||||
* ArgumentNormalizer names and transforms function arguments based upon a
|
||||
* set of rules provided by the user.
|
||||
*/
|
||||
|
||||
if (typeof bobj == 'undefined') {
|
||||
bobj = {};
|
||||
}
|
||||
|
||||
bobj.ArgumentNormalizer = function() {
|
||||
this._rules = [];
|
||||
};
|
||||
|
||||
bobj.ArgumentNormalizer.prototype = {
|
||||
|
||||
/**
|
||||
* Add a rule for naming and transforming arguments.
|
||||
* When arguments are normalized each rule is applied until a match is
|
||||
* found. A rule is a set of elements of the following form:
|
||||
*
|
||||
* {
|
||||
* test: [function, null],
|
||||
* name: [string],
|
||||
* xform: [function - optional]
|
||||
* }
|
||||
*
|
||||
* There should be one element of the above form for each argument expected
|
||||
* by the rule. A rule is a match if and only if true is returned by every
|
||||
* element's test function when passed its corresponding argument. A null
|
||||
* test function is considered to return true. Rules are tested in the order
|
||||
* they were added until one matches or there are no more to test.
|
||||
*
|
||||
* When a rule matches, it applies the optional xform (transform) functions
|
||||
* to it arguments and saves the results in a return object with properties
|
||||
* specified by the names in the rule elements.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* n.addRule({test:isString, name:'description', xform:trim},
|
||||
* {test:isNumber, name:'id'});
|
||||
* n.addRule({test:isString, name:'description', xform:trim},
|
||||
* {test:isString, name:'id', xform:parseInt});
|
||||
*
|
||||
* n.normalize(" Blue car", 11); // First rule matches
|
||||
* -> {description: "Blue car", id: 11}
|
||||
*
|
||||
* n.normalize("Green car ", "55"); // Second rule matches
|
||||
* -> {description: "Green car", id: 55}
|
||||
*
|
||||
* Rule elements may be passed as arrays for brevity. The first rule
|
||||
* from the example above would be added as follows:
|
||||
*
|
||||
* n.addRule([isString, 'description', trim], [isNumber, 'id']);
|
||||
*
|
||||
* When an element simply names an argument (no test or transform is
|
||||
* desired), it may be specified as a string. For example:
|
||||
*
|
||||
* n.addRule([isString, 'description', trim], 'id');
|
||||
*/
|
||||
addRule: function() {
|
||||
this._rules.push(arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
* Normalize the arguments based upon the rules that have been added
|
||||
*
|
||||
* @param arguments Arguments to be normalized
|
||||
*
|
||||
* @return An object with a property for each transformed argument or null
|
||||
*/
|
||||
normalize: function() {
|
||||
for (var rIdx = 0, nRules = this._rules.length; rIdx < nRules; ++rIdx) {
|
||||
var rule = this._rules[rIdx];
|
||||
|
||||
if (rule.length == arguments.length) {
|
||||
var normalArgs = {};
|
||||
|
||||
for (var aIdx = 0, nArgs = rule.length; aIdx < nArgs; ++aIdx) {
|
||||
var argVal = arguments[aIdx];
|
||||
var element = rule[aIdx];
|
||||
|
||||
if (bobj.isString(element)) { // No test specified, just name the argument
|
||||
var argTest = null;
|
||||
var argName = element;
|
||||
var argXform = null;
|
||||
}
|
||||
else if (bobj.isArray(element)) {
|
||||
var argTest = element[0];
|
||||
var argName = element[1];
|
||||
var argXform = element[2];
|
||||
}
|
||||
else {
|
||||
var argTest = element.test;
|
||||
var argName = element.name;
|
||||
var argXform = element.xform;
|
||||
}
|
||||
|
||||
if (!argTest || argTest(argVal)) {
|
||||
normalArgs[argName] = argXform ? argXform(argVal) : argVal;
|
||||
if (aIdx+1 == nArgs) { // if no more args to check
|
||||
return normalArgs; // Rule matched, return normalized args
|
||||
}
|
||||
}
|
||||
else {
|
||||
break; // Rule didn't match, try the next one
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Applies an array of arguments to normalize()
|
||||
*
|
||||
* @param argsArray [Array] Array of arguments to normalize
|
||||
*
|
||||
* @return Normalized arguments or null
|
||||
*/
|
||||
normalizeArray: function(argsArray) {
|
||||
return this.normalize.apply(this, argsArray);
|
||||
}
|
||||
};
|
||||
|
||||
244
crystalreportviewers13/js/crviewer/ButtonList.js
Normal file
@@ -0,0 +1,244 @@
|
||||
|
||||
//** ButtonList Widget *************************************************************
|
||||
|
||||
/**
|
||||
* ButtonList Constructor
|
||||
*/
|
||||
bobj.crv.newButtonList = function(kwArgs) {
|
||||
kwArgs = MochiKit.Base.update({
|
||||
id: bobj.uniqueId(),
|
||||
numLines: null, // null allows the height to grow (will fit within the viewport)
|
||||
buttonWidth: 24,
|
||||
buttonTooltip: L_bobj_crv_TabList,
|
||||
changeCB: null,
|
||||
label: null,
|
||||
tabIndex: 0,
|
||||
multiSelect: false,
|
||||
menuWidth: null,
|
||||
menuTooltip: null
|
||||
}, kwArgs);
|
||||
|
||||
var o = newButtonWidget(
|
||||
kwArgs.id,
|
||||
kwArgs.label,
|
||||
bobj.crv.ButtonList._onClick,
|
||||
kwArgs.buttonWidth,
|
||||
null,
|
||||
kwArgs.buttonTooltip,
|
||||
kwArgs.tabIndex,
|
||||
0, _skin+"menus.gif", 7, 16, 0, 81, true, 0, 97);
|
||||
|
||||
o._menu = newListWidget(
|
||||
kwArgs.id + "_menu",
|
||||
MochiKit.Base.bind(bobj.crv.ButtonList._onChange, o),
|
||||
kwArgs.multiSelect,
|
||||
kwArgs.menuWidth,
|
||||
kwArgs.numLines || 2,
|
||||
kwArgs.menuTooltip,
|
||||
null, //dblClickCB
|
||||
null); //keyUpCB
|
||||
|
||||
o._listItems = [];
|
||||
o._blOldInit = o.init;
|
||||
o._blOldGetHTML = o.getHTML;
|
||||
o._menuDiv = null;
|
||||
|
||||
o._captureClicks = MenuWidget_captureClicks;
|
||||
o._releaseClicks = MenuWidget_releaseClicks;
|
||||
|
||||
bobj.fillIn(o, kwArgs);
|
||||
o.widgetType = 'ButtonList';
|
||||
MochiKit.Base.update(o, bobj.crv.ButtonList);
|
||||
|
||||
return o;
|
||||
};
|
||||
|
||||
bobj.crv.ButtonList = {
|
||||
/**
|
||||
* @return [Widget] Menu/list widget associated with this button.
|
||||
*/
|
||||
getMenu : function() {
|
||||
return this._menu;
|
||||
},
|
||||
|
||||
/**
|
||||
* Add an item to the menu
|
||||
*
|
||||
* @param label [String] The text to display in the menu
|
||||
* @param value [any - opt.] The value associated with the new menu item
|
||||
* @param isSelected [bool - opt.] True if item should be selected after being added
|
||||
* @param id [String - opt.] DHTML id associated with menu item;
|
||||
*/
|
||||
add : function(label, value, isSelected, id) {
|
||||
if (this._menu && this._menu.layer)
|
||||
this._menu.add (label, value, isSelected, id);
|
||||
|
||||
else
|
||||
this._listItems.push ( {
|
||||
lbl : label,
|
||||
val : value,
|
||||
sel : isSelected,
|
||||
id : id
|
||||
});
|
||||
},
|
||||
|
||||
init : function() {
|
||||
var menu = this._menu;
|
||||
this._blOldInit ();
|
||||
menu.init ();
|
||||
|
||||
this._menuDiv = getLayer (this.id + '_menuDiv');
|
||||
|
||||
var listItems = this._listItems;
|
||||
for ( var i = 0, len = listItems.length; i < len; ++i) {
|
||||
var it = listItems[i];
|
||||
menu.add (it.lbl, it.val, it.sel, it.id);
|
||||
}
|
||||
this._listItems = [];
|
||||
},
|
||||
|
||||
getHTML : function() {
|
||||
var h = bobj.html;
|
||||
|
||||
var menuDivAtts = {
|
||||
id : this.id + '_menuDiv',
|
||||
onmousedown : 'event.cancelBubble=true',
|
||||
'class' : 'menuFrame',
|
||||
style : {
|
||||
visibility : 'hidden',
|
||||
position : 'absolute',
|
||||
'z-index' : 5000
|
||||
}
|
||||
};
|
||||
return this._blOldGetHTML () + h.DIV (menuDivAtts, this._menu.getHTML ());
|
||||
},
|
||||
|
||||
/**
|
||||
* @return [bool] True if and only if the menu is visible
|
||||
*/
|
||||
isMenuShowing : function() {
|
||||
return this._menuDiv && this._menuDiv.style.visibility != 'hidden';
|
||||
},
|
||||
|
||||
/**
|
||||
* Hide the menu
|
||||
*/
|
||||
hideMenu : function() {
|
||||
if (this._menuDiv) {
|
||||
this._menuDiv.style.visibility = 'hidden';
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Position and show the menu
|
||||
*/
|
||||
showMenu : function() {
|
||||
if (this._menuDiv) {
|
||||
this._captureClicks ();
|
||||
|
||||
var body = document.body;
|
||||
|
||||
if (this._menuDiv.parentNode !== body) {
|
||||
body.appendChild (this._menuDiv);
|
||||
}
|
||||
|
||||
var divStyle = this._menuDiv.style;
|
||||
divStyle.left = '-1000px';
|
||||
divStyle.top = '-1000px';
|
||||
divStyle.visibility = 'visible';
|
||||
|
||||
var winDim = MochiKit.Style.getViewportDimensions ();
|
||||
|
||||
var w = this._menu.layer.offsetWidth;
|
||||
var h = this._menu.getHeight ();
|
||||
|
||||
/*
|
||||
* If numLines wasn't specified, use as much space as necessary while remaining within the viewport
|
||||
*/
|
||||
if (!this.numLines) {
|
||||
h = Math.min (this._menu.layer.scrollHeight + 10, winDim.h - 10);
|
||||
this._menu.resize (null, h);
|
||||
}
|
||||
|
||||
/* Place the menu below the button and aligned with the left edge */
|
||||
var btnPos = getPosScrolled (this.layer);
|
||||
var x = btnPos.x;
|
||||
var y = btnPos.y + this.getHeight ();
|
||||
|
||||
/* Change coordinates so the whole menu is on the screen */
|
||||
var xRight = x + w + 4;
|
||||
var yBottom = y + h + 4;
|
||||
|
||||
var xMax = winDim.w + body.scrollLeft - Math.max (0, (winDim.w - body.offsetWidth));
|
||||
if (xRight > xMax) {
|
||||
x = Math.max (0, x - (xRight - xMax));
|
||||
}
|
||||
|
||||
var yMax = winDim.h + body.scrollTop;
|
||||
if (yBottom > yMax) {
|
||||
y = Math.max (0, y - (yBottom - yMax));
|
||||
}
|
||||
|
||||
divStyle.left = x + 'px';
|
||||
divStyle.top = y + 'px';
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Private. Capture clicks in the current document so that the menu can be hidden automatically.
|
||||
*/
|
||||
_captureClicks : function() {
|
||||
var BIND = MochiKit.Base.bind;
|
||||
try {
|
||||
this.layer.onmousedown = BIND (this._onCaptureClick, this, true);
|
||||
this._oldMousedown = document.onmousedown;
|
||||
document.onmousedown = BIND (this._onCaptureClick, this, false);
|
||||
} catch (ex) {
|
||||
if (bobj.crv.config.isDebug) {
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Private. Stop capturing clicks.
|
||||
*/
|
||||
_releaseClicks : function() {
|
||||
if (this.layer.onmousedown) { /* non-null if clicks are being captured */
|
||||
this.layer.onmousedown = null;
|
||||
document.onmousedown = this._oldMousedown;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Private. Button click callback.
|
||||
*/
|
||||
_onClick : function() {
|
||||
if (!this._cancelNextClick)
|
||||
this.showMenu ();
|
||||
|
||||
this._cancelNextClick = false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Private. Menu change callback.
|
||||
*/
|
||||
_onChange : function() {
|
||||
this._releaseClicks ();
|
||||
this.hideMenu ();
|
||||
|
||||
if (this.changeCB)
|
||||
this.changeCB ();
|
||||
},
|
||||
|
||||
/**
|
||||
* Private. Called when a click is captured (after _captureClicks has been called)
|
||||
*/
|
||||
_onCaptureClick : function(cancelNext, e) {
|
||||
this._cancelNextClick = cancelNext;
|
||||
eventCancelBubble (e);
|
||||
this.hideMenu ();
|
||||
this._releaseClicks ();
|
||||
}
|
||||
};
|
||||
539
crystalreportviewers13/js/crviewer/Calendar.js
Normal file
@@ -0,0 +1,539 @@
|
||||
/* Copyright (c) Business Objects 2006. All rights reserved. */
|
||||
|
||||
if (typeof bobj == 'undefined') {
|
||||
bobj = {};
|
||||
}
|
||||
if (typeof bobj.crv == 'undefined') {
|
||||
bobj.crv = {};
|
||||
}
|
||||
if (typeof bobj.crv.Calendar == 'undefined') {
|
||||
bobj.crv.Calendar = {};
|
||||
}
|
||||
|
||||
/*
|
||||
================================================================================
|
||||
Calendar Widget
|
||||
================================================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get a shared calendar instance
|
||||
*/
|
||||
bobj.crv.Calendar.getInstance = function() {
|
||||
if (!bobj.crv.Calendar.__instance) {
|
||||
bobj.crv.Calendar.__instance = bobj.crv.newCalendar();
|
||||
}
|
||||
return bobj.crv.Calendar.__instance;
|
||||
};
|
||||
|
||||
bobj.crv.Calendar.Signals = {
|
||||
OK_CLICK: 'okClick',
|
||||
CANCEL_CLICK: 'cancelClick',
|
||||
ON_HIDE: 'onHide'
|
||||
};
|
||||
|
||||
bobj.crv.newCalendar = function(kwArgs) {
|
||||
var UPDATE = MochiKit.Base.update;
|
||||
kwArgs = UPDATE({
|
||||
id: bobj.uniqueId() + "_calendar",
|
||||
showTime: false,
|
||||
date: new Date(),
|
||||
// List of formats to match in order of preference. Once a format is
|
||||
// matched, the time field will be displayed in that format.
|
||||
timeFormats: ["HH:mm:ss", "H:mm:ss", "H:m:s", "HH:mm", "H:mm", "H:m",
|
||||
"h:mm:ss a", "h:m:s a", "h:mm:ssa", "h:m:sa", "h:mm a", "h:m a",
|
||||
"h:mma", "h:ma"]
|
||||
}, kwArgs);
|
||||
|
||||
var o = newMenuWidget( );
|
||||
|
||||
o.widgetType = 'Calendar';
|
||||
|
||||
// Update instance with constructor arguments
|
||||
bobj.fillIn(o, kwArgs);
|
||||
|
||||
// Update instance with member functions
|
||||
o._menuJustInTimeInit = o.justInTimeInit;
|
||||
UPDATE(o, bobj.crv.Calendar);
|
||||
|
||||
o._curTimeFormat = o.timeFormats[0];
|
||||
o._cells = [];
|
||||
o._firstDay = 0;
|
||||
o._numDays = 0;
|
||||
|
||||
return o;
|
||||
};
|
||||
|
||||
bobj.crv.Calendar._createHeaderButtons = function() {
|
||||
var w = 8;
|
||||
var h = 4;
|
||||
var dx = 46;
|
||||
var dyUp = 0;
|
||||
var dyDown = 12;
|
||||
|
||||
var bind = MochiKit.Base.bind;
|
||||
|
||||
this._prevMonthBtn = newIconWidget(this.id+"_pm",_skin+'../lov.gif',bind(this._onPrevMonthClick, this),"",_calendarPrevMonthLab,w,h,dx,dyDown);
|
||||
this._prevYearBtn = newIconWidget(this.id+"_py",_skin+'../lov.gif',bind(this._onPrevYearClick, this),"",_calendarPrevYearLab,w,h,dx,dyDown);
|
||||
this._nextMonthBtn = newIconWidget(this.id+"_nm",_skin+'../lov.gif',bind(this._onNextMonthClick, this),"",_calendarNextMonthLab,w,h,dx,dyUp);
|
||||
this._nextYearBtn = newIconWidget(this.id+"_ny",_skin+'../lov.gif',bind(this._onNextYearClick, this),"",_calendarNextYearLab,w,h,dx,dyUp);
|
||||
};
|
||||
|
||||
bobj.crv.Calendar._createTimeTextField = function() {
|
||||
var bind = MochiKit.Base.bind;
|
||||
|
||||
this._timeField = newTextFieldWidget(
|
||||
this.id + '_time',
|
||||
bind(this._onTimeChange, this), //changeCB
|
||||
null, //maxChar
|
||||
null, //keyUpCB
|
||||
null, //enterCB
|
||||
true, //noMargin
|
||||
null, //tooltip
|
||||
null, //width
|
||||
null, //focusCB
|
||||
null); //blurCB
|
||||
};
|
||||
|
||||
bobj.crv.Calendar._createOKCancelButtons = function() {
|
||||
var bind = MochiKit.Base.bind;
|
||||
this._okBtn = newButtonWidget(this.id + "_ok", L_bobj_crv_OK, bind(this._onOKClick, this));
|
||||
this._cancelBtn = newButtonWidget(this.id + "_cancel", L_bobj_crv_Cancel, bind(this._onCancelClick, this));
|
||||
};
|
||||
|
||||
/**
|
||||
* Widget will auto-initialize the first time its show method is called.
|
||||
* Client code shoud not call this method.
|
||||
*/
|
||||
bobj.crv.Calendar.justInTimeInit = function() {
|
||||
this._menuJustInTimeInit();
|
||||
|
||||
this._prevMonthBtn.init();
|
||||
this._prevYearBtn.init();
|
||||
this._nextMonthBtn.init();
|
||||
this._nextYearBtn.init();
|
||||
|
||||
this._okBtn.init();
|
||||
this._cancelBtn.init();
|
||||
|
||||
this._timeField.init();
|
||||
this._timeField.layer.style.width = '100%';
|
||||
this._timeField.setValue(bobj.external.date.formatDate(this.date, this._curTimeFormat));
|
||||
|
||||
this._timeRow = getLayer(this.id + '_timeRow');
|
||||
this._timeSep = getLayer(this.id + '_timeSep');
|
||||
|
||||
this._month = getLayer(this.id + "_month");
|
||||
this._year = getLayer(this.id + "_year");
|
||||
|
||||
var numCells = 6 * 7; // six rows in the calendar with 7 days each
|
||||
for (var i = 0; i < numCells; i++) {
|
||||
this._cells[i] = getLayer(this.id + '_c' + i);
|
||||
}
|
||||
|
||||
this._update();
|
||||
};
|
||||
|
||||
/**
|
||||
* Widget will be written into the document the first time its show method is called.
|
||||
* Client code shoud not call this method.
|
||||
*/
|
||||
bobj.crv.Calendar.getHTML = function() {
|
||||
var h = bobj.html;
|
||||
var TABLE = h.TABLE;
|
||||
var TBODY = h.TBODY;
|
||||
var TR = h.TR;
|
||||
var TD = h.TD;
|
||||
var DIV = h.DIV;
|
||||
var SPAN = h.SPAN;
|
||||
var A = h.A;
|
||||
|
||||
this._createHeaderButtons();
|
||||
this._createTimeTextField();
|
||||
this._createOKCancelButtons();
|
||||
|
||||
var onkeydown = "MenuWidget_keyDown('" + this.id + "', event); return true";
|
||||
var onmousedown = "eventCancelBubble(event)";
|
||||
var onmouseup = "eventCancelBubble(event)";
|
||||
var onkeypress = "eventCancelBubble(event)";
|
||||
|
||||
var dayHeaderAtt = {'class':"calendarTextPart"};
|
||||
|
||||
var html = TABLE({dir: 'ltr', id: this.id, border:"0", cellpadding:"0", cellspacing:"0",
|
||||
onkeydown: onkeydown, onmousedown: onmousedown, onmouseup: onmouseup, onkeypress: onkeypress,
|
||||
'class':"menuFrame", style:{cursor:"default", visibility:"hidden",'z-index': 10000}},
|
||||
TBODY(null,
|
||||
TR(null, TD(null, this._getMonthYearHTML())),
|
||||
TR(null, TD({align:"center"},
|
||||
TABLE({border:"0", cellspacing:"0", cellpadding:"0", style:{margin:"2px", 'margin-top': "6px"}},
|
||||
TR({align:"center"},
|
||||
TD(dayHeaderAtt, L_bobj_crv_SundayShort),
|
||||
TD(dayHeaderAtt, L_bobj_crv_MondayShort),
|
||||
TD(dayHeaderAtt, L_bobj_crv_TuesdayShort),
|
||||
TD(dayHeaderAtt, L_bobj_crv_WednesdayShort),
|
||||
TD(dayHeaderAtt, L_bobj_crv_ThursdayShort),
|
||||
TD(dayHeaderAtt, L_bobj_crv_FridayShort),
|
||||
TD(dayHeaderAtt, L_bobj_crv_SaturdayShort)),
|
||||
TR(null, TD({colspan:"7", style:{padding:"2px"}}, this._getSeparatorHTML())),
|
||||
this._getDaysHTML(),
|
||||
TR(null, TD({colspan:"7", style:{padding:"2px"}}, this._getSeparatorHTML())),
|
||||
TR({id:this.id + '_timeRow', style:{display:this.showTime ? '' : 'none'}},
|
||||
TD({colspan:"7", style:{'padding-top':"3px", 'padding-bottom':"3px", 'padding-right':"10px", 'padding-left':"10px"}},
|
||||
this._timeField.getHTML())),
|
||||
TR({id:this.id + '_timeSep',style:{display:this.showTime ? '' : 'none'}},
|
||||
TD({colspan:"7", style:{padding:"2px"}}, this._getSeparatorHTML())),
|
||||
TR(null, TD({colspan:"7", align:"right", style:{'padding-bottom':"3px", 'padding-top':"3px"}},
|
||||
TABLE(null, TBODY(null, TR(null,
|
||||
TD(null, this._okBtn.getHTML()),
|
||||
TD(null, this._cancelBtn.getHTML())))))))))));
|
||||
|
||||
return this._getLinkHTML('startLink_' + this.id) + html + this._getLinkHTML('endLink_' + this.id);
|
||||
};
|
||||
|
||||
bobj.crv.Calendar._getMonthYearHTML = function() {
|
||||
var h = bobj.html;
|
||||
var TABLE = h.TABLE;
|
||||
var TBODY = h.TBODY;
|
||||
var TR = h.TR;
|
||||
var TD = h.TD;
|
||||
var DIV = h.DIV;
|
||||
var SPAN = h.SPAN;
|
||||
|
||||
return TABLE({'class':"dialogzone", width:"100%", cellpadding:"0", cellspacing:"0"},
|
||||
TBODY(null,
|
||||
TR(null,
|
||||
TD({style:{'padding-top':"1px"}}, this._nextMonthBtn.getHTML()),
|
||||
TD({rowspan:"2", width:"100%", align:"center", 'class':"dialogzone"},
|
||||
SPAN({id:this.id + "_month", tabIndex:"0"}, _month[this.date.getMonth()]),
|
||||
" ",
|
||||
SPAN({id:this.id + "_year", tabIndex:"0"}, this.date.getFullYear())),
|
||||
TD({style:{'pading-top':"1px"}}, this._nextYearBtn.getHTML())),
|
||||
TR({valign:"top"},
|
||||
TD({style:{'padding-bottom':"1px"}}, this._prevMonthBtn.getHTML()),
|
||||
TD({style:{'padding-bottom':"1px"}}, this._prevYearBtn.getHTML()))));
|
||||
};
|
||||
|
||||
bobj.crv.Calendar._getSeparatorHTML = function() {
|
||||
var h = bobj.html;
|
||||
var TABLE = h.TABLE;
|
||||
var TBODY = h.TBODY;
|
||||
var TR = h.TR;
|
||||
var TD = h.TD;
|
||||
|
||||
return TABLE({width:"100%",
|
||||
height:"3",
|
||||
cellpadding:"0",
|
||||
cellspacing:"0",
|
||||
border:"0",
|
||||
style:backImgOffset(_skin+"menus.gif",0,80)},
|
||||
TBODY(null, TR(null, TD())));
|
||||
};
|
||||
|
||||
bobj.crv.Calendar._getLinkHTML = function(id) {
|
||||
return bobj.html.A({
|
||||
id: id,
|
||||
href: "javascript:void(0)",
|
||||
onfocus: "MenuWidget_keepFocus('"+this.id+"')",
|
||||
style:{
|
||||
visibility:"hidden",
|
||||
position:"absolute"
|
||||
}});
|
||||
};
|
||||
|
||||
bobj.crv.Calendar._getDaysHTML = function() {
|
||||
var TD = bobj.html.TD;
|
||||
var DIV = bobj.html.DIV;
|
||||
var html = '';
|
||||
|
||||
for (i = 0; i < 6; ++i) {
|
||||
html += '<tr align="right">';
|
||||
|
||||
for (j = 0; j < 7; ++j) {
|
||||
var cellNum = j + (i * 7);
|
||||
var eventArgs = "(this," + cellNum + "," + "event);";
|
||||
|
||||
html += TD({id: this.id + '_c' + (i * 7 + j),
|
||||
'class':"calendarTextPart",
|
||||
onmousedown: "bobj.crv.Calendar._onDayMouseDown" + eventArgs,
|
||||
onmouseover: "bobj.crv.Calendar._onDayMouseOver" + eventArgs,
|
||||
onmouseout: "bobj.crv.Calendar._onDayMouseOut" + eventArgs,
|
||||
ondblclick: "bobj.crv.Calendar._onDayDoubleClick" + eventArgs,
|
||||
onkeydown: "bobj.crv.Calendar._onDayKeyDown" + eventArgs},
|
||||
DIV({'class':"menuCalendar"}));
|
||||
}
|
||||
|
||||
html += '</tr>';
|
||||
}
|
||||
|
||||
return html;
|
||||
};
|
||||
|
||||
/**
|
||||
* Update the calendar's display using the current date value
|
||||
*/
|
||||
bobj.crv.Calendar._update = function() {
|
||||
var numCells = 6 * 7; // six rows in the calendar with 7 days each
|
||||
var curDate = this.date.getDate();
|
||||
|
||||
var info = this._getMonthInfo(this.date.getMonth(), this.date.getFullYear());
|
||||
|
||||
var firstCellInMonth = info.firstDay;
|
||||
this._firstDay = info.firstDay;
|
||||
this._numDays = info.numDays;
|
||||
|
||||
var year = "" + this.date.getFullYear();
|
||||
while (year.length < 4) {
|
||||
year = "0" + year;
|
||||
}
|
||||
this._year.innerHTML = year;
|
||||
this._month.innerHTML = _month[this.date.getMonth()];
|
||||
|
||||
this._selectedDate = null;
|
||||
|
||||
for (var cellNum = 0; cellNum < numCells; cellNum++) {
|
||||
var cell = this._cells[cellNum].firstChild;
|
||||
var cssClass = "menuCalendar";
|
||||
var cellDate = this._getDateFromCellNum(cellNum);
|
||||
|
||||
if (cellDate < 1 || cellDate > info.numDays) {
|
||||
cell.innerHTML = "";
|
||||
cell.tabIndex = "-1";
|
||||
}
|
||||
else {
|
||||
cell.innerHTML = "" + cellDate;
|
||||
cell.tabIndex = "0";
|
||||
if (cellDate == curDate) {
|
||||
cssClass = "menuCalendarSel";
|
||||
this._selectedDay = cell;
|
||||
}
|
||||
}
|
||||
|
||||
cell.className = cssClass;
|
||||
}
|
||||
};
|
||||
|
||||
bobj.crv.Calendar._getMonthInfo = function(month, year) {
|
||||
var date = new Date();
|
||||
date.setDate(1);
|
||||
date.setFullYear(year);
|
||||
date.setMonth(month);
|
||||
|
||||
var firstDay = date.getDay(); // First day of the week in this month
|
||||
|
||||
date.setDate(28);
|
||||
var lastDate = 28; // Last date in this month
|
||||
|
||||
for (var i = 29; i < 32; i++) {
|
||||
date.setDate(i);
|
||||
if (date.getMonth() != month) {
|
||||
break;
|
||||
}
|
||||
lastDate = i;
|
||||
}
|
||||
|
||||
return {firstDay: firstDay, numDays: lastDate};
|
||||
};
|
||||
|
||||
bobj.crv.Calendar._setDayOfMonth = function(date) {
|
||||
if (date > 0 && date <= this._numDays) {
|
||||
var prevDate = this.date.getDate();
|
||||
|
||||
if (date != prevDate) {
|
||||
var prevCell = this._getCellFromDate(prevDate);
|
||||
|
||||
if (prevCell) {
|
||||
prevCell.firstChild.className = "menuCalendar";
|
||||
}
|
||||
|
||||
this._getCellFromDate(date).firstChild.className = "menuCalendarSel";
|
||||
this.date.setDate(date);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
bobj.crv.Calendar._getCellFromDate = function(date) {
|
||||
var cellNum = date + this._firstDay - 1;
|
||||
return this._cells[cellNum];
|
||||
};
|
||||
|
||||
bobj.crv.Calendar._getDateFromCellNum = function(cellNum) {
|
||||
return cellNum - this._firstDay + 1;
|
||||
};
|
||||
|
||||
bobj.crv.Calendar._onDayMouseOver = function(node, cellNum, event) {
|
||||
var o = getWidget(node);
|
||||
var div = node.firstChild;
|
||||
|
||||
var date = cellNum - o._firstDay + 1;
|
||||
if (date < 1 || date > o._numDays) {
|
||||
div.className = "menuCalendar";
|
||||
}
|
||||
else {
|
||||
div.className = "menuCalendarSel";
|
||||
}
|
||||
};
|
||||
|
||||
bobj.crv.Calendar._onDayMouseOut = function(node, cellNum, event) {
|
||||
var o = getWidget(node);
|
||||
var div = node.firstChild;
|
||||
|
||||
var date = cellNum - o._firstDay + 1;
|
||||
|
||||
if (date != o.date.getDate()) {
|
||||
div.className = "menuCalendar";
|
||||
}
|
||||
};
|
||||
|
||||
bobj.crv.Calendar._onDayMouseDown = function(node, cellNum, event) {
|
||||
var o = getWidget(node);
|
||||
var date = cellNum - o._firstDay + 1;
|
||||
o._setDayOfMonth(date);
|
||||
};
|
||||
|
||||
bobj.crv.Calendar._onDayDoubleClick = function(node, cellNum, event) {
|
||||
var o = getWidget(node);
|
||||
o._onOKClick();
|
||||
};
|
||||
|
||||
bobj.crv.Calendar._onDayKeyDown = function(node, cellNum, event) {
|
||||
event = new MochiKit.Signal.Event(node, event);
|
||||
var key = event.key().string;
|
||||
if (key === "KEY_ENTER") {
|
||||
var o = getWidget(node);
|
||||
var date = cellNum - o._firstDay + 1;
|
||||
o._setDayOfMonth(date);
|
||||
}
|
||||
};
|
||||
|
||||
bobj.crv.Calendar._onPrevMonthClick = function() {
|
||||
var d = this.date;
|
||||
var oldMonth = d.getMonth();
|
||||
if(d.getMonth() === 0) {
|
||||
d.setYear(d.getFullYear() -1);
|
||||
d.setMonth(11);
|
||||
}
|
||||
else {
|
||||
d.setMonth(d.getMonth() - 1);
|
||||
if (oldMonth === d.getMonth()) {
|
||||
// that means we have decremented 0 month instead of 1. This happens if the current date is Oct 31, for eg. Since there's no Sept 31, it jumps to October 1.
|
||||
d.setMonth(oldMonth-1);
|
||||
}
|
||||
}
|
||||
this._update();
|
||||
};
|
||||
|
||||
bobj.crv.Calendar._onPrevYearClick = function() {
|
||||
this.date.setFullYear(this.date.getFullYear() - 1);
|
||||
this._update();
|
||||
};
|
||||
|
||||
bobj.crv.Calendar._onNextMonthClick = function() {
|
||||
var d = this.date;
|
||||
var oldMonth = d.getMonth();
|
||||
d.setMonth(d.getMonth() + 1);
|
||||
if ((oldMonth+1) < d.getMonth()) {
|
||||
// that means we have incremented 2 months instead of 1. This happens if the current date is Oct 31, for eg. Since there's no Nov 31, it jumps to Dec 1.
|
||||
// For Dec 31, we don't need to worry because there's Jan 31.
|
||||
d.setMonth(oldMonth+1);
|
||||
}
|
||||
this._update();
|
||||
};
|
||||
|
||||
bobj.crv.Calendar._onNextYearClick = function() {
|
||||
this.date.setFullYear(this.date.getFullYear() + 1);
|
||||
this._update();
|
||||
};
|
||||
|
||||
bobj.crv.Calendar._onOKClick = function() {
|
||||
this.restoreFocus();
|
||||
MochiKit.Signal.signal(this, this.Signals.OK_CLICK, this._copyDate(this.date));
|
||||
this.show(false);
|
||||
};
|
||||
|
||||
bobj.crv.Calendar._copyDate = function(date) {
|
||||
if (date) {
|
||||
return new Date(date.getFullYear(),
|
||||
date.getMonth(),
|
||||
date.getDate(),
|
||||
date.getHours(),
|
||||
date.getMinutes(),
|
||||
date.getSeconds(),
|
||||
date.getMilliseconds());
|
||||
}
|
||||
return new Date();
|
||||
};
|
||||
|
||||
bobj.crv.Calendar._onCancelClick = function() {
|
||||
this.restoreFocus();
|
||||
this.show(false);
|
||||
MochiKit.Signal.signal(this, this.Signals.CANCEL_CLICK);
|
||||
};
|
||||
|
||||
bobj.crv.Calendar._onTimeChange = function() {
|
||||
var text = this._timeField.getValue();
|
||||
var date = null;
|
||||
var format = null;
|
||||
|
||||
for (var i = 0; i < this.timeFormats.length && date === null; ++i) {
|
||||
format = this.timeFormats[i];
|
||||
date = bobj.external.date.getDateFromFormat(text, format);
|
||||
}
|
||||
|
||||
if (date) {
|
||||
this._curTimeFormat = format;
|
||||
this.date.setHours(date.getHours());
|
||||
this.date.setMinutes(date.getMinutes());
|
||||
this.date.setSeconds(date.getSeconds());
|
||||
this.date.setMilliseconds(date.getMilliseconds());
|
||||
}
|
||||
else {
|
||||
this._timeField.setValue(bobj.external.date.formatDate(this.date, this._curTimeFormat));
|
||||
}
|
||||
};
|
||||
|
||||
bobj.crv.Calendar.setShowTime = function(isShow) {
|
||||
var disp = isShow ? '' : 'none';
|
||||
this.showTime = isShow;
|
||||
if (this.layer) {
|
||||
this._timeRow.style.display = disp;
|
||||
this._timeSep.style.display = disp;
|
||||
}
|
||||
};
|
||||
|
||||
bobj.crv.Calendar.setDate = function(date) {
|
||||
this.date = date;
|
||||
if (this.layer) {
|
||||
this._timeField.setValue(bobj.external.date.formatDate(this.date, this._curTimeFormat));
|
||||
this._update();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Show the calendar. Will write out the HTML and init the widget also.
|
||||
*
|
||||
* @param isShow [bool] Show calendar if true. Hide it if false.
|
||||
* @param x [int] x coordinate for left of calendar
|
||||
* @param y [int] y coordinate for top of calendar
|
||||
* @param isAlignRight [bool, optional] When true, the x coordinate applies to
|
||||
* the right edge of the calendar
|
||||
* @param isAlignBottom [bool, optional] When true, the y coordinate applies to
|
||||
* the bottom edge of the calendar
|
||||
*/
|
||||
bobj.crv.Calendar.show = function(isShow, x, y, isAlignRight, isAlignBottom) {
|
||||
ScrollMenuWidget_show.call(this, isShow, x, y);
|
||||
if(isShow) {
|
||||
this.focus();
|
||||
}
|
||||
else {
|
||||
MochiKit.Signal.signal(this, this.Signals.ON_HIDE);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Set focus on the Calendar. The currently selected day will receive focus.
|
||||
*/
|
||||
bobj.crv.Calendar.focus = function() {
|
||||
if (this._selectedDay) {
|
||||
this._selectedDay.focus();
|
||||
}
|
||||
};
|
||||
8
crystalreportviewers13/js/crviewer/Colors.js
Normal file
@@ -0,0 +1,8 @@
|
||||
if (typeof bobj == 'undefined') {
|
||||
bobj = {};
|
||||
};
|
||||
|
||||
bobj.Colors = {
|
||||
BLACK :'#000000',
|
||||
GRAY :'#a5a5a5'
|
||||
};
|
||||
930
crystalreportviewers13/js/crviewer/Dialogs.js
Normal file
@@ -0,0 +1,930 @@
|
||||
/* Copyright (c) Business Objects 2006. All rights reserved. */
|
||||
|
||||
if (typeof bobj.crv.PrintUI == 'undefined') {
|
||||
bobj.crv.PrintUI = {};
|
||||
}
|
||||
|
||||
if (typeof bobj.crv.ExportUI == 'undefined') {
|
||||
bobj.crv.ExportUI = {};
|
||||
}
|
||||
|
||||
if (typeof bobj.crv.ErrorDialog == 'undefined') {
|
||||
bobj.crv.ErrorDialog = {};
|
||||
}
|
||||
|
||||
if (typeof bobj.crv.ReportProcessingUI == 'undefined') {
|
||||
bobj.crv.ReportProcessingUI = {};
|
||||
}
|
||||
|
||||
/*
|
||||
================================================================================
|
||||
PrintUI
|
||||
================================================================================
|
||||
*/
|
||||
|
||||
bobj.crv.newPrintUI = function(kwArgs) {
|
||||
if (!kwArgs.id) {
|
||||
kwArgs = MochiKit.Base.update({id: bobj.uniqueId()}, kwArgs);
|
||||
}
|
||||
|
||||
var lbl = kwArgs.submitBtnLabel;
|
||||
if (!lbl) {
|
||||
lbl = L_bobj_crv_submitBtnLbl;
|
||||
}
|
||||
|
||||
var infoTitle = kwArgs.infoTitle;
|
||||
if (!infoTitle) {
|
||||
infoTitle = L_bobj_crv_PrintInfoTitle;
|
||||
}
|
||||
|
||||
var dialogTitle = kwArgs.dialogTitle;
|
||||
if (!dialogTitle) {
|
||||
if (kwArgs.isActxPrinting) {
|
||||
dialogTitle = L_bobj_crv_ActiveXPrintDialogTitle;
|
||||
}
|
||||
else {
|
||||
dialogTitle = L_bobj_crv_PDFPrintDialogTitle;
|
||||
}
|
||||
}
|
||||
|
||||
var infoMsg = kwArgs.infoMsg;
|
||||
if (!infoMsg) {
|
||||
infoMsg = L_bobj_crv_PrintInfo1;
|
||||
infoMsg += '\n';
|
||||
infoMsg += L_bobj_crv_PrintInfo2;
|
||||
}
|
||||
|
||||
var o = newDialogBoxWidget(kwArgs.id + '_dialog',
|
||||
dialogTitle,
|
||||
300,
|
||||
100,
|
||||
null,
|
||||
bobj.crv.PrintUI._cancel,
|
||||
false);
|
||||
o.infoMsg = infoMsg;
|
||||
o.infoTitle = infoTitle;
|
||||
o.actxId = o.id + '_actx';
|
||||
o.actxContainerId = o.id + '_actxdiv';
|
||||
o._processingPrinting = false;
|
||||
o._initOld = o.init;
|
||||
o._showOld = o.show;
|
||||
|
||||
if (!kwArgs.isActxPrinting) {
|
||||
o._fromBox = newIntFieldWidget(o.id + "_fromBox",
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
true,
|
||||
'',
|
||||
50);
|
||||
o._fromBox.setDisabled = bobj.crv.PrintUI.disabledTextFieldWidget;
|
||||
o._toBox = newIntFieldWidget(o.id + "_toBox",
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
true,
|
||||
'',
|
||||
50);
|
||||
o._toBox.setDisabled = bobj.crv.PrintUI.disabledTextFieldWidget;
|
||||
|
||||
o._submitBtn = newButtonWidget(o.id + "_submitBtn",
|
||||
lbl,
|
||||
MochiKit.Base.bind(bobj.crv.PrintUI._submitBtnCB, o));
|
||||
|
||||
o._submitBtn.setDelayCallback(false);
|
||||
o._allRadio = newRadioWidget(o.id + "_allRadio",
|
||||
o.id + "_grp",
|
||||
L_bobj_crv_PrintAllLbl,
|
||||
MochiKit.Base.bind(bobj.crv.PrintUI.disabledPageRange ,o, true));
|
||||
|
||||
o._allRadio.layerClass= "dlgContent";
|
||||
|
||||
o._rangeRadio = newRadioWidget(o.id + "_rangeRadio",
|
||||
o.id + "_grp",
|
||||
L_bobj_crv_PrintPagesLbl,
|
||||
MochiKit.Base.bind(bobj.crv.PrintUI.disabledPageRange ,o, false));
|
||||
|
||||
o._rangeRadio.layerClass= "dlgContent";
|
||||
}
|
||||
|
||||
o.widgetType = 'PrintUI';
|
||||
|
||||
// Update instance with constructor arguments
|
||||
bobj.fillIn(o, kwArgs);
|
||||
|
||||
// Update instance with member functions
|
||||
MochiKit.Base.update(o, bobj.crv.PrintUI);
|
||||
|
||||
return o;
|
||||
};
|
||||
bobj.crv.PrintUI.disabledTextFieldWidget = function(disabled)
|
||||
{
|
||||
TextFieldWidget_setDisabled.call(this,disabled);
|
||||
|
||||
if(disabled)
|
||||
{
|
||||
MochiKit.DOM.addElementClass(this.layer, "textDisabled");
|
||||
}
|
||||
else {
|
||||
MochiKit.DOM.removeElementClass(this.layer, "textDisabled");
|
||||
}
|
||||
}
|
||||
|
||||
bobj.crv.PrintUI.disabledPageRange = function(bool)
|
||||
{
|
||||
if(this._fromBox && this._toBox)
|
||||
{
|
||||
this._fromBox.setDisabled(bool);
|
||||
this._toBox.setDisabled(bool);
|
||||
}
|
||||
}
|
||||
|
||||
bobj.crv.PrintUI._submitBtnCB = function() {
|
||||
var start = null;
|
||||
var end = null;
|
||||
if (this._rangeRadio.isChecked()) {
|
||||
start = parseInt(this._fromBox.getValue(), 10);
|
||||
end = parseInt(this._toBox.getValue(), 10);
|
||||
|
||||
if (!start || !end || (start < 0) || (start > end)) {
|
||||
alert(L_bobj_crv_PrintPageRangeError);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.widgetType == 'PrintUI') {
|
||||
MochiKit.Signal.signal(this, 'printSubmitted', start, end);
|
||||
}
|
||||
else {
|
||||
MochiKit.Signal.signal(this, 'exportSubmitted', start, end, this._comboBox.getSelection().value);
|
||||
}
|
||||
|
||||
this.show(false);
|
||||
};
|
||||
|
||||
bobj.crv.PrintUI._getRPSafeURL = function(url) {
|
||||
if (!url) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (url.indexOf('/') === 0) {
|
||||
return url;
|
||||
}
|
||||
|
||||
var winLoc = window.location.href;
|
||||
|
||||
var qPos = winLoc.lastIndexOf('?');
|
||||
if (qPos > 0) {
|
||||
winLoc = winLoc.substring(0, qPos)
|
||||
}
|
||||
|
||||
var lPos = winLoc.lastIndexOf('/');
|
||||
|
||||
if (lPos < 0) {
|
||||
return url;
|
||||
}
|
||||
|
||||
winLoc = winLoc.substring(0, lPos);
|
||||
return winLoc + '/' + url;
|
||||
};
|
||||
|
||||
bobj.crv.PrintUI._getObjectTag = function(postData) {
|
||||
var oa = [];
|
||||
|
||||
oa.push('<OBJECT width="0" height="0" ID="');
|
||||
oa.push(this.actxId);
|
||||
oa.push('" CLASSID="CLSID:');
|
||||
oa.push(bobj.crv.ActxPrintControl_CLSID);
|
||||
oa.push('" CODEBASE="');
|
||||
oa.push(this._getRPSafeURL(this.codeBase));
|
||||
oa.push('#Version=');
|
||||
oa.push(bobj.crv.ActxPrintControl_Version);
|
||||
oa.push('" VIEWASTEXT>');
|
||||
|
||||
oa.push('<PARAM NAME="PostBackData" VALUE="');
|
||||
oa.push(postData);
|
||||
oa.push('">');
|
||||
|
||||
oa.push('<PARAM NAME="ServerResourceVersion" VALUE="');
|
||||
oa.push(bobj.crv.ActxPrintControl_Version);
|
||||
oa.push('">');
|
||||
|
||||
if (this.lcid) {
|
||||
oa.push('<PARAM NAME="LocaleID" VALUE="');
|
||||
oa.push(this.lcid);
|
||||
oa.push('">');
|
||||
}
|
||||
|
||||
if (this.url) {
|
||||
oa.push('<PARAM NAME="URL" VALUE="');
|
||||
oa.push(this._getRPSafeURL(this.url));
|
||||
oa.push('">');
|
||||
}
|
||||
|
||||
if (this.title) {
|
||||
oa.push('<PARAM NAME="Title" VALUE="');
|
||||
oa.push(this.title);
|
||||
oa.push('">');
|
||||
}
|
||||
|
||||
if (this.maxPage) {
|
||||
oa.push('<PARAM NAME="MaxPageNumber" VALUE="');
|
||||
oa.push(this.maxPage);
|
||||
oa.push('">');
|
||||
}
|
||||
|
||||
if (this.paperOrientation) {
|
||||
oa.push('<PARAM NAME="PageOrientation" VALUE="');
|
||||
oa.push(this.paperOrientation);
|
||||
oa.push('">');
|
||||
}
|
||||
|
||||
if (this.paperSize) {
|
||||
oa.push('<PARAM NAME="PaperSize" VALUE="');
|
||||
oa.push(this.paperSize);
|
||||
oa.push('">');
|
||||
}
|
||||
|
||||
if (this.paperWidth) {
|
||||
oa.push('<PARAM NAME="PaperWidth" VALUE="');
|
||||
oa.push(this.paperWidth);
|
||||
oa.push('">');
|
||||
}
|
||||
|
||||
if (this.paperLength) {
|
||||
oa.push('<PARAM NAME="PaperLength" VALUE="');
|
||||
oa.push(this.paperLength);
|
||||
oa.push('">');
|
||||
}
|
||||
|
||||
if (this.driverName) {
|
||||
oa.push('<PARAM NAME="PrinterDriverName" VALUE="');
|
||||
oa.push(this.driverName);
|
||||
oa.push('">');
|
||||
}
|
||||
|
||||
if (this.useDefPrinter) {
|
||||
oa.push('<PARAM NAME="UseDefaultPrinter" VALUE="');
|
||||
oa.push(this.useDefPrinter);
|
||||
oa.push('">');
|
||||
}
|
||||
|
||||
if (this.useDefPrinterSettings) {
|
||||
oa.push('<PARAM NAME="UseDefaultPrinterSettings" VALUE="');
|
||||
oa.push(this.useDefPrinterSettings);
|
||||
oa.push('">');
|
||||
}
|
||||
|
||||
if (this.sendPostDataOnce) {
|
||||
oa.push('<PARAM NAME="SendPostDataOnce" VALUE="');
|
||||
oa.push(this.sendPostDataOnce);
|
||||
oa.push('">');
|
||||
}
|
||||
oa.push('</OBJECT>');
|
||||
|
||||
// Add waiting UI while the control is loading
|
||||
oa.push('<table id="')
|
||||
oa.push(this.actxId);
|
||||
oa.push('_wait" border="0" cellspacing="0" cellpadding="0" width="100%" ><tbody>');
|
||||
oa.push('<tr><td align="center" valign="top">');
|
||||
|
||||
// Frame Zone
|
||||
var o = this;
|
||||
var zoneW=o.getContainerWidth()-10;
|
||||
var zoneH=o.getContainerHeight()-(2*o.pad+21+10);
|
||||
oa.push('<table style="');
|
||||
oa.push(sty("width",zoneW));
|
||||
oa.push(sty("height",zoneH));
|
||||
oa.push('" id="frame_table_');
|
||||
oa.push(o.id);
|
||||
oa.push('" cellspacing="0" cellpadding="0" border="0"><tbody><tr><td valign="top" class="dlgFrame" style="padding:5px" id="frame_cont_');
|
||||
oa.push(o.id);
|
||||
oa.push('">');
|
||||
|
||||
oa.push('<table border="0" cellspacing="0" cellpadding="0" width="100%"><tbody>');
|
||||
oa.push('<tr><td align="center" style="padding-top:5px;">');
|
||||
oa.push(img(_skin+'wait01.gif',200,40));
|
||||
oa.push('</td></tr>');
|
||||
oa.push('<tr><td align="left" style="padding-left:2px;padding-right:2px;padding-top:5px;">');
|
||||
oa.push('<div class="icontext" style="wordWrap:break_word;">');
|
||||
oa.push(convStr(L_bobj_crv_PrintControlProcessingMessage,false,true));
|
||||
oa.push('</div></td></tr></tbody></table>');
|
||||
|
||||
oa.push('</td></tr></tbody></table>');
|
||||
|
||||
oa.push('</td></tr></tbody></table>');
|
||||
|
||||
return oa.join('');
|
||||
};
|
||||
|
||||
bobj.crv.PrintUI._cancel = function () {
|
||||
if (this.isActxPrinting) {
|
||||
document.getElementById(this.actxContainerId).innerHTML = '';
|
||||
this._processingPrinting = false;
|
||||
}
|
||||
};
|
||||
|
||||
bobj.crv.PrintUI._processPrinting = function(){
|
||||
if (!this._processingPrinting){
|
||||
var o = document.getElementById(this.actxId);
|
||||
var w = document.getElementById(this.actxId + '_wait');
|
||||
if (o && w){
|
||||
o.width = "100%";
|
||||
o.height = "100%";
|
||||
w.style.display="none";
|
||||
}
|
||||
this._processingPrinting = true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
bobj.crv.PrintUI.show = function(visible, postBackData) {
|
||||
this._processingPrinting = false;
|
||||
if (visible) {
|
||||
if (!this.layer) {
|
||||
targetApp(this.getHTML());
|
||||
this.init();
|
||||
}
|
||||
if (this.isActxPrinting) {
|
||||
document.getElementById(this.actxContainerId).innerHTML = this._getObjectTag(postBackData);
|
||||
}
|
||||
this._showOld(true);
|
||||
}
|
||||
else if (this.layer) {
|
||||
this._showOld(false);
|
||||
}
|
||||
};
|
||||
|
||||
bobj.crv.PrintUI.init = function() {
|
||||
this._initOld();
|
||||
|
||||
if (!this.isActxPrinting) {
|
||||
this._fromBox.init();
|
||||
this._toBox.init();
|
||||
this._submitBtn.init();
|
||||
|
||||
this._allRadio.init();
|
||||
this._rangeRadio.init();
|
||||
|
||||
this._allRadio.check(true);
|
||||
this._toBox.setDisabled(true);
|
||||
this._fromBox.setDisabled(true);
|
||||
|
||||
if (this.widgetType == 'ExportUI') {
|
||||
this._updateExportList();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
bobj.crv.PrintUI.getHTML = function(){
|
||||
var h = bobj.html;
|
||||
var o = this;
|
||||
|
||||
var html = o.beginHTML();
|
||||
|
||||
if (!this.isActxPrinting) {
|
||||
html += "<table cellspacing=0 cellpadding=0 border=0>" +
|
||||
"<tr>" +
|
||||
"<td>" +
|
||||
"<div class='dlgFrame'>" +
|
||||
"<table cellspacing=0 cellpadding=0 border=0 style='height:" + (this.height * 0.9) +"px;width:" + this.width + "px;'>" +
|
||||
"<tr>" +
|
||||
"<td valign='top' class='naviBarFrame naviFrame'>" +
|
||||
(this.isExporting ? this._getExportList() : "") +
|
||||
"<fieldset style='border:0px;padding:0px'>" +
|
||||
"<legend style='position:relative;"+(_ie?"margin:0px -7px":"")+"'>" +
|
||||
"<table datatable='0' style='width:100%;line-height:10px;'>" +
|
||||
"<tr>" +
|
||||
(_ie?"<td class='dialogTitleLevel2'><label>":"<td class='dialogTitleLevel2'><label>") +
|
||||
L_bobj_crv_PrintRangeLbl + "</label></td>" +
|
||||
"</tr>" +
|
||||
"</table>" +
|
||||
"</legend>" +
|
||||
"<div style='margin:10px 25px;'>" +
|
||||
o._allRadio.getHTML() +
|
||||
o._rangeRadio.getHTML() +
|
||||
"<div style='padding-left:25px'>" +
|
||||
"<table class=dlgContent datatable='0'>" +
|
||||
"<tr>" +
|
||||
"<td align=right>" +
|
||||
"<label for='" + o._fromBox.id + "'> " + L_bobj_crv_PrintFromLbl + "</label>" +
|
||||
"</td>" +
|
||||
"<td align=left> " +
|
||||
o._fromBox.getHTML() +
|
||||
"</td>" +
|
||||
"</tr>" +
|
||||
"<tr>" +
|
||||
"<td align=right>" +
|
||||
"<label for='" + o._toBox.id + "'> " + L_bobj_crv_PrintToLbl + "</label>" +
|
||||
"</td>" +
|
||||
"<td align=left>" +
|
||||
o._toBox.getHTML() +
|
||||
"</td>" +
|
||||
"</tr>" +
|
||||
"</table>" +
|
||||
"</div>" +
|
||||
"</div>" +
|
||||
"</fieldset>" +
|
||||
(!this.isExporting ?
|
||||
"<table style='width:100%;line-height:10px;'>" +
|
||||
"<tr>" +
|
||||
"<td class='dialogTitleLevel2' tabIndex=0><label>" + this.infoTitle + "</label></td>" +
|
||||
"</tr>" +
|
||||
"</table>" +
|
||||
"<div style='margin:10px 0px 10px 25px;' class='dlgHelpText'>" +
|
||||
this.infoMsg +
|
||||
"</div>"
|
||||
: '') +
|
||||
"</td>" +
|
||||
"</tr>" +
|
||||
"</table>" +
|
||||
"</div>" +
|
||||
"</td>" +
|
||||
"</tr>" +
|
||||
"<tr>" +
|
||||
"<td align='right' valign='top'>" +
|
||||
"<table style='margin:6px 9px 0px 0px' cellspacing=0 cellpadding=0 border=0><tbody><tr>" +
|
||||
"<td>" +
|
||||
this._submitBtn.getHTML() +
|
||||
"</td></tbody></tr>" +
|
||||
"</table>" +
|
||||
"</td>" +
|
||||
"</tr>" +
|
||||
"</table>";
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
html += "<div id='" + this.actxContainerId + "'></div>" +
|
||||
'<script for="' + this.actxId + '" EVENT="Finished(status, statusText)" language="javascript">' +
|
||||
'getWidgetFromID("' + this.id + '").show(false);' +
|
||||
'</script>' +
|
||||
'<script for="' + this.actxId + '" EVENT="PrintingProgress(pageNumber)" language="javascript">' +
|
||||
'getWidgetFromID("' + this.id + '")._processPrinting();' +
|
||||
'</script>' ;
|
||||
}
|
||||
|
||||
html += o.endHTML();
|
||||
html += bobj.crv.getInitHTML(this.widx);
|
||||
|
||||
return html;
|
||||
};
|
||||
|
||||
/*
|
||||
================================================================================
|
||||
ExportUI
|
||||
================================================================================
|
||||
*/
|
||||
bobj.crv.newExportUI = function(kwArgs) {
|
||||
kwArgs = MochiKit.Base.update({ submitBtnLabel:L_bobj_crv_ExportBtnLbl,
|
||||
dialogTitle:L_bobj_crv_ExportDialogTitle,
|
||||
infoTitle:L_bobj_crv_ExportInfoTitle,
|
||||
infoMsg:L_bobj_crv_PrintInfo1,
|
||||
isExporting:true}, kwArgs);
|
||||
|
||||
var o = bobj.crv.newPrintUI(kwArgs);
|
||||
|
||||
o._comboBox = newCustomCombo(
|
||||
o.id + "_combo",
|
||||
MochiKit.Base.bind(bobj.crv.ExportUI._onSelectFormat, o),
|
||||
false,
|
||||
270,
|
||||
L_bobj_crv_ExportFormatLbl,
|
||||
_skin + "../transp.gif", // Screen reader can't read its text without transp.gif
|
||||
0,
|
||||
14);
|
||||
|
||||
//Adjustment to combo box after adding transp.gif as icon
|
||||
if(o._comboBox) {
|
||||
o._comboBox.icon.border=0;
|
||||
o._comboBox.icon.h=14;
|
||||
o._comboBox.arrow.h=12;
|
||||
o._comboBox.arrow.dy+=2
|
||||
o._comboBox.arrow.disDy+=2
|
||||
}
|
||||
|
||||
o.widgetType = 'ExportUI';
|
||||
MochiKit.Base.update(o, bobj.crv.ExportUI);
|
||||
|
||||
return o;
|
||||
};
|
||||
|
||||
bobj.crv.ExportUI._onSelectFormat = function() {
|
||||
var format = this._comboBox.getSelection().value;
|
||||
if (format == 'CrystalReports' || format == 'RPTR' || format == 'RecordToMSExcel' || format == 'RecordToMSExcel2007' || format == 'CharacterSeparatedValues' || format == 'XML') {
|
||||
this._fromBox.setDisabled(true);
|
||||
this._toBox.setDisabled(true);
|
||||
|
||||
this._rangeRadio.check(false);
|
||||
this._rangeRadio.setDisabled(true);
|
||||
|
||||
this._allRadio.check(true);
|
||||
}
|
||||
else {
|
||||
this._rangeRadio.setDisabled(false);
|
||||
}
|
||||
};
|
||||
|
||||
bobj.crv.ExportUI.update = function (update) {
|
||||
if (!update || update.cons !== "bobj.crv.newExportUI") {
|
||||
return;
|
||||
}
|
||||
|
||||
this.availableFormats = update.args.availableFormats;
|
||||
|
||||
if(this._comboBox.initialized()) {
|
||||
/*
|
||||
* Uninitialized combobox is not required to be updated as it will
|
||||
* be updated during initialization
|
||||
*/
|
||||
this._updateExportList();
|
||||
}
|
||||
};
|
||||
|
||||
bobj.crv.ExportUI._updateExportList = function() {
|
||||
if(!this._comboBox.initialized()) {
|
||||
this._comboBox.init();
|
||||
}
|
||||
|
||||
this._updateComboItems();
|
||||
|
||||
var item0 = this._comboBox.getItemByIndex(0);
|
||||
if(item0 != null)
|
||||
this._comboBox.selectItem(item0);
|
||||
|
||||
this._onSelectFormat();
|
||||
};
|
||||
|
||||
bobj.crv.ExportUI._updateComboItems = function () {
|
||||
this._comboBox.removeAllMenuItems();
|
||||
var itemsCount = (bobj.isArray(this.availableFormats) ? this.availableFormats.length : 0);
|
||||
|
||||
for (var i = 0; i < itemsCount; i++) {
|
||||
var item = this.availableFormats[i];
|
||||
this._comboBox.add(item.name, item.value, item.isSelected);
|
||||
}
|
||||
};
|
||||
|
||||
bobj.crv.ExportUI._getExportList = function() {
|
||||
return "<table datatable='0' style='width:100%;line-height:10px;'>" +
|
||||
"<tr>" +
|
||||
(_ie?"<td class='dialogTitleLevel2'><label>":"<td class='dialogTitleLevel2'><label>") +
|
||||
L_bobj_crv_ExportFormatLbl + "</label></td>" +
|
||||
"</tr>" +
|
||||
"</table>" +
|
||||
"<div style='margin:10px 25px;'>" +
|
||||
this._comboBox.getHTML() +
|
||||
"</div>";
|
||||
};
|
||||
|
||||
/*
|
||||
================================================================================
|
||||
ErrorDialog
|
||||
|
||||
TODO Dave: If time permits, make dialog resizable with mouse
|
||||
================================================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* Static function.
|
||||
* @returns [ErrorDialog] Returns a shared Error Dialog
|
||||
*/
|
||||
bobj.crv.ErrorDialog.getInstance = function() {
|
||||
if (!bobj.crv.ErrorDialog.__instance) {
|
||||
bobj.crv.ErrorDialog.__instance = bobj.crv.newErrorDialog();
|
||||
}
|
||||
return bobj.crv.ErrorDialog.__instance;
|
||||
};
|
||||
|
||||
bobj.crv.newErrorDialog = function(kwArgs) {
|
||||
kwArgs = MochiKit.Base.update({
|
||||
id: bobj.uniqueId(),
|
||||
title: L_bobj_crv_Error,
|
||||
text: null,
|
||||
detailText: null,
|
||||
okLabel: L_bobj_crv_OK,
|
||||
promptType: _promptDlgCritical
|
||||
}, kwArgs);
|
||||
|
||||
var o = newPromptDialog(
|
||||
kwArgs.id,
|
||||
kwArgs.title,
|
||||
kwArgs.text,
|
||||
kwArgs.okLabel,
|
||||
null, // cancelLabel
|
||||
kwArgs.promptType,
|
||||
null, // yesCB
|
||||
null, // noCB,
|
||||
true, // noCloseButton
|
||||
true); // isAlert
|
||||
|
||||
o.widgetType = 'ErrorDialog';
|
||||
|
||||
// Update instance with constructor arguments
|
||||
bobj.fillIn(o, kwArgs);
|
||||
|
||||
// Update instance with member functions
|
||||
o._promptDlgInit = o.init;
|
||||
o._promptDialogSetText = o.setText;
|
||||
o._promptDialogShow = o.show;
|
||||
o._promptDialogSetTitle = o.setTitle;
|
||||
o._promptDialogSetPromptType = o.setPromptType;
|
||||
MochiKit.Base.update(o, bobj.crv.ErrorDialog);
|
||||
|
||||
o.noCB = MochiKit.Base.bind(o._onClose, o);
|
||||
o.yesCB = o.noCB;
|
||||
|
||||
o._detailBtn = newIconWidget(
|
||||
o.id + "_detailBtn",
|
||||
bobj.skinUri('../help.gif'),
|
||||
MochiKit.Base.bind(bobj.crv.ErrorDialog._onDetailBtnClick, o),
|
||||
L_bobj_crv_showDetails, // Text
|
||||
L_bobj_crv_showDetails, // Tooltip
|
||||
16,16,0,0,22,0,
|
||||
true); // Tabbing is enabled
|
||||
|
||||
return o;
|
||||
};
|
||||
|
||||
bobj.crv.ErrorDialog.init = function() {
|
||||
this._promptDlgInit();
|
||||
this._detailBtn.init();
|
||||
this._detailRow = document.getElementById(this.id + '_detRow');
|
||||
this._detailArea = document.getElementById(this.id + '_detArea');
|
||||
|
||||
if (!this.detailText) {
|
||||
this._detailBtn.show(false);
|
||||
}
|
||||
};
|
||||
|
||||
bobj.crv.ErrorDialog.getHTML = function() {
|
||||
var TABLE = bobj.html.TABLE;
|
||||
var TBODY = bobj.html.TBODY;
|
||||
var TR = bobj.html.TR;
|
||||
var TD = bobj.html.TD;
|
||||
var PRE = bobj.html.PRE;
|
||||
var DIV = bobj.html.DIV;
|
||||
|
||||
var imgPath = PromptDialog_getimgPath(this.promptType);
|
||||
var imgAlt = PromptDialog_getimgAlt(this.promptType);
|
||||
|
||||
var width = "320";
|
||||
var detailWidth = "300px";
|
||||
var detailHeight = "100px";
|
||||
|
||||
var contentHTML =
|
||||
TABLE({'class':"dlgBody", width: width, cellpadding:"0", cellspacing:"5", border:"0"},
|
||||
TBODY(null,
|
||||
TR(null, TD(null,
|
||||
TABLE({'class':"dlgBody", cellpadding:"5", cellspacing:"0", border:"0"},
|
||||
TBODY(null,
|
||||
TR(null,
|
||||
TD({align:"right", width:"32"},
|
||||
img(imgPath, 32, 32, null, 'id="dlg_img_' + this.id + '"', imgAlt)),
|
||||
TD(),
|
||||
TD({id:"dlg_txt_" + this.id, align:"left"},
|
||||
DIV({tabindex:"0"}, convStr(this.text, false, true)))))))),
|
||||
TR({id: this.id + '_detRow', style: {display: "none"}},
|
||||
TD(null, DIV({'class': "infozone", style: {width: detailWidth, 'height': detailHeight, overflow: "auto"}},
|
||||
PRE({id: this.id + '_detArea'}, this.detailText)))),
|
||||
TR(null, TD(null, getSep())),
|
||||
TR(null, TD(null,
|
||||
TABLE({cellpadding:"5", cellspacing:"0", border:"0", width:"100%"},
|
||||
TBODY(null,
|
||||
TR(null,
|
||||
TD({align:"left"}, this._detailBtn.getHTML()),
|
||||
TD({align:"right"}, this.yes.getHTML()))))))));
|
||||
|
||||
|
||||
return this.beginHTML() + contentHTML + this.endHTML();
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the error message and detail text.
|
||||
*
|
||||
* @param text [String] Error message
|
||||
* @param detailText [String] Detailed error message or technical info
|
||||
*/
|
||||
bobj.crv.ErrorDialog.setText = function (text, detailText) {
|
||||
this.text = text;
|
||||
this.detailText = detailText;
|
||||
|
||||
if (this.layer) {
|
||||
this._promptDialogSetText(text || '');
|
||||
|
||||
if (this._detailArea) {
|
||||
this._detailArea.innerHTML = detailText || '';
|
||||
}
|
||||
|
||||
var showDetails = detailText ? true : false;
|
||||
this._detailBtn.show(showDetails);
|
||||
if (!showDetails) {
|
||||
this.showDetails(false);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
bobj.crv.ErrorDialog.setTitle = function (title) {
|
||||
this.title = title;
|
||||
if (this.layer) {
|
||||
this._promptDialogSetTitle(title || '');
|
||||
}
|
||||
};
|
||||
|
||||
bobj.crv.ErrorDialog.setPromptType = function (promptType) {
|
||||
this.promptType = promptType;
|
||||
if (this.layer) {
|
||||
this._promptDialogSetPromptType(promptType);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Show/Hide the dialog
|
||||
*
|
||||
* @param isShow [bool(=true)] True value displays the dialog, false hides it.
|
||||
* @param closeCB [function] Callback to call after the next close event
|
||||
*/
|
||||
bobj.crv.ErrorDialog.show = function(isShow, closeCB) {
|
||||
if (typeof isShow == 'undefined') {
|
||||
isShow = true;
|
||||
}
|
||||
|
||||
if (isShow) {
|
||||
this._closeCB = closeCB;
|
||||
if (!this.layer) {
|
||||
targetApp(this.getHTML());
|
||||
this.init();
|
||||
}
|
||||
this.layer.onkeyup = DialogBoxWidget_keypress;
|
||||
DialogBoxWidget_keypress = MochiKit.Base.noop;
|
||||
|
||||
this._promptDialogShow(true);
|
||||
}
|
||||
else if (this.layer){
|
||||
this._closeCB = null;
|
||||
this._promptDialogShow(false);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Show/Hide the detailed error message
|
||||
*
|
||||
* @param isShow [bool(=true)] True value displays the details, false hides them.
|
||||
*/
|
||||
bobj.crv.ErrorDialog.showDetails = function(isShow) {
|
||||
if (typeof isShow == 'undefined') {
|
||||
isShow = true;
|
||||
}
|
||||
|
||||
if (this._detailRow && this._detailBtn) {
|
||||
if (isShow) {
|
||||
this._detailRow.style.display = '';
|
||||
this._detailBtn.changeText(L_bobj_crv_hideDetails);
|
||||
}
|
||||
else {
|
||||
this._detailRow.style.display = 'none';
|
||||
this._detailBtn.changeText(L_bobj_crv_showDetails);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Private. Handles detail button clicks.
|
||||
*/
|
||||
bobj.crv.ErrorDialog._onDetailBtnClick = function() {
|
||||
if (this._detailRow) {
|
||||
this.showDetails(this._detailRow.style.display == 'none');
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Private. Notifies listener that dialog has closed;
|
||||
*/
|
||||
bobj.crv.ErrorDialog._onClose = function() {
|
||||
if (this._closeCB) {
|
||||
this._closeCB();
|
||||
this._closeCB = null;
|
||||
}
|
||||
DialogBoxWidget_keypress = this.layer.onkeyup;
|
||||
this.layer.onkeyup = null;
|
||||
};
|
||||
|
||||
/*
|
||||
================================================================================
|
||||
Report Processing Dialog
|
||||
================================================================================
|
||||
kwArgs
|
||||
delay - the wait time prior to showing the dialog.
|
||||
message - a customized message to display in the dialog.
|
||||
*/
|
||||
bobj.crv.newReportProcessingUI = function(kwArgs) {
|
||||
kwArgs = MochiKit.Base.update({
|
||||
id: bobj.uniqueId(),
|
||||
delay: 250,
|
||||
message: L_bobj_crv_ReportProcessingMessage
|
||||
}, kwArgs);
|
||||
|
||||
/* Since JSON escapes the '\' in unicode character references (\uXXXX) in Viewer
|
||||
* process indicator text is converted to html numeric referece (&#ddddd) which Javascript
|
||||
* don't display as expected. Little hack here to it as HTML string */
|
||||
var d = document.createElement('div');
|
||||
d.style.visibility = 'hidden';
|
||||
d.innerHTML = kwArgs.message;
|
||||
var newMsg = d.innerHTML;
|
||||
d = null;
|
||||
|
||||
var o = newWaitDialogBoxWidget(
|
||||
kwArgs.id, // id
|
||||
0, // width
|
||||
0, // height
|
||||
'', // title
|
||||
false, // show cancel
|
||||
bobj.crv.ReportProcessingUI.cancelCB, // cancel callback
|
||||
true, // show label
|
||||
newMsg, // label text
|
||||
true // no close button
|
||||
);
|
||||
|
||||
|
||||
o.widgetType = 'ReportProcessingUI';
|
||||
o.delay = kwArgs.delay;
|
||||
|
||||
// Update instance with member functions
|
||||
MochiKit.Base.update(o, bobj.crv.ReportProcessingUI);
|
||||
|
||||
return o;
|
||||
};
|
||||
|
||||
bobj.crv.reportProcessingDialog = null;
|
||||
bobj.crv.timerID = null;
|
||||
|
||||
bobj.crv.ReportProcessingUI.cancelCB = function ()
|
||||
{
|
||||
bobj.crv.reportProcessingDialog.cancelled = true;
|
||||
|
||||
if (bobj.crv.reportProcessingDialog.deferred !== null) {
|
||||
bobj.crv.reportProcessingDialog.deferred.cancel ();
|
||||
}
|
||||
|
||||
bobj.crv.reportProcessingDialog.cancelShow ();
|
||||
};
|
||||
|
||||
bobj.crv.ReportProcessingUI.wasCancelled = function ()
|
||||
{
|
||||
return bobj.crv.reportProcessingDialog.cancelled;
|
||||
};
|
||||
|
||||
bobj.crv.ReportProcessingUI._prepareToShow = function () {
|
||||
// cleanup any existing dialog?
|
||||
if (bobj.crv.reportProcessingDialog !== null) {
|
||||
bobj.crv.reportProcessingDialog.cancelShow ();
|
||||
}
|
||||
|
||||
if (!this.layer) {
|
||||
append2(document.body, this.getHTML());
|
||||
this.init();
|
||||
}
|
||||
|
||||
this.deferred = null;
|
||||
bobj.crv.reportProcessingDialog = this;
|
||||
};
|
||||
|
||||
bobj.crv.ReportProcessingUI.Show = function () {
|
||||
this._prepareToShow();
|
||||
bobj.crv.reportProcessingDialog.show(true);
|
||||
};
|
||||
|
||||
bobj.crv.ReportProcessingUI.delayedShow = function () {
|
||||
this._prepareToShow();
|
||||
bobj.crv.timerID = setTimeout("bobj.crv._showReportProcessingDialog ()", bobj.crv.reportProcessingDialog.delay);
|
||||
};
|
||||
|
||||
bobj.crv.ReportProcessingUI.cancelShow = function () {
|
||||
if (bobj.crv.timerID) {
|
||||
clearTimeout (bobj.crv.timerID);
|
||||
}
|
||||
|
||||
if (bobj.crv.reportProcessingDialog){
|
||||
bobj.crv.reportProcessingDialog.show (false);
|
||||
}
|
||||
|
||||
bobj.crv.reportProcessingDialog = null;
|
||||
bobj.crv.timerID = null;
|
||||
};
|
||||
|
||||
bobj.crv.ReportProcessingUI.setDeferred = function (deferred) {
|
||||
bobj.crv.reportProcessingDialog.deferred = deferred;
|
||||
|
||||
if (bobj.crv.reportProcessingDialog.wasCancelled () === true) {
|
||||
deferred.cancel ();
|
||||
}
|
||||
};
|
||||
|
||||
bobj.crv._showReportProcessingDialog = function () {
|
||||
if (bobj.crv.reportProcessingDialog && bobj.crv.reportProcessingDialog.delay !== 0) {
|
||||
bobj.crv.logger.info('ShowReportProcessingDialog');
|
||||
bobj.crv.reportProcessingDialog.show (true);
|
||||
}
|
||||
};
|
||||
270
crystalreportviewers13/js/crviewer/GroupTree.js
Normal file
@@ -0,0 +1,270 @@
|
||||
/*
|
||||
================================================================================
|
||||
GroupTree
|
||||
================================================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* GroupTree constructor.
|
||||
*
|
||||
* @param kwArgs.id [String] DOM node id
|
||||
* @param kwArgs.icns [String] URL to magnifying glass icon
|
||||
* @param kwArgs.minIcon [String] URL to min.gif
|
||||
* @param kwArgs.plusIcon [String] URL to plus.gif
|
||||
*/
|
||||
bobj.crv.newGroupTree = function(kwArgs) {
|
||||
var UPDATE = MochiKit.Base.update;
|
||||
kwArgs = UPDATE ( {
|
||||
id : bobj.uniqueId (),
|
||||
visualStyle : {
|
||||
className : null,
|
||||
backgroundColor : null,
|
||||
borderWidth : null,
|
||||
borderStyle : null,
|
||||
borderColor : null,
|
||||
fontFamily : null,
|
||||
fontWeight : null,
|
||||
textDecoration : null,
|
||||
color : null,
|
||||
width : null,
|
||||
height : null,
|
||||
fontStyle : null,
|
||||
fontSize : null
|
||||
},
|
||||
icns : bobj.crvUri ('images/magnify.gif'),
|
||||
minIcon : bobj.crvUri ('images/min.gif'),
|
||||
plusIcon : bobj.crvUri ('images/plus.gif')
|
||||
}, kwArgs);
|
||||
|
||||
var o = newTreeWidget (kwArgs.id + '_tree', '100%', '100%', kwArgs.icns, null, null, 'groupTree',
|
||||
bobj.crv.GroupTree._expand, bobj.crv.GroupTree._collapse, null, kwArgs.minIcon, kwArgs.plusIcon);
|
||||
|
||||
o._children = [];
|
||||
o._modalChildren = [];
|
||||
o._lastNodeIdInitialized = -1;
|
||||
o._lastNodeInitialized = null;
|
||||
o._curSigs = [];
|
||||
bobj.fillIn (o, kwArgs);
|
||||
o.widgetType = 'GroupTree';
|
||||
o.initOld = o.init;
|
||||
|
||||
UPDATE (o, bobj.crv.GroupTree);
|
||||
|
||||
return o;
|
||||
};
|
||||
|
||||
bobj.crv.GroupTree = {
|
||||
/**
|
||||
* Disposes group tree
|
||||
*/
|
||||
dispose : function() {
|
||||
/* removes all the signals */
|
||||
while (this._curSigs.length > 0) {
|
||||
bobj.crv.SignalDisposer.dispose (this._curSigs.pop ());
|
||||
}
|
||||
|
||||
/* disposes all the children*/
|
||||
while (this._children.length > 0) {
|
||||
var child = this._children.pop ();
|
||||
child.dispose ();
|
||||
bobj.deleteWidget (child);
|
||||
delete child;
|
||||
}
|
||||
|
||||
this._lastNodeIdInitialized = -1;
|
||||
this._lastNodeInitialized = null;
|
||||
this.sub = [];
|
||||
bobj.removeAllChildElements(this.treeLyr);
|
||||
},
|
||||
|
||||
getModalChildren : function () {
|
||||
return this._modalChildren;
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds a child widget as a group tree node.
|
||||
*
|
||||
* @param widget
|
||||
* [Widget] Child tree node widget
|
||||
*/
|
||||
addChild : function(widget) {
|
||||
var Base = MochiKit.Base;
|
||||
var Signal = MochiKit.Signal;
|
||||
var connect = Signal.connect;
|
||||
|
||||
widget.expandPath = this._children.length + '';
|
||||
this._children.push (widget);
|
||||
|
||||
widget._updateProperty (this.enableDrilldown, this.enableNavigation);
|
||||
this.add (widget);
|
||||
widget.delayedAddChild (this.enableDrilldown, this.enableNavigation);
|
||||
|
||||
this._curSigs.push (connect (widget, 'grpDrilldown', Base.partial (Signal.signal, this, 'grpDrilldown')));
|
||||
this._curSigs.push (connect (widget, 'grpNodeRetrieveChildren', Base.partial (Signal.signal, this, 'grpNodeRetrieveChildren')));
|
||||
},
|
||||
|
||||
/**
|
||||
* Since GroupTree nodes are delay loaded, we would have to store the timeout ids to cancel them in case user drill down to another views
|
||||
*/
|
||||
delayedBatchAdd : function(children) {
|
||||
if (!children || children.length == 0)
|
||||
return;
|
||||
|
||||
this._modalChildren = children;
|
||||
var childrenHTML = "";
|
||||
|
||||
var numChildrenToRender = children.length > 100 ? 100 : children.length;
|
||||
if(numChildrenToRender > 0) {
|
||||
for(var i = 0 ; i < numChildrenToRender ; i++) {
|
||||
var child = bobj.crv.createWidget (this._modalChildren[i]);
|
||||
this.addChild(child);
|
||||
if(this.initialized())
|
||||
childrenHTML += child.getHTML(0);
|
||||
}
|
||||
}
|
||||
|
||||
if(this.initialized()) {
|
||||
this.appendChildrenHTML (childrenHTML);
|
||||
this.initChildren ();
|
||||
}
|
||||
},
|
||||
|
||||
appendChildrenHTML : function (childrenHTML) {
|
||||
append (this.treeLyr, childrenHTML);
|
||||
},
|
||||
|
||||
init : function() {
|
||||
this.initOld ();
|
||||
bobj.setVisualStyle (this.layer, this.visualStyle);
|
||||
this.css.verticalAlign = "top";
|
||||
|
||||
this.initChildren ();
|
||||
|
||||
this._groupTreeListener = new bobj.crv.GroupTreeListener(this);
|
||||
},
|
||||
|
||||
update : function(update) {
|
||||
if (update.cons == "bobj.crv.newGroupTree") {
|
||||
var args = update.args;
|
||||
var path = args.lastExpandedPath;
|
||||
/* if path specified, then update specific path, otherwise recreate grouptree */
|
||||
// if user has expands a node after session timeout -> the whole gt must be rerendered
|
||||
if (path.length > 0 && this._children.length > 0) {
|
||||
this.updateNode (path, update);
|
||||
} else {
|
||||
this.refreshChildNodes (update)
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
delayedAddChild : function(widget) {
|
||||
this.addChild (widget);
|
||||
append (this.treeLyr, widget.getHTML (this.initialIndent));
|
||||
},
|
||||
|
||||
initChildren : function () {
|
||||
while(this._lastNodeIdInitialized < this._children.length - 1)
|
||||
this.initNextChild ();
|
||||
},
|
||||
|
||||
initNextChild : function () {
|
||||
var nextNode = null;
|
||||
var nextNodeId = -1;
|
||||
if(this._lastNodeIdInitialized == -1) {
|
||||
var treeSpanLayer = getLayer("treeCont_" + this.id);
|
||||
nextNode = treeSpanLayer.firstChild;
|
||||
nextNodeId = 0;
|
||||
}
|
||||
else {
|
||||
nextNode = this._lastNodeInitialized.nextSibling;
|
||||
while(!(nextNode.id && nextNode.id.indexOf("TWe_") > -1))
|
||||
nextNode = nextNode.nextSibling;
|
||||
|
||||
nextNodeId = this._lastNodeIdInitialized + 1;
|
||||
}
|
||||
|
||||
if(nextNodeId < this._children.length && nextNode != null) {
|
||||
this._children[nextNodeId].init(nextNode);
|
||||
this._lastNodeInitialized = nextNode;
|
||||
this._lastNodeIdInitialized = nextNodeId;
|
||||
}
|
||||
},
|
||||
|
||||
getBestFitHeight : function () {
|
||||
return bobj.getHiddenElementDimensions (this.layer).h;
|
||||
/**
|
||||
* Since container of tree could be invisible, getHiddenElementDimensions has to be called
|
||||
* instead of element.getHeight()
|
||||
*/
|
||||
},
|
||||
|
||||
/**
|
||||
* refreshes group tree by removing all nodes and adding new ones
|
||||
*/
|
||||
refreshChildNodes : function(update) {
|
||||
this.dispose ();
|
||||
this.delayedBatchAdd (update.children);
|
||||
MochiKit.Signal.signal(this, "refreshed");
|
||||
},
|
||||
|
||||
/**
|
||||
* @param path
|
||||
* path to the node that should be updated eg) 0-1-2
|
||||
* @param newTree
|
||||
* the new tree sent in update
|
||||
*
|
||||
* Updates children of node specified by path
|
||||
*/
|
||||
updateNode : function(path, newTree) {
|
||||
if (path && path.length > 0) {
|
||||
var pathArray = path.split ('-');
|
||||
var node = this;
|
||||
var newNode = newTree;
|
||||
|
||||
/* Navigating to the node that requires update */
|
||||
for ( var i = 0, len = pathArray.length; i < len; i++) {
|
||||
if (node && newNode) {
|
||||
var childIndex = parseInt (pathArray[i]);
|
||||
newNode = newNode.children[childIndex];
|
||||
node = node._children[childIndex];
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* if we found the node that requires update, then update its children */
|
||||
if (node && newNode && newNode.args.groupPath == node.groupPath && node._children.length == 0) {
|
||||
for ( var nodeNum in newNode.children) {
|
||||
var newChildnode = bobj.crv.createWidget (newNode.children[nodeNum]);
|
||||
node.addChild (newChildnode);
|
||||
}
|
||||
|
||||
node.delayedAddChild (this.enableDrilldown, this.enableNavigation);
|
||||
node.expand ();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
getChildrenCount : function () {
|
||||
return this.sub.length;
|
||||
},
|
||||
|
||||
/**
|
||||
* Private. Callback function when a (complete) group tree node is collapsed.
|
||||
*/
|
||||
_collapse : function(expandPath) {
|
||||
MochiKit.Signal.signal (this, 'grpNodeCollapse', expandPath);
|
||||
},
|
||||
|
||||
/**
|
||||
* Private. Callback function when a (complete) group tree node is expanded.
|
||||
*/
|
||||
_expand : function(expandPath) {
|
||||
MochiKit.Signal.signal (this, 'grpNodeExpand', expandPath);
|
||||
},
|
||||
|
||||
resize : function(width, height) {
|
||||
bobj.setOuterSize (this.layer, width, height);
|
||||
MochiKit.Signal.signal(this, "resized");
|
||||
}
|
||||
};
|
||||
165
crystalreportviewers13/js/crviewer/GroupTreeListener.js
Normal file
@@ -0,0 +1,165 @@
|
||||
bobj.crv.GroupTreeListener = function(groupTree) {
|
||||
this._groupTree = groupTree;
|
||||
this._groupTreePrevState = this.getTreeState ();
|
||||
this._lastNodeRendererd = this.getNumberOfNodesRendered () - 1;
|
||||
this._nodeHeight = -1;
|
||||
this._futreNodesPlaceHolder = null;
|
||||
this.actionIDs = [];
|
||||
this.addFutureNodesPlaceHolder ();
|
||||
|
||||
MochiKit.Signal.connect(groupTree.layer, "onscroll", bobj.bindFunctionToObject(this.detectTreeChanges, this));
|
||||
MochiKit.Signal.connect(groupTree, "refreshed", this, this.reset);
|
||||
MochiKit.Signal.connect(groupTree, "resized", this, this.detectTreeChanges);
|
||||
};
|
||||
|
||||
bobj.crv.GroupTreeListener.prototype = {
|
||||
/**
|
||||
*
|
||||
* @return number of nodes rendered by group tree
|
||||
*/
|
||||
getNumberOfNodesRendered : function() {
|
||||
return this._groupTree.getChildrenCount ();
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
* @return number of nodes that have not been rendered yet
|
||||
*/
|
||||
getNumberOfNodesMissing : function() {
|
||||
return this._groupTree.getModalChildren ().length - this._lastNodeRendererd - 1;
|
||||
},
|
||||
|
||||
getTreeState : function() {
|
||||
var gt = this._groupTree;
|
||||
return {
|
||||
height :gt.getHeight (),
|
||||
scrollTop :gt.layer.scrollTop
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
* @return number of nodes required to be rendered to fill up the group tree height
|
||||
*/
|
||||
getNumberOfNodesToRender : function() {
|
||||
if (this.getNumberOfNodesMissing() == 0)
|
||||
return 0;
|
||||
|
||||
var lastNodeRendered = this._groupTree.sub[this._lastNodeRendererd];
|
||||
var treeNewState = this.getTreeState ();
|
||||
|
||||
if (lastNodeRendered != null) {
|
||||
var offsetY = lastNodeRendered.layer.offsetTop;
|
||||
if (offsetY < treeNewState.scrollTop + treeNewState.height) {
|
||||
var freeSpace = treeNewState.scrollTop + treeNewState.height - offsetY;
|
||||
return Math.floor (freeSpace / this.getNodeHeight ());
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
* @return a single node height
|
||||
*/
|
||||
getNodeHeight : function() {
|
||||
if (this._nodeHeight > -1)
|
||||
return this._nodeHeight;
|
||||
else if (this.getNumberOfNodesRendered () > 0) {
|
||||
var node = this._groupTree.sub[0];
|
||||
this._nodeHeight = bobj.getHiddenElementDimensions (node.layer).h;
|
||||
return this._nodeHeight;
|
||||
}
|
||||
|
||||
return 0;
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
* Adds as many nodes as it can to fill up the grouptree's height
|
||||
*/
|
||||
updateTreeChildren : function() {
|
||||
var numNodesToRender = this.getNumberOfNodesToRender ();
|
||||
var groupTreeModalChildren = this._groupTree.getModalChildren ();
|
||||
|
||||
if (numNodesToRender > 0) {
|
||||
var childrenHTML = "";
|
||||
for ( var i = this._lastNodeRendererd + 1, lastNode = this._lastNodeRendererd + numNodesToRender; i <= lastNode; i++) {
|
||||
var modalChild = groupTreeModalChildren[i];
|
||||
if (modalChild != null) {
|
||||
var treeNode = bobj.crv.createWidget (modalChild);
|
||||
this._groupTree.addChild (treeNode);
|
||||
childrenHTML += treeNode.getHTML(0);
|
||||
this._lastNodeRendererd = i;
|
||||
}
|
||||
}
|
||||
|
||||
this._groupTree.appendChildrenHTML(childrenHTML);
|
||||
this._groupTree.initChildren();
|
||||
}
|
||||
|
||||
this.updateFutureNodesPlaceHolderHeight ();
|
||||
},
|
||||
|
||||
/**
|
||||
* Detects if the tree UI has changed and calls update function
|
||||
*
|
||||
*/
|
||||
detectTreeChanges : function() {
|
||||
if (this.isTreeStateChanged ())
|
||||
this.actionIDs.push(setTimeout(bobj.bindFunctionToObject(this.updateTreeChildren, this), 200));
|
||||
|
||||
this._groupTreePrevState = this.getTreeState ();
|
||||
},
|
||||
|
||||
isTreeStateChanged : function() {
|
||||
var currentState = this.getTreeState ();
|
||||
if (currentState.height != this._groupTreePrevState.height)
|
||||
return true;
|
||||
if (currentState.scrollTop != this._groupTreePrevState.scrollTop)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
* Results listener's internal state when grouptree is refreshed
|
||||
*/
|
||||
reset : function() {
|
||||
this._groupTreePrevState = this.getTreeState ();
|
||||
this._lastNodeRendererd = this.getNumberOfNodesRendered () - 1;
|
||||
this.clearActions ();
|
||||
this.updateFutureNodesPlaceHolderHeight ();
|
||||
},
|
||||
|
||||
clearActions : function () {
|
||||
while(this.actionIDs.length > 0) {
|
||||
clearTimeout(this.actionIDs.pop());
|
||||
}
|
||||
},
|
||||
|
||||
updateFutureNodesPlaceHolderHeight : function() {
|
||||
var futurePlaceHolderLayer = this.getFutureNodesPlaceHolderLayer ();
|
||||
if (futurePlaceHolderLayer != null) {
|
||||
futurePlaceHolderLayer.style.height = (this.getNumberOfNodesMissing () * this.getNodeHeight ()) + "px";
|
||||
}
|
||||
},
|
||||
|
||||
getFutureNodesPlaceHolderLayer : function() {
|
||||
return this._futreNodesPlaceHolder;
|
||||
},
|
||||
|
||||
addFutureNodesPlaceHolder : function() {
|
||||
this._futreNodesPlaceHolder = MochiKit.DOM.DIV ( {
|
||||
id :bobj.uniqueId () + "_futureHolder",
|
||||
style : {
|
||||
width :'0px',
|
||||
height :(this.getNumberOfNodesMissing () * this.getNodeHeight ()) + "px"
|
||||
}
|
||||
});
|
||||
this._groupTree.layer.appendChild (this._futreNodesPlaceHolder);
|
||||
|
||||
}
|
||||
}
|
||||
203
crystalreportviewers13/js/crviewer/GroupTreeNode.js
Normal file
@@ -0,0 +1,203 @@
|
||||
/**
|
||||
* GroupTreeNode constructor.
|
||||
*
|
||||
* @param kwArgs.id [String] DOM node id
|
||||
* @param kwArgs.groupName [String] Name of the group
|
||||
* @param kwArgs.groupPath [String] Path of the group
|
||||
*/
|
||||
bobj.crv.newGroupTreeNode = function(kwArgs) {
|
||||
var UPDATE = MochiKit.Base.update;
|
||||
kwArgs = UPDATE ( {
|
||||
id : bobj.uniqueId ()
|
||||
}, kwArgs);
|
||||
var iconAlt = null;
|
||||
var iconId = -1; // by default, no icon
|
||||
if (!kwArgs.isVisible) {
|
||||
iconId = 0;
|
||||
iconAlt = L_bobj_crv_Tree_Drilldown_Node.replace ('%1', kwArgs.groupName);
|
||||
}
|
||||
|
||||
var o = newTreeWidgetElem (iconId, kwArgs.groupName, kwArgs.groupPath, null, null, null, iconAlt, null, null, false);
|
||||
|
||||
o._children = [];
|
||||
o._curSigs = [];
|
||||
bobj.fillIn (o, kwArgs);
|
||||
|
||||
o.widgetType = 'GroupTreeNode';
|
||||
o.initOld = o.init;
|
||||
o.selectOld = o.select;
|
||||
o.select = bobj.crv.GroupTreeNode._drilldown;
|
||||
|
||||
if (!kwArgs.isVisible) {
|
||||
o.setCursorClass('drill_cursor');
|
||||
}
|
||||
|
||||
UPDATE (o, bobj.crv.GroupTreeNode);
|
||||
|
||||
return o;
|
||||
};
|
||||
|
||||
bobj.crv.GroupTreeNode = {
|
||||
/**
|
||||
* Diposes grouptree node. Deletes all signals and children
|
||||
*/
|
||||
dispose : function() {
|
||||
while (this._curSigs.length > 0) {
|
||||
bobj.crv.SignalDisposer.dispose (this._curSigs.pop ());
|
||||
}
|
||||
|
||||
while (this._children.length > 0) {
|
||||
var child = this._children.pop ();
|
||||
child.dispose ();
|
||||
|
||||
bobj.deleteWidget (child);
|
||||
delete child;
|
||||
}
|
||||
|
||||
this.sub = [];
|
||||
|
||||
//layers of all GroupTreeNodes are disposed in GroupTree.dispose in one batch for performance reason
|
||||
},
|
||||
|
||||
init : function(layer) {
|
||||
this.initOld (layer);
|
||||
this._setVisualStyle ();
|
||||
|
||||
if (this.isStatic) {
|
||||
/*"treeNormal" is the default css class for tree node text */
|
||||
var spans = MochiKit.DOM.getElementsByTagAndClassName ("span", "treeNormal", this.layer);
|
||||
if (spans && spans.length > 0)
|
||||
spans[0].style.cursor = 'text';
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @return boolean true if node is expanded
|
||||
*/
|
||||
isExpanded : function() {
|
||||
var elemId = TreeIdToIdx (this.layer);
|
||||
return _TreeWidgetElemInstances[elemId].expanded;
|
||||
},
|
||||
|
||||
/**
|
||||
* expands node and shows its children
|
||||
*/
|
||||
|
||||
expand : function() {
|
||||
var elemId = TreeIdToIdx (this.layer);
|
||||
_TreeWidgetElemInstances[elemId].expanded = false
|
||||
TreeWidget_toggleCB (elemId);
|
||||
},
|
||||
|
||||
collapse : function() {
|
||||
var elemId = TreeIdToIdx (this.layer);
|
||||
_TreeWidgetElemInstances[elemId].expanded = true
|
||||
TreeWidget_toggleCB (elemId);
|
||||
},
|
||||
|
||||
_setVisualStyle : function() {
|
||||
try {
|
||||
var textNode = this.layer.lastChild;
|
||||
var parentNode = this.treeView;
|
||||
} catch (err) {
|
||||
return;
|
||||
}
|
||||
|
||||
var pvStyle = parentNode.visualStyle;
|
||||
var tStyle = textNode.style;
|
||||
|
||||
if (pvStyle.fontFamily)
|
||||
tStyle.fontFamily = pvStyle.fontFamily;
|
||||
|
||||
if (pvStyle.fontWeight)
|
||||
tStyle.fontWeight = pvStyle.fontWeight;
|
||||
|
||||
if (pvStyle.textDecoration)
|
||||
tStyle.textDecoration = pvStyle.textDecoration;
|
||||
|
||||
if (pvStyle.color)
|
||||
tStyle.color = pvStyle.color;
|
||||
|
||||
if (pvStyle.fontStyle)
|
||||
tStyle.fontStyle = pvStyle.fontStyle;
|
||||
|
||||
if (pvStyle.fontSize)
|
||||
tStyle.fontSize = pvStyle.fontSize;
|
||||
},
|
||||
|
||||
/**
|
||||
* Delay add the child nodes to a node recursively.
|
||||
* The addition of nodes has to happen in a top-down fashion because each node has a reference to the tree
|
||||
* and this reference is retrieved from the parent node.
|
||||
*/
|
||||
|
||||
delayedAddChild : function(enableDrilldown, enableNavigation) {
|
||||
var CONNECT = MochiKit.Signal.connect;
|
||||
var SIGNAL = MochiKit.Signal.signal;
|
||||
var PARTIAL = MochiKit.Base.partial;
|
||||
var childCount = this._children.length;
|
||||
|
||||
if (childCount > 0) {
|
||||
this.expanded = true;
|
||||
} else {
|
||||
this.expanded = false;
|
||||
if (!this.leaf) {
|
||||
this.setIncomplete (bobj.crv.GroupTreeNode._getChildren);
|
||||
}
|
||||
}
|
||||
|
||||
var children = this._children;
|
||||
for ( var i = 0; i < childCount; i++) {
|
||||
var childNode = children[i];
|
||||
childNode.expandPath = this.expandPath + '-' + i;
|
||||
childNode._updateProperty (enableDrilldown, enableNavigation);
|
||||
this.add (childNode);
|
||||
this._curSigs.push (CONNECT (childNode, 'grpDrilldown', PARTIAL (SIGNAL, this, 'grpDrilldown')));
|
||||
this._curSigs.push (CONNECT (childNode, 'grpNodeRetrieveChildren', PARTIAL (SIGNAL, this, 'grpNodeRetrieveChildren')));
|
||||
childNode.delayedAddChild (enableDrilldown, enableNavigation);
|
||||
}
|
||||
},
|
||||
|
||||
addChild : function(widget) {
|
||||
this._children.push (widget);
|
||||
},
|
||||
|
||||
getLevel : function() {
|
||||
return this.expandPath.split('-').length;
|
||||
},
|
||||
|
||||
/**
|
||||
* Private. Callback function when a group tree node is clicked, which is a group drilldown.
|
||||
*/
|
||||
_drilldown : function() {
|
||||
this.selectOld ();
|
||||
MochiKit.Signal.signal (this, 'grpDrilldown', this.groupName, this.groupPath, this.isVisible, this.groupNamePath);
|
||||
},
|
||||
|
||||
/**
|
||||
* Private. Callback function when an incomplete group tree node is expanded.
|
||||
*/
|
||||
_getChildren : function() {
|
||||
this.plusLyr.src = _skin + '../loading.gif';
|
||||
MochiKit.Signal.signal (this, 'grpNodeRetrieveChildren', this.expandPath);
|
||||
},
|
||||
|
||||
/**
|
||||
* Private. Change the select event handler and text style class based on the two given flags.
|
||||
*/
|
||||
_updateProperty : function(enableDrilldown, enableNavigation) {
|
||||
var isStatic = false;
|
||||
if (this.isVisible && !enableNavigation) {
|
||||
isStatic = true;
|
||||
} else if (!this.isVisible && !enableDrilldown) {
|
||||
isStatic = true;
|
||||
}
|
||||
|
||||
if (isStatic) {
|
||||
this.select = MochiKit.Base.noop;
|
||||
}
|
||||
|
||||
this.isStatic = isStatic;
|
||||
}
|
||||
};
|
||||
599
crystalreportviewers13/js/crviewer/IOAdapters.js
Normal file
@@ -0,0 +1,599 @@
|
||||
/* Copyright (c) Business Objects 2006. All rights reserved. */
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Abstract base class. IOAdapters allow the ViewerListener to request data from
|
||||
* a server without knowing the details of how a particular framework requires
|
||||
* the request to be made.
|
||||
*/
|
||||
bobj.crv.IOAdapterBase = {
|
||||
/**
|
||||
* Send a viewer request to the Server.
|
||||
*
|
||||
* @param pageState [Object] The composite view state for all viewers on the page
|
||||
* @param viewerName [String] The name of the viewer that should handle the request
|
||||
* @param eventArgs [Object] Event arguements
|
||||
* @param allowAsynch [bool] True if asynchronous requests are allowed
|
||||
*
|
||||
* @return [MochiKit.Async.Deferred] Returns a Deferred if an asynchronous
|
||||
* request is pending.
|
||||
*/
|
||||
request: function() {},
|
||||
|
||||
/**
|
||||
* Add a parameter to server requests.
|
||||
*
|
||||
* @param fldName [String] Name of the parameter
|
||||
* @param fldValue [String] Value of the parameter
|
||||
*/
|
||||
addRequestField: function(fldName, fldValue) {},
|
||||
|
||||
/**
|
||||
* Remove a parameter from server requests.
|
||||
*
|
||||
* @param fldName [String] Name of the parameter
|
||||
*/
|
||||
removeRequestField: function(fldName) {},
|
||||
|
||||
/**
|
||||
* Save the page state. Persist the state in a manner apropriate
|
||||
* for the framework.
|
||||
*
|
||||
* @param pageState [Object] The composite view state for all viewers on the page
|
||||
* @param viewerName [String] The name of the viewer that making the request
|
||||
*/
|
||||
saveViewState: function(pageState, viewerName) {},
|
||||
|
||||
/**
|
||||
* Get the postback data queryString to use for Active X print control
|
||||
*
|
||||
* @param pageState [Object] The composite view state for all viewers on the page
|
||||
* @param viewerName [String] The name of the viewer that making the request
|
||||
* @return [String] the postback data in a query string format
|
||||
*/
|
||||
getPostDataForPrinting: function(pageState, viewerName) {},
|
||||
|
||||
/**
|
||||
* Allows the IOAdapter to manipulate the error before the Viewer processes it for display to the user.
|
||||
*/
|
||||
processError: function(response) {return response;},
|
||||
|
||||
canUseAjax: function() {
|
||||
try {
|
||||
return (MochiKit.Async.getXMLHttpRequest() !== null);
|
||||
}
|
||||
catch (e) {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Ensures that there is a hidden iframe to be used for postbacks.
|
||||
*/
|
||||
_getPostbackIframe: function() {
|
||||
if (!this._iframe) {
|
||||
ifrm = document.createElement("IFRAME");
|
||||
ifrm.id = bobj.uniqueId();
|
||||
ifrm.name = ifrm.id;
|
||||
ifrm.style.width = '0px';
|
||||
ifrm.style.height = '0px';
|
||||
ifrm.style.position = 'absolute';
|
||||
ifrm.style.top = '0px';
|
||||
ifrm.style.left = '0px';
|
||||
ifrm.style.visibility = 'hidden';
|
||||
document.body.appendChild(ifrm);
|
||||
// in IE, we need to set the window name again
|
||||
if (!ifrm.contentWindow.name) {
|
||||
ifrm.contentWindow.name = ifrm.id;
|
||||
}
|
||||
|
||||
this._iframe = ifrm;
|
||||
}
|
||||
|
||||
return this._iframe;
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
================================================================================
|
||||
ServletAdapter. ServletAdapter issues requests to the Java DHTML viewer.
|
||||
================================================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* Constructor for ServletAdapter.
|
||||
*
|
||||
* @param pageUrl [string] URL of the page
|
||||
* @param servletUrl [string] URL to which requests to a servlet should be made
|
||||
* It doubles as the url for all asyncronous requests
|
||||
*/
|
||||
bobj.crv.ServletAdapter = function(pageUrl, servletUrl) {
|
||||
this._pageUrl = pageUrl;
|
||||
this._servletUrl = servletUrl;
|
||||
this._form = null;
|
||||
};
|
||||
|
||||
bobj.crv.ServletAdapter._requestParams = {
|
||||
STATE: 'CRVCompositeViewState',
|
||||
TARGET: 'CRVEventTarget',
|
||||
ARGUMENT: 'CRVEventArgument'
|
||||
};
|
||||
|
||||
|
||||
bobj.crv.ServletAdapter.prototype = MochiKit.Base.merge(bobj.crv.IOAdapterBase, {
|
||||
|
||||
request: function(pageState, viewerName, eventArgs, allowAsync, useIframe) {
|
||||
if (!this._form) {
|
||||
this._createForm();
|
||||
}
|
||||
|
||||
var rp = bobj.crv.ServletAdapter._requestParams;
|
||||
var toJSON = MochiKit.Base.serializeJSON;
|
||||
|
||||
this._form[rp.STATE].value = encodeURIComponent(toJSON(pageState));
|
||||
this._form[rp.TARGET].value = encodeURIComponent(viewerName);
|
||||
this._form[rp.ARGUMENT].value = encodeURIComponent(toJSON(eventArgs));
|
||||
|
||||
var deferred = null;
|
||||
if (allowAsync && this._servletUrl) {
|
||||
var req = MochiKit.Async.getXMLHttpRequest();
|
||||
req.open("POST", this._servletUrl, true);
|
||||
req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||||
req.setRequestHeader('Accept','application/json');
|
||||
deferred = MochiKit.Async.sendXMLHttpRequest(req, MochiKit.Base.queryString(this._form));
|
||||
}
|
||||
else {
|
||||
if (useIframe) {
|
||||
this._form.target = this._getPostbackIframe().id;
|
||||
}
|
||||
this._form.submit();
|
||||
}
|
||||
|
||||
// once the form is submitted it is not intended to be reused.
|
||||
|
||||
MochiKit.DOM.removeElement(this._form);
|
||||
this._form = null;
|
||||
return deferred;
|
||||
},
|
||||
|
||||
redirectToServlet: function () {
|
||||
if (!this._form) {
|
||||
this._createForm();
|
||||
}
|
||||
|
||||
this._form.action = this._servletUrl;
|
||||
},
|
||||
|
||||
_createForm: function() {
|
||||
var d = MochiKit.DOM;
|
||||
var rp = bobj.crv.ServletAdapter._requestParams;
|
||||
|
||||
this._form = d.FORM({
|
||||
name: bobj.uniqueId(),
|
||||
style: 'display:none',
|
||||
method: 'POST',
|
||||
enctype: 'application/x-www-form-urlencoded;charset=utf-8',
|
||||
action: this._pageUrl},
|
||||
d.INPUT({type: 'hidden', name: rp.STATE}),
|
||||
d.INPUT({type: 'hidden', name: rp.TARGET}),
|
||||
d.INPUT({type: 'hidden', name: rp.ARGUMENT}));
|
||||
|
||||
document.body.appendChild(this._form);
|
||||
},
|
||||
|
||||
addRequestField: function(fldName, fldValue) {
|
||||
if (fldName && fldValue) {
|
||||
if (!this._form) {
|
||||
this._createForm();
|
||||
}
|
||||
|
||||
var existingElem = this._form[fldName];
|
||||
if (existingElem) {
|
||||
existingElem.value = fldValue;
|
||||
}
|
||||
else {
|
||||
this._form.appendChild(MochiKit.DOM.INPUT({type: 'hidden', name:fldName, value:fldValue}));
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
removeRequestField: function(fldName) {
|
||||
if (fldName) {
|
||||
var form = this._form;
|
||||
|
||||
if (form) {
|
||||
var existingElem = form[fldName];
|
||||
if (existingElem) {
|
||||
MochiKit.DOM.removeElement(existingElem);
|
||||
if(form[fldName]) { // Fix for FF
|
||||
form[fldName] = null;
|
||||
}
|
||||
}
|
||||
|
||||
existingElem = null;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
getPostDataForPrinting: function(pageState, viewerName) {
|
||||
var toJSON = MochiKit.Base.serializeJSON;
|
||||
var rp = bobj.crv.ServletAdapter._requestParams;
|
||||
var state = toJSON(pageState);
|
||||
|
||||
var postData = {};
|
||||
postData[rp.STATE] = encodeURIComponent(state);
|
||||
postData[rp.TARGET] = encodeURIComponent(viewerName);
|
||||
postData[rp.ARGUMENT] = encodeURIComponent('"axprint="');
|
||||
if(document.getElementById('com.sun.faces.VIEW')) {
|
||||
postData['com.sun.faces.VIEW'] = encodeURIComponent(document.getElementById('com.sun.faces.VIEW').value);
|
||||
}
|
||||
|
||||
return MochiKit.Base.queryString(postData);
|
||||
},
|
||||
|
||||
processError: function(response) {
|
||||
if (!(typeof(response.number) == 'undefined') && response.number == 404) {
|
||||
return L_bobj_crv_ServletMissing;
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
================================================================================
|
||||
AspDotNetAdapter. AspDotNetAdapter issues requests to the WebForm DHTML viewer.
|
||||
================================================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* Constructor for AspDotNetAdapter.
|
||||
*
|
||||
* @param postbackEventReference [string] The full functiona call to the ASP.NET dopostback function
|
||||
* @param replacementParameter [string] the string to replace in the dopostback function
|
||||
* @param stateID [string] the name of the input field to save the state to
|
||||
*/
|
||||
bobj.crv.AspDotNetAdapter = function(postbackEventReference, replacementParameter, stateID, callbackEventReference, aspnetVersion) {
|
||||
this._postbackEventReference = postbackEventReference;
|
||||
this._replacementParameter = replacementParameter;
|
||||
this._stateID = stateID;
|
||||
this._aspnetVersion = aspnetVersion;
|
||||
this._form = null;
|
||||
this._callbackEventReference = callbackEventReference;
|
||||
this._additionalReqFlds = null;
|
||||
var tmpState = bobj.getElementByIdOrName(this._stateID);
|
||||
if (tmpState) {
|
||||
this._form = tmpState.form;
|
||||
}
|
||||
|
||||
if(this._isAspNetVersionPriorToVersion4()) {
|
||||
WebForm_CallbackComplete = this.WebForm_CallbackComplete;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
bobj.crv.AspDotNetAdapter.prototype = MochiKit.Base.merge(bobj.crv.IOAdapterBase, {
|
||||
|
||||
request: function(pageState, viewerName, eventArgs, allowAsync, useIframe, callbackHandler, errbackHandler) {
|
||||
var toJSON = MochiKit.Base.serializeJSON;
|
||||
if (eventArgs && this._additionalReqFlds) {
|
||||
eventArgs = MochiKit.Base.update(eventArgs, this._additionalReqFlds);
|
||||
}
|
||||
this._additionalReqFlds = null;
|
||||
|
||||
var jsonEventArgs = toJSON(eventArgs);
|
||||
this.saveViewState(pageState, viewerName);
|
||||
|
||||
if (allowAsync) {
|
||||
if(typeof WebForm_InitCallback == "function") {
|
||||
__theFormPostData = ""; //Used by WeForm_InitCallback
|
||||
__theFormPostCollection = []; //Used by WeForm_InitCallback
|
||||
WebForm_InitCallback(); //Need to call this to work around a problem where ASP.NET2 callback does not collect form data prior to request
|
||||
}
|
||||
var callback = this._callbackEventReference.replace("'arg'", "jsonEventArgs");
|
||||
callback = callback.replace("'cb'", "callbackHandler");
|
||||
callback = callback.replace("'errcb'", "errbackHandler");
|
||||
callback = callback.replace("'frmID'", "this._form.id");
|
||||
return eval(callback);
|
||||
}
|
||||
else {
|
||||
if (useIframe) {
|
||||
this._form.target = this._getPostbackIframe().id;
|
||||
}
|
||||
|
||||
var postbackCall;
|
||||
if(this._postbackEventReference.indexOf("'" + this._replacementParameter + "'") >= 0){
|
||||
postbackCall = this._postbackEventReference.replace("'" + this._replacementParameter + "'", "jsonEventArgs");
|
||||
}
|
||||
else {
|
||||
postbackCall = this._postbackEventReference.replace('"' + this._replacementParameter + '"', "jsonEventArgs");
|
||||
}
|
||||
eval(postbackCall);
|
||||
this._clearEventFields();
|
||||
this._form.target = ""; //Give back the target of the form after using, or the form cannot get focused
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @return true if aspnet verion is prior to version 4
|
||||
*/
|
||||
_isAspNetVersionPriorToVersion4 : function () {
|
||||
if(this._aspnetVersion != null) {
|
||||
var sep = this._aspnetVersion.split(".");
|
||||
if(eval(sep[0]) < 4)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
saveViewState: function(pageState, viewerName) {
|
||||
var toJSON = MochiKit.Base.serializeJSON;
|
||||
var viewState = pageState[viewerName];
|
||||
var state = bobj.getElementByIdOrName(this._stateID);
|
||||
if (state) {
|
||||
state.value = toJSON(viewState);
|
||||
}
|
||||
},
|
||||
|
||||
getPostDataForPrinting: function(pageState, viewerName) {
|
||||
this.saveViewState(pageState, viewerName);
|
||||
var nv = MochiKit.DOM.formContents(this.form);
|
||||
var names = nv[0];
|
||||
var values = nv[1];
|
||||
names.push('crprint');
|
||||
values.push(viewerName);
|
||||
var queryString = MochiKit.Base.queryString(names, values);
|
||||
return queryString;
|
||||
},
|
||||
|
||||
addRequestField: function(fldName, fldValue) {
|
||||
if (!this._additionalReqFlds) {
|
||||
this._additionalReqFlds = {};
|
||||
}
|
||||
this._additionalReqFlds[fldName] = fldValue;
|
||||
|
||||
/*if (fldName && fldValue) {
|
||||
var existingElem = this._form[fldName];
|
||||
if (existingElem) {
|
||||
existingElem.value = fldValue;
|
||||
}
|
||||
else {
|
||||
this._form.appendChild(MochiKit.DOM.INPUT({type: 'hidden', name:fldName, value:fldValue}));
|
||||
}
|
||||
}*/
|
||||
},
|
||||
|
||||
_clearRequestField: function(fldName) {
|
||||
if (fldName) {
|
||||
if (this._form) {
|
||||
var existingElem = this._form[fldName];
|
||||
if (existingElem) {
|
||||
existingElem.value = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_clearEventFields: function() {
|
||||
this._clearRequestField("__EVENTTARGET");
|
||||
this._clearRequestField("__EVENTARGUMENT");
|
||||
},
|
||||
|
||||
/*
|
||||
* Overriding WebForm_CallbackComplete provided by .Net framework 2(WebResource.asx) as it was incorrect.
|
||||
* The code below is taken from .Net 4 copy of this function
|
||||
* This code can be removed once the support for .Net 2 is terminated
|
||||
*/
|
||||
WebForm_CallbackComplete : function () {
|
||||
for (var i = 0; i < __pendingCallbacks.length; i++) {
|
||||
callbackObject = __pendingCallbacks[i];
|
||||
if (callbackObject && callbackObject.xmlRequest && (callbackObject.xmlRequest.readyState == 4)) {
|
||||
if (!__pendingCallbacks[i].async) {
|
||||
__synchronousCallBackIndex = -1;
|
||||
}
|
||||
__pendingCallbacks[i] = null;
|
||||
var callbackFrameID = "__CALLBACKFRAME" + i;
|
||||
var xmlRequestFrame = document.getElementById(callbackFrameID);
|
||||
if (xmlRequestFrame) {
|
||||
xmlRequestFrame.parentNode.removeChild(xmlRequestFrame);
|
||||
}
|
||||
WebForm_ExecuteCallback(callbackObject);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
================================================================================
|
||||
FacesAdapter. FacesAdapter issues requests to a JSF viewer component.
|
||||
================================================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* Constructor for FacesAdapter.
|
||||
*
|
||||
* @param formName [string] Name of the form to submit
|
||||
* @param servletUrl [string] URL to which requests to a servlet should be made
|
||||
* It doubles as the url for all asyncronous requests
|
||||
*/
|
||||
bobj.crv.FacesAdapter = function(formName, servletUrl) {
|
||||
this._formName = formName;
|
||||
this._servletUrl = servletUrl;
|
||||
this._useServlet = false;
|
||||
if (!bobj.crv.FacesAdapter._hasInterceptedSubmit) {
|
||||
this._interceptSubmit();
|
||||
bobj.crv.FacesAdapter._hasInterceptedSubmit = true;
|
||||
}
|
||||
};
|
||||
|
||||
bobj.crv.FacesAdapter._requestParams = {
|
||||
STATE: 'CRVCompositeViewState',
|
||||
TARGET: 'CRVEventTarget',
|
||||
ARGUMENT: 'CRVEventArgument'
|
||||
};
|
||||
|
||||
bobj.crv.FacesAdapter.prototype = MochiKit.Base.merge(bobj.crv.IOAdapterBase, {
|
||||
|
||||
request: function(pageState, viewerName, eventArgs, allowAsync, useIframe) {
|
||||
|
||||
var rp = bobj.crv.FacesAdapter._requestParams;
|
||||
var toJSON = MochiKit.Base.serializeJSON;
|
||||
var INPUT = MochiKit.DOM.INPUT;
|
||||
|
||||
var deferred = null;
|
||||
|
||||
var form = this._getForm();
|
||||
if (!form) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!form[rp.TARGET]) {
|
||||
form.appendChild( INPUT({type: 'hidden', name: rp.TARGET}) );
|
||||
}
|
||||
form[rp.TARGET].value = encodeURIComponent(viewerName);
|
||||
|
||||
if (!form[rp.ARGUMENT]) {
|
||||
form.appendChild( INPUT({type: 'hidden', name: rp.ARGUMENT}) );
|
||||
}
|
||||
form[rp.ARGUMENT].value = encodeURIComponent(toJSON(eventArgs));
|
||||
|
||||
if (!form[rp.STATE]) {
|
||||
form.appendChild( INPUT({type: 'hidden', name: rp.STATE}) );
|
||||
}
|
||||
form[rp.STATE].value = encodeURIComponent(toJSON(pageState));
|
||||
|
||||
if (allowAsync && this._servletUrl) {
|
||||
var req = MochiKit.Async.getXMLHttpRequest();
|
||||
req.open("POST", this._servletUrl, true);
|
||||
req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||||
req.setRequestHeader('Accept','application/json');
|
||||
deferred = MochiKit.Async.sendXMLHttpRequest(req, MochiKit.Base.queryString(form));
|
||||
}
|
||||
else {
|
||||
var pageUrl = form.action;
|
||||
if (this._useServlet === true) {
|
||||
form.action = this._servletUrl;
|
||||
}
|
||||
|
||||
var origTarget = form.target;
|
||||
if (useIframe) {
|
||||
form.target = this._getPostbackIframe().id;
|
||||
}
|
||||
|
||||
form.submit();
|
||||
|
||||
form.action = pageUrl;
|
||||
form.target = origTarget;
|
||||
this._useServlet = false;
|
||||
}
|
||||
|
||||
// clear out the request fields so that the form can be reused
|
||||
form[rp.TARGET].value = "";
|
||||
form[rp.ARGUMENT].value = "";
|
||||
form[rp.STATE].value = "";
|
||||
|
||||
// TODO Post Titan: we shouldn't need to have explicit knowledge of this parameter
|
||||
this.removeRequestField ('ServletTask');
|
||||
|
||||
return deferred;
|
||||
},
|
||||
|
||||
redirectToServlet: function () {
|
||||
this._useServlet = true;
|
||||
},
|
||||
|
||||
addRequestField: function(fldName, fldValue) {
|
||||
if (fldName && fldValue) {
|
||||
var form = this._getForm();
|
||||
|
||||
if (form) {
|
||||
var existingElem = form[fldName];
|
||||
if (existingElem) {
|
||||
existingElem.value = fldValue;
|
||||
}
|
||||
else {
|
||||
form.appendChild(MochiKit.DOM.INPUT({type: 'hidden', name:fldName, value:fldValue}));
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
removeRequestField: function(fldName) {
|
||||
if (fldName) {
|
||||
var form = this._getForm();
|
||||
|
||||
if (form) {
|
||||
var existingElem = form[fldName];
|
||||
if (existingElem) {
|
||||
MochiKit.DOM.removeElement(existingElem);
|
||||
if(form[fldName]) { // Fix for FF
|
||||
form[fldName] = null;
|
||||
}
|
||||
}
|
||||
|
||||
existingElem = null;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
saveViewState: function(pageState, viewerName) {
|
||||
if (!bobj.crv.FacesAdapter._isStateSaved) {
|
||||
var form = this._getForm();
|
||||
if (form) {
|
||||
var rp = bobj.crv.FacesAdapter._requestParams;
|
||||
var toJSON = MochiKit.Base.serializeJSON;
|
||||
var INPUT = MochiKit.DOM.INPUT;
|
||||
|
||||
if (!form[rp.STATE]) {
|
||||
form.appendChild( INPUT({type: 'hidden', name: rp.STATE}) );
|
||||
}
|
||||
form[rp.STATE].value = encodeURIComponent(toJSON(pageState));
|
||||
}
|
||||
bobj.crv.FacesAdapter._isStateSaved = true;
|
||||
}
|
||||
},
|
||||
|
||||
_getForm: function() {
|
||||
return document.forms[this._formName];
|
||||
},
|
||||
|
||||
_interceptSubmit: function() {
|
||||
var form = this._getForm();
|
||||
if (form) {
|
||||
var oldSubmit = form.submit;
|
||||
form.submit = function() {
|
||||
bobj.event.publish('saveViewState');
|
||||
form.submit = oldSubmit; // IE needs this
|
||||
form.submit(); // Can't apply args because IE misbehaves
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
getPostDataForPrinting: function(pageState, viewerName) {
|
||||
var toJSON = MochiKit.Base.serializeJSON;
|
||||
var rp = bobj.crv.ServletAdapter._requestParams;
|
||||
var state = toJSON(pageState);
|
||||
|
||||
var postData = {};
|
||||
postData[rp.STATE] = encodeURIComponent(state);
|
||||
postData[rp.TARGET] = encodeURIComponent(viewerName);
|
||||
postData[rp.ARGUMENT] = encodeURIComponent('"axprint="');
|
||||
if(document.getElementById('com.sun.faces.VIEW')) {
|
||||
postData['com.sun.faces.VIEW'] = encodeURIComponent(document.getElementById('com.sun.faces.VIEW').value);
|
||||
}
|
||||
|
||||
return MochiKit.Base.queryString(postData);
|
||||
},
|
||||
|
||||
processError: function(response) {
|
||||
if (!(typeof(response.number) == 'undefined') && response.number == 404) {
|
||||
return L_bobj_crv_ServletMissing;
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
});
|
||||
37
crystalreportviewers13/js/crviewer/ImageSprites.js
Normal file
@@ -0,0 +1,37 @@
|
||||
// allInOne.gif - icon images with different width and heights - disabled states are on the right
|
||||
bobj.crv.allInOne = (function () {
|
||||
var o = new Object();
|
||||
o.uri = bobj.crvUri('images/allInOne.gif');
|
||||
|
||||
var iconHeight22 = 22;
|
||||
var offset = 0;
|
||||
|
||||
// Toolbar icons are 22 pixels height and have 3 pixels place holder
|
||||
offset += 3;
|
||||
offset = o.toolbarExportDy = offset;
|
||||
offset = o.toolbarPrintDy = offset + iconHeight22;
|
||||
|
||||
offset = o.toolbarRefreshDy = offset + iconHeight22;
|
||||
offset = o.toolbarSearchDy = offset + iconHeight22;
|
||||
offset = o.toolbarUpDy = offset + iconHeight22;
|
||||
// Rest of the images don't need the place holder
|
||||
offset -= 3;
|
||||
|
||||
// These are 22 pixels height
|
||||
offset = o.groupTreeToggleDy = offset + iconHeight22;
|
||||
offset = o.paramPanelToggleDy = offset + iconHeight22;
|
||||
|
||||
// These two are 20 pixels height
|
||||
offset = o.toolbarPrevPageDy = offset + iconHeight22; // 22x20
|
||||
offset = o.toolbarNextPageDy = offset + 20; // 22x20
|
||||
|
||||
offset = o.paramRunDy = offset + 20; // 22x22
|
||||
offset = o.paramDataFetchingDy = offset + 22; // 16x16
|
||||
offset = o.closePanelDy = offset + 16; // 8x7
|
||||
offset = o.openParameterArrowDy = offset + 7; // 15x15
|
||||
offset = o.plusDy = offset + 15; // 13x12
|
||||
offset = o.minusDy = offset + 12; // 13x12
|
||||
offset = o.undoDy = offset + 12; // 16x16
|
||||
|
||||
return o;
|
||||
})();
|
||||
289
crystalreportviewers13/js/crviewer/LeftPanel.js
Normal file
@@ -0,0 +1,289 @@
|
||||
/**
|
||||
* LeftPanel is a container class managing PanelNavigator and ToolPanel classes
|
||||
*/
|
||||
|
||||
bobj.crv.newLeftPanel = function(kwArgs) {
|
||||
kwArgs = MochiKit.Base.update ( {
|
||||
id : bobj.uniqueId () + "_leftPanel",
|
||||
hasToggleGroupTreeButton : true,
|
||||
hasToggleParameterPanelButton : true,
|
||||
paramIconImg : null,
|
||||
treeIconImg : null
|
||||
}, kwArgs);
|
||||
|
||||
return new bobj.crv.LeftPanel (kwArgs.id, kwArgs.hasToggleGroupTreeButton, kwArgs.hasToggleParameterPanelButton, kwArgs.paramIconImg, kwArgs.treeIconImg);
|
||||
};
|
||||
|
||||
bobj.crv.LeftPanel = function(id, hasToggleGroupTreeButton, hasToggleParameterPanelButton, paramIconImg, treeIconImg) {
|
||||
this._panelNavigator = null;
|
||||
this._panelHeader = null;
|
||||
this._toolPanel = null;
|
||||
this.id = id;
|
||||
this.widgetType = 'LeftPanel';
|
||||
this.hasToggleParameterPanelButton = hasToggleParameterPanelButton;
|
||||
this.hasToggleGroupTreeButton = hasToggleGroupTreeButton;
|
||||
this.paramIconImg = paramIconImg;
|
||||
this.treeIconImg = treeIconImg;
|
||||
this._lastViewedPanel = null;
|
||||
};
|
||||
|
||||
bobj.crv.LeftPanel.prototype = {
|
||||
getHTML : function() {
|
||||
var toolPanelHTML = this._toolPanel ? this._toolPanel.getHTML () : '';
|
||||
var panelHeaderHTML = this._panelHeader ? this._panelHeader.getHTML () : '';
|
||||
var navigatorHTML = this._panelNavigator ? this._panelNavigator.getHTML () : '';
|
||||
|
||||
return bobj.html.DIV ( {
|
||||
'class' : 'leftPanel',
|
||||
id : this.id
|
||||
}, navigatorHTML, panelHeaderHTML, toolPanelHTML);
|
||||
},
|
||||
|
||||
/**
|
||||
* @return width that would best fit both navigator and toolpanel
|
||||
*/
|
||||
getBestFitWidth : function() {
|
||||
var w = 0;
|
||||
if (this._panelNavigator)
|
||||
w += this._panelNavigator.getWidth ();
|
||||
|
||||
if (this._toolPanel && this._toolPanel.isDisplayed())
|
||||
w += this._toolPanel.getWidth();
|
||||
else
|
||||
w += 5; //The padding between navigator and reportAlbum when no toolpanel exist
|
||||
|
||||
return w;
|
||||
},
|
||||
|
||||
getBestFitHeight : function () {
|
||||
var toolPanelHeight = 0;
|
||||
var panelNavigatorHeight = 0;
|
||||
|
||||
if(this._panelHeader)
|
||||
toolPanelHeight += this._panelHeader.getHeight()
|
||||
if(this._toolPanel)
|
||||
toolPanelHeight += this._toolPanel.getBestFitHeight();
|
||||
if(this._panelNavigator)
|
||||
panelNavigatorHeight = this._panelNavigator.getBestFitHeight();
|
||||
|
||||
return Math.max (toolPanelHeight, panelNavigatorHeight);
|
||||
},
|
||||
|
||||
/**
|
||||
* AJAX update flow
|
||||
* @param update
|
||||
* @return
|
||||
*/
|
||||
update : function(update) {
|
||||
if (!update || update.cons != "bobj.crv.newLeftPanel") {
|
||||
return;
|
||||
}
|
||||
|
||||
for ( var childNum in update.children) {
|
||||
var child = update.children[childNum];
|
||||
if (child && child.cons == "bobj.crv.newToolPanel") {
|
||||
if (this._toolPanel)
|
||||
this._toolPanel.update (child);
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Initializes widgets and connects signals
|
||||
*/
|
||||
init : function() {
|
||||
this.layer = getLayer (this.id);
|
||||
this.css = this.layer.style;
|
||||
|
||||
if (this._toolPanel)
|
||||
this._toolPanel.init ();
|
||||
|
||||
if (this._panelHeader) {
|
||||
this._panelHeader.init ();
|
||||
if(!this.isToolPanelDisplayed())
|
||||
this._panelHeader.setDisplay(false);
|
||||
}
|
||||
|
||||
if (this._panelNavigator)
|
||||
this._panelNavigator.init ();
|
||||
},
|
||||
|
||||
/**
|
||||
* Connects signals
|
||||
* @return
|
||||
*/
|
||||
_initSignals : function() {
|
||||
var partial = MochiKit.Base.partial;
|
||||
var signal = MochiKit.Signal.signal;
|
||||
var connect = MochiKit.Signal.connect;
|
||||
|
||||
if (this._toolPanel) {
|
||||
MochiKit.Iter.forEach ( [ 'grpDrilldown', 'grpNodeRetrieveChildren', 'grpNodeCollapse', 'grpNodeExpand', 'resetParamPanel',
|
||||
'resizeToolPanel' ], function(sigName) {
|
||||
connect (this._toolPanel, sigName, partial (signal, this, sigName));
|
||||
}, this);
|
||||
}
|
||||
|
||||
if (this._panelNavigator)
|
||||
connect (this._panelNavigator, "switchPanel", this, '_switchPanel');
|
||||
|
||||
if(this._panelHeader)
|
||||
connect (this._panelHeader, "switchPanel", this, '_switchPanel');
|
||||
},
|
||||
|
||||
/**
|
||||
* @return true if toolpanel is displayed
|
||||
*/
|
||||
isToolPanelDisplayed : function() {
|
||||
return this._toolPanel && this._toolPanel.isDisplayed ();
|
||||
},
|
||||
|
||||
/**
|
||||
* Do not Remove, Used by WebElements Public API
|
||||
*/
|
||||
displayLastViewedPanel : function () {
|
||||
if(this._toolPanel) {
|
||||
switch(this._lastViewedPanel)
|
||||
{
|
||||
case bobj.crv.ToolPanelType.GroupTree:
|
||||
this._switchPanel (bobj.crv.ToolPanelType.GroupTree);
|
||||
break;
|
||||
case bobj.crv.ToolPanelType.ParameterPanel:
|
||||
this._switchPanel (bobj.crv.ToolPanelType.ParameterPanel);
|
||||
break;
|
||||
default :
|
||||
this._switchPanel (bobj.crv.ToolPanelType.GroupTree);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Do not Remove, Used by WebElements Public API
|
||||
*/
|
||||
hideToolPanel : function () {
|
||||
this._switchPanel (bobj.crv.ToolPanelType.None);
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
* @param panelType [bobj.crv.ToolPanelType]
|
||||
* @return
|
||||
*/
|
||||
_switchPanel : function(panelType) {
|
||||
if (this._toolPanel) {
|
||||
this._toolPanel.setView (panelType);
|
||||
if(panelType == bobj.crv.ToolPanelType.None) {
|
||||
this._toolPanel.setDisplay(false);
|
||||
this._panelHeader.setDisplay(false);
|
||||
}
|
||||
else {
|
||||
this._toolPanel.setDisplay(true);
|
||||
this._panelHeader.setDisplay(true);
|
||||
this._lastViewedPanel = panelType;
|
||||
}
|
||||
}
|
||||
|
||||
if (this._panelHeader)
|
||||
var title = bobj.crv.ToolPanelTypeDetails[panelType].title;
|
||||
this._panelHeader.setTitle (title);
|
||||
|
||||
if (this._panelNavigator)
|
||||
this._panelNavigator.selectChild (panelType);
|
||||
|
||||
MochiKit.Signal.signal (this, 'switchPanel', panelType);
|
||||
},
|
||||
|
||||
/**
|
||||
* Do not Remove, Used by WebElements Public API
|
||||
*/
|
||||
getPanelNavigator : function () {
|
||||
return this._panelNavigator;
|
||||
},
|
||||
|
||||
getToolPanel : function() {
|
||||
return this._toolPanel;
|
||||
},
|
||||
|
||||
addChild : function(child) {
|
||||
if (child.widgetType == "ToolPanel") {
|
||||
this._toolPanel = child;
|
||||
this.updateChildren ();
|
||||
this._initSignals ();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Update Navigator and Header with toolPanel's children
|
||||
* @return
|
||||
*/
|
||||
updateChildren : function() {
|
||||
if (this._toolPanel) {
|
||||
|
||||
this._panelNavigator = new bobj.crv.PanelNavigator ();
|
||||
this._panelHeader = new bobj.crv.PanelHeader ();
|
||||
var newChild = null;
|
||||
|
||||
if (this._toolPanel.hasParameterPanel () && this.hasToggleParameterPanelButton) {
|
||||
newChild = {
|
||||
name : bobj.crv.ToolPanelType.ParameterPanel,
|
||||
img : this.paramIconImg ? this.paramIconImg : bobj.crv.ToolPanelTypeDetails.ParameterPanel.img,
|
||||
title : bobj.crv.ToolPanelTypeDetails.ParameterPanel.title
|
||||
};
|
||||
this._panelNavigator.addChild (newChild);
|
||||
}
|
||||
if (this._toolPanel.hasGroupTree () && this.hasToggleGroupTreeButton) {
|
||||
newChild = {
|
||||
name : bobj.crv.ToolPanelType.GroupTree,
|
||||
img : this.treeIconImg ? this.treeIconImg : bobj.crv.ToolPanelTypeDetails.GroupTree.img,
|
||||
title : bobj.crv.ToolPanelTypeDetails.GroupTree.title
|
||||
};
|
||||
this._panelNavigator.addChild (newChild);
|
||||
}
|
||||
|
||||
this._lastViewedPanel = this._toolPanel.initialViewType;
|
||||
|
||||
this._panelNavigator.selectChild (this._toolPanel.initialViewType);
|
||||
this._panelHeader.setTitle (bobj.crv.ToolPanelTypeDetails[this._toolPanel.initialViewType].title);
|
||||
|
||||
if (!this._panelNavigator.hasChildren())
|
||||
{
|
||||
this._panelHeader.hideCloseButton();
|
||||
this._toolPanel.addLeftBorder();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
resize : function(w, h) {
|
||||
bobj.setOuterSize (this.layer, w, h);
|
||||
this._doLayout ();
|
||||
},
|
||||
|
||||
/**
|
||||
* Layouts children where PanelHeader appears on top of toolPanel and panelNavigator to left of both header and toolpanel
|
||||
* @return
|
||||
*/
|
||||
_doLayout : function() {
|
||||
if(!this._toolPanel || !this._panelNavigator || !this._panelHeader)
|
||||
return;
|
||||
|
||||
var w = this.getWidth ();
|
||||
var h = this.getHeight ();
|
||||
var navigatorW = this._panelNavigator.getWidth ();
|
||||
var newToolPanelWidth = w - navigatorW;
|
||||
var newToolPanelHeight = h - this._panelHeader.getHeight ();
|
||||
|
||||
if (this._toolPanel.isDisplayed()) {
|
||||
this._toolPanel.resize (newToolPanelWidth, newToolPanelHeight);
|
||||
this._toolPanel.move (navigatorW, this._panelHeader.getHeight ());
|
||||
}
|
||||
|
||||
this._panelHeader.resize (newToolPanelWidth, null);
|
||||
this._panelHeader.move (navigatorW, 0);
|
||||
this._panelNavigator.resize(navigatorW, h);
|
||||
},
|
||||
|
||||
move : Widget_move,
|
||||
getWidth : Widget_getWidth,
|
||||
getHeight : Widget_getHeight
|
||||
};
|
||||
35
crystalreportviewers13/js/crviewer/OptionalParameterUI.js
Normal file
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* OptionalParameterUI extends ParameterUI
|
||||
*/
|
||||
|
||||
bobj.crv.params.newOptionalParameterUI = function(kwArgs) {
|
||||
kwArgs = MochiKit.Base.update( {
|
||||
noValueDisplayText :'',
|
||||
isEmptyStringNoValue: true,
|
||||
clearValuesCB : null
|
||||
}, kwArgs);
|
||||
|
||||
var o = bobj.crv.params.newParameterUI(kwArgs);
|
||||
|
||||
/*
|
||||
* The reason I'm using bobj.extendClass is that it would populate all functions defined in ParameterUI
|
||||
* in this.superClass so I can call any function on parent class
|
||||
*/
|
||||
bobj.extendClass(o, bobj.crv.params.OptionalParameterUI, bobj.crv.params.ParameterUI);
|
||||
|
||||
return o;
|
||||
};
|
||||
|
||||
bobj.crv.params.OptionalParameterUI = {
|
||||
_getNewValueRowConstructor : function() {
|
||||
return bobj.crv.params.newOptionalParameterValueRow;
|
||||
},
|
||||
|
||||
_getNewValueRowArgs : function(value) {
|
||||
var args = this.superClass._getNewValueRowArgs(value);
|
||||
args.noValueDisplayText = this.noValueDisplayText;
|
||||
args.isEmptyStringNoValue = this.isEmptyStringNoValue;
|
||||
args.clearValuesCB = this.clearValuesCB;
|
||||
return args;
|
||||
}
|
||||
};
|
||||
143
crystalreportviewers13/js/crviewer/OptionalParameterValueRow.js
Normal file
@@ -0,0 +1,143 @@
|
||||
|
||||
/**
|
||||
* OptionalParameterValueRow extends ParamterValueRow. This class displays a info message for 'undefined' value and
|
||||
* clears the info message when its control get focus
|
||||
*/
|
||||
bobj.crv.params.newOptionalParameterValueRow = function(kwArgs) {
|
||||
kwArgs = MochiKit.Base.update( {
|
||||
noValueDisplayText :'',
|
||||
isEmptyStringNoValue : true,
|
||||
clearValuesCB : null
|
||||
}, kwArgs);
|
||||
|
||||
var o = bobj.crv.params.newParameterValueRow(kwArgs);
|
||||
bobj.extendClass(o, bobj.crv.params.OptionalParameterValueRow, bobj.crv.params.ParameterValueRow);
|
||||
|
||||
if (o.canChangeOnPanel) {
|
||||
o._clearValueButton = newIconWidget(
|
||||
o.id + '_clearBtn',
|
||||
bobj.crvUri('images/clear_x.gif'),
|
||||
o.clearValuesCB,
|
||||
null, //text
|
||||
L_bobj_crv_ParamsClearValues,//tooltip,
|
||||
10, 10, 2, 2); //width, height, dx, dy, disDx, disDy, cancelEventPropagation
|
||||
|
||||
o._clearValueButton.setClasses("", "iconcheck", "", "iconcheckhover");
|
||||
o._clearValueButton.margin = 2;
|
||||
}
|
||||
|
||||
return o;
|
||||
};
|
||||
|
||||
bobj.crv.params.OptionalParameterValueRow = {
|
||||
/**
|
||||
* Returns arguments required for creating new ValueWidget(TextField, TextCombo, RangeField)
|
||||
*/
|
||||
getNewValueWidgetArgs : function() {
|
||||
var args = this.superClass.getNewValueWidgetArgs();
|
||||
|
||||
if (this.value == undefined) {
|
||||
//If value is undefined, the valueWidget should display noValueDisplayText
|
||||
args.cleanValue = this.noValueDisplayText;
|
||||
args.foreColor = bobj.Colors.GRAY;
|
||||
}
|
||||
|
||||
return args;
|
||||
},
|
||||
|
||||
init : function () {
|
||||
this.superClass.init();
|
||||
if(this._clearValueButton) {
|
||||
this._clearValueButton.init();
|
||||
}
|
||||
|
||||
this.updateUI ();
|
||||
},
|
||||
|
||||
getHTML : function () {
|
||||
var rowHTML = this.superClass.getHTML();
|
||||
if (this.canChangeOnPanel) {
|
||||
var h = bobj.html;
|
||||
rowHTML = h.DIV({style : {position : 'relative'}}, rowHTML , h.DIV({'class' : 'clearValueBtnCtn'},this._clearValueButton.getHTML()));
|
||||
}
|
||||
|
||||
return rowHTML;
|
||||
},
|
||||
|
||||
/**
|
||||
* When receiving focus if noValueDisplayText is being displayed (happens when current value is undefined and param is editable on panel),
|
||||
* it must be cleared so user can type something
|
||||
*/
|
||||
onFocus : function() {
|
||||
this.superClass.onFocus();
|
||||
if (this.canChangeOnPanel) {
|
||||
if(this.value == undefined)
|
||||
this._valueWidget.setValue('');
|
||||
}
|
||||
},
|
||||
|
||||
onBlur : function() {
|
||||
this.superClass.onBlur();
|
||||
|
||||
if (this.canChangeOnPanel) {
|
||||
if (this.value == undefined)
|
||||
this._valueWidget.setValue(this.noValueDisplayText);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* When user changes value, value stored in OptionalParmeterUI gets updated and
|
||||
*/
|
||||
_onChange : function() {
|
||||
this.value = this._valueWidget.getValue();
|
||||
if(this.isEmptyStringNoValue && this.value != null && this.value.length == 0)
|
||||
this.value = undefined;
|
||||
|
||||
this.updateUI();
|
||||
if (this.changeCB)
|
||||
this.changeCB();
|
||||
|
||||
},
|
||||
|
||||
updateUI: function() {
|
||||
if (this._valueWidget) {
|
||||
if(this.isReadOnlyParam) {
|
||||
this._valueWidget.setForeColor(bobj.Colors.GRAY);
|
||||
this._valueWidget.setTextItalic(false);
|
||||
}
|
||||
else {
|
||||
if(this.value == undefined) {
|
||||
this._valueWidget.setForeColor(bobj.Colors.GRAY);
|
||||
if(this._clearValueButton)
|
||||
this._clearValueButton.setDisplay(false);
|
||||
}
|
||||
else {
|
||||
this._valueWidget.setForeColor(bobj.Colors.BLACK);
|
||||
if(this._clearValueButton)
|
||||
this._clearValueButton.setDisplay(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
getValueWidgetDisplayValue: function(value) {
|
||||
return (value == undefined) ? this.noValueDisplayText : value;
|
||||
},
|
||||
|
||||
setValue : function(value) {
|
||||
this.value = value;
|
||||
this._valueWidget.setValue(this.getValueWidgetDisplayValue(value));
|
||||
this.updateUI();
|
||||
|
||||
this.setWarning(null); //Since value is set through parameterController it cannot contain any errors
|
||||
},
|
||||
|
||||
reset : function(value) {
|
||||
this.superClass.reset(value);
|
||||
if(this._valueWidget) {
|
||||
this._valueWidget.reset(this.getValueWidgetDisplayValue(value));
|
||||
}
|
||||
|
||||
this.updateUI();
|
||||
}
|
||||
};
|
||||
99
crystalreportviewers13/js/crviewer/PanelHeader.js
Normal file
@@ -0,0 +1,99 @@
|
||||
/**
|
||||
* The header that appears above toolPanel. It consists of a title and close button.
|
||||
*/
|
||||
bobj.crv.PanelHeader = function() {
|
||||
this.id = bobj.uniqueId () + "_panelHeader";
|
||||
|
||||
this._closeButton = newIconWidget (this.id + "_close", bobj.crv.allInOne.uri, bobj
|
||||
.bindFunctionToObject (this._closeButtonOnClick, this), null, L_bobj_crv_Close, 8, 7, 0, bobj.crv.allInOne.closePanelDy,null,null,true);
|
||||
|
||||
this.normalCssClass = "panelHeaderCloseButton";
|
||||
this.highlightedCssClass = "panelHeaderCloseButtonHighlighted";
|
||||
|
||||
this._closeButton.setClasses (this.normalCssClass, this.normalCssClass, this.highlightedCssClass, this.highlightedCssClass);
|
||||
this._title = "";
|
||||
};
|
||||
|
||||
bobj.crv.PanelHeader.prototype = {
|
||||
getHTML : function() {
|
||||
var DIV = bobj.html.DIV;
|
||||
var style = {height : bobj.isBorderBoxModel() ? '21px' : '20px'};
|
||||
|
||||
return DIV ( {
|
||||
'class' : 'panelHeader',
|
||||
id : this.id,
|
||||
style : style
|
||||
}, DIV ( {
|
||||
'class' : 'panelHeaderTitle',
|
||||
id : this.id + "_title"
|
||||
}, this._title), DIV ( {
|
||||
'class' : 'panelHeaderButtonCtn'
|
||||
}, this._closeButton.getHTML ()));
|
||||
},
|
||||
|
||||
init : function() {
|
||||
this.layer = getLayer (this.id);
|
||||
this.css = this.layer.style;
|
||||
this._closeButton.init ();
|
||||
|
||||
var cbLayer = this._closeButton.layer
|
||||
if (cbLayer) {
|
||||
MochiKit.Signal.connect (cbLayer, "onfocus", this, this._closeButtonOnFocus);
|
||||
MochiKit.Signal.connect (cbLayer, "onblur", this, this._closeButtonOnBlur);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
* @return [DOM element] of title
|
||||
*/
|
||||
_getTitleLayer : function() {
|
||||
return getLayer (this.id + "_title");
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets title on panel header
|
||||
* @param title
|
||||
* @return
|
||||
*/
|
||||
setTitle : function(title) {
|
||||
this._title = title;
|
||||
this._closeButton.changeTooltip(L_bobj_crv_Close + " " + title);
|
||||
var l = this._getTitleLayer ();
|
||||
if (l)
|
||||
l.innerHTML = title;
|
||||
},
|
||||
|
||||
_closeButtonOnFocus : function() {
|
||||
if (this._closeButton && this._closeButton.layer)
|
||||
MochiKit.DOM.addElementClass (this._closeButton.layer, this.highlightedCssClass);
|
||||
},
|
||||
|
||||
_closeButtonOnBlur : function() {
|
||||
if (this._closeButton && this._closeButton.layer)
|
||||
MochiKit.DOM.removeElementClass (this._closeButton.layer, this.highlightedCssClass);
|
||||
},
|
||||
|
||||
_closeButtonOnClick : function() {
|
||||
MochiKit.Signal.signal (this, 'switchPanel', bobj.crv.ToolPanelType.None);
|
||||
},
|
||||
|
||||
resize : function(w, h) {
|
||||
if (this.layer)
|
||||
bobj.setOuterSize (this.layer, w, h);
|
||||
|
||||
var titleLayer = this._getTitleLayer ();
|
||||
if(titleLayer)
|
||||
bobj.setOuterSize (titleLayer, w - 30);
|
||||
},
|
||||
|
||||
hideCloseButton : function() {
|
||||
if (this._closeButton)
|
||||
this._closeButton.setDisplay(false);
|
||||
},
|
||||
|
||||
getWidth : Widget_getWidth,
|
||||
getHeight : Widget_getHeight,
|
||||
move : Widget_move,
|
||||
setDisplay : Widget_setDisplay
|
||||
};
|
||||
124
crystalreportviewers13/js/crviewer/PanelNavigator.js
Normal file
@@ -0,0 +1,124 @@
|
||||
/**
|
||||
* Navigator on left of viewer, controlling which panel is shown
|
||||
*/
|
||||
bobj.crv.PanelNavigator = function() {
|
||||
this._children = [];
|
||||
this.widgetType = "PanelNavigator";
|
||||
this.id = bobj.uniqueId () + "_panelNav";
|
||||
};
|
||||
|
||||
bobj.crv.PanelNavigator.prototype = {
|
||||
getHTML : function() {
|
||||
var childrenHTML = "";
|
||||
for ( var i = 0; i < this._children.length; i++)
|
||||
childrenHTML += this._children[i].getHTML ();
|
||||
|
||||
var DIV = bobj.html.DIV;
|
||||
var style = { width : bobj.isBorderBoxModel() ? '37px' : '35px'};
|
||||
|
||||
|
||||
return DIV ( {
|
||||
'class' : 'panelNavigator',
|
||||
id : this.id,
|
||||
style : style
|
||||
}, DIV ( { id : this.id + "_innerBorder",
|
||||
'class' : 'panelNavigatorInnerBorder'
|
||||
}, childrenHTML));
|
||||
},
|
||||
|
||||
/**
|
||||
* Initializes its layer and calls init on children
|
||||
* @return
|
||||
*/
|
||||
init : function() {
|
||||
this.layer = getLayer (this.id);
|
||||
this._innerBorder = getLayer(this.id + "_innerBorder");
|
||||
this.css = this.layer.style;
|
||||
|
||||
if(this._children.length == 0) {
|
||||
this.css.display = "none";
|
||||
}
|
||||
else {
|
||||
for ( var i = 0; i < this._children.length; i++)
|
||||
this._children[i].init ();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets selection on specified child and removes selection from any other child
|
||||
* @return
|
||||
*/
|
||||
selectChild : function(childName) {
|
||||
for ( var i = 0; i < this._children.length; i++) {
|
||||
var child = this._children[i];
|
||||
child.setSelected (child.getName () == childName);
|
||||
}
|
||||
},
|
||||
|
||||
getChild : function (childName) {
|
||||
for ( var i = 0; i < this._children.length; i++) {
|
||||
var child = this._children[i];
|
||||
if(child.getName () == childName)
|
||||
return child;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
hasChildren : function () {
|
||||
return (this._children.length > 0);
|
||||
},
|
||||
|
||||
/**
|
||||
* Do not Remove, Used by WebElements Public API
|
||||
*/
|
||||
getGroupTreeButton : function () {
|
||||
return this.getChild (bobj.crv.ToolPanelType.GroupTree);
|
||||
},
|
||||
|
||||
/**
|
||||
* Do not Remove, Used by WebElements Public API
|
||||
*/
|
||||
getParamPanelButton : function () {
|
||||
return this.getChild (bobj.crv.ToolPanelType.ParameterPanel);
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param kwArgs [JSON] creates PanelNavigatorItem with properties specified in kwArgs and connects signals
|
||||
* @return
|
||||
*/
|
||||
addChild : function(kwArgs) {
|
||||
kwArgs = MochiKit.Base.update ( {
|
||||
name : '',
|
||||
title : '',
|
||||
img : { uri: '', dx: 0, dy: 0 }
|
||||
}, kwArgs);
|
||||
|
||||
var partial = MochiKit.Base.partial;
|
||||
var signal = MochiKit.Signal.signal;
|
||||
var connect = MochiKit.Signal.connect;
|
||||
|
||||
var navItem = new bobj.crv.PanelNavigatorItem (kwArgs.name, kwArgs.img, kwArgs.title, 35 * this._children.length);
|
||||
|
||||
connect (navItem, "switchPanel", partial (signal, this, "switchPanel"));
|
||||
this._children.push (navItem);
|
||||
},
|
||||
|
||||
resize : function(w, h) {
|
||||
bobj.setOuterSize (this.layer, w, h);
|
||||
bobj.setOuterSize (this._innerBorder, w -2, h -2); //Since border size is 1px for all edges
|
||||
},
|
||||
|
||||
getBestFitHeight : function () {
|
||||
var height = 0;
|
||||
for ( var i = 0; i < this._children.length; i++)
|
||||
height += this._children[i].getHeight();
|
||||
|
||||
return height;
|
||||
},
|
||||
|
||||
move : Widget_move,
|
||||
getWidth : Widget_getWidth
|
||||
|
||||
};
|
||||
105
crystalreportviewers13/js/crviewer/PanelNavigatorItem.js
Normal file
@@ -0,0 +1,105 @@
|
||||
/**
|
||||
*
|
||||
* @param name [String] Name of itme
|
||||
* @param img [String] uri location of icon image
|
||||
* @param title [String] tooltip
|
||||
*/
|
||||
bobj.crv.PanelNavigatorItem = function(name, img, title, topOffset) {
|
||||
this._name = name;
|
||||
this._img = img;
|
||||
this._isSelected = false;
|
||||
this._title = title;
|
||||
this.topOffset = topOffset;
|
||||
this.widgetType = 'PanelNavigatorItem';
|
||||
|
||||
this.id = bobj.uniqueId () + "_navItem_" + name;
|
||||
};
|
||||
|
||||
bobj.crv.PanelNavigatorItem.prototype = {
|
||||
getHTML : function() {
|
||||
var h = bobj.html;
|
||||
var img = this._img;
|
||||
|
||||
return h.DIV ( {
|
||||
id : this.id,
|
||||
'class' : 'panelNavigatorItem',
|
||||
'tabindex' : '0',
|
||||
style : {top : this.topOffset + "px"},
|
||||
title : this._title,
|
||||
role : 'button'
|
||||
}, imgOffset(img.uri, 22, 22, img.dx, img.dy, null, 'class="panelNavigatorItemImage" title="' + this._title + '"')
|
||||
);
|
||||
},
|
||||
|
||||
getName : function() {
|
||||
return this._name;
|
||||
},
|
||||
|
||||
init : function() {
|
||||
this.layer = getLayer (this.id);
|
||||
this.css = this.layer.style;
|
||||
|
||||
var connect = MochiKit.Signal.connect;
|
||||
connect (this.layer, "onclick", this, this._onClick);
|
||||
connect (this.layer, "onkeydown", this, this._onKeyDown);
|
||||
connect (this.layer, "onmouseover", this, this._onMouseOver);
|
||||
connect (this.layer, "onmouseout", this, this._onMouseOut);
|
||||
connect (this.layer, "onfocus", this, this._onFocus);
|
||||
connect (this.layer, "onblur", this, this._onBlur);
|
||||
|
||||
this.setSelected (this._isSelected);
|
||||
},
|
||||
|
||||
_onFocus : function () {
|
||||
MochiKit.DOM.addElementClass (this.layer, "highlighted");
|
||||
},
|
||||
|
||||
_onBlur : function () {
|
||||
MochiKit.DOM.removeElementClass (this.layer, "highlighted");
|
||||
},
|
||||
|
||||
_onMouseOver : function () {
|
||||
MochiKit.DOM.addElementClass (this.layer, "highlighted");
|
||||
},
|
||||
|
||||
_onMouseOut : function () {
|
||||
MochiKit.DOM.removeElementClass (this.layer, "highlighted");
|
||||
},
|
||||
|
||||
_onKeyDown : function(ev) {
|
||||
if (ev && ev.key () && (ev.key ().code == 13 || ev.key ().code == 32)) // On Enter or spacebar, signal swith panel
|
||||
this._signalSwitchPanel();
|
||||
},
|
||||
|
||||
_onClick : function() {
|
||||
this._signalSwitchPanel ();
|
||||
},
|
||||
|
||||
/**
|
||||
* Signals switch panel if it's not currently selected
|
||||
* @return
|
||||
*/
|
||||
_signalSwitchPanel : function () {
|
||||
if(!this._isSelected)
|
||||
MochiKit.Signal.signal (this, "switchPanel", this._name);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param isSelected [Boolean] is item selected or not selected
|
||||
*/
|
||||
setSelected : function(isSelected) {
|
||||
this._isSelected = isSelected;
|
||||
var DOM = MochiKit.DOM;
|
||||
if (this.layer) {
|
||||
if (isSelected)
|
||||
DOM.addElementClass (this.layer, "selected");
|
||||
else
|
||||
DOM.removeElementClass (this.layer, "selected");
|
||||
}
|
||||
},
|
||||
|
||||
getWidth : Widget_getWidth,
|
||||
getHeight: Widget_getHeight,
|
||||
setDisplay : Widget_setDisplay,
|
||||
isDisplayed : Widget_isDisplayed
|
||||
};
|
||||
517
crystalreportviewers13/js/crviewer/Parameter.js
Normal file
@@ -0,0 +1,517 @@
|
||||
/* Copyright (c) Business Objects 2006. All rights reserved. */
|
||||
|
||||
if (typeof bobj.crv.params == 'undefined') {
|
||||
bobj.crv.params = {};
|
||||
}
|
||||
|
||||
bobj.crv.params.DataTypes = {
|
||||
DATE: "d",
|
||||
DATE_TIME: "dt",
|
||||
TIME: "t",
|
||||
STRING: "s",
|
||||
NUMBER: "n",
|
||||
CURRENCY: "c",
|
||||
BOOLEAN: "b"
|
||||
};
|
||||
|
||||
bobj.crv.params.RangeBoundTypes = {
|
||||
UNBOUNDED: 0,
|
||||
EXCLUSIVE: 1,
|
||||
INCLUSIVE: 2
|
||||
};
|
||||
|
||||
bobj.crv.params.DefaultDisplayTypes = {
|
||||
Description: 0,
|
||||
DescriptionAndValue: 1
|
||||
};
|
||||
|
||||
bobj.crv.params.CompareResults = {
|
||||
TOO_BIG: 1,
|
||||
TOO_SMALL: -1,
|
||||
EQUAL: 0
|
||||
};
|
||||
|
||||
/*
|
||||
================================================================================
|
||||
Parameter
|
||||
================================================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
bobj.crv.params.Parameter = function(paramInfo) {
|
||||
var PARAMS = bobj.crv.params;
|
||||
var displayTypes = PARAMS.DefaultDisplayTypes;
|
||||
MochiKit.Base.update(this, {
|
||||
paramName: null,
|
||||
reportName: null,
|
||||
description: null,
|
||||
valueDataType: null,
|
||||
value: null,
|
||||
modifiedValue: null,
|
||||
defaultValues: null,
|
||||
defaultDisplayType : displayTypes.DescriptionAndValue,
|
||||
maxValue: null,
|
||||
minValue: null,
|
||||
allowCustomValue: true,
|
||||
allowDiscreteValue: true,
|
||||
allowMultiValue: false,
|
||||
allowNullValue: false,
|
||||
allowRangeValue: false,
|
||||
editMask: null,
|
||||
isOptionalPrompt: false,
|
||||
isEditable: true,
|
||||
isHidden: false,
|
||||
isDataFetching: false,
|
||||
attributes: null,
|
||||
isInUse : false,
|
||||
isShowOnPanel : false
|
||||
}, paramInfo);
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* IMPORTANT! Use getValue and setValue to access the value of the parameter, instead of the property itself.
|
||||
*/
|
||||
bobj.crv.params.Parameter.prototype = {
|
||||
getTitle: function() {
|
||||
return (this.description || this.paramName);
|
||||
},
|
||||
|
||||
isInteractive : function () {
|
||||
return this.isInUse && (this.isShowOnPanel || this.isEditable);
|
||||
},
|
||||
|
||||
getName: function () {
|
||||
return this.paramName;
|
||||
},
|
||||
|
||||
hasLOV: function() {
|
||||
return (this.defaultValues != null && this.defaultValues.length > 0);
|
||||
},
|
||||
|
||||
hasDescription: function() {
|
||||
return this.description != null;
|
||||
},
|
||||
|
||||
isPassword: function() {
|
||||
return (this.editMask !== null && this.editMask.toLowerCase() == "password");
|
||||
},
|
||||
|
||||
getValue: function() {
|
||||
this._initModifiedValue();
|
||||
return this.modifiedValue;
|
||||
},
|
||||
|
||||
/*
|
||||
* Undos any modifications done on parameter that have not been commited
|
||||
*/
|
||||
reset: function() {
|
||||
delete this.modifiedValue;
|
||||
},
|
||||
|
||||
removeValueAt: function(index) {
|
||||
this._initModifiedValue();
|
||||
var value = this.modifiedValue[index];
|
||||
this.modifiedValue.splice(index, 1);
|
||||
},
|
||||
|
||||
// setValue accepts either an array, or an int + an object.
|
||||
setValue: function (i, newValue) {
|
||||
this._initModifiedValue();
|
||||
|
||||
if (arguments.length == 1 && bobj.isArray(arguments[0])) {
|
||||
var value= arguments[0];
|
||||
this.modifiedValue = value;
|
||||
}
|
||||
else if (arguments.length == 2) {
|
||||
var oldValue = this.modifiedValue[i];
|
||||
this.modifiedValue[i] = newValue;
|
||||
}
|
||||
},
|
||||
|
||||
clearValue: function() {
|
||||
this._initModifiedValue();
|
||||
this.modifiedValue = [];
|
||||
},
|
||||
|
||||
// commitValue will actually apply the changes made so far
|
||||
commitValue: function() {
|
||||
this._initModifiedValue();
|
||||
this.value = this.modifiedValue.slice(0);
|
||||
},
|
||||
|
||||
_initModifiedValue: function() {
|
||||
if (!this.modifiedValue) {
|
||||
if (bobj.isArray(this.value)) {
|
||||
this.modifiedValue = this.value.slice(0); // make a deep copy of "value"
|
||||
}
|
||||
else {
|
||||
this.modifiedValue = [];
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
isDCP: function () {
|
||||
if (this.attributes != null) {
|
||||
if (this.attributes['IsDCP'] === true) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
================================================================================
|
||||
Validator for Parameters
|
||||
================================================================================
|
||||
*/
|
||||
bobj.crv.params.Validator = function(){};
|
||||
|
||||
bobj.crv.params.Validator.ValueStatus = {
|
||||
OK: 0,
|
||||
ERROR: 1,
|
||||
VALUE_MISSING: 2, // Required value is missing
|
||||
VALUE_INVALID_TYPE: 3, // Value has the wrong data type
|
||||
VALUE_TOO_LONG: 4, // Value's length is less than the minimum
|
||||
VALUE_TOO_SHORT: 5, // Value's length is greater than the maximum
|
||||
VALUE_TOO_BIG: 6, // Value is greater than the maximum
|
||||
VALUE_TOO_SMALL: 7, // Value is less than the minimum
|
||||
VALUE_DUPLICATE: 8
|
||||
};
|
||||
|
||||
bobj.crv.params.Validator.getInstance = function(){
|
||||
if (!bobj.crv.params.Validator.__instance) {
|
||||
bobj.crv.params.Validator.__instance = new bobj.crv.params.Validator();
|
||||
}
|
||||
return bobj.crv.params.Validator.__instance;
|
||||
};
|
||||
|
||||
bobj.crv.params.Validator.prototype = {
|
||||
/**
|
||||
* Validate a Parameter instance and return a status object
|
||||
*/
|
||||
validateParameter: function(param) {
|
||||
var PARAMS = bobj.crv.params;
|
||||
if (!param) {return null;}
|
||||
|
||||
var Status = PARAMS.Validator.ValueStatus;
|
||||
|
||||
if (!bobj.isArray(param.value) || !param.value.length) {
|
||||
return {
|
||||
isValid: false,
|
||||
reason: Status.VALUE_MISSING
|
||||
};
|
||||
}
|
||||
|
||||
var isValid = true;
|
||||
var statusList = [];
|
||||
|
||||
for (var i = 0, len = param.values.length; i < len; ++i) {
|
||||
var status = PARAMS.validateValue(param, i);
|
||||
statusList.push(status);
|
||||
isValid = isValid && (status === ValueStatus.OK);
|
||||
}
|
||||
|
||||
return {
|
||||
isValid: isValid,
|
||||
statusList: statusList
|
||||
};
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Validate a parameter value and return a status code
|
||||
*/
|
||||
validateValue: function(param, value) {
|
||||
var Status = bobj.crv.params.Validator.ValueStatus;
|
||||
|
||||
if (!param || !bobj.isArray(param.value) || (value === undefined)) {
|
||||
return Status.ERROR;
|
||||
}
|
||||
|
||||
var validatorFunc = this._getTypeValidatorFunc(param.valueDataType);
|
||||
if (!validatorFunc) {
|
||||
return Status.ERROR;
|
||||
}
|
||||
|
||||
var actualValue = bobj.crv.params.getValue(value);
|
||||
return validatorFunc(param, actualValue);
|
||||
},
|
||||
|
||||
_getTypeValidatorFunc: function(type) {
|
||||
var Type = bobj.crv.params.DataTypes;
|
||||
|
||||
switch (type) {
|
||||
case Type.STRING:
|
||||
return this._validateString;
|
||||
case Type.NUMBER:
|
||||
case Type.CURRENCY:
|
||||
return this._validateNumber;
|
||||
case Type.DATE:
|
||||
case Type.TIME:
|
||||
case Type.DATE_TIME:
|
||||
return this._validateDateTime;
|
||||
case Type.BOOLEAN:
|
||||
return this._validateBoolean;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
},
|
||||
|
||||
_validateString: function(param, value) {
|
||||
var Status = bobj.crv.params.Validator.ValueStatus;
|
||||
|
||||
if (!bobj.isString(value)) {
|
||||
return Status.VALUE_INVALID_TYPE;
|
||||
}
|
||||
|
||||
var maxValue = param.maxValue;
|
||||
var minValue = param.minValue;
|
||||
if (bobj.isNumber(maxValue) && value.length > maxValue) {
|
||||
return Status.VALUE_TOO_LONG;
|
||||
}
|
||||
|
||||
if (bobj.isNumber(minValue) && value.length < minValue) {
|
||||
return Status.VALUE_TOO_SHORT;
|
||||
}
|
||||
|
||||
return Status.OK;
|
||||
},
|
||||
|
||||
_validateNumber: function(param, value) {
|
||||
//the "value" passed in here is a number that has at most one decimal separator and no group separator
|
||||
var Status = bobj.crv.params.Validator.ValueStatus;
|
||||
var regNumber = /^(\+|-)?(\d+((\.\d+)|(\.))?|\.\d+)$/;
|
||||
|
||||
if(bobj.isString(value) && regNumber.test(value)) {
|
||||
value = parseFloat(value);
|
||||
}
|
||||
else if(!bobj.isNumber(value)) {
|
||||
return Status.VALUE_INVALID_TYPE;
|
||||
}
|
||||
|
||||
var maxValue = param.maxValue;
|
||||
var minValue = param.minValue;
|
||||
if(maxValue !== null && value > maxValue) {
|
||||
return Status.VALUE_TOO_BIG;
|
||||
}
|
||||
else if(minValue !== null && value < minValue) {
|
||||
return Status.VALUE_TOO_SMALL;
|
||||
}
|
||||
else {
|
||||
return Status.OK;
|
||||
}
|
||||
},
|
||||
|
||||
_validateDateTime: function(param, value) {
|
||||
var Result = bobj.crv.params.CompareResults;
|
||||
var Status = bobj.crv.params.Validator.ValueStatus;
|
||||
|
||||
if (bobj.isObject(value)) {
|
||||
var isNumber = function(sel) {return bobj.isNumber(value[sel]);};
|
||||
if (MochiKit.Iter.every(['d','m', 'y', 'h', 'min', 's', 'ms'], isNumber)) {
|
||||
|
||||
var compareFunc = bobj.crv.params.getDateCompareFunc(param.valueDataType);
|
||||
if(param.minValue && compareFunc(param.minValue,value) == Result.TOO_BIG) {
|
||||
return Status.VALUE_TOO_SMALL;
|
||||
}
|
||||
else if(param.maxValue && compareFunc(param.maxValue,value) == Result.TOO_SMALL) {
|
||||
return Status.VALUE_TOO_BIG;
|
||||
}
|
||||
else {
|
||||
return Status.OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Status.VALUE_INVALID_TYPE;
|
||||
},
|
||||
|
||||
_validateBoolean: function(param, value) {
|
||||
return bobj.crv.params.Validator.ValueStatus.OK;
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
================================================================================
|
||||
Utility Functions
|
||||
================================================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get an object that represents a Date and can be serialized to a json string
|
||||
*
|
||||
* @param date [Date] The Date instance that should be represented as json
|
||||
*
|
||||
* @return [Object] Object representing the date with (key, value) pairs
|
||||
*/
|
||||
bobj.crv.params.dateToJson = function(date) {
|
||||
return {
|
||||
d: date.getDate(),
|
||||
m: date.getMonth(),
|
||||
y: date.getFullYear(),
|
||||
h: date.getHours(),
|
||||
min: date.getMinutes(),
|
||||
s: date.getSeconds(),
|
||||
ms: date.getMilliseconds()
|
||||
};
|
||||
};
|
||||
|
||||
bobj.crv.params.getDateCompareFunc = function(type) {
|
||||
var PARAMS = bobj.crv.params;
|
||||
var Type = PARAMS.DataTypes;
|
||||
|
||||
switch (type) {
|
||||
case Type.DATE:
|
||||
return PARAMS.compareDate;
|
||||
case Type.TIME:
|
||||
return PARAMS.compareTime;
|
||||
case Type.DATE_TIME:
|
||||
return PARAMS.compareDateTime;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
bobj.crv.params.compareDateTime = function(dateTimeA, dateTimeB) {
|
||||
var PARAMS = bobj.crv.params;
|
||||
var Result = PARAMS.CompareResults;
|
||||
|
||||
var dateResult = PARAMS.compareDate(dateTimeA,dateTimeB);
|
||||
var timeResult = PARAMS.compareTime(dateTimeA,dateTimeB);
|
||||
|
||||
if(dateResult == Result.EQUAL && timeResult == Result.EQUAL) {
|
||||
return Result.EQUAL;
|
||||
}
|
||||
|
||||
if(dateResult != Result.EQUAL) {
|
||||
return dateResult;
|
||||
}
|
||||
else {
|
||||
return timeResult;
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* Compares two dates
|
||||
* @param dateA [JSON DateTime {y,m,d,h,m,s,ms}] first date value
|
||||
* @param dateB [JSON DateTime {y,m,d,h,m,s,ms}] second date value
|
||||
*
|
||||
* @return
|
||||
* 0: dateA = dateB
|
||||
* 1: dateA > dateB
|
||||
* -1: dateA < dateB
|
||||
*/
|
||||
bobj.crv.params.compareDate = function(dateTimeA, dateTimeB) {
|
||||
var Result = bobj.crv.params.CompareResults;
|
||||
|
||||
if( dateTimeA.d == dateTimeB.d && dateTimeA.m == dateTimeB.m && dateTimeA.y == dateTimeB.y){
|
||||
return Result.EQUAL;
|
||||
}
|
||||
|
||||
if( dateTimeA.y > dateTimeB.y) {
|
||||
return Result.TOO_BIG;
|
||||
}
|
||||
else if(dateTimeA.y < dateTimeB.y) {
|
||||
return Result.TOO_SMALL;
|
||||
}
|
||||
|
||||
if(dateTimeA.m > dateTimeB.m) {
|
||||
return Result.TOO_BIG;
|
||||
}
|
||||
else if(dateTimeA.m < dateTimeB.m) {
|
||||
return Result.TOO_SMALL;
|
||||
}
|
||||
|
||||
if(dateTimeA.d > dateTimeB.d) {
|
||||
return Result.TOO_BIG;
|
||||
}
|
||||
else if(dateTimeA.d < dateTimeB.d) {
|
||||
return Result.TOO_SMALL;
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* Compares two times
|
||||
* @param timeA [JSON DateTime {y,m,d,h,m,s,ms}] first time value
|
||||
* @param timeB [JSON DateTime {y,m,d,h,m,s,ms}] second time value
|
||||
*
|
||||
* @return
|
||||
* 0: dateA = dateB
|
||||
* 1: dateA > dateB
|
||||
* -1: dateA < dateB
|
||||
*/
|
||||
bobj.crv.params.compareTime = function(dateTimeA,dateTimeB) {
|
||||
var Result = bobj.crv.params.CompareResults;
|
||||
|
||||
if(dateTimeA.h == dateTimeB.h && dateTimeA.min == dateTimeB.min && dateTimeA.s == dateTimeB.s && dateTimeA.ms == dateTimeB.ms) {
|
||||
return Result.EQUAL;
|
||||
}
|
||||
|
||||
if(dateTimeA.h > dateTimeB.h) {
|
||||
return Result.TOO_BIG;
|
||||
}
|
||||
else if(dateTimeA.h < dateTimeB.h){
|
||||
return Result.TOO_SMALL;
|
||||
}
|
||||
|
||||
if(dateTimeA.min > dateTimeB.min) {
|
||||
return Result.TOO_BIG;
|
||||
}
|
||||
else if(dateTimeA.min < dateTimeB.min) {
|
||||
return Result.TOO_SMALL;
|
||||
}
|
||||
|
||||
if(dateTimeA.s > dateTimeB.s) {
|
||||
return Result.TOO_BIG;
|
||||
}
|
||||
else if(dateTimeA.s < dateTimeB.s) {
|
||||
return Result.TOO_SMALL;
|
||||
}
|
||||
|
||||
if(dateTimeA.ms > dateTimeB.ms) {
|
||||
return Result.TOO_BIG;
|
||||
}
|
||||
else if(dateTimeA.ms < dateTimeB.ms){
|
||||
return Result.TOO_SMALL;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a Date instance from an object containing (key, value) pairs
|
||||
*
|
||||
* @param json [Object] Object with keys that match Date properties
|
||||
*
|
||||
* @return [Date] Returns a Date instance
|
||||
*/
|
||||
bobj.crv.params.jsonToDate = function(json) {
|
||||
var date = new Date();
|
||||
|
||||
if (json) {
|
||||
date.setFullYear(json.y || 0, json.m || 0, json.d || 1);
|
||||
date.setHours(json.h || 0);
|
||||
date.setMinutes(json.min || 0);
|
||||
date.setSeconds(json.s || 0);
|
||||
date.setMilliseconds(json.ms || 0);
|
||||
}
|
||||
|
||||
return date;
|
||||
};
|
||||
|
||||
bobj.crv.params.getValue = function (pair) {
|
||||
if (pair === undefined || pair === null || pair.value === undefined)
|
||||
return pair;
|
||||
|
||||
return pair.value;
|
||||
};
|
||||
|
||||
bobj.crv.params.getDescription = function (pair) {
|
||||
if (pair === undefined || pair === null || pair.desc === undefined)
|
||||
return null;
|
||||
|
||||
return pair.desc;
|
||||
};
|
||||
1203
crystalreportviewers13/js/crviewer/ParameterController.js
Normal file
170
crystalreportviewers13/js/crviewer/ParameterDialog.js
Normal file
@@ -0,0 +1,170 @@
|
||||
/*
|
||||
================================================================================
|
||||
ParameterDialog
|
||||
|
||||
Advanced Dialog for editing parameters using the prompt engine
|
||||
================================================================================
|
||||
*/
|
||||
|
||||
bobj.crv.params.newParameterDialog = function(kwArgs) {
|
||||
kwArgs = MochiKit.Base.update({
|
||||
id: bobj.uniqueId(),
|
||||
prompt: null,
|
||||
showCB : null,
|
||||
hideCB : null
|
||||
}, kwArgs);
|
||||
|
||||
var o = newDialogBoxWidget(
|
||||
kwArgs.id,
|
||||
L_bobj_crv_ParamsDlgTitle,
|
||||
kwArgs.width,
|
||||
kwArgs.height /*,defaultCB,cancelCB,noCloseButton*/);
|
||||
|
||||
// Update instance with constructor arguments
|
||||
bobj.fillIn(o, kwArgs);
|
||||
|
||||
// Update instance with member functions
|
||||
o._showDialogBox = o.show;
|
||||
o._initDialogBox = o.init;
|
||||
o._resizeSignal = null;
|
||||
MochiKit.Base.update(o, bobj.crv.params.ParameterDialog);
|
||||
|
||||
return o;
|
||||
};
|
||||
|
||||
bobj.crv.params.ParameterDialog = {
|
||||
init : function() {
|
||||
this._initDialogBox ();
|
||||
this._form = document.getElementById (this.id + '_form');
|
||||
window.paramWindow = this;
|
||||
},
|
||||
|
||||
_checkInitialization : function() {
|
||||
if (!this.layer) {
|
||||
targetApp (this.getHTML ());
|
||||
this.init ();
|
||||
}
|
||||
},
|
||||
|
||||
show : function(show) {
|
||||
if (show) {
|
||||
this._checkInitialization ();
|
||||
this.doLayout ();
|
||||
this.setResize (MochiKit.Base.noop);
|
||||
this._showDialogBox (true);
|
||||
o._resizeSignal = MochiKit.Signal.connect(window, 'onresize', this, '_onWindowResize');
|
||||
} else {
|
||||
if (this.layer)
|
||||
this._showDialogBox (false);
|
||||
bobj.crv.SignalDisposer.dispose(o._resizeSignal, true);
|
||||
}
|
||||
|
||||
if (show && this.showCB) {
|
||||
this.showCB ();
|
||||
} else if (!show && this.hideCB) {
|
||||
this.hideCB ();
|
||||
}
|
||||
},
|
||||
|
||||
isVisible : function() {
|
||||
return (this.initialized () && this.isDisplayed ());
|
||||
},
|
||||
|
||||
/* if dialog's height is less than window's height, it would return dialog's height
|
||||
if dialog's height is greater than window's height, it would return window's height - 100
|
||||
if dialog's height is less than 100, it would return 100
|
||||
*/
|
||||
getPreferredHeight : function () {
|
||||
return Math.min(Math.max (100, winHeight() - 100), this.getFormHeight());
|
||||
},
|
||||
|
||||
getFormHeight : function () {
|
||||
var form = this._form.cloneNode(true);
|
||||
form.style.display = "none";
|
||||
form.style.height ="";
|
||||
document.body.appendChild(form);
|
||||
var dimension = MochiKit.Style.getElementDimensions(form);
|
||||
form.innerHTML = ""; // http://support.microsoft.com/kb/925014
|
||||
document.body.removeChild(form);
|
||||
|
||||
return dimension.h;
|
||||
},
|
||||
|
||||
_onWindowResize : function () {
|
||||
window.paramWindow.doLayout();
|
||||
window.paramWindow.center();
|
||||
},
|
||||
|
||||
doLayout: function () {
|
||||
if(this._form) {
|
||||
this._form.style.height = this.getPreferredHeight() + "px";
|
||||
}
|
||||
},
|
||||
|
||||
updateHtmlAndDisplay : function(html) {
|
||||
if (html) {
|
||||
this._checkInitialization ();
|
||||
|
||||
if (this.isDisplayed ()) {
|
||||
this.show (false);
|
||||
}
|
||||
|
||||
var ext = bobj.html.extractHtml (html);
|
||||
|
||||
var styleText = "";
|
||||
for ( var i = 0, len = ext.styles.length; i < len; i++) {
|
||||
styleText += ext.styles[i].text + '\n';
|
||||
}
|
||||
|
||||
var styleLayerID = this.id + '_stylesheet';
|
||||
|
||||
var styleLayer = getLayer(styleLayerID);
|
||||
if(styleLayer) {
|
||||
MochiKit.DOM.removeElement (styleLayer);
|
||||
}
|
||||
|
||||
if(styleText.length > 0) {
|
||||
bobj.addStyleSheet (styleText, styleLayerID);
|
||||
}
|
||||
|
||||
if (this._form) {
|
||||
this._form.innerHTML = '<div style="overflow:auto">' + ext.html + '</div>';
|
||||
}
|
||||
|
||||
var callback = function (parameterDialog, scripts) {
|
||||
return function () {
|
||||
|
||||
//Must show dialog before executing scripts as scripts could change scroll position
|
||||
parameterDialog.show(true);
|
||||
|
||||
for ( var iScripts = 0, scriptsLen = scripts.length; iScripts < scriptsLen; ++iScripts) {
|
||||
var script = scripts[iScripts];
|
||||
if (!script) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (script.text) {
|
||||
bobj.evalInWindow (script.text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}(this, ext.scripts);
|
||||
|
||||
//CSS links in extracted html are first loaded, then dialog is shown to correctly calcualte
|
||||
//the width and height of dialog
|
||||
|
||||
bobj.includeCSSLinksAndExecuteCallback ( ext.links, callback);
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
getHTML : function(html) {
|
||||
var FORM = bobj.html.FORM;
|
||||
var DIV = bobj.html.DIV;
|
||||
var onsubmit = 'eventCancelBubble(event);return false;';
|
||||
|
||||
return this.beginHTML() +
|
||||
DIV({'class' : 'dlgFrame naviBarFrame', style : { padding : '20px 15px 5px 20px'}}, FORM({id: this.id + '_form', style : {overflow : 'auto'}, onsubmit: onsubmit})) +
|
||||
this.endHTML();
|
||||
}
|
||||
};
|
||||
88
crystalreportviewers13/js/crviewer/ParameterInfoRow.js
Normal file
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
================================================================================
|
||||
ParameterInfoRow
|
||||
|
||||
Internal class for use by ParameterUI. Draws a UI for a single info row.
|
||||
This row is always displayed as last child of parameterUI
|
||||
================================================================================
|
||||
*/
|
||||
|
||||
bobj.crv.params.ParameterInfoRow = function(parentId) {
|
||||
this.layer = null;
|
||||
this.parentId = parentId;
|
||||
this.id = bobj.uniqueId();
|
||||
};
|
||||
|
||||
bobj.crv.params.ParameterInfoRow.prototype = {
|
||||
setTabDisabled : function(dis) {
|
||||
if (this.layer) {
|
||||
bobj.disableTabbingKey(this.layer, dis)
|
||||
}
|
||||
},
|
||||
|
||||
init : function() {
|
||||
var parent = getLayer(this.parentId);
|
||||
if (parent) {
|
||||
append2(parent, this.getHTML());
|
||||
this.layer = getLayer(this.id);
|
||||
}
|
||||
|
||||
if(this.layer) {
|
||||
MochiKit.Signal.connect(this.layer, "onclick", this, '_onClick');
|
||||
MochiKit.Signal.connect(this.layer, "onkeydown", this, '_onKeyDown');
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
getHTML : function() {
|
||||
return bobj.html.DIV( {
|
||||
'class' :'parameterInfoRow',
|
||||
id :this.id,
|
||||
"tabIndex" : "0"
|
||||
});
|
||||
},
|
||||
|
||||
setText : function(text) {
|
||||
if (!this.layer)
|
||||
this.init();
|
||||
|
||||
this.layer.innerHTML = text;
|
||||
},
|
||||
|
||||
setVisible : function(isVisible) {
|
||||
if (isVisible) {
|
||||
if (!this.layer)
|
||||
this.init();
|
||||
|
||||
this.shiftToLastRow();
|
||||
this.layer.style.display = "block";
|
||||
} else {
|
||||
if (this.layer)
|
||||
this.layer.style.display = "none";
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* ParamterInfoRow must always be displayed after all ParmeterValueRows
|
||||
* @return
|
||||
*/
|
||||
shiftToLastRow : function() {
|
||||
var parentNode = getLayer(this.parentId);
|
||||
if (this.layer && parentNode) {
|
||||
parentNode.removeChild(this.layer);
|
||||
parentNode.appendChild(this.layer);
|
||||
}
|
||||
},
|
||||
|
||||
_onClick : function (ev) {
|
||||
MochiKit.Signal.signal(this, "switch");
|
||||
ev.stop();
|
||||
},
|
||||
|
||||
_onKeyDown : function (ev) {
|
||||
if(ev && ev.key() && ev.key().code == 13) {
|
||||
MochiKit.Signal.signal(this, "switch");
|
||||
ev.stop();
|
||||
}
|
||||
}
|
||||
};
|
||||
277
crystalreportviewers13/js/crviewer/ParameterPanel.js
Normal file
@@ -0,0 +1,277 @@
|
||||
/* Copyright (c) Business Objects 2006. All rights reserved. */
|
||||
|
||||
/*
|
||||
================================================================================
|
||||
ParameterPanel
|
||||
================================================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
bobj.crv.params.newParameterPanel = function(kwArgs) {
|
||||
kwArgs = MochiKit.Base.update({
|
||||
id: bobj.uniqueId() + '_IPPanel'
|
||||
}, kwArgs);
|
||||
|
||||
var o = newWidget(kwArgs.id);
|
||||
o.widgetType = 'ParameterPanel';
|
||||
|
||||
// Update instance with constructor arguments
|
||||
bobj.fillIn(o, kwArgs);
|
||||
|
||||
// Update instance with member functions
|
||||
MochiKit.Base.update(o, bobj.crv.params.ParameterPanel);
|
||||
|
||||
o._tabPanel = bobj.crv.newStackedPanel({
|
||||
id: o.id + '_ParamtersStack'
|
||||
});
|
||||
|
||||
//Layer that appears on top of panel when it is disabled; necessary for preventing user to select parameters/widgets
|
||||
o._overlayLayer = new bobj.crv.params.ParameterPanel.OverlayLayer(o.id);
|
||||
o._toolbar = bobj.crv.params.newParameterPanelToolbar({
|
||||
id: o.id + '_IPToolbar'
|
||||
});
|
||||
|
||||
return o;
|
||||
};
|
||||
|
||||
bobj.crv.params.ParameterPanel = {
|
||||
setToolbarCallBacks : function(applyClickCB, resetClickCB) {
|
||||
if(this._toolbar) {
|
||||
this._toolbar.applyClickCB = applyClickCB;
|
||||
this._toolbar.resetClickCB = resetClickCB;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Disables panel by showing modal layer on top of panel, reducing opacity of panel, and disabling tabbing between widgets
|
||||
*/
|
||||
setDisabled : function(dis) {
|
||||
this._overlayLayer.setVisible (dis);
|
||||
this.setTabDisabled (dis);
|
||||
},
|
||||
|
||||
/**
|
||||
* Disables tabbing for toolbar and all parameters within panel
|
||||
*/
|
||||
setTabDisabled : function(dis) {
|
||||
this._toolbar.setTabDisabled (dis);
|
||||
this._tabPanel.setTabDisabled (dis);
|
||||
},
|
||||
|
||||
init : function() {
|
||||
Widget_init.call (this);
|
||||
this._toolbar.init ();
|
||||
if (this._tabPanel) {
|
||||
this._tabPanel.init ();
|
||||
}
|
||||
|
||||
MochiKit.Signal.signal (this, "resetParamPanel");
|
||||
},
|
||||
|
||||
update : function (update) {
|
||||
if (update && update.cons == "bobj.crv.params.newParameterPanel") {
|
||||
if(update.args && update.args.isResetParamPanel)
|
||||
MochiKit.Signal.signal (this, "resetParamPanel");
|
||||
}
|
||||
},
|
||||
|
||||
getHTML : function() {
|
||||
var DIV = bobj.html.DIV;
|
||||
var layerStyle = {
|
||||
overflow : 'hidden',
|
||||
width : this.width ? bobj.unitValue(this.width) : 'auto',
|
||||
height : this.height ? bobj.unitValue(this.height) : 'auto'
|
||||
}
|
||||
|
||||
var innerHTML = this._toolbar.getHTML ();
|
||||
if (this._tabPanel) {
|
||||
innerHTML += this._tabPanel.getHTML ();
|
||||
}
|
||||
|
||||
return DIV ( {
|
||||
id : this.id,
|
||||
style : layerStyle
|
||||
}, innerHTML);
|
||||
},
|
||||
|
||||
getBestFitHeight : function () {
|
||||
var height = 0;
|
||||
if(this._tabPanel) {
|
||||
/**
|
||||
* Since container of parampanel could be invisible, getHiddenElementDimensions has to be called
|
||||
* instead of element.getHeight()
|
||||
*/
|
||||
height += bobj.getHiddenElementDimensions(this._tabPanel.layer).h;
|
||||
}
|
||||
|
||||
if(this._toolbar)
|
||||
height += this._toolbar.getHeight ();
|
||||
|
||||
return height;
|
||||
},
|
||||
|
||||
/**
|
||||
* Resize the panel
|
||||
*
|
||||
* @param w [int - optional] Width in pixels
|
||||
* @param h [int - optional] Height in pixels
|
||||
*/
|
||||
resize : function(w, h) {
|
||||
Widget_resize.call (this, w, h);
|
||||
|
||||
if (this._toolbar) {
|
||||
w = this.layer.clientWidth;
|
||||
this._toolbar.resize (w);
|
||||
if (this._tabPanel) {
|
||||
h = this.layer.clientHeight - this._toolbar.getHeight ();
|
||||
this._tabPanel.resize (w, h);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Add a ParameterUI instance to the panel
|
||||
*
|
||||
* @param paramUI [ParameterUI]
|
||||
* @param label [String] Parameter title
|
||||
* @param isDataFetching [bool] Shows the data fetching icon when true
|
||||
*/
|
||||
addParameter : function(kwArgs) {
|
||||
kwArgs = MochiKit.Base.update ( {
|
||||
paramUI : null,
|
||||
label : null,
|
||||
isDataFetching : false,
|
||||
openAdvCB : null,
|
||||
clearValuesCB : null,
|
||||
id : this._tabPanel.id + '_P' + (this._tabPanel.getNumTabs () + 1)
|
||||
}, kwArgs);
|
||||
|
||||
if (kwArgs.paramUI) {
|
||||
var paramTab = bobj.crv.newStackedTab (kwArgs);
|
||||
paramTab.setContent (kwArgs.paramUI);
|
||||
this._tabPanel.addTab (paramTab);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Remove a ParameterUI instance from the panel
|
||||
*
|
||||
* @param index [int] Index of the widget
|
||||
*/
|
||||
removeParameter : function(index) {
|
||||
this._tabPanel.removeTab(index);
|
||||
},
|
||||
|
||||
getWidth : function() {
|
||||
if (this.layer) {
|
||||
return this.layer.offsetWidth;
|
||||
}
|
||||
return this.width;
|
||||
},
|
||||
|
||||
setResetButtonEnabled : function(isEnabled) {
|
||||
this._toolbar.resetButton.setDisabled (!isEnabled);
|
||||
var tooltip = isEnabled ? L_bobj_crv_ResetTip : L_bobj_crv_ResetDisabledTip;
|
||||
this._toolbar.resetButton.changeTooltip (tooltip, true);
|
||||
},
|
||||
|
||||
setApplyButtonEnabled : function(isEnabled) {
|
||||
this._toolbar.applyButton.setDisabled (!isEnabled);
|
||||
var tooltip = isEnabled ? L_bobj_crv_ParamsApplyTip : L_bobj_crv_ParamsApplyDisabledTip;
|
||||
this._toolbar.applyButton.changeTooltip (tooltip, true);
|
||||
},
|
||||
|
||||
isApplyButtonEnabled : function () {
|
||||
return this._toolbar != null && this._toolbar.applyButton != null && !this._toolbar.applyButton.isDisabled();
|
||||
},
|
||||
|
||||
getIndex : function(paramUI) {
|
||||
var numTabs = this._tabPanel.getNumTabs ();
|
||||
for ( var idx = 0; idx < numTabs; ++idx) {
|
||||
var tab = this._tabPanel.getTab (idx);
|
||||
if (tab.getContent () === paramUI) {
|
||||
return idx;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
},
|
||||
|
||||
getParameterTabByWidget : function(paramUI) {
|
||||
var index = this.getIndex (paramUI);
|
||||
if (index >= 0)
|
||||
return this._tabPanel.getTab (index);
|
||||
|
||||
return null;
|
||||
},
|
||||
|
||||
getParameter : function(index) {
|
||||
var tab = this._tabPanel.getTab (index);
|
||||
if (tab) {
|
||||
return tab.getContent ();
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
* @return ParameterTab, tab specified by index
|
||||
*/
|
||||
getParameterTab : function(index) {
|
||||
return this._tabPanel.getTab (index);
|
||||
},
|
||||
|
||||
/**
|
||||
* return Number of tabs/parameters in panel
|
||||
*/
|
||||
getParameterCount : function() {
|
||||
return this._tabPanel.getNumTabs ();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* A layer that appears on top of panel when it is disabled. Prevents user from selecting widgets
|
||||
* inside panel
|
||||
*/
|
||||
bobj.crv.params.ParameterPanel.OverlayLayer = function(paramPanelID) {
|
||||
this.paramPanelId = paramPanelID;
|
||||
this.layer = null;
|
||||
this.id = bobj.uniqueId();
|
||||
this.widx = _widgets.length
|
||||
_widgets[this.widx] = this;
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
bobj.crv.params.ParameterPanel.OverlayLayer.prototype = {
|
||||
setVisible: function(visible) {
|
||||
if(!this.layer) {
|
||||
this.init();
|
||||
}
|
||||
if(this.css) {
|
||||
this.css.visibility = visible ? "visible" : "hidden";
|
||||
}
|
||||
},
|
||||
|
||||
isVisible: function() {
|
||||
if(!this.layer) {
|
||||
this.init();
|
||||
}
|
||||
return this.css.visibility == "visible";
|
||||
},
|
||||
|
||||
getHTML: function() {
|
||||
return '<div id = ' + this.id + ' onselectstart="return false" ondragstart="return false" onmousedown="'+_codeWinName+'.eventCancelBubble(event)" border="0" hspace="0" vspace="0" src="'+_skin+'../transp.gif" class="paramPanelOverLay">'+(_ie?img(_skin+'../transp.gif','100%','100%',null,'ISMAP'):'')+'</div>'
|
||||
},
|
||||
|
||||
init: function() {
|
||||
var paramPanelLayer = getLayer(this.paramPanelId);
|
||||
|
||||
if(paramPanelLayer) {
|
||||
append2(paramPanelLayer, this.getHTML()); //adds overlay layer to parameter panel layer
|
||||
}
|
||||
|
||||
Widget_init.call(this);
|
||||
}
|
||||
}
|
||||
104
crystalreportviewers13/js/crviewer/ParameterPanelToolbar.js
Normal file
@@ -0,0 +1,104 @@
|
||||
|
||||
/*
|
||||
================================================================================
|
||||
ParameterPanelToolbar
|
||||
|
||||
Contains the Delete and Run buttons
|
||||
================================================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
bobj.crv.params.newParameterPanelToolbar = function(kwArgs) {
|
||||
kwArgs = MochiKit.Base.update({
|
||||
id: bobj.uniqueId()
|
||||
}, kwArgs);
|
||||
var o = newPaletteContainerWidget(kwArgs.id);
|
||||
|
||||
bobj.fillIn(o, kwArgs);
|
||||
o.widgetType = 'ParameterPanelToolbar';
|
||||
|
||||
// Attach member functions
|
||||
o._paletteContainerInit = o.init;
|
||||
MochiKit.Base.update(o, bobj.crv.params.ParameterPanelToolbar);
|
||||
|
||||
o._palette = newPaletteWidget(o.id + "_palette");
|
||||
o.add(o._palette);
|
||||
|
||||
var bind = MochiKit.Base.bind;
|
||||
|
||||
o.applyButton = newIconWidget(
|
||||
o.id + '_applyBtn',
|
||||
bobj.crv.allInOne.uri,
|
||||
bind(o._onApplyClick, o), //clickCB,
|
||||
L_bobj_crv_ParamsApply, //text
|
||||
L_bobj_crv_ParamsApplyDisabledTip,//tooltip,
|
||||
16, 16, 3, 3 + bobj.crv.allInOne.paramRunDy, 25, 3 + bobj.crv.allInOne.paramRunDy, false); //width, height, dx, dy, disDx, disDy
|
||||
|
||||
o.applyButton.setClasses("", "", "", ""); //FIXME : saeed, Assign css class
|
||||
o.resetButton = newIconWidget(
|
||||
o.id + '_resetBtn',
|
||||
bobj.crv.allInOne.uri,
|
||||
bind(o._onResetClick, o), //clickCB,
|
||||
L_bobj_crv_Reset, //text
|
||||
L_bobj_crv_ResetDisabledTip,//tooltip,
|
||||
16, 16, 0, bobj.crv.allInOne.undoDy, 16, bobj.crv.allInOne.undoDy, false); //width, height, dx, dy, disDx, disDy
|
||||
|
||||
o.resetButton.setClasses("", "", "", ""); //FIXME : saeed, Assign css class
|
||||
o._palette.add(o.applyButton);
|
||||
o._palette.add(); // separator
|
||||
o._palette.add(o.resetButton);
|
||||
|
||||
return o;
|
||||
};
|
||||
|
||||
bobj.crv.params.ParameterPanelToolbar = {
|
||||
init : function() {
|
||||
this._paletteContainerInit ();
|
||||
this._palette.init ();
|
||||
this.applyButton.setDisabled (true);
|
||||
this.resetButton.setDisabled (true);
|
||||
},
|
||||
|
||||
/**
|
||||
* Disables tabbing for all buttons in toolbar
|
||||
*/
|
||||
setTabDisabled : function(dis) {
|
||||
var items = [ this.applyButton, this.resetButton ];
|
||||
|
||||
for ( var i = 0, len = items.length; i < len; i++) {
|
||||
var item = items[i];
|
||||
if (item) {
|
||||
bobj.disableTabbingKey (item.layer, dis);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Overrides parent. Opens the toolbar's tags.
|
||||
*/
|
||||
beginHTML : function() {
|
||||
return bobj.html.openTag ('div', {
|
||||
id : this.id,
|
||||
'class' : 'parameterPanelToolbar'
|
||||
});
|
||||
},
|
||||
|
||||
getHTML : function() {
|
||||
return (this.beginHTML () + this._palette.getHTML () + this.endHTML ());
|
||||
},
|
||||
|
||||
_onApplyClick : function() {
|
||||
if (this.applyClickCB) {
|
||||
bobj.crv.logger.info ('UIAction ParameterPanel.Apply');
|
||||
this.applyClickCB ();
|
||||
}
|
||||
},
|
||||
|
||||
_onResetClick : function() {
|
||||
if (this.resetClickCB) {
|
||||
this.resetClickCB ();
|
||||
}
|
||||
}
|
||||
};
|
||||
404
crystalreportviewers13/js/crviewer/ParameterUI.js
Normal file
@@ -0,0 +1,404 @@
|
||||
|
||||
/* Copyright (c) Business Objects 2006. All rights reserved. */
|
||||
|
||||
/*
|
||||
================================================================================
|
||||
ParameterUI
|
||||
|
||||
Widget for displaying and editing parameter values. Contains one or many
|
||||
ParameterValueRows and, optionally, UI that allows rows to be added.
|
||||
================================================================================
|
||||
*/
|
||||
|
||||
bobj.crv.params.newParameterUI = function(kwArgs) {
|
||||
kwArgs = MochiKit.Base.update({
|
||||
id: bobj.uniqueId(),
|
||||
canChangeOnPanel: false,
|
||||
allowCustom: false,
|
||||
isPassword : false,
|
||||
isReadOnlyParam: true,
|
||||
allowRange : false,
|
||||
values: [],
|
||||
defaultValues: null,
|
||||
width: '200px',
|
||||
changeValueCB: null,
|
||||
enterPressCB: null,
|
||||
openAdvDialogCB: null,
|
||||
maxNumParameterDefaultValues: 200,
|
||||
tooltip : null,
|
||||
calendarProperties : {displayValueFormat : '' , isTimeShown : false, hasButton : false, iconUrl : ''},
|
||||
maxNumValuesDisplayed : 7,
|
||||
canOpenAdvDialog : false
|
||||
}, kwArgs);
|
||||
|
||||
var o = newWidget(kwArgs.id);
|
||||
|
||||
// Update instance with constructor arguments
|
||||
bobj.fillIn(o, kwArgs);
|
||||
|
||||
o.displayAllValues = false;
|
||||
|
||||
// Update instance with member functions
|
||||
MochiKit.Base.update(o, bobj.crv.params.ParameterUI);
|
||||
|
||||
o._createMenu();
|
||||
o._rows = [];
|
||||
o._infoRow = new bobj.crv.params.ParameterInfoRow(o.id);
|
||||
return o;
|
||||
};
|
||||
|
||||
bobj.crv.params.ParameterUI = {
|
||||
/**
|
||||
* Creates single menubar for all parameter value rows of current param UI
|
||||
*/
|
||||
_createMenu : function() {
|
||||
var dvLength = this.defaultValues.length;
|
||||
if (dvLength > 0) {
|
||||
var kwArgs = {
|
||||
originalValues : this.defaultValues
|
||||
};
|
||||
|
||||
if (dvLength == this.maxNumParameterDefaultValues) {
|
||||
kwArgs.originalValues[this.maxNumParameterDefaultValues] = L_bobj_crv_ParamsMaxNumDefaultValues;
|
||||
MochiKit.Base.update (kwArgs, {
|
||||
openAdvDialogCB : this.openAdvDialogCB,
|
||||
maxNumParameterDefaultValues : this.maxNumParameterDefaultValues
|
||||
});
|
||||
}
|
||||
|
||||
this._defaultValuesMenu = bobj.crv.params.newScrollMenuWidget (kwArgs);
|
||||
} else {
|
||||
this._defaultValuesMenu = null;
|
||||
}
|
||||
},
|
||||
|
||||
setFocusOnRow : function(rowIndex) {
|
||||
var row = this._rows[rowIndex];
|
||||
if (row)
|
||||
row.focus ();
|
||||
},
|
||||
|
||||
/*
|
||||
* Disables tabbing if dis is true
|
||||
*/
|
||||
setTabDisabled : function(dis) {
|
||||
for(var i = 0, len = this._rows.length; i < len; i++) {
|
||||
this._rows[i].setTabDisabled(dis);
|
||||
}
|
||||
|
||||
this._infoRow.setTabDisabled(dis);
|
||||
},
|
||||
|
||||
init : function() {
|
||||
Widget_init.call (this);
|
||||
|
||||
var rows = this._rows;
|
||||
for ( var i = 0, len = rows.length; i < len; ++i) {
|
||||
rows[i].init ();
|
||||
}
|
||||
|
||||
MochiKit.Signal.connect(this._infoRow, "switch", this, '_onSwitchDisplayAllValues');
|
||||
this.refreshUI ();
|
||||
},
|
||||
|
||||
/**
|
||||
* Processes actions triggered by clicks on "x more values" or "collapse" button displayed in inforow
|
||||
*/
|
||||
_onSwitchDisplayAllValues: function() {
|
||||
this.displayAllValues = !this.displayAllValues;
|
||||
var TIME_INTERVAL = 10; /* 10 msec or 100 actions per second */
|
||||
var timerIndex = 0;
|
||||
|
||||
if(this.displayAllValues) {
|
||||
if (this.values.length > this._rows.length) {
|
||||
for(var i = this._rows.length, l = this.values.length; i < l; i++) {
|
||||
var addRow = function(paramUI, value) {
|
||||
return function() { return paramUI._addRow(value); };
|
||||
};
|
||||
|
||||
timerIndex++;
|
||||
setTimeout(addRow(this, this.values[i]), TIME_INTERVAL * timerIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(this._rows.length > this.maxNumValuesDisplayed) {
|
||||
for(var i = this._rows.length -1; i >= this.maxNumValuesDisplayed; i--) {
|
||||
var deleteRow = function(paramUI, rowIndex) {
|
||||
return function() { return paramUI.deleteValue(rowIndex); };
|
||||
};
|
||||
|
||||
timerIndex++;
|
||||
setTimeout(deleteRow(this, i), TIME_INTERVAL * timerIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var signalResize = function(paramUI) {
|
||||
return function() {MochiKit.Signal.signal(paramUI, 'ParameterUIResized'); };
|
||||
};
|
||||
|
||||
setTimeout(signalResize(this), TIME_INTERVAL * timerIndex);
|
||||
},
|
||||
|
||||
getHTML : function() {
|
||||
var rowsHtml = '';
|
||||
|
||||
var values = this.values;
|
||||
var rows = this._rows;
|
||||
|
||||
var rowsCount = Math.min (values.length, this.maxNumValuesDisplayed);
|
||||
for ( var i = 0; i < rowsCount; ++i) {
|
||||
rows.push (this._getRow (values[i]));
|
||||
rowsHtml += rows[i].getHTML ();
|
||||
}
|
||||
|
||||
return bobj.html.DIV ( {
|
||||
id : this.id,
|
||||
style : {
|
||||
width : bobj.unitValue (this.width),
|
||||
'padding-left' : '20px'
|
||||
}
|
||||
}, rowsHtml);
|
||||
},
|
||||
|
||||
_getNewValueRowArgs : function(value) {
|
||||
return {
|
||||
value : value,
|
||||
defaultValues : this.defaultValues,
|
||||
width : this.width,
|
||||
isReadOnlyParam : this.isReadOnlyParam,
|
||||
canChangeOnPanel : this.canChangeOnPanel,
|
||||
allowCustom : this.allowCustom,
|
||||
isPassword : this.isPassword,
|
||||
calendarProperties : this.calendarProperties,
|
||||
defaultValuesMenu : this._defaultValuesMenu,
|
||||
tooltip : this.tooltip,
|
||||
isRangeValue : this.allowRange,
|
||||
canOpenAdvDialog : this.canOpenAdvDialog
|
||||
};
|
||||
},
|
||||
|
||||
_getNewValueRowConstructor : function() {
|
||||
return bobj.crv.params.newParameterValueRow;
|
||||
},
|
||||
|
||||
_getRow : function(value) {
|
||||
var row = this._getNewValueRowConstructor()(this._getNewValueRowArgs(value));
|
||||
var bind = MochiKit.Base.bind;
|
||||
|
||||
row.changeCB = bind(this._onChangeValue, this, row);
|
||||
row.enterCB = bind(this._onEnterValue, this, row);
|
||||
|
||||
return row;
|
||||
},
|
||||
|
||||
_addRow : function(value) {
|
||||
var row = this._getRow (value);
|
||||
this._rows.push (row);
|
||||
append (this.layer, row.getHTML ());
|
||||
|
||||
row.init ();
|
||||
|
||||
this.refreshUI ();
|
||||
return row;
|
||||
},
|
||||
|
||||
_onChangeValue : function(row) {
|
||||
if (this.changeValueCB) {
|
||||
this.changeValueCB (this._getRowIndex (row), row.getValue ());
|
||||
}
|
||||
},
|
||||
|
||||
_onEnterValue : function(row) {
|
||||
if (this.enterPressCB) {
|
||||
this.enterPressCB (this._getRowIndex (row));
|
||||
}
|
||||
},
|
||||
|
||||
_getRowIndex : function(row) {
|
||||
if (row) {
|
||||
var rows = this._rows;
|
||||
for ( var i = 0, len = rows.length; i < len; ++i) {
|
||||
if (rows[i] === row) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
},
|
||||
|
||||
getNumValues : function() {
|
||||
return this._rows.length;
|
||||
},
|
||||
|
||||
|
||||
refreshUI : function() {
|
||||
if (this.allowRange)
|
||||
this.alignRangeRows ();
|
||||
|
||||
var displayInfoRow = false;
|
||||
var infoRowText = "";
|
||||
|
||||
if (this.values.length > this.maxNumValuesDisplayed) {
|
||||
displayInfoRow = true;
|
||||
|
||||
if(this.displayAllValues)
|
||||
infoRowText = L_bobj_crv_Collapse;
|
||||
else {
|
||||
var hiddenValuesCount = this.values.length - this.maxNumValuesDisplayed;
|
||||
infoRowText = (hiddenValuesCount == 1) ? L_bobj_crv_ParamsMoreValue : L_bobj_crv_ParamsMoreValues;
|
||||
infoRowText = infoRowText.replace ("%1", hiddenValuesCount);
|
||||
}
|
||||
}
|
||||
|
||||
this._infoRow.setText (infoRowText);
|
||||
this._infoRow.setVisible (displayInfoRow);
|
||||
},
|
||||
|
||||
getValueAt : function(index) {
|
||||
var row = this._rows[index];
|
||||
if (row) {
|
||||
return row.getValue ();
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
getValues : function() {
|
||||
var values = [];
|
||||
for ( var i = 0, len = this._rows.length; i < len; ++i) {
|
||||
values.push (this._rows[i].getValue ());
|
||||
}
|
||||
return values;
|
||||
},
|
||||
|
||||
setValueAt : function(index, value) {
|
||||
var row = this._rows[index];
|
||||
if (row) {
|
||||
row.setValue (value);
|
||||
}
|
||||
|
||||
this.refreshUI ();
|
||||
},
|
||||
|
||||
resetValues : function(values) {
|
||||
if (!values) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.values = values;
|
||||
var valuesLen = values.length;
|
||||
var rowsLen = this._rows.length;
|
||||
|
||||
//Resets value
|
||||
for ( var i = 0; i < valuesLen && i < rowsLen; ++i) {
|
||||
this._rows[i].reset (values[i]);
|
||||
}
|
||||
|
||||
//removes newly added values that are not commited
|
||||
if (rowsLen > valuesLen) {
|
||||
for ( var i = rowsLen - 1; i >= valuesLen; --i) {
|
||||
// delete from the end to minimize calls to setBgColor
|
||||
this.deleteValue (i);
|
||||
}
|
||||
}
|
||||
//re-adds removed values
|
||||
else if (valuesLen > rowsLen) {
|
||||
for ( var i = rowsLen; i < valuesLen && (this.displayAllValues || i < this.maxNumValuesDisplayed); ++i) {
|
||||
var row = this._addRow (values[i]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
MochiKit.Signal.signal(this, 'ParameterUIResized');
|
||||
this.refreshUI ();
|
||||
},
|
||||
|
||||
alignRangeRows : function() {
|
||||
if (!this.allowRange)
|
||||
return;
|
||||
|
||||
var lowerBoundWidth = 0;
|
||||
for ( var i = 0, l = this._rows.length; i < l; i++) {
|
||||
var row = this._rows[i];
|
||||
var rangeField = row._valueWidget;
|
||||
lowerBoundWidth = Math.max (lowerBoundWidth, rangeField.getLowerBoundValueWidth ());
|
||||
}
|
||||
|
||||
for ( var i = 0, l = this._rows.length; i < l; i++) {
|
||||
var row = this._rows[i];
|
||||
var rangeField = row._valueWidget;
|
||||
rangeField.setLowerBoundValueWidth (lowerBoundWidth);
|
||||
}
|
||||
},
|
||||
|
||||
setValues : function(values) {
|
||||
if (!values)
|
||||
return;
|
||||
|
||||
this.values = values;
|
||||
var valuesLen = values.length;
|
||||
var rowsLen = this._rows.length;
|
||||
|
||||
for ( var i = 0; i < valuesLen && i < rowsLen; ++i) {
|
||||
this._rows[i].setValue (values[i]);
|
||||
}
|
||||
|
||||
if (rowsLen > valuesLen) {
|
||||
for ( var i = rowsLen - 1; i >= valuesLen; --i) {
|
||||
// delete from the end to minimize calls to setBgColor
|
||||
this.deleteValue (i);
|
||||
}
|
||||
} else if (valuesLen > rowsLen) {
|
||||
for ( var i = rowsLen; i < valuesLen && (this.displayAllValues || i < this.maxNumValuesDisplayed); ++i) {
|
||||
this._addRow (values[i]);
|
||||
}
|
||||
}
|
||||
|
||||
MochiKit.Signal.signal(this, 'ParameterUIResized');
|
||||
this.refreshUI ();
|
||||
},
|
||||
|
||||
setCleanValue : function(index, value) {
|
||||
var row = this._rows[index];
|
||||
if (row)
|
||||
row.setCleanValue (value);
|
||||
},
|
||||
|
||||
deleteValue : function(index) {
|
||||
if (index >= 0 && index < this._rows.length) {
|
||||
var row = this._rows[index];
|
||||
row.layer.parentNode.removeChild (row.layer);
|
||||
_widgets[row.widx] = null;
|
||||
|
||||
this._rows.splice (index, 1);
|
||||
var rowsLen = this._rows.length;
|
||||
}
|
||||
|
||||
this.refreshUI ();
|
||||
},
|
||||
|
||||
setWarning : function(index, warning) {
|
||||
var row = this._rows[index];
|
||||
if (row) {
|
||||
row.setWarning (warning);
|
||||
}
|
||||
},
|
||||
|
||||
getWarning : function(index) {
|
||||
var row = this._rows[index];
|
||||
if (row)
|
||||
return row.getWarning ();
|
||||
|
||||
return null;
|
||||
},
|
||||
|
||||
resize : function(w) {
|
||||
if (w !== null) {
|
||||
this.width = w;
|
||||
if (this.layer) {
|
||||
bobj.setOuterSize (this.layer, w);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
505
crystalreportviewers13/js/crviewer/ParameterValueRow.js
Normal file
@@ -0,0 +1,505 @@
|
||||
/*
|
||||
================================================================================
|
||||
ParameterValueRow
|
||||
|
||||
Internal class for use by ParameterUI. Darws a UI for a single parameter value.
|
||||
================================================================================
|
||||
*/
|
||||
|
||||
bobj.crv.params.newParameterValueRow = function(kwArgs) {
|
||||
kwArgs = MochiKit.Base.update({
|
||||
id: bobj.uniqueId(),
|
||||
value: '',
|
||||
defaultValues: null,
|
||||
isReadOnlyParam: true,
|
||||
canChangeOnPanel: false,
|
||||
isRangeValue : false,
|
||||
allowCustom: false,
|
||||
isPassword: false,
|
||||
calendarProperties : {displayValueFormat : '' , isTimeShown : false, hasButton : false, iconUrl : '', clickCB : null},
|
||||
changeCB: null,
|
||||
enterCB: null,
|
||||
defaultValuesMenu: null,
|
||||
tooltip : null,
|
||||
canOpenAdvDialog : false
|
||||
}, kwArgs);
|
||||
|
||||
var o = newWidget(kwArgs.id);
|
||||
o.widgetType = 'ParameterValueRow';
|
||||
o._prevValueString = kwArgs.value;
|
||||
o._warning = null;
|
||||
|
||||
// Update instance with constructor arguments
|
||||
bobj.fillIn(o, kwArgs);
|
||||
|
||||
// Update instance with member functions
|
||||
MochiKit.Base.update(o, bobj.crv.params.ParameterValueRow);
|
||||
|
||||
return o;
|
||||
};
|
||||
|
||||
bobj.crv.params.ParameterValueRow = {
|
||||
setTabDisabled : function(dis) {
|
||||
if (this._valueWidget)
|
||||
this._valueWidget.setTabDisabled (dis);
|
||||
|
||||
if (this._calendarButton)
|
||||
bobj.disableTabbingKey (this._calendarButton.layer, dis);
|
||||
},
|
||||
|
||||
/**
|
||||
* Resets widget, Restores old value, hides warning and adv dialog icons
|
||||
*/
|
||||
reset : function(value) {
|
||||
this.value = value;
|
||||
this._prevValueString = value;
|
||||
this.setWarning(null);
|
||||
/* Removing Red border color if previous value was errorneous */
|
||||
MochiKit.DOM.removeElementClass(this.layer, "hasError");
|
||||
|
||||
if(this._valueWidget) {
|
||||
this._valueWidget.reset(value);
|
||||
}
|
||||
},
|
||||
|
||||
init : function() {
|
||||
Widget_init.call (this);
|
||||
this._valueWidget.init ();
|
||||
if (this._calendarButton) {
|
||||
this._calendarButton.init ();
|
||||
}
|
||||
|
||||
this._valueCtn = getLayer (this.id + '_vc');
|
||||
this._btnCtn = getLayer (this.id + '_bc');
|
||||
this._valBtnCtn = getLayer (this.id + '_vab');
|
||||
|
||||
if (MochiKit.Base.isIE ()) {
|
||||
/* IE's 100% is different than other browsers,
|
||||
even in standards compliant mode.... */
|
||||
var marg = parseInt (MochiKit.Style.computedStyle (this._valueCtn, 'margin-right'), 10);
|
||||
if (bobj.isNumber (marg)) {
|
||||
this._valueWidget.layer.style.marginRight = (-1 * marg) + 'px';
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
calendarSetValue : function(value) {
|
||||
this.setValue (value);
|
||||
this.changeCB ();
|
||||
},
|
||||
|
||||
getHTML : function() {
|
||||
if (!this._valueWidget) {
|
||||
this._valueWidget = this._getValueWidget ();
|
||||
}
|
||||
if (this.calendarProperties.hasButton && !this._calendarButton) {
|
||||
var getValueCB = bobj.bindFunctionToObject (this.getValue, this);
|
||||
var setValueCB = bobj.bindFunctionToObject (this.calendarSetValue, this);
|
||||
this._calendarButton = bobj.crv.params.newCalendarButton ( {
|
||||
calendarProperties : this.calendarProperties,
|
||||
getValueCB : getValueCB,
|
||||
setValueCB : setValueCB
|
||||
});
|
||||
}
|
||||
|
||||
var DIV = bobj.html.DIV;
|
||||
var IMG = bobj.html.IMG;
|
||||
|
||||
var cssClass = ' iactParamRow';
|
||||
|
||||
if (this.canChangeOnPanel)
|
||||
cssClass += ' editable';
|
||||
else
|
||||
cssClass += ' readOnly';
|
||||
|
||||
if (MochiKit.Base.isIE () && bobj.isQuirksMode ()) {
|
||||
cssClass += ' ' + 'iactParamRowIE';
|
||||
}
|
||||
|
||||
return DIV ( {
|
||||
id : this.id,
|
||||
'class' : cssClass
|
||||
}, this.calendarProperties.hasButton ? this._getValueAndCalendarHTML () : this._getValueHTML ());
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* @return [String] Returns HTML for the the value
|
||||
*/
|
||||
_getValueHTML : function() {
|
||||
var DIV = bobj.html.DIV;
|
||||
var style = {};
|
||||
|
||||
if (MochiKit.Base.isIE () && bobj.isQuirksMode ()) {
|
||||
style.position = "absolute";
|
||||
style.top = "0px";
|
||||
style.left = "0px";
|
||||
}
|
||||
|
||||
return DIV ( {
|
||||
id : this.id + '_vc',
|
||||
'class' : 'iactParamValue',
|
||||
style : style
|
||||
}, this._valueWidget.getHTML ());
|
||||
},
|
||||
|
||||
/**
|
||||
* @return [String] Returns HTML for the value and a button beside it
|
||||
*/
|
||||
_getValueAndCalendarHTML : function() {
|
||||
var style = {};
|
||||
if (MochiKit.Base.isIE () && bobj.isQuirksMode ()) {
|
||||
style.width = '100%';
|
||||
}
|
||||
|
||||
var DIV = bobj.html.DIV;
|
||||
|
||||
var buttonRightOffset = (this._valueWidget.widgetType == "TextCombo") ? 16 : 0;
|
||||
buttonRightOffset += "px";
|
||||
|
||||
var html = DIV ( {
|
||||
id : this.id + "_vab",
|
||||
style : style,
|
||||
'class' : "iactParamValueAndButton"
|
||||
}, this._getValueHTML (), DIV ( {
|
||||
id : this.id + "_bc",
|
||||
'class' : "iactValueIcon",
|
||||
style : {
|
||||
position : "absolute",
|
||||
right : buttonRightOffset,
|
||||
top : "0",
|
||||
cursor : _hand
|
||||
}
|
||||
}, this._calendarButton.getHTML ()));
|
||||
|
||||
return html;
|
||||
},
|
||||
|
||||
getNewValueWidgetConstructor : function() {
|
||||
var showDefVals = this.defaultValuesMenu !== null && !this.isReadOnlyParam && this.canChangeOnPanel;
|
||||
|
||||
if (this.isRangeValue)
|
||||
return bobj.crv.params.newRangeField;
|
||||
else if (showDefVals)
|
||||
return bobj.crv.params.newTextCombo;
|
||||
else
|
||||
return bobj.crv.params.newTextField;
|
||||
},
|
||||
|
||||
getNewValueWidgetArgs : function() {
|
||||
var isEditable = this.allowCustom && this.canChangeOnPanel;
|
||||
return {
|
||||
password : this.isPassword,
|
||||
cleanValue : this.value,
|
||||
editable : isEditable,
|
||||
enterCB : bobj.bindFunctionToObject (this._onEnterPress, this),
|
||||
keyUpCB : isEditable ? bobj.bindFunctionToObject (this._onKeyUp, this) : null,
|
||||
tooltip : this.tooltip,
|
||||
foreColor : this.isReadOnlyParam ? bobj.Colors.GRAY : bobj.Colors.BLACK,
|
||||
focusCB : bobj.bindFunctionToObject (this.onFocus, this),
|
||||
blurCB : bobj.bindFunctionToObject (this.onBlur, this),
|
||||
canOpenAdvDialog : this.canOpenAdvDialog
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates a widget to display/edit the value.
|
||||
*
|
||||
* @return [Widget]
|
||||
*/
|
||||
_getValueWidget : function() {
|
||||
var cons = this.getNewValueWidgetConstructor ();
|
||||
var widget = cons (this.getNewValueWidgetArgs ());
|
||||
var showDefVals = this.defaultValuesMenu !== null && !this.isReadOnlyParam && this.canChangeOnPanel;
|
||||
|
||||
if (showDefVals) {
|
||||
widget.setMenu (this.defaultValuesMenu);
|
||||
widget.changeCB = bobj.bindFunctionToObject (this._onChange, this);
|
||||
}
|
||||
|
||||
return widget;
|
||||
},
|
||||
|
||||
onFocus : function() {
|
||||
this.refreshWarningPopup ();
|
||||
MochiKit.DOM.removeElementClass (this.layer, "hasError");
|
||||
},
|
||||
|
||||
refreshWarningPopup : function() {
|
||||
if (this._warning) {
|
||||
var pos = getPosScrolled (this.layer);
|
||||
var fontFamily = MochiKit.Style.computedStyle (this.layer, 'fontFamily');
|
||||
var fontSize = MochiKit.Style.computedStyle (this.layer, 'fontSize');
|
||||
var valueWidth = bobj.getStringWidth (this.getValue (), fontFamily, fontSize);
|
||||
var leftOffset = this.layer.offsetWidth < valueWidth ? this.layer.offsetWidth : valueWidth;
|
||||
var topOffset = 33;
|
||||
bobj.crv.WarningPopup.getInstance ().show (this._warning.message, pos.x + leftOffset, pos.y + topOffset);
|
||||
} else {
|
||||
bobj.crv.WarningPopup.getInstance ().hide ();
|
||||
MochiKit.DOM.removeElementClass (this.layer, "hasError");
|
||||
}
|
||||
|
||||
var tooltipText = this._warning ? this.tooltip + this._warning.message : this.tooltip;
|
||||
if (this._valueWidget)
|
||||
this._valueWidget.setTooltip (tooltipText);
|
||||
},
|
||||
|
||||
onBlur : function() {
|
||||
if (this._warning) {
|
||||
bobj.crv.WarningPopup.getInstance ().hide ();
|
||||
MochiKit.DOM.addElementClass (this.layer, "hasError");
|
||||
}
|
||||
},
|
||||
|
||||
getValue : function() {
|
||||
return this.value;
|
||||
},
|
||||
|
||||
setValue : function(value) {
|
||||
this.value = value;
|
||||
if (this._valueWidget)
|
||||
this._valueWidget.setValue (value);
|
||||
},
|
||||
|
||||
setCleanValue : function(value) {
|
||||
if (this._valueWidget)
|
||||
this._valueWidget.setCleanValue(value);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Set keyboard focus to the widget and mark it as selected
|
||||
*/
|
||||
focus : function() {
|
||||
if (this._valueWidget.widgetType == "TextCombo")
|
||||
this._valueWidget.text.focus ();
|
||||
else
|
||||
this._valueWidget.focus ();
|
||||
},
|
||||
|
||||
/**
|
||||
* Display a warning icon with a tooltip message
|
||||
*
|
||||
* @param warning
|
||||
* [String] Tooltip message. If null, warning is hidden.
|
||||
*/
|
||||
setWarning : function(warning) {
|
||||
this._warning = warning;
|
||||
this.refreshWarningPopup ();
|
||||
},
|
||||
|
||||
getWarning : function() {
|
||||
return this._warning;
|
||||
},
|
||||
|
||||
/**
|
||||
* Change the outer dimensions of the widget
|
||||
*
|
||||
* @param w
|
||||
* [int, optional] Width in pixels
|
||||
* @param h
|
||||
* [int, optional] Height in pixels
|
||||
*/
|
||||
resize : function(w, h) {
|
||||
bobj.setOuterSize (this.layer, w, h);
|
||||
},
|
||||
|
||||
deleteValue : function() {
|
||||
this._valueWidget.setValue ('', true);
|
||||
},
|
||||
|
||||
/**
|
||||
* Handle keyUp events when editing values or using keyboard navigation.
|
||||
*
|
||||
* @param e
|
||||
* [keyup event]
|
||||
*/
|
||||
_onKeyUp : function(e) {
|
||||
var event = new MochiKit.Signal.Event (src, e);
|
||||
var key = event.key ().string;
|
||||
var newValueString = this._valueWidget.getValue ();
|
||||
|
||||
switch (key) {
|
||||
case "KEY_ESCAPE":
|
||||
this._valueWidget.setValue (this._valueWidget.cleanValue);
|
||||
this._onChange ();
|
||||
break;
|
||||
|
||||
case "KEY_ARROW_LEFT":
|
||||
case "KEY_ARROW_RIGHT":
|
||||
case "KEY_HOME":
|
||||
case "KEY_END":
|
||||
case "KEY_TAB":
|
||||
break;
|
||||
|
||||
default:
|
||||
if (newValueString !== this._prevValueString) {
|
||||
this._onChange ()
|
||||
this._prevValueString = newValueString;
|
||||
}
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Delete the current value
|
||||
*/
|
||||
deleteValue : function() {
|
||||
this._valueWidget.setValue ('', true);
|
||||
},
|
||||
|
||||
_onChange : function() {
|
||||
this.value = this._valueWidget.getValue();
|
||||
if (this.changeCB)
|
||||
this.changeCB();
|
||||
},
|
||||
|
||||
/**
|
||||
* Handles Enter key press events.
|
||||
*/
|
||||
_onEnterPress : function() {
|
||||
if(this.enterCB)
|
||||
this.enterCB();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*
|
||||
================================================================================
|
||||
CalendarButton
|
||||
|
||||
Internal class. Button that fits inline with parameter values
|
||||
================================================================================
|
||||
*/
|
||||
bobj.crv.params.newCalendarButton = function(kwArgs) {
|
||||
kwArgs = MochiKit.Base.update( {
|
||||
id : bobj.uniqueId(),
|
||||
calendarProperties : null,
|
||||
getValueCB : null,
|
||||
setValueCB : null,
|
||||
calendarSignals : {
|
||||
okSignal : null,
|
||||
hideSignal : null,
|
||||
cancelSignal : null
|
||||
}
|
||||
}, kwArgs);
|
||||
|
||||
if (kwArgs.getValueCB == null || kwArgs.setValueCB == null || kwArgs.calendarProperties == null)
|
||||
throw "InvalidArgumentException";
|
||||
|
||||
var o = newIconWidget(
|
||||
kwArgs.id,
|
||||
kwArgs.calendarProperties.iconUrl,
|
||||
null,
|
||||
null,
|
||||
L_bobj_crv_ParamsCalBtn,
|
||||
14,14,0,0,0,0);
|
||||
|
||||
o.setClasses("", "", "", "iconcheckhover");
|
||||
|
||||
bobj.fillIn(o, kwArgs);
|
||||
|
||||
// Update instance with member functions
|
||||
o.margin = 0;
|
||||
o.oldInit = o.init;
|
||||
|
||||
MochiKit.Base.update(o, bobj.crv.params.CalendarButton);
|
||||
o.clickCB = bobj.bindFunctionToObject(o.onClick, o);
|
||||
|
||||
return o;
|
||||
};
|
||||
|
||||
bobj.crv.params.CalendarButton = {
|
||||
onClick : function() {
|
||||
var calendar = bobj.crv.Calendar.getInstance ();
|
||||
var date = bobj.external.date.getDateFromFormat (this.getValueCB (), this.calendarProperties.displayValueFormat);
|
||||
var connect = MochiKit.Signal.connect;
|
||||
if (date)
|
||||
calendar.setDate (date);
|
||||
|
||||
this.calendarSignals = {
|
||||
okSignal : connect (calendar, calendar.Signals.OK_CLICK, this, 'onClickCalendarOKButton'),
|
||||
cancelSignal : connect (calendar, calendar.Signals.CANCEL_CLICK, this, 'onClickCalendarCancelButton'),
|
||||
hideSignal : connect (calendar, calendar.Signals.ON_HIDE, this, 'onHideCalendar')
|
||||
};
|
||||
|
||||
var absPos = getPosScrolled (this.layer);
|
||||
var x = absPos.x + this.getWidth ();
|
||||
var y = absPos.y + this.getHeight () + 1;
|
||||
|
||||
calendar.setShowTime (this.calendarProperties.isTimeShown);
|
||||
calendar.show (true, x, y);
|
||||
},
|
||||
|
||||
onClickCalendarOKButton : function(date) {
|
||||
var strValue = bobj.external.date.formatDate (date, this.calendarProperties.displayValueFormat);
|
||||
this.setValueCB (strValue);
|
||||
},
|
||||
|
||||
onClickCalendarCancelButton : function() {
|
||||
this.clearCalendarSignals ();
|
||||
},
|
||||
|
||||
clearCalendarSignals : function() {
|
||||
for ( var identName in this.calendarSignals) {
|
||||
bobj.crv.SignalDisposer.dispose(this.calendarSignals[identName], true);
|
||||
this.calendarSignals[identName] = null;
|
||||
}
|
||||
},
|
||||
|
||||
onHideCalendar : function() {
|
||||
this.clearCalendarSignals ();
|
||||
if (this.layer.focus)
|
||||
this.layer.focus ();
|
||||
},
|
||||
|
||||
init : function() {
|
||||
this.oldInit ();
|
||||
this.layer.onfocus = IconWidget_realOverCB;
|
||||
this.layer.onblur = IconWidget_realOutCB;
|
||||
},
|
||||
|
||||
getHTML : function() {
|
||||
var imgCode;
|
||||
var h = bobj.html;
|
||||
if (this.src) {
|
||||
imgCode = h.DIV( {
|
||||
style : {
|
||||
overflow : 'hidden',
|
||||
height : '14px',
|
||||
position : 'relative',
|
||||
top : '2px',
|
||||
width : this.w + 'px'
|
||||
}
|
||||
}, simpleImgOffset(this.src, this.w, this.h, this.dx, this.dy, 'IconImg_' + this.id, null, this.alt,
|
||||
'cursor:' + _hand), this.extraHTML);
|
||||
} else {
|
||||
imgCode = h.DIV( {
|
||||
'class' : 'iconText',
|
||||
'style' : {
|
||||
width : '1px',
|
||||
height : (this.h + this.border) + 'px'
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var divStyle = {
|
||||
margin : this.margin + 'px',
|
||||
padding : '1px'
|
||||
};
|
||||
|
||||
if (this.width) {
|
||||
divStyle.width = this.width + 'px';
|
||||
}
|
||||
if (!this.disp) {
|
||||
divStyle.display = 'none';
|
||||
}
|
||||
|
||||
return h.DIV( {
|
||||
style : divStyle,
|
||||
id : this.id,
|
||||
'class' : this.nocheckClass
|
||||
}, (this.clickCB && _ie) ? lnk(imgCode, null, null, null, ' tabIndex="-1"') : imgCode);
|
||||
}
|
||||
};
|
||||
295
crystalreportviewers13/js/crviewer/PromptPage.js
Normal file
@@ -0,0 +1,295 @@
|
||||
/* Copyright (c) Business Objects 2006. All rights reserved. */
|
||||
|
||||
/**
|
||||
* PromptPage constructor
|
||||
*
|
||||
* @param kwArgs.id [String] DOM node id
|
||||
* @param kwArgs.contentId [String] DOM node id of report page content container
|
||||
* @param kwArgs.bgColor [String] Background color of the page
|
||||
* @param kwArgs.width [Int] Page content's width in pixels
|
||||
* @param kwArgs.height [Int] Page content's height in pixels
|
||||
* @param kwArgs.topMargin [Int] Top margin of report page in pixels
|
||||
* @param kwArgs.rightMargin [Int] Right margin of report page in pixels
|
||||
* @param kwArgs.bottomMargin [Int] Bottom margin of report page in pixels
|
||||
* @param kwArgs.leftMargin [Int] Left margin of report page in pixels
|
||||
*/
|
||||
bobj.crv.newPromptPage = function(kwArgs) {
|
||||
kwArgs = MochiKit.Base.update({
|
||||
id: bobj.uniqueId(),
|
||||
layoutType: 'fixed',
|
||||
content : null,
|
||||
width: 800,
|
||||
height: 600,
|
||||
padding: 5,
|
||||
top: 0,
|
||||
left: 0
|
||||
}, kwArgs);
|
||||
|
||||
var o = newWidget(kwArgs.id);
|
||||
o.widgetType = 'PromptPage';
|
||||
o._reportProcessing = null;
|
||||
|
||||
// Update instance with constructor arguments
|
||||
bobj.fillIn(o, kwArgs);
|
||||
|
||||
// Update instance with member functions
|
||||
o.initOld = o.init;
|
||||
MochiKit.Base.update(o, bobj.crv.PromptPage);
|
||||
|
||||
window[o.id] = o;
|
||||
|
||||
return o;
|
||||
};
|
||||
|
||||
bobj.crv.PromptPage = {
|
||||
/**
|
||||
* Overrides parent. Sets the content of the report page.
|
||||
*
|
||||
* @param content
|
||||
* [String|DOM Node] Html or Node to use as report page content
|
||||
*/
|
||||
setHTML : function(content) {
|
||||
var pageNode = this._pageNode;
|
||||
if (bobj.isString (content)) {
|
||||
var ext = bobj.html.extractHtml(content);
|
||||
pageNode.innerHTML = ext.html;
|
||||
|
||||
var links = ext.links;
|
||||
for(var iLinks = 0, linksLen = links.length; iLinks < linksLen; ++iLinks) {
|
||||
bobj.includeLink(links[iLinks]);
|
||||
}
|
||||
|
||||
var scripts = ext.scripts;
|
||||
for (var iScripts = 0, scriptsLen = scripts.length; iScripts < scriptsLen; ++iScripts) {
|
||||
var script = scripts[iScripts];
|
||||
if (!script) {continue;}
|
||||
|
||||
if (script.text) {
|
||||
bobj.evalInWindow(script.text);
|
||||
}
|
||||
}
|
||||
} else if (bobj.isObject (content)) {
|
||||
pageNode.innerHTML = '';
|
||||
pageNode.appendChild (content);
|
||||
var contentStyle = content.style;
|
||||
contentStyle.display = 'block';
|
||||
contentStyle.visibility = 'visible';
|
||||
}
|
||||
},
|
||||
|
||||
getHTML : function() {
|
||||
var h = bobj.html;
|
||||
var isBorderBoxModel = bobj.isBorderBoxModel ();
|
||||
|
||||
var pageOuterHeight = this.height + this.topMargin + this.bottomMargin;
|
||||
var pageOuterWidth = this.width + this.leftMargin + this.rightMargin;
|
||||
|
||||
var contentHeight = isBorderBoxModel ? pageOuterHeight : this.height;
|
||||
var contentWidth = isBorderBoxModel ? pageOuterWidth : this.width;
|
||||
|
||||
var layerStyle = {
|
||||
position : 'relative',
|
||||
width : contentWidth + 'px',
|
||||
height : contentHeight + 'px',
|
||||
top : this.top + "px",
|
||||
left : this.left + "px",
|
||||
border : 'none',
|
||||
'z-index' : 1,
|
||||
'background-color' : this.bgColor
|
||||
};
|
||||
|
||||
/* To support the width and height */
|
||||
if (this.layoutType == 'fixed') {
|
||||
layerStyle.overflow = 'auto';
|
||||
}
|
||||
|
||||
var pageStyle = {
|
||||
'padding' : this.padding + 'px'
|
||||
};
|
||||
|
||||
var html = h.DIV ( {
|
||||
id : this.id,
|
||||
style : layerStyle
|
||||
}, h.DIV ( {
|
||||
id : this.id + '_page',
|
||||
style : pageStyle
|
||||
}));
|
||||
|
||||
return html;
|
||||
},
|
||||
|
||||
init : function() {
|
||||
this._pageNode = document.getElementById (this.id + '_page');
|
||||
|
||||
this.initOld ();
|
||||
|
||||
if (this.contentId) {
|
||||
var content = document.getElementById (this.contentId);
|
||||
if (content) {
|
||||
this.setHTML (content);
|
||||
}
|
||||
}
|
||||
else if(this.content) {
|
||||
this.setHTML(this.content);
|
||||
delete this.content;
|
||||
}
|
||||
|
||||
var connect = MochiKit.Signal.connect;
|
||||
|
||||
if (this.layoutType.toLowerCase () == 'client') {
|
||||
connect (window, 'onresize', this, '_doLayout');
|
||||
}
|
||||
|
||||
this._doLayout ();
|
||||
},
|
||||
|
||||
/* TODO: fix the layout (fitreport) to behave like XIR2 */
|
||||
_doLayout : function() {
|
||||
var layout = this.layoutType.toLowerCase ();
|
||||
|
||||
if ('client' == layout) {
|
||||
this.css.width = '100%';
|
||||
this.css.height = '100%';
|
||||
} else if ('fitreport' == layout) {
|
||||
this.css.width = '100%';
|
||||
this.css.height = '100%';
|
||||
} else { /* fixed layout */
|
||||
if(this.width != null && this.width.length > 0) {
|
||||
if(this.width.indexOf("px") > 0 || this.width.indexOf("%") > 0)
|
||||
this.css.width = this.width;
|
||||
else
|
||||
this.css.width = this.width + 'px';
|
||||
}
|
||||
if(this.height != null && this.height.length > 0) {
|
||||
if(this.height.indexOf("px") > 0 || this.height.indexOf("%") > 0)
|
||||
this.css.height = this.height;
|
||||
else
|
||||
this.css.height = this.height + 'px';
|
||||
}
|
||||
}
|
||||
|
||||
var rptProcessing = this._reportProcessing;
|
||||
if (rptProcessing && rptProcessing.layer) {
|
||||
rptProcessing.center ();
|
||||
}
|
||||
},
|
||||
|
||||
addChild : function(widget) {
|
||||
if (widget.widgetType == 'ReportProcessingUI') {
|
||||
this._reportProcessing = widget;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* FlexPromptPage constructor
|
||||
*
|
||||
* @param kwArgs.id [String] DOM node id
|
||||
* @param kwArgs.contentId [String] DOM node id of report page content container
|
||||
* @param kwArgs.bgColor [String] Background color of the page
|
||||
* @param kwArgs.width [Int] Page content's width in pixels
|
||||
* @param kwArgs.height [Int] Page content's height in pixels
|
||||
* @param kwArgs.topMargin [Int] Top margin of report page in pixels
|
||||
* @param kwArgs.rightMargin [Int] Right margin of report page in pixels
|
||||
* @param kwArgs.bottomMargin [Int] Bottom margin of report page in pixels
|
||||
* @param kwArgs.leftMargin [Int] Left margin of report page in pixels
|
||||
*/
|
||||
bobj.crv.newFlexPromptPage = function(kwArgs) {
|
||||
kwArgs = MochiKit.Base.update({
|
||||
id: bobj.uniqueId(),
|
||||
layoutType: 'fixed',
|
||||
width: 800,
|
||||
height: 600,
|
||||
padding: 5,
|
||||
top: 0,
|
||||
left: 0
|
||||
}, kwArgs);
|
||||
|
||||
var o = newWidget(kwArgs.id);
|
||||
o.widgetType = 'FlexPromptPage';
|
||||
o._reportProcessing = null;
|
||||
|
||||
// Update instance with constructor arguments
|
||||
bobj.fillIn(o, kwArgs);
|
||||
|
||||
// Update instance with member functions
|
||||
o.initOld = o.init;
|
||||
MochiKit.Base.update(o, bobj.crv.FlexPromptPage);
|
||||
window[o.id] = o;
|
||||
|
||||
return o;
|
||||
};
|
||||
|
||||
bobj.crv.FlexPromptPage = {
|
||||
/**
|
||||
* Overrides parent. Does nothing because the swf content will replace the DIV later
|
||||
*
|
||||
* @param content [String|DOM Node] Html or Node to use as report page content
|
||||
*/
|
||||
setHTML : MochiKit.Base.noop,
|
||||
|
||||
getHTML : function() {
|
||||
var isBorderBoxModel = bobj.isBorderBoxModel ();
|
||||
|
||||
var pageOuterHeight = this.height + this.topMargin + this.bottomMargin;
|
||||
var pageOuterWidth = this.width + this.leftMargin + this.rightMargin;
|
||||
|
||||
var contentHeight = isBorderBoxModel ? pageOuterHeight : this.height;
|
||||
var contentWidth = isBorderBoxModel ? pageOuterWidth : this.width;
|
||||
|
||||
var useSize = this.layoutType.toLowerCase () == bobj.crv.Viewer.LayoutTypes.FIXED;
|
||||
|
||||
var layerStyle = {
|
||||
position : 'relative',
|
||||
width : useSize ? contentWidth + 'px' : '100%',
|
||||
height : useSize ? contentHeight + 'px' : '100%',
|
||||
top : this.top + "px",
|
||||
left : this.left + "px",
|
||||
border : 'none',
|
||||
'z-index' : 1,
|
||||
'background-color' : this.bgColor
|
||||
};
|
||||
|
||||
var pageStyle = {
|
||||
'padding': this.padding + 'px',
|
||||
position: 'absolute' // Must be absolute to avoid double initialization in firefox ADAPT01260507
|
||||
};
|
||||
|
||||
bobj.crv.params.ViewerFlexParameterAdapter.setViewerLayoutType (this.id, this.layoutType);
|
||||
|
||||
var h = bobj.html;
|
||||
return h.DIV ( {
|
||||
id : this.id,
|
||||
style : layerStyle
|
||||
}, h.DIV ( {
|
||||
id : this.id + '_page',
|
||||
style : pageStyle
|
||||
}, h.DIV ( {
|
||||
id : this.contentId
|
||||
})));
|
||||
},
|
||||
|
||||
init : function() {
|
||||
var connect = MochiKit.Signal.connect;
|
||||
if (this.layoutType.toLowerCase () == 'client') {
|
||||
connect (window, 'onresize', this, '_doLayout');
|
||||
}
|
||||
|
||||
this._doLayout ();
|
||||
},
|
||||
|
||||
_doLayout : function() {
|
||||
var rptProcessing = this._reportProcessing;
|
||||
if (rptProcessing && rptProcessing.layer) {
|
||||
rptProcessing.center ();
|
||||
}
|
||||
},
|
||||
|
||||
addChild : function(widget) {
|
||||
if (widget.widgetType == 'ReportProcessingUI') {
|
||||
this._reportProcessing = widget;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
275
crystalreportviewers13/js/crviewer/RangeField.js
Normal file
@@ -0,0 +1,275 @@
|
||||
|
||||
/*
|
||||
* ================================================================================
|
||||
* Range Field
|
||||
*
|
||||
* ================================================================================
|
||||
*/
|
||||
|
||||
bobj.crv.params.newRangeField = function(kwArgs) {
|
||||
return new bobj.crv.params.RangeField(kwArgs);
|
||||
};
|
||||
|
||||
bobj.crv.params.RangeField = function(kwArgs) {
|
||||
kwArgs = MochiKit.Base.update( {
|
||||
id : bobj.uniqueId(),
|
||||
cleanValue : {},
|
||||
foreColor : 'black',
|
||||
isTextItalic: false,
|
||||
tooltip : ''
|
||||
}, kwArgs);
|
||||
|
||||
this.widgetType = 'RangeField';
|
||||
this.value = kwArgs.cleanValue;
|
||||
|
||||
// Update instance with constructor arguments
|
||||
bobj.fillIn(this, kwArgs);
|
||||
};
|
||||
|
||||
bobj.crv.params.RangeField.prototype = {
|
||||
setTabDisabled : function(dis) {
|
||||
if(this.layer) {
|
||||
var tds = this.layer.getElementsByTagName("TD");
|
||||
for(var i = 0, len = tds.length; i < len ; i++) {
|
||||
bobj.disableTabbingKey(tds[i], dis);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
setTooltip : function(text) {
|
||||
if(this.layer) {
|
||||
this.layer.title = text;
|
||||
}
|
||||
},
|
||||
|
||||
setForeColor : function(color) {
|
||||
if(this.layer) {
|
||||
this.layer.style.color = color;
|
||||
}
|
||||
},
|
||||
|
||||
setTextItalic : function(isItalic) {
|
||||
if(this.layer) {
|
||||
this.layer.style.fontStyle = isItalic ? 'italic' : '';
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Generates HTML for either lower or upper bound value
|
||||
* @param value - the value of upper/lower bound
|
||||
* @param isRightAligned - a flag for indicating whether left align or right align the generated HTML
|
||||
* @return
|
||||
*/
|
||||
getValueHTML : function(value, isRightAligned) {
|
||||
value = value ? value : ' ';
|
||||
var style = {
|
||||
'text-align' : isRightAligned ? (bobj.crv.config.isRTL? 'left':'right') : (bobj.crv.config.isRTL? 'right':'left')
|
||||
};
|
||||
|
||||
var SPAN = "";
|
||||
|
||||
//[ADAPT01680961] In IE we should force the span to show the value in one line
|
||||
if (MochiKit.Base.isIE ()) {
|
||||
SPAN = bobj.html.SPAN( {
|
||||
style : {"white-space" : 'nowrap'}
|
||||
}, value);
|
||||
}
|
||||
else {
|
||||
SPAN = bobj.html.SPAN(null, value);
|
||||
}
|
||||
|
||||
return bobj.html.TD( {
|
||||
style : style,
|
||||
role : 'presentation'
|
||||
}, SPAN);
|
||||
|
||||
},
|
||||
|
||||
isValueValidRange: function() {
|
||||
return this.value != null && this.value.lowerBound != null && this.value.upperBound != null;
|
||||
},
|
||||
|
||||
getHTML : function() {
|
||||
var TR = "";
|
||||
var h = bobj.html;
|
||||
|
||||
if(this.isValueValidRange()) {
|
||||
TR = h.TR(null, this.getValueHTML(this.getValue().lowerBound.value, true), this
|
||||
.getMiddleImageHTML(), this.getValueHTML(this.getValue().upperBound.value, false))
|
||||
}
|
||||
else {
|
||||
TR = h.TR(null, this.getValueHTML(this.getValue(), false))
|
||||
}
|
||||
|
||||
return h.TABLE( {
|
||||
id : this.id,
|
||||
'class' : 'iactRangeFieldTable',
|
||||
role : 'group',
|
||||
'title' : this.tooltip + " " + this._getRangeValueToolTip(),
|
||||
style : {color : this.foreColor, "font-style" : this.isTextItalic ? 'italic' :''}
|
||||
}, TR);
|
||||
},
|
||||
|
||||
_getRangeValueToolTip : function () {
|
||||
var str = "";
|
||||
|
||||
if(this.isValueValidRange()) {
|
||||
var RangeBoundTypes = bobj.crv.params.RangeBoundTypes;
|
||||
|
||||
switch (this.getValue().lowerBound.type) {
|
||||
case RangeBoundTypes.EXCLUSIVE:
|
||||
str += "(" + this.getValue().lowerBound.value;
|
||||
break;
|
||||
case RangeBoundTypes.INCLUSIVE:
|
||||
str += "[" + this.getValue().lowerBound.value;
|
||||
break;
|
||||
case RangeBoundTypes.UNBOUNDED:
|
||||
str += "( " ;
|
||||
break;
|
||||
}
|
||||
|
||||
str += "..";
|
||||
|
||||
switch (this.getValue().upperBound.type) {
|
||||
case RangeBoundTypes.EXCLUSIVE:
|
||||
str += this.getValue().upperBound.value + ")" ;
|
||||
break;
|
||||
case RangeBoundTypes.INCLUSIVE:
|
||||
str += this.getValue().upperBound.value + "]";
|
||||
break;
|
||||
case RangeBoundTypes.UNBOUNDED:
|
||||
str += " )" ;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
str += this.getValue();
|
||||
}
|
||||
|
||||
return str;
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
* @return HTML for Range type (INCLUSIVE / EXCLUSIVE / UNBOUND)
|
||||
*/
|
||||
getMiddleImageHTML : function() {
|
||||
var lowerImageSrc = "";
|
||||
var upperImageSrc = "";
|
||||
var lineSrc = "images/line.gif";
|
||||
|
||||
switch (this.getValue().lowerBound.type) {
|
||||
case bobj.crv.params.RangeBoundTypes.EXCLUSIVE:
|
||||
lowerImageSrc = "images/hollowCircle.gif";
|
||||
break;
|
||||
case bobj.crv.params.RangeBoundTypes.INCLUSIVE:
|
||||
lowerImageSrc = "images/filledCircle.gif";
|
||||
break;
|
||||
case bobj.crv.params.RangeBoundTypes.UNBOUNDED:
|
||||
if(bobj.crv.config.isRTL){
|
||||
lowerImageSrc = "images/rightTriangle.gif";
|
||||
} else {
|
||||
lowerImageSrc = "images/leftTriangle.gif";
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
switch (this.getValue().upperBound.type) {
|
||||
case bobj.crv.params.RangeBoundTypes.EXCLUSIVE:
|
||||
upperImageSrc = "images/hollowCircle.gif";
|
||||
break;
|
||||
case bobj.crv.params.RangeBoundTypes.INCLUSIVE:
|
||||
upperImageSrc = "images/filledCircle.gif";
|
||||
break;
|
||||
case bobj.crv.params.RangeBoundTypes.UNBOUNDED:
|
||||
if(bobj.crv.config.isRTL){
|
||||
upperImageSrc = "images/leftTriangle.gif";
|
||||
} else {
|
||||
upperImageSrc = "images/rightTriangle.gif";
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var TDStyle = {
|
||||
'vertical-align' : 'middle'
|
||||
};
|
||||
|
||||
var IMG = bobj.html.IMG;
|
||||
return bobj.html.TD( {
|
||||
style : TDStyle
|
||||
}, IMG( {
|
||||
src : bobj.crvUri(lowerImageSrc)
|
||||
}), IMG( {
|
||||
src : bobj.crvUri(lineSrc)
|
||||
}), IMG( {
|
||||
src : bobj.crvUri(upperImageSrc)
|
||||
}));
|
||||
},
|
||||
|
||||
/**
|
||||
* Initializes the widget
|
||||
*/
|
||||
init : function() {
|
||||
this.layer = getLayer(this.id);
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the evaluated width of lower bound TD
|
||||
*/
|
||||
getLowerBoundValueWidth : function() {
|
||||
if(!this.isValueValidRange())
|
||||
return 0;
|
||||
|
||||
var value = this.getValue().lowerBound.value;
|
||||
|
||||
var fontFamily = MochiKit.Style.computedStyle(this.layer, 'fontFamily');
|
||||
var fontSize = MochiKit.Style.computedStyle(this.layer, 'fontSize');
|
||||
|
||||
if (!fontFamily)
|
||||
fontFamily = "arial , sans-serif";
|
||||
|
||||
if (!fontSize)
|
||||
fontSize = "12px";
|
||||
|
||||
return bobj.getStringWidth(value, fontFamily, fontSize);
|
||||
},
|
||||
|
||||
getLowerBoundTD : function() {
|
||||
if (this.layer)
|
||||
return this.layer.getElementsByTagName("TD")[0];
|
||||
|
||||
return null;
|
||||
},
|
||||
|
||||
setLowerBoundValueWidth : function(w) {
|
||||
if (this.getLowerBoundTD())
|
||||
this.getLowerBoundTD().style.width = w+"px";
|
||||
},
|
||||
|
||||
reset : function(value) {
|
||||
this.value = value;
|
||||
this.cleanValue = value;
|
||||
this.updateUI();
|
||||
},
|
||||
|
||||
updateUI : function() {
|
||||
var parent = this.layer.parentNode;
|
||||
MochiKit.DOM.removeElement(this.layer);
|
||||
append2(parent, this.getHTML());
|
||||
this.init();
|
||||
},
|
||||
|
||||
setValue : function(rangeValue) {
|
||||
this.value = rangeValue;
|
||||
this.updateUI();
|
||||
},
|
||||
|
||||
setCleanValue : function(rangeValue) {
|
||||
this.cleanValue = rangeValue;
|
||||
},
|
||||
|
||||
getValue : function() {
|
||||
return this.value;
|
||||
}
|
||||
};
|
||||
335
crystalreportviewers13/js/crviewer/ReportAlbum.js
Normal file
@@ -0,0 +1,335 @@
|
||||
/* Copyright (c) Business Objects 2006. All rights reserved. */
|
||||
|
||||
/**
|
||||
* ReportAlbum Constructor
|
||||
*/
|
||||
bobj.crv.newReportAlbum = function(kwArgs) {
|
||||
var mb = MochiKit.Base;
|
||||
var UPDATE = mb.update;
|
||||
var BIND = mb.bind;
|
||||
var ALBUM = bobj.crv.ReportAlbum;
|
||||
|
||||
kwArgs = UPDATE({
|
||||
id: bobj.uniqueId(),
|
||||
initTabIdx: 0, // Index of tab to select when initializing
|
||||
width: 800,
|
||||
height: 500,
|
||||
displayDrilldownTab : true
|
||||
}, kwArgs);
|
||||
|
||||
|
||||
// Override TabbedZone's TabBarWidget
|
||||
var tabbar = newNaviBarWidget(bobj.uniqueId(), _HorizTabTopWithClose, null, null, kwArgs.width, null, null, null, false, true, false);
|
||||
var o = newTabbedZone(kwArgs.id, tabbar, kwArgs.width, kwArgs.height);
|
||||
|
||||
tabbar.cb = BIND(ALBUM._onSelectTab, o);
|
||||
tabbar.closeTab = BIND(ALBUM._removeView, o, true);
|
||||
bobj.fillIn(o, kwArgs);
|
||||
o.widgetType = 'ReportAlbum';
|
||||
o._views = [];
|
||||
o._hideFrame = false;
|
||||
|
||||
// Attach member functions
|
||||
o.selectOld = o.select;
|
||||
UPDATE(o, ALBUM);
|
||||
|
||||
return o;
|
||||
};
|
||||
|
||||
bobj.crv.ReportAlbum = {
|
||||
getTabBarHeight : function() {
|
||||
return this.tabs.getHeight ();
|
||||
},
|
||||
|
||||
init : function() {
|
||||
/*
|
||||
* This is not nice... Copied super class' init code here so that select will be called only once.
|
||||
*/
|
||||
this.tzOldInit ();
|
||||
this.tabs.init ();
|
||||
this.showDrilldownTab (this.displayDrilldownTab);
|
||||
|
||||
var views = this._views;
|
||||
if (views.length > 0) {
|
||||
for ( var i = 0, len = views.length; i < len; i++) {
|
||||
/* Since views are not initializing themself (as before through
|
||||
adding bobj.crv.getInitHtml to their HTML)
|
||||
it is report album's responsibility to initialize its children */
|
||||
views[i].init ();
|
||||
|
||||
}
|
||||
|
||||
if (this.initTabIdx < 0 || this.initTabIdx >= views.length) {
|
||||
this.initTabIdx = 0;
|
||||
}
|
||||
|
||||
this.select (this.initTabIdx);
|
||||
}
|
||||
},
|
||||
|
||||
showDrilldownTab : function (isDisplay) {
|
||||
this.displayDrilldownTab = isDisplay;
|
||||
try
|
||||
{
|
||||
/* IE supports table-row since IE8. */
|
||||
var displayStyle;
|
||||
if (_ie && !_ie8Up)
|
||||
displayStyle = "block";
|
||||
else
|
||||
displayStyle = "table-row";
|
||||
this.tabs.layer.parentNode.parentNode.style.display = isDisplay ? displayStyle : "none";
|
||||
}
|
||||
catch(e){}
|
||||
},
|
||||
|
||||
isDisplayDrilldownTab : function () {
|
||||
return this.displayDrilldownTab;
|
||||
},
|
||||
|
||||
setHideFrame : function(hide) {
|
||||
this._hideFrame = hide;
|
||||
var selectedView = this.getSelectedView ();
|
||||
if (selectedView && this._hideFrame)
|
||||
selectedView.hideFrame();
|
||||
},
|
||||
|
||||
update : function(update) {
|
||||
if (!update || update.cons !== "bobj.crv.newReportAlbum") {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Updates all views */
|
||||
for ( var i = 0, len = update.children.length; i < len; i++) {
|
||||
var updateView = update.children[i];
|
||||
var view = this._views[i];
|
||||
if (view) {
|
||||
view.update (updateView); /* updates current view */
|
||||
}
|
||||
}
|
||||
|
||||
var updateChildrenLength = update.children.length;
|
||||
var currentViewsLength = this._views.length;
|
||||
|
||||
/* Adds any new view created by drill down action */
|
||||
if (updateChildrenLength > currentViewsLength) {
|
||||
for ( var i = currentViewsLength, len = updateChildrenLength; i < len; i++) {
|
||||
this.delayedAddChild (bobj.crv.createWidget (update.children[i]));
|
||||
}
|
||||
}
|
||||
/* Removes views that are have been removed from viewstate */
|
||||
else if (updateChildrenLength < currentViewsLength) {
|
||||
for ( var i = currentViewsLength -1, len = updateChildrenLength; i >= len; i--) {
|
||||
this._removeView (false, i); /* removes non-existing views */
|
||||
}
|
||||
}
|
||||
|
||||
this.initTabIdx = update.args.initTabIdx;
|
||||
this.select (this.initTabIdx);
|
||||
},
|
||||
|
||||
/**
|
||||
* @return index of the tab specified by viewstateid
|
||||
*/
|
||||
findTabNumber : function(viewStateId) {
|
||||
var views = this._views;
|
||||
for ( var i = 0, len = views.length; i < len; i++)
|
||||
if (views[i].viewStateId == viewStateId)
|
||||
return i;
|
||||
|
||||
return -1;
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds view to its list of views. Since this method can be called after initialization time, its HTML
|
||||
* is first added to report album, and then widget is intialized.
|
||||
*/
|
||||
delayedAddChild : function(view) {
|
||||
this._views.push (view);
|
||||
var tab = this.tabs.add(view.label, view.tooltip);
|
||||
var tabHTML = this.getTabHTML (this._views.length - 1);
|
||||
append (getLayer (this.id + "_container"), tabHTML);
|
||||
view.init ();
|
||||
},
|
||||
|
||||
addChild : function(view) {
|
||||
if (view) {
|
||||
this._views.push (view);
|
||||
this.add (view.label, view.tooltip);
|
||||
}
|
||||
},
|
||||
|
||||
getHTML : function() {
|
||||
var html = this.beginHTML ();
|
||||
var children = this._views;
|
||||
for ( var i = 0, len = children.length; i < len; ++i) {
|
||||
html += this.getTabHTML (i);
|
||||
}
|
||||
|
||||
html += this.endHTML ();
|
||||
return html;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* @param index,
|
||||
* index of tab to create HTML for
|
||||
* @return creates HTML for tab specified by index
|
||||
*/
|
||||
getTabHTML : function(index) {
|
||||
var tab = this.tabs.items[index];
|
||||
var view = this._views[index];
|
||||
html = '';
|
||||
|
||||
if (tab && view) {
|
||||
html += this.beginTabHTML (tab);
|
||||
html += view.getHTML ();
|
||||
html += this.endTabHTML ();
|
||||
}
|
||||
|
||||
return html;
|
||||
},
|
||||
|
||||
/**
|
||||
* Resize the outer dimensions of the ReportAlbum. The standard resize method, inherited from TabbedZoneWidget, resizes the container. We
|
||||
* can't override it without breaking things.
|
||||
*/
|
||||
resizeOuter : function(w, h) {
|
||||
var tabHeight = 33;
|
||||
var frameWidth = 10;
|
||||
|
||||
if(bobj.isNumber (h)) {
|
||||
if(this.displayDrilldownTab)
|
||||
h -= tabHeight;
|
||||
h = Math.max(h, 0);
|
||||
}
|
||||
|
||||
if(bobj.isNumber (w)) {
|
||||
if(!this._hideFrame)
|
||||
w -= frameWidth;
|
||||
|
||||
w = Math.max(w, 0);
|
||||
}
|
||||
|
||||
|
||||
this.resize (w, h);
|
||||
this.tabs.resize (w);
|
||||
|
||||
var selectedView = this.getSelectedView ();
|
||||
if (selectedView) {
|
||||
selectedView.resize (); /* Notify ReportView of resize */
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return Returns a suggested size for the widget as an object with width and height integer properties that specify the dimensions in
|
||||
* pixels.
|
||||
*/
|
||||
getBestFitSize : function() {
|
||||
var w = this._hideFrame ? 0 : 10;
|
||||
var h = this.displayDrilldownTab ? 33 : 0;
|
||||
var selectedView = this.getSelectedView ();
|
||||
if (selectedView) {
|
||||
var viewSize = selectedView.getBestFitSize ();
|
||||
w += viewSize.width;
|
||||
h += viewSize.height;
|
||||
}
|
||||
|
||||
return {
|
||||
width : w,
|
||||
height : h
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Overrides parent. Opens a tab with a positioned div. The positioning prevents
|
||||
* the ReportView from disappearing in IE.
|
||||
*/
|
||||
beginTabHTML : function(tab) {
|
||||
return bobj.html.openTag ('div', {
|
||||
id : tab.zoneId,
|
||||
style : {
|
||||
display : 'none',
|
||||
width : this.w + 'px',
|
||||
height : this.h + 'px',
|
||||
position : 'relative'
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @return Returns the select ReportView or null if no view is selected
|
||||
*/
|
||||
getSelectedView : function() {
|
||||
return this._views[this.oldIndex];
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Overrides parent. Selects a report view to display.
|
||||
*
|
||||
* @param index [int] Index of the report view
|
||||
*/
|
||||
select : function(index) {
|
||||
var partial = MochiKit.Base.partial;
|
||||
|
||||
if (index >= 0 && index < this._views.length && index != this.oldIndex) {
|
||||
|
||||
/* Disposes currently selected view */
|
||||
var selectedView = this.getSelectedView ();
|
||||
if (selectedView) {
|
||||
selectedView.dispose ();
|
||||
}
|
||||
|
||||
/* Creates new signals for newly selected view */
|
||||
var selectedView = this._views[index];
|
||||
|
||||
/* Does the dirty DOM manipulation to actually change the view */
|
||||
this.selectOld (index);
|
||||
|
||||
/*
|
||||
* Notifies parameter controller that view has changes so it can enable/disable panel based on view's type
|
||||
*/
|
||||
MochiKit.Signal.signal (this, "viewChanged");
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes view specified by index from view list
|
||||
*
|
||||
* @param autoSelectNext
|
||||
* [boolean] indicates whether another view should be auto selected after view specified by index is removed
|
||||
* @param index
|
||||
* [Number} index of view that would be removed
|
||||
*/
|
||||
_removeView : function(autoSelectNext, index) {
|
||||
var removedView = this._views[index];
|
||||
var removedTab = this.tabs.items[index];
|
||||
|
||||
autoSelectNext = (removedTab != null && removedTab.isSelected && autoSelectNext);
|
||||
|
||||
if (removedView) {
|
||||
removedView.dispose ();
|
||||
bobj.deleteWidget (removedView);
|
||||
MochiKit.Signal.signal (this, 'removeView', removedView);
|
||||
}
|
||||
|
||||
if (removedTab.isSelected) {
|
||||
/* oldIndex (index of currently selected view) needs to be reset so when
|
||||
response for the next selected view arrives
|
||||
viewer think that view has changed */
|
||||
this.oldIndex = -1;
|
||||
}
|
||||
|
||||
arrayRemove (this, '_views', index);
|
||||
this.tabs.remove (index, autoSelectNext);
|
||||
bobj.deleteWidget (removedTab);
|
||||
},
|
||||
|
||||
_onSelectTab : function(index) {
|
||||
if(index != this.oldIndex)
|
||||
MochiKit.Signal.signal (this, 'selectView', this._views[index]);
|
||||
}
|
||||
};
|
||||
|
||||
280
crystalreportviewers13/js/crviewer/ReportPage.js
Normal file
@@ -0,0 +1,280 @@
|
||||
/* Copyright (c) Business Objects 2006. All rights reserved. */
|
||||
|
||||
/**
|
||||
* ReportPage constructor
|
||||
*
|
||||
* @param kwArgs.id [String] DOM node id
|
||||
* @param kwArgs.bgColor [String] Background color of the page
|
||||
* @param kwArgs.width [Int] Page content's width in pixels
|
||||
* @param kwArgs.height [Int] Page content's height in pixels
|
||||
* @param kwArgs.topMargin [Int] Top margin of report page in pixels
|
||||
* @param kwArgs.rightMargin [Int] Right margin of report page in pixels
|
||||
* @param kwArgs.bottomMargin [Int] Bottom margin of report page in pixels
|
||||
* @param kwArgs.leftMargin [Int] Left margin of report page in pixels
|
||||
* @param kwArgs.extraCssFileUrl [String] The path of an extra CSS file used in report page
|
||||
*/
|
||||
|
||||
bobj.crv.newReportPage = function(kwArgs) {
|
||||
kwArgs = MochiKit.Base.update({
|
||||
id: bobj.uniqueId(),
|
||||
bgColor: '#FFFFFF',
|
||||
width: 720,
|
||||
height: 984,
|
||||
extraCssFileUrl: "",
|
||||
documentView: bobj.crv.ReportPage.DocumentView.PRINT_LAYOUT
|
||||
}, kwArgs);
|
||||
|
||||
var o = newWidget(kwArgs.id);
|
||||
o.widgetType = 'ReportPage';
|
||||
|
||||
// Update instance with constructor arguments
|
||||
bobj.fillIn(o, kwArgs);
|
||||
|
||||
// Update instance with member functions
|
||||
o.initOld = o.init;
|
||||
o.resizeOld = o.resize;
|
||||
MochiKit.Base.update(o, bobj.crv.ReportPage);
|
||||
|
||||
return o;
|
||||
};
|
||||
|
||||
bobj.crv.ReportPage = {
|
||||
DocumentView : {
|
||||
WEB_LAYOUT : 'weblayout',
|
||||
PRINT_LAYOUT : 'printlayout'
|
||||
},
|
||||
|
||||
/**
|
||||
* Disposes report page by removing its layer and stylesheet from DOM
|
||||
*/
|
||||
dispose : function() {
|
||||
MochiKit.DOM.removeElement (this.layer);
|
||||
},
|
||||
|
||||
/**
|
||||
* DO NOT REMOVE. USED BY WEB ELEMENTS
|
||||
*/
|
||||
displayScrollBars : function (isDisplay) {
|
||||
this.layer.style.overflow = isDisplay ? "auto" : "hidden";
|
||||
},
|
||||
|
||||
/**
|
||||
* DO NOT REMOVE. USED BY WEB ELEMENTS
|
||||
*/
|
||||
isDisplayScrollBars : function () {
|
||||
this.layer.style.overflow == "auto";
|
||||
},
|
||||
|
||||
|
||||
update : function(update) {
|
||||
if (update && update.cons == "bobj.crv.newReportPage") {
|
||||
this.updateSize ( {
|
||||
width : update.args.width,
|
||||
height : update.args.height
|
||||
});
|
||||
|
||||
this.layer.scrollLeft = 0;
|
||||
this.layer.scrollTop = 0;
|
||||
this.updateHTML (update.args.content, false);
|
||||
}
|
||||
},
|
||||
|
||||
scrollToHighlighted : function (scrollWindow) {
|
||||
if(this._iframe) {
|
||||
var iframeDoc = _ie ? this._iframe.contentWindow.document : this._iframe.contentDocument;
|
||||
var e = iframeDoc.getElementById("CrystalHighLighted");
|
||||
if(e) {
|
||||
var ePosition = MochiKit.Style.getElementPosition (e, null, iframeDoc);
|
||||
if(scrollWindow) {
|
||||
var reportPagePos = MochiKit.Style.getElementPosition (this.layer);
|
||||
window.scrollTo (reportPagePos.x + ePosition.x , reportPagePos.y + ePosition.y);
|
||||
}
|
||||
else {
|
||||
this.layer.scrollLeft = ePosition.x;
|
||||
this.layer.scrollTop = ePosition.y;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
updateHTML : function(content, useAnimation) {
|
||||
if (content) {
|
||||
if(!this._iframe) {
|
||||
this._iframe = MochiKit.DOM.createDOM('IFRAME', {id : this.id + '_iframe', width : '100%', height : '100%', frameBorder : '0', margin : '0'})
|
||||
this._pageNode.appendChild(this._iframe);
|
||||
}
|
||||
|
||||
if(useAnimation)
|
||||
this._iframe.style.display = "none";
|
||||
|
||||
var iframeDoc = _ie ? this._iframe.contentWindow.document : this._iframe.contentDocument;
|
||||
iframeDoc.open();
|
||||
iframeDoc.write(this.getIFrameHTML (content));
|
||||
iframeDoc.close();
|
||||
|
||||
if(useAnimation)
|
||||
bobj.displayElementWithAnimation(this._iframe);
|
||||
}
|
||||
},
|
||||
|
||||
getIFrameHTML : function (content) {
|
||||
var extraCssFileLink = "";
|
||||
if (this.extraCssFileUrl != "") {
|
||||
extraCssFileLink = "<link href=\"" + this.extraCssFileUrl + "\" rel=\"stylesheet\" type=\"text/css\" />\r\n";
|
||||
}
|
||||
|
||||
return "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">" +
|
||||
"<html>\r\n" +
|
||||
"<head>\r\n" +
|
||||
extraCssFileLink +
|
||||
"<style> body { overflow :hidden; margin : 0px;}</style>\r\n" +
|
||||
"</head>\r\n" +
|
||||
"<body>\r\n" +
|
||||
content +
|
||||
"</body>\r\n" +
|
||||
"</html>";
|
||||
},
|
||||
|
||||
/*
|
||||
* Updates size of report page based on update object
|
||||
* @param update [{width,height,marginLeft,marginRight,marginTop}] dimension and margins
|
||||
* of report p
|
||||
*/
|
||||
updateSize : function(sizeObject) {
|
||||
|
||||
if (sizeObject) {
|
||||
this.width = (sizeObject.width != undefined) ? sizeObject.width : this.width;
|
||||
this.height = (sizeObject.height != undefined) ? sizeObject.height : this.height;
|
||||
}
|
||||
|
||||
if (this._pageNode) {
|
||||
var isBBM = bobj.isBorderBoxModel ();
|
||||
this._pageNode.style.width = (isBBM ? this.width + 2: this.width) + 'px';
|
||||
this._pageNode.style.height = (isBBM ? this.height + 2: this.height) + 'px';
|
||||
}
|
||||
|
||||
if (this._shadowNode) {
|
||||
this._shadowNode.style.width = (isBBM ? this.width + 2: this.width) + 'px';
|
||||
this._shadowNode.style.height = (isBBM ? this.height + 2: this.height) + 'px';
|
||||
}
|
||||
},
|
||||
|
||||
getHTML : function() {
|
||||
var h = bobj.html;
|
||||
var isBBM = bobj.isBorderBoxModel ();
|
||||
|
||||
var layerStyle = {
|
||||
width : '100%',
|
||||
height : '100%',
|
||||
overflow : 'auto',
|
||||
position : 'absolute'
|
||||
};
|
||||
|
||||
var pageStyle = {
|
||||
position : 'relative',
|
||||
width : (isBBM ? this.width + 2: this.width) + 'px',
|
||||
height : (isBBM ? this.height + 2: this.height) + 'px',
|
||||
'z-index' : 1,
|
||||
'border-width' : '1px',
|
||||
'border-style' : 'solid',
|
||||
'background-color' : this.bgColor,
|
||||
overflow : 'hidden',
|
||||
'text-align' : 'left'
|
||||
};
|
||||
|
||||
var shadowStyle = {
|
||||
position : 'absolute',
|
||||
'z-index' : 0,
|
||||
display : 'none',
|
||||
width : (isBBM ? this.width + 2: this.width) + 'px',
|
||||
height : (isBBM ? this.height + 2: this.height) + 'px',
|
||||
top : '0px',
|
||||
left : '0px'
|
||||
};
|
||||
|
||||
|
||||
var shadowHTML = '';
|
||||
if (this.documentView.toLowerCase () == bobj.crv.ReportPage.DocumentView.PRINT_LAYOUT) {
|
||||
layerStyle['background-color'] = '#8E8E8E';
|
||||
pageStyle['border-color'] = '#000000';
|
||||
shadowStyle['background-color'] = '#737373';
|
||||
shadowHTML = h.DIV ( {
|
||||
id : this.id + '_shadow',
|
||||
'class' : 'menuShadow',
|
||||
style : shadowStyle
|
||||
})
|
||||
/* page should appear in the center for print layouts */
|
||||
layerStyle['text-align'] = 'center'; /* For page centering in IE quirks mode */
|
||||
pageStyle['margin'] = '0 auto'; /* center the page horizontally - CSS2 */
|
||||
pageStyle['top'] = "6px";
|
||||
} else {
|
||||
/* Web Layout*/
|
||||
layerStyle['background-color'] = '#FFFFFF';
|
||||
pageStyle['border-color'] = '#FFFFFF';
|
||||
/* page should appear in left for web layouts */
|
||||
pageStyle['margin'] = '0';
|
||||
}
|
||||
|
||||
var html = h.DIV ( {
|
||||
id : this.id,
|
||||
style : layerStyle,
|
||||
'class' : 'insetBorder'
|
||||
}, h.DIV ( {
|
||||
id : this.id + '_page',
|
||||
style : pageStyle
|
||||
}), shadowHTML);
|
||||
|
||||
return html;
|
||||
},
|
||||
|
||||
init : function() {
|
||||
this._pageNode = getLayer (this.id + '_page');
|
||||
this._shadowNode = getLayer (this.id + '_shadow');
|
||||
|
||||
this.initOld ();
|
||||
|
||||
this.updateHTML (this.content, true);
|
||||
},
|
||||
|
||||
updateShadowLocation : function () {
|
||||
var updateFunc = function () {
|
||||
if(this._shadowNode && this._pageNode) {
|
||||
this._shadowNode.style.display = "none"; //Must hide dropshadow as it can cause scrollbars to appear
|
||||
var pageNodPos = {x : this._pageNode.offsetLeft, y : this._pageNode.offsetTop};
|
||||
this._shadowNode.style.display = "block";
|
||||
this._shadowNode.style.top = pageNodPos.y + (bobj.isBorderBoxModel() ? 4 : 6) + "px";
|
||||
this._shadowNode.style.left = pageNodPos.x + (bobj.isBorderBoxModel() ? 4 : 6) + "px";
|
||||
}
|
||||
}
|
||||
|
||||
setTimeout(bobj.bindFunctionToObject(updateFunc,this), 0); // Must be executed after viewer has finished doLayout
|
||||
},
|
||||
|
||||
/**
|
||||
* Resizes the outer dimensions of the widget.
|
||||
*/
|
||||
resize : function (w, h) {
|
||||
bobj.setOuterSize(this.layer, w, h);
|
||||
if(_moz)
|
||||
this.css.clip = bobj.getRect(0,w,h,0);
|
||||
|
||||
this.updateShadowLocation ();
|
||||
},
|
||||
|
||||
/**
|
||||
* @return Returns an object with width and height properties such that there
|
||||
* would be no scroll bars around the page if they were applied to the widget.
|
||||
*/
|
||||
getBestFitSize : function() {
|
||||
var page = this._pageNode;
|
||||
return {
|
||||
width: page.offsetWidth + 30,
|
||||
height: page.offsetHeight + 30
|
||||
};
|
||||
},
|
||||
|
||||
hideFrame : function() {
|
||||
this.css.borderStyle = 'none';
|
||||
this._pageNode.style.border = '';
|
||||
}
|
||||
};
|
||||
156
crystalreportviewers13/js/crviewer/ReportView.js
Normal file
@@ -0,0 +1,156 @@
|
||||
/* Copyright (c) Business Objects 2006. All rights reserved. */
|
||||
|
||||
/**
|
||||
* ReportView Constructor
|
||||
*/
|
||||
bobj.crv.newReportView = function(kwArgs) {
|
||||
kwArgs = MochiKit.Base.update({
|
||||
id: bobj.uniqueId(),
|
||||
viewStateId: null,
|
||||
isMainReport: false
|
||||
}, kwArgs);
|
||||
var o = newWidget(kwArgs.id);
|
||||
|
||||
bobj.fillIn(o, kwArgs);
|
||||
o.widgetType = 'ReportView';
|
||||
|
||||
o.reportPage = null;
|
||||
|
||||
o._lastPanelWidth = null;
|
||||
|
||||
// Attach member functions
|
||||
o.initOld = o.init;
|
||||
o.isMainReportFlag = o.isMainReport;
|
||||
MochiKit.Base.update(o, bobj.crv.ReportView);
|
||||
|
||||
return o;
|
||||
};
|
||||
|
||||
bobj.crv.ReportView = {
|
||||
init : function() {
|
||||
this.initOld ();
|
||||
if (this.reportPage)
|
||||
this.reportPage.init ();
|
||||
},
|
||||
|
||||
addChild : function(widget) {
|
||||
if (widget.widgetType == 'ReportPage')
|
||||
this.reportPage = widget;
|
||||
},
|
||||
|
||||
/**
|
||||
* This method should be called after viewer has initialized. Adds a child to view by first appending its html
|
||||
* to view and then intializing it.
|
||||
*/
|
||||
delayedAddChild : function(widget) {
|
||||
this.addChild (widget);
|
||||
append2 (this.layer, widget.getHTML ());
|
||||
widget.init ();
|
||||
|
||||
},
|
||||
|
||||
scrollToHighlighted : function (scrollWindow) {
|
||||
if(this.reportPage) {
|
||||
this.reportPage.scrollToHighlighted(scrollWindow);
|
||||
}
|
||||
},
|
||||
|
||||
update : function(update) {
|
||||
if (update && update.cons == "bobj.crv.newReportView") {
|
||||
if(update.args)
|
||||
this.viewStateId = update.args.viewStateId;
|
||||
|
||||
for ( var childVar in update.children) {
|
||||
var child = update.children[childVar];
|
||||
if (child && child.cons == "bobj.crv.newReportPage") {
|
||||
if (!this.reportPage) {
|
||||
/* adds reportPage if not existing */
|
||||
this.delayedAddChild (bobj.crv.createWidget (child));
|
||||
} else {
|
||||
/* updates reportpage */
|
||||
this.reportPage.update (child);
|
||||
}
|
||||
|
||||
break; /* There is only one child */
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
getHTML : function() {
|
||||
var h = bobj.html;
|
||||
|
||||
var layerStyle = {
|
||||
width : '100%',
|
||||
height : '100%',
|
||||
overflow : 'hidden',
|
||||
position : 'relative'
|
||||
};
|
||||
|
||||
var html = h.DIV ( {
|
||||
id : this.id,
|
||||
style : layerStyle
|
||||
}, this.reportPage ? this.reportPage.getHTML () : '');
|
||||
|
||||
return html;
|
||||
},
|
||||
|
||||
_doLayout : function() {
|
||||
if (this.reportPage)
|
||||
this.reportPage.resize (this.getWidth (), this.getHeight ());
|
||||
},
|
||||
|
||||
isMainReport : function() {
|
||||
return this.isMainReportFlag;
|
||||
},
|
||||
|
||||
/**
|
||||
* ReportView will always fill its container but it should be told when to
|
||||
* resize so that the layout of its contents will be updated.
|
||||
*/
|
||||
resize : function() {
|
||||
this._doLayout ();
|
||||
},
|
||||
|
||||
dispose : function() {
|
||||
if (this.reportPage) {
|
||||
this.reportPage.dispose ();
|
||||
bobj.deleteWidget (this.reportPage);
|
||||
delete this.reportPage;
|
||||
}
|
||||
|
||||
bobj.removeAllChildElements (this.layer);
|
||||
},
|
||||
|
||||
/**
|
||||
* @return Returns a suggested size for the widget as an object with width and height integer properties that specify the dimensions in
|
||||
* pixels.
|
||||
*/
|
||||
getBestFitSize : function() {
|
||||
var w = 0;
|
||||
var h = 0;
|
||||
|
||||
var pageSize = this.reportPage ? this.reportPage.getBestFitSize () : null;
|
||||
if (pageSize) {
|
||||
w += pageSize.width;
|
||||
h += pageSize.height;
|
||||
}
|
||||
|
||||
return {
|
||||
width : w,
|
||||
height : h
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* @return True if the view has report content. False if the view is empty.
|
||||
*/
|
||||
hasContent : function() {
|
||||
return this.reportPage != null;
|
||||
},
|
||||
|
||||
hideFrame : function() {
|
||||
if (this.reportPage)
|
||||
this.reportPage.hideFrame();
|
||||
}
|
||||
};
|
||||
71
crystalreportviewers13/js/crviewer/Separator.js
Normal file
@@ -0,0 +1,71 @@
|
||||
/* Copyright (c) Business Objects 2006. All rights reserved. */
|
||||
|
||||
if (typeof(bobj.crv.Separator) == 'undefined') {
|
||||
bobj.crv.Separator = {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Separator Constructor. Simple horizontal separator.
|
||||
*
|
||||
*/
|
||||
bobj.crv.newSeparator = function(kwArgs) {
|
||||
var UPDATE = MochiKit.Base.update;
|
||||
kwArgs = UPDATE({
|
||||
id: bobj.uniqueId(),
|
||||
marginLeft: 4,
|
||||
marginRight: 4,
|
||||
marginTop: 0,
|
||||
marginBottom: 2
|
||||
}, kwArgs);
|
||||
var o = newWidget(kwArgs.id);
|
||||
|
||||
bobj.fillIn(o, kwArgs);
|
||||
o.widgetType = 'Separator';
|
||||
|
||||
// Attach member functions
|
||||
UPDATE(o, bobj.crv.Separator);
|
||||
|
||||
return o;
|
||||
};
|
||||
|
||||
bobj.crv.Separator.getHTML = function() {
|
||||
var HTML = bobj.html;
|
||||
var htmlStr = '';
|
||||
if (bobj.isBorderBoxModel()) {
|
||||
htmlStr = HTML.IMG({
|
||||
id: this.id,
|
||||
src: bobj.skinUri('sep.gif'),
|
||||
style: {
|
||||
'height': 2 + 'px',
|
||||
'width':'100%',
|
||||
'margin-left': this.marginLeft + 'px',
|
||||
'margin-right': this.marginRight + 'px',
|
||||
'margin-top': this.marginTop + 'px',
|
||||
'margin-bottom': this.marginBottom + 'px'
|
||||
}});
|
||||
}
|
||||
else {
|
||||
htmlStr = HTML.DIV({
|
||||
id : this.id,
|
||||
style: {
|
||||
'height': 2 + 'px',
|
||||
'margin-left': this.marginLeft + 'px',
|
||||
'margin-right': this.marginRight + 'px',
|
||||
'margin-top': this.marginTop + 'px',
|
||||
'margin-bottom': this.marginBottom + 'px',
|
||||
'background-image': 'url(' + bobj.skinUri('sep.gif') + ')',
|
||||
'background-repeat': 'repeat-x',
|
||||
'overflow': 'hidden'
|
||||
|
||||
|
||||
}});
|
||||
}
|
||||
return htmlStr + bobj.crv.getInitHTML(this.widx);
|
||||
};
|
||||
|
||||
/**
|
||||
* @return Returns the outer height of the widget, including margins
|
||||
*/
|
||||
bobj.crv.Separator.getHeight = function() {
|
||||
return this.layer.offsetHeight + this.marginTop + this.marginBottom;
|
||||
};
|
||||
183
crystalreportviewers13/js/crviewer/SharedWidgetHolder.js
Normal file
@@ -0,0 +1,183 @@
|
||||
/* Copyright (c) Business Objects 2006. All rights reserved. */
|
||||
|
||||
if (typeof(bobj.crv.SharedWidgetHolder) == 'undefined') {
|
||||
bobj.crv.SharedWidgetHolder = {};
|
||||
bobj.crv.SharedWidgetHolder._registry = {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor. SharedWidgetHolder is a placeholder for a widget.
|
||||
* SharedWidgetHolder instances belong to groups, in which one managed
|
||||
* widget will be shown in one placeholder at a time. When show(true) is called
|
||||
* for any member of the group, the managed widget will be displayed in that
|
||||
* member.
|
||||
*
|
||||
* @param id [String] DHTML id
|
||||
* @param group [String] Group the new instance will belong to
|
||||
* @param width [int | String] Width of the placeholder
|
||||
* @param height [int | String] Height of the placeholder
|
||||
* @param resizeWidget [bool] Resize to the placeholder's dimensions
|
||||
*/
|
||||
bobj.crv.newSharedWidgetHolder = function(kwArgs) {
|
||||
var mb = MochiKit.Base;
|
||||
var ms = MochiKit.Signal;
|
||||
|
||||
kwArgs = mb.update({
|
||||
id: bobj.uniqueId(),
|
||||
group: 'SharedWidgetHolder',
|
||||
width: null,
|
||||
height: null,
|
||||
resizeWidget: true
|
||||
}, kwArgs);
|
||||
|
||||
var o = newWidget(kwArgs.id);
|
||||
o.widgetType = 'SharedWidgetHolder';
|
||||
bobj.fillIn(o, kwArgs);
|
||||
|
||||
o._setVisible = o.show;
|
||||
o._resizeHolder = o.resize;
|
||||
o._initHolder = o.init;
|
||||
mb.update(o, bobj.crv.SharedWidgetHolder);
|
||||
|
||||
o._register();
|
||||
|
||||
return o;
|
||||
};
|
||||
|
||||
bobj.crv.SharedWidgetHolder.init = function() {
|
||||
this._initHolder();
|
||||
var regInfo = this._regInfo;
|
||||
if (regInfo.managedWidget && this === regInfo.visibleHolder) {
|
||||
regInfo.managedWidget.init();
|
||||
this.resize();
|
||||
}
|
||||
};
|
||||
|
||||
bobj.crv.SharedWidgetHolder.getHTML = function() {
|
||||
var ISNUMBER = bobj.isNumber;
|
||||
var ISSTRING = bobj.isString;
|
||||
|
||||
var vis = this.isHoldingWidget() ? 'visible' : 'hidden';
|
||||
var innerHTML = this.isHoldingWidget() ? this._regInfo.managedWidget.getHTML() : '';
|
||||
|
||||
var style = {visibility: vis};
|
||||
|
||||
var width = this.width;
|
||||
if (ISNUMBER(width)) {
|
||||
width = width + 'px';
|
||||
}
|
||||
if (ISSTRING(width)) {
|
||||
style.width = width;
|
||||
}
|
||||
|
||||
var height = this.height;
|
||||
if (ISNUMBER(height)) {
|
||||
height = height + 'px';
|
||||
}
|
||||
if (ISSTRING(height)) {
|
||||
style.height = height;
|
||||
}
|
||||
|
||||
return bobj.html.DIV({id: this.id, style: style}, innerHTML);
|
||||
};
|
||||
|
||||
/**
|
||||
* Private. Register this instance in a group.
|
||||
*/
|
||||
bobj.crv.SharedWidgetHolder._register = function() {
|
||||
var registry = bobj.crv.SharedWidgetHolder._registry;
|
||||
var holderInfo = registry[this.group];
|
||||
|
||||
if (!holderInfo) {
|
||||
holderInfo = {
|
||||
managedWidget: null,
|
||||
visibleHolder: this
|
||||
};
|
||||
registry[this.group] = holderInfo;
|
||||
}
|
||||
|
||||
this._regInfo = holderInfo;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return [bool] True if and only if this instance is currently holding a
|
||||
* non-null managed widget. Only one member of a group can return
|
||||
* true at any given time.
|
||||
*/
|
||||
bobj.crv.SharedWidgetHolder.isHoldingWidget = function() {
|
||||
var regInfo = this._regInfo;
|
||||
return ((regInfo.visibleHolder === this) && regInfo.managedWidget);
|
||||
};
|
||||
|
||||
/**
|
||||
* @return [Widget] The widget that is managed by the holder group that this
|
||||
* instance belongs to.
|
||||
*/
|
||||
bobj.crv.SharedWidgetHolder.getManagedWidget = function() {
|
||||
return this._regInfo.managedWidget;
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the widget that is managed by the group that this isntance belongs to.
|
||||
* The widget will be displayed in the currently visible member of the group.
|
||||
*
|
||||
* @param widget [Widget] The widget that should be managed.
|
||||
*/
|
||||
bobj.crv.SharedWidgetHolder.setManagedWidget = function(widget) {
|
||||
var regInfo = this._regInfo;
|
||||
var oldWidget = regInfo.managedWidget;
|
||||
regInfo.managedWidget = widget;
|
||||
|
||||
if (oldWidget && oldWidget.layer) {
|
||||
MochiKit.DOM.removeElement(oldWidget.layer);
|
||||
}
|
||||
|
||||
if (!regInfo.visibleHolder) {
|
||||
regInfo.visibleHolder = this;
|
||||
}
|
||||
|
||||
var holder = regInfo.visibleHolder;
|
||||
|
||||
if (holder.layer && widget && widget.layer) {
|
||||
holder.layer.appendChild(widget.layer);
|
||||
holder.resize();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Alias for setManagedWidget. Allows instantiation using bobj.crv.createWidget();
|
||||
*/
|
||||
bobj.crv.SharedWidgetHolder.addChild = bobj.crv.SharedWidgetHolder.setManagedWidget;
|
||||
|
||||
/**
|
||||
* Show or hide the managed widget in this holder instance.
|
||||
*
|
||||
* @param show [bool] If true, the managed widget will be displayed in this
|
||||
* instance. If false and this holder is currently showing
|
||||
* the managed widget, the widget will be hidden.
|
||||
*/
|
||||
bobj.crv.SharedWidgetHolder.show = function(show) {
|
||||
var regInfo = this._regInfo;
|
||||
if (show && (regInfo.visibleHolder !== this) && regInfo.managedWidget) {
|
||||
this.layer.appendChild(regInfo.managedWidget.layer);
|
||||
regInfo.visibleHolder._setVisible(false);
|
||||
regInfo.visibleHolder = this;
|
||||
this.resize();
|
||||
}
|
||||
this._setVisible(show);
|
||||
};
|
||||
|
||||
/**
|
||||
* Resize the holder instance. If resizeWidget property is true, the managed
|
||||
* widget will be resized to the dimensions of the placeholder.
|
||||
*
|
||||
* @param w [width, optional] Width in pixels
|
||||
* @param h [height, optional] Height in pixels
|
||||
*/
|
||||
bobj.crv.SharedWidgetHolder.resize = function(w, h) {
|
||||
this._resizeHolder(w, h);
|
||||
|
||||
if (this.resizeWidget && this.isHoldingWidget()) {
|
||||
this._regInfo.managedWidget.resize(this.getWidth(), this.getHeight());
|
||||
}
|
||||
};
|
||||
38
crystalreportviewers13/js/crviewer/SignalDisposer.js
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Disposes signals synchronously and asynchronously.
|
||||
*/
|
||||
if (typeof(bobj.crv.SignalDisposer) == 'undefined') {
|
||||
bobj.crv.SignalDisposer = new function() {
|
||||
var signals = []; //private variable
|
||||
var timerID = null; //private variable
|
||||
var CLEAN_SIGNALS_PER_TASK = 20;
|
||||
var disconnect = MochiKit.Signal.disconnect;
|
||||
|
||||
this.dispose = function(signal, sync) {
|
||||
if(signal != null) {
|
||||
if(sync) {
|
||||
disconnect(signal);
|
||||
}
|
||||
else {
|
||||
signals.push (signal);
|
||||
if (timerID == null)
|
||||
timerID = setInterval (bobj.bindFunctionToObject (cleanTask, this), 100);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
cleanTask = function() {
|
||||
var count = CLEAN_SIGNALS_PER_TASK;
|
||||
while (signals.length > 0 && count > 0) {
|
||||
disconnect (signals.pop ());
|
||||
count--;
|
||||
}
|
||||
|
||||
if (signals.length == 0 && timerID != null) {
|
||||
clearInterval (timerID);
|
||||
timerID = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
160
crystalreportviewers13/js/crviewer/StackedPanel.js
Normal file
@@ -0,0 +1,160 @@
|
||||
/* Copyright (c) Business Objects 2006. All rights reserved. */
|
||||
|
||||
if (typeof(bobj.crv.StackedPanel) == 'undefined') {
|
||||
bobj.crv.StackedPanel = {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param id [String] DHTML id
|
||||
* @param width [int] Width of the panel in pixels
|
||||
* @param height [int] Height of the panel in pixels
|
||||
*/
|
||||
bobj.crv.newStackedPanel = function(kwArgs) {
|
||||
var mb = MochiKit.Base;
|
||||
var UPDATE = mb.update;
|
||||
var BIND = mb.bind;
|
||||
|
||||
kwArgs = UPDATE({
|
||||
id: bobj.uniqueId(),
|
||||
width: null,
|
||||
height: null
|
||||
}, kwArgs);
|
||||
|
||||
var o = newWidget(kwArgs.id);
|
||||
o.widgetType = 'StackedPanel';
|
||||
bobj.fillIn(o, kwArgs);
|
||||
|
||||
o._tabs = [];
|
||||
|
||||
o._initWidget = o.init;
|
||||
o._resizeWidget = o.resize;
|
||||
UPDATE(o, bobj.crv.StackedPanel);
|
||||
|
||||
|
||||
return o;
|
||||
};
|
||||
|
||||
bobj.crv.StackedPanel = {
|
||||
init : function() {
|
||||
this._initWidget ();
|
||||
|
||||
var tabs = this._tabs;
|
||||
/* Tabs that were added after getHTML must be written now */
|
||||
var index = this._numTabsWritten;
|
||||
while (index < tabs.length) {
|
||||
append (this.layer, tabs[index].getHTML (), document);
|
||||
index++;
|
||||
}
|
||||
|
||||
for ( var i = 0, len = tabs.length; i < len; ++i) {
|
||||
tabs[i].init ();
|
||||
}
|
||||
},
|
||||
|
||||
setTabDisabled : function(dis) {
|
||||
for ( var i = 0, len = this._tabs.length; i < len; i++) {
|
||||
this._tabs[i].setTabDisabled (dis);
|
||||
}
|
||||
},
|
||||
|
||||
getHTML : function() {
|
||||
var DIV = bobj.html.DIV;
|
||||
|
||||
var layerStyle = {};
|
||||
|
||||
if (this.height) {
|
||||
layerStyle.height = bobj.unitValue (this.height);
|
||||
}
|
||||
|
||||
if (this.width) {
|
||||
layerStyle.width = bobj.unitValue (this.width);
|
||||
}
|
||||
|
||||
return DIV ( {
|
||||
id : this.id,
|
||||
style : layerStyle,
|
||||
'class' : 'stackedPanel',
|
||||
tabIndex : "-1"
|
||||
}, this._getTabsHTML ());
|
||||
},
|
||||
|
||||
_getTabsHTML : function() {
|
||||
var tabsHTML = '';
|
||||
var tabs = this._tabs;
|
||||
var tabsLen = tabs.length;
|
||||
for ( var i = 0; i < tabsLen; ++i) {
|
||||
tabsHTML += tabs[i].getHTML ();
|
||||
}
|
||||
this._numTabsWritten = tabsLen;
|
||||
return tabsHTML;
|
||||
},
|
||||
|
||||
/**
|
||||
* Add a tab to the panel. Must be called before getHTML is called.
|
||||
*
|
||||
* @param tab
|
||||
* [StackedTab]
|
||||
*/
|
||||
addTab : function(tab) {
|
||||
if (tab) {
|
||||
this._tabs.push (tab);
|
||||
if (this.layer) {
|
||||
append (this.layer, tab.getHTML ());
|
||||
tab.init ();
|
||||
}
|
||||
|
||||
if (this.layer)
|
||||
tab.resize(this.layer.clientWidth);
|
||||
|
||||
MochiKit.Signal.connect(tab, "StackedTabResized", this, '_onStackedTabResize');
|
||||
}
|
||||
},
|
||||
|
||||
getNumTabs : function() {
|
||||
return this._tabs.length;
|
||||
},
|
||||
|
||||
getTab : function(index) {
|
||||
return this._tabs[index];
|
||||
},
|
||||
|
||||
removeTab : function(index) {
|
||||
if (index >= 0 && index < this._tabs.length) {
|
||||
var tab = this._tabs[index];
|
||||
this._tabs.splice (index, 1);
|
||||
delete _widgets[this._tabs.widx];
|
||||
if (tab.layer) {
|
||||
tab.layer.parentNode.removeChild (tab.layer);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_onStackedTabResize: function () {
|
||||
this.resize (this.getWidth());
|
||||
},
|
||||
|
||||
resize : function(w, h) {
|
||||
/* Exclude margins for safari as it miscalculates left/top margins */
|
||||
var excludeMargins = !_saf;
|
||||
bobj.setOuterSize(this.layer, w, h, excludeMargins);
|
||||
var tabs = this._tabs;
|
||||
var tabsLen = tabs.length;
|
||||
if (tabsLen) {
|
||||
/* Ensure that the vertical scrollbar never covers the content*/
|
||||
var tabWidth = this.layer.clientWidth;
|
||||
|
||||
/* IE changes the value of clientWidth after resizing the first child... */
|
||||
tabs[0].resize(tabWidth);
|
||||
if (tabWidth != this.layer.clientWidth) {
|
||||
tabWidth = this.layer.clientWidth;
|
||||
tabs[0].resize(tabWidth);
|
||||
}
|
||||
|
||||
for (var i = 1; i < tabsLen; ++i) {
|
||||
tabs[i].resize(tabWidth);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
230
crystalreportviewers13/js/crviewer/StackedTab.js
Normal file
@@ -0,0 +1,230 @@
|
||||
|
||||
/*
|
||||
================================================================================
|
||||
StackedTab
|
||||
================================================================================
|
||||
*/
|
||||
bobj.crv.newStackedTab = function(kwArgs) {
|
||||
var UPDATE = MochiKit.Base.update;
|
||||
|
||||
kwArgs = UPDATE({
|
||||
id: bobj.uniqueId(),
|
||||
label: '',
|
||||
width: 300,
|
||||
height: null, // null height means grow as big as necessary
|
||||
openAdvCB: null,
|
||||
name : '',
|
||||
isDataFetching: false
|
||||
}, kwArgs);
|
||||
|
||||
var o = newWidget(kwArgs.id);
|
||||
o.widgetType = 'StackedTab';
|
||||
bobj.fillIn(o, kwArgs);
|
||||
|
||||
o._content = null;
|
||||
|
||||
if(o.openAdvCB) {
|
||||
o._advanceButton = newIconWidget(
|
||||
o.id + '_advBtn',
|
||||
bobj.crv.allInOne.uri,
|
||||
o.openAdvCB,
|
||||
null, //text
|
||||
L_bobj_crv_paramsOpenAdvance.replace("%1", o.name),//tooltip,
|
||||
10, 10, 3, bobj.crv.allInOne.openParameterArrowDy + (_ie ? 2 : 3)); //width, height, dx, dy, disDx, disDy, cancelEventPropagation
|
||||
bobj.crv.setAllClasses(o._advanceButton, 'arrow_button');
|
||||
o._advanceButton.margin = 0;
|
||||
}
|
||||
|
||||
o._initWidget = o.init;
|
||||
o._resizeWidget = o.resize;
|
||||
UPDATE(o, bobj.crv.StackedTab);
|
||||
|
||||
return o;
|
||||
};
|
||||
|
||||
bobj.crv.StackedTab = {
|
||||
setTabDisabled : function(dis) {
|
||||
if (this._content)
|
||||
this._content.setTabDisabled (dis);
|
||||
|
||||
if (this._advanceButton && this._advanceButton.layer)
|
||||
bobj.disableTabbingKey (this._advanceButton.layer, dis);
|
||||
|
||||
if (this._textCtn)
|
||||
bobj.disableTabbingKey (this._textCtn, dis);
|
||||
|
||||
if(this._dataFetchLayer)
|
||||
bobj.disableTabbingKey (this._dataFetchLayer, dis);
|
||||
},
|
||||
|
||||
init : function() {
|
||||
var connect = MochiKit.Signal.connect;
|
||||
var signal = MochiKit.Signal.signal;
|
||||
var partial = MochiKit.Base.partial;
|
||||
|
||||
this._initWidget ();
|
||||
|
||||
if (this._content) {
|
||||
this._content.init ();
|
||||
}
|
||||
|
||||
if (this._advanceButton) {
|
||||
this._advanceButton.init ();
|
||||
this._onAdvanceButtonClickOld = MochiKit.Base.bind(this._advanceButton.layer.onclick, this._advanceButton.layer);
|
||||
this._advanceButton.layer.onclick = MochiKit.Base.bind(this.advButtonOnClick, this);
|
||||
this._advanceButton.css.width = "14px";
|
||||
}
|
||||
|
||||
this._dataFetchLayer = getLayer(this.id + "_df");
|
||||
this._labelCtn = getLayer (this.id + '_labelCtn');
|
||||
this._textCtn = getLayer (this.id + '_textCtn');
|
||||
this._contentCtn = getLayer (this.id + '_contentCtn');
|
||||
|
||||
if (this._advanceButton) {
|
||||
var advButtonLayer = this._advanceButton.layer;
|
||||
var bind = bobj.bindFunctionToObject;
|
||||
connect (this.layer, 'onclick', bind(IconWidget_upCB, advButtonLayer));
|
||||
connect (this.layer, 'onmouseover', bind(IconWidget_realOverCB, advButtonLayer));
|
||||
connect (this.layer, 'onmouseout', bind(IconWidget_realOutCB, advButtonLayer));
|
||||
connect (this.layer, 'onmousedown', bind(IconWidget_downCB, advButtonLayer));
|
||||
|
||||
}
|
||||
|
||||
connect(this._content, 'ParameterUIResized', partial (signal, this, "StackedTabResized"));
|
||||
},
|
||||
|
||||
getHTML : function() {
|
||||
var h = bobj.html;
|
||||
var DIV = h.DIV;
|
||||
var IMG = h.IMG;
|
||||
|
||||
var stackedTabAtt = {
|
||||
'class' : 'stackedTab',
|
||||
cellpadding : "0",
|
||||
id : this.id,
|
||||
style : {
|
||||
cursor : this._advanceButton ? _hand : 'default'
|
||||
}
|
||||
};
|
||||
|
||||
var labelCtnAtt = {
|
||||
id: this.id + '_labelCtn',
|
||||
cellpadding : "0",
|
||||
'class': 'crvnoselect stackedTabTitle'
|
||||
};
|
||||
|
||||
var contentHTML = this._content ? this._content.getHTML() : '';
|
||||
var advButtonHTML = this._advanceButton ? h.TD ({width : '17px'}, this._advanceButton.getHTML()) : ''; /* 14 for arrow height + 3px right margin */
|
||||
var dataFetchHTML = "";
|
||||
|
||||
if (this.isDataFetching) {
|
||||
var URL_TAG = "url(%1);"
|
||||
dataFetchHTML = h.TD ({width : '20px'}, IMG ( {
|
||||
src : _skin + '../transp.gif',
|
||||
title : L_bobj_crv_ParamsDataTip,
|
||||
tabindex: 0,
|
||||
id: this.id + "_df",
|
||||
style : {
|
||||
width : "16px",
|
||||
height : "16px",
|
||||
"background-image" : URL_TAG.replace("%1", bobj.crv.allInOne.uri),
|
||||
"background-position" : "0px " + (-bobj.crv.allInOne.paramDataFetchingDy) + "px",
|
||||
"margin-right" : '4px',
|
||||
'vertical-align' : 'middle'
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
var html = DIV (stackedTabAtt, DIV (labelCtnAtt, h.TABLE ( {
|
||||
cellpadding : "0",
|
||||
width : '100%',
|
||||
height : '20px',
|
||||
style : {
|
||||
'table-layout' : 'fixed'
|
||||
}
|
||||
}, h.TD ({style : {"vertical-align" : "top", "overflow" : "hidden"}}, DIV ( {
|
||||
'class' :'stackedTabText',
|
||||
id :this.id + '_textCtn',
|
||||
title :this.label,
|
||||
'tabIndex' :0,
|
||||
style : {
|
||||
'font-weight' : 'bold',
|
||||
'color' : '#4F5C72'
|
||||
}
|
||||
}, convStr (this.label))
|
||||
), dataFetchHTML, advButtonHTML)
|
||||
), DIV ( {
|
||||
id :this.id + '_contentCtn',
|
||||
'class' :'stackedTabContentCtn'
|
||||
}, contentHTML));
|
||||
|
||||
return html;
|
||||
},
|
||||
|
||||
setDirty : function(isDirty) {
|
||||
if(this._textCtn) {
|
||||
this._textCtn.style.fontStyle = isDirty ? "italic" : "";
|
||||
this._textCtn.title = isDirty ? this.label + " " + L_bobj_crv_ParamsDirtyTip : this.label;
|
||||
}
|
||||
|
||||
if(this._labelCtn) {
|
||||
var titleClassName = isDirty ? "stackedTabTitleDirty" : "stackedTabTitle";
|
||||
|
||||
// IE 7 uses "className"
|
||||
this._labelCtn.setAttribute("className", titleClassName);
|
||||
|
||||
// IE 8, FireFox, and Safari use "class"
|
||||
this._labelCtn.setAttribute("class", titleClassName);
|
||||
}
|
||||
},
|
||||
|
||||
resize : function(w) {
|
||||
w = w - 4; // TODO exclude margins properly
|
||||
if(this._labelCtn) {
|
||||
// Exclude margins for safari as it miscalculates left/top margins
|
||||
var excludeMargins = !_saf;
|
||||
bobj.setOuterSize(this._labelCtn, w , null, excludeMargins);
|
||||
}
|
||||
if (this._content) {
|
||||
this._content.resize(w -2);
|
||||
}
|
||||
bobj.setOuterSize(this.layer, w);
|
||||
},
|
||||
|
||||
/**
|
||||
* Set the widget that is displayed below the tab. Must be called before getHTML.
|
||||
*
|
||||
* @param widget [Widget] Widget that appears below the tab when the tab is expanded
|
||||
*/
|
||||
setContent : function(widget) {
|
||||
this._content = widget;
|
||||
},
|
||||
|
||||
/**
|
||||
* Get the widget that is displayed below the tab.
|
||||
*
|
||||
* @return [Widget] Widget that appears below the tab
|
||||
*/
|
||||
getContent : function() {
|
||||
return this._content;
|
||||
},
|
||||
|
||||
/**
|
||||
* Focus the advanced button if available
|
||||
*/
|
||||
focusAdvButton : function() {
|
||||
if (this._advanceButton && this._advanceButton.focus)
|
||||
this._advanceButton.focus();
|
||||
},
|
||||
|
||||
/**
|
||||
* Override default onclick for the advanced button to cancel propagating the event.
|
||||
*/
|
||||
advButtonOnClick : function(e) {
|
||||
if (this._onAdvanceButtonClickOld)
|
||||
{
|
||||
this._onAdvanceButtonClickOld(e);
|
||||
eventCancelBubble(e);
|
||||
}
|
||||
}
|
||||
};
|
||||
86
crystalreportviewers13/js/crviewer/StateManager.js
Normal file
@@ -0,0 +1,86 @@
|
||||
/* Copyright (c) Business Objects 2006. All rights reserved. */
|
||||
|
||||
/**
|
||||
* Constructor. StateManager holds state for multiple viewers.
|
||||
*/
|
||||
bobj.crv.StateManager = function() {
|
||||
this._state = {};
|
||||
};
|
||||
|
||||
bobj.crv.StateManager.prototype = {
|
||||
/**
|
||||
* Set the state object for a report view
|
||||
*
|
||||
* @param viewerName [String]
|
||||
* @param stateName [String] The name of the report view
|
||||
* @param viewState [Object] The state associated with the report view
|
||||
*/
|
||||
setViewState: function(viewerName, stateName, viewState) {
|
||||
var state = this._state;
|
||||
|
||||
if (!state[viewerName]) {
|
||||
state[viewerName] = {};
|
||||
}
|
||||
|
||||
state[viewerName][stateName] = viewState;
|
||||
},
|
||||
|
||||
/**
|
||||
* Get the state object for a report view
|
||||
*
|
||||
* @param viewerName [String]
|
||||
* @param stateName [String] The name of the report view
|
||||
*
|
||||
* @return [Object] Returns the state object for the report view or null
|
||||
* if no object is associated with (viewerName, stateName)
|
||||
*/
|
||||
getViewState: function(viewerName, stateName) {
|
||||
var state = this._state;
|
||||
|
||||
if (!state[viewerName]) {
|
||||
return null;
|
||||
}
|
||||
return state[viewerName][stateName];
|
||||
},
|
||||
|
||||
/**
|
||||
* Set the compound state object for a viewer components. This object
|
||||
* should contain a state object for every report view displayed by the
|
||||
* viewer.
|
||||
*
|
||||
* @param viewerName [String]
|
||||
* @param state [Object] All report view states for the viewer
|
||||
*/
|
||||
setComponentState: function(viewerName, state) {
|
||||
this._state[viewerName] = state;
|
||||
},
|
||||
|
||||
/**
|
||||
* Get the compound state object for a viewer component. This object
|
||||
* should contain a state object for every report view displayed by the
|
||||
* viewer.
|
||||
*
|
||||
* @param viewerName [String]
|
||||
*
|
||||
* @return [Object] Returns all report view states for the viewer
|
||||
*/
|
||||
getComponentState: function(viewerName) {
|
||||
return this._state[viewerName];
|
||||
},
|
||||
|
||||
/**
|
||||
* Get the state for all viewer components on the page.
|
||||
*
|
||||
* @return [Object] Returns the state of all viewers on the page, mapped
|
||||
* by the id of the viewer widgets.
|
||||
*/
|
||||
getCompositeState: function() {
|
||||
return this._state;
|
||||
}
|
||||
};
|
||||
|
||||
// Create a single StateManager for all viewers in the page to share
|
||||
if (typeof bobj.crv.viewerState == 'undefined') {
|
||||
bobj.crv.stateManager = new bobj.crv.StateManager();
|
||||
}
|
||||
|
||||
257
crystalreportviewers13/js/crviewer/Statusbar.js
Normal file
@@ -0,0 +1,257 @@
|
||||
/* Copyright (c) Business Objects 2006. All rights reserved. */
|
||||
|
||||
/**
|
||||
* Statusbar widget constructor ({id: String})
|
||||
*/
|
||||
bobj.crv.newStatusbar = function(kwArgs) {
|
||||
var UPDATE = MochiKit.Base.update;
|
||||
kwArgs = UPDATE({
|
||||
id: bobj.uniqueId(),
|
||||
visualStyle : {
|
||||
className : null,
|
||||
backgroundColor : null,
|
||||
borderWidth : null,
|
||||
borderStyle : null,
|
||||
borderColor : null,
|
||||
fontFamily : null,
|
||||
fontWeight : null,
|
||||
textDecoration : null,
|
||||
color : null,
|
||||
width : null,
|
||||
height : null,
|
||||
fontStyle : null,
|
||||
fontSize : null
|
||||
}
|
||||
}, kwArgs);
|
||||
|
||||
var o = newPaletteContainerWidget(kwArgs.id);
|
||||
|
||||
o.margin = 0;
|
||||
bobj.fillIn(o, kwArgs);
|
||||
o._rightZoneWgts = [];
|
||||
o.widgetType = 'Statusbar';
|
||||
|
||||
// Attach member functions (since we can't use prototypes)
|
||||
o.initOld = o.init;
|
||||
UPDATE(o, bobj.crv.Statusbar);
|
||||
|
||||
o.palette = newPaletteWidget(o.id + "_palette");
|
||||
o.palette.isLeftTableFixed = true;
|
||||
o.add(o.palette);
|
||||
|
||||
return o;
|
||||
};
|
||||
|
||||
bobj.crv.Statusbar = {
|
||||
/**
|
||||
* Overrides parent
|
||||
*/
|
||||
init : function() {
|
||||
this.initOld ();
|
||||
bobj.setVisualStyle (this.layer, this.visualStyle);
|
||||
this.palette.init ();
|
||||
},
|
||||
|
||||
/**
|
||||
* Overrides parent
|
||||
*/
|
||||
beginHTML : function() {
|
||||
return bobj.html.openTag ('div', {
|
||||
id : this.id,
|
||||
'class' : 'dialogzone',
|
||||
style : {
|
||||
width : '100%',
|
||||
overflow : 'hidden',
|
||||
margin : this.margin + 'px',
|
||||
padding : '2px 0px',
|
||||
position : 'absolute'
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Overrides parent
|
||||
*/
|
||||
getHTML : function() {
|
||||
this._addRightZone ();
|
||||
return (this.beginHTML () + this.palette.getHTML () + this.endHTML ());
|
||||
},
|
||||
|
||||
/**
|
||||
* Private. Adds right-aligned widgets to the right zone of the palette
|
||||
*/
|
||||
_addRightZone : function() {
|
||||
this.palette.beginRightZone ();
|
||||
|
||||
var w = null;
|
||||
while (w = this._rightZoneWgts.pop ()) {
|
||||
this.palette.add (w);
|
||||
}
|
||||
|
||||
delete this._rightZoneWgts;
|
||||
},
|
||||
|
||||
/**
|
||||
* Overrides parent
|
||||
*/
|
||||
write : function() {
|
||||
this._addRightZone ();
|
||||
this.begin ();
|
||||
this.palette.write ();
|
||||
this.end ();
|
||||
document.write (bobj.crv.getInitHTML (this.widx));
|
||||
},
|
||||
|
||||
/**
|
||||
* Add child widgets to the statusbar - left or right
|
||||
*/
|
||||
addChild : function(widget) {
|
||||
switch (widget.widgetType) {
|
||||
case 'StatusbarBreadcrumb':
|
||||
this.breadcrumb = widget;
|
||||
break;
|
||||
case 'StatusbarVersionIndicator':
|
||||
this.versionIndicator = widget;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Delay adding right-aligned widgets due to the semantics of the palette */
|
||||
if (widget.layoutAlign == 'right') {
|
||||
this._rightZoneWgts.push (widget);
|
||||
} else {
|
||||
this.palette.add (widget);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Update child widgets - if they are exists in the statusbar
|
||||
*/
|
||||
update : function(update) {
|
||||
if (update) {
|
||||
for ( var childNum in update.children) {
|
||||
var child = update.children[childNum];
|
||||
if (child) {
|
||||
switch (child.cons) {
|
||||
case "bobj.crv.newStatusbarBreadcrumb":
|
||||
if (this.breadcrumb) {
|
||||
this.breadcrumb.update (child.args);
|
||||
}
|
||||
break;
|
||||
case "bobj.crv.newStatusbarVersionIndicator":
|
||||
if (this.versionIndicator) {
|
||||
this.versionIndicator.update (child.args);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
doLayout : function() {
|
||||
if (this.breadcrumb) {
|
||||
this.breadcrumb._doLayout();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* StatusbarBreadcrumb widget constructor ({values: String[]})
|
||||
*/
|
||||
bobj.crv.newStatusbarBreadcrumb = function(kwArgs) {
|
||||
var o = newWidget(bobj.uniqueId());
|
||||
|
||||
o.widgetType = 'StatusbarBreadcrumb';
|
||||
o.values = kwArgs.values;
|
||||
o.layoutAlign = 'left';
|
||||
|
||||
o._separatorImage = img(bobj.crvUri('images/breadcrumbSep.gif'), 14, 9);
|
||||
|
||||
MochiKit.Base.update(o, bobj.crv.StatusbarBreadcrumb);
|
||||
return o;
|
||||
};
|
||||
|
||||
bobj.crv.StatusbarBreadcrumb = {
|
||||
/**
|
||||
* Update the breadcrumbs ({values: String[]})
|
||||
*/
|
||||
update : function(kwArgs) {
|
||||
this.values = kwArgs.values;
|
||||
this.layer.innerHTML = this._render ();
|
||||
},
|
||||
|
||||
/**
|
||||
* Overrides parent
|
||||
*/
|
||||
getHTML : function() {
|
||||
return bobj.html.DIV ( {
|
||||
'class' : 'statusbar_breadcrumb'
|
||||
}, bobj.html.DIV ( {
|
||||
id : this.id
|
||||
}, this._render ()));
|
||||
},
|
||||
|
||||
/**
|
||||
* Render the breadcrumbs as table cells separated by an image - called by getHTML and update
|
||||
*/
|
||||
_render : function() {
|
||||
var html = '';
|
||||
if (this.values && this.values.length > 0) {
|
||||
var cells = '';
|
||||
for (i = 0; i < this.values.length; i++) {
|
||||
if (i > 0) { /* insert a separate image before values - except first one */
|
||||
cells += bobj.html.TD (null, this._separatorImage);
|
||||
}
|
||||
cells += bobj.html.TD ( {
|
||||
style : {
|
||||
'white-space' : 'nowrap'
|
||||
}
|
||||
}, this.values[i]);
|
||||
}
|
||||
|
||||
html = bobj.html.TABLE ( {
|
||||
'class' : 'iconText',
|
||||
cellspacing : '0',
|
||||
cellpadding : '0'
|
||||
}, bobj.html.TR (null, cells));
|
||||
}
|
||||
return html;
|
||||
},
|
||||
|
||||
_doLayout : function() {
|
||||
var needsRightAlign = (this.layer.parentNode.scrollWidth > this.layer.parentNode.offsetWidth) || (this.layer.offsetLeft < 0);
|
||||
if (needsRightAlign) {
|
||||
this.layer.style.position = "absolute";
|
||||
this.layer.style.top = "0px";
|
||||
this.layer.style.right = "0px";
|
||||
}
|
||||
else {
|
||||
this.layer.style.position = "";
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* StatusbarVersionIndicator widget constructor ({value: String})
|
||||
*/
|
||||
bobj.crv.newStatusbarVersionIndicator = function(kwArgs) {
|
||||
var text = (kwArgs && kwArgs.value) ? L_bobj_crv_LastRefreshed + ": " + kwArgs.value : ' ';
|
||||
var o = NewLabelWidget(bobj.uniqueId(), text, true);
|
||||
|
||||
o.widgetType = 'StatusbarVersionIndicator';
|
||||
o.layoutAlign = 'right';
|
||||
|
||||
MochiKit.Base.update(o, bobj.crv.StatusbarVersionIndicator);
|
||||
return o;
|
||||
};
|
||||
|
||||
bobj.crv.StatusbarVersionIndicator = {
|
||||
/**
|
||||
* Update the last refreshed value
|
||||
*/
|
||||
update : function(kwArgs) {
|
||||
var text = (kwArgs && kwArgs.value) ? L_bobj_crv_LastRefreshed + ": " + kwArgs.value : ' ';
|
||||
this.layer.innerHTML = text;
|
||||
}
|
||||
};
|
||||
377
crystalreportviewers13/js/crviewer/TextCombo.js
Normal file
@@ -0,0 +1,377 @@
|
||||
|
||||
/*
|
||||
================================================================================
|
||||
TextCombo
|
||||
|
||||
Internal class. Editable combo box that renders correctly in a Parameter UI
|
||||
================================================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* Constructor. TextCombo extends TextComboWidget from the dhtmllib.
|
||||
*/
|
||||
bobj.crv.params.newTextCombo = function(kwArgs) {
|
||||
var UPDATE = MochiKit.Base.update;
|
||||
var PARAMS = bobj.crv.params;
|
||||
kwArgs = UPDATE({
|
||||
id: bobj.uniqueId(),
|
||||
width: '100%',
|
||||
maxChar: null,
|
||||
tooltip: null,
|
||||
disabled: false,
|
||||
editable: false,
|
||||
changeCB: null,
|
||||
enterCB: null,
|
||||
keyUpCB: null,
|
||||
isTextItalic: false
|
||||
}, kwArgs);
|
||||
|
||||
var o = newTextComboWidget(
|
||||
kwArgs.id,
|
||||
kwArgs.maxChar,
|
||||
kwArgs.tooltip,
|
||||
null, // width
|
||||
kwArgs.changeCB,
|
||||
null, // check CB
|
||||
null, // beforeShowCB
|
||||
null);// formName
|
||||
|
||||
o.widgetType = 'TextCombo';
|
||||
|
||||
// Update instance with constructor arguments
|
||||
bobj.fillIn(o, kwArgs);
|
||||
o.width = kwArgs.width;
|
||||
|
||||
// Update instance with member functions
|
||||
o.init_TextCombo = o.init;
|
||||
UPDATE(o, PARAMS.TextCombo);
|
||||
|
||||
o._createTextField(); // Override parent's text property
|
||||
o._createArrow();
|
||||
o.arrow.dy += 2; // Center the arrow
|
||||
o.arrow.disDy += 2;
|
||||
|
||||
return o;
|
||||
};
|
||||
|
||||
bobj.crv.params.TextCombo = {
|
||||
setTextItalic : function(isTextItalic) {
|
||||
if (this.text) {
|
||||
this.text.setTextItalic (isTextItalic);
|
||||
}
|
||||
},
|
||||
|
||||
setForeColor : function(color) {
|
||||
if (this.text)
|
||||
this.text.setForeColor (color);
|
||||
},
|
||||
|
||||
setTooltip : function(tooltip) {
|
||||
if (this.text) {
|
||||
this.text.setTooltip (tooltip);
|
||||
}
|
||||
},
|
||||
|
||||
setTabDisabled : function(dis) {
|
||||
if (this.text)
|
||||
this.text.setTabDisabled (dis);
|
||||
|
||||
if (this.arrow)
|
||||
bobj.disableTabbingKey (this.arrow.layer, dis);
|
||||
},
|
||||
|
||||
setMenu : function(menu) {
|
||||
this.menu = menu;
|
||||
},
|
||||
|
||||
init : function() {
|
||||
this.init_TextCombo ();
|
||||
this.arrowContainer = getLayer (this.id + '_arrowCtn');
|
||||
|
||||
if (this.arrow) {
|
||||
this.arrow.layer.onfocus = IconWidget_realOverCB;
|
||||
this.arrow.layer.onblur = IconWidget_realOutCB;
|
||||
}
|
||||
|
||||
this.text.setValue (this.cleanValue);
|
||||
},
|
||||
|
||||
toggleMenu : function() {
|
||||
var menu = this.menu;
|
||||
menu.parIcon = this;
|
||||
var toShow = !menu.isShown();
|
||||
menu.show (toShow);
|
||||
if (toShow)
|
||||
menu.valueSelect (this.text.getValue () + '');
|
||||
},
|
||||
|
||||
_createArrow : function() {
|
||||
var tooltip = _openMenu.replace("{0}", this.tooltip? this.tooltip: '');
|
||||
this.arrow = newIconWidget(this.id + "arrow_",
|
||||
bobj.skinUri("menus.gif"),
|
||||
bobj.bindFunctionToObject(this.toggleMenu,this),
|
||||
null,
|
||||
tooltip,
|
||||
7, /* w */
|
||||
12, /* h */
|
||||
0, /* dx */
|
||||
83, /* dy */
|
||||
0, /* disDx */
|
||||
99); /* disDy */
|
||||
|
||||
this.arrow.setClasses("iconnocheck", "combobtnhover", "combobtnhover", "combobtnhover");
|
||||
this.arrow.par = this;
|
||||
},
|
||||
|
||||
_createTextField : function() {
|
||||
this.text = bobj.crv.params.newTextField ( {
|
||||
id : this.id + '_text',
|
||||
cleanValue : this.cleanValue,
|
||||
width : '100%',
|
||||
maxChar : null,
|
||||
tooltip : this.tooltip,
|
||||
disabled : false,
|
||||
editable : this.editable,
|
||||
password : false,
|
||||
focusCB : this.focusCB,
|
||||
blurCB : this.blurCB,
|
||||
keyUpCB : bobj.bindFunctionToObject (this._onKeyUp, this),
|
||||
enterCB : this.enterCB,
|
||||
foreColor : this.foreColor,
|
||||
isTextItalic : this.isTextItalic
|
||||
});
|
||||
},
|
||||
|
||||
getHTML : function() {
|
||||
var h = bobj.html;
|
||||
|
||||
var arrowClassName = 'iactTextComboArrow';
|
||||
var arrowStyle = {};
|
||||
arrowStyle.right = "0px";
|
||||
|
||||
if (MochiKit.Base.isIE ()) {
|
||||
arrowStyle.height = "18px";
|
||||
|
||||
} else {
|
||||
arrowStyle.height = "16px";
|
||||
}
|
||||
|
||||
var html = h.DIV ( {
|
||||
id : this.id,
|
||||
style : {
|
||||
width : "100%",
|
||||
position : "relative"
|
||||
}
|
||||
}, h.DIV ( {
|
||||
style : {
|
||||
position : "relative"
|
||||
},
|
||||
'class' : 'iactTextComboTextField'
|
||||
}, this.text.getHTML ()), h.DIV ( {
|
||||
'class' : arrowClassName,
|
||||
id : this.id + '_arrowCtn',
|
||||
style : arrowStyle
|
||||
}, this.arrow.getHTML ()));
|
||||
|
||||
return html;
|
||||
},
|
||||
|
||||
/**
|
||||
* Resets TextCombo. sets original value and hides arrow icon
|
||||
*/
|
||||
reset : function(value) {
|
||||
this.text.reset (value);
|
||||
},
|
||||
|
||||
/**
|
||||
* Set the content of the text box and update the menu selection
|
||||
*
|
||||
* @param text [String]
|
||||
*/
|
||||
setValue : function(text) {
|
||||
this.text.setValue(text);
|
||||
},
|
||||
|
||||
setCleanValue : function(text) {
|
||||
this.text.setCleanValue (text);
|
||||
},
|
||||
|
||||
/**
|
||||
* Private. Overrides parent.
|
||||
*/
|
||||
selectItem : function(item) {
|
||||
if (item) {
|
||||
this.val = item.value;
|
||||
this.text.setValue (item.value, true); /* keep the previous clean value */
|
||||
this.menu.select (item.index);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Get the content on the text box
|
||||
*
|
||||
* @return [String]
|
||||
*/
|
||||
getValue : function() {
|
||||
return this.text.getValue ();
|
||||
},
|
||||
|
||||
_onKeyUp : function(e) {
|
||||
var text = this.text.getValue ();
|
||||
|
||||
if (this.keyUpCB)
|
||||
this.keyUpCB (e);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* ScrollMenuWidget
|
||||
*/
|
||||
|
||||
bobj.crv.params.newScrollMenuWidget = function(kwArgs) {
|
||||
kwArgs = MochiKit.Base.update({
|
||||
id : bobj.uniqueId(),
|
||||
originalValues: [],
|
||||
hasProperWidth: false,
|
||||
hasValueList: false,
|
||||
maxVisibleItems: 10,
|
||||
openAdvDialogCB: null,
|
||||
maxNumParameterDefaultValues: null
|
||||
},kwArgs);
|
||||
|
||||
var visibleLines = (kwArgs.originalValues.length >= kwArgs.maxVisibleItems) ? kwArgs.maxVisibleItems : kwArgs.originalValues.length;
|
||||
if (visibleLines === 1) {
|
||||
visibleLines++;
|
||||
}
|
||||
|
||||
var o = newScrollMenuWidget(
|
||||
"menu_"+ kwArgs.id, //id
|
||||
bobj.crv.params.ScrollMenuWidget.onChange, //changeCB
|
||||
false, //multi
|
||||
null,
|
||||
visibleLines, //lines
|
||||
null, //tooltip
|
||||
null,//dblClickCB
|
||||
null, //keyUpCB
|
||||
false, //showLabel
|
||||
'', //label
|
||||
'',//convBlanks
|
||||
null, //beforeShowCB
|
||||
null); //menuClickCB
|
||||
|
||||
o.oldShow = o.show;
|
||||
MochiKit.Base.update(o,kwArgs, bobj.crv.params.ScrollMenuWidget);
|
||||
|
||||
return o;
|
||||
};
|
||||
|
||||
bobj.crv.params.ScrollMenuWidget = {
|
||||
onChange : function() {
|
||||
var o = this.parIcon;
|
||||
var item = this.getSelection ();
|
||||
|
||||
if (item) {
|
||||
if (this.maxNumParameterDefaultValues && item.index == this.maxNumParameterDefaultValues) {
|
||||
if (this.openAdvDialogCB) {
|
||||
this.openAdvDialogCB ();
|
||||
this.clearSelection ();
|
||||
}
|
||||
} else {
|
||||
o.val = item.value;
|
||||
o.text.setValue (item.value);
|
||||
}
|
||||
} else {
|
||||
o.val = null;
|
||||
o.text.setValue ("");
|
||||
}
|
||||
|
||||
if (o.changeCB) {
|
||||
o.changeCB ();
|
||||
}
|
||||
},
|
||||
|
||||
getPosition : function() {
|
||||
if (this.parIcon === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
var layer = this.parIcon.layer;
|
||||
var getDimensions = MochiKit.Style.getElementDimensions;
|
||||
var position = getPosScrolled (layer);
|
||||
var xPos = position.x + 2;
|
||||
var yPos = position.y + getDimensions (layer).h + 3;
|
||||
if (MochiKit.Base.isIE ()) {
|
||||
xPos -= 1;
|
||||
if (bobj.isQuirksMode ()) {
|
||||
yPos -= 2;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
x : xPos,
|
||||
y : yPos
|
||||
};
|
||||
|
||||
},
|
||||
|
||||
setProperWidth : function() {
|
||||
if (this.hasProperWidth === false) {
|
||||
this.css.display = "block";
|
||||
this.orginalWidth = this.layer.offsetWidth;
|
||||
this.css.display = "none";
|
||||
this.hasProperWidth = true;
|
||||
}
|
||||
},
|
||||
|
||||
setValueList : function() {
|
||||
if (this.hasValueList === false) {
|
||||
this.hasValueList = true;
|
||||
var origValues = this.originalValues;
|
||||
for ( var i = 0, len = origValues.length; i < len; i++) {
|
||||
this.add (origValues[i], origValues[i], false);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
setFocus : function(focus) {
|
||||
if (focus) {
|
||||
var focusCB = bobj.bindFunctionToObject (this.list.focus, this.list);
|
||||
setTimeout (focusCB, 300);
|
||||
} else {
|
||||
if (this.parIcon.selected === true) {
|
||||
this.parIcon.arrow.focus ();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
show : function(show) {
|
||||
if (this.layer === null)
|
||||
this.justInTimeInit ();
|
||||
|
||||
if (this.hasValueList === false)
|
||||
this.setValueList ();
|
||||
|
||||
if (this.parIcon === null)
|
||||
return;
|
||||
|
||||
if (this.hasProperWidth === false)
|
||||
this.setProperWidth ();
|
||||
|
||||
if (this.parIcon && this.parIcon.layer) {
|
||||
var layer = this.parIcon.layer;
|
||||
if (layer.clientWidth > this.orginalWidth) {
|
||||
this.css.width = layer.clientWidth + "px";
|
||||
this.list.css.width = layer.clientWidth + "px";
|
||||
} else {
|
||||
this.css.width = this.orginalWidth + "px";
|
||||
this.list.css.width = this.orginalWidth + "px";
|
||||
}
|
||||
}
|
||||
|
||||
var pos = this.getPosition ();
|
||||
this.oldShow (show, pos.x, pos.y);
|
||||
|
||||
this.setFocus (show);
|
||||
}
|
||||
};
|
||||
151
crystalreportviewers13/js/crviewer/TextField.js
Normal file
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
* ================================================================================
|
||||
* TextField
|
||||
*
|
||||
* Internal class. Text box that renders correctly in a Parameter UI
|
||||
* ================================================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* Constructor. TextField extends TextFieldWidget from the dhtmllib.
|
||||
*/
|
||||
bobj.crv.params.newTextField = function(kwArgs) {
|
||||
kwArgs = MochiKit.Base.update({
|
||||
id: bobj.uniqueId(),
|
||||
cleanValue: '',
|
||||
width: '100%',
|
||||
maxChar: null,
|
||||
tooltip: null,
|
||||
disabled: false,
|
||||
editable: true,
|
||||
password: false,
|
||||
focusCB: null,
|
||||
blurCB: null,
|
||||
changeCB: null,
|
||||
keyUpCB: null,
|
||||
enterCB: null,
|
||||
foreColor : 'black',
|
||||
isTextItalic : false,
|
||||
canOpenAdvDialog : false
|
||||
}, kwArgs);
|
||||
|
||||
var o = newTextFieldWidget(
|
||||
kwArgs.id,
|
||||
kwArgs.changeCB,
|
||||
kwArgs.maxChar,
|
||||
kwArgs.keyUpCB,
|
||||
kwArgs.enterCB,
|
||||
true, //nomargin
|
||||
kwArgs.tooltip,
|
||||
null, //width
|
||||
kwArgs.focusCB,
|
||||
kwArgs.blurCB);
|
||||
|
||||
o.widgetType = 'TextField';
|
||||
|
||||
// Update instance with constructor arguments
|
||||
bobj.fillIn(o, kwArgs);
|
||||
o.disabled = kwArgs.disabled;
|
||||
o.width = kwArgs.width;
|
||||
|
||||
// Update instance with member functions
|
||||
MochiKit.Base.update(o, bobj.crv.params.TextField);
|
||||
|
||||
if (kwArgs.cleanValue) {
|
||||
o.setValue(kwArgs.cleanValue);
|
||||
}
|
||||
|
||||
return o;
|
||||
};
|
||||
|
||||
bobj.crv.params.TextField = {
|
||||
setForeColor : function(color) {
|
||||
this.foreColor = color;
|
||||
if (this.css)
|
||||
this.css.color = color;
|
||||
},
|
||||
|
||||
setTextItalic : function(isTextItalic) {
|
||||
this.isTextItalic = isTextItalic;
|
||||
if (this.css)
|
||||
this.css.fontStyle = isTextItalic ? 'italic' : '';
|
||||
},
|
||||
|
||||
setTabDisabled : function(dis) {
|
||||
bobj.disableTabbingKey (this.layer, dis);
|
||||
},
|
||||
|
||||
eraseHelpTxt: MochiKit.Base.noop,
|
||||
|
||||
getHTML : function() {
|
||||
var style = {
|
||||
width : bobj.unitValue (this.width)
|
||||
};
|
||||
|
||||
var isIE = MochiKit.Base.isIE ();
|
||||
var className = 'iactTextField';
|
||||
|
||||
var attributes = {
|
||||
type : this.password ? 'password' : 'text',
|
||||
name : this.id,
|
||||
id : this.id,
|
||||
maxLength : this.maxChar,
|
||||
style : style,
|
||||
'class' : className,
|
||||
oncontextmenu : "event.cancelBubble=true;return true",
|
||||
onfocus : "TextFieldWidget_focus(this)",
|
||||
onblur : "TextFieldWidget_blur(this)",
|
||||
onchange : "TextFieldWidget_changeCB(event, this)",
|
||||
onkeydown : "return TextFieldWidget_keyDownCB(event, this);",
|
||||
onkeyup : "return TextFieldWidget_keyUpCB(event, this);",
|
||||
onkeypress : "return TextFieldWidget_keyPressCB(event, this);",
|
||||
ondragstart : "event.cancelBubble=true; return true;",
|
||||
onselectstart : "event.cancelBubble=true; return true;"
|
||||
};
|
||||
|
||||
if (this.disabled) {
|
||||
attributes.disabled = "disabled";
|
||||
}
|
||||
|
||||
if (this.isTextItalic) {
|
||||
style["font-style"] = "italic";
|
||||
}
|
||||
|
||||
style.color = this.foreColor;
|
||||
|
||||
if (!this.editable) {
|
||||
attributes.readonly = "readonly";
|
||||
|
||||
if (this.canOpenAdvDialog) {
|
||||
style.cursor = "pointer";
|
||||
}
|
||||
else {
|
||||
style.cursor = "default";
|
||||
}
|
||||
}
|
||||
|
||||
if (this.tooltip) {
|
||||
attributes.title = this.tooltip.replace(/"/g, """);
|
||||
}
|
||||
|
||||
return bobj.html.INPUT (attributes);
|
||||
},
|
||||
|
||||
/**
|
||||
* Resets textField object. Sets clean value, current value
|
||||
*/
|
||||
reset : function(value) {
|
||||
this.value = value;
|
||||
this.cleanValue = value;
|
||||
this.setValue (value);
|
||||
},
|
||||
|
||||
setValue : function(value) {
|
||||
TextFieldWidget_setValue.call (this, value);
|
||||
},
|
||||
|
||||
setCleanValue : function(value) {
|
||||
this.cleanValue = value;
|
||||
}
|
||||
};
|
||||
|
||||
295
crystalreportviewers13/js/crviewer/ToolPanel.js
Normal file
@@ -0,0 +1,295 @@
|
||||
/* Copyright (c) Business Objects 2006. All rights reserved. */
|
||||
|
||||
bobj.crv.ToolPanelType = { //values must match server's expectations
|
||||
None: 'None',
|
||||
GroupTree : 'GroupTree',
|
||||
ParameterPanel: 'ParameterPanel'
|
||||
};
|
||||
|
||||
bobj.crv.ToolPanelTypeDetails = {
|
||||
None : {
|
||||
title : null,
|
||||
img : null,
|
||||
alt : null
|
||||
},
|
||||
GroupTree : {
|
||||
title : L_bobj_crv_GroupTree,
|
||||
img : { uri: bobj.crv.allInOne.uri, dx: 0, dy: bobj.crv.allInOne.groupTreeToggleDy },
|
||||
alt : L_bobj_crv_GroupTree
|
||||
},
|
||||
ParameterPanel : {
|
||||
title : L_bobj_crv_ParamPanel,
|
||||
img : { uri: bobj.crv.allInOne.uri, dx: 0, dy: bobj.crv.allInOne.paramPanelToggleDy },
|
||||
alt : L_bobj_crv_ParamPanel
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* ToolPanel constructor
|
||||
*
|
||||
* @param kwArgs.id [String] DOM node id
|
||||
* @param kwArgs.width [String] Width
|
||||
* @param kwArgs.height [String] Height
|
||||
*/
|
||||
bobj.crv.newToolPanel = function(kwArgs) {
|
||||
kwArgs = MochiKit.Base.update({
|
||||
id: bobj.uniqueId() + "_toolPanel",
|
||||
width: '300px',
|
||||
height: '100%',
|
||||
initialViewType: bobj.crv.ToolPanelType.None
|
||||
}, kwArgs);
|
||||
|
||||
|
||||
var o = newWidget(kwArgs.id);
|
||||
|
||||
// Update instance with constructor arguments
|
||||
bobj.fillIn(o, kwArgs);
|
||||
|
||||
o.widgetType = 'ToolPanel';
|
||||
|
||||
o._children = [];
|
||||
o._selectedChild = null;
|
||||
o._groupTree = null;
|
||||
o._paramPanel = null;
|
||||
|
||||
// Update instance with member functions
|
||||
o.initOld = o.init;
|
||||
o.resizeOld = o.resize;
|
||||
MochiKit.Base.update(o, bobj.crv.ToolPanel);
|
||||
|
||||
o.needLeftBorder = false;
|
||||
|
||||
return o;
|
||||
};
|
||||
|
||||
bobj.crv.ToolPanel = {
|
||||
hasGroupTree : function() {
|
||||
return this._groupTree != null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds a child widget as a view. If the child has an isSelected attribute
|
||||
* that evaluates as true, it will be the selected (active) view.
|
||||
*
|
||||
* This function must be called before getHTML() is called.
|
||||
*
|
||||
* @param widget [Widget] Child view widget
|
||||
*/
|
||||
addChild : function(widget) {
|
||||
if (!widget) {
|
||||
return;
|
||||
}
|
||||
|
||||
var connect = MochiKit.Signal.connect;
|
||||
var partial = MochiKit.Base.partial;
|
||||
var signal = MochiKit.Signal.signal;
|
||||
var Type = bobj.crv.ToolPanelType;
|
||||
|
||||
if (widget.widgetType == 'GroupTree') {
|
||||
this._groupTree = widget;
|
||||
|
||||
MochiKit.Iter.forEach ( [ 'grpDrilldown', 'grpNodeRetrieveChildren', 'grpNodeCollapse', 'grpNodeExpand' ], function(sigName) {
|
||||
connect (this._groupTree, sigName, partial (signal, this, sigName));
|
||||
}, this);
|
||||
|
||||
if (this.initialViewType == Type.GroupTree) {
|
||||
this._selectedChild = widget;
|
||||
}
|
||||
} else if (widget.widgetType == 'ParameterPanel') {
|
||||
this._paramPanel = widget;
|
||||
connect (this._paramPanel, 'resetParamPanel', partial (signal, this, 'resetParamPanel'));
|
||||
if (this.initialViewType == Type.ParameterPanel) {
|
||||
this._selectedChild = widget;
|
||||
}
|
||||
}
|
||||
|
||||
this._children.push (widget);
|
||||
},
|
||||
|
||||
hasParameterPanel : function () {
|
||||
return this._paramPanel != null;
|
||||
},
|
||||
|
||||
getParameterPanel : function() {
|
||||
return this._paramPanel;
|
||||
},
|
||||
|
||||
/**
|
||||
* This method must be called after viewer has been initialized. Adds new child to toolpanel.
|
||||
*/
|
||||
delayedAddChild : function(widget) {
|
||||
this.addChild (widget);
|
||||
|
||||
var display = widget === this._selectedChild ? '' : 'none';
|
||||
append2 (this.layer, bobj.html.DIV ( {
|
||||
style : {
|
||||
display : display
|
||||
}
|
||||
}, widget.getHTML ()));
|
||||
widget.init ();
|
||||
},
|
||||
|
||||
/*
|
||||
* The caller is responsible for calling doLayout after making a call to setView. calling doLayout is very expensive and want to avoid it if
|
||||
* possible.
|
||||
*/
|
||||
setView : function(panelType) {
|
||||
var prevSelectedChild = this._selectedChild;
|
||||
this.updateSelectedChild (panelType);
|
||||
var nextSelectedChild = this._selectedChild;
|
||||
|
||||
if(prevSelectedChild != nextSelectedChild) {
|
||||
if (prevSelectedChild) {
|
||||
var container = bobj.getContainer (prevSelectedChild);
|
||||
if (container) {
|
||||
container.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
if(nextSelectedChild) {
|
||||
var container = bobj.getContainer (nextSelectedChild);
|
||||
if (container) {
|
||||
bobj.displayElementWithAnimation(container);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
updateSelectedChild : function (panelType) {
|
||||
var Type = bobj.crv.ToolPanelType;
|
||||
switch(panelType) {
|
||||
case Type.GroupTree:
|
||||
this._selectedChild = this._groupTree;
|
||||
break;
|
||||
case Type.ParameterPanel:
|
||||
this._selectedChild = this._paramPanel;
|
||||
break;
|
||||
default:
|
||||
this._selectedChild = null;
|
||||
}
|
||||
},
|
||||
|
||||
getHTML : function() {
|
||||
var h = bobj.html;
|
||||
|
||||
var content = '';
|
||||
var children = this._children;
|
||||
for ( var i = 0, len = children.length; i < len; ++i) {
|
||||
var child = children[i];
|
||||
var display = child === this._selectedChild ? '' : 'none';
|
||||
content += h.DIV ( {
|
||||
style : {
|
||||
display : display
|
||||
}
|
||||
}, child.getHTML ());
|
||||
}
|
||||
|
||||
var isDisplayed = (bobj.crv.ToolPanelType.None !== this.initialViewType);
|
||||
var toolPanelClass = 'toolPanel';
|
||||
if (this.needLeftBorder)
|
||||
toolPanelClass += ' leftBorder';
|
||||
|
||||
|
||||
var layerAtt = {
|
||||
id : this.id,
|
||||
'class' : toolPanelClass,
|
||||
style : {
|
||||
position : 'absolute',
|
||||
margin : '0',
|
||||
width : this.width,
|
||||
height : this.height,
|
||||
overflow : 'hidden',
|
||||
display : isDisplayed ? '' : 'none'
|
||||
}
|
||||
};
|
||||
|
||||
var html = h.DIV (layerAtt, content);
|
||||
|
||||
return html;
|
||||
},
|
||||
|
||||
init : function() {
|
||||
this.initOld ();
|
||||
if (this._groupTree)
|
||||
this._groupTree.init ();
|
||||
|
||||
if (this._paramPanel)
|
||||
this._paramPanel.init ();
|
||||
},
|
||||
|
||||
update : function(update) {
|
||||
if (update && update.cons == "bobj.crv.newToolPanel") {
|
||||
for ( var childVar in update.children) {
|
||||
var child = update.children[childVar];
|
||||
if (child) {
|
||||
switch (child.cons) {
|
||||
case "bobj.crv.newGroupTree":
|
||||
/* if there is a group tree, update it */
|
||||
if (this._groupTree) {
|
||||
this._groupTree.update (child);
|
||||
}
|
||||
/* else create and add one */
|
||||
else {
|
||||
this.delayedAddChild (bobj.crv.createWidget (child));
|
||||
}
|
||||
break;
|
||||
case "bobj.crv.params.newParameterPanel":
|
||||
if (this._paramPanel) {
|
||||
this._paramPanel.update (child);
|
||||
}
|
||||
else {
|
||||
this.delayedAddChild (bobj.crv.createWidget (child));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.initialViewType = update.args.initialViewType;
|
||||
this.setView (this.initialViewType);
|
||||
this.css.width = update.args.width;
|
||||
}
|
||||
},
|
||||
|
||||
getBestFitHeight : function () {
|
||||
var height = 0;
|
||||
if(this._selectedChild != null)
|
||||
height = this._selectedChild.getBestFitHeight();
|
||||
|
||||
return height;
|
||||
},
|
||||
|
||||
hasPercentWidth : function () {
|
||||
return (this.width != null) && (this.width.length > 0) && (this.width.charAt(this.width.length - 1) == '%');
|
||||
},
|
||||
|
||||
getPercentWidth : function () {
|
||||
return parseInt(this.width) / 100;
|
||||
},
|
||||
|
||||
_doLayout : function() {
|
||||
var innerWidth = this.layer.clientWidth;
|
||||
var contentHeight = this.layer.clientHeight;
|
||||
|
||||
if (this._selectedChild) {
|
||||
this._selectedChild.setDisplay (true);
|
||||
this._selectedChild.resize (innerWidth, contentHeight);
|
||||
}
|
||||
},
|
||||
|
||||
resize : function(w, h) {
|
||||
bobj.setOuterSize (this.layer, w, h);
|
||||
this._doLayout ();
|
||||
|
||||
var width = _ie && _isQuirksMode ? this.layer.offsetWidth : this.layer.clientWidth;
|
||||
var height = _ie && _isQuirksMode ? this.layer.offsetWidth : this.layer.clientWidth;
|
||||
MochiKit.Signal.signal (this, 'resizeToolPanel', width, height);
|
||||
|
||||
// do not have a percent width if we have resized the tool panel
|
||||
this.width = width;
|
||||
},
|
||||
|
||||
addLeftBorder : function() {
|
||||
this.needLeftBorder = true;
|
||||
}
|
||||
};
|
||||
1213
crystalreportviewers13/js/crviewer/Toolbar.js
Normal file
862
crystalreportviewers13/js/crviewer/Viewer.js
Normal file
@@ -0,0 +1,862 @@
|
||||
/* Copyright (c) Business Objects 2006. All rights reserved. */
|
||||
|
||||
|
||||
/**
|
||||
* Viewer Constructor
|
||||
*
|
||||
* kwArgs.layoutType [String] Tells the viewer how to size itself. Can be
|
||||
* "client" (fill window), "fitReport", or "fixed"
|
||||
* kwArgs.width [Int] Width in pixels when layoutType=fixed
|
||||
* kwArgs.height [Int] Height in pixels when layoutType=fixed
|
||||
*/
|
||||
bobj.crv.newViewer = function(kwArgs) {
|
||||
kwArgs = MochiKit.Base.update({
|
||||
id: bobj.uniqueId(),
|
||||
isDisplayModalBG : false,
|
||||
isLoadContentOnInit : false,
|
||||
layoutType : bobj.crv.Viewer.LayoutTypes.FIXED,
|
||||
visualStyle : {
|
||||
className : null,
|
||||
backgroundColor : null,
|
||||
borderWidth : null,
|
||||
borderStyle : null,
|
||||
borderColor : null,
|
||||
fontFamily : null,
|
||||
fontWeight : null,
|
||||
textDecoration : null,
|
||||
color : null,
|
||||
width : '800px',
|
||||
height : '600px',
|
||||
fontStyle : null,
|
||||
fontSize : null,
|
||||
top : "0px", /* passed by Java DHTML viewer */
|
||||
left : "0px" /* passed by Java DHTML viewer */
|
||||
}
|
||||
}, kwArgs);
|
||||
var o = newWidget(kwArgs.id);
|
||||
|
||||
bobj.fillIn(o, kwArgs);
|
||||
o.widgetType = 'Viewer';
|
||||
|
||||
o._topToolbar = null;
|
||||
o._reportAlbum = null;
|
||||
o._leftPanel = null;
|
||||
o._separator = null;
|
||||
o._print = null;
|
||||
o._export = null;
|
||||
o._promptDlg = null;
|
||||
o._reportProcessing = null;
|
||||
o._eventListeners = [];
|
||||
o._statusbar = null;
|
||||
o._leftPanelResizeGrabber = newGrabberWidget(
|
||||
o.id + '_leftPanelResizeGrabber',
|
||||
bobj.bindFunctionToObject(bobj.crv.Viewer.onGrabberMove, o),
|
||||
0, // intial left
|
||||
0, // intial top
|
||||
4, // width
|
||||
1, // intial height (has to be pixels so we'll figure it out later)
|
||||
true); // Moves on the horizontal axis
|
||||
|
||||
// Attach member functions
|
||||
o.initOld = o.init;
|
||||
o._boundaryControl = new bobj.crv.BoundaryControl(kwArgs.id + "_bc");
|
||||
o._modalBackground = new bobj.crv.ModalBackground(
|
||||
kwArgs.id + "_mb",
|
||||
bobj.bindFunctionToObject(bobj.crv.Viewer.keepFocus, o));
|
||||
MochiKit.Base.update(o, bobj.crv.Viewer);
|
||||
window[o.id] = o
|
||||
|
||||
return o;
|
||||
};
|
||||
|
||||
bobj.crv.Viewer = {
|
||||
LayoutTypes : {
|
||||
FIXED : 'fixed',
|
||||
CLIENT : 'client',
|
||||
FITREPORT : 'fitreport'
|
||||
},
|
||||
|
||||
PromptingTypes : {
|
||||
HTML : 'html',
|
||||
FLEX : 'flex'
|
||||
},
|
||||
|
||||
onGrabberMove : function(x) {
|
||||
if (this._leftPanel) {
|
||||
this._leftPanel.resize (x, null);
|
||||
this._doLayout ();
|
||||
}
|
||||
},
|
||||
|
||||
keepFocus : function () {
|
||||
var swf = bobj.crv.params.FlexParameterBridge.getSWF(this.id);
|
||||
if (swf)
|
||||
swf.focus();
|
||||
},
|
||||
|
||||
addChild : function(widget) {
|
||||
if (widget.widgetType == 'ReportAlbum') {
|
||||
this._reportAlbum = widget;
|
||||
} else if (widget.widgetType == 'Toolbar') {
|
||||
this._topToolbar = widget;
|
||||
this._separator = bobj.crv.newSeparator ();
|
||||
} else if (widget.widgetType == 'Statusbar') {
|
||||
this._statusbar = widget;
|
||||
} else if (widget.widgetType == 'PrintUI') {
|
||||
this._print = widget;
|
||||
} else if (widget.widgetType == 'ExportUI') {
|
||||
this._export = widget;
|
||||
} else if (widget.widgetType == 'ReportProcessingUI') {
|
||||
this._reportProcessing = widget;
|
||||
} else if (widget.widgetType == 'LeftPanel') {
|
||||
this._leftPanel = widget;
|
||||
}
|
||||
},
|
||||
|
||||
getHTML : function() {
|
||||
var h = bobj.html;
|
||||
|
||||
var layerStyle = {
|
||||
overflow: 'hidden',
|
||||
position: 'relative',
|
||||
left : this.visualStyle.left,
|
||||
top : this.visualStyle.top
|
||||
};
|
||||
|
||||
var html = h.DIV({dir: 'ltr', id:this.id, style:layerStyle, 'class':'dialogzone'},
|
||||
this._topToolbar ? this._topToolbar.getHTML() : '',
|
||||
this._separator ? this._separator.getHTML() : '',
|
||||
this._leftPanel ? this._leftPanel.getHTML() : '',
|
||||
this._reportAlbum ? this._reportAlbum.getHTML() : '',
|
||||
this._leftPanelResizeGrabber ? this._leftPanelResizeGrabber.getHTML() : '',
|
||||
this._statusbar ? this._statusbar.getHTML(): '');
|
||||
|
||||
return html;
|
||||
},
|
||||
|
||||
_onWindowResize : function() {
|
||||
if (this._currWinSize.w != winWidth () || this._currWinSize.h != winHeight ()) {
|
||||
this._doLayout ();
|
||||
this._currWinSize.w = winWidth ();
|
||||
this._currWinSize.h = winHeight ();
|
||||
}
|
||||
},
|
||||
|
||||
init : function() {
|
||||
this.initOld ();
|
||||
this._initSignals ();
|
||||
|
||||
if (this._reportAlbum)
|
||||
this._reportAlbum.init ();
|
||||
|
||||
if (this._topToolbar)
|
||||
this._topToolbar.init ();
|
||||
|
||||
if (this._leftPanel)
|
||||
this._leftPanel.init ();
|
||||
|
||||
if (this._statusbar)
|
||||
this._statusbar.init ();
|
||||
|
||||
if (this._leftPanelResizeGrabber) {
|
||||
this._leftPanelResizeGrabber.init ();
|
||||
|
||||
if (!this._leftPanel || !this._leftPanel.isToolPanelDisplayed ())
|
||||
this._leftPanelResizeGrabber.setDisplay (false);
|
||||
}
|
||||
|
||||
this.setDisplayModalBackground(this.isDisplayModalBG);
|
||||
|
||||
bobj.setVisualStyle (this.layer, this.visualStyle);
|
||||
|
||||
this._currWinSize = {
|
||||
w : winWidth (),
|
||||
h : winHeight ()
|
||||
};
|
||||
var connect = MochiKit.Signal.connect;
|
||||
var signal = MochiKit.Signal.signal;
|
||||
|
||||
if (this.layoutType.toLowerCase () == bobj.crv.Viewer.LayoutTypes.CLIENT) {
|
||||
connect (window, 'onresize', this, '_onWindowResize');
|
||||
}
|
||||
|
||||
if (!this._topToolbar && !this._statusbar && this._reportAlbum && !this._reportAlbum.isDisplayDrilldownTab()) {
|
||||
this.layer.className += ' hideFrame';
|
||||
this._reportAlbum.setHideFrame(true);
|
||||
}
|
||||
|
||||
if (this.layer && _ie && bobj.checkParent (this.layer, "TABLE")) {
|
||||
/*
|
||||
* delays the call to doLayout to ensure all dom elemment's width and
|
||||
* height are set beforehand.
|
||||
*/
|
||||
connect (window, 'onload', this, '_doLayoutOnLoad');
|
||||
this._oldCssVisibility = this.css.visibility;
|
||||
this.css.visibility = "hidden";
|
||||
} else {
|
||||
this._doLayout ();
|
||||
}
|
||||
|
||||
this.scrollToHighlighted ();
|
||||
signal (this, 'initialized', this.isLoadContentOnInit);
|
||||
},
|
||||
|
||||
/**
|
||||
* Connects all the signals during initialization
|
||||
*/
|
||||
_initSignals : function() {
|
||||
var partial = MochiKit.Base.partial;
|
||||
var signal = MochiKit.Signal.signal;
|
||||
var connect = MochiKit.Signal.connect;
|
||||
var fe = MochiKit.Iter.forEach;
|
||||
|
||||
if (this._topToolbar) {
|
||||
fe ( [ 'zoom', 'drillUp', 'firstPage', 'prevPage', 'nextPage', 'lastPage', 'selectPage', 'refresh', 'search', 'export', 'print' ], function(sigName) {
|
||||
connect (this._topToolbar, sigName, partial (signal, this, sigName));
|
||||
}, this);
|
||||
}
|
||||
|
||||
this._initLeftPanelSignals ();
|
||||
|
||||
if (this._reportAlbum) {
|
||||
fe ( [ 'selectView', 'removeView', 'viewChanged' ], function(sigName) {
|
||||
connect (this._reportAlbum, sigName, partial (signal, this, sigName));
|
||||
}, this);
|
||||
}
|
||||
|
||||
if (this._print) {
|
||||
connect (this._print, 'printSubmitted', partial (signal, this, 'printSubmitted'));
|
||||
}
|
||||
|
||||
if (this._export) {
|
||||
connect (this._export, 'exportSubmitted', partial (signal, this, 'exportSubmitted'));
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* DO NOT REMOVE. USED BY WEB ELEMENTS
|
||||
*/
|
||||
getLeftPanel : function () {
|
||||
return this._leftPanel;
|
||||
},
|
||||
|
||||
_initLeftPanelSignals : function () {
|
||||
var partial = MochiKit.Base.partial;
|
||||
var signal = MochiKit.Signal.signal;
|
||||
var connect = MochiKit.Signal.connect;
|
||||
var fe = MochiKit.Iter.forEach;
|
||||
|
||||
if (this._leftPanel) {
|
||||
fe ( [ 'grpDrilldown', 'grpNodeRetrieveChildren', 'grpNodeCollapse', 'grpNodeExpand', 'resetParamPanel', 'resizeToolPanel' ], function(sigName) {
|
||||
connect (this._leftPanel, sigName, partial (signal, this, sigName));
|
||||
}, this);
|
||||
|
||||
connect (this._leftPanel, 'switchPanel', this, '_onSwitchPanel')
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* returns true when main report view is selected in report album
|
||||
*/
|
||||
_isMainReportViewSelected : function() {
|
||||
var currentView = this._reportAlbum.getSelectedView();
|
||||
return currentView && currentView.isMainReport();
|
||||
},
|
||||
|
||||
_doLayoutOnLoad : function() {
|
||||
this.css.visibility = this._oldCssVisibility;
|
||||
this._doLayout();
|
||||
},
|
||||
|
||||
_doLayout : function() {
|
||||
var topToolbarH = this._topToolbar ? this._topToolbar.getHeight() : 0;
|
||||
var topToolbarW = this._topToolbar ? this._topToolbar.getWidth() : 0;
|
||||
var separatorH = this._separator ? this._separator.getHeight() : 0;
|
||||
var statusbarH = this._statusbar ? this._statusbar.getHeight() : 0;
|
||||
var leftPanelW = this._leftPanel ? this._leftPanel.getBestFitWidth() : 0;
|
||||
|
||||
var leftPanelGrabberW = this._leftPanelResizeGrabber && this._leftPanelResizeGrabber.isDisplayed() ?
|
||||
this._leftPanelResizeGrabber.getWidth() : 0;
|
||||
|
||||
var layout = this.layoutType.toLowerCase();
|
||||
|
||||
var toolPanel = this._leftPanel ? this._leftPanel.getToolPanel() : null;
|
||||
var hasPercentWidth = (toolPanel && toolPanel.isDisplayed() && toolPanel.hasPercentWidth());
|
||||
|
||||
if (bobj.crv.Viewer.LayoutTypes.CLIENT == layout) {
|
||||
this.css.width = '100%';
|
||||
this.css.height = '100%';
|
||||
|
||||
if (hasPercentWidth)
|
||||
leftPanelW = Math.max(leftPanelW, (this.getWidth() * toolPanel.getPercentWidth()) - leftPanelGrabberW);
|
||||
}
|
||||
else if (bobj.crv.Viewer.LayoutTypes.FITREPORT == layout) {
|
||||
var viewerWidth = 0;
|
||||
var viewerHeight = 0;
|
||||
|
||||
if (hasPercentWidth)
|
||||
leftPanelW += 200;
|
||||
|
||||
if(this._reportAlbum) {
|
||||
var albumSize = this._reportAlbum.getBestFitSize();
|
||||
viewerWidth = (albumSize.width + leftPanelW + leftPanelGrabberW < topToolbarW) ? topToolbarW : albumSize.width + leftPanelW + leftPanelGrabberW;
|
||||
viewerHeight = (albumSize.height + topToolbarH + separatorH + statusbarH);
|
||||
}
|
||||
else if (this._leftPanel) { /* If DisplayPage = false in webformviewer */
|
||||
viewerWidth = leftPanelW;
|
||||
viewerHeight = (this._leftPanel.getBestFitHeight() + topToolbarH + separatorH + statusbarH); ;
|
||||
}
|
||||
|
||||
this.css.height = viewerHeight + 'px';
|
||||
this.css.width = viewerWidth + 'px';
|
||||
}
|
||||
else { /* fixed layout */
|
||||
this.css.width = this.visualStyle.width;
|
||||
this.css.height = this.visualStyle.height;
|
||||
|
||||
if (hasPercentWidth)
|
||||
leftPanelW = Math.max(leftPanelW, (this.getWidth() * toolPanel.getPercentWidth()) - leftPanelGrabberW);
|
||||
}
|
||||
|
||||
var albumW = this.getWidth() - leftPanelW - leftPanelGrabberW;
|
||||
var albumH = Math.max(0, this.getHeight() - topToolbarH - separatorH - statusbarH);
|
||||
|
||||
if (this._reportAlbum) {
|
||||
this._reportAlbum.resizeOuter(albumW, albumH);
|
||||
this._reportAlbum.move(leftPanelW + leftPanelGrabberW, topToolbarH + separatorH);
|
||||
}
|
||||
|
||||
if(this._leftPanel) {
|
||||
this._leftPanel.resize(leftPanelW, albumH);
|
||||
this._leftPanel.move(0, topToolbarH + separatorH);
|
||||
}
|
||||
|
||||
if(this._leftPanelResizeGrabber && this._leftPanelResizeGrabber.isDisplayed()) {
|
||||
this._leftPanelResizeGrabber.resize(null, albumH);
|
||||
this._leftPanelResizeGrabber.move(leftPanelW, topToolbarH + separatorH)
|
||||
}
|
||||
|
||||
if(this._statusbar) {
|
||||
this._statusbar.doLayout();
|
||||
this._statusbar.move(0, topToolbarH + separatorH + albumH)
|
||||
}
|
||||
|
||||
if (this._print && this._print.layer) {
|
||||
this._print.center();
|
||||
}
|
||||
|
||||
if (this._export && this._export.layer) {
|
||||
this._export.center();
|
||||
}
|
||||
|
||||
if (this._reportProcessing && this._reportProcessing.layer) {
|
||||
this._reportProcessing.center();
|
||||
}
|
||||
|
||||
|
||||
var viewerP = MochiKit.Style.getElementPosition(this.layer);
|
||||
var viewerD = MochiKit.Style.getElementDimensions(this.layer);
|
||||
|
||||
if (this._modalBackground)
|
||||
this._modalBackground.updateBoundary(viewerD.w, viewerD.h, viewerP.x, viewerP.y);
|
||||
|
||||
var bodyD = bobj.getBodyScrollDimension();
|
||||
|
||||
var isViewerCutOff = ((viewerP.x + viewerD.w) >= bodyD.w) || ((viewerP.y + viewerD.h) >= bodyD.h);
|
||||
|
||||
if(isViewerCutOff && (layout != bobj.crv.Viewer.LayoutTypes.CLIENT)) {
|
||||
|
||||
/* BoundaryControl adds a hidden div with the same dimension and position as current viewer to body
|
||||
to fix the problem of IE regarding scrollbar that are hidden when left + viewer's width > body's width
|
||||
*/
|
||||
|
||||
this._boundaryControl.updateBoundary(viewerD.w, viewerD.h, viewerP.x, viewerP.y);
|
||||
}
|
||||
else {
|
||||
this._boundaryControl.updateBoundary(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
var FLEXUI = bobj.crv.params.FlexParameterBridge;
|
||||
var swf = FLEXUI.getSWF(this.id);
|
||||
if(swf) {
|
||||
if (this._promptDlg && this._promptDlg.style.visibility != 'hidden') {
|
||||
if(swf._isMaximized) {
|
||||
FLEXUI.fitScreen(this.id);
|
||||
}
|
||||
else {
|
||||
FLEXUI.resize(this.id, swf.offsetHeight, swf.offsetWidth, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this._adjustWindowScrollBars();
|
||||
},
|
||||
|
||||
_onSwitchPanel : function(panelType) {
|
||||
var Type = bobj.crv.ToolPanelType;
|
||||
|
||||
if (Type.GroupTree == panelType) {
|
||||
MochiKit.Signal.signal (this, 'showGroupTree');
|
||||
} else if (Type.ParameterPanel == panelType) {
|
||||
MochiKit.Signal.signal (this, 'showParamPanel');
|
||||
} else if (Type.None == panelType) {
|
||||
MochiKit.Signal.signal (this, 'hideToolPanel');
|
||||
}
|
||||
this._leftPanelResizeGrabber.setDisplay (!(Type.None == panelType));
|
||||
this._doLayout ();
|
||||
},
|
||||
|
||||
resize : function(w, h) {
|
||||
if (bobj.isNumber (w)) {
|
||||
w = w + 'px';
|
||||
}
|
||||
|
||||
if (bobj.isNumber (h)) {
|
||||
h = h + 'px';
|
||||
}
|
||||
|
||||
this.visualStyle.width = w;
|
||||
this.visualStyle.height = h;
|
||||
this._doLayout ();
|
||||
},
|
||||
|
||||
/**
|
||||
* Set the page number. Updates toolbars with current page and number of pages
|
||||
* info.
|
||||
*
|
||||
* @param curPageNum [String]
|
||||
* @param numPages [String] (eg. "1" or "1+");
|
||||
*/
|
||||
setPageNumber : function(curPageNum, numPages) {
|
||||
if (this._topToolbar) {
|
||||
this._topToolbar.setPageNumber (curPageNum, numPages);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Display the prompt dialog.
|
||||
*
|
||||
* @param html [string] HTML fragment to display inside the dialog's form.
|
||||
*/
|
||||
showPromptDialog : function(html, closeCB) {
|
||||
if (!this._promptDlg) {
|
||||
var promptDialog_ShowCB = MochiKit.Base.bind (this._onShowPromptDialog, this);
|
||||
var promptDialog_HideCB = MochiKit.Base.bind (this._onHidePromptDialog, this);
|
||||
this._promptDlg = bobj.crv.params.newParameterDialog ( {
|
||||
id : this.id + '_promptDlg',
|
||||
showCB : promptDialog_ShowCB,
|
||||
hideCB : promptDialog_HideCB
|
||||
});
|
||||
}
|
||||
|
||||
this._promptDlg.setCloseCB (closeCB);
|
||||
this._promptDlg.setNoCloseButton(!closeCB);
|
||||
|
||||
/* The reason for saving document.onkeypress is that prompt dialog steals the document.onkeypress and never sets it back */
|
||||
this._originalDocumentOnKeyPress = document.onkeypress; /*
|
||||
* Must be set before .updateHtmlAndDisplay(html) as this function call modifies
|
||||
* document.onkeypress;
|
||||
*/
|
||||
this.updatePromptDialog(html);
|
||||
},
|
||||
|
||||
/**
|
||||
* Update the prompt dialog - with CR2010 DCP prompting this allow the dialog to be kept open during dependent prompt submits
|
||||
*
|
||||
* @param html [string] HTML fragment to display inside the dialog's form
|
||||
*/
|
||||
updatePromptDialog : function(html) {
|
||||
html = html || '';
|
||||
|
||||
var callback = function(prompt, prompthtml) {
|
||||
return function() {
|
||||
prompt.updateHtmlAndDisplay (prompthtml);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* AllInOne.js lacks prompting javascript files (to reduce amount of data transmitted) therefore, prompting data must be loaded on demand
|
||||
*/
|
||||
|
||||
bobj.loadJSResourceAndExecCallBack(bobj.crv.config.resources.HTMLPromptingSDK, callback(this._promptDlg, html));
|
||||
|
||||
if (bobj.isParentWindowTestRunner ()) {
|
||||
/* for testing purposes only*/
|
||||
setTimeout (MochiKit.Base.partial (MochiKit.Signal.signal, this, "promptDialogIsVisible"), 5);
|
||||
}
|
||||
},
|
||||
|
||||
showFlexPromptDialog : function(servletURL, closeCB) {
|
||||
var FLEXUI = bobj.crv.params.FlexParameterBridge;
|
||||
var VIEWERFLEX = bobj.crv.params.ViewerFlexParameterAdapter;
|
||||
|
||||
if (!FLEXUI.checkFlashPlayer ()) {
|
||||
var msg = L_bobj_crv_FlashRequired;
|
||||
this.showError (msg.substr (0, msg.indexOf ('{0}')), FLEXUI.getInstallHTML ());
|
||||
return;
|
||||
}
|
||||
|
||||
VIEWERFLEX.setViewerLayoutType (this.id, this.layoutType);
|
||||
|
||||
if (!this._promptDlg) {
|
||||
this._promptDlg = document.createElement ('div');
|
||||
this._promptDlg.id = this.id + '_promptDlg';
|
||||
this._promptDlg.closeCB = closeCB;
|
||||
|
||||
var PROMPT_STYLE = this._promptDlg.style;
|
||||
PROMPT_STYLE.border = '1px';
|
||||
PROMPT_STYLE.borderStyle = 'solid';
|
||||
PROMPT_STYLE.borderColor = '#000000';
|
||||
PROMPT_STYLE.position = 'absolute';
|
||||
PROMPT_STYLE.zIndex = bobj.constants.modalLayerIndex;
|
||||
|
||||
var divID = bobj.uniqueId ();
|
||||
this._promptDlg.innerHTML = "<div id=\"" + divID + "\" name=\"" + divID + "\"></div>";
|
||||
|
||||
// generate hidden buttons to prevent tabbing into the viewer
|
||||
var onfocusCB = bobj.bindFunctionToObject(bobj.crv.Viewer.keepFocus, this);
|
||||
|
||||
var firstLink = MochiKit.DOM.createDOM('BUTTON', {
|
||||
id : this._promptDlg.id + '_firstLink',
|
||||
onfocus : onfocusCB,
|
||||
style : {
|
||||
width : '0px',
|
||||
height : '0px',
|
||||
position : 'absolute',
|
||||
left : '-30px',
|
||||
top : '-30px'
|
||||
}
|
||||
});
|
||||
|
||||
var lastLink = MochiKit.DOM.createDOM('BUTTON', {
|
||||
id : this._promptDlg.id + '_lastLink',
|
||||
onfocus : onfocusCB,
|
||||
style : {
|
||||
width : '0px',
|
||||
height : '0px',
|
||||
position : 'absolute',
|
||||
left : '-30px',
|
||||
top : '-30px'
|
||||
}
|
||||
});
|
||||
|
||||
document.body.appendChild (firstLink);
|
||||
document.body.appendChild (this._promptDlg);
|
||||
document.body.appendChild (lastLink);
|
||||
|
||||
var state = bobj.crv.stateManager.getComponentState (this.id);
|
||||
var sessionID = state.common.reportSourceSessionID;
|
||||
var lang = bobj.crv.getLangCode ();
|
||||
|
||||
FLEXUI.setMasterCallBack (this.id, VIEWERFLEX);
|
||||
FLEXUI.createSWF (this.id, divID, servletURL, true, lang, sessionID);
|
||||
} else {
|
||||
this._promptDlg.closeCB = closeCB;
|
||||
this._promptDlg.style.display = '';
|
||||
FLEXUI.init (this.id);
|
||||
}
|
||||
|
||||
this.setDisplayModalBackground (true);
|
||||
},
|
||||
|
||||
sendPromptingAsyncRequest : function (evArgs){
|
||||
MochiKit.Signal.signal(this, 'crprompt_asyncrequest', evArgs);
|
||||
},
|
||||
setDisplayModalBackground : function (isDisplay) {
|
||||
isDisplay = this.isDisplayModalBG || isDisplay; //viewer.isDisplayModalBG has higher priority
|
||||
if(this._modalBackground)
|
||||
this._modalBackground.show(isDisplay);
|
||||
},
|
||||
|
||||
_onShowPromptDialog : function() {
|
||||
this._adjustWindowScrollBars ();
|
||||
this.setDisplayModalBackground (true);
|
||||
},
|
||||
|
||||
_onHidePromptDialog : function() {
|
||||
this._adjustWindowScrollBars ();
|
||||
document.onkeypress = this._originalDocumentOnKeyPress;
|
||||
this.setDisplayModalBackground (false);
|
||||
},
|
||||
|
||||
isPromptDialogVisible: function () {
|
||||
return this._promptDlg && this._promptDlg.isVisible && this._promptDlg.isVisible ();
|
||||
},
|
||||
|
||||
hidePromptDialog : function() {
|
||||
if (this.isPromptDialogVisible()) {
|
||||
this._promptDlg.show (false);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Hide the flex prompt dialog
|
||||
*/
|
||||
hideFlexPromptDialog : function() {
|
||||
if (this._promptDlg) {
|
||||
if (_ie)
|
||||
{
|
||||
/* IE has an issue where if a user calls back from a swf
|
||||
and closes the containing div then when the div is shown
|
||||
again the swf will lose any external interface calls. To get around
|
||||
this we must set the focus to something other than the swf first
|
||||
before hiding the window. */
|
||||
this._promptDlg.focus();
|
||||
}
|
||||
|
||||
this._promptDlg.style.visibility = 'hidden';
|
||||
this._promptDlg.style.display = 'none';
|
||||
this.setDisplayModalBackground (false);
|
||||
|
||||
if (this._promptDlg.closeCB)
|
||||
this._promptDlg.closeCB();
|
||||
}
|
||||
},
|
||||
|
||||
_adjustWindowScrollBars : function() {
|
||||
if (_ie && this.layoutType == bobj.crv.Viewer.LayoutTypes.CLIENT && this._promptDlg && this._promptDlg.layer && MochiKit.DOM.currentDocument ().body) {
|
||||
var bodyOverFlow, pageOverFlow;
|
||||
var body = MochiKit.DOM.currentDocument ().body;
|
||||
var promptDlgLayer = this._promptDlg.layer;
|
||||
|
||||
if (this.getReportPage () && this.getReportPage ().layer) {
|
||||
var reportPageLayer = this.getReportPage ().layer;
|
||||
}
|
||||
|
||||
if (!window["bodyOverFlow"]) {
|
||||
window["bodyOverFlow"] = MochiKit.DOM.getStyle (body, 'overflow');
|
||||
}
|
||||
|
||||
if (body.offsetHeight < (promptDlgLayer.offsetTop + promptDlgLayer.offsetHeight)) {
|
||||
if (window["bodyOverFlow"] == "hidden") {
|
||||
bodyOverFlow = "scroll";
|
||||
}
|
||||
pageOverFlow = "hidden";
|
||||
} else {
|
||||
bodyOverFlow = window["bodyOverFlow"];
|
||||
pageOverFlow = "auto";
|
||||
}
|
||||
|
||||
body.style.overflow = bodyOverFlow;
|
||||
if (reportPageLayer) {
|
||||
reportPageLayer.style.overflow = pageOverFlow;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Display an error message dialog.
|
||||
*
|
||||
* @param text [String] Short, user-friendly error message
|
||||
* @param details [String] Technical info that's hidden unless the user chooses to see it
|
||||
*/
|
||||
showError : function(text, details) {
|
||||
var dlg = bobj.crv.ErrorDialog.getInstance ();
|
||||
dlg.setText (text, details);
|
||||
dlg.setTitle (L_bobj_crv_Error);
|
||||
dlg.show (true);
|
||||
},
|
||||
|
||||
/**
|
||||
* Update the UI using the given properties
|
||||
*
|
||||
* @param update [Object] Component properties
|
||||
*/
|
||||
update : function(update) {
|
||||
if (!update || update.cons != "bobj.crv.newViewer")
|
||||
return;
|
||||
|
||||
if(update.args)
|
||||
this.isDisplayModalBG = update.args.isDisplayModalBG;
|
||||
|
||||
/*
|
||||
* With CR2010 DCP prompting we want to keep open the prompt dialog until all parameters
|
||||
* are resolved (ADAPT01346079). Unfortunately, as soon as the parameters resolved, server
|
||||
* calls the getPage and returns the page content, so we don't know when to close the dialog.
|
||||
*/
|
||||
this.hidePromptDialog();
|
||||
|
||||
for ( var childNum in update.children) {
|
||||
var child = update.children[childNum];
|
||||
if (child) {
|
||||
switch (child.cons) {
|
||||
case "bobj.crv.newReportAlbum":
|
||||
if (this._reportAlbum) {
|
||||
this._reportAlbum.update (child);
|
||||
}
|
||||
break;
|
||||
case "bobj.crv.newToolbar":
|
||||
if (this._topToolbar) {
|
||||
this._topToolbar.update (child);
|
||||
}
|
||||
break;
|
||||
case "bobj.crv.newStatusbar":
|
||||
if (this._statusbar) {
|
||||
this._statusbar.update (child);
|
||||
}
|
||||
break;
|
||||
case "bobj.crv.newLeftPanel":
|
||||
if (this._leftPanel)
|
||||
this._leftPanel.update (child);
|
||||
else {
|
||||
this._leftPanel = bobj.crv.createWidget(child);
|
||||
if(this.layer) {
|
||||
append(this.layer, this._leftPanel.getHTML())
|
||||
this._initLeftPanelSignals ();
|
||||
this._leftPanel.init();
|
||||
}
|
||||
|
||||
if(this._leftPanel && this._leftPanel.isToolPanelDisplayed())
|
||||
this._leftPanelResizeGrabber.setDisplay(true);
|
||||
}
|
||||
break;
|
||||
case "bobj.crv.newExportUI":
|
||||
if (this._export) {
|
||||
this._export.update (child);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this._doLayout ();
|
||||
this.scrollToHighlighted ();
|
||||
this.setDisplayModalBackground (this.isDisplayModalBG);
|
||||
},
|
||||
|
||||
getToolPanel : function() {
|
||||
if(this._leftPanel)
|
||||
return this._leftPanel.getToolPanel();
|
||||
|
||||
return null;
|
||||
},
|
||||
|
||||
getParameterPanel : function() {
|
||||
var toolPanel = this.getToolPanel ();
|
||||
if (toolPanel)
|
||||
return toolPanel.getParameterPanel ();
|
||||
|
||||
return null;
|
||||
},
|
||||
|
||||
getReportPage : function() {
|
||||
if (this._reportAlbum) {
|
||||
var view = this._reportAlbum.getSelectedView();
|
||||
if (view) {
|
||||
return view.reportPage;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
|
||||
scrollToHighlighted : function() {
|
||||
if(!this._reportAlbum)
|
||||
return;
|
||||
|
||||
var currentView = this._reportAlbum.getSelectedView ();
|
||||
|
||||
if (currentView) {
|
||||
currentView.scrollToHighlighted(this.layoutType.toLowerCase () == bobj.crv.Viewer.LayoutTypes.FITREPORT);
|
||||
}
|
||||
},
|
||||
|
||||
addViewerEventListener : function (e, l) {
|
||||
var ls = this._eventListeners[e];
|
||||
if (!ls) {
|
||||
this._eventListeners[e] = [l];
|
||||
return;
|
||||
}
|
||||
|
||||
ls[ls.length] = l;
|
||||
},
|
||||
|
||||
removeViewerEventListener : function (e, l) {
|
||||
var ls = this._eventListeners[e];
|
||||
if (ls) {
|
||||
for (var i = 0, lsLen = ls.length; i < lsLen; i++) {
|
||||
if (ls[i] == l){
|
||||
ls.splice(i, 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
getEventListeners : function (e) {
|
||||
return this._eventListeners[e];
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
bobj.crv.BoundaryControl = function(id) {
|
||||
this.id = id;
|
||||
};
|
||||
|
||||
bobj.crv.BoundaryControl.prototype = {
|
||||
updateBoundary : function(width,height,left,top) {
|
||||
if(!this.layer) {
|
||||
this._init();
|
||||
}
|
||||
if(this.layer) {
|
||||
this.layer.style.width = width + "px";
|
||||
this.layer.style.height = height + "px";
|
||||
this.layer.style.left = left + "px";
|
||||
this.layer.style.top = top + "px";
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
_getStyle : function () {
|
||||
return {
|
||||
display:'block',
|
||||
visibility:'hidden',
|
||||
position:'absolute'
|
||||
};
|
||||
},
|
||||
|
||||
_getHTML : function () {
|
||||
return bobj.html.DIV({id : this.id, style : this._getStyle()});
|
||||
},
|
||||
|
||||
_init: function() {
|
||||
if(!this.layer){
|
||||
append2(_curDoc.body,this._getHTML ());
|
||||
this.layer = getLayer(this.id);
|
||||
this.layer.onselectstart = function () {return false;};
|
||||
this.layer.onmousedown = eventCancelBubble;
|
||||
if (this.mouseupCB)
|
||||
this.layer.onmouseup = this.mouseupCB;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
bobj.crv.ModalBackground = function (id, mouseupCB) {
|
||||
this.id = id;
|
||||
this.mouseupCB = mouseupCB;
|
||||
};
|
||||
|
||||
bobj.crv.ModalBackground.prototype = new bobj.crv.BoundaryControl();
|
||||
MochiKit.Base.update(bobj.crv.ModalBackground.prototype, {
|
||||
_getStyle : function () {
|
||||
return {
|
||||
'background-color' : '#888888',
|
||||
position : 'absolute',
|
||||
opacity : 0.30,
|
||||
display : 'block',
|
||||
filter : 'alpha(opacity=30);',
|
||||
'z-index' : bobj.constants.modalLayerIndex - 2,
|
||||
visibility : 'hidden'
|
||||
};
|
||||
},
|
||||
|
||||
show : function (show) {
|
||||
if(!this.layer) {
|
||||
this._init();
|
||||
}
|
||||
|
||||
this.layer.style.visibility = show ? "visible" : "hidden";
|
||||
}
|
||||
|
||||
});
|
||||
547
crystalreportviewers13/js/crviewer/ViewerFlexParameterAdapter.js
Normal file
@@ -0,0 +1,547 @@
|
||||
/* Copyright (c) Business Objects 2006. All rights reserved. */
|
||||
|
||||
/*
|
||||
================================================================================
|
||||
ViewerFlexParameterAdapter.js
|
||||
|
||||
Viewer's implementaion for flex prompting UI
|
||||
================================================================================
|
||||
*/
|
||||
|
||||
bobj.crv.params.ViewerFlexParameterAdapter = {
|
||||
_viewerLayoutType : [],
|
||||
_promptData : [],
|
||||
_paramCtrl : [],
|
||||
_iParam : [],
|
||||
_iPromptUnitData : [],
|
||||
_iParamData : [],
|
||||
_moveArea : null,
|
||||
|
||||
///////////////////////////
|
||||
// Member setters
|
||||
//////////////////////////
|
||||
setViewerLayoutType : function(id, l) {
|
||||
this._viewerLayoutType[id] = l;
|
||||
},
|
||||
|
||||
setPromptData : function(id, d, forIParams) {
|
||||
if (!forIParams){
|
||||
/* Full prompt UI data */
|
||||
this._promptData[id] = d;
|
||||
this.clearIParamPromptUnitData(id);
|
||||
}else{
|
||||
/* Interactive prompt UI data */
|
||||
for(var i = 0, l = d.length; i < l; i++) {
|
||||
var unit = d[i];
|
||||
this._addIParamPromptUnitData(id, unit.id, unit.names, unit.data);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
setCurrentIParamInfo : function(id, c, p) {
|
||||
this._paramCtrl[id] = c;
|
||||
this._iParam[id] = p;
|
||||
},
|
||||
|
||||
getShowMinUI : function (id) {
|
||||
return this.hasIParamPromptUnitData(id);
|
||||
},
|
||||
|
||||
getWidth : function (id) {
|
||||
if(this.hasIParamPromptUnitData(id))
|
||||
return 300;
|
||||
else
|
||||
return this.getSWFWidth(id);
|
||||
},
|
||||
|
||||
getHeight : function (id) {
|
||||
if(this.hasIParamPromptUnitData(id))
|
||||
return 315;
|
||||
else
|
||||
return this.getSWFHeight(id);
|
||||
},
|
||||
|
||||
getScreenHeight : function (id) {
|
||||
var lDim = MochiKit.Style.getElementDimensions(getLayer(id));
|
||||
return lDim.h - 2;
|
||||
},
|
||||
|
||||
getScreenWidth : function (id) {
|
||||
var lDim = MochiKit.Style.getElementDimensions(getLayer(id));
|
||||
return lDim.w - 2;
|
||||
},
|
||||
|
||||
/*
|
||||
* Returns the ideal height of the prompting window
|
||||
*/
|
||||
getSWFHeight : function(id) {
|
||||
var lTypes = bobj.crv.Viewer.LayoutTypes;
|
||||
var layout = lTypes.CLIENT;
|
||||
if (this._viewerLayoutType[id]) {
|
||||
layout = this._viewerLayoutType[id];
|
||||
}
|
||||
|
||||
var min = layout === lTypes.FIXED ? 0 : 480;
|
||||
var sH = this.getScreenHeight(id);
|
||||
return Math.max(min, sH - 200);
|
||||
},
|
||||
|
||||
getSWFWidth : function(id) {
|
||||
var sW = this.getScreenWidth(id);
|
||||
return Math.min(600, sW - 20);
|
||||
},
|
||||
|
||||
getAllowFullScreen : function(id)
|
||||
{
|
||||
return !this.hasIParamPromptUnitData(id);
|
||||
},
|
||||
|
||||
hasIParamPromptUnitData : function (id) {
|
||||
return (this._iPromptUnitData[id] != null) && (this._iParamData[id] != null) && (this._iParam[id] != null);
|
||||
},
|
||||
|
||||
_addIParamPromptUnitData : function(id, unitID, names, data) {
|
||||
if (!this.hasIParamPromptUnitData(id)) {
|
||||
this._iPromptUnitData[id] = [];
|
||||
this._iParamData[id] = [];
|
||||
}
|
||||
|
||||
this._iPromptUnitData[id][unitID] = data;
|
||||
for ( var i = 0, len = names.length; i < len; i++) {
|
||||
this._iParamData[id][names[i]] = unitID;
|
||||
}
|
||||
},
|
||||
|
||||
clearIParamPromptUnitData : function (id) {
|
||||
if (!this.hasIParamPromptUnitData(id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
delete this._iPromptUnitData[id];
|
||||
delete this._iParamData[id];
|
||||
delete this._iParam[id];
|
||||
},
|
||||
|
||||
///////////////////////////
|
||||
// Callbacks
|
||||
//////////////////////////
|
||||
|
||||
getPromptData : function (id) {
|
||||
if (this.hasIParamPromptUnitData(id)) {
|
||||
var promptUUID = this._iParamData[id][this._iParam[id].paramName];
|
||||
if (promptUUID) {
|
||||
return this._iPromptUnitData[id][promptUUID];
|
||||
}
|
||||
}
|
||||
|
||||
return this._promptData[id];
|
||||
},
|
||||
|
||||
/**
|
||||
* Flex callback to start moving the dialog
|
||||
*/
|
||||
startDrag : function(id) {
|
||||
var swf = bobj.crv.params.FlexParameterBridge.getSWF(id);
|
||||
if (swf) {
|
||||
if (this._moveArea) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._moveArea = document.createElement('div');
|
||||
this._moveArea.id = bobj.uniqueId();
|
||||
|
||||
MOVE_STYLE = this._moveArea.style;
|
||||
|
||||
var STYLE = swf.style;
|
||||
var P_STYLE = swf.parentNode.style;
|
||||
|
||||
MOVE_STYLE.top = P_STYLE.top;
|
||||
MOVE_STYLE.left = P_STYLE.left;
|
||||
MOVE_STYLE.width = STYLE.width ? STYLE.width : swf.width + 'px';
|
||||
MOVE_STYLE.height = STYLE.height ? STYLE.height : swf.height + 'px';;
|
||||
MOVE_STYLE.border = '1px';
|
||||
MOVE_STYLE.borderStyle = 'solid';
|
||||
MOVE_STYLE.borderColor = '#000000';
|
||||
MOVE_STYLE.backgroundColor = '#FFFFFF';
|
||||
MOVE_STYLE.position = 'absolute';
|
||||
MOVE_STYLE.opacity = 0.50;
|
||||
MOVE_STYLE.filter = 'alpha(opacity=50)';
|
||||
MOVE_STYLE.zIndex = bobj.constants.modalLayerIndex - 1;
|
||||
|
||||
document.body.appendChild(this._moveArea);
|
||||
document.body.style.cursor = 'move';
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Flex callback when finished moving the dialog
|
||||
*/
|
||||
stopDrag : function(id) {
|
||||
if (this._moveArea) {
|
||||
var p = MochiKit.Style.getElementPosition(this._moveArea);
|
||||
this.move(id, p.x, p.y);
|
||||
|
||||
document.body.removeChild(this._moveArea);
|
||||
delete this._moveArea;
|
||||
|
||||
document.body.style.cursor = 'default';
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Flex callback for moving the dialog.
|
||||
* x is the amount to move on the x axis, -:left +:right
|
||||
* y is the amount to move on the y axis, -:up +:down
|
||||
*/
|
||||
drag : function(id, x, y) {
|
||||
var LOG = bobj.crv.logger;
|
||||
LOG.info('doMove Called viewer:' + id + ' x:' + x + ' y:' + y);
|
||||
|
||||
var l = getLayer(id);
|
||||
if (!l) {
|
||||
LOG.error('Shifting SWF could not find the viewer:' + id);
|
||||
return;
|
||||
}
|
||||
|
||||
var m = this._moveArea;
|
||||
if (!m) {
|
||||
LOG.error('Unable to move SWF, no move area available');
|
||||
return;
|
||||
}
|
||||
|
||||
var mX = m.offsetLeft;
|
||||
var mY = m.offsetTop;
|
||||
var mH = m.offsetHeight;
|
||||
var mW = m.offsetWidth;
|
||||
var vX = l.offsetLeft;
|
||||
var vY = l.offsetTop;
|
||||
var vH = l.offsetHeight;
|
||||
var vW = l.offsetWidth;
|
||||
|
||||
var newX = mX + x;
|
||||
var newY = mY + y;
|
||||
|
||||
if (newY < vY) {
|
||||
newY = vY;
|
||||
} else if (newY + mH > vY + vH) {
|
||||
newY = vH - mH;
|
||||
}
|
||||
|
||||
if (newX < vX) {
|
||||
newX = vX;
|
||||
} else if (newX + mW > vX + vW) {
|
||||
newX = vW - mW;
|
||||
}
|
||||
|
||||
m.style.top = newY + 'px';
|
||||
m.style.left = newX + 'px';
|
||||
|
||||
LOG.info('Moved the SWF to x:' + newX + ' y:' + newY);
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Flex callback when finished moving the dialog
|
||||
*/
|
||||
move : function(id, x, y) {
|
||||
var swf = bobj.crv.params.FlexParameterBridge.getSWF(id);
|
||||
if (swf) {
|
||||
var p = new MochiKit.Style.Coordinates(x,y);
|
||||
MochiKit.Style.setElementPosition(swf.parentNode, p);
|
||||
}
|
||||
},
|
||||
|
||||
setParamValues : function(id, valueData) {
|
||||
bobj.crv.logger.info('setting parameter values');
|
||||
if (this.hasIParamPromptUnitData(id)){
|
||||
this._setIParamValues (id, valueData);
|
||||
} else {
|
||||
this._setFullParamValues (id, valueData);
|
||||
this.closeDialog(id);
|
||||
}
|
||||
},
|
||||
|
||||
_setFullParamValues : function (id, valueData) {
|
||||
bobj.event.publish('crprompt_flexparam', id, valueData);
|
||||
},
|
||||
|
||||
_setIParamValues : function (id, valueData) {
|
||||
var param = this._iParam[id];
|
||||
var ctrl = this._paramCtrl[id];
|
||||
var data = this._iParamData[id];
|
||||
var unitData = this._iPromptUnitData[id];
|
||||
|
||||
if (!param || !ctrl || !data || !unitData || valueData.length != 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
var vPromptUnit = valueData[0];
|
||||
var vPrompts = vPromptUnit.prompts;
|
||||
for (var i = 0, len = vPrompts.length; i < len; i++) {
|
||||
var vPrompt = vPrompts[i];
|
||||
|
||||
if (!vPrompt || !vPrompt.name || !vPrompt.values) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ctrl.updateParameter(decodeURI(vPrompt.name), this._convertFlexValues(vPrompt, param.valueDataType));
|
||||
}
|
||||
|
||||
ctrl._updateToolbar();
|
||||
|
||||
this._updatePromptData(id, vPromptUnit, param.valueDataType);
|
||||
|
||||
this.closeDialog(id);
|
||||
},
|
||||
|
||||
_updatePromptData: function (id, newUnitData, type){
|
||||
var newPrompts = newUnitData.prompts;
|
||||
|
||||
var data = this._iPromptUnitData[id][newUnitData.id];
|
||||
var unitData = data.promptUnits[0];
|
||||
var prompts = unitData.prompts;
|
||||
for (var i = 0, pLen = prompts.length; i < pLen; i++) {
|
||||
var prompt = prompts[i];
|
||||
for (var j = 0, npLen = newPrompts.length; j < npLen; j++) {
|
||||
var newPrompt = newPrompts[j];
|
||||
if (prompt.id == newPrompt.id){
|
||||
prompt.values = this._unescapeFlexValues(newPrompt.values, type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_unescapeFlexValues: function (fValues, type){
|
||||
if (type != bobj.crv.params.DataTypes.STRING) {
|
||||
return fValues;
|
||||
}
|
||||
|
||||
for (var i = 0, len = fValues.length; i < len; i++) {
|
||||
this._unescapeFlexValue(fValues[i], type);
|
||||
}
|
||||
|
||||
return fValues;
|
||||
},
|
||||
|
||||
_unescapeFlexValue: function (fValue, type) {
|
||||
if (type != bobj.crv.params.DataTypes.STRING) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((fValue.value !== undefined && fValue.value !== null)){
|
||||
fValue.value = decodeURI(fValue.value);
|
||||
|
||||
if (fValue.labels !== undefined && fValue.labels !== null){
|
||||
for (var i = 0, len = fValue.labels.length; i < len; i++) {
|
||||
fValue.labels[i] = decodeURI(fValue.labels[i]);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// Range
|
||||
if (fValue.start){
|
||||
this._unescapeFlexValue(fValue.start, type);
|
||||
}
|
||||
|
||||
if (fValue.end){
|
||||
this._unescapeFlexValue(fValue.end, type);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_getDescriptionIndex: function (prompt)
|
||||
{
|
||||
var vIndex = prompt.lovValueIndex;
|
||||
var types = prompt.lovFieldTypes;
|
||||
if (vIndex !== undefined && types !== undefined)
|
||||
{
|
||||
for (var i=0, len=types.length; i<len; i++) {
|
||||
if (i != vIndex && types[i] == "s"){
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
},
|
||||
|
||||
_convertFlexValues: function (prompt, type){
|
||||
var dIndex = this._getDescriptionIndex(prompt);
|
||||
var fValues = prompt.values;
|
||||
var jsValues = [];
|
||||
for (var i = 0, len = fValues.length; i < len; i++) {
|
||||
jsValues.push(this._convertFlexValue(fValues[i], type, dIndex));
|
||||
}
|
||||
return jsValues;
|
||||
},
|
||||
|
||||
_convertFlexValue: function (fValue, type, dIndex) {
|
||||
var jsValue = {};
|
||||
if ((fValue.value !== undefined && fValue.value !== null)){
|
||||
// Discrete
|
||||
if (dIndex > -1 && fValue.labels && fValue.labels.length > dIndex){
|
||||
jsValue.desc = decodeURI(fValue.labels[dIndex]);
|
||||
}
|
||||
|
||||
var Type = bobj.crv.params.DataTypes;
|
||||
switch (type) {
|
||||
case Type.DATE:
|
||||
case Type.TIME:
|
||||
case Type.DATE_TIME:
|
||||
jsValue.value = this._convertDateTimeFlexValue(fValue.value, type);
|
||||
break;
|
||||
default:
|
||||
jsValue.value = decodeURI(fValue.value);
|
||||
break;
|
||||
}
|
||||
|
||||
} else {
|
||||
// Range
|
||||
if (fValue.start){
|
||||
jsValue.lowerBoundType = fValue.start.inc == true ? 2 : 1;
|
||||
jsValue.beginValue = this._convertFlexValue(fValue.start, type);
|
||||
} else {
|
||||
jsValue.lowerBoundType = 0;
|
||||
}
|
||||
|
||||
if (fValue.end){
|
||||
jsValue.upperBoundType = fValue.end.inc == true ? 2 : 1;
|
||||
jsValue.endValue = this._convertFlexValue(fValue.end, type);
|
||||
} else {
|
||||
jsValue.upperBoundType = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return jsValue;
|
||||
},
|
||||
|
||||
_convertDateTimeFlexValue : function (fValue, type) {
|
||||
var Type = bobj.crv.params.DataTypes;
|
||||
var dValue = {};
|
||||
var parts = fValue.split(',');
|
||||
switch(type) {
|
||||
case Type.DATE:
|
||||
dValue.y = parseInt(parts[0].substring(5), 10);
|
||||
dValue.m = parseInt(parts[1], 10) - 1;
|
||||
dValue.d = parseInt(parts[2].substring(parts[2].length - 1, 0), 10);
|
||||
break;
|
||||
|
||||
case Type.TIME:
|
||||
dValue.h = parseInt(parts[0].substring(5), 10);
|
||||
dValue.min = parseInt(parts[1], 10);
|
||||
dValue.s = parseInt(parts[2].substring(parts[2].length - 1, 0), 10);
|
||||
dValue.ms = 0;
|
||||
break;
|
||||
|
||||
case Type.DATE_TIME:
|
||||
dValue.y = parseInt(parts[0].substring(9), 10);
|
||||
dValue.m = parseInt(parts[1], 10) - 1;
|
||||
dValue.d = parseInt(parts[2], 10);
|
||||
dValue.h = parseInt(parts[3], 10);
|
||||
dValue.min = parseInt(parts[4]);
|
||||
dValue.s = parseInt(parts[5].substring(parts[5].length - 1, 0), 10);
|
||||
dValue.ms = 0;
|
||||
break;
|
||||
}
|
||||
return dValue;
|
||||
},
|
||||
|
||||
|
||||
logon : function(id, logonData) {
|
||||
bobj.crv.logger.info('logging on');
|
||||
this.closeDialog(id);
|
||||
bobj.event.publish('crprompt_flexlogon', id, logonData);
|
||||
},
|
||||
|
||||
processingCancel : function(id) {
|
||||
var v = getWidgetFromID(id);
|
||||
if (v && v._reportProcessing) {
|
||||
v._reportProcessing.cancelShow();
|
||||
}
|
||||
},
|
||||
|
||||
processingDelayedShow : function(id) {
|
||||
var v = getWidgetFromID(id);
|
||||
if (v && v._reportProcessing) {
|
||||
v._reportProcessing.delayedShow();
|
||||
}
|
||||
},
|
||||
|
||||
logger : function(text) {
|
||||
bobj.crv.logger.info(text);
|
||||
},
|
||||
|
||||
getSWFBaseURL : function() {
|
||||
return bobj.crvUri("../../swf/");
|
||||
},
|
||||
|
||||
getSWFID : function() {
|
||||
return bobj.uniqueId();
|
||||
},
|
||||
|
||||
getZIndex : function() {
|
||||
return bobj.constants.modalLayerIndex;
|
||||
},
|
||||
|
||||
getUseSavedData : function(id) {
|
||||
return this.hasIParamPromptUnitData(id);
|
||||
},
|
||||
|
||||
closeDialog : function(id) {
|
||||
var v = getWidgetFromID(id);
|
||||
if (v) {
|
||||
v.hideFlexPromptDialog();
|
||||
}
|
||||
},
|
||||
|
||||
getUseOKCancelButtons : function(id) {
|
||||
return this.hasIParamPromptUnitData(id);
|
||||
},
|
||||
|
||||
getIsDialog : function(id) {
|
||||
return true;
|
||||
},
|
||||
|
||||
getShouldAutoResize : function(id) {
|
||||
return true;
|
||||
},
|
||||
|
||||
setVisibility : function(id) {
|
||||
var swf = bobj.crv.params.FlexParameterBridge.getSWF(id);
|
||||
if (swf) {
|
||||
var P_STYLE = swf.parentNode.style;
|
||||
|
||||
P_STYLE.position = 'absolute';
|
||||
P_STYLE.visibility = 'visible';
|
||||
P_STYLE.borderStyle = 'none';
|
||||
P_STYLE.opacity = 1;
|
||||
|
||||
if (swf.focus !== undefined) {
|
||||
swf.focus();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
getReportStateInfo : function(id) {
|
||||
var s = bobj.crv.stateManager.getComponentState(id);
|
||||
if (s && s.common && s.common.reqCtx) {
|
||||
return MochiKit.Base.serializeJSON(s.common.reqCtx);
|
||||
}
|
||||
},
|
||||
|
||||
setReportStateInfo : function(id, rsInfo) {
|
||||
var s = bobj.crv.stateManager.getComponentState(id);
|
||||
if (s && s.common && s.common.reqCtx) {
|
||||
s.common.reqCtx = MochiKit.Base.evalJSON(unescape(rsInfo));
|
||||
}
|
||||
},
|
||||
|
||||
sendAsyncRequest : function(id, args) {
|
||||
bobj.event.publish('crprompt_asyncrequest', id, args);
|
||||
},
|
||||
|
||||
readyToShow: function(id) {
|
||||
this.processingCancel(id);
|
||||
}
|
||||
};
|
||||
1116
crystalreportviewers13/js/crviewer/ViewerListener.js
Normal file
65
crystalreportviewers13/js/crviewer/WarningPopup.js
Normal file
@@ -0,0 +1,65 @@
|
||||
if (typeof bobj === 'undefined') {
|
||||
bobj = {};
|
||||
}
|
||||
if (typeof bobj.crv === 'undefined') {
|
||||
bobj.crv = {};
|
||||
}
|
||||
if (typeof bobj.crv.WarningPopup === 'undefined') {
|
||||
bobj.crv.WarningPopup = {};
|
||||
}
|
||||
|
||||
bobj.crv.WarningPopup.getInstance = function() {
|
||||
if (bobj.crv.WarningPopup.__instance === undefined)
|
||||
bobj.crv.WarningPopup.__instance = new bobj.crv.WarningPopup.Class();
|
||||
|
||||
return bobj.crv.WarningPopup.__instance;
|
||||
};
|
||||
|
||||
bobj.crv.WarningPopup.Class = function() {
|
||||
this.layer = null;
|
||||
this.id = bobj.uniqueId();
|
||||
};
|
||||
|
||||
bobj.crv.WarningPopup.Class.prototype = {
|
||||
show : function(text, xPos, yPos) {
|
||||
if (!this.layer) {
|
||||
this.init();
|
||||
}
|
||||
|
||||
this.layer.style.top = yPos + "px";
|
||||
this.layer.style.left = xPos + "px";
|
||||
this.txtLayer.innerHTML = text;
|
||||
this.layer.style.display = "block";
|
||||
},
|
||||
|
||||
hide : function() {
|
||||
if (this.layer)
|
||||
this.layer.style.display = "none";
|
||||
},
|
||||
|
||||
getHTML : function() {
|
||||
return bobj.html.DIV( {
|
||||
'class' : 'WarningPopup',
|
||||
id : this.id
|
||||
}, bobj.html.IMG( {
|
||||
id : this.id + "img",
|
||||
style : {
|
||||
position : 'absolute',
|
||||
left : '10px',
|
||||
top : '-19px'
|
||||
},
|
||||
src : bobj.crvUri('images/WarningPopupTriangle.gif')
|
||||
}), bobj.html.DIV( {
|
||||
id : this.id + "txt",
|
||||
style : {
|
||||
padding : "5px"
|
||||
}
|
||||
}));
|
||||
|
||||
},
|
||||
init : function() {
|
||||
append2(document.body, this.getHTML());
|
||||
this.layer = getLayer(this.id);
|
||||
this.txtLayer = getLayer(this.id + "txt");
|
||||
}
|
||||
};
|
||||
84
crystalreportviewers13/js/crviewer/api.js
Normal file
@@ -0,0 +1,84 @@
|
||||
// Copyright (c) Business Objects 2010. All rights reserved.
|
||||
// CrystalReports DHTML Viewer SDK
|
||||
// Version: Internal (Unsupported)
|
||||
// ###################################################################################
|
||||
// CRViewer object contains utilities that allow interaction with the CrystalReports DHTML viewer.
|
||||
// CRViewer has the following properties and methods defined.
|
||||
// CRViewer.getViewer()
|
||||
// returns an CRViewer.Viewer object that represents the DHTML viewer on the current page. Use this object to interact with the DHTML viewer.
|
||||
// CRViewer.getViewer().addEventListener (event type, listener function)
|
||||
// Registers a listener function with the given event type. The listener function should return true if the event was handled and normal viewer processing should not occur.
|
||||
// CRViewer.getViewer().removeEventListener (event type, listener function)
|
||||
// Removes the listener for the given event type.
|
||||
// CRViewer.Events
|
||||
// returns an Array of event types that can be handled using event listeners
|
||||
// CRViewer.Events.HyperlinkClicked
|
||||
// An event that will be fired when a hyperlink is clicked. Note this event will only occur if the viewer is configured to render hyperlinks using javascript.
|
||||
// Arguments to listeners of these events will be as follows: { url : 'url string', target : 'target for the link'}
|
||||
// ###################################################################################
|
||||
|
||||
if (typeof (CRViewer) == "undefined") {
|
||||
CRViewer = {
|
||||
|
||||
getViewer : function (/* optional */ viewerName) {
|
||||
return this._getViewer(viewerName);
|
||||
},
|
||||
|
||||
Events : {
|
||||
HyperlinkClicked : "hyperlinkClicked"
|
||||
},
|
||||
|
||||
_viewersMap : [],
|
||||
_getViewer : function (viewerName) {
|
||||
var map = this._viewersMap;
|
||||
if (viewerName) {
|
||||
for (var i = 0, len = map.length; i < len; i++) {
|
||||
if (map[i].id == viewerName) {
|
||||
return map[i];
|
||||
}
|
||||
}
|
||||
} else if (map.length > 0) {
|
||||
return map[0];
|
||||
}
|
||||
|
||||
return this._createViewer(viewerName);
|
||||
},
|
||||
|
||||
_getRealViewer : function (viewerName)
|
||||
{
|
||||
if (viewerName) {
|
||||
return getWidgetFromID(viewerName);
|
||||
} else {
|
||||
if (_widgets) {
|
||||
for (var i = 0, len = _widgets.length; i < len; i++) {
|
||||
if (_widgets[i].widgetType == "Viewer") {
|
||||
return _widgets[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_createViewer : function (viewerName)
|
||||
{
|
||||
var realViewer = this._getRealViewer(viewerName);
|
||||
|
||||
if (realViewer && realViewer.widgetType == "Viewer") {
|
||||
var o = {};
|
||||
o.id = realViewer.id;
|
||||
o.realViewer = realViewer;
|
||||
|
||||
o.addEventListener = function (event, listener) {
|
||||
this.realViewer.addViewerEventListener(event, listener);
|
||||
}
|
||||
|
||||
o.removeEventListener = function (event, listener) {
|
||||
this.realViewer.removeViewerEventListener(event, listener);
|
||||
}
|
||||
|
||||
this._viewersMap[this._viewersMap.length] = o;
|
||||
return o;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
34
crystalreportviewers13/js/crviewer/bobjcallback.js
Normal file
@@ -0,0 +1,34 @@
|
||||
function bobj_WebForm_Callback (viewerID, callbackEventArgument, formID) {
|
||||
if (!viewerID || !formID) {
|
||||
return;
|
||||
}
|
||||
|
||||
var frm = document.getElementById(formID); // get the form by using viewerID
|
||||
|
||||
if (!frm) {
|
||||
return;
|
||||
}
|
||||
|
||||
var strArr = [];
|
||||
for (var i = 0, itemCount = frm.elements.length; i < itemCount; i++) {
|
||||
var elem = frm.elements[i];
|
||||
if (elem.name && elem.value) {
|
||||
strArr.push(elem.name);
|
||||
strArr.push('=');
|
||||
strArr.push(encodeURIComponent(elem.value));
|
||||
strArr.push('&');
|
||||
}
|
||||
}
|
||||
|
||||
strArr.push('__BOBJ_CALLBACK_EVENTTARGET=');
|
||||
strArr.push(encodeURIComponent(viewerID));
|
||||
strArr.push('&__BOBJ_CALLBACK_EVENTARGUMENT=');
|
||||
strArr.push(encodeURIComponent(callbackEventArgument));
|
||||
var qryString = strArr.join('');
|
||||
|
||||
var req = MochiKit.Async.getXMLHttpRequest();
|
||||
req.open("POST", frm.action, true);
|
||||
req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||||
req.setRequestHeader('Accept','application/json');
|
||||
return MochiKit.Async.sendXMLHttpRequest(req, qryString);
|
||||
}
|
||||
776
crystalreportviewers13/js/crviewer/common.js
Normal file
@@ -0,0 +1,776 @@
|
||||
/* Copyright (c) Business Objects 2006. All rights reserved. */
|
||||
|
||||
if (typeof bobj == 'undefined') {
|
||||
bobj = {};
|
||||
}
|
||||
|
||||
if (typeof bobj.constants == 'undefined') {
|
||||
bobj.constants = {
|
||||
modalLayerIndex:1000
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @return [String] Returns a different id each time it's called
|
||||
*/
|
||||
bobj.uniqueId = function() {
|
||||
return 'bobjid_' + (++bobj.uniqueId._count);
|
||||
};
|
||||
|
||||
if (typeof bobj.uniqueId._count == 'undefined') {
|
||||
bobj.uniqueId._count = new Date().getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* Like MochiKit.Base.update except that it checks each item in obj against
|
||||
* a test function before adding it to self.
|
||||
*
|
||||
* @param test [Function] function that returns a boolean when passed (self, obj, key)
|
||||
* @param self [Object|null] object to be updated
|
||||
* @param obj [Object] object to copy properties from
|
||||
*/
|
||||
bobj.updateIf = function (test, self, obj/*, ... */) {
|
||||
if (self === null) {
|
||||
self = {};
|
||||
}
|
||||
for (var i = 1, len = arguments.length; i < len; i++) {
|
||||
var o = arguments[i];
|
||||
if (typeof(o) != 'undefined' && o !== null) {
|
||||
for (var k in o) {
|
||||
if (test(self, obj, k)) {
|
||||
self[k] = o[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return self;
|
||||
};
|
||||
|
||||
/**
|
||||
* Copy properties from obj to self if the properties are undefined in self
|
||||
*/
|
||||
bobj.fillIn = function (self, obj) {
|
||||
var test = function(self, obj, k) {
|
||||
return (typeof(self[k]) == 'undefined');
|
||||
}
|
||||
bobj.updateIf(test, self, obj);
|
||||
};
|
||||
|
||||
|
||||
bobj.isObject = function(obj) {
|
||||
return (obj && typeof obj == 'object');
|
||||
};
|
||||
|
||||
bobj.isArray = function(obj) {
|
||||
if(bobj.isObject(obj)) {
|
||||
try {
|
||||
return obj.constructor == Array;
|
||||
}
|
||||
catch(e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
bobj.isString = function(obj) {
|
||||
return (typeof(obj) == 'string');
|
||||
};
|
||||
|
||||
bobj.isNumber = function(obj) {
|
||||
return typeof(obj) == 'number' && isFinite(obj);
|
||||
};
|
||||
|
||||
bobj.isBoolean = function(obj) {
|
||||
return typeof obj == 'boolean';
|
||||
};
|
||||
|
||||
bobj.isFunction = function(obj) {
|
||||
return typeof(obj) == 'function';
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks for the border box model, where css width includes padding and borders.
|
||||
* IE uses this box model when a strict dtd is not specified.
|
||||
*
|
||||
* @return [boolean] Returns true if the border box model is being used
|
||||
*/
|
||||
bobj.isBorderBoxModel = function() {
|
||||
if (typeof bobj.isBorderBoxModel._cachedValue == 'undefined') {
|
||||
/*
|
||||
* TODO: It is unnecessary to create DIV to check border box model. All we need to do is check _ie && quirksMode
|
||||
* I didn't remove it for sake of not breaking different scenarios (requires alot of testing)
|
||||
*/
|
||||
if(document.body) {
|
||||
var box = document.createElement('div');
|
||||
box.style.width = '10px';
|
||||
box.style.padding = '1px';
|
||||
box.style.position = 'absolute';
|
||||
box.style.visibility = 'hidden';
|
||||
|
||||
document.body.appendChild(box);
|
||||
bobj.isBorderBoxModel._cachedValue = (box.offsetWidth == 10);
|
||||
document.body.removeChild(box);
|
||||
}
|
||||
else {
|
||||
return _ie && bobj.isQuirksMode();
|
||||
}
|
||||
}
|
||||
return bobj.isBorderBoxModel._cachedValue;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return [boolean] True if the document is rendering in quirks mode
|
||||
*/
|
||||
bobj.isQuirksMode = function() {
|
||||
return (document.compatMode != 'CSS1Compat');
|
||||
};
|
||||
|
||||
/* Sets the visual style of the specified element
|
||||
*
|
||||
* @param element [DOM node]
|
||||
* @param visualStyle {} object containing visual styles
|
||||
*/
|
||||
bobj.setVisualStyle =function(element,visualStyle) {
|
||||
|
||||
if(element === null || visualStyle === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
var elemStyle = element.style;
|
||||
|
||||
if(visualStyle.className)
|
||||
element.className = visualStyle.className;
|
||||
|
||||
MochiKit.Iter.forEach ( [ "background", "borderWidth", "borderStyle", "borderColor", "fontFamily", "fontStyle", "fontSize",
|
||||
"fontWeight", "textDecoration", "color", "width", "height", "left", "top" ], function(styleName) {
|
||||
if (visualStyle[styleName])
|
||||
elemStyle[styleName] = visualStyle[styleName];
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the outer size of an element, including padding, borders and margins.
|
||||
*
|
||||
* Note: Non-pixel units are ignored
|
||||
*
|
||||
* @param node [DOM node]
|
||||
* @param w [Int - optional] Width in pixels
|
||||
* @param h [Int - optional] Height in pixels
|
||||
* @param excludeMargins [bool - optional] When true, margins are not included
|
||||
* in the box size.
|
||||
*/
|
||||
bobj.setOuterSize = function(node, w, h, excludeMargins) {
|
||||
var origStyle = null;
|
||||
var nodeStyle = node.style;
|
||||
if (nodeStyle.display == 'none') {
|
||||
// Nodes have to be displayed to get their calculated styles.
|
||||
// We display them but make them invisible and absolutely positioned
|
||||
// so they don't affect the layout.
|
||||
origStyle = {
|
||||
visibility: nodeStyle.visibility,
|
||||
position: nodeStyle.position,
|
||||
display: 'none'
|
||||
};
|
||||
|
||||
nodeStyle.visibility = 'hidden';
|
||||
nodeStyle.position = 'absolute';
|
||||
nodeStyle.display = '';
|
||||
}
|
||||
|
||||
function pixels (selector) {
|
||||
var value = MochiKit.DOM.getStyle(node, selector);
|
||||
if (bobj.isString(value) && value.substring(value.length - 2 == 'px')) {
|
||||
return (parseInt(value, 10) || 0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (bobj.isNumber(w)) {
|
||||
if (!bobj.isBorderBoxModel()) {
|
||||
w -= pixels('border-left-width');
|
||||
w -= pixels('border-right-width');
|
||||
w -= pixels('padding-left');
|
||||
w -= pixels('padding-right');
|
||||
|
||||
if(excludeMargins) {
|
||||
w -= pixels('margin-left');
|
||||
w -= pixels('margin-right');
|
||||
}
|
||||
}
|
||||
nodeStyle.width = Math.max(0, w) + 'px';
|
||||
}
|
||||
|
||||
if (bobj.isNumber(h)) {
|
||||
if (!bobj.isBorderBoxModel()) {
|
||||
if(excludeMargins) {
|
||||
h -= pixels('margin-top');
|
||||
h -= pixels('margin-bottom');
|
||||
}
|
||||
h -= pixels('border-top-width');
|
||||
h -= pixels('border-bottom-width');
|
||||
h -= pixels('padding-top');
|
||||
h -= pixels('padding-bottom');
|
||||
}
|
||||
nodeStyle.height = Math.max(0, h) + 'px';
|
||||
}
|
||||
|
||||
if (origStyle) {
|
||||
nodeStyle.display = origStyle.display;
|
||||
nodeStyle.position = origStyle.position;
|
||||
nodeStyle.visibility = origStyle.visibility;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the node that contains a child widget.
|
||||
*
|
||||
* @param child [object] the widget whose parent node to be looked for
|
||||
*/
|
||||
bobj.getContainer = function(child) {
|
||||
if (child && child.layer) {
|
||||
return child.layer.parentNode;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks whether elem has a parent with the tag name equivalent to parentTagName
|
||||
*
|
||||
* @param elem [HTML node] the element whose parent is checked against parentTagName
|
||||
* @param parentTagName [String] Parent's tagName ie) TABLE
|
||||
*
|
||||
*
|
||||
* @return [boolean] True if elem has a parent with tagName equivalent to parentTagName
|
||||
*/
|
||||
bobj.checkParent = function(elem,parentTagName) {
|
||||
var foundParent = false;
|
||||
if(elem && parentTagName) {
|
||||
parentTagName = parentTagName.toUpperCase();
|
||||
var parent = elem.parentNode;
|
||||
|
||||
while(parent) {
|
||||
if(parent.tagName == parentTagName) {
|
||||
foundParent = true;
|
||||
break;
|
||||
}
|
||||
parent = parent.parentNode;
|
||||
}
|
||||
}
|
||||
|
||||
return foundParent;
|
||||
};
|
||||
|
||||
/**
|
||||
* Implements Array.slice for array-like objects. For example, the special
|
||||
* "arguments" variable within function calls is array-like but doesn't have
|
||||
* a slice method.
|
||||
*
|
||||
* @param arrayLike [Object] An array-like object as defined by MochiKit.Base.isArrayLike.
|
||||
* @param begin [Number] Zero-based index at which to begin extraction.
|
||||
* @param end [Number] Zero-based index at which to end extraction.
|
||||
* Extracts up to but not including end.
|
||||
*
|
||||
* @return [Array] A shallow copy of the portion of the array specified or null if invalid argument.
|
||||
*/
|
||||
bobj.slice = function(arrayLike, begin, end) {
|
||||
if (bobj.isArray(arrayLike)) {
|
||||
return arrayLike.slice(begin, end);
|
||||
}
|
||||
else if (MochiKit.Base.isArrayLike(arrayLike)) {
|
||||
var retArray = [];
|
||||
|
||||
var endIdx = arrayLike.length;
|
||||
if (bobj.isNumber(end) && end < endIdx) {
|
||||
endIdx = end;
|
||||
}
|
||||
|
||||
begin = Math.max(begin, 0);
|
||||
|
||||
for (var i = begin; i < endIdx; ++i) {
|
||||
retArray.push(arrayLike[i]);
|
||||
}
|
||||
|
||||
return retArray;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Extract a range of elements from a string or array-like list (non-destructive)
|
||||
*
|
||||
* @param list [String | Array-Like]
|
||||
* @param start [Int] Index of start, inclusive
|
||||
* @param end [Int] Index of end, exclusive
|
||||
*
|
||||
* @return Array of extracted elements or Null
|
||||
*/
|
||||
bobj.extractRange = function(list, start, end) {
|
||||
if (list && bobj.isNumber(start)) {
|
||||
if (!bobj.isNumber(end) || end > list.length) {
|
||||
end = list.length;
|
||||
}
|
||||
|
||||
start = Math.max(0, start);
|
||||
|
||||
if (start < end) {
|
||||
var s1 = 0, e1 = start;
|
||||
var s2 = end, e2 = list.length;
|
||||
|
||||
if (list.substring) {
|
||||
return (list.substring(s1, e1) + list.substring(s2, e2));
|
||||
}
|
||||
else {
|
||||
return bobj.slice(list, s1, e1).concat(bobj.slice(list, s2, e2));
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a value with a unit appended
|
||||
*
|
||||
* @param val [int or string]
|
||||
* @param unit [sring - optional] Defaults to 'px'
|
||||
*
|
||||
* @return [string] Returns val as a string with unit appended if val is a
|
||||
* number. Returns val without modification if val is not a number.
|
||||
*/
|
||||
bobj.unitValue = function(val, unit) {
|
||||
if (bobj.isNumber(val)) {
|
||||
return val + (unit || 'px');
|
||||
}
|
||||
return val;
|
||||
};
|
||||
|
||||
/**
|
||||
* Evaluate an expression in the window (global) scope
|
||||
*
|
||||
* @param expression [String] Expression to evaluate
|
||||
*
|
||||
* @return Returns the result of the evaluation
|
||||
*/
|
||||
bobj.evalInWindow = function(expression) {
|
||||
if (window.execScript) { // Internet Explorer
|
||||
return window.execScript(expression);
|
||||
}
|
||||
else {
|
||||
return MochiKit.Base.bind(eval, window, expression).call();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Loads specified resource and executes callback
|
||||
*/
|
||||
bobj.loadJSResourceAndExecCallBack = function(resource, callback)
|
||||
{
|
||||
if(!resource || !callback)
|
||||
return; // if arguments are not defined, just return
|
||||
|
||||
/*
|
||||
* If bobj.crv.config.useCompressedScripts is true, then the resource is already loaded and we can skip loading
|
||||
*/
|
||||
if(!resource.isLoaded) {
|
||||
var onLoad = function(resource, callback, response) {
|
||||
resource.isLoaded = true;
|
||||
bobj.evalInWindow(response.responseText);
|
||||
callback.apply();
|
||||
};
|
||||
|
||||
var req = MochiKit.Async.getXMLHttpRequest();
|
||||
req.open("GET", bobj.crvUri(resource.path), true);
|
||||
req.setRequestHeader('Accept','application/x-javascript,application/javascript, text/javascript');
|
||||
var deferred = MochiKit.Async.sendXMLHttpRequest(req);
|
||||
deferred.addCallback(MochiKit.Base.bind(onLoad, this, resource, callback));
|
||||
}
|
||||
else {
|
||||
setTimeout(function(){callback.apply()},0);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Remove whitespace from the left end of a string.
|
||||
*
|
||||
* @param str [String]
|
||||
*
|
||||
* @return [String] Returns a string with no leading whitespace
|
||||
*/
|
||||
bobj.trimLeft = function(str) {
|
||||
str = str || '';
|
||||
return str.replace(/^\s+/g, '');
|
||||
};
|
||||
|
||||
/**
|
||||
* Remove whitespace from the right end of a string.
|
||||
*
|
||||
* @param str [String]
|
||||
*
|
||||
* @return [String] Returns a string with no trailing whitespace
|
||||
*/
|
||||
bobj.trimRight = function(str) {
|
||||
str = str || '';
|
||||
return str.replace(/\s+$/g, '');
|
||||
};
|
||||
|
||||
/**
|
||||
* Remove whitespace from both ends of a string.
|
||||
*
|
||||
* @param str [String]
|
||||
*
|
||||
* @return [String] Returns a string with no leading or trailing whitespace
|
||||
*/
|
||||
bobj.trim = function(str) {
|
||||
return bobj.trimLeft(bobj.trimRight(str));
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if the two inputs (and their contents) are equal.
|
||||
*
|
||||
* @param obj1 [Any]
|
||||
* @param obj2 [Any]
|
||||
*
|
||||
* @return [boolean] Returns true if the two inputs are equal.
|
||||
*/
|
||||
bobj.equals = function (obj1, obj2) {
|
||||
if (typeof(obj1) != typeof(obj2)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (bobj.isObject(obj1)) {
|
||||
var same = true;
|
||||
for (var prop in obj1) {
|
||||
same = same && bobj.equals(obj1[prop], obj2[prop]);
|
||||
}
|
||||
return same;
|
||||
}
|
||||
else {
|
||||
return obj1 == obj2;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a stylesheet link and adds it to document body
|
||||
* @param1 href [String] location of css file
|
||||
*
|
||||
*/
|
||||
bobj.includeLink = function(href) {
|
||||
var head = document.getElementsByTagName("head")[0];
|
||||
var body = document.body;
|
||||
|
||||
var link = document.createElement("link");
|
||||
link.setAttribute("rel","stylesheet");
|
||||
link.setAttribute("type","text/css");
|
||||
link.setAttribute("href",href);
|
||||
|
||||
if(head) {
|
||||
head.appendChild(link);
|
||||
}
|
||||
else if(body) {
|
||||
body.appendChild(link);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* @param hrefArray Array of url of css files
|
||||
* @param callback function that gets executed once all css files are loaded
|
||||
*/
|
||||
bobj.includeCSSLinksAndExecuteCallback = function (hrefArray, callback) {
|
||||
if(hrefArray == null || hrefArray.length < 1) {
|
||||
callback.apply();
|
||||
return;
|
||||
}
|
||||
|
||||
var cb = function () {
|
||||
var me = arguments.callee;
|
||||
var callback = me.callback;
|
||||
me.hrefCount--;
|
||||
if(me.hrefCount == 0)
|
||||
callback.apply();
|
||||
}
|
||||
|
||||
cb.hrefCount = hrefArray.length;
|
||||
cb.callback = callback;
|
||||
|
||||
for(var i = 0, len = hrefArray.length; i < len; i++) {
|
||||
bobj.includeCSSLinkAndExecuteCallback(hrefArray[i], cb);
|
||||
}
|
||||
};
|
||||
|
||||
bobj.includeCSSLinkAndExecuteCallback = function(href, callback) {
|
||||
var cssLinkId = encodeURIComponent(href);
|
||||
|
||||
/*if a css file with same href is already added, execute cb and continue */
|
||||
if(getLayer(cssLinkId)) {
|
||||
callback.apply();
|
||||
return;
|
||||
}
|
||||
|
||||
/*if css file successfully loads, add css text and call callback*/
|
||||
var onLoad = function(callback, linkId, response) {
|
||||
bobj.addStyleSheet(response.responseText, linkId);
|
||||
callback.apply();
|
||||
};
|
||||
|
||||
/*if css file fails to load, continue with callback */
|
||||
var onError = function(callback) {
|
||||
callback.apply();
|
||||
};
|
||||
|
||||
var req = MochiKit.Async.getXMLHttpRequest();
|
||||
req.open("GET", href, true);
|
||||
req.setRequestHeader('Accept','text/css');
|
||||
var deferred = MochiKit.Async.sendXMLHttpRequest(req);
|
||||
var cb = MochiKit.Base.bind(onLoad, this, callback, cssLinkId)
|
||||
var eb = MochiKit.Base.bind(onError, this, callback)
|
||||
deferred.addCallbacks(cb, eb);
|
||||
};
|
||||
|
||||
bobj.addStyleSheet = function(stylesheet,id) {
|
||||
var style = document.createElement('style');
|
||||
style.setAttribute("type", "text/css");
|
||||
|
||||
if(id) {
|
||||
style.setAttribute("id", id);
|
||||
}
|
||||
|
||||
if (style.styleSheet) {
|
||||
style.styleSheet.cssText = stylesheet;
|
||||
}
|
||||
else {
|
||||
style.appendChild(document.createTextNode(stylesheet));
|
||||
}
|
||||
|
||||
var head = document.getElementsByTagName('head');
|
||||
var body = document.getElementsByTagName('body');
|
||||
|
||||
if(head && head[0]) {
|
||||
head[0].appendChild(style);
|
||||
}
|
||||
else if(body && body[0]) {
|
||||
body[0].appendChild(style);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
bobj.removeAllChildElements = function(elem) {
|
||||
if(elem) {
|
||||
while(elem.lastChild) {
|
||||
elem.removeChild(elem.lastChild);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
bobj.getValueHashCode = function(valueType, value) {
|
||||
var Types = bobj.crv.params.DataTypes;
|
||||
switch(valueType) {
|
||||
case Types.BOOLEAN :
|
||||
case Types.CURRENCY:
|
||||
case Types.NUMBER:
|
||||
case Types.STRING:
|
||||
return '' + value;
|
||||
case Types.TIME:
|
||||
return '' + value.h + ',' + value.min + ',' + value.s + ',' + value.ms;
|
||||
case Types.DATE:
|
||||
return '' + value.y + ',' + value.m + ',' + value.d;
|
||||
case Types.DATE_TIME:
|
||||
return '' + value.y + ',' +value.m + ',' + value.d + ',' + value.h + ',' + value.min + ',' + value.s + ',' + value.ms;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks if there's a DOM element whose ID attribute matches the given string. If not, continue to search for a DOM element
|
||||
* whose Name attribute matches the given string.
|
||||
*
|
||||
* @param idOrName [string] The ID or Name of the element to search for.
|
||||
* @return [DOM element] Returns a DOM element, or null.
|
||||
*/
|
||||
bobj.getElementByIdOrName = function (idOrName) {
|
||||
if (!idOrName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var elem = document.getElementById(idOrName);
|
||||
if (elem) {
|
||||
return elem;
|
||||
}
|
||||
|
||||
var elems = document.getElementsByName(idOrName);
|
||||
if (elems && elems.length > 0) {
|
||||
return elems[0];
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
/*
|
||||
* Returns a rectangle that can be used for css clip property
|
||||
* @param top, right, bottom, left [Int]
|
||||
* @return [String] returns rect(top,right,bottom,left) in pixel unit
|
||||
*/
|
||||
bobj.getRect = function(top, right, bottom, left) {
|
||||
return "rect(" + top + "px, "+ right + "px," + bottom + "px," + left + "px)";
|
||||
}
|
||||
|
||||
bobj.getBodyScrollDimension = function() {
|
||||
var w = 0;
|
||||
var h = 0;
|
||||
var bodyTags = document.getElementsByTagName("Body");
|
||||
if(bodyTags && bodyTags[0]) {
|
||||
w = bodyTags[0].scrollWidth;
|
||||
h = bodyTags[0].scrollHeight;
|
||||
}
|
||||
|
||||
return {w : w, h : h};
|
||||
}
|
||||
/**
|
||||
* Disables tabbing on element specified
|
||||
* @param layer, The layer that will be modified
|
||||
* @param dis [boolean], true would disable tabbing on element
|
||||
*/
|
||||
bobj.disableTabbingKey = function(layer, dis) {
|
||||
if(layer) {
|
||||
//Setting tabIndex value to (-1) would prevent tabbing to the DOM layer
|
||||
layer.tabIndex = dis ? -1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bobj.getStringWidth = function(string, fontFamily, fontSize) {
|
||||
if(document.body) {
|
||||
var span = document.createElement('span');
|
||||
span.appendChild(document.createTextNode(string));
|
||||
span.style.position = 'absolute';
|
||||
span.style.visibility = 'hidden';
|
||||
|
||||
if(fontFamily)
|
||||
span.style.fontFamily = fontFamily;
|
||||
|
||||
if(fontSize)
|
||||
span.style.fontSize = fontSize;
|
||||
|
||||
document.body.appendChild(span);
|
||||
var width = span.offsetWidth;
|
||||
document.body.removeChild(span);
|
||||
return width;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bobj.deleteWidget = function(widget) {
|
||||
if(widget && widget.widx) {
|
||||
if(widget.layer) {
|
||||
|
||||
//Helps GC reclaim memory. Essential to IE memory leak
|
||||
widget.layer.click = null;
|
||||
widget.layer.onmouseup = null;
|
||||
widget.layer.onmousedown = null;
|
||||
widget.layer.onmouseover = null;
|
||||
widget.layer.onmousemove = null;
|
||||
widget.layer.onmouseout = null;
|
||||
widget.layer.onchange = null;
|
||||
widget.layer.onfocus = null;
|
||||
widget.layer.onkeydown = null;
|
||||
widget.layer.onkeyup = null;
|
||||
widget.layer.onkeypress = null;
|
||||
|
||||
var parent = widget.layer.parentNode;
|
||||
if(parent) {
|
||||
parent.removeChild(widget.layer); //removing child from parent
|
||||
}
|
||||
delete widget.layer;
|
||||
}
|
||||
|
||||
delete widget.css;
|
||||
delete _widgets[widget.widx]; // cleans DHTML_Lib collection of widgets
|
||||
_widgets[widget.widx] = null; /* for debugging purpose only */
|
||||
|
||||
delete widget;
|
||||
}
|
||||
};
|
||||
|
||||
bobj.cloneArray = function(array) {
|
||||
return array.slice();
|
||||
};
|
||||
|
||||
/**
|
||||
* returns a function that would execute obj.func with obj as the context
|
||||
* Similar to MochiKit.Base.bind, but this is a lot faster
|
||||
*/
|
||||
bobj.bindFunctionToObject = function(func, obj) {
|
||||
return function () {
|
||||
return func.apply(obj, arguments);
|
||||
};
|
||||
};
|
||||
/**
|
||||
* Object.superClass will be populated with all functions defined in superClass
|
||||
*/
|
||||
bobj.extendClass = function(object, ObjectClassDefinition, superClass) {
|
||||
MochiKit.Base.update(object, ObjectClassDefinition);
|
||||
|
||||
object.superClass = {};
|
||||
for ( var funcName in superClass) {
|
||||
object.superClass[funcName] = bobj.bindFunctionToObject(superClass[funcName], object);;
|
||||
}
|
||||
};
|
||||
|
||||
bobj.displayElementWithAnimation = function (element) {
|
||||
if(element != null) {
|
||||
MochiKit.DOM.setOpacity(element, 0); //to reserve the element's space
|
||||
MochiKit.Style.setDisplayForElement("block", element);
|
||||
new MochiKit.Visual.appear(element, {duration: 0.5});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns dimension of element when it is invisible.DOM.offsetHeight should be used when
|
||||
* element is visible to avoid execution cost of this method
|
||||
*/
|
||||
bobj.getHiddenElementDimensions = function (element) {
|
||||
var size = { w : 0, h : 0};
|
||||
if(element) {
|
||||
var body = document.body;
|
||||
var clonedNode = element.cloneNode(true); //clone and append the node to body as
|
||||
var nodeStyle = clonedNode.style;
|
||||
nodeStyle.display = "";
|
||||
nodeStyle.visibility = "hidden";
|
||||
nodeStyle.width = "";
|
||||
nodeStyle.height = "";
|
||||
nodeStyle.position = "absolute";
|
||||
nodeStyle.left = "-1000px";
|
||||
nodeStyle.top = "-1000px";
|
||||
body.appendChild(clonedNode);
|
||||
size = { w : clonedNode.offsetWidth, h : clonedNode.offsetHeight};
|
||||
body.removeChild(clonedNode);
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for PDF reader that has the ability to process JavaScript.
|
||||
* Currently, it checks for Adobe Acrobat Reader version >= 7 on IE and Version >= 8 on other browsers.
|
||||
*/
|
||||
bobj.hasPDFReaderWithJSFunctionality = function() {
|
||||
if (navigator.plugins) {
|
||||
var plugins = navigator.plugins;
|
||||
for (var i=0, len=plugins.length; i < len; i++) {
|
||||
if (plugins[i].description.indexOf('Adobe PDF Plug-In') != -1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
var pdfReader = new ActiveXObject('AcroPDF.PDF.1');
|
||||
if (pdfReader) {
|
||||
return true;
|
||||
}
|
||||
} catch (e) {}
|
||||
|
||||
return false;
|
||||
};
|
||||
536
crystalreportviewers13/js/crviewer/crv.js
Normal file
@@ -0,0 +1,536 @@
|
||||
/* Copyright (c) Business Objects 2006. All rights reserved. */
|
||||
|
||||
if (typeof(bobj) == 'undefined') {
|
||||
bobj = {};
|
||||
}
|
||||
|
||||
if (typeof(bobj.crv) == 'undefined') {
|
||||
bobj.crv = {};
|
||||
|
||||
// Constants used in the viewer
|
||||
bobj.crv.ActxPrintControl_CLSID = 'B7DA1CA9-1EF8-4831-868A-A767093EA685';
|
||||
bobj.crv.ActxPrintControl_Version = '13,0,30,3805';
|
||||
|
||||
// Configuration for ALL viewers in a page
|
||||
// TODO The dhtmllib doesn't currently suport widgets from different locales
|
||||
// on the same page. We will need that support for the viewer.
|
||||
bobj.crv.config = {
|
||||
isDebug : false,
|
||||
scriptUri: null, // The uri for the viewer script dir (that holds crv.js)
|
||||
skin: "skin_standard",
|
||||
needFallback: true,
|
||||
lang: "en",
|
||||
useCompressedScripts: true,
|
||||
useAsync : true,
|
||||
indicatorOnly: false,
|
||||
resources : {
|
||||
'HTMLPromptingSDK' : {isLoaded: false, path : '../../promptengine-compressed.js'},
|
||||
'ParameterControllerAndDeps' : {isLoaded: false, path: '../../parameterUIController-compressed.js'}
|
||||
},
|
||||
logging: { enabled: false, id: 0}
|
||||
};
|
||||
|
||||
bobj.crv.logger = {
|
||||
info: function(){ /* Do Nothing */}
|
||||
};
|
||||
|
||||
// Udate configuration with properties from crv_config, if it exists
|
||||
if (typeof(crv_config) == 'object') {
|
||||
for (var i in crv_config) {
|
||||
bobj.crv.config[i] = crv_config[i];
|
||||
}
|
||||
}
|
||||
|
||||
// If the uri for the bobj.crv script dir wasn't set, try to figure it out
|
||||
if (!bobj.crv.config.scriptUri) {
|
||||
var scripts = document.getElementsByTagName("script");
|
||||
var reCrvJs = /(.*)crv\.js$/i;
|
||||
|
||||
for(var i = 0; i < scripts.length; i++) {
|
||||
var src = scripts[i].getAttribute("src");
|
||||
if(!src) { continue; }
|
||||
|
||||
var matches = src.match(reCrvJs);
|
||||
|
||||
if(matches && matches.length) {
|
||||
bobj.crv.config.scriptUri = matches[1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!bobj.crv.config.scriptUri ) {
|
||||
bobj.crv.config.scriptUri = '';
|
||||
if (bobj.crv.config.isDebug) {
|
||||
throw "bobj.crv.config.scriptUri is undefined";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a URI into its constitutents as defined in RFC2396
|
||||
*
|
||||
* @param uri [String] Uri to parse
|
||||
*
|
||||
* @return Returns object has string values for the uri's components
|
||||
*/
|
||||
bobj.parseUri = function(uri) {
|
||||
var regExp = "^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?$";
|
||||
var result = uri.match(new RegExp(regExp));
|
||||
return {
|
||||
scheme : result[2],
|
||||
authority : result[4],
|
||||
path : result[5],
|
||||
query : result[7],
|
||||
fragment : result[9]
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
bobj.crvUri = function(uri) {
|
||||
return bobj.crv.config.scriptUri + uri;
|
||||
};
|
||||
|
||||
/**
|
||||
* A helper method for evaluating whether parent window is JSUnit test runner
|
||||
*/
|
||||
bobj.isParentWindowTestRunner = function() {
|
||||
try {
|
||||
var tempTop = top || window;
|
||||
while(tempTop.top && tempTop.top != tempTop) {
|
||||
tempTop = tempTop.top;
|
||||
}
|
||||
|
||||
return tempTop.jsUnitTestSuite !== undefined;
|
||||
}
|
||||
|
||||
catch(err){}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
bobj.skinUri = function(uri) {
|
||||
return bobj.crvUri("../dhtmllib/images/") + bobj.crv.config.skin + "/" + uri;
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a widget using json
|
||||
* eg.
|
||||
* createWidget({
|
||||
* cons: bobj.crv.myWidget,
|
||||
* args: {foo: 'bar'},
|
||||
* children: [ {cons: ...}, ...]
|
||||
* });
|
||||
*
|
||||
* @param json [Object] Object representing the widget
|
||||
* @return Returns the widget or null if creation failed
|
||||
*/
|
||||
bobj.crv.createWidget = function(json) {
|
||||
if (!bobj.isObject(json)){
|
||||
return null;
|
||||
}
|
||||
|
||||
var constructor = json.cons;
|
||||
if (bobj.isString(constructor)) {
|
||||
try {
|
||||
constructor = eval(constructor);
|
||||
}
|
||||
catch (err) {
|
||||
if (bobj.crv.config.isDebug) {
|
||||
throw "bobj.crv.createWidget: invalid constructor";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!bobj.isFunction(constructor)) {
|
||||
if (bobj.crv.config.isDebug) {
|
||||
throw "bobj.crv.createWidget: invalid constructor";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
var widget = constructor(json.args);
|
||||
|
||||
if (bobj.isArray(json.children)) {
|
||||
if (widget.delayedBatchAdd) {
|
||||
widget.delayedBatchAdd(json.children);
|
||||
}
|
||||
else if (widget.addChild){
|
||||
for (var i = 0, len = json.children.length; i < len; ++i) {
|
||||
var child = bobj.crv.createWidget(json.children[i]);
|
||||
widget.addChild(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return widget;
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a widget using bobj.crv.createWidget and write it to the document.
|
||||
* If optional element is given, the innerHTML is written instead and scripts
|
||||
* are executed.
|
||||
*
|
||||
* @param json [Object] Object representing the widget
|
||||
* @return Returns the widget or null if creation failed
|
||||
*/
|
||||
bobj.crv.writeWidget = function(json, element) {
|
||||
|
||||
var widget = bobj.crv.createWidget(json);
|
||||
if (widget) {
|
||||
if(element){
|
||||
var html = widget.getHTML();
|
||||
var ext = bobj.html.extractHtml(html);
|
||||
var links = ext.links;
|
||||
element.innerHTML = html;
|
||||
for(var iLinks = 0, linksLen = links.length; iLinks < linksLen; ++iLinks){
|
||||
bobj.includeLink(links[iLinks]);
|
||||
}
|
||||
|
||||
var scripts = ext.scripts;
|
||||
for (var iScripts = 0, scriptsLen = scripts.length; iScripts < scriptsLen; ++iScripts) {
|
||||
var script = scripts[iScripts];
|
||||
if (!script) {continue;}
|
||||
|
||||
if (script.text) {
|
||||
try {
|
||||
bobj.evalInWindow(script.text);
|
||||
}
|
||||
catch(err) {}
|
||||
}
|
||||
}
|
||||
|
||||
var styleText = "";
|
||||
for (var i = 0, len = ext.styles.length; i < len ; i++) {
|
||||
styleText += ext.styles[i].text + '\n';
|
||||
}
|
||||
|
||||
if(styleText.length > 0) {
|
||||
bobj.addStyleSheet(styleText);
|
||||
}
|
||||
}
|
||||
else {
|
||||
widget.write();
|
||||
}
|
||||
}
|
||||
return widget;
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize a widget.
|
||||
*
|
||||
* @param widx [Int] Widget index
|
||||
* @param initElt [DOM Node, opt] The element that called the init event
|
||||
*/
|
||||
bobj.crv._initWidget = function(widx, initElt) {
|
||||
try {
|
||||
var widget = _widgets[widx];
|
||||
widget.init();
|
||||
|
||||
if (initElt) {
|
||||
MochiKit.DOM.removeElement(initElt);
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
if (bobj.crv.config.isDebug) {
|
||||
var msg = "bobj.crv._initWidget: Couldn't initialize widget: ";
|
||||
msg += 'widx=' + widx;
|
||||
msg += ', type=';
|
||||
if (!_widgets[widx]) {
|
||||
msg += 'null';
|
||||
}
|
||||
else if (bobj.isString(_widgets[widx].widgetType)) {
|
||||
msg += _widgets[widx].widgetType;
|
||||
}
|
||||
else
|
||||
{
|
||||
msg += 'unknown';
|
||||
}
|
||||
msg += ' because: ' + err;
|
||||
throw msg;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates an hidden image tag that initializes a widget using its onload
|
||||
* event. The tag should be appended to the html of the widget.
|
||||
*
|
||||
* Note: doesn't work in Opera 9, but we don't support that yet
|
||||
*
|
||||
* TODO nested widgets fail in Firefox because parent's init method has to
|
||||
* be called after child's init method and the timing of the img onload
|
||||
* events looks to be unpredictable. onerror might be more predictable if
|
||||
* no src is specified... is it supported in Safari?
|
||||
*
|
||||
* @param widx [Int] Widget index
|
||||
*
|
||||
* @return Returns html that initializes the widget with index == widx
|
||||
|
||||
bobj.crv.getInitHTML = function(widx) {
|
||||
return bobj.html.IMG({
|
||||
style: {display:'none'},
|
||||
//onload: 'bobj.crv._initWidget(' + widx + ', this);',
|
||||
onload: "alert('loading " + widx + "')",
|
||||
src: bobj.crvUri("../dhtmllib/images/transp.gif")
|
||||
});
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Returns HTML that auto-intializes a widget.
|
||||
*/
|
||||
bobj.crv.getInitHTML = function(widx) {
|
||||
var scriptId = 'bobj_crv_getInitHTML_' + widx;
|
||||
return '<script id="' + scriptId + '" language="javascript">' +
|
||||
'bobj.crv._initWidget(' + widx + ',"' + scriptId + '");' +
|
||||
'</script>';
|
||||
};
|
||||
|
||||
bobj.crv._preloadProcessingIndicatorImages = function() {
|
||||
var relativeImgPath = bobj.crvUri("../dhtmllib/images/" + bobj.crv.config.skin + "/");
|
||||
var images = [];
|
||||
var imgNames = [
|
||||
"wait01.gif",
|
||||
"dialogtitle.gif",
|
||||
"dialogelements.gif",
|
||||
"../transp.gif"];
|
||||
|
||||
for(var i = 0, len = imgNames.length; i < len; i++){
|
||||
images[i] = new Image();
|
||||
images[i].src = relativeImgPath + imgNames[i];
|
||||
}
|
||||
};
|
||||
|
||||
bobj.crv._loadJavaScript = function(scriptFile) {
|
||||
if (scriptFile) {
|
||||
document.write('<script language="javascript" src="'
|
||||
+ bobj.crvUri(scriptFile)
|
||||
+'"></script>');
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Include the viewer's scripts in the document.
|
||||
*/
|
||||
bobj.crv._includeAll = function() {
|
||||
|
||||
bobj.crv._includeLocaleStrings();
|
||||
|
||||
if (bobj.crv.config.useCompressedScripts) {
|
||||
if (bobj.crv.config.indicatorOnly) {
|
||||
bobj.crv._loadJavaScript('../../processindicator.js');
|
||||
}
|
||||
else {
|
||||
bobj.crv._loadJavaScript('../../allInOne.js');
|
||||
if(!bobj.crv.config.useAsync) {
|
||||
for(var name in bobj.crv.config.resources) {
|
||||
var resource = bobj.crv.config.resources[name];
|
||||
resource.isLoaded = true;
|
||||
bobj.crv._loadJavaScript(resource.path);
|
||||
}
|
||||
}
|
||||
if (bobj.crv.config.logging.enabled) {
|
||||
bobj.crv._loadJavaScript('../log4javascript/log4javascript.js');
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
else {
|
||||
// list of script uris relative to crv.js
|
||||
var scripts = [];
|
||||
if (bobj.crv.config.indicatorOnly) {
|
||||
scripts = [
|
||||
'../MochiKit/Base.js',
|
||||
'../dhtmllib/dom.js',
|
||||
'initDhtmlLib.js',
|
||||
'../dhtmllib/dialog.js',
|
||||
'../dhtmllib/waitdialog.js',
|
||||
'common.js',
|
||||
'Dialogs.js'
|
||||
];
|
||||
}
|
||||
else {
|
||||
scripts = [
|
||||
'../MochiKit/Base.js',
|
||||
'../MochiKit/Async.js',
|
||||
'../MochiKit/DOM.js',
|
||||
'../MochiKit/Style.js',
|
||||
'../MochiKit/Signal.js',
|
||||
'../MochiKit/New.js',
|
||||
'../MochiKit/Color.js',
|
||||
'../MochiKit/Iter.js',
|
||||
'../MochiKit/Visual.js',
|
||||
'../log4javascript/log4javascript_uncompressed.js',
|
||||
'../external/date.js',
|
||||
'../dhtmllib/dom.js',
|
||||
'initDhtmlLib.js',
|
||||
'../dhtmllib/palette.js',
|
||||
'../dhtmllib/menu.js',
|
||||
'../dhtmllib/psheet.js',
|
||||
'../dhtmllib/treeview.js',
|
||||
'../dhtmllib/dialog.js',
|
||||
'../dhtmllib/waitdialog.js',
|
||||
'../../prompting/js/promptengine_prompts2.js',
|
||||
'../../prompting/js/promptengine_calendar2.js',
|
||||
'../swfobject/swfobject.js',
|
||||
'common.js',
|
||||
'encoding.js',
|
||||
'html.js',
|
||||
'ImageSprites.js',
|
||||
'Toolbar.js',
|
||||
'Statusbar.js',
|
||||
'PanelNavigator.js',
|
||||
'PanelNavigatorItem.js',
|
||||
'PanelHeader.js',
|
||||
'LeftPanel.js',
|
||||
'GroupTreeNode.js',
|
||||
'GroupTree.js',
|
||||
'GroupTreeListener.js',
|
||||
'ToolPanel.js',
|
||||
'ReportPage.js',
|
||||
'ReportView.js',
|
||||
'ButtonList.js',
|
||||
'ReportAlbum.js',
|
||||
'Separator.js',
|
||||
'Viewer.js',
|
||||
'ViewerListener.js',
|
||||
'StateManager.js',
|
||||
'IOAdapters.js',
|
||||
'ArgumentNormalizer.js',
|
||||
'event.js',
|
||||
'PromptPage.js',
|
||||
'Dialogs.js',
|
||||
'StackedTab.js',
|
||||
'StackedPanel.js',
|
||||
'Parameter.js',
|
||||
'ParameterController.js',
|
||||
'Colors.js',
|
||||
'TextField.js',
|
||||
'TextCombo.js',
|
||||
'RangeField.js',
|
||||
'ParameterValueRow.js',
|
||||
'ParameterInfoRow.js',
|
||||
'OptionalParameterValueRow.js',
|
||||
'ParameterUI.js',
|
||||
'OptionalParameterUI.js',
|
||||
'ParameterDialog.js',
|
||||
'ParameterPanelToolbar.js',
|
||||
'ParameterPanel.js',
|
||||
'bobjcallback.js',
|
||||
'Calendar.js',
|
||||
'WarningPopup.js',
|
||||
'../FlexParameterBridge.js',
|
||||
'ViewerFlexParameterAdapter.js',
|
||||
'SignalDisposer.js'
|
||||
];
|
||||
}
|
||||
|
||||
if(bobj.isParentWindowTestRunner()) {
|
||||
scripts.push('../jsunit/tests/crViewerTestSuite.js');
|
||||
}
|
||||
|
||||
for (var i = 0, len = scripts.length; i < len; i++) {
|
||||
document.write('<script language="javascript" src="'
|
||||
+ bobj.crvUri(scripts[i])
|
||||
+'"></script>');
|
||||
}
|
||||
|
||||
for(var i in bobj.crv.config.resources){
|
||||
//all Resources are automatically loaded at initialization when useCompressedScripts is false (in debug mode)
|
||||
bobj.crv.config.resources[i].isLoaded = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
bobj.crv.getLangCode = function () {
|
||||
var splitChar = '_'; // default to java's locale split character
|
||||
if (bobj.crv.config.lang.indexOf ('-') > 0) {
|
||||
splitChar = '-'; // must be .Net's locale split
|
||||
}
|
||||
var lang = bobj.crv.config.lang.split(splitChar);
|
||||
|
||||
// TODO (Julian): Java server side now handles the chinese variants due to language pack fix
|
||||
// We'll do the same for WebForm and then the following code can be removed.
|
||||
// For Chinese locales "zh" we only support "TW" & "CN"
|
||||
// zh_HK / zh_MO / zh_MY, are all mapped to zh_TW, everything else is zh_CN
|
||||
if(lang[0].toLowerCase() == "zh") {
|
||||
if(lang.length > 1 ) {
|
||||
var region = lang[1].toUpperCase();
|
||||
if(region == "TW" || region == "HK" || region == "MO" || region == "MY") {
|
||||
lang[1] = "TW";
|
||||
} else {
|
||||
lang[1] = "CN";
|
||||
}
|
||||
} else {
|
||||
lang[1] = "CN";
|
||||
}
|
||||
}
|
||||
|
||||
// .NET webform viewers don't support variants from server side - until we fix this chop-off variant code for all other than "zh"
|
||||
if (lang.length > 1 && (!bobj.crv.config.needFallback || lang[0].toLowerCase() == "zh")) {
|
||||
|
||||
lang = lang[0] + "_" + lang[1];
|
||||
}
|
||||
else {
|
||||
lang = lang[0];
|
||||
}
|
||||
|
||||
return lang;
|
||||
};
|
||||
|
||||
bobj.crv._includeLocaleStrings = function() {
|
||||
var lang = bobj.crv.getLangCode ();
|
||||
|
||||
if (bobj.crv.config.needFallback) {
|
||||
bobj.crv._loadJavaScript('../../allStrings_en.js');
|
||||
if (lang == 'en') return; // DO NOT load 'en' strings below again!
|
||||
}
|
||||
|
||||
bobj.crv._loadJavaScript('../../allStrings_' + lang + '.js');
|
||||
};
|
||||
|
||||
|
||||
if (typeof MochiKit == 'undefined') {
|
||||
MochiKit = {};
|
||||
}
|
||||
if (typeof MochiKit.__export__ == 'undefined') {
|
||||
MochiKit.__export__ = false; // don't export symbols into the global namespace
|
||||
}
|
||||
|
||||
if (!bobj.crv.config.useAsync) bobj.crv._preloadProcessingIndicatorImages();
|
||||
bobj.crv._includeAll();
|
||||
|
||||
bobj.crv.initLog = function(logLevel, handlerUri) {
|
||||
bobj.crv.logger = log4javascript.getLogger();
|
||||
log4javascript.setEnabled(bobj.crv.config.logging.enabled);
|
||||
|
||||
if (bobj.crv.config.logging.enabled) {
|
||||
bobj.crv.logger.setLevel(logLevel);
|
||||
var uri = handlerUri + '?ServletTask=Log';
|
||||
var ajaxAppender = new log4javascript.AjaxAppender(uri);
|
||||
bobj.crv.logger.addAppender(ajaxAppender);
|
||||
|
||||
var oldLogFunc = bobj.crv.logger.log;
|
||||
bobj.crv.logger.log = function(level, message, exception) {
|
||||
oldLogFunc(level, bobj.crv.config.logging.id + ' ' + message, exception);
|
||||
};
|
||||
|
||||
bobj.crv.logger.info('Logging Initialized');
|
||||
}
|
||||
};
|
||||
|
||||
bobj.crv.invokeActionAdapter = function (args) {
|
||||
var n = "invokeAction";
|
||||
var f = window[n];
|
||||
if (!f && window.parent){
|
||||
f = window.parent[n];
|
||||
}
|
||||
|
||||
if (f){
|
||||
f(args.url, args.actionId, args.objectId, args.containerId, args.actionType, null);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
if(typeof(Sys)!=='undefined' && typeof(Sys.Application)!== 'undefined' && typeof(Sys.Application.notifyScriptLoaded)!== 'undefined') {
|
||||
Sys.Application.notifyScriptLoaded();
|
||||
}
|
||||
6
crystalreportviewers13/js/crviewer/dom.js
Normal file
@@ -0,0 +1,6 @@
|
||||
/* Copyright (c) Business Objects 2006. All rights reserved. */
|
||||
|
||||
if (typeof(bobj.dom) == 'undefined') {
|
||||
bobj.dom = {};
|
||||
}
|
||||
|
||||
72
crystalreportviewers13/js/crviewer/encoding.js
Normal file
@@ -0,0 +1,72 @@
|
||||
/* Copyright (c) Business Objects 2006. All rights reserved. */
|
||||
|
||||
if (typeof bobj == 'undefined') {
|
||||
bobj = {};
|
||||
}
|
||||
|
||||
bobj.encodeUTF8 = function(string) {
|
||||
var arr = [];
|
||||
var strLen = string.length;
|
||||
for(var i = 0; i < strLen; i++) {
|
||||
var c = string.charCodeAt(i);
|
||||
if(c < 0x80) {
|
||||
arr.push(c);
|
||||
}
|
||||
else if(c < 0x0800) {
|
||||
arr.push((c >> 6) | 0xc0);
|
||||
arr.push(c & 0x3f | 0x80);
|
||||
}
|
||||
else if(c < 0xd800 || c >= 0xe000) {
|
||||
arr.push((c >> 12) | 0xe0);
|
||||
arr.push((c >> 6) & 0x3f | 0x80);
|
||||
arr.push(c & 0x3f | 0x80);
|
||||
}
|
||||
else if(c < 0xdc00) {
|
||||
var c2 = string.charCodeAt(i + 1);
|
||||
if(isNaN(c2) || c2 < 0xdc00 || c2 >= 0xe000) {
|
||||
arr.push(0xef, 0xbf, 0xbd);
|
||||
continue;
|
||||
}
|
||||
i++;
|
||||
val = ((c & 0x3ff) << 10) | (c2 & 0x3ff);
|
||||
val += 0x10000;
|
||||
arr.push((val >> 18) | 0xf0);
|
||||
arr.push((val >> 12) & 0x3f | 0x80);
|
||||
arr.push((val >> 6) & 0x3f | 0x80);
|
||||
arr.push(val & 0x3f | 0x80);
|
||||
}
|
||||
else {
|
||||
arr.push(0xef, 0xbf, 0xbd);
|
||||
}
|
||||
}
|
||||
return arr;
|
||||
};
|
||||
|
||||
bobj.encodeBASE64 = function(byteArray) {
|
||||
var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
||||
var arr = [];
|
||||
var c1, c2, c3, e1, e2, e3, e4;
|
||||
var i = 0, arrLen = byteArray.length;
|
||||
|
||||
while(i < arrLen) {
|
||||
c1 = byteArray[i++];
|
||||
c2 = byteArray[i++];
|
||||
c3 = byteArray[i++];
|
||||
|
||||
e1 = c1 >> 2;
|
||||
e2 = ((c1 & 3) << 4) | (c2 >> 4);
|
||||
e3 = ((c2 & 15) << 2) | (c3 >> 6);
|
||||
e4 = c3 & 63;
|
||||
|
||||
if (isNaN(c2)) {
|
||||
e3 = e4 = 64;
|
||||
} else if(isNaN(c3)) {
|
||||
e4 = 64;
|
||||
}
|
||||
arr.push(keyStr.charAt(e1));
|
||||
arr.push(keyStr.charAt(e2));
|
||||
arr.push(keyStr.charAt(e3));
|
||||
arr.push(keyStr.charAt(e4));
|
||||
}
|
||||
return arr.join('');
|
||||
};
|
||||
136
crystalreportviewers13/js/crviewer/event.js
Normal file
@@ -0,0 +1,136 @@
|
||||
/**
|
||||
* Publish/Subscribe event system for anonymous message passing
|
||||
*
|
||||
*/
|
||||
|
||||
if (typeof bobj == 'undefined') {
|
||||
bobj = {};
|
||||
}
|
||||
|
||||
if (typeof bobj.event == 'undefined') {
|
||||
bobj.event = {};
|
||||
bobj.event._topicSubscriptions = {};
|
||||
bobj.event._globalSubscriptions = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Publish an event for subscribers to receive
|
||||
*
|
||||
* @param topic [String] The event topic
|
||||
* @param arguments Unnamed args will be passed to subscribers
|
||||
*/
|
||||
bobj.event.publish = function(topic) {
|
||||
var args = bobj.slice(arguments, 1);
|
||||
|
||||
var topicSubs = bobj.event._topicSubscriptions[topic];
|
||||
if (topicSubs) {
|
||||
for (var i = 0; i < topicSubs.length; ++i) {
|
||||
topicSubs[i]._notify.apply(null, args);
|
||||
}
|
||||
}
|
||||
|
||||
var globalSubs = bobj.event._globalSubscriptions;
|
||||
for (var j = 0; j < globalSubs.length; ++j) {
|
||||
globalSubs[j]._notify.apply(null, args);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Subscribe to a topic
|
||||
*
|
||||
* @param topic [String] The event topic
|
||||
* @param callback [Function] Function to be call with topic's arguments
|
||||
* @param target [Object] Object to notify (requires methName)
|
||||
* @param methName [String] Name of method to call when target is notified
|
||||
*
|
||||
* Arguments may be passed in any of the following combinations:
|
||||
* (topic, target, methName)
|
||||
* (topic, callback)
|
||||
* (target, methName)
|
||||
* (callback)
|
||||
*
|
||||
* When a topic is not specified, the subscriber receives all topics
|
||||
*
|
||||
* @return Subscription object that can be used to unsubscribe
|
||||
*/
|
||||
bobj.event.subscribe = function() {
|
||||
var nmlr = bobj.event.subscribe._normalizer;
|
||||
if (!nmlr) {
|
||||
nmlr = bobj.event.subscribe._normalizer = new bobj.ArgumentNormalizer();
|
||||
|
||||
// If 3 args: (topic, target, methName)
|
||||
nmlr.addRule('topic', 'target', 'methName');
|
||||
|
||||
// If 2 args and first is a string: (topic, callback)
|
||||
nmlr.addRule([bobj.isString, 'topic'], 'callback');
|
||||
|
||||
// If 2 args: (target, methName)
|
||||
nmlr.addRule('target', 'methName');
|
||||
|
||||
// If 1 arg: (callback)
|
||||
nmlr.addRule('callback');
|
||||
}
|
||||
|
||||
return bobj.event.kwSubscribe(nmlr.normalizeArray(arguments));
|
||||
};
|
||||
|
||||
/**
|
||||
* Subscribe to a topic using keyword arguments
|
||||
*
|
||||
* @param kwArgs.topic [String] The event topic
|
||||
* @param kwArgs.callback [Function] Function to be call with topic's arguments
|
||||
* @param kwArgs.target [Object] Object to notify (requires methName)
|
||||
* @param kwArgs.methName [String] Name of method to call when target is notified
|
||||
*
|
||||
* @see bobj.event.subscribe
|
||||
*
|
||||
* @return Subscription object that can be used to unsubscribe
|
||||
*/
|
||||
bobj.event.kwSubscribe = function(kwArgs) {
|
||||
var bind = MochiKit.Base.bind;
|
||||
var subscription = {};
|
||||
|
||||
if (kwArgs.callback) {
|
||||
subscription._notify = kwArgs.callback;
|
||||
}
|
||||
else {
|
||||
subscription._notify = bind(kwArgs.target[kwArgs.methName], kwArgs.target);
|
||||
}
|
||||
|
||||
if (kwArgs.topic) {
|
||||
subscription.topic = kwArgs.topic;
|
||||
|
||||
var subs = bobj.event._topicSubscriptions;
|
||||
if (!subs[kwArgs.topic]) {
|
||||
subs[kwArgs.topic] = [];
|
||||
}
|
||||
subs[kwArgs.topic].push(subscription);
|
||||
}
|
||||
else {
|
||||
bobj.event._globalSubscriptions.push(subscription);
|
||||
}
|
||||
|
||||
return subscription;
|
||||
};
|
||||
|
||||
/**
|
||||
* Unsubscribe from a topic
|
||||
*
|
||||
* @param subscription [Subscription] The object returned by subscribe
|
||||
*/
|
||||
bobj.event.unsubscribe = function(subscription) {
|
||||
var subsList = bobj.event._globalSubscriptions;
|
||||
|
||||
if (subscription.topic) {
|
||||
subsList = bobj.event._topicSubscriptions[subscription.topic];
|
||||
}
|
||||
|
||||
if (subsList) {
|
||||
var idx = MochiKit.Base.findIdentical(subsList, subscription);
|
||||
if (idx != -1) {
|
||||
subsList.splice(idx, 1); // remove the subscription
|
||||
delete subscription._notify; // prevent leaks
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
219
crystalreportviewers13/js/crviewer/html.js
Normal file
@@ -0,0 +1,219 @@
|
||||
/* Copyright (c) Business Objects 2006. All rights reserved. */
|
||||
|
||||
if (typeof(bobj.html) == 'undefined') {
|
||||
bobj.html = {};
|
||||
}
|
||||
|
||||
bobj.html.openTag = function(tag, atts) {
|
||||
var html = '<' + tag;
|
||||
|
||||
for (var i in atts) {
|
||||
|
||||
html += ' ' + i + '="';
|
||||
|
||||
var value = atts[i];
|
||||
|
||||
if (bobj.isArray(value)) {
|
||||
value = value.join(' ');
|
||||
}
|
||||
else if (bobj.isObject(value)) {
|
||||
// create a string of the form "foo:bar;baz:garply"
|
||||
var stringValue = ""
|
||||
for (var k in value) {
|
||||
stringValue += k + ':' + value[k] + ';';
|
||||
}
|
||||
value = stringValue;
|
||||
}
|
||||
|
||||
html += value + '"';
|
||||
}
|
||||
|
||||
return html + '>'
|
||||
};
|
||||
|
||||
bobj.html.closeTag = function(tag) {
|
||||
return '</' + tag + '>';
|
||||
};
|
||||
|
||||
bobj.html.createHtml = function(tag, atts, innerHtml /*, innerHtml...*/) {
|
||||
var html = bobj.html.openTag(tag, atts);
|
||||
|
||||
for (var i = 2; i < arguments.length; ++i) {
|
||||
html += arguments[i];
|
||||
}
|
||||
|
||||
html += bobj.html.closeTag(tag);
|
||||
return html;
|
||||
};
|
||||
|
||||
bobj.html.TABLE = MochiKit.Base.partial(bobj.html.createHtml, 'table');
|
||||
bobj.html.UL = MochiKit.Base.partial(bobj.html.createHtml, "ul");
|
||||
bobj.html.OL = MochiKit.Base.partial(bobj.html.createHtml, "ol");
|
||||
bobj.html.LI = MochiKit.Base.partial(bobj.html.createHtml, "li");
|
||||
bobj.html.TD = MochiKit.Base.partial(bobj.html.createHtml, "td");
|
||||
bobj.html.TR = MochiKit.Base.partial(bobj.html.createHtml, "tr");
|
||||
bobj.html.TBODY = MochiKit.Base.partial(bobj.html.createHtml, "tbody");
|
||||
bobj.html.THEAD = MochiKit.Base.partial(bobj.html.createHtml, "thead");
|
||||
bobj.html.TFOOT = MochiKit.Base.partial(bobj.html.createHtml, "tfoot");
|
||||
bobj.html.TABLE = MochiKit.Base.partial(bobj.html.createHtml, "table");
|
||||
bobj.html.TH = MochiKit.Base.partial(bobj.html.createHtml, "th");
|
||||
bobj.html.INPUT = MochiKit.Base.partial(bobj.html.createHtml, "input");
|
||||
bobj.html.SPAN = MochiKit.Base.partial(bobj.html.createHtml, "span");
|
||||
bobj.html.A = MochiKit.Base.partial(bobj.html.createHtml, "a");
|
||||
bobj.html.DIV = MochiKit.Base.partial(bobj.html.createHtml, "div");
|
||||
bobj.html.IMG = MochiKit.Base.partial(bobj.html.createHtml, "img");
|
||||
bobj.html.BUTTON = MochiKit.Base.partial(bobj.html.createHtml, "button");
|
||||
bobj.html.TT = MochiKit.Base.partial(bobj.html.createHtml, "tt");
|
||||
bobj.html.PRE = MochiKit.Base.partial(bobj.html.createHtml, "pre");
|
||||
bobj.html.H1 = MochiKit.Base.partial(bobj.html.createHtml, "h1");
|
||||
bobj.html.H2 = MochiKit.Base.partial(bobj.html.createHtml, "h2");
|
||||
bobj.html.H3 = MochiKit.Base.partial(bobj.html.createHtml, "h3");
|
||||
bobj.html.BR = MochiKit.Base.partial(bobj.html.createHtml, "br");
|
||||
bobj.html.HR = MochiKit.Base.partial(bobj.html.createHtml, "hr");
|
||||
bobj.html.LABEL = MochiKit.Base.partial(bobj.html.createHtml, "label");
|
||||
bobj.html.TEXTAREA = MochiKit.Base.partial(bobj.html.createHtml, "textarea");
|
||||
bobj.html.FORM = MochiKit.Base.partial(bobj.html.createHtml, "form");
|
||||
bobj.html.P = MochiKit.Base.partial(bobj.html.createHtml, "p");
|
||||
bobj.html.SELECT = MochiKit.Base.partial(bobj.html.createHtml, "select");
|
||||
bobj.html.OPTION = MochiKit.Base.partial(bobj.html.createHtml, "option");
|
||||
bobj.html.OPTGROUP = MochiKit.Base.partial(bobj.html.createHtml, "optgroup");
|
||||
bobj.html.LEGEND = MochiKit.Base.partial(bobj.html.createHtml, "legend");
|
||||
bobj.html.FIELDSET = MochiKit.Base.partial(bobj.html.createHtml, "fieldset");
|
||||
bobj.html.STRONG = MochiKit.Base.partial(bobj.html.createHtml, "strong");
|
||||
bobj.html.CANVAS = MochiKit.Base.partial(bobj.html.createHtml, "canvas");
|
||||
bobj.html.IFRAME = MochiKit.Base.partial(bobj.html.createHtml, "iframe");
|
||||
bobj.html.SCRIPT = MochiKit.Base.partial(bobj.html.createHtml, "script");
|
||||
|
||||
|
||||
/**
|
||||
* Extract scripts from an html fragment.
|
||||
*
|
||||
* @param html [String] html fragment
|
||||
*
|
||||
* @return [Object] Returns an object with a list of scripts and html without
|
||||
* scripts
|
||||
* i.e. {scripts: [{src:[String], text:[String]},...], html:[String]}
|
||||
*/
|
||||
bobj.html.extractScripts = function(html) {
|
||||
// Match script tags with or without closing tags
|
||||
// 1 - Attributes of tag that doesn't have closing tag (e.g. <script/>)
|
||||
// 2 - Attributes of tag that has closing tag
|
||||
// 3 - Script text
|
||||
// 1 2 3
|
||||
var regexpScript = /(?:<script([^>]*)\/>|<script([^>]*)>([\s\S]*?)<\/script>)/i;
|
||||
|
||||
// Match src attributes
|
||||
// 1 - URI
|
||||
// 1
|
||||
var regexpSrc = /src=\"([^\"]*)\"/i;
|
||||
|
||||
var scripts = [];
|
||||
var match = null;
|
||||
|
||||
while(match = regexpScript.exec(html)) {
|
||||
var script = {src: null, text: null};
|
||||
|
||||
var attributes = match[1] || match[2];
|
||||
if (attributes = regexpSrc.exec(attributes)) {
|
||||
script.src = attributes[1];
|
||||
}
|
||||
|
||||
if (match[3]) {
|
||||
script.text = match[3];
|
||||
}
|
||||
|
||||
scripts.push(script);
|
||||
html = bobj.extractRange(html, match.index, match.index + match[0].length);
|
||||
}
|
||||
|
||||
return {scripts: scripts, html: html};
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract scripts and css links from a html fragment.
|
||||
*
|
||||
* @param html [String] html fragment
|
||||
*
|
||||
* @return [Object] Returns an object with a list of scripts, css links and html
|
||||
* i.e. {scripts: [{src:[String], text:[String]},...], html:[String], links: [String,...]}
|
||||
*/
|
||||
bobj.html.extractHtml = function(html) {
|
||||
var extScripts = bobj.html.extractScripts(html);
|
||||
var extLinks = bobj.html.extractLinks(extScripts.html);
|
||||
var extStyles = bobj.html.extractStyles(extLinks.html);
|
||||
|
||||
return {scripts: extScripts.scripts, html : extStyles.html, links : extLinks.links, styles: extStyles.styles};
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract css links from a html fragment.
|
||||
*
|
||||
* @param html [String] html fragment
|
||||
*
|
||||
* @return [Object] Returns an object with a list of links and html without
|
||||
* links
|
||||
* i.e. {links: [String,...], html:[String]}
|
||||
*/
|
||||
bobj.html.extractLinks = function(html) {
|
||||
var regexpLink = /<link([^>]*)>/i;
|
||||
var regexpHref = /href=\"([^\"]*)\"/i;
|
||||
|
||||
var links = [];
|
||||
var match = null;
|
||||
|
||||
while(match = regexpLink.exec(html)) {
|
||||
// match = "<link href='' \>
|
||||
|
||||
var href = regexpHref.exec(match);
|
||||
|
||||
if(href && href.length > 0) {
|
||||
links.push(href[1]);
|
||||
}
|
||||
html = bobj.extractRange(html, match.index, match.index + match[0].length);
|
||||
}
|
||||
|
||||
return {links: links, html: html};
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract <style> tags from an html fragment.
|
||||
* Note - links to external style sheets are not currently extracted
|
||||
*
|
||||
* @param html [String] html fragment
|
||||
*
|
||||
* @return [Object] Returns an object with a list of styles and html without
|
||||
* styles
|
||||
* i.e. {styles: [{text:[String], type:[String], media:[String]},...], html:[String]}
|
||||
*/
|
||||
bobj.html.extractStyles = function(html) {
|
||||
// Match style tags
|
||||
// 1 - Attributes
|
||||
// 2 - CSS text
|
||||
// 1 2
|
||||
var regexpStyle = /<style([^>]*)>([\s\S]*?)<\/style>/i;
|
||||
|
||||
var regexpType = /type=\"([^\"]*)\"/i;
|
||||
var regexpMedia = /media=\"([^\"]*)\"/i;
|
||||
|
||||
var styles = [];
|
||||
var match = null;
|
||||
|
||||
while(match = regexpStyle.exec(html)) {
|
||||
var style = {media: null, type: null, text: match[2]};
|
||||
|
||||
var matchType = regexpType.exec(match[1]);
|
||||
if (matchType) {
|
||||
style.type = matchType[1];
|
||||
}
|
||||
|
||||
var matchMedia = regexpMedia.exec(match[1]);
|
||||
if (matchMedia) {
|
||||
style.media = matchMedia[1];
|
||||
}
|
||||
|
||||
styles.push(style);
|
||||
html = bobj.extractRange(html, match.index, match.index + match[0].length);
|
||||
}
|
||||
|
||||
return {styles: styles, html: html};
|
||||
}
|
||||
BIN
crystalreportviewers13/js/crviewer/images/StackedTab.gif
Normal file
|
After Width: | Height: | Size: 78 B |
|
After Width: | Height: | Size: 594 B |
BIN
crystalreportviewers13/js/crviewer/images/allInOne.gif
Normal file
|
After Width: | Height: | Size: 4.0 KiB |
BIN
crystalreportviewers13/js/crviewer/images/allInOneBG.gif
Normal file
|
After Width: | Height: | Size: 739 B |
|
After Width: | Height: | Size: 198 B |
BIN
crystalreportviewers13/js/crviewer/images/arrow_button_hover.gif
Normal file
|
After Width: | Height: | Size: 314 B |
BIN
crystalreportviewers13/js/crviewer/images/breadcrumbSep.gif
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
crystalreportviewers13/js/crviewer/images/calendar.gif
Normal file
|
After Width: | Height: | Size: 120 B |
BIN
crystalreportviewers13/js/crviewer/images/catalyst.gif
Normal file
|
After Width: | Height: | Size: 1016 B |
BIN
crystalreportviewers13/js/crviewer/images/clearValues.gif
Normal file
|
After Width: | Height: | Size: 497 B |
BIN
crystalreportviewers13/js/crviewer/images/clear_x.gif
Normal file
|
After Width: | Height: | Size: 80 B |
BIN
crystalreportviewers13/js/crviewer/images/closePanel.gif
Normal file
|
After Width: | Height: | Size: 54 B |
BIN
crystalreportviewers13/js/crviewer/images/delete.gif
Normal file
|
After Width: | Height: | Size: 231 B |
BIN
crystalreportviewers13/js/crviewer/images/drill_cursor.cur
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
crystalreportviewers13/js/crviewer/images/export.gif
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
BIN
crystalreportviewers13/js/crviewer/images/filledCircle.gif
Normal file
|
After Width: | Height: | Size: 271 B |
BIN
crystalreportviewers13/js/crviewer/images/first.gif
Normal file
|
After Width: | Height: | Size: 122 B |
BIN
crystalreportviewers13/js/crviewer/images/grouptree_toggle.gif
Normal file
|
After Width: | Height: | Size: 370 B |
BIN
crystalreportviewers13/js/crviewer/images/hollowCircle.gif
Normal file
|
After Width: | Height: | Size: 269 B |
BIN
crystalreportviewers13/js/crviewer/images/last.gif
Normal file
|
After Width: | Height: | Size: 122 B |
BIN
crystalreportviewers13/js/crviewer/images/leftTriangle.gif
Normal file
|
After Width: | Height: | Size: 260 B |
BIN
crystalreportviewers13/js/crviewer/images/line.gif
Normal file
|
After Width: | Height: | Size: 59 B |