luca 0.9.4 → 0.9.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. data/CHANGELOG +41 -1
  2. data/Gemfile +1 -0
  3. data/Gemfile.lock +2 -0
  4. data/README.md +5 -0
  5. data/Rakefile +4 -0
  6. data/assets/javascripts/dependencies/underscore-min.js +5 -31
  7. data/assets/javascripts/luca-templates.js +1 -0
  8. data/assets/javascripts/luca-ui-base.coffee +1 -1
  9. data/assets/javascripts/luca-ui-development-tools.coffee +1 -1
  10. data/assets/javascripts/luca-ui-full.js +1 -1
  11. data/assets/javascripts/luca-ui-spec.coffee +1 -1
  12. data/assets/javascripts/luca-ui.js +3 -0
  13. data/assets/javascripts/luca/index.coffee +1 -0
  14. data/lib/generators/luca/application/application_generator.rb +71 -0
  15. data/lib/generators/luca/application/templates/controller.rb +6 -0
  16. data/lib/generators/luca/application/templates/index.html.erb +7 -0
  17. data/lib/generators/luca/application/templates/index.html.haml +6 -0
  18. data/lib/generators/luca/application/templates/javascripts/application.js +28 -0
  19. data/lib/generators/luca/application/templates/javascripts/application.js.coffee +20 -0
  20. data/lib/generators/luca/application/templates/javascripts/config.js +15 -0
  21. data/lib/generators/luca/application/templates/javascripts/config.js.coffee +9 -0
  22. data/lib/generators/luca/application/templates/javascripts/dependencies.js +5 -0
  23. data/lib/generators/luca/application/templates/javascripts/dependencies.js.coffee +5 -0
  24. data/lib/generators/luca/application/templates/javascripts/index.js +9 -0
  25. data/lib/generators/luca/application/templates/javascripts/index.js.coffee +9 -0
  26. data/lib/generators/luca/application/templates/javascripts/main.js +8 -0
  27. data/lib/generators/luca/application/templates/javascripts/main.js.coffee +3 -0
  28. data/lib/generators/luca/application/templates/javascripts/main.jst.ejs +1 -0
  29. data/lib/generators/luca/application/templates/javascripts/router.js +12 -0
  30. data/lib/generators/luca/application/templates/javascripts/router.js.coffee +7 -0
  31. data/lib/luca/rails/version.rb +1 -1
  32. data/lib/luca/template.rb +1 -1
  33. data/spec/components/collection_view_spec.coffee +37 -0
  34. data/spec/components/multi_collection_view_spec.coffee +5 -0
  35. data/spec/components/table_view_spec.coffee +17 -0
  36. data/spec/core/container_spec.coffee +112 -5
  37. data/spec/core/model_spec.coffee +21 -3
  38. data/spec/define_spec.coffee +19 -0
  39. data/spec/mixin_spec.coffee +49 -0
  40. data/src/components/application.coffee +33 -19
  41. data/src/components/collection_view.coffee +109 -38
  42. data/src/components/fields/checkbox_field.coffee +2 -2
  43. data/src/components/fields/file_upload_field.coffee +0 -3
  44. data/src/components/fields/hidden_field.coffee +0 -3
  45. data/src/components/fields/label_field.coffee +1 -4
  46. data/src/components/fields/select_field.coffee +6 -6
  47. data/src/components/fields/text_area_field.coffee +1 -0
  48. data/src/components/fields/text_field.coffee +4 -0
  49. data/src/components/fields/type_ahead_field.coffee +5 -9
  50. data/src/components/form_view.coffee +2 -0
  51. data/src/components/index.coffee +1 -0
  52. data/src/components/multi_collection_view.coffee +94 -0
  53. data/src/components/pagination_control.coffee +100 -0
  54. data/src/components/table_view.coffee +62 -0
  55. data/src/containers/card_view.coffee +44 -11
  56. data/src/containers/panel_toolbar.coffee +88 -82
  57. data/src/containers/tab_view.coffee +3 -3
  58. data/src/containers/viewport.coffee +10 -4
  59. data/src/core/collection.coffee +11 -4
  60. data/src/core/container.coffee +189 -113
  61. data/src/core/field.coffee +13 -10
  62. data/src/core/model.coffee +23 -27
  63. data/src/core/registry.coffee +48 -35
  64. data/src/core/view.coffee +60 -140
  65. data/src/define.coffee +91 -19
  66. data/src/framework.coffee +10 -8
  67. data/src/index.coffee +23 -0
  68. data/src/managers/collection_manager.coffee +24 -8
  69. data/src/modules/application_event_bindings.coffee +19 -0
  70. data/src/modules/collection_event_bindings.coffee +26 -0
  71. data/src/modules/deferrable.coffee +3 -1
  72. data/src/modules/dom_helpers.coffee +49 -0
  73. data/src/modules/enhanced_properties.coffee +23 -0
  74. data/src/modules/filterable.coffee +60 -0
  75. data/src/modules/grid_layout.coffee +15 -0
  76. data/src/modules/{load_mask.coffee → loadmaskable.coffee} +10 -4
  77. data/src/modules/modal_view.coffee +38 -0
  78. data/src/modules/paginatable.coffee +79 -0
  79. data/src/modules/state_model.coffee +16 -0
  80. data/src/modules/templating.coffee +8 -0
  81. data/src/plugins/events.coffee +30 -2
  82. data/src/templates/components/bootstrap_form_controls.jst.ejs +10 -0
  83. data/src/templates/components/collection_loader_view.jst.ejs +6 -0
  84. data/src/templates/components/form_alert.jst.ejs +4 -0
  85. data/src/templates/components/grid_view.jst.ejs +11 -0
  86. data/src/templates/components/grid_view_empty_text.jst.ejs +3 -0
  87. data/src/templates/components/load_mask.jst.ejs +5 -0
  88. data/src/templates/components/nav_bar.jst.ejs +4 -0
  89. data/src/templates/components/pagination.jst.ejs +10 -0
  90. data/src/templates/containers/basic.jst.ejs +1 -0
  91. data/src/templates/containers/tab_selector_container.jst.ejs +12 -0
  92. data/src/templates/containers/tab_view.jst.ejs +2 -0
  93. data/src/templates/containers/toolbar_wrapper.jst.ejs +1 -0
  94. data/src/templates/fields/button_field.jst.ejs +2 -0
  95. data/src/templates/fields/button_field_link.jst.ejs +6 -0
  96. data/src/templates/fields/checkbox_array.jst.ejs +4 -0
  97. data/src/templates/fields/checkbox_array_item.jst.ejs +3 -0
  98. data/src/templates/fields/checkbox_field.jst.ejs +10 -0
  99. data/src/templates/fields/file_upload_field.jst.ejs +10 -0
  100. data/src/templates/fields/hidden_field.jst.ejs +1 -0
  101. data/src/templates/fields/select_field.jst.ejs +11 -0
  102. data/src/templates/fields/text_area_field.jst.ejs +11 -0
  103. data/src/templates/fields/text_field.jst.ejs +16 -0
  104. data/src/templates/table_view.jst.ejs +4 -0
  105. data/src/tools/console.coffee +51 -21
  106. data/src/util.coffee +17 -4
  107. data/vendor/assets/javascripts/luca-ui-base.js +3288 -613
  108. data/vendor/assets/javascripts/luca-ui-development-tools.js +49 -21
  109. data/vendor/assets/javascripts/luca-ui-development-tools.min.js +1 -1
  110. data/vendor/assets/javascripts/luca-ui-full.js +1704 -554
  111. data/vendor/assets/javascripts/luca-ui-full.min.js +7 -6
  112. data/vendor/assets/javascripts/luca-ui-spec.js +1783 -830
  113. data/vendor/assets/javascripts/luca-ui-templates.js +92 -0
  114. data/vendor/assets/javascripts/luca-ui.js +1694 -523
  115. data/vendor/assets/javascripts/luca-ui.min.js +4 -4
  116. metadata +69 -31
  117. data/assets/javascripts/luca-ui.coffee +0 -3
  118. data/src/luca.coffee +0 -22
  119. data/src/templates/components/bootstrap_form_controls.luca +0 -7
  120. data/src/templates/components/collection_loader_view.luca +0 -5
  121. data/src/templates/components/form_alert +0 -0
  122. data/src/templates/components/form_alert.luca +0 -3
  123. data/src/templates/components/grid_view.luca +0 -7
  124. data/src/templates/components/grid_view_empty_text.luca +0 -3
  125. data/src/templates/components/load_mask.luca +0 -3
  126. data/src/templates/components/nav_bar.luca +0 -2
  127. data/src/templates/containers/basic.luca +0 -1
  128. data/src/templates/containers/tab_selector_container.luca +0 -8
  129. data/src/templates/containers/tab_view.luca +0 -2
  130. data/src/templates/containers/toolbar_wrapper.luca +0 -1
  131. data/src/templates/fields/button_field.luca +0 -2
  132. data/src/templates/fields/button_field_link.luca +0 -5
  133. data/src/templates/fields/checkbox_array.luca +0 -4
  134. data/src/templates/fields/checkbox_array_item.luca +0 -4
  135. data/src/templates/fields/checkbox_field.luca +0 -9
  136. data/src/templates/fields/file_upload_field.luca +0 -8
  137. data/src/templates/fields/hidden_field.luca +0 -1
  138. data/src/templates/fields/select_field.luca +0 -8
  139. data/src/templates/fields/text_area_field.luca +0 -8
  140. data/src/templates/fields/text_field.luca +0 -17
  141. data/src/templates/sample/contents.luca +0 -1
  142. data/src/templates/sample/welcome.luca +0 -1
  143. data/vendor/assets/javascripts/luca-spec-dependencies.js +0 -6135
  144. data/vendor/assets/javascripts/luca-ui-development-dependencies.js +0 -12845
@@ -1,8 +1,9 @@
1
1
  /*! jQuery v1.7.1 jquery.com | jquery.org/license */(function(a,b){function c(a){return K.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function d(a){if(!pc[a]){var b=H.body,c=K("<"+a+">").appendTo(b),d=c.css("display");c.remove();if(d==="none"||d===""){qc||(qc=H.createElement("iframe"),qc.frameBorder=qc.width=qc.height=0),b.appendChild(qc);if(!rc||!qc.createElement)rc=(qc.contentWindow||qc.contentDocument).document,rc.write((H.compatMode==="CSS1Compat"?"<!doctype html>":"")+"<html><body>"),rc.close();c=rc.createElement(a),rc.body.appendChild(c),d=K.css(c,"display"),b.removeChild(qc)}pc[a]=d}return pc[a]}function e(a,b){var c={};return K.each(vc.concat.apply([],vc.slice(0,b)),function(){c[this]=a}),c}function f(){wc=b}function g(){return setTimeout(f,0),wc=K.now()}function h(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function i(){try{return new a.XMLHttpRequest}catch(b){}}function j(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var d=a.dataTypes,e={},f,g,h=d.length,i,j=d[0],k,l,m,n,o;for(f=1;f<h;f++){if(f===1)for(g in a.converters)typeof g=="string"&&(e[g.toLowerCase()]=a.converters[g]);k=j,j=d[f];if(j==="*")j=k;else if(k!=="*"&&k!==j){l=k+" "+j,m=e[l]||e["* "+j];if(!m){o=b;for(n in e){i=n.split(" ");if(i[0]===k||i[0]==="*"){o=e[i[1]+" "+j];if(o){n=e[n],n===!0?m=o:o===!0&&(m=n);break}}}}!m&&!o&&K.error("No conversion from "+l.replace(" "," to ")),m!==!0&&(c=m?m(c):o(n(c)))}}return c}function k(a,c,d){var e=a.contents,f=a.dataTypes,g=a.responseFields,h,i,j,k;for(i in g)i in d&&(c[g[i]]=d[i]);while(f[0]==="*")f.shift(),h===b&&(h=a.mimeType||c.getResponseHeader("content-type"));if(h)for(i in e)if(e[i]&&e[i].test(h)){f.unshift(i);break}if(f[0]in d)j=f[0];else{for(i in d){if(!f[0]||a.converters[i+" "+f[0]]){j=i;break}k||(k=i)}j=j||k}if(j)return j!==f[0]&&f.unshift(j),d[j]}function l(a,b,c,d){if(K.isArray(b))K.each(b,function(b,e){c||Rb.test(a)?d(a,e):l(a+"["+(typeof e=="object"||K.isArray(e)?b:"")+"]",e,c,d)});else if(!c&&b!=null&&typeof b=="object")for(var e in b)l(a+"["+e+"]",b[e],c,d);else d(a,b)}function m(a,c){var d,e,f=K.ajaxSettings.flatOptions||{};for(d in c)c[d]!==b&&((f[d]?a:e||(e={}))[d]=c[d]);e&&K.extend(!0,a,e)}function n(a,c,d,e,f,g){f=f||c.dataTypes[0],g=g||{},g[f]=!0;var h=a[f],i=0,j=h?h.length:0,k=a===ec,l;for(;i<j&&(k||!l);i++)l=h[i](c,d,e),typeof l=="string"&&(!k||g[l]?l=b:(c.dataTypes.unshift(l),l=n(a,c,d,e,l,g)));return(k||!l)&&!g["*"]&&(l=n(a,c,d,e,"*",g)),l}function o(a){return function(b,c){typeof b!="string"&&(c=b,b="*");if(K.isFunction(c)){var d=b.toLowerCase().split(ac),e=0,f=d.length,g,h,i;for(;e<f;e++)g=d[e],i=/^\+/.test(g),i&&(g=g.substr(1)||"*"),h=a[g]=a[g]||[],h[i?"unshift":"push"](c)}}}function p(a,b,c){var d=b==="width"?a.offsetWidth:a.offsetHeight,e=b==="width"?Lb:Mb,f=0,g=e.length;if(d>0){if(c!=="border")for(;f<g;f++)c||(d-=parseFloat(K.css(a,"padding"+e[f]))||0),c==="margin"?d+=parseFloat(K.css(a,c+e[f]))||0:d-=parseFloat(K.css(a,"border"+e[f]+"Width"))||0;return d+"px"}d=Nb(a,b,b);if(d<0||d==null)d=a.style[b]||0;d=parseFloat(d)||0;if(c)for(;f<g;f++)d+=parseFloat(K.css(a,"padding"+e[f]))||0,c!=="padding"&&(d+=parseFloat(K.css(a,"border"+e[f]+"Width"))||0),c==="margin"&&(d+=parseFloat(K.css(a,c+e[f]))||0);return d+"px"}function q(a,b){b.src?K.ajax({url:b.src,async:!1,dataType:"script"}):K.globalEval((b.text||b.textContent||b.innerHTML||"").replace(Bb,"/*$0*/")),b.parentNode&&b.parentNode.removeChild(b)}function r(a){var b=H.createElement("div");return Db.appendChild(b),b.innerHTML=a.outerHTML,b.firstChild}function s(a){var b=(a.nodeName||"").toLowerCase();b==="input"?t(a):b!=="script"&&typeof a.getElementsByTagName!="undefined"&&K.grep(a.getElementsByTagName("input"),t)}function t(a){if(a.type==="checkbox"||a.type==="radio")a.defaultChecked=a.checked}function u(a){return typeof a.getElementsByTagName!="undefined"?a.getElementsByTagName("*"):typeof a.querySelectorAll!="undefined"?a.querySelectorAll("*"):[]}function v(a,b){var c;if(b.nodeType===1){b.clearAttributes&&b.clearAttributes(),b.mergeAttributes&&b.mergeAttributes(a),c=b.nodeName.toLowerCase();if(c==="object")b.outerHTML=a.outerHTML;else if(c!=="input"||a.type!=="checkbox"&&a.type!=="radio"){if(c==="option")b.selected=a.defaultSelected;else if(c==="input"||c==="textarea")b.defaultValue=a.defaultValue}else a.checked&&(b.defaultChecked=b.checked=a.checked),b.value!==a.value&&(b.value=a.value);b.removeAttribute(K.expando)}}function w(a,b){if(b.nodeType===1&&!!K.hasData(a)){var c,d,e,f=K._data(a),g=K._data(b,f),h=f.events;if(h){delete g.handle,g.events={};for(c in h)for(d=0,e=h[c].length;d<e;d++)K.event.add(b,c+(h[c][d].namespace?".":"")+h[c][d].namespace,h[c][d],h[c][d].data)}g.data&&(g.data=K.extend({},g.data))}}function x(a,b){return K.nodeName(a,"table")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function y(a){var b=pb.split("|"),c=a.createDocumentFragment();if(c.createElement)while(b.length)c.createElement(b.pop());return c}function z(a,b,c){b=b||0;if(K.isFunction(b))return K.grep(a,function(a,d){var e=!!b.call(a,d,a);return e===c});if(b.nodeType)return K.grep(a,function(a,d){return a===b===c});if(typeof b=="string"){var d=K.grep(a,function(a){return a.nodeType===1});if(lb.test(b))return K.filter(b,d,!c);b=K.filter(b,d)}return K.grep(a,function(a,d){return K.inArray(a,b)>=0===c})}function A(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function B(){return!0}function C(){return!1}function D(a,b,c){var d=b+"defer",e=b+"queue",f=b+"mark",g=K._data(a,d);g&&(c==="queue"||!K._data(a,e))&&(c==="mark"||!K._data(a,f))&&setTimeout(function(){!K._data(a,e)&&!K._data(a,f)&&(K.removeData(a,d,!0),g.fire())},0)}function E(a){for(var b in a){if(b==="data"&&K.isEmptyObject(a[b]))continue;if(b!=="toJSON")return!1}return!0}function F(a,c,d){if(d===b&&a.nodeType===1){var e="data-"+c.replace(O,"-$1").toLowerCase();d=a.getAttribute(e);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:K.isNumeric(d)?parseFloat(d):N.test(d)?K.parseJSON(d):d}catch(f){}K.data(a,c,d)}else d=b}return d}function G(a){var b=L[a]={},c,d;a=a.split(/\s+/);for(c=0,d=a.length;c<d;c++)b[a[c]]=!0;return b}var H=a.document,I=a.navigator,J=a.location,K=function(){function c(){if(!d.isReady){try{H.documentElement.doScroll("left")}catch(a){setTimeout(c,1);return}d.ready()}}var d=function(a,b){return new d.fn.init(a,b,g)},e=a.jQuery,f=a.$,g,h=/^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,i=/\S/,j=/^\s+/,k=/\s+$/,l=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,m=/^[\],:{}\s]*$/,n=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,o=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,p=/(?:^|:|,)(?:\s*\[)+/g,q=/(webkit)[ \/]([\w.]+)/,r=/(opera)(?:.*version)?[ \/]([\w.]+)/,s=/(msie) ([\w.]+)/,t=/(mozilla)(?:.*? rv:([\w.]+))?/,u=/-([a-z]|[0-9])/ig,v=/^-ms-/,w=function(a,b){return(b+"").toUpperCase()},x=I.userAgent,y,z,A,B=Object.prototype.toString,C=Object.prototype.hasOwnProperty,D=Array.prototype.push,E=Array.prototype.slice,F=String.prototype.trim,G=Array.prototype.indexOf,J={};return d.fn=d.prototype={constructor:d,init:function(a,c,e){var f,g,i,j;if(!a)return this;if(a.nodeType)return this.context=this[0]=a,this.length=1,this;if(a==="body"&&!c&&H.body)return this.context=H,this[0]=H.body,this.selector=a,this.length=1,this;if(typeof a=="string"){a.charAt(0)!=="<"||a.charAt(a.length-1)!==">"||a.length<3?f=h.exec(a):f=[null,a,null];if(f&&(f[1]||!c)){if(f[1])return c=c instanceof d?c[0]:c,j=c?c.ownerDocument||c:H,i=l.exec(a),i?d.isPlainObject(c)?(a=[H.createElement(i[1])],d.fn.attr.call(a,c,!0)):a=[j.createElement(i[1])]:(i=d.buildFragment([f[1]],[j]),a=(i.cacheable?d.clone(i.fragment):i.fragment).childNodes),d.merge(this,a);g=H.getElementById(f[2]);if(g&&g.parentNode){if(g.id!==f[2])return e.find(a);this.length=1,this[0]=g}return this.context=H,this.selector=a,this}return!c||c.jquery?(c||e).find(a):this.constructor(c).find(a)}return d.isFunction(a)?e.ready(a):(a.selector!==b&&(this.selector=a.selector,this.context=a.context),d.makeArray(a,this))},selector:"",jquery:"1.7.1",length:0,size:function(){return this.length},toArray:function(){return E.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var e=this.constructor();return d.isArray(a)?D.apply(e,a):d.merge(e,a),e.prevObject=this,e.context=this.context,b==="find"?e.selector=this.selector+(this.selector?" ":"")+c:b&&(e.selector=this.selector+"."+b+"("+c+")"),e},each:function(a,b){return d.each(this,a,b)},ready:function(a){return d.bindReady(),z.add(a),this},eq:function(a){return a=+a,a===-1?this.slice(a):this.slice(a,a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(E.apply(this,arguments),"slice",E.call(arguments).join(","))},map:function(a){return this.pushStack(d.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:D,sort:[].sort,splice:[].splice},d.fn.init.prototype=d.fn,d.extend=d.fn.extend=function(){var a,c,e,f,g,h,i=arguments[0]||{},j=1,k=arguments.length,l=!1;typeof i=="boolean"&&(l=i,i=arguments[1]||{},j=2),typeof i!="object"&&!d.isFunction(i)&&(i={}),k===j&&(i=this,--j);for(;j<k;j++)if((a=arguments[j])!=null)for(c in a){e=i[c],f=a[c];if(i===f)continue;l&&f&&(d.isPlainObject(f)||(g=d.isArray(f)))?(g?(g=!1,h=e&&d.isArray(e)?e:[]):h=e&&d.isPlainObject(e)?e:{},i[c]=d.extend(l,h,f)):f!==b&&(i[c]=f)}return i},d.extend({noConflict:function(b){return a.$===d&&(a.$=f),b&&a.jQuery===d&&(a.jQuery=e),d},isReady:!1,readyWait:1,holdReady:function(a){a?d.readyWait++:d.ready(!0)},ready:function(a){if(a===!0&&!--d.readyWait||a!==!0&&!d.isReady){if(!H.body)return setTimeout(d.ready,1);d.isReady=!0;if(a!==!0&&--d.readyWait>0)return;z.fireWith(H,[d]),d.fn.trigger&&d(H).trigger("ready").off("ready")}},bindReady:function(){if(!z){z=d.Callbacks("once memory");if(H.readyState==="complete")return setTimeout(d.ready,1);if(H.addEventListener)H.addEventListener("DOMContentLoaded",A,!1),a.addEventListener("load",d.ready,!1);else if(H.attachEvent){H.attachEvent("onreadystatechange",A),a.attachEvent("onload",d.ready);var b=!1;try{b=a.frameElement==null}catch(e){}H.documentElement.doScroll&&b&&c()}}},isFunction:function(a){return d.type(a)==="function"},isArray:Array.isArray||function(a){return d.type(a)==="array"},isWindow:function(a){return a&&typeof a=="object"&&"setInterval"in a},isNumeric:function(a){return!isNaN(parseFloat(a))&&isFinite(a)},type:function(a){return a==null?String(a):J[B.call(a)]||"object"},isPlainObject:function(a){if(!a||d.type(a)!=="object"||a.nodeType||d.isWindow(a))return!1;try{if(a.constructor&&!C.call(a,"constructor")&&!C.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}var e;for(e in a);return e===b||C.call(a,e)},isEmptyObject:function(a){for(var b in a)return!1;return!0},error:function(a){throw new Error(a)},parseJSON:function(b){if(typeof b!="string"||!b)return null;b=d.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(m.test(b.replace(n,"@").replace(o,"]").replace(p,"")))return(new Function("return "+b))();d.error("Invalid JSON: "+b)},parseXML:function(c){var e,f;try{a.DOMParser?(f=new DOMParser,e=f.parseFromString(c,"text/xml")):(e=new ActiveXObject("Microsoft.XMLDOM"),e.async="false",e.loadXML(c))}catch(g){e=b}return(!e||!e.documentElement||e.getElementsByTagName("parsererror").length)&&d.error("Invalid XML: "+c),e},noop:function(){},globalEval:function(b){b&&i.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(v,"ms-").replace(u,w)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,e){var f,g=0,h=a.length,i=h===b||d.isFunction(a);if(e){if(i){for(f in a)if(c.apply(a[f],e)===!1)break}else for(;g<h;)if(c.apply(a[g++],e)===!1)break}else if(i){for(f in a)if(c.call(a[f],f,a[f])===!1)break}else for(;g<h;)if(c.call(a[g],g,a[g++])===!1)break;return a},trim:F?function(a){return a==null?"":F.call(a)}:function(a){return a==null?"":(a+"").replace(j,"").replace(k,"")},makeArray:function(a,b){var c=b||[];if(a!=null){var e=d.type(a);a.length==null||e==="string"||e==="function"||e==="regexp"||d.isWindow(a)?D.call(c,a):d.merge(c,a)}return c},inArray:function(a,b,c){var d;if(b){if(G)return G.call(b,a,c);d=b.length,c=c?c<0?Math.max(0,d+c):c:0;for(;c<d;c++)if(c in b&&b[c]===a)return c}return-1},merge:function(a,c){var d=a.length,e=0;if(typeof c.length=="number")for(var f=c.length;e<f;e++)a[d++]=c[e];else while(c[e]!==b)a[d++]=c[e++];return a.length=d,a},grep:function(a,b,c){var d=[],e;c=!!c;for(var f=0,g=a.length;f<g;f++)e=!!b(a[f],f),c!==e&&d.push(a[f]);return d},map:function(a,c,e){var f,g,h=[],i=0,j=a.length,k=a instanceof d||j!==b&&typeof j=="number"&&(j>0&&a[0]&&a[j-1]||j===0||d.isArray(a));if(k)for(;i<j;i++)f=c(a[i],i,e),f!=null&&(h[h.length]=f);else for(g in a)f=c(a[g],g,e),f!=null&&(h[h.length]=f);return h.concat.apply([],h)},guid:1,proxy:function(a,c){if(typeof c=="string"){var e=a[c];c=a,a=e}if(!d.isFunction(a))return b;var f=E.call(arguments,2),g=function(){return a.apply(c,f.concat(E.call(arguments)))};return g.guid=a.guid=a.guid||g.guid||d.guid++,g},access:function(a,c,e,f,g,h){var i=a.length;if(typeof c=="object"){for(var j in c)d.access(a,j,c[j],f,g,e);return a}if(e!==b){f=!h&&f&&d.isFunction(e);for(var k=0;k<i;k++)g(a[k],c,f?e.call(a[k],k,g(a[k],c)):e,h);return a}return i?g(a[0],c):b},now:function(){return(new Date).getTime()},uaMatch:function(a){a=a.toLowerCase();var b=q.exec(a)||r.exec(a)||s.exec(a)||a.indexOf("compatible")<0&&t.exec(a)||[];return{browser:b[1]||"",version:b[2]||"0"}},sub:function(){function a(b,c){return new a.fn.init(b,c)}d.extend(!0,a,this),a.superclass=this,a.fn=a.prototype=this(),a.fn.constructor=a,a.sub=this.sub,a.fn.init=function(c,e){return e&&e instanceof d&&!(e instanceof a)&&(e=a(e)),d.fn.init.call(this,c,e,b)},a.fn.init.prototype=a.fn;var b=a(H);return a},browser:{}}),d.each("Boolean Number String Function Array Date RegExp Object".split(" "),function(a,b){J["[object "+b+"]"]=b.toLowerCase()}),y=d.uaMatch(x),y.browser&&(d.browser[y.browser]=!0,d.browser.version=y.version),d.browser.webkit&&(d.browser.safari=!0),i.test(" ")&&(j=/^[\s\xA0]+/,k=/[\s\xA0]+$/),g=d(H),H.addEventListener?A=function(){H.removeEventListener("DOMContentLoaded",A,!1),d.ready()}:H.attachEvent&&(A=function(){H.readyState==="complete"&&(H.detachEvent("onreadystatechange",A),d.ready())}),d}(),L={};K.Callbacks=function(a){a=a?L[a]||G(a):{};var c=[],d=[],e,f,g,h,i,j=function(b){var d,e,f,g,h;for(d=0,e=b.length;d<e;d++)f=b[d],g=K.type(f),g==="array"?j(f):g==="function"&&(!a.unique||!l.has(f))&&c.push(f)},k=function(b,j){j=j||[],e=!a.memory||[b,j],f=!0,i=g||0,g=0,h=c.length;for(;c&&i<h;i++)if(c[i].apply(b,j)===!1&&a.stopOnFalse){e=!0;break}f=!1,c&&(a.once?e===!0?l.disable():c=[]:d&&d.length&&(e=d.shift(),l.fireWith(e[0],e[1])))},l={add:function(){if(c){var a=c.length;j(arguments),f?h=c.length:e&&e!==!0&&(g=a,k(e[0],e[1]))}return this},remove:function(){if(c){var b=arguments,d=0,e=b.length;for(;d<e;d++)for(var g=0;g<c.length;g++)if(b[d]===c[g]){f&&g<=h&&(h--,g<=i&&i--),c.splice(g--,1);if(a.unique)break}}return this},has:function(a){if(c){var b=0,d=c.length;for(;b<d;b++)if(a===c[b])return!0}return!1},empty:function(){return c=[],this},disable:function(){return c=d=e=b,this},disabled:function(){return!c},lock:function(){return d=b,(!e||e===!0)&&l.disable(),this},locked:function(){return!d},fireWith:function(b,c){return d&&(f?a.once||d.push([b,c]):(!a.once||!e)&&k(b,c)),this},fire:function(){return l.fireWith(this,arguments),this},fired:function(){return!!e}};return l};var M=[].slice;K.extend({Deferred:function(a){var b=K.Callbacks("once memory"),c=K.Callbacks("once memory"),d=K.Callbacks("memory"),e="pending",f={resolve:b,reject:c,notify:d},g={done:b.add,fail:c.add,progress:d.add,state:function(){return e},isResolved:b.fired,isRejected:c.fired,then:function(a,b,c){return h.done(a).fail(b).progress(c),this},always:function(){return h.done.apply(h,arguments).fail.apply(h,arguments),this},pipe:function(a,b,c){return K.Deferred(function(d){K.each({done:[a,"resolve"],fail:[b,"reject"],progress:[c,"notify"]},function(a,b){var c=b[0],e=b[1],f;K.isFunction(c)?h[a](function(){f=c.apply(this,arguments),f&&K.isFunction(f.promise)?f.promise().then(d.resolve,d.reject,d.notify):d[e+"With"](this===h?d:this,[f])}):h[a](d[e])})}).promise()},promise:function(a){if(a==null)a=g;else for(var b in g)a[b]=g[b];return a}},h=g.promise({}),i;for(i in f)h[i]=f[i].fire,h[i+"With"]=f[i].fireWith;return h.done(function(){e="resolved"},c.disable,d.lock).fail(function(){e="rejected"},b.disable,d.lock),a&&a.call(h,h),h},when:function(a){function b(a){return function(b){g[a]=arguments.length>1?M.call(arguments,0):b,j.notifyWith(k,g)}}function c(a){return function(b){d[a]=arguments.length>1?M.call(arguments,0):b,--h||j.resolveWith(j,d)}}var d=M.call(arguments,0),e=0,f=d.length,g=Array(f),h=f,i=f,j=f<=1&&a&&K.isFunction(a.promise)?a:K.Deferred(),k=j.promise();if(f>1){for(;e<f;e++)d[e]&&d[e].promise&&K.isFunction(d[e].promise)?d[e].promise().then(c(e),j.reject,b(e)):--h;h||j.resolveWith(j,d)}else j!==a&&j.resolveWith(j,f?[a]:[]);return k}}),K.support=function(){var b,c,d,e,f,g,h,i,j,k,l,m,n,o=H.createElement("div"),p=H.documentElement;o.setAttribute("className","t"),o.innerHTML=" <link/><table></table><a href='/a' style='top:1px;float:left;opacity:.55;'>a</a><input type='checkbox'/>",c=o.getElementsByTagName("*"),d=o.getElementsByTagName("a")[0];if(!c||!c.length||!d)return{};e=H.createElement("select"),f=e.appendChild(H.createElement("option")),g=o.getElementsByTagName("input")[0],b={leadingWhitespace:o.firstChild.nodeType===3,tbody:!o.getElementsByTagName("tbody").length,htmlSerialize:!!o.getElementsByTagName("link").length,style:/top/.test(d.getAttribute("style")),hrefNormalized:d.getAttribute("href")==="/a",opacity:/^0.55/.test(d.style.opacity),cssFloat:!!d.style.cssFloat,checkOn:g.value==="on",optSelected:f.selected,getSetAttribute:o.className!=="t",enctype:!!H.createElement("form").enctype,html5Clone:H.createElement("nav").cloneNode(!0).outerHTML!=="<:nav></:nav>",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0},g.checked=!0,b.noCloneChecked=g.cloneNode(!0).checked,e.disabled=!0,b.optDisabled=!f.disabled;try{delete o.test}catch(q){b.deleteExpando=!1}!o.addEventListener&&o.attachEvent&&o.fireEvent&&(o.attachEvent("onclick",function(){b.noCloneEvent=!1}),o.cloneNode(!0).fireEvent("onclick")),g=H.createElement("input"),g.value="t",g.setAttribute("type","radio"),b.radioValue=g.value==="t",g.setAttribute("checked","checked"),o.appendChild(g),i=H.createDocumentFragment(),i.appendChild(o.lastChild),b.checkClone=i.cloneNode(!0).cloneNode(!0).lastChild.checked,b.appendChecked=g.checked,i.removeChild(g),i.appendChild(o),o.innerHTML="",a.getComputedStyle&&(h=H.createElement("div"),h.style.width="0",h.style.marginRight="0",o.style.width="2px",o.appendChild(h),b.reliableMarginRight=(parseInt((a.getComputedStyle(h,null)||{marginRight:0}).marginRight,10)||0)===0);if(o.attachEvent)for(m in{submit:1,change:1,focusin:1})l="on"+m,n=l in o,n||(o.setAttribute(l,"return;"),n=typeof o[l]=="function"),b[m+"Bubbles"]=n;return i.removeChild(o),i=e=f=h=o=g=null,K(function(){var a,c,d,e,f,g,h,i,k,l,m,p=H.getElementsByTagName("body")[0];!p||(h=1,i="position:absolute;top:0;left:0;width:1px;height:1px;margin:0;",k="visibility:hidden;border:0;",l="style='"+i+"border:5px solid #000;padding:0;'",m="<div "+l+"><div></div></div>"+"<table "+l+" cellpadding='0' cellspacing='0'>"+"<tr><td></td></tr></table>",a=H.createElement("div"),a.style.cssText=k+"width:0;height:0;position:static;top:0;margin-top:"+h+"px",p.insertBefore(a,p.firstChild),o=H.createElement("div"),a.appendChild(o),o.innerHTML="<table><tr><td style='padding:0;border:0;display:none'></td><td>t</td></tr></table>",j=o.getElementsByTagName("td"),n=j[0].offsetHeight===0,j[0].style.display="",j[1].style.display="none",b.reliableHiddenOffsets=n&&j[0].offsetHeight===0,o.innerHTML="",o.style.width=o.style.paddingLeft="1px",K.boxModel=b.boxModel=o.offsetWidth===2,typeof o.style.zoom!="undefined"&&(o.style.display="inline",o.style.zoom=1,b.inlineBlockNeedsLayout=o.offsetWidth===2,o.style.display="",o.innerHTML="<div style='width:4px;'></div>",b.shrinkWrapBlocks=o.offsetWidth!==2),o.style.cssText=i+k,o.innerHTML=m,c=o.firstChild,d=c.firstChild,f=c.nextSibling.firstChild.firstChild,g={doesNotAddBorder:d.offsetTop!==5,doesAddBorderForTableAndCells:f.offsetTop===5},d.style.position="fixed",d.style.top="20px",g.fixedPosition=d.offsetTop===20||d.offsetTop===15,d.style.position=d.style.top="",c.style.overflow="hidden",c.style.position="relative",g.subtractsBorderForOverflowNotVisible=d.offsetTop===-5,g.doesNotIncludeMarginInBodyOffset=p.offsetTop!==h,p.removeChild(a),o=a=null,K.extend(b,g))}),b}();var N=/^(?:\{.*\}|\[.*\])$/,O=/([A-Z])/g;K.extend({cache:{},uuid:0,expando:"jQuery"+(K.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){return a=a.nodeType?K.cache[a[K.expando]]:a[K.expando],!!a&&!E(a)},data:function(a,c,d,e){if(!!K.acceptData(a)){var f,g,h,i=K.expando,j=typeof c=="string",k=a.nodeType,l=k?K.cache:a,m=k?a[i]:a[i]&&i,n=c==="events";if((!m||!l[m]||!n&&!e&&!l[m].data)&&j&&d===b)return;m||(k?a[i]=m=++K.uuid:m=i),l[m]||(l[m]={},k||(l[m].toJSON=K.noop));if(typeof c=="object"||typeof c=="function")e?l[m]=K.extend(l[m],c):l[m].data=K.extend(l[m].data,c);return f=g=l[m],e||(g.data||(g.data={}),g=g.data),d!==b&&(g[K.camelCase(c)]=d),n&&!g[c]?f.events:(j?(h=g[c],h==null&&(h=g[K.camelCase(c)])):h=g,h)}},removeData:function(a,b,c){if(!!K.acceptData(a)){var d,e,f,g=K.expando,h=a.nodeType,i=h?K.cache:a,j=h?a[g]:g;if(!i[j])return;if(b){d=c?i[j]:i[j].data;if(d){K.isArray(b)||(b in d?b=[b]:(b=K.camelCase(b),b in d?b=[b]:b=b.split(" ")));for(e=0,f=b.length;e<f;e++)delete d[b[e]];if(!(c?E:K.isEmptyObject)(d))return}}if(!c){delete i[j].data;if(!E(i[j]))return}K.support.deleteExpando||!i.setInterval?delete i[j]:i[j]=null,h&&(K.support.deleteExpando?delete a[g]:a.removeAttribute?a.removeAttribute(g):a[g]=null)}},_data:function(a,b,c){return K.data(a,b,c,!0)},acceptData:function(a){if(a.nodeName){var b=K.noData[a.nodeName.toLowerCase()];if(b)return b!==!0&&a.getAttribute("classid")===b}return!0}}),K.fn.extend({data:function(a,c){var d,e,f,g=null;if(typeof a=="undefined"){if(this.length){g=K.data(this[0]);if(this[0].nodeType===1&&!K._data(this[0],"parsedAttrs")){e=this[0].attributes;for(var h=0,i=e.length;h<i;h++)f=e[h].name,f.indexOf("data-")===0&&(f=K.camelCase(f.substring(5)),F(this[0],f,g[f]));K._data(this[0],"parsedAttrs",!0)}}return g}return typeof a=="object"?this.each(function(){K.data(this,a)}):(d=a.split("."),d[1]=d[1]?"."+d[1]:"",c===b?(g=this.triggerHandler("getData"+d[1]+"!",[d[0]]),g===b&&this.length&&(g=K.data(this[0],a),g=F(this[0],a,g)),g===b&&d[1]?this.data(d[0]):g):this.each(function(){var b=K(this),e=[d[0],c];b.triggerHandler("setData"+d[1]+"!",e),K.data(this,a,c),b.triggerHandler("changeData"+d[1]+"!",e)}))},removeData:function(a){return this.each(function(){K.removeData(this,a)})}}),K.extend({_mark:function(a,b){a&&(b=(b||"fx")+"mark",K._data(a,b,(K._data(a,b)||0)+1))},_unmark:function(a,b,c){a!==!0&&(c=b,b=a,a=!1);if(b){c=c||"fx";var d=c+"mark",e=a?0:(K._data(b,d)||1)-1;e?K._data(b,d,e):(K.removeData(b,d,!0),D(b,c,"mark"))}},queue:function(a,b,c){var d;if(a)return b=(b||"fx")+"queue",d=K._data(a,b),c&&(!d||K.isArray(c)?d=K._data(a,b,K.makeArray(c)):d.push(c)),d||[]},dequeue:function(a,b){b=b||"fx";var c=K.queue(a,b),d=c.shift(),e={};d==="inprogress"&&(d=c.shift()),d&&(b==="fx"&&c.unshift("inprogress"),K._data(a,b+".run",e),d.call(a,function(){K.dequeue(a,b)},e)),c.length||(K.removeData(a,b+"queue "+b+".run",!0),D(a,b,"queue"))}}),K.fn.extend({queue:function(a,c){return typeof a!="string"&&(c=a,a="fx"),c===b?K.queue(this[0],a):this.each(function(){var b=K.queue(this,a,c);a==="fx"&&b[0]!=="inprogress"&&K.dequeue(this,a)})},dequeue:function(a){return this.each(function(){K.dequeue(this,a)})},delay:function(a,b){return a=K.fx?K.fx.speeds[a]||a:a,b=b||"fx",this.queue(b,function(b,c){var d=setTimeout(b,a);c.stop=function(){clearTimeout(d)}})},clearQueue:function(a){return this.queue(a||"fx",[])},promise:function(a,c){function d(){--h||e.resolveWith(f,[f])}typeof a!="string"&&(c=a,a=b),a=a||"fx";var e=K.Deferred(),f=this,g=f.length,h=1,i=a+"defer",j=a+"queue",k=a+"mark",l;while(g--)if(l=K.data(f[g],i,b,!0)||(K.data(f[g],j,b,!0)||K.data(f[g],k,b,!0))&&K.data(f[g],i,K.Callbacks("once memory"),!0))h++,l.add(d);return d(),e.promise()}});var P=/[\n\t\r]/g,Q=/\s+/,R=/\r/g,S=/^(?:button|input)$/i,T=/^(?:button|input|object|select|textarea)$/i,U=/^a(?:rea)?$/i,V=/^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,W=K.support.getSetAttribute,X,Y,Z;K.fn.extend({attr:function(a,b){return K.access(this,a,b,!0,K.attr)},removeAttr:function(a){return this.each(function(){K.removeAttr(this,a)})},prop:function(a,b){return K.access(this,a,b,!0,K.prop)},removeProp:function(a){return a=K.propFix[a]||a,this.each(function(){try{this[a]=b,delete this[a]}catch(c){}})},addClass:function(a){var b,c,d,e,f,g,h;if(K.isFunction(a))return this.each(function(b){K(this).addClass(a.call(this,b,this.className))});if(a&&typeof a=="string"){b=a.split(Q);for(c=0,d=this.length;c<d;c++){e=this[c];if(e.nodeType===1)if(!e.className&&b.length===1)e.className=a;else{f=" "+e.className+" ";for(g=0,h=b.length;g<h;g++)~f.indexOf(" "+b[g]+" ")||(f+=b[g]+" ");e.className=K.trim(f)}}}return this},removeClass:function(a){var c,d,e,f,g,h,i;if(K.isFunction(a))return this.each(function(b){K(this).removeClass(a.call(this,b,this.className))});if(a&&typeof a=="string"||a===b){c=(a||"").split(Q);for(d=0,e=this.length;d<e;d++){f=this[d];if(f.nodeType===1&&f.className)if(a){g=(" "+f.className+" ").replace(P," ");for(h=0,i=c.length;h<i;h++)g=g.replace(" "+c[h]+" "," ");f.className=K.trim(g)}else f.className=""}}return this},toggleClass:function(a,b){var c=typeof a,d=typeof b=="boolean";return K.isFunction(a)?this.each(function(c){K(this).toggleClass(a.call(this,c,this.className,b),b)}):this.each(function(){if(c==="string"){var e,f=0,g=K(this),h=b,i=a.split(Q);while(e=i[f++])h=d?h:!g.hasClass(e),g[h?"addClass":"removeClass"](e)}else if(c==="undefined"||c==="boolean")this.className&&K._data(this,"__className__",this.className),this.className=this.className||a===!1?"":K._data(this,"__className__")||""})},hasClass:function(a){var b=" "+a+" ",c=0,d=this.length;for(;c<d;c++)if(this[c].nodeType===1&&(" "+this[c].className+" ").replace(P," ").indexOf(b)>-1)return!0;return!1},val:function(a){var c,d,e,f=this[0];if(!!arguments.length)return e=K.isFunction(a),this.each(function(d){var f=K(this),g;if(this.nodeType===1){e?g=a.call(this,d,f.val()):g=a,g==null?g="":typeof g=="number"?g+="":K.isArray(g)&&(g=K.map(g,function(a){return a==null?"":a+""})),c=K.valHooks[this.nodeName.toLowerCase()]||K.valHooks[this.type];if(!c||!("set"in c)||c.set(this,g,"value")===b)this.value=g}});if(f)return c=K.valHooks[f.nodeName.toLowerCase()]||K.valHooks[f.type],c&&"get"in c&&(d=c.get(f,"value"))!==b?d:(d=f.value,typeof d=="string"?d.replace(R,""):d==null?"":d)}}),K.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){var b,c,d,e,f=a.selectedIndex,g=[],h=a.options,i=a.type==="select-one";if(f<0)return null;c=i?f:0,d=i?f+1:h.length;for(;c<d;c++){e=h[c];if(e.selected&&(K.support.optDisabled?!e.disabled:e.getAttribute("disabled")===null)&&(!e.parentNode.disabled||!K.nodeName(e.parentNode,"optgroup"))){b=K(e).val();if(i)return b;g.push(b)}}return i&&!g.length&&h.length?K(h[f]).val():g},set:function(a,b){var c=K.makeArray(b);return K(a).find("option").each(function(){this.selected=K.inArray(K(this).val(),c)>=0}),c.length||(a.selectedIndex=-1),c}}},attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attr:function(a,c,d,e){var f,g,h,i=a.nodeType;if(!!a&&i!==3&&i!==8&&i!==2){if(e&&c in K.attrFn)return K(a)[c](d);if(typeof a.getAttribute=="undefined")return K.prop(a,c,d);h=i!==1||!K.isXMLDoc(a),h&&(c=c.toLowerCase(),g=K.attrHooks[c]||(V.test(c)?Y:X));if(d!==b){if(d===null){K.removeAttr(a,c);return}return g&&"set"in g&&h&&(f=g.set(a,d,c))!==b?f:(a.setAttribute(c,""+d),d)}return g&&"get"in g&&h&&(f=g.get(a,c))!==null?f:(f=a.getAttribute(c),f===null?b:f)}},removeAttr:function(a,b){var c,d,e,f,g=0;if(b&&a.nodeType===1){d=b.toLowerCase().split(Q),f=d.length;for(;g<f;g++)e=d[g],e&&(c=K.propFix[e]||e,K.attr(a,e,""),a.removeAttribute(W?e:c),V.test(e)&&c in a&&(a[c]=!1))}},attrHooks:{type:{set:function(a,b){if(S.test(a.nodeName)&&a.parentNode)K.error("type property can't be changed");else if(!K.support.radioValue&&b==="radio"&&K.nodeName(a,"input")){var c=a.value;return a.setAttribute("type",b),c&&(a.value=c),b}}},value:{get:function(a,b){return X&&K.nodeName(a,"button")?X.get(a,b):b in a?a.value:null},set:function(a,b,c){if(X&&K.nodeName(a,"button"))return X.set(a,b,c);a.value=b}}},propFix:{tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},prop:function(a,c,d){var e,f,g,h=a.nodeType;if(!!a&&h!==3&&h!==8&&h!==2)return g=h!==1||!K.isXMLDoc(a),g&&(c=K.propFix[c]||c,f=K.propHooks[c]),d!==b?f&&"set"in f&&(e=f.set(a,d,c))!==b?e:a[c]=d:f&&"get"in f&&(e=f.get(a,c))!==null?e:a[c]},propHooks:{tabIndex:{get:function(a){var c=a.getAttributeNode("tabindex");return c&&c.specified?parseInt(c.value,10):T.test(a.nodeName)||U.test(a.nodeName)&&a.href?0:b}}}}),K.attrHooks.tabindex=K.propHooks.tabIndex,Y={get:function(a,c){var d,e=K.prop(a,c);return e===!0||typeof e!="boolean"&&(d=a.getAttributeNode(c))&&d.nodeValue!==!1?c.toLowerCase():b},set:function(a,b,c){var d;return b===!1?K.removeAttr(a,c):(d=K.propFix[c]||c,d in a&&(a[d]=!0),a.setAttribute(c,c.toLowerCase())),c}},W||(Z={name:!0,id:!0},X=K.valHooks.button={get:function(a,c){var d;return d=a.getAttributeNode(c),d&&(Z[c]?d.nodeValue!=="":d.specified)?d.nodeValue:b},set:function(a,b,c){var d=a.getAttributeNode(c);return d||(d=H.createAttribute(c),a.setAttributeNode(d)),d.nodeValue=b+""}},K.attrHooks.tabindex.set=X.set,K.each(["width","height"],function(a,b){K.attrHooks[b]=K.extend(K.attrHooks[b],{set:function(a,c){if(c==="")return a.setAttribute(b,"auto"),c}})}),K.attrHooks.contenteditable={get:X.get,set:function(a,b,c){b===""&&(b="false"),X.set(a,b,c)}}),K.support.hrefNormalized||K.each(["href","src","width","height"],function(a,c){K.attrHooks[c]=K.extend(K.attrHooks[c],{get:function(a){var d=a.getAttribute(c,2);return d===null?b:d}})}),K.support.style||(K.attrHooks.style={get:function(a){return a.style.cssText.toLowerCase()||b},set:function(a,b){return a.style.cssText=""+b}}),K.support.optSelected||(K.propHooks.selected=K.extend(K.propHooks.selected,{get:function(a){var b=a.parentNode;return b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex),null}})),K.support.enctype||(K.propFix.enctype="encoding"),K.support.checkOn||K.each(["radio","checkbox"],function(){K.valHooks[this]={get:function(a){return a.getAttribute("value")===null?"on":a.value}}}),K.each(["radio","checkbox"],function(){K.valHooks[this]=K.extend(K.valHooks[this],{set:function(a,b){if(K.isArray(b))return a.checked=K.inArray(K(a).val(),b)>=0}})});var $=/^(?:textarea|input|select)$/i,_=/^([^\.]*)?(?:\.(.+))?$/,ab=/\bhover(\.\S+)?\b/,bb=/^key/,cb=/^(?:mouse|contextmenu)|click/,db=/^(?:focusinfocus|focusoutblur)$/,eb=/^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/,fb=function(a){var b=eb.exec(a);return b&&(b[1]=(b[1]||"").toLowerCase(),b[3]=b[3]&&new RegExp("(?:^|\\s)"+b[3]+"(?:\\s|$)")),b},gb=function(a,b){var c=a.attributes||{};return(!b[1]||a.nodeName.toLowerCase()===b[1])&&(!b[2]||(c.id||{}).value===b[2])&&(!b[3]||b[3].test((c["class"]||{}).value))},hb=function(a){return K.event.special.hover?a:a.replace(ab,"mouseenter$1 mouseleave$1")};K.event={add:function(a,c,d,e,f){var g,h,i,j,k,l,m,n,o,p,q,r;if(!(a.nodeType===3||a.nodeType===8||!c||!d||!(g=K._data(a)))){d.handler&&(o=d,d=o.handler),d.guid||(d.guid=K.guid++),i=g.events,i||(g.events=i={}),h=g.handle,h||(g.handle=h=function(a){return typeof K=="undefined"||!!a&&K.event.triggered===a.type?b:K.event.dispatch.apply(h.elem,arguments)},h.elem=a),c=K.trim(hb(c)).split(" ");for(j=0;j<c.length;j++){k=_.exec(c[j])||[],l=k[1],m=(k[2
2
2
  ]||"").split(".").sort(),r=K.event.special[l]||{},l=(f?r.delegateType:r.bindType)||l,r=K.event.special[l]||{},n=K.extend({type:l,origType:k[1],data:e,handler:d,guid:d.guid,selector:f,quick:fb(f),namespace:m.join(".")},o),q=i[l];if(!q){q=i[l]=[],q.delegateCount=0;if(!r.setup||r.setup.call(a,e,m,h)===!1)a.addEventListener?a.addEventListener(l,h,!1):a.attachEvent&&a.attachEvent("on"+l,h)}r.add&&(r.add.call(a,n),n.handler.guid||(n.handler.guid=d.guid)),f?q.splice(q.delegateCount++,0,n):q.push(n),K.event.global[l]=!0}a=null}},global:{},remove:function(a,b,c,d,e){var f=K.hasData(a)&&K._data(a),g,h,i,j,k,l,m,n,o,p,q,r;if(!!f&&!!(n=f.events)){b=K.trim(hb(b||"")).split(" ");for(g=0;g<b.length;g++){h=_.exec(b[g])||[],i=j=h[1],k=h[2];if(!i){for(i in n)K.event.remove(a,i+b[g],c,d,!0);continue}o=K.event.special[i]||{},i=(d?o.delegateType:o.bindType)||i,q=n[i]||[],l=q.length,k=k?new RegExp("(^|\\.)"+k.split(".").sort().join("\\.(?:.*\\.)?")+"(\\.|$)"):null;for(m=0;m<q.length;m++)r=q[m],(e||j===r.origType)&&(!c||c.guid===r.guid)&&(!k||k.test(r.namespace))&&(!d||d===r.selector||d==="**"&&r.selector)&&(q.splice(m--,1),r.selector&&q.delegateCount--,o.remove&&o.remove.call(a,r));q.length===0&&l!==q.length&&((!o.teardown||o.teardown.call(a,k)===!1)&&K.removeEvent(a,i,f.handle),delete n[i])}K.isEmptyObject(n)&&(p=f.handle,p&&(p.elem=null),K.removeData(a,["events","handle"],!0))}},customEvent:{getData:!0,setData:!0,changeData:!0},trigger:function(c,d,e,f){if(!e||e.nodeType!==3&&e.nodeType!==8){var g=c.type||c,h=[],i,j,k,l,m,n,o,p,q,r;if(db.test(g+K.event.triggered))return;g.indexOf("!")>=0&&(g=g.slice(0,-1),j=!0),g.indexOf(".")>=0&&(h=g.split("."),g=h.shift(),h.sort());if((!e||K.event.customEvent[g])&&!K.event.global[g])return;c=typeof c=="object"?c[K.expando]?c:new K.Event(g,c):new K.Event(g),c.type=g,c.isTrigger=!0,c.exclusive=j,c.namespace=h.join("."),c.namespace_re=c.namespace?new RegExp("(^|\\.)"+h.join("\\.(?:.*\\.)?")+"(\\.|$)"):null,n=g.indexOf(":")<0?"on"+g:"";if(!e){i=K.cache;for(k in i)i[k].events&&i[k].events[g]&&K.event.trigger(c,d,i[k].handle.elem,!0);return}c.result=b,c.target||(c.target=e),d=d!=null?K.makeArray(d):[],d.unshift(c),o=K.event.special[g]||{};if(o.trigger&&o.trigger.apply(e,d)===!1)return;q=[[e,o.bindType||g]];if(!f&&!o.noBubble&&!K.isWindow(e)){r=o.delegateType||g,l=db.test(r+g)?e:e.parentNode,m=null;for(;l;l=l.parentNode)q.push([l,r]),m=l;m&&m===e.ownerDocument&&q.push([m.defaultView||m.parentWindow||a,r])}for(k=0;k<q.length&&!c.isPropagationStopped();k++)l=q[k][0],c.type=q[k][1],p=(K._data(l,"events")||{})[c.type]&&K._data(l,"handle"),p&&p.apply(l,d),p=n&&l[n],p&&K.acceptData(l)&&p.apply(l,d)===!1&&c.preventDefault();return c.type=g,!f&&!c.isDefaultPrevented()&&(!o._default||o._default.apply(e.ownerDocument,d)===!1)&&(g!=="click"||!K.nodeName(e,"a"))&&K.acceptData(e)&&n&&e[g]&&(g!=="focus"&&g!=="blur"||c.target.offsetWidth!==0)&&!K.isWindow(e)&&(m=e[n],m&&(e[n]=null),K.event.triggered=g,e[g](),K.event.triggered=b,m&&(e[n]=m)),c.result}},dispatch:function(c){c=K.event.fix(c||a.event);var d=(K._data(this,"events")||{})[c.type]||[],e=d.delegateCount,f=[].slice.call(arguments,0),g=!c.exclusive&&!c.namespace,h=[],i,j,k,l,m,n,o,p,q,r,s;f[0]=c,c.delegateTarget=this;if(e&&!c.target.disabled&&(!c.button||c.type!=="click")){l=K(this),l.context=this.ownerDocument||this;for(k=c.target;k!=this;k=k.parentNode||this){n={},p=[],l[0]=k;for(i=0;i<e;i++)q=d[i],r=q.selector,n[r]===b&&(n[r]=q.quick?gb(k,q.quick):l.is(r)),n[r]&&p.push(q);p.length&&h.push({elem:k,matches:p})}}d.length>e&&h.push({elem:this,matches:d.slice(e)});for(i=0;i<h.length&&!c.isPropagationStopped();i++){o=h[i],c.currentTarget=o.elem;for(j=0;j<o.matches.length&&!c.isImmediatePropagationStopped();j++){q=o.matches[j];if(g||!c.namespace&&!q.namespace||c.namespace_re&&c.namespace_re.test(q.namespace))c.data=q.data,c.handleObj=q,m=((K.event.special[q.origType]||{}).handle||q.handler).apply(o.elem,f),m!==b&&(c.result=m,m===!1&&(c.preventDefault(),c.stopPropagation()))}}return c.result},props:"attrChange attrName relatedNode srcElement altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(a,b){return a.which==null&&(a.which=b.charCode!=null?b.charCode:b.keyCode),a}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(a,c){var d,e,f,g=c.button,h=c.fromElement;return a.pageX==null&&c.clientX!=null&&(d=a.target.ownerDocument||H,e=d.documentElement,f=d.body,a.pageX=c.clientX+(e&&e.scrollLeft||f&&f.scrollLeft||0)-(e&&e.clientLeft||f&&f.clientLeft||0),a.pageY=c.clientY+(e&&e.scrollTop||f&&f.scrollTop||0)-(e&&e.clientTop||f&&f.clientTop||0)),!a.relatedTarget&&h&&(a.relatedTarget=h===a.target?c.toElement:h),!a.which&&g!==b&&(a.which=g&1?1:g&2?3:g&4?2:0),a}},fix:function(a){if(a[K.expando])return a;var c,d,e=a,f=K.event.fixHooks[a.type]||{},g=f.props?this.props.concat(f.props):this.props;a=K.Event(e);for(c=g.length;c;)d=g[--c],a[d]=e[d];return a.target||(a.target=e.srcElement||H),a.target.nodeType===3&&(a.target=a.target.parentNode),a.metaKey===b&&(a.metaKey=a.ctrlKey),f.filter?f.filter(a,e):a},special:{ready:{setup:K.bindReady},load:{noBubble:!0},focus:{delegateType:"focusin"},blur:{delegateType:"focusout"},beforeunload:{setup:function(a,b,c){K.isWindow(this)&&(this.onbeforeunload=c)},teardown:function(a,b){this.onbeforeunload===b&&(this.onbeforeunload=null)}}},simulate:function(a,b,c,d){var e=K.extend(new K.Event,c,{type:a,isSimulated:!0,originalEvent:{}});d?K.event.trigger(e,null,b):K.event.dispatch.call(b,e),e.isDefaultPrevented()&&c.preventDefault()}},K.event.handle=K.event.dispatch,K.removeEvent=H.removeEventListener?function(a,b,c){a.removeEventListener&&a.removeEventListener(b,c,!1)}:function(a,b,c){a.detachEvent&&a.detachEvent("on"+b,c)},K.Event=function(a,b){if(!(this instanceof K.Event))return new K.Event(a,b);a&&a.type?(this.originalEvent=a,this.type=a.type,this.isDefaultPrevented=a.defaultPrevented||a.returnValue===!1||a.getPreventDefault&&a.getPreventDefault()?B:C):this.type=a,b&&K.extend(this,b),this.timeStamp=a&&a.timeStamp||K.now(),this[K.expando]=!0},K.Event.prototype={preventDefault:function(){this.isDefaultPrevented=B;var a=this.originalEvent;!a||(a.preventDefault?a.preventDefault():a.returnValue=!1)},stopPropagation:function(){this.isPropagationStopped=B;var a=this.originalEvent;!a||(a.stopPropagation&&a.stopPropagation(),a.cancelBubble=!0)},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=B,this.stopPropagation()},isDefaultPrevented:C,isPropagationStopped:C,isImmediatePropagationStopped:C},K.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(a,b){K.event.special[a]={delegateType:b,bindType:b,handle:function(a){var c=this,d=a.relatedTarget,e=a.handleObj,f=e.selector,g;if(!d||d!==c&&!K.contains(c,d))a.type=e.origType,g=e.handler.apply(this,arguments),a.type=b;return g}}}),K.support.submitBubbles||(K.event.special.submit={setup:function(){if(K.nodeName(this,"form"))return!1;K.event.add(this,"click._submit keypress._submit",function(a){var c=a.target,d=K.nodeName(c,"input")||K.nodeName(c,"button")?c.form:b;d&&!d._submit_attached&&(K.event.add(d,"submit._submit",function(a){this.parentNode&&!a.isTrigger&&K.event.simulate("submit",this.parentNode,a,!0)}),d._submit_attached=!0)})},teardown:function(){if(K.nodeName(this,"form"))return!1;K.event.remove(this,"._submit")}}),K.support.changeBubbles||(K.event.special.change={setup:function(){if($.test(this.nodeName)){if(this.type==="checkbox"||this.type==="radio")K.event.add(this,"propertychange._change",function(a){a.originalEvent.propertyName==="checked"&&(this._just_changed=!0)}),K.event.add(this,"click._change",function(a){this._just_changed&&!a.isTrigger&&(this._just_changed=!1,K.event.simulate("change",this,a,!0))});return!1}K.event.add(this,"beforeactivate._change",function(a){var b=a.target;$.test(b.nodeName)&&!b._change_attached&&(K.event.add(b,"change._change",function(a){this.parentNode&&!a.isSimulated&&!a.isTrigger&&K.event.simulate("change",this.parentNode,a,!0)}),b._change_attached=!0)})},handle:function(a){var b=a.target;if(this!==b||a.isSimulated||a.isTrigger||b.type!=="radio"&&b.type!=="checkbox")return a.handleObj.handler.apply(this,arguments)},teardown:function(){return K.event.remove(this,"._change"),$.test(this.nodeName)}}),K.support.focusinBubbles||K.each({focus:"focusin",blur:"focusout"},function(a,b){var c=0,d=function(a){K.event.simulate(b,a.target,K.event.fix(a),!0)};K.event.special[b]={setup:function(){c++===0&&H.addEventListener(a,d,!0)},teardown:function(){--c===0&&H.removeEventListener(a,d,!0)}}}),K.fn.extend({on:function(a,c,d,e,f){var g,h;if(typeof a=="object"){typeof c!="string"&&(d=c,c=b);for(h in a)this.on(h,c,d,a[h],f);return this}d==null&&e==null?(e=c,d=c=b):e==null&&(typeof c=="string"?(e=d,d=b):(e=d,d=c,c=b));if(e===!1)e=C;else if(!e)return this;return f===1&&(g=e,e=function(a){return K().off(a),g.apply(this,arguments)},e.guid=g.guid||(g.guid=K.guid++)),this.each(function(){K.event.add(this,a,e,d,c)})},one:function(a,b,c,d){return this.on.call(this,a,b,c,d,1)},off:function(a,c,d){if(a&&a.preventDefault&&a.handleObj){var e=a.handleObj;return K(a.delegateTarget).off(e.namespace?e.type+"."+e.namespace:e.type,e.selector,e.handler),this}if(typeof a=="object"){for(var f in a)this.off(f,c,a[f]);return this}if(c===!1||typeof c=="function")d=c,c=b;return d===!1&&(d=C),this.each(function(){K.event.remove(this,a,d,c)})},bind:function(a,b,c){return this.on(a,null,b,c)},unbind:function(a,b){return this.off(a,null,b)},live:function(a,b,c){return K(this.context).on(a,this.selector,b,c),this},die:function(a,b){return K(this.context).off(a,this.selector||"**",b),this},delegate:function(a,b,c,d){return this.on(b,a,c,d)},undelegate:function(a,b,c){return arguments.length==1?this.off(a,"**"):this.off(b,a,c)},trigger:function(a,b){return this.each(function(){K.event.trigger(a,b,this)})},triggerHandler:function(a,b){if(this[0])return K.event.trigger(a,b,this[0],!0)},toggle:function(a){var b=arguments,c=a.guid||K.guid++,d=0,e=function(c){var e=(K._data(this,"lastToggle"+a.guid)||0)%d;return K._data(this,"lastToggle"+a.guid,e+1),c.preventDefault(),b[e].apply(this,arguments)||!1};e.guid=c;while(d<b.length)b[d++].guid=c;return this.click(e)},hover:function(a,b){return this.mouseenter(a).mouseleave(b||a)}}),K.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(a,b){K.fn[b]=function(a,c){return c==null&&(c=a,a=null),arguments.length>0?this.on(b,null,a,c):this.trigger(b)},K.attrFn&&(K.attrFn[b]=!0),bb.test(b)&&(K.event.fixHooks[b]=K.event.keyHooks),cb.test(b)&&(K.event.fixHooks[b]=K.event.mouseHooks)}),function(){function a(a,b,c,d,f,g){for(var h=0,i=d.length;h<i;h++){var j=d[h];if(j){var k=!1;j=j[a];while(j){if(j[e]===c){k=d[j.sizset];break}if(j.nodeType===1){g||(j[e]=c,j.sizset=h);if(typeof b!="string"){if(j===b){k=!0;break}}else if(m.filter(b,[j]).length>0){k=j;break}}j=j[a]}d[h]=k}}}function c(a,b,c,d,f,g){for(var h=0,i=d.length;h<i;h++){var j=d[h];if(j){var k=!1;j=j[a];while(j){if(j[e]===c){k=d[j.sizset];break}j.nodeType===1&&!g&&(j[e]=c,j.sizset=h);if(j.nodeName.toLowerCase()===b){k=j;break}j=j[a]}d[h]=k}}}var d=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,e="sizcache"+(Math.random()+"").replace(".",""),f=0,g=Object.prototype.toString,h=!1,i=!0,j=/\\/g,k=/\r\n/g,l=/\W/;[0,0].sort(function(){return i=!1,0});var m=function(a,b,c,e){c=c||[],b=b||H;var f=b;if(b.nodeType!==1&&b.nodeType!==9)return[];if(!a||typeof a!="string")return c;var h,i,j,k,l,n,q,r,t=!0,u=m.isXML(b),v=[],x=a;do{d.exec(""),h=d.exec(x);if(h){x=h[3],v.push(h[1]);if(h[2]){k=h[3];break}}}while(h);if(v.length>1&&p.exec(a))if(v.length===2&&o.relative[v[0]])i=w(v[0]+v[1],b,e);else{i=o.relative[v[0]]?[b]:m(v.shift(),b);while(v.length)a=v.shift(),o.relative[a]&&(a+=v.shift()),i=w(a,i,e)}else{!e&&v.length>1&&b.nodeType===9&&!u&&o.match.ID.test(v[0])&&!o.match.ID.test(v[v.length-1])&&(l=m.find(v.shift(),b,u),b=l.expr?m.filter(l.expr,l.set)[0]:l.set[0]);if(b){l=e?{expr:v.pop(),set:s(e)}:m.find(v.pop(),v.length!==1||v[0]!=="~"&&v[0]!=="+"||!b.parentNode?b:b.parentNode,u),i=l.expr?m.filter(l.expr,l.set):l.set,v.length>0?j=s(i):t=!1;while(v.length)n=v.pop(),q=n,o.relative[n]?q=v.pop():n="",q==null&&(q=b),o.relative[n](j,q,u)}else j=v=[]}j||(j=i),j||m.error(n||a);if(g.call(j)==="[object Array]")if(!t)c.push.apply(c,j);else if(b&&b.nodeType===1)for(r=0;j[r]!=null;r++)j[r]&&(j[r]===!0||j[r].nodeType===1&&m.contains(b,j[r]))&&c.push(i[r]);else for(r=0;j[r]!=null;r++)j[r]&&j[r].nodeType===1&&c.push(i[r]);else s(j,c);return k&&(m(k,f,c,e),m.uniqueSort(c)),c};m.uniqueSort=function(a){if(u){h=i,a.sort(u);if(h)for(var b=1;b<a.length;b++)a[b]===a[b-1]&&a.splice(b--,1)}return a},m.matches=function(a,b){return m(a,null,null,b)},m.matchesSelector=function(a,b){return m(b,null,null,[a]).length>0},m.find=function(a,b,c){var d,e,f,g,h,i;if(!a)return[];for(e=0,f=o.order.length;e<f;e++){h=o.order[e];if(g=o.leftMatch[h].exec(a)){i=g[1],g.splice(1,1);if(i.substr(i.length-1)!=="\\"){g[1]=(g[1]||"").replace(j,""),d=o.find[h](g,b,c);if(d!=null){a=a.replace(o.match[h],"");break}}}}return d||(d=typeof b.getElementsByTagName!="undefined"?b.getElementsByTagName("*"):[]),{set:d,expr:a}},m.filter=function(a,c,d,e){var f,g,h,i,j,k,l,n,p,q=a,r=[],s=c,t=c&&c[0]&&m.isXML(c[0]);while(a&&c.length){for(h in o.filter)if((f=o.leftMatch[h].exec(a))!=null&&f[2]){k=o.filter[h],l=f[1],g=!1,f.splice(1,1);if(l.substr(l.length-1)==="\\")continue;s===r&&(r=[]);if(o.preFilter[h]){f=o.preFilter[h](f,s,d,r,e,t);if(!f)g=i=!0;else if(f===!0)continue}if(f)for(n=0;(j=s[n])!=null;n++)j&&(i=k(j,f,n,s),p=e^i,d&&i!=null?p?g=!0:s[n]=!1:p&&(r.push(j),g=!0));if(i!==b){d||(s=r),a=a.replace(o.match[h],"");if(!g)return[];break}}if(a===q){if(g!=null)break;m.error(a)}q=a}return s},m.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)};var n=m.getText=function(a){var b,c,d=a.nodeType,e="";if(d){if(d===1||d===9){if(typeof a.textContent=="string")return a.textContent;if(typeof a.innerText=="string")return a.innerText.replace(k,"");for(a=a.firstChild;a;a=a.nextSibling)e+=n(a)}else if(d===3||d===4)return a.nodeValue}else for(b=0;c=a[b];b++)c.nodeType!==8&&(e+=n(c));return e},o=m.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,CLASS:/\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/,POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/},leftMatch:{},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(a){return a.getAttribute("href")},type:function(a){return a.getAttribute("type")}},relative:{"+":function(a,b){var c=typeof b=="string",d=c&&!l.test(b),e=c&&!d;d&&(b=b.toLowerCase());for(var f=0,g=a.length,h;f<g;f++)if(h=a[f]){while((h=h.previousSibling)&&h.nodeType!==1);a[f]=e||h&&h.nodeName.toLowerCase()===b?h||!1:h===b}e&&m.filter(b,a,!0)},">":function(a,b){var c,d=typeof b=="string",e=0,f=a.length;if(d&&!l.test(b)){b=b.toLowerCase();for(;e<f;e++){c=a[e];if(c){var g=c.parentNode;a[e]=g.nodeName.toLowerCase()===b?g:!1}}}else{for(;e<f;e++)c=a[e],c&&(a[e]=d?c.parentNode:c.parentNode===b);d&&m.filter(b,a,!0)}},"":function(b,d,e){var g,h=f++,i=a;typeof d=="string"&&!l.test(d)&&(d=d.toLowerCase(),g=d,i=c),i("parentNode",d,h,b,g,e)},"~":function(b,d,e){var g,h=f++,i=a;typeof d=="string"&&!l.test(d)&&(d=d.toLowerCase(),g=d,i=c),i("previousSibling",d,h,b,g,e)}},find:{ID:function(a,b,c){if(typeof b.getElementById!="undefined"&&!c){var d=b.getElementById(a[1]);return d&&d.parentNode?[d]:[]}},NAME:function(a,b){if(typeof b.getElementsByName!="undefined"){var c=[],d=b.getElementsByName(a[1]);for(var e=0,f=d.length;e<f;e++)d[e].getAttribute("name")===a[1]&&c.push(d[e]);return c.length===0?null:c}},TAG:function(a,b){if(typeof b.getElementsByTagName!="undefined")return b.getElementsByTagName(a[1])}},preFilter:{CLASS:function(a,b,c,d,e,f){a=" "+a[1].replace(j,"")+" ";if(f)return a;for(var g=0,h;(h=b[g])!=null;g++)h&&(e^(h.className&&(" "+h.className+" ").replace(/[\t\n\r]/g," ").indexOf(a)>=0)?c||d.push(h):c&&(b[g]=!1));return!1},ID:function(a){return a[1].replace(j,"")},TAG:function(a,b){return a[1].replace(j,"").toLowerCase()},CHILD:function(a){if(a[1]==="nth"){a[2]||m.error(a[0]),a[2]=a[2].replace(/^\+|\s*/g,"");var b=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(a[2]==="even"&&"2n"||a[2]==="odd"&&"2n+1"||!/\D/.test(a[2])&&"0n+"+a[2]||a[2]);a[2]=b[1]+(b[2]||1)-0,a[3]=b[3]-0}else a[2]&&m.error(a[0]);return a[0]=f++,a},ATTR:function(a,b,c,d,e,f){var g=a[1]=a[1].replace(j,"");return!f&&o.attrMap[g]&&(a[1]=o.attrMap[g]),a[4]=(a[4]||a[5]||"").replace(j,""),a[2]==="~="&&(a[4]=" "+a[4]+" "),a},PSEUDO:function(a,b,c,e,f){if(a[1]==="not"){if(!((d.exec(a[3])||"").length>1||/^\w/.test(a[3]))){var g=m.filter(a[3],b,c,!0^f);return c||e.push.apply(e,g),!1}a[3]=m(a[3],null,null,b)}else if(o.match.POS.test(a[0])||o.match.CHILD.test(a[0]))return!0;return a},POS:function(a){return a.unshift(!0),a}},filters:{enabled:function(a){return a.disabled===!1&&a.type!=="hidden"},disabled:function(a){return a.disabled===!0},checked:function(a){return a.checked===!0},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},parent:function(a){return!!a.firstChild},empty:function(a){return!a.firstChild},has:function(a,b,c){return!!m(c[3],a).length},header:function(a){return/h\d/i.test(a.nodeName)},text:function(a){var b=a.getAttribute("type"),c=a.type;return a.nodeName.toLowerCase()==="input"&&"text"===c&&(b===c||b===null)},radio:function(a){return a.nodeName.toLowerCase()==="input"&&"radio"===a.type},checkbox:function(a){return a.nodeName.toLowerCase()==="input"&&"checkbox"===a.type},file:function(a){return a.nodeName.toLowerCase()==="input"&&"file"===a.type},password:function(a){return a.nodeName.toLowerCase()==="input"&&"password"===a.type},submit:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"submit"===a.type},image:function(a){return a.nodeName.toLowerCase()==="input"&&"image"===a.type},reset:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"reset"===a.type},button:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&"button"===a.type||b==="button"},input:function(a){return/input|select|textarea|button/i.test(a.nodeName)},focus:function(a){return a===a.ownerDocument.activeElement}},setFilters:{first:function(a,b){return b===0},last:function(a,b,c,d){return b===d.length-1},even:function(a,b){return b%2===0},odd:function(a,b){return b%2===1},lt:function(a,b,c){return b<c[3]-0},gt:function(a,b,c){return b>c[3]-0},nth:function(a,b,c){return c[3]-0===b},eq:function(a,b,c){return c[3]-0===b}},filter:{PSEUDO:function(a,b,c,d){var e=b[1],f=o.filters[e];if(f)return f(a,c,b,d);if(e==="contains")return(a.textContent||a.innerText||n([a])||"").indexOf(b[3])>=0;if(e==="not"){var g=b[3];for(var h=0,i=g.length;h<i;h++)if(g[h]===a)return!1;return!0}m.error(e)},CHILD:function(a,b){var c,d,f,g,h,i,j,k=b[1],l=a;switch(k){case"only":case"first":while(l=l.previousSibling)if(l.nodeType===1)return!1;if(k==="first")return!0;l=a;case"last":while(l=l.nextSibling)if(l.nodeType===1)return!1;return!0;case"nth":c=b[2],d=b[3];if(c===1&&d===0)return!0;f=b[0],g=a.parentNode;if(g&&(g[e]!==f||!a.nodeIndex)){i=0;for(l=g.firstChild;l;l=l.nextSibling)l.nodeType===1&&(l.nodeIndex=++i);g[e]=f}return j=a.nodeIndex-d,c===0?j===0:j%c===0&&j/c>=0}},ID:function(a,b){return a.nodeType===1&&a.getAttribute("id")===b},TAG:function(a,b){return b==="*"&&a.nodeType===1||!!a.nodeName&&a.nodeName.toLowerCase()===b},CLASS:function(a,b){return(" "+(a.className||a.getAttribute("class"))+" ").indexOf(b)>-1},ATTR:function(a,b){var c=b[1],d=m.attr?m.attr(a,c):o.attrHandle[c]?o.attrHandle[c](a):a[c]!=null?a[c]:a.getAttribute(c),e=d+"",f=b[2],g=b[4];return d==null?f==="!=":!f&&m.attr?d!=null:f==="="?e===g:f==="*="?e.indexOf(g)>=0:f==="~="?(" "+e+" ").indexOf(g)>=0:g?f==="!="?e!==g:f==="^="?e.indexOf(g)===0:f==="$="?e.substr(e.length-g.length)===g:f==="|="?e===g||e.substr(0,g.length+1)===g+"-":!1:e&&d!==!1},POS:function(a,b,c,d){var e=b[2],f=o.setFilters[e];if(f)return f(a,c,b,d)}}},p=o.match.POS,q=function(a,b){return"\\"+(b-0+1)};for(var r in o.match)o.match[r]=new RegExp(o.match[r].source+/(?![^\[]*\])(?![^\(]*\))/.source),o.leftMatch[r]=new RegExp(/(^(?:.|\r|\n)*?)/.source+o.match[r].source.replace(/\\(\d+)/g,q));var s=function(a,b){return a=Array.prototype.slice.call(a,0),b?(b.push.apply(b,a),b):a};try{Array.prototype.slice.call(H.documentElement.childNodes,0)[0].nodeType}catch(t){s=function(a,b){var c=0,d=b||[];if(g.call(a)==="[object Array]")Array.prototype.push.apply(d,a);else if(typeof a.length=="number")for(var e=a.length;c<e;c++)d.push(a[c]);else for(;a[c];c++)d.push(a[c]);return d}}var u,v;H.documentElement.compareDocumentPosition?u=function(a,b){return a===b?(h=!0,0):!a.compareDocumentPosition||!b.compareDocumentPosition?a.compareDocumentPosition?-1:1:a.compareDocumentPosition(b)&4?-1:1}:(u=function(a,b){if(a===b)return h=!0,0;if(a.sourceIndex&&b.sourceIndex)return a.sourceIndex-b.sourceIndex;var c,d,e=[],f=[],g=a.parentNode,i=b.parentNode,j=g;if(g===i)return v(a,b);if(!g)return-1;if(!i)return 1;while(j)e.unshift(j),j=j.parentNode;j=i;while(j)f.unshift(j),j=j.parentNode;c=e.length,d=f.length;for(var k=0;k<c&&k<d;k++)if(e[k]!==f[k])return v(e[k],f[k]);return k===c?v(a,f[k],-1):v(e[k],b,1)},v=function(a,b,c){if(a===b)return c;var d=a.nextSibling;while(d){if(d===b)return-1;d=d.nextSibling}return 1}),function(){var a=H.createElement("div"),c="script"+(new Date).getTime(),d=H.documentElement;a.innerHTML="<a name='"+c+"'/>",d.insertBefore(a,d.firstChild),H.getElementById(c)&&(o.find.ID=function(a,c,d){if(typeof c.getElementById!="undefined"&&!d){var e=c.getElementById(a[1]);return e?e.id===a[1]||typeof e.getAttributeNode!="undefined"&&e.getAttributeNode("id").nodeValue===a[1]?[e]:b:[]}},o.filter.ID=function(a,b){var c=typeof a.getAttributeNode!="undefined"&&a.getAttributeNode("id");return a.nodeType===1&&c&&c.nodeValue===b}),d.removeChild(a),d=a=null}(),function(){var a=H.createElement("div");a.appendChild(H.createComment("")),a.getElementsByTagName("*").length>0&&(o.find.TAG=function(a,b){var c=b.getElementsByTagName(a[1]);if(a[1]==="*"){var d=[];for(var e=0;c[e];e++)c[e].nodeType===1&&d.push(c[e]);c=d}return c}),a.innerHTML="<a href='#'></a>",a.firstChild&&typeof a.firstChild.getAttribute!="undefined"&&a.firstChild.getAttribute("href")!=="#"&&(o.attrHandle.href=function(a){return a.getAttribute("href",2)}),a=null}(),H.querySelectorAll&&function(){var a=m,b=H.createElement("div"),c="__sizzle__";b.innerHTML="<p class='TEST'></p>";if(!b.querySelectorAll||b.querySelectorAll(".TEST").length!==0){m=function(b,d,e,f){d=d||H;if(!f&&!m.isXML(d)){var g=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(g&&(d.nodeType===1||d.nodeType===9)){if(g[1])return s(d.getElementsByTagName(b),e);if(g[2]&&o.find.CLASS&&d.getElementsByClassName)return s(d.getElementsByClassName(g[2]),e)}if(d.nodeType===9){if(b==="body"&&d.body)return s([d.body],e);if(g&&g[3]){var h=d.getElementById(g[3]);if(!h||!h.parentNode)return s([],e);if(h.id===g[3])return s([h],e)}try{return s(d.querySelectorAll(b),e)}catch(i){}}else if(d.nodeType===1&&d.nodeName.toLowerCase()!=="object"){var j=d,k=d.getAttribute("id"),l=k||c,n=d.parentNode,p=/^\s*[+~]/.test(b);k?l=l.replace(/'/g,"\\$&"):d.setAttribute("id",l),p&&n&&(d=d.parentNode);try{if(!p||n)return s(d.querySelectorAll("[id='"+l+"'] "+b),e)}catch(q){}finally{k||j.removeAttribute("id")}}}return a(b,d,e,f)};for(var d in a)m[d]=a[d];b=null}}(),function(){var a=H.documentElement,b=a.matchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.msMatchesSelector;if(b){var c=!b.call(H.createElement("div"),"div"),d=!1;try{b.call(H.documentElement,"[test!='']:sizzle")}catch(e){d=!0}m.matchesSelector=function(a,e){e=e.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!m.isXML(a))try{if(d||!o.match.PSEUDO.test(e)&&!/!=/.test(e)){var f=b.call(a,e);if(f||!c||a.document&&a.document.nodeType!==11)return f}}catch(g){}return m(e,null,null,[a]).length>0}}}(),function(){var a=H.createElement("div");a.innerHTML="<div class='test e'></div><div class='test'></div>";if(!!a.getElementsByClassName&&a.getElementsByClassName("e").length!==0){a.lastChild.className="e";if(a.getElementsByClassName("e").length===1)return;o.order.splice(1,0,"CLASS"),o.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!="undefined"&&!c)return b.getElementsByClassName(a[1])},a=null}}(),H.documentElement.contains?m.contains=function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:H.documentElement.compareDocumentPosition?m.contains=function(a,b){return!!(a.compareDocumentPosition(b)&16)}:m.contains=function(){return!1},m.isXML=function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1};var w=function(a,b,c){var d,e=[],f="",g=b.nodeType?[b]:b;while(d=o.match.PSEUDO.exec(a))f+=d[0],a=a.replace(o.match.PSEUDO,"");a=o.relative[a]?a+"*":a;for(var h=0,i=g.length;h<i;h++)m(a,g[h],e,c);return m.filter(f,e)};m.attr=K.attr,m.selectors.attrMap={},K.find=m,K.expr=m.selectors,K.expr[":"]=K.expr.filters,K.unique=m.uniqueSort,K.text=m.getText,K.isXMLDoc=m.isXML,K.contains=m.contains}();var ib=/Until$/,jb=/^(?:parents|prevUntil|prevAll)/,kb=/,/,lb=/^.[^:#\[\.,]*$/,mb=Array.prototype.slice,nb=K.expr.match.POS,ob={children:!0,contents:!0,next:!0,prev:!0};K.fn.extend({find:function(a){var b=this,c,d;if(typeof a!="string")return K(a).filter(function(){for(c=0,d=b.length;c<d;c++)if(K.contains(b[c],this))return!0});var e=this.pushStack("","find",a),f,g,h;for(c=0,d=this.length;c<d;c++){f=e.length,K.find(a,this[c],e);if(c>0)for(g=f;g<e.length;g++)for(h=0;h<f;h++)if(e[h]===e[g]){e.splice(g--,1);break}}return e},has:function(a){var b=K(a);return this.filter(function(){for(var a=0,c=b.length;a<c;a++)if(K.contains(this,b[a]))return!0})},not:function(a){return this.pushStack(z(this,a,!1),"not",a)},filter:function(a){return this.pushStack(z(this,a,!0),"filter",a)},is:function(a){return!!a&&(typeof a=="string"?nb.test(a)?K(a,this.context).index(this[0])>=0:K.filter(a,this).length>0:this.filter(a).length>0)},closest:function(a,b){var c=[],d,e,f=this[0];if(K.isArray(a)){var g=1;while(f&&f.ownerDocument&&f!==b){for(d=0;d<a.length;d++)K(f).is(a[d])&&c.push({selector:a[d],elem:f,level:g});f=f.parentNode,g++}return c}var h=nb.test(a)||typeof a!="string"?K(a,b||this.context):0;for(d=0,e=this.length;d<e;d++){f=this[d];while(f){if(h?h.index(f)>-1:K.find.matchesSelector(f,a)){c.push(f);break}f=f.parentNode;if(!f||!f.ownerDocument||f===b||f.nodeType===11)break}}return c=c.length>1?K.unique(c):c,this.pushStack(c,"closest",a)},index:function(a){return a?typeof a=="string"?K.inArray(this[0],K(a)):K.inArray(a.jquery?a[0]:a,this):this[0]&&this[0].parentNode?this.prevAll().length:-1},add:function(a,b){var c=typeof a=="string"?K(a,b):K.makeArray(a&&a.nodeType?[a]:a),d=K.merge(this.get(),c);return this.pushStack(A(c[0])||A(d[0])?d:K.unique(d))},andSelf:function(){return this.add(this.prevObject)}}),K.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return K.dir(a,"parentNode")},parentsUntil:function(a,b,c){return K.dir(a,"parentNode",c)},next:function(a){return K.nth(a,2,"nextSibling")},prev:function(a){return K.nth(a,2,"previousSibling")},nextAll:function(a){return K.dir(a,"nextSibling")},prevAll:function(a){return K.dir(a,"previousSibling")},nextUntil:function(a,b,c){return K.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return K.dir(a,"previousSibling",c)},siblings:function(a){return K.sibling(a.parentNode.firstChild,a)},children:function(a){return K.sibling(a.firstChild)},contents:function(a){return K.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:K.makeArray(a.childNodes)}},function(a,b){K.fn[a]=function(c,d){var e=K.map(this,b,c);return ib.test(a)||(d=c),d&&typeof d=="string"&&(e=K.filter(d,e)),e=this.length>1&&!ob[a]?K.unique(e):e,(this.length>1||kb.test(d))&&jb.test(a)&&(e=e.reverse()),this.pushStack(e,a,mb.call(arguments).join(","))}}),K.extend({filter:function(a,b,c){return c&&(a=":not("+a+")"),b.length===1?K.find.matchesSelector(b[0],a)?[b[0]]:[]:K.find.matches(a,b)},dir:function(a,c,d){var e=[],f=a[c];while(f&&f.nodeType!==9&&(d===b||f.nodeType!==1||!K(f).is(d)))f.nodeType===1&&e.push(f),f=f[c];return e},nth:function(a,b,c,d){b=b||1;var e=0;for(;a;a=a[c])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var pb="abbr|article|aside|audio|canvas|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",qb=/ jQuery\d+="(?:\d+|null)"/g,rb=/^\s+/,sb=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,tb=/<([\w:]+)/,ub=/<tbody/i,vb=/<|&#?\w+;/,wb=/<(?:script|style)/i,xb=/<(?:script|object|embed|option|style)/i,yb=new RegExp("<(?:"+pb+")","i"),zb=/checked\s*(?:[^=]|=\s*.checked.)/i,Ab=/\/(java|ecma)script/i,Bb=/^\s*<!(?:\[CDATA\[|\-\-)/,Cb={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],area:[1,"<map>","</map>"],_default:[0,"",""]},Db=y(H);Cb.optgroup=Cb.option,Cb.tbody=Cb.tfoot=Cb.colgroup=Cb.caption=Cb.thead,Cb.th=Cb.td,K.support.htmlSerialize||(Cb._default=[1,"div<div>","</div>"]),K.fn.extend({text:function(a){return K.isFunction(a)?this.each(function(b){var c=K(this);c.text(a.call(this,b,c.text()))}):typeof a!="object"&&a!==b?this.empty().append((this[0]&&this[0].ownerDocument||H).createTextNode(a)):K.text(this)},wrapAll:function(a){if(K.isFunction(a))return this.each(function(b){K(this).wrapAll(a.call(this,b))});if(this[0]){var b=K(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){return K.isFunction(a)?this.each(function(b){K(this).wrapInner(a.call(this,b))}):this.each(function(){var b=K(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=K.isFunction(a);return this.each(function(c){K(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){K.nodeName(this,"body")||K(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=K.clean(arguments);return a.push.apply(a,this.toArray()),this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=this.pushStack(this,"after",arguments);return a.push.apply(a,K.clean(arguments)),a}},remove:function(a,b){for(var c=0,d;(d=this[c])!=null;c++)if(!a||K.filter(a,[d]).length)!b&&d.nodeType===1&&(K.cleanData(d.getElementsByTagName("*")),K.cleanData([d])),d.parentNode&&d.parentNode.removeChild(d);return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++){b.nodeType===1&&K.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){return a=a==null?!1:a,b=b==null?a:b,this.map(function(){return K.clone(this,a,b)})},html:function(a){if(a===b)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(qb,""):null;if(typeof a=="string"&&!wb.test(a)&&(K.support.leadingWhitespace||!rb.test(a))&&!Cb[(tb.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(sb,"<$1></$2>"
3
- );try{for(var c=0,d=this.length;c<d;c++)this[c].nodeType===1&&(K.cleanData(this[c].getElementsByTagName("*")),this[c].innerHTML=a)}catch(e){this.empty().append(a)}}else K.isFunction(a)?this.each(function(b){var c=K(this);c.html(a.call(this,b,c.html()))}):this.empty().append(a);return this},replaceWith:function(a){return this[0]&&this[0].parentNode?K.isFunction(a)?this.each(function(b){var c=K(this),d=c.html();c.replaceWith(a.call(this,b,d))}):(typeof a!="string"&&(a=K(a).detach()),this.each(function(){var b=this.nextSibling,c=this.parentNode;K(this).remove(),b?K(b).before(a):K(c).append(a)})):this.length?this.pushStack(K(K.isFunction(a)?a():a),"replaceWith",a):this},detach:function(a){return this.remove(a,!0)},domManip:function(a,c,d){var e,f,g,h,i=a[0],j=[];if(!K.support.checkClone&&arguments.length===3&&typeof i=="string"&&zb.test(i))return this.each(function(){K(this).domManip(a,c,d,!0)});if(K.isFunction(i))return this.each(function(e){var f=K(this);a[0]=i.call(this,e,c?f.html():b),f.domManip(a,c,d)});if(this[0]){h=i&&i.parentNode,K.support.parentNode&&h&&h.nodeType===11&&h.childNodes.length===this.length?e={fragment:h}:e=K.buildFragment(a,this,j),g=e.fragment,g.childNodes.length===1?f=g=g.firstChild:f=g.firstChild;if(f){c=c&&K.nodeName(f,"tr");for(var k=0,l=this.length,m=l-1;k<l;k++)d.call(c?x(this[k],f):this[k],e.cacheable||l>1&&k<m?K.clone(g,!0,!0):g)}j.length&&K.each(j,q)}return this}}),K.buildFragment=function(a,b,c){var d,e,f,g,h=a[0];return b&&b[0]&&(g=b[0].ownerDocument||b[0]),g.createDocumentFragment||(g=H),a.length===1&&typeof h=="string"&&h.length<512&&g===H&&h.charAt(0)==="<"&&!xb.test(h)&&(K.support.checkClone||!zb.test(h))&&(K.support.html5Clone||!yb.test(h))&&(e=!0,f=K.fragments[h],f&&f!==1&&(d=f)),d||(d=g.createDocumentFragment(),K.clean(a,g,d,c)),e&&(K.fragments[h]=f?d:1),{fragment:d,cacheable:e}},K.fragments={},K.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){K.fn[a]=function(c){var d=[],e=K(c),f=this.length===1&&this[0].parentNode;if(f&&f.nodeType===11&&f.childNodes.length===1&&e.length===1)return e[b](this[0]),this;for(var g=0,h=e.length;g<h;g++){var i=(g>0?this.clone(!0):this).get();K(e[g])[b](i),d=d.concat(i)}return this.pushStack(d,a,e.selector)}}),K.extend({clone:function(a,b,c){var d,e,f,g=K.support.html5Clone||!yb.test("<"+a.nodeName)?a.cloneNode(!0):r(a);if((!K.support.noCloneEvent||!K.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!K.isXMLDoc(a)){v(a,g),d=u(a),e=u(g);for(f=0;d[f];++f)e[f]&&v(d[f],e[f])}if(b){w(a,g);if(c){d=u(a),e=u(g);for(f=0;d[f];++f)w(d[f],e[f])}}return d=e=null,g},clean:function(a,b,c,d){var e;b=b||H,typeof b.createElement=="undefined"&&(b=b.ownerDocument||b[0]&&b[0].ownerDocument||H);var f=[],g;for(var h=0,i;(i=a[h])!=null;h++){typeof i=="number"&&(i+="");if(!i)continue;if(typeof i=="string")if(!vb.test(i))i=b.createTextNode(i);else{i=i.replace(sb,"<$1></$2>");var j=(tb.exec(i)||["",""])[1].toLowerCase(),k=Cb[j]||Cb._default,l=k[0],m=b.createElement("div");b===H?Db.appendChild(m):y(b).appendChild(m),m.innerHTML=k[1]+i+k[2];while(l--)m=m.lastChild;if(!K.support.tbody){var n=ub.test(i),o=j==="table"&&!n?m.firstChild&&m.firstChild.childNodes:k[1]==="<table>"&&!n?m.childNodes:[];for(g=o.length-1;g>=0;--g)K.nodeName(o[g],"tbody")&&!o[g].childNodes.length&&o[g].parentNode.removeChild(o[g])}!K.support.leadingWhitespace&&rb.test(i)&&m.insertBefore(b.createTextNode(rb.exec(i)[0]),m.firstChild),i=m.childNodes}var p;if(!K.support.appendChecked)if(i[0]&&typeof (p=i.length)=="number")for(g=0;g<p;g++)s(i[g]);else s(i);i.nodeType?f.push(i):f=K.merge(f,i)}if(c){e=function(a){return!a.type||Ab.test(a.type)};for(h=0;f[h];h++)if(d&&K.nodeName(f[h],"script")&&(!f[h].type||f[h].type.toLowerCase()==="text/javascript"))d.push(f[h].parentNode?f[h].parentNode.removeChild(f[h]):f[h]);else{if(f[h].nodeType===1){var q=K.grep(f[h].getElementsByTagName("script"),e);f.splice.apply(f,[h+1,0].concat(q))}c.appendChild(f[h])}}return f},cleanData:function(a){var b,c,d=K.cache,e=K.event.special,f=K.support.deleteExpando;for(var g=0,h;(h=a[g])!=null;g++){if(h.nodeName&&K.noData[h.nodeName.toLowerCase()])continue;c=h[K.expando];if(c){b=d[c];if(b&&b.events){for(var i in b.events)e[i]?K.event.remove(h,i):K.removeEvent(h,i,b.handle);b.handle&&(b.handle.elem=null)}f?delete h[K.expando]:h.removeAttribute&&h.removeAttribute(K.expando),delete d[c]}}}});var Eb=/alpha\([^)]*\)/i,Fb=/opacity=([^)]*)/,Gb=/([A-Z]|^ms)/g,Hb=/^-?\d+(?:px)?$/i,Ib=/^-?\d/,Jb=/^([\-+])=([\-+.\de]+)/,Kb={position:"absolute",visibility:"hidden",display:"block"},Lb=["Left","Right"],Mb=["Top","Bottom"],Nb,Ob,Pb;K.fn.css=function(a,c){return arguments.length===2&&c===b?this:K.access(this,a,c,!0,function(a,c,d){return d!==b?K.style(a,c,d):K.css(a,c)})},K.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=Nb(a,"opacity","opacity");return c===""?"1":c}return a.style.opacity}}},cssNumber:{fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":K.support.cssFloat?"cssFloat":"styleFloat"},style:function(a,c,d,e){if(!!a&&a.nodeType!==3&&a.nodeType!==8&&!!a.style){var f,g,h=K.camelCase(c),i=a.style,j=K.cssHooks[h];c=K.cssProps[h]||h;if(d===b)return j&&"get"in j&&(f=j.get(a,!1,e))!==b?f:i[c];g=typeof d,g==="string"&&(f=Jb.exec(d))&&(d=+(f[1]+1)*+f[2]+parseFloat(K.css(a,c)),g="number");if(d==null||g==="number"&&isNaN(d))return;g==="number"&&!K.cssNumber[h]&&(d+="px");if(!j||!("set"in j)||(d=j.set(a,d))!==b)try{i[c]=d}catch(k){}}},css:function(a,c,d){var e,f;c=K.camelCase(c),f=K.cssHooks[c],c=K.cssProps[c]||c,c==="cssFloat"&&(c="float");if(f&&"get"in f&&(e=f.get(a,!0,d))!==b)return e;if(Nb)return Nb(a,c)},swap:function(a,b,c){var d={};for(var e in b)d[e]=a.style[e],a.style[e]=b[e];c.call(a);for(e in b)a.style[e]=d[e]}}),K.curCSS=K.css,K.each(["height","width"],function(a,b){K.cssHooks[b]={get:function(a,c,d){var e;if(c)return a.offsetWidth!==0?p(a,b,d):(K.swap(a,Kb,function(){e=p(a,b,d)}),e)},set:function(a,b){if(!Hb.test(b))return b;b=parseFloat(b);if(b>=0)return b+"px"}}}),K.support.opacity||(K.cssHooks.opacity={get:function(a,b){return Fb.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=K.isNumeric(b)?"alpha(opacity="+b*100+")":"",f=d&&d.filter||c.filter||"";c.zoom=1;if(b>=1&&K.trim(f.replace(Eb,""))===""){c.removeAttribute("filter");if(d&&!d.filter)return}c.filter=Eb.test(f)?f.replace(Eb,e):f+" "+e}}),K(function(){K.support.reliableMarginRight||(K.cssHooks.marginRight={get:function(a,b){var c;return K.swap(a,{display:"inline-block"},function(){b?c=Nb(a,"margin-right","marginRight"):c=a.style.marginRight}),c}})}),H.defaultView&&H.defaultView.getComputedStyle&&(Ob=function(a,b){var c,d,e;return b=b.replace(Gb,"-$1").toLowerCase(),(d=a.ownerDocument.defaultView)&&(e=d.getComputedStyle(a,null))&&(c=e.getPropertyValue(b),c===""&&!K.contains(a.ownerDocument.documentElement,a)&&(c=K.style(a,b))),c}),H.documentElement.currentStyle&&(Pb=function(a,b){var c,d,e,f=a.currentStyle&&a.currentStyle[b],g=a.style;return f===null&&g&&(e=g[b])&&(f=e),!Hb.test(f)&&Ib.test(f)&&(c=g.left,d=a.runtimeStyle&&a.runtimeStyle.left,d&&(a.runtimeStyle.left=a.currentStyle.left),g.left=b==="fontSize"?"1em":f||0,f=g.pixelLeft+"px",g.left=c,d&&(a.runtimeStyle.left=d)),f===""?"auto":f}),Nb=Ob||Pb,K.expr&&K.expr.filters&&(K.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!K.support.reliableHiddenOffsets&&(a.style&&a.style.display||K.css(a,"display"))==="none"},K.expr.filters.visible=function(a){return!K.expr.filters.hidden(a)});var Qb=/%20/g,Rb=/\[\]$/,Sb=/\r?\n/g,Tb=/#.*$/,Ub=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,Vb=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,Wb=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,Xb=/^(?:GET|HEAD)$/,Yb=/^\/\//,Zb=/\?/,$b=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,_b=/^(?:select|textarea)/i,ac=/\s+/,bc=/([?&])_=[^&]*/,cc=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,dc=K.fn.load,ec={},fc={},gc,hc,ic=["*/"]+["*"];try{gc=J.href}catch(jc){gc=H.createElement("a"),gc.href="",gc=gc.href}hc=cc.exec(gc.toLowerCase())||[],K.fn.extend({load:function(a,c,d){if(typeof a!="string"&&dc)return dc.apply(this,arguments);if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var f=a.slice(e,a.length);a=a.slice(0,e)}var g="GET";c&&(K.isFunction(c)?(d=c,c=b):typeof c=="object"&&(c=K.param(c,K.ajaxSettings.traditional),g="POST"));var h=this;return K.ajax({url:a,type:g,dataType:"html",data:c,complete:function(a,b,c){c=a.responseText,a.isResolved()&&(a.done(function(a){c=a}),h.html(f?K("<div>").append(c.replace($b,"")).find(f):c)),d&&h.each(d,[c,b,a])}}),this},serialize:function(){return K.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?K.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||_b.test(this.nodeName)||Vb.test(this.type))}).map(function(a,b){var c=K(this).val();return c==null?null:K.isArray(c)?K.map(c,function(a,c){return{name:b.name,value:a.replace(Sb,"\r\n")}}):{name:b.name,value:c.replace(Sb,"\r\n")}}).get()}}),K.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){K.fn[b]=function(a){return this.on(b,a)}}),K.each(["get","post"],function(a,c){K[c]=function(a,d,e,f){return K.isFunction(d)&&(f=f||e,e=d,d=b),K.ajax({type:c,url:a,data:d,success:e,dataType:f})}}),K.extend({getScript:function(a,c){return K.get(a,b,c,"script")},getJSON:function(a,b,c){return K.get(a,b,c,"json")},ajaxSetup:function(a,b){return b?m(a,K.ajaxSettings):(b=a,a=K.ajaxSettings),m(a,b),a},ajaxSettings:{url:gc,isLocal:Wb.test(hc[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":ic},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":K.parseJSON,"text xml":K.parseXML},flatOptions:{context:!0,url:!0}},ajaxPrefilter:o(ec),ajaxTransport:o(fc),ajax:function(a,c){function d(a,c,d,n){if(v!==2){v=2,t&&clearTimeout(t),s=b,q=n||"",y.readyState=a>0?4:0;var o,p,r,u=c,x=d?k(e,y,d):b,z,A;if(a>=200&&a<300||a===304){if(e.ifModified){if(z=y.getResponseHeader("Last-Modified"))K.lastModified[m]=z;if(A=y.getResponseHeader("Etag"))K.etag[m]=A}if(a===304)u="notmodified",o=!0;else try{p=j(e,x),u="success",o=!0}catch(B){u="parsererror",r=B}}else{r=u;if(!u||a)u="error",a<0&&(a=0)}y.status=a,y.statusText=""+(c||u),o?h.resolveWith(f,[p,u,y]):h.rejectWith(f,[y,u,r]),y.statusCode(l),l=b,w&&g.trigger("ajax"+(o?"Success":"Error"),[y,e,o?p:r]),i.fireWith(f,[y,u]),w&&(g.trigger("ajaxComplete",[y,e]),--K.active||K.event.trigger("ajaxStop"))}}typeof a=="object"&&(c=a,a=b),c=c||{};var e=K.ajaxSetup({},c),f=e.context||e,g=f!==e&&(f.nodeType||f instanceof K)?K(f):K.event,h=K.Deferred(),i=K.Callbacks("once memory"),l=e.statusCode||{},m,o={},p={},q,r,s,t,u,v=0,w,x,y={readyState:0,setRequestHeader:function(a,b){if(!v){var c=a.toLowerCase();a=p[c]=p[c]||a,o[a]=b}return this},getAllResponseHeaders:function(){return v===2?q:null},getResponseHeader:function(a){var c;if(v===2){if(!r){r={};while(c=Ub.exec(q))r[c[1].toLowerCase()]=c[2]}c=r[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){return v||(e.mimeType=a),this},abort:function(a){return a=a||"abort",s&&s.abort(a),d(0,a),this}};h.promise(y),y.success=y.done,y.error=y.fail,y.complete=i.add,y.statusCode=function(a){if(a){var b;if(v<2)for(b in a)l[b]=[l[b],a[b]];else b=a[y.status],y.then(b,b)}return this},e.url=((a||e.url)+"").replace(Tb,"").replace(Yb,hc[1]+"//"),e.dataTypes=K.trim(e.dataType||"*").toLowerCase().split(ac),e.crossDomain==null&&(u=cc.exec(e.url.toLowerCase()),e.crossDomain=!(!u||u[1]==hc[1]&&u[2]==hc[2]&&(u[3]||(u[1]==="http:"?80:443))==(hc[3]||(hc[1]==="http:"?80:443)))),e.data&&e.processData&&typeof e.data!="string"&&(e.data=K.param(e.data,e.traditional)),n(ec,e,c,y);if(v===2)return!1;w=e.global,e.type=e.type.toUpperCase(),e.hasContent=!Xb.test(e.type),w&&K.active++===0&&K.event.trigger("ajaxStart");if(!e.hasContent){e.data&&(e.url+=(Zb.test(e.url)?"&":"?")+e.data,delete e.data),m=e.url;if(e.cache===!1){var z=K.now(),A=e.url.replace(bc,"$1_="+z);e.url=A+(A===e.url?(Zb.test(e.url)?"&":"?")+"_="+z:"")}}(e.data&&e.hasContent&&e.contentType!==!1||c.contentType)&&y.setRequestHeader("Content-Type",e.contentType),e.ifModified&&(m=m||e.url,K.lastModified[m]&&y.setRequestHeader("If-Modified-Since",K.lastModified[m]),K.etag[m]&&y.setRequestHeader("If-None-Match",K.etag[m])),y.setRequestHeader("Accept",e.dataTypes[0]&&e.accepts[e.dataTypes[0]]?e.accepts[e.dataTypes[0]]+(e.dataTypes[0]!=="*"?", "+ic+"; q=0.01":""):e.accepts["*"]);for(x in e.headers)y.setRequestHeader(x,e.headers[x]);if(!e.beforeSend||e.beforeSend.call(f,y,e)!==!1&&v!==2){for(x in{success:1,error:1,complete:1})y[x](e[x]);s=n(fc,e,c,y);if(!s)d(-1,"No Transport");else{y.readyState=1,w&&g.trigger("ajaxSend",[y,e]),e.async&&e.timeout>0&&(t=setTimeout(function(){y.abort("timeout")},e.timeout));try{v=1,s.send(o,d)}catch(B){if(!(v<2))throw B;d(-1,B)}}return y}return y.abort(),!1},param:function(a,c){var d=[],e=function(a,b){b=K.isFunction(b)?b():b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};c===b&&(c=K.ajaxSettings.traditional);if(K.isArray(a)||a.jquery&&!K.isPlainObject(a))K.each(a,function(){e(this.name,this.value)});else for(var f in a)l(f,a[f],c,e);return d.join("&").replace(Qb,"+")}}),K.extend({active:0,lastModified:{},etag:{}});var kc=K.now(),lc=/(\=)\?(&|$)|\?\?/i;K.ajaxSetup({jsonp:"callback",jsonpCallback:function(){return K.expando+"_"+kc++}}),K.ajaxPrefilter("json jsonp",function(b,c,d){var e=b.contentType==="application/x-www-form-urlencoded"&&typeof b.data=="string";if(b.dataTypes[0]==="jsonp"||b.jsonp!==!1&&(lc.test(b.url)||e&&lc.test(b.data))){var f,g=b.jsonpCallback=K.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,h=a[g],i=b.url,j=b.data,k="$1"+g+"$2";return b.jsonp!==!1&&(i=i.replace(lc,k),b.url===i&&(e&&(j=j.replace(lc,k)),b.data===j&&(i+=(/\?/.test(i)?"&":"?")+b.jsonp+"="+g))),b.url=i,b.data=j,a[g]=function(a){f=[a]},d.always(function(){a[g]=h,f&&K.isFunction(h)&&a[g](f[0])}),b.converters["script json"]=function(){return f||K.error(g+" was not called"),f[0]},b.dataTypes[0]="json","script"}}),K.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){return K.globalEval(a),a}}}),K.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),K.ajaxTransport("script",function(a){if(a.crossDomain){var c,d=H.head||H.getElementsByTagName("head")[0]||H.documentElement;return{send:function(e,f){c=H.createElement("script"),c.async="async",a.scriptCharset&&(c.charset=a.scriptCharset),c.src=a.url,c.onload=c.onreadystatechange=function(a,e){if(e||!c.readyState||/loaded|complete/.test(c.readyState))c.onload=c.onreadystatechange=null,d&&c.parentNode&&d.removeChild(c),c=b,e||f(200,"success")},d.insertBefore(c,d.firstChild)},abort:function(){c&&c.onload(0,1)}}}});var mc=a.ActiveXObject?function(){for(var a in oc)oc[a](0,1)}:!1,nc=0,oc;K.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&i()||h()}:i,function(a){K.extend(K.support,{ajax:!!a,cors:!!a&&"withCredentials"in a})}(K.ajaxSettings.xhr()),K.support.ajax&&K.ajaxTransport(function(c){if(!c.crossDomain||K.support.cors){var d;return{send:function(e,f){var g=c.xhr(),h,i;c.username?g.open(c.type,c.url,c.async,c.username,c.password):g.open(c.type,c.url,c.async);if(c.xhrFields)for(i in c.xhrFields)g[i]=c.xhrFields[i];c.mimeType&&g.overrideMimeType&&g.overrideMimeType(c.mimeType),!c.crossDomain&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(i in e)g.setRequestHeader(i,e[i])}catch(j){}g.send(c.hasContent&&c.data||null),d=function(a,e){var i,j,k,l,m;try{if(d&&(e||g.readyState===4)){d=b,h&&(g.onreadystatechange=K.noop,mc&&delete oc[h]);if(e)g.readyState!==4&&g.abort();else{i=g.status,k=g.getAllResponseHeaders(),l={},m=g.responseXML,m&&m.documentElement&&(l.xml=m),l.text=g.responseText;try{j=g.statusText}catch(n){j=""}!i&&c.isLocal&&!c.crossDomain?i=l.text?200:404:i===1223&&(i=204)}}}catch(o){e||f(-1,o)}l&&f(i,j,l,k)},!c.async||g.readyState===4?d():(h=++nc,mc&&(oc||(oc={},K(a).unload(mc)),oc[h]=d),g.onreadystatechange=d)},abort:function(){d&&d(0,1)}}}});var pc={},qc,rc,sc=/^(?:toggle|show|hide)$/,tc=/^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,uc,vc=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]],wc;K.fn.extend({show:function(a,b,c){var f,g;if(a||a===0)return this.animate(e("show",3),a,b,c);for(var h=0,i=this.length;h<i;h++)f=this[h],f.style&&(g=f.style.display,!K._data(f,"olddisplay")&&g==="none"&&(g=f.style.display=""),g===""&&K.css(f,"display")==="none"&&K._data(f,"olddisplay",d(f.nodeName)));for(h=0;h<i;h++){f=this[h];if(f.style){g=f.style.display;if(g===""||g==="none")f.style.display=K._data(f,"olddisplay")||""}}return this},hide:function(a,b,c){if(a||a===0)return this.animate(e("hide",3),a,b,c);var d,f,g=0,h=this.length;for(;g<h;g++)d=this[g],d.style&&(f=K.css(d,"display"),f!=="none"&&!K._data(d,"olddisplay")&&K._data(d,"olddisplay",f));for(g=0;g<h;g++)this[g].style&&(this[g].style.display="none");return this},_toggle:K.fn.toggle,toggle:function(a,b,c){var d=typeof a=="boolean";return K.isFunction(a)&&K.isFunction(b)?this._toggle.apply(this,arguments):a==null||d?this.each(function(){var b=d?a:K(this).is(":hidden");K(this)[b?"show":"hide"]()}):this.animate(e("toggle",3),a,b,c),this},fadeTo:function(a,b,c,d){return this.filter(":hidden").css("opacity",0).show().end().animate({opacity:b},a,c,d)},animate:function(a,b,c,e){function f(){g.queue===!1&&K._mark(this);var b=K.extend({},g),c=this.nodeType===1,e=c&&K(this).is(":hidden"),f,h,i,j,k,l,m,n,o;b.animatedProperties={};for(i in a){f=K.camelCase(i),i!==f&&(a[f]=a[i],delete a[i]),h=a[f],K.isArray(h)?(b.animatedProperties[f]=h[1],h=a[f]=h[0]):b.animatedProperties[f]=b.specialEasing&&b.specialEasing[f]||b.easing||"swing";if(h==="hide"&&e||h==="show"&&!e)return b.complete.call(this);c&&(f==="height"||f==="width")&&(b.overflow=[this.style.overflow,this.style.overflowX,this.style.overflowY],K.css(this,"display")==="inline"&&K.css(this,"float")==="none"&&(!K.support.inlineBlockNeedsLayout||d(this.nodeName)==="inline"?this.style.display="inline-block":this.style.zoom=1))}b.overflow!=null&&(this.style.overflow="hidden");for(i in a)j=new K.fx(this,b,i),h=a[i],sc.test(h)?(o=K._data(this,"toggle"+i)||(h==="toggle"?e?"show":"hide":0),o?(K._data(this,"toggle"+i,o==="show"?"hide":"show"),j[o]()):j[h]()):(k=tc.exec(h),l=j.cur(),k?(m=parseFloat(k[2]),n=k[3]||(K.cssNumber[i]?"":"px"),n!=="px"&&(K.style(this,i,(m||1)+n),l=(m||1)/j.cur()*l,K.style(this,i,l+n)),k[1]&&(m=(k[1]==="-="?-1:1)*m+l),j.custom(l,m,n)):j.custom(l,h,""));return!0}var g=K.speed(b,c,e);return K.isEmptyObject(a)?this.each(g.complete,[!1]):(a=K.extend({},a),g.queue===!1?this.each(f):this.queue(g.queue,f))},stop:function(a,c,d){return typeof a!="string"&&(d=c,c=a,a=b),c&&a!==!1&&this.queue(a||"fx",[]),this.each(function(){function b(a,b,c){var e=b[c];K.removeData(a,c,!0),e.stop(d)}var c,e=!1,f=K.timers,g=K._data(this);d||K._unmark(!0,this);if(a==null)for(c in g)g[c]&&g[c].stop&&c.indexOf(".run")===c.length-4&&b(this,g,c);else g[c=a+".run"]&&g[c].stop&&b(this,g,c);for(c=f.length;c--;)f[c].elem===this&&(a==null||f[c].queue===a)&&(d?f[c](!0):f[c].saveState(),e=!0,f.splice(c,1));(!d||!e)&&K.dequeue(this,a)})}}),K.each({slideDown:e("show",1),slideUp:e("hide",1),slideToggle:e("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){K.fn[a]=function(a,c,d){return this.animate(b,a,c,d)}}),K.extend({speed:function(a,b,c){var d=a&&typeof a=="object"?K.extend({},a):{complete:c||!c&&b||K.isFunction(a)&&a,duration:a,easing:c&&b||b&&!K.isFunction(b)&&b};d.duration=K.fx.off?0:typeof d.duration=="number"?d.duration:d.duration in K.fx.speeds?K.fx.speeds[d.duration]:K.fx.speeds._default;if(d.queue==null||d.queue===!0)d.queue="fx";return d.old=d.complete,d.complete=function(a){K.isFunction(d.old)&&d.old.call(this),d.queue?K.dequeue(this,d.queue):a!==!1&&K._unmark(this)},d},easing:{linear:function(a,b,c,d){return c+d*a},swing:function(a,b,c,d){return(-Math.cos(a*Math.PI)/2+.5)*d+c}},timers:[],fx:function(a,b,c){this.options=b,this.elem=a,this.prop=c,b.orig=b.orig||{}}}),K.fx.prototype={update:function(){this.options.step&&this.options.step.call(this.elem,this.now,this),(K.fx.step[this.prop]||K.fx.step._default)(this)},cur:function(){if(this.elem[this.prop]==null||!!this.elem.style&&this.elem.style[this.prop]!=null){var a,b=K.css(this.elem,this.prop);return isNaN(a=parseFloat(b))?!b||b==="auto"?0:b:a}return this.elem[this.prop]},custom:function(a,c,d){function e(a){return f.step(a)}var f=this,h=K.fx;this.startTime=wc||g(),this.end=c,this.now=this.start=a,this.pos=this.state=0,this.unit=d||this.unit||(K.cssNumber[this.prop]?"":"px"),e.queue=this.options.queue,e.elem=this.elem,e.saveState=function(){f.options.hide&&K._data(f.elem,"fxshow"+f.prop)===b&&K._data(f.elem,"fxshow"+f.prop,f.start)},e()&&K.timers.push(e)&&!uc&&(uc=setInterval(h.tick,h.interval))},show:function(){var a=K._data(this.elem,"fxshow"+this.prop);this.options.orig[this.prop]=a||K.style(this.elem,this.prop),this.options.show=!0,a!==b?this.custom(this.cur(),a):this.custom(this.prop==="width"||this.prop==="height"?1:0,this.cur()),K(this.elem).show()},hide:function(){this.options.orig[this.prop]=K._data(this.elem,"fxshow"+this.prop)||K.style(this.elem,this.prop),this.options.hide=!0,this.custom(this.cur(),0)},step:function(a){var b,c,d,e=wc||g(),f=!0,h=this.elem,i=this.options;if(a||e>=i.duration+this.startTime){this.now=this.end,this.pos=this.state=1,this.update(),i.animatedProperties[this.prop]=!0;for(b in i.animatedProperties)i.animatedProperties[b]!==!0&&(f=!1);if(f){i.overflow!=null&&!K.support.shrinkWrapBlocks&&K.each(["","X","Y"],function(a,b){h.style["overflow"+b]=i.overflow[a]}),i.hide&&K(h).hide();if(i.hide||i.show)for(b in i.animatedProperties)K.style(h,b,i.orig[b]),K.removeData(h,"fxshow"+b,!0),K.removeData(h,"toggle"+b,!0);d=i.complete,d&&(i.complete=!1,d.call(h))}return!1}return i.duration==Infinity?this.now=e:(c=e-this.startTime,this.state=c/i.duration,this.pos=K.easing[i.animatedProperties[this.prop]](this.state,c,0,1,i.duration),this.now=this.start+(this.end-this.start)*this.pos),this.update(),!0}},K.extend(K.fx,{tick:function(){var a,b=K.timers,c=0;for(;c<b.length;c++)a=b[c],!a()&&b[c]===a&&b.splice(c--,1);b.length||K.fx.stop()},interval:13,stop:function(){clearInterval(uc),uc=null},speeds:{slow:600,fast:200,_default:400},step:{opacity:function(a){K.style(a.elem,"opacity",a.now)},_default:function(a){a.elem.style&&a.elem.style[a.prop]!=null?a.elem.style[a.prop]=a.now+a.unit:a.elem[a.prop]=a.now}}}),K.each(["width","height"],function(a,b){K.fx.step[b]=function(a){K.style(a.elem,b,Math.max(0,a.now)+a.unit)}}),K.expr&&K.expr.filters&&(K.expr.filters.animated=function(a){return K.grep(K.timers,function(b){return a===b.elem}).length});var xc=/^t(?:able|d|h)$/i,yc=/^(?:body|html)$/i;"getBoundingClientRect"in H.documentElement?K.fn.offset=function(a){var b=this[0],d;if(a)return this.each(function(b){K.offset.setOffset(this,a,b)});if(!b||!b.ownerDocument)return null;if(b===b.ownerDocument.body)return K.offset.bodyOffset(b);try{d=b.getBoundingClientRect()}catch(e){}var f=b.ownerDocument,g=f.documentElement;if(!d||!K.contains(g,b))return d?{top:d.top,left:d.left}:{top:0,left:0};var h=f.body,i=c(f),j=g.clientTop||h.clientTop||0,k=g.clientLeft||h.clientLeft||0,l=i.pageYOffset||K.support.boxModel&&g.scrollTop||h.scrollTop,m=i.pageXOffset||K.support.boxModel&&g.scrollLeft||h.scrollLeft,n=d.top+l-j,o=d.left+m-k;return{top:n,left:o}}:K.fn.offset=function(a){var b=this[0];if(a)return this.each(function(b){K.offset.setOffset(this,a,b)});if(!b||!b.ownerDocument)return null;if(b===b.ownerDocument.body)return K.offset.bodyOffset(b);var c,d=b.offsetParent,e=b,f=b.ownerDocument,g=f.documentElement,h=f.body,i=f.defaultView,j=i?i.getComputedStyle(b,null):b.currentStyle,k=b.offsetTop,l=b.offsetLeft;while((b=b.parentNode)&&b!==h&&b!==g){if(K.support.fixedPosition&&j.position==="fixed")break;c=i?i.getComputedStyle(b,null):b.currentStyle,k-=b.scrollTop,l-=b.scrollLeft,b===d&&(k+=b.offsetTop,l+=b.offsetLeft,K.support.doesNotAddBorder&&(!K.support.doesAddBorderForTableAndCells||!xc.test(b.nodeName))&&(k+=parseFloat(c.borderTopWidth)||0,l+=parseFloat(c.borderLeftWidth)||0),e=d,d=b.offsetParent),K.support.subtractsBorderForOverflowNotVisible&&c.overflow!=="visible"&&(k+=parseFloat(c.borderTopWidth)||0,l+=parseFloat(c.borderLeftWidth)||0),j=c}if(j.position==="relative"||j.position==="static")k+=h.offsetTop,l+=h.offsetLeft;return K.support.fixedPosition&&j.position==="fixed"&&(k+=Math.max(g.scrollTop,h.scrollTop),l+=Math.max(g.scrollLeft,h.scrollLeft)),{top:k,left:l}},K.offset={bodyOffset:function(a){var b=a.offsetTop,c=a.offsetLeft;return K.support.doesNotIncludeMarginInBodyOffset&&(b+=parseFloat(K.css(a,"marginTop"))||0,c+=parseFloat(K.css(a,"marginLeft"))||0),{top:b,left:c}},setOffset:function(a,b,c){var d=K.css(a,"position");d==="static"&&(a.style.position="relative");var e=K(a),f=e.offset(),g=K.css(a,"top"),h=K.css(a,"left"),i=(d==="absolute"||d==="fixed")&&K.inArray("auto",[g,h])>-1,j={},k={},l,m;i?(k=e.position(),l=k.top,m=k.left):(l=parseFloat(g)||0,m=parseFloat(h)||0),K.isFunction(b)&&(b=b.call(a,c,f)),b.top!=null&&(j.top=b.top-f.top+l),b.left!=null&&(j.left=b.left-f.left+m),"using"in b?b.using.call(a,j):e.css(j)}},K.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),c=this.offset(),d=yc.test(b[0].nodeName)?{top:0,left:0}:b.offset();return c.top-=parseFloat(K.css(a,"marginTop"))||0,c.left-=parseFloat(K.css(a,"marginLeft"))||0,d.top+=parseFloat(K.css(b[0],"borderTopWidth"))||0,d.left+=parseFloat(K.css(b[0],"borderLeftWidth"))||0,{top:c.top-d.top,left:c.left-d.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||H.body;while(a&&!yc.test(a.nodeName)&&K.css(a,"position")==="static")a=a.offsetParent;return a})}}),K.each(["Left","Top"],function(a,d){var e="scroll"+d;K.fn[e]=function(d){var f,g;return d===b?(f=this[0],f?(g=c(f),g?"pageXOffset"in g?g[a?"pageYOffset":"pageXOffset"]:K.support.boxModel&&g.document.documentElement[e]||g.document.body[e]:f[e]):null):this.each(function(){g=c(this),g?g.scrollTo(a?K(g).scrollLeft():d,a?d:K(g).scrollTop()):this[e]=d})}}),K.each(["Height","Width"],function(a,c){var d=c.toLowerCase();K.fn["inner"+c]=function(){var a=this[0];return a?a.style?parseFloat(K.css(a,d,"padding")):this[d]():null},K.fn["outer"+c]=function(a){var b=this[0];return b?b.style?parseFloat(K.css(b,d,a?"margin":"border")):this[d]():null},K.fn[d]=function(a){var e=this[0];if(!e)return a==null?null:this;if(K.isFunction(a))return this.each(function(b){var c=K(this);c[d](a.call(this,b,c[d]()))});if(K.isWindow(e)){var f=e.document.documentElement["client"+c],g=e.document.body;return e.document.compatMode==="CSS1Compat"&&f||g&&g["client"+c]||f}if(e.nodeType===9)return Math.max(e.documentElement["client"+c],e.body["scroll"+c],e.documentElement["scroll"+c],e.body["offset"+c],e.documentElement["offset"+c]);if(a===b){var h=K.css(e,d),i=parseFloat(h);return K.isNumeric(i)?i:h}return this.css(d,typeof a=="string"?a:a+"px")}}),a.jQuery=a.$=K,typeof define=="function"&&define.amd&&define.amd.jQuery&&define("jquery",[],function(){return K})})(window),function(){function a(b,c,d){if(b===c)return b!==0||1/b==1/c;if(b==null||c==null)return b===c;b._chain&&(b=b._wrapped),c._chain&&(c=c._wrapped);if(b.isEqual&&v.isFunction(b.isEqual))return b.isEqual(c);if(c.isEqual&&v.isFunction(c.isEqual))return c.isEqual(b);var e=i.call(b);if(e!=i.call(c))return!1;switch(e){case"[object String]":return b==String(c);case"[object Number]":return b!=+b?c!=+c:b==0?1/b==1/c:b==+c;case"[object Date]":case"[object Boolean]":return+b==+c;case"[object RegExp]":return b.source==c.source&&b.global==c.global&&b.multiline==c.multiline&&b.ignoreCase==c.ignoreCase}if(typeof b!="object"||typeof c!="object")return!1;for(var f=d.length;f--;)if(d[f]==b)return!0;d.push(b);var f=0,g=!0;if(e=="[object Array]"){if(f=b.length,g=f==c.length)for(;f--;)if(!(g=f in b==f in c&&a(b[f],c[f],d)))break}else{if("constructor"in b!="constructor"in c||b.constructor!=c.constructor)return!1;for(var h in b)if(v.has(b,h)&&(f++,!(g=v.has(c,h)&&a(b[h],c[h],d))))break;if(g){for(h in c)if(v.has(c,h)&&!(f--))break;g=!f}}return d.pop(),g}var b=this,c=b._,d={},e=Array.prototype,f=Object.prototype,g=e.slice,h=e.unshift,i=f.toString,j=f.hasOwnProperty,k=e.forEach,l=e.map,m=e.reduce,n=e.reduceRight,o=e.filter,p=e.every,q=e.some,r=e.indexOf,s=e.lastIndexOf,f=Array.isArray,t=Object.keys,u=Function.prototype.bind,v=function(a){return new C(a)};typeof exports!="undefined"?(typeof module!="undefined"&&module.exports&&(exports=module.exports=v),exports._=v):b._=v,v.VERSION="1.3.1";var w=v.each=v.forEach=function(a,b,c){if(a!=null)if(k&&a.forEach===k)a.forEach(b,c);else if(a.length===+a.length){for(var e=0,f=a.length;e<f;e++)if(e in a&&b.call(c,a[e],e,a)===d)break}else for(e in a)if(v.has(a,e)&&b.call(c,a[e],e,a)===d)break};v.map=v.collect=function(a,b,c){var d=[];return a==null?d:l&&a.map===l?a.map(b,c):(w(a,function(a,e,f){d[d.length]=b.call(c,a,e,f)}),a.length===+a.length&&(d.length=a.length),d)},v.reduce=v.foldl=v.inject=function(a,b,c,d){var e=arguments.length>2;a==null&&(a=[]);if(m&&a.reduce===m)return d&&(b=v.bind(b,d)),e?a.reduce(b,c):a.reduce(b);w(a,function(a,f,g){e?c=b.call(d,c,a,f,g):(c=a,e=!0)});if(!e)throw new TypeError("Reduce of empty array with no initial value");return c},v.reduceRight=v.foldr=function(a,b,c,d){var e=arguments.length>2;a==null&&(a=[]);if(n&&a.reduceRight===n)return d&&(b=v.bind(b,d)),e?a.reduceRight(b,c):a.reduceRight(b);var f=v.toArray(a).reverse();return d&&!e&&(b=v.bind(b,d)),e?v.reduce(f,b,c,d):v.reduce(f,b)},v.find=v.detect=function(a,b,c){var d;return x(a,function(a,e,f){if(b.call(c,a,e,f))return d=a,!0}),d},v.filter=v.select=function(a,b,c){var d=[];return a==null?d:o&&a.filter===o?a.filter(b,c):(w(a,function(a,e,f){b.call(c,a,e,f)&&(d[d.length]=a)}),d)},v.reject=function(a,b,c){var d=[];return a==null?d:(w(a,function(a,e,f){b.call(c,a,e,f)||(d[d.length]=a)}),d)},v.every=v.all=function(a,b,c){var e=!0;return a==null?e:p&&a.every===p?a.every(b,c):(w(a,function(a,f,g){if(!(e=e&&b.call(c,a,f,g)))return d}),e)};var x=v.some=v.any=function(a,b,c){b||(b=v.identity);var e=!1;return a==null?e:q&&a.some===q?a.some(b,c):(w(a,function(a,f,g){if(e||(e=b.call(c,a,f,g)))return d}),!!e)};v.include=v.contains=function(a,b){var c=!1;return a==null?c:r&&a.indexOf===r?a.indexOf(b)!=-1:c=x(a,function(a){return a===b})},v.invoke=function(a,b){var c=g.call(arguments,2);return v.map(a,function(a){return(v.isFunction(b)?b||a:a[b]).apply(a,c)})},v.pluck=function(a,b){return v.map(a,function(a){return a[b]})},v.max=function(a,b,c){if(!b&&v.isArray(a))return Math.max.apply(Math,a);if(!b&&v.isEmpty(a))return-Infinity;var d={computed:-Infinity};return w(a,function(a,e,f){e=b?b.call(c,a,e,f):a,e>=d.computed&&(d={value:a,computed:e})}),d.value},v.min=function(a,b,c){if(!b&&v.isArray(a))return Math.min.apply(Math,a);if(!b&&v.isEmpty(a))return Infinity;var d={computed:Infinity};return w(a,function(a,e,f){e=b?b.call(c,a,e,f):a,e<d.computed&&(d={value:a,computed:e})}),d.value},v.shuffle=function(a){var b=[],c;return w(a,function(a,d){d==0?b[0]=a:(c=Math.floor(Math.random()*(d+1)),b[d]=b[c],b[c]=a)}),b},v.sortBy=function(a,b,c){return v.pluck(v.map(a,function(a,d,e){return{value:a,criteria:b.call(c,a,d,e)}}).sort(function(a,b){var c=a.criteria,d=b.criteria;return c<d?-1:c>d?1:0}),"value")},v.groupBy=function(a,b){var c={},d=v.isFunction(b)?b:function(a){return a[b]};return w(a,function(a,b){var e=d(a,b);(c[e]||(c[e]=[])).push(a)}),c},v.sortedIndex=function(a,b,c){c||(c=v.identity);for(var d=0,e=a.length;d<e;){var f=d+e>>1;c(a[f])<c(b)?d=f+1:e=f}return d},v.toArray=function(a){return a?a.toArray?a.toArray():v.isArray(a)?g.call(a):v.isArguments(a)?g.call(a):v.values(a):[]},v.size=function(a){return v.toArray(a).length},v.first=v.head=function(a,b,c){return b!=null&&!c?g.call
4
- (a,0,b):a[0]},v.initial=function(a,b,c){return g.call(a,0,a.length-(b==null||c?1:b))},v.last=function(a,b,c){return b!=null&&!c?g.call(a,Math.max(a.length-b,0)):a[a.length-1]},v.rest=v.tail=function(a,b,c){return g.call(a,b==null||c?1:b)},v.compact=function(a){return v.filter(a,function(a){return!!a})},v.flatten=function(a,b){return v.reduce(a,function(a,c){return v.isArray(c)?a.concat(b?c:v.flatten(c)):(a[a.length]=c,a)},[])},v.without=function(a){return v.difference(a,g.call(arguments,1))},v.uniq=v.unique=function(a,b,c){var c=c?v.map(a,c):a,d=[];return v.reduce(c,function(c,e,f){if(0==f||(b===!0?v.last(c)!=e:!v.include(c,e)))c[c.length]=e,d[d.length]=a[f];return c},[]),d},v.union=function(){return v.uniq(v.flatten(arguments,!0))},v.intersection=v.intersect=function(a){var b=g.call(arguments,1);return v.filter(v.uniq(a),function(a){return v.every(b,function(b){return v.indexOf(b,a)>=0})})},v.difference=function(a){var b=v.flatten(g.call(arguments,1));return v.filter(a,function(a){return!v.include(b,a)})},v.zip=function(){for(var a=g.call(arguments),b=v.max(v.pluck(a,"length")),c=Array(b),d=0;d<b;d++)c[d]=v.pluck(a,""+d);return c},v.indexOf=function(a,b,c){if(a==null)return-1;var d;if(c)return c=v.sortedIndex(a,b),a[c]===b?c:-1;if(r&&a.indexOf===r)return a.indexOf(b);for(c=0,d=a.length;c<d;c++)if(c in a&&a[c]===b)return c;return-1},v.lastIndexOf=function(a,b){if(a==null)return-1;if(s&&a.lastIndexOf===s)return a.lastIndexOf(b);for(var c=a.length;c--;)if(c in a&&a[c]===b)return c;return-1},v.range=function(a,b,c){arguments.length<=1&&(b=a||0,a=0);for(var c=arguments[2]||1,d=Math.max(Math.ceil((b-a)/c),0),e=0,f=Array(d);e<d;)f[e++]=a,a+=c;return f};var y=function(){};v.bind=function(a,b){var c,d;if(a.bind===u&&u)return u.apply(a,g.call(arguments,1));if(!v.isFunction(a))throw new TypeError;return d=g.call(arguments,2),c=function(){if(this instanceof c){y.prototype=a.prototype;var e=new y,f=a.apply(e,d.concat(g.call(arguments)));return Object(f)===f?f:e}return a.apply(b,d.concat(g.call(arguments)))}},v.bindAll=function(a){var b=g.call(arguments,1);return b.length==0&&(b=v.functions(a)),w(b,function(b){a[b]=v.bind(a[b],a)}),a},v.memoize=function(a,b){var c={};return b||(b=v.identity),function(){var d=b.apply(this,arguments);return v.has(c,d)?c[d]:c[d]=a.apply(this,arguments)}},v.delay=function(a,b){var c=g.call(arguments,2);return setTimeout(function(){return a.apply(a,c)},b)},v.defer=function(a){return v.delay.apply(v,[a,1].concat(g.call(arguments,1)))},v.throttle=function(a,b){var c,d,e,f,g,h=v.debounce(function(){g=f=!1},b);return function(){c=this,d=arguments;var i;e||(e=setTimeout(function(){e=null,g&&a.apply(c,d),h()},b)),f?g=!0:a.apply(c,d),h(),f=!0}},v.debounce=function(a,b){var c;return function(){var d=this,e=arguments;clearTimeout(c),c=setTimeout(function(){c=null,a.apply(d,e)},b)}},v.once=function(a){var b=!1,c;return function(){return b?c:(b=!0,c=a.apply(this,arguments))}},v.wrap=function(a,b){return function(){var c=[a].concat(g.call(arguments,0));return b.apply(this,c)}},v.compose=function(){var a=arguments;return function(){for(var b=arguments,c=a.length-1;c>=0;c--)b=[a[c].apply(this,b)];return b[0]}},v.after=function(a,b){return a<=0?b():function(){if(--a<1)return b.apply(this,arguments)}},v.keys=t||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var b=[],c;for(c in a)v.has(a,c)&&(b[b.length]=c);return b},v.values=function(a){return v.map(a,v.identity)},v.functions=v.methods=function(a){var b=[],c;for(c in a)v.isFunction(a[c])&&b.push(c);return b.sort()},v.extend=function(a){return w(g.call(arguments,1),function(b){for(var c in b)a[c]=b[c]}),a},v.defaults=function(a){return w(g.call(arguments,1),function(b){for(var c in b)a[c]==null&&(a[c]=b[c])}),a},v.clone=function(a){return v.isObject(a)?v.isArray(a)?a.slice():v.extend({},a):a},v.tap=function(a,b){return b(a),a},v.isEqual=function(b,c){return a(b,c,[])},v.isEmpty=function(a){if(v.isArray(a)||v.isString(a))return a.length===0;for(var b in a)if(v.has(a,b))return!1;return!0},v.isElement=function(a){return!!a&&a.nodeType==1},v.isArray=f||function(a){return i.call(a)=="[object Array]"},v.isObject=function(a){return a===Object(a)},v.isArguments=function(a){return i.call(a)=="[object Arguments]"},v.isArguments(arguments)||(v.isArguments=function(a){return!!a&&!!v.has(a,"callee")}),v.isFunction=function(a){return i.call(a)=="[object Function]"},v.isString=function(a){return i.call(a)=="[object String]"},v.isNumber=function(a){return i.call(a)=="[object Number]"},v.isNaN=function(a){return a!==a},v.isBoolean=function(a){return a===!0||a===!1||i.call(a)=="[object Boolean]"},v.isDate=function(a){return i.call(a)=="[object Date]"},v.isRegExp=function(a){return i.call(a)=="[object RegExp]"},v.isNull=function(a){return a===null},v.isUndefined=function(a){return a===void 0},v.has=function(a,b){return j.call(a,b)},v.noConflict=function(){return b._=c,this},v.identity=function(a){return a},v.times=function(a,b,c){for(var d=0;d<a;d++)b.call(c,d)},v.escape=function(a){return(""+a).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;").replace(/\//g,"&#x2F;")},v.mixin=function(a){w(v.functions(a),function(b){E(b,v[b]=a[b])})};var z=0;v.uniqueId=function(a){var b=z++;return a?a+b:b},v.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var A=/.^/,B=function(a){return a.replace(/\\\\/g,"\\").replace(/\\'/g,"'")};v.template=function(a,b){var c=v.templateSettings,c="var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('"+a.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(c.escape||A,function(a,b){return"',_.escape("+B(b)+"),'"}).replace(c.interpolate||A,function(a,b){return"',"+B(b)+",'"}).replace(c.evaluate||A,function(a,b){return"');"+B(b).replace(/[\r\n\t]/g," ")+";__p.push('"}).replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\t/g,"\\t")+"');}return __p.join('');",d=new Function("obj","_",c);return b?d(b,v):function(a){return d.call(this,a,v)}},v.chain=function(a){return v(a).chain()};var C=function(a){this._wrapped=a};v.prototype=C.prototype;var D=function(a,b){return b?v(a).chain():a},E=function(a,b){C.prototype[a]=function(){var a=g.call(arguments);return h.call(a,this._wrapped),D(b.apply(v,a),this._chain)}};v.mixin(v),w("pop,push,reverse,shift,sort,splice,unshift".split(","),function(a){var b=e[a];C.prototype[a]=function(){var c=this._wrapped;b.apply(c,arguments);var d=c.length;return(a=="shift"||a=="splice")&&d===0&&delete c[0],D(c,this._chain)}}),w(["concat","join","slice"],function(a){var b=e[a];C.prototype[a]=function(){return D(b.apply(this._wrapped,arguments),this._chain)}}),C.prototype.chain=function(){return this._chain=!0,this},C.prototype.value=function(){return this._wrapped}}.call(this),function(a){var b=String.prototype.trim,c=function(a,b){for(var c=[];b>0;c[--b]=a);return c.join("")},d=function(a){return function(){for(var b=Array.prototype.slice.call(arguments),c=0;c<b.length;c++)b[c]=b[c]==null?"":""+b[c];return a.apply(null,b)}},e=function(){function a(a){return Object.prototype.toString.call(a).slice(8,-1).toLowerCase()}var b=function(){return b.cache.hasOwnProperty(arguments[0])||(b.cache[arguments[0]]=b.parse(arguments[0])),b.format.call(null,b.cache[arguments[0]],arguments)};return b.format=function(b,d){var f=1,g=b.length,h="",i=[],j,k,n,o;for(j=0;j<g;j++)if(h=a(b[j]),h==="string")i.push(b[j]);else if(h==="array"){n=b[j];if(n[2]){h=d[f];for(k=0;k<n[2].length;k++){if(!h.hasOwnProperty(n[2][k]))throw e('[_.sprintf] property "%s" does not exist',n[2][k]);h=h[n[2][k]]}}else h=n[1]?d[n[1]]:d[f++];if(/[^s]/.test(n[8])&&a(h)!="number")throw e("[_.sprintf] expecting number but found %s",a(h));switch(n[8]){case"b":h=h.toString(2);break;case"c":h=String.fromCharCode(h);break;case"d":h=parseInt(h,10);break;case"e":h=n[7]?h.toExponential(n[7]):h.toExponential();break;case"f":h=n[7]?parseFloat(h).toFixed(n[7]):parseFloat(h);break;case"o":h=h.toString(8);break;case"s":h=(h=String(h))&&n[7]?h.substring(0,n[7]):h;break;case"u":h=Math.abs(h);break;case"x":h=h.toString(16);break;case"X":h=h.toString(16).toUpperCase()}h=/[def]/.test(n[8])&&n[3]&&h>=0?"+"+h:h,k=n[4]?n[4]=="0"?"0":n[4].charAt(1):" ",o=n[6]-String(h).length,k=n[6]?c(k,o):"",i.push(n[5]?h+k:k+h)}return i.join("")},b.cache={},b.parse=function(a){for(var b=[],c=[],d=0;a;){if((b=/^[^\x25]+/.exec(a))!==null)c.push(b[0]);else if((b=/^\x25{2}/.exec(a))!==null)c.push("%");else{if((b=/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(a))===null)throw"[_.sprintf] huh?";if(b[2]){d|=1;var e=[],f=b[2],g=[];if((g=/^([a-z_][a-z_\d]*)/i.exec(f))===null)throw"[_.sprintf] huh?";for(e.push(g[1]);(f=f.substring(g[0].length))!=="";)if((g=/^\.([a-z_][a-z_\d]*)/i.exec(f))!==null)e.push(g[1]);else{if((g=/^\[(\d+)\]/.exec(f))===null)throw"[_.sprintf] huh?";e.push(g[1])}b[2]=e}else d|=2;if(d===3)throw"[_.sprintf] mixing positional and named placeholders is not (yet) supported";c.push(b)}a=a.substring(b[0].length)}return c},b}(),f={VERSION:"1.2.0",isBlank:d(function(a){return/^\s*$/.test(a)}),stripTags:d(function(a){return a.replace(/<\/?[^>]+>/ig,"")}),capitalize:d(function(a){return a.charAt(0).toUpperCase()+a.substring(1).toLowerCase()}),chop:d(function(a,b){for(var b=b*1||0||a.length,c=[],d=0;d<a.length;)c.push(a.slice(d,d+b)),d+=b;return c}),clean:d(function(a){return f.strip(a.replace(/\s+/g," "))}),count:d(function(a,b){for(var c=0,d,e=0;e<a.length;)d=a.indexOf(b,e),d>=0&&c++,e=e+(d>=0?d:0)+b.length;return c}),chars:d(function(a){return a.split("")}),escapeHTML:d(function(a){return a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}),unescapeHTML:d(function(a){return a.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&apos;/g,"'").replace(/&amp;/g,"&")}),escapeRegExp:d(function(a){return a.replace(/([-.*+?^${}()|[\]\/\\])/g,"\\$1")}),insert:d(function(a,b,c){return a=a.split(""),a.splice(b*1||0,0,c),a.join("")}),include:d(function(a,b){return a.indexOf(b)!==-1}),join:d(function(a){var b=Array.prototype.slice.call(arguments);return b.join(b.shift())}),lines:d(function(a){return a.split("\n")}),reverse:d(function(a){return Array.prototype.reverse.apply(String(a).split("")).join("")}),splice:d(function(a,b,c,d){return a=a.split(""),a.splice(b*1||0,c*1||0,d),a.join("")}),startsWith:d(function(a,b){return a.length>=b.length&&a.substring(0,b.length)===b}),endsWith:d(function(a,b){return a.length>=b.length&&a.substring(a.length-b.length)===b}),succ:d(function(a){var b=a.split("");return b.splice(a.length-1,1,String.fromCharCode(a.charCodeAt(a.length-1)+1)),b.join("")}),titleize:d(function(a){for(var a=a.split(" "),b,c=0;c<a.length;c++)b=a[c].split(""),typeof b[0]!="undefined"&&(b[0]=b[0].toUpperCase()),c+1===a.length?a[c]=b.join(""):a[c]=b.join("")+" ";return a.join("")}),camelize:d(function(a){return f.trim(a).replace(/(\-|_|\s)+(.)?/g,function(a,b,c){return c?c.toUpperCase():""})}),underscored:function(a){return f.trim(a).replace(/([a-z\d])([A-Z]+)/g,"$1_$2").replace(/\-|\s+/g,"_").toLowerCase()},dasherize:function(a){return f.trim(a).replace(/([a-z\d])([A-Z]+)/g,"$1-$2").replace(/^([A-Z]+)/,"-$1").replace(/\_|\s+/g,"-").toLowerCase()},humanize:function(a){return f.capitalize(this.underscored(a).replace(/_id$/,"").replace(/_/g," "))},trim:d(function(a,c){return!c&&b?b.call(a):(c=c?f.escapeRegExp(c):"\\s",a.replace(RegExp("^["+c+"]+|["+c+"]+$","g"),""))}),ltrim:d(function(a,b){return b=b?f.escapeRegExp(b):"\\s",a.replace(RegExp("^["+b+"]+","g"),"")}),rtrim:d(function(a,b){return b=b?f.escapeRegExp(b):"\\s",a.replace(RegExp("["+b+"]+$","g"),"")}),truncate:d(function(a,b,c){return b=b*1||0,a.length>b?a.slice(0,b)+(c||"..."):a}),prune:d(function(a,b,c){var c=c||"...",b=b*1||0,d="",d=a.substring(b-1,b+1).search(/^\w\w$/)===0?f.rtrim(a.slice(0,b).replace(/([\W][\w]*)$/,"")):f.rtrim(a.slice(0,b)),d=d.replace(/\W+$/,"");return d.length+c.length>a.length?a:d+c}),words:function(a,b){return String(a).split(b||" ")},pad:d(function(a,b,d,e){var f="",f=0,b=b*1||0;d?d.length>1&&(d=d.charAt(0)):d=" ";switch(e){case"right":f=b-a.length,f=c(d,f),a+=f;break;case"both":f=b-a.length,f={left:c(d,Math.ceil(f/2)),right:c(d,Math.floor(f/2))},a=f.left+a+f.right;break;default:f=b-a.length,f=c(d,f),a=f+a}return a}),lpad:function(a,b,c){return f.pad(a,b,c)},rpad:function(a,b,c){return f.pad(a,b,c,"right")},lrpad:function(a,b,c){return f.pad(a,b,c,"both")},sprintf:e,vsprintf:function(a,b){return b.unshift(a),e.apply(null,b)},toNumber:function(a,b){var c;return c=(a*1||0).toFixed(b*1||0)*1||0,c!==0||a==="0"||a===0?c:Number.NaN},strRight:d(function(a,b){var c=b?a.indexOf(b):-1;return c!=-1?a.slice(c+b.length,a.length):a}),strRightBack:d(function(a,b){var c=b?a.lastIndexOf(b):-1;return c!=-1?a.slice(c+b.length,a.length):a}),strLeft:d(function(a,b){var c=b?a.indexOf(b):-1;return c!=-1?a.slice(0,c):a}),strLeftBack:d(function(a,b){var c=a.lastIndexOf(b);return c!=-1?a.slice(0,c):a}),exports:function(){var a={},b;for(b in this)this.hasOwnProperty(b)&&b!="include"&&b!="contains"&&b!="reverse"&&(a[b]=this[b]);return a}};f.strip=f.trim,f.lstrip=f.ltrim,f.rstrip=f.rtrim,f.center=f.lrpad,f.ljust=f.lpad,f.rjust=f.rpad,f.contains=f.include,typeof exports!="undefined"?(typeof module!="undefined"&&module.exports&&(module.exports=f),exports._s=f):typeof a._!="undefined"?(a._.string=f,a._.str=a._.string):a._={string:f,str:f}}(this||window),function(){var a=this,b=a.Backbone,c=Array.prototype.slice,d=Array.prototype.splice,e;e="undefined"!=typeof exports?exports:a.Backbone={},e.VERSION="0.9.1";var f=a._;!f&&"undefined"!=typeof require&&(f=require("underscore"));var g=a.jQuery||a.Zepto||a.ender;e.setDomLibrary=function(a){g=a},e.noConflict=function(){return a.Backbone=b,this},e.emulateHTTP=!1,e.emulateJSON=!1,e.Events={on:function(a,b,c){for(var d,a=a.split(/\s+/),e=this._callbacks||(this._callbacks={});d=a.shift();){d=e[d]||(e[d]={});var f=d.tail||(d.tail=d.next={});f.callback=b,f.context=c,d.tail=f.next={}}return this},off:function(a,b,c){var d,e,f;if(a){if(e=this._callbacks)for(a=a.split(/\s+/);d=a.shift();)if(f=e[d],delete e[d],b&&f)for(;(f=f.next)&&f.next;)(f.callback!==b||!!c&&f.context!==c)&&this.on(d,f.callback,f.context)}else delete this._callbacks;return this},trigger:function(a){var b,d,e,f;if(!(e=this._callbacks))return this;f=e.all;for((a=a.split(/\s+/)).push(null);b=a.shift();)f&&a.push({next:f.next,tail:f.tail,event:b}),(d=e[b])&&a.push({next:d.next,tail:d.tail});for(f=c.call(arguments,1);d=a.pop();){b=d.tail;for(e=d.event?[d.event].concat(f):f;(d=d.next)!==b;)d.callback.apply(d.context||this,e)}return this}},e.Events.bind=e.Events.on,e.Events.unbind=e.Events.off,e.Model=function(a,b){var c;a||(a={}),b&&b.parse&&(a=this.parse(a));if(c=s(this,"defaults"))a=f.extend({},c,a);b&&b.collection&&(this.collection=b.collection),this.attributes={},this._escapedAttributes={},this.cid=f.uniqueId("c");if(!this.set(a,{silent:!0}))throw Error("Can't create an invalid model");delete this._changed,this._previousAttributes=f.clone(this.attributes),this.initialize.apply(this,arguments)},f.extend(e.Model.prototype,e.Events,{idAttribute:"id",initialize:function(){},toJSON:function(){return f.clone(this.attributes)},get:function(a){return this.attributes[a]},escape:function(a){var b;return(b=this._escapedAttributes[a])?b:(b=this.attributes[a],this._escapedAttributes[a]=f.escape(null==b?"":""+b))},has:function(a){return null!=this.attributes[a]},set:function(a,b,c){var d,g;f.isObject(a)||null==a?(d=a,c=b):(d={},d[a]=b),c||(c={});if(!d)return this;d instanceof e.Model&&(d=d.attributes);if(c.unset)for(g in d)d[g]=void 0;if(!this._validate(d,c))return!1;this.idAttribute in d&&(this.id=d[this.idAttribute]);var b=this.attributes,h=this._escapedAttributes,i=this._previousAttributes||{},j=this._setting;this._changed||(this._changed={}),this._setting=!0;for(g in d)if(a=d[g],f.isEqual(b[g],a)||delete h[g],c.unset?delete b[g]:b[g]=a,this._changing&&!f.isEqual(this._changed[g],a)&&(this.trigger("change:"+g,this,a,c),this._moreChanges=!0),delete this._changed[g],!f.isEqual(i[g],a)||f.has(b,g)!=f.has(i,g))this._changed[g]=a;return j||(!c.silent&&this.hasChanged()&&this.change(c),this._setting=!1),this},unset:function(a,b){return(b||(b={})).unset=!0,this.set(a,null,b)},clear:function(a){return(a||(a={})).unset=!0,this.set(f.clone(this.attributes),a)},fetch:function(a){var a=a?f.clone(a):{},b=this,c=a.success;return a.success=function(d,e,f){if(!b.set(b.parse(d,f),a))return!1;c&&c(b,d)},a.error=e.wrapError(a.error,b,a),(this.sync||e.sync).call(this,"read",this,a)},save:function(a,b,c){var d,g;f.isObject(a)||null==a?(d=a,c=b):(d={},d[a]=b),c=c?f.clone(c):{},c.wait&&(g=f.clone(this.attributes)),a=f.extend({},c,{silent:!0});if(d&&!this.set(d,c.wait?a:c))return!1;var h=this,i=c.success;return c.success=function(a,b,e){b=h.parse(a,e),c.wait&&(b=f.extend(d||{},b));if(!h.set(b,c))return!1;i?i(h,a):h.trigger("sync",h,a,c)},c.error=e.wrapError(c.error,h,c),b=this.isNew()?"create":"update",b=(this.sync||e.sync).call(this,b,this,c),c.wait&&this.set(g,a),b},destroy:function(a){var a=a?f.clone(a):{},b=this,c=a.success,d=function(){b.trigger("destroy",b,b.collection,a)};if(this.isNew())return d();a.success=function(e){a.wait&&d(),c?c(b,e):b.trigger("sync",b,e,a)},a.error=e.wrapError(a.error,b,a);var g=(this.sync||e.sync).call(this,"delete",this,a);return a.wait||d(),g},url:function(){var a=s(this.collection,"url")||s(this,"urlRoot")||t();return this.isNew()?a:a+("/"==a.charAt(a.length-1)?"":"/")+encodeURIComponent(this.id)},parse:function(a){return a},clone:function(){return new this.constructor(this.attributes)},isNew:function(){return null==this.id},change:function(a){if(this._changing||!this.hasChanged())return this;this._moreChanges=this._changing=!0;for(var b in this._changed)this.trigger("change:"+b,this,this._changed[b],a);for(;this._moreChanges;)this._moreChanges=!1,this.trigger("change",this,a);return this._previousAttributes=f.clone(this.attributes),delete this._changed,this._changing=!1,this},hasChanged:function(a){return arguments.length?this._changed&&f.has(this._changed,a):!f.isEmpty(this._changed)},changedAttributes:function(a){if(!a)return this.hasChanged()?f.clone(this._changed):!1;var b,c=!1,d=this._previousAttributes,e;for(e in a)f.isEqual(d[e],b=a[e])||((c||(c={}))[e]=b);return c},previous:function(a){return!arguments.length||!this._previousAttributes?null:this._previousAttributes[a]},previousAttributes:function(){return f.clone(this._previousAttributes)},isValid:function(){return!this.validate(this.attributes)},_validate:function(a,b){if(b.silent||!this.validate)return!0;var a=f.extend({},this.attributes,a),c=this.validate(a,b);return c?(b&&b.error?b.error(this,c,b):this.trigger("error",this,c,b),!1):!0}}),e.Collection=function(a,b){b||(b={}),b.comparator&&(this.comparator=b.comparator),this._reset(),this.initialize.apply(this,arguments),a&&this.reset(a,{silent:!0,parse:b.parse})},f.extend(e.Collection.prototype,e.Events,{model:e.Model,initialize:function(){},toJSON:function(){return this.map(function(a){return a.toJSON()})},add:function(a,b){var c,e,g,h,i,j={},k={};b||(b={}),a=f.isArray(a)?a.slice():[a];for(c=0,e=a.length;c<e;c++){if(!(g=a[c]=this._prepareModel(a[c],b)))throw Error("Can't add an invalid model to a collection");if(j[h=g.cid]||this._byCid[h]||null!=(i=g.id)&&(k[i]||this._byId[i]))throw Error("Can't add the same model to a collection twice");j[h]=k[i]=g}for(c=0;c<e;c++)(g=a[c]).on("all",this._onModelEvent,this),this._byCid[g.cid]=g,null!=g.id&&(this._byId[g.id]=g);this.length+=e,d.apply(this.models,[null!=b.at?b.at:this.models.length,0].concat(a)),this.comparator&&this.sort({silent:!0});if(b.silent)return this;for(c=0,e=this.models.length;c<e;c++)j[(g=this.models[c]).cid]&&(b.index=c,g.trigger("add",g,this,b));return this},remove:function(a,b){var c,d,e,g;b||(b={}),a=f.isArray(a)?a.slice():[a];for(c=0,d=a.length;c<d;c++)if(g=this.getByCid(a[c])||this.get(a[c]))delete this._byId[g.id],delete this._byCid[g.cid],e=this.indexOf(g),this.models.splice(e,1),this.length--,b.silent||(b.index=e,g.trigger("remove",g,this,b)),this._removeReference(g);return this},get:function(a){return null==a?null:this._byId[null!=a.id?a.id:a]},getByCid:function(a){return a&&this._byCid[a.cid||a]},at:function(a){return this.models[a]},sort:function(a){a||(a={});if(!this.comparator)throw Error("Cannot sort a set without a comparator");var b=f.bind(this.comparator,this);return 1==this.comparator.length?this.models=this.sortBy(b):this.models.sort(b),a.silent||this.trigger("reset",this,a),this},pluck:function(a){return f.map(this.models,function(b){return b.get(a)})},reset:function(a,b){a||(a=[]),b||(b={});for(var c=0,d=this.models.length;c<d;c++)this._removeReference(this.models[c]);return this._reset(),this.add(a,{silent:!0,parse:b.parse}),b.silent||this.trigger("reset",this,b),this},fetch:function(a){a=a?f.clone(a):{},void 0===a.parse&&(a.parse=!0);var b=this,c=a.success;return a.success=function(d,e,f){b[a.add?"add":"reset"](b.parse(d,f),a),c&&c(b,d)},a.error=e.wrapError(a.error,b,a),(this.sync||e.sync).call(this,"read",this,a)},create:function(a,b){var c=this,b=b?f.clone(b):{},a=this._prepareModel(a,b);if(!a)return!1;b.wait||c.add(a,b);var d=b.success;return b.success=function(e,f){b.wait&&c.add(e,b),d?d(e,f):e.trigger("sync",a,f,b)},a.save(null,b),a},parse:function(a){return a},chain:function(){return f(this.models).chain()},_reset:function(){this.length=0,this.models=[],this._byId={},this._byCid={}},_prepareModel:function(a,b){return a instanceof e.Model?a.collection||(a.collection=this):(b.collection=this,a=new this.model(a,b),a._validate(a.attributes,b)||(a=!1)),a},_removeReference:function(a){this==a.collection&&delete a.collection,a.off("all",this._onModelEvent,this)},_onModelEvent:function(a,b,c,d){("add"==a||"remove"==a)&&c!=this||("destroy"==a&&this.remove(b,d),b&&a==="change:"+b.idAttribute&&(delete this._byId[b.previous(b.idAttribute)],this._byId[b.id]=b),this.trigger.apply(this,arguments))}}),f.each("forEach,each,map,reduce,reduceRight,find,detect,filter,select,reject,every,all,some,any,include,contains,invoke,max,min,sortBy,sortedIndex,toArray,size,first,initial,rest,last,without,indexOf,shuffle,lastIndexOf,isEmpty,groupBy".split(","),function(a){e.Collection.prototype[a]=function(){return f[a].apply(f,[this.models].concat(f.toArray(arguments)))}}),e.Router=function(a){a||(a={}),a.routes&&(this.routes=a.routes),this._bindRoutes(),this.initialize.apply(this,arguments)};var h=/:\w+/g,i=/\*\w+/g,j=/[-[\]{}()+?.,\\^$|#\s]/g;f.extend(e.Router.prototype,e.Events,{initialize:function(){},route:function(a,b,c){return e.history||(e.history=new e.History),f.isRegExp(a)||(a=this._routeToRegExp(a)),c||(c=this[b]),e.history.route(a,f.bind(function(d){d=this._extractParameters(a,d),c&&c.apply(this,d),this.trigger.apply(this,["route:"+b].concat(d)),e.history.trigger("route",this,b,d)},this)),this},navigate:function(a,b){e.history.navigate(a,b)},_bindRoutes:function(){if(this.routes){var a=[],b;for(b in this.routes)a.unshift([b,this.routes[b]]);b=0;for(var c=a.length;b<c;b++)this.route(a[b][0],a[b][1],this[a[b][1]])}},_routeToRegExp:function(a){return a=a.replace(j,"\\$&").replace(h,"([^/]+)").replace(i,"(.*?)"),RegExp("^"+a+"$")},_extractParameters:function(a,b){return a.exec(b).slice(1)}}),e.History=function(){this.handlers=[],f.bindAll(this,"checkUrl")};var k=/^[#\/]/,l=/msie [\w.]+/,m=!1;f.extend(e.History.prototype,e.Events,{interval:50,getFragment:function(a,b){if(null==a)if(this._hasPushState||b){var a=window.location.pathname,c=window.location.search;c&&(a+=c)}else a=window.location.hash;return a=decodeURIComponent(a),a.indexOf(this.options.root)||(a=a.substr(this.options.root.length)),a.replace(k,"")},start:function(a){if(m)throw Error("Backbone.history has already been started");this.options=f.extend({},{root:"/"},this.options,a),this._wantsHashChange=!1!==this.options.hashChange,this._wantsPushState=!!this.options.pushState,this._hasPushState=!(!this.options.pushState||!window.history||!window.history.pushState);var a=this.getFragment(),b=document.documentMode;if(b=l.exec(navigator.userAgent.toLowerCase())&&(!b||7>=b))this.iframe=g('<iframe src="javascript:0" tabindex="-1" />').hide().appendTo("body")[0].contentWindow,this.navigate(a);this._hasPushState?g(window).bind("popstate",this.checkUrl):this._wantsHashChange&&"onhashchange"in window&&!b?g(window).bind("hashchange",this.checkUrl):this._wantsHashChange&&(this._checkUrlInterval=setInterval(this.checkUrl,this.interval)),this.fragment=a,m=!0,a=window.location,b=a.pathname==this.options.root;if(this._wantsHashChange&&this._wantsPushState&&!this._hasPushState&&!b)return this.fragment=this.getFragment(null,!0),window.location.replace(this.options.root+"#"+this.fragment),!0;this._wantsPushState&&this._hasPushState&&b&&a.hash&&(this.fragment=a.hash.replace(k,""),window.history.replaceState({},document.title,a.protocol+"//"+a.host+this.options.root+this.fragment));if(!this.options.silent)return this.loadUrl()},stop:function(){g(window).unbind("popstate",this.checkUrl).unbind("hashchange",this.checkUrl),clearInterval(this._checkUrlInterval),m=!1},route:function(a,b){this.handlers.unshift({route:a,callback:b})},checkUrl:function(){var a=this.getFragment();a==this.fragment&&this.iframe&&(a=this.getFragment(this.iframe.location.hash));if(a==this.fragment||a==decodeURIComponent(this.fragment))return!1;this.iframe&&this.navigate(a),this.loadUrl()||this.loadUrl(window.location.hash)},loadUrl:function(a){var b=this.fragment=this.getFragment(a);return f.any(this.handlers,function(a){if(a.route.test(b))return a.callback(b),!0})},navigate:function(a,b){if(!m)return!1;if(!b||!0===b)b={trigger:b};var c=(a||"").replace(k,"");this.fragment==c||this.fragment==decodeURIComponent(c)||(this._hasPushState?(0!=c.indexOf(this.options.root)&&(c=this.options.root+c),this.fragment=c,window.history[b.replace?"replaceState":"pushState"]({},document.title,c)):this._wantsHashChange?(this.fragment=c,this._updateHash(window.location,c,b.replace),this.iframe&&c!=this.getFragment(this.iframe.location.hash)&&(b.replace||this.iframe.document.open().close(),this._updateHash(this.iframe.location,c,b.replace))):window.location.assign(this.options.root+a),b.trigger&&this.loadUrl(a))},_updateHash:function(a,b,c){c?a.replace(a.toString().replace(/(javascript:|#).*$/,"")+"#"+b):a.hash=b}}),e.View=function(a){this.cid=f.uniqueId("view"),this._configure(a||{}),this._ensureElement(),this.initialize.apply(this,arguments),this.delegateEvents()};var n=/^(\S+)\s*(.*)$/,o="model,collection,el,id,attributes,className,tagName".split(",");f.extend(e.View.prototype,e.Events,{tagName:"div",$:function(a){return this.$el.find(a)},initialize:function(){},render:function(){return this},remove:function(){return this.$el.remove(),this},make:function(a,b,c){return a=document.createElement(a),b&&g(a).attr(b),c&&g(a).html(c),a},setElement:function(a,b){return this.$el=g(a),this.el=this.$el[0],!1!==b&&this.delegateEvents(),this},delegateEvents:function(a){if(a||(a=s(this,"events"))){this.undelegateEvents();for(var b in a){var c=a[b];f.isFunction(c)||(c=this[a[b]]);if(!c)throw Error('Event "'+a[b]+'" does not exist');var d=b.match(n),e=d[1],d=d[2],c=f.bind(c,this),e=e+(".delegateEvents"+this.cid);""===d?this.$el.bind(e,c):this.$el.delegate(d,e,c)}}},undelegateEvents:function(){this.$el.unbind(".delegateEvents"+this.cid)},_configure:function(a){this.options&&(a=f.extend({},this.options,a));for(var b=0,c=o.length;b<c;b++){var d=o[b];a[d]&&(this[d]=a[d])}this.options=a},_ensureElement:function(){if(this.el)this.setElement(this.el,!1);else{var a=s(this,"attributes")||{};this.id&&(a.id=this.id),this.className&&(a["class"]=this.className),this.setElement(this.make(this.tagName,a),!1)}}}),e.Model.extend=e.Collection.extend=e.Router.extend=e.View.extend=function(a,b){var c=r(this,a,b);return c.extend=this.extend,c};var p={create:"POST",update:"PUT","delete":"DELETE",read:"GET"};e.sync=function(a,b,c){var d=p[a],h={type:d,dataType:"json"};return c.url||(h.url=s(b,"url")||t()),!c.data&&b&&("create"==a||"update"==a)&&(h.contentType="application/json",h.data=JSON.stringify(b.toJSON())),e.emulateJSON&&(h.contentType="application/x-www-form-urlencoded",h.data=h.data?{model:h.data}:{}),e.emulateHTTP&&("PUT"===d||"DELETE"===d)&&(e.emulateJSON&&(h.data._method=d),h.type="POST",h.beforeSend=function(a){a.setRequestHeader("X-HTTP-Method-Override",d)}),"GET"!==h.type&&!e.emulateJSON&&(h.processData=!1),g.ajax(f.extend(h,c))},e.wrapError=function(a,b,c){return function(d,e){e=d===b?e:d,a?a(b,e,c):b.trigger("error",b,e,c)}};var q=function(){},r=function(a,b,c){var d;return d=b&&b.hasOwnProperty("constructor")?b.constructor:function(){a.apply(this,arguments)},f.extend(d,a),q.prototype=a.prototype,d.prototype=new q,b&&f.extend(d.prototype,b),c&&f.extend(d,c),d.prototype.constructor=d,d.__super__=a.prototype,d},s=function(a,b){return!a||!a[b]?null:f.isFunction(a[b])?a[b]():a[b]},t=function(){throw Error('A "url" property or function must be specified')}}.call(this),function(){var a,b,c,d,e,f,g,h,i,j,k,l=Array.prototype.indexOf||function(a){for(var b=0,c=this.length;b<c;b++)if(this[b]===a)return b;return-1};f=function(a){var b,c,d,e,f,g;g=[];for(b in a){d=a[b],c={key:b};if(_.isRegExp(d))c.type="$regex",c.value=d;else if(_(d).isObject())for(e in d)f=d[e],k(e,f)&&(c.type=e,c.value=f);else c.type="$equal",c.value=d;g.push(c)}return g},k=function(a,b){switch(a){case"$in":case"$nin":case"$all":case"$any":return _(b).isArray();case"$size":return _(b).isNumber();case"$regex":return _(b).isRegExp();case"$like":case"$likeI":return _(b).isString();case"$between":return _(b).isArray()&&b.length===2;case"$cb":return _(b).isFunction();default:return!0}},j=function(a,b){switch(a){case"$like":case"$likeI":case"$regex":return _(b).isString();case"$contains":case"$all":case"$any":return _(b).isArray();case"$size":return _(b).isArray()||_(b).isString();case"$in":case"$nin":return b!=null;default:return!0}},g=function(a,b,c,d){switch(a){case"$equal":return c===b;case"$contains":return l.call(c,b)>=0;case"$ne":return c!==b;case"$lt":return c<b;case"$gt":return c>b;case"$lte":return c<=b;case"$gte":return c>=b;case"$between":return b[0]<c&&c<b[1];case"$in":return l.call(b,c)>=0;case"$nin":return l.call(b,c)<0;case"$all":return _(c).all(function(a){return l.call(b,a)>=0});case"$any":return _(c).any(function(a){return l.call(b,a)>=0});case"$size":return c.length===b;case"$exists":case"$has":return c!=null===b;case"$like":return c.indexOf(b)!==-1;case"$likeI":return c.toLowerCase().indexOf(b.toLowerCase())!==-1;case"$regex":return b.test(c);case"$cb":return b.call(d,c);default:return!1}},d=function(a,b,c,d){var e;return e=f(b),_[d](a,function(a){var b,d,f,h,i;for(h=0,i=e.length;h<i;h++){d=e[h],b=a.get(d.key),f=j(d.type,b),f&&(f=g(d.type,d.value,b,a));if(c===f)return c}return!c})},h={$and:function(a,b){return d(a,b,!1,"filter")},$or:function(a,b){return d(a,b,!0,"filter")},$nor:function(a,b){return d(a,b,!0,"reject")},$not:function(a,b){return d(a,b,!1,"reject")}},a=function(a,b,d){var e,f,g,h;return g=JSON.stringify(b),e=(h=a._query_cache)!=null?h:a._query_cache={},f=e[g],f||(f=c(a,b,d),e[g]=f),f},b=function(a,b){var c,d,e;return c=_.intersection(["$and","$not","$or","$nor"],_(b).keys()),d=a.models,c.length===0?h.$and(d,b):(e=function(a,c){return h[c](a,b[c])},_.reduce(c,e,d))},c=function(a,c,d){var e;return e=b(a,c),d.sortBy&&(e=i(e,d)),e},i=function(a,b){return _(b.sortBy).isString()?a=_(a).sortBy(function(a){return a.get(b.sortBy)}):_(b.sortBy).isFunction()&&(a=_(a).sortBy(b.sortBy)),b.order==="desc"&&(a=a.reverse()),a},e=function(a,b){var c,d,e,f;return b.offset?e=b.offset:b.page?e=(b.page-1)*b.limit:e=0,c=e+b.limit,d=a.slice(e,c),b.pager&&_.isFunction(b.pager)&&(f=Math.ceil(a.length/b.limit),b.pager(f,d)),d};if(typeof require!="undefined"){if(typeof _=="undefined"||_===null)_=require("underscore");if(typeof Backbone=="undefined"||Backbone===null)Backbone=require("backbone")}Backbone.QueryCollection=Backbone.Collection.extend({query:function(b,d){var f;return d==null&&(d={}),d.cache?f=a(this,b,d):f=c(this,b,d),d.limit&&(f=e(f,d)),f},where:function(a,b){return b==null&&(b={}),new this.constructor(this.query(a,b))},reset_query_cache:function(){return this._query_cache={}}}),typeof exports!="undefined"&&(exports.QueryCollection=Backbone.QueryCollection)}.call(this),function(){}.call(this),!function(a){a(function(){a.support.transition=function(){var a=function(){var a=document.createElement("bootstrap"),b={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd"
5
- ,msTransition:"MSTransitionEnd",transition:"transitionend"},c;for(c in b)if(a.style[c]!==undefined)return b[c]}();return a&&{end:a}}()})}(window.jQuery),!function(a){function b(){var b=this,d=setTimeout(function(){b.$element.off(a.support.transition.end),c.call(b)},500);this.$element.one(a.support.transition.end,function(){clearTimeout(d),c.call(b)})}function c(a){this.$element.hide().trigger("hidden"),d.call(this)}function d(b){var c=this,d=this.$element.hasClass("fade")?"fade":"";if(this.isShown&&this.options.backdrop){var f=a.support.transition&&d;this.$backdrop=a('<div class="modal-backdrop '+d+'" />').appendTo(document.body),this.options.backdrop!="static"&&this.$backdrop.click(a.proxy(this.hide,this)),f&&this.$backdrop[0].offsetWidth,this.$backdrop.addClass("in"),f?this.$backdrop.one(a.support.transition.end,b):b()}else!this.isShown&&this.$backdrop?(this.$backdrop.removeClass("in"),a.support.transition&&this.$element.hasClass("fade")?this.$backdrop.one(a.support.transition.end,a.proxy(e,this)):e.call(this)):b&&b()}function e(){this.$backdrop.remove(),this.$backdrop=null}function f(){var b=this;this.isShown&&this.options.keyboard?a(document).on("keyup.dismiss.modal",function(a){a.which==27&&b.hide()}):this.isShown||a(document).off("keyup.dismiss.modal")}var g=function(b,c){this.options=c,this.$element=a(b).delegate('[data-dismiss="modal"]',"click.dismiss.modal",a.proxy(this.hide,this))};g.prototype={constructor:g,toggle:function(){return this[this.isShown?"hide":"show"]()},show:function(){var b=this,c=a.Event("show");this.$element.trigger(c);if(this.isShown||c.isDefaultPrevented())return;a("body").addClass("modal-open"),this.isShown=!0,f.call(this),d.call(this,function(){var c=a.support.transition&&b.$element.hasClass("fade");b.$element.parent().length||b.$element.appendTo(document.body),b.$element.show(),c&&b.$element[0].offsetWidth,b.$element.addClass("in"),c?b.$element.one(a.support.transition.end,function(){b.$element.trigger("shown")}):b.$element.trigger("shown")})},hide:function(d){d&&d.preventDefault();var e=this;d=a.Event("hide"),this.$element.trigger(d);if(!this.isShown||d.isDefaultPrevented())return;this.isShown=!1,a("body").removeClass("modal-open"),f.call(this),this.$element.removeClass("in"),a.support.transition&&this.$element.hasClass("fade")?b.call(this):c.call(this)}},a.fn.modal=function(b){return this.each(function(){var c=a(this),d=c.data("modal"),e=a.extend({},a.fn.modal.defaults,c.data(),typeof b=="object"&&b);d||c.data("modal",d=new g(this,e)),typeof b=="string"?d[b]():e.show&&d.show()})},a.fn.modal.defaults={backdrop:!0,keyboard:!0,show:!0},a.fn.modal.Constructor=g,a(function(){a("body").on("click.modal.data-api",'[data-toggle="modal"]',function(b){var c=a(this),d,e=a(c.attr("data-target")||(d=c.attr("href"))&&d.replace(/.*(?=#[^\s]+$)/,"")),f=e.data("modal")?"toggle":a.extend({},e.data(),c.data());b.preventDefault(),e.modal(f)})})}(window.jQuery),!function(a){function b(){a(c).parent().removeClass("open")}var c='[data-toggle="dropdown"]',d=function(b){var c=a(b).on("click.dropdown.data-api",this.toggle);a("html").on("click.dropdown.data-api",function(){c.parent().removeClass("open")})};d.prototype={constructor:d,toggle:function(c){var d=a(this),e,f,g;if(d.is(".disabled, :disabled"))return;return f=d.attr("data-target"),f||(f=d.attr("href"),f=f&&f.replace(/.*(?=#[^\s]*$)/,"")),e=a(f),e.length||(e=d.parent()),g=e.hasClass("open"),b(),g||e.toggleClass("open"),!1}},a.fn.dropdown=function(b){return this.each(function(){var c=a(this),e=c.data("dropdown");e||c.data("dropdown",e=new d(this)),typeof b=="string"&&e[b].call(c)})},a.fn.dropdown.Constructor=d,a(function(){a("html").on("click.dropdown.data-api",b),a("body").on("click.dropdown",".dropdown form",function(a){a.stopPropagation()}).on("click.dropdown.data-api",c,d.prototype.toggle)})}(window.jQuery),!function(a){var b=function(a,b){this.init("tooltip",a,b)};b.prototype={constructor:b,init:function(b,c,d){var e,f;this.type=b,this.$element=a(c),this.options=this.getOptions(d),this.enabled=!0,this.options.trigger!="manual"&&(e=this.options.trigger=="hover"?"mouseenter":"focus",f=this.options.trigger=="hover"?"mouseleave":"blur",this.$element.on(e,this.options.selector,a.proxy(this.enter,this)),this.$element.on(f,this.options.selector,a.proxy(this.leave,this))),this.options.selector?this._options=a.extend({},this.options,{trigger:"manual",selector:""}):this.fixTitle()},getOptions:function(b){return b=a.extend({},a.fn[this.type].defaults,b,this.$element.data()),b.delay&&typeof b.delay=="number"&&(b.delay={show:b.delay,hide:b.delay}),b},enter:function(b){var c=a(b.currentTarget)[this.type](this._options).data(this.type);if(!c.options.delay||!c.options.delay.show)return c.show();clearTimeout(this.timeout),c.hoverState="in",this.timeout=setTimeout(function(){c.hoverState=="in"&&c.show()},c.options.delay.show)},leave:function(b){var c=a(b.currentTarget)[this.type](this._options).data(this.type);if(!c.options.delay||!c.options.delay.hide)return c.hide();clearTimeout(this.timeout),c.hoverState="out",this.timeout=setTimeout(function(){c.hoverState=="out"&&c.hide()},c.options.delay.hide)},show:function(){var a,b,c,d,e,f,g;if(this.hasContent()&&this.enabled){a=this.tip(),this.setContent(),this.options.animation&&a.addClass("fade"),f=typeof this.options.placement=="function"?this.options.placement.call(this,a[0],this.$element[0]):this.options.placement,b=/in/.test(f),a.remove().css({top:0,left:0,display:"block"}).appendTo(b?this.$element:document.body),c=this.getPosition(b),d=a[0].offsetWidth,e=a[0].offsetHeight;switch(b?f.split(" ")[1]:f){case"bottom":g={top:c.top+c.height,left:c.left+c.width/2-d/2};break;case"top":g={top:c.top-e,left:c.left+c.width/2-d/2};break;case"left":g={top:c.top+c.height/2-e/2,left:c.left-d};break;case"right":g={top:c.top+c.height/2-e/2,left:c.left+c.width}}a.css(g).addClass(f).addClass("in")}},isHTML:function(a){return typeof a!="string"||a.charAt(0)==="<"&&a.charAt(a.length-1)===">"&&a.length>=3||/^(?:[^<]*<[\w\W]+>[^>]*$)/.exec(a)},setContent:function(){var a=this.tip(),b=this.getTitle();a.find(".tooltip-inner")[this.isHTML(b)?"html":"text"](b),a.removeClass("fade in top bottom left right")},hide:function(){function b(){var b=setTimeout(function(){d.off(a.support.transition.end).remove()},500);d.one(a.support.transition.end,function(){clearTimeout(b),d.remove()})}var c=this,d=this.tip();d.removeClass("in"),a.support.transition&&this.$tip.hasClass("fade")?b():d.remove()},fixTitle:function(){var a=this.$element;(a.attr("title")||typeof a.attr("data-original-title")!="string")&&a.attr("data-original-title",a.attr("title")||"").removeAttr("title")},hasContent:function(){return this.getTitle()},getPosition:function(b){return a.extend({},b?{top:0,left:0}:this.$element.offset(),{width:this.$element[0].offsetWidth,height:this.$element[0].offsetHeight})},getTitle:function(){var a,b=this.$element,c=this.options;return a=b.attr("data-original-title")||(typeof c.title=="function"?c.title.call(b[0]):c.title),a},tip:function(){return this.$tip=this.$tip||a(this.options.template)},validate:function(){this.$element[0].parentNode||(this.hide(),this.$element=null,this.options=null)},enable:function(){this.enabled=!0},disable:function(){this.enabled=!1},toggleEnabled:function(){this.enabled=!this.enabled},toggle:function(){this[this.tip().hasClass("in")?"hide":"show"]()}},a.fn.tooltip=function(c){return this.each(function(){var d=a(this),e=d.data("tooltip"),f=typeof c=="object"&&c;e||d.data("tooltip",e=new b(this,f)),typeof c=="string"&&e[c]()})},a.fn.tooltip.Constructor=b,a.fn.tooltip.defaults={animation:!0,placement:"top",selector:!1,template:'<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',trigger:"hover",title:"",delay:0}}(window.jQuery),!function(a){var b=function(a,b){this.init("popover",a,b)};b.prototype=a.extend({},a.fn.tooltip.Constructor.prototype,{constructor:b,setContent:function(){var a=this.tip(),b=this.getTitle(),c=this.getContent();a.find(".popover-title")[this.isHTML(b)?"html":"text"](b),a.find(".popover-content > *")[this.isHTML(c)?"html":"text"](c),a.removeClass("fade top bottom left right in")},hasContent:function(){return this.getTitle()||this.getContent()},getContent:function(){var a,b=this.$element,c=this.options;return a=b.attr("data-content")||(typeof c.content=="function"?c.content.call(b[0]):c.content),a},tip:function(){return this.$tip||(this.$tip=a(this.options.template)),this.$tip}}),a.fn.popover=function(c){return this.each(function(){var d=a(this),e=d.data("popover"),f=typeof c=="object"&&c;e||d.data("popover",e=new b(this,f)),typeof c=="string"&&e[c]()})},a.fn.popover.Constructor=b,a.fn.popover.defaults=a.extend({},a.fn.tooltip.defaults,{placement:"right",content:"",template:'<div class="popover"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"><p></p></div></div></div>'})}(window.jQuery),!function(a){var b='[data-dismiss="alert"]',c=function(c){a(c).on("click",b,this.close)};c.prototype.close=function(b){function c(){f.trigger("closed").remove()}var d=a(this),e=d.attr("data-target"),f;e||(e=d.attr("href"),e=e&&e.replace(/.*(?=#[^\s]*$)/,"")),f=a(e),b&&b.preventDefault(),f.length||(f=d.hasClass("alert")?d:d.parent()),f.trigger(b=a.Event("close"));if(b.isDefaultPrevented())return;f.removeClass("in"),a.support.transition&&f.hasClass("fade")?f.on(a.support.transition.end,c):c()},a.fn.alert=function(b){return this.each(function(){var d=a(this),e=d.data("alert");e||d.data("alert",e=new c(this)),typeof b=="string"&&e[b].call(d)})},a.fn.alert.Constructor=c,a(function(){a("body").on("click.alert.data-api",b,c.prototype.close)})}(window.jQuery),!function(a){var b=function(b,c){this.$element=a(b),this.options=a.extend({},a.fn.button.defaults,c)};b.prototype.setState=function(a){var b="disabled",c=this.$element,d=c.data(),e=c.is("input")?"val":"html";a+="Text",d.resetText||c.data("resetText",c[e]()),c[e](d[a]||this.options[a]),setTimeout(function(){a=="loadingText"?c.addClass(b).attr(b,b):c.removeClass(b).removeAttr(b)},0)},b.prototype.toggle=function(){var a=this.$element.parent('[data-toggle="buttons-radio"]');a&&a.find(".active").removeClass("active"),this.$element.toggleClass("active")},a.fn.button=function(c){return this.each(function(){var d=a(this),e=d.data("button"),f=typeof c=="object"&&c;e||d.data("button",e=new b(this,f)),c=="toggle"?e.toggle():c&&e.setState(c)})},a.fn.button.defaults={loadingText:"loading..."},a.fn.button.Constructor=b,a(function(){a("body").on("click.button.data-api","[data-toggle^=button]",function(b){var c=a(b.target);c.hasClass("btn")||(c=c.closest(".btn")),c.button("toggle")})})}(window.jQuery),!function(a){var b=function(b,c){this.$element=a(b),this.options=a.extend({},a.fn.collapse.defaults,c),this.options.parent&&(this.$parent=a(this.options.parent)),this.options.toggle&&this.toggle()};b.prototype={constructor:b,dimension:function(){var a=this.$element.hasClass("width");return a?"width":"height"},show:function(){var b,c,d,e;if(this.transitioning)return;b=this.dimension(),c=a.camelCase(["scroll",b].join("-")),d=this.$parent&&this.$parent.find("> .accordion-group > .in");if(d&&d.length){e=d.data("collapse");if(e&&e.transitioning)return;d.collapse("hide"),e||d.data("collapse",null)}this.$element[b](0),this.transition("addClass",a.Event("show"),"shown"),this.$element[b](this.$element[0][c])},hide:function(){var b;if(this.transitioning)return;b=this.dimension(),this.reset(this.$element[b]()),this.transition("removeClass",a.Event("hide"),"hidden"),this.$element[b](0)},reset:function(a){var b=this.dimension();return this.$element.removeClass("collapse")[b](a||"auto")[0].offsetWidth,this.$element[a!==null?"addClass":"removeClass"]("collapse"),this},transition:function(b,c,d){var e=this,f=function(){c.type=="show"&&e.reset(),e.transitioning=0,e.$element.trigger(d)};this.$element.trigger(c);if(c.isDefaultPrevented())return;this.transitioning=1,this.$element[b]("in"),a.support.transition&&this.$element.hasClass("collapse")?this.$element.one(a.support.transition.end,f):f()},toggle:function(){this[this.$element.hasClass("in")?"hide":"show"]()}},a.fn.collapse=function(c){return this.each(function(){var d=a(this),e=d.data("collapse"),f=typeof c=="object"&&c;e||d.data("collapse",e=new b(this,f)),typeof c=="string"&&e[c]()})},a.fn.collapse.defaults={toggle:!0},a.fn.collapse.Constructor=b,a(function(){a("body").on("click.collapse.data-api","[data-toggle=collapse]",function(b){var c=a(this),d,e=c.attr("data-target")||b.preventDefault()||(d=c.attr("href"))&&d.replace(/.*(?=#[^\s]+$)/,""),f=a(e).data("collapse")?"toggle":c.data();a(e).collapse(f)})})}(window.jQuery),!function(a){var b=function(b,c){this.$element=a(b),this.options=a.extend({},a.fn.typeahead.defaults,c),this.matcher=this.options.matcher||this.matcher,this.sorter=this.options.sorter||this.sorter,this.highlighter=this.options.highlighter||this.highlighter,this.updater=this.options.updater||this.updater,this.$menu=a(this.options.menu).appendTo("body"),this.source=this.options.source,this.shown=!1,this.listen()};b.prototype={constructor:b,select:function(){var a=this.$menu.find(".active").attr("data-value");return this.$element.val(this.updater(a)).change(),this.hide()},updater:function(a){return a},show:function(){var b=a.extend({},this.$element.offset(),{height:this.$element[0].offsetHeight});return this.$menu.css({top:b.top+b.height,left:b.left}),this.$menu.show(),this.shown=!0,this},hide:function(){return this.$menu.hide(),this.shown=!1,this},lookup:function(b){var c=this,d,e;return this.query=this.$element.val(),this.query?(d=a.grep(this.source,function(a){return c.matcher(a)}),d=this.sorter(d),d.length?this.render(d.slice(0,this.options.items)).show():this.shown?this.hide():this):this.shown?this.hide():this},matcher:function(a){return~a.toLowerCase().indexOf(this.query.toLowerCase())},sorter:function(a){var b=[],c=[],d=[],e;while(e=a.shift())e.toLowerCase().indexOf(this.query.toLowerCase())?~e.indexOf(this.query)?c.push(e):d.push(e):b.push(e);return b.concat(c,d)},highlighter:function(a){var b=this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&");return a.replace(new RegExp("("+b+")","ig"),function(a,b){return"<strong>"+b+"</strong>"})},render:function(b){var c=this;return b=a(b).map(function(b,d){return b=a(c.options.item).attr("data-value",d),b.find("a").html(c.highlighter(d)),b[0]}),b.first().addClass("active"),this.$menu.html(b),this},next:function(b){var c=this.$menu.find(".active").removeClass("active"),d=c.next();d.length||(d=a(this.$menu.find("li")[0])),d.addClass("active")},prev:function(a){var b=this.$menu.find(".active").removeClass("active"),c=b.prev();c.length||(c=this.$menu.find("li").last()),c.addClass("active")},listen:function(){this.$element.on("blur",a.proxy(this.blur,this)).on("keypress",a.proxy(this.keypress,this)).on("keyup",a.proxy(this.keyup,this)),(a.browser.webkit||a.browser.msie)&&this.$element.on("keydown",a.proxy(this.keypress,this)),this.$menu.on("click",a.proxy(this.click,this)).on("mouseenter","li",a.proxy(this.mouseenter,this))},keyup:function(a){switch(a.keyCode){case 40:case 38:break;case 9:case 13:if(!this.shown)return;this.select();break;case 27:if(!this.shown)return;this.hide();break;default:this.lookup()}a.stopPropagation(),a.preventDefault()},keypress:function(a){if(!this.shown)return;switch(a.keyCode){case 9:case 13:case 27:a.preventDefault();break;case 38:if(a.type!="keydown")break;a.preventDefault(),this.prev();break;case 40:if(a.type!="keydown")break;a.preventDefault(),this.next()}a.stopPropagation()},blur:function(a){var b=this;setTimeout(function(){b.hide()},150)},click:function(a){a.stopPropagation(),a.preventDefault(),this.select()},mouseenter:function(b){this.$menu.find(".active").removeClass("active"),a(b.currentTarget).addClass("active")}},a.fn.typeahead=function(c){return this.each(function(){var d=a(this),e=d.data("typeahead"),f=typeof c=="object"&&c;e||d.data("typeahead",e=new b(this,f)),typeof c=="string"&&e[c]()})},a.fn.typeahead.defaults={source:[],items:8,menu:'<ul class="typeahead dropdown-menu"></ul>',item:'<li><a href="#"></a></li>'},a.fn.typeahead.Constructor=b,a(function(){a("body").on("focus.typeahead.data-api",'[data-provide="typeahead"]',function(b){var c=a(this);if(c.data("typeahead"))return;b.preventDefault(),c.typeahead(c.data())})})}(window.jQuery),function(){var a,b=Array.prototype.slice;(window||global).Luca=function(){var a,c,d,e,f,g;f=arguments[0],a=2<=arguments.length?b.call(arguments,1):[];if(_.isString(f)&&(g=Luca.cache(f)))return g;if(_.isString(f)&&(g=Luca.find(f)))return g;if(_.isObject(f)&&f.ctype!=null)return Luca.util.lazyComponent(f);_.isObject(f)&&f.defines&&f["extends"]&&(c=f.defines,e=f["extends"]);if(_.isFunction(d=_(a).last()))return d()},_.extend(Luca,{VERSION:"0.9.4",core:{},containers:{},components:{},modules:{},util:{},fields:{},registry:{},options:{}}),_.extend(Luca,Backbone.Events),Luca.autoRegister=!0,Luca.developmentMode=!1,Luca.enableGlobalObserver=!1,Luca.enableBootstrap=!0,Luca.keys={ENTER:13,ESCAPE:27,KEYLEFT:37,KEYUP:38,KEYRIGHT:39,KEYDOWN:40,SPACEBAR:32,FORWARDSLASH:191},Luca.keyMap=_(Luca.keys).inject(function(a,b,c){return a[b]=c.toLowerCase(),a},{}),Luca.find=function(){return},Luca.supportsEvents=Luca.supportsBackboneEvents=function(a){return Luca.isComponent(a)||_.isFunction(a!=null?a.trigger:void 0)||_.isFunction(a!=null?a.bind:void 0)},Luca.isComponent=function(a){return Luca.isBackboneModel(a)||Luca.isBackboneView(a)||Luca.isBackboneCollection(a)},Luca.isComponentPrototype=function(a){return Luca.isViewPrototype(a)||Luca.isModelPrototype(a)||Luca.isCollectionPrototype(a)},Luca.isBackboneModel=function(a){return _.isString(a)&&(a=Luca.util.resolve(a)),_.isFunction(a!=null?a.set:void 0)&&_.isFunction(a!=null?a.get:void 0)&&_.isObject(a!=null?a.attributes:void 0)},Luca.isBackboneView=function(a){return _.isString(a)&&(a=Luca.util.resolve(a)),_.isFunction(a!=null?a.render:void 0)&&!_.isUndefined(a!=null?a.el:void 0)},Luca.isBackboneCollection=function(a){return _.isString(a)&&(a=Luca.util.resolve(a)),_.isFunction(a!=null?a.fetch:void 0)&&_.isFunction(a!=null?a.reset:void 0)},Luca.isViewPrototype=function(a){return _.isString(a)&&(a=Luca.util.resolve(a)),a!=null&&a.prototype!=null&&a.prototype.make!=null&&a.prototype.$!=null&&a.prototype.render!=null},Luca.isModelPrototype=function(a){return _.isString(a)&&(a=Luca.util.resolve(a)),a!=null&&(typeof a.prototype=="function"?a.prototype(a.prototype.save!=null&&a.prototype.changedAttributes!=null):void 0)},Luca.isCollectionPrototype=function(a){return _.isString(a)&&(a=Luca.util.resolve(a)),a!=null&&a.prototype!=null&&!Luca.isModelPrototype(a)&&a.prototype.reset!=null&&a.prototype.select!=null&&a.prototype.reject!=null},Luca.inheritanceChain=function(a){return _(Luca.parentClasses(a)).map(function(a){return Luca.util.resolve(a)})},Luca.parentClasses=function(a){var b,c,d;return c=[],_.isString(a)&&(a=Luca.util.resolve(a)),c.push(a.displayName||((d=a.prototype)!=null?d.displayName:void 0)||Luca.parentClass(a)),b=function(){var b;b=[];while(Luca.parentClass(a)!=null)b.push(a=Luca.parentClass(a));return b}(),c=c.concat(b),_.uniq(c)},Luca.parentClass=function(a){var b,c,d;b=[],_.isString(a)&&(a=Luca.util.resolve(a));if(Luca.isComponent(a))return a.displayName;if(Luca.isComponentPrototype(a))return typeof (c=a.prototype)._superClass=="function"?(d=c._superClass())!=null?d.displayName:void 0:void 0},Luca.template=function(a,b){var c,d,e,f,g;window.JST||(window.JST={});if(_.isFunction(a))return a(b);d=(g=Luca.templates)!=null?g[a]:void 0,c=typeof JST!="undefined"&&JST!==null?JST[a]:void 0,d==null&&c==null&&(e=new RegExp(""+a+"$"),d=_(Luca.templates).detect(function(a,b){return e.exec(b)}),c=_(JST).detect(function(a,b){return e.exec(b)}));if(!d&&!c)throw"Could not find template named "+a;return f=d||c,b!=null?f(b):f},Luca.available_templates=function(a){var b;return a==null&&(a=""),b=_(Luca.templates).keys(),a.length>0?_(b).select(function(b){return b.match(a)}):b},a={module:function(a,b){_.extend(a,b);if(a.included&&_(a.included).isFunction())return a.included.apply(a)},"delete":function(a,b){var c;return c=a[b],delete a[b],c},idle:function(a,b){var c;return b==null&&(b=1e3),window.DISABLE_IDLE&&(b=0),c=void 0,function(){return c&&window.clearTimeout(c),c=window.setTimeout(_.bind(a,this),b)}},idleShort:function(a,b){var c;return b==null&&(b=100),window.DISABLE_IDLE&&(b=0),c=void 0,function(){return c&&window.clearTimeout(c),c=window.setTimeout(_.bind(a,this),b)}},idleMedium:function(a,b){var c;return b==null&&(b=2e3),window.DISABLE_IDLE&&(b=0),c=void 0,function(){return c&&window.clearTimeout(c),c=window.setTimeout(_.bind(a,this),b)}},idleLong:function(a,b){var c;return b==null&&(b=5e3),window.DISABLE_IDLE&&(b=0),c=void 0,function(){return c&&window.clearTimeout(c),c=window.setTimeout(_.bind(a,this),b)}}},_.mixin(a)}.call(this),function(){var currentNamespace;Luca.util.resolve=function(a,b){return b||(b=window||global),_(a.split(/\./)).inject(function(a,b){return a=a!=null?a[b]:void 0},b)},Luca.util.nestedValue=Luca.util.resolve,Luca.util.classify=function(a){return a==null&&(a=""),_.string.camelize(_.string.capitalize(a))},Luca.util.hook=function(a){var b,c,d;return a==null&&(a=""),c=a.split(":"),d=c.shift(),c=_(c).map(function(a){return _.string.capitalize(a)}),b=d+c.join("")},Luca.util.isIE=function(){try{return Object.defineProperty({},"",{}),!1}catch(a){return!0}},currentNamespace=window||global,Luca.util.namespace=function(namespace){return namespace==null?currentNamespace:(currentNamespace=_.isString(namespace)?Luca.util.resolve(namespace,window||global):namespace,currentNamespace!=null?currentNamespace:currentNamespace=eval("(window||global)."+namespace+" = {}"))},Luca.util.lazyComponent=function(config){var componentClass,constructor,ctype;_.isObject(config)&&(ctype=config.ctype||config.type),_.isString(config)&&(ctype=config),componentClass=Luca.registry.lookup(ctype);if(!componentClass)throw"Invalid Component Type: "+ctype+". Did you forget to register it?";return constructor=eval(componentClass),new constructor(config)},Luca.util.selectProperties=function(a,b,c){var d;return d=_(b).values(),_(d).select(a)},Luca.util.loadScript=function(a,b){var c;return c=document.createElement("script"),c.type="text/javascript",c.readyState&&(c.onreadystatechange=function(){return c.readyState==="loaded"||c.readyState==="complete"?(c.onreadystatechange=null,b()):c.onload=function(){return b()}}),c.src=a,document.body.appendChild(c)},Luca.util.make=Backbone.View.prototype.make,Luca.util.list=function(a,b,c){var d,e,f,g;b==null&&(b={}),d=c?"ol":"ul",d=Luca.util.make(d,b);if(_.isArray(a))for(f=0,g=a.length;f<g;f++)e=a[f],$(d).append(Luca.util.make("li",{},e));return d.outerHTML},Luca.util.label=function(a,b,c){var d;return a==null&&(a=""),c==null&&(c="label"),d=c,b!=null&&(d+=" "+c+"-"+b),Luca.util.make("span",{"class":d},a)},Luca.util.badge=function(a,b,c){var d;return a==null&&(a=""),c==null&&(c="badge"),d=c,b!=null&&(d+=" "+c+"-"+b),Luca.util.make("span",{"class":d},a)}}.call(this),function(){Luca.DevelopmentToolHelpers={refreshCode:function(){var a;return a=this,_(this.eventHandlerProperties()).each(function(b){return a[b]=a.definitionClass()[b]}),this.autoBindEventHandlers===!0&&this.bindAllEventHandlers(),this.delegateEvents()},eventHandlerProperties:function(){var a;return a=_(this.events).values(),_(a).select(function(a){return _.isString(a)})},eventHandlerFunctions:function(){var a,b=this;return a=_(this.events).values(),_(a).map(function(a){return _.isFunction(a)?a:b[a]})}}}.call(this),function(){var a;a=function(){function a(a,b,c){var d,e=this;this.object=a,c==null&&(c=!0),_.isFunction(b)?d=b:_.isString(b)&&_.isFunction(this.object[b])&&(d=this.object[b]);if(!_.isFunction(d))throw"Must pass a function or a string representing one";c===!0?this.fn=function(){return _.defer(d)}:this.fn=d,this}return a.prototype.until=function(a,b){return a!=null&&b==null&&(b=a,a=this.object),a.once(b,this.fn),this.object},a}(),Luca.Events={defer:function(b,c){return c==null&&(c=!0),new a(this,b,c)},once:function(a,b,c){var d;return c||(c=this),d=function(){return b.apply(c,arguments),this.unbind(a,d)},this.bind(a,d)}}}.call(this),function(){var DefineProxy;Luca.define=function(a){return new DefineProxy(a)},Luca.component=Luca.define,DefineProxy=function(){function DefineProxy(a){var b;this.namespace=Luca.util.namespace(),this.componentId=this.componentName=a,a.match(/\./)&&(this.namespaced=!0,b=a.split("."),this.componentId=b.pop(),this.namespace=b.join("."),Luca.registry.addNamespace(b.join(".")))}return DefineProxy.prototype["in"]=function(a){return this.namespace=a,this},DefineProxy.prototype.from=function(a){return this.superClassName=a,this},DefineProxy.prototype["extends"]=function(a){return this.superClassName=a,this},DefineProxy.prototype.extend=function(a){return this.superClassName=a,this},DefineProxy.prototype.enhance=function(a){return a!=null?this["with"](a):this},DefineProxy.prototype["with"]=function(properties){var at,componentType,_base;return at=this.namespaced?Luca.util.resolve(this.namespace,window||global):window||global,this.namespaced&&at==null&&(eval("(window||global)."+this.namespace+" = {}"),at=Luca.util.resolve(this.namespace,window||global)),at[this.componentId]=Luca.extend(this.superClassName,this.componentName,properties),Luca.autoRegister===!0&&(Luca.isViewPrototype(at[this.componentId])&&(componentType="view"),Luca.isCollectionPrototype(at[this.componentId])&&((_base=Luca.Collection).namespaces||(_base.namespaces=[]),Luca.Collection.namespaces.push(this.namespace),componentType="collection"),Luca.isModelPrototype(at[this.componentId])&&(componentType="model"),Luca.register(_.string.underscored(this.componentId),this.componentName,componentType)),at[this.componentId]},DefineProxy}(),Luca.extend=function(a,b,c){var d,e,f,g,h,i;c==null&&(c={}),f=Luca.util.resolve(a,window||global);if(!_.isFunction(f!=null?f.extend:void 0))throw""+a+" is not a valid component to extend from";c.displayName=b,c._superClass=function(){return f.displayName||(f.displayName=a),f},c._super=function(a,b,c){var d;return(d=this._superClass().prototype[a])!=null?d.apply(b,c):void 0},d=f.extend(c);if(_.isArray(c!=null?c.include:void 0)){i=c.include;for(g=0,h=i.length;g<h;g++)e=i[g],_.isString(e)&&(e=Luca.util.resolve(e)),_.extend(d.prototype,e)}return d},_.mixin({def:Luca.define})}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["components/bootstrap_form_controls"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<div class='form-actions'>\n <a class='btn btn-primary submit-button'>\n <i class='icon-ok icon-white'></i>\n Save Changes\n </a>\n <a class='btn reset-button cancel-button'>\n <i class='icon-remove'></i>\n Cancel\n </a>\n</div>\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["components/collection_loader_view"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<div class='modal' id='progress-model' style='display: none;'>\n <div class='progress progress-info progress-striped active'>\n <div class='bar' style='width: 0%;'></div>\n </div>\n <div class='message'>\n Initializing...\n </div>\n</div>\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["components/form_alert"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<div class='",className,"'>\n <a class='close' data-dismiss='alert' href='#'>x</a>\n ",message,"\n</div>\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["components/grid_view"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<div class='luca-ui-g-view-wrapper'>\n <div class='g-view-header'></div>\n <div class='luca-ui-g-view-body'>\n <table cellpadding='0' cellspacing='0' class='luca-ui-g-view scrollable-table' width='100%'>\n <thead class='fixed'></thead>\n <tbody class='scrollable'></tbody>\n </table>\n </div>\n <div class='luca-ui-g-view-footer'></div>\n</div>\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["components/grid_view_empty_text"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<div class='empty-text-wrapper'>\n <p>\n ",text,"\n </p>\n</div>\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["components/load_mask"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<div class='load-mask'>\n <div class='progress progress-striped active'>\n <div class='bar' style='width:1%'></div>\n </div>\n</div>\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["components/nav_bar"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<div class='navbar-inner'>\n <div class='luca-ui-navbar-body container'></div>\n</div>\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["containers/basic"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<div class='",classes,"' id='",id,"' style='",style,"'></div>\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["containers/tab_selector_container"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{}){__p.push("<div class='tab-selector-container' id='",cid,"-tab-selector'>\n <ul class='nav nav-tabs' id='",cid,"-tabs-nav'>\n ");for(var i=0;i<components.length;i++){__p.push("\n ");var component=components[i];__p.push("\n <li class='tab-selector' data-target='",i,"'>\n <a data-target='",i,"'>\n ",component.title,"\n </a>\n </li>\n ")}__p.push("\n </ul>\n</div>\n")}return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["containers/tab_view"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<ul class='nav ",navClass,"' id='",cid,"-tabs-selector'></ul>\n<div class='tab-content' id='",cid,"-tab-view-content'></div>\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["containers/toolbar_wrapper"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<div class='luca-ui-toolbar-wrapper' id='",id,"'></div>\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["fields/button_field"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<label>&nbsp</label>\n<input class='btn ",input_class,"' id='",input_id,"' style='",inputStyles,"' type='",input_type,"' value='",input_value,"' />\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["fields/button_field_link"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<a class='btn ",input_class,"'>\n "),icon_class.length&&__p.push("\n <i class='",icon_class,"'></i>\n "),__p.push("\n ",input_value,"\n</a>\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["fields/checkbox_array"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<div class='control-group'>\n <label for='",input_id,"'>\n ",label,"\n </label>\n <div class='controls'></div>\n</div>\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["fields/checkbox_array_item"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<label for='",input_id,"'>\n <input id='",input_id,"' name='",input_name,"' type='checkbox' value='",value,"' />\n ",label,"\n</label>\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["fields/checkbox_field"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<label for='",input_id,"'>\n ",label,"\n <input name='",input_name,"' style='",inputStyles,"' type='checkbox' value='",input_value,"' />\n</label>\n"),helperText&&__p.push("\n<p class='helper-text help-block'>\n ",helperText,"\n</p>\n"),__p.push("\n");return __p.join(""
6
- )}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["fields/file_upload_field"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<label for='",input_id,"'>\n ",label,"\n</label>\n<input id='",input_id,"' name='",input_name,"' style='",inputStyles,"' type='file' />\n"),helperText&&__p.push("\n<p class='helper-text help-block'>\n ",helperText,"\n</p>\n"),__p.push("\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["fields/hidden_field"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<input id='",input_id,"' name='",input_name,"' type='hidden' value='",input_value,"' />\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["fields/select_field"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<label for='",input_id,"'>\n ",label,"\n</label>\n<div class='controls'>\n <select id='",input_id,"' name='",input_name,"' style='",inputStyles,"'></select>\n "),helperText&&__p.push("\n <p class='helper-text help-block'>\n ",helperText,"\n </p>\n "),__p.push("\n</div>\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["fields/text_area_field"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<label for='",input_id,"'>\n ",label,"\n</label>\n<textarea class='",input_class,"' id='",input_id,"' name='",input_name,"' style='",inputStyles,"'></textarea>\n"),helperText&&__p.push("\n<p class='helper-text help-block'>\n ",helperText,"\n</p>\n"),__p.push("\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["fields/text_field"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push(""),(typeof label!="undefined"&&typeof hideLabel!="undefined"&&!hideLabel||typeof hideLabel=="undefined")&&__p.push("\n<label class='control-label' for='",input_id,"'>\n ",label,"\n</label>\n"),__p.push("\n<div class='controls'>\n "),typeof addOn!="undefined"&&__p.push("\n <span class='add-on'>\n ",addOn,"\n </span>\n "),__p.push("\n <input class='",input_class,"' id='",input_id,"' name='",input_name,"' placeholder='",placeHolder,"' style='",inputStyles,"' type='text' />\n "),helperText&&__p.push("\n <p class='helper-text help-block'>\n ",helperText,"\n </p>\n "),__p.push("\n</div>\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["sample/contents"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("<p>Sample Contents</p>\n");return __p.join("")}}.call(this),function(){Luca.templates||(Luca.templates={}),Luca.templates["sample/welcome"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push("welcome.luca\n");return __p.join("")}}.call(this),function(){Luca.modules.Deferrable={configure_collection:function(a){var b,c,d;a==null&&(a=!0);if(!this.collection)return;_.isString(this.collection)&&(b=(c=Luca.CollectionManager)!=null?c.get():void 0)&&(this.collection=b.getOrCreate(this.collection)),this.collection&&_.isFunction(this.collection.fetch)&&_.isFunction(this.collection.reset)||(this.collection=new Luca.Collection(this.collection.initial_set,this.collection));if((d=this.collection)!=null?d.deferrable_trigger:void 0)this.deferrable_trigger=this.collection.deferrable_trigger;if(a)return this.deferrable=this.collection}}}.call(this),function(){Luca.modules.LoadMaskable={_included:function(a,b){var c=this;_.bindAll(a,"applyLoadMask","disableLoadMask");if(this.loadMask===!0)return this.defer(function(){c.$el.addClass("with-mask");if(c.$(".load-mask").length===0)return c.loadMaskTarget().prepend(Luca.template(c.loadMaskTemplate,c)),c.$(".load-mask").hide()}).until("after:render"),this.on(this.loadmaskEnableEvent||"enable:loadmask",this.applyLoadMask),this.on(this.loadmaskDisableEvent||"disable:loadmask",this.applyLoadMask)},loadMaskTarget:function(){return this.loadMaskEl!=null?this.$(this.loadMaskEl):this.$bodyEl()},disableLoadMask:function(){return this.$(".load-mask .bar").css("width","100%"),this.$(".load-mask").hide(),clearInterval(this.loadMaskInterval)},enableLoadMask:function(){var a,b=this;this.$(".load-mask").show().find(".bar").css("width","0%"),a=this.$(".load-mask .progress").width(),a<20&&(a=this.$el.width())<20&&(a=this.$el.parent().width()),this.loadMaskInterval=setInterval(function(){var a,c;return a=b.$(".load-mask .bar").width(),c=a+12,b.$(".load-mask .bar").css("width",c)},200);if(this.loadMaskTimeout==null)return;return _.delay(function(){return b.disableLoadMask()},this.loadMaskTimeout)},applyLoadMask:function(){return this.$(".load-mask").is(":visible")?this.disableLoadMask():this.enableLoadMask()}}}.call(this),function(){Luca.LocalStore=function(){function a(a){var b;this.name=a,b=localStorage.getItem(this.name),this.data=b&&JSON.parse(b)||{}}return a.prototype.guid=function(){var a;return a=function(){return((1+Math.random())*65536|0).toString(16).substring(1)},a()+a()+"-"+a()+"-"+a()+"-"+a()+"-"+a()+a()+a()},a.prototype.save=function(){return localStorage.setItem(this.name,JSON.stringify(this.data))},a.prototype.create=function(a){return a.id||(a.id=a.attribtues.id=this.guid()),this.data[a.id]=a,this.save(),a},a.prototype.update=function(a){return this.data[a.id]=a,this.save(),a},a.prototype.find=function(a){return this.data[a.id]},a.prototype.findAll=function(){return _.values(this.data)},a.prototype.destroy=function(a){return delete this.data[a.id],this.save(),a},a}(),Backbone.LocalSync=function(a,b,c){var d,e;return e=b.localStorage||b.collection.localStorage,d=function(){switch(a){case"read":return b.id?e.find(b):e.findAll();case"create":return e.create(b);case"update":return e.update(b);case"delete":return e.destroy(b)}}(),d?c.success(d):c.error("Record not found")}}.call(this),function(){var a,b;b={classes:{},model_classes:{},collection_classes:{},namespaces:["Luca.containers","Luca.components"]},a={cid_index:{},name_index:{}},Luca.defaultComponentType="view",Luca.register=function(a,c,d){d==null&&(d="view"),Luca.trigger("component:registered",a,c);switch(d){case"model":return b.model_classes[a]=c;case"collection":return b.model_classes[a]=c;default:return b.classes[a]=c}},Luca.development_mode_register=function(a,c){var d,e,f;return d=b.classes[a],Luca.enableDevelopmentTools===!0&&d!=null&&(f=Luca.util.resolve(d,window),e=Luca.registry.findInstancesByClassName(c),_(e).each(function(a){var b;return a!=null?(b=a.refreshCode)!=null?b.call(a,f):void 0:void 0})),Luca.register(a,c)},Luca.registry.addNamespace=function(a){return b.namespaces.push(a),b.namespaces=_(b.namespaces).uniq()},Luca.registry.namespaces=function(a){return a==null&&(a=!0),_(b.namespaces).map(function(b){return a?Luca.util.resolve(b):b})},Luca.registry.aliases={grid:"grid_view",form:"form_view",text:"text_field",button:"button_field",select:"select_field",card:"card_view",paged:"card_view",wizard:"card_view",collection:"collection_view"},Luca.registry.lookup=function(a){var c,d,e,f,g,h;if(c=Luca.registry.aliases[a])a=c;return d=b.classes[a],d!=null?d:(e=Luca.util.classify(a),g=Luca.registry.namespaces(),f=(h=_(g).chain().map(function(a){return a[e]}).compact().value())!=null?h[0]:void 0)},Luca.registry.instances=function(){return _(a.cid_index).values()},Luca.registry.findInstancesByClassName=function(a){var b;return b=Luca.registry.instances(),_(b).select(function(b){var c;return b.displayName===a||(typeof b._superClass=="function"?(c=b._superClass())!=null?c.displayName:void 0:void 0)===a})},Luca.registry.classes=function(a){return a==null&&(a=!1),_(_.extend({},b.classes,b.model_classes,b.collection_classes)).map(function(b,c){return a?b:{className:b,ctype:c}})},Luca.cache=function(b,c){var d;return c!=null&&(a.cid_index[b]=c),c=a.cid_index[b],(c!=null?c.component_name:void 0)!=null?(Luca.trigger("component:created:"+c.component_name,c),a.name_index[c.component_name]=c.cid):(c!=null?c.name:void 0)!=null&&(Luca.trigger("component:created:"+c.component_name,c),a.name_index[c.name]=c.cid),c!=null?c:(d=a.name_index[b],a.cid_index[d])}}.call(this),function(){var a=Array.prototype.slice;Luca.Observer=function(){function b(a){var b=this;this.options=a!=null?a:{},_.extend(this,Backbone.Events),this.type=this.options.type,this.options.debugAll&&this.bind("all",function(a,b,c){return console.log("ALL",a,b,c)})}return b.prototype.relay=function(){var b,c;return c=arguments[0],b=2<=arguments.length?a.call(arguments,1):[],console.log("Relaying",trigger,b),this.trigger("event",c,b),this.trigger("event:"+b[0],c,b.slice(1))},b}(),Luca.Observer.enableObservers=function(a){return a==null&&(a={}),Luca.enableGlobalObserver=!0,Luca.ViewObserver=new Luca.Observer(_.extend(a,{type:"view"})),Luca.CollectionObserver=new Luca.Observer(_.extend(a,{type:"collection"}))}}.call(this),function(){var a,b,c,d,e;_.def("Luca.View")["extends"]("Backbone.View")["with"]({include:["Luca.Events"],additionalClassNames:[],hooks:["after:initialize","before:render","after:render","first:activation","activation","deactivation"],initialize:function(b){var c,f,g,h,i,j,k,l,m,n,o,p;this.options=b!=null?b:{},this.trigger("before:initialize",this,this.options),_.extend(this,this.options),this.name!=null&&(this.cid=_.uniqueId(this.name)),h=this.bodyTemplateVars?this.bodyTemplateVars.call(this):this;if(g=this.bodyTemplate)this.$el.empty(),Luca.View.prototype.$html.call(this,Luca.template(g,h));Luca.cache(this.cid,this),this.setupHooks(_(Luca.View.prototype.hooks.concat(this.hooks)).uniq()),(this.autoBindEventHandlers===!0||this.bindAllEvents===!0)&&a.call(this),this.additionalClassNames&&_.isString(this.additionalClassNames)&&(this.additionalClassNames=this.additionalClassNames.split(" ")),this.gridSpan&&this.additionalClassNames.push("span"+this.gridSpan),this.gridOffset&&this.additionalClassNames.push("offset"+this.gridOffset),this.gridRowFluid&&this.additionalClassNames.push("row-fluid"),this.gridRow&&this.additionalClassNames.push("row");if(((m=this.additionalClassNames)!=null?m.length:void 0)>0){n=this.additionalClassNames;for(i=0,k=n.length;i<k;i++)c=n[i],this.$el.addClass(c)}this.wrapperClass!=null&&this.$wrap(this.wrapperClass),e.call(this),d.call(this),this.delegateEvents(),this.stateful===!0&&this.state==null&&(this.state=new Backbone.Model(this.defaultState||{}),this.set==null&&(this.set=_.bind(this,this.state.set),this.get=_.bind(this,this.state.get)));if(((o=this.mixins)!=null?o.length:void 0)>0){p=this.mixins;for(j=0,l=p.length;j<l;j++)f=p[j],Luca.modules[f]._included.call(this,this,f)}return this.trigger("after:initialize",this)},$wrap:function(a){return _.isString(a)&&!a.match(/[<>]/)&&(a=this.make("div",{"class":a})),this.$el.wrap(a)},$template:function(a,b){return b==null&&(b={}),this.$el.html(Luca.template(a,b))},$html:function(a){return this.$el.html(a)},$append:function(a){return this.$el.append(a)},$attach:function(){return this.$container().append(this.el)},$bodyEl:function(){return this.$el},$container:function(){return $(this.container)},setupHooks:function(a){var b=this;return a||(a=this.hooks),_(a).each(function(a){var c,d;d=Luca.util.hook(a),c=function(){var a;return(a=b[d])!=null?a.apply(b,arguments):void 0};if(a!=null?a.match(/once:/):void 0)c=_.once(c);return b.bind(a,c)})},registerEvent:function(a,b){return this.events||(this.events={}),this.events[a]=b,this.delegateEvents()},definitionClass:function(){var a;return(a=Luca.util.resolve(this.displayName,window))!=null?a.prototype:void 0},collections:function(){return Luca.util.selectProperties(Luca.isBackboneCollection,this)},models:function(){return Luca.util.selectProperties(Luca.isBackboneModel,this)},views:function(){return Luca.util.selectProperties(Luca.isBackboneView,this)},debug:function(){var a,b,c,d;if(!this.debugMode&&window.LucaDebugMode==null)return;d=[];for(b=0,c=arguments.length;b<c;b++)a=arguments[b],d.push(console.log([this.name||this.cid,a]));return d},trigger:function(){return Luca.enableGlobalObserver&&(Luca.developmentMode===!0||this.observeEvents===!0)&&(Luca.ViewObserver||(Luca.ViewObserver=new Luca.Observer({type:"view"})),Luca.ViewObserver.relay(this,arguments)),Backbone.View.prototype.trigger.apply(this,arguments)}}),c=Backbone.View.extend,b=function(a){var b;return b=a.render,b||(b=Luca.View.prototype.$attach),a.render=function(){var a,c,d,e,f,g,h=this;return g=this,this.deferrable?(e=this.deferrable_target,Luca.isBackboneCollection(this.deferrable)||(this.deferrable=this.collection),e||(e=this.deferrable),f=this.deferrable_event?this.deferrable_event:"reset",c=function(){return b.call(g),g.trigger("after:render",g)},g.defer(c).until(e,f),g.trigger("before:render",this),a=this.deferrable_trigger||this.deferUntil,a==null?e[this.deferrable_method||"fetch"].call(e):(d=_.once(function(){var a,b;return typeof (a=h.deferrable)[b=h.deferrable_method||"fetch"]=="function"?a[b]():void 0}),(this.deferrable_target||this).bind(this.deferrable_trigger,d)),this):(this.trigger("before:render",this),b.apply(this,arguments),this.trigger("after:render",this),this)},a},a=function(){var a=this;return _(this.events).each(function(b,c){if(_.isString(b))return _.bindAll(a,b)})},d=function(){var a,b,c,d,e,f,g;if(_.isEmpty(this.applicationEvents))return;a=this.app;if(_.isString(a)||_.isUndefined(a))a=(e=Luca.Application)!=null?typeof e.get=="function"?e.get(a):void 0:void 0;if(!Luca.supportsEvents(a))throw"Error binding to the application object on "+(this.name||this.cid);f=this.applicationEvents,g=[];for(c=0,d=f.length;c<d;c++){b=f[c],_.isString(c)&&(c=this[c]);if(!_.isFunction(c))throw"Error registering application event "+b+" on "+(this.name||this.cid);g.push(a.on(b,c))}return g},e=function(){var a,b,c,d,e,f,g,h,i;if(_.isEmpty(this.collectionEvents))return;e=this.collectionManager;if(_.isString(e)||_.isUndefined(e))e=Luca.CollectionManager.get(e);g=this.collectionEvents,i=[];for(f in g){c=g[f],console.log("Sig",f,"Handler",c),h=f.split(" "),d=h[0],b=h[1],a=e.getOrCreate(d);if(!a)throw"Could not find collection specified by "+d;_.isString(c)&&(c=this[c]);if(!_.isFunction(c))throw"invalid collectionEvents configuration";try{i.push(a.bind(b,c))}catch(j){throw console.log("Error Binding To Collection in registerCollectionEvents",this),j}}return i},Luca.View.extend=function(a){var d,e,f,g;a=b(a);if(a.mixins!=null&&_.isArray(a.mixins)){g=a.mixins;for(e=0,f=g.length;e<f;e++)d=g[e],_.extend(a,Luca.modules[d])}return c.call(this,a)}}.call(this),function(){var a;a=function(){var a,b,c,d,e=this;if(_.isUndefined(this.computed))return;this._computed={},c=this.computed,d=[];for(a in c)b=c[a],this.on("change:"+a,function(){return e._computed[a]=e[a].call(e)}),_.isString(b)&&(b=b.split(",")),d.push(_(b).each(function(b){e.on("change:"+b,function(){return e.trigger("change:"+a)});if(e.has(b))return e.trigger("change:"+a)}));return d},_.def("Luca.Model")["extends"]("Backbone.Model")["with"]({include:["Luca.Events"],initialize:function(){return Backbone.Model.prototype.initialize(this,arguments),a.call(this)},get:function(a){var b;return((b=this.computed)!=null?b.hasOwnProperty(a):void 0)?this._computed[a]:Backbone.Model.prototype.get.call(this,a)}})}.call(this),function(){var a;a="Backbone.Collection",Backbone.QueryCollection!=null&&(a="Backbone.QueryCollection"),_.def("Luca.Collection")["extends"](a)["with"]({include:["Luca.Events"],cachedMethods:[],remoteFilter:!1,initialize:function(a,b){var c,d=this;a==null&&(a=[]),this.options=b,_.extend(this,this.options),this.setupMethodCaching(),this._reset(),this.cached&&console.log("The @cached property of Luca.Collection is being deprecated. Please change to cache_key");if(this.cache_key||(this.cache_key=this.cached))this.bootstrap_cache_key=_.isFunction(this.cache_key)?this.cache_key():this.cache_key;(this.registerAs||this.registerWith)&&console.log("This configuration API is deprecated. use @name and @manager properties instead"),this.name||(this.name=this.registerAs),this.manager||(this.manager=this.registerWith),this.manager=_.isFunction(this.manager)?this.manager():this.manager,this.name&&!this.manager&&(this.manager=Luca.CollectionManager.get()),this.manager&&(this.name||(this.name=this.cache_key()),this.name=_.isFunction(this.name)?this.name():this.name,!this.private&&!this.anonymous&&this.bind("after:initialize",function(){return d.register(d.manager,d.name,d)}));if(this.useLocalStorage===!0&&window.localStorage!=null)throw c=this.bootstrap_cache_key||this.name,"Must specify either a cached or registerAs property to use localStorage";return _.isArray(this.data)&&this.data.length>0&&(this.memoryCollection=!0),this.useNormalUrl!==!0&&this.__wrapUrl(),Backbone.Collection.prototype.initialize.apply(this,[a,this.options]),a&&this.reset(a,{silent:!0,parse:b!=null?b.parse:void 0}),this.trigger("after:initialize")},__wrapUrl:function(){var a,b,c=this;return _.isFunction(this.url)?this.url=_.wrap(this.url,function(a){var b,d,e,f,g;return g=a.apply(c),e=g.split("?"),e.length>1&&(b=_.last(e)),f=c.queryString(),b&&g.match(b)&&(f=f.replace(b,"")),d=""+g+"?"+f,d.match(/\?$/)&&(d=d.replace(/\?$/,"")),d}):(b=this.url,a=this.queryString(),this.url=_([b,a]).compact().join("?"))},queryString:function(){var a,b=this;return a=_(this.base_params||(this.base_params=Luca.Collection.baseParams())).inject(function(a,b,c){var d;return d=""+c+"="+b,a.push(d),a},[]),_.uniq(a).join("&")},resetFilter:function(){return this.base_params=_(Luca.Collection.baseParams()).clone(),this},applyFilter:function(a,b){return a==null&&(a={}),b==null&&(b={}),b.remote!=null==1||this.remoteFilter===!0?(this.applyParams(a),this.fetch(_.extend(b,{refresh:!0}))):this.reset(this.query(a))},applyParams:function(a){return this.base_params=_(Luca.Collection.baseParams()).clone(),_.extend(this.base_params,a),this},register:function(a,b,c){a==null&&(a=Luca.CollectionManager.get()),b==null&&(b="");if(!(b.length>=1))throw"Can not register with a collection manager without a key";if(a==null)throw"Can not register with a collection manager without a valid collection manager";_.isString(a)&&(a=Luca.util.nestedValue(a,window||global));if(!a)throw"Could not register with collection manager";if(_.isFunction(a.add))return a.add(b,c);if(_.isObject(a))return a[b]=c},loadFromBootstrap:function(){if(!this.bootstrap_cache_key)return;return this.reset(this.cached_models()),this.trigger("bootstrapped",this)},bootstrap:function(){return this.loadFromBootstrap()},cached_models:function(){return Luca.Collection.cache(this.bootstrap_cache_key)},fetch:function(a){var b;a==null&&(a={}),this.trigger("before:fetch",this);if(this.memoryCollection===!0)return this.reset(this.data);if(this.cached_models().length&&!a.refresh)return this.bootstrap();b=_.isFunction(this.url)?this.url():this.url;if(!(b&&b.length>1||this.localStorage))return!0;this.fetching=!0;try{return Backbone.Collection.prototype.fetch.apply(this,arguments)}catch(c){throw console.log("Error in Collection.fetch",c),c}},onceLoaded:function(a,b){var c,d=this;b==null&&(b={autoFetch:!0});if(this.length>0&&!this.fetching){a.apply(this,[this]);return}c=function(){return a.apply(d,[d])},this.bind("reset",function(){return c(),this.unbind("reset",this)});if(!this.fetching&&!!b.autoFetch)return this.fetch()},ifLoaded:function(a,b){var c,d=this;b==null&&(b={scope:this,autoFetch:!0}),c=b.scope||this,this.length>0&&!this.fetching&&a.apply(c,[this]),this.bind("reset",function(b){return a.call(c,b)});if(!(this.fetching===!0||!b.autoFetch||this.length>0))return this.fetch()},parse:function(a){var b;return this.fetching=!1,this.trigger("after:response",a),b=this.root!=null?a[this.root]:a,this.bootstrap_cache_key&&Luca.Collection.cache(this.bootstrap_cache_key,b),b},restoreMethodCache:function(){var a,b,c,d;c=this._methodCache,d=[];for(b in c)a=c[b],a.original!=null?(a.args=void 0,d.push(this[b]=a.original)):d.push(void 0);return d},clearMethodCache:function(a){return this._methodCache[a].value=void 0},clearAllMethodsCache:function(){var a,b,c,d;c=this._methodCache,d=[];for(b in c)a=c[b],d.push(this.clearMethodCache(b));return d},setupMethodCaching:function(){var a,b,c;return b=this,c=["reset","add","remove"],a=this._methodCache={},_(this.cachedMethods).each(function(d){var e,f,g,h,i,j,k,l,m;a[d]={name:d,original:b[d],value:void 0},b[d]=function(){var c;return(c=a[d]).value||(c.value=a[d].original.apply(b,arguments))};for(h=0,j=c.length;h<j;h++)g=c[h],b.bind(g,function(){return b.clearAllMethodsCache()});e=d.split(":")[1];if(e){l=e.split(","),m=[];for(i=0,k=l.length;i<k;i++)f=l[i],m.push(b.bind("change:"+f,function(){return b.clearMethodCache({method:d})}));return m}})},query:function(a,b){return a==null&&(a={}),b==null&&(b={}),Backbone.QueryCollection!=null?Backbone.QueryCollection.prototype.query.apply(this,arguments):this.models}}),_.extend(Luca.Collection.prototype,{trigger:function(){return Luca.enableGlobalObserver&&(Luca.CollectionObserver||(Luca.CollectionObserver=new Luca.Observer({type:"collection"})),Luca.CollectionObserver.relay(this,arguments)),Backbone.View.prototype.trigger.apply(this,arguments)}}),Luca.Collection.baseParams=function(a){if(a)return Luca.Collection._baseParams=a;if(_.isFunction(Luca.Collection._baseParams))return Luca.Collection._baseParams();if(_.isObject(Luca.Collection._baseParams))return Luca.Collection._baseParams},Luca.Collection._bootstrapped_models={},Luca.Collection.bootstrap=function(a){return _.extend(Luca.Collection._bootstrapped_models,a)},Luca.Collection.cache=function(a,b){return b?Luca.Collection._bootstrapped_models[a]=b:Luca.Collection._bootstrapped_models[a]||[]}}.call(this),function(){var a;a=function(a,b){var c,d,e,f,g;return a==null&&(a={}),a.orientation||(a.orientation="top"),a.ctype||(a.ctype=this.toolbarType||"panel_toolbar"),f=""+this.cid+"-tbc-"+a.orientation,g=Luca.util.lazyComponent(a),d=this.make("div",{"class":"toolbar-container "+a.orientation,id:f},g.render().el),e=this.bodyClassName||this.bodyTagName,c=function(){switch(a.orientation){case"top":case"left":return e?"before":"prepend";case"bottom":case"right":return e?"after":"append"}}(),(b||this.$bodyEl())[c](d)},_.def("Luca.components.Panel")["extends"]("Luca.View")["with"]({topToolbar:void 0,bottomToolbar:void 0,loadMask:!1,loadMaskTemplate:["components/load_mask"],loadMaskTimeout:3e3,mixins:["LoadMaskable"],initialize:function(a){return this.options=a!=null?a:{},Luca.View.prototype.initialize.apply(this,arguments)},applyStyles:function(a,b){var c,d,e;a==null&&(a={}),b==null&&(b=!1),d=b?this.$bodyEl():this.$el;for(c in a)e=a[c],d.css(c,e);return this},beforeRender:function(){var a;return(a=Luca.View.prototype.beforeRender)!=null&&a.apply(this,arguments),this.styles!=null&&this.applyStyles(this.styles),this.bodyStyles!=null&&this.applyStyles(this.bodyStyles,!0),typeof this.renderToolbars=="function"?this.renderToolbars():void 0},$bodyEl:function(){var a,b,c,d;return c=this.bodyTagName||"div",b=this.bodyClassName||"view-body",this.bodyEl||(this.bodyEl=""+c+"."+b),a=this.$(this.bodyEl),a.length>0?a:a.length!==0||this.bodyClassName==null&&this.bodyTagName==null?$(this.el):(d=this.make(c,{"class":b,"data-auto-appended":!0}),$(this.el).append(d),this.$(this.bodyEl))},$wrap:function(a){return _.isString(a)&&!a.match(/[<>]/)&&(a=this.make("div",{"class":a})),this.$el.wrap(a)},$template:function(a,b){return b==null&&(b={}),this.$html(Luca.template(a,b))},$empty:function(){return this.$bodyEl().empty()},$html:function(a){return this.$bodyEl().html(a)},$append:function(a){return this.$bodyEl().append(a)},renderToolbars:function(){var a=this;return _(["top","left","right","bottom"]).each(function(b){var c;if(c=a[""+b+"Toolbar"])return a.renderToolbar(b,c)})},renderToolbar:function(b,c){return b==null&&(b="top"),c==null&&(c={}),c.parent=this,c.orientation=b,a.call(this,c,c.targetEl)}})}.call(this),function(){_.def("Luca.core.Field")["extends"]("Luca.View")["with"]({className:"luca-ui-text-field luca-ui-field",isField:!0,template:"fields/text_field",labelAlign:"top",hooks:["before:validation","after:validation","on:change"],statuses:["warning","error","success"],initialize:function(a){var b;return this.options=a!=null?a:{},_.extend(this,this.options),this.input_id||(this.input_id=_.uniqueId("field")),this.input_name||(this.input_name=this.name),this.input_class||(this.input_class=""),this.helperText||(this.helperText=""),this.required&&((b=this.label)!=null?!b.match(/^\*/):!void 0)&&(this.label||(this.label="*"+this.label)),this.inputStyles||(this.inputStyles=""),this.disabled&&this.disable(),this.updateState(this.state),this.placeHolder||(this.placeHolder=""),Luca.View.prototype.initialize.apply(this,arguments)},beforeRender:function(){return Luca.enableBootstrap&&this.$el.addClass("control-group"),this.required&&this.$el.addClass("required"),this.$el.html(Luca.template(this.template,this)),this.input=$("input",this.el)},change_handler:function(a){return this.trigger("on:change",this,a)},disable:function(){return $("input",this.el).attr("disabled",!0)},enable:function(){return $("input",this.el).attr("disabled",!1)},getValue:function(){var a;a=this.input.attr("value");if(_.str.isBlank(a))return a;switch(this.valueType){case"integer":return parseInt(a);case"string":return""+a;case"float":return parseFloat(a);default:return a}},render:function(){return $(this.container).append(this.$el)},setValue:function(a){return this.input.attr("value",a)},updateState:function(a){var b=this;return _(this.statuses).each(function(c){return b.$el.removeClass(c),b.$el.addClass(a)})}})}.call(this),function(){var a,b,c;c=function(){return this.trigger("before:layout",this),this.prepareLayout(),this.trigger("after:layout",this)},a=function(a,b){var c,d;return d=[],a.height!=null&&d.push("height: "+(_.isNumber(a.height)?a.height+"px":a.height)),a.width!=null&&d.push("width: "+(_.isNumber(a.width)?a.width+"px":a.width)),a.float&&d.push("float: "+a.float),c={"class":(a!=null?a.classes:void 0)||this.componentClass,id:""+this.cid+"-"+b,style:d.join(";"),"data-luca-owner":this.name||this.cid},this.customizeContainerEl!=null&&(c=this.customizeContainerEl(c,a,b)),c},b=function(){return this.trigger("before:components",this,this.components),this.prepareComponents(),this.createComponents(),this.trigger("before:render:components",this,this.components),this.renderComponents(),this.trigger("after:components",this,this.components)},_.def("Luca.core.Container")["extends"]("Luca.components.Panel")["with"]({className:"luca-ui-container",componentTag:"div",componentClass:"luca-ui-panel",isContainer:!0,hooks:["before:components","before:render:components","before:layout","after:components","after:layout","first:activation"],rendered:!1,components:[],initialize:function(a){return this.options=a!=null?a:{},_.extend(this,this.options),this.setupHooks(["before:components","before:render:components","before:layout","after:components","after:layout","first:activation"]),Luca.View.prototype.initialize.apply(this,arguments)},beforeRender:function(){var a;return c.call(this),b.call(this),(a=Luca.components.Panel.prototype.beforeRender)!=null?a.apply(this,arguments):void 0},customizeContainerEl:function(a,b,c){return a},prepareLayout:function(){var b;return b=this,this.componentContainers=_(this.components).map(function(c,d){return a.call(b,c,d)})},prepareComponents:function(){var a,b,c,d,e=this;d=this.components;for(b=0,c=d.length;b<c;b++)a=d[b],_.isString(a)&&(a={type:a});return _(this.components).each(function(a,b){var c,d,f,g;c=d=(g=e.componentContainers)!=null?g[b]:void 0,c["class"]=c["class"]||c.className||c.classes,e.generateComponentElements&&(f=e.make(e.componentTag,d,""),e.$append(f));if(a.container==null)return e.generateComponentElements&&(a.container="#"+d.id),a.container||(a.container=e.$bodyEl())})},createComponents:function(){var a,b=this;if(this.componentsCreated===!0)return;return a=this.componentIndex={name_index:{},cid_index:{}},this.components=_(this.components).map(function(c,d){var e;return e=Luca.isBackboneView(c)?c:(c.type||(c.type=c.ctype),c.type==null?c.components!=null?c.type=c.ctype="container":c.type=c.ctype=Luca.defaultComponentType:void 0,Luca.util.lazyComponent(c)),_.isString(e.getter)&&(b[e.getter]=function(){return e}),!e.container&&e.options.container&&(e.container=e.options.container),a&&e.cid!=null&&(a.cid_index[e.cid]=d),a&&e.name!=null&&(a.name_index[e.name]=d),e}),this.componentsCreated=!0,_.isEmpty(this.componentEvents)||this.registerComponentEvents(),a},renderComponents:function(a){var b;return this.debugMode=a!=null?a:"",this.debug("container render components"),b=this,_(this.components).each(function(a){a.getParent=function(){return b};try{return $(a.container).append(a.el),a.render()}catch(c){console.log("Error Rendering Component "+(a.name||a.cid),a),_.isObject(c)&&(console.log(c.message),console.log(c.stack));if(Luca.silenceRenderErrors!=null!=1)throw c}})},firstActivation:function(){var a;return a=this,this.each(function(b,c){var d;if((b!=null?b.previously_activated:void 0)!==!0)return b!=null&&(d=b.trigger)!=null&&d.call(b,"first:activation",b,a),b.previously_activated=!0})},pluck:function(a){return _(this.components).pluck(a)},invoke:function(a){return _(this.components).invoke(a)},map:function(a){return _(this.components).map(a)},componentEvents:{},registerComponentEvents:function(){var a,b,c,d,e,f,g,h;f=this.componentEvents,h=[];for(d in f)c=f[d],g=d.split(" "),b=g[0],e=g[1],a=this.findComponentByName(b),h.push(a!=null?a.bind(e,this[c]):void 0);return h},findComponentByName:function(a,b){return b==null&&(b=!1),this.findComponent(a,"name_index",b)},findComponentById:function(a,b){return b==null&&(b=!1),this.findComponent(a,"cid_index",b)},findComponent:function(a,b,c){var d,e,f,g,h;b==null&&(b="name"),c==null&&(c=!1),this.componentsCreated!==!0&&this.createComponents(),e=(g=this.componentIndex)!=null?g[b][a]:void 0,d=(h=this.components)!=null?h[e]:void 0;if(d)return d;if(c===!0)return f=_(this.components).detect(function(c){return c!=null?typeof c.findComponent=="function"?c.findComponent(a,b,!0):void 0:void 0}),f!=null?typeof f.findComponent=="function"?f.findComponent(a,b,!0):void 0:void 0},each:function(a){return this.eachComponent(a,!1)},eachComponent:function(a,b){var c=this;return b==null&&(b=!0),_(this.components).each(function(c,d){var e;a.call(c,c,d);if(b)return c!=null?(e=c.eachComponent)!=null?e.apply(c,[a,b]):void 0:void 0})},indexOf:function(a){var b;return b=_(this.components).pluck("name"),_(b).indexOf(a)},activeComponent:function(){return this.activeItem?this.components[this.activeItem]:this},componentElements:function(){return this.$(">."+this.componentClass,this.$bodyEl())},getComponent:function(a){return this.components[a]},rootComponent:function(){return console.log("Calling rootComponent will be deprecated. use isRootComponent instead"),this.getParent==null},isRootComponent:function(){return this.getParent==null},getRootComponent:function(){return this.rootComponent()?this:this.getParent().getRootComponent()},selectByAttribute:function(a,b,c){var d;return c==null&&(c=!1),d=_(this.components).map(function(d){var e,f;return e=[],f=d[a],f===b&&e.push(d),c===!0&&e.push(typeof d.selectByAttribute=="function"?d.selectByAttribute(a,b,!0):void 0),_.compact(e)}),_.flatten(d)},select:function(a,b,c){return c==null&&(c=!1),console.log("Container.select will be replaced by selectByAttribute in 1.0"),Luca.core.Container.prototype.selectByAttribute.apply(this,arguments)}}),Luca.core.Container.componentRenderer=function(a,b){var c;return c=$(b.container)[b.attachWith||"append"],c(b.render().el)}}.call(this),function(){var a,b,c;Luca.CollectionManager=function(){function c(a){var c,d,e,f;this.options=a!=null?a:{},_.extend(this,this.options),d=this;if(c=typeof (e=Luca.CollectionManager).get=="function"?e.get(this.name):void 0)throw"Attempt to create a collection manager with a name which already exists";(f=Luca.CollectionManager).instances||(f.instances={}),_.extend(this,Backbone.Events),_.extend(this,Luca.Events),Luca.CollectionManager.instances[this.name]=d,Luca.CollectionManager.get=function(a){return a==null?d:Luca.CollectionManager.instances[a]},this.state=new Luca.Model,this.initialCollections&&b.call(this)}return c.prototype.name="primary",c.prototype.collectionNamespace=Luca.Collection.namespace,c.prototype.__collections={},c.prototype.relayEvents=!0,c.prototype.add=function(a,b){var c;return(c=this.currentScope())[a]||(c[a]=b)},c.prototype.allCollections=function(){return _(this.currentScope()).values()},c.prototype.create=function(b,c,
7
- d){var e,f,g;return c==null&&(c={}),d==null&&(d=[]),e=c.base,e||(e=a.call(this,b)),c.private&&(c.name=""),f=new e(d,c),this.add(b,f),g=this,this.relayEvents===!0&&this.bind("*",function(){return console.log("Relay Events on Collection Manager *",f,arguments)}),f},c.prototype.currentScope=function(){var a,b;return(a=this.getScope())?(b=this.__collections)[a]||(b[a]={}):this.__collections},c.prototype.each=function(a){return _(this.all()).each(a)},c.prototype.get=function(a){return this.currentScope()[a]},c.prototype.getScope=function(){return},c.prototype.destroy=function(a){var b;return b=this.get(a),delete this.currentScope()[a],b},c.prototype.getOrCreate=function(a,b,c){return b==null&&(b={}),c==null&&(c=[]),this.get(a)||this.create(a,b,c,!1)},c.prototype.collectionCountDidChange=function(){if(this.allCollectionsLoaded())return this.trigger("all_collections_loaded"),this.trigger("initial:load")},c.prototype.allCollectionsLoaded=function(){return this.totalCollectionsCount()===this.loadedCollectionsCount()},c.prototype.totalCollectionsCount=function(){return this.state.get("collections_count")},c.prototype.loadedCollectionsCount=function(){return this.state.get("loaded_collections_count")},c.prototype.private=function(a,b,c){return b==null&&(b={}),c==null&&(c=[]),this.create(a,b,c,!0)},c}(),Luca.CollectionManager.destroyAll=function(){return Luca.CollectionManager.instances={}},a=function(a){var b,c,d,e;return b=Luca.util.classify(a),c=(this.collectionNamespace||window||global)[b],c||(c=(this.collectionNamespace||window||global)[""+b+"Collection"]),c==null&&((e=Luca.Collection.namespaces)!=null?e.length:void 0)>0&&(d=_(Luca.Collection.namespaces.reverse()).map(function(a){return Luca.util.resolve(""+a+"."+b)||Luca.util.resolve(""+a+"."+b+"Collection")}),d=_(d).compact(),d.length>0&&(c=d[0])),c},c=function(){var a,b=this;return a=function(a){var c;return c=b.state.get("loaded_collections_count"),b.state.set("loaded_collections_count",c+1),b.trigger("collection_loaded",a.name),a.unbind("reset")},_(this.initialCollections).each(function(c){var d;return d=b.getOrCreate(c),d.once("reset",function(){return a(d)}),d.fetch()})},b=function(){var a=this;return this.state.set({loaded_collections_count:0,collections_count:this.initialCollections.length}),this.state.bind("change:loaded_collections_count",function(){return a.collectionCountDidChange()}),this.useProgressLoader&&(this.loaderView||(this.loaderView=new Luca.components.CollectionLoaderView({manager:this,name:"collection_loader_view"}))),c.call(this),this}}.call(this),function(){Luca.SocketManager=function(){function a(a){this.options=a!=null?a:{},_.extend(Backbone.Events),this.loadTransport()}return a.prototype.connect=function(){switch(this.options.provider){case"socket.io":return this.socket=io.connect(this.options.socket_host);case"faye.js":return this.socket=new Faye.Client(this.options.socket_host)}},a.prototype.transportLoaded=function(){return this.connect()},a.prototype.transport_script=function(){switch(this.options.provider){case"socket.io":return""+this.options.transport_host+"/socket.io/socket.io.js";case"faye.js":return""+this.options.transport_host+"/faye.js"}},a.prototype.loadTransport=function(){var a,b=this;return a=document.createElement("script"),a.setAttribute("type","text/javascript"),a.setAttribute("src",this.transport_script()),a.onload=this.transportLoaded,Luca.util.isIE()&&(a.onreadystatechange=function(){if(a.readyState==="loaded")return b.transportLoaded()}),document.getElementsByTagName("head")[0].appendChild(a)},a}()}.call(this),function(){_.def("Luca.containers.SplitView")["extends"]("Luca.core.Container")["with"]({componentType:"split_view",containerTemplate:"containers/basic",className:"luca-ui-split-view",componentClass:"luca-ui-panel"})}.call(this),function(){_.def("Luca.containers.ColumnView")["extends"]("Luca.core.Container")["with"]({componentType:"column_view",className:"luca-ui-column-view",components:[],initialize:function(a){return this.options=a!=null?a:{},console.log("Column Views are deprecated in favor of just using grid css on a normal container"),Luca.core.Container.prototype.initialize.apply(this,arguments),this.setColumnWidths()},componentClass:"luca-ui-column",containerTemplate:"containers/basic",generateComponentElements:!0,autoColumnWidths:function(){var a,b=this;return a=[],_(this.components.length).times(function(){return a.push(parseInt(100/b.components.length))}),a},setColumnWidths:function(){return this.columnWidths=this.layout!=null?_(this.layout.split("/")).map(function(a){return parseInt(a)}):this.autoColumnWidths(),this.columnWidths=_(this.columnWidths).map(function(a){return""+a+"%"})},beforeLayout:function(){var a,b=this;return this.debug("column_view before layout"),_(this.columnWidths).each(function(a,c){return b.components[c].float="left",b.components[c].width=a}),(a=Luca.core.Container.prototype.beforeLayout)!=null?a.apply(this,arguments):void 0}})}.call(this),function(){_.def("Luca.containers.CardView")["extends"]("Luca.core.Container")["with"]({componentType:"card_view",className:"luca-ui-card-view-wrapper",activeCard:0,components:[],hooks:["before:card:switch","after:card:switch"],componentClass:"luca-ui-card",generateComponentElements:!0,initialize:function(a){return this.options=a,Luca.core.Container.prototype.initialize.apply(this,arguments),this.setupHooks(this.hooks)},prepareComponents:function(){var a,b=this;return(a=Luca.core.Container.prototype.prepareComponents)!=null&&a.apply(this,arguments),_(this.components).each(function(a,c){return c===b.activeCard?$(a.container).show():$(a.container).hide()})},activeComponentElement:function(){return this.componentElements().eq(this.activeCard)},activeComponent:function(){return this.getComponent(this.activeCard)},customizeContainerEl:function(a,b,c){return a.style+=c===this.activeCard?"display:block;":"display:none;",a},cycle:function(){var a;return a=this.activeCard<this.components.length-1?this.activeCard+1:0,this.activate(a)},find:function(a){return this.findComponentByName(a,!0)},firstActivation:function(){return this.activeComponent().trigger("first:activation",this,this.activeComponent())},activate:function(a,b,c){var d,e,f,g,h,i,j=this;b==null&&(b=!1),_.isFunction(b)&&(b=!1,c=b);if(a===this.activeCard)return;e=this.activeComponent(),d=this.getComponent(a),d||(a=this.indexOf(a),d=this.getComponent(a));if(!d)return;b||(this.trigger("before:card:switch",e,d),e!=null&&(f=e.trigger)!=null&&f.apply(e,["before:deactivation",this,e,d]),d!=null&&(g=d.trigger)!=null&&g.apply(e,["before:activation",this,e,d]),_.defer(function(){return j.$el.data(j.activeAttribute||"active-card",d.name)})),this.componentElements().hide(),d.previously_activated||(d.trigger("first:activation"),d.previously_activated=!0),this.activeCard=a,this.activeComponentElement().show(),b||(this.trigger("after:card:switch",e,d),(h=e.trigger)!=null&&h.apply(e,["deactivation",this,e,d]),(i=d.trigger)!=null&&i.apply(d,["activation",this,e,d]));if(_.isFunction(c))return c.apply(this,[this,e,d])}})}.call(this),function(){_.def("Luca.ModalView")["extends"]("Luca.core.Container")["with"]({closeOnEscape:!0,showOnInitialize:!1,backdrop:!1,className:"luca-ui-container modal",container:function(){return $("body")},toggle:function(){return this.$el.modal("toggle")},show:function(){return this.$el.modal("show")},hide:function(){return this.$el.modal("hide")},render:function(){return this.$el.addClass("modal"),this.fade===!0&&this.$el.addClass("fade"),$("body").append(this.$el),this.$el.modal({backdrop:this.backdrop===!0,keyboard:this.closeOnEscape===!0,show:this.showOnInitialize===!0}),this}}),_.def("Luca.containers.ModalView")["extends"]("Luca.ModalView")["with"]()}.call(this),function(){_.def("Luca.PageView")["extends"]("Luca.containers.CardView")["with"]({version:2})}.call(this),function(){var a,b,c;b=Backbone.View.prototype.make,a=function(a,d){var e,f,g,h,i,j,k,l,m,n,o=this;d==null&&(d=!0);if(a.ctype!=null){a.className||(a.className=""),a.className+="toolbar-component",l=Luca(a).render();if(Luca.isBackboneView(l))return console.log("Adding toolbar component",l),l.el}return a.spacer?b("div",{"class":"spacer "+a.spacer}):a.text?b("div",{"class":"toolbar-text"},a.text):(n="btn-group",a.wrapper!=null&&(n+=" "+a.wrapper),a.align!=null&&(n+=" align-"+a.align),a.group!=null&&a.buttons!=null?(h=c(a.buttons,!1),b("div",{"class":n},h)):(k=a.label||(a.label=""),a.eventId||(a.eventId=_.string.dasherize(a.label.toLowerCase())),a.icon&&(_.string.isBlank(k)&&(k=" "),a.white&&(m="icon-white"),k="<i class='"+(m||"")+" icon-"+a.icon+"' /> "+k),f={"class":_.compact(["btn",a.classes,a.className]).join(" "),"data-eventId":a.eventId,title:a.title||a.description},a.color!=null&&(f["class"]+=" btn-"+a.color),a.dropdown&&(k=""+k+" <span class='caret'></span>",f["class"]+=" dropdown-toggle",f["data-toggle"]="dropdown",j=_(a.dropdown).map(function(a){var c;return c=b("a",{},a[1]),b("li",{"data-eventId":a[0]},c)}),i=b("ul",{"class":"dropdown-menu"},j)),g=b("a",f,k),e="btn-group",a.align!=null&&(e+=" align-"+a.align),d===!0?b("div",{"class":e},[g,i]):g))},c=function(b,c){return c==null&&(c=!0),_(b).map(function(b){return a(b,c)})},_.def("Luca.containers.PanelToolbar")["extends"]("Luca.View")["with"]({className:"luca-ui-toolbar btn-toolbar",buttons:[],well:!0,orientation:"top",autoBindEventHandlers:!0,events:{"click a.btn, click .dropdown-menu li":"clickHandler"},clickHandler:function(a){var b,c,d,e,f;d=e=$(a.target),d.is("i")&&(d=e=$(a.target).parent()),b=e.data("eventid");if(b==null)return;return c=Luca.util.hook(b),f=this.parent||this,_.isFunction(f[c])?f[c].call(this,d,a):f.trigger(b,d,a)},beforeRender:function(){this._super("beforeRender",this,arguments),this.well===!0&&this.$el.addClass("well"),this.$el.addClass("toolbar-"+this.orientation);if(this.styles!=null)return this.applyStyles(this.styles)},render:function(){var a,b=this;return this.$el.empty(),a=c(this.buttons),_(a).each(function(a){return b.$el.append(a)})}})}.call(this),function(){_.def("Luca.containers.PanelView")["extends"]("Luca.core.Container")["with"]({className:"luca-ui-panel",initialize:function(a){return this.options=a!=null?a:{},Luca.core.Container.prototype.initialize.apply(this,arguments)},afterLayout:function(){var a;if(this.template)return a=(Luca.templates||JST)[this.template](this),this.$el.html(a)},render:function(){return $(this.container).append(this.$el)},afterRender:function(){var a,b=this;(a=Luca.core.Container.prototype.afterRender)!=null&&a.apply(this,arguments);if(this.css)return _(this.css).each(function(a,c){return b.$el.css(c,a)})}})}.call(this),function(){_.def("Luca.containers.TabView")["extends"]("Luca.containers.CardView")["with"]({hooks:["before:select","after:select"],componentType:"tab_view",className:"luca-ui-tab-view tabbable",tab_position:"top",tabVerticalOffset:"50px",navClass:"nav-tabs",bodyTemplate:"containers/tab_view",bodyEl:"div.tab-content",initialize:function(a){return this.options=a!=null?a:{},this.navStyle==="list"&&(this.navClass="nav-list"),Luca.containers.CardView.prototype.initialize.apply(this,arguments),_.bindAll(this,"select","highlightSelectedTab"),this.setupHooks(this.hooks),this.bind("after:card:switch",this.highlightSelectedTab)},activeTabSelector:function(){return this.tabSelectors().eq(this.activeCard||this.activeTab||this.activeItem)},beforeLayout:function(){var a;return this.$el.addClass("tabs-"+this.tab_position),this.activeTabSelector().addClass("active"),this.createTabSelectors(),(a=Luca.containers.CardView.prototype.beforeLayout)!=null?a.apply(this,arguments):void 0},afterRender:function(){var a;(a=Luca.containers.CardView.prototype.afterRender)!=null&&a.apply(this,arguments),this.registerEvent("click #"+this.cid+"-tabs-selector li a","select");if(Luca.enableBootstrap&&(this.tab_position==="left"||this.tab_position==="right"))return this.tabContainerWrapper().addClass("span2"),this.tabContentWrapper().addClass("span9")},createTabSelectors:function(){var a;return a=this,this.each(function(b,c){var d,e,f,g;b.tabIcon&&(d="<i class='icon-"+b.tabIcon),e="<a href='#'>"+(d||"")+" "+b.title+"</a>",f=a.make("li",{"class":"tab-selector","data-target":c},e),a.tabContainer().append(f);if(b.navHeading!=null&&((g=a.navHeadings)!=null?!g[b.navHeading]:!void 0))return $(f).before(a.make("li",{"class":"nav-header"},b.navHeading)),a.navHeadings||(a.navHeadings={}),a.navHeadings[b.navHeading]=!0})},highlightSelectedTab:function(){return this.tabSelectors().removeClass("active"),this.activeTabSelector().addClass("active")},select:function(a){var b,c;return a.preventDefault(),b=c=$(a.target),this.trigger("before:select",this),this.activate(c.parent().data("target")),this.trigger("after:select",this)},componentElements:function(){return this.$(">.tab-content >."+this.componentClass)},tabContentWrapper:function(){return $("#"+this.cid+"-tab-view-content")},tabContainerWrapper:function(){return $("#"+this.cid+"-tabs-selector")},tabContainer:function(){return this.$("ul."+this.navClass,this.tabContainerWrapper())},tabSelectors:function(){return this.$("li.tab-selector",this.tabContainer())}})}.call(this),function(){_.def("Luca.containers.Viewport").extend("Luca.containers.CardView")["with"]({activeItem:0,additionalClassNames:"luca-ui-viewport",fullscreen:!0,fluid:!1,initialize:function(a){this.options=a!=null?a:{},_.extend(this,this.options),Luca.enableBootstrap===!0&&(this.wrapperClass=this.fluid===!0?Luca.containers.Viewport.fluidWrapperClass:Luca.containers.Viewport.defaultWrapperClass),Luca.core.Container.prototype.initialize.apply(this,arguments);if(this.fullscreen===!0)return this.enableFullscreen()},enableFluid:function(){return this.$el.parent().addClass(this.wrapperClass)},disableFluid:function(){return this.$el.parent().removeClass(this.wrapperClass)},enableFullscreen:function(){return $("html,body").addClass("luca-ui-fullscreen"),this.$el.addClass("fullscreen-enabled")},disableFullscreen:function(){return $("html,body").removeClass("luca-ui-fullscreen"),this.$el.removeClass("fullscreen-enabled")},beforeRender:function(){var a;(a=Luca.containers.CardView.prototype.beforeRender)!=null&&a.apply(this,arguments),this.topNav!=null&&this.renderTopNavigation();if(this.bottomNav!=null)return this.renderBottomNavigation()},height:function(){return this.$el.height()},width:function(){return this.$el.width()},afterRender:function(){var a;(a=Luca.containers.CardView.prototype.after)!=null&&a.apply(this,arguments);if(Luca.enableBootstrap===!0&&this.containerClassName)return this.$el.children().wrap('<div class="#{ containerClassName }" />')},renderTopNavigation:function(){var a;if(this.topNav==null)return;return _.isString(this.topNav)&&(this.topNav=Luca.util.lazyComponent(this.topNav)),_.isObject(this.topNav)&&((a=this.topNav).ctype||(a.ctype=this.topNav.type||"nav_bar"),Luca.isBackboneView(this.topNav)||(this.topNav=Luca.util.lazyComponent(this.topNav))),this.topNav.app=this,$("body").prepend(this.topNav.render().el)},renderBottomNavigation:function(){}}),Luca.containers.Viewport.defaultWrapperClass="row",Luca.containers.Viewport.fluidWrapperClass="row-fluid"}.call(this),function(){}.call(this),function(){}.call(this),function(){_.def("Luca.components.Template")["extends"]("Luca.View")["with"]({initialize:function(a){return this.options=a!=null?a:{},console.log("The Use of Luca.components.Template directly is being DEPRECATED"),Luca.View.prototype.initialize.apply(this,arguments)}})}.call(this),function(){var a;a=function(){return Backbone.history.start()},_.def("Luca.Application")["extends"]("Luca.containers.Viewport")["with"]({name:"MyApp",defaultState:{},autoBoot:!1,autoStartHistory:"before:render",useCollectionManager:!0,collectionManager:{},collectionManagerClass:"Luca.CollectionManager",plugin:!1,useController:!0,useKeyHandler:!1,keyEvents:{},components:[{ctype:"template",name:"welcome",template:"sample/welcome",templateContainer:"Luca.templates"}],initialize:function(a){var b,c,d,e,f=this;this.options=a!=null?a:{},c=this,d=this.name,b=typeof Luca.getApplication=="function"?Luca.getApplication():void 0,(e=Luca.Application).instances||(e.instances={}),Luca.Application.instances[d]=c,Luca.containers.Viewport.prototype.initialize.apply(this,arguments),this.state=new Luca.Model(this.defaultState),this.setupMainController(),this.setupCollectionManager(),this.defer(function(){return c.render()}).until(this,"ready"),this.setupRouter(),this.useKeyRouter===!0&&console.log("The useKeyRouter property is being deprecated. switch to useKeyHandler instead"),(this.useKeyHandler===!0||this.useKeyRouter===!0)&&this.keyEvents!=null&&this.setupKeyHandler(),this.plugin!==!0&&!b&&(Luca.getApplication=function(a){return a==null?c:Luca.Application.instances[a]});if(this.autoBoot){if(Luca.util.resolve(this.name))throw"Attempting to override window."+this.name+" when it already exists";return $(function(){return window[d]=c,c.boot()})}},activeView:function(){var a;return(a=this.activeSubSection())?this.view(a):this.view(this.activeSection())},activeSection:function(){return this.get("active_section")},activeSubSection:function(){return this.get("active_sub_section")},activePages:function(){var a=this;return this.$(".luca-ui-controller").map(function(a,b){return $(b).data("active-section")})},boot:function(){return this.trigger("ready")},collection:function(){return this.collectionManager.getOrCreate.apply(this.collectionManager,arguments)},get:function(a){return this.state.get(a)},set:function(a,b,c){return this.state.set.apply(this.state,arguments)},view:function(a){return Luca.cache(a)},navigate_to:function(a,b){return this.getMainController().navigate_to(a,b)},getMainController:function(){return this.useController===!0?this.components[0]:Luca.cache("main_controller")},keyHandler:function(a){var b,c,d,e,f,g,h;if(!a||!this.keyEvents)return;c=$(a.target).is("input")||$(a.target).is("textarea");if(c)return;e=Luca.keyMap[a.keyCode];if(!e)return;f=(a!=null?a.metaKey:void 0)===!0,b=(a!=null?a.ctrlKey:void 0)===!0,g=this.keyEvents,g=f?this.keyEvents.meta:g,g=b?this.keyEvents.control:g,g=f&&b?this.keyEvents.meta_control:g;if(d=g!=null?g[e]:void 0)return this[d]!=null&&_.isFunction(this[d])?(h=this[d])!=null?h.call(this):void 0:this.trigger(d,a,e)},setupControllerBindings:function(){var a,b,c,d=this;return a=this,(b=this.getMainController())!=null&&b.bind("after:card:switch",function(b,c){return d.state.set({active_section:c.name}),a.trigger("page:change")}),(c=this.getMainController())!=null?c.each(function(b){if(b.ctype.match(/controller$/))return b.bind("after:card:switch",function(b,c){return d.state.set({active_sub_section:c.name}),a.trigger("sub:page:change")})}):void 0},setupMainController:function(){var a;if(this.useController===!0)return a=this.components||[],this.components=[{ctype:"controller",name:"main_controller",components:a}],this.defer(this.setupControllerBindings,!1).until("after:components")},setupCollectionManager:function(){var a,b,c,d;if(this.useCollectionManager===!0){_.isString(this.collectionManagerClass)&&(this.collectionManagerClass=Luca.util.resolve(this.collectionManagerClass)),a=this.collectionManagerOptions,_.isObject(this.collectionManager)&&!_.isFunction((c=this.collectionManager)!=null?c.get:void 0)&&(a=this.collectionManager,this.collectionManager=void 0),_.isString(this.collectionManager)&&(a={name:this.collectionManager}),this.collectionManager=typeof (b=Luca.CollectionManager).get=="function"?b.get(a.name):void 0;if(!_.isFunction((d=this.collectionManager)!=null?d.get:void 0))return this.collectionManager=new this.collectionManagerClass(a)}},setupRouter:function(){var b,c;b=this,_.isString(this.router)&&(c=Luca.util.resolve(this.router),this.router=new c({app:b}));if(this.router&&this.autoStartHistory)return this.autoStartHistory===!0&&(this.autoStartHistory="before:render"),this.defer(a,!1).until(this,this.autoStartHistory)},setupKeyHandler:function(){var a,b,c,d,e,f,g;if(!this.keyEvents)return;(c=this.keyEvents).control_meta||(c.control_meta={}),this.keyEvents.meta_control&&_.extend(this.keyEvents.control_meta,this.keyEvents.meta_control),a=_.bind(this.keyHandler,this),f=this.keypressEvents||["keydown"],g=[];for(d=0,e=f.length;d<e;d++)b=f[d],g.push($(document).on(b,a));return g}})}.call(this),function(){_.def("Luca.components.Toolbar")["extends"]("Luca.core.Container")["with"]({className:"luca-ui-toolbar toolbar",position:"bottom",initialize:function(a){return this.options=a!=null?a:{},Luca.core.Container.prototype.initialize.apply(this,arguments)},prepareComponents:function(){var a=this;return _(this.components).each(function(b){return b.container=a.$el})},render:function(){return $(this.container).append(this.el)}})}.call(this),function(){_.def("Luca.components.CollectionLoaderView")["extends"]("Luca.components.Template")["with"]({className:"luca-ui-collection-loader-view",template:"components/collection_loader_view",initialize:function(a){return this.options=a!=null?a:{},Luca.components.Template.prototype.initialize.apply(this,arguments),this.container||(this.container=$("body")),this.manager||(this.manager=Luca.CollectionManager.get()),this.setupBindings()},modalContainer:function(){return $("#progress-modal",this.el)},setupBindings:function(){var a=this;return this.manager.bind("collection_loaded",function(b){var c,d,e,f;return d=a.manager.loadedCollectionsCount(),f=a.manager.totalCollectionsCount(),e=parseInt(d/f*100),c=_.string.titleize(_.string.humanize(b)),a.modalContainer().find(".progress .bar").attr("style","width: "+e+"%;"),a.modalContainer().find(".message").html("Loaded "+c+"...")}),this.manager.bind("all_collections_loaded",function(){return a.modalContainer().find(".message").html("All done!"),_.delay(function(){return a.modalContainer().modal("hide")},400)})}})}.call(this),function(){var a;_.def("Luca.components.CollectionView")["extends"]("Luca.components.Panel")["with"]({tagName:"div",className:"luca-ui-collection-view",bodyClassName:"collection-ui-panel",itemTemplate:void 0,itemRenderer:void 0,itemTagName:"li",itemClassName:"collection-item",hooks:["empty:results"],initialize:function(a){var b=this;this.options=a!=null?a:{},_.extend(this,this.options),_.bindAll(this,"refresh");if(this.collection==null&&!this.options.collection)throw"Collection Views must specify a collection";if(this.itemTemplate==null&&this.itemRenderer==null&&this.itemProperty==null)throw"Collection Views must specify an item template or item renderer function";Luca.components.Panel.prototype.initialize.apply(this,arguments),_.isString(this.collection)&&Luca.CollectionManager.get()&&(this.collection=Luca.CollectionManager.get().getOrCreate(this.collection));if(!Luca.isBackboneCollection(this.collection))throw"Collection Views must have a valid backbone collection";this.collection.on("before:fetch",function(){if(b.loadMask===!0)return b.trigger("enable:loadmask")}),this.collection.bind("reset",function(){return b.loadMask===!0&&b.trigger("disable:loadmask"),b.refresh()}),this.collection.bind("add",this.refresh),this.collection.bind("remove",this.refresh);if(this.collection.length>0)return this.refresh()},attributesForItem:function(a){return _.extend({},{"class":this.itemClassName,"data-index":a.index})},contentForItem:function(a){var b,c;return a==null&&(a={}),this.itemTemplate!=null&&(c=Luca.template(this.itemTemplate))&&(b=c.call(this,a)),this.itemRenderer!=null&&_.isFunction(this.itemRenderer)&&(b=this.itemRenderer.call(this,a,a.model,a.index)),this.itemProperty&&(b=a.model.get(this.itemProperty)||a.model[this.itemProperty],_.isFunction(b)&&(b=b())),b},makeItem:function(b,c){var d;return d=this.prepareItem!=null?this.prepareItem.call(this,b,c):{model:b,index:c},a(this.itemTagName,this.attributesForItem(d),this.contentForItem(d))},getModels:function(){var a;return((a=this.collection)!=null?a.query:void 0)&&(this.filter||this.filterOptions)?this.collection.query(this.filter,this.filterOptions):this.collection.models},refresh:function(){var a=this;return this.$bodyEl().empty(),this.getModels().length===0&&this.trigger("empty:results"),_(this.getModels()).each(function(b,c){return a.$append(a.makeItem(b,c))})},registerEvent:function(a,b,c){var d;return c==null&&_.isFunction(b)&&(c=b,b=void 0),d=_([a,""+this.itemTagName+"."+this.itemClassName,b]).compact().join(" "),Luca.View.prototype.registerEvent(d,c)},render:function(){return this.refresh(),this.$el.parent().length>0&&this.container!=null&&this.$attach(),this}}),a=Luca.View.prototype.make}.call(this),function(){_.def("Luca.components.Controller")["extends"]("Luca.containers.CardView")["with"]({additionalClassNames:["luca-ui-controller"],activeAttribute:"active-section",initialize:function(a){var b;this.options=a,Luca.containers.CardView.prototype.initialize.apply(this,arguments),this.defaultCard||(this.defaultCard=(b=this.components[0])!=null?b.name:void 0);if(!this.defaultCard)throw"Controllers must specify a defaultCard property and/or the first component must have a name";return this.state=new Backbone.Model({active_section:this.defaultCard})},each:function(a){var b=this;return _(this.components).each(function(c){return a.apply(b,[c])})},activeSection:function(){return this.get("activeSection")},controllers:function(a){return a==null&&(a=!1),this.select("ctype","controller",a)},availableSections:function(){var a,b=this;return a={},a[this.name]=this.sectionNames(),_(this.controllers()).reduce(function(a,b){return a[b.name]=b.sectionNames(),a},a)},sectionNames:function(a){return a==null&&(a=!1),this.pluck("name")},"default":function(a){return this.navigate_to(this.defaultCard,a)},navigate_to:function(a,b){var c=this;return a||(a=this.defaultCard),this.activate(a,!1,function(a,d,e){c.state.set({active_section:e.name});if(_.isFunction(b))return b.apply(e)}),this.find(a)}})}.call(this),function(){_.def("Luca.fields.ButtonField")["extends"]("Luca.core.Field")["with"]({readOnly:!0,events:{"click input":"click_handler"},hooks:["button:click"],className:"luca-ui-field luca-ui-button-field",template:"fields/button_field",click_handler:function(a){var b,c;return b=c=$(a.currentTarget),this.trigger("button:click")},initialize:function(a){var b;this.options=a!=null?a:{},_.extend(this.options),_.bindAll(this,"click_handler"),Luca.core.Field.prototype.initialize.apply(this,arguments);if((b=this.icon_class)!=null?b.length:void 0)return this.template="fields/button_field_link"},afterInitialize:function(){this.input_id||(this.input_id=_.uniqueId("button")),this.input_name||(this.input_name=this.name||(this.name=this.input_id)),this.input_value||(this.input_value=this.label||(this.label=this.text)),this.input_type||(this.input_type="button"),this.input_class||(this.input_class=this["class"]),this.icon_class||(this.icon_class=""),this.icon_class.length&&!this.icon_class.match(/^icon-/)&&(this.icon_class="icon-"+this.icon_class);if(this.white)return this.icon_class+=" icon-white"},setValue:function(){return!0}})}.call(this),function(){var a;a=Luca.View.prototype.make,_.def("Luca.fields.CheckboxArray")["extends"]("Luca.core.Field")["with"]({version:2,template:"fields/checkbox_array",className:"luca-ui-checkbox-array",events:{"click input":"clickHandler"},selectedItems:[],initialize:function(a){return this.options=a!=null?a:{},_.extend(this,this.options),_.extend(this,Luca.modules.Deferrable),_.bindAll(this,"renderCheckboxes","clickHandler","checkSelected"),Luca.core.Field.prototype.initialize.apply(this,arguments),this.input_id||(this.input_id=_.uniqueId("field")),this.input_name||(this.input_name=this.name),this.label||(this.label=this.name),this.valueField||(this.valueField="id"),this.displayField||(this.displayField="name")},afterInitialize:function(a){var b;this.options=a!=null?a:{};try{this.configure_collection()}catch(c){console.log("Error Configuring Collection",this,c.message)}return b=this,this.collection.length>0?this.renderCheckboxes():this.defer("renderCheckboxes").until(this.collection,"reset")},clickHandler:function(a){var b;b=$(a.target);if(b.prop("checked"))return this.selectedItems.push(b.val());if(_(this.selectedItems).include(b.val()))return this.selectedItems=_(this.selectedItems).without(b.val())},controls:function(){return this.$(".controls")},renderCheckboxes:function(){var b=this;return this.controls().empty(),this.selectedItems=[],this.collection.each(function(c){var d,e,f,g,h;return h=c.get(b.valueField),g=c.get(b.displayField),f=_.uniqueId(""+b.cid+"_checkbox"),e=a("input",{type:"checkbox","class":"array-checkbox",name:b.input_name,value:h,id:f}),d=a("label",{"for":f},e),$(d).append(" "+g),b.controls().append(d)}),this.trigger("checkboxes:rendered",this.checkboxesRendered=!0),this},uncheckAll:function(){return this.allFields().prop("checked",!1)},allFields:function(){return this.controls().find("input[type='checkbox']")},checkSelected:function(a){var b,c,d,e,f;a!=null&&(this.selectedItems=a),this.uncheckAll(),f=this.selectedItems;for(d=0,e=f.length;d<e;d++)c=f[d],b=this.controls().find("input[value='"+c+"']"),b.prop("checked",!0);return this.selectedItems},getValue:function(){var a,b,c,d,e;d=this.allFields(),e=[];for(b=0,c=d.length;b<c;b++)a=d[b],this.$(a).prop("checked")&&e.push(this.$(a).val());return e},setValue:function(a){var b;return this.selectedItems=a,this.checkboxesRendered===!0?this.checkSelected(a):(b=this,this.defer(function(){return b.checkSelected(a)}).until("checkboxes:rendered"))},getValues:function(){return this.getValue()},setValues:function(a){return this.setValue(a)}})}.call(this),function(){_.def("Luca.fields.CheckboxField")["extends"]("Luca.core.Field")["with"]({events:{"change input":"change_handler"},className:"luca-ui-checkbox-field luca-ui-field",template:"fields/checkbox_field",hooks:["checked","unchecked"],send_blanks:!0,change_handler:function(a){var b,c;return b=c=$(a.target),b.is(":checked")?this.trigger("checked"):this.trigger("unchecked"),this.trigger("on:change",this,a,b.is(":checked"))},initialize:function(a){return this.options=a!=null?a:{},_.extend(this,this.options),_.bindAll(this,"change_handler"),Luca.core.Field.prototype.initialize.apply(this,arguments)},afterInitialize:function(){return this.input_id||(this.input_id=_.uniqueId("field")),this.input_name||(this.input_name=this.name),this.input_value||(this.input_value=1),this.label||(this.label=this.name)},setValue:function(a){return this.input.attr("checked",a)},getValue:function(){return this.input.is(":checked")}})}.call(this),function(){_.def("Luca.fields.FileUploadField")["extends"]("Luca.core.Field")["with"]({template:"fields/file_upload_field",initialize:function(a){return this.options=a!=null?a:{},Luca.core.Field.prototype.initialize.apply(this,arguments)},afterInitialize:function(){return this.input_id||(this.input_id=_.uniqueId("field")),this.input_name||(this.input_name=this.name),this.label||(this.label=this.name),this.helperText||(this.helperText="")}})}.call(this),function(){_.def("Luca.fields.HiddenField")["extends"]("Luca.core.Field")["with"]({template:"fields/hidden_field",initialize:function(a){return this.options=a!=null?a:{},Luca.core.Field.prototype.initialize.apply(this,arguments)},afterInitialize:function(){return this.input_id||(this.input_id=_.uniqueId("field")),this.input_name||(this.input_name=this.name),this.input_value||(this.input_value=this.value),this.label||(this.label=this.name)}})}.call(this),function(){_.def("Luca.components.LabelField")["extends"]("Luca.core.Field")["with"]({className:"luca-ui-field luca-ui-label-field",getValue:function(){return this.$("input").attr("value")},formatter:function(a){return a||(a=this.getValue()),_.str.titleize(a)},setValue:function(a){return this.trigger("change",a,this.getValue()),this.$("input").attr("value",a),this.$(".value").html(this.formatter(a))}})}.call(this),function(){_.def("Luca.fields.SelectField")["extends"]("Luca.core.Field")["with"]({events:{"change select":"change_handler"},hooks:["after:select"],className:"luca-ui-select-field luca-ui-field",template:"fields/select_field",includeBlank:!0,blankValue:"",blankText:"Select One",initialize:function(a){this.options=a!=null?a:{},_.extend(this,this.options),_.extend(this,Luca.modules.Deferrable),_.bindAll(this,"change_handler","populateOptions","beforeFetch"),Luca.core.Field.prototype.initialize.apply(this,arguments),this.input_id||(this.input_id=_.uniqueId("field")),this.input_name||(this.input_name=this.name),this.label||(this.label=this.name);if(_.isUndefined(this.retainValue))return this.retainValue=!0},afterInitialize:function(){var a;if((a=this.collection)!=null?a.data:void 0)this.valueField||(this.valueField="id"),this.displayField||(this.displayField="name"),this.parseData();try{this.configure_collection()}catch(b){console.log("Error Configuring Collection"
8
- ,this,b.message)}return this.collection.bind("before:fetch",this.beforeFetch),this.collection.bind("reset",this.populateOptions)},parseData:function(){var a=this;return this.collection.data=_(this.collection.data).map(function(b){var c;return _.isArray(b)?(c={},c[a.valueField]=b[0],c[a.displayField]=b[1]||b[0],c):b})},afterRender:function(){var a,b;return this.input=$("select",this.el),((a=this.collection)!=null?(b=a.models)!=null?b.length:void 0:void 0)>0?this.populateOptions():this.collection.trigger("reset")},setValue:function(a){return this.currentValue=a,Luca.core.Field.prototype.setValue.apply(this,arguments)},beforeFetch:function(){return this.resetOptions()},change_handler:function(a){return this.trigger("on:change",this,a)},resetOptions:function(){this.input.html("");if(this.includeBlank)return this.input.append("<option value='"+this.blankValue+"'>"+this.blankText+"</option>")},populateOptions:function(){var a,b=this;return this.resetOptions(),((a=this.collection)!=null?a.each:void 0)!=null&&this.collection.each(function(a){var c,d,e,f;return f=a.get(b.valueField),c=a.get(b.displayField),b.selected&&f===b.selected&&(e="selected"),d="<option "+e+" value='"+f+"'>"+c+"</option>",b.input.append(d)}),this.trigger("after:populate:options",this),this.setValue(this.currentValue)}})}.call(this),function(){_.def("Luca.fields.TextAreaField")["extends"]("Luca.core.Field")["with"]({events:{"keydown input":"keydown_handler","blur input":"blur_handler","focus input":"focus_handler"},template:"fields/text_area_field",height:"200px",width:"90%",initialize:function(a){return this.options=a!=null?a:{},_.bindAll(this,"keydown_handler"),Luca.core.Field.prototype.initialize.apply(this,arguments),this.input_id||(this.input_id=_.uniqueId("field")),this.input_name||(this.input_name=this.name),this.label||(this.label=this.name),this.input_class||(this.input_class=this["class"]),this.inputStyles||(this.inputStyles="height:"+this.height+";width:"+this.width)},setValue:function(a){return $(this.field()).val(a)},getValue:function(){return $(this.field()).val()},field:function(){return this.input=$("textarea#"+this.input_id,this.el)},keydown_handler:function(a){var b,c;return b=c=$(a.currentTarget)},blur_handler:function(a){var b,c;return b=c=$(a.currentTarget)},focus_handler:function(a){var b,c;return b=c=$(a.currentTarget)}})}.call(this),function(){_.def("Luca.fields.TextField")["extends"]("Luca.core.Field")["with"]({events:{"blur input":"blur_handler","focus input":"focus_handler","change input":"change_handler"},template:"fields/text_field",autoBindEventHandlers:!0,send_blanks:!0,keyEventThrottle:300,initialize:function(a){return this.options=a!=null?a:{},this.enableKeyEvents&&this.registerEvent("keyup input","keyup_handler"),this.input_id||(this.input_id=_.uniqueId("field")),this.input_name||(this.input_name=this.name),this.label||(this.label=this.name),this.input_class||(this.input_class=this["class"]),this.prepend&&(this.$el.addClass("input-prepend"),this.addOn=this.prepend),this.append&&(this.$el.addClass("input-append"),this.addOn=this.append),Luca.core.Field.prototype.initialize.apply(this,arguments)},keyup_handler:function(a){return this.trigger("on:keyup",this,a)},blur_handler:function(a){return this.trigger("on:blur",this,a)},focus_handler:function(a){return this.trigger("on:focus",this,a)},change_handler:function(a){return this.trigger("on:change",this,a)}})}.call(this),function(){_.def("Luca.fields.TypeAheadField")["extends"]("Luca.fields.TextField")["with"]({className:"luca-ui-field",getSource:function(){return _.isFunction(this.source)?this.source.call(this):this.source||[]},matcher:function(a){return!0},beforeRender:function(){return this._super("beforeRender",this,arguments),this.$("input").attr("data-provide","typeahead")},afterRender:function(){return this._super("afterRender",this,arguments),this.$("input").typeahead({matcher:this.matcher,source:this.getSource()})}})}.call(this),function(){_.def("Luca.components.FormButtonToolbar")["extends"]("Luca.components.Toolbar")["with"]({className:"luca-ui-form-toolbar form-actions",position:"bottom",includeReset:!1,render:function(){return $(this.container).append(this.el)},initialize:function(a){this.options=a!=null?a:{},Luca.components.Toolbar.prototype.initialize.apply(this,arguments),this.components=[{ctype:"button_field",label:"Submit","class":"btn submit-button"}];if(this.includeReset)return this.components.push({ctype:"button_field",label:"Reset","class":"btn reset-button"})}})}.call(this),function(){var a;a={buttons:[{icon:"remove-sign",label:"Reset",eventId:"click:reset",className:"reset-button",align:"right"},{icon:"ok-sign",white:!0,label:"Save Changes",eventId:"click:submit",color:"success",className:"submit-button",align:"right"}]},_.def("Luca.components.FormView")["extends"]("Luca.core.Container")["with"]({tagName:"form",className:"luca-ui-form-view",hooks:["before:submit","before:reset","before:load","before:load:new","before:load:existing","after:submit","after:reset","after:load","after:load:new","after:load:existing","after:submit:success","after:submit:fatal_error","after:submit:error"],events:{"click .submit-button":"submitHandler","click .reset-button":"resetHandler"},toolbar:!0,legend:"",bodyClassName:"form-view-body",version:"0.9.33333333",initialize:function(a){this.options=a!=null?a:{},this.loadMask==null&&(this.loadMask=Luca.enableBootstrap),Luca.core.Container.prototype.initialize.apply(this,arguments),_.bindAll(this,"submitHandler","resetHandler","renderToolbars","applyLoadMask"),this.state||(this.state=new Backbone.Model),this.setupHooks(this.hooks),this.applyStyleClasses();if(this.toolbar!==!1&&!this.topToolbar&&!this.bottomToolbar){if(this.toolbar==="both"||this.toolbar==="top")this.topToolbar=this.getDefaultToolbar();if(this.toolbar!=="top")return this.bottomToolbar=this.getDefaultToolbar()}},getDefaultToolbar:function(){return a},applyStyleClasses:function(){Luca.enableBootstrap&&this.applyBootstrapStyleClasses(),this.labelAlign&&this.$el.addClass("label-align-"+this.labelAlign);if(this.fieldLayoutClass)return this.$el.addClass(this.fieldLayoutClass)},applyBootstrapStyleClasses:function(){this.labelAlign==="left"&&(this.inlineForm=!0),this.well&&this.$el.addClass("well"),this.searchForm&&this.$el.addClass("form-search"),this.horizontalForm&&this.$el.addClass("form-horizontal");if(this.inlineForm)return this.$el.addClass("form-inline")},resetHandler:function(a){var b,c;return b=c=$(a!=null?a.target:void 0),this.trigger("before:reset",this),this.reset(),this.trigger("after:reset",this)},submitHandler:function(a){var b,c;b=c=$(a!=null?a.target:void 0),this.trigger("before:submit",this),this.loadMask===!0&&this.trigger("enable:loadmask",this);if(this.hasModel())return this.submit()},afterComponents:function(){var a,b=this;return(a=Luca.core.Container.prototype.afterComponents)!=null&&a.apply(this,arguments),this.eachField(function(a){return a.getForm=function(){return b},a.getModel=function(){return b.currentModel()}})},eachField:function(a){return _(this.getFields()).map(a)},getField:function(a){var b;return b=_(this.getFields("name",a)).first(),b!=null?b:_(this.getFields("input_name",a)).first()},getFields:function(a,b){var c;return c=this.selectByAttribute("isField",!0,!0),a!=null&&b!=null&&(c=_(c).select(function(c){var d;return d=c[a],_.isFunction(d)&&(d=d.call(c)),d===b})),c},loadModel:function(a){var b,c,d,e;this.current_model=a,d=this,c=this.getFields(),this.trigger("before:load",this,this.current_model),this.current_model&&((e=this.current_model.beforeFormLoad)!=null&&e.apply(this.current_model,this),b="before:load:"+(this.current_model.isNew()?"new":"existing"),this.trigger(b,this,this.current_model)),this.setValues(this.current_model),this.trigger("after:load",this,this.current_model);if(this.current_model)return this.trigger("after:load:"+(this.current_model.isNew()?"new":"existing"),this,this.current_model)},reset:function(){if(this.current_model!=null)return this.loadModel(this.current_model)},clear:function(){var a=this;return this.current_model=this.defaultModel!=null?this.defaultModel():void 0,_(this.getFields()).each(function(b){try{return b.setValue("")}catch(c){return console.log("Error Clearing",a,b)}})},setValues:function(a,b){var c,d=this;b==null&&(b={}),a||(a=this.currentModel()),c=this.getFields(),_(c).each(function(b){var c,e;c=b.input_name||b.name,(e=a[c])&&_.isFunction(e)&&(e=e.apply(d)),!e&&Luca.isBackboneModel(a)&&(e=a.get(c));if(b.readOnly!==!0)return b!=null?b.setValue(e):void 0});if(b.silent!=null!=1)return this.syncFormWithModel()},getValues:function(a){var b,c=this;return a==null&&(a={}),a.reject_blank==null&&(a.reject_blank=!0),a.skip_buttons==null&&(a.skip_buttons=!0),a.blanks===!1&&(a.reject_blank=!0),b=_(this.getFields()).inject(function(b,c){var d,e,f,g,h;return g=c.getValue(),e=c.input_name||c.name,h=!!_.str.isBlank(g)||!!_.isUndefined(g),d=!a.reject_blank&&!c.send_blanks,a.debug&&console.log(""+e+" Options",a,"Value",g,"Value Is Blank?",h,"Allow Blanks?",d),a.skip_buttons&&c.ctype==="button_field"?f=!0:(h&&d===!1&&(f=!0),c.input_name==="id"&&h===!0&&(f=!0)),a.debug&&console.log("Skip is true on "+e),f!==!0&&(b[e]=g),b},a.defaults||{}),b},submit_success_handler:function(a,b,c){return this.trigger("after:submit",this,a,b),this.loadMask===!0&&this.trigger("disable:loadmask",this),b&&(b!=null?b.success:void 0)===!0?this.trigger("after:submit:success",this,a,b):this.trigger("after:submit:error",this,a,b)},submit_fatal_error_handler:function(a,b,c){return this.trigger("after:submit",this,a,b),this.trigger("after:submit:fatal_error",this,a,b)},submit:function(a,b){a==null&&(a=!0),b==null&&(b={}),_.bindAll(this,"submit_success_handler","submit_fatal_error_handler"),b.success||(b.success=this.submit_success_handler),b.error||(b.error=this.submit_fatal_error_handler),this.syncFormWithModel();if(!a)return;return this.current_model.save(this.current_model.toJSON(),b)},hasModel:function(){return this.current_model!=null},currentModel:function(a){return a==null&&(a={}),(a===!0||(a!=null?a.refresh:void 0)===!0)&&this.syncFormWithModel(),this.current_model},syncFormWithModel:function(){var a;return(a=this.current_model)!=null?a.set(this.getValues()):void 0},setLegend:function(a){return this.legend=a,$("fieldset legend",this.el).first().html(this.legend)},flash:function(a){return this.$(".toolbar-container.top").length>0?this.$(".toolbar-container.top").after(a):this.$bodyEl().prepend(a)},successFlashDelay:1500,successMessage:function(a){var b=this;return this.$(".alert.alert-success").remove(),this.flash(Luca.template("components/form_alert",{className:"alert alert-success",message:a})),_.delay(function(){return b.$(".alert.alert-success").fadeOut()},this.successFlashDelay||0)},errorMessage:function(a){return this.$(".alert.alert-error").remove(),this.flash(Luca.template("components/form_alert",{className:"alert alert-error",message:a}))}})}.call(this),function(){_.def("Luca.components.GridView").extend("Luca.components.Panel")["with"]({bodyTemplate:"components/grid_view",autoBindEventHandlers:!0,events:{"dblclick table tbody tr":"double_click_handler","click table tbody tr":"click_handler"},className:"luca-ui-g-view",rowClass:"luca-ui-g-row",wrapperClass:"luca-ui-g-view-wrapper",additionalWrapperClasses:[],wrapperStyles:{},scrollable:!0,emptyText:"No Results To display.",tableStyle:"striped",defaultHeight:285,defaultWidth:756,maxWidth:void 0,hooks:["before:grid:render","before:render:header","before:render:row","after:grid:render","row:double:click","row:click","after:collection:load"],initialize:function(a){var b=this;return this.options=a!=null?a:{},_.extend(this,this.options),_.extend(this,Luca.modules.Deferrable),this.loadMask==null&&(this.loadMask=Luca.enableBootstrap),this.loadMask===!0&&(this.loadMaskEl||(this.loadMaskEl=".luca-ui-g-view-body")),Luca.components.Panel.prototype.initialize.apply(this,arguments),this.configure_collection(!0),this.collection.bind("before:fetch",function(){if(b.loadMask===!0)return b.trigger("enable:loadmask")}),this.collection.bind("reset",function(a){return b.refresh(),b.loadMask===!0&&b.trigger("disable:loadmask"),b.trigger("after:collection:load",a)}),this.collection.bind("change",function(a){var c,d;if(b.rendered!==!0)return;try{return d=b.getRowEl(a.id||a.get("id")||a.cid),c=b.render_row(a,b.collection.indexOf(a),{cellsOnly:!0}),$(d).html(c.join(" "))}catch(e){return console.log("Error in change handler for GridView.collection",e,b,a)}})},beforeRender:function(){var a;return(a=Luca.components.Panel.prototype.beforeRender)!=null&&a.apply(this,arguments),this.trigger("before:grid:render",this),this.table=this.$("table.luca-ui-g-view"),this.header=this.$("thead"),this.body=this.$("tbody"),this.footer=this.$("tfoot"),this.wrapper=this.$("."+this.wrapperClass),this.applyCssClasses(),this.scrollable&&this.setDimensions(),this.renderHeader(),this.emptyMessage(),$(this.container).append(this.$el)},afterRender:function(){var a;return(a=Luca.components.Panel.prototype.afterRender)!=null&&a.apply(this,arguments),this.rendered=!0,this.refresh(),this.trigger("after:grid:render",this)},applyCssClasses:function(){var a,b=this;return this.scrollable&&this.$el.addClass("scrollable-g-view"),_(this.additionalWrapperClasses).each(function(a){var c;return(c=b.wrapper)!=null?c.addClass(a):void 0}),Luca.enableBootstrap&&this.table.addClass("table"),_((a=this.tableStyle)!=null?a.split(" "):void 0).each(function(a){return b.table.addClass("table-"+a)})},setDimensions:function(a){var b=this;return this.height||(this.height=this.defaultHeight),this.$(".luca-ui-g-view-body").height(this.height),this.$("tbody.scrollable").height(this.height-23),this.container_width=function(){return $(b.container).width()}(),this.width||(this.width=this.container_width>0?this.container_width:this.defaultWidth),this.width=_([this.width,this.maxWidth||this.width]).max(),this.$(".luca-ui-g-view-body").width(this.width),this.$(".luca-ui-g-view-body table").width(this.width),this.setDefaultColumnWidths()},resize:function(a){var b,c,d=this;b=a-this.width,this.width=a,this.$(".luca-ui-g-view-body").width(this.width),this.$(".luca-ui-g-view-body table").width(this.width);if(this.columns.length>0)return c=b/this.columns.length,_(this.columns).each(function(a,b){var e;return e=$(".column-"+b,d.el),e.width(a.width=a.width+c)})},padLastColumn:function(){var a,b;a=_(this.columns).inject(function(a,b){return a=b.width+a},0),b=this.width-a;if(b>0)return this.lastColumn().width+=b},setDefaultColumnWidths:function(){var a;return a=this.columns.length>0?this.width/this.columns.length:200,_(this.columns).each(function(b){return parseInt(b.width||(b.width=a))}),this.padLastColumn()},lastColumn:function(){return this.columns[this.columns.length-1]},emptyMessage:function(a){return a==null&&(a=""),a||(a=this.emptyText),this.body.html(""),this.body.append(Luca.templates["components/grid_view_empty_text"]({colspan:this.columns.length,text:a}))},refresh:function(){var a=this;this.body.html(""),this.collection.each(function(b,c){return a.render_row.apply(a,[b,c])});if(this.collection.models.length===0)return this.emptyMessage()},ifLoaded:function(a,b){return b||(b=this),a||(a=function(){return!0}),this.collection.ifLoaded(a,b)},applyFilter:function(a,b){return b==null&&(b={auto:!0,refresh:!0}),this.collection.applyFilter(a,b)},renderHeader:function(){var a,b=this;return this.trigger("before:render:header"),a=_(this.columns).map(function(a,b){var c;return c=a.width?"width:"+a.width+"px;":"","<th style='"+c+"' class='column-"+b+"'>"+a.header+"</th>"}),this.header.append("<tr>"+a+"</tr>")},getRowEl:function(a){return this.$("[data-record-id="+a+"]","table")},render_row:function(a,b,c){var d,e,f,g,h,i,j=this;return c==null&&(c={}),h=this.rowClass,g=(a!=null?a.get:void 0)&&(a!=null?a.attributes:void 0)?a.get("id"):"",this.trigger("before:render:row",a,b),e=_(this.columns).map(function(b,c){var d,e,f;return f=j.cell_renderer(a,b,c),e=b.width?"width:"+b.width+"px;":"",d=_.isUndefined(f)?"":f,"<td style='"+e+"' class='column-"+c+"'>"+d+"</td>"}),c.cellsOnly?e:(d="",this.alternateRowClasses&&(d=b%2===0?"even":"odd"),f="<tr data-record-id='"+g+"' data-row-index='"+b+"' class='"+h+" "+d+"' id='row-"+b+"'>"+e+"</tr>",c.contentOnly===!0?f:(i=this.body)!=null?i.append(f):void 0)},cell_renderer:function(a,b,c){var d;return _.isFunction(b.renderer)?b.renderer.apply(this,[a,b,c]):b.data.match(/\w+\.\w+/)?(d=a.attributes||a,Luca.util.nestedValue(b.data,d)):(typeof a.get=="function"?a.get(b.data):void 0)||a[b.data]},double_click_handler:function(a){var b,c,d,e;return b=c=$(a.currentTarget),e=c.data("row-index"),d=this.collection.at(e),this.trigger("row:double:click",this,d,e)},click_handler:function(a){var b,c,d,e;return b=c=$(a.currentTarget),e=c.data("row-index"),d=this.collection.at(e),this.trigger("row:click",this,d,e),$("."+this.rowClass,this.body).removeClass("selected-row"),b.addClass("selected-row")}})}.call(this),function(){_.def("Luca.components.LoadMask")["extends"]("Luca.View")["with"]({className:"luca-ui-load-mask",bodyTemplate:"components/load_mask"})}.call(this),function(){_.def("Luca.components.NavBar")["extends"]("Luca.View")["with"]({fixed:!0,position:"top",className:"navbar",brand:"Luca.js",bodyTemplate:"nav_bar",bodyClassName:"luca-ui-navbar-body",beforeRender:function(){this.fixed&&this.$el.addClass("navbar-fixed-"+this.position),this.brand!=null&&this.content().append("<a class='brand' href='#'>"+this.brand+"</a>");if(this.template)return this.content().append(Luca.template(this.template,this))},render:function(){return this},content:function(){return this.$(".container").eq(0)}})}.call(this),function(){_.def("Luca.PageController")["extends"]("Luca.components.Controller")["with"]({version:2})}.call(this),function(){_.def("Luca.components.RecordManager")["extends"]("Luca.containers.CardView")["with"]({events:{"click .record-manager-grid .edit-link":"edit_handler","click .record-manager-filter .filter-button":"filter_handler","click .record-manager-filter .reset-button":"reset_filter_handler","click .add-button":"add_handler","click .refresh-button":"filter_handler","click .back-to-search-button":"back_to_search_handler"},record_manager:!0,initialize:function(a){var b=this;this.options=a!=null?a:{},Luca.containers.CardView.prototype.initialize.apply(this,arguments);if(!this.name)throw"Record Managers must specify a name";return _.bindAll(this,"add_handler","edit_handler","filter_handler","reset_filter_handler"),this.filterConfig&&_.extend(this.components[0][0],this.filterConfig),this.gridConfig&&_.extend(this.components[0][1],this.gridConfig),this.editorConfig&&_.extend(this.components[1][0],this.editorConfig),this.bind("after:card:switch",function(){b.activeCard===0&&b.trigger("activation:search",b);if(b.activeCard===1)return b.trigger("activation:editor",b)})},components:[{ctype:"split_view",relayFirstActivation:!0,components:[{ctype:"form_view"},{ctype:"grid_view"}]},{ctype:"form_view"}],getSearch:function(a,b){return a==null&&(a=!1),b==null&&(b=!0),a===!0&&this.activate(0),b===!0&&this.getEditor().clear(),_.first(this.components)},getFilter:function(){return _.first(this.getSearch().components)},getGrid:function(){return _.last(this.getSearch().components)},getCollection:function(){return this.getGrid().collection},getEditor:function(a,b){var c=this;return a==null&&(a=!1),b==null&&(b=!1),a===!0&&this.activate(1,function(a,b,c){return c.reset()}),_.last(this.components)},beforeRender:function(){var a;return this.$el.addClass(""+this.resource+"-manager"),(a=Luca.containers.CardView.prototype.beforeRender)!=null&&a.apply(this,arguments),this.$el.addClass(""+this.resource+" record-manager"),this.$el.data("resource",this.resource),$(this.getGrid().el).addClass(""+this.resource+" record-manager-grid"),$(this.getFilter().el).addClass(""+this.resource+" record-manager-filter"),$(this.getEditor().el).addClass(""+this.resource+" record-manager-editor")},afterRender:function(){var a,b,c,d,e,f,g=this;return(f=Luca.containers.CardView.prototype.afterRender)!=null&&f.apply(this,arguments),e=this,d=this.getGrid(),c=this.getFilter(),b=this.getEditor(),a=this.getCollection(),d.bind("row:double:click",function(a,c,d){return e.getEditor(!0),b.loadModel(c)}),b.bind("before:submit",function(){return $(".form-view-flash-container",g.el).html(""),$(".form-view-body",g.el).spin("large")}),b.bind("after:submit",function(){return $(".form-view-body",g.el).spin(!1)}),b.bind("after:submit:fatal_error",function(){return $(".form-view-flash-container",g.el).append("<li class='error'>There was an internal server error saving this record. Please contact developers@benchprep.com to report this error.</li>"),$(".form-view-body",g.el).spin(!1)}),b.bind("after:submit:error",function(a,b,c){return _(c.errors).each(function(a){return $(".form-view-flash-container",g.el).append("<li class='error'>"+a+"</li>")})}),b.bind("after:submit:success",function(a,b,c){return $(".form-view-flash-container",g.el).append("<li class='success'>Successfully Saved Record</li>"),b.set(c.result),a.loadModel(b),d.refresh(),_.delay(function(){return $(".form-view-flash-container li.success",g.el).fadeOut(1e3),$(".form-view-flash-container",g.el).html("")},4e3)}),c.eachComponent(function(a){try{return a.bind("on:change",g.filter_handler)}catch(b){return}})},firstActivation:function(){return this.getGrid().trigger("first:activation",this,this.getGrid()),this.getFilter().trigger("first:activation",this,this.getGrid())},reload:function(){var a,b,c,d;return d=this,c=this.getGrid(),b=this.getFilter(),a=this.getEditor(),b.clear(),c.applyFilter()},manageRecord:function(a){var b,c=this;return b=this.getCollection().get(a),b?this.loadModel(b):(console.log("Could Not Find Model, building and fetching"),b=this.buildModel(),b.set({id:a},{silent:!0}),b.fetch({success:function(a,b){return c.loadModel(a)}}))},loadModel:function(a){return this.current_model=a,this.getEditor(!0).loadModel(this.current_model),this.trigger("model:loaded",this.current_model)},currentModel:function(){return this.getEditor(!1).currentModel()},buildModel:function(){var a,b,c;return b=this.getEditor(!1),a=this.getCollection(),a.add([{}],{silent:!0,at:0}),c=a.at(0)},createModel:function(){return this.loadModel(this.buildModel())},reset_filter_handler:function(a){return this.getFilter().clear(),this.getGrid().applyFilter(this.getFilter().getValues())},filter_handler:function(a){return this.getGrid().applyFilter(this.getFilter().getValues())},edit_handler:function(a){var b,c,d,e;return b=d=$(a.currentTarget),e=d.parents("tr").data("record-id"),e&&(c=this.getGrid().collection.get(e)),c||(c=this.getGrid().collection.at(row_index))},add_handler:function(a){var b,c,d;return b=c=$(a.currentTarget),d=c.parents(".record-manager").eq(0).data("resource")},destroy_handler:function(a){},back_to_search_handler:function(){}})}.call(this),function(){_.def("Luca.Router")["extends"]("Backbone.Router")["with"]({routes:{"":"default"},initialize:function(a){var b=this;return this.options=a,_.extend(this,this.options),this.routeHandlers=_(this.routes).values(),_(this.routeHandlers).each(function(a){return b.bind("route:"+a,function(){return b.trigger.apply(b,["change:navigation",a].concat(_(arguments).flatten()))})})},navigate:function(a,b){return b==null&&(b=!1),Backbone.Router.prototype.navigate.apply(this,arguments),this.buildPathFrom(Backbone.history.getFragment())},buildPathFrom:function(a){var b=this;return _(this.routes).each(function(c,d){var e,f;f=b._routeToRegExp(d);if(f.test(a))return e=b._extractParameters(f,a),b.trigger.apply(b,["change:navigation",c].concat(e))})}})}.call(this),function(){_.def("Luca.components.ToolbarDialog")["extends"]("Luca.View")["with"]({className:"luca-ui-toolbar-dialog span well",styles:{position:"absolute","z-Index":"3000","float":"left"},initialize:function(a){return this.options=a!=null?a:{},this._super("initialize",this,arguments)},createWrapper:function(){return this.make("div",{"class":"component-picker span4 well",style:"position: absolute; z-index:12000"})},show:function(){return this.$el.parent().show()},hide:function(){return this.$el.parent().hide()},toggle:function(){return this.$el.parent().toggle()}})}.call(this),function(){}.call(this);
3
+ );try{for(var c=0,d=this.length;c<d;c++)this[c].nodeType===1&&(K.cleanData(this[c].getElementsByTagName("*")),this[c].innerHTML=a)}catch(e){this.empty().append(a)}}else K.isFunction(a)?this.each(function(b){var c=K(this);c.html(a.call(this,b,c.html()))}):this.empty().append(a);return this},replaceWith:function(a){return this[0]&&this[0].parentNode?K.isFunction(a)?this.each(function(b){var c=K(this),d=c.html();c.replaceWith(a.call(this,b,d))}):(typeof a!="string"&&(a=K(a).detach()),this.each(function(){var b=this.nextSibling,c=this.parentNode;K(this).remove(),b?K(b).before(a):K(c).append(a)})):this.length?this.pushStack(K(K.isFunction(a)?a():a),"replaceWith",a):this},detach:function(a){return this.remove(a,!0)},domManip:function(a,c,d){var e,f,g,h,i=a[0],j=[];if(!K.support.checkClone&&arguments.length===3&&typeof i=="string"&&zb.test(i))return this.each(function(){K(this).domManip(a,c,d,!0)});if(K.isFunction(i))return this.each(function(e){var f=K(this);a[0]=i.call(this,e,c?f.html():b),f.domManip(a,c,d)});if(this[0]){h=i&&i.parentNode,K.support.parentNode&&h&&h.nodeType===11&&h.childNodes.length===this.length?e={fragment:h}:e=K.buildFragment(a,this,j),g=e.fragment,g.childNodes.length===1?f=g=g.firstChild:f=g.firstChild;if(f){c=c&&K.nodeName(f,"tr");for(var k=0,l=this.length,m=l-1;k<l;k++)d.call(c?x(this[k],f):this[k],e.cacheable||l>1&&k<m?K.clone(g,!0,!0):g)}j.length&&K.each(j,q)}return this}}),K.buildFragment=function(a,b,c){var d,e,f,g,h=a[0];return b&&b[0]&&(g=b[0].ownerDocument||b[0]),g.createDocumentFragment||(g=H),a.length===1&&typeof h=="string"&&h.length<512&&g===H&&h.charAt(0)==="<"&&!xb.test(h)&&(K.support.checkClone||!zb.test(h))&&(K.support.html5Clone||!yb.test(h))&&(e=!0,f=K.fragments[h],f&&f!==1&&(d=f)),d||(d=g.createDocumentFragment(),K.clean(a,g,d,c)),e&&(K.fragments[h]=f?d:1),{fragment:d,cacheable:e}},K.fragments={},K.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){K.fn[a]=function(c){var d=[],e=K(c),f=this.length===1&&this[0].parentNode;if(f&&f.nodeType===11&&f.childNodes.length===1&&e.length===1)return e[b](this[0]),this;for(var g=0,h=e.length;g<h;g++){var i=(g>0?this.clone(!0):this).get();K(e[g])[b](i),d=d.concat(i)}return this.pushStack(d,a,e.selector)}}),K.extend({clone:function(a,b,c){var d,e,f,g=K.support.html5Clone||!yb.test("<"+a.nodeName)?a.cloneNode(!0):r(a);if((!K.support.noCloneEvent||!K.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!K.isXMLDoc(a)){v(a,g),d=u(a),e=u(g);for(f=0;d[f];++f)e[f]&&v(d[f],e[f])}if(b){w(a,g);if(c){d=u(a),e=u(g);for(f=0;d[f];++f)w(d[f],e[f])}}return d=e=null,g},clean:function(a,b,c,d){var e;b=b||H,typeof b.createElement=="undefined"&&(b=b.ownerDocument||b[0]&&b[0].ownerDocument||H);var f=[],g;for(var h=0,i;(i=a[h])!=null;h++){typeof i=="number"&&(i+="");if(!i)continue;if(typeof i=="string")if(!vb.test(i))i=b.createTextNode(i);else{i=i.replace(sb,"<$1></$2>");var j=(tb.exec(i)||["",""])[1].toLowerCase(),k=Cb[j]||Cb._default,l=k[0],m=b.createElement("div");b===H?Db.appendChild(m):y(b).appendChild(m),m.innerHTML=k[1]+i+k[2];while(l--)m=m.lastChild;if(!K.support.tbody){var n=ub.test(i),o=j==="table"&&!n?m.firstChild&&m.firstChild.childNodes:k[1]==="<table>"&&!n?m.childNodes:[];for(g=o.length-1;g>=0;--g)K.nodeName(o[g],"tbody")&&!o[g].childNodes.length&&o[g].parentNode.removeChild(o[g])}!K.support.leadingWhitespace&&rb.test(i)&&m.insertBefore(b.createTextNode(rb.exec(i)[0]),m.firstChild),i=m.childNodes}var p;if(!K.support.appendChecked)if(i[0]&&typeof (p=i.length)=="number")for(g=0;g<p;g++)s(i[g]);else s(i);i.nodeType?f.push(i):f=K.merge(f,i)}if(c){e=function(a){return!a.type||Ab.test(a.type)};for(h=0;f[h];h++)if(d&&K.nodeName(f[h],"script")&&(!f[h].type||f[h].type.toLowerCase()==="text/javascript"))d.push(f[h].parentNode?f[h].parentNode.removeChild(f[h]):f[h]);else{if(f[h].nodeType===1){var q=K.grep(f[h].getElementsByTagName("script"),e);f.splice.apply(f,[h+1,0].concat(q))}c.appendChild(f[h])}}return f},cleanData:function(a){var b,c,d=K.cache,e=K.event.special,f=K.support.deleteExpando;for(var g=0,h;(h=a[g])!=null;g++){if(h.nodeName&&K.noData[h.nodeName.toLowerCase()])continue;c=h[K.expando];if(c){b=d[c];if(b&&b.events){for(var i in b.events)e[i]?K.event.remove(h,i):K.removeEvent(h,i,b.handle);b.handle&&(b.handle.elem=null)}f?delete h[K.expando]:h.removeAttribute&&h.removeAttribute(K.expando),delete d[c]}}}});var Eb=/alpha\([^)]*\)/i,Fb=/opacity=([^)]*)/,Gb=/([A-Z]|^ms)/g,Hb=/^-?\d+(?:px)?$/i,Ib=/^-?\d/,Jb=/^([\-+])=([\-+.\de]+)/,Kb={position:"absolute",visibility:"hidden",display:"block"},Lb=["Left","Right"],Mb=["Top","Bottom"],Nb,Ob,Pb;K.fn.css=function(a,c){return arguments.length===2&&c===b?this:K.access(this,a,c,!0,function(a,c,d){return d!==b?K.style(a,c,d):K.css(a,c)})},K.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=Nb(a,"opacity","opacity");return c===""?"1":c}return a.style.opacity}}},cssNumber:{fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":K.support.cssFloat?"cssFloat":"styleFloat"},style:function(a,c,d,e){if(!!a&&a.nodeType!==3&&a.nodeType!==8&&!!a.style){var f,g,h=K.camelCase(c),i=a.style,j=K.cssHooks[h];c=K.cssProps[h]||h;if(d===b)return j&&"get"in j&&(f=j.get(a,!1,e))!==b?f:i[c];g=typeof d,g==="string"&&(f=Jb.exec(d))&&(d=+(f[1]+1)*+f[2]+parseFloat(K.css(a,c)),g="number");if(d==null||g==="number"&&isNaN(d))return;g==="number"&&!K.cssNumber[h]&&(d+="px");if(!j||!("set"in j)||(d=j.set(a,d))!==b)try{i[c]=d}catch(k){}}},css:function(a,c,d){var e,f;c=K.camelCase(c),f=K.cssHooks[c],c=K.cssProps[c]||c,c==="cssFloat"&&(c="float");if(f&&"get"in f&&(e=f.get(a,!0,d))!==b)return e;if(Nb)return Nb(a,c)},swap:function(a,b,c){var d={};for(var e in b)d[e]=a.style[e],a.style[e]=b[e];c.call(a);for(e in b)a.style[e]=d[e]}}),K.curCSS=K.css,K.each(["height","width"],function(a,b){K.cssHooks[b]={get:function(a,c,d){var e;if(c)return a.offsetWidth!==0?p(a,b,d):(K.swap(a,Kb,function(){e=p(a,b,d)}),e)},set:function(a,b){if(!Hb.test(b))return b;b=parseFloat(b);if(b>=0)return b+"px"}}}),K.support.opacity||(K.cssHooks.opacity={get:function(a,b){return Fb.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=K.isNumeric(b)?"alpha(opacity="+b*100+")":"",f=d&&d.filter||c.filter||"";c.zoom=1;if(b>=1&&K.trim(f.replace(Eb,""))===""){c.removeAttribute("filter");if(d&&!d.filter)return}c.filter=Eb.test(f)?f.replace(Eb,e):f+" "+e}}),K(function(){K.support.reliableMarginRight||(K.cssHooks.marginRight={get:function(a,b){var c;return K.swap(a,{display:"inline-block"},function(){b?c=Nb(a,"margin-right","marginRight"):c=a.style.marginRight}),c}})}),H.defaultView&&H.defaultView.getComputedStyle&&(Ob=function(a,b){var c,d,e;return b=b.replace(Gb,"-$1").toLowerCase(),(d=a.ownerDocument.defaultView)&&(e=d.getComputedStyle(a,null))&&(c=e.getPropertyValue(b),c===""&&!K.contains(a.ownerDocument.documentElement,a)&&(c=K.style(a,b))),c}),H.documentElement.currentStyle&&(Pb=function(a,b){var c,d,e,f=a.currentStyle&&a.currentStyle[b],g=a.style;return f===null&&g&&(e=g[b])&&(f=e),!Hb.test(f)&&Ib.test(f)&&(c=g.left,d=a.runtimeStyle&&a.runtimeStyle.left,d&&(a.runtimeStyle.left=a.currentStyle.left),g.left=b==="fontSize"?"1em":f||0,f=g.pixelLeft+"px",g.left=c,d&&(a.runtimeStyle.left=d)),f===""?"auto":f}),Nb=Ob||Pb,K.expr&&K.expr.filters&&(K.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!K.support.reliableHiddenOffsets&&(a.style&&a.style.display||K.css(a,"display"))==="none"},K.expr.filters.visible=function(a){return!K.expr.filters.hidden(a)});var Qb=/%20/g,Rb=/\[\]$/,Sb=/\r?\n/g,Tb=/#.*$/,Ub=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,Vb=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,Wb=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,Xb=/^(?:GET|HEAD)$/,Yb=/^\/\//,Zb=/\?/,$b=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,_b=/^(?:select|textarea)/i,ac=/\s+/,bc=/([?&])_=[^&]*/,cc=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,dc=K.fn.load,ec={},fc={},gc,hc,ic=["*/"]+["*"];try{gc=J.href}catch(jc){gc=H.createElement("a"),gc.href="",gc=gc.href}hc=cc.exec(gc.toLowerCase())||[],K.fn.extend({load:function(a,c,d){if(typeof a!="string"&&dc)return dc.apply(this,arguments);if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var f=a.slice(e,a.length);a=a.slice(0,e)}var g="GET";c&&(K.isFunction(c)?(d=c,c=b):typeof c=="object"&&(c=K.param(c,K.ajaxSettings.traditional),g="POST"));var h=this;return K.ajax({url:a,type:g,dataType:"html",data:c,complete:function(a,b,c){c=a.responseText,a.isResolved()&&(a.done(function(a){c=a}),h.html(f?K("<div>").append(c.replace($b,"")).find(f):c)),d&&h.each(d,[c,b,a])}}),this},serialize:function(){return K.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?K.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||_b.test(this.nodeName)||Vb.test(this.type))}).map(function(a,b){var c=K(this).val();return c==null?null:K.isArray(c)?K.map(c,function(a,c){return{name:b.name,value:a.replace(Sb,"\r\n")}}):{name:b.name,value:c.replace(Sb,"\r\n")}}).get()}}),K.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){K.fn[b]=function(a){return this.on(b,a)}}),K.each(["get","post"],function(a,c){K[c]=function(a,d,e,f){return K.isFunction(d)&&(f=f||e,e=d,d=b),K.ajax({type:c,url:a,data:d,success:e,dataType:f})}}),K.extend({getScript:function(a,c){return K.get(a,b,c,"script")},getJSON:function(a,b,c){return K.get(a,b,c,"json")},ajaxSetup:function(a,b){return b?m(a,K.ajaxSettings):(b=a,a=K.ajaxSettings),m(a,b),a},ajaxSettings:{url:gc,isLocal:Wb.test(hc[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":ic},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":K.parseJSON,"text xml":K.parseXML},flatOptions:{context:!0,url:!0}},ajaxPrefilter:o(ec),ajaxTransport:o(fc),ajax:function(a,c){function d(a,c,d,n){if(v!==2){v=2,t&&clearTimeout(t),s=b,q=n||"",y.readyState=a>0?4:0;var o,p,r,u=c,x=d?k(e,y,d):b,z,A;if(a>=200&&a<300||a===304){if(e.ifModified){if(z=y.getResponseHeader("Last-Modified"))K.lastModified[m]=z;if(A=y.getResponseHeader("Etag"))K.etag[m]=A}if(a===304)u="notmodified",o=!0;else try{p=j(e,x),u="success",o=!0}catch(B){u="parsererror",r=B}}else{r=u;if(!u||a)u="error",a<0&&(a=0)}y.status=a,y.statusText=""+(c||u),o?h.resolveWith(f,[p,u,y]):h.rejectWith(f,[y,u,r]),y.statusCode(l),l=b,w&&g.trigger("ajax"+(o?"Success":"Error"),[y,e,o?p:r]),i.fireWith(f,[y,u]),w&&(g.trigger("ajaxComplete",[y,e]),--K.active||K.event.trigger("ajaxStop"))}}typeof a=="object"&&(c=a,a=b),c=c||{};var e=K.ajaxSetup({},c),f=e.context||e,g=f!==e&&(f.nodeType||f instanceof K)?K(f):K.event,h=K.Deferred(),i=K.Callbacks("once memory"),l=e.statusCode||{},m,o={},p={},q,r,s,t,u,v=0,w,x,y={readyState:0,setRequestHeader:function(a,b){if(!v){var c=a.toLowerCase();a=p[c]=p[c]||a,o[a]=b}return this},getAllResponseHeaders:function(){return v===2?q:null},getResponseHeader:function(a){var c;if(v===2){if(!r){r={};while(c=Ub.exec(q))r[c[1].toLowerCase()]=c[2]}c=r[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){return v||(e.mimeType=a),this},abort:function(a){return a=a||"abort",s&&s.abort(a),d(0,a),this}};h.promise(y),y.success=y.done,y.error=y.fail,y.complete=i.add,y.statusCode=function(a){if(a){var b;if(v<2)for(b in a)l[b]=[l[b],a[b]];else b=a[y.status],y.then(b,b)}return this},e.url=((a||e.url)+"").replace(Tb,"").replace(Yb,hc[1]+"//"),e.dataTypes=K.trim(e.dataType||"*").toLowerCase().split(ac),e.crossDomain==null&&(u=cc.exec(e.url.toLowerCase()),e.crossDomain=!(!u||u[1]==hc[1]&&u[2]==hc[2]&&(u[3]||(u[1]==="http:"?80:443))==(hc[3]||(hc[1]==="http:"?80:443)))),e.data&&e.processData&&typeof e.data!="string"&&(e.data=K.param(e.data,e.traditional)),n(ec,e,c,y);if(v===2)return!1;w=e.global,e.type=e.type.toUpperCase(),e.hasContent=!Xb.test(e.type),w&&K.active++===0&&K.event.trigger("ajaxStart");if(!e.hasContent){e.data&&(e.url+=(Zb.test(e.url)?"&":"?")+e.data,delete e.data),m=e.url;if(e.cache===!1){var z=K.now(),A=e.url.replace(bc,"$1_="+z);e.url=A+(A===e.url?(Zb.test(e.url)?"&":"?")+"_="+z:"")}}(e.data&&e.hasContent&&e.contentType!==!1||c.contentType)&&y.setRequestHeader("Content-Type",e.contentType),e.ifModified&&(m=m||e.url,K.lastModified[m]&&y.setRequestHeader("If-Modified-Since",K.lastModified[m]),K.etag[m]&&y.setRequestHeader("If-None-Match",K.etag[m])),y.setRequestHeader("Accept",e.dataTypes[0]&&e.accepts[e.dataTypes[0]]?e.accepts[e.dataTypes[0]]+(e.dataTypes[0]!=="*"?", "+ic+"; q=0.01":""):e.accepts["*"]);for(x in e.headers)y.setRequestHeader(x,e.headers[x]);if(!e.beforeSend||e.beforeSend.call(f,y,e)!==!1&&v!==2){for(x in{success:1,error:1,complete:1})y[x](e[x]);s=n(fc,e,c,y);if(!s)d(-1,"No Transport");else{y.readyState=1,w&&g.trigger("ajaxSend",[y,e]),e.async&&e.timeout>0&&(t=setTimeout(function(){y.abort("timeout")},e.timeout));try{v=1,s.send(o,d)}catch(B){if(!(v<2))throw B;d(-1,B)}}return y}return y.abort(),!1},param:function(a,c){var d=[],e=function(a,b){b=K.isFunction(b)?b():b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};c===b&&(c=K.ajaxSettings.traditional);if(K.isArray(a)||a.jquery&&!K.isPlainObject(a))K.each(a,function(){e(this.name,this.value)});else for(var f in a)l(f,a[f],c,e);return d.join("&").replace(Qb,"+")}}),K.extend({active:0,lastModified:{},etag:{}});var kc=K.now(),lc=/(\=)\?(&|$)|\?\?/i;K.ajaxSetup({jsonp:"callback",jsonpCallback:function(){return K.expando+"_"+kc++}}),K.ajaxPrefilter("json jsonp",function(b,c,d){var e=b.contentType==="application/x-www-form-urlencoded"&&typeof b.data=="string";if(b.dataTypes[0]==="jsonp"||b.jsonp!==!1&&(lc.test(b.url)||e&&lc.test(b.data))){var f,g=b.jsonpCallback=K.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,h=a[g],i=b.url,j=b.data,k="$1"+g+"$2";return b.jsonp!==!1&&(i=i.replace(lc,k),b.url===i&&(e&&(j=j.replace(lc,k)),b.data===j&&(i+=(/\?/.test(i)?"&":"?")+b.jsonp+"="+g))),b.url=i,b.data=j,a[g]=function(a){f=[a]},d.always(function(){a[g]=h,f&&K.isFunction(h)&&a[g](f[0])}),b.converters["script json"]=function(){return f||K.error(g+" was not called"),f[0]},b.dataTypes[0]="json","script"}}),K.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){return K.globalEval(a),a}}}),K.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),K.ajaxTransport("script",function(a){if(a.crossDomain){var c,d=H.head||H.getElementsByTagName("head")[0]||H.documentElement;return{send:function(e,f){c=H.createElement("script"),c.async="async",a.scriptCharset&&(c.charset=a.scriptCharset),c.src=a.url,c.onload=c.onreadystatechange=function(a,e){if(e||!c.readyState||/loaded|complete/.test(c.readyState))c.onload=c.onreadystatechange=null,d&&c.parentNode&&d.removeChild(c),c=b,e||f(200,"success")},d.insertBefore(c,d.firstChild)},abort:function(){c&&c.onload(0,1)}}}});var mc=a.ActiveXObject?function(){for(var a in oc)oc[a](0,1)}:!1,nc=0,oc;K.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&i()||h()}:i,function(a){K.extend(K.support,{ajax:!!a,cors:!!a&&"withCredentials"in a})}(K.ajaxSettings.xhr()),K.support.ajax&&K.ajaxTransport(function(c){if(!c.crossDomain||K.support.cors){var d;return{send:function(e,f){var g=c.xhr(),h,i;c.username?g.open(c.type,c.url,c.async,c.username,c.password):g.open(c.type,c.url,c.async);if(c.xhrFields)for(i in c.xhrFields)g[i]=c.xhrFields[i];c.mimeType&&g.overrideMimeType&&g.overrideMimeType(c.mimeType),!c.crossDomain&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(i in e)g.setRequestHeader(i,e[i])}catch(j){}g.send(c.hasContent&&c.data||null),d=function(a,e){var i,j,k,l,m;try{if(d&&(e||g.readyState===4)){d=b,h&&(g.onreadystatechange=K.noop,mc&&delete oc[h]);if(e)g.readyState!==4&&g.abort();else{i=g.status,k=g.getAllResponseHeaders(),l={},m=g.responseXML,m&&m.documentElement&&(l.xml=m),l.text=g.responseText;try{j=g.statusText}catch(n){j=""}!i&&c.isLocal&&!c.crossDomain?i=l.text?200:404:i===1223&&(i=204)}}}catch(o){e||f(-1,o)}l&&f(i,j,l,k)},!c.async||g.readyState===4?d():(h=++nc,mc&&(oc||(oc={},K(a).unload(mc)),oc[h]=d),g.onreadystatechange=d)},abort:function(){d&&d(0,1)}}}});var pc={},qc,rc,sc=/^(?:toggle|show|hide)$/,tc=/^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,uc,vc=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]],wc;K.fn.extend({show:function(a,b,c){var f,g;if(a||a===0)return this.animate(e("show",3),a,b,c);for(var h=0,i=this.length;h<i;h++)f=this[h],f.style&&(g=f.style.display,!K._data(f,"olddisplay")&&g==="none"&&(g=f.style.display=""),g===""&&K.css(f,"display")==="none"&&K._data(f,"olddisplay",d(f.nodeName)));for(h=0;h<i;h++){f=this[h];if(f.style){g=f.style.display;if(g===""||g==="none")f.style.display=K._data(f,"olddisplay")||""}}return this},hide:function(a,b,c){if(a||a===0)return this.animate(e("hide",3),a,b,c);var d,f,g=0,h=this.length;for(;g<h;g++)d=this[g],d.style&&(f=K.css(d,"display"),f!=="none"&&!K._data(d,"olddisplay")&&K._data(d,"olddisplay",f));for(g=0;g<h;g++)this[g].style&&(this[g].style.display="none");return this},_toggle:K.fn.toggle,toggle:function(a,b,c){var d=typeof a=="boolean";return K.isFunction(a)&&K.isFunction(b)?this._toggle.apply(this,arguments):a==null||d?this.each(function(){var b=d?a:K(this).is(":hidden");K(this)[b?"show":"hide"]()}):this.animate(e("toggle",3),a,b,c),this},fadeTo:function(a,b,c,d){return this.filter(":hidden").css("opacity",0).show().end().animate({opacity:b},a,c,d)},animate:function(a,b,c,e){function f(){g.queue===!1&&K._mark(this);var b=K.extend({},g),c=this.nodeType===1,e=c&&K(this).is(":hidden"),f,h,i,j,k,l,m,n,o;b.animatedProperties={};for(i in a){f=K.camelCase(i),i!==f&&(a[f]=a[i],delete a[i]),h=a[f],K.isArray(h)?(b.animatedProperties[f]=h[1],h=a[f]=h[0]):b.animatedProperties[f]=b.specialEasing&&b.specialEasing[f]||b.easing||"swing";if(h==="hide"&&e||h==="show"&&!e)return b.complete.call(this);c&&(f==="height"||f==="width")&&(b.overflow=[this.style.overflow,this.style.overflowX,this.style.overflowY],K.css(this,"display")==="inline"&&K.css(this,"float")==="none"&&(!K.support.inlineBlockNeedsLayout||d(this.nodeName)==="inline"?this.style.display="inline-block":this.style.zoom=1))}b.overflow!=null&&(this.style.overflow="hidden");for(i in a)j=new K.fx(this,b,i),h=a[i],sc.test(h)?(o=K._data(this,"toggle"+i)||(h==="toggle"?e?"show":"hide":0),o?(K._data(this,"toggle"+i,o==="show"?"hide":"show"),j[o]()):j[h]()):(k=tc.exec(h),l=j.cur(),k?(m=parseFloat(k[2]),n=k[3]||(K.cssNumber[i]?"":"px"),n!=="px"&&(K.style(this,i,(m||1)+n),l=(m||1)/j.cur()*l,K.style(this,i,l+n)),k[1]&&(m=(k[1]==="-="?-1:1)*m+l),j.custom(l,m,n)):j.custom(l,h,""));return!0}var g=K.speed(b,c,e);return K.isEmptyObject(a)?this.each(g.complete,[!1]):(a=K.extend({},a),g.queue===!1?this.each(f):this.queue(g.queue,f))},stop:function(a,c,d){return typeof a!="string"&&(d=c,c=a,a=b),c&&a!==!1&&this.queue(a||"fx",[]),this.each(function(){function b(a,b,c){var e=b[c];K.removeData(a,c,!0),e.stop(d)}var c,e=!1,f=K.timers,g=K._data(this);d||K._unmark(!0,this);if(a==null)for(c in g)g[c]&&g[c].stop&&c.indexOf(".run")===c.length-4&&b(this,g,c);else g[c=a+".run"]&&g[c].stop&&b(this,g,c);for(c=f.length;c--;)f[c].elem===this&&(a==null||f[c].queue===a)&&(d?f[c](!0):f[c].saveState(),e=!0,f.splice(c,1));(!d||!e)&&K.dequeue(this,a)})}}),K.each({slideDown:e("show",1),slideUp:e("hide",1),slideToggle:e("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){K.fn[a]=function(a,c,d){return this.animate(b,a,c,d)}}),K.extend({speed:function(a,b,c){var d=a&&typeof a=="object"?K.extend({},a):{complete:c||!c&&b||K.isFunction(a)&&a,duration:a,easing:c&&b||b&&!K.isFunction(b)&&b};d.duration=K.fx.off?0:typeof d.duration=="number"?d.duration:d.duration in K.fx.speeds?K.fx.speeds[d.duration]:K.fx.speeds._default;if(d.queue==null||d.queue===!0)d.queue="fx";return d.old=d.complete,d.complete=function(a){K.isFunction(d.old)&&d.old.call(this),d.queue?K.dequeue(this,d.queue):a!==!1&&K._unmark(this)},d},easing:{linear:function(a,b,c,d){return c+d*a},swing:function(a,b,c,d){return(-Math.cos(a*Math.PI)/2+.5)*d+c}},timers:[],fx:function(a,b,c){this.options=b,this.elem=a,this.prop=c,b.orig=b.orig||{}}}),K.fx.prototype={update:function(){this.options.step&&this.options.step.call(this.elem,this.now,this),(K.fx.step[this.prop]||K.fx.step._default)(this)},cur:function(){if(this.elem[this.prop]==null||!!this.elem.style&&this.elem.style[this.prop]!=null){var a,b=K.css(this.elem,this.prop);return isNaN(a=parseFloat(b))?!b||b==="auto"?0:b:a}return this.elem[this.prop]},custom:function(a,c,d){function e(a){return f.step(a)}var f=this,h=K.fx;this.startTime=wc||g(),this.end=c,this.now=this.start=a,this.pos=this.state=0,this.unit=d||this.unit||(K.cssNumber[this.prop]?"":"px"),e.queue=this.options.queue,e.elem=this.elem,e.saveState=function(){f.options.hide&&K._data(f.elem,"fxshow"+f.prop)===b&&K._data(f.elem,"fxshow"+f.prop,f.start)},e()&&K.timers.push(e)&&!uc&&(uc=setInterval(h.tick,h.interval))},show:function(){var a=K._data(this.elem,"fxshow"+this.prop);this.options.orig[this.prop]=a||K.style(this.elem,this.prop),this.options.show=!0,a!==b?this.custom(this.cur(),a):this.custom(this.prop==="width"||this.prop==="height"?1:0,this.cur()),K(this.elem).show()},hide:function(){this.options.orig[this.prop]=K._data(this.elem,"fxshow"+this.prop)||K.style(this.elem,this.prop),this.options.hide=!0,this.custom(this.cur(),0)},step:function(a){var b,c,d,e=wc||g(),f=!0,h=this.elem,i=this.options;if(a||e>=i.duration+this.startTime){this.now=this.end,this.pos=this.state=1,this.update(),i.animatedProperties[this.prop]=!0;for(b in i.animatedProperties)i.animatedProperties[b]!==!0&&(f=!1);if(f){i.overflow!=null&&!K.support.shrinkWrapBlocks&&K.each(["","X","Y"],function(a,b){h.style["overflow"+b]=i.overflow[a]}),i.hide&&K(h).hide();if(i.hide||i.show)for(b in i.animatedProperties)K.style(h,b,i.orig[b]),K.removeData(h,"fxshow"+b,!0),K.removeData(h,"toggle"+b,!0);d=i.complete,d&&(i.complete=!1,d.call(h))}return!1}return i.duration==Infinity?this.now=e:(c=e-this.startTime,this.state=c/i.duration,this.pos=K.easing[i.animatedProperties[this.prop]](this.state,c,0,1,i.duration),this.now=this.start+(this.end-this.start)*this.pos),this.update(),!0}},K.extend(K.fx,{tick:function(){var a,b=K.timers,c=0;for(;c<b.length;c++)a=b[c],!a()&&b[c]===a&&b.splice(c--,1);b.length||K.fx.stop()},interval:13,stop:function(){clearInterval(uc),uc=null},speeds:{slow:600,fast:200,_default:400},step:{opacity:function(a){K.style(a.elem,"opacity",a.now)},_default:function(a){a.elem.style&&a.elem.style[a.prop]!=null?a.elem.style[a.prop]=a.now+a.unit:a.elem[a.prop]=a.now}}}),K.each(["width","height"],function(a,b){K.fx.step[b]=function(a){K.style(a.elem,b,Math.max(0,a.now)+a.unit)}}),K.expr&&K.expr.filters&&(K.expr.filters.animated=function(a){return K.grep(K.timers,function(b){return a===b.elem}).length});var xc=/^t(?:able|d|h)$/i,yc=/^(?:body|html)$/i;"getBoundingClientRect"in H.documentElement?K.fn.offset=function(a){var b=this[0],d;if(a)return this.each(function(b){K.offset.setOffset(this,a,b)});if(!b||!b.ownerDocument)return null;if(b===b.ownerDocument.body)return K.offset.bodyOffset(b);try{d=b.getBoundingClientRect()}catch(e){}var f=b.ownerDocument,g=f.documentElement;if(!d||!K.contains(g,b))return d?{top:d.top,left:d.left}:{top:0,left:0};var h=f.body,i=c(f),j=g.clientTop||h.clientTop||0,k=g.clientLeft||h.clientLeft||0,l=i.pageYOffset||K.support.boxModel&&g.scrollTop||h.scrollTop,m=i.pageXOffset||K.support.boxModel&&g.scrollLeft||h.scrollLeft,n=d.top+l-j,o=d.left+m-k;return{top:n,left:o}}:K.fn.offset=function(a){var b=this[0];if(a)return this.each(function(b){K.offset.setOffset(this,a,b)});if(!b||!b.ownerDocument)return null;if(b===b.ownerDocument.body)return K.offset.bodyOffset(b);var c,d=b.offsetParent,e=b,f=b.ownerDocument,g=f.documentElement,h=f.body,i=f.defaultView,j=i?i.getComputedStyle(b,null):b.currentStyle,k=b.offsetTop,l=b.offsetLeft;while((b=b.parentNode)&&b!==h&&b!==g){if(K.support.fixedPosition&&j.position==="fixed")break;c=i?i.getComputedStyle(b,null):b.currentStyle,k-=b.scrollTop,l-=b.scrollLeft,b===d&&(k+=b.offsetTop,l+=b.offsetLeft,K.support.doesNotAddBorder&&(!K.support.doesAddBorderForTableAndCells||!xc.test(b.nodeName))&&(k+=parseFloat(c.borderTopWidth)||0,l+=parseFloat(c.borderLeftWidth)||0),e=d,d=b.offsetParent),K.support.subtractsBorderForOverflowNotVisible&&c.overflow!=="visible"&&(k+=parseFloat(c.borderTopWidth)||0,l+=parseFloat(c.borderLeftWidth)||0),j=c}if(j.position==="relative"||j.position==="static")k+=h.offsetTop,l+=h.offsetLeft;return K.support.fixedPosition&&j.position==="fixed"&&(k+=Math.max(g.scrollTop,h.scrollTop),l+=Math.max(g.scrollLeft,h.scrollLeft)),{top:k,left:l}},K.offset={bodyOffset:function(a){var b=a.offsetTop,c=a.offsetLeft;return K.support.doesNotIncludeMarginInBodyOffset&&(b+=parseFloat(K.css(a,"marginTop"))||0,c+=parseFloat(K.css(a,"marginLeft"))||0),{top:b,left:c}},setOffset:function(a,b,c){var d=K.css(a,"position");d==="static"&&(a.style.position="relative");var e=K(a),f=e.offset(),g=K.css(a,"top"),h=K.css(a,"left"),i=(d==="absolute"||d==="fixed")&&K.inArray("auto",[g,h])>-1,j={},k={},l,m;i?(k=e.position(),l=k.top,m=k.left):(l=parseFloat(g)||0,m=parseFloat(h)||0),K.isFunction(b)&&(b=b.call(a,c,f)),b.top!=null&&(j.top=b.top-f.top+l),b.left!=null&&(j.left=b.left-f.left+m),"using"in b?b.using.call(a,j):e.css(j)}},K.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),c=this.offset(),d=yc.test(b[0].nodeName)?{top:0,left:0}:b.offset();return c.top-=parseFloat(K.css(a,"marginTop"))||0,c.left-=parseFloat(K.css(a,"marginLeft"))||0,d.top+=parseFloat(K.css(b[0],"borderTopWidth"))||0,d.left+=parseFloat(K.css(b[0],"borderLeftWidth"))||0,{top:c.top-d.top,left:c.left-d.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||H.body;while(a&&!yc.test(a.nodeName)&&K.css(a,"position")==="static")a=a.offsetParent;return a})}}),K.each(["Left","Top"],function(a,d){var e="scroll"+d;K.fn[e]=function(d){var f,g;return d===b?(f=this[0],f?(g=c(f),g?"pageXOffset"in g?g[a?"pageYOffset":"pageXOffset"]:K.support.boxModel&&g.document.documentElement[e]||g.document.body[e]:f[e]):null):this.each(function(){g=c(this),g?g.scrollTo(a?K(g).scrollLeft():d,a?d:K(g).scrollTop()):this[e]=d})}}),K.each(["Height","Width"],function(a,c){var d=c.toLowerCase();K.fn["inner"+c]=function(){var a=this[0];return a?a.style?parseFloat(K.css(a,d,"padding")):this[d]():null},K.fn["outer"+c]=function(a){var b=this[0];return b?b.style?parseFloat(K.css(b,d,a?"margin":"border")):this[d]():null},K.fn[d]=function(a){var e=this[0];if(!e)return a==null?null:this;if(K.isFunction(a))return this.each(function(b){var c=K(this);c[d](a.call(this,b,c[d]()))});if(K.isWindow(e)){var f=e.document.documentElement["client"+c],g=e.document.body;return e.document.compatMode==="CSS1Compat"&&f||g&&g["client"+c]||f}if(e.nodeType===9)return Math.max(e.documentElement["client"+c],e.body["scroll"+c],e.documentElement["scroll"+c],e.body["offset"+c],e.documentElement["offset"+c]);if(a===b){var h=K.css(e,d),i=parseFloat(h);return K.isNumeric(i)?i:h}return this.css(d,typeof a=="string"?a:a+"px")}}),a.jQuery=a.$=K,typeof define=="function"&&define.amd&&define.amd.jQuery&&define("jquery",[],function(){return K})})(window),function(){var a=this,b=a._,c={},d=Array.prototype,e=Object.prototype,f=Function.prototype,g=d.push,h=d.slice,i=d.concat,j=d.unshift,k=e.toString,l=e.hasOwnProperty,m=d.forEach,n=d.map,o=d.reduce,p=d.reduceRight,q=d.filter,r=d.every,s=d.some,t=d.indexOf,u=d.lastIndexOf,v=Array.isArray,w=Object.keys,x=f.bind,y=function(a){if(a instanceof y)return a;if(!(this instanceof y))return new y(a);this._wrapped=a};typeof exports!="undefined"?(typeof module!="undefined"&&module.exports&&(exports=module.exports=y),exports._=y):a._=y,y.VERSION="1.4.2";var z=y.each=y.forEach=function(a,b,d){if(a==null)return;if(m&&a.forEach===m)a.forEach(b,d);else if(a.length===+a.length){for(var e=0,f=a.length;e<f;e++)if(b.call(d,a[e],e,a)===c)return}else for(var g in a)if(y.has(a,g)&&b.call(d,a[g],g,a)===c)return};y.map=y.collect=function(a,b,c){var d=[];return a==null?d:n&&a.map===n?a.map(b,c):(z(a,function(a,e,f){d[d.length]=b.call(c,a,e,f)}),d)},y.reduce=y.foldl=y.inject=function(a,b,c,d){var e=arguments.length>2;a==null&&(a=[]);if(o&&a.reduce===o)return d&&(b=y.bind(b,d)),e?a.reduce(b,c):a.reduce(b);z(a,function(a,f,g){e?c=b.call(d,c,a,f,g):(c=a,e=!0)});if(!e)throw new TypeError("Reduce of empty array with no initial value");return c},y.reduceRight=y.foldr=function(a,b,c,d){var e=arguments.length>2;a==null&&(a=[]);if(p&&a.reduceRight===p)return d&&(b=y.bind(b,d)),arguments.length>2?a.reduceRight(b,c):a.reduceRight(b);var f=a.length;if(f!==+f){var g=y.keys(a);f=g.length}z(a,function(h,i,j){i=g?g[--f]:--f,e?c=b.call(d,c,a[i],i,j):(c=a[i],e=!0)});if(!e)throw new TypeError("Reduce of empty array with no initial value");return c},y.find=y.detect=function(a,b,c){var d;return A(a,function(a,e,f){if(b.call(c,a,e,f))return d=a,!0}),d},y.filter=y.select=function(a,b,c){var d=[];return a==null?d:q&&a.filter===q?a.filter(b,c):(z(a,function(a,e,f){b.call(c,a,e,f)&&(d[d.length]=a)}),d)},y.reject=function(a,b,c){var d=[];return a==null?d:(z(a,function(a,e,f){b.call(c,a,e,f)||(d[d.length]=a)}),d)},y.every=y.all=function(a,b,d){b||(b=y.identity);var e=!0;return a==null?e:r&&a.every===r?a.every(b,d):(z(a,function(a,f,g){if(!(e=e&&b.call(d,a,f,g)))return c}),!!e)};var A=y.some=y.any=function(a,b,d){b||(b=y.identity);var e=!1;return a==null?e:s&&a.some===s?a.some(b,d):(z(a,function(a,f,g){if(e||(e=b.call(d,a,f,g)))return c}),!!e)};y.contains=y.include=function(a,b){var c=!1;return a==null?c:t&&a.indexOf===t?a.indexOf(b)!=-1:(c=A(a,function(a){return a===b}),c)},y.invoke=function(a,b){var c=h.call(arguments,2);return y.map(a,function(a){return(y.isFunction(b)?b:a[b]).apply(a,c)})},y.pluck=function(a,b){return y.map(a,function(a){return a[b]})},y.where=function(a,b){return y.isEmpty(b)?[]:y.filter(a,function(a){for(var c in b)if(b[c]!==a[c])return!1;return!0})},y.max=function(a,b,c){if(!b&&y.isArray(a)&&a[0]===+a[0]&&a.length<65535)return Math.max.apply(Math,a);if(!b&&y.isEmpty(a))return-Infinity;var d={computed:-Infinity};return z(a,function(a,e,f){var g=b?b.call(c,a,e,f):a;g>=d.computed&&(d={value:a,computed:g})}),d.value},y.min=function(a,b,c){if(!b&&y.isArray(a)&&a[0]===+a[0]&&a.length<65535)return Math.min.apply(Math,a);if(!b&&y.isEmpty(a))return Infinity;var d={computed:Infinity};return z(a,function(a,e,f){var g=b?b.call(c,a,e,f):a;g<d.computed&&(d={value:a,computed:g})}),d.value},y.shuffle=function(a){var b,c=0,d=[];return z(a,function(a){b=y.random(c++),d[c-1]=d[b],d[b]=a}),d};var B=function(a){return y.isFunction(a)?a:function(b){return b[a]}};y.sortBy=function(a,b,c){var d=B(b);return y.pluck(y.map(a,function(a,b,e){return{value:a,index:b,criteria:d.call(c,a,b,e)}}).sort(function(a,b){var c=a.criteria,d=b.criteria;if(c!==d){if(c>d||c===void 0)return 1;if(c<d||d===void 0)return-1}return a.index<b.index?-1:1}),"value")};var C=function(a,b,c,d){var e={},f=B(b);return z(a,function(b,g){var h=f.call(c,b,g,a);d(e,h,b)}),e};y.groupBy=function(a,b,c){return C(a,b,c,function(a,b,c){(y.has(a,b)?a[b]:a[b]=[]).push(c)})},y.countBy=function(a,b,c){return C(a,b,c,function(a,b,c){y.has(a,b)||(a[b]=0),a[b]++})},y.sortedIndex=function(a,b,c,d){c=c==null?y.identity:B(c);var e=c.call(d,b),f=0,g=a.length;while(f<g){var h=f+g>>>1;c.call(d,a[h])<e?f=h+1:g=h}return f},y.toArray=function(a){return a?a.length===+a.length?h.call(a):y.values(a):[]},y.size=function(a){return a.length===+a.length?a.length:y.keys(a).length},y.first=y.head=y.take=function(a,b,c){return b!=null&&!c?h.call(a,0,b):a[0]},y.initial=function(a,b,c){return h.call(a,0,a.length-(b==null||c?1:b))},y.last=function(a,b,c){return b!=null&&!c?h.call(a,Math.max(a.length-b,0)):a[a.length-1]},y.rest=y.tail=y.drop=function(a,b,c){return h.call(a,b==null||c?1:b)},y.compact=function(a){return y.filter(a,function(a){return!!a})};var D=function(a,b,c){return z(
4
+ a,function(a){y.isArray(a)?b?g.apply(c,a):D(a,b,c):c.push(a)}),c};y.flatten=function(a,b){return D(a,b,[])},y.without=function(a){return y.difference(a,h.call(arguments,1))},y.uniq=y.unique=function(a,b,c,d){var e=c?y.map(a,c,d):a,f=[],g=[];return z(e,function(c,d){if(b?!d||g[g.length-1]!==c:!y.contains(g,c))g.push(c),f.push(a[d])}),f},y.union=function(){return y.uniq(i.apply(d,arguments))},y.intersection=function(a){var b=h.call(arguments,1);return y.filter(y.uniq(a),function(a){return y.every(b,function(b){return y.indexOf(b,a)>=0})})},y.difference=function(a){var b=i.apply(d,h.call(arguments,1));return y.filter(a,function(a){return!y.contains(b,a)})},y.zip=function(){var a=h.call(arguments),b=y.max(y.pluck(a,"length")),c=new Array(b);for(var d=0;d<b;d++)c[d]=y.pluck(a,""+d);return c},y.object=function(a,b){var c={};for(var d=0,e=a.length;d<e;d++)b?c[a[d]]=b[d]:c[a[d][0]]=a[d][1];return c},y.indexOf=function(a,b,c){if(a==null)return-1;var d=0,e=a.length;if(c){if(typeof c!="number")return d=y.sortedIndex(a,b),a[d]===b?d:-1;d=c<0?Math.max(0,e+c):c}if(t&&a.indexOf===t)return a.indexOf(b,c);for(;d<e;d++)if(a[d]===b)return d;return-1},y.lastIndexOf=function(a,b,c){if(a==null)return-1;var d=c!=null;if(u&&a.lastIndexOf===u)return d?a.lastIndexOf(b,c):a.lastIndexOf(b);var e=d?c:a.length;while(e--)if(a[e]===b)return e;return-1},y.range=function(a,b,c){arguments.length<=1&&(b=a||0,a=0),c=arguments[2]||1;var d=Math.max(Math.ceil((b-a)/c),0),e=0,f=new Array(d);while(e<d)f[e++]=a,a+=c;return f};var E=function(){};y.bind=function(a,b){var c,d;if(a.bind===x&&x)return x.apply(a,h.call(arguments,1));if(!y.isFunction(a))throw new TypeError;return d=h.call(arguments,2),c=function(){if(this instanceof c){E.prototype=a.prototype;var e=new E,f=a.apply(e,d.concat(h.call(arguments)));return Object(f)===f?f:e}return a.apply(b,d.concat(h.call(arguments)))}},y.bindAll=function(a){var b=h.call(arguments,1);return b.length==0&&(b=y.functions(a)),z(b,function(b){a[b]=y.bind(a[b],a)}),a},y.memoize=function(a,b){var c={};return b||(b=y.identity),function(){var d=b.apply(this,arguments);return y.has(c,d)?c[d]:c[d]=a.apply(this,arguments)}},y.delay=function(a,b){var c=h.call(arguments,2);return setTimeout(function(){return a.apply(null,c)},b)},y.defer=function(a){return y.delay.apply(y,[a,1].concat(h.call(arguments,1)))},y.throttle=function(a,b){var c,d,e,f,g,h,i=y.debounce(function(){g=f=!1},b);return function(){c=this,d=arguments;var j=function(){e=null,g&&(h=a.apply(c,d)),i()};return e||(e=setTimeout(j,b)),f?g=!0:(f=!0,h=a.apply(c,d)),i(),h}},y.debounce=function(a,b,c){var d,e;return function(){var f=this,g=arguments,h=function(){d=null,c||(e=a.apply(f,g))},i=c&&!d;return clearTimeout(d),d=setTimeout(h,b),i&&(e=a.apply(f,g)),e}},y.once=function(a){var b=!1,c;return function(){return b?c:(b=!0,c=a.apply(this,arguments),a=null,c)}},y.wrap=function(a,b){return function(){var c=[a];return g.apply(c,arguments),b.apply(this,c)}},y.compose=function(){var a=arguments;return function(){var b=arguments;for(var c=a.length-1;c>=0;c--)b=[a[c].apply(this,b)];return b[0]}},y.after=function(a,b){return a<=0?b():function(){if(--a<1)return b.apply(this,arguments)}},y.keys=w||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var b=[];for(var c in a)y.has(a,c)&&(b[b.length]=c);return b},y.values=function(a){var b=[];for(var c in a)y.has(a,c)&&b.push(a[c]);return b},y.pairs=function(a){var b=[];for(var c in a)y.has(a,c)&&b.push([c,a[c]]);return b},y.invert=function(a){var b={};for(var c in a)y.has(a,c)&&(b[a[c]]=c);return b},y.functions=y.methods=function(a){var b=[];for(var c in a)y.isFunction(a[c])&&b.push(c);return b.sort()},y.extend=function(a){return z(h.call(arguments,1),function(b){for(var c in b)a[c]=b[c]}),a},y.pick=function(a){var b={},c=i.apply(d,h.call(arguments,1));return z(c,function(c){c in a&&(b[c]=a[c])}),b},y.omit=function(a){var b={},c=i.apply(d,h.call(arguments,1));for(var e in a)y.contains(c,e)||(b[e]=a[e]);return b},y.defaults=function(a){return z(h.call(arguments,1),function(b){for(var c in b)a[c]==null&&(a[c]=b[c])}),a},y.clone=function(a){return y.isObject(a)?y.isArray(a)?a.slice():y.extend({},a):a},y.tap=function(a,b){return b(a),a};var F=function(a,b,c,d){if(a===b)return a!==0||1/a==1/b;if(a==null||b==null)return a===b;a instanceof y&&(a=a._wrapped),b instanceof y&&(b=b._wrapped);var e=k.call(a);if(e!=k.call(b))return!1;switch(e){case"[object String]":return a==String(b);case"[object Number]":return a!=+a?b!=+b:a==0?1/a==1/b:a==+b;case"[object Date]":case"[object Boolean]":return+a==+b;case"[object RegExp]":return a.source==b.source&&a.global==b.global&&a.multiline==b.multiline&&a.ignoreCase==b.ignoreCase}if(typeof a!="object"||typeof b!="object")return!1;var f=c.length;while(f--)if(c[f]==a)return d[f]==b;c.push(a),d.push(b);var g=0,h=!0;if(e=="[object Array]"){g=a.length,h=g==b.length;if(h)while(g--)if(!(h=F(a[g],b[g],c,d)))break}else{var i=a.constructor,j=b.constructor;if(i!==j&&!(y.isFunction(i)&&i instanceof i&&y.isFunction(j)&&j instanceof j))return!1;for(var l in a)if(y.has(a,l)){g++;if(!(h=y.has(b,l)&&F(a[l],b[l],c,d)))break}if(h){for(l in b)if(y.has(b,l)&&!(g--))break;h=!g}}return c.pop(),d.pop(),h};y.isEqual=function(a,b){return F(a,b,[],[])},y.isEmpty=function(a){if(a==null)return!0;if(y.isArray(a)||y.isString(a))return a.length===0;for(var b in a)if(y.has(a,b))return!1;return!0},y.isElement=function(a){return!!a&&a.nodeType===1},y.isArray=v||function(a){return k.call(a)=="[object Array]"},y.isObject=function(a){return a===Object(a)},z(["Arguments","Function","String","Number","Date","RegExp"],function(a){y["is"+a]=function(b){return k.call(b)=="[object "+a+"]"}}),y.isArguments(arguments)||(y.isArguments=function(a){return!!a&&!!y.has(a,"callee")}),typeof /./!="function"&&(y.isFunction=function(a){return typeof a=="function"}),y.isFinite=function(a){return y.isNumber(a)&&isFinite(a)},y.isNaN=function(a){return y.isNumber(a)&&a!=+a},y.isBoolean=function(a){return a===!0||a===!1||k.call(a)=="[object Boolean]"},y.isNull=function(a){return a===null},y.isUndefined=function(a){return a===void 0},y.has=function(a,b){return l.call(a,b)},y.noConflict=function(){return a._=b,this},y.identity=function(a){return a},y.times=function(a,b,c){for(var d=0;d<a;d++)b.call(c,d)},y.random=function(a,b){return b==null&&(b=a,a=0),a+(0|Math.random()*(b-a+1))};var G={escape:{"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","/":"&#x2F;"}};G.unescape=y.invert(G.escape);var H={escape:new RegExp("["+y.keys(G.escape).join("")+"]","g"),unescape:new RegExp("("+y.keys(G.unescape).join("|")+")","g")};y.each(["escape","unescape"],function(a){y[a]=function(b){return b==null?"":(""+b).replace(H[a],function(b){return G[a][b]})}}),y.result=function(a,b){if(a==null)return null;var c=a[b];return y.isFunction(c)?c.call(a):c},y.mixin=function(a){z(y.functions(a),function(b){var c=y[b]=a[b];y.prototype[b]=function(){var a=[this._wrapped];return g.apply(a,arguments),M.call(this,c.apply(y,a))}})};var I=0;y.uniqueId=function(a){var b=I++;return a?a+b:b},y.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var J=/(.)^/,K={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},L=/\\|'|\r|\n|\t|\u2028|\u2029/g;y.template=function(a,b,c){c=y.defaults({},c,y.templateSettings);var d=new RegExp([(c.escape||J).source,(c.interpolate||J).source,(c.evaluate||J).source].join("|")+"|$","g"),e=0,f="__p+='";a.replace(d,function(b,c,d,g,h){f+=a.slice(e,h).replace(L,function(a){return"\\"+K[a]}),f+=c?"'+\n((__t=("+c+"))==null?'':_.escape(__t))+\n'":d?"'+\n((__t=("+d+"))==null?'':__t)+\n'":g?"';\n"+g+"\n__p+='":"",e=h+b.length}),f+="';\n",c.variable||(f="with(obj||{}){\n"+f+"}\n"),f="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+f+"return __p;\n";try{var g=new Function(c.variable||"obj","_",f)}catch(h){throw h.source=f,h}if(b)return g(b,y);var i=function(a){return g.call(this,a,y)};return i.source="function("+(c.variable||"obj")+"){\n"+f+"}",i},y.chain=function(a){return y(a).chain()};var M=function(a){return this._chain?y(a).chain():a};y.mixin(y),z(["pop","push","reverse","shift","sort","splice","unshift"],function(a){var b=d[a];y.prototype[a]=function(){var c=this._wrapped;return b.apply(c,arguments),(a=="shift"||a=="splice")&&c.length===0&&delete c[0],M.call(this,c)}}),z(["concat","join","slice"],function(a){var b=d[a];y.prototype[a]=function(){return M.call(this,b.apply(this._wrapped,arguments))}}),y.extend(y.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}.call(this),function(a){var b=String.prototype.trim,c=function(a,b){for(var c=[];b>0;c[--b]=a);return c.join("")},d=function(a){return function(){for(var b=Array.prototype.slice.call(arguments),c=0;c<b.length;c++)b[c]=b[c]==null?"":""+b[c];return a.apply(null,b)}},e=function(){function a(a){return Object.prototype.toString.call(a).slice(8,-1).toLowerCase()}var b=function(){return b.cache.hasOwnProperty(arguments[0])||(b.cache[arguments[0]]=b.parse(arguments[0])),b.format.call(null,b.cache[arguments[0]],arguments)};return b.format=function(b,d){var f=1,g=b.length,h="",i=[],j,k,n,o;for(j=0;j<g;j++)if(h=a(b[j]),h==="string")i.push(b[j]);else if(h==="array"){n=b[j];if(n[2]){h=d[f];for(k=0;k<n[2].length;k++){if(!h.hasOwnProperty(n[2][k]))throw e('[_.sprintf] property "%s" does not exist',n[2][k]);h=h[n[2][k]]}}else h=n[1]?d[n[1]]:d[f++];if(/[^s]/.test(n[8])&&a(h)!="number")throw e("[_.sprintf] expecting number but found %s",a(h));switch(n[8]){case"b":h=h.toString(2);break;case"c":h=String.fromCharCode(h);break;case"d":h=parseInt(h,10);break;case"e":h=n[7]?h.toExponential(n[7]):h.toExponential();break;case"f":h=n[7]?parseFloat(h).toFixed(n[7]):parseFloat(h);break;case"o":h=h.toString(8);break;case"s":h=(h=String(h))&&n[7]?h.substring(0,n[7]):h;break;case"u":h=Math.abs(h);break;case"x":h=h.toString(16);break;case"X":h=h.toString(16).toUpperCase()}h=/[def]/.test(n[8])&&n[3]&&h>=0?"+"+h:h,k=n[4]?n[4]=="0"?"0":n[4].charAt(1):" ",o=n[6]-String(h).length,k=n[6]?c(k,o):"",i.push(n[5]?h+k:k+h)}return i.join("")},b.cache={},b.parse=function(a){for(var b=[],c=[],d=0;a;){if((b=/^[^\x25]+/.exec(a))!==null)c.push(b[0]);else if((b=/^\x25{2}/.exec(a))!==null)c.push("%");else{if((b=/^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(a))===null)throw"[_.sprintf] huh?";if(b[2]){d|=1;var e=[],f=b[2],g=[];if((g=/^([a-z_][a-z_\d]*)/i.exec(f))===null)throw"[_.sprintf] huh?";for(e.push(g[1]);(f=f.substring(g[0].length))!=="";)if((g=/^\.([a-z_][a-z_\d]*)/i.exec(f))!==null)e.push(g[1]);else{if((g=/^\[(\d+)\]/.exec(f))===null)throw"[_.sprintf] huh?";e.push(g[1])}b[2]=e}else d|=2;if(d===3)throw"[_.sprintf] mixing positional and named placeholders is not (yet) supported";c.push(b)}a=a.substring(b[0].length)}return c},b}(),f={VERSION:"1.2.0",isBlank:d(function(a){return/^\s*$/.test(a)}),stripTags:d(function(a){return a.replace(/<\/?[^>]+>/ig,"")}),capitalize:d(function(a){return a.charAt(0).toUpperCase()+a.substring(1).toLowerCase()}),chop:d(function(a,b){for(var b=b*1||0||a.length,c=[],d=0;d<a.length;)c.push(a.slice(d,d+b)),d+=b;return c}),clean:d(function(a){return f.strip(a.replace(/\s+/g," "))}),count:d(function(a,b){for(var c=0,d,e=0;e<a.length;)d=a.indexOf(b,e),d>=0&&c++,e=e+(d>=0?d:0)+b.length;return c}),chars:d(function(a){return a.split("")}),escapeHTML:d(function(a){return a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}),unescapeHTML:d(function(a){return a.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&apos;/g,"'").replace(/&amp;/g,"&")}),escapeRegExp:d(function(a){return a.replace(/([-.*+?^${}()|[\]\/\\])/g,"\\$1")}),insert:d(function(a,b,c){return a=a.split(""),a.splice(b*1||0,0,c),a.join("")}),include:d(function(a,b){return a.indexOf(b)!==-1}),join:d(function(a){var b=Array.prototype.slice.call(arguments);return b.join(b.shift())}),lines:d(function(a){return a.split("\n")}),reverse:d(function(a){return Array.prototype.reverse.apply(String(a).split("")).join("")}),splice:d(function(a,b,c,d){return a=a.split(""),a.splice(b*1||0,c*1||0,d),a.join("")}),startsWith:d(function(a,b){return a.length>=b.length&&a.substring(0,b.length)===b}),endsWith:d(function(a,b){return a.length>=b.length&&a.substring(a.length-b.length)===b}),succ:d(function(a){var b=a.split("");return b.splice(a.length-1,1,String.fromCharCode(a.charCodeAt(a.length-1)+1)),b.join("")}),titleize:d(function(a){for(var a=a.split(" "),b,c=0;c<a.length;c++)b=a[c].split(""),typeof b[0]!="undefined"&&(b[0]=b[0].toUpperCase()),c+1===a.length?a[c]=b.join(""):a[c]=b.join("")+" ";return a.join("")}),camelize:d(function(a){return f.trim(a).replace(/(\-|_|\s)+(.)?/g,function(a,b,c){return c?c.toUpperCase():""})}),underscored:function(a){return f.trim(a).replace(/([a-z\d])([A-Z]+)/g,"$1_$2").replace(/\-|\s+/g,"_").toLowerCase()},dasherize:function(a){return f.trim(a).replace(/([a-z\d])([A-Z]+)/g,"$1-$2").replace(/^([A-Z]+)/,"-$1").replace(/\_|\s+/g,"-").toLowerCase()},humanize:function(a){return f.capitalize(this.underscored(a).replace(/_id$/,"").replace(/_/g," "))},trim:d(function(a,c){return!c&&b?b.call(a):(c=c?f.escapeRegExp(c):"\\s",a.replace(RegExp("^["+c+"]+|["+c+"]+$","g"),""))}),ltrim:d(function(a,b){return b=b?f.escapeRegExp(b):"\\s",a.replace(RegExp("^["+b+"]+","g"),"")}),rtrim:d(function(a,b){return b=b?f.escapeRegExp(b):"\\s",a.replace(RegExp("["+b+"]+$","g"),"")}),truncate:d(function(a,b,c){return b=b*1||0,a.length>b?a.slice(0,b)+(c||"..."):a}),prune:d(function(a,b,c){var c=c||"...",b=b*1||0,d="",d=a.substring(b-1,b+1).search(/^\w\w$/)===0?f.rtrim(a.slice(0,b).replace(/([\W][\w]*)$/,"")):f.rtrim(a.slice(0,b)),d=d.replace(/\W+$/,"");return d.length+c.length>a.length?a:d+c}),words:function(a,b){return String(a).split(b||" ")},pad:d(function(a,b,d,e){var f="",f=0,b=b*1||0;d?d.length>1&&(d=d.charAt(0)):d=" ";switch(e){case"right":f=b-a.length,f=c(d,f),a+=f;break;case"both":f=b-a.length,f={left:c(d,Math.ceil(f/2)),right:c(d,Math.floor(f/2))},a=f.left+a+f.right;break;default:f=b-a.length,f=c(d,f),a=f+a}return a}),lpad:function(a,b,c){return f.pad(a,b,c)},rpad:function(a,b,c){return f.pad(a,b,c,"right")},lrpad:function(a,b,c){return f.pad(a,b,c,"both")},sprintf:e,vsprintf:function(a,b){return b.unshift(a),e.apply(null,b)},toNumber:function(a,b){var c;return c=(a*1||0).toFixed(b*1||0)*1||0,c!==0||a==="0"||a===0?c:Number.NaN},strRight:d(function(a,b){var c=b?a.indexOf(b):-1;return c!=-1?a.slice(c+b.length,a.length):a}),strRightBack:d(function(a,b){var c=b?a.lastIndexOf(b):-1;return c!=-1?a.slice(c+b.length,a.length):a}),strLeft:d(function(a,b){var c=b?a.indexOf(b):-1;return c!=-1?a.slice(0,c):a}),strLeftBack:d(function(a,b){var c=a.lastIndexOf(b);return c!=-1?a.slice(0,c):a}),exports:function(){var a={},b;for(b in this)this.hasOwnProperty(b)&&b!="include"&&b!="contains"&&b!="reverse"&&(a[b]=this[b]);return a}};f.strip=f.trim,f.lstrip=f.ltrim,f.rstrip=f.rtrim,f.center=f.lrpad,f.ljust=f.lpad,f.rjust=f.rpad,f.contains=f.include,typeof exports!="undefined"?(typeof module!="undefined"&&module.exports&&(module.exports=f),exports._s=f):typeof a._!="undefined"?(a._.string=f,a._.str=a._.string):a._={string:f,str:f}}(this||window),function(){var a=this,b=a.Backbone,c=Array.prototype.slice,d=Array.prototype.splice,e;e="undefined"!=typeof exports?exports:a.Backbone={},e.VERSION="0.9.1";var f=a._;!f&&"undefined"!=typeof require&&(f=require("underscore"));var g=a.jQuery||a.Zepto||a.ender;e.setDomLibrary=function(a){g=a},e.noConflict=function(){return a.Backbone=b,this},e.emulateHTTP=!1,e.emulateJSON=!1,e.Events={on:function(a,b,c){for(var d,a=a.split(/\s+/),e=this._callbacks||(this._callbacks={});d=a.shift();){d=e[d]||(e[d]={});var f=d.tail||(d.tail=d.next={});f.callback=b,f.context=c,d.tail=f.next={}}return this},off:function(a,b,c){var d,e,f;if(a){if(e=this._callbacks)for(a=a.split(/\s+/);d=a.shift();)if(f=e[d],delete e[d],b&&f)for(;(f=f.next)&&f.next;)(f.callback!==b||!!c&&f.context!==c)&&this.on(d,f.callback,f.context)}else delete this._callbacks;return this},trigger:function(a){var b,d,e,f;if(!(e=this._callbacks))return this;f=e.all;for((a=a.split(/\s+/)).push(null);b=a.shift();)f&&a.push({next:f.next,tail:f.tail,event:b}),(d=e[b])&&a.push({next:d.next,tail:d.tail});for(f=c.call(arguments,1);d=a.pop();){b=d.tail;for(e=d.event?[d.event].concat(f):f;(d=d.next)!==b;)d.callback.apply(d.context||this,e)}return this}},e.Events.bind=e.Events.on,e.Events.unbind=e.Events.off,e.Model=function(a,b){var c;a||(a={}),b&&b.parse&&(a=this.parse(a));if(c=s(this,"defaults"))a=f.extend({},c,a);b&&b.collection&&(this.collection=b.collection),this.attributes={},this._escapedAttributes={},this.cid=f.uniqueId("c");if(!this.set(a,{silent:!0}))throw Error("Can't create an invalid model");delete this._changed,this._previousAttributes=f.clone(this.attributes),this.initialize.apply(this,arguments)},f.extend(e.Model.prototype,e.Events,{idAttribute:"id",initialize:function(){},toJSON:function(){return f.clone(this.attributes)},get:function(a){return this.attributes[a]},escape:function(a){var b;return(b=this._escapedAttributes[a])?b:(b=this.attributes[a],this._escapedAttributes[a]=f.escape(null==b?"":""+b))},has:function(a){return null!=this.attributes[a]},set:function(a,b,c){var d,g;f.isObject(a)||null==a?(d=a,c=b):(d={},d[a]=b),c||(c={});if(!d)return this;d instanceof e.Model&&(d=d.attributes);if(c.unset)for(g in d)d[g]=void 0;if(!this._validate(d,c))return!1;this.idAttribute in d&&(this.id=d[this.idAttribute]);var b=this.attributes,h=this._escapedAttributes,i=this._previousAttributes||{},j=this._setting;this._changed||(this._changed={}),this._setting=!0;for(g in d)if(a=d[g],f.isEqual(b[g],a)||delete h[g],c.unset?delete b[g]:b[g]=a,this._changing&&!f.isEqual(this._changed[g],a)&&(this.trigger("change:"+g,this,a,c),this._moreChanges=!0),delete this._changed[g],!f.isEqual(i[g],a)||f.has(b,g)!=f.has(i,g))this._changed[g]=a;return j||(!c.silent&&this.hasChanged()&&this.change(c),this._setting=!1),this},unset:function(a,b){return(b||(b={})).unset=!0,this.set(a,null,b)},clear:function(a){return(a||(a={})).unset=!0,this.set(f.clone(this.attributes),a)},fetch:function(a){var a=a?f.clone(a):{},b=this,c=a.success;return a.success=function(d,e,f){if(!b.set(b.parse(d,f),a))return!1;c&&c(b,d)},a.error=e.wrapError(a.error,b,a),(this.sync||e.sync).call(this,"read",this,a)},save:function(a,b,c){var d,g;f.isObject(a)||null==a?(d=a,c=b):(d={},d[a]=b),c=c?f.clone(c):{},c.wait&&(g=f.clone(this.attributes)),a=f.extend({},c,{silent:!0});if(d&&!this.set(d,c.wait?a:c))return!1;var h=this,i=c.success;return c.success=function(a,b,e){b=h.parse(a,e),c.wait&&(b=f.extend(d||{},b));if(!h.set(b,c))return!1;i?i(h,a):h.trigger("sync",h,a,c)},c.error=e.wrapError(c.error,h,c),b=this.isNew()?"create":"update",b=(this.sync||e.sync).call(this,b,this,c),c.wait&&this.set(g,a),b},destroy:function(a){var a=a?f.clone(a):{},b=this,c=a.success,d=function(){b.trigger("destroy",b,b.collection,a)};if(this.isNew())return d();a.success=function(e){a.wait&&d(),c?c(b,e):b.trigger("sync",b,e,a)},a.error=e.wrapError(a.error,b,a);var g=(this.sync||e.sync).call(this,"delete",this,a);return a.wait||d(),g},url:function(){var a=s(this.collection,"url")||s(this,"urlRoot")||t();return this.isNew()?a:a+("/"==a.charAt(a.length-1)?"":"/")+encodeURIComponent(this.id)},parse:function(a){return a},clone:function(){return new this.constructor(this.attributes)},isNew:function(){return null==this.id},change:function(a){if(this._changing||!this.hasChanged())return this;this._moreChanges=this._changing=!0;for(var b in this._changed)this.trigger("change:"+b,this,this._changed[b],a);for(;this._moreChanges;)this._moreChanges=!1,this.trigger("change",this,a);return this._previousAttributes=f.clone(this.attributes),delete this._changed,this._changing=!1,this},hasChanged:function(a){return arguments.length?this._changed&&f.has(this._changed,a):!f.isEmpty(this._changed)},changedAttributes:function(a){if(!a)return this.hasChanged()?f.clone(this._changed):!1;var b,c=!1,d=this._previousAttributes,e;for(e in a)f.isEqual(d[e],b=a[e])||((c||(c={}))[e]=b);return c},previous:function(a){return!arguments.length||!this._previousAttributes?null:this._previousAttributes[a]},previousAttributes:function(){return f.clone(this._previousAttributes)},isValid:function(){return!this.validate(this.attributes)},_validate:function(a,b){if(b.silent||!this.validate)return!0;var a=f.extend({},this.attributes,a),c=this.validate(a,b);return c?(b&&b.error?b.error(this,c,b):this.trigger("error",this,c,b),!1):!0}}),e.Collection=function(a,b){b||(b={}),b.comparator&&(this.comparator=b.comparator),this._reset(),this.initialize.apply(this,arguments),a&&this.reset(a,{silent:!0,parse:b.parse})},f.extend(e.Collection.prototype,e.Events,{model:e.Model,initialize:function(){},toJSON:function(){return this.map(function(a){return a.toJSON()})},add:function(a,b){var c,e,g,h,i,j={},k={};b||(b={}),a=f.isArray(a)?a.slice():[a];for(c=0,e=a.length;c<e;c++){if(!(g=a[c]=this._prepareModel(a[c],b)))throw Error("Can't add an invalid model to a collection");if(j[h=g.cid]||this._byCid[h]||null!=(i=g.id)&&(k[i]||this._byId[i]))throw Error("Can't add the same model to a collection twice");j[h]=k[i]=g}for(c=0;c<e;c++)(g=a[c]).on("all",this._onModelEvent,this),this._byCid[g.cid]=g,null!=g.id&&(this._byId[g.id]=g);this.length+=e,d.apply(this.models,[null!=b.at?b.at:this.models.length,0].concat(a)),this.comparator&&this.sort({silent:!0});if(b.silent)return this;for(c=0,e=this.models.length;c<e;c++)j[(g=this.models[c]).cid]&&(b.index=c,g.trigger("add",g,this,b));return this},remove:function(a,b){var c,d,e,g;b||(b={}),a=f.isArray(a)?a.slice():[a];for(c=0,d=a.length;c<d;c++)if(g=this.getByCid(a[c])||this.get(a[c]))delete this._byId[g.id],delete this._byCid[g.cid],e=this.indexOf(g),this.models.splice(e,1),this.length--,b.silent||(b.index=e,g.trigger("remove",g,this,b)),this._removeReference(g);return this},get:function(a){return null==a?null:this._byId[null!=a.id?a.id:a]},getByCid:function(a){return a&&this._byCid[a.cid||a]},at:function(a){return this.models[a]},sort:function(a){a||(a={});if(!this.comparator)throw Error("Cannot sort a set without a comparator");var b=f.bind(this.comparator,this);return 1==this.comparator.length?this.models=this.sortBy(b):this.models.sort(b),a.silent||this.trigger("reset",this,a),this},pluck:function(a){return f.map(this.models,function(b){return b.get(a)})},reset:function(a,b){a||(a=[]),b||(b={});for(var c=0,d=this.models.length;c<d;c++)this._removeReference(this.models[c]);return this._reset(),this.add(a,{silent:!0,parse:b.parse}),b.silent||this.trigger("reset",this,b),this},fetch:function(a){a=a?f.clone(a):{},void 0===a.parse&&(a.parse=!0);var b=this,c=a.success;return a.success=function(d,e,f){b[a.add?"add":"reset"](b.parse(d,f),a),c&&c(b,d)},a.error=e.wrapError(a.error,b,a),(this.sync||e.sync).call(this,"read",this,a)},create:function(a,b){var c=this,b=b?f.clone(b):{},a=this._prepareModel(a,b);if(!a)return!1;b.wait||c.add(a,b);var d=b.success;return b.success=function(e,f){b.wait&&c.add(e,b),d?d(e,f):e.trigger("sync",a,f,b)},a.save(null,b),a},parse:function(a){return a},chain:function(){return f(this.models).chain()},_reset:function(){this.length=0,this.models=[],this._byId={},this._byCid={}},_prepareModel:function(a,b){return a instanceof e.Model?a.collection||(a.collection=this):(b.collection=this,a=new this.model(a,b),a._validate(a.attributes,b)||(a=!1)),a},_removeReference:function(a){this==a.collection&&delete a.collection,a.off("all",this._onModelEvent,this)},_onModelEvent:function(a,b,c,d){("add"==a||"remove"==a)&&c!=this||("destroy"==a&&this.remove(b,d),b&&a==="change:"+b.idAttribute&&(delete this._byId[b.previous(b.idAttribute)],this._byId[b.id]=b),this.trigger.apply(this,arguments))}}),f.each("forEach,each,map,reduce,reduceRight,find,detect,filter,select,reject,every,all,some,any,include,contains,invoke,max,min,sortBy,sortedIndex,toArray,size,first,initial,rest,last,without,indexOf,shuffle,lastIndexOf,isEmpty,groupBy".split(","),function(a){e.Collection.prototype[a]=function(){return f[a].apply(f,[this.models].concat(f.toArray(arguments)))}}),e.Router=function(a){a||(a={}),a.routes&&(this.routes=a.routes),this._bindRoutes(),this.initialize.apply(this,arguments)};var h=/:\w+/g,i=/\*\w+/g,j=/[-[\]{}()+?.,\\^$|#\s]/g;f.extend(e.Router.prototype,e.Events,{initialize:function(){},route:function(a,b,c){return e.history||(e.history=new e.History),f.isRegExp(a)||(a=this._routeToRegExp(a)),c||(c=this[b]),e.history.route(a,f.bind(function(d){d=this._extractParameters(a,d),c&&c.apply(this,d),this.trigger.apply(this,["route:"+b].concat(d)),e.history.trigger("route",this,b,d)},this)),this},navigate:function(a,b){e.history.navigate(a,b)},_bindRoutes:function(){if(this.routes){var a=[],b;for(b in this.routes)a.unshift([b,this.routes[b]]);b=0;for(var c=a.length;b<c;b++)this.route(a[b][0],a[b][1],this[a[b][1]])}},_routeToRegExp:function(a){return a=a.replace(j,"\\$&").replace(h,"([^/]+)").replace(i,"(.*?)"),RegExp("^"+a+"$")},_extractParameters:function(a,b){return a.exec(b).slice(1)}}),e.History=function(){this.handlers=[],f.bindAll(this,"checkUrl")};var k=/^[#\/]/,l=/msie [\w.]+/,m=!1;f.extend(e.History.prototype,e.Events,{interval:50,getFragment:function(a,b){if(null==a)if(this._hasPushState||b){var a=window.location.pathname,c=window.location.search;c&&(a+=c)}else a=window.location.hash;return a=decodeURIComponent(a),a.indexOf(this.options.root)||(a=a.substr(this.options.root.length)),a.replace(k,"")},start:function(a){if(m)throw Error("Backbone.history has already been started");this.options=f.extend({},{root:"/"},this.options,a),this._wantsHashChange=!1!==this.options.hashChange,this._wantsPushState=!!this.options.pushState,this._hasPushState=!(!this.options.pushState||!window.history||!window.history.pushState);var a=this.getFragment(),b=document.documentMode;if(b=l.exec(navigator.userAgent.toLowerCase())&&(!b||7>=b))this.iframe=g('<iframe src="javascript:0" tabindex="-1" />').hide().appendTo("body")[0].contentWindow,this.navigate(a);this._hasPushState?g(window).bind("popstate",this.checkUrl):this._wantsHashChange&&"onhashchange"in window&&!b?g(window).bind("hashchange",this.checkUrl):this._wantsHashChange&&(this._checkUrlInterval=setInterval(this.checkUrl,this.interval)),this.fragment=a,m=!0,a=window.location,b=a.pathname==this.options.root;if(this._wantsHashChange&&this._wantsPushState&&!this._hasPushState&&!b)return this.fragment=this.getFragment(null,!0),window.location.replace(this.options.root+"#"+this.fragment),!0;this._wantsPushState&&this._hasPushState&&b&&a.hash&&(this.fragment=a.hash.replace(k,""),window.history.replaceState({},document.title,a.protocol+"//"+a.host+this.options.root+this.fragment));if(!this.options.silent)return this.loadUrl()},stop:function(){g(window).unbind("popstate",this.checkUrl).unbind("hashchange",this.checkUrl),clearInterval(this._checkUrlInterval),m=!1},route:function(a,b){this.handlers.unshift({route:a,callback:b})},checkUrl:function(){var a=this.getFragment();a==this.fragment&&this.iframe&&(a=this.getFragment(this.iframe.location.hash));if(a==this.fragment||a==decodeURIComponent(this.fragment))return!1;this.iframe&&this.navigate(a),this.loadUrl()||this.loadUrl(window.location.hash)},loadUrl:function(a){var b=this.fragment=this.getFragment(a);return f.any(this.handlers,function(a){if(a.route.test(b))return a.callback(b),!0})},navigate:function(a,b){if(!m)return!1;if(!b||!0===b)b={trigger:b};var c=(a||"").replace(k,"");this.fragment==c||this.fragment==decodeURIComponent(c)||(this._hasPushState?(0!=c.indexOf(this.options.root)&&(c=this.options.root+c),this.fragment=c,window.history[b.replace?"replaceState":"pushState"]({},document.title,c)):this._wantsHashChange?(this.fragment=c,this._updateHash(window.location,c,b.replace),this.iframe&&c!=this.getFragment(this.iframe.location.hash)&&(b.replace||this.iframe.document.open().close(),this._updateHash(this.iframe.location,c,b.replace))):window.location.assign(this.options.root+a),b.trigger&&this.loadUrl(a))},_updateHash:function(a,b,c){c?a.replace(a.toString().replace(/(javascript:|#).*$/,"")+"#"+b):a.hash=b}}),e.View=function(a){this.cid=f.uniqueId("view"),this._configure(a||{}),this._ensureElement(),this.initialize.apply(this,arguments),this.delegateEvents()};var n=/^(\S+)\s*(.*)$/,o="model,collection,el,id,attributes,className,tagName".split(",");f.extend(e.View.prototype,e.Events,{tagName:"div",$:function(a){return this.$el.find(a)},initialize:function(){},render:function(){return this},remove:function(){return this.$el.remove(),this},make:function(a,b,c){return a=document.createElement(a),b&&g(a).attr(b),c&&g(a).html(c),a},setElement:function(a,b){return this.$el=g(a),this.el=this.$el[0],!1!==b&&this.delegateEvents(),this},delegateEvents:function(a){if(a||(a=s(this,"events"))){this.undelegateEvents();for(var b in a){var c=a[b];f.isFunction(c)||(c=this[a[b]]);if(!c)throw Error('Event "'+a[b]+'" does not exist');var d=b.match(n),e=d[1],d=d[2],c=f.bind(c,this),e=e+(".delegateEvents"+this.cid);""===d?this.$el.bind(e,c):this.$el.delegate(d,e,c)}}},undelegateEvents:function(){this.$el.unbind(".delegateEvents"+this.cid)},_configure:function(a){this.options&&(a=f.extend({},this.options,a));for(var b=0,c=o.length;b<c;b++){var d=o[b];a[d]&&(this[d]=a[d])}this.options=a},_ensureElement:function(){if(this.el)this.setElement(this.el,!1);else{var a=s(this,"attributes")||{};this.id&&(a.id=this.id),this.className&&(a["class"]=this.className),this.setElement(this.make(this.tagName,a),!1)}}}),e.Model.extend=e.Collection.extend=e.Router.extend=e.View.extend=function(a,b){var c=r(this,a,b);return c.extend=this.extend,c};var p={create:"POST",update:"PUT","delete":"DELETE",read:"GET"};e.sync=function(a,b,c){var d=p[a],h={type:d,dataType:"json"};return c.url||(h.url=s(b,"url")||t()),!c.data&&b&&("create"==a||"update"==a)&&(h.contentType="application/json",h.data=JSON.stringify(b.toJSON())),e.emulateJSON&&(h.contentType="application/x-www-form-urlencoded",h.data=h.data?{model:h.data}:{}),e.emulateHTTP&&("PUT"===d||"DELETE"===d)&&(e.emulateJSON&&(h.data._method=d),h.type="POST",h.beforeSend=function(a){a.setRequestHeader("X-HTTP-Method-Override",d)}),"GET"!==h.type&&!e.emulateJSON&&(h.processData=!1),g.ajax(f.extend(h,c))},e.wrapError=function(a,b,c){return function(d,e){e=d===b?e:d,a?a(b,e,c):b.trigger("error",b,e,c)}};var q=function(){},r=function(a,b,c){var d;return d=b&&b.hasOwnProperty("constructor")?b.constructor:function(){a.apply(this,arguments)},f.extend(d,a),q.prototype=a.prototype,d.prototype=new q,b&&f.extend(d.prototype,b),c&&f.extend(d,c),d.prototype.constructor=d,d.__super__=a.prototype,d},s=function(a,b){return!a||!a[b]?null:f.isFunction(a[b])?a[b]():a[b]},t=function(){throw Error('A "url" property or function must be specified')}}.call(this),function(){var a,b,c,d,e,f,g,h,i,j,k,l=Array.prototype.indexOf||function(a){for(var b=0,c=this.length;b<c;b++)if(this[b]===a)return b;return-1};f=function(a){var b,c,d,e,f,g;g=[];for(b in a){d=a[b],c={key:b};if(_.isRegExp(d))c.type="$regex",c.value=d;else if(_(d).isObject())for(e in d)f=d[e],k(e,f)&&(c.type=e,c.value=f);else c.type="$equal",c.value=d;g.push(c)}return g},k=function(a,b){switch(a){case"$in":case"$nin":case"$all":case"$any":return _(b).isArray();case"$size":return _(b).isNumber();case"$regex":return _(b).isRegExp();case"$like":case"$likeI":return _(b).isString();case"$between":return _(b).isArray()&&b.length===2;case"$cb":return _(b).isFunction();default:return!0}},j=function(a,b){switch(a){case"$like":case"$likeI":case"$regex":return _(b).isString();case"$contains":case"$all":case"$any":return _(b).isArray();case"$size":return _(b).isArray()||_(b).isString();case"$in":case"$nin":return b!=null;default:return!0}},g=function(a,b,c,d){switch(a){case"$equal":return c===b;case"$contains":return l.call(c,b)>=0;case"$ne":return c!==b;case"$lt":return c<b;case"$gt":return c>b;case"$lte":return c<=b;case"$gte":return c>=b;case"$between":return b[0]<c&&c<b[1];case"$in":return l.call(b,c)>=0;case"$nin":return l.call(b,c)<0;case"$all":return _(c).all(function(a){return l.call(b,a)>=0});case"$any":return _(c).any(function(a){return l.call(b,a)>=0});case"$size":return c.length===b;case"$exists":case"$has":return c!=null===b;case"$like":return c.indexOf(b)!==-1;case"$likeI":return c.toLowerCase().indexOf(b.toLowerCase())!==-1;case"$regex":return b.test(c);case"$cb":return b.call(d,c);default:return!1}},d=function(a,b,c,d){var e;return e=f(b),_[d](a,function(a){var b,d,f,h,i;for(h=0,i=e.length;h<i;h++){d=e[h],b=a.get(d.key)
5
+ ,f=j(d.type,b),f&&(f=g(d.type,d.value,b,a));if(c===f)return c}return!c})},h={$and:function(a,b){return d(a,b,!1,"filter")},$or:function(a,b){return d(a,b,!0,"filter")},$nor:function(a,b){return d(a,b,!0,"reject")},$not:function(a,b){return d(a,b,!1,"reject")}},a=function(a,b,d){var e,f,g,h;return g=JSON.stringify(b),e=(h=a._query_cache)!=null?h:a._query_cache={},f=e[g],f||(f=c(a,b,d),e[g]=f),f},b=function(a,b){var c,d,e;return c=_.intersection(["$and","$not","$or","$nor"],_(b).keys()),d=a.models,c.length===0?h.$and(d,b):(e=function(a,c){return h[c](a,b[c])},_.reduce(c,e,d))},c=function(a,c,d){var e;return e=b(a,c),d.sortBy&&(e=i(e,d)),e},i=function(a,b){return _(b.sortBy).isString()?a=_(a).sortBy(function(a){return a.get(b.sortBy)}):_(b.sortBy).isFunction()&&(a=_(a).sortBy(b.sortBy)),b.order==="desc"&&(a=a.reverse()),a},e=function(a,b){var c,d,e,f;return b.offset?e=b.offset:b.page?e=(b.page-1)*b.limit:e=0,c=e+b.limit,d=a.slice(e,c),b.pager&&_.isFunction(b.pager)&&(f=Math.ceil(a.length/b.limit),b.pager(f,d)),d};if(typeof require!="undefined"){if(typeof _=="undefined"||_===null)_=require("underscore");if(typeof Backbone=="undefined"||Backbone===null)Backbone=require("backbone")}Backbone.QueryCollection=Backbone.Collection.extend({query:function(b,d){var f;return d==null&&(d={}),d.cache?f=a(this,b,d):f=c(this,b,d),d.limit&&(f=e(f,d)),f},where:function(a,b){return b==null&&(b={}),new this.constructor(this.query(a,b))},reset_query_cache:function(){return this._query_cache={}}}),typeof exports!="undefined"&&(exports.QueryCollection=Backbone.QueryCollection)}.call(this),function(){}.call(this),!function(a){a(function(){a.support.transition=function(){var a=function(){var a=document.createElement("bootstrap"),b={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd",msTransition:"MSTransitionEnd",transition:"transitionend"},c;for(c in b)if(a.style[c]!==undefined)return b[c]}();return a&&{end:a}}()})}(window.jQuery),!function(a){function b(){var b=this,d=setTimeout(function(){b.$element.off(a.support.transition.end),c.call(b)},500);this.$element.one(a.support.transition.end,function(){clearTimeout(d),c.call(b)})}function c(a){this.$element.hide().trigger("hidden"),d.call(this)}function d(b){var c=this,d=this.$element.hasClass("fade")?"fade":"";if(this.isShown&&this.options.backdrop){var f=a.support.transition&&d;this.$backdrop=a('<div class="modal-backdrop '+d+'" />').appendTo(document.body),this.options.backdrop!="static"&&this.$backdrop.click(a.proxy(this.hide,this)),f&&this.$backdrop[0].offsetWidth,this.$backdrop.addClass("in"),f?this.$backdrop.one(a.support.transition.end,b):b()}else!this.isShown&&this.$backdrop?(this.$backdrop.removeClass("in"),a.support.transition&&this.$element.hasClass("fade")?this.$backdrop.one(a.support.transition.end,a.proxy(e,this)):e.call(this)):b&&b()}function e(){this.$backdrop.remove(),this.$backdrop=null}function f(){var b=this;this.isShown&&this.options.keyboard?a(document).on("keyup.dismiss.modal",function(a){a.which==27&&b.hide()}):this.isShown||a(document).off("keyup.dismiss.modal")}var g=function(b,c){this.options=c,this.$element=a(b).delegate('[data-dismiss="modal"]',"click.dismiss.modal",a.proxy(this.hide,this))};g.prototype={constructor:g,toggle:function(){return this[this.isShown?"hide":"show"]()},show:function(){var b=this,c=a.Event("show");this.$element.trigger(c);if(this.isShown||c.isDefaultPrevented())return;a("body").addClass("modal-open"),this.isShown=!0,f.call(this),d.call(this,function(){var c=a.support.transition&&b.$element.hasClass("fade");b.$element.parent().length||b.$element.appendTo(document.body),b.$element.show(),c&&b.$element[0].offsetWidth,b.$element.addClass("in"),c?b.$element.one(a.support.transition.end,function(){b.$element.trigger("shown")}):b.$element.trigger("shown")})},hide:function(d){d&&d.preventDefault();var e=this;d=a.Event("hide"),this.$element.trigger(d);if(!this.isShown||d.isDefaultPrevented())return;this.isShown=!1,a("body").removeClass("modal-open"),f.call(this),this.$element.removeClass("in"),a.support.transition&&this.$element.hasClass("fade")?b.call(this):c.call(this)}},a.fn.modal=function(b){return this.each(function(){var c=a(this),d=c.data("modal"),e=a.extend({},a.fn.modal.defaults,c.data(),typeof b=="object"&&b);d||c.data("modal",d=new g(this,e)),typeof b=="string"?d[b]():e.show&&d.show()})},a.fn.modal.defaults={backdrop:!0,keyboard:!0,show:!0},a.fn.modal.Constructor=g,a(function(){a("body").on("click.modal.data-api",'[data-toggle="modal"]',function(b){var c=a(this),d,e=a(c.attr("data-target")||(d=c.attr("href"))&&d.replace(/.*(?=#[^\s]+$)/,"")),f=e.data("modal")?"toggle":a.extend({},e.data(),c.data());b.preventDefault(),e.modal(f)})})}(window.jQuery),!function(a){function b(){a(c).parent().removeClass("open")}var c='[data-toggle="dropdown"]',d=function(b){var c=a(b).on("click.dropdown.data-api",this.toggle);a("html").on("click.dropdown.data-api",function(){c.parent().removeClass("open")})};d.prototype={constructor:d,toggle:function(c){var d=a(this),e,f,g;if(d.is(".disabled, :disabled"))return;return f=d.attr("data-target"),f||(f=d.attr("href"),f=f&&f.replace(/.*(?=#[^\s]*$)/,"")),e=a(f),e.length||(e=d.parent()),g=e.hasClass("open"),b(),g||e.toggleClass("open"),!1}},a.fn.dropdown=function(b){return this.each(function(){var c=a(this),e=c.data("dropdown");e||c.data("dropdown",e=new d(this)),typeof b=="string"&&e[b].call(c)})},a.fn.dropdown.Constructor=d,a(function(){a("html").on("click.dropdown.data-api",b),a("body").on("click.dropdown",".dropdown form",function(a){a.stopPropagation()}).on("click.dropdown.data-api",c,d.prototype.toggle)})}(window.jQuery),!function(a){var b=function(a,b){this.init("tooltip",a,b)};b.prototype={constructor:b,init:function(b,c,d){var e,f;this.type=b,this.$element=a(c),this.options=this.getOptions(d),this.enabled=!0,this.options.trigger!="manual"&&(e=this.options.trigger=="hover"?"mouseenter":"focus",f=this.options.trigger=="hover"?"mouseleave":"blur",this.$element.on(e,this.options.selector,a.proxy(this.enter,this)),this.$element.on(f,this.options.selector,a.proxy(this.leave,this))),this.options.selector?this._options=a.extend({},this.options,{trigger:"manual",selector:""}):this.fixTitle()},getOptions:function(b){return b=a.extend({},a.fn[this.type].defaults,b,this.$element.data()),b.delay&&typeof b.delay=="number"&&(b.delay={show:b.delay,hide:b.delay}),b},enter:function(b){var c=a(b.currentTarget)[this.type](this._options).data(this.type);if(!c.options.delay||!c.options.delay.show)return c.show();clearTimeout(this.timeout),c.hoverState="in",this.timeout=setTimeout(function(){c.hoverState=="in"&&c.show()},c.options.delay.show)},leave:function(b){var c=a(b.currentTarget)[this.type](this._options).data(this.type);if(!c.options.delay||!c.options.delay.hide)return c.hide();clearTimeout(this.timeout),c.hoverState="out",this.timeout=setTimeout(function(){c.hoverState=="out"&&c.hide()},c.options.delay.hide)},show:function(){var a,b,c,d,e,f,g;if(this.hasContent()&&this.enabled){a=this.tip(),this.setContent(),this.options.animation&&a.addClass("fade"),f=typeof this.options.placement=="function"?this.options.placement.call(this,a[0],this.$element[0]):this.options.placement,b=/in/.test(f),a.remove().css({top:0,left:0,display:"block"}).appendTo(b?this.$element:document.body),c=this.getPosition(b),d=a[0].offsetWidth,e=a[0].offsetHeight;switch(b?f.split(" ")[1]:f){case"bottom":g={top:c.top+c.height,left:c.left+c.width/2-d/2};break;case"top":g={top:c.top-e,left:c.left+c.width/2-d/2};break;case"left":g={top:c.top+c.height/2-e/2,left:c.left-d};break;case"right":g={top:c.top+c.height/2-e/2,left:c.left+c.width}}a.css(g).addClass(f).addClass("in")}},isHTML:function(a){return typeof a!="string"||a.charAt(0)==="<"&&a.charAt(a.length-1)===">"&&a.length>=3||/^(?:[^<]*<[\w\W]+>[^>]*$)/.exec(a)},setContent:function(){var a=this.tip(),b=this.getTitle();a.find(".tooltip-inner")[this.isHTML(b)?"html":"text"](b),a.removeClass("fade in top bottom left right")},hide:function(){function b(){var b=setTimeout(function(){d.off(a.support.transition.end).remove()},500);d.one(a.support.transition.end,function(){clearTimeout(b),d.remove()})}var c=this,d=this.tip();d.removeClass("in"),a.support.transition&&this.$tip.hasClass("fade")?b():d.remove()},fixTitle:function(){var a=this.$element;(a.attr("title")||typeof a.attr("data-original-title")!="string")&&a.attr("data-original-title",a.attr("title")||"").removeAttr("title")},hasContent:function(){return this.getTitle()},getPosition:function(b){return a.extend({},b?{top:0,left:0}:this.$element.offset(),{width:this.$element[0].offsetWidth,height:this.$element[0].offsetHeight})},getTitle:function(){var a,b=this.$element,c=this.options;return a=b.attr("data-original-title")||(typeof c.title=="function"?c.title.call(b[0]):c.title),a},tip:function(){return this.$tip=this.$tip||a(this.options.template)},validate:function(){this.$element[0].parentNode||(this.hide(),this.$element=null,this.options=null)},enable:function(){this.enabled=!0},disable:function(){this.enabled=!1},toggleEnabled:function(){this.enabled=!this.enabled},toggle:function(){this[this.tip().hasClass("in")?"hide":"show"]()}},a.fn.tooltip=function(c){return this.each(function(){var d=a(this),e=d.data("tooltip"),f=typeof c=="object"&&c;e||d.data("tooltip",e=new b(this,f)),typeof c=="string"&&e[c]()})},a.fn.tooltip.Constructor=b,a.fn.tooltip.defaults={animation:!0,placement:"top",selector:!1,template:'<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',trigger:"hover",title:"",delay:0}}(window.jQuery),!function(a){var b=function(a,b){this.init("popover",a,b)};b.prototype=a.extend({},a.fn.tooltip.Constructor.prototype,{constructor:b,setContent:function(){var a=this.tip(),b=this.getTitle(),c=this.getContent();a.find(".popover-title")[this.isHTML(b)?"html":"text"](b),a.find(".popover-content > *")[this.isHTML(c)?"html":"text"](c),a.removeClass("fade top bottom left right in")},hasContent:function(){return this.getTitle()||this.getContent()},getContent:function(){var a,b=this.$element,c=this.options;return a=b.attr("data-content")||(typeof c.content=="function"?c.content.call(b[0]):c.content),a},tip:function(){return this.$tip||(this.$tip=a(this.options.template)),this.$tip}}),a.fn.popover=function(c){return this.each(function(){var d=a(this),e=d.data("popover"),f=typeof c=="object"&&c;e||d.data("popover",e=new b(this,f)),typeof c=="string"&&e[c]()})},a.fn.popover.Constructor=b,a.fn.popover.defaults=a.extend({},a.fn.tooltip.defaults,{placement:"right",content:"",template:'<div class="popover"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"><p></p></div></div></div>'})}(window.jQuery),!function(a){var b='[data-dismiss="alert"]',c=function(c){a(c).on("click",b,this.close)};c.prototype.close=function(b){function c(){f.trigger("closed").remove()}var d=a(this),e=d.attr("data-target"),f;e||(e=d.attr("href"),e=e&&e.replace(/.*(?=#[^\s]*$)/,"")),f=a(e),b&&b.preventDefault(),f.length||(f=d.hasClass("alert")?d:d.parent()),f.trigger(b=a.Event("close"));if(b.isDefaultPrevented())return;f.removeClass("in"),a.support.transition&&f.hasClass("fade")?f.on(a.support.transition.end,c):c()},a.fn.alert=function(b){return this.each(function(){var d=a(this),e=d.data("alert");e||d.data("alert",e=new c(this)),typeof b=="string"&&e[b].call(d)})},a.fn.alert.Constructor=c,a(function(){a("body").on("click.alert.data-api",b,c.prototype.close)})}(window.jQuery),!function(a){var b=function(b,c){this.$element=a(b),this.options=a.extend({},a.fn.button.defaults,c)};b.prototype.setState=function(a){var b="disabled",c=this.$element,d=c.data(),e=c.is("input")?"val":"html";a+="Text",d.resetText||c.data("resetText",c[e]()),c[e](d[a]||this.options[a]),setTimeout(function(){a=="loadingText"?c.addClass(b).attr(b,b):c.removeClass(b).removeAttr(b)},0)},b.prototype.toggle=function(){var a=this.$element.parent('[data-toggle="buttons-radio"]');a&&a.find(".active").removeClass("active"),this.$element.toggleClass("active")},a.fn.button=function(c){return this.each(function(){var d=a(this),e=d.data("button"),f=typeof c=="object"&&c;e||d.data("button",e=new b(this,f)),c=="toggle"?e.toggle():c&&e.setState(c)})},a.fn.button.defaults={loadingText:"loading..."},a.fn.button.Constructor=b,a(function(){a("body").on("click.button.data-api","[data-toggle^=button]",function(b){var c=a(b.target);c.hasClass("btn")||(c=c.closest(".btn")),c.button("toggle")})})}(window.jQuery),!function(a){var b=function(b,c){this.$element=a(b),this.options=a.extend({},a.fn.collapse.defaults,c),this.options.parent&&(this.$parent=a(this.options.parent)),this.options.toggle&&this.toggle()};b.prototype={constructor:b,dimension:function(){var a=this.$element.hasClass("width");return a?"width":"height"},show:function(){var b,c,d,e;if(this.transitioning)return;b=this.dimension(),c=a.camelCase(["scroll",b].join("-")),d=this.$parent&&this.$parent.find("> .accordion-group > .in");if(d&&d.length){e=d.data("collapse");if(e&&e.transitioning)return;d.collapse("hide"),e||d.data("collapse",null)}this.$element[b](0),this.transition("addClass",a.Event("show"),"shown"),this.$element[b](this.$element[0][c])},hide:function(){var b;if(this.transitioning)return;b=this.dimension(),this.reset(this.$element[b]()),this.transition("removeClass",a.Event("hide"),"hidden"),this.$element[b](0)},reset:function(a){var b=this.dimension();return this.$element.removeClass("collapse")[b](a||"auto")[0].offsetWidth,this.$element[a!==null?"addClass":"removeClass"]("collapse"),this},transition:function(b,c,d){var e=this,f=function(){c.type=="show"&&e.reset(),e.transitioning=0,e.$element.trigger(d)};this.$element.trigger(c);if(c.isDefaultPrevented())return;this.transitioning=1,this.$element[b]("in"),a.support.transition&&this.$element.hasClass("collapse")?this.$element.one(a.support.transition.end,f):f()},toggle:function(){this[this.$element.hasClass("in")?"hide":"show"]()}},a.fn.collapse=function(c){return this.each(function(){var d=a(this),e=d.data("collapse"),f=typeof c=="object"&&c;e||d.data("collapse",e=new b(this,f)),typeof c=="string"&&e[c]()})},a.fn.collapse.defaults={toggle:!0},a.fn.collapse.Constructor=b,a(function(){a("body").on("click.collapse.data-api","[data-toggle=collapse]",function(b){var c=a(this),d,e=c.attr("data-target")||b.preventDefault()||(d=c.attr("href"))&&d.replace(/.*(?=#[^\s]+$)/,""),f=a(e).data("collapse")?"toggle":c.data();a(e).collapse(f)})})}(window.jQuery),!function(a){var b=function(b,c){this.$element=a(b),this.options=a.extend({},a.fn.typeahead.defaults,c),this.matcher=this.options.matcher||this.matcher,this.sorter=this.options.sorter||this.sorter,this.highlighter=this.options.highlighter||this.highlighter,this.updater=this.options.updater||this.updater,this.$menu=a(this.options.menu).appendTo("body"),this.source=this.options.source,this.shown=!1,this.listen()};b.prototype={constructor:b,select:function(){var a=this.$menu.find(".active").attr("data-value");return this.$element.val(this.updater(a)).change(),this.hide()},updater:function(a){return a},show:function(){var b=a.extend({},this.$element.offset(),{height:this.$element[0].offsetHeight});return this.$menu.css({top:b.top+b.height,left:b.left}),this.$menu.show(),this.shown=!0,this},hide:function(){return this.$menu.hide(),this.shown=!1,this},lookup:function(b){var c=this,d,e;return this.query=this.$element.val(),this.query?(d=a.grep(this.source,function(a){return c.matcher(a)}),d=this.sorter(d),d.length?this.render(d.slice(0,this.options.items)).show():this.shown?this.hide():this):this.shown?this.hide():this},matcher:function(a){return~a.toLowerCase().indexOf(this.query.toLowerCase())},sorter:function(a){var b=[],c=[],d=[],e;while(e=a.shift())e.toLowerCase().indexOf(this.query.toLowerCase())?~e.indexOf(this.query)?c.push(e):d.push(e):b.push(e);return b.concat(c,d)},highlighter:function(a){var b=this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&");return a.replace(new RegExp("("+b+")","ig"),function(a,b){return"<strong>"+b+"</strong>"})},render:function(b){var c=this;return b=a(b).map(function(b,d){return b=a(c.options.item).attr("data-value",d),b.find("a").html(c.highlighter(d)),b[0]}),b.first().addClass("active"),this.$menu.html(b),this},next:function(b){var c=this.$menu.find(".active").removeClass("active"),d=c.next();d.length||(d=a(this.$menu.find("li")[0])),d.addClass("active")},prev:function(a){var b=this.$menu.find(".active").removeClass("active"),c=b.prev();c.length||(c=this.$menu.find("li").last()),c.addClass("active")},listen:function(){this.$element.on("blur",a.proxy(this.blur,this)).on("keypress",a.proxy(this.keypress,this)).on("keyup",a.proxy(this.keyup,this)),(a.browser.webkit||a.browser.msie)&&this.$element.on("keydown",a.proxy(this.keypress,this)),this.$menu.on("click",a.proxy(this.click,this)).on("mouseenter","li",a.proxy(this.mouseenter,this))},keyup:function(a){switch(a.keyCode){case 40:case 38:break;case 9:case 13:if(!this.shown)return;this.select();break;case 27:if(!this.shown)return;this.hide();break;default:this.lookup()}a.stopPropagation(),a.preventDefault()},keypress:function(a){if(!this.shown)return;switch(a.keyCode){case 9:case 13:case 27:a.preventDefault();break;case 38:if(a.type!="keydown")break;a.preventDefault(),this.prev();break;case 40:if(a.type!="keydown")break;a.preventDefault(),this.next()}a.stopPropagation()},blur:function(a){var b=this;setTimeout(function(){b.hide()},150)},click:function(a){a.stopPropagation(),a.preventDefault(),this.select()},mouseenter:function(b){this.$menu.find(".active").removeClass("active"),a(b.currentTarget).addClass("active")}},a.fn.typeahead=function(c){return this.each(function(){var d=a(this),e=d.data("typeahead"),f=typeof c=="object"&&c;e||d.data("typeahead",e=new b(this,f)),typeof c=="string"&&e[c]()})},a.fn.typeahead.defaults={source:[],items:8,menu:'<ul class="typeahead dropdown-menu"></ul>',item:'<li><a href="#"></a></li>'},a.fn.typeahead.Constructor=b,a(function(){a("body").on("focus.typeahead.data-api",'[data-provide="typeahead"]',function(b){var c=a(this);if(c.data("typeahead"))return;b.preventDefault(),c.typeahead(c.data())})})}(window.jQuery),function(){var a,b=Array.prototype.slice;(window||global).Luca=function(){var a,c,d,e,f,g;f=arguments[0],a=2<=arguments.length?b.call(arguments,1):[];if(_.isString(f)&&(g=Luca.cache(f)))return g;if(_.isString(f)&&(g=Luca.find(f)))return g;if(_.isObject(f)&&f.ctype!=null)return Luca.util.lazyComponent(f);_.isObject(f)&&f.defines&&f["extends"]&&(c=f.defines,e=f["extends"]);if(_.isFunction(d=_(a).last()))return d()},_.extend(Luca,{VERSION:"0.9.6",core:{},containers:{},components:{},modules:{},util:{},fields:{},registry:{},options:{},config:{}}),_.extend(Luca,Backbone.Events),Luca.autoRegister=Luca.config.autoRegister=!0,Luca.developmentMode=Luca.config.developmentMode=!1,Luca.enableGlobalObserver=Luca.config.enableGlobalObserver=!1,Luca.enableBootstrap=Luca.config.enableBootstrap=!0,Luca.config.enhancedViewProperties=!0,Luca.keys={ENTER:13,ESCAPE:27,KEYLEFT:37,KEYUP:38,KEYRIGHT:39,KEYDOWN:40,SPACEBAR:32,FORWARDSLASH:191},Luca.keyMap=_(Luca.keys).inject(function(a,b,c){return a[b]=c.toLowerCase(),a},{}),Luca.find=function(a){return Luca($(a).data("luca-id"))},Luca.supportsEvents=Luca.supportsBackboneEvents=function(a){return Luca.isComponent(a)||_.isFunction(a!=null?a.trigger:void 0)||_.isFunction(a!=null?a.bind:void 0)},Luca.isComponent=function(a){return Luca.isBackboneModel(a)||Luca.isBackboneView(a)||Luca.isBackboneCollection(a)},Luca.isComponentPrototype=function(a){return Luca.isViewPrototype(a)||Luca.isModelPrototype(a)||Luca.isCollectionPrototype(a)},Luca.isBackboneModel=function(a){return _.isString(a)&&(a=Luca.util.resolve(a)),_.isFunction(a!=null?a.set:void 0)&&_.isFunction(a!=null?a.get:void 0)&&_.isObject(a!=null?a.attributes:void 0)},Luca.isBackboneView=function(a){return _.isString(a)&&(a=Luca.util.resolve(a)),_.isFunction(a!=null?a.render:void 0)&&!_.isUndefined(a!=null?a.el:void 0)},Luca.isBackboneCollection=function(a){return _.isString(a)&&(a=Luca.util.resolve(a)),_.isFunction(a!=null?a.fetch:void 0)&&_.isFunction(a!=null?a.reset:void 0)},Luca.isViewPrototype=function(a){return _.isString(a)&&(a=Luca.util.resolve(a)),a!=null&&a.prototype!=null&&a.prototype.make!=null&&a.prototype.$!=null&&a.prototype.render!=null},Luca.isModelPrototype=function(a){return _.isString(a)&&(a=Luca.util.resolve(a)),a!=null&&(typeof a.prototype=="function"?a.prototype(a.prototype.save!=null&&a.prototype.changedAttributes!=null):void 0)},Luca.isCollectionPrototype=function(a){return _.isString(a)&&(a=Luca.util.resolve(a)),a!=null&&a.prototype!=null&&!Luca.isModelPrototype(a)&&a.prototype.reset!=null&&a.prototype.select!=null&&a.prototype.reject!=null},Luca.inheritanceChain=function(a){return _(Luca.parentClasses(a)).map(function(a){return Luca.util.resolve(a)})},Luca.parentClasses=function(a){var b,c,d;return c=[],_.isString(a)&&(a=Luca.util.resolve(a)),c.push(a.displayName||((d=a.prototype)!=null?d.displayName:void 0)||Luca.parentClass(a)),b=function(){var b;b=[];while(Luca.parentClass(a)!=null)b.push(a=Luca.parentClass(a));return b}(),c=c.concat(b),_.uniq(c)},Luca.parentClass=function(a){var b,c,d;b=[],_.isString(a)&&(a=Luca.util.resolve(a));if(Luca.isComponent(a))return a.displayName;if(Luca.isComponentPrototype(a))return typeof (c=a.prototype)._superClass=="function"?(d=c._superClass())!=null?d.displayName:void 0:void 0},Luca.template=function(a,b){var c,d,e,f,g;window.JST||(window.JST={});if(_.isFunction(a))return a(b);d=(g=Luca.templates)!=null?g[a]:void 0,c=typeof JST!="undefined"&&JST!==null?JST[a]:void 0,d==null&&c==null&&(e=new RegExp(""+a+"$"),d=_(Luca.templates).detect(function(a,b){return e.exec(b)}),c=_(JST).detect(function(a,b){return e.exec(b)}));if(!d&&!c)throw"Could not find template named "+a;return f=d||c,b!=null?f(b):f},Luca.available_templates=function(a){var b;return a==null&&(a=""),b=_(Luca.templates).keys(),a.length>0?_(b).select(function(b){return b.match(a)}):b},a={module:function(a,b){_.extend(a,b);if(a.included&&_(a.included).isFunction())return a.included.apply(a)},"delete":function(a,b){var c;return c=a[b],delete a[b],c},idle:function(a,b){var c;return b==null&&(b=1e3),window.DISABLE_IDLE&&(b=0),c=void 0,function(){return c&&window.clearTimeout(c),c=window.setTimeout(_.bind(a,this),b)}},idleShort:function(a,b){var c;return b==null&&(b=100),window.DISABLE_IDLE&&(b=0),c=void 0,function(){return c&&window.clearTimeout(c),c=window.setTimeout(_.bind(a,this),b)}},idleMedium:function(a,b){var c;return b==null&&(b=2e3),window.DISABLE_IDLE&&(b=0),c=void 0,function(){return c&&window.clearTimeout(c),c=window.setTimeout(_.bind(a,this),b)}},idleLong:function(a,b){var c;return b==null&&(b=5e3),window.DISABLE_IDLE&&(b=0),c=void 0,function(){return c&&window.clearTimeout(c),c=window.setTimeout(_.bind(a,this),b)}}},_.mixin(a)}.call(this),function(){this.JST||(this.JST={}),this.JST["luca-src/templates/components/bootstrap_form_controls"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<div class="btn-group form-actions">\n <a class="btn btn-primary submit-button">\n <i class="icon icon-ok icon-white"></i>\n Save Changes\n </a>\n <a class="btn reset-button cancel-button">\n <i class="icon icon-remove"></i>\n Cancel\n </a>\n</div>\n');return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca-src/templates/components/collection_loader_view"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<div id="progress-modal" class="modal" style="display: none">\n <div class="progress progress-info progress-striped active">\n <div class="bar" style="width:0%;"></div>\n </div>\n <div class="message">Initializing...</div>\n</div>\n');return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca-src/templates/components/form_alert"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<div class="',className,'">\n <a class="close" href="#" data-dismiss="alert">x</a>\n ',message,"\n</div>\n");return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca-src/templates/components/grid_view"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<div class="luca-ui-g-view-wrapper">\n <div class="g-view-header"></div>\n <div class="luca-ui-g-view-body">\n <table class="luca-ui-g-view scrollable-table" width="100%" cellpadding=0 cellspacing=0>\n <thead class="fixed"></thead>\n <tbody class="scrollable"></tbody>\n <tfoot></tfoot>\n </table>\n </div>\n <div class="luca-ui-g-view-header"></div>\n</div>\n');return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca-src/templates/components/grid_view_empty_text"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<div class="empty-text empty-text-wrapper">\n <p>',text,"</p>\n</div>\n");return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca-src/templates/components/load_mask"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<div class="load-mask">\n <div class="progress progress-striped active">\n <div class="bar" style="width:0%"></div>\n </div>\n</div>\n');return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca-src/templates/components/nav_bar"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<div class="navbar-inner">\n <div class="luca-ui-navbar-body container">\n </div>\n</div>\n');return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca-src/templates/components/pagination"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<div class="pagination">\n <a class="btn previous">\n <i class="icon icon-chevron-left"></i>\n </a>\n <div class="pagination-group">\n </div>\n <a class="btn next">\n <i class="icon icon-chevron-right"></i>\n </a>\n</div>\n');return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca-src/templates/containers/basic"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<div id="',id,'" class="',classes,'" style="',style,'"></div>\n');return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca-src/templates/containers/tab_selector_container"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{}){__p.push('<div id="',cid,'-tab-selector" class="tab-selector-container">\n <ul id="',cid,'-tabs-nav" class="nav nav-tabs">\n ');for(var i=0;i<components.length;i++){__p.push("\n ");var component=components[i];__p.push('\n <li class="tab-selector" data-target="',i,'">\n <a data-target="',i,'">\n ',component.title,"\n </a>\n </li>\n ")}__p.push("\n </ul>\n</div>\n")}return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca-src/templates/containers/tab_view"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<ul id="',cid,'-tabs-selector" class="nav ',navClass,'"></ul>\n<div id="',cid,'-tab-view-content" class="tab-content"></div>\n');return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca-src/templates/containers/toolbar_wrapper"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<div class="luca-ui-toolbar-wrapper" id="',id,'"></div>\n');return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca-src/templates/fields/button_field"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<label>&nbsp;</label>\n<input style="',inputStyles,'" class="btn ',input_class,'" value="',input_value,'" type="',input_type,'" id="<%= input_id" />\n');return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca-src/templates/fields/button_field_link"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<a class="btn ',input_class,'">\n '),icon_class.length&&__p.push('\n <i class="',icon_class,'"></i>\n ',input_value,"\n "),__p.push("\n</a>\n");return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca-src/templates/fields/checkbox_array"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<div class="control-group">\n <label for="',input_id,'"><%= label =>\n <div class="controls"><div>\n</div>\n');return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca-src/templates/fields/checkbox_array_item"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<label for="',input_id,'">\n <input id="',input_id,'" type="checkbox" name="',input_name,'" value="',value,'" />\n</label>\n');return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca-src/templates/fields/checkbox_field"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<label for="',input_id,'">\n ',label,'\n <input type="checkbox" name="',input_name,'" value="',input_value,'" style="',inputStyles,'" />\n</label>\n\n'),helperText&&__p.push('\n<p class="helper-text help-block">\n ',helperText,"\n</p>\n"),__p.push("\n");return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca-src/templates/fields/file_upload_field"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<label for="',input_id,'">\n ',label,'\n <input type="file" name="',input_name,'" value="',input_value,'" style="',inputStyles,'" />\n</label>\n\n'),helperText&&__p.push('\n<p class="helper-text help-block">\n ',helperText,"\n</p>\n"),__p.push("\n");return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca-src/templates/fields/hidden_field"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push(' <input type="hidden" name="',input_name,'" value="',input_value,'" style="',inputStyles,'" />\n');return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca-src/templates/fields/select_field"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<label for="',input_id,'">\n ',label,'\n</label>\n<div class="controls">\n <select name="',input_name,'" value="',input_value,'" style="',inputStyles,'" ></select>\n '),helperText&&__p.push('\n <p class="helper-text help-block">\n ',helperText,"\n </p>\n "),__p.push("\n</div>\n");return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca-src/templates/fields/text_area_field"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<label for="',input_id,'">\n ',label,'\n</label>\n<div class="controls">\n <textarea name="',input_name,'" style="',inputStyles,'" >',input_value,"</textarea>\n "),helperText&&__p.push('\n <p class="helper-text help-block">\n ',helperText,"\n </p>\n "),__p.push("\n</div>\n");return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca-src/templates/fields/text_field"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push(""),(typeof label!="undefined"&&typeof hideLabel!="undefined"&&!hideLabel||typeof hideLabel=="undefined")&&__p.push('\n<label class="control-label" for="',input_id,'">',label,"</label>\n"),__p.push('\n\n<div class="controls">\n'),typeof addOn!="undefined"&&__p.push('\n <span class="add-on">',addOn,"</span>\n"),__p.push('\n<input type="text" name="',input_name,'" style="',inputStyles,'" value="',input_value,'" />\n'),helperText&&__p.push('\n<p class="helper-text help-block">\n ',helperText,"\n</p>\n"),__p.push("\n\n</div>\n");return __p.join("")}}.call(this),function(){this.JST||(this.JST={}),this.JST["luca-src/templates/table_view"]=function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments)};with(obj||{})__p.push('<thead></thead>\n<tbody class="table-body"></tbody>\n<tfoot></tfoot>\n<caption></caption>\n');return __p.join("")}}.call(this),function(){var currentNamespace,__slice=Array.prototype.slice;Luca.util.resolve=function(a,b){var c;try{b||(b=window||global),c=_(a.split(/\./)).inject(function(a,b){return a=a!=null?a[b]:void 0},b)}catch(d){
6
+ throw console.log("Error resolving",a,b),d}return c},Luca.util.nestedValue=Luca.util.resolve,Luca.util.argumentsLogger=function(a){return function(){return console.log(a,arguments)}},Luca.util.read=function(){var a,b;return b=arguments[0],a=2<=arguments.length?__slice.call(arguments,1):[],_.isFunction(b)?b.apply(this,a):b},Luca.util.classify=function(a){return a==null&&(a=""),_.string.camelize(_.string.capitalize(a))},Luca.util.hook=function(a){var b,c,d;return a==null&&(a=""),c=a.split(":"),d=c.shift(),c=_(c).map(function(a){return _.string.capitalize(a)}),b=d+c.join("")},Luca.util.isIE=function(){try{return Object.defineProperty({},"",{}),!1}catch(a){return!0}},currentNamespace=window||global,Luca.util.namespace=function(namespace){return namespace==null?currentNamespace:(currentNamespace=_.isString(namespace)?Luca.util.resolve(namespace,window||global):namespace,currentNamespace!=null?currentNamespace:currentNamespace=eval("(window||global)."+namespace+" = {}"))},Luca.util.lazyComponent=function(config){var componentClass,constructor,ctype;_.isObject(config)&&(ctype=config.ctype||config.type),_.isString(config)&&(ctype=config),componentClass=Luca.registry.lookup(ctype);if(!componentClass)throw"Invalid Component Type: "+ctype+". Did you forget to register it?";return constructor=eval(componentClass),new constructor(config)},Luca.util.selectProperties=function(a,b,c){var d;return d=_(b).values(),_(d).select(a)},Luca.util.loadScript=function(a,b){var c;return c=document.createElement("script"),c.type="text/javascript",c.readyState&&(c.onreadystatechange=function(){return c.readyState==="loaded"||c.readyState==="complete"?(c.onreadystatechange=null,b()):c.onload=function(){return b()}}),c.src=a,document.body.appendChild(c)},Luca.util.make=Backbone.View.prototype.make,Luca.util.list=function(a,b,c){var d,e,f,g;b==null&&(b={}),d=c?"ol":"ul",d=Luca.util.make(d,b);if(_.isArray(a))for(f=0,g=a.length;f<g;f++)e=a[f],$(d).append(Luca.util.make("li",{},e));return d.outerHTML},Luca.util.label=function(a,b,c){var d;return a==null&&(a=""),c==null&&(c="label"),d=c,b!=null&&(d+=" "+c+"-"+b),Luca.util.make("span",{"class":d},a)},Luca.util.badge=function(a,b,c){var d;return a==null&&(a=""),c==null&&(c="badge"),d=c,b!=null&&(d+=" "+c+"-"+b),Luca.util.make("span",{"class":d},a)}}.call(this),function(){Luca.DevelopmentToolHelpers={refreshCode:function(){var a;return a=this,_(this.eventHandlerProperties()).each(function(b){return a[b]=a.definitionClass()[b]}),this.autoBindEventHandlers===!0&&this.bindAllEventHandlers(),this.delegateEvents()},eventHandlerProperties:function(){var a;return a=_(this.events).values(),_(a).select(function(a){return _.isString(a)})},eventHandlerFunctions:function(){var a,b=this;return a=_(this.events).values(),_(a).map(function(a){return _.isFunction(a)?a:b[a]})}}}.call(this),function(){var a,b=Array.prototype.slice;a=function(){function a(a,b,c){var d;this.object=a,c==null&&(c=!0),_.isFunction(b)?d=b:_.isString(b)&&_.isFunction(this.object[b])&&(d=this.object[b]);if(!_.isFunction(d))throw"Must pass a function or a string representing one";c===!0?this.fn=_.bind(function(){return _.defer(d)},this.object):this.fn=_.bind(d,this.object),this}return a.prototype.until=function(a,b){return a!=null&&b==null&&(b=a,a=this.object),a.once(b,this.fn),this.object},a}(),Luca.Events={defer:function(b,c){return c==null&&(c=!0),new a(this,b,c)},once:function(a,b,c){var d;return c||(c=this),d=function(){return b.apply(c,arguments),this.unbind(a,d)},this.bind(a,d)}},Luca.EventsExt={waitUntil:function(a,b){return this.waitFor.call(this,a,b)},waitFor:function(a,c){var d,e;return e=this,d={on:function(b){return b.waitFor.call(b,a,c)},and:function(){var d,f,g,h,i;f=1<=arguments.length?b.call(arguments,0):[],i=[];for(g=0,h=f.length;g<h;g++)d=f[g],d=_.isFunction(d)?d:e[d],i.push(e.once(a,d,c));return i},andThen:function(){return e.and.apply(e,arguments)}}},relayEvent:function(a){var c=this;return{on:function(){var d;return d=1<=arguments.length?b.call(arguments,0):[],{to:function(){var e,f,g,h,i,j;g=1<=arguments.length?b.call(arguments,0):[],j=[];for(h=0,i=g.length;h<i;h++)f=g[h],j.push(function(){var c,g,h,i=this;h=[];for(c=0,g=d.length;c<g;c++)e=d[c],h.push(e.on(a,function(){var c;return c=1<=arguments.length?b.call(arguments,0):[],c.unshift(a),f.trigger.apply(f,c)}));return h}.call(c));return j}}}}}}}.call(this),function(){var DefineProxy,__slice=Array.prototype.slice;_.mixin({def:Luca.component=Luca.define=Luca.register=function(a){return new DefineProxy(a)}}),DefineProxy=function(){function DefineProxy(a){var b;this.namespace=Luca.util.namespace(),this.componentId=this.componentName=a,this.superClassName="Luca.View",a.match(/\./)&&(this.namespaced=!0,b=a.split("."),this.componentId=b.pop(),this.namespace=b.join("."),Luca.registry.addNamespace(b.join(".")))}return DefineProxy.prototype["in"]=function(a){return this.namespace=a,this},DefineProxy.prototype.from=function(a){return this.superClassName=a,this},DefineProxy.prototype["extends"]=function(a){return this.superClassName=a,this},DefineProxy.prototype.extend=function(a){return this.superClassName=a,this},DefineProxy.prototype.triggers=function(){var a,b,c,d;b=1<=arguments.length?__slice.call(arguments,0):[],_.defaults(this.properties||(this.properties={}),{hooks:[]});for(c=0,d=b.length;c<d;c++)a=b[c],this.properties.hooks.push(a);return this.properties.hooks=_.uniq(this.properties.hooks),this},DefineProxy.prototype.includes=function(){var a,b,c,d;b=1<=arguments.length?__slice.call(arguments,0):[],_.defaults(this.properties||(this.properties={}),{include:[]});for(c=0,d=b.length;c<d;c++)a=b[c],this.properties.include.push(a);return this.properties.include=_.uniq(this.properties.include),this},DefineProxy.prototype.mixesIn=function(){var a,b,c,d;b=1<=arguments.length?__slice.call(arguments,0):[],_.defaults(this.properties||(this.properties={}),{mixins:[]});for(c=0,d=b.length;c<d;c++)a=b[c],this.properties.mixins.push(a);return this.properties.mixins=_.uniq(this.properties.mixins),this},DefineProxy.prototype.defaultProperties=function(properties){var at,componentType,_base;return properties==null&&(properties={}),_.defaults(this.properties||(this.properties={}),properties),at=this.namespaced?Luca.util.resolve(this.namespace,window||global):window||global,this.namespaced&&at==null&&(eval("(window||global)."+this.namespace+" = {}"),at=Luca.util.resolve(this.namespace,window||global)),at[this.componentId]=Luca.extend(this.superClassName,this.componentName,this.properties),Luca.autoRegister===!0&&(Luca.isViewPrototype(at[this.componentId])&&(componentType="view"),Luca.isCollectionPrototype(at[this.componentId])&&((_base=Luca.Collection).namespaces||(_base.namespaces=[]),Luca.Collection.namespaces.push(this.namespace),componentType="collection"),Luca.isModelPrototype(at[this.componentId])&&(componentType="model"),Luca.registerComponent(_.string.underscored(this.componentId),this.componentName,componentType)),at[this.componentId]},DefineProxy}(),DefineProxy.prototype.behavesAs=DefineProxy.prototype.uses=DefineProxy.prototype.mixesIn,DefineProxy.prototype.defines=DefineProxy.prototype.defaults=DefineProxy.prototype.exports=DefineProxy.prototype.defaultProperties,DefineProxy.prototype.defaultsTo=DefineProxy.prototype.enhance=DefineProxy.prototype["with"]=DefineProxy.prototype.defaultProperties,Luca.extend=function(a,b,c){var d,e,f,g,h,i;c==null&&(c={}),f=Luca.util.resolve(a,window||global),f.__initializers||(f.__initializers=[]);if(!_.isFunction(f!=null?f.extend:void 0))throw"Error defining "+b+". "+a+" is not a valid component to extend from";c.displayName=b,c._superClass=function(){return f.displayName||(f.displayName=a),f},c._super=function(a,b,c){var d;return b==null&&(b=this),c==null&&(c=[]),(d=this._superClass().prototype[a])!=null?d.apply(b,c):void 0},d=f.extend(c);if(_.isArray(c!=null?c.include:void 0)){i=c.include;for(g=0,h=i.length;g<h;g++)e=i[g],_.isString(e)&&(e=Luca.util.resolve(e)),_.extend(d.prototype,e)}return d},Luca.mixin=function(a){var b,c;return b=_(Luca.mixin.namespaces).detect(function(b){var c;return((c=Luca.util.resolve(b))!=null?c[a]:void 0)!=null}),b||(b="Luca.modules"),c=Luca.util.resolve(b)[a],c==null&&console.log("Could not find "+a+" in ",Luca.mixin.namespaces),c},Luca.mixin.namespaces=["Luca.modules"],Luca.mixin.namespace=function(a){return Luca.mixin.namespaces.push(a),Luca.mixin.namespaces=_(Luca.mixin.namespaces).uniq()},Luca.decorate=function(a){return _.isString(a)&&(a=Luca.util.resolve(a).prototype),{"with":function(b){var c,d,e,f,g;return c=Luca.mixin(b),d=_(c).chain().keys().select(function(a){return(""+a).match(/^__/)}),e=_(c).omit(d.value()),_.extend(a,e),c!=null&&(g=c.__included)!=null&&g.call(c,b),f=a._superClass().prototype.mixins,a.mixins||(a.mixins=[]),a.mixins.push(b),a.mixins=a.mixins.concat(f),a.mixins=_(a.mixins).chain().uniq().compact().value(),a}}}}.call(this),function(){Luca.modules.ApplicationEventBindings={__initializer:function(){var a,b,c,d,e,f,g;if(_.isEmpty(this.applicationEvents))return;a=this.app;if(_.isString(a)||_.isUndefined(a))a=(e=Luca.Application)!=null?typeof e.get=="function"?e.get(a):void 0:void 0;if(!Luca.supportsEvents(a))throw"Error binding to the application object on "+(this.name||this.cid);f=this.applicationEvents,g=[];for(c=0,d=f.length;c<d;c++){b=f[c],_.isString(c)&&(c=this[c]);if(!_.isFunction(c))throw"Error registering application event "+b+" on "+(this.name||this.cid);g.push(a.on(b,c))}return g}}}.call(this),function(){Luca.modules.CollectionEventBindings={__initializer:function(){var a,b,c,d,e,f,g,h,i;if(_.isEmpty(this.collectionEvents))return;e=this.collectionManager||Luca.CollectionManager.get(),g=this.collectionEvents,i=[];for(f in g){c=g[f],h=f.split(" "),d=h[0],b=h[1],a=e.getOrCreate(d);if(!a)throw"Could not find collection specified by "+d;_.isString(c)&&(c=this[c]);if(!_.isFunction(c))throw"invalid collectionEvents configuration";try{i.push(a.on(b,c,a))}catch(j){throw console.log("Error Binding To Collection in registerCollectionEvents",this),j}}return i}}}.call(this),function(){Luca.modules.Deferrable={configure_collection:function(a){var b,c,d;a==null&&(a=!0);if(!this.collection)return;_.isString(this.collection)&&(b=(c=Luca.CollectionManager)!=null?c.get():void 0)&&(this.collection=b.getOrCreate(this.collection)),this.collection&&_.isFunction(this.collection.fetch)&&_.isFunction(this.collection.reset)||(this.collection=new Luca.Collection(this.collection.initial_set,this.collection));if((d=this.collection)!=null?d.deferrable_trigger:void 0)this.deferrable_trigger=this.collection.deferrable_trigger;if(a)return this.deferrable=this.collection}}}.call(this),function(){Luca.modules.DomHelpers={__initializer:function(){var a,b,c,d,e;b=_(this.additionalClassNames||[]).clone(),this.wrapperClass!=null&&this.$wrap(this.wrapperClass),_.isString(b)&&(b=b.split(" ")),this.gridSpan&&b.push("span"+this.gridSpan),this.gridOffset&&b.push("offset"+this.gridOffset),this.gridRowFluid&&b.push("row-fluid"),this.gridRow&&b.push("row");if(b==null)return;e=[];for(c=0,d=b.length;c<d;c++)a=b[c],e.push(this.$el.addClass(a));return e},$wrap:function(a){return _.isString(a)&&!a.match(/[<>]/)&&(a=this.make("div",{"class":a})),this.$el.wrap(a)},$template:function(a,b){return b==null&&(b={}),this.$el.html(Luca.template(a,b))},$html:function(a){return this.$el.html(a)},$append:function(a){return this.$el.append(a)},$attach:function(){return this.$container().append(this.el)},$bodyEl:function(){return this.$el},$container:function(){return $(this.container)}}}.call(this),function(){Luca.modules.EnhancedProperties={__initializer:function(){if(Luca.config.enhancedViewProperties!==!0)return;_.isString(this.collection)&&Luca.CollectionManager.get()&&(this.collection=Luca.CollectionManager.get().getOrCreate(this.collection)),this.template!=null&&this.$template(this.template,this);if(_.isString(this.collectionManager))return this.collectionManager=Luca.CollectionManager.get(this.collectionManager)}}}.call(this),function(){var a,b=Object.prototype.hasOwnProperty,c=function(a,c){function e(){this.constructor=a}for(var d in c)b.call(c,d)&&(a[d]=c[d]);return e.prototype=c.prototype,a.prototype=new e,a.__super__=c.prototype,a};Luca.modules.Filterable={__included:function(a,b){return _.extend(Luca.Collection.prototype,{__filters:{}})},__initializer:function(a,b){var c,d=this;if(this.filterable===!1||!Luca.isBackboneCollection(this.collection))return;return this.getCollection||(this.getCollection=function(){return this.collection}),c=this.getFilterState(),c.on("change",function(a){return d.trigger("collection:change:filter",a,d.getCollection()),d.trigger("refresh")}),this.getQuery!=null?this.getQuery=_.compose(this.getQuery,function(a){var b;return a==null&&(a={}),b=_.clone(a),_.extend(b,c.toQuery())}):this.getQuery=function(){return c.toQuery()},this.getQueryOptions!=null?this.getQueryOptions=_.compose(this.getQueryOptions,function(a){var b;return a==null&&(a={}),b=_.clone(a),_.extend(b,c.toOptions())}):this.getQueryOptions=function(){return c.toOptions()}},getFilterState:function(){var b,c;return(b=this.collection.__filters)[c=this.cid]||(b[c]=new a(this.filterable))},setSortBy:function(a,b){return b==null&&(b={}),this.getFilterState().setOption("sortBy",a,b)},applyFilter:function(a,b){var c;return a==null&&(a={}),b==null&&(b={}),b=_.defaults(b,this.getQueryOptions()),a=_.defaults(a,this.getQuery()),c=_(b)["delete"]("silent")===!0,this.getFilterState().set({query:a,options:b},{silent:c})}},a=function(a){function b(){b.__super__.constructor.apply(this,arguments)}return c(b,a),b.prototype.setOption=function(a,b,c){var d;return d={},d[a]=b,this.set("options",_.extend(this.toOptions(),d),c)},b.prototype.setQueryOption=function(a,b,c){var d;return d={},d[a]=b,this.set("query",_.extend(this.toQuery(),d),c)},b.prototype.toOptions=function(){return this.toJSON().options},b.prototype.toQuery=function(){return this.toJSON().query},b}(Backbone.Model)}.call(this),function(){Luca.modules.GridLayout={_initializer:function(){this.gridSpan&&this.$el.addClass("span"+this.gridSpan),this.gridOffset&&this.$el.addClass("offset"+this.gridOffset),this.gridRowFluid&&this.$el.addClass("row-fluid");if(this.gridRow)return this.$el.addClass("row")}}}.call(this),function(){Luca.modules.LoadMaskable={__initializer:function(){var a=this;if(this.loadMask!==!0)return;if(this.loadMask===!0)return this.defer(function(){a.$el.addClass("with-mask");if(a.$(".load-mask").length===0)return a.loadMaskTarget().prepend(Luca.template(a.loadMaskTemplate,a)),a.$(".load-mask").hide()}).until("after:render"),this.on(this.loadmaskEnableEvent||"enable:loadmask",this.applyLoadMask,this),this.on(this.loadmaskDisableEvent||"disable:loadmask",this.applyLoadMask,this)},showLoadMask:function(){return this.trigger("enable:loadmask")},hideLoadMask:function(){return this.trigger("disable:loadmask")},loadMaskTarget:function(){return this.loadMaskEl!=null?this.$(this.loadMaskEl):this.$bodyEl()},disableLoadMask:function(){return this.$(".load-mask .bar").css("width","100%"),this.$(".load-mask").hide(),clearInterval(this.loadMaskInterval)},enableLoadMask:function(){var a,b=this;this.$(".load-mask").show().find(".bar").css("width","0%"),a=this.$(".load-mask .progress").width(),a<20&&(a=this.$el.width())<20&&(a=this.$el.parent().width()),this.loadMaskInterval=setInterval(function(){var a,c;return a=b.$(".load-mask .bar").width(),c=a+12,b.$(".load-mask .bar").css("width",c)},200);if(this.loadMaskTimeout==null)return;return _.delay(function(){return b.disableLoadMask()},this.loadMaskTimeout)},applyLoadMask:function(){return this.$(".load-mask").is(":visible")?this.disableLoadMask():this.enableLoadMask()}}}.call(this),function(){Luca.LocalStore=function(){function a(a){var b;this.name=a,b=localStorage.getItem(this.name),this.data=b&&JSON.parse(b)||{}}return a.prototype.guid=function(){var a;return a=function(){return((1+Math.random())*65536|0).toString(16).substring(1)},a()+a()+"-"+a()+"-"+a()+"-"+a()+"-"+a()+a()+a()},a.prototype.save=function(){return localStorage.setItem(this.name,JSON.stringify(this.data))},a.prototype.create=function(a){return a.id||(a.id=a.attribtues.id=this.guid()),this.data[a.id]=a,this.save(),a},a.prototype.update=function(a){return this.data[a.id]=a,this.save(),a},a.prototype.find=function(a){return this.data[a.id]},a.prototype.findAll=function(){return _.values(this.data)},a.prototype.destroy=function(a){return delete this.data[a.id],this.save(),a},a}(),Backbone.LocalSync=function(a,b,c){var d,e;return e=b.localStorage||b.collection.localStorage,d=function(){switch(a){case"read":return b.id?e.find(b):e.findAll();case"create":return e.create(b);case"update":return e.update(b);case"delete":return e.destroy(b)}}(),d?c.success(d):c.error("Record not found")}}.call(this),function(){var a;Luca.modules.ModalView={closeOnEscape:!0,showOnInitialize:!1,backdrop:!1,__initializer:function(){return this.$el.addClass("modal"),this.on("before:render",a,this),this},container:function(){return $("body")},toggle:function(){return this.$el.modal("toggle")},show:function(){return this.$el.modal("show")},hide:function(){return this.$el.modal("hide")}},a=function(){return this.$el.addClass("modal"),this.fade===!0&&this.$el.addClass("fade"),$("body").append(this.$el),this.$el.modal({backdrop:this.backdrop===!0,keyboard:this.closeOnEscape===!0,show:this.showOnInitialize===!0}),this}}.call(this),function(){Luca.modules.Paginatable={paginatorViewClass:"Luca.components.PaginationControl",paginationSelector:".toolbar.bottom",__included:function(){return _.extend(Luca.Collection.prototype,{__paginators:{}})},__initializer:function(){var a,b,c,d=this;if(this.paginatable===!1||!Luca.isBackboneCollection(this.collection))return;return _.bindAll(this,"paginationControl"),this.getCollection||(this.getCollection=function(){return this.collection}),a=this.getCollection(),c=this.getPaginationState(),c.on("change",function(b){return d.trigger("collection:change:pagination",b,a),d.trigger("refresh")}),this.on("after:refresh",function(a,b,c){return _.defer(function(){return d.updatePagination.call(d,a,b,c)})}),this.on("after:render",function(){return d.paginationControl().refresh()}),(b=this.getQueryOptions)?this.getQueryOptions=function(){return _.extend(b(),c.toJSON())}:this.getQueryOptions=function(){return c.toJSON()}},getPaginationState:function(){var a,b;return(a=this.collection.__paginators)[b=this.cid]||(a[b]=this.paginationControl().state)},paginationContainer:function(){return this.$(">"+this.paginationSelector)},setCurrentPage:function(a,b){return a==null&&(a=1),b==null&&(b={}),this.getPaginationState().set("page",a,b)},setLimit:function(a,b){return a==null&&(a=0),b==null&&(b={}),this.getPaginationState().set("limit",a,b)},updatePagination:function(a,b,c){var d,e,f,g;return a==null&&(a=[]),b==null&&(b={}),c==null&&(c={}),_.defaults(c,this.getQueryOptions(),{limit:0}),e=this.paginationControl(),d=(a!=null?a.length:void 0)||0,f=(g=this.getCollection())!=null?g.length:void 0,d===0||f<=c.limit?e.$el.hide():e.$el.show(),e.state.set({page:c.page,limit:c.limit})},paginationControl:function(){return this.paginator!=null?this.paginator:(_.defaults(this.paginatable||(this.paginatable={}),{page:1,limit:20}),this.paginator=Luca.util.lazyComponent({type:"pagination_control",collection:this.getCollection(),defaultState:this.paginatable}),this.paginator)},renderPaginationControl:function(){return this.paginationControl(),this.paginationContainer().append(this.paginationControl().render().$el)}}}.call(this),function(){Luca.modules.StateModel={__initializer:function(){var a=this;if(this.stateful!==!0)return;if(this.state!=null&&!Luca.isBackboneModel(this.state))return;return this.state=new Backbone.Model(this.defaultState||{}),this.set||(this.set=function(){return a.state.set.apply(a.state,arguments)}),this.get||(this.get=function(){return a.state.get.apply(a.state,arguments)}),this.state.on("change",function(b){var c,d,e,f,g,h;a.trigger("state:change",b),d=b.previousAttributes(),g=b.changedAttributes,h=[];for(e=0,f=g.length;e<f;e++)c=g[e],h.push(a.trigger("state:change:"+c,e,b.previous(c)));return h})}}}.call(this),function(){Luca.modules.Templating={__initializer:function(){var a,b,c;c=Luca.util.read.call(this,this.bodyTemplateVars)||{};if(a=this.bodyTemplate)return this.$el.empty(),b=Luca.template(a,c),Luca.View.prototype.$html.call(this,b)}}}.call(this),function(){var a,b;b={classes:{},model_classes:{},collection_classes:{},namespaces:["Luca.containers","Luca.components"]},a={cid_index:{},name_index:{}},Luca.config.defaultComponentClass=Luca.defaultComponentClass="Luca.View",Luca.config.defaultComponentType=Luca.defaultComponentType="view",Luca.registry.aliases={grid:"grid_view",form:"form_view",text:"text_field",button:"button_field",select:"select_field",card:"card_view",paged:"card_view",wizard:"card_view",collection:"collection_view",list:"collection_view",multi:"collection_multi_view",table:"table_view"},Luca.registerComponent=function(a,c,d){d==null&&(d="view"),Luca.trigger("component:registered",a,c);switch(d){case"model":return b.model_classes[a]=c;case"collection":return b.collection_classes[a]=c;default:return b.classes[a]=c}},Luca.development_mode_register=function(a,c){var d,e,f;return d=b.classes[a],Luca.enableDevelopmentTools===!0&&d!=null&&(f=Luca.util.resolve(d,window),e=Luca.registry.findInstancesByClassName(c),_(e).each(function(a){var b;return a!=null?(b=a.refreshCode)!=null?b.call(a,f):void 0:void 0})),Luca.registerComponent(a,c)},Luca.registry.addNamespace=Luca.registry.namespace=function(a){return b.namespaces.push(a),b.namespaces=_(b.namespaces).uniq()},Luca.registry.namespaces=function(a){return a==null&&(a=!0),_(b.namespaces).map(function(b){return a?Luca.util.resolve(b):b})},Luca.registry.lookup=function(a){var c,d,e,f,g,h;if(c=Luca.registry.aliases[a])a=c;return d=b.classes[a],d!=null?d:(e=Luca.util.classify(a),g=Luca.registry.namespaces(),f=(h=_(g).chain().map(function(a){return a[e]}).compact().value())!=null?h[0]:void 0)},Luca.registry.instances=function(){return _(a.cid_index).values()},Luca.registry.findInstancesByClass=function(a){return Luca.registry.findInstancesByClassName(a.displayName)},Luca.registry.findInstancesByClassName=function(a){var b;return _.isString(a)||(a=a.displayName),b=Luca.registry.instances(),_(b).select(function(b){var c,d;return c=b.displayName===a,b.displayName===a||(typeof b._superClass=="function"?(d=b._superClass())!=null?d.displayName:void 0:void 0)===a})},Luca.registry.classes=function(a){return a==null&&(a=!1),_(_.extend({},b.classes,b.model_classes,b.collection_classes)).map(function(b,c){return a?b:{className:b,ctype:c}})},Luca.cache=Luca.cacheInstance=function(b,c){var d;if(b==null)return;return(c!=null?c.doNotCache:void 0)===!0?c:(c!=null&&(a.cid_index[b]=c),c=a.cid_index[b],(c!=null?c.component_name:void 0)!=null?a.name_index[c.component_name]=c.cid:(c!=null?c.name:void 0)!=null&&(a.name_index[c.name]=c.cid),c!=null?c:(d=a.name_index[b],a.cid_index[d]))}}.call(this),function(){var a=Array.prototype.slice;Luca.Observer=function(){function b(a){var b=this;this.options=a!=null?a:{},_.extend(this,Backbone.Events),this.type=this.options.type,this.options.debugAll&&this.bind("all",function(a,b,c){return console.log("ALL",a,b,c)})}return b.prototype.relay=function(){var b,c;return c=arguments[0],b=2<=arguments.length?a.call(arguments,1):[],console.log("Relaying",trigger,b),this.trigger("event",c,b),this.trigger("event:"+b[0],c,b.slice(1))},b}(),Luca.Observer.enableObservers=function(a){return a==null&&(a={}),Luca.enableGlobalObserver=!0,Luca.ViewObserver=new Luca.Observer(_.extend(a,{type:"view"})),Luca.CollectionObserver=new Luca.Observer(_.extend(a,{type:"collection"}))}}.call(this),function(){var a,b,c;c=Luca.register("Luca.View"),c["extends"]("Backbone.View"),c.includes("Luca.Events","Luca.modules.DomHelpers"),c.mixesIn("DomHelpers","Templating","EnhancedProperties","CollectionEventBindings","ApplicationEventBindings","StateModel"),c.triggers("before:initialize","after:initialize","before:render","after:render","first:activation","activation","deactivation"),c.defines({initialize:function(b){var c,d,e,f,g,h,i;this.options=b!=null?b:{},this.trigger("before:initialize",this,this.options),_.extend(this,this.options),(this.autoBindEventHandlers===!0||this.bindAllEvents===!0)&&a.call(this),this.name!=null&&(this.cid=_.uniqueId(this.name)),this.$el.attr("data-luca-id",this.name||this.cid),Luca.cacheInstance(this.cid,this),this.setupHooks(_(Luca.View.prototype.hooks.concat(this.hooks)).uniq());if(((f=this.mixins)!=null?f.length:void 0)>0){g=this.mixins;for(d=0,e=g.length;d<e;d++)c=g[d],(h=Luca.mixin(c))!=null&&(i=h.__initializer)!=null&&i.call(this,this,c)}return this.delegateEvents(),this.trigger("after:initialize",this)},setupHooks:function(a){var b=this;return a||(a=this.hooks),_(a).each(function(a){var c,d;d=Luca.util.hook(a),c=function(){var a;return(a=this[d])!=null?a.apply(this,arguments):void 0};if(a!=null?a.match(/once:/):void 0)c=_.once(c);return b.on(a,c,b)})},registerEvent:function(a,b){return this.events||(this.events={}),this.events[a]=b,this.delegateEvents()},definitionClass:function(){var a;return(a=Luca.util.resolve(this.displayName,window))!=null?a.prototype:void 0},collections:function(){return Luca.util.selectProperties(Luca.isBackboneCollection,this)},models:function(){return Luca.util.selectProperties(Luca.isBackboneModel,this)},views:function(){return Luca.util.selectProperties(Luca.isBackboneView,this)},debug:function(){var a,b,c,d;if(!this.debugMode&&window.LucaDebugMode==null)return;d=[];for(b=0,c=arguments.length;b<c;b++)a=arguments[b],d.push(console.log([this.name||this.cid,a]));return d},trigger:function(){return Luca.enableGlobalObserver&&(Luca.developmentMode===!0||this.observeEvents===!0)&&(Luca.ViewObserver||(Luca.ViewObserver=new Luca.Observer({type:"view"})),Luca.ViewObserver.relay(this,arguments)),Backbone.View.prototype.trigger.apply(this,arguments)}}),Luca.View._originalExtend=Backbone.View.extend,Luca.View.renderWrapper=function(a){var b;return b=a.render,b||(b=Luca.View.prototype.$attach),a.render=function(){var a,d,e,f,g,h=this;return c=this,this.deferrable?(f=this.deferrable_target,Luca.isBackboneCollection(this.deferrable)||(this.deferrable=this.collection),f||(f=this.deferrable),g=this.deferrable_event?this.deferrable_event:Luca.View.deferrableEvent,d=function(){return b.call(c),c.trigger("after:render",c)},c.defer(d).until(f,g),c.trigger("before:render",this),a=this.deferrable_trigger||this.deferUntil,a==null?f[this.deferrable_method||"fetch"].call(f):(e=_.once(function(){var a,b;return typeof (a=h.deferrable)[b=h.deferrable_method||"fetch"]=="function"?a[b]():void 0}),(this.deferrable_target||this).bind(this.deferrable_trigger,e)),this):(this.trigger("before:render",this),b.apply(this,arguments),this.trigger("after:render",this),this)},a},a=function(){var a,c,d,e,f;e=[this.events,this.componentEvents,this.collectionEvents,this.applicationEvents],f=[];for(c=0,d=e.length;c<d;c++)a=e[c],_.isEmpty(a)||f.push(b.call(this,a));return f},b=function(a){var b,c,d;a==null&&(a={}),d=[];for(b in a)c=a[b],_.isString(c)?d.push(_.bindAll(this,c)):d.push(void 0);return d},Luca.View.extend=function(a){var b,c,d,e;a=Luca.View.renderWrapper(a);if(a.mixins!=null&&_.isArray(a.mixins)){e=a.mixins;for(c=0,d=e.length;c<d;c++)b=e[c],Luca.decorate(a)["with"](b)}return Luca.View._originalExtend.call(this,a)},Luca.View.deferrableEvent="reset"}.call(this),function(){var a,b;a=Luca.define("Luca.Model"),a["extends"]("Backbone.Model"),a.includes("Luca.Events"),a.defines({initialize:function(){return Backbone.Model.prototype.initialize(this,arguments),b.call(this)},read:function(a){return _.isFunction(this[a])?this[a].call(this):this.get(a)},get:function(a){var b;return((b=this.computed)!=null?b.hasOwnProperty(a):void 0)?this._computed[a]:Backbone.Model.prototype.get.call(this,a)}}),b=function(){var a,b,c,d,e=this;if(_.isUndefined(this.computed))return;this._computed={},c=this.computed,d=[];for(a in c)b=c[a],this.on("change:"+a,function(){return e._computed[a]=e[a].call(e)}),_.isString(b)&&(b=b.split(",")),d.push(_(b).each(function(b){e.on("change:"+b,function(){return e.trigger("change:"+a)});if(e.has(b))return e.trigger("change:"+a)}));return d}}.call(this),function(){var a;a=Luca.define("Luca.Collection"),Backbone.QueryCollection!=null?a["extends"]("Backbone.QueryCollection"):a["extends"]("Backbone.Collection"),a.includes("Luca.Events"),a.defines({model:Luca.Model,cachedMethods:[],remoteFilter:!1,initialize:function(a,b){var c,d=this;a==null&&(a=[]),this.options=b,_.extend(this,this.options),this.setupMethodCaching(),this._reset(),this.cached&&console.log("The @cached property of Luca.Collection is being deprecated. Please change to cache_key");if(this.cache_key||(this.cache_key=this.cached))this.bootstrap_cache_key=_.isFunction(this.cache_key)?this.cache_key():this.cache_key;(this.registerAs||this.registerWith)&&console.log("This configuration API is deprecated. use @name and @manager properties instead"),this.name||(this.name=this.registerAs),this.manager||(this.manager=this.registerWith),this.manager=_.isFunction(this.manager)?this.manager():this.manager,this.name&&!this.manager&&(this.manager=Luca.CollectionManager.get()),this.manager&&(this.name||(this.name=this.cache_key()),this.name=_.isFunction(this.name)?this.name():this.name,!this.private&&!this.anonymous&&this.bind("after:initialize",function(){return d.register(d.manager,d.name,d)}));if(this.useLocalStorage===!0&&window.localStorage!=null)throw c=this.bootstrap_cache_key||this.name,"Must specify either a cached or registerAs property to use localStorage";return _.isArray(this.data)&&this.data.length>0&&(this.memoryCollection=!0),this.useNormalUrl!==!0&&this.__wrapUrl(),Backbone.Collection.prototype.initialize.apply(this,[a,this.options]),a&&this.reset(a,{silent:!0,parse:b!=null?b.parse:void 0}),this.trigger("after:initialize")},__wrapUrl:function(){var a,b,c=this;return _.isFunction(this.url)?this.url=_.wrap(this.url,function(a){var b,d,e,f,g;return g=a.apply(c),e=g.split("?"),e.length>1&&(b=_.last(e)),f=c.queryString(),b&&g.match(b)&&(f=f.replace(b,"")),d=""+g+"?"+f,d.match(/\?$/)&&(d=d.replace(/\?$/,"")),d}):(b=this.url,a=this.queryString(),this.url=_([b,a]).compact().join("?"))},queryString:function(){var a,b=this;return a=_(this.base_params||(this.base_params=Luca.Collection.baseParams())).inject(function(a,b,c){var d;return d=""+c+"="+b,a.push(d),a},[]),_.uniq(a).join("&")},resetFilter:function(){return this.base_params=_(Luca.Collection.baseParams()).clone(),this},applyFilter:function(a,b){return a==null&&(a={}),b==null&&(b={}),b.remote!=null==1||this.remoteFilter===!0?(this.applyParams(a),this.fetch(_.extend(b,{refresh:!0}))):this.reset(this.query(a))},applyParams:function(a){return this.base_params=_(Luca.Collection.baseParams()).clone(),_.extend(this.base_params,a),this},register:function(a,b,c){a==null&&(a=Luca.CollectionManager.get()),b==null&&(b="");if(!(b.length>=1))throw"Can not register with a collection manager without a key";if(a==null)throw"Can not register with a collection manager without a valid collection manager";_.isString(a)&&(a=Luca.util.nestedValue(a,window||global));if(!a)throw"Could not register with collection manager";if(_.isFunction(a.add))return a.add(b,c);if(_.isObject(a))return a[b]=c},loadFromBootstrap:function(){if(!this.bootstrap_cache_key)return;return this.reset(this.cached_models()),this.trigger("bootstrapped",this)},bootstrap:function(){return this.loadFromBootstrap()},cached_models:function(){return Luca.Collection.cache(this.bootstrap_cache_key)},fetch:function(a){var b;a==null&&(a={}),this.trigger("before:fetch",this);if(this.memoryCollection===!0)return this.reset(this.data);if(this.cached_models().length&&!a.refresh)return this.bootstrap();b=_.isFunction(this.url)?this.url():this.url;if(!(b&&b.length>1||this.localStorage))return!0;this.fetching=!0;try{return Backbone.Collection.prototype.fetch.apply(this,arguments)}catch(c){throw console.log("Error in Collection.fetch",c),c}},onceLoaded:function(a,b){var c,d=this;b==null&&(b={autoFetch:!0});if(this.length>0&&!this.fetching){a.apply(this,[this]);return}c=function(){return a.apply(d,[d])},this.bind("reset",function(){return c(),this.unbind("reset",this)});if(!this.fetching&&!!b.autoFetch)return this.fetch()},ifLoaded:function(a,b){var c,d=this;b==null&&(b={scope:this,autoFetch:!0}),c=b.scope||this,this.length>0&&!this.fetching&&a.apply(c,[this]),this.bind("reset",function(b){return a.call(c,b)});if(!(this.fetching===!0||!b.autoFetch||this.length>0))return this.fetch()},parse:function(a){var b;return this.fetching=!1
7
+ ,this.trigger("after:response",a),b=this.root!=null?a[this.root]:a,this.bootstrap_cache_key&&Luca.Collection.cache(this.bootstrap_cache_key,b),b},restoreMethodCache:function(){var a,b,c,d;c=this._methodCache,d=[];for(b in c)a=c[b],a.original!=null?(a.args=void 0,d.push(this[b]=a.original)):d.push(void 0);return d},clearMethodCache:function(a){return this._methodCache[a].value=void 0},clearAllMethodsCache:function(){var a,b,c,d;c=this._methodCache,d=[];for(b in c)a=c[b],d.push(this.clearMethodCache(b));return d},setupMethodCaching:function(){var b,c;return a=this,c=["reset","add","remove"],b=this._methodCache={},_(this.cachedMethods).each(function(d){var e,f,g,h,i,j,k,l,m;b[d]={name:d,original:a[d],value:void 0},a[d]=function(){var c;return(c=b[d]).value||(c.value=b[d].original.apply(a,arguments))};for(h=0,j=c.length;h<j;h++)g=c[h],a.bind(g,function(){return a.clearAllMethodsCache()});e=d.split(":")[1];if(e){l=e.split(","),m=[];for(i=0,k=l.length;i<k;i++)f=l[i],m.push(a.bind("change:"+f,function(){return a.clearMethodCache({method:d})}));return m}})},query:function(a,b){return a==null&&(a={}),b==null&&(b={}),Backbone.QueryCollection!=null?Backbone.QueryCollection.prototype.query.apply(this,arguments):this.models}}),_.extend(Luca.Collection.prototype,{trigger:function(){return Luca.enableGlobalObserver&&(Luca.CollectionObserver||(Luca.CollectionObserver=new Luca.Observer({type:"collection"})),Luca.CollectionObserver.relay(this,arguments)),Backbone.View.prototype.trigger.apply(this,arguments)}}),Luca.Collection.baseParams=function(a){if(a)return Luca.Collection._baseParams=a;if(_.isFunction(Luca.Collection._baseParams))return Luca.Collection._baseParams();if(_.isObject(Luca.Collection._baseParams))return Luca.Collection._baseParams},Luca.Collection._bootstrapped_models={},Luca.Collection.bootstrap=function(a){return _.extend(Luca.Collection._bootstrapped_models,a)},Luca.Collection.cache=function(a,b){return b?Luca.Collection._bootstrapped_models[a]=b:Luca.Collection._bootstrapped_models[a]||[]}}.call(this),function(){var a;a=function(a,b){var c,d,e,f,g;return a==null&&(a={}),a.orientation||(a.orientation="top"),a.ctype||(a.ctype=this.toolbarType||"panel_toolbar"),f=""+this.cid+"-tbc-"+a.orientation,g=Luca.util.lazyComponent(a),d=this.make("div",{"class":"toolbar-container "+a.orientation,id:f},g.render().el),e=this.bodyClassName||this.bodyTagName,c=function(){switch(a.orientation){case"top":case"left":return e?"before":"prepend";case"bottom":case"right":return e?"after":"append"}}(),(b||this.$bodyEl())[c](d)},_.def("Luca.components.Panel")["extends"]("Luca.View")["with"]({topToolbar:void 0,bottomToolbar:void 0,loadMask:!1,loadMaskTemplate:["components/load_mask"],loadMaskTimeout:3e3,mixins:["LoadMaskable"],initialize:function(a){return this.options=a!=null?a:{},Luca.View.prototype.initialize.apply(this,arguments)},applyStyles:function(a,b){var c,d,e;a==null&&(a={}),b==null&&(b=!1),d=b?this.$bodyEl():this.$el;for(c in a)e=a[c],d.css(c,e);return this},beforeRender:function(){var a;return(a=Luca.View.prototype.beforeRender)!=null&&a.apply(this,arguments),this.styles!=null&&this.applyStyles(this.styles),this.bodyStyles!=null&&this.applyStyles(this.bodyStyles,!0),typeof this.renderToolbars=="function"?this.renderToolbars():void 0},$bodyEl:function(){var a,b,c,d;return c=this.bodyTagName||"div",b=this.bodyClassName||"view-body",this.bodyEl||(this.bodyEl=""+c+"."+b),a=this.$(this.bodyEl),a.length>0?a:a.length!==0||this.bodyClassName==null&&this.bodyTagName==null?$(this.el):(d=this.make(c,{"class":b,"data-auto-appended":!0}),$(this.el).append(d),this.$(this.bodyEl))},$wrap:function(a){return _.isString(a)&&!a.match(/[<>]/)&&(a=this.make("div",{"class":a})),this.$el.wrap(a)},$template:function(a,b){return b==null&&(b={}),this.$html(Luca.template(a,b))},$empty:function(){return this.$bodyEl().empty()},$html:function(a){return this.$bodyEl().html(a)},$append:function(a){return this.$bodyEl().append(a)},renderToolbars:function(){var a=this;return _(["top","left","right","bottom"]).each(function(b){var c;if(c=a[""+b+"Toolbar"])return a.renderToolbar(b,c)})},renderToolbar:function(b,c){return b==null&&(b="top"),c==null&&(c={}),c.parent=this,c.orientation=b,a.call(this,c,c.targetEl)}})}.call(this),function(){_.def("Luca.core.Field")["extends"]("Luca.View")["with"]({className:"luca-ui-text-field luca-ui-field",isField:!0,template:"fields/text_field",labelAlign:"top",hooks:["before:validation","after:validation","on:change"],statuses:["warning","error","success"],initialize:function(a){var b;return this.options=a!=null?a:{},_.extend(this,this.options),this.input_id||(this.input_id=_.uniqueId("field")),this.input_name||(this.input_name=this.name),this.input_class||(this.input_class=""),this.input_type||(this.input_type=""),this.helperText||(this.helperText=""),this.required&&((b=this.label)!=null?!b.match(/^\*/):!void 0)&&(this.label||(this.label="*"+this.label)),this.inputStyles||(this.inputStyles=""),this.input_value||(this.input_value=this.value||""),this.disabled&&this.disable(),this.updateState(this.state),this.placeHolder||(this.placeHolder=""),Luca.View.prototype.initialize.apply(this,arguments)},beforeRender:function(){Luca.enableBootstrap&&this.$el.addClass("control-group");if(this.required)return this.$el.addClass("required")},change_handler:function(a){return this.trigger("on:change",this,a)},disable:function(){return this.getInputElement().attr("disabled",!0)},enable:function(){return this.getInputElement().attr("disabled",!1)},getValue:function(){var a,b;a=(b=this.getInputElement())!=null?b.attr("value"):void 0;if(_.str.isBlank(a))return a;switch(this.valueType){case"integer":return parseInt(a);case"string":return""+a;case"float":return parseFloat(a);default:return a}},setValue:function(a){var b;return(b=this.getInputElement())!=null?b.attr("value",a):void 0},getInputElement:function(){return this.input||(this.input=this.$("input").eq(0))},updateState:function(a){var b=this;return _(this.statuses).each(function(c){return b.$el.removeClass(c),b.$el.addClass(a)})}})}.call(this),function(){var a,b,c,d,e,f,g,h;b=Luca.register("Luca.core.Container"),b["extends"]("Luca.components.Panel"),b.triggers("before:components","before:render:components","before:layout","after:components","after:layout","first:activation"),b.defines({className:"luca-ui-container",componentTag:"div",componentClass:"luca-ui-panel",isContainer:!0,rendered:!1,components:[],componentEvents:{},initialize:function(a){return this.options=a!=null?a:{},_.extend(this,this.options),this.setupHooks(Luca.core.Container.prototype.hooks),this.components||(this.components=this.fields||(this.fields=this.pages||(this.pages=this.cards||(this.cards=this.views)))),h(this),Luca.View.prototype.initialize.apply(this,arguments)},beforeRender:function(){var a;return f.call(this),e.call(this),(a=Luca.components.Panel.prototype.beforeRender)!=null?a.apply(this,arguments):void 0},customizeContainerEl:function(a,b,c){return a},prepareLayout:function(){return b=this,this.componentContainers=_(this.components).map(function(c,d){return a.call(b,c,d)})},prepareComponents:function(){var a,b,c,d,e=this;d=this.components;for(b=0,c=d.length;b<c;b++)a=d[b],_.isString(a)&&(a={type:a});return _(this.components).each(function(a,b){var c,d,f,g;c=d=(g=e.componentContainers)!=null?g[b]:void 0,c["class"]=c["class"]||c.className||c.classes,e.generateComponentElements&&(f=e.make(e.componentTag,d,""),e.$append(f));if(a.container==null)return e.generateComponentElements&&(a.container="#"+d.id),a.container||(a.container=e.$bodyEl())})},createComponents:function(){var a,c=this;if(this.componentsCreated===!0)return;return a=this.componentIndex={name_index:{},cid_index:{},role_index:{}},b=this,this.components=_(this.components).map(function(a,d){var e,f;return e=Luca.isBackboneView(a)?a:(a.type||(a.type=a.ctype),a.type==null?a.components!=null?a.type=a.ctype="container":a.type=a.ctype=Luca.defaultComponentType:void 0,a=_.defaults(a,b.defaults||{}),f=Luca.util.lazyComponent(a)),!e.container&&e.options.container&&(e.container=e.options.container),g(e).at(d)["in"](c.componentIndex),e}),this.componentsCreated=!0,a},renderComponents:function(a){return this.debugMode=a!=null?a:"",this.debug("container render components"),b=this,_(this.components).each(function(a){a.getParent=function(){return b};try{return $(a.container).append(a.el),a.render()}catch(c){console.log("Error Rendering Component "+(a.name||a.cid),a),_.isObject(c)&&(console.log(c.message),console.log(c.stack));if(Luca.silenceRenderErrors!=null!=1)throw c}})},firstActivation:function(){var a;return a=this,this.each(function(b,c){var d;if((b!=null?b.previously_activated:void 0)!==!0)return b!=null&&(d=b.trigger)!=null&&d.call(b,"first:activation",b,a),b.previously_activated=!0})},_:function(){return _(this.components)},pluck:function(a){return this._().pluck(a)},invoke:function(a){return this._().invoke(a)},select:function(a){return this._().select(a)},detect:function(a){return this._().detect(attribute)},reject:function(a){return this._().reject(a)},map:function(a){return this._().map(a)},registerComponentEvents:function(){var a,c,d,e,f,g,h,i,j=this;b=this,g=this.componentEvents||{},i=[];for(f in g){e=g[f],h=f.split(" "),c=h[0],d=h[1];if(!_.isFunction(this[e]))throw console.log("Error registering component event",f,c,d),"Invalid component event definition "+f+". Specified handler is not a method on the container";if(c==="*")i.push(this.eachComponent(function(a){return a.on(d,j[e],b)}));else{a=this.findComponentForEventBinding(c);if(a==null||!Luca.isComponent(a))throw console.log("Error registering component event",f,c,d),"Invalid component event definition: "+c;i.push(a!=null?a.bind(d,this[e],b):void 0)}}return i},subContainers:function(){return this.select(function(a){return a.isContainer===!0})},roles:function(){return _(this.allChildren()).pluck("role")},allChildren:function(){var a,b;return a=this.components,b=_(this.subContainers()).invoke("allChildren"),this._allChildren||(this._allChildren=_([a,b]).chain().compact().flatten().uniq().value())},findComponentForEventBinding:function(a,b){return b==null&&(b=!1),this.findComponentByName(a,b)||this.findComponentByGetter(a,b)||this.findComponentByRole(a,b)},findComponentByGetter:function(a,b){return b==null&&(b=!1),_(this.allChildren()).detect(function(b){return b.getter===a})},findComponentByRole:function(a,b){return b==null&&(b=!1),_(this.allChildren()).detect(function(b){return b.role===a})},findComponentByName:function(a,b){return b==null&&(b=!1),_(this.allChildren()).detect(function(b){return b.name===a})},findComponentById:function(a,b){return b==null&&(b=!1),this.findComponent(a,"cid_index",b)},findComponent:function(a,b,c){var d,e,f,g;b==null&&(b="name"),c==null&&(c=!1),this.componentsCreated!==!0&&this.createComponents(),e=(g=this.componentIndex)!=null?g[b][a]:void 0,d=this.components[e];if(d)return d;if(c===!0)return f=_(this.components).detect(function(c){return c!=null?typeof c.findComponent=="function"?c.findComponent(a,b,!0):void 0:void 0}),f!=null?typeof f.findComponent=="function"?f.findComponent(a,b,!0):void 0:void 0},each:function(a){return this.eachComponent(a,!1)},eachComponent:function(a,b){var c=this;return b==null&&(b=!0),_(this.components).each(function(c,d){var e;a.call(c,c,d);if(b)return c!=null?(e=c.eachComponent)!=null?e.apply(c,[a,b]):void 0:void 0})},indexOf:function(a){var b;return b=_(this.components).pluck("name"),_(b).indexOf(a)},activeComponent:function(){return this.activeItem?this.components[this.activeItem]:this},componentElements:function(){return this.$("[data-luca-parent='"+(this.name||this.cid)+"']")},getComponent:function(a){return this.components[a]},isRootComponent:function(){return this.getParent==null},getRootComponent:function(){return this.isRootComponent()?this:this.getParent().getRootComponent()},selectByAttribute:function(a,b,c){var d;return b==null&&(b=void 0),c==null&&(c=!1),d=_(this.components).map(function(d){var e,f;return e=[],f=d[a],(f===b||b==null&&f!=null)&&e.push(d),c===!0&&e.push(typeof d.selectByAttribute=="function"?d.selectByAttribute(a,b,!0):void 0),_.compact(e)}),_.flatten(d)}}),Luca.core.Container.componentRenderer=function(a,b){var c;return c=$(b.container)[b.attachWith||"append"],c(b.render().el)},f=function(){return this.trigger("before:layout",this),this.prepareLayout(),this.trigger("after:layout",this)},a=function(a,b){var c,d;return d=[],a.height!=null&&d.push("height: "+(_.isNumber(a.height)?a.height+"px":a.height)),a.width!=null&&d.push("width: "+(_.isNumber(a.width)?a.width+"px":a.width)),a.float&&d.push("float: "+a.float),c={"class":(a!=null?a.classes:void 0)||this.componentClass,id:""+this.cid+"-"+b,style:d.join(";"),"data-luca-parent":this.name||this.cid},this.customizeContainerEl!=null&&(c=this.customizeContainerEl(c,a,b)),c},c=function(){var a;return b=this,a=_(this.allChildren()).select(function(a){return a.getter!=null}),_(a).each(function(a){var c;return b[c=a.getter]||(b[c]=function(){return console.log("getter is being deprecated in favor of role"),console.log(a.getter,a,b),a})})},d=function(){var a;return b=this,a=_(this.allChildren()).select(function(a){return a.role!=null}),_(a).each(function(a){var c;return c=_.str.camelize("get_"+a.role),b[c]||(b[c]=function(){return a})})},e=function(){return this.trigger("before:components",this,this.components),this.prepareComponents(),this.createComponents(),this.trigger("before:render:components",this,this.components),this.renderComponents(),this.trigger("after:components",this,this.components),c.call(this),d.call(this),this.registerComponentEvents()},h=function(){return!0},g=function(a){return{at:function(b){return{"in":function(c){a.cid!=null&&(c.cid_index[a.cid]=b),a.role!=null&&(c.role_index[a.role]=b);if(a.name!=null)return c.name_index[a.name]=b}}}}}}.call(this),function(){var a,b,c;Luca.CollectionManager=function(){function c(a){var c,d,e,f;this.options=a!=null?a:{},_.extend(this,this.options),d=this;if(c=typeof (e=Luca.CollectionManager).get=="function"?e.get(this.name):void 0)throw"Attempt to create a collection manager with a name which already exists";(f=Luca.CollectionManager).instances||(f.instances={}),_.extend(this,Backbone.Events),_.extend(this,Luca.Events),Luca.CollectionManager.instances[this.name]=d,Luca.CollectionManager.get=function(a){return a==null?d:Luca.CollectionManager.instances[a]},this.state=new Luca.Model,this.initialCollections&&b.call(this)}return c.prototype.name="primary",c.prototype.collectionNamespace=Luca.Collection.namespace,c.prototype.__collections={},c.prototype.relayEvents=!0,c.prototype.add=function(a,b){var c;return(c=this.currentScope())[a]||(c[a]=b)},c.prototype.allCollections=function(){return _(this.currentScope()).values()},c.prototype.create=function(b,c,d){var e,f,g;c==null&&(c={}),d==null&&(d=[]),e=c.base,e||(e=a.call(this,b)),c.private&&(c.name="");try{f=new e(d,c)}catch(h){throw console.log("Error creating collection",e,c,b),h}return this.add(b,f),g=this,this.relayEvents===!0&&this.bind("*",function(){return console.log("Relay Events on Collection Manager *",f,arguments)}),f},c.prototype.currentScope=function(){var a,b;return(a=this.getScope())?(b=this.__collections)[a]||(b[a]={}):this.__collections},c.prototype.each=function(a){return _(this.all()).each(a)},c.prototype.get=function(a){return this.currentScope()[a]},c.prototype.getScope=function(){return},c.prototype.destroy=function(a){var b;return b=this.get(a),delete this.currentScope()[a],b},c.prototype.getOrCreate=function(a,b,c){return b==null&&(b={}),c==null&&(c=[]),this.get(a)||this.create(a,b,c,!1)},c.prototype.collectionCountDidChange=function(){if(this.allCollectionsLoaded())return this.trigger("all_collections_loaded"),this.trigger("initial:load")},c.prototype.allCollectionsLoaded=function(){return this.totalCollectionsCount()===this.loadedCollectionsCount()},c.prototype.totalCollectionsCount=function(){return this.state.get("collections_count")},c.prototype.loadedCollectionsCount=function(){return this.state.get("loaded_collections_count")},c.prototype.private=function(a,b,c){return b==null&&(b={}),c==null&&(c=[]),this.create(a,b,c,!0)},c}(),Luca.CollectionManager.isRunning=function(){return _.isEmpty(Luca.CollectionManager.instances)!==!0},Luca.CollectionManager.destroyAll=function(){return Luca.CollectionManager.instances={}},Luca.CollectionManager.loadCollectionsByName=function(a,b){var c,d,e,f,g;g=[];for(e=0,f=a.length;e<f;e++)d=a[e],c=this.getOrCreate(d),c.once("reset",function(){return b(c)}),g.push(c.fetch());return g},a=function(a){var b,c,d,e;return b=Luca.util.classify(a),c=(this.collectionNamespace||window||global)[b],c||(c=(this.collectionNamespace||window||global)[""+b+"Collection"]),c==null&&((e=Luca.Collection.namespaces)!=null?e.length:void 0)>0&&(d=_(Luca.Collection.namespaces.reverse()).map(function(a){return Luca.util.resolve(""+a+"."+b)||Luca.util.resolve(""+a+"."+b+"Collection")}),d=_(d).compact(),d.length>0&&(c=d[0])),c},c=function(){var a,b,c=this;return a=function(a){var b;return b=c.state.get("loaded_collections_count"),c.state.set("loaded_collections_count",b+1),c.trigger("collection_loaded",a.name),a.unbind("reset")},b=this.initialCollections,Luca.CollectionManager.loadCollectionsByName.call(this,b,a)},b=function(){var a=this;return this.state.set({loaded_collections_count:0,collections_count:this.initialCollections.length}),this.state.bind("change:loaded_collections_count",function(){return a.collectionCountDidChange()}),this.useProgressLoader&&(this.loaderView||(this.loaderView=new Luca.components.CollectionLoaderView({manager:this,name:"collection_loader_view"}))),c.call(this),this.initialCollectionsLoadedu,this}}.call(this),function(){Luca.SocketManager=function(){function a(a){this.options=a!=null?a:{},_.extend(Backbone.Events),this.loadTransport()}return a.prototype.connect=function(){switch(this.options.provider){case"socket.io":return this.socket=io.connect(this.options.socket_host);case"faye.js":return this.socket=new Faye.Client(this.options.socket_host)}},a.prototype.transportLoaded=function(){return this.connect()},a.prototype.transport_script=function(){switch(this.options.provider){case"socket.io":return""+this.options.transport_host+"/socket.io/socket.io.js";case"faye.js":return""+this.options.transport_host+"/faye.js"}},a.prototype.loadTransport=function(){var a,b=this;return a=document.createElement("script"),a.setAttribute("type","text/javascript"),a.setAttribute("src",this.transport_script()),a.onload=this.transportLoaded,Luca.util.isIE()&&(a.onreadystatechange=function(){if(a.readyState==="loaded")return b.transportLoaded()}),document.getElementsByTagName("head")[0].appendChild(a)},a}()}.call(this),function(){_.def("Luca.containers.SplitView")["extends"]("Luca.core.Container")["with"]({componentType:"split_view",containerTemplate:"containers/basic",className:"luca-ui-split-view",componentClass:"luca-ui-panel"})}.call(this),function(){_.def("Luca.containers.ColumnView")["extends"]("Luca.core.Container")["with"]({componentType:"column_view",className:"luca-ui-column-view",components:[],initialize:function(a){return this.options=a!=null?a:{},console.log("Column Views are deprecated in favor of just using grid css on a normal container"),Luca.core.Container.prototype.initialize.apply(this,arguments),this.setColumnWidths()},componentClass:"luca-ui-column",containerTemplate:"containers/basic",generateComponentElements:!0,autoColumnWidths:function(){var a,b=this;return a=[],_(this.components.length).times(function(){return a.push(parseInt(100/b.components.length))}),a},setColumnWidths:function(){return this.columnWidths=this.layout!=null?_(this.layout.split("/")).map(function(a){return parseInt(a)}):this.autoColumnWidths(),this.columnWidths=_(this.columnWidths).map(function(a){return""+a+"%"})},beforeLayout:function(){var a,b=this;return this.debug("column_view before layout"),_(this.columnWidths).each(function(a,c){return b.components[c].float="left",b.components[c].width=a}),(a=Luca.core.Container.prototype.beforeLayout)!=null?a.apply(this,arguments):void 0}})}.call(this),function(){var a;a=Luca.define("Luca.containers.CardView"),a["extends"]("Luca.core.Container"),a.defaults({className:"luca-ui-card-view-wrapper",activeCard:0,components:[],hooks:["before:card:switch","after:card:switch"],componentClass:"luca-ui-card",generateComponentElements:!0,initialize:function(a){return this.options=a,Luca.core.Container.prototype.initialize.apply(this,arguments),this.setupHooks(this.hooks),this.components||(this.components=this.pages||(this.pages=this.cards))},prepareComponents:function(){var a;return(a=Luca.core.Container.prototype.prepareComponents)!=null&&a.apply(this,arguments),this.componentElements().hide(),this.activeComponentElement().show()},activeComponentElement:function(){return this.componentElements().eq(this.activeCard)},activeComponent:function(){return this.getComponent(this.activeCard)},customizeContainerEl:function(a,b,c){return a.style+=c===this.activeCard?"display:block;":"display:none;",a},atFirst:function(){return this.activeCard===0},atLast:function(){return this.activeCard===this.components.length-1},next:function(){if(this.atLast())return;return this.activate(this.activeCard+1)},previous:function(){if(this.atFirst())return;return this.activate(this.activeCard-1)},cycle:function(){var a;return a=this.atLast()?0:this.activeCard+1,this.activate(a)},find:function(a){return Luca(a)},firstActivation:function(){return this.activeComponent().trigger("first:activation",this,this.activeComponent())},activate:function(a,b,c){var d,e,f,g,h,i,j=this;b==null&&(b=!1),_.isFunction(b)&&(b=!1,c=b);if(a===this.activeCard)return;e=this.activeComponent(),d=this.getComponent(a),d||(a=this.indexOf(a),d=this.getComponent(a));if(!d)return;b||(this.trigger("before:card:switch",e,d),e!=null&&(f=e.trigger)!=null&&f.apply(e,["before:deactivation",this,e,d]),d!=null&&(g=d.trigger)!=null&&g.apply(e,["before:activation",this,e,d]),_.defer(function(){return j.$el.data(j.activeAttribute||"active-card",d.name)})),this.componentElements().hide(),d.previously_activated||(d.trigger("first:activation"),d.previously_activated=!0),this.activeCard=a,this.activeComponentElement().show(),b||(this.trigger("after:card:switch",e,d),(h=e.trigger)!=null&&h.apply(e,["deactivation",this,e,d]),(i=d.trigger)!=null&&i.apply(d,["activation",this,e,d]));if(_.isFunction(c))return c.apply(this,[this,e,d])}})}.call(this),function(){_.def("Luca.ModalView")["extends"]("Luca.core.Container")["with"]({closeOnEscape:!0,showOnInitialize:!1,backdrop:!1,className:"luca-ui-container modal",container:function(){return $("body")},toggle:function(){return this.$el.modal("toggle")},show:function(){return this.$el.modal("show")},hide:function(){return this.$el.modal("hide")},render:function(){return this.$el.addClass("modal"),this.fade===!0&&this.$el.addClass("fade"),$("body").append(this.$el),this.$el.modal({backdrop:this.backdrop===!0,keyboard:this.closeOnEscape===!0,show:this.showOnInitialize===!0}),this}}),_.def("Luca.containers.ModalView")["extends"]("Luca.ModalView")["with"]()}.call(this),function(){_.def("Luca.PageView")["extends"]("Luca.containers.CardView")["with"]({version:2})}.call(this),function(){var a,b,c,d;c=Luca.register("Luca.components.PanelToolbar"),c["extends"]("Luca.View"),c.defines({buttons:[],className:"luca-ui-toolbar btn-toolbar",well:!0,orientation:"top",autoBindEventHandlers:!0,events:{"click a.btn, click .dropdown-menu li":"clickHandler"},initialize:function(a){var b;this.options=a!=null?a:{},this._super("initialize",this,arguments);if(this.group===!0&&((b=this.buttons)!=null?b.length:void 0)>=0)return this.buttons=[{group:!0,buttons:this.buttons}]},clickHandler:function(a){var b,c,d,e,f;d=e=$(a.target),d.is("i")&&(d=e=$(a.target).parent()),this.selectable===!0&&(e.siblings().removeClass("is-selected"),d.addClass("is-selected"));if(!(b=e.data("eventid")))return;return c=Luca.util.hook(b),f=this.parent||this,_.isFunction(f[c])?f[c].call(this,d,a):f.trigger(b,d,a)},beforeRender:function(){this._super("beforeRender",this,arguments),this.well===!0&&this.$el.addClass("well"),this.selectable===!0&&this.$el.addClass("btn-selectable"),this.$el.addClass("toolbar-"+this.orientation),this.align==="right"&&this.$el.addClass("pull-right");if(this.align==="left")return this.$el.addClass("pull-left")},render:function(){var a,b,c,e;this.$el.empty(),e=d(this.buttons);for(b=0,c=e.length;b<c;b++)a=e[b],this.$el.append(a);return this}}),b=Backbone.View.prototype.make,a=function(a,c){var e,f,g,h,i,j,k,l,m,n,o=this;c==null&&(c=!0);if(a.ctype!=null||a.type!=null){a.className||(a.className=""),a.className+="toolbar-component",l=Luca(a).render();if(Luca.isBackboneView(l))return l.$el}return a.spacer?b("div",{"class":"spacer "+a.spacer}):a.text?b("div",{"class":"toolbar-text"},a.text):(n="btn-group",a.wrapper!=null&&(n+=""+a.wrapper),a.align!=null&&(n+="pull-"+a.align+" align-"+a.align),a.selectable===!0&&(n+="btn-selectable"),a.group!=null&&a.buttons!=null?(h=d(a.buttons,!1),b("div",{"class":n},h)):(k=a.label||(a.label=""),a.eventId||(a.eventId=_.string.dasherize(a.label.toLowerCase())),a.icon&&(_.string.isBlank(k)&&(k=" "),a.white&&(m="icon-white"),k="<i class='"+(m||"")+" icon-"+a.icon+"' /> "+k),f={"class":_.compact(["btn",a.classes,a.className]).join(" "),"data-eventId":a.eventId,title:a.title||a.description},a.color!=null&&(f["class"]+=" btn-"+a.color),a.selected!=null&&(f["class"]+=" is-selected"),a.dropdown&&(k=""+k+" <span class='caret'></span>",f["class"]+=" dropdown-toggle",f["data-toggle"]="dropdown",j=_(a.dropdown).map(function(a){var c;return c=b("a",{},a[1]),b("li",{"data-eventId":a[0]},c)}),i=b("ul",{"class":"dropdown-menu"},j)),g=b("a",f,k),e="btn-group",a.align!=null&&(e+=" align-"+a.align),c===!0?b("div",{"class":e},[g,i]):g))},d=function(b,c){var d,e,f,g;b==null&&(b=[]),c==null&&(c=!0),g=[];for(e=0,f=b.length;e<f;e++)d=b[e],g.push(a(d,c));return g}}.call(this),function(){_.def("Luca.containers.PanelView")["extends"]("Luca.core.Container")["with"]({className:"luca-ui-panel",initialize:function(a){return this.options=a!=null?a:{},Luca.core.Container.prototype.initialize.apply(this,arguments)},afterLayout:function(){var a;if(this.template)return a=(Luca.templates||JST)[this.template](this),this.$el.html(a)},render:function(){return $(this.container).append(this.$el)},afterRender:function(){var a,b=this;(a=Luca.core.Container.prototype.afterRender)!=null&&a.apply(this,arguments);if(this.css)return _(this.css).each(function(a,c){return b.$el.css(c,a)})}})}.call(this),function(){_.def("Luca.containers.TabView")["extends"]("Luca.containers.CardView")["with"]({hooks:["before:select","after:select"],componentType:"tab_view",className:"luca-ui-tab-view tabbable",tab_position:"top",tabVerticalOffset:"50px",navClass:"nav-tabs",bodyTemplate:"containers/tab_view",bodyEl:"div.tab-content",initialize:function(a){return this.options=a!=null?a:{},this.navStyle==="list"&&(this.navClass="nav-list"),Luca.containers.CardView.prototype.initialize.apply(this,arguments),_.bindAll(this,"select","highlightSelectedTab"),this.setupHooks(this.hooks),this.bind("after:card:switch",this.highlightSelectedTab)},activeTabSelector:function(){return this.tabSelectors().eq(this.activeCard||this.activeTab||this.activeItem)},beforeLayout:function(){var a;return this.$el.addClass("tabs-"+this.tab_position),this.activeTabSelector().addClass("active"),this.createTabSelectors(),(a=Luca.containers.CardView.prototype.beforeLayout)!=null?a.apply(this,arguments):void 0},afterRender:function(){var a,b;(b=Luca.containers.CardView.prototype.afterRender)!=null&&b.apply(this,arguments),a=this.tabContainer().attr("id"),this.registerEvent("click #"+a+" li a","select");if(Luca.enableBootstrap&&(this.tab_position==="left"||this.tab_position==="right"))return this.tabContainerWrapper().addClass("span2"),this.tabContentWrapper().addClass("span9")},createTabSelectors:function(){var a;return a=this,this.each(function(b,c){var d,e,f,g;b.tabIcon&&(d="<i class='icon-"+b.tabIcon+"'></i>"),e="<a href='#'>"+(d||"")+" "+b.title+"</a>",f=a.make("li",{"class":"tab-selector","data-target":c},e),a.tabContainer().append(f);if(b.navHeading!=null&&((g=a.navHeadings)!=null?!g[b.navHeading]:!void 0))return $(f).before(a.make("li",{"class":"nav-header"},b.navHeading)),a.navHeadings||(a.navHeadings={}),a.navHeadings[b.navHeading]=!0})},highlightSelectedTab:function(){return this.tabSelectors().removeClass("active"),this.activeTabSelector().addClass("active")},select:function(a){var b,c;return a.preventDefault(),b=c=$(a.target),this.trigger("before:select",this),this.activate(c.parent().data("target")),this.trigger("after:select",this)},componentElements:function(){return this.$(">.tab-content >."+this.componentClass)},tabContentWrapper:function(){return $("#"+this.cid+"-tab-view-content")},tabContainerWrapper:function(){return $("#"+this.cid+"-tabs-selector")},tabContainer:function(){return this.$("ul."+this.navClass,this.tabContainerWrapper())},tabSelectors:function(){return this.$("li.tab-selector",this.tabContainer())}})}.call(this),function(){_.def("Luca.containers.Viewport").extend("Luca.containers.CardView")["with"]({activeItem:0,additionalClassNames:"luca-ui-viewport",fullscreen:!0,fluid:!1,initialize:function(a){this.options=a!=null?a:{},_.extend(this,this.options),Luca.enableBootstrap===!0&&(this.wrapperClass=this.fluid===!0?Luca.containers.Viewport.fluidWrapperClass:Luca.containers.Viewport.defaultWrapperClass),Luca.core.Container.prototype.initialize.apply(this,arguments);if(this.fullscreen===!0)return this.enableFullscreen()},enableFluid:function(){return this.enableWrapper()},disableFluid:function(){return this.disableWrapper()},enableWrapper:function(){if(this.wrapperClass!=null)return this.$el.parent().addClass(this.wrapperClass)},disableWrapper:function(){if(this.wrapperClass!=null)return this.$el.parent().removeClass(this.wrapperClass)},enableFullscreen:function(){return $("html,body").addClass("luca-ui-fullscreen"),this.$el.addClass("fullscreen-enabled")},disableFullscreen:function(){return $("html,body").removeClass("luca-ui-fullscreen"),this.$el.removeClass("fullscreen-enabled")},beforeRender:function(){var a;(a=Luca.containers.CardView.prototype.beforeRender)!=null&&a.apply(this,arguments),this.topNav!=null&&this.renderTopNavigation();if(this.bottomNav!=null)return this.renderBottomNavigation()},height:function(){return this.$el.height()},width:function(){return this.$el.width()},afterRender:function(){var a;(a=Luca.containers.CardView.prototype.after)!=null&&a.apply(this,arguments);if(Luca.enableBootstrap===!0&&this.containerClassName)return this.$el.children().wrap('<div class="#{ containerClassName }" />')},renderTopNavigation:function(){var a;if(this.topNav==null)return;return _.isString(this.topNav)&&(this.topNav=Luca.util.lazyComponent(this.topNav)),_.isObject(this.topNav)&&((a=this.topNav).ctype||(a.ctype=this.topNav.type||"nav_bar"),Luca.isBackboneView(this.topNav)||(this.topNav=Luca.util.lazyComponent(this.topNav))),this.topNav.app=this,$("body").prepend(this.topNav.render().el)},renderBottomNavigation:function(){}}),Luca.containers.Viewport.defaultWrapperClass="row",Luca.containers.Viewport.fluidWrapperClass="row-fluid"}.call(this),function(){_.def("Luca.components.Template")["extends"]("Luca.View")["with"]({initialize:function(a){return this.options=a!=null?a:{},console.log("The Use of Luca.components.Template directly is being DEPRECATED"),Luca.View.prototype.initialize.apply(this,arguments)}})}.call(this),function(){var a;a=function(){return Backbone.history.start()},_.def("Luca.Application")["extends"]("Luca.containers.Viewport")["with"]({name:"MyApp",defaultState:{},autoBoot:!1,autoStartHistory:"before:render",useCollectionManager:!0,collectionManager:{},collectionManagerClass:"Luca.CollectionManager",plugin:!1,useController:!0,useKeyHandler:!1,keyEvents:{},components:[{ctype:"template",name:"welcome",template:"sample/welcome",templateContainer:"Luca.templates"}],initialize:function(a){var b,c,d,e,f=this;this.options=a!=null?a:{},c=this,d=this.name,b=typeof Luca.getApplication=="function"?Luca.getApplication():void 0,(e=Luca.Application).instances||(e.instances={}),Luca.Application.instances[d]=c,Luca.containers.Viewport.prototype.initialize.apply(this,arguments),this.state=new Luca.Model(this.defaultState),this.useController===!0&&this.setupMainController(),this.setupCollectionManager(),this.defer(function(){return c.render()}).until(this,"ready"),this.setupRouter(),this.useKeyRouter===!0&&console.log("The useKeyRouter property is being deprecated. switch to useKeyHandler instead"),(this.useKeyHandler===!0||this
8
+ .useKeyRouter===!0)&&this.keyEvents!=null&&this.setupKeyHandler(),this.plugin!==!0&&!b&&(Luca.getApplication=function(a){return a==null?c:Luca.Application.instances[a]});if(this.autoBoot){if(Luca.util.resolve(this.name))throw"Attempting to override window."+this.name+" when it already exists";return $(function(){return window[d]=c,c.boot()})}},activeView:function(){var a;return(a=this.activeSubSection())?this.view(a):this.view(this.activeSection())},activeSection:function(){return this.get("active_section")},activeSubSection:function(){return this.get("active_sub_section")},activePages:function(){var a=this;return this.$(".luca-ui-controller").map(function(a,b){return $(b).data("active-section")})},boot:function(){return this.trigger("ready")},collection:function(){return this.collectionManager.getOrCreate.apply(this.collectionManager,arguments)},get:function(a){return this.state.get(a)},set:function(a,b,c){return this.state.set.apply(this.state,arguments)},view:function(a){return Luca.cache(a)},navigate_to:function(a,b){return this.getMainController().navigate_to(a,b)},getMainController:function(){return this.useController===!0?this.components[0]:Luca.cache("main_controller")},keyHandler:function(a){var b,c,d,e,f,g,h;if(!a||!this.keyEvents)return;c=$(a.target).is("input")||$(a.target).is("textarea");if(c)return;e=Luca.keyMap[a.keyCode];if(!e)return;f=(a!=null?a.metaKey:void 0)===!0,b=(a!=null?a.ctrlKey:void 0)===!0,g=this.keyEvents,g=f?this.keyEvents.meta:g,g=b?this.keyEvents.control:g,g=f&&b?this.keyEvents.meta_control:g;if(d=g!=null?g[e]:void 0)return this[d]!=null&&_.isFunction(this[d])?(h=this[d])!=null?h.call(this):void 0:this.trigger(d,a,e)},setupControllerBindings:function(){var a,b,c,d=this;return a=this,(b=this.getMainController())!=null&&b.bind("after:card:switch",function(b,c){return d.state.set({active_section:c.name}),a.trigger("page:change")}),(c=this.getMainController())!=null?c.each(function(b){var c;c=b.type||b.type;if(c.match(/controller$/))return b.bind("after:card:switch",function(b,c){return d.state.set({active_sub_section:c.name}),a.trigger("sub:page:change")})}):void 0},setupMainController:function(){var a;if(this.useController===!0)return a=this.components||[],this.components=[{type:"controller",name:"main_controller",components:a}],this.defer(this.setupControllerBindings,!1).until("after:components")},setupCollectionManager:function(){var a,b,c,d,e;if(this.useCollectionManager!==!0)return;if(this.collectionManager!=null&&((c=this.collectionManager)!=null?c.get:void 0)!=null)return;_.isString(this.collectionManagerClass)&&(this.collectionManagerClass=Luca.util.resolve(this.collectionManagerClass)),a=this.collectionManagerOptions||{},_.isObject(this.collectionManager)&&!_.isFunction((d=this.collectionManager)!=null?d.get:void 0)&&(a=this.collectionManager,this.collectionManager=void 0),_.isString(this.collectionManager)&&(a={name:this.collectionManager}),this.collectionManager=typeof (b=Luca.CollectionManager).get=="function"?b.get(a.name):void 0;if(!_.isFunction((e=this.collectionManager)!=null?e.get:void 0))return this.collectionManager=new this.collectionManagerClass(a)},setupRouter:function(){var b,c;b=this,_.isString(this.router)&&(c=Luca.util.resolve(this.router),this.router=new c({app:b}));if(this.router&&this.autoStartHistory)return this.autoStartHistory===!0&&(this.autoStartHistory="before:render"),this.defer(a,!1).until(this,this.autoStartHistory)},setupKeyHandler:function(){var a,b,c,d,e,f,g;if(!this.keyEvents)return;(c=this.keyEvents).control_meta||(c.control_meta={}),this.keyEvents.meta_control&&_.extend(this.keyEvents.control_meta,this.keyEvents.meta_control),a=_.bind(this.keyHandler,this),f=this.keypressEvents||["keydown"],g=[];for(d=0,e=f.length;d<e;d++)b=f[d],g.push($(document).on(b,a));return g}})}.call(this),function(){_.def("Luca.components.Toolbar")["extends"]("Luca.core.Container")["with"]({className:"luca-ui-toolbar toolbar",position:"bottom",initialize:function(a){return this.options=a!=null?a:{},Luca.core.Container.prototype.initialize.apply(this,arguments)},prepareComponents:function(){var a=this;return _(this.components).each(function(b){return b.container=a.$el})},render:function(){return $(this.container).append(this.el)}})}.call(this),function(){_.def("Luca.components.CollectionLoaderView")["extends"]("Luca.components.Template")["with"]({className:"luca-ui-collection-loader-view",template:"components/collection_loader_view",initialize:function(a){return this.options=a!=null?a:{},Luca.components.Template.prototype.initialize.apply(this,arguments),this.container||(this.container=$("body")),this.manager||(this.manager=Luca.CollectionManager.get()),this.setupBindings()},modalContainer:function(){return $("#progress-modal",this.el)},setupBindings:function(){var a=this;return this.manager.bind("collection_loaded",function(b){var c,d,e,f;return d=a.manager.loadedCollectionsCount(),f=a.manager.totalCollectionsCount(),e=parseInt(d/f*100),c=_.string.titleize(_.string.humanize(b)),a.modalContainer().find(".progress .bar").attr("style","width: "+e+"%;"),a.modalContainer().find(".message").html("Loaded "+c+"...")}),this.manager.bind("all_collections_loaded",function(){return a.modalContainer().find(".message").html("All done!"),_.delay(function(){return a.modalContainer().modal("hide")},400)})}})}.call(this),function(){var a,b;a=Luca.define("Luca.components.CollectionView"),a["extends"]("Luca.components.Panel"),a.behavesAs("LoadMaskable","Filterable","Paginatable"),a.triggers("before:refresh","after:refresh","refresh","empty:results"),a.defaults({tagName:"ol",className:"luca-ui-collection-view",bodyClassName:"collection-ui-panel",itemTemplate:void 0,itemRenderer:void 0,itemTagName:"li",itemClassName:"collection-item",initialize:function(a){var b=this;this.options=a!=null?a:{},_.extend(this,this.options),_.bindAll(this,"refresh");if(this.collection==null&&!this.options.collection)throw console.log("Error on initialize of collection view",this),"Collection Views must specify a collection";if(this.itemTemplate==null&&this.itemRenderer==null&&this.itemProperty==null)throw"Collection Views must specify an item template or item renderer function";Luca.components.Panel.prototype.initialize.apply(this,arguments),_.isString(this.collection)&&Luca.CollectionManager.get()&&(this.collection=Luca.CollectionManager.get().getOrCreate(this.collection));if(!Luca.isBackboneCollection(this.collection))throw"Collection Views must have a valid backbone collection";return this.autoRefreshOnModelsPresent!==!1&&this.defer(function(){if(b.collection.length>0)return b.refresh()}).until("after:render"),this.on("collection:change",this.refresh,this)},attributesForItem:function(a,b){return _.extend({},{"class":this.itemClassName,"data-index":a.index,"data-model-id":a.model.get("id")})},contentForItem:function(a){var b,c;return a==null&&(a={}),this.itemTemplate!=null&&(c=Luca.template(this.itemTemplate))?b=c.call(this,a):this.itemRenderer!=null&&_.isFunction(this.itemRenderer)?b=this.itemRenderer.call(this,a,a.model,a.index):this.itemProperty&&a.model!=null?b=a.model.read(this.itemProperty):""},makeItem:function(a,c){var d,e,f;f=this.prepareItem!=null?this.prepareItem.call(this,a,c):{model:a,index:c},d=this.attributesForItem(f,a),e=this.contentForItem(f);try{return b(this.itemTagName,d,e)}catch(g){return console.log("Error generating DOM element for CollectionView",this,a,c)}},getCollection:function(){return this.collection},getQuery:function(){return this.query||(this.query={})},getQueryOptions:function(){return this.queryOptions||(this.queryOptions={})},getModels:function(a,b){var c;return((c=this.collection)!=null?c.query:void 0)?(a||(a=this.getQuery()),b||(b=this.getQueryOptions()),this.collection.query(a,b)):this.collection.models},locateItemElement:function(a){return this.$("."+this.itemClassName+"[data-model-id='"+a+"']")},refreshModel:function(a){var b;return b=this.collection.indexOf(a),this.locateItemElement(a.get("id")).empty().append(this.contentForItem({model:a,index:b},a)),this.trigger("model:refreshed",b,a)},refresh:function(a,b){var c,d,e,f,g;a||(a=this.getQuery()),b||(b=this.getQueryOptions()),this.$bodyEl().empty(),e=this.getModels(a,b),this.trigger("before:refresh",e,a,b),e.length===0&&this.trigger("empty:results"),c=0;for(f=0,g=e.length;f<g;f++)d=e[f],this.$append(this.makeItem(d,c++));return this.trigger("after:refresh",e,a,b),this},registerEvent:function(a,b,c){var d;return c==null&&_.isFunction(b)&&(c=b,b=void 0),d=_([a,""+this.itemTagName+"."+this.itemClassName,b]).compact().join(" "),Luca.View.prototype.registerEvent(d,c)},render:function(){return this.refresh(),this.$el.parent().length>0&&this.container!=null&&this.$attach(),this}}),b=Luca.View.prototype.make}.call(this),function(){_.def("Luca.components.Controller")["extends"]("Luca.containers.CardView")["with"]({additionalClassNames:["luca-ui-controller"],activeAttribute:"active-section",initialize:function(a){var b;this.options=a,Luca.containers.CardView.prototype.initialize.apply(this,arguments),this.defaultCard||(this.defaultCard=(b=this.components[0])!=null?b.name:void 0);if(!this.defaultCard)throw"Controllers must specify a defaultCard property and/or the first component must have a name";return this.state=new Backbone.Model({active_section:this.defaultCard})},each:function(a){var b=this;return _(this.components).each(function(c){return a.apply(b,[c])})},activeSection:function(){return this.get("activeSection")},controllers:function(a){return a==null&&(a=!1),this.select("ctype","controller",a)},availableSections:function(){var a,b=this;return a={},a[this.name]=this.sectionNames(),_(this.controllers()).reduce(function(a,b){return a[b.name]=b.sectionNames(),a},a)},sectionNames:function(a){return a==null&&(a=!1),this.pluck("name")},"default":function(a){return this.navigate_to(this.defaultCard,a)},navigate_to:function(a,b){var c=this;return a||(a=this.defaultCard),this.activate(a,!1,function(a,d,e){c.state.set({active_section:e.name});if(_.isFunction(b))return b.apply(e)}),this.find(a)}})}.call(this),function(){_.def("Luca.fields.ButtonField")["extends"]("Luca.core.Field")["with"]({readOnly:!0,events:{"click input":"click_handler"},hooks:["button:click"],className:"luca-ui-field luca-ui-button-field",template:"fields/button_field",click_handler:function(a){var b,c;return b=c=$(a.currentTarget),this.trigger("button:click")},initialize:function(a){var b;this.options=a!=null?a:{},_.extend(this.options),_.bindAll(this,"click_handler"),Luca.core.Field.prototype.initialize.apply(this,arguments);if((b=this.icon_class)!=null?b.length:void 0)return this.template="fields/button_field_link"},afterInitialize:function(){this.input_id||(this.input_id=_.uniqueId("button")),this.input_name||(this.input_name=this.name||(this.name=this.input_id)),this.input_value||(this.input_value=this.label||(this.label=this.text)),this.input_type||(this.input_type="button"),this.input_class||(this.input_class=this["class"]),this.icon_class||(this.icon_class=""),this.icon_class.length&&!this.icon_class.match(/^icon-/)&&(this.icon_class="icon-"+this.icon_class);if(this.white)return this.icon_class+=" icon-white"},setValue:function(){return!0}})}.call(this),function(){var a;a=Luca.View.prototype.make,_.def("Luca.fields.CheckboxArray")["extends"]("Luca.core.Field")["with"]({version:2,template:"fields/checkbox_array",className:"luca-ui-checkbox-array",events:{"click input":"clickHandler"},selectedItems:[],initialize:function(a){return this.options=a!=null?a:{},_.extend(this,this.options),_.extend(this,Luca.modules.Deferrable),_.bindAll(this,"renderCheckboxes","clickHandler","checkSelected"),Luca.core.Field.prototype.initialize.apply(this,arguments),this.input_id||(this.input_id=_.uniqueId("field")),this.input_name||(this.input_name=this.name),this.label||(this.label=this.name),this.valueField||(this.valueField="id"),this.displayField||(this.displayField="name")},afterInitialize:function(a){var b;this.options=a!=null?a:{};try{this.configure_collection()}catch(c){console.log("Error Configuring Collection",this,c.message)}return b=this,this.collection.length>0?this.renderCheckboxes():this.defer("renderCheckboxes").until(this.collection,"reset")},clickHandler:function(a){var b;b=$(a.target);if(b.prop("checked"))return this.selectedItems.push(b.val());if(_(this.selectedItems).include(b.val()))return this.selectedItems=_(this.selectedItems).without(b.val())},controls:function(){return this.$(".controls")},renderCheckboxes:function(){var b=this;return this.controls().empty(),this.selectedItems=[],this.collection.each(function(c){var d,e,f,g,h;return h=c.get(b.valueField),g=c.get(b.displayField),f=_.uniqueId(""+b.cid+"_checkbox"),e=a("input",{type:"checkbox","class":"array-checkbox",name:b.input_name,value:h,id:f}),d=a("label",{"for":f},e),$(d).append(" "+g),b.controls().append(d)}),this.trigger("checkboxes:rendered",this.checkboxesRendered=!0),this},uncheckAll:function(){return this.allFields().prop("checked",!1)},allFields:function(){return this.controls().find("input[type='checkbox']")},checkSelected:function(a){var b,c,d,e,f;a!=null&&(this.selectedItems=a),this.uncheckAll(),f=this.selectedItems;for(d=0,e=f.length;d<e;d++)c=f[d],b=this.controls().find("input[value='"+c+"']"),b.prop("checked",!0);return this.selectedItems},getValue:function(){var a,b,c,d,e;d=this.allFields(),e=[];for(b=0,c=d.length;b<c;b++)a=d[b],this.$(a).prop("checked")&&e.push(this.$(a).val());return e},setValue:function(a){var b;return this.selectedItems=a,this.checkboxesRendered===!0?this.checkSelected(a):(b=this,this.defer(function(){return b.checkSelected(a)}).until("checkboxes:rendered"))},getValues:function(){return this.getValue()},setValues:function(a){return this.setValue(a)}})}.call(this),function(){_.def("Luca.fields.CheckboxField")["extends"]("Luca.core.Field")["with"]({events:{"change input":"change_handler"},className:"luca-ui-checkbox-field luca-ui-field",template:"fields/checkbox_field",hooks:["checked","unchecked"],send_blanks:!0,change_handler:function(a){var b,c;return b=c=$(a.target),b.is(":checked")?this.trigger("checked"):this.trigger("unchecked"),this.trigger("on:change",this,a,b.is(":checked"))},initialize:function(a){return this.options=a!=null?a:{},_.extend(this,this.options),_.bindAll(this,"change_handler"),Luca.core.Field.prototype.initialize.apply(this,arguments)},afterInitialize:function(){return this.input_id||(this.input_id=_.uniqueId("field")),this.input_name||(this.input_name=this.name),this.input_value||(this.input_value=1),this.label||(this.label=this.name)},setValue:function(a){return this.getInputElement().attr("checked",a)},getValue:function(){return this.getInputElement().is(":checked")}})}.call(this),function(){_.def("Luca.fields.FileUploadField")["extends"]("Luca.core.Field")["with"]({template:"fields/file_upload_field",afterInitialize:function(){return this.input_id||(this.input_id=_.uniqueId("field")),this.input_name||(this.input_name=this.name),this.label||(this.label=this.name),this.helperText||(this.helperText="")}})}.call(this),function(){_.def("Luca.fields.HiddenField")["extends"]("Luca.core.Field")["with"]({template:"fields/hidden_field",afterInitialize:function(){return this.input_id||(this.input_id=_.uniqueId("field")),this.input_name||(this.input_name=this.name),this.input_value||(this.input_value=this.value),this.label||(this.label=this.name)}})}.call(this),function(){_.def("Luca.components.LabelField")["extends"]("Luca.core.Field")["with"]({className:"luca-ui-field luca-ui-label-field",formatter:function(a){return a||(a=this.getValue()),_.str.titleize(a)},setValue:function(a){return this.trigger("change",a,this.getValue()),this.getInputElement().attr("value",a),this.$(".value").html(this.formatter(a))}})}.call(this),function(){_.def("Luca.fields.SelectField")["extends"]("Luca.core.Field")["with"]({events:{"change select":"change_handler"},hooks:["after:select"],className:"luca-ui-select-field luca-ui-field",template:"fields/select_field",includeBlank:!0,blankValue:"",blankText:"Select One",initialize:function(a){this.options=a!=null?a:{},_.extend(this,this.options),_.extend(this,Luca.modules.Deferrable),_.bindAll(this,"change_handler","populateOptions","beforeFetch"),Luca.core.Field.prototype.initialize.apply(this,arguments),this.input_id||(this.input_id=_.uniqueId("field")),this.input_name||(this.input_name=this.name),this.label||(this.label=this.name);if(_.isUndefined(this.retainValue))return this.retainValue=!0},afterInitialize:function(){var a;if((a=this.collection)!=null?a.data:void 0)this.valueField||(this.valueField="id"),this.displayField||(this.displayField="name"),this.parseData();try{this.configure_collection()}catch(b){console.log("Error Configuring Collection",this,b.message)}return this.collection.bind("before:fetch",this.beforeFetch),this.collection.bind("reset",this.populateOptions)},parseData:function(){var a=this;return this.collection.data=_(this.collection.data).map(function(b){var c;return _.isArray(b)?(c={},c[a.valueField]=b[0],c[a.displayField]=b[1]||b[0],c):b})},getInputElement:function(){return this.input||(this.input=this.$("select").eq(0))},afterRender:function(){var a,b;return((a=this.collection)!=null?(b=a.models)!=null?b.length:void 0:void 0)>0?this.populateOptions():this.collection.trigger("reset")},setValue:function(a){return this.currentValue=a,Luca.core.Field.prototype.setValue.apply(this,arguments)},beforeFetch:function(){return this.resetOptions()},change_handler:function(a){return this.trigger("on:change",this,a)},resetOptions:function(){this.getInputElement().html("");if(this.includeBlank)return this.getInputElement().append("<option value='"+this.blankValue+"'>"+this.blankText+"</option>")},populateOptions:function(){var a,b=this;return this.resetOptions(),((a=this.collection)!=null?a.each:void 0)!=null&&this.collection.each(function(a){var c,d,e,f;return f=a.get(b.valueField),c=a.get(b.displayField),b.selected&&f===b.selected&&(e="selected"),d="<option "+e+" value='"+f+"'>"+c+"</option>",b.getInputElement().append(d)}),this.trigger("after:populate:options",this),this.setValue(this.currentValue)}})}.call(this),function(){_.def("Luca.fields.TextAreaField")["extends"]("Luca.core.Field")["with"]({events:{"keydown input":"keydown_handler","blur input":"blur_handler","focus input":"focus_handler"},template:"fields/text_area_field",height:"200px",width:"90%",initialize:function(a){return this.options=a!=null?a:{},_.bindAll(this,"keydown_handler"),Luca.core.Field.prototype.initialize.apply(this,arguments),this.input_id||(this.input_id=_.uniqueId("field")),this.input_name||(this.input_name=this.name),this.label||(this.label=this.name),this.input_class||(this.input_class=this["class"]),this.input_value||(this.input_value=""),this.inputStyles||(this.inputStyles="height:"+this.height+";width:"+this.width)},setValue:function(a){return $(this.field()).val(a)},getValue:function(){return $(this.field()).val()},field:function(){return this.input=$("textarea#"+this.input_id,this.el)},keydown_handler:function(a){var b,c;return b=c=$(a.currentTarget)},blur_handler:function(a){var b,c;return b=c=$(a.currentTarget)},focus_handler:function(a){var b,c;return b=c=$(a.currentTarget)}})}.call(this),function(){_.def("Luca.fields.TextField")["extends"]("Luca.core.Field")["with"]({events:{"blur input":"blur_handler","focus input":"focus_handler","change input":"change_handler"},template:"fields/text_field",autoBindEventHandlers:!0,send_blanks:!0,keyEventThrottle:300,initialize:function(a){return this.options=a!=null?a:{},this.enableKeyEvents&&this.registerEvent("keyup input","keyup_handler"),this.input_id||(this.input_id=_.uniqueId("field")),this.input_name||(this.input_name=this.name),this.label||(this.label=this.name),this.input_class||(this.input_class=this["class"]),this.input_value||(this.input_value=this.value||""),this.prepend&&(this.$el.addClass("input-prepend"),this.addOn=this.prepend),this.append&&(this.$el.addClass("input-append"),this.addOn=this.append),Luca.core.Field.prototype.initialize.apply(this,arguments)},keyup_handler:function(a){return this.trigger("on:keyup",this,a)},blur_handler:function(a){return this.trigger("on:blur",this,a)},focus_handler:function(a){return this.trigger("on:focus",this,a)},change_handler:function(a){return this.trigger("on:change",this,a)}})}.call(this),function(){_.def("Luca.fields.TypeAheadField")["extends"]("Luca.fields.TextField")["with"]({className:"luca-ui-field",getSource:function(){return Luca.util.read(this.source)||[]},matcher:function(a){return!0},beforeRender:function(){return Luca.fields.TextField.prototype.beforeRender.apply(this,arguments),this.getInputElement().attr("data-provide","typeahead")},afterRender:function(){return Luca.fields.TextField.prototype.afterRender.apply(this,arguments),this.getInputElement().typeahead({matcher:this.matcher,source:this.getSource()})}})}.call(this),function(){_.def("Luca.components.FormButtonToolbar")["extends"]("Luca.components.Toolbar")["with"]({className:"luca-ui-form-toolbar form-actions",position:"bottom",includeReset:!1,render:function(){return $(this.container).append(this.el)},initialize:function(a){this.options=a!=null?a:{},Luca.components.Toolbar.prototype.initialize.apply(this,arguments),this.components=[{ctype:"button_field",label:"Submit","class":"btn submit-button"}];if(this.includeReset)return this.components.push({ctype:"button_field",label:"Reset","class":"btn reset-button"})}})}.call(this),function(){var a;a={buttons:[{icon:"remove-sign",label:"Reset",eventId:"click:reset",className:"reset-button",align:"right"},{icon:"ok-sign",white:!0,label:"Save Changes",eventId:"click:submit",color:"success",className:"submit-button",align:"right"}]},_.def("Luca.components.FormView")["extends"]("Luca.core.Container")["with"]({tagName:"form",className:"luca-ui-form-view",hooks:["before:submit","before:reset","before:load","before:load:new","before:load:existing","after:submit","after:reset","after:load","after:load:new","after:load:existing","after:submit:success","after:submit:fatal_error","after:submit:error"],events:{"click .submit-button":"submitHandler","click .reset-button":"resetHandler"},toolbar:!0,legend:"",bodyClassName:"form-view-body",version:"0.9.33333333",initialize:function(a){this.options=a!=null?a:{},this.loadMask==null&&(this.loadMask=Luca.enableBootstrap),Luca.core.Container.prototype.initialize.apply(this,arguments),this.components||(this.components=this.fields),_.bindAll(this,"submitHandler","resetHandler","renderToolbars","applyLoadMask"),this.state||(this.state=new Backbone.Model),this.setupHooks(this.hooks),this.applyStyleClasses();if(this.toolbar!==!1&&!this.topToolbar&&!this.bottomToolbar){if(this.toolbar==="both"||this.toolbar==="top")this.topToolbar=this.getDefaultToolbar();if(this.toolbar!=="top")return this.bottomToolbar=this.getDefaultToolbar()}},getDefaultToolbar:function(){return a},applyStyleClasses:function(){Luca.enableBootstrap&&this.applyBootstrapStyleClasses(),this.labelAlign&&this.$el.addClass("label-align-"+this.labelAlign);if(this.fieldLayoutClass)return this.$el.addClass(this.fieldLayoutClass)},applyBootstrapStyleClasses:function(){this.labelAlign==="left"&&(this.inlineForm=!0),this.well&&this.$el.addClass("well"),this.searchForm&&this.$el.addClass("form-search"),this.horizontalForm&&this.$el.addClass("form-horizontal");if(this.inlineForm)return this.$el.addClass("form-inline")},resetHandler:function(a){var b,c;return b=c=$(a!=null?a.target:void 0),this.trigger("before:reset",this),this.reset(),this.trigger("after:reset",this)},submitHandler:function(a){var b,c;b=c=$(a!=null?a.target:void 0),this.trigger("before:submit",this),this.loadMask===!0&&this.trigger("enable:loadmask",this);if(this.hasModel())return this.submit()},afterComponents:function(){var a,b=this;return(a=Luca.core.Container.prototype.afterComponents)!=null&&a.apply(this,arguments),this.eachField(function(a){return a.getForm=function(){return b},a.getModel=function(){return b.currentModel()}})},eachField:function(a){return _(this.getFields()).map(a)},getField:function(a){var b;return b=_(this.getFields("name",a)).first(),b!=null?b:_(this.getFields("input_name",a)).first()},getFields:function(a,b){var c;return c=this.selectByAttribute("isField",!0,!0),a!=null&&b!=null&&(c=_(c).select(function(c){var d;return d=c[a],_.isFunction(d)&&(d=d.call(c)),d===b})),c},loadModel:function(a){var b,c,d,e;this.current_model=a,d=this,c=this.getFields(),this.trigger("before:load",this,this.current_model),this.current_model&&((e=this.current_model.beforeFormLoad)!=null&&e.apply(this.current_model,this),b="before:load:"+(this.current_model.isNew()?"new":"existing"),this.trigger(b,this,this.current_model)),this.setValues(this.current_model),this.trigger("after:load",this,this.current_model);if(this.current_model)return this.trigger("after:load:"+(this.current_model.isNew()?"new":"existing"),this,this.current_model)},reset:function(){if(this.current_model!=null)return this.loadModel(this.current_model)},clear:function(){var a=this;return this.current_model=this.defaultModel!=null?this.defaultModel():void 0,_(this.getFields()).each(function(b){try{return b.setValue("")}catch(c){return console.log("Error Clearing",a,b)}})},setValues:function(a,b){var c,d=this;b==null&&(b={}),a||(a=this.currentModel()),c=this.getFields(),_(c).each(function(b){var c,e;c=b.input_name||b.name,(e=a[c])&&_.isFunction(e)&&(e=e.apply(d)),!e&&Luca.isBackboneModel(a)&&(e=a.get(c));if(b.readOnly!==!0)return b!=null?b.setValue(e):void 0});if(b.silent!=null!=1)return this.syncFormWithModel()},getValues:function(a){var b,c=this;return a==null&&(a={}),a.reject_blank==null&&(a.reject_blank=!0),a.skip_buttons==null&&(a.skip_buttons=!0),a.blanks===!1&&(a.reject_blank=!0),b=_(this.getFields()).inject(function(b,c){var d,e,f,g,h;return g=c.getValue(),e=c.input_name||c.name,h=!!_.str.isBlank(g)||!!_.isUndefined(g),d=!a.reject_blank&&!c.send_blanks,a.debug&&console.log(""+e+" Options",a,"Value",g,"Value Is Blank?",h,"Allow Blanks?",d),a.skip_buttons&&c.ctype==="button_field"?f=!0:(h&&d===!1&&(f=!0),c.input_name==="id"&&h===!0&&(f=!0)),a.debug&&console.log("Skip is true on "+e),f!==!0&&(b[e]=g),b},a.defaults||{}),b},submit_success_handler:function(a,b,c){return this.trigger("after:submit",this,a,b),this.loadMask===!0&&this.trigger("disable:loadmask",this),b&&(b!=null?b.success:void 0)===!0?this.trigger("after:submit:success",this,a,b):this.trigger("after:submit:error",this,a,b)},submit_fatal_error_handler:function(a,b,c){return this.trigger("after:submit",this,a,b),this.trigger("after:submit:fatal_error",this,a,b)},submit:function(a,b){a==null&&(a=!0),b==null&&(b={}),_.bindAll(this,"submit_success_handler","submit_fatal_error_handler"),b.success||(b.success=this.submit_success_handler),b.error||(b.error=this.submit_fatal_error_handler),this.syncFormWithModel();if(!a)return;return this.current_model.save(this.current_model.toJSON(),b)},hasModel:function(){return this.current_model!=null},currentModel:function(a){return a==null&&(a={}),(a===!0||(a!=null?a.refresh:void 0)===!0)&&this.syncFormWithModel(),this.current_model},syncFormWithModel:function(){var a;return(a=this.current_model)!=null?a.set(this.getValues()):void 0},setLegend:function(a){return this.legend=a,$("fieldset legend",this.el).first().html(this.legend)},flash:function(a){return this.$(".toolbar-container.top").length>0?this.$(".toolbar-container.top").after(a):this.$bodyEl().prepend(a)},successFlashDelay:1500,successMessage:function(a){var b=this;return this.$(".alert.alert-success").remove(),this.flash(Luca.template("components/form_alert",{className:"alert alert-success",message:a})),_.delay(function(){return b.$(".alert.alert-success").fadeOut()},this.successFlashDelay||0)},errorMessage:function(a){return this.$(".alert.alert-error").remove(),this.flash(Luca.template("components/form_alert",{className:"alert alert-error",message:a}))}})}.call(this),function(){_.def("Luca.components.GridView").extend("Luca.components.Panel")["with"]({bodyTemplate:"components/grid_view",autoBindEventHandlers:!0,events:{"dblclick table tbody tr":"double_click_handler","click table tbody tr":"click_handler"},className:"luca-ui-g-view",rowClass:"luca-ui-g-row",wrapperClass:"luca-ui-g-view-wrapper",additionalWrapperClasses:[],wrapperStyles:{},scrollable:!0,emptyText:"No Results To display.",tableStyle:"striped",defaultHeight:285,defaultWidth:756,maxWidth:void 0,hooks:["before:grid:render","before:render:header","before:render:row","after:grid:render","row:double:click","row:click","after:collection:load"],initialize:function(a){var b=this;return this.options=a!=null?a:{},_.extend(this,this.options),_.extend(this,Luca.modules.Deferrable),this.loadMask==null&&(this.loadMask=Luca.enableBootstrap),this.loadMask===!0&&(this.loadMaskEl||(this.loadMaskEl=".luca-ui-g-view-body")),Luca.components.Panel.prototype.initialize.apply(this,arguments),this.configure_collection(!0),this.collection.bind("before:fetch",function(){if(b.loadMask===!0)return b.trigger("enable:loadmask")}),this.collection.bind("reset",function(a){return b.refresh(),b.loadMask===!0&&b.trigger("disable:loadmask"),b.trigger("after:collection:load",a)}),this.collection.bind("change",function(a){var c,d;if(b.rendered!==!0)return;try{return d=b.getRowEl(a.id||a.get("id")||a.cid),c=b.render_row(a,b.collection.indexOf(a),{cellsOnly:!0}),$(d).html(c.join(" "))}catch(e){return console.log("Error in change handler for GridView.collection",e,b,a)}})},beforeRender:function(){var a;return(a=Luca.components.Panel.prototype.beforeRender)!=null&&a.apply(this,arguments),this.trigger("before:grid:render",this),this.table=this.$("table.luca-ui-g-view"),this.header=this.$("thead"),this.body=this.$("tbody"),this.footer=this.$("tfoot"),this.wrapper=this.$("."+this.wrapperClass),this.applyCssClasses(),this.scrollable&&this.setDimensions(),this.renderHeader(),this.emptyMessage(),$(this.container).append(this.$el)},afterRender:function(){var a;return(a=Luca.components.Panel.prototype.afterRender)!=null&&a.apply(this,arguments),this.rendered=!0,this.refresh(),this.trigger("after:grid:render",this)},applyCssClasses:function(){var a,b=this;return this.scrollable&&this.$el.addClass("scrollable-g-view"),_(this.additionalWrapperClasses).each(function(a){var c;return(c=b.wrapper)!=null?c.addClass(a):void 0}),Luca.enableBootstrap&&this.table.addClass("table"),_((a=this.tableStyle)!=null?a.split(" "):void 0).each(function(a){return b.table.addClass("table-"+a)})},setDimensions:function(a){var b=this;return this.height||(this.height=this.defaultHeight),this.$(".luca-ui-g-view-body").height(this.height),this.$("tbody.scrollable").height(this.height-23),this.container_width=function(){return $(b.container).width()}(),this.width||(this.width=this.container_width>0?this.container_width:this.defaultWidth),this.width=_([this.width,this.maxWidth||this.width]).max(),this.$(".luca-ui-g-view-body").width(this.width),this.$(".luca-ui-g-view-body table").width(this.width),this.setDefaultColumnWidths()},resize:function(a){var b,c,d=this;b=a-this.width,this.width=a,this.$(".luca-ui-g-view-body").width(this.width),this.$(".luca-ui-g-view-body table").width(this.width);if(this.columns.length>0)return c=b/this.columns.length,_(this.columns).each(function(a,b){var e;return e=$(".column-"+b,d.el),e.width(a.width=a.width+c)})},padLastColumn:function(){var a,b;a=_(this.columns).inject(function(a,b){return a=b.width+a},0),b=this.width-a;if(b>0)return this.lastColumn().width+=b},setDefaultColumnWidths:function(){var a;return a=this.columns.length>0?this.width/this.columns.length:200,_(this.columns).each(function(b){return parseInt(b.width||(b.width=a))}),this.padLastColumn()},lastColumn:function(){return this.columns[this.columns.length-1]},emptyMessage:function(a){return a==null&&(a=""),a||(a=this.emptyText),this.body.html(""),this.body.append(Luca.templates["components/grid_view_empty_text"]({colspan:this.columns.length,text:a}))},refresh:function(){var a=this;this.body.html(""),this.collection.each(function(b,c){return a.render_row.apply(a,[b,c])});if(this.collection.models.length===0)return this.emptyMessage()},ifLoaded:function(a,b){return b||(b=this),a||(a=function(){return!0}),this.collection.ifLoaded(a,b)},applyFilter:function(a,b){return b==null&&(b={auto:!0,refresh:!0}),this.collection.applyFilter(a,b)},renderHeader:function(){var a,b=this;return this.trigger("before:render:header"),a=_(this.columns).map(function(a,b){var c;return c=a.width?"width:"+a.width+"px;":"","<th style='"+c+"' class='column-"+b+"'>"+a.header+"</th>"}),this.header.append("<tr>"+a+"</tr>")},getRowEl:function(a){return this.$("[data-record-id="+a+"]","table")},render_row:function(
9
+ a,b,c){var d,e,f,g,h,i,j=this;return c==null&&(c={}),h=this.rowClass,g=(a!=null?a.get:void 0)&&(a!=null?a.attributes:void 0)?a.get("id"):"",this.trigger("before:render:row",a,b),e=_(this.columns).map(function(b,c){var d,e,f;return f=j.cell_renderer(a,b,c),e=b.width?"width:"+b.width+"px;":"",d=_.isUndefined(f)?"":f,"<td style='"+e+"' class='column-"+c+"'>"+d+"</td>"}),c.cellsOnly?e:(d="",this.alternateRowClasses&&(d=b%2===0?"even":"odd"),f="<tr data-record-id='"+g+"' data-row-index='"+b+"' class='"+h+" "+d+"' id='row-"+b+"'>"+e+"</tr>",c.contentOnly===!0?f:(i=this.body)!=null?i.append(f):void 0)},cell_renderer:function(a,b,c){var d;return _.isFunction(b.renderer)?b.renderer.apply(this,[a,b,c]):b.data.match(/\w+\.\w+/)?(d=a.attributes||a,Luca.util.nestedValue(b.data,d)):(typeof a.get=="function"?a.get(b.data):void 0)||a[b.data]},double_click_handler:function(a){var b,c,d,e;return b=c=$(a.currentTarget),e=c.data("row-index"),d=this.collection.at(e),this.trigger("row:double:click",this,d,e)},click_handler:function(a){var b,c,d,e;return b=c=$(a.currentTarget),e=c.data("row-index"),d=this.collection.at(e),this.trigger("row:click",this,d,e),$("."+this.rowClass,this.body).removeClass("selected-row"),b.addClass("selected-row")}})}.call(this),function(){_.def("Luca.components.LoadMask")["extends"]("Luca.View")["with"]({className:"luca-ui-load-mask",bodyTemplate:"components/load_mask"})}.call(this),function(){var a,b,c,d;b=Luca.define("Luca.components.MultiCollectionView"),b["extends"]("Luca.containers.CardView"),b.behavesAs("LoadMaskable","Filterable","Paginatable"),b.triggers("before:refresh","after:refresh","refresh","empty:results"),b.defaultsTo({version:1,stateful:!0,defaultState:{activeView:0},viewContainerClass:"luca-ui-multi-view-container",initialize:function(b){var e,f,g,h;this.options=b!=null?b:{},this.components||(this.components=this.views),h=this.components;for(f=0,g=h.length;f<g;f++)e=h[f],d(e);return this.on("collection:change",this.refresh,this),this.on("after:card:switch",this.refresh,this),this.on("before:components",c,this),this.on("after:components",a,this),Luca.containers.CardView.prototype.initialize.apply(this,arguments)},refresh:function(){var a;return(a=this.activeComponent())!=null?a.trigger("refresh"):void 0},getQuery:Luca.components.CollectionView.prototype.getQuery,getQueryOptions:Luca.components.CollectionView.prototype.getQueryOptions,getCollection:Luca.components.CollectionView.prototype.getCollection}),a=function(){var a;return a=this,a.eachComponent(function(b){var c,d,e,f,g;f=["refresh","before:refresh","after:refresh","empty:results"],g=[];for(d=0,e=f.length;d<e;d++)c=f[d],g.push(b.on(c,function(){if(b===a.activeComponent())return a.trigger(c)}));return g})},c=function(){var a,b,c,d,e,f;b=this,e=this.components,f=[];for(c=0,d=e.length;c<d;c++)a=e[c],f.push(_.extend(a,{collection:(typeof b.getCollection=="function"?b.getCollection():void 0)||this.collection,getQuery:b.getQuery,getQueryOptions:b.getQueryOptions}));return f},d=function(a){var b;b=a.type||a.ctype;if(b==="collection"||b==="collection_view"||b==="table"||b==="table_view")return;throw"The MultiCollectionView expects to contain multiple collection views"}}.call(this),function(){_.def("Luca.components.NavBar")["extends"]("Luca.View")["with"]({fixed:!0,position:"top",className:"navbar",brand:"Luca.js",bodyTemplate:"nav_bar",bodyClassName:"luca-ui-navbar-body",beforeRender:function(){this.fixed&&this.$el.addClass("navbar-fixed-"+this.position),this.brand!=null&&this.content().append("<a class='brand' href='#'>"+this.brand+"</a>");if(this.template)return this.content().append(Luca.template(this.template,this))},render:function(){return this},content:function(){return this.$(".container").eq(0)}})}.call(this),function(){_.def("Luca.PageController")["extends"]("Luca.components.Controller")["with"]({version:2})}.call(this),function(){var a;a=Luca.register("Luca.components.PaginationControl"),a["extends"]("Luca.View"),a.defines({template:"components/pagination",stateful:!0,autoBindEventHandlers:!0,events:{"click a[data-page-number]":"selectPage","click a.next":"nextPage","click a.prev":"previousPage"},afterInitialize:function(){return _.bindAll(this,"refresh"),this.state.on("change",this.refresh,this)},limit:function(){var a;return parseInt(this.state.get("limit")||((a=this.collection)!=null?a.length:void 0))},page:function(){return parseInt(this.state.get("page")||1)},nextPage:function(){if(!this.nextEnabled())return;return this.state.set("page",this.page()+1)},previousPage:function(){if(!this.previousEnabled())return;return this.state.set("page",this.page()-1)},selectPage:function(a){var b,c;return b=c=this.$(a.target),b.is("a.page")||(b=c=c.closest("a.page")),c.siblings().removeClass("is-selected"),b.addClass("is-selected"),this.setPage(c.data("page-number"))},setPage:function(a,b){return a==null&&(a=1),b==null&&(b={}),this.state.set("page",a,b)},setLimit:function(a,b){return a==null&&(a=1),b==null&&(b={}),this.state.set("limit",a,b)},pageButtonContainer:function(){return this.$(".group")},previousEnabled:function(){return this.page()>1},nextEnabled:function(){return this.page()<this.totalPages()},previousButton:function(){return this.$("a.page.prev")},nextButton:function(){return this.$("a.page.next")},pageButtons:function(){return this.$("a[data-page-number]",this.pageButtonContainer())},refresh:function(){var a,b,c;this.pageButtonContainer().empty();for(b=1,c=this.totalPages();1<=c?b<=c:b>=c;1<=c?b++:b--)a=this.make("a",{"data-page-number":b,"class":"page"},b),this.pageButtonContainer().append(a);return this.toggleNavigationButtons(),this.selectActivePageButton(),this},toggleNavigationButtons:function(){this.$("a.next, a.prev").addClass("disabled"),this.nextEnabled()&&this.nextButton().removeClass("disabled");if(this.previousEnabled())return this.previousButton().removeClass("disabled")},selectActivePageButton:function(){return this.activePageButton().addClass("is-selected")},activePageButton:function(){return this.pageButtons().filter("[data-page-number='"+this.page()+"']")},totalPages:function(){return parseInt(Math.ceil(this.totalItems()/this.itemsPerPage()))},totalItems:function(){var a;return parseInt(((a=this.collection)!=null?a.length:void 0)||0)},itemsPerPage:function(a,b){return b==null&&(b={}),a!=null&&this.state.set("limit",a,b),parseInt(this.state.get("limit"))}})}.call(this),function(){_.def("Luca.components.RecordManager")["extends"]("Luca.containers.CardView")["with"]({events:{"click .record-manager-grid .edit-link":"edit_handler","click .record-manager-filter .filter-button":"filter_handler","click .record-manager-filter .reset-button":"reset_filter_handler","click .add-button":"add_handler","click .refresh-button":"filter_handler","click .back-to-search-button":"back_to_search_handler"},record_manager:!0,initialize:function(a){var b=this;this.options=a!=null?a:{},Luca.containers.CardView.prototype.initialize.apply(this,arguments);if(!this.name)throw"Record Managers must specify a name";return _.bindAll(this,"add_handler","edit_handler","filter_handler","reset_filter_handler"),this.filterConfig&&_.extend(this.components[0][0],this.filterConfig),this.gridConfig&&_.extend(this.components[0][1],this.gridConfig),this.editorConfig&&_.extend(this.components[1][0],this.editorConfig),this.bind("after:card:switch",function(){b.activeCard===0&&b.trigger("activation:search",b);if(b.activeCard===1)return b.trigger("activation:editor",b)})},components:[{ctype:"split_view",relayFirstActivation:!0,components:[{ctype:"form_view"},{ctype:"grid_view"}]},{ctype:"form_view"}],getSearch:function(a,b){return a==null&&(a=!1),b==null&&(b=!0),a===!0&&this.activate(0),b===!0&&this.getEditor().clear(),_.first(this.components)},getFilter:function(){return _.first(this.getSearch().components)},getGrid:function(){return _.last(this.getSearch().components)},getCollection:function(){return this.getGrid().collection},getEditor:function(a,b){var c=this;return a==null&&(a=!1),b==null&&(b=!1),a===!0&&this.activate(1,function(a,b,c){return c.reset()}),_.last(this.components)},beforeRender:function(){var a;return this.$el.addClass(""+this.resource+"-manager"),(a=Luca.containers.CardView.prototype.beforeRender)!=null&&a.apply(this,arguments),this.$el.addClass(""+this.resource+" record-manager"),this.$el.data("resource",this.resource),$(this.getGrid().el).addClass(""+this.resource+" record-manager-grid"),$(this.getFilter().el).addClass(""+this.resource+" record-manager-filter"),$(this.getEditor().el).addClass(""+this.resource+" record-manager-editor")},afterRender:function(){var a,b,c,d,e,f,g=this;return(f=Luca.containers.CardView.prototype.afterRender)!=null&&f.apply(this,arguments),e=this,d=this.getGrid(),c=this.getFilter(),b=this.getEditor(),a=this.getCollection(),d.bind("row:double:click",function(a,c,d){return e.getEditor(!0),b.loadModel(c)}),b.bind("before:submit",function(){return $(".form-view-flash-container",g.el).html(""),$(".form-view-body",g.el).spin("large")}),b.bind("after:submit",function(){return $(".form-view-body",g.el).spin(!1)}),b.bind("after:submit:fatal_error",function(){return $(".form-view-flash-container",g.el).append("<li class='error'>There was an internal server error saving this record. Please contact developers@benchprep.com to report this error.</li>"),$(".form-view-body",g.el).spin(!1)}),b.bind("after:submit:error",function(a,b,c){return _(c.errors).each(function(a){return $(".form-view-flash-container",g.el).append("<li class='error'>"+a+"</li>")})}),b.bind("after:submit:success",function(a,b,c){return $(".form-view-flash-container",g.el).append("<li class='success'>Successfully Saved Record</li>"),b.set(c.result),a.loadModel(b),d.refresh(),_.delay(function(){return $(".form-view-flash-container li.success",g.el).fadeOut(1e3),$(".form-view-flash-container",g.el).html("")},4e3)}),c.eachComponent(function(a){try{return a.bind("on:change",g.filter_handler)}catch(b){return}})},firstActivation:function(){return this.getGrid().trigger("first:activation",this,this.getGrid()),this.getFilter().trigger("first:activation",this,this.getGrid())},reload:function(){var a,b,c,d;return d=this,c=this.getGrid(),b=this.getFilter(),a=this.getEditor(),b.clear(),c.applyFilter()},manageRecord:function(a){var b,c=this;return b=this.getCollection().get(a),b?this.loadModel(b):(console.log("Could Not Find Model, building and fetching"),b=this.buildModel(),b.set({id:a},{silent:!0}),b.fetch({success:function(a,b){return c.loadModel(a)}}))},loadModel:function(a){return this.current_model=a,this.getEditor(!0).loadModel(this.current_model),this.trigger("model:loaded",this.current_model)},currentModel:function(){return this.getEditor(!1).currentModel()},buildModel:function(){var a,b,c;return b=this.getEditor(!1),a=this.getCollection(),a.add([{}],{silent:!0,at:0}),c=a.at(0)},createModel:function(){return this.loadModel(this.buildModel())},reset_filter_handler:function(a){return this.getFilter().clear(),this.getGrid().applyFilter(this.getFilter().getValues())},filter_handler:function(a){return this.getGrid().applyFilter(this.getFilter().getValues())},edit_handler:function(a){var b,c,d,e;return b=d=$(a.currentTarget),e=d.parents("tr").data("record-id"),e&&(c=this.getGrid().collection.get(e)),c||(c=this.getGrid().collection.at(row_index))},add_handler:function(a){var b,c,d;return b=c=$(a.currentTarget),d=c.parents(".record-manager").eq(0).data("resource")},destroy_handler:function(a){},back_to_search_handler:function(){}})}.call(this),function(){_.def("Luca.Router")["extends"]("Backbone.Router")["with"]({routes:{"":"default"},initialize:function(a){var b=this;return this.options=a,_.extend(this,this.options),this.routeHandlers=_(this.routes).values(),_(this.routeHandlers).each(function(a){return b.bind("route:"+a,function(){return b.trigger.apply(b,["change:navigation",a].concat(_(arguments).flatten()))})})},navigate:function(a,b){return b==null&&(b=!1),Backbone.Router.prototype.navigate.apply(this,arguments),this.buildPathFrom(Backbone.history.getFragment())},buildPathFrom:function(a){var b=this;return _(this.routes).each(function(c,d){var e,f;f=b._routeToRegExp(d);if(f.test(a))return e=b._extractParameters(f,a),b.trigger.apply(b,["change:navigation",c].concat(e))})}})}.call(this),function(){var a;_.def("Luca.components.TableView")["extends"]("Luca.components.CollectionView")["with"]({additionalClassNames:"table",tagName:"table",bodyTemplate:"table_view",bodyTagName:"tbody",bodyClassName:"table-body",itemTagName:"tr",stateful:!0,observeChanges:!0,columns:[],emptyText:"There are no results to display",itemRenderer:function(a,b){return Luca.components.TableView.rowRenderer.call(this,a,b)},initialize:function(a){var b,c=this;return this.options=a!=null?a:{},Luca.components.CollectionView.prototype.initialize.apply(this,arguments),this.columns=function(){var a,c,d,e;d=this.columns,e=[];for(a=0,c=d.length;a<c;a++)b=d[a],_.isString(b)&&(b={reader:b}),b.header==null&&(b.header=_.str.titleize(_.str.humanize(b.reader))),e.push(b);return e}.call(this),this.defer(function(){return Luca.components.TableView.renderHeader.call(c,c.columns,c.$("thead"))}).until("after:render")}}),a=Backbone.View.prototype.make,Luca.components.TableView.renderHeader=function(a,b){var c,d,e,f,g,h;e=0,d=function(){var b,d,f;f=[];for(b=0,d=a.length;b<d;b++)c=a[b],f.push("<th data-col-index='"+e++ +"'>"+c.header+"</th>");return f}(),this.$(b).append("<tr>"+d.join("")+"</tr>"),e=0,h=[];for(f=0,g=a.length;f<g;f++)c=a[f],c.width!=null&&h.push(this.$("th[data-col-index='"+e++ +"']",b).css("width",c.width));return h},Luca.components.TableView.rowRenderer=function(a,b,c){var d,e,f,g,h,i;d=0,h=this.columns,i=[];for(f=0,g=h.length;f<g;f++)e=h[f],i.push(Luca.components.TableView.renderColumn.call(this,e,a,b,d++));return i},Luca.components.TableView.renderColumn=function(b,c,d,e){var f;return f=d.read(b.reader),_.isFunction(b.renderer)&&(f=b.renderer.call(this,f,d,b)),a("td",{"data-col-index":e},f)}}.call(this),function(){_.def("Luca.components.ToolbarDialog")["extends"]("Luca.View")["with"]({className:"luca-ui-toolbar-dialog span well",styles:{position:"absolute","z-Index":"3000","float":"left"},initialize:function(a){return this.options=a!=null?a:{},this._super("initialize",this,arguments)},createWrapper:function(){return this.make("div",{"class":"component-picker span4 well",style:"position: absolute; z-index:12000"})},show:function(){return this.$el.parent().show()},hide:function(){return this.$el.parent().hide()},toggle:function(){return this.$el.parent().toggle()}})}.call(this),function(){}.call(this),function(){}.call(this),function(){}.call(this);
@@ -18,7 +18,7 @@
18
18
  };
19
19
 
20
20
  _.extend(Luca, {
21
- VERSION: "0.9.2",
21
+ VERSION: "0.9.45",
22
22
  core: {},
23
23
  containers: {},
24
24
  components: {},
@@ -55,8 +55,8 @@
55
55
  return memo;
56
56
  }, {});
57
57
 
58
- Luca.find = function() {
59
- return;
58
+ Luca.find = function(el) {
59
+ return Luca($(el).data('luca-id'));
60
60
  };
61
61
 
62
62
  Luca.supportsEvents = Luca.supportsBackboneEvents = function(obj) {
@@ -228,62 +228,96 @@
228
228
 
229
229
  }).call(this);
230
230
  (function() {
231
- var DeferredBindingProxy;
232
-
233
- DeferredBindingProxy = (function() {
234
-
235
- function DeferredBindingProxy(object, operation, wrapWithUnderscore) {
236
- var fn,
237
- _this = this;
238
- this.object = object;
239
- if (wrapWithUnderscore == null) wrapWithUnderscore = true;
240
- if (_.isFunction(operation)) {
241
- fn = operation;
242
- } else if (_.isString(operation) && _.isFunction(this.object[operation])) {
243
- fn = this.object[operation];
244
- }
245
- if (!_.isFunction(fn)) {
246
- throw "Must pass a function or a string representing one";
247
- }
248
- if (wrapWithUnderscore === true) {
249
- this.fn = function() {
250
- return _.defer(fn);
251
- };
252
- } else {
253
- this.fn = fn;
254
- }
255
- this;
256
- }
257
-
258
- DeferredBindingProxy.prototype.until = function(watch, trigger) {
259
- if ((watch != null) && !(trigger != null)) {
260
- trigger = watch;
261
- watch = this.object;
262
- }
263
- watch.once(trigger, this.fn);
264
- return this.object;
265
- };
266
-
267
- return DeferredBindingProxy;
268
-
269
- })();
270
-
271
- Luca.Events = {
272
- defer: function(operation, wrapWithUnderscore) {
273
- if (wrapWithUnderscore == null) wrapWithUnderscore = true;
274
- return new DeferredBindingProxy(this, operation, wrapWithUnderscore);
275
- },
276
- once: function(trigger, callback, context) {
277
- var onceFn;
278
- context || (context = this);
279
- onceFn = function() {
280
- callback.apply(context, arguments);
281
- return this.unbind(trigger, onceFn);
282
- };
283
- return this.bind(trigger, onceFn);
284
- }
285
- };
286
-
231
+ this.JST || (this.JST = {});
232
+ this.JST["luca-src/templates/components/bootstrap_form_controls"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class="btn-group form-actions">\n <a class="btn btn-primary submit-button">\n <i class="icon icon-ok icon-white"></i>\n Save Changes\n </a>\n <a class="btn reset-button cancel-button">\n <i class="icon icon-remove"></i>\n Cancel\n </a>\n</div>\n');}return __p.join('');};
233
+ }).call(this);
234
+ (function() {
235
+ this.JST || (this.JST = {});
236
+ this.JST["luca-src/templates/components/collection_loader_view"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div id="progress-modal" class="modal" style="display: none">\n <div class="progress progress-info progress-striped active">\n <div class="bar" style="width:0%;"></div>\n </div>\n <div class="message">Initializing...</div>\n</div>\n');}return __p.join('');};
237
+ }).call(this);
238
+ (function() {
239
+ this.JST || (this.JST = {});
240
+ this.JST["luca-src/templates/components/form_alert"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class="', className ,'">\n <a class="close" href="#" data-dismiss="alert">x</a>\n ', message ,'\n</div>\n');}return __p.join('');};
241
+ }).call(this);
242
+ (function() {
243
+ this.JST || (this.JST = {});
244
+ this.JST["luca-src/templates/components/grid_view"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class="luca-ui-g-view-wrapper">\n <div class="g-view-header"></div>\n <div class="luca-ui-g-view-body">\n <table class="luca-ui-g-view scrollable-table" width="100%" cellpadding=0 cellspacing=0>\n <thead class="fixed"></thead>\n <tbody class="scrollable"></tbody>\n <tfoot></tfoot>\n </table>\n </div>\n <div class="luca-ui-g-view-header"></div>\n</div>\n');}return __p.join('');};
245
+ }).call(this);
246
+ (function() {
247
+ this.JST || (this.JST = {});
248
+ this.JST["luca-src/templates/components/grid_view_empty_text"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class="empty-text empty-text-wrapper">\n <p>', text ,'</p>\n</div>\n');}return __p.join('');};
249
+ }).call(this);
250
+ (function() {
251
+ this.JST || (this.JST = {});
252
+ this.JST["luca-src/templates/components/load_mask"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class="load-mask">\n <div class="progress progress-striped active">\n <div class="bar" style="width:0%"></div>\n </div>\n</div>\n');}return __p.join('');};
253
+ }).call(this);
254
+ (function() {
255
+ this.JST || (this.JST = {});
256
+ this.JST["luca-src/templates/components/nav_bar"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class="navbar-inner">\n <div class="luca-ui-navbar-body container">\n </div>\n</div>\n');}return __p.join('');};
257
+ }).call(this);
258
+ (function() {
259
+ this.JST || (this.JST = {});
260
+ this.JST["luca-src/templates/components/pagination"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class="pagination">\n <a class="btn previous">\n <i class="icon icon-chevron-left"></i>\n </a>\n <div class="pagination-group">\n </div>\n <a class="btn next">\n <i class="icon icon-chevron-right"></i>\n </a>\n</div>\n');}return __p.join('');};
261
+ }).call(this);
262
+ (function() {
263
+ this.JST || (this.JST = {});
264
+ this.JST["luca-src/templates/containers/basic"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div id="', id ,'" class="', classes ,'" style="', style ,'"></div>\n');}return __p.join('');};
265
+ }).call(this);
266
+ (function() {
267
+ this.JST || (this.JST = {});
268
+ this.JST["luca-src/templates/containers/tab_selector_container"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div id="', cid ,'-tab-selector" class="tab-selector-container">\n <ul id="', cid ,'-tabs-nav" class="nav nav-tabs">\n '); for(var i = 0; i < components.length; i++ ) { __p.push('\n '); var component = components[i];__p.push('\n <li class="tab-selector" data-target="', i ,'">\n <a data-target="', i ,'">\n ', component.title ,'\n </a>\n </li>\n '); } __p.push('\n </ul>\n</div>\n');}return __p.join('');};
269
+ }).call(this);
270
+ (function() {
271
+ this.JST || (this.JST = {});
272
+ this.JST["luca-src/templates/containers/tab_view"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<ul id="', cid ,'-tabs-selector" class="nav ', navClass ,'"></ul>\n<div id="', cid ,'-tab-view-content" class="tab-content"></div>\n');}return __p.join('');};
273
+ }).call(this);
274
+ (function() {
275
+ this.JST || (this.JST = {});
276
+ this.JST["luca-src/templates/containers/toolbar_wrapper"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class="luca-ui-toolbar-wrapper" id="', id ,'"></div>\n');}return __p.join('');};
277
+ }).call(this);
278
+ (function() {
279
+ this.JST || (this.JST = {});
280
+ this.JST["luca-src/templates/fields/button_field"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<label>&nbsp;</label>\n<input style="', inputStyles ,'" class="btn ', input_class ,'" value="', input_value ,'" type="', input_type ,'" id="<%= input_id" />\n');}return __p.join('');};
281
+ }).call(this);
282
+ (function() {
283
+ this.JST || (this.JST = {});
284
+ this.JST["luca-src/templates/fields/button_field_link"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<a class="btn ', input_class ,'">\n '); if(icon_class.length) { __p.push('\n <i class="', icon_class ,'"></i>\n ', input_value ,'\n '); } __p.push('\n</a>\n');}return __p.join('');};
285
+ }).call(this);
286
+ (function() {
287
+ this.JST || (this.JST = {});
288
+ this.JST["luca-src/templates/fields/checkbox_array"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class="control-group">\n <label for="', input_id ,'"><%= label =>\n <div class="controls"><div>\n</div>\n');}return __p.join('');};
289
+ }).call(this);
290
+ (function() {
291
+ this.JST || (this.JST = {});
292
+ this.JST["luca-src/templates/fields/checkbox_array_item"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<label for="', input_id ,'">\n <input id="', input_id ,'" type="checkbox" name="', input_name ,'" value="', value ,'" />\n</label>\n');}return __p.join('');};
293
+ }).call(this);
294
+ (function() {
295
+ this.JST || (this.JST = {});
296
+ this.JST["luca-src/templates/fields/checkbox_field"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<label for="', input_id ,'">\n ', label ,'\n <input type="checkbox" name="', input_name ,'" value="', input_value ,'" style="', inputStyles ,'" />\n</label>\n\n'); if(helperText) { __p.push('\n<p class="helper-text help-block">\n ', helperText ,'\n</p>\n'); } __p.push('\n');}return __p.join('');};
297
+ }).call(this);
298
+ (function() {
299
+ this.JST || (this.JST = {});
300
+ this.JST["luca-src/templates/fields/file_upload_field"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<label for="', input_id ,'">\n ', label ,'\n <input type="file" name="', input_name ,'" value="', input_value ,'" style="', inputStyles ,'" />\n</label>\n\n'); if(helperText) { __p.push('\n<p class="helper-text help-block">\n ', helperText ,'\n</p>\n'); } __p.push('\n');}return __p.join('');};
301
+ }).call(this);
302
+ (function() {
303
+ this.JST || (this.JST = {});
304
+ this.JST["luca-src/templates/fields/hidden_field"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push(' <input type="hidden" name="', input_name ,'" value="', input_value ,'" style="', inputStyles ,'" />\n');}return __p.join('');};
305
+ }).call(this);
306
+ (function() {
307
+ this.JST || (this.JST = {});
308
+ this.JST["luca-src/templates/fields/select_field"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<label for="', input_id ,'">\n ', label ,'\n</label>\n<div class="controls">\n <select name="', input_name ,'" value="', input_value ,'" style="', inputStyles ,'" ></select>\n '); if(helperText) { __p.push('\n <p class="helper-text help-block">\n ', helperText ,'\n </p>\n '); } __p.push('\n</div>\n');}return __p.join('');};
309
+ }).call(this);
310
+ (function() {
311
+ this.JST || (this.JST = {});
312
+ this.JST["luca-src/templates/fields/text_area_field"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<label for="', input_id ,'">\n ', label ,'\n</label>\n<div class="controls">\n <textarea name="', input_name ,'" style="', inputStyles ,'" >', input_value ,'</textarea>\n '); if(helperText) { __p.push('\n <p class="helper-text help-block">\n ', helperText ,'\n </p>\n '); } __p.push('\n</div>\n');}return __p.join('');};
313
+ }).call(this);
314
+ (function() {
315
+ this.JST || (this.JST = {});
316
+ this.JST["luca-src/templates/fields/text_field"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push(''); if(typeof(label)!=="undefined" && (typeof(hideLabel) !== "undefined" && !hideLabel) || (typeof(hideLabel)==="undefined")) {__p.push('\n<label class="control-label" for="', input_id ,'">', label ,'</label>\n'); } __p.push('\n\n<div class="controls">\n'); if( typeof(addOn) !== "undefined" ) { __p.push('\n <span class="add-on">', addOn ,'</span>\n'); } __p.push('\n<input type="text" name="', input_name ,'" style="', inputStyles ,'" value="', input_value ,'" />\n'); if(helperText) { __p.push('\n<p class="helper-text help-block">\n ', helperText ,'\n</p>\n'); } __p.push('\n\n</div>\n');}return __p.join('');};
317
+ }).call(this);
318
+ (function() {
319
+ this.JST || (this.JST = {});
320
+ this.JST["luca-src/templates/table_view"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<thead></thead>\n<tbody class="table-body"></tbody>\n<tfoot></tfoot>\n<caption></caption>\n');}return __p.join('');};
287
321
  }).call(this);
288
322
  (function() {
289
323
  var currentNamespace;
@@ -297,6 +331,12 @@
297
331
 
298
332
  Luca.util.nestedValue = Luca.util.resolve;
299
333
 
334
+ Luca.util.argumentsLogger = function(prompt) {
335
+ return function() {
336
+ return console.log(prompt, arguments);
337
+ };
338
+ };
339
+
300
340
  Luca.util.classify = function(string) {
301
341
  if (string == null) string = "";
302
342
  return _.string.camelize(_.string.capitalize(string));
@@ -371,6 +411,20 @@
371
411
 
372
412
  Luca.util.make = Backbone.View.prototype.make;
373
413
 
414
+ Luca.util.list = function(list, options, ordered) {
415
+ var container, item, _i, _len;
416
+ if (options == null) options = {};
417
+ container = ordered ? "ol" : "ul";
418
+ container = Luca.util.make(container, options);
419
+ if (_.isArray(list)) {
420
+ for (_i = 0, _len = list.length; _i < _len; _i++) {
421
+ item = list[_i];
422
+ $(container).append(Luca.util.make("li", {}, item));
423
+ }
424
+ }
425
+ return container.outerHTML;
426
+ };
427
+
374
428
  Luca.util.label = function(contents, type, baseClass) {
375
429
  var cssClass;
376
430
  if (contents == null) contents = "";
@@ -395,7 +449,164 @@
395
449
 
396
450
  }).call(this);
397
451
  (function() {
398
- var DefineProxy;
452
+
453
+ Luca.DevelopmentToolHelpers = {
454
+ refreshCode: function() {
455
+ var view;
456
+ view = this;
457
+ _(this.eventHandlerProperties()).each(function(prop) {
458
+ return view[prop] = view.definitionClass()[prop];
459
+ });
460
+ if (this.autoBindEventHandlers === true) this.bindAllEventHandlers();
461
+ return this.delegateEvents();
462
+ },
463
+ eventHandlerProperties: function() {
464
+ var handlerIds;
465
+ handlerIds = _(this.events).values();
466
+ return _(handlerIds).select(function(v) {
467
+ return _.isString(v);
468
+ });
469
+ },
470
+ eventHandlerFunctions: function() {
471
+ var handlerIds,
472
+ _this = this;
473
+ handlerIds = _(this.events).values();
474
+ return _(handlerIds).map(function(handlerId) {
475
+ if (_.isFunction(handlerId)) {
476
+ return handlerId;
477
+ } else {
478
+ return _this[handlerId];
479
+ }
480
+ });
481
+ }
482
+ };
483
+
484
+ }).call(this);
485
+ (function() {
486
+ var DeferredBindingProxy,
487
+ __slice = Array.prototype.slice;
488
+
489
+ DeferredBindingProxy = (function() {
490
+
491
+ function DeferredBindingProxy(object, operation, wrapWithUnderscore) {
492
+ var fn;
493
+ this.object = object;
494
+ if (wrapWithUnderscore == null) wrapWithUnderscore = true;
495
+ if (_.isFunction(operation)) {
496
+ fn = operation;
497
+ } else if (_.isString(operation) && _.isFunction(this.object[operation])) {
498
+ fn = this.object[operation];
499
+ }
500
+ if (!_.isFunction(fn)) {
501
+ throw "Must pass a function or a string representing one";
502
+ }
503
+ if (wrapWithUnderscore === true) {
504
+ this.fn = _.bind(function() {
505
+ return _.defer(fn);
506
+ }, this.object);
507
+ } else {
508
+ this.fn = _.bind(fn, this.object);
509
+ }
510
+ this;
511
+ }
512
+
513
+ DeferredBindingProxy.prototype.until = function(watch, trigger) {
514
+ if ((watch != null) && !(trigger != null)) {
515
+ trigger = watch;
516
+ watch = this.object;
517
+ }
518
+ watch.once(trigger, this.fn);
519
+ return this.object;
520
+ };
521
+
522
+ return DeferredBindingProxy;
523
+
524
+ })();
525
+
526
+ Luca.Events = {
527
+ defer: function(operation, wrapWithUnderscore) {
528
+ if (wrapWithUnderscore == null) wrapWithUnderscore = true;
529
+ return new DeferredBindingProxy(this, operation, wrapWithUnderscore);
530
+ },
531
+ once: function(trigger, callback, context) {
532
+ var onceFn;
533
+ context || (context = this);
534
+ onceFn = function() {
535
+ callback.apply(context, arguments);
536
+ return this.unbind(trigger, onceFn);
537
+ };
538
+ return this.bind(trigger, onceFn);
539
+ }
540
+ };
541
+
542
+ Luca.EventsExt = {
543
+ waitUntil: function(trigger, context) {
544
+ return this.waitFor.call(this, trigger, context);
545
+ },
546
+ waitFor: function(trigger, context) {
547
+ var proxy, self;
548
+ self = this;
549
+ return proxy = {
550
+ on: function(target) {
551
+ return target.waitFor.call(target, trigger, context);
552
+ },
553
+ and: function() {
554
+ var fn, runList, _i, _len, _results;
555
+ runList = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
556
+ _results = [];
557
+ for (_i = 0, _len = runList.length; _i < _len; _i++) {
558
+ fn = runList[_i];
559
+ fn = _.isFunction(fn) ? fn : self[fn];
560
+ _results.push(self.once(trigger, fn, context));
561
+ }
562
+ return _results;
563
+ },
564
+ andThen: function() {
565
+ return self.and.apply(self, arguments);
566
+ }
567
+ };
568
+ },
569
+ relayEvent: function(trigger) {
570
+ var _this = this;
571
+ return {
572
+ on: function() {
573
+ var components;
574
+ components = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
575
+ return {
576
+ to: function() {
577
+ var component, target, targets, _i, _len, _results;
578
+ targets = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
579
+ _results = [];
580
+ for (_i = 0, _len = targets.length; _i < _len; _i++) {
581
+ target = targets[_i];
582
+ _results.push((function() {
583
+ var _j, _len2, _results2,
584
+ _this = this;
585
+ _results2 = [];
586
+ for (_j = 0, _len2 = components.length; _j < _len2; _j++) {
587
+ component = components[_j];
588
+ _results2.push(component.on(trigger, function() {
589
+ var args;
590
+ args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
591
+ args.unshift(trigger);
592
+ return target.trigger.apply(target, args);
593
+ }));
594
+ }
595
+ return _results2;
596
+ }).call(_this));
597
+ }
598
+ return _results;
599
+ }
600
+ };
601
+ }
602
+ };
603
+ }
604
+ };
605
+
606
+ }).call(this);
607
+ (function() {
608
+ var DefineProxy,
609
+ __slice = Array.prototype.slice;
399
610
 
400
611
  Luca.define = function(componentName) {
401
612
  return new DefineProxy(componentName);
@@ -428,68 +639,497 @@
428
639
  return this;
429
640
  };
430
641
 
431
- DefineProxy.prototype["extends"] = function(superClassName) {
432
- this.superClassName = superClassName;
433
- return this;
642
+ DefineProxy.prototype["extends"] = function(superClassName) {
643
+ this.superClassName = superClassName;
644
+ return this;
645
+ };
646
+
647
+ DefineProxy.prototype.extend = function(superClassName) {
648
+ this.superClassName = superClassName;
649
+ return this;
650
+ };
651
+
652
+ DefineProxy.prototype.enhance = function(properties) {
653
+ if (properties != null) return this["with"](properties);
654
+ return this;
655
+ };
656
+
657
+ DefineProxy.prototype.defaultsTo = function(properties) {
658
+ if (properties != null) return this["with"](properties);
659
+ return this;
660
+ };
661
+
662
+ DefineProxy.prototype.defaults = function(properties) {
663
+ if (properties != null) return this["with"](properties);
664
+ return this;
665
+ };
666
+
667
+ DefineProxy.prototype.hasDefaultProperties = function(properties) {
668
+ if (properties != null) return this["with"](properties);
669
+ return this;
670
+ };
671
+
672
+ DefineProxy.prototype.behavesAs = function() {
673
+ var mixin, mixins, _i, _len;
674
+ mixins = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
675
+ _.defaults(this.properties || (this.properties = {}), {
676
+ mixins: []
677
+ });
678
+ for (_i = 0, _len = mixins.length; _i < _len; _i++) {
679
+ mixin = mixins[_i];
680
+ this.properties.mixins.push(mixin);
681
+ }
682
+ return this;
683
+ };
684
+
685
+ DefineProxy.prototype["with"] = function(properties) {
686
+ var at, componentType, _base;
687
+ if (properties == null) properties = {};
688
+ _.defaults((this.properties || (this.properties = {})), properties);
689
+ at = this.namespaced ? Luca.util.resolve(this.namespace, window || global) : window || global;
690
+ if (this.namespaced && !(at != null)) {
691
+ eval("(window||global)." + this.namespace + " = {}");
692
+ at = Luca.util.resolve(this.namespace, window || global);
693
+ }
694
+ at[this.componentId] = Luca.extend(this.superClassName, this.componentName, this.properties);
695
+ if (Luca.autoRegister === true) {
696
+ if (Luca.isViewPrototype(at[this.componentId])) componentType = "view";
697
+ if (Luca.isCollectionPrototype(at[this.componentId])) {
698
+ (_base = Luca.Collection).namespaces || (_base.namespaces = []);
699
+ Luca.Collection.namespaces.push(this.namespace);
700
+ componentType = "collection";
701
+ }
702
+ if (Luca.isModelPrototype(at[this.componentId])) componentType = "model";
703
+ Luca.register(_.string.underscored(this.componentId), this.componentName, componentType);
704
+ }
705
+ return at[this.componentId];
706
+ };
707
+
708
+ return DefineProxy;
709
+
710
+ })();
711
+
712
+ Luca.extend = function(superClassName, childName, properties) {
713
+ var definition, include, superClass, _i, _len, _ref;
714
+ if (properties == null) properties = {};
715
+ superClass = Luca.util.resolve(superClassName, window || global);
716
+ if (!_.isFunction(superClass != null ? superClass.extend : void 0)) {
717
+ throw "" + superClassName + " is not a valid component to extend from";
718
+ }
719
+ properties.displayName = childName;
720
+ properties._superClass = function() {
721
+ superClass.displayName || (superClass.displayName = superClassName);
722
+ return superClass;
723
+ };
724
+ properties._super = function(method, context, args) {
725
+ var _ref;
726
+ return (_ref = this._superClass().prototype[method]) != null ? _ref.apply(context, args) : void 0;
727
+ };
728
+ definition = superClass.extend(properties);
729
+ if (_.isArray(properties != null ? properties.include : void 0)) {
730
+ _ref = properties.include;
731
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
732
+ include = _ref[_i];
733
+ if (_.isString(include)) include = Luca.util.resolve(include);
734
+ _.extend(definition.prototype, include);
735
+ }
736
+ }
737
+ return definition;
738
+ };
739
+
740
+ Luca.mixin = function(mixinName) {
741
+ var namespace, resolved;
742
+ namespace = _(Luca.mixin.namespaces).detect(function(space) {
743
+ var _ref;
744
+ return ((_ref = Luca.util.resolve(space)) != null ? _ref[mixinName] : void 0) != null;
745
+ });
746
+ namespace || (namespace = "Luca.modules");
747
+ resolved = Luca.util.resolve(namespace)[mixinName];
748
+ if (resolved == null) {
749
+ console.log("Could not find " + mixinName + " in ", Luca.mixin.namespaces);
750
+ }
751
+ return resolved;
752
+ };
753
+
754
+ Luca.mixin.namespaces = ["Luca.modules"];
755
+
756
+ Luca.mixin.namespace = function(namespace) {
757
+ Luca.mixin.namespaces.push(namespace);
758
+ return Luca.mixin.namespaces = _(Luca.mixin.namespaces).uniq();
759
+ };
760
+
761
+ Luca.decorate = function(componentPrototype) {
762
+ if (_.isString(componentPrototype)) {
763
+ componentPrototype = Luca.util.resolve(componentPrototype).prototype;
764
+ }
765
+ return {
766
+ "with": function(mixin) {
767
+ _.extend(componentPrototype, Luca.mixin(mixin));
768
+ componentPrototype.mixins || (componentPrototype.mixins = []);
769
+ componentPrototype.mixins.push(mixin);
770
+ componentPrototype.mixins = _(componentPrototype.mixins).uniq();
771
+ return componentPrototype;
772
+ }
773
+ };
774
+ };
775
+
776
+ _.mixin({
777
+ def: Luca.define
778
+ });
779
+
780
+ }).call(this);
781
+ (function() {
782
+
783
+ Luca.modules.Deferrable = {
784
+ configure_collection: function(setAsDeferrable) {
785
+ var collectionManager, _ref, _ref2;
786
+ if (setAsDeferrable == null) setAsDeferrable = true;
787
+ if (!this.collection) return;
788
+ if (_.isString(this.collection) && (collectionManager = (_ref = Luca.CollectionManager) != null ? _ref.get() : void 0)) {
789
+ this.collection = collectionManager.getOrCreate(this.collection);
790
+ }
791
+ if (!(this.collection && _.isFunction(this.collection.fetch) && _.isFunction(this.collection.reset))) {
792
+ this.collection = new Luca.Collection(this.collection.initial_set, this.collection);
793
+ }
794
+ if ((_ref2 = this.collection) != null ? _ref2.deferrable_trigger : void 0) {
795
+ this.deferrable_trigger = this.collection.deferrable_trigger;
796
+ }
797
+ if (setAsDeferrable) return this.deferrable = this.collection;
798
+ }
799
+ };
800
+
801
+ }).call(this);
802
+ (function() {
803
+ var FilterModel,
804
+ __hasProp = Object.prototype.hasOwnProperty,
805
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
806
+
807
+ Luca.modules.Filterable = {
808
+ _initializer: function(component, module) {
809
+ var oldOptions, oldQuery, sortBy, _ref, _ref2;
810
+ if (this.filterable === false) return;
811
+ this.filterState = this.getFilterModel();
812
+ if (oldQuery = this.getQuery) {
813
+ this.getQuery = function() {
814
+ return _.extend(oldQuery.call(this), this.filterState.toQuery());
815
+ };
816
+ }
817
+ if (oldOptions = this.getQueryOptions) {
818
+ this.getQueryOptions = function() {
819
+ return {};
820
+ return _.extend(oldOptions.call(this), this.filterState.toOptions());
821
+ };
822
+ }
823
+ if (sortBy = (_ref = this.filterable) != null ? (_ref2 = _ref.options) != null ? _ref2.sortBy : void 0 : void 0) {
824
+ return this.setSortBy(sortBy);
825
+ }
826
+ },
827
+ setSortBy: function(sortBy, options) {
828
+ if (options == null) options = {};
829
+ return this.filterState.setOption('sortBy', sortBy, options);
830
+ },
831
+ getFilterModel: function() {
832
+ if (this.filterState != null) return this.filterState;
833
+ this.filterState = new FilterModel(this.filterable || (this.filterable = {}));
834
+ this.filterState.on("change", function() {
835
+ return this.trigger("collection:change");
836
+ }, this);
837
+ return this.filterState;
838
+ },
839
+ applyFilter: function(query, options) {
840
+ var silent;
841
+ if (query == null) query = {};
842
+ if (options == null) options = {};
843
+ if (_.isEmpty(options)) {
844
+ options = _.defaults(options, this.getQueryOptions());
845
+ }
846
+ if (_.isEmpty(query)) query = _.defaults(query, this.getQuery());
847
+ silent = _(options)["delete"]('silent') === true;
848
+ return this.filterState.set({
849
+ query: query,
850
+ options: options
851
+ }, {
852
+ silent: silent
853
+ });
854
+ }
855
+ };
856
+
857
+ FilterModel = (function(_super) {
858
+
859
+ __extends(FilterModel, _super);
860
+
861
+ function FilterModel() {
862
+ FilterModel.__super__.constructor.apply(this, arguments);
863
+ }
864
+
865
+ FilterModel.prototype.setOption = function(option, value, options) {
866
+ var payload;
867
+ payload = {};
868
+ payload[option] = value;
869
+ return this.set('options', _.extend(this.toOptions(), payload), options);
870
+ };
871
+
872
+ FilterModel.prototype.setQueryOption = function(option, value, options) {
873
+ var payload;
874
+ payload = {};
875
+ payload[option] = value;
876
+ return this.set('query', _.extend(this.toQuery(), payload), options);
877
+ };
878
+
879
+ FilterModel.prototype.toOptions = function() {
880
+ return this.get("options");
881
+ };
882
+
883
+ FilterModel.prototype.toQuery = function() {
884
+ return this.get("query");
885
+ };
886
+
887
+ return FilterModel;
888
+
889
+ })(Backbone.Model);
890
+
891
+ }).call(this);
892
+ (function() {
893
+
894
+ Luca.modules.GridLayout = {
895
+ _initializer: function() {
896
+ if (this.gridSpan) this.$el.addClass("span" + this.gridSpan);
897
+ if (this.gridOffset) this.$el.addClass("offset" + this.gridOffset);
898
+ if (this.gridRowFluid) this.$el.addClass("row-fluid");
899
+ if (this.gridRow) return this.$el.addClass("row");
900
+ }
901
+ };
902
+
903
+ }).call(this);
904
+ (function() {
905
+
906
+ Luca.modules.LoadMaskable = {
907
+ _initializer: function() {
908
+ var _this = this;
909
+ if (this.loadMask !== true) return;
910
+ if (this.loadMask === true) {
911
+ this.defer(function() {
912
+ _this.$el.addClass('with-mask');
913
+ if (_this.$('.load-mask').length === 0) {
914
+ _this.loadMaskTarget().prepend(Luca.template(_this.loadMaskTemplate, _this));
915
+ return _this.$('.load-mask').hide();
916
+ }
917
+ }).until("after:render");
918
+ this.on(this.loadmaskEnableEvent || "enable:loadmask", this.applyLoadMask, this);
919
+ return this.on(this.loadmaskDisableEvent || "disable:loadmask", this.applyLoadMask, this);
920
+ }
921
+ },
922
+ showLoadMask: function() {
923
+ return this.trigger("enable:loadmask");
924
+ },
925
+ hideLoadMask: function() {
926
+ return this.trigger("disable:loadmask");
927
+ },
928
+ loadMaskTarget: function() {
929
+ if (this.loadMaskEl != null) {
930
+ return this.$(this.loadMaskEl);
931
+ } else {
932
+ return this.$bodyEl();
933
+ }
934
+ },
935
+ disableLoadMask: function() {
936
+ this.$('.load-mask .bar').css("width", "100%");
937
+ this.$('.load-mask').hide();
938
+ return clearInterval(this.loadMaskInterval);
939
+ },
940
+ enableLoadMask: function() {
941
+ var maxWidth,
942
+ _this = this;
943
+ this.$('.load-mask').show().find('.bar').css("width", "0%");
944
+ maxWidth = this.$('.load-mask .progress').width();
945
+ if (maxWidth < 20 && (maxWidth = this.$el.width()) < 20) {
946
+ maxWidth = this.$el.parent().width();
947
+ }
948
+ this.loadMaskInterval = setInterval(function() {
949
+ var currentWidth, newWidth;
950
+ currentWidth = _this.$('.load-mask .bar').width();
951
+ newWidth = currentWidth + 12;
952
+ return _this.$('.load-mask .bar').css('width', newWidth);
953
+ }, 200);
954
+ if (this.loadMaskTimeout == null) return;
955
+ return _.delay(function() {
956
+ return _this.disableLoadMask();
957
+ }, this.loadMaskTimeout);
958
+ },
959
+ applyLoadMask: function() {
960
+ if (this.$('.load-mask').is(":visible")) {
961
+ return this.disableLoadMask();
962
+ } else {
963
+ return this.enableLoadMask();
964
+ }
965
+ }
966
+ };
967
+
968
+ }).call(this);
969
+ (function() {
970
+
971
+ Luca.LocalStore = (function() {
972
+
973
+ function LocalStore(name) {
974
+ var store;
975
+ this.name = name;
976
+ store = localStorage.getItem(this.name);
977
+ this.data = (store && JSON.parse(store)) || {};
978
+ }
979
+
980
+ LocalStore.prototype.guid = function() {
981
+ var S4;
982
+ S4 = function() {
983
+ return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
984
+ };
985
+ return S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4();
986
+ };
987
+
988
+ LocalStore.prototype.save = function() {
989
+ return localStorage.setItem(this.name, JSON.stringify(this.data));
990
+ };
991
+
992
+ LocalStore.prototype.create = function(model) {
993
+ if (!model.id) model.id = model.attribtues.id = this.guid();
994
+ this.data[model.id] = model;
995
+ this.save();
996
+ return model;
997
+ };
998
+
999
+ LocalStore.prototype.update = function(model) {
1000
+ this.data[model.id] = model;
1001
+ this.save();
1002
+ return model;
434
1003
  };
435
1004
 
436
- DefineProxy.prototype.extend = function(superClassName) {
437
- this.superClassName = superClassName;
438
- return this;
1005
+ LocalStore.prototype.find = function(model) {
1006
+ return this.data[model.id];
439
1007
  };
440
1008
 
441
- DefineProxy.prototype.enhance = function(properties) {
442
- if (properties != null) return this["with"](properties);
443
- return this;
1009
+ LocalStore.prototype.findAll = function() {
1010
+ return _.values(this.data);
444
1011
  };
445
1012
 
446
- DefineProxy.prototype["with"] = function(properties) {
447
- var at, componentType, _base;
448
- at = this.namespaced ? Luca.util.resolve(this.namespace, window || global) : window || global;
449
- if (this.namespaced && !(at != null)) {
450
- eval("(window||global)." + this.namespace + " = {}");
451
- at = Luca.util.resolve(this.namespace, window || global);
452
- }
453
- at[this.componentId] = Luca.extend(this.superClassName, this.componentName, properties);
454
- if (Luca.autoRegister === true) {
455
- if (Luca.isViewPrototype(at[this.componentId])) componentType = "view";
456
- if (Luca.isCollectionPrototype(at[this.componentId])) {
457
- (_base = Luca.Collection).namespaces || (_base.namespaces = []);
458
- Luca.Collection.namespaces.push(this.namespace);
459
- componentType = "collection";
460
- }
461
- if (Luca.isModelPrototype(at[this.componentId])) componentType = "model";
462
- Luca.register(_.string.underscored(this.componentId), this.componentName, componentType);
463
- }
464
- return at[this.componentId];
1013
+ LocalStore.prototype.destroy = function(model) {
1014
+ delete this.data[model.id];
1015
+ this.save();
1016
+ return model;
465
1017
  };
466
1018
 
467
- return DefineProxy;
1019
+ return LocalStore;
468
1020
 
469
1021
  })();
470
1022
 
471
- Luca.extend = function(superClassName, childName, properties) {
472
- var superClass;
473
- if (properties == null) properties = {};
474
- superClass = Luca.util.resolve(superClassName, window || global);
475
- if (!_.isFunction(superClass != null ? superClass.extend : void 0)) {
476
- throw "" + superClassName + " is not a valid component to extend from";
1023
+ Backbone.LocalSync = function(method, model, options) {
1024
+ var resp, store;
1025
+ store = model.localStorage || model.collection.localStorage;
1026
+ resp = (function() {
1027
+ switch (method) {
1028
+ case "read":
1029
+ if (model.id) {
1030
+ return store.find(model);
1031
+ } else {
1032
+ return store.findAll();
1033
+ }
1034
+ case "create":
1035
+ return store.create(model);
1036
+ case "update":
1037
+ return store.update(model);
1038
+ case "delete":
1039
+ return store.destroy(model);
1040
+ }
1041
+ })();
1042
+ if (resp) {
1043
+ return options.success(resp);
1044
+ } else {
1045
+ return options.error("Record not found");
477
1046
  }
478
- properties.displayName = childName;
479
- properties._superClass = function() {
480
- superClass.displayName || (superClass.displayName = superClassName);
481
- return superClass;
482
- };
483
- properties._super = function(method, context, args) {
484
- var _ref;
485
- return (_ref = this._superClass().prototype[method]) != null ? _ref.apply(context, args) : void 0;
486
- };
487
- return superClass.extend(properties);
488
1047
  };
489
1048
 
490
- _.mixin({
491
- def: Luca.define
492
- });
1049
+ }).call(this);
1050
+ (function() {
1051
+
1052
+ Luca.modules.Paginatable = {
1053
+ paginatorViewClass: 'Luca.components.PaginationControl',
1054
+ _initializer: function() {
1055
+ var old;
1056
+ if (this.paginatable === false) return;
1057
+ _.bindAll(this, "paginationControl");
1058
+ this.getCollection || (this.getCollection = function() {
1059
+ return this.collection;
1060
+ });
1061
+ if (old = this.getQueryOptions) {
1062
+ this.getQueryOptions = function() {
1063
+ var filtered, p;
1064
+ p = this.paginationControl();
1065
+ filtered = _.extend(old.call(this), {
1066
+ limit: p.limit(),
1067
+ page: p.page()
1068
+ });
1069
+ return filtered;
1070
+ };
1071
+ }
1072
+ if (this.paginationContainer().length === 0) {
1073
+ return this.$bodyEl().after(this.make("div", {
1074
+ "class": "toolbar bottom"
1075
+ }));
1076
+ }
1077
+ },
1078
+ paginationContainer: function() {
1079
+ return this.$('.toolbar.bottom');
1080
+ },
1081
+ setCurrentPage: function(page, options) {
1082
+ if (page == null) page = 1;
1083
+ if (options == null) options = {};
1084
+ return this.paginationControl().state.set('page', page, options);
1085
+ },
1086
+ setLimit: function(limit, options) {
1087
+ if (limit == null) limit = 0;
1088
+ if (options == null) options = {};
1089
+ return this.paginationControl().state.set('limit', limit, options);
1090
+ },
1091
+ updatePagination: function(models, query, options) {
1092
+ var itemCount, paginator, totalCount, _ref;
1093
+ if (models == null) models = [];
1094
+ if (query == null) query = {};
1095
+ if (options == null) options = {};
1096
+ _.defaults(options, this.getQueryOptions(), {
1097
+ limit: 0
1098
+ });
1099
+ paginator = this.paginationControl();
1100
+ itemCount = (models != null ? models.length : void 0) || 0;
1101
+ totalCount = (_ref = this.getCollection()) != null ? _ref.length : void 0;
1102
+ if (itemCount === 0 || totalCount <= options.limit) {
1103
+ paginator.$el.hide();
1104
+ } else {
1105
+ paginator.$el.show();
1106
+ }
1107
+ return paginator.state.set({
1108
+ page: options.page,
1109
+ limit: options.limit
1110
+ });
1111
+ },
1112
+ paginationControl: function() {
1113
+ if (this.paginator != null) return this.paginator;
1114
+ _.defaults(this.paginatable || (this.paginatable = {}), {
1115
+ page: 1,
1116
+ limit: 20
1117
+ });
1118
+ this.paginator = Luca.util.lazyComponent({
1119
+ type: "pagination_control",
1120
+ collection: this.getCollection(),
1121
+ parent: this
1122
+ });
1123
+ this.paginator.setPage(this.paginatable.page);
1124
+ this.paginator.setLimit(this.paginatable.limit);
1125
+ this.paginator.state.on("change", function() {
1126
+ return this.trigger("collection:change");
1127
+ }, this);
1128
+ this.on("after:refresh", this.updatePagination, this);
1129
+ this.paginationContainer().append(this.paginator.render().$el);
1130
+ return this.paginator;
1131
+ }
1132
+ };
493
1133
 
494
1134
  }).call(this);
495
1135
  (function() {
@@ -509,6 +1149,21 @@
509
1149
 
510
1150
  Luca.defaultComponentType = 'view';
511
1151
 
1152
+ Luca.registry.aliases = {
1153
+ grid: "grid_view",
1154
+ form: "form_view",
1155
+ text: "text_field",
1156
+ button: "button_field",
1157
+ select: "select_field",
1158
+ card: "card_view",
1159
+ paged: "card_view",
1160
+ wizard: "card_view",
1161
+ collection: "collection_view",
1162
+ list: "collection_view",
1163
+ multi: "collection_multi_view",
1164
+ table: "table_view"
1165
+ };
1166
+
512
1167
  Luca.register = function(component, prototypeName, componentType) {
513
1168
  if (componentType == null) componentType = "view";
514
1169
  Luca.trigger("component:registered", component, prototypeName);
@@ -516,7 +1171,7 @@
516
1171
  case "model":
517
1172
  return registry.model_classes[component] = prototypeName;
518
1173
  case "collection":
519
- return registry.model_classes[component] = prototypeName;
1174
+ return registry.collection_classes[component] = prototypeName;
520
1175
  default:
521
1176
  return registry.classes[component] = prototypeName;
522
1177
  }
@@ -536,7 +1191,7 @@
536
1191
  return Luca.register(component, prototypeName);
537
1192
  };
538
1193
 
539
- Luca.registry.addNamespace = function(identifier) {
1194
+ Luca.registry.addNamespace = Luca.registry.namespace = function(identifier) {
540
1195
  registry.namespaces.push(identifier);
541
1196
  return registry.namespaces = _(registry.namespaces).uniq();
542
1197
  };
@@ -553,7 +1208,8 @@
553
1208
  };
554
1209
 
555
1210
  Luca.registry.lookup = function(ctype) {
556
- var c, className, fullPath, parents, _ref;
1211
+ var alias, c, className, fullPath, parents, _ref;
1212
+ if (alias = Luca.registry.aliases[ctype]) ctype = alias;
557
1213
  c = registry.classes[ctype];
558
1214
  if (c != null) return c;
559
1215
  className = Luca.util.classify(ctype);
@@ -563,9 +1219,13 @@
563
1219
  }).compact().value()) != null ? _ref[0] : void 0;
564
1220
  };
565
1221
 
1222
+ Luca.registry.instances = function() {
1223
+ return _(component_cache.cid_index).values();
1224
+ };
1225
+
566
1226
  Luca.registry.findInstancesByClassName = function(className) {
567
1227
  var instances;
568
- instances = _(component_cache.cid_index).values();
1228
+ instances = Luca.registry.instances();
569
1229
  return _(instances).select(function(instance) {
570
1230
  var _ref;
571
1231
  return instance.displayName === className || (typeof instance._superClass === "function" ? (_ref = instance._superClass()) != null ? _ref.displayName : void 0 : void 0) === className;
@@ -591,10 +1251,8 @@
591
1251
  if (component != null) component_cache.cid_index[needle] = component;
592
1252
  component = component_cache.cid_index[needle];
593
1253
  if ((component != null ? component.component_name : void 0) != null) {
594
- Luca.trigger("component:created:" + component.component_name, component);
595
1254
  component_cache.name_index[component.component_name] = component.cid;
596
1255
  } else if ((component != null ? component.name : void 0) != null) {
597
- Luca.trigger("component:created:" + component.component_name, component);
598
1256
  component_cache.name_index[component.name] = component.cid;
599
1257
  }
600
1258
  if (component != null) return component;
@@ -604,60 +1262,84 @@
604
1262
 
605
1263
  }).call(this);
606
1264
  (function() {
607
- var customizeRender, originalExtend;
1265
+ var __slice = Array.prototype.slice;
1266
+
1267
+ Luca.Observer = (function() {
1268
+
1269
+ function Observer(options) {
1270
+ var _this = this;
1271
+ this.options = options != null ? options : {};
1272
+ _.extend(this, Backbone.Events);
1273
+ this.type = this.options.type;
1274
+ if (this.options.debugAll) {
1275
+ this.bind("all", function(trigger, one, two) {
1276
+ return console.log("ALL", trigger, one, two);
1277
+ });
1278
+ }
1279
+ }
1280
+
1281
+ Observer.prototype.relay = function() {
1282
+ var args, triggerer;
1283
+ triggerer = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
1284
+ console.log("Relaying", trigger, args);
1285
+ this.trigger("event", triggerer, args);
1286
+ return this.trigger("event:" + args[0], triggerer, args.slice(1));
1287
+ };
1288
+
1289
+ return Observer;
1290
+
1291
+ })();
1292
+
1293
+ Luca.Observer.enableObservers = function(options) {
1294
+ if (options == null) options = {};
1295
+ Luca.enableGlobalObserver = true;
1296
+ Luca.ViewObserver = new Luca.Observer(_.extend(options, {
1297
+ type: "view"
1298
+ }));
1299
+ return Luca.CollectionObserver = new Luca.Observer(_.extend(options, {
1300
+ type: "collection"
1301
+ }));
1302
+ };
1303
+
1304
+ }).call(this);
1305
+ (function() {
1306
+ var bindAllEventHandlers, registerApplicationEvents, registerCollectionEvents, setupBodyTemplate, setupClassHelpers, setupStateMachine, setupTemplate;
608
1307
 
609
1308
  _.def("Luca.View")["extends"]("Backbone.View")["with"]({
610
1309
  include: ['Luca.Events'],
611
1310
  additionalClassNames: [],
612
- hooks: ["after:initialize", "before:render", "after:render", "first:activation", "activation", "deactivation"],
613
- debug: function() {
614
- var message, _i, _len, _results;
615
- if (!(this.debugMode || (window.LucaDebugMode != null))) return;
616
- _results = [];
617
- for (_i = 0, _len = arguments.length; _i < _len; _i++) {
618
- message = arguments[_i];
619
- _results.push(console.log([this.name || this.cid, message]));
620
- }
621
- return _results;
622
- },
623
- trigger: function() {
624
- if (Luca.enableGlobalObserver) {
625
- if (Luca.developmentMode === true || this.observeEvents === true) {
626
- Luca.ViewObserver || (Luca.ViewObserver = new Luca.Observer({
627
- type: "view"
628
- }));
629
- Luca.ViewObserver.relay(this, arguments);
630
- }
631
- }
632
- return Backbone.View.prototype.trigger.apply(this, arguments);
633
- },
1311
+ hooks: ["before:initialize", "after:initialize", "before:render", "after:render", "first:activation", "activation", "deactivation"],
634
1312
  initialize: function(options) {
635
- var additional, template, unique, _i, _len, _ref;
1313
+ var module, _i, _len, _ref, _ref2, _ref3;
636
1314
  this.options = options != null ? options : {};
1315
+ this.trigger("before:initialize", this, this.options);
637
1316
  _.extend(this, this.options);
638
- if (this.name != null) this.cid = _.uniqueId(this.name);
639
- if (template = this.bodyTemplate) {
640
- this.$el.empty();
641
- Luca.View.prototype.$html.call(this, Luca.template(template, this));
1317
+ if (this.autoBindEventHandlers === true || this.bindAllEvents === true) {
1318
+ bindAllEventHandlers.call(this);
642
1319
  }
1320
+ setupBodyTemplate.call(this);
1321
+ if (this.name != null) this.cid = _.uniqueId(this.name);
1322
+ this.$el.attr("data-luca-id", this.name || this.cid);
643
1323
  Luca.cache(this.cid, this);
644
- unique = _(Luca.View.prototype.hooks.concat(this.hooks)).uniq();
645
- this.setupHooks(unique);
646
- if (this.autoBindEventHandlers === true) this.bindAllEventHandlers();
647
- if (this.additionalClassNames) {
648
- if (_.isString(this.additionalClassNames)) {
649
- this.additionalClassNames = this.additionalClassNames.split(" ");
650
- }
651
- _ref = this.additionalClassNames;
652
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
653
- additional = _ref[_i];
654
- this.$el.addClass(additional);
1324
+ this.setupHooks(_(Luca.View.prototype.hooks.concat(this.hooks)).uniq());
1325
+ setupClassHelpers.call(this);
1326
+ if (this.stateful === true && !(this.state != null)) {
1327
+ setupStateMachine.call(this);
1328
+ }
1329
+ registerCollectionEvents.call(this);
1330
+ registerApplicationEvents.call(this);
1331
+ if (((_ref = this.mixins) != null ? _ref.length : void 0) > 0) {
1332
+ _ref2 = _.uniq(this.mixins);
1333
+ for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
1334
+ module = _ref2[_i];
1335
+ if ((_ref3 = Luca.mixin(module)) != null) {
1336
+ _ref3._initializer.call(this, this, module);
1337
+ }
655
1338
  }
656
1339
  }
657
- if (this.wrapperClass != null) this.$wrap(this.wrapperClass);
658
- this.trigger("after:initialize", this);
659
- this.registerCollectionEvents();
660
- return this.delegateEvents();
1340
+ this.delegateEvents();
1341
+ if (this.template && !this.isField) setupTemplate.call(this);
1342
+ return this.trigger("after:initialize", this);
661
1343
  },
662
1344
  $wrap: function(wrapper) {
663
1345
  if (_.isString(wrapper) && !wrapper.match(/[<>]/)) {
@@ -680,6 +1362,9 @@
680
1362
  $attach: function() {
681
1363
  return this.$container().append(this.el);
682
1364
  },
1365
+ $bodyEl: function() {
1366
+ return this.$el;
1367
+ },
683
1368
  $container: function() {
684
1369
  return $(this.container);
685
1370
  },
@@ -699,72 +1384,15 @@
699
1384
  return _this.bind(eventId, callback);
700
1385
  });
701
1386
  },
702
- getCollectionManager: function() {
703
- var _base;
704
- return this.collectionManager || (typeof (_base = Luca.CollectionManager).get === "function" ? _base.get() : void 0);
705
- },
706
- registerCollectionEvents: function() {
707
- var manager,
708
- _this = this;
709
- manager = this.getCollectionManager();
710
- return _(this.collectionEvents).each(function(handler, signature) {
711
- var collection, event, key, _ref;
712
- _ref = signature.split(" "), key = _ref[0], event = _ref[1];
713
- collection = _this["" + key + "Collection"] = manager.getOrCreate(key);
714
- if (!collection) throw "Could not find collection specified by " + key;
715
- if (_.isString(handler)) handler = _this[handler];
716
- if (!_.isFunction(handler)) throw "invalid collectionEvents configuration";
717
- try {
718
- return collection.bind(event, handler);
719
- } catch (e) {
720
- console.log("Error Binding To Collection in registerCollectionEvents", _this);
721
- throw e;
722
- }
723
- });
724
- },
725
1387
  registerEvent: function(selector, handler) {
726
1388
  this.events || (this.events = {});
727
1389
  this.events[selector] = handler;
728
1390
  return this.delegateEvents();
729
1391
  },
730
- bindAllEventHandlers: function() {
731
- var _this = this;
732
- return _(this.events).each(function(handler, event) {
733
- if (_.isString(handler)) return _.bindAll(_this, handler);
734
- });
735
- },
736
1392
  definitionClass: function() {
737
1393
  var _ref;
738
1394
  return (_ref = Luca.util.resolve(this.displayName, window)) != null ? _ref.prototype : void 0;
739
1395
  },
740
- refreshCode: function() {
741
- var view;
742
- view = this;
743
- _(this.eventHandlerProperties()).each(function(prop) {
744
- return view[prop] = view.definitionClass()[prop];
745
- });
746
- if (this.autoBindEventHandlers === true) this.bindAllEventHandlers();
747
- return this.delegateEvents();
748
- },
749
- eventHandlerProperties: function() {
750
- var handlerIds;
751
- handlerIds = _(this.events).values();
752
- return _(handlerIds).select(function(v) {
753
- return _.isString(v);
754
- });
755
- },
756
- eventHandlerFunctions: function() {
757
- var handlerIds,
758
- _this = this;
759
- handlerIds = _(this.events).values();
760
- return _(handlerIds).map(function(handlerId) {
761
- if (_.isFunction(handlerId)) {
762
- return handlerId;
763
- } else {
764
- return _this[handlerId];
765
- }
766
- });
767
- },
768
1396
  collections: function() {
769
1397
  return Luca.util.selectProperties(Luca.isBackboneCollection, this);
770
1398
  },
@@ -773,12 +1401,33 @@
773
1401
  },
774
1402
  views: function() {
775
1403
  return Luca.util.selectProperties(Luca.isBackboneView, this);
1404
+ },
1405
+ debug: function() {
1406
+ var message, _i, _len, _results;
1407
+ if (!(this.debugMode || (window.LucaDebugMode != null))) return;
1408
+ _results = [];
1409
+ for (_i = 0, _len = arguments.length; _i < _len; _i++) {
1410
+ message = arguments[_i];
1411
+ _results.push(console.log([this.name || this.cid, message]));
1412
+ }
1413
+ return _results;
1414
+ },
1415
+ trigger: function() {
1416
+ if (Luca.enableGlobalObserver) {
1417
+ if (Luca.developmentMode === true || this.observeEvents === true) {
1418
+ Luca.ViewObserver || (Luca.ViewObserver = new Luca.Observer({
1419
+ type: "view"
1420
+ }));
1421
+ Luca.ViewObserver.relay(this, arguments);
1422
+ }
1423
+ }
1424
+ return Backbone.View.prototype.trigger.apply(this, arguments);
776
1425
  }
777
1426
  });
778
1427
 
779
- originalExtend = Backbone.View.extend;
1428
+ Luca.View._originalExtend = Backbone.View.extend;
780
1429
 
781
- customizeRender = function(definition) {
1430
+ Luca.View.renderWrapper = function(definition) {
782
1431
  var _base;
783
1432
  _base = definition.render;
784
1433
  _base || (_base = Luca.View.prototype.$attach);
@@ -792,7 +1441,7 @@
792
1441
  this.deferrable = this.collection;
793
1442
  }
794
1443
  target || (target = this.deferrable);
795
- trigger = this.deferrable_event ? this.deferrable_event : "reset";
1444
+ trigger = this.deferrable_event ? this.deferrable_event : Luca.View.deferrableEvent;
796
1445
  deferred = function() {
797
1446
  _base.call(view);
798
1447
  return view.trigger("after:render", view);
@@ -816,15 +1465,130 @@
816
1465
  this.trigger("after:render", this);
817
1466
  return this;
818
1467
  }
819
- };
820
- return definition;
1468
+ };
1469
+ return definition;
1470
+ };
1471
+
1472
+ bindAllEventHandlers = function() {
1473
+ var _this = this;
1474
+ return _(this.events).each(function(handler, event) {
1475
+ if (_.isString(handler)) return _.bindAll(_this, handler);
1476
+ });
1477
+ };
1478
+
1479
+ registerApplicationEvents = function() {
1480
+ var app, eventTrigger, handler, _len, _ref, _ref2, _results;
1481
+ if (_.isEmpty(this.applicationEvents)) return;
1482
+ app = this.app;
1483
+ if (_.isString(app) || _.isUndefined(app)) {
1484
+ app = (_ref = Luca.Application) != null ? typeof _ref.get === "function" ? _ref.get(app) : void 0 : void 0;
1485
+ }
1486
+ if (!Luca.supportsEvents(app)) {
1487
+ throw "Error binding to the application object on " + (this.name || this.cid);
1488
+ }
1489
+ _ref2 = this.applicationEvents;
1490
+ _results = [];
1491
+ for (handler = 0, _len = _ref2.length; handler < _len; handler++) {
1492
+ eventTrigger = _ref2[handler];
1493
+ if (_.isString(handler)) handler = this[handler];
1494
+ if (!_.isFunction(handler)) {
1495
+ throw "Error registering application event " + eventTrigger + " on " + (this.name || this.cid);
1496
+ }
1497
+ _results.push(app.on(eventTrigger, handler));
1498
+ }
1499
+ return _results;
1500
+ };
1501
+
1502
+ registerCollectionEvents = function() {
1503
+ var collection, eventTrigger, handler, key, manager, signature, _ref, _ref2, _results;
1504
+ if (_.isEmpty(this.collectionEvents)) return;
1505
+ manager = this.collectionManager;
1506
+ if (_.isString(manager) || _.isUndefined(manager)) {
1507
+ manager = Luca.CollectionManager.get(manager);
1508
+ }
1509
+ _ref = this.collectionEvents;
1510
+ _results = [];
1511
+ for (signature in _ref) {
1512
+ handler = _ref[signature];
1513
+ _ref2 = signature.split(" "), key = _ref2[0], eventTrigger = _ref2[1];
1514
+ collection = manager.getOrCreate(key);
1515
+ if (!collection) throw "Could not find collection specified by " + key;
1516
+ if (_.isString(handler)) handler = this[handler];
1517
+ if (!_.isFunction(handler)) throw "invalid collectionEvents configuration";
1518
+ try {
1519
+ _results.push(collection.bind(eventTrigger, handler));
1520
+ } catch (e) {
1521
+ console.log("Error Binding To Collection in registerCollectionEvents", this);
1522
+ throw e;
1523
+ }
1524
+ }
1525
+ return _results;
1526
+ };
1527
+
1528
+ setupClassHelpers = function() {
1529
+ var additional, additionalClasses, _i, _len, _results;
1530
+ additionalClasses = _(this.additionalClassNames || []).clone();
1531
+ if (this.wrapperClass != null) this.$wrap(this.wrapperClass);
1532
+ if (_.isString(additionalClasses)) {
1533
+ additionalClasses = additionalClasses.split(" ");
1534
+ }
1535
+ if (this.gridSpan) additionalClasses.push("span" + this.gridSpan);
1536
+ if (this.gridOffset) additionalClasses.push("offset" + this.gridOffset);
1537
+ if (this.gridRowFluid) additionalClasses.push("row-fluid");
1538
+ if (this.gridRow) additionalClasses.push("row");
1539
+ if (additionalClasses == null) return;
1540
+ _results = [];
1541
+ for (_i = 0, _len = additionalClasses.length; _i < _len; _i++) {
1542
+ additional = additionalClasses[_i];
1543
+ _results.push(this.$el.addClass(additional));
1544
+ }
1545
+ return _results;
1546
+ };
1547
+
1548
+ setupStateMachine = function() {
1549
+ var _this = this;
1550
+ this.state = new Backbone.Model(this.defaultState || {});
1551
+ this.set || (this.set = function() {
1552
+ return _this.state.set.apply(_this.state, arguments);
1553
+ });
1554
+ return this.get || (this.get = function() {
1555
+ return _this.state.get.apply(_this.state, arguments);
1556
+ });
1557
+ };
1558
+
1559
+ setupBodyTemplate = function() {
1560
+ var template, templateVars;
1561
+ templateVars = this.bodyTemplateVars ? this.bodyTemplateVars.call(this) : this;
1562
+ if (template = this.bodyTemplate) {
1563
+ this.$el.empty();
1564
+ return Luca.View.prototype.$html.call(this, Luca.template(template, templateVars));
1565
+ }
1566
+ };
1567
+
1568
+ setupTemplate = function() {
1569
+ var _this = this;
1570
+ if (this.template != null) {
1571
+ return this.defer(function() {
1572
+ return _this.$template(_this.template, _this);
1573
+ }).until("before:render");
1574
+ }
821
1575
  };
822
1576
 
823
1577
  Luca.View.extend = function(definition) {
824
- definition = customizeRender(definition);
825
- return originalExtend.call(this, definition);
1578
+ var module, _i, _len, _ref;
1579
+ definition = Luca.View.renderWrapper(definition);
1580
+ if ((definition.mixins != null) && _.isArray(definition.mixins)) {
1581
+ _ref = definition.mixins;
1582
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
1583
+ module = _ref[_i];
1584
+ Luca.decorate(definition)["with"](module);
1585
+ }
1586
+ }
1587
+ return Luca.View._originalExtend.call(this, definition);
826
1588
  };
827
1589
 
1590
+ Luca.View.deferrableEvent = "reset";
1591
+
828
1592
  }).call(this);
829
1593
  (function() {
830
1594
  var setupComputedProperties;
@@ -841,6 +1605,7 @@
841
1605
  this.on("change:" + attr, function() {
842
1606
  return _this._computed[attr] = _this[attr].call(_this);
843
1607
  });
1608
+ if (_.isString(dependencies)) dependencies = dependencies.split(',');
844
1609
  _results.push(_(dependencies).each(function(dep) {
845
1610
  _this.on("change:" + dep, function() {
846
1611
  return _this.trigger("change:" + attr);
@@ -1213,389 +1978,107 @@
1213
1978
  if (hasBody) {
1214
1979
  return "before";
1215
1980
  } else {
1216
- return "prepend";
1217
- }
1218
- break;
1219
- case "bottom":
1220
- case "right":
1221
- if (hasBody) {
1222
- return "after";
1223
- } else {
1224
- return "append";
1225
- }
1226
- }
1227
- })();
1228
- return (targetEl || this.$bodyEl())[action](container);
1229
- };
1230
-
1231
- _.def("Luca.components.Panel")["extends"]("Luca.View")["with"]({
1232
- topToolbar: void 0,
1233
- bottomToolbar: void 0,
1234
- loadMask: false,
1235
- loadMaskTemplate: ["components/load_mask"],
1236
- loadMaskTimeout: 3000,
1237
- initialize: function(options) {
1238
- var _this = this;
1239
- this.options = options != null ? options : {};
1240
- Luca.View.prototype.initialize.apply(this, arguments);
1241
- _.bindAll(this, "applyLoadMask", "disableLoadMask");
1242
- if (this.loadMask === true) {
1243
- this.defer(function() {
1244
- _this.$el.addClass('with-mask');
1245
- if (_this.$('.load-mask').length === 0) {
1246
- _this.loadMaskTarget().prepend(Luca.template(_this.loadMaskTemplate, _this));
1247
- return _this.$('.load-mask').hide();
1248
- }
1249
- }).until("after:render");
1250
- this.on("enable:loadmask", this.applyLoadMask);
1251
- return this.on("disable:loadmask", this.applyLoadMask);
1252
- }
1253
- },
1254
- loadMaskTarget: function() {
1255
- if (this.loadMaskEl != null) {
1256
- return this.$(this.loadMaskEl);
1257
- } else {
1258
- return this.$bodyEl();
1259
- }
1260
- },
1261
- disableLoadMask: function() {
1262
- this.$('.load-mask .bar').css("width", "100%");
1263
- this.$('.load-mask').hide();
1264
- return clearInterval(this.loadMaskInterval);
1265
- },
1266
- enableLoadMask: function() {
1267
- var maxWidth,
1268
- _this = this;
1269
- this.$('.load-mask').show().find('.bar').css("width", "0%");
1270
- maxWidth = this.$('.load-mask .progress').width();
1271
- if (maxWidth < 20 && (maxWidth = this.$el.width()) < 20) {
1272
- maxWidth = this.$el.parent().width();
1273
- }
1274
- this.loadMaskInterval = setInterval(function() {
1275
- var currentWidth, newWidth;
1276
- currentWidth = _this.$('.load-mask .bar').width();
1277
- newWidth = currentWidth + 12;
1278
- return _this.$('.load-mask .bar').css('width', newWidth);
1279
- }, 200);
1280
- if (this.loadMaskTimeout == null) return;
1281
- return _.delay(function() {
1282
- return _this.disableLoadMask();
1283
- }, this.loadMaskTimeout);
1284
- },
1285
- applyLoadMask: function() {
1286
- if (this.$('.load-mask').is(":visible")) {
1287
- return this.disableLoadMask();
1288
- } else {
1289
- return this.enableLoadMask();
1290
- }
1291
- },
1292
- applyStyles: function(styles, body) {
1293
- var setting, target, value;
1294
- if (styles == null) styles = {};
1295
- if (body == null) body = false;
1296
- target = body ? this.$bodyEl() : this.$el;
1297
- for (setting in styles) {
1298
- value = styles[setting];
1299
- target.css(setting, value);
1300
- }
1301
- return this;
1302
- },
1303
- beforeRender: function() {
1304
- var _ref;
1305
- if ((_ref = Luca.View.prototype.beforeRender) != null) {
1306
- _ref.apply(this, arguments);
1307
- }
1308
- if (this.styles != null) this.applyStyles(this.styles);
1309
- if (this.bodyStyles != null) this.applyStyles(this.bodyStyles, true);
1310
- return typeof this.renderToolbars === "function" ? this.renderToolbars() : void 0;
1311
- },
1312
- $bodyEl: function() {
1313
- var bodyEl, className, element, newElement;
1314
- element = this.bodyTagName || "div";
1315
- className = this.bodyClassName || "view-body";
1316
- this.bodyEl || (this.bodyEl = "" + element + "." + className);
1317
- bodyEl = this.$(this.bodyEl);
1318
- if (bodyEl.length > 0) return bodyEl;
1319
- if (bodyEl.length === 0 && ((this.bodyClassName != null) || (this.bodyTagName != null))) {
1320
- newElement = this.make(element, {
1321
- "class": className,
1322
- "data-auto-appended": true
1323
- });
1324
- $(this.el).append(newElement);
1325
- return this.$(this.bodyEl);
1326
- }
1327
- return $(this.el);
1328
- },
1329
- $wrap: function(wrapper) {
1330
- if (_.isString(wrapper) && !wrapper.match(/[<>]/)) {
1331
- wrapper = this.make("div", {
1332
- "class": wrapper
1333
- });
1334
- }
1335
- return this.$el.wrap(wrapper);
1336
- },
1337
- $template: function(template, variables) {
1338
- if (variables == null) variables = {};
1339
- return this.$html(Luca.template(template, variables));
1340
- },
1341
- $html: function(content) {
1342
- return this.$bodyEl().html(content);
1343
- },
1344
- $append: function(content) {
1345
- return this.$bodyEl().append(content);
1346
- },
1347
- renderToolbars: function() {
1348
- var _this = this;
1349
- return _(["top", "left", "right", "bottom"]).each(function(orientation) {
1350
- var config;
1351
- if (config = _this["" + orientation + "Toolbar"]) {
1352
- return _this.renderToolbar(orientation, config);
1353
- }
1354
- });
1355
- },
1356
- renderToolbar: function(orientation, config) {
1357
- if (orientation == null) orientation = "top";
1358
- if (config == null) config = {};
1359
- config.parent = this;
1360
- config.orientation = orientation;
1361
- return attachToolbar.call(this, config, config.targetEl);
1362
- }
1363
- });
1364
-
1365
- }).call(this);
1366
- (function() {
1367
-
1368
- Luca.modules.Deferrable = {
1369
- configure_collection: function(setAsDeferrable) {
1370
- var collectionManager, _ref, _ref2;
1371
- if (setAsDeferrable == null) setAsDeferrable = true;
1372
- if (!this.collection) return;
1373
- if (_.isString(this.collection) && (collectionManager = (_ref = Luca.CollectionManager) != null ? _ref.get() : void 0)) {
1374
- this.collection = collectionManager.getOrCreate(this.collection);
1375
- }
1376
- if (!(this.collection && _.isFunction(this.collection.fetch) && _.isFunction(this.collection.reset))) {
1377
- this.collection = new Luca.Collection(this.collection.initial_set, this.collection);
1378
- }
1379
- if ((_ref2 = this.collection) != null ? _ref2.deferrable_trigger : void 0) {
1380
- this.deferrable_trigger = this.collection.deferrable_trigger;
1381
- }
1382
- if (setAsDeferrable) return this.deferrable = this.collection;
1383
- }
1384
- };
1385
-
1386
- }).call(this);
1387
- (function() {
1388
-
1389
- Luca.LocalStore = (function() {
1390
-
1391
- function LocalStore(name) {
1392
- var store;
1393
- this.name = name;
1394
- store = localStorage.getItem(this.name);
1395
- this.data = (store && JSON.parse(store)) || {};
1396
- }
1397
-
1398
- LocalStore.prototype.guid = function() {
1399
- var S4;
1400
- S4 = function() {
1401
- return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
1402
- };
1403
- return S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4();
1404
- };
1405
-
1406
- LocalStore.prototype.save = function() {
1407
- return localStorage.setItem(this.name, JSON.stringify(this.data));
1408
- };
1409
-
1410
- LocalStore.prototype.create = function(model) {
1411
- if (!model.id) model.id = model.attribtues.id = this.guid();
1412
- this.data[model.id] = model;
1413
- this.save();
1414
- return model;
1415
- };
1416
-
1417
- LocalStore.prototype.update = function(model) {
1418
- this.data[model.id] = model;
1419
- this.save();
1420
- return model;
1421
- };
1422
-
1423
- LocalStore.prototype.find = function(model) {
1424
- return this.data[model.id];
1425
- };
1426
-
1427
- LocalStore.prototype.findAll = function() {
1428
- return _.values(this.data);
1429
- };
1430
-
1431
- LocalStore.prototype.destroy = function(model) {
1432
- delete this.data[model.id];
1433
- this.save();
1434
- return model;
1435
- };
1436
-
1437
- return LocalStore;
1438
-
1439
- })();
1440
-
1441
- Backbone.LocalSync = function(method, model, options) {
1442
- var resp, store;
1443
- store = model.localStorage || model.collection.localStorage;
1444
- resp = (function() {
1445
- switch (method) {
1446
- case "read":
1447
- if (model.id) {
1448
- return store.find(model);
1449
- } else {
1450
- return store.findAll();
1981
+ return "prepend";
1982
+ }
1983
+ break;
1984
+ case "bottom":
1985
+ case "right":
1986
+ if (hasBody) {
1987
+ return "after";
1988
+ } else {
1989
+ return "append";
1451
1990
  }
1452
- case "create":
1453
- return store.create(model);
1454
- case "update":
1455
- return store.update(model);
1456
- case "delete":
1457
- return store.destroy(model);
1458
1991
  }
1459
1992
  })();
1460
- if (resp) {
1461
- return options.success(resp);
1462
- } else {
1463
- return options.error("Record not found");
1464
- }
1993
+ return (targetEl || this.$bodyEl())[action](container);
1465
1994
  };
1466
1995
 
1467
- }).call(this);
1468
- (function() {
1469
- Luca.templates || (Luca.templates = {});
1470
- Luca.templates["components/bootstrap_form_controls"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'form-actions\'>\n <a class=\'btn btn-primary submit-button\'>\n <i class=\'icon-ok icon-white\'></i>\n Save Changes\n </a>\n <a class=\'btn reset-button cancel-button\'>\n <i class=\'icon-remove\'></i>\n Cancel\n </a>\n</div>\n');}return __p.join('');};
1471
- }).call(this);
1472
- (function() {
1473
- Luca.templates || (Luca.templates = {});
1474
- Luca.templates["components/collection_loader_view"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'modal\' id=\'progress-model\' style=\'display: none;\'>\n <div class=\'progress progress-info progress-striped active\'>\n <div class=\'bar\' style=\'width: 0%;\'></div>\n </div>\n <div class=\'message\'>\n Initializing...\n </div>\n</div>\n');}return __p.join('');};
1475
- }).call(this);
1476
- (function() {
1477
- Luca.templates || (Luca.templates = {});
1478
- Luca.templates["components/form_alert"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'', className ,'\'>\n <a class=\'close\' data-dismiss=\'alert\' href=\'#\'>x</a>\n ', message ,'\n</div>\n');}return __p.join('');};
1479
- }).call(this);
1480
- (function() {
1481
- Luca.templates || (Luca.templates = {});
1482
- Luca.templates["components/grid_view"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'luca-ui-g-view-wrapper\'>\n <div class=\'g-view-header\'></div>\n <div class=\'luca-ui-g-view-body\'>\n <table cellpadding=\'0\' cellspacing=\'0\' class=\'luca-ui-g-view scrollable-table\' width=\'100%\'>\n <thead class=\'fixed\'></thead>\n <tbody class=\'scrollable\'></tbody>\n </table>\n </div>\n <div class=\'luca-ui-g-view-footer\'></div>\n</div>\n');}return __p.join('');};
1483
- }).call(this);
1484
- (function() {
1485
- Luca.templates || (Luca.templates = {});
1486
- Luca.templates["components/grid_view_empty_text"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'empty-text-wrapper\'>\n <p>\n ', text ,'\n </p>\n</div>\n');}return __p.join('');};
1487
- }).call(this);
1488
- (function() {
1489
- Luca.templates || (Luca.templates = {});
1490
- Luca.templates["components/load_mask"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'load-mask\'>\n <div class=\'progress progress-striped active\'>\n <div class=\'bar\' style=\'width:1%\'></div>\n </div>\n</div>\n');}return __p.join('');};
1491
- }).call(this);
1492
- (function() {
1493
- Luca.templates || (Luca.templates = {});
1494
- Luca.templates["components/nav_bar"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'navbar-inner\'>\n <div class=\'luca-ui-navbar-body container\'></div>\n</div>\n');}return __p.join('');};
1495
- }).call(this);
1496
- (function() {
1497
- Luca.templates || (Luca.templates = {});
1498
- Luca.templates["containers/basic"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'', classes ,'\' id=\'', id ,'\' style=\'', style ,'\'></div>\n');}return __p.join('');};
1499
- }).call(this);
1500
- (function() {
1501
- Luca.templates || (Luca.templates = {});
1502
- Luca.templates["containers/tab_selector_container"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'tab-selector-container\' id=\'', cid ,'-tab-selector\'>\n <ul class=\'nav nav-tabs\' id=\'', cid ,'-tabs-nav\'>\n '); for(var i = 0; i < components.length; i++ ) { __p.push('\n '); var component = components[i];__p.push('\n <li class=\'tab-selector\' data-target=\'', i ,'\'>\n <a data-target=\'', i ,'\'>\n ', component.title ,'\n </a>\n </li>\n '); } __p.push('\n </ul>\n</div>\n');}return __p.join('');};
1503
- }).call(this);
1504
- (function() {
1505
- Luca.templates || (Luca.templates = {});
1506
- Luca.templates["containers/tab_view"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<ul class=\'nav ', navClass ,'\' id=\'', cid ,'-tabs-selector\'></ul>\n<div class=\'tab-content\' id=\'', cid ,'-tab-view-content\'></div>\n');}return __p.join('');};
1507
- }).call(this);
1508
- (function() {
1509
- Luca.templates || (Luca.templates = {});
1510
- Luca.templates["containers/toolbar_wrapper"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'luca-ui-toolbar-wrapper\' id=\'', id ,'\'></div>\n');}return __p.join('');};
1511
- }).call(this);
1512
- (function() {
1513
- Luca.templates || (Luca.templates = {});
1514
- Luca.templates["fields/button_field"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<label>&nbsp</label>\n<input class=\'btn ', input_class ,'\' id=\'', input_id ,'\' style=\'', inputStyles ,'\' type=\'', input_type ,'\' value=\'', input_value ,'\' />\n');}return __p.join('');};
1515
- }).call(this);
1516
- (function() {
1517
- Luca.templates || (Luca.templates = {});
1518
- Luca.templates["fields/button_field_link"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<a class=\'btn ', input_class ,'\'>\n '); if(icon_class.length) { __p.push('\n <i class=\'', icon_class ,'\'></i>\n '); } __p.push('\n ', input_value ,'\n</a>\n');}return __p.join('');};
1519
- }).call(this);
1520
- (function() {
1521
- Luca.templates || (Luca.templates = {});
1522
- Luca.templates["fields/checkbox_array"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'control-group\'>\n <label for=\'', input_id ,'\'>\n ', label ,'\n </label>\n <div class=\'controls\'></div>\n</div>\n');}return __p.join('');};
1523
- }).call(this);
1524
- (function() {
1525
- Luca.templates || (Luca.templates = {});
1526
- Luca.templates["fields/checkbox_array_item"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<label for=\'', input_id ,'\'>\n <input id=\'', input_id ,'\' name=\'', input_name ,'\' type=\'checkbox\' value=\'', value ,'\' />\n ', label ,'\n</label>\n');}return __p.join('');};
1527
- }).call(this);
1528
- (function() {
1529
- Luca.templates || (Luca.templates = {});
1530
- Luca.templates["fields/checkbox_field"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<label for=\'', input_id ,'\'>\n ', label ,'\n <input name=\'', input_name ,'\' style=\'', inputStyles ,'\' type=\'checkbox\' value=\'', input_value ,'\' />\n</label>\n'); if(helperText) { __p.push('\n<p class=\'helper-text help-block\'>\n ', helperText ,'\n</p>\n'); } __p.push('\n');}return __p.join('');};
1531
- }).call(this);
1532
- (function() {
1533
- Luca.templates || (Luca.templates = {});
1534
- Luca.templates["fields/file_upload_field"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<label for=\'', input_id ,'\'>\n ', label ,'\n</label>\n<input id=\'', input_id ,'\' name=\'', input_name ,'\' style=\'', inputStyles ,'\' type=\'file\' />\n'); if(helperText) { __p.push('\n<p class=\'helper-text help-block\'>\n ', helperText ,'\n</p>\n'); } __p.push('\n');}return __p.join('');};
1535
- }).call(this);
1536
- (function() {
1537
- Luca.templates || (Luca.templates = {});
1538
- Luca.templates["fields/hidden_field"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<input id=\'', input_id ,'\' name=\'', input_name ,'\' type=\'hidden\' value=\'', input_value ,'\' />\n');}return __p.join('');};
1539
- }).call(this);
1540
- (function() {
1541
- Luca.templates || (Luca.templates = {});
1542
- Luca.templates["fields/select_field"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<label for=\'', input_id ,'\'>\n ', label ,'\n</label>\n<select id=\'', input_id ,'\' name=\'', input_name ,'\' style=\'', inputStyles ,'\'></select>\n'); if(helperText) { __p.push('\n<p class=\'helper-text help-block\'>\n ', helperText ,'\n</p>\n'); } __p.push('\n');}return __p.join('');};
1543
- }).call(this);
1544
- (function() {
1545
- Luca.templates || (Luca.templates = {});
1546
- Luca.templates["fields/text_area_field"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<label for=\'', input_id ,'\'>\n ', label ,'\n</label>\n<textarea class=\'', input_class ,'\' id=\'', input_id ,'\' name=\'', input_name ,'\' style=\'', inputStyles ,'\'></textarea>\n'); if(helperText) { __p.push('\n<p class=\'helper-text help-block\'>\n ', helperText ,'\n</p>\n'); } __p.push('\n');}return __p.join('');};
1547
- }).call(this);
1548
- (function() {
1549
- Luca.templates || (Luca.templates = {});
1550
- Luca.templates["fields/text_field"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push(''); if(typeof(label)!=="undefined" && (typeof(hideLabel) !== "undefined" && !hideLabel) || (typeof(hideLabel)==="undefined")) {__p.push('\n<label class=\'control-label\' for=\'', input_id ,'\'>\n ', label ,'\n</label>\n'); } __p.push('\n'); if( typeof(addOn) !== "undefined" ) { __p.push('\n<span class=\'add-on\'>\n ', addOn ,'\n</span>\n'); } __p.push('\n<input class=\'', input_class ,'\' id=\'', input_id ,'\' name=\'', input_name ,'\' placeholder=\'', placeHolder ,'\' style=\'', inputStyles ,'\' type=\'text\' />\n'); if(helperText) { __p.push('\n<p class=\'helper-text help-block\'>\n ', helperText ,'\n</p>\n'); } __p.push('\n');}return __p.join('');};
1551
- }).call(this);
1552
- (function() {
1553
- Luca.templates || (Luca.templates = {});
1554
- Luca.templates["sample/contents"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<p>Sample Contents</p>\n');}return __p.join('');};
1555
- }).call(this);
1556
- (function() {
1557
- Luca.templates || (Luca.templates = {});
1558
- Luca.templates["sample/welcome"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('welcome.luca\n');}return __p.join('');};
1559
- }).call(this);
1560
- (function() {
1561
- var __slice = Array.prototype.slice;
1562
-
1563
- Luca.Observer = (function() {
1564
-
1565
- function Observer(options) {
1566
- var _this = this;
1996
+ _.def("Luca.components.Panel")["extends"]("Luca.View")["with"]({
1997
+ topToolbar: void 0,
1998
+ bottomToolbar: void 0,
1999
+ loadMask: false,
2000
+ loadMaskTemplate: ["components/load_mask"],
2001
+ loadMaskTimeout: 3000,
2002
+ mixins: ["LoadMaskable"],
2003
+ initialize: function(options) {
1567
2004
  this.options = options != null ? options : {};
1568
- _.extend(this, Backbone.Events);
1569
- this.type = this.options.type;
1570
- if (this.options.debugAll) {
1571
- this.bind("all", function(trigger, one, two) {
1572
- return console.log("ALL", trigger, one, two);
2005
+ return Luca.View.prototype.initialize.apply(this, arguments);
2006
+ },
2007
+ applyStyles: function(styles, body) {
2008
+ var setting, target, value;
2009
+ if (styles == null) styles = {};
2010
+ if (body == null) body = false;
2011
+ target = body ? this.$bodyEl() : this.$el;
2012
+ for (setting in styles) {
2013
+ value = styles[setting];
2014
+ target.css(setting, value);
2015
+ }
2016
+ return this;
2017
+ },
2018
+ beforeRender: function() {
2019
+ var _ref;
2020
+ if ((_ref = Luca.View.prototype.beforeRender) != null) {
2021
+ _ref.apply(this, arguments);
2022
+ }
2023
+ if (this.styles != null) this.applyStyles(this.styles);
2024
+ if (this.bodyStyles != null) this.applyStyles(this.bodyStyles, true);
2025
+ return typeof this.renderToolbars === "function" ? this.renderToolbars() : void 0;
2026
+ },
2027
+ $bodyEl: function() {
2028
+ var bodyEl, className, element, newElement;
2029
+ element = this.bodyTagName || "div";
2030
+ className = this.bodyClassName || "view-body";
2031
+ this.bodyEl || (this.bodyEl = "" + element + "." + className);
2032
+ bodyEl = this.$(this.bodyEl);
2033
+ if (bodyEl.length > 0) return bodyEl;
2034
+ if (bodyEl.length === 0 && ((this.bodyClassName != null) || (this.bodyTagName != null))) {
2035
+ newElement = this.make(element, {
2036
+ "class": className,
2037
+ "data-auto-appended": true
2038
+ });
2039
+ $(this.el).append(newElement);
2040
+ return this.$(this.bodyEl);
2041
+ }
2042
+ return $(this.el);
2043
+ },
2044
+ $wrap: function(wrapper) {
2045
+ if (_.isString(wrapper) && !wrapper.match(/[<>]/)) {
2046
+ wrapper = this.make("div", {
2047
+ "class": wrapper
1573
2048
  });
1574
2049
  }
2050
+ return this.$el.wrap(wrapper);
2051
+ },
2052
+ $template: function(template, variables) {
2053
+ if (variables == null) variables = {};
2054
+ return this.$html(Luca.template(template, variables));
2055
+ },
2056
+ $empty: function() {
2057
+ return this.$bodyEl().empty();
2058
+ },
2059
+ $html: function(content) {
2060
+ return this.$bodyEl().html(content);
2061
+ },
2062
+ $append: function(content) {
2063
+ return this.$bodyEl().append(content);
2064
+ },
2065
+ renderToolbars: function() {
2066
+ var _this = this;
2067
+ return _(["top", "left", "right", "bottom"]).each(function(orientation) {
2068
+ var config;
2069
+ if (config = _this["" + orientation + "Toolbar"]) {
2070
+ return _this.renderToolbar(orientation, config);
2071
+ }
2072
+ });
2073
+ },
2074
+ renderToolbar: function(orientation, config) {
2075
+ if (orientation == null) orientation = "top";
2076
+ if (config == null) config = {};
2077
+ config.parent = this;
2078
+ config.orientation = orientation;
2079
+ return attachToolbar.call(this, config, config.targetEl);
1575
2080
  }
1576
-
1577
- Observer.prototype.relay = function() {
1578
- var args, triggerer;
1579
- triggerer = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
1580
- console.log("Relaying", trigger, args);
1581
- this.trigger("event", triggerer, args);
1582
- return this.trigger("event:" + args[0], triggerer, args.slice(1));
1583
- };
1584
-
1585
- return Observer;
1586
-
1587
- })();
1588
-
1589
- Luca.Observer.enableObservers = function(options) {
1590
- if (options == null) options = {};
1591
- Luca.enableGlobalObserver = true;
1592
- Luca.ViewObserver = new Luca.Observer(_.extend(options, {
1593
- type: "view"
1594
- }));
1595
- return Luca.CollectionObserver = new Luca.Observer(_.extend(options, {
1596
- type: "collection"
1597
- }));
1598
- };
2081
+ });
1599
2082
 
1600
2083
  }).call(this);
1601
2084
  (function() {
@@ -1619,6 +2102,7 @@
1619
2102
  this.label || (this.label = "*" + this.label);
1620
2103
  }
1621
2104
  this.inputStyles || (this.inputStyles = "");
2105
+ this.input_value || (this.input_value = this.value || "");
1622
2106
  if (this.disabled) this.disable();
1623
2107
  this.updateState(this.state);
1624
2108
  this.placeHolder || (this.placeHolder = "");
@@ -1627,7 +2111,7 @@
1627
2111
  beforeRender: function() {
1628
2112
  if (Luca.enableBootstrap) this.$el.addClass('control-group');
1629
2113
  if (this.required) this.$el.addClass('required');
1630
- this.$el.html(Luca.templates[this.template](this));
2114
+ this.$template(this.template, this);
1631
2115
  return this.input = $('input', this.el);
1632
2116
  },
1633
2117
  change_handler: function(e) {
@@ -1640,7 +2124,19 @@
1640
2124
  return $("input", this.el).attr('disabled', false);
1641
2125
  },
1642
2126
  getValue: function() {
1643
- return this.input.attr('value');
2127
+ var raw;
2128
+ raw = this.input.attr('value');
2129
+ if (_.str.isBlank(raw)) return raw;
2130
+ switch (this.valueType) {
2131
+ case "integer":
2132
+ return parseInt(raw);
2133
+ case "string":
2134
+ return "" + raw;
2135
+ case "float":
2136
+ return parseFloat(raw);
2137
+ default:
2138
+ return raw;
2139
+ }
1644
2140
  },
1645
2141
  render: function() {
1646
2142
  return $(this.container).append(this.$el);
@@ -1681,7 +2177,7 @@
1681
2177
  "class": (panel != null ? panel.classes : void 0) || this.componentClass,
1682
2178
  id: "" + this.cid + "-" + panelIndex,
1683
2179
  style: style_declarations.join(';'),
1684
- "data-luca-owner": this.name || this.cid
2180
+ "data-luca-parent": this.name || this.cid
1685
2181
  };
1686
2182
  if (this.customizeContainerEl != null) {
1687
2183
  config = this.customizeContainerEl(config, panel, panelIndex);
@@ -1710,6 +2206,7 @@
1710
2206
  this.options = options != null ? options : {};
1711
2207
  _.extend(this, this.options);
1712
2208
  this.setupHooks(["before:components", "before:render:components", "before:layout", "after:components", "after:layout", "first:activation"]);
2209
+ this.components || (this.components = this.fields || (this.fields = this.pages || (this.pages = this.cards)));
1713
2210
  return Luca.View.prototype.initialize.apply(this, arguments);
1714
2211
  },
1715
2212
  beforeRender: function() {
@@ -1741,30 +2238,38 @@
1741
2238
  }
1742
2239
  }
1743
2240
  return _(this.components).each(function(component, index) {
1744
- var container, panel, _ref2;
1745
- container = (_ref2 = _this.componentContainers) != null ? _ref2[index] : void 0;
1746
- container["class"] = container["class"] || container.className || container.classes;
1747
- if (_this.appendContainers) {
1748
- panel = _this.make(_this.componentTag, container, '');
2241
+ var ce, componentContainerElement, panel, _ref2;
2242
+ ce = componentContainerElement = (_ref2 = _this.componentContainers) != null ? _ref2[index] : void 0;
2243
+ ce["class"] = ce["class"] || ce.className || ce.classes;
2244
+ if (_this.generateComponentElements) {
2245
+ panel = _this.make(_this.componentTag, componentContainerElement, '');
1749
2246
  _this.$append(panel);
1750
2247
  }
1751
2248
  if (component.container == null) {
1752
- if (_this.appendContainers) component.container = "#" + container.id;
2249
+ if (_this.generateComponentElements) {
2250
+ component.container = "#" + componentContainerElement.id;
2251
+ }
1753
2252
  return component.container || (component.container = _this.$bodyEl());
1754
2253
  }
1755
2254
  });
1756
2255
  },
1757
2256
  createComponents: function() {
1758
- var map,
2257
+ var container, map,
1759
2258
  _this = this;
1760
2259
  if (this.componentsCreated === true) return;
1761
2260
  map = this.componentIndex = {
1762
2261
  name_index: {},
1763
2262
  cid_index: {}
1764
2263
  };
2264
+ container = this;
1765
2265
  this.components = _(this.components).map(function(object, index) {
1766
- var component;
1767
- component = Luca.isBackboneView(object) ? object : (object.type || (object.type = object.ctype), !(object.type != null) ? object.components != null ? object.type = object.ctype = 'container' : object.type = object.ctype = Luca.defaultComponentType : void 0, Luca.util.lazyComponent(object));
2266
+ var component, created;
2267
+ component = Luca.isBackboneView(object) ? object : (object.type || (object.type = object.ctype), !(object.type != null) ? object.components != null ? object.type = object.ctype = 'container' : object.type = object.ctype = Luca.defaultComponentType : void 0, object = _.defaults(object, container.defaults || {}), created = Luca.util.lazyComponent(object));
2268
+ if (_.isString(component.getter)) {
2269
+ container[component.getter] = (function() {
2270
+ return component;
2271
+ });
2272
+ }
1768
2273
  if (!component.container && component.options.container) {
1769
2274
  component.container = component.options.container;
1770
2275
  }
@@ -1779,15 +2284,16 @@
1779
2284
  return map;
1780
2285
  },
1781
2286
  renderComponents: function(debugMode) {
1782
- var _this = this;
2287
+ var container;
1783
2288
  this.debugMode = debugMode != null ? debugMode : "";
1784
2289
  this.debug("container render components");
2290
+ container = this;
1785
2291
  return _(this.components).each(function(component) {
1786
2292
  component.getParent = function() {
1787
- return _this;
2293
+ return container;
1788
2294
  };
1789
- $(component.container).append($(component.el));
1790
2295
  try {
2296
+ $(component.container).append(component.el);
1791
2297
  return component.render();
1792
2298
  } catch (e) {
1793
2299
  console.log("Error Rendering Component " + (component.name || component.cid), component);
@@ -1820,20 +2326,8 @@
1820
2326
  invoke: function(method) {
1821
2327
  return _(this.components).invoke(method);
1822
2328
  },
1823
- select: function(attribute, value, deep) {
1824
- var components;
1825
- if (deep == null) deep = false;
1826
- components = _(this.components).map(function(component) {
1827
- var matches, test;
1828
- matches = [];
1829
- test = component[attribute];
1830
- if (test === value) matches.push(component);
1831
- if (deep === true) {
1832
- matches.push(typeof component.select === "function" ? component.select(attribute, value, true) : void 0);
1833
- }
1834
- return _.compact(matches);
1835
- });
1836
- return _.flatten(components);
2329
+ map: function(fn) {
2330
+ return _(this.components).map(fn);
1837
2331
  },
1838
2332
  componentEvents: {},
1839
2333
  registerComponentEvents: function() {
@@ -1895,32 +2389,63 @@
1895
2389
  return this.components[this.activeItem];
1896
2390
  },
1897
2391
  componentElements: function() {
1898
- return $(">." + this.componentClass, this.el);
2392
+ return this.$("[data-luca-parent='" + (this.name || this.cid) + "']");
1899
2393
  },
1900
2394
  getComponent: function(needle) {
1901
2395
  return this.components[needle];
1902
2396
  },
1903
- rootComponent: function() {
2397
+ isRootComponent: function() {
1904
2398
  return !(this.getParent != null);
1905
2399
  },
1906
2400
  getRootComponent: function() {
1907
- if (this.rootComponent()) {
2401
+ if (this.isRootComponent()) {
1908
2402
  return this;
1909
2403
  } else {
1910
2404
  return this.getParent().getRootComponent();
1911
2405
  }
2406
+ },
2407
+ selectByAttribute: function(attribute, value, deep) {
2408
+ var components;
2409
+ if (deep == null) deep = false;
2410
+ components = _(this.components).map(function(component) {
2411
+ var matches, test;
2412
+ matches = [];
2413
+ test = component[attribute];
2414
+ if (test === value) matches.push(component);
2415
+ if (deep === true) {
2416
+ matches.push(typeof component.selectByAttribute === "function" ? component.selectByAttribute(attribute, value, true) : void 0);
2417
+ }
2418
+ return _.compact(matches);
2419
+ });
2420
+ return _.flatten(components);
2421
+ },
2422
+ select: function(attribute, value, deep) {
2423
+ if (deep == null) deep = false;
2424
+ console.log("Container.select will be replaced by selectByAttribute in 1.0");
2425
+ return Luca.core.Container.prototype.selectByAttribute.apply(this, arguments);
1912
2426
  }
1913
2427
  });
1914
2428
 
2429
+ Luca.core.Container.componentRenderer = function(container, component) {
2430
+ var attachMethod;
2431
+ attachMethod = $(component.container)[component.attachWith || "append"];
2432
+ return attachMethod(component.render().el);
2433
+ };
2434
+
1915
2435
  }).call(this);
1916
2436
  (function() {
2437
+ var guessCollectionClass, handleInitialCollections, loadInitialCollections;
1917
2438
 
1918
2439
  Luca.CollectionManager = (function() {
1919
2440
 
1920
2441
  CollectionManager.prototype.name = "primary";
1921
2442
 
2443
+ CollectionManager.prototype.collectionNamespace = Luca.Collection.namespace;
2444
+
1922
2445
  CollectionManager.prototype.__collections = {};
1923
2446
 
2447
+ CollectionManager.prototype.relayEvents = true;
2448
+
1924
2449
  function CollectionManager(options) {
1925
2450
  var existing, manager, _base, _base2;
1926
2451
  this.options = options != null ? options : {};
@@ -1938,21 +2463,7 @@
1938
2463
  return Luca.CollectionManager.instances[name];
1939
2464
  };
1940
2465
  this.state = new Luca.Model();
1941
- if (this.initialCollections) {
1942
- this.state.set({
1943
- loaded_collections_count: 0,
1944
- collections_count: this.initialCollections.length
1945
- });
1946
- this.state.bind("change:loaded_collections_count", this.collectionCountDidChange);
1947
- if (this.useProgressLoader) {
1948
- this.loaderView || (this.loaderView = new Luca.components.CollectionLoaderView({
1949
- manager: this,
1950
- name: "collection_loader_view"
1951
- }));
1952
- }
1953
- this.loadInitialCollections();
1954
- }
1955
- this;
2466
+ if (this.initialCollections) handleInitialCollections.call(this);
1956
2467
  }
1957
2468
 
1958
2469
  CollectionManager.prototype.add = function(key, collection) {
@@ -1965,19 +2476,23 @@
1965
2476
  };
1966
2477
 
1967
2478
  CollectionManager.prototype.create = function(key, collectionOptions, initialModels) {
1968
- var CollectionClass, collection;
2479
+ var CollectionClass, collection, collectionManager;
1969
2480
  if (collectionOptions == null) collectionOptions = {};
1970
2481
  if (initialModels == null) initialModels = [];
1971
2482
  CollectionClass = collectionOptions.base;
1972
- CollectionClass || (CollectionClass = this.guessCollectionClass(key));
2483
+ CollectionClass || (CollectionClass = guessCollectionClass.call(this, key));
1973
2484
  if (collectionOptions.private) collectionOptions.name = "";
1974
2485
  collection = new CollectionClass(initialModels, collectionOptions);
1975
2486
  this.add(key, collection);
2487
+ collectionManager = this;
2488
+ if (this.relayEvents === true) {
2489
+ this.bind("*", function() {
2490
+ return console.log("Relay Events on Collection Manager *", collection, arguments);
2491
+ });
2492
+ }
1976
2493
  return collection;
1977
2494
  };
1978
2495
 
1979
- CollectionManager.prototype.collectionNamespace = Luca.Collection.namespace;
1980
-
1981
2496
  CollectionManager.prototype.currentScope = function() {
1982
2497
  var current_scope, _base;
1983
2498
  if (current_scope = this.getScope()) {
@@ -1999,48 +2514,28 @@
1999
2514
  return;
2000
2515
  };
2001
2516
 
2517
+ CollectionManager.prototype.destroy = function(key) {
2518
+ var c;
2519
+ c = this.get(key);
2520
+ delete this.currentScope()[key];
2521
+ return c;
2522
+ };
2523
+
2002
2524
  CollectionManager.prototype.getOrCreate = function(key, collectionOptions, initialModels) {
2003
2525
  if (collectionOptions == null) collectionOptions = {};
2004
2526
  if (initialModels == null) initialModels = [];
2005
2527
  return this.get(key) || this.create(key, collectionOptions, initialModels, false);
2006
2528
  };
2007
2529
 
2008
- CollectionManager.prototype.guessCollectionClass = function(key) {
2009
- var classified, guess, guesses, _ref;
2010
- classified = Luca.util.classify(key);
2011
- guess = (this.collectionNamespace || (window || global))[classified];
2012
- guess || (guess = (this.collectionNamespace || (window || global))["" + classified + "Collection"]);
2013
- if (!(guess != null) && ((_ref = Luca.Collection.namespaces) != null ? _ref.length : void 0) > 0) {
2014
- guesses = _(Luca.Collection.namespaces.reverse()).map(function(namespace) {
2015
- return Luca.util.resolve("" + namespace + "." + classified) || Luca.util.resolve("" + namespace + "." + classified + "Collection");
2016
- });
2017
- guesses = _(guesses).compact();
2018
- if (guesses.length > 0) guess = guesses[0];
2530
+ CollectionManager.prototype.collectionCountDidChange = function() {
2531
+ if (this.allCollectionsLoaded()) {
2532
+ this.trigger("all_collections_loaded");
2533
+ return this.trigger("initial:load");
2019
2534
  }
2020
- return guess;
2021
- };
2022
-
2023
- CollectionManager.prototype.loadInitialCollections = function() {
2024
- var collectionDidLoad,
2025
- _this = this;
2026
- collectionDidLoad = function(collection) {
2027
- collection.unbind("reset");
2028
- return _this.trigger("collection_loaded", collection.name);
2029
- };
2030
- return _(this.initialCollections).each(function(name) {
2031
- var collection;
2032
- collection = _this.getOrCreate(name);
2033
- collection.bind("reset", function() {
2034
- return collectionDidLoad(collection);
2035
- });
2036
- return collection.fetch();
2037
- });
2038
2535
  };
2039
2536
 
2040
- CollectionManager.prototype.collectionCountDidChange = function() {
2041
- if (this.totalCollectionsCount() === this.loadedCollectionsCount()) {
2042
- return this.trigger("all_collections_loaded");
2043
- }
2537
+ CollectionManager.prototype.allCollectionsLoaded = function() {
2538
+ return this.totalCollectionsCount() === this.loadedCollectionsCount();
2044
2539
  };
2045
2540
 
2046
2541
  CollectionManager.prototype.totalCollectionsCount = function() {
@@ -2059,10 +2554,64 @@
2059
2554
 
2060
2555
  return CollectionManager;
2061
2556
 
2062
- })();
2557
+ })();
2558
+
2559
+ Luca.CollectionManager.destroyAll = function() {
2560
+ return Luca.CollectionManager.instances = {};
2561
+ };
2562
+
2563
+ guessCollectionClass = function(key) {
2564
+ var classified, guess, guesses, _ref;
2565
+ classified = Luca.util.classify(key);
2566
+ guess = (this.collectionNamespace || (window || global))[classified];
2567
+ guess || (guess = (this.collectionNamespace || (window || global))["" + classified + "Collection"]);
2568
+ if (!(guess != null) && ((_ref = Luca.Collection.namespaces) != null ? _ref.length : void 0) > 0) {
2569
+ guesses = _(Luca.Collection.namespaces.reverse()).map(function(namespace) {
2570
+ return Luca.util.resolve("" + namespace + "." + classified) || Luca.util.resolve("" + namespace + "." + classified + "Collection");
2571
+ });
2572
+ guesses = _(guesses).compact();
2573
+ if (guesses.length > 0) guess = guesses[0];
2574
+ }
2575
+ return guess;
2576
+ };
2577
+
2578
+ loadInitialCollections = function() {
2579
+ var collectionDidLoad,
2580
+ _this = this;
2581
+ collectionDidLoad = function(collection) {
2582
+ var current;
2583
+ current = _this.state.get("loaded_collections_count");
2584
+ _this.state.set("loaded_collections_count", current + 1);
2585
+ _this.trigger("collection_loaded", collection.name);
2586
+ return collection.unbind("reset");
2587
+ };
2588
+ return _(this.initialCollections).each(function(name) {
2589
+ var collection;
2590
+ collection = _this.getOrCreate(name);
2591
+ collection.once("reset", function() {
2592
+ return collectionDidLoad(collection);
2593
+ });
2594
+ return collection.fetch();
2595
+ });
2596
+ };
2063
2597
 
2064
- Luca.CollectionManager.destroyAll = function() {
2065
- return Luca.CollectionManager.instances = {};
2598
+ handleInitialCollections = function() {
2599
+ var _this = this;
2600
+ this.state.set({
2601
+ loaded_collections_count: 0,
2602
+ collections_count: this.initialCollections.length
2603
+ });
2604
+ this.state.bind("change:loaded_collections_count", function() {
2605
+ return _this.collectionCountDidChange();
2606
+ });
2607
+ if (this.useProgressLoader) {
2608
+ this.loaderView || (this.loaderView = new Luca.components.CollectionLoaderView({
2609
+ manager: this,
2610
+ name: "collection_loader_view"
2611
+ }));
2612
+ }
2613
+ loadInitialCollections.call(this);
2614
+ return this;
2066
2615
  };
2067
2616
 
2068
2617
  }).call(this);
@@ -2136,12 +2685,13 @@
2136
2685
  components: [],
2137
2686
  initialize: function(options) {
2138
2687
  this.options = options != null ? options : {};
2688
+ console.log("Column Views are deprecated in favor of just using grid css on a normal container");
2139
2689
  Luca.core.Container.prototype.initialize.apply(this, arguments);
2140
2690
  return this.setColumnWidths();
2141
2691
  },
2142
2692
  componentClass: 'luca-ui-column',
2143
2693
  containerTemplate: "containers/basic",
2144
- appendContainers: true,
2694
+ generateComponentElements: true,
2145
2695
  autoColumnWidths: function() {
2146
2696
  var widths,
2147
2697
  _this = this;
@@ -2173,33 +2723,32 @@
2173
2723
 
2174
2724
  }).call(this);
2175
2725
  (function() {
2726
+ var component;
2727
+
2728
+ component = Luca.define("Luca.containers.CardView");
2176
2729
 
2177
- _.def("Luca.containers.CardView")["extends"]("Luca.core.Container")["with"]({
2178
- componentType: 'card_view',
2730
+ component["extends"]("Luca.core.Container");
2731
+
2732
+ component.defaults({
2179
2733
  className: 'luca-ui-card-view-wrapper',
2180
2734
  activeCard: 0,
2181
2735
  components: [],
2182
2736
  hooks: ['before:card:switch', 'after:card:switch'],
2183
2737
  componentClass: 'luca-ui-card',
2184
- appendContainers: true,
2738
+ generateComponentElements: true,
2185
2739
  initialize: function(options) {
2186
2740
  this.options = options;
2187
2741
  Luca.core.Container.prototype.initialize.apply(this, arguments);
2188
- return this.setupHooks(this.hooks);
2742
+ this.setupHooks(this.hooks);
2743
+ return this.components || (this.components = this.pages || (this.pages = this.cards));
2189
2744
  },
2190
2745
  prepareComponents: function() {
2191
- var _ref,
2192
- _this = this;
2746
+ var _ref;
2193
2747
  if ((_ref = Luca.core.Container.prototype.prepareComponents) != null) {
2194
2748
  _ref.apply(this, arguments);
2195
2749
  }
2196
- return _(this.components).each(function(component, index) {
2197
- if (index === _this.activeCard) {
2198
- return $(component.container).show();
2199
- } else {
2200
- return $(component.container).hide();
2201
- }
2202
- });
2750
+ this.componentElements().hide();
2751
+ return this.activeComponentElement().show();
2203
2752
  },
2204
2753
  activeComponentElement: function() {
2205
2754
  return this.componentElements().eq(this.activeCard);
@@ -2211,13 +2760,27 @@
2211
2760
  containerEl.style += panelIndex === this.activeCard ? "display:block;" : "display:none;";
2212
2761
  return containerEl;
2213
2762
  },
2763
+ atFirst: function() {
2764
+ return this.activeCard === 0;
2765
+ },
2766
+ atLast: function() {
2767
+ return this.activeCard === this.components.length - 1;
2768
+ },
2769
+ next: function() {
2770
+ if (this.atLast()) return;
2771
+ return this.activate(this.activeCard + 1);
2772
+ },
2773
+ previous: function() {
2774
+ if (this.atFirst()) return;
2775
+ return this.activate(this.activeCard - 1);
2776
+ },
2214
2777
  cycle: function() {
2215
2778
  var nextIndex;
2216
- nextIndex = this.activeCard < this.components.length - 1 ? this.activeCard + 1 : 0;
2779
+ nextIndex = this.atLast() ? 0 : this.activeCard + 1;
2217
2780
  return this.activate(nextIndex);
2218
2781
  },
2219
2782
  find: function(name) {
2220
- return this.findComponentByName(name, true);
2783
+ return Luca(name);
2221
2784
  },
2222
2785
  firstActivation: function() {
2223
2786
  return this.activeComponent().trigger("first:activation", this, this.activeComponent());
@@ -2279,10 +2842,11 @@
2279
2842
  }).call(this);
2280
2843
  (function() {
2281
2844
 
2282
- _.def("Luca.ModalView")["extends"]("Luca.View")["with"]({
2845
+ _.def("Luca.ModalView")["extends"]("Luca.core.Container")["with"]({
2283
2846
  closeOnEscape: true,
2284
2847
  showOnInitialize: false,
2285
2848
  backdrop: false,
2849
+ className: "luca-ui-container modal",
2286
2850
  container: function() {
2287
2851
  return $('body');
2288
2852
  },
@@ -2299,16 +2863,24 @@
2299
2863
  this.$el.addClass('modal');
2300
2864
  if (this.fade === true) this.$el.addClass('fade');
2301
2865
  $('body').append(this.$el);
2302
- return this.$el.modal({
2866
+ this.$el.modal({
2303
2867
  backdrop: this.backdrop === true,
2304
2868
  keyboard: this.closeOnEscape === true,
2305
2869
  show: this.showOnInitialize === true
2306
2870
  });
2871
+ return this;
2307
2872
  }
2308
2873
  });
2309
2874
 
2310
2875
  _.def("Luca.containers.ModalView")["extends"]("Luca.ModalView")["with"]();
2311
2876
 
2877
+ }).call(this);
2878
+ (function() {
2879
+
2880
+ _.def("Luca.PageView")["extends"]("Luca.containers.CardView")["with"]({
2881
+ version: 2
2882
+ });
2883
+
2312
2884
  }).call(this);
2313
2885
  (function() {
2314
2886
  var buildButton, make, prepareButtons;
@@ -2501,11 +3073,12 @@
2501
3073
  return (_ref = Luca.containers.CardView.prototype.beforeLayout) != null ? _ref.apply(this, arguments) : void 0;
2502
3074
  },
2503
3075
  afterRender: function() {
2504
- var _ref;
3076
+ var tabContainerId, _ref;
2505
3077
  if ((_ref = Luca.containers.CardView.prototype.afterRender) != null) {
2506
3078
  _ref.apply(this, arguments);
2507
3079
  }
2508
- this.registerEvent("click #" + this.cid + "-tabs-selector li a", "select");
3080
+ tabContainerId = this.tabContainer().attr("id");
3081
+ this.registerEvent("click #" + tabContainerId + " li a", "select");
2509
3082
  if (Luca.enableBootstrap && (this.tab_position === "left" || this.tab_position === "right")) {
2510
3083
  this.tabContainerWrapper().addClass("span2");
2511
3084
  return this.tabContentWrapper().addClass("span9");
@@ -2516,7 +3089,9 @@
2516
3089
  tabView = this;
2517
3090
  return this.each(function(component, index) {
2518
3091
  var icon, link, selector, _ref;
2519
- if (component.tabIcon) icon = "<i class='icon-" + component.tabIcon;
3092
+ if (component.tabIcon) {
3093
+ icon = "<i class='icon-" + component.tabIcon + "'></i>";
3094
+ }
2520
3095
  link = "<a href='#'>" + (icon || '') + " " + component.title + "</a>";
2521
3096
  selector = tabView.make("li", {
2522
3097
  "class": "tab-selector",
@@ -2569,17 +3144,38 @@
2569
3144
  additionalClassNames: 'luca-ui-viewport',
2570
3145
  fullscreen: true,
2571
3146
  fluid: false,
2572
- wrapperClass: 'row',
2573
3147
  initialize: function(options) {
2574
3148
  this.options = options != null ? options : {};
2575
3149
  _.extend(this, this.options);
2576
3150
  if (Luca.enableBootstrap === true) {
2577
- if (this.fluid === true) {
2578
- this.wrapperClass = "row-fluid fluid-viewport-wrapper";
2579
- }
3151
+ this.wrapperClass = this.fluid === true ? Luca.containers.Viewport.fluidWrapperClass : Luca.containers.Viewport.defaultWrapperClass;
2580
3152
  }
2581
3153
  Luca.core.Container.prototype.initialize.apply(this, arguments);
2582
- if (this.fullscreen) return $('html,body').addClass('luca-ui-fullscreen');
3154
+ if (this.fullscreen === true) return this.enableFullscreen();
3155
+ },
3156
+ enableFluid: function() {
3157
+ return this.enableWrapper();
3158
+ },
3159
+ disableFluid: function() {
3160
+ return this.disableWrapper();
3161
+ },
3162
+ enableWrapper: function() {
3163
+ if (this.wrapperClass != null) {
3164
+ return this.$el.parent().addClass(this.wrapperClass);
3165
+ }
3166
+ },
3167
+ disableWrapper: function() {
3168
+ if (this.wrapperClass != null) {
3169
+ return this.$el.parent().removeClass(this.wrapperClass);
3170
+ }
3171
+ },
3172
+ enableFullscreen: function() {
3173
+ $('html,body').addClass('luca-ui-fullscreen');
3174
+ return this.$el.addClass('fullscreen-enabled');
3175
+ },
3176
+ disableFullscreen: function() {
3177
+ $('html,body').removeClass('luca-ui-fullscreen');
3178
+ return this.$el.removeClass('fullscreen-enabled');
2583
3179
  },
2584
3180
  beforeRender: function() {
2585
3181
  var _ref;
@@ -2589,6 +3185,12 @@
2589
3185
  if (this.topNav != null) this.renderTopNavigation();
2590
3186
  if (this.bottomNav != null) return this.renderBottomNavigation();
2591
3187
  },
3188
+ height: function() {
3189
+ return this.$el.height();
3190
+ },
3191
+ width: function() {
3192
+ return this.$el.width();
3193
+ },
2592
3194
  afterRender: function() {
2593
3195
  var _ref;
2594
3196
  if ((_ref = Luca.containers.CardView.prototype.after) != null) {
@@ -2616,15 +3218,9 @@
2616
3218
  renderBottomNavigation: function() {}
2617
3219
  });
2618
3220
 
2619
- }).call(this);
2620
- (function() {
2621
-
2622
-
2623
-
2624
- }).call(this);
2625
- (function() {
2626
-
3221
+ Luca.containers.Viewport.defaultWrapperClass = 'row';
2627
3222
 
3223
+ Luca.containers.Viewport.fluidWrapperClass = 'row-fluid';
2628
3224
 
2629
3225
  }).call(this);
2630
3226
  (function() {
@@ -2676,13 +3272,15 @@
2676
3272
  Luca.Application.instances[appName] = app;
2677
3273
  Luca.containers.Viewport.prototype.initialize.apply(this, arguments);
2678
3274
  this.state = new Luca.Model(this.defaultState);
2679
- this.setupMainController();
3275
+ if (this.useController === true) this.setupMainController();
2680
3276
  this.setupCollectionManager();
2681
3277
  this.defer(function() {
2682
3278
  return app.render();
2683
3279
  }).until(this, "ready");
2684
3280
  this.setupRouter();
2685
- console.log("The useKeyRouter property is being deprecated. switch to useKeyHandler instead");
3281
+ if (this.useKeyRouter === true) {
3282
+ console.log("The useKeyRouter property is being deprecated. switch to useKeyHandler instead");
3283
+ }
2686
3284
  if ((this.useKeyHandler === true || this.useKeyRouter === true) && (this.keyEvents != null)) {
2687
3285
  this.setupKeyHandler();
2688
3286
  }
@@ -2758,29 +3356,32 @@
2758
3356
  source = control ? this.keyEvents.control : source;
2759
3357
  source = meta && control ? this.keyEvents.meta_control : source;
2760
3358
  if (keyEvent = source != null ? source[keyname] : void 0) {
2761
- if (this[keyEvent] != null) {
3359
+ if ((this[keyEvent] != null) && _.isFunction(this[keyEvent])) {
2762
3360
  return (_ref = this[keyEvent]) != null ? _ref.call(this) : void 0;
2763
3361
  } else {
2764
- return this.trigger(keyEvent);
3362
+ return this.trigger(keyEvent, e, keyname);
2765
3363
  }
2766
3364
  }
2767
3365
  },
2768
3366
  setupControllerBindings: function() {
2769
- var _ref, _ref2,
3367
+ var app, _ref, _ref2,
2770
3368
  _this = this;
3369
+ app = this;
2771
3370
  if ((_ref = this.getMainController()) != null) {
2772
3371
  _ref.bind("after:card:switch", function(previous, current) {
2773
- return _this.state.set({
3372
+ _this.state.set({
2774
3373
  active_section: current.name
2775
3374
  });
3375
+ return app.trigger("page:change");
2776
3376
  });
2777
3377
  }
2778
3378
  return (_ref2 = this.getMainController()) != null ? _ref2.each(function(component) {
2779
3379
  if (component.ctype.match(/controller$/)) {
2780
3380
  return component.bind("after:card:switch", function(previous, current) {
2781
- return _this.state.set({
3381
+ _this.state.set({
2782
3382
  active_sub_section: current.name
2783
3383
  });
3384
+ return app.trigger("sub:page:change");
2784
3385
  });
2785
3386
  }
2786
3387
  }) : void 0;
@@ -2838,14 +3439,20 @@
2838
3439
  }
2839
3440
  },
2840
3441
  setupKeyHandler: function() {
2841
- var handler, _base;
3442
+ var handler, keyEvent, _base, _i, _len, _ref, _results;
2842
3443
  if (!this.keyEvents) return;
2843
3444
  (_base = this.keyEvents).control_meta || (_base.control_meta = {});
2844
3445
  if (this.keyEvents.meta_control) {
2845
3446
  _.extend(this.keyEvents.control_meta, this.keyEvents.meta_control);
2846
3447
  }
2847
3448
  handler = _.bind(this.keyHandler, this);
2848
- return $(document).keydown(handler);
3449
+ _ref = this.keypressEvents || ["keydown"];
3450
+ _results = [];
3451
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
3452
+ keyEvent = _ref[_i];
3453
+ _results.push($(document).on(keyEvent, handler));
3454
+ }
3455
+ return _results;
2849
3456
  }
2850
3457
  });
2851
3458
 
@@ -2853,7 +3460,7 @@
2853
3460
  (function() {
2854
3461
 
2855
3462
  _.def('Luca.components.Toolbar')["extends"]('Luca.core.Container')["with"]({
2856
- className: 'luca-ui-toolbar',
3463
+ className: 'luca-ui-toolbar toolbar',
2857
3464
  position: 'bottom',
2858
3465
  initialize: function(options) {
2859
3466
  this.options = options != null ? options : {};
@@ -2908,19 +3515,25 @@
2908
3515
 
2909
3516
  }).call(this);
2910
3517
  (function() {
2911
- var make;
3518
+ var collectionView, make, setupChangeObserver;
2912
3519
 
2913
- make = Luca.View.prototype.make;
3520
+ collectionView = Luca.define("Luca.components.CollectionView");
3521
+
3522
+ collectionView["extends"]("Luca.components.Panel");
2914
3523
 
2915
- _.def("Luca.components.CollectionView")["extends"]("Luca.components.Panel")["with"]({
2916
- tagName: "div",
3524
+ collectionView.behavesAs("LoadMaskable", "Filterable", "Paginatable");
3525
+
3526
+ collectionView.defaultsTo({
3527
+ tagName: "ol",
2917
3528
  className: "luca-ui-collection-view",
2918
3529
  bodyClassName: "collection-ui-panel",
2919
3530
  itemTemplate: void 0,
2920
3531
  itemRenderer: void 0,
2921
3532
  itemTagName: 'li',
2922
3533
  itemClassName: 'collection-item',
3534
+ hooks: ["before:refresh", "empty:results", "after:refresh"],
2923
3535
  initialize: function(options) {
3536
+ var _this = this;
2924
3537
  this.options = options != null ? options : {};
2925
3538
  _.extend(this, this.options);
2926
3539
  _.bindAll(this, "refresh");
@@ -2932,58 +3545,110 @@
2932
3545
  }
2933
3546
  Luca.components.Panel.prototype.initialize.apply(this, arguments);
2934
3547
  if (_.isString(this.collection) && Luca.CollectionManager.get()) {
2935
- this.collection = Luca.CollectionManager.get().get(this.collection);
3548
+ this.collection = Luca.CollectionManager.get().getOrCreate(this.collection);
3549
+ }
3550
+ if (!Luca.isBackboneCollection(this.collection)) {
3551
+ throw "Collection Views must have a valid backbone collection";
3552
+ this.collection.on("before:fetch", function() {
3553
+ if (_this.loadMask === true) return _this.trigger("enable:loadmask");
3554
+ });
3555
+ this.collection.bind("reset", function() {
3556
+ _this.trigger("collection:change");
3557
+ if (_this.loadMask === true) return _this.trigger("disable:loadmask");
3558
+ });
3559
+ this.collection.bind("remove", function() {
3560
+ return _this.trigger("collection:change");
3561
+ });
3562
+ this.collection.bind("add", function() {
3563
+ return _this.trigger("collection:change");
3564
+ });
3565
+ if (this.observeChanges === true) setupChangeObserver.call(this);
2936
3566
  }
2937
- if (Luca.isBackboneCollection(this.collection)) {
2938
- this.collection.bind("reset", this.refresh);
2939
- this.collection.bind("add", this.refresh);
2940
- return this.collection.bind("remove", this.refresh);
3567
+ if (this.autoRefreshOnModelsPresent !== false) {
3568
+ this.defer(function() {
3569
+ if (_this.collection.length > 0) return _this.refresh();
3570
+ }).until("after:render");
2941
3571
  }
3572
+ return this.on("collection:change", this.refresh, this);
2942
3573
  },
2943
- attributesForItem: function(item) {
3574
+ attributesForItem: function(item, model) {
2944
3575
  return _.extend({}, {
2945
3576
  "class": this.itemClassName,
2946
- "data-index": item.index
3577
+ "data-index": item.index,
3578
+ "data-model-id": item.model.get('id')
2947
3579
  });
2948
3580
  },
2949
3581
  contentForItem: function(item) {
2950
3582
  var content, templateFn;
2951
3583
  if (item == null) item = {};
2952
3584
  if ((this.itemTemplate != null) && (templateFn = Luca.template(this.itemTemplate))) {
2953
- content = templateFn.call(this, item);
3585
+ return content = templateFn.call(this, item);
2954
3586
  }
2955
3587
  if ((this.itemRenderer != null) && _.isFunction(this.itemRenderer)) {
2956
- content = this.itemRenderer.call(this, item, item.model, item.index);
3588
+ return content = this.itemRenderer.call(this, item, item.model, item.index);
2957
3589
  }
2958
- if (this.itemProperty) {
2959
- content = item.model.get(this.itemProperty) || item.model[this.itemProperty];
2960
- if (_.isFunction(content)) content = content();
3590
+ if (this.itemProperty && (item.model != null)) {
3591
+ return content = item.model.read(this.itemProperty);
2961
3592
  }
2962
- return content;
3593
+ return "";
2963
3594
  },
2964
3595
  makeItem: function(model, index) {
2965
- var item;
3596
+ var attributes, content, item;
2966
3597
  item = this.prepareItem != null ? this.prepareItem.call(this, model, index) : {
2967
3598
  model: model,
2968
3599
  index: index
2969
3600
  };
2970
- return make(this.itemTagName, this.attributesForItem(item), this.contentForItem(item));
3601
+ attributes = this.attributesForItem(item, model);
3602
+ content = this.contentForItem(item);
3603
+ try {
3604
+ return make(this.itemTagName, attributes, content);
3605
+ } catch (e) {
3606
+ return console.log("Error generating DOM element for CollectionView", this, model, index);
3607
+ }
3608
+ },
3609
+ getCollection: function() {
3610
+ return this.collection;
3611
+ },
3612
+ getQuery: function() {
3613
+ return {};
2971
3614
  },
2972
- getModels: function() {
3615
+ getQueryOptions: function() {
3616
+ return {};
3617
+ },
3618
+ getModels: function(query, options) {
2973
3619
  var _ref;
2974
- if (((_ref = this.collection) != null ? _ref.query : void 0) && (this.filter || this.filterOptions)) {
2975
- return this.collection.query(this.filter, this.filterOptions);
3620
+ if ((_ref = this.collection) != null ? _ref.query : void 0) {
3621
+ query || (query = this.getQuery());
3622
+ options || (options = this.getQueryOptions());
3623
+ return this.collection.query(query, options);
2976
3624
  } else {
2977
3625
  return this.collection.models;
2978
3626
  }
2979
3627
  },
2980
- refresh: function() {
2981
- var panel;
2982
- panel = this;
3628
+ locateItemElement: function(id) {
3629
+ return this.$("." + this.itemClassName + "[data-model-id='" + id + "']");
3630
+ },
3631
+ refreshModel: function(model) {
3632
+ var index;
3633
+ index = this.collection.indexOf(model);
3634
+ return this.locateItemElement(model.get('id')).empty().append(this.contentForItem({
3635
+ model: model,
3636
+ index: index
3637
+ }, model));
3638
+ },
3639
+ refresh: function(query, options) {
3640
+ var index, model, models, _i, _len;
2983
3641
  this.$bodyEl().empty();
2984
- return _(this.getModels()).each(function(model, index) {
2985
- return panel.$append(panel.makeItem(model, index));
2986
- });
3642
+ models = this.getModels(query, options);
3643
+ this.trigger("before:refresh", models, query, options);
3644
+ if (models.length === 0) this.trigger("empty:results");
3645
+ index = 0;
3646
+ for (_i = 0, _len = models.length; _i < _len; _i++) {
3647
+ model = models[_i];
3648
+ this.$append(this.makeItem(model, index++));
3649
+ }
3650
+ this.trigger("after:refresh", models, query, options);
3651
+ return this;
2987
3652
  },
2988
3653
  registerEvent: function(domEvent, selector, handler) {
2989
3654
  var eventTrigger;
@@ -2996,12 +3661,20 @@
2996
3661
  },
2997
3662
  render: function() {
2998
3663
  this.refresh();
2999
- if (this.$el.parent().length > 0 && (this.container != null)) {
3000
- return this.$attach();
3001
- }
3664
+ if (this.$el.parent().length > 0 && (this.container != null)) this.$attach();
3665
+ return this;
3002
3666
  }
3003
3667
  });
3004
3668
 
3669
+ make = Luca.View.prototype.make;
3670
+
3671
+ setupChangeObserver = function() {
3672
+ var _this = this;
3673
+ return this.collection.on("change", function(model) {
3674
+ return _this.refreshModel(model);
3675
+ });
3676
+ };
3677
+
3005
3678
  }).call(this);
3006
3679
  (function() {
3007
3680
 
@@ -3241,20 +3914,20 @@
3241
3914
  events: {
3242
3915
  "change input": "change_handler"
3243
3916
  },
3917
+ className: 'luca-ui-checkbox-field luca-ui-field',
3918
+ template: 'fields/checkbox_field',
3919
+ hooks: ["checked", "unchecked"],
3920
+ send_blanks: true,
3244
3921
  change_handler: function(e) {
3245
3922
  var me, my;
3246
- me = my = $(e.currentTarget);
3247
- this.trigger("on:change", this, e);
3248
- if (me.checked === true) {
3249
- return this.trigger("checked");
3923
+ me = my = $(e.target);
3924
+ if (me.is(":checked")) {
3925
+ this.trigger("checked");
3250
3926
  } else {
3251
- return this.trigger("unchecked");
3927
+ this.trigger("unchecked");
3252
3928
  }
3929
+ return this.trigger("on:change", this, e, me.is(":checked"));
3253
3930
  },
3254
- className: 'luca-ui-checkbox-field luca-ui-field',
3255
- template: 'fields/checkbox_field',
3256
- hooks: ["checked", "unchecked"],
3257
- send_blanks: true,
3258
3931
  initialize: function(options) {
3259
3932
  this.options = options != null ? options : {};
3260
3933
  _.extend(this, this.options);
@@ -3271,7 +3944,7 @@
3271
3944
  return this.input.attr('checked', checked);
3272
3945
  },
3273
3946
  getValue: function() {
3274
- return this.input.attr('checked') === true;
3947
+ return this.input.is(":checked");
3275
3948
  }
3276
3949
  });
3277
3950
 
@@ -3309,6 +3982,25 @@
3309
3982
  }
3310
3983
  });
3311
3984
 
3985
+ }).call(this);
3986
+ (function() {
3987
+
3988
+ _.def("Luca.components.LabelField")["extends"]("Luca.core.Field")["with"]({
3989
+ className: "luca-ui-field luca-ui-label-field",
3990
+ getValue: function() {
3991
+ return this.$('input').attr('value');
3992
+ },
3993
+ formatter: function(value) {
3994
+ value || (value = this.getValue());
3995
+ return _.str.titleize(value);
3996
+ },
3997
+ setValue: function(value) {
3998
+ this.trigger("change", value, this.getValue());
3999
+ this.$('input').attr('value', value);
4000
+ return this.$('.value').html(this.formatter(value));
4001
+ }
4002
+ });
4003
+
3312
4004
  }).call(this);
3313
4005
  (function() {
3314
4006
 
@@ -3355,7 +4047,7 @@
3355
4047
  if (!_.isArray(record)) return record;
3356
4048
  hash = {};
3357
4049
  hash[_this.valueField] = record[0];
3358
- hash[_this.displayField] = record[1];
4050
+ hash[_this.displayField] = record[1] || record[0];
3359
4051
  return hash;
3360
4052
  });
3361
4053
  },
@@ -3423,6 +4115,7 @@
3423
4115
  this.input_name || (this.input_name = this.name);
3424
4116
  this.label || (this.label = this.name);
3425
4117
  this.input_class || (this.input_class = this["class"]);
4118
+ this.input_value || (this.input_value = "");
3426
4119
  return this.inputStyles || (this.inputStyles = "height:" + this.height + ";width:" + this.width);
3427
4120
  },
3428
4121
  setValue: function(value) {
@@ -3450,11 +4143,6 @@
3450
4143
 
3451
4144
  }).call(this);
3452
4145
  (function() {
3453
- var change_handler;
3454
-
3455
- change_handler = function(e) {
3456
- return this.trigger("on:change", this, e);
3457
- };
3458
4146
 
3459
4147
  _.def('Luca.fields.TextField')["extends"]('Luca.core.Field')["with"]({
3460
4148
  events: {
@@ -3465,13 +4153,15 @@
3465
4153
  template: 'fields/text_field',
3466
4154
  autoBindEventHandlers: true,
3467
4155
  send_blanks: true,
4156
+ keyEventThrottle: 300,
3468
4157
  initialize: function(options) {
3469
4158
  this.options = options != null ? options : {};
3470
- Luca.core.Field.prototype.initialize.apply(this, arguments);
4159
+ if (this.enableKeyEvents) this.registerEvent("keyup input", "keyup_handler");
3471
4160
  this.input_id || (this.input_id = _.uniqueId('field'));
3472
4161
  this.input_name || (this.input_name = this.name);
3473
4162
  this.label || (this.label = this.name);
3474
4163
  this.input_class || (this.input_class = this["class"]);
4164
+ this.input_value || (this.input_value = this.value || "");
3475
4165
  if (this.prepend) {
3476
4166
  this.$el.addClass('input-prepend');
3477
4167
  this.addOn = this.prepend;
@@ -3480,22 +4170,20 @@
3480
4170
  this.$el.addClass('input-append');
3481
4171
  this.addOn = this.append;
3482
4172
  }
3483
- if (this.enableKeyEvents) {
3484
- return this.registerEvent("keydown input", "keydown_handler");
3485
- }
4173
+ return Luca.core.Field.prototype.initialize.apply(this, arguments);
4174
+ },
4175
+ keyup_handler: function(e) {
4176
+ return this.trigger("on:keyup", this, e);
3486
4177
  },
3487
4178
  blur_handler: function(e) {
3488
- var me, my;
3489
- return me = my = $(e.currentTarget);
4179
+ return this.trigger("on:blur", this, e);
3490
4180
  },
3491
4181
  focus_handler: function(e) {
3492
- var me, my;
3493
- return me = my = $(e.currentTarget);
4182
+ return this.trigger("on:focus", this, e);
3494
4183
  },
3495
- change_handler: change_handler,
3496
- keydown_handler: _.throttle((function(e) {
3497
- return change_handler.apply(this, arguments);
3498
- }), 300)
4184
+ change_handler: function(e) {
4185
+ return this.trigger("on:change", this, e);
4186
+ }
3499
4187
  });
3500
4188
 
3501
4189
  }).call(this);
@@ -3504,6 +4192,7 @@
3504
4192
  _.def('Luca.fields.TypeAheadField')["extends"]('Luca.fields.TextField')["with"]({
3505
4193
  className: 'luca-ui-field',
3506
4194
  getSource: function() {
4195
+ if (_.isFunction(this.source)) return this.source.call(this);
3507
4196
  return this.source || [];
3508
4197
  },
3509
4198
  matcher: function(item) {
@@ -3587,10 +4276,12 @@
3587
4276
  toolbar: true,
3588
4277
  legend: "",
3589
4278
  bodyClassName: "form-view-body",
4279
+ version: "0.9.33333333",
3590
4280
  initialize: function(options) {
3591
4281
  this.options = options != null ? options : {};
3592
4282
  if (this.loadMask == null) this.loadMask = Luca.enableBootstrap;
3593
4283
  Luca.core.Container.prototype.initialize.apply(this, arguments);
4284
+ this.components || (this.components = this.fields);
3594
4285
  _.bindAll(this, "submitHandler", "resetHandler", "renderToolbars", "applyLoadMask");
3595
4286
  this.state || (this.state = new Backbone.Model);
3596
4287
  this.setupHooks(this.hooks);
@@ -3652,17 +4343,22 @@
3652
4343
  return _(this.getFields()).map(iterator);
3653
4344
  },
3654
4345
  getField: function(name) {
3655
- return _(this.getFields('name', name)).first();
4346
+ var passOne;
4347
+ passOne = _(this.getFields('name', name)).first();
4348
+ if (passOne != null) return passOne;
4349
+ return _(this.getFields('input_name', name)).first();
3656
4350
  },
3657
4351
  getFields: function(attr, value) {
3658
4352
  var fields;
3659
- fields = this.select("isField", true, true);
3660
- if (!(attr && value)) return fields;
3661
- _(fields).select(function(field) {
3662
- var property;
3663
- property = field[attr];
3664
- return (property != null) && value === (_.isFunction(property) ? property() : property);
3665
- });
4353
+ fields = this.selectByAttribute("isField", true, true);
4354
+ if ((attr != null) && (value != null)) {
4355
+ fields = _(fields).select(function(field) {
4356
+ var property;
4357
+ property = field[attr];
4358
+ if (_.isFunction(property)) property = property.call(field);
4359
+ return property === value;
4360
+ });
4361
+ }
3666
4362
  return fields;
3667
4363
  },
3668
4364
  loadModel: function(current_model) {
@@ -3718,22 +4414,32 @@
3718
4414
  if ((options.silent != null) !== true) return this.syncFormWithModel();
3719
4415
  },
3720
4416
  getValues: function(options) {
4417
+ var values,
4418
+ _this = this;
3721
4419
  if (options == null) options = {};
3722
4420
  if (options.reject_blank == null) options.reject_blank = true;
3723
4421
  if (options.skip_buttons == null) options.skip_buttons = true;
3724
- return _(this.getFields()).inject(function(memo, field) {
3725
- var key, skip, value;
4422
+ if (options.blanks === false) options.reject_blank = true;
4423
+ values = _(this.getFields()).inject(function(memo, field) {
4424
+ var allowBlankValues, key, skip, value, valueIsBlank;
3726
4425
  value = field.getValue();
3727
4426
  key = field.input_name || field.name;
3728
- skip = false;
3729
- if (options.skip_buttons && field.ctype === "button_field") skip = true;
3730
- if (_.string.isBlank(value)) {
3731
- if (options.reject_blank && !field.send_blanks) skip = true;
3732
- if (field.input_name === "id") skip = true;
4427
+ valueIsBlank = !!(_.str.isBlank(value) || _.isUndefined(value));
4428
+ allowBlankValues = !options.reject_blank && !field.send_blanks;
4429
+ if (options.debug) {
4430
+ console.log("" + key + " Options", options, "Value", value, "Value Is Blank?", valueIsBlank, "Allow Blanks?", allowBlankValues);
3733
4431
  }
4432
+ if (options.skip_buttons && field.ctype === "button_field") {
4433
+ skip = true;
4434
+ } else {
4435
+ if (valueIsBlank && allowBlankValues === false) skip = true;
4436
+ if (field.input_name === "id" && valueIsBlank === true) skip = true;
4437
+ }
4438
+ if (options.debug) console.log("Skip is true on " + key);
3734
4439
  if (skip !== true) memo[key] = value;
3735
4440
  return memo;
3736
- }, {});
4441
+ }, options.defaults || {});
4442
+ return values;
3737
4443
  },
3738
4444
  submit_success_handler: function(model, response, xhr) {
3739
4445
  this.trigger("after:submit", this, model, response);
@@ -4081,6 +4787,124 @@
4081
4787
  }
4082
4788
  });
4083
4789
 
4790
+ }).call(this);
4791
+ (function() {
4792
+
4793
+ _.def("Luca.PageController")["extends"]("Luca.components.Controller")["with"]({
4794
+ version: 2
4795
+ });
4796
+
4797
+ }).call(this);
4798
+ (function() {
4799
+ var paginationControl;
4800
+
4801
+ paginationControl = Luca.define("Luca.components.PaginationControl");
4802
+
4803
+ paginationControl["extends"]("Luca.View");
4804
+
4805
+ paginationControl.defaultsTo({
4806
+ template: "components/pagination",
4807
+ stateful: true,
4808
+ autoBindEventHandlers: true,
4809
+ events: {
4810
+ "click a[data-page-number]": "selectPage",
4811
+ "click a.next": "nextPage",
4812
+ "click a.prev": "previousPage"
4813
+ },
4814
+ afterInitialize: function() {
4815
+ return this.state.on("change", this.refresh, this);
4816
+ },
4817
+ limit: function() {
4818
+ var _ref;
4819
+ return parseInt(this.state.get('limit') || ((_ref = this.collection) != null ? _ref.length : void 0));
4820
+ },
4821
+ page: function() {
4822
+ return parseInt(this.state.get('page') || 1);
4823
+ },
4824
+ nextPage: function() {
4825
+ if (!this.nextEnabled()) return;
4826
+ return this.state.set('page', this.page() + 1);
4827
+ },
4828
+ previousPage: function() {
4829
+ if (!this.previousEnabled()) return;
4830
+ return this.state.set('page', this.page() - 1);
4831
+ },
4832
+ selectPage: function(e) {
4833
+ var me, my;
4834
+ me = my = this.$(e.target);
4835
+ if (!me.is('a.page')) me = my = my.closest('a.page');
4836
+ my.siblings().removeClass('is-selected');
4837
+ me.addClass('is-selected');
4838
+ return this.setPage(my.data('page-number'));
4839
+ },
4840
+ setPage: function(page, options) {
4841
+ if (page == null) page = 1;
4842
+ if (options == null) options = {};
4843
+ return this.state.set('page', page, options);
4844
+ },
4845
+ setLimit: function(limit, options) {
4846
+ if (limit == null) limit = 1;
4847
+ if (options == null) options = {};
4848
+ return this.state.set('limit', limit, options);
4849
+ },
4850
+ pageButtonContainer: function() {
4851
+ return this.$('.group');
4852
+ },
4853
+ previousEnabled: function() {
4854
+ return this.page() > 1;
4855
+ },
4856
+ nextEnabled: function() {
4857
+ return this.page() < this.totalPages();
4858
+ },
4859
+ previousButton: function() {
4860
+ return this.$('a.page.prev');
4861
+ },
4862
+ nextButton: function() {
4863
+ return this.$('a.page.next');
4864
+ },
4865
+ pageButtons: function() {
4866
+ return this.$('a[data-page-number]', this.pageButtonContainer());
4867
+ },
4868
+ refresh: function() {
4869
+ var button, page, _ref;
4870
+ this.pageButtonContainer().empty();
4871
+ for (page = 1, _ref = this.totalPages(); 1 <= _ref ? page <= _ref : page >= _ref; 1 <= _ref ? page++ : page--) {
4872
+ button = this.make("a", {
4873
+ "data-page-number": page,
4874
+ "class": "page"
4875
+ }, page);
4876
+ this.pageButtonContainer().append(button);
4877
+ }
4878
+ this.toggleNavigationButtons();
4879
+ return this.selectActivePageButton();
4880
+ },
4881
+ toggleNavigationButtons: function() {
4882
+ this.$('a.next, a.prev').addClass('disabled');
4883
+ if (this.nextEnabled()) this.nextButton().removeClass('disabled');
4884
+ if (this.previousEnabled()) {
4885
+ return this.previousButton().removeClass('disabled');
4886
+ }
4887
+ },
4888
+ selectActivePageButton: function() {
4889
+ return this.activePageButton().addClass('is-selected');
4890
+ },
4891
+ activePageButton: function() {
4892
+ return this.pageButtons().filter("[data-page-number='" + (this.page()) + "']");
4893
+ },
4894
+ totalPages: function() {
4895
+ return parseInt(Math.ceil(this.totalItems() / this.itemsPerPage()));
4896
+ },
4897
+ totalItems: function() {
4898
+ var _ref;
4899
+ return parseInt(((_ref = this.collection) != null ? _ref.length : void 0) || 0);
4900
+ },
4901
+ itemsPerPage: function(value, options) {
4902
+ if (options == null) options = {};
4903
+ if (value != null) this.set("limit", value, options);
4904
+ return parseInt(this.get("limit"));
4905
+ }
4906
+ });
4907
+
4084
4908
  }).call(this);
4085
4909
  (function() {
4086
4910
 
@@ -4324,6 +5148,105 @@
4324
5148
  }
4325
5149
  });
4326
5150
 
5151
+ }).call(this);
5152
+ (function() {
5153
+ var make;
5154
+
5155
+ _.def("Luca.components.TableView")["extends"]("Luca.components.CollectionView")["with"]({
5156
+ additionalClassNames: "table",
5157
+ tagName: "table",
5158
+ bodyTemplate: "table_view",
5159
+ bodyTagName: "tbody",
5160
+ bodyClassName: "table-body",
5161
+ itemTagName: "tr",
5162
+ stateful: true,
5163
+ observeChanges: true,
5164
+ columns: [],
5165
+ emptyText: "There are no results to display",
5166
+ itemRenderer: function(item, model) {
5167
+ return Luca.components.TableView.rowRenderer.call(this, item, model);
5168
+ },
5169
+ initialize: function(options) {
5170
+ var column,
5171
+ _this = this;
5172
+ this.options = options != null ? options : {};
5173
+ Luca.components.CollectionView.prototype.initialize.apply(this, arguments);
5174
+ this.columns = (function() {
5175
+ var _i, _len, _ref, _results;
5176
+ _ref = this.columns;
5177
+ _results = [];
5178
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
5179
+ column = _ref[_i];
5180
+ if (_.isString(column)) {
5181
+ column = {
5182
+ reader: column
5183
+ };
5184
+ }
5185
+ if (!(column.header != null)) {
5186
+ column.header = _.str.titleize(_.str.humanize(column.reader));
5187
+ }
5188
+ _results.push(column);
5189
+ }
5190
+ return _results;
5191
+ }).call(this);
5192
+ return this.defer(function() {
5193
+ return Luca.components.TableView.renderHeader.call(_this, _this.columns, _this.$('thead'));
5194
+ }).until("after:render");
5195
+ }
5196
+ });
5197
+
5198
+ make = Backbone.View.prototype.make;
5199
+
5200
+ Luca.components.TableView.renderHeader = function(columns, targetElement) {
5201
+ var column, content, index, _i, _len, _results;
5202
+ index = 0;
5203
+ content = (function() {
5204
+ var _i, _len, _results;
5205
+ _results = [];
5206
+ for (_i = 0, _len = columns.length; _i < _len; _i++) {
5207
+ column = columns[_i];
5208
+ _results.push("<th data-col-index='" + (index++) + "'>" + column.header + "</th>");
5209
+ }
5210
+ return _results;
5211
+ })();
5212
+ console.log("one");
5213
+ this.$(targetElement).append(make("tr", {}, content));
5214
+ console.log("two");
5215
+ index = 0;
5216
+ console.log("three");
5217
+ _results = [];
5218
+ for (_i = 0, _len = columns.length; _i < _len; _i++) {
5219
+ column = columns[_i];
5220
+ if (column.width != null) {
5221
+ _results.push(this.$("th[data-col-index='" + (index++) + "']", targetElement).css('width', column.width));
5222
+ }
5223
+ }
5224
+ return _results;
5225
+ };
5226
+
5227
+ Luca.components.TableView.rowRenderer = function(item, model, index) {
5228
+ var colIndex, columnConfig, _i, _len, _ref, _results;
5229
+ colIndex = 0;
5230
+ _ref = this.columns;
5231
+ _results = [];
5232
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
5233
+ columnConfig = _ref[_i];
5234
+ _results.push(Luca.components.TableView.renderColumn.call(this, columnConfig, item, model, colIndex++));
5235
+ }
5236
+ return _results;
5237
+ };
5238
+
5239
+ Luca.components.TableView.renderColumn = function(column, item, model, index) {
5240
+ var cellValue;
5241
+ cellValue = model.read(column.reader);
5242
+ if (_.isFunction(column.renderer)) {
5243
+ cellValue = column.renderer.call(this, cellValue, model, column);
5244
+ }
5245
+ return make("td", {
5246
+ "data-col-index": index
5247
+ }, cellValue);
5248
+ };
5249
+
4327
5250
  }).call(this);
4328
5251
  (function() {
4329
5252
 
@@ -4365,6 +5288,19 @@
4365
5288
 
4366
5289
 
4367
5290
 
5291
+ }).call(this);
5292
+
5293
+
5294
+
5295
+ (function() {
5296
+
5297
+
5298
+
5299
+ }).call(this);
5300
+ (function() {
5301
+
5302
+
5303
+
4368
5304
  }).call(this);
4369
5305
  (function() {
4370
5306
 
@@ -4508,6 +5444,25 @@
4508
5444
 
4509
5445
 
4510
5446
 
5447
+ }).call(this);
5448
+ (function() {
5449
+
5450
+ describe('The Table View', function() {
5451
+ beforeEach(function() {
5452
+ this.tableView = new Luca.components.TableView({
5453
+ collection: new Luca.Collection,
5454
+ columns: ["column_one", "column_two"]
5455
+ });
5456
+ return $('body').append(this.tableView.render());
5457
+ });
5458
+ it('should accept strings for column config', function() {
5459
+ return expect(this.tableView.columns[0].reader).toEqual("column_one");
5460
+ });
5461
+ return it('should automatically determine a missing header config', function() {
5462
+ return expect(this.tableView.columns[0].header).toBeDefined();
5463
+ });
5464
+ });
5465
+
4511
5466
  }).call(this);
4512
5467
  (function() {
4513
5468
 
@@ -4983,16 +5938,22 @@
4983
5938
 
4984
5939
  describe('The Luca Container', function() {
4985
5940
  beforeEach(function() {
4986
- return this.container = new Luca.core.Container({
5941
+ var c;
5942
+ return c = this.container = new Luca.core.Container({
5943
+ defaults: {
5944
+ defaultProperty: 'it_works'
5945
+ },
4987
5946
  components: [
4988
5947
  {
4989
5948
  name: "component_one",
4990
5949
  ctype: "view",
5950
+ defaultProperty: "oh_yeah",
4991
5951
  bodyTemplate: function() {
4992
5952
  return "markup for component one";
4993
5953
  },
4994
5954
  id: "c1",
4995
5955
  value: 1,
5956
+ getter: "getOne",
4996
5957
  spy: sinon.spy()
4997
5958
  }, {
4998
5959
  name: "component_two",
@@ -5044,7 +6005,7 @@
5044
6005
  });
5045
6006
  it("should select all components matching a key/value combo", function() {
5046
6007
  var components;
5047
- components = this.container.select("value", 1);
6008
+ components = this.container.selectByAttribute("value", 1);
5048
6009
  return expect(components.length).toEqual(2);
5049
6010
  });
5050
6011
  it("should run a function on each component", function() {
@@ -5222,9 +6183,12 @@
5222
6183
  });
5223
6184
  });
5224
6185
 
5225
- describe("Introspection Helpers", function() {
6186
+ describe("Development Tool Helpers", function() {
5226
6187
  beforeEach(function() {
5227
- return this.view = new Luca.View({
6188
+ _.def("Luca.views.IntrospectionView")["extends"]("Luca.View")["with"]({
6189
+ include: ["Luca.DevelopmentToolHelpers"]
6190
+ });
6191
+ return this.view = new Luca.views.IntrospectionView({
5228
6192
  events: {
5229
6193
  "click .a": "clickHandler",
5230
6194
  "hover .a": "hoverHandler"
@@ -5379,16 +6343,6 @@
5379
6343
  this.manager || (this.manager = new SampleManager());
5380
6344
  return this.collection = this.manager.getOrCreate("sample");
5381
6345
  });
5382
- it("should know which collection manager to use", function() {
5383
- var view;
5384
- view = new SampleView();
5385
- return expect(view.getCollectionManager().name).toEqual("collectionEvents");
5386
- });
5387
- it("should create a reference to the collection", function() {
5388
- var view;
5389
- view = new SampleView();
5390
- return expect(view.sampleCollection).toBeDefined();
5391
- });
5392
6346
  return it("should call the resetHandler callback on the view", function() {
5393
6347
  var collection, view;
5394
6348
  view = new SampleView();
@@ -5398,12 +6352,6 @@
5398
6352
  });
5399
6353
  });
5400
6354
 
5401
- describe("Code Refresh", function() {
5402
- beforeEach(function() {});
5403
- it("should reference the event handler function property names", function() {});
5404
- return it("should reference the event handler functions", function() {});
5405
- });
5406
-
5407
6355
  }).call(this);
5408
6356
  (function() {
5409
6357
  var EventMatchers, ModelMatchers, createFakeServer, eventBucket, getMatcherFunction, i, j, json, matcherName, msg, sinonName, spyMatcherHash, spyMatchers, triggerSpy, unusualMatchers;
@@ -5719,22 +6667,18 @@
5719
6667
  collectionNamespace: App.collections
5720
6668
  });
5721
6669
  });
5722
- it("should be defined", function() {
5723
- return expect(Luca.CollectionManager).toBeDefined();
5724
- });
5725
6670
  it("should make the latest instance accessible by class function", function() {
5726
6671
  return expect(Luca.CollectionManager.get().name).toEqual("manager");
5727
6672
  });
5728
- it("should be able to guess a collection constructor class", function() {
5729
- var base;
5730
- base = this.manager.guessCollectionClass("sample_collection");
5731
- return expect(base).toEqual(App.collections.SampleCollection);
5732
- });
5733
- return it("should create a collection on demand", function() {
6673
+ it("should create a collection on demand", function() {
5734
6674
  var collection;
5735
6675
  collection = this.manager.getOrCreate("sample_collection");
5736
6676
  return expect(collection.url).toEqual("/models");
5737
6677
  });
6678
+ return it("should destroy a collection", function() {
6679
+ this.manager.destroy("sample_collection");
6680
+ return expect(this.manager.get("sample_collection")).toBeUndefined();
6681
+ });
5738
6682
  });
5739
6683
 
5740
6684
  describe("Adding Collections", function() {
@@ -5854,6 +6798,15 @@
5854
6798
 
5855
6799
 
5856
6800
 
6801
+ }).call(this);
6802
+ (function() {
6803
+
6804
+ describe('The Mixin System', function() {
6805
+ it('Should not extend the prototype with the initializer', function() {});
6806
+ it('Should fire the intializer when an instance is created', function() {});
6807
+ return describe('The Initializer on extended classes', function() {});
6808
+ });
6809
+
5857
6810
  }).call(this);
5858
6811
  (function() {
5859
6812