+(function() {
+ var slice = Array.prototype.slice;
+
+ function update(array, args) {
+ var arrayLength = array.length, length = args.length;
+ while (length--) array[arrayLength + length] = args[length];
+ return array;
+ };
+
+ function merge(array, args) {
+ array = slice.call(array, 0);
+ return update(array, args);
+ };
+
+ Function.prototype.bind = function(context) {
+ if (arguments.length < 2 && typeof arguments[0] === 'undefined') {
+ return this;
+ }
+ var __method = this;
+ var args = slice.call(arguments, 1);
+ return function() {
+ var a = merge(args, arguments);
+ return __method.apply(context, a);
+ }
+ }
+
+})();
+
+
function ScriptletCenter()
{
this.scriptlets = {};
{
var text = this.XMLEditorSelectedText(context);
var start_tag = '<'+params.tag;
+ var move_cursor = false;
for (var attr in params.attrs) {
start_tag += ' '+attr+'="' + params.attrs[attr] + '"';
output += token;
}
else {
- output = start_tag + end_tag;
+ if(params.nocontent) {
+ output = "<"+params.tag +" />";
+ }
+ else {
+ output = start_tag + end_tag;
+ move_cursor = true;
+ }
}
this.XMLEditorReplaceSelectedText(context, output);
- if (text.length == 0) {
- this.XMLEditorMoveCursorForward(context, -params.tag.length-3);
- }
+ try {
+ if (move_cursor) {
+ this.XMLEditorMoveCursorForward(context, params.tag.length+2);
+ }
+ } catch(e) {}
+
}.bind(this);
this.scriptlets['lineregexp'] = function(context, params) {
}
}.bind(this);
- this.scriptlets['codemirror_fontsize'] = function(context, params) {
- var frameBody = this.XMLEditorBody(context);
-
- if(params.fontSize) {
- frameBody.css('font-size', params.fontSize);
- }
- else {
- var old_size = parseInt(frameBody.css('font-size'), 10);
- frameBody.css('font-size', old_size + (params.change || 0) );
- }
-
- }.bind(this);
-
this.scriptlets['fulltextregexp'] = function(context, params) {
var exprs = $.map(params.exprs, function(expr) {
var opts = "mg";
else if(ucase != text) repl = lcase; /* neither lower- or upper-case */
else { /* upper case -> camel-case */
var words = $(lcase.split(/\s/)).map(function() {
- if(this.length > 0) {
+ if(this.length > 0) {
return this[0].toUpperCase() + this.slice(1);
} else {
return '';
if (!text) {
this.XMLEditorMoveCursorForward(context, params.tag.length + 2);
}
-
+
}.bind(this);
}
ScriptletCenter.prototype.XMLEditorSelectedText = function(panel) {
- return panel.contentView.editor.selection();
+ return panel.selection();
};
ScriptletCenter.prototype.XMLEditorReplaceSelectedText = function(panel, replacement)
{
- panel.contentView.editor.replaceSelection(replacement);
+ panel.replaceSelection(replacement);
// Tell XML view that it's data has changed
- panel.contentView.editorDataChanged();
+ // panel.contentView.editorDataChanged();
};
ScriptletCenter.prototype.XMLEditorMoveCursorForward = function(panel, n) {
- var pos = panel.contentView.editor.cursorPosition();
- panel.contentView.editor.selectLines(pos.line, pos.character + n);
+ var pos = panel.cursorPosition();
+ panel.selectLines(pos.line, pos.character + n);
};
var scriptletCenter;