-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Item14454: Merge commit of feature branch Item14454.
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
Showing
11 changed files
with
5,423 additions
and
231 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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><button data-link="disabled{:disableButton} title{:theTitle} data-myvalue{:myVal} class{:disableButton ? 'class2' : 'class1'}"></code> | ||
* If you are data-linking tags, you might be interested in two-way binding: <code><input data-link="{:name}" /></code> becomes this <code><input data-link="{:name:}" /></code> | ||
* (Actually, the default for <input> elements is two-way binding, so you can just use the shorthand <code><input data-link="name" /></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><span data-link="name" contenteditable="true"></span></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) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
Oops, something went wrong.