diff --git a/FeedTree.js b/FeedTree.js index ca1002549..c9a0cc81c 100644 --- a/FeedTree.js +++ b/FeedTree.js @@ -175,7 +175,7 @@ dojo.declare("fox.FeedTree", dijit.Tree, { if (treeNode) { treeNode = treeNode[0]; if (!is_cat) this._expandNode(treeNode); - this._selectNode(treeNode); + this.set("selectedNodes", [treeNode]); } }, setFeedIcon: function(feed, is_cat, src) { diff --git a/lib/dijit/Calendar.js b/lib/dijit/Calendar.js index fa82770ee..b092ed797 100644 --- a/lib/dijit/Calendar.js +++ b/lib/dijit/Calendar.js @@ -1,12 +1,12 @@ /* - Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved. + Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved. Available via Academic Free License >= 2.1 OR the modified BSD license. see: http://dojotoolkit.org/license for details */ -if(!dojo._hasResource["dijit.Calendar"]){ -dojo._hasResource["dijit.Calendar"]=true; +if(!dojo._hasResource["dijit.Calendar"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["dijit.Calendar"] = true; dojo.provide("dijit.Calendar"); dojo.require("dojo.cldr.supplemental"); dojo.require("dojo.date"); @@ -14,252 +14,596 @@ dojo.require("dojo.date.locale"); dojo.require("dijit._Widget"); dojo.require("dijit._Templated"); dojo.require("dijit._CssStateMixin"); -dojo.declare("dijit.Calendar",[dijit._Widget,dijit._Templated,dijit._CssStateMixin],{templateString:dojo.cache("dijit","templates/Calendar.html","\n\t\n\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\n\t\t\n\t\t\t\n\t\t\n\t\n\t\n\t\t\n\t\t\t\n\t\t\n\t\n\t\n\t\t\n\t\t\t\n\t\t\n\t\n
\n\t\t\t\t\"\"\n\t\t\t\t-\n\t\t\t\n\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t
\n\t\t\t\t\"\"\n\t\t\t\t+\n\t\t\t
\n\t\t\t\t

\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t

\n\t\t\t
\n"),value:new Date(),datePackage:"dojo.date",dayWidth:"narrow",tabIndex:"0",baseClass:"dijitCalendar",cssStateNodes:{"decrementMonth":"dijitCalendarArrow","incrementMonth":"dijitCalendarArrow","previousYearLabelNode":"dijitCalendarPreviousYear","nextYearLabelNode":"dijitCalendarNextYear"},attributeMap:dojo.delegate(dijit._Widget.prototype.attributeMap,{tabIndex:"domNode"}),setValue:function(_1){ -dojo.deprecated("dijit.Calendar:setValue() is deprecated. Use set('value', ...) instead.","","2.0"); -this.set("value",_1); -},_getValueAttr:function(){ -var _2=new this.dateClassObj(this.value); -_2.setHours(0,0,0,0); -if(_2.getDate()_7){ -_b-=7; -} -dojo.query(".dijitCalendarDateTemplate",this.domNode).forEach(function(_c,i){ -i+=_b; -var _d=new this.dateClassObj(_6),_e,_f="dijitCalendar",adj=0; -if(i<_7){ -_e=_9-_7+i+1; -adj=-1; -_f+="Previous"; -}else{ -if(i>=(_7+_8)){ -_e=i-_7-_8+1; -adj=1; -_f+="Next"; -}else{ -_e=i-_7+1; -_f+="Current"; -} -} -if(adj){ -_d=this.dateFuncObj.add(_d,"month",adj); -} -_d.setDate(_e); -if(!this.dateFuncObj.compare(_d,_a,"date")){ -_f="dijitCalendarCurrentDate "+_f; -} -if(this._isSelectedDate(_d,this.lang)){ -_f="dijitCalendarSelectedDate "+_f; -} -if(this.isDisabledDate(_d,this.lang)){ -_f="dijitCalendarDisabledDate "+_f; -} -var _10=this.getClassForDate(_d,this.lang); -if(_10){ -_f=_10+" "+_f; -} -_c.className=_f+"Month dijitCalendarDateTemplate"; -_c.dijitDateValue=_d.valueOf(); -var _11=dojo.query(".dijitCalendarDateLabel",_c)[0],_12=_d.getDateLocalized?_d.getDateLocalized(this.lang):_d.getDate(); -this._setText(_11,_12); -},this); -var _13=this.dateLocaleModule.getNames("months","wide","standAlone",this.lang,_6); -this._setText(this.monthLabelNode,_13[_6.getMonth()]); -dojo.query(".dijitCalendarMonthLabelTemplate",this.domNode).forEach(function(_14,i){ -dojo.toggleClass(_14,"dijitHidden",!(i in _13)); -this._setText(_14,_13[i]); -},this); -var y=_6.getFullYear()-1; -var d=new this.dateClassObj(); -dojo.forEach(["previous","current","next"],function(_15){ -d.setFullYear(y++); -this._setText(this[_15+"YearLabelNode"],this.dateLocaleModule.format(d,{selector:"year",locale:this.lang})); -},this); -var _16=this; -var _17=function(_18,_19,adj){ -_16._connects.push(dijit.typematic.addMouseListener(_16[_18],_16,function(_1a){ -if(_1a>=0){ -_16._adjustDisplay(_19,adj); -} -},0.8,500)); -}; -_17("incrementMonth","month",1); -_17("decrementMonth","month",-1); -_17("nextYearLabelNode","year",1); -_17("previousYearLabelNode","year",-1); -},goToToday:function(){ -this.set("value",new this.dateClassObj()); -},constructor:function(_1b){ -var _1c=(_1b.datePackage&&(_1b.datePackage!="dojo.date"))?_1b.datePackage+".Date":"Date"; -this.dateClassObj=dojo.getObject(_1c,false); -this.datePackage=_1b.datePackage||this.datePackage; -this.dateFuncObj=dojo.getObject(this.datePackage,false); -this.dateLocaleModule=dojo.getObject(this.datePackage+".locale",false); -},postMixInProperties:function(){ -if(isNaN(this.value)){ -delete this.value; -} -this.inherited(arguments); -},postCreate:function(){ -this.inherited(arguments); -dojo.setSelectable(this.domNode,false); -var _1d=dojo.hitch(this,function(_1e,n){ -var _1f=dojo.query(_1e,this.domNode)[0]; -for(var i=0;i` field. For a form element, use dijit.form.DateTextBox instead. + // + // Note that the parser takes all dates attributes passed in the + // [RFC 3339 format](http://www.faqs.org/rfcs/rfc3339.html), e.g. `2005-06-30T08:05:00-07:00` + // so that they are serializable and locale-independent. + // + // example: + // | var calendar = new dijit.Calendar({}, dojo.byId("calendarNode")); + // + // example: + // |
+ + templateString: dojo.cache("dijit", "templates/Calendar.html", "\n\t\n\t\t\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\n\t\t\n\t\t\t\n\t\t\n\t\n\t\n\t\t\n\t\t\t\n\t\t\n\t\n\t\n\t\t\n\t\t\t\n\t\t\n\t\n
\n\t\t\t\t\"\"\n\t\t\t\t-\n\t\t\t\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t
\n\t\t\t\t\"\"\n\t\t\t\t+\n\t\t\t
\n\t\t\t\t

\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t

\n\t\t\t
\n"), + widgetsInTemplate: true, + + // value: Date + // The currently selected Date, initially set to invalid date to indicate no selection. + value: new Date(""), + // TODO: for 2.0 make this a string (ISO format) rather than a Date + + // datePackage: String + // JavaScript namespace to find Calendar routines. Uses Gregorian Calendar routines + // at dojo.date by default. + datePackage: "dojo.date", + + // dayWidth: String + // How to represent the days of the week in the calendar header. See dojo.date.locale + dayWidth: "narrow", + + // tabIndex: Integer + // Order fields are traversed when user hits the tab key + tabIndex: "0", + + // currentFocus: Date + // Date object containing the currently focused date, or the date which would be focused + // if the calendar itself was focused. Also indicates which year and month to display, + // i.e. the current "page" the calendar is on. + currentFocus: new Date(), + + baseClass:"dijitCalendar", + + // Set node classes for various mouse events, see dijit._CssStateMixin for more details + cssStateNodes: { + "decrementMonth": "dijitCalendarArrow", + "incrementMonth": "dijitCalendarArrow", + "previousYearLabelNode": "dijitCalendarPreviousYear", + "nextYearLabelNode": "dijitCalendarNextYear" + }, + + _isValidDate: function(/*Date*/ value){ + // summary: + // Runs various tests on the value, checking that it's a valid date, rather + // than blank or NaN. + // tags: + // private + return value && !isNaN(value) && typeof value == "object" && + value.toString() != this.constructor.prototype.value.toString(); + }, + + setValue: function(/*Date*/ value){ + // summary: + // Deprecated. Use set('value', ...) instead. + // tags: + // deprecated + dojo.deprecated("dijit.Calendar:setValue() is deprecated. Use set('value', ...) instead.", "", "2.0"); + this.set('value', value); + }, + + _getValueAttr: function(){ + // summary: + // Support get('value') + + // this.value is set to 1AM, but return midnight, local time for back-compat + var value = new this.dateClassObj(this.value); + value.setHours(0, 0, 0, 0); + + // If daylight savings pushes midnight to the previous date, fix the Date + // object to point at 1am so it will represent the correct day. See #9366 + if(value.getDate() < this.value.getDate()){ + value = this.dateFuncObj.add(value, "hour", 1); + } + return value; + }, + + _setValueAttr: function(/*Date|Number*/ value, /*Boolean*/ priorityChange){ + // summary: + // Support set("value", ...) + // description: + // Set the current date and update the UI. If the date is disabled, the value will + // not change, but the display will change to the corresponding month. + // value: + // Either a Date or the number of seconds since 1970. + // tags: + // protected + if(value){ + // convert from Number to Date, or make copy of Date object so that setHours() call below + // doesn't affect original value + value = new this.dateClassObj(value); + } + if(this._isValidDate(value)){ + if(!this._isValidDate(this.value) || this.dateFuncObj.compare(value, this.value)){ + value.setHours(1, 0, 0, 0); // round to nearest day (1am to avoid issues when DST shift occurs at midnight, see #8521, #9366) + + if(!this.isDisabledDate(value, this.lang)){ + this._set("value", value); + + // Set focus cell to the new value. Arguably this should only happen when there isn't a current + // focus point. This will also repopulate the grid, showing the new selected value (and possibly + // new month/year). + this.set("currentFocus", value); + + if(priorityChange || typeof priorityChange == "undefined"){ + this.onChange(this.get('value')); + this.onValueSelected(this.get('value')); // remove in 2.0 + } + } + } + }else{ + // clear value, and repopulate grid (to deselect the previously selected day) without changing currentFocus + this._set("value", null); + this.set("currentFocus", this.currentFocus); + } + }, + + _setText: function(node, text){ + // summary: + // This just sets the content of node to the specified text. + // Can't do "node.innerHTML=text" because of an IE bug w/tables, see #3434. + // tags: + // private + while(node.firstChild){ + node.removeChild(node.firstChild); + } + node.appendChild(dojo.doc.createTextNode(text)); + }, + + _populateGrid: function(){ + // summary: + // Fills in the calendar grid with each day (1-31) + // tags: + // private + + var month = new this.dateClassObj(this.currentFocus); + month.setDate(1); + + var firstDay = month.getDay(), + daysInMonth = this.dateFuncObj.getDaysInMonth(month), + daysInPreviousMonth = this.dateFuncObj.getDaysInMonth(this.dateFuncObj.add(month, "month", -1)), + today = new this.dateClassObj(), + dayOffset = dojo.cldr.supplemental.getFirstDayOfWeek(this.lang); + if(dayOffset > firstDay){ dayOffset -= 7; } + + // Iterate through dates in the calendar and fill in date numbers and style info + dojo.query(".dijitCalendarDateTemplate", this.domNode).forEach(function(template, i){ + i += dayOffset; + var date = new this.dateClassObj(month), + number, clazz = "dijitCalendar", adj = 0; + + if(i < firstDay){ + number = daysInPreviousMonth - firstDay + i + 1; + adj = -1; + clazz += "Previous"; + }else if(i >= (firstDay + daysInMonth)){ + number = i - firstDay - daysInMonth + 1; + adj = 1; + clazz += "Next"; + }else{ + number = i - firstDay + 1; + clazz += "Current"; + } + + if(adj){ + date = this.dateFuncObj.add(date, "month", adj); + } + date.setDate(number); + + if(!this.dateFuncObj.compare(date, today, "date")){ + clazz = "dijitCalendarCurrentDate " + clazz; + } + + if(this._isSelectedDate(date, this.lang)){ + clazz = "dijitCalendarSelectedDate " + clazz; + } + + if(this.isDisabledDate(date, this.lang)){ + clazz = "dijitCalendarDisabledDate " + clazz; + } + + var clazz2 = this.getClassForDate(date, this.lang); + if(clazz2){ + clazz = clazz2 + " " + clazz; + } + + template.className = clazz + "Month dijitCalendarDateTemplate"; + template.dijitDateValue = date.valueOf(); // original code + dojo.attr(template, "dijitDateValue", date.valueOf()); // so I can dojo.query() it + var label = dojo.query(".dijitCalendarDateLabel", template)[0], + text = date.getDateLocalized ? date.getDateLocalized(this.lang) : date.getDate(); + this._setText(label, text); + }, this); + + // Repopulate month drop down list based on current year. + // Need to do this to hide leap months in Hebrew calendar. + var monthNames = this.dateLocaleModule.getNames('months', 'wide', 'standAlone', this.lang, month); + this.monthDropDownButton.dropDown.set("months", monthNames); + + // Set name of current month and also fill in spacer element with all the month names + // (invisible) so that the maximum width will affect layout. But not on IE6 because then + // the center overlaps the right (due to a browser bug). + this.monthDropDownButton.containerNode.innerHTML = + (dojo.isIE == 6 ? "" : "
" + this.monthDropDownButton.dropDown.domNode.innerHTML + "
") + + "
" + monthNames[month.getMonth()] + "
"; + + // Fill in localized prev/current/next years + var y = month.getFullYear() - 1; + var d = new this.dateClassObj(); + dojo.forEach(["previous", "current", "next"], function(name){ + d.setFullYear(y++); + this._setText(this[name+"YearLabelNode"], + this.dateLocaleModule.format(d, {selector:'year', locale:this.lang})); + }, this); + }, + + goToToday: function(){ + // summary: + // Sets calendar's value to today's date + this.set('value', new this.dateClassObj()); + }, + + constructor: function(/*Object*/args){ + var dateClass = (args.datePackage && (args.datePackage != "dojo.date"))? args.datePackage + ".Date" : "Date"; + this.dateClassObj = dojo.getObject(dateClass, false); + this.datePackage = args.datePackage || this.datePackage; + this.dateFuncObj = dojo.getObject(this.datePackage, false); + this.dateLocaleModule = dojo.getObject(this.datePackage + ".locale", false); + }, + + postMixInProperties: function(){ + // Parser.instantiate sometimes passes in NaN for IE. Use default value in prototype instead. + // TODO: remove this for 2.0 (thanks to #11511) + if(isNaN(this.value)){ delete this.value; } + + this.inherited(arguments); + }, + + buildRendering: function(){ + this.inherited(arguments); + dojo.setSelectable(this.domNode, false); + + var cloneClass = dojo.hitch(this, function(clazz, n){ + var template = dojo.query(clazz, this.domNode)[0]; + for(var i=0; i= 0){ _this._adjustDisplay(dateProp, adj); } + }, 0.8, 500) + ); + }; + typematic("incrementMonth", "month", 1); + typematic("decrementMonth", "month", -1); + typematic("nextYearLabelNode", "year", 1); + typematic("previousYearLabelNode", "year", -1); + }, + + _adjustDisplay: function(/*String*/ part, /*int*/ amount){ + // summary: + // Moves calendar forwards or backwards by months or years + // part: + // "month" or "year" + // amount: + // Number of months or years + // tags: + // private + this._setCurrentFocusAttr(this.dateFuncObj.add(this.currentFocus, part, amount)); + }, + + _setCurrentFocusAttr: function(/*Date*/ date, /*Boolean*/ forceFocus){ + // summary: + // If the calendar currently has focus, then focuses specified date, + // changing the currently displayed month/year if necessary. + // If the calendar doesn't have focus, updates currently + // displayed month/year, and sets the cell that will get focus. + // forceFocus: + // If true, will focus() the cell even if calendar itself doesn't have focus + + var oldFocus = this.currentFocus, + oldCell = oldFocus ? dojo.query("[dijitDateValue=" + oldFocus.valueOf() + "]", this.domNode)[0] : null; + + // round specified value to nearest day (1am to avoid issues when DST shift occurs at midnight, see #8521, #9366) + date = new this.dateClassObj(date); + date.setHours(1, 0, 0, 0); + + this._set("currentFocus", date); + + // TODO: only re-populate grid when month/year has changed + this._populateGrid(); + + // set tabIndex=0 on new cell, and focus it (but only if Calendar itself is focused) + var newCell = dojo.query("[dijitDateValue=" + date.valueOf() + "]", this.domNode)[0]; + newCell.setAttribute("tabIndex", this.tabIndex); + if(this._focused || forceFocus){ + newCell.focus(); + } + + // set tabIndex=-1 on old focusable cell + if(oldCell && oldCell != newCell){ + if(dojo.isWebKit){ // see #11064 about webkit bug + oldCell.setAttribute("tabIndex", "-1"); + }else{ + oldCell.removeAttribute("tabIndex"); + } + } + }, + + focus: function(){ + // summary: + // Focus the calendar by focusing one of the calendar cells + this._setCurrentFocusAttr(this.currentFocus, true); + }, + + _onMonthSelect: function(/*Number*/ newMonth){ + // summary: + // Handler for when user selects a month from the drop down list + // tags: + // protected + + // move to selected month, bounding by the number of days in the month + // (ex: dec 31 --> jan 28, not jan 31) + this.currentFocus = this.dateFuncObj.add(this.currentFocus, "month", + newMonth - this.currentFocus.getMonth()); + this._populateGrid(); + }, + + _onDayClick: function(/*Event*/ evt){ + // summary: + // Handler for day clicks, selects the date if appropriate + // tags: + // protected + dojo.stopEvent(evt); + for(var node = evt.target; node && !node.dijitDateValue; node = node.parentNode); + if(node && !dojo.hasClass(node, "dijitCalendarDisabledDate")){ + this.set('value', node.dijitDateValue); + } + }, + + _onDayMouseOver: function(/*Event*/ evt){ + // summary: + // Handler for mouse over events on days, sets hovered style + // tags: + // protected + + // event can occur on or the inside the td, + // set node to the . + var node = + dojo.hasClass(evt.target, "dijitCalendarDateLabel") ? + evt.target.parentNode : + evt.target; + + if(node && (node.dijitDateValue || node == this.previousYearLabelNode || node == this.nextYearLabelNode) ){ + dojo.addClass(node, "dijitCalendarHoveredDate"); + this._currentNode = node; + } + }, + + _onDayMouseOut: function(/*Event*/ evt){ + // summary: + // Handler for mouse out events on days, clears hovered style + // tags: + // protected + + if(!this._currentNode){ return; } + + // if mouse out occurs moving from to inside , ignore it + if(evt.relatedTarget && evt.relatedTarget.parentNode == this._currentNode){ return; } + var cls = "dijitCalendarHoveredDate"; + if(dojo.hasClass(this._currentNode, "dijitCalendarActiveDate")) { + cls += " dijitCalendarActiveDate"; + } + dojo.removeClass(this._currentNode, cls); + this._currentNode = null; + }, + + _onDayMouseDown: function(/*Event*/ evt){ + var node = evt.target.parentNode; + if(node && node.dijitDateValue){ + dojo.addClass(node, "dijitCalendarActiveDate"); + this._currentNode = node; + } + }, + + _onDayMouseUp: function(/*Event*/ evt){ + var node = evt.target.parentNode; + if(node && node.dijitDateValue){ + dojo.removeClass(node, "dijitCalendarActiveDate"); + } + }, + +//TODO: use typematic + handleKey: function(/*Event*/ evt){ + // summary: + // Provides keyboard navigation of calendar. + // description: + // Called from _onKeyPress() to handle keypress on a stand alone Calendar, + // and also from `dijit.form._DateTimeTextBox` to pass a keypress event + // from the `dijit.form.DateTextBox` to be handled in this widget + // returns: + // False if the key was recognized as a navigation key, + // to indicate that the event was handled by Calendar and shouldn't be propogated + // tags: + // protected + var dk = dojo.keys, + increment = -1, + interval, + newValue = this.currentFocus; + switch(evt.keyCode){ + case dk.RIGHT_ARROW: + increment = 1; + //fallthrough... + case dk.LEFT_ARROW: + interval = "day"; + if(!this.isLeftToRight()){ increment *= -1; } + break; + case dk.DOWN_ARROW: + increment = 1; + //fallthrough... + case dk.UP_ARROW: + interval = "week"; + break; + case dk.PAGE_DOWN: + increment = 1; + //fallthrough... + case dk.PAGE_UP: + interval = evt.ctrlKey || evt.altKey ? "year" : "month"; + break; + case dk.END: + // go to the next month + newValue = this.dateFuncObj.add(newValue, "month", 1); + // subtract a day from the result when we're done + interval = "day"; + //fallthrough... + case dk.HOME: + newValue = new this.dateClassObj(newValue); + newValue.setDate(1); + break; + case dk.ENTER: + case dk.SPACE: + this.set("value", this.currentFocus); + break; + default: + return true; + } + + if(interval){ + newValue = this.dateFuncObj.add(newValue, interval, increment); + } + + this._setCurrentFocusAttr(newValue); + + return false; + }, + + _onKeyPress: function(/*Event*/ evt){ + // summary: + // For handling keypress events on a stand alone calendar + if(!this.handleKey(evt)){ + dojo.stopEvent(evt); + } + }, + + onValueSelected: function(/*Date*/ date){ + // summary: + // Notification that a date cell was selected. It may be the same as the previous value. + // description: + // Formerly used by `dijit.form._DateTimeTextBox` (and thus `dijit.form.DateTextBox`) + // to get notification when the user has clicked a date. Now onExecute() (above) is used. + // tags: + // protected + }, + + onChange: function(/*Date*/ date){ + // summary: + // Called only when the selected date has changed + }, + + _isSelectedDate: function(/*Date*/ dateObject, /*String?*/ locale){ + // summary: + // Extension point so developers can subclass Calendar to + // support multiple (concurrently) selected dates + // tags: + // protected extension + return this._isValidDate(this.value) && !this.dateFuncObj.compare(dateObject, this.value, "date") + }, + + isDisabledDate: function(/*Date*/ dateObject, /*String?*/ locale){ + // summary: + // May be overridden to disable certain dates in the calendar e.g. `isDisabledDate=dojo.date.locale.isWeekend` + // tags: + // extension +/*===== + return false; // Boolean +=====*/ + }, + + getClassForDate: function(/*Date*/ dateObject, /*String?*/ locale){ + // summary: + // May be overridden to return CSS classes to associate with the date entry for the given dateObject, + // for example to indicate a holiday in specified locale. + // tags: + // extension + +/*===== + return ""; // String +=====*/ + } + } +); + +dojo.declare("dijit.Calendar._MonthDropDown", [dijit._Widget, dijit._Templated], { + // summary: + // The month drop down + + // months: String[] + // List of names of months, possibly w/some undefined entries for Hebrew leap months + // (ex: ["January", "February", undefined, "April", ...]) + months: [], + + templateString: "
", + + _setMonthsAttr: function(/*String[]*/ months){ + this.domNode.innerHTML = dojo.map(months, function(month, idx){ + return month ? "
" + month + "
" : ""; + }).join(""); + }, + + _onClick: function(/*Event*/ evt){ + this.onChange(dojo.attr(evt.target, "month")); + }, + + onChange: function(/*Number*/ month){ + // summary: + // Callback when month is selected from drop down + }, + + _onMenuHover: function(evt){ + dojo.toggleClass(evt.target, "dijitCalendarMonthLabelHover", evt.type == "mouseover"); + } }); -_1d(".dijitCalendarDayLabelTemplate",6); -_1d(".dijitCalendarDateTemplate",6); -_1d(".dijitCalendarWeekTemplate",5); -var _20=this.dateLocaleModule.getNames("days",this.dayWidth,"standAlone",this.lang); -var _21=dojo.cldr.supplemental.getFirstDayOfWeek(this.lang); -dojo.query(".dijitCalendarDayLabel",this.domNode).forEach(function(_22,i){ -this._setText(_22,_20[(i+_21)%7]); -},this); -var _23=new this.dateClassObj(this.value); -var _24=this.dateLocaleModule.getNames("months","wide","standAlone",this.lang,_23); -_1d(".dijitCalendarMonthLabelTemplate",_24.length-1); -dojo.query(".dijitCalendarMonthLabelTemplate",this.domNode).forEach(function(_25,i){ -dojo.attr(_25,"month",i); -if(i in _24){ -this._setText(_25,_24[i]); -} -dojo.place(_25.cloneNode(true),this.monthLabelSpacer); -},this); -this.value=null; -this.set("value",_23); -},_onMenuHover:function(e){ -dojo.stopEvent(e); -dojo.toggleClass(e.target,"dijitMenuItemHover"); -},_adjustDisplay:function(_26,_27){ -this.displayMonth=this.dateFuncObj.add(this.displayMonth,_26,_27); -this._populateGrid(); -},_onMonthToggle:function(evt){ -dojo.stopEvent(evt); -if(evt.type=="mousedown"){ -var _28=dojo.position(this.monthLabelNode); -var dim={width:_28.w+"px",top:-this.displayMonth.getMonth()*_28.h+"px"}; -if((dojo.isIE&&dojo.isQuirks)||dojo.isIE<7){ -dim.left=-_28.w/2+"px"; -} -dojo.style(this.monthDropDown,dim); -this._popupHandler=this.connect(document,"onmouseup","_onMonthToggle"); -}else{ -this.disconnect(this._popupHandler); -delete this._popupHandler; -} -dojo.toggleClass(this.monthDropDown,"dijitHidden"); -dojo.toggleClass(this.monthLabelNode,"dijitVisible"); -},_onMonthSelect:function(evt){ -this._onMonthToggle(evt); -this.displayMonth.setMonth(dojo.attr(evt.target,"month")); -this._populateGrid(); -},_onDayClick:function(evt){ -dojo.stopEvent(evt); -for(var _29=evt.target;_29&&!_29.dijitDateValue;_29=_29.parentNode){ -} -if(_29&&!dojo.hasClass(_29,"dijitCalendarDisabledDate")){ -this.set("value",_29.dijitDateValue); -this.onValueSelected(this.get("value")); -} -},_onDayMouseOver:function(evt){ -var _2a=dojo.hasClass(evt.target,"dijitCalendarDateLabel")?evt.target.parentNode:evt.target; -if(_2a&&(_2a.dijitDateValue||_2a==this.previousYearLabelNode||_2a==this.nextYearLabelNode)){ -dojo.addClass(_2a,"dijitCalendarHoveredDate"); -this._currentNode=_2a; -} -},_onDayMouseOut:function(evt){ -if(!this._currentNode){ -return; -} -if(evt.relatedTarget&&evt.relatedTarget.parentNode==this._currentNode){ -return; -} -dojo.removeClass(this._currentNode,"dijitCalendarHoveredDate"); -if(dojo.hasClass(this._currentNode,"dijitCalendarActiveDate")){ -dojo.removeClass(this._currentNode,"dijitCalendarActiveDate"); -} -this._currentNode=null; -},_onDayMouseDown:function(evt){ -var _2b=evt.target.parentNode; -if(_2b&&_2b.dijitDateValue){ -dojo.addClass(_2b,"dijitCalendarActiveDate"); -this._currentNode=_2b; -} -},_onDayMouseUp:function(evt){ -var _2c=evt.target.parentNode; -if(_2c&&_2c.dijitDateValue){ -dojo.removeClass(_2c,"dijitCalendarActiveDate"); -} -},_onKeyPress:function(evt){ -var dk=dojo.keys,_2d=-1,_2e,_2f=this.value; -switch(evt.keyCode){ -case dk.RIGHT_ARROW: -_2d=1; -case dk.LEFT_ARROW: -_2e="day"; -if(!this.isLeftToRight()){ -_2d*=-1; -} -break; -case dk.DOWN_ARROW: -_2d=1; -case dk.UP_ARROW: -_2e="week"; -break; -case dk.PAGE_DOWN: -_2d=1; -case dk.PAGE_UP: -_2e=evt.ctrlKey?"year":"month"; -break; -case dk.END: -_2f=this.dateFuncObj.add(_2f,"month",1); -_2e="day"; -case dk.HOME: -_2f=new Date(_2f).setDate(1); -break; -case dk.ENTER: -this.onValueSelected(this.get("value")); -break; -case dk.ESCAPE: -default: -return; -} -dojo.stopEvent(evt); -if(_2e){ -_2f=this.dateFuncObj.add(_2f,_2e,_2d); -} -this.set("value",_2f); -},onValueSelected:function(_30){ -},onChange:function(_31){ -},_isSelectedDate:function(_32,_33){ -return !this.dateFuncObj.compare(_32,this.value,"date"); -},isDisabledDate:function(_34,_35){ -},getClassForDate:function(_36,_37){ -}}); + } diff --git a/lib/dijit/CheckedMenuItem.js b/lib/dijit/CheckedMenuItem.js index a84837897..ab24dfb95 100644 --- a/lib/dijit/CheckedMenuItem.js +++ b/lib/dijit/CheckedMenuItem.js @@ -1,24 +1,54 @@ /* - Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved. + Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved. Available via Academic Free License >= 2.1 OR the modified BSD license. see: http://dojotoolkit.org/license for details */ -if(!dojo._hasResource["dijit.CheckedMenuItem"]){ -dojo._hasResource["dijit.CheckedMenuItem"]=true; +if(!dojo._hasResource["dijit.CheckedMenuItem"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["dijit.CheckedMenuItem"] = true; dojo.provide("dijit.CheckedMenuItem"); dojo.require("dijit.MenuItem"); -dojo.declare("dijit.CheckedMenuItem",dijit.MenuItem,{templateString:dojo.cache("dijit","templates/CheckedMenuItem.html","\n\t\n\t\t\"\"\n\t\t\n\t\n\t\n\t\n\t \n\n"),checked:false,_setCheckedAttr:function(_1){ -dojo.toggleClass(this.domNode,"dijitCheckedMenuItemChecked",_1); -dijit.setWaiState(this.domNode,"checked",_1); -this.checked=_1; -},onChange:function(_2){ -},_onClick:function(e){ -if(!this.disabled){ -this.set("checked",!this.checked); -this.onChange(this.checked); -} -this.inherited(arguments); -}}); + + +dojo.declare("dijit.CheckedMenuItem", + dijit.MenuItem, + { + // summary: + // A checkbox-like menu item for toggling on and off + + templateString: dojo.cache("dijit", "templates/CheckedMenuItem.html", "\n\t\n\t\t\"\"\n\t\t\n\t\n\t\n\t\n\t \n\n"), + + // checked: Boolean + // Our checked state + checked: false, + _setCheckedAttr: function(/*Boolean*/ checked){ + // summary: + // Hook so attr('checked', bool) works. + // Sets the class and state for the check box. + dojo.toggleClass(this.domNode, "dijitCheckedMenuItemChecked", checked); + dijit.setWaiState(this.domNode, "checked", checked); + this._set("checked", checked); + }, + + onChange: function(/*Boolean*/ checked){ + // summary: + // User defined function to handle check/uncheck events + // tags: + // callback + }, + + _onClick: function(/*Event*/ e){ + // summary: + // Clicking this item just toggles its state + // tags: + // private + if(!this.disabled){ + this.set("checked", !this.checked); + this.onChange(this.checked); + } + this.inherited(arguments); + } + }); + } diff --git a/lib/dijit/ColorPalette.js b/lib/dijit/ColorPalette.js index 62aae00df..62c9d8df6 100644 --- a/lib/dijit/ColorPalette.js +++ b/lib/dijit/ColorPalette.js @@ -1,31 +1,142 @@ /* - Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved. + Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved. Available via Academic Free License >= 2.1 OR the modified BSD license. see: http://dojotoolkit.org/license for details */ -if(!dojo._hasResource["dijit.ColorPalette"]){ -dojo._hasResource["dijit.ColorPalette"]=true; +if(!dojo._hasResource["dijit.ColorPalette"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["dijit.ColorPalette"] = true; dojo.provide("dijit.ColorPalette"); dojo.require("dijit._Widget"); dojo.require("dijit._Templated"); dojo.require("dojo.colors"); dojo.require("dojo.i18n"); +dojo.require("dojo.string"); dojo.require("dijit._PaletteMixin"); -dojo.requireLocalization("dojo","colors",null,"ROOT,ar,ca,cs,da,de,el,es,fi,fr,he,hu,it,ja,ko,nb,nl,pl,pt,pt-pt,ro,ru,sk,sl,sv,th,tr,zh,zh-tw"); -dojo.declare("dijit.ColorPalette",[dijit._Widget,dijit._Templated,dijit._PaletteMixin],{palette:"7x10",_palettes:{"7x10":[["white","seashell","cornsilk","lemonchiffon","lightyellow","palegreen","paleturquoise","lightcyan","lavender","plum"],["lightgray","pink","bisque","moccasin","khaki","lightgreen","lightseagreen","lightskyblue","cornflowerblue","violet"],["silver","lightcoral","sandybrown","orange","palegoldenrod","chartreuse","mediumturquoise","skyblue","mediumslateblue","orchid"],["gray","red","orangered","darkorange","yellow","limegreen","darkseagreen","royalblue","slateblue","mediumorchid"],["dimgray","crimson","chocolate","coral","gold","forestgreen","seagreen","blue","blueviolet","darkorchid"],["darkslategray","firebrick","saddlebrown","sienna","olive","green","darkcyan","mediumblue","darkslateblue","darkmagenta"],["black","darkred","maroon","brown","darkolivegreen","darkgreen","midnightblue","navy","indigo","purple"]],"3x4":[["white","lime","green","blue"],["silver","yellow","fuchsia","navy"],["gray","red","purple","black"]]},_imagePaths:{"7x10":dojo.moduleUrl("dijit.themes","a11y/colors7x10.png"),"3x4":dojo.moduleUrl("dijit.themes","a11y/colors3x4.png"),"7x10-rtl":dojo.moduleUrl("dijit.themes","a11y/colors7x10-rtl.png"),"3x4-rtl":dojo.moduleUrl("dijit.themes","a11y/colors3x4-rtl.png")},templateString:dojo.cache("dijit","templates/ColorPalette.html","
\n\t\"\"/\n\t\n\t\t\n\t
\n
\n"),baseClass:"dijitColorPalette",dyeClass:"dijit._Color",buildRendering:function(){ -this.inherited(arguments); -this.imageNode.setAttribute("src",this._imagePaths[this.palette+(this.isLeftToRight()?"":"-rtl")].toString()); -var _1=dojo.i18n.getLocalization("dojo","colors",this.lang); -this._preparePalette(this._palettes[this.palette],_1); -}}); -dojo.declare("dijit._Color",dojo.Color,{constructor:function(_2){ -this._alias=_2; -this.setColor(dojo.Color.named[_2]); -},getValue:function(){ -return this.toHex(); -},fillCell:function(_3,_4){ -dojo.create("img",{src:_4,"class":"dijitPaletteImg",alt:this._alias},_3); -}}); +dojo.requireLocalization("dojo", "colors", null, "ROOT,ar,ca,cs,da,de,el,es,fi,fr,he,hu,it,ja,kk,ko,nb,nl,pl,pt,pt-pt,ro,ru,sk,sl,sv,th,tr,zh,zh-tw"); + + +dojo.declare("dijit.ColorPalette", + [dijit._Widget, dijit._Templated, dijit._PaletteMixin], + { + // summary: + // A keyboard accessible color-picking widget + // description: + // Grid showing various colors, so the user can pick a certain color. + // Can be used standalone, or as a popup. + // + // example: + // |
+ // + // example: + // | var picker = new dijit.ColorPalette({ },srcNode); + // | picker.startup(); + + + // palette: [const] String + // Size of grid, either "7x10" or "3x4". + palette: "7x10", + + // _palettes: [protected] Map + // This represents the value of the colors. + // The first level is a hashmap of the different palettes available. + // The next two dimensions represent the columns and rows of colors. + _palettes: { + "7x10": [["white", "seashell", "cornsilk", "lemonchiffon","lightyellow", "palegreen", "paleturquoise", "lightcyan", "lavender", "plum"], + ["lightgray", "pink", "bisque", "moccasin", "khaki", "lightgreen", "lightseagreen", "lightskyblue", "cornflowerblue", "violet"], + ["silver", "lightcoral", "sandybrown", "orange", "palegoldenrod", "chartreuse", "mediumturquoise", "skyblue", "mediumslateblue","orchid"], + ["gray", "red", "orangered", "darkorange", "yellow", "limegreen", "darkseagreen", "royalblue", "slateblue", "mediumorchid"], + ["dimgray", "crimson", "chocolate", "coral", "gold", "forestgreen", "seagreen", "blue", "blueviolet", "darkorchid"], + ["darkslategray","firebrick","saddlebrown", "sienna", "olive", "green", "darkcyan", "mediumblue","darkslateblue", "darkmagenta" ], + ["black", "darkred", "maroon", "brown", "darkolivegreen", "darkgreen", "midnightblue", "navy", "indigo", "purple"]], + + "3x4": [["white", "lime", "green", "blue"], + ["silver", "yellow", "fuchsia", "navy"], + ["gray", "red", "purple", "black"]] + }, + + // templateString: String + // The template of this widget. + templateString: dojo.cache("dijit", "templates/ColorPalette.html", "
\n\t\n\t\t\n\t
\n
\n"), + + baseClass: "dijitColorPalette", + + buildRendering: function(){ + // Instantiate the template, which makes a skeleton into which we'll insert a bunch of + // nodes + this.inherited(arguments); + + // Creates nodes in each cell of the template. + // Pass in "customized" dijit._Color constructor for specified palette and high-contrast vs. normal mode + this._preparePalette( + this._palettes[this.palette], + dojo.i18n.getLocalization("dojo", "colors", this.lang), + dojo.declare(dijit._Color, { + hc: dojo.hasClass(dojo.body(), "dijit_a11y"), + palette: this.palette + }) + ); + } +}); + +dojo.declare("dijit._Color", dojo.Color, { + // summary: + // Object associated with each cell in a ColorPalette palette. + // Implements dijit.Dye. + + // Template for each cell in normal (non-high-contrast mode). Each cell contains a wrapper + // node for showing the border (called dijitPaletteImg for back-compat), and dijitColorPaletteSwatch + // for showing the color. + template: + "" + + "${alt}" + + "", + + // Template for each cell in high contrast mode. Each cell contains an image with the whole palette, + // but scrolled and clipped to show the correct color only + hcTemplate: + "" + + "${alt}" + + "", + + // _imagePaths: [protected] Map + // This is stores the path to the palette images used for high-contrast mode display + _imagePaths: { + "7x10": dojo.moduleUrl("dijit.themes", "a11y/colors7x10.png"), + "3x4": dojo.moduleUrl("dijit.themes", "a11y/colors3x4.png") + }, + + constructor: function(/*String*/alias, /*Number*/ row, /*Number*/ col){ + this._alias = alias; + this._row = row; + this._col = col; + this.setColor(dojo.Color.named[alias]); + }, + + getValue: function(){ + // summary: + // Note that although dijit._Color is initialized with a value like "white" getValue() always + // returns a hex value + return this.toHex(); + }, + + fillCell: function(/*DOMNode*/ cell, /*String*/ blankGif){ + var html = dojo.string.substitute(this.hc ? this.hcTemplate : this.template, { + // substitution variables for normal mode + color: this.toHex(), + blankGif: blankGif, + alt: this._alias, + + // variables used for high contrast mode + image: this._imagePaths[this.palette].toString(), + left: this._col * -20 - 5, + top: this._row * -20 - 5, + size: this.palette == "7x10" ? "height: 145px; width: 206px" : "height: 64px; width: 86px" + }); + + dojo.place(html, cell); + } +}); + } diff --git a/lib/dijit/Declaration.js b/lib/dijit/Declaration.js index 57cbfd031..1cfa8ecad 100644 --- a/lib/dijit/Declaration.js +++ b/lib/dijit/Declaration.js @@ -1,36 +1,106 @@ /* - Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved. + Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved. Available via Academic Free License >= 2.1 OR the modified BSD license. see: http://dojotoolkit.org/license for details */ -if(!dojo._hasResource["dijit.Declaration"]){ -dojo._hasResource["dijit.Declaration"]=true; +if(!dojo._hasResource["dijit.Declaration"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. +dojo._hasResource["dijit.Declaration"] = true; dojo.provide("dijit.Declaration"); dojo.require("dijit._Widget"); dojo.require("dijit._Templated"); -dojo.declare("dijit.Declaration",dijit._Widget,{_noScript:true,widgetClass:"",defaults:null,mixins:[],buildRendering:function(){ -var _1=this.srcNodeRef.parentNode.removeChild(this.srcNodeRef),_2=dojo.query("> script[type^='dojo/method'][event]",_1).orphan(),_3=dojo.query("> script[type^='dojo/method']",_1).orphan(),_4=dojo.query("> script[type^='dojo/connect']",_1).orphan(),_5=_1.nodeName; -var _6=this.defaults||{}; -dojo.forEach(_2,function(s){ -var _7=s.getAttribute("event"),_8=dojo.parser._functionFromScript(s); -_6[_7]=_8; -}); -this.mixins=this.mixins.length?dojo.map(this.mixins,function(_9){ -return dojo.getObject(_9); -}):[dijit._Widget,dijit._Templated]; -_6.widgetsInTemplate=true; -_6._skipNodeCache=true; -_6.templateString="<"+_5+" class='"+_1.className+"' dojoAttachPoint='"+(_1.getAttribute("dojoAttachPoint")||"")+"' dojoAttachEvent='"+(_1.getAttribute("dojoAttachEvent")||"")+"' >"+_1.innerHTML.replace(/\%7B/g,"{").replace(/\%7D/g,"}")+""; -dojo.query("[dojoType]",_1).forEach(function(_a){ -_a.removeAttribute("dojoType"); -}); -var wc=dojo.declare(this.widgetClass,this.mixins,_6); -var _b=_4.concat(_3); -dojo.forEach(_b,function(s){ -var _c=s.getAttribute("event")||"postscript",_d=dojo.parser._functionFromScript(s); -dojo.connect(wc.prototype,_c,_d); -}); -}}); + + +dojo.declare( + "dijit.Declaration", + dijit._Widget, + { + // summary: + // The Declaration widget allows a developer to declare new widget + // classes directly from a snippet of markup. + + // _noScript: [private] Boolean + // Flag to parser to leave alone the script tags contained inside of me + _noScript: true, + + // stopParser: [private] Boolean + // Flag to parser to not try and parse widgets declared inside of me + stopParser: true, + + // widgetClass: [const] String + // Name of class being declared, ex: "acme.myWidget" + widgetClass: "", + + // propList: [const] Object + // Set of attributes for this widget along with default values, ex: + // {delay: 100, title: "hello world"} + defaults: null, + + // mixins: [const] String[] + // List containing the prototype for this widget, and also any mixins, + // ex: ["dijit._Widget", "dijit._Container"] + mixins: [], + + buildRendering: function(){ + var src = this.srcNodeRef.parentNode.removeChild(this.srcNodeRef), + methods = dojo.query("> script[type^='dojo/method']", src).orphan(), + connects = dojo.query("> script[type^='dojo/connect']", src).orphan(), + srcType = src.nodeName; + + var propList = this.defaults || {}; + + // For all methods defined like + // +}; +=====*/ + +// All the stuff in _base (these are the function that are guaranteed available without an explicit dojo.require) + +// And some other stuff that we tend to pull in all the time anyway + +} diff --git a/lib/dijit/dijit.js.uncompressed.js b/lib/dijit/dijit.js.uncompressed.js deleted file mode 100644 index 076a03208..000000000 --- a/lib/dijit/dijit.js.uncompressed.js +++ /dev/null @@ -1,5961 +0,0 @@ -/* - Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved. - Available via Academic Free License >= 2.1 OR the modified BSD license. - see: http://dojotoolkit.org/license for details -*/ - -/* - This is an optimized version of Dojo, built for deployment and not for - development. To get sources and documentation, please visit: - - http://dojotoolkit.org -*/ - -if(!dojo._hasResource["dojo.window"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. -dojo._hasResource["dojo.window"] = true; -dojo.provide("dojo.window"); - -dojo.window.getBox = function(){ - // summary: - // Returns the dimensions and scroll position of the viewable area of a browser window - - var scrollRoot = (dojo.doc.compatMode == 'BackCompat') ? dojo.body() : dojo.doc.documentElement; - - // get scroll position - var scroll = dojo._docScroll(); // scrollRoot.scrollTop/Left should work - return { w: scrollRoot.clientWidth, h: scrollRoot.clientHeight, l: scroll.x, t: scroll.y }; -}; - -dojo.window.get = function(doc){ - // summary: - // Get window object associated with document doc - - // In some IE versions (at least 6.0), document.parentWindow does not return a - // reference to the real window object (maybe a copy), so we must fix it as well - // We use IE specific execScript to attach the real window reference to - // document._parentWindow for later use - if(dojo.isIE && window !== document.parentWindow){ - /* - In IE 6, only the variable "window" can be used to connect events (others - may be only copies). - */ - doc.parentWindow.execScript("document._parentWindow = window;", "Javascript"); - //to prevent memory leak, unset it after use - //another possibility is to add an onUnload handler which seems overkill to me (liucougar) - var win = doc._parentWindow; - doc._parentWindow = null; - return win; // Window - } - - return doc.parentWindow || doc.defaultView; // Window -}; - -dojo.window.scrollIntoView = function(/*DomNode*/ node, /*Object?*/ pos){ - // summary: - // Scroll the passed node into view, if it is not already. - - // don't rely on node.scrollIntoView working just because the function is there - - try{ // catch unexpected/unrecreatable errors (#7808) since we can recover using a semi-acceptable native method - node = dojo.byId(node); - var doc = node.ownerDocument || dojo.doc, - body = doc.body || dojo.body(), - html = doc.documentElement || body.parentNode, - isIE = dojo.isIE, isWK = dojo.isWebKit; - // if an untested browser, then use the native method - if((!(dojo.isMoz || isIE || isWK || dojo.isOpera) || node == body || node == html) && (typeof node.scrollIntoView != "undefined")){ - node.scrollIntoView(false); // short-circuit to native if possible - return; - } - var backCompat = doc.compatMode == 'BackCompat', - clientAreaRoot = backCompat? body : html, - scrollRoot = isWK ? body : clientAreaRoot, - rootWidth = clientAreaRoot.clientWidth, - rootHeight = clientAreaRoot.clientHeight, - rtl = !dojo._isBodyLtr(), - nodePos = pos || dojo.position(node), - el = node.parentNode, - isFixed = function(el){ - return ((isIE <= 6 || (isIE && backCompat))? false : (dojo.style(el, 'position').toLowerCase() == "fixed")); - }; - if(isFixed(node)){ return; } // nothing to do - - while(el){ - if(el == body){ el = scrollRoot; } - var elPos = dojo.position(el), - fixedPos = isFixed(el); - - if(el == scrollRoot){ - elPos.w = rootWidth; elPos.h = rootHeight; - if(scrollRoot == html && isIE && rtl){ elPos.x += scrollRoot.offsetWidth-elPos.w; } // IE workaround where scrollbar causes negative x - if(elPos.x < 0 || !isIE){ elPos.x = 0; } // IE can have values > 0 - if(elPos.y < 0 || !isIE){ elPos.y = 0; } - }else{ - var pb = dojo._getPadBorderExtents(el); - elPos.w -= pb.w; elPos.h -= pb.h; elPos.x += pb.l; elPos.y += pb.t; - } - - if(el != scrollRoot){ // body, html sizes already have the scrollbar removed - var clientSize = el.clientWidth, - scrollBarSize = elPos.w - clientSize; - if(clientSize > 0 && scrollBarSize > 0){ - elPos.w = clientSize; - if(isIE && rtl){ elPos.x += scrollBarSize; } - } - clientSize = el.clientHeight; - scrollBarSize = elPos.h - clientSize; - if(clientSize > 0 && scrollBarSize > 0){ - elPos.h = clientSize; - } - } - if(fixedPos){ // bounded by viewport, not parents - if(elPos.y < 0){ - elPos.h += elPos.y; elPos.y = 0; - } - if(elPos.x < 0){ - elPos.w += elPos.x; elPos.x = 0; - } - if(elPos.y + elPos.h > rootHeight){ - elPos.h = rootHeight - elPos.y; - } - if(elPos.x + elPos.w > rootWidth){ - elPos.w = rootWidth - elPos.x; - } - } - // calculate overflow in all 4 directions - var l = nodePos.x - elPos.x, // beyond left: < 0 - t = nodePos.y - Math.max(elPos.y, 0), // beyond top: < 0 - r = l + nodePos.w - elPos.w, // beyond right: > 0 - bot = t + nodePos.h - elPos.h; // beyond bottom: > 0 - if(r * l > 0){ - var s = Math[l < 0? "max" : "min"](l, r); - nodePos.x += el.scrollLeft; - el.scrollLeft += (isIE >= 8 && !backCompat && rtl)? -s : s; - nodePos.x -= el.scrollLeft; - } - if(bot * t > 0){ - nodePos.y += el.scrollTop; - el.scrollTop += Math[t < 0? "max" : "min"](t, bot); - nodePos.y -= el.scrollTop; - } - el = (el != scrollRoot) && !fixedPos && el.parentNode; - } - }catch(error){ - console.error('scrollIntoView: ' + error); - node.scrollIntoView(false); - } -}; - -} - -if(!dojo._hasResource["dijit._base.manager"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code. -dojo._hasResource["dijit._base.manager"] = true; -dojo.provide("dijit._base.manager"); - -dojo.declare("dijit.WidgetSet", null, { - // summary: - // A set of widgets indexed by id. A default instance of this class is - // available as `dijit.registry` - // - // example: - // Create a small list of widgets: - // | var ws = new dijit.WidgetSet(); - // | ws.add(dijit.byId("one")); - // | ws.add(dijit.byId("two")); - // | // destroy both: - // | ws.forEach(function(w){ w.destroy(); }); - // - // example: - // Using dijit.registry: - // | dijit.registry.forEach(function(w){ /* do something */ }); - - constructor: function(){ - this._hash = {}; - this.length = 0; - }, - - add: function(/*dijit._Widget*/ widget){ - // summary: - // Add a widget to this list. If a duplicate ID is detected, a error is thrown. - // - // widget: dijit._Widget - // Any dijit._Widget subclass. - if(this._hash[widget.id]){ - throw new Error("Tried to register widget with id==" + widget.id + " but that id is already registered"); - } - this._hash[widget.id] = widget; - this.length++; - }, - - remove: function(/*String*/ id){ - // summary: - // Remove a widget from this WidgetSet. Does not destroy the widget; simply - // removes the reference. - if(this._hash[id]){ - delete this._hash[id]; - this.length--; - } - }, - - forEach: function(/*Function*/ func, /* Object? */thisObj){ - // summary: - // Call specified function for each widget in this set. - // - // func: - // A callback function to run for each item. Is passed the widget, the index - // in the iteration, and the full hash, similar to `dojo.forEach`. - // - // thisObj: - // An optional scope parameter - // - // example: - // Using the default `dijit.registry` instance: - // | dijit.registry.forEach(function(widget){ - // | console.log(widget.declaredClass); - // | }); - // - // returns: - // Returns self, in order to allow for further chaining. - - thisObj = thisObj || dojo.global; - var i = 0, id; - for(id in this._hash){ - func.call(thisObj, this._hash[id], i++, this._hash); - } - return this; // dijit.WidgetSet - }, - - filter: function(/*Function*/ filter, /* Object? */thisObj){ - // summary: - // Filter down this WidgetSet to a smaller new WidgetSet - // Works the same as `dojo.filter` and `dojo.NodeList.filter` - // - // filter: - // Callback function to test truthiness. Is passed the widget - // reference and the pseudo-index in the object. - // - // thisObj: Object? - // Option scope to use for the filter function. - // - // example: - // Arbitrary: select the odd widgets in this list - // | dijit.registry.filter(function(w, i){ - // | return i % 2 == 0; - // | }).forEach(function(w){ /* odd ones */ }); - - thisObj = thisObj || dojo.global; - var res = new dijit.WidgetSet(), i = 0, id; - for(id in this._hash){ - var w = this._hash[id]; - if(filter.call(thisObj, w, i++, this._hash)){ - res.add(w); - } - } - return res; // dijit.WidgetSet - }, - - byId: function(/*String*/ id){ - // summary: - // Find a widget in this list by it's id. - // example: - // Test if an id is in a particular WidgetSet - // | var ws = new dijit.WidgetSet(); - // | ws.add(dijit.byId("bar")); - // | var t = ws.byId("bar") // returns a widget - // | var x = ws.byId("foo"); // returns undefined - - return this._hash[id]; // dijit._Widget - }, - - byClass: function(/*String*/ cls){ - // summary: - // Reduce this widgetset to a new WidgetSet of a particular `declaredClass` - // - // cls: String - // The Class to scan for. Full dot-notated string. - // - // example: - // Find all `dijit.TitlePane`s in a page: - // | dijit.registry.byClass("dijit.TitlePane").forEach(function(tp){ tp.close(); }); - - var res = new dijit.WidgetSet(), id, widget; - for(id in this._hash){ - widget = this._hash[id]; - if(widget.declaredClass == cls){ - res.add(widget); - } - } - return res; // dijit.WidgetSet -}, - - toArray: function(){ - // summary: - // Convert this WidgetSet into a true Array - // - // example: - // Work with the widget .domNodes in a real Array - // | dojo.map(dijit.registry.toArray(), function(w){ return w.domNode; }); - - var ar = []; - for(var id in this._hash){ - ar.push(this._hash[id]); - } - return ar; // dijit._Widget[] -}, - - map: function(/* Function */func, /* Object? */thisObj){ - // summary: - // Create a new Array from this WidgetSet, following the same rules as `dojo.map` - // example: - // | var nodes = dijit.registry.map(function(w){ return w.domNode; }); - // - // returns: - // A new array of the returned values. - return dojo.map(this.toArray(), func, thisObj); // Array - }, - - every: function(func, thisObj){ - // summary: - // A synthetic clone of `dojo.every` acting explicitly on this WidgetSet - // - // func: Function - // A callback function run for every widget in this list. Exits loop - // when the first false return is encountered. - // - // thisObj: Object? - // Optional scope parameter to use for the callback - - thisObj = thisObj || dojo.global; - var x = 0, i; - for(i in this._hash){ - if(!func.call(thisObj, this._hash[i], x++, this._hash)){ - return false; // Boolean - } - } - return true; // Boolean - }, - - some: function(func, thisObj){ - // summary: - // A synthetic clone of `dojo.some` acting explictly on this WidgetSet - // - // func: Function - // A callback function run for every widget in this list. Exits loop - // when the first true return is encountered. - // - // thisObj: Object? - // Optional scope parameter to use for the callback - - thisObj = thisObj || dojo.global; - var x = 0, i; - for(i in this._hash){ - if(func.call(thisObj, this._hash[i], x++, this._hash)){ - return true; // Boolean - } - } - return false; // Boolean - } - -}); - -(function(){ - - /*===== - dijit.registry = { - // summary: - // A list of widgets on a page. - // description: - // Is an instance of `dijit.WidgetSet` - }; - =====*/ - dijit.registry = new dijit.WidgetSet(); - - var hash = dijit.registry._hash, - attr = dojo.attr, - hasAttr = dojo.hasAttr, - style = dojo.style; - - dijit.byId = function(/*String|dijit._Widget*/ id){ - // summary: - // Returns a widget by it's id, or if passed a widget, no-op (like dojo.byId()) - return typeof id == "string" ? hash[id] : id; // dijit._Widget - }; - - var _widgetTypeCtr = {}; - dijit.getUniqueId = function(/*String*/widgetType){ - // summary: - // Generates a unique id for a given widgetType - - var id; - do{ - id = widgetType + "_" + - (widgetType in _widgetTypeCtr ? - ++_widgetTypeCtr[widgetType] : _widgetTypeCtr[widgetType] = 0); - }while(hash[id]); - return dijit._scopeName == "dijit" ? id : dijit._scopeName + "_" + id; // String - }; - - dijit.findWidgets = function(/*DomNode*/ root){ - // summary: - // Search subtree under root returning widgets found. - // Doesn't search for nested widgets (ie, widgets inside other widgets). - - var outAry = []; - - function getChildrenHelper(root){ - for(var node = root.firstChild; node; node = node.nextSibling){ - if(node.nodeType == 1){ - var widgetId = node.getAttribute("widgetId"); - if(widgetId){ - outAry.push(hash[widgetId]); - }else{ - getChildrenHelper(node); - } - } - } - } - - getChildrenHelper(root); - return outAry; - }; - - dijit._destroyAll = function(){ - // summary: - // Code to destroy all widgets and do other cleanup on page unload - - // Clean up focus manager lingering references to widgets and nodes - dijit._curFocus = null; - dijit._prevFocus = null; - dijit._activeStack = []; - - // Destroy all the widgets, top down - dojo.forEach(dijit.findWidgets(dojo.body()), function(widget){ - // Avoid double destroy of widgets like Menu that are attached to - // even though they are logically children of other widgets. - if(!widget._destroyed){ - if(widget.destroyRecursive){ - widget.destroyRecursive(); - }else if(widget.destroy){ - widget.destroy(); - } - } - }); - }; - - if(dojo.isIE){ - // Only run _destroyAll() for IE because we think it's only necessary in that case, - // and because it causes problems on FF. See bug #3531 for details. - dojo.addOnWindowUnload(function(){ - dijit._destroyAll(); - }); - } - - dijit.byNode = function(/*DOMNode*/ node){ - // summary: - // Returns the widget corresponding to the given DOMNode - return hash[node.getAttribute("widgetId")]; // dijit._Widget - }; - - dijit.getEnclosingWidget = function(/*DOMNode*/ node){ - // summary: - // Returns the widget whose DOM tree contains the specified DOMNode, or null if - // the node is not contained within the DOM tree of any widget - while(node){ - var id = node.getAttribute && node.getAttribute("widgetId"); - if(id){ - return hash[id]; - } - node = node.parentNode; - } - return null; - }; - - var shown = (dijit._isElementShown = function(/*Element*/ elem){ - var s = style(elem); - return (s.visibility != "hidden") - && (s.visibility != "collapsed") - && (s.display != "none") - && (attr(elem, "type") != "hidden"); - }); - - dijit.hasDefaultTabStop = function(/*Element*/ elem){ - // summary: - // Tests if element is tab-navigable even without an explicit tabIndex setting - - // No explicit tabIndex setting, need to investigate node type - switch(elem.nodeName.toLowerCase()){ - case "a": - // An w/out a tabindex is only navigable if it has an href - return hasAttr(elem, "href"); - case "area": - case "button": - case "input": - case "object": - case "select": - case "textarea": - // These are navigable by default - return true; - case "iframe": - // If it's an editor