! function(e, t) { var n = !0; e && "undefined" != typeof e.umd && (n = e.umd), n && "object" == typeof exports ? module.exports = t(require("jquery"), require("handlebars"), require("bootstrap")) : n && "function" == typeof define && define.amd ? define("alpaca", ["jquery", "handlebars", "bootstrap"], t) : e.Alpaca = t(e.jQuery, e.Handlebars, e.Bootstrap) }(this, function($, Handlebars, Bootstrap) { return this.HandlebarsPrecompiled = this.HandlebarsPrecompiled || {}, this.HandlebarsPrecompiled["web-display"] = this.HandlebarsPrecompiled["web-display"] || {}, this.HandlebarsPrecompiled["web-display"]["container-array-item"] = Handlebars.template({ 1: function(e, t, n, i, a) { return "" }, compiler: [7, ">= 4.0.0"], main: function(e, t, n, i, a) { var r, o, l, s = '\n" }, useData: !0 }), this.HandlebarsPrecompiled["web-display"]["container-array"] = Handlebars.template({ 1: function(e, t, n, i, a) { var r, o, l, s = "\n "; return o = null != (o = n.item || (null != t ? t.item : t)) ? o : n.helperMissing, l = { name: "item", hash: {}, fn: e.program(2, a, 0), inverse: e.noop, data: a }, r = "function" == typeof o ? o.call(null != t ? t : {}, l) : o, n.item || (r = n.blockHelperMissing.call(t, r, l)), null != r && (s += r), s + "\n\n" }, 2: function(e, t, n, i, a) { return "" }, compiler: [7, ">= 4.0.0"], main: function(e, t, n, i, a) { var r; return '" }, useData: !0 }), this.HandlebarsPrecompiled["web-display"]["container-object-item"] = Handlebars.template({ 1: function(e, t, n, i, a) { return "" }, compiler: [7, ">= 4.0.0"], main: function(e, t, n, i, a) { var r, o, l, s = '\n" }, useData: !0 }), this.HandlebarsPrecompiled["web-display"]["container-object"] = Handlebars.template({ 1: function(e, t, n, i, a) { var r, o, l, s = "\n "; return o = null != (o = n.item || (null != t ? t.item : t)) ? o : n.helperMissing, l = { name: "item", hash: {}, fn: e.program(2, a, 0), inverse: e.noop, data: a }, r = "function" == typeof o ? o.call(null != t ? t : {}, l) : o, n.item || (r = n.blockHelperMissing.call(t, r, l)), null != r && (s += r), s + "\n\n" }, 2: function(e, t, n, i, a) { return "" }, compiler: [7, ">= 4.0.0"], main: function(e, t, n, i, a) { var r; return '" }, useData: !0 }), this.HandlebarsPrecompiled["web-display"]["container-table-item"] = Handlebars.template({ 1: function(e, t, n, i, a) { return "" }, compiler: [7, ">= 4.0.0"], main: function(e, t, n, i, a) { var r; return '\n" }, useData: !0 }), this.HandlebarsPrecompiled["web-display"]["container-table"] = Handlebars.template({ 1: function(e, t, n, i, a) { return "" }, 3: function(e, t, n, i, a) { var r; return "
\n \n ' + (null != (r = e.lambda(t, t)) ? r : "") + "\n
\n" }, 6: function(e, t, n, i, a) { var r; return e.escapeExpression(e.lambda(null != (r = null != t ? t.options : t) ? r.helperClass : r, t)) }, 8: function(e, t, n, i, a) { return "" }, compiler: [7, ">= 4.0.0"], main: function(e, t, n, i, a) { var r, o, l, s = null != t ? t : {}, u = '" }, useData: !0 }), this.HandlebarsPrecompiled["web-display"]["control-any"] = Handlebars.template({ compiler: [7, ">= 4.0.0"], main: function(e, t, n, i, a) { var r; return '" }, useData: !0 }), this.HandlebarsPrecompiled["web-display"]["control-checkbox"] = Handlebars.template({ compiler: [7, ">= 4.0.0"], main: function(e, t, n, i, a) { var r; return '" }, useData: !0 }), this.HandlebarsPrecompiled["web-display"]["control-hidden"] = Handlebars.template({ compiler: [7, ">= 4.0.0"], main: function(e, t, n, i, a) { return '' }, useData: !0 }), this.HandlebarsPrecompiled["web-display"]["control-image"] = Handlebars.template({ compiler: [7, ">= 4.0.0"], main: function(e, t, n, i, a) { var r, o = null != t ? t : {}, l = n.helperMissing, s = "function", u = e.escapeExpression; return '' }, useData: !0 }), this.HandlebarsPrecompiled["web-display"]["control-password"] = Handlebars.template({ 1: function(e, t, n, i, a) { return "" }, compiler: [7, ">= 4.0.0"], main: function(e, t, n, i, a) { var r; return '" }, useData: !0 }), this.HandlebarsPrecompiled["web-display"]["control-radio"] = Handlebars.template({ 1: function(e, t, n, i, a, r, o) { var l; return null != (l = (n.compare || t && t.compare || n.helperMissing).call(null != t ? t : {}, null != t ? t.value : t, null != o[1] ? o[1].data : o[1], { name: "compare", hash: {}, fn: e.program(2, a, 0, r, o), inverse: e.noop, data: a })) ? l : "" }, 2: function(e, t, n, i, a) { var r, o; return " " + (null != (o = null != (o = n.text || (null != t ? t.text : t)) ? o : n.helperMissing, r = "function" == typeof o ? o.call(null != t ? t : {}, { name: "text", hash: {}, data: a }) : o) ? r : "") + "\n" }, compiler: [7, ">= 4.0.0"], main: function(e, t, n, i, a, r, o) { var l; return '\n" }, useData: !0, useDepths: !0 }), this.HandlebarsPrecompiled["web-display"]["control-select"] = Handlebars.template({ compiler: [7, ">= 4.0.0"], main: function(e, t, n, i, a) { var r; return '\n" }, useData: !0 }), this.HandlebarsPrecompiled["web-display"]["control-text"] = Handlebars.template({ compiler: [7, ">= 4.0.0"], main: function(e, t, n, i, a) { var r, o; return '" }, useData: !0 }), this.HandlebarsPrecompiled["web-display"]["control-textarea"] = Handlebars.template({ compiler: [7, ">= 4.0.0"], main: function(e, t, n, i, a) { var r, o; return '" }, useData: !0 }), this.HandlebarsPrecompiled["web-display"]["control-url"] = Handlebars.template({ 1: function(e, t, n, i, a) { var r; return 'target="' + e.escapeExpression(e.lambda(null != (r = null != t ? t.options : t) ? r.anchorTarget : r, t)) + '"' }, 3: function(e, t, n, i, a) { var r; return e.escapeExpression(e.lambda(null != (r = null != t ? t.options : t) ? r.anchorTitle : r, t)) }, 5: function(e, t, n, i, a) { var r; return e.escapeExpression((r = null != (r = n.data || (null != t ? t.data : t)) ? r : n.helperMissing, "function" == typeof r ? r.call(null != t ? t : {}, { name: "data", hash: {}, data: a }) : r)) }, 7: function(e, t, n, i, a) { var r; return " " + e.escapeExpression(e.lambda(null != (r = null != t ? t.options : t) ? r.anchorTitle : r, t)) + "\n" }, 9: function(e, t, n, i, a) { var r; return " " + e.escapeExpression((r = null != (r = n.data || (null != t ? t.data : t)) ? r : n.helperMissing, "function" == typeof r ? r.call(null != t ? t : {}, { name: "data", hash: {}, data: a }) : r)) + "\n" }, compiler: [7, ">= 4.0.0"], main: function(e, t, n, i, a) { var r, o, l = null != t ? t : {}; return '" }, useData: !0 }), this.HandlebarsPrecompiled["web-display"].control = Handlebars.template({ 1: function(e, t, n, i, a) { var r, o, l = null != t ? t : {}; return ' \n" }, 2: function(e, t, n, i, a) { var r; return e.escapeExpression(e.lambda(null != (r = null != t ? t.options : t) ? r.labelClass : r, t)) }, 4: function(e, t, n, i, a) { return "" }, 6: function(e, t, n, i, a) { var r; return null != (r = n.each.call(null != t ? t : {}, null != (r = null != t ? t.options : t) ? r.helpers : r, { name: "each", hash: {}, fn: e.program(7, a, 0), inverse: e.noop, data: a })) ? r : "" }, 7: function(e, t, n, i, a) { var r; return '\n \n ' + (null != (r = e.lambda(t, t)) ? r : "") + "\n
\n" }, 8: function(e, t, n, i, a) { var r; return e.escapeExpression(e.lambda(null != (r = null != t ? t.options : t) ? r.helperClass : r, t)) }, compiler: [7, ">= 4.0.0"], main: function(e, t, n, i, a) { var r, o, l, s = null != t ? t : {}, u = '\n" }, useData: !0 }), this.HandlebarsPrecompiled["web-display"].form = Handlebars.template({ 1: function(e, t, n, i, a) { return "" }, 3: function(e, t, n, i, a) { var r; return null != (r = n.each.call(null != t ? t : {}, null != (r = null != t ? t.options : t) ? r.buttons : r, { name: "each", hash: {}, fn: e.program(4, a, 0), inverse: e.noop, data: a })) ? r : "" }, 4: function(e, t, n, i, a) { var r, o, l = null != t ? t : {}, s = n.helperMissing, u = "function", c = e.escapeExpression; return ' \n" }, 5: function(e, t, n, i, a) { return 'type="submit"' }, 7: function(e, t, n, i, a) { return 'type="reset"' }, 9: function(e, t, n, i, a) { var r, o = e.escapeExpression; return o((r = null != (r = n.key || a && a.key) ? r : n.helperMissing, "function" == typeof r ? r.call(null != t ? t : {}, { name: "key", hash: {}, data: a }) : r)) + '="' + o(e.lambda(t, t)) + '"' }, 11: function(e, t, n, i, a) { var r, o = e.escapeExpression; return " " + o((r = null != (r = n.key || a && a.key) ? r : n.helperMissing, "function" == typeof r ? r.call(null != t ? t : {}, { name: "key", hash: {}, data: a }) : r)) + '="' + o(e.lambda(t, t)) + '"' }, compiler: [7, ">= 4.0.0"], main: function(e, t, n, i, a) { var r, o, l, s = null != t ? t : {}, u = '" }, useData: !0 }), this.HandlebarsPrecompiled["web-edit"] = this.HandlebarsPrecompiled["web-edit"] || {}, this.HandlebarsPrecompiled["web-edit"]["container-array-actionbar"] = Handlebars.template({ 1: function(e, t, n, i, a, r, o) { var l, s, u = e.escapeExpression, c = null != t ? t : {}; return ' \n" }, 2: function(e, t, n, i, a) { return ' \n' }, 4: function(e, t, n, i, a) { var r, o; return null != (o = null != (o = n.label || (null != t ? t.label : t)) ? o : n.helperMissing, r = "function" == typeof o ? o.call(null != t ? t : {}, { name: "label", hash: {}, data: a }) : o) ? r : "" }, compiler: [7, ">= 4.0.0"], main: function(e, t, n, i, a, r, o) { var l, s, u = null != t ? t : {}, c = n.helperMissing, d = "function", p = e.escapeExpression; return '" }, useData: !0, useDepths: !0 }), this.HandlebarsPrecompiled["web-edit"]["container-array-item"] = Handlebars.template({ 1: function(e, t, n, i, a) { var r, o, l, s = null != t ? t : {}, u = n.helperMissing, c = "function", d = n.blockHelperMissing, p = '\n \n ' + (null != (r = e.lambda(t, t)) ? r : "") + "\n
\n" }, 6: function(e, t, n, i, a) { var r; return e.escapeExpression(e.lambda(null != (r = null != t ? t.options : t) ? r.helperClass : r, t)) }, 8: function(e, t, n, i, a) { return "" }, compiler: [7, ">= 4.0.0"], main: function(e, t, n, i, a) { var r, o, l, s = null != t ? t : {}, u = '" }, useData: !0 }), this.HandlebarsPrecompiled["web-edit"]["control-any"] = Handlebars.template({ 1: function(e, t, n, i, a) { return 'readonly="readonly"' }, 3: function(e, t, n, i, a) { var r; return 'name="' + e.escapeExpression((r = null != (r = n.name || (null != t ? t.name : t)) ? r : n.helperMissing, "function" == typeof r ? r.call(null != t ? t : {}, { name: "name", hash: {}, data: a }) : r)) + '"' }, 5: function(e, t, n, i, a) { var r, o = e.escapeExpression; return "data-" + o((r = null != (r = n.key || a && a.key) ? r : n.helperMissing, "function" == typeof r ? r.call(null != t ? t : {}, { name: "key", hash: {}, data: a }) : r)) + '="' + o(e.lambda(t, t)) + '"' }, compiler: [7, ">= 4.0.0"], main: function(e, t, n, i, a) { var r, o, l = null != t ? t : {}; return '" }, useData: !0 }), this.HandlebarsPrecompiled["web-edit"]["control-checkbox"] = Handlebars.template({ 1: function(e, t, n, i, a, r, o) { var l; return "\n" + (null != (l = n.each.call(null != t ? t : {}, null != t ? t.checkboxOptions : t, { name: "each", hash: {}, fn: e.program(2, a, 0, r, o), inverse: e.noop, data: a })) ? l : "") + "\n" }, 2: function(e, t, n, i, a, r, o) { var l, s, u = null != t ? t : {}, c = n.helperMissing, d = "function", p = e.escapeExpression; return '\n\n \n ' + (null != (r = e.lambda(t, t)) ? r : "") + "\n
\n" }, 8: function(e, t, n, i, a) { var r; return e.escapeExpression(e.lambda(null != (r = null != t ? t.options : t) ? r.helperClass : r, t)) }, 10: function(e, t, n, i, a) { var r; return null != (r = n["if"].call(null != t ? t : {}, null != (r = null != t ? t.options : t) ? r.buttons : r, { name: "if", hash: {}, fn: e.program(11, a, 0), inverse: e.noop, data: a })) ? r : "" }, 11: function(e, t, n, i, a) { var r; return ' \n" }, 12: function(e, t, n, i, a) { var r, o, l = null != t ? t : {}, s = n.helperMissing, u = "function", c = e.escapeExpression; return ' \n" }, 13: function(e, t, n, i, a) { var r, o = null != t ? t : {}, l = n.helperMissing, s = "function", u = e.escapeExpression; return u((r = null != (r = n.key || a && a.key) ? r : l, typeof r === s ? r.call(o, { name: "key", hash: {}, data: a }) : r)) + '="' + u((r = null != (r = n.value || (null != t ? t.value : t)) ? r : l, typeof r === s ? r.call(o, { name: "value", hash: {}, data: a }) : r)) + '" ' }, compiler: [7, ">= 4.0.0"], main: function(e, t, n, i, a) { var r, o, l, s = null != t ? t : {}, u = '" }, useData: !0 }), this.HandlebarsPrecompiled["web-edit"].form = Handlebars.template({ 1: function(e, t, n, i, a) { return "" }, 3: function(e, t, n, i, a) { var r; return null != (r = n.each.call(null != t ? t : {}, null != (r = null != t ? t.options : t) ? r.buttons : r, { name: "each", hash: {}, fn: e.program(4, a, 0), inverse: e.noop, data: a })) ? r : "" }, 4: function(e, t, n, i, a) { var r, o, l = null != t ? t : {}, s = n.helperMissing, u = "function", c = e.escapeExpression; return ' \n" }, 5: function(e, t, n, i, a) { var r; return 'id="' + e.escapeExpression((r = null != (r = n.id || (null != t ? t.id : t)) ? r : n.helperMissing, "function" == typeof r ? r.call(null != t ? t : {}, { name: "id", hash: {}, data: a }) : r)) + '"' }, 7: function(e, t, n, i, a) { var r, o = e.escapeExpression; return o((r = null != (r = n.key || a && a.key) ? r : n.helperMissing, "function" == typeof r ? r.call(null != t ? t : {}, { name: "key", hash: {}, data: a }) : r)) + '="' + o(e.lambda(t, t)) + '"' }, 9: function(e, t, n, i, a) { var r, o = e.escapeExpression; return " " + o((r = null != (r = n.key || a && a.key) ? r : n.helperMissing, "function" == typeof r ? r.call(null != t ? t : {}, { name: "key", hash: {}, data: a }) : r)) + '="' + o(e.lambda(t, t)) + '"' }, compiler: [7, ">= 4.0.0"], main: function(e, t, n, i, a) { var r, o, l, s = null != t ? t : {}, u = '" }, useData: !0 }), this.HandlebarsPrecompiled["web-edit"].message = Handlebars.template({ compiler: [7, ">= 4.0.0"], main: function(e, t, n, i, a) { var r, o, l = null != t ? t : {}, s = n.helperMissing, u = "function"; return '" }, useData: !0 }), this.HandlebarsPrecompiled["web-edit"].wizard = Handlebars.template({ 1: function(e, t, n, i, a) { var r; return '\n \n ' + (null != (r = e.lambda(t, t)) ? r : "") + "\n
\n" }, 10: function(e, t, n, i, a) { var r; return e.escapeExpression(e.lambda(null != (r = null != t ? t.options : t) ? r.helperClass : r, t)) }, 12: function(e, t, n, i, a) { return "" }, compiler: [7, ">= 4.0.0"], main: function(e, t, n, i, a) { var r, o, l, s = null != t ? t : {}, u = '\n" }, useData: !0 }), this.HandlebarsPrecompiled["bootstrap-display"]["control-radio"] = Handlebars.template({ 1: function(e, t, n, i, a, r, o) { var l; return null != (l = (n.compare || t && t.compare || n.helperMissing).call(null != t ? t : {}, null != t ? t.value : t, null != o[1] ? o[1].data : o[1], { name: "compare", hash: {}, fn: e.program(2, a, 0, r, o), inverse: e.noop, data: a })) ? l : "" }, 2: function(e, t, n, i, a) { var r, o; return " " + (null != (o = null != (o = n.text || (null != t ? t.text : t)) ? o : n.helperMissing, r = "function" == typeof o ? o.call(null != t ? t : {}, { name: "text", hash: {}, data: a }) : o) ? r : "") + "\n" }, compiler: [7, ">= 4.0.0"], main: function(e, t, n, i, a, r, o) { var l; return '\n" }, useData: !0, useDepths: !0 }), this.HandlebarsPrecompiled["bootstrap-display"]["control-select"] = Handlebars.template({ compiler: [7, ">= 4.0.0"], main: function(e, t, n, i, a) { var r; return '\n" }, useData: !0 }), this.HandlebarsPrecompiled["bootstrap-display"]["control-upload-partial-download"] = Handlebars.template({ 1: function(e, t, n, i, a) { var r, o = e.lambda, l = e.escapeExpression; return '\n \n ' + (null != (r = e.lambda(t, t)) ? r : "") + "\n
\n" }, 8: function(e, t, n, i, a) { var r; return e.escapeExpression(e.lambda(null != (r = null != t ? t.options : t) ? r.helperClass : r, t)) }, compiler: [7, ">= 4.0.0"], main: function(e, t, n, i, a) { var r, o, l, s = null != t ? t : {}, u = '" }, useData: !0 }), this.HandlebarsPrecompiled["bootstrap-display"].message = Handlebars.template({ compiler: [7, ">= 4.0.0"], main: function(e, t, n, i, a) { var r, o; return '" }, useData: !0 }), this.HandlebarsPrecompiled["bootstrap-edit"] = this.HandlebarsPrecompiled["bootstrap-edit"] || {}, this.HandlebarsPrecompiled["bootstrap-edit"]["container-grid"] = Handlebars.template({ 1: function(e, t, n, i, a) { return " btn-group" }, 3: function(e, t, n, i, a, r, o) { var l, s = null != t ? t : {}, u = n.helperMissing; return "\n" + (null != (l = (n.compare || t && t.compare || u).call(s, null != (l = null != o[1] ? o[1].options : o[1]) ? l.toolbarStyle : l, "link", { name: "compare", hash: {}, fn: e.program(4, a, 0, r, o), inverse: e.noop, data: a })) ? l : "") + "\n" + (null != (l = (n.compare || t && t.compare || u).call(s, null != (l = null != o[1] ? o[1].options : o[1]) ? l.toolbarStyle : l, "button", { name: "compare", hash: {}, fn: e.program(6, a, 0, r, o), inverse: e.noop, data: a })) ? l : "") + "\n" }, 4: function(e, t, n, i, a) { var r = e.lambda, o = e.escapeExpression; return ' ' + o(r(null != t ? t.label : t, t)) + "\n" }, 6: function(e, t, n, i, a, r, o) { var l, s, u = e.escapeExpression, c = null != t ? t : {}; return ' \n" }, 7: function(e, t, n, i, a) { var r; return ' \n' }, 9: function(e, t, n, i, a) { var r, o; return null != (o = null != (o = n.label || (null != t ? t.label : t)) ? o : n.helperMissing, r = "function" == typeof o ? o.call(null != t ? t : {}, { name: "label", hash: {}, data: a }) : o) ? r : "" }, compiler: [7, ">= 4.0.0"], main: function(e, t, n, i, a, r, o) { var l, s = null != t ? t : {}; return '' }, useData: !0, useDepths: !0 }), this.HandlebarsPrecompiled["bootstrap-edit"]["container-table"] = Handlebars.template({ 1: function(e, t, n, i, a) { return "" }, 3: function(e, t, n, i, a) { return ' \n\n \n ' + (null != (r = e.lambda(t, t)) ? r : "") + "\n
\n" }, 10: function(e, t, n, i, a) { var r; return e.escapeExpression(e.lambda(null != (r = null != t ? t.options : t) ? r.helperClass : r, t)) }, 12: function(e, t, n, i, a) { return "" }, compiler: [7, ">= 4.0.0"], main: function(e, t, n, i, a) { var r, o, l, s = null != t ? t : {}, u = '\n" }, useData: !0 }), this.HandlebarsPrecompiled["bootstrap-edit"]["control-colorpicker"] = Handlebars.template({ 1: function(e, t, n, i, a) { return '\n \n ' + (null != (r = e.lambda(t, t)) ? r : "") + "\n
\n" }, 8: function(e, t, n, i, a) { var r; return e.escapeExpression(e.lambda(null != (r = null != t ? t.options : t) ? r.helperClass : r, t)) }, 10: function(e, t, n, i, a) { var r; return null != (r = n["if"].call(null != t ? t : {}, null != (r = null != t ? t.options : t) ? r.buttons : r, { name: "if", hash: {}, fn: e.program(11, a, 0), inverse: e.noop, data: a })) ? r : "" }, 11: function(e, t, n, i, a) { var r; return ' \n" }, 12: function(e, t, n, i, a) { var r, o, l = null != t ? t : {}, s = n.helperMissing, u = "function", c = e.escapeExpression; return ' \n" }, 13: function(e, t, n, i, a) { var r, o = null != t ? t : {}, l = n.helperMissing, s = "function", u = e.escapeExpression; return u((r = null != (r = n.key || a && a.key) ? r : l, typeof r === s ? r.call(o, { name: "key", hash: {}, data: a }) : r)) + '="' + u((r = null != (r = n.value || (null != t ? t.value : t)) ? r : l, typeof r === s ? r.call(o, { name: "value", hash: {}, data: a }) : r)) + '" ' }, compiler: [7, ">= 4.0.0"], main: function(e, t, n, i, a) { var r, o, l, s = null != t ? t : {}, u = '" }, useData: !0 }), this.HandlebarsPrecompiled["bootstrap-edit"].message = Handlebars.template({ compiler: [7, ">= 4.0.0"], main: function(e, t, n, i, a) { var r, o, l = null != t ? t : {}, s = n.helperMissing, u = "function"; return '" }, useData: !0 }), function(e, t) { e.Base = t() }(this, function() { var e = "function", t = "object", n = "string", i = !1, a = ["constructor", "toString", "valueOf"], r = a.length, o = /\bbase\b/, l = function() {}, s = { toSource: null, base: l }, u = function() {}; return u.extend = function(n, a) { var r = u.prototype.extend; i = !0; var o = new this; r.call(o, n), o.base = s.base, i = !1; var l = o.constructor, c = o.constructor = function() { i || (this && (this._constructing || this.constructor === c) ? (this._constructing = !0, l.apply(this, arguments), this._constructing = !1) : arguments.length && u.cast.apply(c, arguments)) }; return r.call(c, this), c.ancestor = this, c.prototype = o, c.valueOf = function(e) { return e === t ? c : l.valueOf() }, r.call(c, a), typeof c.init === e && c.init(), c }, u.prototype.extend = function(l, c) { if (typeof l === n && arguments.length > 1) { var d = this[l]; if (d && typeof c === e && (!d.valueOf || d.valueOf() !== c.valueOf()) && o.test(c)) { var p = c.valueOf(); c = function() { var e, t = this.base || s.base; return this.base = d, e = 0 === arguments.length ? p.call(this) : p.apply(this, arguments), this.base = t, e }, c.valueOf = function(e) { return e === t ? c : p }, c.toString = u.toString } this[l] = c } else if (l) { var h = u.prototype.extend; i || typeof this === e || (h = this.extend || h); for (var f, m = i ? 0 : 1; r > m; m++) f = a[m], l[f] !== s[f] && h.call(this, f, l[f]); for (f in l) s[f] || h.call(this, f, l[f]) } return this }, u = u.extend({ base: s.base }, { ancestor: Object, version: "1.1", cast: function() { for (var t, n, i = 0, a = arguments.length; a > i; i++) n = arguments[i], t = n.extend || u.prototype.extend, typeof n === e ? (t = n.prototype.extend || u.prototype.extend, t.call(n.prototype, this.prototype), t.call(n, this), n.ancestor = this) : t.call(n, this.prototype); return this }, implement: function() { for (var e = 0; e < arguments.length; e++) this.cast.call(arguments[e], this); return this }, toString: function() { return this.valueOf() + "" } }) }), function(e) { var t = function() { var n = t.makeArray(arguments); if (0 === n.length) return t.throwDefaultError("You must supply at least one argument. This argument can either be a DOM element against which Alpaca will generate a form or it can be a function name. See http://www.alpacajs.org for more details."); var i = n[0]; i && t.isString(i) && (i = e("#" + i)); var a = null, r = null, o = null, l = null, s = null, u = null, c = null, d = null, p = !1, h = {}, f = null, m = null, g = null, v = null, b = function(n, a) { var r = null, o = e(n).attr("data-alpaca-field-id"); if (o) { var l = t.fieldInstances[o]; l && (r = l) } if (!r) { var s = e(n).attr("data-alpaca-form-id"); if (s) { var u = e(n).find(":first"); if (u.length > 0) { var c = e(u[0]).attr("data-alpaca-field-id"); if (c) { var d = t.fieldInstances[c]; d && (r = d) } } } } if (!r && !a) { var p = e(i).find(":first"); if (p.length > 0) { var h = b(p[0], !0); h && (r = h) } } if (!r && !a) { var f = e(i).parent(); if (f) { var m = b(f, !0); m && (r = m) } } return r }, y = ["get", "exists", "destroy"], w = n.length > 1 && t.isString(n[1]) && y.indexOf(n[1]) > -1, E = b(i); if (E || w) { if (w) { var x = n[1]; return "get" === x ? E : "exists" === x ? !!E : "destroy" === x ? void(E && E.destroy()) : t.throwDefaultError("Unknown special function: " + x) } return E } var F = null; if (1 === n.length) { var C = e(i).text(); F = JSON.parse(C), e(i).html("") } else F = t.isObject(n[1]) ? n[1] : t.isFunction(n[1]) ? n[1]() : { data: n[1] }; if (!F) return t.throwDefaultError("Unable to determine Alpaca configuration"); if (a = F.data, r = F.schema, o = F.options, l = F.view, s = F.render, F.callback && (s = F.callback), u = F.postRender, c = F.error, d = F.connector, f = F.dataSource, m = F.schemaSource, g = F.optionsSource, v = F.viewSource, F.ui && (h.ui = F.ui), F.type && (h.type = F.type), t.isEmpty(F.notTopLevel) || (p = F.notTopLevel), t.isEmpty(c) && (c = t.defaultErrorCallback), !d || !d.connect) { var T = "default", S = {}; t.isString(d) ? T = d : t.isObject(d) && d.id && (T = d.id, d.config && (S = d.config)); var k = t.getConnectorClass(T); k || (k = t.getConnectorClass("default")), d = new k(T, S) } var A = d; if (p) { var O = t.getConnectorClass("default"); A = new O("default") } o || (o = {}); var I = function(e) { e.parent || (e.hideInitValidationError || e.refreshValidationState(!0), "view" !== e.view.type && t.fieldApplyFieldAndChildren(e, function(e) { e.hideInitValidationError = !1 })) }, M = function(e) { e.parent || (e.observableScope = t.generateId()), e.parent || t.fireReady(e), t.isUndefined(o.focus) && !e.parent && (o.focus = t.defaultFocus), o && o.focus ? window.setTimeout(function() { var t = function(e) { e.suspendBlurFocus = !0, e.focus(), e.suspendBlurFocus = !1 }; if (o.focus) { if (e.isControlField && e.isAutoFocusable()) t(e); else if (e.isContainerField) if (o.focus === !0) e.children && e.children.length > 0 && t(e); else if ("string" == typeof o.focus) { var n = e.getControlByPath(o.focus); n && n.isControlField && n.isAutoFocusable() && t(n) } I(e) } }, 500) : I(e), u && u(e) }; A.loadAll({ data: a, schema: r, options: o, view: l, dataSource: f, schemaSource: m, optionsSource: g, viewSource: v }, function(e, n, u, p) { return e = e ? e : a, u = u ? u : r, n = n ? n : o, p = p ? p : l, t.isEmpty(e) && t.isEmpty(u) && (t.isEmpty(n) || t.isEmpty(n.type)) && (e = "", t.isEmpty(n) ? n = "text" : o && t.isObject(o) && (n.type = "text")), n.view && (p = n.view), t.init(i, e, n, u, p, h, s, M, d, c) }, function(e) { return c(e), null }) }; t.Fields = {}, t.Connectors = {}, t.Extend = e.extend, t.Create = function() { var t = Array.prototype.slice.call(arguments); return t.unshift({}), e.extend.apply(this, t) }, t.Extend(t, { makeArray: function(e) { return Array.prototype.slice.call(e) }, isFunction: function(e) { return "[object Function]" === Object.prototype.toString.call(e) }, isString: function(e) { return "string" == typeof e }, isObject: function(e) { return !t.isUndefined(e) && "[object Object]" === Object.prototype.toString.call(e) }, isPlainObject: function(t) { return e.isPlainObject(t) }, isNumber: function(e) { return "number" == typeof e }, isArray: function(e) { return e instanceof Array }, isBoolean: function(e) { return "boolean" == typeof e }, isUndefined: function(e) { return "undefined" == typeof e }, trim: function(e) { var n = e; return n && t.isString(n) && (n = n.replace(/^\s+|\s+$/g, "")), n }, safeDomParse: function(n) { if (n && t.isString(n)) { n = t.trim(n); var i = null; try { i = e(n) } catch (a) { n = "displayReadonly attribute set to false, the read-only field will not appear.", type: "boolean", "default": !1 }, required: { title: "Required", description: "Indicates whether the field's value is required. If set to true, the field must take on a valid value and cannnot be left empty or unassigned.", type: "boolean", "default": !1 }, "default": { title: "Default", description: "The default value to be assigned for this property. If the data for the field is empty or not provided, this default value will be plugged in for you. Specify a default value when you want to pre-populate the field's value ahead of time.", type: "any" }, type: { title: "Type", description: "Data type of the property.", type: "string", readonly: !0 }, format: { title: "Format", description: "Data format of the property.", type: "string" }, disallow: { title: "Disallowed Values", description: "List of disallowed values for the property.", type: "array" }, dependencies: { title: "Dependencies", description: "List of property dependencies.", type: "array" } } };
return this.getType && !t.isValEmpty(this.getType()) && (e.properties.type["default"] = this.getType(),
e.properties.type["enum"] = [this.getType()]), e
},
getOptionsForSchema: function() {
return { fields: { title: { helper: "Field short description", type: "text" }, description: { helper: "Field detailed description", type: "textarea" }, readonly: { helper: "Field will be read only if checked", rightLabel: "This field is read-only", type: "checkbox" }, required: { helper: "Field value must be set if checked", rightLabel: "This field is required", type: "checkbox" }, "default": { helper: "Field default value", type: "textarea" }, type: { helper: "Field data type", type: "text" }, format: { type: "select", dataSource: function(e) {
for (var n in t.defaultFormatFieldMapping) this.selectOptions.push({ value: n, text: n });
e() } }, disallow: { helper: "Disallowed values for the field", itemLabel: "Value", type: "array" }, dependencies: { helper: "Field Dependencies", multiple: !0, size: 3, type: "select", dataSource: function(e, t) {
if (e.parent && e.parent.schemaParent && e.parent.schemaParent.parent)
for (var n in e.parent.schemaParent.parent.childrenByPropertyId) n != e.parent.schemaParent.propertyId && e.selectOptions.push({ value: n, text: n });
t && t() } } } } },
getSchemaOfOptions: function() {
var e = { title: "Options for " + this.getTitle(), description: this.getDescription() + " (Options)", type: "object", properties: { form: {}, id: { title: "Field Id", description: "Unique field id. Auto-generated if not provided.", type: "string" }, type: { title: "Field Type", description: "Field type.", type: "string", "default": this.getFieldType(), readonly: !0 }, validate: { title: "Validation", description: "Field validation is required if true.", type: "boolean", "default": !0 }, showMessages: { title: "Show Messages", description: "Display validation messages if true.", type: "boolean", "default": !0 }, disabled: { title: "Disabled", description: "Field will be disabled if true.", type: "boolean", "default": !1 }, readonly: { title: "Readonly", description: "Field will be readonly if true.", type: "boolean", "default": !1 }, hidden: { title: "Hidden", description: "Field will be hidden if true.", type: "boolean", "default": !1 }, label: { title: "Label", description: "Field label.", type: "string" }, helper: { title: "Helper", description: "Field help message.", type: "string" }, helpers: { title: "Helpers", description: "An array of field help messages. Each message will be displayed on it's own line.", type: "array", items: { type: "string" } }, fieldClass: { title: "CSS class", description: "Specifies one or more CSS classes that should be applied to the dom element for this field once it is rendered. Supports a single value, comma-delimited values, space-delimited values or values passed in as an array.", type: "string" }, hideInitValidationError: { title: "Hide Initial Validation Errors", description: "Hide initial validation errors if true.", type: "boolean", "default": !1 }, focus: { title: "Focus", description: "If true, the initial focus for the form will be set to the first child element (usually the first field in the form). If a field name or path is provided, then the specified child field will receive focus. For example, you might set focus to 'name' (selecting the 'name' field) or you might set it to 'client/name' which picks the 'name' field on the 'client' object.", type: "checkbox", "default": !0 }, optionLabels: { title: "Enumerated Value Labels", description: "An array of string labels for items in the enum array", type: "array" }, view: { title: "Override of the view for this field", description: "Allows for this field to be rendered with a different view (such as 'display' or 'create')", type: "string" } } };
return this.isTopLevel() ? e.properties.form = { title: "Form", description: "Options for rendering the FORM tag.", type: "object", properties: { attributes: { title: "Form Attributes", description: "List of attributes for the FORM tag.", type: "object", properties: { id: { title: "Id", description: "Unique form id. Auto-generated if not provided.", type: "string" }, action: { title: "Action", description: "Form submission endpoint", type: "string" }, method: { title: "Method", description: "Form submission method", "enum": ["post", "get"], type: "string" }, rubyrails: { title: "Ruby On Rails", description: "Ruby on Rails Name Standard", "enum": ["true", "false"], type: "string" }, name: { title: "Name", description: "Form name", type: "string" }, focus: { title: "Focus", description: "Focus Setting", type: "any" } } }, buttons: { title: "Form Buttons", description: "Configuration for form-bound buttons", type: "object", properties: { submit: { type: "object", title: "Submit Button", required: !1 }, reset: { type: "object", title: "Reset button", required: !1 } } }, toggleSubmitValidState: { title: "Toggle Submit Valid State", description: "Toggle the validity state of the Submit button", type: "boolean", "default": !0 } } } : delete e.properties.form, e },
getOptionsForOptions: function() {
var e = { type: "object", fields: { id: { type: "text", readonly: !0 }, type: { type: "text" }, validate: { rightLabel: "Enforce validation", type: "checkbox" }, showMessages: { rightLabel: "Show validation messages", type: "checkbox" }, disabled: { rightLabel: "Disable this field", type: "checkbox" }, hidden: { type: "checkbox", rightLabel: "Hide this field" }, label: { type: "text" }, helper: { type: "textarea" }, helpers: { type: "array", items: { type: "textarea" } }, fieldClass: { type: "text" }, hideInitValidationError: { rightLabel: "Hide initial validation errors", type: "checkbox" }, focus: { type: "checkbox", rightLabel: "Auto-focus first child field" }, optionLabels: { type: "array", items: { type: "text" } }, view: { type: "text" } } };
return this.isTopLevel() && (e.fields.form = { type: "object", fields: { attributes: { type: "object", fields: { id: { type: "text", readonly: !0 }, action: { type: "text" }, method: { type: "select" }, name: { type: "text" } } } } }), e }
}), t.registerMessages({ disallowValue: "{0} are disallowed values.", notOptional: "This field is not optional." })
}(jQuery),
function(e) {
var t = e.alpaca;
t.ControlField = t.Field.extend({ onConstruct: function() {
var t = this;
this.isControlField = !0, this._getControlVal = function(n) {
var i = null;
return this.control && (i = e(this.control).val(), n && (i = t.ensureProperType(i))), i } }, setup: function() {
var e = this;
this.base();
var n = e.resolveControlTemplateType();
if (!n) return t.throwErrorWithCallback("Unable to find template descriptor for control: " + e.getFieldType());
if (this.controlDescriptor = this.view.getTemplateDescriptor("control-" + n, e), "undefined" == typeof this.options.renderButtons && (this.options.renderButtons = !0), this.options.buttons)
for (var i in this.options.buttons) this.options.buttons[i].label && (this.options.buttons[i].value = this.options.buttons[i].label), this.options.buttons[i].title && (this.options.buttons[i].value = this.options.buttons[i].title), this.options.buttons[i].type || (this.options.buttons[i].type = "button"), this.options.buttons[i].styles || (this.options.buttons[i].styles = this.view.styles.button) }, getControlEl: function() {
return this.control }, resolveControlTemplateType: function() {
var e = this,
t = !1,
n = null,
i = this;
do
if (i.getFieldType) {
var a = this.view.getTemplateDescriptor("control-" + i.getFieldType(), e);
a ? (n = i.getFieldType(), t = !0) : i = i.constructor.ancestor.prototype } else t = !0;
while (!t);
return n }, onSetup: function() {}, isAutoFocusable: function() {
return !0 }, getTemplateDescriptorId: function() {
return "control" }, renderFieldElements: function(n) {
var i = this;
this.control = e(this.field).find("." + t.MARKER_CLASS_CONTROL_FIELD), this.control.removeClass(t.MARKER_CLASS_CONTROL_FIELD), i.prepareControlModel(function(e) { i.beforeRenderControl(e, function() { i.renderControl(e, function(a) { a && (i.control.replaceWith(a), i.control = a, i.control.addClass(t.CLASS_CONTROL)), i.fireCallback("control"), i.afterRenderControl(e, function() { n() }) }) }) }) }, prepareControlModel: function(e) {
var t = {};
t.id = this.getId(), t.name = this.name, t.options = this.options, t.schema = this.schema, t.data = this.data, t.required = this.isRequired(), t.view = this.view, e(t) }, beforeRenderControl: function(e, t) { t() }, afterRenderControl: function(t, n) {
var i = this;
i.firstUpdateObservableFire || "undefined" == typeof i.data || null == i.data || (i.firstUpdateObservableFire = !0, i.updateObservable()), e(this.getFieldEl()).find(".alpaca-control-button").each(function() { e(this).click(function(t) { e(this).attr("button-pushed", !0) });
var t = e(this).attr("data-key");
if (t) {
var n = i.options.buttons[t];
n && n.click && e(this).click(function(e, t) {
return function(n) { n.preventDefault(), t.call(e, n) } }(i, n.click)) } }), n() }, renderControl: function(e, n) {
var i = null;
this.controlDescriptor && (i = t.tmpl(this.controlDescriptor, e)), n(i) }, postRender: function(e) { this.base(function() { e() }) }, updateDOMElement: function() { this.base(), this.control.attr("name", this.getName()) }, setDefault: function() {
var e = t.isEmpty(this.schema["default"]) ? "" : this.schema["default"];
this.setValue(e) }, getValue: function() {
var e = this,
t = this.base();
return this.isDisplayOnly() || (t = e.getControlValue()), t = e.ensureProperType(t) }, getControlValue: function() {
return this._getControlVal(!0) }, _validateEnum: function() {
if (!this.getEnum()) return !0;
var e = this.getValue();
return !this.isRequired() && t.isValEmpty(e) ? !0 : t.inArray(this.getEnum(), e) }, handleValidate: function() {
var e = this.base(),
n = this.validation,
i = this._validateEnum(),
a = this.getEnum(),
r = this.getOptionLabels();
return r && r.length > 0 && (a = r), n.invalidValueOfEnum = { message: i ? "" : t.substituteTokens(this.getMessage("invalidValueOfEnum"), [a.join(", "), this.getValue()]), status: i }, e && n.invalidValueOfEnum.status }, initEvents: function() { this.base(), this.control && this.control.length > 0 && this.initControlEvents() }, initControlEvents: function() {
var e = this,
t = this.control;
t.click(function(t) { e.onClick.call(e, t), e.trigger("click", t) }), t.change(function(t) { setTimeout(function() { e.onChange.call(e, t), e.triggerWithPropagation("change", t) }, 200) }), t.focus(function(t) {
if (e.wasFocused = !0, !e.suspendBlurFocus) {
var n = e.onFocus.call(e, t);
return n !== !1 && (n = e.trigger("focus", t)), n } }), t.blur(function(t) {
if (e.wasBlurred = !0, !e.suspendBlurFocus) {
var n = e.onBlur.call(e, t);
return n !== !1 && (n = e.trigger("blur", t)), n } }), t.keypress(function(t) {
var n = e.onKeyPress.call(e, t);
return n !== !1 && (n = e.trigger("keypress", t)), n }), t.keyup(function(t) {
var n = e.onKeyUp.call(e, t);
return n !== !1 && (n = e.trigger("keyup", t)), n }), t.keydown(function(t) {
var n = e.onKeyDown.call(e, t);
return n !== !1 && (n = e.trigger("keydown", t)), n }) }, onKeyPress: function(e) {
var t = this,
n = !1;
if (t.view.type && "edit" === t.view.type) {
var i = this.isValid();
i || (n = !0) } else if (t.view.type && "create" === t.view.type) {
var i = this.isValid();!i && t.wasBlurred && (n = !0) }
n && window.setTimeout(function() { t.refreshValidationState() }, 50) }, onKeyDown: function(e) {}, onKeyUp: function(e) {}, onClick: function(e) {}, disable: function() { this.options.readonly || (this.base(), this.control && this.control.length > 0 && e(this.control).prop("disabled", !0)) }, enable: function() { this.options.readonly || (this.base(), this.control && this.control.length > 0 && e(this.control).prop("disabled", !1)) }, isDisabled: function() {
return e(this.control).prop("disabled") }, getEnum: function() {
var e = null;
return this.schema && this.schema["enum"] && (e = this.schema["enum"]), e }, setEnum: function(e) { t.safeSetObjectArray(this.schema, "enum", e) }, getOptionLabels: function() {
var e = null;
return this.options && this.options.optionLabels && (e = this.options.optionLabels), e }, setOptionLabels: function(e) { t.safeSetObjectArray(this.options, "optionLabels", e) }, sortEnum: function() {
var e = this.getEnum();
if (e && e.length > 0) {
for (var n = this.getOptionLabels(), i = [], a = 0; a < e.length; a++) {
var r = e[a],
o = e[a];
n && n.length >= a + 1 && (o = n[a]), i.push({ value: r, text: o }) }
this.sortSelectableOptions(i);
for (var l = [], s = [], a = 0; a < i.length; a++) l.push(i[a].value), t.isArray(n) && s.push(i[a].text);
this.setEnum(l), this.setOptionLabels(s) } }, sortSelectableOptions: function(e) {
var n = this;
if (n.options.sort !== !1) {
var i = t.defaultSort;
n.options.sort && "function" == typeof n.options.sort && (i = n.options.sort), e.sort(i) } }, invokeDataSource: function(n, i, a) {
var r = this,
o = function(e) {
var t = this;
return e ? a(e) : void t.afterLoadDataSourceOptions(n, i, function(e, n) {
return e ? a(e) : (t.sortSelectableOptions(n), void a(null, n)) }) }.bind(r);
if (t.isFunction(r.options.dataSource)) r.options.dataSource.call(r, function(e) {
if (t.isArray(e)) {
for (var i = 0; i < e.length; i++) "string" == typeof e[i] ? n.push({ text: e[i], value: e[i] }) : t.isObject(e[i]) && n.push(e[i]);
o() } else if (t.isObject(e)) {
for (var a in e) n.push({ text: a, value: e[a] });
o() } else o() });
else if (t.isUri(r.options.dataSource)) {
var l = r.view.locale,
s = "" + r.options.dataSource;
l && (s += -1 === s.indexOf("?") ? "?" : "&", s += "locale=" + l), e.ajax({ url: s, type: "get", dataType: "json", success: function(i) {
var a = i;
r.options.dsTransformer && t.isFunction(r.options.dsTransformer) && (a = r.options.dsTransformer(a)), a && (t.isObject(a) ? (e.each(a, function(e, t) { n.push({ value: e, text: t }) }), o()) : t.isArray(a) && (e.each(a, function(e, t) { n.push({ value: t.value, text: t.text }) }), o())) }, error: function(e, t, n) { r.errorCallback({ message: "Unable to load data from uri : " + r.options.dataSource, stage: "DATASOURCE_LOADING_ERROR", details: { jqXHR: e, textStatus: t, errorThrown: n } }) } }) } else if (t.isArray(r.options.dataSource)) {
for (var u = r.options.dataSource, c = 0; c < u.length; c++) "string" == typeof u[c] ? n.push({ text: u[c], value: u[c] }) : t.isObject(u[c]) && n.push(u[c]);
o() } else if (t.isObject(r.options.dataSource))
if (r.options.dataSource.connector) {
var d = r.connector;
if (t.isObject(r.options.dataSource.connector)) {
var p = r.options.dataSource.connector.id,
h = r.options.dataSource.connector.config;
h || (h = {});
var f = t.getConnectorClass(p);
f && (d = new f(p, h)) }
var m = r.options.dataSource.config;
m || (m = {}), d.loadDataSource(m, function(e) {
for (var i = 0; i < e.length; i++) "string" == typeof e[i] ? n.push({ text: e[i], value: e[i] }) : t.isObject(e[i]) && n.push(e[i]);
o() }) } else {
for (var g in r.options.dataSource) n.push({ text: r.options.dataSource[g], value: g });
o() }
else a() }, afterLoadDataSourceOptions: function(e, t, n) { n(null, e) }, getSchemaOfSchema: function() {
return t.merge(this.base(), { properties: { "enum": { title: "Enumerated Values", description: "List of specific values for this property", type: "array" } } }) }, getOptionsForSchema: function() {
return t.merge(this.base(), { fields: { "enum": { itemLabel: "Value", type: "array" } } }) }, getSchemaOfOptions: function() {
return t.merge(this.base(), { properties: { name: { title: "Field Name", description: "Field Name.", type: "string" }, sort: { title: "Sort Function", description: "Defines an f(a,b) sort function for the array of enumerated values [{text, value}]. This is used to sort enum and optionLabels as well as results that come back from any data sources (for select and radio controls). By default the items are sorted alphabetically. Don't apply any sorting if false.", type: "function" } } }) }, getOptionsForOptions: function() {
return t.merge(this.base(), { fields: { name: { type: "text" } } }) } }), t.registerMessages({ invalidValueOfEnum: "This field should have one of the values in {0}. Current value is: {1}" }) }(jQuery),
function(e) {
var t = e.alpaca;
t.ContainerField = t.Field.extend({ onConstruct: function() { this.isContainerField = !0 }, isContainer: function() {
return !0 }, getContainerEl: function() {
return this.container }, getTemplateDescriptorId: function() {
return "container" }, resolveContainerTemplateType: function() {
var e = !1,
t = null,
n = this;
do
if (n.getFieldType) {
var i = this.view.getTemplateDescriptor("container-" + n.getFieldType(), this);
i ? (t = n.getFieldType(), e = !0) : n = n.constructor.ancestor.prototype } else e = !0;
while (!e);
return t }, resolveContainerItemTemplateType: function() {
var e = !1,
t = null,
n = this;
do
if (n.getFieldType) {
var i = this.view.getTemplateDescriptor("container-" + n.getFieldType() + "-item", this);
i ? (t = n.getFieldType(), e = !0) : n = n.constructor.ancestor.prototype } else e = !0;
while (!e);
return t }, setup: function() {
var e = this;
this.base();
var n = e.resolveContainerTemplateType();
if (!n) return t.throwErrorWithCallback("Unable to find template descriptor for container: " + e.getFieldType());
this.containerDescriptor = this.view.getTemplateDescriptor("container-" + n, e);
var i = !1;
t.isEmpty(this.view.collapsible) || (i = this.view.collapsible), t.isEmpty(this.options.collapsible) || (i = this.options.collapsible), this.options.collapsible = i;
var a = "button";
t.isEmpty(this.view.legendStyle) || (a = this.view.legendStyle), t.isEmpty(this.options.legendStyle) || (a = this.options.legendStyle), this.options.legendStyle = a, this.lazyLoading = !1, t.isEmpty(this.options.lazyLoading) || (this.lazyLoading = this.options.lazyLoading, this.lazyLoading && (this.options.collapsed = !0)), this.children = [], this.childrenById = {}, this.childrenByPropertyId = {} }, destroy: function() { this.form && (this.form.destroy(!0), delete this.form), t.each(this.children, function() { this.destroy() }), this.base() }, renderFieldElements: function(n) {
var i = this;
this.container = e(this.field).find("." + t.MARKER_CLASS_CONTAINER_FIELD), this.container.removeClass(t.MARKER_CLASS_CONTAINER_FIELD), i.prepareContainerModel(function(e) { i.beforeRenderContainer(e, function() { i.renderContainer(e, function(a) { a && (i.container.replaceWith(a), i.container = a, i.container.addClass(t.CLASS_CONTAINER)), i.view.horizontal ? i.container.addClass("alpaca-horizontal") : i.container.addClass("alpaca-vertical"), i.fireCallback("container"), i.afterRenderContainer(e, function() { n() }) }) }) }) }, prepareContainerModel: function(e) {
var t = this,
n = { id: this.getId(), name: this.name, schema: this.schema, options: this.options, view: this.view };
t.createItems(function(t) { t || (t = []);
for (var i = 0; i < t.length; i++) t[i].containerItemEl || (t[i].containerItemEl = t[i].getFieldEl());
n.items = t, e(n) }) }, beforeRenderContainer: function(e, t) { t() }, renderContainer: function(e, n) {
var i = null;
this.containerDescriptor && (i = t.tmpl(this.containerDescriptor, e)), n(i) }, afterRenderContainer: function(e, t) {
var n = this;
n.beforeApplyCreatedItems(e, function() { n.applyCreatedItems(e, function() { n.afterApplyCreatedItems(e, function() { t() }) }) }) }, postRender: function(e) { this.base(function() { e() }) }, initEvents: function() { this.base() }, createItems: function(e) { e() }, beforeApplyCreatedItems: function(e, t) { t() }, applyCreatedItems: function(n, i) {
var a = this,
r = null;
if (a.isTopLevel() && a.view.getLayout() && (r = a.view.getLayout().bindings, !r && a.view.getLayout().templateDescriptor && n.items.length > 0)) { r = {};
for (var o = 0; o < n.items.length; o++) {
var l = n.items[o].name;
r[l] = "[data-alpaca-layout-binding='" + l + "']" } }
n.items.length > 0 ? (e(a.container).addClass("alpaca-container-has-items"), e(a.container).attr("data-alpaca-container-item-count", n.items.length)) : (e(a.container).removeClass("alpaca-container-has-items"), e(a.container).removeAttr("data-alpaca-container-item-count"));
for (var o = 0; o < n.items.length; o++) {
var s = n.items[o],
u = e(a.container).find("." + t.MARKER_CLASS_CONTAINER_FIELD_ITEM + "[" + t.MARKER_DATA_CONTAINER_FIELD_ITEM_KEY + "='" + s.name + "']");
if (r) {
var c = r[s.name];
if (c) {
var d = e(c, a.field);
if (0 == d.length) try { d = e("#" + c, a.field) } catch (p) {}
d.length > 0 && (s.domEl = e(""), e(s.domEl).addClass("alpaca-layout-binding-holder"), e(s.domEl).attr("alpaca-layout-binding-field-name", s.name), d.append(s.domEl), s.domEl.append(s.containerItemEl)) }
e(u).remove() } else {
var d = e(u).parent();
e(u).replaceWith(s.containerItemEl), s.domEl = d }
e(s.containerItemEl).addClass("alpaca-container-item"), 0 === o && e(s.containerItemEl).addClass("alpaca-container-item-first"), o + 1 === n.items.length && e(s.containerItemEl).addClass("alpaca-container-item-last"), e(s.containerItemEl).attr("data-alpaca-container-item-index", o), e(s.containerItemEl).attr("data-alpaca-container-item-name", s.name), e(s.containerItemEl).attr("data-alpaca-container-item-parent-field-id", a.getId()), a.registerChild(s, o) }
a.options.collapsible && a.fireCallback("collapsible"), a.triggerUpdate(), i() }, afterApplyCreatedItems: function(e, t) { t() }, registerChild: function(e, n) { t.isEmpty(n) ? this.children.push(e) : this.children.splice(n, 0, e), this.childrenById[e.getId()] = e, e.propertyId && (this.childrenByPropertyId[e.propertyId] = e), e.parent = this }, unregisterChild: function(e) {
var n = this.children[e];
n && (t.isEmpty(e) || this.children.splice(e, 1), delete this.childrenById[n.getId()], n.propertyId && delete this.childrenByPropertyId[n.propertyId], n.parent = null) }, updateDOMElement: function() {
var t = this;
this.base(), t.children.length > 0 ? (e(t.getContainerEl()).addClass("alpaca-container-has-items"), e(t.getContainerEl()).attr("data-alpaca-container-item-count", t.children.length)) : (e(t.getContainerEl()).removeClass("alpaca-container-has-items"), e(t.getContainerEl()).removeAttr("data-alpaca-container-item-count"));
for (var n = 0; n < t.children.length; n++) {
var i = t.children[n];
i.path || ("array" === i.schema.type ? i.path = t.path + "[" + n + "]" : i.path = t.path + "/" + i.propertyId), i.calculateName(), e(i.containerItemEl).removeClass("alpaca-container-item-first"), e(i.containerItemEl).removeClass("alpaca-container-item-last"), e(i.containerItemEl).removeClass("alpaca-container-item-index"), e(i.containerItemEl).removeClass("alpaca-container-item-key"), e(i.containerItemEl).addClass("alpaca-container-item"), 0 === n && e(i.containerItemEl).addClass("alpaca-container-item-first"), n + 1 === t.children.length && e(i.containerItemEl).addClass("alpaca-container-item-last"), e(i.containerItemEl).attr("data-alpaca-container-item-index", n), e(i.containerItemEl).attr("data-alpaca-container-item-name", i.name), e(i.containerItemEl).attr("data-alpaca-container-item-parent-field-id", t.getId()), t.updateChildDOMWrapperElement(n, i), i.updateDOMElement() } }, updateChildDOMWrapperElement: function(e, t) {}, handleRepositionDOMRefresh: function() {
var e = this;
e.getParent() ? e.getParent().updateDOMElement() : e.updateDOMElement() }, onDependentReveal: function() {
for (var e = 0; e < this.children.length; e++) this.children[e].onDependentReveal() }, onDependentConceal: function() {
for (var e = 0; e < this.children.length; e++) this.children[e].onDependentConceal() }, focus: function(t) {
var n = this;
if (this.isDisplayOnly()) return void(t && t());
this.base();
var i = -1,
a = [],
r = this.getContainerEl();
this.form && (r = this.form.getFormEl()), e(r).find(".alpaca-container-item[data-alpaca-container-item-parent-field-id='" + this.getId() + "']").each(function() {
var t = e(this).attr("data-alpaca-container-item-index");
a.push(n.children[t]) });
for (var o = 0; o < a.length; o++)
if (a[o] && !a[o].isValid(!0) && a[o].isControlField && a[o].isAutoFocusable() && !a[o].options.readonly) { i = o;
break } - 1 === i && a.length > 0 && (i = 0), i > -1 && (a[i].focus(), t && t(a[i])) }, disable: function() {
if (!this.options.readonly) { this.base();
for (var e = 0; e < this.children.length; e++) this.children[e].disable() } }, enable: function() {
if (!this.options.readonly) { this.base();
for (var e = 0; e < this.children.length; e++) this.children[e].enable() } }, getValue: function() {
var e = this,
t = e.getContainerValue();
return t }, getContainerValue: function() {
return null }, firstChild: function() {
var e = null;
return this.children.length > 0 && (e = this.children[0]), e }, lastChild: function() {
var e = null;
return this.children.length > 0 && (e = this.children[this.children.length - 1]), e }, getSchemaOfOptions: function() {
return t.merge(this.base(), { properties: { lazyLoading: { title: "Lazy Loading", description: "Child fields will only be rendered when the fieldset is expanded if this option is set true.", type: "boolean", "default": !1 }, collapsible: { title: "Collapsible", description: "Field set is collapsible if true.", type: "boolean", "default": !1 }, collapsed: { title: "Collapsed", description: "Field set is initially collapsed if true.", type: "boolean", "default": !1 }, legendStyle: { title: "Legend Style", description: "Field set legend style.", type: "string", "enum": ["button", "link"], "default": "button" }, animate: { title: "Animate movements and transitions", description: "Up and down transitions will be animated", type: "boolean", "default": !0 } } }) }, getOptionsForOptions: function() {
return t.merge(this.base(), { fields: { lazyLoading: { rightLabel: "Lazy loading child fields ?", helper: "Lazy loading will be enabled if checked.", type: "checkbox" }, collapsible: { rightLabel: "Field set collapsible ?", helper: "Field set is collapsible if checked.", type: "checkbox" }, collapsed: { rightLabel: "Field set initially collapsed ?", description: "Field set is initially collapsed if checked.", type: "checkbox" }, legendStyle: { type: "select" }, animate: { rightLabel: "Animate movements and transitions", type: "checkbox" } } }) } }) }(jQuery),
function(e) {
var t = e.alpaca;
t.Form = Base.extend({ constructor: function(e, n, i, a, r) {
if (this.domEl = e, this.parent = null, this.connector = a, this.errorCallback = r, this.options = n, this.options.attributes ? this.attributes = this.options.attributes : this.attributes = {}, this.options.buttons) { this.options.buttons.submit && (this.options.buttons.submit.type || (this.options.buttons.submit.type = "submit"), this.options.buttons.submit.name || (this.options.buttons.submit.name = "submit"), this.options.buttons.submit.value || (this.options.buttons.submit.value = "Submit")), this.options.buttons.reset && (this.options.buttons.reset.type || (this.options.buttons.reset.type = "reset"), this.options.buttons.reset.name || (this.options.buttons.reset.name = "reset"), this.options.buttons.reset.value || (this.options.buttons.reset.value = "Reset"));
for (var o in this.options.buttons) this.options.buttons[o].label && (this.options.buttons[o].value = this.options.buttons[o].label), this.options.buttons[o].title && (this.options.buttons[o].value = this.options.buttons[o].title), this.options.buttons[o].type || (this.options.buttons[o].type = "button") }
this.attributes.id ? this.id = this.attributes.id : (this.id = t.generateId(), this.attributes.id = this.id), this.options.buttons && this.options.buttons.submit && t.isUndefined(this.options.toggleSubmitValidState) && (this.options.toggleSubmitValidState = !0), this.viewType = n.viewType, this.view = new t.RuntimeView(i, this);
for (var o in this.options.buttons) this.options.buttons[o].styles || (this.options.buttons[o].styles = this.view.styles.button) }, render: function(e) {
var t = this;
this.processRender(this.domEl, function() { t.form.appendTo(t.domEl), t.form.addClass("alpaca-form"), t.fireCallback("form"), e(t) }) }, afterInitialize: function() {
var e = this;
e.options.toggleSubmitValidState && e.adjustSubmitButtonState() }, isFormValid: function() { this.topControl.validate(!0);
var e = this.topControl.isValid(!0);
return e }, isValid: function() {
return this.isFormValid() }, validate: function(e) {
return this.topControl.validate(e) }, enableSubmitButton: function() {
if (e(".alpaca-form-button-submit").attrProp("disabled", !1), e.mobile) try { e(".alpaca-form-button-submit").button("refresh") } catch (t) {} }, disableSubmitButton: function() {
if (e(".alpaca-form-button-submit").attrProp("disabled", !0), e.mobile) try { e(".alpaca-form-button-submit").button("refresh") } catch (t) {} }, adjustSubmitButtonState: function() { this.disableSubmitButton(), this.isFormValid() && this.enableSubmitButton() }, processRender: function(n, i) {
var a = this;
if (this.formDescriptor = this.view.getTemplateDescriptor("form"), !this.formDescriptor) return t.throwErrorWithCallback("Could not find template descriptor: form");
var r = t.tmpl(this.formDescriptor, { id: this.getId(), options: this.options, view: this.view });
r.appendTo(n), this.form = r, this.formFieldsContainer = e(this.form).find("." + t.MARKER_CLASS_FORM_ITEMS_FIELD), this.formFieldsContainer.removeClass(t.MARKER_CLASS_FORM_ITEMS_FIELD), t.isEmpty(this.form.attr("id")) && this.form.attr("id", this.getId() + "-form-outer"), t.isEmpty(this.form.attr("data-alpaca-form-id")) && this.form.attr("data-alpaca-form-id", this.getId()), e(n).find("form").attr(this.attributes), this.buttons = {}, e(n).find(".alpaca-form-button").each(function() { e(this).click(function(t) { e(this).attr("button-pushed", !0) });
var t = e(this).attr("data-key");
if (t) {
var n = a.options.buttons[t];
n && n.click && e(this).click(function(e, t) {
return function(n) { n.preventDefault(), t.call(e, n) } }(a, n.click)) } }), i() }, getId: function() {
return this.id }, getType: function() {
return this.type }, getParent: function() {
return this.parent }, getValue: function() {
return this.topControl.getValue() }, setValue: function(e) { this.topControl.setValue(e) }, initEvents: function() {
var t = this,
n = e(this.domEl).find("form"),
i = this.getValue();
e(n).submit(i, function(e) {
return t.onSubmit(e, t) }), this.options.toggleSubmitValidState && (e(t.topControl.getFieldEl()).bind("fieldupdate", function() { t.adjustSubmitButtonState() }), e(t.topControl.getFieldEl()).bind("fieldkeyup", function() { t.adjustSubmitButtonState() }), e(t.topControl.getFieldEl()).bind("fieldblur", function() { t.adjustSubmitButtonState() })) }, getButtonEl: function(t) {
return e(this.domEl).find(".alpaca-form-button-" + t) }, onSubmit: function(e, n) {
if (!this.isFormValid()) return e.stopPropagation(), this.refreshValidationState(!0), !1;
if (this.submitHandler) { e.stopPropagation();
var i = this.submitHandler(e, n);
return t.isUndefined(i) && (i = !1), i } }, registerSubmitHandler: function(e) { t.isFunction(e) && (this.submitHandler = e) }, refreshValidationState: function(e, t) { this.topControl.refreshValidationState(e, t) }, disable: function() { this.topControl.disable() }, enable: function() { this.topControl.enable() }, focus: function(e) { this.topControl.focus(function(t) { e && e(t) }) }, destroy: function(e) { this.getFormEl().remove(), !e && this.parent && this.parent.destroy() }, show: function() { this.getFormEl().css({ display: "" }) }, hide: function() { this.getFormEl().css({ display: "none" }) }, clear: function(e) { this.topControl.clear(e) }, isEmpty: function() {
return this.topControl.isEmpty() }, fireCallback: function(e, t, n, i, a, r) { this.view.fireCallback(this, e, t, n, i, a, r) }, getFormEl: function() {
return this.form }, submit: function() { this.form.submit() }, ajaxSubmit: function(n) {
var i = this;
n || (n = {}), n.url = i.options.attributes.action, n.type = i.options.attributes.method, n.data || (n.data = this.getValue()), n.dataType || (n.dataType = "json"), n.headers || (n.headers = {});
var a = i.determineCsrfToken();
return a && (n.headers[t.CSRF_HEADER_NAME] = a), e.ajax(n) }, determineCsrfToken: function() {
var e = t.CSRF_TOKEN;
if (!e)
for (var n = 0; n < t.CSRF_COOKIE_NAMES.length; n++) {
var i = t.CSRF_COOKIE_NAMES[n],
a = t.readCookie(i);
if (a) { e = a;
break } }
return e } }) }(jQuery),
function(e) {
var t = e.alpaca,
n = 36e5;
t.Connector = Base.extend({ constructor: function(e, a) { this.id = e, this.config = a, this.isUri = function(e) {
return !t.isEmpty(e) && t.isUri(e) }, this.cache = new i("URL", !0, n) }, connect: function(e, t) { e() }, loadTemplate: function(e, n, i) { t.isEmpty(e) ? i({ message: "Empty data source.", reason: "TEMPLATE_LOADING_ERROR" }) : t.isUri(e) ? this.loadUri(e, !1, function(e) { n && t.isFunction(n) && n(e) }, function(e) { i && t.isFunction(i) && i(e) }) : n(e) }, loadData: function(e, t, n, i) {
return this._handleLoadJsonResource(e, n, i) }, loadSchema: function(e, t, n, i) {
return this._handleLoadJsonResource(e, n, i) }, loadOptions: function(e, t, n, i) {
return this._handleLoadJsonResource(e, n, i) }, loadView: function(e, t, n, i) {
return this._handleLoadJsonResource(e, n, i) }, loadAll: function(e, n, i) {
var a = this,
r = function() {
var r = e.dataSource,
o = e.schemaSource,
l = e.optionsSource,
s = e.viewSource;
o || "string" != typeof e.schema || (o = e.schema), l || "string" != typeof e.options || (l = e.options), s || "string" != typeof e.view || (s = e.view);
var u = {},
c = 0,
d = 0,
p = function() { c === d && n && t.isFunction(n) && n(u.data, u.options, u.schema, u.view) },
h = function(e) { i && t.isFunction(i) && i(e) };
if (r && d++, o && d++, l && d++, s && d++, 0 === d) return void p();
var f = function(e, n, i) { u[e] = n, i && ("object" == typeof u[e] && "object" == typeof i ? t.mergeObject(u[e], i) : u[e] = i) };
r && a.loadData(r, e, function(t) { f("data", e.data, t), c++, p() }, h), o && a.loadSchema(o, e, function(t) { f("schema", e.schema, t), c++, p() }, h), l && a.loadOptions(l, e, function(t) { f("options", e.options, t), c++, p() }, h), s && a.loadView(s, e, function(t) { f("view", e.view, t), c++, p() }, h) },
o = function(e) { i && t.isFunction(i) && i(e) };
a.connect(r, o) }, loadJson: function(e, t, n) { this.loadUri(e, !0, t, n) }, buildAjaxConfig: function(e, t) {
var n = { url: e, type: "get" };
return t ? n.dataType = "json" : n.dataType = "text", n }, loadUri: function(n, i, a, r) {
var o = this,
l = o.buildAjaxConfig(n, i);
l.success = function(e) { o.cache.put(n, e), a && t.isFunction(a) && a(e) }, l.error = function(e, i, a) { r && t.isFunction(r) && r({ message: "Unable to load data from uri : " + n, stage: "DATA_LOADING_ERROR", details: { jqXHR: e, textStatus: i, errorThrown: a } }) };
var s = o.cache.get(n);
s !== !1 && a && t.isFunction(a) ? a(s) : e.ajax(l) }, loadReferenceSchema: function(e, t, n) {
return this._handleLoadJsonResource(e, t, n) }, loadReferenceOptions: function(e, t, n) {
return this._handleLoadJsonResource(e, t, n) }, _handleLoadJsonResource: function(e, t, n) { this.isUri(e) ? this.loadJson(e, function(e) { t(e) }, n) : t(e) }, loadDataSource: function(e, t, n) {
return this._handleLoadDataSource(e, t, n) }, _handleLoadDataSource: function(e, n, i) {
var a = e;
return t.isObject(a) && (a = e.url), this._handleLoadJsonResource(a, n, i) } }), t.registerConnectorClass("default", t.Connector);
var i = function(e, t, n) {
switch (t ? this.on = !0 : this.on = !1, null != n && (this.defaultLifetime = n), this.type = e, this.type) {
case "URL":
this.put = this.put_url;
break;
case "GET":
this.put = this.put_GET } };
i.prototype.on = !1, i.prototype.type = void 0, i.prototype.defaultLifetime = 18e5, i.prototype.items = {}, i.prototype.put_url = function(e, t, n) {
null == n && (n = this.defaultLifetime);
var i = this.make_key(e);
return this.items[i] = {}, this.items[i].key = i, this.items[i].url = e, this.items[i].response = t, this.items[i].expire = (new Date).getTime() + n, !0
}, i.prototype.put_GET = function(e, t, n, i) { null == i && (i = this.defaultLifetime);
var a = this.make_key(e, [t]);
return this.items[a] = {}, this.items[a].key = a, this.items[a].url = e, this.items[a].data = t, this.items[a].response = n, this.items[a].expire = (new Date).getTime() + i, !0 }, i.prototype.get = function(e, t) {
var n = this.make_key(e, t);
return null == this.items[n] ? !1 : this.items[n].expire < (new Date).getTime() ? !1 : this.items[n].response }, i.prototype.make_key = function(e, t) {
var n = e;
switch (this.type) {
case "URL":
break;
case "GET":
n += this.stringify(t[0]) }
return n }, i.prototype.flush = function() {
return cache.items = {}, !0 }, i.prototype.stringify = function(e, t, n) {
var i;
if (gap = "", indent = "", "number" == typeof n)
for (i = 0; n > i; i += 1) indent += " ";
else "string" == typeof n && (indent = n);
if (rep = t, t && "function" != typeof t && ("object" != typeof t || "number" != typeof t.length)) throw new Error("JSON.stringify");
return this.str("", { "": e }) }, i.prototype.quote = function(e) {
var t = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;
return t.lastIndex = 0, t.test(e) ? '"' + e.replace(t, function(e) {
var t = meta[e];
return "string" == typeof t ? t : "\\u" + ("0000" + e.charCodeAt(0).toString(16)).slice(-4) }) + '"' : '"' + e + '"' }, i.prototype.str = function(e, t) {
var n, i, a, r, o, l = gap,
s = t[e];
switch (s && "object" == typeof s && "function" == typeof s.toJSON && (s = s.toJSON(e)), "function" == typeof rep && (s = rep.call(t, e, s)), typeof s) {
case "string":
return this.quote(s);
case "number":
return isFinite(s) ? String(s) : "null";
case "boolean":
case "null":
return String(s);
case "object":
if (!s) return "null";
if (gap += indent, o = [], "[object Array]" === Object.prototype.toString.apply(s)) {
for (r = s.length, n = 0; r > n; n += 1) o[n] = this.str(n, s) || "null";
return a = 0 === o.length ? "[]" : gap ? "[\n" + gap + o.join(",\n" + gap) + "\n" + l + "]" : "[" + o.join(",") + "]", gap = l, a }
if (rep && "object" == typeof rep)
for (r = rep.length, n = 0; r > n; n += 1) i = rep[n], "string" == typeof i && (a = this.str(i, s), a && o.push(this.quote(i) + (gap ? ": " : ":") + a));
else
for (i in s) Object.hasOwnProperty.call(s, i) && (a = this.str(i, s), a && o.push(this.quote(i) + (gap ? ": " : ":") + a));
return a = 0 === o.length ? "{}" : gap ? "{\n" + gap + o.join(",\n" + gap) + "\n" + l + "}" : "{" + o.join(",") + "}", gap = l, a } }
}(jQuery),
function(e) {
var t = e.alpaca;
t.CloudCmsConnector = t.Connector.extend({ connect: function(e, n) {
var i = this,
a = function(t, a) {
return t ? void n(t) : (a && (i.branch = Chain(a), i.bindHelperFunctions(i.branch)), void e()) };
t.globalContext && t.globalContext.branch ? a(null, t.globalContext.branch) : (i.branch = null, i.doConnect(function(e, t) { a(e, t) })) }, doConnect: function(e) { this.config.key || (this.config.key = "default"), Gitana.connect(this.config, function(t) {
return t ? void e(t) : void(this.getDriver().getOriginalConfiguration().loadAppHelper ? this.datastore("content").readBranch("master").then(function() { e(null, this) }) : e()) }) }, bindHelperFunctions: function(e) { e.loadAlpacaSchema || (e.loadAlpacaSchema = function(t, n, i) {
var a = function() {
return e.getUri() + "/alpaca/schema" },
r = {};
return r.id = t, this.chainGetResponse(this, a, r).then(function(e) { i.call(this, null, e) }) }), e.loadAlpacaOptions || (e.loadAlpacaOptions = function(t, n, i) {
var a = function() {
return e.getUri() + "/alpaca/options" },
r = {};
return r.schemaId = n.schemaSource, r.id = t, this.chainGetResponse(this, a, r).then(function(e) { i.call(this, null, e) }) }), e.loadAlpacaData || (e.loadAlpacaData = function(t, n, i) {
var a = function() {
return e.getUri() + "/alpaca/data" },
r = {};
return r.id = t, this.chainGetResponse(this, a, r).then(function(e) { i.call(this, null, e) }) }), e.loadAlpacaDataSource || (e.loadAlpacaDataSource = function(n, i, a) {
var r = {};
i && t.copyInto(r, i);
var o = function() {
return e.getUri() + "/alpaca/datasource" };
return this.chainPostResponse(this, o, r, n).then(function(e) { a.call(this, null, e.datasource) }) }) }, loadData: function(e, t, n, i) {
var a = this;
return a.branch ? void a.branch.loadAlpacaData(e, t, function(e, t) {
if (e) return void i(e);
var a = null;
t && (a = JSON.parse(JSON.stringify(t))), n(a) }) : this.base(e, t, n, i) }, loadSchema: function(e, t, n, i) {
var a = this;
return a.branch ? void a.branch.loadAlpacaSchema(e, t, function(e, t) {
return e ? i(e) : void n(t) }) : this.base(e, t, n, i) }, loadOptions: function(e, n, i, a) {
var r = this;
return r.branch ? void r.branch.loadAlpacaOptions(e, n, function(e, n) {
return e ? a(e) : (n || (n = {}), n.form.buttons = { submit: { title: "Submit", click: function(e) {
var t = this,
n = this.getValue();
n || (n = {});
var i = this.ajaxSubmit({ xhrFields: { withCredentials: !0 }, crossDomain: !0, processData: !1, data: JSON.stringify(n), contentType: "application/json; charset=utf-8" });
i.done(function() { t.topControl.trigger("formSubmitSuccess") }), i.fail(function() { t.topControl.trigger("formSubmitFail") }) } } }, "undefined" == typeof n.focus && (n.focus = t.defaultFocus), n.form.attributes.action = r.config.baseURL + n.form.attributes.action, void i(n)) }) : this.base(e, n, i, a) }, loadReferenceSchema: function(e, t, n) {
var i = this;
if (0 === e.indexOf("qname://")) {
var a = e.substring(8).split("/");
e = a[0] + ":" + a[1] }
if (0 === e.toLowerCase().indexOf("http://") || 0 === e.toLowerCase().indexOf("https://")) return this._handleLoadJsonResource(e, t, n);
var r = null;
return i.loadSchema(e, r, t, n) }, loadReferenceOptions: function(e, t, n) {
var i = this;
if (0 === e.toLowerCase().indexOf("http://") || 0 === e.toLowerCase().indexOf("https://")) return this._handleLoadJsonResource(e, t, n);
var a = null;
if (0 === e.indexOf("qname://")) {
var r = e.substring(8).split("/");
if (r.length > 2) return a = {}, a.schemaSource = r[0] + ":" + r[1], e = r[2], i.loadOptions(e, a, t, n) }
t(null) }, loadDataSource: function(e, t, n) {
var i = this;
if (!i.branch) return this.base(e, t, n);
var a = e.pagination;
return delete e.pagination, i.branch.loadAlpacaDataSource(e, a, function(e, i) {
return e ? void n(e) : void t(i) }) } }), t.registerConnectorClass("cloudcms", t.CloudCmsConnector) }(jQuery),
function(e) {
var t = e.alpaca;
t.Fields.TextField = t.ControlField.extend({ getFieldType: function() {
return "text" }, setup: function() { this.base(), this.inputType || (this.inputType = "text"), this.options.inputType && (this.inputType = this.options.inputType), this.options.data || (this.options.data = {}), this.options.attributes || (this.options.attributes = {}), "undefined" == typeof this.options.allowOptionalEmpty && (this.options.allowOptionalEmpty = !0), this.options.autocomplete && "string" == typeof this.options.autocomplete && ("on" === this.options.autocomplete.toLowerCase() ? this.options.autocomplete = !0 : "true" === this.options.autocomplete.toLowerCase() ? this.options.autocomplete = !0 : "yes" === this.options.autocomplete.toLowerCase() ? this.options.autocomplete = !0 : this.options.autocomplete = !1), "undefined" == typeof this.options.autocomplete && (this.options.autocomplete = !1), "undefined" == typeof this.options.disallowEmptySpaces && (this.options.disallowEmptySpaces = !1), "undefined" == typeof this.options.disallowOnlyEmptySpaces && (this.options.disallowOnlyEmptySpaces = !1) }, destroy: function() { this.base(), this.control && this.control.typeahead && this.options.typeahead && e(this.control).typeahead("destroy") }, postRender: function(e) {
var t = this;
this.base(function() { t.control && (t.applyAutocomplete(), t.applyMask(), t.applyTypeAhead(), t.updateMaxLengthIndicator()), e() }) }, applyAutocomplete: function() {
var t = this; "undefined" != typeof t.options.autocomplete && (e(t.field).addClass("alpaca-autocomplete"), e(t.control).attr("autocomplete", t.options.autocomplete ? "on" : "off"), t.fireCallback("autocomplete")) }, applyMask: function() {
var e = this;
e.control.mask && e.options.maskString && e.control.mask(e.options.maskString) }, applyTypeAhead: function() {
var n = this;
if (n.control.typeahead && n.options.typeahead && !t.isEmpty(n.options.typeahead)) {
var i = n.options.typeahead.config;
i || (i = {});
var a = n.options.typeahead.datasets;
a || (a = {}), a.name || (a.name = n.getId());
var r = n.options.typeahead.events;
if (r || (r = {}), !a.init && ("local" === a.type || "remote" === a.type || "prefetch" === a.type)) {
var o = { datumTokenizer: function(e) {
var t = "";
for (var n in e)(e.hasOwnProperty(n) || e[n]) && (t += " " + e[n]);
return Bloodhound.tokenizers.whitespace(t) }, queryTokenizer: Bloodhound.tokenizers.whitespace };
if ("local" === a.type) {
var l = [];
if ("function" == typeof a.source) o.local = a.source;
else {
for (var s = 0; s < a.source.length; s++) {
var u = a.source[s]; "string" == typeof u && (u = { value: u }), l.push(u) }
o.local = l }
a.local && (o.local = a.local) } "prefetch" === a.type && (o.prefetch = { url: a.source }, a.filter && (o.prefetch.filter = a.filter)), "remote" === a.type && (o.remote = { url: a.source }, a.filter && (o.remote.filter = a.filter), a.replace && (o.remote.replace = a.replace)), e.each(a, function(e, t) { "type" !== e && "source" !== e && "filter" !== e && "replace" !== e && "local" !== e && "templates" !== e && (o[e] = t) });
var c = new Bloodhound(o);
c.initialize(), a.source = c.ttAdapter(), a.init = !0 }
if (a.templates)
for (var d in a.templates) {
var p = a.templates[d]; "string" == typeof p && (a.templates[d] = Handlebars.compile(p)) }
e(n.control).typeahead(i, a), e(n.control).on("typeahead:autocompleted", function(t, i) { n.setValue(i.value), e(n.control).change() }), e(n.control).on("typeahead:selected", function(t, i) { n.setValue(i.value), e(n.control).change() }), r && (r.autocompleted && e(n.control).on("typeahead:autocompleted", function(e, t) { r.autocompleted(e, t) }), r.selected && e(n.control).on("typeahead:selected", function(e, t) { r.selected(e, t) }));
var h = e(n.control);
e(n.control).change(function() {
var t = e(this).val(),
n = e(h).typeahead("val");
n !== t && e(h).typeahead("val", n) }), e(n.field).find("span.twitter-typeahead").first().css("display", "block"), e(n.field).find("span.twitter-typeahead input.tt-input").first().css("background-color", "") } }, prepareControlModel: function(e) {
var t = this;
this.base(function(n) { n.inputType = t.inputType, e(n) }) }, updateMaxLengthIndicator: function() {
var n = this,
i = !1,
a = "";
if (!t.isEmpty(n.schema.maxLength) && n.options.showMaxLengthIndicator) {
var r = n.getValue() || "",
o = n.schema.maxLength - r.length;
o >= 0 ? a = "You have " + o + " characters remaining" : (a = "Your message is too long by " + -1 * o + " characters", i = !0);
var l = e(n.field).find(".alpaca-field-text-max-length-indicator");
0 === l.length && (l = e(""), e(n.control).after(l)), e(l).html(a), e(l).removeClass("err"), i && e(l).addClass("err") } }, getControlValue: function() {
var t = this,
n = this._getControlVal(!0);
if (t.control.mask && t.options.maskString) {
var i = e(this.control).data(e.mask.dataName);
i && (n = i(), n = t.ensureProperType(n)) }
return n }, setValue: function(e) { this.control && this.control.length > 0 && (t.isEmpty(e) ? this.control.val("") : this.control.val(e)), this.base(e), this.updateMaxLengthIndicator() }, handleValidate: function() {
var e = this.base(),
n = this.validation,
i = this._validatePattern();
return n.invalidPattern = { message: i ? "" : t.substituteTokens(this.getMessage("invalidPattern"), [this.schema.pattern]), status: i }, i = this._validateMaxLength(), n.stringTooLong = { message: i ? "" : t.substituteTokens(this.getMessage("stringTooLong"), [this.schema.maxLength]), status: i }, i = this._validateMinLength(), n.stringTooShort = { message: i ? "" : t.substituteTokens(this.getMessage("stringTooShort"), [this.schema.minLength]), status: i }, e && n.invalidPattern.status && n.stringTooLong.status && n.stringTooShort.status }, _validatePattern: function() {
if (this.schema.pattern) {
var e = this.getValue();
if ("" === e && this.options.allowOptionalEmpty && !this.isRequired()) return !0;
if (t.isEmpty(e) && (e = ""), "string" == typeof e && !e.match(this.schema.pattern)) return !1 }
return !0 }, _validateMinLength: function() {
if (!t.isEmpty(this.schema.minLength)) {
var e = this.getValue();
if (e !== e && (e = ""), "" === e && this.options.allowOptionalEmpty && !this.isRequired()) return !0;
if (t.isEmpty(e) && (e = ""), ("" + e).length < this.schema.minLength) return !1 }
return !0 }, _validateMaxLength: function() {
if (!t.isEmpty(this.schema.maxLength)) {
var e = this.getValue();
if ("" === e && this.options.allowOptionalEmpty && !this.isRequired()) return !0;
if (t.isEmpty(e) && (e = ""), ("" + e).length > this.schema.maxLength) return !1 }
return !0 }, focus: function(t) {
if (this.control && this.control.length > 0) {
var n = e(this.control).get(0);
try {
var i = n.value ? n.value.length : 0;
n.selectionStart = i, n.selectionEnd = i } catch (a) {}
n.focus(), t && t(this) } }, getType: function() {
return "string" }, onKeyPress: function(e) {
var n = this;
if (9 !== e.keyCode && 37 !== e.keyCode && 38 !== e.keyCode && 39 !== e.keyCode && 40 !== e.keyCode) {
if (8 === e.keyCode) {
if (!t.isEmpty(n.schema.minLength) && (n.options.constrainLengths || n.options.constrainMinLength)) {
var i = n.getValue() || "";
i.length <= n.schema.minLength && (e.preventDefault(), e.stopImmediatePropagation()) } } else if (!t.isEmpty(n.schema.maxLength) && (n.options.constrainLengths || n.options.constrainMaxLength)) {
var i = n.getValue() || "";
i.length >= n.schema.maxLength && (e.preventDefault(), e.stopImmediatePropagation()) }
32 === e.keyCode && n.options.disallowEmptySpaces && (e.preventDefault(), e.stopImmediatePropagation()) } }, onKeyUp: function(t) {
var n = this;
n.updateMaxLengthIndicator(), e(this.field).trigger("fieldkeyup") }, getTitle: function() {
return "Single-Line Text" }, getDescription: function() {
return "Text field for single-line text." }, getSchemaOfSchema: function() {
return t.merge(this.base(), { properties: { minLength: { title: "Minimal Length", description: "Minimal length of the property value.", type: "number" }, maxLength: { title: "Maximum Length", description: "Maximum length of the property value.", type: "number" }, pattern: { title: "Pattern", description: "Regular expression for the property value.", type: "string" } } }) }, getOptionsForSchema: function() {
return t.merge(this.base(), { fields: { "default": { helper: "Field default value", type: "text" }, minLength: { type: "integer" }, maxLength: { type: "integer" }, pattern: { type: "text" } } }) }, getSchemaOfOptions: function() {
return t.merge(this.base(), { properties: { size: { title: "Field Size", description: "Field size.", type: "number", "default": 40 }, maskString: { title: "Mask Expression", description: "Expression for the field mask. Field masking will be enabled if not empty.", type: "string" }, placeholder: { title: "Field Placeholder", description: "Field placeholder.", type: "string" }, typeahead: { title: "Type Ahead", description: "Provides configuration for the $.typeahead plugin if it is available. For full configuration options, see: https://github.com/twitter/typeahead.js" }, allowOptionalEmpty: { title: "Allow Optional Empty", description: "Allows this non-required field to validate when the value is empty" }, inputType: { title: "HTML5 Input Type", description: "Allows for the override of the underlying HTML5 input type. If not specified, an assumed value is provided based on the kind of input control (i.e. 'text', 'date', 'email' and so forth)", type: "string" }, data: { title: "Data attributes for the underlying DOM input control", description: "Allows you to specify a key/value map of data attributes that will be added as DOM attribuets for the underlying input control. The data attributes will be added as data-{name}='{value}'.", type: "object" }, autocomplete: { title: "HTML autocomplete attribute for the underlying DOM input control", description: "Allows you to specify the autocomplete attribute for the underlying input control whether or not field should have autocomplete enabled.", type: "string" }, disallowEmptySpaces: { title: "Disallow Empty Spaces", description: "Whether to disallow the entry of empty spaces in the text", type: "boolean", "default": !1 }, disallowOnlyEmptySpaces: { title: "Disallow Only Empty Spaces", description: "Whether to disallow the entry of only empty spaces in the text", type: "boolean", "default": !1 } } }) }, getOptionsForOptions: function() {
return t.merge(this.base(), { fields: { size: { type: "integer" }, maskString: { helper: "a - an alpha character;9 - a numeric character;* - an alphanumeric character", type: "text" }, typeahead: { type: "object" }, allowOptionalEmpty: { type: "checkbox" }, inputType: { type: "text" }, data: { type: "object" } } }) } }), t.registerMessages({ invalidPattern: "This field should have pattern {0}", stringTooShort: "This field should contain at least {0} numbers or characters", stringTooLong: "This field should contain at most {0} numbers or characters" }), t.registerFieldClass("text", t.Fields.TextField), t.registerDefaultSchemaFieldMapping("string", "text") }(jQuery),
function(e) {
var t = e.alpaca;
t.Fields.TextAreaField = t.Fields.TextField.extend({ getFieldType: function() {
return "textarea" }, setup: function() { this.base(), this.options.rows || (this.options.rows = 5), this.options.cols || (this.options.cols = 40) }, handleValidate: function() {
var e = this.base(),
n = this.validation,
i = this._validateWordCount();
return n.wordLimitExceeded = { message: i ? "" : t.substituteTokens(this.getMessage("wordLimitExceeded"), [this.options.wordlimit]), status: i }, e && n.wordLimitExceeded.status }, _validateWordCount: function() {
if (this.options.wordlimit && this.options.wordlimit > -1) {
var e = this.data;
if (e) {
var t = e.split(" ").length;
if (t > this.options.wordlimit) return !1 } }
return !0 }, getTitle: function() {
return "Multi-Line Text" }, getDescription: function() {
return "Textarea field for multiple line text." }, getSchemaOfOptions: function() {
return t.merge(this.base(), { properties: { rows: { title: "Rows", description: "Number of rows", type: "number", "default": 5 }, cols: { title: "Columns", description: "Number of columns", type: "number", "default": 40 }, wordlimit: { title: "Word Limit", description: "Limits the number of words allowed in the text area.", type: "number", "default": -1 } } }) }, getOptionsForOptions: function() {
return t.merge(this.base(), { fields: { rows: { type: "integer" }, cols: { type: "integer" }, wordlimit: { type: "integer" } } }) } }), t.registerMessages({ wordLimitExceeded: "The maximum word limit of {0} has been exceeded." }), t.registerFieldClass("textarea", t.Fields.TextAreaField) }(jQuery),
function(e) {
var t = e.alpaca;
t.Fields.CheckBoxField = t.ControlField.extend({ getFieldType: function() {
return "checkbox" }, setup: function() {
var n = this;
if (n.base(), "undefined" == typeof n.options.multiple && ("array" === n.schema.type ? n.options.multiple = !0 : "undefined" != typeof n.schema["enum"] && (n.options.multiple = !0)), n.options.multiple) {
if (n.checkboxOptions = [], n.getEnum()) { n.sortEnum();
var i = n.getOptionLabels();
e.each(n.getEnum(), function(e, a) {
var r = a;
i && (t.isEmpty(i[e]) ? t.isEmpty(i[a]) || (r = i[a]) : r = i[e]), n.checkboxOptions.push({ value: a, text: r }) }) }
n.options.datasource && !n.options.dataSource && (n.options.dataSource = n.options.datasource, delete n.options.datasource), "undefined" == typeof n.options.useDataSourceAsEnum && (n.options.useDataSourceAsEnum = !0) } else this.options.rightLabel || (this.options.rightLabel = "") }, prepareControlModel: function(e) {
var t = this;
this.base(function(n) { t.checkboxOptions && (n.checkboxOptions = t.checkboxOptions), e(n) }) }, getEnum: function() {
var e = this.base();
return e || this.schema && this.schema.items && this.schema.items["enum"] && (e = this.schema.items["enum"]), e }, getOptionLabels: function() {
var e = this.base();
return e || this.options && this.options.items && this.options.items.optionLabels && (e = this.options.items.optionLabels), e }, onClick: function(e) { this.refreshValidationState() }, beforeRenderControl: function(e, t) {
var n = this;
this.base(e, function() { n.options.dataSource ? (n.options.multiple = !0, n.checkboxOptions || (e.checkboxOptions = n.checkboxOptions = []), n.checkboxOptions.length = 0, n.invokeDataSource(n.checkboxOptions, e, function(e) {
if (n.options.useDataSourceAsEnum) {
for (var i = [], a = [], r = 0; r < n.checkboxOptions.length; r++) i.push(n.checkboxOptions[r].value), a.push(n.checkboxOptions[r].text);
n.setEnum(i), n.setOptionLabels(a) }
t() })) : t() }) }, postRender: function(t) {
var n = this;
this.base(function() {
if (n.data && "undefined" != typeof n.data && n.setValue(n.data), n.options.multiple && (e(n.getFieldEl()).find("input:checkbox").prop("checked", !1), n.data)) {
var i = n.data;
if ("string" == typeof n.data) { i = n.data.split(",");
for (var a = 0; a < i.length; a++) i[a] = e.trim(i[a]) }
for (var r in i) e(n.getFieldEl()).find('input:checkbox[data-checkbox-value="' + i[r] + '"]').prop("checked", !0) }
e(n.getFieldEl()).find("input:checkbox").change(function(e) { n.triggerWithPropagation("change") }), t() }) }, getControlValue: function() {
var n = this,
i = null;
if (n.options.multiple) {
for (var a = [], r = 0; r < n.checkboxOptions.length; r++) {
var o = e(n.getFieldEl()).find("input[data-checkbox-index='" + r + "']");
if (t.checked(o)) {
var l = e(o).attr("data-checkbox-value");
a.push(l) } } "array" === n.schema.type ? i = a : "string" === n.schema.type && (i = a.join(",")) } else {
var s = e(n.getFieldEl()).find("input");
i = s.length > 0 ? t.checked(e(s[0])) : !1 }
return i }, setValue: function(n) {
var i = this,
a = function(n) { t.isString(n) && (n = "true" === n);
var a = e(i.getFieldEl()).find("input");
a.length > 0 && t.checked(e(a[0]), n) },
r = function(a) { "string" == typeof a && (a = a.split(","));
for (var r = 0; r < a.length; r++) a[r] = t.trim(a[r]);
t.checked(e(i.getFieldEl()).find("input[data-checkbox-value]"), !1);
for (var o = 0; o < a.length; o++) {
var l = e(i.getFieldEl()).find('input[data-checkbox-value="' + a[o] + '"]');
l.length > 0 && t.checked(e(l[0]), n) } },
o = !1;
i.options.multiple ? "string" == typeof n ? (r(n), o = !0) : t.isArray(n) && (r(n), o = !0) : "boolean" == typeof n ? (a(n), o = !0) : "string" == typeof n && (a(n), o = !0), !o && n && t.logError("CheckboxField cannot set value for schema.type=" + i.schema.type + " and value=" + n), this.base(n) }, _validateEnum: function() {
var e = this;
if (!e.options.multiple) return !0;
var n = e.getValue();
return !e.isRequired() && t.isValEmpty(n) ? !0 : ("string" == typeof n && (n = n.split(",")), t.anyEquality(n, e.getEnum())) }, disable: function() { e(this.control).find("input").each(function() { e(this).disabled = !0, e(this).prop("disabled", !0) }) }, enable: function() { e(this.control).find("input").each(function() { e(this).disabled = !1, e(this).prop("disabled", !1) }) }, getType: function() {
return "boolean" }, getTitle: function() {
return "Checkbox Field" }, getDescription: function() {
return "Checkbox Field for boolean (true/false), string ('true', 'false' or comma-delimited string of values) or data array." }, getSchemaOfOptions: function() {
return t.merge(this.base(), { properties: { rightLabel: { title: "Option Label", description: "Optional right-hand side label for single checkbox field.", type: "string" }, multiple: { title: "Multiple", description: "Whether to render multiple checkboxes for multi-valued type (such as an array or a comma-delimited string)", type: "boolean" }, dataSource: { title: "Option DataSource", description: "Data source for generating list of options. This can be a string or a function. If a string, it is considered to be a URI to a service that produces a object containing key/value pairs or an array of elements of structure {'text': '', 'value': ''}. This can also be a function that is called to produce the same list.", type: "string" }, useDataSourceAsEnum: { title: "Use Data Source as Enumerated Values", description: "Whether to constrain the field's schema enum property to the values that come back from the data source.", type: "boolean", "default": !0 } } }) }, getOptionsForOptions: function() {
return t.merge(this.base(), { fields: { rightLabel: { type: "text" }, multiple: { type: "checkbox" }, dataSource: { type: "text" } } }) } }), t.registerFieldClass("checkbox", t.Fields.CheckBoxField), t.registerDefaultSchemaFieldMapping("boolean", "checkbox") }(jQuery),
function(e) {
var t = e.alpaca;
t.Fields.FileField = t.Fields.TextField.extend({ getFieldType: function() {
return "file" }, setValue: function(e) { this.data = e, this.data = e, this.updateObservable(), this.triggerUpdate() }, getControlValue: function() {
return this.data }, onChange: function(e) { this.base(e), this.options.selectionHandler && this.processSelectionHandler(e.target.files) }, processSelectionHandler: function(e) {
if (e && e.length > 0 && "undefined" != typeof FileReader) {
var t = [],
n = 0,
i = new FileReader;
i.onload = function() {
var i = this;
return function(a) {
var r = a.target.result;
t.push(r), n++, n === e.length && i.options.selectionHandler.call(i, e, t) } }.call(this);
for (var a = 0; a < e.length; a++) i.readAsDataURL(e[a]) } }, getTitle: function() {
return "File Field" }, getDescription: function() {
return "Field for uploading files." }, getSchemaOfOptions: function() {
return t.merge(this.base(), { properties: { selectionHandler: { title: "Selection Handler", description: "Function that should be called when files are selected. Requires HTML5.", type: "boolean", "default": !1 } } }) }, getOptionsForOptions: function() {
return t.merge(this.base(), { fields: { selectionHandler: { type: "checkbox" } } }) } }), t.registerFieldClass("file", t.Fields.FileField) }(jQuery),
function(e) {
var t = e.alpaca;
t.Fields.ListField = t.ControlField.extend({ setup: function() {
var n = this;
if (n.base(), n.selectOptions = [], n.getEnum()) { n.sortEnum();
var i = n.getOptionLabels();
e.each(n.getEnum(), function(e, a) {
var r = a;
i && (t.isEmpty(i[e]) ? t.isEmpty(i[a]) || (r = i[a]) : r = i[e]), n.selectOptions.push({ value: a, text: r }) }) }
if (n.isRequired() && !n.data && n.options.removeDefaultNone === !0) {
var a = n.getEnum();
a && a.length > 0 && (n.data = a[0]) }
n.options.datasource && !n.options.dataSource && (n.options.dataSource = n.options.datasource, delete n.options.datasource), "undefined" == typeof n.options.useDataSourceAsEnum && (n.options.useDataSourceAsEnum = !0) }, prepareControlModel: function(e) {
var t = this;
this.base(function(n) { "undefined" == typeof t.options.noneLabel && (t.options.noneLabel = t.getMessage("noneLabel")), "undefined" == typeof t.options.hideNone && ("undefined" != typeof t.options.removeDefaultNone ? t.options.hideNone = t.options.removeDefaultNone : t.options.hideNone = t.isRequired()), e(n) }) }, beforeRenderControl: function(e, t) {
var n = this,
i = function() {
for (var e = n.convertToScalarValue(n.data), i = 0; i < n.selectOptions.length; i++)
if (e === n.selectOptions[i].value) { n.selectOptions[i].selected = !0;
break }
t() };
this.base(e, function() { n.options.dataSource ? (n.selectOptions.length = 0, n.invokeDataSource(n.selectOptions, e, function() {
if (n.options.useDataSourceAsEnum) {
for (var e = [], t = [], a = 0; a < n.selectOptions.length; a++) e.push(n.selectOptions[a].value), t.push(n.selectOptions[a].text);
n.setEnum(e), n.setOptionLabels(t) }
i() })) : i() }) }, convertToScalarValue: function(e) {
return e }, convertToDataValue: function(e, t) { t(null, e) }, getSchemaOfSchema: function() {
return t.merge(this.base(), { properties: { "enum": { title: "Enumeration", description: "List of field value options", type: "array", required: !0 } } }) }, getSchemaOfOptions: function() {
return t.merge(this.base(), { properties: { dataSource: { title: "Option Datasource", description: "Datasource for generating list of options. This can be a string or a function. If a string, it is considered to be a URI to a service that produces a object containing key/value pairs or an array of elements of structure {'text': '', 'value': ''}. This can also be a function that is called to produce the same list.", type: "string" }, removeDefaultNone: { title: "Remove Default None", description: "If true, the default 'None' option will not be shown.", type: "boolean", "default": !1 }, noneLabel: { title: "None Label", description: "The label to use for the 'None' option in a list (select, radio or otherwise).", type: "string", "default": "None" }, hideNone: { title: "Hide None", description: "Whether to hide the None option from a list (select, radio or otherwise). This will be true if the field is required and false otherwise.", type: "boolean", "default": !1 }, useDataSourceAsEnum: { title: "Use Data Source as Enumerated Values", description: "Whether to constrain the field's schema enum property to the values that come back from the data source.", type: "boolean", "default": !0 } } }) }, getOptionsForOptions: function() {
return t.merge(this.base(), { fields: { dataSource: { type: "text" }, removeDefaultNone: { type: "checkbox", rightLabel: "Remove Default None" }, noneLabel: { type: "text" }, hideNone: { type: "checkbox", rightLabel: "Hide the 'None' option from the list" } } }) } }), t.registerMessages({ noneLabel: "None" }) }(jQuery),
function(e) {
var t = e.alpaca;
t.Fields.RadioField = t.Fields.ListField.extend({ getFieldType: function() {
return "radio" }, setup: function() { this.base(), this.options.name ? this.name = this.options.name : this.name || (this.name = this.getId() + "-name"), t.isUndefined(this.options.emptySelectFirst) && (this.options.emptySelectFirst = !1), t.isUndefined(this.options.vertical) && (this.options.vertical = !0) }, getControlValue: function() {
var t = this,
n = null;
return e(this.control).find(":checked").each(function() { n = e(this).val(), n = t.ensureProperType(n) }), n }, setValue: function(n) {
var i = this;
e(this.control).find("input").each(function() { t.checked(e(this), null) }), "undefined" != typeof n && t.checked(e(i.control).find('input[value="' + n + '"]'), "checked"), this.options.emptySelectFirst && 0 === e(this.control).find("input:checked").length && t.checked(e(i.control).find("input:radio").first(), "checked"), this.base(n) }, initControlEvents: function() {
var t = this;
t.base();
var n = e(this.control).find("input");
n.focus(function(e) { t.suspendBlurFocus || (t.onFocus.call(t, e), t.trigger("focus", e)) }), n.blur(function(e) { t.suspendBlurFocus || (t.onBlur.call(t, e), t.trigger("blur", e)) }) }, prepareControlModel: function(e) {
var t = this;
this.base(function(n) { n.selectOptions = t.selectOptions, n.removeDefaultNone = t.options.removeDefaultNone, e(n) }) }, afterRenderControl: function(n, i) {
var a = this;
this.base(n, function() { a.options.emptySelectFirst && a.selectOptions && a.selectOptions.length > 0 && (a.data = a.selectOptions[0].value, 0 === e("input:radio:checked", a.control).length && t.checked(e(a.control).find('input:radio[value="' + a.data + '"]'), "checked")), a.options.vertical ? e(a.control).css("display", "block") : e(a.control).css("display", "inline-block"), i() }) }, updateDOMElement: function() { this.base(), e(this.control).find("input:radio").attr("name", this.getName()) }, onClick: function(t) {
var n = this,
i = n.getValue();
this.base(t);
var a = e(t.currentTarget).find("input").val(); "undefined" != typeof a && (n.setValue(a), n.refreshValidationState(), i !== a && n.trigger("change")) }, disable: function() { this.base(), this.getFieldEl().addClass("disabled") }, enable: function() { this.base(), this.getFieldEl().removeClass("disabled") }, getTitle: function() {
return "Radio Group Field" }, getDescription: function() {
return "Radio Group Field with list of options." }, getSchemaOfOptions: function() {
return t.merge(this.base(), { properties: { name: { title: "Field name", description: "Field name.", type: "string" }, emptySelectFirst: { title: "Empty Select First", description: "If the data is empty, then automatically select the first item in the list.", type: "boolean", "default": !1 }, vertical: { title: "Position the radio selector items vertically", description: "By default, radio controls are stacked vertically. Set to false if you'd like radio controls to lay out horizontally.", type: "boolean", "default": !0 } } }) } }), t.registerFieldClass("radio", t.Fields.RadioField) }(jQuery),
function(e) {
var t = e.alpaca;
t.Fields.SelectField = t.Fields.ListField.extend({
getFieldType: function() {
return "select" },
setup: function() {
var t = this;
this.base(), t.schema.type && "array" === t.schema.type && (t.options.multiple = !0), t.options.multiple && e.fn.multiselect && "undefined" == typeof t.options.hideNone && (t.options.hideNone = !0), this.schema.items && this.schema.items.maxItems && "undefined" == typeof this.schema.maxItems && (this.schema.maxItems = this.schema.items.maxItems, delete this.schema.items.maxItems), this.schema.items && this.schema.items.minItems && "undefined" == typeof this.schema.minItems && (this.schema.minItems = this.schema.items.minItems, delete this.schema.items.minItems), !t.options.multiselect && e.fn.multiselect && (t.options.multiselect = {}), t.options.multiselect && "undefined" == typeof t.options.multiselect.disableIfEmpty && (t.options.multiselect.disableIfEmpty = !0) },
getValue: function() {
var e = this;
return "object" === e.schema.type ? this.data : this.base() },
setValue: function(e) {
var n = this,
i = n.convertToScalarValue(e),
a = n.convertToScalarValue(n.getValue());
if (t.isArray(e)) t.compareArrayContent(i, a) || (!t.isEmpty(i) && this.control && this.control.val(i), this.base(e));
else {
var r = !1;
t.isEmpty(i) && t.isEmpty(a) ? r = !0 : i !== a && (r = !0), r && (n.control && "undefined" != typeof i && null !== i && n.control.val(i), this.base(e)) } },
getEnum: function() {
if (this.schema) {
if (this.schema["enum"]) return this.schema["enum"];
if (this.schema.type && "array" === this.schema.type && this.schema.items && this.schema.items["enum"]) return this.schema.items["enum"] } },
initControlEvents: function() {
var e = this;
if (e.base(), e.options.multiple) {
var t = this.control.parent().find("button.multiselect");
t.focus(function(t) { e.suspendBlurFocus || (e.onFocus.call(e, t), e.trigger("focus", t)) }), t.blur(function(t) { e.suspendBlurFocus || (e.onBlur.call(e, t), e.trigger("blur", t)) }) } },
prepareControlModel: function(e) {
var t = this;
this.base(function(n) { n.selectOptions = t.selectOptions, e(n) }) },
beforeRenderControl: function(e, n) { this.base(e, function() {
for (var i = [], a = {}, r = 0; r < e.selectOptions.length; r++) a[e.selectOptions[r].value] = e.selectOptions[r].text;
if (t.isArray(e.data))
for (var r = 0; r < e.data.length; r++) {
var o = a[e.data[r]];
o && i.push(o) } else {
var o = a[e.data];
o && i.push(o) }
e.displayableText = i.join(", "), n() }) },
afterRenderControl: function(n, i) {
var a = this;
this.base(n, function() {
if (t.isUndefined(a.data) && a.options.emptySelectFirst && a.selectOptions && a.selectOptions.length > 0 && (a.data = a.selectOptions[0].value),
a.data && a.setValue(a.data), a.options.multiple && e.fn.multiselect && !a.isDisplayOnly()) {
var n = null;
n = a.options.multiselect ? a.options.multiselect : {}, n.nonSelectedText || (n.nonSelectedText = "None", a.options.noneLabel && (n.nonSelectedText = a.options.noneLabel)), e(a.getControlEl()).multiselect(n) }
i()
})
},
_validateEnum: function() {
var n = this;
if (this.schema["enum"]) {
var i = this.data;
if (!this.isRequired() && t.isValEmpty(i)) return !0;
if (this.options.multiple) {
var a = !0;
return i || (i = []), t.isArray(i) || t.isObject(i) || (i = [i]), e.each(i, function(e, i) {
var r = n.convertToScalarValue(i),
o = t.inArray(n.schema["enum"], r);
o || (a = !1) }), a }
t.isArray(i) && (i = i[0]);
var r = n.convertToScalarValue(i);
return t.inArray(this.schema["enum"], r) }
return !0 },
onChange: function(e) {
var t = this,
n = t.getControlValue();
t.convertToDataValue(n, function(e, i) { t.data = i, t.control.val(n), t.updateObservable(), t.triggerUpdate(), t.refreshValidationState() }) },
_validateMinItems: function() {
return !(this.schema.minItems && this.schema.minItems >= 0 && e(":selected", this.control).length < this.schema.minItems) },
_validateMaxItems: function() {
return !(this.schema.maxItems && this.schema.maxItems >= 0 && e(":selected", this.control).length > this.schema.maxItems) },
handleValidate: function() {
var e = this.base(),
n = this.validation,
i = this._validateMaxItems();
return n.tooManyItems = { message: i ? "" : t.substituteTokens(this.getMessage("tooManyItems"), [this.schema.maxItems]), status: i }, i = this._validateMinItems(), n.notEnoughItems = { message: i ? "" : t.substituteTokens(this.getMessage("notEnoughItems"), [this.schema.minItems]), status: i }, e && n.tooManyItems.status && n.notEnoughItems.status },
focus: function(t) {
if (this.control && this.control.length > 0) {
var n = e(this.control).get(0);
n.focus(), t && t(this) } },
disable: function() {
var t = this;
this.base(), t.options.multiselect && e(t.getControlEl()).multiselect("disable") },
enable: function() {
var t = this;
this.base(), t.options.multiselect && e(t.getControlEl()).multiselect("enable") },
getTitle: function() {
return "Select Field" },
getDescription: function() {
return "Select Field" },
getSchemaOfOptions: function() {
return t.merge(this.base(), { properties: { multiple: { title: "Mulitple Selection", description: "Allow multiple selection if true.", type: "boolean", "default": !1 }, size: { title: "Displayed Options", description: "Number of options to be shown.", type: "number" }, emptySelectFirst: { title: "Empty Select First", description: "If the data is empty, then automatically select the first item in the list.", type: "boolean", "default": !1 }, multiselect: { title: "Multiselect Plugin Settings", description: "Multiselect plugin properties - http://davidstutz.github.io/bootstrap-multiselect", type: "any" } } }) },
getOptionsForOptions: function() {
return t.merge(this.base(), { fields: { multiple: { rightLabel: "Allow multiple selection ?", helper: "Allow multiple selection if checked", type: "checkbox" }, size: { type: "integer" }, emptySelectFirst: { type: "checkbox", rightLabel: "Empty Select First" }, multiselect: { type: "object", rightLabel: "Multiselect plugin properties - http://davidstutz.github.io/bootstrap-multiselect" } } }) }
}), t.registerFieldClass("select", t.Fields.SelectField)
}(jQuery),
function(e) {
var t = e.alpaca;
t.Fields.NumberField = t.Fields.TextField.extend({ setup: function() { this.base(), "undefined" == typeof this.options.numericEntry && (this.options.numericEntry = !1) }, getFieldType: function() {
return "number" }, postRender: function(e) {
var t = this;
this.base(function() { t.control && t.on("keypress", function(e) {
var n = e.charCode || e.keyCode || 0,
i = !0;
return t.options.numericEntry && (i = i && n >= 48 && 57 >= n), i || (e.preventDefault(), e.stopImmediatePropagation()), i }), e() }) }, getControlValue: function() {
var e = this._getControlVal(!0);
return "undefined" == typeof e || "" == e ? e : parseFloat(e) }, handleValidate: function() {
var e = this.base(),
n = this.validation,
i = this._validateNumber();
return n.stringNotANumber = { message: i ? "" : this.getMessage("stringNotANumber"), status: i }, i = this._validateDivisibleBy(), n.stringDivisibleBy = { message: i ? "" : t.substituteTokens(this.getMessage("stringDivisibleBy"), [this.schema.divisibleBy]), status: i }, i = this._validateMaximum(), n.stringValueTooLarge = { message: "", status: i }, i || (this.schema.exclusiveMaximum ? n.stringValueTooLarge.message = t.substituteTokens(this.getMessage("stringValueTooLargeExclusive"), [this.schema.maximum]) : n.stringValueTooLarge.message = t.substituteTokens(this.getMessage("stringValueTooLarge"), [this.schema.maximum])), i = this._validateMinimum(), n.stringValueTooSmall = { message: "", status: i }, i || (this.schema.exclusiveMinimum ? n.stringValueTooSmall.message = t.substituteTokens(this.getMessage("stringValueTooSmallExclusive"), [this.schema.minimum]) : n.stringValueTooSmall.message = t.substituteTokens(this.getMessage("stringValueTooSmall"), [this.schema.minimum])), i = this._validateMultipleOf(), n.stringValueNotMultipleOf = { message: "", status: i }, i || (n.stringValueNotMultipleOf.message = t.substituteTokens(this.getMessage("stringValueNotMultipleOf"), [this.schema.multipleOf])), e && n.stringNotANumber.status && n.stringDivisibleBy.status && n.stringValueTooLarge.status && n.stringValueTooSmall.status && n.stringValueNotMultipleOf.status && n.invalidPattern.status && n.stringTooLong.status && n.stringTooShort.status }, _validateOptional: function() {
return this.isDisplayOnly() || !this.isRequired() || !t.isValEmpty(e(this.control).val()) }, _validateNumber: function() {
var e = this._getControlVal();
if ("number" == typeof e && (e = "" + e), t.isValEmpty(e)) return !0;
var n = t.testRegex(t.regexps.number, e);
if (!n) return !1;
var i = this.getValue();
return !isNaN(i) }, _validateDivisibleBy: function() {
var e = this.getValue();
return !(!t.isEmpty(this.schema.divisibleBy) && e % this.schema.divisibleBy !== 0) }, _validateMaximum: function() {
var e = this.getValue();
if (!t.isEmpty(this.schema.maximum)) {
if (e > this.schema.maximum) return !1;
if (!t.isEmpty(this.schema.exclusiveMaximum) && e == this.schema.maximum && this.schema.exclusiveMaximum) return !1 }
return !0 }, _validateMinimum: function() {
var e = this.getValue();
if (!t.isEmpty(this.schema.minimum)) {
if (e < this.schema.minimum) return !1;
if (!t.isEmpty(this.schema.exclusiveMinimum) && e == this.schema.minimum && this.schema.exclusiveMinimum) return !1 }
return !0 }, _validateMultipleOf: function() {
var e = this.getValue();
return t.isEmpty(this.schema.multipleOf) || !e || 0 === this.schema.multipleOf }, getType: function() {
return "number" }, onKeyPress: function(e) {
var n = this;
if (9 !== e.keyCode && 37 !== e.keyCode && 38 !== e.keyCode && 39 !== e.keyCode && 40 !== e.keyCode) {
if (8 === e.keyCode) {
if (!t.isEmpty(n.schema.minLength) && (n.options.constrainLengths || n.options.constrainMinLength)) {
var i = n.getValue() || "";
t.isNumber(i) && (i = i.toString()), i.length <= n.schema.minLength && (e.preventDefault(), e.stopImmediatePropagation()) } } else if (!t.isEmpty(n.schema.maxLength) && (n.options.constrainLengths || n.options.constrainMaxLength)) {
var i = n.getValue() || "";
t.isNumber(i) && (i = i.toString()), i.length >= n.schema.maxLength && (e.preventDefault(), e.stopImmediatePropagation()) }
32 === e.keyCode && n.options.disallowEmptySpaces && (e.preventDefault(), e.stopImmediatePropagation()) } }, onKeyUp: function(t) {
var n = this;
n.updateMaxLengthIndicator(), e(this.field).trigger("fieldkeyup") }, getSchemaOfSchema: function() {
return t.merge(this.base(), { properties: { multipleOf: { title: "Multiple Of", description: "Property value must be a multiple of the multipleOf schema property such that division by this value yields an interger (mod zero).", type: "number" }, minimum: { title: "Minimum", description: "Minimum value of the property.", type: "number" }, maximum: { title: "Maximum", description: "Maximum value of the property.", type: "number" }, exclusiveMinimum: { title: "Exclusive Minimum", description: "Property value can not equal the number defined by the minimum schema property.", type: "boolean", "default": !1 }, exclusiveMaximum: { title: "Exclusive Maximum", description: "Property value can not equal the number defined by the maximum schema property.", type: "boolean", "default": !1 } } }) }, getOptionsForSchema: function() {
return t.merge(this.base(), { fields: { multipleOf: { title: "Multiple Of", description: "The value must be a integral multiple of the property", type: "number" }, minimum: { title: "Minimum", description: "Minimum value of the property", type: "number" }, maximum: { title: "Maximum", description: "Maximum value of the property", type: "number" }, exclusiveMinimum: { rightLabel: "Exclusive minimum ?", helper: "Field value must be greater than but not equal to this number if checked", type: "checkbox" }, exclusiveMaximum: { rightLabel: "Exclusive Maximum ?", helper: "Field value must be less than but not equal to this number if checked", type: "checkbox" } } }) }, getSchemaOfOptions: function() {
return t.merge(this.base(), { properties: { numericEntry: { title: "Numeric Entry", description: "Whether to constrain data entry key presses to numeric values (0-9)", type: "boolean", "default": !1 } } }) }, getTitle: function() {
return "Number Field" }, getDescription: function() {
return "Field for float numbers." } }), t.registerMessages({ stringValueTooSmall: "The minimum value for this field is {0}", stringValueTooLarge: "The maximum value for this field is {0}", stringValueTooSmallExclusive: "Value of this field must be greater than {0}", stringValueTooLargeExclusive: "Value of this field must be less than {0}", stringDivisibleBy: "The value must be divisible by {0}", stringNotANumber: "This value is not a number.", stringValueNotMultipleOf: "This value is not a multiple of {0}" }), t.registerFieldClass("number", t.Fields.NumberField), t.registerDefaultSchemaFieldMapping("number", "number") }(jQuery),
function(e) {
var t = e.alpaca;
t.Fields.ArrayField = t.ContainerField.extend({ getFieldType: function() {
return "array" }, setup: function() {
var n = this;
this.base();
var i = n.resolveContainerItemTemplateType();
if (!i) return t.throwErrorWithCallback("Unable to find template descriptor for container item: " + n.getFieldType());
this.containerItemTemplateDescriptor = n.view.getTemplateDescriptor("container-" + i + "-item", n), this.options.toolbarStyle || (this.options.toolbarStyle = t.isEmpty(this.view.toolbarStyle) ? "button" : this.view.toolbarStyle), this.options.toolbarStyle || (this.options.toolbarStyle = "button"), this.options.actionbarStyle || (this.options.actionbarStyle = t.isEmpty(this.view.actionbarStyle) ? "top" : this.view.actionbarStyle), this.options.actionbarStyle || (this.options.actionbarStyle = "top"), this.schema.items || (this.schema.items = {}), this.options.items || (this.options.items = {}), this.schema.items && this.schema.items.maxItems && "undefined" == typeof this.schema.maxItems && (this.schema.maxItems = this.schema.items.maxItems, delete this.schema.items.maxItems), this.schema.items && this.schema.items.minItems && "undefined" == typeof this.schema.minItems && (this.schema.minItems = this.schema.items.minItems, delete this.schema.items.minItems), this.schema.items && this.schema.items.uniqueItems && "undefined" == typeof this.schema.uniqueItems && (this.schema.uniqueItems = this.schema.items.uniqueItems, delete this.schema.items.uniqueItems), this.options.rubyrails = !1, this.parent && this.parent.options && this.parent.options.form && this.parent.options.form.attributes && (t.isEmpty(this.parent.options.form.attributes.rubyrails) || (this.options.rubyrails = !0));
var a = t.defaultToolbarSticky;
if (t.isEmpty(this.view.toolbarSticky) || (a = this.view.toolbarSticky), t.isEmpty(this.options.toolbarSticky) || (a = this.options.toolbarSticky), this.options.toolbarSticky = a, "undefined" == typeof n.options.hideToolbarWithChildren && (n.options.hideToolbarWithChildren = !0), this.schema.items && this.schema.uniqueItems && t.mergeObject(this.options, { forceRevalidation: !0 }), "undefined" == typeof this.data && (this.data = []), null == this.data && (this.data = []), "" == this.data && (this.data = []), t.isString(this.data)) try {
var r = t.parseJSON(this.data);
if (!t.isArray(r) && !t.isObject(r)) return void t.logWarn("ArrayField parsed string data but it was not an array: " + this.data);
this.data = r } catch (o) { this.data = [this.data] }
if (!t.isArray(this.data) && !t.isObject(this.data)) return void t.logWarn("ArrayField data is not an array: " + JSON.stringify(this.data, null, " "));
var l = function(e, t, i) {
var a = n.findAction(e, t);
a || (a = { core: !0 }, e.push(a));
for (var r in i) a[r] || (a[r] = i[r]) },
s = function(e, t) {
var n = 0;
do "undefined" == typeof e[n].enabled && (e[n].enabled = !0), t || delete e[n].label, e[n].enabled ? n++ : e.splice(n, 1); while (n < e.length);
e.sort(function(e, t) {
return e.core && !t.core ? -1 : !e.core && t.core ? 1 : 0 }) };
if (n.toolbar = {}, n.options.toolbar)
for (var u in n.options.toolbar) n.toolbar[u] = t.copyOf(n.options.toolbar[u]);
if ("undefined" == typeof n.toolbar.showLabels && (n.toolbar.showLabels = !0), n.toolbar.actions || (n.toolbar.actions = []), l(n.toolbar.actions, "add", { label: n.getMessage("addItemButtonLabel"), action: "add", iconClass: n.view.getStyle("addIcon"), click: function(e, t) { n.handleToolBarAddItemClick(function(e) {}) } }), s(n.toolbar.actions, n.toolbar.showLabels), n.actionbar = {}, n.options.actionbar)
for (var c in n.options.actionbar) n.actionbar[c] = t.copyOf(n.options.actionbar[c]); "undefined" == typeof n.actionbar.showLabels && (n.actionbar.showLabels = !1), n.actionbar.actions || (n.actionbar.actions = []), l(n.actionbar.actions, "add", { label: n.getMessage("addButtonLabel"), action: "add", iconClass: n.view.getStyle("addIcon"), click: function(e, t, i) { n.handleActionBarAddItemClick(i, function(e) {}) } }), l(n.actionbar.actions, "remove", { label: n.getMessage("removeButtonLabel"), action: "remove", iconClass: n.view.getStyle("removeIcon"), click: function(e, t, i) { n.handleActionBarRemoveItemClick(i, function(e) {}) } }), l(n.actionbar.actions, "up", { label: n.getMessage("upButtonLabel"), action: "up", iconClass: n.view.getStyle("upIcon"), click: function(e, t, i) { n.handleActionBarMoveItemUpClick(i, function() {}) } }), l(n.actionbar.actions, "down", { label: n.getMessage("downButtonLabel"), action: "down", iconClass: n.view.getStyle("downIcon"), click: function(e, t, i) { n.handleActionBarMoveItemDownClick(i, function() {}) } }), s(n.actionbar.actions, n.actionbar.showLabels);
var d = this.data.length,
p = e.extend(!0, {}, this.data);
p.length = d, this.data = Array.prototype.slice.call(p) }, setValue: function(e) {
var n = this;
if (e && t.isArray(e)) {
var i = 0;
do
if (i < n.children.length) {
var a = n.children[i];
e.length > i ? (a.setValue(e[i]), i++) : n.removeItem(i) }
while (i < n.children.length);
i < e.length && n.resolveItemSchemaOptions(function(a, r, o) {
if (a || t.logDebug("Unable to resolve schema for item: " + i), o) return t.throwErrorWithCallback("Circular reference detected for schema: " + JSON.stringify(a), n.errorCallback);
for (var l = []; i < e.length;) {
var s = function(e, i) {
return function(o) { n.addItem(e, a, r, i[e], function() { t.nextTick(function() { o() }) }) } }(i, e);
l.push(s), i++ }
t.series(l, function() {}) }) } }, getContainerValue: function() {
if (0 === this.children.length && !this.isRequired()) return [];
for (var e = [], t = 0; t < this.children.length; t++) {
var n = this.children[t].getValue();
n !== n && (n = void 0), "undefined" != typeof n && e.push(n) }
return e }, createItems: function(e) {
var n = this,
i = [];
n.data && n.data.length > 0 ? n.resolveItemSchemaOptions(function(a, r, o) {
if (o) return t.throwErrorWithCallback("Circular reference detected for schema: " + JSON.stringify(a), n.errorCallback);
for (var l = [], s = 0; s < n.data.length; s++) {
var u = n.data[s],
c = function(e, t) {
return function(o) { n.createItem(e, a, r, t, function(e) { i.push(e), o() }) } }(s, u);
l.push(c) }
t.nextTick(function() { t.series(l, function(t) { e(i) }) }) }) : e(i) }, createItem: function(n, i, a, r, o) {
var l = this;
if (l._validateEqualMaxItems()) {
var s = e("");
s.alpaca({ data: r, options: a, schema: i, view: this.view.id ? this.view.id : this.view, connector: this.connector, error: function(e) { l.destroy(), l.errorCallback.call(l, e) }, notTopLevel: !0, render: function(e, t) { e.parent = l, e.path = l.path + "[" + n + "]", e.render(null, function() { t && t() }) }, postRender: function(n) {
var i = t.tmpl(l.containerItemTemplateDescriptor, { id: l.getId(), name: n.name, parentFieldId: l.getId(), actionbarStyle: l.options.actionbarStyle, view: l.view, data: r }),
a = e(i).find("." + t.MARKER_CLASS_CONTAINER_FIELD_ITEM_FIELD);
return 0 === a.length && e(i).hasClass(t.MARKER_CLASS_CONTAINER_FIELD_ITEM_FIELD) && (a = e(i)), 0 === a.length ? void l.errorCallback.call(l, { message: "Cannot find insertion point for field: " + l.getId() }) : (e(a).before(n.getFieldEl()), e(a).remove(), n.containerItemEl = i, t.fieldApplyFieldAndChildren(n, function(e) { e.hideInitValidationError = !1 }), t.isFunction(l.options.items.postRender) && l.options.items.postRender.call(n, a), void(o && o(n))) } }) } }, resolveItemSchemaOptions: function(e) {
var n, i = this,
a = function(t, n, a) { i.options.readonly && (n.readonly = !0), e(t, n, a) };!n && i.options && i.options.fields && i.options.fields.item && (n = i.options.fields.item), !n && i.options && i.options.items && (n = i.options.items);
var r;
if (i.schema && i.schema.items && (r = i.schema.items), r && r.$ref) {
var o = r.$ref,
l = r.$ref;
n.$ref && (l = n.$ref);
for (var s = this, u = [s]; s.parent;) s = s.parent, u.push(s);
var c = r,
d = n;
t.loadRefSchemaOptions(s, o, l, function(e, n) {
for (var i = 0, r = 0; r < u.length; r++) u[r].schema && (u[r].schema.id === o || u[r].schema.id === "#" + o ? i++ : u[r].schema.$ref === o && i++);
var l = i > 10,
s = {};
c && t.mergeObject(s, c), e && t.mergeObject(s, e), delete s.id;
var p = {};
d && t.mergeObject(p, d), n && t.mergeObject(p, n), t.nextTick(function() { a(s, p, l) }) }) } else t.nextTick(function() { a(r, n) }) }, handleValidate: function() {
var e = this.base(),
n = this.validation,
i = this._validateUniqueItems();
return n.valueNotUnique = { message: i ? "" : this.getMessage("valueNotUnique"), status: i }, i = this._validateMaxItems(), n.tooManyItems = { message: i ? "" : t.substituteTokens(this.getMessage("tooManyItems"), [this.schema.maxItems]), status: i }, i = this._validateMinItems(), n.notEnoughItems = { message: i ? "" : t.substituteTokens(this.getMessage("notEnoughItems"), [this.schema.minItems]), status: i }, e && n.valueNotUnique.status && n.tooManyItems.status && n.notEnoughItems.status }, _validateEqualMaxItems: function() {
return !(this.schema.maxItems && this.schema.maxItems >= 0 && this.getSize() >= this.schema.maxItems) }, _validateEqualMinItems: function() {
return !(this.schema.minItems && this.schema.minItems >= 0 && this.getSize() <= this.schema.minItems) }, _validateMinItems: function() {
return !(this.schema.minItems && this.schema.minItems >= 0 && this.getSize() < this.schema.minItems) }, _validateMaxItems: function() {
return !(this.schema.maxItems && this.schema.maxItems >= 0 && this.getSize() > this.schema.maxItems) }, _validateUniqueItems: function() {
if (this.schema.items && this.schema.uniqueItems)
for (var e = {}, t = 0; t < this.children.length; t++) {
var n = this.children[t].getValue();
if (n || (n = ""), e[n]) return !1;
e[n] = !0 }
return !0 }, findAction: function(t, n) {
var i = null;
return e.each(t, function(e, t) { t.action === n && (i = t) }), i }, postRender: function(e) {
var t = this;
this.base(function() { t.updateToolbars(), e() }) }, getSize: function() {
return this.children.length }, updateDOMElement: function() { this.updatePathAndName(), this.base() }, updatePathAndName: function() {
var n = function(i) { i.children && e.each(i.children, function(a, r) { i.prePath && t.startsWith(r.path, i.prePath) && (r.prePath = r.path, r.path = r.path.replace(i.prePath, i.path)), i.preName && t.startsWith(r.name, i.preName) && (r.preName = r.name, r.name = r.name.replace(i.preName, i.name), r.field && e(r.field).attr("name", r.name)), n(r) }) };
this.children && this.children.length > 0 && e.each(this.children, function(t, i) {
var a = i.path.lastIndexOf("/"),
r = i.path.substring(a + 1);
r.indexOf("[") < 0 && r.indexOf("]") < 0 && (r = r.substring(r.indexOf("[") + 1, r.indexOf("]"))), r !== t && (i.prePath = i.path, i.path = i.path.substring(0, a) + "/[" + t + "]"), i.nameCalculated && (i.preName = i.name, i.parent && i.parent.name && i.path ? i.name = i.parent.name + "_" + t : i.path && (i.name = i.path.replace(/\//g, "").replace(/\[/g, "_").replace(/\]/g, "")), this.parent.options.rubyrails ? e(i.field).attr("name", i.parent.name) : e(i.field).attr("name", i.name)), i.prePath || (i.prePath = i.path), n(i) }) }, updateToolbars: function() {
var t = this;
if ("display" !== this.view.type && !this.schema.readonly) { t.toolbar && (t.fireCallback("arrayToolbar", !0), t.fireCallback("arrayToolbar")), t.actionbar && (t.fireCallback("arrayActionbars", !0), t.fireCallback("arrayActionbars"));
var n = e(this.getFieldEl()).find(".alpaca-array-toolbar[data-alpaca-array-toolbar-field-id='" + t.getId() + "']");
if (this.children.length > 0 && t.options.hideToolbarWithChildren ? e(n).hide() : (e(n).show(), e(n).find("[data-alpaca-array-toolbar-action]").each(function() {
var n = e(this).attr("data-alpaca-array-toolbar-action"),
i = t.findAction(t.toolbar.actions, n);
i && e(this).off().click(function(e) { e.preventDefault(), i.click.call(t, n, i) }) })), "undefined" == typeof this.options.toolbarSticky || null === this.options.toolbarSticky) {
var i = this.getFieldEl().find(".alpaca-container-item[data-alpaca-container-item-parent-field-id='" + t.getId() + "']");
e(i).each(function(n) {
var i = e(t.getFieldEl()).find(".alpaca-array-actionbar[data-alpaca-array-actionbar-parent-field-id='" + t.getId() + "'][data-alpaca-array-actionbar-item-index='" + n + "']");
i && i.length > 0 && (e(this).hover(function() { e(i).show() }, function() { e(i).hide() }), e(i).hide()) }) } else this.options.toolbarSticky ? e(t.getFieldEl()).find(".alpaca-array-actionbar[data-alpaca-array-actionbar-parent-field-id='" + t.getId() + "']").css("display", "inline-block") : this.options.toolbarSticky || e(t.getFieldEl()).find(".alpaca-array-actionbar[data-alpaca-array-actionbar-parent-field-id='" + t.getId() + "']").hide();
var a = e(t.getFieldEl()).find(".alpaca-array-actionbar[data-alpaca-array-actionbar-parent-field-id='" + t.getId() + "']");
e(a).each(function() {
var n = e(this).attr("data-alpaca-array-actionbar-item-index"); "string" == typeof n && (n = parseInt(n, 10)), e(this).children("[data-alpaca-array-actionbar-action]").each(function() {
var i = e(this).attr("data-alpaca-array-actionbar-action"),
a = t.findAction(t.actionbar.actions, i);
a && e(this).off().click(function(e) { e.preventDefault(), a.click.call(t, i, a, n) }) }), t._validateEqualMaxItems() ? (e(this).children("[data-alpaca-array-toolbar-action='add']").each(function(n) { e(this).removeClass("alpaca-button-disabled"), t.fireCallback("enableButton", this) }), e(this).children("[data-alpaca-array-actionbar-action='add']").each(function(n) { e(this).removeClass("alpaca-button-disabled"), t.fireCallback("enableButton", this) })) : (e(this).children("[data-alpaca-array-toolbar-action='add']").each(function(n) { e(this).addClass("alpaca-button-disabled"), t.fireCallback("disableButton", this) }), e(this).children("[data-alpaca-array-actionbar-action='add']").each(function(n) { e(this).addClass("alpaca-button-disabled"), t.fireCallback("disableButton", this) })), t._validateEqualMinItems() ? e(this).children("[data-alpaca-array-actionbar-action='remove']").each(function(n) { e(this).removeClass("alpaca-button-disabled"), t.fireCallback("enableButton", this) }) : e(this).children("[data-alpaca-array-actionbar-action='remove']").each(function(n) { e(this).addClass("alpaca-button-disabled"), t.fireCallback("disableButton", this) }) }), e(a).first().children("[data-alpaca-array-actionbar-action='up']").each(function() { e(this).addClass("alpaca-button-disabled"), t.fireCallback("disableButton", this) }), e(a).last().children("[data-alpaca-array-actionbar-action='down']").each(function() { e(this).addClass("alpaca-button-disabled"), t.fireCallback("disableButton", this) }) } }, doResolveItemContainer: function() {
var t = this;
return e(t.container) }, handleToolBarAddItemClick: function(e) {
var n = this;
n.resolveItemSchemaOptions(function(i, a, r) {
if (r) return t.throwErrorWithCallback("Circular reference detected for schema: " + JSON.stringify(i), n.errorCallback);
var o = n.children.length,
l = t.createEmptyDataInstance(i);
n.addItem(o, i, a, l, function(t) { e && e(t) }) }) }, handleActionBarAddItemClick: function(e, n) {
var i = this;
i.resolveItemSchemaOptions(function(a, r, o) {
if (o) return t.throwErrorWithCallback("Circular reference detected for schema: " + JSON.stringify(a), i.errorCallback);
var l = i.getValue(),
s = t.createEmptyDataInstance(a);
i.addItem(e + 1, a, r, s, function(t) { l.splice(e + 1, 0, t.getValue()), i.setValue(l), n && n(t) }) }) }, handleActionBarRemoveItemClick: function(e, t) {
var n = this;
n.removeItem(e, function() { t && t() }) }, handleActionBarMoveItemUpClick: function(e, t) {
var n = this;
n.swapItem(e, e - 1, n.options.animate, function() { t && t() }) }, handleActionBarMoveItemDownClick: function(e, t) {
var n = this;
n.swapItem(e, e + 1, n.options.animate, function() { t && t() }) }, doAddItem: function(n, i, a) {
var r = this,
o = r.doResolveItemContainer();
if (0 === n) e(o).append(i.containerItemEl);
else {
var l = o.children("[data-alpaca-container-item-index='" + (n - 1) + "']");
l && l.length > 0 && l.after(i.containerItemEl) }
r.doAfterAddItem(i, function(e) { t.fireReady(i), a(e) }) }, doAfterAddItem: function(e, t) { t() }, addItem: function(e, t, n, i, a) {
var r = this;
r._validateEqualMaxItems() && r.createItem(e, t, n, i, function(t) { r.registerChild(t, e), r.doAddItem(e, t, function() { r.handleRepositionDOMRefresh(), r.updateToolbars(), r.refreshValidationState(), r.trigger("add", t), r.triggerUpdate(), a && a(t) }) }) }, doRemoveItem: function(e, t) {
var n = this,
i = n.doResolveItemContainer();
i.children(".alpaca-container-item[data-alpaca-container-item-index='" + e + "']").remove(), n.doAfterRemoveItem(e, function(e) { t(e) }) }, doAfterRemoveItem: function(e, t) { t() }, removeItem: function(e, t) {
var n = this;
this._validateEqualMinItems() && (n.unregisterChild(e), n.doRemoveItem(e, function() { n.handleRepositionDOMRefresh(), n.updateToolbars(), n.refreshValidationState(), n.trigger("remove", e), n.triggerUpdate(), t && t() })) }, moveItem: function(n, i, a, r) {
var o = this;
if ("function" == typeof a && (r = a, a = o.options.animate), "undefined" == typeof a && (a = o.options.animate ? o.options.animate : !0), "string" == typeof n && (n = parseInt(n, 10)), "string" == typeof i && (i = parseInt(i, 10)), 0 > i && (i = 0), i >= o.children.length && (i = o.children.length - 1), -1 !== i && n !== i) {
var l = o.children[i];
if (l) {
var s = function() {
var e = i;
i > n && e--;
var t = o.children.splice(n, 1)[0];
o.children.splice(e, 0, t), o.data = o.getValue(), o.refresh(function() { o.refreshValidationState(), o.triggerUpdate(), o.trigger("move"), r && r() }) },
u = 0;
if (a && (u = 500), u > 0) {
var c = o.getId(),
d = o.getContainerEl().find(".alpaca-container-item[data-alpaca-container-item-index='" + n + "'][data-alpaca-container-item-parent-field-id='" + c + "']"),
p = o.getContainerEl().find(".alpaca-container-item[data-alpaca-container-item-index='" + i + "'][data-alpaca-container-item-parent-field-id='" + c + "']"),
h = e("");
d.before(h);
var f = e("");
p.before(f), t.animatedMove(d, p, u, function() { s() }) } else s() } } }, swapItem: function(n, i, a, r) {
var o = this;
if ("function" == typeof a && (r = a, a = o.options.animate), "undefined" == typeof a && (a = o.options.animate ? o.options.animate : !0), "string" == typeof n && (n = parseInt(n, 10)), "string" == typeof i && (i = parseInt(i, 10)), 0 > i && (i = 0), i >= o.children.length && (i = o.children.length - 1), -1 !== i && n !== i) {
var l = o.children[i];
if (l) {
var s = function() {
var e = o.children[n],
t = o.children[i];
o.children[n] = t, o.children[i] = e, o.data = o.getValue(), o.refresh(function() { o.refreshValidationState(), o.triggerUpdate(), o.trigger("move"), r && r() }) },
u = 0;
if (a && (u = 500), u > 0) {
var c = o.getId(),
d = o.getContainerEl().find(".alpaca-container-item[data-alpaca-container-item-index='" + n + "'][data-alpaca-container-item-parent-field-id='" + c + "']"),
p = o.getContainerEl().find(".alpaca-container-item[data-alpaca-container-item-index='" + i + "'][data-alpaca-container-item-parent-field-id='" + c + "']"),
h = e("");
d.before(h);
var f = e("");
p.before(f), t.animatedSwap(d, p, u, function() { s() }) } else s() } } }, getType: function() {
return "array" }, getTitle: function() {
return "Array Field" }, getDescription: function() {
return "Field for list of items with same data type or structure." }, getSchemaOfSchema: function() {
var e = { properties: { items: { title: "Array Items", description: "Schema for array items.", type: "object" }, minItems: { title: "Minimum Items", description: "Minimum number of items.", type: "number" }, maxItems: { title: "Maximum Items", description: "Maximum number of items.", type: "number" }, uniqueItems: { title: "Items Unique", description: "Item values should be unique if true.", type: "boolean", "default": !1 } } };
return this.children && this.children[0] && t.merge(e.properties.items.properties, this.children[0].getSchemaOfSchema()), t.merge(this.base(), e) }, getOptionsForSchema: function() {
return t.merge(this.base(), { fields: { items: { type: "object" }, minItems: { type: "integer" }, maxItems: { type: "integer" }, uniqueItems: { type: "checkbox" } } }) }, getSchemaOfOptions: function() {
var e = { properties: { toolbarSticky: { title: "Sticky Toolbar", description: "If true, the array item toolbar will always be enabled. If false, the toolbar is always disabled. If undefined or null, the toolbar will appear when hovered over.", type: "boolean", "default": void 0 }, toolbarStyle: { title: "Toolbar Style", description: "The kind of top-level toolbar to render for the array field. Either 'button' or 'link'.", type: "string", "default": "button" }, actionbarStyle: { title: "Actionbar Style", description: "The kind of actionbar to render for each item in the array. Either 'top', 'bottom', 'left', or 'right'.", type: "string", "default": "top" }, toolbar: { type: "object", title: "Toolbar Configuration", properties: { showLabels: { type: "boolean", "default": !0, title: "Whether to show labels next to actions" }, actions: { type: "array", title: "Toolbar Actions Configuration", items: { action: { type: "string", title: "Action Key" }, label: { type: "string", title: "Action Label" }, iconClass: { type: "string", title: "Action CSS Classes for Icon" }, click: { type: "function", title: "Action Click Handler" }, enabled: { type: "boolean", title: "Whether to enable the action", "default": !0 } } } } }, actionbar: { type: "object", properties: { showLabels: { type: "boolean", "default": !1, title: "Whether to show labels next to actions" }, actions: { type: "array", title: "Actions Bar Actions Configuration", items: { action: { type: "string", title: "Action Key" }, label: { type: "string", title: "Action Label" }, iconClass: { type: "string", title: "Action CSS Classes for Icon" }, click: { type: "function", title: "Action Click Handler" }, enabled: { type: "boolean", title: "Whether to enable the action", "default": !0 } } } } }, hideToolbarWithChildren: { type: "boolean", title: "Hide Toolbar with Children", description: "Indicates whether to hide the top toolbar when child elements are available.", "default": !0 } } };
return this.children && this.children[0] && t.merge(e.properties.items.properties, this.children[0].getSchemaOfSchema()), t.merge(this.base(), e) }, getOptionsForOptions: function() {
return t.merge(this.base(), { fields: { toolbarSticky: { type: "checkbox" }, items: { type: "object", fields: {} } } }) } }), t.registerMessages({ notEnoughItems: "The minimum number of items is {0}", tooManyItems: "The maximum number of items is {0}", valueNotUnique: "Values are not unique", notAnArray: "This value is not an Array" }), t.registerFieldClass("array", t.Fields.ArrayField), t.registerDefaultSchemaFieldMapping("array", "array"), t.registerMessages({ addItemButtonLabel: "Add New Item", addButtonLabel: "Add", removeButtonLabel: "Remove", upButtonLabel: "Up", downButtonLabel: "Down" }) }(jQuery),
function(e) {
var t = e.alpaca;
t.Fields.ObjectField = t.ContainerField.extend({
getFieldType: function() {
return "object" },
setup: function() {
var e = this;
this.base();
var n = e.resolveContainerItemTemplateType();
if (!n) { e.resolveContainerItemTemplateType();
return t.throwErrorWithCallback("Unable to find template descriptor for container item: " + e.getFieldType()) }
if (this.containerItemTemplateDescriptor = e.view.getTemplateDescriptor("container-" + n + "-item", e), !t.isEmpty(this.data) && "" !== this.data && !t.isObject(this.data)) {
if (!t.isString(this.data)) return;
try {
if (this.data = t.parseJSON(this.data), !t.isObject(this.data)) return void t.logWarn("ObjectField parsed data but it was not an object: " + JSON.stringify(this.data)) } catch (i) {
return } } },
setValue: function(e) {
if (e || (e = {}), t.isObject(e)) {
var n = {};
for (var i in this.childrenById) {
var a = this.childrenById[i].propertyId;
n[a] = this.childrenById[i] }
var r = {};
for (var o in e) e.hasOwnProperty(o) && (r[o] = e[o]);
for (var a in r) {
var l = n[a];
l && (l.setValue(r[a]), delete n[a], delete r[a]) }
for (var a in n) {
var l = n[a];
l.setValue(null) } } },
getContainerValue: function() {
if (0 === this.children.length && !this.isRequired()) return {};
for (var e = {}, n = 0; n < this.children.length; n++) {
var i = this.children[n].propertyId,
a = this.children[n].getValue();
if (a !== a && (a = void 0), "undefined" != typeof a && this.determineAllDependenciesValid(i)) {
var r = null; "boolean" == typeof a ? r = !!a : t.isArray(a) || t.isObject(a) || t.isNumber(a) ? r = a : (a || 0 === a) && (r = a), null !== r && (e[i] = r) } }
return e },
afterRenderContainer: function(e, n) {
var i = this;
this.base(e, function() {
if (i.isTopLevel() && i.view) { i.wizardConfigs = i.view.getWizard(), "undefined" != typeof i.wizardConfigs && (i.wizardConfigs && i.wizardConfigs !== !0 || (i.wizardConfigs = {}));
var e = i.view.getLayout().templateDescriptor;
i.wizardConfigs && t.isObject(i.wizardConfigs) && (!e || i.wizardConfigs.bindings ? i.autoWizard() : i.wizard()) }
n() }) },
createItems: function(e) {
var n = this,
i = [],
a = {};
for (var r in n.data) a[r] = r;
var o = n.data;
n.schema && n.schema.properties && (o = n.schema.properties);
var l = function() {
var n = [];
for (var r in a) n.push(r);
n.length > 0 && t.logDebug("There were " + n.length + " extra data keys that were not part of the schema " + JSON.stringify(n)), e(i) },
s = [];
for (var u in o) {
var c = null;
n.data && n.data.hasOwnProperty(u) && (c = n.data[u]);
var d = function(e, a, r) {
return function(o) { n.resolvePropertySchemaOptions(e, function(l, s, u) {
return u ? t.throwErrorWithCallback("Circular reference detected for schema: " + JSON.stringify(l), n.errorCallback) : (l || t.logDebug("Unable to resolve schema for property: " + e), void n.createItem(e, l, s, a, null, function(t) { i.push(t), delete r[e], o() })) }) } }(u, c, a);
s.push(d) }
t.nextTick(function() { t.series(s, function(e) {
for (var t = !1, n = 0; n < i.length; n++)
if ("undefined" != typeof i[n].options.order) { t = !0;
break }
t && i.sort(function(e, t) {
var n = e.options.order;
n || (n = 0);
var i = t.options.order;
return i || (i = 0), n - i }), l() }) })
},
createItem: function(n, i, a, r, o, l) {
var s = this,
u = e("");
u.alpaca({ data: r, options: a, schema: i, view: this.view.id ? this.view.id : this.view, connector: this.connector, error: function(e) { s.destroy(), s.errorCallback.call(s, e) }, notTopLevel: !0, render: function(e, t) { e.parent = s, e.propertyId = n, "/" !== s.path ? e.path = s.path + "/" + n : e.path = s.path + n, e.render(null, function() { t && t() }) }, postRender: function(n) {
var i = t.tmpl(s.containerItemTemplateDescriptor, { id: s.getId(), name: n.name, parentFieldId: s.getId(), actionbarStyle: s.options.actionbarStyle, view: s.view, data: r }),
a = e(i).find("." + t.MARKER_CLASS_CONTAINER_FIELD_ITEM_FIELD);
return 0 === a.length && e(i).hasClass(t.MARKER_CLASS_CONTAINER_FIELD_ITEM_FIELD) && (a = e(i)), 0 === a.length ? void s.errorCallback.call(s, { message: "Cannot find insertion point for field: " + s.getId() }) : (e(a).before(n.getFieldEl()), e(a).remove(), n.containerItemEl = i, t.fieldApplyFieldAndChildren(n, function(e) { e.hideInitValidationError = !1 }), void(l && l(n))) } }) },
resolvePropertySchemaOptions: function(e, n) {
var i = this,
a = function(e, t, a) { i.options.readonly && (t.readonly = !0), n(e, t, a) },
r = null;
i.schema && i.schema.properties && i.schema.properties[e] && (r = i.schema.properties[e]);
var o = {};
if (i.options && i.options.fields && i.options.fields[e] && (o = i.options.fields[e]), r && r.$ref) {
var l = r.$ref,
s = r.$ref;
o.$ref && (s = o.$ref);
for (var u = this, c = [u]; u.parent;) u = u.parent, c.push(u);
var d = r,
p = o;
t.loadRefSchemaOptions(u, l, s, function(e, n) {
for (var i = 0, r = 0; r < c.length; r++) c[r].schema && (c[r].schema.id === l || c[r].schema.id === "#" + l ? i++ : c[r].schema.$ref === l && i++);
var o = i > 1,
s = {};
d && t.mergeObject(s, d), e && t.mergeObject(s, e), d && d.id && (s.id = d.id);
var u = {};
p && t.mergeObject(u, p), n && t.mergeObject(u, n), t.nextTick(function() { a(s, u, o) }) }) } else t.nextTick(function() { a(r, o) }) },
applyCreatedItems: function(e, t) {
var n = this;
this.base(e, function() {
var i = function(a) {
if (a === e.items.length) return void t();
var r = e.items[a],
o = r.propertyId;
n.showOrHidePropertyBasedOnDependencies(o), n.bindDependencyFieldUpdateEvent(o), n.refreshDependentFieldStates(o), i(a + 1) };
i(0) }) },
handleValidate: function() {
var e = this.base(),
n = this.validation,
i = this._validateMaxProperties();
return n.tooManyProperties = { message: i ? "" : t.substituteTokens(this.getMessage("tooManyProperties"), [this.schema.maxProperties]), status: i }, i = this._validateMinProperties(), n.tooFewProperties = { message: i ? "" : t.substituteTokens(this.getMessage("tooManyItems"), [this.schema.minProperties]), status: i }, e && n.tooManyProperties.status && n.tooFewProperties.status },
_validateMaxProperties: function() {
if ("undefined" == typeof this.schema.maxProperties) return !0;
var e = this.schema.maxProperties,
t = 0;
for (var n in this.data) t++;
return e >= t },
_validateMinProperties: function() {
if ("undefined" == typeof this.schema.minProperties) return !0;
var e = this.schema.minProperties,
t = 0;
for (var n in this.data) t++;
return t >= e },
showOrHidePropertyBasedOnDependencies: function(e) {
var n = this,
i = this.childrenByPropertyId[e];
if (!i) return t.throwErrorWithCallback("Missing property: " + e, n.errorCallback);
var a = this.determineAllDependenciesValid(e);
a ? (i.show(), i.onDependentReveal()) : (i.hide(), i.onDependentConceal()), i.getFieldEl().trigger("fieldupdate") },
getChildDependencies: function(e) {
var t = null;
if (this.schema.dependencies && (t = this.schema.dependencies[e]), !t) {
var n = this.childrenByPropertyId[e];
n && (t = n.schema.dependencies) }
return t },
getChildConditionalDependencies: function(e) {
var t = null,
n = this.childrenByPropertyId[e];
return n && (t = n.options.dependencies), t },
determineAllDependenciesValid: function(n) {
var i = this,
a = this.childrenByPropertyId[n];
if (!a) return t.throwErrorWithCallback("Missing property: " + n, i.errorCallback);
var r = i.getChildDependencies(n);
if (!r) return !0;
var o = !0;
return t.isString(r) ? o = i.determineSingleDependencyValid(n, r) : t.isArray(r) && e.each(r, function(e, t) { o = o && i.determineSingleDependencyValid(n, t) }), o },
bindDependencyFieldUpdateEvent: function(n) {
var i = this,
a = this.childrenByPropertyId[n];
if (!a) return t.throwErrorWithCallback("Missing property: " + n, i.errorCallback);
var r = i.getChildDependencies(n);
if (!r) return !0;
var o = function(e, n) {
var r = t.resolveField(i, n);
r && (r.getFieldEl().bind("fieldupdate", function(e, t, n, a) {
return function(t) { i.showOrHidePropertyBasedOnDependencies(n), e.getFieldEl().trigger("fieldupdate") } }(a, r, e, n)), r.getFieldEl().trigger("fieldupdate")) };
t.isString(r) ? o(n, r) : t.isArray(r) && e.each(r, function(e, t) { o(n, t) }) },
refreshDependentFieldStates: function(n) {
var i = this,
a = this.childrenByPropertyId[n];
if (!a) return t.throwErrorWithCallback("Missing property: " + n, i.errorCallback);
var r = i.getChildDependencies(n);
if (!r) return !0;
var o = function(e) {
var n = t.resolveField(i, e);
n && n.getFieldEl().trigger("fieldupdate") };
t.isString(r) ? o(r) : t.isArray(r) && e.each(r, function(e, t) { o(t) }) },
determineSingleDependencyValid: function(e, n) {
var i = this,
a = t.resolveField(i, n);
if (!a) return !1;
var r = a.data,
o = !1,
l = this.getChildConditionalDependencies(e);
if (l && 0 !== l.length) { "boolean" !== a.getType() || r || (r = !1);
var s = l[n];!t.isEmpty(s) && t.isFunction(s) ? o = s.call(this, r) : (o = !0, t.isArray(s) ? t.anyEquality(r, s) || (o = !1) : t.isEmpty(s) || t.anyEquality(s, r) || (o = !1)) } else o = "boolean" !== a.getType() || this.childrenByPropertyId[e].options.dependencies || r ? !t.isValEmpty(a.data) : !1;
return a && a.isHidden() && (o = !1), o },
getIndex: function(e) {
if (t.isEmpty(e)) return -1;
for (var n = 0; n < this.children.length; n++) {
var i = this.children[n].propertyId;
if (i == e) return n }
return -1 },
addItem: function(e, t, n, i, a, r) {
var o = this;
this.createItem(e, t, n, i, a, function(e) {
var t = null;
if (a && o.childrenById[a])
for (var n = 0; n < o.children.length; n++)
if (o.children[n].getId() == a) { t = n;
break }
o.registerChild(e, null != t ? t + 1 : 0), o.doAddItem(t, e), o.handleRepositionDOMRefresh(), o.refreshValidationState(!0, function() { o.trigger("add", e), o.triggerUpdate(), e.triggerWithPropagation.call(e, "ready", "down"), r && r() }) }) },
doAddItem: function(n, i) {
var a = this;
if (n) {
var r = a.getContainerEl().children("[data-alpaca-container-item-index='" + n + "']");
r && r.length > 0 && r.after(i.containerItemEl) } else e(a.container).prepend(i.containerItemEl);
a.doAfterAddItem(i, function() { t.fireReady(i) }) },
doAfterAddItem: function(e, t) { t() },
doResolveItemContainer: function() {
var t = this;
return e(t.container) },
removeItem: function(t, n) {
var i = this,
a = this.childrenByPropertyId[t];
a ? (this.children = e.grep(this.children, function(e, n) {
return e.propertyId !== t }), delete this.childrenByPropertyId[t], delete this.childrenById[a.getId()], i.doRemoveItem(a), this.refreshValidationState(!0, function() { i.handleRepositionDOMRefresh(), i.trigger("remove", a), i.triggerUpdate(), n && n() })) : n() },
doRemoveItem: function(e) {
var t = this,
n = t.doResolveItemContainer();
n.children(".alpaca-container-item[data-alpaca-container-item-name='" + e.name + "']").remove(), e.destroy() },
wizard: function() {
var n = this,
i = this.wizardConfigs.steps;
i || (i = []);
var a = this.wizardConfigs.title,
r = this.wizardConfigs.description,
o = this.wizardConfigs.buttons;
o || (o = {}), o.previous || (o.previous = {}), o.previous.title || (o.previous.title = "Previous"), o.previous.align || (o.previous.align = "left"), o.previous.type || (o.previous.type = "button"), o.next || (o.next = {}), o.next.title || (o.next.title = "Next"), o.next.align || (o.next.align = "right"), o.next.type || (o.next.type = "button"), this.wizardConfigs.hideSubmitButton || (o.submit || (o.submit = {}), o.submit.title || (o.submit.title = "Submit"), o.submit.align || (o.submit.align = "right"), o.submit.type || (o.submit.type = "button"));
for (var l in o) o[l].type || (o[l].type = "button");
var s = this.wizardConfigs.showSteps; "undefined" == typeof s && (s = !0);
var u = this.wizardConfigs.showProgressBar,
c = this.wizardConfigs.validation; "undefined" == typeof c && (c = !0);
var a = e(this.field).attr("data-alpaca-wizard-title"),
r = e(this.field).attr("data-alpaca-wizard-description"),
d = e(this.field).attr("data-alpaca-wizard-validation"); "undefined" != typeof d && (c = !!d);
var p = e(this.field).attr("data-alpaca-wizard-show-steps"); "undefined" != typeof p && (s = !!p);
var h = e(this.field).attr("data-alpaca-wizard-show-progress-bar"); "undefined" != typeof h && (u = !!h);
var f = e(this.field).find("[data-alpaca-wizard-role='step']");
0 == i.length && f.each(function(t) {
var n = {},
a = e(this).attr("data-alpaca-wizard-step-title"); "undefined" != typeof a && (n.title = a), n.title || (n.title = "Step " + t);
var r = e(this).attr("data-alpaca-wizard-step-description"); "undefined" != typeof r && (n.description = r), n.description || (n.description = "Step " + t), i.push(n) }), "undefined" == typeof u && i.length > 1 && (u = !0);
var m = {};
m.wizardTitle = a, m.wizardDescription = r, m.showSteps = s, m.performValidation = c, m.steps = i, m.buttons = o, m.schema = n.schema, m.options = n.options, m.data = n.data, m.showProgressBar = u, m.markAllStepsVisited = this.wizardConfigs.markAllStepsVisited, m.view = n.view;
var g = n.view.getTemplateDescriptor("wizard", n);
if (g) {
var v = t.tmpl(g, m);
e(n.field).append(v);
var b = e(v).find(".alpaca-wizard-nav"),
y = e(v).find(".alpaca-wizard-steps"),
w = e(v).find(".alpaca-wizard-buttons"),
E = e(v).find(".alpaca-wizard-progress-bar");
e(y).append(f),
function(i, a, r, o) {
var l = 0,
s = e(r).find("[data-alpaca-wizard-button-key='previous']"),
u = e(r).find("[data-alpaca-wizard-button-key='next']"),
c = e(r).find("[data-alpaca-wizard-button-key='submit']"),
d = function() {
if (o.showSteps) {
if (o.visits || (o.visits = {}), o.markAllStepsVisited)
for (var t = e(i).find("[data-alpaca-wizard-step-index]"), n = 0; n < t.length; n++) o.visits[n] = !0;
o.visits[l] = !0;
var t = e(i).find("[data-alpaca-wizard-step-index]");
e(t).removeClass("disabled"), e(t).removeClass("completed"), e(t).removeClass("active"), e(t).removeClass("visited");
for (var n = 0; n < t.length; n++) l > n ? e(i).find("[data-alpaca-wizard-step-index='" + n + "']").addClass("completed") : n === l ? e(i).find("[data-alpaca-wizard-step-index='" + n + "']").addClass("active") : o.visits && o.visits[n] || e(i).find("[data-alpaca-wizard-step-index='" + n + "']").addClass("disabled"), o.visits && o.visits[n] && e(i).find("[data-alpaca-wizard-step-index='" + n + "']").addClass("visited") }
if (o.showProgressBar) {
var r = l + 1,
d = o.steps.length + 1,
p = parseInt(r / d * 100, 10) + "%";
e(E).find(".progress-bar").attr("aria-valuemax", d), e(E).find(".progress-bar").attr("aria-valuenow", r), e(E).find(".progress-bar").css("width", p) }
s.hide(), u.hide(), c.hide(), 1 == o.steps.length ? c.show() : o.steps.length > 1 && (l > 0 && s.show(), u.show(), 0 == l ? u.show() : l == o.steps.length - 1 && (u.hide(), c.show())), e(a).find("[data-alpaca-wizard-role='step']").hide(), e(e(a).find("[data-alpaca-wizard-role='step']")[l]).show() },
p = function(i, r) {
if (!o.performValidation) return void r(!0);
var s = [],
u = e(e(a).find("[data-alpaca-wizard-role='step']")[l]);
e(u).find(".alpaca-field").each(function() {
var t = e(this).attr("data-alpaca-field-id");
if (t) {
var i = n.childrenById[t];
i && s.push(i) } });
for (var c = [], d = 0; d < s.length; d++) c.push(function(e) {
return function(t) { e.refreshValidationState(!0, function() { t() }) } }(s[d]));
t.series(c, function() {
for (var e = !0, t = 0; t < s.length; t++) e = e && s[t].isValid(!0);
var a = o.buttons[i];
a && a.validate ? a.validate.call(n, function(t) { e = e && t, r(e) }) : r(e) }) };
e(s).click(function(e) {
if (e.preventDefault(), l >= 1) {
var t = o.buttons.previous;
t && t.click && t.click.call(n, e), l--, d() } }), e(u).click(function(e) { e.preventDefault(), l + 1 <= o.steps.length - 1 && p("next", function(t) {
if (t) {
var i = o.buttons.next;
i && i.click && i.click.call(n, e), l++, d() } else window.setTimeout(function() { n.focus(function(e) {}) }, 250) }) }), e(c).click(function(e) { e.preventDefault(), l === o.steps.length - 1 && p("submit", function(t) {
if (t) {
var i = o.buttons.submit;
i && (i.click ? i.click.call(n, e) : n.form && n.form.submit()) } else window.setTimeout(function() { n.focus(function(e) {}) }, 250) }) }), e(r).find("[data-alpaca-wizard-button-key]").each(function() {
var t = e(this).attr("data-alpaca-wizard-button-key");
if ("submit" != t && "next" != t && "previous" != t) {
var i = o.buttons[t];
i && i.click && e(this).click(function(e) {
return function(t) { e.click.call(n, t) } }(i)) } }), e(i).find("[data-alpaca-wizard-step-index]").click(function(t) { t.preventDefault();
var n = e(this).attr("data-alpaca-wizard-step-index");
n && (n = parseInt(n, 10), (n == l || o.visits && o.visits[n]) && (l > n ? (l = n, d()) : n > l && p(null, function(e) { e && (l = n, d()) }))) }), n.on("moveToStep", function(e) {
var t = e.index,
n = e.skipValidation; "undefined" != typeof t && t <= o.steps.length - 1 && (n ? (l = t, d()) : p(null, function(e) { e && (l = t, d()) })) }), n.on("advanceOrSubmit", function(t) { p(null, function(t) { t && (l === o.steps.length - 1 ? e(c).click() : e(u).click()) }) }), d() }(b, y, w, m) } },
autoWizard: function() {
var t = this.wizardConfigs.bindings;
t || (t = {});
for (var n in this.childrenByPropertyId) t.hasOwnProperty(n) || (t[n] = 1);
var i = !0;
e(this.field).find("[data-alpaca-wizard-role='step']").length > 0 && (i = !1);
var a = 1,
r = [];
do { r = [];
for (var n in t) t[n] === a && this.childrenByPropertyId && this.childrenByPropertyId[n] && r.push(this.childrenByPropertyId[n]);
if (r.length > 0) {
var o = null;
i ? (o = e(''), e(this.field).append(o)) : o = e(e(this.field).find("[data-alpaca-wizard-role='step']")[a - 1]);
for (var l = !1, s = 0; s < r.length; s++)
if ("undefined" != typeof r[s].options.order) { l = !0;
break }
l && r.sort(function(e, t) {
var n = e.options.order;
n || (n = 0);
var i = t.options.order;
return i || (i = 0), n - i });
for (var s = 0; s < r.length; s++) e(o).append(r[s].containerItemEl);
a++ } } while (r.length > 0);
this.wizard(), 0 === e(this.container).children().length && e(this.container).css("display", "none") },
getType: function() {
return "object" },
moveItem: function(n, i, a, r) {
var o = this;
if ("function" == typeof a && (r = a, a = o.options.animate), "undefined" == typeof a && (a = o.options.animate ? o.options.animate : !0), "string" == typeof n && (n = parseInt(n, 10)), "string" == typeof i && (i = parseInt(i, 10)), 0 > i && (i = 0), i >= o.children.length && (i = o.children.length - 1), -1 !== i) {
var l = o.children[i];
if (l) {
var s = o.getContainerEl().children("[data-alpaca-container-item-index='" + n + "']"),
u = o.getContainerEl().children("[data-alpaca-container-item-index='" + i + "']"),
c = e("");
s.before(c);
var d = e("");
u.before(d);
var p = function() {
for (var t = [], a = 0; a < o.children.length; a++) a === n ? t[a] = o.children[i] : a === i ? t[a] = o.children[n] : t[a] = o.children[a];
o.children = t, c.replaceWith(u), d.replaceWith(s), o.handleRepositionDOMRefresh(), e(s).find("[data-alpaca-array-actionbar-item-index='" + n + "']").attr("data-alpaca-array-actionbar-item-index", i), e(u).find("[data-alpaca-array-actionbar-item-index='" + i + "']").attr("data-alpaca-array-actionbar-item-index", n), o.refreshValidationState(), o.triggerUpdate(), o.trigger("move"), r && r() };
a ? t.animatedSwap(s, u, 500, function() { p() }) : p() } } },
getTitle: function() {
return "Object Field" },
getDescription: function() {
return "Object field for containing other fields" },
getSchemaOfSchema: function() {
var e = { properties: { properties: { title: "Properties", description: "List of child properties.", type: "object" }, maxProperties: { type: "number", title: "Maximum Number Properties", description: "The maximum number of properties that this object is allowed to have" }, minProperties: { type: "number", title: "Minimum Number of Properties", description: "The minimum number of properties that this object is required to have" } } },
n = e.properties.properties;
if (n.properties = {}, this.children)
for (var i = 0; i < this.children.length; i++) {
var a = this.children[i].propertyId;
n.properties[a] = this.children[i].getSchemaOfSchema(), n.properties[a].title = a + " :: " + n.properties[a].title }
return t.merge(this.base(), e) },
getSchemaOfOptions: function() {
var e = t.merge(this.base(), { properties: {}, order: { type: "number", title: "Order", description: "Allows for optional specification of the index of this field in the properties array." } }),
n = { properties: { fields: { title: "Field Options", description: "List of options for child fields.", type: "object" } } },
i = n.properties.fields;
if (i.properties = {}, this.children)
for (var a = 0; a < this.children.length; a++) {
var r = this.children[a].propertyId;
i.properties[r] = this.children[a].getSchemaOfOptions(), i.properties[r].title = r + " :: " + i.properties[r].title }
return t.merge(e, n) }
}), t.registerMessages({ tooManyProperties: "The maximum number of properties ({0}) has been exceeded.", tooFewProperties: "There are not enough properties ({0} are required)" }), t.registerFieldClass("object", t.Fields.ObjectField), t.registerDefaultSchemaFieldMapping("object", "object")
}(jQuery),
function(e) {
var t = e.alpaca;
t.Fields.AnyField = t.ControlField.extend({ getFieldType: function() {
return "any" }, setup: function() { this.base() }, getControlValue: function() {
return this._getControlVal(!0) }, setValue: function(e) { t.isEmpty(e) ? this.control.val("") : this.control.val(e), this.base(e) }, disable: function() { this.control.disabled = !0 }, enable: function() { this.control.disabled = !1 }, focus: function(e) { this.control.focus(), e && e(this) }, getType: function() {
return "any" }, getTitle: function() {
return "Any Field" }, getDescription: function() {
return "Any field." }, getSchemaOfSchema: function() {
return t.merge(this.base(), { properties: {} }) }, getOptionsForSchema: function() {
return t.merge(this.base(), { fields: {} }) }, getSchemaOfOptions: function() {
return t.merge(this.base(), { properties: {} }) }, getOptionsForOptions: function() {
return t.merge(this.base(), { fields: {} }) } }), t.registerFieldClass("any", t.Fields.AnyField), t.registerDefaultSchemaFieldMapping("any", "any") }(jQuery),
function(e) {
var t = e.alpaca;
t.Fields.HiddenField = t.ControlField.extend({ getFieldType: function() {
return "hidden" }, setup: function() { this.base() }, getControlValue: function() {
return this._getControlVal(!0) }, setValue: function(e) { t.isEmpty(e) ? this.getControlEl().val("") : this.getControlEl().val(e), this.base(e) }, getType: function() {
return "string" }, getTitle: function() {
return "Hidden" }, getDescription: function() {
return "Field for a hidden HTML input" } }), t.registerFieldClass("hidden", t.Fields.HiddenField) }(jQuery),
function(e) {
var t = e.alpaca;
t.Fields.AddressField = t.Fields.ObjectField.extend({ getFieldType: function() {
return "address" }, setup: function() { this.base(), this.data && this.data.street || (this.data = { street: ["", ""] }), this.schema = { title: "Home Address", type: "object", properties: { street: { title: "Street", type: "array", items: { type: "string", maxLength: 30 }, minItems: 0, maxItems: 3 }, city: { title: "City", type: "string" }, state: { title: "State", type: "string", "enum": ["AL", "AK", "AS", "AZ", "AR", "CA", "CO", "CT", "DE", "DC", "FM", "FL", "GA", "GU", "HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MH", "MD", "MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ", "NM", "NY", "NC", "ND", "MP", "OH", "OK", "OR", "PW", "PA", "PR", "RI", "SC", "SD", "TN", "TX", "UT", "VT", "VI", "VA", "WA", "WV", "WI", "WY"] }, zip: { title: "Zip Code", type: "string", pattern: /^(\d{5}(-\d{4})?)?$/ } } }, t.merge(this.options, { fields: { zip: { maskString: "99999", size: 5 }, state: { optionLabels: ["ALABAMA", "ALASKA", "AMERICAN SAMOA", "ARIZONA", "ARKANSAS", "CALIFORNIA", "COLORADO", "CONNECTICUT", "DELAWARE", "DISTRICT OF COLUMBIA", "FEDERATED STATES OF MICRONESIA", "FLORIDA", "GEORGIA", "GUAM", "HAWAII", "IDAHO", "ILLINOIS", "INDIANA", "IOWA", "KANSAS", "KENTUCKY", "LOUISIANA", "MAINE", "MARSHALL ISLANDS", "MARYLAND", "MASSACHUSETTS", "MICHIGAN", "MINNESOTA", "MISSISSIPPI", "MISSOURI", "MONTANA", "NEBRASKA", "NEVADA", "NEW HAMPSHIRE", "NEW JERSEY", "NEW MEXICO", "NEW YORK", "NORTH CAROLINA", "NORTH DAKOTA", "NORTHERN MARIANA ISLANDS", "OHIO", "OKLAHOMA", "OREGON", "PALAU", "PENNSYLVANIA", "PUERTO RICO", "RHODE ISLAND", "SOUTH CAROLINA", "SOUTH DAKOTA", "TENNESSEE", "TEXAS", "UTAH", "VERMONT", "VIRGIN ISLANDS", "VIRGINIA", "WASHINGTON", "WEST VIRGINIA", "WISCONSIN", "WYOMING"] } } }), t.isEmpty(this.options.addressValidation) && (this.options.addressValidation = !0) }, isContainer: function() {
return !1 }, getAddress: function() {
var t = this.getValue(); "view" === this.view.type && (t = this.data);
var n = "";
return t && (t.street && e.each(t.street, function(e, t) { n += t + " " }), t.city && (n += t.city + " "), t.state && (n += t.state + " "), t.zip && (n += t.zip)), n }, afterRenderContainer: function(t, n) {
var i = this;
this.base(t, function() {
var t = i.getContainerEl();
if (e(t).addClass("alpaca-addressfield"), i.options.addressValidation && !i.isDisplayOnly()) { e('').appendTo(t);
var a = e('').appendTo(t);
a.button && a.button({ text: !0 }), a.click(function() {
if (google && google.maps) {
var t = new google.maps.Geocoder,
n = i.getAddress();
t && t.geocode({ address: n }, function(t, n) {
if (n === google.maps.GeocoderStatus.OK) {
var a = i.getId() + "-map-canvas";
0 === e("#" + a).length && e("").appendTo(i.getFieldEl());
var r = new google.maps.Map(document.getElementById(i.getId() + "-map-canvas"), { zoom: 10, center: t[0].geometry.location, mapTypeId: google.maps.MapTypeId.ROADMAP });
new google.maps.Marker({ map: r, position: t[0].geometry.location }) } else i.displayMessage("Geocoding failed: " + n) }) } else i.displayMessage("Google Map API is not installed.") }).wrap(""), i.options.showMapOnLoad && a.click() }
n() }) }, getType: function() {
return "any" }, getTitle: function() {
return "Address" }, getDescription: function() {
return "Standard US Address with Street, City, State and Zip. Also comes with support for Google map." }, getSchemaOfOptions: function() {
return t.merge(this.base(), { properties: { validateAddress: { title: "Address Validation", description: "Enable address validation if true", type: "boolean", "default": !0 }, showMapOnLoad: { title: "Whether to show the map when first loaded", type: "boolean" } } }) }, getOptionsForOptions: function() {
return t.merge(this.base(), { fields: { validateAddress: { helper: "Address validation if checked", rightLabel: "Enable Google Map for address validation?", type: "checkbox" } } }) } }), t.registerFieldClass("address", t.Fields.AddressField) }(jQuery),
function(e) {
var t = e.alpaca;
t.Fields.CKEditorField = t.Fields.TextAreaField.extend({ getFieldType: function() {
return "ckeditor" }, setup: function() { this.data || (this.data = ""), this.base(), "undefined" == typeof this.options.ckeditor && (this.options.ckeditor = {}) }, afterRenderControl: function(t, n) {
var i = this;
this.base(t, function() {!i.isDisplayOnly() && i.control && "undefined" != typeof CKEDITOR && i.on("ready", function() { i.editor || (i.editor = CKEDITOR.replace(e(i.control)[0], i.options.ckeditor), i.initCKEditorEvents()) }), e(i.control).bind("destroyed", function() {
if (i.editor) { i.editor.removeAllListeners();
try { i.editor.destroy(!1) } catch (e) {}
i.editor = null } }), n() }) }, initCKEditorEvents: function() {
var e = this;
e.editor && (e.editor.on("click", function(t) { e.onClick.call(e, t), e.trigger("click", t) }), e.editor.on("change", function(t) { e.onChange(), e.triggerWithPropagation("change", t) }), e.editor.on("blur", function(t) { e.onBlur(), e.trigger("blur", t) }), e.editor.on("focus", function(t) { e.onFocus.call(e, t), e.trigger("focus", t) }), e.editor.on("key", function(t) { e.onKeyPress.call(e, t), e.trigger("keypress", t) })) }, setValue: function(e) {
var t = this;
this.base(e), t.editor && t.editor.setData(e) }, getControlValue: function() {
var e = this,
t = null;
return e.editor && (t = e.editor.getData()), t }, destroy: function() {
var e = this;
e.editor && (e.editor.destroy(), e.editor = null), this.base() }, getTitle: function() {
return "CK Editor" }, getDescription: function() {
return "Provides an instance of a CK Editor control for use in editing HTML." }, getSchemaOfOptions: function() {
return t.merge(this.base(), { properties: { ckeditor: { title: "CK Editor options", description: "Use this entry to provide configuration options to the underlying CKEditor plugin.", type: "any" } } }) }, getOptionsForOptions: function() {
return t.merge(this.base(), { fields: { ckeditor: { type: "any" } } }) } }), t.registerFieldClass("ckeditor", t.Fields.CKEditorField) }(jQuery),
function(e) {
var t = e.alpaca;
t.Fields.ColorField = t.Fields.TextField.extend({ setup: function() {
var t = this;
this.spectrumAvailable = !1, t.isDisplayOnly() || "undefined" == typeof e.fn.spectrum || (this.spectrumAvailable = !0), "undefined" == typeof this.options.spectrum && t.spectrumAvailable && (this.inputType = "color"), this.base(), t.spectrumAvailable && ("undefined" == typeof this.options.spectrum && (this.options.spectrum = {}), "undefined" == typeof this.options.spectrum.showInput && (this.options.spectrum.showInput = !0), "undefined" == typeof this.options.spectrum.showPalette && (this.options.spectrum.showPalette = !0), "undefined" == typeof this.options.spectrum.preferredFormat && (this.options.spectrum.preferredFormat = "hex3"), "undefined" == typeof this.options.spectrum.clickoutFiresChange && (this.options.spectrum.clickoutFiresChange = !0)) }, getFieldType: function() {
return "color" }, getType: function() {
return "string" }, afterRenderControl: function(t, n) {
var i = this;
this.base(t, function() { i.spectrumAvailable && i.control && (setTimeout(function() { e(i.control[0]).spectrum(e.extend({ color: i.data }, i.options.spectrum)) }, 100), e(i.control).on("change.spectrum", function(e, t) {
var n = i.convertTinyColor(t);
i.setValue(n) })), n() }) }, convertTinyColor: function(e) {
return e.toHexString() }, getTitle: function() {
return "Color Field" }, getDescription: function() {
return "A color picker for selecting hexadecimal color values" } }), t.registerFieldClass("color", t.Fields.ColorField), t.registerDefaultSchemaFieldMapping("color", "color") }(jQuery),
function(e) {
var t = e.alpaca;
t.Fields.ColorPickerField = t.Fields.TextField.extend({ setup: function() {
var t = this;
this.simpleColorPickerAvailable = !1, t.isDisplayOnly() || "undefined" == typeof e.fn.colorpicker || (this.simpleColorPickerAvailable = !0), "undefined" != typeof this.options.colorpicker || t.simpleColorPickerAvailable || (this.inputType = "color"), this.base(), "undefined" == typeof this.options.colorpicker && (this.options.colorpicker = {}), t.data && (t.options.colorpicker.color = t.data) }, getFieldType: function() {
return "colorpicker" }, getType: function() {
return "string" }, afterRenderControl: function(t, n) {
var i = this;
this.base(t, function() { i.simpleColorPickerAvailable && i.control && (setTimeout(function() { e(i.control[0]).colorpicker(i.options.colorpicker) }, 100), e(i.control).on("changeColor.colorpicker", function(e) { i.setValue(e.color.toHex()) })), n() }) }, getTitle: function() {
return "Color Picker Field" }, getDescription: function() {
return "A color picker for selecting hexadecimal color values" } }), t.registerFieldClass("colorpicker", t.Fields.ColorPickerField) }(jQuery),
function(e) {
var t = e.alpaca;
t.Fields.CountryField = t.Fields.SelectField.extend({ getFieldType: function() {
return "country" }, setup: function() { t.isUndefined(this.options.capitalize) && (this.options.capitalize = !1), this.schema["enum"] = [], this.options.optionLabels = [];
var e = this.getMessage("countries");
if (e)
for (var n in e) { this.schema["enum"].push(n);
var i = e[n];
this.options.capitalize && (i = i.toUpperCase()), this.options.optionLabels.push(i) }
this.base() }, getTitle: function() {
return "Country Field" }, getDescription: function() {
return "Provides a dropdown selector of countries keyed by their ISO3 code. The names of the countries are read from the I18N bundle for the current locale." }, getSchemaOfOptions: function() {
return t.merge(this.base(), { properties: { capitalize: { title: "Capitalize", description: "Whether the values should be capitalized", type: "boolean", "default": !1, readonly: !0 } } }) }, getOptionsForOptions: function() {
return t.merge(this.base(), { fields: { capitalize: { type: "checkbox" } } }) } }), t.registerFieldClass("country", t.Fields.CountryField), t.registerDefaultFormatFieldMapping("country", "country") }(jQuery),
function(e) {
var t = function() {
var e = { up: Math.ceil, down: function(e) {
return ~~e }, nearest: Math.round };
return function(t) {
return e[t] } }(),
n = e.alpaca;
n.Fields.CurrencyField = n.Fields.TextField.extend({ constructor: function(e, t, n, i, a, r, o) { n = n || {};
var l = this.getSchemaOfPriceFormatOptions().properties;
for (var s in l) {
var u = l[s];
s in n || (n[s] = u["default"] || void 0) } "undefined" != typeof t && (t = "" + parseFloat(t).toFixed(n.centsLimit)), this.base(e, t, n, i, a, r, o) }, getFieldType: function() {
return "currency" }, afterRenderControl: function(t, n) {
var i = this,
a = this.getControlEl();
this.base(t, function() { e(a).priceFormat(i.options), n() }) }, getControlValue: function() {
var n = this.getControlEl(),
i = e(n).is("input") ? n.val() : n.html();
if (this.options.unmask || "none" !== this.options.round) {
var a = function() {
var e = "";
for (var t in i) {
var n = i[t];
isNaN(n) ? n === this.options.centsSeparator && (e += ".") : e += n }
return parseFloat(e) }.bind(this)();
if ("none" !== this.options.round && (a = t(this.options.round)(a), !this.options.unmask)) {
for (var r = [], o = "" + a, l = 0, s = 0; l < i.length; l++) isNaN(i[l]) ? r.push(i[l]) : r.push(o[s++] || 0);
return r.join("") }
return a }
return i }, getTitle: function() {
return "Currency Field" }, getDescription: function() {
return "Provides an automatically formatted and configurable input for entering currency amounts." }, getSchemaOfPriceFormatOptions: function() {
return { properties: { allowNegative: { title: "Allow Negative", description: "Determines if negative numbers are allowed.", type: "boolean", "default": !1 }, centsLimit: { title: "Cents Limit", description: "The limit of fractional digits.", type: "number", "default": 2, minimum: 0 }, centsSeparator: { title: "Cents Separator", description: "The separator between whole and fractional amounts.", type: "text", "default": "." }, clearPrefix: { title: "Clear Prefix", description: "Determines if the prefix is cleared on blur.", type: "boolean", "default": !1 }, clearSuffix: { title: "Clear Suffix", description: "Determines if the suffix is cleared on blur.", type: "boolean", "default": !1 }, insertPlusSign: { title: "Plus Sign", description: "Determines if a plus sign should be inserted for positive values.", type: "boolean", "default": !1 }, limit: { title: "Limit", description: "A limit of the length of the field.", type: "number", "default": void 0, minimum: 0 }, prefix: { title: "Prefix", description: "The prefix if any for the field.", type: "text", "default": "$" }, round: { title: "Round", description: "Determines if the field is rounded. (Rounding is done when getValue is called and is not reflected in the UI)", type: "string", "enum": ["up", "down", "nearest", "none"], "default": "none" }, suffix: { title: "Suffix", description: "The suffix if any for the field.", type: "text", "default": "" }, thousandsSeparator: { title: "Thousands Separator", description: "The separator between thousands.", type: "string", "default": "," }, unmask: { title: "Unmask", description: "If true then the resulting value for this field will be unmasked. That is, the resulting value will be a float instead of a string (with the prefix, suffix, etc. removed).", type: "boolean", "default": !0 } } } }, getSchemaOfOptions: function() {
return n.merge(this.base(), this.getSchemaOfPriceFormatOptions()) }, getOptionsForOptions: function() {
return n.merge(this.base(), { fields: { allowNegative: { type: "checkbox" }, centsLimit: { type: "number" }, centsSeparator: { type: "text" }, clearPrefix: { type: "checkbox" }, clearSuffix: { type: "checkbox" }, insertPlusSign: { type: "checkbox" }, limit: { type: "number" }, prefix: { type: "text" }, round: { type: "select" }, suffix: { type: "text" }, thousandsSeparator: { type: "string" }, unmask: { type: "checkbox" } } }) } }), n.registerFieldClass("currency", n.Fields.CurrencyField) }(jQuery),
function(e) {
var t = e.alpaca;
t.Fields.DateField = t.Fields.TextField.extend({
getFieldType: function() {
return "date" },
getDefaultFormat: function() {
return t.defaultDateFormat },
getDefaultExtraFormats: function() {
return [] },
setup: function() {
var e = this;
if (this.base(), e.options.picker || (e.options.picker = {}), "undefined" == typeof e.options.picker.useCurrent && (e.options.picker.useCurrent = !1), e.options.picker.format && (e.options.dateFormat = e.options.picker.format), e.options.dateFormat || (e.options.dateFormat = e.getDefaultFormat()), e.options.picker.format || (e.options.picker.format = e.options.dateFormat), e.options.picker.locale || (e.options.picker.locale = t.defaultLocale), e.options.picker.dayViewHeaderFormat || (e.options.picker.dayViewHeaderFormat = "MMMM YYYY"), !e.options.picker.extraFormats) {
var n = e.getDefaultExtraFormats();
n && (e.options.picker.extraFormats = n) } "undefined" == typeof e.options.manualEntry && (e.options.manualEntry = !1) },
onKeyPress: function(e) {
return this.options.manualEntry ? (e.preventDefault(), void e.stopImmediatePropagation()) : void this.base(e);
},
onKeyDown: function(e) {
return this.options.manualEntry ? (e.preventDefault(), void e.stopImmediatePropagation()) : void this.base(e) },
beforeRenderControl: function(e, t) { this.field.css("position", "relative"), t() },
afterRenderControl: function(t, n) {
var i = this;
this.base(t, function() { "display" !== i.view.type && e.fn.datetimepicker && (i.getControlEl().datetimepicker(i.options.picker), i.picker = i.getControlEl().data("DateTimePicker"), i.picker && i.options.dateFormat && i.picker.format(i.options.dateFormat), i.picker && (i.options.dateFormat = i.picker.format()), i.getFieldEl().on("dp.change", function(e) { setTimeout(function() { i.onChange.call(i, e), i.triggerWithPropagation("change", e) }, 250) }), i.data && i.picker.date(i.data)), n() }) },
setManualEntry: function(e) { this.options.manualEntry = e },
getDate: function() {
var e = this,
t = null;
try { t = e.picker ? e.picker.date() ? e.picker.date()._d : null : new Date(this.getValue()) } catch (n) { console.error(n) }
return t },
date: function() {
return this.getDate() },
onChange: function(e) { this.base(), this.refreshValidationState() },
isAutoFocusable: function() {
return !1 },
handleValidate: function() {
var e = this.base(),
n = this.validation,
i = this._validateDateFormat();
return n.invalidDate = { message: i ? "" : t.substituteTokens(this.getMessage("invalidDate"), [this.options.dateFormat]), status: i }, e && n.invalidDate.status },
_validateDateFormat: function() {
var e = this,
n = !0;
if (e.options.dateFormat) {
var i = e.getValue();
if (i || e.isRequired()) {
var a = [];
if (a.push(e.options.dateFormat), e.options.picker && e.options.picker.extraFormats)
for (var r = 0; r < e.options.picker.extraFormats.length; r++) a.push(e.options.picker.extraFormats[r]);
for (var r = 0; r < a.length; r++) n = n || t.moment(i, e.options.dateFormat, !0).isValid() } }
return n },
setValue: function(e) {
var n = this;
this.base(e), this.picker && t.moment(e, n.options.dateFormat, !0).isValid() && this.picker.date(e) },
destroy: function() { this.base(), this.picker = null },
getTitle: function() {
return "Date Field" },
getDescription: function() {
return "Date Field" },
getSchemaOfSchema: function() {
return t.merge(this.base(), { properties: { format: { title: "Format", description: "Property data format", type: "string", "default": "date", "enum": ["date"], readonly: !0 } } }) },
getOptionsForSchema: function() {
return t.merge(this.base(), { fields: { format: { type: "text" } } }) },
getSchemaOfOptions: function() {
return t.merge(this.base(), { properties: { dateFormat: { title: "Date Format", description: "Date format (using moment.js format)", type: "string" }, picker: { title: "DatetimePicker options", description: "Options that are supported by the Bootstrap DateTime Picker.", type: "any" } } }) },
getOptionsForOptions: function() {
return t.merge(this.base(), { fields: { dateFormat: { type: "text" }, picker: { type: "any" } } }) }
}), t.registerMessages({ invalidDate: "Invalid date for format {0}" }), t.registerFieldClass("date", t.Fields.DateField), t.registerDefaultFormatFieldMapping("date", "date")
}(jQuery),
function(e) {
var t = e.alpaca;
t.Fields.DatetimeField = t.Fields.DateField.extend({ getFieldType: function() {
return "datetime" }, getDefaultFormat: function() {
return t.defaultDateFormat + " " + t.defaultTimeFormat }, getDefaultExtraFormats: function() {
return [t.defaultDateFormat + " hh:mm:ss a", t.defaultDateFormat + " HH:mm", t.defaultDateFormat] }, setup: function() { this.base() }, getTitle: function() {
return "Datetime Field" }, getDescription: function() {
return "Datetime Field based on Bootstrap DateTime Picker." } }), t.registerFieldClass("datetime", t.Fields.DatetimeField), t.registerDefaultFormatFieldMapping("datetime", "datetime"), t.registerDefaultFormatFieldMapping("date-time", "datetime") }(jQuery),
function(e) {
var t = e.alpaca;
t.Fields.EditorField = t.Fields.TextField.extend({ getFieldType: function() {
return "editor" }, setup: function() {
var e = this;
this.base(), e.options.aceTheme || (e.options.aceTheme = "ace/theme/chrome"), e.options.aceMode || (e.options.aceMode = "ace/mode/json"), "undefined" == typeof e.options.beautify && (e.options.beautify = !0), e.options.beautify && this.data && ("ace/mode/json" === e.options.aceMode && (t.isObject(this.data) ? this.data = JSON.stringify(this.data, null, " ") : t.isString(this.data) && (this.data = JSON.stringify(JSON.parse(this.data), null, " "))), "ace/mode/html" === e.options.aceMode && "undefined" != typeof html_beautify && (this.data = html_beautify(this.data)), "ace/mode/css" === e.options.aceMode && "undefined" != typeof css_beautify && (this.data = css_beautify(this.data)), "ace/mode/javascript" === e.options.aceMode && "undefined" != typeof js_beautify && (this.data = js_beautify(this.data))), "ace/mode/json" === e.options.aceMode && (this.data && "{}" !== this.data || (this.data = "{\n \n}")) }, afterRenderControl: function(n, i) {
var a = this;
this.base(n, function() {
if (a.control) {
var n = a.options.aceHeight;
n && e(a.control).css("height", n);
var r = a.options.aceWidth;
r || (r = "100%"), e(a.control).css("width", r) }
var o = e(a.control)[0];
if (!ace && window.ace && (ace = window.ace), ace) { a.editor = ace.edit(o), a.editor.setOptions({ maxLines: 1 / 0 }), a.editor.getSession().setUseWrapMode(!0);
var l = a.options.aceTheme;
a.editor.setTheme(l);
var s = a.options.aceMode;
if (a.editor.getSession().setMode(s), a.editor.renderer.setHScrollBarAlwaysVisible(!1), a.editor.setShowPrintMargin(!1), a.editor.setValue(a.data), a.editor.clearSelection(), a.editor.getSession().getUndoManager().reset(), a.options.aceFitContentHeight) {
var u = function() {
var t = !1;
0 === a.editor.renderer.lineHeight && (t = !0, a.editor.renderer.lineHeight = 16);
var n = a.editor.getSession().getScreenLength() * a.editor.renderer.lineHeight + a.editor.renderer.scrollBar.getWidth();
e(a.control).height(n.toString() + "px"), a.editor.resize(), t && window.setTimeout(function() { a.editor.clearSelection() }, 100) };
u(), a.editor.getSession().on("change", u) }
a.schema.readonly && a.editor.setReadOnly(!0), e(o).bind("destroyed", function() { a.editor && (a.editor.destroy(), a.editor = null) }) } else t.logError("Editor Field is missing the 'ace' Cloud 9 Editor");
i() }) }, destroy: function() { this.editor && (this.editor.destroy(), this.editor = null), this.base() }, getEditor: function() {
return this.editor }, handleValidate: function() {
var e = this.base(),
n = this.validation,
i = this._validateWordCount();
n.wordLimitExceeded = { message: i ? "" : t.substituteTokens(this.getMessage("wordLimitExceeded"), [this.options.wordlimit]), status: i };
var a = this._validateEditorAnnotations();
return n.editorAnnotationsExist = { message: a ? "" : this.getMessage("editorAnnotationsExist"), status: a }, e && n.wordLimitExceeded.status && n.editorAnnotationsExist.status }, _validateEditorAnnotations: function() {
if (this.editor) {
var e = this.editor.getSession().getAnnotations();
if (e && e.length > 0) return !1 }
return !0 }, _validateWordCount: function() {
if (this.options.wordlimit && this.options.wordlimit > -1) {
var e = this.editor.getValue();
if (e) {
var t = e.split(" ").length;
if (t > this.options.wordlimit) return !1 } }
return !0 }, onDependentReveal: function() { this.editor && this.editor.resize() }, setValue: function(e) {
var n = this;
this.editor && ("object" == n.schema.type && t.isObject(e) && (e = JSON.stringify(e, null, " ")), this.editor.setValue(e), n.editor.clearSelection()), this.base(e) }, getControlValue: function() {
var e = null;
return this.editor && (e = this.editor.getValue()), "object" == this.schema.type && (e = e ? JSON.parse(e) : {}), e }, getTitle: function() {
return "Editor" }, getDescription: function() {
return "Editor" }, getSchemaOfOptions: function() {
return t.merge(this.base(), { properties: { aceTheme: { title: "ACE Editor Theme", description: "Specifies the theme to set onto the editor instance", type: "string", "default": "ace/theme/twilight" }, aceMode: { title: "ACE Editor Mode", description: "Specifies the mode to set onto the editor instance", type: "string", "default": "ace/mode/javascript" }, aceWidth: { title: "ACE Editor Height", description: "Specifies the width of the wrapping div around the editor", type: "string", "default": "100%" }, aceHeight: { title: "ACE Editor Height", description: "Specifies the height of the wrapping div around the editor", type: "string", "default": "300px" }, aceFitContentHeight: { title: "ACE Fit Content Height", description: "Configures the ACE Editor to auto-fit its height to the contents of the editor", type: "boolean", "default": !1 }, wordlimit: { title: "Word Limit", description: "Limits the number of words allowed in the text area.", type: "number", "default": -1 } } }) }, getOptionsForOptions: function() {
return t.merge(this.base(), { fields: { aceTheme: { type: "text" }, aceMode: { type: "text" }, wordlimit: { type: "integer" } } }) } }), t.registerMessages({ wordLimitExceeded: "The maximum word limit of {0} has been exceeded.", editorAnnotationsExist: "The editor has errors in it that must be corrected" }), t.registerFieldClass("editor", t.Fields.EditorField) }(jQuery),
function(e) {
var t = e.alpaca;
t.Fields.EmailField = t.Fields.TextField.extend({ getFieldType: function() {
return "email" }, setup: function() { this.inputType = "email", this.base(), this.schema.pattern || (this.schema.pattern = t.regexps.email) }, handleValidate: function() {
var e = this.base(),
t = this.validation;
return t.invalidPattern.status || (t.invalidPattern.message = this.getMessage("invalidEmail")), e }, getTitle: function() {
return "Email Field" }, getDescription: function() {
return "Email Field." }, getSchemaOfSchema: function() {
var e = this.schema && this.schema.pattern ? this.schema.pattern : t.regexps.email;
return t.merge(this.base(), { properties: { pattern: { title: "Pattern", description: "Field Pattern in Regular Expression", type: "string", "default": e, "enum": [e], readonly: !0 }, format: { title: "Format", description: "Property data format", type: "string", "default": "email", "enum": ["email"], readonly: !0 } } }) }, getOptionsForSchema: function() {
return t.merge(this.base(), { fields: { format: { type: "text" } } }) } }), t.registerMessages({ invalidEmail: "Invalid Email address e.g. info@cloudcms.com" }), t.registerFieldClass("email", t.Fields.EmailField), t.registerDefaultFormatFieldMapping("email", "email") }(jQuery),
function(e) {
var t = e.alpaca;
t.Fields.GridField = t.Fields.ArrayField.extend({ getFieldType: function() {
return "grid" }, setup: function() { this.base(), "undefined" == typeof this.options.grid && (this.options.grid = {}) }, afterRenderContainer: function(t, n) {
var i = this;
this.base(t, function() {
var t = [],
a = [];
for (var r in i.options.fields) {
var o = i.options.fields[r],
l = r;
o.label && (l = o.label), a.push(l) }
t.push(a);
for (var s = 0; s < i.data.length; s++) {
var u = [];
for (var c in i.data[s]) u.push(i.data[s][c]);
t.push(u) }
var d = e(i.container).find(".alpaca-container-grid-holder"),
p = i.options.grid;
p.data = t, e(d).handsontable(p), n() }) }, getType: function() {
return "array" }, getTitle: function() {
return "Grid Field" }, getDescription: function() {
return "Renders array items into a grid" } }), t.registerFieldClass("grid", t.Fields.GridField) }(jQuery),
function(e) {
var t = e.alpaca;
t.Fields.ImageField = t.Fields.TextField.extend({ getFieldType: function() {
return "image" }, getTitle: function() {
return "Image Field" }, getDescription: function() {
return "Image Field." } }), t.registerFieldClass("image", t.Fields.ImageField) }(jQuery),
function(e) {
var t = e.alpaca;
t.Fields.IntegerField = t.Fields.NumberField.extend({ getFieldType: function() {
return "integer" }, getControlValue: function() {
var e = this.base();
return "undefined" == typeof e || "" == e ? e : parseInt(e, 10) }, onChange: function(e) { this.base(), this.slider && this.slider.slider("value", this.getValue()) }, postRender: function(n) {
var i = this;
this.base(function() { i.options.slider && (t.isEmpty(i.schema.maximum) || t.isEmpty(i.schema.minimum) || i.control && (i.control.after(''), i.slider = e("#slider", i.control.parent()).slider({ value: i.getValue(), min: i.schema.minimum, max: i.schema.maximum, slide: function(e, t) { i.setValue(t.value), i.refreshValidationState() } }))), n() }) }, handleValidate: function() {
var e = this.base(),
t = this.validation,
n = this._validateInteger();
return t.stringNotANumber = { message: n ? "" : this.getMessage("stringNotAnInteger"), status: n }, e }, _validateInteger: function() {
var e = this._getControlVal();
if ("number" == typeof e && (e = "" + e), t.isValEmpty(e)) return !0;
var n = t.testRegex(t.regexps.integer, e);
if (!n) return !1;
var i = this.getValue();
return !isNaN(i) }, getType: function() {
return "integer" }, getTitle: function() {
return "Integer Field" }, getDescription: function() {
return "Field for integers." }, getSchemaOfSchema: function() {
return t.merge(this.base(), { properties: { minimum: { title: "Minimum", description: "Minimum value of the property.", type: "integer" }, maximum: { title: "Maximum", description: "Maximum value of the property.", type: "integer" }, divisibleBy: { title: "Divisible By", description: "Property value must be divisible by this number.", type: "integer" } } }) }, getOptionsForSchema: function() {
return t.merge(this.base(), { fields: { minimum: { helper: "Minimum value of the field.", type: "integer" }, maximum: { helper: "Maximum value of the field.", type: "integer" }, divisibleBy: { helper: "Property value must be divisible by this number.", type: "integer" } } }) }, getSchemaOfOptions: function() {
return t.merge(this.base(), { properties: { slider: { title: "Slider", description: "Generate jQuery UI slider control with the field if true.", type: "boolean", "default": !1 } } }) }, getOptionsForOptions: function() {
return t.merge(this.base(), { fields: { slider: { rightLabel: "Slider control ?", helper: "Generate slider control if selected.", type: "checkbox" } } }) } }), t.registerMessages({ stringNotAnInteger: "This value is not an integer." }), t.registerFieldClass("integer", t.Fields.IntegerField), t.registerDefaultSchemaFieldMapping("integer", "integer") }(jQuery),
function(e) {
var t = e.alpaca;
t.Fields.IPv4Field = t.Fields.TextField.extend({ getFieldType: function() {
return "ipv4" }, setup: function() { this.base(), this.schema.pattern || (this.schema.pattern = t.regexps.ipv4) }, handleValidate: function() {
var e = this.base(),
t = this.validation;
return t.invalidPattern.status || (t.invalidPattern.message = this.getMessage("invalidIPv4")), e }, getTitle: function() {
return "IP Address Field" }, getDescription: function() {
return "IP Address Field." }, getSchemaOfSchema: function() {
var e = this.schema && this.schema.pattern ? this.schema.pattern : t.regexps.ipv4;
return t.merge(this.base(), { properties: { pattern: { title: "Pattern", description: "Field Pattern in Regular Expression", type: "string", "default": e, readonly: !0 }, format: { title: "Format", description: "Property data format", type: "string", "enum": ["ip-address"], "default": "ip-address", readonly: !0 } } }) }, getOptionsForSchema: function() {
return t.merge(this.base(), { fields: { format: { type: "text" } } }) } }), t.registerMessages({ invalidIPv4: "Invalid IPv4 address, e.g. 192.168.0.1" }), t.registerFieldClass("ipv4", t.Fields.IPv4Field), t.registerDefaultFormatFieldMapping("ip-address", "ipv4") }(jQuery),
function(e) {
function t(e) {
if ("string" == typeof e.data) {
var t = e.handler,
n = e.data.toLowerCase().split(" ");
e.handler = function(e) {
if (this === e.target || !/textarea|select/i.test(e.target.nodeName) && "text" !== e.target.type) {
var i = "keypress" !== e.type && jQuery.hotkeys.specialKeys[e.which],
a = String.fromCharCode(e.which).toLowerCase(),
r = "",
o = {};
e.altKey && "alt" !== i && (r += "alt+"), e.ctrlKey && "ctrl" !== i && (r += "ctrl+"), e.metaKey && !e.ctrlKey && "meta" !== i && (r += "meta+"), e.shiftKey && "shift" !== i && (r += "shift+"), i ? o[r + i] = !0 : (o[r + a] = !0, o[r + jQuery.hotkeys.shiftNums[a]] = !0, "shift+" === r && (o[jQuery.hotkeys.shiftNums[a]] = !0));
for (var l = 0, s = n.length; s > l; l++)
if (o[n[l]]) return t.apply(this, arguments) } } } }
var n = e.alpaca;
n.Fields.JSONField = n.Fields.TextAreaField.extend({ getFieldType: function() {
return "json" }, setValue: function(e) {
(n.isObject(e) || "object" == typeof e) && (e = JSON.stringify(e, null, 3)), this.base(e) }, getControlValue: function() {
var e = this.base();
return e && n.isString(e) && (e = JSON.parse(e)), e }, handleValidate: function() {
var e = this.base(),
t = this.validation,
n = this._validateJSON();
return t.stringNotAJSON = { message: n.status ? "" : this.getMessage("stringNotAJSON") + " " + n.message, status: n.status }, e && t.stringNotAJSON.status }, _validateJSON: function() {
var e = this.control.val();
if (n.isValEmpty(e)) return { status: !0 };
try {
var t = JSON.parse(e);
return this.setValue(JSON.stringify(t, null, 3)), { status: !0 } } catch (i) {
return { status: !1, message: i.message } } }, afterRenderControl: function(e, t) {
var n = this;
this.base(e, function() { n.control && (n.control.bind("keypress", function(e) {
var t = e.keyCode || e.wich;
34 === t && n.control.insertAtCaret('"'), 123 === t && n.control.insertAtCaret("}"), 91 === t && n.control.insertAtCaret("]") }), n.control.bind("keypress", "Ctrl+l", function() { n.getFieldEl().removeClass("alpaca-field-focused"), n.refreshValidationState() }), n.control.attr("title", "Type Ctrl+L to format and validate the JSON string.")), t() }) }, getTitle: function() {
return "JSON Editor" }, getDescription: function() {
return "Editor for JSON objects with basic validation and formatting." } }), n.registerMessages({ stringNotAJSON: "This value is not a valid JSON string." }), n.registerFieldClass("json", n.Fields.JSONField), e.fn.insertAtCaret = function(e) {
return this.each(function() {
if (document.selection) this.focus(), sel = document.selection.createRange(), sel.text = e, this.focus();
else if (this.selectionStart || "0" == this.selectionStart) {
var t = this.selectionStart,
n = this.selectionEnd,
i = this.scrollTop;
this.value = this.value.substring(0, t) + e + this.value.substring(n, this.value.length), this.focus(), this.selectionStart = t, this.selectionEnd = t, this.scrollTop = i } else this.value += e, this.focus() }) }, jQuery.hotkeys = { version: "0.8", specialKeys: { 8: "backspace", 9: "tab", 13: "return", 16: "shift", 17: "ctrl", 18: "alt", 19: "pause", 20: "capslock", 27: "esc", 32: "space", 33: "pageup", 34: "pagedown", 35: "end", 36: "home", 37: "left", 38: "up", 39: "right", 40: "down", 45: "insert", 46: "del", 96: "0", 97: "1", 98: "2", 99: "3", 100: "4", 101: "5", 102: "6", 103: "7", 104: "8", 105: "9", 106: "*", 107: "+", 109: "-", 110: ".", 111: "/", 112: "f1", 113: "f2", 114: "f3", 115: "f4", 116: "f5", 117: "f6", 118: "f7", 119: "f8", 120: "f9", 121: "f10", 122: "f11", 123: "f12", 144: "numlock", 145: "scroll", 191: "/", 224: "meta" }, shiftNums: { "`": "~", 1: "!", 2: "@", 3: "#", 4: "$", 5: "%", 6: "^", 7: "&", 8: "*", 9: "(", 0: ")", "-": "_", "=": "+", ";": ": ", "'": '"', ",": "<", ".": ">", "/": "?", "\\": "|" } }, jQuery.each(["keydown", "keyup", "keypress"], function() { jQuery.event.special[this] = { add: t } }) }(jQuery),
function(e) {
var t = e.alpaca;
t.Fields.LowerCaseField = t.Fields.TextField.extend({ getFieldType: function() {
return "lowercase" }, setup: function() { this.base(), this.data && (this.data = this.data.toLowerCase()) }, setValue: function(e) {
if (!e) return this.base(e);
var t = e.toLowerCase();
t != this.getValue() && this.base(t) }, onKeyPress: function(e) { this.base(e);
var n = this;
t.later(25, this, function() {
var e = n.getValue();
n.setValue(e) }) }, getTitle: function() {
return "Lowercase Text" }, getDescription: function() {
return "Text field for lowercase text." } }), t.registerFieldClass("lowercase", t.Fields.LowerCaseField), t.registerDefaultFormatFieldMapping("lowercase", "lowercase") }(jQuery),
function(e) {
var t = e.alpaca;
t.Fields.MapField = t.Fields.ArrayField.extend({ getFieldType: function() {
return "map" }, getType: function() {
return "object" }, setup: function() {
if (this.data && t.isObject(this.data)) {
var n = [];
e.each(this.data, function(e, i) {
var a = t.copyOf(i);
a._key = e, n.push(a) }), this.data = n }
this.base(), t.mergeObject(this.options, { forceRevalidation: !0 }), t.isEmpty(this.data) }, getContainerValue: function() {
if (0 !== this.children.length || this.isRequired()) {
for (var e = {}, t = 0; t < this.children.length; t++) {
var n = this.children[t].getValue(),
i = n._key;
i && (delete n._key, e[i] = n) }
return e } }, handleValidate: function() {
var e = this.base(),
t = this.validation,
n = this._validateMapKeysNotEmpty();
t.keyMissing = { message: n ? "" : this.getMessage("keyMissing"), status: n };
var i = this._validateMapKeysUnique();
return t.keyNotUnique = { message: i ? "" : this.getMessage("keyNotUnique"), status: i }, e && t.keyMissing.status && t.keyNotUnique.status }, _validateMapKeysNotEmpty: function() {
for (var e = !0, t = 0; t < this.children.length; t++) {
var n = this.children[t].getValue(),
i = n._key;
if (!i) { e = !1;
break } }
return e }, _validateMapKeysUnique: function() {
for (var e = !0, t = {}, n = 0; n < this.children.length; n++) {
var i = this.children[n].getValue(),
a = i._key;
t[a] && (e = !1), t[a] = a }
return e }, getTitle: function() {
return "Map Field" }, getDescription: function() {
return "Field for objects with key/value pairs that share the same schema for values." } }), t.registerFieldClass("map", t.Fields.MapField), t.registerMessages({ keyNotUnique: "Keys of map field are not unique.", keyMissing: "Map contains an empty key." }) }(jQuery),
function(e) {
var t = e.alpaca;
t.Fields.OptionTreeField = t.Fields.TextField.extend({ getFieldType: function() {
return "optiontree" }, setup: function() {
var e = this;
this.base(), this.options.tree || (this.options.tree = {}), this.options.tree.selectors || (this.options.tree.selectors = {}), this.options.tree.order || (this.options.tree.order = []);
for (var n in this.options.tree.selectors) {
if (!this.options.tree.selectors[n].schema) return void t.logError("OptionTree selector for: " + n + " is missing schema");
this.options.tree.selectors[n].options || (this.options.tree.selectors[n].options = {}) }
this.options.tree.data || (this.options.tree.data = []);
for (var i = 0; i < this.options.tree.data.length; i++) {
var a = this.options.tree.data[i];
if (a.attributes)
for (var n in a.attributes) this.options.tree.selectors[n] || (this.options.tree.selectors[n] = {}), this.options.tree.selectors[n].label || (this.options.tree.selectors[n].options.noneLabel = "Choose..."), this.options.tree.selectors[n].type || (this.options.tree.selectors[n].options.type = "select") }
if (!e.options.tree.order) { e.options.tree.order = [];
for (var n in e.options.tree.selectors) e.options.tree.order.push(e.options.tree.selectors[n]) } "undefined" == typeof e.options.tree.horizontal && (e.options.tree.horizontal = !0), this.locationValueLists = {}, this.locationValues = {};
for (var i = 0; i < e.options.tree.data.length; i++)
if (e.options.tree.data[i].attributes) {
var r = "root";
for (var n in e.options.tree.data[i].attributes) {
var o = e.options.tree.data[i].attributes[n],
l = this.locationValueLists[r];
l || (l = [], this.locationValueLists[r] = l);
for (var s = !1, u = 0; u < l.length; u++)
if (l[u].value === o) { s = !0;
break }
s || l.push({ text: o, value: o }), r.length > 0 && (r += "~"), r += n + "=" + o }
this.locationValues[r] = e.options.tree.data[i].value }
this.currentAttributes = {}, this.controls = {} }, toLocation: function(e) {
var t = "root";
for (var n in e) {
var i = e[n];
t.length > 0 && (t += "~"), t += n + "=" + i }
return t }, existsLocationWithPrefix: function(e) {
var t = !1;
for (var n in this.locationValueLists)
if (n.indexOf(e) > -1) { t = !0;
break }
return t }, afterRenderControl: function(t, n) {
var i = this;
i.optionTreeHolder = e(i.field).find(".optiontree"), i.options.tree.horizontal && e(i.field).addClass("optiontree-horizontal"), this.base(t, function() { i.refreshOptionTreeControls(function() { n() }) }) }, refreshOptionTreeControls: function(n) {
var i = this;
for (var a in i.controls) i.controls[a].hide();
for (var r = 0, o = 0; o < i.options.tree.order.length; o++) {
var l = i.options.tree.order[o]; "undefined" != typeof i.currentAttributes[l] && null !== i.currentAttributes[l] && "" !== i.currentAttributes[l] && r++ }
var s = "root",
u = [],
c = 0,
o = 0;
do {
if (o < i.options.tree.order.length) {
var l = i.options.tree.order[o],
d = o == i.options.tree.order.length - 1 || i.existsLocationWithPrefix(s + "~" + l + "=");
if (d)
if (r >= c) {
if (i.controls[l]) i.controls[l].show(), s += "~" + l + "=" + i.currentAttributes[l];
else {
var p = i.options.tree.selectors[l],
h = o + 1 === i.options.tree.order.length,
f = function(t, n, a, r, o, l) {
return function(s) {
var u = a.schema,
c = a.options;
c || (c = {}), c.type || (c.type = "select"), "select" === c.type && (c.dataSource = function(e) {
var t = i.toLocation(i.currentAttributes),
n = i.locationValueLists[t];
e(n) });
var d = e("");
e(d).alpaca({ schema: u, options: c, postRender: function(a) { r[n] = a, e(o).append(d), a.selectorId = n, a.on("change", function() {
var e = this.selectorId;
i.currentAttributes[e] = this.getValue();
for (var n = 0; n < i.options.tree.order.length; n++)
if (n > t) {
var e = i.options.tree.order[n];
delete i.currentAttributes[e], r[e] && (r[e].destroy(), delete r[e]) }
if (l) {
for (var a = null, n = 0; n < i.options.tree.data.length; n++) {
var o = !0,
s = i.options.tree.data[n].attributes;
for (var u in i.currentAttributes)
if (s[u] !== i.currentAttributes[u]) { o = !1;
break }
o && (a = i.options.tree.data[n].value) }
a && i.setValue(a) }
i.refreshOptionTreeControls() }), a.show(), s() } }) } }(o, l, p, i.controls, i.optionTreeHolder, h);
u.push(f), s += "~" + l + "=" + i.currentAttributes[l] }
c++ } else i.controls[l] && (i.controls[l].destroy(), delete i.controls[l]);
else i.controls[l] && (i.controls[l].destroy(), delete i.controls[l]) }
o++ } while (o < i.options.tree.order.length);
t.series(u, function() { n && n() }) }, getType: function() {
return "any" }, getTitle: function() {
return "Option Tree" }, getDescription: function() {
return "Option Tree" }, getSchemaOfOptions: function() {
return t.merge(this.base(), { properties: { tree: { type: "object", properties: { options: { type: "object" }, order: { type: "array", items: { type: "string" } }, data: { type: "array", items: { type: "object", properties: { value: { type: "any" }, attributes: { type: "object" } } } }, horizontal: { type: "boolean" } } } } }) }, getOptionsForOptions: function() {
return t.merge(this.base(), { fields: {} }) } }), t.registerFieldClass("optiontree", t.Fields.OptionTreeField) }(jQuery),
function(e) {
var t = e.alpaca;
t.Fields.PasswordField = t.Fields.TextField.extend({ getFieldType: function() {
return "password" }, setup: function() { this.base(), this.schema.pattern || (this.schema.pattern = t.regexps.password) }, handleValidate: function() {
var e = this.base(),
t = this.validation;
return t.invalidPattern.status || (t.invalidPattern.message = this.getMessage("invalidPassword")), e }, getTitle: function() {
return "Password Field" }, getDescription: function() {
return "Password Field." }, getSchemaOfSchema: function() {
var e = this.schema && this.schema.pattern ? this.schema.pattern : /^[0-9a-zA-Z\x20-\x7E]*$/;
return t.merge(this.base(), { properties: { pattern: { title: "Pattern", description: "Field Pattern in Regular Expression", type: "string", "default": this.schema.pattern, "enum": [e], readonly: !0 }, format: { title: "Format", description: "Property data format", type: "string", "default": "password", "enum": ["password"], readonly: !0 } } }) }, getOptionsForSchema: function() {
return t.merge(this.base(), { fields: { format: { type: "text" } } }) } }), t.registerMessages({ invalidPassword: "Invalid Password" }), t.registerFieldClass("password", t.Fields.PasswordField), t.registerDefaultFormatFieldMapping("password", "password") }(jQuery),
function(e) {
var t = e.alpaca;
t.Fields.PersonalNameField = t.Fields.TextField.extend({ getFieldType: function() {
return "personalname" }, setValue: function(e) {
if (!e) return this.base(e);
for (var t = "", n = 0; n < e.length; n++) t += 0 === n ? e.charAt(n).toUpperCase() : " " === e.charAt(n - 1) || "-" === e.charAt(n - 1) || "'" === e.charAt(n - 1) ? e.charAt(n).toUpperCase() : e.charAt(n);
t != this.getValue() && this.base(t) }, onKeyPress: function(e) { this.base(e);
var n = this;
t.later(25, this, function() {
var e = n.getValue();
n.setValue(e) }) }, getTitle: function() {
return "Personal Name" }, getDescription: function() {
return "Text Field for personal name with captical letter for first letter & after hyphen, space or apostrophe." } }), t.registerFieldClass("personalname", t.Fields.PersonalNameField) }(jQuery),
function(e) {
var t = e.alpaca;
t.Fields.PhoneField = t.Fields.TextField.extend({ setup: function() { this.inputType = "tel", this.base(), this.schema.pattern || (this.schema.pattern = t.regexps.phone), t.isEmpty(this.options.maskString) && (this.options.maskString = "(999) 999-9999") }, postRender: function(e) { this.base(function() { e() }) }, handleValidate: function() {
var e = this.base(),
t = this.validation;
return t.invalidPattern.status || (t.invalidPattern.message = this.getMessage("invalidPhone")), e }, getFieldType: function() {
return "phone" }, getTitle: function() {
return "Phone Field" }, getDescription: function() {
return "Phone Field." }, getSchemaOfSchema: function() {
var e = this.schema && this.schema.pattern ? this.schema.pattern : t.regexps.phone;
return t.merge(this.base(), { properties: { pattern: { title: "Pattern", description: "Field Pattern in Regular Expression", type: "string", "default": e, "enum": [e], readonly: !0 }, format: { title: "Format", description: "Property data format", type: "string", "default": "phone", "enum": ["phone"], readonly: !0 } } }) }, getOptionsForSchema: function() {
return t.merge(this.base(), { fields: { format: { type: "text" } } }) }, getSchemaOfOptions: function() {
return t.merge(this.base(), { properties: { maskString: { title: "Field Mask String", description: "Expression for field mask", type: "string", "default": "(999) 999-9999" } } }) } }), t.registerMessages({ invalidPhone: "Invalid Phone Number, e.g. (123) 456-9999" }), t.registerFieldClass("phone", t.Fields.PhoneField), t.registerDefaultFormatFieldMapping("phone", "phone") }(jQuery),
function(e) {
var t = e.alpaca;
t.Fields.PickAColorField = t.Fields.TextField.extend({ setup: function() {
var t = this;
this.pickAColorFieldAvailable = !1, t.isDisplayOnly() || "undefined" == typeof e.fn.pickAColor || (this.pickAColorFieldAvailable = !0), "undefined" != typeof this.options.pickacolor || t.pickAColorFieldAvailable || (this.inputType = "color"), this.base(), "undefined" == typeof this.options.pickacolor && (this.options.pickacolor = { showSpectrum: !0, showSavedColors: !0, saveColorsPerElement: !1, fadeMenuToggle: !0, showAdvanced: !0, showBasicColors: !0, showHexInput: !0, allowBlank: !0, inlineDropdown: !1 }), "undefined" == typeof this.options.colors && (this.options.colors = { white: "#ffffff", clouds: "#ecf0f1", red: "#c0392b", orange: "#e67e22", yellow: "#f1c40f", green: "#27ae60", blue: "#2980b9", purple: "#8e44ad", dark: "#34495e", black: "#000000", brown: "#bb9977" }), this.options.pickacolor && "undefined" == typeof this.options.pickacolor.basicColors && (this.options.pickacolor.basicColors = this.options.colors), "undefined" == typeof this.options.pickacolor.inlineDropdown && (this.options.pickacolor.inlineDropdown = !1) }, getFieldType: function() {
return "pickacolor" }, getType: function() {
return "string" }, afterRenderControl: function(t, n) {
var i = this;
this.base(t, function() { i.control && i.pickAColorFieldAvailable && i.options.pickacolor && (i.data && e(i.control).attr("value", i.data), e(i.control).addClass("pick-a-color"), e(i.control).pickAColor(i.options.pickacolor), e(i.control).on("change", function(t) { i.setValue(e(this).val()) })), n() }) }, getTitle: function() {
return "Pick-A-Color Field" }, getDescription: function() {
return "A color picker for selecting hexadecimal color values" } }), t.registerFieldClass("pickacolor", t.Fields.PickAColorField) }(jQuery),
function(e) {
var t = e.alpaca;
t.Fields.SearchField = t.Fields.TextField.extend({ setup: function() { this.inputType = "search", this.base(), this.options.attributes.results = 5 }, getFieldType: function() {
return "search" }, getType: function() {
return "string" }, getTitle: function() {
return "Search Field" }, getDescription: function() {
return "A search box field" } }), t.registerFieldClass("search", t.Fields.SearchField), t.registerDefaultSchemaFieldMapping("search", "search") }(jQuery),
function(e) {
var t = e.alpaca;
t.usHoldings = {}, t.usHoldings.territories = { "American Samoa": "AS", "District Of Columbia": "DC", "Federated States Of Micronesia": "FM", Guam: "GU", "Marshall Islands": "MH", "Northern Mariana Islands": "MP", Palau: "PW", "Puerto Rico": "PR", "Virgin Islands": "VI" }, t.usHoldings.states = { Alabama: "AL", Alaska: "AK", Arizona: "AZ", Arkansas: "AR", California: "CA", Colorado: "CO", Connecticut: "CT", Delaware: "DE", Florida: "FL", Georgia: "GA", Hawaii: "HI", Idaho: "ID", Illinois: "IL", Indiana: "IN", Iowa: "IA", Kansas: "KS", Kentucky: "KY", Louisiana: "LA", Maine: "ME", Maryland: "MD", Massachusetts: "MA", Michigan: "MI", Minnesota: "MN", Mississippi: "MS", Missouri: "MO", Montana: "MT", Nebraska: "NE", Nevada: "NV", "New Hampshire": "NH", "New Jersey": "NJ", "New Mexico": "NM", "New York": "NY", "North Carolina": "NC", "North Dakota": "ND", Ohio: "OH", Oklahoma: "OK", Oregon: "OR", Pennsylvania: "PA", "Rhode Island": "RI", "South Carolina": "SC", "South Dakota": "SD", Tennessee: "TN", Texas: "TX", Utah: "UT", Vermont: "VT", Virginia: "VA", Washington: "WA", "West Virginia": "WV", Wisconsin: "WI", Wyoming: "WY" }, t.Fields.StateField = t.Fields.SelectField.extend({
getFieldType: function() {
return "state" },
setup: function() { t.isUndefined(this.options.capitalize) && (this.options.capitalize = !1), t.isUndefined(this.options.includeStates) && (this.options.includeStates = !0), t.isUndefined(this.options.includeTerritories) && (this.options.includeTerritories = !0), t.isUndefined(this.options.format) && (this.options.format = "name"), "name" === this.options.format || "code" === this.options.format || (t.logError("The configured state format: " + this.options.format + " is not a legal value [name, code]"), this.options.format = "name");
var e = t.retrieveUSHoldings(this.options.includeStates, this.options.includeTerritories, "code" === this.options.format, this.options.capitalize);
this.schema["enum"] = e.keys, this.options.optionLabels = e.values, this.base() },
getTitle: function() {
return "State Field" },
getDescription: function() {
return "Provides a dropdown selector of states and/or territories in the United States, keyed by their two-character code." },
getSchemaOfOptions: function() {
return t.merge(this.base(), {
properties: { format: { title: "Format", description: "How to represent the state values in the selector", type: "string", "default": "name", "enum": ["name", "code"], readonly: !0 }, capitalize: { title: "Capitalize", description: "Whether the values should be capitalized", type: "boolean", "default": !1, readonly: !0 }, includeStates: { title: "Include States", description: "Whether to include the states of the United States", type: "boolean", "default": !0, readonly: !0 }, includeTerritories: { title: "Include Territories", description: "Whether to include the territories of the United States", type: "boolean", "default": !0, readonly: !0 } }
})
},
getOptionsForOptions: function() {
return t.merge(this.base(), { fields: { format: { type: "text" }, capitalize: { type: "checkbox" }, includeStates: { type: "checkbox" }, includeTerritories: { type: "checkbox" } } }) }
}), t.registerFieldClass("state", t.Fields.StateField), t.registerDefaultFormatFieldMapping("state", "state"), t.retrieveUSHoldings = function() {
return function(n, i, a, r) {
var o = { keys: [], values: [] },
l = e.extend({}, n ? t.usHoldings.states : {}, i ? t.usHoldings.territories : {}),
s = Object.keys(l);
s.sort();
for (var u in s) {
var c = s[u],
d = l[c],
p = a ? d : c;
r && (p = p.toUpperCase()), o.keys.push(d), o.values.push(p) }
return o } }()
}(jQuery),
function(e) {
var t = e.alpaca;
t.Fields.SummernoteField = t.Fields.TextAreaField.extend({ getFieldType: function() {
return "summernote" }, setup: function() { this.data || (this.data = ""), this.base(), "undefined" == typeof this.options.summernote && (this.options.summernote = { height: null, minHeight: null, maxHeight: null, focus: !0 }) }, afterRenderControl: function(t, n) {
var i = this;
this.base(t, function() {!i.isDisplayOnly() && i.control && e.fn.summernote && i.on("ready", function() { e(i.control).summernote(i.options.summernote) }), e(i.control).bind("destroyed", function() {
try { e(i.control).summernote("destroy") } catch (t) {} }), n() }) }, getTitle: function() {
return "Summernote Editor" }, getDescription: function() {
return "Provides an instance of a Summernote Editor control for use in editing HTML." }, getSchemaOfOptions: function() {
return t.merge(this.base(), { properties: { summernote: { title: "Summernote Editor options", description: "Use this entry to provide configuration options to the underlying Summernote plugin.", type: "any" } } }) }, getOptionsForOptions: function() {
return t.merge(this.base(), { fields: { summernote: { type: "any" } } }) } }), t.registerFieldClass("summernote", t.Fields.SummernoteField) }(jQuery),
function(e) {
var t = e.alpaca;
t.Fields.TableField = t.Fields.ArrayField.extend({ setup: function() {
var n = this;
n.options || (n.options = {}), "undefined" == typeof n.options.animate && (n.options.animate = !1), "undefined" == typeof this.options.toolbarSticky && (this.options.toolbarSticky = !0), this.base(), this.options.items.type || (this.options.items.type = "tablerow"), this.options.datatable && (this.options.datatables = this.options.datatable), "undefined" == typeof this.options.datatables && (this.options.datatables = { paging: !1, lengthChange: !1, info: !1, searching: !1, ordering: !0 }, "undefined" == typeof this.options.dragRows && (this.options.dragRows = !1), this.options.readonly && (this.options.dragRows = !1), this.isDisplayOnly() && (this.options.dragRows = !1)), "undefined" == typeof this.options.showActionsColumn && (this.options.showActionsColumn = !0, this.options.readonly && (this.options.showActionsColumn = !1), this.isDisplayOnly() && (this.options.showActionsColumn = !1)), this.options.datatables.columns = [], e.fn.dataTableExt && !e.fn.DataTable.ext.type.search.alpaca && (e.fn.DataTable.ext.order.alpaca = function(e, t) { n.data = n.getValue();
var i = null,
a = 0;
for (var r in n.schema.items.properties) {
if (a === t) { i = r;
break }
a++ }
var o = [];
if (n.data)
for (var l = 0; l < n.data.length; l++) o.push(n.data[l][i]);
return o.sort(), o }, e.fn.dataTableExt.afnFiltering.push(function(n, i, a, r, o) {
var l = e(n.nTableWrapper).find(".dataTables_filter input[type='search']").val();
if (!l) return !0;
l = "" + l, l = e.trim(l), l = l.toLowerCase();
for (var s = !1, u = 0; u < r.length; u++) {
var c = r[u];
if (c) {
var d = c.indexOf("data-alpaca-field-id=");
if (d > -1) {
var p = e(c).attr("data-alpaca-field-id"),
h = t.fieldInstances[p].getValue();
if (h && (h = "" + h, h = h.toLowerCase(), h.indexOf(l) > -1)) { s = !0;
break } } } }
return s })) }, getFieldType: function() {
return "table" }, prepareContainerModel: function(e) {
var t = this;
t.base(function(n) {
if (n.headers = [], t.schema.items && t.schema.items.properties)
for (var i in t.schema.items.properties) {
var a = {};
a.id = i, a.title = t.schema.items.properties[i].title, a.hidden = !1, t.options.items && t.options.items.fields && t.options.items.fields[i] && (t.options.items.fields[i].label && (a.title = t.options.items.fields[i].label), "hidden" === t.options.items.fields[i].type && (a.hidden = !0)), n.headers.push(a) }
e(n) }) }, afterRenderContainer: function(t, n) {
var i = this;
this.base(t, function() { i.cleanupDomInjections();
var t = e(this.container).find("table");
if (i.applyStyle("table", t), i.options.datatables && e.fn.DataTable) { i.options.dragRows && (i.options.datatables.columns.push({ orderable: !1, name: "dragRowsIndex", hidden: !0 }), i.options.datatables.columns.push({ orderable: !1, name: "dragRowsDraggable" }));
for (var a in i.schema.items.properties) {
var r = { orderable: !0, orderDataType: "alpaca" };
i.options.datatables.columns.push(r) }
i.options.showActionsColumn && i.options.datatables.columns.push({ orderable: !1, name: "actions" }), i.options.dragRows && (i.options.datatables.rowReorder = { selector: "tr td.alpaca-table-reorder-draggable-cell", dataSrc: 0, snapX: !0, update: !0 }), i.off("ready"), i.on("ready", function() { i._dt && (i._dt.destroy(), i._dt = void 0);
var t = e(i.container).find("table");
i._dt = e(t).DataTable(i.options.datatables), i._dt.on("row-reorder", function(e, t, n) { i._dt._disableAlpacaHandlers || t.length > 0 && t[0].oldPosition !== t[0].newPosition && (i._dt._disableAlpacaHandlers = !0, i.moveItem(t[0].oldPosition, t[0].newPosition, !1, function() {})) }), e(i.container).bind("destroyed", function() { i._dt && (i._dt.destroy(), i._dt = void 0) }), i._dt.on("order", function(e, t, n, a) {
if (!i._dt._disableAlpacaHandlers) {
if (!i._dt._originalChildren) { i._dt._originalChildren = [];
for (var r = 0; r < i.children.length; r++) i._dt._originalChildren.push(i.children[r]) }
for (var o = [], l = 0; l < t.aiDisplay.length; l++) {
var s = t.aiDisplay[l];
o.push(i._dt._originalChildren[s]) }
i.children = o, i._dt._disableAlpacaHandlers = !1 } }) }) }
e(t).find("thead > tr > th[data-header-id]").each(function() {
var t = e(this).attr("data-header-id"),
n = i.schema.items.properties[t],
a = null;
i.options.items.fields && i.options.items.fields[t] && (a = i.options.items.fields[t]), n.required || a && a.required ? i.fireCallback("tableHeaderRequired", n, a, this) : i.fireCallback("tableHeaderOptional", n, a, this) }), n() }.bind(i)) }, cleanupDomInjections: function() {
var n = function(t) {
var n = e(t).parent(),
i = e(t).children(),
a = e(t).attr("class").split(/\s+/);
e.each(a, function(t, i) { "alpaca-merge-up" === i || e(n).addClass(i) }), e.each(e(t)[0].attributes, function() { this.name && 0 === this.name.indexOf("data-") && e(n).attr(this.name, this.value) }), i.length > 0 ? e(t).replaceWith(i) : e(t).remove() };
this.getFieldEl().find("tr > .alpaca-field").each(function() { n(this) }), this.getFieldEl().find("tr > .alpaca-container").each(function() { n(this) });
var i = this.getFieldEl().find("." + t.MARKER_CLASS_ARRAY_ITEM_ACTIONBAR);
i.length > 0 && i.each(function() {
var t = e("