PluginProbe ʕ •ᴥ•ʔ
Pods – Custom Content Types and Fields / 3.2.2
Pods – Custom Content Types and Fields v3.2.2
trunk 1.14.8 2.7.31.3 2.8.23.3 2.9.19.3 3.0.10.3 3.1.4.1 3.2.0 3.2.1 3.2.1.1 3.2.2 3.2.4 3.2.5 3.2.6 3.2.7 3.2.7.1 3.2.8 3.2.8.1 3.2.8.2 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9
pods / components / Templates / assets / js / handlebars.baldrick2.js
pods / components / Templates / assets / js Last commit date
editor1.js 2 years ago handlebars.baldrick2.js 8 years ago handlebars2.js 8 years ago jquery.baldrick3.js 8 years ago panel.js 8 years ago scripts-pod_reference.js 2 years ago scripts-view_template.js 8 years ago
handlebars.baldrick2.js
49 lines
1 /* Baldrick handlebars.js templating plugin */
2 (function ( $ ) {
3 var compiledTemplates = {};
4 $.fn.baldrick.registerhelper( 'handlebars', {
5 bind : function ( triggers, defaults ) {
6 var templates = triggers.filter( "[data-template-url]" );
7 if ( templates.length ) {
8 templates.each( function () {
9 var trigger = $( this );
10 if ( typeof compiledTemplates[trigger.data( 'templateUrl' )] === 'undefined' ) {
11 compiledTemplates[trigger.data( 'templateUrl' )] = true;
12 $.get( trigger.data( 'templateUrl' ), function ( data ) {
13 compiledTemplates[trigger.data( 'templateUrl' )] = Handlebars.compile( data );
14 } );
15 }
16 } );
17 }
18
19 }, request_params : function ( request, defaults, params ) {
20 if ( (params.trigger.data( 'templateUrl' ) || params.trigger.data( 'template' )) && typeof Handlebars === 'object' ) {
21 request.dataType = 'json';
22 return request;
23 }
24 }, filter : function ( opts, defaults ) {
25
26 if ( opts.params.trigger.data( 'templateUrl' ) ) {
27 if ( typeof compiledTemplates[opts.params.trigger.data( 'templateUrl' )] === 'function' ) {
28 opts.data = compiledTemplates[opts.params.trigger.data( 'templateUrl' )]( opts.data );
29 }
30 }
31 else {
32 if ( opts.params.trigger.data( 'template' ) ) {
33 if ( typeof compiledTemplates[opts.params.trigger.data( 'template' )] === 'function' ) {
34 opts.data = compiledTemplates[opts.params.trigger.data( 'template' )]( opts.data );
35 }
36 else {
37 if ( $( opts.params.trigger.data( 'template' ) ) ) {
38 compiledTemplates[opts.params.trigger.data( 'template' )] = Handlebars.compile( $( opts.params.trigger.data( 'template' ) ).html() );
39 opts.data = compiledTemplates[opts.params.trigger.data( 'template' )]( opts.data );
40 }
41 }
42 }
43 }
44
45 return opts;
46 }
47 } );
48
49 })( jQuery );