jaydata
Version:
Cross-platform HTML5 data-management, JavaScript Language Query (JSLQ) support for OData, SQLite, WebSQL, IndexedDB, YQL and Facebook (packaged for Node.JS)
16 lines (15 loc) • 6.96 kB
JavaScript
// JayData 1.5.10
// Dual licensed under MIT and GPL v2
// Copyright JayStack Technologies (http://jaydata.org/licensing)
//
// JayData is a standards-based, cross-platform Javascript library and a set of
// practices to access and manipulate data from various online and offline sources.
//
// Credits:
// Hajnalka Battancs, Dániel József, János Roden, László Horváth, Péter Nochta
// Péter Zentai, Róbert Bónay, Szabolcs Czinege, Viktor Borza, Viktor Lázár,
// Zoltán Gyebrovszki, Gábor Dolla
//
// More info: http://jaydata.org
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define("jaydata/modules/handlebars",["jaydata/core"],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.$data=e()}}(function(){return function e(t,n,r){function a(o,d){if(!n[o]){if(!t[o]){var c="function"==typeof require&&require;if(!d&&c)return c(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var u=n[o]={exports:{}};t[o][0].call(u.exports,function(e){var n=t[o][1][e];return a(n?n:e)},u,u.exports,e,t,n,r)}return n[o].exports}for(var i="function"==typeof require&&require,o=0;o<r.length;o++)a(r[o]);return a}({1:[function(e,t,n){(function(r){"use strict";function a(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(n,"__esModule",{value:!0});var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},o=e("jaydata/core"),d=a(o),c="undefined"!=typeof window?window.jQuery:"undefined"!=typeof r?r.jQuery:null,f=a(c),u="undefined"!=typeof window?window.Handlebars:"undefined"!=typeof r?r.Handlebars:null,l=a(u);!function(e,t,n){function r(e){return t.compile(e)}function a(e,t){return t?(t=t.trim(),t&&("<"===t[0]||"{"===t[0])?t:void 0):void 0}function o(e,t){}function d(t,r){if(!r){var a=e.Container.resolveName(t).split("."),i=a[a.length-1];r=i}return n("#"+r).html()}function c(t,n){"undefined"==typeof n&&(n=n||p++);var r=t.cacheKey;if("undefined"==typeof r)r=t.cacheKey=s++,e.displayCache[t.cacheKey]={value:t,references:[n]};else{var a=e.displayCache[r];a.references.indexOf(n)<0&&a.references.push(n)}return{cacheKey:r,clientId:n}}function f(t){return e.displayCache[t].value}var u=e.Entity.inheritedTypeProcessor,l={templateResolvers:[a,o,d],templateCompiler:r,templateCache:{},getTemplate:function(e,t){var n,r,a,i=e.fullName+"::"+t;for(r=n=this.templateCache[i],a=0;!n&&a<this.templateResolvers.length;)n=this.templateResolvers[a++](e,t);return n&&!r&&(n=this.templateCache[i]=this.templateCompiler(n)),n||console.log("Can not find template: "+t),n}};e.templateEngine=l,e.render=function(t,n){if(t instanceof e.Entity)return t.render(n);var r,a=Array.isArray(t)?t[0]:t;for(var i in a)a.hasOwnProperty(i)&&(r+=i+"::");var o={fullName:r},d=l.getTemplate(o,n);return d(t)},e.renderItems=function(t,n){for(var r="",a=0;a<t.length;a++)r+=e.render(t[a],n);return r},e.renderTo=function(t,r,a){return a=a||"replaceContent",function(i){"replaceContent"===a&&n(t).empty();var o;switch(o=e.render(i,r),a){case"append":case"replaceContent":n(t).append(o);break;case"replace":n(t).replaceWith(o);break;case"after":n(t).after(o);break;case"before":n(t).before(o)}return i}},e.renderItemsTo=function(t,r,a){return a=a||"replaceContent",function(i){"replaceContent"===a&&n(t).empty();var o;switch(o=e.renderItems(i,r),a){case"append":case"replaceContent":n(t).append(o);break;case"replace":n(t).replaceWith(o);break;case"after":n(t).after(o);break;case"before":n(t).before(o)}return i}},e.Entity.inheritedTypeProcessor=function(t){function r(n,r){var a=l.getTemplate(t,r);return n instanceof e.Entity||(n=new t(n)),a(n)}function a(e,t){for(var n="",a=0;a<e.length;a++)n+=r(e[a],t);return n}u&&u(t),t.render=r,t.renderItems=a,t.addCommand=function(e,r,a,i){i=i||document,"function"==typeof r&&(a=r,r="click");var o=t.fullName.split("."),d=o[o.length-1],c="[data-command='"+e+"'][data-type='"+d+"']";n(i).delegate(c,r,function(){var e=this,t=n(this).data("cache-item"),r=f(t);[r,n(this).data("id")];a.apply(r,[r,e,n(e).data("id")])})},t.renderTo=function(n,r,a,o){if("object"!==("undefined"==typeof n?"undefined":i(n)))return o=a,a=r,r=n,t.readAll().then(e.renderTo(r,a,o));throw new Error("Not implemented")},t.renderItemsTo=function(n,r,a,i){if(!Array.isArray(n))return i=a,a=r,r=n,t.readAll().then(e.renderItemsTo(r,a,i));throw new Error("Not implemented")}},e.Entity.prototype.render=function(e){return this.getType().render(this,e)},e.Entity.prototype.renderTo=function(t,n,r){return e.renderTo(t,n,r)(this)},e.Queryable.prototype.renderTo=function(t,n,r){return this.toArray().then(function(a){return e.renderTo(t,n,r)(a)})},e.Queryable.prototype.renderItemsTo=function(t,n,r){return this.toArray().then(function(a){return e.renderItemsTo(t,n,r)(a)})},Object.defineProperty(e.Entity.prototype,"fields",{get:function(){var e=this,t=[];return this.getType().memberDefinitions.getPublicMappedProperties().forEach(function(n){var r=n.name;if("property"===n.kind){var a={name:n.name,metadata:n};Object.defineProperty(a,"value",{get:function(){return e[r]}}),t.push(a)}}),t}}),t.registerHelper("renderEntity",function(n){return arguments.length<2&&(n=void 0),new t.SafeString(e.render(this,n))}),e.displayCache={};var s=0,p=0;t.registerHelper("entityScope",function(){var t=e.Container.resolveName(this.getType()).split("."),n=t[t.length-1],r=this.getType().memberDefinitions.getKeyProperties()[0],a=this[r.name],i="data-"+n.toLowerCase()+"-"+a,o=c(this);return i+=" data-cache-client="+o.clientId,i+=" data-cache-item="+o.cacheKey}),t.registerHelper("entityCommand",function(t){var n=this;e.entityCache=e.entityCache||{};var r=e.Container.resolveName(this.getType()).split("."),a=r[r.length-1],i=n.getType().memberDefinitions.getKeyProperties()[0],o=n[i.name],d=a+":"+o;e.entityCache[d]||(e.entityCache[d]=n);var f="data-command="+t+" data-type="+a+" data-id="+o,u=c(this);return f+=" data-cache-client="+u.clientId,f+=" data-cache-item="+u.cacheKey}),e.setCommandHandler=function(e,t){t=t||document,n(t).delegate("[data-command]","click",function(){var t=(n(this).data("type")+":"+n(this).data("id"),e[n(this).data("command")+n(this).data("type")]),r=n(this).data("cache-item"),a=f(r),i=[a,n(this).data("id")];t.apply(e,i)})},n(document).delegate(".single-select","click",function(e){var t=n(e.srcElement).parentsUntil(this);n(this).children().removeClass("active"),t.addClass("active")})}(d["default"],l["default"],f["default"]),n["default"]=d["default"],t.exports=n["default"]}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"jaydata/core":"jaydata/core"}]},{},[1])(1)});
//# sourceMappingURL=handlebars.min.js.map