Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
13c00e54
Commit
13c00e54
authored
Apr 13, 2016
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Switch from jQuery.Cookie to js.Cookie
Signed-off-by:
Michal Čihař
<
michal@cihar.com
>
parent
1640f358
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
155 additions
and
121 deletions
+155
-121
weblate/html/base.html
weblate/html/base.html
+1
-1
weblate/static/js/jquery.cookie.js
weblate/static/js/jquery.cookie.js
+0
-117
weblate/static/js/js.cookie.js
weblate/static/js/js.cookie.js
+151
-0
weblate/static/loader-bootstrap.js
weblate/static/loader-bootstrap.js
+3
-3
No files found.
weblate/html/base.html
View file @
13c00e54
...
...
@@ -45,7 +45,7 @@ var _rollbarConfig = {
</script>
{% endif %}
<script
src=
"{% static 'js/jquery-1.12.3.js' %}"
type=
"text/javascript"
></script>
<script
src=
"{% static 'js/j
query
.cookie.js' %}"
type=
"text/javascript"
></script>
<script
src=
"{% static 'js/j
s
.cookie.js' %}"
type=
"text/javascript"
></script>
<script
src=
"{% static 'js/autosize.js' %}"
type=
"text/javascript"
></script>
<script
src=
"{% static 'js/jquery.sortElements.js' %}"
type=
"text/javascript"
></script>
<script
src=
"{% static 'js/jquery.multi-select.js' %}"
type=
"text/javascript"
></script>
...
...
weblate/static/js/jquery.cookie.js
deleted
100644 → 0
View file @
1640f358
/*!
* jQuery Cookie Plugin v1.4.1
* https://github.com/carhartl/jquery-cookie
*
* Copyright 2013 Klaus Hartl
* Released under the MIT license
*/
(
function
(
factory
)
{
if
(
typeof
define
===
'
function
'
&&
define
.
amd
)
{
// AMD
define
([
'
jquery
'
],
factory
);
}
else
if
(
typeof
exports
===
'
object
'
)
{
// CommonJS
factory
(
require
(
'
jquery
'
));
}
else
{
// Browser globals
factory
(
jQuery
);
}
}(
function
(
$
)
{
var
pluses
=
/
\+
/g
;
function
encode
(
s
)
{
return
config
.
raw
?
s
:
encodeURIComponent
(
s
);
}
function
decode
(
s
)
{
return
config
.
raw
?
s
:
decodeURIComponent
(
s
);
}
function
stringifyCookieValue
(
value
)
{
return
encode
(
config
.
json
?
JSON
.
stringify
(
value
)
:
String
(
value
));
}
function
parseCookieValue
(
s
)
{
if
(
s
.
indexOf
(
'
"
'
)
===
0
)
{
// This is a quoted cookie as according to RFC2068, unescape...
s
=
s
.
slice
(
1
,
-
1
).
replace
(
/
\\
"/g
,
'
"
'
).
replace
(
/
\\\\
/g
,
'
\\
'
);
}
try
{
// Replace server-side written pluses with spaces.
// If we can't decode the cookie, ignore it, it's unusable.
// If we can't parse the cookie, ignore it, it's unusable.
s
=
decodeURIComponent
(
s
.
replace
(
pluses
,
'
'
));
return
config
.
json
?
JSON
.
parse
(
s
)
:
s
;
}
catch
(
e
)
{}
}
function
read
(
s
,
converter
)
{
var
value
=
config
.
raw
?
s
:
parseCookieValue
(
s
);
return
$
.
isFunction
(
converter
)
?
converter
(
value
)
:
value
;
}
var
config
=
$
.
cookie
=
function
(
key
,
value
,
options
)
{
// Write
if
(
value
!==
undefined
&&
!
$
.
isFunction
(
value
))
{
options
=
$
.
extend
({},
config
.
defaults
,
options
);
if
(
typeof
options
.
expires
===
'
number
'
)
{
var
days
=
options
.
expires
,
t
=
options
.
expires
=
new
Date
();
t
.
setTime
(
+
t
+
days
*
864
e
+
5
);
}
return
(
document
.
cookie
=
[
encode
(
key
),
'
=
'
,
stringifyCookieValue
(
value
),
options
.
expires
?
'
; expires=
'
+
options
.
expires
.
toUTCString
()
:
''
,
// use expires attribute, max-age is not supported by IE
options
.
path
?
'
; path=
'
+
options
.
path
:
''
,
options
.
domain
?
'
; domain=
'
+
options
.
domain
:
''
,
options
.
secure
?
'
; secure
'
:
''
].
join
(
''
));
}
// Read
var
result
=
key
?
undefined
:
{};
// To prevent the for loop in the first place assign an empty array
// in case there are no cookies at all. Also prevents odd result when
// calling $.cookie().
var
cookies
=
document
.
cookie
?
document
.
cookie
.
split
(
'
;
'
)
:
[];
for
(
var
i
=
0
,
l
=
cookies
.
length
;
i
<
l
;
i
++
)
{
var
parts
=
cookies
[
i
].
split
(
'
=
'
);
var
name
=
decode
(
parts
.
shift
());
var
cookie
=
parts
.
join
(
'
=
'
);
if
(
key
&&
key
===
name
)
{
// If second argument (value) is a function it's a converter...
result
=
read
(
cookie
,
value
);
break
;
}
// Prevent storing a cookie that we couldn't decode.
if
(
!
key
&&
(
cookie
=
read
(
cookie
))
!==
undefined
)
{
result
[
name
]
=
cookie
;
}
}
return
result
;
};
config
.
defaults
=
{};
$
.
removeCookie
=
function
(
key
,
options
)
{
if
(
$
.
cookie
(
key
)
===
undefined
)
{
return
false
;
}
// Must not alter options, thus extending a fresh object...
$
.
cookie
(
key
,
''
,
$
.
extend
({},
options
,
{
expires
:
-
1
}));
return
!
$
.
cookie
(
key
);
};
}));
weblate/static/js/js.cookie.js
0 → 100644
View file @
13c00e54
/*!
* JavaScript Cookie v2.1.0
* https://github.com/js-cookie/js-cookie
*
* Copyright 2006, 2015 Klaus Hartl & Fagner Brack
* Released under the MIT license
*/
(
function
(
factory
)
{
if
(
typeof
define
===
'
function
'
&&
define
.
amd
)
{
define
(
factory
);
}
else
if
(
typeof
exports
===
'
object
'
)
{
module
.
exports
=
factory
();
}
else
{
var
_OldCookies
=
window
.
Cookies
;
var
api
=
window
.
Cookies
=
factory
();
api
.
noConflict
=
function
()
{
window
.
Cookies
=
_OldCookies
;
return
api
;
};
}
}(
function
()
{
function
extend
()
{
var
i
=
0
;
var
result
=
{};
for
(;
i
<
arguments
.
length
;
i
++
)
{
var
attributes
=
arguments
[
i
];
for
(
var
key
in
attributes
)
{
result
[
key
]
=
attributes
[
key
];
}
}
return
result
;
}
function
init
(
converter
)
{
function
api
(
key
,
value
,
attributes
)
{
var
result
;
if
(
typeof
document
===
'
undefined
'
)
{
return
;
}
// Write
if
(
arguments
.
length
>
1
)
{
attributes
=
extend
({
path
:
'
/
'
},
api
.
defaults
,
attributes
);
if
(
typeof
attributes
.
expires
===
'
number
'
)
{
var
expires
=
new
Date
();
expires
.
setMilliseconds
(
expires
.
getMilliseconds
()
+
attributes
.
expires
*
864
e
+
5
);
attributes
.
expires
=
expires
;
}
try
{
result
=
JSON
.
stringify
(
value
);
if
(
/^
[\{\[]
/
.
test
(
result
))
{
value
=
result
;
}
}
catch
(
e
)
{}
if
(
!
converter
.
write
)
{
value
=
encodeURIComponent
(
String
(
value
))
.
replace
(
/%
(
23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C
)
/g
,
decodeURIComponent
);
}
else
{
value
=
converter
.
write
(
value
,
key
);
}
key
=
encodeURIComponent
(
String
(
key
));
key
=
key
.
replace
(
/%
(
23|24|26|2B|5E|60|7C
)
/g
,
decodeURIComponent
);
key
=
key
.
replace
(
/
[\(\)]
/g
,
escape
);
return
(
document
.
cookie
=
[
key
,
'
=
'
,
value
,
attributes
.
expires
&&
'
; expires=
'
+
attributes
.
expires
.
toUTCString
(),
// use expires attribute, max-age is not supported by IE
attributes
.
path
&&
'
; path=
'
+
attributes
.
path
,
attributes
.
domain
&&
'
; domain=
'
+
attributes
.
domain
,
attributes
.
secure
?
'
; secure
'
:
''
].
join
(
''
));
}
// Read
if
(
!
key
)
{
result
=
{};
}
// To prevent the for loop in the first place assign an empty array
// in case there are no cookies at all. Also prevents odd result when
// calling "get()"
var
cookies
=
document
.
cookie
?
document
.
cookie
.
split
(
'
;
'
)
:
[];
var
rdecode
=
/
(
%
[
0-9A-Z
]{2})
+/g
;
var
i
=
0
;
for
(;
i
<
cookies
.
length
;
i
++
)
{
var
parts
=
cookies
[
i
].
split
(
'
=
'
);
var
name
=
parts
[
0
].
replace
(
rdecode
,
decodeURIComponent
);
var
cookie
=
parts
.
slice
(
1
).
join
(
'
=
'
);
if
(
cookie
.
charAt
(
0
)
===
'
"
'
)
{
cookie
=
cookie
.
slice
(
1
,
-
1
);
}
try
{
cookie
=
converter
.
read
?
converter
.
read
(
cookie
,
name
)
:
converter
(
cookie
,
name
)
||
cookie
.
replace
(
rdecode
,
decodeURIComponent
);
if
(
this
.
json
)
{
try
{
cookie
=
JSON
.
parse
(
cookie
);
}
catch
(
e
)
{}
}
if
(
key
===
name
)
{
result
=
cookie
;
break
;
}
if
(
!
key
)
{
result
[
name
]
=
cookie
;
}
}
catch
(
e
)
{}
}
return
result
;
}
api
.
set
=
api
;
api
.
get
=
function
(
key
)
{
return
api
(
key
);
};
api
.
getJSON
=
function
()
{
return
api
.
apply
({
json
:
true
},
[].
slice
.
call
(
arguments
));
};
api
.
defaults
=
{};
api
.
remove
=
function
(
key
,
attributes
)
{
api
(
key
,
''
,
extend
(
attributes
,
{
expires
:
-
1
}));
};
api
.
withConverter
=
init
;
return
api
;
}
return
init
(
function
()
{});
}));
weblate/static/loader-bootstrap.js
View file @
13c00e54
...
...
@@ -522,9 +522,9 @@ $(function () {
activeTab
.
tab
(
'
show
'
);
window
.
scrollTo
(
0
,
0
);
}
}
else
if
(
$
(
'
.translation-tabs
'
).
length
>
0
&&
$
.
cookie
(
'
translate-tab
'
))
{
}
else
if
(
$
(
'
.translation-tabs
'
).
length
>
0
&&
Cookies
.
get
(
'
translate-tab
'
))
{
/* From cookie */
activeTab
=
$
(
'
[data-toggle=tab][href="
'
+
$
.
cookie
(
'
translate-tab
'
)
+
'
"]
'
);
activeTab
=
$
(
'
[data-toggle=tab][href="
'
+
Cookies
.
get
(
'
translate-tab
'
)
+
'
"]
'
);
if
(
activeTab
.
length
)
{
activeTab
.
tab
(
'
show
'
);
}
...
...
@@ -539,7 +539,7 @@ $(function () {
/* Store active translation tab in cookie */
$
(
'
.translation-tabs a[data-toggle="tab"]
'
).
on
(
'
shown.bs.tab
'
,
function
(
e
)
{
$
.
cookie
(
'
translate-tab
'
,
$
(
this
).
attr
(
'
href
'
)
);
Cookies
.
set
(
'
translate-tab
'
,
$
(
this
).
attr
(
'
href
'
),
{
path
:
''
}
);
});
/* Navigate to a tab when the history changes */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment