Skip to content

Commit b539057

Browse files
author
Evgeniy Negometyanov
committed
CMS-692: Improve the current JS according to the standards
1 parent 49882a9 commit b539057

File tree

14 files changed

+117
-1534
lines changed

14 files changed

+117
-1534
lines changed

filer/static/filer/js/addons/fileuploader.min.js

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* Cookie plugin
3+
*
4+
* Copyright (c) 2006 Klaus Hartl (stilbuero.de)
5+
* Dual licensed under the MIT and GPL licenses:
6+
* http://www.opensource.org/licenses/mit-license.php
7+
* http://www.gnu.org/licenses/gpl.html
8+
*
9+
*/
10+
11+
/**
12+
* Create a cookie with the given name and value and other optional parameters.
13+
*
14+
* @example $.cookie('the_cookie', 'the_value');
15+
* @desc Set the value of a cookie.
16+
* @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
17+
* @desc Create a cookie with all available options.
18+
* @example $.cookie('the_cookie', 'the_value');
19+
* @desc Create a session cookie.
20+
* @example $.cookie('the_cookie', null);
21+
* @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
22+
* used when the cookie was set.
23+
*
24+
* @param String name The name of the cookie.
25+
* @param String value The value of the cookie.
26+
* @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
27+
* @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
28+
* If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
29+
* If set to null or omitted, the cookie will be a session cookie and will not be retained
30+
* when the the browser exits.
31+
* @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
32+
* @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
33+
* @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
34+
* require a secure protocol (like HTTPS).
35+
* @type undefined
36+
*
37+
* @name $.cookie
38+
* @cat Plugins/Cookie
39+
* @author Klaus Hartl/[email protected]
40+
*/
41+
42+
!function(e){e.cookie=function(n,o,i){if("undefined"==typeof o){var t=null;if(document.cookie&&""!=document.cookie)for(var r=document.cookie.split(";"),p=0;p<r.length;p++){var u=e.trim(r[p]);if(u.substring(0,n.length+1)==n+"="){t=decodeURIComponent(u.substring(n.length+1));break}}return t}i=i||{},null===o&&(o="",i=$.extend({},i),i.expires=-1);var s="";if(i.expires&&("number"==typeof i.expires||i.expires.toUTCString)){var a;"number"==typeof i.expires?(a=new Date,a.setTime(a.getTime()+24*i.expires*60*60*1e3)):a=i.expires,s="; expires="+a.toUTCString()}var c=i.path?"; path="+i.path:"",d=i.domain?"; domain="+i.domain:"",m=i.secure?"; secure":"";document.cookie=[n,"=",encodeURIComponent(o),s,c,d,m].join("")}}(django.jQuery);
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
'use strict';
2+
/* global django */
3+
4+
(function ($) {
5+
window.dismissPopupAndReload = function (win) {
6+
document.location.reload();
7+
win.close();
8+
};
9+
window.dismissRelatedImageLookupPopup = function (win, chosenId, chosenThumbnailUrl, chosenDescriptionTxt) {
10+
var name = window.windowname_to_id(win.name);
11+
var img_name = name + '_thumbnail_img';
12+
var txt_name = name + '_description_txt';
13+
var clear_name = name + '_clear';
14+
var elem = document.getElementById(name);
15+
var old_id = elem.value;
16+
document.getElementById(name).value = chosenId;
17+
document.getElementById(img_name).src = chosenThumbnailUrl;
18+
document.getElementById(txt_name).innerHTML = chosenDescriptionTxt;
19+
document.getElementById(clear_name).style.display = 'inline';
20+
if (old_id !== chosenId) {
21+
$(elem).trigger('change');
22+
}
23+
win.close();
24+
};
25+
window.dismissRelatedFolderLookupPopup = function (win, chosenId, chosenName) {
26+
var id = window.windowname_to_id(win.name);
27+
var id_name = id + '_description_txt';
28+
document.getElementById(id).value = chosenId;
29+
document.getElementById(id_name).innerHTML = chosenName;
30+
win.close();
31+
};
32+
})(django.jQuery);

0 commit comments

Comments
 (0)