@@ -62,7 +62,7 @@
|
||||
// get form fields
|
||||
var oldAction = $('#gollum-editor form').attr('action');
|
||||
var $form = $($('#gollum-editor form').get(0));
|
||||
$form.attr('action', '/preview');
|
||||
$form.attr('action', this.href || '/preview');
|
||||
$form.attr('target', '_blank');
|
||||
$form.submit();
|
||||
|
||||
@@ -154,7 +154,13 @@
|
||||
define: function( name, definitionObject ) {
|
||||
LanguageDefinition._ACTIVE_LANG = name;
|
||||
LanguageDefinition._LOADED_LANGS.push( name );
|
||||
LanguageDefinition._LANG[name] = definitionObject;
|
||||
if ( typeof $.GollumEditor.WikiLanguage == 'object' ) {
|
||||
var definition = {};
|
||||
$.extend(definition, $.GollumEditor.WikiLanguage, definitionObject);
|
||||
LanguageDefinition._LANG[name] = definition;
|
||||
} else {
|
||||
LanguageDefinition._LANG[name] = definitionObject;
|
||||
}
|
||||
},
|
||||
|
||||
getActiveLanguage: function() {
|
||||
@@ -776,226 +782,221 @@
|
||||
var Help = {
|
||||
|
||||
_ACTIVE_HELP: '',
|
||||
_LOADED_HELP_LANGS: [],
|
||||
_HELP: {},
|
||||
_LOADED_HELP_LANGS: [],
|
||||
_HELP: {},
|
||||
|
||||
/**
|
||||
* Help.define
|
||||
*
|
||||
* Defines a new help context and enables the help function if it
|
||||
* exists in the Gollum Function Bar.
|
||||
*
|
||||
* @param string name The name you're giving to this help context.
|
||||
* Generally, this should match the language name.
|
||||
* @param object definitionObject The definition object being loaded from a
|
||||
* language / help definition file.
|
||||
* @return void
|
||||
*/
|
||||
define: function( name, definitionObject ) {
|
||||
if ( Help.isValidHelpFormat( definitionObject ) ) {
|
||||
debug('help is a valid format');
|
||||
|
||||
Help._ACTIVE_HELP_LANG = name;
|
||||
Help._LOADED_HELP_LANGS.push( name );
|
||||
Help._HELP[name] = definitionObject;
|
||||
|
||||
if ( $("#function-help").length ) {
|
||||
if ( $('#function-help').hasClass('disabled') ) {
|
||||
$('#function-help').removeClass('disabled');
|
||||
}
|
||||
$('#function-help').unbind('click');
|
||||
$('#function-help').click( Help.evtHelpButtonClick );
|
||||
|
||||
// generate help menus
|
||||
Help.generateHelpMenuFor( name );
|
||||
|
||||
if ( $('#gollum-editor-help').length &&
|
||||
typeof $('#gollum-editor-help').attr('data-autodisplay') !== 'undefined' &&
|
||||
$('#gollum-editor-help').attr('data-autodisplay') === 'true' ) {
|
||||
Help.show();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ( $('#function-help').length ) {
|
||||
$('#function-help').addClass('disabled');
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Help.generateHelpMenuFor
|
||||
* Generates the markup for the main help menu given a context name.
|
||||
*
|
||||
* @param string name The context name.
|
||||
* @return void
|
||||
*/
|
||||
generateHelpMenuFor: function( name ) {
|
||||
if ( !Help._HELP[name] ) {
|
||||
debug('Help is not defined for ' + name.toString());
|
||||
return false;
|
||||
}
|
||||
var helpData = Help._HELP[name];
|
||||
|
||||
if ( EditorHas.mathJax() && Help.isLoadedFor('mathjax') ) {
|
||||
debug('Adding MathJax support to help');
|
||||
// TODO
|
||||
}
|
||||
|
||||
// clear this shiz out
|
||||
$('#gollum-editor-help-parent').html('');
|
||||
$('#gollum-editor-help-list').html('');
|
||||
$('#gollum-editor-help-content').html('');
|
||||
|
||||
// go go inefficient algorithm
|
||||
for ( var i=0; i < helpData.length; i++ ) {
|
||||
if ( typeof helpData[i] != 'object' ) {
|
||||
break;
|
||||
}
|
||||
|
||||
var $newLi = $('<li><a href="#" rel="' + i + '">' +
|
||||
helpData[i].menuName + '</a></li>');
|
||||
$('#gollum-editor-help-parent').append( $newLi );
|
||||
if ( i === 0 ) {
|
||||
// select on first run
|
||||
$newLi.children('a').addClass('selected');
|
||||
}
|
||||
$newLi.children('a').click( Help.evtParentMenuClick );
|
||||
}
|
||||
|
||||
// generate parent submenu on first run
|
||||
Help.generateSubMenu( helpData[0], 0 );
|
||||
$($('#gollum-editor-help-list li a').get(0)).click();
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Help.generateSubMenu
|
||||
* Generates the markup for the inline help sub-menu given the data
|
||||
* object for the submenu and the array index to start at.
|
||||
*
|
||||
* @param object subData The data for the sub-menu.
|
||||
* @param integer index The index clicked on (parent menu index).
|
||||
* @return void
|
||||
*/
|
||||
generateSubMenu: function( subData, index ) {
|
||||
$('#gollum-editor-help-list').html('');
|
||||
$('#gollum-editor-help-content').html('');
|
||||
for ( var i=0; i < subData.content.length; i++ ) {
|
||||
if ( typeof subData.content[i] != 'object' ) {
|
||||
break;
|
||||
}
|
||||
|
||||
var $subLi = $('<li><a href="#" rel="' + index + ':' + i + '">' +
|
||||
subData.content[i].menuName + '</a></li>');
|
||||
|
||||
|
||||
/**
|
||||
* Help.define
|
||||
*
|
||||
* Defines a new help context and enables the help function if it
|
||||
* exists in the Gollum Function Bar.
|
||||
*
|
||||
* @param string name The name you're giving to this help context.
|
||||
* Generally, this should match the language name.
|
||||
* @param object definitionObject The definition object being loaded from a
|
||||
* language / help definition file.
|
||||
* @return void
|
||||
*/
|
||||
define: function( name, definitionObject ) {
|
||||
if ( Help.isValidHelpFormat( definitionObject ) ) {
|
||||
debug('help is a valid format');
|
||||
$('#gollum-editor-help-list').append( $subLi );
|
||||
$subLi.children('a').click( Help.evtSubMenuClick );
|
||||
}
|
||||
},
|
||||
|
||||
Help._ACTIVE_HELP_LANG = name;
|
||||
Help._LOADED_HELP_LANGS.push( name );
|
||||
Help._HELP[name] = definitionObject;
|
||||
hide: function() {
|
||||
if ( $.browser.msie ) {
|
||||
$('#gollum-editor-help').css('display', 'none');
|
||||
} else {
|
||||
$('#gollum-editor-help').animate({
|
||||
opacity: 0
|
||||
}, 200, function() {
|
||||
$('#gollum-editor-help')
|
||||
.animate({ height: 'hide' }, 200);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
if ( $("#function-help").length ) {
|
||||
if ( $('#function-help').hasClass('disabled') ) {
|
||||
$('#function-help').removeClass('disabled');
|
||||
}
|
||||
$('#function-help').unbind('click');
|
||||
$('#function-help').click( Help.evtHelpButtonClick );
|
||||
show: function() {
|
||||
if ( $.browser.msie ) {
|
||||
// bypass effects for internet explorer, since it does weird crap
|
||||
// to text antialiasing with opacity animations
|
||||
$('#gollum-editor-help').css('display', 'block');
|
||||
} else {
|
||||
$('#gollum-editor-help').animate({
|
||||
height: 'show'
|
||||
}, 200, function() {
|
||||
$('#gollum-editor-help')
|
||||
.animate({ opacity: 1 }, 300);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// generate help menus
|
||||
Help.generateHelpMenuFor( name );
|
||||
}
|
||||
} else {
|
||||
if ( $('#function-help').length ) {
|
||||
$('#function-help').addClass('disabled');
|
||||
}
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Help.showHelpFor
|
||||
* Displays the actual help content given the two menu indexes, which are
|
||||
* rendered in the rel="" attributes of the help menus
|
||||
*
|
||||
* @param integer index1 parent index
|
||||
* @param integer index2 submenu index
|
||||
* @return void
|
||||
*/
|
||||
showHelpFor: function( index1, index2 ) {
|
||||
var html =
|
||||
Help._HELP[Help._ACTIVE_HELP_LANG][index1].content[index2].data;
|
||||
$('#gollum-editor-help-content').html(html);
|
||||
},
|
||||
|
||||
/**
|
||||
* Help.isLoadedFor
|
||||
* Returns true if help is loaded for a specific markup language,
|
||||
* false otherwise.
|
||||
*
|
||||
* @param string name The name of the markup language.
|
||||
* @return boolean
|
||||
*/
|
||||
isLoadedFor: function( name ) {
|
||||
for ( var i=0; i < Help._LOADED_HELP_LANGS.length; i++ ) {
|
||||
if ( name == Help._LOADED_HELP_LANGS[i] ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Help.generateHelpMenuFor
|
||||
* Generates the markup for the main help menu given a context name.
|
||||
*
|
||||
* @param string name The context name.
|
||||
* @return void
|
||||
*/
|
||||
generateHelpMenuFor: function( name ) {
|
||||
if ( !Help._HELP[name] ) {
|
||||
debug('Help is not defined for ' + name.toString());
|
||||
return false;
|
||||
}
|
||||
var helpData = Help._HELP[name];
|
||||
isShown: function() {
|
||||
return ($('#gollum-editor-help').is(':visible'));
|
||||
},
|
||||
|
||||
if ( EditorHas.mathJax() && Help.isLoadedFor('mathjax') ) {
|
||||
debug('Adding MathJax support to help');
|
||||
// TODO
|
||||
}
|
||||
/**
|
||||
* Help.isValidHelpFormat
|
||||
* Does a quick check to make sure that the help definition isn't in a
|
||||
* completely messed-up format.
|
||||
*
|
||||
* @param object (Array) helpArr The help definition array.
|
||||
* @return boolean
|
||||
*/
|
||||
isValidHelpFormat: function( helpArr ) {
|
||||
return ( typeof helpArr == 'object' &&
|
||||
helpArr.length &&
|
||||
typeof helpArr[0].menuName == 'string' &&
|
||||
typeof helpArr[0].content == 'object' &&
|
||||
helpArr[0].content.length );
|
||||
},
|
||||
|
||||
// clear this shiz out
|
||||
$('#gollum-editor-help-parent').html('');
|
||||
$('#gollum-editor-help-list').html('');
|
||||
$('#gollum-editor-help-content').html('');
|
||||
|
||||
// go go inefficient algorithm
|
||||
for ( var i=0; i < helpData.length; i++ ) {
|
||||
if ( typeof helpData[i] != 'object' ) {
|
||||
break;
|
||||
}
|
||||
|
||||
var $newLi = $('<li><a href="#" rel="' + i + '">' +
|
||||
helpData[i].menuName + '</a></li>');
|
||||
$('#gollum-editor-help-parent').append( $newLi );
|
||||
if ( i === 0 ) {
|
||||
// select on first run
|
||||
$newLi.children('a').addClass('selected');
|
||||
}
|
||||
$newLi.children('a').click( Help.evtParentMenuClick );
|
||||
}
|
||||
|
||||
// generate parent submenu on first run
|
||||
Help.generateSubMenu( helpData[0], 0 );
|
||||
$($('#gollum-editor-help-list li a').get(0)).click();
|
||||
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Help.generateSubMenu
|
||||
* Generates the markup for the inline help sub-menu given the data
|
||||
* object for the submenu and the array index to start at.
|
||||
*
|
||||
* @param object subData The data for the sub-menu.
|
||||
* @param integer index The index clicked on (parent menu index).
|
||||
* @return void
|
||||
*/
|
||||
generateSubMenu: function( subData, index ) {
|
||||
$('#gollum-editor-help-list').html('');
|
||||
$('#gollum-editor-help-content').html('');
|
||||
for ( var i=0; i < subData.content.length; i++ ) {
|
||||
if ( typeof subData.content[i] != 'object' ) {
|
||||
break;
|
||||
}
|
||||
|
||||
var $subLi = $('<li><a href="#" rel="' + index + ':' + i + '">' +
|
||||
subData.content[i].menuName + '</a></li>');
|
||||
|
||||
|
||||
$('#gollum-editor-help-list').append( $subLi );
|
||||
$subLi.children('a').click( Help.evtSubMenuClick );
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
hide: function() {
|
||||
if ( $.browser.msie ) {
|
||||
$('#gollum-editor-help').css('display', 'none');
|
||||
} else {
|
||||
$('#gollum-editor-help').animate({
|
||||
opacity: 0
|
||||
}, 200,
|
||||
function() {
|
||||
$('#gollum-editor-help')
|
||||
.animate({ height: 'hide' }, 200);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
show: function() {
|
||||
if ( $.browser.msie ) {
|
||||
// bypass effects for internet explorer, since it does weird crap
|
||||
// to text antialiasing with opacity animations
|
||||
$('#gollum-editor-help').css('display', 'block');
|
||||
} else {
|
||||
$('#gollum-editor-help').animate({
|
||||
height: 'show'
|
||||
}, 200,
|
||||
function() {
|
||||
$('#gollum-editor-help')
|
||||
.animate({ opacity: 1 }, 300);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Help.showHelpFor
|
||||
* Displays the actual help content given the two menu indexes, which are
|
||||
* rendered in the rel="" attributes of the help menus
|
||||
*
|
||||
* @param integer index1 parent index
|
||||
* @param integer index2 submenu index
|
||||
* @return void
|
||||
*/
|
||||
showHelpFor: function( index1, index2 ) {
|
||||
var html =
|
||||
Help._HELP[Help._ACTIVE_HELP_LANG][index1].content[index2].data;
|
||||
$('#gollum-editor-help-content').html(html);
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Help.isLoadedFor
|
||||
* Returns true if help is loaded for a specific markup language,
|
||||
* false otherwise.
|
||||
*
|
||||
* @param string name The name of the markup language.
|
||||
* @return boolean
|
||||
*/
|
||||
isLoadedFor: function( name ) {
|
||||
for ( var i=0; i < Help._LOADED_HELP_LANGS.length; i++ ) {
|
||||
if ( name == Help._LOADED_HELP_LANGS[i] ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
|
||||
isShown: function() {
|
||||
return ( $('#gollum-editor-help').is(':visible') );
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Help.isValidHelpFormat
|
||||
* Does a quick check to make sure that the help definition isn't in a
|
||||
* completely messed-up format.
|
||||
*
|
||||
* @param object (Array) helpArr The help definition array.
|
||||
* @return boolean
|
||||
*/
|
||||
isValidHelpFormat: function( helpArr ) {
|
||||
return ( typeof helpArr == 'object' &&
|
||||
helpArr.length &&
|
||||
typeof helpArr[0].menuName == 'string' &&
|
||||
typeof helpArr[0].content == 'object' &&
|
||||
helpArr[0].content.length );
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Help.setActiveHelp
|
||||
* Sets the active help definition to the one defined in the argument,
|
||||
* re-rendering the help menu to match the new definition.
|
||||
*
|
||||
* @param string name The name of the help definition.
|
||||
* @return void
|
||||
*/
|
||||
setActiveHelp: function( name ) {
|
||||
if ( !Help.isLoadedFor( name ) ) {
|
||||
if ( $('#function-help').length ) {
|
||||
$('#function-help').addClass('disabled');
|
||||
}
|
||||
if ( Help.isShown() ) {
|
||||
Help.hide();
|
||||
}
|
||||
} else {
|
||||
/**
|
||||
* Help.setActiveHelp
|
||||
* Sets the active help definition to the one defined in the argument,
|
||||
* re-rendering the help menu to match the new definition.
|
||||
*
|
||||
* @param string name The name of the help definition.
|
||||
* @return void
|
||||
*/
|
||||
setActiveHelp: function( name ) {
|
||||
if ( !Help.isLoadedFor( name ) ) {
|
||||
if ( $('#function-help').length ) {
|
||||
$('#function-help').addClass('disabled');
|
||||
}
|
||||
if ( Help.isShown() ) {
|
||||
Help.hide();
|
||||
}
|
||||
} else {
|
||||
Help._ACTIVE_HELP_LANG = name;
|
||||
if ( $("#function-help").length ) {
|
||||
if ( $('#function-help').hasClass('disabled') ) {
|
||||
@@ -1005,80 +1006,84 @@
|
||||
$('#function-help').click( Help.evtHelpButtonClick );
|
||||
Help.generateHelpMenuFor( name );
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Help.evtHelpButtonClick
|
||||
* Event handler for clicking the help button in the function bar.
|
||||
*
|
||||
* @param jQuery.Event e The jQuery event object.
|
||||
* @return void
|
||||
*/
|
||||
evtHelpButtonClick: function( e ) {
|
||||
e.preventDefault();
|
||||
if ( Help.isShown() ) {
|
||||
// turn off autodisplay if it's on
|
||||
if ( $('#gollum-editor-help').length &&
|
||||
$('#gollum-editor-help').attr('data-autodisplay') !== 'undefined' &&
|
||||
$('#gollum-editor-help').attr('data-autodisplay') === 'true' ) {
|
||||
$.post('/wiki/help?_method=delete');
|
||||
$('#gollum-editor-help').attr('data-autodisplay', '');
|
||||
}
|
||||
Help.hide(); }
|
||||
else { Help.show(); }
|
||||
},
|
||||
|
||||
/**
|
||||
* Help.evtHelpButtonClick
|
||||
* Event handler for clicking the help button in the function bar.
|
||||
*
|
||||
* @param jQuery.Event e The jQuery event object.
|
||||
* @return void
|
||||
*/
|
||||
evtHelpButtonClick: function( e ) {
|
||||
e.preventDefault();
|
||||
if ( Help.isShown() ) { Help.hide(); }
|
||||
else { Help.show(); }
|
||||
},
|
||||
/**
|
||||
* Help.evtParentMenuClick
|
||||
* Event handler for clicking on an item in the parent menu. Automatically
|
||||
* renders the submenu for the parent menu as well as the first result for
|
||||
* the actual plain text.
|
||||
*
|
||||
* @param jQuery.Event e The jQuery event object.
|
||||
* @return void
|
||||
*/
|
||||
evtParentMenuClick: function( e ) {
|
||||
e.preventDefault();
|
||||
// short circuit if we've selected this already
|
||||
if ( $(this).hasClass('selected') ) { return; }
|
||||
|
||||
// populate from help data for this
|
||||
var helpIndex = $(this).attr('rel');
|
||||
var subData = Help._HELP[Help._ACTIVE_HELP_LANG][helpIndex];
|
||||
|
||||
/**
|
||||
* Help.evtParentMenuClick
|
||||
* Event handler for clicking on an item in the parent menu. Automatically
|
||||
* renders the submenu for the parent menu as well as the first result for
|
||||
* the actual plain text.
|
||||
*
|
||||
* @param jQuery.Event e The jQuery event object.
|
||||
* @return void
|
||||
*/
|
||||
evtParentMenuClick: function( e ) {
|
||||
e.preventDefault();
|
||||
// short circuit if we've selected this already
|
||||
if ( $(this).hasClass('selected') ) { return; }
|
||||
$('#gollum-editor-help-parent li a').removeClass('selected');
|
||||
$(this).addClass('selected');
|
||||
Help.generateSubMenu( subData, helpIndex );
|
||||
$($('#gollum-editor-help-list li a').get(0)).click();
|
||||
},
|
||||
|
||||
// populate from help data for this
|
||||
var helpIndex = $(this).attr('rel');
|
||||
var subData = Help._HELP[Help._ACTIVE_HELP_LANG][helpIndex];
|
||||
/**
|
||||
* Help.evtSubMenuClick
|
||||
* Event handler for clicking an item in a help submenu. Renders the
|
||||
* appropriate text for the submenu link.
|
||||
*
|
||||
* @param jQuery.Event e The jQuery event object.
|
||||
* @return void
|
||||
*/
|
||||
evtSubMenuClick: function( e ) {
|
||||
e.preventDefault();
|
||||
if ( $(this).hasClass('selected') ) { return; }
|
||||
|
||||
$('#gollum-editor-help-parent li a').removeClass('selected');
|
||||
$(this).addClass('selected');
|
||||
Help.generateSubMenu( subData, helpIndex );
|
||||
$($('#gollum-editor-help-list li a').get(0)).click();
|
||||
},
|
||||
// split index rel data
|
||||
var rawIndex = $(this).attr('rel').split(':');
|
||||
$('#gollum-editor-help-list li a').removeClass('selected');
|
||||
$(this).addClass('selected');
|
||||
Help.showHelpFor( rawIndex[0], rawIndex[1] );
|
||||
}
|
||||
};
|
||||
|
||||
// Publicly-accessible function to Help.define
|
||||
$.GollumEditor.defineHelp = Help.define;
|
||||
|
||||
/**
|
||||
* Help.evtSubMenuClick
|
||||
* Event handler for clicking an item in a help submenu. Renders the
|
||||
* appropriate text for the submenu link.
|
||||
*
|
||||
* @param jQuery.Event e The jQuery event object.
|
||||
* @return void
|
||||
*/
|
||||
evtSubMenuClick: function( e ) {
|
||||
e.preventDefault();
|
||||
if ( $(this).hasClass('selected') ) { return; }
|
||||
// Dialog exists as its own thing now
|
||||
$.GollumEditor.Dialog = $.GollumDialog;
|
||||
$.GollumEditor.replaceSelection = function( repText ) {
|
||||
FunctionBar.replaceFieldSelection( $('#gollum-editor-body'), repText );
|
||||
};
|
||||
|
||||
// split index rel data
|
||||
var rawIndex = $(this).attr('rel').split(':');
|
||||
$('#gollum-editor-help-list li a').removeClass('selected');
|
||||
$(this).addClass('selected');
|
||||
Help.showHelpFor( rawIndex[0], rawIndex[1] );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Publicly-accessible function to Help.define
|
||||
$.GollumEditor.defineHelp = Help.define;
|
||||
|
||||
// Dialog exists as its own thing now
|
||||
$.GollumEditor.Dialog = $.GollumDialog;
|
||||
$.GollumEditor.replaceSelection = function( repText ) {
|
||||
FunctionBar.replaceFieldSelection( $('#gollum-editor-body'), repText );
|
||||
};
|
||||
|
||||
// Placeholder exists as its own thing now
|
||||
$.GollumEditor.Placeholder = $.GollumPlaceholder;
|
||||
// Placeholder exists as its own thing now
|
||||
$.GollumEditor.Placeholder = $.GollumPlaceholder;
|
||||
|
||||
})(jQuery);
|
||||
|
||||
@@ -4,171 +4,222 @@
|
||||
* Used for dialogs. Duh.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
(function($) {
|
||||
|
||||
var Dialog = {
|
||||
|
||||
debugOn: false,
|
||||
markupCreated: false,
|
||||
|
||||
attachEvents: function( evtOK ) {
|
||||
$('#gollum-dialog-action-ok').click(function( e ) {
|
||||
|
||||
var Dialog = {
|
||||
|
||||
debugOn: false,
|
||||
markupCreated: false,
|
||||
markup: '',
|
||||
|
||||
attachEvents: function( evtOK ) {
|
||||
$('#gollum-dialog-action-ok').click(function( e ) {
|
||||
Dialog.eventOK( e, evtOK );
|
||||
});
|
||||
$('#gollum-dialog-action-cancel').click( Dialog.eventCancel );
|
||||
},
|
||||
|
||||
createFieldMarkup: function( fieldArray ) {
|
||||
var fieldMarkup = '<fieldset>';
|
||||
for ( var i=0; i < fieldArray.length; i++ ) {
|
||||
if ( typeof fieldArray[i] == 'object' ) {
|
||||
fieldMarkup += '<div class="field">';
|
||||
switch ( fieldArray[i].type ) {
|
||||
|
||||
// only text is supported for now
|
||||
case 'text':
|
||||
fieldMarkup += Dialog.createFieldText( fieldArray[i] );
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
fieldMarkup += '</div>';
|
||||
}
|
||||
|
||||
}
|
||||
fieldMarkup += '</fieldset>';
|
||||
return fieldMarkup;
|
||||
},
|
||||
|
||||
createFieldText: function( fieldAttributes ) {
|
||||
var html = '';
|
||||
|
||||
if ( fieldAttributes.name ) {
|
||||
html += '<label';
|
||||
if ( fieldAttributes.id ) {
|
||||
html += ' for="' + fieldAttributes.name + '"';
|
||||
}
|
||||
html += '>' + fieldAttributes.name + '</label>';
|
||||
}
|
||||
|
||||
html += '<input type="text"';
|
||||
|
||||
if ( fieldAttributes.id ) {
|
||||
html += ' name="' + fieldAttributes.id + '"'
|
||||
if ( fieldAttributes.type == 'code' ) {
|
||||
html+= ' class="code"';
|
||||
}
|
||||
html += ' id="gollum-dialog-dialog-generated-field-' +
|
||||
fieldAttributes.id + '">';
|
||||
}
|
||||
|
||||
return html;
|
||||
},
|
||||
|
||||
createMarkup: function( title, body ) {
|
||||
Dialog.markupCreated = true;
|
||||
return '<div id="gollum-dialog-dialog">' +
|
||||
});
|
||||
$('#gollum-dialog-action-cancel').click( Dialog.eventCancel );
|
||||
$('#gollum-dialog-dialog input[type="text"]').keydown(function( e ) {
|
||||
if ( e.keyCode == 13 ) {
|
||||
Dialog.eventOK( e, evtOK );
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
detachEvents: function() {
|
||||
$('#gollum-dialog-action-ok').unbind('click');
|
||||
$('#gollum-dialog-action-cancel').unbind('click');
|
||||
},
|
||||
|
||||
createFieldMarkup: function( fieldArray ) {
|
||||
var fieldMarkup = '<fieldset>';
|
||||
for ( var i=0; i < fieldArray.length; i++ ) {
|
||||
if ( typeof fieldArray[i] == 'object' ) {
|
||||
fieldMarkup += '<div class="field">';
|
||||
switch ( fieldArray[i].type ) {
|
||||
|
||||
// only text is supported for now
|
||||
case 'text':
|
||||
fieldMarkup += Dialog.createFieldText( fieldArray[i] );
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
fieldMarkup += '</div>';
|
||||
}
|
||||
|
||||
}
|
||||
fieldMarkup += '</fieldset>';
|
||||
return fieldMarkup;
|
||||
},
|
||||
|
||||
createFieldText: function( fieldAttributes ) {
|
||||
var html = '';
|
||||
|
||||
if ( fieldAttributes.name ) {
|
||||
html += '<label';
|
||||
if ( fieldAttributes.id ) {
|
||||
html += ' for="' + fieldAttributes.name + '"';
|
||||
}
|
||||
html += '>' + fieldAttributes.name + '</label>';
|
||||
}
|
||||
|
||||
html += '<input type="text"';
|
||||
|
||||
if ( fieldAttributes.id ) {
|
||||
html += ' name="' + fieldAttributes.id + '"'
|
||||
if ( fieldAttributes.type == 'code' ) {
|
||||
html+= ' class="code"';
|
||||
}
|
||||
html += ' id="gollum-dialog-dialog-generated-field-' +
|
||||
fieldAttributes.id + '">';
|
||||
}
|
||||
|
||||
return html;
|
||||
},
|
||||
|
||||
createMarkup: function( title, body ) {
|
||||
Dialog.markupCreated = true;
|
||||
if ($.facebox) {
|
||||
return '<div id="gollum-dialog-dialog">' +
|
||||
'<div id="gollum-dialog-dialog-title"><h4>' +
|
||||
title +'</h4></div>' +
|
||||
'<div id="gollum-dialog-dialog-body">' + body + '</div>' +
|
||||
'<div id="gollum-dialog-dialog-buttons">' +
|
||||
'<a href="#" title="Cancel" id="gollum-dialog-action-cancel" ' +
|
||||
'class="gollum-minibutton">Cancel</a>' +
|
||||
'<a href="#" title="OK" id="gollum-dialog-action-ok" '+
|
||||
'class="gollum-minibutton">OK</a>' +
|
||||
'</div>' +
|
||||
'</div>';
|
||||
} else {
|
||||
return '<div id="gollum-dialog-dialog">' +
|
||||
'<div id="gollum-dialog-dialog-inner">' +
|
||||
'<div id="gollum-dialog-dialog-bg">' +
|
||||
'<div id="gollum-dialog-dialog-title"><h4>' +
|
||||
title +'</h4></div>' +
|
||||
'<div id="gollum-dialog-dialog-body">' + body + '</div>' +
|
||||
'<div id="gollum-dialog-dialog-buttons">' +
|
||||
'<a href="#" title="Cancel" id="gollum-dialog-action-cancel" ' +
|
||||
'<div id="gollum-dialog-dialog-title"><h4>' +
|
||||
title +'</h4></div>' +
|
||||
'<div id="gollum-dialog-dialog-body">' + body + '</div>' +
|
||||
'<div id="gollum-dialog-dialog-buttons">' +
|
||||
'<a href="#" title="Cancel" id="gollum-dialog-action-cancel" ' +
|
||||
'class="minibutton">Cancel</a>' +
|
||||
'<a href="#" title="OK" id="gollum-dialog-action-ok" '+
|
||||
'<a href="#" title="OK" id="gollum-dialog-action-ok" '+
|
||||
'class="minibutton">OK</a>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>';
|
||||
},
|
||||
|
||||
eventCancel: function( e ) {
|
||||
e.preventDefault();
|
||||
debug('Cancelled dialog.');
|
||||
Dialog.hide();
|
||||
},
|
||||
|
||||
eventOK: function( e, evtOK ) {
|
||||
e.preventDefault();
|
||||
|
||||
var results = [];
|
||||
// get the results from each field and build them into the object
|
||||
$('#gollum-dialog-dialog-body input').each(function() {
|
||||
results[$(this).attr('name')] = $(this).val();
|
||||
});
|
||||
|
||||
// pass them to evtOK if it exists (which it should)
|
||||
if ( evtOK &&
|
||||
typeof evtOK == 'function' ) {
|
||||
evtOK( results );
|
||||
}
|
||||
Dialog.hide();
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
hide: function() {
|
||||
if ( $.browser.msie ) {
|
||||
$('#gollum-dialog-dialog').hide().removeClass('active');
|
||||
$('select').css('visibility', 'visible');
|
||||
} else {
|
||||
$('#gollum-dialog-dialog').animate({ opacity: 0 }, {
|
||||
eventCancel: function( e ) {
|
||||
e.preventDefault();
|
||||
debug('Cancelled dialog.');
|
||||
Dialog.hide();
|
||||
},
|
||||
|
||||
eventOK: function( e, evtOK ) {
|
||||
e.preventDefault();
|
||||
|
||||
var results = [];
|
||||
// get the results from each field and build them into the object
|
||||
$('#gollum-dialog-dialog-body input').each(function() {
|
||||
results[$(this).attr('name')] = $(this).val();
|
||||
});
|
||||
|
||||
// pass them to evtOK if it exists (which it should)
|
||||
if ( evtOK &&
|
||||
typeof evtOK == 'function' ) {
|
||||
evtOK( results );
|
||||
}
|
||||
Dialog.hide();
|
||||
},
|
||||
|
||||
hide: function() {
|
||||
if ( $.facebox ) {
|
||||
Dialog.markupCreated = false;
|
||||
$(document).trigger('close.facebox');
|
||||
Dialog.detachEvents();
|
||||
} else {
|
||||
if ( $.browser.msie ) {
|
||||
$('#gollum-dialog-dialog').hide().removeClass('active');
|
||||
$('select').css('visibility', 'visible');
|
||||
} else {
|
||||
$('#gollum-dialog-dialog').animate({ opacity: 0 }, {
|
||||
duration: 200,
|
||||
complete: function() {
|
||||
$('#gollum-dialog-dialog').removeClass('active');
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
init: function( argObject ) {
|
||||
var title = '';
|
||||
var body = '';
|
||||
|
||||
// bail out if necessary
|
||||
if ( !argObject ||
|
||||
typeof argObject != 'object' ) {
|
||||
debug('Editor Dialog: Cannot init; invalid init object');
|
||||
return;
|
||||
}
|
||||
|
||||
if ( argObject.body && typeof argObject.body == 'string' ) {
|
||||
body = '<p>' + argObject.body + '</p>';
|
||||
}
|
||||
|
||||
// alright, build out fields
|
||||
if ( argObject.fields && typeof argObject.fields == 'object' ) {
|
||||
body += Dialog.createFieldMarkup( argObject.fields );
|
||||
}
|
||||
|
||||
if ( argObject.title && typeof argObject.title == 'string' ) {
|
||||
title = argObject.title;
|
||||
}
|
||||
|
||||
if ( Dialog.markupCreated ) {
|
||||
$('#gollum-dialog-dialog').remove();
|
||||
}
|
||||
var $dialog = $( Dialog.createMarkup( title, body ) );
|
||||
$('body').append( $dialog );
|
||||
if ( argObject.OK &&
|
||||
typeof argObject.OK == 'function' ) {
|
||||
Dialog.attachEvents( argObject.OK );
|
||||
}
|
||||
Dialog.show();
|
||||
},
|
||||
|
||||
show: function() {
|
||||
if ( !Dialog.markupCreated ) {
|
||||
debug('Dialog: No markup to show. Please use init first.');
|
||||
} else {
|
||||
debug('Showing dialog');
|
||||
}
|
||||
},
|
||||
|
||||
init: function( argObject ) {
|
||||
var title = '';
|
||||
var body = '';
|
||||
|
||||
// bail out if necessary
|
||||
if ( !argObject ||
|
||||
typeof argObject != 'object' ) {
|
||||
debug('Editor Dialog: Cannot init; invalid init object');
|
||||
return;
|
||||
}
|
||||
|
||||
if ( argObject.body && typeof argObject.body == 'string' ) {
|
||||
body = '<p>' + argObject.body + '</p>';
|
||||
}
|
||||
|
||||
// alright, build out fields
|
||||
if ( argObject.fields && typeof argObject.fields == 'object' ) {
|
||||
body += Dialog.createFieldMarkup( argObject.fields );
|
||||
}
|
||||
|
||||
if ( argObject.title && typeof argObject.title == 'string' ) {
|
||||
title = argObject.title;
|
||||
}
|
||||
|
||||
if ( Dialog.markupCreated ) {
|
||||
if ($.facebox) {
|
||||
$(document).trigger('close.facebox');
|
||||
} else {
|
||||
$('#gollum-dialog-dialog').remove();
|
||||
}
|
||||
}
|
||||
|
||||
Dialog.markup = Dialog.createMarkup( title, body );
|
||||
|
||||
if ($.facebox) {
|
||||
$(document).bind('reveal.facebox', function() {
|
||||
if ( argObject.OK &&
|
||||
typeof argObject.OK == 'function' ) {
|
||||
Dialog.attachEvents( argObject.OK );
|
||||
$($('#facebox input[type="text"]').get(0)).focus();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$('body').append( Dialog.markup );
|
||||
if ( argObject.OK &&
|
||||
typeof argObject.OK == 'function' ) {
|
||||
Dialog.attachEvents( argObject.OK );
|
||||
}
|
||||
}
|
||||
|
||||
Dialog.show();
|
||||
},
|
||||
|
||||
show: function() {
|
||||
if ( !Dialog.markupCreated ) {
|
||||
debug('Dialog: No markup to show. Please use init first.');
|
||||
} else {
|
||||
debug('Showing dialog');
|
||||
if ($.facebox) {
|
||||
$.facebox( Dialog.markup );
|
||||
} else {
|
||||
if ( $.browser.msie ) {
|
||||
$('#gollum-dialog.dialog').addClass('active');
|
||||
Dialog.position();
|
||||
$('select').css('visibility', 'hidden');
|
||||
$('select').css('visibility', 'hidden');
|
||||
} else {
|
||||
$('#gollum-dialog.dialog').css('display', 'none');
|
||||
$('#gollum-dialog-dialog').animate({ opacity: 0 }, {
|
||||
@@ -177,30 +228,36 @@
|
||||
$('#gollum-dialog-dialog').css('display', 'block');
|
||||
Dialog.position(); // position this thing
|
||||
$('#gollum-dialog-dialog').animate({ opacity: 1 }, {
|
||||
duration: 500
|
||||
duration: 500
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
position: function() {
|
||||
var dialogHeight = $('#gollum-dialog-dialog-inner').height();
|
||||
$('#gollum-dialog-dialog-inner')
|
||||
.css('height', dialogHeight + 'px')
|
||||
.css('margin-top', -1 * parseInt( dialogHeight / 2 ));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
position: function() {
|
||||
var dialogHeight = $('#gollum-dialog-dialog-inner').height();
|
||||
$('#gollum-dialog-dialog-inner')
|
||||
.css('height', dialogHeight + 'px')
|
||||
.css('margin-top', -1 * parseInt( dialogHeight / 2 ));
|
||||
}
|
||||
};
|
||||
|
||||
if ($.facebox) {
|
||||
$(document).bind('reveal.facebox', function() {
|
||||
$('#facebox img.close_image').remove();
|
||||
});
|
||||
}
|
||||
|
||||
var debug = function(m) {
|
||||
if ( Dialog.debugOn
|
||||
&& typeof console != 'undefined' ) {
|
||||
console.log( m );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
$.GollumDialog = Dialog;
|
||||
|
||||
})(jQuery);
|
||||
|
||||
})(jQuery);
|
||||
|
||||
@@ -1,6 +1,88 @@
|
||||
// ua
|
||||
$(document).ready(function() {
|
||||
|
||||
var nodeSelector = {
|
||||
node1: null,
|
||||
node2: null,
|
||||
|
||||
selectNodeRange: function( n1, n2 ) {
|
||||
if ( nodeSelector.node1 && nodeSelector.node2 ) {
|
||||
$('#wiki-history td.selected').removeClass('selected');
|
||||
nodeSelector.node1.addClass('selected');
|
||||
nodeSelector.node2.addClass('selected');
|
||||
|
||||
// swap the nodes around if they went in reverse
|
||||
if ( nodeSelector.nodeComesAfter( nodeSelector.node1,
|
||||
nodeSelector.node2 ) ) {
|
||||
var n = nodeSelector.node1;
|
||||
nodeSelector.node1 = nodeSelector.node2;
|
||||
nodeSelector.node2 = n;
|
||||
}
|
||||
|
||||
var s = true;
|
||||
var $nextNode = nodeSelector.node1.next();
|
||||
while ( $nextNode ) {
|
||||
$nextNode.addClass('selected');
|
||||
if ( $nextNode[0] == nodeSelector.node2[0] ) {
|
||||
break;
|
||||
}
|
||||
$nextNode = $nextNode.next();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
nodeComesAfter: function ( n1, n2 ) {
|
||||
var s = false;
|
||||
$(n1).prevAll().each(function() {
|
||||
if ( $(this)[0] == $(n2)[0] ) {
|
||||
s = true;
|
||||
}
|
||||
});
|
||||
return s;
|
||||
},
|
||||
|
||||
checkNode: function( nodeCheckbox ) {
|
||||
var $nodeCheckbox = nodeCheckbox;
|
||||
var $node = $(nodeCheckbox).parent().parent();
|
||||
// if we're unchecking
|
||||
if ( !$nodeCheckbox.is(':checked') ) {
|
||||
|
||||
// remove the range, since we're breaking it
|
||||
$('#wiki-history tr.selected').each(function() {
|
||||
if ( $(this).find('td.checkbox input').is(':checked') ) {
|
||||
return;
|
||||
}
|
||||
$(this).removeClass('selected');
|
||||
});
|
||||
|
||||
// no longer track this
|
||||
if ( $node[0] == nodeSelector.node1[0] ) {
|
||||
nodeSelector.node1 = null;
|
||||
if ( nodeSelector.node2 ) {
|
||||
nodeSelector.node1 = nodeSelector.node2;
|
||||
nodeSelector.node2 = null;
|
||||
}
|
||||
} else if ( $node[0] == nodeSelector.node2[0] ) {
|
||||
nodeSelector.node2 = null;
|
||||
}
|
||||
|
||||
} else {
|
||||
if ( !nodeSelector.node1 ) {
|
||||
nodeSelector.node1 = $node;
|
||||
nodeSelector.node1.addClass('selected');
|
||||
} else if ( !nodeSelector.node2 ) {
|
||||
// okay, we don't have a node 2 but have a node1
|
||||
nodeSelector.node2 = $node;
|
||||
nodeSelector.node2.addClass('selected');
|
||||
nodeSelector.selectNodeRange( nodeSelector.node1,
|
||||
nodeSelector.node2 );
|
||||
} else {
|
||||
// we have two selected already
|
||||
$nodeCheckbox[0].checked = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// ua detection
|
||||
if ($.browser.mozilla) {
|
||||
$('body').addClass('ff');
|
||||
@@ -14,7 +96,7 @@ $(document).ready(function() {
|
||||
$('body').addClass('ie8');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($('#minibutton-new-page').length) {
|
||||
$('#minibutton-new-page').removeClass('jaws');
|
||||
$('#minibutton-new-page').click(function(e) {
|
||||
@@ -38,10 +120,12 @@ $(document).ready(function() {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
if ($('#wiki-wrapper').hasClass('history')) {
|
||||
$('#wiki-history td.checkbox input').each(function() {
|
||||
$(this).click(highlightChecked);
|
||||
$(this).click(function() {
|
||||
nodeSelector.checkNode($(this));
|
||||
});
|
||||
if ( $(this).is(':checked') ) {
|
||||
nodeSelector.checkNode($(this));
|
||||
}
|
||||
@@ -53,9 +137,7 @@ $(document).ready(function() {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($('#searchbar a#search-submit').length) {
|
||||
$.GollumPlaceholder.add($('#searchbar #search-query'));
|
||||
$('#searchbar a#search-submit').click(function(e) {
|
||||
@@ -67,8 +149,8 @@ $(document).ready(function() {
|
||||
$(this).unbind('submit');
|
||||
$(this).submit();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($('#gollum-revert-form').length &&
|
||||
$('.gollum-revert-button').length ) {
|
||||
$('a.gollum-revert-button').click(function(e) {
|
||||
@@ -76,116 +158,4 @@ $(document).ready(function() {
|
||||
$('#gollum-revert-form').submit();
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
var nodeSelector = {
|
||||
|
||||
node1: null,
|
||||
node2: null,
|
||||
|
||||
selectNodeRange: function( n1, n2 ) {
|
||||
if ( nodeSelector.node1 && nodeSelector.node2 ) {
|
||||
$('#wiki-history td.selected').removeClass('selected');
|
||||
nodeSelector.node1.addClass('selected');
|
||||
nodeSelector.node2.addClass('selected');
|
||||
|
||||
// swap the nodes around if they went in reverse
|
||||
if ( nodeSelector.nodeComesAfter( nodeSelector.node1,
|
||||
nodeSelector.node2 ) ) {
|
||||
var n = nodeSelector.node1;
|
||||
nodeSelector.node1 = nodeSelector.node2;
|
||||
nodeSelector.node2 = n;
|
||||
}
|
||||
|
||||
var s = true;
|
||||
var $nextNode = nodeSelector.node1.next();
|
||||
while ( $nextNode ) {
|
||||
$nextNode.addClass('selected');
|
||||
if ( $nextNode[0] == nodeSelector.node2[0] ) {
|
||||
break;
|
||||
}
|
||||
$nextNode = $nextNode.next();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
nodeComesAfter: function ( n1, n2 ) {
|
||||
var s = false;
|
||||
$(n1).prevAll().each(function() {
|
||||
if ( $(this)[0] == $(n2)[0] ) {
|
||||
s = true;
|
||||
}
|
||||
});
|
||||
return s;
|
||||
},
|
||||
|
||||
checkNode: function( nodeCheckbox ) {
|
||||
var $nodeCheckbox = nodeCheckbox;
|
||||
var $node = $(nodeCheckbox).parent().parent();
|
||||
// if we're unchecking
|
||||
if ( !$nodeCheckbox.is(':checked') ) {
|
||||
|
||||
// remove the range, since we're breaking it
|
||||
$('#wiki-history tr.selected').each(function() {
|
||||
if ( $(this).find('td.checkbox input').is(':checked') ) {
|
||||
return;
|
||||
}
|
||||
$(this).removeClass('selected');
|
||||
});
|
||||
|
||||
// no longer track this
|
||||
if ( $node[0] == nodeSelector.node1[0] ) {
|
||||
nodeSelector.node1 = null;
|
||||
if ( nodeSelector.node2 ) {
|
||||
nodeSelector.node1 = nodeSelector.node2;
|
||||
nodeSelector.node2 = null;
|
||||
}
|
||||
} else if ( $node[0] == nodeSelector.node2[0] ) {
|
||||
nodeSelector.node2 = null;
|
||||
}
|
||||
|
||||
} else {
|
||||
if ( !nodeSelector.node1 ) {
|
||||
nodeSelector.node1 = $node;
|
||||
nodeSelector.node1.addClass('selected');
|
||||
} else if ( !nodeSelector.node2 ) {
|
||||
// okay, we don't have a node 2 but have a node1
|
||||
nodeSelector.node2 = $node;
|
||||
nodeSelector.node2.addClass('selected');
|
||||
nodeSelector.selectNodeRange( nodeSelector.node1,
|
||||
nodeSelector.node2 );
|
||||
} else {
|
||||
// we have two selected already
|
||||
$nodeCheckbox[0].checked = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
function highlightOn() {
|
||||
$(this).parent().parent().animate({
|
||||
backgroundColor: '#ffffea',
|
||||
duration: 400
|
||||
});
|
||||
}
|
||||
|
||||
function highlightOff() {
|
||||
var color = '#ebf2f6';
|
||||
if ($(this).parent().parent().hasClass('alt-row')) {
|
||||
color = '#f3f7fa';
|
||||
}
|
||||
$(this).parent().parent().animate({
|
||||
backgroundColor: color,
|
||||
duration: 400
|
||||
});
|
||||
}
|
||||
|
||||
function highlightChecked() {
|
||||
nodeSelector.checkNode($(this));
|
||||
}
|
||||
|
||||
function initMathJax() {
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user