@@ -0,0 +1,70 @@
|
||||
.twitter-typeahead .tt-query,
|
||||
.twitter-typeahead .tt-hint {
|
||||
margin-bottom: 0px;
|
||||
margin-top: 0px;
|
||||
font-size: 13px;
|
||||
padding-left: 14px;
|
||||
padding-right: 14px;
|
||||
-webkit-border-radius: 15px;
|
||||
-moz-border-radius: 15px;
|
||||
border-radius: 15px;
|
||||
width: 100%;
|
||||
min-height: 30px;
|
||||
display: block;
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.twitter-typeahead .tt-query:focus,
|
||||
.twitter-typeahead .tt-hint:focus {
|
||||
background-color: #fff ! important;
|
||||
}
|
||||
.navbar .search-query, .navbar .tt-hint {
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
.tt-dropdown-menu {
|
||||
width: 100%;
|
||||
margin-top: 2px;
|
||||
padding: 5px 0;
|
||||
background-color: #fff;
|
||||
border: 1px solid #ccc;
|
||||
border: 1px solid rgba(0,0,0,.2);
|
||||
*border-right-width: 2px;
|
||||
*border-bottom-width: 2px;
|
||||
-webkit-border-radius: 6px;
|
||||
-moz-border-radius: 6px;
|
||||
border-radius: 6px;
|
||||
-webkit-box-shadow: 0 5px 10px rgba(0,0,0,.2);
|
||||
-moz-box-shadow: 0 5px 10px rgba(0,0,0,.2);
|
||||
box-shadow: 0 5px 10px rgba(0,0,0,.2);
|
||||
-webkit-background-clip: padding-box;
|
||||
-moz-background-clip: padding;
|
||||
background-clip: padding-box;
|
||||
}
|
||||
|
||||
.tt-suggestion {
|
||||
display: block;
|
||||
padding: 3px 20px;
|
||||
}
|
||||
|
||||
.tt-suggestion.tt-is-under-cursor {
|
||||
color: #fff;
|
||||
background-color: #0081c2;
|
||||
background-image: -moz-linear-gradient(top, #0088cc, #0077b3);
|
||||
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0077b3));
|
||||
background-image: -webkit-linear-gradient(top, #0088cc, #0077b3);
|
||||
background-image: -o-linear-gradient(top, #0088cc, #0077b3);
|
||||
background-image: linear-gradient(to bottom, #0088cc, #0077b3);
|
||||
background-repeat: repeat-x;
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc', endColorstr='#ff0077b3', GradientType=0)
|
||||
}
|
||||
|
||||
.tt-suggestion.tt-is-under-cursor a {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.tt-suggestion p {
|
||||
margin: 0;
|
||||
}
|
||||
@@ -66,9 +66,8 @@ function doClickSave() {
|
||||
'doClickSave');
|
||||
},
|
||||
success: function(json,text,xhr){
|
||||
|
||||
|
||||
|
||||
jQuery(editor).data('saved', true); // Set as saved
|
||||
editor.on("change", store_changes_function); // Re-enable change watcher
|
||||
// reenable disabled submit button
|
||||
var t=jQuery("input[name='save']");
|
||||
t.attr('class','');
|
||||
@@ -248,3 +247,16 @@ function load_file (url) {
|
||||
error: function(x) { on_error(); }
|
||||
});
|
||||
}
|
||||
|
||||
function set_font(editor, incr) {
|
||||
var fontSize = '';
|
||||
if (incr !== 0) {
|
||||
fontSize = parseInt(jQuery(editor.getWrapperElement()).css('font-size'));
|
||||
fontSize = fontSize + incr + "px";
|
||||
}
|
||||
jQuery(editor.getWrapperElement()).css('font-size', fontSize);
|
||||
editor.refresh();
|
||||
}
|
||||
|
||||
var template_js = '<p class="repo-name">{{{a_tag}}}</p><small>{{address}}</small>';
|
||||
|
||||
|
||||
@@ -0,0 +1,576 @@
|
||||
/*
|
||||
* Copyright 2011 Twitter, Inc.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
var Hogan = {};
|
||||
|
||||
(function (Hogan, useArrayBuffer) {
|
||||
Hogan.Template = function (renderFunc, text, compiler, options) {
|
||||
this.r = renderFunc || this.r;
|
||||
this.c = compiler;
|
||||
this.options = options;
|
||||
this.text = text || '';
|
||||
this.buf = (useArrayBuffer) ? [] : '';
|
||||
}
|
||||
|
||||
Hogan.Template.prototype = {
|
||||
// render: replaced by generated code.
|
||||
r: function (context, partials, indent) { return ''; },
|
||||
|
||||
// variable escaping
|
||||
v: hoganEscape,
|
||||
|
||||
// triple stache
|
||||
t: coerceToString,
|
||||
|
||||
render: function render(context, partials, indent) {
|
||||
return this.ri([context], partials || {}, indent);
|
||||
},
|
||||
|
||||
// render internal -- a hook for overrides that catches partials too
|
||||
ri: function (context, partials, indent) {
|
||||
return this.r(context, partials, indent);
|
||||
},
|
||||
|
||||
// tries to find a partial in the curent scope and render it
|
||||
rp: function(name, context, partials, indent) {
|
||||
var partial = partials[name];
|
||||
|
||||
if (!partial) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (this.c && typeof partial == 'string') {
|
||||
partial = this.c.compile(partial, this.options);
|
||||
}
|
||||
|
||||
return partial.ri(context, partials, indent);
|
||||
},
|
||||
|
||||
// render a section
|
||||
rs: function(context, partials, section) {
|
||||
var tail = context[context.length - 1];
|
||||
|
||||
if (!isArray(tail)) {
|
||||
section(context, partials, this);
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0; i < tail.length; i++) {
|
||||
context.push(tail[i]);
|
||||
section(context, partials, this);
|
||||
context.pop();
|
||||
}
|
||||
},
|
||||
|
||||
// maybe start a section
|
||||
s: function(val, ctx, partials, inverted, start, end, tags) {
|
||||
var pass;
|
||||
|
||||
if (isArray(val) && val.length === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (typeof val == 'function') {
|
||||
val = this.ls(val, ctx, partials, inverted, start, end, tags);
|
||||
}
|
||||
|
||||
pass = (val === '') || !!val;
|
||||
|
||||
if (!inverted && pass && ctx) {
|
||||
ctx.push((typeof val == 'object') ? val : ctx[ctx.length - 1]);
|
||||
}
|
||||
|
||||
return pass;
|
||||
},
|
||||
|
||||
// find values with dotted names
|
||||
d: function(key, ctx, partials, returnFound) {
|
||||
var names = key.split('.'),
|
||||
val = this.f(names[0], ctx, partials, returnFound),
|
||||
cx = null;
|
||||
|
||||
if (key === '.' && isArray(ctx[ctx.length - 2])) {
|
||||
return ctx[ctx.length - 1];
|
||||
}
|
||||
|
||||
for (var i = 1; i < names.length; i++) {
|
||||
if (val && typeof val == 'object' && names[i] in val) {
|
||||
cx = val;
|
||||
val = val[names[i]];
|
||||
} else {
|
||||
val = '';
|
||||
}
|
||||
}
|
||||
|
||||
if (returnFound && !val) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!returnFound && typeof val == 'function') {
|
||||
ctx.push(cx);
|
||||
val = this.lv(val, ctx, partials);
|
||||
ctx.pop();
|
||||
}
|
||||
|
||||
return val;
|
||||
},
|
||||
|
||||
// find values with normal names
|
||||
f: function(key, ctx, partials, returnFound) {
|
||||
var val = false,
|
||||
v = null,
|
||||
found = false;
|
||||
|
||||
for (var i = ctx.length - 1; i >= 0; i--) {
|
||||
v = ctx[i];
|
||||
if (v && typeof v == 'object' && key in v) {
|
||||
val = v[key];
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
return (returnFound) ? false : "";
|
||||
}
|
||||
|
||||
if (!returnFound && typeof val == 'function') {
|
||||
val = this.lv(val, ctx, partials);
|
||||
}
|
||||
|
||||
return val;
|
||||
},
|
||||
|
||||
// higher order templates
|
||||
ho: function(val, cx, partials, text, tags) {
|
||||
var compiler = this.c;
|
||||
var options = this.options;
|
||||
options.delimiters = tags;
|
||||
var text = val.call(cx, text);
|
||||
text = (text == null) ? String(text) : text.toString();
|
||||
this.b(compiler.compile(text, options).render(cx, partials));
|
||||
return false;
|
||||
},
|
||||
|
||||
// template result buffering
|
||||
b: (useArrayBuffer) ? function(s) { this.buf.push(s); } :
|
||||
function(s) { this.buf += s; },
|
||||
fl: (useArrayBuffer) ? function() { var r = this.buf.join(''); this.buf = []; return r; } :
|
||||
function() { var r = this.buf; this.buf = ''; return r; },
|
||||
|
||||
// lambda replace section
|
||||
ls: function(val, ctx, partials, inverted, start, end, tags) {
|
||||
var cx = ctx[ctx.length - 1],
|
||||
t = null;
|
||||
|
||||
if (!inverted && this.c && val.length > 0) {
|
||||
return this.ho(val, cx, partials, this.text.substring(start, end), tags);
|
||||
}
|
||||
|
||||
t = val.call(cx);
|
||||
|
||||
if (typeof t == 'function') {
|
||||
if (inverted) {
|
||||
return true;
|
||||
} else if (this.c) {
|
||||
return this.ho(t, cx, partials, this.text.substring(start, end), tags);
|
||||
}
|
||||
}
|
||||
|
||||
return t;
|
||||
},
|
||||
|
||||
// lambda replace variable
|
||||
lv: function(val, ctx, partials) {
|
||||
var cx = ctx[ctx.length - 1];
|
||||
var result = val.call(cx);
|
||||
|
||||
if (typeof result == 'function') {
|
||||
result = coerceToString(result.call(cx));
|
||||
if (this.c && ~result.indexOf("{\u007B")) {
|
||||
return this.c.compile(result, this.options).render(cx, partials);
|
||||
}
|
||||
}
|
||||
|
||||
return coerceToString(result);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
var rAmp = /&/g,
|
||||
rLt = /</g,
|
||||
rGt = />/g,
|
||||
rApos =/\'/g,
|
||||
rQuot = /\"/g,
|
||||
hChars =/[&<>\"\']/;
|
||||
|
||||
|
||||
function coerceToString(val) {
|
||||
return String((val === null || val === undefined) ? '' : val);
|
||||
}
|
||||
|
||||
function hoganEscape(str) {
|
||||
str = coerceToString(str);
|
||||
return hChars.test(str) ?
|
||||
str
|
||||
.replace(rAmp,'&')
|
||||
.replace(rLt,'<')
|
||||
.replace(rGt,'>')
|
||||
.replace(rApos,''')
|
||||
.replace(rQuot, '"') :
|
||||
str;
|
||||
}
|
||||
|
||||
var isArray = Array.isArray || function(a) {
|
||||
return Object.prototype.toString.call(a) === '[object Array]';
|
||||
};
|
||||
|
||||
})(typeof exports !== 'undefined' ? exports : Hogan);
|
||||
|
||||
|
||||
|
||||
|
||||
(function (Hogan) {
|
||||
// Setup regex assignments
|
||||
// remove whitespace according to Mustache spec
|
||||
var rIsWhitespace = /\S/,
|
||||
rQuot = /\"/g,
|
||||
rNewline = /\n/g,
|
||||
rCr = /\r/g,
|
||||
rSlash = /\\/g,
|
||||
tagTypes = {
|
||||
'#': 1, '^': 2, '/': 3, '!': 4, '>': 5,
|
||||
'<': 6, '=': 7, '_v': 8, '{': 9, '&': 10
|
||||
};
|
||||
|
||||
Hogan.scan = function scan(text, delimiters) {
|
||||
var len = text.length,
|
||||
IN_TEXT = 0,
|
||||
IN_TAG_TYPE = 1,
|
||||
IN_TAG = 2,
|
||||
state = IN_TEXT,
|
||||
tagType = null,
|
||||
tag = null,
|
||||
buf = '',
|
||||
tokens = [],
|
||||
seenTag = false,
|
||||
i = 0,
|
||||
lineStart = 0,
|
||||
otag = '{{',
|
||||
ctag = '}}';
|
||||
|
||||
function addBuf() {
|
||||
if (buf.length > 0) {
|
||||
tokens.push(new String(buf));
|
||||
buf = '';
|
||||
}
|
||||
}
|
||||
|
||||
function lineIsWhitespace() {
|
||||
var isAllWhitespace = true;
|
||||
for (var j = lineStart; j < tokens.length; j++) {
|
||||
isAllWhitespace =
|
||||
(tokens[j].tag && tagTypes[tokens[j].tag] < tagTypes['_v']) ||
|
||||
(!tokens[j].tag && tokens[j].match(rIsWhitespace) === null);
|
||||
if (!isAllWhitespace) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return isAllWhitespace;
|
||||
}
|
||||
|
||||
function filterLine(haveSeenTag, noNewLine) {
|
||||
addBuf();
|
||||
|
||||
if (haveSeenTag && lineIsWhitespace()) {
|
||||
for (var j = lineStart, next; j < tokens.length; j++) {
|
||||
if (!tokens[j].tag) {
|
||||
if ((next = tokens[j+1]) && next.tag == '>') {
|
||||
// set indent to token value
|
||||
next.indent = tokens[j].toString()
|
||||
}
|
||||
tokens.splice(j, 1);
|
||||
}
|
||||
}
|
||||
} else if (!noNewLine) {
|
||||
tokens.push({tag:'\n'});
|
||||
}
|
||||
|
||||
seenTag = false;
|
||||
lineStart = tokens.length;
|
||||
}
|
||||
|
||||
function changeDelimiters(text, index) {
|
||||
var close = '=' + ctag,
|
||||
closeIndex = text.indexOf(close, index),
|
||||
delimiters = trim(
|
||||
text.substring(text.indexOf('=', index) + 1, closeIndex)
|
||||
).split(' ');
|
||||
|
||||
otag = delimiters[0];
|
||||
ctag = delimiters[1];
|
||||
|
||||
return closeIndex + close.length - 1;
|
||||
}
|
||||
|
||||
if (delimiters) {
|
||||
delimiters = delimiters.split(' ');
|
||||
otag = delimiters[0];
|
||||
ctag = delimiters[1];
|
||||
}
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
if (state == IN_TEXT) {
|
||||
if (tagChange(otag, text, i)) {
|
||||
--i;
|
||||
addBuf();
|
||||
state = IN_TAG_TYPE;
|
||||
} else {
|
||||
if (text.charAt(i) == '\n') {
|
||||
filterLine(seenTag);
|
||||
} else {
|
||||
buf += text.charAt(i);
|
||||
}
|
||||
}
|
||||
} else if (state == IN_TAG_TYPE) {
|
||||
i += otag.length - 1;
|
||||
tag = tagTypes[text.charAt(i + 1)];
|
||||
tagType = tag ? text.charAt(i + 1) : '_v';
|
||||
if (tagType == '=') {
|
||||
i = changeDelimiters(text, i);
|
||||
state = IN_TEXT;
|
||||
} else {
|
||||
if (tag) {
|
||||
i++;
|
||||
}
|
||||
state = IN_TAG;
|
||||
}
|
||||
seenTag = i;
|
||||
} else {
|
||||
if (tagChange(ctag, text, i)) {
|
||||
tokens.push({tag: tagType, n: trim(buf), otag: otag, ctag: ctag,
|
||||
i: (tagType == '/') ? seenTag - ctag.length : i + otag.length});
|
||||
buf = '';
|
||||
i += ctag.length - 1;
|
||||
state = IN_TEXT;
|
||||
if (tagType == '{') {
|
||||
if (ctag == '}}') {
|
||||
i++;
|
||||
} else {
|
||||
cleanTripleStache(tokens[tokens.length - 1]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
buf += text.charAt(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
filterLine(seenTag, true);
|
||||
|
||||
return tokens;
|
||||
}
|
||||
|
||||
function cleanTripleStache(token) {
|
||||
if (token.n.substr(token.n.length - 1) === '}') {
|
||||
token.n = token.n.substring(0, token.n.length - 1);
|
||||
}
|
||||
}
|
||||
|
||||
function trim(s) {
|
||||
if (s.trim) {
|
||||
return s.trim();
|
||||
}
|
||||
|
||||
return s.replace(/^\s*|\s*$/g, '');
|
||||
}
|
||||
|
||||
function tagChange(tag, text, index) {
|
||||
if (text.charAt(index) != tag.charAt(0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (var i = 1, l = tag.length; i < l; i++) {
|
||||
if (text.charAt(index + i) != tag.charAt(i)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function buildTree(tokens, kind, stack, customTags) {
|
||||
var instructions = [],
|
||||
opener = null,
|
||||
token = null;
|
||||
|
||||
while (tokens.length > 0) {
|
||||
token = tokens.shift();
|
||||
if (token.tag == '#' || token.tag == '^' || isOpener(token, customTags)) {
|
||||
stack.push(token);
|
||||
token.nodes = buildTree(tokens, token.tag, stack, customTags);
|
||||
instructions.push(token);
|
||||
} else if (token.tag == '/') {
|
||||
if (stack.length === 0) {
|
||||
throw new Error('Closing tag without opener: /' + token.n);
|
||||
}
|
||||
opener = stack.pop();
|
||||
if (token.n != opener.n && !isCloser(token.n, opener.n, customTags)) {
|
||||
throw new Error('Nesting error: ' + opener.n + ' vs. ' + token.n);
|
||||
}
|
||||
opener.end = token.i;
|
||||
return instructions;
|
||||
} else {
|
||||
instructions.push(token);
|
||||
}
|
||||
}
|
||||
|
||||
if (stack.length > 0) {
|
||||
throw new Error('missing closing tag: ' + stack.pop().n);
|
||||
}
|
||||
|
||||
return instructions;
|
||||
}
|
||||
|
||||
function isOpener(token, tags) {
|
||||
for (var i = 0, l = tags.length; i < l; i++) {
|
||||
if (tags[i].o == token.n) {
|
||||
token.tag = '#';
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function isCloser(close, open, tags) {
|
||||
for (var i = 0, l = tags.length; i < l; i++) {
|
||||
if (tags[i].c == close && tags[i].o == open) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Hogan.generate = function (tree, text, options) {
|
||||
var code = 'var _=this;_.b(i=i||"");' + walk(tree) + 'return _.fl();';
|
||||
if (options.asString) {
|
||||
return 'function(c,p,i){' + code + ';}';
|
||||
}
|
||||
|
||||
return new Hogan.Template(new Function('c', 'p', 'i', code), text, Hogan, options);
|
||||
}
|
||||
|
||||
function esc(s) {
|
||||
return s.replace(rSlash, '\\\\')
|
||||
.replace(rQuot, '\\\"')
|
||||
.replace(rNewline, '\\n')
|
||||
.replace(rCr, '\\r');
|
||||
}
|
||||
|
||||
function chooseMethod(s) {
|
||||
return (~s.indexOf('.')) ? 'd' : 'f';
|
||||
}
|
||||
|
||||
function walk(tree) {
|
||||
var code = '';
|
||||
for (var i = 0, l = tree.length; i < l; i++) {
|
||||
var tag = tree[i].tag;
|
||||
if (tag == '#') {
|
||||
code += section(tree[i].nodes, tree[i].n, chooseMethod(tree[i].n),
|
||||
tree[i].i, tree[i].end, tree[i].otag + " " + tree[i].ctag);
|
||||
} else if (tag == '^') {
|
||||
code += invertedSection(tree[i].nodes, tree[i].n,
|
||||
chooseMethod(tree[i].n));
|
||||
} else if (tag == '<' || tag == '>') {
|
||||
code += partial(tree[i]);
|
||||
} else if (tag == '{' || tag == '&') {
|
||||
code += tripleStache(tree[i].n, chooseMethod(tree[i].n));
|
||||
} else if (tag == '\n') {
|
||||
code += text('"\\n"' + (tree.length-1 == i ? '' : ' + i'));
|
||||
} else if (tag == '_v') {
|
||||
code += variable(tree[i].n, chooseMethod(tree[i].n));
|
||||
} else if (tag === undefined) {
|
||||
code += text('"' + esc(tree[i]) + '"');
|
||||
}
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
function section(nodes, id, method, start, end, tags) {
|
||||
return 'if(_.s(_.' + method + '("' + esc(id) + '",c,p,1),' +
|
||||
'c,p,0,' + start + ',' + end + ',"' + tags + '")){' +
|
||||
'_.rs(c,p,' +
|
||||
'function(c,p,_){' +
|
||||
walk(nodes) +
|
||||
'});c.pop();}';
|
||||
}
|
||||
|
||||
function invertedSection(nodes, id, method) {
|
||||
return 'if(!_.s(_.' + method + '("' + esc(id) + '",c,p,1),c,p,1,0,0,"")){' +
|
||||
walk(nodes) +
|
||||
'};';
|
||||
}
|
||||
|
||||
function partial(tok) {
|
||||
return '_.b(_.rp("' + esc(tok.n) + '",c,p,"' + (tok.indent || '') + '"));';
|
||||
}
|
||||
|
||||
function tripleStache(id, method) {
|
||||
return '_.b(_.t(_.' + method + '("' + esc(id) + '",c,p,0)));';
|
||||
}
|
||||
|
||||
function variable(id, method) {
|
||||
return '_.b(_.v(_.' + method + '("' + esc(id) + '",c,p,0)));';
|
||||
}
|
||||
|
||||
function text(id) {
|
||||
return '_.b(' + id + ');';
|
||||
}
|
||||
|
||||
Hogan.parse = function(tokens, text, options) {
|
||||
options = options || {};
|
||||
return buildTree(tokens, '', [], options.sectionTags || []);
|
||||
},
|
||||
|
||||
Hogan.cache = {};
|
||||
|
||||
Hogan.compile = function(text, options) {
|
||||
// options
|
||||
//
|
||||
// asString: false (default)
|
||||
//
|
||||
// sectionTags: [{o: '_foo', c: 'foo'}]
|
||||
// An array of object with o and c fields that indicate names for custom
|
||||
// section tags. The example above allows parsing of {{_foo}}{{/foo}}.
|
||||
//
|
||||
// delimiters: A string that overrides the default delimiters.
|
||||
// Example: "<% %>"
|
||||
//
|
||||
options = options || {};
|
||||
|
||||
var key = text + '||' + !!options.asString;
|
||||
|
||||
var t = this.cache[key];
|
||||
|
||||
if (t) {
|
||||
return t;
|
||||
}
|
||||
|
||||
t = this.generate(this.parse(this.scan(text, options.delimiters), text, options), text, options);
|
||||
return this.cache[key] = t;
|
||||
};
|
||||
})(typeof exports !== 'undefined' ? exports : Hogan);
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -37,10 +37,11 @@
|
||||
<link rel="stylesheet" href="{{=cm}}/addon/dialog/dialog.css">
|
||||
<script src="{{=cm}}/addon/selection/active-line.js"></script>
|
||||
<script src="{{=cm}}/emmet.min.js"></script>
|
||||
|
||||
<script language="Javascript" type="text/javascript" src="{{=URL('static','js/ajax_editor.js')}}"></script>
|
||||
<link rel="stylesheet" href="{{=URL('static/css','typeahead.js-bootstrap.css')}}">
|
||||
<script language="Javascript" type="text/javascript">
|
||||
var current_theme = "web2py"; //Default theme
|
||||
var current_font_incr = 0; // Default font-size, 0 means don't set
|
||||
jQuery(document).on('shown click', 'a[data-toggle="tab"]', function (e) {
|
||||
var tab_id = jQuery(this).attr('href');
|
||||
var editor = jQuery(tab_id + " textarea").data('editor');
|
||||
@@ -55,12 +56,18 @@ jQuery(document).on('shown click', 'a[data-toggle="tab"]', function (e) {
|
||||
jQuery(document).on('click', '#filesTab button[class="close"]', function (e) {
|
||||
var tab_body = jQuery(jQuery(this).parent().attr("href")); // it should be a div
|
||||
var tab_header = jQuery(this).parent().parent(); // it should be a li
|
||||
|
||||
if (tab_header.hasClass('active') === true) { //Set active an other tab
|
||||
jQuery(tab_header).prev().children('a[data-toggle="tab"]').tab('show'); // Select first tab
|
||||
var saved = jQuery(tab_body.find('textarea').data('editor')).data('saved');
|
||||
var close = true;
|
||||
if (saved === false) {
|
||||
close = confirm("You are closing an unsaved file")
|
||||
}
|
||||
if (close) {
|
||||
if (tab_header.hasClass('active') === true) { //Set active an other tab
|
||||
jQuery(tab_header).prev().children('a[data-toggle="tab"]').tab('show'); // Select first tab
|
||||
}
|
||||
tab_header.remove(); //remove li of tab
|
||||
tab_body.remove(); //remove li of tab
|
||||
}
|
||||
tab_header.remove(); //remove li of tab
|
||||
tab_body.remove(); //remove li of tab
|
||||
});
|
||||
|
||||
// Revert current file
|
||||
@@ -102,6 +109,22 @@ jQuery(document).on('click', '#themes a', function (e) {
|
||||
//#TODO save on session
|
||||
});
|
||||
|
||||
// incr/decr editor font-size
|
||||
jQuery(document).on('click', 'a.font_button', function (e) {
|
||||
e.preventDefault();
|
||||
var id = jQuery(this).attr('id');
|
||||
var new_font_incr;
|
||||
switch (id) {
|
||||
case 'incr': new_incr = 2; break;
|
||||
case 'decr': new_incr = -2; break;
|
||||
case 'default': new_incr = 0; break;
|
||||
}
|
||||
jQuery('textarea[name="data"]') .each(function(id, ta) {
|
||||
editor = jQuery(ta).data('editor');
|
||||
set_font(editor, new_incr);
|
||||
});
|
||||
current_font_incr = (new_incr !== 0) ? current_font_incr + new_incr : 0;
|
||||
});
|
||||
function isFullScreen(instance) {
|
||||
return /\bCodeMirror-fullscreen\b/.test(instance.getWrapperElement().className);
|
||||
}
|
||||
@@ -130,6 +153,7 @@ jQuery(document).on('click', '#themes a', function (e) {
|
||||
{{if len(request.args) > 1:}}
|
||||
load_file('{{=URL(f='edit', args=request.args, vars=request.get_vars)}}');
|
||||
{{pass}}
|
||||
|
||||
</script>
|
||||
|
||||
{{block sectionclass}}edit{{end}}
|
||||
@@ -145,6 +169,11 @@ jQuery(document).on('click', '#themes a', function (e) {
|
||||
{{pass}}
|
||||
</ul>
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
<a id="decr" class="button btn font_button">-</a>
|
||||
<a id="default" class="button btn font_button" >A</a>
|
||||
<a id="incr" class="button btn font_button">+</a>
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
{{=button(URL('design',args=request.vars.app if request.vars.app else request.args[0], anchor=request.vars.id), T('back'))}}
|
||||
{{#if request.args[1]=='models':}}
|
||||
@@ -156,11 +185,13 @@ jQuery(document).on('click', '#themes a', function (e) {
|
||||
</div>
|
||||
<div id="editor_area" class="row-fluid">
|
||||
<ul class="nav nav-list span2 well" rel="pagebookmark" id="filelist">
|
||||
<li><input type="text" placeholder="{{=T('Rapid Search')}}" class="input-block-level typeahead-tw search-query"></li>
|
||||
{{dirs=[{'name':'models', 'reg':'.*\.py$'},
|
||||
{'name':'controllers', 'reg':'.*\.py$'},
|
||||
{'name':'views', 'reg':'[\w/\-]+(\.\w+)+$'},
|
||||
{'name':'modules', 'reg':'.*\.py$'},
|
||||
{'name':'private', 'reg': '[^\.#].*'}]}}
|
||||
{{auto_complete_list=[]}}
|
||||
{{for dir in dirs:}}
|
||||
<li class="nav-header component" onclick="collapse('{{="%s_files" % dir['name']}}');">{{=dir['name']}}</li>
|
||||
<li id="{{="%s_files" % dir['name']}}">
|
||||
@@ -169,7 +200,9 @@ jQuery(document).on('click', '#themes a', function (e) {
|
||||
{{id="%s__" % dir['name'] + f.replace('.','__')}}
|
||||
{{current_file = request.args(len(request.args) - 1)}}
|
||||
<li class="{{#='active' if current_file==f else ''}}">
|
||||
{{=editfile(dir['name'], f, dict(id=id))}}
|
||||
{{a_tag=editfile(dir['name'], f, dict(id=id))}}
|
||||
{{=a_tag}}
|
||||
{{auto_complete_list.append({'value':f, 'tokens':f.split('/'), 'a_tag':a_tag})}}
|
||||
</li>
|
||||
{{pass}}
|
||||
</ul>
|
||||
@@ -183,4 +216,19 @@ jQuery(document).on('click', '#themes a', function (e) {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Typeahead scripts here so the page load faster -->
|
||||
<script src="{{=URL('static/js', 'typeahead.min.js')}}"></script>
|
||||
<script src="{{=URL('static/js', 'hogan-2.0.0.js')}}"></script>
|
||||
<script>
|
||||
jQuery('.typeahead-tw').typeahead({
|
||||
name: 'files',
|
||||
local:{{from gluon.serializers import json}}{{=XML(json(auto_complete_list))}},
|
||||
template: template_js,
|
||||
engine: Hogan,
|
||||
});
|
||||
jQuery(document).on("typeahead:selected", '.typeahead', function(e, datum) {
|
||||
load_file(datum.link);
|
||||
jQuery(this).val('');
|
||||
});
|
||||
</script>
|
||||
<!-- end "edit" block -->
|
||||
|
||||
@@ -113,11 +113,16 @@
|
||||
CodeMirror.showHint(cm, CodeMirror.pythonHint);
|
||||
}
|
||||
{{pass}}
|
||||
store_changes_function = function(instance, changeObj) {
|
||||
jQuery(instance).data('saved', false);
|
||||
instance.off("change", store_changes_function);
|
||||
}
|
||||
editor.on("change", store_changes_function);
|
||||
// save the editor as textarea data attribute
|
||||
jQuery("#{{=id}} textarea").data('editor', editor);
|
||||
var hlLine = editor.addLineClass(0, "background", "activeline");
|
||||
window.mirror = editor; //backward compatibility
|
||||
|
||||
set_font(editor, current_font_incr);
|
||||
doListBreakpoints({{=XML("'%s','%s://%s%s'" % (filename,
|
||||
request.env['wsgi_url_scheme'], request.env['http_host'],
|
||||
URL(c='debug', f='list_breakpoints')))}}, editor);
|
||||
|
||||
Reference in New Issue
Block a user