Skip to content

Commit

Permalink
Item14454: Merge commit of feature branch Item14454.
Browse files Browse the repository at this point in the history
The following commits were squashed:
    Item14454: More docu fixes for jsviews
    commit 3d86c6a

    Item14454: Update JQueryPlugin MANIFEST and Config.spec to include jsviews
    commit 16dc8db

    Item14454: Fix minor docu error
    commit 7f37405

    Item14454: Update jsrender/jsviews version strings in .pm
    commit 27074b1

    Item14454: Update jsrender to latest master (v0.9.90)
    commit 562e752

    Item14454: Update jsviews to latest master (v0.9.90)
    commit cfb113c

    Item14454: Update jsviews to latest master (v0.9.90)
    commit b27be89

    Item14454: Add Makefile to update jsviews from git repo
    commit 931187e

    Item14454: Merge with branch 'master'
    commit 611e981

    Item14454: Bundle JsViews as an option with JsRender
    commit 23fe329

    Item14454 (#16)
    commit f23d1f0

Changes to be committed:
    new file:   JQueryPlugin/data/System/JQueryView.txt
    modified:   JQueryPlugin/lib/Foswiki/Plugins/JQueryPlugin/Config.spec
    modified:   JQueryPlugin/lib/Foswiki/Plugins/JQueryPlugin/MANIFEST
    modified:   JQueryPlugin/lib/Foswiki/Plugins/JQueryPlugin/RENDER.pm
    new file:   JQueryPlugin/lib/Foswiki/Plugins/JQueryPlugin/VIEW.pm
    modified:   JQueryPlugin/pub/System/JQueryPlugin/plugins/render/jquery.render.uncompressed.js
    new file:   JQueryPlugin/pub/System/JQueryPlugin/plugins/view/Makefile
    new file:   JQueryPlugin/pub/System/JQueryPlugin/plugins/view/jquery.observable.js
    new file:   JQueryPlugin/pub/System/JQueryPlugin/plugins/view/jquery.observable.uncompressed.js
    new file:   JQueryPlugin/pub/System/JQueryPlugin/plugins/view/jquery.views.js
    new file:   JQueryPlugin/pub/System/JQueryPlugin/plugins/view/jquery.views.uncompressed.js
  • Loading branch information
hoeflerb committed Dec 15, 2017
1 parent 49ad329 commit 63aab4f
Show file tree
Hide file tree
Showing 11 changed files with 5,423 additions and 231 deletions.
131 changes: 131 additions & 0 deletions JQueryPlugin/data/System/JQueryView.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
%META:TOPICINFO{author="ProjectContributor" comment="" date="1513189072" format="1.1" version="1"}%
%META:TOPICPARENT{name="JQueryPlugin"}%

---+!! %TOPIC%

%JQPLUGINS{"view"
format="
Homepage: $homepage <br />
Author(s): $author <br />
Version: $version
"
}%

%TOC%

%STARTSECTION{"summary"}%
This plugin adds JsViews functionality to the JsRender plugin. JsViews builds off of standard JsRender templates, but adds
two-way declarative data-binding, MVVM, and MVP.

See System.JQueryRender and https://www.jsviews.com/#jsviews for more details.
%ENDSECTION{"summary"}%

---++ Usage

%JQREQUIRE{"view"}%

---+++ In the SCRIPT head
<verbatim>
var data = [
{
"name": "Robert",
"nickname": "Bob",
"showNickname": true
},
{
"name": "Susan",
"nickname": "Sue",
"showNickname": false
}
];

var template = $.templates("#theTmpl");

template.link("#result", data);
</verbatim>

---+++ In the BODY
<verbatim>
<div id="result"></div>

<script id="theTmpl" type="text/x-jsrender">
<div>
Edit: <input type="checkbox" data-link="editable"/>
<em>Name:</em> {^{:name}}
{^{if showNickname && nickname}}
(Goes by <em data-link="nickname"></em>)
{{/if}}
{^{if editable}}
<div>
<input data-link="name"/>
<input data-link="nickname"/>
Show nickname: <input type="checkbox" data-link="showNickname"/>
</div>
{{/if}}
</div>
</script>
</verbatim>

---+++ See the demo
<div id="result"></div>

<script id="theTmpl" type="text/x-jsrender">
<div>
Edit: <input type="checkbox" data-link="editable"/>
<em>Name:</em> {^{:name}}
{^{if showNickname && nickname}}
(Goes by <em data-link="nickname"></em>)
{{/if}}
{^{if editable}}
<div>
<input data-link="name"/>
<input data-link="nickname"/>
Show nickname: <input type="checkbox" data-link="showNickname"/>
</div>
{{/if}}
</div>
</script>

<script type="text/javascript">
(function($) {
var data = [
{
"name": "Robert",
"nickname": "Bob",
"showNickname": true
},
{
"name": "Susan",
"nickname": "Sue",
"showNickname": false
}
];

$(function() {
var template = $.templates("#theTmpl");
template.link("#result", data);
});
})(jQuery);
</script>

Pretty cool!

---++ Further reading
* http://www.jsviews.com
* [[http://borismoore.github.io/jsviews/demos/][JsViews Demos]]

---++ Syntax

!JsViews templates are very similar to !JsRender templates, but with minor changes to the tag structure.
* For data-dependent linking, <code>{{:name}}</code> becomes this <code>{^{:name}}</code>
* Tag attributes can also be data-linked: <code>&lt;button data-link="disabled{:disableButton} title{:theTitle} data-myvalue{:myVal} class{:disableButton ? 'class2' : 'class1'}"&gt;</code>
* If you are data-linking tags, you might be interested in two-way binding: <code>&lt;input data-link="{:name}" /&gt;</code> becomes this <code>&lt;input data-link="{:name:}" /&gt;</code>
* (Actually, the default for &lt;input&gt; elements is two-way binding, so you can just use the shorthand <code>&lt;input data-link="name" /&gt;</code>. The more explicit form is only necessary if you want to force it to one-way binding.)
* You can also use this for contenteditable elements: <code>&lt;span data-link="name" contenteditable="true"&gt;&lt;/span&gt;</code>
* As with !JsRender, there is support for converters and helpers as well.

Other functionality includes the <code>$.observe()</code> method for assigning callback functions to respond to observable
changes, and the <code>$.view()</code> method for retrieving the data slice associated with a particular View object.

(see http://www.jsviews.com/#jsvapi for lots of details and examples)

3 changes: 3 additions & 0 deletions JQueryPlugin/lib/Foswiki/Plugins/JQueryPlugin/Config.spec
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,9 @@ $Foswiki::cfg{JQueryPlugin}{Plugins}{'UI::Tooltip'}{Enabled} = 1;
# **BOOLEAN LABEL="UI::Validate"**
$Foswiki::cfg{JQueryPlugin}{Plugins}{Validate}{Enabled} = 1;

# **BOOLEAN LABEL="View"**
$Foswiki::cfg{JQueryPlugin}{Plugins}{View}{Enabled} = 1;

# **BOOLEAN LABEL="WikiWord"**
$Foswiki::cfg{JQueryPlugin}{Plugins}{WikiWord}{Enabled} = 1;

Expand Down
9 changes: 9 additions & 0 deletions JQueryPlugin/lib/Foswiki/Plugins/JQueryPlugin/MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ data/System/JQueryUIDialog.txt 0644
data/System/JQueryUITooltip.txt 0644
data/System/JQueryUI.txt 0644
data/System/JQueryValidate.txt 0644
data/System/JQueryView.txt 0644
data/System/JQueryWikiWord.txt 0644
data/System/VarBUTTON.txt 0644
data/System/VarENDTABPANE.txt 0644
Expand Down Expand Up @@ -159,6 +160,7 @@ lib/Foswiki/Plugins/JQueryPlugin/UI/SPINNER.pm 0644
lib/Foswiki/Plugins/JQueryPlugin/UI/TABS.pm 0644
lib/Foswiki/Plugins/JQueryPlugin/UI/TOOLTIP.pm 0644
lib/Foswiki/Plugins/JQueryPlugin/VALIDATE.pm 0644
lib/Foswiki/Plugins/JQueryPlugin/VIEW.pm 0644
lib/Foswiki/Plugins/JQueryPlugin/WIKIWORD.pm 0644
pub/System/JQueryCycle/beach1.jpg 0644
pub/System/JQueryCycle/beach2.jpg 0644
Expand Down Expand Up @@ -966,6 +968,13 @@ pub/System/JQueryPlugin/plugins/validate/Makefile 0644
pub/System/JQueryPlugin/plugins/validate/pkg.js 0644
pub/System/JQueryPlugin/plugins/validate/pkg.js.gz 0644
pub/System/JQueryPlugin/plugins/validate/pkg.uncompressed.js 0644
pub/System/JQueryPlugin/plugins/view/jquery.observable.js 0644
pub/System/JQueryPlugin/plugins/view/jquery.observable.js.gz 0644
pub/System/JQueryPlugin/plugins/view/jquery.observable.uncompressed.js 0644
pub/System/JQueryPlugin/plugins/view/jquery.views.js 0644
pub/System/JQueryPlugin/plugins/view/jquery.views.js.gz 0644
pub/System/JQueryPlugin/plugins/view/jquery.views.uncompressed.js 0644
pub/System/JQueryPlugin/plugins/view/Makefile 0644
pub/System/JQueryPlugin/plugins/wikiword/downgradeMap.small.uncompressed.js 0644
pub/System/JQueryPlugin/plugins/wikiword/downgradeMap.uncompressed.js 0644
pub/System/JQueryPlugin/plugins/wikiword/jquery.wikiword.uncompressed.js 0644
Expand Down
2 changes: 1 addition & 1 deletion JQueryPlugin/lib/Foswiki/Plugins/JQueryPlugin/RENDER.pm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ sub new {
$class->SUPER::new(
$session,
name => 'Render',
version => '0.9.83',
version => '0.9.90',
author => 'Boris Moore',
homepage => 'http://www.jsviews.com',
javascript => [ 'jquery.render.js', 'jquery.template-loader.js' ],
Expand Down
52 changes: 52 additions & 0 deletions JQueryPlugin/lib/Foswiki/Plugins/JQueryPlugin/VIEW.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# See bottom of file for license and copyright information

package Foswiki::Plugins::JQueryPlugin::VIEW;
use strict;
use warnings;

use Foswiki ();
use Foswiki::Plugins::JQueryPlugin::Plugin ();
our @ISA = qw( Foswiki::Plugins::JQueryPlugin::Plugin );

sub new {
my $class = shift;
my $session = shift || $Foswiki::Plugins::SESSION;

my $this = bless(
$class->SUPER::new(
$session,
name => 'View',
version => '0.9.90',
author => 'Boris Moore',
homepage => 'http://www.jsviews.com',
dependencies => ['render'],
javascript => [
'jquery.observable.uncompressed.js',
'jquery.views.uncompressed.js'
],
),
$class
);

return $this;
}

1;

__END__
Foswiki - The Free and Open Source Wiki, http://foswiki.org/
Copyright (C) 2010-2016 Foswiki Contributors. Foswiki Contributors
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. For
more details read LICENSE in the root of this distribution.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
As per the GPL, removal of this notice is prohibited.
Loading

0 comments on commit 63aab4f

Please sign in to comment.