Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Replace vendored jquery.cookie with npm dependency

Alexander Brandon Coles70def5bc2dcc
diff --git a/frontend/package-lock.json b/frontend/package-lock.json
index 2952f354000..5ec1f15c075 100644
--- a/frontend/package-lock.json
+++ b/frontend/package-lock.json
@@ -60,6 +60,7 @@
"@primer/view-components": "npm:@openproject/primer-view-components@^0.71.0",
"@stimulus-components/auto-submit": "^6.0.0",
"@types/hotwired__turbo": "^8.0.1",
+ "@types/jquery.cookie": "^1.4.36",
"@uirouter/angular": "^13.0.0",
"@uirouter/core": "^6.1.0",
"@uirouter/rx": "^1.0.0",
@@ -84,6 +85,7 @@
"jquery": "^3.7.1",
"jquery-ujs": "^1.2.3",
"jquery.caret": "^0.3.1",
+ "jquery.cookie": "^1.4.1",
"json5": "^2.2.2",
"lodash": "^4.17.21",
"mark.js": "^8.11.0",
@@ -8080,11 +8082,18 @@
"version": "3.5.32",
"resolved": "https://registry.npmjs.org/@types/jquery/-/jquery-3.5.32.tgz",
"integrity": "sha512-b9Xbf4CkMqS02YH8zACqN1xzdxc3cO735Qe5AbSUFmyOiaWAbcpqh9Wna+Uk0vgACvoQHpWDg2rGdHkYPLmCiQ==",
- "dev": true,
"dependencies": {
"@types/sizzle": "*"
}
},
+ "node_modules/@types/jquery.cookie": {
+ "version": "1.4.36",
+ "resolved": "https://registry.npmjs.org/@types/jquery.cookie/-/jquery.cookie-1.4.36.tgz",
+ "integrity": "sha512-qtTnH4jHqFWyYX4deNBklWoaK5myKm0WtKf7LbGQB7DUKt6tdAVWfYQ4Kl8Hw/7eNth864Jjts5rBsHjNveR4Q==",
+ "dependencies": {
+ "@types/jquery": "*"
+ }
+ },
"node_modules/@types/jqueryui": {
"version": "1.12.24",
"resolved": "https://registry.npmjs.org/@types/jqueryui/-/jqueryui-1.12.24.tgz",
@@ -8263,8 +8272,7 @@
"node_modules/@types/sizzle": {
"version": "2.3.3",
"resolved": "https://registry.npmjs.org/@types/sizzle/-/sizzle-2.3.3.tgz",
- "integrity": "sha512-JYM8x9EGF163bEyhdJBpR2QX1R5naCJHC8ucJylJ3w9/CVBaskdQ8WqBf8MmQrd1kRvp/a4TS8HJ+bxzR7ZJYQ==",
- "dev": true
+ "integrity": "sha512-JYM8x9EGF163bEyhdJBpR2QX1R5naCJHC8ucJylJ3w9/CVBaskdQ8WqBf8MmQrd1kRvp/a4TS8HJ+bxzR7ZJYQ=="
},
"node_modules/@types/sockjs": {
"version": "0.3.36",
@@ -16584,6 +16592,12 @@
"resolved": "https://registry.npmjs.org/jquery.caret/-/jquery.caret-0.3.1.tgz",
"integrity": "sha512-nS2mjMZzP4e4tIOgeTLSs+jFhUsUVZUPgkUMpi4DlJq9SgKEg6w2jf7q8joMJp6v+voJHXrH8rzAnbyxWHwAeA=="
},
+ "node_modules/jquery.cookie": {
+ "version": "1.4.1",
+ "resolved": "https://registry.npmjs.org/jquery.cookie/-/jquery.cookie-1.4.1.tgz",
+ "integrity": "sha512-c/hZOOL+8VSw/FkTVH637gS1/6YzMSCROpTZ2qBYwJ7s7sHajU7uBkSSiE5+GXWwrfCCyO+jsYjUQ7Hs2rIxAA==",
+ "license": "MIT"
+ },
"node_modules/js-tokens": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
@@ -31326,11 +31340,18 @@
"version": "3.5.32",
"resolved": "https://registry.npmjs.org/@types/jquery/-/jquery-3.5.32.tgz",
"integrity": "sha512-b9Xbf4CkMqS02YH8zACqN1xzdxc3cO735Qe5AbSUFmyOiaWAbcpqh9Wna+Uk0vgACvoQHpWDg2rGdHkYPLmCiQ==",
- "dev": true,
"requires": {
"@types/sizzle": "*"
}
},
+ "@types/jquery.cookie": {
+ "version": "1.4.36",
+ "resolved": "https://registry.npmjs.org/@types/jquery.cookie/-/jquery.cookie-1.4.36.tgz",
+ "integrity": "sha512-qtTnH4jHqFWyYX4deNBklWoaK5myKm0WtKf7LbGQB7DUKt6tdAVWfYQ4Kl8Hw/7eNth864Jjts5rBsHjNveR4Q==",
+ "requires": {
+ "@types/jquery": "*"
+ }
+ },
"@types/jqueryui": {
"version": "1.12.24",
"resolved": "https://registry.npmjs.org/@types/jqueryui/-/jqueryui-1.12.24.tgz",
@@ -31502,8 +31523,7 @@
"@types/sizzle": {
"version": "2.3.3",
"resolved": "https://registry.npmjs.org/@types/sizzle/-/sizzle-2.3.3.tgz",
- "integrity": "sha512-JYM8x9EGF163bEyhdJBpR2QX1R5naCJHC8ucJylJ3w9/CVBaskdQ8WqBf8MmQrd1kRvp/a4TS8HJ+bxzR7ZJYQ==",
- "dev": true
+ "integrity": "sha512-JYM8x9EGF163bEyhdJBpR2QX1R5naCJHC8ucJylJ3w9/CVBaskdQ8WqBf8MmQrd1kRvp/a4TS8HJ+bxzR7ZJYQ=="
},
"@types/sockjs": {
"version": "0.3.36",
@@ -37481,6 +37501,11 @@
"resolved": "https://registry.npmjs.org/jquery.caret/-/jquery.caret-0.3.1.tgz",
"integrity": "sha512-nS2mjMZzP4e4tIOgeTLSs+jFhUsUVZUPgkUMpi4DlJq9SgKEg6w2jf7q8joMJp6v+voJHXrH8rzAnbyxWHwAeA=="
},
+ "jquery.cookie": {
+ "version": "1.4.1",
+ "resolved": "https://registry.npmjs.org/jquery.cookie/-/jquery.cookie-1.4.1.tgz",
+ "integrity": "sha512-c/hZOOL+8VSw/FkTVH637gS1/6YzMSCROpTZ2qBYwJ7s7sHajU7uBkSSiE5+GXWwrfCCyO+jsYjUQ7Hs2rIxAA=="
+ },
"js-tokens": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
diff --git a/frontend/package.json b/frontend/package.json
index 6c1825ebb11..ed5d106443a 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -114,6 +114,7 @@
"@primer/view-components": "npm:@openproject/primer-view-components@^0.71.0",
"@stimulus-components/auto-submit": "^6.0.0",
"@types/hotwired__turbo": "^8.0.1",
+ "@types/jquery.cookie": "^1.4.36",
"@uirouter/angular": "^13.0.0",
"@uirouter/core": "^6.1.0",
"@uirouter/rx": "^1.0.0",
@@ -138,6 +139,7 @@
"jquery": "^3.7.1",
"jquery-ujs": "^1.2.3",
"jquery.caret": "^0.3.1",
+ "jquery.cookie": "^1.4.1",
"json5": "^2.2.2",
"lodash": "^4.17.21",
"mark.js": "^8.11.0",
diff --git a/frontend/src/stimulus/controllers/dynamic/backlogs.controller.ts b/frontend/src/stimulus/controllers/dynamic/backlogs.controller.ts
index c72defb7b78..8ce154be058 100644
--- a/frontend/src/stimulus/controllers/dynamic/backlogs.controller.ts
+++ b/frontend/src/stimulus/controllers/dynamic/backlogs.controller.ts
@@ -3,7 +3,6 @@ import { Controller } from '@hotwired/stimulus';
import 'core-vendor/jquery.flot/jquery.flot';
import 'core-vendor/jquery.flot/excanvas';
import 'core-vendor/jquery.jeditable.mini';
-import 'core-vendor/jquery.cookie';
import 'core-vendor/jquery.colorcontrast';
import './backlogs/common';
diff --git a/frontend/src/stimulus/controllers/dynamic/backlogs/common.ts b/frontend/src/stimulus/controllers/dynamic/backlogs/common.ts
index f80917edfc2..950d76bf277 100644
--- a/frontend/src/stimulus/controllers/dynamic/backlogs/common.ts
+++ b/frontend/src/stimulus/controllers/dynamic/backlogs/common.ts
@@ -26,6 +26,8 @@
// See COPYRIGHT and LICENSE files for more details.
//++
+import 'jquery.cookie';
+
// @ts-expect-error TS(2339): Property 'RB' does not exist on type 'Window & typ... Remove this comment to see the full error message
if (window.RB === null || window.RB === undefined) {
// @ts-expect-error TS(2339): Property 'RB' does not exist on type 'Window & typ... Remove this comment to see the full error message
diff --git a/frontend/src/vendor/jquery.cookie.js b/frontend/src/vendor/jquery.cookie.js
deleted file mode 100644
index 6df1faca25f..00000000000
--- a/frontend/src/vendor/jquery.cookie.js
+++ /dev/null
@@ -1,96 +0,0 @@
-/**
- * Cookie plugin
- *
- * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
- * Dual licensed under the MIT and GPL licenses:
- * http://www.opensource.org/licenses/mit-license.php
- * http://www.gnu.org/licenses/gpl.html
- *
- */
-
-/**
- * Create a cookie with the given name and value and other optional parameters.
- *
- * @example $.cookie('the_cookie', 'the_value');
- * @desc Set the value of a cookie.
- * @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
- * @desc Create a cookie with all available options.
- * @example $.cookie('the_cookie', 'the_value');
- * @desc Create a session cookie.
- * @example $.cookie('the_cookie', null);
- * @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
- * used when the cookie was set.
- *
- * @param String name The name of the cookie.
- * @param String value The value of the cookie.
- * @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
- * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
- * If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
- * If set to null or omitted, the cookie will be a session cookie and will not be retained
- * when the the browser exits.
- * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
- * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
- * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
- * require a secure protocol (like HTTPS).
- * @type undefined
- *
- * @name $.cookie
- * @cat Plugins/Cookie
- * @author Klaus Hartl/[email protected]
- */
-
-/**
- * Get the value of a cookie with the given name.
- *
- * @example $.cookie('the_cookie');
- * @desc Get the value of a cookie.
- *
- * @param String name The name of the cookie.
- * @return The value of the cookie.
- * @type String
- *
- * @name $.cookie
- * @cat Plugins/Cookie
- * @author Klaus Hartl/[email protected]
- */
-jQuery.cookie = function(name, value, options) {
- if (typeof value != 'undefined') { // name and value given, set cookie
- options = options || {};
- if (value === null) {
- value = '';
- options.expires = -1;
- }
- var expires = '';
- if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
- var date;
- if (typeof options.expires == 'number') {
- date = new Date();
- date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
- } else {
- date = options.expires;
- }
- expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
- }
- // CAUTION: Needed to parenthesize options.path and options.domain
- // in the following expressions, otherwise they evaluate to undefined
- // in the packed version for some reason...
- var path = options.path ? '; path=' + (options.path) : '';
- var domain = options.domain ? '; domain=' + (options.domain) : '';
- var secure = options.secure ? '; secure' : '';
- document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
- } else { // only name given, get cookie
- var cookieValue = null;
- if (document.cookie && document.cookie != '') {
- var cookies = document.cookie.split(';');
- for (var i = 0; i < cookies.length; i++) {
- var cookie = jQuery.trim(cookies[i]);
- // Does this cookie string begin with the name we want?
- if (cookie.substring(0, name.length + 1) == (name + '=')) {
- cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
- break;
- }
- }
- }
- return cookieValue;
- }
-};
\ No newline at end of file