Skip to content

Commit

Permalink
Item9244: minor debugging before release.
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk/HijaxPlugin@8458 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
DavidPatterson authored and DavidPatterson committed Aug 11, 2010
1 parent 5daf4bc commit 090a5e0
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 78 deletions.
28 changes: 14 additions & 14 deletions data/System/HijaxPlugin.txt
Expand Up @@ -40,7 +40,7 @@ You can define additional templates to be referenced by the above parameters in
</verbatim>
* =hijax= relevant templates just need to be wrapped in =%TMPL:DEF{<name>}%%TMPL:END%=

=returntemplate= is the third associated parameter. If this is set and it's not an =oops= script and there's no redirect cache, the redirectCgiQueryHandler adds <code>template=<setting></code> to the url. There is a =nocontent= template provided which wipes out the =content= and =ajaxhead= templates for performance purposes, e.g. you're saving an =%ACTION{}%= to your action list topic and you only want to know that it worked, i.e. a redirect to the =view= script, you don't want the core to put effort in to parsing all those actions so you use this flag.
=returntemplate= is the third associated parameter. If this is set and it's not an =oops= script and there's no redirect cache, the redirectCgiQueryHandler adds <code>template=<setting></code> to the url. There is a =nocontent= template provided which wipes out the =content= and =ajaxhead= templates for performance purposes, e.g. you're saving an =%%NOP%ACTION{}%= to your action list topic and you only want to know that it worked, i.e. a redirect to the =view= script, you don't want the core to put effort in to parsing all those actions so you use this flag.

---++ The =hijax.js= javascript

Expand All @@ -61,28 +61,28 @@ The hijax menu, the CSS selector of the links not to hijax and the jQuery select
A suite of javascript helper functions are also provided as part of the =foswiki.HijaxPlugin= object.
* =serverAction= : can be considered almost as a 1:1 drop in replacement for the jQuery $.ajax() function in your code. It handles login, oops and validate (strikeone) responses. The arguments it accepts as part of a javascript object are:
* async: default true,
* cache: default false,
* dataType: default "json",
* type: default "POST",
* url: the foswiki url you want to call over ajax,
* data: the params to the url, can be as a javascript object or as a jQuery .serialize() string. serverAction ensures that the =cover= parameter contains 'ajax'. If a .serialize() string is passed in, it gets objectified, checked, and rejoined into a string. To avoid the objectify step, it is recommended to use the !HijaxPlugin =asObject= function which takes a jQuery selection as its arguement.
* loading: a jQuery identifier of the DOM element over which a spinner will appear during the ajax request, default is the browser window,
* nooverlay: set to true to prevent an opaque overlay during the ajax request, default false,
* success: the function to execute upon a successful foswiki action, i.e. not an =oops= . The JSON object is passed as the only argument.
* error: the function to execute on an oops response but be careful because an =oops= is not always an error is Foswiki :-( . The JSON object is passed as the only argument.
* target and targetmethod: these are related parameters and are relevant when there has been a successful foswiki action and you want to add the response to the page. See their descriptions under =loadContent= below. Note that if a =target= as well as a =success= function are specified, then both are executed.
* cache: default false,
* dataType: default "json",
* type: default "POST",
* url: the foswiki url you want to call over ajax,
* data: the params to the url, can be as a javascript object or as a jQuery .serialize() string. serverAction ensures that the =cover= parameter contains 'ajax'. If a .serialize() string is passed in, it gets objectified, checked, and rejoined into a string. To avoid the objectify step, it is recommended to use the !HijaxPlugin =asObject= function which takes a jQuery selection as its arguement.
* loading: a jQuery identifier of the DOM element over which a spinner will appear during the ajax request, default is the browser window,
* nooverlay: set to true to prevent an opaque overlay during the ajax request, default false,
* success: the function to execute upon a successful foswiki action, i.e. not an =oops= . The JSON object is passed as the only argument.
* error: the function to execute on an oops response but be careful because an =oops= is not always an error is Foswiki :-( . The JSON object is passed as the only argument.
* target and targetmethod: these are related parameters and are relevant when there has been a successful foswiki action and you want to add the response to the page. See their descriptions under =loadContent= below. Note that if a =target= as well as a =success= function are specified, then both are executed.
* =showResponse= : this is the function used by =hijax= as the success action passed into =serverAction= . See the description above.
* =showOops= : this is the function used by =hijax= to present an =oops= response to the user. See the description above.
* =loadContent= : this is the low-level function used by =showResponse= and =showOops= . It takes three arguments:
* response: if this is an object it is assumed to be the JSON object returned by the !HijaxPlugin on the server and used to retrieve the content parameter, and the head and body parameters (from ADDTOZONEs). Each element of the head and body content is checked, if it is inline css or js it gets added to the respective zone, and if it is a file, it is checked to see if it is already on the page and added if not. =response= can also be a string.
* $target: this is a jQuery identifier of the DOM element that should contain the response,
* method: this is the jQuery method for how the response should be added to the $target: 'replaceWith', 'append', 'prepend' or 'html'. Default is =html= .
* $target: this is a jQuery identifier of the DOM element that should contain the response,
* method: this is the jQuery method for how the response should be added to the $target: 'replaceWith', 'append', 'prepend' or 'html'. Default is =html= .
* =sortUserlists= : alphabetically sorts select elements that have the class 'userlist'.
* =parseURL= : this is a customisation of a function by James Padolsey. As well as exposing the usual elements of a URL in a js object it also exposes the Foswiki relevant web, topic and script.

See the =hijax.js= file for further comments and functions. Lots of code examples can be found in the javascript of the !FullCalendar and Object plugins.

---++ The %RAND% macro
---++ The %%NOP%RAND% macro

This provides a random integer from the base 999999. With elements being incrementally added to a page via ajax, applications can use this as a way of having a simple unique identifier.

Expand Down
116 changes: 58 additions & 58 deletions data/System/JQueryMarkItUpEditor.txt
@@ -1,28 +1,31 @@
%META:TOPICINFO{author="ProjectContributor" date="1276173208" format="1.1" reprev="1.1" version="1.1"}%
<verbatim>
%STARTINCLUDE%
<link rel="stylesheet" type="text/css" href="%ATTACHURL%/style.css" />
<link rel="stylesheet" type="text/css" href="%ATTACHURL%/wikistyle.css" />
<style>
.markItUp {
width: 670px;
}
.markItUpEditor {
padding:5px 5px 5px 5px;
background-image:none;
}
.markItUpButton1, .markItUpButton2, .markItUpButton3, .markItUpButton4, .markItUpButton5, .markItUpButton6 {
display: %IF{"'%headingbuttons%' = 'yes'" then="inline" else="none"}%;
}
</style>
<script type="text/javascript" src="%ATTACHURL%/jquery.markitup.pack.js"></script>
<script language="javascript">
myWikiSettings = {
previewParserPath: '%SCRIPTURL{rest}%/RenderPlugin/render', // path to your Wiki parser
%ADDTOZONE{"head" topic="%TOPIC%" section="head"}%
%ADDTOZONE{"body" requires="JQUERYPLUGIN" text="
%INCLUDE{"%TOPIC%" section="body" headingbuttons="%headingbuttons%"}%
"}%
%STOPINCLUDE%
%STARTSECTION{type="section" name="body"}%
<script type='text/javascript' src='%ATTACHURL%/jquery.markitup.pack.js'></script>
<script language='javascript'>
jQuery(function(){
$('%target%').markItUp(miueWikiSettings)%IF{"'%headingbuttons%' = 'yes'" else="
.parent().find('.markItUpButton1, .markItUpButton2, .markItUpButton3, .markItUpButton4, .markItUpButton5, .markItUpButton6').hide()"}%;
});
</script>
%ENDSECTION{name="body"}%
Note that miueWikiSettings is being added to head because in the body it gets 'rendered' which screws things up.
%STARTSECTION{type="section" name="head"}%
<link rel='stylesheet' type='text/css' href='%ATTACHURL%/style.css' />
<link rel='stylesheet' type='text/css' href='%ATTACHURL%/wikistyle.css' />
<script language='javascript'>
var miueWikiSettings = {
previewParserPath: '%SCRIPTURL{rest}%/RenderPlugin/render',
previewTemplatePath: '%ATTACHURL%/Preview.html',
previewParserVar: 'text',
previewAutoRefresh: 0,
resizeHandle: true,
previewAutoRefresh: 0,
resizeHandle: true,
onShiftEnter: {keepDefault:false, replaceWith:'\n\n'},
onTab: {keepDefault:false, openWith:' * ', placeHolder:''},
markupSet: [
Expand All @@ -33,58 +36,55 @@ myWikiSettings = {
{name:'Heading 5', key:'5', openWith:'---+++++ ', placeHolder:'Your title here...' },
{name:'Heading 6', key:'6', openWith:'---++++++ ', placeHolder:'Your title here...' },
{separator:'---------------' },
{name:'Bold', key:'B', openWith:"*", closeWith:"*"},
{name:'Italic', key:'I', openWith:"_", closeWith:"_"},
{name:'Bold', key:'B', openWith:'*', closeWith:'*'},
{name:'Italic', key:'I', openWith:'_', closeWith:'_'},
{name:'Stroke through', key:'S', openWith:'<del>', closeWith:'</del>'},
{separator:'---------------' },
{name:'Bulleted list', key:'U', openWith:' * '},
{name:'Numeric list', key:'O', openWith:' 1 '},
{separator:'---------------' },
{name:'Picture', key:'P', replaceWith:'<img src="[![Source:!:http://]!]" alt="[![Alternative text]!]" />' },
{name:'Link', key:"L", openWith:"[[[![Link]!]][", closeWith:']]', placeHolder:'Your text to link here...' },
{name:'Url', openWith:"[[[![Url:!:http://]!]][", closeWith:']]', placeHolder:'Your text to link here...' },
{name:'Picture', key:'P', replaceWith:'<img src="[![Source:!:%<nop>ATTACHURL%/]!]" alt="[![Alternative text]!]" />' },
{name:'Link', key:'L', openWith:'[[[![Link]!]][', closeWith:']]', placeHolder:'Your text to link here...' },
{name:'Url', openWith:'[[[![Url:!:http://]!]][', closeWith:']]', placeHolder:'Your text to link here...' },
{separator:'---------------' },
{name:'Quotes', openWith:'<blockquote>', closeWith:'</blockquote>', placeHolder:''},
{name:'Code', openWith:'(!(<source lang="[![Language:!:php]!]">|!|<pre>)!)', closeWith:'(!(</source>|!|</pre>)!)'},
{separator:'---------------' },
{name:'Colors', openWith:'%NOP%%[![Color in UPPERCASE]!]%', closeWith:'%ENDC%NOP%OLOR%', dropMenu: [
{name:'Yellow', openWith:'%YEL%NOP%LOW%', closeWith:'%ENDC%NOP%OLOR%', className:"col1-1" },
{name:'Orange', openWith:'%ORA%NOP%NGE%', closeWith:'%ENDC%NOP%OLOR%', className:"col1-2" },
{name:'Red', openWith:'%RE%NOP%D%', closeWith:'%ENDC%NOP%OLOR%', className:"col1-3" },
{name:'Blue', openWith:'%BL%NOP%UE%', closeWith:'%ENDC%NOP%OLOR%', className:"col2-1" },
{name:'Purple', openWith:'%PUR%NOP%PLE%', closeWith:'%ENDC%NOP%OLOR%', className:"col2-2" },
{name:'Green', openWith:'%GRE%NOP%EN%', closeWith:'%ENDC%NOP%OLOR%', className:"col2-3" },
{name:'White', openWith:'%WH%NOP%ITE%', closeWith:'%ENDC%NOP%OLOR%', className:"col3-1" },
{name:'Gray', openWith:'%GR%NOP%AY%', closeWith:'%ENDC%NOP%OLOR%', className:"col3-2" },
{name:'Black', openWith:'%BLA%NOP%CK%', closeWith:'%ENDC%NOP%OLOR%', className:"col3-3" }
{name:'Colors', openWith:'%[![Color in UPPERCASE]!]%', closeWith:'%ENDCOLOR%', dropMenu: [
{name:'Yellow', openWith:'%<nop>YELLOW%', closeWith:'%<nop>ENDCOLOR%', className:'col1-1' },
{name:'Orange', openWith:'%<nop>ORANGE%', closeWith:'%<nop>ENDCOLOR%', className:'col1-2' },
{name:'Red', openWith:'%<nop>RED%', closeWith:'%<nop>ENDCOLOR%', className:'col1-3' },
{name:'Blue', openWith:'%<nop>BLUE%', closeWith:'%<nop>ENDCOLOR%', className:'col2-1' },
{name:'Purple', openWith:'%<nop>PURPLE%', closeWith:'%<nop>ENDCOLOR%', className:'col2-2' },
{name:'Green', openWith:'%<nop>GREEN%', closeWith:'%<nop>ENDCOLOR%', className:'col2-3' },
{name:'White', openWith:'%<nop>WHITE%', closeWith:'%<nop>ENDCOLOR%', className:'col3-1' },
{name:'Gray', openWith:'%<nop>GRAY%', closeWith:'%<nop>ENDCOLOR%', className:'col3-2' },
{name:'Black', openWith:'%<nop>BLACK%', closeWith:'%<nop>ENDCOLOR%', className:'col3-3' }
]},
{name:'Smilies', replaceWith:'', dropMenu: [
{name:'smile', replaceWith:' <nop>:) ', className:"col1-1" },
{name:'cool', replaceWith:' <nop>8-) ', className:"col1-2" },
{name:'indifferent', replaceWith:' <nop>:-I ', className:"col1-3" },
{name:'frown', replaceWith:' <nop>:( ', className:"col2-1" },
{name:'embarrassment', replaceWith:' <nop>:o ', className:"col2-2" },
{name:'big grin', replaceWith:' <nop>:D ', className:"col2-3" },
{name:'wink', replaceWith:' <nop>;) ', className:"col3-1" },
{name:'stick out tongue', replaceWith:' <nop>:p ', className:"col3-2" },
{name:'roll eyes (sarcastic)', replaceWith:' <nop>:rolleyes: ', className:"col3-3" },
{name:'mad!', replaceWith:' <nop>:mad: ', className:"col4-1" },
{name:'eek!', replaceWith:' <nop>:eek: ', className:"col4-2" },
{name:'confused', replaceWith:' <nop>:confused: ', className:"col4-3" },
{name:'hehe!', replaceWith:' <nop>:devil: ', className:"col5-1" },
{name:'hehe! (friendly)', replaceWith:' <nop>:devilish: ', className:"col5-2" },
{name:'sealed lips', replaceWith:' <nop>:-X ', className:"col5-3" },
{name:'thumbs up', replaceWith:' <nop>:ok: ', className:"col6-1" },
{name:'yes', replaceWith:' <nop>:yes: ', className:"col6-2" },
{name:'no', replaceWith:' <nop>:no: ', className:"col6-3" }
{name:'smile', replaceWith:' :) ', className:'col1-1' },
{name:'cool', replaceWith:' 8-) ', className:'col1-2' },
{name:'indifferent', replaceWith:' :-I ', className:'col1-3' },
{name:'frown', replaceWith:' :( ', className:'col2-1' },
{name:'embarrassment', replaceWith:' :o ', className:'col2-2' },
{name:'big grin', replaceWith:' :D ', className:'col2-3' },
{name:'wink', replaceWith:' ;) ', className:'col3-1' },
{name:'stick out tongue', replaceWith:' :p ', className:'col3-2' },
{name:'roll eyes (sarcastic)', replaceWith:' :rolleyes: ', className:'col3-3' },
{name:'mad!', replaceWith:' :mad: ', className:'col4-1' },
{name:'eek!', replaceWith:' :eek: ', className:'col4-2' },
{name:'confused', replaceWith:' :confused: ', className:'col4-3' },
{name:'hehe!', replaceWith:' :devil: ', className:'col5-1' },
{name:'hehe! (friendly)', replaceWith:' :devilish: ', className:'col5-2' },
{name:'sealed lips', replaceWith:' :-X ', className:'col5-3' },
{name:'thumbs up', replaceWith:' :ok: ', className:'col6-1' },
{name:'yes', replaceWith:' :yes: ', className:'col6-2' },
{name:'no', replaceWith:' :no: ', className:'col6-3' }
]},
{separator:'---------------' },
{name:'Preview', call:'preview', className:'preview'}
]
}
jQuery(function() {
$('%target%').markItUp(myWikiSettings);
});
};
</script>
%STOPINCLUDE%
%ENDSECTION{name="head"}%
</verbatim>
10 changes: 5 additions & 5 deletions pub/System/HijaxPlugin/hijax.js
Expand Up @@ -308,6 +308,9 @@ hijax : function(el){
var myURL = foswiki.HijaxPlugin.parseURL(el.href);
if (myURL.hostname != foswiki.HijaxPlugin.pageURL.hostname) return;
switch (myURL.script) {
case 'edit':
if (!myURL.params.nowysiwyg) break;
// we can't support wysiwyg editing over ajax yet
case ''||'view':
if (myURL.query == '') {
// get the link's position and show the menu
Expand All @@ -322,13 +325,13 @@ hijax : function(el){
}
case 'oops':
if (myURL.params.cover && myURL.params.cover.search('print') !== -1) break;
case 'attach':
// case 'attach':
// not ready to handle upload over ajax yet, need to look at the jQuery Form Plugin
case 'compare':
case 'manage':
case 'rename':
// case 'rest':
// for now, assume that it already has an associated js eventHandler from its FW plugin
case 'edit':
$hpmenu.find('li').not('#hppreviewli').hide();
$('#hppreviewli a').attr('href',el.href);
positionMenu(el);
Expand Down Expand Up @@ -440,9 +443,6 @@ loadContent : function(response, $target, method) {
default:
$target.html(content);
}
// return $('#responseContent').html(content)
// .end().parent().css("z-index","2000").centerInClient()
// .fadeIn('slow').end();
if (head) appendTo('head',head);
if (body) appendTo('body',body);
return $target;
Expand Down
12 changes: 11 additions & 1 deletion pub/System/JQueryMarkItUpEditor/wikistyle.css
@@ -1,7 +1,9 @@
/* -------------------------------------------------------------------
// markItUp!
// By Jay Salvat - http://markitup.jaysalvat.com/
// ------------------------------------------------------------------*/
// ------------------------------------------------------------------
// the following css taken from the markItUp demo and customised
// for use on the Foswiki platform */
.markItUp .markItUpButton1 a {
background-image:url(images/h1.png);
}
Expand Down Expand Up @@ -175,3 +177,11 @@
.markItUp .markItUpButton18 .col6-3 a {
background-image:url(smilies/no.gif);
}

.markItUp {
width: 90%;
}
.markItUpEditor {
padding:5px 5px 5px 5px;
background-image:none;
}

0 comments on commit 090a5e0

Please sign in to comment.