/trunk/api/js/dojo1.0/dijit/form/FilteringSelect.js |
---|
New file |
0,0 → 1,175 |
if(!dojo._hasResource["dijit.form.FilteringSelect"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. |
dojo._hasResource["dijit.form.FilteringSelect"] = true; |
dojo.provide("dijit.form.FilteringSelect"); |
dojo.require("dijit.form.ComboBox"); |
dojo.declare( |
"dijit.form.FilteringSelect", |
[dijit.form.MappedTextBox, dijit.form.ComboBoxMixin], |
{ |
/* |
* summary |
* Enhanced version of HTML's <select> tag. |
* |
* Similar features: |
* - There is a drop down list of possible values. |
* - You can only enter a value from the drop down list. (You can't enter an arbitrary value.) |
* - The value submitted with the form is the hidden value (ex: CA), |
* not the displayed value a.k.a. label (ex: California) |
* |
* Enhancements over plain HTML version: |
* - If you type in some text then it will filter down the list of possible values in the drop down list. |
* - List can be specified either as a static list or via a javascript function (that can get the list from a server) |
*/ |
// searchAttr: String |
// Searches pattern match against this field |
// labelAttr: String |
// Optional. The text that actually appears in the drop down. |
// If not specified, the searchAttr text is used instead. |
labelAttr: "", |
// labelType: String |
// "html" or "text" |
labelType: "text", |
_isvalid:true, |
isValid:function(){ |
return this._isvalid; |
}, |
_callbackSetLabel: function(/*Array*/ result, /*Object*/ dataObject, /*Boolean, optional*/ priorityChange){ |
// summary |
// Callback function that dynamically sets the label of the ComboBox |
// setValue does a synchronous lookup, |
// so it calls _callbackSetLabel directly, |
// and so does not pass dataObject |
// dataObject==null means do not test the lastQuery, just continue |
if(dataObject&&dataObject.query[this.searchAttr]!=this._lastQuery){return;} |
if(!result.length){ |
//#3268: do nothing on bad input |
//this._setValue("", ""); |
//#3285: change CSS to indicate error |
if(!this._hasFocus){ this.valueNode.value=""; } |
dijit.form.TextBox.superclass.setValue.call(this, undefined, !this._hasFocus); |
this._isvalid=false; |
this.validate(this._hasFocus); |
}else{ |
this._setValueFromItem(result[0], priorityChange); |
} |
}, |
_openResultList: function(/*Object*/ results, /*Object*/ dataObject){ |
// #3285: tap into search callback to see if user's query resembles a match |
if(dataObject.query[this.searchAttr]!=this._lastQuery){return;} |
this._isvalid=results.length!=0; |
this.validate(true); |
dijit.form.ComboBoxMixin.prototype._openResultList.apply(this, arguments); |
}, |
getValue:function(){ |
// don't get the textbox value but rather the previously set hidden value |
return this.valueNode.value; |
}, |
_getValueField:function(){ |
// used for option tag selects |
return "value"; |
}, |
_setValue:function(/*String*/ value, /*String*/ displayedValue, /*Boolean, optional*/ priorityChange){ |
this.valueNode.value = value; |
dijit.form.FilteringSelect.superclass.setValue.call(this, value, priorityChange, displayedValue); |
this._lastDisplayedValue = displayedValue; |
}, |
setValue: function(/*String*/ value, /*Boolean, optional*/ priorityChange){ |
// summary |
// Sets the value of the select. |
// Also sets the label to the corresponding value by reverse lookup. |
//#3347: fetchItemByIdentity if no keyAttr specified |
var self=this; |
var handleFetchByIdentity = function(item, priorityChange){ |
if(item){ |
if(self.store.isItemLoaded(item)){ |
self._callbackSetLabel([item], undefined, priorityChange); |
}else{ |
self.store.loadItem({item:item, onItem: function(result, dataObject){self._callbackSetLabel(result, dataObject, priorityChange)}}); |
} |
}else{ |
self._isvalid=false; |
// prevent errors from Tooltip not being created yet |
self.validate(false); |
} |
} |
this.store.fetchItemByIdentity({identity: value, onItem: function(item){handleFetchByIdentity(item, priorityChange)}}); |
}, |
_setValueFromItem: function(/*item*/ item, /*Boolean, optional*/ priorityChange){ |
// summary |
// Set the displayed valued in the input box, based on a selected item. |
// Users shouldn't call this function; they should be calling setDisplayedValue() instead |
this._isvalid=true; |
this._setValue(this.store.getIdentity(item), this.labelFunc(item, this.store), priorityChange); |
}, |
labelFunc: function(/*item*/ item, /*dojo.data.store*/ store){ |
// summary: Event handler called when the label changes |
// returns the label that the ComboBox should display |
return store.getValue(item, this.searchAttr); |
}, |
onkeyup: function(/*Event*/ evt){ |
// summary: internal function |
// FilteringSelect needs to wait for the complete label before committing to a reverse lookup |
//this.setDisplayedValue(this.textbox.value); |
}, |
_doSelect: function(/*Event*/ tgt){ |
// summary: |
// ComboBox's menu callback function |
// FilteringSelect overrides this to set both the visible and hidden value from the information stored in the menu |
this.item = tgt.item; |
this._setValueFromItem(tgt.item, true); |
}, |
setDisplayedValue:function(/*String*/ label){ |
// summary: |
// Set textbox to display label |
// Also performs reverse lookup to set the hidden value |
// Used in InlineEditBox |
if(this.store){ |
var query={}; |
this._lastQuery=query[this.searchAttr]=label; |
// if the label is not valid, the callback will never set it, |
// so the last valid value will get the warning textbox |
// set the textbox value now so that the impending warning will make sense to the user |
this.textbox.value=label; |
this._lastDisplayedValue=label; |
this.store.fetch({query:query, queryOptions:{ignoreCase:this.ignoreCase, deep:true}, onComplete: dojo.hitch(this, this._callbackSetLabel)}); |
} |
}, |
_getMenuLabelFromItem:function(/*Item*/ item){ |
// internal function to help ComboBoxMenu figure out what to display |
if(this.labelAttr){return {html:this.labelType=="html", label:this.store.getValue(item, this.labelAttr)};} |
else{ |
// because this function is called by ComboBoxMenu, this.inherited tries to find the superclass of ComboBoxMenu |
return dijit.form.ComboBoxMixin.prototype._getMenuLabelFromItem.apply(this, arguments); |
} |
}, |
postMixInProperties: function(){ |
dijit.form.ComboBoxMixin.prototype.postMixInProperties.apply(this, arguments); |
dijit.form.MappedTextBox.prototype.postMixInProperties.apply(this, arguments); |
} |
} |
); |
} |
/trunk/api/js/dojo1.0/dijit/form/templates/CheckBox.html |
---|
New file |
0,0 → 1,7 |
<fieldset class="dijitReset dijitInline" waiRole="presentation" |
><input |
type="${type}" name="${name}" |
class="dijitReset dijitCheckBoxInput" |
dojoAttachPoint="inputNode,focusNode" |
dojoAttachEvent="onmouseover:_onMouse,onmouseout:_onMouse,onclick:_onClick" |
/></fieldset> |
/trunk/api/js/dojo1.0/dijit/form/templates/ComboBox.html |
---|
New file |
0,0 → 1,21 |
<table class="dijit dijitReset dijitInlineTable dijitLeft" cellspacing="0" cellpadding="0" |
id="widget_${id}" name="${name}" dojoAttachEvent="onmouseenter:_onMouse,onmouseleave:_onMouse" waiRole="presentation" |
><tr class="dijitReset" |
><td class='dijitReset dijitStretch dijitInputField' width="100%" |
><input type="text" autocomplete="off" name="${name}" |
dojoAttachEvent="onkeypress, onkeyup, onfocus, compositionend" |
dojoAttachPoint="textbox,focusNode" waiRole="combobox" |
/></td |
><td class="dijitReset dijitValidationIconField" width="0%" |
><div dojoAttachPoint='iconNode' class='dijitValidationIcon'></div |
><div class='dijitValidationIconText'>Χ</div |
></td |
><td class='dijitReset dijitRight dijitButtonNode dijitDownArrowButton' width="0%" |
dojoAttachPoint="downArrowNode" |
dojoAttachEvent="onmousedown:_onArrowMouseDown,onmouseup:_onMouse,onmouseenter:_onMouse,onmouseleave:_onMouse" |
><div class="dijitDownArrowButtonInner" waiRole="presentation" |
><div class="dijitDownArrowButtonChar">▼</div |
></div |
></td |
></tr |
></table> |
/trunk/api/js/dojo1.0/dijit/form/templates/DropDownButton.html |
---|
New file |
0,0 → 1,11 |
<div class="dijit dijitLeft dijitInline" |
dojoAttachEvent="onmouseenter:_onMouse,onmouseleave:_onMouse,onmousedown:_onMouse,onclick:_onDropDownClick,onkeydown:_onDropDownKeydown,onblur:_onDropDownBlur,onkeypress:_onKey" |
><div class='dijitRight'> |
<button class="dijitStretch dijitButtonNode dijitButtonContents" type="${type}" |
dojoAttachPoint="focusNode,titleNode" waiRole="button" waiState="haspopup-true,labelledby-${id}_label" |
><div class="dijitInline ${iconClass}" dojoAttachPoint="iconNode"></div |
><span class="dijitButtonText" dojoAttachPoint="containerNode,popupStateNode" |
id="${id}_label">${label}</span |
><span class='dijitA11yDownArrow'>▼</span> |
</button> |
</div></div> |
/trunk/api/js/dojo1.0/dijit/form/templates/ValidationTextBox.html |
---|
New file |
0,0 → 1,13 |
<table style="display: -moz-inline-stack;" class="dijit dijitReset dijitInlineTable" cellspacing="0" cellpadding="0" |
id="widget_${id}" name="${name}" |
dojoAttachEvent="onmouseenter:_onMouse,onmouseleave:_onMouse" waiRole="presentation" |
><tr class="dijitReset" |
><td class="dijitReset dijitInputField" width="100%" |
><input dojoAttachPoint='textbox,focusNode' dojoAttachEvent='onfocus,onblur:_onMouse,onkeyup,onkeypress:_onKeyPress' autocomplete="off" |
type='${type}' name='${name}' |
/></td |
><td class="dijitReset dijitValidationIconField" width="0%" |
><div dojoAttachPoint='iconNode' class='dijitValidationIcon'></div><div class='dijitValidationIconText'>Χ</div |
></td |
></tr |
></table> |
/trunk/api/js/dojo1.0/dijit/form/templates/blank.gif |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/trunk/api/js/dojo1.0/dijit/form/templates/blank.gif |
---|
New file |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/trunk/api/js/dojo1.0/dijit/form/templates/Button.html |
---|
New file |
0,0 → 1,12 |
<div class="dijit dijitLeft dijitInline dijitButton" |
dojoAttachEvent="onclick:_onButtonClick,onmouseenter:_onMouse,onmouseleave:_onMouse,onmousedown:_onMouse" |
><div class='dijitRight' |
><button class="dijitStretch dijitButtonNode dijitButtonContents" dojoAttachPoint="focusNode,titleNode" |
type="${type}" waiRole="button" waiState="labelledby-${id}_label" |
><span class="dijitInline ${iconClass}" dojoAttachPoint="iconNode" |
><span class="dijitToggleButtonIconChar">✓</span |
></span |
><span class="dijitButtonText" id="${id}_label" dojoAttachPoint="containerNode">${label}</span |
></button |
></div |
></div> |
/trunk/api/js/dojo1.0/dijit/form/templates/ComboButton.html |
---|
New file |
0,0 → 1,20 |
<table class='dijit dijitReset dijitInline dijitLeft' |
cellspacing='0' cellpadding='0' |
dojoAttachEvent="onmouseenter:_onMouse,onmouseleave:_onMouse,onmousedown:_onMouse"> |
<tr> |
<td class="dijitStretch dijitButtonContents dijitButtonNode" |
tabIndex="${tabIndex}" |
dojoAttachEvent="ondijitclick:_onButtonClick" dojoAttachPoint="titleNode" |
waiRole="button" waiState="labelledby-${id}_label"> |
<div class="dijitInline ${iconClass}" dojoAttachPoint="iconNode"></div> |
<span class="dijitButtonText" id="${id}_label" dojoAttachPoint="containerNode">${label}</span> |
</td> |
<td class='dijitReset dijitRight dijitButtonNode dijitDownArrowButton' |
dojoAttachPoint="popupStateNode,focusNode" |
dojoAttachEvent="ondijitclick:_onArrowClick, onkeypress:_onKey" |
stateModifier="DownArrow" |
title="${optionsTitle}" name="${name}" |
waiRole="button" waiState="haspopup-true" |
><div waiRole="presentation">▼</div> |
</td></tr> |
</table> |
/trunk/api/js/dojo1.0/dijit/form/templates/HorizontalSlider.html |
---|
New file |
0,0 → 1,37 |
<table class="dijit dijitReset dijitSlider" cellspacing="0" cellpadding="0" border="0" rules="none" |
><tr class="dijitReset" |
><td class="dijitReset" colspan="2"></td |
><td dojoAttachPoint="containerNode,topDecoration" class="dijitReset" style="text-align:center;width:100%;"></td |
><td class="dijitReset" colspan="2"></td |
></tr |
><tr class="dijitReset" |
><td class="dijitReset dijitSliderButtonContainer dijitHorizontalSliderButtonContainer" |
><div class="dijitHorizontalSliderDecrementIcon" tabIndex="-1" style="display:none" dojoAttachPoint="decrementButton" dojoAttachEvent="onclick: decrement"><span class="dijitSliderButtonInner">-</span></div |
></td |
><td class="dijitReset" |
><div class="dijitSliderBar dijitSliderBumper dijitHorizontalSliderBumper dijitSliderLeftBumper dijitHorizontalSliderLeftBumper"></div |
></td |
><td class="dijitReset" |
><input dojoAttachPoint="valueNode" type="hidden" name="${name}" |
/><div style="position:relative;" dojoAttachPoint="sliderBarContainer" |
><div dojoAttachPoint="progressBar" class="dijitSliderBar dijitHorizontalSliderBar dijitSliderProgressBar dijitHorizontalSliderProgressBar" dojoAttachEvent="onclick:_onBarClick" |
><div dojoAttachPoint="sliderHandle,focusNode" class="dijitSliderMoveable dijitHorizontalSliderMoveable" dojoAttachEvent="onkeypress:_onKeyPress,onclick:_onHandleClick" waiRole="slider" valuemin="${minimum}" valuemax="${maximum}" |
><div class="dijitSliderImageHandle dijitHorizontalSliderImageHandle"></div |
></div |
></div |
><div dojoAttachPoint="remainingBar" class="dijitSliderBar dijitHorizontalSliderBar dijitSliderRemainingBar dijitHorizontalSliderRemainingBar" dojoAttachEvent="onclick:_onBarClick"></div |
></div |
></td |
><td class="dijitReset" |
><div class="dijitSliderBar dijitSliderBumper dijitHorizontalSliderBumper dijitSliderRightBumper dijitHorizontalSliderRightBumper"></div |
></td |
><td class="dijitReset dijitSliderButtonContainer dijitHorizontalSliderButtonContainer" style="right:0px;" |
><div class="dijitHorizontalSliderIncrementIcon" tabIndex="-1" style="display:none" dojoAttachPoint="incrementButton" dojoAttachEvent="onclick: increment"><span class="dijitSliderButtonInner">+</span></div |
></td |
></tr |
><tr class="dijitReset" |
><td class="dijitReset" colspan="2"></td |
><td dojoAttachPoint="containerNode,bottomDecoration" class="dijitReset" style="text-align:center;"></td |
><td class="dijitReset" colspan="2"></td |
></tr |
></table> |
/trunk/api/js/dojo1.0/dijit/form/templates/TimePicker.html |
---|
New file |
0,0 → 1,5 |
<div id="widget_${id}" class="dijitMenu" |
><div dojoAttachPoint="upArrow" class="dijitButtonNode"><span class="dijitTimePickerA11yText">▲</span></div |
><div dojoAttachPoint="timeMenu,focusNode" dojoAttachEvent="onclick:_onOptionSelected,onmouseover,onmouseout"></div |
><div dojoAttachPoint="downArrow" class="dijitButtonNode"><span class="dijitTimePickerA11yText">▼</span></div |
></div> |
/trunk/api/js/dojo1.0/dijit/form/templates/VerticalSlider.html |
---|
New file |
0,0 → 1,46 |
<table class="dijitReset dijitSlider" cellspacing="0" cellpadding="0" border="0" rules="none" |
><tbody class="dijitReset" |
><tr class="dijitReset" |
><td class="dijitReset"></td |
><td class="dijitReset dijitSliderButtonContainer dijitVerticalSliderButtonContainer" |
><div class="dijitVerticalSliderIncrementIcon" tabIndex="-1" style="display:none" dojoAttachPoint="incrementButton" dojoAttachEvent="onclick: increment"><span class="dijitSliderButtonInner">+</span></div |
></td |
><td class="dijitReset"></td |
></tr |
><tr class="dijitReset" |
><td class="dijitReset"></td |
><td class="dijitReset" |
><center><div class="dijitSliderBar dijitSliderBumper dijitVerticalSliderBumper dijitSliderTopBumper dijitVerticalSliderTopBumper"></div></center |
></td |
><td class="dijitReset"></td |
></tr |
><tr class="dijitReset" |
><td dojoAttachPoint="leftDecoration" class="dijitReset" style="text-align:center;height:100%;"></td |
><td class="dijitReset" style="height:100%;" |
><input dojoAttachPoint="valueNode" type="hidden" name="${name}" |
/><center style="position:relative;height:100%;" dojoAttachPoint="sliderBarContainer" |
><div dojoAttachPoint="remainingBar" class="dijitSliderBar dijitVerticalSliderBar dijitSliderRemainingBar dijitVerticalSliderRemainingBar" dojoAttachEvent="onclick:_onBarClick"></div |
><div dojoAttachPoint="progressBar" class="dijitSliderBar dijitVerticalSliderBar dijitSliderProgressBar dijitVerticalSliderProgressBar" dojoAttachEvent="onclick:_onBarClick" |
><div dojoAttachPoint="sliderHandle,focusNode" class="dijitSliderMoveable" dojoAttachEvent="onkeypress:_onKeyPress,onclick:_onHandleClick" style="vertical-align:top;" waiRole="slider" valuemin="${minimum}" valuemax="${maximum}" |
><div class="dijitSliderImageHandle dijitVerticalSliderImageHandle"></div |
></div |
></div |
></center |
></td |
><td dojoAttachPoint="containerNode,rightDecoration" class="dijitReset" style="text-align:center;height:100%;"></td |
></tr |
><tr class="dijitReset" |
><td class="dijitReset"></td |
><td class="dijitReset" |
><center><div class="dijitSliderBar dijitSliderBumper dijitVerticalSliderBumper dijitSliderBottomBumper dijitVerticalSliderBottomBumper"></div></center |
></td |
><td class="dijitReset"></td |
></tr |
><tr class="dijitReset" |
><td class="dijitReset"></td |
><td class="dijitReset dijitSliderButtonContainer dijitVerticalSliderButtonContainer" |
><div class="dijitVerticalSliderDecrementIcon" tabIndex="-1" style="display:none" dojoAttachPoint="decrementButton" dojoAttachEvent="onclick: decrement"><span class="dijitSliderButtonInner">-</span></div |
></td |
><td class="dijitReset"></td |
></tr |
></tbody></table> |
/trunk/api/js/dojo1.0/dijit/form/templates/InlineEditBox.html |
---|
New file |
0,0 → 1,12 |
<span |
><fieldset dojoAttachPoint="editNode" style="display:none;" waiRole="presentation" |
><div dojoAttachPoint="containerNode" dojoAttachEvent="onkeypress:_onEditWidgetKeyPress"></div |
><div dojoAttachPoint="buttonContainer" |
><button class='saveButton' dojoAttachPoint="saveButton" dojoType="dijit.form.Button" dojoAttachEvent="onClick:save">${buttonSave}</button |
><button class='cancelButton' dojoAttachPoint="cancelButton" dojoType="dijit.form.Button" dojoAttachEvent="onClick:cancel">${buttonCancel}</button |
></div |
></fieldset |
><span tabIndex="0" dojoAttachPoint="textNode,focusNode" waiRole="button" style="display:none;" |
dojoAttachEvent="onkeypress:_onKeyPress,onclick:_onClick,onmouseout:_onMouseOut,onmouseover:_onMouseOver,onfocus:_onMouseOver,onblur:_onMouseOut" |
></span |
></span> |
/trunk/api/js/dojo1.0/dijit/form/templates/TextBox.html |
---|
New file |
0,0 → 1,4 |
<input class="dojoTextBox" dojoAttachPoint='textbox,focusNode' name="${name}" |
dojoAttachEvent='onmouseenter:_onMouse,onmouseleave:_onMouse,onfocus:_onMouse,onblur:_onMouse,onkeyup,onkeypress:_onKeyPress' |
autocomplete="off" type="${type}" |
/> |
/trunk/api/js/dojo1.0/dijit/form/templates/Spinner.html |
---|
New file |
0,0 → 1,29 |
<table class="dijit dijitReset dijitInlineTable dijitLeft" cellspacing="0" cellpadding="0" |
id="widget_${id}" name="${name}" |
dojoAttachEvent="onmouseenter:_onMouse,onmouseleave:_onMouse,onkeypress:_onKeyPress" |
waiRole="presentation" |
><tr class="dijitReset" |
><td rowspan="2" class="dijitReset dijitStretch dijitInputField" width="100%" |
><input dojoAttachPoint="textbox,focusNode" type="${type}" dojoAttachEvent="onfocus,onkeyup" |
waiRole="spinbutton" autocomplete="off" name="${name}" |
></td |
><td rowspan="2" class="dijitReset dijitValidationIconField" width="0%" |
><div dojoAttachPoint='iconNode' class='dijitValidationIcon'></div |
></td |
><td class="dijitReset dijitRight dijitButtonNode dijitUpArrowButton" width="0%" |
dojoAttachPoint="upArrowNode" |
dojoAttachEvent="onmousedown:_handleUpArrowEvent,onmouseup:_handleUpArrowEvent,onmouseover:_handleUpArrowEvent,onmouseout:_handleUpArrowEvent" |
stateModifier="UpArrow" |
><div class="dijitA11yUpArrow">▲</div |
></td |
></tr |
><tr class="dijitReset" |
><td class="dijitReset dijitRight dijitButtonNode dijitDownArrowButton" width="0%" |
dojoAttachPoint="downArrowNode" |
dojoAttachEvent="onmousedown:_handleDownArrowEvent,onmouseup:_handleDownArrowEvent,onmouseover:_handleDownArrowEvent,onmouseout:_handleDownArrowEvent" |
stateModifier="DownArrow" |
><div class="dijitA11yDownArrow">▼</div |
></td |
></tr |
></table> |
/trunk/api/js/dojo1.0/dijit/form/CheckBox.js |
---|
New file |
0,0 → 1,119 |
if(!dojo._hasResource["dijit.form.CheckBox"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. |
dojo._hasResource["dijit.form.CheckBox"] = true; |
dojo.provide("dijit.form.CheckBox"); |
dojo.require("dijit.form.Button"); |
dojo.declare( |
"dijit.form.CheckBox", |
dijit.form.ToggleButton, |
{ |
// summary: |
// Same as an HTML checkbox, but with fancy styling. |
// |
// description: |
// User interacts with real html inputs. |
// On onclick (which occurs by mouse click, space-bar, or |
// using the arrow keys to switch the selected radio button), |
// we update the state of the checkbox/radio. |
// |
// There are two modes: |
// 1. High contrast mode |
// 2. Normal mode |
// In case 1, the regular html inputs are shown and used by the user. |
// In case 2, the regular html inputs are invisible but still used by |
// the user. They are turned quasi-invisible and overlay the background-image. |
templateString:"<fieldset class=\"dijitReset dijitInline\" waiRole=\"presentation\"\n\t><input\n\t \ttype=\"${type}\" name=\"${name}\"\n\t\tclass=\"dijitReset dijitCheckBoxInput\"\n\t\tdojoAttachPoint=\"inputNode,focusNode\"\n\t \tdojoAttachEvent=\"onmouseover:_onMouse,onmouseout:_onMouse,onclick:_onClick\"\n/></fieldset>\n", |
baseClass: "dijitCheckBox", |
// Value of "type" attribute for <input> |
type: "checkbox", |
// value: Value |
// equivalent to value field on normal checkbox (if checked, the value is passed as |
// the value when form is submitted) |
value: "on", |
postCreate: function(){ |
dojo.setSelectable(this.inputNode, false); |
this.setChecked(this.checked); |
this.inherited(arguments); |
}, |
setChecked: function(/*Boolean*/ checked){ |
if(dojo.isIE){ |
if(checked){ this.inputNode.setAttribute('checked', 'checked'); } |
else{ this.inputNode.removeAttribute('checked'); } |
}else{ this.inputNode.checked = checked; } |
this.inherited(arguments); |
}, |
setValue: function(/*String*/ value){ |
if(value == null){ value = ""; } |
this.inputNode.value = value; |
dijit.form.CheckBox.superclass.setValue.call(this,value); |
} |
} |
); |
dojo.declare( |
"dijit.form.RadioButton", |
dijit.form.CheckBox, |
{ |
// summary: |
// Same as an HTML radio, but with fancy styling. |
// |
// description: |
// Implementation details |
// |
// Specialization: |
// We keep track of dijit radio groups so that we can update the state |
// of all the siblings (the "context") in a group based on input |
// events. We don't rely on browser radio grouping. |
type: "radio", |
baseClass: "dijitRadio", |
// This shared object keeps track of all widgets, grouped by name |
_groups: {}, |
postCreate: function(){ |
// add this widget to _groups |
(this._groups[this.name] = this._groups[this.name] || []).push(this); |
this.inherited(arguments); |
}, |
uninitialize: function(){ |
// remove this widget from _groups |
dojo.forEach(this._groups[this.name], function(widget, i, arr){ |
if(widget === this){ |
arr.splice(i, 1); |
return; |
} |
}, this); |
}, |
setChecked: function(/*Boolean*/ checked){ |
// If I am being checked then have to deselect currently checked radio button |
if(checked){ |
dojo.forEach(this._groups[this.name], function(widget){ |
if(widget != this && widget.checked){ |
widget.setChecked(false); |
} |
}, this); |
} |
this.inherited(arguments); |
}, |
_clicked: function(/*Event*/ e){ |
if(!this.checked){ |
this.setChecked(true); |
} |
} |
} |
); |
} |
/trunk/api/js/dojo1.0/dijit/form/NumberSpinner.js |
---|
New file |
0,0 → 1,31 |
if(!dojo._hasResource["dijit.form.NumberSpinner"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. |
dojo._hasResource["dijit.form.NumberSpinner"] = true; |
dojo.provide("dijit.form.NumberSpinner"); |
dojo.require("dijit.form._Spinner"); |
dojo.require("dijit.form.NumberTextBox"); |
dojo.declare( |
"dijit.form.NumberSpinner", |
[dijit.form._Spinner, dijit.form.NumberTextBoxMixin], |
{ |
// summary: Number Spinner |
// description: This widget is the same as NumberTextBox but with up/down arrows added |
required: true, |
adjust: function(/* Object */ val, /*Number*/ delta){ |
// summary: change Number val by the given amount |
var newval = val+delta; |
if(isNaN(val) || isNaN(newval)){ return val; } |
if((typeof this.constraints.max == "number") && (newval > this.constraints.max)){ |
newval = this.constraints.max; |
} |
if((typeof this.constraints.min == "number") && (newval < this.constraints.min)){ |
newval = this.constraints.min; |
} |
return newval; |
} |
}); |
} |
/trunk/api/js/dojo1.0/dijit/form/DateTextBox.js |
---|
New file |
0,0 → 1,24 |
if(!dojo._hasResource["dijit.form.DateTextBox"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. |
dojo._hasResource["dijit.form.DateTextBox"] = true; |
dojo.provide("dijit.form.DateTextBox"); |
dojo.require("dijit._Calendar"); |
dojo.require("dijit.form.TimeTextBox"); |
dojo.declare( |
"dijit.form.DateTextBox", |
dijit.form.TimeTextBox, |
{ |
// summary: |
// A validating, serializable, range-bound date text box. |
_popupClass: "dijit._Calendar", |
postMixInProperties: function(){ |
this.inherited('postMixInProperties', arguments); |
this.constraints.selector = 'date'; |
} |
} |
); |
} |
/trunk/api/js/dojo1.0/dijit/form/InlineEditBox.js |
---|
New file |
0,0 → 1,317 |
if(!dojo._hasResource["dijit.form.InlineEditBox"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. |
dojo._hasResource["dijit.form.InlineEditBox"] = true; |
dojo.provide("dijit.form.InlineEditBox"); |
dojo.require("dojo.i18n"); |
dojo.require("dijit.form._FormWidget"); |
dojo.require("dijit._Container"); |
dojo.require("dijit.form.Button"); |
dojo.requireLocalization("dijit", "common", null, "ko,zh,ja,zh-tw,ru,it,hu,fr,pt,ROOT,pl,es,de,cs"); |
dojo.deprecated("dijit.form.InlineEditBox is deprecated, use dijit.InlineEditBox instead", "", "1.1"); |
dojo.declare( |
"dijit.form.InlineEditBox", |
[dijit.form._FormWidget, dijit._Container], |
// summary |
// Wrapper widget to a text edit widget. |
// The text is displayed on the page using normal user-styling. |
// When clicked, the text is hidden, and the edit widget is |
// visible, allowing the text to be updated. Optionally, |
// Save and Cancel button are displayed below the edit widget. |
// When Save is clicked, the text is pulled from the edit |
// widget and redisplayed and the edit widget is again hidden. |
// Currently all textboxes that inherit from dijit.form.TextBox |
// are supported edit widgets. |
// An edit widget must support the following API to be used: |
// String getDisplayedValue() OR String getValue() |
// void setDisplayedValue(String) OR void setValue(String) |
// void focus() |
// It must also be able to initialize with style="display:none;" set. |
{ |
templateString:"<span\n\t><fieldset dojoAttachPoint=\"editNode\" style=\"display:none;\" waiRole=\"presentation\"\n\t\t><div dojoAttachPoint=\"containerNode\" dojoAttachEvent=\"onkeypress:_onEditWidgetKeyPress\"></div\n\t\t><div dojoAttachPoint=\"buttonContainer\"\n\t\t\t><button class='saveButton' dojoAttachPoint=\"saveButton\" dojoType=\"dijit.form.Button\" dojoAttachEvent=\"onClick:save\">${buttonSave}</button\n\t\t\t><button class='cancelButton' dojoAttachPoint=\"cancelButton\" dojoType=\"dijit.form.Button\" dojoAttachEvent=\"onClick:cancel\">${buttonCancel}</button\n\t\t></div\n\t></fieldset\n\t><span tabIndex=\"0\" dojoAttachPoint=\"textNode,focusNode\" waiRole=\"button\" style=\"display:none;\"\n\t\tdojoAttachEvent=\"onkeypress:_onKeyPress,onclick:_onClick,onmouseout:_onMouseOut,onmouseover:_onMouseOver,onfocus:_onMouseOver,onblur:_onMouseOut\"\n\t></span\n></span>\n", |
// editing: Boolean |
// Is the node currently in edit mode? |
editing: false, |
// autoSave: Boolean |
// Changing the value automatically saves it, don't have to push save button |
autoSave: true, |
// buttonSave: String |
// Save button label |
buttonSave: "", |
// buttonCancel: String |
// Cancel button label |
buttonCancel: "", |
// renderAsHtml: Boolean |
// should text render as HTML(true) or plain text(false) |
renderAsHtml: false, |
widgetsInTemplate: true, |
// _display: String |
// srcNodeRef display style |
_display:"", |
startup: function(){ |
// look for the input widget as a child of the containerNode |
if(!this._started){ |
if(this.editWidget){ |
this.containerNode.appendChild(this.editWidget.domNode); |
}else{ |
this.editWidget = this.getChildren()[0]; |
} |
// #3209: copy the style from the source |
// don't copy ALL properties though, just the necessary/applicable ones |
var srcStyle=dojo.getComputedStyle(this.domNode); |
dojo.forEach(["fontWeight","fontFamily","fontSize","fontStyle"], function(prop){ |
this.editWidget.focusNode.style[prop]=srcStyle[prop]; |
}, this); |
this._setEditValue = dojo.hitch(this.editWidget,this.editWidget.setDisplayedValue||this.editWidget.setValue); |
this._getEditValue = dojo.hitch(this.editWidget,this.editWidget.getDisplayedValue||this.editWidget.getValue); |
this._setEditFocus = dojo.hitch(this.editWidget,this.editWidget.focus); |
this._isEditValid = dojo.hitch(this.editWidget,this.editWidget.isValid || function(){return true;}); |
this.editWidget.onChange = dojo.hitch(this, "_onChange"); |
if(!this.autoSave){ // take over the setValue method so we can know when the value changes |
this._oldSetValue = this.editWidget.setValue; |
var _this = this; |
this.editWidget.setValue = dojo.hitch(this, function(value){ |
_this._oldSetValue.apply(_this.editWidget, arguments); |
_this._onEditWidgetKeyPress(null); // check the Save button |
}); |
} |
this._showText(); |
this._started = true; |
} |
}, |
postMixInProperties: function(){ |
this._srcTag = this.srcNodeRef.tagName; |
this._srcStyle=dojo.getComputedStyle(this.srcNodeRef); |
// getComputedStyle is not good until after onLoad is called |
var srcNodeStyle = this.srcNodeRef.style; |
this._display=""; |
if(srcNodeStyle && srcNodeStyle.display){ this._display=srcNodeStyle.display; } |
else{ |
switch(this.srcNodeRef.tagName.toLowerCase()){ |
case 'span': |
case 'input': |
case 'img': |
case 'button': |
this._display='inline'; |
break; |
default: |
this._display='block'; |
break; |
} |
} |
this.inherited('postMixInProperties', arguments); |
this.messages = dojo.i18n.getLocalization("dijit", "common", this.lang); |
dojo.forEach(["buttonSave", "buttonCancel"], function(prop){ |
if(!this[prop]){ this[prop] = this.messages[prop]; } |
}, this); |
}, |
postCreate: function(){ |
// don't call setValue yet since the editing widget is not setup |
if(this.autoSave){ |
dojo.style(this.buttonContainer, "display", "none"); |
} |
}, |
_onKeyPress: function(e){ |
// summary: handle keypress when edit box is not open |
if(this.disabled || e.altKey || e.ctrlKey){ return; } |
if(e.charCode == dojo.keys.SPACE || e.keyCode == dojo.keys.ENTER){ |
dojo.stopEvent(e); |
this._onClick(e); |
} |
}, |
_onMouseOver: function(){ |
if(!this.editing){ |
var classname = this.disabled ? "dijitDisabledClickableRegion" : "dijitClickableRegion"; |
dojo.addClass(this.textNode, classname); |
} |
}, |
_onMouseOut: function(){ |
if(!this.editing){ |
var classStr = this.disabled ? "dijitDisabledClickableRegion" : "dijitClickableRegion"; |
dojo.removeClass(this.textNode, classStr); |
} |
}, |
_onClick: function(e){ |
// summary |
// When user clicks the text, then start editing. |
// Hide the text and display the form instead. |
if(this.editing || this.disabled){ return; } |
this._onMouseOut(); |
this.editing = true; |
// show the edit form and hide the read only version of the text |
this._setEditValue(this._isEmpty ? '' : (this.renderAsHtml ? this.textNode.innerHTML : this.textNode.innerHTML.replace(/\s*\r?\n\s*/g,"").replace(/<br\/?>/gi, "\n").replace(/>/g,">").replace(/</g,"<").replace(/&/g,"&"))); |
this._initialText = this._getEditValue(); |
this._visualize(); |
// Before changing the focus, give the browser time to render. |
setTimeout(dojo.hitch(this, function(){ |
this._setEditFocus(); |
this.saveButton.setDisabled(true); |
}), 1); |
}, |
_visualize: function(){ |
dojo.style(this.editNode, "display", this.editing ? this._display : "none"); |
// #3749: try to set focus now to fix missing caret |
// #3997: call right after this.containerNode appears |
if(this.editing){this._setEditFocus();} |
dojo.style(this.textNode, "display", this.editing ? "none" : this._display); |
}, |
_showText: function(){ |
var value = "" + this._getEditValue(); // "" is to make sure its a string |
dijit.form.InlineEditBox.superclass.setValue.call(this, value); |
// whitespace is really hard to click so show a ? |
// TODO: show user defined message in gray |
if(/^\s*$/.test(value)){ value = "?"; this._isEmpty = true; } |
else { this._isEmpty = false; } |
if(this.renderAsHtml){ |
this.textNode.innerHTML = value; |
}else{ |
this.textNode.innerHTML = ""; |
if(value.split){ |
var _this=this; |
var isFirst = true; |
dojo.forEach(value.split("\n"), function(line){ |
if(isFirst){ |
isFirst = false; |
}else{ |
_this.textNode.appendChild(document.createElement("BR")); // preserve line breaks |
} |
_this.textNode.appendChild(document.createTextNode(line)); // use text nodes so that imbedded tags can be edited |
}); |
}else{ |
this.textNode.appendChild(document.createTextNode(value)); |
} |
} |
this._visualize(); |
}, |
save: function(e){ |
// summary: Callback when user presses "Save" button or it's simulated. |
// e is passed in if click on save button or user presses Enter. It's not |
// passed in when called by _onBlur. |
if(typeof e == "object"){ dojo.stopEvent(e); } |
if(!this.enableSave()){ return; } |
this.editing = false; |
this._showText(); |
// If save button pressed on non-autoSave widget or Enter pressed on autoSave |
// widget, restore focus to the inline text. |
if(e){ dijit.focus(this.focusNode); } |
if(this._lastValue != this._lastValueReported){ |
this.onChange(this._lastValue); // tell the world that we have changed |
} |
}, |
cancel: function(e){ |
// summary: Callback when user presses "Cancel" button or it's simulated. |
// e is passed in if click on cancel button or user presses Esc. It's not |
// passed in when called by _onBlur. |
if(e){ dojo.stopEvent(e); } |
this.editing = false; |
this._visualize(); |
// If cancel button pressed on non-autoSave widget or Esc pressed on autoSave |
// widget, restore focus to the inline text. |
if(e){ dijit.focus(this.focusNode); } |
}, |
setValue: function(/*String*/ value){ |
// sets the text without informing the server |
this._setEditValue(value); |
this.editing = false; |
this._showText(); |
}, |
_onEditWidgetKeyPress: function(e){ |
// summary: |
// Callback when keypress in the edit box (see template). |
// For autoSave widgets, if Esc/Enter, call cancel/save. |
// For non-autoSave widgets, enable save button if the text value is |
// different than the original value. |
if(!this.editing){ return; } |
if(this.autoSave){ |
// If Enter/Esc pressed, treat as save/cancel. |
if(e.keyCode == dojo.keys.ESCAPE){ |
this.cancel(e); |
}else if(e.keyCode == dojo.keys.ENTER){ |
this.save(e); |
} |
}else{ |
var _this = this; |
// Delay before calling _getEditValue. |
// The delay gives the browser a chance to update the textarea. |
setTimeout( |
function(){ |
_this.saveButton.setDisabled(_this._getEditValue() == _this._initialText); |
}, 100); |
} |
}, |
_onBlur: function(){ |
// summary: |
// Called by the focus manager in focus.js when focus moves outside of the |
// InlineEditBox widget (or it's descendants). |
if(this.autoSave && this.editing){ |
if(this._getEditValue() == this._initialText){ |
this.cancel(); |
}else{ |
this.save(); |
} |
} |
}, |
enableSave: function(){ |
// summary: User replacable function returning a Boolean to indicate |
// if the Save button should be enabled or not - usually due to invalid conditions |
return this._isEditValid(); |
}, |
_onChange: function(){ |
// summary: |
// This is called when the underlying widget fires an onChange event, |
// which means that the user has finished entering the value |
if(!this.editing){ |
this._showText(); // asynchronous update made famous by ComboBox/FilteringSelect |
}else if(this.autoSave){ |
this.save(1); |
}else{ |
// #3752 |
// if the keypress does not bubble up to the div, (iframe in TextArea blocks it for example) |
// make sure the save button gets enabled |
this.saveButton.setDisabled((this._getEditValue() == this._initialText) || !this.enableSave()); |
} |
}, |
setDisabled: function(/*Boolean*/ disabled){ |
this.saveButton.setDisabled(disabled); |
this.cancelButton.setDisabled(disabled); |
this.textNode.disabled = disabled; |
this.editWidget.setDisabled(disabled); |
this.inherited('setDisabled', arguments); |
} |
}); |
} |
/trunk/api/js/dojo1.0/dijit/form/TextBox.js |
---|
New file |
0,0 → 1,139 |
if(!dojo._hasResource["dijit.form.TextBox"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. |
dojo._hasResource["dijit.form.TextBox"] = true; |
dojo.provide("dijit.form.TextBox"); |
dojo.require("dijit.form._FormWidget"); |
dojo.declare( |
"dijit.form.TextBox", |
dijit.form._FormWidget, |
{ |
// summary: |
// A generic textbox field. |
// Serves as a base class to derive more specialized functionality in subclasses. |
// trim: Boolean |
// Removes leading and trailing whitespace if true. Default is false. |
trim: false, |
// uppercase: Boolean |
// Converts all characters to uppercase if true. Default is false. |
uppercase: false, |
// lowercase: Boolean |
// Converts all characters to lowercase if true. Default is false. |
lowercase: false, |
// propercase: Boolean |
// Converts the first character of each word to uppercase if true. |
propercase: false, |
// maxLength: String |
// HTML INPUT tag maxLength declaration. |
maxLength: "", |
templateString:"<input class=\"dojoTextBox\" dojoAttachPoint='textbox,focusNode' name=\"${name}\"\n\tdojoAttachEvent='onmouseenter:_onMouse,onmouseleave:_onMouse,onfocus:_onMouse,onblur:_onMouse,onkeyup,onkeypress:_onKeyPress'\n\tautocomplete=\"off\" type=\"${type}\"\n\t/>\n", |
baseClass: "dijitTextBox", |
attributeMap: dojo.mixin(dojo.clone(dijit.form._FormWidget.prototype.attributeMap), |
{maxLength:"focusNode"}), |
getDisplayedValue: function(){ |
return this.filter(this.textbox.value); |
}, |
getValue: function(){ |
return this.parse(this.getDisplayedValue(), this.constraints); |
}, |
setValue: function(value, /*Boolean, optional*/ priorityChange, /*String, optional*/ formattedValue){ |
var filteredValue = this.filter(value); |
if((typeof filteredValue == typeof value) && (formattedValue == null || formattedValue == undefined)){ |
formattedValue = this.format(filteredValue, this.constraints); |
} |
if(formattedValue != null && formattedValue != undefined){ |
this.textbox.value = formattedValue; |
} |
dijit.form.TextBox.superclass.setValue.call(this, filteredValue, priorityChange); |
}, |
setDisplayedValue: function(/*String*/value){ |
this.textbox.value = value; |
this.setValue(this.getValue(), true); |
}, |
forWaiValuenow: function(){ |
return this.getDisplayedValue(); |
}, |
format: function(/* String */ value, /* Object */ constraints){ |
// summary: Replacable function to convert a value to a properly formatted string |
return ((value == null || value == undefined) ? "" : (value.toString ? value.toString() : value)); |
}, |
parse: function(/* String */ value, /* Object */ constraints){ |
// summary: Replacable function to convert a formatted string to a value |
return value; |
}, |
postCreate: function(){ |
// setting the value here is needed since value="" in the template causes "undefined" |
// and setting in the DOM (instead of the JS object) helps with form reset actions |
this.textbox.setAttribute("value", this.getDisplayedValue()); |
this.inherited('postCreate', arguments); |
if(this.srcNodeRef){ |
dojo.style(this.textbox, "cssText", this.style); |
this.textbox.className += " " + this["class"]; |
} |
this._layoutHack(); |
}, |
_layoutHack: function(){ |
// summary: work around table sizing bugs on FF2 by forcing redraw |
if(dojo.isFF == 2 && this.domNode.tagName=="TABLE"){ |
var node=this.domNode; |
var old = node.style.opacity; |
node.style.opacity = "0.999"; |
setTimeout(function(){ |
node.style.opacity = old; |
}, 0); |
} |
}, |
filter: function(val){ |
// summary: Apply various filters to textbox value |
if(val == undefined || val == null){ return ""; } |
else if(typeof val != "string"){ return val; } |
if(this.trim){ |
val = dojo.trim(val); |
} |
if(this.uppercase){ |
val = val.toUpperCase(); |
} |
if(this.lowercase){ |
val = val.toLowerCase(); |
} |
if(this.propercase){ |
val = val.replace(/[^\s]+/g, function(word){ |
return word.substring(0,1).toUpperCase() + word.substring(1); |
}); |
} |
return val; |
}, |
// event handlers, you can over-ride these in your own subclasses |
_onBlur: function(){ |
this.setValue(this.getValue(), (this.isValid ? this.isValid() : true)); |
}, |
onkeyup: function(){ |
// TODO: it would be nice to massage the value (ie: automatic uppercase, etc) as the user types |
// but this messes up the cursor position if you are typing into the middle of a word, and |
// also trimming doesn't work correctly (it prevents spaces between words too!) |
// this.setValue(this.getValue()); |
} |
} |
); |
} |
/trunk/api/js/dojo1.0/dijit/form/Form.js |
---|
New file |
0,0 → 1,283 |
if(!dojo._hasResource["dijit.form.Form"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. |
dojo._hasResource["dijit.form.Form"] = true; |
dojo.provide("dijit.form.Form"); |
dojo.require("dijit._Widget"); |
dojo.require("dijit._Templated"); |
dojo.declare("dijit.form._FormMixin", null, |
{ |
/* |
summary: |
Widget corresponding to <form> tag, for validation and serialization |
usage: |
<form dojoType="dijit.form.Form" id="myForm"> |
Name: <input type="text" name="name" /> |
</form> |
myObj={name: "John Doe"}; |
dijit.byId('myForm').setValues(myObj); |
myObj=dijit.byId('myForm').getValues(); |
TODO: |
* Repeater |
* better handling for arrays. Often form elements have names with [] like |
* people[3].sex (for a list of people [{name: Bill, sex: M}, ...]) |
*/ |
// HTML <FORM> attributes |
action: "", |
method: "", |
enctype: "", |
name: "", |
"accept-charset": "", |
accept: "", |
target: "", |
attributeMap: dojo.mixin(dojo.clone(dijit._Widget.prototype.attributeMap), |
{action: "", method: "", enctype: "", "accept-charset": "", accept: "", target: ""}), |
// execute: Function |
// User defined function to do stuff when the user hits the submit button |
execute: function(/*Object*/ formContents){}, |
// onCancel: Function |
// Callback when user has canceled dialog, to notify container |
// (user shouldn't override) |
onCancel: function(){}, |
// onExecute: Function |
// Callback when user is about to execute dialog, to notify container |
// (user shouldn't override) |
onExecute: function(){}, |
templateString: "<form dojoAttachPoint='containerNode' dojoAttachEvent='onsubmit:_onSubmit' name='${name}' enctype='multipart/form-data'></form>", |
_onSubmit: function(/*event*/e) { |
// summary: callback when user hits submit button |
dojo.stopEvent(e); |
this.onExecute(); // notify container that we are about to execute |
this.execute(this.getValues()); |
}, |
submit: function() { |
// summary: programatically submit form |
this.containerNode.submit(); |
}, |
setValues: function(/*object*/obj) { |
// summary: fill in form values from a JSON structure |
// generate map from name --> [list of widgets with that name] |
var map = {}; |
dojo.forEach(this.getDescendants(), function(widget){ |
if(!widget.name){ return; } |
var entry = map[widget.name] || (map[widget.name] = [] ); |
entry.push(widget); |
}); |
// call setValue() or setChecked() for each widget, according to obj |
for(var name in map){ |
var widgets = map[name], // array of widgets w/this name |
values = dojo.getObject(name, false, obj); // list of values for those widgets |
if(!dojo.isArray(values)){ |
values = [ values ]; |
} |
if(widgets[0].setChecked){ |
// for checkbox/radio, values is a list of which widgets should be checked |
dojo.forEach(widgets, function(w, i){ |
w.setChecked(dojo.indexOf(values, w.value) != -1); |
}); |
}else{ |
// otherwise, values is a list of values to be assigned sequentially to each widget |
dojo.forEach(widgets, function(w, i){ |
w.setValue(values[i]); |
}); |
} |
} |
/*** |
* TODO: code for plain input boxes (this shouldn't run for inputs that are part of widgets |
dojo.forEach(this.containerNode.elements, function(element){ |
if (element.name == ''){return}; // like "continue" |
var namePath = element.name.split("."); |
var myObj=obj; |
var name=namePath[namePath.length-1]; |
for(var j=1,len2=namePath.length;j<len2;++j) { |
var p=namePath[j - 1]; |
// repeater support block |
var nameA=p.split("["); |
if (nameA.length > 1) { |
if(typeof(myObj[nameA[0]]) == "undefined") { |
myObj[nameA[0]]=[ ]; |
} // if |
nameIndex=parseInt(nameA[1]); |
if(typeof(myObj[nameA[0]][nameIndex]) == "undefined") { |
myObj[nameA[0]][nameIndex]={}; |
} |
myObj=myObj[nameA[0]][nameIndex]; |
continue; |
} // repeater support ends |
if(typeof(myObj[p]) == "undefined") { |
myObj=undefined; |
break; |
}; |
myObj=myObj[p]; |
} |
if (typeof(myObj) == "undefined") { |
return; // like "continue" |
} |
if (typeof(myObj[name]) == "undefined" && this.ignoreNullValues) { |
return; // like "continue" |
} |
// TODO: widget values (just call setValue() on the widget) |
switch(element.type) { |
case "checkbox": |
element.checked = (name in myObj) && |
dojo.some(myObj[name], function(val){ return val==element.value; }); |
break; |
case "radio": |
element.checked = (name in myObj) && myObj[name]==element.value; |
break; |
case "select-multiple": |
element.selectedIndex=-1; |
dojo.forEach(element.options, function(option){ |
option.selected = dojo.some(myObj[name], function(val){ return option.value == val; }); |
}); |
break; |
case "select-one": |
element.selectedIndex="0"; |
dojo.forEach(element.options, function(option){ |
option.selected = option.value == myObj[name]; |
}); |
break; |
case "hidden": |
case "text": |
case "textarea": |
case "password": |
element.value = myObj[name] || ""; |
break; |
} |
}); |
*/ |
}, |
getValues: function() { |
// summary: generate JSON structure from form values |
// get widget values |
var obj = {}; |
dojo.forEach(this.getDescendants(), function(widget){ |
var value = widget.getValue ? widget.getValue() : widget.value; |
var name = widget.name; |
if(!name){ return; } |
// Store widget's value(s) as a scalar, except for checkboxes which are automatically arrays |
if(widget.setChecked){ |
if(/Radio/.test(widget.declaredClass)){ |
// radio button |
if(widget.checked){ |
dojo.setObject(name, value, obj); |
} |
}else{ |
// checkbox/toggle button |
var ary=dojo.getObject(name, false, obj); |
if(!ary){ |
ary=[]; |
dojo.setObject(name, ary, obj); |
} |
if(widget.checked){ |
ary.push(value); |
} |
} |
}else{ |
// plain input |
dojo.setObject(name, value, obj); |
} |
}); |
/*** |
* code for plain input boxes (see also dojo.formToObject, can we use that instead of this code? |
* but it doesn't understand [] notation, presumably) |
var obj = { }; |
dojo.forEach(this.containerNode.elements, function(elm){ |
if (!elm.name) { |
return; // like "continue" |
} |
var namePath = elm.name.split("."); |
var myObj=obj; |
var name=namePath[namePath.length-1]; |
for(var j=1,len2=namePath.length;j<len2;++j) { |
var nameIndex = null; |
var p=namePath[j - 1]; |
var nameA=p.split("["); |
if (nameA.length > 1) { |
if(typeof(myObj[nameA[0]]) == "undefined") { |
myObj[nameA[0]]=[ ]; |
} // if |
nameIndex=parseInt(nameA[1]); |
if(typeof(myObj[nameA[0]][nameIndex]) == "undefined") { |
myObj[nameA[0]][nameIndex]={}; |
} |
} else if(typeof(myObj[nameA[0]]) == "undefined") { |
myObj[nameA[0]]={} |
} // if |
if (nameA.length == 1) { |
myObj=myObj[nameA[0]]; |
} else { |
myObj=myObj[nameA[0]][nameIndex]; |
} // if |
} // for |
if ((elm.type != "select-multiple" && elm.type != "checkbox" && elm.type != "radio") || (elm.type=="radio" && elm.checked)) { |
if(name == name.split("[")[0]) { |
myObj[name]=elm.value; |
} else { |
// can not set value when there is no name |
} |
} else if (elm.type == "checkbox" && elm.checked) { |
if(typeof(myObj[name]) == 'undefined') { |
myObj[name]=[ ]; |
} |
myObj[name].push(elm.value); |
} else if (elm.type == "select-multiple") { |
if(typeof(myObj[name]) == 'undefined') { |
myObj[name]=[ ]; |
} |
for (var jdx=0,len3=elm.options.length; jdx<len3; ++jdx) { |
if (elm.options[jdx].selected) { |
myObj[name].push(elm.options[jdx].value); |
} |
} |
} // if |
name=undefined; |
}); // forEach |
***/ |
return obj; |
}, |
isValid: function() { |
// TODO: ComboBox might need time to process a recently input value. This should be async? |
// make sure that every widget that has a validator function returns true |
return dojo.every(this.getDescendants(), function(widget){ |
return !widget.isValid || widget.isValid(); |
}); |
} |
}); |
dojo.declare( |
"dijit.form.Form", |
[dijit._Widget, dijit._Templated, dijit.form._FormMixin], |
null |
); |
} |
/trunk/api/js/dojo1.0/dijit/form/NumberTextBox.js |
---|
New file |
0,0 → 1,42 |
if(!dojo._hasResource["dijit.form.NumberTextBox"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. |
dojo._hasResource["dijit.form.NumberTextBox"] = true; |
dojo.provide("dijit.form.NumberTextBox"); |
dojo.require("dijit.form.ValidationTextBox"); |
dojo.require("dojo.number"); |
dojo.declare( |
"dijit.form.NumberTextBoxMixin", |
null, |
{ |
// summary: |
// A mixin for all number textboxes |
regExpGen: dojo.number.regexp, |
format: function(/*Number*/ value, /*Object*/ constraints){ |
if(isNaN(value)){ return ""; } |
return dojo.number.format(value, constraints); |
}, |
parse: dojo.number.parse, |
filter: function(/*Number*/ value){ |
if(typeof value == "string"){ return this.inherited('filter', arguments); } |
return (isNaN(value) ? '' : value); |
}, |
value: NaN |
} |
); |
dojo.declare( |
"dijit.form.NumberTextBox", |
[dijit.form.RangeBoundTextBox,dijit.form.NumberTextBoxMixin], |
{ |
// summary: |
// A validating, serializable, range-bound text box. |
// constraints object: min, max, places |
} |
); |
} |
/trunk/api/js/dojo1.0/dijit/form/_FormWidget.js |
---|
New file |
0,0 → 1,269 |
if(!dojo._hasResource["dijit.form._FormWidget"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. |
dojo._hasResource["dijit.form._FormWidget"] = true; |
dojo.provide("dijit.form._FormWidget"); |
dojo.require("dijit._Widget"); |
dojo.require("dijit._Templated"); |
dojo.declare("dijit.form._FormWidget", [dijit._Widget, dijit._Templated], |
{ |
/* |
Summary: |
FormElement widgets correspond to native HTML elements such as <input> or <button> or <select>. |
Each FormElement represents a single input value, and has a (possibly hidden) <input> element, |
to which it serializes its input value, so that form submission (either normal submission or via FormBind?) |
works as expected. |
All these widgets should have these attributes just like native HTML input elements. |
You can set them during widget construction, but after that they are read only. |
They also share some common methods. |
*/ |
// baseClass: String |
// Root CSS class of the widget (ex: dijitTextBox), used to add CSS classes of widget |
// (ex: "dijitTextBox dijitTextBoxInvalid dijitTextBoxFocused dijitTextBoxInvalidFocused") |
// See _setStateClass(). |
baseClass: "", |
// value: String |
// Corresponds to the native HTML <input> element's attribute. |
value: "", |
// name: String |
// Name used when submitting form; same as "name" attribute or plain HTML elements |
name: "", |
// id: String |
// Corresponds to the native HTML <input> element's attribute. |
// Also becomes the id for the widget. |
id: "", |
// alt: String |
// Corresponds to the native HTML <input> element's attribute. |
alt: "", |
// type: String |
// Corresponds to the native HTML <input> element's attribute. |
type: "text", |
// tabIndex: Integer |
// Order fields are traversed when user hits the tab key |
tabIndex: "0", |
// disabled: Boolean |
// Should this widget respond to user input? |
// In markup, this is specified as "disabled='disabled'", or just "disabled". |
disabled: false, |
// intermediateChanges: Boolean |
// Fires onChange for each value change or only on demand |
intermediateChanges: false, |
// These mixins assume that the focus node is an INPUT, as many but not all _FormWidgets are. |
// Don't attempt to mixin the 'type', 'name' attributes here programatically -- they must be declared |
// directly in the template as read by the parser in order to function. IE is known to specifically |
// require the 'name' attribute at element creation time. |
attributeMap: dojo.mixin(dojo.clone(dijit._Widget.prototype.attributeMap), |
{id:"focusNode", tabIndex:"focusNode", alt:"focusNode"}), |
setDisabled: function(/*Boolean*/ disabled){ |
// summary: |
// Set disabled state of widget. |
this.domNode.disabled = this.disabled = disabled; |
if(this.focusNode){ |
this.focusNode.disabled = disabled; |
} |
if(disabled){ |
//reset those, because after the domNode is disabled, we can no longer receive |
//mouse related events, see #4200 |
this._hovering = false; |
this._active = false; |
} |
dijit.setWaiState(this.focusNode || this.domNode, "disabled", disabled); |
this._setStateClass(); |
}, |
_onMouse : function(/*Event*/ event){ |
// summary: |
// Sets _hovering, _active, and stateModifier properties depending on mouse state, |
// then calls setStateClass() to set appropriate CSS classes for this.domNode. |
// |
// To get a different CSS class for hover, send onmouseover and onmouseout events to this method. |
// To get a different CSS class while mouse button is depressed, send onmousedown to this method. |
var mouseNode = event.target; |
if(mouseNode && mouseNode.getAttribute){ |
this.stateModifier = mouseNode.getAttribute("stateModifier") || ""; |
} |
if(!this.disabled){ |
switch(event.type){ |
case "mouseenter" : |
case "mouseover" : |
this._hovering = true; |
break; |
case "mouseout" : |
case "mouseleave" : |
this._hovering = false; |
break; |
case "mousedown" : |
this._active = true; |
// set a global event to handle mouseup, so it fires properly |
// even if the cursor leaves the button |
var self = this; |
// #2685: use this.connect and disconnect so destroy works properly |
var mouseUpConnector = this.connect(dojo.body(), "onmouseup", function(){ |
self._active = false; |
self._setStateClass(); |
self.disconnect(mouseUpConnector); |
}); |
break; |
} |
this._setStateClass(); |
} |
}, |
isFocusable: function(){ |
return !this.disabled && (dojo.style(this.domNode, "display") != "none"); |
}, |
focus: function(){ |
dijit.focus(this.focusNode); |
}, |
_setStateClass: function(){ |
// summary |
// Update the visual state of the widget by setting the css classes on this.domNode |
// (or this.stateNode if defined) by combining this.baseClass with |
// various suffixes that represent the current widget state(s). |
// |
// In the case where a widget has multiple |
// states, it sets the class based on all possible |
// combinations. For example, an invalid form widget that is being hovered |
// will be "dijitInput dijitInputInvalid dijitInputHover dijitInputInvalidHover". |
// |
// For complex widgets with multiple regions, there can be various hover/active states, |
// such as "Hover" or "CloseButtonHover" (for tab buttons). |
// This is controlled by a stateModifier="CloseButton" attribute on the close button node. |
// |
// The widget may have one or more of the following states, determined |
// by this.state, this.checked, this.valid, and this.selected: |
// Error - ValidationTextBox sets this.state to "Error" if the current input value is invalid |
// Checked - ex: a checkmark or a ToggleButton in a checked state, will have this.checked==true |
// Selected - ex: currently selected tab will have this.selected==true |
// |
// In addition, it may have at most one of the following states, |
// based on this.disabled and flags set in _onMouse (this._active, this._hovering, this._focused): |
// Disabled - if the widget is disabled |
// Active - if the mouse (or space/enter key?) is being pressed down |
// Focused - if the widget has focus |
// Hover - if the mouse is over the widget |
// |
// (even if multiple af the above conditions are true we only pick the first matching one) |
// Get original (non state related, non baseClass related) class specified in template |
if(!("staticClass" in this)){ |
this.staticClass = (this.stateNode||this.domNode).className; |
} |
// Compute new set of classes |
var classes = [ this.baseClass ]; |
function multiply(modifier){ |
classes=classes.concat(dojo.map(classes, function(c){ return c+modifier; })); |
} |
if(this.checked){ |
multiply("Checked"); |
} |
if(this.state){ |
multiply(this.state); |
} |
if(this.selected){ |
multiply("Selected"); |
} |
// Only one of these four can be applied. |
// Active trumps Focused, Focused trumps Hover, and Disabled trumps all. |
if(this.disabled){ |
multiply("Disabled"); |
}else if(this._active){ |
multiply(this.stateModifier+"Active"); |
}else{ |
if(this._focused){ |
multiply("Focused"); |
} |
if((this.stateModifier || !this._focused) && this._hovering){ |
multiply(this.stateModifier+"Hover"); |
} |
} |
(this.stateNode || this.domNode).className = this.staticClass + " " + classes.join(" "); |
}, |
onChange: function(newValue){ |
// summary: callback when value is changed |
}, |
postCreate: function(){ |
this.setValue(this.value, null); // null reserved for initial value |
this.setDisabled(this.disabled); |
this._setStateClass(); |
}, |
setValue: function(/*anything*/ newValue, /*Boolean, optional*/ priorityChange){ |
// summary: set the value of the widget. |
this._lastValue = newValue; |
dijit.setWaiState(this.focusNode || this.domNode, "valuenow", this.forWaiValuenow()); |
if(priorityChange === undefined){ priorityChange = true; } // setValue with value only should fire onChange |
if(this._lastValueReported == undefined && priorityChange === null){ // don't report the initial value |
this._lastValueReported = newValue; |
} |
if((this.intermediateChanges || priorityChange) && |
((newValue && newValue.toString)?newValue.toString():newValue) !== ((this._lastValueReported && this._lastValueReported.toString)?this._lastValueReported.toString():this._lastValueReported)){ |
this._lastValueReported = newValue; |
this.onChange(newValue); |
} |
}, |
getValue: function(){ |
// summary: get the value of the widget. |
return this._lastValue; |
}, |
undo: function(){ |
// summary: restore the value to the last value passed to onChange |
this.setValue(this._lastValueReported, false); |
}, |
_onKeyPress: function(e){ |
if(e.keyCode == dojo.keys.ESCAPE && !e.shiftKey && !e.ctrlKey && !e.altKey){ |
var v = this.getValue(); |
var lv = this._lastValueReported; |
// Equality comparison of objects such as dates are done by reference so |
// two distinct objects are != even if they have the same data. So use |
// toStrings in case the values are objects. |
if((typeof lv != "undefined") && ((v!==null && v.toString)?v.toString():null) !== lv.toString()){ |
this.undo(); |
dojo.stopEvent(e); |
return false; |
} |
} |
return true; |
}, |
forWaiValuenow: function(){ |
// summary: returns a value, reflecting the current state of the widget, |
// to be used for the ARIA valuenow. |
// This method may be overridden by subclasses that want |
// to use something other than this.getValue() for valuenow |
return this.getValue(); |
} |
}); |
} |
/trunk/api/js/dojo1.0/dijit/form/ComboBox.js |
---|
New file |
0,0 → 1,828 |
if(!dojo._hasResource["dijit.form.ComboBox"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. |
dojo._hasResource["dijit.form.ComboBox"] = true; |
dojo.provide("dijit.form.ComboBox"); |
dojo.require("dojo.data.ItemFileReadStore"); |
dojo.require("dijit.form.ValidationTextBox"); |
dojo.requireLocalization("dijit.form", "ComboBox", null, "ko,zh,ja,zh-tw,ru,it,hu,ROOT,fr,pt,pl,es,de,cs"); |
dojo.declare( |
"dijit.form.ComboBoxMixin", |
null, |
{ |
// summary: |
// Auto-completing text box, and base class for FilteringSelect widget. |
// |
// The drop down box's values are populated from an class called |
// a data provider, which returns a list of values based on the characters |
// that the user has typed into the input box. |
// |
// Some of the options to the ComboBox are actually arguments to the data |
// provider. |
// |
// You can assume that all the form widgets (and thus anything that mixes |
// in ComboBoxMixin) will inherit from _FormWidget and thus the "this" |
// reference will also "be a" _FormWidget. |
// item: Object |
// This is the item returned by the dojo.data.store implementation that |
// provides the data for this cobobox, it's the currently selected item. |
item: null, |
// pageSize: Integer |
// Argument to data provider. |
// Specifies number of search results per page (before hitting "next" button) |
pageSize: Infinity, |
// store: Object |
// Reference to data provider object used by this ComboBox |
store: null, |
// query: Object |
// A query that can be passed to 'store' to initially filter the items, |
// before doing further filtering based on searchAttr and the key. |
query: {}, |
// autoComplete: Boolean |
// If you type in a partial string, and then tab out of the <input> box, |
// automatically copy the first entry displayed in the drop down list to |
// the <input> field |
autoComplete: true, |
// searchDelay: Integer |
// Delay in milliseconds between when user types something and we start |
// searching based on that value |
searchDelay: 100, |
// searchAttr: String |
// Searches pattern match against this field |
searchAttr: "name", |
// ignoreCase: Boolean |
// Set true if the ComboBox should ignore case when matching possible items |
ignoreCase: true, |
// hasDownArrow: Boolean |
// Set this textbox to have a down arrow button. |
// Defaults to true. |
hasDownArrow:true, |
// _hasFocus: Boolean |
// Represents focus state of the textbox |
// TODO: get rid of this; it's unnecessary (but currently referenced in FilteringSelect) |
_hasFocus:false, |
templateString:"<table class=\"dijit dijitReset dijitInlineTable dijitLeft\" cellspacing=\"0\" cellpadding=\"0\"\n\tid=\"widget_${id}\" name=\"${name}\" dojoAttachEvent=\"onmouseenter:_onMouse,onmouseleave:_onMouse\" waiRole=\"presentation\"\n\t><tr class=\"dijitReset\"\n\t\t><td class='dijitReset dijitStretch dijitInputField' width=\"100%\"\n\t\t\t><input type=\"text\" autocomplete=\"off\" name=\"${name}\"\n\t\t\tdojoAttachEvent=\"onkeypress, onkeyup, onfocus, compositionend\"\n\t\t\tdojoAttachPoint=\"textbox,focusNode\" waiRole=\"combobox\"\n\t\t/></td\n\t\t><td class=\"dijitReset dijitValidationIconField\" width=\"0%\"\n\t\t\t><div dojoAttachPoint='iconNode' class='dijitValidationIcon'></div\n\t\t\t><div class='dijitValidationIconText'>Χ</div\n\t\t></td\n\t\t><td class='dijitReset dijitRight dijitButtonNode dijitDownArrowButton' width=\"0%\"\n\t\t\tdojoAttachPoint=\"downArrowNode\"\n\t\t\tdojoAttachEvent=\"onmousedown:_onArrowMouseDown,onmouseup:_onMouse,onmouseenter:_onMouse,onmouseleave:_onMouse\"\n\t\t\t><div class=\"dijitDownArrowButtonInner\" waiRole=\"presentation\"\n\t\t\t\t><div class=\"dijitDownArrowButtonChar\">▼</div\n\t\t\t></div\n\t\t></td\t\n\t></tr\n></table>\n", |
baseClass:"dijitComboBox", |
_lastDisplayedValue: "", |
getValue:function(){ |
// don't get the textbox value but rather the previously set hidden value |
return dijit.form.TextBox.superclass.getValue.apply(this, arguments); |
}, |
setDisplayedValue:function(/*String*/ value){ |
this._lastDisplayedValue = value; |
this.setValue(value, true); |
}, |
_getCaretPos: function(/*DomNode*/ element){ |
// khtml 3.5.2 has selection* methods as does webkit nightlies from 2005-06-22 |
if(typeof(element.selectionStart)=="number"){ |
// FIXME: this is totally borked on Moz < 1.3. Any recourse? |
return element.selectionStart; |
}else if(dojo.isIE){ |
// 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(/*DomNode*/ element, /*Number*/ location){ |
location = parseInt(location); |
this._setSelectedRange(element, location, location); |
}, |
_setSelectedRange: function(/*DomNode*/ element, /*Number*/ start, /*Number*/ 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){ |
dijit.focus(element); |
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(); |
dijit.focus(element); |
// 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); |
} |
} |
}, |
onkeypress: function(/*Event*/ evt){ |
// summary: handles keyboard events |
//except for pasting case - ctrl + v(118) |
if(evt.altKey || (evt.ctrlKey && evt.charCode != 118)){ |
return; |
} |
var doSearch = false; |
this.item = null; // #4872 |
if(this._isShowingNow){this._popupWidget.handleKey(evt);} |
switch(evt.keyCode){ |
case dojo.keys.PAGE_DOWN: |
case dojo.keys.DOWN_ARROW: |
if(!this._isShowingNow||this._prev_key_esc){ |
this._arrowPressed(); |
doSearch=true; |
}else{ |
this._announceOption(this._popupWidget.getHighlightedOption()); |
} |
dojo.stopEvent(evt); |
this._prev_key_backspace = false; |
this._prev_key_esc = false; |
break; |
case dojo.keys.PAGE_UP: |
case dojo.keys.UP_ARROW: |
if(this._isShowingNow){ |
this._announceOption(this._popupWidget.getHighlightedOption()); |
} |
dojo.stopEvent(evt); |
this._prev_key_backspace = false; |
this._prev_key_esc = false; |
break; |
case dojo.keys.ENTER: |
// prevent submitting form if user presses enter |
// also prevent accepting the value if either Next or Previous are selected |
var highlighted; |
if(this._isShowingNow&&(highlighted=this._popupWidget.getHighlightedOption())){ |
// only stop event on prev/next |
if(highlighted==this._popupWidget.nextButton){ |
this._nextSearch(1); |
dojo.stopEvent(evt); |
break; |
} |
else if(highlighted==this._popupWidget.previousButton){ |
this._nextSearch(-1); |
dojo.stopEvent(evt); |
break; |
} |
}else{ |
this.setDisplayedValue(this.getDisplayedValue()); |
} |
// default case: |
// prevent submit, but allow event to bubble |
evt.preventDefault(); |
// fall through |
case dojo.keys.TAB: |
var newvalue=this.getDisplayedValue(); |
// #4617: if the user had More Choices selected fall into the _onBlur handler |
if(this._popupWidget && |
(newvalue == this._popupWidget._messages["previousMessage"] || |
newvalue == this._popupWidget._messages["nextMessage"])){ |
break; |
} |
if(this._isShowingNow){ |
this._prev_key_backspace = false; |
this._prev_key_esc = false; |
if(this._popupWidget.getHighlightedOption()){ |
this._popupWidget.setValue({target:this._popupWidget.getHighlightedOption()}, true); |
} |
this._hideResultList(); |
} |
break; |
case dojo.keys.SPACE: |
this._prev_key_backspace = false; |
this._prev_key_esc = false; |
if(this._isShowingNow && this._popupWidget.getHighlightedOption()){ |
dojo.stopEvent(evt); |
this._selectOption(); |
this._hideResultList(); |
}else{ |
doSearch = true; |
} |
break; |
case dojo.keys.ESCAPE: |
this._prev_key_backspace = false; |
this._prev_key_esc = true; |
this._hideResultList(); |
if(this._lastDisplayedValue != this.getDisplayedValue()){ |
this.setDisplayedValue(this._lastDisplayedValue); |
dojo.stopEvent(evt); |
}else{ |
this.setValue(this.getValue(), false); |
} |
break; |
case dojo.keys.DELETE: |
case dojo.keys.BACKSPACE: |
this._prev_key_esc = false; |
this._prev_key_backspace = true; |
doSearch = true; |
break; |
case dojo.keys.RIGHT_ARROW: // fall through |
case dojo.keys.LEFT_ARROW: // fall through |
this._prev_key_backspace = false; |
this._prev_key_esc = false; |
break; |
default:// non char keys (F1-F12 etc..) shouldn't open list |
this._prev_key_backspace = false; |
this._prev_key_esc = false; |
if(dojo.isIE || evt.charCode != 0){ |
doSearch=true; |
} |
} |
if(this.searchTimer){ |
clearTimeout(this.searchTimer); |
} |
if(doSearch){ |
// need to wait a tad before start search so that the event bubbles through DOM and we have value visible |
this.searchTimer = setTimeout(dojo.hitch(this, this._startSearchFromInput), this.searchDelay); |
} |
}, |
_autoCompleteText: function(/*String*/ text){ |
// summary: |
// Fill in the textbox with the first item from the drop down list, and |
// highlight the characters that were auto-completed. For example, if user |
// typed "CA" and the drop down list appeared, the textbox would be changed to |
// "California" and "ifornia" would be highlighted. |
// IE7: clear selection so next highlight works all the time |
this._setSelectedRange(this.focusNode, this.focusNode.value.length, this.focusNode.value.length); |
// does text autoComplete the value in the textbox? |
// #3744: escape regexp so the user's input isn't treated as a regular expression. |
// Example: If the user typed "(" then the regexp would throw "unterminated parenthetical." |
// Also see #2558 for the autocompletion bug this regular expression fixes. |
if(new RegExp("^"+escape(this.focusNode.value), this.ignoreCase ? "i" : "").test(escape(text))){ |
var cpos = this._getCaretPos(this.focusNode); |
// only try to extend if we added the last character at the end of the input |
if((cpos+1) > this.focusNode.value.length){ |
// only add to input node as we would overwrite Capitalisation of chars |
// actually, that is ok |
this.focusNode.value = text;//.substr(cpos); |
// visually highlight the autocompleted characters |
this._setSelectedRange(this.focusNode, cpos, this.focusNode.value.length); |
dijit.setWaiState(this.focusNode, "valuenow", text); |
} |
}else{ |
// text does not autoComplete; replace the whole value and highlight |
this.focusNode.value = text; |
this._setSelectedRange(this.focusNode, 0, this.focusNode.value.length); |
dijit.setWaiState(this.focusNode, "valuenow", text); |
} |
}, |
_openResultList: function(/*Object*/ results, /*Object*/ dataObject){ |
if(this.disabled || dataObject.query[this.searchAttr] != this._lastQuery){ |
return; |
} |
this._popupWidget.clearResultList(); |
if(!results.length){ |
this._hideResultList(); |
return; |
} |
// Fill in the textbox with the first item from the drop down list, and |
// highlight the characters that were auto-completed. For example, if user |
// typed "CA" and the drop down list appeared, the textbox would be changed to |
// "California" and "ifornia" would be highlighted. |
var zerothvalue=new String(this.store.getValue(results[0], this.searchAttr)); |
if(zerothvalue && this.autoComplete && !this._prev_key_backspace && |
// when the user clicks the arrow button to show the full list, |
// startSearch looks for "*". |
// it does not make sense to autocomplete |
// if they are just previewing the options available. |
(dataObject.query[this.searchAttr] != "*")){ |
this._autoCompleteText(zerothvalue); |
// announce the autocompleted value |
dijit.setWaiState(this.focusNode || this.domNode, "valuenow", zerothvalue); |
} |
this._popupWidget.createOptions(results, dataObject, dojo.hitch(this, this._getMenuLabelFromItem)); |
// show our list (only if we have content, else nothing) |
this._showResultList(); |
// #4091: tell the screen reader that the paging callback finished by shouting the next choice |
if(dataObject.direction){ |
if(dataObject.direction==1){ |
this._popupWidget.highlightFirstOption(); |
}else if(dataObject.direction==-1){ |
this._popupWidget.highlightLastOption(); |
} |
this._announceOption(this._popupWidget.getHighlightedOption()); |
} |
}, |
_showResultList: function(){ |
this._hideResultList(); |
var items = this._popupWidget.getItems(), |
visibleCount = Math.min(items.length,this.maxListLength); |
this._arrowPressed(); |
// hide the tooltip |
this._displayMessage(""); |
// Position the list and if it's too big to fit on the screen then |
// size it to the maximum possible height |
// Our dear friend IE doesnt take max-height so we need to calculate that on our own every time |
// TODO: want to redo this, see http://trac.dojotoolkit.org/ticket/3272, http://trac.dojotoolkit.org/ticket/4108 |
with(this._popupWidget.domNode.style){ |
// natural size of the list has changed, so erase old width/height settings, |
// which were hardcoded in a previous call to this function (via dojo.marginBox() call) |
width=""; |
height=""; |
} |
var best=this.open(); |
// #3212: only set auto scroll bars if necessary |
// prevents issues with scroll bars appearing when they shouldn't when node is made wider (fractional pixels cause this) |
var popupbox=dojo.marginBox(this._popupWidget.domNode); |
this._popupWidget.domNode.style.overflow=((best.h==popupbox.h)&&(best.w==popupbox.w))?"hidden":"auto"; |
// #4134: borrow TextArea scrollbar test so content isn't covered by scrollbar and horizontal scrollbar doesn't appear |
var newwidth=best.w; |
if(best.h<this._popupWidget.domNode.scrollHeight){newwidth+=16;} |
dojo.marginBox(this._popupWidget.domNode, {h:best.h,w:Math.max(newwidth,this.domNode.offsetWidth)}); |
}, |
_hideResultList: function(){ |
if(this._isShowingNow){ |
dijit.popup.close(this._popupWidget); |
this._arrowIdle(); |
this._isShowingNow=false; |
} |
}, |
_onBlur: function(){ |
// summary: called magically when focus has shifted away from this widget and it's dropdown |
this._hasFocus=false; |
this._hasBeenBlurred = true; |
this._hideResultList(); |
this._arrowIdle(); |
// if the user clicks away from the textbox OR tabs away, set the value to the textbox value |
// #4617: if value is now more choices or previous choices, revert the value |
var newvalue=this.getDisplayedValue(); |
if(this._popupWidget&&(newvalue==this._popupWidget._messages["previousMessage"]||newvalue==this._popupWidget._messages["nextMessage"])){ |
this.setValue(this._lastValueReported, true); |
}else{ |
this.setDisplayedValue(newvalue); |
} |
}, |
onfocus:function(/*Event*/ evt){ |
this._hasFocus=true; |
// update styling to reflect that we are focused |
this._onMouse(evt); |
}, |
_announceOption: function(/*Node*/ node){ |
// summary: |
// a11y code that puts the highlighted option in the textbox |
// This way screen readers will know what is happening in the menu |
if(node==null){return;} |
// pull the text value from the item attached to the DOM node |
var newValue; |
if(node==this._popupWidget.nextButton||node==this._popupWidget.previousButton){ |
newValue=node.innerHTML; |
}else{ |
newValue=this.store.getValue(node.item, this.searchAttr); |
} |
// get the text that the user manually entered (cut off autocompleted text) |
this.focusNode.value=this.focusNode.value.substring(0, this._getCaretPos(this.focusNode)); |
// autocomplete the rest of the option to announce change |
this._autoCompleteText(newValue); |
}, |
_selectOption: function(/*Event*/ evt){ |
var tgt = null; |
if(!evt){ |
evt ={ target: this._popupWidget.getHighlightedOption()}; |
} |
// what if nothing is highlighted yet? |
if(!evt.target){ |
// handle autocompletion where the the user has hit ENTER or TAB |
this.setDisplayedValue(this.getDisplayedValue()); |
return; |
// otherwise the user has accepted the autocompleted value |
}else{ |
tgt = evt.target; |
} |
if(!evt.noHide){ |
this._hideResultList(); |
this._setCaretPos(this.focusNode, this.store.getValue(tgt.item, this.searchAttr).length); |
} |
this._doSelect(tgt); |
}, |
_doSelect: function(tgt){ |
this.item = tgt.item; |
this.setValue(this.store.getValue(tgt.item, this.searchAttr), true); |
}, |
_onArrowMouseDown: function(evt){ |
// summary: callback when arrow is clicked |
if(this.disabled){ |
return; |
} |
dojo.stopEvent(evt); |
this.focus(); |
if(this._isShowingNow){ |
this._hideResultList(); |
}else{ |
// forces full population of results, if they click |
// on the arrow it means they want to see more options |
this._startSearch(""); |
} |
}, |
_startSearchFromInput: function(){ |
this._startSearch(this.focusNode.value); |
}, |
_startSearch: function(/*String*/ key){ |
if(!this._popupWidget){ |
this._popupWidget = new dijit.form._ComboBoxMenu({ |
onChange: dojo.hitch(this, this._selectOption) |
}); |
} |
// create a new query to prevent accidentally querying for a hidden value from FilteringSelect's keyField |
var query=this.query; |
this._lastQuery=query[this.searchAttr]=key+"*"; |
var dataObject=this.store.fetch({queryOptions:{ignoreCase:this.ignoreCase, deep:true}, query: query, onComplete:dojo.hitch(this, "_openResultList"), start:0, count:this.pageSize}); |
function nextSearch(dataObject, direction){ |
dataObject.start+=dataObject.count*direction; |
// #4091: tell callback the direction of the paging so the screen reader knows which menu option to shout |
dataObject.direction=direction; |
dataObject.store.fetch(dataObject); |
} |
this._nextSearch=this._popupWidget.onPage=dojo.hitch(this, nextSearch, dataObject); |
}, |
_getValueField:function(){ |
return this.searchAttr; |
}, |
/////////////// Event handlers ///////////////////// |
_arrowPressed: function(){ |
if(!this.disabled&&this.hasDownArrow){ |
dojo.addClass(this.downArrowNode, "dijitArrowButtonActive"); |
} |
}, |
_arrowIdle: function(){ |
if(!this.disabled&&this.hasDownArrow){ |
dojo.removeClass(this.downArrowNode, "dojoArrowButtonPushed"); |
} |
}, |
compositionend: function(/*Event*/ evt){ |
// summary: When inputting characters using an input method, such as Asian |
// languages, it will generate this event instead of onKeyDown event |
// Note: this event is only triggered in FF (not in IE) |
this.onkeypress({charCode:-1}); |
}, |
//////////// INITIALIZATION METHODS /////////////////////////////////////// |
constructor: function(){ |
this.query={}; |
}, |
postMixInProperties: function(){ |
if(!this.hasDownArrow){ |
this.baseClass = "dijitTextBox"; |
} |
if(!this.store){ |
// if user didn't specify store, then assume there are option tags |
var items = this.srcNodeRef ? dojo.query("> option", this.srcNodeRef).map(function(node){ |
node.style.display="none"; |
return { value: node.getAttribute("value"), name: String(node.innerHTML) }; |
}) : {}; |
this.store = new dojo.data.ItemFileReadStore({data: {identifier:this._getValueField(), items:items}}); |
// if there is no value set and there is an option list, |
// set the value to the first value to be consistent with native Select |
if(items && items.length && !this.value){ |
// For <select>, IE does not let you set the value attribute of the srcNodeRef (and thus dojo.mixin does not copy it). |
// IE does understand selectedIndex though, which is automatically set by the selected attribute of an option tag |
this.value = items[this.srcNodeRef.selectedIndex != -1 ? this.srcNodeRef.selectedIndex : 0] |
[this._getValueField()]; |
} |
} |
}, |
uninitialize:function(){ |
if(this._popupWidget){ |
this._hideResultList(); |
this._popupWidget.destroy() |
}; |
}, |
_getMenuLabelFromItem:function(/*Item*/ item){ |
return {html:false, label:this.store.getValue(item, this.searchAttr)}; |
}, |
open:function(){ |
this._isShowingNow=true; |
return dijit.popup.open({ |
popup: this._popupWidget, |
around: this.domNode, |
parent: this |
}); |
} |
} |
); |
dojo.declare( |
"dijit.form._ComboBoxMenu", |
[dijit._Widget, dijit._Templated], |
{ |
// summary: |
// Focus-less div based menu for internal use in ComboBox |
templateString:"<div class='dijitMenu' dojoAttachEvent='onmousedown,onmouseup,onmouseover,onmouseout' tabIndex='-1' style='overflow:\"auto\";'>" |
+"<div class='dijitMenuItem dijitMenuPreviousButton' dojoAttachPoint='previousButton'></div>" |
+"<div class='dijitMenuItem dijitMenuNextButton' dojoAttachPoint='nextButton'></div>" |
+"</div>", |
_messages:null, |
postMixInProperties:function(){ |
this._messages = dojo.i18n.getLocalization("dijit.form", "ComboBox", this.lang); |
this.inherited("postMixInProperties", arguments); |
}, |
setValue:function(/*Object*/ value){ |
this.value=value; |
this.onChange(value); |
}, |
onChange:function(/*Object*/ value){}, |
onPage:function(/*Number*/ direction){}, |
postCreate:function(){ |
// fill in template with i18n messages |
this.previousButton.innerHTML=this._messages["previousMessage"]; |
this.nextButton.innerHTML=this._messages["nextMessage"]; |
this.inherited("postCreate", arguments); |
}, |
onClose:function(){ |
this._blurOptionNode(); |
}, |
_createOption:function(/*Object*/ item, labelFunc){ |
// summary: creates an option to appear on the popup menu |
// subclassed by FilteringSelect |
var labelObject=labelFunc(item); |
var menuitem = document.createElement("div"); |
if(labelObject.html){menuitem.innerHTML=labelObject.label;} |
else{menuitem.appendChild(document.createTextNode(labelObject.label));} |
// #3250: in blank options, assign a normal height |
if(menuitem.innerHTML==""){ |
menuitem.innerHTML=" " |
} |
menuitem.item=item; |
return menuitem; |
}, |
createOptions:function(results, dataObject, labelFunc){ |
//this._dataObject=dataObject; |
//this._dataObject.onComplete=dojo.hitch(comboBox, comboBox._openResultList); |
// display "Previous . . ." button |
this.previousButton.style.display=dataObject.start==0?"none":""; |
// create options using _createOption function defined by parent ComboBox (or FilteringSelect) class |
// #2309: iterate over cache nondestructively |
var _this=this; |
dojo.forEach(results, function(item){ |
var menuitem=_this._createOption(item, labelFunc); |
menuitem.className = "dijitMenuItem"; |
_this.domNode.insertBefore(menuitem, _this.nextButton); |
}); |
// display "Next . . ." button |
this.nextButton.style.display=dataObject.count==results.length?"":"none"; |
}, |
clearResultList:function(){ |
// keep the previous and next buttons of course |
while(this.domNode.childNodes.length>2){ |
this.domNode.removeChild(this.domNode.childNodes[this.domNode.childNodes.length-2]); |
} |
}, |
// these functions are called in showResultList |
getItems:function(){ |
return this.domNode.childNodes; |
}, |
getListLength:function(){ |
return this.domNode.childNodes.length-2; |
}, |
onmousedown:function(/*Event*/ evt){ |
dojo.stopEvent(evt); |
}, |
onmouseup:function(/*Event*/ evt){ |
if(evt.target === this.domNode){ |
return; |
}else if(evt.target==this.previousButton){ |
this.onPage(-1); |
}else if(evt.target==this.nextButton){ |
this.onPage(1); |
}else{ |
var tgt=evt.target; |
// while the clicked node is inside the div |
while(!tgt.item){ |
// recurse to the top |
tgt=tgt.parentNode; |
} |
this.setValue({target:tgt}, true); |
} |
}, |
onmouseover:function(/*Event*/ evt){ |
if(evt.target === this.domNode){ return; } |
var tgt=evt.target; |
if(!(tgt==this.previousButton||tgt==this.nextButton)){ |
// while the clicked node is inside the div |
while(!tgt.item){ |
// recurse to the top |
tgt=tgt.parentNode; |
} |
} |
this._focusOptionNode(tgt); |
}, |
onmouseout:function(/*Event*/ evt){ |
if(evt.target === this.domNode){ return; } |
this._blurOptionNode(); |
}, |
_focusOptionNode:function(/*DomNode*/ node){ |
// summary: |
// does the actual highlight |
if(this._highlighted_option != node){ |
this._blurOptionNode(); |
this._highlighted_option = node; |
dojo.addClass(this._highlighted_option, "dijitMenuItemHover"); |
} |
}, |
_blurOptionNode:function(){ |
// summary: |
// removes highlight on highlighted option |
if(this._highlighted_option){ |
dojo.removeClass(this._highlighted_option, "dijitMenuItemHover"); |
this._highlighted_option = null; |
} |
}, |
_highlightNextOption:function(){ |
// because each press of a button clears the menu, |
// the highlighted option sometimes becomes detached from the menu! |
// test to see if the option has a parent to see if this is the case. |
if(!this.getHighlightedOption()){ |
this._focusOptionNode(this.domNode.firstChild.style.display=="none"?this.domNode.firstChild.nextSibling:this.domNode.firstChild); |
}else if(this._highlighted_option.nextSibling&&this._highlighted_option.nextSibling.style.display!="none"){ |
this._focusOptionNode(this._highlighted_option.nextSibling); |
} |
// scrollIntoView is called outside of _focusOptionNode because in IE putting it inside causes the menu to scroll up on mouseover |
dijit.scrollIntoView(this._highlighted_option); |
}, |
highlightFirstOption:function(){ |
// highlight the non-Previous choices option |
this._focusOptionNode(this.domNode.firstChild.nextSibling); |
dijit.scrollIntoView(this._highlighted_option); |
}, |
highlightLastOption:function(){ |
// highlight the noon-More choices option |
this._focusOptionNode(this.domNode.lastChild.previousSibling); |
dijit.scrollIntoView(this._highlighted_option); |
}, |
_highlightPrevOption:function(){ |
// if nothing selected, highlight last option |
// makes sense if you select Previous and try to keep scrolling up the list |
if(!this.getHighlightedOption()){ |
this._focusOptionNode(this.domNode.lastChild.style.display=="none"?this.domNode.lastChild.previousSibling:this.domNode.lastChild); |
}else if(this._highlighted_option.previousSibling&&this._highlighted_option.previousSibling.style.display!="none"){ |
this._focusOptionNode(this._highlighted_option.previousSibling); |
} |
dijit.scrollIntoView(this._highlighted_option); |
}, |
_page:function(/*Boolean*/ up){ |
var scrollamount=0; |
var oldscroll=this.domNode.scrollTop; |
var height=parseInt(dojo.getComputedStyle(this.domNode).height); |
// if no item is highlighted, highlight the first option |
if(!this.getHighlightedOption()){this._highlightNextOption();} |
while(scrollamount<height){ |
if(up){ |
// stop at option 1 |
if(!this.getHighlightedOption().previousSibling||this._highlighted_option.previousSibling.style.display=="none"){break;} |
this._highlightPrevOption(); |
}else{ |
// stop at last option |
if(!this.getHighlightedOption().nextSibling||this._highlighted_option.nextSibling.style.display=="none"){break;} |
this._highlightNextOption(); |
} |
// going backwards |
var newscroll=this.domNode.scrollTop; |
scrollamount+=(newscroll-oldscroll)*(up ? -1:1); |
oldscroll=newscroll; |
} |
}, |
pageUp:function(){ |
this._page(true); |
}, |
pageDown:function(){ |
this._page(false); |
}, |
getHighlightedOption:function(){ |
// summary: |
// Returns the highlighted option. |
return this._highlighted_option&&this._highlighted_option.parentNode ? this._highlighted_option : null; |
}, |
handleKey:function(evt){ |
switch(evt.keyCode){ |
case dojo.keys.DOWN_ARROW: |
this._highlightNextOption(); |
break; |
case dojo.keys.PAGE_DOWN: |
this.pageDown(); |
break; |
case dojo.keys.UP_ARROW: |
this._highlightPrevOption(); |
break; |
case dojo.keys.PAGE_UP: |
this.pageUp(); |
break; |
} |
} |
} |
); |
dojo.declare( |
"dijit.form.ComboBox", |
[dijit.form.ValidationTextBox, dijit.form.ComboBoxMixin], |
{ |
postMixInProperties: function(){ |
dijit.form.ComboBoxMixin.prototype.postMixInProperties.apply(this, arguments); |
dijit.form.ValidationTextBox.prototype.postMixInProperties.apply(this, arguments); |
} |
} |
); |
} |
/trunk/api/js/dojo1.0/dijit/form/CurrencyTextBox.js |
---|
New file |
0,0 → 1,35 |
if(!dojo._hasResource["dijit.form.CurrencyTextBox"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. |
dojo._hasResource["dijit.form.CurrencyTextBox"] = true; |
dojo.provide("dijit.form.CurrencyTextBox"); |
//FIXME: dojo.experimental throws an unreadable exception? |
//dojo.experimental("dijit.form.CurrencyTextBox"); |
dojo.require("dojo.currency"); |
dojo.require("dijit.form.NumberTextBox"); |
dojo.declare( |
"dijit.form.CurrencyTextBox", |
dijit.form.NumberTextBox, |
{ |
// code: String |
// the ISO4217 currency code, a three letter sequence like "USD" |
// See http://en.wikipedia.org/wiki/ISO_4217 |
currency: "", |
regExpGen: dojo.currency.regexp, |
format: dojo.currency.format, |
parse: dojo.currency.parse, |
postMixInProperties: function(){ |
if(this.constraints === dijit.form.ValidationTextBox.prototype.constraints){ |
// declare a constraints property on 'this' so we don't overwrite the shared default object in 'prototype' |
this.constraints = {}; |
} |
this.constraints.currency = this.currency; |
dijit.form.CurrencyTextBox.superclass.postMixInProperties.apply(this, arguments); |
} |
} |
); |
} |
/trunk/api/js/dojo1.0/dijit/form/ValidationTextBox.js |
---|
New file |
0,0 → 1,268 |
if(!dojo._hasResource["dijit.form.ValidationTextBox"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. |
dojo._hasResource["dijit.form.ValidationTextBox"] = true; |
dojo.provide("dijit.form.ValidationTextBox"); |
dojo.require("dojo.i18n"); |
dojo.require("dijit.form.TextBox"); |
dojo.require("dijit.Tooltip"); |
dojo.requireLocalization("dijit.form", "validate", null, "ko,zh-cn,zh,ja,zh-tw,ru,it,hu,ROOT,fr,pt,pl,es,de,cs"); |
dojo.declare( |
"dijit.form.ValidationTextBox", |
dijit.form.TextBox, |
{ |
// summary: |
// A subclass of TextBox. |
// Over-ride isValid in subclasses to perform specific kinds of validation. |
templateString:"<table style=\"display: -moz-inline-stack;\" class=\"dijit dijitReset dijitInlineTable\" cellspacing=\"0\" cellpadding=\"0\"\n\tid=\"widget_${id}\" name=\"${name}\"\n\tdojoAttachEvent=\"onmouseenter:_onMouse,onmouseleave:_onMouse\" waiRole=\"presentation\"\n\t><tr class=\"dijitReset\"\n\t\t><td class=\"dijitReset dijitInputField\" width=\"100%\"\n\t\t\t><input dojoAttachPoint='textbox,focusNode' dojoAttachEvent='onfocus,onblur:_onMouse,onkeyup,onkeypress:_onKeyPress' autocomplete=\"off\"\n\t\t\ttype='${type}' name='${name}'\n\t\t/></td\n\t\t><td class=\"dijitReset dijitValidationIconField\" width=\"0%\"\n\t\t\t><div dojoAttachPoint='iconNode' class='dijitValidationIcon'></div><div class='dijitValidationIconText'>Χ</div\n\t\t></td\n\t></tr\n></table>\n", |
baseClass: "dijitTextBox", |
// default values for new subclass properties |
// required: Boolean |
// Can be true or false, default is false. |
required: false, |
// promptMessage: String |
// Hint string |
promptMessage: "", |
// invalidMessage: String |
// The message to display if value is invalid. |
invalidMessage: "$_unset_$", // read from the message file if not overridden |
// constraints: Object |
// user-defined object needed to pass parameters to the validator functions |
constraints: {}, |
// regExp: String |
// regular expression string used to validate the input |
// Do not specify both regExp and regExpGen |
regExp: ".*", |
// regExpGen: Function |
// user replaceable function used to generate regExp when dependent on constraints |
// Do not specify both regExp and regExpGen |
regExpGen: function(constraints){ return this.regExp; }, |
// state: String |
// Shows current state (ie, validation result) of input (Normal, Warning, or Error) |
state: "", |
setValue: function(){ |
this.inherited('setValue', arguments); |
this.validate(false); |
}, |
validator: function(value,constraints){ |
// summary: user replaceable function used to validate the text input against the regular expression. |
return (new RegExp("^(" + this.regExpGen(constraints) + ")"+(this.required?"":"?")+"$")).test(value) && |
(!this.required || !this._isEmpty(value)) && |
(this._isEmpty(value) || this.parse(value, constraints) !== null); |
}, |
isValid: function(/* Boolean*/ isFocused){ |
// summary: Need to over-ride with your own validation code in subclasses |
return this.validator(this.textbox.value, this.constraints); |
}, |
_isEmpty: function(value){ |
// summary: Checks for whitespace |
return /^\s*$/.test(value); // Boolean |
}, |
getErrorMessage: function(/* Boolean*/ isFocused){ |
// summary: return an error message to show if appropriate |
return this.invalidMessage; |
}, |
getPromptMessage: function(/* Boolean*/ isFocused){ |
// summary: return a hint to show if appropriate |
return this.promptMessage; |
}, |
validate: function(/* Boolean*/ isFocused){ |
// summary: |
// Called by oninit, onblur, and onkeypress. |
// description: |
// Show missing or invalid messages if appropriate, and highlight textbox field. |
var message = ""; |
var isValid = this.isValid(isFocused); |
var isEmpty = this._isEmpty(this.textbox.value); |
this.state = (isValid || (!this._hasBeenBlurred && isEmpty)) ? "" : "Error"; |
this._setStateClass(); |
dijit.setWaiState(this.focusNode, "invalid", (isValid? "false" : "true")); |
if(isFocused){ |
if(isEmpty){ |
message = this.getPromptMessage(true); |
} |
if(!message && !isValid){ |
message = this.getErrorMessage(true); |
} |
} |
this._displayMessage(message); |
}, |
// currently displayed message |
_message: "", |
_displayMessage: function(/*String*/ message){ |
if(this._message == message){ return; } |
this._message = message; |
this.displayMessage(message); |
}, |
displayMessage: function(/*String*/ message){ |
// summary: |
// User overridable method to display validation errors/hints. |
// By default uses a tooltip. |
if(message){ |
dijit.showTooltip(message, this.domNode); |
}else{ |
dijit.hideTooltip(this.domNode); |
} |
}, |
_hasBeenBlurred: false, |
_onBlur: function(evt){ |
this._hasBeenBlurred = true; |
this.validate(false); |
this.inherited('_onBlur', arguments); |
}, |
onfocus: function(evt){ |
// TODO: change to _onFocus? |
this.validate(true); |
this._onMouse(evt); // update CSS classes |
}, |
onkeyup: function(evt){ |
this.onfocus(evt); |
}, |
//////////// INITIALIZATION METHODS /////////////////////////////////////// |
constructor: function(){ |
this.constraints = {}; |
}, |
postMixInProperties: function(){ |
this.inherited('postMixInProperties', arguments); |
this.constraints.locale=this.lang; |
this.messages = dojo.i18n.getLocalization("dijit.form", "validate", this.lang); |
if(this.invalidMessage == "$_unset_$"){ this.invalidMessage = this.messages.invalidMessage; } |
var p = this.regExpGen(this.constraints); |
this.regExp = p; |
// make value a string for all types so that form reset works well |
} |
} |
); |
dojo.declare( |
"dijit.form.MappedTextBox", |
dijit.form.ValidationTextBox, |
{ |
// summary: |
// A subclass of ValidationTextBox. |
// Provides a hidden input field and a serialize method to override |
serialize: function(val, /*Object?*/options){ |
// summary: user replaceable function used to convert the getValue() result to a String |
return (val.toString ? val.toString() : ""); |
}, |
toString: function(){ |
// summary: display the widget as a printable string using the widget's value |
var val = this.filter(this.getValue()); |
return (val!=null) ? ((typeof val == "string") ? val : this.serialize(val, this.constraints)) : ""; |
}, |
validate: function(){ |
this.valueNode.value = this.toString(); |
this.inherited('validate', arguments); |
}, |
postCreate: function(){ |
var textbox = this.textbox; |
var valueNode = (this.valueNode = document.createElement("input")); |
valueNode.setAttribute("type", textbox.type); |
valueNode.setAttribute("value", this.toString()); |
dojo.style(valueNode, "display", "none"); |
valueNode.name = this.textbox.name; |
this.textbox.name = "_" + this.textbox.name + "_displayed_"; |
this.textbox.removeAttribute("name"); |
dojo.place(valueNode, textbox, "after"); |
this.inherited('postCreate', arguments); |
} |
} |
); |
dojo.declare( |
"dijit.form.RangeBoundTextBox", |
dijit.form.MappedTextBox, |
{ |
// summary: |
// A subclass of MappedTextBox. |
// Tests for a value out-of-range |
/*===== contraints object: |
// min: Number |
// Minimum signed value. Default is -Infinity |
min: undefined, |
// max: Number |
// Maximum signed value. Default is +Infinity |
max: undefined, |
=====*/ |
// rangeMessage: String |
// The message to display if value is out-of-range |
rangeMessage: "", |
compare: function(val1, val2){ |
// summary: compare 2 values |
return val1 - val2; |
}, |
rangeCheck: function(/* Number */ primitive, /* Object */ constraints){ |
// summary: user replaceable function used to validate the range of the numeric input value |
var isMin = (typeof constraints.min != "undefined"); |
var isMax = (typeof constraints.max != "undefined"); |
if(isMin || isMax){ |
return (!isMin || this.compare(primitive,constraints.min) >= 0) && |
(!isMax || this.compare(primitive,constraints.max) <= 0); |
}else{ return true; } |
}, |
isInRange: function(/* Boolean*/ isFocused){ |
// summary: Need to over-ride with your own validation code in subclasses |
return this.rangeCheck(this.getValue(), this.constraints); |
}, |
isValid: function(/* Boolean*/ isFocused){ |
return this.inherited('isValid', arguments) && |
((this._isEmpty(this.textbox.value) && !this.required) || this.isInRange(isFocused)); |
}, |
getErrorMessage: function(/* Boolean*/ isFocused){ |
if(dijit.form.RangeBoundTextBox.superclass.isValid.call(this, false) && !this.isInRange(isFocused)){ return this.rangeMessage; } |
else{ return this.inherited('getErrorMessage', arguments); } |
}, |
postMixInProperties: function(){ |
this.inherited('postMixInProperties', arguments); |
if(!this.rangeMessage){ |
this.messages = dojo.i18n.getLocalization("dijit.form", "validate", this.lang); |
this.rangeMessage = this.messages.rangeMessage; |
} |
}, |
postCreate: function(){ |
this.inherited('postCreate', arguments); |
if(typeof this.constraints.min != "undefined"){ |
dijit.setWaiState(this.focusNode, "valuemin", this.constraints.min); |
} |
if(typeof this.constraints.max != "undefined"){ |
dijit.setWaiState(this.focusNode, "valuemax", this.constraints.max); |
} |
} |
} |
); |
} |
/trunk/api/js/dojo1.0/dijit/form/Button.js |
---|
New file |
0,0 → 1,380 |
if(!dojo._hasResource["dijit.form.Button"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. |
dojo._hasResource["dijit.form.Button"] = true; |
dojo.provide("dijit.form.Button"); |
dojo.require("dijit.form._FormWidget"); |
dojo.require("dijit._Container"); |
dojo.declare("dijit.form.Button", dijit.form._FormWidget, { |
/* |
* usage |
* <button dojoType="button" onClick="...">Hello world</button> |
* |
* var button1 = new dijit.form.Button({label: "hello world", onClick: foo}); |
* dojo.body().appendChild(button1.domNode); |
*/ |
// summary |
// Basically the same thing as a normal HTML button, but with special styling. |
// label: String |
// text to display in button |
label: "", |
// showLabel: Boolean |
// whether or not to display the text label in button |
showLabel: true, |
// iconClass: String |
// class to apply to div in button to make it display an icon |
iconClass: "", |
type: "button", |
baseClass: "dijitButton", |
templateString:"<div class=\"dijit dijitLeft dijitInline dijitButton\"\n\tdojoAttachEvent=\"onclick:_onButtonClick,onmouseenter:_onMouse,onmouseleave:_onMouse,onmousedown:_onMouse\"\n\t><div class='dijitRight'\n\t\t><button class=\"dijitStretch dijitButtonNode dijitButtonContents\" dojoAttachPoint=\"focusNode,titleNode\"\n\t\t\ttype=\"${type}\" waiRole=\"button\" waiState=\"labelledby-${id}_label\"\n\t\t\t><span class=\"dijitInline ${iconClass}\" dojoAttachPoint=\"iconNode\" \n \t\t\t\t><span class=\"dijitToggleButtonIconChar\">✓</span \n\t\t\t></span\n\t\t\t><span class=\"dijitButtonText\" id=\"${id}_label\" dojoAttachPoint=\"containerNode\">${label}</span\n\t\t></button\n\t></div\n></div>\n", |
// TODO: set button's title to this.containerNode.innerText |
_onClick: function(/*Event*/ e){ |
// summary: internal function to handle click actions |
if(this.disabled){ return false; } |
this._clicked(); // widget click actions |
return this.onClick(e); // user click actions |
}, |
_onButtonClick: function(/*Event*/ e){ |
// summary: callback when the user mouse clicks the button portion |
dojo.stopEvent(e); |
var okToSubmit = this._onClick(e) !== false; // returning nothing is same as true |
// for some reason type=submit buttons don't automatically submit the form; do it manually |
if(this.type=="submit" && okToSubmit){ |
for(var node=this.domNode; node; node=node.parentNode){ |
var widget=dijit.byNode(node); |
if(widget && widget._onSubmit){ |
widget._onSubmit(e); |
break; |
} |
if(node.tagName.toLowerCase() == "form"){ |
if(!node.onsubmit || node.onsubmit()){ node.submit(); } |
break; |
} |
} |
} |
}, |
postCreate: function(){ |
// summary: |
// get label and set as title on button icon if necessary |
if (this.showLabel == false){ |
var labelText = ""; |
this.label = this.containerNode.innerHTML; |
labelText = dojo.trim(this.containerNode.innerText || this.containerNode.textContent); |
// set title attrib on iconNode |
this.titleNode.title=labelText; |
dojo.addClass(this.containerNode,"dijitDisplayNone"); |
} |
this.inherited(arguments); |
}, |
onClick: function(/*Event*/ e){ |
// summary: user callback for when button is clicked |
// if type="submit", return value != false to perform submit |
return true; |
}, |
_clicked: function(/*Event*/ e){ |
// summary: internal replaceable function for when the button is clicked |
}, |
setLabel: function(/*String*/ content){ |
// summary: reset the label (text) of the button; takes an HTML string |
this.containerNode.innerHTML = this.label = content; |
if(dojo.isMozilla){ // Firefox has re-render issues with tables |
var oldDisplay = dojo.getComputedStyle(this.domNode).display; |
this.domNode.style.display="none"; |
var _this = this; |
setTimeout(function(){_this.domNode.style.display=oldDisplay;},1); |
} |
if (this.showLabel == false){ |
this.titleNode.title=dojo.trim(this.containerNode.innerText || this.containerNode.textContent); |
} |
} |
}); |
/* |
* usage |
* <button dojoType="DropDownButton" label="Hello world"><div dojotype=dijit.Menu>...</div></button> |
* |
* var button1 = new dijit.form.DropDownButton({ label: "hi", dropDown: new dijit.Menu(...) }); |
* dojo.body().appendChild(button1); |
*/ |
dojo.declare("dijit.form.DropDownButton", [dijit.form.Button, dijit._Container], { |
// summary |
// push the button and a menu shows up |
baseClass : "dijitDropDownButton", |
templateString:"<div class=\"dijit dijitLeft dijitInline\"\n\tdojoAttachEvent=\"onmouseenter:_onMouse,onmouseleave:_onMouse,onmousedown:_onMouse,onclick:_onDropDownClick,onkeydown:_onDropDownKeydown,onblur:_onDropDownBlur,onkeypress:_onKey\"\n\t><div class='dijitRight'>\n\t<button class=\"dijitStretch dijitButtonNode dijitButtonContents\" type=\"${type}\"\n\t\tdojoAttachPoint=\"focusNode,titleNode\" waiRole=\"button\" waiState=\"haspopup-true,labelledby-${id}_label\"\n\t\t><div class=\"dijitInline ${iconClass}\" dojoAttachPoint=\"iconNode\"></div\n\t\t><span class=\"dijitButtonText\" \tdojoAttachPoint=\"containerNode,popupStateNode\"\n\t\tid=\"${id}_label\">${label}</span\n\t\t><span class='dijitA11yDownArrow'>▼</span>\n\t</button>\n</div></div>\n", |
_fillContent: function(){ |
// my inner HTML contains both the button contents and a drop down widget, like |
// <DropDownButton> <span>push me</span> <Menu> ... </Menu> </DropDownButton> |
// The first node is assumed to be the button content. The widget is the popup. |
if(this.srcNodeRef){ // programatically created buttons might not define srcNodeRef |
//FIXME: figure out how to filter out the widget and use all remaining nodes as button |
// content, not just nodes[0] |
var nodes = dojo.query("*", this.srcNodeRef); |
dijit.form.DropDownButton.superclass._fillContent.call(this, nodes[0]); |
// save pointer to srcNode so we can grab the drop down widget after it's instantiated |
this.dropDownContainer = this.srcNodeRef; |
} |
}, |
startup: function(){ |
// the child widget from srcNodeRef is the dropdown widget. Insert it in the page DOM, |
// make it invisible, and store a reference to pass to the popup code. |
if(!this.dropDown){ |
var dropDownNode = dojo.query("[widgetId]", this.dropDownContainer)[0]; |
this.dropDown = dijit.byNode(dropDownNode); |
delete this.dropDownContainer; |
} |
dojo.body().appendChild(this.dropDown.domNode); |
this.dropDown.domNode.style.display="none"; |
}, |
_onArrowClick: function(/*Event*/ e){ |
// summary: callback when the user mouse clicks on menu popup node |
if(this.disabled){ return; } |
this._toggleDropDown(); |
}, |
_onDropDownClick: function(/*Event*/ e){ |
// on Firefox 2 on the Mac it is possible to fire onclick |
// by pressing enter down on a second element and transferring |
// focus to the DropDownButton; |
// we want to prevent opening our menu in this situation |
// and only do so if we have seen a keydown on this button; |
// e.detail != 0 means that we were fired by mouse |
var isMacFFlessThan3 = dojo.isFF && dojo.isFF < 3 |
&& navigator.appVersion.indexOf("Macintosh") != -1; |
if(!isMacFFlessThan3 || e.detail != 0 || this._seenKeydown){ |
this._onArrowClick(e); |
} |
this._seenKeydown = false; |
}, |
_onDropDownKeydown: function(/*Event*/ e){ |
this._seenKeydown = true; |
}, |
_onDropDownBlur: function(/*Event*/ e){ |
this._seenKeydown = false; |
}, |
_onKey: function(/*Event*/ e){ |
// summary: callback when the user presses a key on menu popup node |
if(this.disabled){ return; } |
if(e.keyCode == dojo.keys.DOWN_ARROW){ |
if(!this.dropDown || this.dropDown.domNode.style.display=="none"){ |
dojo.stopEvent(e); |
return this._toggleDropDown(); |
} |
} |
}, |
_onBlur: function(){ |
// summary: called magically when focus has shifted away from this widget and it's dropdown |
this._closeDropDown(); |
// don't focus on button. the user has explicitly focused on something else. |
}, |
_toggleDropDown: function(){ |
// summary: toggle the drop-down widget; if it is up, close it, if not, open it |
if(this.disabled){ return; } |
dijit.focus(this.popupStateNode); |
var dropDown = this.dropDown; |
if(!dropDown){ return false; } |
if(!dropDown.isShowingNow){ |
// If there's an href, then load that first, so we don't get a flicker |
if(dropDown.href && !dropDown.isLoaded){ |
var self = this; |
var handler = dojo.connect(dropDown, "onLoad", function(){ |
dojo.disconnect(handler); |
self._openDropDown(); |
}); |
dropDown._loadCheck(true); |
return; |
}else{ |
this._openDropDown(); |
} |
}else{ |
this._closeDropDown(); |
} |
}, |
_openDropDown: function(){ |
var dropDown = this.dropDown; |
var oldWidth=dropDown.domNode.style.width; |
var self = this; |
dijit.popup.open({ |
parent: this, |
popup: dropDown, |
around: this.domNode, |
orient: this.isLeftToRight() ? {'BL':'TL', 'BR':'TR', 'TL':'BL', 'TR':'BR'} |
: {'BR':'TR', 'BL':'TL', 'TR':'BR', 'TL':'BL'}, |
onExecute: function(){ |
self._closeDropDown(true); |
}, |
onCancel: function(){ |
self._closeDropDown(true); |
}, |
onClose: function(){ |
dropDown.domNode.style.width = oldWidth; |
self.popupStateNode.removeAttribute("popupActive"); |
this._opened = false; |
} |
}); |
if(this.domNode.offsetWidth > dropDown.domNode.offsetWidth){ |
var adjustNode = null; |
if(!this.isLeftToRight()){ |
adjustNode = dropDown.domNode.parentNode; |
var oldRight = adjustNode.offsetLeft + adjustNode.offsetWidth; |
} |
// make menu at least as wide as the button |
dojo.marginBox(dropDown.domNode, {w: this.domNode.offsetWidth}); |
if(adjustNode){ |
adjustNode.style.left = oldRight - this.domNode.offsetWidth + "px"; |
} |
} |
this.popupStateNode.setAttribute("popupActive", "true"); |
this._opened=true; |
if(dropDown.focus){ |
dropDown.focus(); |
} |
// TODO: set this.checked and call setStateClass(), to affect button look while drop down is shown |
}, |
_closeDropDown: function(/*Boolean*/ focus){ |
if(this._opened){ |
dijit.popup.close(this.dropDown); |
if(focus){ this.focus(); } |
this._opened = false; |
} |
} |
}); |
/* |
* usage |
* <button dojoType="ComboButton" onClick="..."><span>Hello world</span><div dojoType=dijit.Menu>...</div></button> |
* |
* var button1 = new dijit.form.ComboButton({label: "hello world", onClick: foo, dropDown: "myMenu"}); |
* dojo.body().appendChild(button1.domNode); |
*/ |
dojo.declare("dijit.form.ComboButton", dijit.form.DropDownButton, { |
// summary |
// left side is normal button, right side displays menu |
templateString:"<table class='dijit dijitReset dijitInline dijitLeft'\n\tcellspacing='0' cellpadding='0'\n\tdojoAttachEvent=\"onmouseenter:_onMouse,onmouseleave:_onMouse,onmousedown:_onMouse\">\n\t<tr>\n\t\t<td\tclass=\"dijitStretch dijitButtonContents dijitButtonNode\"\n\t\t\ttabIndex=\"${tabIndex}\"\n\t\t\tdojoAttachEvent=\"ondijitclick:_onButtonClick\" dojoAttachPoint=\"titleNode\"\n\t\t\twaiRole=\"button\" waiState=\"labelledby-${id}_label\">\n\t\t\t<div class=\"dijitInline ${iconClass}\" dojoAttachPoint=\"iconNode\"></div>\n\t\t\t<span class=\"dijitButtonText\" id=\"${id}_label\" dojoAttachPoint=\"containerNode\">${label}</span>\n\t\t</td>\n\t\t<td class='dijitReset dijitRight dijitButtonNode dijitDownArrowButton'\n\t\t\tdojoAttachPoint=\"popupStateNode,focusNode\"\n\t\t\tdojoAttachEvent=\"ondijitclick:_onArrowClick, onkeypress:_onKey\"\n\t\t\tstateModifier=\"DownArrow\"\n\t\t\ttitle=\"${optionsTitle}\" name=\"${name}\"\n\t\t\twaiRole=\"button\" waiState=\"haspopup-true\"\n\t\t><div waiRole=\"presentation\">▼</div>\n\t</td></tr>\n</table>\n", |
attributeMap: dojo.mixin(dojo.clone(dijit.form._FormWidget.prototype.attributeMap), |
{id:"", name:""}), |
// optionsTitle: String |
// text that describes the options menu (accessibility) |
optionsTitle: "", |
baseClass: "dijitComboButton", |
_focusedNode: null, |
postCreate: function(){ |
this.inherited(arguments); |
this._focalNodes = [this.titleNode, this.popupStateNode]; |
dojo.forEach(this._focalNodes, dojo.hitch(this, function(node){ |
if(dojo.isIE){ |
this.connect(node, "onactivate", this._onNodeFocus); |
}else{ |
this.connect(node, "onfocus", this._onNodeFocus); |
} |
})); |
}, |
focusFocalNode: function(node){ |
// summary: Focus the focal node node. |
this._focusedNode = node; |
dijit.focus(node); |
}, |
hasNextFocalNode: function(){ |
// summary: Returns true if this widget has no node currently |
// focused or if there is a node following the focused one. |
// False is returned if the last node has focus. |
return this._focusedNode !== this.getFocalNodes()[1]; |
}, |
focusNext: function(){ |
// summary: Focus the focal node following the current node with focus |
// or the first one if no node currently has focus. |
this._focusedNode = this.getFocalNodes()[this._focusedNode ? 1 : 0]; |
dijit.focus(this._focusedNode); |
}, |
hasPrevFocalNode: function(){ |
// summary: Returns true if this widget has no node currently |
// focused or if there is a node before the focused one. |
// False is returned if the first node has focus. |
return this._focusedNode !== this.getFocalNodes()[0]; |
}, |
focusPrev: function(){ |
// summary: Focus the focal node before the current node with focus |
// or the last one if no node currently has focus. |
this._focusedNode = this.getFocalNodes()[this._focusedNode ? 0 : 1]; |
dijit.focus(this._focusedNode); |
}, |
getFocalNodes: function(){ |
// summary: Returns an array of focal nodes for this widget. |
return this._focalNodes; |
}, |
_onNodeFocus: function(evt){ |
this._focusedNode = evt.currentTarget; |
}, |
_onBlur: function(evt){ |
this.inherited(arguments); |
this._focusedNode = null; |
} |
}); |
dojo.declare("dijit.form.ToggleButton", dijit.form.Button, { |
// summary |
// A button that can be in two states (checked or not). |
// Can be base class for things like tabs or checkbox or radio buttons |
baseClass: "dijitToggleButton", |
// checked: Boolean |
// Corresponds to the native HTML <input> element's attribute. |
// In markup, specified as "checked='checked'" or just "checked". |
// True if the button is depressed, or the checkbox is checked, |
// or the radio button is selected, etc. |
checked: false, |
_clicked: function(/*Event*/ evt){ |
this.setChecked(!this.checked); |
}, |
setChecked: function(/*Boolean*/ checked){ |
// summary |
// Programatically deselect the button |
this.checked = checked; |
dijit.setWaiState(this.focusNode || this.domNode, "pressed", this.checked); |
this._setStateClass(); |
this.onChange(checked); |
} |
}); |
} |
/trunk/api/js/dojo1.0/dijit/form/TimeTextBox.js |
---|
New file |
0,0 → 1,125 |
if(!dojo._hasResource["dijit.form.TimeTextBox"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. |
dojo._hasResource["dijit.form.TimeTextBox"] = true; |
dojo.provide("dijit.form.TimeTextBox"); |
dojo.require("dojo.date"); |
dojo.require("dojo.date.locale"); |
dojo.require("dojo.date.stamp"); |
dojo.require("dijit._TimePicker"); |
dojo.require("dijit.form.ValidationTextBox"); |
dojo.declare( |
"dijit.form.TimeTextBox", |
dijit.form.RangeBoundTextBox, |
{ |
// summary: |
// A validating, serializable, range-bound date text box. |
// constraints object: min, max |
regExpGen: dojo.date.locale.regexp, |
compare: dojo.date.compare, |
format: function(/*Date*/ value, /*Object*/ constraints){ |
if(!value || value.toString() == this._invalid){ return null; } |
return dojo.date.locale.format(value, constraints); |
}, |
parse: dojo.date.locale.parse, |
serialize: dojo.date.stamp.toISOString, |
value: new Date(""), // NaN |
_invalid: (new Date("")).toString(), // NaN |
_popupClass: "dijit._TimePicker", |
postMixInProperties: function(){ |
//dijit.form.RangeBoundTextBox.prototype.postMixInProperties.apply(this, arguments); |
this.inherited("postMixInProperties",arguments); |
var constraints = this.constraints; |
constraints.selector = 'time'; |
if(typeof constraints.min == "string"){ constraints.min = dojo.date.stamp.fromISOString(constraints.min); } |
if(typeof constraints.max == "string"){ constraints.max = dojo.date.stamp.fromISOString(constraints.max); } |
}, |
_onFocus: function(/*Event*/ evt){ |
// summary: open the TimePicker popup |
this._open(); |
}, |
setValue: function(/*Date*/ value, /*Boolean, optional*/ priorityChange){ |
// summary: |
// Sets the date on this textbox |
this.inherited('setValue', arguments); |
if(this._picker){ |
// #3948: fix blank date on popup only |
if(!value || value.toString() == this._invalid){value=new Date();} |
this._picker.setValue(value); |
} |
}, |
_open: function(){ |
// summary: |
// opens the TimePicker, and sets the onValueSelected value |
if(this.disabled){return;} |
var self = this; |
if(!this._picker){ |
var popupProto=dojo.getObject(this._popupClass, false); |
this._picker = new popupProto({ |
onValueSelected: function(value){ |
self.focus(); // focus the textbox before the popup closes to avoid reopening the popup |
setTimeout(dojo.hitch(self, "_close"), 1); // allow focus time to take |
// this will cause InlineEditBox and other handlers to do stuff so make sure it's last |
dijit.form.TimeTextBox.superclass.setValue.call(self, value, true); |
}, |
lang: this.lang, |
constraints:this.constraints, |
isDisabledDate: function(/*Date*/ date){ |
// summary: |
// disables dates outside of the min/max of the TimeTextBox |
return self.constraints && (dojo.date.compare(self.constraints.min,date) > 0 || dojo.date.compare(self.constraints.max,date) < 0); |
} |
}); |
this._picker.setValue(this.getValue() || new Date()); |
} |
if(!this._opened){ |
dijit.popup.open({ |
parent: this, |
popup: this._picker, |
around: this.domNode, |
onCancel: dojo.hitch(this, this._close), |
onClose: function(){ self._opened=false; } |
}); |
this._opened=true; |
} |
dojo.marginBox(this._picker.domNode,{ w:this.domNode.offsetWidth }); |
}, |
_close: function(){ |
if(this._opened){ |
dijit.popup.close(this._picker); |
this._opened=false; |
} |
}, |
_onBlur: function(){ |
// summary: called magically when focus has shifted away from this widget and it's dropdown |
this._close(); |
this.inherited('_onBlur', arguments); |
// don't focus on <input>. the user has explicitly focused on something else. |
}, |
getDisplayedValue:function(){ |
return this.textbox.value; |
}, |
setDisplayedValue:function(/*String*/ value){ |
this.textbox.value=value; |
} |
} |
); |
} |
/trunk/api/js/dojo1.0/dijit/form/_Spinner.js |
---|
New file |
0,0 → 1,104 |
if(!dojo._hasResource["dijit.form._Spinner"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. |
dojo._hasResource["dijit.form._Spinner"] = true; |
dojo.provide("dijit.form._Spinner"); |
dojo.require("dijit.form.ValidationTextBox"); |
dojo.declare( |
"dijit.form._Spinner", |
dijit.form.RangeBoundTextBox, |
{ |
// summary: Mixin for validation widgets with a spinner |
// description: This class basically (conceptually) extends dijit.form.ValidationTextBox. |
// It modifies the template to have up/down arrows, and provides related handling code. |
// defaultTimeout: Number |
// number of milliseconds before a held key or button becomes typematic |
defaultTimeout: 500, |
// timeoutChangeRate: Number |
// fraction of time used to change the typematic timer between events |
// 1.0 means that each typematic event fires at defaultTimeout intervals |
// < 1.0 means that each typematic event fires at an increasing faster rate |
timeoutChangeRate: 0.90, |
// smallDelta: Number |
// adjust the value by this much when spinning using the arrow keys/buttons |
smallDelta: 1, |
// largeDelta: Number |
// adjust the value by this much when spinning using the PgUp/Dn keys |
largeDelta: 10, |
templateString:"<table class=\"dijit dijitReset dijitInlineTable dijitLeft\" cellspacing=\"0\" cellpadding=\"0\"\n\tid=\"widget_${id}\" name=\"${name}\"\n\tdojoAttachEvent=\"onmouseenter:_onMouse,onmouseleave:_onMouse,onkeypress:_onKeyPress\"\n\twaiRole=\"presentation\"\n\t><tr class=\"dijitReset\"\n\t\t><td rowspan=\"2\" class=\"dijitReset dijitStretch dijitInputField\" width=\"100%\"\n\t\t\t><input dojoAttachPoint=\"textbox,focusNode\" type=\"${type}\" dojoAttachEvent=\"onfocus,onkeyup\"\n\t\t\t\twaiRole=\"spinbutton\" autocomplete=\"off\" name=\"${name}\"\n\t\t></td\n\t\t><td rowspan=\"2\" class=\"dijitReset dijitValidationIconField\" width=\"0%\" \n\t\t\t><div dojoAttachPoint='iconNode' class='dijitValidationIcon'></div\n\t\t></td\n\t\t><td class=\"dijitReset dijitRight dijitButtonNode dijitUpArrowButton\" width=\"0%\"\n\t\t\t\tdojoAttachPoint=\"upArrowNode\"\n\t\t\t\tdojoAttachEvent=\"onmousedown:_handleUpArrowEvent,onmouseup:_handleUpArrowEvent,onmouseover:_handleUpArrowEvent,onmouseout:_handleUpArrowEvent\"\n\t\t\t\tstateModifier=\"UpArrow\"\n\t\t\t><div class=\"dijitA11yUpArrow\">▲</div\n\t\t></td\n\t></tr\n\t><tr class=\"dijitReset\"\n\t\t><td class=\"dijitReset dijitRight dijitButtonNode dijitDownArrowButton\" width=\"0%\"\n\t\t\t\tdojoAttachPoint=\"downArrowNode\"\n\t\t\t\tdojoAttachEvent=\"onmousedown:_handleDownArrowEvent,onmouseup:_handleDownArrowEvent,onmouseover:_handleDownArrowEvent,onmouseout:_handleDownArrowEvent\"\n\t\t\t\tstateModifier=\"DownArrow\"\n\t\t\t><div class=\"dijitA11yDownArrow\">▼</div\n\t\t></td\n\t></tr\n></table>\n\n", |
baseClass: "dijitSpinner", |
adjust: function(/* Object */ val, /*Number*/ delta){ |
// summary: user replaceable function used to adjust a primitive value(Number/Date/...) by the delta amount specified |
// the val is adjusted in a way that makes sense to the object type |
return val; |
}, |
_handleUpArrowEvent : function(/*Event*/ e){ |
this._onMouse(e, this.upArrowNode); |
}, |
_handleDownArrowEvent : function(/*Event*/ e){ |
this._onMouse(e, this.downArrowNode); |
}, |
_arrowPressed: function(/*Node*/ nodePressed, /*Number*/ direction){ |
if(this.disabled){ return; } |
dojo.addClass(nodePressed, "dijitSpinnerButtonActive"); |
this.setValue(this.adjust(this.getValue(), direction*this.smallDelta), false); |
}, |
_arrowReleased: function(/*Node*/ node){ |
if(this.disabled){ return; } |
this._wheelTimer = null; |
dijit.focus(this.textbox); |
dojo.removeClass(node, "dijitSpinnerButtonActive"); |
}, |
_typematicCallback: function(/*Number*/ count, /*DOMNode*/ node, /*Event*/ evt){ |
if(node == this.textbox){ node = (evt.keyCode == dojo.keys.UP_ARROW) ? this.upArrowNode : this.downArrowNode; } |
if(count == -1){ this._arrowReleased(node); } |
else{ this._arrowPressed(node, (node == this.upArrowNode) ? 1 : -1); } |
}, |
_wheelTimer: null, |
_mouseWheeled: function(/*Event*/ evt){ |
dojo.stopEvent(evt); |
var scrollAmount = 0; |
if(typeof evt.wheelDelta == 'number'){ // IE |
scrollAmount = evt.wheelDelta; |
}else if(typeof evt.detail == 'number'){ // Mozilla+Firefox |
scrollAmount = -evt.detail; |
} |
if(scrollAmount > 0){ |
var node = this.upArrowNode; |
var dir = +1; |
}else if(scrollAmount < 0){ |
var node = this.downArrowNode; |
var dir = -1; |
}else{ return; } |
this._arrowPressed(node, dir); |
if(this._wheelTimer != null){ |
clearTimeout(this._wheelTimer); |
} |
var _this = this; |
this._wheelTimer = setTimeout(function(){_this._arrowReleased(node);}, 50); |
}, |
postCreate: function(){ |
this.inherited('postCreate', arguments); |
// extra listeners |
this.connect(this.textbox, dojo.isIE ? "onmousewheel" : 'DOMMouseScroll', "_mouseWheeled"); |
dijit.typematic.addListener(this.upArrowNode, this.textbox, {keyCode:dojo.keys.UP_ARROW,ctrlKey:false,altKey:false,shiftKey:false}, this, "_typematicCallback", this.timeoutChangeRate, this.defaultTimeout); |
dijit.typematic.addListener(this.downArrowNode, this.textbox, {keyCode:dojo.keys.DOWN_ARROW,ctrlKey:false,altKey:false,shiftKey:false}, this, "_typematicCallback", this.timeoutChangeRate, this.defaultTimeout); |
} |
}); |
} |
/trunk/api/js/dojo1.0/dijit/form/Textarea.js |
---|
New file |
0,0 → 1,238 |
if(!dojo._hasResource["dijit.form.Textarea"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. |
dojo._hasResource["dijit.form.Textarea"] = true; |
dojo.provide("dijit.form.Textarea"); |
dojo.require("dijit.form._FormWidget"); |
dojo.require("dojo.i18n"); |
dojo.requireLocalization("dijit", "Textarea", null, "ROOT"); |
dojo.declare( |
"dijit.form.Textarea", |
dijit.form._FormWidget, |
{ |
// summary |
// A textarea that resizes vertically to contain the data. |
// Takes nearly all the parameters (name, value, etc.) that a vanilla textarea takes. |
// Cols is not supported and the width should be specified with style width. |
// Rows is not supported since this widget adjusts the height. |
// usage: |
// <textarea dojoType="dijit.form.TextArea">...</textarea> |
attributeMap: dojo.mixin(dojo.clone(dijit.form._FormWidget.prototype.attributeMap), |
{style:"styleNode", 'class':"styleNode"}), |
templateString: (dojo.isIE || dojo.isSafari || dojo.isMozilla) ? |
((dojo.isIE || dojo.isSafari) ? '<fieldset id="${id}" class="dijitInline dijitInputField dijitTextArea" dojoAttachPoint="styleNode" waiRole="presentation"><div dojoAttachPoint="editNode,focusNode,eventNode" dojoAttachEvent="onpaste:_changing,oncut:_changing" waiRole="textarea" style="text-decoration:none;_padding-bottom:16px;display:block;overflow:auto;" contentEditable="true"></div>' |
: '<span id="${id}" class="dijitReset">'+ |
'<iframe src="javascript:<html><head><title>${_iframeEditTitle}</title></head><body><script>var _postCreate=window.frameElement?window.frameElement.postCreate:null;if(_postCreate)_postCreate();</script></body></html>"'+ |
' dojoAttachPoint="iframe,styleNode" dojoAttachEvent="onblur:_onIframeBlur" class="dijitInline dijitInputField dijitTextArea"></iframe>') |
+ '<textarea name="${name}" value="${value}" dojoAttachPoint="formValueNode" style="display:none;"></textarea>' |
+ ((dojo.isIE || dojo.isSafari) ? '</fieldset>':'</span>') |
: '<textarea id="${id}" name="${name}" value="${value}" dojoAttachPoint="formValueNode,editNode,focusNode,styleNode" class="dijitInputField dijitTextArea"></textarea>', |
focus: function(){ |
// summary: Received focus, needed for the InlineEditBox widget |
if(!this.disabled){ |
this._changing(); // set initial height |
} |
if(dojo.isMozilla){ |
dijit.focus(this.iframe); |
}else{ |
dijit.focus(this.focusNode); |
} |
}, |
setValue: function(/*String*/ value, /*Boolean, optional*/ priorityChange){ |
var editNode = this.editNode; |
if(typeof value == "string"){ |
editNode.innerHTML = ""; // wipe out old nodes |
if(value.split){ |
var _this=this; |
var isFirst = true; |
dojo.forEach(value.split("\n"), function(line){ |
if(isFirst){ isFirst = false; } |
else { |
editNode.appendChild(document.createElement("BR")); // preserve line breaks |
} |
editNode.appendChild(document.createTextNode(line)); // use text nodes so that imbedded tags can be edited |
}); |
}else{ |
editNode.appendChild(document.createTextNode(value)); |
} |
}else{ |
// blah<BR>blah --> blah\nblah |
// <P>blah</P><P>blah</P> --> blah\nblah |
// <DIV>blah</DIV><DIV>blah</DIV> --> blah\nblah |
// &<> -->&< > |
value = editNode.innerHTML; |
if(this.iframe){ // strip sizeNode |
value = value.replace(/<div><\/div>\r?\n?$/i,""); |
} |
value = value.replace(/\s*\r?\n|^\s+|\s+$| /g,"").replace(/>\s+</g,"><").replace(/<\/(p|div)>$|^<(p|div)[^>]*>/gi,"").replace(/([^>])<div>/g,"$1\n").replace(/<\/p>\s*<p[^>]*>|<br[^>]*>/gi,"\n").replace(/<[^>]*>/g,"").replace(/&/gi,"\&").replace(/</gi,"<").replace(/>/gi,">"); |
} |
this.value = this.formValueNode.value = value; |
if(this.iframe){ |
var sizeNode = document.createElement('div'); |
editNode.appendChild(sizeNode); |
var newHeight = sizeNode.offsetTop; |
if(editNode.scrollWidth > editNode.clientWidth){ newHeight+=16; } // scrollbar space needed? |
if(this.lastHeight != newHeight){ // cache size so that we don't get a resize event because of a resize event |
if(newHeight == 0){ newHeight = 16; } // height = 0 causes the browser to not set scrollHeight |
dojo.contentBox(this.iframe, {h: newHeight}); |
this.lastHeight = newHeight; |
} |
editNode.removeChild(sizeNode); |
} |
dijit.form.Textarea.superclass.setValue.call(this, this.getValue(), priorityChange); |
}, |
getValue: function(){ |
return this.formValueNode.value.replace(/\r/g,""); |
}, |
postMixInProperties: function(){ |
dijit.form.Textarea.superclass.postMixInProperties.apply(this,arguments); |
// don't let the source text be converted to a DOM structure since we just want raw text |
if(this.srcNodeRef && this.srcNodeRef.innerHTML != ""){ |
this.value = this.srcNodeRef.innerHTML; |
this.srcNodeRef.innerHTML = ""; |
} |
if((!this.value || this.value == "") && this.srcNodeRef && this.srcNodeRef.value){ |
this.value = this.srcNodeRef.value; |
} |
if(!this.value){ this.value = ""; } |
this.value = this.value.replace(/\r\n/g,"\n").replace(/>/g,">").replace(/</g,"<").replace(/&/g,"&"); |
if(dojo.isMozilla){ |
// In the case of Firefox an iframe is used and when the text gets focus, |
// focus is fired from the document object. There isn't a way to put a |
// waiRole on the document object and as a result screen readers don't |
// announce the role. As a result screen reader users are lost. |
// |
// An additional problem is that the browser gives the document object a |
// very cryptic accessible name, e.g. |
// wysiwyg://13/http://archive.dojotoolkit.org/nightly/dojotoolkit/dijit/tests/form/test_InlineEditBox.html |
// When focus is fired from the document object, the screen reader speaks |
// the accessible name. The cyptic accessile name is confusing. |
// |
// A workaround for both of these problems is to give the iframe's |
// document a title, the name of which is similar to a role name, i.e. |
// "edit area". This will be used as the accessible name which will replace |
// the cryptic name and will also convey the role information to the user. |
// Because it is read directly to the user, the string must be localized. |
// In addition, since a <label> element can not be associated with an iframe, if |
// this control has a label, insert the text into the title as well. |
var _nlsResources = dojo.i18n.getLocalization("dijit", "Textarea"); |
this._iframeEditTitle = _nlsResources.iframeEditTitle; |
this._iframeFocusTitle = _nlsResources.iframeFocusTitle; |
var label=dojo.query('label[for="'+this.id+'"]'); |
if(label.length){ |
this._iframeEditTitle = label[0].innerHTML + " " + this._iframeEditTitle; |
} |
var body = this.focusNode = this.editNode = document.createElement('BODY'); |
body.style.margin="0px"; |
body.style.padding="0px"; |
body.style.border="0px"; |
} |
}, |
postCreate: function(){ |
if(dojo.isIE || dojo.isSafari){ |
this.domNode.style.overflowY = 'hidden'; |
}else if(dojo.isMozilla){ |
var w = this.iframe.contentWindow; |
try { // #4715: peeking at the title can throw a security exception during iframe setup |
var title = this.iframe.contentDocument.title; |
} catch(e) { var title = ''; } |
if(!w || !title){ |
this.iframe.postCreate = dojo.hitch(this, this.postCreate); |
return; |
} |
var d = w.document; |
d.getElementsByTagName('HTML')[0].replaceChild(this.editNode, d.getElementsByTagName('BODY')[0]); |
if(!this.isLeftToRight()){ |
d.getElementsByTagName('HTML')[0].dir = "rtl"; |
} |
this.iframe.style.overflowY = 'hidden'; |
this.eventNode = d; |
// this.connect won't destroy this handler cleanly since its on the iframe's window object |
// resize is a method of window, not document |
w.addEventListener("resize", dojo.hitch(this, this._changed), false); // resize is only on the window object |
}else{ |
this.focusNode = this.domNode; |
} |
if(this.eventNode){ |
this.connect(this.eventNode, "keypress", this._onKeyPress); |
this.connect(this.eventNode, "mousemove", this._changed); |
this.connect(this.eventNode, "focus", this._focused); |
this.connect(this.eventNode, "blur", this._blurred); |
} |
if(this.editNode){ |
this.connect(this.editNode, "change", this._changed); // needed for mouse paste events per #3479 |
} |
this.inherited('postCreate', arguments); |
}, |
// event handlers, you can over-ride these in your own subclasses |
_focused: function(e){ |
dojo.addClass(this.iframe||this.domNode, "dijitInputFieldFocused"); |
this._changed(e); |
}, |
_blurred: function(e){ |
dojo.removeClass(this.iframe||this.domNode, "dijitInputFieldFocused"); |
this._changed(e, true); |
}, |
_onIframeBlur: function(){ |
// Reset the title back to "edit area". |
this.iframe.contentDocument.title = this._iframeEditTitle; |
}, |
_onKeyPress: function(e){ |
if(e.keyCode == dojo.keys.TAB && !e.shiftKey && !e.ctrlKey && !e.altKey && this.iframe){ |
// Pressing the tab key in the iframe (with designMode on) will cause the |
// entry of a tab character so we have to trap that here. Since we don't |
// know the next focusable object we put focus on the iframe and then the |
// user has to press tab again (which then does the expected thing). |
// A problem with that is that the screen reader user hears "edit area" |
// announced twice which causes confusion. By setting the |
// contentDocument's title to "edit area frame" the confusion should be |
// eliminated. |
this.iframe.contentDocument.title = this._iframeFocusTitle; |
// Place focus on the iframe. A subsequent tab or shift tab will put focus |
// on the correct control. |
// Note: Can't use this.focus() because that results in a call to |
// dijit.focus and if that receives an iframe target it will set focus |
// on the iframe's contentWindow. |
this.iframe.focus(); // this.focus(); won't work |
dojo.stopEvent(e); |
}else if(e.keyCode == dojo.keys.ENTER){ |
e.stopPropagation(); |
}else if(this.inherited("_onKeyPress", arguments) && this.iframe){ |
// #3752: |
// The key press will not make it past the iframe. |
// If a widget is listening outside of the iframe, (like InlineEditBox) |
// it will not hear anything. |
// Create an equivalent event so everyone else knows what is going on. |
var te = document.createEvent("KeyEvents"); |
te.initKeyEvent("keypress", true, true, null, e.ctrlKey, e.altKey, e.shiftKey, e.metaKey, e.keyCode, e.charCode); |
this.iframe.dispatchEvent(te); |
} |
this._changing(); |
}, |
_changing: function(e){ |
// summary: event handler for when a change is imminent |
setTimeout(dojo.hitch(this, "_changed", e, false), 1); |
}, |
_changed: function(e, priorityChange){ |
// summary: event handler for when a change has already happened |
if(this.iframe && this.iframe.contentDocument.designMode != "on"){ |
this.iframe.contentDocument.designMode="on"; // in case this failed on init due to being hidden |
} |
this.setValue(null, priorityChange); |
} |
}); |
} |
/trunk/api/js/dojo1.0/dijit/form/nls/cs/ComboBox.js |
---|
New file |
0,0 → 1,0 |
({"previousMessage": "Předchozí volby", "nextMessage": "Další volby"}) |
/trunk/api/js/dojo1.0/dijit/form/nls/cs/validate.js |
---|
New file |
0,0 → 1,0 |
({"rangeMessage": "* Tato hodnota je mimo rozsah.", "invalidMessage": "* Zadaná hodnota není platná.", "missingMessage": "* Tato hodnota je vyžadována."}) |
/trunk/api/js/dojo1.0/dijit/form/nls/cs/Textarea.js |
---|
New file |
0,0 → 1,0 |
({"iframeTitle1": "oblast úprav", "iframeTitle2": "rámec oblasti úprav"}) |
/trunk/api/js/dojo1.0/dijit/form/nls/es/validate.js |
---|
New file |
0,0 → 1,0 |
({"rangeMessage": "* Este valor está fuera del intervalo.", "invalidMessage": "* El valor especificado no es válido.", "missingMessage": "* Este valor es necesario."}) |
/trunk/api/js/dojo1.0/dijit/form/nls/es/Textarea.js |
---|
New file |
0,0 → 1,0 |
({"iframeTitle1": "área de edición", "iframeTitle2": "marco del área de edición"}) |
/trunk/api/js/dojo1.0/dijit/form/nls/es/ComboBox.js |
---|
New file |
0,0 → 1,0 |
({"previousMessage": "Opciones anteriores", "nextMessage": "Más opciones"}) |
/trunk/api/js/dojo1.0/dijit/form/nls/fr/Textarea.js |
---|
New file |
0,0 → 1,0 |
({"iframeTitle1": "zone d'édition", "iframeTitle2": "cadre de la zone d'édition"}) |
/trunk/api/js/dojo1.0/dijit/form/nls/fr/ComboBox.js |
---|
New file |
0,0 → 1,0 |
({"previousMessage": "Choix précédents", "nextMessage": "Plus de choix"}) |
/trunk/api/js/dojo1.0/dijit/form/nls/fr/validate.js |
---|
New file |
0,0 → 1,0 |
({"rangeMessage": "* Cette valeur n'est pas comprise dans la plage autorisée. ", "invalidMessage": "* La valeur indiquée n'est pas correcte. ", "missingMessage": "* Cette valeur est requise. "}) |
/trunk/api/js/dojo1.0/dijit/form/nls/zh-tw/Textarea.js |
---|
New file |
0,0 → 1,0 |
({"iframeTitle1": "編輯區", "iframeTitle2": "編輯區框"}) |
/trunk/api/js/dojo1.0/dijit/form/nls/zh-tw/ComboBox.js |
---|
New file |
0,0 → 1,0 |
({"previousMessage": "前一個選擇項", "nextMessage": "其他選擇項"}) |
/trunk/api/js/dojo1.0/dijit/form/nls/zh-tw/validate.js |
---|
New file |
0,0 → 1,0 |
({"rangeMessage": "* 此值超出範圍。", "invalidMessage": "* 輸入的值無效。", "missingMessage": "* 必須提供此值。"}) |
/trunk/api/js/dojo1.0/dijit/form/nls/ko/validate.js |
---|
New file |
0,0 → 1,0 |
({"rangeMessage": "* 이 값은 범위를 벗어납니다. ", "invalidMessage": "* 입력한 값이 유효하지 않습니다. ", "missingMessage": "* 이 값은 필수입니다. "}) |
/trunk/api/js/dojo1.0/dijit/form/nls/ko/Textarea.js |
---|
New file |
0,0 → 1,0 |
({"iframeTitle1": "편집 영역", "iframeTitle2": "편집 영역 프레임"}) |
/trunk/api/js/dojo1.0/dijit/form/nls/ko/ComboBox.js |
---|
New file |
0,0 → 1,0 |
({"previousMessage": "이전 선택사항", "nextMessage": "기타 선택사항"}) |
/trunk/api/js/dojo1.0/dijit/form/nls/pl/Textarea.js |
---|
New file |
0,0 → 1,0 |
({"iframeTitle1": "edycja obszaru", "iframeTitle2": "edycja ramki obszaru"}) |
/trunk/api/js/dojo1.0/dijit/form/nls/pl/ComboBox.js |
---|
New file |
0,0 → 1,0 |
({"previousMessage": "Poprzednie wybory", "nextMessage": "Więcej wyborów"}) |
/trunk/api/js/dojo1.0/dijit/form/nls/pl/validate.js |
---|
New file |
0,0 → 1,0 |
({"rangeMessage": "* Ta wartość jest spoza zakresu.", "invalidMessage": "* Wprowadzona wartość nie jest poprawna.", "missingMessage": "* Ta wartość jest wymagana."}) |
/trunk/api/js/dojo1.0/dijit/form/nls/it/ComboBox.js |
---|
New file |
0,0 → 1,0 |
({"previousMessage": "Scelte precedenti", "nextMessage": "Altre scelte"}) |
/trunk/api/js/dojo1.0/dijit/form/nls/it/validate.js |
---|
New file |
0,0 → 1,0 |
({"rangeMessage": "* Questo valore non è compreso nell'intervallo.", "invalidMessage": "* Il valore immesso non è valido.", "missingMessage": "* Questo valore è obbligatorio."}) |
/trunk/api/js/dojo1.0/dijit/form/nls/it/Textarea.js |
---|
New file |
0,0 → 1,0 |
({"iframeTitle1": "modifica area", "iframeTitle2": "modifica frame area"}) |
/trunk/api/js/dojo1.0/dijit/form/nls/hu/ComboBox.js |
---|
New file |
0,0 → 1,0 |
({"previousMessage": "Előző menüpontok", "nextMessage": "További menüpontok"}) |
/trunk/api/js/dojo1.0/dijit/form/nls/hu/validate.js |
---|
New file |
0,0 → 1,0 |
({"rangeMessage": "* Az érték kívül van a megengedett tartományon. ", "invalidMessage": "* A megadott érték érvénytelen. ", "missingMessage": "* Meg kell adni egy értéket. "}) |
/trunk/api/js/dojo1.0/dijit/form/nls/hu/Textarea.js |
---|
New file |
0,0 → 1,0 |
({"iframeTitle1": "szerkesztési terület", "iframeTitle2": "szerkesztési terület keret"}) |
/trunk/api/js/dojo1.0/dijit/form/nls/zh-cn/validate.js |
---|
New file |
0,0 → 1,0 |
({"rangeMessage": "* 输入数据超出值域。", "invalidMessage": "* 非法的输入值。", "missingMessage": "* 此值是必须的。"}) |
/trunk/api/js/dojo1.0/dijit/form/nls/zh/Textarea.js |
---|
New file |
0,0 → 1,0 |
({"iframeTitle1": "编辑区", "iframeTitle2": "编辑区框架"}) |
/trunk/api/js/dojo1.0/dijit/form/nls/zh/ComboBox.js |
---|
New file |
0,0 → 1,0 |
({"previousMessage": "先前选项", "nextMessage": "更多选项"}) |
/trunk/api/js/dojo1.0/dijit/form/nls/zh/validate.js |
---|
New file |
0,0 → 1,0 |
({"rangeMessage": "* 此值超出范围。", "invalidMessage": "* 输入的值无效。", "missingMessage": "* 此值是必需值。"}) |
/trunk/api/js/dojo1.0/dijit/form/nls/ComboBox.js |
---|
New file |
0,0 → 1,0 |
({"previousMessage": "Previous choices", "nextMessage": "More choices"}) |
/trunk/api/js/dojo1.0/dijit/form/nls/pt/ComboBox.js |
---|
New file |
0,0 → 1,0 |
({"previousMessage": "Opções anteriores", "nextMessage": "Mais opções"}) |
/trunk/api/js/dojo1.0/dijit/form/nls/pt/validate.js |
---|
New file |
0,0 → 1,0 |
({"rangeMessage": "* Esse valor está fora do intervalo.", "invalidMessage": "* O valor digitado não é válido.", "missingMessage": "* Esse valor é necessário."}) |
/trunk/api/js/dojo1.0/dijit/form/nls/pt/Textarea.js |
---|
New file |
0,0 → 1,0 |
({"iframeTitle1": "área de edição", "iframeTitle2": "quadro da área de edição"}) |
/trunk/api/js/dojo1.0/dijit/form/nls/ru/Textarea.js |
---|
New file |
0,0 → 1,0 |
({"iframeTitle1": "область редактирования", "iframeTitle2": "фрейм области редактирования"}) |
/trunk/api/js/dojo1.0/dijit/form/nls/ru/ComboBox.js |
---|
New file |
0,0 → 1,0 |
({"previousMessage": "Предыдущие варианты", "nextMessage": "Следующие варианты"}) |
/trunk/api/js/dojo1.0/dijit/form/nls/ru/validate.js |
---|
New file |
0,0 → 1,0 |
({"rangeMessage": "* Это значение вне диапазона.", "invalidMessage": "* Указано недопустимое значение.", "missingMessage": "* Это обязательное значение."}) |
/trunk/api/js/dojo1.0/dijit/form/nls/Textarea.js |
---|
New file |
0,0 → 1,0 |
({"iframeTitle1": "edit area", "iframeTitle2": "edit area frame"}) |
/trunk/api/js/dojo1.0/dijit/form/nls/de/ComboBox.js |
---|
New file |
0,0 → 1,0 |
({"previousMessage": "Vorherige Auswahl", "nextMessage": "Weitere Auswahlmöglichkeiten"}) |
/trunk/api/js/dojo1.0/dijit/form/nls/de/validate.js |
---|
New file |
0,0 → 1,0 |
({"rangeMessage": "* Dieser Wert ist außerhalb des gültigen Bereichs. ", "invalidMessage": "* Der eingegebene Wert ist ungültig. ", "missingMessage": "* Dieser Wert ist erforderlich."}) |
/trunk/api/js/dojo1.0/dijit/form/nls/de/Textarea.js |
---|
New file |
0,0 → 1,0 |
({"iframeTitle1": "Editierbereich", "iframeTitle2": "Rahmen für Editierbereich"}) |
/trunk/api/js/dojo1.0/dijit/form/nls/ja/ComboBox.js |
---|
New file |
0,0 → 1,0 |
({"previousMessage": "以前の選択項目", "nextMessage": "追加の選択項目"}) |
/trunk/api/js/dojo1.0/dijit/form/nls/ja/validate.js |
---|
New file |
0,0 → 1,0 |
({"rangeMessage": "* この値は範囲外です。", "invalidMessage": "* 入力した値は無効です。", "missingMessage": "* この値は必須です。"}) |
/trunk/api/js/dojo1.0/dijit/form/nls/ja/Textarea.js |
---|
New file |
0,0 → 1,0 |
({"iframeTitle1": "編集域", "iframeTitle2": "編集域フレーム"}) |
/trunk/api/js/dojo1.0/dijit/form/nls/validate.js |
---|
New file |
0,0 → 1,0 |
({"rangeMessage": "* This value is out of range.", "invalidMessage": "* The value entered is not valid.", "missingMessage": "* This value is required."}) |
/trunk/api/js/dojo1.0/dijit/form/Slider.js |
---|
New file |
0,0 → 1,401 |
if(!dojo._hasResource["dijit.form.Slider"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. |
dojo._hasResource["dijit.form.Slider"] = true; |
dojo.provide("dijit.form.Slider"); |
dojo.require("dijit.form._FormWidget"); |
dojo.require("dijit._Container"); |
dojo.require("dojo.dnd.move"); |
dojo.require("dijit.form.Button"); |
dojo.require("dojo.number"); |
dojo.declare( |
"dijit.form.HorizontalSlider", |
[dijit.form._FormWidget, dijit._Container], |
{ |
// summary |
// A form widget that allows one to select a value with a horizontally draggable image |
templateString:"<table class=\"dijit dijitReset dijitSlider\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" rules=\"none\"\n\t><tr class=\"dijitReset\"\n\t\t><td class=\"dijitReset\" colspan=\"2\"></td\n\t\t><td dojoAttachPoint=\"containerNode,topDecoration\" class=\"dijitReset\" style=\"text-align:center;width:100%;\"></td\n\t\t><td class=\"dijitReset\" colspan=\"2\"></td\n\t></tr\n\t><tr class=\"dijitReset\"\n\t\t><td class=\"dijitReset dijitSliderButtonContainer dijitHorizontalSliderButtonContainer\"\n\t\t\t><div class=\"dijitHorizontalSliderDecrementIcon\" tabIndex=\"-1\" style=\"display:none\" dojoAttachPoint=\"decrementButton\" dojoAttachEvent=\"onclick: decrement\"><span class=\"dijitSliderButtonInner\">-</span></div\n\t\t></td\n\t\t><td class=\"dijitReset\"\n\t\t\t><div class=\"dijitSliderBar dijitSliderBumper dijitHorizontalSliderBumper dijitSliderLeftBumper dijitHorizontalSliderLeftBumper\"></div\n\t\t></td\n\t\t><td class=\"dijitReset\"\n\t\t\t><input dojoAttachPoint=\"valueNode\" type=\"hidden\" name=\"${name}\"\n\t\t\t/><div style=\"position:relative;\" dojoAttachPoint=\"sliderBarContainer\"\n\t\t\t\t><div dojoAttachPoint=\"progressBar\" class=\"dijitSliderBar dijitHorizontalSliderBar dijitSliderProgressBar dijitHorizontalSliderProgressBar\" dojoAttachEvent=\"onclick:_onBarClick\"\n\t\t\t\t\t><div dojoAttachPoint=\"sliderHandle,focusNode\" class=\"dijitSliderMoveable dijitHorizontalSliderMoveable\" dojoAttachEvent=\"onkeypress:_onKeyPress,onclick:_onHandleClick\" waiRole=\"slider\" valuemin=\"${minimum}\" valuemax=\"${maximum}\"\n\t\t\t\t\t\t><div class=\"dijitSliderImageHandle dijitHorizontalSliderImageHandle\"></div\n\t\t\t\t\t></div\n\t\t\t\t></div\n\t\t\t\t><div dojoAttachPoint=\"remainingBar\" class=\"dijitSliderBar dijitHorizontalSliderBar dijitSliderRemainingBar dijitHorizontalSliderRemainingBar\" dojoAttachEvent=\"onclick:_onBarClick\"></div\n\t\t\t></div\n\t\t></td\n\t\t><td class=\"dijitReset\"\n\t\t\t><div class=\"dijitSliderBar dijitSliderBumper dijitHorizontalSliderBumper dijitSliderRightBumper dijitHorizontalSliderRightBumper\"></div\n\t\t></td\n\t\t><td class=\"dijitReset dijitSliderButtonContainer dijitHorizontalSliderButtonContainer\" style=\"right:0px;\"\n\t\t\t><div class=\"dijitHorizontalSliderIncrementIcon\" tabIndex=\"-1\" style=\"display:none\" dojoAttachPoint=\"incrementButton\" dojoAttachEvent=\"onclick: increment\"><span class=\"dijitSliderButtonInner\">+</span></div\n\t\t></td\n\t></tr\n\t><tr class=\"dijitReset\"\n\t\t><td class=\"dijitReset\" colspan=\"2\"></td\n\t\t><td dojoAttachPoint=\"containerNode,bottomDecoration\" class=\"dijitReset\" style=\"text-align:center;\"></td\n\t\t><td class=\"dijitReset\" colspan=\"2\"></td\n\t></tr\n></table>\n", |
value: 0, |
// showButtons: boolean |
// Show increment/decrement buttons at the ends of the slider? |
showButtons: true, |
// minimum:: integer |
// The minimum value allowed. |
minimum: 0, |
// maximum: integer |
// The maximum allowed value. |
maximum: 100, |
// discreteValues: integer |
// The maximum allowed values dispersed evenly between minimum and maximum (inclusive). |
discreteValues: Infinity, |
// pageIncrement: integer |
// The amount of change with shift+arrow |
pageIncrement: 2, |
// clickSelect: boolean |
// If clicking the progress bar changes the value or not |
clickSelect: true, |
widgetsInTemplate: true, |
attributeMap: dojo.mixin(dojo.clone(dijit.form._FormWidget.prototype.attributeMap), |
{id:"", name:"valueNode"}), |
baseClass: "dijitSlider", |
_mousePixelCoord: "pageX", |
_pixelCount: "w", |
_startingPixelCoord: "x", |
_startingPixelCount: "l", |
_handleOffsetCoord: "left", |
_progressPixelSize: "width", |
_upsideDown: false, |
_onKeyPress: function(/*Event*/ e){ |
if(this.disabled || e.altKey || e.ctrlKey){ return; } |
switch(e.keyCode){ |
case dojo.keys.HOME: |
this.setValue(this.minimum, false); |
break; |
case dojo.keys.END: |
this.setValue(this.maximum, false); |
break; |
case dojo.keys.UP_ARROW: |
case (this._isReversed() ? dojo.keys.LEFT_ARROW : dojo.keys.RIGHT_ARROW): |
case dojo.keys.PAGE_UP: |
this.increment(e); |
break; |
case dojo.keys.DOWN_ARROW: |
case (this._isReversed() ? dojo.keys.RIGHT_ARROW : dojo.keys.LEFT_ARROW): |
case dojo.keys.PAGE_DOWN: |
this.decrement(e); |
break; |
default: |
this.inherited("_onKeyPress", arguments); |
return; |
} |
dojo.stopEvent(e); |
}, |
_onHandleClick: function(e){ |
if(this.disabled){ return; } |
if(!dojo.isIE){ |
// make sure you get focus when dragging the handle |
// (but don't do on IE because it causes a flicker on mouse up (due to blur then focus) |
dijit.focus(this.sliderHandle); |
} |
dojo.stopEvent(e); |
}, |
_isReversed: function() { |
return !(this._upsideDown || this.isLeftToRight()); |
}, |
_onBarClick: function(e){ |
if(this.disabled || !this.clickSelect){ return; } |
dijit.focus(this.sliderHandle); |
dojo.stopEvent(e); |
var abspos = dojo.coords(this.sliderBarContainer, true); |
var pixelValue = e[this._mousePixelCoord] - abspos[this._startingPixelCoord]; |
this._setPixelValue(this._isReversed() || this._upsideDown ? (abspos[this._pixelCount] - pixelValue) : pixelValue, abspos[this._pixelCount], true); |
}, |
_setPixelValue: function(/*Number*/ pixelValue, /*Number*/ maxPixels, /*Boolean, optional*/ priorityChange){ |
if(this.disabled){ return; } |
pixelValue = pixelValue < 0 ? 0 : maxPixels < pixelValue ? maxPixels : pixelValue; |
var count = this.discreteValues; |
if(count <= 1 || count == Infinity){ count = maxPixels; } |
count--; |
var pixelsPerValue = maxPixels / count; |
var wholeIncrements = Math.round(pixelValue / pixelsPerValue); |
this.setValue((this.maximum-this.minimum)*wholeIncrements/count + this.minimum, priorityChange); |
}, |
setValue: function(/*Number*/ value, /*Boolean, optional*/ priorityChange){ |
this.valueNode.value = this.value = value; |
this.inherited('setValue', arguments); |
var percent = (value - this.minimum) / (this.maximum - this.minimum); |
this.progressBar.style[this._progressPixelSize] = (percent*100) + "%"; |
this.remainingBar.style[this._progressPixelSize] = ((1-percent)*100) + "%"; |
}, |
_bumpValue: function(signedChange){ |
if(this.disabled){ return; } |
var s = dojo.getComputedStyle(this.sliderBarContainer); |
var c = dojo._getContentBox(this.sliderBarContainer, s); |
var count = this.discreteValues; |
if(count <= 1 || count == Infinity){ count = c[this._pixelCount]; } |
count--; |
var value = (this.value - this.minimum) * count / (this.maximum - this.minimum) + signedChange; |
if(value < 0){ value = 0; } |
if(value > count){ value = count; } |
value = value * (this.maximum - this.minimum) / count + this.minimum; |
this.setValue(value, true); |
}, |
decrement: function(e){ |
// summary |
// decrement slider by 1 unit |
this._bumpValue(e.keyCode == dojo.keys.PAGE_DOWN?-this.pageIncrement:-1); |
}, |
increment: function(e){ |
// summary |
// increment slider by 1 unit |
this._bumpValue(e.keyCode == dojo.keys.PAGE_UP?this.pageIncrement:1); |
}, |
_mouseWheeled: function(/*Event*/ evt){ |
dojo.stopEvent(evt); |
var scrollAmount = 0; |
if(typeof evt.wheelDelta == 'number'){ // IE |
scrollAmount = evt.wheelDelta; |
}else if(typeof evt.detail == 'number'){ // Mozilla+Firefox |
scrollAmount = -evt.detail; |
} |
if(scrollAmount > 0){ |
this.increment(evt); |
}else if(scrollAmount < 0){ |
this.decrement(evt); |
} |
}, |
startup: function(){ |
dojo.forEach(this.getChildren(), function(child){ |
if(this[child.container] != this.containerNode){ |
this[child.container].appendChild(child.domNode); |
} |
}, this); |
}, |
_onBlur: function(){ |
dijit.form.HorizontalSlider.superclass.setValue.call(this, this.value, true); |
}, |
postCreate: function(){ |
if(this.showButtons){ |
this.incrementButton.style.display=""; |
this.decrementButton.style.display=""; |
} |
this.connect(this.domNode, dojo.isIE ? "onmousewheel" : 'DOMMouseScroll', "_mouseWheeled"); |
// define a custom constructor for a SliderMover that points back to me |
var _self = this; |
var mover = function(){ |
dijit.form._SliderMover.apply(this, arguments); |
this.widget = _self; |
}; |
dojo.extend(mover, dijit.form._SliderMover.prototype); |
this._movable = new dojo.dnd.Moveable(this.sliderHandle, {mover: mover}); |
this.inherited('postCreate', arguments); |
}, |
destroy: function(){ |
this._movable.destroy(); |
this.inherited('destroy', arguments); |
} |
}); |
dojo.declare( |
"dijit.form.VerticalSlider", |
dijit.form.HorizontalSlider, |
{ |
// summary |
// A form widget that allows one to select a value with a vertically draggable image |
templateString:"<table class=\"dijitReset dijitSlider\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" rules=\"none\"\n><tbody class=\"dijitReset\"\n\t><tr class=\"dijitReset\"\n\t\t><td class=\"dijitReset\"></td\n\t\t><td class=\"dijitReset dijitSliderButtonContainer dijitVerticalSliderButtonContainer\"\n\t\t\t><div class=\"dijitVerticalSliderIncrementIcon\" tabIndex=\"-1\" style=\"display:none\" dojoAttachPoint=\"incrementButton\" dojoAttachEvent=\"onclick: increment\"><span class=\"dijitSliderButtonInner\">+</span></div\n\t\t></td\n\t\t><td class=\"dijitReset\"></td\n\t></tr\n\t><tr class=\"dijitReset\"\n\t\t><td class=\"dijitReset\"></td\n\t\t><td class=\"dijitReset\"\n\t\t\t><center><div class=\"dijitSliderBar dijitSliderBumper dijitVerticalSliderBumper dijitSliderTopBumper dijitVerticalSliderTopBumper\"></div></center\n\t\t></td\n\t\t><td class=\"dijitReset\"></td\n\t></tr\n\t><tr class=\"dijitReset\"\n\t\t><td dojoAttachPoint=\"leftDecoration\" class=\"dijitReset\" style=\"text-align:center;height:100%;\"></td\n\t\t><td class=\"dijitReset\" style=\"height:100%;\"\n\t\t\t><input dojoAttachPoint=\"valueNode\" type=\"hidden\" name=\"${name}\"\n\t\t\t/><center style=\"position:relative;height:100%;\" dojoAttachPoint=\"sliderBarContainer\"\n\t\t\t\t><div dojoAttachPoint=\"remainingBar\" class=\"dijitSliderBar dijitVerticalSliderBar dijitSliderRemainingBar dijitVerticalSliderRemainingBar\" dojoAttachEvent=\"onclick:_onBarClick\"></div\n\t\t\t\t><div dojoAttachPoint=\"progressBar\" class=\"dijitSliderBar dijitVerticalSliderBar dijitSliderProgressBar dijitVerticalSliderProgressBar\" dojoAttachEvent=\"onclick:_onBarClick\"\n\t\t\t\t\t><div dojoAttachPoint=\"sliderHandle,focusNode\" class=\"dijitSliderMoveable\" dojoAttachEvent=\"onkeypress:_onKeyPress,onclick:_onHandleClick\" style=\"vertical-align:top;\" waiRole=\"slider\" valuemin=\"${minimum}\" valuemax=\"${maximum}\"\n\t\t\t\t\t\t><div class=\"dijitSliderImageHandle dijitVerticalSliderImageHandle\"></div\n\t\t\t\t\t></div\n\t\t\t\t></div\n\t\t\t></center\n\t\t></td\n\t\t><td dojoAttachPoint=\"containerNode,rightDecoration\" class=\"dijitReset\" style=\"text-align:center;height:100%;\"></td\n\t></tr\n\t><tr class=\"dijitReset\"\n\t\t><td class=\"dijitReset\"></td\n\t\t><td class=\"dijitReset\"\n\t\t\t><center><div class=\"dijitSliderBar dijitSliderBumper dijitVerticalSliderBumper dijitSliderBottomBumper dijitVerticalSliderBottomBumper\"></div></center\n\t\t></td\n\t\t><td class=\"dijitReset\"></td\n\t></tr\n\t><tr class=\"dijitReset\"\n\t\t><td class=\"dijitReset\"></td\n\t\t><td class=\"dijitReset dijitSliderButtonContainer dijitVerticalSliderButtonContainer\"\n\t\t\t><div class=\"dijitVerticalSliderDecrementIcon\" tabIndex=\"-1\" style=\"display:none\" dojoAttachPoint=\"decrementButton\" dojoAttachEvent=\"onclick: decrement\"><span class=\"dijitSliderButtonInner\">-</span></div\n\t\t></td\n\t\t><td class=\"dijitReset\"></td\n\t></tr\n></tbody></table>\n", |
_mousePixelCoord: "pageY", |
_pixelCount: "h", |
_startingPixelCoord: "y", |
_startingPixelCount: "t", |
_handleOffsetCoord: "top", |
_progressPixelSize: "height", |
_upsideDown: true |
}); |
dojo.declare("dijit.form._SliderMover", |
dojo.dnd.Mover, |
{ |
onMouseMove: function(e){ |
var widget = this.widget; |
var c = this.constraintBox; |
if(!c){ |
var container = widget.sliderBarContainer; |
var s = dojo.getComputedStyle(container); |
var c = dojo._getContentBox(container, s); |
c[widget._startingPixelCount] = 0; |
this.constraintBox = c; |
} |
var m = this.marginBox; |
var pixelValue = widget._isReversed() ? |
e[widget._mousePixelCoord] - dojo._abs(widget.sliderBarContainer).x : |
m[widget._startingPixelCount] + e[widget._mousePixelCoord]; |
dojo.hitch(widget, "_setPixelValue")(widget._isReversed() || widget._upsideDown? (c[widget._pixelCount]-pixelValue) : pixelValue, c[widget._pixelCount]); |
}, |
destroy: function(e){ |
var widget = this.widget; |
widget.setValue(widget.value, true); |
dojo.dnd.Mover.prototype.destroy.call(this); |
} |
}); |
dojo.declare("dijit.form.HorizontalRule", [dijit._Widget, dijit._Templated], |
{ |
// Summary: |
// Create hash marks for the Horizontal slider |
templateString: '<div class="RuleContainer HorizontalRuleContainer"></div>', |
// count: Integer |
// Number of hash marks to generate |
count: 3, |
// container: Node |
// If this is a child widget, connect it to this parent node |
container: "containerNode", |
// ruleStyle: String |
// CSS style to apply to individual hash marks |
ruleStyle: "", |
_positionPrefix: '<div class="RuleMark HorizontalRuleMark" style="left:', |
_positionSuffix: '%;', |
_suffix: '"></div>', |
_genHTML: function(pos, ndx){ |
return this._positionPrefix + pos + this._positionSuffix + this.ruleStyle + this._suffix; |
}, |
_isHorizontal: true, |
postCreate: function(){ |
if(this.count==1){ |
var innerHTML = this._genHTML(50, 0); |
}else{ |
var interval = 100 / (this.count-1); |
if(!this._isHorizontal || this.isLeftToRight()){ |
var innerHTML = this._genHTML(0, 0); |
for(var i=1; i < this.count-1; i++){ |
innerHTML += this._genHTML(interval*i, i); |
} |
innerHTML += this._genHTML(100, this.count-1); |
}else{ |
var innerHTML = this._genHTML(100, 0); |
for(var i=1; i < this.count-1; i++){ |
innerHTML += this._genHTML(100-interval*i, i); |
} |
innerHTML += this._genHTML(0, this.count-1); |
} |
} |
this.domNode.innerHTML = innerHTML; |
} |
}); |
dojo.declare("dijit.form.VerticalRule", dijit.form.HorizontalRule, |
{ |
// Summary: |
// Create hash marks for the Vertical slider |
templateString: '<div class="RuleContainer VerticalRuleContainer"></div>', |
_positionPrefix: '<div class="RuleMark VerticalRuleMark" style="top:', |
_isHorizontal: false |
}); |
dojo.declare("dijit.form.HorizontalRuleLabels", dijit.form.HorizontalRule, |
{ |
// Summary: |
// Create labels for the Horizontal slider |
templateString: '<div class="RuleContainer HorizontalRuleContainer"></div>', |
// labelStyle: String |
// CSS style to apply to individual text labels |
labelStyle: "", |
// labels: Array |
// Array of text labels to render - evenly spaced from left-to-right or bottom-to-top |
labels: [], |
// numericMargin: Integer |
// Number of generated numeric labels that should be rendered as '' on the ends when labels[] are not specified |
numericMargin: 0, |
// numericMinimum: Integer |
// Leftmost label value for generated numeric labels when labels[] are not specified |
minimum: 0, |
// numericMaximum: Integer |
// Rightmost label value for generated numeric labels when labels[] are not specified |
maximum: 1, |
// constraints: object |
// pattern, places, lang, et al (see dojo.number) for generated numeric labels when labels[] are not specified |
constraints: {pattern:"#%"}, |
_positionPrefix: '<div class="RuleLabelContainer HorizontalRuleLabelContainer" style="left:', |
_labelPrefix: '"><span class="RuleLabel HorizontalRuleLabel">', |
_suffix: '</span></div>', |
_calcPosition: function(pos){ |
return pos; |
}, |
_genHTML: function(pos, ndx){ |
return this._positionPrefix + this._calcPosition(pos) + this._positionSuffix + this.labelStyle + this._labelPrefix + this.labels[ndx] + this._suffix; |
}, |
getLabels: function(){ |
// summary: user replaceable function to return the labels array |
// if the labels array was not specified directly, then see if <li> children were |
var labels = this.labels; |
if(!labels.length){ |
// for markup creation, labels are specified as child elements |
labels = dojo.query("> li", this.srcNodeRef).map(function(node){ |
return String(node.innerHTML); |
}); |
} |
this.srcNodeRef.innerHTML = ''; |
// if the labels were not specified directly and not as <li> children, then calculate numeric labels |
if(!labels.length && this.count > 1){ |
var start = this.minimum; |
var inc = (this.maximum - start) / (this.count-1); |
for (var i=0; i < this.count; i++){ |
labels.push((i<this.numericMargin||i>=(this.count-this.numericMargin))? '' : dojo.number.format(start, this.constraints)); |
start += inc; |
} |
} |
return labels; |
}, |
postMixInProperties: function(){ |
this.inherited('postMixInProperties', arguments); |
this.labels = this.getLabels(); |
this.count = this.labels.length; |
} |
}); |
dojo.declare("dijit.form.VerticalRuleLabels", dijit.form.HorizontalRuleLabels, |
{ |
// Summary: |
// Create labels for the Vertical slider |
templateString: '<div class="RuleContainer VerticalRuleContainer"></div>', |
_positionPrefix: '<div class="RuleLabelContainer VerticalRuleLabelContainer" style="top:', |
_labelPrefix: '"><span class="RuleLabel VerticalRuleLabel">', |
_calcPosition: function(pos){ |
return 100-pos; |
}, |
_isHorizontal: false |
}); |
} |