feat(SublimeText2.EditorPackages): cache packages

This commit is contained in:
Iristyle
2013-04-04 08:55:15 -04:00
parent d65666cdfc
commit c3efdad2c2
274 changed files with 26863 additions and 0 deletions

View File

@@ -0,0 +1,206 @@
/*jshint globalstrict: true*/
"use strict";
var win_attr = {
get_center : function (dim) {
var c = {
'x' : (win_attr.get_size('x')/2),
'y' : (win_attr.get_size('y')/2)
};
return ((dim) ? c[dim] : c);
},
get_size : function(dir) {
dir = (dir === 'x') ? 'Width' : 'Height';
return ((window['inner'+dir]) ?
window['inner'+dir] :
((window.document.documentElement && window.document.documentElement['client'+dir]) ?
window.document.documentElement['client'+dir] :
window.document.body['client'+dir]
)
);
}
},
position_el = {
center : function (el, dim) {
var c = win_attr.get_center(),
top = (c.y - (el.offsetHeight/2)),
left = (c.x - (el.offsetWidth/2));
if (dim == null || dim === 'y') el.style.top = (top < 0) ? 0 + 'px' : top + 'px';
if (dim == null || dim === 'x') el.style.left = (left < 0) ? 0 + 'px' : left + 'px';
},
set : function (el, x, y) {
var left, top;
if (typeof x === "undefined") x = null;
if (typeof y === "undefined") y = null;
if (y === 'center') {
position_el.center(el, 'y');
} else if (y === 'top') {
el.style.top = 0 + 'px';
} else if (y === 'bottom') {
top = (win_attr.get_size('y') - (el.offsetHeight));
el.style.top = (top < 0) ? 0 + 'px' : top + 'px';
} else if (y.match(/^[\d]+(%|px|em|mm|cm|in|pt|pc)$/) != null) {
el.style.top = y;
}
if (x === "center") {
position_el.center(el, 'x');
} else if (x === 'left') {
el.style.left = 0 + 'px';
} else if (x === 'right') {
left = (win_attr.get_size('x') - (el.offsetWidth));
el.style.left = (left < 0) ? 0 + 'px' : left + 'px';
} else if (x.match(/^[\d]+(%|px|em|mm|cm|in|pt|pc)$/) != null) {
el.style.left = x;
}
}
};
function position_table(el) {
var x, y,
sel = document.getElementById('dock'),
option = sel.options[sel.selectedIndex].value;
switch(option) {
case "0": x = 'center'; y = 'center'; break;
case "1": x = 'center'; y = 'top'; break;
case "2": x = 'center'; y = 'bottom'; break;
case "3": x = 'left'; y = 'center'; break;
case "4": x = 'right'; y = 'center'; break;
case "5": x = 'left'; y = 'top'; break;
case "6": x = 'right'; y = 'top'; break;
case "7": x = 'left'; y = 'bottom'; break;
case "8": x = 'right'; y = 'bottom'; break;
default: break;
}
setTimeout(function () {position_el.set(el, x, y); el.style.visibility = 'visible';}, 300);
}
function toggle_annotations() {
var comments_div = document.getElementById('comment_list'),
mode = comments_div.style.display;
if (mode == 'none') {
comments_div.style.display = 'block';
position_table(comments_div);
} else {
comments_div.style.visibility = 'hidden';
comments_div.style.display = 'none';
}
}
function dock_table() {
var comments_div = document.getElementById('comment_list');
position_table(comments_div);
}
function scroll_to_line(value) {
var pos = 0,
el = document.getElementById(value);
window.scrollTo(0, 0);
while(el) {
pos += el.offsetTop;
el = el.offsetParent;
}
pos -= win_attr.get_center('y');
if (pos < 0) {
pos = 0;
}
window.scrollTo(0, pos);
}
// Tooltips from http://www.scriptiny.com/2008/06/javascript-tooltip/
var tooltip = function() {
var id = 'tooltip',
top = 3,
left = 3,
maxw = 300,
speed = 10,
timer = 20,
endalpha = 95,
alpha = 0,
ie = document.all ? true : false,
tt, t, c, b, h;
return{
annotation_list: {},
init: function() {
var i, comment, comments, len;
comments = document.querySelectorAll("div.annotation_comment");
len = comments.length;
for (i = 0; i < len; i++) {
comment = comments[i];
if ("textContent" in comment) {
tooltip.annotation_list[i] = comment.textContent;
} else {
tooltip.annotation_list[i] = comment.innerText;
}
}
},
show:function(v, w) {
if(tt == null) {
tt = document.createElement('div');
tt.setAttribute('id', id);
document.body.appendChild(tt);
tt.style.opacity = 0;
tt.style.filter = 'alpha(opacity=0)';
document.onmousemove = this.pos;
}
tt.style.display = 'block';
tt.innerHTML = v in tooltip.annotation_list ? tooltip.annotation_list[v] : '?';
tt.style.width = w ? w + 'px' : 'auto';
if(!w && ie){
tt.style.width = tt.offsetWidth;
}
if(tt.offsetWidth > maxw){
tt.style.width = maxw + 'px';
}
h = parseInt(tt.offsetHeight, 10) + top;
clearInterval(tt.timer);
tooltip.instantshow(true);
// tt.timer = setInterval(function(){tooltip.fade(1);}, timer);
},
pos:function(e) {
var u = ie ? event.clientY + document.documentElement.scrollTop : e.pageY,
l = ie ? event.clientX + document.documentElement.scrollLeft : e.pageX;
tt.style.top = (u - h) + 'px';
tt.style.left = (l + left) + 'px';
},
instantshow: function(show) {
if (show === true) {
tt.style.opacity = endalpha * 0.01;
tt.style.filter = 'alpha(opacity=' + endalpha + ')';
} else {
tt.style.display = 'none';
}
},
fade:function(d) {
var a = alpha, i;
if((a != endalpha && d == 1) || (a !== 0 && d == -1)){
i = speed;
if(endalpha - a < speed && d == 1){
i = endalpha - a;
}else if(alpha < speed && d == -1){
i = a;
}
alpha = a + (i * d);
tt.style.opacity = alpha * 0.01;
tt.style.filter = 'alpha(opacity=' + alpha + ')';
}else{
clearInterval(tt.timer);
if(d == -1){
tt.style.display = 'none';
}
}
},
hide:function() {
clearInterval(tt.timer);
tooltip.instantshow(false);
// tt.timer = setInterval(function(){tooltip.fade(-1);},timer);
}
};
}();
tooltip.init();

View File

@@ -0,0 +1,87 @@
/*jshint globalstrict: true*/
"use strict";
var page_line_info = {
wrap: false,
ranges: null,
wrap_size: null,
tables: null,
header: null,
gutter: false
};
function wrap_code() {
var start, end, i, j, mode, idx,
width = 0, el;
if (page_line_info.header) {
document.getElementById("file_info").style.width = page_line_info.wrap_size + "px";
}
for (i = 1; i <= page_line_info.tables; i++) {
idx = i - 1;
start = page_line_info.ranges[idx][0];
end = page_line_info.ranges[idx][1];
for(j = start; j < end; j++) {
if (mode == null) {
mode = true;
if (page_line_info.gutter) {
width = document.getElementById("L_" + idx + "_" + j).offsetWidth;
}
}
el = document.getElementById("C_" + idx + "_" + j);
el.style.width = (page_line_info.wrap_size - width) + "px";
el.className = "wrap";
}
}
}
function toggle_gutter() {
var i, j, mode, rows, r, tbls, cells;
tbls = document.getElementsByTagName('table');
for (i = 1; i <= page_line_info.tables; i++) {
rows = tbls[i].getElementsByTagName('tr');
r = rows.length;
for (j = 0; j < r; j++) {
cells = rows[j].getElementsByTagName('td');
if (mode == null) {
if (page_line_info.gutter) {
mode = 'none';
page_line_info.gutter = false;
} else {
mode = 'table-cell';
page_line_info.gutter = true;
}
}
cells[0].style.display = mode;
}
}
if (page_line_info.wrap && mode != null) {
setTimeout(function() {wrap_code();}, 500);
}
}
function unwrap_code() {
var i, j, idx, start, end, el;
if (page_line_info.header) {
document.getElementById("file_info").style.width = "100%";
}
for (i = 1; i <= page_line_info.tables; i++) {
idx = i - 1;
start = page_line_info.ranges[idx][0];
end = page_line_info.ranges[idx][1];
for(j = start; j < end; j++) {
el = document.getElementById("C_" + idx + "_" + j);
el.style.width = "100%";
el.className = "";
}
}
}
function toggle_wrapping() {
if (page_line_info.wrap) {
page_line_info.wrap = false;
unwrap_code();
} else {
page_line_info.wrap = true;
wrap_code();
}
}

View File

@@ -0,0 +1,39 @@
/*jshint globalstrict: true*/
"use strict";
var plain_text_clone = null;
function toggle_plain_text() {
var lines = document.querySelectorAll("td.code_line"),
line_len = lines.length,
text = "",
plain_pre = document.querySelectorAll("pre.simple_code_page"),
orig_pre, pre, i, j, spans, span_len, span;
if (plain_pre.length > 0) {
document.body.removeChild(plain_pre[0]);
document.body.appendChild(plain_text_clone);
document.body.className = "code_page";
} else {
for (i = 0; i < line_len; i++) {
spans = lines[i].querySelectorAll("span.real_text");
span_len = spans.length;
for (j = 0; j < span_len; j++) {
span = spans[j];
if ("textContent" in span) {
text += span.textContent;
} else {
text += span.innerText;
}
}
text += "\n";
}
orig_pre = document.querySelectorAll("pre.code_page")[0];
plain_text_clone = orig_pre.cloneNode(true);
pre = document.createElement('pre');
pre.className = "simple_code_page";
pre.appendChild(document.createTextNode(text));
document.body.removeChild(orig_pre);
document.body.appendChild(pre);
document.body.className = "simple_code_page";
}
}

View File

@@ -0,0 +1,129 @@
/*jshint globalstrict: true*/
"use strict";
var plist = {
color_scheme: {},
content: "",
indentlevel: 0,
get: function(file_name) {
this.content = '<?xml version="1.0" encoding="UTF-8"?>\n' +
'<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">\n' +
'<plist version="1.0">\n' +
'<!-- ' + file_name + ' -->\n';
this.parsedict(this.color_scheme);
this.content += '</plist>\n';
return this.content;
},
isinstance: function(obj, s) {
return ({}).toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase() === s;
},
sortkeys: function(obj) {
var sorted = {},
keys = [],
key;
for (key in obj) {
if (obj.hasOwnProperty(key)) {
keys.push(key);
}
}
keys.sort();
return keys;
},
indent: function() {
var i;
for (i = 0; i < this.indentlevel; i++) {
this.content += " ";
}
},
parsekey: function(k) {
this.indent();
this.content += '<key>' + k + '</key>\n';
},
parseitem: function(obj) {
if (this.isinstance(obj, "string")) {
this.parsestring(obj);
} else if (this.isinstance(obj, "array")) {
this.parsearray(obj);
} else if (this.isinstance(obj, "object")) {
this.parsedict(obj);
}
},
parsearray: function(obj) {
var i, len = obj.length;
this.indent();
this.content += '<array>\n';
this.indentlevel++;
for (i = 0; i < len; i++) {
this.parseitem(obj[i]);
}
this.indentlevel--;
this.indent();
this.content += '</array>\n';
},
parsestring: function(s) {
this.indent();
this.content += '<string>' + s + '</string>\n';
},
parsedict: function(obj) {
var keys = this.sortkeys(obj),
len = keys.length,
k, i;
this.indent();
this.content += '<dict>\n';
this.indentlevel++;
for (i = 0; i < len; i++)
{
k = keys[i];
this.parsekey(k);
this.parseitem(obj[k]);
}
this.indentlevel--;
this.indent();
this.content += '</dict>\n';
}
},
escape_html = {
safe_chars: {
"&": "&amp;",
"<": "&lt;",
">": "&gt;",
'"': '&quot;',
"'": '&#39;',
"/": '&#x2F;'
},
escape: function (s) {
return String(s).replace(/[&<>"'\/]/g, function (c) {return escape_html.safe_chars[c];});
}
};
function extract_theme(name) {
var text, wnd, doc,
a = document.createElement('a');
window.URL = window.URL || window.webkitURL;
if (window.Blob != null && a.download != null) {
text = new Blob([plist.get(name)], {'type':'application/octet-stream'});
a.href = window.URL.createObjectURL(text);
a.download = name;
a.click();
} else {
text = '<pre>' + escape_html.escape(plist.get(name)) + '</pre>',
wnd = window.open('', '_blank', "status=1,toolbar=0,scrollbars=1"),
doc = wnd.document;
doc.write(text);
doc.close();
wnd.focus();
}
}

View File

@@ -0,0 +1,15 @@
/*jshint globalstrict: true*/
"use strict";
function page_print() {
var element = document.getElementById("toolbarhide");
if (element != null) {
element.style.display = "none";
}
if (window.print) {
window.print();
}
if (element != null) {
element.style.display = "block";
}
}