Ext: dynamically changing theme 1 (skin)

Source: Internet
Author: User

Cookie. js

[Javascript]/**
* @ Name Cookie. js
* This should be an older cookie tool. If you want to save it with this tool class
* It's okay for unimportant things (such as status), so you don't need to think about the user name and password.
*/
/**
* Save
* @ Param {Object} name
* @ Param {Object} value
*/
JpkFrame. saveCookie = function (name, value ){
// Save for one month
Var saveDate = new Date (). getTime () + 30*24*3600*1000 );
// Console. log (saveDate. toUTCString ());
Cookies. set (name, value, saveDate );
}
/**
* Get
* @ Param {Object} name
*/
JpkFrame. getCookie = function (name ){
Return Cookies. get (name );
}
/**
* Clear
* @ Param {Object} name
*/
JpkFrame. clearCookie = function (name ){
Cookies. clear (name );
}
Var Cookies = {};
Cookies. set = function (name, value ){
Var argv = arguments;
Var argc = arguments. length;
Var expires = (argc> 2 )? Argv [2]: null;
Var path = (argc> 3 )? Argv [3]: '/';
Var domain = (argc> 4 )? Argv [4]: null;
Var secure = (argc> 5 )? Argv [5]: false;
Document. cookie = name + "=" + encodeURIComponent (value) +
(Expires = null )? "": ("; Expires =" + expires. toUTCString () +
(Path = null )? "": ("; Path =" + path) +
(Domain = null )? "": ("; Domain =" + domain) +
(Secure = true )? "; Secure ":"");
};
Cookies. get = function (name ){
Var arg = name + "= ";
Var alen = arg. length;
Var clen = document. cookie. length;
Var I = 0;
Var j = 0;
While (I <clen ){
J = I + alen;
If (document. cookie. substring (I, j) = arg)
Return Cookies. getCookieVal (j );
I = document. cookie. indexOf ("", I) + 1;
If (I = 0)
Break;
}
Return null;
};
Cookies. clear = function (name ){
If (Cookies. get (name )){
Document. cookie = name + "=" +
"; Expires = Thu, 01-Jan-70 00:00:01 GMT ";
}
};
Cookies. getCookieVal = function (offset ){
Var endstr = document. cookie. indexOf (";", offset );
If (endstr =-1 ){
Endstr = document. cookie. length;
}
Return decodeURIComponent (document. cookie. substring (offset, endstr ));
};
/**
* @ Name Cookie. js
* This should be an older cookie tool. If you want to save it with this tool class
* It's okay for unimportant things (such as status), so you don't need to think about the user name and password.
*/
/**
* Save
* @ Param {Object} name
* @ Param {Object} value
*/
JpkFrame. saveCookie = function (name, value ){
// Save for one month
Var saveDate = new Date (). getTime () + 30*24*3600*1000 );
// Console. log (saveDate. toUTCString ());
Cookies. set (name, value, saveDate );
}
/**
* Get
* @ Param {Object} name
*/
JpkFrame. getCookie = function (name ){
Return Cookies. get (name );
}
/**
* Clear
* @ Param {Object} name
*/
JpkFrame. clearCookie = function (name ){
Cookies. clear (name );
}
Var Cookies = {};
Cookies. set = function (name, value ){
Var argv = arguments;
Var argc = arguments. length;
Var expires = (argc> 2 )? Argv [2]: null;
Var path = (argc> 3 )? Argv [3]: '/';
Var domain = (argc> 4 )? Argv [4]: null;
Var secure = (argc> 5 )? Argv [5]: false;
Document. cookie = name + "=" + encodeURIComponent (value) +
(Expires = null )? "": ("; Expires =" + expires. toUTCString () +
(Path = null )? "": ("; Path =" + path) +
(Domain = null )? "": ("; Domain =" + domain) +
(Secure = true )? "; Secure ":"");
};
Cookies. get = function (name ){
Var arg = name + "= ";
Var alen = arg. length;
Var clen = document. cookie. length;
Var I = 0;
Var j = 0;
While (I <clen ){
J = I + alen;
If (document. cookie. substring (I, j) = arg)
Return Cookies. getCookieVal (j );
I = document. cookie. indexOf ("", I) + 1;
If (I = 0)
Break;
}
Return null;
};
Cookies. clear = function (name ){
If (Cookies. get (name )){
Document. cookie = name + "=" +
"; Expires = Thu, 01-Jan-70 00:00:01 GMT ";
}
};
Cookies. getCookieVal = function (offset ){
Var endstr = document. cookie. indexOf (";", offset );
If (endstr =-1 ){
Endstr = document. cookie. length;
}
Return decodeURIComponent (document. cookie. substring (offset, endstr ));
};


In onReady of Ext

[Javascript]/**
* Change the topic
* @ Param {Object} value
*/
Var changeTheme = function (value ){
If (value ){
Ext. util. CSS. swapStyleSheet ('window', 'ext/resources/css/'+ value + '.css ');
// When restoring to the default style, do not forget to add the custom Style
If (value = 'ext-all '){
Ext. util. CSS. swapStyleSheet ('window', 'jslib/css/main.css ');
}
// Save the topic
SaveThemeToCookie (value );
}
}
/**
* Save the topic name to the cookie.
* @ Param {Object} value
*/
Var saveThemeToCookie = function (value ){
JpkFrame. saveCookie ('jpkframe. theme ', value );
}
/**
* Obtain a topic from a cookie
* Parentheses indicate that the function is executed immediately.
*/
Var readThemeFromCookie = function (){
Var themeValue = JpkFrame. getCookie ('jpkframe. theme ');
If (themeValue ){
Ext. getCmp ('Theme-combo '). setValue (themeValue );
ChangeTheme (themeValue );
}
}();

 

 

From jelly village chief

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.