summaryrefslogtreecommitdiff
path: root/extensions/WikiEditor/modules/jquery.wikiEditor.templates.js
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/WikiEditor/modules/jquery.wikiEditor.templates.js')
-rw-r--r--extensions/WikiEditor/modules/jquery.wikiEditor.templates.js51
1 files changed, 30 insertions, 21 deletions
diff --git a/extensions/WikiEditor/modules/jquery.wikiEditor.templates.js b/extensions/WikiEditor/modules/jquery.wikiEditor.templates.js
index b303e3fa..b0462563 100644
--- a/extensions/WikiEditor/modules/jquery.wikiEditor.templates.js
+++ b/extensions/WikiEditor/modules/jquery.wikiEditor.templates.js
@@ -1,22 +1,23 @@
/* Templates Module for wikiEditor */
-( function( $ ) { $.wikiEditor.modules.templates = {
+/*jshint onevar:false */
+( function ( $ ) { $.wikiEditor.modules.templates = {
/**
* Core Requirements
*/
-'req': [ 'iframe' ],
+req: [ 'iframe' ],
/**
* Object Templates
*/
-'tpl': {
- 'marker': {
- 'type': 'template',
- 'anchor': 'wrap',
- 'skipDivision': 'realchange',
- 'afterWrap': function( node ) {
+tpl: {
+ marker: {
+ type: 'template',
+ anchor: 'wrap',
+ skipDivision: 'realchange',
+ afterWrap: function ( node ) {
$( node ).addClass( 'wikiEditor-template' );
},
- 'getAnchor': function( ca1, ca2 ) {
+ getAnchor: function ( ca1 ) {
return $( ca1.parentNode ).is( '.wikiEditor-template' ) ? ca1.parentNode : null;
}
}
@@ -24,10 +25,14 @@
/**
* Event handlers
*/
-'evt': {
- 'mark': function( context, event ) {
+evt: {
+ /**
+ * @param context
+ * @param event
+ */
+ mark: function ( context ) {
// The markers returned by this function are skipped on realchange, so don't regenerate them in that case
- if ( context.modules.highlight.currentScope == 'realchange' ) {
+ if ( context.modules.highlight.currentScope === 'realchange' ) {
return;
}
// Get references to the markers and tokens from the current context
@@ -36,14 +41,14 @@
// Use depth-tracking to extract top-level templates from tokens
var depth = 0, bias, start;
for ( var i in tokens ) {
- depth += ( bias = tokens[i].label == 'TEMPLATE_BEGIN' ? 1 : ( tokens[i].label == 'TEMPLATE_END' ? -1 : 0 ) );
- if ( bias > 0 && depth == 1 ) {
+ depth += ( bias = tokens[i].label === 'TEMPLATE_BEGIN' ? 1 : ( tokens[i].label === 'TEMPLATE_END' ? -1 : 0 ) );
+ if ( bias > 0 && depth === 1 ) {
// Top-level opening - use offset as start
start = tokens[i].offset;
- } else if ( bias < 0 && depth == 0 ) {
+ } else if ( bias < 0 && depth === 0 ) {
// Top-level closing - use offset as end
markers[markers.length] = $.extend(
- { 'context': context, 'start': start, 'end': tokens[i].offset },
+ { context: context, start: start, end: tokens[i].offset },
$.wikiEditor.modules.templates.tpl.marker
);
}
@@ -53,15 +58,19 @@
}
}
},
-'exp': [
- { 'regex': /{{/, 'label': "TEMPLATE_BEGIN" },
- { 'regex': /}}/, 'label': "TEMPLATE_END", 'markAfter': true }
+exp: [
+ { regex: /{{/, label: 'TEMPLATE_BEGIN' },
+ { regex: /}}/, label: 'TEMPLATE_END', markAfter: true }
],
/**
* Internally used functions
*/
-'fn': {
- 'create': function( context, config ) {
+fn: {
+ /**
+ * @param context
+ * @param config
+ */
+ create: function () {
// Do some stuff here...
}
}