Skip to content

Commit

Permalink
Item8956:
Browse files Browse the repository at this point in the history
    * css fixes for simple BUTTON
    * padding fixes to tags in textboxlist formfield
    * remove type="text/javascrip" as per html5
    * added initializer for jquery.wikiword
    * fixed jquery.debug being used without firebug console
    * fixed initialization of title/values in textboxlist formfield 



git-svn-id: http://svn.foswiki.org/trunk@7282 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
MichaelDaum authored and MichaelDaum committed Apr 28, 2010
1 parent 5e238f1 commit c1b1285
Show file tree
Hide file tree
Showing 17 changed files with 110 additions and 75 deletions.
41 changes: 17 additions & 24 deletions JQueryPlugin/data/System/JQueryWikiWord.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" comment="reprev" date="1265666211" format="1.1" reprev="1.4" version="1.4"}%
%META:TOPICINFO{author="ProjectContributor" comment="reprev" date="1271756116" format="1.1" reprev="1.4" rev="4" version="1.4"}%
%META:TOPICPARENT{name="JQueryPlugin"}%
---+ %TOPIC%
%JQPLUGINS{"wikiword"
Expand All @@ -16,13 +16,26 @@ normalized to be a valid <nop>WikiWord. For example, this can be used
to derive a topic name from a free-form topic title text.
%ENDSECTION{"summary"}%

---++ Foswiki integration

Add the =jqWikiWord= to an html input field and specify the source from which
to derive the !WikiWord using metadata of the following format:
<verbatim class="js">
{
source:'selector', /* e.g. '#projectTitle' */
initial:'initial value', /* e.g. 'Project...' */
prefix:'string to be prefixed to the wiki word', /* e.g. 'Project' */
suffix:'string to be appended to the wiki word' /* e.g. 'AUTOINC0' */
}
</verbatim>

---++ Examples
<div class="foswikiFormSteps">
<h2>Add Project</h2>
<form action="%SCRIPTURLPATH{"edit"}%/%WEB%" />
<div class="foswikiFormStep">
<h3>Title:</h3>
<input type="text" id="prjTitle" size="30" name="TopicTitle" />
<input type="text" id="prjTitle" size="60" name="TopicTitle" />
</div>
<div class="foswikiFormStep">
<h3>Year:</h3>
Expand All @@ -39,32 +52,12 @@ to derive a topic name from a free-form topic title text.
</div>
<div class="foswikiFormStep">
<h3>Project topic:</h3>
<input type="text" id="prjTopic" size="30" name="topic" />
<input type="text" id="prjTopic" size="60" name="topic" class="jqWikiWord {source:'#prjTitle, #prjYear', prefix:'Project', initial:'Project...', suffix:'AUTOINC0'}" />
</div>
<div class="foswikiFormStep foswikiFormLast">
%BUTTON{"Submit" icon="tick" type="submit"}%
%CLEAR%
</div>
</div>

%JQREQUIRE{"wikiword"}%
%ADDTOZONE{"body" topic="%TOPIC%" section="init" requires="JQUERYPLUGIN::WIKIWORD"}%

---++ !JavaScript initialization
<verbatim class="tml">
%STARTSECTION{"init"}%
<literal>
<script type='text/javascript'>
(function($) {
$(function() {
$('#prjTopic').wikiword(
'#prjTitle, #prjYear', {
prefix: 'Project',
initial: 'Project...'
});
});
})(jQuery);
</script>
</literal>
%ENDSECTION{"init"}%
</verbatim>
%JQREQUIRE{"wikiword"}%
14 changes: 12 additions & 2 deletions JQueryPlugin/lib/Foswiki/Form/Rating.pm
Expand Up @@ -65,10 +65,15 @@ sub renderForEdit {
Foswiki::Plugins::JQueryPlugin::createPlugin("rating");

my $result = "<div class='jqRating {$this->{attributes}}'>\n";
my $found = 0;
my $intVal = ($value)?$value:0;
foreach my $item (@{ $this->getOptions() }) {
$result .= '<input type="radio" name="' . $this->{name} . '" ' . ' value="' . $item . '" ';
$result .= 'title="'.$this->{valueMap}{$item}.'" ' if $this->{valueMap}{$item};
$result .= 'checked="checked" ' if $item eq $value;
if ($item == $intVal || ($item > $intVal && !$found)) {
$found = 1;
$result .= 'checked="checked" ';
}
$result .= "/>\n";
}
$result .= '<input type="hidden" name="'.$this->{name}.'" value="" />';
Expand All @@ -83,11 +88,16 @@ sub renderForDisplay {
Foswiki::Plugins::JQueryPlugin::createPlugin("rating");

my $result = "<div class='jqRating {$this->{attributes}}'>\n";
my $found = 0;
my $intVal = ($value)?$value:0;
foreach my $item (@{ $this->getOptions() }) {
$result .= '<input type="radio" name="' . $this->{name} . '" ' . ' value="' . $item . '" ';
$result .= 'title="'.$this->{valueMap}{$item}.'" ' if $this->{valueMap}{$item};
$result .= 'disabled="disabled" ';
$result .= 'checked="checked" ' if $item eq $value;
if ($item == $intVal || ($item > $intVal && !$found)) {
$found = 1;
$result .= 'checked="checked" ';
}
$result .= "/>\n";
}
$result .= "</div>\n";
Expand Down
2 changes: 1 addition & 1 deletion JQueryPlugin/lib/Foswiki/Form/Textboxlist.pm
Expand Up @@ -54,7 +54,7 @@ sub renderForEdit {
);

# SMELLL: in case this gets loaded via ajax
$field .= "<script type='text/javascript' src='%PUBURLPATH%/%SYSTEMWEB%/JQueryPlugin/plugins/textboxlist/jquery.textboxlist.init.js'></script>";
$field .= "<script src='%PUBURLPATH%/%SYSTEMWEB%/JQueryPlugin/plugins/textboxlist/jquery.textboxlist.init.js'></script>";

return ('',$field);
}
Expand Down
15 changes: 9 additions & 6 deletions JQueryPlugin/lib/Foswiki/Plugins/JQueryPlugin.pm
Expand Up @@ -34,7 +34,7 @@ use vars qw(


$VERSION = '$Rev: 20090710 (2009-07-10) $';
$RELEASE = '3.42';
$RELEASE = '3.50';
$SHORTDESCRIPTION = 'jQuery <nop>JavaScript library for Foswiki';
$NO_PREFS_IN_TOPIC = 1;

Expand Down Expand Up @@ -240,13 +240,16 @@ Handles the =%<nop>JQREQUIRE% tag.
sub handleJQueryRequire {
my ($session, $params, $theTopic, $theWeb) = @_;

my $pluginName = $params->{_DEFAULT};
my $plugins = $params->{_DEFAULT} || '';
my $warn = $params->{warn} || '';
my $plugin = createPlugin($pluginName, $session);
return "<span class='foswikiAlert'>Error: no such plugin $pluginName</span>"
if !$plugin && $warn ne 'off' ;
my $errorMsg = '';
foreach my $pluginName (split(/\s*,\s*/, $plugins)) {
my $plugin = createPlugin($pluginName, $session);
$errorMsg .= "<div class='foswikiAlert'>Error: no such plugin $pluginName</div>"
if !$plugin && $warn ne 'off' ;
}

return '';
return $errorMsg;
}

=begin TML
Expand Down
2 changes: 1 addition & 1 deletion JQueryPlugin/lib/Foswiki/Plugins/JQueryPlugin/FOSWIKI.pm
Expand Up @@ -89,7 +89,7 @@ HERE
$js .= '.uncompressed' if $this->{debug};
$js .= '.js?version='.$this->{version};

my $footer = "<script type='text/javascript' src='%PUBURLPATH%/%SYSTEMWEB%/JQueryPlugin/plugins/foswiki/$js'></script>\n";
my $footer = "<script src='%PUBURLPATH%/%SYSTEMWEB%/JQueryPlugin/plugins/foswiki/$js'></script>\n";

Foswiki::Func::addToZone('head', 'JQUERYPLUGIN::FOSWIKI', $header, 'JQUERYPLUGIN');
Foswiki::Func::addToZone('body', 'JQUERYPLUGIN::FOSWIKI', $footer, 'JQUERYPLUGIN');
Expand Down
3 changes: 3 additions & 0 deletions JQueryPlugin/lib/Foswiki/Plugins/JQueryPlugin/MANIFEST
Expand Up @@ -620,6 +620,9 @@ pub/System/JQueryPlugin/plugins/validate/Makefile 0644
pub/System/JQueryPlugin/plugins/wikiword/jquery.wikiword.js 0644
pub/System/JQueryPlugin/plugins/wikiword/jquery.wikiword.js.gz 0644
pub/System/JQueryPlugin/plugins/wikiword/jquery.wikiword.uncompressed.js 0644
pub/System/JQueryPlugin/plugins/wikiword/jquery.wikiword.init.js 0644
pub/System/JQueryPlugin/plugins/wikiword/jquery.wikiword.init.js.gz 0644
pub/System/JQueryPlugin/plugins/wikiword/jquery.wikiword.init.uncompressed.js 0644
pub/System/JQueryPlugin/plugins/wikiword/Makefile 0644
pub/System/JQueryPlugin/themes/base/images/ui-bg_flat_0_aaaaaa_40x100.png 0644
pub/System/JQueryPlugin/themes/base/images/ui-bg_glass_55_fbf9ee_1x400.png 0644
Expand Down
2 changes: 1 addition & 1 deletion JQueryPlugin/lib/Foswiki/Plugins/JQueryPlugin/Plugin.pm
Expand Up @@ -141,7 +141,7 @@ sub renderJS {

$text =~ s/\.js$/.uncompressed.js/ if $this->{debug};
$text .= '?version='.$this->{version};
$text = "<script type='text/javascript' src='$this->{puburl}/$text'></script>\n";
$text = "<script src='$this->{puburl}/$text'></script>\n";

return $text;
}
Expand Down
4 changes: 2 additions & 2 deletions JQueryPlugin/lib/Foswiki/Plugins/JQueryPlugin/Plugins.pm
Expand Up @@ -56,10 +56,10 @@ sub init () {
# load jquery
my $jQuery = $Foswiki::cfg{JQueryPlugin}{JQueryVersion} || "jquery-1.3.2";
$jQuery .= ".uncompressed" if $debug;
my $footer = "<script type='text/javascript' src='%PUBURLPATH%/%SYSTEMWEB%/JQueryPlugin/$jQuery.js'></script>";
my $footer = "<script src='%PUBURLPATH%/%SYSTEMWEB%/JQueryPlugin/$jQuery.js'></script>";

# switch on noconflict mode
$footer .= "\n<script type='text/javascript' src='%PUBURLPATH%/%SYSTEMWEB%/JQueryPlugin/jquery.noconflict.js'></script>"
$footer .= "\n<script src='%PUBURLPATH%/%SYSTEMWEB%/JQueryPlugin/jquery.noconflict.js'></script>"
if $Foswiki::cfg{JQueryPlugin}{NoConflict};

Foswiki::Func::addToZone('body', 'JQUERYPLUGIN', $footer);
Expand Down
2 changes: 1 addition & 1 deletion JQueryPlugin/lib/Foswiki/Plugins/JQueryPlugin/UI.pm
Expand Up @@ -75,7 +75,7 @@ sub init {
my $messagePath = $Foswiki::cfg{SystemWebName}.'/JQueryPlugin/i18n/ui.datepicker-'.$langTag.'.js';
my $messageFile = $Foswiki::cfg{PubDir}.'/'.$messagePath;
if (-f $messageFile) {
my $text .= "<script type='text/javascript' src='$Foswiki::cfg{PubUrlPath}/$messagePath'></script>\n";
my $text .= "<script src='$Foswiki::cfg{PubUrlPath}/$messagePath'></script>\n";
Foswiki::Func::addToZone('body', "JQUERYPLUGIN::UI::LANG", $text, 'JQUERYPLUGIN::UI');
}
}
Expand Down
2 changes: 1 addition & 1 deletion JQueryPlugin/lib/Foswiki/Plugins/JQueryPlugin/VALIDATE.pm
Expand Up @@ -71,7 +71,7 @@ sub init {
my $messagePath = $Foswiki::cfg{SystemWebName}.'/JQueryPlugin/plugins/validate/localization/messages_'.$langTag.'.js';
my $messageFile = $Foswiki::cfg{PubDir}.'/'.$messagePath;
if (-f $messageFile) {
my $text .= "<script type='text/javascript' src='$Foswiki::cfg{PubUrlPath}/$messagePath'></script>\n";
my $text .= "<script src='$Foswiki::cfg{PubUrlPath}/$messagePath'></script>\n";
Foswiki::Func::addToZone('body', "JQUERYPLUGIN::VALIDATE::LANG", $text, 'JQUERYPLUGIN::VALIDATE');
}

Expand Down
4 changes: 2 additions & 2 deletions JQueryPlugin/lib/Foswiki/Plugins/JQueryPlugin/WIKIWORD.pm
Expand Up @@ -42,10 +42,10 @@ sub new {
my $this = bless($class->SUPER::new(
$session,
name => 'WikiWord',
version => '1.0',
version => '1.1',
author => 'Michael Daum',
homepage => 'http://michaeldaumconsulting.com',
javascript => ['jquery.wikiword.js'],
javascript => ['jquery.wikiword.js', 'jquery.wikiword.init.js'],
), $class);

return $this;
Expand Down
Expand Up @@ -52,7 +52,7 @@
float:left;
height:23px;
line-height:23px;
padding:0px 8px;
padding:0px 5px 0px 8px;
margin:0px 3px 0px 0px;
font-size:13px;
/* ie 6 */
Expand All @@ -62,6 +62,10 @@
.jqButton.simple span {
padding:0px;
}
.jqButtonSimple span span,
.jqButton.simple span span {
padding:0px 0px 0px 23px;
}
.jqButton .jqButtonIcon {
background-position:0px 4px;
background-repeat:no-repeat;
Expand Down
Expand Up @@ -18,11 +18,7 @@ var DEBUG = true;
if (!("console" in window) || !("firebug" in console)){
var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
// create the logging div
$(document).ready(
function(){
$(document.body).append('<div id="DEBUG"><ol></ol></div>');
}
);
$('body').append('<div id="DEBUG"><ol></ol></div>');
// attach a function to each of the firebug methods
window.console = {};
for (var i = 0; i < names.length; ++i){
Expand Down
Expand Up @@ -8,7 +8,7 @@
margin:2px 0px;
}
.jqTextboxListValue {
padding:0px 15px 2px 5px;
padding:1px 15px 1px 5px;
border:1px solid #CAD8F3;
margin:2px 5px 2px 0px;
background:#DEE7F8;
Expand Down

0 comments on commit c1b1285

Please sign in to comment.