PageRenderTime 51ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

/pollapli/ui/static/pollapli/views/filter_view.js

https://bitbucket.org/kaosat_dev/pollapli
JavaScript | 82 lines | 70 code | 8 blank | 4 comment | 2 complexity | 5a1f36e8fafe5f1248d7042582d37eaa MD5 | raw file
  1. var FilterView= Backbone.View.extend
  2. (
  3. {
  4. initialize: function()
  5. {
  6. this.template=pollapli.ui.templates["filter_widget_tmpl"];
  7. this.filterables=this.options.filterables;
  8. this.orderables=this.options.orderables;
  9. this.currentOrder="name";
  10. this.filterParams={};
  11. //this.el=this.options.el;
  12. _.bindAll(this, "render");
  13. // $("#truc").jqotesub(pollapli.ui.templates["filter_widget_tmpl"], {orderables:["name","version","type"],filterables:["downloaded","installed",]});
  14. },
  15. render: function()
  16. {
  17. //alert(this.el+"gfdfs"+$(this.el).attr("id"));
  18. $(this.el).jqotesub(this.template, {orderables:this.orderables,filterables:this.filterables});
  19. return this;
  20. },
  21. order : function(e)
  22. {
  23. var sortParam=this.$('[id=criteriaSelect]').val();
  24. this.$('[id=criteriaSelect]').val("0");
  25. if(this.currentOrder!=null)
  26. {
  27. if(this.currentOrder==sortParam)
  28. {
  29. this.currentOrder="-"+this.currentOrder;
  30. }
  31. else
  32. {
  33. this.currentOrder=sortParam;
  34. }
  35. }
  36. else
  37. {
  38. this.currentOrder=sortParam;
  39. }
  40. this.parent.renderList(this.parent.collection.filterAndOrder(this.filterParams,this.currentOrder));
  41. // this.parent.renderList(this.parent.collection.sortByParam(this.currentOrder));
  42. },
  43. filter : function(e)
  44. {
  45. var checked={};
  46. $('#filterControl input').each(function()
  47. {
  48. checked[$(this).attr('name')]=$(this).prop("checked") ;
  49. });
  50. this.filterParams=checked;
  51. this.parent.renderList(this.parent.collection.filterAndOrder(this.filterParams,this.currentOrder));
  52. },
  53. clearFilters : function()
  54. {
  55. $(this.el).trigger('tutuEvent');
  56. this.filterParams={};
  57. $('#filterControl input').each(function()
  58. {
  59. $(this).prop("checked",false) ;
  60. });
  61. this.parent.renderList(this.parent.collection.filterAndOrder(this.filterParams,this.currentOrder));
  62. },
  63. doClick : function(e)
  64. {
  65. alert("kljlk") ;
  66. },
  67. events:
  68. {
  69. 'change select ' : 'order',
  70. 'click input': 'filter',
  71. 'click #clearFiltersButton': 'clearFilters',
  72. },
  73. }
  74. );