fork download
  1. Y.extend(Filter, Y.QueryBuilder, {
  2. initializer: function() {
  3. },
  4. renderUI: function() {
  5. // Add the Apply button to the end of filter constraints.
  6. Filter.superclass.renderUI.apply(this);
  7. var content = this.get("contentBox");
  8. content.append('<button class="gf-filter-apply" type="button">' + this.get("applyText") + '</button>');
  9. },
  10. count:0,
  11. appendNew:function(){
  12. Filter.superclass.appendNew.apply(this, arguments);
  13. var selectNode=Y.all(".yui3-filter-variable .yui3-filter-field").item(this.count++);
  14. selectNode.on("change",function(e,selectNode){
  15. this.fire("selectChange",{payload:selectNode});
  16. },this,selectNode);
  17. },
  18. destructor : function() {
  19. }
  20. });
  21. //And I am using this new filter something like
  22.  
  23. this.dateVars=[START_DATE,END_DATE] //this is the array of key that require date
  24. if(this.dateVars){
  25. this._createDatePicker();
  26. this.filter.on("selectChange",function(e){
  27. this._calendarHandling(e.payload,e.payload.get("value"));
  28. },this)
  29. }
  30.  
  31. _createDatePicker:function(){
  32. var WIDTH = "150px";
  33. var HEIGHT = "150px"
  34. var overlay = new Y.Overlay({
  35. height:HEIGHT,
  36. width:WIDTH,
  37. visible:false
  38. });
  39. overlay.render("#workspace");
  40. overlay.get("boundingBox").addClass("yui3-skin-sam");
  41. this.overlay = overlay;
  42. var currentDate = this.currentDate;
  43. var calendar = new Y.Calendar({
  44. height:HEIGHT,
  45. width:WIDTH,
  46. visible:true,
  47. showPrevMonth: true,
  48. showNextMonth: true,
  49. date:currentDate }).render();
  50. var dtdate = Y.DataType.Date;
  51. var self = this;
  52. calendar.selectDates(currentDate);
  53. calendar.on("selectionChange", function (ev) {
  54. var newDate = ev.newSelection[0];
  55. self.dateNode.set("value",dtdate.format(newDate,{format:"%B %d %Y"}));
  56. overlay.hide();
  57. });
  58. overlay.set("bodyContent",calendar.get("boundingBox"));
  59. },
  60. _calendarHandling:function(node,key){
  61. if(!this._isDateVars(key)){
  62. return;
  63. }
  64. var dtdate = Y.DataType.Date
  65. var textNode = node.get("parentNode").get("parentNode").one("input");
  66. textNode.set("value",dtdate.format(this.currentDate,{format:"%B %d %Y"}));
  67. var WidgetPositionAlign = Y.WidgetPositionAlign;
  68. textNode.on("click",function(e,textNode){
  69. this.overlay.show();
  70. this.overlay.set("align", {node:textNode, points:[WidgetPositionAlign.TC, WidgetPositionAlign.RC]});
  71. this.dateNode = textNode;
  72. },this,textNode);
  73.  
  74. },
  75. _isDateVars:function(key){
  76. for(i=0;i<this.dateVars.length;i++){
  77. if(this.dateVars[i]==key){
  78. return true;
  79. }
  80. }
  81. return false;
  82. }
Runtime error #stdin #stdout 0.28s 213632KB
stdin
Standard input is empty
stdout
Standard output is empty