Site for researching all meanings of Hebrew Bible.

Difference between revisions of "MediaWiki:Common.js"

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

Revision as of 22:20, 26 November 2012

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

$(document).ready(function() {
  if($( '#wpTextbox1' ).size())
    $( '#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");
	      }
	      if(!/^[\u05d0-\u05fa]+$/.test(word)) {
		alert("You must enter or select a Hebrew word without vowels!");
		return;
	      }
	      var reference = "[[Hebrew:"+word+"|"+word+"]]";
	      context.$textarea.textSelection(
		      'encapsulateSelection',
		      { replace: true, peri: reference }
	      );
	    }
	  }
	}
      }
    } );
});