-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patht4Query.min.js
4 lines (4 loc) · 6.27 KB
/
t4Query.min.js
1
2
3
4
///// t4Query - T4 JavaScript Preprocessor superset ///////////////////////////
///// v1.2 ///////////////////////////
if(typeof $=='undefined'){importClass(com.terminalfour.publish.utils.BrokerUtils);var $=function(field){var t4Obj;if(content.get(field).publish()!==null){t4Obj=$.createObject({name:field,type:'content',output:'normal'});if(content.get(field).publish().isEmpty()){t4Obj.empty=true;t4Obj.toString=function(){return ''};t4Obj.valueOf=function(){return ''}}return t4Obj}else{t4Obj=$.createObject({name:field,type:'content',output:'normal'});t4Obj.fail=true;t4Obj.empty=true;t4Obj.toString=function(){return ''};t4Obj.valueOf=function(){return ''};return t4Obj}};$.random=function(){return Math.floor(Math.random()*10000000)};$.directEditPreserve=true;$.toggleDirectEditPreserve=function(){if($.directEditPreserve){$.directEditPreserve=false}else{$.directEditPreserve=true}};$.w=function(str,indent){var tabs='';if(typeof indent=='number'){for(var i=0;i<Math.floor(indent);i+=1){tabs+='\t'}}if($.directEditPreserve&&typeof str==='string'){str=str.replace(/(<[a-zA-Z1-6]*)((?=[^>]*class=(['"]).*?['"])(?![^>]*id=['"].*?['"]).*?>)/g,'$1 id=$3'+$.meta('content_id')+'_'+$.random()+'$3$2')}document.write(tabs+str+'\n')};$.t4=function(tag){return BrokerUtils.processT4Tags(dbStatement,publishCache,section,content,language,isPreview,tag)};$.createObject=function(keyValuePairs){var element=new $.Functions();element.tag={};for(var key in keyValuePairs){element.tag[key]=keyValuePairs[key]}element.empty=false;element.fail=false;return element};$.meta=function(prop){return $.createObject({meta:prop,type:'meta'})};$.nav=function(id){return $.createObject({id:id+'',type:'navigation'})};$.pageInfo=function(prop){if(typeof $.pageInfo[prop]=='function'){return $.pageInfo[prop]()}};$.pageInfo.section=function(){return parseInt(section.getID())};$.pageInfo.sectionName=function(){var thisSection=com.terminalfour.publish.utils.TreeTraversalUtils.findSection(publishCache.getChannel(),section,section.getID(),language);return ""+thisSection.getName(language)};$.pageInfo.channel=function(){var channel=publishCache.getChannel();return parseInt(channel.getID())};$.pageInfo.channelName=function(){var channel=publishCache.getChannel();return ""+channel.getName()};$.pageInfo.microChannel=function(){var sectionID=section.getID();var thisSection=com.terminalfour.publish.utils.TreeTraversalUtils.findSection(publishCache.getChannel(),section,sectionID,language);var microChannel=publishCache.getMicroSiteFromChild(thisSection);if(!microChannel){return false}return parseInt(microChannel.getID())};$.pageInfo.microChannelName=function(){var sectionID=section.getID();var thisSection=com.terminalfour.publish.utils.TreeTraversalUtils.findSection(publishCache.getChannel(),section,sectionID,language);var microChannel=publishCache.getMicroSiteFromChild(thisSection);if(!microChannel){return false}return ""+microChannel.getName()};$.pageInfo.layout=function(){var channel=publishCache.getChannel();return section.getStyle(channel)};$.pageInfo.path=function(){var thisSection=com.terminalfour.publish.utils.TreeTraversalUtils.findSection(publishCache.getChannel(),section,section.getID(),language);var linkObject=com.terminalfour.publish.PathBuilder.getLink(dbStatement,section,thisSection,publishCache,language,false);return ""+linkObject.getLink()};$.Functions=function(){this.valueOf=function(){return this.insert()};this.toString=function(){return this.insert()}};$.Functions.prototype.action=function(str){return this.attr('action',str)};$.Functions.prototype.after=function(str){return this.attr('after',str)};$.Functions.prototype.appendContent=function(str){return this.attr('append-content',str)};$.Functions.prototype.appendElement=function(str){return this.attr('append-element',str)};$.Functions.prototype.attr=function(attribute,str){if(typeof str=='string'){this.tag[attribute]=str;return this}else{this.fail=true;document.write('<br><span style="color: red; font-weight: bold;">t4Query warning:</span> Passed attribute '+str+' should be a string.<br>');return false}};$.Functions.prototype.before=function(str){return this.attr('before',str)};$.Functions.prototype.checked=function(){return!this.empty};$.Functions.prototype.dateFormat=function(str){return this.attr('date_format',str)};$.Functions.prototype.delimiter=function(str){return this.attr('delimiter',str)};$.Functions.prototype.disableDirectEdit=function(){return this.attr('enable-dedit','false')};$.Functions.prototype.displayField=function(str){return this.attr('display_field',str)};$.Functions.prototype.element=function(str){return this.attr('element',str)};$.Functions.prototype.format=function(str){return this.attr('format',str)};$.Functions.prototype.formatter=function(str){return this.attr('formatter',str)};$.Functions.prototype.formatModifiers=function(str){return this.attr('format-modifiers',str)};$.Functions.prototype.hasContent=function(){return this.checked()};$.Functions.prototype.id=function(str){return this.attr('id',str)};$.Functions.prototype.insert=function(){if(!this.fail){var tag='t4 ';for(var key in this.tag){tag+=key+'="'+this.tag[key]+'" '}tag+='/>';return ''+$.t4('<'+tag)}else{return false}};$.Functions.prototype.locale=function(str){return this.attr('locale',str)};$.Functions.prototype.localeEs=function(str){return this.attr('locale_es',str)};$.Functions.prototype.meta=function(str){return this.attr('meta',str)};$.Functions.prototype.method=function(str){return this.attr('method',str)};$.Functions.prototype.modifiers=function(str){return this.attr('modifiers',str)};$.Functions.prototype.name=function(str){return this.attr('name',str)};$.Functions.prototype.output=function(str){return this.attr('output',str)};$.Functions.prototype.outputSheetName=function(str){return this.attr('output-sheet-name',str)};$.Functions.prototype.processFormat=function(str){if(typeof str!=='string'&&str){str='true'}else{str='false'}return this.attr('process-format',str)};$.Functions.prototype.text=function(str){return this.attr('text',str)};$.Functions.prototype.textualNameSeparator=function(str){return this.attr('textual-name-separator',str)};$.Functions.prototype.type=function(str){return this.attr('type',str)};$.Functions.prototype.url=function(str){return this.attr('url',str)}}
///// End of t4Query - Create your content layout below ///////////////////////