Difference between revisions of "MediaWiki:Common.js"

From SacredWiki
Jump to navigation Jump to search
m
 
(68 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
/* Any JavaScript here will be loaded for all users on every page load. */
 
/* Any JavaScript here will be loaded for all users on every page load. */
 +
  
 
  if (mwCustomEditButtons) {
 
  if (mwCustomEditButtons) {
 +
  mwCustomEditButtons[mwCustomEditButtons.length] = {
 +
    "imageFile": "http://www.darkmatters.org/SacredWiki/images/buttons/align_center.png",
 +
    "speedTip": "Will center highlighted text.",
 +
    "tagOpen": "<center>",
 +
    "tagClose": "</center>",
 +
    "sampleText": ""};
 
   mwCustomEditButtons[mwCustomEditButtons.length] = {
 
   mwCustomEditButtons[mwCustomEditButtons.length] = {
 
     "imageFile": "http://www.darkmatters.org/SacredWiki/images/buttons/S1internallink.jpg",
 
     "imageFile": "http://www.darkmatters.org/SacredWiki/images/buttons/S1internallink.jpg",
 
     "speedTip": "Make a Sacred Underworld Internal Link",
 
     "speedTip": "Make a Sacred Underworld Internal Link",
 
     "tagOpen": "[[Sacred:",
 
     "tagOpen": "[[Sacred:",
     "tagClose": "|Type here what you want the link to be read as]]",
+
     "tagClose": "|]]",
 
     "sampleText": "Page Name you are linking to"};
 
     "sampleText": "Page Name you are linking to"};
 
 
   mwCustomEditButtons[mwCustomEditButtons.length] = {
 
   mwCustomEditButtons[mwCustomEditButtons.length] = {
 
     "imageFile": "http://www.darkmatters.org/SacredWiki/images/buttons/S2internallink.jpg",
 
     "imageFile": "http://www.darkmatters.org/SacredWiki/images/buttons/S2internallink.jpg",
 
     "speedTip": "Make a Sacred 2:Fallen Angel Internal Link",
 
     "speedTip": "Make a Sacred 2:Fallen Angel Internal Link",
     "tagOpen": "[[Sacred 2:WikiPageName|",
+
     "tagOpen": "[[Sacred 2:",
     "tagClose": "]]",
+
     "tagClose": "|]]",
 
     "sampleText": "Type here what you want the link to be read as..."};
 
     "sampleText": "Type here what you want the link to be read as..."};
 
 
   mwCustomEditButtons[mwCustomEditButtons.length] = {
 
   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://www.darkmatters.org/SacredWiki/images/buttons/indent.jpg",
+
     "imageFile": "http://www.darkmatters.org/SacredWiki/images/buttons/questbutton.jpg",
     "speedTip": "Indent a paragraph",
+
     "speedTip": "Quest Template.  Push the preview to see results.",
     "tagOpen": "<span style="indent:3em;">",
+
     "tagOpen": "{{subst:Quest",
     "tagClose": "</span>",
+
    "tagClose": "}}",
 +
    "sampleText": ""};
 +
  mwCustomEditButtons[mwCustomEditButtons.length] = {
 +
    "imageFile": "http://www.darkmatters.org/SacredWiki/images/buttons/chainquest.jpg",
 +
    "speedTip": "ChainQuest Template.  Push the preview to see results.",
 +
    "tagOpen": "{{subst:ChainQuest",
 +
    "tagClose": "}}",
 +
    "sampleText": ""};
 +
  mwCustomEditButtons[mwCustomEditButtons.length] = {
 +
    "imageFile": "http://www.darkmatters.org/SacredWiki/images/buttons/place.jpg",
 +
    "speedTip": "Place Template.  Push the preview to see results.",
 +
    "tagOpen": "{{subst:Place",
 +
     "tagClose": "}}",
 
     "sampleText": ""};
 
     "sampleText": ""};
 
 
   mwCustomEditButtons[mwCustomEditButtons.length] = {
 
   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://www.sacredwiki.org/images/buttons/linebreak.jpg",
+
     "imageFile": "http://www.darkmatters.org/SacredWiki/images/buttons/npc.jpg",
     "speedTip": "Line break",
+
     "speedTip": "NPC Template.  Push the preview to see results.",
     "tagOpen": "<br />",
+
     "tagOpen": "{{subst:NPC",
     "tagClose": "",
+
     "tagClose": "}}",
     "sampleText": ""}
+
     "sampleText": ""};
 
   }
 
   }
 +
 +
var customizeToolbar = function() {
 +
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
 +
        'section': 'main',
 +
        'group': 'insert',
 +
        'tools': {
 +
                'S1link': {
 +
                        label: 'Sacred 1 Link', // or use labelMsg for a localized label, see above
 +
                        type: 'button',
 +
                        icon: 'S1link.jpg',
 +
'action': {
 +
'type': 'encapsulate',
 +
'options': {
 +
'pre': "[[Sacred:",
 +
'peri': 'Page Name you want to link to',
 +
'post': "|]]"
 +
}
 +
}
 +
          },
 +
                'S2link': {
 +
                        label: 'Sacred 2 Link', // or use labelMsg for a localized label, see above
 +
                        type: 'button',
 +
                        icon: 'S2link.jpg',
 +
'action': {
 +
'type': 'encapsulate',
 +
'options': {
 +
'pre': "[[Sacred 2:",
 +
'peri': 'Page Name you want to link to',
 +
'post': "|]]"
 +
}
 +
}
 +
},
 +
                'Quest': {
 +
                        label: 'Quest Template.  Push the preview to see results', // or use labelMsg for a localized label, see above
 +
                        type: 'button',
 +
                        icon: 'quest.png',
 +
'action': {
 +
'type': 'encapsulate',
 +
'options': {
 +
'pre': "{{subst:Quest",
 +
'post': "}}"
 +
}
 +
}
 +
},
 +
                'ChainQuest': {
 +
                        label: 'Chain Quest Template.  Push the preview to see results', // or use labelMsg for a localized label, see above
 +
                        type: 'button',
 +
                        icon: 'chainquest.png',
 +
'action': {
 +
'type': 'encapsulate',
 +
'options': {
 +
'pre': "{{subst:ChainQuest",
 +
'post': "}}"
 +
}
 +
}
 +
},
 +
                'Place': {
 +
                        label: 'Place Template.  Push the preview to see results', // or use labelMsg for a localized label, see above
 +
                        type: 'button',
 +
                        icon: 'place.png',
 +
'action': {
 +
'type': 'encapsulate',
 +
'options': {
 +
'pre': "{{subst:Place",
 +
'post': "}}"
 +
}
 +
}
 +
},
 +
                'NPC': {
 +
                        label: 'NPC Template.  Push the preview to see results', // or use labelMsg for a localized label, see above
 +
                        type: 'button',
 +
                        icon: 'NPC.png',
 +
'action': {
 +
'type': 'encapsulate',
 +
'options': {
 +
'pre': "{{subst:NPC",
 +
'post': "}}"
 +
}
 +
}
 +
},
 +
/*                'TEST': {
 +
                        label: 'TESTing',
 +
                        type: 'button',
 +
                        icon: 'NPC.png',
 +
'action': {
 +
                            'type':'dialog',
 +
                                'module':'insert-link'
 +
}
 +
}
 +
}, */
 +
                'S2Frame': {
 +
                        label: 'Sacred 2 Frame to put around images and videos',
 +
                        type: 'button',
 +
                        icon: 's2frame.png',
 +
'action': {
 +
'type': 'encapsulate',
 +
'options': {
 +
'pre': "{{s2frame|",
 +
'post': "|none}}"
 +
}
 +
}
 +
},
 +
                'Dialogue': {
 +
                        label: 'S2 Dialogue Template.  Push the preview to see results', // or use labelMsg for a localized label, see above
 +
                        type: 'button',
 +
                        icon: 'dialogue.png',
 +
'action': {
 +
'type': 'encapsulate',
 +
'options': {
 +
'pre': "{{S2 Dialogue|NPC NAME=NPCNAME|PORTRAIT FILE NAME=NoPicDialog.png|DIALOGUE=<poem>",
 +
'peri': 'TYPEtextHERE',
 +
'post': "</poem>}}"
 +
}
 +
}
 +
}
 +
        }
 +
} );
 +
}
 +
 +
/* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar . . . */
 +
if ( $.inArray( mw.config.get( 'wgAction' ), ['edit', 'submit'] ) !== -1 ) {
 +
        mw.loader.using( 'user.options', function () {
 +
                if ( mw.user.options.get('usebetatoolbar') ) {
 +
                        mw.loader.using( 'ext.wikiEditor.toolbar', function () {
 +
                                $(document).ready( customizeToolbar );
 +
                        } );
 +
                }
 +
        } );
 +
}

Latest revision as of 10:36, 25 February 2014

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


 if (mwCustomEditButtons) {
   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://www.darkmatters.org/SacredWiki/images/buttons/align_center.png",
     "speedTip": "Will center highlighted text.",
     "tagOpen": "<center>",
     "tagClose": "</center>",
     "sampleText": ""};
   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://www.darkmatters.org/SacredWiki/images/buttons/S1internallink.jpg",
     "speedTip": "Make a Sacred Underworld Internal Link",
     "tagOpen": "[[Sacred:",
     "tagClose": "|]]",
     "sampleText": "Page Name you are linking to"};
   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://www.darkmatters.org/SacredWiki/images/buttons/S2internallink.jpg",
     "speedTip": "Make a Sacred 2:Fallen Angel Internal Link",
     "tagOpen": "[[Sacred 2:",
     "tagClose": "|]]",
     "sampleText": "Type here what you want the link to be read as..."};
   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://www.darkmatters.org/SacredWiki/images/buttons/questbutton.jpg",
     "speedTip": "Quest Template.  Push the preview to see results.",
     "tagOpen": "{{subst:Quest",
     "tagClose": "}}",
     "sampleText": ""};
   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://www.darkmatters.org/SacredWiki/images/buttons/chainquest.jpg",
     "speedTip": "ChainQuest Template.  Push the preview to see results.",
     "tagOpen": "{{subst:ChainQuest",
     "tagClose": "}}",
     "sampleText": ""};
   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://www.darkmatters.org/SacredWiki/images/buttons/place.jpg",
     "speedTip": "Place Template.  Push the preview to see results.",
     "tagOpen": "{{subst:Place",
     "tagClose": "}}",
     "sampleText": ""};
   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://www.darkmatters.org/SacredWiki/images/buttons/npc.jpg",
     "speedTip": "NPC Template.  Push the preview to see results.",
     "tagOpen": "{{subst:NPC",
     "tagClose": "}}",
     "sampleText": ""};
  }

var customizeToolbar = function() {
$( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
        'section': 'main',
        'group': 'insert',
        'tools': {
                'S1link': {
                        label: 'Sacred 1 Link', // or use labelMsg for a localized label, see above
                        type: 'button',
                        icon: 'S1link.jpg',
			'action': {
				'type': 'encapsulate',
				'options': {
					'pre': "[[Sacred:",
					'peri': 'Page Name you want to link to',
					'post': "|]]"
				}
			}
          },
                'S2link': {
                        label: 'Sacred 2 Link', // or use labelMsg for a localized label, see above
                        type: 'button',
                        icon: 'S2link.jpg',
			'action': {
				'type': 'encapsulate',
				'options': {
					'pre': "[[Sacred 2:",
					'peri': 'Page Name you want to link to',
					'post': "|]]"
					}
				}
			},
                'Quest': {
                        label: 'Quest Template.  Push the preview to see results', // or use labelMsg for a localized label, see above
                        type: 'button',
                        icon: 'quest.png',
			'action': {
				'type': 'encapsulate',
				'options': {
					'pre': "{{subst:Quest",
					'post': "}}"
					}
				}
			},
                'ChainQuest': {
                        label: 'Chain Quest Template.  Push the preview to see results', // or use labelMsg for a localized label, see above
                        type: 'button',
                        icon: 'chainquest.png',
			'action': {
				'type': 'encapsulate',
				'options': {
					'pre': "{{subst:ChainQuest",
					'post': "}}"
					}
				}
			},
                'Place': {
                        label: 'Place Template.  Push the preview to see results', // or use labelMsg for a localized label, see above
                        type: 'button',
                        icon: 'place.png',
			'action': {
				'type': 'encapsulate',
				'options': {
					'pre': "{{subst:Place",
					'post': "}}"
					}
				}
			},
                'NPC': {
                        label: 'NPC Template.  Push the preview to see results', // or use labelMsg for a localized label, see above
                        type: 'button',
                        icon: 'NPC.png',
			'action': {
				'type': 'encapsulate',
				'options': {
					'pre': "{{subst:NPC",
					'post': "}}"
					}
				}
			},
/*                'TEST': {
                        label: 'TESTing',
                        type: 'button',
                        icon: 'NPC.png',
			'action': {
                            'type':'dialog',
                                'module':'insert-link'
					}
				}
			}, */
                'S2Frame': {
                        label: 'Sacred 2 Frame to put around images and videos',
                        type: 'button',
                        icon: 's2frame.png',
			'action': {
				'type': 'encapsulate',
				'options': {
					'pre': "{{s2frame|",
					'post': "|none}}"
					}
				}
			},
                'Dialogue': {
                        label: 'S2 Dialogue Template.  Push the preview to see results', // or use labelMsg for a localized label, see above
                        type: 'button',
                        icon: 'dialogue.png',
			'action': {
				'type': 'encapsulate',
				'options': {
					'pre': "{{S2 Dialogue|NPC NAME=NPCNAME|PORTRAIT FILE NAME=NoPicDialog.png|DIALOGUE=<poem>",
					'peri': 'TYPEtextHERE',
					'post': "</poem>}}"
					}
				}
			}
        }
} );
}
 
/* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar . . . */
if ( $.inArray( mw.config.get( 'wgAction' ), ['edit', 'submit'] ) !== -1 ) {
        mw.loader.using( 'user.options', function () {
                if ( mw.user.options.get('usebetatoolbar') ) {
                        mw.loader.using( 'ext.wikiEditor.toolbar', function () {
                                $(document).ready( customizeToolbar );
                        } );
                }
        } );
}