Use link+blob urls for the stylesheet. That'll help me inspect the css.
I wonder if it matters performance-wise.
This commit is contained in:
parent
270f7f8ec2
commit
b91d343679
@ -733,10 +733,17 @@
|
|||||||
return setTimeout($.asap, 25, test, cb);
|
return setTimeout($.asap, 25, test, cb);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
addStyle: function(css) {
|
addStyle: function(css, type) {
|
||||||
var style;
|
var style;
|
||||||
style = $.el('style', {
|
style = type === 'style' || !window.URL ? $.el('style', {
|
||||||
textContent: css
|
textContent: css
|
||||||
|
}) : $.el('link', {
|
||||||
|
rel: 'stylesheet',
|
||||||
|
href: URL.createObjectURL(new Blob([css]))
|
||||||
|
}, {
|
||||||
|
type: 'text/css'
|
||||||
|
}, {
|
||||||
|
title: g.NAMESPACE
|
||||||
});
|
});
|
||||||
$.asap((function() {
|
$.asap((function() {
|
||||||
return d.head;
|
return d.head;
|
||||||
@ -3505,7 +3512,7 @@
|
|||||||
if (checked) {
|
if (checked) {
|
||||||
$.on(window, 'resize', ImageExpand.resize);
|
$.on(window, 'resize', ImageExpand.resize);
|
||||||
if (!ImageExpand.style) {
|
if (!ImageExpand.style) {
|
||||||
ImageExpand.style = $.addStyle('');
|
ImageExpand.style = $.addStyle(null, 'style');
|
||||||
}
|
}
|
||||||
return ImageExpand.resize();
|
return ImageExpand.resize();
|
||||||
} else {
|
} else {
|
||||||
@ -4474,7 +4481,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
_Class.prototype.setFile = function(file) {
|
_Class.prototype.setFile = function(file) {
|
||||||
var fileUrl, img, url,
|
var fileUrl, img,
|
||||||
_this = this;
|
_this = this;
|
||||||
this.file = file;
|
this.file = file;
|
||||||
this.el.title = "" + file.name + " (" + ($.bytesToString(file.size)) + ")";
|
this.el.title = "" + file.name + " (" + ($.bytesToString(file.size)) + ")";
|
||||||
@ -4485,10 +4492,10 @@
|
|||||||
this.el.style.backgroundImage = null;
|
this.el.style.backgroundImage = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!(url = window.URL || window.webkitURL)) {
|
if (!window.URL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
url.revokeObjectURL(this.url);
|
URL.revokeObjectURL(this.url);
|
||||||
fileUrl = url.createObjectURL(file);
|
fileUrl = url.createObjectURL(file);
|
||||||
img = $.el('img');
|
img = $.el('img');
|
||||||
$.on(img, 'load', function() {
|
$.on(img, 'load', function() {
|
||||||
@ -4516,17 +4523,16 @@
|
|||||||
for (i = _i = 0; 0 <= l ? _i < l : _i > l; i = 0 <= l ? ++_i : --_i) {
|
for (i = _i = 0; 0 <= l ? _i < l : _i > l; i = 0 <= l ? ++_i : --_i) {
|
||||||
ui8a[i] = data.charCodeAt(i);
|
ui8a[i] = data.charCodeAt(i);
|
||||||
}
|
}
|
||||||
_this.url = url.createObjectURL(new Blob([ui8a], {
|
_this.url = URL.createObjectURL(new Blob([ui8a], {
|
||||||
type: 'image/png'
|
type: 'image/png'
|
||||||
}));
|
}));
|
||||||
_this.el.style.backgroundImage = "url(" + _this.url + ")";
|
_this.el.style.backgroundImage = "url(" + _this.url + ")";
|
||||||
return typeof url.revokeObjectURL === "function" ? url.revokeObjectURL(fileUrl) : void 0;
|
return URL.revokeObjectURL(fileUrl);
|
||||||
});
|
});
|
||||||
return img.src = fileUrl;
|
return img.src = fileUrl;
|
||||||
};
|
};
|
||||||
|
|
||||||
_Class.prototype.rmFile = function() {
|
_Class.prototype.rmFile = function() {
|
||||||
var _base;
|
|
||||||
QR.resetFileInput();
|
QR.resetFileInput();
|
||||||
delete this.file;
|
delete this.file;
|
||||||
this.el.title = null;
|
this.el.title = null;
|
||||||
@ -4534,7 +4540,10 @@
|
|||||||
if (QR.spoiler) {
|
if (QR.spoiler) {
|
||||||
$('label', this.el).hidden = true;
|
$('label', this.el).hidden = true;
|
||||||
}
|
}
|
||||||
return typeof (_base = window.URL || window.webkitURL).revokeObjectURL === "function" ? _base.revokeObjectURL(this.url) : void 0;
|
if (!window.URL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return URL.revokeObjectURL(this.url);
|
||||||
};
|
};
|
||||||
|
|
||||||
_Class.prototype.select = function() {
|
_Class.prototype.select = function() {
|
||||||
@ -4599,7 +4608,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
_Class.prototype.rm = function() {
|
_Class.prototype.rm = function() {
|
||||||
var index, _ref;
|
var index;
|
||||||
QR.resetFileInput();
|
QR.resetFileInput();
|
||||||
$.rm(this.el);
|
$.rm(this.el);
|
||||||
index = QR.replies.indexOf(this);
|
index = QR.replies.indexOf(this);
|
||||||
@ -4609,7 +4618,10 @@
|
|||||||
(QR.replies[index - 1] || QR.replies[index + 1]).select();
|
(QR.replies[index - 1] || QR.replies[index + 1]).select();
|
||||||
}
|
}
|
||||||
QR.replies.splice(index, 1);
|
QR.replies.splice(index, 1);
|
||||||
return (_ref = window.URL || window.webkitURL) != null ? _ref.revokeObjectURL(this.url) : void 0;
|
if (!window.URL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return URL.revokeObjectURL(this.url);
|
||||||
};
|
};
|
||||||
|
|
||||||
return _Class;
|
return _Class;
|
||||||
|
|||||||
13
lib/$.coffee
13
lib/$.coffee
@ -83,9 +83,16 @@ $.extend $,
|
|||||||
cb()
|
cb()
|
||||||
else
|
else
|
||||||
setTimeout $.asap, 25, test, cb
|
setTimeout $.asap, 25, test, cb
|
||||||
addStyle: (css) ->
|
addStyle: (css, type) ->
|
||||||
style = $.el 'style',
|
style = if type is 'style' or !window.URL
|
||||||
textContent: css
|
$.el 'style',
|
||||||
|
textContent: css
|
||||||
|
else
|
||||||
|
$.el 'link',
|
||||||
|
rel: 'stylesheet'
|
||||||
|
href: URL.createObjectURL new Blob [css],
|
||||||
|
type: 'text/css'
|
||||||
|
title: g.NAMESPACE
|
||||||
$.asap (-> d.head), ->
|
$.asap (-> d.head), ->
|
||||||
$.add d.head, style
|
$.add d.head, style
|
||||||
style
|
style
|
||||||
|
|||||||
@ -2134,7 +2134,7 @@ ImageExpand =
|
|||||||
if checked
|
if checked
|
||||||
$.on window, 'resize', ImageExpand.resize
|
$.on window, 'resize', ImageExpand.resize
|
||||||
unless ImageExpand.style
|
unless ImageExpand.style
|
||||||
ImageExpand.style = $.addStyle ''
|
ImageExpand.style = $.addStyle null, 'style'
|
||||||
ImageExpand.resize()
|
ImageExpand.resize()
|
||||||
else
|
else
|
||||||
$.off window, 'resize', ImageExpand.resize
|
$.off window, 'resize', ImageExpand.resize
|
||||||
|
|||||||
@ -351,9 +351,9 @@ QR =
|
|||||||
unless /^image/.test file.type
|
unless /^image/.test file.type
|
||||||
@el.style.backgroundImage = null
|
@el.style.backgroundImage = null
|
||||||
return
|
return
|
||||||
# XXX Opera does not support window.URL
|
# XXX Opera does not support blob URL
|
||||||
return unless url = window.URL or window.webkitURL
|
return unless window.URL
|
||||||
url.revokeObjectURL @url
|
URL.revokeObjectURL @url
|
||||||
|
|
||||||
# Create a redimensioned thumbnail.
|
# Create a redimensioned thumbnail.
|
||||||
fileUrl = url.createObjectURL file
|
fileUrl = url.createObjectURL file
|
||||||
@ -388,9 +388,9 @@ QR =
|
|||||||
for i in [0...l]
|
for i in [0...l]
|
||||||
ui8a[i] = data.charCodeAt i
|
ui8a[i] = data.charCodeAt i
|
||||||
|
|
||||||
@url = url.createObjectURL new Blob [ui8a], type: 'image/png'
|
@url = URL.createObjectURL new Blob [ui8a], type: 'image/png'
|
||||||
@el.style.backgroundImage = "url(#{@url})"
|
@el.style.backgroundImage = "url(#{@url})"
|
||||||
url.revokeObjectURL? fileUrl
|
URL.revokeObjectURL fileUrl
|
||||||
|
|
||||||
img.src = fileUrl
|
img.src = fileUrl
|
||||||
rmFile: ->
|
rmFile: ->
|
||||||
@ -399,7 +399,8 @@ QR =
|
|||||||
@el.title = null
|
@el.title = null
|
||||||
@el.style.backgroundImage = null
|
@el.style.backgroundImage = null
|
||||||
$('label', @el).hidden = true if QR.spoiler
|
$('label', @el).hidden = true if QR.spoiler
|
||||||
(window.URL or window.webkitURL).revokeObjectURL? @url
|
return unless window.URL
|
||||||
|
URL.revokeObjectURL @url
|
||||||
select: ->
|
select: ->
|
||||||
QR.selected?.el.id = null
|
QR.selected?.el.id = null
|
||||||
QR.selected = @
|
QR.selected = @
|
||||||
@ -446,7 +447,8 @@ QR =
|
|||||||
else if @el.id is 'selected'
|
else if @el.id is 'selected'
|
||||||
(QR.replies[index-1] or QR.replies[index+1]).select()
|
(QR.replies[index-1] or QR.replies[index+1]).select()
|
||||||
QR.replies.splice index, 1
|
QR.replies.splice index, 1
|
||||||
(window.URL or window.webkitURL)?.revokeObjectURL @url
|
return unless window.URL
|
||||||
|
URL.revokeObjectURL @url
|
||||||
|
|
||||||
captcha:
|
captcha:
|
||||||
init: ->
|
init: ->
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user