@@ -62,7 +62,7 @@
|
|||||||
// get form fields
|
// get form fields
|
||||||
var oldAction = $('#gollum-editor form').attr('action');
|
var oldAction = $('#gollum-editor form').attr('action');
|
||||||
var $form = $($('#gollum-editor form').get(0));
|
var $form = $($('#gollum-editor form').get(0));
|
||||||
$form.attr('action', '/preview');
|
$form.attr('action', this.href || '/preview');
|
||||||
$form.attr('target', '_blank');
|
$form.attr('target', '_blank');
|
||||||
$form.submit();
|
$form.submit();
|
||||||
|
|
||||||
@@ -154,7 +154,13 @@
|
|||||||
define: function( name, definitionObject ) {
|
define: function( name, definitionObject ) {
|
||||||
LanguageDefinition._ACTIVE_LANG = name;
|
LanguageDefinition._ACTIVE_LANG = name;
|
||||||
LanguageDefinition._LOADED_LANGS.push( 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() {
|
getActiveLanguage: function() {
|
||||||
@@ -776,226 +782,221 @@
|
|||||||
var Help = {
|
var Help = {
|
||||||
|
|
||||||
_ACTIVE_HELP: '',
|
_ACTIVE_HELP: '',
|
||||||
_LOADED_HELP_LANGS: [],
|
_LOADED_HELP_LANGS: [],
|
||||||
_HELP: {},
|
_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>');
|
||||||
|
|
||||||
|
|
||||||
/**
|
$('#gollum-editor-help-list').append( $subLi );
|
||||||
* Help.define
|
$subLi.children('a').click( Help.evtSubMenuClick );
|
||||||
*
|
}
|
||||||
* 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;
|
hide: function() {
|
||||||
Help._LOADED_HELP_LANGS.push( name );
|
if ( $.browser.msie ) {
|
||||||
Help._HELP[name] = definitionObject;
|
$('#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 ) {
|
show: function() {
|
||||||
if ( $('#function-help').hasClass('disabled') ) {
|
if ( $.browser.msie ) {
|
||||||
$('#function-help').removeClass('disabled');
|
// bypass effects for internet explorer, since it does weird crap
|
||||||
}
|
// to text antialiasing with opacity animations
|
||||||
$('#function-help').unbind('click');
|
$('#gollum-editor-help').css('display', 'block');
|
||||||
$('#function-help').click( Help.evtHelpButtonClick );
|
} else {
|
||||||
|
$('#gollum-editor-help').animate({
|
||||||
|
height: 'show'
|
||||||
|
}, 200, function() {
|
||||||
|
$('#gollum-editor-help')
|
||||||
|
.animate({ opacity: 1 }, 300);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
// generate help menus
|
/**
|
||||||
Help.generateHelpMenuFor( name );
|
* Help.showHelpFor
|
||||||
}
|
* Displays the actual help content given the two menu indexes, which are
|
||||||
} else {
|
* rendered in the rel="" attributes of the help menus
|
||||||
if ( $('#function-help').length ) {
|
*
|
||||||
$('#function-help').addClass('disabled');
|
* @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() {
|
||||||
* Help.generateHelpMenuFor
|
return ($('#gollum-editor-help').is(':visible'));
|
||||||
* 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');
|
* Help.isValidHelpFormat
|
||||||
// TODO
|
* 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('');
|
* Help.setActiveHelp
|
||||||
$('#gollum-editor-help-list').html('');
|
* Sets the active help definition to the one defined in the argument,
|
||||||
$('#gollum-editor-help-content').html('');
|
* re-rendering the help menu to match the new definition.
|
||||||
|
*
|
||||||
// go go inefficient algorithm
|
* @param string name The name of the help definition.
|
||||||
for ( var i=0; i < helpData.length; i++ ) {
|
* @return void
|
||||||
if ( typeof helpData[i] != 'object' ) {
|
*/
|
||||||
break;
|
setActiveHelp: function( name ) {
|
||||||
}
|
if ( !Help.isLoadedFor( name ) ) {
|
||||||
|
if ( $('#function-help').length ) {
|
||||||
var $newLi = $('<li><a href="#" rel="' + i + '">' +
|
$('#function-help').addClass('disabled');
|
||||||
helpData[i].menuName + '</a></li>');
|
}
|
||||||
$('#gollum-editor-help-parent').append( $newLi );
|
if ( Help.isShown() ) {
|
||||||
if ( i === 0 ) {
|
Help.hide();
|
||||||
// select on first run
|
}
|
||||||
$newLi.children('a').addClass('selected');
|
} else {
|
||||||
}
|
|
||||||
$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._ACTIVE_HELP_LANG = name;
|
Help._ACTIVE_HELP_LANG = name;
|
||||||
if ( $("#function-help").length ) {
|
if ( $("#function-help").length ) {
|
||||||
if ( $('#function-help').hasClass('disabled') ) {
|
if ( $('#function-help').hasClass('disabled') ) {
|
||||||
@@ -1005,80 +1006,84 @@
|
|||||||
$('#function-help').click( Help.evtHelpButtonClick );
|
$('#function-help').click( Help.evtHelpButtonClick );
|
||||||
Help.generateHelpMenuFor( name );
|
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
|
* Help.evtParentMenuClick
|
||||||
* Event handler for clicking the help button in the function bar.
|
* 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
|
||||||
* @param jQuery.Event e The jQuery event object.
|
* the actual plain text.
|
||||||
* @return void
|
*
|
||||||
*/
|
* @param jQuery.Event e The jQuery event object.
|
||||||
evtHelpButtonClick: function( e ) {
|
* @return void
|
||||||
e.preventDefault();
|
*/
|
||||||
if ( Help.isShown() ) { Help.hide(); }
|
evtParentMenuClick: function( e ) {
|
||||||
else { Help.show(); }
|
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];
|
||||||
|
|
||||||
/**
|
$('#gollum-editor-help-parent li a').removeClass('selected');
|
||||||
* Help.evtParentMenuClick
|
$(this).addClass('selected');
|
||||||
* Event handler for clicking on an item in the parent menu. Automatically
|
Help.generateSubMenu( subData, helpIndex );
|
||||||
* renders the submenu for the parent menu as well as the first result for
|
$($('#gollum-editor-help-list li a').get(0)).click();
|
||||||
* 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');
|
* Help.evtSubMenuClick
|
||||||
var subData = Help._HELP[Help._ACTIVE_HELP_LANG][helpIndex];
|
* 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');
|
// split index rel data
|
||||||
$(this).addClass('selected');
|
var rawIndex = $(this).attr('rel').split(':');
|
||||||
Help.generateSubMenu( subData, helpIndex );
|
$('#gollum-editor-help-list li a').removeClass('selected');
|
||||||
$($('#gollum-editor-help-list li a').get(0)).click();
|
$(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
|
||||||
* Help.evtSubMenuClick
|
$.GollumEditor.Dialog = $.GollumDialog;
|
||||||
* Event handler for clicking an item in a help submenu. Renders the
|
$.GollumEditor.replaceSelection = function( repText ) {
|
||||||
* appropriate text for the submenu link.
|
FunctionBar.replaceFieldSelection( $('#gollum-editor-body'), repText );
|
||||||
*
|
};
|
||||||
* @param jQuery.Event e The jQuery event object.
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
evtSubMenuClick: function( e ) {
|
|
||||||
e.preventDefault();
|
|
||||||
if ( $(this).hasClass('selected') ) { return; }
|
|
||||||
|
|
||||||
// split index rel data
|
// Placeholder exists as its own thing now
|
||||||
var rawIndex = $(this).attr('rel').split(':');
|
$.GollumEditor.Placeholder = $.GollumPlaceholder;
|
||||||
$('#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;
|
|
||||||
|
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
|||||||
@@ -4,171 +4,222 @@
|
|||||||
* Used for dialogs. Duh.
|
* Used for dialogs. Duh.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
(function($) {
|
(function($) {
|
||||||
|
|
||||||
var Dialog = {
|
var Dialog = {
|
||||||
|
|
||||||
debugOn: false,
|
debugOn: false,
|
||||||
markupCreated: false,
|
markupCreated: false,
|
||||||
|
markup: '',
|
||||||
attachEvents: function( evtOK ) {
|
|
||||||
$('#gollum-dialog-action-ok').click(function( e ) {
|
attachEvents: function( evtOK ) {
|
||||||
|
$('#gollum-dialog-action-ok').click(function( e ) {
|
||||||
Dialog.eventOK( e, evtOK );
|
Dialog.eventOK( e, evtOK );
|
||||||
});
|
});
|
||||||
$('#gollum-dialog-action-cancel').click( Dialog.eventCancel );
|
$('#gollum-dialog-action-cancel').click( Dialog.eventCancel );
|
||||||
},
|
$('#gollum-dialog-dialog input[type="text"]').keydown(function( e ) {
|
||||||
|
if ( e.keyCode == 13 ) {
|
||||||
createFieldMarkup: function( fieldArray ) {
|
Dialog.eventOK( e, evtOK );
|
||||||
var fieldMarkup = '<fieldset>';
|
}
|
||||||
for ( var i=0; i < fieldArray.length; i++ ) {
|
});
|
||||||
if ( typeof fieldArray[i] == 'object' ) {
|
},
|
||||||
fieldMarkup += '<div class="field">';
|
|
||||||
switch ( fieldArray[i].type ) {
|
detachEvents: function() {
|
||||||
|
$('#gollum-dialog-action-ok').unbind('click');
|
||||||
// only text is supported for now
|
$('#gollum-dialog-action-cancel').unbind('click');
|
||||||
case 'text':
|
},
|
||||||
fieldMarkup += Dialog.createFieldText( fieldArray[i] );
|
|
||||||
break;
|
createFieldMarkup: function( fieldArray ) {
|
||||||
|
var fieldMarkup = '<fieldset>';
|
||||||
default:
|
for ( var i=0; i < fieldArray.length; i++ ) {
|
||||||
break;
|
if ( typeof fieldArray[i] == 'object' ) {
|
||||||
|
fieldMarkup += '<div class="field">';
|
||||||
}
|
switch ( fieldArray[i].type ) {
|
||||||
fieldMarkup += '</div>';
|
|
||||||
}
|
// only text is supported for now
|
||||||
|
case 'text':
|
||||||
}
|
fieldMarkup += Dialog.createFieldText( fieldArray[i] );
|
||||||
fieldMarkup += '</fieldset>';
|
break;
|
||||||
return fieldMarkup;
|
|
||||||
},
|
default:
|
||||||
|
break;
|
||||||
createFieldText: function( fieldAttributes ) {
|
|
||||||
var html = '';
|
}
|
||||||
|
fieldMarkup += '</div>';
|
||||||
if ( fieldAttributes.name ) {
|
}
|
||||||
html += '<label';
|
|
||||||
if ( fieldAttributes.id ) {
|
}
|
||||||
html += ' for="' + fieldAttributes.name + '"';
|
fieldMarkup += '</fieldset>';
|
||||||
}
|
return fieldMarkup;
|
||||||
html += '>' + fieldAttributes.name + '</label>';
|
},
|
||||||
}
|
|
||||||
|
createFieldText: function( fieldAttributes ) {
|
||||||
html += '<input type="text"';
|
var html = '';
|
||||||
|
|
||||||
if ( fieldAttributes.id ) {
|
if ( fieldAttributes.name ) {
|
||||||
html += ' name="' + fieldAttributes.id + '"'
|
html += '<label';
|
||||||
if ( fieldAttributes.type == 'code' ) {
|
if ( fieldAttributes.id ) {
|
||||||
html+= ' class="code"';
|
html += ' for="' + fieldAttributes.name + '"';
|
||||||
}
|
}
|
||||||
html += ' id="gollum-dialog-dialog-generated-field-' +
|
html += '>' + fieldAttributes.name + '</label>';
|
||||||
fieldAttributes.id + '">';
|
}
|
||||||
}
|
|
||||||
|
html += '<input type="text"';
|
||||||
return html;
|
|
||||||
},
|
if ( fieldAttributes.id ) {
|
||||||
|
html += ' name="' + fieldAttributes.id + '"'
|
||||||
createMarkup: function( title, body ) {
|
if ( fieldAttributes.type == 'code' ) {
|
||||||
Dialog.markupCreated = true;
|
html+= ' class="code"';
|
||||||
return '<div id="gollum-dialog-dialog">' +
|
}
|
||||||
|
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-inner">' +
|
||||||
'<div id="gollum-dialog-dialog-bg">' +
|
'<div id="gollum-dialog-dialog-bg">' +
|
||||||
'<div id="gollum-dialog-dialog-title"><h4>' +
|
'<div id="gollum-dialog-dialog-title"><h4>' +
|
||||||
title +'</h4></div>' +
|
title +'</h4></div>' +
|
||||||
'<div id="gollum-dialog-dialog-body">' + body + '</div>' +
|
'<div id="gollum-dialog-dialog-body">' + body + '</div>' +
|
||||||
'<div id="gollum-dialog-dialog-buttons">' +
|
'<div id="gollum-dialog-dialog-buttons">' +
|
||||||
'<a href="#" title="Cancel" id="gollum-dialog-action-cancel" ' +
|
'<a href="#" title="Cancel" id="gollum-dialog-action-cancel" ' +
|
||||||
'class="minibutton">Cancel</a>' +
|
'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>' +
|
'class="minibutton">OK</a>' +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
'</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() {
|
eventCancel: function( e ) {
|
||||||
if ( $.browser.msie ) {
|
e.preventDefault();
|
||||||
$('#gollum-dialog-dialog').hide().removeClass('active');
|
debug('Cancelled dialog.');
|
||||||
$('select').css('visibility', 'visible');
|
Dialog.hide();
|
||||||
} else {
|
},
|
||||||
$('#gollum-dialog-dialog').animate({ opacity: 0 }, {
|
|
||||||
|
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,
|
duration: 200,
|
||||||
complete: function() {
|
complete: function() {
|
||||||
$('#gollum-dialog-dialog').removeClass('active');
|
$('#gollum-dialog-dialog').removeClass('active');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
},
|
||||||
init: function( argObject ) {
|
|
||||||
var title = '';
|
init: function( argObject ) {
|
||||||
var body = '';
|
var title = '';
|
||||||
|
var body = '';
|
||||||
// bail out if necessary
|
|
||||||
if ( !argObject ||
|
// bail out if necessary
|
||||||
typeof argObject != 'object' ) {
|
if ( !argObject ||
|
||||||
debug('Editor Dialog: Cannot init; invalid init object');
|
typeof argObject != 'object' ) {
|
||||||
return;
|
debug('Editor Dialog: Cannot init; invalid init object');
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
if ( argObject.body && typeof argObject.body == 'string' ) {
|
|
||||||
body = '<p>' + argObject.body + '</p>';
|
if ( argObject.body && typeof argObject.body == 'string' ) {
|
||||||
}
|
body = '<p>' + argObject.body + '</p>';
|
||||||
|
}
|
||||||
// alright, build out fields
|
|
||||||
if ( argObject.fields && typeof argObject.fields == 'object' ) {
|
// alright, build out fields
|
||||||
body += Dialog.createFieldMarkup( argObject.fields );
|
if ( argObject.fields && typeof argObject.fields == 'object' ) {
|
||||||
}
|
body += Dialog.createFieldMarkup( argObject.fields );
|
||||||
|
}
|
||||||
if ( argObject.title && typeof argObject.title == 'string' ) {
|
|
||||||
title = argObject.title;
|
if ( argObject.title && typeof argObject.title == 'string' ) {
|
||||||
}
|
title = argObject.title;
|
||||||
|
}
|
||||||
if ( Dialog.markupCreated ) {
|
|
||||||
$('#gollum-dialog-dialog').remove();
|
if ( Dialog.markupCreated ) {
|
||||||
}
|
if ($.facebox) {
|
||||||
var $dialog = $( Dialog.createMarkup( title, body ) );
|
$(document).trigger('close.facebox');
|
||||||
$('body').append( $dialog );
|
} else {
|
||||||
if ( argObject.OK &&
|
$('#gollum-dialog-dialog').remove();
|
||||||
typeof argObject.OK == 'function' ) {
|
}
|
||||||
Dialog.attachEvents( argObject.OK );
|
}
|
||||||
}
|
|
||||||
Dialog.show();
|
Dialog.markup = Dialog.createMarkup( title, body );
|
||||||
},
|
|
||||||
|
if ($.facebox) {
|
||||||
show: function() {
|
$(document).bind('reveal.facebox', function() {
|
||||||
if ( !Dialog.markupCreated ) {
|
if ( argObject.OK &&
|
||||||
debug('Dialog: No markup to show. Please use init first.');
|
typeof argObject.OK == 'function' ) {
|
||||||
} else {
|
Dialog.attachEvents( argObject.OK );
|
||||||
debug('Showing dialog');
|
$($('#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 ) {
|
if ( $.browser.msie ) {
|
||||||
$('#gollum-dialog.dialog').addClass('active');
|
$('#gollum-dialog.dialog').addClass('active');
|
||||||
Dialog.position();
|
Dialog.position();
|
||||||
$('select').css('visibility', 'hidden');
|
$('select').css('visibility', 'hidden');
|
||||||
} else {
|
} else {
|
||||||
$('#gollum-dialog.dialog').css('display', 'none');
|
$('#gollum-dialog.dialog').css('display', 'none');
|
||||||
$('#gollum-dialog-dialog').animate({ opacity: 0 }, {
|
$('#gollum-dialog-dialog').animate({ opacity: 0 }, {
|
||||||
@@ -177,30 +228,36 @@
|
|||||||
$('#gollum-dialog-dialog').css('display', 'block');
|
$('#gollum-dialog-dialog').css('display', 'block');
|
||||||
Dialog.position(); // position this thing
|
Dialog.position(); // position this thing
|
||||||
$('#gollum-dialog-dialog').animate({ opacity: 1 }, {
|
$('#gollum-dialog-dialog').animate({ opacity: 1 }, {
|
||||||
duration: 500
|
duration: 500
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
},
|
||||||
position: function() {
|
|
||||||
var dialogHeight = $('#gollum-dialog-dialog-inner').height();
|
position: function() {
|
||||||
$('#gollum-dialog-dialog-inner')
|
var dialogHeight = $('#gollum-dialog-dialog-inner').height();
|
||||||
.css('height', dialogHeight + 'px')
|
$('#gollum-dialog-dialog-inner')
|
||||||
.css('margin-top', -1 * parseInt( dialogHeight / 2 ));
|
.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) {
|
var debug = function(m) {
|
||||||
if ( Dialog.debugOn
|
if ( Dialog.debugOn
|
||||||
&& typeof console != 'undefined' ) {
|
&& typeof console != 'undefined' ) {
|
||||||
console.log( m );
|
console.log( m );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$.GollumDialog = Dialog;
|
$.GollumDialog = Dialog;
|
||||||
|
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
|||||||
@@ -1,6 +1,88 @@
|
|||||||
// ua
|
// ua
|
||||||
$(document).ready(function() {
|
$(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
|
// ua detection
|
||||||
if ($.browser.mozilla) {
|
if ($.browser.mozilla) {
|
||||||
$('body').addClass('ff');
|
$('body').addClass('ff');
|
||||||
@@ -14,7 +96,7 @@ $(document).ready(function() {
|
|||||||
$('body').addClass('ie8');
|
$('body').addClass('ie8');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($('#minibutton-new-page').length) {
|
if ($('#minibutton-new-page').length) {
|
||||||
$('#minibutton-new-page').removeClass('jaws');
|
$('#minibutton-new-page').removeClass('jaws');
|
||||||
$('#minibutton-new-page').click(function(e) {
|
$('#minibutton-new-page').click(function(e) {
|
||||||
@@ -38,10 +120,12 @@ $(document).ready(function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($('#wiki-wrapper').hasClass('history')) {
|
if ($('#wiki-wrapper').hasClass('history')) {
|
||||||
$('#wiki-history td.checkbox input').each(function() {
|
$('#wiki-history td.checkbox input').each(function() {
|
||||||
$(this).click(highlightChecked);
|
$(this).click(function() {
|
||||||
|
nodeSelector.checkNode($(this));
|
||||||
|
});
|
||||||
if ( $(this).is(':checked') ) {
|
if ( $(this).is(':checked') ) {
|
||||||
nodeSelector.checkNode($(this));
|
nodeSelector.checkNode($(this));
|
||||||
}
|
}
|
||||||
@@ -53,9 +137,7 @@ $(document).ready(function() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ($('#searchbar a#search-submit').length) {
|
if ($('#searchbar a#search-submit').length) {
|
||||||
$.GollumPlaceholder.add($('#searchbar #search-query'));
|
$.GollumPlaceholder.add($('#searchbar #search-query'));
|
||||||
$('#searchbar a#search-submit').click(function(e) {
|
$('#searchbar a#search-submit').click(function(e) {
|
||||||
@@ -67,8 +149,8 @@ $(document).ready(function() {
|
|||||||
$(this).unbind('submit');
|
$(this).unbind('submit');
|
||||||
$(this).submit();
|
$(this).submit();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($('#gollum-revert-form').length &&
|
if ($('#gollum-revert-form').length &&
|
||||||
$('.gollum-revert-button').length ) {
|
$('.gollum-revert-button').length ) {
|
||||||
$('a.gollum-revert-button').click(function(e) {
|
$('a.gollum-revert-button').click(function(e) {
|
||||||
@@ -76,116 +158,4 @@ $(document).ready(function() {
|
|||||||
$('#gollum-revert-form').submit();
|
$('#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