(function(root, factory) { if (typeof exports == "object") module.exports = factory(); else if (typeof define == "function" && define.amd) define(factory); else root.Spinner = factory(); })(this, function() { "use strict"; var prefixes = [ "webkit", "Moz", "ms", "O" ], animations = {}, useCssAnimations; function createEl(tag, prop) { var el = document.createElement(tag || "div"), n; for (n in prop) el[n] = prop[n]; return el; } function ins(parent) { for (var i = 1, n = arguments.length; i < n; i++) parent.appendChild(arguments[i]); return parent; } var sheet = function() { var el = createEl("style", { type: "text/css" }); ins(document.getElementsByTagName("head")[0], el); return el.sheet || el.styleSheet; }(); function addAnimation(alpha, trail, i, lines) { var name = [ "opacity", trail, ~~(alpha * 100), i, lines ].join("-"), start = .01 + i / lines * 100, z = Math.max(1 - (1 - alpha) / trail * (100 - start), alpha), prefix = useCssAnimations.substring(0, useCssAnimations.indexOf("Animation")).toLowerCase(), pre = prefix && "-" + prefix + "-" || ""; if (!animations[name]) { sheet.insertRule("@" + pre + "keyframes " + name + "{" + "0%{opacity:" + z + "}" + start + "%{opacity:" + alpha + "}" + (start + .01) + "%{opacity:1}" + (start + trail) % 100 + "%{opacity:" + alpha + "}" + "100%{opacity:" + z + "}" + "}", sheet.cssRules.length); animations[name] = 1; } return name; } function vendor(el, prop) { var s = el.style, pp, i; prop = prop.charAt(0).toUpperCase() + prop.slice(1); for (i = 0; i < prefixes.length; i++) { pp = prefixes[i] + prop; if (s[pp] !== undefined) return pp; } if (s[prop] !== undefined) return prop; } function css(el, prop) { for (var n in prop) el.style[vendor(el, n) || n] = prop[n]; return el; } function merge(obj) { for (var i = 1; i < arguments.length; i++) { var def = arguments[i]; for (var n in def) if (obj[n] === undefined) obj[n] = def[n]; } return obj; } function pos(el) { var o = { x: el.offsetLeft, y: el.offsetTop }; while (el = el.offsetParent) o.x += el.offsetLeft, o.y += el.offsetTop; return o; } function getColor(color, idx) { return typeof color == "string" ? color : color[idx % color.length]; } var defaults = { lines: 12, length: 7, width: 5, radius: 10, rotate: 0, corners: 1, color: "#000", direction: 1, speed: 1, trail: 100, opacity: 1 / 4, fps: 20, zIndex: 2e9, className: "spinner", top: "50%", left: "50%", position: "absolute" }; function Spinner(o) { this.opts = merge(o || {}, Spinner.defaults, defaults); } Spinner.defaults = {}; merge(Spinner.prototype, { spin: function(target) { this.stop(); var self = this, o = self.opts, el = self.el = css(createEl(0, { className: o.className }), { position: o.position, width: 0, zIndex: o.zIndex }), mid = o.radius + o.length + o.width; css(el, { left: o.left, top: o.top }); if (target) { target.insertBefore(el, target.firstChild || null); } el.setAttribute("role", "progressbar"); self.lines(el, self.opts); if (!useCssAnimations) { var i = 0, start = (o.lines - 1) * (1 - o.direction) / 2, alpha, fps = o.fps, f = fps / o.speed, ostep = (1 - o.opacity) / (f * o.trail / 100), astep = f / o.lines; (function anim() { i++; for (var j = 0; j < o.lines; j++) { alpha = Math.max(1 - (i + (o.lines - j) * astep) % f * ostep, o.opacity); self.opacity(el, j * o.direction + start, alpha, o); } self.timeout = self.el && setTimeout(anim, ~~(1e3 / fps)); })(); } return self; }, stop: function() { var el = this.el; if (el) { clearTimeout(this.timeout); if (el.parentNode) el.parentNode.removeChild(el); this.el = undefined; } return this; }, lines: function(el, o) { var i = 0, start = (o.lines - 1) * (1 - o.direction) / 2, seg; function fill(color, shadow) { return css(createEl(), { position: "absolute", width: o.length + o.width + "px", height: o.width + "px", background: color, boxShadow: shadow, transformOrigin: "left", transform: "rotate(" + ~~(360 / o.lines * i + o.rotate) + "deg) translate(" + o.radius + "px" + ",0)", borderRadius: (o.corners * o.width >> 1) + "px" }); } for (;i < o.lines; i++) { seg = css(createEl(), { position: "absolute", top: 1 + ~(o.width / 2) + "px", transform: o.hwaccel ? "translate3d(0,0,0)" : "", opacity: o.opacity, animation: useCssAnimations && addAnimation(o.opacity, o.trail, start + i * o.direction, o.lines) + " " + 1 / o.speed + "s linear infinite" }); if (o.shadow) ins(seg, css(fill("#000", "0 0 4px " + "#000"), { top: 2 + "px" })); ins(el, ins(seg, fill(getColor(o.color, i), "0 0 1px rgba(0,0,0,.1)"))); } return el; }, opacity: function(el, i, val) { if (i < el.childNodes.length) el.childNodes[i].style.opacity = val; } }); function initVML() { function vml(tag, attr) { return createEl("<" + tag + ' xmlns="urn:schemas-microsoft.com:vml" class="spin-vml">', attr); } sheet.addRule(".spin-vml", "behavior:url(#default#VML)"); Spinner.prototype.lines = function(el, o) { var r = o.length + o.width, s = 2 * r; function grp() { return css(vml("group", { coordsize: s + " " + s, coordorigin: -r + " " + -r }), { width: s, height: s }); } var margin = -(o.width + o.length) * 2 + "px", g = css(grp(), { position: "absolute", top: margin, left: margin }), i; function seg(i, dx, filter) { ins(g, ins(css(grp(), { rotation: 360 / o.lines * i + "deg", left: ~~dx }), ins(css(vml("roundrect", { arcsize: o.corners }), { width: r, height: o.width, left: o.radius, top: -o.width >> 1, filter: filter }), vml("fill", { color: getColor(o.color, i), opacity: o.opacity }), vml("stroke", { opacity: 0 })))); } if (o.shadow) for (i = 1; i <= o.lines; i++) seg(i, -2, "progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)"); for (i = 1; i <= o.lines; i++) seg(i); return ins(el, g); }; Spinner.prototype.opacity = function(el, i, val, o) { var c = el.firstChild; o = o.shadow && o.lines || 0; if (c && i + o < c.childNodes.length) { c = c.childNodes[i + o]; c = c && c.firstChild; c = c && c.firstChild; if (c) c.opacity = val; } }; } var probe = css(createEl("group"), { behavior: "url(#default#VML)" }); if (!vendor(probe, "transform") && probe.adj) initVML(); else useCssAnimations = vendor(probe, "animation"); return Spinner; }); /*download by www.sucaijiayuan.com*/ var iosOverlay = function(params) { "use strict"; var overlayDOM; var noop = function() {}; var defaults = { onbeforeshow: noop, onshow: noop, onbeforehide: noop, onhide: noop, text: "", icon: null, spinner: null, duration: null, id: null, parentEl: null }; // helper - merge two objects together, without using $.extend var merge = function (obj1, obj2) { var obj3 = {}; for (var attrOne in obj1) { obj3[attrOne] = obj1[attrOne]; } for (var attrTwo in obj2) { obj3[attrTwo] = obj2[attrTwo]; } return obj3; }; // helper - does it support CSS3 transitions/animation var doesTransitions = (function() { var b = document.body || document.documentElement; var s = b.style; var p = 'transition'; if (typeof s[p] === 'string') { return true; } // Tests for vendor specific prop var v = ['Moz', 'Webkit', 'Khtml', 'O', 'ms']; p = p.charAt(0).toUpperCase() + p.substr(1); for(var i=0; i'; } else if (params.spinner) { overlayDOM.appendChild(params.spinner.el); } if (doesTransitions) { overlayDOM.addEventListener("webkitAnimationEnd", handleAnim, false); overlayDOM.addEventListener("msAnimationEnd", handleAnim, false); overlayDOM.addEventListener("oAnimationEnd", handleAnim, false); overlayDOM.addEventListener("animationend", handleAnim, false); } if (params.parentEl) { document.getElementById(params.parentEl).appendChild(overlayDOM); } else { document.body.appendChild(overlayDOM); } settings.onbeforeshow(); // begin fade in if (doesTransitions) { overlayDOM.className += " ios-overlay-show"; } else if (typeof $ === "function") { $(overlayDOM).fadeIn({ duration: 200 }, function() { settings.onshow(); }); } if (settings.duration) { window.setTimeout(function() { hide(); },settings.duration); } }; var hide = function() { // pre-callback settings.onbeforehide(); // fade out if (doesTransitions) { // CSS animation bound to classes overlayDOM.className = overlayDOM.className.replace("show","hide"); } else if (typeof $ === "function") { // polyfill requires jQuery $(overlayDOM).fadeOut({ duration: 200 }, function() { destroy(); settings.onhide(); }); } }; var destroy = function() { if (params.parentEl) { document.getElementById(params.parentEl).removeChild(overlayDOM); } else { document.body.removeChild(overlayDOM); } }; var update = function(params) { if (params.text) { overlayDOM.getElementsByTagName("span")[0].innerHTML = params.text; } if (params.icon) { if (settings.spinner) { settings.spinner.el.parentNode.removeChild(settings.spinner.el); } overlayDOM.innerHTML += ''; } }; return { show: show, hide: hide, destroy: destroy, update: update }; }; (function(root, factory) { if (typeof exports === "object") { module.exports = factory(); } else if (typeof define === "function" && define.amd) { define([ "./spin" ], factory); } else { root.Ladda = factory(root.Spinner); } })(this, function(Spinner) { "use strict"; var ALL_INSTANCES = []; function create(button) { if (typeof button === "undefined") { console.warn("Ladda button target must be defined."); return; } if (!button.querySelector(".ladda-label")) { button.innerHTML = '' + button.innerHTML + ""; } var spinner = createSpinner(button); var spinnerWrapper = document.createElement("span"); spinnerWrapper.className = "ladda-spinner"; button.appendChild(spinnerWrapper); var timer; var instance = { start: function() { button.setAttribute("disabled", ""); button.setAttribute("data-loading", ""); clearTimeout(timer); spinner.spin(spinnerWrapper); this.setProgress(0); return this; }, startAfter: function(delay) { clearTimeout(timer); timer = setTimeout(function() { instance.start(); }, delay); return this; }, stop: function() { button.removeAttribute("disabled"); button.removeAttribute("data-loading"); clearTimeout(timer); timer = setTimeout(function() { spinner.stop(); }, 1e3); return this; }, toggle: function() { if (this.isLoading()) { this.stop(); } else { this.start(); } return this; }, setProgress: function(progress) { progress = Math.max(Math.min(progress, 1), 0); var progressElement = button.querySelector(".ladda-progress"); if (progress === 0 && progressElement && progressElement.parentNode) { progressElement.parentNode.removeChild(progressElement); } else { if (!progressElement) { progressElement = document.createElement("div"); progressElement.className = "ladda-progress"; button.appendChild(progressElement); } progressElement.style.width = (progress || 0) * button.offsetWidth + "px"; } }, enable: function() { this.stop(); return this; }, disable: function() { this.stop(); button.setAttribute("disabled", ""); return this; }, isLoading: function() { return button.hasAttribute("data-loading"); }, getTarget: function() { return button; } }; ALL_INSTANCES.push(instance); return instance; } function bind(target, options) { options = options || {}; var targets = []; if (typeof target === "string") { targets = toArray(document.querySelectorAll(target)); } else if (typeof target === "object" && typeof target.nodeName === "string") { targets = [ target ]; } for (var i = 0, len = targets.length; i < len; i++) { (function() { var element = targets[i]; if (typeof element.addEventListener === "function") { var instance = create(element); var timeout = -1; element.addEventListener("click", function() { instance.startAfter(1); if (typeof options.timeout === "number") { clearTimeout(timeout); timeout = setTimeout(instance.stop, options.timeout); } if (typeof options.callback === "function") { options.callback.apply(null, [ instance ]); } }, false); } })(); } } function stopAll() { for (var i = 0, len = ALL_INSTANCES.length; i < len; i++) { ALL_INSTANCES[i].stop(); } } function createSpinner(button) { var height = button.offsetHeight, spinnerColor; if (height > 32) { height *= .8; } if (button.hasAttribute("data-spinner-size")) { height = parseInt(button.getAttribute("data-spinner-size"), 10); } if (button.hasAttribute("data-spinner-color")) { spinnerColor = button.getAttribute("data-spinner-color"); } var lines = 12, radius = height * .2, length = radius * .6, width = radius < 7 ? 2 : 3; return new Spinner({ color: spinnerColor || "#fff", lines: lines, radius: radius, length: length, width: width, zIndex: "auto", top: "50%", left: "50%", className: "" }); } function toArray(nodes) { var a = []; for (var i = 0; i < nodes.length; i++) { a.push(nodes[i]); } return a; } return { bind: bind, create: create, stopAll: stopAll }; }); (function($) { $.csrf = function(data){ $.extend({}, data); var d = new Object(); var p = $("[name='csrf-param']").attr('content'); var t = $("[name='csrf-token']").attr('content'); d[p] = t; return $.extend(d, data); } $.ladda = function(element){ return Ladda.create(element); } $.loading = function(settings){ var _settings = { text: "" } settings = $.extend(_settings, settings); var opts = { lines: 13, // The number of lines to draw length: 11, // The length of each line width: 5, // The line thickness radius: 17, // The radius of the inner circle corners: 1, // Corner roundness (0..1) rotate: 0, // The rotation offset color: '#000', // #rgb or #rrggbb speed: 1, // Rounds per second trail: 60, // Afterglow percentage shadow: false, // Whether to render a shadow hwaccel: false, // Whether to use hardware acceleration className: 'spinner', // The CSS class to assign to the spinner zIndex: 2e9, // The z-index (defaults to 2000000000) top: '50%', // Top position relative to parent in px left: '50%' // Left position relative to parent in px }; var target = document.createElement("div"); document.body.appendChild(target); var spinner = new Spinner(opts).spin(target); return iosOverlay({ //text: settings.text, spinner: spinner }); } var validateRegExp = { decmal: "^([+-]?)\\d*\\.\\d+$",// 浮点数 decmal1: "^[1-9]\\d*.\\d*|0.\\d*[1-9]\\d*$",// 正浮点数 decmal2: "^-([1-9]\\d*.\\d*|0.\\d*[1-9]\\d*)$",// 负浮点数 decmal3: "^-?([1-9]\\d*.\\d*|0.\\d*[1-9]\\d*|0?.0+|0)$", // 浮点数 decmal4: "^[1-9]\\d*.\\d*|0.\\d*[1-9]\\d*|0?.0+|0$", // 非负浮点数(正浮点数 + 0) decmal5: "^(-([1-9]\\d*.\\d*|0.\\d*[1-9]\\d*))|0?.0+|0$", // 非正浮点数(负浮点数 + // 0) intege: "^-?[1-9]\\d*$", // 整数 intege1: "^[1-9]\\d*$", // 正整数 intege2: "^-[1-9]\\d*$", // 负整数 num: "^([+-]?)\\d*\\.?\\d+$", // 数字 num1: "^[1-9]\\d*|0$", // 正数(正整数 + 0) num2: "^-[1-9]\\d*|0$", // 负数(负整数 + 0) ascii: "^[\\x00-\\xFF]+$", // 仅ACSII字符 chinese: "^[\\u4e00-\\u9fa5]+$", // 仅中文 color: "^[a-fA-F0-9]{6}$", // 颜色 date: "^\\d{4}(\\-|\\/|\.)\\d{1,2}\\1\\d{1,2}$", // 日期 email: "^\\w+((-\\w+)|(\\.\\w+))*\\@[A-Za-z0-9]+((\\.|-)[A-Za-z0-9]+)*\\.[A-Za-z0-9]+$", // 邮件 idcard: "^[1-9]([0-9]{14}|[0-9]{17})$", // 身份证 ip4: "^(25[0-5]|2[0-4]\\d|[0-1]\\d{2}|[1-9]?\\d)\\.(25[0-5]|2[0-4]\\d|[0-1]\\d{2}|[1-9]?\\d)\\.(25[0-5]|2[0-4]\\d|[0-1]\\d{2}|[1-9]?\\d)\\.(25[0-5]|2[0-4]\\d|[0-1]\\d{2}|[1-9]?\\d)$", // ip地址 letter: "^[A-Za-z]+$", // 字母 letter_l: "^[a-z]+$", // 小写字母 letter_u: "^[A-Z]+$", // 大写字母 mobile: "^0?(13|15|18|14|17)[0-9]{9}$", //^1[3|4|5|7|8]\d{9}$ // 手机 notempty: "^\\S+$", // 非空 password: "^.*[A-Za-z0-9\\w_-]+.*$", // 密码 fullNumber: "^[0-9]+$", // 数字 picture: "(.*)\\.(jpg|bmp|gif|ico|pcx|jpeg|tif|png|raw|tga)$", // 图片 qq: "^[1-9]*[1-9][0-9]*$", // QQ号码 rar: "(.*)\\.(rar|zip|7zip|tgz)$", // 压缩文件 tel: "^[0-9\-()()]{7,18}$", // 电话号码的函数(包括验证国内区号,国际区号,分机号) url: "^http[s]?:\\/\\/([\\w-]+\\.)+[\\w-]+([\\w-./?%&=]*)?$", // url username: "^[A-Za-z0-9_\\-\\u4e00-\\u9fa5]+$", // 用户名 deptname: "^[A-Za-z0-9_()()\\-\\u4e00-\\u9fa5]+$", // 单位名 zipcode: "^\\d{6}$", // 邮编 realname: "^[A-Za-z\\u4e00-\\u9fa5]+$", // 真实姓名 addr: "^[A-Za-z0-9_()()\\#\\-\\u4e00-\\u9fa5]+$", siteurl: "^http[s]?:\\/\\/([\\w-]+\\.)+[\\w-]+([\\w-./?%&#=]*)?$" }; $.validate = { isAmount: function(str){ return new RegExp(validateRegExp.decmal1).test(str); }, isEmpty: function(a) { return typeof(a)=='undefined' || !a || a == '0' //return new RegExp("^[\\s+]*$").test(a) }, isChinese: function(a) { return new RegExp("^[\\u4e00-\\u9fa5]+$").test(a) }, isLetter: function(a) { return new RegExp("^[A-Za-z]+$").test(a) }, isNumeric: function(a) { return new RegExp("^([+-]?)\\d*\\.?\\d+$").test(a) }, isBetweenLength: function(str, _min, _max) { return (str.length >= _min && str.length <= _max); }, isUsername: function(str) { return new RegExp(validateRegExp.username).test(str); }, isFullNumberName: function(str) { return new RegExp(validateRegExp.fullNumber).test(str); }, isPassword: function(str) { return /^.*([\W_a-zA-z0-9-])+.*$/i.test(str); }, isEmail: function(str) { return new RegExp(validateRegExp.email).test(str); }, isTelephone: function(str) { return new RegExp(validateRegExp.tel).test(str); }, isMobile: function(str) { return new RegExp(validateRegExp.mobile).test(str); }, isRealName: function(str) { return new RegExp(validateRegExp.realname).test(str); }, isAddress: function(str) { return new RegExp(validateRegExp.addr).test(str); }, isSiteUrl: function(str) { return new RegExp(validateRegExp.siteurl).test(str); } }; /**模板引擎**/ /** * {for item in items} ${item.id} {/for} * {if}{else}{/if} */ var TrimPath; !function() { null == TrimPath && (TrimPath = new Object), null == TrimPath.evalEx && (TrimPath.evalEx = function(src) { return eval(src) }); var UNDEFINED; null == Array.prototype.pop && (Array.prototype.pop = function() { return 0 === this.length ? UNDEFINED : this[--this.length] }), null == Array.prototype.push && (Array.prototype.push = function() { for (var a = 0; a < arguments.length; ++a) this[this.length] = arguments[a]; return this.length }), TrimPath.parseTemplate = function(a, b, c) { null == c && (c = TrimPath.parseTemplate_etc); var d = parse(a, b, c); var e = TrimPath.evalEx(d, b, 1); return null != e ? new c.Template(b, a, d, e, c) : null }; try { /** * 绑定成处理字符串 * @param a * @param b * @returns {*} */ String.prototype.process = function(a, b) { var c = TrimPath.parseTemplate(this, null); return null != c ? c.process(a, b) : this } /** * 绑定成 jQuery插件 * @param a * @param b * @returns {*} */ $.fn.tpl = function(a, b) { var html = $(this).html(); var c = TrimPath.parseTemplate(html, null); return null != c ? c.process(a, b) : this } } catch (e) {; } TrimPath.parseTemplate_etc = {}, TrimPath.parseTemplate_etc.statementTag = "forelse|for|if|elseif|else|var|macro", TrimPath.parseTemplate_etc.statementDef = { "if": { delta: 1, prefix: "if (", suffix: ") {", paramMin: 1 }, "else": { delta: 0, prefix: "} else {" }, elseif: { delta: 0, prefix: "} else if (", suffix: ") {", paramDefault: "true" }, "/if": { delta: -1, prefix: "}" }, "for": { delta: 1, paramMin: 3, prefixFunc: function(a, b, c, d) { if ("in" != a[2]) throw new d.ParseError(c, b.line, "bad for loop statement: " + a.join(" ")); var e = a[1]; var f = "__LIST__" + e; return ["var ", f, " = ", a[3], ";", "var __LENGTH_STACK__;", "if (typeof(__LENGTH_STACK__) == 'undefined' || !__LENGTH_STACK__.length) __LENGTH_STACK__ = new Array();", "__LENGTH_STACK__[__LENGTH_STACK__.length] = 0;", "if ((", f, ") != null) { ", "var ", e, "_ct = 0;", "for (var ", e, "_index in ", f, ") { ", e, "_ct++;", "if (typeof(", f, "[", e, "_index]) == 'function') {continue;}", "__LENGTH_STACK__[__LENGTH_STACK__.length - 1]++;", "var ", e, " = ", f, "[", e, "_index];"].join("") } }, forelse: { delta: 0, prefix: "} } if (__LENGTH_STACK__[__LENGTH_STACK__.length - 1] == 0) { if (", suffix: ") {", paramDefault: "true" }, "/for": { delta: -1, prefix: "} }; delete __LENGTH_STACK__[__LENGTH_STACK__.length - 1];" }, "var": { delta: 0, prefix: "var ", suffix: ";" }, macro: { delta: 1, prefixFunc: function(a) { var e = a[1].split("(")[0]; return ["var ", e, " = function", a.slice(1).join(" ").substring(e.length), "{ var _OUT_arr = []; var _OUT = { write: function(m) { if (m) _OUT_arr.push(m); } }; "].join("") } }, "/macro": { delta: -1, prefix: " return _OUT_arr.join(''); };" } }, TrimPath.parseTemplate_etc.modifierDef = { eat: function() { return "" }, escape: function(a) { return String(a).replace(/&/g, "&").replace(//g, ">") }, capitalize: function(a) { return String(a).toUpperCase() }, "default": function(a, b) { return null != a ? a : b } }, TrimPath.parseTemplate_etc.modifierDef.h = TrimPath.parseTemplate_etc.modifierDef.escape, TrimPath.parseTemplate_etc.Template = function(a, b, c, d, e) { this.process = function(a, b) { null == a && (a = {}), null == a._MODIFIERS && (a._MODIFIERS = {}), null == a.defined && (a.defined = function(b) { return void 0 != a[b] }); for (var c in e.modifierDef) null == a._MODIFIERS[c] && (a._MODIFIERS[c] = e.modifierDef[c]); null == b && (b = {}); var f = []; var g = { write: function(a) { f.push(a) } }; try { d(g, a, b) } catch (h) { if (1 == b.throwExceptions) throw h; var i = new String(f.join("") + "[ERROR: " + h.toString() + (h.message ? "; " + h.message : "") + "]"); return i.exception = h, i } return f.join("") }, this.name = a, this.source = b, this.sourceFunc = c, this.toString = function() { return "TrimPath.Template [" + a + "]" } }, TrimPath.parseTemplate_etc.ParseError = function(a, b, c) { this.name = a, this.line = b, this.message = c }, TrimPath.parseTemplate_etc.ParseError.prototype.toString = function() { return "TrimPath template ParseError in " + this.name + ": line " + this.line + ", " + this.message }; var parse = function(a, b, c) { a = cleanWhiteSpace(a); var d = ["var TrimPath_Template_TEMP = function(_OUT, _CONTEXT, _FLAGS) { with (_CONTEXT) {"]; var e = { stack: [], line: 1 }; var f = -1; for (; f + 1 < a.length;) { var g = f; for (g = a.indexOf("{", g + 1); g >= 0;) { var h = a.indexOf("}", g + 1); var i = a.substring(g, h); var j = i.match(/^\{(cdata|minify|eval)/); if (j) { var k = j[1]; var l = g + k.length + 1; var m = a.indexOf("}", l); if (m >= 0) { var n; n = 0 >= m - l ? "{/" + k + "}" : a.substring(l + 1, m); var o = a.indexOf(n, m + 1); if (o >= 0) { emitSectionText(a.substring(f + 1, g), d); var p = a.substring(m + 1, o); "cdata" == k ? emitText(p, d) : "minify" == k ? emitText(scrubWhiteSpace(p), d) : "eval" == k && null != p && p.length > 0 && d.push("_OUT.write( (function() { " + p + " })() );"), g = f = o + n.length - 1 } } } else if ("$" != a.charAt(g - 1) && "\\" != a.charAt(g - 1)) { var q = "/" == a.charAt(g + 1) ? 2 : 1; if (0 == a.substring(g + q, g + 10 + q).search(TrimPath.parseTemplate_etc.statementTag)) break } g = a.indexOf("{", g + 1) } if (0 > g) break; var h = a.indexOf("}", g + 1); if (0 > h) break; emitSectionText(a.substring(f + 1, g), d), emitStatement(a.substring(g, h + 1), e, d, b, c), f = h } if (emitSectionText(a.substring(f + 1), d), 0 != e.stack.length) throw new c.ParseError(b, e.line, "unclosed, unmatched statement(s): " + e.stack.join(",")); return d.push("}}; TrimPath_Template_TEMP"), d.join("") }; var emitStatement = function(a, b, c, d, e) { var f = a.slice(1, -1).split(" "); var g = e.statementDef[f[0]]; if (null == g) return void emitSectionText(a, c); if (g.delta < 0) { if (b.stack.length <= 0) throw new e.ParseError(d, b.line, "close tag does not match any previous statement: " + a); b.stack.pop() } if (g.delta > 0 && b.stack.push(a), null != g.paramMin && g.paramMin >= f.length) throw new e.ParseError(d, b.line, "statement needs more parameters: " + a); if (c.push(null != g.prefixFunc ? g.prefixFunc(f, b, d, e) : g.prefix), null != g.suffix) { if (f.length <= 1) null != g.paramDefault && c.push(g.paramDefault); else for (var h = 1; h < f.length; h++) h > 1 && c.push(" "), c.push(f[h]); c.push(g.suffix) } }; var emitSectionText = function(a, b) { if (!(a.length <= 0)) { var c = 0; var d = a.length - 1; for (; c < a.length && "\n" == a.charAt(c);) c++; for (; d >= 0 && (" " == a.charAt(d) || " " == a.charAt(d));) d--; if (c > d && (d = c), c > 0) { b.push('if (_FLAGS.keepWhitespace == true) _OUT.write("'); var e = a.substring(0, c).replace("\n", "\\n"); "\n" == e.charAt(e.length - 1) && (e = e.substring(0, e.length - 1)), b.push(e), b.push('");') } var f = a.substring(c, d + 1).split("\n"); for (var g = 0; g < f.length; g++) emitSectionTextLine(f[g], b), g < f.length - 1 && b.push('_OUT.write("\\n");\n'); if (d + 1 < a.length) { b.push('if (_FLAGS.keepWhitespace == true) _OUT.write("'); var e = a.substring(d + 1).replace("\n", "\\n"); "\n" == e.charAt(e.length - 1) && (e = e.substring(0, e.length - 1)), b.push(e), b.push('");') } } }; var emitSectionTextLine = function(a, b) { var c = "}"; var d = -1; for (; d + c.length < a.length;) { var e = "${", f = "}"; var g = a.indexOf(e, d + c.length); if (0 > g) break; "%" == a.charAt(g + 2) && (e = "${%", f = "%}"); var h = a.indexOf(f, g + e.length); if (0 > h) break; emitText(a.substring(d + c.length, g), b); var i = a.substring(g + e.length, h).replace(/\|\|/g, "#@@#").split("|"); for (var j in i) i[j].replace && (i[j] = i[j].replace(/#@@#/g, "||")); b.push("_OUT.write("), emitExpression(i, i.length - 1, b), b.push(");"), d = h, c = f } emitText(a.substring(d + c.length), b) }; var emitText = function(a, b) { null == a || a.length <= 0 || (a = a.replace(/\\/g, "\\\\"), a = a.replace(/\n/g, "\\n"), a = a.replace(/"/g, '\\"'), b.push('_OUT.write("'), b.push(a), b.push('");')) }; var emitExpression = function(a, b, c) { var d = a[b]; if (0 >= b) return void c.push(d); var e = d.split(":"); c.push('_MODIFIERS["'), c.push(e[0]), c.push('"]('), emitExpression(a, b - 1, c), e.length > 1 && (c.push(","), c.push(e[1])), c.push(")") }; var cleanWhiteSpace = function(a) { return a = a.replace(/\t/g, " "), a = a.replace(/\r\n/g, "\n"), a = a.replace(/\r/g, "\n"), a = a.replace(/^(\s*\S*(\s+\S+)*)\s*$/, "$1") }; var scrubWhiteSpace = function(a) { return a = a.replace(/^\s+/g, ""), a = a.replace(/\s+$/g, ""), a = a.replace(/\s+/g, " "), a = a.replace(/^(\s*\S*(\s+\S+)*)\s*$/, "$1") }; TrimPath.parseDOMTemplate = function(a, b, c) { null == b && (b = document); var d = b.getElementById(a); var e = d.value; return null == e && (e = d.innerHTML), e = e.replace(//g, ">"), TrimPath.parseTemplate(e, a, c) }, TrimPath.processDOMTemplate = function(a, b, c, d, e) { return TrimPath.parseDOMTemplate(a, d, e).process(b, c) } }(); })(jQuery);