Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Css auto reload
- * NOTE!!! remove on production
- */
- (function() {
- 'use strict';
- var CssReload = {
- config: {
- keyCode: 83
- },
- init: function() {
- this.link = $('link[href*="style.css"]');
- this.unix = null;
- this.href = null;
- this.event();
- },
- event: function() {
- jQuery(window).on('keydown', this.reloadStyle.bind(this));
- },
- reloadStyle: function(e) {
- if( e.keyCode === this.config.keyCode
- && localStorage.getItem('dev') == 1 ){
- this._refreshStyle();
- }
- },
- _refreshStyle: function() {
- this.href = this.link.attr('href');
- this.unix = new Date().getTime();
- this.href = /\?/.test(this.href) ? this.href.split('?')[0] : this.href;
- this.link.attr('href', this.href + '?' + this.unix);
- }
- };
- window.CssReload = CssReload;
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement