PageSourceSearch

https://www.epicureanfriends.com/wcf/js/WCF.Bookmark.js?v=1788988795

js epicureanfriends.com collected 2026-10-02 07:14:35 UTC 6,706 bytes, 252 lines download raw bytes

1/**
2 * Namespace for bookmarks.
3 *
4 * @author		2016-2022 Darkwood.Design
5 * @license		Commercial Darkwood.Design License <https://darkwood.design/lizenz/>
6 * @package		com.uz.bookmark
7 */
8window.WCF.Bookmark = {};
9
10/**
11 * Loads further bookmarks for a specific user
12 *
13 * @param	integer		userID
14 */
15window.WCF.Bookmark.Loader = Class.extend({
16  /**
17   * container object
18   * @var	jQuery
19   */
20  _container: null,
21
22  /**
23   * access type
24   * @var	string
25   */
26  _bookmarkAccess: "all",
27
28  /**
29   * type
30   * @var	integer
31   */
32  _bookmarkType: "all",
33
34  /**
35   * button to load next events
36   * @var	jQuery
37   */
38  _loadButton: null,
39
40  /**
41   * 'no more entries' element
42   * @var	jQuery
43   */
44  _noMoreEntries: null,
45
46  /**
47   * action proxy
48   * @var	window.WCF.Action.Proxy
49   */
50  _proxy: null,
51
52  /**
53   * user id
54   * @var	integer
55   */
56  _userID: 0,
57
58  _inlineEditor: null,
59
60  /**
61   * Initializes a new Bookmark Loader object.
62   */
63  init: function (userID) {
64    this._container = $("#bookmarkList");
65    this._userID = userID;
66
67    if (!this._userID) {
68      console.debug("[window.WCF.Bookmark.Loader] Invalid parameter 'userID' given.");
69      return;
70    }
71
72    this._proxy = new window.WCF.Action.Proxy({
73      success: $.proxy(this._success, this),
74    });
75
76    var $container = $('<li class="bookmarkListMore showMore"><button class="small">' + WoltLabLanguage.getPhrase("wcf.bookmark.profile.moreItems") + "</button><small>" + WoltLabLanguage.getPhrase("wcf.bookmark.profile.noMoreItems") + "</small></li>").appendTo(this._container);
77    this._loadButton = $container.children("button").click($.proxy(this._click, this));
78    this._noMoreEntries = $container.children("small").hide();
79
80    if (this._container.find("> li").length == 2) {
81      this._loadButton.hide();
82      this._noMoreEntries.show();
83    }
84
85    $("#bookmarkAccess .button").click($.proxy(this._clickBookmarkAccess, this));
86    $("#bookmarkType").on("click", "li", $.proxy(this._clickBookmarkType, this));
87
88    this._inlineEditor = new window.WCF.Bookmark.InlineEditor(".bookmark");
89  },
90
91  /**
92   * Handles bookmark access change.
93   */
94  _clickBookmarkAccess: function (event) {
95    var $button = $(event.currentTarget);
96    if (this._bookmarkAccess != $button.data("bookmarkAccess")) {
97      this._bookmarkAccess = $button.data("bookmarkAccess");
98      $("#bookmarkAccess .button").removeClass("active");
99      $button.addClass("active");
100      this._reload();
101    }
102  },
103
104  /**
105   * Handles bookmark type change.
106   */
107  _clickBookmarkType: function (event) {
108    $("#bookmarkTypeSelector").text($(event.currentTarget).text());
109    this._bookmarkType = $(event.currentTarget).attr("id");
110
111    this._reload();
112  },
113
114  /**
115   * Handles reload.
116   */
117  _reload: function () {
118    this._container.find("> li:not(:first-child):not(:last-child)").remove();
119    this._container.data("lastBookmarkTime", 0);
120    this._click();
121  },
122
123  /**
124   * Loads next bookmarks.
125   */
126  _click: function () {
127    this._loadButton.enable();
128
129    var $parameters = {
130      lastBookmarkTime: this._container.data("lastBookmarkTime"),
131      userID: this._userID,
132      bookmarkAccess: this._bookmarkAccess,
133      bookmarkType: this._bookmarkType,
134    };
135
136    this._proxy.setOption("data", {
137      actionName: "load",
138      className: "wcf\\data\\bookmark\\BookmarkAction",
139      parameters: $parameters,
140    });
141    this._proxy.sendRequest();
142  },
143
144  /**
145   * Handles successful AJAX requests.
146   *
147   * @param	object		data
148   * @param	string		textStatus
149   * @param	jQuery		jqXHR
150   */
151  _success: function (data, textStatus, jqXHR) {
152    if (data.returnValues.template) {
153      $(data.returnValues.template).insertBefore(this._loadButton.parent());
154
155      this._container.data("lastBookmarkTime", data.returnValues.lastBookmarkTime);
156      this._noMoreEntries.hide();
157      this._loadButton.show().enable();
158    } else {
159      this._noMoreEntries.show();
160      this._loadButton.hide();
161    }
162
163    this._inlineEditor = new window.WCF.Bookmark.InlineEditor(".bookmark");
164  },
165});
166
167/**
168 * Inline editor implementation for bookmarks.
169 *
170 * @see	window.WCF.Inline.Editor
171 */
172window.WCF.Bookmark.InlineEditor = window.WCF.InlineEditor.extend({
173  _setOptions: function () {
174    // clear array to clean it from dropdown remains
175    this._dropdowns = [];
176
177    this._options = [
178      { label: WoltLabLanguage.getPhrase("wcf.bookmark.edit.edit"), optionName: "edit" },
179      { label: WoltLabLanguage.getPhrase("wcf.bookmark.edit.delete"), optionName: "delete" },
180    ];
181
182    var share = elById("bookmarkList");
183    var shareEnable = elData(share, "share-enable");
184
185    if (shareEnable == "1") {
186      this._options.push({ optionName: "divider" });
187      this._options.push({ label: WoltLabLanguage.getPhrase("wcf.bookmark.edit.share"), optionName: "share" });
188    }
189  },
190
191  /**
192   * Identify new elements and adds the event listeners to them.
193   */
194  rebuild: function () {
195    var $elements = $(this._elementSelector);
196    var self = this;
197    $elements.each(function (index, element) {
198      var $element = $(element);
199      var $elementID = $element.wcfIdentify();
200
201      // find trigger element
202      var $trigger = self._getTriggerElement($element);
203      if ($trigger === null || $trigger.length !== 1) {
204        return;
205      }
206
207      $trigger.on(WCF_CLICK_EVENT, $.proxy(self._show, self)).data("elementID", $elementID);
208      if (self._quickOption) {
209        // simulate click on target action
210        $trigger.disableSelection().data("optionName", self._quickOption).dblclick($.proxy(self._click, self));
211      }
212
213      // store reference
214      self._elements[$elementID] = $element;
215    });
216  },
217
218  _getTriggerElement: function (element) {
219    return element.find(".jsBookmarkEditor");
220  },
221
222  _validate: function (elementID, optionName) {
223    return true;
224  },
225
226  _execute: function (elementID, optionName) {
227    // abort if option is invalid or not accessible
228    if (!this._validate(elementID, optionName)) {
229      return false;
230    }
231
232    switch (optionName) {
233      case "edit":
234        require(["UZ/Bookmark/Edit"], function (UZBookmarkEdit) {
235          new UZBookmarkEdit(document.getElementById(elementID).getAttribute("data-bookmark-id"), "edit");
236        });
237        break;
238
239      case "delete":
240        require(["UZ/Bookmark/Delete"], function (UZBookmarkDelete) {
241          new UZBookmarkDelete(document.getElementById(elementID).getAttribute("data-bookmark-id"));
242        });
243        break;
244
245      case "share":
246        require(["UZ/Bookmark/Share"], function (UZBookmarkShare) {
247          new UZBookmarkShare(document.getElementById(elementID).getAttribute("data-bookmark-id"));
248        });
249        break;
250    }
251  },
252});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.