SaveSearchItemView.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. define([ "require", "backbone", "hbs!tmpl/search/save/SaveSearchItemView_tmpl", "utils/UrlLinks", "utils/Utils", "utils/CommonViewFunction", "utils/Messages" ], function(require, Backbone, SaveSearchItemViewTmpl, UrlLinks, Utils, CommonViewFunction, Messages) {
  2. "use strict";
  3. return Backbone.Marionette.ItemView.extend({
  4. template: SaveSearchItemViewTmpl,
  5. tagName: "li",
  6. className: "parent-node",
  7. ui: {
  8. stateChange: ".item",
  9. tools: ".tools"
  10. },
  11. events: function() {
  12. var events = {};
  13. return events["click " + this.ui.stateChange] = "stateChange", events["click " + this.ui.tools] = function(e) {
  14. e.stopPropagation();
  15. }, events;
  16. },
  17. initialize: function(options) {
  18. _.extend(this, _.pick(options, "collection", "typeHeaders", "applyValue", "fetchFavioriteCollection", "isBasic", "classificationDefCollection", "entityDefCollection", "searchTypeObj")),
  19. this.model.id = this.model.get("guid"), this.model.idAttribute = "guid";
  20. },
  21. onRender: function() {
  22. this.showToolTip();
  23. },
  24. stateChange: function() {
  25. this.applyValue(this.model, this.searchTypeObj), this.trigger("item:clicked"), this.ui.stateChange.parent("li").addClass("active").siblings().removeClass("active");
  26. },
  27. modelEvents: {
  28. change: "render"
  29. },
  30. showToolTip: function(e) {
  31. var that = this;
  32. Utils.generatePopover({
  33. el: this.$(".saveSearchPopover"),
  34. viewFixedPopover: !0,
  35. popoverOptions: {
  36. content: function() {
  37. return "<ul class='saveSearchPopoverList_" + (that.isBasic ? "isBasic" : "isAdvance") + "' data-id=" + that.model.id + "><li class='listTerm' ><i class='fa fa-search'></i> <a href='javascript:void(0)' data-fn='onSearch'>Search </a></li><li class='listTerm' ><i class='fa fa-pencil'></i> <a href='javascript:void(0)' data-fn='onRename'>Rename</a></li><li class='listTerm' ><i class='fa fa-trash-o'></i> <a href='javascript:void(0)' data-fn='onDelete'>Delete</a></li></ul>";
  38. }
  39. }
  40. });
  41. }
  42. });
  43. });