Skip to content

Commit

Permalink
Item12511: added support for HTML5 data
Browse files Browse the repository at this point in the history
- this is stage 1 of transitioning over from metadata to html5 data
- added "use strict" where applicable
- fixed some js errors pointed out by jslint
- using prop() instead of attr() where appropriate to be upgrade safe
  • Loading branch information
MichaelDaum committed Dec 6, 2017
1 parent 287e562 commit 1be1659
Show file tree
Hide file tree
Showing 36 changed files with 99 additions and 59 deletions.
5 changes: 2 additions & 3 deletions JQueryPlugin/data/System/JQueryLiveQuery.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" date="1456220586" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" date="1512570593" format="1.1" version="1"}%
%META:TOPICPARENT{name="JQueryPlugin"}%
---+ %TOPIC%
%JQPLUGINS{"livequery"
Expand Down Expand Up @@ -160,10 +160,9 @@ processed by an event handler registered using =livequery=.
%STARTSECTION{"loadme"}% <div class="trigger">hello world</div> %ENDSECTION{"loadme"}%
</verbatim>


This is a JQueryLoader that will load the content of the =loadme= section below one with a delay of two second.

<div id="loader" class="jqLoader {section:'loadme', delay:2000}">
<div id="loader" class="jqLoader" data-section="loadme" data-delay="2000">
%ICON{"processing"}%
</div>

Expand Down
10 changes: 5 additions & 5 deletions JQueryPlugin/data/System/JQueryLoader.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" date="1456220586" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" date="1512570593" format="1.1" version="1"}%
%META:TOPICPARENT{name="JQueryPlugin"}%
---+!! %TOPIC%
%JQPLUGINS{"loader"
Expand All @@ -23,10 +23,10 @@ Then add the ==jqLoader== css class to the div (or verbatim) element which will
a container for the content to be loaded. Any ==jqLoader== container requires either
an ==url== or a ==section== parameter to specify the location from where to load the content.

Parameter are specified using JQueryMetadata, as in
Parameter are specified using HTML5 data, as in

<verbatim class="html">
<div class="jqLoader {key:'value', ....}"></div>
<div class="jqLoader" data-key1="value1" data-key2="value2" ...></div>
</verbatim>

| *Parameter* | *Description* | *Default* |
Expand Down Expand Up @@ -61,7 +61,7 @@ events can be used to hook your own callbacks to be processed when they are fire

<verbatim class="tml">
%JQREQUIRE{"loader"}%
<div class="jqLoader {section:'recentchanges'}" id="myLoader">
<div class="jqLoader" data-section="recentchanges" id="myLoader">
<verbatim>
%STARTSECTION{"recentchanges"}%<!-- -->
%SEARCH{
Expand All @@ -82,7 +82,7 @@ events can be used to hook your own callbacks to be processed when they are fire
... if installed:

%JQREQUIRE{"loader"}%
<div class="jqLoader {section:'recentchanges', effect:'%CALCULATE{$FILTER([^a-zA-Z0-9 ], %URLPARAM{"effect" default="fade" }%)}%'}" id="myLoader"></div>
<div class="jqLoader" id="myLoader" data-section="recentchanges" data-effect="%URLPARAM{"effect" default="fade" encode="safe"}%" ></div>

<div class="foswikiLeft">
<label for="effect"><b>Effect:</b></label>
Expand Down
6 changes: 3 additions & 3 deletions JQueryPlugin/data/System/JQueryTextboxList.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" date="1456220586" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" date="1512570593" format="1.1" version="1"}%
%META:TOPICPARENT{name="JQueryPlugin"}%
---+ %TOPIC%
%JQPLUGINS{"textboxlist"
Expand All @@ -13,7 +13,7 @@

---++ Description
%STARTSECTION{"summary"}%
Turns a text input into a Facebook like list widget with autocompletion.
Turns a text input into a list widget with autocompletion.
This plugin adds a new formfield type =textboxlist= to DataForms.
%ENDSECTION{"summary"}%

Expand Down Expand Up @@ -48,7 +48,7 @@ In both cases =options= is a json object to customized the textboxlist to your n
| listValueClass | css class of values in the list | jqTextboxListValue |
| closeClass | css class of the close button of a list value | jqTextboxListClose |
| enableClose | boolean flag toggling the display of a close button on a list value | true |
| doSort | boolean flag enabling to sort list values when displaying them | false |
| sorting | option to enable sorting of the list of values, can =true=, =false= or =manual= | manual |
| inputName | name of the input element used for list values; equals to the name of the original input field if undefined | undefined |
| resetControl | jquery selector to specify a reset button; will revert changes to the initial list of values | undefined |
| clearControl | jquery selector to specify a clear button that will empty the textboxlist | undefined |
Expand Down
2 changes: 1 addition & 1 deletion JQueryPlugin/lib/Foswiki/Plugins/JQueryPlugin/LIVEQUERY.pm
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ sub new {
my $this = bless(
$class->SUPER::new(
name => 'LiveQuery',
version => '1.3.1',
version => '1.3.6',
author => 'Brandon Aaron, Alexander Zaytsev',
homepage => 'https://github.com/hazzik/livequery',
javascript => ['jquery.livequery.js'],
Expand Down
2 changes: 1 addition & 1 deletion JQueryPlugin/lib/Foswiki/Plugins/JQueryPlugin/LOADER.pm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ sub new {
my $this = bless(
$class->SUPER::new(
name => 'Loader',
version => '2.11',
version => '2.12',
author => 'Michael Daum',
homepage => 'http://foswiki.org/Extensions/JQueryPlugin',
tags => 'LOADER',
Expand Down
2 changes: 1 addition & 1 deletion JQueryPlugin/lib/Foswiki/Plugins/JQueryPlugin/STARS.pm
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ sub new {
my $this = bless(
$class->SUPER::new(
name => 'Stars',
version => '2.00',
version => '2.10',
author => 'Michael Daum',
homepage => 'http://foswiki.org/Extensions/JQueryPlugin',
css => [ 'jquery.stars.css', ],
Expand Down
12 changes: 6 additions & 6 deletions JQueryPlugin/lib/Foswiki/Plugins/JQueryPlugin/SUPERFISH.pm
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ sub new {

my $this = bless(
$class->SUPER::new(
name => 'Superfish',
version => '1.7.7',
author => 'Joel Birch',
homepage => 'http://users.tpg.com.au/j_birch/plugins/superfish/',
javascript => ['jquery.superfish.js'],
css => ['jquery.superfish.css'],
name => 'Superfish',
version => '1.7.7',
author => 'Joel Birch',
homepage => 'https://superfish.joelbirch.co/',
javascript => ['jquery.superfish.js'],
css => ['jquery.superfish.css'],
dependencies => ['hoverintent'],
),
$class
Expand Down
4 changes: 2 additions & 2 deletions JQueryPlugin/lib/Foswiki/Plugins/JQueryPlugin/TEXTBOXLIST.pm
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ sub new {
my $this = bless(
$class->SUPER::new(
name => 'TextboxList',
version => '1.01',
version => '2.11',
author => 'Michael Daum',
homepage => 'http://foswiki.org/Extensions/JQueryPlugin',
css => ['jquery.textboxlist.css'],
Expand All @@ -47,7 +47,7 @@ sub new {
__END__
Foswiki - The Free and Open Source Wiki, http://foswiki.org/
Copyright (C) 2010-2016 Foswiki Contributors. Foswiki Contributors
Copyright (C) 2010-2017 Foswiki Contributors. Foswiki Contributors
are listed in the AUTHORS file in the root of this distribution.
NOTE: Please extend that file, not this notice.
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
"use strict";
var $j = jQuery.noConflict();
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"use strict";
jQuery(function($) {
var defaults = {
selectFirst:false,
Expand All @@ -14,7 +15,7 @@ jQuery(function($) {
$this.attr("autocomplete")
|| $this[0].getAttribute("autocomplete") /* fix for firefox-4 */
|| '',
options = $.extend({}, defaults, $this.metadata());
options = $.extend({}, defaults, $this.data(), $this.metadata());

if (!urlOrData.match("^https?://")) {
urlOrData = urlOrData.split(/\s*,\s*/);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"use strict";
jQuery(function($) {
$(".jqCycle:not(.jqInitedCycle)").livequery(function() {
var $this = $(this);
var opts = $.extend({}, $this.metadata());
var opts = $.extend({}, $this.data(), $this.metadata());
$this.addClass(".jqInitedCycle").cycle(opts);
});
});
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* jQuery fluid font plugin 1.0
* jQuery fluid font plugin 1.01
*
* Copyright (c) 2009-2016 Foswiki Contributors http://foswiki.org
* Copyright (c) 2009-2017 Foswiki Contributors http://foswiki.org
*
* inspired by TextZooming by James Newbery http://www.tinnedfruit.com/sandbox/textzoom.html
*
Expand All @@ -11,6 +11,7 @@
*
*/

"use strict";
/***************************************************************************
* plugin definition
*/
Expand Down Expand Up @@ -47,7 +48,7 @@

fontSize = $this.css('font-size');
fontRatio = getRatio(fontSize);
lineHeight = $this.css('line-height')
lineHeight = $this.css('line-height');
lineRatio = getRatio(lineHeight);
lineRatio = lineRatio / fontRatio;
//$.log("fontSize="+fontSize+" lineHeight="+lineHeight+" fontRatio="+fontRatio+" lineRatio="+lineRatio);
Expand Down Expand Up @@ -97,7 +98,7 @@
/* initialisation */
$(function() {
$(".jqFluidFont").not(".jqInitedFluidFont").each(function() {
var $this = $(this), opts = $.extend({}, $this.metadata());
var $this = $(this), opts = $.extend({}, $this.data(), $this.metadata());
$this.addClass("jqInitedFluidFont");
$this.fluidfont(opts);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"use strict";
jQuery(function($) {
$(".jqGradient:not(.jqInitedGradient)").each(function() {
var $this = $(this);
$this.addClass("jqInitedGradient");
var opts = $.extend({}, $this.metadata());
var opts = $.extend({}, $this.data(), $this.metadata());
$this.gradient(opts);
});
});
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"use strict";
jQuery(function($) {
var defaults = {
speed: 1000,
Expand All @@ -8,7 +9,7 @@ jQuery(function($) {
$('.jqInnerfade:not(.jqInitedInnerfade)').livequery(function() {
var $this = $(this);
$this.addClass("jqInitedInnerfade");
var opts = $.extend({}, defaults, $this.metadata());
var opts = $.extend({}, defaults, $this.data(), $this.metadata());
$this.innerfade(opts);
});
});
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
/*
* jQuery Loader plugin 2.11
* jQuery Loader plugin 2.13
*
* Copyright (c) 2011-2016 Foswiki Contributors http://foswiki.org
* Copyright (c) 2011-2017 Foswiki Contributors http://foswiki.org
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
*/
"use strict";
jQuery(function($) {

// global defaults
Expand Down Expand Up @@ -55,7 +56,7 @@ jQuery(function($) {
self.load();
}
}
};
}

// init method
JQLoader.prototype.init = function() {
Expand All @@ -65,7 +66,13 @@ jQuery(function($) {
// add refresh listener
$elem.bind("refresh.jqloader", function(e, opts) {
$.extend(self.options, opts);
self.load();
if (self.options.delay) {
window.setTimeout(function() {
self.load();
}, self.options.delay);
} else {
self.load();
}
});

// add onload listener
Expand Down Expand Up @@ -135,7 +142,6 @@ jQuery(function($) {
// load method
JQLoader.prototype.load = function() {
var self = this,
pubUrlPath = foswiki.getPreference("PUBURLPATH"),
$elem = $(self.element),
web = self.options.web || foswiki.getPreference("WEB"),
topic = self.options.topic || foswiki.getPreference("TOPIC"),
Expand Down Expand Up @@ -225,7 +231,7 @@ jQuery(function($) {
);
}
});
}
};

// register css class
$(".jqLoader:not(.jqLoaderInited)").livequery(function() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use strict';
"use strict";
jQuery(function($) {
var defaults = {
waitForImages: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3185,7 +3185,7 @@ return Outlayer;

}));

'use strict';
"use strict";
jQuery(function($) {
var defaults = {
waitForImages: true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"use strict";
jQuery(function($) {
var pubUrlPath = foswiki.getPreference("PUBURLPATH")+'/'+foswiki.getPreference("SYSTEMWEB")+'/JQueryPlugin';

Expand All @@ -13,7 +14,7 @@ jQuery(function($) {
options = $.extend({
caption: '',
skin: 'stormtrooper'
}, $this.metadata());
}, $this.data(), $this.metadata());

if (options.autoplay) {
options.flashvars = $.extend({}, options.flashvars, {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"use strict";
jQuery(function($) {

$(".jqRating:not(.jqInitedRating)").livequery(function() {
Expand All @@ -20,7 +21,7 @@ jQuery(function($) {
title = $link.attr("title") || $link.attr("value");
$this.find(".jqRatingValue").text(title);
}
}, $this.metadata()),
}, $this.data(), $this.metadata()),
$link = $this.find(":checked"),
val = $link.attr("title") || $link.attr("value") || '';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,8 @@
var lastipt = $( control.inputs ).filter(':checked');
var deadipt = $( control.inputs ).not(current);
// check and uncheck elements as required
deadipt.prop('checked',false);//.removeAttr('checked');
current.prop('checked',true);//.attr('checked','checked');
deadipt.prop('checked',false);
current.prop('checked',true);
// trigger change on current or last selected input
$(current.length? current : lastipt ).trigger({ type:'change', selfTriggered:true });
// click callback, as requested here: http://plugins.jquery.com/node/1655
Expand All @@ -320,7 +320,7 @@
// setread-only status
control.readOnly = toggle || toggle==undefined ? true : false;
// enable/disable control value submission
if(disable) $(control.inputs).attr("disabled", "disabled");
if(disable) $(control.inputs).pop("disabled", true);
else $(control.inputs).removeAttr("disabled");
// Update rating control state
this.data('rating', control);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
"use strict";
jQuery(function($) {
$(document).on("click", ".jqScrollToLink", function() {
var opts = $.extend({}, $(this).metadata());
var $this = $(this),
opts = $.extend({}, $this.data(), $this.metadata());

$.scrollTo(opts.target, opts);
return false;
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"use strict";
(function($) {
/**************************************************************************/
foswiki.openDialog = function(data, opts) {
Expand Down Expand Up @@ -86,7 +87,7 @@
dialog.container.find(".jqSimpleModalDraggable").each(function() {
var opts = $.extend({
handle: '.jqSimpleModalDraggable'
}, $(this).metadata());
}, $(this).data(), $(this).metadata());
dialog.container.draggable(opts);
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"use strict";
jQuery(function($) {
var defaults = {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
"use strict";
jQuery(function($) {
$("input.jqTextboxList:not(.jqInitedTextboxList)").livequery(function() {
var $this = $(this),
opts = $.extend({
autocomplete:$this.attr("autocomplete")
}, $this.metadata());
opts = $.extend({ autocomplete:$this.attr("autocomplete") }, $this.data(), $this.metadata());

$this.addClass("jqInitedTextboxList").textboxlist(opts);
});
Expand Down
Loading

0 comments on commit 1be1659

Please sign in to comment.