Site for researching all meanings of Hebrew Bible.

Difference between revisions of "MediaWiki:Common.js"

From Without Vowels project
Jump to: navigation, search
Line 2: Line 2:
  
 
$(document).ready(function() {
 
$(document).ready(function() {
                $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
+
  $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
                        'section': 'main',
+
    'section': 'main',
                        'group': 'format',
+
    'group': 'format',
                        'tools': {
+
    'tools': {
                                'hebrew_link': {
+
      'hebrew_link': {
                                        label: 'Hebrew word with dictionary link',
+
label: 'Hebrew word with dictionary link',
                                        type: 'button',
+
type: 'button',
                                        icon: 'http://www.withoutvowels.org/w/images/9/95/Button_hebrew_word.png',
+
icon: 'http://www.withoutvowels.org/w/images/9/95/Button_hebrew_word.png',
                                        action: {
+
action: {
                                                type: 'callback',
+
  type: 'callback',
                                                execute: function(c) {
+
  execute: function(context) {
                                                        alert(c.$textarea.textSelection( 'getSelection' ));
+
    var selection = context.$textarea.textSelection( 'getSelection' );
                                                }
+
    var word;
                                        }
+
    if(selection) {
                                }
+
      word = selection;
                        }
+
    } else {
                } );
+
      word = prompt("Enter a Hebrew word");
 +
    }
 +
    var reference = "[[Hebrew:"+word+"|"+word+"]]";
 +
    context.$textarea.textSelection(
 +
    'encapsulateSelection',
 +
    { replace: true, peri: reference }
 +
    );
 +
  }
 +
}
 +
      }
 +
    }
 +
  } );
 
});
 
});

Revision as of 18:10, 28 October 2011

/* Any JavaScript here will be loaded for all users on every page load. */

$(document).ready(function() {
  $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
    'section': 'main',
    'group': 'format',
    'tools': {
      'hebrew_link': {
	label: 'Hebrew word with dictionary link',
	type: 'button',
	icon: 'http://www.withoutvowels.org/w/images/9/95/Button_hebrew_word.png',
	action: {
	  type: 'callback',
	  execute: function(context) {
	    var selection = context.$textarea.textSelection( 'getSelection' );
	    var word;
	    if(selection) {
	      word = selection;
	    } else {
	      word = prompt("Enter a Hebrew word");
	    }
	    var reference = "[[Hebrew:"+word+"|"+word+"]]";
	    context.$textarea.textSelection(
		    'encapsulateSelection',
		    { replace: true, peri: reference }
	    );
	  }
	}
      }
    }
  } );
});