diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2011-12-03 13:29:22 +0100 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2011-12-03 13:29:22 +0100 |
commit | ca32f08966f1b51fcb19460f0996bb0c4048e6fe (patch) | |
tree | ec04cc15b867bc21eedca904cea9af0254531a11 /extensions/WikiEditor/modules/jquery.wikiEditor.templates.js | |
parent | a22fbfc60f36f5f7ee10d5ae6fe347340c2ee67c (diff) |
Update to MediaWiki 1.18.0
* also update ArchLinux skin to chagnes in MonoBook
* Use only css to hide our menu bar when printing
Diffstat (limited to 'extensions/WikiEditor/modules/jquery.wikiEditor.templates.js')
-rw-r--r-- | extensions/WikiEditor/modules/jquery.wikiEditor.templates.js | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/extensions/WikiEditor/modules/jquery.wikiEditor.templates.js b/extensions/WikiEditor/modules/jquery.wikiEditor.templates.js new file mode 100644 index 00000000..b303e3fa --- /dev/null +++ b/extensions/WikiEditor/modules/jquery.wikiEditor.templates.js @@ -0,0 +1,69 @@ +/* Templates Module for wikiEditor */ +( function( $ ) { $.wikiEditor.modules.templates = { + +/** + * Core Requirements + */ +'req': [ 'iframe' ], +/** + * Object Templates + */ +'tpl': { + 'marker': { + 'type': 'template', + 'anchor': 'wrap', + 'skipDivision': 'realchange', + 'afterWrap': function( node ) { + $( node ).addClass( 'wikiEditor-template' ); + }, + 'getAnchor': function( ca1, ca2 ) { + return $( ca1.parentNode ).is( '.wikiEditor-template' ) ? ca1.parentNode : null; + } + } +}, +/** + * Event handlers + */ +'evt': { + 'mark': function( context, event ) { + // The markers returned by this function are skipped on realchange, so don't regenerate them in that case + if ( context.modules.highlight.currentScope == 'realchange' ) { + return; + } + // Get references to the markers and tokens from the current context + var markers = context.modules.highlight.markers; + var tokens = context.modules.highlight.tokenArray; + // 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 ) { + // Top-level opening - use offset as start + start = tokens[i].offset; + } 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 }, + $.wikiEditor.modules.templates.tpl.marker + ); + } + if ( depth < 0 ) { + depth = 0; + } + } + } +}, +'exp': [ + { 'regex': /{{/, 'label': "TEMPLATE_BEGIN" }, + { 'regex': /}}/, 'label': "TEMPLATE_END", 'markAfter': true } +], +/** + * Internally used functions + */ +'fn': { + 'create': function( context, config ) { + // Do some stuff here... + } +} + +}; } ) ( jQuery ); |