You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by mr...@apache.org on 2006/04/14 01:47:17 UTC
svn commit: r393978 [22/25] - in
/incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo:
./ demos/ demos/widget/ demos/widget/EditorTree/
demos/widget/EditorTree/static/ demos/widget/Mail/ demos/widget/images/
src/ src/alg/...
Added: incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/ComboBox.js
URL: http://svn.apache.org/viewcvs/incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/ComboBox.js?rev=393978&view=auto
==============================================================================
--- incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/ComboBox.js (added)
+++ incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/ComboBox.js Thu Apr 13 16:46:55 2006
@@ -0,0 +1,419 @@
+/*
+ Copyright (c) 2004-2005, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.widget.html.ComboBox");
+dojo.require("dojo.widget.ComboBox");
+dojo.require("dojo.widget.*");
+dojo.require("dojo.io.*");
+dojo.require("dojo.fx.*");
+dojo.require("dojo.dom");
+dojo.require("dojo.html");
+dojo.require("dojo.string");
+dojo.require("dojo.widget.html.stabile");
+
+dojo.widget.html.ComboBox = function(){
+ dojo.widget.ComboBox.call(this);
+ dojo.widget.HtmlWidget.call(this);
+
+ this.autoComplete = true;
+ this.formInputName = "";
+ this.name = ""; // clone in the name from the DOM node
+ this.textInputNode = null;
+ this.comboBoxValue = null;
+ this.comboBoxSelectionValue = null;
+ this.optionsListWrapper = null;
+ this.optionsListNode = null;
+ this.downArrowNode = null;
+ this.cbTableNode = null;
+ this.searchTimer = null;
+ this.searchDelay = 100;
+ this.dataUrl = "";
+ // mode can also be "remote" for JSON-returning live search or "html" for
+ // dumber live search
+ this.mode = "local";
+ this.selectedResult = null;
+ this._highlighted_option = null;
+ this._prev_key_backspace = false;
+ this._prev_key_esc = false;
+ this._result_list_open = false;
+}
+
+dojo.inherits(dojo.widget.html.ComboBox, dojo.widget.HtmlWidget);
+
+// copied from superclass since we can't really over-ride via prototype
+dojo.lang.extend(dojo.widget.html.ComboBox, dojo.widget.ComboBox.defaults);
+
+dojo.lang.extend(dojo.widget.html.ComboBox, {
+
+
+ templatePath: dojo.uri.dojoUri("src/widget/templates/HtmlComboBox.html"),
+ templateCssPath: dojo.uri.dojoUri("src/widget/templates/HtmlComboBox.css"),
+
+ setValue: function(value) {
+ this.comboBoxValue.value = this.textInputNode.value = value;
+ dojo.widget.html.stabile.setState(this.widgetId, this.getState(), true);
+ },
+
+ getValue: function() {
+ return this.comboBoxValue.value;
+ },
+
+ getState: function() {
+ return {value: this.getValue()};
+ },
+
+ setState: function(state) {
+ this.setValue(state.value);
+ },
+
+
+ getCaretPos: function(element){
+ // FIXME: we need to figure this out for Konq/Safari!
+ if(dojo.render.html.mozilla){
+ // FIXME: this is totally borked on Moz < 1.3. Any recourse?
+ return element.selectionStart;
+ }else if(dojo.render.html.ie){
+ // in the case of a mouse click in a popup being handled,
+ // then the document.selection is not the textarea, but the popup
+ // var r = document.selection.createRange();
+ // hack to get IE 6 to play nice. What a POS browser.
+ // var tr = r.duplicate();
+ var tr = document.selection.createRange().duplicate();
+ // var ntr = document.selection.createRange().duplicate();
+ var ntr = element.createTextRange();
+ // FIXME: this seems to work but I'm getting some execptions on reverse-tab
+ tr.move("character",0);
+ ntr.move("character",0);
+ /*
+ try{
+ ntr.moveToElementText(element);
+ }catch(e){ dojo.debug(e); }
+ */
+ ntr.setEndPoint("EndToEnd", tr);
+ return String(ntr.text).replace(/\r/g,"").length;
+ }
+ },
+
+ setCaretPos: function(element, location){
+ location = parseInt(location);
+ this.setSelectedRange(element, location, location);
+ },
+
+ setSelectedRange: function(element, start, end){
+ if(!end){ end = element.value.length; }
+ // Mozilla
+ // parts borrowed from http://www.faqts.com/knowledge_base/view.phtml/aid/13562/fid/130
+ if(element.setSelectionRange){
+ element.focus();
+ element.setSelectionRange(start, end);
+ }else if(element.createTextRange){ // IE
+ var range = element.createTextRange();
+ with(range){
+ collapse(true);
+ moveEnd('character', end);
+ moveStart('character', start);
+ select();
+ }
+ }else{ //otherwise try the event-creation hack (our own invention)
+ // do we need these?
+ element.value = element.value;
+ element.blur();
+ element.focus();
+ // figure out how far back to go
+ var dist = parseInt(element.value.length)-end;
+ var tchar = String.fromCharCode(37);
+ var tcc = tchar.charCodeAt(0);
+ for(var x = 0; x < dist; x++){
+ var te = document.createEvent("KeyEvents");
+ te.initKeyEvent("keypress", true, true, null, false, false, false, false, tcc, tcc);
+ twe.dispatchEvent(te);
+ }
+ }
+ },
+
+ killEvent: function(evt){
+ evt.preventDefault();
+ evt.stopPropagation();
+ },
+
+ onKeyDown: function(evt){
+ },
+
+ setSelectedValue: function(value){
+ // FIXME, not sure what to do here!
+ this.comboBoxSelectionValue.value = value;
+ this.hideResultList();
+ },
+
+ highlightNextOption: function(){
+ if(this._highlighted_option){
+ dojo.html.removeClass(this._highlighted_option, "cbItemHighlight");
+ }
+ if((!this._highlighted_option)||(!this._highlighted_option.nextSibling)){
+ this._highlighted_option = this.optionsListNode.firstChild;
+ }else{
+ this._highlighted_option = this._highlighted_option.nextSibling;
+ }
+ dojo.html.addClass(this._highlighted_option, "cbItemHighlight");
+ },
+
+ highlightPrevOption: function(){
+ if(this._highlighted_option){
+ dojo.html.removeClass(this._highlighted_option, "cbItemHighlight");
+ }
+ if((!this._highlighted_option)||(!this._highlighted_option.previousSibling)){
+ this._highlighted_option = this.optionsListNode.lastChild;
+ }else{
+ this._highlighted_option = this._highlighted_option.previousSibling;
+ }
+ dojo.html.addClass(this._highlighted_option, "cbItemHighlight");
+ },
+
+ onKeyUp: function(evt){
+ if(evt.keyCode == 27){ // esc is 27
+ this.hideResultList();
+ if(this._prev_key_esc){
+ this.textInputNode.blur();
+ this.selectedResult = null;
+ }
+ this._prev_key_esc = true;
+ return;
+ }else if((evt.keyCode == 32)||(evt.keyCode == 13)){ // space is 32, enter is 13.
+ /*
+ // Cancel the enter key event bubble to avoid submitting the form.
+ if (evt.keyCode == 13) {
+ // FIXME: the does not cancel the form submission.
+ this.killEvent(evt);
+ }
+ */
+ // If the list is open select the option with the event.
+ if(this._result_list_open){
+ evt = { target: this._highlighted_option };
+ this.selectOption(evt);
+ }else{
+ // Otherwise select the option with out the event.
+ this.selectOption();
+ }
+ return;
+ }else if(evt.keyCode == 40){ // down is 40
+ if(!this._result_list_open){
+ this.startSearchFromInput();
+ }
+ this.highlightNextOption();
+ return;
+ }else if(evt.keyCode == 38){ // up is 38
+ this.highlightPrevOption();
+ return;
+ }else{
+ this.setValue(this.textInputNode.value);
+ }
+
+ // backspace is 8
+ this._prev_key_backspace = (evt.keyCode == 8) ? true : false;
+ this._prev_key_esc = false;
+
+ if(this.searchTimer){
+ clearTimeout(this.searchTimer);
+ }
+ if((this._prev_key_backspace)&&(!this.textInputNode.value.length)){
+ this.hideResultList();
+ }else{
+ this.searchTimer = setTimeout(dojo.lang.hitch(this, this.startSearchFromInput), this.searchDelay);
+ }
+ },
+
+ fillInTemplate: function(args, frag){
+ // FIXME: need to get/assign DOM node names for form participation here.
+ this.comboBoxValue.name = this.name;
+ this.comboBoxSelectionValue.name = this.name+"_selected";
+
+ // NOTE: this doesn't copy style info inherited from classes;
+ // it's just primitive support for direct style setting
+ var sourceNodeStyle = this.getFragNodeRef(frag).style;
+ if ( sourceNodeStyle ){
+ this.domNode.style.cssText = sourceNodeStyle.cssText;
+ }
+
+ // FIXME: add logic
+ this.dataProvider = new dojo.widget.ComboBoxDataProvider();
+
+ if(!dojo.string.isBlank(this.dataUrl)){
+ if("local" == this.mode){
+ var _this = this;
+ dojo.io.bind({
+ url: this.dataUrl,
+ load: function(type, data, evt){
+ if(type=="load"){
+ _this.dataProvider.setData(data);
+ }
+ },
+ mimetype: "text/javascript"
+ });
+ }else if("remote" == this.mode){
+ this.dataProvider = new dojo.widget.incrementalComboBoxDataProvider(this.dataUrl);
+ }
+ }else{
+ // check to see if we can populate the list from <option> elements
+ var node = frag["dojo:"+this.widgetType.toLowerCase()]["nodeRef"];
+ if((node)&&(node.nodeName.toLowerCase() == "select")){
+ // NOTE: we're not handling <optgroup> here yet
+ var opts = node.getElementsByTagName("option");
+ var ol = opts.length;
+ var data = [];
+ for(var x=0; x<ol; x++){
+ data.push([new String(opts[x].innerHTML), new String(opts[x].value)]);
+ }
+ this.dataProvider.setData(data);
+ }
+ }
+
+ // Prevent IE bleed-through problem
+ this.bgIframe = new dojo.html.BackgroundIframe();
+ if(this.bgIframe.iframe){
+ this.optionsListWrapper.appendChild(this.bgIframe.iframe);
+ }
+ },
+
+ openResultList: function(results){
+ this.clearResultList();
+ if(!results.length){
+ this.hideResultList();
+ }else{
+ this.showResultList();
+ }
+ if( (this.autoComplete)&&
+ (results.length)&&
+ (!this._prev_key_backspace)&&
+ (this.textInputNode.value.length > 0)){
+ var cpos = this.getCaretPos(this.textInputNode);
+ // only try to extend if we added the last charachter at the end of the input
+ if((cpos+1) >= this.textInputNode.value.length){
+ this.textInputNode.value = results[0][0];
+ // build a new range that has the distance from the earlier
+ // caret position to the end of the first string selected
+ this.setSelectedRange(this.textInputNode, cpos, this.textInputNode.value.length);
+ }
+ }
+
+ var even = true;
+ while(results.length){
+ var tr = results.shift();
+ if(tr){
+ var td = document.createElement("div");
+ td.appendChild(document.createTextNode(tr[0]));
+ td.setAttribute("resultName", tr[0]);
+ td.setAttribute("resultValue", tr[1]);
+ td.className = "cbItem "+((even) ? "cbItemEven" : "cbItemOdd");
+ even = (!even);
+ this.optionsListNode.appendChild(td);
+ }
+ }
+
+ dojo.event.kwConnect({
+ once: true,
+ srcObj: dojo.html.body(),
+ srcFunc: "onclick",
+ adviceObj: this,
+ adviceFunc: "hideResultList"
+ });
+
+ // prevent IE bleed through
+ dojo.lang.setTimeout(this, "showBackgroundIframe", 100);
+ },
+
+ showBackgroundIframe: function(){
+ var w = dojo.style.getOuterWidth(this.optionsListNode);
+ var h = dojo.style.getOuterHeight(this.optionsListNode);
+ if ( isNaN(w) || isNaN(h) ){
+ // need more time to calculate size
+ dojo.lang.setTimeout(this, "showBackgroundIframe", 100);
+ return;
+ }
+ this.bgIframe.show([0,0,w,h]);
+ this.bgIframe.setZIndex(1);
+ },
+
+ selectOption: function(evt){
+ if(!evt){
+ evt = { target: this._highlighted_option };
+ }
+
+ if(!dojo.dom.isDescendantOf(evt.target, this.optionsListNode)){
+ return;
+ }
+
+ var tgt = evt.target;
+ while((tgt.nodeType!=1)||(!tgt.getAttribute("resultName"))){
+ tgt = tgt.parentNode;
+ if(tgt === dojo.html.body()){
+ return false;
+ }
+ }
+
+ this.textInputNode.value = tgt.getAttribute("resultName");
+ this.selectedResult = [tgt.getAttribute("resultName"), tgt.getAttribute("resultValue")];
+ this.setValue(tgt.getAttribute("resultName"));
+ this.comboBoxSelectionValue.value = tgt.getAttribute("resultValue");
+ this.hideResultList();
+ },
+
+ clearResultList: function(){
+ var oln = this.optionsListNode;
+ while(oln.firstChild){
+ oln.removeChild(oln.firstChild);
+ }
+ },
+
+ hideResultList: function(){
+ dojo.fx.fadeHide(this.optionsListNode, 200);
+ dojo.event.disconnect(dojo.html.body(), "onclick", this, "hideResultList");
+ this._result_list_open = false;
+ this.bgIframe.hide();
+ return;
+ },
+
+ showResultList: function(){
+ if(this._result_list_open){ return; }
+ with(this.optionsListNode.style){
+ display = "";
+ // visibility = "hidden";
+ height = "";
+ width = dojo.html.getInnerWidth(this.downArrowNode)+dojo.html.getInnerWidth(this.textInputNode)+"px";
+ if(dojo.render.html.khtml){
+ marginTop = dojo.html.totalOffsetTop(this.optionsListNode.parentNode)+"px";
+ }
+ }
+ dojo.html.setOpacity(this.optionsListNode, 0);
+ dojo.fx.fadeIn(this.optionsListNode, 200);
+ this._result_list_open = true;
+ },
+
+ handleArrowClick: function(){
+ if(this._result_list_open){
+ this.hideResultList();
+ }else{
+ this.startSearchFromInput();
+ }
+ },
+
+ startSearchFromInput: function(){
+ this.startSearch(this.textInputNode.value);
+ },
+
+ postCreate: function(){
+ dojo.event.connect(this, "startSearch", this.dataProvider, "startSearch");
+ dojo.event.connect(this.dataProvider, "provideSearchResults", this, "openResultList");
+ var s = dojo.widget.html.stabile.getState(this.widgetId);
+ if (s) {
+ this.setState(s);
+ }
+ }
+
+});
Added: incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/Container.js
URL: http://svn.apache.org/viewcvs/incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/Container.js?rev=393978&view=auto
==============================================================================
--- incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/Container.js (added)
+++ incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/Container.js Thu Apr 13 16:46:55 2006
@@ -0,0 +1,46 @@
+/*
+ Copyright (c) 2004-2005, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.widget.html.Container");
+
+dojo.require("dojo.widget.*");
+dojo.require("dojo.widget.Container");
+
+dojo.widget.html.Container = function(){
+ dojo.widget.HtmlWidget.call(this);
+}
+
+dojo.inherits(dojo.widget.html.Container, dojo.widget.HtmlWidget);
+
+dojo.lang.extend(dojo.widget.html.Container, {
+ widgetType: "Container",
+
+ isContainer: true,
+ containerNode: null,
+ domNode: null,
+
+ onResized: function() {
+ // Clients should override this function to do special processing,
+ // then call this.notifyChildrenOfResize() to notify children of resize
+ this.notifyChildrenOfResize();
+ },
+
+ notifyChildrenOfResize: function() {
+ for(var i=0; i<this.children.length; i++) {
+ var child = this.children[i];
+ //dojo.debug(this.widgetId + " resizing child " + child.widgetId);
+ if ( child.onResized ) {
+ child.onResized();
+ }
+ }
+ }
+});
+
+dojo.widget.tags.addParseTreeHandler("dojo:Container");
Added: incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/ContentPane.js
URL: http://svn.apache.org/viewcvs/incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/ContentPane.js?rev=393978&view=auto
==============================================================================
--- incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/ContentPane.js (added)
+++ incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/ContentPane.js Thu Apr 13 16:46:55 2006
@@ -0,0 +1,127 @@
+/*
+ Copyright (c) 2004-2005, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.widget.html.ContentPane");
+
+dojo.require("dojo.widget.*");
+dojo.require("dojo.io.*");
+dojo.require("dojo.widget.Container");
+dojo.require("dojo.widget.ContentPane");
+
+dojo.widget.html.ContentPane = function(){
+ dojo.widget.html.Container.call(this);
+}
+dojo.inherits(dojo.widget.html.ContentPane, dojo.widget.html.Container);
+
+dojo.lang.extend(dojo.widget.html.ContentPane, {
+ widgetType: "ContentPane",
+
+ href: "",
+ extractContent: true,
+ parseContent: true,
+ cacheContent: true,
+
+ // To generate pane content from a java function
+ handler: "",
+
+ postCreate: function(args, frag, parentComp){
+ if ( this.handler != "" ){
+ this.setHandler(this.handler);
+ }
+ },
+
+ onResized: function(){
+ if(this.isVisible()){
+ this.loadContents();
+ }
+ dojo.widget.html.ContentPane.superclass.onResized.call(this);
+ },
+
+ show: function(){
+ this.loadContents();
+ dojo.widget.html.ContentPane.superclass.show.call(this);
+ },
+
+ loadContents: function() {
+ if ( this.isLoaded ){
+ return;
+ }
+ this.isLoaded=true;
+ if ( dojo.lang.isFunction(this.handler)) {
+ this._runHandler();
+ } else if ( this.href != "" ) {
+ this._downloadExternalContent(this.href, this.cacheContent);
+ }
+ },
+
+ // Reset the (external defined) content of this pane
+ setUrl: function(url) {
+ this.href = url;
+ this.isLoaded = false;
+ if ( this.isVisible() ){
+ this.loadContents();
+ }
+ },
+
+ _downloadExternalContent: function(url, useCache) {
+ this.setContent("Loading...");
+
+ var self = this;
+ dojo.io.bind({
+ url: url,
+ useCache: useCache,
+ mimetype: "text/html",
+ handler: function(type, data, e) {
+ if(type == "load") {
+ if(self.extractContent) {
+ var matches = data.match(/<body[^>]*>\s*([\s\S]+)\s*<\/body>/im);
+ if(matches) { data = matches[1]; }
+ }
+ self.setContent.call(self, data);
+ } else {
+ self.setContent.call(self, "Error loading '" + url + "' (" + e.status + " " + e.statusText + ")");
+ }
+ }
+ });
+ },
+
+ setContent: function(data){
+ var node = this.containerNode || this.domNode;
+ node.innerHTML = data;
+ if(this.parseContent) {
+ var parser = new dojo.xml.Parse();
+ var frag = parser.parseElement(node, null, true);
+ dojo.widget.getParser().createComponents(frag);
+ this.onResized();
+ }
+ },
+
+ // Generate pane content from given java function
+ setHandler: function(handler) {
+ var fcn = dojo.lang.isFunction(handler) ? handler : window[handler];
+ if(!dojo.lang.isFunction(fcn)) {
+ throw new Error("Unable to set handler, '" + handler + "' not a function.");
+ return;
+ }
+ this.handler = function() {
+ return fcn.apply(this, arguments);
+ }
+ },
+
+ _runHandler: function() {
+ if(dojo.lang.isFunction(this.handler)) {
+ this.handler(this, this.domNode);
+ return false;
+ }
+ return true;
+ }
+});
+
+dojo.widget.tags.addParseTreeHandler("dojo:ContentPane");
Added: incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/ContextMenu.js
URL: http://svn.apache.org/viewcvs/incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/ContextMenu.js?rev=393978&view=auto
==============================================================================
--- incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/ContextMenu.js (added)
+++ incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/ContextMenu.js Thu Apr 13 16:46:55 2006
@@ -0,0 +1,166 @@
+/*
+ Copyright (c) 2004-2005, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.widget.html.ContextMenu");
+dojo.require("dojo.html");
+dojo.require("dojo.widget.HtmlWidget");
+dojo.require("dojo.widget.ContextMenu");
+dojo.require("dojo.lang");
+
+dojo.widget.html.ContextMenu = function(){
+ dojo.widget.ContextMenu.call(this);
+ dojo.widget.HtmlWidget.call(this);
+
+ this.isShowing = 0;
+ this.templatePath = dojo.uri.dojoUri("src/widget/templates/HtmlContextMenuTemplate.html");
+ this.templateCssPath = dojo.uri.dojoUri("src/widget/templates/Menu.css");
+
+ this.targetNodeIds = []; // fill this with nodeIds upon widget creation and it only responds to those nodes
+
+ // default event detection method
+ var eventType = "oncontextmenu";
+
+ var doc = document.documentElement || dojo.html.body();
+
+ var _blockHide = false;
+
+ this.fillInTemplate = function(args, frag){
+
+ var func = "onOpen";
+ var attached = false;
+
+ // connect with rightclick if oncontextmenu is not around
+ // NOTE: It would be very nice to have a dojo.event.browser.supportsEvent here
+ // NOTE: Opera does not have rightclick events, it is listed here only because
+ // it bails out when connecting with oncontextmenu event
+
+ if((dojo.render.html.khtml && !dojo.render.html.safari) || (dojo.render.html.opera)){
+ eventType = "onmousedown";
+ func = "_checkRightClick";
+ }
+
+ // attach event listeners to our selected nodes
+ for(var i=0; i<this.targetNodeIds.length; i++){
+ var node = document.getElementById(this.targetNodeIds[i]);
+ if(node){
+ dojo.event.connect(node, eventType, this, func);
+ attached = true;
+ }else{
+ // remove this nodeId
+ dj_debug("Couldent find "+this.targetNodeIds[i]+", cant do ContextMenu on this node");
+ this.targetNodeIds.splice(i,1);
+ }
+ }
+
+ // if we got attached to a node, hide on all non node contextevents
+ if(attached){ func = "_canHide"; }
+
+ dojo.event.connect(doc, eventType, this, func);
+ }
+
+ this.onOpen = function(evt){
+ // if (this.isShowing){ this.onHide(evt); } // propably not needed
+ this.isShowing = 1;
+
+ // if I do this, I cant preventDefault in khtml
+ //evt = dojo.event.browser.fixEvent(evt);
+
+ // stop default contextmenu, needed in khtml
+ if (evt.preventDefault){ evt.preventDefault(); }
+
+ // need to light up this one before we check width and height
+ this.domNode.style.left = "-9999px";
+ this.domNode.style.top = "-9999px";
+ this.domNode.style.display = "block";
+
+ // calculate if menu is going to apear within window
+ // or if its partially out of visable area
+ with(dojo.html){
+
+ var menuW = getInnerWidth(this.domNode);
+ var menuH = getInnerHeight(this.domNode);
+
+ var viewport = getViewportSize();
+ var scrolloffset = getScrollOffset();
+ }
+
+ var minX = viewport[0];
+ var minY = viewport[1];
+
+ var maxX = (viewport[0] + scrolloffset[0]) - menuW;
+ var maxY = (viewport[1] + scrolloffset[1]) - menuH;
+
+ var posX = evt.clientX + scrolloffset[0];
+ var posY = evt.clientY + scrolloffset[1];
+
+ if (posX > maxX){ posX = posX - menuW; }
+ if (posY > maxY){ posY = posY - menuH; }
+
+ this.domNode.style.left = posX + "px";
+ this.domNode.style.top = posY + "px";
+
+
+ // block the onclick that follows this particular right click
+ // not if the eventtrigger is documentElement and always when
+ // we use onmousedown hack
+ _blockHide = (evt.currentTarget!=doc || eventType=='onmousedown');
+
+ //return false; // we propably doesnt need to return false as we dont stop the event as we did before
+ }
+
+ /*
+ * _canHide is meant to block the onHide call that follows the event that triggered
+ * onOpen. This is (hopefully) faster that event.connect and event.disconnect every
+ * time the code executes and it makes connecting with onmousedown event possible
+ * and we dont have to stop the event from bubbling further.
+ *
+ * this code is moved into a separete function because it makes it possible for the
+ * user to connect to a onHide event, if anyone would like that.
+ */
+
+ this._canHide = function(evt){
+ // block the onclick that follows the same event that turn on contextmenu
+ if(_blockHide){
+ // the onclick check is needed to prevent displaying multiple
+ // menus when we have 2 or more contextmenus loaded and are using
+ // the onmousedown hack
+ if(evt.type=='click' || eventType=='oncontextmenu'){
+ _blockHide = false;
+ return;
+ }else{
+ return;
+ }
+ }
+
+ this.onHide(evt);
+ }
+
+ this.onHide = function(evt){
+ // FIXME: use whatever we use to do more general style setting?
+ this.domNode.style.display = "none";
+ //dojo.event.disconnect(doc, "onclick", this, "onHide");
+ this.isShowing = 0;
+ }
+
+ // callback for rightclicks, needed for browsers that doesnt implement oncontextmenu, konqueror and more?
+ this._checkRightClick = function(evt){
+
+ // for some reason konq comes here even when we are not clicking on the attached nodes
+ // added check for targetnode
+ if (evt.button==2 && (this.targetNodeIds.length==0 || (evt.currentTarget.id!="" && dojo.lang.inArray(this.targetNodeIds, evt.currentTarget.id)))){
+
+ return this.onOpen(evt);
+ }
+ }
+
+ dojo.event.connect(doc, "onclick", this, "_canHide");
+}
+
+dojo.inherits(dojo.widget.html.ContextMenu, dojo.widget.HtmlWidget);
Added: incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/DatePicker.js
URL: http://svn.apache.org/viewcvs/incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/DatePicker.js?rev=393978&view=auto
==============================================================================
--- incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/DatePicker.js (added)
+++ incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/DatePicker.js Thu Apr 13 16:46:55 2006
@@ -0,0 +1,307 @@
+/*
+ Copyright (c) 2004-2005, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.widget.html.DatePicker");
+dojo.require("dojo.widget.*");
+dojo.require("dojo.widget.HtmlWidget");
+dojo.require("dojo.widget.DatePicker");
+dojo.require("dojo.event.*");
+dojo.require("dojo.html");
+
+/*
+ Some assumptions:
+ - I'm planning on always showing 42 days at a time, and we can scroll by week,
+ not just by month or year
+ - To get a sense of what month to highlight, I basically initialize on the
+ first Saturday of each month, since that will be either the first of two or
+ the second of three months being partially displayed, and then I work forwards
+ and backwards from that point.
+ Currently, I assume that dates are stored in the RFC 3339 format,
+ because I find it to be most human readable and easy to parse
+ http://www.faqs.org/rfcs/rfc3339.html: 2005-06-30T08:05:00-07:00
+ FIXME: scroll by week not yet implemented
+*/
+
+
+dojo.widget.html.DatePicker = function(){
+ dojo.widget.DatePicker.call(this);
+ dojo.widget.HtmlWidget.call(this);
+
+ var _this = this;
+ // today's date, JS Date object
+ this.today = "";
+ // selected date, JS Date object
+ this.date = "";
+ // rfc 3339 date
+ this.storedDate = "";
+ // date currently selected in the UI, stored in year, month, date in the format that will be actually displayed
+ this.currentDate = {};
+ // stored in year, month, date in the format that will be actually displayed
+ this.firstSaturday = {};
+ this.classNames = {
+ previous: "previousMonth",
+ current: "currentMonth",
+ next: "nextMonth",
+ currentDate: "currentDate",
+ selectedDate: "selectedItem"
+ }
+
+ this.templatePath = dojo.uri.dojoUri("src/widget/templates/HtmlDatePicker.html");
+ this.templateCssPath = dojo.uri.dojoUri("src/widget/templates/HtmlDatePicker.css");
+
+ this.fillInTemplate = function(){
+ this.initData();
+ this.initUI();
+ }
+
+ this.initData = function() {
+ this.today = new Date();
+ if(this.storedDate && (this.storedDate.split("-").length > 2)) {
+ this.date = dojo.widget.DatePicker.util.fromRfcDate(this.storedDate);
+ } else {
+ this.date = this.today;
+ }
+ // calendar math is simplified if time is set to 0
+ this.today.setHours(0);
+ this.date.setHours(0);
+ var month = this.date.getMonth();
+ var tempSaturday = dojo.widget.DatePicker.util.initFirstSaturday(this.date.getMonth().toString(), this.date.getFullYear());
+ this.firstSaturday.year = tempSaturday.year;
+ this.firstSaturday.month = tempSaturday.month;
+ this.firstSaturday.date = tempSaturday.date;
+ }
+
+ this.setDate = function(rfcDate) {
+ this.storedDate = rfcDate;
+ }
+
+
+ this.initUI = function() {
+ this.selectedIsUsed = false;
+ this.currentIsUsed = false;
+ var currentClassName = "";
+ var previousDate = new Date();
+ var calendarNodes = this.calendarDatesContainerNode.getElementsByTagName("td");
+ var currentCalendarNode;
+ // set hours of date such that there is no chance of rounding error due to
+ // time change in local time zones
+ previousDate.setHours(8);
+ var nextDate = new Date(this.firstSaturday.year, this.firstSaturday.month, this.firstSaturday.date, 8);
+
+
+ if(this.firstSaturday.date < 7) {
+ // this means there are days to show from the previous month
+ var dayInWeek = 6;
+ for (var i=this.firstSaturday.date; i>0; i--) {
+ currentCalendarNode = calendarNodes.item(dayInWeek);
+ currentCalendarNode.innerHTML = nextDate.getDate();
+ dojo.html.setClass(currentCalendarNode, this.getDateClassName(nextDate, "current"));
+ dayInWeek--;
+ previousDate = nextDate;
+ nextDate = this.incrementDate(nextDate, false);
+ }
+ for(var i=dayInWeek; i>-1; i--) {
+ currentCalendarNode = calendarNodes.item(i);
+ currentCalendarNode.innerHTML = nextDate.getDate();
+ dojo.html.setClass(currentCalendarNode, this.getDateClassName(nextDate, "previous"));
+ previousDate = nextDate;
+ nextDate = this.incrementDate(nextDate, false);
+ }
+ } else {
+ nextDate.setDate(1);
+ for(var i=0; i<7; i++) {
+ currentCalendarNode = calendarNodes.item(i);
+ currentCalendarNode.innerHTML = i + 1;
+ dojo.html.setClass(currentCalendarNode, this.getDateClassName(nextDate, "current"));
+ previousDate = nextDate;
+ nextDate = this.incrementDate(nextDate, true);
+ }
+ }
+ previousDate.setDate(this.firstSaturday.date);
+ previousDate.setMonth(this.firstSaturday.month);
+ previousDate.setFullYear(this.firstSaturday.year);
+ nextDate = this.incrementDate(previousDate, true);
+ var count = 7;
+ currentCalendarNode = calendarNodes.item(count);
+ while((nextDate.getMonth() == previousDate.getMonth()) && (count<42)) {
+ currentCalendarNode.innerHTML = nextDate.getDate();
+ dojo.html.setClass(currentCalendarNode, this.getDateClassName(nextDate, "current"));
+ currentCalendarNode = calendarNodes.item(++count);
+ previousDate = nextDate;
+ nextDate = this.incrementDate(nextDate, true);
+ }
+
+ while(count < 42) {
+ currentCalendarNode.innerHTML = nextDate.getDate();
+ dojo.html.setClass(currentCalendarNode, this.getDateClassName(nextDate, "next"));
+ currentCalendarNode = calendarNodes.item(++count);
+ previousDate = nextDate;
+ nextDate = this.incrementDate(nextDate, true);
+ }
+ this.setMonthLabel(this.firstSaturday.month);
+ this.setYearLabels(this.firstSaturday.year);
+ }
+
+ this.incrementDate = function(date, bool) {
+ // bool: true to increase, false to decrease
+ var time = date.getTime();
+ var increment = 1000 * 60 * 60 * 24;
+ time = (bool) ? (time + increment) : (time - increment);
+ var returnDate = new Date();
+ returnDate.setTime(time);
+ return returnDate;
+ }
+
+ this.incrementWeek = function(date, bool) {
+ dojo.unimplemented('dojo.widget.html.DatePicker.incrementWeek');
+ }
+
+ this.incrementMonth = function(date, bool) {
+ dojo.unimplemented('dojo.widget.html.DatePicker.incrementMonth');
+ }
+
+ this.incrementYear = function(date, bool) {
+ dojo.unimplemented('dojo.widget.html.DatePicker.incrementYear');
+ }
+
+ this.onIncrementDate = function(evt) {
+ dojo.unimplemented('dojo.widget.html.DatePicker.onIncrementDate');
+ }
+
+ this.onIncrementWeek = function(evt) {
+ // FIXME: should make a call to incrementWeek when that is implemented
+ evt.stopPropagation();
+ dojo.unimplemented('dojo.widget.html.DatePicker.onIncrementWeek');
+ switch(evt.target) {
+ case this.increaseWeekNode:
+ break;
+ case this.decreaseWeekNode:
+ break;
+ }
+ }
+
+ this.onIncrementMonth = function(evt) {
+ // FIXME: should make a call to incrementMonth when that is implemented
+ evt.stopPropagation();
+ var month = this.firstSaturday.month;
+ var year = this.firstSaturday.year;
+ switch(evt.currentTarget) {
+ case this.increaseMonthNode:
+ if(month < 11) {
+ month++;
+ } else {
+ month = 0;
+ year++;
+
+ this.setYearLabels(year);
+ }
+ break;
+ case this.decreaseMonthNode:
+ if(month > 0) {
+ month--;
+ } else {
+ month = 11;
+ year--;
+ this.setYearLabels(year);
+ }
+ break;
+ case this.increaseMonthNode.getElementsByTagName("img").item(0):
+ if(month < 11) {
+ month++;
+ } else {
+ month = 0;
+ year++;
+ this.setYearLabels(year);
+ }
+ break;
+ case this.decreaseMonthNode.getElementsByTagName("img").item(0):
+ if(month > 0) {
+ month--;
+ } else {
+ month = 11;
+ year--;
+ this.setYearLabels(year);
+ }
+ break;
+ }
+ var tempSaturday = dojo.widget.DatePicker.util.initFirstSaturday(month.toString(), year);
+ this.firstSaturday.year = tempSaturday.year;
+ this.firstSaturday.month = tempSaturday.month;
+ this.firstSaturday.date = tempSaturday.date;
+ this.initUI();
+ }
+
+ this.onIncrementYear = function(evt) {
+ // FIXME: should make a call to incrementYear when that is implemented
+ evt.stopPropagation();
+ var year = this.firstSaturday.year;
+ switch(evt.target) {
+ case this.nextYearLabelNode:
+ year++;
+ break;
+ case this.previousYearLabelNode:
+ year--;
+ break;
+ }
+ var tempSaturday = dojo.widget.DatePicker.util.initFirstSaturday(this.firstSaturday.month.toString(), year);
+ this.firstSaturday.year = tempSaturday.year;
+ this.firstSaturday.month = tempSaturday.month;
+ this.firstSaturday.date = tempSaturday.date;
+ this.initUI();
+ }
+
+ this.setMonthLabel = function(monthIndex) {
+ this.monthLabelNode.innerHTML = this.months[monthIndex];
+ }
+
+ this.setYearLabels = function(year) {
+ this.previousYearLabelNode.innerHTML = year - 1;
+ this.currentYearLabelNode.innerHTML = year;
+ this.nextYearLabelNode.innerHTML = year + 1;
+ }
+
+ this.getDateClassName = function(date, monthState) {
+ var currentClassName = this.classNames[monthState];
+ if ((!this.selectedIsUsed) && (date.getDate() == this.date.getDate()) && (date.getMonth() == this.date.getMonth()) && (date.getFullYear() == this.date.getFullYear())) {
+ currentClassName = this.classNames.selectedDate + " " + currentClassName;
+ this.selectedIsUsed = 1;
+ }
+ if((!this.currentIsUsed) && (date.getDate() == this.today.getDate()) && (date.getMonth() == this.today.getMonth()) && (date.getFullYear() == this.today.getFullYear())) {
+ currentClassName = currentClassName + " " + this.classNames.currentDate;
+ this.currentIsUsed = 1;
+ }
+ return currentClassName;
+ }
+
+ this.onClick = function(evt) {
+ dojo.event.browser.stopEvent(evt)
+ }
+
+ this.onSetDate = function(evt) {
+ dojo.event.browser.stopEvent(evt);
+ this.selectedIsUsed = 0;
+ this.todayIsUsed = 0;
+ var month = this.firstSaturday.month;
+ var year = this.firstSaturday.year;
+ if (dojo.html.hasClass(evt.target, this.classNames["next"])) {
+ month = ++month % 12;
+ // if month is now == 0, add a year
+ year = (month==0) ? ++year : year;
+ } else if (dojo.html.hasClass(evt.target, this.classNames["previous"])) {
+ month = --month % 12;
+ // if month is now == 0, add a year
+ year = (month==11) ? --year : year;
+ }
+ this.date = new Date(year, month, evt.target.innerHTML);
+ this.setDate(dojo.widget.DatePicker.util.toRfcDate(this.date));
+ this.initUI();
+ }
+}
+dojo.inherits(dojo.widget.html.DatePicker, dojo.widget.HtmlWidget);
Added: incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/DebugConsole.js
URL: http://svn.apache.org/viewcvs/incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/DebugConsole.js?rev=393978&view=auto
==============================================================================
--- incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/DebugConsole.js (added)
+++ incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/DebugConsole.js Thu Apr 13 16:46:55 2006
@@ -0,0 +1,32 @@
+/*
+ Copyright (c) 2004-2005, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.widget.html.DebugConsole");
+
+dojo.require("dojo.widget.*");
+dojo.require("dojo.widget.FloatingPane");
+
+// Collection of widgets in a bar, like Windows task bar
+dojo.widget.html.DebugConsole= function(){
+
+ dojo.widget.html.FloatingPane.call(this);
+ dojo.widget.DebugConsole.call(this);
+}
+
+dojo.inherits(dojo.widget.html.DebugConsole, dojo.widget.html.FloatingPane);
+
+dojo.lang.extend(dojo.widget.html.DebugConsole, {
+ postCreate: function() {
+ dojo.widget.html.DebugConsole.superclass.postCreate.call(this);
+ this.clientPane.domNode.id = "debugConsoleClientPane"
+ djConfig.isDebug = true;
+ djConfig.debugContainerId = this.clientPane.domNode.id;
+ }
+});
Added: incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/DropdownButton.js
URL: http://svn.apache.org/viewcvs/incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/DropdownButton.js?rev=393978&view=auto
==============================================================================
--- incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/DropdownButton.js (added)
+++ incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/DropdownButton.js Thu Apr 13 16:46:55 2006
@@ -0,0 +1,188 @@
+/*
+ Copyright (c) 2004-2005, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+/* TODO:
+ * - make the dropdown "smart" so it can't get cutoff on bottom of page, sides of page, etc.
+ */
+
+dojo.provide("dojo.widget.html.DropdownButton");
+
+dojo.require("dojo.event.*");
+dojo.require("dojo.widget.*");
+dojo.require("dojo.widget.HtmlWidget");
+dojo.require("dojo.uri.Uri");
+dojo.require("dojo.dom");
+dojo.require("dojo.style");
+dojo.require("dojo.html");
+
+dojo.widget.html.DropdownButton = function() {
+ // mix in the button properties
+ dojo.widget.DropdownButton.call(this);
+ dojo.widget.HtmlWidget.call(this);
+}
+
+dojo.inherits(dojo.widget.html.DropdownButton, dojo.widget.HtmlWidget);
+
+dojo.lang.extend(dojo.widget.html.DropdownButton, {
+
+ // In IE, event handlers on objects inside buttons don't work correctly, so
+ // we just set onClick on the button itself.
+ templatePath: dojo.uri.dojoUri("src/widget/templates/HtmlDropDownButtonTemplate.html"),
+ templateCssPath: dojo.uri.dojoUri("src/widget/templates/HtmlButtonTemplate.css"),
+
+ // attach points
+ button: null,
+ table: null,
+ labelCell: null,
+ borderCell: null,
+ arrowCell: null,
+ arrow: null,
+
+ fillInTemplate: function(args, frag) {
+ // input data (containing the anchor for the button itself, plus the
+ // thing to display when you push the down arrow)
+ var input = frag["dojo:"+this.widgetType.toLowerCase()]["nodeRef"];
+
+ // Recursively expand widgets inside of the <dojo:dropdownButton>
+ var parser = new dojo.xml.Parse();
+ var frag = parser.parseElement(input, null, true);
+ var ary = dojo.widget.getParser().createComponents(frag);
+
+ this.a = dojo.dom.getFirstChildElement(input); // the button contents
+ this.menu = dojo.dom.getNextSiblingElement(this.a); // the menu under the button
+
+ this.disabled = dojo.html.hasClass(this.a, "disabled");
+ if( this.disabled ) {
+ dojo.html.addClass(this.button, "dojoDisabled");
+ this.domNode.setAttribute("disabled", "true");
+ }
+
+ dojo.html.disableSelection(this.a);
+ this.a.style["text-decoration"]="none";
+ this.labelCell.appendChild(this.a);
+
+ this.arrow.src =
+ dojo.uri.dojoUri("src/widget/templates/images/dropdownButtonsArrow" +
+ (this.disabled ? "-disabled" : "") + ".gif");
+
+ // Attach menu to body so that it appears above other buttons
+ this.menu.style.position="absolute";
+ this.menu.style.display="none";
+ this.menu.style["z-index"] = 99;
+ dojo.html.body().appendChild(this.menu);
+ },
+
+ postCreate: function() {
+ if ( dojo.render.html.ie ) {
+ // Compensate for IE's weird padding of button content, which seems to be relative
+ // to the length of the content
+ var contentWidth = dojo.style.getOuterWidth(this.table);
+ this.labelCell.style["left"] = "-" + (contentWidth / 10) + "px";
+ this.arrowCell.style["left"] = (contentWidth / 10) + "px";
+ }
+
+ // Make menu at least as wide as the button
+ var buttonWidth = dojo.style.getOuterWidth(this.button);
+ var menuWidth = dojo.style.getOuterWidth(this.menu);
+ if ( buttonWidth > menuWidth ) {
+ dojo.style.setOuterWidth(this.menu, buttonWidth);
+ }
+ },
+
+ // If someone clicks anywhere else on the screen (including another menu),
+ // then close this menu.
+ onCanvasMouseDown: function(e) {
+ if( !dojo.dom.isDescendantOf(e.target, this.button) &&
+ !dojo.dom.isDescendantOf(e.target, this.menu) ) {
+ this.hideMenu();
+ }
+ },
+
+ eventWasOverArrow: function(e) {
+ // want to use dojo.html.overElement() but also need to detect clicks
+ // on the area between the arrow and the edge of the button
+ var eventX = e.clientX;
+ var borderX = dojo.style.totalOffsetLeft(this.borderCell);
+ return (eventX > borderX );
+ },
+
+ onMouseOver: function(e) {
+ dojo.html.addClass(this.button, "dojoButtonHover");
+ dojo.html.removeClass(this.button, "dojoButtonNoHover");
+ },
+
+ onMouseOut: function(e) {
+ dojo.html.removeClass(this.button, "dojoButtonHover");
+ dojo.html.addClass(this.button, "dojoButtonNoHover");
+ },
+
+ onClick: function(e) {
+ if ( this.eventWasOverArrow(e) ) {
+ this._onClickArrow();
+ } else {
+ this._onClickButton();
+ }
+ },
+
+ // Action when the user presses the button
+ _onClickButton: function(e) {
+ if ( this.a ) {
+ if ( this.a.click ) {
+ this.a.click();
+ } else if ( this.a.href ) {
+ location.href = this.a.href;
+ }
+ }
+ },
+
+ // Action when user presses the arrow
+ _onClickArrow: function() {
+ if ( this.menu.style.display == "none" ) {
+ this.showMenu();
+ } else {
+ this.hideMenu();
+ }
+ },
+
+ showMenu: function() {
+ if ( this.disabled )
+ return;
+
+ // Position it accordingly, relative to screen root (since
+ // it's attached to document.body)
+ this.menu.style.left = dojo.style.totalOffsetLeft(this.button) + "px";
+ this.menu.style.top = dojo.style.totalOffsetTop(this.button) + dojo.style.getOuterHeight(this.button) + "px";
+
+ // Display the menu; do this funky code below to stop the menu from extending
+ // all the way to the right edge of the screen.
+ // TODO: retest simple display="" to confirm that it doesn't work.
+ try {
+ this.menu.style.display="table"; // mozilla
+ } catch(e) {
+ this.menu.style.display="block"; // IE
+ }
+
+ // If someone clicks somewhere else on the screen then close the menu
+ dojo.event.connect(document.documentElement, "onmousedown", this, "onCanvasMouseDown");
+
+ // When someone clicks the menu, after the menu handles the event,
+ // close the menu (be careful not to close the menu too early or else
+ // the menu will never receive the event.)
+ dojo.event.connect(this.menu, "onclick", this, "hideMenu");
+ },
+
+ hideMenu: function() {
+ this.menu.style.display = "none";
+ dojo.event.disconnect(document.documentElement, "onmousedown", this, "onCanvasMouseDown");
+ dojo.event.disconnect(this.menu, "onclick", this, "hideMenu");
+ }
+});
+
+
Added: incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/LayoutPane.js
URL: http://svn.apache.org/viewcvs/incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/LayoutPane.js?rev=393978&view=auto
==============================================================================
--- incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/LayoutPane.js (added)
+++ incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/LayoutPane.js Thu Apr 13 16:46:55 2006
@@ -0,0 +1,418 @@
+/*
+ Copyright (c) 2004-2005, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.widget.LayoutPane");
+dojo.provide("dojo.widget.html.LayoutPane");
+
+//
+// this widget provides Delphi-style panel layout semantics
+// this is a good place to stash layout logic, then derive components from it
+//
+// TODO: allow more edge priority orders (e.g. t,r,l,b)
+// TODO: allow percentage sizing stuff
+//
+
+dojo.require("dojo.widget.LayoutPane");
+dojo.require("dojo.widget.*");
+dojo.require("dojo.event.*");
+dojo.require("dojo.io.*");
+dojo.require("dojo.widget.Container");
+dojo.require("dojo.html");
+dojo.require("dojo.style");
+dojo.require("dojo.dom");
+dojo.require("dojo.string");
+
+
+dojo.widget.html.LayoutPane = function(){
+ dojo.widget.html.Container.call(this);
+}
+
+dojo.inherits(dojo.widget.html.LayoutPane, dojo.widget.html.Container);
+
+dojo.lang.extend(dojo.widget.html.LayoutPane, {
+ widgetType: "LayoutPane",
+
+ isChild: false,
+
+ clientWidth: 0,
+ clientHeight: 0,
+
+ layoutChildPriority: 'top-bottom',
+
+ cssPath: dojo.uri.dojoUri("src/widget/templates/HtmlLayoutPane.css"),
+
+ // If this pane's content is external then set the url here
+ url: "inline",
+ extractContent: true,
+ parseContent: true,
+ cacheContent: true,
+
+ // To generate pane content from a java function
+ handler: "none",
+
+ minWidth: 0,
+ minHeight: 0,
+
+ fillInTemplate: function(){
+ this.filterAllowed(this, 'layoutChildPriority', ['left-right', 'top-bottom']);
+
+ // Need to include CSS manually because there is no template file/string
+ dojo.style.insertCssFile(this.cssPath, null, true);
+ dojo.html.addClass(this.domNode, "dojoLayoutPane");
+ },
+
+ postCreate: function(args, fragment, parentComp){
+ for(var i=0; i<this.children.length; i++){
+ this._injectChild(this.children[i]);
+ }
+
+ if ( this.handler != "none" ){
+ this.setHandler(this.handler);
+ }
+ if ( this.isVisible() ){
+ this.loadContents();
+ }
+ },
+
+ // If the pane contents are external then load them
+ loadContents: function() {
+ if ( this.isLoaded ){
+ return;
+ }
+ if ( dojo.lang.isFunction(this.handler)) {
+ this._runHandler();
+ } else if ( this.url != "inline" ) {
+ this._downloadExternalContent(this.url, this.cacheContent);
+ }
+ this.isLoaded=true;
+ },
+
+ // Reset the (external defined) content of this pane
+ setUrl: function(url) {
+ this.url = url;
+ this.isLoaded = false;
+ if ( this.isVisible() ){
+ this.loadContents();
+ }
+ },
+
+ _downloadExternalContent: function(url, useCache) {
+ dojo.deprecated("LayoutPane url parameter.", "use LinkPane to download from a URL", "0.4");
+ //dojo.debug(this.widgetId + " downloading " + url);
+ var node = this.containerNode || this.domNode;
+ node.innerHTML = "Loading...";
+
+ var extract = this.extractContent;
+ var parse = this.parseContent;
+ var self = this;
+
+ dojo.io.bind({
+ url: url,
+ useCache: useCache,
+ mimetype: "text/html",
+ handler: function(type, data, e) {
+ if(type == "load") {
+ if(extract) {
+ var matches = data.match(/<body[^>]*>\s*([\s\S]+)\s*<\/body>/im);
+ if(matches) { data = matches[1]; }
+ }
+ node.innerHTML = data;
+ if(parse) {
+ var parser = new dojo.xml.Parse();
+ var frag = parser.parseElement(node, null, true);
+ dojo.widget.getParser().createComponents(frag);
+ }
+ self.onResized();
+ } else {
+ node.innerHTML = "Error loading '" + url + "' (" + e.status + " " + e.statusText + ")";
+ }
+ }
+ });
+ },
+
+ // Generate pane content from given java function
+ setHandler: function(handler) {
+ var fcn = dojo.lang.isFunction(handler) ? handler : window[handler];
+ if(!dojo.lang.isFunction(fcn)) {
+ throw new Error("Unable to set handler, '" + handler + "' not a function.");
+ return;
+ }
+ this.handler = function() {
+ return fcn.apply(this, arguments);
+ }
+ },
+
+ _runHandler: function() {
+ if(dojo.lang.isFunction(this.handler)) {
+ dojo.deprecated("use LinkPane to download content from a java function", "0.4");
+ this.handler(this, this.domNode);
+ return false;
+ }
+ return true;
+ },
+
+ filterAllowed: function(node, param, values){
+ if ( !dojo.lang.inArray(values, node[param]) ) {
+ node[param] = values[0];
+ }
+ },
+
+ layoutChildren: function(){
+ // find the children to arrange
+
+ var kids = {'left':[], 'right':[], 'top':[], 'bottom':[], 'client':[], 'flood':[]};
+ var hits = 0;
+
+ for(var i=0; i<this.children.length; i++){
+ if (this.hasLayoutAlign(this.children[i])){
+ kids[this.children[i].layoutAlign].push(this.children[i]);
+ hits++;
+ }
+ }
+
+ if (!hits){
+ return;
+ }
+
+ var container = this.containerNode || this.domNode;
+
+ // calc layout space
+
+ this.clientWidth = dojo.style.getContentWidth(container);
+ this.clientHeight = dojo.style.getContentHeight(container);
+
+ // note: don't setup clientRect as a member of the prototype because that
+ // would make the contents shared between instances
+ this.clientRect={};
+ this.clientRect['left'] = dojo.style.getPixelValue(container, "padding-left", true);
+ this.clientRect['right'] = dojo.style.getPixelValue(container, "padding-right", true);
+ this.clientRect['top'] = dojo.style.getPixelValue(container, "padding-top", true);
+ this.clientRect['bottom'] = dojo.style.getPixelValue(container, "padding-bottom", true);
+
+ // arrange them in order
+ this._layoutCenter(kids, "flood");
+ if (this.layoutChildPriority == 'top-bottom'){
+ this._layoutFloat(kids, "top");
+ this._layoutFloat(kids, "bottom");
+ this._layoutFloat(kids, "left");
+ this._layoutFloat(kids, "right");
+ }else{
+ this._layoutFloat(kids, "left");
+ this._layoutFloat(kids, "right");
+ this._layoutFloat(kids, "top");
+ this._layoutFloat(kids, "bottom");
+ }
+ this._layoutCenter(kids, "client");
+ },
+
+ // Position the left/right/top/bottom aligned elements
+ _layoutFloat: function(kids, position){
+ var ary = kids[position];
+
+ // figure out which two of the left/right/top/bottom properties to set
+ var lr = (position=="right")?"right":"left";
+ var tb = (position=="bottom")?"bottom":"top";
+
+ for(var i=0; i<ary.length; i++){
+ var elm=ary[i];
+
+ // set two of left/right/top/bottom properties
+ elm.domNode.style[lr]=this.clientRect[lr] + "px";
+ elm.domNode.style[tb]=this.clientRect[tb] + "px";
+
+ // adjust record of remaining space
+ if ( (position=="top")||(position=="bottom") ) {
+ dojo.style.setOuterWidth(elm.domNode, this.clientWidth);
+ var height = dojo.style.getOuterHeight(elm.domNode);
+ this.clientHeight -= height;
+ this.clientRect[position] += height;
+ } else {
+ dojo.style.setOuterHeight(elm.domNode, this.clientHeight);
+ var width = dojo.style.getOuterWidth(elm.domNode);
+ this.clientWidth -= width;
+ this.clientRect[position] += width;
+ }
+ }
+ },
+
+ // Position elements into the remaining space (in the center)
+ // If multiple elements are present they overlap each other
+ _layoutCenter: function(kids, position){
+ var ary = kids[position];
+ for(var i=0; i<ary.length; i++){
+ var elm=ary[i];
+ elm.domNode.style.left=this.clientRect.left + "px";
+ elm.domNode.style.top=this.clientRect.top + "px";
+ dojo.style.setOuterWidth(elm.domNode, this.clientWidth);
+ dojo.style.setOuterHeight(elm.domNode, this.clientHeight);
+ }
+
+ },
+
+ hasLayoutAlign: function(child){
+ return dojo.lang.inArray(['left','right','top','bottom','client', 'flood'], child.layoutAlign);
+ },
+
+ addChild: function(child, overrideContainerNode, pos, ref, insertIndex){
+ this._injectChild(child);
+ dojo.widget.html.LayoutPane.superclass.addChild.call(this, child, overrideContainerNode, pos, ref, insertIndex);
+ this.resizeSoon();
+ },
+
+ _injectChild: function(child){
+ if ( this.hasLayoutAlign(child) ){
+ child.domNode.style.position = 'absolute';
+ child.isChild = true;
+ this.filterAllowed(child, 'layoutAlign', ['none', 'left', 'top', 'right', 'bottom', 'client', 'flood']);
+ dojo.html.addClass(child.domNode, "dojoAlign" + dojo.string.capitalize(child.layoutAlign));
+ }
+ },
+
+ removeChild: function(pane){
+ dojo.widget.html.LayoutPane.superclass.removeChild.call(this,pane);
+ dojo.dom.removeNode(pane.domNode);
+ this.resizeSoon();
+ },
+
+ onResized: function(){
+ if ( !this.isVisible() ) {
+ return;
+ }
+
+ //dojo.debug(this.widgetId + ": resized");
+
+ // set position/size for my children
+ this.layoutChildren();
+
+ // notify children that they have been moved/resized
+ this.notifyChildrenOfResize();
+ },
+
+ resizeTo: function(w, h){
+
+ w = Math.max(w, this.getMinWidth());
+ h = Math.max(h, this.getMinHeight());
+
+ dojo.style.setOuterWidth(this.domNode, w);
+ dojo.style.setOuterHeight(this.domNode, h);
+ this.onResized();
+ },
+
+ show: function(){
+ // If this is the first time we are displaying this object,
+ // and the contents are external, then download them.
+ this.loadContents();
+
+ // If this node was created while display=="none" then it
+ // hasn't been laid out yet. Do that now.
+ this.domNode.style.display="";
+ this.onResized();
+ this.domNode.style.display="none";
+ this.domNode.style.visibility="";
+
+ dojo.widget.html.LayoutPane.superclass.show.call(this);
+ },
+
+ getMinWidth: function(){
+
+ //
+ // we need to first get the cumulative width
+ //
+
+ var w = this.minWidth;
+
+ if ((this.layoutAlign == 'left') || (this.layoutAlign == 'right')){
+
+ w = dojo.style.getOuterWidth(this.domNode);
+ }
+
+ for(var i=0; i<this.children.length; i++){
+ var ch = this.children[i];
+ var a = ch.layoutAlign;
+
+ if ((a == 'left') || (a == 'right') || (a == 'client')){
+
+ if (dojo.lang.isFunction(ch.getMinWidth)){
+ w += ch.getMinWidth();
+ }
+ }
+ }
+
+ //
+ // but then we need to check to see if the top/bottom kids are larger
+ //
+
+ for(var i=0; i<this.children.length; i++){
+ var ch = this.children[i];
+ var a = ch.layoutAlign;
+
+ if ((a == 'top') || (a == 'bottom')){
+
+ if (dojo.lang.isFunction(ch.getMinWidth)){
+ w = Math.max(w, ch.getMinWidth());
+ }
+ }
+ }
+
+ return w;
+ },
+
+ getMinHeight: function(){
+
+ //
+ // we need to first get the cumulative height
+ //
+
+ var h = this.minHeight;
+
+ if ((this.layoutAlign == 'top') || (this.layoutAlign == 'bottom')){
+
+ h = dojo.style.getOuterHeight(this.domNode);
+ }
+
+ for(var i=0; i<this.children.length; i++){
+ var ch = this.children[i];
+ var a = ch.layoutAlign;
+
+ if ((a == 'top') || (a == 'bottom') || (a == 'client')){
+
+ if (dojo.lang.isFunction(ch.getMinHeight)){
+ h += ch.getMinHeight();
+ }
+ }
+ }
+
+ //
+ // but then we need to check to see if the left/right kids are larger
+ //
+
+ for(var i=0; i<this.children.length; i++){
+ var ch = this.children[i];
+ var a = ch.layoutAlign;
+
+ if ((a == 'left') || (a == 'right')){
+
+ if (dojo.lang.isFunction(ch.getMinHeight)){
+ h = Math.max(h, ch.getMinHeight());
+ }
+ }
+ }
+
+ return h;
+ }
+});
+
+// This arguments can be specified for the children of a LayoutPane.
+// Since any widget can be specified as a LayoutPane child, mix it
+// into the base widget class. (This is a hack, but it's effective.)
+dojo.lang.extend(dojo.widget.Widget, {
+ layoutAlign: 'none'
+});
+
Added: incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/LinkPane.js
URL: http://svn.apache.org/viewcvs/incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/LinkPane.js?rev=393978&view=auto
==============================================================================
--- incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/LinkPane.js (added)
+++ incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/LinkPane.js Thu Apr 13 16:46:55 2006
@@ -0,0 +1,55 @@
+/*
+ Copyright (c) 2004-2005, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.widget.LinkPane");
+dojo.provide("dojo.widget.html.LinkPane");
+
+//
+// a div that loads from a URL. (Similar to an iframe, but
+// it's in the same environment as the main window)
+//
+
+dojo.require("dojo.widget.LinkPane");
+dojo.require("dojo.widget.*");
+dojo.require("dojo.event.*");
+dojo.require("dojo.io.*");
+dojo.require("dojo.widget.ContentPane");
+dojo.require("dojo.html");
+dojo.require("dojo.style");
+dojo.require("dojo.dom");
+dojo.require("dojo.string");
+
+
+dojo.widget.html.LinkPane = function(){
+ dojo.widget.html.ContentPane.call(this);
+}
+
+dojo.inherits(dojo.widget.html.LinkPane, dojo.widget.html.ContentPane);
+
+dojo.lang.extend(dojo.widget.html.LinkPane, {
+ widgetType: "LinkPane",
+
+ // I'm using a template because the user may specify the input as
+ // <a href="foo.html">label</a>, in which case we need to get rid of the
+ // <a> because we don't want a link.
+ templateString: '<div class="dojoLinkPane"></div>',
+
+ fillInTemplate: function(args, frag){
+ var source = this.getFragNodeRef(frag);
+
+ // If user has specified node contents, they become the label
+ // (the link must be plain text)
+ this.label += source.innerHTML;
+
+ // Copy style info from input node to output node
+ this.domNode.style.cssText = source.style.cssText;
+ dojo.html.addClass(this.domNode, dojo.html.getClass(source));
+ }
+});
Added: incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/Menu.js
URL: http://svn.apache.org/viewcvs/incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/Menu.js?rev=393978&view=auto
==============================================================================
--- incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/Menu.js (added)
+++ incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/Menu.js Thu Apr 13 16:46:55 2006
@@ -0,0 +1,51 @@
+/*
+ Copyright (c) 2004-2005, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.require("dojo.widget.Menu");
+dojo.provide("dojo.widget.html.Menu");
+
+/* HtmlMenu
+ ***********/
+
+dojo.widget.html.Menu = function(){
+ dojo.widget.html.Menu.superclass.constructor.call(this);
+ this.items = [];
+}
+dojo.inherits(dojo.widget.html.Menu, dojo.widget.HtmlWidget);
+
+dojo.lang.extend(dojo.widget.html.Menu, {
+ widgetType: "Menu",
+ isContainer: true,
+
+ // copy children widgets output directly to parent (this node), to avoid
+ // errors trying to insert an <li> under a <div>
+ snarfChildDomOutput: true,
+
+ templateString: '<ul></ul>',
+ templateCssPath: dojo.uri.dojoUri("src/widget/templates/Menu.css"),
+
+ fillInTemplate: function (args, frag){
+ //dojo.widget.HtmlMenu.superclass.fillInTemplate.apply(this, arguments);
+ this.domNode.className = "dojoMenu";
+ },
+
+
+ _register: function (item ) {
+ dojo.event.connect(item, "onSelect", this, "onSelect");
+ this.items.push(item);
+ },
+
+ push: function (item) {
+ this.domNode.appendChild(item.domNode);
+ this._register(item);
+ }
+
+});
+
Added: incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/MenuItem.js
URL: http://svn.apache.org/viewcvs/incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/MenuItem.js?rev=393978&view=auto
==============================================================================
--- incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/MenuItem.js (added)
+++ incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/MenuItem.js Thu Apr 13 16:46:55 2006
@@ -0,0 +1,60 @@
+/*
+ Copyright (c) 2004-2005, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.widget.html.MenuItem");
+
+/* HtmlMenuItem
+ ***************/
+
+dojo.widget.html.MenuItem = function(){
+ dojo.widget.HtmlWidget.call(this);
+}
+dojo.inherits(dojo.widget.html.MenuItem, dojo.widget.HtmlWidget);
+
+dojo.lang.extend(dojo.widget.html.MenuItem, {
+ widgetType: "MenuItem",
+ templateString: '<li class="dojoMenuItem" dojoAttachEvent="onMouseOver; onMouseOut; onMouseDown; onMouseUp; onClick;"></li>',
+ title: "",
+
+ fillInTemplate: function(args, frag){
+ dojo.html.disableSelection(this.domNode);
+
+ if(!dojo.string.isBlank(this.title)){
+ this.domNode.appendChild(document.createTextNode(this.title));
+ }else{
+ this.domNode.appendChild(frag["dojo:"+this.widgetType.toLowerCase()]["nodeRef"]);
+ }
+ },
+
+ onMouseOver: function(e){
+ dojo.html.addClass(this.domNode, "dojoMenuItemHover");
+ },
+
+ onMouseOut: function(e){
+ dojo.html.removeClass(this.domNode, "dojoMenuItemHover");
+ },
+
+ onClick: function(e){ this.onSelect(this, e); },
+ onMouseDown: function(e){},
+ onMouseUp: function(e){},
+
+ // By default, when I am clicked, click the item inside of me
+ onSelect: function (item, e) {
+ var child = dojo.dom.getFirstChildElement(this.domNode);
+ if(child){
+ if(child.click){
+ child.click();
+ }else if(child.href){
+ location.href = child.href;
+ }
+ }
+ }
+});
+
Added: incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/TaskBar.js
URL: http://svn.apache.org/viewcvs/incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/TaskBar.js?rev=393978&view=auto
==============================================================================
--- incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/TaskBar.js (added)
+++ incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/TaskBar.js Thu Apr 13 16:46:55 2006
@@ -0,0 +1,74 @@
+/*
+ Copyright (c) 2004-2005, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.widget.html.TaskBar");
+dojo.provide("dojo.widget.html.TaskBarItem");
+
+dojo.require("dojo.widget.*");
+dojo.require("dojo.widget.FloatingPane");
+dojo.require("dojo.widget.HtmlWidget");
+dojo.require("dojo.event");
+
+// Icon associated w/a floating pane
+dojo.widget.html.TaskBarItem = function(){
+ dojo.widget.TaskBarItem.call(this);
+ dojo.widget.HtmlWidget.call(this);
+}
+dojo.inherits(dojo.widget.html.TaskBarItem, dojo.widget.HtmlWidget);
+
+dojo.lang.extend(dojo.widget.html.TaskBarItem, {
+ // constructor arguments
+ iconSrc: '',
+ caption: 'Untitled',
+ window: null,
+ templatePath: dojo.uri.dojoUri("src/widget/templates/HtmlTaskBarItemTemplate.html"),
+ templateCssPath: dojo.uri.dojoUri("src/widget/templates/HtmlTaskBar.css"),
+
+ fillInTemplate: function() {
+ if ( this.iconSrc != '' ) {
+ var img = document.createElement("img");
+ img.src = this.iconSrc;
+ this.domNode.appendChild(img);
+ }
+ this.domNode.appendChild(document.createTextNode(this.caption));
+ dojo.html.disableSelection(this.domNode);
+ },
+
+ postCreate: function() {
+ this.window=dojo.widget.getWidgetById(this.windowId);
+ this.window.explodeSrc = this.domNode;
+ dojo.event.connect(this.window, "destroy", this, "destroy")
+ },
+
+ onClick: function() {
+ if (this.window.windowState != "minimized") {
+ this.window.bringToTop();
+ } else {
+ this.window.restoreWindow();
+ }
+ }
+});
+
+// Collection of widgets in a bar, like Windows task bar
+dojo.widget.html.TaskBar = function(){
+
+ dojo.widget.html.FloatingPane.call(this);
+ dojo.widget.TaskBar.call(this);
+ this.titleBarDisplay = "none";
+}
+
+dojo.inherits(dojo.widget.html.TaskBar, dojo.widget.html.FloatingPane);
+
+dojo.lang.extend(dojo.widget.html.TaskBar, {
+ addChild: function(child) {
+ var tbi = dojo.widget.createWidget("TaskBarItem",{windowId:child.widgetId, caption: child.title, iconSrc: child.iconSrc} );
+ dojo.widget.html.TaskBar.superclass.addChild.call(this,tbi);
+ }
+});
Added: incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/TimePicker.js
URL: http://svn.apache.org/viewcvs/incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/TimePicker.js?rev=393978&view=auto
==============================================================================
--- incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/TimePicker.js (added)
+++ incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/TimePicker.js Thu Apr 13 16:46:55 2006
@@ -0,0 +1,248 @@
+/*
+ Copyright (c) 2004-2005, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.widget.html.TimePicker");
+dojo.require("dojo.widget.*");
+dojo.require("dojo.widget.HtmlWidget");
+dojo.require("dojo.widget.TimePicker");
+dojo.require("dojo.widget.TimePicker.util");
+dojo.require("dojo.event.*");
+dojo.require("dojo.html");
+
+dojo.widget.html.TimePicker = function(){
+ dojo.widget.TimePicker.call(this);
+ dojo.widget.HtmlWidget.call(this);
+
+
+ var _this = this;
+ // selected time, JS Date object
+ this.time = "";
+ // set following flag to true if a default time should be set
+ this.useDefaultTime = false;
+ // set the following to true to set default minutes to current time, false to // use zero
+ this.useDefaultMinutes = false;
+ // rfc 3339 date
+ this.storedTime = "";
+ // time currently selected in the UI, stored in hours, minutes, seconds in the format that will be actually displayed
+ this.currentTime = {};
+ this.classNames = {
+ selectedTime: "selectedItem"
+ }
+ this.any = "any"
+ // dom node indecies for selected hour, minute, amPm, and "any time option"
+ this.selectedTime = {
+ hour: "",
+ minute: "",
+ amPm: "",
+ anyTime: false
+ }
+
+ // minutes are ordered as follows: ["12", "6", "1", "7", "2", "8", "3", "9", "4", "10", "5", "11"]
+ this.hourIndexMap = ["", 2, 4, 6, 8, 10, 1, 3, 5, 7, 9, 11, 0];
+ // minutes are ordered as follows: ["00", "30", "05", "35", "10", "40", "15", "45", "20", "50", "25", "55"]
+ this.minuteIndexMap = [0, 2, 4, 6, 8, 10, 1, 3, 5, 7, 9, 11];
+
+ this.templatePath = dojo.uri.dojoUri("src/widget/templates/HtmlTimePicker.html");
+ this.templateCssPath = dojo.uri.dojoUri("src/widget/templates/HtmlTimePicker.css");
+
+ this.fillInTemplate = function(){
+ this.initData();
+ this.initUI();
+ }
+
+ this.initData = function() {
+ // FIXME: doesn't currently validate the time before trying to set it
+ // Determine the date/time from stored info, or by default don't
+ // have a set time
+ // FIXME: should normalize against whitespace on storedTime... for now
+ // just a lame hack
+ if(this.storedTime.split("T")[1] && this.storedTime!=" " && this.storedTime.split("T")[1]!="any") {
+ this.time = dojo.widget.TimePicker.util.fromRfcDateTime(this.storedTime, this.useDefaultMinutes);
+ } else if (this.useDefaultTime) {
+ this.time = dojo.widget.TimePicker.util.fromRfcDateTime("", this.useDefaultMinutes);
+ } else {
+ this.selectedTime.anyTime = true;
+ }
+ }
+
+ this.initUI = function() {
+ // set UI to match the currently selected time
+ if(this.time) {
+ var amPmHour = dojo.widget.TimePicker.util.toAmPmHour(this.time.getHours());
+ var hour = amPmHour[0];
+ var isAm = amPmHour[1];
+ var minute = this.time.getMinutes();
+ var minuteIndex = parseInt(minute/5);
+ this.onSetSelectedHour(this.hourIndexMap[hour]);
+ this.onSetSelectedMinute(this.minuteIndexMap[minuteIndex]);
+ this.onSetSelectedAmPm(isAm);
+ } else {
+ this.onSetSelectedAnyTime();
+ }
+ }
+
+ this.setDateTime = function(rfcDate) {
+ this.storedTime = rfcDate;
+ }
+
+ this.onClearSelectedHour = function(evt) {
+ this.clearSelectedHour();
+ }
+
+ this.onClearSelectedMinute = function(evt) {
+ this.clearSelectedMinute();
+ }
+
+ this.onClearSelectedAmPm = function(evt) {
+ this.clearSelectedAmPm();
+ }
+
+ this.onClearSelectedAnyTime = function(evt) {
+ this.clearSelectedAnyTime();
+ if(this.selectedTime.anyTime) {
+ this.selectedTime.anyTime = false;
+ this.time = dojo.widget.TimePicker.util.fromRfcDateTime("", this.useDefaultMinutes);
+ this.initUI();
+ }
+ }
+
+ this.clearSelectedHour = function() {
+ var hourNodes = this.hourContainerNode.getElementsByTagName("td");
+ for (var i=0; i<hourNodes.length; i++) {
+ dojo.html.setClass(hourNodes.item(i), "");
+ }
+ }
+
+ this.clearSelectedMinute = function() {
+ var minuteNodes = this.minuteContainerNode.getElementsByTagName("td");
+ for (var i=0; i<minuteNodes.length; i++) {
+ dojo.html.setClass(minuteNodes.item(i), "");
+ }
+ }
+
+ this.clearSelectedAmPm = function() {
+ var amPmNodes = this.amPmContainerNode.getElementsByTagName("td");
+ for (var i=0; i<amPmNodes.length; i++) {
+ dojo.html.setClass(amPmNodes.item(i), "");
+ }
+ }
+
+ this.clearSelectedAnyTime = function() {
+ dojo.html.setClass(this.anyTimeContainerNode, "anyTimeContainer");
+ }
+
+ this.onSetSelectedHour = function(evt) {
+ this.onClearSelectedAnyTime();
+ this.onClearSelectedHour();
+ this.setSelectedHour(evt);
+ this.onSetTime();
+ }
+
+ this.setSelectedHour = function(evt) {
+ if(evt && evt.target) {
+ dojo.html.setClass(evt.target, this.classNames.selectedTime);
+ this.selectedTime["hour"] = evt.target.innerHTML;
+ } else if (!isNaN(evt)) {
+ var hourNodes = this.hourContainerNode.getElementsByTagName("td");
+ if(hourNodes.item(evt)) {
+ dojo.html.setClass(hourNodes.item(evt), this.classNames.selectedTime);
+ this.selectedTime["hour"] = hourNodes.item(evt).innerHTML;
+ }
+ }
+ this.selectedTime.anyTime = false;
+ }
+
+ this.onSetSelectedMinute = function(evt) {
+ this.onClearSelectedAnyTime();
+ this.onClearSelectedMinute();
+ this.setSelectedMinute(evt);
+ this.selectedTime.anyTime = false;
+ this.onSetTime();
+ }
+
+ this.setSelectedMinute = function(evt) {
+ if(evt && evt.target) {
+ dojo.html.setClass(evt.target, this.classNames.selectedTime);
+ this.selectedTime["minute"] = evt.target.innerHTML;
+ } else if (!isNaN(evt)) {
+ var minuteNodes = this.minuteContainerNode.getElementsByTagName("td");
+ if(minuteNodes.item(evt)) {
+ dojo.html.setClass(minuteNodes.item(evt), this.classNames.selectedTime);
+ this.selectedTime["minute"] = minuteNodes.item(evt).innerHTML;
+ }
+ }
+ }
+
+ this.onSetSelectedAmPm = function(evt) {
+ this.onClearSelectedAnyTime();
+ this.onClearSelectedAmPm();
+ this.setSelectedAmPm(evt);
+ this.selectedTime.anyTime = false;
+ this.onSetTime();
+ }
+
+ this.setSelectedAmPm = function(evt) {
+ if(evt && evt.target) {
+ dojo.html.setClass(evt.target, this.classNames.selectedTime);
+ this.selectedTime["amPm"] = evt.target.innerHTML;
+ } else {
+ evt = evt ? 0 : 1;
+ var amPmNodes = this.amPmContainerNode.getElementsByTagName("td");
+ if(amPmNodes.item(evt)) {
+ dojo.html.setClass(amPmNodes.item(evt), this.classNames.selectedTime);
+ this.selectedTime["amPm"] = amPmNodes.item(evt).innerHTML;
+ }
+ }
+ }
+
+ this.onSetSelectedAnyTime = function(evt) {
+ this.onClearSelectedHour();
+ this.onClearSelectedMinute();
+ this.onClearSelectedAmPm();
+ this.setSelectedAnyTime();
+ this.onSetTime();
+ }
+
+ this.setSelectedAnyTime = function(evt) {
+ this.selectedTime.anyTime = true;
+ dojo.html.setClass(this.anyTimeContainerNode, this.classNames.selectedTime + " " + "anyTimeContainer");
+ }
+
+ this.onClick = function(evt) {
+ dojo.event.browser.stopEvent(evt)
+ }
+
+ this.onSetTime = function() {
+ if(this.selectedTime.anyTime) {
+ this.time = new Date();
+ var tempDateTime = dojo.widget.TimePicker.util.toRfcDateTime(this.time);
+ this.setDateTime(tempDateTime.split("T")[0] + "T" + this.any);
+ } else {
+ var hour = 12;
+ var minute = 0;
+ var isAm = false;
+ if(this.selectedTime["hour"]) {
+ hour = parseInt(this.selectedTime["hour"], 10);
+ }
+ if(this.selectedTime["minute"]) {
+ minute = parseInt(this.selectedTime["minute"], 10);
+ }
+ if(this.selectedTime["amPm"]) {
+ isAm = (this.selectedTime["amPm"].toLowerCase() == "am");
+ }
+ this.time = new Date();
+ this.time.setHours(dojo.widget.TimePicker.util.fromAmPmHour(hour, isAm));
+ this.time.setMinutes(minute);
+ this.setDateTime(dojo.widget.TimePicker.util.toRfcDateTime(this.time));
+ }
+ }
+
+}
+dojo.inherits(dojo.widget.html.TimePicker, dojo.widget.HtmlWidget);
Added: incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/Tooltip.js
URL: http://svn.apache.org/viewcvs/incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/Tooltip.js?rev=393978&view=auto
==============================================================================
--- incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/Tooltip.js (added)
+++ incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/Tooltip.js Thu Apr 13 16:46:55 2006
@@ -0,0 +1,108 @@
+/*
+ Copyright (c) 2004-2005, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.widget.html.Tooltip");
+dojo.require("dojo.widget.HtmlWidget");
+dojo.require("dojo.widget.Tooltip");
+dojo.require("dojo.uri");
+dojo.require("dojo.widget.*");
+dojo.require("dojo.event");
+dojo.require("dojo.style");
+dojo.require("dojo.html");
+
+dojo.widget.html.Tooltip = function(){
+ // mix in the tooltip properties
+ dojo.widget.Tooltip.call(this);
+ dojo.widget.HtmlWidget.call(this);
+}
+dojo.inherits(dojo.widget.html.Tooltip, dojo.widget.HtmlWidget);
+dojo.lang.extend(dojo.widget.html.Tooltip, {
+
+ // Constructor arguments (should these be in tooltip.js rather than html/tooltip.js???)
+ caption: "undefined",
+ delay: 500,
+ connectId: "",
+
+ templatePath: dojo.uri.dojoUri("src/widget/templates/HtmlTooltipTemplate.html"),
+ templateCssPath: dojo.uri.dojoUri("src/widget/templates/HtmlTooltipTemplate.css"),
+
+ containerNode: null,
+ connectNode: null,
+
+ hovering: false,
+ displayed: false,
+
+ fillInTemplate: function(args, frag){
+ if(this.caption != "undefined"){
+ this.domNode.appendChild(document.createTextNode(this.caption));
+ }
+ dojo.html.body().appendChild(this.domNode);
+ this.connectNode = dojo.byId(this.connectId);
+
+ // IE bug workaround
+ this.bgIframe = new dojo.html.BackgroundIframe();
+ },
+
+ postCreate: function(args, frag){
+ var self = this;
+ this.timerEvent = function () { self.display.apply(self); };
+ dojo.event.connect(this.connectNode, "onmouseover", this, "onMouseOver");
+ },
+
+ onMouseOver: function(e) {
+ if( this.displayed ){ return; }
+ this.timerEventId = setTimeout(this.timerEvent, this.delay);
+ dojo.event.connect(document.documentElement, "onmousemove", this, "onMouseMove");
+ },
+
+ onMouseMove: function(e) {
+ this.mouseX = e.pageX || e.clientX + dojo.html.body().scrollLeft;
+ this.mouseY = e.pageY || e.clientY + dojo.html.body().scrollTop;
+ if( !dojo.html.overElement(this.connectNode, e) ){
+ // Note: can't use onMouseOut because the "explode" effect causes
+ // spurious onMouseOut/onMouseOver events (due to interference from outline)
+ this.erase();
+ }
+ },
+
+ display: function() {
+ if ( this.displayed ) { return; }
+
+ this.domNode.style.top = this.mouseY + 15 + "px";
+ this.domNode.style.left = this.mouseX + 10 + "px";
+
+ // if rendering using explosion effect, need to set explosion source
+ this.explodeSrc = [this.mouseX, this.mouseY];
+
+ this.show();
+ this.bgIframe.show(this.domNode);
+
+ this.displayed=true;
+ },
+
+ onShow: function() {
+ // for explode effect, have to display the iframe after the effect completes
+ this.bgIframe.show(this.domNode);
+ dojo.widget.html.Tooltip.superclass.onShow.call(this);
+ },
+
+ erase: function() {
+ if ( this.timerEventId ) {
+ clearTimeout(this.timerEventId);
+ delete this.timerEventId;
+ }
+ if ( this.displayed ) {
+ this.hide();
+ this.bgIframe.hide();
+ this.displayed=false;
+ }
+ dojo.event.disconnect(document.documentElement, "onmousemove", this, "onMouseMove");
+ }
+});
Added: incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/stabile.js
URL: http://svn.apache.org/viewcvs/incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/stabile.js?rev=393978&view=auto
==============================================================================
--- incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/stabile.js (added)
+++ incubator/webwork2/action/src/main/resources/org/apache/struts/action2/static/dojo/src/widget/html/stabile.js Thu Apr 13 16:46:55 2006
@@ -0,0 +1,208 @@
+/*
+ Copyright (c) 2004-2005, The Dojo Foundation
+ All Rights Reserved.
+
+ Licensed under the Academic Free License version 2.1 or above OR the
+ modified BSD license. For more information on Dojo licensing, see:
+
+ http://dojotoolkit.org/community/licensing.shtml
+*/
+
+// Maintain state of widgets when user hits back/forward button
+
+dojo.provide("dojo.widget.html.stabile");
+
+dojo.widget.html.stabile = {
+ // Characters to quote in single-quoted regexprs
+ _sqQuotables: new RegExp("([\\\\'])", "g"),
+
+ // Current depth.
+ _depth: 0,
+
+ // Set to true when calling v.toString, to sniff for infinite
+ // recursion.
+ _recur: false,
+
+ // Levels of nesting of Array and object displays.
+ // If when >= depth, no display or array or object internals.
+ depthLimit: 2
+};
+
+
+
+
+
+//// PUBLIC METHODS
+
+// Get the state stored for the widget with the given ID, or undefined
+// if none.
+//
+dojo.widget.html.stabile.getState = function(id){
+ dojo.widget.html.stabile.setup();
+ return dojo.widget.html.stabile.widgetState[id];
+}
+
+
+// Set the state stored for the widget with the given ID. If isCommit
+// is true, commits all widget state to more stable storage.
+//
+dojo.widget.html.stabile.setState = function(id, state, isCommit){
+ dojo.widget.html.stabile.setup();
+ dojo.widget.html.stabile.widgetState[id] = state;
+ if(isCommit){
+ dojo.widget.html.stabile.commit(dojo.widget.html.stabile.widgetState);
+ }
+}
+
+
+// Sets up widgetState: a hash keyed by widgetId, maps to an object
+// or array writable with "describe". If there is data in the widget
+// storage area, use it, otherwise initialize an empty object.
+//
+dojo.widget.html.stabile.setup = function(){
+ if(!dojo.widget.html.stabile.widgetState){
+ var text = dojo.widget.html.stabile.getStorage().value;
+ dojo.widget.html.stabile.widgetState = text ? dj_eval("("+text+")") : {};
+ }
+}
+
+
+// Commits all widget state to more stable storage, so if the user
+// navigates away and returns, it can be restored.
+//
+dojo.widget.html.stabile.commit = function(state){
+ dojo.widget.html.stabile.getStorage().value = dojo.widget.html.stabile.description(state);
+}
+
+
+// Return a JSON "description string" for the given value.
+// Supports only core JavaScript types with literals, plus Date,
+// and cyclic structures are unsupported.
+// showAll defaults to false -- if true, this becomes a simple symbolic
+// object dumper, but you cannot "eval" the output.
+//
+dojo.widget.html.stabile.description = function(v, showAll){
+ // Save and later restore dojo.widget.html.stabile._depth;
+ var depth = dojo.widget.html.stabile._depth;
+
+ try {
+
+ if(v===void(0)){
+ return "undefined";
+ }
+ if(v===null){
+ return "null";
+ }
+ if(typeof(v)=="boolean" || typeof(v)=="number"
+ || v instanceof Boolean || v instanceof Number){
+ return v.toString();
+ }
+
+ if(typeof(v)=="string" || v instanceof String){
+ // Quote strings and their contents as required.
+ // Replacing by $& fails in IE 5.0
+ var v1 = v.replace(dojo.widget.html.stabile._sqQuotables, "\\$1");
+ v1 = v1.replace(/\n/g, "\\n");
+ v1 = v1.replace(/\r/g, "\\r");
+ // Any other important special cases?
+ return "'"+v1+"'";
+ }
+
+ if(v instanceof Date){
+ // Create a data constructor.
+ return "new Date("+d.getFullYear+","+d.getMonth()+","+d.getDate()+")";
+ }
+
+ var d;
+ if(v instanceof Array || v.push){
+ // "push" test needed for KHTML/Safari, don't know why -cp
+
+ if(depth>=dojo.widget.html.stabile.depthLimit)
+ return "[ ... ]";
+
+ d = "[";
+ var first = true;
+ dojo.widget.html.stabile._depth++;
+ for(var i=0; i<v.length; i++){
+ // Skip functions and undefined values
+ // if(v[i]==undef || typeof(v[i])=="function")
+ // continue;
+ if(first){
+ first = false;
+ }else{
+ d += ",";
+ }
+ d+=arguments.callee(v[i], showAll);
+ }
+ return d+"]";
+ }
+
+ if(v.constructor==Object
+ || v.toString==describeThis){
+ if(depth>=dojo.widget.html.stabile.depthLimit)
+ return "{ ... }";
+
+ // Instanceof Hash is good, or if we just use Objects,
+ // we can say v.constructor==Object.
+ // IE (5?) lacks hasOwnProperty, but perhaps objects do not always
+ // have prototypes??
+ if(typeof(v.hasOwnProperty)!="function" && v.prototype){
+ throw new Error("description: "+v+" not supported by script engine");
+ }
+ var first = true;
+ d = "{";
+ dojo.widget.html.stabile._depth++;
+ for(var key in v){
+ // Skip values that are functions or undefined.
+ if(v[key]==void(0) || typeof(v[key])=="function")
+ continue;
+ if(first){
+ first = false;
+ }else{
+ d += ", ";
+ }
+ kd = key;
+ // If the key is not a legal identifier, use its description.
+ // For strings this will quote the stirng.
+ if(!kd.match(/^[a-zA-Z_][a-zA-Z0-9_]*$/)){
+ kd = arguments.callee(key, showAll);
+ }
+ d += kd+": "+arguments.callee(v[key], showAll);
+ }
+ return d+"}";
+ }
+
+ if(showAll){
+ if(dojo.widget.html.stabile._recur){
+ return objectToString.apply(v, []);
+ }else{
+ dojo.widget.html.stabile._recur = true;
+ return v.toString();
+ }
+ }else{
+ // log("Description? "+v.toString()+", "+typeof(v));
+ throw new Error("Unknown type: "+v);
+ return "'unknown'";
+ }
+
+ } finally {
+ // Always restore the global current depth.
+ dojo.widget.html.stabile._depth = depth;
+ }
+
+}
+
+
+
+//// PRIVATE TO MODULE
+
+// Gets an object (form field) with a read/write "value" property.
+//
+dojo.widget.html.stabile.getStorage = function(){
+ if (dojo.widget.html.stabile.dataField) {
+ return dojo.widget.html.stabile.dataField;
+ }
+ var form = document.forms._dojo_form;
+ return dojo.widget.html.stabile.dataField = form ? form.stabile : {value: ""};
+}
+
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org