You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by we...@apache.org on 2006/08/19 00:37:35 UTC
svn commit: r432759 [1/2] - in
/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget:
html/ svg/
Author: werpu
Date: Fri Aug 18 15:37:34 2006
New Revision: 432759
URL: http://svn.apache.org/viewvc?rev=432759&view=rev
Log:
updated to the current dojo version
Added:
myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/Button2.js
myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/Checkbox.js
myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/ComboBox.js
myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/ContentPane.js
myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/ContextMenu.js
myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/DatePicker.js
myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/DebugConsole.js
myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/DropdownButton.js
myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/LinkPane.js
myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/Menu.js
myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/MenuItem.js
myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/TaskBar.js
myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/TimePicker.js
myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/Tooltip.js
myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/stabile.js
myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/svg/Chart.js
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/Button2.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/Button2.js?rev=432759&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/Button2.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/Button2.js Fri Aug 18 15:37:34 2006
@@ -0,0 +1,25 @@
+/*
+ Copyright (c) 2004-2006, 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
+*/
+
+// this is a stub that will be removed in 0.4, see ../Button2.html for details
+
+dojo.provide("dojo.widget.html.Button2");
+
+dojo.widget.html.Button2 = function(){}
+dojo.inherits(dojo.widget.html.Button2, dojo.widget.html.Button);
+dojo.lang.extend(dojo.widget.html.Button2, { widgetType: "Button2" });
+
+dojo.widget.html.DropDownButton2 = function(){}
+dojo.inherits(dojo.widget.html.DropDownButton2, dojo.widget.html.DropDownButton);
+dojo.lang.extend(dojo.widget.html.DropDownButton2, { widgetType: "DropDownButton2" });
+
+dojo.widget.html.ComboButton2 = function(){}
+dojo.inherits(dojo.widget.html.ComboButton2, dojo.widget.html.ComboButton);
+dojo.lang.extend(dojo.widget.html.ComboButton2, { widgetType: "ComboButton2" });
\ No newline at end of file
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/Checkbox.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/Checkbox.js?rev=432759&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/Checkbox.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/Checkbox.js Fri Aug 18 15:37:34 2006
@@ -0,0 +1,82 @@
+/*
+ Copyright (c) 2004-2006, 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.Checkbox");
+
+dojo.require("dojo.widget.*");
+dojo.require("dojo.event");
+dojo.require("dojo.html");
+
+dojo.widget.defineWidget(
+ "dojo.widget.html.Checkbox",
+ dojo.widget.HtmlWidget,
+ {
+ widgetType: "Checkbox",
+
+ templatePath: dojo.uri.dojoUri('src/widget/templates/HtmlCheckBox.html'),
+
+ srcOn: dojo.uri.dojoUri('src/widget/templates/check_on.gif'),
+ srcOff: dojo.uri.dojoUri('src/widget/templates/check_off.gif'),
+ srcDisabledOn: dojo.uri.dojoUri('src/widget/templates/check_disabled_on.gif'),
+ srcDisabledOff: dojo.uri.dojoUri('src/widget/templates/check_disabled_off.gif'),
+ srcHoverOn: dojo.uri.dojoUri('src/widget/templates/check_hover_on.gif'),
+ srcHoverOff: dojo.uri.dojoUri('src/widget/templates/check_hover_off.gif'),
+
+ imgSrc: null,
+
+ // parameters
+ disabled: "enabled",
+ name: "",
+ checked: false,
+ tabIndex: -1,
+
+ imgNode: null,
+ inputNode: null,
+
+ postMixInProperties: function(){
+ // set correct source for image before instantiating template
+ this._updateImgSrc();
+ },
+
+ onMouseUp: function(){
+ if(this.disabled == "enabled"){
+ this.checked = !this.checked;
+ this.inputNode.checked = this.checked;
+ this._updateImgSrc();
+ }
+ },
+
+ onMouseOver: function(){
+ this.hover=true;
+ this._updateImgSrc();
+ },
+
+ onMouseOut: function(){
+ this.hover=false;
+ this._updateImgSrc();
+ },
+
+ _updateImgSrc: function(){
+ if(this.disabled == "enabled"){
+ if(this.hover){
+ this.imgSrc = this.checked ? this.srcHoverOn : this.srcHoverOff;
+ }else{
+ this.imgSrc = this.checked ? this.srcOn : this.srcOff;
+ }
+ }else{
+ this.imgSrc = this.checked ? this.srcDisabledOn : this.srcDisabledOff;
+ }
+ if(this.imgNode){
+ this.imgNode.src = this.imgSrc;
+ }
+ }
+ }
+);
+
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/ComboBox.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/ComboBox.js?rev=432759&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/ComboBox.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/ComboBox.js Fri Aug 18 15:37:34 2006
@@ -0,0 +1,611 @@
+/*
+ Copyright (c) 2004-2006, 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.lfx.*");
+dojo.require("dojo.dom");
+dojo.require("dojo.html");
+dojo.require("dojo.string");
+dojo.require("dojo.widget.html.stabile");
+
+dojo.widget.defineWidget(
+ "dojo.widget.html.ComboBox",
+ [dojo.widget.HtmlWidget, dojo.widget.ComboBox],
+ {
+ autoComplete: true,
+ formInputName: "",
+ name: "", // clone in the name from the DOM node
+ textInputNode: null,
+ comboBoxValue: null,
+ comboBoxSelectionValue: null,
+ optionsListWrapper: null,
+ optionsListNode: null,
+ downArrowNode: null,
+ cbTableNode: null,
+ searchTimer: null,
+ searchDelay: 100,
+ dataUrl: "",
+ fadeTime: 200,
+ // maxListLength limits list to X visible rows, scroll on rest
+ maxListLength: 8,
+ // mode can also be "remote" for JSON-returning live search or "html" for
+ // dumber live search
+ mode: "local",
+ selectedResult: null,
+ _highlighted_option: null,
+ _prev_key_backspace: false,
+ _prev_key_esc: false,
+ _result_list_open: false,
+ _gotFocus: false,
+ _mouseover_list: false,
+ dataProviderClass: "dojo.widget.ComboBoxDataProvider",
+
+ templatePath: dojo.uri.dojoUri("src/widget/templates/HtmlComboBox.html"),
+ templateCssPath: dojo.uri.dojoUri("src/widget/templates/HtmlComboBox.css"),
+
+ setValue: function(value) {
+ this.comboBoxValue.value = value;
+ if (this.textInputNode.value != value) { // prevent mucking up of selection
+ 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){
+ // khtml 3.5.2 has selection* methods as does webkit nightlies from 2005-06-22
+ if(dojo.lang.isNumber(element.selectionStart)){
+ // 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 = document.selection.createRange().duplicate();
+ var ntr = element.createTextRange();
+ tr.move("character",0);
+ ntr.move("character",0);
+ try {
+ // If control doesnt have focus, you get an exception.
+ // Seems to happen on reverse-tab, but can also happen on tab (seems to be a race condition - only happens sometimes).
+ // There appears to be no workaround for this - googled for quite a while.
+ ntr.setEndPoint("EndToEnd", tr);
+ return String(ntr.text).replace(/\r/g,"").length;
+ } catch (e) {
+ return 0; // If focus has shifted, 0 is fine for caret pos.
+ }
+
+ }
+ },
+
+ setCaretPos: function(element, location){
+ location = parseInt(location);
+ this.setSelectedRange(element, location, location);
+ },
+
+ setSelectedRange: function(element, start, end){
+ if(!end){ end = element.value.length; } // NOTE: Strange - should be able to put caret at start of text?
+ // 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);
+ element.dispatchEvent(te);
+ }
+ }
+ },
+
+ // does the keyboard related stuff
+ _handleKeyEvents: function(evt){
+ if(evt.ctrlKey || evt.altKey){ return; }
+
+ // reset these
+ this._prev_key_backspace = false;
+ this._prev_key_esc = false;
+
+ var k = dojo.event.browser.keys;
+ var doSearch = true;
+
+ // mozilla quirk
+ // space has no keyCode in mozilla
+ var keyCode = evt.keyCode;
+ if(keyCode==0 && evt.charCode==k.KEY_SPACE){
+ keyCode = k.KEY_SPACE;
+ }
+ switch(keyCode){
+ case k.KEY_DOWN_ARROW:
+ if(!this._result_list_open){
+ this.startSearchFromInput();
+ }
+ this.highlightNextOption();
+ dojo.event.browser.stopEvent(evt);
+ return;
+ case k.KEY_UP_ARROW:
+ this.highlightPrevOption();
+ dojo.event.browser.stopEvent(evt);
+ return;
+ case k.KEY_ENTER:
+ // prevent submitting form if we press enter with list open
+ if(this._result_list_open){
+ dojo.event.browser.stopEvent(evt);
+ }
+ // fallthrough
+ case k.KEY_TAB:
+ // using linux alike tab for autocomplete
+ if(!this.autoComplete && this._result_list_open && this._highlighted_option){
+ dojo.event.browser.stopEvent(evt);
+ this.selectOption({ 'target': this._highlighted_option, 'noHide': true });
+
+ // put caret last
+ this.setSelectedRange(this.textInputNode, this.textInputNode.value.length, null);
+ }else{
+ this.selectOption();
+ return;
+ }
+ break;
+ case k.KEY_SPACE:
+ if(this._result_list_open && this._highlighted_option){
+ dojo.event.browser.stopEvent(evt);
+ this.selectOption();
+ this.hideResultList();
+ return;
+ }
+ break;
+ case k.KEY_ESCAPE:
+ this.hideResultList();
+ this._prev_key_esc = true;
+ return;
+ case k.KEY_BACKSPACE:
+ this._prev_key_backspace = true;
+ if(!this.textInputNode.value.length){
+ this.setAllValues("", "");
+ this.hideResultList();
+ doSearch = false;
+ }
+ break;
+ case k.KEY_RIGHT_ARROW: // fall through
+ case k.KEY_LEFT_ARROW: // fall through
+ case k.KEY_SHIFT:
+ doSearch = false;
+ break;
+ default:// non char keys (F1-F12 etc..) shouldn't open list
+ if(evt.charCode==0){
+ doSearch = false;
+ }
+ }
+
+ if(this.searchTimer){
+ clearTimeout(this.searchTimer);
+ }
+ if(doSearch){
+ // if we have gotten this far we dont want to keep our highlight
+ this.blurOptionNode();
+
+ // need to wait a tad before start search so that the event bubbles through DOM and we have value visible
+ this.searchTimer = setTimeout(dojo.lang.hitch(this, this.startSearchFromInput), this.searchDelay);
+ }
+ },
+
+ onKeyDown: function(evt){
+ // IE needs to stop keyDown others need to stop keyPress
+ if(!document.createEvent){ // only IE
+ this._handleKeyEvents(evt);
+ }
+ // FIXME: What about ESC ??
+ },
+
+ onKeyPress: function(evt){
+ if(document.createEvent){ // never IE
+ this._handleKeyEvents(evt);
+ }
+ },
+
+ onKeyUp: function(evt){
+ this.setValue(this.textInputNode.value);
+ },
+
+ setSelectedValue: function(value){
+ // FIXME, not sure what to do here!
+ this.comboBoxSelectionValue.value = value;
+ },
+
+ setAllValues: function(value1, value2){
+ this.setValue(value1);
+ this.setSelectedValue(value2);
+ },
+
+ // opera, khtml, safari doesnt support node.scrollIntoView(), workaround
+ scrollIntoView: function(){
+ var node = this._highlighted_option;
+ var parent = this.optionsListNode;
+ // don't rely on that node.scrollIntoView works just because the function is there
+ // it doesnt work in Konqueror or Opera even though the function is there and probably
+ // not safari either
+ // dont like browser sniffs implementations but sometimes you have to use it
+ if(dojo.render.html.ie || dojo.render.html.mozilla){
+ // IE, mozilla
+ node.scrollIntoView(false);
+ }else{
+ var parentBottom = parent.scrollTop + dojo.style.getInnerHeight(parent);
+ var nodeBottom = node.offsetTop + dojo.style.getOuterHeight(node);
+ if(parentBottom < nodeBottom){
+ parent.scrollTop += (nodeBottom - parentBottom);
+ }else if(parent.scrollTop > node.offsetTop){
+ parent.scrollTop -= (parent.scrollTop - node.offsetTop);
+ }
+ }
+ },
+
+ // does the actual highlight
+ focusOptionNode: function(node){
+ if(this._highlighted_option != node){
+ this.blurOptionNode();
+ this._highlighted_option = node;
+ dojo.html.addClass(this._highlighted_option, "dojoComboBoxItemHighlight");
+ }
+ },
+
+ // removes highlight on highlighted
+ blurOptionNode: function(){
+ if(this._highlighted_option){
+ dojo.html.removeClass(this._highlighted_option, "dojoComboBoxItemHighlight");
+ this._highlighted_option = null;
+ }
+ },
+
+ highlightNextOption: function(){
+ if((!this._highlighted_option) || !this._highlighted_option.parentNode){
+ this.focusOptionNode(this.optionsListNode.firstChild);
+ }else if(this._highlighted_option.nextSibling){
+ this.focusOptionNode(this._highlighted_option.nextSibling);
+ }
+ this.scrollIntoView();
+ },
+
+ highlightPrevOption: function(){
+ if(this._highlighted_option && this._highlighted_option.previousSibling){
+ this.focusOptionNode(this._highlighted_option.previousSibling);
+ }else{
+ this._highlighted_option = null;
+ this.hideResultList();
+ return;
+ }
+ this.scrollIntoView();
+ },
+
+ itemMouseOver: function(evt){
+ this.focusOptionNode(evt.target);
+ dojo.html.addClass(this._highlighted_option, "dojoComboBoxItemHighlight");
+ },
+
+ itemMouseOut: function(evt){
+ this.blurOptionNode();
+ },
+
+ 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";
+
+ var source = this.getFragNodeRef(frag);
+ dojo.html.copyStyle(this.domNode, source);
+
+ var dpClass;
+ if(this.mode == "remote"){
+ dpClass = dojo.widget.incrementalComboBoxDataProvider;
+ }else if(typeof this.dataProviderClass == "string"){
+ dpClass = dojo.evalObjPath(this.dataProviderClass)
+ }else{
+ dpClass = this.dataProviderClass;
+ }
+ this.dataProvider = new dpClass();
+ this.dataProvider.init(this, this.getFragNodeRef(frag));
+
+ // Prevent IE bleed-through problem
+ this.optionsIframe = new dojo.html.BackgroundIframe(this.optionsListWrapper);
+ this.optionsIframe.size([0,0,0,0]);
+ },
+
+
+ focus: function(){
+ // summary
+ // set focus to input node from code
+ this.tryFocus();
+ },
+
+ openResultList: function(results){
+ this.clearResultList();
+ if(!results.length){
+ this.hideResultList();
+ }
+
+ 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 character at the end of the input
+ if((cpos+1) > this.textInputNode.value.length){
+ // only add to input node as we would overwrite Capitalisation of chars
+ this.textInputNode.value += results[0][0].substr(cpos);
+ // 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 = "dojoComboBoxItem "+((even) ? "dojoComboBoxItemEven" : "dojoComboBoxItemOdd");
+ even = (!even);
+ this.optionsListNode.appendChild(td);
+ dojo.event.connect(td, "onmouseover", this, "itemMouseOver");
+ dojo.event.connect(td, "onmouseout", this, "itemMouseOut");
+ }
+ }
+
+ // show our list (only if we have content, else nothing)
+ this.showResultList();
+ },
+
+ onFocusInput: function(){
+ this._hasFocus = true;
+ },
+
+ onBlurInput: function(){
+ this._hasFocus = false;
+ this._handleBlurTimer(true, 500);
+ },
+
+ // collect all blur timers issues here
+ _handleBlurTimer: function(/*Boolean*/clear, /*Number*/ millisec){
+ if(this.blurTimer && (clear || millisec)){
+ clearTimeout(this.blurTimer);
+ }
+ if(millisec){ // we ignore that zero is false and never sets as that never happens in this widget
+ this.blurTimer = dojo.lang.setTimeout(this, "checkBlurred", millisec);
+ }
+ },
+
+ // these 2 are needed in IE and Safari as inputTextNode loses focus when scrolling optionslist
+ _onMouseOver: function(evt){
+ if(!this._mouseover_list){
+ this._handleBlurTimer(true, 0);
+ this._mouseover_list = true;
+ }
+ },
+
+ _onMouseOut:function(evt){
+ var relTarget = evt.relatedTarget;
+ if(!relTarget || relTarget.parentNode!=this.optionsListNode){
+ this._mouseover_list = false;
+ this._handleBlurTimer(true, 100);
+ this.tryFocus();
+ }
+ },
+
+ _isInputEqualToResult: function(result){
+ input = this.textInputNode.value;
+ if(!this.dataProvider.caseSensitive){
+ input = input.toLowerCase();
+ result = result.toLowerCase();
+ }
+ return (input == result);
+ },
+
+ _isValidOption: function(){
+ tgt = dojo.dom.firstElement(this.optionsListNode);
+ isValidOption = false;
+ while(!isValidOption && tgt){
+ if(this._isInputEqualToResult(tgt.getAttribute("resultName"))){
+ isValidOption = true;
+ }else{
+ tgt = dojo.dom.nextElement(tgt);
+ }
+ }
+ return isValidOption;
+ },
+
+ checkBlurred: function(){
+ if(!this._hasFocus && !this._mouseover_list){
+ this.hideResultList();
+ // clear the list if the user empties field and moves away.
+ if(!this.textInputNode.value.length){
+ this.setAllValues("", "");
+ return;
+ }
+
+ isValidOption = this._isValidOption();
+ // enforce selection from option list
+ if(this.forceValidOption && !isValidOption){
+ this.setAllValues("", "");
+ return;
+ }
+ if(!isValidOption){// clear
+ this.setSelectedValue("");
+ }
+ }
+ },
+
+ sizeBackgroundIframe: function(){
+ var w = dojo.style.getOuterWidth(this.optionsListNode);
+ var h = dojo.style.getOuterHeight(this.optionsListNode);
+ if( w==0 || h==0 ){
+ // need more time to calculate size
+ dojo.lang.setTimeout(this, "sizeBackgroundIframe", 100);
+ return;
+ }
+ if(this._result_list_open){
+ this.optionsIframe.size([0,0,w,h]);
+ }
+ },
+
+ selectOption: function(evt){
+ var tgt = null;
+ if(!evt){
+ evt = { target: this._highlighted_option };
+ }
+
+ if(!dojo.dom.isDescendantOf(evt.target, this.optionsListNode)){
+ // handle autocompletion where the the user has hit ENTER or TAB
+
+ // if the input is empty do nothing
+ if(!this.textInputNode.value.length){
+ return;
+ }
+ tgt = dojo.dom.firstElement(this.optionsListNode);
+
+ // user has input value not in option list
+ if(!tgt || !this._isInputEqualToResult(tgt.getAttribute("resultName"))){
+ return;
+ }
+ // otherwise the user has accepted the autocompleted value
+ }else{
+ tgt = evt.target;
+ }
+
+ while((tgt.nodeType!=1)||(!tgt.getAttribute("resultName"))){
+ tgt = tgt.parentNode;
+ if(tgt === document.body){
+ return false;
+ }
+ }
+
+ this.textInputNode.value = tgt.getAttribute("resultName");
+ this.selectedResult = [tgt.getAttribute("resultName"), tgt.getAttribute("resultValue")];
+ this.setAllValues(tgt.getAttribute("resultName"), tgt.getAttribute("resultValue"));
+ if(!evt.noHide){
+ this.hideResultList();
+ this.setSelectedRange(this.textInputNode, 0, null);
+ }
+ this.tryFocus();
+ },
+
+ clearResultList: function(){
+ var oln = this.optionsListNode;
+ while(oln.firstChild){
+ dojo.event.disconnect(oln.firstChild, "onmouseover", this, "itemMouseOver");
+ dojo.event.disconnect(oln.firstChild, "onmouseout", this, "itemMouseOut");
+ oln.removeChild(oln.firstChild);
+ }
+ },
+
+ hideResultList: function(){
+ if(this._result_list_open){
+ this._result_list_open = false;
+ this.optionsIframe.size([0,0,0,0]);
+ dojo.lfx.fadeHide(this.optionsListNode, this.fadeTime).play();
+ }
+ },
+
+ showResultList: function(){
+ // Our dear friend IE doesnt take max-height so we need to calculate that on our own every time
+ var childs = this.optionsListNode.childNodes;
+ if(childs.length){
+ var visibleCount = this.maxListLength;
+ if(childs.length < visibleCount){
+ visibleCount = childs.length;
+ }
+
+ with(this.optionsListNode.style){
+ display = "";
+ height = ((visibleCount) ? (dojo.style.getOuterHeight(childs[0]) * visibleCount) : 0)+"px";
+ width = dojo.html.getOuterWidth(this.cbTableNode)-2+"px";
+ }
+ // only fadein once (flicker)
+ if(!this._result_list_open){
+ dojo.html.setOpacity(this.optionsListNode, 0);
+ dojo.lfx.fadeIn(this.optionsListNode, this.fadeTime).play();
+ }
+
+ // prevent IE bleed through
+ this._iframeTimer = dojo.lang.setTimeout(this, "sizeBackgroundIframe", 200);
+ this._result_list_open = true;
+ }else{
+ this.hideResultList();
+ }
+ },
+
+ handleArrowClick: function(){
+ this._handleBlurTimer(true, 0);
+ this.tryFocus();
+ if(this._result_list_open){
+ this.hideResultList();
+ }else{
+ this.startSearchFromInput();
+ }
+ },
+
+ tryFocus: function(){
+ try {
+ this.textInputNode.focus();
+ } catch (e) {
+ // element isn't focusable if disabled, or not visible etc - not easy to test for.
+ };
+ },
+
+ 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");
+ dojo.event.connect(this.textInputNode, "onblur", this, "onBlurInput");
+ dojo.event.connect(this.textInputNode, "onfocus", this, "onFocusInput");
+
+ var s = dojo.widget.html.stabile.getState(this.widgetId);
+ if (s) {
+ this.setState(s);
+ }
+ }
+ }
+);
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/ContentPane.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/ContentPane.js?rev=432759&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/ContentPane.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/ContentPane.js Fri Aug 18 15:37:34 2006
@@ -0,0 +1,566 @@
+/*
+ Copyright (c) 2004-2006, 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.HtmlWidget");
+dojo.require("dojo.widget.ContentPane");
+dojo.require("dojo.string");
+dojo.require("dojo.string.extras");
+dojo.require("dojo.style");
+
+dojo.widget.html.ContentPane = function(){
+ this._onLoadStack = [];
+ this._onUnLoadStack = [];
+ dojo.widget.HtmlWidget.call(this);
+}
+dojo.inherits(dojo.widget.html.ContentPane, dojo.widget.HtmlWidget);
+
+dojo.lang.extend(dojo.widget.html.ContentPane, {
+ widgetType: "ContentPane",
+ isContainer: true,
+
+ // remote loading options
+ adjustPaths: true,
+ href: "",
+ extractContent: true,
+ parseContent: true,
+ cacheContent: true,
+ preload: false, // force load of data even if pane is hidden
+ refreshOnShow: false,
+ handler: "", // generate pane content from a java function
+ executeScripts: false, // if true scripts in content will be evaled after content is set and parsed
+ scriptScope: null, // scopeContainer for downloaded scripts
+
+ // If the user want a global in the remote script he/she just omitts the var
+ // examples:
+ //--------------------------
+ // these gets collected by scriptScope and is reached by dojo.widget.byId('..').scriptScope.myCustomproperty
+ // this.myString = "dojo is a great javascript toolkit!";
+ //
+ // this.alertMyString = function(){
+ // alert(myString);
+ // }
+ // -------------------------
+ // these go into the global namespace (window) notice lack of var, equiv to window.myString
+ // myString = "dojo is a javascript toolkit!";
+ //
+ // alertMyString = function(){
+ // alert(myString);
+ // }
+
+
+ // private
+ _remoteStyles: null, // array of stylenodes inserted to document head
+ // by remote content, used when we clean up for new content
+
+ _callOnUnLoad: false, // used by setContent and _handleDefults, makes sure onUnLoad is only called once
+
+ postCreate: function(args, frag, parentComp){
+ if ( this.handler != "" ){
+ this.setHandler(this.handler);
+ }
+ if(this.isShowing()||this.preload){ this.loadContents(); }
+ },
+
+ show: function(){
+ // if refreshOnShow is true, reload the contents every time; otherwise, load only the first time
+ if(this.refreshOnShow){
+ this.refresh();
+ }else{
+ this.loadContents();
+ }
+ dojo.widget.html.ContentPane.superclass.show.call(this);
+ },
+
+ refresh: function(){
+ this.isLoaded=false;
+ this.loadContents();
+ },
+
+ 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);
+ }
+ },
+
+
+ setUrl: function(/*String*/ url) {
+ // summary:
+ // Reset the (external defined) content of this pane and replace with new url
+ this.href = url;
+ this.isLoaded = false;
+ if ( this.preload || this.isShowing() ){
+ this.loadContents();
+ }
+ },
+
+ _downloadExternalContent: function(url, useCache) {
+ this._handleDefaults("Loading...", "onDownloadStart");
+ var self = this;
+ dojo.io.bind({
+ url: url,
+ useCache: useCache,
+ preventCache: !useCache,
+ mimetype: "text/html",
+ handler: function(type, data, e) {
+ if(type == "load") {
+ self.onDownloadEnd.call(self, url, data);
+ } else {
+ // works best when from a live server instead of from file system
+ self._handleDefaults.call(self, "Error loading '" + url + "' (" + e.status + " "+ e.statusText + ")", "onDownloadError");
+ self.onLoad();
+ }
+ }
+ });
+ },
+
+ // called when setContent is finished
+ onLoad: function(e){
+ this._runStack("_onLoadStack");
+ },
+
+ // called before old content is cleared
+ onUnLoad: function(e){
+ this._runStack("_onUnLoadStack");
+ this.scriptScope = null;
+ },
+
+ _runStack: function(stName){
+ var st = this[stName]; var err = "";
+ for(var i = 0;i < st.length; i++){
+ try{
+ st[i].call(this.scriptScope);
+ }catch(e){
+ err += "\n"+st[i]+" failed: "+e.description;
+ }
+ }
+ this[stName] = [];
+
+ if(err.length){
+ var name = (stName== "_onLoadStack") ? "addOnLoad" : "addOnUnLoad";
+ this._handleDefaults(name+" failure\n "+err, "onExecError", true);
+ }
+ },
+
+ addOnLoad: function(obj, func){
+ // summary
+ // same as to dojo.addOnLoad but does not take "function_name" as a string
+ this._pushOnStack(this._onLoadStack, obj, func);
+ },
+
+ addOnUnLoad: function(obj, func){
+ // summary
+ // same as to dojo.addUnOnLoad but does not take "function_name" as a string
+ this._pushOnStack(this._onUnLoadStack, obj, func);
+ },
+
+ _pushOnStack: function(stack, obj, func){
+ if(typeof func == 'undefined') {
+ stack.push(obj);
+ }else{
+ stack.push(function(){ obj[func](); });
+ }
+ },
+
+ destroy: function(){
+ // make sure we call onUnLoad
+ this.onUnLoad();
+ dojo.widget.html.ContentPane.superclass.destroy.call(this);
+ },
+
+ // called when content script eval error or Java error occurs, preventDefault-able
+ onExecError: function(e){ /*stub*/ },
+
+ // called on DOM faults, require fault etc in content, preventDefault-able
+ onContentError: function(e){ /*stub*/ },
+
+ // called when download error occurs, preventDefault-able
+ onDownloadError: function(e){ /*stub*/ },
+
+ // called before download starts, preventDefault-able
+ onDownloadStart: function(e){ /*stub*/ },
+
+ // called when download is finished
+ onDownloadEnd: function(url, data){
+ data = this.splitAndFixPaths(data, url);
+ this.setContent(data);
+ },
+
+ // usefull if user wants to prevent default behaviour ie: _setContent("Error...")
+ _handleDefaults: function(e, handler, useAlert){
+ if(!handler){ handler = "onContentError"; }
+ if(dojo.lang.isString(e)){
+ e = {
+ "text": e,
+ "toString": function(){ return this.text; }
+ }
+ }
+ if(typeof e.returnValue != "boolean"){
+ e.returnValue = true;
+ }
+ if(typeof e.preventDefault != "function"){
+ e.preventDefault = function(){
+ this.returnValue = false;
+ }
+ }
+ // call our handler
+ this[handler](e);
+ if(e.returnValue){
+ if(useAlert){
+ alert(e.toString());
+ }else{
+ if(this._callOnUnLoad){
+ this.onUnLoad(); // makes sure scripts can clean up after themselves, before we setContent
+ }
+ this._callOnUnLoad = false; // makes sure we dont try to call onUnLoad again on this event,
+ // ie onUnLoad before 'Loading...' but not before clearing 'Loading...'
+ this._setContent(e.toString());
+ }
+ }
+ },
+
+
+ splitAndFixPaths: function(/*String*/s, /*dojo.uri.Uri?*/url){
+ // summary:
+ // fixes all remote paths in (hopefully) all cases for example images, remote scripts, links etc.
+ // splits up content in different pieces, scripts, title, style, link and whats left becomes .xml
+
+ if(!url) { url = "./"; } // point to this page if not set
+ if(!s) { return ""; }
+
+ // fix up paths in data
+ var titles = []; var scripts = []; var linkStyles = [];
+ var styles = []; var remoteScripts = []; var requires = [];
+
+ // khtml is much more picky about dom faults, you can't for example attach a style node under body of document
+ // must go into head, as does a title node, so we need to cut out those tags
+ // cut out title tags
+ var match = [];
+ while(match){
+ match = s.match(/<title[^>]*>([\s\S]*?)<\/title>/i); // can't match with dot as that
+ if(!match){ break;} //doesnt match newline in js
+ titles.push(match[1]);
+ s = s.replace(/<title[^>]*>[\s\S]*?<\/title>/i, "");
+ }
+
+ // cut out <style> url(...) </style>, as that bails out in khtml
+ var match = [];
+ while(match){
+ match = s.match(/<style[^>]*>([\s\S]*?)<\/style>/i);
+ if(!match){ break; }
+ styles.push(dojo.style.fixPathsInCssText(match[1], url));
+ s = s.replace(/<style[^>]*?>[\s\S]*?<\/style>/i, "");
+ }
+
+ // attributepaths one tag can have multiple paths example:
+ // <input src="..." style="url(..)"/> or <a style="url(..)" href="..">
+ // strip out the tag and run fix on that.
+ // this guarantees that we won't run replace another tag's attribute + it was easier do
+ var pos = 0; var pos2 = 0; var stop = 0 ;var str = ""; var fixedPath = "";
+ var attr = []; var fix = ""; var tagFix = ""; var tag = ""; var regex = "";
+ while(pos>-1){
+ pos = s.search(/<[a-z][a-z0-9]*[^>]*\s(?:(?:src|href|style)=[^>])+[^>]*>/i);
+ if(pos==-1){ break; }
+ str += s.substring(0, pos);
+ s = s.substring(pos, s.length);
+ tag = s.match(/^<[a-z][a-z0-9]*[^>]*>/i)[0];
+ s = s.substring(tag.length, s.length);
+
+ // loop through attributes
+ pos2 = 0; tagFix = ""; fix = ""; regex = ""; var regexlen = 0;
+ while(pos2!=-1){
+ // slices up before next attribute check, values from previous loop
+ tagFix += tag.substring(0, pos2) + fix;
+ tag = tag.substring(pos2+regexlen, tag.length);
+
+ // fix next attribute or bail out when done
+ // hopefully this charclass covers most urls
+ attr = tag.match(/ (src|href|style)=(['"]?)([\w()\[\]\/.,\\'"-:;#=&?\s@]+?)\2/i);
+ if(!attr){ break; }
+
+ switch(attr[1].toLowerCase()){
+ case "src":// falltrough
+ case "href":
+ // this hopefully covers most common protocols
+ if(attr[3].search(/^(?:[#]|(?:(?:https?|ftps?|file|javascript|mailto|news):))/)==-1){
+ fixedPath = (new dojo.uri.Uri(url, attr[3]).toString());
+ } else {
+ pos2 = pos2 + attr[3].length;
+ continue;
+ }
+ break;
+ case "style":// style
+ fixedPath = dojo.style.fixPathsInCssText(attr[3], url);
+ break;
+ default:
+ pos2 = pos2 + attr[3].length;
+ continue;
+ }
+
+ regex = " " + attr[1] + "=" + attr[2] + attr[3] + attr[2];
+ regexlen = regex.length;
+ fix = " " + attr[1] + "=" + attr[2] + fixedPath + attr[2];
+ pos2 = tag.search(new RegExp(dojo.string.escapeRegExp(regex)));
+ }
+ str += tagFix + tag;
+ pos = 0; // reset for next mainloop
+ }
+ s = str+s;
+
+ // cut out all script tags, push them into scripts array
+ match = []; var tmp = [];
+ while(match){
+ match = s.match(/<script([^>]*)>([\s\S]*?)<\/script>/i);
+ if(!match){ break; }
+ if(match[1]){
+ attr = match[1].match(/src=(['"]?)([^"']*)\1/i);
+ if(attr){
+ // remove a dojo.js or dojo.js.uncompressed.js from remoteScripts
+ // we declare all files with dojo.js as bad, regardless of folder
+ var tmp = attr[2].search(/.*(\bdojo\b(?:\.uncompressed)?\.js)$/);
+ if(tmp > -1){
+ dojo.debug("Security note! inhibit:"+attr[2]+" from beeing loaded again.");
+ }else{
+ remoteScripts.push(attr[2]);
+ }
+ }
+ }
+ if(match[2]){
+ // strip out all djConfig variables from script tags nodeValue
+ // this is ABSOLUTLY needed as reinitialize djConfig after dojo is initialised
+ // makes a dissaster greater than Titanic, update remove writeIncludes() to
+ var sc = match[2].replace(/(?:var )?\bdjConfig\b(?:[\s]*=[\s]*\{[^}]+\}|\.[\w]*[\s]*=[\s]*[^;\n]*)?;?|dojo\.hostenv\.writeIncludes\(\s*\);?/g, "");
+ if(!sc){ continue; }
+
+ // cut out all dojo.require (...) calls, if we have execute
+ // scripts false widgets dont get there require calls
+ // does suck out possible widgetpackage registration as well
+ tmp = [];
+ while(tmp && requires.length<100){
+ tmp = sc.match(/dojo\.(?:(?:require(?:After)?(?:If)?)|(?:widget\.(?:manager\.)?registerWidgetPackage)|(?:(?:hostenv\.)?setModulePrefix))\((['"]).*?\1\)\s*;?/);
+ if(!tmp){ break;}
+ requires.push(tmp[0]);
+ sc = sc.replace(tmp[0], "");
+ }
+ scripts.push(sc);
+ }
+ s = s.replace(/<script[^>]*>[\s\S]*?<\/script>/i, "");
+ }
+
+ // scan for scriptScope in html eventHandlers and replace with link to this pane
+ if(this.executeScripts){
+ var regex = /(<[a-zA-Z][a-zA-Z0-9]*\s[^>]*\S=(['"])[^>]*[^\.\]])scriptScope([^>]*>)/;
+ var pos = 0;var str = "";match = [];var cit = "";
+ while(pos > -1){
+ pos = s.search(regex);
+ if(pos > -1){
+ cit = ((RegExp.$2=="'") ? '"': "'");
+ str += s.substring(0, pos);
+ s = s.substr(pos).replace(regex, "$1dojo.widget.byId("+ cit + this.widgetId + cit + ").scriptScope$3");
+ }
+ }
+ s = str + s;
+ }
+
+ // cut out all <link rel="stylesheet" href="..">
+ match = [];
+ while(match){
+ match = s.match(/<link ([^>]*rel=['"]?stylesheet['"]?[^>]*)>/i);
+ if(!match){ break; }
+ attr = match[1].match(/href=(['"]?)([^'">]*)\1/i);
+ if(attr){
+ linkStyles.push(attr[2]);
+ }
+ s = s.replace(new RegExp(match[0]), "");
+ }
+
+ return {"xml": s, // Object
+ "styles": styles,
+ "linkStyles": linkStyles,
+ "titles": titles,
+ "requires": requires,
+ "scripts": scripts,
+ "remoteScripts": remoteScripts,
+ "url": url};
+ },
+
+
+ _setContent: function(/*String*/ xml){
+ // summary:
+ // private internal function without path regExpCheck and no onLoad calls aftervards
+
+ // remove old children from current content
+ this.destroyChildren();
+
+ // remove old stylenodes from HEAD
+ if(this._remoteStyles){
+ for(var i = 0; i < this._remoteStyles.length; i++){
+ if(this._remoteStyles[i] && this._remoteStyles.parentNode){
+ this._remoteStyles[i].parentNode.removeChild(this._remoteStyles[i]);
+ }
+ }
+ this._remoteStyles = null;
+ }
+
+ var node = this.containerNode || this.domNode;
+ try{
+ if(typeof xml != "string"){
+ node.innerHTML = "";
+ node.appendChild(xml);
+ }else{
+ node.innerHTML = xml;
+ }
+ } catch(e){
+ e = "Could'nt load content:"+e;
+ this._handleDefaults(e, "onContentError");
+ }
+ },
+
+ setContent: function(/*String*/ data){
+ // summary:
+ // Destroys old content and setting new content, and possibly initialize any widgets within 'data'
+
+ if(this._callOnUnLoad){ // this tells a remote script clean up after itself
+ this.onUnLoad();
+ }
+ this._callOnUnLoad = true;
+
+ if(!data || dojo.dom.isNode(data)){
+ // if we do a clean using setContent(""); or setContent(#node) bypass all parseing, extractContent etc
+ this._setContent(data);
+ this.onResized();
+ this.onLoad();
+ }else{
+ // need to run splitAndFixPaths? ie. manually setting content
+ if((!data.xml)&&(this.adjustPaths)){
+ data = this.splitAndFixPaths(data);
+ }
+ if(this.extractContent) {
+ var matches = data.xml.match(/<body[^>]*>\s*([\s\S]+)\s*<\/body>/im);
+ if(matches) { data.xml = matches[1]; }
+ }
+ // insert styleNodes, from <style>....
+ for(var i = 0; i < data.styles.length; i++){
+ if(i==0){
+ this._remoteStyles = [];
+ }
+ this._remoteStyles.push(dojo.style.insertCssText(data.styles[i]));
+ }
+ // insert styleNodes, from <link href="...">
+ for(var i = 0; i < data.linkStyles.length; i++){
+ if(i==0){
+ this._remoteStyles = [];
+ }
+ this._remoteStyles.push(dojo.style.insertCssFile(data.linkStyles[i]));
+ }
+ this._setContent(data.xml);
+
+ if(this.parseContent){
+ for(var i = 0; i < data.requires.length; i++){
+ try{
+ eval(data.requires[i]);
+ } catch(e){
+ this._handleDefaults(e, "onContentError", true);
+ }
+ }
+ }
+ // need to allow async load, Xdomain uses it
+ // is inline function because we cant send args to addOnLoad function
+ var _self = this;
+ function asyncParse(){
+ if(_self.executeScripts){
+ _self._executeScripts(data);
+ }
+
+ if(_self.parseContent){
+ var node = _self.containerNode || _self.domNode;
+ var parser = new dojo.xml.Parse();
+ var frag = parser.parseElement(node, null, true);
+ // createSubComponents not createComponents because frag has already been created
+ dojo.widget.getParser().createSubComponents(frag, _self);
+ }
+
+ _self.onResized();
+ _self.onLoad();
+ }
+ // try as long as possible to make setContent sync call
+ if(dojo.hostenv.isXDomain && data.requires.length){
+ dojo.addOnLoad(asyncParse);
+ }else{
+ asyncParse();
+ }
+ }
+ },
+
+ // Generate pane content from given java function
+ setHandler: function(handler) {
+ var fcn = dojo.lang.isFunction(handler) ? handler : window[handler];
+ if(!dojo.lang.isFunction(fcn)) {
+ // FIXME: needs testing! somebody with java knowledge needs to try this
+ this._handleDefaults("Unable to set handler, '" + handler + "' not a function.", "onExecError", true);
+ 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;
+ },
+
+ _executeScripts: function(data) {
+ // do remoteScripts first
+ var self = this;
+ for(var i = 0; i < data.remoteScripts.length; i++){
+ dojo.io.bind({
+ "url": data.remoteScripts[i],
+ "useCash": this.cacheContent,
+ "load": function(type, scriptStr){
+ dojo.lang.hitch(self, data.scripts.push(scriptStr));
+ },
+ "error": function(type, error){
+ self._handleDefaults.call(self, type + " downloading remote script", "onExecError", true);
+ },
+ "mimetype": "text/plain",
+ "sync": true
+ });
+ }
+
+ var scripts = "";
+ for(var i = 0; i < data.scripts.length; i++){
+ scripts += data.scripts[i];
+ }
+
+ try{
+ // initialize a new anonymous container for our script, dont make it part of this widgets scope chain
+ // instead send in a variable that points to this widget, usefull to connect events to onLoad, onUnLoad etc..
+ this.scriptScope = null;
+ this.scriptScope = new (new Function('_container_', scripts+'; return this;'))(self);
+ }catch(e){
+ this._handleDefaults("Error running scripts from content:\n"+e, "onExecError", true);
+ }
+ }
+});
+
+dojo.widget.tags.addParseTreeHandler("dojo:ContentPane");
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/ContextMenu.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/ContextMenu.js?rev=432759&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/ContextMenu.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/ContextMenu.js Fri Aug 18 15:37:34 2006
@@ -0,0 +1,166 @@
+/*
+ Copyright (c) 2004-2006, 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 || document.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
+ dojo.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: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/DatePicker.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/DatePicker.js?rev=432759&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/DatePicker.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/DatePicker.js Fri Aug 18 15:37:34 2006
@@ -0,0 +1,346 @@
+/*
+ Copyright (c) 2004-2006, 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");
+dojo.require("dojo.date");
+
+/*
+ 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
+*/
+
+dojo.widget.defineWidget(
+ "dojo.widget.html.DatePicker",
+ dojo.widget.HtmlWidget,
+ {
+ classConstructor: function() {
+ // mixin dojo.widget.DatePicker non-demoninational code
+ dojo.widget.DatePicker.call(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 = {};
+ },
+ classNames: {
+ previous: "previousMonth",
+ current: "currentMonth",
+ next: "nextMonth",
+ currentDate: "currentDate",
+ selectedDate: "selectedItem"
+ },
+ templatePath: dojo.uri.dojoUri("src/widget/templates/HtmlDatePicker.html"),
+ templateCssPath: dojo.uri.dojoUri("src/widget/templates/HtmlDatePicker.css"),
+
+ fillInTemplate: function(){
+ dojo.widget.DatePicker.call(this);
+ this.initData();
+ this.initUI();
+ },
+ 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;
+ },
+
+ setDate: function(rfcDate) {
+ this.storedDate = rfcDate;
+ },
+
+ 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(this.firstSaturday.date-6);
+ for(var i=0; i<7; i++) {
+ currentCalendarNode = calendarNodes.item(i);
+ currentCalendarNode.innerHTML = nextDate.getDate();
+ 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);
+ },
+
+ 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;
+ },
+
+ incrementWeek: function(evt) {
+ var date = this.firstSaturday.date;
+ var month = this.firstSaturday.month;
+ var year = this.firstSaturday.year;
+ switch(evt.target) {
+ case this.increaseWeekNode.getElementsByTagName("img").item(0):
+ case this.increaseWeekNode:
+ date = date + 7;
+ if (date>this._daysIn(month,year)) {
+ date = date - this._daysIn(month,year);
+ if (month < 11) {
+ month++;
+ } else {
+ month=0;
+ year++;
+ }
+ }
+ break;
+ case this.decreaseWeekNode.getElementsByTagName("img").item(0):
+ case this.decreaseWeekNode:
+ if (date > 7) {
+ date = date - 7;
+ } else {
+ var diff = 7 - date;
+ if (month > 0) {
+ month--;
+ date = this._daysIn(month,year) - diff;
+ }else {
+ year--;
+ month=11;
+ date = 31 - diff;
+ }
+ }
+ break;
+
+ }
+
+ this.firstSaturday.date=date;
+ this.firstSaturday.month=month;
+ this.firstSaturday.year=year;
+ this.initUI();
+ },
+
+ incrementMonth: function(evt) {
+ 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();
+ },
+
+ incrementYear: function(evt) {
+ 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();
+ },
+
+ _daysIn: function(month,year) {
+ var daysIn = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
+
+ if (month==1) {
+ return (year%400 == 0) ? 29: (year%100 == 0) ? 28: (year%4 == 0) ? 29: 28;
+ } else {
+ return daysIn[month];
+ }
+ },
+
+ onIncrementDate: function(evt) {
+ dojo.unimplemented('dojo.widget.html.DatePicker.onIncrementDate');
+ },
+
+ onIncrementWeek: function(evt) {
+ evt.stopPropagation();
+ this.incrementWeek(evt);
+ },
+
+ onIncrementMonth: function(evt) {
+ evt.stopPropagation();
+ this.incrementMonth(evt);
+ },
+
+ onIncrementYear: function(evt) {
+ evt.stopPropagation();
+ this.incrementYear(evt);
+ },
+
+ setMonthLabel: function(monthIndex) {
+ this.monthLabelNode.innerHTML = dojo.date.months[monthIndex];
+ },
+
+ setYearLabels: function(year) {
+ this.previousYearLabelNode.innerHTML = year - 1;
+ this.currentYearLabelNode.innerHTML = year;
+ this.nextYearLabelNode.innerHTML = year + 1;
+ },
+
+ 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;
+ },
+
+ onClick: function(evt) {
+ dojo.event.browser.stopEvent(evt)
+ },
+
+ 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();
+ }
+ }
+);
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/DebugConsole.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/DebugConsole.js?rev=432759&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/DebugConsole.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/DebugConsole.js Fri Aug 18 15:37:34 2006
@@ -0,0 +1,31 @@
+/*
+ Copyright (c) 2004-2006, 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");
+
+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, {
+ fillInTemplate: function() {
+ dojo.widget.html.DebugConsole.superclass.fillInTemplate.apply(this, arguments);
+ this.containerNode.id = "debugConsoleClientPane";
+ djConfig.isDebug = true;
+ djConfig.debugContainerId = this.containerNode.id;
+ }
+});
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/DropdownButton.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/DropdownButton.js?rev=432759&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/DropdownButton.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/DropdownButton.js Fri Aug 18 15:37:34 2006
@@ -0,0 +1,188 @@
+/*
+ Copyright (c) 2004-2006, 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;
+ document.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: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/LinkPane.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/LinkPane.js?rev=432759&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/LinkPane.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/LinkPane.js Fri Aug 18 15:37:34 2006
@@ -0,0 +1,54 @@
+/*
+ Copyright (c) 2004-2006, 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;
+
+ var source = this.getFragNodeRef(frag);
+ dojo.html.copyStyle(this.domNode, source);
+ }
+});
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/Menu.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/Menu.js?rev=432759&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/Menu.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/Menu.js Fri Aug 18 15:37:34 2006
@@ -0,0 +1,51 @@
+/*
+ Copyright (c) 2004-2006, 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: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/MenuItem.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/MenuItem.js?rev=432759&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/MenuItem.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/MenuItem.js Fri Aug 18 15:37:34 2006
@@ -0,0 +1,60 @@
+/*
+ Copyright (c) 2004-2006, 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: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/TaskBar.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/TaskBar.js?rev=432759&view=auto
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/TaskBar.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/widget/html/TaskBar.js Fri Aug 18 15:37:34 2006
@@ -0,0 +1,85 @@
+/*
+ Copyright (c) 2004-2006, 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() {
+ this.window.show();
+ }
+});
+
+// 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._addChildStack = [];
+}
+
+dojo.inherits(dojo.widget.html.TaskBar, dojo.widget.html.FloatingPane);
+
+dojo.lang.extend(dojo.widget.html.TaskBar, {
+
+ resizable: false,
+ titleBarDisplay: "none",
+
+ addChild: function(child) {
+ if(!this.containerNode){
+ this._addChildStack.push(child);
+ }else if(this._addChildStack.length > 0){
+ var oarr = this._addChildStack;
+ this._addChildStack = [];
+ dojo.lang.forEach(oarr, this.addChild, this);
+ }
+ var tbi = dojo.widget.createWidget("TaskBarItem",
+ { windowId: child.widgetId,
+ caption: child.title,
+ iconSrc: child.iconSrc
+ });
+ dojo.widget.html.TaskBar.superclass.addChild.call(this,tbi);
+ }
+});